file_close (void * handle, void * data)
{
  unsigned int D.11699;
  unsigned int D.11700;
  gchar * D.11703;
  struct _WapiFileShare * D.11704;
  struct _WapiHandle_file * file_handle;
  int fd;

  file_handle = data;
  fd = file_handle->fd;
  D.11699 = file_handle->attrs;
  D.11700 = D.11699 & 67108864;
  if (D.11700 != 0) goto <D.11701>; else goto <D.11702>;
  <D.11701>:
  D.11703 = file_handle->filename;
  _wapi_unlink (D.11703);
  <D.11702>:
  D.11703 = file_handle->filename;
  monoeg_g_free (D.11703);
  D.11704 = file_handle->share_info;
  if (D.11704 != 0B) goto <D.11705>; else goto <D.11706>;
  <D.11705>:
  D.11704 = file_handle->share_info;
  _wapi_handle_share_release (D.11704);
  <D.11706>:
  close (fd);
}


_wapi_handle_share_release (struct _WapiFileShare * info)
{
  unsigned int D.11707;
  _Bool D.11708;
  long int D.11709;
  long int D.11710;
  _Bool D.11713;
  long int D.11714;
  long int D.11715;
  guint32 * D.11718;
  int D.11719;
  int thr_ret;

  D.11707 = info->handle_refs;
  D.11708 = D.11707 == 0;
  D.11709 = (long int) D.11708;
  D.11710 = __builtin_expect (D.11709, 0);
  if (D.11710 != 0) goto <D.11711>; else goto <D.11712>;
  <D.11711>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "../../mono/io-layer/handles-private.h", 364, "info->handle_refs > 0");
  <D.11712>:
  thr_ret = _wapi_shm_sem_lock (2);
  D.11713 = thr_ret != 0;
  D.11714 = (long int) D.11713;
  D.11715 = __builtin_expect (D.11714, 0);
  if (D.11715 != 0) goto <D.11716>; else goto <D.11717>;
  <D.11716>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "../../mono/io-layer/handles-private.h", 368, "thr_ret == 0");
  <D.11717>:
  D.11718 = &info->handle_refs;
  D.11719 = InterlockedDecrement (D.11718);
  if (D.11719 == 0) goto <D.11720>; else goto <D.11721>;
  <D.11720>:
  _wapi_free_share_info (info);
  <D.11721>:
  thr_ret = _wapi_shm_sem_unlock (2);
}


InterlockedDecrement (volatile gint32 * val)
{
  gint32 D.11722;
  unsigned int D.11723;

  D.11723 = __sync_sub_and_fetch_4 (val, 1);
  D.11722 = (gint32) D.11723;
  return D.11722;
}


_wapi_file_details (void * handle_info)
{
  gchar * D.11725;
  int iftmp.0;
  unsigned int D.11727;
  signed int D.11728;
  int iftmp.1;
  unsigned int D.11733;
  int iftmp.2;
  unsigned int D.11738;
  int iftmp.3;
  unsigned int D.11743;
  unsigned int D.11744;
  int iftmp.4;
  unsigned int D.11749;
  int iftmp.5;
  unsigned int D.11754;
  unsigned int D.11758;
  struct _WapiHandle_file * file;

  file = handle_info;
  D.11725 = file->filename;
  D.11727 = file->fileaccess;
  D.11728 = (signed int) D.11727;
  if (D.11728 < 0) goto <D.11729>; else goto <D.11730>;
  <D.11729>:
  iftmp.0 = 82;
  goto <D.11731>;
  <D.11730>:
  iftmp.0 = 46;
  <D.11731>:
  D.11727 = file->fileaccess;
  D.11733 = D.11727 & 1073741824;
  if (D.11733 != 0) goto <D.11734>; else goto <D.11735>;
  <D.11734>:
  iftmp.1 = 87;
  goto <D.11736>;
  <D.11735>:
  iftmp.1 = 46;
  <D.11736>:
  D.11727 = file->fileaccess;
  D.11738 = D.11727 & 536870912;
  if (D.11738 != 0) goto <D.11739>; else goto <D.11740>;
  <D.11739>:
  iftmp.2 = 88;
  goto <D.11741>;
  <D.11740>:
  iftmp.2 = 46;
  <D.11741>:
  D.11743 = file->sharemode;
  D.11744 = D.11743 & 1;
  if (D.11744 != 0) goto <D.11745>; else goto <D.11746>;
  <D.11745>:
  iftmp.3 = 82;
  goto <D.11747>;
  <D.11746>:
  iftmp.3 = 46;
  <D.11747>:
  D.11743 = file->sharemode;
  D.11749 = D.11743 & 2;
  if (D.11749 != 0) goto <D.11750>; else goto <D.11751>;
  <D.11750>:
  iftmp.4 = 87;
  goto <D.11752>;
  <D.11751>:
  iftmp.4 = 46;
  <D.11752>:
  D.11743 = file->sharemode;
  D.11754 = D.11743 & 4;
  if (D.11754 != 0) goto <D.11755>; else goto <D.11756>;
  <D.11755>:
  iftmp.5 = 68;
  goto <D.11757>;
  <D.11756>:
  iftmp.5 = 46;
  <D.11757>:
  D.11758 = file->attrs;
  monoeg_g_print ("[%20s] acc: %c%c%c, shr: %c%c%c, attrs: %5u", D.11725, iftmp.0, iftmp.1, iftmp.2, iftmp.3, iftmp.4, iftmp.5, D.11758);
}


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

  console_handle = data;
  fd = console_handle->fd;
  D.11759 = console_handle->filename;
  monoeg_g_free (D.11759);
  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.11760;
  unsigned int D.11763;
  void * D.11766;
  int * D.11773;
  int D.11774;
  int D.11777;
  unsigned int fd.6;
  unsigned int _wapi_fd_reserve.7;
  int D.11786;
  struct _WapiFileShare * D.11789;
  unsigned int D.11794;
  unsigned int D.11797;
  unsigned int D.11800;
  unsigned int D.11801;
  <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.11760 = attrs & 256;
      if (D.11760 != 0) goto <D.11761>; else goto <D.11762>;
      <D.11761>:
      perms = 384;
      <D.11762>:
      D.11763 = attrs & 64;
      if (D.11763 != 0) goto <D.11764>; else goto <D.11765>;
      <D.11764>:
      SetLastError (6000);
      D.11766 = 4294967295B;
      return D.11766;
      <D.11765>:
      if (name == 0B) goto <D.11767>; else goto <D.11768>;
      <D.11767>:
      SetLastError (123);
      D.11766 = 4294967295B;
      return D.11766;
      <D.11768>:
      filename = mono_unicode_to_external (name);
      if (filename == 0B) goto <D.11769>; else goto <D.11770>;
      <D.11769>:
      SetLastError (123);
      D.11766 = 4294967295B;
      return D.11766;
      <D.11770>:
      fd = _wapi_open (filename, flags, perms);
      if (fd == -1) goto <D.11771>; else goto <D.11772>;
      <D.11771>:
      D.11773 = __errno_location ();
      D.11774 = *D.11773;
      if (D.11774 == 21) goto <D.11775>; else goto <D.11776>;
      <D.11775>:
      D.11777 = flags & -4;
      fd = _wapi_open (filename, D.11777, perms);
      <D.11776>:
      <D.11772>:
      if (fd == -1) goto <D.11778>; else goto <D.11779>;
      <D.11778>:
      _wapi_set_last_path_error_from_errno (0B, filename);
      monoeg_g_free (filename);
      D.11766 = 4294967295B;
      return D.11766;
      <D.11779>:
      fd.6 = (unsigned int) fd;
      _wapi_fd_reserve.7 = _wapi_fd_reserve;
      if (fd.6 >= _wapi_fd_reserve.7) goto <D.11782>; else goto <D.11783>;
      <D.11782>:
      SetLastError (4);
      close (fd);
      monoeg_g_free (filename);
      D.11766 = 4294967295B;
      return D.11766;
      <D.11783>:
      ret = fstat (fd, &statbuf);
      if (ret == -1) goto <D.11784>; else goto <D.11785>;
      <D.11784>:
      _wapi_set_last_error_from_errno ();
      monoeg_g_free (filename);
      close (fd);
      D.11766 = 4294967295B;
      return D.11766;
      <D.11785>:
      D.11786 = share_check (&statbuf, sharemode, fileaccess, &file_handle.share_info, fd);
      if (D.11786 == 0) goto <D.11787>; else goto <D.11788>;
      <D.11787>:
      SetLastError (32);
      monoeg_g_free (filename);
      close (fd);
      D.11766 = 4294967295B;
      return D.11766;
      <D.11788>:
      D.11789 = file_handle.share_info;
      if (D.11789 == 0B) goto <D.11790>; else goto <D.11791>;
      <D.11790>:
      SetLastError (4);
      close (fd);
      monoeg_g_free (filename);
      D.11766 = 4294967295B;
      return D.11766;
      <D.11791>:
      file_handle.filename = filename;
      if (security != 0B) goto <D.11792>; else goto <D.11793>;
      <D.11792>:
      <D.11793>:
      file_handle.fd = fd;
      file_handle.fileaccess = fileaccess;
      file_handle.sharemode = sharemode;
      file_handle.attrs = attrs;
      D.11794 = attrs & 134217728;
      if (D.11794 != 0) goto <D.11795>; else goto <D.11796>;
      <D.11795>:
      posix_fadvise (fd, 0, 0, 2);
      <D.11796>:
      D.11797 = attrs & 268435456;
      if (D.11797 != 0) goto <D.11798>; else goto <D.11799>;
      <D.11798>:
      posix_fadvise (fd, 0, 0, 1);
      <D.11799>:
      D.11800 = statbuf.st_mode;
      D.11801 = D.11800 & 61440;
      if (D.11801 == 4096) goto <D.11802>; else goto <D.11803>;
      <D.11802>:
      handle_type = 10;
      goto <D.11804>;
      <D.11803>:
      D.11800 = statbuf.st_mode;
      D.11801 = D.11800 & 61440;
      if (D.11801 == 8192) goto <D.11805>; else goto <D.11806>;
      <D.11805>:
      handle_type = 2;
      goto <D.11807>;
      <D.11806>:
      handle_type = 1;
      <D.11807>:
      <D.11804>:
      handle_type.8 = (<unnamed type>) handle_type;
      handle = _wapi_handle_new_fd (handle_type.8, fd, &file_handle);
      if (handle == 4294967295B) goto <D.11809>; else goto <D.11810>;
      <D.11809>:
      monoeg_g_log (0B, 16, "%s: error creating file handle", &__func__);
      monoeg_g_free (filename);
      close (fd);
      SetLastError (31);
      D.11766 = 4294967295B;
      return D.11766;
      <D.11810>:
      D.11766 = handle;
      return D.11766;
    }
  finally
    {
      file_handle = {CLOBBER};
      statbuf = {CLOBBER};
    }
}


io_ops_init ()
{
  const gchar * D.11813;

  D.11813 = monoeg_g_getenv ("MONO_STRICT_IO_EMULATION");
  if (D.11813 != 0B) goto <D.11814>; else goto <D.11815>;
  <D.11814>:
  lock_while_writing = 1;
  <D.11815>:
}


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

  flags = 0;
  switch (fileaccess) <default: <D.11165>, case 1073741824: <D.11163>, case 2147483648: <D.11161>, case 3221225472: <D.11164>>
  <D.11161>:
  flags = 0;
  goto <D.11162>;
  <D.11163>:
  flags = 1;
  goto <D.11162>;
  <D.11164>:
  flags = 2;
  goto <D.11162>;
  <D.11165>:
  goto <D.11162>;
  <D.11162>:
  switch (createmode) <default: <D.11172>, case 1: <D.11166>, case 2: <D.11168>, case 3: <D.11169>, case 4: <D.11170>, case 5: <D.11171>>
  <D.11166>:
  flags = flags | 1280;
  goto <D.11167>;
  <D.11168>:
  flags = flags | 768;
  goto <D.11167>;
  <D.11169>:
  goto <D.11167>;
  <D.11170>:
  flags = flags | 256;
  goto <D.11167>;
  <D.11171>:
  flags = flags | 512;
  goto <D.11167>;
  <D.11172>:
  goto <D.11167>;
  <D.11167>:
  D.11816 = flags;
  return D.11816;
}


_wapi_set_last_path_error_from_errno (const gchar * dir, const gchar * path)
{
  int * D.11820;
  int D.11821;
  int D.11827;

  D.11820 = __errno_location ();
  D.11821 = *D.11820;
  if (D.11821 == 2) goto <D.11822>; else goto <D.11823>;
  <D.11822>:
  {
    gchar * dirname;

    if (dir == 0B) goto <D.11824>; else goto <D.11825>;
    <D.11824>:
    dirname = _wapi_dirname (path);
    goto <D.11826>;
    <D.11825>:
    dirname = monoeg_strdup (dir);
    <D.11826>:
    D.11827 = _wapi_access (dirname, 0);
    if (D.11827 == 0) goto <D.11828>; else goto <D.11829>;
    <D.11828>:
    SetLastError (2);
    goto <D.11830>;
    <D.11829>:
    SetLastError (3);
    <D.11830>:
    monoeg_g_free (dirname);
  }
  goto <D.11831>;
  <D.11823>:
  _wapi_set_last_error_from_errno ();
  <D.11831>:
}


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

  if (str != 0B) goto <D.11832>; else goto <D.11833>;
  <D.11832>:
  D.11834 = __strdup (str);
  return D.11834;
  <D.11833>:
  D.11834 = 0B;
  return D.11834;
}


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

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


_wapi_set_last_error_from_errno ()
{
  int * D.11838;
  int D.11839;
  int D.11840;
  unsigned int D.11841;

  D.11838 = __errno_location ();
  D.11839 = *D.11838;
  D.11840 = _wapi_get_win32_file_error (D.11839);
  D.11841 = (unsigned int) D.11840;
  SetLastError (D.11841);
}


share_check (struct stat * statbuf, guint32 sharemode, guint32 fileaccess, struct _WapiFileShare * * share_info, int fd)
{
  int D.11842;
  gboolean D.11845;
  struct _WapiFileShare * D.11846;
  int D.11847;

  D.11842 = share_allows_open (statbuf, sharemode, fileaccess, share_info);
  if (D.11842 == 1) goto <D.11843>; else goto <D.11844>;
  <D.11843>:
  D.11845 = 1;
  return D.11845;
  <D.11844>:
  D.11846 = *share_info;
  _wapi_handle_check_share (D.11846, fd);
  D.11847 = share_allows_open (statbuf, sharemode, fileaccess, share_info);
  if (D.11847 == 1) goto <D.11848>; else goto <D.11849>;
  <D.11848>:
  D.11845 = 1;
  return D.11845;
  <D.11849>:
  _wapi_handle_collect ();
  D.11845 = share_allows_open (statbuf, sharemode, fileaccess, share_info);
  return D.11845;
}


share_allows_open (struct stat * statbuf, guint32 sharemode, guint32 fileaccess, struct _WapiFileShare * * share_info)
{
  long unsigned int D.11851;
  long long unsigned int D.11852;
  long long unsigned int D.11853;
  unsigned int file_existing_share.9;
  struct _WapiFileShare * D.11859;
  gboolean D.11860;
  unsigned int file_existing_access.10;
  signed int file_existing_access.11;
  unsigned int D.11872;
  unsigned int D.11873;
  unsigned int D.11875;
  gboolean file_already_shared;
  guint32 file_existing_share;
  guint32 file_existing_access;

  try
    {
      D.11851 = statbuf->st_dev;
      D.11852 = (long long unsigned int) D.11851;
      D.11853 = statbuf->st_ino;
      file_already_shared = _wapi_handle_get_or_set_share (D.11852, D.11853, sharemode, fileaccess, &file_existing_share, &file_existing_access, share_info);
      if (file_already_shared != 0) goto <D.11854>; else goto <D.11855>;
      <D.11854>:
      file_existing_share.9 = file_existing_share;
      if (file_existing_share.9 == 0) goto <D.11857>; else goto <D.11858>;
      <D.11857>:
      D.11859 = *share_info;
      _wapi_handle_share_release (D.11859);
      D.11860 = 0;
      return D.11860;
      <D.11858>:
      file_existing_share.9 = file_existing_share;
      if (file_existing_share.9 == 1) goto <D.11864>; else goto <D.11861>;
      <D.11864>:
      if (fileaccess != 2147483648) goto <D.11862>; else goto <D.11861>;
      <D.11861>:
      file_existing_share.9 = file_existing_share;
      if (file_existing_share.9 == 2) goto <D.11865>; else goto <D.11863>;
      <D.11865>:
      if (fileaccess != 1073741824) goto <D.11862>; else goto <D.11863>;
      <D.11862>:
      D.11859 = *share_info;
      _wapi_handle_share_release (D.11859);
      D.11860 = 0;
      return D.11860;
      <D.11863>:
      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.11871>; else goto <D.11866>;
      <D.11871>:
      D.11872 = sharemode & 1;
      if (D.11872 == 0) goto <D.11867>; else goto <D.11866>;
      <D.11866>:
      file_existing_access.10 = file_existing_access;
      D.11873 = file_existing_access.10 & 1073741824;
      if (D.11873 != 0) goto <D.11874>; else goto <D.11868>;
      <D.11874>:
      D.11875 = sharemode & 2;
      if (D.11875 == 0) goto <D.11867>; else goto <D.11868>;
      <D.11867>:
      D.11859 = *share_info;
      _wapi_handle_share_release (D.11859);
      D.11860 = 0;
      return D.11860;
      <D.11868>:
      goto <D.11876>;
      <D.11855>:
      <D.11876>:
      D.11860 = 1;
      return D.11860;
    }
  finally
    {
      file_existing_share = {CLOBBER};
      file_existing_access = {CLOBBER};
    }
}


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

  ret = 0;
  if (name == 0B) goto <D.11879>; else goto <D.11880>;
  <D.11879>:
  SetLastError (123);
  D.11881 = 0;
  return D.11881;
  <D.11880>:
  filename = mono_unicode_to_external (name);
  if (filename == 0B) goto <D.11882>; else goto <D.11883>;
  <D.11882>:
  SetLastError (123);
  D.11881 = 0;
  return D.11881;
  <D.11883>:
  attrs = GetFileAttributes (name);
  if (attrs == 4294967295) goto <D.11884>; else goto <D.11885>;
  <D.11884>:
  monoeg_g_free (filename);
  D.11881 = 0;
  return D.11881;
  <D.11885>:
  retval = _wapi_unlink (filename);
  if (retval == -1) goto <D.11886>; else goto <D.11887>;
  <D.11886>:
  _wapi_set_last_path_error_from_errno (0B, filename);
  goto <D.11888>;
  <D.11887>:
  ret = 1;
  <D.11888>:
  monoeg_g_free (filename);
  D.11881 = ret;
  return D.11881;
}


