file_close (void * handle, void * data)
{
  unsigned int D.12074;
  unsigned int D.12075;
  gchar * D.12078;
  struct _WapiFileShare * D.12079;
  struct _WapiHandle_file * file_handle;
  int fd;

  file_handle = data;
  fd = file_handle->fd;
  D.12074 = file_handle->attrs;
  D.12075 = D.12074 & 67108864;
  if (D.12075 != 0) goto <D.12076>; else goto <D.12077>;
  <D.12076>:
  D.12078 = file_handle->filename;
  _wapi_unlink (D.12078);
  <D.12077>:
  D.12078 = file_handle->filename;
  monoeg_g_free (D.12078);
  D.12079 = file_handle->share_info;
  if (D.12079 != 0B) goto <D.12080>; else goto <D.12081>;
  <D.12080>:
  D.12079 = file_handle->share_info;
  _wapi_handle_share_release (D.12079);
  <D.12081>:
  close (fd);
}


_wapi_handle_share_release (struct _WapiFileShare * info)
{
  unsigned int D.12082;
  _Bool D.12083;
  long int D.12084;
  long int D.12085;
  _Bool D.12088;
  long int D.12089;
  long int D.12090;
  guint32 * D.12093;
  int D.12094;
  int thr_ret;

  D.12082 = info->handle_refs;
  D.12083 = D.12082 == 0;
  D.12084 = (long int) D.12083;
  D.12085 = __builtin_expect (D.12084, 0);
  if (D.12085 != 0) goto <D.12086>; else goto <D.12087>;
  <D.12086>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "../../mono/io-layer/handles-private.h", 364, "info->handle_refs > 0");
  <D.12087>:
  thr_ret = _wapi_shm_sem_lock (2);
  D.12088 = thr_ret != 0;
  D.12089 = (long int) D.12088;
  D.12090 = __builtin_expect (D.12089, 0);
  if (D.12090 != 0) goto <D.12091>; else goto <D.12092>;
  <D.12091>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "../../mono/io-layer/handles-private.h", 368, "thr_ret == 0");
  <D.12092>:
  D.12093 = &info->handle_refs;
  D.12094 = InterlockedDecrement (D.12093);
  if (D.12094 == 0) goto <D.12095>; else goto <D.12096>;
  <D.12095>:
  _wapi_free_share_info (info);
  <D.12096>:
  thr_ret = _wapi_shm_sem_unlock (2);
}


InterlockedDecrement (volatile gint32 * val)
{
  gint32 D.12097;
  unsigned int D.12098;

  D.12098 = __sync_sub_and_fetch_4 (val, 1);
  D.12097 = (gint32) D.12098;
  return D.12097;
}


_wapi_file_details (void * handle_info)
{
  unsigned int D.12100;
  int iftmp.0;
  unsigned int D.12102;
  unsigned int D.12103;
  int iftmp.1;
  unsigned int D.12108;
  int iftmp.2;
  unsigned int D.12113;
  int iftmp.3;
  unsigned int D.12118;
  unsigned int D.12119;
  int iftmp.4;
  unsigned int D.12124;
  int iftmp.5;
  signed int D.12129;
  gchar * D.12133;
  struct _WapiHandle_file * file;

  file = handle_info;
  D.12100 = file->attrs;
  D.12102 = file->sharemode;
  D.12103 = D.12102 & 4;
  if (D.12103 != 0) goto <D.12104>; else goto <D.12105>;
  <D.12104>:
  iftmp.0 = 68;
  goto <D.12106>;
  <D.12105>:
  iftmp.0 = 46;
  <D.12106>:
  D.12102 = file->sharemode;
  D.12108 = D.12102 & 2;
  if (D.12108 != 0) goto <D.12109>; else goto <D.12110>;
  <D.12109>:
  iftmp.1 = 87;
  goto <D.12111>;
  <D.12110>:
  iftmp.1 = 46;
  <D.12111>:
  D.12102 = file->sharemode;
  D.12113 = D.12102 & 1;
  if (D.12113 != 0) goto <D.12114>; else goto <D.12115>;
  <D.12114>:
  iftmp.2 = 82;
  goto <D.12116>;
  <D.12115>:
  iftmp.2 = 46;
  <D.12116>:
  D.12118 = file->fileaccess;
  D.12119 = D.12118 & 536870912;
  if (D.12119 != 0) goto <D.12120>; else goto <D.12121>;
  <D.12120>:
  iftmp.3 = 88;
  goto <D.12122>;
  <D.12121>:
  iftmp.3 = 46;
  <D.12122>:
  D.12118 = file->fileaccess;
  D.12124 = D.12118 & 1073741824;
  if (D.12124 != 0) goto <D.12125>; else goto <D.12126>;
  <D.12125>:
  iftmp.4 = 87;
  goto <D.12127>;
  <D.12126>:
  iftmp.4 = 46;
  <D.12127>:
  D.12118 = file->fileaccess;
  D.12129 = (signed int) D.12118;
  if (D.12129 < 0) goto <D.12130>; else goto <D.12131>;
  <D.12130>:
  iftmp.5 = 82;
  goto <D.12132>;
  <D.12131>:
  iftmp.5 = 46;
  <D.12132>:
  D.12133 = file->filename;
  monoeg_g_print ("[%20s] acc: %c%c%c, shr: %c%c%c, attrs: %5u", D.12133, iftmp.5, iftmp.4, iftmp.3, iftmp.2, iftmp.1, iftmp.0, D.12100);
}


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

  console_handle = data;
  fd = console_handle->fd;
  D.12134 = console_handle->filename;
  monoeg_g_free (D.12134);
  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.12135;
  unsigned int D.12138;
  void * D.12141;
  int * D.12148;
  int D.12149;
  int D.12152;
  unsigned int fd.6;
  unsigned int _wapi_fd_reserve.7;
  int D.12161;
  struct _WapiFileShare * D.12164;
  unsigned int D.12169;
  unsigned int D.12172;
  unsigned int D.12175;
  unsigned int D.12176;
  <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.12135 = attrs & 256;
      if (D.12135 != 0) goto <D.12136>; else goto <D.12137>;
      <D.12136>:
      perms = 384;
      <D.12137>:
      D.12138 = attrs & 64;
      if (D.12138 != 0) goto <D.12139>; else goto <D.12140>;
      <D.12139>:
      SetLastError (6000);
      D.12141 = -1B;
      return D.12141;
      <D.12140>:
      if (name == 0B) goto <D.12142>; else goto <D.12143>;
      <D.12142>:
      SetLastError (123);
      D.12141 = -1B;
      return D.12141;
      <D.12143>:
      filename = mono_unicode_to_external (name);
      if (filename == 0B) goto <D.12144>; else goto <D.12145>;
      <D.12144>:
      SetLastError (123);
      D.12141 = -1B;
      return D.12141;
      <D.12145>:
      fd = _wapi_open (filename, flags, perms);
      if (fd == -1) goto <D.12146>; else goto <D.12147>;
      <D.12146>:
      D.12148 = __errno_location ();
      D.12149 = *D.12148;
      if (D.12149 == 21) goto <D.12150>; else goto <D.12151>;
      <D.12150>:
      D.12152 = flags & -4;
      fd = _wapi_open (filename, D.12152, perms);
      <D.12151>:
      <D.12147>:
      if (fd == -1) goto <D.12153>; else goto <D.12154>;
      <D.12153>:
      _wapi_set_last_path_error_from_errno (0B, filename);
      monoeg_g_free (filename);
      D.12141 = -1B;
      return D.12141;
      <D.12154>:
      fd.6 = (unsigned int) fd;
      _wapi_fd_reserve.7 = _wapi_fd_reserve;
      if (fd.6 >= _wapi_fd_reserve.7) goto <D.12157>; else goto <D.12158>;
      <D.12157>:
      SetLastError (4);
      close (fd);
      monoeg_g_free (filename);
      D.12141 = -1B;
      return D.12141;
      <D.12158>:
      ret = fstat (fd, &statbuf);
      if (ret == -1) goto <D.12159>; else goto <D.12160>;
      <D.12159>:
      _wapi_set_last_error_from_errno ();
      monoeg_g_free (filename);
      close (fd);
      D.12141 = -1B;
      return D.12141;
      <D.12160>:
      D.12161 = share_check (&statbuf, sharemode, fileaccess, &file_handle.share_info, fd);
      if (D.12161 == 0) goto <D.12162>; else goto <D.12163>;
      <D.12162>:
      SetLastError (32);
      monoeg_g_free (filename);
      close (fd);
      D.12141 = -1B;
      return D.12141;
      <D.12163>:
      D.12164 = file_handle.share_info;
      if (D.12164 == 0B) goto <D.12165>; else goto <D.12166>;
      <D.12165>:
      SetLastError (4);
      close (fd);
      monoeg_g_free (filename);
      D.12141 = -1B;
      return D.12141;
      <D.12166>:
      file_handle.filename = filename;
      if (security != 0B) goto <D.12167>; else goto <D.12168>;
      <D.12167>:
      <D.12168>:
      file_handle.fd = fd;
      file_handle.fileaccess = fileaccess;
      file_handle.sharemode = sharemode;
      file_handle.attrs = attrs;
      D.12169 = attrs & 134217728;
      if (D.12169 != 0) goto <D.12170>; else goto <D.12171>;
      <D.12170>:
      posix_fadvise (fd, 0, 0, 2);
      <D.12171>:
      D.12172 = attrs & 268435456;
      if (D.12172 != 0) goto <D.12173>; else goto <D.12174>;
      <D.12173>:
      posix_fadvise (fd, 0, 0, 1);
      <D.12174>:
      D.12175 = statbuf.st_mode;
      D.12176 = D.12175 & 61440;
      if (D.12176 == 4096) goto <D.12177>; else goto <D.12178>;
      <D.12177>:
      handle_type = 10;
      goto <D.12179>;
      <D.12178>:
      D.12175 = statbuf.st_mode;
      D.12176 = D.12175 & 61440;
      if (D.12176 == 8192) goto <D.12180>; else goto <D.12181>;
      <D.12180>:
      handle_type = 2;
      goto <D.12182>;
      <D.12181>:
      handle_type = 1;
      <D.12182>:
      <D.12179>:
      handle_type.8 = (<unnamed type>) handle_type;
      handle = _wapi_handle_new_fd (handle_type.8, fd, &file_handle);
      if (handle == -1B) goto <D.12184>; else goto <D.12185>;
      <D.12184>:
      monoeg_g_log (0B, 16, "%s: error creating file handle", &__func__);
      monoeg_g_free (filename);
      close (fd);
      SetLastError (31);
      D.12141 = -1B;
      return D.12141;
      <D.12185>:
      D.12141 = handle;
      return D.12141;
    }
  finally
    {
      file_handle = {CLOBBER};
      statbuf = {CLOBBER};
    }
}


io_ops_init ()
{
  const gchar * D.12188;

  D.12188 = monoeg_g_getenv ("MONO_STRICT_IO_EMULATION");
  if (D.12188 != 0B) goto <D.12189>; else goto <D.12190>;
  <D.12189>:
  lock_while_writing = 1;
  <D.12190>:
}


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

  flags = 0;
  switch (fileaccess) <default: <D.11540>, case 1073741824: <D.11538>, case 2147483648: <D.11536>, case 3221225472: <D.11539>>
  <D.11536>:
  flags = 0;
  goto <D.11537>;
  <D.11538>:
  flags = 1;
  goto <D.11537>;
  <D.11539>:
  flags = 2;
  goto <D.11537>;
  <D.11540>:
  goto <D.11537>;
  <D.11537>:
  switch (createmode) <default: <D.11547>, case 1: <D.11541>, case 2: <D.11543>, case 3: <D.11544>, case 4: <D.11545>, case 5: <D.11546>>
  <D.11541>:
  flags = flags | 192;
  goto <D.11542>;
  <D.11543>:
  flags = flags | 576;
  goto <D.11542>;
  <D.11544>:
  goto <D.11542>;
  <D.11545>:
  flags = flags | 64;
  goto <D.11542>;
  <D.11546>:
  flags = flags | 512;
  goto <D.11542>;
  <D.11547>:
  goto <D.11542>;
  <D.11542>:
  D.12191 = flags;
  return D.12191;
}


_wapi_set_last_path_error_from_errno (const gchar * dir, const gchar * path)
{
  int * D.12195;
  int D.12196;
  int D.12202;

  D.12195 = __errno_location ();
  D.12196 = *D.12195;
  if (D.12196 == 2) goto <D.12197>; else goto <D.12198>;
  <D.12197>:
  {
    gchar * dirname;

    if (dir == 0B) goto <D.12199>; else goto <D.12200>;
    <D.12199>:
    dirname = _wapi_dirname (path);
    goto <D.12201>;
    <D.12200>:
    dirname = monoeg_strdup (dir);
    <D.12201>:
    D.12202 = _wapi_access (dirname, 0);
    if (D.12202 == 0) goto <D.12203>; else goto <D.12204>;
    <D.12203>:
    SetLastError (2);
    goto <D.12205>;
    <D.12204>:
    SetLastError (3);
    <D.12205>:
    monoeg_g_free (dirname);
  }
  goto <D.12206>;
  <D.12198>:
  _wapi_set_last_error_from_errno ();
  <D.12206>:
}


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

  if (str != 0B) goto <D.12207>; else goto <D.12208>;
  <D.12207>:
  D.12209 = __strdup (str);
  return D.12209;
  <D.12208>:
  D.12209 = 0B;
  return D.12209;
}


fstat (int __fd, struct stat * __statbuf)
{
  int D.12211;

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


_wapi_set_last_error_from_errno ()
{
  int * D.12213;
  int D.12214;
  int D.12215;
  unsigned int D.12216;

  D.12213 = __errno_location ();
  D.12214 = *D.12213;
  D.12215 = _wapi_get_win32_file_error (D.12214);
  D.12216 = (unsigned int) D.12215;
  SetLastError (D.12216);
}


share_check (struct stat * statbuf, guint32 sharemode, guint32 fileaccess, struct _WapiFileShare * * share_info, int fd)
{
  int D.12217;
  gboolean D.12220;
  struct _WapiFileShare * D.12221;
  int D.12222;

  D.12217 = share_allows_open (statbuf, sharemode, fileaccess, share_info);
  if (D.12217 == 1) goto <D.12218>; else goto <D.12219>;
  <D.12218>:
  D.12220 = 1;
  return D.12220;
  <D.12219>:
  D.12221 = *share_info;
  _wapi_handle_check_share (D.12221, fd);
  D.12222 = share_allows_open (statbuf, sharemode, fileaccess, share_info);
  if (D.12222 == 1) goto <D.12223>; else goto <D.12224>;
  <D.12223>:
  D.12220 = 1;
  return D.12220;
  <D.12224>:
  _wapi_handle_collect ();
  D.12220 = share_allows_open (statbuf, sharemode, fileaccess, share_info);
  return D.12220;
}


share_allows_open (struct stat * statbuf, guint32 sharemode, guint32 fileaccess, struct _WapiFileShare * * share_info)
{
  long unsigned int D.12226;
  long unsigned int D.12227;
  unsigned int file_existing_share.9;
  struct _WapiFileShare * D.12233;
  gboolean D.12234;
  unsigned int file_existing_access.10;
  signed int file_existing_access.11;
  unsigned int D.12246;
  unsigned int D.12247;
  unsigned int D.12249;
  gboolean file_already_shared;
  guint32 file_existing_share;
  guint32 file_existing_access;

  try
    {
      D.12226 = statbuf->st_ino;
      D.12227 = statbuf->st_dev;
      file_already_shared = _wapi_handle_get_or_set_share (D.12227, D.12226, sharemode, fileaccess, &file_existing_share, &file_existing_access, share_info);
      if (file_already_shared != 0) goto <D.12228>; else goto <D.12229>;
      <D.12228>:
      file_existing_share.9 = file_existing_share;
      if (file_existing_share.9 == 0) goto <D.12231>; else goto <D.12232>;
      <D.12231>:
      D.12233 = *share_info;
      _wapi_handle_share_release (D.12233);
      D.12234 = 0;
      return D.12234;
      <D.12232>:
      file_existing_share.9 = file_existing_share;
      if (file_existing_share.9 == 1) goto <D.12238>; else goto <D.12235>;
      <D.12238>:
      if (fileaccess != 2147483648) goto <D.12236>; else goto <D.12235>;
      <D.12235>:
      file_existing_share.9 = file_existing_share;
      if (file_existing_share.9 == 2) goto <D.12239>; else goto <D.12237>;
      <D.12239>:
      if (fileaccess != 1073741824) goto <D.12236>; else goto <D.12237>;
      <D.12236>:
      D.12233 = *share_info;
      _wapi_handle_share_release (D.12233);
      D.12234 = 0;
      return D.12234;
      <D.12237>:
      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.12245>; else goto <D.12240>;
      <D.12245>:
      D.12246 = sharemode & 1;
      if (D.12246 == 0) goto <D.12241>; else goto <D.12240>;
      <D.12240>:
      file_existing_access.10 = file_existing_access;
      D.12247 = file_existing_access.10 & 1073741824;
      if (D.12247 != 0) goto <D.12248>; else goto <D.12242>;
      <D.12248>:
      D.12249 = sharemode & 2;
      if (D.12249 == 0) goto <D.12241>; else goto <D.12242>;
      <D.12241>:
      D.12233 = *share_info;
      _wapi_handle_share_release (D.12233);
      D.12234 = 0;
      return D.12234;
      <D.12242>:
      goto <D.12250>;
      <D.12229>:
      <D.12250>:
      D.12234 = 1;
      return D.12234;
    }
  finally
    {
      file_existing_share = {CLOBBER};
      file_existing_access = {CLOBBER};
    }
}


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

  ret = 0;
  if (name == 0B) goto <D.12253>; else goto <D.12254>;
  <D.12253>:
  SetLastError (123);
  D.12255 = 0;
  return D.12255;
  <D.12254>:
  filename = mono_unicode_to_external (name);
  if (filename == 0B) goto <D.12256>; else goto <D.12257>;
  <D.12256>:
  SetLastError (123);
  D.12255 = 0;
  return D.12255;
  <D.12257>:
  attrs = GetFileAttributes (name);
  if (attrs == 4294967295) goto <D.12258>; else goto <D.12259>;
  <D.12258>:
  monoeg_g_free (filename);
  D.12255 = 0;
  return D.12255;
  <D.12259>:
  retval = _wapi_unlink (filename);
  if (retval == -1) goto <D.12260>; else goto <D.12261>;
  <D.12260>:
  _wapi_set_last_path_error_from_errno (0B, filename);
  goto <D.12262>;
  <D.12261>:
  ret = 1;
  <D.12262>:
  monoeg_g_free (filename);
  D.12255 = ret;
  return D.12255;
}


MoveFile (const gunichar2 * name, const gunichar2 * dest_name)
{
  gboolean D.12266;
  int D.12273;
  int * D.12278;
  int D.12279;
  int D.12281;
  int D.12282;
  long unsigned int D.12287;
  long unsigned int D.12288;
  long unsigned int D.12290;
  long unsigned int D.12291;
  int D.12292;
  struct _WapiFileShare * shareinfo.12;
  _Bool D.12300;
  _Bool D.12301;
  _Bool D.12302;
  unsigned int D.12305;
  unsigned int D.12306;
  int D.12309;
  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.12264>; else goto <D.12265>;
      <D.12264>:
      SetLastError (123);
      D.12266 = 0;
      return D.12266;
      <D.12265>:
      utf8_name = mono_unicode_to_external (name);
      if (utf8_name == 0B) goto <D.12267>; else goto <D.12268>;
      <D.12267>:
      SetLastError (123);
      D.12266 = 0;
      return D.12266;
      <D.12268>:
      if (dest_name == 0B) goto <D.12269>; else goto <D.12270>;
      <D.12269>:
      monoeg_g_free (utf8_name);
      SetLastError (123);
      D.12266 = 0;
      return D.12266;
      <D.12270>:
      utf8_dest_name = mono_unicode_to_external (dest_name);
      if (utf8_dest_name == 0B) goto <D.12271>; else goto <D.12272>;
      <D.12271>:
      monoeg_g_free (utf8_name);
      SetLastError (123);
      D.12266 = 0;
      return D.12266;
      <D.12272>:
      D.12273 = _wapi_stat (utf8_name, &stat_src);
      if (D.12273 < 0) goto <D.12274>; else goto <D.12275>;
      <D.12274>:
      D.12278 = __errno_location ();
      D.12279 = *D.12278;
      if (D.12279 != 2) goto <D.12276>; else goto <D.12280>;
      <D.12280>:
      D.12281 = _wapi_lstat (utf8_name, &stat_src);
      if (D.12281 < 0) goto <D.12276>; else goto <D.12277>;
      <D.12276>:
      _wapi_set_last_path_error_from_errno (0B, utf8_name);
      monoeg_g_free (utf8_name);
      monoeg_g_free (utf8_dest_name);
      D.12266 = 0;
      return D.12266;
      <D.12277>:
      <D.12275>:
      D.12282 = _wapi_stat (utf8_dest_name, &stat_dest);
      if (D.12282 == 0) goto <D.12283>; else goto <D.12284>;
      <D.12283>:
      D.12287 = stat_dest.st_dev;
      D.12288 = stat_src.st_dev;
      if (D.12287 != D.12288) goto <D.12285>; else goto <D.12289>;
      <D.12289>:
      D.12290 = stat_dest.st_ino;
      D.12291 = stat_src.st_ino;
      if (D.12290 != D.12291) goto <D.12285>; else goto <D.12286>;
      <D.12285>:
      monoeg_g_free (utf8_name);
      monoeg_g_free (utf8_dest_name);
      SetLastError (183);
      D.12266 = 0;
      return D.12266;
      <D.12286>:
      <D.12284>:
      D.12292 = share_allows_delete (&stat_src, &shareinfo);
      if (D.12292 == 0) goto <D.12293>; else goto <D.12294>;
      <D.12293>:
      SetLastError (32);
      D.12266 = 0;
      return D.12266;
      <D.12294>:
      shareinfo.12 = shareinfo;
      if (shareinfo.12 != 0B) goto <D.12296>; else goto <D.12297>;
      <D.12296>:
      shareinfo.12 = shareinfo;
      _wapi_handle_share_release (shareinfo.12);
      <D.12297>:
      result = _wapi_rename (utf8_name, utf8_dest_name);
      D.12278 = __errno_location ();
      errno_copy = *D.12278;
      if (result == -1) goto <D.12298>; else goto <D.12299>;
      <D.12298>:
      switch (errno_copy) <default: <D.11612>, case 17: <D.11609>, case 18: <D.11611>>
      <D.11609>:
      SetLastError (183);
      goto <D.11610>;
      <D.11611>:
      goto <D.11610>;
      <D.11612>:
      _wapi_set_last_path_error_from_errno (0B, utf8_name);
      <D.11610>:
      <D.12299>:
      monoeg_g_free (utf8_name);
      monoeg_g_free (utf8_dest_name);
      D.12300 = result != 0;
      D.12301 = errno_copy == 18;
      D.12302 = D.12300 & D.12301;
      if (D.12302 != 0) goto <D.12303>; else goto <D.12304>;
      <D.12303>:
      D.12305 = stat_src.st_mode;
      D.12306 = D.12305 & 61440;
      if (D.12306 == 16384) goto <D.12307>; else goto <D.12308>;
      <D.12307>:
      SetLastError (17);
      D.12266 = 0;
      return D.12266;
      <D.12308>:
      D.12309 = CopyFile (name, dest_name, 1);
      if (D.12309 == 0) goto <D.12310>; else goto <D.12311>;
      <D.12310>:
      D.12266 = 0;
      return D.12266;
      <D.12311>:
      D.12266 = DeleteFile (name);
      return D.12266;
      <D.12304>:
      if (result == 0) goto <D.12312>; else goto <D.12313>;
      <D.12312>:
      ret = 1;
      <D.12313>:
      D.12266 = ret;
      return D.12266;
    }
  finally
    {
      stat_src = {CLOBBER};
      stat_dest = {CLOBBER};
      shareinfo = {CLOBBER};
    }
}


