file_close (void * handle, void * data)
{
  unsigned int D.11722;
  unsigned int D.11723;
  gchar * D.11726;
  struct _WapiFileShare * D.11727;
  struct _WapiHandle_file * file_handle;
  int fd;

  file_handle = data;
  fd = file_handle->fd;
  D.11722 = file_handle->attrs;
  D.11723 = D.11722 & 67108864;
  if (D.11723 != 0) goto <D.11724>; else goto <D.11725>;
  <D.11724>:
  D.11726 = file_handle->filename;
  _wapi_unlink (D.11726);
  <D.11725>:
  D.11726 = file_handle->filename;
  monoeg_g_free (D.11726);
  D.11727 = file_handle->share_info;
  if (D.11727 != 0B) goto <D.11728>; else goto <D.11729>;
  <D.11728>:
  D.11727 = file_handle->share_info;
  _wapi_handle_share_release (D.11727);
  <D.11729>:
  close (fd);
}


_wapi_handle_share_release (struct _WapiFileShare * info)
{
  unsigned int D.11730;
  _Bool D.11731;
  long int D.11732;
  long int D.11733;
  _Bool D.11736;
  long int D.11737;
  long int D.11738;
  guint32 * D.11741;
  int D.11742;
  int thr_ret;

  D.11730 = info->handle_refs;
  D.11731 = D.11730 == 0;
  D.11732 = (long int) D.11731;
  D.11733 = __builtin_expect (D.11732, 0);
  if (D.11733 != 0) goto <D.11734>; else goto <D.11735>;
  <D.11734>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "../../mono/io-layer/handles-private.h", 364, "info->handle_refs > 0");
  <D.11735>:
  thr_ret = _wapi_shm_sem_lock (2);
  D.11736 = thr_ret != 0;
  D.11737 = (long int) D.11736;
  D.11738 = __builtin_expect (D.11737, 0);
  if (D.11738 != 0) goto <D.11739>; else goto <D.11740>;
  <D.11739>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "../../mono/io-layer/handles-private.h", 368, "thr_ret == 0");
  <D.11740>:
  D.11741 = &info->handle_refs;
  D.11742 = InterlockedDecrement (D.11741);
  if (D.11742 == 0) goto <D.11743>; else goto <D.11744>;
  <D.11743>:
  _wapi_free_share_info (info);
  <D.11744>:
  thr_ret = _wapi_shm_sem_unlock (2);
}


InterlockedDecrement (volatile gint32 * val)
{
  gint32 D.11745;
  unsigned int D.11746;

  D.11746 = __sync_sub_and_fetch_4 (val, 1);
  D.11745 = (gint32) D.11746;
  return D.11745;
}


_wapi_file_details (void * handle_info)
{
  unsigned int D.11748;
  int iftmp.0;
  unsigned int D.11750;
  unsigned int D.11751;
  int iftmp.1;
  unsigned int D.11756;
  int iftmp.2;
  unsigned int D.11761;
  int iftmp.3;
  unsigned int D.11766;
  unsigned int D.11767;
  int iftmp.4;
  unsigned int D.11772;
  int iftmp.5;
  signed int D.11777;
  gchar * D.11781;
  struct _WapiHandle_file * file;

  file = handle_info;
  D.11748 = file->attrs;
  D.11750 = file->sharemode;
  D.11751 = D.11750 & 4;
  if (D.11751 != 0) goto <D.11752>; else goto <D.11753>;
  <D.11752>:
  iftmp.0 = 68;
  goto <D.11754>;
  <D.11753>:
  iftmp.0 = 46;
  <D.11754>:
  D.11750 = file->sharemode;
  D.11756 = D.11750 & 2;
  if (D.11756 != 0) goto <D.11757>; else goto <D.11758>;
  <D.11757>:
  iftmp.1 = 87;
  goto <D.11759>;
  <D.11758>:
  iftmp.1 = 46;
  <D.11759>:
  D.11750 = file->sharemode;
  D.11761 = D.11750 & 1;
  if (D.11761 != 0) goto <D.11762>; else goto <D.11763>;
  <D.11762>:
  iftmp.2 = 82;
  goto <D.11764>;
  <D.11763>:
  iftmp.2 = 46;
  <D.11764>:
  D.11766 = file->fileaccess;
  D.11767 = D.11766 & 536870912;
  if (D.11767 != 0) goto <D.11768>; else goto <D.11769>;
  <D.11768>:
  iftmp.3 = 88;
  goto <D.11770>;
  <D.11769>:
  iftmp.3 = 46;
  <D.11770>:
  D.11766 = file->fileaccess;
  D.11772 = D.11766 & 1073741824;
  if (D.11772 != 0) goto <D.11773>; else goto <D.11774>;
  <D.11773>:
  iftmp.4 = 87;
  goto <D.11775>;
  <D.11774>:
  iftmp.4 = 46;
  <D.11775>:
  D.11766 = file->fileaccess;
  D.11777 = (signed int) D.11766;
  if (D.11777 < 0) goto <D.11778>; else goto <D.11779>;
  <D.11778>:
  iftmp.5 = 82;
  goto <D.11780>;
  <D.11779>:
  iftmp.5 = 46;
  <D.11780>:
  D.11781 = file->filename;
  monoeg_g_print ("[%20s] acc: %c%c%c, shr: %c%c%c, attrs: %5u", D.11781, iftmp.5, iftmp.4, iftmp.3, iftmp.2, iftmp.1, iftmp.0, D.11748);
}


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

  console_handle = data;
  fd = console_handle->fd;
  D.11782 = console_handle->filename;
  monoeg_g_free (D.11782);
  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.11783;
  unsigned int D.11786;
  void * D.11789;
  int * D.11796;
  int D.11797;
  int D.11800;
  unsigned int fd.6;
  unsigned int _wapi_fd_reserve.7;
  int D.11809;
  struct _WapiFileShare * D.11812;
  unsigned int D.11817;
  unsigned int D.11820;
  unsigned int D.11823;
  unsigned int D.11824;
  <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.11783 = attrs & 256;
      if (D.11783 != 0) goto <D.11784>; else goto <D.11785>;
      <D.11784>:
      perms = 384;
      <D.11785>:
      D.11786 = attrs & 64;
      if (D.11786 != 0) goto <D.11787>; else goto <D.11788>;
      <D.11787>:
      SetLastError (6000);
      D.11789 = 4294967295B;
      return D.11789;
      <D.11788>:
      if (name == 0B) goto <D.11790>; else goto <D.11791>;
      <D.11790>:
      SetLastError (123);
      D.11789 = 4294967295B;
      return D.11789;
      <D.11791>:
      filename = mono_unicode_to_external (name);
      if (filename == 0B) goto <D.11792>; else goto <D.11793>;
      <D.11792>:
      SetLastError (123);
      D.11789 = 4294967295B;
      return D.11789;
      <D.11793>:
      fd = _wapi_open (filename, flags, perms);
      if (fd == -1) goto <D.11794>; else goto <D.11795>;
      <D.11794>:
      D.11796 = __errno_location ();
      D.11797 = *D.11796;
      if (D.11797 == 21) goto <D.11798>; else goto <D.11799>;
      <D.11798>:
      D.11800 = flags & -4;
      fd = _wapi_open (filename, D.11800, perms);
      <D.11799>:
      <D.11795>:
      if (fd == -1) goto <D.11801>; else goto <D.11802>;
      <D.11801>:
      _wapi_set_last_path_error_from_errno (0B, filename);
      monoeg_g_free (filename);
      D.11789 = 4294967295B;
      return D.11789;
      <D.11802>:
      fd.6 = (unsigned int) fd;
      _wapi_fd_reserve.7 = _wapi_fd_reserve;
      if (fd.6 >= _wapi_fd_reserve.7) goto <D.11805>; else goto <D.11806>;
      <D.11805>:
      SetLastError (4);
      close (fd);
      monoeg_g_free (filename);
      D.11789 = 4294967295B;
      return D.11789;
      <D.11806>:
      ret = fstat (fd, &statbuf);
      if (ret == -1) goto <D.11807>; else goto <D.11808>;
      <D.11807>:
      _wapi_set_last_error_from_errno ();
      monoeg_g_free (filename);
      close (fd);
      D.11789 = 4294967295B;
      return D.11789;
      <D.11808>:
      D.11809 = share_check (&statbuf, sharemode, fileaccess, &file_handle.share_info, fd);
      if (D.11809 == 0) goto <D.11810>; else goto <D.11811>;
      <D.11810>:
      SetLastError (32);
      monoeg_g_free (filename);
      close (fd);
      D.11789 = 4294967295B;
      return D.11789;
      <D.11811>:
      D.11812 = file_handle.share_info;
      if (D.11812 == 0B) goto <D.11813>; else goto <D.11814>;
      <D.11813>:
      SetLastError (4);
      close (fd);
      monoeg_g_free (filename);
      D.11789 = 4294967295B;
      return D.11789;
      <D.11814>:
      file_handle.filename = filename;
      if (security != 0B) goto <D.11815>; else goto <D.11816>;
      <D.11815>:
      <D.11816>:
      file_handle.fd = fd;
      file_handle.fileaccess = fileaccess;
      file_handle.sharemode = sharemode;
      file_handle.attrs = attrs;
      D.11817 = attrs & 134217728;
      if (D.11817 != 0) goto <D.11818>; else goto <D.11819>;
      <D.11818>:
      posix_fadvise (fd, 0, 0, 2);
      <D.11819>:
      D.11820 = attrs & 268435456;
      if (D.11820 != 0) goto <D.11821>; else goto <D.11822>;
      <D.11821>:
      posix_fadvise (fd, 0, 0, 1);
      <D.11822>:
      D.11823 = statbuf.st_mode;
      D.11824 = D.11823 & 61440;
      if (D.11824 == 4096) goto <D.11825>; else goto <D.11826>;
      <D.11825>:
      handle_type = 10;
      goto <D.11827>;
      <D.11826>:
      D.11823 = statbuf.st_mode;
      D.11824 = D.11823 & 61440;
      if (D.11824 == 8192) goto <D.11828>; else goto <D.11829>;
      <D.11828>:
      handle_type = 2;
      goto <D.11830>;
      <D.11829>:
      handle_type = 1;
      <D.11830>:
      <D.11827>:
      handle_type.8 = (<unnamed type>) handle_type;
      handle = _wapi_handle_new_fd (handle_type.8, fd, &file_handle);
      if (handle == 4294967295B) goto <D.11832>; else goto <D.11833>;
      <D.11832>:
      monoeg_g_log (0B, 16, "%s: error creating file handle", &__func__);
      monoeg_g_free (filename);
      close (fd);
      SetLastError (31);
      D.11789 = 4294967295B;
      return D.11789;
      <D.11833>:
      D.11789 = handle;
      return D.11789;
    }
  finally
    {
      file_handle = {CLOBBER};
      statbuf = {CLOBBER};
    }
}


io_ops_init ()
{
  const gchar * D.11836;

  D.11836 = monoeg_g_getenv ("MONO_STRICT_IO_EMULATION");
  if (D.11836 != 0B) goto <D.11837>; else goto <D.11838>;
  <D.11837>:
  lock_while_writing = 1;
  <D.11838>:
}


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

  flags = 0;
  switch (fileaccess) <default: <D.11188>, case 1073741824: <D.11186>, case 2147483648: <D.11184>, case 3221225472: <D.11187>>
  <D.11184>:
  flags = 0;
  goto <D.11185>;
  <D.11186>:
  flags = 1;
  goto <D.11185>;
  <D.11187>:
  flags = 2;
  goto <D.11185>;
  <D.11188>:
  goto <D.11185>;
  <D.11185>:
  switch (createmode) <default: <D.11195>, case 1: <D.11189>, case 2: <D.11191>, case 3: <D.11192>, case 4: <D.11193>, case 5: <D.11194>>
  <D.11189>:
  flags = flags | 192;
  goto <D.11190>;
  <D.11191>:
  flags = flags | 576;
  goto <D.11190>;
  <D.11192>:
  goto <D.11190>;
  <D.11193>:
  flags = flags | 64;
  goto <D.11190>;
  <D.11194>:
  flags = flags | 512;
  goto <D.11190>;
  <D.11195>:
  goto <D.11190>;
  <D.11190>:
  D.11839 = flags;
  return D.11839;
}


_wapi_set_last_path_error_from_errno (const gchar * dir, const gchar * path)
{
  int * D.11843;
  int D.11844;
  int D.11850;

  D.11843 = __errno_location ();
  D.11844 = *D.11843;
  if (D.11844 == 2) goto <D.11845>; else goto <D.11846>;
  <D.11845>:
  {
    gchar * dirname;

    if (dir == 0B) goto <D.11847>; else goto <D.11848>;
    <D.11847>:
    dirname = _wapi_dirname (path);
    goto <D.11849>;
    <D.11848>:
    dirname = monoeg_strdup (dir);
    <D.11849>:
    D.11850 = _wapi_access (dirname, 0);
    if (D.11850 == 0) goto <D.11851>; else goto <D.11852>;
    <D.11851>:
    SetLastError (2);
    goto <D.11853>;
    <D.11852>:
    SetLastError (3);
    <D.11853>:
    monoeg_g_free (dirname);
  }
  goto <D.11854>;
  <D.11846>:
  _wapi_set_last_error_from_errno ();
  <D.11854>:
}


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

  if (str != 0B) goto <D.11855>; else goto <D.11856>;
  <D.11855>:
  D.11857 = __strdup (str);
  return D.11857;
  <D.11856>:
  D.11857 = 0B;
  return D.11857;
}


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

  D.11859 = __fxstat (3, __fd, __statbuf);
  return D.11859;
}


_wapi_set_last_error_from_errno ()
{
  int * D.11861;
  int D.11862;
  int D.11863;
  unsigned int D.11864;

  D.11861 = __errno_location ();
  D.11862 = *D.11861;
  D.11863 = _wapi_get_win32_file_error (D.11862);
  D.11864 = (unsigned int) D.11863;
  SetLastError (D.11864);
}


share_check (struct stat * statbuf, guint32 sharemode, guint32 fileaccess, struct _WapiFileShare * * share_info, int fd)
{
  int D.11865;
  gboolean D.11868;
  struct _WapiFileShare * D.11869;
  int D.11870;

  D.11865 = share_allows_open (statbuf, sharemode, fileaccess, share_info);
  if (D.11865 == 1) goto <D.11866>; else goto <D.11867>;
  <D.11866>:
  D.11868 = 1;
  return D.11868;
  <D.11867>:
  D.11869 = *share_info;
  _wapi_handle_check_share (D.11869, fd);
  D.11870 = share_allows_open (statbuf, sharemode, fileaccess, share_info);
  if (D.11870 == 1) goto <D.11871>; else goto <D.11872>;
  <D.11871>:
  D.11868 = 1;
  return D.11868;
  <D.11872>:
  _wapi_handle_collect ();
  D.11868 = share_allows_open (statbuf, sharemode, fileaccess, share_info);
  return D.11868;
}


share_allows_open (struct stat * statbuf, guint32 sharemode, guint32 fileaccess, struct _WapiFileShare * * share_info)
{
  long long unsigned int D.11874;
  long long unsigned int D.11875;
  unsigned int file_existing_share.9;
  struct _WapiFileShare * D.11881;
  gboolean D.11882;
  unsigned int file_existing_access.10;
  signed int file_existing_access.11;
  unsigned int D.11894;
  unsigned int D.11895;
  unsigned int D.11897;
  gboolean file_already_shared;
  guint32 file_existing_share;
  guint32 file_existing_access;

  try
    {
      D.11874 = statbuf->st_ino;
      D.11875 = statbuf->st_dev;
      file_already_shared = _wapi_handle_get_or_set_share (D.11875, D.11874, sharemode, fileaccess, &file_existing_share, &file_existing_access, share_info);
      if (file_already_shared != 0) goto <D.11876>; else goto <D.11877>;
      <D.11876>:
      file_existing_share.9 = file_existing_share;
      if (file_existing_share.9 == 0) goto <D.11879>; else goto <D.11880>;
      <D.11879>:
      D.11881 = *share_info;
      _wapi_handle_share_release (D.11881);
      D.11882 = 0;
      return D.11882;
      <D.11880>:
      file_existing_share.9 = file_existing_share;
      if (file_existing_share.9 == 1) goto <D.11886>; else goto <D.11883>;
      <D.11886>:
      if (fileaccess != 2147483648) goto <D.11884>; else goto <D.11883>;
      <D.11883>:
      file_existing_share.9 = file_existing_share;
      if (file_existing_share.9 == 2) goto <D.11887>; else goto <D.11885>;
      <D.11887>:
      if (fileaccess != 1073741824) goto <D.11884>; else goto <D.11885>;
      <D.11884>:
      D.11881 = *share_info;
      _wapi_handle_share_release (D.11881);
      D.11882 = 0;
      return D.11882;
      <D.11885>:
      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.11893>; else goto <D.11888>;
      <D.11893>:
      D.11894 = sharemode & 1;
      if (D.11894 == 0) goto <D.11889>; else goto <D.11888>;
      <D.11888>:
      file_existing_access.10 = file_existing_access;
      D.11895 = file_existing_access.10 & 1073741824;
      if (D.11895 != 0) goto <D.11896>; else goto <D.11890>;
      <D.11896>:
      D.11897 = sharemode & 2;
      if (D.11897 == 0) goto <D.11889>; else goto <D.11890>;
      <D.11889>:
      D.11881 = *share_info;
      _wapi_handle_share_release (D.11881);
      D.11882 = 0;
      return D.11882;
      <D.11890>:
      goto <D.11898>;
      <D.11877>:
      <D.11898>:
      D.11882 = 1;
      return D.11882;
    }
  finally
    {
      file_existing_share = {CLOBBER};
      file_existing_access = {CLOBBER};
    }
}


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

  ret = 0;
  if (name == 0B) goto <D.11901>; else goto <D.11902>;
  <D.11901>:
  SetLastError (123);
  D.11903 = 0;
  return D.11903;
  <D.11902>:
  filename = mono_unicode_to_external (name);
  if (filename == 0B) goto <D.11904>; else goto <D.11905>;
  <D.11904>:
  SetLastError (123);
  D.11903 = 0;
  return D.11903;
  <D.11905>:
  attrs = GetFileAttributes (name);
  if (attrs == 4294967295) goto <D.11906>; else goto <D.11907>;
  <D.11906>:
  monoeg_g_free (filename);
  D.11903 = 0;
  return D.11903;
  <D.11907>:
  retval = _wapi_unlink (filename);
  if (retval == -1) goto <D.11908>; else goto <D.11909>;
  <D.11908>:
  _wapi_set_last_path_error_from_errno (0B, filename);
  goto <D.11910>;
  <D.11909>:
  ret = 1;
  <D.11910>:
  monoeg_g_free (filename);
  D.11903 = ret;
  return D.11903;
}


MoveFile (const gunichar2 * name, const gunichar2 * dest_name)
{
  gboolean D.11914;
  int D.11921;
  int * D.11926;
  int D.11927;
  int D.11929;
  int D.11930;
  long long unsigned int D.11935;
  long long unsigned int D.11936;
  long long unsigned int D.11938;
  long long unsigned int D.11939;
  int D.11940;
  struct _WapiFileShare * shareinfo.12;
  _Bool D.11948;
  _Bool D.11949;
  _Bool D.11950;
  unsigned int D.11953;
  unsigned int D.11954;
  int D.11957;
  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.11912>; else goto <D.11913>;
      <D.11912>:
      SetLastError (123);
      D.11914 = 0;
      return D.11914;
      <D.11913>:
      utf8_name = mono_unicode_to_external (name);
      if (utf8_name == 0B) goto <D.11915>; else goto <D.11916>;
      <D.11915>:
      SetLastError (123);
      D.11914 = 0;
      return D.11914;
      <D.11916>:
      if (dest_name == 0B) goto <D.11917>; else goto <D.11918>;
      <D.11917>:
      monoeg_g_free (utf8_name);
      SetLastError (123);
      D.11914 = 0;
      return D.11914;
      <D.11918>:
      utf8_dest_name = mono_unicode_to_external (dest_name);
      if (utf8_dest_name == 0B) goto <D.11919>; else goto <D.11920>;
      <D.11919>:
      monoeg_g_free (utf8_name);
      SetLastError (123);
      D.11914 = 0;
      return D.11914;
      <D.11920>:
      D.11921 = _wapi_stat (utf8_name, &stat_src);
      if (D.11921 < 0) goto <D.11922>; else goto <D.11923>;
      <D.11922>:
      D.11926 = __errno_location ();
      D.11927 = *D.11926;
      if (D.11927 != 2) goto <D.11924>; else goto <D.11928>;
      <D.11928>:
      D.11929 = _wapi_lstat (utf8_name, &stat_src);
      if (D.11929 < 0) goto <D.11924>; else goto <D.11925>;
      <D.11924>:
      _wapi_set_last_path_error_from_errno (0B, utf8_name);
      monoeg_g_free (utf8_name);
      monoeg_g_free (utf8_dest_name);
      D.11914 = 0;
      return D.11914;
      <D.11925>:
      <D.11923>:
      D.11930 = _wapi_stat (utf8_dest_name, &stat_dest);
      if (D.11930 == 0) goto <D.11931>; else goto <D.11932>;
      <D.11931>:
      D.11935 = stat_dest.st_dev;
      D.11936 = stat_src.st_dev;
      if (D.11935 != D.11936) goto <D.11933>; else goto <D.11937>;
      <D.11937>:
      D.11938 = stat_dest.st_ino;
      D.11939 = stat_src.st_ino;
      if (D.11938 != D.11939) goto <D.11933>; else goto <D.11934>;
      <D.11933>:
      monoeg_g_free (utf8_name);
      monoeg_g_free (utf8_dest_name);
      SetLastError (183);
      D.11914 = 0;
      return D.11914;
      <D.11934>:
      <D.11932>:
      D.11940 = share_allows_delete (&stat_src, &shareinfo);
      if (D.11940 == 0) goto <D.11941>; else goto <D.11942>;
      <D.11941>:
      SetLastError (32);
      D.11914 = 0;
      return D.11914;
      <D.11942>:
      shareinfo.12 = shareinfo;
      if (shareinfo.12 != 0B) goto <D.11944>; else goto <D.11945>;
      <D.11944>:
      shareinfo.12 = shareinfo;
      _wapi_handle_share_release (shareinfo.12);
      <D.11945>:
      result = _wapi_rename (utf8_name, utf8_dest_name);
      D.11926 = __errno_location ();
      errno_copy = *D.11926;
      if (result == -1) goto <D.11946>; else goto <D.11947>;
      <D.11946>:
      switch (errno_copy) <default: <D.11260>, case 17: <D.11257>, case 18: <D.11259>>
      <D.11257>:
      SetLastError (183);
      goto <D.11258>;
      <D.11259>:
      goto <D.11258>;
      <D.11260>:
      _wapi_set_last_path_error_from_errno (0B, utf8_name);
      <D.11258>:
      <D.11947>:
      monoeg_g_free (utf8_name);
      monoeg_g_free (utf8_dest_name);
      D.11948 = result != 0;
      D.11949 = errno_copy == 18;
      D.11950 = D.11948 & D.11949;
      if (D.11950 != 0) goto <D.11951>; else goto <D.11952>;
      <D.11951>:
      D.11953 = stat_src.st_mode;
      D.11954 = D.11953 & 61440;
      if (D.11954 == 16384) goto <D.11955>; else goto <D.11956>;
      <D.11955>:
      SetLastError (17);
      D.11914 = 0;
      return D.11914;
      <D.11956>:
      D.11957 = CopyFile (name, dest_name, 1);
      if (D.11957 == 0) goto <D.11958>; else goto <D.11959>;
      <D.11958>:
      D.11914 = 0;
      return D.11914;
      <D.11959>:
      D.11914 = DeleteFile (name);
      return D.11914;
      <D.11952>:
      if (result == 0) goto <D.11960>; else goto <D.11961>;
      <D.11960>:
      ret = 1;
      <D.11961>:
      D.11914 = ret;
      return D.11914;
    }
  finally
    {
      stat_src = {CLOBBER};
      stat_dest = {CLOBBER};
      shareinfo = {CLOBBER};
    }
}