MoveFile (const gunichar2 * name, const gunichar2 * dest_name)
{
  gboolean D.11892;
  int D.11899;
  int * D.11904;
  int D.11905;
  int D.11907;
  int D.11908;
  long unsigned int D.11913;
  long unsigned int D.11914;
  long long unsigned int D.11916;
  long long unsigned int D.11917;
  int D.11918;
  struct _WapiFileShare * shareinfo.12;
  unsigned int D.11930;
  unsigned int D.11931;
  int D.11934;
  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.11890>; else goto <D.11891>;
      <D.11890>:
      SetLastError (123);
      D.11892 = 0;
      return D.11892;
      <D.11891>:
      utf8_name = mono_unicode_to_external (name);
      if (utf8_name == 0B) goto <D.11893>; else goto <D.11894>;
      <D.11893>:
      SetLastError (123);
      D.11892 = 0;
      return D.11892;
      <D.11894>:
      if (dest_name == 0B) goto <D.11895>; else goto <D.11896>;
      <D.11895>:
      monoeg_g_free (utf8_name);
      SetLastError (123);
      D.11892 = 0;
      return D.11892;
      <D.11896>:
      utf8_dest_name = mono_unicode_to_external (dest_name);
      if (utf8_dest_name == 0B) goto <D.11897>; else goto <D.11898>;
      <D.11897>:
      monoeg_g_free (utf8_name);
      SetLastError (123);
      D.11892 = 0;
      return D.11892;
      <D.11898>:
      D.11899 = _wapi_stat (utf8_name, &stat_src);
      if (D.11899 < 0) goto <D.11900>; else goto <D.11901>;
      <D.11900>:
      D.11904 = __errno_location ();
      D.11905 = *D.11904;
      if (D.11905 != 2) goto <D.11902>; else goto <D.11906>;
      <D.11906>:
      D.11907 = _wapi_lstat (utf8_name, &stat_src);
      if (D.11907 < 0) goto <D.11902>; else goto <D.11903>;
      <D.11902>:
      _wapi_set_last_path_error_from_errno (0B, utf8_name);
      monoeg_g_free (utf8_name);
      monoeg_g_free (utf8_dest_name);
      D.11892 = 0;
      return D.11892;
      <D.11903>:
      <D.11901>:
      D.11908 = _wapi_stat (utf8_dest_name, &stat_dest);
      if (D.11908 == 0) goto <D.11909>; else goto <D.11910>;
      <D.11909>:
      D.11913 = stat_dest.st_dev;
      D.11914 = stat_src.st_dev;
      if (D.11913 != D.11914) goto <D.11911>; else goto <D.11915>;
      <D.11915>:
      D.11916 = stat_dest.st_ino;
      D.11917 = stat_src.st_ino;
      if (D.11916 != D.11917) goto <D.11911>; else goto <D.11912>;
      <D.11911>:
      monoeg_g_free (utf8_name);
      monoeg_g_free (utf8_dest_name);
      SetLastError (183);
      D.11892 = 0;
      return D.11892;
      <D.11912>:
      <D.11910>:
      D.11918 = share_allows_delete (&stat_src, &shareinfo);
      if (D.11918 == 0) goto <D.11919>; else goto <D.11920>;
      <D.11919>:
      SetLastError (32);
      D.11892 = 0;
      return D.11892;
      <D.11920>:
      shareinfo.12 = shareinfo;
      if (shareinfo.12 != 0B) goto <D.11922>; else goto <D.11923>;
      <D.11922>:
      shareinfo.12 = shareinfo;
      _wapi_handle_share_release (shareinfo.12);
      <D.11923>:
      result = _wapi_rename (utf8_name, utf8_dest_name);
      D.11904 = __errno_location ();
      errno_copy = *D.11904;
      if (result == -1) goto <D.11924>; else goto <D.11925>;
      <D.11924>:
      switch (errno_copy) <default: <D.11237>, case 17: <D.11234>, case 18: <D.11236>>
      <D.11234>:
      SetLastError (183);
      goto <D.11235>;
      <D.11236>:
      goto <D.11235>;
      <D.11237>:
      _wapi_set_last_path_error_from_errno (0B, utf8_name);
      <D.11235>:
      <D.11925>:
      monoeg_g_free (utf8_name);
      monoeg_g_free (utf8_dest_name);
      if (result != 0) goto <D.11926>; else goto <D.11927>;
      <D.11926>:
      if (errno_copy == 18) goto <D.11928>; else goto <D.11929>;
      <D.11928>:
      D.11930 = stat_src.st_mode;
      D.11931 = D.11930 & 61440;
      if (D.11931 == 16384) goto <D.11932>; else goto <D.11933>;
      <D.11932>:
      SetLastError (17);
      D.11892 = 0;
      return D.11892;
      <D.11933>:
      D.11934 = CopyFile (name, dest_name, 1);
      if (D.11934 == 0) goto <D.11935>; else goto <D.11936>;
      <D.11935>:
      D.11892 = 0;
      return D.11892;
      <D.11936>:
      D.11892 = DeleteFile (name);
      return D.11892;
      <D.11929>:
      <D.11927>:
      if (result == 0) goto <D.11937>; else goto <D.11938>;
      <D.11937>:
      ret = 1;
      <D.11938>:
      D.11892 = ret;
      return D.11892;
    }
  finally
    {
      stat_src = {CLOBBER};
      stat_dest = {CLOBBER};
      shareinfo = {CLOBBER};
    }
}


share_allows_delete (struct stat * statbuf, struct _WapiFileShare * * share_info)
{
  long unsigned int D.11942;
  long long unsigned int D.11943;
  long long unsigned int D.11944;
  unsigned int file_existing_share.13;
  struct _WapiFileShare * D.11950;
  gboolean D.11951;
  unsigned int D.11952;
  gboolean file_already_shared;
  guint32 file_existing_share;
  guint32 file_existing_access;

  try
    {
      D.11942 = statbuf->st_dev;
      D.11943 = (long long unsigned int) D.11942;
      D.11944 = statbuf->st_ino;
      file_already_shared = _wapi_handle_get_or_set_share (D.11943, D.11944, 4, 2147483648, &file_existing_share, &file_existing_access, share_info);
      if (file_already_shared != 0) goto <D.11945>; else goto <D.11946>;
      <D.11945>:
      file_existing_share.13 = file_existing_share;
      if (file_existing_share.13 == 0) goto <D.11948>; else goto <D.11949>;
      <D.11948>:
      D.11950 = *share_info;
      _wapi_handle_share_release (D.11950);
      D.11951 = 0;
      return D.11951;
      <D.11949>:
      file_existing_share.13 = file_existing_share;
      D.11952 = file_existing_share.13 & 4;
      if (D.11952 == 0) goto <D.11953>; else goto <D.11954>;
      <D.11953>:
      D.11950 = *share_info;
      _wapi_handle_share_release (D.11950);
      D.11951 = 0;
      return D.11951;
      <D.11954>:
      goto <D.11955>;
      <D.11946>:
      <D.11955>:
      D.11951 = 1;
      return D.11951;
    }
  finally
    {
      file_existing_share = {CLOBBER};
      file_existing_access = {CLOBBER};
    }
}


CopyFile (const gunichar2 * name, const gunichar2 * dest_name, gboolean fail_if_exists)
{
  gboolean D.11960;
  int D.11969;
  int D.11972;
  long unsigned int D.11975;
  long unsigned int D.11976;
  long long unsigned int D.11979;
  long long unsigned int D.11980;
  unsigned int D.11985;
  int D.11992;
  long int D.11995;
  long int D.11996;
  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.11958>; else goto <D.11959>;
      <D.11958>:
      SetLastError (123);
      D.11960 = 0;
      return D.11960;
      <D.11959>:
      utf8_src = mono_unicode_to_external (name);
      if (utf8_src == 0B) goto <D.11961>; else goto <D.11962>;
      <D.11961>:
      SetLastError (87);
      D.11960 = 0;
      return D.11960;
      <D.11962>:
      if (dest_name == 0B) goto <D.11963>; else goto <D.11964>;
      <D.11963>:
      monoeg_g_free (utf8_src);
      SetLastError (123);
      D.11960 = 0;
      return D.11960;
      <D.11964>:
      utf8_dest = mono_unicode_to_external (dest_name);
      if (utf8_dest == 0B) goto <D.11965>; else goto <D.11966>;
      <D.11965>:
      SetLastError (87);
      monoeg_g_free (utf8_src);
      D.11960 = 0;
      return D.11960;
      <D.11966>:
      src_fd = _wapi_open (utf8_src, 0, 0);
      if (src_fd < 0) goto <D.11967>; else goto <D.11968>;
      <D.11967>:
      _wapi_set_last_path_error_from_errno (0B, utf8_src);
      monoeg_g_free (utf8_src);
      monoeg_g_free (utf8_dest);
      D.11960 = 0;
      return D.11960;
      <D.11968>:
      D.11969 = fstat (src_fd, &st);
      if (D.11969 < 0) goto <D.11970>; else goto <D.11971>;
      <D.11970>:
      _wapi_set_last_error_from_errno ();
      monoeg_g_free (utf8_src);
      monoeg_g_free (utf8_dest);
      close (src_fd);
      D.11960 = 0;
      return D.11960;
      <D.11971>:
      D.11972 = _wapi_stat (utf8_dest, &dest_st);
      if (D.11972 == 0) goto <D.11973>; else goto <D.11974>;
      <D.11973>:
      D.11975 = st.st_dev;
      D.11976 = dest_st.st_dev;
      if (D.11975 == D.11976) goto <D.11977>; else goto <D.11978>;
      <D.11977>:
      D.11979 = st.st_ino;
      D.11980 = dest_st.st_ino;
      if (D.11979 == D.11980) goto <D.11981>; else goto <D.11982>;
      <D.11981>:
      monoeg_g_free (utf8_src);
      monoeg_g_free (utf8_dest);
      close (src_fd);
      SetLastError (32);
      D.11960 = 0;
      return D.11960;
      <D.11982>:
      <D.11978>:
      <D.11974>:
      if (fail_if_exists != 0) goto <D.11983>; else goto <D.11984>;
      <D.11983>:
      D.11985 = st.st_mode;
      dest_fd = _wapi_open (utf8_dest, 1281, D.11985);
      goto <D.11986>;
      <D.11984>:
      D.11985 = st.st_mode;
      dest_fd = _wapi_open (utf8_dest, 513, D.11985);
      if (dest_fd < 0) goto <D.11987>; else goto <D.11988>;
      <D.11987>:
      D.11985 = st.st_mode;
      dest_fd = _wapi_open (utf8_dest, 769, D.11985);
      goto <D.11989>;
      <D.11988>:
      SetLastError (183);
      <D.11989>:
      <D.11986>:
      if (dest_fd < 0) goto <D.11990>; else goto <D.11991>;
      <D.11990>:
      _wapi_set_last_error_from_errno ();
      monoeg_g_free (utf8_src);
      monoeg_g_free (utf8_dest);
      close (src_fd);
      D.11960 = 0;
      return D.11960;
      <D.11991>:
      D.11992 = write_file (src_fd, dest_fd, &st, 1);
      if (D.11992 == 0) goto <D.11993>; else goto <D.11994>;
      <D.11993>:
      ret = 0;
      <D.11994>:
      close (src_fd);
      close (dest_fd);
      D.11995 = st.st_mtim.tv_sec;
      dest_time.modtime = D.11995;
      D.11996 = st.st_atim.tv_sec;
      dest_time.actime = D.11996;
      ret_utime = utime (utf8_dest, &dest_time);
      if (ret_utime == -1) goto <D.11997>; else goto <D.11998>;
      <D.11997>:
      <D.11998>:
      monoeg_g_free (utf8_src);
      monoeg_g_free (utf8_dest);
      D.11960 = ret;
      return D.11960;
    }
  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.12008;
  int D.12009;
  int D.12012;
  gboolean D.12017;
  unsigned int remain.16;
  int D.12024;
  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.12002>; else goto <D.12003>;
  <D.12002>:
  iftmp.14 = MIN_EXPR <buf_size, 65536>;
  goto <D.12004>;
  <D.12003>:
  iftmp.14 = 8192;
  <D.12004>:
  buf_size = iftmp.14;
  buf_size.15 = (unsigned int) buf_size;
  buf = malloc (buf_size.15);
  <D.11254>:
  buf_size.15 = (unsigned int) buf_size;
  remain = read (src_fd, buf, buf_size.15);
  if (remain < 0) goto <D.12006>; else goto <D.12007>;
  <D.12006>:
  D.12008 = __errno_location ();
  D.12009 = *D.12008;
  if (D.12009 == 4) goto <D.12010>; else goto <D.12011>;
  <D.12010>:
  D.12012 = _wapi_thread_cur_apc_pending ();
  if (D.12012 == 0) goto <D.12013>; else goto <D.12014>;
  <D.12013>:
  // predicted unlikely by continue predictor.
  goto <D.11249>;
  <D.12014>:
  <D.12011>:
  if (report_errors != 0) goto <D.12015>; else goto <D.12016>;
  <D.12015>:
  _wapi_set_last_error_from_errno ();
  <D.12016>:
  free (buf);
  D.12017 = 0;
  return D.12017;
  <D.12007>:
  if (remain == 0) goto <D.11250>; else goto <D.12018>;
  <D.12018>:
  wbuf = buf;
  goto <D.11251>;
  <D.11252>:
  remain.16 = (unsigned int) remain;
  n = write (dest_fd, wbuf, remain.16);
  if (n < 0) goto <D.12020>; else goto <D.12021>;
  <D.12020>:
  D.12008 = __errno_location ();
  D.12009 = *D.12008;
  if (D.12009 == 4) goto <D.12022>; else goto <D.12023>;
  <D.12022>:
  D.12024 = _wapi_thread_cur_apc_pending ();
  if (D.12024 == 0) goto <D.12025>; else goto <D.12026>;
  <D.12025>:
  // predicted unlikely by continue predictor.
  goto <D.11251>;
  <D.12026>:
  <D.12023>:
  if (report_errors != 0) goto <D.12027>; else goto <D.12028>;
  <D.12027>:
  _wapi_set_last_error_from_errno ();
  <D.12028>:
  free (buf);
  D.12017 = 0;
  return D.12017;
  <D.12021>:
  remain = remain - n;
  n.17 = (sizetype) n;
  wbuf = wbuf + n.17;
  <D.11251>:
  if (remain > 0) goto <D.11252>; else goto <D.11253>;
  <D.11253>:
  <D.11249>:
  goto <D.11254>;
  <D.11250>:
  free (buf);
  D.12017 = 1;
  return D.12017;
}


read (int __fd, void * __buf, size_t __nbytes)
{
  unsigned int D.12031;
  int D.12034;
  ssize_t D.12037;
  unsigned int D.12038;
  unsigned int D.12039;
  unsigned int D.12042;

  D.12031 = __builtin_object_size (__buf, 0);
  if (D.12031 != 4294967295) goto <D.12032>; else goto <D.12033>;
  <D.12032>:
  D.12034 = __builtin_constant_p (__nbytes);
  if (D.12034 == 0) goto <D.12035>; else goto <D.12036>;
  <D.12035>:
  D.12038 = __builtin_object_size (__buf, 0);
  D.12037 = __read_chk (__fd, __buf, __nbytes, D.12038);
  return D.12037;
  <D.12036>:
  D.12039 = __builtin_object_size (__buf, 0);
  if (D.12039 < __nbytes) goto <D.12040>; else goto <D.12041>;
  <D.12040>:
  D.12042 = __builtin_object_size (__buf, 0);
  D.12037 = __read_chk_warn (__fd, __buf, __nbytes, D.12042);
  return D.12037;
  <D.12041>:
  <D.12033>:
  D.12037 = __read_alias (__fd, __buf, __nbytes);
  return D.12037;
}


ReplaceFile (const gunichar2 * replacedFileName, const gunichar2 * replacementFileName, const gunichar2 * backupFileName, guint32 replaceFlags, void * exclude, void * reserved)
{
  gboolean D.12046;
  int * D.12053;
  int D.12059;
  unsigned int D.12062;
  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.12044>; else goto <D.12045>;
      <D.12044>:
      D.12046 = 0;
      return D.12046;
      <D.12045>:
      utf8_replacementFileName = convert_arg_to_utf8 (replacementFileName, "replacementFileName");
      if (utf8_replacementFileName == 0B) goto replace_cleanup; else goto <D.12047>;
      <D.12047>:
      if (backupFileName != 0B) goto <D.12048>; else goto <D.12049>;
      <D.12048>:
      utf8_backupFileName = convert_arg_to_utf8 (backupFileName, "backupFileName");
      if (utf8_backupFileName == 0B) goto replace_cleanup; else goto <D.12050>;
      <D.12050>:
      <D.12049>:
      if (utf8_backupFileName != 0B) goto <D.12051>; else goto <D.12052>;
      <D.12051>:
      backup_fd = _wapi_open (utf8_backupFileName, 0, 0);
      result = _wapi_rename (utf8_replacedFileName, utf8_backupFileName);
      D.12053 = __errno_location ();
      errno_copy = *D.12053;
      if (result == -1) goto replace_cleanup; else goto <D.12054>;
      <D.12054>:
      <D.12052>:
      result = _wapi_rename (utf8_replacementFileName, utf8_replacedFileName);
      D.12053 = __errno_location ();
      errno_copy = *D.12053;
      if (result == -1) goto <D.12055>; else goto <D.12056>;
      <D.12055>:
      _wapi_set_last_path_error_from_errno (0B, utf8_replacementFileName);
      _wapi_rename (utf8_backupFileName, utf8_replacedFileName);
      if (backup_fd != -1) goto <D.12057>; else goto <D.12058>;
      <D.12057>:
      D.12059 = fstat (backup_fd, &stBackup);
      if (D.12059 == 0) goto <D.12060>; else goto <D.12061>;
      <D.12060>:
      D.12062 = stBackup.st_mode;
      replaced_fd = _wapi_open (utf8_backupFileName, 769, D.12062);
      if (replaced_fd == -1) goto replace_cleanup; else goto <D.12063>;
      <D.12063>:
      write_file (backup_fd, replaced_fd, &stBackup, 0);
      <D.12061>:
      <D.12058>:
      goto replace_cleanup;
      <D.12056>:
      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.12064>; else goto <D.12065>;
      <D.12064>:
      close (backup_fd);
      <D.12065>:
      if (replaced_fd != -1) goto <D.12066>; else goto <D.12067>;
      <D.12066>:
      close (replaced_fd);
      <D.12067>:
      D.12046 = ret;
      return D.12046;
    }
  finally
    {
      stBackup = {CLOBBER};
    }
}


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

  if (arg == 0B) goto <D.12070>; else goto <D.12071>;
  <D.12070>:
  SetLastError (123);
  D.12072 = 0B;
  return D.12072;
  <D.12071>:
  utf8_ret = mono_unicode_to_external (arg);
  if (utf8_ret == 0B) goto <D.12073>; else goto <D.12074>;
  <D.12073>:
  SetLastError (87);
  D.12072 = 0B;
  return D.12072;
  <D.12074>:
  D.12072 = utf8_ret;
  return D.12072;
}


GetStdHandle (WapiStdHandle stdhandle)
{
  void * D.12076;
  long int D.12077;
  _Bool D.12080;
  long int D.12081;
  long int D.12082;
  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.11306>, case -12: <D.11305>, case -11: <D.11304>, case -10: <D.11302>>
      <D.11302>:
      fd = 0;
      name = "<stdin>";
      goto <D.11303>;
      <D.11304>:
      fd = 1;
      name = "<stdout>";
      goto <D.11303>;
      <D.11305>:
      fd = 2;
      name = "<stderr>";
      goto <D.11303>;
      <D.11306>:
      SetLastError (87);
      D.12076 = 4294967295B;
      return D.12076;
      <D.11303>:
      handle = (void *) fd;
      {
        struct __pthread_unwind_buf_t __cancel_buf;
        void (*<Tc3>) (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.12077 = __builtin_expect (__not_first_call, 0);
            if (D.12077 != 0) goto <D.12078>; else goto <D.12079>;
            <D.12078>:
            __cancel_routine (__cancel_arg);
            __pthread_unwind_next (&__cancel_buf);
            <D.12079>:
            __pthread_register_cancel (&__cancel_buf);
            thr_ret = pthread_mutex_lock (&stdhandle_mutex);
            D.12080 = thr_ret != 0;
            D.12081 = (long int) D.12080;
            D.12082 = __builtin_expect (D.12081, 0);
            if (D.12082 != 0) goto <D.12083>; else goto <D.12084>;
            <D.12083>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "io.c", 2187, "thr_ret == 0");
            <D.12084>:
            ok = _wapi_lookup_handle (handle, 2, &file_handle);
            if (ok == 0) goto <D.12085>; else goto <D.12086>;
            <D.12085>:
            handle = _wapi_stdhandle_create (fd, name);
            if (handle == 4294967295B) goto <D.12087>; else goto <D.12088>;
            <D.12087>:
            SetLastError (18);
            goto done;
            <D.12088>:
            goto <D.12089>;
            <D.12086>:
            _wapi_handle_ref (handle);
            <D.12089>:
            done:
            thr_ret = pthread_mutex_unlock (&stdhandle_mutex);
            D.12080 = thr_ret != 0;
            D.12081 = (long int) D.12080;
            D.12082 = __builtin_expect (D.12081, 0);
            if (D.12082 != 0) goto <D.12090>; else goto <D.12091>;
            <D.12090>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "io.c", 2206, "thr_ret == 0");
            <D.12091>:
            __pthread_unregister_cancel (&__cancel_buf);
            if (0 != 0) goto <D.12092>; else goto <D.12093>;
            <D.12092>:
            __cancel_routine (__cancel_arg);
            <D.12093>:
          }
        finally
          {
            __cancel_buf = {CLOBBER};
          }
      }
      D.12076 = handle;
      return D.12076;
    }
  finally
    {
      file_handle = {CLOBBER};
    }
}


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

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


ReadFile (void * handle, void * buffer, guint32 numbytes, guint32 * bytesread, struct WapiOverlapped * overlapped)
{
  gboolean (*<T1a7c>) (void *, void *, guint32, guint32 *, struct WapiOverlapped *) D.12102;
  gboolean D.12105;
  WapiHandleType type;

  type = _wapi_handle_type (handle);
  D.12102 = io_ops[type].readfile;
  if (D.12102 == 0B) goto <D.12103>; else goto <D.12104>;
  <D.12103>:
  SetLastError (6);
  D.12105 = 0;
  return D.12105;
  <D.12104>:
  D.12102 = io_ops[type].readfile;
  D.12105 = D.12102 (handle, buffer, numbytes, bytesread, overlapped);
  return D.12105;
}


