file_close (void * handle, void * data)
{
  unsigned int D.12203;
  unsigned int D.12204;
  gchar * D.12207;
  struct _WapiFileShare * D.12208;
  struct _WapiHandle_file * file_handle;
  int fd;

  file_handle = data;
  fd = file_handle->fd;
  D.12203 = file_handle->attrs;
  D.12204 = D.12203 & 67108864;
  if (D.12204 != 0) goto <D.12205>; else goto <D.12206>;
  <D.12205>:
  D.12207 = file_handle->filename;
  _wapi_unlink (D.12207);
  <D.12206>:
  D.12207 = file_handle->filename;
  monoeg_g_free (D.12207);
  D.12208 = file_handle->share_info;
  if (D.12208 != 0B) goto <D.12209>; else goto <D.12210>;
  <D.12209>:
  D.12208 = file_handle->share_info;
  _wapi_handle_share_release (D.12208);
  <D.12210>:
  close (fd);
}


_wapi_handle_share_release (struct _WapiFileShare * info)
{
  unsigned int D.12211;
  _Bool D.12212;
  long int D.12213;
  long int D.12214;
  _Bool D.12217;
  long int D.12218;
  long int D.12219;
  guint32 * D.12222;
  int D.12223;
  int thr_ret;

  D.12211 = info->handle_refs;
  D.12212 = D.12211 == 0;
  D.12213 = (long int) D.12212;
  D.12214 = __builtin_expect (D.12213, 0);
  if (D.12214 != 0) goto <D.12215>; else goto <D.12216>;
  <D.12215>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "../../mono/io-layer/handles-private.h", 364, "info->handle_refs > 0");
  <D.12216>:
  thr_ret = _wapi_shm_sem_lock (2);
  D.12217 = thr_ret != 0;
  D.12218 = (long int) D.12217;
  D.12219 = __builtin_expect (D.12218, 0);
  if (D.12219 != 0) goto <D.12220>; else goto <D.12221>;
  <D.12220>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "../../mono/io-layer/handles-private.h", 368, "thr_ret == 0");
  <D.12221>:
  D.12222 = &info->handle_refs;
  D.12223 = InterlockedDecrement (D.12222);
  if (D.12223 == 0) goto <D.12224>; else goto <D.12225>;
  <D.12224>:
  _wapi_free_share_info (info);
  <D.12225>:
  thr_ret = _wapi_shm_sem_unlock (2);
}


InterlockedDecrement (volatile gint32 * val)
{
  gint32 D.12226;
  unsigned int D.12227;

  D.12227 = __sync_sub_and_fetch_4 (val, 1);
  D.12226 = (gint32) D.12227;
  return D.12226;
}


_wapi_file_details (void * handle_info)
{
  gchar * D.12229;
  int iftmp.0;
  unsigned int D.12231;
  signed int D.12232;
  int iftmp.1;
  unsigned int D.12237;
  int iftmp.2;
  unsigned int D.12242;
  int iftmp.3;
  unsigned int D.12247;
  unsigned int D.12248;
  int iftmp.4;
  unsigned int D.12253;
  int iftmp.5;
  unsigned int D.12258;
  unsigned int D.12262;
  struct _WapiHandle_file * file;

  file = handle_info;
  D.12229 = file->filename;
  D.12231 = file->fileaccess;
  D.12232 = (signed int) D.12231;
  if (D.12232 < 0) goto <D.12233>; else goto <D.12234>;
  <D.12233>:
  iftmp.0 = 82;
  goto <D.12235>;
  <D.12234>:
  iftmp.0 = 46;
  <D.12235>:
  D.12231 = file->fileaccess;
  D.12237 = D.12231 & 1073741824;
  if (D.12237 != 0) goto <D.12238>; else goto <D.12239>;
  <D.12238>:
  iftmp.1 = 87;
  goto <D.12240>;
  <D.12239>:
  iftmp.1 = 46;
  <D.12240>:
  D.12231 = file->fileaccess;
  D.12242 = D.12231 & 536870912;
  if (D.12242 != 0) goto <D.12243>; else goto <D.12244>;
  <D.12243>:
  iftmp.2 = 88;
  goto <D.12245>;
  <D.12244>:
  iftmp.2 = 46;
  <D.12245>:
  D.12247 = file->sharemode;
  D.12248 = D.12247 & 1;
  if (D.12248 != 0) goto <D.12249>; else goto <D.12250>;
  <D.12249>:
  iftmp.3 = 82;
  goto <D.12251>;
  <D.12250>:
  iftmp.3 = 46;
  <D.12251>:
  D.12247 = file->sharemode;
  D.12253 = D.12247 & 2;
  if (D.12253 != 0) goto <D.12254>; else goto <D.12255>;
  <D.12254>:
  iftmp.4 = 87;
  goto <D.12256>;
  <D.12255>:
  iftmp.4 = 46;
  <D.12256>:
  D.12247 = file->sharemode;
  D.12258 = D.12247 & 4;
  if (D.12258 != 0) goto <D.12259>; else goto <D.12260>;
  <D.12259>:
  iftmp.5 = 68;
  goto <D.12261>;
  <D.12260>:
  iftmp.5 = 46;
  <D.12261>:
  D.12262 = file->attrs;
  monoeg_g_print ("[%20s] acc: %c%c%c, shr: %c%c%c, attrs: %5u", D.12229, iftmp.0, iftmp.1, iftmp.2, iftmp.3, iftmp.4, iftmp.5, D.12262);
}


console_close (void * handle, void * data)
{
  gchar * D.12263;
  struct _WapiHandle_file * console_handle;
  int fd;

  console_handle = data;
  fd = console_handle->fd;
  D.12263 = console_handle->filename;
  monoeg_g_free (D.12263);
  close (fd);
}


_wapi_console_details (void * handle_info)
{
  _wapi_file_details (handle_info);
}


pipe_close (void * handle, void * data)
{
  struct _WapiHandle_file * pipe_handle;
  int fd;

  pipe_handle = data;
  fd = pipe_handle->fd;
  close (fd);
}


_wapi_pipe_details (void * handle_info)
{
  _wapi_file_details (handle_info);
}


CreateFile (const gunichar2 * name, guint32 fileaccess, guint32 sharemode, struct WapiSecurityAttributes * security, guint32 createmode, guint32 attrs, void * template)
{
  unsigned int D.12264;
  unsigned int D.12267;
  void * D.12270;
  int * D.12277;
  int D.12278;
  int D.12281;
  unsigned int fd.6;
  unsigned int _wapi_fd_reserve.7;
  int D.12290;
  struct _WapiFileShare * D.12293;
  unsigned int D.12298;
  unsigned int D.12301;
  unsigned int D.12304;
  unsigned int D.12305;
  <unnamed type> handle_type.8;
  struct _WapiHandle_file file_handle;
  void * handle;
  int flags;
  mode_t perms;
  gchar * filename;
  int fd;
  int ret;
  int handle_type;
  struct stat statbuf;
  static const char __func__[11] = "CreateFile";

  try
    {
      file_handle = {};
      flags = convert_flags (fileaccess, createmode);
      perms = 438;
      mono_once (&io_ops_once, io_ops_init);
      D.12264 = attrs & 256;
      if (D.12264 != 0) goto <D.12265>; else goto <D.12266>;
      <D.12265>:
      perms = 384;
      <D.12266>:
      D.12267 = attrs & 64;
      if (D.12267 != 0) goto <D.12268>; else goto <D.12269>;
      <D.12268>:
      SetLastError (6000);
      D.12270 = -1B;
      return D.12270;
      <D.12269>:
      if (name == 0B) goto <D.12271>; else goto <D.12272>;
      <D.12271>:
      SetLastError (123);
      D.12270 = -1B;
      return D.12270;
      <D.12272>:
      filename = mono_unicode_to_external (name);
      if (filename == 0B) goto <D.12273>; else goto <D.12274>;
      <D.12273>:
      SetLastError (123);
      D.12270 = -1B;
      return D.12270;
      <D.12274>:
      fd = _wapi_open (filename, flags, perms);
      if (fd == -1) goto <D.12275>; else goto <D.12276>;
      <D.12275>:
      D.12277 = __errno_location ();
      D.12278 = *D.12277;
      if (D.12278 == 21) goto <D.12279>; else goto <D.12280>;
      <D.12279>:
      D.12281 = flags & -4;
      fd = _wapi_open (filename, D.12281, perms);
      <D.12280>:
      <D.12276>:
      if (fd == -1) goto <D.12282>; else goto <D.12283>;
      <D.12282>:
      _wapi_set_last_path_error_from_errno (0B, filename);
      monoeg_g_free (filename);
      D.12270 = -1B;
      return D.12270;
      <D.12283>:
      fd.6 = (unsigned int) fd;
      _wapi_fd_reserve.7 = _wapi_fd_reserve;
      if (fd.6 >= _wapi_fd_reserve.7) goto <D.12286>; else goto <D.12287>;
      <D.12286>:
      SetLastError (4);
      close (fd);
      monoeg_g_free (filename);
      D.12270 = -1B;
      return D.12270;
      <D.12287>:
      ret = fstat (fd, &statbuf);
      if (ret == -1) goto <D.12288>; else goto <D.12289>;
      <D.12288>:
      _wapi_set_last_error_from_errno ();
      monoeg_g_free (filename);
      close (fd);
      D.12270 = -1B;
      return D.12270;
      <D.12289>:
      D.12290 = share_check (&statbuf, sharemode, fileaccess, &file_handle.share_info, fd);
      if (D.12290 == 0) goto <D.12291>; else goto <D.12292>;
      <D.12291>:
      SetLastError (32);
      monoeg_g_free (filename);
      close (fd);
      D.12270 = -1B;
      return D.12270;
      <D.12292>:
      D.12293 = file_handle.share_info;
      if (D.12293 == 0B) goto <D.12294>; else goto <D.12295>;
      <D.12294>:
      SetLastError (4);
      close (fd);
      monoeg_g_free (filename);
      D.12270 = -1B;
      return D.12270;
      <D.12295>:
      file_handle.filename = filename;
      if (security != 0B) goto <D.12296>; else goto <D.12297>;
      <D.12296>:
      <D.12297>:
      file_handle.fd = fd;
      file_handle.fileaccess = fileaccess;
      file_handle.sharemode = sharemode;
      file_handle.attrs = attrs;
      D.12298 = attrs & 134217728;
      if (D.12298 != 0) goto <D.12299>; else goto <D.12300>;
      <D.12299>:
      posix_fadvise (fd, 0, 0, 2);
      <D.12300>:
      D.12301 = attrs & 268435456;
      if (D.12301 != 0) goto <D.12302>; else goto <D.12303>;
      <D.12302>:
      posix_fadvise (fd, 0, 0, 1);
      <D.12303>:
      D.12304 = statbuf.st_mode;
      D.12305 = D.12304 & 61440;
      if (D.12305 == 4096) goto <D.12306>; else goto <D.12307>;
      <D.12306>:
      handle_type = 10;
      goto <D.12308>;
      <D.12307>:
      D.12304 = statbuf.st_mode;
      D.12305 = D.12304 & 61440;
      if (D.12305 == 8192) goto <D.12309>; else goto <D.12310>;
      <D.12309>:
      handle_type = 2;
      goto <D.12311>;
      <D.12310>:
      handle_type = 1;
      <D.12311>:
      <D.12308>:
      handle_type.8 = (<unnamed type>) handle_type;
      handle = _wapi_handle_new_fd (handle_type.8, fd, &file_handle);
      if (handle == -1B) goto <D.12313>; else goto <D.12314>;
      <D.12313>:
      monoeg_g_log (0B, 16, "%s: error creating file handle", &__func__);
      monoeg_g_free (filename);
      close (fd);
      SetLastError (31);
      D.12270 = -1B;
      return D.12270;
      <D.12314>:
      D.12270 = handle;
      return D.12270;
    }
  finally
    {
      file_handle = {CLOBBER};
      statbuf = {CLOBBER};
    }
}


io_ops_init ()
{
  const gchar * D.12317;

  D.12317 = monoeg_g_getenv ("MONO_STRICT_IO_EMULATION");
  if (D.12317 != 0B) goto <D.12318>; else goto <D.12319>;
  <D.12318>:
  lock_while_writing = 1;
  <D.12319>:
}


convert_flags (guint32 fileaccess, guint32 createmode)
{
  int D.12320;
  int flags;

  flags = 0;
  switch (fileaccess) <default: <D.11669>, case 1073741824: <D.11667>, case 2147483648: <D.11665>, case 3221225472: <D.11668>>
  <D.11665>:
  flags = 0;
  goto <D.11666>;
  <D.11667>:
  flags = 1;
  goto <D.11666>;
  <D.11668>:
  flags = 2;
  goto <D.11666>;
  <D.11669>:
  goto <D.11666>;
  <D.11666>:
  switch (createmode) <default: <D.11676>, case 1: <D.11670>, case 2: <D.11672>, case 3: <D.11673>, case 4: <D.11674>, case 5: <D.11675>>
  <D.11670>:
  flags = flags | 192;
  goto <D.11671>;
  <D.11672>:
  flags = flags | 576;
  goto <D.11671>;
  <D.11673>:
  goto <D.11671>;
  <D.11674>:
  flags = flags | 64;
  goto <D.11671>;
  <D.11675>:
  flags = flags | 512;
  goto <D.11671>;
  <D.11676>:
  goto <D.11671>;
  <D.11671>:
  D.12320 = flags;
  return D.12320;
}


_wapi_set_last_path_error_from_errno (const gchar * dir, const gchar * path)
{
  int * D.12324;
  int D.12325;
  int D.12331;

  D.12324 = __errno_location ();
  D.12325 = *D.12324;
  if (D.12325 == 2) goto <D.12326>; else goto <D.12327>;
  <D.12326>:
  {
    gchar * dirname;

    if (dir == 0B) goto <D.12328>; else goto <D.12329>;
    <D.12328>:
    dirname = _wapi_dirname (path);
    goto <D.12330>;
    <D.12329>:
    dirname = monoeg_strdup (dir);
    <D.12330>:
    D.12331 = _wapi_access (dirname, 0);
    if (D.12331 == 0) goto <D.12332>; else goto <D.12333>;
    <D.12332>:
    SetLastError (2);
    goto <D.12334>;
    <D.12333>:
    SetLastError (3);
    <D.12334>:
    monoeg_g_free (dirname);
  }
  goto <D.12335>;
  <D.12327>:
  _wapi_set_last_error_from_errno ();
  <D.12335>:
}


monoeg_strdup (const gchar * str)
{
  gchar * D.12338;

  if (str != 0B) goto <D.12336>; else goto <D.12337>;
  <D.12336>:
  D.12338 = __strdup (str);
  return D.12338;
  <D.12337>:
  D.12338 = 0B;
  return D.12338;
}


__attribute__((__gnu_inline__, __leaf__, __nothrow__))
fstat (int __fd, struct stat * __statbuf)
{
  int D.12340;

  D.12340 = __fxstat (1, __fd, __statbuf);
  return D.12340;
}


_wapi_set_last_error_from_errno ()
{
  int * D.12342;
  int D.12343;
  int D.12344;
  unsigned int D.12345;

  D.12342 = __errno_location ();
  D.12343 = *D.12342;
  D.12344 = _wapi_get_win32_file_error (D.12343);
  D.12345 = (unsigned int) D.12344;
  SetLastError (D.12345);
}


share_check (struct stat * statbuf, guint32 sharemode, guint32 fileaccess, struct _WapiFileShare * * share_info, int fd)
{
  int D.12346;
  gboolean D.12349;
  struct _WapiFileShare * D.12350;
  int D.12351;

  D.12346 = share_allows_open (statbuf, sharemode, fileaccess, share_info);
  if (D.12346 == 1) goto <D.12347>; else goto <D.12348>;
  <D.12347>:
  D.12349 = 1;
  return D.12349;
  <D.12348>:
  D.12350 = *share_info;
  _wapi_handle_check_share (D.12350, fd);
  D.12351 = share_allows_open (statbuf, sharemode, fileaccess, share_info);
  if (D.12351 == 1) goto <D.12352>; else goto <D.12353>;
  <D.12352>:
  D.12349 = 1;
  return D.12349;
  <D.12353>:
  _wapi_handle_collect ();
  D.12349 = share_allows_open (statbuf, sharemode, fileaccess, share_info);
  return D.12349;
}


share_allows_open (struct stat * statbuf, guint32 sharemode, guint32 fileaccess, struct _WapiFileShare * * share_info)
{
  long unsigned int D.12355;
  long unsigned int D.12356;
  unsigned int file_existing_share.9;
  struct _WapiFileShare * D.12362;
  gboolean D.12363;
  unsigned int file_existing_access.10;
  signed int file_existing_access.11;
  unsigned int D.12375;
  unsigned int D.12376;
  unsigned int D.12378;
  gboolean file_already_shared;
  guint32 file_existing_share;
  guint32 file_existing_access;

  try
    {
      D.12355 = statbuf->st_dev;
      D.12356 = statbuf->st_ino;
      file_already_shared = _wapi_handle_get_or_set_share (D.12355, D.12356, sharemode, fileaccess, &file_existing_share, &file_existing_access, share_info);
      if (file_already_shared != 0) goto <D.12357>; else goto <D.12358>;
      <D.12357>:
      file_existing_share.9 = file_existing_share;
      if (file_existing_share.9 == 0) goto <D.12360>; else goto <D.12361>;
      <D.12360>:
      D.12362 = *share_info;
      _wapi_handle_share_release (D.12362);
      D.12363 = 0;
      return D.12363;
      <D.12361>:
      file_existing_share.9 = file_existing_share;
      if (file_existing_share.9 == 1) goto <D.12367>; else goto <D.12364>;
      <D.12367>:
      if (fileaccess != 2147483648) goto <D.12365>; else goto <D.12364>;
      <D.12364>:
      file_existing_share.9 = file_existing_share;
      if (file_existing_share.9 == 2) goto <D.12368>; else goto <D.12366>;
      <D.12368>:
      if (fileaccess != 1073741824) goto <D.12365>; else goto <D.12366>;
      <D.12365>:
      D.12362 = *share_info;
      _wapi_handle_share_release (D.12362);
      D.12363 = 0;
      return D.12363;
      <D.12366>:
      file_existing_access.10 = file_existing_access;
      file_existing_access.11 = (signed int) file_existing_access.10;
      if (file_existing_access.11 < 0) goto <D.12374>; else goto <D.12369>;
      <D.12374>:
      D.12375 = sharemode & 1;
      if (D.12375 == 0) goto <D.12370>; else goto <D.12369>;
      <D.12369>:
      file_existing_access.10 = file_existing_access;
      D.12376 = file_existing_access.10 & 1073741824;
      if (D.12376 != 0) goto <D.12377>; else goto <D.12371>;
      <D.12377>:
      D.12378 = sharemode & 2;
      if (D.12378 == 0) goto <D.12370>; else goto <D.12371>;
      <D.12370>:
      D.12362 = *share_info;
      _wapi_handle_share_release (D.12362);
      D.12363 = 0;
      return D.12363;
      <D.12371>:
      goto <D.12379>;
      <D.12358>:
      <D.12379>:
      D.12363 = 1;
      return D.12363;
    }
  finally
    {
      file_existing_share = {CLOBBER};
      file_existing_access = {CLOBBER};
    }
}


DeleteFile (const gunichar2 * name)
{
  gboolean D.12384;
  gchar * filename;
  int retval;
  gboolean ret;
  guint32 attrs;

  ret = 0;
  if (name == 0B) goto <D.12382>; else goto <D.12383>;
  <D.12382>:
  SetLastError (123);
  D.12384 = 0;
  return D.12384;
  <D.12383>:
  filename = mono_unicode_to_external (name);
  if (filename == 0B) goto <D.12385>; else goto <D.12386>;
  <D.12385>:
  SetLastError (123);
  D.12384 = 0;
  return D.12384;
  <D.12386>:
  attrs = GetFileAttributes (name);
  if (attrs == 4294967295) goto <D.12387>; else goto <D.12388>;
  <D.12387>:
  monoeg_g_free (filename);
  D.12384 = 0;
  return D.12384;
  <D.12388>:
  retval = _wapi_unlink (filename);
  if (retval == -1) goto <D.12389>; else goto <D.12390>;
  <D.12389>:
  _wapi_set_last_path_error_from_errno (0B, filename);
  goto <D.12391>;
  <D.12390>:
  ret = 1;
  <D.12391>:
  monoeg_g_free (filename);
  D.12384 = ret;
  return D.12384;
}


MoveFile (const gunichar2 * name, const gunichar2 * dest_name)
{
  gboolean D.12395;
  int D.12402;
  int * D.12407;
  int D.12408;
  int D.12410;
  int D.12411;
  long unsigned int D.12416;
  long unsigned int D.12417;
  long unsigned int D.12419;
  long unsigned int D.12420;
  int D.12421;
  struct _WapiFileShare * shareinfo.12;
  unsigned int D.12433;
  unsigned int D.12434;
  int D.12437;
  gchar * utf8_name;
  gchar * utf8_dest_name;
  int result;
  int errno_copy;
  struct stat stat_src;
  struct stat stat_dest;
  gboolean ret;
  struct _WapiFileShare * shareinfo;

  try
    {
      ret = 0;
      if (name == 0B) goto <D.12393>; else goto <D.12394>;
      <D.12393>:
      SetLastError (123);
      D.12395 = 0;
      return D.12395;
      <D.12394>:
      utf8_name = mono_unicode_to_external (name);
      if (utf8_name == 0B) goto <D.12396>; else goto <D.12397>;
      <D.12396>:
      SetLastError (123);
      D.12395 = 0;
      return D.12395;
      <D.12397>:
      if (dest_name == 0B) goto <D.12398>; else goto <D.12399>;
      <D.12398>:
      monoeg_g_free (utf8_name);
      SetLastError (123);
      D.12395 = 0;
      return D.12395;
      <D.12399>:
      utf8_dest_name = mono_unicode_to_external (dest_name);
      if (utf8_dest_name == 0B) goto <D.12400>; else goto <D.12401>;
      <D.12400>:
      monoeg_g_free (utf8_name);
      SetLastError (123);
      D.12395 = 0;
      return D.12395;
      <D.12401>:
      D.12402 = _wapi_stat (utf8_name, &stat_src);
      if (D.12402 < 0) goto <D.12403>; else goto <D.12404>;
      <D.12403>:
      D.12407 = __errno_location ();
      D.12408 = *D.12407;
      if (D.12408 != 2) goto <D.12405>; else goto <D.12409>;
      <D.12409>:
      D.12410 = _wapi_lstat (utf8_name, &stat_src);
      if (D.12410 < 0) goto <D.12405>; else goto <D.12406>;
      <D.12405>:
      _wapi_set_last_path_error_from_errno (0B, utf8_name);
      monoeg_g_free (utf8_name);
      monoeg_g_free (utf8_dest_name);
      D.12395 = 0;
      return D.12395;
      <D.12406>:
      <D.12404>:
      D.12411 = _wapi_stat (utf8_dest_name, &stat_dest);
      if (D.12411 == 0) goto <D.12412>; else goto <D.12413>;
      <D.12412>:
      D.12416 = stat_dest.st_dev;
      D.12417 = stat_src.st_dev;
      if (D.12416 != D.12417) goto <D.12414>; else goto <D.12418>;
      <D.12418>:
      D.12419 = stat_dest.st_ino;
      D.12420 = stat_src.st_ino;
      if (D.12419 != D.12420) goto <D.12414>; else goto <D.12415>;
      <D.12414>:
      monoeg_g_free (utf8_name);
      monoeg_g_free (utf8_dest_name);
      SetLastError (183);
      D.12395 = 0;
      return D.12395;
      <D.12415>:
      <D.12413>:
      D.12421 = share_allows_delete (&stat_src, &shareinfo);
      if (D.12421 == 0) goto <D.12422>; else goto <D.12423>;
      <D.12422>:
      SetLastError (32);
      D.12395 = 0;
      return D.12395;
      <D.12423>:
      shareinfo.12 = shareinfo;
      if (shareinfo.12 != 0B) goto <D.12425>; else goto <D.12426>;
      <D.12425>:
      shareinfo.12 = shareinfo;
      _wapi_handle_share_release (shareinfo.12);
      <D.12426>:
      result = _wapi_rename (utf8_name, utf8_dest_name);
      D.12407 = __errno_location ();
      errno_copy = *D.12407;
      if (result == -1) goto <D.12427>; else goto <D.12428>;
      <D.12427>:
      switch (errno_copy) <default: <D.11741>, case 17: <D.11738>, case 18: <D.11740>>
      <D.11738>:
      SetLastError (183);
      goto <D.11739>;
      <D.11740>:
      goto <D.11739>;
      <D.11741>:
      _wapi_set_last_path_error_from_errno (0B, utf8_name);
      <D.11739>:
      <D.12428>:
      monoeg_g_free (utf8_name);
      monoeg_g_free (utf8_dest_name);
      if (result != 0) goto <D.12429>; else goto <D.12430>;
      <D.12429>:
      if (errno_copy == 18) goto <D.12431>; else goto <D.12432>;
      <D.12431>:
      D.12433 = stat_src.st_mode;
      D.12434 = D.12433 & 61440;
      if (D.12434 == 16384) goto <D.12435>; else goto <D.12436>;
      <D.12435>:
      SetLastError (17);
      D.12395 = 0;
      return D.12395;
      <D.12436>:
      D.12437 = CopyFile (name, dest_name, 1);
      if (D.12437 == 0) goto <D.12438>; else goto <D.12439>;
      <D.12438>:
      D.12395 = 0;
      return D.12395;
      <D.12439>:
      D.12395 = DeleteFile (name);
      return D.12395;
      <D.12432>:
      <D.12430>:
      if (result == 0) goto <D.12440>; else goto <D.12441>;
      <D.12440>:
      ret = 1;
      <D.12441>:
      D.12395 = ret;
      return D.12395;
    }
  finally
    {
      stat_src = {CLOBBER};
      stat_dest = {CLOBBER};
      shareinfo = {CLOBBER};
    }
}