share_allows_delete (struct stat * statbuf, struct _WapiFileShare * * share_info)
{
  long long unsigned int D.11965;
  long long unsigned int D.11966;
  unsigned int file_existing_share.13;
  struct _WapiFileShare * D.11972;
  gboolean D.11973;
  unsigned int D.11974;
  gboolean file_already_shared;
  guint32 file_existing_share;
  guint32 file_existing_access;

  try
    {
      D.11965 = statbuf->st_ino;
      D.11966 = statbuf->st_dev;
      file_already_shared = _wapi_handle_get_or_set_share (D.11966, D.11965, 4, 2147483648, &file_existing_share, &file_existing_access, share_info);
      if (file_already_shared != 0) goto <D.11967>; else goto <D.11968>;
      <D.11967>:
      file_existing_share.13 = file_existing_share;
      if (file_existing_share.13 == 0) goto <D.11970>; else goto <D.11971>;
      <D.11970>:
      D.11972 = *share_info;
      _wapi_handle_share_release (D.11972);
      D.11973 = 0;
      return D.11973;
      <D.11971>:
      file_existing_share.13 = file_existing_share;
      D.11974 = file_existing_share.13 & 4;
      if (D.11974 == 0) goto <D.11975>; else goto <D.11976>;
      <D.11975>:
      D.11972 = *share_info;
      _wapi_handle_share_release (D.11972);
      D.11973 = 0;
      return D.11973;
      <D.11976>:
      goto <D.11977>;
      <D.11968>:
      <D.11977>:
      D.11973 = 1;
      return D.11973;
    }
  finally
    {
      file_existing_share = {CLOBBER};
      file_existing_access = {CLOBBER};
    }
}


CopyFile (const gunichar2 * name, const gunichar2 * dest_name, gboolean fail_if_exists)
{
  gboolean D.11982;
  int D.11991;
  int D.11994;
  long long unsigned int D.11997;
  long long unsigned int D.11998;
  long long unsigned int D.12001;
  long long unsigned int D.12002;
  unsigned int D.12007;
  int D.12014;
  long int D.12017;
  long int D.12018;
  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.11980>; else goto <D.11981>;
      <D.11980>:
      SetLastError (123);
      D.11982 = 0;
      return D.11982;
      <D.11981>:
      utf8_src = mono_unicode_to_external (name);
      if (utf8_src == 0B) goto <D.11983>; else goto <D.11984>;
      <D.11983>:
      SetLastError (87);
      D.11982 = 0;
      return D.11982;
      <D.11984>:
      if (dest_name == 0B) goto <D.11985>; else goto <D.11986>;
      <D.11985>:
      monoeg_g_free (utf8_src);
      SetLastError (123);
      D.11982 = 0;
      return D.11982;
      <D.11986>:
      utf8_dest = mono_unicode_to_external (dest_name);
      if (utf8_dest == 0B) goto <D.11987>; else goto <D.11988>;
      <D.11987>:
      SetLastError (87);
      monoeg_g_free (utf8_src);
      D.11982 = 0;
      return D.11982;
      <D.11988>:
      src_fd = _wapi_open (utf8_src, 0, 0);
      if (src_fd < 0) goto <D.11989>; else goto <D.11990>;
      <D.11989>:
      _wapi_set_last_path_error_from_errno (0B, utf8_src);
      monoeg_g_free (utf8_src);
      monoeg_g_free (utf8_dest);
      D.11982 = 0;
      return D.11982;
      <D.11990>:
      D.11991 = fstat (src_fd, &st);
      if (D.11991 < 0) goto <D.11992>; else goto <D.11993>;
      <D.11992>:
      _wapi_set_last_error_from_errno ();
      monoeg_g_free (utf8_src);
      monoeg_g_free (utf8_dest);
      close (src_fd);
      D.11982 = 0;
      return D.11982;
      <D.11993>:
      D.11994 = _wapi_stat (utf8_dest, &dest_st);
      if (D.11994 == 0) goto <D.11995>; else goto <D.11996>;
      <D.11995>:
      D.11997 = st.st_dev;
      D.11998 = dest_st.st_dev;
      if (D.11997 == D.11998) goto <D.11999>; else goto <D.12000>;
      <D.11999>:
      D.12001 = st.st_ino;
      D.12002 = dest_st.st_ino;
      if (D.12001 == D.12002) goto <D.12003>; else goto <D.12004>;
      <D.12003>:
      monoeg_g_free (utf8_src);
      monoeg_g_free (utf8_dest);
      close (src_fd);
      SetLastError (32);
      D.11982 = 0;
      return D.11982;
      <D.12004>:
      <D.12000>:
      <D.11996>:
      if (fail_if_exists != 0) goto <D.12005>; else goto <D.12006>;
      <D.12005>:
      D.12007 = st.st_mode;
      dest_fd = _wapi_open (utf8_dest, 193, D.12007);
      goto <D.12008>;
      <D.12006>:
      D.12007 = st.st_mode;
      dest_fd = _wapi_open (utf8_dest, 513, D.12007);
      if (dest_fd < 0) goto <D.12009>; else goto <D.12010>;
      <D.12009>:
      D.12007 = st.st_mode;
      dest_fd = _wapi_open (utf8_dest, 577, D.12007);
      goto <D.12011>;
      <D.12010>:
      SetLastError (183);
      <D.12011>:
      <D.12008>:
      if (dest_fd < 0) goto <D.12012>; else goto <D.12013>;
      <D.12012>:
      _wapi_set_last_error_from_errno ();
      monoeg_g_free (utf8_src);
      monoeg_g_free (utf8_dest);
      close (src_fd);
      D.11982 = 0;
      return D.11982;
      <D.12013>:
      D.12014 = write_file (src_fd, dest_fd, &st, 1);
      if (D.12014 == 0) goto <D.12015>; else goto <D.12016>;
      <D.12015>:
      ret = 0;
      <D.12016>:
      close (src_fd);
      close (dest_fd);
      D.12017 = st.st_mtim.tv_sec;
      dest_time.modtime = D.12017;
      D.12018 = st.st_atim.tv_sec;
      dest_time.actime = D.12018;
      ret_utime = utime (utf8_dest, &dest_time);
      if (ret_utime == -1) goto <D.12019>; else goto <D.12020>;
      <D.12019>:
      <D.12020>:
      monoeg_g_free (utf8_src);
      monoeg_g_free (utf8_dest);
      D.11982 = ret;
      return D.11982;
    }
  finally
    {
      st = {CLOBBER};
      dest_st = {CLOBBER};
      dest_time = {CLOBBER};
    }
}


write_file (int src_fd, int dest_fd, struct stat * st_src, gboolean report_errors)
{
  int iftmp.14;
  unsigned int buf_size.15;
  int * D.12030;
  int D.12031;
  int D.12034;
  gboolean D.12039;
  unsigned int remain.16;
  int D.12046;
  sizetype n.17;
  int remain;
  int n;
  char * buf;
  char * wbuf;
  int buf_size;

  buf_size = st_src->st_blksize;
  if (buf_size > 8191) goto <D.12024>; else goto <D.12025>;
  <D.12024>:
  iftmp.14 = MIN_EXPR <buf_size, 65536>;
  goto <D.12026>;
  <D.12025>:
  iftmp.14 = 8192;
  <D.12026>:
  buf_size = iftmp.14;
  buf_size.15 = (unsigned int) buf_size;
  buf = malloc (buf_size.15);
  <D.11277>:
  buf_size.15 = (unsigned int) buf_size;
  remain = read (src_fd, buf, buf_size.15);
  if (remain < 0) goto <D.12028>; else goto <D.12029>;
  <D.12028>:
  D.12030 = __errno_location ();
  D.12031 = *D.12030;
  if (D.12031 == 4) goto <D.12032>; else goto <D.12033>;
  <D.12032>:
  D.12034 = _wapi_thread_cur_apc_pending ();
  if (D.12034 == 0) goto <D.12035>; else goto <D.12036>;
  <D.12035>:
  // predicted unlikely by continue predictor.
  goto <D.11272>;
  <D.12036>:
  <D.12033>:
  if (report_errors != 0) goto <D.12037>; else goto <D.12038>;
  <D.12037>:
  _wapi_set_last_error_from_errno ();
  <D.12038>:
  free (buf);
  D.12039 = 0;
  return D.12039;
  <D.12029>:
  if (remain == 0) goto <D.11273>; else goto <D.12040>;
  <D.12040>:
  wbuf = buf;
  goto <D.11274>;
  <D.11275>:
  remain.16 = (unsigned int) remain;
  n = write (dest_fd, wbuf, remain.16);
  if (n < 0) goto <D.12042>; else goto <D.12043>;
  <D.12042>:
  D.12030 = __errno_location ();
  D.12031 = *D.12030;
  if (D.12031 == 4) goto <D.12044>; else goto <D.12045>;
  <D.12044>:
  D.12046 = _wapi_thread_cur_apc_pending ();
  if (D.12046 == 0) goto <D.12047>; else goto <D.12048>;
  <D.12047>:
  // predicted unlikely by continue predictor.
  goto <D.11274>;
  <D.12048>:
  <D.12045>:
  if (report_errors != 0) goto <D.12049>; else goto <D.12050>;
  <D.12049>:
  _wapi_set_last_error_from_errno ();
  <D.12050>:
  free (buf);
  D.12039 = 0;
  return D.12039;
  <D.12043>:
  remain = remain - n;
  n.17 = (sizetype) n;
  wbuf = wbuf + n.17;
  <D.11274>:
  if (remain > 0) goto <D.11275>; else goto <D.11276>;
  <D.11276>:
  <D.11272>:
  goto <D.11277>;
  <D.11273>:
  free (buf);
  D.12039 = 1;
  return D.12039;
}


read (int __fd, void * __buf, size_t __nbytes)
{
  unsigned int D.12053;
  int D.12056;
  ssize_t D.12059;
  unsigned int D.12060;
  unsigned int D.12061;
  unsigned int D.12064;

  D.12053 = __builtin_object_size (__buf, 0);
  if (D.12053 != 4294967295) goto <D.12054>; else goto <D.12055>;
  <D.12054>:
  D.12056 = __builtin_constant_p (__nbytes);
  if (D.12056 == 0) goto <D.12057>; else goto <D.12058>;
  <D.12057>:
  D.12060 = __builtin_object_size (__buf, 0);
  D.12059 = __read_chk (__fd, __buf, __nbytes, D.12060);
  return D.12059;
  <D.12058>:
  D.12061 = __builtin_object_size (__buf, 0);
  if (D.12061 < __nbytes) goto <D.12062>; else goto <D.12063>;
  <D.12062>:
  D.12064 = __builtin_object_size (__buf, 0);
  D.12059 = __read_chk_warn (__fd, __buf, __nbytes, D.12064);
  return D.12059;
  <D.12063>:
  <D.12055>:
  D.12059 = __read_alias (__fd, __buf, __nbytes);
  return D.12059;
}


ReplaceFile (const gunichar2 * replacedFileName, const gunichar2 * replacementFileName, const gunichar2 * backupFileName, guint32 replaceFlags, void * exclude, void * reserved)
{
  gboolean D.12068;
  int * D.12075;
  int D.12081;
  unsigned int D.12084;
  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.12066>; else goto <D.12067>;
      <D.12066>:
      D.12068 = 0;
      return D.12068;
      <D.12067>:
      utf8_replacementFileName = convert_arg_to_utf8 (replacementFileName, "replacementFileName");
      if (utf8_replacementFileName == 0B) goto replace_cleanup; else goto <D.12069>;
      <D.12069>:
      if (backupFileName != 0B) goto <D.12070>; else goto <D.12071>;
      <D.12070>:
      utf8_backupFileName = convert_arg_to_utf8 (backupFileName, "backupFileName");
      if (utf8_backupFileName == 0B) goto replace_cleanup; else goto <D.12072>;
      <D.12072>:
      <D.12071>:
      if (utf8_backupFileName != 0B) goto <D.12073>; else goto <D.12074>;
      <D.12073>:
      backup_fd = _wapi_open (utf8_backupFileName, 0, 0);
      result = _wapi_rename (utf8_replacedFileName, utf8_backupFileName);
      D.12075 = __errno_location ();
      errno_copy = *D.12075;
      if (result == -1) goto replace_cleanup; else goto <D.12076>;
      <D.12076>:
      <D.12074>:
      result = _wapi_rename (utf8_replacementFileName, utf8_replacedFileName);
      D.12075 = __errno_location ();
      errno_copy = *D.12075;
      if (result == -1) goto <D.12077>; else goto <D.12078>;
      <D.12077>:
      _wapi_set_last_path_error_from_errno (0B, utf8_replacementFileName);
      _wapi_rename (utf8_backupFileName, utf8_replacedFileName);
      if (backup_fd != -1) goto <D.12079>; else goto <D.12080>;
      <D.12079>:
      D.12081 = fstat (backup_fd, &stBackup);
      if (D.12081 == 0) goto <D.12082>; else goto <D.12083>;
      <D.12082>:
      D.12084 = stBackup.st_mode;
      replaced_fd = _wapi_open (utf8_backupFileName, 577, D.12084);
      if (replaced_fd == -1) goto replace_cleanup; else goto <D.12085>;
      <D.12085>:
      write_file (backup_fd, replaced_fd, &stBackup, 0);
      <D.12083>:
      <D.12080>:
      goto replace_cleanup;
      <D.12078>:
      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.12086>; else goto <D.12087>;
      <D.12086>:
      close (backup_fd);
      <D.12087>:
      if (replaced_fd != -1) goto <D.12088>; else goto <D.12089>;
      <D.12088>:
      close (replaced_fd);
      <D.12089>:
      D.12068 = ret;
      return D.12068;
    }
  finally
    {
      stBackup = {CLOBBER};
    }
}


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

  if (arg == 0B) goto <D.12092>; else goto <D.12093>;
  <D.12092>:
  SetLastError (123);
  D.12094 = 0B;
  return D.12094;
  <D.12093>:
  utf8_ret = mono_unicode_to_external (arg);
  if (utf8_ret == 0B) goto <D.12095>; else goto <D.12096>;
  <D.12095>:
  SetLastError (87);
  D.12094 = 0B;
  return D.12094;
  <D.12096>:
  D.12094 = utf8_ret;
  return D.12094;
}


GetStdHandle (WapiStdHandle stdhandle)
{
  void * D.12098;
  long int D.12099;
  _Bool D.12102;
  long int D.12103;
  long int D.12104;
  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.11329>, case -12: <D.11328>, case -11: <D.11327>, case -10: <D.11325>>
      <D.11325>:
      fd = 0;
      name = "<stdin>";
      goto <D.11326>;
      <D.11327>:
      fd = 1;
      name = "<stdout>";
      goto <D.11326>;
      <D.11328>:
      fd = 2;
      name = "<stderr>";
      goto <D.11326>;
      <D.11329>:
      SetLastError (87);
      D.12098 = 4294967295B;
      return D.12098;
      <D.11326>:
      handle = (void *) fd;
      {
        struct __pthread_unwind_buf_t __cancel_buf;
        void (*<Tbf>) (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.12099 = __builtin_expect (__not_first_call, 0);
            if (D.12099 != 0) goto <D.12100>; else goto <D.12101>;
            <D.12100>:
            __cancel_routine (__cancel_arg);
            __pthread_unwind_next (&__cancel_buf);
            <D.12101>:
            __pthread_register_cancel (&__cancel_buf);
            thr_ret = pthread_mutex_lock (&stdhandle_mutex);
            D.12102 = thr_ret != 0;
            D.12103 = (long int) D.12102;
            D.12104 = __builtin_expect (D.12103, 0);
            if (D.12104 != 0) goto <D.12105>; else goto <D.12106>;
            <D.12105>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "io.c", 2187, "thr_ret == 0");
            <D.12106>:
            ok = _wapi_lookup_handle (handle, 2, &file_handle);
            if (ok == 0) goto <D.12107>; else goto <D.12108>;
            <D.12107>:
            handle = _wapi_stdhandle_create (fd, name);
            if (handle == 4294967295B) goto <D.12109>; else goto <D.12110>;
            <D.12109>:
            SetLastError (18);
            goto done;
            <D.12110>:
            goto <D.12111>;
            <D.12108>:
            _wapi_handle_ref (handle);
            <D.12111>:
            done:
            thr_ret = pthread_mutex_unlock (&stdhandle_mutex);
            D.12102 = thr_ret != 0;
            D.12103 = (long int) D.12102;
            D.12104 = __builtin_expect (D.12103, 0);
            if (D.12104 != 0) goto <D.12112>; else goto <D.12113>;
            <D.12112>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "io.c", 2206, "thr_ret == 0");
            <D.12113>:
            __pthread_unregister_cancel (&__cancel_buf);
            if (0 != 0) goto <D.12114>; else goto <D.12115>;
            <D.12114>:
            __cancel_routine (__cancel_arg);
            <D.12115>:
          }
        finally
          {
            __cancel_buf = {CLOBBER};
          }
      }
      D.12098 = handle;
      return D.12098;
    }
  finally
    {
      file_handle = {CLOBBER};
    }
}


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

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


ReadFile (void * handle, void * buffer, guint32 numbytes, guint32 * bytesread, struct WapiOverlapped * overlapped)
{
  gboolean (*<T1a8c>) (void *, void *, guint32, guint32 *, struct WapiOverlapped *) D.12124;
  gboolean D.12127;
  WapiHandleType type;

  type = _wapi_handle_type (handle);
  D.12124 = io_ops[type].readfile;
  if (D.12124 == 0B) goto <D.12125>; else goto <D.12126>;
  <D.12125>:
  SetLastError (6);
  D.12127 = 0;
  return D.12127;
  <D.12126>:
  D.12124 = io_ops[type].readfile;
  D.12127 = D.12124 (handle, buffer, numbytes, bytesread, overlapped);
  return D.12127;
}


pipe_write (void * handle, const void * buffer, guint32 numbytes, guint32 * byteswritten, struct WapiOverlapped * overlapped)
{
  gboolean D.12131;
  struct _WapiHandle_file * pipe_handle.18;
  unsigned int D.12135;
  unsigned int D.12136;
  int * D.12140;
  int D.12141;
  int D.12143;
  unsigned int ret.19;
  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.12129>; else goto <D.12130>;
      <D.12129>:
      monoeg_g_log (0B, 16, "%s: error looking up pipe handle %p", &__func__, handle);
      SetLastError (6);
      D.12131 = 0;
      return D.12131;
      <D.12130>:
      pipe_handle.18 = pipe_handle;
      fd = pipe_handle.18->fd;
      if (byteswritten != 0B) goto <D.12133>; else goto <D.12134>;
      <D.12133>:
      *byteswritten = 0;
      <D.12134>:
      pipe_handle.18 = pipe_handle;
      D.12135 = BIT_FIELD_REF <*pipe_handle.18, 32, 128>;
      D.12136 = D.12135 & 1342177280;
      if (D.12136 == 0) goto <D.12137>; else goto <D.12138>;
      <D.12137>:
      SetLastError (5);
      D.12131 = 0;
      return D.12131;
      <D.12138>:
      <D.11177>:
      ret = write (fd, buffer, numbytes);
      if (ret == -1) goto <D.12139>; else goto <D.11178>;
      <D.12139>:
      D.12140 = __errno_location ();
      D.12141 = *D.12140;
      if (D.12141 == 4) goto <D.12142>; else goto <D.11178>;
      <D.12142>:
      D.12143 = _wapi_thread_cur_apc_pending ();
      if (D.12143 == 0) goto <D.11177>; else goto <D.11178>;
      <D.11178>:
      if (ret == -1) goto <D.12144>; else goto <D.12145>;
      <D.12144>:
      D.12140 = __errno_location ();
      D.12141 = *D.12140;
      if (D.12141 == 4) goto <D.12146>; else goto <D.12147>;
      <D.12146>:
      ret = 0;
      goto <D.12148>;
      <D.12147>:
      _wapi_set_last_error_from_errno ();
      D.12131 = 0;
      return D.12131;
      <D.12148>:
      <D.12145>:
      if (byteswritten != 0B) goto <D.12149>; else goto <D.12150>;
      <D.12149>:
      ret.19 = (unsigned int) ret;
      *byteswritten = ret.19;
      <D.12150>:
      D.12131 = 1;
      return D.12131;
    }
  finally
    {
      pipe_handle = {CLOBBER};
    }
}