share_allows_delete (struct stat * statbuf, struct _WapiFileShare * * share_info)
{
  long unsigned int D.12317;
  long unsigned int D.12318;
  unsigned int file_existing_share.13;
  struct _WapiFileShare * D.12324;
  gboolean D.12325;
  unsigned int D.12326;
  gboolean file_already_shared;
  guint32 file_existing_share;
  guint32 file_existing_access;

  try
    {
      D.12317 = statbuf->st_ino;
      D.12318 = statbuf->st_dev;
      file_already_shared = _wapi_handle_get_or_set_share (D.12318, D.12317, 4, 2147483648, &file_existing_share, &file_existing_access, share_info);
      if (file_already_shared != 0) goto <D.12319>; else goto <D.12320>;
      <D.12319>:
      file_existing_share.13 = file_existing_share;
      if (file_existing_share.13 == 0) goto <D.12322>; else goto <D.12323>;
      <D.12322>:
      D.12324 = *share_info;
      _wapi_handle_share_release (D.12324);
      D.12325 = 0;
      return D.12325;
      <D.12323>:
      file_existing_share.13 = file_existing_share;
      D.12326 = file_existing_share.13 & 4;
      if (D.12326 == 0) goto <D.12327>; else goto <D.12328>;
      <D.12327>:
      D.12324 = *share_info;
      _wapi_handle_share_release (D.12324);
      D.12325 = 0;
      return D.12325;
      <D.12328>:
      goto <D.12329>;
      <D.12320>:
      <D.12329>:
      D.12325 = 1;
      return D.12325;
    }
  finally
    {
      file_existing_share = {CLOBBER};
      file_existing_access = {CLOBBER};
    }
}


CopyFile (const gunichar2 * name, const gunichar2 * dest_name, gboolean fail_if_exists)
{
  gboolean D.12334;
  int D.12343;
  int D.12346;
  long unsigned int D.12349;
  long unsigned int D.12350;
  long unsigned int D.12353;
  long unsigned int D.12354;
  unsigned int D.12359;
  int D.12366;
  long int D.12369;
  long int D.12370;
  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.12332>; else goto <D.12333>;
      <D.12332>:
      SetLastError (123);
      D.12334 = 0;
      return D.12334;
      <D.12333>:
      utf8_src = mono_unicode_to_external (name);
      if (utf8_src == 0B) goto <D.12335>; else goto <D.12336>;
      <D.12335>:
      SetLastError (87);
      D.12334 = 0;
      return D.12334;
      <D.12336>:
      if (dest_name == 0B) goto <D.12337>; else goto <D.12338>;
      <D.12337>:
      monoeg_g_free (utf8_src);
      SetLastError (123);
      D.12334 = 0;
      return D.12334;
      <D.12338>:
      utf8_dest = mono_unicode_to_external (dest_name);
      if (utf8_dest == 0B) goto <D.12339>; else goto <D.12340>;
      <D.12339>:
      SetLastError (87);
      monoeg_g_free (utf8_src);
      D.12334 = 0;
      return D.12334;
      <D.12340>:
      src_fd = _wapi_open (utf8_src, 0, 0);
      if (src_fd < 0) goto <D.12341>; else goto <D.12342>;
      <D.12341>:
      _wapi_set_last_path_error_from_errno (0B, utf8_src);
      monoeg_g_free (utf8_src);
      monoeg_g_free (utf8_dest);
      D.12334 = 0;
      return D.12334;
      <D.12342>:
      D.12343 = fstat (src_fd, &st);
      if (D.12343 < 0) goto <D.12344>; else goto <D.12345>;
      <D.12344>:
      _wapi_set_last_error_from_errno ();
      monoeg_g_free (utf8_src);
      monoeg_g_free (utf8_dest);
      close (src_fd);
      D.12334 = 0;
      return D.12334;
      <D.12345>:
      D.12346 = _wapi_stat (utf8_dest, &dest_st);
      if (D.12346 == 0) goto <D.12347>; else goto <D.12348>;
      <D.12347>:
      D.12349 = st.st_dev;
      D.12350 = dest_st.st_dev;
      if (D.12349 == D.12350) goto <D.12351>; else goto <D.12352>;
      <D.12351>:
      D.12353 = st.st_ino;
      D.12354 = dest_st.st_ino;
      if (D.12353 == D.12354) goto <D.12355>; else goto <D.12356>;
      <D.12355>:
      monoeg_g_free (utf8_src);
      monoeg_g_free (utf8_dest);
      close (src_fd);
      SetLastError (32);
      D.12334 = 0;
      return D.12334;
      <D.12356>:
      <D.12352>:
      <D.12348>:
      if (fail_if_exists != 0) goto <D.12357>; else goto <D.12358>;
      <D.12357>:
      D.12359 = st.st_mode;
      dest_fd = _wapi_open (utf8_dest, 193, D.12359);
      goto <D.12360>;
      <D.12358>:
      D.12359 = st.st_mode;
      dest_fd = _wapi_open (utf8_dest, 513, D.12359);
      if (dest_fd < 0) goto <D.12361>; else goto <D.12362>;
      <D.12361>:
      D.12359 = st.st_mode;
      dest_fd = _wapi_open (utf8_dest, 577, D.12359);
      goto <D.12363>;
      <D.12362>:
      SetLastError (183);
      <D.12363>:
      <D.12360>:
      if (dest_fd < 0) goto <D.12364>; else goto <D.12365>;
      <D.12364>:
      _wapi_set_last_error_from_errno ();
      monoeg_g_free (utf8_src);
      monoeg_g_free (utf8_dest);
      close (src_fd);
      D.12334 = 0;
      return D.12334;
      <D.12365>:
      D.12366 = write_file (src_fd, dest_fd, &st, 1);
      if (D.12366 == 0) goto <D.12367>; else goto <D.12368>;
      <D.12367>:
      ret = 0;
      <D.12368>:
      close (src_fd);
      close (dest_fd);
      D.12369 = st.st_mtim.tv_sec;
      dest_time.modtime = D.12369;
      D.12370 = st.st_atim.tv_sec;
      dest_time.actime = D.12370;
      ret_utime = utime (utf8_dest, &dest_time);
      if (ret_utime == -1) goto <D.12371>; else goto <D.12372>;
      <D.12371>:
      <D.12372>:
      monoeg_g_free (utf8_src);
      monoeg_g_free (utf8_dest);
      D.12334 = ret;
      return D.12334;
    }
  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.12375;
  int iftmp.14;
  long unsigned int D.12380;
  long int D.12381;
  int * D.12384;
  int D.12385;
  int D.12388;
  gboolean D.12393;
  long unsigned int D.12395;
  long int D.12396;
  int D.12401;
  sizetype D.12406;
  int remain;
  int n;
  char * buf;
  char * wbuf;
  int buf_size;

  D.12375 = st_src->st_blksize;
  buf_size = (int) D.12375;
  if (buf_size > 8191) goto <D.12377>; else goto <D.12378>;
  <D.12377>:
  iftmp.14 = MIN_EXPR <buf_size, 65536>;
  goto <D.12379>;
  <D.12378>:
  iftmp.14 = 8192;
  <D.12379>:
  buf_size = iftmp.14;
  D.12380 = (long unsigned int) buf_size;
  buf = malloc (D.12380);
  <D.11629>:
  D.12380 = (long unsigned int) buf_size;
  D.12381 = read (src_fd, buf, D.12380);
  remain = (int) D.12381;
  if (remain < 0) goto <D.12382>; else goto <D.12383>;
  <D.12382>:
  D.12384 = __errno_location ();
  D.12385 = *D.12384;
  if (D.12385 == 4) goto <D.12386>; else goto <D.12387>;
  <D.12386>:
  D.12388 = _wapi_thread_cur_apc_pending ();
  if (D.12388 == 0) goto <D.12389>; else goto <D.12390>;
  <D.12389>:
  // predicted unlikely by continue predictor.
  goto <D.11624>;
  <D.12390>:
  <D.12387>:
  if (report_errors != 0) goto <D.12391>; else goto <D.12392>;
  <D.12391>:
  _wapi_set_last_error_from_errno ();
  <D.12392>:
  free (buf);
  D.12393 = 0;
  return D.12393;
  <D.12383>:
  if (remain == 0) goto <D.11625>; else goto <D.12394>;
  <D.12394>:
  wbuf = buf;
  goto <D.11626>;
  <D.11627>:
  D.12395 = (long unsigned int) remain;
  D.12396 = write (dest_fd, wbuf, D.12395);
  n = (int) D.12396;
  if (n < 0) goto <D.12397>; else goto <D.12398>;
  <D.12397>:
  D.12384 = __errno_location ();
  D.12385 = *D.12384;
  if (D.12385 == 4) goto <D.12399>; else goto <D.12400>;
  <D.12399>:
  D.12401 = _wapi_thread_cur_apc_pending ();
  if (D.12401 == 0) goto <D.12402>; else goto <D.12403>;
  <D.12402>:
  // predicted unlikely by continue predictor.
  goto <D.11626>;
  <D.12403>:
  <D.12400>:
  if (report_errors != 0) goto <D.12404>; else goto <D.12405>;
  <D.12404>:
  _wapi_set_last_error_from_errno ();
  <D.12405>:
  free (buf);
  D.12393 = 0;
  return D.12393;
  <D.12398>:
  remain = remain - n;
  D.12406 = (sizetype) n;
  wbuf = wbuf + D.12406;
  <D.11626>:
  if (remain > 0) goto <D.11627>; else goto <D.11628>;
  <D.11628>:
  <D.11624>:
  goto <D.11629>;
  <D.11625>:
  free (buf);
  D.12393 = 1;
  return D.12393;
}


read (int __fd, void * __buf, size_t __nbytes)
{
  long unsigned int D.12408;
  int D.12411;
  ssize_t D.12414;
  long unsigned int D.12415;
  long unsigned int D.12416;
  long unsigned int D.12419;

  D.12408 = __builtin_object_size (__buf, 0);
  if (D.12408 != 18446744073709551615) goto <D.12409>; else goto <D.12410>;
  <D.12409>:
  D.12411 = __builtin_constant_p (__nbytes);
  if (D.12411 == 0) goto <D.12412>; else goto <D.12413>;
  <D.12412>:
  D.12415 = __builtin_object_size (__buf, 0);
  D.12414 = __read_chk (__fd, __buf, __nbytes, D.12415);
  return D.12414;
  <D.12413>:
  D.12416 = __builtin_object_size (__buf, 0);
  if (D.12416 < __nbytes) goto <D.12417>; else goto <D.12418>;
  <D.12417>:
  D.12419 = __builtin_object_size (__buf, 0);
  D.12414 = __read_chk_warn (__fd, __buf, __nbytes, D.12419);
  return D.12414;
  <D.12418>:
  <D.12410>:
  D.12414 = __read_alias (__fd, __buf, __nbytes);
  return D.12414;
}


ReplaceFile (const gunichar2 * replacedFileName, const gunichar2 * replacementFileName, const gunichar2 * backupFileName, guint32 replaceFlags, void * exclude, void * reserved)
{
  gboolean D.12423;
  int * D.12430;
  int D.12436;
  unsigned int D.12439;
  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.12421>; else goto <D.12422>;
      <D.12421>:
      D.12423 = 0;
      return D.12423;
      <D.12422>:
      utf8_replacementFileName = convert_arg_to_utf8 (replacementFileName, "replacementFileName");
      if (utf8_replacementFileName == 0B) goto replace_cleanup; else goto <D.12424>;
      <D.12424>:
      if (backupFileName != 0B) goto <D.12425>; else goto <D.12426>;
      <D.12425>:
      utf8_backupFileName = convert_arg_to_utf8 (backupFileName, "backupFileName");
      if (utf8_backupFileName == 0B) goto replace_cleanup; else goto <D.12427>;
      <D.12427>:
      <D.12426>:
      if (utf8_backupFileName != 0B) goto <D.12428>; else goto <D.12429>;
      <D.12428>:
      backup_fd = _wapi_open (utf8_backupFileName, 0, 0);
      result = _wapi_rename (utf8_replacedFileName, utf8_backupFileName);
      D.12430 = __errno_location ();
      errno_copy = *D.12430;
      if (result == -1) goto replace_cleanup; else goto <D.12431>;
      <D.12431>:
      <D.12429>:
      result = _wapi_rename (utf8_replacementFileName, utf8_replacedFileName);
      D.12430 = __errno_location ();
      errno_copy = *D.12430;
      if (result == -1) goto <D.12432>; else goto <D.12433>;
      <D.12432>:
      _wapi_set_last_path_error_from_errno (0B, utf8_replacementFileName);
      _wapi_rename (utf8_backupFileName, utf8_replacedFileName);
      if (backup_fd != -1) goto <D.12434>; else goto <D.12435>;
      <D.12434>:
      D.12436 = fstat (backup_fd, &stBackup);
      if (D.12436 == 0) goto <D.12437>; else goto <D.12438>;
      <D.12437>:
      D.12439 = stBackup.st_mode;
      replaced_fd = _wapi_open (utf8_backupFileName, 577, D.12439);
      if (replaced_fd == -1) goto replace_cleanup; else goto <D.12440>;
      <D.12440>:
      write_file (backup_fd, replaced_fd, &stBackup, 0);
      <D.12438>:
      <D.12435>:
      goto replace_cleanup;
      <D.12433>:
      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.12441>; else goto <D.12442>;
      <D.12441>:
      close (backup_fd);
      <D.12442>:
      if (replaced_fd != -1) goto <D.12443>; else goto <D.12444>;
      <D.12443>:
      close (replaced_fd);
      <D.12444>:
      D.12423 = ret;
      return D.12423;
    }
  finally
    {
      stBackup = {CLOBBER};
    }
}


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

  if (arg == 0B) goto <D.12447>; else goto <D.12448>;
  <D.12447>:
  SetLastError (123);
  D.12449 = 0B;
  return D.12449;
  <D.12448>:
  utf8_ret = mono_unicode_to_external (arg);
  if (utf8_ret == 0B) goto <D.12450>; else goto <D.12451>;
  <D.12450>:
  SetLastError (87);
  D.12449 = 0B;
  return D.12449;
  <D.12451>:
  D.12449 = utf8_ret;
  return D.12449;
}


GetStdHandle (WapiStdHandle stdhandle)
{
  void * D.12453;
  long int D.12454;
  long int D.12455;
  long int D.12456;
  _Bool D.12459;
  long int D.12460;
  long int D.12461;
  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.11681>, case -12: <D.11680>, case -11: <D.11679>, case -10: <D.11677>>
      <D.11677>:
      fd = 0;
      name = "<stdin>";
      goto <D.11678>;
      <D.11679>:
      fd = 1;
      name = "<stdout>";
      goto <D.11678>;
      <D.11680>:
      fd = 2;
      name = "<stderr>";
      goto <D.11678>;
      <D.11681>:
      SetLastError (87);
      D.12453 = -1B;
      return D.12453;
      <D.11678>:
      D.12454 = (long int) fd;
      handle = (void *) D.12454;
      {
        struct __pthread_unwind_buf_t __cancel_buf;
        void (*<Tc2>) (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.12455 = (long int) __not_first_call;
            D.12456 = __builtin_expect (D.12455, 0);
            if (D.12456 != 0) goto <D.12457>; else goto <D.12458>;
            <D.12457>:
            __cancel_routine (__cancel_arg);
            __pthread_unwind_next (&__cancel_buf);
            <D.12458>:
            __pthread_register_cancel (&__cancel_buf);
            thr_ret = pthread_mutex_lock (&stdhandle_mutex);
            D.12459 = thr_ret != 0;
            D.12460 = (long int) D.12459;
            D.12461 = __builtin_expect (D.12460, 0);
            if (D.12461 != 0) goto <D.12462>; else goto <D.12463>;
            <D.12462>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "io.c", 2187, "thr_ret == 0");
            <D.12463>:
            ok = _wapi_lookup_handle (handle, 2, &file_handle);
            if (ok == 0) goto <D.12464>; else goto <D.12465>;
            <D.12464>:
            handle = _wapi_stdhandle_create (fd, name);
            if (handle == -1B) goto <D.12466>; else goto <D.12467>;
            <D.12466>:
            SetLastError (18);
            goto done;
            <D.12467>:
            goto <D.12468>;
            <D.12465>:
            _wapi_handle_ref (handle);
            <D.12468>:
            done:
            thr_ret = pthread_mutex_unlock (&stdhandle_mutex);
            D.12459 = thr_ret != 0;
            D.12460 = (long int) D.12459;
            D.12461 = __builtin_expect (D.12460, 0);
            if (D.12461 != 0) goto <D.12469>; else goto <D.12470>;
            <D.12469>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "io.c", 2206, "thr_ret == 0");
            <D.12470>:
            __pthread_unregister_cancel (&__cancel_buf);
            if (0 != 0) goto <D.12471>; else goto <D.12472>;
            <D.12471>:
            __cancel_routine (__cancel_arg);
            <D.12472>:
          }
        finally
          {
            __cancel_buf = {CLOBBER};
          }
      }
      D.12453 = handle;
      return D.12453;
    }
  finally
    {
      file_handle = {CLOBBER};
    }
}


mono_mutex_unlock_in_cleanup (union mono_mutex_t * mutex)
{
  int D.12479;

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


ReadFile (void * handle, void * buffer, guint32 numbytes, guint32 * bytesread, struct WapiOverlapped * overlapped)
{
  gboolean (*<T1b0b>) (void *, void *, guint32, guint32 *, struct WapiOverlapped *) D.12481;
  gboolean D.12484;
  WapiHandleType type;

  type = _wapi_handle_type (handle);
  D.12481 = io_ops[type].readfile;
  if (D.12481 == 0B) goto <D.12482>; else goto <D.12483>;
  <D.12482>:
  SetLastError (6);
  D.12484 = 0;
  return D.12484;
  <D.12483>:
  D.12481 = io_ops[type].readfile;
  D.12484 = D.12481 (handle, buffer, numbytes, bytesread, overlapped);
  return D.12484;
}


pipe_write (void * handle, const void * buffer, guint32 numbytes, guint32 * byteswritten, struct WapiOverlapped * overlapped)
{
  gboolean D.12488;
  struct _WapiHandle_file * pipe_handle.15;
  unsigned int D.12492;
  unsigned int D.12493;
  long unsigned int D.12496;
  long int D.12497;
  int * D.12499;
  int D.12500;
  int D.12502;
  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.12486>; else goto <D.12487>;
      <D.12486>:
      monoeg_g_log (0B, 16, "%s: error looking up pipe handle %p", &__func__, handle);
      SetLastError (6);
      D.12488 = 0;
      return D.12488;
      <D.12487>:
      pipe_handle.15 = pipe_handle;
      fd = pipe_handle.15->fd;
      if (byteswritten != 0B) goto <D.12490>; else goto <D.12491>;
      <D.12490>:
      *byteswritten = 0;
      <D.12491>:
      pipe_handle.15 = pipe_handle;
      D.12492 = BIT_FIELD_REF <*pipe_handle.15, 32, 192>;
      D.12493 = D.12492 & 1342177280;
      if (D.12493 == 0) goto <D.12494>; else goto <D.12495>;
      <D.12494>:
      SetLastError (5);
      D.12488 = 0;
      return D.12488;
      <D.12495>:
      <D.11529>:
      D.12496 = (long unsigned int) numbytes;
      D.12497 = write (fd, buffer, D.12496);
      ret = (int) D.12497;
      if (ret == -1) goto <D.12498>; else goto <D.11530>;
      <D.12498>:
      D.12499 = __errno_location ();
      D.12500 = *D.12499;
      if (D.12500 == 4) goto <D.12501>; else goto <D.11530>;
      <D.12501>:
      D.12502 = _wapi_thread_cur_apc_pending ();
      if (D.12502 == 0) goto <D.11529>; else goto <D.11530>;
      <D.11530>:
      if (ret == -1) goto <D.12503>; else goto <D.12504>;
      <D.12503>:
      D.12499 = __errno_location ();
      D.12500 = *D.12499;
      if (D.12500 == 4) goto <D.12505>; else goto <D.12506>;
      <D.12505>:
      ret = 0;
      goto <D.12507>;
      <D.12506>:
      _wapi_set_last_error_from_errno ();
      D.12488 = 0;
      return D.12488;
      <D.12507>:
      <D.12504>:
      if (byteswritten != 0B) goto <D.12508>; else goto <D.12509>;
      <D.12508>:
      ret.16 = (unsigned int) ret;
      *byteswritten = ret.16;
      <D.12509>:
      D.12488 = 1;
      return D.12488;
    }
  finally
    {
      pipe_handle = {CLOBBER};
    }
}