share_allows_delete (struct stat * statbuf, struct _WapiFileShare * * share_info)
{
  long unsigned int D.12445;
  long unsigned int D.12446;
  unsigned int file_existing_share.13;
  struct _WapiFileShare * D.12452;
  gboolean D.12453;
  unsigned int D.12454;
  gboolean file_already_shared;
  guint32 file_existing_share;
  guint32 file_existing_access;

  try
    {
      D.12445 = statbuf->st_dev;
      D.12446 = statbuf->st_ino;
      file_already_shared = _wapi_handle_get_or_set_share (D.12445, D.12446, 4, 2147483648, &file_existing_share, &file_existing_access, share_info);
      if (file_already_shared != 0) goto <D.12447>; else goto <D.12448>;
      <D.12447>:
      file_existing_share.13 = file_existing_share;
      if (file_existing_share.13 == 0) goto <D.12450>; else goto <D.12451>;
      <D.12450>:
      D.12452 = *share_info;
      _wapi_handle_share_release (D.12452);
      D.12453 = 0;
      return D.12453;
      <D.12451>:
      file_existing_share.13 = file_existing_share;
      D.12454 = file_existing_share.13 & 4;
      if (D.12454 == 0) goto <D.12455>; else goto <D.12456>;
      <D.12455>:
      D.12452 = *share_info;
      _wapi_handle_share_release (D.12452);
      D.12453 = 0;
      return D.12453;
      <D.12456>:
      goto <D.12457>;
      <D.12448>:
      <D.12457>:
      D.12453 = 1;
      return D.12453;
    }
  finally
    {
      file_existing_share = {CLOBBER};
      file_existing_access = {CLOBBER};
    }
}


CopyFile (const gunichar2 * name, const gunichar2 * dest_name, gboolean fail_if_exists)
{
  gboolean D.12462;
  int D.12471;
  int D.12474;
  long unsigned int D.12477;
  long unsigned int D.12478;
  long unsigned int D.12481;
  long unsigned int D.12482;
  unsigned int D.12487;
  int D.12494;
  long int D.12497;
  long int D.12498;
  gchar * utf8_src;
  gchar * utf8_dest;
  int src_fd;
  int dest_fd;
  struct stat st;
  struct stat dest_st;
  struct utimbuf dest_time;
  gboolean ret;
  int ret_utime;

  try
    {
      ret = 1;
      if (name == 0B) goto <D.12460>; else goto <D.12461>;
      <D.12460>:
      SetLastError (123);
      D.12462 = 0;
      return D.12462;
      <D.12461>:
      utf8_src = mono_unicode_to_external (name);
      if (utf8_src == 0B) goto <D.12463>; else goto <D.12464>;
      <D.12463>:
      SetLastError (87);
      D.12462 = 0;
      return D.12462;
      <D.12464>:
      if (dest_name == 0B) goto <D.12465>; else goto <D.12466>;
      <D.12465>:
      monoeg_g_free (utf8_src);
      SetLastError (123);
      D.12462 = 0;
      return D.12462;
      <D.12466>:
      utf8_dest = mono_unicode_to_external (dest_name);
      if (utf8_dest == 0B) goto <D.12467>; else goto <D.12468>;
      <D.12467>:
      SetLastError (87);
      monoeg_g_free (utf8_src);
      D.12462 = 0;
      return D.12462;
      <D.12468>:
      src_fd = _wapi_open (utf8_src, 0, 0);
      if (src_fd < 0) goto <D.12469>; else goto <D.12470>;
      <D.12469>:
      _wapi_set_last_path_error_from_errno (0B, utf8_src);
      monoeg_g_free (utf8_src);
      monoeg_g_free (utf8_dest);
      D.12462 = 0;
      return D.12462;
      <D.12470>:
      D.12471 = fstat (src_fd, &st);
      if (D.12471 < 0) goto <D.12472>; else goto <D.12473>;
      <D.12472>:
      _wapi_set_last_error_from_errno ();
      monoeg_g_free (utf8_src);
      monoeg_g_free (utf8_dest);
      close (src_fd);
      D.12462 = 0;
      return D.12462;
      <D.12473>:
      D.12474 = _wapi_stat (utf8_dest, &dest_st);
      if (D.12474 == 0) goto <D.12475>; else goto <D.12476>;
      <D.12475>:
      D.12477 = st.st_dev;
      D.12478 = dest_st.st_dev;
      if (D.12477 == D.12478) goto <D.12479>; else goto <D.12480>;
      <D.12479>:
      D.12481 = st.st_ino;
      D.12482 = dest_st.st_ino;
      if (D.12481 == D.12482) goto <D.12483>; else goto <D.12484>;
      <D.12483>:
      monoeg_g_free (utf8_src);
      monoeg_g_free (utf8_dest);
      close (src_fd);
      SetLastError (32);
      D.12462 = 0;
      return D.12462;
      <D.12484>:
      <D.12480>:
      <D.12476>:
      if (fail_if_exists != 0) goto <D.12485>; else goto <D.12486>;
      <D.12485>:
      D.12487 = st.st_mode;
      dest_fd = _wapi_open (utf8_dest, 193, D.12487);
      goto <D.12488>;
      <D.12486>:
      D.12487 = st.st_mode;
      dest_fd = _wapi_open (utf8_dest, 513, D.12487);
      if (dest_fd < 0) goto <D.12489>; else goto <D.12490>;
      <D.12489>:
      D.12487 = st.st_mode;
      dest_fd = _wapi_open (utf8_dest, 577, D.12487);
      goto <D.12491>;
      <D.12490>:
      SetLastError (183);
      <D.12491>:
      <D.12488>:
      if (dest_fd < 0) goto <D.12492>; else goto <D.12493>;
      <D.12492>:
      _wapi_set_last_error_from_errno ();
      monoeg_g_free (utf8_src);
      monoeg_g_free (utf8_dest);
      close (src_fd);
      D.12462 = 0;
      return D.12462;
      <D.12493>:
      D.12494 = write_file (src_fd, dest_fd, &st, 1);
      if (D.12494 == 0) goto <D.12495>; else goto <D.12496>;
      <D.12495>:
      ret = 0;
      <D.12496>:
      close (src_fd);
      close (dest_fd);
      D.12497 = st.st_mtim.tv_sec;
      dest_time.modtime = D.12497;
      D.12498 = st.st_atim.tv_sec;
      dest_time.actime = D.12498;
      ret_utime = utime (utf8_dest, &dest_time);
      if (ret_utime == -1) goto <D.12499>; else goto <D.12500>;
      <D.12499>:
      <D.12500>:
      monoeg_g_free (utf8_src);
      monoeg_g_free (utf8_dest);
      D.12462 = ret;
      return D.12462;
    }
  finally
    {
      st = {CLOBBER};
      dest_st = {CLOBBER};
      dest_time = {CLOBBER};
    }
}


write_file (int src_fd, int dest_fd, struct stat * st_src, gboolean report_errors)
{
  long int D.12503;
  int iftmp.14;
  long unsigned int D.12508;
  long int D.12509;
  int * D.12512;
  int D.12513;
  int D.12516;
  gboolean D.12521;
  long unsigned int D.12523;
  long int D.12524;
  int D.12529;
  sizetype D.12534;
  int remain;
  int n;
  char * buf;
  char * wbuf;
  int buf_size;

  D.12503 = st_src->st_blksize;
  buf_size = (int) D.12503;
  if (buf_size > 8191) goto <D.12505>; else goto <D.12506>;
  <D.12505>:
  iftmp.14 = MIN_EXPR <buf_size, 65536>;
  goto <D.12507>;
  <D.12506>:
  iftmp.14 = 8192;
  <D.12507>:
  buf_size = iftmp.14;
  D.12508 = (long unsigned int) buf_size;
  buf = malloc (D.12508);
  <D.11758>:
  D.12508 = (long unsigned int) buf_size;
  D.12509 = read (src_fd, buf, D.12508);
  remain = (int) D.12509;
  if (remain < 0) goto <D.12510>; else goto <D.12511>;
  <D.12510>:
  D.12512 = __errno_location ();
  D.12513 = *D.12512;
  if (D.12513 == 4) goto <D.12514>; else goto <D.12515>;
  <D.12514>:
  D.12516 = _wapi_thread_cur_apc_pending ();
  if (D.12516 == 0) goto <D.12517>; else goto <D.12518>;
  <D.12517>:
  // predicted unlikely by continue predictor.
  goto <D.11753>;
  <D.12518>:
  <D.12515>:
  if (report_errors != 0) goto <D.12519>; else goto <D.12520>;
  <D.12519>:
  _wapi_set_last_error_from_errno ();
  <D.12520>:
  free (buf);
  D.12521 = 0;
  return D.12521;
  <D.12511>:
  if (remain == 0) goto <D.11754>; else goto <D.12522>;
  <D.12522>:
  wbuf = buf;
  goto <D.11755>;
  <D.11756>:
  D.12523 = (long unsigned int) remain;
  D.12524 = write (dest_fd, wbuf, D.12523);
  n = (int) D.12524;
  if (n < 0) goto <D.12525>; else goto <D.12526>;
  <D.12525>:
  D.12512 = __errno_location ();
  D.12513 = *D.12512;
  if (D.12513 == 4) goto <D.12527>; else goto <D.12528>;
  <D.12527>:
  D.12529 = _wapi_thread_cur_apc_pending ();
  if (D.12529 == 0) goto <D.12530>; else goto <D.12531>;
  <D.12530>:
  // predicted unlikely by continue predictor.
  goto <D.11755>;
  <D.12531>:
  <D.12528>:
  if (report_errors != 0) goto <D.12532>; else goto <D.12533>;
  <D.12532>:
  _wapi_set_last_error_from_errno ();
  <D.12533>:
  free (buf);
  D.12521 = 0;
  return D.12521;
  <D.12526>:
  remain = remain - n;
  D.12534 = (sizetype) n;
  wbuf = wbuf + D.12534;
  <D.11755>:
  if (remain > 0) goto <D.11756>; else goto <D.11757>;
  <D.11757>:
  <D.11753>:
  goto <D.11758>;
  <D.11754>:
  free (buf);
  D.12521 = 1;
  return D.12521;
}


__attribute__((__artificial__, __gnu_inline__, __always_inline__))
read (int __fd, void * __buf, size_t __nbytes)
{
  long unsigned int D.12536;
  int D.12539;
  ssize_t D.12542;
  long unsigned int D.12543;
  long unsigned int D.12544;
  long unsigned int D.12547;

  D.12536 = __builtin_object_size (__buf, 0);
  if (D.12536 != 18446744073709551615) goto <D.12537>; else goto <D.12538>;
  <D.12537>:
  D.12539 = __builtin_constant_p (__nbytes);
  if (D.12539 == 0) goto <D.12540>; else goto <D.12541>;
  <D.12540>:
  D.12543 = __builtin_object_size (__buf, 0);
  D.12542 = __read_chk (__fd, __buf, __nbytes, D.12543);
  return D.12542;
  <D.12541>:
  D.12544 = __builtin_object_size (__buf, 0);
  if (D.12544 < __nbytes) goto <D.12545>; else goto <D.12546>;
  <D.12545>:
  D.12547 = __builtin_object_size (__buf, 0);
  D.12542 = __read_chk_warn (__fd, __buf, __nbytes, D.12547);
  return D.12542;
  <D.12546>:
  <D.12538>:
  D.12542 = __read_alias (__fd, __buf, __nbytes);
  return D.12542;
}


ReplaceFile (const gunichar2 * replacedFileName, const gunichar2 * replacementFileName, const gunichar2 * backupFileName, guint32 replaceFlags, void * exclude, void * reserved)
{
  gboolean D.12551;
  int * D.12558;
  int D.12564;
  unsigned int D.12567;
  int result;
  int errno_copy;
  int backup_fd;
  int replaced_fd;
  gchar * utf8_replacedFileName;
  gchar * utf8_replacementFileName;
  gchar * utf8_backupFileName;
  struct stat stBackup;
  gboolean ret;
  void replace_cleanup = <<< error >>>;

  try
    {
      backup_fd = -1;
      replaced_fd = -1;
      utf8_replacementFileName = 0B;
      utf8_backupFileName = 0B;
      ret = 0;
      utf8_replacedFileName = convert_arg_to_utf8 (replacedFileName, "replacedFileName");
      if (utf8_replacedFileName == 0B) goto <D.12549>; else goto <D.12550>;
      <D.12549>:
      D.12551 = 0;
      return D.12551;
      <D.12550>:
      utf8_replacementFileName = convert_arg_to_utf8 (replacementFileName, "replacementFileName");
      if (utf8_replacementFileName == 0B) goto replace_cleanup; else goto <D.12552>;
      <D.12552>:
      if (backupFileName != 0B) goto <D.12553>; else goto <D.12554>;
      <D.12553>:
      utf8_backupFileName = convert_arg_to_utf8 (backupFileName, "backupFileName");
      if (utf8_backupFileName == 0B) goto replace_cleanup; else goto <D.12555>;
      <D.12555>:
      <D.12554>:
      if (utf8_backupFileName != 0B) goto <D.12556>; else goto <D.12557>;
      <D.12556>:
      backup_fd = _wapi_open (utf8_backupFileName, 0, 0);
      result = _wapi_rename (utf8_replacedFileName, utf8_backupFileName);
      D.12558 = __errno_location ();
      errno_copy = *D.12558;
      if (result == -1) goto replace_cleanup; else goto <D.12559>;
      <D.12559>:
      <D.12557>:
      result = _wapi_rename (utf8_replacementFileName, utf8_replacedFileName);
      D.12558 = __errno_location ();
      errno_copy = *D.12558;
      if (result == -1) goto <D.12560>; else goto <D.12561>;
      <D.12560>:
      _wapi_set_last_path_error_from_errno (0B, utf8_replacementFileName);
      _wapi_rename (utf8_backupFileName, utf8_replacedFileName);
      if (backup_fd != -1) goto <D.12562>; else goto <D.12563>;
      <D.12562>:
      D.12564 = fstat (backup_fd, &stBackup);
      if (D.12564 == 0) goto <D.12565>; else goto <D.12566>;
      <D.12565>:
      D.12567 = stBackup.st_mode;
      replaced_fd = _wapi_open (utf8_backupFileName, 577, D.12567);
      if (replaced_fd == -1) goto replace_cleanup; else goto <D.12568>;
      <D.12568>:
      write_file (backup_fd, replaced_fd, &stBackup, 0);
      <D.12566>:
      <D.12563>:
      goto replace_cleanup;
      <D.12561>:
      ret = 1;
      replace_cleanup:
      monoeg_g_free (utf8_replacedFileName);
      monoeg_g_free (utf8_replacementFileName);
      monoeg_g_free (utf8_backupFileName);
      if (backup_fd != -1) goto <D.12569>; else goto <D.12570>;
      <D.12569>:
      close (backup_fd);
      <D.12570>:
      if (replaced_fd != -1) goto <D.12571>; else goto <D.12572>;
      <D.12571>:
      close (replaced_fd);
      <D.12572>:
      D.12551 = ret;
      return D.12551;
    }
  finally
    {
      stBackup = {CLOBBER};
    }
}


convert_arg_to_utf8 (const gunichar2 * arg, const gchar * arg_name)
{
  gchar * D.12577;
  gchar * utf8_ret;

  if (arg == 0B) goto <D.12575>; else goto <D.12576>;
  <D.12575>:
  SetLastError (123);
  D.12577 = 0B;
  return D.12577;
  <D.12576>:
  utf8_ret = mono_unicode_to_external (arg);
  if (utf8_ret == 0B) goto <D.12578>; else goto <D.12579>;
  <D.12578>:
  SetLastError (87);
  D.12577 = 0B;
  return D.12577;
  <D.12579>:
  D.12577 = utf8_ret;
  return D.12577;
}


GetStdHandle (WapiStdHandle stdhandle)
{
  void * D.12581;
  long int D.12582;
  long int D.12583;
  long int D.12584;
  _Bool D.12587;
  long int D.12588;
  long int D.12589;
  struct _WapiHandle_file * file_handle;
  void * handle;
  int thr_ret;
  int fd;
  const gchar * name;
  gboolean ok;
  void done = <<< error >>>;

  try
    {
      switch (stdhandle) <default: <D.11810>, case -12: <D.11809>, case -11: <D.11808>, case -10: <D.11806>>
      <D.11806>:
      fd = 0;
      name = "<stdin>";
      goto <D.11807>;
      <D.11808>:
      fd = 1;
      name = "<stdout>";
      goto <D.11807>;
      <D.11809>:
      fd = 2;
      name = "<stderr>";
      goto <D.11807>;
      <D.11810>:
      SetLastError (87);
      D.12581 = -1B;
      return D.12581;
      <D.11807>:
      D.12582 = (long int) fd;
      handle = (void *) D.12582;
      {
        struct __pthread_unwind_buf_t __cancel_buf;
        void (*<Tc6>) (void *) __cancel_routine;
        void * __cancel_arg;
        int __not_first_call;

        try
          {
            __cancel_routine = mono_mutex_unlock_in_cleanup;
            __cancel_arg = &stdhandle_mutex;
            __not_first_call = __sigsetjmp (&__cancel_buf.__cancel_jmp_buf, 0);
            D.12583 = (long int) __not_first_call;
            D.12584 = __builtin_expect (D.12583, 0);
            if (D.12584 != 0) goto <D.12585>; else goto <D.12586>;
            <D.12585>:
            __cancel_routine (__cancel_arg);
            __pthread_unwind_next (&__cancel_buf);
            <D.12586>:
            __pthread_register_cancel (&__cancel_buf);
            thr_ret = pthread_mutex_lock (&stdhandle_mutex);
            D.12587 = thr_ret != 0;
            D.12588 = (long int) D.12587;
            D.12589 = __builtin_expect (D.12588, 0);
            if (D.12589 != 0) goto <D.12590>; else goto <D.12591>;
            <D.12590>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "io.c", 2187, "thr_ret == 0");
            <D.12591>:
            ok = _wapi_lookup_handle (handle, 2, &file_handle);
            if (ok == 0) goto <D.12592>; else goto <D.12593>;
            <D.12592>:
            handle = _wapi_stdhandle_create (fd, name);
            if (handle == -1B) goto <D.12594>; else goto <D.12595>;
            <D.12594>:
            SetLastError (18);
            goto done;
            <D.12595>:
            goto <D.12596>;
            <D.12593>:
            _wapi_handle_ref (handle);
            <D.12596>:
            done:
            thr_ret = pthread_mutex_unlock (&stdhandle_mutex);
            D.12587 = thr_ret != 0;
            D.12588 = (long int) D.12587;
            D.12589 = __builtin_expect (D.12588, 0);
            if (D.12589 != 0) goto <D.12597>; else goto <D.12598>;
            <D.12597>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "io.c", 2206, "thr_ret == 0");
            <D.12598>:
            __pthread_unregister_cancel (&__cancel_buf);
            if (0 != 0) goto <D.12599>; else goto <D.12600>;
            <D.12599>:
            __cancel_routine (__cancel_arg);
            <D.12600>:
          }
        finally
          {
            __cancel_buf = {CLOBBER};
          }
      }
      D.12581 = handle;
      return D.12581;
    }
  finally
    {
      file_handle = {CLOBBER};
    }
}


__attribute__((__unused__))
mono_mutex_unlock_in_cleanup (union mono_mutex_t * mutex)
{
  int D.12607;

  D.12607 = pthread_mutex_unlock (mutex);
  return D.12607;
}


ReadFile (void * handle, void * buffer, guint32 numbytes, guint32 * bytesread, struct WapiOverlapped * overlapped)
{
  gboolean (*<T1c15>) (void *, void *, guint32, guint32 *, struct WapiOverlapped *) D.12609;
  gboolean D.12612;
  WapiHandleType type;

  type = _wapi_handle_type (handle);
  D.12609 = io_ops[type].readfile;
  if (D.12609 == 0B) goto <D.12610>; else goto <D.12611>;
  <D.12610>:
  SetLastError (6);
  D.12612 = 0;
  return D.12612;
  <D.12611>:
  D.12609 = io_ops[type].readfile;
  D.12612 = D.12609 (handle, buffer, numbytes, bytesread, overlapped);
  return D.12612;
}


pipe_write (void * handle, const void * buffer, guint32 numbytes, guint32 * byteswritten, struct WapiOverlapped * overlapped)
{
  gboolean D.12616;
  struct _WapiHandle_file * pipe_handle.15;
  long unsigned int D.12620;
  long unsigned int D.12621;
  long unsigned int D.12624;
  long int D.12625;
  int * D.12627;
  int D.12628;
  int D.12630;
  unsigned int ret.16;
  struct _WapiHandle_file * pipe_handle;
  gboolean ok;
  int ret;
  int fd;
  static const char __func__[11] = "pipe_write";

  try
    {
      ok = _wapi_lookup_handle (handle, 10, &pipe_handle);
      if (ok == 0) goto <D.12614>; else goto <D.12615>;
      <D.12614>:
      monoeg_g_log (0B, 16, "%s: error looking up pipe handle %p", &__func__, handle);
      SetLastError (6);
      D.12616 = 0;
      return D.12616;
      <D.12615>:
      pipe_handle.15 = pipe_handle;
      fd = pipe_handle.15->fd;
      if (byteswritten != 0B) goto <D.12618>; else goto <D.12619>;
      <D.12618>:
      *byteswritten = 0;
      <D.12619>:
      pipe_handle.15 = pipe_handle;
      D.12620 = BIT_FIELD_REF <*pipe_handle.15, 64, 192>;
      D.12621 = D.12620 & 5764607523034234880;
      if (D.12621 == 0) goto <D.12622>; else goto <D.12623>;
      <D.12622>:
      SetLastError (5);
      D.12616 = 0;
      return D.12616;
      <D.12623>:
      <D.11658>:
      D.12624 = (long unsigned int) numbytes;
      D.12625 = write (fd, buffer, D.12624);
      ret = (int) D.12625;
      if (ret == -1) goto <D.12626>; else goto <D.11659>;
      <D.12626>:
      D.12627 = __errno_location ();
      D.12628 = *D.12627;
      if (D.12628 == 4) goto <D.12629>; else goto <D.11659>;
      <D.12629>:
      D.12630 = _wapi_thread_cur_apc_pending ();
      if (D.12630 == 0) goto <D.11658>; else goto <D.11659>;
      <D.11659>:
      if (ret == -1) goto <D.12631>; else goto <D.12632>;
      <D.12631>:
      D.12627 = __errno_location ();
      D.12628 = *D.12627;
      if (D.12628 == 4) goto <D.12633>; else goto <D.12634>;
      <D.12633>:
      ret = 0;
      goto <D.12635>;
      <D.12634>:
      _wapi_set_last_error_from_errno ();
      D.12616 = 0;
      return D.12616;
      <D.12635>:
      <D.12632>:
      if (byteswritten != 0B) goto <D.12636>; else goto <D.12637>;
      <D.12636>:
      ret.16 = (unsigned int) ret;
      *byteswritten = ret.16;
      <D.12637>:
      D.12616 = 1;
      return D.12616;
    }
  finally
    {
      pipe_handle = {CLOBBER};
    }
}