pipe_read (void * handle, void * buffer, guint32 numbytes, guint32 * bytesread, struct WapiOverlapped * overlapped)
{
  gboolean D.12156;
  struct _WapiHandle_file * pipe_handle.20;
  unsigned int D.12160;
  signed int D.12161;
  unsigned int D.12164;
  int * D.12168;
  int D.12169;
  int D.12171;
  unsigned int ret.21;
  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.12154>; else goto <D.12155>;
      <D.12154>:
      monoeg_g_log (0B, 16, "%s: error looking up pipe handle %p", &__func__, handle);
      SetLastError (6);
      D.12156 = 0;
      return D.12156;
      <D.12155>:
      pipe_handle.20 = pipe_handle;
      fd = pipe_handle.20->fd;
      if (bytesread != 0B) goto <D.12158>; else goto <D.12159>;
      <D.12158>:
      *bytesread = 0;
      <D.12159>:
      pipe_handle.20 = pipe_handle;
      D.12160 = pipe_handle.20->fileaccess;
      D.12161 = (signed int) D.12160;
      if (D.12161 >= 0) goto <D.12162>; else goto <D.12163>;
      <D.12162>:
      pipe_handle.20 = pipe_handle;
      D.12160 = pipe_handle.20->fileaccess;
      D.12164 = D.12160 & 268435456;
      if (D.12164 == 0) goto <D.12165>; else goto <D.12166>;
      <D.12165>:
      SetLastError (5);
      D.12156 = 0;
      return D.12156;
      <D.12166>:
      <D.12163>:
      <D.11163>:
      ret = read (fd, buffer, numbytes);
      if (ret == -1) goto <D.12167>; else goto <D.11164>;
      <D.12167>:
      D.12168 = __errno_location ();
      D.12169 = *D.12168;
      if (D.12169 == 4) goto <D.12170>; else goto <D.11164>;
      <D.12170>:
      D.12171 = _wapi_thread_cur_apc_pending ();
      if (D.12171 == 0) goto <D.11163>; else goto <D.11164>;
      <D.11164>:
      if (ret == -1) goto <D.12172>; else goto <D.12173>;
      <D.12172>:
      D.12168 = __errno_location ();
      D.12169 = *D.12168;
      if (D.12169 == 4) goto <D.12174>; else goto <D.12175>;
      <D.12174>:
      ret = 0;
      goto <D.12176>;
      <D.12175>:
      _wapi_set_last_error_from_errno ();
      D.12156 = 0;
      return D.12156;
      <D.12176>:
      <D.12173>:
      if (bytesread != 0B) goto <D.12177>; else goto <D.12178>;
      <D.12177>:
      ret.21 = (unsigned int) ret;
      *bytesread = ret.21;
      <D.12178>:
      D.12156 = 1;
      return D.12156;
    }
  finally
    {
      pipe_handle = {CLOBBER};
    }
}


pipe_getfiletype ()
{
  WapiFileType D.12182;

  D.12182 = 3;
  return D.12182;
}


console_write (void * handle, const void * buffer, guint32 numbytes, guint32 * byteswritten, struct WapiOverlapped * overlapped)
{
  gboolean D.12186;
  struct _WapiHandle_file * console_handle.22;
  unsigned int D.12190;
  unsigned int D.12191;
  int * D.12195;
  int D.12196;
  int D.12198;
  unsigned int ret.23;
  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.12184>; else goto <D.12185>;
      <D.12184>:
      monoeg_g_log (0B, 16, "%s: error looking up console handle %p", &__func__, handle);
      SetLastError (6);
      D.12186 = 0;
      return D.12186;
      <D.12185>:
      console_handle.22 = console_handle;
      fd = console_handle.22->fd;
      if (byteswritten != 0B) goto <D.12188>; else goto <D.12189>;
      <D.12188>:
      *byteswritten = 0;
      <D.12189>:
      console_handle.22 = console_handle;
      D.12190 = BIT_FIELD_REF <*console_handle.22, 32, 128>;
      D.12191 = D.12190 & 1342177280;
      if (D.12191 == 0) goto <D.12192>; else goto <D.12193>;
      <D.12192>:
      SetLastError (5);
      D.12186 = 0;
      return D.12186;
      <D.12193>:
      <D.11140>:
      ret = write (fd, buffer, numbytes);
      if (ret == -1) goto <D.12194>; else goto <D.11141>;
      <D.12194>:
      D.12195 = __errno_location ();
      D.12196 = *D.12195;
      if (D.12196 == 4) goto <D.12197>; else goto <D.11141>;
      <D.12197>:
      D.12198 = _wapi_thread_cur_apc_pending ();
      if (D.12198 == 0) goto <D.11140>; else goto <D.11141>;
      <D.11141>:
      if (ret == -1) goto <D.12199>; else goto <D.12200>;
      <D.12199>:
      D.12195 = __errno_location ();
      D.12196 = *D.12195;
      if (D.12196 == 4) goto <D.12201>; else goto <D.12202>;
      <D.12201>:
      ret = 0;
      goto <D.12203>;
      <D.12202>:
      _wapi_set_last_error_from_errno ();
      D.12186 = 0;
      return D.12186;
      <D.12203>:
      <D.12200>:
      if (byteswritten != 0B) goto <D.12204>; else goto <D.12205>;
      <D.12204>:
      ret.23 = (unsigned int) ret;
      *byteswritten = ret.23;
      <D.12205>:
      D.12186 = 1;
      return D.12186;
    }
  finally
    {
      console_handle = {CLOBBER};
    }
}


console_read (void * handle, void * buffer, guint32 numbytes, guint32 * bytesread, struct WapiOverlapped * overlapped)
{
  gboolean D.12211;
  struct _WapiHandle_file * console_handle.24;
  unsigned int D.12215;
  signed int D.12216;
  unsigned int D.12219;
  int * D.12223;
  int D.12224;
  int D.12226;
  unsigned int ret.25;
  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.12209>; else goto <D.12210>;
      <D.12209>:
      monoeg_g_log (0B, 16, "%s: error looking up console handle %p", &__func__, handle);
      SetLastError (6);
      D.12211 = 0;
      return D.12211;
      <D.12210>:
      console_handle.24 = console_handle;
      fd = console_handle.24->fd;
      if (bytesread != 0B) goto <D.12213>; else goto <D.12214>;
      <D.12213>:
      *bytesread = 0;
      <D.12214>:
      console_handle.24 = console_handle;
      D.12215 = console_handle.24->fileaccess;
      D.12216 = (signed int) D.12215;
      if (D.12216 >= 0) goto <D.12217>; else goto <D.12218>;
      <D.12217>:
      console_handle.24 = console_handle;
      D.12215 = console_handle.24->fileaccess;
      D.12219 = D.12215 & 268435456;
      if (D.12219 == 0) goto <D.12220>; else goto <D.12221>;
      <D.12220>:
      SetLastError (5);
      D.12211 = 0;
      return D.12211;
      <D.12221>:
      <D.12218>:
      <D.11126>:
      ret = read (fd, buffer, numbytes);
      if (ret == -1) goto <D.12222>; else goto <D.11127>;
      <D.12222>:
      D.12223 = __errno_location ();
      D.12224 = *D.12223;
      if (D.12224 == 4) goto <D.12225>; else goto <D.11127>;
      <D.12225>:
      D.12226 = _wapi_thread_cur_apc_pending ();
      if (D.12226 == 0) goto <D.11126>; else goto <D.11127>;
      <D.11127>:
      if (ret == -1) goto <D.12227>; else goto <D.12228>;
      <D.12227>:
      _wapi_set_last_error_from_errno ();
      D.12211 = 0;
      return D.12211;
      <D.12228>:
      if (bytesread != 0B) goto <D.12229>; else goto <D.12230>;
      <D.12229>:
      ret.25 = (unsigned int) ret;
      *bytesread = ret.25;
      <D.12230>:
      D.12211 = 1;
      return D.12211;
    }
  finally
    {
      console_handle = {CLOBBER};
    }
}


console_getfiletype ()
{
  WapiFileType D.12234;

  D.12234 = 2;
  return D.12234;
}


file_setfiletime (void * handle, const struct WapiFileTime * create_time, const struct WapiFileTime * last_access, const struct WapiFileTime * last_write)
{
  gboolean D.12238;
  struct _WapiHandle_file * file_handle.26;
  unsigned int D.12240;
  unsigned int D.12241;
  gchar * D.12244;
  unsigned int D.12251;
  long long unsigned int D.12252;
  long long unsigned int D.12253;
  unsigned int D.12254;
  long long unsigned int D.12255;
  long long unsigned int D.12258;
  long long unsigned int D.12259;
  long int D.12260;
  long int D.12262;
  unsigned int D.12265;
  long long unsigned int D.12266;
  long long unsigned int D.12267;
  unsigned int D.12268;
  long long unsigned int D.12269;
  long long unsigned int D.12272;
  long long unsigned int D.12273;
  long int D.12274;
  long int D.12276;
  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.12236>; else goto <D.12237>;
      <D.12236>:
      monoeg_g_log (0B, 16, "%s: error looking up file handle %p", &__func__, handle);
      SetLastError (6);
      D.12238 = 0;
      return D.12238;
      <D.12237>:
      file_handle.26 = file_handle;
      fd = file_handle.26->fd;
      file_handle.26 = file_handle;
      D.12240 = BIT_FIELD_REF <*file_handle.26, 32, 128>;
      D.12241 = D.12240 & 1342177280;
      if (D.12241 == 0) goto <D.12242>; else goto <D.12243>;
      <D.12242>:
      SetLastError (5);
      D.12238 = 0;
      return D.12238;
      <D.12243>:
      file_handle.26 = file_handle;
      D.12244 = file_handle.26->filename;
      if (D.12244 == 0B) goto <D.12245>; else goto <D.12246>;
      <D.12245>:
      SetLastError (6);
      D.12238 = 0;
      return D.12238;
      <D.12246>:
      ret = fstat (fd, &statbuf);
      if (ret == -1) goto <D.12247>; else goto <D.12248>;
      <D.12247>:
      SetLastError (87);
      D.12238 = 0;
      return D.12238;
      <D.12248>:
      if (last_access != 0B) goto <D.12249>; else goto <D.12250>;
      <D.12249>:
      D.12251 = last_access->dwHighDateTime;
      D.12252 = (long long unsigned int) D.12251;
      D.12253 = D.12252 << 32;
      D.12254 = last_access->dwLowDateTime;
      D.12255 = (long long unsigned int) D.12254;
      access_ticks = D.12253 + D.12255;
      if (access_ticks <= 116444735999999999) goto <D.12256>; else goto <D.12257>;
      <D.12256>:
      SetLastError (87);
      D.12238 = 0;
      return D.12238;
      <D.12257>:
      D.12258 = access_ticks + 18330299337709551616;
      D.12259 = D.12258 / 10000000;
      D.12260 = (long int) D.12259;
      utbuf.actime = D.12260;
      goto <D.12261>;
      <D.12250>:
      D.12262 = statbuf.st_atim.tv_sec;
      utbuf.actime = D.12262;
      <D.12261>:
      if (last_write != 0B) goto <D.12263>; else goto <D.12264>;
      <D.12263>:
      D.12265 = last_write->dwHighDateTime;
      D.12266 = (long long unsigned int) D.12265;
      D.12267 = D.12266 << 32;
      D.12268 = last_write->dwLowDateTime;
      D.12269 = (long long unsigned int) D.12268;
      write_ticks = D.12267 + D.12269;
      if (write_ticks <= 116444735999999999) goto <D.12270>; else goto <D.12271>;
      <D.12270>:
      SetLastError (87);
      D.12238 = 0;
      return D.12238;
      <D.12271>:
      D.12272 = write_ticks + 18330299337709551616;
      D.12273 = D.12272 / 10000000;
      D.12274 = (long int) D.12273;
      utbuf.modtime = D.12274;
      goto <D.12275>;
      <D.12264>:
      D.12276 = statbuf.st_mtim.tv_sec;
      utbuf.modtime = D.12276;
      <D.12275>:
      file_handle.26 = file_handle;
      D.12244 = file_handle.26->filename;
      ret = _wapi_utime (D.12244, &utbuf);
      if (ret == -1) goto <D.12277>; else goto <D.12278>;
      <D.12277>:
      SetLastError (87);
      D.12238 = 0;
      return D.12238;
      <D.12278>:
      D.12238 = 1;
      return D.12238;
    }
  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.12283;
  struct _WapiHandle_file * file_handle.27;
  unsigned int D.12285;
  signed int D.12286;
  unsigned int D.12289;
  long int D.12294;
  long int D.12295;
  long long unsigned int D.12298;
  long long unsigned int D.12299;
  long long unsigned int D.12301;
  long long unsigned int D.12302;
  long int D.12303;
  long long unsigned int D.12304;
  long long unsigned int D.12305;
  unsigned int D.12308;
  long long unsigned int D.12309;
  unsigned int D.12310;
  unsigned int D.12313;
  long long unsigned int D.12314;
  unsigned int D.12315;
  unsigned int D.12318;
  long long unsigned int D.12319;
  unsigned int D.12320;
  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.12281>; else goto <D.12282>;
      <D.12281>:
      monoeg_g_log (0B, 16, "%s: error looking up file handle %p", &__func__, handle);
      SetLastError (6);
      D.12283 = 0;
      return D.12283;
      <D.12282>:
      file_handle.27 = file_handle;
      fd = file_handle.27->fd;
      file_handle.27 = file_handle;
      D.12285 = file_handle.27->fileaccess;
      D.12286 = (signed int) D.12285;
      if (D.12286 >= 0) goto <D.12287>; else goto <D.12288>;
      <D.12287>:
      file_handle.27 = file_handle;
      D.12285 = file_handle.27->fileaccess;
      D.12289 = D.12285 & 268435456;
      if (D.12289 == 0) goto <D.12290>; else goto <D.12291>;
      <D.12290>:
      SetLastError (5);
      D.12283 = 0;
      return D.12283;
      <D.12291>:
      <D.12288>:
      ret = fstat (fd, &statbuf);
      if (ret == -1) goto <D.12292>; else goto <D.12293>;
      <D.12292>:
      _wapi_set_last_error_from_errno ();
      D.12283 = 0;
      return D.12283;
      <D.12293>:
      D.12294 = statbuf.st_atim.tv_sec;
      D.12295 = statbuf.st_ctim.tv_sec;
      if (D.12294 < D.12295) goto <D.12296>; else goto <D.12297>;
      <D.12296>:
      D.12294 = statbuf.st_atim.tv_sec;
      D.12298 = (long long unsigned int) D.12294;
      D.12299 = D.12298 * 10000000;
      create_ticks = D.12299 + 116444736000000000;
      goto <D.12300>;
      <D.12297>:
      D.12295 = statbuf.st_ctim.tv_sec;
      D.12301 = (long long unsigned int) D.12295;
      D.12302 = D.12301 * 10000000;
      create_ticks = D.12302 + 116444736000000000;
      <D.12300>:
      D.12294 = statbuf.st_atim.tv_sec;
      D.12298 = (long long unsigned int) D.12294;
      D.12299 = D.12298 * 10000000;
      access_ticks = D.12299 + 116444736000000000;
      D.12303 = statbuf.st_mtim.tv_sec;
      D.12304 = (long long unsigned int) D.12303;
      D.12305 = D.12304 * 10000000;
      write_ticks = D.12305 + 116444736000000000;
      if (create_time != 0B) goto <D.12306>; else goto <D.12307>;
      <D.12306>:
      D.12308 = (unsigned int) create_ticks;
      create_time->dwLowDateTime = D.12308;
      D.12309 = create_ticks >> 32;
      D.12310 = (unsigned int) D.12309;
      create_time->dwHighDateTime = D.12310;
      <D.12307>:
      if (last_access != 0B) goto <D.12311>; else goto <D.12312>;
      <D.12311>:
      D.12313 = (unsigned int) access_ticks;
      last_access->dwLowDateTime = D.12313;
      D.12314 = access_ticks >> 32;
      D.12315 = (unsigned int) D.12314;
      last_access->dwHighDateTime = D.12315;
      <D.12312>:
      if (last_write != 0B) goto <D.12316>; else goto <D.12317>;
      <D.12316>:
      D.12318 = (unsigned int) write_ticks;
      last_write->dwLowDateTime = D.12318;
      D.12319 = write_ticks >> 32;
      D.12320 = (unsigned int) D.12319;
      last_write->dwHighDateTime = D.12320;
      <D.12317>:
      D.12283 = 1;
      return D.12283;
    }
  finally
    {
      file_handle = {CLOBBER};
      statbuf = {CLOBBER};
    }
}


file_getfilesize (void * handle, guint32 * highsize)
{
  guint32 D.12325;
  struct _WapiHandle_file * file_handle.28;
  unsigned int D.12327;
  signed int D.12328;
  unsigned int D.12331;
  unsigned int D.12332;
  unsigned int D.12337;
  unsigned int D.12338;
  int D.12341;
  long long unsigned int bigsize.29;
  long long unsigned int D.12347;
  unsigned int D.12348;
  long long int D.12349;
  long long int D.12352;
  unsigned int D.12353;
  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.12323>; else goto <D.12324>;
      <D.12323>:
      monoeg_g_log (0B, 16, "%s: error looking up file handle %p", &__func__, handle);
      SetLastError (6);
      D.12325 = 4294967295;
      return D.12325;
      <D.12324>:
      file_handle.28 = file_handle;
      fd = file_handle.28->fd;
      file_handle.28 = file_handle;
      D.12327 = file_handle.28->fileaccess;
      D.12328 = (signed int) D.12327;
      if (D.12328 >= 0) goto <D.12329>; else goto <D.12330>;
      <D.12329>:
      file_handle.28 = file_handle;
      D.12331 = BIT_FIELD_REF <*file_handle.28, 32, 128>;
      D.12332 = D.12331 & 1342177280;
      if (D.12332 == 0) goto <D.12333>; else goto <D.12334>;
      <D.12333>:
      SetLastError (5);
      D.12325 = 4294967295;
      return D.12325;
      <D.12334>:
      <D.12330>:
      SetLastError (0);
      ret = fstat (fd, &statbuf);
      if (ret == -1) goto <D.12335>; else goto <D.12336>;
      <D.12335>:
      _wapi_set_last_error_from_errno ();
      D.12325 = 4294967295;
      return D.12325;
      <D.12336>:
      D.12337 = statbuf.st_mode;
      D.12338 = D.12337 & 61440;
      if (D.12338 == 24576) goto <D.12339>; else goto <D.12340>;
      <D.12339>:
      {
        guint64 bigsize;

        try
          {
            D.12341 = ioctl (fd, 2147750514, &bigsize);
            if (D.12341 < 0) goto <D.12342>; else goto <D.12343>;
            <D.12342>:
            _wapi_set_last_error_from_errno ();
            D.12325 = 4294967295;
            return D.12325;
            <D.12343>:
            bigsize.29 = bigsize;
            size = (guint32) bigsize.29;
            if (highsize != 0B) goto <D.12345>; else goto <D.12346>;
            <D.12345>:
            bigsize.29 = bigsize;
            D.12347 = bigsize.29 >> 32;
            D.12348 = (unsigned int) D.12347;
            *highsize = D.12348;
            <D.12346>:
            D.12325 = size;
            return D.12325;
          }
        finally
          {
            bigsize = {CLOBBER};
          }
      }
      <D.12340>:
      D.12349 = statbuf.st_size;
      size = (guint32) D.12349;
      if (highsize != 0B) goto <D.12350>; else goto <D.12351>;
      <D.12350>:
      D.12349 = statbuf.st_size;
      D.12352 = D.12349 >> 32;
      D.12353 = (unsigned int) D.12352;
      *highsize = D.12353;
      <D.12351>:
      D.12325 = size;
      return D.12325;
    }
  finally
    {
      file_handle = {CLOBBER};
      statbuf = {CLOBBER};
    }
}


file_setendoffile (void * handle)
{
  gboolean D.12359;
  struct _WapiHandle_file * file_handle.30;
  unsigned int D.12361;
  unsigned int D.12362;
  int * D.12370;
  int D.12371;
  int D.12373;
  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.12357>; else goto <D.12358>;
      <D.12357>:
      monoeg_g_log (0B, 16, "%s: error looking up file handle %p", &__func__, handle);
      SetLastError (6);
      D.12359 = 0;
      return D.12359;
      <D.12358>:
      file_handle.30 = file_handle;
      fd = file_handle.30->fd;
      file_handle.30 = file_handle;
      D.12361 = BIT_FIELD_REF <*file_handle.30, 32, 128>;
      D.12362 = D.12361 & 1342177280;
      if (D.12362 == 0) goto <D.12363>; else goto <D.12364>;
      <D.12363>:
      SetLastError (5);
      D.12359 = 0;
      return D.12359;
      <D.12364>:
      ret = fstat (fd, &statbuf);
      if (ret == -1) goto <D.12365>; else goto <D.12366>;
      <D.12365>:
      _wapi_set_last_error_from_errno ();
      D.12359 = 0;
      return D.12359;
      <D.12366>:
      size = statbuf.st_size;
      pos = lseek (fd, 0, 1);
      if (pos == -1) goto <D.12367>; else goto <D.12368>;
      <D.12367>:
      _wapi_set_last_error_from_errno ();
      D.12359 = 0;
      return D.12359;
      <D.12368>:
      <D.11061>:
      ret = ftruncate (fd, pos);
      if (ret == -1) goto <D.12369>; else goto <D.11062>;
      <D.12369>:
      D.12370 = __errno_location ();
      D.12371 = *D.12370;
      if (D.12371 == 4) goto <D.12372>; else goto <D.11062>;
      <D.12372>:
      D.12373 = _wapi_thread_cur_apc_pending ();
      if (D.12373 == 0) goto <D.11061>; else goto <D.11062>;
      <D.11062>:
      if (ret == -1) goto <D.12374>; else goto <D.12375>;
      <D.12374>:
      _wapi_set_last_error_from_errno ();
      D.12359 = 0;
      return D.12359;
      <D.12375>:
      D.12359 = 1;
      return D.12359;
    }
  finally
    {
      file_handle = {CLOBBER};
      statbuf = {CLOBBER};
    }
}