pipe_read (void * handle, void * buffer, guint32 numbytes, guint32 * bytesread, struct WapiOverlapped * overlapped)
{
  gboolean D.12515;
  struct _WapiHandle_file * pipe_handle.17;
  unsigned int D.12519;
  signed int D.12520;
  unsigned int D.12523;
  long unsigned int D.12526;
  long int D.12527;
  int * D.12529;
  int D.12530;
  int D.12532;
  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.12513>; else goto <D.12514>;
      <D.12513>:
      monoeg_g_log (0B, 16, "%s: error looking up pipe handle %p", &__func__, handle);
      SetLastError (6);
      D.12515 = 0;
      return D.12515;
      <D.12514>:
      pipe_handle.17 = pipe_handle;
      fd = pipe_handle.17->fd;
      if (bytesread != 0B) goto <D.12517>; else goto <D.12518>;
      <D.12517>:
      *bytesread = 0;
      <D.12518>:
      pipe_handle.17 = pipe_handle;
      D.12519 = pipe_handle.17->fileaccess;
      D.12520 = (signed int) D.12519;
      if (D.12520 >= 0) goto <D.12521>; else goto <D.12522>;
      <D.12521>:
      pipe_handle.17 = pipe_handle;
      D.12519 = pipe_handle.17->fileaccess;
      D.12523 = D.12519 & 268435456;
      if (D.12523 == 0) goto <D.12524>; else goto <D.12525>;
      <D.12524>:
      SetLastError (5);
      D.12515 = 0;
      return D.12515;
      <D.12525>:
      <D.12522>:
      <D.11515>:
      D.12526 = (long unsigned int) numbytes;
      D.12527 = read (fd, buffer, D.12526);
      ret = (int) D.12527;
      if (ret == -1) goto <D.12528>; else goto <D.11516>;
      <D.12528>:
      D.12529 = __errno_location ();
      D.12530 = *D.12529;
      if (D.12530 == 4) goto <D.12531>; else goto <D.11516>;
      <D.12531>:
      D.12532 = _wapi_thread_cur_apc_pending ();
      if (D.12532 == 0) goto <D.11515>; else goto <D.11516>;
      <D.11516>:
      if (ret == -1) goto <D.12533>; else goto <D.12534>;
      <D.12533>:
      D.12529 = __errno_location ();
      D.12530 = *D.12529;
      if (D.12530 == 4) goto <D.12535>; else goto <D.12536>;
      <D.12535>:
      ret = 0;
      goto <D.12537>;
      <D.12536>:
      _wapi_set_last_error_from_errno ();
      D.12515 = 0;
      return D.12515;
      <D.12537>:
      <D.12534>:
      if (bytesread != 0B) goto <D.12538>; else goto <D.12539>;
      <D.12538>:
      ret.18 = (unsigned int) ret;
      *bytesread = ret.18;
      <D.12539>:
      D.12515 = 1;
      return D.12515;
    }
  finally
    {
      pipe_handle = {CLOBBER};
    }
}


pipe_getfiletype ()
{
  WapiFileType D.12543;

  D.12543 = 3;
  return D.12543;
}


console_write (void * handle, const void * buffer, guint32 numbytes, guint32 * byteswritten, struct WapiOverlapped * overlapped)
{
  gboolean D.12547;
  struct _WapiHandle_file * console_handle.19;
  unsigned int D.12551;
  unsigned int D.12552;
  long unsigned int D.12555;
  long int D.12556;
  int * D.12558;
  int D.12559;
  int D.12561;
  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.12545>; else goto <D.12546>;
      <D.12545>:
      monoeg_g_log (0B, 16, "%s: error looking up console handle %p", &__func__, handle);
      SetLastError (6);
      D.12547 = 0;
      return D.12547;
      <D.12546>:
      console_handle.19 = console_handle;
      fd = console_handle.19->fd;
      if (byteswritten != 0B) goto <D.12549>; else goto <D.12550>;
      <D.12549>:
      *byteswritten = 0;
      <D.12550>:
      console_handle.19 = console_handle;
      D.12551 = BIT_FIELD_REF <*console_handle.19, 32, 192>;
      D.12552 = D.12551 & 1342177280;
      if (D.12552 == 0) goto <D.12553>; else goto <D.12554>;
      <D.12553>:
      SetLastError (5);
      D.12547 = 0;
      return D.12547;
      <D.12554>:
      <D.11492>:
      D.12555 = (long unsigned int) numbytes;
      D.12556 = write (fd, buffer, D.12555);
      ret = (int) D.12556;
      if (ret == -1) goto <D.12557>; else goto <D.11493>;
      <D.12557>:
      D.12558 = __errno_location ();
      D.12559 = *D.12558;
      if (D.12559 == 4) goto <D.12560>; else goto <D.11493>;
      <D.12560>:
      D.12561 = _wapi_thread_cur_apc_pending ();
      if (D.12561 == 0) goto <D.11492>; else goto <D.11493>;
      <D.11493>:
      if (ret == -1) goto <D.12562>; else goto <D.12563>;
      <D.12562>:
      D.12558 = __errno_location ();
      D.12559 = *D.12558;
      if (D.12559 == 4) goto <D.12564>; else goto <D.12565>;
      <D.12564>:
      ret = 0;
      goto <D.12566>;
      <D.12565>:
      _wapi_set_last_error_from_errno ();
      D.12547 = 0;
      return D.12547;
      <D.12566>:
      <D.12563>:
      if (byteswritten != 0B) goto <D.12567>; else goto <D.12568>;
      <D.12567>:
      ret.20 = (unsigned int) ret;
      *byteswritten = ret.20;
      <D.12568>:
      D.12547 = 1;
      return D.12547;
    }
  finally
    {
      console_handle = {CLOBBER};
    }
}


console_read (void * handle, void * buffer, guint32 numbytes, guint32 * bytesread, struct WapiOverlapped * overlapped)
{
  gboolean D.12574;
  struct _WapiHandle_file * console_handle.21;
  unsigned int D.12578;
  signed int D.12579;
  unsigned int D.12582;
  long unsigned int D.12585;
  long int D.12586;
  int * D.12588;
  int D.12589;
  int D.12591;
  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.12572>; else goto <D.12573>;
      <D.12572>:
      monoeg_g_log (0B, 16, "%s: error looking up console handle %p", &__func__, handle);
      SetLastError (6);
      D.12574 = 0;
      return D.12574;
      <D.12573>:
      console_handle.21 = console_handle;
      fd = console_handle.21->fd;
      if (bytesread != 0B) goto <D.12576>; else goto <D.12577>;
      <D.12576>:
      *bytesread = 0;
      <D.12577>:
      console_handle.21 = console_handle;
      D.12578 = console_handle.21->fileaccess;
      D.12579 = (signed int) D.12578;
      if (D.12579 >= 0) goto <D.12580>; else goto <D.12581>;
      <D.12580>:
      console_handle.21 = console_handle;
      D.12578 = console_handle.21->fileaccess;
      D.12582 = D.12578 & 268435456;
      if (D.12582 == 0) goto <D.12583>; else goto <D.12584>;
      <D.12583>:
      SetLastError (5);
      D.12574 = 0;
      return D.12574;
      <D.12584>:
      <D.12581>:
      <D.11478>:
      D.12585 = (long unsigned int) numbytes;
      D.12586 = read (fd, buffer, D.12585);
      ret = (int) D.12586;
      if (ret == -1) goto <D.12587>; else goto <D.11479>;
      <D.12587>:
      D.12588 = __errno_location ();
      D.12589 = *D.12588;
      if (D.12589 == 4) goto <D.12590>; else goto <D.11479>;
      <D.12590>:
      D.12591 = _wapi_thread_cur_apc_pending ();
      if (D.12591 == 0) goto <D.11478>; else goto <D.11479>;
      <D.11479>:
      if (ret == -1) goto <D.12592>; else goto <D.12593>;
      <D.12592>:
      _wapi_set_last_error_from_errno ();
      D.12574 = 0;
      return D.12574;
      <D.12593>:
      if (bytesread != 0B) goto <D.12594>; else goto <D.12595>;
      <D.12594>:
      ret.22 = (unsigned int) ret;
      *bytesread = ret.22;
      <D.12595>:
      D.12574 = 1;
      return D.12574;
    }
  finally
    {
      console_handle = {CLOBBER};
    }
}


console_getfiletype ()
{
  WapiFileType D.12599;

  D.12599 = 2;
  return D.12599;
}


file_setfiletime (void * handle, const struct WapiFileTime * create_time, const struct WapiFileTime * last_access, const struct WapiFileTime * last_write)
{
  gboolean D.12603;
  struct _WapiHandle_file * file_handle.23;
  unsigned int D.12605;
  unsigned int D.12606;
  gchar * D.12609;
  unsigned int D.12616;
  long unsigned int D.12617;
  long unsigned int D.12618;
  unsigned int D.12619;
  long unsigned int D.12620;
  long long unsigned int D.12623;
  long long unsigned int D.12624;
  long int D.12625;
  long int D.12627;
  unsigned int D.12630;
  long unsigned int D.12631;
  long unsigned int D.12632;
  unsigned int D.12633;
  long unsigned int D.12634;
  long long unsigned int D.12637;
  long long unsigned int D.12638;
  long int D.12639;
  long int D.12641;
  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.12601>; else goto <D.12602>;
      <D.12601>:
      monoeg_g_log (0B, 16, "%s: error looking up file handle %p", &__func__, handle);
      SetLastError (6);
      D.12603 = 0;
      return D.12603;
      <D.12602>:
      file_handle.23 = file_handle;
      fd = file_handle.23->fd;
      file_handle.23 = file_handle;
      D.12605 = BIT_FIELD_REF <*file_handle.23, 32, 192>;
      D.12606 = D.12605 & 1342177280;
      if (D.12606 == 0) goto <D.12607>; else goto <D.12608>;
      <D.12607>:
      SetLastError (5);
      D.12603 = 0;
      return D.12603;
      <D.12608>:
      file_handle.23 = file_handle;
      D.12609 = file_handle.23->filename;
      if (D.12609 == 0B) goto <D.12610>; else goto <D.12611>;
      <D.12610>:
      SetLastError (6);
      D.12603 = 0;
      return D.12603;
      <D.12611>:
      ret = fstat (fd, &statbuf);
      if (ret == -1) goto <D.12612>; else goto <D.12613>;
      <D.12612>:
      SetLastError (87);
      D.12603 = 0;
      return D.12603;
      <D.12613>:
      if (last_access != 0B) goto <D.12614>; else goto <D.12615>;
      <D.12614>:
      D.12616 = last_access->dwHighDateTime;
      D.12617 = (long unsigned int) D.12616;
      D.12618 = D.12617 << 32;
      D.12619 = last_access->dwLowDateTime;
      D.12620 = (long unsigned int) D.12619;
      access_ticks = D.12618 + D.12620;
      if (access_ticks <= 116444735999999999) goto <D.12621>; else goto <D.12622>;
      <D.12621>:
      SetLastError (87);
      D.12603 = 0;
      return D.12603;
      <D.12622>:
      D.12623 = access_ticks + 18330299337709551616;
      D.12624 = D.12623 / 10000000;
      D.12625 = (long int) D.12624;
      utbuf.actime = D.12625;
      goto <D.12626>;
      <D.12615>:
      D.12627 = statbuf.st_atim.tv_sec;
      utbuf.actime = D.12627;
      <D.12626>:
      if (last_write != 0B) goto <D.12628>; else goto <D.12629>;
      <D.12628>:
      D.12630 = last_write->dwHighDateTime;
      D.12631 = (long unsigned int) D.12630;
      D.12632 = D.12631 << 32;
      D.12633 = last_write->dwLowDateTime;
      D.12634 = (long unsigned int) D.12633;
      write_ticks = D.12632 + D.12634;
      if (write_ticks <= 116444735999999999) goto <D.12635>; else goto <D.12636>;
      <D.12635>:
      SetLastError (87);
      D.12603 = 0;
      return D.12603;
      <D.12636>:
      D.12637 = write_ticks + 18330299337709551616;
      D.12638 = D.12637 / 10000000;
      D.12639 = (long int) D.12638;
      utbuf.modtime = D.12639;
      goto <D.12640>;
      <D.12629>:
      D.12641 = statbuf.st_mtim.tv_sec;
      utbuf.modtime = D.12641;
      <D.12640>:
      file_handle.23 = file_handle;
      D.12609 = file_handle.23->filename;
      ret = _wapi_utime (D.12609, &utbuf);
      if (ret == -1) goto <D.12642>; else goto <D.12643>;
      <D.12642>:
      SetLastError (87);
      D.12603 = 0;
      return D.12603;
      <D.12643>:
      D.12603 = 1;
      return D.12603;
    }
  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.12648;
  struct _WapiHandle_file * file_handle.24;
  unsigned int D.12650;
  signed int D.12651;
  unsigned int D.12654;
  long int D.12659;
  long int D.12660;
  long unsigned int D.12663;
  long unsigned int D.12664;
  long unsigned int D.12666;
  long unsigned int D.12667;
  long int D.12668;
  long unsigned int D.12669;
  long unsigned int D.12670;
  unsigned int D.12673;
  long unsigned int D.12674;
  unsigned int D.12675;
  unsigned int D.12678;
  long unsigned int D.12679;
  unsigned int D.12680;
  unsigned int D.12683;
  long unsigned int D.12684;
  unsigned int D.12685;
  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.12646>; else goto <D.12647>;
      <D.12646>:
      monoeg_g_log (0B, 16, "%s: error looking up file handle %p", &__func__, handle);
      SetLastError (6);
      D.12648 = 0;
      return D.12648;
      <D.12647>:
      file_handle.24 = file_handle;
      fd = file_handle.24->fd;
      file_handle.24 = file_handle;
      D.12650 = file_handle.24->fileaccess;
      D.12651 = (signed int) D.12650;
      if (D.12651 >= 0) goto <D.12652>; else goto <D.12653>;
      <D.12652>:
      file_handle.24 = file_handle;
      D.12650 = file_handle.24->fileaccess;
      D.12654 = D.12650 & 268435456;
      if (D.12654 == 0) goto <D.12655>; else goto <D.12656>;
      <D.12655>:
      SetLastError (5);
      D.12648 = 0;
      return D.12648;
      <D.12656>:
      <D.12653>:
      ret = fstat (fd, &statbuf);
      if (ret == -1) goto <D.12657>; else goto <D.12658>;
      <D.12657>:
      _wapi_set_last_error_from_errno ();
      D.12648 = 0;
      return D.12648;
      <D.12658>:
      D.12659 = statbuf.st_atim.tv_sec;
      D.12660 = statbuf.st_ctim.tv_sec;
      if (D.12659 < D.12660) goto <D.12661>; else goto <D.12662>;
      <D.12661>:
      D.12659 = statbuf.st_atim.tv_sec;
      D.12663 = (long unsigned int) D.12659;
      D.12664 = D.12663 * 10000000;
      create_ticks = D.12664 + 116444736000000000;
      goto <D.12665>;
      <D.12662>:
      D.12660 = statbuf.st_ctim.tv_sec;
      D.12666 = (long unsigned int) D.12660;
      D.12667 = D.12666 * 10000000;
      create_ticks = D.12667 + 116444736000000000;
      <D.12665>:
      D.12659 = statbuf.st_atim.tv_sec;
      D.12663 = (long unsigned int) D.12659;
      D.12664 = D.12663 * 10000000;
      access_ticks = D.12664 + 116444736000000000;
      D.12668 = statbuf.st_mtim.tv_sec;
      D.12669 = (long unsigned int) D.12668;
      D.12670 = D.12669 * 10000000;
      write_ticks = D.12670 + 116444736000000000;
      if (create_time != 0B) goto <D.12671>; else goto <D.12672>;
      <D.12671>:
      D.12673 = (unsigned int) create_ticks;
      create_time->dwLowDateTime = D.12673;
      D.12674 = create_ticks >> 32;
      D.12675 = (unsigned int) D.12674;
      create_time->dwHighDateTime = D.12675;
      <D.12672>:
      if (last_access != 0B) goto <D.12676>; else goto <D.12677>;
      <D.12676>:
      D.12678 = (unsigned int) access_ticks;
      last_access->dwLowDateTime = D.12678;
      D.12679 = access_ticks >> 32;
      D.12680 = (unsigned int) D.12679;
      last_access->dwHighDateTime = D.12680;
      <D.12677>:
      if (last_write != 0B) goto <D.12681>; else goto <D.12682>;
      <D.12681>:
      D.12683 = (unsigned int) write_ticks;
      last_write->dwLowDateTime = D.12683;
      D.12684 = write_ticks >> 32;
      D.12685 = (unsigned int) D.12684;
      last_write->dwHighDateTime = D.12685;
      <D.12682>:
      D.12648 = 1;
      return D.12648;
    }
  finally
    {
      file_handle = {CLOBBER};
      statbuf = {CLOBBER};
    }
}


file_getfilesize (void * handle, guint32 * highsize)
{
  guint32 D.12690;
  struct _WapiHandle_file * file_handle.25;
  unsigned int D.12692;
  signed int D.12693;
  unsigned int D.12696;
  unsigned int D.12697;
  unsigned int D.12702;
  unsigned int D.12703;
  int D.12706;
  long unsigned int bigsize.26;
  long unsigned int D.12712;
  unsigned int D.12713;
  long int D.12714;
  long int D.12717;
  unsigned int D.12718;
  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.12688>; else goto <D.12689>;
      <D.12688>:
      monoeg_g_log (0B, 16, "%s: error looking up file handle %p", &__func__, handle);
      SetLastError (6);
      D.12690 = 4294967295;
      return D.12690;
      <D.12689>:
      file_handle.25 = file_handle;
      fd = file_handle.25->fd;
      file_handle.25 = file_handle;
      D.12692 = file_handle.25->fileaccess;
      D.12693 = (signed int) D.12692;
      if (D.12693 >= 0) goto <D.12694>; else goto <D.12695>;
      <D.12694>:
      file_handle.25 = file_handle;
      D.12696 = BIT_FIELD_REF <*file_handle.25, 32, 192>;
      D.12697 = D.12696 & 1342177280;
      if (D.12697 == 0) goto <D.12698>; else goto <D.12699>;
      <D.12698>:
      SetLastError (5);
      D.12690 = 4294967295;
      return D.12690;
      <D.12699>:
      <D.12695>:
      SetLastError (0);
      ret = fstat (fd, &statbuf);
      if (ret == -1) goto <D.12700>; else goto <D.12701>;
      <D.12700>:
      _wapi_set_last_error_from_errno ();
      D.12690 = 4294967295;
      return D.12690;
      <D.12701>:
      D.12702 = statbuf.st_mode;
      D.12703 = D.12702 & 61440;
      if (D.12703 == 24576) goto <D.12704>; else goto <D.12705>;
      <D.12704>:
      {
        guint64 bigsize;

        try
          {
            D.12706 = ioctl (fd, 2148012658, &bigsize);
            if (D.12706 < 0) goto <D.12707>; else goto <D.12708>;
            <D.12707>:
            _wapi_set_last_error_from_errno ();
            D.12690 = 4294967295;
            return D.12690;
            <D.12708>:
            bigsize.26 = bigsize;
            size = (guint32) bigsize.26;
            if (highsize != 0B) goto <D.12710>; else goto <D.12711>;
            <D.12710>:
            bigsize.26 = bigsize;
            D.12712 = bigsize.26 >> 32;
            D.12713 = (unsigned int) D.12712;
            *highsize = D.12713;
            <D.12711>:
            D.12690 = size;
            return D.12690;
          }
        finally
          {
            bigsize = {CLOBBER};
          }
      }
      <D.12705>:
      D.12714 = statbuf.st_size;
      size = (guint32) D.12714;
      if (highsize != 0B) goto <D.12715>; else goto <D.12716>;
      <D.12715>:
      D.12714 = statbuf.st_size;
      D.12717 = D.12714 >> 32;
      D.12718 = (unsigned int) D.12717;
      *highsize = D.12718;
      <D.12716>:
      D.12690 = size;
      return D.12690;
    }
  finally
    {
      file_handle = {CLOBBER};
      statbuf = {CLOBBER};
    }
}


file_setendoffile (void * handle)
{
  gboolean D.12724;
  struct _WapiHandle_file * file_handle.27;
  unsigned int D.12726;
  unsigned int D.12727;
  int * D.12735;
  int D.12736;
  int D.12738;
  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.12722>; else goto <D.12723>;
      <D.12722>:
      monoeg_g_log (0B, 16, "%s: error looking up file handle %p", &__func__, handle);
      SetLastError (6);
      D.12724 = 0;
      return D.12724;
      <D.12723>:
      file_handle.27 = file_handle;
      fd = file_handle.27->fd;
      file_handle.27 = file_handle;
      D.12726 = BIT_FIELD_REF <*file_handle.27, 32, 192>;
      D.12727 = D.12726 & 1342177280;
      if (D.12727 == 0) goto <D.12728>; else goto <D.12729>;
      <D.12728>:
      SetLastError (5);
      D.12724 = 0;
      return D.12724;
      <D.12729>:
      ret = fstat (fd, &statbuf);
      if (ret == -1) goto <D.12730>; else goto <D.12731>;
      <D.12730>:
      _wapi_set_last_error_from_errno ();
      D.12724 = 0;
      return D.12724;
      <D.12731>:
      size = statbuf.st_size;
      pos = lseek (fd, 0, 1);
      if (pos == -1) goto <D.12732>; else goto <D.12733>;
      <D.12732>:
      _wapi_set_last_error_from_errno ();
      D.12724 = 0;
      return D.12724;
      <D.12733>:
      <D.11413>:
      ret = ftruncate (fd, pos);
      if (ret == -1) goto <D.12734>; else goto <D.11414>;
      <D.12734>:
      D.12735 = __errno_location ();
      D.12736 = *D.12735;
      if (D.12736 == 4) goto <D.12737>; else goto <D.11414>;
      <D.12737>:
      D.12738 = _wapi_thread_cur_apc_pending ();
      if (D.12738 == 0) goto <D.11413>; else goto <D.11414>;
      <D.11414>:
      if (ret == -1) goto <D.12739>; else goto <D.12740>;
      <D.12739>:
      _wapi_set_last_error_from_errno ();
      D.12724 = 0;
      return D.12724;
      <D.12740>:
      D.12724 = 1;
      return D.12724;
    }
  finally
    {
      file_handle = {CLOBBER};
      statbuf = {CLOBBER};
    }
}