pipe_read (void * handle, void * buffer, guint32 numbytes, guint32 * bytesread, struct WapiOverlapped * overlapped)
{
  gboolean D.12643;
  struct _WapiHandle_file * pipe_handle.17;
  unsigned int D.12647;
  signed int D.12648;
  unsigned int D.12651;
  long unsigned int D.12654;
  long int D.12655;
  int * D.12657;
  int D.12658;
  int D.12660;
  unsigned int ret.18;
  struct _WapiHandle_file * pipe_handle;
  gboolean ok;
  int ret;
  int fd;
  static const char __func__[10] = "pipe_read";

  try
    {
      ok = _wapi_lookup_handle (handle, 10, &pipe_handle);
      if (ok == 0) goto <D.12641>; else goto <D.12642>;
      <D.12641>:
      monoeg_g_log (0B, 16, "%s: error looking up pipe handle %p", &__func__, handle);
      SetLastError (6);
      D.12643 = 0;
      return D.12643;
      <D.12642>:
      pipe_handle.17 = pipe_handle;
      fd = pipe_handle.17->fd;
      if (bytesread != 0B) goto <D.12645>; else goto <D.12646>;
      <D.12645>:
      *bytesread = 0;
      <D.12646>:
      pipe_handle.17 = pipe_handle;
      D.12647 = pipe_handle.17->fileaccess;
      D.12648 = (signed int) D.12647;
      if (D.12648 >= 0) goto <D.12649>; else goto <D.12650>;
      <D.12649>:
      pipe_handle.17 = pipe_handle;
      D.12647 = pipe_handle.17->fileaccess;
      D.12651 = D.12647 & 268435456;
      if (D.12651 == 0) goto <D.12652>; else goto <D.12653>;
      <D.12652>:
      SetLastError (5);
      D.12643 = 0;
      return D.12643;
      <D.12653>:
      <D.12650>:
      <D.11644>:
      D.12654 = (long unsigned int) numbytes;
      D.12655 = read (fd, buffer, D.12654);
      ret = (int) D.12655;
      if (ret == -1) goto <D.12656>; else goto <D.11645>;
      <D.12656>:
      D.12657 = __errno_location ();
      D.12658 = *D.12657;
      if (D.12658 == 4) goto <D.12659>; else goto <D.11645>;
      <D.12659>:
      D.12660 = _wapi_thread_cur_apc_pending ();
      if (D.12660 == 0) goto <D.11644>; else goto <D.11645>;
      <D.11645>:
      if (ret == -1) goto <D.12661>; else goto <D.12662>;
      <D.12661>:
      D.12657 = __errno_location ();
      D.12658 = *D.12657;
      if (D.12658 == 4) goto <D.12663>; else goto <D.12664>;
      <D.12663>:
      ret = 0;
      goto <D.12665>;
      <D.12664>:
      _wapi_set_last_error_from_errno ();
      D.12643 = 0;
      return D.12643;
      <D.12665>:
      <D.12662>:
      if (bytesread != 0B) goto <D.12666>; else goto <D.12667>;
      <D.12666>:
      ret.18 = (unsigned int) ret;
      *bytesread = ret.18;
      <D.12667>:
      D.12643 = 1;
      return D.12643;
    }
  finally
    {
      pipe_handle = {CLOBBER};
    }
}


pipe_getfiletype ()
{
  WapiFileType D.12671;

  D.12671 = 3;
  return D.12671;
}


console_write (void * handle, const void * buffer, guint32 numbytes, guint32 * byteswritten, struct WapiOverlapped * overlapped)
{
  gboolean D.12675;
  struct _WapiHandle_file * console_handle.19;
  long unsigned int D.12679;
  long unsigned int D.12680;
  long unsigned int D.12683;
  long int D.12684;
  int * D.12686;
  int D.12687;
  int D.12689;
  unsigned int ret.20;
  struct _WapiHandle_file * console_handle;
  gboolean ok;
  int ret;
  int fd;
  static const char __func__[14] = "console_write";

  try
    {
      ok = _wapi_lookup_handle (handle, 2, &console_handle);
      if (ok == 0) goto <D.12673>; else goto <D.12674>;
      <D.12673>:
      monoeg_g_log (0B, 16, "%s: error looking up console handle %p", &__func__, handle);
      SetLastError (6);
      D.12675 = 0;
      return D.12675;
      <D.12674>:
      console_handle.19 = console_handle;
      fd = console_handle.19->fd;
      if (byteswritten != 0B) goto <D.12677>; else goto <D.12678>;
      <D.12677>:
      *byteswritten = 0;
      <D.12678>:
      console_handle.19 = console_handle;
      D.12679 = BIT_FIELD_REF <*console_handle.19, 64, 192>;
      D.12680 = D.12679 & 5764607523034234880;
      if (D.12680 == 0) goto <D.12681>; else goto <D.12682>;
      <D.12681>:
      SetLastError (5);
      D.12675 = 0;
      return D.12675;
      <D.12682>:
      <D.11621>:
      D.12683 = (long unsigned int) numbytes;
      D.12684 = write (fd, buffer, D.12683);
      ret = (int) D.12684;
      if (ret == -1) goto <D.12685>; else goto <D.11622>;
      <D.12685>:
      D.12686 = __errno_location ();
      D.12687 = *D.12686;
      if (D.12687 == 4) goto <D.12688>; else goto <D.11622>;
      <D.12688>:
      D.12689 = _wapi_thread_cur_apc_pending ();
      if (D.12689 == 0) goto <D.11621>; else goto <D.11622>;
      <D.11622>:
      if (ret == -1) goto <D.12690>; else goto <D.12691>;
      <D.12690>:
      D.12686 = __errno_location ();
      D.12687 = *D.12686;
      if (D.12687 == 4) goto <D.12692>; else goto <D.12693>;
      <D.12692>:
      ret = 0;
      goto <D.12694>;
      <D.12693>:
      _wapi_set_last_error_from_errno ();
      D.12675 = 0;
      return D.12675;
      <D.12694>:
      <D.12691>:
      if (byteswritten != 0B) goto <D.12695>; else goto <D.12696>;
      <D.12695>:
      ret.20 = (unsigned int) ret;
      *byteswritten = ret.20;
      <D.12696>:
      D.12675 = 1;
      return D.12675;
    }
  finally
    {
      console_handle = {CLOBBER};
    }
}


console_read (void * handle, void * buffer, guint32 numbytes, guint32 * bytesread, struct WapiOverlapped * overlapped)
{
  gboolean D.12702;
  struct _WapiHandle_file * console_handle.21;
  unsigned int D.12706;
  signed int D.12707;
  unsigned int D.12710;
  long unsigned int D.12713;
  long int D.12714;
  int * D.12716;
  int D.12717;
  int D.12719;
  unsigned int ret.22;
  struct _WapiHandle_file * console_handle;
  gboolean ok;
  int ret;
  int fd;
  static const char __func__[13] = "console_read";

  try
    {
      ok = _wapi_lookup_handle (handle, 2, &console_handle);
      if (ok == 0) goto <D.12700>; else goto <D.12701>;
      <D.12700>:
      monoeg_g_log (0B, 16, "%s: error looking up console handle %p", &__func__, handle);
      SetLastError (6);
      D.12702 = 0;
      return D.12702;
      <D.12701>:
      console_handle.21 = console_handle;
      fd = console_handle.21->fd;
      if (bytesread != 0B) goto <D.12704>; else goto <D.12705>;
      <D.12704>:
      *bytesread = 0;
      <D.12705>:
      console_handle.21 = console_handle;
      D.12706 = console_handle.21->fileaccess;
      D.12707 = (signed int) D.12706;
      if (D.12707 >= 0) goto <D.12708>; else goto <D.12709>;
      <D.12708>:
      console_handle.21 = console_handle;
      D.12706 = console_handle.21->fileaccess;
      D.12710 = D.12706 & 268435456;
      if (D.12710 == 0) goto <D.12711>; else goto <D.12712>;
      <D.12711>:
      SetLastError (5);
      D.12702 = 0;
      return D.12702;
      <D.12712>:
      <D.12709>:
      <D.11607>:
      D.12713 = (long unsigned int) numbytes;
      D.12714 = read (fd, buffer, D.12713);
      ret = (int) D.12714;
      if (ret == -1) goto <D.12715>; else goto <D.11608>;
      <D.12715>:
      D.12716 = __errno_location ();
      D.12717 = *D.12716;
      if (D.12717 == 4) goto <D.12718>; else goto <D.11608>;
      <D.12718>:
      D.12719 = _wapi_thread_cur_apc_pending ();
      if (D.12719 == 0) goto <D.11607>; else goto <D.11608>;
      <D.11608>:
      if (ret == -1) goto <D.12720>; else goto <D.12721>;
      <D.12720>:
      _wapi_set_last_error_from_errno ();
      D.12702 = 0;
      return D.12702;
      <D.12721>:
      if (bytesread != 0B) goto <D.12722>; else goto <D.12723>;
      <D.12722>:
      ret.22 = (unsigned int) ret;
      *bytesread = ret.22;
      <D.12723>:
      D.12702 = 1;
      return D.12702;
    }
  finally
    {
      console_handle = {CLOBBER};
    }
}


console_getfiletype ()
{
  WapiFileType D.12727;

  D.12727 = 2;
  return D.12727;
}


file_setfiletime (void * handle, const struct WapiFileTime * create_time, const struct WapiFileTime * last_access, const struct WapiFileTime * last_write)
{
  gboolean D.12731;
  struct _WapiHandle_file * file_handle.23;
  long unsigned int D.12733;
  long unsigned int D.12734;
  gchar * D.12737;
  unsigned int D.12744;
  long unsigned int D.12745;
  long unsigned int D.12746;
  unsigned int D.12747;
  long unsigned int D.12748;
  long long unsigned int D.12751;
  long long unsigned int D.12752;
  long int D.12753;
  long int D.12755;
  unsigned int D.12758;
  long unsigned int D.12759;
  long unsigned int D.12760;
  unsigned int D.12761;
  long unsigned int D.12762;
  long long unsigned int D.12765;
  long long unsigned int D.12766;
  long int D.12767;
  long int D.12769;
  struct _WapiHandle_file * file_handle;
  gboolean ok;
  struct utimbuf utbuf;
  struct stat statbuf;
  guint64 access_ticks;
  guint64 write_ticks;
  int ret;
  int fd;
  static const char __func__[17] = "file_setfiletime";

  try
    {
      ok = _wapi_lookup_handle (handle, 1, &file_handle);
      if (ok == 0) goto <D.12729>; else goto <D.12730>;
      <D.12729>:
      monoeg_g_log (0B, 16, "%s: error looking up file handle %p", &__func__, handle);
      SetLastError (6);
      D.12731 = 0;
      return D.12731;
      <D.12730>:
      file_handle.23 = file_handle;
      fd = file_handle.23->fd;
      file_handle.23 = file_handle;
      D.12733 = BIT_FIELD_REF <*file_handle.23, 64, 192>;
      D.12734 = D.12733 & 5764607523034234880;
      if (D.12734 == 0) goto <D.12735>; else goto <D.12736>;
      <D.12735>:
      SetLastError (5);
      D.12731 = 0;
      return D.12731;
      <D.12736>:
      file_handle.23 = file_handle;
      D.12737 = file_handle.23->filename;
      if (D.12737 == 0B) goto <D.12738>; else goto <D.12739>;
      <D.12738>:
      SetLastError (6);
      D.12731 = 0;
      return D.12731;
      <D.12739>:
      ret = fstat (fd, &statbuf);
      if (ret == -1) goto <D.12740>; else goto <D.12741>;
      <D.12740>:
      SetLastError (87);
      D.12731 = 0;
      return D.12731;
      <D.12741>:
      if (last_access != 0B) goto <D.12742>; else goto <D.12743>;
      <D.12742>:
      D.12744 = last_access->dwHighDateTime;
      D.12745 = (long unsigned int) D.12744;
      D.12746 = D.12745 << 32;
      D.12747 = last_access->dwLowDateTime;
      D.12748 = (long unsigned int) D.12747;
      access_ticks = D.12746 + D.12748;
      if (access_ticks <= 116444735999999999) goto <D.12749>; else goto <D.12750>;
      <D.12749>:
      SetLastError (87);
      D.12731 = 0;
      return D.12731;
      <D.12750>:
      D.12751 = access_ticks + 18330299337709551616;
      D.12752 = D.12751 / 10000000;
      D.12753 = (long int) D.12752;
      utbuf.actime = D.12753;
      goto <D.12754>;
      <D.12743>:
      D.12755 = statbuf.st_atim.tv_sec;
      utbuf.actime = D.12755;
      <D.12754>:
      if (last_write != 0B) goto <D.12756>; else goto <D.12757>;
      <D.12756>:
      D.12758 = last_write->dwHighDateTime;
      D.12759 = (long unsigned int) D.12758;
      D.12760 = D.12759 << 32;
      D.12761 = last_write->dwLowDateTime;
      D.12762 = (long unsigned int) D.12761;
      write_ticks = D.12760 + D.12762;
      if (write_ticks <= 116444735999999999) goto <D.12763>; else goto <D.12764>;
      <D.12763>:
      SetLastError (87);
      D.12731 = 0;
      return D.12731;
      <D.12764>:
      D.12765 = write_ticks + 18330299337709551616;
      D.12766 = D.12765 / 10000000;
      D.12767 = (long int) D.12766;
      utbuf.modtime = D.12767;
      goto <D.12768>;
      <D.12757>:
      D.12769 = statbuf.st_mtim.tv_sec;
      utbuf.modtime = D.12769;
      <D.12768>:
      file_handle.23 = file_handle;
      D.12737 = file_handle.23->filename;
      ret = _wapi_utime (D.12737, &utbuf);
      if (ret == -1) goto <D.12770>; else goto <D.12771>;
      <D.12770>:
      SetLastError (87);
      D.12731 = 0;
      return D.12731;
      <D.12771>:
      D.12731 = 1;
      return D.12731;
    }
  finally
    {
      file_handle = {CLOBBER};
      utbuf = {CLOBBER};
      statbuf = {CLOBBER};
    }
}


file_getfiletime (void * handle, struct WapiFileTime * create_time, struct WapiFileTime * last_access, struct WapiFileTime * last_write)
{
  gboolean D.12776;
  struct _WapiHandle_file * file_handle.24;
  unsigned int D.12778;
  signed int D.12779;
  unsigned int D.12782;
  long int D.12787;
  long int D.12788;
  long unsigned int D.12791;
  long unsigned int D.12792;
  long unsigned int D.12794;
  long unsigned int D.12795;
  long int D.12796;
  long unsigned int D.12797;
  long unsigned int D.12798;
  unsigned int D.12801;
  long unsigned int D.12802;
  unsigned int D.12803;
  unsigned int D.12806;
  long unsigned int D.12807;
  unsigned int D.12808;
  unsigned int D.12811;
  long unsigned int D.12812;
  unsigned int D.12813;
  struct _WapiHandle_file * file_handle;
  gboolean ok;
  struct stat statbuf;
  guint64 create_ticks;
  guint64 access_ticks;
  guint64 write_ticks;
  int ret;
  int fd;
  static const char __func__[17] = "file_getfiletime";

  try
    {
      ok = _wapi_lookup_handle (handle, 1, &file_handle);
      if (ok == 0) goto <D.12774>; else goto <D.12775>;
      <D.12774>:
      monoeg_g_log (0B, 16, "%s: error looking up file handle %p", &__func__, handle);
      SetLastError (6);
      D.12776 = 0;
      return D.12776;
      <D.12775>:
      file_handle.24 = file_handle;
      fd = file_handle.24->fd;
      file_handle.24 = file_handle;
      D.12778 = file_handle.24->fileaccess;
      D.12779 = (signed int) D.12778;
      if (D.12779 >= 0) goto <D.12780>; else goto <D.12781>;
      <D.12780>:
      file_handle.24 = file_handle;
      D.12778 = file_handle.24->fileaccess;
      D.12782 = D.12778 & 268435456;
      if (D.12782 == 0) goto <D.12783>; else goto <D.12784>;
      <D.12783>:
      SetLastError (5);
      D.12776 = 0;
      return D.12776;
      <D.12784>:
      <D.12781>:
      ret = fstat (fd, &statbuf);
      if (ret == -1) goto <D.12785>; else goto <D.12786>;
      <D.12785>:
      _wapi_set_last_error_from_errno ();
      D.12776 = 0;
      return D.12776;
      <D.12786>:
      D.12787 = statbuf.st_atim.tv_sec;
      D.12788 = statbuf.st_ctim.tv_sec;
      if (D.12787 < D.12788) goto <D.12789>; else goto <D.12790>;
      <D.12789>:
      D.12787 = statbuf.st_atim.tv_sec;
      D.12791 = (long unsigned int) D.12787;
      D.12792 = D.12791 * 10000000;
      create_ticks = D.12792 + 116444736000000000;
      goto <D.12793>;
      <D.12790>:
      D.12788 = statbuf.st_ctim.tv_sec;
      D.12794 = (long unsigned int) D.12788;
      D.12795 = D.12794 * 10000000;
      create_ticks = D.12795 + 116444736000000000;
      <D.12793>:
      D.12787 = statbuf.st_atim.tv_sec;
      D.12791 = (long unsigned int) D.12787;
      D.12792 = D.12791 * 10000000;
      access_ticks = D.12792 + 116444736000000000;
      D.12796 = statbuf.st_mtim.tv_sec;
      D.12797 = (long unsigned int) D.12796;
      D.12798 = D.12797 * 10000000;
      write_ticks = D.12798 + 116444736000000000;
      if (create_time != 0B) goto <D.12799>; else goto <D.12800>;
      <D.12799>:
      D.12801 = (unsigned int) create_ticks;
      create_time->dwLowDateTime = D.12801;
      D.12802 = create_ticks >> 32;
      D.12803 = (unsigned int) D.12802;
      create_time->dwHighDateTime = D.12803;
      <D.12800>:
      if (last_access != 0B) goto <D.12804>; else goto <D.12805>;
      <D.12804>:
      D.12806 = (unsigned int) access_ticks;
      last_access->dwLowDateTime = D.12806;
      D.12807 = access_ticks >> 32;
      D.12808 = (unsigned int) D.12807;
      last_access->dwHighDateTime = D.12808;
      <D.12805>:
      if (last_write != 0B) goto <D.12809>; else goto <D.12810>;
      <D.12809>:
      D.12811 = (unsigned int) write_ticks;
      last_write->dwLowDateTime = D.12811;
      D.12812 = write_ticks >> 32;
      D.12813 = (unsigned int) D.12812;
      last_write->dwHighDateTime = D.12813;
      <D.12810>:
      D.12776 = 1;
      return D.12776;
    }
  finally
    {
      file_handle = {CLOBBER};
      statbuf = {CLOBBER};
    }
}


file_getfilesize (void * handle, guint32 * highsize)
{
  guint32 D.12818;
  struct _WapiHandle_file * file_handle.25;
  unsigned int D.12820;
  signed int D.12821;
  long unsigned int D.12824;
  long unsigned int D.12825;
  unsigned int D.12830;
  unsigned int D.12831;
  int D.12834;
  long unsigned int bigsize.26;
  long unsigned int D.12840;
  unsigned int D.12841;
  long int D.12842;
  long int D.12845;
  unsigned int D.12846;
  struct _WapiHandle_file * file_handle;
  gboolean ok;
  struct stat statbuf;
  guint32 size;
  int ret;
  int fd;
  static const char __func__[17] = "file_getfilesize";

  try
    {
      ok = _wapi_lookup_handle (handle, 1, &file_handle);
      if (ok == 0) goto <D.12816>; else goto <D.12817>;
      <D.12816>:
      monoeg_g_log (0B, 16, "%s: error looking up file handle %p", &__func__, handle);
      SetLastError (6);
      D.12818 = 4294967295;
      return D.12818;
      <D.12817>:
      file_handle.25 = file_handle;
      fd = file_handle.25->fd;
      file_handle.25 = file_handle;
      D.12820 = file_handle.25->fileaccess;
      D.12821 = (signed int) D.12820;
      if (D.12821 >= 0) goto <D.12822>; else goto <D.12823>;
      <D.12822>:
      file_handle.25 = file_handle;
      D.12824 = BIT_FIELD_REF <*file_handle.25, 64, 192>;
      D.12825 = D.12824 & 5764607523034234880;
      if (D.12825 == 0) goto <D.12826>; else goto <D.12827>;
      <D.12826>:
      SetLastError (5);
      D.12818 = 4294967295;
      return D.12818;
      <D.12827>:
      <D.12823>:
      SetLastError (0);
      ret = fstat (fd, &statbuf);
      if (ret == -1) goto <D.12828>; else goto <D.12829>;
      <D.12828>:
      _wapi_set_last_error_from_errno ();
      D.12818 = 4294967295;
      return D.12818;
      <D.12829>:
      D.12830 = statbuf.st_mode;
      D.12831 = D.12830 & 61440;
      if (D.12831 == 24576) goto <D.12832>; else goto <D.12833>;
      <D.12832>:
      {
        guint64 bigsize;

        try
          {
            D.12834 = ioctl (fd, 2148012658, &bigsize);
            if (D.12834 < 0) goto <D.12835>; else goto <D.12836>;
            <D.12835>:
            _wapi_set_last_error_from_errno ();
            D.12818 = 4294967295;
            return D.12818;
            <D.12836>:
            bigsize.26 = bigsize;
            size = (guint32) bigsize.26;
            if (highsize != 0B) goto <D.12838>; else goto <D.12839>;
            <D.12838>:
            bigsize.26 = bigsize;
            D.12840 = bigsize.26 >> 32;
            D.12841 = (unsigned int) D.12840;
            *highsize = D.12841;
            <D.12839>:
            D.12818 = size;
            return D.12818;
          }
        finally
          {
            bigsize = {CLOBBER};
          }
      }
      <D.12833>:
      D.12842 = statbuf.st_size;
      size = (guint32) D.12842;
      if (highsize != 0B) goto <D.12843>; else goto <D.12844>;
      <D.12843>:
      D.12842 = statbuf.st_size;
      D.12845 = D.12842 >> 32;
      D.12846 = (unsigned int) D.12845;
      *highsize = D.12846;
      <D.12844>:
      D.12818 = size;
      return D.12818;
    }
  finally
    {
      file_handle = {CLOBBER};
      statbuf = {CLOBBER};
    }
}


file_setendoffile (void * handle)
{
  gboolean D.12852;
  struct _WapiHandle_file * file_handle.27;
  long unsigned int D.12854;
  long unsigned int D.12855;
  int * D.12863;
  int D.12864;
  int D.12866;
  struct _WapiHandle_file * file_handle;
  gboolean ok;
  struct stat statbuf;
  off_t size;
  off_t pos;
  int ret;
  int fd;
  static const char __func__[18] = "file_setendoffile";

  try
    {
      ok = _wapi_lookup_handle (handle, 1, &file_handle);
      if (ok == 0) goto <D.12850>; else goto <D.12851>;
      <D.12850>:
      monoeg_g_log (0B, 16, "%s: error looking up file handle %p", &__func__, handle);
      SetLastError (6);
      D.12852 = 0;
      return D.12852;
      <D.12851>:
      file_handle.27 = file_handle;
      fd = file_handle.27->fd;
      file_handle.27 = file_handle;
      D.12854 = BIT_FIELD_REF <*file_handle.27, 64, 192>;
      D.12855 = D.12854 & 5764607523034234880;
      if (D.12855 == 0) goto <D.12856>; else goto <D.12857>;
      <D.12856>:
      SetLastError (5);
      D.12852 = 0;
      return D.12852;
      <D.12857>:
      ret = fstat (fd, &statbuf);
      if (ret == -1) goto <D.12858>; else goto <D.12859>;
      <D.12858>:
      _wapi_set_last_error_from_errno ();
      D.12852 = 0;
      return D.12852;
      <D.12859>:
      size = statbuf.st_size;
      pos = lseek (fd, 0, 1);
      if (pos == -1) goto <D.12860>; else goto <D.12861>;
      <D.12860>:
      _wapi_set_last_error_from_errno ();
      D.12852 = 0;
      return D.12852;
      <D.12861>:
      <D.11542>:
      ret = ftruncate (fd, pos);
      if (ret == -1) goto <D.12862>; else goto <D.11543>;
      <D.12862>:
      D.12863 = __errno_location ();
      D.12864 = *D.12863;
      if (D.12864 == 4) goto <D.12865>; else goto <D.11543>;
      <D.12865>:
      D.12866 = _wapi_thread_cur_apc_pending ();
      if (D.12866 == 0) goto <D.11542>; else goto <D.11543>;
      <D.11543>:
      if (ret == -1) goto <D.12867>; else goto <D.12868>;
      <D.12867>:
      _wapi_set_last_error_from_errno ();
      D.12852 = 0;
      return D.12852;
      <D.12868>:
      D.12852 = 1;
      return D.12852;
    }
  finally
    {
      file_handle = {CLOBBER};
      statbuf = {CLOBBER};
    }
}