file_seek (void * handle, gint32 movedistance, gint32 * highmovedistance, WapiSeekMethod method)
{
  guint32 D.12380;
  struct _WapiHandle_file * file_handle.31;
  unsigned int D.12382;
  signed int D.12383;
  unsigned int D.12386;
  unsigned int D.12387;
  int D.12393;
  long long int D.12394;
  long long int D.12395;
  unsigned int movedistance.32;
  long long int D.12397;
  long long int D.12402;
  int D.12403;
  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.12378>; else goto <D.12379>;
      <D.12378>:
      monoeg_g_log (0B, 16, "%s: error looking up file handle %p", &__func__, handle);
      SetLastError (6);
      D.12380 = 4294967295;
      return D.12380;
      <D.12379>:
      file_handle.31 = file_handle;
      fd = file_handle.31->fd;
      file_handle.31 = file_handle;
      D.12382 = file_handle.31->fileaccess;
      D.12383 = (signed int) D.12382;
      if (D.12383 >= 0) goto <D.12384>; else goto <D.12385>;
      <D.12384>:
      file_handle.31 = file_handle;
      D.12386 = BIT_FIELD_REF <*file_handle.31, 32, 128>;
      D.12387 = D.12386 & 1342177280;
      if (D.12387 == 0) goto <D.12388>; else goto <D.12389>;
      <D.12388>:
      SetLastError (5);
      D.12380 = 4294967295;
      return D.12380;
      <D.12389>:
      <D.12385>:
      switch (method) <default: <D.11049>, case 0: <D.11045>, case 1: <D.11047>, case 2: <D.11048>>
      <D.11045>:
      whence = 0;
      goto <D.11046>;
      <D.11047>:
      whence = 1;
      goto <D.11046>;
      <D.11048>:
      whence = 2;
      goto <D.11046>;
      <D.11049>:
      SetLastError (87);
      D.12380 = 4294967295;
      return D.12380;
      <D.11046>:
      if (highmovedistance == 0B) goto <D.12390>; else goto <D.12391>;
      <D.12390>:
      offset = (gint64) movedistance;
      goto <D.12392>;
      <D.12391>:
      D.12393 = *highmovedistance;
      D.12394 = (long long int) D.12393;
      D.12395 = D.12394 << 32;
      movedistance.32 = (unsigned int) movedistance;
      D.12397 = (long long int) movedistance.32;
      offset = D.12395 | D.12397;
      <D.12392>:
      newpos = lseek (fd, offset, whence);
      if (newpos == -1) goto <D.12398>; else goto <D.12399>;
      <D.12398>:
      _wapi_set_last_error_from_errno ();
      D.12380 = 4294967295;
      return D.12380;
      <D.12399>:
      ret = (guint32) newpos;
      if (highmovedistance != 0B) goto <D.12400>; else goto <D.12401>;
      <D.12400>:
      D.12402 = newpos >> 32;
      D.12403 = (int) D.12402;
      *highmovedistance = D.12403;
      <D.12401>:
      D.12380 = ret;
      return D.12380;
    }
  finally
    {
      file_handle = {CLOBBER};
    }
}


file_flush (void * handle)
{
  gboolean D.12408;
  struct _WapiHandle_file * file_handle.33;
  unsigned int D.12410;
  unsigned int D.12411;
  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.12406>; else goto <D.12407>;
      <D.12406>:
      monoeg_g_log (0B, 16, "%s: error looking up file handle %p", &__func__, handle);
      SetLastError (6);
      D.12408 = 0;
      return D.12408;
      <D.12407>:
      file_handle.33 = file_handle;
      fd = file_handle.33->fd;
      file_handle.33 = file_handle;
      D.12410 = BIT_FIELD_REF <*file_handle.33, 32, 128>;
      D.12411 = D.12410 & 1342177280;
      if (D.12411 == 0) goto <D.12412>; else goto <D.12413>;
      <D.12412>:
      SetLastError (5);
      D.12408 = 0;
      return D.12408;
      <D.12413>:
      ret = fsync (fd);
      if (ret == -1) goto <D.12414>; else goto <D.12415>;
      <D.12414>:
      _wapi_set_last_error_from_errno ();
      D.12408 = 0;
      return D.12408;
      <D.12415>:
      D.12408 = 1;
      return D.12408;
    }
  finally
    {
      file_handle = {CLOBBER};
    }
}


file_write (void * handle, const void * buffer, guint32 numbytes, guint32 * byteswritten, struct WapiOverlapped * overlapped)
{
  gboolean D.12420;
  struct _WapiHandle_file * file_handle.34;
  unsigned int D.12424;
  unsigned int D.12425;
  int lock_while_writing.35;
  long long int D.12433;
  int D.12434;
  int * D.12438;
  int D.12439;
  int D.12441;
  unsigned int ret.36;
  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.12418>; else goto <D.12419>;
      <D.12418>:
      monoeg_g_log (0B, 16, "%s: error looking up file handle %p", &__func__, handle);
      SetLastError (6);
      D.12420 = 0;
      return D.12420;
      <D.12419>:
      file_handle.34 = file_handle;
      fd = file_handle.34->fd;
      if (byteswritten != 0B) goto <D.12422>; else goto <D.12423>;
      <D.12422>:
      *byteswritten = 0;
      <D.12423>:
      file_handle.34 = file_handle;
      D.12424 = BIT_FIELD_REF <*file_handle.34, 32, 128>;
      D.12425 = D.12424 & 1342177280;
      if (D.12425 == 0) goto <D.12426>; else goto <D.12427>;
      <D.12426>:
      SetLastError (5);
      D.12420 = 0;
      return D.12420;
      <D.12427>:
      lock_while_writing.35 = lock_while_writing;
      if (lock_while_writing.35 != 0) goto <D.12429>; else goto <D.12430>;
      <D.12429>:
      current_pos = lseek (fd, 0, 1);
      if (current_pos == -1) goto <D.12431>; else goto <D.12432>;
      <D.12431>:
      _wapi_set_last_error_from_errno ();
      D.12420 = 0;
      return D.12420;
      <D.12432>:
      D.12433 = (long long int) numbytes;
      D.12434 = _wapi_lock_file_region (fd, current_pos, D.12433);
      if (D.12434 == 0) goto <D.12435>; else goto <D.12436>;
      <D.12435>:
      D.12420 = 0;
      return D.12420;
      <D.12436>:
      <D.12430>:
      <D.11021>:
      ret = write (fd, buffer, numbytes);
      if (ret == -1) goto <D.12437>; else goto <D.11022>;
      <D.12437>:
      D.12438 = __errno_location ();
      D.12439 = *D.12438;
      if (D.12439 == 4) goto <D.12440>; else goto <D.11022>;
      <D.12440>:
      D.12441 = _wapi_thread_cur_apc_pending ();
      if (D.12441 == 0) goto <D.11021>; else goto <D.11022>;
      <D.11022>:
      lock_while_writing.35 = lock_while_writing;
      if (lock_while_writing.35 != 0) goto <D.12442>; else goto <D.12443>;
      <D.12442>:
      D.12433 = (long long int) numbytes;
      _wapi_unlock_file_region (fd, current_pos, D.12433);
      <D.12443>:
      if (ret == -1) goto <D.12444>; else goto <D.12445>;
      <D.12444>:
      D.12438 = __errno_location ();
      D.12439 = *D.12438;
      if (D.12439 == 4) goto <D.12446>; else goto <D.12447>;
      <D.12446>:
      ret = 0;
      goto <D.12448>;
      <D.12447>:
      _wapi_set_last_error_from_errno ();
      D.12420 = 0;
      return D.12420;
      <D.12448>:
      <D.12445>:
      if (byteswritten != 0B) goto <D.12449>; else goto <D.12450>;
      <D.12449>:
      ret.36 = (unsigned int) ret;
      *byteswritten = ret.36;
      <D.12450>:
      D.12420 = 1;
      return D.12420;
    }
  finally
    {
      file_handle = {CLOBBER};
    }
}


file_read (void * handle, void * buffer, guint32 numbytes, guint32 * bytesread, struct WapiOverlapped * overlapped)
{
  gboolean D.12456;
  struct _WapiHandle_file * file_handle.37;
  unsigned int D.12460;
  signed int D.12461;
  unsigned int D.12464;
  int * D.12468;
  int D.12469;
  int D.12471;
  int D.12474;
  unsigned int D.12475;
  unsigned int ret.38;
  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.12454>; else goto <D.12455>;
      <D.12454>:
      monoeg_g_log (0B, 16, "%s: error looking up file handle %p", &__func__, handle);
      SetLastError (6);
      D.12456 = 0;
      return D.12456;
      <D.12455>:
      file_handle.37 = file_handle;
      fd = file_handle.37->fd;
      if (bytesread != 0B) goto <D.12458>; else goto <D.12459>;
      <D.12458>:
      *bytesread = 0;
      <D.12459>:
      file_handle.37 = file_handle;
      D.12460 = file_handle.37->fileaccess;
      D.12461 = (signed int) D.12460;
      if (D.12461 >= 0) goto <D.12462>; else goto <D.12463>;
      <D.12462>:
      file_handle.37 = file_handle;
      D.12460 = file_handle.37->fileaccess;
      D.12464 = D.12460 & 268435456;
      if (D.12464 == 0) goto <D.12465>; else goto <D.12466>;
      <D.12465>:
      SetLastError (5);
      D.12456 = 0;
      return D.12456;
      <D.12466>:
      <D.12463>:
      <D.11005>:
      ret = read (fd, buffer, numbytes);
      if (ret == -1) goto <D.12467>; else goto <D.11006>;
      <D.12467>:
      D.12468 = __errno_location ();
      D.12469 = *D.12468;
      if (D.12469 == 4) goto <D.12470>; else goto <D.11006>;
      <D.12470>:
      D.12471 = _wapi_thread_cur_apc_pending ();
      if (D.12471 == 0) goto <D.11005>; else goto <D.11006>;
      <D.11006>:
      if (ret == -1) goto <D.12472>; else goto <D.12473>;
      <D.12472>:
      {
        gint err;

        D.12468 = __errno_location ();
        err = *D.12468;
        D.12474 = _wapi_get_win32_file_error (err);
        D.12475 = (unsigned int) D.12474;
        SetLastError (D.12475);
        D.12456 = 0;
        return D.12456;
      }
      <D.12473>:
      if (bytesread != 0B) goto <D.12476>; else goto <D.12477>;
      <D.12476>:
      ret.38 = (unsigned int) ret;
      *bytesread = ret.38;
      <D.12477>:
      D.12456 = 1;
      return D.12456;
    }
  finally
    {
      file_handle = {CLOBBER};
    }
}


file_getfiletype ()
{
  WapiFileType D.12481;

  D.12481 = 1;
  return D.12481;
}


_wapi_handle_type (void * handle)
{
  unsigned int D.12486;
  struct _WapiHandleUnshared * D.12487;
  WapiHandleType D.12488;
  unsigned int D.12489;
  unsigned int D.12490;
  struct _WapiHandleUnshared * D.12491;
  guint32 idx;

  idx = (guint32) handle;
  if (idx > 4194303) goto <D.12483>; else goto <D.12485>;
  <D.12485>:
  D.12486 = idx / 256;
  D.12487 = _wapi_private_handles[D.12486];
  if (D.12487 == 0B) goto <D.12483>; else goto <D.12484>;
  <D.12483>:
  D.12488 = 0;
  return D.12488;
  <D.12484>:
  D.12486 = idx / 256;
  D.12487 = _wapi_private_handles[D.12486];
  D.12489 = idx & 255;
  D.12490 = D.12489 * 136;
  D.12491 = D.12487 + D.12490;
  D.12488 = D.12491->type;
  return D.12488;
}


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

  type = _wapi_handle_type (handle);
  D.12493 = io_ops[type].writefile;
  if (D.12493 == 0B) goto <D.12494>; else goto <D.12495>;
  <D.12494>:
  SetLastError (6);
  D.12496 = 0;
  return D.12496;
  <D.12495>:
  D.12493 = io_ops[type].writefile;
  D.12496 = D.12493 (handle, buffer, numbytes, byteswritten, overlapped);
  return D.12496;
}


FlushFileBuffers (void * handle)
{
  gboolean (*<T17d2>) (void *) D.12498;
  gboolean D.12501;
  WapiHandleType type;

  type = _wapi_handle_type (handle);
  D.12498 = io_ops[type].flushfile;
  if (D.12498 == 0B) goto <D.12499>; else goto <D.12500>;
  <D.12499>:
  SetLastError (6);
  D.12501 = 0;
  return D.12501;
  <D.12500>:
  D.12498 = io_ops[type].flushfile;
  D.12501 = D.12498 (handle);
  return D.12501;
}


SetEndOfFile (void * handle)
{
  gboolean (*<T17d2>) (void *) D.12503;
  gboolean D.12506;
  WapiHandleType type;

  type = _wapi_handle_type (handle);
  D.12503 = io_ops[type].setendoffile;
  if (D.12503 == 0B) goto <D.12504>; else goto <D.12505>;
  <D.12504>:
  SetLastError (6);
  D.12506 = 0;
  return D.12506;
  <D.12505>:
  D.12503 = io_ops[type].setendoffile;
  D.12506 = D.12503 (handle);
  return D.12506;
}


SetFilePointer (void * handle, gint32 movedistance, gint32 * highmovedistance, WapiSeekMethod method)
{
  guint32 (*<T1a96>) (void *, gint32, gint32 *, WapiSeekMethod) D.12508;
  guint32 D.12511;
  WapiHandleType type;

  type = _wapi_handle_type (handle);
  D.12508 = io_ops[type].seek;
  if (D.12508 == 0B) goto <D.12509>; else goto <D.12510>;
  <D.12509>:
  SetLastError (6);
  D.12511 = 4294967295;
  return D.12511;
  <D.12510>:
  D.12508 = io_ops[type].seek;
  D.12511 = D.12508 (handle, movedistance, highmovedistance, method);
  return D.12511;
}


GetFileType (void * handle)
{
  unsigned int handle.39;
  unsigned int D.12517;
  struct _WapiHandleUnshared * D.12518;
  WapiFileType D.12519;
  WapiFileType (*<T1a88>) (void) D.12520;
  WapiHandleType type;

  handle.39 = (unsigned int) handle;
  if (handle.39 > 268435455) goto <D.12513>; else goto <D.12516>;
  <D.12516>:
  handle.39 = (unsigned int) handle;
  D.12517 = handle.39 / 256;
  D.12518 = _wapi_private_handles[D.12517];
  if (D.12518 == 0B) goto <D.12513>; else goto <D.12514>;
  <D.12513>:
  SetLastError (6);
  D.12519 = 0;
  return D.12519;
  <D.12514>:
  type = _wapi_handle_type (handle);
  D.12520 = io_ops[type].getfiletype;
  if (D.12520 == 0B) goto <D.12521>; else goto <D.12522>;
  <D.12521>:
  SetLastError (6);
  D.12519 = 0;
  return D.12519;
  <D.12522>:
  D.12520 = io_ops[type].getfiletype;
  D.12519 = D.12520 ();
  return D.12519;
}


GetFileSize (void * handle, guint32 * highsize)
{
  guint32 (*<T1a9c>) (void *, guint32 *) D.12524;
  guint32 D.12527;
  WapiHandleType type;

  type = _wapi_handle_type (handle);
  D.12524 = io_ops[type].getfilesize;
  if (D.12524 == 0B) goto <D.12525>; else goto <D.12526>;
  <D.12525>:
  SetLastError (6);
  D.12527 = 4294967295;
  return D.12527;
  <D.12526>:
  D.12524 = io_ops[type].getfilesize;
  D.12527 = D.12524 (handle, highsize);
  return D.12527;
}


GetFileTime (void * handle, struct WapiFileTime * create_time, struct WapiFileTime * last_access, struct WapiFileTime * last_write)
{
  gboolean (*<T1aa0>) (void *, struct WapiFileTime *, struct WapiFileTime *, struct WapiFileTime *) D.12529;
  gboolean D.12532;
  WapiHandleType type;

  type = _wapi_handle_type (handle);
  D.12529 = io_ops[type].getfiletime;
  if (D.12529 == 0B) goto <D.12530>; else goto <D.12531>;
  <D.12530>:
  SetLastError (6);
  D.12532 = 0;
  return D.12532;
  <D.12531>:
  D.12529 = io_ops[type].getfiletime;
  D.12532 = D.12529 (handle, create_time, last_access, last_write);
  return D.12532;
}


SetFileTime (void * handle, const struct WapiFileTime * create_time, const struct WapiFileTime * last_access, const struct WapiFileTime * last_write)
{
  gboolean (*<T1aa4>) (void *, const struct WapiFileTime *, const struct WapiFileTime *, const struct WapiFileTime *) D.12534;
  gboolean D.12537;
  WapiHandleType type;

  type = _wapi_handle_type (handle);
  D.12534 = io_ops[type].setfiletime;
  if (D.12534 == 0B) goto <D.12535>; else goto <D.12536>;
  <D.12535>:
  SetLastError (6);
  D.12537 = 0;
  return D.12537;
  <D.12536>:
  D.12534 = io_ops[type].setfiletime;
  D.12537 = D.12534 (handle, create_time, last_access, last_write);
  return D.12537;
}