file_seek (void * handle, gint32 movedistance, gint32 * highmovedistance, WapiSeekMethod method)
{
  guint32 D.12745;
  struct _WapiHandle_file * file_handle.28;
  unsigned int D.12747;
  signed int D.12748;
  unsigned int D.12751;
  unsigned int D.12752;
  int D.12758;
  long int D.12759;
  long int D.12760;
  unsigned int movedistance.29;
  long int D.12762;
  long int D.12767;
  int D.12768;
  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.12743>; else goto <D.12744>;
      <D.12743>:
      monoeg_g_log (0B, 16, "%s: error looking up file handle %p", &__func__, handle);
      SetLastError (6);
      D.12745 = 4294967295;
      return D.12745;
      <D.12744>:
      file_handle.28 = file_handle;
      fd = file_handle.28->fd;
      file_handle.28 = file_handle;
      D.12747 = file_handle.28->fileaccess;
      D.12748 = (signed int) D.12747;
      if (D.12748 >= 0) goto <D.12749>; else goto <D.12750>;
      <D.12749>:
      file_handle.28 = file_handle;
      D.12751 = BIT_FIELD_REF <*file_handle.28, 32, 192>;
      D.12752 = D.12751 & 1342177280;
      if (D.12752 == 0) goto <D.12753>; else goto <D.12754>;
      <D.12753>:
      SetLastError (5);
      D.12745 = 4294967295;
      return D.12745;
      <D.12754>:
      <D.12750>:
      switch (method) <default: <D.11401>, case 0: <D.11397>, case 1: <D.11399>, case 2: <D.11400>>
      <D.11397>:
      whence = 0;
      goto <D.11398>;
      <D.11399>:
      whence = 1;
      goto <D.11398>;
      <D.11400>:
      whence = 2;
      goto <D.11398>;
      <D.11401>:
      SetLastError (87);
      D.12745 = 4294967295;
      return D.12745;
      <D.11398>:
      if (highmovedistance == 0B) goto <D.12755>; else goto <D.12756>;
      <D.12755>:
      offset = (gint64) movedistance;
      goto <D.12757>;
      <D.12756>:
      D.12758 = *highmovedistance;
      D.12759 = (long int) D.12758;
      D.12760 = D.12759 << 32;
      movedistance.29 = (unsigned int) movedistance;
      D.12762 = (long int) movedistance.29;
      offset = D.12760 | D.12762;
      <D.12757>:
      newpos = lseek (fd, offset, whence);
      if (newpos == -1) goto <D.12763>; else goto <D.12764>;
      <D.12763>:
      _wapi_set_last_error_from_errno ();
      D.12745 = 4294967295;
      return D.12745;
      <D.12764>:
      ret = (guint32) newpos;
      if (highmovedistance != 0B) goto <D.12765>; else goto <D.12766>;
      <D.12765>:
      D.12767 = newpos >> 32;
      D.12768 = (int) D.12767;
      *highmovedistance = D.12768;
      <D.12766>:
      D.12745 = ret;
      return D.12745;
    }
  finally
    {
      file_handle = {CLOBBER};
    }
}


file_flush (void * handle)
{
  gboolean D.12773;
  struct _WapiHandle_file * file_handle.30;
  unsigned int D.12775;
  unsigned int D.12776;
  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.12771>; else goto <D.12772>;
      <D.12771>:
      monoeg_g_log (0B, 16, "%s: error looking up file handle %p", &__func__, handle);
      SetLastError (6);
      D.12773 = 0;
      return D.12773;
      <D.12772>:
      file_handle.30 = file_handle;
      fd = file_handle.30->fd;
      file_handle.30 = file_handle;
      D.12775 = BIT_FIELD_REF <*file_handle.30, 32, 192>;
      D.12776 = D.12775 & 1342177280;
      if (D.12776 == 0) goto <D.12777>; else goto <D.12778>;
      <D.12777>:
      SetLastError (5);
      D.12773 = 0;
      return D.12773;
      <D.12778>:
      ret = fsync (fd);
      if (ret == -1) goto <D.12779>; else goto <D.12780>;
      <D.12779>:
      _wapi_set_last_error_from_errno ();
      D.12773 = 0;
      return D.12773;
      <D.12780>:
      D.12773 = 1;
      return D.12773;
    }
  finally
    {
      file_handle = {CLOBBER};
    }
}


file_write (void * handle, const void * buffer, guint32 numbytes, guint32 * byteswritten, struct WapiOverlapped * overlapped)
{
  gboolean D.12785;
  struct _WapiHandle_file * file_handle.31;
  unsigned int D.12789;
  unsigned int D.12790;
  int lock_while_writing.32;
  long int D.12798;
  int D.12799;
  long unsigned int D.12802;
  long int D.12803;
  int * D.12805;
  int D.12806;
  int D.12808;
  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.12783>; else goto <D.12784>;
      <D.12783>:
      monoeg_g_log (0B, 16, "%s: error looking up file handle %p", &__func__, handle);
      SetLastError (6);
      D.12785 = 0;
      return D.12785;
      <D.12784>:
      file_handle.31 = file_handle;
      fd = file_handle.31->fd;
      if (byteswritten != 0B) goto <D.12787>; else goto <D.12788>;
      <D.12787>:
      *byteswritten = 0;
      <D.12788>:
      file_handle.31 = file_handle;
      D.12789 = BIT_FIELD_REF <*file_handle.31, 32, 192>;
      D.12790 = D.12789 & 1342177280;
      if (D.12790 == 0) goto <D.12791>; else goto <D.12792>;
      <D.12791>:
      SetLastError (5);
      D.12785 = 0;
      return D.12785;
      <D.12792>:
      lock_while_writing.32 = lock_while_writing;
      if (lock_while_writing.32 != 0) goto <D.12794>; else goto <D.12795>;
      <D.12794>:
      current_pos = lseek (fd, 0, 1);
      if (current_pos == -1) goto <D.12796>; else goto <D.12797>;
      <D.12796>:
      _wapi_set_last_error_from_errno ();
      D.12785 = 0;
      return D.12785;
      <D.12797>:
      D.12798 = (long int) numbytes;
      D.12799 = _wapi_lock_file_region (fd, current_pos, D.12798);
      if (D.12799 == 0) goto <D.12800>; else goto <D.12801>;
      <D.12800>:
      D.12785 = 0;
      return D.12785;
      <D.12801>:
      <D.12795>:
      <D.11373>:
      D.12802 = (long unsigned int) numbytes;
      D.12803 = write (fd, buffer, D.12802);
      ret = (int) D.12803;
      if (ret == -1) goto <D.12804>; else goto <D.11374>;
      <D.12804>:
      D.12805 = __errno_location ();
      D.12806 = *D.12805;
      if (D.12806 == 4) goto <D.12807>; else goto <D.11374>;
      <D.12807>:
      D.12808 = _wapi_thread_cur_apc_pending ();
      if (D.12808 == 0) goto <D.11373>; else goto <D.11374>;
      <D.11374>:
      lock_while_writing.32 = lock_while_writing;
      if (lock_while_writing.32 != 0) goto <D.12809>; else goto <D.12810>;
      <D.12809>:
      D.12798 = (long int) numbytes;
      _wapi_unlock_file_region (fd, current_pos, D.12798);
      <D.12810>:
      if (ret == -1) goto <D.12811>; else goto <D.12812>;
      <D.12811>:
      D.12805 = __errno_location ();
      D.12806 = *D.12805;
      if (D.12806 == 4) goto <D.12813>; else goto <D.12814>;
      <D.12813>:
      ret = 0;
      goto <D.12815>;
      <D.12814>:
      _wapi_set_last_error_from_errno ();
      D.12785 = 0;
      return D.12785;
      <D.12815>:
      <D.12812>:
      if (byteswritten != 0B) goto <D.12816>; else goto <D.12817>;
      <D.12816>:
      ret.33 = (unsigned int) ret;
      *byteswritten = ret.33;
      <D.12817>:
      D.12785 = 1;
      return D.12785;
    }
  finally
    {
      file_handle = {CLOBBER};
    }
}


file_read (void * handle, void * buffer, guint32 numbytes, guint32 * bytesread, struct WapiOverlapped * overlapped)
{
  gboolean D.12823;
  struct _WapiHandle_file * file_handle.34;
  unsigned int D.12827;
  signed int D.12828;
  unsigned int D.12831;
  long unsigned int D.12834;
  long int D.12835;
  int * D.12837;
  int D.12838;
  int D.12840;
  int D.12843;
  unsigned int D.12844;
  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.12821>; else goto <D.12822>;
      <D.12821>:
      monoeg_g_log (0B, 16, "%s: error looking up file handle %p", &__func__, handle);
      SetLastError (6);
      D.12823 = 0;
      return D.12823;
      <D.12822>:
      file_handle.34 = file_handle;
      fd = file_handle.34->fd;
      if (bytesread != 0B) goto <D.12825>; else goto <D.12826>;
      <D.12825>:
      *bytesread = 0;
      <D.12826>:
      file_handle.34 = file_handle;
      D.12827 = file_handle.34->fileaccess;
      D.12828 = (signed int) D.12827;
      if (D.12828 >= 0) goto <D.12829>; else goto <D.12830>;
      <D.12829>:
      file_handle.34 = file_handle;
      D.12827 = file_handle.34->fileaccess;
      D.12831 = D.12827 & 268435456;
      if (D.12831 == 0) goto <D.12832>; else goto <D.12833>;
      <D.12832>:
      SetLastError (5);
      D.12823 = 0;
      return D.12823;
      <D.12833>:
      <D.12830>:
      <D.11357>:
      D.12834 = (long unsigned int) numbytes;
      D.12835 = read (fd, buffer, D.12834);
      ret = (int) D.12835;
      if (ret == -1) goto <D.12836>; else goto <D.11358>;
      <D.12836>:
      D.12837 = __errno_location ();
      D.12838 = *D.12837;
      if (D.12838 == 4) goto <D.12839>; else goto <D.11358>;
      <D.12839>:
      D.12840 = _wapi_thread_cur_apc_pending ();
      if (D.12840 == 0) goto <D.11357>; else goto <D.11358>;
      <D.11358>:
      if (ret == -1) goto <D.12841>; else goto <D.12842>;
      <D.12841>:
      {
        gint err;

        D.12837 = __errno_location ();
        err = *D.12837;
        D.12843 = _wapi_get_win32_file_error (err);
        D.12844 = (unsigned int) D.12843;
        SetLastError (D.12844);
        D.12823 = 0;
        return D.12823;
      }
      <D.12842>:
      if (bytesread != 0B) goto <D.12845>; else goto <D.12846>;
      <D.12845>:
      ret.35 = (unsigned int) ret;
      *bytesread = ret.35;
      <D.12846>:
      D.12823 = 1;
      return D.12823;
    }
  finally
    {
      file_handle = {CLOBBER};
    }
}


file_getfiletype ()
{
  WapiFileType D.12850;

  D.12850 = 1;
  return D.12850;
}


_wapi_handle_type (void * handle)
{
  long int handle.36;
  unsigned int D.12856;
  struct _WapiHandleUnshared * D.12857;
  WapiHandleType D.12858;
  unsigned int D.12859;
  struct _WapiHandleUnshared * D.12860;
  long unsigned int D.12861;
  long unsigned int D.12862;
  long unsigned int D.12863;
  struct _WapiHandleUnshared * D.12864;
  guint32 idx;

  handle.36 = (long int) handle;
  idx = (guint32) handle.36;
  if (idx > 4194303) goto <D.12853>; else goto <D.12855>;
  <D.12855>:
  D.12856 = idx / 256;
  D.12857 = _wapi_private_handles[D.12856];
  if (D.12857 == 0B) goto <D.12853>; else goto <D.12854>;
  <D.12853>:
  D.12858 = 0;
  return D.12858;
  <D.12854>:
  D.12859 = idx / 256;
  D.12860 = _wapi_private_handles[D.12859];
  D.12861 = (long unsigned int) idx;
  D.12862 = D.12861 & 255;
  D.12863 = D.12862 * 200;
  D.12864 = D.12860 + D.12863;
  D.12858 = D.12864->type;
  return D.12858;
}


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

  type = _wapi_handle_type (handle);
  D.12866 = io_ops[type].writefile;
  if (D.12866 == 0B) goto <D.12867>; else goto <D.12868>;
  <D.12867>:
  SetLastError (6);
  D.12869 = 0;
  return D.12869;
  <D.12868>:
  D.12866 = io_ops[type].writefile;
  D.12869 = D.12866 (handle, buffer, numbytes, byteswritten, overlapped);
  return D.12869;
}


FlushFileBuffers (void * handle)
{
  gboolean (*<T184e>) (void *) D.12871;
  gboolean D.12874;
  WapiHandleType type;

  type = _wapi_handle_type (handle);
  D.12871 = io_ops[type].flushfile;
  if (D.12871 == 0B) goto <D.12872>; else goto <D.12873>;
  <D.12872>:
  SetLastError (6);
  D.12874 = 0;
  return D.12874;
  <D.12873>:
  D.12871 = io_ops[type].flushfile;
  D.12874 = D.12871 (handle);
  return D.12874;
}


SetEndOfFile (void * handle)
{
  gboolean (*<T184e>) (void *) D.12876;
  gboolean D.12879;
  WapiHandleType type;

  type = _wapi_handle_type (handle);
  D.12876 = io_ops[type].setendoffile;
  if (D.12876 == 0B) goto <D.12877>; else goto <D.12878>;
  <D.12877>:
  SetLastError (6);
  D.12879 = 0;
  return D.12879;
  <D.12878>:
  D.12876 = io_ops[type].setendoffile;
  D.12879 = D.12876 (handle);
  return D.12879;
}


SetFilePointer (void * handle, gint32 movedistance, gint32 * highmovedistance, WapiSeekMethod method)
{
  guint32 (*<T1b15>) (void *, gint32, gint32 *, WapiSeekMethod) D.12881;
  guint32 D.12884;
  WapiHandleType type;

  type = _wapi_handle_type (handle);
  D.12881 = io_ops[type].seek;
  if (D.12881 == 0B) goto <D.12882>; else goto <D.12883>;
  <D.12882>:
  SetLastError (6);
  D.12884 = 4294967295;
  return D.12884;
  <D.12883>:
  D.12881 = io_ops[type].seek;
  D.12884 = D.12881 (handle, movedistance, highmovedistance, method);
  return D.12884;
}


GetFileType (void * handle)
{
  long int handle.37;
  unsigned int D.12889;
  unsigned int D.12891;
  struct _WapiHandleUnshared * D.12892;
  WapiFileType D.12893;
  WapiFileType (*<T1b07>) (void) D.12894;
  WapiHandleType type;

  handle.37 = (long int) handle;
  D.12889 = (unsigned int) handle.37;
  if (D.12889 > 268435455) goto <D.12886>; else goto <D.12890>;
  <D.12890>:
  handle.37 = (long int) handle;
  D.12889 = (unsigned int) handle.37;
  D.12891 = D.12889 / 256;
  D.12892 = _wapi_private_handles[D.12891];
  if (D.12892 == 0B) goto <D.12886>; else goto <D.12887>;
  <D.12886>:
  SetLastError (6);
  D.12893 = 0;
  return D.12893;
  <D.12887>:
  type = _wapi_handle_type (handle);
  D.12894 = io_ops[type].getfiletype;
  if (D.12894 == 0B) goto <D.12895>; else goto <D.12896>;
  <D.12895>:
  SetLastError (6);
  D.12893 = 0;
  return D.12893;
  <D.12896>:
  D.12894 = io_ops[type].getfiletype;
  D.12893 = D.12894 ();
  return D.12893;
}


GetFileSize (void * handle, guint32 * highsize)
{
  guint32 (*<T1b1b>) (void *, guint32 *) D.12898;
  guint32 D.12901;
  WapiHandleType type;

  type = _wapi_handle_type (handle);
  D.12898 = io_ops[type].getfilesize;
  if (D.12898 == 0B) goto <D.12899>; else goto <D.12900>;
  <D.12899>:
  SetLastError (6);
  D.12901 = 4294967295;
  return D.12901;
  <D.12900>:
  D.12898 = io_ops[type].getfilesize;
  D.12901 = D.12898 (handle, highsize);
  return D.12901;
}


GetFileTime (void * handle, struct WapiFileTime * create_time, struct WapiFileTime * last_access, struct WapiFileTime * last_write)
{
  gboolean (*<T1b1f>) (void *, struct WapiFileTime *, struct WapiFileTime *, struct WapiFileTime *) D.12903;
  gboolean D.12906;
  WapiHandleType type;

  type = _wapi_handle_type (handle);
  D.12903 = io_ops[type].getfiletime;
  if (D.12903 == 0B) goto <D.12904>; else goto <D.12905>;
  <D.12904>:
  SetLastError (6);
  D.12906 = 0;
  return D.12906;
  <D.12905>:
  D.12903 = io_ops[type].getfiletime;
  D.12906 = D.12903 (handle, create_time, last_access, last_write);
  return D.12906;
}


SetFileTime (void * handle, const struct WapiFileTime * create_time, const struct WapiFileTime * last_access, const struct WapiFileTime * last_write)
{
  gboolean (*<T1b23>) (void *, const struct WapiFileTime *, const struct WapiFileTime *, const struct WapiFileTime *) D.12908;
  gboolean D.12911;
  WapiHandleType type;

  type = _wapi_handle_type (handle);
  D.12908 = io_ops[type].setfiletime;
  if (D.12908 == 0B) goto <D.12909>; else goto <D.12910>;
  <D.12909>:
  SetLastError (6);
  D.12911 = 0;
  return D.12911;
  <D.12910>:
  D.12908 = io_ops[type].setfiletime;
  D.12911 = D.12908 (handle, create_time, last_access, last_write);
  return D.12911;
}