pipe_write (void * handle, const void * buffer, guint32 numbytes, guint32 * byteswritten, struct WapiOverlapped * overlapped)
{
  gboolean D.12109;
  struct _WapiHandle_file * pipe_handle.18;
  unsigned int D.12113;
  unsigned int D.12114;
  int * D.12118;
  int D.12119;
  int D.12121;
  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.12107>; else goto <D.12108>;
      <D.12107>:
      monoeg_g_log (0B, 16, "%s: error looking up pipe handle %p", &__func__, handle);
      SetLastError (6);
      D.12109 = 0;
      return D.12109;
      <D.12108>:
      pipe_handle.18 = pipe_handle;
      fd = pipe_handle.18->fd;
      if (byteswritten != 0B) goto <D.12111>; else goto <D.12112>;
      <D.12111>:
      *byteswritten = 0;
      <D.12112>:
      pipe_handle.18 = pipe_handle;
      D.12113 = BIT_FIELD_REF <*pipe_handle.18, 32, 128>;
      D.12114 = D.12113 & 1342177280;
      if (D.12114 == 0) goto <D.12115>; else goto <D.12116>;
      <D.12115>:
      SetLastError (5);
      D.12109 = 0;
      return D.12109;
      <D.12116>:
      <D.11154>:
      ret = write (fd, buffer, numbytes);
      if (ret == -1) goto <D.12117>; else goto <D.11155>;
      <D.12117>:
      D.12118 = __errno_location ();
      D.12119 = *D.12118;
      if (D.12119 == 4) goto <D.12120>; else goto <D.11155>;
      <D.12120>:
      D.12121 = _wapi_thread_cur_apc_pending ();
      if (D.12121 == 0) goto <D.11154>; else goto <D.11155>;
      <D.11155>:
      if (ret == -1) goto <D.12122>; else goto <D.12123>;
      <D.12122>:
      D.12118 = __errno_location ();
      D.12119 = *D.12118;
      if (D.12119 == 4) goto <D.12124>; else goto <D.12125>;
      <D.12124>:
      ret = 0;
      goto <D.12126>;
      <D.12125>:
      _wapi_set_last_error_from_errno ();
      D.12109 = 0;
      return D.12109;
      <D.12126>:
      <D.12123>:
      if (byteswritten != 0B) goto <D.12127>; else goto <D.12128>;
      <D.12127>:
      ret.19 = (unsigned int) ret;
      *byteswritten = ret.19;
      <D.12128>:
      D.12109 = 1;
      return D.12109;
    }
  finally
    {
      pipe_handle = {CLOBBER};
    }
}


pipe_read (void * handle, void * buffer, guint32 numbytes, guint32 * bytesread, struct WapiOverlapped * overlapped)
{
  gboolean D.12134;
  struct _WapiHandle_file * pipe_handle.20;
  unsigned int D.12138;
  signed int D.12139;
  unsigned int D.12142;
  int * D.12146;
  int D.12147;
  int D.12149;
  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.12132>; else goto <D.12133>;
      <D.12132>:
      monoeg_g_log (0B, 16, "%s: error looking up pipe handle %p", &__func__, handle);
      SetLastError (6);
      D.12134 = 0;
      return D.12134;
      <D.12133>:
      pipe_handle.20 = pipe_handle;
      fd = pipe_handle.20->fd;
      if (bytesread != 0B) goto <D.12136>; else goto <D.12137>;
      <D.12136>:
      *bytesread = 0;
      <D.12137>:
      pipe_handle.20 = pipe_handle;
      D.12138 = pipe_handle.20->fileaccess;
      D.12139 = (signed int) D.12138;
      if (D.12139 >= 0) goto <D.12140>; else goto <D.12141>;
      <D.12140>:
      pipe_handle.20 = pipe_handle;
      D.12138 = pipe_handle.20->fileaccess;
      D.12142 = D.12138 & 268435456;
      if (D.12142 == 0) goto <D.12143>; else goto <D.12144>;
      <D.12143>:
      SetLastError (5);
      D.12134 = 0;
      return D.12134;
      <D.12144>:
      <D.12141>:
      <D.11140>:
      ret = read (fd, buffer, numbytes);
      if (ret == -1) goto <D.12145>; else goto <D.11141>;
      <D.12145>:
      D.12146 = __errno_location ();
      D.12147 = *D.12146;
      if (D.12147 == 4) goto <D.12148>; else goto <D.11141>;
      <D.12148>:
      D.12149 = _wapi_thread_cur_apc_pending ();
      if (D.12149 == 0) goto <D.11140>; else goto <D.11141>;
      <D.11141>:
      if (ret == -1) goto <D.12150>; else goto <D.12151>;
      <D.12150>:
      D.12146 = __errno_location ();
      D.12147 = *D.12146;
      if (D.12147 == 4) goto <D.12152>; else goto <D.12153>;
      <D.12152>:
      ret = 0;
      goto <D.12154>;
      <D.12153>:
      _wapi_set_last_error_from_errno ();
      D.12134 = 0;
      return D.12134;
      <D.12154>:
      <D.12151>:
      if (bytesread != 0B) goto <D.12155>; else goto <D.12156>;
      <D.12155>:
      ret.21 = (unsigned int) ret;
      *bytesread = ret.21;
      <D.12156>:
      D.12134 = 1;
      return D.12134;
    }
  finally
    {
      pipe_handle = {CLOBBER};
    }
}


pipe_getfiletype ()
{
  WapiFileType D.12160;

  D.12160 = 3;
  return D.12160;
}


console_write (void * handle, const void * buffer, guint32 numbytes, guint32 * byteswritten, struct WapiOverlapped * overlapped)
{
  gboolean D.12164;
  struct _WapiHandle_file * console_handle.22;
  unsigned int D.12168;
  unsigned int D.12169;
  int * D.12173;
  int D.12174;
  int D.12176;
  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.12162>; else goto <D.12163>;
      <D.12162>:
      monoeg_g_log (0B, 16, "%s: error looking up console handle %p", &__func__, handle);
      SetLastError (6);
      D.12164 = 0;
      return D.12164;
      <D.12163>:
      console_handle.22 = console_handle;
      fd = console_handle.22->fd;
      if (byteswritten != 0B) goto <D.12166>; else goto <D.12167>;
      <D.12166>:
      *byteswritten = 0;
      <D.12167>:
      console_handle.22 = console_handle;
      D.12168 = BIT_FIELD_REF <*console_handle.22, 32, 128>;
      D.12169 = D.12168 & 1342177280;
      if (D.12169 == 0) goto <D.12170>; else goto <D.12171>;
      <D.12170>:
      SetLastError (5);
      D.12164 = 0;
      return D.12164;
      <D.12171>:
      <D.11117>:
      ret = write (fd, buffer, numbytes);
      if (ret == -1) goto <D.12172>; else goto <D.11118>;
      <D.12172>:
      D.12173 = __errno_location ();
      D.12174 = *D.12173;
      if (D.12174 == 4) goto <D.12175>; else goto <D.11118>;
      <D.12175>:
      D.12176 = _wapi_thread_cur_apc_pending ();
      if (D.12176 == 0) goto <D.11117>; else goto <D.11118>;
      <D.11118>:
      if (ret == -1) goto <D.12177>; else goto <D.12178>;
      <D.12177>:
      D.12173 = __errno_location ();
      D.12174 = *D.12173;
      if (D.12174 == 4) goto <D.12179>; else goto <D.12180>;
      <D.12179>:
      ret = 0;
      goto <D.12181>;
      <D.12180>:
      _wapi_set_last_error_from_errno ();
      D.12164 = 0;
      return D.12164;
      <D.12181>:
      <D.12178>:
      if (byteswritten != 0B) goto <D.12182>; else goto <D.12183>;
      <D.12182>:
      ret.23 = (unsigned int) ret;
      *byteswritten = ret.23;
      <D.12183>:
      D.12164 = 1;
      return D.12164;
    }
  finally
    {
      console_handle = {CLOBBER};
    }
}


console_read (void * handle, void * buffer, guint32 numbytes, guint32 * bytesread, struct WapiOverlapped * overlapped)
{
  gboolean D.12189;
  struct _WapiHandle_file * console_handle.24;
  unsigned int D.12193;
  signed int D.12194;
  unsigned int D.12197;
  int * D.12201;
  int D.12202;
  int D.12204;
  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.12187>; else goto <D.12188>;
      <D.12187>:
      monoeg_g_log (0B, 16, "%s: error looking up console handle %p", &__func__, handle);
      SetLastError (6);
      D.12189 = 0;
      return D.12189;
      <D.12188>:
      console_handle.24 = console_handle;
      fd = console_handle.24->fd;
      if (bytesread != 0B) goto <D.12191>; else goto <D.12192>;
      <D.12191>:
      *bytesread = 0;
      <D.12192>:
      console_handle.24 = console_handle;
      D.12193 = console_handle.24->fileaccess;
      D.12194 = (signed int) D.12193;
      if (D.12194 >= 0) goto <D.12195>; else goto <D.12196>;
      <D.12195>:
      console_handle.24 = console_handle;
      D.12193 = console_handle.24->fileaccess;
      D.12197 = D.12193 & 268435456;
      if (D.12197 == 0) goto <D.12198>; else goto <D.12199>;
      <D.12198>:
      SetLastError (5);
      D.12189 = 0;
      return D.12189;
      <D.12199>:
      <D.12196>:
      <D.11103>:
      ret = read (fd, buffer, numbytes);
      if (ret == -1) goto <D.12200>; else goto <D.11104>;
      <D.12200>:
      D.12201 = __errno_location ();
      D.12202 = *D.12201;
      if (D.12202 == 4) goto <D.12203>; else goto <D.11104>;
      <D.12203>:
      D.12204 = _wapi_thread_cur_apc_pending ();
      if (D.12204 == 0) goto <D.11103>; else goto <D.11104>;
      <D.11104>:
      if (ret == -1) goto <D.12205>; else goto <D.12206>;
      <D.12205>:
      _wapi_set_last_error_from_errno ();
      D.12189 = 0;
      return D.12189;
      <D.12206>:
      if (bytesread != 0B) goto <D.12207>; else goto <D.12208>;
      <D.12207>:
      ret.25 = (unsigned int) ret;
      *bytesread = ret.25;
      <D.12208>:
      D.12189 = 1;
      return D.12189;
    }
  finally
    {
      console_handle = {CLOBBER};
    }
}


console_getfiletype ()
{
  WapiFileType D.12212;

  D.12212 = 2;
  return D.12212;
}


file_setfiletime (void * handle, const struct WapiFileTime * create_time, const struct WapiFileTime * last_access, const struct WapiFileTime * last_write)
{
  gboolean D.12216;
  struct _WapiHandle_file * file_handle.26;
  unsigned int D.12218;
  unsigned int D.12219;
  gchar * D.12222;
  unsigned int D.12229;
  long long unsigned int D.12230;
  long long unsigned int D.12231;
  unsigned int D.12232;
  long long unsigned int D.12233;
  long long unsigned int D.12236;
  long long unsigned int D.12237;
  long int D.12238;
  long int D.12240;
  unsigned int D.12243;
  long long unsigned int D.12244;
  long long unsigned int D.12245;
  unsigned int D.12246;
  long long unsigned int D.12247;
  long long unsigned int D.12250;
  long long unsigned int D.12251;
  long int D.12252;
  long int D.12254;
  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.12214>; else goto <D.12215>;
      <D.12214>:
      monoeg_g_log (0B, 16, "%s: error looking up file handle %p", &__func__, handle);
      SetLastError (6);
      D.12216 = 0;
      return D.12216;
      <D.12215>:
      file_handle.26 = file_handle;
      fd = file_handle.26->fd;
      file_handle.26 = file_handle;
      D.12218 = BIT_FIELD_REF <*file_handle.26, 32, 128>;
      D.12219 = D.12218 & 1342177280;
      if (D.12219 == 0) goto <D.12220>; else goto <D.12221>;
      <D.12220>:
      SetLastError (5);
      D.12216 = 0;
      return D.12216;
      <D.12221>:
      file_handle.26 = file_handle;
      D.12222 = file_handle.26->filename;
      if (D.12222 == 0B) goto <D.12223>; else goto <D.12224>;
      <D.12223>:
      SetLastError (6);
      D.12216 = 0;
      return D.12216;
      <D.12224>:
      ret = fstat (fd, &statbuf);
      if (ret == -1) goto <D.12225>; else goto <D.12226>;
      <D.12225>:
      SetLastError (87);
      D.12216 = 0;
      return D.12216;
      <D.12226>:
      if (last_access != 0B) goto <D.12227>; else goto <D.12228>;
      <D.12227>:
      D.12229 = last_access->dwHighDateTime;
      D.12230 = (long long unsigned int) D.12229;
      D.12231 = D.12230 << 32;
      D.12232 = last_access->dwLowDateTime;
      D.12233 = (long long unsigned int) D.12232;
      access_ticks = D.12231 + D.12233;
      if (access_ticks <= 116444735999999999) goto <D.12234>; else goto <D.12235>;
      <D.12234>:
      SetLastError (87);
      D.12216 = 0;
      return D.12216;
      <D.12235>:
      D.12236 = access_ticks + 18330299337709551616;
      D.12237 = D.12236 / 10000000;
      D.12238 = (long int) D.12237;
      utbuf.actime = D.12238;
      goto <D.12239>;
      <D.12228>:
      D.12240 = statbuf.st_atim.tv_sec;
      utbuf.actime = D.12240;
      <D.12239>:
      if (last_write != 0B) goto <D.12241>; else goto <D.12242>;
      <D.12241>:
      D.12243 = last_write->dwHighDateTime;
      D.12244 = (long long unsigned int) D.12243;
      D.12245 = D.12244 << 32;
      D.12246 = last_write->dwLowDateTime;
      D.12247 = (long long unsigned int) D.12246;
      write_ticks = D.12245 + D.12247;
      if (write_ticks <= 116444735999999999) goto <D.12248>; else goto <D.12249>;
      <D.12248>:
      SetLastError (87);
      D.12216 = 0;
      return D.12216;
      <D.12249>:
      D.12250 = write_ticks + 18330299337709551616;
      D.12251 = D.12250 / 10000000;
      D.12252 = (long int) D.12251;
      utbuf.modtime = D.12252;
      goto <D.12253>;
      <D.12242>:
      D.12254 = statbuf.st_mtim.tv_sec;
      utbuf.modtime = D.12254;
      <D.12253>:
      file_handle.26 = file_handle;
      D.12222 = file_handle.26->filename;
      ret = _wapi_utime (D.12222, &utbuf);
      if (ret == -1) goto <D.12255>; else goto <D.12256>;
      <D.12255>:
      SetLastError (87);
      D.12216 = 0;
      return D.12216;
      <D.12256>:
      D.12216 = 1;
      return D.12216;
    }
  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.12261;
  struct _WapiHandle_file * file_handle.27;
  unsigned int D.12263;
  signed int D.12264;
  unsigned int D.12267;
  long int D.12272;
  long int D.12273;
  long long unsigned int D.12276;
  long long unsigned int D.12277;
  long long unsigned int D.12279;
  long long unsigned int D.12280;
  long int D.12281;
  long long unsigned int D.12282;
  long long unsigned int D.12283;
  unsigned int D.12286;
  long long unsigned int D.12287;
  unsigned int D.12288;
  unsigned int D.12291;
  long long unsigned int D.12292;
  unsigned int D.12293;
  unsigned int D.12296;
  long long unsigned int D.12297;
  unsigned int D.12298;
  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.12259>; else goto <D.12260>;
      <D.12259>:
      monoeg_g_log (0B, 16, "%s: error looking up file handle %p", &__func__, handle);
      SetLastError (6);
      D.12261 = 0;
      return D.12261;
      <D.12260>:
      file_handle.27 = file_handle;
      fd = file_handle.27->fd;
      file_handle.27 = file_handle;
      D.12263 = file_handle.27->fileaccess;
      D.12264 = (signed int) D.12263;
      if (D.12264 >= 0) goto <D.12265>; else goto <D.12266>;
      <D.12265>:
      file_handle.27 = file_handle;
      D.12263 = file_handle.27->fileaccess;
      D.12267 = D.12263 & 268435456;
      if (D.12267 == 0) goto <D.12268>; else goto <D.12269>;
      <D.12268>:
      SetLastError (5);
      D.12261 = 0;
      return D.12261;
      <D.12269>:
      <D.12266>:
      ret = fstat (fd, &statbuf);
      if (ret == -1) goto <D.12270>; else goto <D.12271>;
      <D.12270>:
      _wapi_set_last_error_from_errno ();
      D.12261 = 0;
      return D.12261;
      <D.12271>:
      D.12272 = statbuf.st_atim.tv_sec;
      D.12273 = statbuf.st_ctim.tv_sec;
      if (D.12272 < D.12273) goto <D.12274>; else goto <D.12275>;
      <D.12274>:
      D.12272 = statbuf.st_atim.tv_sec;
      D.12276 = (long long unsigned int) D.12272;
      D.12277 = D.12276 * 10000000;
      create_ticks = D.12277 + 116444736000000000;
      goto <D.12278>;
      <D.12275>:
      D.12273 = statbuf.st_ctim.tv_sec;
      D.12279 = (long long unsigned int) D.12273;
      D.12280 = D.12279 * 10000000;
      create_ticks = D.12280 + 116444736000000000;
      <D.12278>:
      D.12272 = statbuf.st_atim.tv_sec;
      D.12276 = (long long unsigned int) D.12272;
      D.12277 = D.12276 * 10000000;
      access_ticks = D.12277 + 116444736000000000;
      D.12281 = statbuf.st_mtim.tv_sec;
      D.12282 = (long long unsigned int) D.12281;
      D.12283 = D.12282 * 10000000;
      write_ticks = D.12283 + 116444736000000000;
      if (create_time != 0B) goto <D.12284>; else goto <D.12285>;
      <D.12284>:
      D.12286 = (unsigned int) create_ticks;
      create_time->dwLowDateTime = D.12286;
      D.12287 = create_ticks >> 32;
      D.12288 = (unsigned int) D.12287;
      create_time->dwHighDateTime = D.12288;
      <D.12285>:
      if (last_access != 0B) goto <D.12289>; else goto <D.12290>;
      <D.12289>:
      D.12291 = (unsigned int) access_ticks;
      last_access->dwLowDateTime = D.12291;
      D.12292 = access_ticks >> 32;
      D.12293 = (unsigned int) D.12292;
      last_access->dwHighDateTime = D.12293;
      <D.12290>:
      if (last_write != 0B) goto <D.12294>; else goto <D.12295>;
      <D.12294>:
      D.12296 = (unsigned int) write_ticks;
      last_write->dwLowDateTime = D.12296;
      D.12297 = write_ticks >> 32;
      D.12298 = (unsigned int) D.12297;
      last_write->dwHighDateTime = D.12298;
      <D.12295>:
      D.12261 = 1;
      return D.12261;
    }
  finally
    {
      file_handle = {CLOBBER};
      statbuf = {CLOBBER};
    }
}


file_getfilesize (void * handle, guint32 * highsize)
{
  guint32 D.12303;
  struct _WapiHandle_file * file_handle.28;
  unsigned int D.12305;
  signed int D.12306;
  unsigned int D.12309;
  unsigned int D.12310;
  unsigned int D.12315;
  unsigned int D.12316;
  int D.12319;
  long long unsigned int bigsize.29;
  long long unsigned int D.12325;
  unsigned int D.12326;
  long long int D.12327;
  long long int D.12330;
  unsigned int D.12331;
  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.12301>; else goto <D.12302>;
      <D.12301>:
      monoeg_g_log (0B, 16, "%s: error looking up file handle %p", &__func__, handle);
      SetLastError (6);
      D.12303 = 4294967295;
      return D.12303;
      <D.12302>:
      file_handle.28 = file_handle;
      fd = file_handle.28->fd;
      file_handle.28 = file_handle;
      D.12305 = file_handle.28->fileaccess;
      D.12306 = (signed int) D.12305;
      if (D.12306 >= 0) goto <D.12307>; else goto <D.12308>;
      <D.12307>:
      file_handle.28 = file_handle;
      D.12309 = BIT_FIELD_REF <*file_handle.28, 32, 128>;
      D.12310 = D.12309 & 1342177280;
      if (D.12310 == 0) goto <D.12311>; else goto <D.12312>;
      <D.12311>:
      SetLastError (5);
      D.12303 = 4294967295;
      return D.12303;
      <D.12312>:
      <D.12308>:
      SetLastError (0);
      ret = fstat (fd, &statbuf);
      if (ret == -1) goto <D.12313>; else goto <D.12314>;
      <D.12313>:
      _wapi_set_last_error_from_errno ();
      D.12303 = 4294967295;
      return D.12303;
      <D.12314>:
      D.12315 = statbuf.st_mode;
      D.12316 = D.12315 & 61440;
      if (D.12316 == 24576) goto <D.12317>; else goto <D.12318>;
      <D.12317>:
      {
        guint64 bigsize;

        try
          {
            D.12319 = ioctl (fd, 1074008690, &bigsize);
            if (D.12319 < 0) goto <D.12320>; else goto <D.12321>;
            <D.12320>:
            _wapi_set_last_error_from_errno ();
            D.12303 = 4294967295;
            return D.12303;
            <D.12321>:
            bigsize.29 = bigsize;
            size = (guint32) bigsize.29;
            if (highsize != 0B) goto <D.12323>; else goto <D.12324>;
            <D.12323>:
            bigsize.29 = bigsize;
            D.12325 = bigsize.29 >> 32;
            D.12326 = (unsigned int) D.12325;
            *highsize = D.12326;
            <D.12324>:
            D.12303 = size;
            return D.12303;
          }
        finally
          {
            bigsize = {CLOBBER};
          }
      }
      <D.12318>:
      D.12327 = statbuf.st_size;
      size = (guint32) D.12327;
      if (highsize != 0B) goto <D.12328>; else goto <D.12329>;
      <D.12328>:
      D.12327 = statbuf.st_size;
      D.12330 = D.12327 >> 32;
      D.12331 = (unsigned int) D.12330;
      *highsize = D.12331;
      <D.12329>:
      D.12303 = size;
      return D.12303;
    }
  finally
    {
      file_handle = {CLOBBER};
      statbuf = {CLOBBER};
    }
}