FileTimeToSystemTime (const struct WapiFileTime * file_time, struct WapiSystemTime * system_time)
{
  gboolean D.12541;
  unsigned int D.12542;
  long long int D.12543;
  long long int D.12544;
  unsigned int D.12545;
  long long int D.12546;
  long long int D.12549;
  short unsigned int D.12550;
  long long int D.12551;
  short unsigned int D.12552;
  long long int D.12553;
  short unsigned int D.12554;
  long long int D.12555;
  short unsigned int D.12556;
  long long int D.12557;
  long long int D.12558;
  short unsigned int D.12559;
  short unsigned int D.12560;
  long long int D.12561;
  long long int D.12562;
  long long int D.12563;
  _Bool D.12564;
  long long int D.12565;
  long long int D.12566;
  long long int D.12567;
  long long int D.12568;
  _Bool D.12569;
  long long int D.12570;
  long long int D.12571;
  long long int D.12572;
  _Bool D.12573;
  long long int D.12574;
  long long int D.12575;
  long long int D.12576;
  long long int D.12577;
  long long int D.12578;
  long long int D.12579;
  _Bool D.12580;
  long long int D.12581;
  long long int D.12582;
  long long int D.12583;
  long long int D.12584;
  long long int D.12585;
  long long int D.12586;
  _Bool D.12587;
  long long int D.12588;
  long long int D.12589;
  long long int D.12590;
  _Bool D.12591;
  long long int D.12592;
  long long int D.12593;
  long long int D.12594;
  long long int D.12595;
  long long int D.12596;
  long long int D.12597;
  _Bool D.12598;
  long long int D.12599;
  long long int D.12600;
  long long int D.12601;
  long long int D.12602;
  long long int D.12603;
  long long int D.12604;
  long long int D.12605;
  long long int D.12606;
  long long int D.12607;
  long long int D.12608;
  long long int D.12609;
  long long int D.12610;
  long long int D.12611;
  long long int D.12612;
  long long int D.12613;
  gint64 iftmp.40;
  unsigned long long y.41;
  unsigned long long D.12620;
  long long int D.12622;
  long long int D.12624;
  short unsigned int D.12625;
  int iftmp.42;
  unsigned int D.12632;
  unsigned int D.12633;
  const guint16 * D.12634;
  short unsigned int D.12635;
  long long int D.12636;
  short unsigned int D.12637;
  short unsigned int D.12638;
  short unsigned int D.12639;
  gint64 file_ticks;
  gint64 totaldays;
  gint64 rem;
  gint64 y;
  const guint16 * ip;
  static const char __func__[21] = "FileTimeToSystemTime";

  if (system_time == 0B) goto <D.12539>; else goto <D.12540>;
  <D.12539>:
  SetLastError (87);
  D.12541 = 0;
  return D.12541;
  <D.12540>:
  D.12542 = file_time->dwHighDateTime;
  D.12543 = (long long int) D.12542;
  D.12544 = D.12543 << 32;
  D.12545 = file_time->dwLowDateTime;
  D.12546 = (long long int) D.12545;
  file_ticks = D.12544 + D.12546;
  if (file_ticks < 0) goto <D.12547>; else goto <D.12548>;
  <D.12547>:
  SetLastError (87);
  D.12541 = 0;
  return D.12541;
  <D.12548>:
  totaldays = file_ticks / 864000000000;
  rem = file_ticks % 864000000000;
  D.12549 = rem / 36000000000;
  D.12550 = (short unsigned int) D.12549;
  system_time->wHour = D.12550;
  rem = rem % 36000000000;
  D.12551 = rem / 600000000;
  D.12552 = (short unsigned int) D.12551;
  system_time->wMinute = D.12552;
  rem = rem % 600000000;
  D.12553 = rem / 10000000;
  D.12554 = (short unsigned int) D.12553;
  system_time->wSecond = D.12554;
  rem = rem % 10000000;
  D.12555 = rem / 10000;
  D.12556 = (short unsigned int) D.12555;
  system_time->wMilliseconds = D.12556;
  D.12557 = totaldays + 1;
  D.12558 = D.12557 % 7;
  D.12559 = (short unsigned int) D.12558;
  D.12560 = D.12559 + 1;
  system_time->wDayOfWeek = D.12560;
  y = 1601;
  goto <D.11404>;
  <D.11403>:
  {
    gint64 yg;

    D.12561 = totaldays / 365;
    D.12562 = D.12561 + y;
    D.12563 = totaldays % 365;
    D.12564 = D.12563 < 0;
    D.12565 = (long long int) D.12564;
    yg = D.12562 - D.12565;
    D.12566 = y + -1;
    D.12567 = D.12566 / 4;
    D.12566 = y + -1;
    D.12568 = D.12566 % 4;
    D.12569 = D.12568 < 0;
    D.12570 = (long long int) D.12569;
    D.12571 = D.12567 - D.12570;
    D.12566 = y + -1;
    D.12572 = D.12566 % 100;
    D.12573 = D.12572 < 0;
    D.12574 = (long long int) D.12573;
    D.12566 = y + -1;
    D.12575 = D.12566 / -100;
    D.12576 = D.12574 + D.12575;
    D.12577 = D.12571 + D.12576;
    D.12566 = y + -1;
    D.12578 = D.12566 / 400;
    D.12566 = y + -1;
    D.12579 = D.12566 % 400;
    D.12580 = D.12579 < 0;
    D.12581 = (long long int) D.12580;
    D.12582 = D.12578 - D.12581;
    D.12583 = D.12577 + D.12582;
    D.12584 = yg + -1;
    D.12585 = D.12584 / 4;
    D.12584 = yg + -1;
    D.12586 = D.12584 % 4;
    D.12587 = D.12586 < 0;
    D.12588 = (long long int) D.12587;
    D.12589 = D.12585 - D.12588;
    D.12584 = yg + -1;
    D.12590 = D.12584 % 100;
    D.12591 = D.12590 < 0;
    D.12592 = (long long int) D.12591;
    D.12584 = yg + -1;
    D.12593 = D.12584 / -100;
    D.12594 = D.12592 + D.12593;
    D.12595 = D.12589 + D.12594;
    D.12584 = yg + -1;
    D.12596 = D.12584 / 400;
    D.12584 = yg + -1;
    D.12597 = D.12584 % 400;
    D.12598 = D.12597 < 0;
    D.12599 = (long long int) D.12598;
    D.12600 = D.12596 - D.12599;
    D.12601 = D.12595 + D.12600;
    monoeg_g_log (0B, 32, "%s: LEAPS(yg): %lld LEAPS(y): %lld", &__func__, D.12601, D.12583);
    D.12566 = y + -1;
    D.12567 = D.12566 / 4;
    D.12566 = y + -1;
    D.12568 = D.12566 % 4;
    D.12569 = D.12568 < 0;
    D.12570 = (long long int) D.12569;
    D.12571 = D.12567 - D.12570;
    D.12566 = y + -1;
    D.12572 = D.12566 % 100;
    D.12573 = D.12572 < 0;
    D.12574 = (long long int) D.12573;
    D.12566 = y + -1;
    D.12575 = D.12566 / -100;
    D.12576 = D.12574 + D.12575;
    D.12577 = D.12571 + D.12576;
    D.12566 = y + -1;
    D.12578 = D.12566 / 400;
    D.12566 = y + -1;
    D.12579 = D.12566 % 400;
    D.12580 = D.12579 < 0;
    D.12581 = (long long int) D.12580;
    D.12582 = D.12578 - D.12581;
    D.12583 = D.12577 + D.12582;
    D.12584 = yg + -1;
    D.12597 = D.12584 % 400;
    D.12598 = D.12597 < 0;
    D.12599 = (long long int) D.12598;
    D.12584 = yg + -1;
    D.12602 = D.12584 / -400;
    D.12603 = D.12599 + D.12602;
    D.12584 = yg + -1;
    D.12604 = D.12584 / 100;
    D.12584 = yg + -1;
    D.12590 = D.12584 % 100;
    D.12591 = D.12590 < 0;
    D.12592 = (long long int) D.12591;
    D.12605 = D.12604 - D.12592;
    D.12584 = yg + -1;
    D.12586 = D.12584 % 4;
    D.12587 = D.12586 < 0;
    D.12588 = (long long int) D.12587;
    D.12584 = yg + -1;
    D.12606 = D.12584 / -4;
    D.12607 = D.12588 + D.12606;
    D.12608 = D.12605 + D.12607;
    D.12609 = D.12603 + D.12608;
    D.12610 = y - yg;
    D.12611 = D.12610 * 365;
    D.12612 = D.12609 + D.12611;
    D.12613 = D.12583 + D.12612;
    totaldays = D.12613 + totaldays;
    y = yg;
  }
  <D.11404>:
  if (totaldays < 0) goto <D.11403>; else goto <D.12614>;
  <D.12614>:
  y.41 = (unsigned long long) y;
  D.12620 = y.41 & 3;
  if (D.12620 == 0) goto <D.12621>; else goto <D.12616>;
  <D.12621>:
  D.12622 = y % 100;
  if (D.12622 != 0) goto <D.12617>; else goto <D.12623>;
  <D.12623>:
  D.12624 = y % 400;
  if (D.12624 == 0) goto <D.12617>; else goto <D.12616>;
  <D.12617>:
  iftmp.40 = 366;
  goto <D.12618>;
  <D.12616>:
  iftmp.40 = 365;
  <D.12618>:
  if (iftmp.40 <= totaldays) goto <D.11403>; else goto <D.11405>;
  <D.11405>:
  D.12625 = (short unsigned int) y;
  system_time->wYear = D.12625;
  y.41 = (unsigned long long) y;
  D.12620 = y.41 & 3;
  if (D.12620 == 0) goto <D.12630>; else goto <D.12627>;
  <D.12630>:
  D.12622 = y % 100;
  if (D.12622 != 0) goto <D.12628>; else goto <D.12631>;
  <D.12631>:
  D.12624 = y % 400;
  if (D.12624 == 0) goto <D.12628>; else goto <D.12627>;
  <D.12628>:
  iftmp.42 = 1;
  goto <D.12629>;
  <D.12627>:
  iftmp.42 = 0;
  <D.12629>:
  ip = &mon_yday[iftmp.42];
  y = 11;
  goto <D.11408>;
  <D.11407>:
  // predicted unlikely by continue predictor.
  goto <D.11406>;
  <D.11406>:
  y = y + -1;
  <D.11408>:
  D.12632 = (unsigned int) y;
  D.12633 = D.12632 * 2;
  D.12634 = ip + D.12633;
  D.12635 = *D.12634;
  D.12636 = (long long int) D.12635;
  if (D.12636 > totaldays) goto <D.11407>; else goto <D.11409>;
  <D.11409>:
  D.12632 = (unsigned int) y;
  D.12633 = D.12632 * 2;
  D.12634 = ip + D.12633;
  D.12635 = *D.12634;
  D.12636 = (long long int) D.12635;
  totaldays = totaldays - D.12636;
  D.12625 = (short unsigned int) y;
  D.12637 = D.12625 + 1;
  system_time->wMonth = D.12637;
  D.12638 = (short unsigned int) totaldays;
  D.12639 = D.12638 + 1;
  system_time->wDay = D.12639;
  D.12541 = 1;
  return D.12541;
}


FindFirstFile (const gunichar2 * pattern, struct WapiFindData * find_data)
{
  void * D.12643;
  int D.12654;
  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.12641>; else goto <D.12642>;
      <D.12641>:
      SetLastError (3);
      D.12643 = 4294967295B;
      return D.12643;
      <D.12642>:
      utf8_pattern = mono_unicode_to_external (pattern);
      if (utf8_pattern == 0B) goto <D.12644>; else goto <D.12645>;
      <D.12644>:
      SetLastError (123);
      D.12643 = 4294967295B;
      return D.12643;
      <D.12645>:
      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.12646>; else goto <D.12647>;
      <D.12646>:
      SetLastError (2);
      monoeg_g_free (utf8_pattern);
      monoeg_g_free (entry_part);
      monoeg_g_free (dir_part);
      D.12643 = 4294967295B;
      return D.12643;
      <D.12647>:
      if (result < 0) goto <D.12648>; else goto <D.12649>;
      <D.12648>:
      _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.12643 = 4294967295B;
      return D.12643;
      <D.12649>:
      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 == 4294967295B) goto <D.12650>; else goto <D.12651>;
      <D.12650>:
      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.12643 = 4294967295B;
      return D.12643;
      <D.12651>:
      if (handle != 4294967295B) goto <D.12652>; else goto <D.12653>;
      <D.12652>:
      D.12654 = FindNextFile (handle, find_data);
      if (D.12654 == 0) goto <D.12655>; else goto <D.12656>;
      <D.12655>:
      FindClose (handle);
      SetLastError (18);
      handle = 4294967295B;
      <D.12656>:
      <D.12653>:
      D.12643 = handle;
      return D.12643;
    }
  finally
    {
      find_handle = {CLOBBER};
    }
}


FindNextFile (void * handle, struct WapiFindData * find_data)
{
  gboolean D.12661;
  long int D.12662;
  _Bool D.12665;
  long int D.12666;
  long int D.12667;
  struct _WapiHandle_find * find_handle.43;
  unsigned int D.12671;
  int D.12672;
  unsigned int D.12673;
  gchar * * D.12676;
  unsigned int D.12677;
  unsigned int D.12678;
  unsigned int D.12679;
  gchar * * D.12680;
  gchar * D.12681;
  gchar * D.12682;
  int * D.12685;
  int D.12686;
  long int D.12695;
  long int D.12696;
  unsigned int D.12700;
  struct WapiFileTime * D.12701;
  struct WapiFileTime * D.12702;
  long int D.12703;
  struct WapiFileTime * D.12704;
  unsigned int D.12705;
  unsigned int D.12706;
  long long int D.12710;
  long long int D.12711;
  unsigned int D.12712;
  unsigned int D.12713;
  long int bytes.44;
  long int bytes.45;
  gunichar2[260] * D.12718;
  long int D.12719;
  unsigned int D.12720;
  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.12659>; else goto <D.12660>;
      <D.12659>:
      monoeg_g_log (0B, 16, "%s: error looking up find handle %p", &__func__, handle);
      SetLastError (6);
      D.12661 = 0;
      return D.12661;
      <D.12660>:
      {
        struct __pthread_unwind_buf_t __cancel_buf;
        void (*<Tbf>) (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.12662 = __builtin_expect (__not_first_call, 0);
            if (D.12662 != 0) goto <D.12663>; else goto <D.12664>;
            <D.12663>:
            __cancel_routine (__cancel_arg);
            __pthread_unwind_next (&__cancel_buf);
            <D.12664>:
            __pthread_register_cancel (&__cancel_buf);
            thr_ret = _wapi_handle_lock_handle (handle);
            D.12665 = thr_ret != 0;
            D.12666 = (long int) D.12665;
            D.12667 = __builtin_expect (D.12666, 0);
            if (D.12667 != 0) goto <D.12668>; else goto <D.12669>;
            <D.12668>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "io.c", 2803, "thr_ret == 0");
            <D.12669>:
            retry:
            find_handle.43 = find_handle;
            D.12671 = find_handle.43->count;
            find_handle.43 = find_handle;
            D.12672 = find_handle.43->num;
            D.12673 = (unsigned int) D.12672;
            if (D.12671 >= D.12673) goto <D.12674>; else goto <D.12675>;
            <D.12674>:
            SetLastError (18);
            goto cleanup;
            <D.12675>:
            find_handle.43 = find_handle;
            D.12676 = find_handle.43->namelist;
            find_handle.43 = find_handle;
            D.12671 = find_handle.43->count;
            D.12677 = D.12671;
            D.12678 = D.12677 + 1;
            find_handle.43->count = D.12678;
            D.12679 = D.12677 * 4;
            D.12680 = D.12676 + D.12679;
            D.12681 = *D.12680;
            find_handle.43 = find_handle;
            D.12682 = find_handle.43->dir_part;
            filename = monoeg_g_build_path ("/", D.12682, D.12681, 0B);
            result = _wapi_stat (filename, &buf);
            if (result == -1) goto <D.12683>; else goto <D.12684>;
            <D.12683>:
            D.12685 = __errno_location ();
            D.12686 = *D.12685;
            if (D.12686 == 2) goto <D.12687>; else goto <D.12688>;
            <D.12687>:
            result = _wapi_lstat (filename, &buf);
            <D.12688>:
            <D.12684>:
            if (result != 0) goto <D.12689>; else goto <D.12690>;
            <D.12689>:
            monoeg_g_free (filename);
            goto retry;
            <D.12690>:
            result = _wapi_lstat (filename, &linkbuf);
            if (result != 0) goto <D.12691>; else goto <D.12692>;
            <D.12691>:
            monoeg_g_free (filename);
            goto retry;
            <D.12692>:
            utf8_filename = mono_utf8_from_external (filename);
            if (utf8_filename == 0B) goto <D.12693>; else goto <D.12694>;
            <D.12693>:
            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.12694>:
            monoeg_g_free (filename);
            D.12695 = buf.st_mtim.tv_sec;
            D.12696 = buf.st_ctim.tv_sec;
            if (D.12695 < D.12696) goto <D.12697>; else goto <D.12698>;
            <D.12697>:
            create_time = buf.st_mtim.tv_sec;
            goto <D.12699>;
            <D.12698>:
            create_time = buf.st_ctim.tv_sec;
            <D.12699>:
            D.12700 = _wapi_stat_to_file_attributes (utf8_filename, &buf, &linkbuf);
            find_data->dwFileAttributes = D.12700;
            D.12701 = &find_data->ftCreationTime;
            _wapi_time_t_to_filetime (create_time, D.12701);
            D.12702 = &find_data->ftLastAccessTime;
            D.12703 = buf.st_atim.tv_sec;
            _wapi_time_t_to_filetime (D.12703, D.12702);
            D.12704 = &find_data->ftLastWriteTime;
            D.12695 = buf.st_mtim.tv_sec;
            _wapi_time_t_to_filetime (D.12695, D.12704);
            D.12705 = find_data->dwFileAttributes;
            D.12706 = D.12705 & 16;
            if (D.12706 != 0) goto <D.12707>; else goto <D.12708>;
            <D.12707>:
            find_data->nFileSizeHigh = 0;
            find_data->nFileSizeLow = 0;
            goto <D.12709>;
            <D.12708>:
            D.12710 = buf.st_size;
            D.12711 = D.12710 >> 32;
            D.12712 = (unsigned int) D.12711;
            find_data->nFileSizeHigh = D.12712;
            D.12710 = buf.st_size;
            D.12713 = (unsigned int) D.12710;
            find_data->nFileSizeLow = D.12713;
            <D.12709>:
            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.12714>; else goto <D.12715>;
            <D.12714>:
            monoeg_g_free (utf8_basename);
            monoeg_g_free (utf8_filename);
            goto retry;
            <D.12715>:
            ret = 1;
            bytes.44 = bytes;
            bytes.45 = bytes.44 * 2;
            bytes = bytes.45;
            D.12718 = &find_data->cFileName;
            memset (D.12718, 0, 520);
            bytes.44 = bytes;
            D.12719 = MIN_EXPR <bytes.44, 518>;
            D.12720 = (unsigned int) D.12719;
            D.12718 = &find_data->cFileName;
            memcpy (D.12718, utf16_basename, D.12720);
            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.12665 = thr_ret != 0;
            D.12666 = (long int) D.12665;
            D.12667 = __builtin_expect (D.12666, 0);
            if (D.12667 != 0) goto <D.12721>; else goto <D.12722>;
            <D.12721>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "io.c", 2910, "thr_ret == 0");
            <D.12722>:
            __pthread_unregister_cancel (&__cancel_buf);
            if (0 != 0) goto <D.12723>; else goto <D.12724>;
            <D.12723>:
            __cancel_routine (__cancel_arg);
            <D.12724>:
          }
        finally
          {
            __cancel_buf = {CLOBBER};
          }
      }
      D.12661 = ret;
      return D.12661;
    }
  finally
    {
      find_handle = {CLOBBER};
      buf = {CLOBBER};
      linkbuf = {CLOBBER};
      bytes = {CLOBBER};
    }
}


_wapi_handle_lock_handle (void * handle)
{
  int D.12740;
  <unnamed type> D.12743;
  <unnamed type> D.12745;
  <unnamed type> D.12747;
  <unnamed type> D.12749;
  unsigned int D.12750;
  struct _WapiHandleUnshared * D.12751;
  unsigned int D.12752;
  unsigned int D.12753;
  struct _WapiHandleUnshared * D.12754;
  union mono_mutex_t * D.12755;
  guint32 idx;

  idx = (guint32) handle;
  if (idx > 4194303) goto <D.12738>; else goto <D.12739>;
  <D.12738>:
  D.12740 = 0;
  return D.12740;
  <D.12739>:
  _wapi_handle_ref (handle);
  D.12743 = _wapi_handle_type (handle);
  if (D.12743 == 9) goto <D.12741>; else goto <D.12744>;
  <D.12744>:
  D.12745 = _wapi_handle_type (handle);
  if (D.12745 == 11) goto <D.12741>; else goto <D.12746>;
  <D.12746>:
  D.12747 = _wapi_handle_type (handle);
  if (D.12747 == 12) goto <D.12741>; else goto <D.12748>;
  <D.12748>:
  D.12749 = _wapi_handle_type (handle);
  if (D.12749 == 13) goto <D.12741>; else goto <D.12742>;
  <D.12741>:
  D.12740 = 0;
  return D.12740;
  <D.12742>:
  D.12750 = idx / 256;
  D.12751 = _wapi_private_handles[D.12750];
  D.12752 = idx & 255;
  D.12753 = D.12752 * 136;
  D.12754 = D.12751 + D.12753;
  D.12755 = &D.12754->signal_mutex;
  D.12740 = pthread_mutex_lock (D.12755);
  return D.12740;
}


_wapi_stat_to_file_attributes (const gchar * pathname, struct stat * buf, struct stat * lbuf)
{
  unsigned int D.12757;
  unsigned int D.12758;
  unsigned int D.12761;
  int D.12764;
  char D.12767;
  int D.12771;
  unsigned int D.12782;
  unsigned int D.12783;
  guint32 D.12786;
  guint32 attrs;
  gchar * filename;

  attrs = 0;
  D.12757 = buf->st_mode;
  D.12758 = D.12757 & 61440;
  if (D.12758 == 49152) goto <D.12759>; else goto <D.12760>;
  <D.12759>:
  D.12757 = buf->st_mode;
  D.12761 = D.12757 & 4294918143;
  buf->st_mode = D.12761;
  <D.12760>:
  filename = _wapi_basename (pathname);
  D.12757 = buf->st_mode;
  D.12758 = D.12757 & 61440;
  if (D.12758 == 16384) goto <D.12762>; else goto <D.12763>;
  <D.12762>:
  attrs = 16;
  D.12764 = is_file_writable (buf, pathname);
  if (D.12764 == 0) goto <D.12765>; else goto <D.12766>;
  <D.12765>:
  attrs = attrs | 1;
  <D.12766>:
  D.12767 = *filename;
  if (D.12767 == 46) goto <D.12768>; else goto <D.12769>;
  <D.12768>:
  attrs = attrs | 2;
  <D.12769>:
  goto <D.12770>;
  <D.12763>:
  D.12771 = is_file_writable (buf, pathname);
  if (D.12771 == 0) goto <D.12772>; else goto <D.12773>;
  <D.12772>:
  attrs = 1;
  D.12767 = *filename;
  if (D.12767 == 46) goto <D.12774>; else goto <D.12775>;
  <D.12774>:
  attrs = attrs | 2;
  <D.12775>:
  goto <D.12776>;
  <D.12773>:
  D.12767 = *filename;
  if (D.12767 == 46) goto <D.12777>; else goto <D.12778>;
  <D.12777>:
  attrs = 2;
  goto <D.12779>;
  <D.12778>:
  attrs = 128;
  <D.12779>:
  <D.12776>:
  <D.12770>:
  if (lbuf != 0B) goto <D.12780>; else goto <D.12781>;
  <D.12780>:
  D.12782 = lbuf->st_mode;
  D.12783 = D.12782 & 61440;
  if (D.12783 == 40960) goto <D.12784>; else goto <D.12785>;
  <D.12784>:
  attrs = attrs | 1024;
  <D.12785>:
  <D.12781>:
  monoeg_g_free (filename);
  D.12786 = attrs;
  return D.12786;
}


is_file_writable (struct stat * st, const char * path)
{
  unsigned int D.12788;
  unsigned int D.12789;
  gboolean D.12792;
  unsigned int D.12793;
  unsigned int D.12794;
  unsigned int D.12797;
  unsigned int D.12800;
  unsigned int D.12801;
  unsigned int D.12804;
  int D.12807;
  _Bool D.12808;

  D.12788 = st->st_mode;
  D.12789 = D.12788 & 2;
  if (D.12789 != 0) goto <D.12790>; else goto <D.12791>;
  <D.12790>:
  D.12792 = 1;
  return D.12792;
  <D.12791>:
  D.12793 = st->st_uid;
  D.12794 = geteuid ();
  if (D.12793 == D.12794) goto <D.12795>; else goto <D.12796>;
  <D.12795>:
  D.12788 = st->st_mode;
  D.12797 = D.12788 & 128;
  if (D.12797 != 0) goto <D.12798>; else goto <D.12799>;
  <D.12798>:
  D.12792 = 1;
  return D.12792;
  <D.12799>:
  <D.12796>:
  D.12800 = st->st_gid;
  D.12801 = getegid ();
  if (D.12800 == D.12801) goto <D.12802>; else goto <D.12803>;
  <D.12802>:
  D.12788 = st->st_mode;
  D.12804 = D.12788 & 16;
  if (D.12804 != 0) goto <D.12805>; else goto <D.12806>;
  <D.12805>:
  D.12792 = 1;
  return D.12792;
  <D.12806>:
  <D.12803>:
  D.12807 = access (path, 2);
  D.12808 = D.12807 == 0;
  D.12792 = (gboolean) D.12808;
  return D.12792;
}


memset (void * __dest, int __ch, size_t __len)
{
  int D.12812;
  int D.12817;
  void * D.12819;
  unsigned int D.12820;

  D.12812 = __builtin_constant_p (__len);
  if (D.12812 != 0) goto <D.12813>; else goto <D.12814>;
  <D.12813>:
  if (__len == 0) goto <D.12815>; else goto <D.12816>;
  <D.12815>:
  D.12817 = __builtin_constant_p (__ch);
  if (D.12817 == 0) goto <D.12810>; else goto <D.12818>;
  <D.12818>:
  if (__ch != 0) goto <D.12810>; else goto <D.12811>;
  <D.12810>:
  __warn_memset_zero_len ();
  D.12819 = __dest;
  return D.12819;
  <D.12811>:
  <D.12816>:
  <D.12814>:
  D.12820 = __builtin_object_size (__dest, 0);
  D.12819 = __builtin___memset_chk (__dest, __ch, __len, D.12820);
  return D.12819;
}


memcpy (void * restrict __dest, const void * restrict __src, size_t __len)
{
  void * D.12822;
  unsigned int D.12823;

  D.12823 = __builtin_object_size (__dest, 0);
  D.12822 = __builtin___memcpy_chk (__dest, __src, __len, D.12823);
  return D.12822;
}