FileTimeToSystemTime (const struct WapiFileTime * file_time, struct WapiSystemTime * system_time)
{
  gboolean D.12915;
  unsigned int D.12916;
  long int D.12917;
  long int D.12918;
  unsigned int D.12919;
  long int D.12920;
  long long int D.12923;
  short unsigned int D.12924;
  long int D.12925;
  short unsigned int D.12926;
  long int D.12927;
  short unsigned int D.12928;
  long int D.12929;
  short unsigned int D.12930;
  long int D.12931;
  long int D.12932;
  short unsigned int D.12933;
  short unsigned int D.12934;
  long int D.12935;
  long int D.12936;
  long int D.12937;
  _Bool D.12938;
  long int D.12939;
  long int D.12940;
  long int D.12941;
  long int D.12942;
  _Bool D.12943;
  long int D.12944;
  long int D.12945;
  long int D.12946;
  _Bool D.12947;
  long int D.12948;
  long int D.12949;
  long int D.12950;
  long int D.12951;
  long int D.12952;
  long int D.12953;
  _Bool D.12954;
  long int D.12955;
  long int D.12956;
  long int D.12957;
  long int D.12958;
  long int D.12959;
  long int D.12960;
  _Bool D.12961;
  long int D.12962;
  long int D.12963;
  long int D.12964;
  _Bool D.12965;
  long int D.12966;
  long int D.12967;
  long int D.12968;
  long int D.12969;
  long int D.12970;
  long int D.12971;
  _Bool D.12972;
  long int D.12973;
  long int D.12974;
  long int D.12975;
  long int D.12976;
  long int D.12977;
  long int D.12978;
  long int D.12979;
  long int D.12980;
  long int D.12981;
  long int D.12982;
  long int D.12983;
  long int D.12984;
  long int D.12985;
  long int D.12986;
  long int D.12987;
  gint64 iftmp.38;
  unsigned long y.39;
  unsigned long D.12994;
  long int D.12996;
  long int D.12998;
  short unsigned int D.12999;
  int iftmp.40;
  long unsigned int y.41;
  long unsigned int D.13007;
  const guint16 * D.13008;
  short unsigned int D.13009;
  long int D.13010;
  short unsigned int D.13011;
  short unsigned int D.13012;
  short unsigned int D.13013;
  gint64 file_ticks;
  gint64 totaldays;
  gint64 rem;
  gint64 y;
  const guint16 * ip;
  static const char __func__[21] = "FileTimeToSystemTime";

  if (system_time == 0B) goto <D.12913>; else goto <D.12914>;
  <D.12913>:
  SetLastError (87);
  D.12915 = 0;
  return D.12915;
  <D.12914>:
  D.12916 = file_time->dwHighDateTime;
  D.12917 = (long int) D.12916;
  D.12918 = D.12917 << 32;
  D.12919 = file_time->dwLowDateTime;
  D.12920 = (long int) D.12919;
  file_ticks = D.12918 + D.12920;
  if (file_ticks < 0) goto <D.12921>; else goto <D.12922>;
  <D.12921>:
  SetLastError (87);
  D.12915 = 0;
  return D.12915;
  <D.12922>:
  totaldays = file_ticks / 864000000000;
  rem = file_ticks % 864000000000;
  D.12923 = rem / 36000000000;
  D.12924 = (short unsigned int) D.12923;
  system_time->wHour = D.12924;
  rem = rem % 36000000000;
  D.12925 = rem / 600000000;
  D.12926 = (short unsigned int) D.12925;
  system_time->wMinute = D.12926;
  rem = rem % 600000000;
  D.12927 = rem / 10000000;
  D.12928 = (short unsigned int) D.12927;
  system_time->wSecond = D.12928;
  rem = rem % 10000000;
  D.12929 = rem / 10000;
  D.12930 = (short unsigned int) D.12929;
  system_time->wMilliseconds = D.12930;
  D.12931 = totaldays + 1;
  D.12932 = D.12931 % 7;
  D.12933 = (short unsigned int) D.12932;
  D.12934 = D.12933 + 1;
  system_time->wDayOfWeek = D.12934;
  y = 1601;
  goto <D.11756>;
  <D.11755>:
  {
    gint64 yg;

    D.12935 = totaldays / 365;
    D.12936 = D.12935 + y;
    D.12937 = totaldays % 365;
    D.12938 = D.12937 < 0;
    D.12939 = (long int) D.12938;
    yg = D.12936 - D.12939;
    D.12940 = y + -1;
    D.12941 = D.12940 / 4;
    D.12940 = y + -1;
    D.12942 = D.12940 % 4;
    D.12943 = D.12942 < 0;
    D.12944 = (long int) D.12943;
    D.12945 = D.12941 - D.12944;
    D.12940 = y + -1;
    D.12946 = D.12940 % 100;
    D.12947 = D.12946 < 0;
    D.12948 = (long int) D.12947;
    D.12940 = y + -1;
    D.12949 = D.12940 / -100;
    D.12950 = D.12948 + D.12949;
    D.12951 = D.12945 + D.12950;
    D.12940 = y + -1;
    D.12952 = D.12940 / 400;
    D.12940 = y + -1;
    D.12953 = D.12940 % 400;
    D.12954 = D.12953 < 0;
    D.12955 = (long int) D.12954;
    D.12956 = D.12952 - D.12955;
    D.12957 = D.12951 + D.12956;
    D.12958 = yg + -1;
    D.12959 = D.12958 / 4;
    D.12958 = yg + -1;
    D.12960 = D.12958 % 4;
    D.12961 = D.12960 < 0;
    D.12962 = (long int) D.12961;
    D.12963 = D.12959 - D.12962;
    D.12958 = yg + -1;
    D.12964 = D.12958 % 100;
    D.12965 = D.12964 < 0;
    D.12966 = (long int) D.12965;
    D.12958 = yg + -1;
    D.12967 = D.12958 / -100;
    D.12968 = D.12966 + D.12967;
    D.12969 = D.12963 + D.12968;
    D.12958 = yg + -1;
    D.12970 = D.12958 / 400;
    D.12958 = yg + -1;
    D.12971 = D.12958 % 400;
    D.12972 = D.12971 < 0;
    D.12973 = (long int) D.12972;
    D.12974 = D.12970 - D.12973;
    D.12975 = D.12969 + D.12974;
    monoeg_g_log (0B, 32, "%s: LEAPS(yg): %lld LEAPS(y): %lld", &__func__, D.12975, D.12957);
    D.12940 = y + -1;
    D.12941 = D.12940 / 4;
    D.12940 = y + -1;
    D.12942 = D.12940 % 4;
    D.12943 = D.12942 < 0;
    D.12944 = (long int) D.12943;
    D.12945 = D.12941 - D.12944;
    D.12940 = y + -1;
    D.12946 = D.12940 % 100;
    D.12947 = D.12946 < 0;
    D.12948 = (long int) D.12947;
    D.12940 = y + -1;
    D.12949 = D.12940 / -100;
    D.12950 = D.12948 + D.12949;
    D.12951 = D.12945 + D.12950;
    D.12940 = y + -1;
    D.12952 = D.12940 / 400;
    D.12940 = y + -1;
    D.12953 = D.12940 % 400;
    D.12954 = D.12953 < 0;
    D.12955 = (long int) D.12954;
    D.12956 = D.12952 - D.12955;
    D.12957 = D.12951 + D.12956;
    D.12958 = yg + -1;
    D.12971 = D.12958 % 400;
    D.12972 = D.12971 < 0;
    D.12973 = (long int) D.12972;
    D.12958 = yg + -1;
    D.12976 = D.12958 / -400;
    D.12977 = D.12973 + D.12976;
    D.12958 = yg + -1;
    D.12978 = D.12958 / 100;
    D.12958 = yg + -1;
    D.12964 = D.12958 % 100;
    D.12965 = D.12964 < 0;
    D.12966 = (long int) D.12965;
    D.12979 = D.12978 - D.12966;
    D.12958 = yg + -1;
    D.12960 = D.12958 % 4;
    D.12961 = D.12960 < 0;
    D.12962 = (long int) D.12961;
    D.12958 = yg + -1;
    D.12980 = D.12958 / -4;
    D.12981 = D.12962 + D.12980;
    D.12982 = D.12979 + D.12981;
    D.12983 = D.12977 + D.12982;
    D.12984 = y - yg;
    D.12985 = D.12984 * 365;
    D.12986 = D.12983 + D.12985;
    D.12987 = D.12957 + D.12986;
    totaldays = D.12987 + totaldays;
    y = yg;
  }
  <D.11756>:
  if (totaldays < 0) goto <D.11755>; else goto <D.12988>;
  <D.12988>:
  y.39 = (unsigned long) y;
  D.12994 = y.39 & 3;
  if (D.12994 == 0) goto <D.12995>; else goto <D.12990>;
  <D.12995>:
  D.12996 = y % 100;
  if (D.12996 != 0) goto <D.12991>; else goto <D.12997>;
  <D.12997>:
  D.12998 = y % 400;
  if (D.12998 == 0) goto <D.12991>; else goto <D.12990>;
  <D.12991>:
  iftmp.38 = 366;
  goto <D.12992>;
  <D.12990>:
  iftmp.38 = 365;
  <D.12992>:
  if (iftmp.38 <= totaldays) goto <D.11755>; else goto <D.11757>;
  <D.11757>:
  D.12999 = (short unsigned int) y;
  system_time->wYear = D.12999;
  y.39 = (unsigned long) y;
  D.12994 = y.39 & 3;
  if (D.12994 == 0) goto <D.13004>; else goto <D.13001>;
  <D.13004>:
  D.12996 = y % 100;
  if (D.12996 != 0) goto <D.13002>; else goto <D.13005>;
  <D.13005>:
  D.12998 = y % 400;
  if (D.12998 == 0) goto <D.13002>; else goto <D.13001>;
  <D.13002>:
  iftmp.40 = 1;
  goto <D.13003>;
  <D.13001>:
  iftmp.40 = 0;
  <D.13003>:
  ip = &mon_yday[iftmp.40];
  y = 11;
  goto <D.11760>;
  <D.11759>:
  // predicted unlikely by continue predictor.
  goto <D.11758>;
  <D.11758>:
  y = y + -1;
  <D.11760>:
  y.41 = (long unsigned int) y;
  D.13007 = y.41 * 2;
  D.13008 = ip + D.13007;
  D.13009 = *D.13008;
  D.13010 = (long int) D.13009;
  if (D.13010 > totaldays) goto <D.11759>; else goto <D.11761>;
  <D.11761>:
  y.41 = (long unsigned int) y;
  D.13007 = y.41 * 2;
  D.13008 = ip + D.13007;
  D.13009 = *D.13008;
  D.13010 = (long int) D.13009;
  totaldays = totaldays - D.13010;
  D.12999 = (short unsigned int) y;
  D.13011 = D.12999 + 1;
  system_time->wMonth = D.13011;
  D.13012 = (short unsigned int) totaldays;
  D.13013 = D.13012 + 1;
  system_time->wDay = D.13013;
  D.12915 = 1;
  return D.12915;
}


FindFirstFile (const gunichar2 * pattern, struct WapiFindData * find_data)
{
  void * D.13017;
  int D.13028;
  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.13015>; else goto <D.13016>;
      <D.13015>:
      SetLastError (3);
      D.13017 = -1B;
      return D.13017;
      <D.13016>:
      utf8_pattern = mono_unicode_to_external (pattern);
      if (utf8_pattern == 0B) goto <D.13018>; else goto <D.13019>;
      <D.13018>:
      SetLastError (123);
      D.13017 = -1B;
      return D.13017;
      <D.13019>:
      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.13020>; else goto <D.13021>;
      <D.13020>:
      SetLastError (2);
      monoeg_g_free (utf8_pattern);
      monoeg_g_free (entry_part);
      monoeg_g_free (dir_part);
      D.13017 = -1B;
      return D.13017;
      <D.13021>:
      if (result < 0) goto <D.13022>; else goto <D.13023>;
      <D.13022>:
      _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.13017 = -1B;
      return D.13017;
      <D.13023>:
      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.13024>; else goto <D.13025>;
      <D.13024>:
      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.13017 = -1B;
      return D.13017;
      <D.13025>:
      if (handle != -1B) goto <D.13026>; else goto <D.13027>;
      <D.13026>:
      D.13028 = FindNextFile (handle, find_data);
      if (D.13028 == 0) goto <D.13029>; else goto <D.13030>;
      <D.13029>:
      FindClose (handle);
      SetLastError (18);
      handle = -1B;
      <D.13030>:
      <D.13027>:
      D.13017 = handle;
      return D.13017;
    }
  finally
    {
      find_handle = {CLOBBER};
    }
}


FindNextFile (void * handle, struct WapiFindData * find_data)
{
  gboolean D.13035;
  long int D.13036;
  long int D.13037;
  _Bool D.13040;
  long int D.13041;
  long int D.13042;
  struct _WapiHandle_find * find_handle.42;
  long unsigned int D.13046;
  int D.13047;
  long unsigned int D.13048;
  gchar * * D.13051;
  long unsigned int D.13052;
  long unsigned int D.13053;
  long unsigned int D.13054;
  gchar * * D.13055;
  gchar * D.13056;
  gchar * D.13057;
  int * D.13060;
  int D.13061;
  long int D.13070;
  long int D.13071;
  unsigned int D.13075;
  struct WapiFileTime * D.13076;
  struct WapiFileTime * D.13077;
  long int D.13078;
  struct WapiFileTime * D.13079;
  unsigned int D.13080;
  unsigned int D.13081;
  long int D.13085;
  long int D.13086;
  unsigned int D.13087;
  unsigned int D.13088;
  long int bytes.43;
  long int bytes.44;
  gunichar2[260] * D.13093;
  long int D.13094;
  long unsigned int D.13095;
  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.13033>; else goto <D.13034>;
      <D.13033>:
      monoeg_g_log (0B, 16, "%s: error looking up find handle %p", &__func__, handle);
      SetLastError (6);
      D.13035 = 0;
      return D.13035;
      <D.13034>:
      {
        struct __pthread_unwind_buf_t __cancel_buf;
        void (*<Tc2>) (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.13036 = (long int) __not_first_call;
            D.13037 = __builtin_expect (D.13036, 0);
            if (D.13037 != 0) goto <D.13038>; else goto <D.13039>;
            <D.13038>:
            __cancel_routine (__cancel_arg);
            __pthread_unwind_next (&__cancel_buf);
            <D.13039>:
            __pthread_register_cancel (&__cancel_buf);
            thr_ret = _wapi_handle_lock_handle (handle);
            D.13040 = thr_ret != 0;
            D.13041 = (long int) D.13040;
            D.13042 = __builtin_expect (D.13041, 0);
            if (D.13042 != 0) goto <D.13043>; else goto <D.13044>;
            <D.13043>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "io.c", 2803, "thr_ret == 0");
            <D.13044>:
            retry:
            find_handle.42 = find_handle;
            D.13046 = find_handle.42->count;
            find_handle.42 = find_handle;
            D.13047 = find_handle.42->num;
            D.13048 = (long unsigned int) D.13047;
            if (D.13046 >= D.13048) goto <D.13049>; else goto <D.13050>;
            <D.13049>:
            SetLastError (18);
            goto cleanup;
            <D.13050>:
            find_handle.42 = find_handle;
            D.13051 = find_handle.42->namelist;
            find_handle.42 = find_handle;
            D.13046 = find_handle.42->count;
            D.13052 = D.13046;
            D.13053 = D.13052 + 1;
            find_handle.42->count = D.13053;
            D.13054 = D.13052 * 8;
            D.13055 = D.13051 + D.13054;
            D.13056 = *D.13055;
            find_handle.42 = find_handle;
            D.13057 = find_handle.42->dir_part;
            filename = monoeg_g_build_path ("/", D.13057, D.13056, 0B);
            result = _wapi_stat (filename, &buf);
            if (result == -1) goto <D.13058>; else goto <D.13059>;
            <D.13058>:
            D.13060 = __errno_location ();
            D.13061 = *D.13060;
            if (D.13061 == 2) goto <D.13062>; else goto <D.13063>;
            <D.13062>:
            result = _wapi_lstat (filename, &buf);
            <D.13063>:
            <D.13059>:
            if (result != 0) goto <D.13064>; else goto <D.13065>;
            <D.13064>:
            monoeg_g_free (filename);
            goto retry;
            <D.13065>:
            result = _wapi_lstat (filename, &linkbuf);
            if (result != 0) goto <D.13066>; else goto <D.13067>;
            <D.13066>:
            monoeg_g_free (filename);
            goto retry;
            <D.13067>:
            utf8_filename = mono_utf8_from_external (filename);
            if (utf8_filename == 0B) goto <D.13068>; else goto <D.13069>;
            <D.13068>:
            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.13069>:
            monoeg_g_free (filename);
            D.13070 = buf.st_mtim.tv_sec;
            D.13071 = buf.st_ctim.tv_sec;
            if (D.13070 < D.13071) goto <D.13072>; else goto <D.13073>;
            <D.13072>:
            create_time = buf.st_mtim.tv_sec;
            goto <D.13074>;
            <D.13073>:
            create_time = buf.st_ctim.tv_sec;
            <D.13074>:
            D.13075 = _wapi_stat_to_file_attributes (utf8_filename, &buf, &linkbuf);
            find_data->dwFileAttributes = D.13075;
            D.13076 = &find_data->ftCreationTime;
            _wapi_time_t_to_filetime (create_time, D.13076);
            D.13077 = &find_data->ftLastAccessTime;
            D.13078 = buf.st_atim.tv_sec;
            _wapi_time_t_to_filetime (D.13078, D.13077);
            D.13079 = &find_data->ftLastWriteTime;
            D.13070 = buf.st_mtim.tv_sec;
            _wapi_time_t_to_filetime (D.13070, D.13079);
            D.13080 = find_data->dwFileAttributes;
            D.13081 = D.13080 & 16;
            if (D.13081 != 0) goto <D.13082>; else goto <D.13083>;
            <D.13082>:
            find_data->nFileSizeHigh = 0;
            find_data->nFileSizeLow = 0;
            goto <D.13084>;
            <D.13083>:
            D.13085 = buf.st_size;
            D.13086 = D.13085 >> 32;
            D.13087 = (unsigned int) D.13086;
            find_data->nFileSizeHigh = D.13087;
            D.13085 = buf.st_size;
            D.13088 = (unsigned int) D.13085;
            find_data->nFileSizeLow = D.13088;
            <D.13084>:
            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.13089>; else goto <D.13090>;
            <D.13089>:
            monoeg_g_free (utf8_basename);
            monoeg_g_free (utf8_filename);
            goto retry;
            <D.13090>:
            ret = 1;
            bytes.43 = bytes;
            bytes.44 = bytes.43 * 2;
            bytes = bytes.44;
            D.13093 = &find_data->cFileName;
            memset (D.13093, 0, 520);
            bytes.43 = bytes;
            D.13094 = MIN_EXPR <bytes.43, 518>;
            D.13095 = (long unsigned int) D.13094;
            D.13093 = &find_data->cFileName;
            memcpy (D.13093, utf16_basename, D.13095);
            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.13040 = thr_ret != 0;
            D.13041 = (long int) D.13040;
            D.13042 = __builtin_expect (D.13041, 0);
            if (D.13042 != 0) goto <D.13096>; else goto <D.13097>;
            <D.13096>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "io.c", 2910, "thr_ret == 0");
            <D.13097>:
            __pthread_unregister_cancel (&__cancel_buf);
            if (0 != 0) goto <D.13098>; else goto <D.13099>;
            <D.13098>:
            __cancel_routine (__cancel_arg);
            <D.13099>:
          }
        finally
          {
            __cancel_buf = {CLOBBER};
          }
      }
      D.13035 = ret;
      return D.13035;
    }
  finally
    {
      find_handle = {CLOBBER};
      buf = {CLOBBER};
      linkbuf = {CLOBBER};
      bytes = {CLOBBER};
    }
}


_wapi_handle_lock_handle (void * handle)
{
  long int handle.45;
  int D.13116;
  <unnamed type> D.13119;
  <unnamed type> D.13121;
  <unnamed type> D.13123;
  <unnamed type> D.13125;
  unsigned int D.13126;
  struct _WapiHandleUnshared * D.13127;
  long unsigned int D.13128;
  long unsigned int D.13129;
  long unsigned int D.13130;
  struct _WapiHandleUnshared * D.13131;
  union mono_mutex_t * D.13132;
  guint32 idx;

  handle.45 = (long int) handle;
  idx = (guint32) handle.45;
  if (idx > 4194303) goto <D.13114>; else goto <D.13115>;
  <D.13114>:
  D.13116 = 0;
  return D.13116;
  <D.13115>:
  _wapi_handle_ref (handle);
  D.13119 = _wapi_handle_type (handle);
  if (D.13119 == 9) goto <D.13117>; else goto <D.13120>;
  <D.13120>:
  D.13121 = _wapi_handle_type (handle);
  if (D.13121 == 11) goto <D.13117>; else goto <D.13122>;
  <D.13122>:
  D.13123 = _wapi_handle_type (handle);
  if (D.13123 == 12) goto <D.13117>; else goto <D.13124>;
  <D.13124>:
  D.13125 = _wapi_handle_type (handle);
  if (D.13125 == 13) goto <D.13117>; else goto <D.13118>;
  <D.13117>:
  D.13116 = 0;
  return D.13116;
  <D.13118>:
  D.13126 = idx / 256;
  D.13127 = _wapi_private_handles[D.13126];
  D.13128 = (long unsigned int) idx;
  D.13129 = D.13128 & 255;
  D.13130 = D.13129 * 200;
  D.13131 = D.13127 + D.13130;
  D.13132 = &D.13131->signal_mutex;
  D.13116 = pthread_mutex_lock (D.13132);
  return D.13116;
}


_wapi_stat_to_file_attributes (const gchar * pathname, struct stat * buf, struct stat * lbuf)
{
  unsigned int D.13134;
  unsigned int D.13135;
  unsigned int D.13138;
  int D.13141;
  char D.13144;
  int D.13148;
  unsigned int D.13159;
  unsigned int D.13160;
  guint32 D.13163;
  guint32 attrs;
  gchar * filename;

  attrs = 0;
  D.13134 = buf->st_mode;
  D.13135 = D.13134 & 61440;
  if (D.13135 == 49152) goto <D.13136>; else goto <D.13137>;
  <D.13136>:
  D.13134 = buf->st_mode;
  D.13138 = D.13134 & 4294918143;
  buf->st_mode = D.13138;
  <D.13137>:
  filename = _wapi_basename (pathname);
  D.13134 = buf->st_mode;
  D.13135 = D.13134 & 61440;
  if (D.13135 == 16384) goto <D.13139>; else goto <D.13140>;
  <D.13139>:
  attrs = 16;
  D.13141 = is_file_writable (buf, pathname);
  if (D.13141 == 0) goto <D.13142>; else goto <D.13143>;
  <D.13142>:
  attrs = attrs | 1;
  <D.13143>:
  D.13144 = *filename;
  if (D.13144 == 46) goto <D.13145>; else goto <D.13146>;
  <D.13145>:
  attrs = attrs | 2;
  <D.13146>:
  goto <D.13147>;
  <D.13140>:
  D.13148 = is_file_writable (buf, pathname);
  if (D.13148 == 0) goto <D.13149>; else goto <D.13150>;
  <D.13149>:
  attrs = 1;
  D.13144 = *filename;
  if (D.13144 == 46) goto <D.13151>; else goto <D.13152>;
  <D.13151>:
  attrs = attrs | 2;
  <D.13152>:
  goto <D.13153>;
  <D.13150>:
  D.13144 = *filename;
  if (D.13144 == 46) goto <D.13154>; else goto <D.13155>;
  <D.13154>:
  attrs = 2;
  goto <D.13156>;
  <D.13155>:
  attrs = 128;
  <D.13156>:
  <D.13153>:
  <D.13147>:
  if (lbuf != 0B) goto <D.13157>; else goto <D.13158>;
  <D.13157>:
  D.13159 = lbuf->st_mode;
  D.13160 = D.13159 & 61440;
  if (D.13160 == 40960) goto <D.13161>; else goto <D.13162>;
  <D.13161>:
  attrs = attrs | 1024;
  <D.13162>:
  <D.13158>:
  monoeg_g_free (filename);
  D.13163 = attrs;
  return D.13163;
}


is_file_writable (struct stat * st, const char * path)
{
  unsigned int D.13165;
  unsigned int D.13166;
  gboolean D.13169;
  unsigned int D.13170;
  unsigned int D.13171;
  unsigned int D.13174;
  unsigned int D.13177;
  unsigned int D.13178;
  unsigned int D.13181;
  int D.13184;
  _Bool D.13185;

  D.13165 = st->st_mode;
  D.13166 = D.13165 & 2;
  if (D.13166 != 0) goto <D.13167>; else goto <D.13168>;
  <D.13167>:
  D.13169 = 1;
  return D.13169;
  <D.13168>:
  D.13170 = st->st_uid;
  D.13171 = geteuid ();
  if (D.13170 == D.13171) goto <D.13172>; else goto <D.13173>;
  <D.13172>:
  D.13165 = st->st_mode;
  D.13174 = D.13165 & 128;
  if (D.13174 != 0) goto <D.13175>; else goto <D.13176>;
  <D.13175>:
  D.13169 = 1;
  return D.13169;
  <D.13176>:
  <D.13173>:
  D.13177 = st->st_gid;
  D.13178 = getegid ();
  if (D.13177 == D.13178) goto <D.13179>; else goto <D.13180>;
  <D.13179>:
  D.13165 = st->st_mode;
  D.13181 = D.13165 & 16;
  if (D.13181 != 0) goto <D.13182>; else goto <D.13183>;
  <D.13182>:
  D.13169 = 1;
  return D.13169;
  <D.13183>:
  <D.13180>:
  D.13184 = access (path, 2);
  D.13185 = D.13184 == 0;
  D.13169 = (gboolean) D.13185;
  return D.13169;
}


memset (void * __dest, int __ch, size_t __len)
{
  int D.13189;
  int D.13194;
  void * D.13196;
  long unsigned int D.13197;

  D.13189 = __builtin_constant_p (__len);
  if (D.13189 != 0) goto <D.13190>; else goto <D.13191>;
  <D.13190>:
  if (__len == 0) goto <D.13192>; else goto <D.13193>;
  <D.13192>:
  D.13194 = __builtin_constant_p (__ch);
  if (D.13194 == 0) goto <D.13187>; else goto <D.13195>;
  <D.13195>:
  if (__ch != 0) goto <D.13187>; else goto <D.13188>;
  <D.13187>:
  __warn_memset_zero_len ();
  D.13196 = __dest;
  return D.13196;
  <D.13188>:
  <D.13193>:
  <D.13191>:
  D.13197 = __builtin_object_size (__dest, 0);
  D.13196 = __builtin___memset_chk (__dest, __ch, __len, D.13197);
  return D.13196;
}


memcpy (void * restrict __dest, const void * restrict __src, size_t __len)
{
  void * D.13199;
  long unsigned int D.13200;

  D.13200 = __builtin_object_size (__dest, 0);
  D.13199 = __builtin___memcpy_chk (__dest, __src, __len, D.13200);
  return D.13199;
}