file_seek (void * handle, gint32 movedistance, gint32 * highmovedistance, WapiSeekMethod method)
{
  guint32 D.12873;
  struct _WapiHandle_file * file_handle.28;
  unsigned int D.12875;
  signed int D.12876;
  long unsigned int D.12879;
  long unsigned int D.12880;
  int D.12886;
  long int D.12887;
  long int D.12888;
  unsigned int movedistance.29;
  long int D.12890;
  long int D.12895;
  int D.12896;
  struct _WapiHandle_file * file_handle;
  gboolean ok;
  gint64 offset;
  gint64 newpos;
  int whence;
  int fd;
  guint32 ret;
  static const char __func__[10] = "file_seek";

  try
    {
      ok = _wapi_lookup_handle (handle, 1, &file_handle);
      if (ok == 0) goto <D.12871>; else goto <D.12872>;
      <D.12871>:
      monoeg_g_log (0B, 16, "%s: error looking up file handle %p", &__func__, handle);
      SetLastError (6);
      D.12873 = 4294967295;
      return D.12873;
      <D.12872>:
      file_handle.28 = file_handle;
      fd = file_handle.28->fd;
      file_handle.28 = file_handle;
      D.12875 = file_handle.28->fileaccess;
      D.12876 = (signed int) D.12875;
      if (D.12876 >= 0) goto <D.12877>; else goto <D.12878>;
      <D.12877>:
      file_handle.28 = file_handle;
      D.12879 = BIT_FIELD_REF <*file_handle.28, 64, 192>;
      D.12880 = D.12879 & 5764607523034234880;
      if (D.12880 == 0) goto <D.12881>; else goto <D.12882>;
      <D.12881>:
      SetLastError (5);
      D.12873 = 4294967295;
      return D.12873;
      <D.12882>:
      <D.12878>:
      switch (method) <default: <D.11530>, case 0: <D.11526>, case 1: <D.11528>, case 2: <D.11529>>
      <D.11526>:
      whence = 0;
      goto <D.11527>;
      <D.11528>:
      whence = 1;
      goto <D.11527>;
      <D.11529>:
      whence = 2;
      goto <D.11527>;
      <D.11530>:
      SetLastError (87);
      D.12873 = 4294967295;
      return D.12873;
      <D.11527>:
      if (highmovedistance == 0B) goto <D.12883>; else goto <D.12884>;
      <D.12883>:
      offset = (gint64) movedistance;
      goto <D.12885>;
      <D.12884>:
      D.12886 = *highmovedistance;
      D.12887 = (long int) D.12886;
      D.12888 = D.12887 << 32;
      movedistance.29 = (unsigned int) movedistance;
      D.12890 = (long int) movedistance.29;
      offset = D.12888 | D.12890;
      <D.12885>:
      newpos = lseek (fd, offset, whence);
      if (newpos == -1) goto <D.12891>; else goto <D.12892>;
      <D.12891>:
      _wapi_set_last_error_from_errno ();
      D.12873 = 4294967295;
      return D.12873;
      <D.12892>:
      ret = (guint32) newpos;
      if (highmovedistance != 0B) goto <D.12893>; else goto <D.12894>;
      <D.12893>:
      D.12895 = newpos >> 32;
      D.12896 = (int) D.12895;
      *highmovedistance = D.12896;
      <D.12894>:
      D.12873 = ret;
      return D.12873;
    }
  finally
    {
      file_handle = {CLOBBER};
    }
}


file_flush (void * handle)
{
  gboolean D.12901;
  struct _WapiHandle_file * file_handle.30;
  long unsigned int D.12903;
  long unsigned int D.12904;
  struct _WapiHandle_file * file_handle;
  gboolean ok;
  int ret;
  int fd;
  static const char __func__[11] = "file_flush";

  try
    {
      ok = _wapi_lookup_handle (handle, 1, &file_handle);
      if (ok == 0) goto <D.12899>; else goto <D.12900>;
      <D.12899>:
      monoeg_g_log (0B, 16, "%s: error looking up file handle %p", &__func__, handle);
      SetLastError (6);
      D.12901 = 0;
      return D.12901;
      <D.12900>:
      file_handle.30 = file_handle;
      fd = file_handle.30->fd;
      file_handle.30 = file_handle;
      D.12903 = BIT_FIELD_REF <*file_handle.30, 64, 192>;
      D.12904 = D.12903 & 5764607523034234880;
      if (D.12904 == 0) goto <D.12905>; else goto <D.12906>;
      <D.12905>:
      SetLastError (5);
      D.12901 = 0;
      return D.12901;
      <D.12906>:
      ret = fsync (fd);
      if (ret == -1) goto <D.12907>; else goto <D.12908>;
      <D.12907>:
      _wapi_set_last_error_from_errno ();
      D.12901 = 0;
      return D.12901;
      <D.12908>:
      D.12901 = 1;
      return D.12901;
    }
  finally
    {
      file_handle = {CLOBBER};
    }
}


file_write (void * handle, const void * buffer, guint32 numbytes, guint32 * byteswritten, struct WapiOverlapped * overlapped)
{
  gboolean D.12913;
  struct _WapiHandle_file * file_handle.31;
  long unsigned int D.12917;
  long unsigned int D.12918;
  int lock_while_writing.32;
  long int D.12926;
  int D.12927;
  long unsigned int D.12930;
  long int D.12931;
  int * D.12933;
  int D.12934;
  int D.12936;
  unsigned int ret.33;
  struct _WapiHandle_file * file_handle;
  gboolean ok;
  int ret;
  int fd;
  off_t current_pos;
  static const char __func__[11] = "file_write";

  try
    {
      current_pos = 0;
      ok = _wapi_lookup_handle (handle, 1, &file_handle);
      if (ok == 0) goto <D.12911>; else goto <D.12912>;
      <D.12911>:
      monoeg_g_log (0B, 16, "%s: error looking up file handle %p", &__func__, handle);
      SetLastError (6);
      D.12913 = 0;
      return D.12913;
      <D.12912>:
      file_handle.31 = file_handle;
      fd = file_handle.31->fd;
      if (byteswritten != 0B) goto <D.12915>; else goto <D.12916>;
      <D.12915>:
      *byteswritten = 0;
      <D.12916>:
      file_handle.31 = file_handle;
      D.12917 = BIT_FIELD_REF <*file_handle.31, 64, 192>;
      D.12918 = D.12917 & 5764607523034234880;
      if (D.12918 == 0) goto <D.12919>; else goto <D.12920>;
      <D.12919>:
      SetLastError (5);
      D.12913 = 0;
      return D.12913;
      <D.12920>:
      lock_while_writing.32 = lock_while_writing;
      if (lock_while_writing.32 != 0) goto <D.12922>; else goto <D.12923>;
      <D.12922>:
      current_pos = lseek (fd, 0, 1);
      if (current_pos == -1) goto <D.12924>; else goto <D.12925>;
      <D.12924>:
      _wapi_set_last_error_from_errno ();
      D.12913 = 0;
      return D.12913;
      <D.12925>:
      D.12926 = (long int) numbytes;
      D.12927 = _wapi_lock_file_region (fd, current_pos, D.12926);
      if (D.12927 == 0) goto <D.12928>; else goto <D.12929>;
      <D.12928>:
      D.12913 = 0;
      return D.12913;
      <D.12929>:
      <D.12923>:
      <D.11502>:
      D.12930 = (long unsigned int) numbytes;
      D.12931 = write (fd, buffer, D.12930);
      ret = (int) D.12931;
      if (ret == -1) goto <D.12932>; else goto <D.11503>;
      <D.12932>:
      D.12933 = __errno_location ();
      D.12934 = *D.12933;
      if (D.12934 == 4) goto <D.12935>; else goto <D.11503>;
      <D.12935>:
      D.12936 = _wapi_thread_cur_apc_pending ();
      if (D.12936 == 0) goto <D.11502>; else goto <D.11503>;
      <D.11503>:
      lock_while_writing.32 = lock_while_writing;
      if (lock_while_writing.32 != 0) goto <D.12937>; else goto <D.12938>;
      <D.12937>:
      D.12926 = (long int) numbytes;
      _wapi_unlock_file_region (fd, current_pos, D.12926);
      <D.12938>:
      if (ret == -1) goto <D.12939>; else goto <D.12940>;
      <D.12939>:
      D.12933 = __errno_location ();
      D.12934 = *D.12933;
      if (D.12934 == 4) goto <D.12941>; else goto <D.12942>;
      <D.12941>:
      ret = 0;
      goto <D.12943>;
      <D.12942>:
      _wapi_set_last_error_from_errno ();
      D.12913 = 0;
      return D.12913;
      <D.12943>:
      <D.12940>:
      if (byteswritten != 0B) goto <D.12944>; else goto <D.12945>;
      <D.12944>:
      ret.33 = (unsigned int) ret;
      *byteswritten = ret.33;
      <D.12945>:
      D.12913 = 1;
      return D.12913;
    }
  finally
    {
      file_handle = {CLOBBER};
    }
}


file_read (void * handle, void * buffer, guint32 numbytes, guint32 * bytesread, struct WapiOverlapped * overlapped)
{
  gboolean D.12951;
  struct _WapiHandle_file * file_handle.34;
  unsigned int D.12955;
  signed int D.12956;
  unsigned int D.12959;
  long unsigned int D.12962;
  long int D.12963;
  int * D.12965;
  int D.12966;
  int D.12968;
  int D.12971;
  unsigned int D.12972;
  unsigned int ret.35;
  struct _WapiHandle_file * file_handle;
  gboolean ok;
  int fd;
  int ret;
  static const char __func__[10] = "file_read";

  try
    {
      ok = _wapi_lookup_handle (handle, 1, &file_handle);
      if (ok == 0) goto <D.12949>; else goto <D.12950>;
      <D.12949>:
      monoeg_g_log (0B, 16, "%s: error looking up file handle %p", &__func__, handle);
      SetLastError (6);
      D.12951 = 0;
      return D.12951;
      <D.12950>:
      file_handle.34 = file_handle;
      fd = file_handle.34->fd;
      if (bytesread != 0B) goto <D.12953>; else goto <D.12954>;
      <D.12953>:
      *bytesread = 0;
      <D.12954>:
      file_handle.34 = file_handle;
      D.12955 = file_handle.34->fileaccess;
      D.12956 = (signed int) D.12955;
      if (D.12956 >= 0) goto <D.12957>; else goto <D.12958>;
      <D.12957>:
      file_handle.34 = file_handle;
      D.12955 = file_handle.34->fileaccess;
      D.12959 = D.12955 & 268435456;
      if (D.12959 == 0) goto <D.12960>; else goto <D.12961>;
      <D.12960>:
      SetLastError (5);
      D.12951 = 0;
      return D.12951;
      <D.12961>:
      <D.12958>:
      <D.11486>:
      D.12962 = (long unsigned int) numbytes;
      D.12963 = read (fd, buffer, D.12962);
      ret = (int) D.12963;
      if (ret == -1) goto <D.12964>; else goto <D.11487>;
      <D.12964>:
      D.12965 = __errno_location ();
      D.12966 = *D.12965;
      if (D.12966 == 4) goto <D.12967>; else goto <D.11487>;
      <D.12967>:
      D.12968 = _wapi_thread_cur_apc_pending ();
      if (D.12968 == 0) goto <D.11486>; else goto <D.11487>;
      <D.11487>:
      if (ret == -1) goto <D.12969>; else goto <D.12970>;
      <D.12969>:
      {
        gint err;

        D.12965 = __errno_location ();
        err = *D.12965;
        D.12971 = _wapi_get_win32_file_error (err);
        D.12972 = (unsigned int) D.12971;
        SetLastError (D.12972);
        D.12951 = 0;
        return D.12951;
      }
      <D.12970>:
      if (bytesread != 0B) goto <D.12973>; else goto <D.12974>;
      <D.12973>:
      ret.35 = (unsigned int) ret;
      *bytesread = ret.35;
      <D.12974>:
      D.12951 = 1;
      return D.12951;
    }
  finally
    {
      file_handle = {CLOBBER};
    }
}


file_getfiletype ()
{
  WapiFileType D.12978;

  D.12978 = 1;
  return D.12978;
}


_wapi_handle_type (void * handle)
{
  long int handle.36;
  unsigned int D.12985;
  struct _WapiHandleUnshared * D.12986;
  WapiHandleType D.12987;
  unsigned int D.12988;
  struct _WapiHandleUnshared * D.12989;
  long unsigned int D.12990;
  long unsigned int D.12991;
  long unsigned int D.12992;
  struct _WapiHandleUnshared * D.12993;
  guint32 idx;

  handle.36 = (long int) handle;
  idx = (guint32) handle.36;
  if (idx > 4194303) goto <D.12981>; else goto <D.12983>;
  <D.12983>:
  if (idx > 268435455) goto <D.12981>; else goto <D.12984>;
  <D.12984>:
  D.12985 = idx / 256;
  D.12986 = _wapi_private_handles[D.12985];
  if (D.12986 == 0B) goto <D.12981>; else goto <D.12982>;
  <D.12981>:
  D.12987 = 0;
  return D.12987;
  <D.12982>:
  D.12988 = idx / 256;
  D.12989 = _wapi_private_handles[D.12988];
  D.12990 = (long unsigned int) idx;
  D.12991 = D.12990 & 255;
  D.12992 = D.12991 * 200;
  D.12993 = D.12989 + D.12992;
  D.12987 = D.12993->type;
  return D.12987;
}


WriteFile (void * handle, const void * buffer, guint32 numbytes, guint32 * byteswritten, struct WapiOverlapped * overlapped)
{
  gboolean (*<T1c19>) (void *, const void *, guint32, guint32 *, struct WapiOverlapped *) D.12995;
  gboolean D.12998;
  WapiHandleType type;

  type = _wapi_handle_type (handle);
  D.12995 = io_ops[type].writefile;
  if (D.12995 == 0B) goto <D.12996>; else goto <D.12997>;
  <D.12996>:
  SetLastError (6);
  D.12998 = 0;
  return D.12998;
  <D.12997>:
  D.12995 = io_ops[type].writefile;
  D.12998 = D.12995 (handle, buffer, numbytes, byteswritten, overlapped);
  return D.12998;
}


FlushFileBuffers (void * handle)
{
  gboolean (*<T1958>) (void *) D.13000;
  gboolean D.13003;
  WapiHandleType type;

  type = _wapi_handle_type (handle);
  D.13000 = io_ops[type].flushfile;
  if (D.13000 == 0B) goto <D.13001>; else goto <D.13002>;
  <D.13001>:
  SetLastError (6);
  D.13003 = 0;
  return D.13003;
  <D.13002>:
  D.13000 = io_ops[type].flushfile;
  D.13003 = D.13000 (handle);
  return D.13003;
}


SetEndOfFile (void * handle)
{
  gboolean (*<T1958>) (void *) D.13005;
  gboolean D.13008;
  WapiHandleType type;

  type = _wapi_handle_type (handle);
  D.13005 = io_ops[type].setendoffile;
  if (D.13005 == 0B) goto <D.13006>; else goto <D.13007>;
  <D.13006>:
  SetLastError (6);
  D.13008 = 0;
  return D.13008;
  <D.13007>:
  D.13005 = io_ops[type].setendoffile;
  D.13008 = D.13005 (handle);
  return D.13008;
}


SetFilePointer (void * handle, gint32 movedistance, gint32 * highmovedistance, WapiSeekMethod method)
{
  guint32 (*<T1c1f>) (void *, gint32, gint32 *, WapiSeekMethod) D.13010;
  guint32 D.13013;
  WapiHandleType type;

  type = _wapi_handle_type (handle);
  D.13010 = io_ops[type].seek;
  if (D.13010 == 0B) goto <D.13011>; else goto <D.13012>;
  <D.13011>:
  SetLastError (6);
  D.13013 = 4294967295;
  return D.13013;
  <D.13012>:
  D.13010 = io_ops[type].seek;
  D.13013 = D.13010 (handle, movedistance, highmovedistance, method);
  return D.13013;
}


GetFileType (void * handle)
{
  long int handle.37;
  unsigned int D.13018;
  unsigned int D.13020;
  struct _WapiHandleUnshared * D.13021;
  WapiFileType D.13022;
  WapiFileType (*<T1c11>) (void) D.13023;
  WapiHandleType type;

  handle.37 = (long int) handle;
  D.13018 = (unsigned int) handle.37;
  if (D.13018 > 268435455) goto <D.13015>; else goto <D.13019>;
  <D.13019>:
  handle.37 = (long int) handle;
  D.13018 = (unsigned int) handle.37;
  D.13020 = D.13018 / 256;
  D.13021 = _wapi_private_handles[D.13020];
  if (D.13021 == 0B) goto <D.13015>; else goto <D.13016>;
  <D.13015>:
  SetLastError (6);
  D.13022 = 0;
  return D.13022;
  <D.13016>:
  type = _wapi_handle_type (handle);
  D.13023 = io_ops[type].getfiletype;
  if (D.13023 == 0B) goto <D.13024>; else goto <D.13025>;
  <D.13024>:
  SetLastError (6);
  D.13022 = 0;
  return D.13022;
  <D.13025>:
  D.13023 = io_ops[type].getfiletype;
  D.13022 = D.13023 ();
  return D.13022;
}


GetFileSize (void * handle, guint32 * highsize)
{
  guint32 (*<T1c25>) (void *, guint32 *) D.13027;
  guint32 D.13030;
  WapiHandleType type;

  type = _wapi_handle_type (handle);
  D.13027 = io_ops[type].getfilesize;
  if (D.13027 == 0B) goto <D.13028>; else goto <D.13029>;
  <D.13028>:
  SetLastError (6);
  D.13030 = 4294967295;
  return D.13030;
  <D.13029>:
  D.13027 = io_ops[type].getfilesize;
  D.13030 = D.13027 (handle, highsize);
  return D.13030;
}


GetFileTime (void * handle, struct WapiFileTime * create_time, struct WapiFileTime * last_access, struct WapiFileTime * last_write)
{
  gboolean (*<T1c29>) (void *, struct WapiFileTime *, struct WapiFileTime *, struct WapiFileTime *) D.13032;
  gboolean D.13035;
  WapiHandleType type;

  type = _wapi_handle_type (handle);
  D.13032 = io_ops[type].getfiletime;
  if (D.13032 == 0B) goto <D.13033>; else goto <D.13034>;
  <D.13033>:
  SetLastError (6);
  D.13035 = 0;
  return D.13035;
  <D.13034>:
  D.13032 = io_ops[type].getfiletime;
  D.13035 = D.13032 (handle, create_time, last_access, last_write);
  return D.13035;
}


SetFileTime (void * handle, const struct WapiFileTime * create_time, const struct WapiFileTime * last_access, const struct WapiFileTime * last_write)
{
  gboolean (*<T1c2d>) (void *, const struct WapiFileTime *, const struct WapiFileTime *, const struct WapiFileTime *) D.13037;
  gboolean D.13040;
  WapiHandleType type;

  type = _wapi_handle_type (handle);
  D.13037 = io_ops[type].setfiletime;
  if (D.13037 == 0B) goto <D.13038>; else goto <D.13039>;
  <D.13038>:
  SetLastError (6);
  D.13040 = 0;
  return D.13040;
  <D.13039>:
  D.13037 = io_ops[type].setfiletime;
  D.13040 = D.13037 (handle, create_time, last_access, last_write);
  return D.13040;
}