_wapi_handle_unlock_handle (void * handle)
{
  int D.12827;
  <unnamed type> D.12830;
  <unnamed type> D.12832;
  <unnamed type> D.12834;
  <unnamed type> D.12836;
  unsigned int D.12837;
  struct _WapiHandleUnshared * D.12838;
  unsigned int D.12839;
  unsigned int D.12840;
  struct _WapiHandleUnshared * D.12841;
  union mono_mutex_t * D.12842;
  guint32 idx;
  int ret;

  idx = (guint32) handle;
  if (idx > 4194303) goto <D.12825>; else goto <D.12826>;
  <D.12825>:
  D.12827 = 0;
  return D.12827;
  <D.12826>:
  D.12830 = _wapi_handle_type (handle);
  if (D.12830 == 9) goto <D.12828>; else goto <D.12831>;
  <D.12831>:
  D.12832 = _wapi_handle_type (handle);
  if (D.12832 == 11) goto <D.12828>; else goto <D.12833>;
  <D.12833>:
  D.12834 = _wapi_handle_type (handle);
  if (D.12834 == 12) goto <D.12828>; else goto <D.12835>;
  <D.12835>:
  D.12836 = _wapi_handle_type (handle);
  if (D.12836 == 13) goto <D.12828>; else goto <D.12829>;
  <D.12828>:
  _wapi_handle_unref (handle);
  D.12827 = 0;
  return D.12827;
  <D.12829>:
  D.12837 = idx / 256;
  D.12838 = _wapi_private_handles[D.12837];
  D.12839 = idx & 255;
  D.12840 = D.12839 * 136;
  D.12841 = D.12838 + D.12840;
  D.12842 = &D.12841->signal_mutex;
  ret = pthread_mutex_unlock (D.12842);
  _wapi_handle_unref (handle);
  D.12827 = ret;
  return D.12827;
}


FindClose (void * handle)
{
  gboolean D.12846;
  long int D.12849;
  _Bool D.12852;
  long int D.12853;
  long int D.12854;
  struct _WapiHandle_find * find_handle.46;
  gchar * * D.12858;
  gchar * D.12859;
  struct _WapiHandle_find * find_handle;
  gboolean ok;
  int thr_ret;
  static const char __func__[10] = "FindClose";

  try
    {
      if (handle == 0B) goto <D.12844>; else goto <D.12845>;
      <D.12844>:
      SetLastError (6);
      D.12846 = 0;
      return D.12846;
      <D.12845>:
      ok = _wapi_lookup_handle (handle, 8, &find_handle);
      if (ok == 0) goto <D.12847>; else goto <D.12848>;
      <D.12847>:
      monoeg_g_log (0B, 16, "%s: error looking up find handle %p", &__func__, handle);
      SetLastError (6);
      D.12846 = 0;
      return D.12846;
      <D.12848>:
      {
        struct __pthread_unwind_buf_t __cancel_buf;
        void (*<Tbf>) (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.12849 = __builtin_expect (__not_first_call, 0);
            if (D.12849 != 0) goto <D.12850>; else goto <D.12851>;
            <D.12850>:
            __cancel_routine (__cancel_arg);
            __pthread_unwind_next (&__cancel_buf);
            <D.12851>:
            __pthread_register_cancel (&__cancel_buf);
            thr_ret = _wapi_handle_lock_handle (handle);
            D.12852 = thr_ret != 0;
            D.12853 = (long int) D.12852;
            D.12854 = __builtin_expect (D.12853, 0);
            if (D.12854 != 0) goto <D.12855>; else goto <D.12856>;
            <D.12855>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "io.c", 2947, "thr_ret == 0");
            <D.12856>:
            find_handle.46 = find_handle;
            D.12858 = find_handle.46->namelist;
            monoeg_g_strfreev (D.12858);
            find_handle.46 = find_handle;
            D.12859 = find_handle.46->dir_part;
            monoeg_g_free (D.12859);
            thr_ret = _wapi_handle_unlock_handle (handle);
            D.12852 = thr_ret != 0;
            D.12853 = (long int) D.12852;
            D.12854 = __builtin_expect (D.12853, 0);
            if (D.12854 != 0) goto <D.12860>; else goto <D.12861>;
            <D.12860>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "io.c", 2953, "thr_ret == 0");
            <D.12861>:
            __pthread_unregister_cancel (&__cancel_buf);
            if (0 != 0) goto <D.12862>; else goto <D.12863>;
            <D.12862>:
            __cancel_routine (__cancel_arg);
            <D.12863>:
          }
        finally
          {
            __cancel_buf = {CLOBBER};
          }
      }
      _wapi_handle_unref (handle);
      D.12846 = 1;
      return D.12846;
    }
  finally
    {
      find_handle = {CLOBBER};
    }
}


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

  if (name == 0B) goto <D.12869>; else goto <D.12870>;
  <D.12869>:
  SetLastError (123);
  D.12871 = 0;
  return D.12871;
  <D.12870>:
  utf8_name = mono_unicode_to_external (name);
  if (utf8_name == 0B) goto <D.12872>; else goto <D.12873>;
  <D.12872>:
  SetLastError (123);
  D.12871 = 0;
  return D.12871;
  <D.12873>:
  result = _wapi_mkdir (utf8_name, 511);
  if (result == 0) goto <D.12874>; else goto <D.12875>;
  <D.12874>:
  monoeg_g_free (utf8_name);
  D.12871 = 1;
  return D.12871;
  <D.12875>:
  _wapi_set_last_path_error_from_errno (0B, utf8_name);
  monoeg_g_free (utf8_name);
  D.12871 = 0;
  return D.12871;
}


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

  if (name == 0B) goto <D.12877>; else goto <D.12878>;
  <D.12877>:
  SetLastError (123);
  D.12879 = 0;
  return D.12879;
  <D.12878>:
  utf8_name = mono_unicode_to_external (name);
  if (utf8_name == 0B) goto <D.12880>; else goto <D.12881>;
  <D.12880>:
  SetLastError (123);
  D.12879 = 0;
  return D.12879;
  <D.12881>:
  result = _wapi_rmdir (utf8_name);
  if (result == -1) goto <D.12882>; else goto <D.12883>;
  <D.12882>:
  _wapi_set_last_path_error_from_errno (0B, utf8_name);
  monoeg_g_free (utf8_name);
  D.12879 = 0;
  return D.12879;
  <D.12883>:
  monoeg_g_free (utf8_name);
  D.12879 = 1;
  return D.12879;
}


GetFileAttributes (const gunichar2 * name)
{
  guint32 D.12887;
  int * D.12892;
  int D.12893;
  gchar * utf8_name;
  struct stat buf;
  struct stat linkbuf;
  int result;
  guint32 ret;

  try
    {
      if (name == 0B) goto <D.12885>; else goto <D.12886>;
      <D.12885>:
      SetLastError (123);
      D.12887 = 0;
      return D.12887;
      <D.12886>:
      utf8_name = mono_unicode_to_external (name);
      if (utf8_name == 0B) goto <D.12888>; else goto <D.12889>;
      <D.12888>:
      SetLastError (87);
      D.12887 = 4294967295;
      return D.12887;
      <D.12889>:
      result = _wapi_stat (utf8_name, &buf);
      if (result == -1) goto <D.12890>; else goto <D.12891>;
      <D.12890>:
      D.12892 = __errno_location ();
      D.12893 = *D.12892;
      if (D.12893 == 2) goto <D.12894>; else goto <D.12895>;
      <D.12894>:
      result = _wapi_lstat (utf8_name, &buf);
      <D.12895>:
      <D.12891>:
      if (result != 0) goto <D.12896>; else goto <D.12897>;
      <D.12896>:
      _wapi_set_last_path_error_from_errno (0B, utf8_name);
      monoeg_g_free (utf8_name);
      D.12887 = 4294967295;
      return D.12887;
      <D.12897>:
      result = _wapi_lstat (utf8_name, &linkbuf);
      if (result != 0) goto <D.12898>; else goto <D.12899>;
      <D.12898>:
      _wapi_set_last_path_error_from_errno (0B, utf8_name);
      monoeg_g_free (utf8_name);
      D.12887 = 4294967295;
      return D.12887;
      <D.12899>:
      ret = _wapi_stat_to_file_attributes (utf8_name, &buf, &linkbuf);
      monoeg_g_free (utf8_name);
      D.12887 = ret;
      return D.12887;
    }
  finally
    {
      buf = {CLOBBER};
      linkbuf = {CLOBBER};
    }
}


GetFileAttributesEx (const gunichar2 * name, WapiGetFileExInfoLevels level, void * info)
{
  gboolean D.12904;
  int * D.12911;
  int D.12912;
  long int D.12919;
  long int D.12920;
  unsigned int D.12924;
  struct WapiFileTime * D.12925;
  struct WapiFileTime * D.12926;
  long int D.12927;
  struct WapiFileTime * D.12928;
  unsigned int D.12929;
  unsigned int D.12930;
  long long int D.12934;
  long long int D.12935;
  unsigned int D.12936;
  unsigned int D.12937;
  gchar * utf8_name;
  struct WapiFileAttributesData * data;
  struct stat buf;
  struct stat linkbuf;
  time_t create_time;
  int result;

  try
    {
      if (level != 0) goto <D.12902>; else goto <D.12903>;
      <D.12902>:
      SetLastError (87);
      D.12904 = 0;
      return D.12904;
      <D.12903>:
      if (name == 0B) goto <D.12905>; else goto <D.12906>;
      <D.12905>:
      SetLastError (123);
      D.12904 = 0;
      return D.12904;
      <D.12906>:
      utf8_name = mono_unicode_to_external (name);
      if (utf8_name == 0B) goto <D.12907>; else goto <D.12908>;
      <D.12907>:
      SetLastError (87);
      D.12904 = 0;
      return D.12904;
      <D.12908>:
      result = _wapi_stat (utf8_name, &buf);
      if (result == -1) goto <D.12909>; else goto <D.12910>;
      <D.12909>:
      D.12911 = __errno_location ();
      D.12912 = *D.12911;
      if (D.12912 == 2) goto <D.12913>; else goto <D.12914>;
      <D.12913>:
      result = _wapi_lstat (utf8_name, &buf);
      <D.12914>:
      <D.12910>:
      if (result != 0) goto <D.12915>; else goto <D.12916>;
      <D.12915>:
      _wapi_set_last_path_error_from_errno (0B, utf8_name);
      monoeg_g_free (utf8_name);
      D.12904 = 0;
      return D.12904;
      <D.12916>:
      result = _wapi_lstat (utf8_name, &linkbuf);
      if (result != 0) goto <D.12917>; else goto <D.12918>;
      <D.12917>:
      _wapi_set_last_path_error_from_errno (0B, utf8_name);
      monoeg_g_free (utf8_name);
      D.12904 = 0;
      return D.12904;
      <D.12918>:
      data = info;
      D.12919 = buf.st_mtim.tv_sec;
      D.12920 = buf.st_ctim.tv_sec;
      if (D.12919 < D.12920) goto <D.12921>; else goto <D.12922>;
      <D.12921>:
      create_time = buf.st_mtim.tv_sec;
      goto <D.12923>;
      <D.12922>:
      create_time = buf.st_ctim.tv_sec;
      <D.12923>:
      D.12924 = _wapi_stat_to_file_attributes (utf8_name, &buf, &linkbuf);
      data->dwFileAttributes = D.12924;
      monoeg_g_free (utf8_name);
      D.12925 = &data->ftCreationTime;
      _wapi_time_t_to_filetime (create_time, D.12925);
      D.12926 = &data->ftLastAccessTime;
      D.12927 = buf.st_atim.tv_sec;
      _wapi_time_t_to_filetime (D.12927, D.12926);
      D.12928 = &data->ftLastWriteTime;
      D.12919 = buf.st_mtim.tv_sec;
      _wapi_time_t_to_filetime (D.12919, D.12928);
      D.12929 = data->dwFileAttributes;
      D.12930 = D.12929 & 16;
      if (D.12930 != 0) goto <D.12931>; else goto <D.12932>;
      <D.12931>:
      data->nFileSizeHigh = 0;
      data->nFileSizeLow = 0;
      goto <D.12933>;
      <D.12932>:
      D.12934 = buf.st_size;
      D.12935 = D.12934 >> 32;
      D.12936 = (unsigned int) D.12935;
      data->nFileSizeHigh = D.12936;
      D.12934 = buf.st_size;
      D.12937 = (unsigned int) D.12934;
      data->nFileSizeLow = D.12937;
      <D.12933>:
      D.12904 = 1;
      return D.12904;
    }
  finally
    {
      buf = {CLOBBER};
      linkbuf = {CLOBBER};
    }
}


SetFileAttributes (const gunichar2 * name, guint32 attrs)
{
  gboolean D.12942;
  int * D.12947;
  int D.12948;
  unsigned int D.12953;
  unsigned int D.12956;
  unsigned int D.12957;
  unsigned int D.12959;
  signed int attrs.47;
  unsigned int D.12963;
  unsigned int D.12966;
  unsigned int D.12969;
  unsigned int D.12972;
  gchar * utf8_name;
  struct stat buf;
  int result;

  try
    {
      if (name == 0B) goto <D.12940>; else goto <D.12941>;
      <D.12940>:
      SetLastError (123);
      D.12942 = 0;
      return D.12942;
      <D.12941>:
      utf8_name = mono_unicode_to_external (name);
      if (utf8_name == 0B) goto <D.12943>; else goto <D.12944>;
      <D.12943>:
      SetLastError (123);
      D.12942 = 0;
      return D.12942;
      <D.12944>:
      result = _wapi_stat (utf8_name, &buf);
      if (result == -1) goto <D.12945>; else goto <D.12946>;
      <D.12945>:
      D.12947 = __errno_location ();
      D.12948 = *D.12947;
      if (D.12948 == 2) goto <D.12949>; else goto <D.12950>;
      <D.12949>:
      result = _wapi_lstat (utf8_name, &buf);
      <D.12950>:
      <D.12946>:
      if (result != 0) goto <D.12951>; else goto <D.12952>;
      <D.12951>:
      _wapi_set_last_path_error_from_errno (0B, utf8_name);
      monoeg_g_free (utf8_name);
      D.12942 = 0;
      return D.12942;
      <D.12952>:
      D.12953 = attrs & 1;
      if (D.12953 != 0) goto <D.12954>; else goto <D.12955>;
      <D.12954>:
      D.12956 = buf.st_mode;
      D.12957 = D.12956 & 4294967149;
      result = _wapi_chmod (utf8_name, D.12957);
      goto <D.12958>;
      <D.12955>:
      D.12956 = buf.st_mode;
      D.12959 = D.12956 | 128;
      result = _wapi_chmod (utf8_name, D.12959);
      <D.12958>:
      attrs.47 = (signed int) attrs;
      if (attrs.47 < 0) goto <D.12961>; else goto <D.12962>;
      <D.12961>:
      {
        mode_t exec_mask;

        exec_mask = 0;
        D.12956 = buf.st_mode;
        D.12963 = D.12956 & 256;
        if (D.12963 != 0) goto <D.12964>; else goto <D.12965>;
        <D.12964>:
        exec_mask = exec_mask | 64;
        <D.12965>:
        D.12956 = buf.st_mode;
        D.12966 = D.12956 & 32;
        if (D.12966 != 0) goto <D.12967>; else goto <D.12968>;
        <D.12967>:
        exec_mask = exec_mask | 8;
        <D.12968>:
        D.12956 = buf.st_mode;
        D.12969 = D.12956 & 4;
        if (D.12969 != 0) goto <D.12970>; else goto <D.12971>;
        <D.12970>:
        exec_mask = exec_mask | 1;
        <D.12971>:
        D.12956 = buf.st_mode;
        D.12972 = D.12956 | exec_mask;
        result = chmod (utf8_name, D.12972);
      }
      <D.12962>:
      monoeg_g_free (utf8_name);
      D.12942 = 1;
      return D.12942;
    }
  finally
    {
      buf = {CLOBBER};
    }
}


GetCurrentDirectory (guint32 length, gunichar2 * buffer)
{
  char * D.12975;
  int * D.12978;
  int D.12979;
  guint32 D.12984;
  unsigned int bytes.48;
  unsigned int D.12986;
  unsigned int D.12987;
  long unsigned int count.49;
  _Bool D.12989;
  long int D.12990;
  long int D.12991;
  unsigned int D.12994;
  gunichar2 * utf16_path;
  glong count;
  gsize bytes;

  try
    {
      D.12975 = getcwd (buffer, length);
      if (D.12975 == 0B) goto <D.12976>; else goto <D.12977>;
      <D.12976>:
      D.12978 = __errno_location ();
      D.12979 = *D.12978;
      if (D.12979 == 34) goto <D.12980>; else goto <D.12981>;
      <D.12980>:
      {
        gchar * path;

        path = monoeg_g_get_current_dir ();
        if (path == 0B) goto <D.12982>; else goto <D.12983>;
        <D.12982>:
        D.12984 = 0;
        return D.12984;
        <D.12983>:
        utf16_path = mono_unicode_from_external (path, &bytes);
        monoeg_g_free (utf16_path);
        monoeg_g_free (path);
        bytes.48 = bytes;
        D.12986 = bytes.48 / 2;
        D.12984 = D.12986 + 1;
        return D.12984;
      }
      <D.12981>:
      _wapi_set_last_error_from_errno ();
      D.12984 = 0;
      return D.12984;
      <D.12977>:
      utf16_path = mono_unicode_from_external (buffer, &bytes);
      bytes.48 = bytes;
      D.12986 = bytes.48 / 2;
      D.12987 = D.12986 + 1;
      count = (glong) D.12987;
      count.49 = (long unsigned int) count;
      D.12989 = count.49 > length;
      D.12990 = (long int) D.12989;
      D.12991 = __builtin_expect (D.12990, 0);
      if (D.12991 != 0) goto <D.12992>; else goto <D.12993>;
      <D.12992>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "io.c", 3320, "count <= length");
      <D.12993>:
      bytes.48 = bytes;
      D.12994 = bytes.48 + 2;
      memset (buffer, 0, D.12994);
      bytes.48 = bytes;
      memcpy (buffer, utf16_path, bytes.48);
      monoeg_g_free (utf16_path);
      D.12984 = (guint32) count;
      return D.12984;
    }
  finally
    {
      bytes = {CLOBBER};
    }
}


getcwd (char * __buf, size_t __size)
{
  unsigned int D.12997;
  int D.13000;
  char * D.13003;
  unsigned int D.13004;
  unsigned int D.13005;
  unsigned int D.13008;

  D.12997 = __builtin_object_size (__buf, 1);
  if (D.12997 != 4294967295) goto <D.12998>; else goto <D.12999>;
  <D.12998>:
  D.13000 = __builtin_constant_p (__size);
  if (D.13000 == 0) goto <D.13001>; else goto <D.13002>;
  <D.13001>:
  D.13004 = __builtin_object_size (__buf, 1);
  D.13003 = __getcwd_chk (__buf, __size, D.13004);
  return D.13003;
  <D.13002>:
  D.13005 = __builtin_object_size (__buf, 1);
  if (D.13005 < __size) goto <D.13006>; else goto <D.13007>;
  <D.13006>:
  D.13008 = __builtin_object_size (__buf, 1);
  D.13003 = __getcwd_chk_warn (__buf, __size, D.13008);
  return D.13003;
  <D.13007>:
  <D.12999>:
  D.13003 = __getcwd_alias (__buf, __size);
  return D.13003;
}


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

  if (path == 0B) goto <D.13010>; else goto <D.13011>;
  <D.13010>:
  SetLastError (87);
  D.13012 = 0;
  return D.13012;
  <D.13011>:
  utf8_path = mono_unicode_to_external (path);
  D.13013 = _wapi_chdir (utf8_path);
  if (D.13013 != 0) goto <D.13014>; else goto <D.13015>;
  <D.13014>:
  _wapi_set_last_error_from_errno ();
  result = 0;
  goto <D.13016>;
  <D.13015>:
  result = 1;
  <D.13016>:
  monoeg_g_free (utf8_path);
  D.13012 = result;
  return D.13012;
}


CreatePipe (void * * readpipe, void * * writepipe, struct WapiSecurityAttributes * security, guint32 size)
{
  gboolean D.13020;
  int D.13023;
  unsigned int D.13024;
  unsigned int _wapi_fd_reserve.50;
  int D.13027;
  unsigned int D.13028;
  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.13018>; else goto <D.13019>;
      <D.13018>:
      _wapi_set_last_error_from_errno ();
      D.13020 = 0;
      return D.13020;
      <D.13019>:
      D.13023 = filedes[0];
      D.13024 = (unsigned int) D.13023;
      _wapi_fd_reserve.50 = _wapi_fd_reserve;
      if (D.13024 >= _wapi_fd_reserve.50) goto <D.13021>; else goto <D.13026>;
      <D.13026>:
      D.13027 = filedes[1];
      D.13028 = (unsigned int) D.13027;
      _wapi_fd_reserve.50 = _wapi_fd_reserve;
      if (D.13028 >= _wapi_fd_reserve.50) goto <D.13021>; else goto <D.13022>;
      <D.13021>:
      SetLastError (4);
      D.13023 = filedes[0];
      close (D.13023);
      D.13027 = filedes[1];
      close (D.13027);
      D.13020 = 0;
      return D.13020;
      <D.13022>:
      D.13023 = filedes[0];
      pipe_read_handle.fd = D.13023;
      pipe_read_handle.fileaccess = 2147483648;
      D.13023 = filedes[0];
      read_handle = _wapi_handle_new_fd (10, D.13023, &pipe_read_handle);
      if (read_handle == 4294967295B) goto <D.13029>; else goto <D.13030>;
      <D.13029>:
      monoeg_g_log (0B, 16, "%s: error creating pipe read handle", &__func__);
      D.13023 = filedes[0];
      close (D.13023);
      D.13027 = filedes[1];
      close (D.13027);
      SetLastError (31);
      D.13020 = 0;
      return D.13020;
      <D.13030>:
      D.13027 = filedes[1];
      pipe_write_handle.fd = D.13027;
      pipe_write_handle.fileaccess = 1073741824;
      D.13027 = filedes[1];
      write_handle = _wapi_handle_new_fd (10, D.13027, &pipe_write_handle);
      if (write_handle == 4294967295B) goto <D.13031>; else goto <D.13032>;
      <D.13031>:
      monoeg_g_log (0B, 16, "%s: error creating pipe write handle", &__func__);
      _wapi_handle_unref (read_handle);
      D.13023 = filedes[0];
      close (D.13023);
      D.13027 = filedes[1];
      close (D.13027);
      SetLastError (31);
      D.13020 = 0;
      return D.13020;
      <D.13032>:
      *readpipe = read_handle;
      *writepipe = write_handle;
      D.13020 = 1;
      return D.13020;
    }
  finally
    {
      pipe_read_handle = {CLOBBER};
      pipe_write_handle = {CLOBBER};
      filedes = {CLOBBER};
    }
}