_wapi_handle_unlock_handle (void * handle)
{
  long int handle.46;
  int D.13205;
  <unnamed type> D.13208;
  <unnamed type> D.13210;
  <unnamed type> D.13212;
  <unnamed type> D.13214;
  unsigned int D.13215;
  struct _WapiHandleUnshared * D.13216;
  long unsigned int D.13217;
  long unsigned int D.13218;
  long unsigned int D.13219;
  struct _WapiHandleUnshared * D.13220;
  union mono_mutex_t * D.13221;
  guint32 idx;
  int ret;

  handle.46 = (long int) handle;
  idx = (guint32) handle.46;
  if (idx > 4194303) goto <D.13203>; else goto <D.13204>;
  <D.13203>:
  D.13205 = 0;
  return D.13205;
  <D.13204>:
  D.13208 = _wapi_handle_type (handle);
  if (D.13208 == 9) goto <D.13206>; else goto <D.13209>;
  <D.13209>:
  D.13210 = _wapi_handle_type (handle);
  if (D.13210 == 11) goto <D.13206>; else goto <D.13211>;
  <D.13211>:
  D.13212 = _wapi_handle_type (handle);
  if (D.13212 == 12) goto <D.13206>; else goto <D.13213>;
  <D.13213>:
  D.13214 = _wapi_handle_type (handle);
  if (D.13214 == 13) goto <D.13206>; else goto <D.13207>;
  <D.13206>:
  _wapi_handle_unref (handle);
  D.13205 = 0;
  return D.13205;
  <D.13207>:
  D.13215 = idx / 256;
  D.13216 = _wapi_private_handles[D.13215];
  D.13217 = (long unsigned int) idx;
  D.13218 = D.13217 & 255;
  D.13219 = D.13218 * 200;
  D.13220 = D.13216 + D.13219;
  D.13221 = &D.13220->signal_mutex;
  ret = pthread_mutex_unlock (D.13221);
  _wapi_handle_unref (handle);
  D.13205 = ret;
  return D.13205;
}


FindClose (void * handle)
{
  gboolean D.13225;
  long int D.13228;
  long int D.13229;
  _Bool D.13232;
  long int D.13233;
  long int D.13234;
  struct _WapiHandle_find * find_handle.47;
  gchar * * D.13238;
  gchar * D.13239;
  struct _WapiHandle_find * find_handle;
  gboolean ok;
  int thr_ret;
  static const char __func__[10] = "FindClose";

  try
    {
      if (handle == 0B) goto <D.13223>; else goto <D.13224>;
      <D.13223>:
      SetLastError (6);
      D.13225 = 0;
      return D.13225;
      <D.13224>:
      ok = _wapi_lookup_handle (handle, 8, &find_handle);
      if (ok == 0) goto <D.13226>; else goto <D.13227>;
      <D.13226>:
      monoeg_g_log (0B, 16, "%s: error looking up find handle %p", &__func__, handle);
      SetLastError (6);
      D.13225 = 0;
      return D.13225;
      <D.13227>:
      {
        struct __pthread_unwind_buf_t __cancel_buf;
        void (*<Tc2>) (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.13228 = (long int) __not_first_call;
            D.13229 = __builtin_expect (D.13228, 0);
            if (D.13229 != 0) goto <D.13230>; else goto <D.13231>;
            <D.13230>:
            __cancel_routine (__cancel_arg);
            __pthread_unwind_next (&__cancel_buf);
            <D.13231>:
            __pthread_register_cancel (&__cancel_buf);
            thr_ret = _wapi_handle_lock_handle (handle);
            D.13232 = thr_ret != 0;
            D.13233 = (long int) D.13232;
            D.13234 = __builtin_expect (D.13233, 0);
            if (D.13234 != 0) goto <D.13235>; else goto <D.13236>;
            <D.13235>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "io.c", 2947, "thr_ret == 0");
            <D.13236>:
            find_handle.47 = find_handle;
            D.13238 = find_handle.47->namelist;
            monoeg_g_strfreev (D.13238);
            find_handle.47 = find_handle;
            D.13239 = find_handle.47->dir_part;
            monoeg_g_free (D.13239);
            thr_ret = _wapi_handle_unlock_handle (handle);
            D.13232 = thr_ret != 0;
            D.13233 = (long int) D.13232;
            D.13234 = __builtin_expect (D.13233, 0);
            if (D.13234 != 0) goto <D.13240>; else goto <D.13241>;
            <D.13240>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "io.c", 2953, "thr_ret == 0");
            <D.13241>:
            __pthread_unregister_cancel (&__cancel_buf);
            if (0 != 0) goto <D.13242>; else goto <D.13243>;
            <D.13242>:
            __cancel_routine (__cancel_arg);
            <D.13243>:
          }
        finally
          {
            __cancel_buf = {CLOBBER};
          }
      }
      _wapi_handle_unref (handle);
      D.13225 = 1;
      return D.13225;
    }
  finally
    {
      find_handle = {CLOBBER};
    }
}


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

  if (name == 0B) goto <D.13249>; else goto <D.13250>;
  <D.13249>:
  SetLastError (123);
  D.13251 = 0;
  return D.13251;
  <D.13250>:
  utf8_name = mono_unicode_to_external (name);
  if (utf8_name == 0B) goto <D.13252>; else goto <D.13253>;
  <D.13252>:
  SetLastError (123);
  D.13251 = 0;
  return D.13251;
  <D.13253>:
  result = _wapi_mkdir (utf8_name, 511);
  if (result == 0) goto <D.13254>; else goto <D.13255>;
  <D.13254>:
  monoeg_g_free (utf8_name);
  D.13251 = 1;
  return D.13251;
  <D.13255>:
  _wapi_set_last_path_error_from_errno (0B, utf8_name);
  monoeg_g_free (utf8_name);
  D.13251 = 0;
  return D.13251;
}


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

  if (name == 0B) goto <D.13257>; else goto <D.13258>;
  <D.13257>:
  SetLastError (123);
  D.13259 = 0;
  return D.13259;
  <D.13258>:
  utf8_name = mono_unicode_to_external (name);
  if (utf8_name == 0B) goto <D.13260>; else goto <D.13261>;
  <D.13260>:
  SetLastError (123);
  D.13259 = 0;
  return D.13259;
  <D.13261>:
  result = _wapi_rmdir (utf8_name);
  if (result == -1) goto <D.13262>; else goto <D.13263>;
  <D.13262>:
  _wapi_set_last_path_error_from_errno (0B, utf8_name);
  monoeg_g_free (utf8_name);
  D.13259 = 0;
  return D.13259;
  <D.13263>:
  monoeg_g_free (utf8_name);
  D.13259 = 1;
  return D.13259;
}


GetFileAttributes (const gunichar2 * name)
{
  guint32 D.13267;
  int * D.13272;
  int D.13273;
  gchar * utf8_name;
  struct stat buf;
  struct stat linkbuf;
  int result;
  guint32 ret;

  try
    {
      if (name == 0B) goto <D.13265>; else goto <D.13266>;
      <D.13265>:
      SetLastError (123);
      D.13267 = 0;
      return D.13267;
      <D.13266>:
      utf8_name = mono_unicode_to_external (name);
      if (utf8_name == 0B) goto <D.13268>; else goto <D.13269>;
      <D.13268>:
      SetLastError (87);
      D.13267 = 4294967295;
      return D.13267;
      <D.13269>:
      result = _wapi_stat (utf8_name, &buf);
      if (result == -1) goto <D.13270>; else goto <D.13271>;
      <D.13270>:
      D.13272 = __errno_location ();
      D.13273 = *D.13272;
      if (D.13273 == 2) goto <D.13274>; else goto <D.13275>;
      <D.13274>:
      result = _wapi_lstat (utf8_name, &buf);
      <D.13275>:
      <D.13271>:
      if (result != 0) goto <D.13276>; else goto <D.13277>;
      <D.13276>:
      _wapi_set_last_path_error_from_errno (0B, utf8_name);
      monoeg_g_free (utf8_name);
      D.13267 = 4294967295;
      return D.13267;
      <D.13277>:
      result = _wapi_lstat (utf8_name, &linkbuf);
      if (result != 0) goto <D.13278>; else goto <D.13279>;
      <D.13278>:
      _wapi_set_last_path_error_from_errno (0B, utf8_name);
      monoeg_g_free (utf8_name);
      D.13267 = 4294967295;
      return D.13267;
      <D.13279>:
      ret = _wapi_stat_to_file_attributes (utf8_name, &buf, &linkbuf);
      monoeg_g_free (utf8_name);
      D.13267 = ret;
      return D.13267;
    }
  finally
    {
      buf = {CLOBBER};
      linkbuf = {CLOBBER};
    }
}


GetFileAttributesEx (const gunichar2 * name, WapiGetFileExInfoLevels level, void * info)
{
  gboolean D.13284;
  int * D.13291;
  int D.13292;
  long int D.13299;
  long int D.13300;
  unsigned int D.13304;
  struct WapiFileTime * D.13305;
  struct WapiFileTime * D.13306;
  long int D.13307;
  struct WapiFileTime * D.13308;
  unsigned int D.13309;
  unsigned int D.13310;
  long int D.13314;
  long int D.13315;
  unsigned int D.13316;
  unsigned int D.13317;
  gchar * utf8_name;
  struct WapiFileAttributesData * data;
  struct stat buf;
  struct stat linkbuf;
  time_t create_time;
  int result;

  try
    {
      if (level != 0) goto <D.13282>; else goto <D.13283>;
      <D.13282>:
      SetLastError (87);
      D.13284 = 0;
      return D.13284;
      <D.13283>:
      if (name == 0B) goto <D.13285>; else goto <D.13286>;
      <D.13285>:
      SetLastError (123);
      D.13284 = 0;
      return D.13284;
      <D.13286>:
      utf8_name = mono_unicode_to_external (name);
      if (utf8_name == 0B) goto <D.13287>; else goto <D.13288>;
      <D.13287>:
      SetLastError (87);
      D.13284 = 0;
      return D.13284;
      <D.13288>:
      result = _wapi_stat (utf8_name, &buf);
      if (result == -1) goto <D.13289>; else goto <D.13290>;
      <D.13289>:
      D.13291 = __errno_location ();
      D.13292 = *D.13291;
      if (D.13292 == 2) goto <D.13293>; else goto <D.13294>;
      <D.13293>:
      result = _wapi_lstat (utf8_name, &buf);
      <D.13294>:
      <D.13290>:
      if (result != 0) goto <D.13295>; else goto <D.13296>;
      <D.13295>:
      _wapi_set_last_path_error_from_errno (0B, utf8_name);
      monoeg_g_free (utf8_name);
      D.13284 = 0;
      return D.13284;
      <D.13296>:
      result = _wapi_lstat (utf8_name, &linkbuf);
      if (result != 0) goto <D.13297>; else goto <D.13298>;
      <D.13297>:
      _wapi_set_last_path_error_from_errno (0B, utf8_name);
      monoeg_g_free (utf8_name);
      D.13284 = 0;
      return D.13284;
      <D.13298>:
      data = info;
      D.13299 = buf.st_mtim.tv_sec;
      D.13300 = buf.st_ctim.tv_sec;
      if (D.13299 < D.13300) goto <D.13301>; else goto <D.13302>;
      <D.13301>:
      create_time = buf.st_mtim.tv_sec;
      goto <D.13303>;
      <D.13302>:
      create_time = buf.st_ctim.tv_sec;
      <D.13303>:
      D.13304 = _wapi_stat_to_file_attributes (utf8_name, &buf, &linkbuf);
      data->dwFileAttributes = D.13304;
      monoeg_g_free (utf8_name);
      D.13305 = &data->ftCreationTime;
      _wapi_time_t_to_filetime (create_time, D.13305);
      D.13306 = &data->ftLastAccessTime;
      D.13307 = buf.st_atim.tv_sec;
      _wapi_time_t_to_filetime (D.13307, D.13306);
      D.13308 = &data->ftLastWriteTime;
      D.13299 = buf.st_mtim.tv_sec;
      _wapi_time_t_to_filetime (D.13299, D.13308);
      D.13309 = data->dwFileAttributes;
      D.13310 = D.13309 & 16;
      if (D.13310 != 0) goto <D.13311>; else goto <D.13312>;
      <D.13311>:
      data->nFileSizeHigh = 0;
      data->nFileSizeLow = 0;
      goto <D.13313>;
      <D.13312>:
      D.13314 = buf.st_size;
      D.13315 = D.13314 >> 32;
      D.13316 = (unsigned int) D.13315;
      data->nFileSizeHigh = D.13316;
      D.13314 = buf.st_size;
      D.13317 = (unsigned int) D.13314;
      data->nFileSizeLow = D.13317;
      <D.13313>:
      D.13284 = 1;
      return D.13284;
    }
  finally
    {
      buf = {CLOBBER};
      linkbuf = {CLOBBER};
    }
}


SetFileAttributes (const gunichar2 * name, guint32 attrs)
{
  gboolean D.13322;
  int * D.13327;
  int D.13328;
  unsigned int D.13333;
  unsigned int D.13336;
  unsigned int D.13337;
  unsigned int D.13339;
  signed int attrs.48;
  unsigned int D.13343;
  unsigned int D.13346;
  unsigned int D.13349;
  unsigned int D.13352;
  gchar * utf8_name;
  struct stat buf;
  int result;

  try
    {
      if (name == 0B) goto <D.13320>; else goto <D.13321>;
      <D.13320>:
      SetLastError (123);
      D.13322 = 0;
      return D.13322;
      <D.13321>:
      utf8_name = mono_unicode_to_external (name);
      if (utf8_name == 0B) goto <D.13323>; else goto <D.13324>;
      <D.13323>:
      SetLastError (123);
      D.13322 = 0;
      return D.13322;
      <D.13324>:
      result = _wapi_stat (utf8_name, &buf);
      if (result == -1) goto <D.13325>; else goto <D.13326>;
      <D.13325>:
      D.13327 = __errno_location ();
      D.13328 = *D.13327;
      if (D.13328 == 2) goto <D.13329>; else goto <D.13330>;
      <D.13329>:
      result = _wapi_lstat (utf8_name, &buf);
      <D.13330>:
      <D.13326>:
      if (result != 0) goto <D.13331>; else goto <D.13332>;
      <D.13331>:
      _wapi_set_last_path_error_from_errno (0B, utf8_name);
      monoeg_g_free (utf8_name);
      D.13322 = 0;
      return D.13322;
      <D.13332>:
      D.13333 = attrs & 1;
      if (D.13333 != 0) goto <D.13334>; else goto <D.13335>;
      <D.13334>:
      D.13336 = buf.st_mode;
      D.13337 = D.13336 & 4294967149;
      result = _wapi_chmod (utf8_name, D.13337);
      goto <D.13338>;
      <D.13335>:
      D.13336 = buf.st_mode;
      D.13339 = D.13336 | 128;
      result = _wapi_chmod (utf8_name, D.13339);
      <D.13338>:
      attrs.48 = (signed int) attrs;
      if (attrs.48 < 0) goto <D.13341>; else goto <D.13342>;
      <D.13341>:
      {
        mode_t exec_mask;

        exec_mask = 0;
        D.13336 = buf.st_mode;
        D.13343 = D.13336 & 256;
        if (D.13343 != 0) goto <D.13344>; else goto <D.13345>;
        <D.13344>:
        exec_mask = exec_mask | 64;
        <D.13345>:
        D.13336 = buf.st_mode;
        D.13346 = D.13336 & 32;
        if (D.13346 != 0) goto <D.13347>; else goto <D.13348>;
        <D.13347>:
        exec_mask = exec_mask | 8;
        <D.13348>:
        D.13336 = buf.st_mode;
        D.13349 = D.13336 & 4;
        if (D.13349 != 0) goto <D.13350>; else goto <D.13351>;
        <D.13350>:
        exec_mask = exec_mask | 1;
        <D.13351>:
        D.13336 = buf.st_mode;
        D.13352 = D.13336 | exec_mask;
        result = chmod (utf8_name, D.13352);
      }
      <D.13342>:
      monoeg_g_free (utf8_name);
      D.13322 = 1;
      return D.13322;
    }
  finally
    {
      buf = {CLOBBER};
    }
}


GetCurrentDirectory (guint32 length, gunichar2 * buffer)
{
  long unsigned int D.13355;
  char * D.13356;
  int * D.13359;
  int D.13360;
  guint32 D.13365;
  long unsigned int bytes.49;
  long unsigned int D.13367;
  unsigned int D.13368;
  long unsigned int D.13369;
  long int D.13370;
  _Bool D.13371;
  long int D.13372;
  long int D.13373;
  long unsigned int D.13376;
  gunichar2 * utf16_path;
  glong count;
  gsize bytes;

  try
    {
      D.13355 = (long unsigned int) length;
      D.13356 = getcwd (buffer, D.13355);
      if (D.13356 == 0B) goto <D.13357>; else goto <D.13358>;
      <D.13357>:
      D.13359 = __errno_location ();
      D.13360 = *D.13359;
      if (D.13360 == 34) goto <D.13361>; else goto <D.13362>;
      <D.13361>:
      {
        gchar * path;

        path = monoeg_g_get_current_dir ();
        if (path == 0B) goto <D.13363>; else goto <D.13364>;
        <D.13363>:
        D.13365 = 0;
        return D.13365;
        <D.13364>:
        utf16_path = mono_unicode_from_external (path, &bytes);
        monoeg_g_free (utf16_path);
        monoeg_g_free (path);
        bytes.49 = bytes;
        D.13367 = bytes.49 / 2;
        D.13368 = (unsigned int) D.13367;
        D.13365 = D.13368 + 1;
        return D.13365;
      }
      <D.13362>:
      _wapi_set_last_error_from_errno ();
      D.13365 = 0;
      return D.13365;
      <D.13358>:
      utf16_path = mono_unicode_from_external (buffer, &bytes);
      bytes.49 = bytes;
      D.13367 = bytes.49 / 2;
      D.13369 = D.13367 + 1;
      count = (glong) D.13369;
      D.13370 = (long int) length;
      D.13371 = D.13370 < count;
      D.13372 = (long int) D.13371;
      D.13373 = __builtin_expect (D.13372, 0);
      if (D.13373 != 0) goto <D.13374>; else goto <D.13375>;
      <D.13374>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "io.c", 3320, "count <= length");
      <D.13375>:
      bytes.49 = bytes;
      D.13376 = bytes.49 + 2;
      memset (buffer, 0, D.13376);
      bytes.49 = bytes;
      memcpy (buffer, utf16_path, bytes.49);
      monoeg_g_free (utf16_path);
      D.13365 = (guint32) count;
      return D.13365;
    }
  finally
    {
      bytes = {CLOBBER};
    }
}


getcwd (char * __buf, size_t __size)
{
  long unsigned int D.13379;
  int D.13382;
  char * D.13385;
  long unsigned int D.13386;
  long unsigned int D.13387;
  long unsigned int D.13390;

  D.13379 = __builtin_object_size (__buf, 1);
  if (D.13379 != 18446744073709551615) goto <D.13380>; else goto <D.13381>;
  <D.13380>:
  D.13382 = __builtin_constant_p (__size);
  if (D.13382 == 0) goto <D.13383>; else goto <D.13384>;
  <D.13383>:
  D.13386 = __builtin_object_size (__buf, 1);
  D.13385 = __getcwd_chk (__buf, __size, D.13386);
  return D.13385;
  <D.13384>:
  D.13387 = __builtin_object_size (__buf, 1);
  if (D.13387 < __size) goto <D.13388>; else goto <D.13389>;
  <D.13388>:
  D.13390 = __builtin_object_size (__buf, 1);
  D.13385 = __getcwd_chk_warn (__buf, __size, D.13390);
  return D.13385;
  <D.13389>:
  <D.13381>:
  D.13385 = __getcwd_alias (__buf, __size);
  return D.13385;
}


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

  if (path == 0B) goto <D.13392>; else goto <D.13393>;
  <D.13392>:
  SetLastError (87);
  D.13394 = 0;
  return D.13394;
  <D.13393>:
  utf8_path = mono_unicode_to_external (path);
  D.13395 = _wapi_chdir (utf8_path);
  if (D.13395 != 0) goto <D.13396>; else goto <D.13397>;
  <D.13396>:
  _wapi_set_last_error_from_errno ();
  result = 0;
  goto <D.13398>;
  <D.13397>:
  result = 1;
  <D.13398>:
  monoeg_g_free (utf8_path);
  D.13394 = result;
  return D.13394;
}


CreatePipe (void * * readpipe, void * * writepipe, struct WapiSecurityAttributes * security, guint32 size)
{
  gboolean D.13402;
  int D.13405;
  unsigned int D.13406;
  unsigned int _wapi_fd_reserve.50;
  int D.13409;
  unsigned int D.13410;
  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.13400>; else goto <D.13401>;
      <D.13400>:
      _wapi_set_last_error_from_errno ();
      D.13402 = 0;
      return D.13402;
      <D.13401>:
      D.13405 = filedes[0];
      D.13406 = (unsigned int) D.13405;
      _wapi_fd_reserve.50 = _wapi_fd_reserve;
      if (D.13406 >= _wapi_fd_reserve.50) goto <D.13403>; else goto <D.13408>;
      <D.13408>:
      D.13409 = filedes[1];
      D.13410 = (unsigned int) D.13409;
      _wapi_fd_reserve.50 = _wapi_fd_reserve;
      if (D.13410 >= _wapi_fd_reserve.50) goto <D.13403>; else goto <D.13404>;
      <D.13403>:
      SetLastError (4);
      D.13405 = filedes[0];
      close (D.13405);
      D.13409 = filedes[1];
      close (D.13409);
      D.13402 = 0;
      return D.13402;
      <D.13404>:
      D.13405 = filedes[0];
      pipe_read_handle.fd = D.13405;
      pipe_read_handle.fileaccess = 2147483648;
      D.13405 = filedes[0];
      read_handle = _wapi_handle_new_fd (10, D.13405, &pipe_read_handle);
      if (read_handle == -1B) goto <D.13411>; else goto <D.13412>;
      <D.13411>:
      monoeg_g_log (0B, 16, "%s: error creating pipe read handle", &__func__);
      D.13405 = filedes[0];
      close (D.13405);
      D.13409 = filedes[1];
      close (D.13409);
      SetLastError (31);
      D.13402 = 0;
      return D.13402;
      <D.13412>:
      D.13409 = filedes[1];
      pipe_write_handle.fd = D.13409;
      pipe_write_handle.fileaccess = 1073741824;
      D.13409 = filedes[1];
      write_handle = _wapi_handle_new_fd (10, D.13409, &pipe_write_handle);
      if (write_handle == -1B) goto <D.13413>; else goto <D.13414>;
      <D.13413>:
      monoeg_g_log (0B, 16, "%s: error creating pipe write handle", &__func__);
      _wapi_handle_unref (read_handle);
      D.13405 = filedes[0];
      close (D.13405);
      D.13409 = filedes[1];
      close (D.13409);
      SetLastError (31);
      D.13402 = 0;
      return D.13402;
      <D.13414>:
      *readpipe = read_handle;
      *writepipe = write_handle;
      D.13402 = 1;
      return D.13402;
    }
  finally
    {
      pipe_read_handle = {CLOBBER};
      pipe_write_handle = {CLOBBER};
      filedes = {CLOBBER};
    }
}