FileTimeToSystemTime (const struct WapiFileTime * file_time, struct WapiSystemTime * system_time)
{
  gboolean D.13044;
  unsigned int D.13045;
  long int D.13046;
  long int D.13047;
  unsigned int D.13048;
  long int D.13049;
  long long int D.13052;
  short unsigned int D.13053;
  long int D.13054;
  short unsigned int D.13055;
  long int D.13056;
  short unsigned int D.13057;
  long int D.13058;
  short unsigned int D.13059;
  long int D.13060;
  long int D.13061;
  short unsigned int D.13062;
  short unsigned int D.13063;
  long int D.13064;
  long int D.13065;
  long int D.13066;
  _Bool D.13067;
  long int D.13068;
  long int D.13069;
  long int D.13070;
  long int D.13071;
  _Bool D.13072;
  long int D.13073;
  long int D.13074;
  long int D.13075;
  long int D.13076;
  _Bool D.13077;
  long int D.13078;
  long int D.13079;
  long int D.13080;
  long int D.13081;
  long int D.13082;
  _Bool D.13083;
  long int D.13084;
  long int D.13085;
  long int D.13086;
  long int D.13087;
  long int D.13088;
  long int D.13089;
  _Bool D.13090;
  long int D.13091;
  long int D.13092;
  long int D.13093;
  long int D.13094;
  _Bool D.13095;
  long int D.13096;
  long int D.13097;
  long int D.13098;
  long int D.13099;
  long int D.13100;
  _Bool D.13101;
  long int D.13102;
  long int D.13103;
  long int D.13104;
  long int D.13105;
  long int D.13106;
  long int D.13107;
  long int D.13108;
  gint64 iftmp.38;
  unsigned long y.39;
  unsigned long D.13115;
  long int D.13117;
  long int D.13119;
  short unsigned int D.13120;
  int iftmp.40;
  long unsigned int y.41;
  long unsigned int D.13128;
  const guint16 * D.13129;
  short unsigned int D.13130;
  long int D.13131;
  short unsigned int D.13132;
  short unsigned int D.13133;
  short unsigned int D.13134;
  gint64 file_ticks;
  gint64 totaldays;
  gint64 rem;
  gint64 y;
  const guint16 * ip;
  static const char __func__[21] = "FileTimeToSystemTime";

  if (system_time == 0B) goto <D.13042>; else goto <D.13043>;
  <D.13042>:
  SetLastError (87);
  D.13044 = 0;
  return D.13044;
  <D.13043>:
  D.13045 = file_time->dwHighDateTime;
  D.13046 = (long int) D.13045;
  D.13047 = D.13046 << 32;
  D.13048 = file_time->dwLowDateTime;
  D.13049 = (long int) D.13048;
  file_ticks = D.13047 + D.13049;
  if (file_ticks < 0) goto <D.13050>; else goto <D.13051>;
  <D.13050>:
  SetLastError (87);
  D.13044 = 0;
  return D.13044;
  <D.13051>:
  totaldays = file_ticks / 864000000000;
  rem = file_ticks % 864000000000;
  D.13052 = rem / 36000000000;
  D.13053 = (short unsigned int) D.13052;
  system_time->wHour = D.13053;
  rem = rem % 36000000000;
  D.13054 = rem / 600000000;
  D.13055 = (short unsigned int) D.13054;
  system_time->wMinute = D.13055;
  rem = rem % 600000000;
  D.13056 = rem / 10000000;
  D.13057 = (short unsigned int) D.13056;
  system_time->wSecond = D.13057;
  rem = rem % 10000000;
  D.13058 = rem / 10000;
  D.13059 = (short unsigned int) D.13058;
  system_time->wMilliseconds = D.13059;
  D.13060 = totaldays + 1;
  D.13061 = D.13060 % 7;
  D.13062 = (short unsigned int) D.13061;
  D.13063 = D.13062 + 1;
  system_time->wDayOfWeek = D.13063;
  y = 1601;
  goto <D.11885>;
  <D.11884>:
  {
    gint64 yg;

    D.13064 = totaldays / 365;
    D.13065 = D.13064 + y;
    D.13066 = totaldays % 365;
    D.13067 = D.13066 < 0;
    D.13068 = (long int) D.13067;
    yg = D.13065 - D.13068;
    D.13069 = yg + -1;
    D.13070 = D.13069 / 4;
    D.13069 = yg + -1;
    D.13071 = D.13069 % 4;
    D.13072 = D.13071 < 0;
    D.13073 = (long int) D.13072;
    D.13074 = D.13070 - D.13073;
    D.13069 = yg + -1;
    D.13075 = D.13069 / 100;
    D.13069 = yg + -1;
    D.13076 = D.13069 % 100;
    D.13077 = D.13076 < 0;
    D.13078 = (long int) D.13077;
    D.13079 = D.13075 - D.13078;
    D.13080 = D.13074 - D.13079;
    D.13069 = yg + -1;
    D.13081 = D.13069 / 400;
    D.13069 = yg + -1;
    D.13082 = D.13069 % 400;
    D.13083 = D.13082 < 0;
    D.13084 = (long int) D.13083;
    D.13085 = D.13081 - D.13084;
    D.13086 = D.13080 + D.13085;
    D.13087 = y + -1;
    D.13088 = D.13087 / 4;
    D.13087 = y + -1;
    D.13089 = D.13087 % 4;
    D.13090 = D.13089 < 0;
    D.13091 = (long int) D.13090;
    D.13092 = D.13088 - D.13091;
    D.13087 = y + -1;
    D.13093 = D.13087 / 100;
    D.13087 = y + -1;
    D.13094 = D.13087 % 100;
    D.13095 = D.13094 < 0;
    D.13096 = (long int) D.13095;
    D.13097 = D.13093 - D.13096;
    D.13098 = D.13092 - D.13097;
    D.13087 = y + -1;
    D.13099 = D.13087 / 400;
    D.13087 = y + -1;
    D.13100 = D.13087 % 400;
    D.13101 = D.13100 < 0;
    D.13102 = (long int) D.13101;
    D.13103 = D.13099 - D.13102;
    D.13104 = D.13098 + D.13103;
    monoeg_g_log (0B, 32, "%s: LEAPS(yg): %lld LEAPS(y): %lld", &__func__, D.13086, D.13104);
    D.13105 = yg - y;
    D.13106 = D.13105 * 365;
    D.13069 = yg + -1;
    D.13070 = D.13069 / 4;
    D.13069 = yg + -1;
    D.13071 = D.13069 % 4;
    D.13072 = D.13071 < 0;
    D.13073 = (long int) D.13072;
    D.13074 = D.13070 - D.13073;
    D.13069 = yg + -1;
    D.13075 = D.13069 / 100;
    D.13069 = yg + -1;
    D.13076 = D.13069 % 100;
    D.13077 = D.13076 < 0;
    D.13078 = (long int) D.13077;
    D.13079 = D.13075 - D.13078;
    D.13080 = D.13074 - D.13079;
    D.13069 = yg + -1;
    D.13081 = D.13069 / 400;
    D.13069 = yg + -1;
    D.13082 = D.13069 % 400;
    D.13083 = D.13082 < 0;
    D.13084 = (long int) D.13083;
    D.13085 = D.13081 - D.13084;
    D.13086 = D.13080 + D.13085;
    D.13107 = D.13106 + D.13086;
    D.13087 = y + -1;
    D.13088 = D.13087 / 4;
    D.13087 = y + -1;
    D.13089 = D.13087 % 4;
    D.13090 = D.13089 < 0;
    D.13091 = (long int) D.13090;
    D.13092 = D.13088 - D.13091;
    D.13087 = y + -1;
    D.13093 = D.13087 / 100;
    D.13087 = y + -1;
    D.13094 = D.13087 % 100;
    D.13095 = D.13094 < 0;
    D.13096 = (long int) D.13095;
    D.13097 = D.13093 - D.13096;
    D.13098 = D.13092 - D.13097;
    D.13087 = y + -1;
    D.13099 = D.13087 / 400;
    D.13087 = y + -1;
    D.13100 = D.13087 % 400;
    D.13101 = D.13100 < 0;
    D.13102 = (long int) D.13101;
    D.13103 = D.13099 - D.13102;
    D.13104 = D.13098 + D.13103;
    D.13108 = D.13107 - D.13104;
    totaldays = totaldays - D.13108;
    y = yg;
  }
  <D.11885>:
  if (totaldays < 0) goto <D.11884>; else goto <D.13109>;
  <D.13109>:
  y.39 = (unsigned long) y;
  D.13115 = y.39 & 3;
  if (D.13115 == 0) goto <D.13116>; else goto <D.13111>;
  <D.13116>:
  D.13117 = y % 100;
  if (D.13117 != 0) goto <D.13112>; else goto <D.13118>;
  <D.13118>:
  D.13119 = y % 400;
  if (D.13119 == 0) goto <D.13112>; else goto <D.13111>;
  <D.13112>:
  iftmp.38 = 366;
  goto <D.13113>;
  <D.13111>:
  iftmp.38 = 365;
  <D.13113>:
  if (iftmp.38 <= totaldays) goto <D.11884>; else goto <D.11886>;
  <D.11886>:
  D.13120 = (short unsigned int) y;
  system_time->wYear = D.13120;
  y.39 = (unsigned long) y;
  D.13115 = y.39 & 3;
  if (D.13115 == 0) goto <D.13125>; else goto <D.13122>;
  <D.13125>:
  D.13117 = y % 100;
  if (D.13117 != 0) goto <D.13123>; else goto <D.13126>;
  <D.13126>:
  D.13119 = y % 400;
  if (D.13119 == 0) goto <D.13123>; else goto <D.13122>;
  <D.13123>:
  iftmp.40 = 1;
  goto <D.13124>;
  <D.13122>:
  iftmp.40 = 0;
  <D.13124>:
  ip = &mon_yday[iftmp.40];
  y = 11;
  goto <D.11889>;
  <D.11888>:
  // predicted unlikely by continue predictor.
  goto <D.11887>;
  <D.11887>:
  y = y + -1;
  <D.11889>:
  y.41 = (long unsigned int) y;
  D.13128 = y.41 * 2;
  D.13129 = ip + D.13128;
  D.13130 = *D.13129;
  D.13131 = (long int) D.13130;
  if (D.13131 > totaldays) goto <D.11888>; else goto <D.11890>;
  <D.11890>:
  y.41 = (long unsigned int) y;
  D.13128 = y.41 * 2;
  D.13129 = ip + D.13128;
  D.13130 = *D.13129;
  D.13131 = (long int) D.13130;
  totaldays = totaldays - D.13131;
  D.13120 = (short unsigned int) y;
  D.13132 = D.13120 + 1;
  system_time->wMonth = D.13132;
  D.13133 = (short unsigned int) totaldays;
  D.13134 = D.13133 + 1;
  system_time->wDay = D.13134;
  D.13044 = 1;
  return D.13044;
}


FindFirstFile (const gunichar2 * pattern, struct WapiFindData * find_data)
{
  void * D.13138;
  int D.13149;
  struct _WapiHandle_find find_handle;
  void * handle;
  gchar * utf8_pattern;
  gchar * dir_part;
  gchar * entry_part;
  int result;
  static const char __func__[14] = "FindFirstFile";

  try
    {
      find_handle = {};
      utf8_pattern = 0B;
      if (pattern == 0B) goto <D.13136>; else goto <D.13137>;
      <D.13136>:
      SetLastError (3);
      D.13138 = -1B;
      return D.13138;
      <D.13137>:
      utf8_pattern = mono_unicode_to_external (pattern);
      if (utf8_pattern == 0B) goto <D.13139>; else goto <D.13140>;
      <D.13139>:
      SetLastError (123);
      D.13138 = -1B;
      return D.13138;
      <D.13140>:
      dir_part = _wapi_dirname (utf8_pattern);
      entry_part = _wapi_basename (utf8_pattern);
      find_handle.namelist = 0B;
      result = _wapi_io_scandir (dir_part, entry_part, &find_handle.namelist);
      if (result == 0) goto <D.13141>; else goto <D.13142>;
      <D.13141>:
      SetLastError (2);
      monoeg_g_free (utf8_pattern);
      monoeg_g_free (entry_part);
      monoeg_g_free (dir_part);
      D.13138 = -1B;
      return D.13138;
      <D.13142>:
      if (result < 0) goto <D.13143>; else goto <D.13144>;
      <D.13143>:
      _wapi_set_last_path_error_from_errno (dir_part, 0B);
      monoeg_g_free (utf8_pattern);
      monoeg_g_free (entry_part);
      monoeg_g_free (dir_part);
      D.13138 = -1B;
      return D.13138;
      <D.13144>:
      monoeg_g_free (utf8_pattern);
      monoeg_g_free (entry_part);
      find_handle.dir_part = dir_part;
      find_handle.num = result;
      find_handle.count = 0;
      handle = _wapi_handle_new (8, &find_handle);
      if (handle == -1B) goto <D.13145>; else goto <D.13146>;
      <D.13145>:
      monoeg_g_log (0B, 16, "%s: error creating find handle", &__func__);
      monoeg_g_free (dir_part);
      monoeg_g_free (entry_part);
      monoeg_g_free (utf8_pattern);
      SetLastError (31);
      D.13138 = -1B;
      return D.13138;
      <D.13146>:
      if (handle != -1B) goto <D.13147>; else goto <D.13148>;
      <D.13147>:
      D.13149 = FindNextFile (handle, find_data);
      if (D.13149 == 0) goto <D.13150>; else goto <D.13151>;
      <D.13150>:
      FindClose (handle);
      SetLastError (18);
      handle = -1B;
      <D.13151>:
      <D.13148>:
      D.13138 = handle;
      return D.13138;
    }
  finally
    {
      find_handle = {CLOBBER};
    }
}


FindNextFile (void * handle, struct WapiFindData * find_data)
{
  gboolean D.13156;
  long int D.13157;
  long int D.13158;
  _Bool D.13161;
  long int D.13162;
  long int D.13163;
  struct _WapiHandle_find * find_handle.42;
  long unsigned int D.13167;
  int D.13168;
  long unsigned int D.13169;
  gchar * D.13172;
  gchar * * D.13173;
  long unsigned int D.13174;
  long unsigned int D.13175;
  long unsigned int D.13176;
  gchar * * D.13177;
  gchar * D.13178;
  int * D.13181;
  int D.13182;
  long int D.13191;
  long int D.13192;
  unsigned int D.13196;
  struct WapiFileTime * D.13197;
  long int D.13198;
  struct WapiFileTime * D.13199;
  struct WapiFileTime * D.13200;
  unsigned int D.13201;
  unsigned int D.13202;
  long int D.13206;
  long int D.13207;
  unsigned int D.13208;
  unsigned int D.13209;
  long int bytes.43;
  long int bytes.44;
  gunichar2[260] * D.13214;
  long int D.13215;
  long unsigned int D.13216;
  struct _WapiHandle_find * find_handle;
  gboolean ok;
  struct stat buf;
  struct stat linkbuf;
  int result;
  gchar * filename;
  gchar * utf8_filename;
  gchar * utf8_basename;
  gunichar2 * utf16_basename;
  time_t create_time;
  glong bytes;
  int thr_ret;
  gboolean ret;
  static const char __func__[13] = "FindNextFile";
  void retry = <<< error >>>;
  void cleanup = <<< error >>>;

  try
    {
      ret = 0;
      ok = _wapi_lookup_handle (handle, 8, &find_handle);
      if (ok == 0) goto <D.13154>; else goto <D.13155>;
      <D.13154>:
      monoeg_g_log (0B, 16, "%s: error looking up find handle %p", &__func__, handle);
      SetLastError (6);
      D.13156 = 0;
      return D.13156;
      <D.13155>:
      {
        struct __pthread_unwind_buf_t __cancel_buf;
        void (*<Tc6>) (void *) __cancel_routine;
        void * __cancel_arg;
        int __not_first_call;

        try
          {
            __cancel_routine = _wapi_handle_unlock_handle;
            __cancel_arg = handle;
            __not_first_call = __sigsetjmp (&__cancel_buf.__cancel_jmp_buf, 0);
            D.13157 = (long int) __not_first_call;
            D.13158 = __builtin_expect (D.13157, 0);
            if (D.13158 != 0) goto <D.13159>; else goto <D.13160>;
            <D.13159>:
            __cancel_routine (__cancel_arg);
            __pthread_unwind_next (&__cancel_buf);
            <D.13160>:
            __pthread_register_cancel (&__cancel_buf);
            thr_ret = _wapi_handle_lock_handle (handle);
            D.13161 = thr_ret != 0;
            D.13162 = (long int) D.13161;
            D.13163 = __builtin_expect (D.13162, 0);
            if (D.13163 != 0) goto <D.13164>; else goto <D.13165>;
            <D.13164>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "io.c", 2803, "thr_ret == 0");
            <D.13165>:
            retry:
            find_handle.42 = find_handle;
            D.13167 = find_handle.42->count;
            find_handle.42 = find_handle;
            D.13168 = find_handle.42->num;
            D.13169 = (long unsigned int) D.13168;
            if (D.13167 >= D.13169) goto <D.13170>; else goto <D.13171>;
            <D.13170>:
            SetLastError (18);
            goto cleanup;
            <D.13171>:
            find_handle.42 = find_handle;
            D.13172 = find_handle.42->dir_part;
            find_handle.42 = find_handle;
            D.13173 = find_handle.42->namelist;
            find_handle.42 = find_handle;
            D.13167 = find_handle.42->count;
            D.13174 = D.13167;
            D.13175 = D.13174 + 1;
            find_handle.42->count = D.13175;
            D.13176 = D.13174 * 8;
            D.13177 = D.13173 + D.13176;
            D.13178 = *D.13177;
            filename = monoeg_g_build_path ("/", D.13172, D.13178, 0B);
            result = _wapi_stat (filename, &buf);
            if (result == -1) goto <D.13179>; else goto <D.13180>;
            <D.13179>:
            D.13181 = __errno_location ();
            D.13182 = *D.13181;
            if (D.13182 == 2) goto <D.13183>; else goto <D.13184>;
            <D.13183>:
            result = _wapi_lstat (filename, &buf);
            <D.13184>:
            <D.13180>:
            if (result != 0) goto <D.13185>; else goto <D.13186>;
            <D.13185>:
            monoeg_g_free (filename);
            goto retry;
            <D.13186>:
            result = _wapi_lstat (filename, &linkbuf);
            if (result != 0) goto <D.13187>; else goto <D.13188>;
            <D.13187>:
            monoeg_g_free (filename);
            goto retry;
            <D.13188>:
            utf8_filename = mono_utf8_from_external (filename);
            if (utf8_filename == 0B) goto <D.13189>; else goto <D.13190>;
            <D.13189>:
            monoeg_g_log (0B, 16, "%s: Bad encoding for \'%s\'\nConsider using MONO_EXTERNAL_ENCODINGS\n", &__func__, filename);
            monoeg_g_free (filename);
            goto retry;
            <D.13190>:
            monoeg_g_free (filename);
            D.13191 = buf.st_mtim.tv_sec;
            D.13192 = buf.st_ctim.tv_sec;
            if (D.13191 < D.13192) goto <D.13193>; else goto <D.13194>;
            <D.13193>:
            create_time = buf.st_mtim.tv_sec;
            goto <D.13195>;
            <D.13194>:
            create_time = buf.st_ctim.tv_sec;
            <D.13195>:
            D.13196 = _wapi_stat_to_file_attributes (utf8_filename, &buf, &linkbuf);
            find_data->dwFileAttributes = D.13196;
            D.13197 = &find_data->ftCreationTime;
            _wapi_time_t_to_filetime (create_time, D.13197);
            D.13198 = buf.st_atim.tv_sec;
            D.13199 = &find_data->ftLastAccessTime;
            _wapi_time_t_to_filetime (D.13198, D.13199);
            D.13191 = buf.st_mtim.tv_sec;
            D.13200 = &find_data->ftLastWriteTime;
            _wapi_time_t_to_filetime (D.13191, D.13200);
            D.13201 = find_data->dwFileAttributes;
            D.13202 = D.13201 & 16;
            if (D.13202 != 0) goto <D.13203>; else goto <D.13204>;
            <D.13203>:
            find_data->nFileSizeHigh = 0;
            find_data->nFileSizeLow = 0;
            goto <D.13205>;
            <D.13204>:
            D.13206 = buf.st_size;
            D.13207 = D.13206 >> 32;
            D.13208 = (unsigned int) D.13207;
            find_data->nFileSizeHigh = D.13208;
            D.13206 = buf.st_size;
            D.13209 = (unsigned int) D.13206;
            find_data->nFileSizeLow = D.13209;
            <D.13205>:
            find_data->dwReserved0 = 0;
            find_data->dwReserved1 = 0;
            utf8_basename = _wapi_basename (utf8_filename);
            utf16_basename = monoeg_g_utf8_to_utf16 (utf8_basename, -1, 0B, &bytes, 0B);
            if (utf16_basename == 0B) goto <D.13210>; else goto <D.13211>;
            <D.13210>:
            monoeg_g_free (utf8_basename);
            monoeg_g_free (utf8_filename);
            goto retry;
            <D.13211>:
            ret = 1;
            bytes.43 = bytes;
            bytes.44 = bytes.43 * 2;
            bytes = bytes.44;
            D.13214 = &find_data->cFileName;
            memset (D.13214, 0, 520);
            D.13214 = &find_data->cFileName;
            bytes.43 = bytes;
            D.13215 = MIN_EXPR <bytes.43, 518>;
            D.13216 = (long unsigned int) D.13215;
            memcpy (D.13214, utf16_basename, D.13216);
            find_data->cAlternateFileName[0] = 0;
            monoeg_g_free (utf8_basename);
            monoeg_g_free (utf8_filename);
            monoeg_g_free (utf16_basename);
            cleanup:
            thr_ret = _wapi_handle_unlock_handle (handle);
            D.13161 = thr_ret != 0;
            D.13162 = (long int) D.13161;
            D.13163 = __builtin_expect (D.13162, 0);
            if (D.13163 != 0) goto <D.13217>; else goto <D.13218>;
            <D.13217>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "io.c", 2910, "thr_ret == 0");
            <D.13218>:
            __pthread_unregister_cancel (&__cancel_buf);
            if (0 != 0) goto <D.13219>; else goto <D.13220>;
            <D.13219>:
            __cancel_routine (__cancel_arg);
            <D.13220>:
          }
        finally
          {
            __cancel_buf = {CLOBBER};
          }
      }
      D.13156 = ret;
      return D.13156;
    }
  finally
    {
      find_handle = {CLOBBER};
      buf = {CLOBBER};
      linkbuf = {CLOBBER};
      bytes = {CLOBBER};
    }
}


_wapi_handle_lock_handle (void * handle)
{
  long int handle.45;
  int D.13237;
  <unnamed type> D.13240;
  <unnamed type> D.13242;
  <unnamed type> D.13244;
  <unnamed type> D.13246;
  unsigned int D.13247;
  struct _WapiHandleUnshared * D.13248;
  long unsigned int D.13249;
  long unsigned int D.13250;
  long unsigned int D.13251;
  struct _WapiHandleUnshared * D.13252;
  union mono_mutex_t * D.13253;
  guint32 idx;

  handle.45 = (long int) handle;
  idx = (guint32) handle.45;
  if (idx > 4194303) goto <D.13235>; else goto <D.13236>;
  <D.13235>:
  D.13237 = 0;
  return D.13237;
  <D.13236>:
  _wapi_handle_ref (handle);
  D.13240 = _wapi_handle_type (handle);
  if (D.13240 == 9) goto <D.13238>; else goto <D.13241>;
  <D.13241>:
  D.13242 = _wapi_handle_type (handle);
  if (D.13242 == 11) goto <D.13238>; else goto <D.13243>;
  <D.13243>:
  D.13244 = _wapi_handle_type (handle);
  if (D.13244 == 12) goto <D.13238>; else goto <D.13245>;
  <D.13245>:
  D.13246 = _wapi_handle_type (handle);
  if (D.13246 == 13) goto <D.13238>; else goto <D.13239>;
  <D.13238>:
  D.13237 = 0;
  return D.13237;
  <D.13239>:
  D.13247 = idx / 256;
  D.13248 = _wapi_private_handles[D.13247];
  D.13249 = (long unsigned int) idx;
  D.13250 = D.13249 & 255;
  D.13251 = D.13250 * 200;
  D.13252 = D.13248 + D.13251;
  D.13253 = &D.13252->signal_mutex;
  D.13237 = pthread_mutex_lock (D.13253);
  return D.13237;
}


_wapi_stat_to_file_attributes (const gchar * pathname, struct stat * buf, struct stat * lbuf)
{
  unsigned int D.13255;
  unsigned int D.13256;
  unsigned int D.13259;
  int D.13262;
  char D.13265;
  int D.13269;
  unsigned int D.13280;
  unsigned int D.13281;
  guint32 D.13284;
  guint32 attrs;
  gchar * filename;

  attrs = 0;
  D.13255 = buf->st_mode;
  D.13256 = D.13255 & 61440;
  if (D.13256 == 49152) goto <D.13257>; else goto <D.13258>;
  <D.13257>:
  D.13255 = buf->st_mode;
  D.13259 = D.13255 & 4294918143;
  buf->st_mode = D.13259;
  <D.13258>:
  filename = _wapi_basename (pathname);
  D.13255 = buf->st_mode;
  D.13256 = D.13255 & 61440;
  if (D.13256 == 16384) goto <D.13260>; else goto <D.13261>;
  <D.13260>:
  attrs = 16;
  D.13262 = is_file_writable (buf, pathname);
  if (D.13262 == 0) goto <D.13263>; else goto <D.13264>;
  <D.13263>:
  attrs = attrs | 1;
  <D.13264>:
  D.13265 = *filename;
  if (D.13265 == 46) goto <D.13266>; else goto <D.13267>;
  <D.13266>:
  attrs = attrs | 2;
  <D.13267>:
  goto <D.13268>;
  <D.13261>:
  D.13269 = is_file_writable (buf, pathname);
  if (D.13269 == 0) goto <D.13270>; else goto <D.13271>;
  <D.13270>:
  attrs = 1;
  D.13265 = *filename;
  if (D.13265 == 46) goto <D.13272>; else goto <D.13273>;
  <D.13272>:
  attrs = attrs | 2;
  <D.13273>:
  goto <D.13274>;
  <D.13271>:
  D.13265 = *filename;
  if (D.13265 == 46) goto <D.13275>; else goto <D.13276>;
  <D.13275>:
  attrs = 2;
  goto <D.13277>;
  <D.13276>:
  attrs = 128;
  <D.13277>:
  <D.13274>:
  <D.13268>:
  if (lbuf != 0B) goto <D.13278>; else goto <D.13279>;
  <D.13278>:
  D.13280 = lbuf->st_mode;
  D.13281 = D.13280 & 61440;
  if (D.13281 == 40960) goto <D.13282>; else goto <D.13283>;
  <D.13282>:
  attrs = attrs | 1024;
  <D.13283>:
  <D.13279>:
  monoeg_g_free (filename);
  D.13284 = attrs;
  return D.13284;
}