file_setendoffile (void * handle)
{
  gboolean D.12337;
  struct _WapiHandle_file * file_handle.30;
  unsigned int D.12339;
  unsigned int D.12340;
  int * D.12348;
  int D.12349;
  int D.12351;
  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.12335>; else goto <D.12336>;
      <D.12335>:
      monoeg_g_log (0B, 16, "%s: error looking up file handle %p", &__func__, handle);
      SetLastError (6);
      D.12337 = 0;
      return D.12337;
      <D.12336>:
      file_handle.30 = file_handle;
      fd = file_handle.30->fd;
      file_handle.30 = file_handle;
      D.12339 = BIT_FIELD_REF <*file_handle.30, 32, 128>;
      D.12340 = D.12339 & 1342177280;
      if (D.12340 == 0) goto <D.12341>; else goto <D.12342>;
      <D.12341>:
      SetLastError (5);
      D.12337 = 0;
      return D.12337;
      <D.12342>:
      ret = fstat (fd, &statbuf);
      if (ret == -1) goto <D.12343>; else goto <D.12344>;
      <D.12343>:
      _wapi_set_last_error_from_errno ();
      D.12337 = 0;
      return D.12337;
      <D.12344>:
      size = statbuf.st_size;
      pos = lseek (fd, 0, 1);
      if (pos == -1) goto <D.12345>; else goto <D.12346>;
      <D.12345>:
      _wapi_set_last_error_from_errno ();
      D.12337 = 0;
      return D.12337;
      <D.12346>:
      <D.11038>:
      ret = ftruncate (fd, pos);
      if (ret == -1) goto <D.12347>; else goto <D.11039>;
      <D.12347>:
      D.12348 = __errno_location ();
      D.12349 = *D.12348;
      if (D.12349 == 4) goto <D.12350>; else goto <D.11039>;
      <D.12350>:
      D.12351 = _wapi_thread_cur_apc_pending ();
      if (D.12351 == 0) goto <D.11038>; else goto <D.11039>;
      <D.11039>:
      if (ret == -1) goto <D.12352>; else goto <D.12353>;
      <D.12352>:
      _wapi_set_last_error_from_errno ();
      D.12337 = 0;
      return D.12337;
      <D.12353>:
      D.12337 = 1;
      return D.12337;
    }
  finally
    {
      file_handle = {CLOBBER};
      statbuf = {CLOBBER};
    }
}


file_seek (void * handle, gint32 movedistance, gint32 * highmovedistance, WapiSeekMethod method)
{
  guint32 D.12358;
  struct _WapiHandle_file * file_handle.31;
  unsigned int D.12360;
  signed int D.12361;
  unsigned int D.12364;
  unsigned int D.12365;
  int D.12371;
  long long int D.12372;
  long long int D.12373;
  unsigned int movedistance.32;
  long long int D.12375;
  long long int D.12380;
  int D.12381;
  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.12356>; else goto <D.12357>;
      <D.12356>:
      monoeg_g_log (0B, 16, "%s: error looking up file handle %p", &__func__, handle);
      SetLastError (6);
      D.12358 = 4294967295;
      return D.12358;
      <D.12357>:
      file_handle.31 = file_handle;
      fd = file_handle.31->fd;
      file_handle.31 = file_handle;
      D.12360 = file_handle.31->fileaccess;
      D.12361 = (signed int) D.12360;
      if (D.12361 >= 0) goto <D.12362>; else goto <D.12363>;
      <D.12362>:
      file_handle.31 = file_handle;
      D.12364 = BIT_FIELD_REF <*file_handle.31, 32, 128>;
      D.12365 = D.12364 & 1342177280;
      if (D.12365 == 0) goto <D.12366>; else goto <D.12367>;
      <D.12366>:
      SetLastError (5);
      D.12358 = 4294967295;
      return D.12358;
      <D.12367>:
      <D.12363>:
      switch (method) <default: <D.11026>, case 0: <D.11022>, case 1: <D.11024>, case 2: <D.11025>>
      <D.11022>:
      whence = 0;
      goto <D.11023>;
      <D.11024>:
      whence = 1;
      goto <D.11023>;
      <D.11025>:
      whence = 2;
      goto <D.11023>;
      <D.11026>:
      SetLastError (87);
      D.12358 = 4294967295;
      return D.12358;
      <D.11023>:
      if (highmovedistance == 0B) goto <D.12368>; else goto <D.12369>;
      <D.12368>:
      offset = (gint64) movedistance;
      goto <D.12370>;
      <D.12369>:
      D.12371 = *highmovedistance;
      D.12372 = (long long int) D.12371;
      D.12373 = D.12372 << 32;
      movedistance.32 = (unsigned int) movedistance;
      D.12375 = (long long int) movedistance.32;
      offset = D.12373 | D.12375;
      <D.12370>:
      newpos = lseek (fd, offset, whence);
      if (newpos == -1) goto <D.12376>; else goto <D.12377>;
      <D.12376>:
      _wapi_set_last_error_from_errno ();
      D.12358 = 4294967295;
      return D.12358;
      <D.12377>:
      ret = (guint32) newpos;
      if (highmovedistance != 0B) goto <D.12378>; else goto <D.12379>;
      <D.12378>:
      D.12380 = newpos >> 32;
      D.12381 = (int) D.12380;
      *highmovedistance = D.12381;
      <D.12379>:
      D.12358 = ret;
      return D.12358;
    }
  finally
    {
      file_handle = {CLOBBER};
    }
}


file_flush (void * handle)
{
  gboolean D.12386;
  struct _WapiHandle_file * file_handle.33;
  unsigned int D.12388;
  unsigned int D.12389;
  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.12384>; else goto <D.12385>;
      <D.12384>:
      monoeg_g_log (0B, 16, "%s: error looking up file handle %p", &__func__, handle);
      SetLastError (6);
      D.12386 = 0;
      return D.12386;
      <D.12385>:
      file_handle.33 = file_handle;
      fd = file_handle.33->fd;
      file_handle.33 = file_handle;
      D.12388 = BIT_FIELD_REF <*file_handle.33, 32, 128>;
      D.12389 = D.12388 & 1342177280;
      if (D.12389 == 0) goto <D.12390>; else goto <D.12391>;
      <D.12390>:
      SetLastError (5);
      D.12386 = 0;
      return D.12386;
      <D.12391>:
      ret = fsync (fd);
      if (ret == -1) goto <D.12392>; else goto <D.12393>;
      <D.12392>:
      _wapi_set_last_error_from_errno ();
      D.12386 = 0;
      return D.12386;
      <D.12393>:
      D.12386 = 1;
      return D.12386;
    }
  finally
    {
      file_handle = {CLOBBER};
    }
}


file_write (void * handle, const void * buffer, guint32 numbytes, guint32 * byteswritten, struct WapiOverlapped * overlapped)
{
  gboolean D.12398;
  struct _WapiHandle_file * file_handle.34;
  unsigned int D.12402;
  unsigned int D.12403;
  int lock_while_writing.35;
  long long int D.12411;
  int D.12412;
  int * D.12416;
  int D.12417;
  int D.12419;
  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.12396>; else goto <D.12397>;
      <D.12396>:
      monoeg_g_log (0B, 16, "%s: error looking up file handle %p", &__func__, handle);
      SetLastError (6);
      D.12398 = 0;
      return D.12398;
      <D.12397>:
      file_handle.34 = file_handle;
      fd = file_handle.34->fd;
      if (byteswritten != 0B) goto <D.12400>; else goto <D.12401>;
      <D.12400>:
      *byteswritten = 0;
      <D.12401>:
      file_handle.34 = file_handle;
      D.12402 = BIT_FIELD_REF <*file_handle.34, 32, 128>;
      D.12403 = D.12402 & 1342177280;
      if (D.12403 == 0) goto <D.12404>; else goto <D.12405>;
      <D.12404>:
      SetLastError (5);
      D.12398 = 0;
      return D.12398;
      <D.12405>:
      lock_while_writing.35 = lock_while_writing;
      if (lock_while_writing.35 != 0) goto <D.12407>; else goto <D.12408>;
      <D.12407>:
      current_pos = lseek (fd, 0, 1);
      if (current_pos == -1) goto <D.12409>; else goto <D.12410>;
      <D.12409>:
      _wapi_set_last_error_from_errno ();
      D.12398 = 0;
      return D.12398;
      <D.12410>:
      D.12411 = (long long int) numbytes;
      D.12412 = _wapi_lock_file_region (fd, current_pos, D.12411);
      if (D.12412 == 0) goto <D.12413>; else goto <D.12414>;
      <D.12413>:
      D.12398 = 0;
      return D.12398;
      <D.12414>:
      <D.12408>:
      <D.10998>:
      ret = write (fd, buffer, numbytes);
      if (ret == -1) goto <D.12415>; else goto <D.10999>;
      <D.12415>:
      D.12416 = __errno_location ();
      D.12417 = *D.12416;
      if (D.12417 == 4) goto <D.12418>; else goto <D.10999>;
      <D.12418>:
      D.12419 = _wapi_thread_cur_apc_pending ();
      if (D.12419 == 0) goto <D.10998>; else goto <D.10999>;
      <D.10999>:
      lock_while_writing.35 = lock_while_writing;
      if (lock_while_writing.35 != 0) goto <D.12420>; else goto <D.12421>;
      <D.12420>:
      D.12411 = (long long int) numbytes;
      _wapi_unlock_file_region (fd, current_pos, D.12411);
      <D.12421>:
      if (ret == -1) goto <D.12422>; else goto <D.12423>;
      <D.12422>:
      D.12416 = __errno_location ();
      D.12417 = *D.12416;
      if (D.12417 == 4) goto <D.12424>; else goto <D.12425>;
      <D.12424>:
      ret = 0;
      goto <D.12426>;
      <D.12425>:
      _wapi_set_last_error_from_errno ();
      D.12398 = 0;
      return D.12398;
      <D.12426>:
      <D.12423>:
      if (byteswritten != 0B) goto <D.12427>; else goto <D.12428>;
      <D.12427>:
      ret.36 = (unsigned int) ret;
      *byteswritten = ret.36;
      <D.12428>:
      D.12398 = 1;
      return D.12398;
    }
  finally
    {
      file_handle = {CLOBBER};
    }
}


file_read (void * handle, void * buffer, guint32 numbytes, guint32 * bytesread, struct WapiOverlapped * overlapped)
{
  gboolean D.12434;
  struct _WapiHandle_file * file_handle.37;
  unsigned int D.12438;
  signed int D.12439;
  unsigned int D.12442;
  int * D.12446;
  int D.12447;
  int D.12449;
  int D.12452;
  unsigned int D.12453;
  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.12432>; else goto <D.12433>;
      <D.12432>:
      monoeg_g_log (0B, 16, "%s: error looking up file handle %p", &__func__, handle);
      SetLastError (6);
      D.12434 = 0;
      return D.12434;
      <D.12433>:
      file_handle.37 = file_handle;
      fd = file_handle.37->fd;
      if (bytesread != 0B) goto <D.12436>; else goto <D.12437>;
      <D.12436>:
      *bytesread = 0;
      <D.12437>:
      file_handle.37 = file_handle;
      D.12438 = file_handle.37->fileaccess;
      D.12439 = (signed int) D.12438;
      if (D.12439 >= 0) goto <D.12440>; else goto <D.12441>;
      <D.12440>:
      file_handle.37 = file_handle;
      D.12438 = file_handle.37->fileaccess;
      D.12442 = D.12438 & 268435456;
      if (D.12442 == 0) goto <D.12443>; else goto <D.12444>;
      <D.12443>:
      SetLastError (5);
      D.12434 = 0;
      return D.12434;
      <D.12444>:
      <D.12441>:
      <D.10982>:
      ret = read (fd, buffer, numbytes);
      if (ret == -1) goto <D.12445>; else goto <D.10983>;
      <D.12445>:
      D.12446 = __errno_location ();
      D.12447 = *D.12446;
      if (D.12447 == 4) goto <D.12448>; else goto <D.10983>;
      <D.12448>:
      D.12449 = _wapi_thread_cur_apc_pending ();
      if (D.12449 == 0) goto <D.10982>; else goto <D.10983>;
      <D.10983>:
      if (ret == -1) goto <D.12450>; else goto <D.12451>;
      <D.12450>:
      {
        gint err;

        D.12446 = __errno_location ();
        err = *D.12446;
        D.12452 = _wapi_get_win32_file_error (err);
        D.12453 = (unsigned int) D.12452;
        SetLastError (D.12453);
        D.12434 = 0;
        return D.12434;
      }
      <D.12451>:
      if (bytesread != 0B) goto <D.12454>; else goto <D.12455>;
      <D.12454>:
      ret.38 = (unsigned int) ret;
      *bytesread = ret.38;
      <D.12455>:
      D.12434 = 1;
      return D.12434;
    }
  finally
    {
      file_handle = {CLOBBER};
    }
}


file_getfiletype ()
{
  WapiFileType D.12459;

  D.12459 = 1;
  return D.12459;
}


_wapi_handle_type (void * handle)
{
  unsigned int D.12465;
  struct _WapiHandleUnshared * D.12466;
  WapiHandleType D.12467;
  unsigned int D.12468;
  unsigned int D.12469;
  struct _WapiHandleUnshared * D.12470;
  guint32 idx;

  idx = (guint32) handle;
  if (idx > 4194303) goto <D.12461>; else goto <D.12463>;
  <D.12463>:
  if (idx > 268435455) goto <D.12461>; else goto <D.12464>;
  <D.12464>:
  D.12465 = idx / 256;
  D.12466 = _wapi_private_handles[D.12465];
  if (D.12466 == 0B) goto <D.12461>; else goto <D.12462>;
  <D.12461>:
  D.12467 = 0;
  return D.12467;
  <D.12462>:
  D.12465 = idx / 256;
  D.12466 = _wapi_private_handles[D.12465];
  D.12468 = idx & 255;
  D.12469 = D.12468 * 144;
  D.12470 = D.12466 + D.12469;
  D.12467 = D.12470->type;
  return D.12467;
}


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

  type = _wapi_handle_type (handle);
  D.12472 = io_ops[type].writefile;
  if (D.12472 == 0B) goto <D.12473>; else goto <D.12474>;
  <D.12473>:
  SetLastError (6);
  D.12475 = 0;
  return D.12475;
  <D.12474>:
  D.12472 = io_ops[type].writefile;
  D.12475 = D.12472 (handle, buffer, numbytes, byteswritten, overlapped);
  return D.12475;
}


FlushFileBuffers (void * handle)
{
  gboolean (*<T17c1>) (void *) D.12477;
  gboolean D.12480;
  WapiHandleType type;

  type = _wapi_handle_type (handle);
  D.12477 = io_ops[type].flushfile;
  if (D.12477 == 0B) goto <D.12478>; else goto <D.12479>;
  <D.12478>:
  SetLastError (6);
  D.12480 = 0;
  return D.12480;
  <D.12479>:
  D.12477 = io_ops[type].flushfile;
  D.12480 = D.12477 (handle);
  return D.12480;
}


SetEndOfFile (void * handle)
{
  gboolean (*<T17c1>) (void *) D.12482;
  gboolean D.12485;
  WapiHandleType type;

  type = _wapi_handle_type (handle);
  D.12482 = io_ops[type].setendoffile;
  if (D.12482 == 0B) goto <D.12483>; else goto <D.12484>;
  <D.12483>:
  SetLastError (6);
  D.12485 = 0;
  return D.12485;
  <D.12484>:
  D.12482 = io_ops[type].setendoffile;
  D.12485 = D.12482 (handle);
  return D.12485;
}


SetFilePointer (void * handle, gint32 movedistance, gint32 * highmovedistance, WapiSeekMethod method)
{
  guint32 (*<T1a86>) (void *, gint32, gint32 *, WapiSeekMethod) D.12487;
  guint32 D.12490;
  WapiHandleType type;

  type = _wapi_handle_type (handle);
  D.12487 = io_ops[type].seek;
  if (D.12487 == 0B) goto <D.12488>; else goto <D.12489>;
  <D.12488>:
  SetLastError (6);
  D.12490 = 4294967295;
  return D.12490;
  <D.12489>:
  D.12487 = io_ops[type].seek;
  D.12490 = D.12487 (handle, movedistance, highmovedistance, method);
  return D.12490;
}


GetFileType (void * handle)
{
  unsigned int handle.39;
  unsigned int D.12496;
  struct _WapiHandleUnshared * D.12497;
  WapiFileType D.12498;
  WapiFileType (*<T1a78>) (void) D.12499;
  WapiHandleType type;

  handle.39 = (unsigned int) handle;
  if (handle.39 > 268435455) goto <D.12492>; else goto <D.12495>;
  <D.12495>:
  handle.39 = (unsigned int) handle;
  D.12496 = handle.39 / 256;
  D.12497 = _wapi_private_handles[D.12496];
  if (D.12497 == 0B) goto <D.12492>; else goto <D.12493>;
  <D.12492>:
  SetLastError (6);
  D.12498 = 0;
  return D.12498;
  <D.12493>:
  type = _wapi_handle_type (handle);
  D.12499 = io_ops[type].getfiletype;
  if (D.12499 == 0B) goto <D.12500>; else goto <D.12501>;
  <D.12500>:
  SetLastError (6);
  D.12498 = 0;
  return D.12498;
  <D.12501>:
  D.12499 = io_ops[type].getfiletype;
  D.12498 = D.12499 ();
  return D.12498;
}