GetTempPath (guint32 len, gunichar2 * buf)
{
  const gchar * D.13417;
  long unsigned int D.13418;
  gchar * D.13419;
  char D.13420;
  const gchar * D.13423;
  guint32 D.13426;
  long unsigned int bytes.51;
  long unsigned int D.13428;
  long int D.13429;
  unsigned int D.13432;
  long unsigned int D.13434;
  gchar * tmpdir;
  gunichar2 * tmpdir16;
  glong dirlen;
  gsize bytes;
  guint32 ret;

  try
    {
      D.13417 = monoeg_g_get_tmp_dir ();
      tmpdir = monoeg_strdup (D.13417);
      tmpdir16 = 0B;
      D.13418 = strlen (tmpdir);
      D.13419 = tmpdir + D.13418;
      D.13420 = *D.13419;
      if (D.13420 != 47) goto <D.13421>; else goto <D.13422>;
      <D.13421>:
      monoeg_g_free (tmpdir);
      D.13423 = monoeg_g_get_tmp_dir ();
      tmpdir = monoeg_g_strdup_printf ("%s/", D.13423);
      <D.13422>:
      tmpdir16 = mono_unicode_from_external (tmpdir, &bytes);
      if (tmpdir16 == 0B) goto <D.13424>; else goto <D.13425>;
      <D.13424>:
      monoeg_g_free (tmpdir);
      D.13426 = 0;
      return D.13426;
      <D.13425>:
      bytes.51 = bytes;
      D.13428 = bytes.51 / 2;
      dirlen = (glong) D.13428;
      D.13429 = (long int) len;
      if (D.13429 <= dirlen) goto <D.13430>; else goto <D.13431>;
      <D.13430>:
      D.13432 = (unsigned int) dirlen;
      ret = D.13432 + 1;
      goto <D.13433>;
      <D.13431>:
      bytes.51 = bytes;
      D.13434 = bytes.51 + 2;
      memset (buf, 0, D.13434);
      bytes.51 = bytes;
      memcpy (buf, tmpdir16, bytes.51);
      ret = (guint32) dirlen;
      <D.13433>:
      if (tmpdir16 != 0B) goto <D.13435>; else goto <D.13436>;
      <D.13435>:
      monoeg_g_free (tmpdir16);
      <D.13436>:
      monoeg_g_free (tmpdir);
      D.13426 = ret;
      return D.13426;
    }
  finally
    {
      bytes = {CLOBBER};
    }
}


GetLogicalDriveStrings (guint32 len, gunichar2 * buf)
{
  long unsigned int D.13439;
  long unsigned int D.13440;
  unsigned int D.13448;
  char D.13449;
  unsigned int D.13452;
  gchar * D.13453;
  long int D.13458;
  int D.13459;
  long int D.13460;
  long int D.13461;
  gint32 D.13464;
  int fd;
  gint32 ret;
  struct LinuxMountInfoParseState state;
  gboolean (*<T1cf2>) (guint32, gunichar2 *, struct LinuxMountInfoParseState *) parser;
  void done_and_out = <<< error >>>;

  try
    {
      ret = 0;
      parser = 0B;
      D.13439 = (long unsigned int) len;
      D.13440 = D.13439 * 2;
      memset (buf, 0, D.13440);
      fd = open ("/proc/self/mountinfo", 0);
      if (fd != -1) goto <D.13441>; else goto <D.13442>;
      <D.13441>:
      parser = GetLogicalDriveStrings_MountInfo;
      goto <D.13443>;
      <D.13442>:
      fd = open ("/proc/mounts", 0);
      if (fd != -1) goto <D.13444>; else goto <D.13445>;
      <D.13444>:
      parser = GetLogicalDriveStrings_Mounts;
      <D.13445>:
      <D.13443>:
      if (parser == 0B) goto <D.13446>; else goto <D.13447>;
      <D.13446>:
      ret = GetLogicalDriveStrings_Mtab (len, buf);
      goto done_and_out;
      <D.13447>:
      memset (&state, 0, 1224);
      state.field_number = 1;
      state.delimiter = 32;
      goto <D.11945>;
      <D.11944>:
      state.buffer_index = 0;
      goto <D.11942>;
      <D.11941>:
      D.13448 = state.buffer_index;
      D.13449 = state.buffer[D.13448];
      if (D.13449 == 10) goto <D.13450>; else goto <D.13451>;
      <D.13450>:
      {
        gboolean quit;

        quit = add_drive_string (len, buf, &state);
        state.field_number = 1;
        D.13448 = state.buffer_index;
        D.13452 = D.13448 + 1;
        state.buffer_index = D.13452;
        D.13453 = state.mountpoint_allocated;
        if (D.13453 != 0B) goto <D.13454>; else goto <D.13455>;
        <D.13454>:
        D.13453 = state.mountpoint_allocated;
        monoeg_g_free (D.13453);
        state.mountpoint_allocated = 0B;
        <D.13455>:
        if (quit != 0) goto <D.13456>; else goto <D.13457>;
        <D.13456>:
        D.13458 = state.total;
        ret = (gint32) D.13458;
        goto done_and_out;
        <D.13457>:
      }
      <D.13451>:
      <D.11942>:
      D.13459 = parser (len, buf, &state);
      if (D.13459 != 0) goto <D.11941>; else goto <D.11943>;
      <D.11943>:
      <D.11945>:
      D.13460 = read (fd, &state.buffer, 512);
      state.nbytes = D.13460;
      D.13461 = state.nbytes;
      if (D.13461 > 0) goto <D.11944>; else goto <D.11946>;
      <D.11946>:
      D.13458 = state.total;
      ret = (gint32) D.13458;
      done_and_out:
      if (fd != -1) goto <D.13462>; else goto <D.13463>;
      <D.13462>:
      close (fd);
      <D.13463>:
      D.13464 = ret;
      return D.13464;
    }
  finally
    {
      state = {CLOBBER};
    }
}


GetLogicalDriveStrings_Mounts (guint32 len, gunichar2 * buf, struct LinuxMountInfoParseState * state)
{
  unsigned int D.13467;
  unsigned int D.13470;
  char D.13471;
  char D.13472;
  unsigned int D.13475;
  gchar * D.13476;
  unsigned int D.13479;
  sizetype D.13480;
  gchar * D.13481;
  unsigned int D.13483;
  long unsigned int D.13484;
  sizetype D.13485;
  gchar * D.13486;
  long int ptr.52;
  gchar[512] * D.13490;
  long int D.13491;
  long int D.13492;
  unsigned int D.13493;
  unsigned int D.13494;
  long int D.13496;
  unsigned int D.13497;
  gboolean D.13498;
  unsigned int D.13499;
  int D.13502;
  unsigned int D.13505;
  unsigned int D.13510;
  unsigned int D.13511;
  unsigned int D.13514;
  unsigned int D.13515;
  unsigned int D.13516;
  unsigned int D.13519;
  unsigned int D.13520;
  unsigned int D.13522;
  gchar * ptr;

  D.13467 = state->field_number;
  if (D.13467 == 1) goto <D.13468>; else goto <D.13469>;
  <D.13468>:
  state->check_mount_source = 1;
  <D.13469>:
  goto <D.11957>;
  <D.11962>:
  D.13470 = state->buffer_index;
  D.13471 = state->buffer[D.13470];
  D.13472 = state->delimiter;
  if (D.13471 == D.13472) goto <D.13473>; else goto <D.13474>;
  <D.13473>:
  D.13467 = state->field_number;
  D.13475 = D.13467 + 1;
  state->field_number = D.13475;
  D.13467 = state->field_number;
  switch (D.13467) <default: <D.11956>, case 2: <D.11953>, case 3: <D.11955>>
  <D.11953>:
  state->mountpoint_index = 0;
  goto <D.11954>;
  <D.11955>:
  D.13476 = state->mountpoint_allocated;
  if (D.13476 != 0B) goto <D.13477>; else goto <D.13478>;
  <D.13477>:
  D.13476 = state->mountpoint_allocated;
  D.13479 = state->mountpoint_index;
  D.13480 = (sizetype) D.13479;
  D.13481 = D.13476 + D.13480;
  *D.13481 = 0;
  goto <D.13482>;
  <D.13478>:
  D.13479 = state->mountpoint_index;
  state->mountpoint[D.13479] = 0;
  <D.13482>:
  goto <D.11954>;
  <D.11956>:
  D.13470 = state->buffer_index;
  D.13483 = 512 - D.13470;
  D.13484 = (long unsigned int) D.13483;
  D.13470 = state->buffer_index;
  D.13485 = (sizetype) D.13470;
  D.13486 = &state->buffer[D.13485];
  ptr = memchr (D.13486, 10, D.13484);
  if (ptr != 0B) goto <D.13487>; else goto <D.13488>;
  <D.13487>:
  ptr.52 = (long int) ptr;
  D.13490 = &state->buffer;
  D.13491 = (long int) D.13490;
  D.13492 = ptr.52 - D.13491;
  D.13493 = (unsigned int) D.13492;
  D.13494 = D.13493 + 4294967295;
  state->buffer_index = D.13494;
  goto <D.13495>;
  <D.13488>:
  D.13496 = state->nbytes;
  D.13497 = (unsigned int) D.13496;
  state->buffer_index = D.13497;
  <D.13495>:
  D.13498 = 1;
  return D.13498;
  <D.11954>:
  D.13470 = state->buffer_index;
  D.13499 = D.13470 + 1;
  state->buffer_index = D.13499;
  // predicted unlikely by continue predictor.
  goto <D.11957>;
  <D.13474>:
  D.13470 = state->buffer_index;
  D.13471 = state->buffer[D.13470];
  if (D.13471 == 10) goto <D.13500>; else goto <D.13501>;
  <D.13500>:
  D.13498 = 1;
  return D.13498;
  <D.13501>:
  D.13467 = state->field_number;
  switch (D.13467) <default: <D.13521>, case 1: <D.11958>, case 2: <D.11960>, case 3: <D.11961>>
  <D.11958>:
  D.13502 = state->check_mount_source;
  if (D.13502 != 0) goto <D.13503>; else goto <D.13504>;
  <D.13503>:
  D.13505 = state->fsname_index;
  if (D.13505 == 0) goto <D.13506>; else goto <D.13507>;
  <D.13506>:
  D.13470 = state->buffer_index;
  D.13471 = state->buffer[D.13470];
  if (D.13471 == 47) goto <D.13508>; else goto <D.13509>;
  <D.13508>:
  state->check_mount_source = 0;
  D.13505 = state->fsname_index;
  D.13510 = D.13505;
  D.13511 = D.13510 + 1;
  state->fsname_index = D.13511;
  state->fsname[D.13510] = 47;
  goto <D.11959>;
  <D.13509>:
  <D.13507>:
  D.13505 = state->fsname_index;
  if (D.13505 <= 63) goto <D.13512>; else goto <D.13513>;
  <D.13512>:
  D.13505 = state->fsname_index;
  D.13514 = D.13505;
  D.13515 = D.13514 + 1;
  state->fsname_index = D.13515;
  D.13470 = state->buffer_index;
  D.13471 = state->buffer[D.13470];
  state->fsname[D.13514] = D.13471;
  <D.13513>:
  <D.13504>:
  goto <D.11959>;
  <D.11960>:
  append_to_mountpoint (state);
  goto <D.11959>;
  <D.11961>:
  D.13516 = state->fstype_index;
  if (D.13516 <= 63) goto <D.13517>; else goto <D.13518>;
  <D.13517>:
  D.13516 = state->fstype_index;
  D.13519 = D.13516;
  D.13520 = D.13519 + 1;
  state->fstype_index = D.13520;
  D.13470 = state->buffer_index;
  D.13471 = state->buffer[D.13470];
  state->fstype[D.13519] = D.13471;
  <D.13518>:
  goto <D.11959>;
  <D.13521>:
  <D.11959>:
  D.13470 = state->buffer_index;
  D.13499 = D.13470 + 1;
  state->buffer_index = D.13499;
  <D.11957>:
  D.13470 = state->buffer_index;
  D.13496 = state->nbytes;
  D.13522 = (unsigned int) D.13496;
  if (D.13470 < D.13522) goto <D.11962>; else goto <D.11963>;
  <D.11963>:
  D.13498 = 0;
  return D.13498;
}


append_to_mountpoint (struct LinuxMountInfoParseState * state)
{
  unsigned int D.13524;
  gchar * D.13525;
  unsigned int D.13528;
  unsigned int D.13529;
  unsigned int D.13532;
  long unsigned int D.13533;
  long unsigned int D.13534;
  unsigned int D.13535;
  unsigned int D.13536;
  sizetype D.13537;
  gchar * D.13538;
  unsigned int D.13542;
  unsigned int D.13543;
  long unsigned int D.13544;
  void * D.13545;
  gchar[513] * D.13546;
  unsigned int D.13547;
  unsigned int D.13548;
  sizetype D.13549;
  gchar * D.13550;
  unsigned int D.13552;
  unsigned int D.13553;
  gchar ch;

  D.13524 = state->buffer_index;
  ch = state->buffer[D.13524];
  D.13525 = state->mountpoint_allocated;
  if (D.13525 != 0B) goto <D.13526>; else goto <D.13527>;
  <D.13526>:
  D.13528 = state->mountpoint_index;
  D.13529 = state->allocated_size;
  if (D.13528 >= D.13529) goto <D.13530>; else goto <D.13531>;
  <D.13530>:
  {
    guint32 newsize;
    gchar * newbuf;

    D.13529 = state->allocated_size;
    D.13532 = D.13529 << 1;
    newsize = D.13532 + 1;
    D.13533 = (long unsigned int) newsize;
    newbuf = monoeg_malloc0 (D.13533);
    D.13528 = state->mountpoint_index;
    D.13534 = (long unsigned int) D.13528;
    D.13525 = state->mountpoint_allocated;
    memcpy (newbuf, D.13525, D.13534);
    D.13525 = state->mountpoint_allocated;
    monoeg_g_free (D.13525);
    state->mountpoint_allocated = newbuf;
    state->allocated_size = newsize;
  }
  <D.13531>:
  D.13525 = state->mountpoint_allocated;
  D.13528 = state->mountpoint_index;
  D.13535 = D.13528;
  D.13536 = D.13535 + 1;
  state->mountpoint_index = D.13536;
  D.13537 = (sizetype) D.13535;
  D.13538 = D.13525 + D.13537;
  *D.13538 = ch;
  goto <D.13539>;
  <D.13527>:
  D.13528 = state->mountpoint_index;
  if (D.13528 > 511) goto <D.13540>; else goto <D.13541>;
  <D.13540>:
  D.13528 = state->mountpoint_index;
  D.13542 = D.13528 << 1;
  D.13543 = D.13542 + 1;
  state->allocated_size = D.13543;
  D.13529 = state->allocated_size;
  D.13544 = (long unsigned int) D.13529;
  D.13545 = monoeg_malloc0 (D.13544);
  state->mountpoint_allocated = D.13545;
  D.13528 = state->mountpoint_index;
  D.13534 = (long unsigned int) D.13528;
  D.13546 = &state->mountpoint;
  D.13525 = state->mountpoint_allocated;
  memcpy (D.13525, D.13546, D.13534);
  D.13525 = state->mountpoint_allocated;
  D.13528 = state->mountpoint_index;
  D.13547 = D.13528;
  D.13548 = D.13547 + 1;
  state->mountpoint_index = D.13548;
  D.13549 = (sizetype) D.13547;
  D.13550 = D.13525 + D.13549;
  *D.13550 = ch;
  goto <D.13551>;
  <D.13541>:
  D.13528 = state->mountpoint_index;
  D.13552 = D.13528;
  D.13553 = D.13552 + 1;
  state->mountpoint_index = D.13553;
  state->mountpoint[D.13552] = ch;
  <D.13551>:
  <D.13539>:
}


GetLogicalDriveStrings_MountInfo (guint32 len, gunichar2 * buf, struct LinuxMountInfoParseState * state)
{
  unsigned int D.13554;
  char D.13555;
  char D.13556;
  unsigned int D.13559;
  unsigned int D.13560;
  gchar * D.13561;
  unsigned int D.13564;
  sizetype D.13565;
  gchar * D.13566;
  unsigned int D.13569;
  gboolean D.13572;
  unsigned int D.13573;
  unsigned int D.13576;
  unsigned int D.13577;
  int D.13578;
  unsigned int D.13581;
  unsigned int D.13586;
  unsigned int D.13587;
  unsigned int D.13590;
  unsigned int D.13591;
  long int D.13593;
  unsigned int D.13594;

  goto <D.11975>;
  <D.11980>:
  D.13554 = state->buffer_index;
  D.13555 = state->buffer[D.13554];
  D.13556 = state->delimiter;
  if (D.13555 == D.13556) goto <D.13557>; else goto <D.13558>;
  <D.13557>:
  D.13559 = state->field_number;
  D.13560 = D.13559 + 1;
  state->field_number = D.13560;
  D.13559 = state->field_number;
  switch (D.13559) <default: <D.13568>, case 5: <D.11969>, case 6: <D.11971>, case 7: <D.11972>, case 8: <D.11973>, case 10: <D.11974>>
  <D.11969>:
  state->mountpoint_index = 0;
  goto <D.11970>;
  <D.11971>:
  D.13561 = state->mountpoint_allocated;
  if (D.13561 != 0B) goto <D.13562>; else goto <D.13563>;
  <D.13562>:
  D.13561 = state->mountpoint_allocated;
  D.13564 = state->mountpoint_index;
  D.13565 = (sizetype) D.13564;
  D.13566 = D.13561 + D.13565;
  *D.13566 = 0;
  goto <D.13567>;
  <D.13563>:
  D.13564 = state->mountpoint_index;
  state->mountpoint[D.13564] = 0;
  <D.13567>:
  goto <D.11970>;
  <D.11972>:
  state->delimiter = 45;
  goto <D.11970>;
  <D.11973>:
  state->delimiter = 32;
  goto <D.11970>;
  <D.11974>:
  state->check_mount_source = 1;
  goto <D.11970>;
  <D.13568>:
  <D.11970>:
  D.13554 = state->buffer_index;
  D.13569 = D.13554 + 1;
  state->buffer_index = D.13569;
  // predicted unlikely by continue predictor.
  goto <D.11975>;
  <D.13558>:
  D.13554 = state->buffer_index;
  D.13555 = state->buffer[D.13554];
  if (D.13555 == 10) goto <D.13570>; else goto <D.13571>;
  <D.13570>:
  D.13572 = 1;
  return D.13572;
  <D.13571>:
  D.13559 = state->field_number;
  switch (D.13559) <default: <D.13592>, case 5: <D.11976>, case 9: <D.11978>, case 10: <D.11979>>
  <D.11976>:
  append_to_mountpoint (state);
  goto <D.11977>;
  <D.11978>:
  D.13573 = state->fstype_index;
  if (D.13573 <= 63) goto <D.13574>; else goto <D.13575>;
  <D.13574>:
  D.13573 = state->fstype_index;
  D.13576 = D.13573;
  D.13577 = D.13576 + 1;
  state->fstype_index = D.13577;
  D.13554 = state->buffer_index;
  D.13555 = state->buffer[D.13554];
  state->fstype[D.13576] = D.13555;
  <D.13575>:
  goto <D.11977>;
  <D.11979>:
  D.13578 = state->check_mount_source;
  if (D.13578 != 0) goto <D.13579>; else goto <D.13580>;
  <D.13579>:
  D.13581 = state->fsname_index;
  if (D.13581 == 0) goto <D.13582>; else goto <D.13583>;
  <D.13582>:
  D.13554 = state->buffer_index;
  D.13555 = state->buffer[D.13554];
  if (D.13555 == 47) goto <D.13584>; else goto <D.13585>;
  <D.13584>:
  state->check_mount_source = 0;
  D.13581 = state->fsname_index;
  D.13586 = D.13581;
  D.13587 = D.13586 + 1;
  state->fsname_index = D.13587;
  state->fsname[D.13586] = 47;
  goto <D.11977>;
  <D.13585>:
  <D.13583>:
  D.13581 = state->fsname_index;
  if (D.13581 <= 63) goto <D.13588>; else goto <D.13589>;
  <D.13588>:
  D.13581 = state->fsname_index;
  D.13590 = D.13581;
  D.13591 = D.13590 + 1;
  state->fsname_index = D.13591;
  D.13554 = state->buffer_index;
  D.13555 = state->buffer[D.13554];
  state->fsname[D.13590] = D.13555;
  <D.13589>:
  <D.13580>:
  goto <D.11977>;
  <D.13592>:
  <D.11977>:
  D.13554 = state->buffer_index;
  D.13569 = D.13554 + 1;
  state->buffer_index = D.13569;
  <D.11975>:
  D.13554 = state->buffer_index;
  D.13593 = state->nbytes;
  D.13594 = (unsigned int) D.13593;
  if (D.13554 < D.13594) goto <D.11980>; else goto <D.11981>;
  <D.11981>:
  D.13572 = 0;
  return D.13572;
}


open (const char * __path, int __oflag)
{
  int D.13596;
  int D.13599;
  int D.13604;
  int D.13606;
  int D.13607;
  int D.13610;
  int D.13611;

  D.13596 = __builtin_va_arg_pack_len ();
  if (D.13596 > 1) goto <D.13597>; else goto <D.13598>;
  <D.13597>:
  __open_too_many_args ();
  <D.13598>:
  D.13599 = __builtin_constant_p (__oflag);
  if (D.13599 != 0) goto <D.13600>; else goto <D.13601>;
  <D.13600>:
  D.13604 = __oflag & 64;
  if (D.13604 != 0) goto <D.13602>; else goto <D.13605>;
  <D.13605>:
  D.13606 = __oflag & 4259840;
  if (D.13606 == 4259840) goto <D.13602>; else goto <D.13603>;
  <D.13602>:
  D.13607 = __builtin_va_arg_pack_len ();
  if (D.13607 <= 0) goto <D.13608>; else goto <D.13609>;
  <D.13608>:
  __open_missing_mode ();
  D.13610 = __open_2 (__path, __oflag);
  return D.13610;
  <D.13609>:
  <D.13603>:
  D.13610 = __open_alias (__path, __oflag, __builtin_va_arg_pack ());
  return D.13610;
  <D.13601>:
  D.13611 = __builtin_va_arg_pack_len ();
  if (D.13611 <= 0) goto <D.13612>; else goto <D.13613>;
  <D.13612>:
  D.13610 = __open_2 (__path, __oflag);
  return D.13610;
  <D.13613>:
  D.13610 = __open_alias (__path, __oflag, __builtin_va_arg_pack ());
  return D.13610;
}