is_file_writable (struct stat * st, const char * path)
{
  unsigned int D.13286;
  unsigned int D.13287;
  gboolean D.13290;
  unsigned int D.13291;
  unsigned int D.13292;
  unsigned int D.13295;
  unsigned int D.13298;
  unsigned int D.13299;
  unsigned int D.13302;
  int D.13305;
  _Bool D.13306;

  D.13286 = st->st_mode;
  D.13287 = D.13286 & 2;
  if (D.13287 != 0) goto <D.13288>; else goto <D.13289>;
  <D.13288>:
  D.13290 = 1;
  return D.13290;
  <D.13289>:
  D.13291 = st->st_uid;
  D.13292 = geteuid ();
  if (D.13291 == D.13292) goto <D.13293>; else goto <D.13294>;
  <D.13293>:
  D.13286 = st->st_mode;
  D.13295 = D.13286 & 128;
  if (D.13295 != 0) goto <D.13296>; else goto <D.13297>;
  <D.13296>:
  D.13290 = 1;
  return D.13290;
  <D.13297>:
  <D.13294>:
  D.13298 = st->st_gid;
  D.13299 = getegid ();
  if (D.13298 == D.13299) goto <D.13300>; else goto <D.13301>;
  <D.13300>:
  D.13286 = st->st_mode;
  D.13302 = D.13286 & 16;
  if (D.13302 != 0) goto <D.13303>; else goto <D.13304>;
  <D.13303>:
  D.13290 = 1;
  return D.13290;
  <D.13304>:
  <D.13301>:
  D.13305 = access (path, 2);
  D.13306 = D.13305 == 0;
  D.13290 = (gboolean) D.13306;
  return D.13290;
}


__attribute__((__artificial__, __gnu_inline__, __always_inline__, __nothrow__, __leaf__))
memset (void * __dest, int __ch, size_t __len)
{
  void * D.13308;
  long unsigned int D.13309;

  D.13309 = __builtin_object_size (__dest, 0);
  D.13308 = __builtin___memset_chk (__dest, __ch, __len, D.13309);
  return D.13308;
}


__attribute__((__artificial__, __gnu_inline__, __always_inline__, __nothrow__, __leaf__))
memcpy (void * restrict __dest, const void * restrict __src, size_t __len)
{
  void * D.13311;
  long unsigned int D.13312;

  D.13312 = __builtin_object_size (__dest, 0);
  D.13311 = __builtin___memcpy_chk (__dest, __src, __len, D.13312);
  return D.13311;
}


_wapi_handle_unlock_handle (void * handle)
{
  long int handle.46;
  int D.13317;
  <unnamed type> D.13320;
  <unnamed type> D.13322;
  <unnamed type> D.13324;
  <unnamed type> D.13326;
  unsigned int D.13327;
  struct _WapiHandleUnshared * D.13328;
  long unsigned int D.13329;
  long unsigned int D.13330;
  long unsigned int D.13331;
  struct _WapiHandleUnshared * D.13332;
  union mono_mutex_t * D.13333;
  guint32 idx;
  int ret;

  handle.46 = (long int) handle;
  idx = (guint32) handle.46;
  if (idx > 4194303) goto <D.13315>; else goto <D.13316>;
  <D.13315>:
  D.13317 = 0;
  return D.13317;
  <D.13316>:
  D.13320 = _wapi_handle_type (handle);
  if (D.13320 == 9) goto <D.13318>; else goto <D.13321>;
  <D.13321>:
  D.13322 = _wapi_handle_type (handle);
  if (D.13322 == 11) goto <D.13318>; else goto <D.13323>;
  <D.13323>:
  D.13324 = _wapi_handle_type (handle);
  if (D.13324 == 12) goto <D.13318>; else goto <D.13325>;
  <D.13325>:
  D.13326 = _wapi_handle_type (handle);
  if (D.13326 == 13) goto <D.13318>; else goto <D.13319>;
  <D.13318>:
  _wapi_handle_unref (handle);
  D.13317 = 0;
  return D.13317;
  <D.13319>:
  D.13327 = idx / 256;
  D.13328 = _wapi_private_handles[D.13327];
  D.13329 = (long unsigned int) idx;
  D.13330 = D.13329 & 255;
  D.13331 = D.13330 * 200;
  D.13332 = D.13328 + D.13331;
  D.13333 = &D.13332->signal_mutex;
  ret = pthread_mutex_unlock (D.13333);
  _wapi_handle_unref (handle);
  D.13317 = ret;
  return D.13317;
}


FindClose (void * handle)
{
  gboolean D.13337;
  long int D.13340;
  long int D.13341;
  _Bool D.13344;
  long int D.13345;
  long int D.13346;
  struct _WapiHandle_find * find_handle.47;
  gchar * * D.13350;
  gchar * D.13351;
  struct _WapiHandle_find * find_handle;
  gboolean ok;
  int thr_ret;
  static const char __func__[10] = "FindClose";

  try
    {
      if (handle == 0B) goto <D.13335>; else goto <D.13336>;
      <D.13335>:
      SetLastError (6);
      D.13337 = 0;
      return D.13337;
      <D.13336>:
      ok = _wapi_lookup_handle (handle, 8, &find_handle);
      if (ok == 0) goto <D.13338>; else goto <D.13339>;
      <D.13338>:
      monoeg_g_log (0B, 16, "%s: error looking up find handle %p", &__func__, handle);
      SetLastError (6);
      D.13337 = 0;
      return D.13337;
      <D.13339>:
      {
        struct __pthread_unwind_buf_t __cancel_buf;
        void (*<Tc6>) (void *) __cancel_routine;
        void * __cancel_arg;
        int __not_first_call;

        try
          {
            __cancel_routine = _wapi_handle_unlock_handle;
            __cancel_arg = handle;
            __not_first_call = __sigsetjmp (&__cancel_buf.__cancel_jmp_buf, 0);
            D.13340 = (long int) __not_first_call;
            D.13341 = __builtin_expect (D.13340, 0);
            if (D.13341 != 0) goto <D.13342>; else goto <D.13343>;
            <D.13342>:
            __cancel_routine (__cancel_arg);
            __pthread_unwind_next (&__cancel_buf);
            <D.13343>:
            __pthread_register_cancel (&__cancel_buf);
            thr_ret = _wapi_handle_lock_handle (handle);
            D.13344 = thr_ret != 0;
            D.13345 = (long int) D.13344;
            D.13346 = __builtin_expect (D.13345, 0);
            if (D.13346 != 0) goto <D.13347>; else goto <D.13348>;
            <D.13347>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "io.c", 2947, "thr_ret == 0");
            <D.13348>:
            find_handle.47 = find_handle;
            D.13350 = find_handle.47->namelist;
            monoeg_g_strfreev (D.13350);
            find_handle.47 = find_handle;
            D.13351 = find_handle.47->dir_part;
            monoeg_g_free (D.13351);
            thr_ret = _wapi_handle_unlock_handle (handle);
            D.13344 = thr_ret != 0;
            D.13345 = (long int) D.13344;
            D.13346 = __builtin_expect (D.13345, 0);
            if (D.13346 != 0) goto <D.13352>; else goto <D.13353>;
            <D.13352>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "io.c", 2953, "thr_ret == 0");
            <D.13353>:
            __pthread_unregister_cancel (&__cancel_buf);
            if (0 != 0) goto <D.13354>; else goto <D.13355>;
            <D.13354>:
            __cancel_routine (__cancel_arg);
            <D.13355>:
          }
        finally
          {
            __cancel_buf = {CLOBBER};
          }
      }
      _wapi_handle_unref (handle);
      D.13337 = 1;
      return D.13337;
    }
  finally
    {
      find_handle = {CLOBBER};
    }
}


CreateDirectory (const gunichar2 * name, struct WapiSecurityAttributes * security)
{
  gboolean D.13363;
  gchar * utf8_name;
  int result;

  if (name == 0B) goto <D.13361>; else goto <D.13362>;
  <D.13361>:
  SetLastError (123);
  D.13363 = 0;
  return D.13363;
  <D.13362>:
  utf8_name = mono_unicode_to_external (name);
  if (utf8_name == 0B) goto <D.13364>; else goto <D.13365>;
  <D.13364>:
  SetLastError (123);
  D.13363 = 0;
  return D.13363;
  <D.13365>:
  result = _wapi_mkdir (utf8_name, 511);
  if (result == 0) goto <D.13366>; else goto <D.13367>;
  <D.13366>:
  monoeg_g_free (utf8_name);
  D.13363 = 1;
  return D.13363;
  <D.13367>:
  _wapi_set_last_path_error_from_errno (0B, utf8_name);
  monoeg_g_free (utf8_name);
  D.13363 = 0;
  return D.13363;
}


RemoveDirectory (const gunichar2 * name)
{
  gboolean D.13371;
  gchar * utf8_name;
  int result;

  if (name == 0B) goto <D.13369>; else goto <D.13370>;
  <D.13369>:
  SetLastError (123);
  D.13371 = 0;
  return D.13371;
  <D.13370>:
  utf8_name = mono_unicode_to_external (name);
  if (utf8_name == 0B) goto <D.13372>; else goto <D.13373>;
  <D.13372>:
  SetLastError (123);
  D.13371 = 0;
  return D.13371;
  <D.13373>:
  result = _wapi_rmdir (utf8_name);
  if (result == -1) goto <D.13374>; else goto <D.13375>;
  <D.13374>:
  _wapi_set_last_path_error_from_errno (0B, utf8_name);
  monoeg_g_free (utf8_name);
  D.13371 = 0;
  return D.13371;
  <D.13375>:
  monoeg_g_free (utf8_name);
  D.13371 = 1;
  return D.13371;
}


GetFileAttributes (const gunichar2 * name)
{
  guint32 D.13379;
  int * D.13384;
  int D.13385;
  gchar * utf8_name;
  struct stat buf;
  struct stat linkbuf;
  int result;
  guint32 ret;

  try
    {
      if (name == 0B) goto <D.13377>; else goto <D.13378>;
      <D.13377>:
      SetLastError (123);
      D.13379 = 0;
      return D.13379;
      <D.13378>:
      utf8_name = mono_unicode_to_external (name);
      if (utf8_name == 0B) goto <D.13380>; else goto <D.13381>;
      <D.13380>:
      SetLastError (87);
      D.13379 = 4294967295;
      return D.13379;
      <D.13381>:
      result = _wapi_stat (utf8_name, &buf);
      if (result == -1) goto <D.13382>; else goto <D.13383>;
      <D.13382>:
      D.13384 = __errno_location ();
      D.13385 = *D.13384;
      if (D.13385 == 2) goto <D.13386>; else goto <D.13387>;
      <D.13386>:
      result = _wapi_lstat (utf8_name, &buf);
      <D.13387>:
      <D.13383>:
      if (result != 0) goto <D.13388>; else goto <D.13389>;
      <D.13388>:
      _wapi_set_last_path_error_from_errno (0B, utf8_name);
      monoeg_g_free (utf8_name);
      D.13379 = 4294967295;
      return D.13379;
      <D.13389>:
      result = _wapi_lstat (utf8_name, &linkbuf);
      if (result != 0) goto <D.13390>; else goto <D.13391>;
      <D.13390>:
      _wapi_set_last_path_error_from_errno (0B, utf8_name);
      monoeg_g_free (utf8_name);
      D.13379 = 4294967295;
      return D.13379;
      <D.13391>:
      ret = _wapi_stat_to_file_attributes (utf8_name, &buf, &linkbuf);
      monoeg_g_free (utf8_name);
      D.13379 = ret;
      return D.13379;
    }
  finally
    {
      buf = {CLOBBER};
      linkbuf = {CLOBBER};
    }
}


GetFileAttributesEx (const gunichar2 * name, WapiGetFileExInfoLevels level, void * info)
{
  gboolean D.13396;
  int * D.13403;
  int D.13404;
  long int D.13411;
  long int D.13412;
  unsigned int D.13416;
  struct WapiFileTime * D.13417;
  long int D.13418;
  struct WapiFileTime * D.13419;
  struct WapiFileTime * D.13420;
  unsigned int D.13421;
  unsigned int D.13422;
  long int D.13426;
  long int D.13427;
  unsigned int D.13428;
  unsigned int D.13429;
  gchar * utf8_name;
  struct WapiFileAttributesData * data;
  struct stat buf;
  struct stat linkbuf;
  time_t create_time;
  int result;

  try
    {
      if (level != 0) goto <D.13394>; else goto <D.13395>;
      <D.13394>:
      SetLastError (87);
      D.13396 = 0;
      return D.13396;
      <D.13395>:
      if (name == 0B) goto <D.13397>; else goto <D.13398>;
      <D.13397>:
      SetLastError (123);
      D.13396 = 0;
      return D.13396;
      <D.13398>:
      utf8_name = mono_unicode_to_external (name);
      if (utf8_name == 0B) goto <D.13399>; else goto <D.13400>;
      <D.13399>:
      SetLastError (87);
      D.13396 = 0;
      return D.13396;
      <D.13400>:
      result = _wapi_stat (utf8_name, &buf);
      if (result == -1) goto <D.13401>; else goto <D.13402>;
      <D.13401>:
      D.13403 = __errno_location ();
      D.13404 = *D.13403;
      if (D.13404 == 2) goto <D.13405>; else goto <D.13406>;
      <D.13405>:
      result = _wapi_lstat (utf8_name, &buf);
      <D.13406>:
      <D.13402>:
      if (result != 0) goto <D.13407>; else goto <D.13408>;
      <D.13407>:
      _wapi_set_last_path_error_from_errno (0B, utf8_name);
      monoeg_g_free (utf8_name);
      D.13396 = 0;
      return D.13396;
      <D.13408>:
      result = _wapi_lstat (utf8_name, &linkbuf);
      if (result != 0) goto <D.13409>; else goto <D.13410>;
      <D.13409>:
      _wapi_set_last_path_error_from_errno (0B, utf8_name);
      monoeg_g_free (utf8_name);
      D.13396 = 0;
      return D.13396;
      <D.13410>:
      data = info;
      D.13411 = buf.st_mtim.tv_sec;
      D.13412 = buf.st_ctim.tv_sec;
      if (D.13411 < D.13412) goto <D.13413>; else goto <D.13414>;
      <D.13413>:
      create_time = buf.st_mtim.tv_sec;
      goto <D.13415>;
      <D.13414>:
      create_time = buf.st_ctim.tv_sec;
      <D.13415>:
      D.13416 = _wapi_stat_to_file_attributes (utf8_name, &buf, &linkbuf);
      data->dwFileAttributes = D.13416;
      monoeg_g_free (utf8_name);
      D.13417 = &data->ftCreationTime;
      _wapi_time_t_to_filetime (create_time, D.13417);
      D.13418 = buf.st_atim.tv_sec;
      D.13419 = &data->ftLastAccessTime;
      _wapi_time_t_to_filetime (D.13418, D.13419);
      D.13411 = buf.st_mtim.tv_sec;
      D.13420 = &data->ftLastWriteTime;
      _wapi_time_t_to_filetime (D.13411, D.13420);
      D.13421 = data->dwFileAttributes;
      D.13422 = D.13421 & 16;
      if (D.13422 != 0) goto <D.13423>; else goto <D.13424>;
      <D.13423>:
      data->nFileSizeHigh = 0;
      data->nFileSizeLow = 0;
      goto <D.13425>;
      <D.13424>:
      D.13426 = buf.st_size;
      D.13427 = D.13426 >> 32;
      D.13428 = (unsigned int) D.13427;
      data->nFileSizeHigh = D.13428;
      D.13426 = buf.st_size;
      D.13429 = (unsigned int) D.13426;
      data->nFileSizeLow = D.13429;
      <D.13425>:
      D.13396 = 1;
      return D.13396;
    }
  finally
    {
      buf = {CLOBBER};
      linkbuf = {CLOBBER};
    }
}


SetFileAttributes (const gunichar2 * name, guint32 attrs)
{
  gboolean D.13434;
  int * D.13439;
  int D.13440;
  unsigned int D.13445;
  unsigned int D.13448;
  unsigned int D.13449;
  unsigned int D.13451;
  signed int attrs.48;
  unsigned int D.13455;
  unsigned int D.13458;
  unsigned int D.13461;
  unsigned int D.13464;
  gchar * utf8_name;
  struct stat buf;
  int result;

  try
    {
      if (name == 0B) goto <D.13432>; else goto <D.13433>;
      <D.13432>:
      SetLastError (123);
      D.13434 = 0;
      return D.13434;
      <D.13433>:
      utf8_name = mono_unicode_to_external (name);
      if (utf8_name == 0B) goto <D.13435>; else goto <D.13436>;
      <D.13435>:
      SetLastError (123);
      D.13434 = 0;
      return D.13434;
      <D.13436>:
      result = _wapi_stat (utf8_name, &buf);
      if (result == -1) goto <D.13437>; else goto <D.13438>;
      <D.13437>:
      D.13439 = __errno_location ();
      D.13440 = *D.13439;
      if (D.13440 == 2) goto <D.13441>; else goto <D.13442>;
      <D.13441>:
      result = _wapi_lstat (utf8_name, &buf);
      <D.13442>:
      <D.13438>:
      if (result != 0) goto <D.13443>; else goto <D.13444>;
      <D.13443>:
      _wapi_set_last_path_error_from_errno (0B, utf8_name);
      monoeg_g_free (utf8_name);
      D.13434 = 0;
      return D.13434;
      <D.13444>:
      D.13445 = attrs & 1;
      if (D.13445 != 0) goto <D.13446>; else goto <D.13447>;
      <D.13446>:
      D.13448 = buf.st_mode;
      D.13449 = D.13448 & 4294967149;
      result = _wapi_chmod (utf8_name, D.13449);
      goto <D.13450>;
      <D.13447>:
      D.13448 = buf.st_mode;
      D.13451 = D.13448 | 128;
      result = _wapi_chmod (utf8_name, D.13451);
      <D.13450>:
      attrs.48 = (signed int) attrs;
      if (attrs.48 < 0) goto <D.13453>; else goto <D.13454>;
      <D.13453>:
      {
        mode_t exec_mask;

        exec_mask = 0;
        D.13448 = buf.st_mode;
        D.13455 = D.13448 & 256;
        if (D.13455 != 0) goto <D.13456>; else goto <D.13457>;
        <D.13456>:
        exec_mask = exec_mask | 64;
        <D.13457>:
        D.13448 = buf.st_mode;
        D.13458 = D.13448 & 32;
        if (D.13458 != 0) goto <D.13459>; else goto <D.13460>;
        <D.13459>:
        exec_mask = exec_mask | 8;
        <D.13460>:
        D.13448 = buf.st_mode;
        D.13461 = D.13448 & 4;
        if (D.13461 != 0) goto <D.13462>; else goto <D.13463>;
        <D.13462>:
        exec_mask = exec_mask | 1;
        <D.13463>:
        D.13448 = buf.st_mode;
        D.13464 = D.13448 | exec_mask;
        result = chmod (utf8_name, D.13464);
      }
      <D.13454>:
      monoeg_g_free (utf8_name);
      D.13434 = 1;
      return D.13434;
    }
  finally
    {
      buf = {CLOBBER};
    }
}


GetCurrentDirectory (guint32 length, gunichar2 * buffer)
{
  long unsigned int D.13467;
  char * D.13468;
  int * D.13471;
  int D.13472;
  guint32 D.13477;
  long unsigned int bytes.49;
  long unsigned int D.13479;
  unsigned int D.13480;
  long unsigned int D.13481;
  long int D.13482;
  _Bool D.13483;
  long int D.13484;
  long int D.13485;
  long unsigned int D.13488;
  gunichar2 * utf16_path;
  glong count;
  gsize bytes;

  try
    {
      D.13467 = (long unsigned int) length;
      D.13468 = getcwd (buffer, D.13467);
      if (D.13468 == 0B) goto <D.13469>; else goto <D.13470>;
      <D.13469>:
      D.13471 = __errno_location ();
      D.13472 = *D.13471;
      if (D.13472 == 34) goto <D.13473>; else goto <D.13474>;
      <D.13473>:
      {
        gchar * path;

        path = monoeg_g_get_current_dir ();
        if (path == 0B) goto <D.13475>; else goto <D.13476>;
        <D.13475>:
        D.13477 = 0;
        return D.13477;
        <D.13476>:
        utf16_path = mono_unicode_from_external (path, &bytes);
        monoeg_g_free (utf16_path);
        monoeg_g_free (path);
        bytes.49 = bytes;
        D.13479 = bytes.49 / 2;
        D.13480 = (unsigned int) D.13479;
        D.13477 = D.13480 + 1;
        return D.13477;
      }
      <D.13474>:
      _wapi_set_last_error_from_errno ();
      D.13477 = 0;
      return D.13477;
      <D.13470>:
      utf16_path = mono_unicode_from_external (buffer, &bytes);
      bytes.49 = bytes;
      D.13479 = bytes.49 / 2;
      D.13481 = D.13479 + 1;
      count = (glong) D.13481;
      D.13482 = (long int) length;
      D.13483 = D.13482 < count;
      D.13484 = (long int) D.13483;
      D.13485 = __builtin_expect (D.13484, 0);
      if (D.13485 != 0) goto <D.13486>; else goto <D.13487>;
      <D.13486>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "io.c", 3320, "count <= length");
      <D.13487>:
      bytes.49 = bytes;
      D.13488 = bytes.49 + 2;
      memset (buffer, 0, D.13488);
      bytes.49 = bytes;
      memcpy (buffer, utf16_path, bytes.49);
      monoeg_g_free (utf16_path);
      D.13477 = (guint32) count;
      return D.13477;
    }
  finally
    {
      bytes = {CLOBBER};
    }
}


__attribute__((__artificial__, __gnu_inline__, __always_inline__, __nothrow__, __leaf__))
getcwd (char * __buf, size_t __size)
{
  long unsigned int D.13491;
  int D.13494;
  char * D.13497;
  long unsigned int D.13498;
  long unsigned int D.13499;
  long unsigned int D.13502;

  D.13491 = __builtin_object_size (__buf, 1);
  if (D.13491 != 18446744073709551615) goto <D.13492>; else goto <D.13493>;
  <D.13492>:
  D.13494 = __builtin_constant_p (__size);
  if (D.13494 == 0) goto <D.13495>; else goto <D.13496>;
  <D.13495>:
  D.13498 = __builtin_object_size (__buf, 1);
  D.13497 = __getcwd_chk (__buf, __size, D.13498);
  return D.13497;
  <D.13496>:
  D.13499 = __builtin_object_size (__buf, 1);
  if (D.13499 < __size) goto <D.13500>; else goto <D.13501>;
  <D.13500>:
  D.13502 = __builtin_object_size (__buf, 1);
  D.13497 = __getcwd_chk_warn (__buf, __size, D.13502);
  return D.13497;
  <D.13501>:
  <D.13493>:
  D.13497 = __getcwd_alias (__buf, __size);
  return D.13497;
}


SetCurrentDirectory (const gunichar2 * path)
{
  gboolean D.13506;
  int D.13507;
  gchar * utf8_path;
  gboolean result;

  if (path == 0B) goto <D.13504>; else goto <D.13505>;
  <D.13504>:
  SetLastError (87);
  D.13506 = 0;
  return D.13506;
  <D.13505>:
  utf8_path = mono_unicode_to_external (path);
  D.13507 = _wapi_chdir (utf8_path);
  if (D.13507 != 0) goto <D.13508>; else goto <D.13509>;
  <D.13508>:
  _wapi_set_last_error_from_errno ();
  result = 0;
  goto <D.13510>;
  <D.13509>:
  result = 1;
  <D.13510>:
  monoeg_g_free (utf8_path);
  D.13506 = result;
  return D.13506;
}