GetFileSize (void * handle, guint32 * highsize)
{
  guint32 (*<T1a8c>) (void *, guint32 *) D.12503;
  guint32 D.12506;
  WapiHandleType type;

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


GetFileTime (void * handle, struct WapiFileTime * create_time, struct WapiFileTime * last_access, struct WapiFileTime * last_write)
{
  gboolean (*<T1a90>) (void *, struct WapiFileTime *, struct WapiFileTime *, struct WapiFileTime *) D.12508;
  gboolean D.12511;
  WapiHandleType type;

  type = _wapi_handle_type (handle);
  D.12508 = io_ops[type].getfiletime;
  if (D.12508 == 0B) goto <D.12509>; else goto <D.12510>;
  <D.12509>:
  SetLastError (6);
  D.12511 = 0;
  return D.12511;
  <D.12510>:
  D.12508 = io_ops[type].getfiletime;
  D.12511 = D.12508 (handle, create_time, last_access, last_write);
  return D.12511;
}


SetFileTime (void * handle, const struct WapiFileTime * create_time, const struct WapiFileTime * last_access, const struct WapiFileTime * last_write)
{
  gboolean (*<T1a94>) (void *, const struct WapiFileTime *, const struct WapiFileTime *, const struct WapiFileTime *) D.12513;
  gboolean D.12516;
  WapiHandleType type;

  type = _wapi_handle_type (handle);
  D.12513 = io_ops[type].setfiletime;
  if (D.12513 == 0B) goto <D.12514>; else goto <D.12515>;
  <D.12514>:
  SetLastError (6);
  D.12516 = 0;
  return D.12516;
  <D.12515>:
  D.12513 = io_ops[type].setfiletime;
  D.12516 = D.12513 (handle, create_time, last_access, last_write);
  return D.12516;
}


FileTimeToSystemTime (const struct WapiFileTime * file_time, struct WapiSystemTime * system_time)
{
  gboolean D.12520;
  unsigned int D.12521;
  long long int D.12522;
  long long int D.12523;
  unsigned int D.12524;
  long long int D.12525;
  long long int D.12528;
  short unsigned int D.12529;
  long long int D.12530;
  short unsigned int D.12531;
  long long int D.12532;
  short unsigned int D.12533;
  long long int D.12534;
  short unsigned int D.12535;
  long long int D.12536;
  long long int D.12537;
  short unsigned int D.12538;
  short unsigned int D.12539;
  long long int D.12540;
  long long int D.12541;
  long long int D.12542;
  _Bool D.12543;
  long long int D.12544;
  long long int D.12545;
  long long int D.12546;
  long long int D.12547;
  _Bool D.12548;
  long long int D.12549;
  long long int D.12550;
  long long int D.12551;
  _Bool D.12552;
  long long int D.12553;
  long long int D.12554;
  long long int D.12555;
  long long int D.12556;
  long long int D.12557;
  long long int D.12558;
  _Bool D.12559;
  long long int D.12560;
  long long int D.12561;
  long long int D.12562;
  long long int D.12563;
  long long int D.12564;
  long long int D.12565;
  _Bool D.12566;
  long long int D.12567;
  long long int D.12568;
  long long int D.12569;
  _Bool D.12570;
  long long int D.12571;
  long long int D.12572;
  long long int D.12573;
  long long int D.12574;
  long long int D.12575;
  long long int D.12576;
  _Bool D.12577;
  long long int D.12578;
  long long int D.12579;
  long long int 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;
  long long int D.12587;
  long long int D.12588;
  long long int D.12589;
  long long int D.12590;
  long long int D.12591;
  long long int D.12592;
  gint64 iftmp.40;
  unsigned long long y.41;
  unsigned long long D.12599;
  long long int D.12601;
  long long int D.12603;
  short unsigned int D.12604;
  int iftmp.42;
  unsigned int D.12611;
  unsigned int D.12612;
  const guint16 * D.12613;
  short unsigned int D.12614;
  long long int D.12615;
  short unsigned int D.12616;
  short unsigned int D.12617;
  short unsigned int D.12618;
  gint64 file_ticks;
  gint64 totaldays;
  gint64 rem;
  gint64 y;
  const guint16 * ip;
  static const char __func__[21] = "FileTimeToSystemTime";

  if (system_time == 0B) goto <D.12518>; else goto <D.12519>;
  <D.12518>:
  SetLastError (87);
  D.12520 = 0;
  return D.12520;
  <D.12519>:
  D.12521 = file_time->dwHighDateTime;
  D.12522 = (long long int) D.12521;
  D.12523 = D.12522 << 32;
  D.12524 = file_time->dwLowDateTime;
  D.12525 = (long long int) D.12524;
  file_ticks = D.12523 + D.12525;
  if (file_ticks < 0) goto <D.12526>; else goto <D.12527>;
  <D.12526>:
  SetLastError (87);
  D.12520 = 0;
  return D.12520;
  <D.12527>:
  totaldays = file_ticks / 864000000000;
  rem = file_ticks % 864000000000;
  D.12528 = rem / 36000000000;
  D.12529 = (short unsigned int) D.12528;
  system_time->wHour = D.12529;
  rem = rem % 36000000000;
  D.12530 = rem / 600000000;
  D.12531 = (short unsigned int) D.12530;
  system_time->wMinute = D.12531;
  rem = rem % 600000000;
  D.12532 = rem / 10000000;
  D.12533 = (short unsigned int) D.12532;
  system_time->wSecond = D.12533;
  rem = rem % 10000000;
  D.12534 = rem / 10000;
  D.12535 = (short unsigned int) D.12534;
  system_time->wMilliseconds = D.12535;
  D.12536 = totaldays + 1;
  D.12537 = D.12536 % 7;
  D.12538 = (short unsigned int) D.12537;
  D.12539 = D.12538 + 1;
  system_time->wDayOfWeek = D.12539;
  y = 1601;
  goto <D.11381>;
  <D.11380>:
  {
    gint64 yg;

    D.12540 = totaldays / 365;
    D.12541 = D.12540 + y;
    D.12542 = totaldays % 365;
    D.12543 = D.12542 < 0;
    D.12544 = (long long int) D.12543;
    yg = D.12541 - D.12544;
    D.12545 = yg + -1;
    D.12546 = D.12545 / 4;
    D.12545 = yg + -1;
    D.12547 = D.12545 % 4;
    D.12548 = D.12547 < 0;
    D.12549 = (long long int) D.12548;
    D.12550 = D.12546 - D.12549;
    D.12545 = yg + -1;
    D.12551 = D.12545 % 100;
    D.12552 = D.12551 < 0;
    D.12553 = (long long int) D.12552;
    D.12545 = yg + -1;
    D.12554 = D.12545 / -100;
    D.12555 = D.12553 + D.12554;
    D.12556 = D.12550 + D.12555;
    D.12545 = yg + -1;
    D.12557 = D.12545 / 400;
    D.12545 = yg + -1;
    D.12558 = D.12545 % 400;
    D.12559 = D.12558 < 0;
    D.12560 = (long long int) D.12559;
    D.12561 = D.12557 - D.12560;
    D.12562 = D.12556 + D.12561;
    D.12563 = y + -1;
    D.12564 = D.12563 / 4;
    D.12563 = y + -1;
    D.12565 = D.12563 % 4;
    D.12566 = D.12565 < 0;
    D.12567 = (long long int) D.12566;
    D.12568 = D.12564 - D.12567;
    D.12563 = y + -1;
    D.12569 = D.12563 % 100;
    D.12570 = D.12569 < 0;
    D.12571 = (long long int) D.12570;
    D.12563 = y + -1;
    D.12572 = D.12563 / -100;
    D.12573 = D.12571 + D.12572;
    D.12574 = D.12568 + D.12573;
    D.12563 = y + -1;
    D.12575 = D.12563 / 400;
    D.12563 = y + -1;
    D.12576 = D.12563 % 400;
    D.12577 = D.12576 < 0;
    D.12578 = (long long int) D.12577;
    D.12579 = D.12575 - D.12578;
    D.12580 = D.12574 + D.12579;
    monoeg_g_log (0B, 32, "%s: LEAPS(yg): %lld LEAPS(y): %lld", &__func__, D.12562, D.12580);
    D.12563 = y + -1;
    D.12564 = D.12563 / 4;
    D.12563 = y + -1;
    D.12565 = D.12563 % 4;
    D.12566 = D.12565 < 0;
    D.12567 = (long long int) D.12566;
    D.12568 = D.12564 - D.12567;
    D.12563 = y + -1;
    D.12569 = D.12563 % 100;
    D.12570 = D.12569 < 0;
    D.12571 = (long long int) D.12570;
    D.12563 = y + -1;
    D.12572 = D.12563 / -100;
    D.12573 = D.12571 + D.12572;
    D.12574 = D.12568 + D.12573;
    D.12563 = y + -1;
    D.12575 = D.12563 / 400;
    D.12563 = y + -1;
    D.12576 = D.12563 % 400;
    D.12577 = D.12576 < 0;
    D.12578 = (long long int) D.12577;
    D.12579 = D.12575 - D.12578;
    D.12580 = D.12574 + D.12579;
    D.12545 = yg + -1;
    D.12558 = D.12545 % 400;
    D.12559 = D.12558 < 0;
    D.12560 = (long long int) D.12559;
    D.12545 = yg + -1;
    D.12581 = D.12545 / -400;
    D.12582 = D.12560 + D.12581;
    D.12545 = yg + -1;
    D.12583 = D.12545 / 100;
    D.12545 = yg + -1;
    D.12551 = D.12545 % 100;
    D.12552 = D.12551 < 0;
    D.12553 = (long long int) D.12552;
    D.12584 = D.12583 - D.12553;
    D.12545 = yg + -1;
    D.12547 = D.12545 % 4;
    D.12548 = D.12547 < 0;
    D.12549 = (long long int) D.12548;
    D.12545 = yg + -1;
    D.12585 = D.12545 / -4;
    D.12586 = D.12549 + D.12585;
    D.12587 = D.12584 + D.12586;
    D.12588 = D.12582 + D.12587;
    D.12589 = y - yg;
    D.12590 = D.12589 * 365;
    D.12591 = D.12588 + D.12590;
    D.12592 = D.12580 + D.12591;
    totaldays = D.12592 + totaldays;
    y = yg;
  }
  <D.11381>:
  if (totaldays < 0) goto <D.11380>; else goto <D.12593>;
  <D.12593>:
  y.41 = (unsigned long long) y;
  D.12599 = y.41 & 3;
  if (D.12599 == 0) goto <D.12600>; else goto <D.12595>;
  <D.12600>:
  D.12601 = y % 100;
  if (D.12601 != 0) goto <D.12596>; else goto <D.12602>;
  <D.12602>:
  D.12603 = y % 400;
  if (D.12603 == 0) goto <D.12596>; else goto <D.12595>;
  <D.12596>:
  iftmp.40 = 366;
  goto <D.12597>;
  <D.12595>:
  iftmp.40 = 365;
  <D.12597>:
  if (iftmp.40 <= totaldays) goto <D.11380>; else goto <D.11382>;
  <D.11382>:
  D.12604 = (short unsigned int) y;
  system_time->wYear = D.12604;
  y.41 = (unsigned long long) y;
  D.12599 = y.41 & 3;
  if (D.12599 == 0) goto <D.12609>; else goto <D.12606>;
  <D.12609>:
  D.12601 = y % 100;
  if (D.12601 != 0) goto <D.12607>; else goto <D.12610>;
  <D.12610>:
  D.12603 = y % 400;
  if (D.12603 == 0) goto <D.12607>; else goto <D.12606>;
  <D.12607>:
  iftmp.42 = 1;
  goto <D.12608>;
  <D.12606>:
  iftmp.42 = 0;
  <D.12608>:
  ip = &mon_yday[iftmp.42];
  y = 11;
  goto <D.11385>;
  <D.11384>:
  // predicted unlikely by continue predictor.
  goto <D.11383>;
  <D.11383>:
  y = y + -1;
  <D.11385>:
  D.12611 = (unsigned int) y;
  D.12612 = D.12611 * 2;
  D.12613 = ip + D.12612;
  D.12614 = *D.12613;
  D.12615 = (long long int) D.12614;
  if (D.12615 > totaldays) goto <D.11384>; else goto <D.11386>;
  <D.11386>:
  D.12611 = (unsigned int) y;
  D.12612 = D.12611 * 2;
  D.12613 = ip + D.12612;
  D.12614 = *D.12613;
  D.12615 = (long long int) D.12614;
  totaldays = totaldays - D.12615;
  D.12604 = (short unsigned int) y;
  D.12616 = D.12604 + 1;
  system_time->wMonth = D.12616;
  D.12617 = (short unsigned int) totaldays;
  D.12618 = D.12617 + 1;
  system_time->wDay = D.12618;
  D.12520 = 1;
  return D.12520;
}


FindFirstFile (const gunichar2 * pattern, struct WapiFindData * find_data)
{
  void * D.12622;
  int D.12633;
  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.12620>; else goto <D.12621>;
      <D.12620>:
      SetLastError (3);
      D.12622 = 4294967295B;
      return D.12622;
      <D.12621>:
      utf8_pattern = mono_unicode_to_external (pattern);
      if (utf8_pattern == 0B) goto <D.12623>; else goto <D.12624>;
      <D.12623>:
      SetLastError (123);
      D.12622 = 4294967295B;
      return D.12622;
      <D.12624>:
      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.12625>; else goto <D.12626>;
      <D.12625>:
      SetLastError (2);
      monoeg_g_free (utf8_pattern);
      monoeg_g_free (entry_part);
      monoeg_g_free (dir_part);
      D.12622 = 4294967295B;
      return D.12622;
      <D.12626>:
      if (result < 0) goto <D.12627>; else goto <D.12628>;
      <D.12627>:
      _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.12622 = 4294967295B;
      return D.12622;
      <D.12628>:
      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.12629>; else goto <D.12630>;
      <D.12629>:
      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.12622 = 4294967295B;
      return D.12622;
      <D.12630>:
      if (handle != 4294967295B) goto <D.12631>; else goto <D.12632>;
      <D.12631>:
      D.12633 = FindNextFile (handle, find_data);
      if (D.12633 == 0) goto <D.12634>; else goto <D.12635>;
      <D.12634>:
      FindClose (handle);
      SetLastError (18);
      handle = 4294967295B;
      <D.12635>:
      <D.12632>:
      D.12622 = handle;
      return D.12622;
    }
  finally
    {
      find_handle = {CLOBBER};
    }
}


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


_wapi_handle_lock_handle (void * handle)
{
  int D.12719;
  <unnamed type> D.12722;
  <unnamed type> D.12724;
  <unnamed type> D.12726;
  <unnamed type> D.12728;
  unsigned int D.12729;
  struct _WapiHandleUnshared * D.12730;
  unsigned int D.12731;
  unsigned int D.12732;
  struct _WapiHandleUnshared * D.12733;
  union mono_mutex_t * D.12734;
  guint32 idx;

  idx = (guint32) handle;
  if (idx > 4194303) goto <D.12717>; else goto <D.12718>;
  <D.12717>:
  D.12719 = 0;
  return D.12719;
  <D.12718>:
  _wapi_handle_ref (handle);
  D.12722 = _wapi_handle_type (handle);
  if (D.12722 == 9) goto <D.12720>; else goto <D.12723>;
  <D.12723>:
  D.12724 = _wapi_handle_type (handle);
  if (D.12724 == 11) goto <D.12720>; else goto <D.12725>;
  <D.12725>:
  D.12726 = _wapi_handle_type (handle);
  if (D.12726 == 12) goto <D.12720>; else goto <D.12727>;
  <D.12727>:
  D.12728 = _wapi_handle_type (handle);
  if (D.12728 == 13) goto <D.12720>; else goto <D.12721>;
  <D.12720>:
  D.12719 = 0;
  return D.12719;
  <D.12721>:
  D.12729 = idx / 256;
  D.12730 = _wapi_private_handles[D.12729];
  D.12731 = idx & 255;
  D.12732 = D.12731 * 144;
  D.12733 = D.12730 + D.12732;
  D.12734 = &D.12733->signal_mutex;
  D.12719 = pthread_mutex_lock (D.12734);
  return D.12719;
}


_wapi_stat_to_file_attributes (const gchar * pathname, struct stat * buf, struct stat * lbuf)
{
  unsigned int D.12736;
  unsigned int D.12737;
  unsigned int D.12740;
  int D.12743;
  char D.12746;
  int D.12750;
  unsigned int D.12761;
  unsigned int D.12762;
  guint32 D.12765;
  guint32 attrs;
  gchar * filename;

  attrs = 0;
  D.12736 = buf->st_mode;
  D.12737 = D.12736 & 61440;
  if (D.12737 == 49152) goto <D.12738>; else goto <D.12739>;
  <D.12738>:
  D.12736 = buf->st_mode;
  D.12740 = D.12736 & 4294918143;
  buf->st_mode = D.12740;
  <D.12739>:
  filename = _wapi_basename (pathname);
  D.12736 = buf->st_mode;
  D.12737 = D.12736 & 61440;
  if (D.12737 == 16384) goto <D.12741>; else goto <D.12742>;
  <D.12741>:
  attrs = 16;
  D.12743 = is_file_writable (buf, pathname);
  if (D.12743 == 0) goto <D.12744>; else goto <D.12745>;
  <D.12744>:
  attrs = attrs | 1;
  <D.12745>:
  D.12746 = *filename;
  if (D.12746 == 46) goto <D.12747>; else goto <D.12748>;
  <D.12747>:
  attrs = attrs | 2;
  <D.12748>:
  goto <D.12749>;
  <D.12742>:
  D.12750 = is_file_writable (buf, pathname);
  if (D.12750 == 0) goto <D.12751>; else goto <D.12752>;
  <D.12751>:
  attrs = 1;
  D.12746 = *filename;
  if (D.12746 == 46) goto <D.12753>; else goto <D.12754>;
  <D.12753>:
  attrs = attrs | 2;
  <D.12754>:
  goto <D.12755>;
  <D.12752>:
  D.12746 = *filename;
  if (D.12746 == 46) goto <D.12756>; else goto <D.12757>;
  <D.12756>:
  attrs = 2;
  goto <D.12758>;
  <D.12757>:
  attrs = 128;
  <D.12758>:
  <D.12755>:
  <D.12749>:
  if (lbuf != 0B) goto <D.12759>; else goto <D.12760>;
  <D.12759>:
  D.12761 = lbuf->st_mode;
  D.12762 = D.12761 & 61440;
  if (D.12762 == 40960) goto <D.12763>; else goto <D.12764>;
  <D.12763>:
  attrs = attrs | 1024;
  <D.12764>:
  <D.12760>:
  monoeg_g_free (filename);
  D.12765 = attrs;
  return D.12765;
}


is_file_writable (struct stat * st, const char * path)
{
  unsigned int D.12767;
  unsigned int D.12768;
  gboolean D.12771;
  unsigned int D.12772;
  unsigned int D.12773;
  unsigned int D.12776;
  unsigned int D.12779;
  unsigned int D.12780;
  unsigned int D.12783;
  int D.12786;
  _Bool D.12787;

  D.12767 = st->st_mode;
  D.12768 = D.12767 & 2;
  if (D.12768 != 0) goto <D.12769>; else goto <D.12770>;
  <D.12769>:
  D.12771 = 1;
  return D.12771;
  <D.12770>:
  D.12772 = st->st_uid;
  D.12773 = geteuid ();
  if (D.12772 == D.12773) goto <D.12774>; else goto <D.12775>;
  <D.12774>:
  D.12767 = st->st_mode;
  D.12776 = D.12767 & 128;
  if (D.12776 != 0) goto <D.12777>; else goto <D.12778>;
  <D.12777>:
  D.12771 = 1;
  return D.12771;
  <D.12778>:
  <D.12775>:
  D.12779 = st->st_gid;
  D.12780 = getegid ();
  if (D.12779 == D.12780) goto <D.12781>; else goto <D.12782>;
  <D.12781>:
  D.12767 = st->st_mode;
  D.12783 = D.12767 & 16;
  if (D.12783 != 0) goto <D.12784>; else goto <D.12785>;
  <D.12784>:
  D.12771 = 1;
  return D.12771;
  <D.12785>:
  <D.12782>:
  D.12786 = access (path, 2);
  D.12787 = D.12786 == 0;
  D.12771 = (gboolean) D.12787;
  return D.12771;
}


memset (void * __dest, int __ch, size_t __len)
{
  int D.12791;
  int D.12796;
  void * D.12798;
  unsigned int D.12799;

  D.12791 = __builtin_constant_p (__len);
  if (D.12791 != 0) goto <D.12792>; else goto <D.12793>;
  <D.12792>:
  if (__len == 0) goto <D.12794>; else goto <D.12795>;
  <D.12794>:
  D.12796 = __builtin_constant_p (__ch);
  if (D.12796 == 0) goto <D.12789>; else goto <D.12797>;
  <D.12797>:
  if (__ch != 0) goto <D.12789>; else goto <D.12790>;
  <D.12789>:
  __warn_memset_zero_len ();
  D.12798 = __dest;
  return D.12798;
  <D.12790>:
  <D.12795>:
  <D.12793>:
  D.12799 = __builtin_object_size (__dest, 0);
  D.12798 = __builtin___memset_chk (__dest, __ch, __len, D.12799);
  return D.12798;
}


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

  D.12802 = __builtin_object_size (__dest, 0);
  D.12801 = __builtin___memcpy_chk (__dest, __src, __len, D.12802);
  return D.12801;
}


_wapi_handle_unlock_handle (void * handle)
{
  int D.12806;
  <unnamed type> D.12809;
  <unnamed type> D.12811;
  <unnamed type> D.12813;
  <unnamed type> D.12815;
  unsigned int D.12816;
  struct _WapiHandleUnshared * D.12817;
  unsigned int D.12818;
  unsigned int D.12819;
  struct _WapiHandleUnshared * D.12820;
  union mono_mutex_t * D.12821;
  guint32 idx;
  int ret;

  idx = (guint32) handle;
  if (idx > 4194303) goto <D.12804>; else goto <D.12805>;
  <D.12804>:
  D.12806 = 0;
  return D.12806;
  <D.12805>:
  D.12809 = _wapi_handle_type (handle);
  if (D.12809 == 9) goto <D.12807>; else goto <D.12810>;
  <D.12810>:
  D.12811 = _wapi_handle_type (handle);
  if (D.12811 == 11) goto <D.12807>; else goto <D.12812>;
  <D.12812>:
  D.12813 = _wapi_handle_type (handle);
  if (D.12813 == 12) goto <D.12807>; else goto <D.12814>;
  <D.12814>:
  D.12815 = _wapi_handle_type (handle);
  if (D.12815 == 13) goto <D.12807>; else goto <D.12808>;
  <D.12807>:
  _wapi_handle_unref (handle);
  D.12806 = 0;
  return D.12806;
  <D.12808>:
  D.12816 = idx / 256;
  D.12817 = _wapi_private_handles[D.12816];
  D.12818 = idx & 255;
  D.12819 = D.12818 * 144;
  D.12820 = D.12817 + D.12819;
  D.12821 = &D.12820->signal_mutex;
  ret = pthread_mutex_unlock (D.12821);
  _wapi_handle_unref (handle);
  D.12806 = ret;
  return D.12806;
}