GetLogicalDriveStrings_Mtab (guint32 len, gunichar2 * buf)
{
  unsigned int D.13615;
  long unsigned int D.13616;
  long unsigned int D.13617;
  gunichar2 * D.13618;
  gunichar2 * D.13619;
  gint32 D.13624;
  char D.13625;
  gchar * D.13630;
  gchar * * D.13632;
  gchar * D.13633;
  long int length.53;
  long int D.13635;
  long int D.13636;
  unsigned int D.13639;
  long unsigned int length.54;
  long unsigned int D.13641;
  long unsigned int total.55;
  long unsigned int D.13643;
  gunichar2 * D.13644;
  long int D.13645;
  char * D.13646;
  struct FILE * fp;
  gunichar2 * ptr;
  gunichar2 * dir;
  glong length;
  glong total;
  gchar buffer[512];
  gchar * * splitted;

  try
    {
      total = 0;
      D.13615 = len + 1;
      D.13616 = (long unsigned int) D.13615;
      D.13617 = D.13616 * 2;
      memset (buf, 0, D.13617);
      *buf = 47;
      D.13618 = buf + 2;
      *D.13618 = 0;
      D.13619 = buf + 4;
      *D.13619 = 0;
      fp = fopen ("/etc/mtab", "rt");
      if (fp == 0B) goto <D.13620>; else goto <D.13621>;
      <D.13620>:
      fp = fopen ("/etc/mnttab", "rt");
      if (fp == 0B) goto <D.13622>; else goto <D.13623>;
      <D.13622>:
      D.13624 = 1;
      return D.13624;
      <D.13623>:
      <D.13621>:
      ptr = buf;
      goto <D.12009>;
      <D.12010>:
      D.13625 = buffer[0];
      if (D.13625 != 47) goto <D.13626>; else goto <D.13627>;
      <D.13626>:
      // predicted unlikely by continue predictor.
      goto <D.12009>;
      <D.13627>:
      splitted = monoeg_g_strsplit (&buffer, " ", 0);
      D.13630 = *splitted;
      if (D.13630 == 0B) goto <D.13628>; else goto <D.13631>;
      <D.13631>:
      D.13632 = splitted + 8;
      D.13633 = *D.13632;
      if (D.13633 == 0B) goto <D.13628>; else goto <D.13629>;
      <D.13628>:
      monoeg_g_strfreev (splitted);
      // predicted unlikely by continue predictor.
      goto <D.12009>;
      <D.13629>:
      D.13632 = splitted + 8;
      D.13633 = *D.13632;
      unescape_octal (D.13633);
      D.13632 = splitted + 8;
      D.13633 = *D.13632;
      dir = monoeg_g_utf8_to_utf16 (D.13633, -1, 0B, &length, 0B);
      monoeg_g_strfreev (splitted);
      length.53 = length;
      D.13635 = total + length.53;
      D.13636 = (long int) len;
      if (D.13635 >= D.13636) goto <D.13637>; else goto <D.13638>;
      <D.13637>:
      fclose (fp);
      monoeg_g_free (dir);
      D.13639 = len * 2;
      D.13624 = (gint32) D.13639;
      return D.13624;
      <D.13638>:
      length.53 = length;
      length.54 = (long unsigned int) length.53;
      D.13641 = length.54 * 2;
      total.55 = (long unsigned int) total;
      D.13643 = total.55 * 2;
      D.13644 = ptr + D.13643;
      memcpy (D.13644, dir, D.13641);
      monoeg_g_free (dir);
      length.53 = length;
      D.13645 = length.53 + 1;
      total = D.13645 + total;
      <D.12009>:
      D.13646 = fgets (&buffer, 512, fp);
      if (D.13646 != 0B) goto <D.12010>; else goto <D.12011>;
      <D.12011>:
      fclose (fp);
      D.13624 = (gint32) total;
      return D.13624;
    }
  finally
    {
      length = {CLOBBER};
      buffer = {CLOBBER};
    }
}


unescape_octal (gchar * str)
{
  char D.13651;
  gchar * rptr.56;
  char D.13655;
  int D.13656;
  int D.13657;
  int D.13658;
  gchar * rptr.57;
  char D.13660;
  int D.13661;
  int D.13662;
  int D.13663;
  unsigned char D.13664;
  unsigned char c.58;
  unsigned char D.13666;
  gchar * rptr.59;
  char D.13668;
  int D.13669;
  int D.13670;
  unsigned char D.13671;
  unsigned char D.13672;
  gchar * wptr.60;
  gchar * wptr.61;
  gchar * rptr.62;
  char D.13679;
  gchar * rptr;
  gchar * wptr;

  if (str == 0B) goto <D.13649>; else goto <D.13650>;
  <D.13649>:
  return;
  <D.13650>:
  wptr = str;
  rptr = wptr;
  goto <D.11892>;
  <D.11891>:
  D.13651 = *rptr;
  if (D.13651 == 92) goto <D.13652>; else goto <D.13653>;
  <D.13652>:
  {
    char c;

    rptr = rptr + 1;
    rptr.56 = rptr;
    rptr = rptr.56 + 1;
    D.13655 = *rptr.56;
    D.13656 = (int) D.13655;
    D.13657 = D.13656 + -48;
    D.13658 = D.13657 << 6;
    c = (char) D.13658;
    rptr.57 = rptr;
    rptr = rptr.57 + 1;
    D.13660 = *rptr.57;
    D.13661 = (int) D.13660;
    D.13662 = D.13661 + -48;
    D.13663 = D.13662 << 3;
    D.13664 = (unsigned char) D.13663;
    c.58 = (unsigned char) c;
    D.13666 = D.13664 + c.58;
    c = (char) D.13666;
    rptr.59 = rptr;
    rptr = rptr.59 + 1;
    D.13668 = *rptr.59;
    D.13669 = (int) D.13668;
    D.13670 = D.13669 + -48;
    D.13671 = (unsigned char) D.13670;
    c.58 = (unsigned char) c;
    D.13672 = D.13671 + c.58;
    c = (char) D.13672;
    wptr.60 = wptr;
    wptr = wptr.60 + 1;
    *wptr.60 = c;
  }
  goto <D.13674>;
  <D.13653>:
  if (wptr != rptr) goto <D.13675>; else goto <D.13676>;
  <D.13675>:
  wptr.61 = wptr;
  wptr = wptr.61 + 1;
  rptr.62 = rptr;
  rptr = rptr.62 + 1;
  D.13679 = *rptr.62;
  *wptr.61 = D.13679;
  goto <D.13680>;
  <D.13676>:
  rptr = rptr + 1;
  wptr = wptr + 1;
  <D.13680>:
  <D.13674>:
  <D.11892>:
  D.13651 = *rptr;
  if (D.13651 != 0) goto <D.11891>; else goto <D.11893>;
  <D.11893>:
  *wptr = 0;
}


fgets (char * restrict __s, int __n, struct FILE * restrict __stream)
{
  long unsigned int D.13682;
  int D.13687;
  char * D.13689;
  long unsigned int D.13690;
  long unsigned int D.13691;
  long unsigned int D.13692;
  long unsigned int D.13695;

  D.13682 = __builtin_object_size (__s, 1);
  if (D.13682 != 18446744073709551615) goto <D.13683>; else goto <D.13684>;
  <D.13683>:
  D.13687 = __builtin_constant_p (__n);
  if (D.13687 == 0) goto <D.13685>; else goto <D.13688>;
  <D.13688>:
  if (__n <= 0) goto <D.13685>; else goto <D.13686>;
  <D.13685>:
  D.13690 = __builtin_object_size (__s, 1);
  D.13689 = __fgets_chk (__s, D.13690, __n, __stream);
  return D.13689;
  <D.13686>:
  D.13691 = (long unsigned int) __n;
  D.13692 = __builtin_object_size (__s, 1);
  if (D.13691 > D.13692) goto <D.13693>; else goto <D.13694>;
  <D.13693>:
  D.13695 = __builtin_object_size (__s, 1);
  D.13689 = __fgets_chk_warn (__s, D.13695, __n, __stream);
  return D.13689;
  <D.13694>:
  <D.13684>:
  D.13689 = __fgets_alias (__s, __n, __stream);
  return D.13689;
}


add_drive_string (guint32 len, gunichar2 * buf, struct LinuxMountInfoParseState * state)
{
  unsigned int D.13699;
  char D.13701;
  long unsigned int D.13707;
  gchar[65] * D.13708;
  int D.13709;
  unsigned int D.13712;
  gchar[65] * D.13714;
  int D.13715;
  long unsigned int D.13720;
  int D.13721;
  gchar * iftmp.63;
  gchar * D.13726;
  long int D.13730;
  long int length.64;
  long int D.13732;
  long int D.13733;
  unsigned int D.13736;
  long int D.13737;
  long int length.65;
  long unsigned int length.66;
  long unsigned int D.13741;
  long unsigned int D.13742;
  long unsigned int D.13743;
  gunichar2 * D.13744;
  gboolean D.13745;
  gboolean quit;
  gboolean ignore_entry;

  quit = 0;
  D.13699 = state->fsname_index;
  if (D.13699 == 1) goto <D.13700>; else goto <D.13697>;
  <D.13700>:
  D.13701 = state->fsname[0];
  if (D.13701 == 47) goto <D.13702>; else goto <D.13697>;
  <D.13702>:
  ignore_entry = 0;
  goto <D.13698>;
  <D.13697>:
  D.13699 = state->fsname_index;
  if (D.13699 == 0) goto <D.13703>; else goto <D.13706>;
  <D.13706>:
  D.13699 = state->fsname_index;
  D.13707 = (long unsigned int) D.13699;
  D.13708 = &state->fsname;
  D.13709 = memcmp ("none", D.13708, D.13707);
  if (D.13709 == 0) goto <D.13703>; else goto <D.13704>;
  <D.13703>:
  ignore_entry = 1;
  goto <D.13705>;
  <D.13704>:
  D.13712 = state->fstype_index;
  if (D.13712 > 4) goto <D.13713>; else goto <D.13710>;
  <D.13713>:
  D.13714 = &state->fstype;
  D.13715 = memcmp ("fuse.", D.13714, 5);
  if (D.13715 == 0) goto <D.13716>; else goto <D.13710>;
  <D.13716>:
  D.13712 = state->fstype_index;
  if (D.13712 == 21) goto <D.13719>; else goto <D.13717>;
  <D.13719>:
  D.13712 = state->fstype_index;
  D.13720 = (long unsigned int) D.13712;
  D.13714 = &state->fstype;
  D.13721 = memcmp ("fuse.gvfs-fuse-daemon", D.13714, D.13720);
  if (D.13721 == 0) goto <D.13722>; else goto <D.13717>;
  <D.13722>:
  ignore_entry = 1;
  goto <D.13718>;
  <D.13717>:
  ignore_entry = 0;
  <D.13718>:
  goto <D.13711>;
  <D.13710>:
  ignore_entry = 1;
  <D.13711>:
  <D.13705>:
  <D.13698>:
  if (ignore_entry == 0) goto <D.13723>; else goto <D.13724>;
  <D.13723>:
  {
    gunichar2 * dir;
    glong length;
    gchar * mountpoint;

    try
      {
        D.13726 = state->mountpoint_allocated;
        if (D.13726 != 0B) goto <D.13727>; else goto <D.13728>;
        <D.13727>:
        iftmp.63 = state->mountpoint_allocated;
        goto <D.13729>;
        <D.13728>:
        iftmp.63 = &state->mountpoint;
        <D.13729>:
        mountpoint = iftmp.63;
        unescape_octal (mountpoint);
        dir = monoeg_g_utf8_to_utf16 (mountpoint, -1, 0B, &length, 0B);
        D.13730 = state->total;
        length.64 = length;
        D.13732 = D.13730 + length.64;
        D.13733 = (long int) len;
        if (D.13732 >= D.13733) goto <D.13734>; else goto <D.13735>;
        <D.13734>:
        quit = 1;
        D.13736 = len * 2;
        D.13737 = (long int) D.13736;
        state->total = D.13737;
        goto <D.13738>;
        <D.13735>:
        length.64 = length;
        length.65 = length.64 + 1;
        length = length.65;
        length.64 = length;
        length.66 = (long unsigned int) length.64;
        D.13741 = length.66 * 2;
        D.13730 = state->total;
        D.13742 = (long unsigned int) D.13730;
        D.13743 = D.13742 * 2;
        D.13744 = buf + D.13743;
        memcpy (D.13744, dir, D.13741);
        D.13730 = state->total;
        length.64 = length;
        D.13732 = D.13730 + length.64;
        state->total = D.13732;
        <D.13738>:
        monoeg_g_free (dir);
      }
    finally
      {
        length = {CLOBBER};
      }
  }
  <D.13724>:
  state->fsname_index = 0;
  state->fstype_index = 0;
  D.13745 = quit;
  return D.13745;
}


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.13749;
  gboolean D.13752;
  long unsigned int D.13756;
  long unsigned int D.13757;
  _Bool D.13758;
  int * D.13760;
  int D.13761;
  long unsigned int D.13769;
  long unsigned int D.13770;
  long unsigned int D.13773;
  long unsigned int D.13774;
  long unsigned int D.13780;
  long unsigned int D.13781;
  struct statvfs fsstat;
  gboolean isreadonly;
  gchar * utf8_path_name;
  int ret;
  long unsigned int block_size;

  try
    {
      if (path_name == 0B) goto <D.13747>; else goto <D.13748>;
      <D.13747>:
      D.13749 = monoeg_g_get_current_dir ();
      utf8_path_name = monoeg_strdup (D.13749);
      if (utf8_path_name == 0B) goto <D.13750>; else goto <D.13751>;
      <D.13750>:
      SetLastError (267);
      D.13752 = 0;
      return D.13752;
      <D.13751>:
      goto <D.13753>;
      <D.13748>:
      utf8_path_name = mono_unicode_to_external (path_name);
      if (utf8_path_name == 0B) goto <D.13754>; else goto <D.13755>;
      <D.13754>:
      SetLastError (123);
      D.13752 = 0;
      return D.13752;
      <D.13755>:
      <D.13753>:
      <D.12023>:
      ret = statvfs (utf8_path_name, &fsstat);
      D.13756 = fsstat.f_flag;
      D.13757 = D.13756 & 1;
      D.13758 = D.13757 != 0;
      isreadonly = (gboolean) D.13758;
      block_size = fsstat.f_frsize;
      if (ret == -1) goto <D.13759>; else goto <D.12024>;
      <D.13759>:
      D.13760 = __errno_location ();
      D.13761 = *D.13760;
      if (D.13761 == 4) goto <D.12023>; else goto <D.12024>;
      <D.12024>:
      monoeg_g_free (utf8_path_name);
      if (ret == -1) goto <D.13762>; else goto <D.13763>;
      <D.13762>:
      _wapi_set_last_error_from_errno ();
      D.13752 = 0;
      return D.13752;
      <D.13763>:
      if (free_bytes_avail != 0B) goto <D.13764>; else goto <D.13765>;
      <D.13764>:
      if (isreadonly != 0) goto <D.13766>; else goto <D.13767>;
      <D.13766>:
      free_bytes_avail->QuadPart = 0;
      goto <D.13768>;
      <D.13767>:
      D.13769 = fsstat.f_bavail;
      D.13770 = D.13769 * block_size;
      free_bytes_avail->QuadPart = D.13770;
      <D.13768>:
      <D.13765>:
      if (total_number_of_bytes != 0B) goto <D.13771>; else goto <D.13772>;
      <D.13771>:
      D.13773 = fsstat.f_blocks;
      D.13774 = D.13773 * block_size;
      total_number_of_bytes->QuadPart = D.13774;
      <D.13772>:
      if (total_number_of_free_bytes != 0B) goto <D.13775>; else goto <D.13776>;
      <D.13775>:
      if (isreadonly != 0) goto <D.13777>; else goto <D.13778>;
      <D.13777>:
      total_number_of_free_bytes->QuadPart = 0;
      goto <D.13779>;
      <D.13778>:
      D.13780 = fsstat.f_bfree;
      D.13781 = D.13780 * block_size;
      total_number_of_free_bytes->QuadPart = D.13781;
      <D.13779>:
      <D.13776>:
      D.13752 = 1;
      return D.13752;
    }
  finally
    {
      fsstat = {CLOBBER};
    }
}


GetDriveType (const gunichar2 * root_path_name)
{
  gchar * D.13786;
  guint32 D.13789;
  int D.13793;
  gchar * D.13796;
  char D.13797;
  long unsigned int D.13800;
  sizetype D.13801;
  gchar * D.13802;
  gchar * utf8_root_path_name;
  guint32 drive_type;

  if (root_path_name == 0B) goto <D.13784>; else goto <D.13785>;
  <D.13784>:
  D.13786 = monoeg_g_get_current_dir ();
  utf8_root_path_name = monoeg_strdup (D.13786);
  if (utf8_root_path_name == 0B) goto <D.13787>; else goto <D.13788>;
  <D.13787>:
  D.13789 = 1;
  return D.13789;
  <D.13788>:
  goto <D.13790>;
  <D.13785>:
  utf8_root_path_name = mono_unicode_to_external (root_path_name);
  if (utf8_root_path_name == 0B) goto <D.13791>; else goto <D.13792>;
  <D.13791>:
  D.13789 = 1;
  return D.13789;
  <D.13792>:
  D.13793 = monoeg_g_str_has_suffix (utf8_root_path_name, "/");
  if (D.13793 != 0) goto <D.13794>; else goto <D.13795>;
  <D.13794>:
  D.13796 = utf8_root_path_name + 1;
  D.13797 = *D.13796;
  if (D.13797 != 0) goto <D.13798>; else goto <D.13799>;
  <D.13798>:
  D.13800 = strlen (utf8_root_path_name);
  D.13801 = D.13800 + 18446744073709551615;
  D.13802 = utf8_root_path_name + D.13801;
  *D.13802 = 0;
  <D.13799>:
  <D.13795>:
  <D.13790>:
  drive_type = GetDriveTypeFromPath (utf8_root_path_name);
  monoeg_g_free (utf8_root_path_name);
  D.13789 = drive_type;
  return D.13789;
}


GetDriveTypeFromPath (const char * utf8_root_path_name)
{
  int D.13804;
  guint32 D.13807;
  long int D.13808;
  struct statfs buf;

  try
    {
      D.13804 = statfs (utf8_root_path_name, &buf);
      if (D.13804 == -1) goto <D.13805>; else goto <D.13806>;
      <D.13805>:
      D.13807 = 0;
      return D.13807;
      <D.13806>:
      D.13808 = buf.f_type;
      D.13807 = _wapi_get_drive_type (D.13808);
      return D.13807;
    }
  finally
    {
      buf = {CLOBBER};
    }
}


_wapi_get_drive_type (long int f_type)
{
  long int D.13811;
  guint32 D.13814;
  unsigned int D.13815;
  struct _wapi_drive_type * current;

  current = &_wapi_drive_types[0];
  goto <D.12036>;
  <D.12035>:
  D.13811 = current->fstypeid;
  if (D.13811 == f_type) goto <D.13812>; else goto <D.13813>;
  <D.13812>:
  D.13814 = current->drive_type;
  return D.13814;
  <D.13813>:
  current = current + 24;
  <D.12036>:
  D.13815 = current->drive_type;
  if (D.13815 != 0) goto <D.12035>; else goto <D.12037>;
  <D.12037>:
  D.13814 = 0;
  return D.13814;
}


GetVolumeInformation (const gunichar2 * path, gunichar2 * volumename, int volumesize, int * outserial, int * maxcomp, int * fsflags, gunichar2 * fsbuffer, int fsbuffersize)
{
  gboolean D.13819;
  long int D.13824;
  long int len.67;
  long unsigned int len.68;
  long unsigned int D.13829;
  gunichar2 * D.13830;
  gchar * utfpath;
  gchar * fstypename;
  gboolean status;
  glong len;

  try
    {
      status = 0;
      if (fsbuffer == 0B) goto <D.13817>; else goto <D.13818>;
      <D.13817>:
      D.13819 = 0;
      return D.13819;
      <D.13818>:
      utfpath = mono_unicode_to_external (path);
      fstypename = get_fstypename (utfpath);
      if (fstypename != 0B) goto <D.13820>; else goto <D.13821>;
      <D.13820>:
      {
        gunichar2 * ret;

        ret = monoeg_g_utf8_to_utf16 (fstypename, -1, 0B, &len, 0B);
        if (ret != 0B) goto <D.13822>; else goto <D.13823>;
        <D.13822>:
        D.13824 = (long int) fsbuffersize;
        len.67 = len;
        if (D.13824 > len.67) goto <D.13826>; else goto <D.13827>;
        <D.13826>:
        len.67 = len;
        len.68 = (long unsigned int) len.67;
        D.13829 = len.68 * 2;
        memcpy (fsbuffer, ret, D.13829);
        len.67 = len;
        len.68 = (long unsigned int) len.67;
        D.13829 = len.68 * 2;
        D.13830 = fsbuffer + D.13829;
        *D.13830 = 0;
        status = 1;
        <D.13827>:
        <D.13823>:
        if (ret != 0B) goto <D.13831>; else goto <D.13832>;
        <D.13831>:
        monoeg_g_free (ret);
        <D.13832>:
        monoeg_g_free (fstypename);
      }
      <D.13821>:
      monoeg_g_free (utfpath);
      D.13819 = status;
      return D.13819;
    }
  finally
    {
      len = {CLOBBER};
    }
}


get_fstypename (gchar * utfpath)
{
  int D.13835;
  gchar * D.13838;
  long int D.13839;
  long int D.13840;
  const gchar * D.13843;
  unsigned int D.13844;
  struct statfs stat;
  struct _wapi_drive_type * current;

  try
    {
      D.13835 = statfs (utfpath, &stat);
      if (D.13835 == -1) goto <D.13836>; else goto <D.13837>;
      <D.13836>:
      D.13838 = 0B;
      return D.13838;
      <D.13837>:
      current = &_wapi_drive_types[0];
      goto <D.12053>;
      <D.12052>:
      D.13839 = stat.f_type;
      D.13840 = current->fstypeid;
      if (D.13839 == D.13840) goto <D.13841>; else goto <D.13842>;
      <D.13841>:
      D.13843 = current->fstype;
      D.13838 = monoeg_strdup (D.13843);
      return D.13838;
      <D.13842>:
      current = current + 24;
      <D.12053>:
      D.13844 = current->drive_type;
      if (D.13844 != 0) goto <D.12052>; else goto <D.12054>;
      <D.12054>:
      D.13838 = 0B;
      return D.13838;
    }
  finally
    {
      stat = {CLOBBER};
    }
}


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