CreatePipe (void * * readpipe, void * * writepipe, struct WapiSecurityAttributes * security, guint32 size)
{
  gboolean D.13514;
  int D.13517;
  unsigned int D.13518;
  unsigned int _wapi_fd_reserve.50;
  int D.13521;
  unsigned int D.13522;
  struct _WapiHandle_file pipe_read_handle;
  struct _WapiHandle_file pipe_write_handle;
  void * read_handle;
  void * write_handle;
  int filedes[2];
  int ret;
  static const char __func__[11] = "CreatePipe";

  try
    {
      pipe_read_handle = {};
      pipe_write_handle = {};
      mono_once (&io_ops_once, io_ops_init);
      ret = pipe (&filedes);
      if (ret == -1) goto <D.13512>; else goto <D.13513>;
      <D.13512>:
      _wapi_set_last_error_from_errno ();
      D.13514 = 0;
      return D.13514;
      <D.13513>:
      D.13517 = filedes[0];
      D.13518 = (unsigned int) D.13517;
      _wapi_fd_reserve.50 = _wapi_fd_reserve;
      if (D.13518 >= _wapi_fd_reserve.50) goto <D.13515>; else goto <D.13520>;
      <D.13520>:
      D.13521 = filedes[1];
      D.13522 = (unsigned int) D.13521;
      _wapi_fd_reserve.50 = _wapi_fd_reserve;
      if (D.13522 >= _wapi_fd_reserve.50) goto <D.13515>; else goto <D.13516>;
      <D.13515>:
      SetLastError (4);
      D.13517 = filedes[0];
      close (D.13517);
      D.13521 = filedes[1];
      close (D.13521);
      D.13514 = 0;
      return D.13514;
      <D.13516>:
      D.13517 = filedes[0];
      pipe_read_handle.fd = D.13517;
      pipe_read_handle.fileaccess = 2147483648;
      D.13517 = filedes[0];
      read_handle = _wapi_handle_new_fd (10, D.13517, &pipe_read_handle);
      if (read_handle == -1B) goto <D.13523>; else goto <D.13524>;
      <D.13523>:
      monoeg_g_log (0B, 16, "%s: error creating pipe read handle", &__func__);
      D.13517 = filedes[0];
      close (D.13517);
      D.13521 = filedes[1];
      close (D.13521);
      SetLastError (31);
      D.13514 = 0;
      return D.13514;
      <D.13524>:
      D.13521 = filedes[1];
      pipe_write_handle.fd = D.13521;
      pipe_write_handle.fileaccess = 1073741824;
      D.13521 = filedes[1];
      write_handle = _wapi_handle_new_fd (10, D.13521, &pipe_write_handle);
      if (write_handle == -1B) goto <D.13525>; else goto <D.13526>;
      <D.13525>:
      monoeg_g_log (0B, 16, "%s: error creating pipe write handle", &__func__);
      _wapi_handle_unref (read_handle);
      D.13517 = filedes[0];
      close (D.13517);
      D.13521 = filedes[1];
      close (D.13521);
      SetLastError (31);
      D.13514 = 0;
      return D.13514;
      <D.13526>:
      *readpipe = read_handle;
      *writepipe = write_handle;
      D.13514 = 1;
      return D.13514;
    }
  finally
    {
      pipe_read_handle = {CLOBBER};
      pipe_write_handle = {CLOBBER};
      filedes = {CLOBBER};
    }
}


GetTempPath (guint32 len, gunichar2 * buf)
{
  const gchar * D.13529;
  long unsigned int D.13530;
  gchar * D.13531;
  char D.13532;
  const gchar * D.13535;
  guint32 D.13538;
  long unsigned int bytes.51;
  long unsigned int D.13540;
  long int D.13541;
  unsigned int D.13544;
  long unsigned int D.13546;
  gchar * tmpdir;
  gunichar2 * tmpdir16;
  glong dirlen;
  gsize bytes;
  guint32 ret;

  try
    {
      D.13529 = monoeg_g_get_tmp_dir ();
      tmpdir = monoeg_strdup (D.13529);
      tmpdir16 = 0B;
      D.13530 = __strlen_g (tmpdir);
      D.13531 = tmpdir + D.13530;
      D.13532 = *D.13531;
      if (D.13532 != 47) goto <D.13533>; else goto <D.13534>;
      <D.13533>:
      monoeg_g_free (tmpdir);
      D.13535 = monoeg_g_get_tmp_dir ();
      tmpdir = monoeg_g_strdup_printf ("%s/", D.13535);
      <D.13534>:
      tmpdir16 = mono_unicode_from_external (tmpdir, &bytes);
      if (tmpdir16 == 0B) goto <D.13536>; else goto <D.13537>;
      <D.13536>:
      monoeg_g_free (tmpdir);
      D.13538 = 0;
      return D.13538;
      <D.13537>:
      bytes.51 = bytes;
      D.13540 = bytes.51 / 2;
      dirlen = (glong) D.13540;
      D.13541 = (long int) len;
      if (D.13541 <= dirlen) goto <D.13542>; else goto <D.13543>;
      <D.13542>:
      D.13544 = (unsigned int) dirlen;
      ret = D.13544 + 1;
      goto <D.13545>;
      <D.13543>:
      bytes.51 = bytes;
      D.13546 = bytes.51 + 2;
      memset (buf, 0, D.13546);
      bytes.51 = bytes;
      memcpy (buf, tmpdir16, bytes.51);
      ret = (guint32) dirlen;
      <D.13545>:
      if (tmpdir16 != 0B) goto <D.13547>; else goto <D.13548>;
      <D.13547>:
      monoeg_g_free (tmpdir16);
      <D.13548>:
      monoeg_g_free (tmpdir);
      D.13538 = ret;
      return D.13538;
    }
  finally
    {
      bytes = {CLOBBER};
    }
}