GetTempPath (guint32 len, gunichar2 * buf)
{
  const gchar * D.13035;
  unsigned int D.13036;
  gchar * D.13037;
  char D.13038;
  const gchar * D.13041;
  guint32 D.13044;
  unsigned int bytes.51;
  unsigned int D.13046;
  long int D.13047;
  long unsigned int D.13048;
  unsigned int D.13052;
  gchar * tmpdir;
  gunichar2 * tmpdir16;
  glong dirlen;
  gsize bytes;
  guint32 ret;

  try
    {
      D.13035 = monoeg_g_get_tmp_dir ();
      tmpdir = monoeg_strdup (D.13035);
      tmpdir16 = 0B;
      D.13036 = strlen (tmpdir);
      D.13037 = tmpdir + D.13036;
      D.13038 = *D.13037;
      if (D.13038 != 47) goto <D.13039>; else goto <D.13040>;
      <D.13039>:
      monoeg_g_free (tmpdir);
      D.13041 = monoeg_g_get_tmp_dir ();
      tmpdir = monoeg_g_strdup_printf ("%s/", D.13041);
      <D.13040>:
      tmpdir16 = mono_unicode_from_external (tmpdir, &bytes);
      if (tmpdir16 == 0B) goto <D.13042>; else goto <D.13043>;
      <D.13042>:
      monoeg_g_free (tmpdir);
      D.13044 = 0;
      return D.13044;
      <D.13043>:
      bytes.51 = bytes;
      D.13046 = bytes.51 / 2;
      dirlen = (glong) D.13046;
      D.13047 = dirlen + 1;
      D.13048 = (long unsigned int) D.13047;
      if (D.13048 > len) goto <D.13049>; else goto <D.13050>;
      <D.13049>:
      D.13047 = dirlen + 1;
      ret = (guint32) D.13047;
      goto <D.13051>;
      <D.13050>:
      bytes.51 = bytes;
      D.13052 = bytes.51 + 2;
      memset (buf, 0, D.13052);
      bytes.51 = bytes;
      memcpy (buf, tmpdir16, bytes.51);
      ret = (guint32) dirlen;
      <D.13051>:
      if (tmpdir16 != 0B) goto <D.13053>; else goto <D.13054>;
      <D.13053>:
      monoeg_g_free (tmpdir16);
      <D.13054>:
      monoeg_g_free (tmpdir);
      D.13044 = ret;
      return D.13044;
    }
  finally
    {
      bytes = {CLOBBER};
    }
}


GetLogicalDriveStrings (guint32 len, gunichar2 * buf)
{
  unsigned int D.13057;
  unsigned int D.13065;
  char D.13066;
  unsigned int D.13069;
  gchar * D.13070;
  int D.13075;
  int D.13076;
  int D.13077;
  gint32 D.13080;
  int fd;
  gint32 ret;
  struct LinuxMountInfoParseState state;
  gboolean (*<T1c73>) (guint32, gunichar2 *, struct LinuxMountInfoParseState *) parser;
  void done_and_out = <<< error >>>;

  try
    {
      ret = 0;
      parser = 0B;
      D.13057 = len * 2;
      memset (buf, 0, D.13057);
      fd = open ("/proc/self/mountinfo", 0);
      if (fd != -1) goto <D.13058>; else goto <D.13059>;
      <D.13058>:
      parser = GetLogicalDriveStrings_MountInfo;
      goto <D.13060>;
      <D.13059>:
      fd = open ("/proc/mounts", 0);
      if (fd != -1) goto <D.13061>; else goto <D.13062>;
      <D.13061>:
      parser = GetLogicalDriveStrings_Mounts;
      <D.13062>:
      <D.13060>:
      if (parser == 0B) goto <D.13063>; else goto <D.13064>;
      <D.13063>:
      ret = GetLogicalDriveStrings_Mtab (len, buf);
      goto done_and_out;
      <D.13064>:
      memset (&state, 0, 1204);
      state.field_number = 1;
      state.delimiter = 32;
      goto <D.11593>;
      <D.11592>:
      state.buffer_index = 0;
      goto <D.11590>;
      <D.11589>:
      D.13065 = state.buffer_index;
      D.13066 = state.buffer[D.13065];
      if (D.13066 == 10) goto <D.13067>; else goto <D.13068>;
      <D.13067>:
      {
        gboolean quit;

        quit = add_drive_string (len, buf, &state);
        state.field_number = 1;
        D.13065 = state.buffer_index;
        D.13069 = D.13065 + 1;
        state.buffer_index = D.13069;
        D.13070 = state.mountpoint_allocated;
        if (D.13070 != 0B) goto <D.13071>; else goto <D.13072>;
        <D.13071>:
        D.13070 = state.mountpoint_allocated;
        monoeg_g_free (D.13070);
        state.mountpoint_allocated = 0B;
        <D.13072>:
        if (quit != 0) goto <D.13073>; else goto <D.13074>;
        <D.13073>:
        ret = state.total;
        goto done_and_out;
        <D.13074>:
      }
      <D.13068>:
      <D.11590>:
      D.13075 = parser (len, buf, &state);
      if (D.13075 != 0) goto <D.11589>; else goto <D.11591>;
      <D.11591>:
      <D.11593>:
      D.13076 = read (fd, &state.buffer, 512);
      state.nbytes = D.13076;
      D.13077 = state.nbytes;
      if (D.13077 > 0) goto <D.11592>; else goto <D.11594>;
      <D.11594>:
      ret = state.total;
      done_and_out:
      if (fd != -1) goto <D.13078>; else goto <D.13079>;
      <D.13078>:
      close (fd);
      <D.13079>:
      D.13080 = ret;
      return D.13080;
    }
  finally
    {
      state = {CLOBBER};
    }
}


GetLogicalDriveStrings_Mounts (guint32 len, gunichar2 * buf, struct LinuxMountInfoParseState * state)
{
  unsigned int D.13083;
  unsigned int D.13086;
  char D.13087;
  char D.13088;
  unsigned int D.13091;
  gchar * D.13092;
  unsigned int D.13095;
  gchar * D.13096;
  unsigned int D.13098;
  gchar * D.13099;
  int ptr.52;
  gchar[512] * D.13103;
  int D.13104;
  int D.13105;
  int D.13106;
  unsigned int D.13107;
  int D.13109;
  unsigned int D.13110;
  gboolean D.13111;
  unsigned int D.13112;
  int D.13115;
  unsigned int D.13118;
  unsigned int D.13123;
  unsigned int D.13124;
  unsigned int D.13127;
  unsigned int D.13128;
  unsigned int D.13129;
  unsigned int D.13132;
  unsigned int D.13133;
  gchar * ptr;

  D.13083 = state->field_number;
  if (D.13083 == 1) goto <D.13084>; else goto <D.13085>;
  <D.13084>:
  state->check_mount_source = 1;
  <D.13085>:
  goto <D.11605>;
  <D.11610>:
  D.13086 = state->buffer_index;
  D.13087 = state->buffer[D.13086];
  D.13088 = state->delimiter;
  if (D.13087 == D.13088) goto <D.13089>; else goto <D.13090>;
  <D.13089>:
  D.13083 = state->field_number;
  D.13091 = D.13083 + 1;
  state->field_number = D.13091;
  D.13083 = state->field_number;
  switch (D.13083) <default: <D.11604>, case 2: <D.11601>, case 3: <D.11603>>
  <D.11601>:
  state->mountpoint_index = 0;
  goto <D.11602>;
  <D.11603>:
  D.13092 = state->mountpoint_allocated;
  if (D.13092 != 0B) goto <D.13093>; else goto <D.13094>;
  <D.13093>:
  D.13092 = state->mountpoint_allocated;
  D.13095 = state->mountpoint_index;
  D.13096 = D.13092 + D.13095;
  *D.13096 = 0;
  goto <D.13097>;
  <D.13094>:
  D.13095 = state->mountpoint_index;
  state->mountpoint[D.13095] = 0;
  <D.13097>:
  goto <D.11602>;
  <D.11604>:
  D.13086 = state->buffer_index;
  D.13098 = 512 - D.13086;
  D.13086 = state->buffer_index;
  D.13099 = &state->buffer[D.13086];
  ptr = memchr (D.13099, 10, D.13098);
  if (ptr != 0B) goto <D.13100>; else goto <D.13101>;
  <D.13100>:
  ptr.52 = (int) ptr;
  D.13103 = &state->buffer;
  D.13104 = (int) D.13103;
  D.13105 = ptr.52 - D.13104;
  D.13106 = D.13105 + -1;
  D.13107 = (unsigned int) D.13106;
  state->buffer_index = D.13107;
  goto <D.13108>;
  <D.13101>:
  D.13109 = state->nbytes;
  D.13110 = (unsigned int) D.13109;
  state->buffer_index = D.13110;
  <D.13108>:
  D.13111 = 1;
  return D.13111;
  <D.11602>:
  D.13086 = state->buffer_index;
  D.13112 = D.13086 + 1;
  state->buffer_index = D.13112;
  // predicted unlikely by continue predictor.
  goto <D.11605>;
  <D.13090>:
  D.13086 = state->buffer_index;
  D.13087 = state->buffer[D.13086];
  if (D.13087 == 10) goto <D.13113>; else goto <D.13114>;
  <D.13113>:
  D.13111 = 1;
  return D.13111;
  <D.13114>:
  D.13083 = state->field_number;
  switch (D.13083) <default: <D.13134>, case 1: <D.11606>, case 2: <D.11608>, case 3: <D.11609>>
  <D.11606>:
  D.13115 = state->check_mount_source;
  if (D.13115 != 0) goto <D.13116>; else goto <D.13117>;
  <D.13116>:
  D.13118 = state->fsname_index;
  if (D.13118 == 0) goto <D.13119>; else goto <D.13120>;
  <D.13119>:
  D.13086 = state->buffer_index;
  D.13087 = state->buffer[D.13086];
  if (D.13087 == 47) goto <D.13121>; else goto <D.13122>;
  <D.13121>:
  state->check_mount_source = 0;
  D.13118 = state->fsname_index;
  D.13123 = D.13118;
  D.13124 = D.13123 + 1;
  state->fsname_index = D.13124;
  state->fsname[D.13123] = 47;
  goto <D.11607>;
  <D.13122>:
  <D.13120>:
  D.13118 = state->fsname_index;
  if (D.13118 <= 63) goto <D.13125>; else goto <D.13126>;
  <D.13125>:
  D.13118 = state->fsname_index;
  D.13127 = D.13118;
  D.13128 = D.13127 + 1;
  state->fsname_index = D.13128;
  D.13086 = state->buffer_index;
  D.13087 = state->buffer[D.13086];
  state->fsname[D.13127] = D.13087;
  <D.13126>:
  <D.13117>:
  goto <D.11607>;
  <D.11608>:
  append_to_mountpoint (state);
  goto <D.11607>;
  <D.11609>:
  D.13129 = state->fstype_index;
  if (D.13129 <= 63) goto <D.13130>; else goto <D.13131>;
  <D.13130>:
  D.13129 = state->fstype_index;
  D.13132 = D.13129;
  D.13133 = D.13132 + 1;
  state->fstype_index = D.13133;
  D.13086 = state->buffer_index;
  D.13087 = state->buffer[D.13086];
  state->fstype[D.13132] = D.13087;
  <D.13131>:
  goto <D.11607>;
  <D.13134>:
  <D.11607>:
  D.13086 = state->buffer_index;
  D.13112 = D.13086 + 1;
  state->buffer_index = D.13112;
  <D.11605>:
  D.13086 = state->buffer_index;
  D.13109 = state->nbytes;
  D.13110 = (unsigned int) D.13109;
  if (D.13086 < D.13110) goto <D.11610>; else goto <D.11611>;
  <D.11611>:
  D.13111 = 0;
  return D.13111;
}


append_to_mountpoint (struct LinuxMountInfoParseState * state)
{
  unsigned int D.13136;
  gchar * D.13137;
  unsigned int D.13140;
  unsigned int D.13141;
  unsigned int D.13144;
  unsigned int D.13145;
  unsigned int D.13146;
  gchar * D.13147;
  unsigned int D.13151;
  unsigned int D.13152;
  void * D.13153;
  gchar[513] * D.13154;
  unsigned int D.13155;
  unsigned int D.13156;
  gchar * D.13157;
  unsigned int D.13159;
  unsigned int D.13160;
  gchar ch;

  D.13136 = state->buffer_index;
  ch = state->buffer[D.13136];
  D.13137 = state->mountpoint_allocated;
  if (D.13137 != 0B) goto <D.13138>; else goto <D.13139>;
  <D.13138>:
  D.13140 = state->mountpoint_index;
  D.13141 = state->allocated_size;
  if (D.13140 >= D.13141) goto <D.13142>; else goto <D.13143>;
  <D.13142>:
  {
    guint32 newsize;
    gchar * newbuf;

    D.13141 = state->allocated_size;
    D.13144 = D.13141 << 1;
    newsize = D.13144 + 1;
    newbuf = monoeg_malloc0 (newsize);
    D.13140 = state->mountpoint_index;
    D.13137 = state->mountpoint_allocated;
    memcpy (newbuf, D.13137, D.13140);
    D.13137 = state->mountpoint_allocated;
    monoeg_g_free (D.13137);
    state->mountpoint_allocated = newbuf;
    state->allocated_size = newsize;
  }
  <D.13143>:
  D.13137 = state->mountpoint_allocated;
  D.13140 = state->mountpoint_index;
  D.13145 = D.13140;
  D.13146 = D.13145 + 1;
  state->mountpoint_index = D.13146;
  D.13147 = D.13137 + D.13145;
  *D.13147 = ch;
  goto <D.13148>;
  <D.13139>:
  D.13140 = state->mountpoint_index;
  if (D.13140 > 511) goto <D.13149>; else goto <D.13150>;
  <D.13149>:
  D.13140 = state->mountpoint_index;
  D.13151 = D.13140 << 1;
  D.13152 = D.13151 + 1;
  state->allocated_size = D.13152;
  D.13141 = state->allocated_size;
  D.13153 = monoeg_malloc0 (D.13141);
  state->mountpoint_allocated = D.13153;
  D.13140 = state->mountpoint_index;
  D.13154 = &state->mountpoint;
  D.13137 = state->mountpoint_allocated;
  memcpy (D.13137, D.13154, D.13140);
  D.13137 = state->mountpoint_allocated;
  D.13140 = state->mountpoint_index;
  D.13155 = D.13140;
  D.13156 = D.13155 + 1;
  state->mountpoint_index = D.13156;
  D.13157 = D.13137 + D.13155;
  *D.13157 = ch;
  goto <D.13158>;
  <D.13150>:
  D.13140 = state->mountpoint_index;
  D.13159 = D.13140;
  D.13160 = D.13159 + 1;
  state->mountpoint_index = D.13160;
  state->mountpoint[D.13159] = ch;
  <D.13158>:
  <D.13148>:
}


GetLogicalDriveStrings_MountInfo (guint32 len, gunichar2 * buf, struct LinuxMountInfoParseState * state)
{
  unsigned int D.13161;
  char D.13162;
  char D.13163;
  unsigned int D.13166;
  unsigned int D.13167;
  gchar * D.13168;
  unsigned int D.13171;
  gchar * D.13172;
  unsigned int D.13175;
  gboolean D.13178;
  unsigned int D.13179;
  unsigned int D.13182;
  unsigned int D.13183;
  int D.13184;
  unsigned int D.13187;
  unsigned int D.13192;
  unsigned int D.13193;
  unsigned int D.13196;
  unsigned int D.13197;
  int D.13199;
  unsigned int D.13200;

  goto <D.11623>;
  <D.11628>:
  D.13161 = state->buffer_index;
  D.13162 = state->buffer[D.13161];
  D.13163 = state->delimiter;
  if (D.13162 == D.13163) goto <D.13164>; else goto <D.13165>;
  <D.13164>:
  D.13166 = state->field_number;
  D.13167 = D.13166 + 1;
  state->field_number = D.13167;
  D.13166 = state->field_number;
  switch (D.13166) <default: <D.13174>, case 5: <D.11617>, case 6: <D.11619>, case 7: <D.11620>, case 8: <D.11621>, case 10: <D.11622>>
  <D.11617>:
  state->mountpoint_index = 0;
  goto <D.11618>;
  <D.11619>:
  D.13168 = state->mountpoint_allocated;
  if (D.13168 != 0B) goto <D.13169>; else goto <D.13170>;
  <D.13169>:
  D.13168 = state->mountpoint_allocated;
  D.13171 = state->mountpoint_index;
  D.13172 = D.13168 + D.13171;
  *D.13172 = 0;
  goto <D.13173>;
  <D.13170>:
  D.13171 = state->mountpoint_index;
  state->mountpoint[D.13171] = 0;
  <D.13173>:
  goto <D.11618>;
  <D.11620>:
  state->delimiter = 45;
  goto <D.11618>;
  <D.11621>:
  state->delimiter = 32;
  goto <D.11618>;
  <D.11622>:
  state->check_mount_source = 1;
  goto <D.11618>;
  <D.13174>:
  <D.11618>:
  D.13161 = state->buffer_index;
  D.13175 = D.13161 + 1;
  state->buffer_index = D.13175;
  // predicted unlikely by continue predictor.
  goto <D.11623>;
  <D.13165>:
  D.13161 = state->buffer_index;
  D.13162 = state->buffer[D.13161];
  if (D.13162 == 10) goto <D.13176>; else goto <D.13177>;
  <D.13176>:
  D.13178 = 1;
  return D.13178;
  <D.13177>:
  D.13166 = state->field_number;
  switch (D.13166) <default: <D.13198>, case 5: <D.11624>, case 9: <D.11626>, case 10: <D.11627>>
  <D.11624>:
  append_to_mountpoint (state);
  goto <D.11625>;
  <D.11626>:
  D.13179 = state->fstype_index;
  if (D.13179 <= 63) goto <D.13180>; else goto <D.13181>;
  <D.13180>:
  D.13179 = state->fstype_index;
  D.13182 = D.13179;
  D.13183 = D.13182 + 1;
  state->fstype_index = D.13183;
  D.13161 = state->buffer_index;
  D.13162 = state->buffer[D.13161];
  state->fstype[D.13182] = D.13162;
  <D.13181>:
  goto <D.11625>;
  <D.11627>:
  D.13184 = state->check_mount_source;
  if (D.13184 != 0) goto <D.13185>; else goto <D.13186>;
  <D.13185>:
  D.13187 = state->fsname_index;
  if (D.13187 == 0) goto <D.13188>; else goto <D.13189>;
  <D.13188>:
  D.13161 = state->buffer_index;
  D.13162 = state->buffer[D.13161];
  if (D.13162 == 47) goto <D.13190>; else goto <D.13191>;
  <D.13190>:
  state->check_mount_source = 0;
  D.13187 = state->fsname_index;
  D.13192 = D.13187;
  D.13193 = D.13192 + 1;
  state->fsname_index = D.13193;
  state->fsname[D.13192] = 47;
  goto <D.11625>;
  <D.13191>:
  <D.13189>:
  D.13187 = state->fsname_index;
  if (D.13187 <= 63) goto <D.13194>; else goto <D.13195>;
  <D.13194>:
  D.13187 = state->fsname_index;
  D.13196 = D.13187;
  D.13197 = D.13196 + 1;
  state->fsname_index = D.13197;
  D.13161 = state->buffer_index;
  D.13162 = state->buffer[D.13161];
  state->fsname[D.13196] = D.13162;
  <D.13195>:
  <D.13186>:
  goto <D.11625>;
  <D.13198>:
  <D.11625>:
  D.13161 = state->buffer_index;
  D.13175 = D.13161 + 1;
  state->buffer_index = D.13175;
  <D.11623>:
  D.13161 = state->buffer_index;
  D.13199 = state->nbytes;
  D.13200 = (unsigned int) D.13199;
  if (D.13161 < D.13200) goto <D.11628>; else goto <D.11629>;
  <D.11629>:
  D.13178 = 0;
  return D.13178;
}


open (const char * __path, int __oflag)
{
  int D.13202;
  int D.13205;
  int D.13210;
  int D.13212;
  int D.13213;
  int D.13216;
  int D.13217;

  D.13202 = __builtin_va_arg_pack_len ();
  if (D.13202 > 1) goto <D.13203>; else goto <D.13204>;
  <D.13203>:
  __open_too_many_args ();
  <D.13204>:
  D.13205 = __builtin_constant_p (__oflag);
  if (D.13205 != 0) goto <D.13206>; else goto <D.13207>;
  <D.13206>:
  D.13210 = __oflag & 64;
  if (D.13210 != 0) goto <D.13208>; else goto <D.13211>;
  <D.13211>:
  D.13212 = __oflag & 4259840;
  if (D.13212 == 4259840) goto <D.13208>; else goto <D.13209>;
  <D.13208>:
  D.13213 = __builtin_va_arg_pack_len ();
  if (D.13213 <= 0) goto <D.13214>; else goto <D.13215>;
  <D.13214>:
  __open_missing_mode ();
  D.13216 = __open_2 (__path, __oflag);
  return D.13216;
  <D.13215>:
  <D.13209>:
  D.13216 = __open_alias (__path, __oflag, __builtin_va_arg_pack ());
  return D.13216;
  <D.13207>:
  D.13217 = __builtin_va_arg_pack_len ();
  if (D.13217 <= 0) goto <D.13218>; else goto <D.13219>;
  <D.13218>:
  D.13216 = __open_2 (__path, __oflag);
  return D.13216;
  <D.13219>:
  D.13216 = __open_alias (__path, __oflag, __builtin_va_arg_pack ());
  return D.13216;
}