FindClose (void * handle)
{
  gboolean D.12825;
  long int D.12828;
  _Bool D.12831;
  long int D.12832;
  long int D.12833;
  struct _WapiHandle_find * find_handle.46;
  gchar * * D.12837;
  gchar * D.12838;
  struct _WapiHandle_find * find_handle;
  gboolean ok;
  int thr_ret;
  static const char __func__[10] = "FindClose";

  try
    {
      if (handle == 0B) goto <D.12823>; else goto <D.12824>;
      <D.12823>:
      SetLastError (6);
      D.12825 = 0;
      return D.12825;
      <D.12824>:
      ok = _wapi_lookup_handle (handle, 8, &find_handle);
      if (ok == 0) goto <D.12826>; else goto <D.12827>;
      <D.12826>:
      monoeg_g_log (0B, 16, "%s: error looking up find handle %p", &__func__, handle);
      SetLastError (6);
      D.12825 = 0;
      return D.12825;
      <D.12827>:
      {
        struct __pthread_unwind_buf_t __cancel_buf;
        void (*<Tc3>) (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.12828 = __builtin_expect (__not_first_call, 0);
            if (D.12828 != 0) goto <D.12829>; else goto <D.12830>;
            <D.12829>:
            __cancel_routine (__cancel_arg);
            __pthread_unwind_next (&__cancel_buf);
            <D.12830>:
            __pthread_register_cancel (&__cancel_buf);
            thr_ret = _wapi_handle_lock_handle (handle);
            D.12831 = thr_ret != 0;
            D.12832 = (long int) D.12831;
            D.12833 = __builtin_expect (D.12832, 0);
            if (D.12833 != 0) goto <D.12834>; else goto <D.12835>;
            <D.12834>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "io.c", 2947, "thr_ret == 0");
            <D.12835>:
            find_handle.46 = find_handle;
            D.12837 = find_handle.46->namelist;
            monoeg_g_strfreev (D.12837);
            find_handle.46 = find_handle;
            D.12838 = find_handle.46->dir_part;
            monoeg_g_free (D.12838);
            thr_ret = _wapi_handle_unlock_handle (handle);
            D.12831 = thr_ret != 0;
            D.12832 = (long int) D.12831;
            D.12833 = __builtin_expect (D.12832, 0);
            if (D.12833 != 0) goto <D.12839>; else goto <D.12840>;
            <D.12839>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "io.c", 2953, "thr_ret == 0");
            <D.12840>:
            __pthread_unregister_cancel (&__cancel_buf);
            if (0 != 0) goto <D.12841>; else goto <D.12842>;
            <D.12841>:
            __cancel_routine (__cancel_arg);
            <D.12842>:
          }
        finally
          {
            __cancel_buf = {CLOBBER};
          }
      }
      _wapi_handle_unref (handle);
      D.12825 = 1;
      return D.12825;
    }
  finally
    {
      find_handle = {CLOBBER};
    }
}


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

  if (name == 0B) goto <D.12848>; else goto <D.12849>;
  <D.12848>:
  SetLastError (123);
  D.12850 = 0;
  return D.12850;
  <D.12849>:
  utf8_name = mono_unicode_to_external (name);
  if (utf8_name == 0B) goto <D.12851>; else goto <D.12852>;
  <D.12851>:
  SetLastError (123);
  D.12850 = 0;
  return D.12850;
  <D.12852>:
  result = _wapi_mkdir (utf8_name, 511);
  if (result == 0) goto <D.12853>; else goto <D.12854>;
  <D.12853>:
  monoeg_g_free (utf8_name);
  D.12850 = 1;
  return D.12850;
  <D.12854>:
  _wapi_set_last_path_error_from_errno (0B, utf8_name);
  monoeg_g_free (utf8_name);
  D.12850 = 0;
  return D.12850;
}


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

  if (name == 0B) goto <D.12856>; else goto <D.12857>;
  <D.12856>:
  SetLastError (123);
  D.12858 = 0;
  return D.12858;
  <D.12857>:
  utf8_name = mono_unicode_to_external (name);
  if (utf8_name == 0B) goto <D.12859>; else goto <D.12860>;
  <D.12859>:
  SetLastError (123);
  D.12858 = 0;
  return D.12858;
  <D.12860>:
  result = _wapi_rmdir (utf8_name);
  if (result == -1) goto <D.12861>; else goto <D.12862>;
  <D.12861>:
  _wapi_set_last_path_error_from_errno (0B, utf8_name);
  monoeg_g_free (utf8_name);
  D.12858 = 0;
  return D.12858;
  <D.12862>:
  monoeg_g_free (utf8_name);
  D.12858 = 1;
  return D.12858;
}


GetFileAttributes (const gunichar2 * name)
{
  guint32 D.12866;
  int * D.12871;
  int D.12872;
  gchar * utf8_name;
  struct stat buf;
  struct stat linkbuf;
  int result;
  guint32 ret;

  try
    {
      if (name == 0B) goto <D.12864>; else goto <D.12865>;
      <D.12864>:
      SetLastError (123);
      D.12866 = 0;
      return D.12866;
      <D.12865>:
      utf8_name = mono_unicode_to_external (name);
      if (utf8_name == 0B) goto <D.12867>; else goto <D.12868>;
      <D.12867>:
      SetLastError (87);
      D.12866 = 4294967295;
      return D.12866;
      <D.12868>:
      result = _wapi_stat (utf8_name, &buf);
      if (result == -1) goto <D.12869>; else goto <D.12870>;
      <D.12869>:
      D.12871 = __errno_location ();
      D.12872 = *D.12871;
      if (D.12872 == 2) goto <D.12873>; else goto <D.12874>;
      <D.12873>:
      result = _wapi_lstat (utf8_name, &buf);
      <D.12874>:
      <D.12870>:
      if (result != 0) goto <D.12875>; else goto <D.12876>;
      <D.12875>:
      _wapi_set_last_path_error_from_errno (0B, utf8_name);
      monoeg_g_free (utf8_name);
      D.12866 = 4294967295;
      return D.12866;
      <D.12876>:
      result = _wapi_lstat (utf8_name, &linkbuf);
      if (result != 0) goto <D.12877>; else goto <D.12878>;
      <D.12877>:
      _wapi_set_last_path_error_from_errno (0B, utf8_name);
      monoeg_g_free (utf8_name);
      D.12866 = 4294967295;
      return D.12866;
      <D.12878>:
      ret = _wapi_stat_to_file_attributes (utf8_name, &buf, &linkbuf);
      monoeg_g_free (utf8_name);
      D.12866 = ret;
      return D.12866;
    }
  finally
    {
      buf = {CLOBBER};
      linkbuf = {CLOBBER};
    }
}


GetFileAttributesEx (const gunichar2 * name, WapiGetFileExInfoLevels level, void * info)
{
  gboolean D.12883;
  int * D.12890;
  int D.12891;
  long int D.12898;
  long int D.12899;
  unsigned int D.12903;
  struct WapiFileTime * D.12904;
  long int D.12905;
  struct WapiFileTime * D.12906;
  struct WapiFileTime * D.12907;
  unsigned int D.12908;
  unsigned int D.12909;
  long long int D.12913;
  long long int D.12914;
  unsigned int D.12915;
  unsigned int D.12916;
  gchar * utf8_name;
  struct WapiFileAttributesData * data;
  struct stat buf;
  struct stat linkbuf;
  time_t create_time;
  int result;

  try
    {
      if (level != 0) goto <D.12881>; else goto <D.12882>;
      <D.12881>:
      SetLastError (87);
      D.12883 = 0;
      return D.12883;
      <D.12882>:
      if (name == 0B) goto <D.12884>; else goto <D.12885>;
      <D.12884>:
      SetLastError (123);
      D.12883 = 0;
      return D.12883;
      <D.12885>:
      utf8_name = mono_unicode_to_external (name);
      if (utf8_name == 0B) goto <D.12886>; else goto <D.12887>;
      <D.12886>:
      SetLastError (87);
      D.12883 = 0;
      return D.12883;
      <D.12887>:
      result = _wapi_stat (utf8_name, &buf);
      if (result == -1) goto <D.12888>; else goto <D.12889>;
      <D.12888>:
      D.12890 = __errno_location ();
      D.12891 = *D.12890;
      if (D.12891 == 2) goto <D.12892>; else goto <D.12893>;
      <D.12892>:
      result = _wapi_lstat (utf8_name, &buf);
      <D.12893>:
      <D.12889>:
      if (result != 0) goto <D.12894>; else goto <D.12895>;
      <D.12894>:
      _wapi_set_last_path_error_from_errno (0B, utf8_name);
      monoeg_g_free (utf8_name);
      D.12883 = 0;
      return D.12883;
      <D.12895>:
      result = _wapi_lstat (utf8_name, &linkbuf);
      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.12883 = 0;
      return D.12883;
      <D.12897>:
      data = info;
      D.12898 = buf.st_mtim.tv_sec;
      D.12899 = buf.st_ctim.tv_sec;
      if (D.12898 < D.12899) goto <D.12900>; else goto <D.12901>;
      <D.12900>:
      create_time = buf.st_mtim.tv_sec;
      goto <D.12902>;
      <D.12901>:
      create_time = buf.st_ctim.tv_sec;
      <D.12902>:
      D.12903 = _wapi_stat_to_file_attributes (utf8_name, &buf, &linkbuf);
      data->dwFileAttributes = D.12903;
      monoeg_g_free (utf8_name);
      D.12904 = &data->ftCreationTime;
      _wapi_time_t_to_filetime (create_time, D.12904);
      D.12905 = buf.st_atim.tv_sec;
      D.12906 = &data->ftLastAccessTime;
      _wapi_time_t_to_filetime (D.12905, D.12906);
      D.12898 = buf.st_mtim.tv_sec;
      D.12907 = &data->ftLastWriteTime;
      _wapi_time_t_to_filetime (D.12898, D.12907);
      D.12908 = data->dwFileAttributes;
      D.12909 = D.12908 & 16;
      if (D.12909 != 0) goto <D.12910>; else goto <D.12911>;
      <D.12910>:
      data->nFileSizeHigh = 0;
      data->nFileSizeLow = 0;
      goto <D.12912>;
      <D.12911>:
      D.12913 = buf.st_size;
      D.12914 = D.12913 >> 32;
      D.12915 = (unsigned int) D.12914;
      data->nFileSizeHigh = D.12915;
      D.12913 = buf.st_size;
      D.12916 = (unsigned int) D.12913;
      data->nFileSizeLow = D.12916;
      <D.12912>:
      D.12883 = 1;
      return D.12883;
    }
  finally
    {
      buf = {CLOBBER};
      linkbuf = {CLOBBER};
    }
}


SetFileAttributes (const gunichar2 * name, guint32 attrs)
{
  gboolean D.12921;
  int * D.12926;
  int D.12927;
  unsigned int D.12932;
  unsigned int D.12935;
  unsigned int D.12936;
  unsigned int D.12938;
  signed int attrs.47;
  unsigned int D.12942;
  unsigned int D.12945;
  unsigned int D.12948;
  unsigned int D.12951;
  gchar * utf8_name;
  struct stat buf;
  int result;

  try
    {
      if (name == 0B) goto <D.12919>; else goto <D.12920>;
      <D.12919>:
      SetLastError (123);
      D.12921 = 0;
      return D.12921;
      <D.12920>:
      utf8_name = mono_unicode_to_external (name);
      if (utf8_name == 0B) goto <D.12922>; else goto <D.12923>;
      <D.12922>:
      SetLastError (123);
      D.12921 = 0;
      return D.12921;
      <D.12923>:
      result = _wapi_stat (utf8_name, &buf);
      if (result == -1) goto <D.12924>; else goto <D.12925>;
      <D.12924>:
      D.12926 = __errno_location ();
      D.12927 = *D.12926;
      if (D.12927 == 2) goto <D.12928>; else goto <D.12929>;
      <D.12928>:
      result = _wapi_lstat (utf8_name, &buf);
      <D.12929>:
      <D.12925>:
      if (result != 0) goto <D.12930>; else goto <D.12931>;
      <D.12930>:
      _wapi_set_last_path_error_from_errno (0B, utf8_name);
      monoeg_g_free (utf8_name);
      D.12921 = 0;
      return D.12921;
      <D.12931>:
      D.12932 = attrs & 1;
      if (D.12932 != 0) goto <D.12933>; else goto <D.12934>;
      <D.12933>:
      D.12935 = buf.st_mode;
      D.12936 = D.12935 & 4294967149;
      result = _wapi_chmod (utf8_name, D.12936);
      goto <D.12937>;
      <D.12934>:
      D.12935 = buf.st_mode;
      D.12938 = D.12935 | 128;
      result = _wapi_chmod (utf8_name, D.12938);
      <D.12937>:
      attrs.47 = (signed int) attrs;
      if (attrs.47 < 0) goto <D.12940>; else goto <D.12941>;
      <D.12940>:
      {
        mode_t exec_mask;

        exec_mask = 0;
        D.12935 = buf.st_mode;
        D.12942 = D.12935 & 256;
        if (D.12942 != 0) goto <D.12943>; else goto <D.12944>;
        <D.12943>:
        exec_mask = exec_mask | 64;
        <D.12944>:
        D.12935 = buf.st_mode;
        D.12945 = D.12935 & 32;
        if (D.12945 != 0) goto <D.12946>; else goto <D.12947>;
        <D.12946>:
        exec_mask = exec_mask | 8;
        <D.12947>:
        D.12935 = buf.st_mode;
        D.12948 = D.12935 & 4;
        if (D.12948 != 0) goto <D.12949>; else goto <D.12950>;
        <D.12949>:
        exec_mask = exec_mask | 1;
        <D.12950>:
        D.12935 = buf.st_mode;
        D.12951 = D.12935 | exec_mask;
        result = chmod (utf8_name, D.12951);
      }
      <D.12941>:
      monoeg_g_free (utf8_name);
      D.12921 = 1;
      return D.12921;
    }
  finally
    {
      buf = {CLOBBER};
    }
}


GetCurrentDirectory (guint32 length, gunichar2 * buffer)
{
  char * D.12954;
  int * D.12957;
  int D.12958;
  guint32 D.12963;
  unsigned int bytes.48;
  unsigned int D.12965;
  unsigned int D.12966;
  long unsigned int count.49;
  _Bool D.12968;
  long int D.12969;
  long int D.12970;
  unsigned int D.12973;
  gunichar2 * utf16_path;
  glong count;
  gsize bytes;

  try
    {
      D.12954 = getcwd (buffer, length);
      if (D.12954 == 0B) goto <D.12955>; else goto <D.12956>;
      <D.12955>:
      D.12957 = __errno_location ();
      D.12958 = *D.12957;
      if (D.12958 == 34) goto <D.12959>; else goto <D.12960>;
      <D.12959>:
      {
        gchar * path;

        path = monoeg_g_get_current_dir ();
        if (path == 0B) goto <D.12961>; else goto <D.12962>;
        <D.12961>:
        D.12963 = 0;
        return D.12963;
        <D.12962>:
        utf16_path = mono_unicode_from_external (path, &bytes);
        monoeg_g_free (utf16_path);
        monoeg_g_free (path);
        bytes.48 = bytes;
        D.12965 = bytes.48 / 2;
        D.12963 = D.12965 + 1;
        return D.12963;
      }
      <D.12960>:
      _wapi_set_last_error_from_errno ();
      D.12963 = 0;
      return D.12963;
      <D.12956>:
      utf16_path = mono_unicode_from_external (buffer, &bytes);
      bytes.48 = bytes;
      D.12965 = bytes.48 / 2;
      D.12966 = D.12965 + 1;
      count = (glong) D.12966;
      count.49 = (long unsigned int) count;
      D.12968 = count.49 > length;
      D.12969 = (long int) D.12968;
      D.12970 = __builtin_expect (D.12969, 0);
      if (D.12970 != 0) goto <D.12971>; else goto <D.12972>;
      <D.12971>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "io.c", 3320, "count <= length");
      <D.12972>:
      bytes.48 = bytes;
      D.12973 = bytes.48 + 2;
      memset (buffer, 0, D.12973);
      bytes.48 = bytes;
      memcpy (buffer, utf16_path, bytes.48);
      monoeg_g_free (utf16_path);
      D.12963 = (guint32) count;
      return D.12963;
    }
  finally
    {
      bytes = {CLOBBER};
    }
}


getcwd (char * __buf, size_t __size)
{
  unsigned int D.12976;
  int D.12979;
  char * D.12982;
  unsigned int D.12983;
  unsigned int D.12984;
  unsigned int D.12987;

  D.12976 = __builtin_object_size (__buf, 1);
  if (D.12976 != 4294967295) goto <D.12977>; else goto <D.12978>;
  <D.12977>:
  D.12979 = __builtin_constant_p (__size);
  if (D.12979 == 0) goto <D.12980>; else goto <D.12981>;
  <D.12980>:
  D.12983 = __builtin_object_size (__buf, 1);
  D.12982 = __getcwd_chk (__buf, __size, D.12983);
  return D.12982;
  <D.12981>:
  D.12984 = __builtin_object_size (__buf, 1);
  if (D.12984 < __size) goto <D.12985>; else goto <D.12986>;
  <D.12985>:
  D.12987 = __builtin_object_size (__buf, 1);
  D.12982 = __getcwd_chk_warn (__buf, __size, D.12987);
  return D.12982;
  <D.12986>:
  <D.12978>:
  D.12982 = __getcwd_alias (__buf, __size);
  return D.12982;
}


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

  if (path == 0B) goto <D.12989>; else goto <D.12990>;
  <D.12989>:
  SetLastError (87);
  D.12991 = 0;
  return D.12991;
  <D.12990>:
  utf8_path = mono_unicode_to_external (path);
  D.12992 = _wapi_chdir (utf8_path);
  if (D.12992 != 0) goto <D.12993>; else goto <D.12994>;
  <D.12993>:
  _wapi_set_last_error_from_errno ();
  result = 0;
  goto <D.12995>;
  <D.12994>:
  result = 1;
  <D.12995>:
  monoeg_g_free (utf8_path);
  D.12991 = result;
  return D.12991;
}


CreatePipe (void * * readpipe, void * * writepipe, struct WapiSecurityAttributes * security, guint32 size)
{
  gboolean D.12999;
  int D.13002;
  unsigned int D.13003;
  unsigned int _wapi_fd_reserve.50;
  int D.13006;
  unsigned int D.13007;
  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.12997>; else goto <D.12998>;
      <D.12997>:
      _wapi_set_last_error_from_errno ();
      D.12999 = 0;
      return D.12999;
      <D.12998>:
      D.13002 = filedes[0];
      D.13003 = (unsigned int) D.13002;
      _wapi_fd_reserve.50 = _wapi_fd_reserve;
      if (D.13003 >= _wapi_fd_reserve.50) goto <D.13000>; else goto <D.13005>;
      <D.13005>:
      D.13006 = filedes[1];
      D.13007 = (unsigned int) D.13006;
      _wapi_fd_reserve.50 = _wapi_fd_reserve;
      if (D.13007 >= _wapi_fd_reserve.50) goto <D.13000>; else goto <D.13001>;
      <D.13000>:
      SetLastError (4);
      D.13002 = filedes[0];
      close (D.13002);
      D.13006 = filedes[1];
      close (D.13006);
      D.12999 = 0;
      return D.12999;
      <D.13001>:
      D.13002 = filedes[0];
      pipe_read_handle.fd = D.13002;
      pipe_read_handle.fileaccess = 2147483648;
      D.13002 = filedes[0];
      read_handle = _wapi_handle_new_fd (10, D.13002, &pipe_read_handle);
      if (read_handle == 4294967295B) goto <D.13008>; else goto <D.13009>;
      <D.13008>:
      monoeg_g_log (0B, 16, "%s: error creating pipe read handle", &__func__);
      D.13002 = filedes[0];
      close (D.13002);
      D.13006 = filedes[1];
      close (D.13006);
      SetLastError (31);
      D.12999 = 0;
      return D.12999;
      <D.13009>:
      D.13006 = filedes[1];
      pipe_write_handle.fd = D.13006;
      pipe_write_handle.fileaccess = 1073741824;
      D.13006 = filedes[1];
      write_handle = _wapi_handle_new_fd (10, D.13006, &pipe_write_handle);
      if (write_handle == 4294967295B) goto <D.13010>; else goto <D.13011>;
      <D.13010>:
      monoeg_g_log (0B, 16, "%s: error creating pipe write handle", &__func__);
      _wapi_handle_unref (read_handle);
      D.13002 = filedes[0];
      close (D.13002);
      D.13006 = filedes[1];
      close (D.13006);
      SetLastError (31);
      D.12999 = 0;
      return D.12999;
      <D.13011>:
      *readpipe = read_handle;
      *writepipe = write_handle;
      D.12999 = 1;
      return D.12999;
    }
  finally
    {
      pipe_read_handle = {CLOBBER};
      pipe_write_handle = {CLOBBER};
      filedes = {CLOBBER};
    }
}


GetTempPath (guint32 len, gunichar2 * buf)
{
  const gchar * D.13014;
  unsigned int D.13015;
  gchar * D.13016;
  char D.13017;
  const gchar * D.13020;
  guint32 D.13023;
  unsigned int bytes.51;
  unsigned int D.13025;
  long int D.13026;
  long unsigned int D.13027;
  unsigned int D.13031;
  gchar * tmpdir;
  gunichar2 * tmpdir16;
  glong dirlen;
  gsize bytes;
  guint32 ret;

  try
    {
      D.13014 = monoeg_g_get_tmp_dir ();
      tmpdir = monoeg_strdup (D.13014);
      tmpdir16 = 0B;
      D.13015 = strlen (tmpdir);
      D.13016 = tmpdir + D.13015;
      D.13017 = *D.13016;
      if (D.13017 != 47) goto <D.13018>; else goto <D.13019>;
      <D.13018>:
      monoeg_g_free (tmpdir);
      D.13020 = monoeg_g_get_tmp_dir ();
      tmpdir = monoeg_g_strdup_printf ("%s/", D.13020);
      <D.13019>:
      tmpdir16 = mono_unicode_from_external (tmpdir, &bytes);
      if (tmpdir16 == 0B) goto <D.13021>; else goto <D.13022>;
      <D.13021>:
      monoeg_g_free (tmpdir);
      D.13023 = 0;
      return D.13023;
      <D.13022>:
      bytes.51 = bytes;
      D.13025 = bytes.51 / 2;
      dirlen = (glong) D.13025;
      D.13026 = dirlen + 1;
      D.13027 = (long unsigned int) D.13026;
      if (D.13027 > len) goto <D.13028>; else goto <D.13029>;
      <D.13028>:
      D.13026 = dirlen + 1;
      ret = (guint32) D.13026;
      goto <D.13030>;
      <D.13029>:
      bytes.51 = bytes;
      D.13031 = bytes.51 + 2;
      memset (buf, 0, D.13031);
      bytes.51 = bytes;
      memcpy (buf, tmpdir16, bytes.51);
      ret = (guint32) dirlen;
      <D.13030>:
      if (tmpdir16 != 0B) goto <D.13032>; else goto <D.13033>;
      <D.13032>:
      monoeg_g_free (tmpdir16);
      <D.13033>:
      monoeg_g_free (tmpdir);
      D.13023 = ret;
      return D.13023;
    }
  finally
    {
      bytes = {CLOBBER};
    }
}