__attribute__((__gnu_inline__))
__strlen_g (const char * __str)
{
  size_t D.13551;
  long int __ptr.52;
  long int __str.53;
  long int D.13554;
  char * __ptr;
  char * __tmp;

  __ptr = 0B;
  __tmp = __str;
  __asm__ __volatile__("   la    0,0
0: srst  %0,%1
   jo    0b
" : "=&a" __ptr, "=&a" __tmp : "0" __ptr, "1" __tmp : "0", "memory", "cc");
  __ptr.52 = (long int) __ptr;
  __str.53 = (long int) __str;
  D.13554 = __ptr.52 - __str.53;
  D.13551 = (size_t) D.13554;
  return D.13551;
}


GetLogicalDriveStrings (guint32 len, gunichar2 * buf)
{
  long unsigned int D.13556;
  long unsigned int D.13557;
  unsigned int D.13565;
  char D.13566;
  unsigned int D.13569;
  gchar * D.13570;
  long int D.13575;
  int D.13576;
  long int D.13577;
  long int D.13578;
  gint32 D.13581;
  int fd;
  gint32 ret;
  struct LinuxMountInfoParseState state;
  gboolean (*<T1df9>) (guint32, gunichar2 *, struct LinuxMountInfoParseState *) parser;
  void done_and_out = <<< error >>>;

  try
    {
      ret = 0;
      parser = 0B;
      D.13556 = (long unsigned int) len;
      D.13557 = D.13556 * 2;
      memset (buf, 0, D.13557);
      fd = open ("/proc/self/mountinfo", 0);
      if (fd != -1) goto <D.13558>; else goto <D.13559>;
      <D.13558>:
      parser = GetLogicalDriveStrings_MountInfo;
      goto <D.13560>;
      <D.13559>:
      fd = open ("/proc/mounts", 0);
      if (fd != -1) goto <D.13561>; else goto <D.13562>;
      <D.13561>:
      parser = GetLogicalDriveStrings_Mounts;
      <D.13562>:
      <D.13560>:
      if (parser == 0B) goto <D.13563>; else goto <D.13564>;
      <D.13563>:
      ret = GetLogicalDriveStrings_Mtab (len, buf);
      goto done_and_out;
      <D.13564>:
      memset (&state, 0, 1224);
      state.field_number = 1;
      state.delimiter = 32;
      goto <D.12074>;
      <D.12073>:
      state.buffer_index = 0;
      goto <D.12071>;
      <D.12070>:
      D.13565 = state.buffer_index;
      D.13566 = state.buffer[D.13565];
      if (D.13566 == 10) goto <D.13567>; else goto <D.13568>;
      <D.13567>:
      {
        gboolean quit;

        quit = add_drive_string (len, buf, &state);
        state.field_number = 1;
        D.13565 = state.buffer_index;
        D.13569 = D.13565 + 1;
        state.buffer_index = D.13569;
        D.13570 = state.mountpoint_allocated;
        if (D.13570 != 0B) goto <D.13571>; else goto <D.13572>;
        <D.13571>:
        D.13570 = state.mountpoint_allocated;
        monoeg_g_free (D.13570);
        state.mountpoint_allocated = 0B;
        <D.13572>:
        if (quit != 0) goto <D.13573>; else goto <D.13574>;
        <D.13573>:
        D.13575 = state.total;
        ret = (gint32) D.13575;
        goto done_and_out;
        <D.13574>:
      }
      <D.13568>:
      <D.12071>:
      D.13576 = parser (len, buf, &state);
      if (D.13576 != 0) goto <D.12070>; else goto <D.12072>;
      <D.12072>:
      <D.12074>:
      D.13577 = read (fd, &state.buffer, 512);
      state.nbytes = D.13577;
      D.13578 = state.nbytes;
      if (D.13578 > 0) goto <D.12073>; else goto <D.12075>;
      <D.12075>:
      D.13575 = state.total;
      ret = (gint32) D.13575;
      done_and_out:
      if (fd != -1) goto <D.13579>; else goto <D.13580>;
      <D.13579>:
      close (fd);
      <D.13580>:
      D.13581 = ret;
      return D.13581;
    }
  finally
    {
      state = {CLOBBER};
    }
}


GetLogicalDriveStrings_Mounts (guint32 len, gunichar2 * buf, struct LinuxMountInfoParseState * state)
{
  unsigned int D.13584;
  unsigned int D.13587;
  char D.13588;
  char D.13589;
  unsigned int D.13592;
  gchar * D.13593;
  unsigned int D.13596;
  sizetype D.13597;
  gchar * D.13598;
  gchar[512] * D.13600;
  sizetype D.13601;
  const void * D.13602;
  unsigned int D.13603;
  long unsigned int D.13604;
  long int ptr.54;
  long int D.13608;
  long int D.13609;
  unsigned int D.13610;
  unsigned int D.13611;
  long int D.13613;
  unsigned int D.13614;
  gboolean D.13615;
  unsigned int D.13616;
  int D.13619;
  unsigned int D.13622;
  unsigned int D.13627;
  unsigned int D.13628;
  unsigned int D.13631;
  unsigned int D.13632;
  unsigned int D.13633;
  unsigned int D.13636;
  unsigned int D.13637;
  gchar * ptr;

  D.13584 = state->field_number;
  if (D.13584 == 1) goto <D.13585>; else goto <D.13586>;
  <D.13585>:
  state->check_mount_source = 1;
  <D.13586>:
  goto <D.12086>;
  <D.12091>:
  D.13587 = state->buffer_index;
  D.13588 = state->buffer[D.13587];
  D.13589 = state->delimiter;
  if (D.13588 == D.13589) goto <D.13590>; else goto <D.13591>;
  <D.13590>:
  D.13584 = state->field_number;
  D.13592 = D.13584 + 1;
  state->field_number = D.13592;
  D.13584 = state->field_number;
  switch (D.13584) <default: <D.12085>, case 2: <D.12082>, case 3: <D.12084>>
  <D.12082>:
  state->mountpoint_index = 0;
  goto <D.12083>;
  <D.12084>:
  D.13593 = state->mountpoint_allocated;
  if (D.13593 != 0B) goto <D.13594>; else goto <D.13595>;
  <D.13594>:
  D.13593 = state->mountpoint_allocated;
  D.13596 = state->mountpoint_index;
  D.13597 = (sizetype) D.13596;
  D.13598 = D.13593 + D.13597;
  *D.13598 = 0;
  goto <D.13599>;
  <D.13595>:
  D.13596 = state->mountpoint_index;
  state->mountpoint[D.13596] = 0;
  <D.13599>:
  goto <D.12083>;
  <D.12085>:
  D.13600 = &state->buffer;
  D.13587 = state->buffer_index;
  D.13601 = (sizetype) D.13587;
  D.13602 = D.13600 + D.13601;
  D.13587 = state->buffer_index;
  D.13603 = 512 - D.13587;
  D.13604 = (long unsigned int) D.13603;
  ptr = memchr (D.13602, 10, D.13604);
  if (ptr != 0B) goto <D.13605>; else goto <D.13606>;
  <D.13605>:
  ptr.54 = (long int) ptr;
  D.13600 = &state->buffer;
  D.13608 = (long int) D.13600;
  D.13609 = ptr.54 - D.13608;
  D.13610 = (unsigned int) D.13609;
  D.13611 = D.13610 + 4294967295;
  state->buffer_index = D.13611;
  goto <D.13612>;
  <D.13606>:
  D.13613 = state->nbytes;
  D.13614 = (unsigned int) D.13613;
  state->buffer_index = D.13614;
  <D.13612>:
  D.13615 = 1;
  return D.13615;
  <D.12083>:
  D.13587 = state->buffer_index;
  D.13616 = D.13587 + 1;
  state->buffer_index = D.13616;
  // predicted unlikely by continue predictor.
  goto <D.12086>;
  <D.13591>:
  D.13587 = state->buffer_index;
  D.13588 = state->buffer[D.13587];
  if (D.13588 == 10) goto <D.13617>; else goto <D.13618>;
  <D.13617>:
  D.13615 = 1;
  return D.13615;
  <D.13618>:
  D.13584 = state->field_number;
  switch (D.13584) <default: <D.13638>, case 1: <D.12087>, case 2: <D.12089>, case 3: <D.12090>>
  <D.12087>:
  D.13619 = state->check_mount_source;
  if (D.13619 != 0) goto <D.13620>; else goto <D.13621>;
  <D.13620>:
  D.13622 = state->fsname_index;
  if (D.13622 == 0) goto <D.13623>; else goto <D.13624>;
  <D.13623>:
  D.13587 = state->buffer_index;
  D.13588 = state->buffer[D.13587];
  if (D.13588 == 47) goto <D.13625>; else goto <D.13626>;
  <D.13625>:
  state->check_mount_source = 0;
  D.13622 = state->fsname_index;
  D.13627 = D.13622;
  D.13628 = D.13627 + 1;
  state->fsname_index = D.13628;
  state->fsname[D.13627] = 47;
  goto <D.12088>;
  <D.13626>:
  <D.13624>:
  D.13622 = state->fsname_index;
  if (D.13622 <= 63) goto <D.13629>; else goto <D.13630>;
  <D.13629>:
  D.13622 = state->fsname_index;
  D.13631 = D.13622;
  D.13632 = D.13631 + 1;
  state->fsname_index = D.13632;
  D.13587 = state->buffer_index;
  D.13588 = state->buffer[D.13587];
  state->fsname[D.13631] = D.13588;
  <D.13630>:
  <D.13621>:
  goto <D.12088>;
  <D.12089>:
  append_to_mountpoint (state);
  goto <D.12088>;
  <D.12090>:
  D.13633 = state->fstype_index;
  if (D.13633 <= 63) goto <D.13634>; else goto <D.13635>;
  <D.13634>:
  D.13633 = state->fstype_index;
  D.13636 = D.13633;
  D.13637 = D.13636 + 1;
  state->fstype_index = D.13637;
  D.13587 = state->buffer_index;
  D.13588 = state->buffer[D.13587];
  state->fstype[D.13636] = D.13588;
  <D.13635>:
  goto <D.12088>;
  <D.13638>:
  <D.12088>:
  D.13587 = state->buffer_index;
  D.13616 = D.13587 + 1;
  state->buffer_index = D.13616;
  <D.12086>:
  D.13587 = state->buffer_index;
  D.13613 = state->nbytes;
  D.13614 = (unsigned int) D.13613;
  if (D.13587 < D.13614) goto <D.12091>; else goto <D.12092>;
  <D.12092>:
  D.13615 = 0;
  return D.13615;
}


__attribute__((__gnu_inline__, nothrow, leaf, pure))
memchr (const void * __str, int __c, size_t __n)
{
  void * D.13640;
  char * __ptr;
  char * __tmp;

  __tmp = __str;
  __ptr = __tmp + __n;
  __asm__ __volatile__("   lhi   0,0xff
   nr    0,%2
0: srst  %0,%1
   jo    0b
   brc   13,1f
   la    %0,0
1:" : "=&a" __ptr, "=&a" __tmp : "d" __c, "0" __ptr, "1" __tmp : "0", "memory", "cc");
  D.13640 = __ptr;
  return D.13640;
}


append_to_mountpoint (struct LinuxMountInfoParseState * state)
{
  unsigned int D.13642;
  gchar * D.13643;
  unsigned int D.13646;
  unsigned int D.13647;
  unsigned int D.13650;
  long unsigned int D.13651;
  long unsigned int D.13652;
  unsigned int D.13653;
  unsigned int D.13654;
  sizetype D.13655;
  gchar * D.13656;
  unsigned int D.13660;
  unsigned int D.13661;
  long unsigned int D.13662;
  void * D.13663;
  gchar[513] * D.13664;
  unsigned int D.13665;
  unsigned int D.13666;
  sizetype D.13667;
  gchar * D.13668;
  unsigned int D.13670;
  unsigned int D.13671;
  gchar ch;

  D.13642 = state->buffer_index;
  ch = state->buffer[D.13642];
  D.13643 = state->mountpoint_allocated;
  if (D.13643 != 0B) goto <D.13644>; else goto <D.13645>;
  <D.13644>:
  D.13646 = state->mountpoint_index;
  D.13647 = state->allocated_size;
  if (D.13646 >= D.13647) goto <D.13648>; else goto <D.13649>;
  <D.13648>:
  {
    guint32 newsize;
    gchar * newbuf;

    D.13647 = state->allocated_size;
    D.13650 = D.13647 << 1;
    newsize = D.13650 + 1;
    D.13651 = (long unsigned int) newsize;
    newbuf = monoeg_malloc0 (D.13651);
    D.13643 = state->mountpoint_allocated;
    D.13646 = state->mountpoint_index;
    D.13652 = (long unsigned int) D.13646;
    memcpy (newbuf, D.13643, D.13652);
    D.13643 = state->mountpoint_allocated;
    monoeg_g_free (D.13643);
    state->mountpoint_allocated = newbuf;
    state->allocated_size = newsize;
  }
  <D.13649>:
  D.13643 = state->mountpoint_allocated;
  D.13646 = state->mountpoint_index;
  D.13653 = D.13646;
  D.13654 = D.13653 + 1;
  state->mountpoint_index = D.13654;
  D.13655 = (sizetype) D.13653;
  D.13656 = D.13643 + D.13655;
  *D.13656 = ch;
  goto <D.13657>;
  <D.13645>:
  D.13646 = state->mountpoint_index;
  if (D.13646 > 511) goto <D.13658>; else goto <D.13659>;
  <D.13658>:
  D.13646 = state->mountpoint_index;
  D.13660 = D.13646 << 1;
  D.13661 = D.13660 + 1;
  state->allocated_size = D.13661;
  D.13647 = state->allocated_size;
  D.13662 = (long unsigned int) D.13647;
  D.13663 = monoeg_malloc0 (D.13662);
  state->mountpoint_allocated = D.13663;
  D.13643 = state->mountpoint_allocated;
  D.13664 = &state->mountpoint;
  D.13646 = state->mountpoint_index;
  D.13652 = (long unsigned int) D.13646;
  memcpy (D.13643, D.13664, D.13652);
  D.13643 = state->mountpoint_allocated;
  D.13646 = state->mountpoint_index;
  D.13665 = D.13646;
  D.13666 = D.13665 + 1;
  state->mountpoint_index = D.13666;
  D.13667 = (sizetype) D.13665;
  D.13668 = D.13643 + D.13667;
  *D.13668 = ch;
  goto <D.13669>;
  <D.13659>:
  D.13646 = state->mountpoint_index;
  D.13670 = D.13646;
  D.13671 = D.13670 + 1;
  state->mountpoint_index = D.13671;
  state->mountpoint[D.13670] = ch;
  <D.13669>:
  <D.13657>:
}


GetLogicalDriveStrings_MountInfo (guint32 len, gunichar2 * buf, struct LinuxMountInfoParseState * state)
{
  unsigned int D.13672;
  char D.13673;
  char D.13674;
  unsigned int D.13677;
  unsigned int D.13678;
  gchar * D.13679;
  unsigned int D.13682;
  sizetype D.13683;
  gchar * D.13684;
  unsigned int D.13687;
  gboolean D.13690;
  unsigned int D.13691;
  unsigned int D.13694;
  unsigned int D.13695;
  int D.13696;
  unsigned int D.13699;
  unsigned int D.13704;
  unsigned int D.13705;
  unsigned int D.13708;
  unsigned int D.13709;
  long int D.13711;
  unsigned int D.13712;

  goto <D.12104>;
  <D.12109>:
  D.13672 = state->buffer_index;
  D.13673 = state->buffer[D.13672];
  D.13674 = state->delimiter;
  if (D.13673 == D.13674) goto <D.13675>; else goto <D.13676>;
  <D.13675>:
  D.13677 = state->field_number;
  D.13678 = D.13677 + 1;
  state->field_number = D.13678;
  D.13677 = state->field_number;
  switch (D.13677) <default: <D.13686>, case 5: <D.12098>, case 6: <D.12100>, case 7: <D.12101>, case 8: <D.12102>, case 10: <D.12103>>
  <D.12098>:
  state->mountpoint_index = 0;
  goto <D.12099>;
  <D.12100>:
  D.13679 = state->mountpoint_allocated;
  if (D.13679 != 0B) goto <D.13680>; else goto <D.13681>;
  <D.13680>:
  D.13679 = state->mountpoint_allocated;
  D.13682 = state->mountpoint_index;
  D.13683 = (sizetype) D.13682;
  D.13684 = D.13679 + D.13683;
  *D.13684 = 0;
  goto <D.13685>;
  <D.13681>:
  D.13682 = state->mountpoint_index;
  state->mountpoint[D.13682] = 0;
  <D.13685>:
  goto <D.12099>;
  <D.12101>:
  state->delimiter = 45;
  goto <D.12099>;
  <D.12102>:
  state->delimiter = 32;
  goto <D.12099>;
  <D.12103>:
  state->check_mount_source = 1;
  goto <D.12099>;
  <D.13686>:
  <D.12099>:
  D.13672 = state->buffer_index;
  D.13687 = D.13672 + 1;
  state->buffer_index = D.13687;
  // predicted unlikely by continue predictor.
  goto <D.12104>;
  <D.13676>:
  D.13672 = state->buffer_index;
  D.13673 = state->buffer[D.13672];
  if (D.13673 == 10) goto <D.13688>; else goto <D.13689>;
  <D.13688>:
  D.13690 = 1;
  return D.13690;
  <D.13689>:
  D.13677 = state->field_number;
  switch (D.13677) <default: <D.13710>, case 5: <D.12105>, case 9: <D.12107>, case 10: <D.12108>>
  <D.12105>:
  append_to_mountpoint (state);
  goto <D.12106>;
  <D.12107>:
  D.13691 = state->fstype_index;
  if (D.13691 <= 63) goto <D.13692>; else goto <D.13693>;
  <D.13692>:
  D.13691 = state->fstype_index;
  D.13694 = D.13691;
  D.13695 = D.13694 + 1;
  state->fstype_index = D.13695;
  D.13672 = state->buffer_index;
  D.13673 = state->buffer[D.13672];
  state->fstype[D.13694] = D.13673;
  <D.13693>:
  goto <D.12106>;
  <D.12108>:
  D.13696 = state->check_mount_source;
  if (D.13696 != 0) goto <D.13697>; else goto <D.13698>;
  <D.13697>:
  D.13699 = state->fsname_index;
  if (D.13699 == 0) goto <D.13700>; else goto <D.13701>;
  <D.13700>:
  D.13672 = state->buffer_index;
  D.13673 = state->buffer[D.13672];
  if (D.13673 == 47) goto <D.13702>; else goto <D.13703>;
  <D.13702>:
  state->check_mount_source = 0;
  D.13699 = state->fsname_index;
  D.13704 = D.13699;
  D.13705 = D.13704 + 1;
  state->fsname_index = D.13705;
  state->fsname[D.13704] = 47;
  goto <D.12106>;
  <D.13703>:
  <D.13701>:
  D.13699 = state->fsname_index;
  if (D.13699 <= 63) goto <D.13706>; else goto <D.13707>;
  <D.13706>:
  D.13699 = state->fsname_index;
  D.13708 = D.13699;
  D.13709 = D.13708 + 1;
  state->fsname_index = D.13709;
  D.13672 = state->buffer_index;
  D.13673 = state->buffer[D.13672];
  state->fsname[D.13708] = D.13673;
  <D.13707>:
  <D.13698>:
  goto <D.12106>;
  <D.13710>:
  <D.12106>:
  D.13672 = state->buffer_index;
  D.13687 = D.13672 + 1;
  state->buffer_index = D.13687;
  <D.12104>:
  D.13672 = state->buffer_index;
  D.13711 = state->nbytes;
  D.13712 = (unsigned int) D.13711;
  if (D.13672 < D.13712) goto <D.12109>; else goto <D.12110>;
  <D.12110>:
  D.13690 = 0;
  return D.13690;
}


__attribute__((__artificial__, __gnu_inline__, __always_inline__))
open (const char * __path, int __oflag)
{
  int D.13714;
  int D.13717;
  int D.13722;
  int D.13724;
  int D.13725;
  int D.13728;
  int D.13729;

  D.13714 = __builtin_va_arg_pack_len ();
  if (D.13714 > 1) goto <D.13715>; else goto <D.13716>;
  <D.13715>:
  __open_too_many_args ();
  <D.13716>:
  D.13717 = __builtin_constant_p (__oflag);
  if (D.13717 != 0) goto <D.13718>; else goto <D.13719>;
  <D.13718>:
  D.13722 = __oflag & 64;
  if (D.13722 != 0) goto <D.13720>; else goto <D.13723>;
  <D.13723>:
  D.13724 = __oflag & 4259840;
  if (D.13724 == 4259840) goto <D.13720>; else goto <D.13721>;
  <D.13720>:
  D.13725 = __builtin_va_arg_pack_len ();
  if (D.13725 <= 0) goto <D.13726>; else goto <D.13727>;
  <D.13726>:
  __open_missing_mode ();
  D.13728 = __open_2 (__path, __oflag);
  return D.13728;
  <D.13727>:
  <D.13721>:
  D.13728 = __open_alias (__path, __oflag, __builtin_va_arg_pack ());
  return D.13728;
  <D.13719>:
  D.13729 = __builtin_va_arg_pack_len ();
  if (D.13729 <= 0) goto <D.13730>; else goto <D.13731>;
  <D.13730>:
  D.13728 = __open_2 (__path, __oflag);
  return D.13728;
  <D.13731>:
  D.13728 = __open_alias (__path, __oflag, __builtin_va_arg_pack ());
  return D.13728;
}


GetLogicalDriveStrings_Mtab (guint32 len, gunichar2 * buf)
{
  unsigned int D.13733;
  long unsigned int D.13734;
  long unsigned int D.13735;
  gunichar2 * D.13736;
  gunichar2 * D.13737;
  gint32 D.13742;
  char D.13743;
  gchar * D.13748;
  gchar * * D.13750;
  gchar * D.13751;
  long int length.55;
  long int D.13753;
  long int D.13754;
  unsigned int D.13757;
  long unsigned int total.56;
  long unsigned int D.13759;
  gunichar2 * D.13760;
  long unsigned int length.57;
  long unsigned int D.13762;
  long int D.13763;
  char * D.13764;
  struct FILE * fp;
  gunichar2 * ptr;
  gunichar2 * dir;
  glong length;
  glong total;
  gchar buffer[512];
  gchar * * splitted;

  try
    {
      total = 0;
      D.13733 = len + 1;
      D.13734 = (long unsigned int) D.13733;
      D.13735 = D.13734 * 2;
      memset (buf, 0, D.13735);
      *buf = 47;
      D.13736 = buf + 2;
      *D.13736 = 0;
      D.13737 = buf + 4;
      *D.13737 = 0;
      fp = fopen ("/etc/mtab", "rt");
      if (fp == 0B) goto <D.13738>; else goto <D.13739>;
      <D.13738>:
      fp = fopen ("/etc/mnttab", "rt");
      if (fp == 0B) goto <D.13740>; else goto <D.13741>;
      <D.13740>:
      D.13742 = 1;
      return D.13742;
      <D.13741>:
      <D.13739>:
      ptr = buf;
      goto <D.12138>;
      <D.12139>:
      D.13743 = buffer[0];
      if (D.13743 != 47) goto <D.13744>; else goto <D.13745>;
      <D.13744>:
      // predicted unlikely by continue predictor.
      goto <D.12138>;
      <D.13745>:
      splitted = monoeg_g_strsplit (&buffer, " ", 0);
      D.13748 = *splitted;
      if (D.13748 == 0B) goto <D.13746>; else goto <D.13749>;
      <D.13749>:
      D.13750 = splitted + 8;
      D.13751 = *D.13750;
      if (D.13751 == 0B) goto <D.13746>; else goto <D.13747>;
      <D.13746>:
      monoeg_g_strfreev (splitted);
      // predicted unlikely by continue predictor.
      goto <D.12138>;
      <D.13747>:
      D.13750 = splitted + 8;
      D.13751 = *D.13750;
      unescape_octal (D.13751);
      D.13750 = splitted + 8;
      D.13751 = *D.13750;
      dir = monoeg_g_utf8_to_utf16 (D.13751, -1, 0B, &length, 0B);
      monoeg_g_strfreev (splitted);
      length.55 = length;
      D.13753 = total + length.55;
      D.13754 = (long int) len;
      if (D.13753 >= D.13754) goto <D.13755>; else goto <D.13756>;
      <D.13755>:
      fclose (fp);
      monoeg_g_free (dir);
      D.13757 = len * 2;
      D.13742 = (gint32) D.13757;
      return D.13742;
      <D.13756>:
      total.56 = (long unsigned int) total;
      D.13759 = total.56 * 2;
      D.13760 = ptr + D.13759;
      length.55 = length;
      length.57 = (long unsigned int) length.55;
      D.13762 = length.57 * 2;
      memcpy (D.13760, dir, D.13762);
      monoeg_g_free (dir);
      length.55 = length;
      D.13763 = length.55 + 1;
      total = D.13763 + total;
      <D.12138>:
      D.13764 = fgets (&buffer, 512, fp);
      if (D.13764 != 0B) goto <D.12139>; else goto <D.12140>;
      <D.12140>:
      fclose (fp);
      D.13742 = (gint32) total;
      return D.13742;
    }
  finally
    {
      length = {CLOBBER};
      buffer = {CLOBBER};
    }
}


unescape_octal (gchar * str)
{
  char D.13769;
  gchar * rptr.58;
  char D.13773;
  char D.13774;
  gchar * rptr.59;
  char D.13776;
  int D.13777;
  int D.13778;
  int D.13779;
  char D.13780;
  gchar * rptr.60;
  char D.13782;
  int D.13783;
  int D.13784;
  char D.13785;
  gchar * wptr.61;
  gchar * wptr.62;
  gchar * rptr.63;
  char D.13792;
  gchar * rptr;
  gchar * wptr;

  if (str == 0B) goto <D.13767>; else goto <D.13768>;
  <D.13767>:
  return;
  <D.13768>:
  wptr = str;
  rptr = wptr;
  goto <D.12021>;
  <D.12020>:
  D.13769 = *rptr;
  if (D.13769 == 92) goto <D.13770>; else goto <D.13771>;
  <D.13770>:
  {
    char c;

    rptr = rptr + 1;
    rptr.58 = rptr;
    rptr = rptr.58 + 1;
    D.13773 = *rptr.58;
    D.13774 = D.13773 + 208;
    c = D.13774 << 6;
    rptr.59 = rptr;
    rptr = rptr.59 + 1;
    D.13776 = *rptr.59;
    D.13777 = (int) D.13776;
    D.13778 = D.13777 + -48;
    D.13779 = D.13778 << 3;
    D.13780 = (char) D.13779;
    c = D.13780 + c;
    rptr.60 = rptr;
    rptr = rptr.60 + 1;
    D.13782 = *rptr.60;
    D.13783 = (int) D.13782;
    D.13784 = D.13783 + -48;
    D.13785 = (char) D.13784;
    c = D.13785 + c;
    wptr.61 = wptr;
    wptr = wptr.61 + 1;
    *wptr.61 = c;
  }
  goto <D.13787>;
  <D.13771>:
  if (wptr != rptr) goto <D.13788>; else goto <D.13789>;
  <D.13788>:
  wptr.62 = wptr;
  wptr = wptr.62 + 1;
  rptr.63 = rptr;
  rptr = rptr.63 + 1;
  D.13792 = *rptr.63;
  *wptr.62 = D.13792;
  goto <D.13793>;
  <D.13789>:
  rptr = rptr + 1;
  wptr = wptr + 1;
  <D.13793>:
  <D.13787>:
  <D.12021>:
  D.13769 = *rptr;
  if (D.13769 != 0) goto <D.12020>; else goto <D.12022>;
  <D.12022>:
  *wptr = 0;
}


__attribute__((__artificial__, __gnu_inline__, __always_inline__))
fgets (char * restrict __s, int __n, struct FILE * restrict __stream)
{
  long unsigned int D.13795;
  int D.13800;
  char * D.13802;
  long unsigned int D.13803;
  long unsigned int D.13804;
  long unsigned int D.13805;
  long unsigned int D.13808;

  D.13795 = __builtin_object_size (__s, 1);
  if (D.13795 != 18446744073709551615) goto <D.13796>; else goto <D.13797>;
  <D.13796>:
  D.13800 = __builtin_constant_p (__n);
  if (D.13800 == 0) goto <D.13798>; else goto <D.13801>;
  <D.13801>:
  if (__n <= 0) goto <D.13798>; else goto <D.13799>;
  <D.13798>:
  D.13803 = __builtin_object_size (__s, 1);
  D.13802 = __fgets_chk (__s, D.13803, __n, __stream);
  return D.13802;
  <D.13799>:
  D.13804 = (long unsigned int) __n;
  D.13805 = __builtin_object_size (__s, 1);
  if (D.13804 > D.13805) goto <D.13806>; else goto <D.13807>;
  <D.13806>:
  D.13808 = __builtin_object_size (__s, 1);
  D.13802 = __fgets_chk_warn (__s, D.13808, __n, __stream);
  return D.13802;
  <D.13807>:
  <D.13797>:
  D.13802 = __fgets_alias (__s, __n, __stream);
  return D.13802;
}


add_drive_string (guint32 len, gunichar2 * buf, struct LinuxMountInfoParseState * state)
{
  unsigned int D.13812;
  char D.13814;
  gchar[65] * D.13820;
  long unsigned int D.13821;
  int D.13822;
  unsigned int D.13825;
  gchar[65] * D.13827;
  int D.13828;
  long unsigned int D.13833;
  int D.13834;
  gchar * iftmp.64;
  gchar * D.13839;
  long int D.13843;
  long int length.65;
  long int D.13845;
  long int D.13846;
  unsigned int D.13849;
  long int D.13850;
  long int length.66;
  long unsigned int D.13853;
  long unsigned int D.13854;
  gunichar2 * D.13855;
  long unsigned int length.67;
  long unsigned int D.13857;
  gboolean D.13858;
  gboolean quit;
  gboolean ignore_entry;

  quit = 0;
  D.13812 = state->fsname_index;
  if (D.13812 == 1) goto <D.13813>; else goto <D.13810>;
  <D.13813>:
  D.13814 = state->fsname[0];
  if (D.13814 == 47) goto <D.13815>; else goto <D.13810>;
  <D.13815>:
  ignore_entry = 0;
  goto <D.13811>;
  <D.13810>:
  D.13812 = state->fsname_index;
  if (D.13812 == 0) goto <D.13816>; else goto <D.13819>;
  <D.13819>:
  D.13820 = &state->fsname;
  D.13812 = state->fsname_index;
  D.13821 = (long unsigned int) D.13812;
  D.13822 = memcmp ("none", D.13820, D.13821);
  if (D.13822 == 0) goto <D.13816>; else goto <D.13817>;
  <D.13816>:
  ignore_entry = 1;
  goto <D.13818>;
  <D.13817>:
  D.13825 = state->fstype_index;
  if (D.13825 > 4) goto <D.13826>; else goto <D.13823>;
  <D.13826>:
  D.13827 = &state->fstype;
  D.13828 = memcmp ("fuse.", D.13827, 5);
  if (D.13828 == 0) goto <D.13829>; else goto <D.13823>;
  <D.13829>:
  D.13825 = state->fstype_index;
  if (D.13825 == 21) goto <D.13832>; else goto <D.13830>;
  <D.13832>:
  D.13827 = &state->fstype;
  D.13825 = state->fstype_index;
  D.13833 = (long unsigned int) D.13825;
  D.13834 = memcmp ("fuse.gvfs-fuse-daemon", D.13827, D.13833);
  if (D.13834 == 0) goto <D.13835>; else goto <D.13830>;
  <D.13835>:
  ignore_entry = 1;
  goto <D.13831>;
  <D.13830>:
  ignore_entry = 0;
  <D.13831>:
  goto <D.13824>;
  <D.13823>:
  ignore_entry = 1;
  <D.13824>:
  <D.13818>:
  <D.13811>:
  if (ignore_entry == 0) goto <D.13836>; else goto <D.13837>;
  <D.13836>:
  {
    gunichar2 * dir;
    glong length;
    gchar * mountpoint;

    try
      {
        D.13839 = state->mountpoint_allocated;
        if (D.13839 != 0B) goto <D.13840>; else goto <D.13841>;
        <D.13840>:
        iftmp.64 = state->mountpoint_allocated;
        goto <D.13842>;
        <D.13841>:
        iftmp.64 = &state->mountpoint;
        <D.13842>:
        mountpoint = iftmp.64;
        unescape_octal (mountpoint);
        dir = monoeg_g_utf8_to_utf16 (mountpoint, -1, 0B, &length, 0B);
        D.13843 = state->total;
        length.65 = length;
        D.13845 = D.13843 + length.65;
        D.13846 = (long int) len;
        if (D.13845 >= D.13846) goto <D.13847>; else goto <D.13848>;
        <D.13847>:
        quit = 1;
        D.13849 = len * 2;
        D.13850 = (long int) D.13849;
        state->total = D.13850;
        goto <D.13851>;
        <D.13848>:
        length.65 = length;
        length.66 = length.65 + 1;
        length = length.66;
        D.13843 = state->total;
        D.13853 = (long unsigned int) D.13843;
        D.13854 = D.13853 * 2;
        D.13855 = buf + D.13854;
        length.65 = length;
        length.67 = (long unsigned int) length.65;
        D.13857 = length.67 * 2;
        memcpy (D.13855, dir, D.13857);
        D.13843 = state->total;
        length.65 = length;
        D.13845 = D.13843 + length.65;
        state->total = D.13845;
        <D.13851>:
        monoeg_g_free (dir);
      }
    finally
      {
        length = {CLOBBER};
      }
  }
  <D.13837>:
  state->fsname_index = 0;
  state->fstype_index = 0;
  D.13858 = quit;
  return D.13858;
}


GetDiskFreeSpaceEx (const gunichar2 * path_name, union WapiULargeInteger * free_bytes_avail, union WapiULargeInteger * total_number_of_bytes, union WapiULargeInteger * total_number_of_free_bytes)
{
  gchar * D.13862;
  gboolean D.13865;
  long unsigned int D.13869;
  long unsigned int D.13870;
  _Bool D.13871;
  int * D.13873;
  int D.13874;
  long unsigned int D.13882;
  long unsigned int D.13883;
  long unsigned int D.13886;
  long unsigned int D.13887;
  long unsigned int D.13893;
  long unsigned int D.13894;
  struct statvfs fsstat;
  gboolean isreadonly;
  gchar * utf8_path_name;
  int ret;
  long unsigned int block_size;

  try
    {
      if (path_name == 0B) goto <D.13860>; else goto <D.13861>;
      <D.13860>:
      D.13862 = monoeg_g_get_current_dir ();
      utf8_path_name = monoeg_strdup (D.13862);
      if (utf8_path_name == 0B) goto <D.13863>; else goto <D.13864>;
      <D.13863>:
      SetLastError (267);
      D.13865 = 0;
      return D.13865;
      <D.13864>:
      goto <D.13866>;
      <D.13861>:
      utf8_path_name = mono_unicode_to_external (path_name);
      if (utf8_path_name == 0B) goto <D.13867>; else goto <D.13868>;
      <D.13867>:
      SetLastError (123);
      D.13865 = 0;
      return D.13865;
      <D.13868>:
      <D.13866>:
      <D.12152>:
      ret = statvfs (utf8_path_name, &fsstat);
      D.13869 = fsstat.f_flag;
      D.13870 = D.13869 & 1;
      D.13871 = D.13870 != 0;
      isreadonly = (gboolean) D.13871;
      block_size = fsstat.f_frsize;
      if (ret == -1) goto <D.13872>; else goto <D.12153>;
      <D.13872>:
      D.13873 = __errno_location ();
      D.13874 = *D.13873;
      if (D.13874 == 4) goto <D.12152>; else goto <D.12153>;
      <D.12153>:
      monoeg_g_free (utf8_path_name);
      if (ret == -1) goto <D.13875>; else goto <D.13876>;
      <D.13875>:
      _wapi_set_last_error_from_errno ();
      D.13865 = 0;
      return D.13865;
      <D.13876>:
      if (free_bytes_avail != 0B) goto <D.13877>; else goto <D.13878>;
      <D.13877>:
      if (isreadonly != 0) goto <D.13879>; else goto <D.13880>;
      <D.13879>:
      free_bytes_avail->QuadPart = 0;
      goto <D.13881>;
      <D.13880>:
      D.13882 = fsstat.f_bavail;
      D.13883 = D.13882 * block_size;
      free_bytes_avail->QuadPart = D.13883;
      <D.13881>:
      <D.13878>:
      if (total_number_of_bytes != 0B) goto <D.13884>; else goto <D.13885>;
      <D.13884>:
      D.13886 = fsstat.f_blocks;
      D.13887 = D.13886 * block_size;
      total_number_of_bytes->QuadPart = D.13887;
      <D.13885>:
      if (total_number_of_free_bytes != 0B) goto <D.13888>; else goto <D.13889>;
      <D.13888>:
      if (isreadonly != 0) goto <D.13890>; else goto <D.13891>;
      <D.13890>:
      total_number_of_free_bytes->QuadPart = 0;
      goto <D.13892>;
      <D.13891>:
      D.13893 = fsstat.f_bfree;
      D.13894 = D.13893 * block_size;
      total_number_of_free_bytes->QuadPart = D.13894;
      <D.13892>:
      <D.13889>:
      D.13865 = 1;
      return D.13865;
    }
  finally
    {
      fsstat = {CLOBBER};
    }
}


GetDriveType (const gunichar2 * root_path_name)
{
  gchar * D.13899;
  guint32 D.13902;
  int D.13906;
  gchar * D.13909;
  char D.13910;
  long unsigned int D.13913;
  sizetype D.13914;
  gchar * D.13915;
  gchar * utf8_root_path_name;
  guint32 drive_type;

  if (root_path_name == 0B) goto <D.13897>; else goto <D.13898>;
  <D.13897>:
  D.13899 = monoeg_g_get_current_dir ();
  utf8_root_path_name = monoeg_strdup (D.13899);
  if (utf8_root_path_name == 0B) goto <D.13900>; else goto <D.13901>;
  <D.13900>:
  D.13902 = 1;
  return D.13902;
  <D.13901>:
  goto <D.13903>;
  <D.13898>:
  utf8_root_path_name = mono_unicode_to_external (root_path_name);
  if (utf8_root_path_name == 0B) goto <D.13904>; else goto <D.13905>;
  <D.13904>:
  D.13902 = 1;
  return D.13902;
  <D.13905>:
  D.13906 = monoeg_g_str_has_suffix (utf8_root_path_name, "/");
  if (D.13906 != 0) goto <D.13907>; else goto <D.13908>;
  <D.13907>:
  D.13909 = utf8_root_path_name + 1;
  D.13910 = *D.13909;
  if (D.13910 != 0) goto <D.13911>; else goto <D.13912>;
  <D.13911>:
  D.13913 = __strlen_g (utf8_root_path_name);
  D.13914 = D.13913 + 18446744073709551615;
  D.13915 = utf8_root_path_name + D.13914;
  *D.13915 = 0;
  <D.13912>:
  <D.13908>:
  <D.13903>:
  drive_type = GetDriveTypeFromPath (utf8_root_path_name);
  monoeg_g_free (utf8_root_path_name);
  D.13902 = drive_type;
  return D.13902;
}


GetDriveTypeFromPath (const char * utf8_root_path_name)
{
  int D.13917;
  guint32 D.13920;
  unsigned int D.13921;
  long int D.13922;
  struct statfs buf;

  try
    {
      D.13917 = statfs (utf8_root_path_name, &buf);
      if (D.13917 == -1) goto <D.13918>; else goto <D.13919>;
      <D.13918>:
      D.13920 = 0;
      return D.13920;
      <D.13919>:
      D.13921 = buf.f_type;
      D.13922 = (long int) D.13921;
      D.13920 = _wapi_get_drive_type (D.13922);
      return D.13920;
    }
  finally
    {
      buf = {CLOBBER};
    }
}


_wapi_get_drive_type (long int f_type)
{
  long int D.13925;
  guint32 D.13928;
  unsigned int D.13929;
  struct _wapi_drive_type * current;

  current = &_wapi_drive_types[0];
  goto <D.12165>;
  <D.12164>:
  D.13925 = current->fstypeid;
  if (D.13925 == f_type) goto <D.13926>; else goto <D.13927>;
  <D.13926>:
  D.13928 = current->drive_type;
  return D.13928;
  <D.13927>:
  current = current + 24;
  <D.12165>:
  D.13929 = current->drive_type;
  if (D.13929 != 0) goto <D.12164>; else goto <D.12166>;
  <D.12166>:
  D.13928 = 0;
  return D.13928;
}


GetVolumeInformation (const gunichar2 * path, gunichar2 * volumename, int volumesize, int * outserial, int * maxcomp, int * fsflags, gunichar2 * fsbuffer, int fsbuffersize)
{
  gboolean D.13933;
  long int D.13938;
  long int len.68;
  long unsigned int len.69;
  long unsigned int D.13943;
  gunichar2 * D.13944;
  gchar * utfpath;
  gchar * fstypename;
  gboolean status;
  glong len;

  try
    {
      status = 0;
      if (fsbuffer == 0B) goto <D.13931>; else goto <D.13932>;
      <D.13931>:
      D.13933 = 0;
      return D.13933;
      <D.13932>:
      utfpath = mono_unicode_to_external (path);
      fstypename = get_fstypename (utfpath);
      if (fstypename != 0B) goto <D.13934>; else goto <D.13935>;
      <D.13934>:
      {
        gunichar2 * ret;

        ret = monoeg_g_utf8_to_utf16 (fstypename, -1, 0B, &len, 0B);
        if (ret != 0B) goto <D.13936>; else goto <D.13937>;
        <D.13936>:
        D.13938 = (long int) fsbuffersize;
        len.68 = len;
        if (D.13938 > len.68) goto <D.13940>; else goto <D.13941>;
        <D.13940>:
        len.68 = len;
        len.69 = (long unsigned int) len.68;
        D.13943 = len.69 * 2;
        memcpy (fsbuffer, ret, D.13943);
        len.68 = len;
        len.69 = (long unsigned int) len.68;
        D.13943 = len.69 * 2;
        D.13944 = fsbuffer + D.13943;
        *D.13944 = 0;
        status = 1;
        <D.13941>:
        <D.13937>:
        if (ret != 0B) goto <D.13945>; else goto <D.13946>;
        <D.13945>:
        monoeg_g_free (ret);
        <D.13946>:
        monoeg_g_free (fstypename);
      }
      <D.13935>:
      monoeg_g_free (utfpath);
      D.13933 = status;
      return D.13933;
    }
  finally
    {
      len = {CLOBBER};
    }
}


get_fstypename (gchar * utfpath)
{
  int D.13949;
  gchar * D.13952;
  unsigned int D.13953;
  long int D.13954;
  long int D.13955;
  const gchar * D.13958;
  unsigned int D.13959;
  struct statfs stat;
  struct _wapi_drive_type * current;

  try
    {
      D.13949 = statfs (utfpath, &stat);
      if (D.13949 == -1) goto <D.13950>; else goto <D.13951>;
      <D.13950>:
      D.13952 = 0B;
      return D.13952;
      <D.13951>:
      current = &_wapi_drive_types[0];
      goto <D.12182>;
      <D.12181>:
      D.13953 = stat.f_type;
      D.13954 = (long int) D.13953;
      D.13955 = current->fstypeid;
      if (D.13954 == D.13955) goto <D.13956>; else goto <D.13957>;
      <D.13956>:
      D.13958 = current->fstype;
      D.13952 = monoeg_strdup (D.13958);
      return D.13952;
      <D.13957>:
      current = current + 24;
      <D.12182>:
      D.13959 = current->drive_type;
      if (D.13959 != 0) goto <D.12181>; else goto <D.12183>;
      <D.12183>:
      D.13952 = 0B;
      return D.13952;
    }
  finally
    {
      stat = {CLOBBER};
    }
}


_wapi_io_init ()
{
  pthread_mutex_init (&stdhandle_mutex, 0B);
}