GetLogicalDriveStrings_Mtab (guint32 len, gunichar2 * buf)
{
  unsigned int D.13221;
  unsigned int D.13222;
  gunichar2 * D.13223;
  gunichar2 * D.13224;
  gint32 D.13229;
  char D.13230;
  gchar * D.13235;
  gchar * * D.13237;
  gchar * D.13238;
  long int length.53;
  long int D.13240;
  long int D.13241;
  long unsigned int D.13242;
  unsigned int D.13245;
  long unsigned int length.54;
  long unsigned int D.13247;
  unsigned int total.55;
  unsigned int D.13249;
  gunichar2 * D.13250;
  long int D.13251;
  char * D.13252;
  struct FILE * fp;
  gunichar2 * ptr;
  gunichar2 * dir;
  glong length;
  glong total;
  gchar buffer[512];
  gchar * * splitted;

  try
    {
      total = 0;
      D.13221 = len + 1;
      D.13222 = D.13221 * 2;
      memset (buf, 0, D.13222);
      *buf = 47;
      D.13223 = buf + 2;
      *D.13223 = 0;
      D.13224 = buf + 4;
      *D.13224 = 0;
      fp = fopen ("/etc/mtab", "rt");
      if (fp == 0B) goto <D.13225>; else goto <D.13226>;
      <D.13225>:
      fp = fopen ("/etc/mnttab", "rt");
      if (fp == 0B) goto <D.13227>; else goto <D.13228>;
      <D.13227>:
      D.13229 = 1;
      return D.13229;
      <D.13228>:
      <D.13226>:
      ptr = buf;
      goto <D.11657>;
      <D.11658>:
      D.13230 = buffer[0];
      if (D.13230 != 47) goto <D.13231>; else goto <D.13232>;
      <D.13231>:
      // predicted unlikely by continue predictor.
      goto <D.11657>;
      <D.13232>:
      splitted = monoeg_g_strsplit (&buffer, " ", 0);
      D.13235 = *splitted;
      if (D.13235 == 0B) goto <D.13233>; else goto <D.13236>;
      <D.13236>:
      D.13237 = splitted + 4;
      D.13238 = *D.13237;
      if (D.13238 == 0B) goto <D.13233>; else goto <D.13234>;
      <D.13233>:
      monoeg_g_strfreev (splitted);
      // predicted unlikely by continue predictor.
      goto <D.11657>;
      <D.13234>:
      D.13237 = splitted + 4;
      D.13238 = *D.13237;
      unescape_octal (D.13238);
      D.13237 = splitted + 4;
      D.13238 = *D.13237;
      dir = monoeg_g_utf8_to_utf16 (D.13238, -1, 0B, &length, 0B);
      monoeg_g_strfreev (splitted);
      length.53 = length;
      D.13240 = total + length.53;
      D.13241 = D.13240 + 1;
      D.13242 = (long unsigned int) D.13241;
      if (D.13242 > len) goto <D.13243>; else goto <D.13244>;
      <D.13243>:
      fclose (fp);
      monoeg_g_free (dir);
      D.13245 = len * 2;
      D.13229 = (gint32) D.13245;
      return D.13229;
      <D.13244>:
      length.53 = length;
      length.54 = (long unsigned int) length.53;
      D.13247 = length.54 * 2;
      total.55 = (unsigned int) total;
      D.13249 = total.55 * 2;
      D.13250 = ptr + D.13249;
      memcpy (D.13250, dir, D.13247);
      monoeg_g_free (dir);
      length.53 = length;
      D.13251 = length.53 + 1;
      total = D.13251 + total;
      <D.11657>:
      D.13252 = fgets (&buffer, 512, fp);
      if (D.13252 != 0B) goto <D.11658>; else goto <D.11659>;
      <D.11659>:
      fclose (fp);
      D.13229 = total;
      return D.13229;
    }
  finally
    {
      length = {CLOBBER};
      buffer = {CLOBBER};
    }
}


unescape_octal (gchar * str)
{
  char D.13257;
  gchar * rptr.56;
  char D.13261;
  int D.13262;
  int D.13263;
  int D.13264;
  gchar * rptr.57;
  char D.13266;
  int D.13267;
  int D.13268;
  int D.13269;
  unsigned char D.13270;
  unsigned char c.58;
  unsigned char D.13272;
  gchar * rptr.59;
  char D.13274;
  int D.13275;
  int D.13276;
  unsigned char D.13277;
  unsigned char D.13278;
  gchar * wptr.60;
  gchar * wptr.61;
  gchar * rptr.62;
  char D.13285;
  gchar * rptr;
  gchar * wptr;

  if (str == 0B) goto <D.13255>; else goto <D.13256>;
  <D.13255>:
  return;
  <D.13256>:
  wptr = str;
  rptr = wptr;
  goto <D.11540>;
  <D.11539>:
  D.13257 = *rptr;
  if (D.13257 == 92) goto <D.13258>; else goto <D.13259>;
  <D.13258>:
  {
    char c;

    rptr = rptr + 1;
    rptr.56 = rptr;
    rptr = rptr.56 + 1;
    D.13261 = *rptr.56;
    D.13262 = (int) D.13261;
    D.13263 = D.13262 + -48;
    D.13264 = D.13263 << 6;
    c = (char) D.13264;
    rptr.57 = rptr;
    rptr = rptr.57 + 1;
    D.13266 = *rptr.57;
    D.13267 = (int) D.13266;
    D.13268 = D.13267 + -48;
    D.13269 = D.13268 << 3;
    D.13270 = (unsigned char) D.13269;
    c.58 = (unsigned char) c;
    D.13272 = D.13270 + c.58;
    c = (char) D.13272;
    rptr.59 = rptr;
    rptr = rptr.59 + 1;
    D.13274 = *rptr.59;
    D.13275 = (int) D.13274;
    D.13276 = D.13275 + -48;
    D.13277 = (unsigned char) D.13276;
    c.58 = (unsigned char) c;
    D.13278 = D.13277 + c.58;
    c = (char) D.13278;
    wptr.60 = wptr;
    wptr = wptr.60 + 1;
    *wptr.60 = c;
  }
  goto <D.13280>;
  <D.13259>:
  if (wptr != rptr) goto <D.13281>; else goto <D.13282>;
  <D.13281>:
  wptr.61 = wptr;
  wptr = wptr.61 + 1;
  rptr.62 = rptr;
  rptr = rptr.62 + 1;
  D.13285 = *rptr.62;
  *wptr.61 = D.13285;
  goto <D.13286>;
  <D.13282>:
  rptr = rptr + 1;
  wptr = wptr + 1;
  <D.13286>:
  <D.13280>:
  <D.11540>:
  D.13257 = *rptr;
  if (D.13257 != 0) goto <D.11539>; else goto <D.11541>;
  <D.11541>:
  *wptr = 0;
}


fgets (char * restrict __s, int __n, struct FILE * restrict __stream)
{
  unsigned int D.13288;
  int D.13293;
  char * D.13295;
  unsigned int D.13296;
  unsigned int __n.63;
  unsigned int D.13298;
  unsigned int D.13301;

  D.13288 = __builtin_object_size (__s, 1);
  if (D.13288 != 4294967295) goto <D.13289>; else goto <D.13290>;
  <D.13289>:
  D.13293 = __builtin_constant_p (__n);
  if (D.13293 == 0) goto <D.13291>; else goto <D.13294>;
  <D.13294>:
  if (__n <= 0) goto <D.13291>; else goto <D.13292>;
  <D.13291>:
  D.13296 = __builtin_object_size (__s, 1);
  D.13295 = __fgets_chk (__s, D.13296, __n, __stream);
  return D.13295;
  <D.13292>:
  __n.63 = (unsigned int) __n;
  D.13298 = __builtin_object_size (__s, 1);
  if (__n.63 > D.13298) goto <D.13299>; else goto <D.13300>;
  <D.13299>:
  D.13301 = __builtin_object_size (__s, 1);
  D.13295 = __fgets_chk_warn (__s, D.13301, __n, __stream);
  return D.13295;
  <D.13300>:
  <D.13290>:
  D.13295 = __fgets_alias (__s, __n, __stream);
  return D.13295;
}


add_drive_string (guint32 len, gunichar2 * buf, struct LinuxMountInfoParseState * state)
{
  unsigned int D.13305;
  char D.13307;
  gchar[65] * D.13313;
  int D.13314;
  unsigned int D.13317;
  gchar[65] * D.13319;
  int D.13320;
  int D.13325;
  gchar * iftmp.64;
  gchar * D.13330;
  long int D.13334;
  long int length.65;
  long int D.13336;
  long int D.13337;
  long unsigned int D.13338;
  unsigned int D.13341;
  long int D.13342;
  long int length.66;
  long unsigned int length.67;
  long unsigned int D.13346;
  unsigned int D.13347;
  unsigned int D.13348;
  gunichar2 * D.13349;
  gboolean D.13350;
  gboolean quit;
  gboolean ignore_entry;

  quit = 0;
  D.13305 = state->fsname_index;
  if (D.13305 == 1) goto <D.13306>; else goto <D.13303>;
  <D.13306>:
  D.13307 = state->fsname[0];
  if (D.13307 == 47) goto <D.13308>; else goto <D.13303>;
  <D.13308>:
  ignore_entry = 0;
  goto <D.13304>;
  <D.13303>:
  D.13305 = state->fsname_index;
  if (D.13305 == 0) goto <D.13309>; else goto <D.13312>;
  <D.13312>:
  D.13305 = state->fsname_index;
  D.13313 = &state->fsname;
  D.13314 = memcmp ("none", D.13313, D.13305);
  if (D.13314 == 0) goto <D.13309>; else goto <D.13310>;
  <D.13309>:
  ignore_entry = 1;
  goto <D.13311>;
  <D.13310>:
  D.13317 = state->fstype_index;
  if (D.13317 > 4) goto <D.13318>; else goto <D.13315>;
  <D.13318>:
  D.13319 = &state->fstype;
  D.13320 = memcmp ("fuse.", D.13319, 5);
  if (D.13320 == 0) goto <D.13321>; else goto <D.13315>;
  <D.13321>:
  D.13317 = state->fstype_index;
  if (D.13317 == 21) goto <D.13324>; else goto <D.13322>;
  <D.13324>:
  D.13317 = state->fstype_index;
  D.13319 = &state->fstype;
  D.13325 = memcmp ("fuse.gvfs-fuse-daemon", D.13319, D.13317);
  if (D.13325 == 0) goto <D.13326>; else goto <D.13322>;
  <D.13326>:
  ignore_entry = 1;
  goto <D.13323>;
  <D.13322>:
  ignore_entry = 0;
  <D.13323>:
  goto <D.13316>;
  <D.13315>:
  ignore_entry = 1;
  <D.13316>:
  <D.13311>:
  <D.13304>:
  if (ignore_entry == 0) goto <D.13327>; else goto <D.13328>;
  <D.13327>:
  {
    gunichar2 * dir;
    glong length;
    gchar * mountpoint;

    try
      {
        D.13330 = state->mountpoint_allocated;
        if (D.13330 != 0B) goto <D.13331>; else goto <D.13332>;
        <D.13331>:
        iftmp.64 = state->mountpoint_allocated;
        goto <D.13333>;
        <D.13332>:
        iftmp.64 = &state->mountpoint;
        <D.13333>:
        mountpoint = iftmp.64;
        unescape_octal (mountpoint);
        dir = monoeg_g_utf8_to_utf16 (mountpoint, -1, 0B, &length, 0B);
        D.13334 = state->total;
        length.65 = length;
        D.13336 = D.13334 + length.65;
        D.13337 = D.13336 + 1;
        D.13338 = (long unsigned int) D.13337;
        if (D.13338 > len) goto <D.13339>; else goto <D.13340>;
        <D.13339>:
        quit = 1;
        D.13341 = len * 2;
        D.13342 = (long int) D.13341;
        state->total = D.13342;
        goto <D.13343>;
        <D.13340>:
        length.65 = length;
        length.66 = length.65 + 1;
        length = length.66;
        length.65 = length;
        length.67 = (long unsigned int) length.65;
        D.13346 = length.67 * 2;
        D.13334 = state->total;
        D.13347 = (unsigned int) D.13334;
        D.13348 = D.13347 * 2;
        D.13349 = buf + D.13348;
        memcpy (D.13349, dir, D.13346);
        D.13334 = state->total;
        length.65 = length;
        D.13336 = D.13334 + length.65;
        state->total = D.13336;
        <D.13343>:
        monoeg_g_free (dir);
      }
    finally
      {
        length = {CLOBBER};
      }
  }
  <D.13328>:
  state->fsname_index = 0;
  state->fstype_index = 0;
  D.13350 = quit;
  return D.13350;
}


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.13354;
  gboolean D.13357;
  long unsigned int D.13361;
  long unsigned int D.13362;
  _Bool D.13363;
  int * D.13365;
  int D.13366;
  long long unsigned int D.13374;
  long long unsigned int D.13375;
  long long unsigned int D.13376;
  long long unsigned int D.13379;
  long long unsigned int D.13380;
  long long unsigned int D.13386;
  long long unsigned int D.13387;
  struct statvfs fsstat;
  gboolean isreadonly;
  gchar * utf8_path_name;
  int ret;
  long unsigned int block_size;

  try
    {
      if (path_name == 0B) goto <D.13352>; else goto <D.13353>;
      <D.13352>:
      D.13354 = monoeg_g_get_current_dir ();
      utf8_path_name = monoeg_strdup (D.13354);
      if (utf8_path_name == 0B) goto <D.13355>; else goto <D.13356>;
      <D.13355>:
      SetLastError (267);
      D.13357 = 0;
      return D.13357;
      <D.13356>:
      goto <D.13358>;
      <D.13353>:
      utf8_path_name = mono_unicode_to_external (path_name);
      if (utf8_path_name == 0B) goto <D.13359>; else goto <D.13360>;
      <D.13359>:
      SetLastError (123);
      D.13357 = 0;
      return D.13357;
      <D.13360>:
      <D.13358>:
      <D.11671>:
      ret = statvfs (utf8_path_name, &fsstat);
      D.13361 = fsstat.f_flag;
      D.13362 = D.13361 & 1;
      D.13363 = D.13362 != 0;
      isreadonly = (gboolean) D.13363;
      block_size = fsstat.f_frsize;
      if (ret == -1) goto <D.13364>; else goto <D.11672>;
      <D.13364>:
      D.13365 = __errno_location ();
      D.13366 = *D.13365;
      if (D.13366 == 4) goto <D.11671>; else goto <D.11672>;
      <D.11672>:
      monoeg_g_free (utf8_path_name);
      if (ret == -1) goto <D.13367>; else goto <D.13368>;
      <D.13367>:
      _wapi_set_last_error_from_errno ();
      D.13357 = 0;
      return D.13357;
      <D.13368>:
      if (free_bytes_avail != 0B) goto <D.13369>; else goto <D.13370>;
      <D.13369>:
      if (isreadonly != 0) goto <D.13371>; else goto <D.13372>;
      <D.13371>:
      free_bytes_avail->QuadPart = 0;
      goto <D.13373>;
      <D.13372>:
      D.13374 = (long long unsigned int) block_size;
      D.13375 = fsstat.f_bavail;
      D.13376 = D.13374 * D.13375;
      free_bytes_avail->QuadPart = D.13376;
      <D.13373>:
      <D.13370>:
      if (total_number_of_bytes != 0B) goto <D.13377>; else goto <D.13378>;
      <D.13377>:
      D.13374 = (long long unsigned int) block_size;
      D.13379 = fsstat.f_blocks;
      D.13380 = D.13374 * D.13379;
      total_number_of_bytes->QuadPart = D.13380;
      <D.13378>:
      if (total_number_of_free_bytes != 0B) goto <D.13381>; else goto <D.13382>;
      <D.13381>:
      if (isreadonly != 0) goto <D.13383>; else goto <D.13384>;
      <D.13383>:
      total_number_of_free_bytes->QuadPart = 0;
      goto <D.13385>;
      <D.13384>:
      D.13374 = (long long unsigned int) block_size;
      D.13386 = fsstat.f_bfree;
      D.13387 = D.13374 * D.13386;
      total_number_of_free_bytes->QuadPart = D.13387;
      <D.13385>:
      <D.13382>:
      D.13357 = 1;
      return D.13357;
    }
  finally
    {
      fsstat = {CLOBBER};
    }
}


GetDriveType (const gunichar2 * root_path_name)
{
  gchar * D.13392;
  guint32 D.13395;
  int D.13399;
  gchar * D.13402;
  char D.13403;
  unsigned int D.13406;
  sizetype D.13407;
  gchar * D.13408;
  gchar * utf8_root_path_name;
  guint32 drive_type;

  if (root_path_name == 0B) goto <D.13390>; else goto <D.13391>;
  <D.13390>:
  D.13392 = monoeg_g_get_current_dir ();
  utf8_root_path_name = monoeg_strdup (D.13392);
  if (utf8_root_path_name == 0B) goto <D.13393>; else goto <D.13394>;
  <D.13393>:
  D.13395 = 1;
  return D.13395;
  <D.13394>:
  goto <D.13396>;
  <D.13391>:
  utf8_root_path_name = mono_unicode_to_external (root_path_name);
  if (utf8_root_path_name == 0B) goto <D.13397>; else goto <D.13398>;
  <D.13397>:
  D.13395 = 1;
  return D.13395;
  <D.13398>:
  D.13399 = monoeg_g_str_has_suffix (utf8_root_path_name, "/");
  if (D.13399 != 0) goto <D.13400>; else goto <D.13401>;
  <D.13400>:
  D.13402 = utf8_root_path_name + 1;
  D.13403 = *D.13402;
  if (D.13403 != 0) goto <D.13404>; else goto <D.13405>;
  <D.13404>:
  D.13406 = strlen (utf8_root_path_name);
  D.13407 = D.13406 + 4294967295;
  D.13408 = utf8_root_path_name + D.13407;
  *D.13408 = 0;
  <D.13405>:
  <D.13401>:
  <D.13396>:
  drive_type = GetDriveTypeFromPath (utf8_root_path_name);
  monoeg_g_free (utf8_root_path_name);
  D.13395 = drive_type;
  return D.13395;
}


GetDriveTypeFromPath (const char * utf8_root_path_name)
{
  int D.13410;
  guint32 D.13413;
  int D.13414;
  struct statfs buf;

  try
    {
      D.13410 = statfs (utf8_root_path_name, &buf);
      if (D.13410 == -1) goto <D.13411>; else goto <D.13412>;
      <D.13411>:
      D.13413 = 0;
      return D.13413;
      <D.13412>:
      D.13414 = buf.f_type;
      D.13413 = _wapi_get_drive_type (D.13414);
      return D.13413;
    }
  finally
    {
      buf = {CLOBBER};
    }
}


_wapi_get_drive_type (long int f_type)
{
  long int D.13417;
  guint32 D.13420;
  unsigned int D.13421;
  struct _wapi_drive_type * current;

  current = &_wapi_drive_types[0];
  goto <D.11684>;
  <D.11683>:
  D.13417 = current->fstypeid;
  if (D.13417 == f_type) goto <D.13418>; else goto <D.13419>;
  <D.13418>:
  D.13420 = current->drive_type;
  return D.13420;
  <D.13419>:
  current = current + 12;
  <D.11684>:
  D.13421 = current->drive_type;
  if (D.13421 != 0) goto <D.11683>; else goto <D.11685>;
  <D.11685>:
  D.13420 = 0;
  return D.13420;
}


GetVolumeInformation (const gunichar2 * path, gunichar2 * volumename, int volumesize, int * outserial, int * maxcomp, int * fsflags, gunichar2 * fsbuffer, int fsbuffersize)
{
  gboolean D.13425;
  long int len.68;
  long unsigned int len.69;
  long unsigned int D.13434;
  unsigned int len.70;
  unsigned int D.13436;
  gunichar2 * D.13437;
  gchar * utfpath;
  gchar * fstypename;
  gboolean status;
  glong len;

  try
    {
      status = 0;
      if (fsbuffer == 0B) goto <D.13423>; else goto <D.13424>;
      <D.13423>:
      D.13425 = 0;
      return D.13425;
      <D.13424>:
      utfpath = mono_unicode_to_external (path);
      fstypename = get_fstypename (utfpath);
      if (fstypename != 0B) goto <D.13426>; else goto <D.13427>;
      <D.13426>:
      {
        gunichar2 * ret;

        ret = monoeg_g_utf8_to_utf16 (fstypename, -1, 0B, &len, 0B);
        if (ret != 0B) goto <D.13428>; else goto <D.13429>;
        <D.13428>:
        len.68 = len;
        if (len.68 < fsbuffersize) goto <D.13431>; else goto <D.13432>;
        <D.13431>:
        len.68 = len;
        len.69 = (long unsigned int) len.68;
        D.13434 = len.69 * 2;
        memcpy (fsbuffer, ret, D.13434);
        len.68 = len;
        len.70 = (unsigned int) len.68;
        D.13436 = len.70 * 2;
        D.13437 = fsbuffer + D.13436;
        *D.13437 = 0;
        status = 1;
        <D.13432>:
        <D.13429>:
        if (ret != 0B) goto <D.13438>; else goto <D.13439>;
        <D.13438>:
        monoeg_g_free (ret);
        <D.13439>:
        monoeg_g_free (fstypename);
      }
      <D.13427>:
      monoeg_g_free (utfpath);
      D.13425 = status;
      return D.13425;
    }
  finally
    {
      len = {CLOBBER};
    }
}


get_fstypename (gchar * utfpath)
{
  int D.13442;
  gchar * D.13445;
  int D.13446;
  long int D.13447;
  const gchar * D.13450;
  unsigned int D.13451;
  struct statfs stat;
  struct _wapi_drive_type * current;

  try
    {
      D.13442 = statfs (utfpath, &stat);
      if (D.13442 == -1) goto <D.13443>; else goto <D.13444>;
      <D.13443>:
      D.13445 = 0B;
      return D.13445;
      <D.13444>:
      current = &_wapi_drive_types[0];
      goto <D.11701>;
      <D.11700>:
      D.13446 = stat.f_type;
      D.13447 = current->fstypeid;
      if (D.13446 == D.13447) goto <D.13448>; else goto <D.13449>;
      <D.13448>:
      D.13450 = current->fstype;
      D.13445 = monoeg_strdup (D.13450);
      return D.13445;
      <D.13449>:
      current = current + 12;
      <D.11701>:
      D.13451 = current->drive_type;
      if (D.13451 != 0) goto <D.11700>; else goto <D.11702>;
      <D.11702>:
      D.13445 = 0B;
      return D.13445;
    }
  finally
    {
      stat = {CLOBBER};
    }
}


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