GetLogicalDriveStrings (guint32 len, gunichar2 * buf)
{
  unsigned int D.13036;
  unsigned int D.13044;
  char D.13045;
  unsigned int D.13048;
  gchar * D.13049;
  int D.13054;
  int D.13055;
  int D.13056;
  gint32 D.13059;
  int fd;
  gint32 ret;
  struct LinuxMountInfoParseState state;
  gboolean (*<T1c63>) (guint32, gunichar2 *, struct LinuxMountInfoParseState *) parser;
  void done_and_out = <<< error >>>;

  try
    {
      ret = 0;
      parser = 0B;
      D.13036 = len * 2;
      memset (buf, 0, D.13036);
      fd = open ("/proc/self/mountinfo", 0);
      if (fd != -1) goto <D.13037>; else goto <D.13038>;
      <D.13037>:
      parser = GetLogicalDriveStrings_MountInfo;
      goto <D.13039>;
      <D.13038>:
      fd = open ("/proc/mounts", 0);
      if (fd != -1) goto <D.13040>; else goto <D.13041>;
      <D.13040>:
      parser = GetLogicalDriveStrings_Mounts;
      <D.13041>:
      <D.13039>:
      if (parser == 0B) goto <D.13042>; else goto <D.13043>;
      <D.13042>:
      ret = GetLogicalDriveStrings_Mtab (len, buf);
      goto done_and_out;
      <D.13043>:
      memset (&state, 0, 1204);
      state.field_number = 1;
      state.delimiter = 32;
      goto <D.11570>;
      <D.11569>:
      state.buffer_index = 0;
      goto <D.11567>;
      <D.11566>:
      D.13044 = state.buffer_index;
      D.13045 = state.buffer[D.13044];
      if (D.13045 == 10) goto <D.13046>; else goto <D.13047>;
      <D.13046>:
      {
        gboolean quit;

        quit = add_drive_string (len, buf, &state);
        state.field_number = 1;
        D.13044 = state.buffer_index;
        D.13048 = D.13044 + 1;
        state.buffer_index = D.13048;
        D.13049 = state.mountpoint_allocated;
        if (D.13049 != 0B) goto <D.13050>; else goto <D.13051>;
        <D.13050>:
        D.13049 = state.mountpoint_allocated;
        monoeg_g_free (D.13049);
        state.mountpoint_allocated = 0B;
        <D.13051>:
        if (quit != 0) goto <D.13052>; else goto <D.13053>;
        <D.13052>:
        ret = state.total;
        goto done_and_out;
        <D.13053>:
      }
      <D.13047>:
      <D.11567>:
      D.13054 = parser (len, buf, &state);
      if (D.13054 != 0) goto <D.11566>; else goto <D.11568>;
      <D.11568>:
      <D.11570>:
      D.13055 = read (fd, &state.buffer, 512);
      state.nbytes = D.13055;
      D.13056 = state.nbytes;
      if (D.13056 > 0) goto <D.11569>; else goto <D.11571>;
      <D.11571>:
      ret = state.total;
      done_and_out:
      if (fd != -1) goto <D.13057>; else goto <D.13058>;
      <D.13057>:
      close (fd);
      <D.13058>:
      D.13059 = ret;
      return D.13059;
    }
  finally
    {
      state = {CLOBBER};
    }
}


GetLogicalDriveStrings_Mounts (guint32 len, gunichar2 * buf, struct LinuxMountInfoParseState * state)
{
  unsigned int D.13062;
  unsigned int D.13065;
  char D.13066;
  char D.13067;
  unsigned int D.13070;
  gchar * D.13071;
  unsigned int D.13074;
  gchar * D.13075;
  gchar * D.13077;
  unsigned int D.13078;
  int ptr.52;
  gchar[512] * D.13082;
  int D.13083;
  int D.13084;
  int D.13085;
  unsigned int D.13086;
  int D.13088;
  unsigned int D.13089;
  gboolean D.13090;
  unsigned int D.13091;
  int D.13094;
  unsigned int D.13097;
  unsigned int D.13102;
  unsigned int D.13103;
  unsigned int D.13106;
  unsigned int D.13107;
  unsigned int D.13108;
  unsigned int D.13111;
  unsigned int D.13112;
  gchar * ptr;

  D.13062 = state->field_number;
  if (D.13062 == 1) goto <D.13063>; else goto <D.13064>;
  <D.13063>:
  state->check_mount_source = 1;
  <D.13064>:
  goto <D.11582>;
  <D.11587>:
  D.13065 = state->buffer_index;
  D.13066 = state->buffer[D.13065];
  D.13067 = state->delimiter;
  if (D.13066 == D.13067) goto <D.13068>; else goto <D.13069>;
  <D.13068>:
  D.13062 = state->field_number;
  D.13070 = D.13062 + 1;
  state->field_number = D.13070;
  D.13062 = state->field_number;
  switch (D.13062) <default: <D.11581>, case 2: <D.11578>, case 3: <D.11580>>
  <D.11578>:
  state->mountpoint_index = 0;
  goto <D.11579>;
  <D.11580>:
  D.13071 = state->mountpoint_allocated;
  if (D.13071 != 0B) goto <D.13072>; else goto <D.13073>;
  <D.13072>:
  D.13071 = state->mountpoint_allocated;
  D.13074 = state->mountpoint_index;
  D.13075 = D.13071 + D.13074;
  *D.13075 = 0;
  goto <D.13076>;
  <D.13073>:
  D.13074 = state->mountpoint_index;
  state->mountpoint[D.13074] = 0;
  <D.13076>:
  goto <D.11579>;
  <D.11581>:
  D.13065 = state->buffer_index;
  D.13077 = &state->buffer[D.13065];
  D.13065 = state->buffer_index;
  D.13078 = 512 - D.13065;
  ptr = memchr (D.13077, 10, D.13078);
  if (ptr != 0B) goto <D.13079>; else goto <D.13080>;
  <D.13079>:
  ptr.52 = (int) ptr;
  D.13082 = &state->buffer;
  D.13083 = (int) D.13082;
  D.13084 = ptr.52 - D.13083;
  D.13085 = D.13084 + -1;
  D.13086 = (unsigned int) D.13085;
  state->buffer_index = D.13086;
  goto <D.13087>;
  <D.13080>:
  D.13088 = state->nbytes;
  D.13089 = (unsigned int) D.13088;
  state->buffer_index = D.13089;
  <D.13087>:
  D.13090 = 1;
  return D.13090;
  <D.11579>:
  D.13065 = state->buffer_index;
  D.13091 = D.13065 + 1;
  state->buffer_index = D.13091;
  // predicted unlikely by continue predictor.
  goto <D.11582>;
  <D.13069>:
  D.13065 = state->buffer_index;
  D.13066 = state->buffer[D.13065];
  if (D.13066 == 10) goto <D.13092>; else goto <D.13093>;
  <D.13092>:
  D.13090 = 1;
  return D.13090;
  <D.13093>:
  D.13062 = state->field_number;
  switch (D.13062) <default: <D.13113>, case 1: <D.11583>, case 2: <D.11585>, case 3: <D.11586>>
  <D.11583>:
  D.13094 = state->check_mount_source;
  if (D.13094 != 0) goto <D.13095>; else goto <D.13096>;
  <D.13095>:
  D.13097 = state->fsname_index;
  if (D.13097 == 0) goto <D.13098>; else goto <D.13099>;
  <D.13098>:
  D.13065 = state->buffer_index;
  D.13066 = state->buffer[D.13065];
  if (D.13066 == 47) goto <D.13100>; else goto <D.13101>;
  <D.13100>:
  state->check_mount_source = 0;
  D.13097 = state->fsname_index;
  D.13102 = D.13097;
  D.13103 = D.13102 + 1;
  state->fsname_index = D.13103;
  state->fsname[D.13102] = 47;
  goto <D.11584>;
  <D.13101>:
  <D.13099>:
  D.13097 = state->fsname_index;
  if (D.13097 <= 63) goto <D.13104>; else goto <D.13105>;
  <D.13104>:
  D.13097 = state->fsname_index;
  D.13106 = D.13097;
  D.13107 = D.13106 + 1;
  state->fsname_index = D.13107;
  D.13065 = state->buffer_index;
  D.13066 = state->buffer[D.13065];
  state->fsname[D.13106] = D.13066;
  <D.13105>:
  <D.13096>:
  goto <D.11584>;
  <D.11585>:
  append_to_mountpoint (state);
  goto <D.11584>;
  <D.11586>:
  D.13108 = state->fstype_index;
  if (D.13108 <= 63) goto <D.13109>; else goto <D.13110>;
  <D.13109>:
  D.13108 = state->fstype_index;
  D.13111 = D.13108;
  D.13112 = D.13111 + 1;
  state->fstype_index = D.13112;
  D.13065 = state->buffer_index;
  D.13066 = state->buffer[D.13065];
  state->fstype[D.13111] = D.13066;
  <D.13110>:
  goto <D.11584>;
  <D.13113>:
  <D.11584>:
  D.13065 = state->buffer_index;
  D.13091 = D.13065 + 1;
  state->buffer_index = D.13091;
  <D.11582>:
  D.13065 = state->buffer_index;
  D.13088 = state->nbytes;
  D.13089 = (unsigned int) D.13088;
  if (D.13065 < D.13089) goto <D.11587>; else goto <D.11588>;
  <D.11588>:
  D.13090 = 0;
  return D.13090;
}


append_to_mountpoint (struct LinuxMountInfoParseState * state)
{
  unsigned int D.13115;
  gchar * D.13116;
  unsigned int D.13119;
  unsigned int D.13120;
  unsigned int D.13123;
  unsigned int D.13124;
  unsigned int D.13125;
  gchar * D.13126;
  unsigned int D.13130;
  unsigned int D.13131;
  void * D.13132;
  gchar[513] * D.13133;
  unsigned int D.13134;
  unsigned int D.13135;
  gchar * D.13136;
  unsigned int D.13138;
  unsigned int D.13139;
  gchar ch;

  D.13115 = state->buffer_index;
  ch = state->buffer[D.13115];
  D.13116 = state->mountpoint_allocated;
  if (D.13116 != 0B) goto <D.13117>; else goto <D.13118>;
  <D.13117>:
  D.13119 = state->mountpoint_index;
  D.13120 = state->allocated_size;
  if (D.13119 >= D.13120) goto <D.13121>; else goto <D.13122>;
  <D.13121>:
  {
    guint32 newsize;
    gchar * newbuf;

    D.13120 = state->allocated_size;
    D.13123 = D.13120 << 1;
    newsize = D.13123 + 1;
    newbuf = monoeg_malloc0 (newsize);
    D.13116 = state->mountpoint_allocated;
    D.13119 = state->mountpoint_index;
    memcpy (newbuf, D.13116, D.13119);
    D.13116 = state->mountpoint_allocated;
    monoeg_g_free (D.13116);
    state->mountpoint_allocated = newbuf;
    state->allocated_size = newsize;
  }
  <D.13122>:
  D.13116 = state->mountpoint_allocated;
  D.13119 = state->mountpoint_index;
  D.13124 = D.13119;
  D.13125 = D.13124 + 1;
  state->mountpoint_index = D.13125;
  D.13126 = D.13116 + D.13124;
  *D.13126 = ch;
  goto <D.13127>;
  <D.13118>:
  D.13119 = state->mountpoint_index;
  if (D.13119 > 511) goto <D.13128>; else goto <D.13129>;
  <D.13128>:
  D.13119 = state->mountpoint_index;
  D.13130 = D.13119 << 1;
  D.13131 = D.13130 + 1;
  state->allocated_size = D.13131;
  D.13120 = state->allocated_size;
  D.13132 = monoeg_malloc0 (D.13120);
  state->mountpoint_allocated = D.13132;
  D.13116 = state->mountpoint_allocated;
  D.13133 = &state->mountpoint;
  D.13119 = state->mountpoint_index;
  memcpy (D.13116, D.13133, D.13119);
  D.13116 = state->mountpoint_allocated;
  D.13119 = state->mountpoint_index;
  D.13134 = D.13119;
  D.13135 = D.13134 + 1;
  state->mountpoint_index = D.13135;
  D.13136 = D.13116 + D.13134;
  *D.13136 = ch;
  goto <D.13137>;
  <D.13129>:
  D.13119 = state->mountpoint_index;
  D.13138 = D.13119;
  D.13139 = D.13138 + 1;
  state->mountpoint_index = D.13139;
  state->mountpoint[D.13138] = ch;
  <D.13137>:
  <D.13127>:
}


GetLogicalDriveStrings_MountInfo (guint32 len, gunichar2 * buf, struct LinuxMountInfoParseState * state)
{
  unsigned int D.13140;
  char D.13141;
  char D.13142;
  unsigned int D.13145;
  unsigned int D.13146;
  gchar * D.13147;
  unsigned int D.13150;
  gchar * D.13151;
  unsigned int D.13154;
  gboolean D.13157;
  unsigned int D.13158;
  unsigned int D.13161;
  unsigned int D.13162;
  int D.13163;
  unsigned int D.13166;
  unsigned int D.13171;
  unsigned int D.13172;
  unsigned int D.13175;
  unsigned int D.13176;
  int D.13178;
  unsigned int D.13179;

  goto <D.11600>;
  <D.11605>:
  D.13140 = state->buffer_index;
  D.13141 = state->buffer[D.13140];
  D.13142 = state->delimiter;
  if (D.13141 == D.13142) goto <D.13143>; else goto <D.13144>;
  <D.13143>:
  D.13145 = state->field_number;
  D.13146 = D.13145 + 1;
  state->field_number = D.13146;
  D.13145 = state->field_number;
  switch (D.13145) <default: <D.13153>, case 5: <D.11594>, case 6: <D.11596>, case 7: <D.11597>, case 8: <D.11598>, case 10: <D.11599>>
  <D.11594>:
  state->mountpoint_index = 0;
  goto <D.11595>;
  <D.11596>:
  D.13147 = state->mountpoint_allocated;
  if (D.13147 != 0B) goto <D.13148>; else goto <D.13149>;
  <D.13148>:
  D.13147 = state->mountpoint_allocated;
  D.13150 = state->mountpoint_index;
  D.13151 = D.13147 + D.13150;
  *D.13151 = 0;
  goto <D.13152>;
  <D.13149>:
  D.13150 = state->mountpoint_index;
  state->mountpoint[D.13150] = 0;
  <D.13152>:
  goto <D.11595>;
  <D.11597>:
  state->delimiter = 45;
  goto <D.11595>;
  <D.11598>:
  state->delimiter = 32;
  goto <D.11595>;
  <D.11599>:
  state->check_mount_source = 1;
  goto <D.11595>;
  <D.13153>:
  <D.11595>:
  D.13140 = state->buffer_index;
  D.13154 = D.13140 + 1;
  state->buffer_index = D.13154;
  // predicted unlikely by continue predictor.
  goto <D.11600>;
  <D.13144>:
  D.13140 = state->buffer_index;
  D.13141 = state->buffer[D.13140];
  if (D.13141 == 10) goto <D.13155>; else goto <D.13156>;
  <D.13155>:
  D.13157 = 1;
  return D.13157;
  <D.13156>:
  D.13145 = state->field_number;
  switch (D.13145) <default: <D.13177>, case 5: <D.11601>, case 9: <D.11603>, case 10: <D.11604>>
  <D.11601>:
  append_to_mountpoint (state);
  goto <D.11602>;
  <D.11603>:
  D.13158 = state->fstype_index;
  if (D.13158 <= 63) goto <D.13159>; else goto <D.13160>;
  <D.13159>:
  D.13158 = state->fstype_index;
  D.13161 = D.13158;
  D.13162 = D.13161 + 1;
  state->fstype_index = D.13162;
  D.13140 = state->buffer_index;
  D.13141 = state->buffer[D.13140];
  state->fstype[D.13161] = D.13141;
  <D.13160>:
  goto <D.11602>;
  <D.11604>:
  D.13163 = state->check_mount_source;
  if (D.13163 != 0) goto <D.13164>; else goto <D.13165>;
  <D.13164>:
  D.13166 = state->fsname_index;
  if (D.13166 == 0) goto <D.13167>; else goto <D.13168>;
  <D.13167>:
  D.13140 = state->buffer_index;
  D.13141 = state->buffer[D.13140];
  if (D.13141 == 47) goto <D.13169>; else goto <D.13170>;
  <D.13169>:
  state->check_mount_source = 0;
  D.13166 = state->fsname_index;
  D.13171 = D.13166;
  D.13172 = D.13171 + 1;
  state->fsname_index = D.13172;
  state->fsname[D.13171] = 47;
  goto <D.11602>;
  <D.13170>:
  <D.13168>:
  D.13166 = state->fsname_index;
  if (D.13166 <= 63) goto <D.13173>; else goto <D.13174>;
  <D.13173>:
  D.13166 = state->fsname_index;
  D.13175 = D.13166;
  D.13176 = D.13175 + 1;
  state->fsname_index = D.13176;
  D.13140 = state->buffer_index;
  D.13141 = state->buffer[D.13140];
  state->fsname[D.13175] = D.13141;
  <D.13174>:
  <D.13165>:
  goto <D.11602>;
  <D.13177>:
  <D.11602>:
  D.13140 = state->buffer_index;
  D.13154 = D.13140 + 1;
  state->buffer_index = D.13154;
  <D.11600>:
  D.13140 = state->buffer_index;
  D.13178 = state->nbytes;
  D.13179 = (unsigned int) D.13178;
  if (D.13140 < D.13179) goto <D.11605>; else goto <D.11606>;
  <D.11606>:
  D.13157 = 0;
  return D.13157;
}


open (const char * __path, int __oflag)
{
  int D.13181;
  int D.13184;
  int D.13189;
  int D.13191;
  int D.13192;
  int D.13195;
  int D.13196;

  D.13181 = __builtin_va_arg_pack_len ();
  if (D.13181 > 1) goto <D.13182>; else goto <D.13183>;
  <D.13182>:
  __open_too_many_args ();
  <D.13183>:
  D.13184 = __builtin_constant_p (__oflag);
  if (D.13184 != 0) goto <D.13185>; else goto <D.13186>;
  <D.13185>:
  D.13189 = __oflag & 256;
  if (D.13189 != 0) goto <D.13187>; else goto <D.13190>;
  <D.13190>:
  D.13191 = __oflag & 4259840;
  if (D.13191 == 4259840) goto <D.13187>; else goto <D.13188>;
  <D.13187>:
  D.13192 = __builtin_va_arg_pack_len ();
  if (D.13192 <= 0) goto <D.13193>; else goto <D.13194>;
  <D.13193>:
  __open_missing_mode ();
  D.13195 = __open_2 (__path, __oflag);
  return D.13195;
  <D.13194>:
  <D.13188>:
  D.13195 = __open_alias (__path, __oflag, __builtin_va_arg_pack ());
  return D.13195;
  <D.13186>:
  D.13196 = __builtin_va_arg_pack_len ();
  if (D.13196 <= 0) goto <D.13197>; else goto <D.13198>;
  <D.13197>:
  D.13195 = __open_2 (__path, __oflag);
  return D.13195;
  <D.13198>:
  D.13195 = __open_alias (__path, __oflag, __builtin_va_arg_pack ());
  return D.13195;
}


GetLogicalDriveStrings_Mtab (guint32 len, gunichar2 * buf)
{
  unsigned int D.13200;
  unsigned int D.13201;
  gunichar2 * D.13202;
  gunichar2 * D.13203;
  gint32 D.13208;
  char D.13209;
  gchar * D.13214;
  gchar * * D.13216;
  gchar * D.13217;
  long int length.53;
  long int D.13219;
  long int D.13220;
  long unsigned int D.13221;
  unsigned int D.13224;
  unsigned int total.54;
  unsigned int D.13226;
  gunichar2 * D.13227;
  long unsigned int length.55;
  long unsigned int D.13229;
  long int D.13230;
  char * D.13231;
  struct FILE * fp;
  gunichar2 * ptr;
  gunichar2 * dir;
  glong length;
  glong total;
  gchar buffer[512];
  gchar * * splitted;

  try
    {
      total = 0;
      D.13200 = len + 1;
      D.13201 = D.13200 * 2;
      memset (buf, 0, D.13201);
      *buf = 47;
      D.13202 = buf + 2;
      *D.13202 = 0;
      D.13203 = buf + 4;
      *D.13203 = 0;
      fp = fopen ("/etc/mtab", "rt");
      if (fp == 0B) goto <D.13204>; else goto <D.13205>;
      <D.13204>:
      fp = fopen ("/etc/mnttab", "rt");
      if (fp == 0B) goto <D.13206>; else goto <D.13207>;
      <D.13206>:
      D.13208 = 1;
      return D.13208;
      <D.13207>:
      <D.13205>:
      ptr = buf;
      goto <D.11634>;
      <D.11635>:
      D.13209 = buffer[0];
      if (D.13209 != 47) goto <D.13210>; else goto <D.13211>;
      <D.13210>:
      // predicted unlikely by continue predictor.
      goto <D.11634>;
      <D.13211>:
      splitted = monoeg_g_strsplit (&buffer, " ", 0);
      D.13214 = *splitted;
      if (D.13214 == 0B) goto <D.13212>; else goto <D.13215>;
      <D.13215>:
      D.13216 = splitted + 4;
      D.13217 = *D.13216;
      if (D.13217 == 0B) goto <D.13212>; else goto <D.13213>;
      <D.13212>:
      monoeg_g_strfreev (splitted);
      // predicted unlikely by continue predictor.
      goto <D.11634>;
      <D.13213>:
      D.13216 = splitted + 4;
      D.13217 = *D.13216;
      unescape_octal (D.13217);
      D.13216 = splitted + 4;
      D.13217 = *D.13216;
      dir = monoeg_g_utf8_to_utf16 (D.13217, -1, 0B, &length, 0B);
      monoeg_g_strfreev (splitted);
      length.53 = length;
      D.13219 = total + length.53;
      D.13220 = D.13219 + 1;
      D.13221 = (long unsigned int) D.13220;
      if (D.13221 > len) goto <D.13222>; else goto <D.13223>;
      <D.13222>:
      fclose (fp);
      monoeg_g_free (dir);
      D.13224 = len * 2;
      D.13208 = (gint32) D.13224;
      return D.13208;
      <D.13223>:
      total.54 = (unsigned int) total;
      D.13226 = total.54 * 2;
      D.13227 = ptr + D.13226;
      length.53 = length;
      length.55 = (long unsigned int) length.53;
      D.13229 = length.55 * 2;
      memcpy (D.13227, dir, D.13229);
      monoeg_g_free (dir);
      length.53 = length;
      D.13230 = length.53 + 1;
      total = D.13230 + total;
      <D.11634>:
      D.13231 = fgets (&buffer, 512, fp);
      if (D.13231 != 0B) goto <D.11635>; else goto <D.11636>;
      <D.11636>:
      fclose (fp);
      D.13208 = total;
      return D.13208;
    }
  finally
    {
      length = {CLOBBER};
      buffer = {CLOBBER};
    }
}


unescape_octal (gchar * str)
{
  char D.13236;
  gchar * rptr.56;
  char D.13240;
  int D.13241;
  int D.13242;
  int D.13243;
  gchar * rptr.57;
  char D.13245;
  int D.13246;
  int D.13247;
  int D.13248;
  unsigned char D.13249;
  unsigned char c.58;
  unsigned char D.13251;
  gchar * rptr.59;
  char D.13253;
  int D.13254;
  int D.13255;
  unsigned char D.13256;
  unsigned char D.13257;
  gchar * wptr.60;
  gchar * wptr.61;
  gchar * rptr.62;
  char D.13264;
  gchar * rptr;
  gchar * wptr;

  if (str == 0B) goto <D.13234>; else goto <D.13235>;
  <D.13234>:
  return;
  <D.13235>:
  wptr = str;
  rptr = wptr;
  goto <D.11517>;
  <D.11516>:
  D.13236 = *rptr;
  if (D.13236 == 92) goto <D.13237>; else goto <D.13238>;
  <D.13237>:
  {
    char c;

    rptr = rptr + 1;
    rptr.56 = rptr;
    rptr = rptr.56 + 1;
    D.13240 = *rptr.56;
    D.13241 = (int) D.13240;
    D.13242 = D.13241 + -48;
    D.13243 = D.13242 << 6;
    c = (char) D.13243;
    rptr.57 = rptr;
    rptr = rptr.57 + 1;
    D.13245 = *rptr.57;
    D.13246 = (int) D.13245;
    D.13247 = D.13246 + -48;
    D.13248 = D.13247 << 3;
    D.13249 = (unsigned char) D.13248;
    c.58 = (unsigned char) c;
    D.13251 = D.13249 + c.58;
    c = (char) D.13251;
    rptr.59 = rptr;
    rptr = rptr.59 + 1;
    D.13253 = *rptr.59;
    D.13254 = (int) D.13253;
    D.13255 = D.13254 + -48;
    D.13256 = (unsigned char) D.13255;
    c.58 = (unsigned char) c;
    D.13257 = D.13256 + c.58;
    c = (char) D.13257;
    wptr.60 = wptr;
    wptr = wptr.60 + 1;
    *wptr.60 = c;
  }
  goto <D.13259>;
  <D.13238>:
  if (wptr != rptr) goto <D.13260>; else goto <D.13261>;
  <D.13260>:
  wptr.61 = wptr;
  wptr = wptr.61 + 1;
  rptr.62 = rptr;
  rptr = rptr.62 + 1;
  D.13264 = *rptr.62;
  *wptr.61 = D.13264;
  goto <D.13265>;
  <D.13261>:
  rptr = rptr + 1;
  wptr = wptr + 1;
  <D.13265>:
  <D.13259>:
  <D.11517>:
  D.13236 = *rptr;
  if (D.13236 != 0) goto <D.11516>; else goto <D.11518>;
  <D.11518>:
  *wptr = 0;
}


fgets (char * restrict __s, int __n, struct FILE * restrict __stream)
{
  unsigned int D.13267;
  int D.13272;
  char * D.13274;
  unsigned int D.13275;
  unsigned int __n.63;
  unsigned int D.13277;
  unsigned int D.13280;

  D.13267 = __builtin_object_size (__s, 1);
  if (D.13267 != 4294967295) goto <D.13268>; else goto <D.13269>;
  <D.13268>:
  D.13272 = __builtin_constant_p (__n);
  if (D.13272 == 0) goto <D.13270>; else goto <D.13273>;
  <D.13273>:
  if (__n <= 0) goto <D.13270>; else goto <D.13271>;
  <D.13270>:
  D.13275 = __builtin_object_size (__s, 1);
  D.13274 = __fgets_chk (__s, D.13275, __n, __stream);
  return D.13274;
  <D.13271>:
  __n.63 = (unsigned int) __n;
  D.13277 = __builtin_object_size (__s, 1);
  if (__n.63 > D.13277) goto <D.13278>; else goto <D.13279>;
  <D.13278>:
  D.13280 = __builtin_object_size (__s, 1);
  D.13274 = __fgets_chk_warn (__s, D.13280, __n, __stream);
  return D.13274;
  <D.13279>:
  <D.13269>:
  D.13274 = __fgets_alias (__s, __n, __stream);
  return D.13274;
}


add_drive_string (guint32 len, gunichar2 * buf, struct LinuxMountInfoParseState * state)
{
  unsigned int D.13284;
  char D.13286;
  gchar[65] * D.13292;
  int D.13293;
  unsigned int D.13296;
  gchar[65] * D.13298;
  int D.13299;
  int D.13304;
  gchar * iftmp.64;
  gchar * D.13309;
  long int D.13313;
  long int length.65;
  long int D.13315;
  long int D.13316;
  long unsigned int D.13317;
  unsigned int D.13320;
  long int D.13321;
  long int length.66;
  unsigned int D.13324;
  unsigned int D.13325;
  gunichar2 * D.13326;
  long unsigned int length.67;
  long unsigned int D.13328;
  gboolean D.13329;
  gboolean quit;
  gboolean ignore_entry;

  quit = 0;
  D.13284 = state->fsname_index;
  if (D.13284 == 1) goto <D.13285>; else goto <D.13282>;
  <D.13285>:
  D.13286 = state->fsname[0];
  if (D.13286 == 47) goto <D.13287>; else goto <D.13282>;
  <D.13287>:
  ignore_entry = 0;
  goto <D.13283>;
  <D.13282>:
  D.13284 = state->fsname_index;
  if (D.13284 == 0) goto <D.13288>; else goto <D.13291>;
  <D.13291>:
  D.13292 = &state->fsname;
  D.13284 = state->fsname_index;
  D.13293 = memcmp ("none", D.13292, D.13284);
  if (D.13293 == 0) goto <D.13288>; else goto <D.13289>;
  <D.13288>:
  ignore_entry = 1;
  goto <D.13290>;
  <D.13289>:
  D.13296 = state->fstype_index;
  if (D.13296 > 4) goto <D.13297>; else goto <D.13294>;
  <D.13297>:
  D.13298 = &state->fstype;
  D.13299 = memcmp ("fuse.", D.13298, 5);
  if (D.13299 == 0) goto <D.13300>; else goto <D.13294>;
  <D.13300>:
  D.13296 = state->fstype_index;
  if (D.13296 == 21) goto <D.13303>; else goto <D.13301>;
  <D.13303>:
  D.13298 = &state->fstype;
  D.13296 = state->fstype_index;
  D.13304 = memcmp ("fuse.gvfs-fuse-daemon", D.13298, D.13296);
  if (D.13304 == 0) goto <D.13305>; else goto <D.13301>;
  <D.13305>:
  ignore_entry = 1;
  goto <D.13302>;
  <D.13301>:
  ignore_entry = 0;
  <D.13302>:
  goto <D.13295>;
  <D.13294>:
  ignore_entry = 1;
  <D.13295>:
  <D.13290>:
  <D.13283>:
  if (ignore_entry == 0) goto <D.13306>; else goto <D.13307>;
  <D.13306>:
  {
    gunichar2 * dir;
    glong length;
    gchar * mountpoint;

    try
      {
        D.13309 = state->mountpoint_allocated;
        if (D.13309 != 0B) goto <D.13310>; else goto <D.13311>;
        <D.13310>:
        iftmp.64 = state->mountpoint_allocated;
        goto <D.13312>;
        <D.13311>:
        iftmp.64 = &state->mountpoint;
        <D.13312>:
        mountpoint = iftmp.64;
        unescape_octal (mountpoint);
        dir = monoeg_g_utf8_to_utf16 (mountpoint, -1, 0B, &length, 0B);
        D.13313 = state->total;
        length.65 = length;
        D.13315 = D.13313 + length.65;
        D.13316 = D.13315 + 1;
        D.13317 = (long unsigned int) D.13316;
        if (D.13317 > len) goto <D.13318>; else goto <D.13319>;
        <D.13318>:
        quit = 1;
        D.13320 = len * 2;
        D.13321 = (long int) D.13320;
        state->total = D.13321;
        goto <D.13322>;
        <D.13319>:
        length.65 = length;
        length.66 = length.65 + 1;
        length = length.66;
        D.13313 = state->total;
        D.13324 = (unsigned int) D.13313;
        D.13325 = D.13324 * 2;
        D.13326 = buf + D.13325;
        length.65 = length;
        length.67 = (long unsigned int) length.65;
        D.13328 = length.67 * 2;
        memcpy (D.13326, dir, D.13328);
        D.13313 = state->total;
        length.65 = length;
        D.13315 = D.13313 + length.65;
        state->total = D.13315;
        <D.13322>:
        monoeg_g_free (dir);
      }
    finally
      {
        length = {CLOBBER};
      }
  }
  <D.13307>:
  state->fsname_index = 0;
  state->fstype_index = 0;
  D.13329 = quit;
  return D.13329;
}


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.13333;
  gboolean D.13336;
  long unsigned int D.13340;
  long unsigned int D.13341;
  _Bool D.13342;
  int * D.13344;
  int D.13345;
  long long unsigned int D.13353;
  long long unsigned int D.13354;
  long long unsigned int D.13355;
  long long unsigned int D.13358;
  long long unsigned int D.13359;
  long long unsigned int D.13365;
  long long unsigned int D.13366;
  struct statvfs fsstat;
  gboolean isreadonly;
  gchar * utf8_path_name;
  int ret;
  long unsigned int block_size;

  try
    {
      if (path_name == 0B) goto <D.13331>; else goto <D.13332>;
      <D.13331>:
      D.13333 = monoeg_g_get_current_dir ();
      utf8_path_name = monoeg_strdup (D.13333);
      if (utf8_path_name == 0B) goto <D.13334>; else goto <D.13335>;
      <D.13334>:
      SetLastError (267);
      D.13336 = 0;
      return D.13336;
      <D.13335>:
      goto <D.13337>;
      <D.13332>:
      utf8_path_name = mono_unicode_to_external (path_name);
      if (utf8_path_name == 0B) goto <D.13338>; else goto <D.13339>;
      <D.13338>:
      SetLastError (123);
      D.13336 = 0;
      return D.13336;
      <D.13339>:
      <D.13337>:
      <D.11648>:
      ret = statvfs (utf8_path_name, &fsstat);
      D.13340 = fsstat.f_flag;
      D.13341 = D.13340 & 1;
      D.13342 = D.13341 != 0;
      isreadonly = (gboolean) D.13342;
      block_size = fsstat.f_frsize;
      if (ret == -1) goto <D.13343>; else goto <D.11649>;
      <D.13343>:
      D.13344 = __errno_location ();
      D.13345 = *D.13344;
      if (D.13345 == 4) goto <D.11648>; else goto <D.11649>;
      <D.11649>:
      monoeg_g_free (utf8_path_name);
      if (ret == -1) goto <D.13346>; else goto <D.13347>;
      <D.13346>:
      _wapi_set_last_error_from_errno ();
      D.13336 = 0;
      return D.13336;
      <D.13347>:
      if (free_bytes_avail != 0B) goto <D.13348>; else goto <D.13349>;
      <D.13348>:
      if (isreadonly != 0) goto <D.13350>; else goto <D.13351>;
      <D.13350>:
      free_bytes_avail->QuadPart = 0;
      goto <D.13352>;
      <D.13351>:
      D.13353 = (long long unsigned int) block_size;
      D.13354 = fsstat.f_bavail;
      D.13355 = D.13353 * D.13354;
      free_bytes_avail->QuadPart = D.13355;
      <D.13352>:
      <D.13349>:
      if (total_number_of_bytes != 0B) goto <D.13356>; else goto <D.13357>;
      <D.13356>:
      D.13353 = (long long unsigned int) block_size;
      D.13358 = fsstat.f_blocks;
      D.13359 = D.13353 * D.13358;
      total_number_of_bytes->QuadPart = D.13359;
      <D.13357>:
      if (total_number_of_free_bytes != 0B) goto <D.13360>; else goto <D.13361>;
      <D.13360>:
      if (isreadonly != 0) goto <D.13362>; else goto <D.13363>;
      <D.13362>:
      total_number_of_free_bytes->QuadPart = 0;
      goto <D.13364>;
      <D.13363>:
      D.13353 = (long long unsigned int) block_size;
      D.13365 = fsstat.f_bfree;
      D.13366 = D.13353 * D.13365;
      total_number_of_free_bytes->QuadPart = D.13366;
      <D.13364>:
      <D.13361>:
      D.13336 = 1;
      return D.13336;
    }
  finally
    {
      fsstat = {CLOBBER};
    }
}


GetDriveType (const gunichar2 * root_path_name)
{
  gchar * D.13371;
  guint32 D.13374;
  int D.13378;
  gchar * D.13381;
  char D.13382;
  unsigned int D.13385;
  sizetype D.13386;
  gchar * D.13387;
  gchar * utf8_root_path_name;
  guint32 drive_type;

  if (root_path_name == 0B) goto <D.13369>; else goto <D.13370>;
  <D.13369>:
  D.13371 = monoeg_g_get_current_dir ();
  utf8_root_path_name = monoeg_strdup (D.13371);
  if (utf8_root_path_name == 0B) goto <D.13372>; else goto <D.13373>;
  <D.13372>:
  D.13374 = 1;
  return D.13374;
  <D.13373>:
  goto <D.13375>;
  <D.13370>:
  utf8_root_path_name = mono_unicode_to_external (root_path_name);
  if (utf8_root_path_name == 0B) goto <D.13376>; else goto <D.13377>;
  <D.13376>:
  D.13374 = 1;
  return D.13374;
  <D.13377>:
  D.13378 = monoeg_g_str_has_suffix (utf8_root_path_name, "/");
  if (D.13378 != 0) goto <D.13379>; else goto <D.13380>;
  <D.13379>:
  D.13381 = utf8_root_path_name + 1;
  D.13382 = *D.13381;
  if (D.13382 != 0) goto <D.13383>; else goto <D.13384>;
  <D.13383>:
  D.13385 = strlen (utf8_root_path_name);
  D.13386 = D.13385 + 4294967295;
  D.13387 = utf8_root_path_name + D.13386;
  *D.13387 = 0;
  <D.13384>:
  <D.13380>:
  <D.13375>:
  drive_type = GetDriveTypeFromPath (utf8_root_path_name);
  monoeg_g_free (utf8_root_path_name);
  D.13374 = drive_type;
  return D.13374;
}


GetDriveTypeFromPath (const char * utf8_root_path_name)
{
  int D.13389;
  guint32 D.13392;
  long int D.13393;
  struct statfs buf;

  try
    {
      D.13389 = statfs (utf8_root_path_name, &buf);
      if (D.13389 == -1) goto <D.13390>; else goto <D.13391>;
      <D.13390>:
      D.13392 = 0;
      return D.13392;
      <D.13391>:
      D.13393 = buf.f_type;
      D.13392 = _wapi_get_drive_type (D.13393);
      return D.13392;
    }
  finally
    {
      buf = {CLOBBER};
    }
}


_wapi_get_drive_type (long int f_type)
{
  long int D.13396;
  guint32 D.13399;
  unsigned int D.13400;
  struct _wapi_drive_type * current;

  current = &_wapi_drive_types[0];
  goto <D.11661>;
  <D.11660>:
  D.13396 = current->fstypeid;
  if (D.13396 == f_type) goto <D.13397>; else goto <D.13398>;
  <D.13397>:
  D.13399 = current->drive_type;
  return D.13399;
  <D.13398>:
  current = current + 12;
  <D.11661>:
  D.13400 = current->drive_type;
  if (D.13400 != 0) goto <D.11660>; else goto <D.11662>;
  <D.11662>:
  D.13399 = 0;
  return D.13399;
}


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

  try
    {
      status = 0;
      if (fsbuffer == 0B) goto <D.13402>; else goto <D.13403>;
      <D.13402>:
      D.13404 = 0;
      return D.13404;
      <D.13403>:
      utfpath = mono_unicode_to_external (path);
      fstypename = get_fstypename (utfpath);
      if (fstypename != 0B) goto <D.13405>; else goto <D.13406>;
      <D.13405>:
      {
        gunichar2 * ret;

        ret = monoeg_g_utf8_to_utf16 (fstypename, -1, 0B, &len, 0B);
        if (ret != 0B) goto <D.13407>; else goto <D.13408>;
        <D.13407>:
        len.68 = len;
        if (len.68 < fsbuffersize) goto <D.13410>; else goto <D.13411>;
        <D.13410>:
        len.68 = len;
        len.69 = (long unsigned int) len.68;
        D.13413 = len.69 * 2;
        memcpy (fsbuffer, ret, D.13413);
        len.68 = len;
        len.70 = (unsigned int) len.68;
        D.13415 = len.70 * 2;
        D.13416 = fsbuffer + D.13415;
        *D.13416 = 0;
        status = 1;
        <D.13411>:
        <D.13408>:
        if (ret != 0B) goto <D.13417>; else goto <D.13418>;
        <D.13417>:
        monoeg_g_free (ret);
        <D.13418>:
        monoeg_g_free (fstypename);
      }
      <D.13406>:
      monoeg_g_free (utfpath);
      D.13404 = status;
      return D.13404;
    }
  finally
    {
      len = {CLOBBER};
    }
}


get_fstypename (gchar * utfpath)
{
  int D.13421;
  gchar * D.13424;
  long int D.13425;
  long int D.13426;
  const gchar * D.13429;
  unsigned int D.13430;
  struct statfs stat;
  struct _wapi_drive_type * current;

  try
    {
      D.13421 = statfs (utfpath, &stat);
      if (D.13421 == -1) goto <D.13422>; else goto <D.13423>;
      <D.13422>:
      D.13424 = 0B;
      return D.13424;
      <D.13423>:
      current = &_wapi_drive_types[0];
      goto <D.11678>;
      <D.11677>:
      D.13425 = stat.f_type;
      D.13426 = current->fstypeid;
      if (D.13425 == D.13426) goto <D.13427>; else goto <D.13428>;
      <D.13427>:
      D.13429 = current->fstype;
      D.13424 = monoeg_strdup (D.13429);
      return D.13424;
      <D.13428>:
      current = current + 12;
      <D.11678>:
      D.13430 = current->drive_type;
      if (D.13430 != 0) goto <D.11677>; else goto <D.11679>;
      <D.11679>:
      D.13424 = 0B;
      return D.13424;
    }
  finally
    {
      stat = {CLOBBER};
    }
}


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


