file_close (void * handle, void * data)
{
  unsigned int D.12622;
  unsigned int D.12623;
  gchar * D.12626;
  struct _WapiFileShare * D.12627;
  struct _WapiHandle_file * file_handle;
  int fd;

  file_handle = data;
  fd = file_handle->fd;
  D.12622 = file_handle->attrs;
  D.12623 = D.12622 & 67108864;
  if (D.12623 != 0) goto <D.12624>; else goto <D.12625>;
  <D.12624>:
  D.12626 = file_handle->filename;
  _wapi_unlink (D.12626);
  <D.12625>:
  D.12626 = file_handle->filename;
  monoeg_g_free (D.12626);
  D.12627 = file_handle->share_info;
  if (D.12627 != 0B) goto <D.12628>; else goto <D.12629>;
  <D.12628>:
  D.12627 = file_handle->share_info;
  _wapi_handle_share_release (D.12627);
  <D.12629>:
  close (fd);
}


_wapi_handle_share_release (struct _WapiFileShare * info)
{
  unsigned int D.12630;
  _Bool D.12631;
  long int D.12632;
  long int D.12633;
  _Bool D.12636;
  long int D.12637;
  long int D.12638;
  guint32 * D.12641;
  int D.12642;
  int thr_ret;

  D.12630 = info->handle_refs;
  D.12631 = D.12630 == 0;
  D.12632 = (long int) D.12631;
  D.12633 = __builtin_expect (D.12632, 0);
  if (D.12633 != 0) goto <D.12634>; else goto <D.12635>;
  <D.12634>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "../../mono/io-layer/handles-private.h", 364, "info->handle_refs > 0");
  <D.12635>:
  thr_ret = _wapi_shm_sem_lock (2);
  D.12636 = thr_ret != 0;
  D.12637 = (long int) D.12636;
  D.12638 = __builtin_expect (D.12637, 0);
  if (D.12638 != 0) goto <D.12639>; else goto <D.12640>;
  <D.12639>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "../../mono/io-layer/handles-private.h", 368, "thr_ret == 0");
  <D.12640>:
  D.12641 = &info->handle_refs;
  D.12642 = InterlockedDecrement (D.12641);
  if (D.12642 == 0) goto <D.12643>; else goto <D.12644>;
  <D.12643>:
  _wapi_free_share_info (info);
  <D.12644>:
  thr_ret = _wapi_shm_sem_unlock (2);
}


InterlockedDecrement (volatile gint32 * val)
{
  gint32 D.12645;
  unsigned int D.12646;

  D.12646 = __sync_sub_and_fetch_4 (val, 1);
  D.12645 = (gint32) D.12646;
  return D.12645;
}


_wapi_file_details (void * handle_info)
{
  gchar * D.12648;
  int iftmp.0;
  unsigned int D.12650;
  signed int D.12651;
  int iftmp.1;
  unsigned int D.12656;
  int iftmp.2;
  unsigned int D.12661;
  int iftmp.3;
  unsigned int D.12666;
  unsigned int D.12667;
  int iftmp.4;
  unsigned int D.12672;
  int iftmp.5;
  unsigned int D.12677;
  unsigned int D.12681;
  struct _WapiHandle_file * file;

  file = handle_info;
  D.12648 = file->filename;
  D.12650 = file->fileaccess;
  D.12651 = (signed int) D.12650;
  if (D.12651 < 0) goto <D.12652>; else goto <D.12653>;
  <D.12652>:
  iftmp.0 = 82;
  goto <D.12654>;
  <D.12653>:
  iftmp.0 = 46;
  <D.12654>:
  D.12650 = file->fileaccess;
  D.12656 = D.12650 & 1073741824;
  if (D.12656 != 0) goto <D.12657>; else goto <D.12658>;
  <D.12657>:
  iftmp.1 = 87;
  goto <D.12659>;
  <D.12658>:
  iftmp.1 = 46;
  <D.12659>:
  D.12650 = file->fileaccess;
  D.12661 = D.12650 & 536870912;
  if (D.12661 != 0) goto <D.12662>; else goto <D.12663>;
  <D.12662>:
  iftmp.2 = 88;
  goto <D.12664>;
  <D.12663>:
  iftmp.2 = 46;
  <D.12664>:
  D.12666 = file->sharemode;
  D.12667 = D.12666 & 1;
  if (D.12667 != 0) goto <D.12668>; else goto <D.12669>;
  <D.12668>:
  iftmp.3 = 82;
  goto <D.12670>;
  <D.12669>:
  iftmp.3 = 46;
  <D.12670>:
  D.12666 = file->sharemode;
  D.12672 = D.12666 & 2;
  if (D.12672 != 0) goto <D.12673>; else goto <D.12674>;
  <D.12673>:
  iftmp.4 = 87;
  goto <D.12675>;
  <D.12674>:
  iftmp.4 = 46;
  <D.12675>:
  D.12666 = file->sharemode;
  D.12677 = D.12666 & 4;
  if (D.12677 != 0) goto <D.12678>; else goto <D.12679>;
  <D.12678>:
  iftmp.5 = 68;
  goto <D.12680>;
  <D.12679>:
  iftmp.5 = 46;
  <D.12680>:
  D.12681 = file->attrs;
  monoeg_g_print ("[%20s] acc: %c%c%c, shr: %c%c%c, attrs: %5u", D.12648, iftmp.0, iftmp.1, iftmp.2, iftmp.3, iftmp.4, iftmp.5, D.12681);
}


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

  console_handle = data;
  fd = console_handle->fd;
  D.12682 = console_handle->filename;
  monoeg_g_free (D.12682);
  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.12683;
  unsigned int D.12686;
  void * D.12689;
  int * D.12696;
  int D.12697;
  int D.12700;
  unsigned int fd.6;
  unsigned int _wapi_fd_reserve.7;
  int D.12709;
  struct _WapiFileShare * D.12712;
  unsigned int D.12717;
  unsigned int D.12720;
  unsigned int D.12723;
  unsigned int D.12724;
  <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.12683 = attrs & 256;
      if (D.12683 != 0) goto <D.12684>; else goto <D.12685>;
      <D.12684>:
      perms = 384;
      <D.12685>:
      D.12686 = attrs & 64;
      if (D.12686 != 0) goto <D.12687>; else goto <D.12688>;
      <D.12687>:
      SetLastError (6000);
      D.12689 = -1B;
      return D.12689;
      <D.12688>:
      if (name == 0B) goto <D.12690>; else goto <D.12691>;
      <D.12690>:
      SetLastError (123);
      D.12689 = -1B;
      return D.12689;
      <D.12691>:
      filename = mono_unicode_to_external (name);
      if (filename == 0B) goto <D.12692>; else goto <D.12693>;
      <D.12692>:
      SetLastError (123);
      D.12689 = -1B;
      return D.12689;
      <D.12693>:
      fd = _wapi_open (filename, flags, perms);
      if (fd == -1) goto <D.12694>; else goto <D.12695>;
      <D.12694>:
      D.12696 = __errno_location ();
      D.12697 = *D.12696;
      if (D.12697 == 21) goto <D.12698>; else goto <D.12699>;
      <D.12698>:
      D.12700 = flags & -4;
      fd = _wapi_open (filename, D.12700, perms);
      <D.12699>:
      <D.12695>:
      if (fd == -1) goto <D.12701>; else goto <D.12702>;
      <D.12701>:
      _wapi_set_last_path_error_from_errno (0B, filename);
      monoeg_g_free (filename);
      D.12689 = -1B;
      return D.12689;
      <D.12702>:
      fd.6 = (unsigned int) fd;
      _wapi_fd_reserve.7 = _wapi_fd_reserve;
      if (fd.6 >= _wapi_fd_reserve.7) goto <D.12705>; else goto <D.12706>;
      <D.12705>:
      SetLastError (4);
      close (fd);
      monoeg_g_free (filename);
      D.12689 = -1B;
      return D.12689;
      <D.12706>:
      ret = fstat (fd, &statbuf);
      if (ret == -1) goto <D.12707>; else goto <D.12708>;
      <D.12707>:
      _wapi_set_last_error_from_errno ();
      monoeg_g_free (filename);
      close (fd);
      D.12689 = -1B;
      return D.12689;
      <D.12708>:
      D.12709 = share_check (&statbuf, sharemode, fileaccess, &file_handle.share_info, fd);
      if (D.12709 == 0) goto <D.12710>; else goto <D.12711>;
      <D.12710>:
      SetLastError (32);
      monoeg_g_free (filename);
      close (fd);
      D.12689 = -1B;
      return D.12689;
      <D.12711>:
      D.12712 = file_handle.share_info;
      if (D.12712 == 0B) goto <D.12713>; else goto <D.12714>;
      <D.12713>:
      SetLastError (4);
      close (fd);
      monoeg_g_free (filename);
      D.12689 = -1B;
      return D.12689;
      <D.12714>:
      file_handle.filename = filename;
      if (security != 0B) goto <D.12715>; else goto <D.12716>;
      <D.12715>:
      <D.12716>:
      file_handle.fd = fd;
      file_handle.fileaccess = fileaccess;
      file_handle.sharemode = sharemode;
      file_handle.attrs = attrs;
      D.12717 = attrs & 134217728;
      if (D.12717 != 0) goto <D.12718>; else goto <D.12719>;
      <D.12718>:
      posix_fadvise (fd, 0, 0, 2);
      <D.12719>:
      D.12720 = attrs & 268435456;
      if (D.12720 != 0) goto <D.12721>; else goto <D.12722>;
      <D.12721>:
      posix_fadvise (fd, 0, 0, 1);
      <D.12722>:
      D.12723 = statbuf.st_mode;
      D.12724 = D.12723 & 61440;
      if (D.12724 == 4096) goto <D.12725>; else goto <D.12726>;
      <D.12725>:
      handle_type = 10;
      goto <D.12727>;
      <D.12726>:
      D.12723 = statbuf.st_mode;
      D.12724 = D.12723 & 61440;
      if (D.12724 == 8192) goto <D.12728>; else goto <D.12729>;
      <D.12728>:
      handle_type = 2;
      goto <D.12730>;
      <D.12729>:
      handle_type = 1;
      <D.12730>:
      <D.12727>:
      handle_type.8 = (<unnamed type>) handle_type;
      handle = _wapi_handle_new_fd (handle_type.8, fd, &file_handle);
      if (handle == -1B) goto <D.12732>; else goto <D.12733>;
      <D.12732>:
      monoeg_g_log (0B, 16, "%s: error creating file handle", &__func__);
      monoeg_g_free (filename);
      close (fd);
      SetLastError (31);
      D.12689 = -1B;
      return D.12689;
      <D.12733>:
      D.12689 = handle;
      return D.12689;
    }
  finally
    {
      file_handle = {CLOBBER};
      statbuf = {CLOBBER};
    }
}


io_ops_init ()
{
  const gchar * D.12736;

  D.12736 = monoeg_g_getenv ("MONO_STRICT_IO_EMULATION");
  if (D.12736 != 0B) goto <D.12737>; else goto <D.12738>;
  <D.12737>:
  lock_while_writing = 1;
  <D.12738>:
}


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

  flags = 0;
  switch (fileaccess) <default: <D.12088>, case 1073741824: <D.12086>, case 2147483648: <D.12084>, case 3221225472: <D.12087>>
  <D.12084>:
  flags = 0;
  goto <D.12085>;
  <D.12086>:
  flags = 1;
  goto <D.12085>;
  <D.12087>:
  flags = 2;
  goto <D.12085>;
  <D.12088>:
  goto <D.12085>;
  <D.12085>:
  switch (createmode) <default: <D.12095>, case 1: <D.12089>, case 2: <D.12091>, case 3: <D.12092>, case 4: <D.12093>, case 5: <D.12094>>
  <D.12089>:
  flags = flags | 192;
  goto <D.12090>;
  <D.12091>:
  flags = flags | 576;
  goto <D.12090>;
  <D.12092>:
  goto <D.12090>;
  <D.12093>:
  flags = flags | 64;
  goto <D.12090>;
  <D.12094>:
  flags = flags | 512;
  goto <D.12090>;
  <D.12095>:
  goto <D.12090>;
  <D.12090>:
  D.12739 = flags;
  return D.12739;
}


_wapi_set_last_path_error_from_errno (const gchar * dir, const gchar * path)
{
  int * D.12743;
  int D.12744;
  int D.12750;

  D.12743 = __errno_location ();
  D.12744 = *D.12743;
  if (D.12744 == 2) goto <D.12745>; else goto <D.12746>;
  <D.12745>:
  {
    gchar * dirname;

    if (dir == 0B) goto <D.12747>; else goto <D.12748>;
    <D.12747>:
    dirname = _wapi_dirname (path);
    goto <D.12749>;
    <D.12748>:
    dirname = monoeg_strdup (dir);
    <D.12749>:
    D.12750 = _wapi_access (dirname, 0);
    if (D.12750 == 0) goto <D.12751>; else goto <D.12752>;
    <D.12751>:
    SetLastError (2);
    goto <D.12753>;
    <D.12752>:
    SetLastError (3);
    <D.12753>:
    monoeg_g_free (dirname);
  }
  goto <D.12754>;
  <D.12746>:
  _wapi_set_last_error_from_errno ();
  <D.12754>:
}


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

  if (str != 0B) goto <D.12755>; else goto <D.12756>;
  <D.12755>:
  D.12757 = __strdup (str);
  return D.12757;
  <D.12756>:
  D.12757 = 0B;
  return D.12757;
}


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

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


_wapi_set_last_error_from_errno ()
{
  int * D.12761;
  int D.12762;
  int D.12763;
  unsigned int D.12764;

  D.12761 = __errno_location ();
  D.12762 = *D.12761;
  D.12763 = _wapi_get_win32_file_error (D.12762);
  D.12764 = (unsigned int) D.12763;
  SetLastError (D.12764);
}


share_check (struct stat * statbuf, guint32 sharemode, guint32 fileaccess, struct _WapiFileShare * * share_info, int fd)
{
  int D.12765;
  gboolean D.12768;
  struct _WapiFileShare * D.12769;
  int D.12770;

  D.12765 = share_allows_open (statbuf, sharemode, fileaccess, share_info);
  if (D.12765 == 1) goto <D.12766>; else goto <D.12767>;
  <D.12766>:
  D.12768 = 1;
  return D.12768;
  <D.12767>:
  D.12769 = *share_info;
  _wapi_handle_check_share (D.12769, fd);
  D.12770 = share_allows_open (statbuf, sharemode, fileaccess, share_info);
  if (D.12770 == 1) goto <D.12771>; else goto <D.12772>;
  <D.12771>:
  D.12768 = 1;
  return D.12768;
  <D.12772>:
  _wapi_handle_collect ();
  D.12768 = share_allows_open (statbuf, sharemode, fileaccess, share_info);
  return D.12768;
}


share_allows_open (struct stat * statbuf, guint32 sharemode, guint32 fileaccess, struct _WapiFileShare * * share_info)
{
  long unsigned int D.12774;
  long unsigned int D.12775;
  unsigned int file_existing_share.9;
  struct _WapiFileShare * D.12781;
  gboolean D.12782;
  unsigned int file_existing_access.10;
  signed int file_existing_access.11;
  unsigned int D.12794;
  unsigned int D.12795;
  unsigned int D.12797;
  gboolean file_already_shared;
  guint32 file_existing_share;
  guint32 file_existing_access;

  try
    {
      D.12774 = statbuf->st_dev;
      D.12775 = statbuf->st_ino;
      file_already_shared = _wapi_handle_get_or_set_share (D.12774, D.12775, sharemode, fileaccess, &file_existing_share, &file_existing_access, share_info);
      if (file_already_shared != 0) goto <D.12776>; else goto <D.12777>;
      <D.12776>:
      file_existing_share.9 = file_existing_share;
      if (file_existing_share.9 == 0) goto <D.12779>; else goto <D.12780>;
      <D.12779>:
      D.12781 = *share_info;
      _wapi_handle_share_release (D.12781);
      D.12782 = 0;
      return D.12782;
      <D.12780>:
      file_existing_share.9 = file_existing_share;
      if (file_existing_share.9 == 1) goto <D.12786>; else goto <D.12783>;
      <D.12786>:
      if (fileaccess != 2147483648) goto <D.12784>; else goto <D.12783>;
      <D.12783>:
      file_existing_share.9 = file_existing_share;
      if (file_existing_share.9 == 2) goto <D.12787>; else goto <D.12785>;
      <D.12787>:
      if (fileaccess != 1073741824) goto <D.12784>; else goto <D.12785>;
      <D.12784>:
      D.12781 = *share_info;
      _wapi_handle_share_release (D.12781);
      D.12782 = 0;
      return D.12782;
      <D.12785>:
      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.12793>; else goto <D.12788>;
      <D.12793>:
      D.12794 = sharemode & 1;
      if (D.12794 == 0) goto <D.12789>; else goto <D.12788>;
      <D.12788>:
      file_existing_access.10 = file_existing_access;
      D.12795 = file_existing_access.10 & 1073741824;
      if (D.12795 != 0) goto <D.12796>; else goto <D.12790>;
      <D.12796>:
      D.12797 = sharemode & 2;
      if (D.12797 == 0) goto <D.12789>; else goto <D.12790>;
      <D.12789>:
      D.12781 = *share_info;
      _wapi_handle_share_release (D.12781);
      D.12782 = 0;
      return D.12782;
      <D.12790>:
      goto <D.12798>;
      <D.12777>:
      <D.12798>:
      D.12782 = 1;
      return D.12782;
    }
  finally
    {
      file_existing_share = {CLOBBER};
      file_existing_access = {CLOBBER};
    }
}


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

  ret = 0;
  if (name == 0B) goto <D.12801>; else goto <D.12802>;
  <D.12801>:
  SetLastError (123);
  D.12803 = 0;
  return D.12803;
  <D.12802>:
  filename = mono_unicode_to_external (name);
  if (filename == 0B) goto <D.12804>; else goto <D.12805>;
  <D.12804>:
  SetLastError (123);
  D.12803 = 0;
  return D.12803;
  <D.12805>:
  attrs = GetFileAttributes (name);
  if (attrs == 4294967295) goto <D.12806>; else goto <D.12807>;
  <D.12806>:
  monoeg_g_free (filename);
  D.12803 = 0;
  return D.12803;
  <D.12807>:
  retval = _wapi_unlink (filename);
  if (retval == -1) goto <D.12808>; else goto <D.12809>;
  <D.12808>:
  _wapi_set_last_path_error_from_errno (0B, filename);
  goto <D.12810>;
  <D.12809>:
  ret = 1;
  <D.12810>:
  monoeg_g_free (filename);
  D.12803 = ret;
  return D.12803;
}


MoveFile (const gunichar2 * name, const gunichar2 * dest_name)
{
  gboolean D.12814;
  int D.12821;
  int * D.12826;
  int D.12827;
  int D.12829;
  int D.12830;
  long unsigned int D.12835;
  long unsigned int D.12836;
  long unsigned int D.12838;
  long unsigned int D.12839;
  int D.12840;
  struct _WapiFileShare * shareinfo.12;
  unsigned int D.12852;
  unsigned int D.12853;
  int D.12856;
  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.12812>; else goto <D.12813>;
      <D.12812>:
      SetLastError (123);
      D.12814 = 0;
      return D.12814;
      <D.12813>:
      utf8_name = mono_unicode_to_external (name);
      if (utf8_name == 0B) goto <D.12815>; else goto <D.12816>;
      <D.12815>:
      SetLastError (123);
      D.12814 = 0;
      return D.12814;
      <D.12816>:
      if (dest_name == 0B) goto <D.12817>; else goto <D.12818>;
      <D.12817>:
      monoeg_g_free (utf8_name);
      SetLastError (123);
      D.12814 = 0;
      return D.12814;
      <D.12818>:
      utf8_dest_name = mono_unicode_to_external (dest_name);
      if (utf8_dest_name == 0B) goto <D.12819>; else goto <D.12820>;
      <D.12819>:
      monoeg_g_free (utf8_name);
      SetLastError (123);
      D.12814 = 0;
      return D.12814;
      <D.12820>:
      D.12821 = _wapi_stat (utf8_name, &stat_src);
      if (D.12821 < 0) goto <D.12822>; else goto <D.12823>;
      <D.12822>:
      D.12826 = __errno_location ();
      D.12827 = *D.12826;
      if (D.12827 != 2) goto <D.12824>; else goto <D.12828>;
      <D.12828>:
      D.12829 = _wapi_lstat (utf8_name, &stat_src);
      if (D.12829 < 0) goto <D.12824>; else goto <D.12825>;
      <D.12824>:
      _wapi_set_last_path_error_from_errno (0B, utf8_name);
      monoeg_g_free (utf8_name);
      monoeg_g_free (utf8_dest_name);
      D.12814 = 0;
      return D.12814;
      <D.12825>:
      <D.12823>:
      D.12830 = _wapi_stat (utf8_dest_name, &stat_dest);
      if (D.12830 == 0) goto <D.12831>; else goto <D.12832>;
      <D.12831>:
      D.12835 = stat_dest.st_dev;
      D.12836 = stat_src.st_dev;
      if (D.12835 != D.12836) goto <D.12833>; else goto <D.12837>;
      <D.12837>:
      D.12838 = stat_dest.st_ino;
      D.12839 = stat_src.st_ino;
      if (D.12838 != D.12839) goto <D.12833>; else goto <D.12834>;
      <D.12833>:
      monoeg_g_free (utf8_name);
      monoeg_g_free (utf8_dest_name);
      SetLastError (183);
      D.12814 = 0;
      return D.12814;
      <D.12834>:
      <D.12832>:
      D.12840 = share_allows_delete (&stat_src, &shareinfo);
      if (D.12840 == 0) goto <D.12841>; else goto <D.12842>;
      <D.12841>:
      SetLastError (32);
      D.12814 = 0;
      return D.12814;
      <D.12842>:
      shareinfo.12 = shareinfo;
      if (shareinfo.12 != 0B) goto <D.12844>; else goto <D.12845>;
      <D.12844>:
      shareinfo.12 = shareinfo;
      _wapi_handle_share_release (shareinfo.12);
      <D.12845>:
      result = _wapi_rename (utf8_name, utf8_dest_name);
      D.12826 = __errno_location ();
      errno_copy = *D.12826;
      if (result == -1) goto <D.12846>; else goto <D.12847>;
      <D.12846>:
      switch (errno_copy) <default: <D.12160>, case 17: <D.12157>, case 18: <D.12159>>
      <D.12157>:
      SetLastError (183);
      goto <D.12158>;
      <D.12159>:
      goto <D.12158>;
      <D.12160>:
      _wapi_set_last_path_error_from_errno (0B, utf8_name);
      <D.12158>:
      <D.12847>:
      monoeg_g_free (utf8_name);
      monoeg_g_free (utf8_dest_name);
      if (result != 0) goto <D.12848>; else goto <D.12849>;
      <D.12848>:
      if (errno_copy == 18) goto <D.12850>; else goto <D.12851>;
      <D.12850>:
      D.12852 = stat_src.st_mode;
      D.12853 = D.12852 & 61440;
      if (D.12853 == 16384) goto <D.12854>; else goto <D.12855>;
      <D.12854>:
      SetLastError (17);
      D.12814 = 0;
      return D.12814;
      <D.12855>:
      D.12856 = CopyFile (name, dest_name, 1);
      if (D.12856 == 0) goto <D.12857>; else goto <D.12858>;
      <D.12857>:
      D.12814 = 0;
      return D.12814;
      <D.12858>:
      D.12814 = DeleteFile (name);
      return D.12814;
      <D.12851>:
      <D.12849>:
      if (result == 0) goto <D.12859>; else goto <D.12860>;
      <D.12859>:
      ret = 1;
      <D.12860>:
      D.12814 = ret;
      return D.12814;
    }
  finally
    {
      stat_src = {CLOBBER};
      stat_dest = {CLOBBER};
      shareinfo = {CLOBBER};
    }
}


share_allows_delete (struct stat * statbuf, struct _WapiFileShare * * share_info)
{
  long unsigned int D.12864;
  long unsigned int D.12865;
  unsigned int file_existing_share.13;
  struct _WapiFileShare * D.12871;
  gboolean D.12872;
  unsigned int D.12873;
  gboolean file_already_shared;
  guint32 file_existing_share;
  guint32 file_existing_access;

  try
    {
      D.12864 = statbuf->st_dev;
      D.12865 = statbuf->st_ino;
      file_already_shared = _wapi_handle_get_or_set_share (D.12864, D.12865, 4, 2147483648, &file_existing_share, &file_existing_access, share_info);
      if (file_already_shared != 0) goto <D.12866>; else goto <D.12867>;
      <D.12866>:
      file_existing_share.13 = file_existing_share;
      if (file_existing_share.13 == 0) goto <D.12869>; else goto <D.12870>;
      <D.12869>:
      D.12871 = *share_info;
      _wapi_handle_share_release (D.12871);
      D.12872 = 0;
      return D.12872;
      <D.12870>:
      file_existing_share.13 = file_existing_share;
      D.12873 = file_existing_share.13 & 4;
      if (D.12873 == 0) goto <D.12874>; else goto <D.12875>;
      <D.12874>:
      D.12871 = *share_info;
      _wapi_handle_share_release (D.12871);
      D.12872 = 0;
      return D.12872;
      <D.12875>:
      goto <D.12876>;
      <D.12867>:
      <D.12876>:
      D.12872 = 1;
      return D.12872;
    }
  finally
    {
      file_existing_share = {CLOBBER};
      file_existing_access = {CLOBBER};
    }
}


CopyFile (const gunichar2 * name, const gunichar2 * dest_name, gboolean fail_if_exists)
{
  gboolean D.12881;
  int D.12890;
  int D.12893;
  long unsigned int D.12896;
  long unsigned int D.12897;
  long unsigned int D.12900;
  long unsigned int D.12901;
  unsigned int D.12906;
  int D.12913;
  long int D.12916;
  long int D.12917;
  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.12879>; else goto <D.12880>;
      <D.12879>:
      SetLastError (123);
      D.12881 = 0;
      return D.12881;
      <D.12880>:
      utf8_src = mono_unicode_to_external (name);
      if (utf8_src == 0B) goto <D.12882>; else goto <D.12883>;
      <D.12882>:
      SetLastError (87);
      D.12881 = 0;
      return D.12881;
      <D.12883>:
      if (dest_name == 0B) goto <D.12884>; else goto <D.12885>;
      <D.12884>:
      monoeg_g_free (utf8_src);
      SetLastError (123);
      D.12881 = 0;
      return D.12881;
      <D.12885>:
      utf8_dest = mono_unicode_to_external (dest_name);
      if (utf8_dest == 0B) goto <D.12886>; else goto <D.12887>;
      <D.12886>:
      SetLastError (87);
      monoeg_g_free (utf8_src);
      D.12881 = 0;
      return D.12881;
      <D.12887>:
      src_fd = _wapi_open (utf8_src, 0, 0);
      if (src_fd < 0) goto <D.12888>; else goto <D.12889>;
      <D.12888>:
      _wapi_set_last_path_error_from_errno (0B, utf8_src);
      monoeg_g_free (utf8_src);
      monoeg_g_free (utf8_dest);
      D.12881 = 0;
      return D.12881;
      <D.12889>:
      D.12890 = fstat (src_fd, &st);
      if (D.12890 < 0) goto <D.12891>; else goto <D.12892>;
      <D.12891>:
      _wapi_set_last_error_from_errno ();
      monoeg_g_free (utf8_src);
      monoeg_g_free (utf8_dest);
      close (src_fd);
      D.12881 = 0;
      return D.12881;
      <D.12892>:
      D.12893 = _wapi_stat (utf8_dest, &dest_st);
      if (D.12893 == 0) goto <D.12894>; else goto <D.12895>;
      <D.12894>:
      D.12896 = st.st_dev;
      D.12897 = dest_st.st_dev;
      if (D.12896 == D.12897) goto <D.12898>; else goto <D.12899>;
      <D.12898>:
      D.12900 = st.st_ino;
      D.12901 = dest_st.st_ino;
      if (D.12900 == D.12901) goto <D.12902>; else goto <D.12903>;
      <D.12902>:
      monoeg_g_free (utf8_src);
      monoeg_g_free (utf8_dest);
      close (src_fd);
      SetLastError (32);
      D.12881 = 0;
      return D.12881;
      <D.12903>:
      <D.12899>:
      <D.12895>:
      if (fail_if_exists != 0) goto <D.12904>; else goto <D.12905>;
      <D.12904>:
      D.12906 = st.st_mode;
      dest_fd = _wapi_open (utf8_dest, 193, D.12906);
      goto <D.12907>;
      <D.12905>:
      D.12906 = st.st_mode;
      dest_fd = _wapi_open (utf8_dest, 513, D.12906);
      if (dest_fd < 0) goto <D.12908>; else goto <D.12909>;
      <D.12908>:
      D.12906 = st.st_mode;
      dest_fd = _wapi_open (utf8_dest, 577, D.12906);
      goto <D.12910>;
      <D.12909>:
      SetLastError (183);
      <D.12910>:
      <D.12907>:
      if (dest_fd < 0) goto <D.12911>; else goto <D.12912>;
      <D.12911>:
      _wapi_set_last_error_from_errno ();
      monoeg_g_free (utf8_src);
      monoeg_g_free (utf8_dest);
      close (src_fd);
      D.12881 = 0;
      return D.12881;
      <D.12912>:
      D.12913 = write_file (src_fd, dest_fd, &st, 1);
      if (D.12913 == 0) goto <D.12914>; else goto <D.12915>;
      <D.12914>:
      ret = 0;
      <D.12915>:
      close (src_fd);
      close (dest_fd);
      D.12916 = st.st_mtim.tv_sec;
      dest_time.modtime = D.12916;
      D.12917 = st.st_atim.tv_sec;
      dest_time.actime = D.12917;
      ret_utime = utime (utf8_dest, &dest_time);
      if (ret_utime == -1) goto <D.12918>; else goto <D.12919>;
      <D.12918>:
      <D.12919>:
      monoeg_g_free (utf8_src);
      monoeg_g_free (utf8_dest);
      D.12881 = ret;
      return D.12881;
    }
  finally
    {
      st = {CLOBBER};
      dest_st = {CLOBBER};
      dest_time = {CLOBBER};
    }
}


write_file (int src_fd, int dest_fd, struct stat * st_src, gboolean report_errors)
{
  long int D.12922;
  int iftmp.14;
  long unsigned int D.12927;
  long int D.12928;
  int * D.12931;
  int D.12932;
  int D.12935;
  gboolean D.12940;
  long unsigned int D.12942;
  long int D.12943;
  int D.12948;
  sizetype D.12953;
  int remain;
  int n;
  char * buf;
  char * wbuf;
  int buf_size;

  D.12922 = st_src->st_blksize;
  buf_size = (int) D.12922;
  if (buf_size > 8191) goto <D.12924>; else goto <D.12925>;
  <D.12924>:
  iftmp.14 = MIN_EXPR <buf_size, 65536>;
  goto <D.12926>;
  <D.12925>:
  iftmp.14 = 8192;
  <D.12926>:
  buf_size = iftmp.14;
  D.12927 = (long unsigned int) buf_size;
  buf = malloc (D.12927);
  <D.12177>:
  D.12927 = (long unsigned int) buf_size;
  D.12928 = read (src_fd, buf, D.12927);
  remain = (int) D.12928;
  if (remain < 0) goto <D.12929>; else goto <D.12930>;
  <D.12929>:
  D.12931 = __errno_location ();
  D.12932 = *D.12931;
  if (D.12932 == 4) goto <D.12933>; else goto <D.12934>;
  <D.12933>:
  D.12935 = _wapi_thread_cur_apc_pending ();
  if (D.12935 == 0) goto <D.12936>; else goto <D.12937>;
  <D.12936>:
  // predicted unlikely by continue predictor.
  goto <D.12172>;
  <D.12937>:
  <D.12934>:
  if (report_errors != 0) goto <D.12938>; else goto <D.12939>;
  <D.12938>:
  _wapi_set_last_error_from_errno ();
  <D.12939>:
  free (buf);
  D.12940 = 0;
  return D.12940;
  <D.12930>:
  if (remain == 0) goto <D.12173>; else goto <D.12941>;
  <D.12941>:
  wbuf = buf;
  goto <D.12174>;
  <D.12175>:
  D.12942 = (long unsigned int) remain;
  D.12943 = write (dest_fd, wbuf, D.12942);
  n = (int) D.12943;
  if (n < 0) goto <D.12944>; else goto <D.12945>;
  <D.12944>:
  D.12931 = __errno_location ();
  D.12932 = *D.12931;
  if (D.12932 == 4) goto <D.12946>; else goto <D.12947>;
  <D.12946>:
  D.12948 = _wapi_thread_cur_apc_pending ();
  if (D.12948 == 0) goto <D.12949>; else goto <D.12950>;
  <D.12949>:
  // predicted unlikely by continue predictor.
  goto <D.12174>;
  <D.12950>:
  <D.12947>:
  if (report_errors != 0) goto <D.12951>; else goto <D.12952>;
  <D.12951>:
  _wapi_set_last_error_from_errno ();
  <D.12952>:
  free (buf);
  D.12940 = 0;
  return D.12940;
  <D.12945>:
  remain = remain - n;
  D.12953 = (sizetype) n;
  wbuf = wbuf + D.12953;
  <D.12174>:
  if (remain > 0) goto <D.12175>; else goto <D.12176>;
  <D.12176>:
  <D.12172>:
  goto <D.12177>;
  <D.12173>:
  free (buf);
  D.12940 = 1;
  return D.12940;
}


read (int __fd, void * __buf, size_t __nbytes)
{
  long unsigned int D.12955;
  int D.12958;
  ssize_t D.12961;
  long unsigned int D.12962;
  long unsigned int D.12963;
  long unsigned int D.12966;

  D.12955 = __builtin_object_size (__buf, 0);
  if (D.12955 != 18446744073709551615) goto <D.12956>; else goto <D.12957>;
  <D.12956>:
  D.12958 = __builtin_constant_p (__nbytes);
  if (D.12958 == 0) goto <D.12959>; else goto <D.12960>;
  <D.12959>:
  D.12962 = __builtin_object_size (__buf, 0);
  D.12961 = __read_chk (__fd, __buf, __nbytes, D.12962);
  return D.12961;
  <D.12960>:
  D.12963 = __builtin_object_size (__buf, 0);
  if (D.12963 < __nbytes) goto <D.12964>; else goto <D.12965>;
  <D.12964>:
  D.12966 = __builtin_object_size (__buf, 0);
  D.12961 = __read_chk_warn (__fd, __buf, __nbytes, D.12966);
  return D.12961;
  <D.12965>:
  <D.12957>:
  D.12961 = __read_alias (__fd, __buf, __nbytes);
  return D.12961;
}


ReplaceFile (const gunichar2 * replacedFileName, const gunichar2 * replacementFileName, const gunichar2 * backupFileName, guint32 replaceFlags, void * exclude, void * reserved)
{
  gboolean D.12970;
  int * D.12977;
  int D.12983;
  unsigned int D.12986;
  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.12968>; else goto <D.12969>;
      <D.12968>:
      D.12970 = 0;
      return D.12970;
      <D.12969>:
      utf8_replacementFileName = convert_arg_to_utf8 (replacementFileName, "replacementFileName");
      if (utf8_replacementFileName == 0B) goto replace_cleanup; else goto <D.12971>;
      <D.12971>:
      if (backupFileName != 0B) goto <D.12972>; else goto <D.12973>;
      <D.12972>:
      utf8_backupFileName = convert_arg_to_utf8 (backupFileName, "backupFileName");
      if (utf8_backupFileName == 0B) goto replace_cleanup; else goto <D.12974>;
      <D.12974>:
      <D.12973>:
      if (utf8_backupFileName != 0B) goto <D.12975>; else goto <D.12976>;
      <D.12975>:
      backup_fd = _wapi_open (utf8_backupFileName, 0, 0);
      result = _wapi_rename (utf8_replacedFileName, utf8_backupFileName);
      D.12977 = __errno_location ();
      errno_copy = *D.12977;
      if (result == -1) goto replace_cleanup; else goto <D.12978>;
      <D.12978>:
      <D.12976>:
      result = _wapi_rename (utf8_replacementFileName, utf8_replacedFileName);
      D.12977 = __errno_location ();
      errno_copy = *D.12977;
      if (result == -1) goto <D.12979>; else goto <D.12980>;
      <D.12979>:
      _wapi_set_last_path_error_from_errno (0B, utf8_replacementFileName);
      _wapi_rename (utf8_backupFileName, utf8_replacedFileName);
      if (backup_fd != -1) goto <D.12981>; else goto <D.12982>;
      <D.12981>:
      D.12983 = fstat (backup_fd, &stBackup);
      if (D.12983 == 0) goto <D.12984>; else goto <D.12985>;
      <D.12984>:
      D.12986 = stBackup.st_mode;
      replaced_fd = _wapi_open (utf8_backupFileName, 577, D.12986);
      if (replaced_fd == -1) goto replace_cleanup; else goto <D.12987>;
      <D.12987>:
      write_file (backup_fd, replaced_fd, &stBackup, 0);
      <D.12985>:
      <D.12982>:
      goto replace_cleanup;
      <D.12980>:
      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.12988>; else goto <D.12989>;
      <D.12988>:
      close (backup_fd);
      <D.12989>:
      if (replaced_fd != -1) goto <D.12990>; else goto <D.12991>;
      <D.12990>:
      close (replaced_fd);
      <D.12991>:
      D.12970 = ret;
      return D.12970;
    }
  finally
    {
      stBackup = {CLOBBER};
    }
}


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

  if (arg == 0B) goto <D.12994>; else goto <D.12995>;
  <D.12994>:
  SetLastError (123);
  D.12996 = 0B;
  return D.12996;
  <D.12995>:
  utf8_ret = mono_unicode_to_external (arg);
  if (utf8_ret == 0B) goto <D.12997>; else goto <D.12998>;
  <D.12997>:
  SetLastError (87);
  D.12996 = 0B;
  return D.12996;
  <D.12998>:
  D.12996 = utf8_ret;
  return D.12996;
}


GetStdHandle (WapiStdHandle stdhandle)
{
  void * D.13000;
  long int D.13001;
  long int D.13002;
  long int D.13003;
  _Bool D.13006;
  long int D.13007;
  long int D.13008;
  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.12229>, case -12: <D.12228>, case -11: <D.12227>, case -10: <D.12225>>
      <D.12225>:
      fd = 0;
      name = "<stdin>";
      goto <D.12226>;
      <D.12227>:
      fd = 1;
      name = "<stdout>";
      goto <D.12226>;
      <D.12228>:
      fd = 2;
      name = "<stderr>";
      goto <D.12226>;
      <D.12229>:
      SetLastError (87);
      D.13000 = -1B;
      return D.13000;
      <D.12226>:
      D.13001 = (long int) fd;
      handle = (void *) D.13001;
      {
        struct __pthread_unwind_buf_t __cancel_buf;
        void (*<Tbf>) (void *) __cancel_routine;
        void * __cancel_arg;
        int __not_first_call;

        try
          {
            __cancel_routine = mono_mutex_unlock_in_cleanup;
            __cancel_arg = &stdhandle_mutex;
            __not_first_call = __sigsetjmp (&__cancel_buf.__cancel_jmp_buf, 0);
            D.13002 = (long int) __not_first_call;
            D.13003 = __builtin_expect (D.13002, 0);
            if (D.13003 != 0) goto <D.13004>; else goto <D.13005>;
            <D.13004>:
            __cancel_routine (__cancel_arg);
            __pthread_unwind_next (&__cancel_buf);
            <D.13005>:
            __pthread_register_cancel (&__cancel_buf);
            thr_ret = pthread_mutex_lock (&stdhandle_mutex);
            D.13006 = thr_ret != 0;
            D.13007 = (long int) D.13006;
            D.13008 = __builtin_expect (D.13007, 0);
            if (D.13008 != 0) goto <D.13009>; else goto <D.13010>;
            <D.13009>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "io.c", 2187, "thr_ret == 0");
            <D.13010>:
            ok = _wapi_lookup_handle (handle, 2, &file_handle);
            if (ok == 0) goto <D.13011>; else goto <D.13012>;
            <D.13011>:
            handle = _wapi_stdhandle_create (fd, name);
            if (handle == -1B) goto <D.13013>; else goto <D.13014>;
            <D.13013>:
            SetLastError (18);
            goto done;
            <D.13014>:
            goto <D.13015>;
            <D.13012>:
            _wapi_handle_ref (handle);
            <D.13015>:
            done:
            thr_ret = pthread_mutex_unlock (&stdhandle_mutex);
            D.13006 = thr_ret != 0;
            D.13007 = (long int) D.13006;
            D.13008 = __builtin_expect (D.13007, 0);
            if (D.13008 != 0) goto <D.13016>; else goto <D.13017>;
            <D.13016>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "io.c", 2206, "thr_ret == 0");
            <D.13017>:
            __pthread_unregister_cancel (&__cancel_buf);
            if (0 != 0) goto <D.13018>; else goto <D.13019>;
            <D.13018>:
            __cancel_routine (__cancel_arg);
            <D.13019>:
          }
        finally
          {
            __cancel_buf = {CLOBBER};
          }
      }
      D.13000 = handle;
      return D.13000;
    }
  finally
    {
      file_handle = {CLOBBER};
    }
}


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

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


ReadFile (void * handle, void * buffer, guint32 numbytes, guint32 * bytesread, struct WapiOverlapped * overlapped)
{
  gboolean (*<T1b5f>) (void *, void *, guint32, guint32 *, struct WapiOverlapped *) D.13028;
  gboolean D.13031;
  WapiHandleType type;

  type = _wapi_handle_type (handle);
  D.13028 = io_ops[type].readfile;
  if (D.13028 == 0B) goto <D.13029>; else goto <D.13030>;
  <D.13029>:
  SetLastError (6);
  D.13031 = 0;
  return D.13031;
  <D.13030>:
  D.13028 = io_ops[type].readfile;
  D.13031 = D.13028 (handle, buffer, numbytes, bytesread, overlapped);
  return D.13031;
}


pipe_write (void * handle, const void * buffer, guint32 numbytes, guint32 * byteswritten, struct WapiOverlapped * overlapped)
{
  gboolean D.13035;
  struct _WapiHandle_file * pipe_handle.15;
  long unsigned int D.13039;
  long unsigned int D.13040;
  long unsigned int D.13043;
  long int D.13044;
  int * D.13046;
  int D.13047;
  int D.13049;
  unsigned int ret.16;
  struct _WapiHandle_file * pipe_handle;
  gboolean ok;
  int ret;
  int fd;
  static const char __func__[11] = "pipe_write";

  try
    {
      ok = _wapi_lookup_handle (handle, 10, &pipe_handle);
      if (ok == 0) goto <D.13033>; else goto <D.13034>;
      <D.13033>:
      monoeg_g_log (0B, 16, "%s: error looking up pipe handle %p", &__func__, handle);
      SetLastError (6);
      D.13035 = 0;
      return D.13035;
      <D.13034>:
      pipe_handle.15 = pipe_handle;
      fd = pipe_handle.15->fd;
      if (byteswritten != 0B) goto <D.13037>; else goto <D.13038>;
      <D.13037>:
      *byteswritten = 0;
      <D.13038>:
      pipe_handle.15 = pipe_handle;
      D.13039 = BIT_FIELD_REF <*pipe_handle.15, 64, 192>;
      D.13040 = D.13039 & 1342177280;
      if (D.13040 == 0) goto <D.13041>; else goto <D.13042>;
      <D.13041>:
      SetLastError (5);
      D.13035 = 0;
      return D.13035;
      <D.13042>:
      <D.12077>:
      D.13043 = (long unsigned int) numbytes;
      D.13044 = write (fd, buffer, D.13043);
      ret = (int) D.13044;
      if (ret == -1) goto <D.13045>; else goto <D.12078>;
      <D.13045>:
      D.13046 = __errno_location ();
      D.13047 = *D.13046;
      if (D.13047 == 4) goto <D.13048>; else goto <D.12078>;
      <D.13048>:
      D.13049 = _wapi_thread_cur_apc_pending ();
      if (D.13049 == 0) goto <D.12077>; else goto <D.12078>;
      <D.12078>:
      if (ret == -1) goto <D.13050>; else goto <D.13051>;
      <D.13050>:
      D.13046 = __errno_location ();
      D.13047 = *D.13046;
      if (D.13047 == 4) goto <D.13052>; else goto <D.13053>;
      <D.13052>:
      ret = 0;
      goto <D.13054>;
      <D.13053>:
      _wapi_set_last_error_from_errno ();
      D.13035 = 0;
      return D.13035;
      <D.13054>:
      <D.13051>:
      if (byteswritten != 0B) goto <D.13055>; else goto <D.13056>;
      <D.13055>:
      ret.16 = (unsigned int) ret;
      *byteswritten = ret.16;
      <D.13056>:
      D.13035 = 1;
      return D.13035;
    }
  finally
    {
      pipe_handle = {CLOBBER};
    }
}


pipe_read (void * handle, void * buffer, guint32 numbytes, guint32 * bytesread, struct WapiOverlapped * overlapped)
{
  gboolean D.13062;
  struct _WapiHandle_file * pipe_handle.17;
  unsigned int D.13066;
  signed int D.13067;
  unsigned int D.13070;
  long unsigned int D.13073;
  long int D.13074;
  int * D.13076;
  int D.13077;
  int D.13079;
  unsigned int ret.18;
  struct _WapiHandle_file * pipe_handle;
  gboolean ok;
  int ret;
  int fd;
  static const char __func__[10] = "pipe_read";

  try
    {
      ok = _wapi_lookup_handle (handle, 10, &pipe_handle);
      if (ok == 0) goto <D.13060>; else goto <D.13061>;
      <D.13060>:
      monoeg_g_log (0B, 16, "%s: error looking up pipe handle %p", &__func__, handle);
      SetLastError (6);
      D.13062 = 0;
      return D.13062;
      <D.13061>:
      pipe_handle.17 = pipe_handle;
      fd = pipe_handle.17->fd;
      if (bytesread != 0B) goto <D.13064>; else goto <D.13065>;
      <D.13064>:
      *bytesread = 0;
      <D.13065>:
      pipe_handle.17 = pipe_handle;
      D.13066 = pipe_handle.17->fileaccess;
      D.13067 = (signed int) D.13066;
      if (D.13067 >= 0) goto <D.13068>; else goto <D.13069>;
      <D.13068>:
      pipe_handle.17 = pipe_handle;
      D.13066 = pipe_handle.17->fileaccess;
      D.13070 = D.13066 & 268435456;
      if (D.13070 == 0) goto <D.13071>; else goto <D.13072>;
      <D.13071>:
      SetLastError (5);
      D.13062 = 0;
      return D.13062;
      <D.13072>:
      <D.13069>:
      <D.12063>:
      D.13073 = (long unsigned int) numbytes;
      D.13074 = read (fd, buffer, D.13073);
      ret = (int) D.13074;
      if (ret == -1) goto <D.13075>; else goto <D.12064>;
      <D.13075>:
      D.13076 = __errno_location ();
      D.13077 = *D.13076;
      if (D.13077 == 4) goto <D.13078>; else goto <D.12064>;
      <D.13078>:
      D.13079 = _wapi_thread_cur_apc_pending ();
      if (D.13079 == 0) goto <D.12063>; else goto <D.12064>;
      <D.12064>:
      if (ret == -1) goto <D.13080>; else goto <D.13081>;
      <D.13080>:
      D.13076 = __errno_location ();
      D.13077 = *D.13076;
      if (D.13077 == 4) goto <D.13082>; else goto <D.13083>;
      <D.13082>:
      ret = 0;
      goto <D.13084>;
      <D.13083>:
      _wapi_set_last_error_from_errno ();
      D.13062 = 0;
      return D.13062;
      <D.13084>:
      <D.13081>:
      if (bytesread != 0B) goto <D.13085>; else goto <D.13086>;
      <D.13085>:
      ret.18 = (unsigned int) ret;
      *bytesread = ret.18;
      <D.13086>:
      D.13062 = 1;
      return D.13062;
    }
  finally
    {
      pipe_handle = {CLOBBER};
    }
}


pipe_getfiletype ()
{
  WapiFileType D.13090;

  D.13090 = 3;
  return D.13090;
}


console_write (void * handle, const void * buffer, guint32 numbytes, guint32 * byteswritten, struct WapiOverlapped * overlapped)
{
  gboolean D.13094;
  struct _WapiHandle_file * console_handle.19;
  long unsigned int D.13098;
  long unsigned int D.13099;
  long unsigned int D.13102;
  long int D.13103;
  int * D.13105;
  int D.13106;
  int D.13108;
  unsigned int ret.20;
  struct _WapiHandle_file * console_handle;
  gboolean ok;
  int ret;
  int fd;
  static const char __func__[14] = "console_write";

  try
    {
      ok = _wapi_lookup_handle (handle, 2, &console_handle);
      if (ok == 0) goto <D.13092>; else goto <D.13093>;
      <D.13092>:
      monoeg_g_log (0B, 16, "%s: error looking up console handle %p", &__func__, handle);
      SetLastError (6);
      D.13094 = 0;
      return D.13094;
      <D.13093>:
      console_handle.19 = console_handle;
      fd = console_handle.19->fd;
      if (byteswritten != 0B) goto <D.13096>; else goto <D.13097>;
      <D.13096>:
      *byteswritten = 0;
      <D.13097>:
      console_handle.19 = console_handle;
      D.13098 = BIT_FIELD_REF <*console_handle.19, 64, 192>;
      D.13099 = D.13098 & 1342177280;
      if (D.13099 == 0) goto <D.13100>; else goto <D.13101>;
      <D.13100>:
      SetLastError (5);
      D.13094 = 0;
      return D.13094;
      <D.13101>:
      <D.12040>:
      D.13102 = (long unsigned int) numbytes;
      D.13103 = write (fd, buffer, D.13102);
      ret = (int) D.13103;
      if (ret == -1) goto <D.13104>; else goto <D.12041>;
      <D.13104>:
      D.13105 = __errno_location ();
      D.13106 = *D.13105;
      if (D.13106 == 4) goto <D.13107>; else goto <D.12041>;
      <D.13107>:
      D.13108 = _wapi_thread_cur_apc_pending ();
      if (D.13108 == 0) goto <D.12040>; else goto <D.12041>;
      <D.12041>:
      if (ret == -1) goto <D.13109>; else goto <D.13110>;
      <D.13109>:
      D.13105 = __errno_location ();
      D.13106 = *D.13105;
      if (D.13106 == 4) goto <D.13111>; else goto <D.13112>;
      <D.13111>:
      ret = 0;
      goto <D.13113>;
      <D.13112>:
      _wapi_set_last_error_from_errno ();
      D.13094 = 0;
      return D.13094;
      <D.13113>:
      <D.13110>:
      if (byteswritten != 0B) goto <D.13114>; else goto <D.13115>;
      <D.13114>:
      ret.20 = (unsigned int) ret;
      *byteswritten = ret.20;
      <D.13115>:
      D.13094 = 1;
      return D.13094;
    }
  finally
    {
      console_handle = {CLOBBER};
    }
}


console_read (void * handle, void * buffer, guint32 numbytes, guint32 * bytesread, struct WapiOverlapped * overlapped)
{
  gboolean D.13121;
  struct _WapiHandle_file * console_handle.21;
  unsigned int D.13125;
  signed int D.13126;
  unsigned int D.13129;
  long unsigned int D.13132;
  long int D.13133;
  int * D.13135;
  int D.13136;
  int D.13138;
  unsigned int ret.22;
  struct _WapiHandle_file * console_handle;
  gboolean ok;
  int ret;
  int fd;
  static const char __func__[13] = "console_read";

  try
    {
      ok = _wapi_lookup_handle (handle, 2, &console_handle);
      if (ok == 0) goto <D.13119>; else goto <D.13120>;
      <D.13119>:
      monoeg_g_log (0B, 16, "%s: error looking up console handle %p", &__func__, handle);
      SetLastError (6);
      D.13121 = 0;
      return D.13121;
      <D.13120>:
      console_handle.21 = console_handle;
      fd = console_handle.21->fd;
      if (bytesread != 0B) goto <D.13123>; else goto <D.13124>;
      <D.13123>:
      *bytesread = 0;
      <D.13124>:
      console_handle.21 = console_handle;
      D.13125 = console_handle.21->fileaccess;
      D.13126 = (signed int) D.13125;
      if (D.13126 >= 0) goto <D.13127>; else goto <D.13128>;
      <D.13127>:
      console_handle.21 = console_handle;
      D.13125 = console_handle.21->fileaccess;
      D.13129 = D.13125 & 268435456;
      if (D.13129 == 0) goto <D.13130>; else goto <D.13131>;
      <D.13130>:
      SetLastError (5);
      D.13121 = 0;
      return D.13121;
      <D.13131>:
      <D.13128>:
      <D.12026>:
      D.13132 = (long unsigned int) numbytes;
      D.13133 = read (fd, buffer, D.13132);
      ret = (int) D.13133;
      if (ret == -1) goto <D.13134>; else goto <D.12027>;
      <D.13134>:
      D.13135 = __errno_location ();
      D.13136 = *D.13135;
      if (D.13136 == 4) goto <D.13137>; else goto <D.12027>;
      <D.13137>:
      D.13138 = _wapi_thread_cur_apc_pending ();
      if (D.13138 == 0) goto <D.12026>; else goto <D.12027>;
      <D.12027>:
      if (ret == -1) goto <D.13139>; else goto <D.13140>;
      <D.13139>:
      _wapi_set_last_error_from_errno ();
      D.13121 = 0;
      return D.13121;
      <D.13140>:
      if (bytesread != 0B) goto <D.13141>; else goto <D.13142>;
      <D.13141>:
      ret.22 = (unsigned int) ret;
      *bytesread = ret.22;
      <D.13142>:
      D.13121 = 1;
      return D.13121;
    }
  finally
    {
      console_handle = {CLOBBER};
    }
}


console_getfiletype ()
{
  WapiFileType D.13146;

  D.13146 = 2;
  return D.13146;
}


file_setfiletime (void * handle, const struct WapiFileTime * create_time, const struct WapiFileTime * last_access, const struct WapiFileTime * last_write)
{
  gboolean D.13150;
  struct _WapiHandle_file * file_handle.23;
  long unsigned int D.13152;
  long unsigned int D.13153;
  gchar * D.13156;
  unsigned int D.13163;
  long unsigned int D.13164;
  long unsigned int D.13165;
  unsigned int D.13166;
  long unsigned int D.13167;
  long long unsigned int D.13170;
  long long unsigned int D.13171;
  long int D.13172;
  long int D.13174;
  unsigned int D.13177;
  long unsigned int D.13178;
  long unsigned int D.13179;
  unsigned int D.13180;
  long unsigned int D.13181;
  long long unsigned int D.13184;
  long long unsigned int D.13185;
  long int D.13186;
  long int D.13188;
  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.13148>; else goto <D.13149>;
      <D.13148>:
      monoeg_g_log (0B, 16, "%s: error looking up file handle %p", &__func__, handle);
      SetLastError (6);
      D.13150 = 0;
      return D.13150;
      <D.13149>:
      file_handle.23 = file_handle;
      fd = file_handle.23->fd;
      file_handle.23 = file_handle;
      D.13152 = BIT_FIELD_REF <*file_handle.23, 64, 192>;
      D.13153 = D.13152 & 1342177280;
      if (D.13153 == 0) goto <D.13154>; else goto <D.13155>;
      <D.13154>:
      SetLastError (5);
      D.13150 = 0;
      return D.13150;
      <D.13155>:
      file_handle.23 = file_handle;
      D.13156 = file_handle.23->filename;
      if (D.13156 == 0B) goto <D.13157>; else goto <D.13158>;
      <D.13157>:
      SetLastError (6);
      D.13150 = 0;
      return D.13150;
      <D.13158>:
      ret = fstat (fd, &statbuf);
      if (ret == -1) goto <D.13159>; else goto <D.13160>;
      <D.13159>:
      SetLastError (87);
      D.13150 = 0;
      return D.13150;
      <D.13160>:
      if (last_access != 0B) goto <D.13161>; else goto <D.13162>;
      <D.13161>:
      D.13163 = last_access->dwHighDateTime;
      D.13164 = (long unsigned int) D.13163;
      D.13165 = D.13164 << 32;
      D.13166 = last_access->dwLowDateTime;
      D.13167 = (long unsigned int) D.13166;
      access_ticks = D.13165 + D.13167;
      if (access_ticks <= 116444735999999999) goto <D.13168>; else goto <D.13169>;
      <D.13168>:
      SetLastError (87);
      D.13150 = 0;
      return D.13150;
      <D.13169>:
      D.13170 = access_ticks + 18330299337709551616;
      D.13171 = D.13170 / 10000000;
      D.13172 = (long int) D.13171;
      utbuf.actime = D.13172;
      goto <D.13173>;
      <D.13162>:
      D.13174 = statbuf.st_atim.tv_sec;
      utbuf.actime = D.13174;
      <D.13173>:
      if (last_write != 0B) goto <D.13175>; else goto <D.13176>;
      <D.13175>:
      D.13177 = last_write->dwHighDateTime;
      D.13178 = (long unsigned int) D.13177;
      D.13179 = D.13178 << 32;
      D.13180 = last_write->dwLowDateTime;
      D.13181 = (long unsigned int) D.13180;
      write_ticks = D.13179 + D.13181;
      if (write_ticks <= 116444735999999999) goto <D.13182>; else goto <D.13183>;
      <D.13182>:
      SetLastError (87);
      D.13150 = 0;
      return D.13150;
      <D.13183>:
      D.13184 = write_ticks + 18330299337709551616;
      D.13185 = D.13184 / 10000000;
      D.13186 = (long int) D.13185;
      utbuf.modtime = D.13186;
      goto <D.13187>;
      <D.13176>:
      D.13188 = statbuf.st_mtim.tv_sec;
      utbuf.modtime = D.13188;
      <D.13187>:
      file_handle.23 = file_handle;
      D.13156 = file_handle.23->filename;
      ret = _wapi_utime (D.13156, &utbuf);
      if (ret == -1) goto <D.13189>; else goto <D.13190>;
      <D.13189>:
      SetLastError (87);
      D.13150 = 0;
      return D.13150;
      <D.13190>:
      D.13150 = 1;
      return D.13150;
    }
  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.13195;
  struct _WapiHandle_file * file_handle.24;
  unsigned int D.13197;
  signed int D.13198;
  unsigned int D.13201;
  long int D.13206;
  long int D.13207;
  long unsigned int D.13210;
  long unsigned int D.13211;
  long unsigned int D.13213;
  long unsigned int D.13214;
  long int D.13215;
  long unsigned int D.13216;
  long unsigned int D.13217;
  unsigned int D.13220;
  long unsigned int D.13221;
  unsigned int D.13222;
  unsigned int D.13225;
  long unsigned int D.13226;
  unsigned int D.13227;
  unsigned int D.13230;
  long unsigned int D.13231;
  unsigned int D.13232;
  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.13193>; else goto <D.13194>;
      <D.13193>:
      monoeg_g_log (0B, 16, "%s: error looking up file handle %p", &__func__, handle);
      SetLastError (6);
      D.13195 = 0;
      return D.13195;
      <D.13194>:
      file_handle.24 = file_handle;
      fd = file_handle.24->fd;
      file_handle.24 = file_handle;
      D.13197 = file_handle.24->fileaccess;
      D.13198 = (signed int) D.13197;
      if (D.13198 >= 0) goto <D.13199>; else goto <D.13200>;
      <D.13199>:
      file_handle.24 = file_handle;
      D.13197 = file_handle.24->fileaccess;
      D.13201 = D.13197 & 268435456;
      if (D.13201 == 0) goto <D.13202>; else goto <D.13203>;
      <D.13202>:
      SetLastError (5);
      D.13195 = 0;
      return D.13195;
      <D.13203>:
      <D.13200>:
      ret = fstat (fd, &statbuf);
      if (ret == -1) goto <D.13204>; else goto <D.13205>;
      <D.13204>:
      _wapi_set_last_error_from_errno ();
      D.13195 = 0;
      return D.13195;
      <D.13205>:
      D.13206 = statbuf.st_atim.tv_sec;
      D.13207 = statbuf.st_ctim.tv_sec;
      if (D.13206 < D.13207) goto <D.13208>; else goto <D.13209>;
      <D.13208>:
      D.13206 = statbuf.st_atim.tv_sec;
      D.13210 = (long unsigned int) D.13206;
      D.13211 = D.13210 * 10000000;
      create_ticks = D.13211 + 116444736000000000;
      goto <D.13212>;
      <D.13209>:
      D.13207 = statbuf.st_ctim.tv_sec;
      D.13213 = (long unsigned int) D.13207;
      D.13214 = D.13213 * 10000000;
      create_ticks = D.13214 + 116444736000000000;
      <D.13212>:
      D.13206 = statbuf.st_atim.tv_sec;
      D.13210 = (long unsigned int) D.13206;
      D.13211 = D.13210 * 10000000;
      access_ticks = D.13211 + 116444736000000000;
      D.13215 = statbuf.st_mtim.tv_sec;
      D.13216 = (long unsigned int) D.13215;
      D.13217 = D.13216 * 10000000;
      write_ticks = D.13217 + 116444736000000000;
      if (create_time != 0B) goto <D.13218>; else goto <D.13219>;
      <D.13218>:
      D.13220 = (unsigned int) create_ticks;
      create_time->dwLowDateTime = D.13220;
      D.13221 = create_ticks >> 32;
      D.13222 = (unsigned int) D.13221;
      create_time->dwHighDateTime = D.13222;
      <D.13219>:
      if (last_access != 0B) goto <D.13223>; else goto <D.13224>;
      <D.13223>:
      D.13225 = (unsigned int) access_ticks;
      last_access->dwLowDateTime = D.13225;
      D.13226 = access_ticks >> 32;
      D.13227 = (unsigned int) D.13226;
      last_access->dwHighDateTime = D.13227;
      <D.13224>:
      if (last_write != 0B) goto <D.13228>; else goto <D.13229>;
      <D.13228>:
      D.13230 = (unsigned int) write_ticks;
      last_write->dwLowDateTime = D.13230;
      D.13231 = write_ticks >> 32;
      D.13232 = (unsigned int) D.13231;
      last_write->dwHighDateTime = D.13232;
      <D.13229>:
      D.13195 = 1;
      return D.13195;
    }
  finally
    {
      file_handle = {CLOBBER};
      statbuf = {CLOBBER};
    }
}


file_getfilesize (void * handle, guint32 * highsize)
{
  guint32 D.13237;
  struct _WapiHandle_file * file_handle.25;
  unsigned int D.13239;
  signed int D.13240;
  long unsigned int D.13243;
  long unsigned int D.13244;
  unsigned int D.13249;
  unsigned int D.13250;
  int D.13253;
  long unsigned int bigsize.26;
  long unsigned int D.13259;
  unsigned int D.13260;
  long int D.13261;
  long int D.13264;
  unsigned int D.13265;
  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.13235>; else goto <D.13236>;
      <D.13235>:
      monoeg_g_log (0B, 16, "%s: error looking up file handle %p", &__func__, handle);
      SetLastError (6);
      D.13237 = 4294967295;
      return D.13237;
      <D.13236>:
      file_handle.25 = file_handle;
      fd = file_handle.25->fd;
      file_handle.25 = file_handle;
      D.13239 = file_handle.25->fileaccess;
      D.13240 = (signed int) D.13239;
      if (D.13240 >= 0) goto <D.13241>; else goto <D.13242>;
      <D.13241>:
      file_handle.25 = file_handle;
      D.13243 = BIT_FIELD_REF <*file_handle.25, 64, 192>;
      D.13244 = D.13243 & 1342177280;
      if (D.13244 == 0) goto <D.13245>; else goto <D.13246>;
      <D.13245>:
      SetLastError (5);
      D.13237 = 4294967295;
      return D.13237;
      <D.13246>:
      <D.13242>:
      SetLastError (0);
      ret = fstat (fd, &statbuf);
      if (ret == -1) goto <D.13247>; else goto <D.13248>;
      <D.13247>:
      _wapi_set_last_error_from_errno ();
      D.13237 = 4294967295;
      return D.13237;
      <D.13248>:
      D.13249 = statbuf.st_mode;
      D.13250 = D.13249 & 61440;
      if (D.13250 == 24576) goto <D.13251>; else goto <D.13252>;
      <D.13251>:
      {
        guint64 bigsize;

        try
          {
            D.13253 = ioctl (fd, 1074270834, &bigsize);
            if (D.13253 < 0) goto <D.13254>; else goto <D.13255>;
            <D.13254>:
            _wapi_set_last_error_from_errno ();
            D.13237 = 4294967295;
            return D.13237;
            <D.13255>:
            bigsize.26 = bigsize;
            size = (guint32) bigsize.26;
            if (highsize != 0B) goto <D.13257>; else goto <D.13258>;
            <D.13257>:
            bigsize.26 = bigsize;
            D.13259 = bigsize.26 >> 32;
            D.13260 = (unsigned int) D.13259;
            *highsize = D.13260;
            <D.13258>:
            D.13237 = size;
            return D.13237;
          }
        finally
          {
            bigsize = {CLOBBER};
          }
      }
      <D.13252>:
      D.13261 = statbuf.st_size;
      size = (guint32) D.13261;
      if (highsize != 0B) goto <D.13262>; else goto <D.13263>;
      <D.13262>:
      D.13261 = statbuf.st_size;
      D.13264 = D.13261 >> 32;
      D.13265 = (unsigned int) D.13264;
      *highsize = D.13265;
      <D.13263>:
      D.13237 = size;
      return D.13237;
    }
  finally
    {
      file_handle = {CLOBBER};
      statbuf = {CLOBBER};
    }
}


file_setendoffile (void * handle)
{
  gboolean D.13271;
  struct _WapiHandle_file * file_handle.27;
  long unsigned int D.13273;
  long unsigned int D.13274;
  int * D.13282;
  int D.13283;
  int D.13285;
  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.13269>; else goto <D.13270>;
      <D.13269>:
      monoeg_g_log (0B, 16, "%s: error looking up file handle %p", &__func__, handle);
      SetLastError (6);
      D.13271 = 0;
      return D.13271;
      <D.13270>:
      file_handle.27 = file_handle;
      fd = file_handle.27->fd;
      file_handle.27 = file_handle;
      D.13273 = BIT_FIELD_REF <*file_handle.27, 64, 192>;
      D.13274 = D.13273 & 1342177280;
      if (D.13274 == 0) goto <D.13275>; else goto <D.13276>;
      <D.13275>:
      SetLastError (5);
      D.13271 = 0;
      return D.13271;
      <D.13276>:
      ret = fstat (fd, &statbuf);
      if (ret == -1) goto <D.13277>; else goto <D.13278>;
      <D.13277>:
      _wapi_set_last_error_from_errno ();
      D.13271 = 0;
      return D.13271;
      <D.13278>:
      size = statbuf.st_size;
      pos = lseek (fd, 0, 1);
      if (pos == -1) goto <D.13279>; else goto <D.13280>;
      <D.13279>:
      _wapi_set_last_error_from_errno ();
      D.13271 = 0;
      return D.13271;
      <D.13280>:
      <D.11961>:
      ret = ftruncate (fd, pos);
      if (ret == -1) goto <D.13281>; else goto <D.11962>;
      <D.13281>:
      D.13282 = __errno_location ();
      D.13283 = *D.13282;
      if (D.13283 == 4) goto <D.13284>; else goto <D.11962>;
      <D.13284>:
      D.13285 = _wapi_thread_cur_apc_pending ();
      if (D.13285 == 0) goto <D.11961>; else goto <D.11962>;
      <D.11962>:
      if (ret == -1) goto <D.13286>; else goto <D.13287>;
      <D.13286>:
      _wapi_set_last_error_from_errno ();
      D.13271 = 0;
      return D.13271;
      <D.13287>:
      D.13271 = 1;
      return D.13271;
    }
  finally
    {
      file_handle = {CLOBBER};
      statbuf = {CLOBBER};
    }
}


file_seek (void * handle, gint32 movedistance, gint32 * highmovedistance, WapiSeekMethod method)
{
  guint32 D.13292;
  struct _WapiHandle_file * file_handle.28;
  unsigned int D.13294;
  signed int D.13295;
  long unsigned int D.13298;
  long unsigned int D.13299;
  int D.13305;
  long int D.13306;
  long int D.13307;
  unsigned int movedistance.29;
  long int D.13309;
  long int D.13314;
  int D.13315;
  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.13290>; else goto <D.13291>;
      <D.13290>:
      monoeg_g_log (0B, 16, "%s: error looking up file handle %p", &__func__, handle);
      SetLastError (6);
      D.13292 = 4294967295;
      return D.13292;
      <D.13291>:
      file_handle.28 = file_handle;
      fd = file_handle.28->fd;
      file_handle.28 = file_handle;
      D.13294 = file_handle.28->fileaccess;
      D.13295 = (signed int) D.13294;
      if (D.13295 >= 0) goto <D.13296>; else goto <D.13297>;
      <D.13296>:
      file_handle.28 = file_handle;
      D.13298 = BIT_FIELD_REF <*file_handle.28, 64, 192>;
      D.13299 = D.13298 & 1342177280;
      if (D.13299 == 0) goto <D.13300>; else goto <D.13301>;
      <D.13300>:
      SetLastError (5);
      D.13292 = 4294967295;
      return D.13292;
      <D.13301>:
      <D.13297>:
      switch (method) <default: <D.11949>, case 0: <D.11945>, case 1: <D.11947>, case 2: <D.11948>>
      <D.11945>:
      whence = 0;
      goto <D.11946>;
      <D.11947>:
      whence = 1;
      goto <D.11946>;
      <D.11948>:
      whence = 2;
      goto <D.11946>;
      <D.11949>:
      SetLastError (87);
      D.13292 = 4294967295;
      return D.13292;
      <D.11946>:
      if (highmovedistance == 0B) goto <D.13302>; else goto <D.13303>;
      <D.13302>:
      offset = (gint64) movedistance;
      goto <D.13304>;
      <D.13303>:
      D.13305 = *highmovedistance;
      D.13306 = (long int) D.13305;
      D.13307 = D.13306 << 32;
      movedistance.29 = (unsigned int) movedistance;
      D.13309 = (long int) movedistance.29;
      offset = D.13307 | D.13309;
      <D.13304>:
      newpos = lseek (fd, offset, whence);
      if (newpos == -1) goto <D.13310>; else goto <D.13311>;
      <D.13310>:
      _wapi_set_last_error_from_errno ();
      D.13292 = 4294967295;
      return D.13292;
      <D.13311>:
      ret = (guint32) newpos;
      if (highmovedistance != 0B) goto <D.13312>; else goto <D.13313>;
      <D.13312>:
      D.13314 = newpos >> 32;
      D.13315 = (int) D.13314;
      *highmovedistance = D.13315;
      <D.13313>:
      D.13292 = ret;
      return D.13292;
    }
  finally
    {
      file_handle = {CLOBBER};
    }
}


file_flush (void * handle)
{
  gboolean D.13320;
  struct _WapiHandle_file * file_handle.30;
  long unsigned int D.13322;
  long unsigned int D.13323;
  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.13318>; else goto <D.13319>;
      <D.13318>:
      monoeg_g_log (0B, 16, "%s: error looking up file handle %p", &__func__, handle);
      SetLastError (6);
      D.13320 = 0;
      return D.13320;
      <D.13319>:
      file_handle.30 = file_handle;
      fd = file_handle.30->fd;
      file_handle.30 = file_handle;
      D.13322 = BIT_FIELD_REF <*file_handle.30, 64, 192>;
      D.13323 = D.13322 & 1342177280;
      if (D.13323 == 0) goto <D.13324>; else goto <D.13325>;
      <D.13324>:
      SetLastError (5);
      D.13320 = 0;
      return D.13320;
      <D.13325>:
      ret = fsync (fd);
      if (ret == -1) goto <D.13326>; else goto <D.13327>;
      <D.13326>:
      _wapi_set_last_error_from_errno ();
      D.13320 = 0;
      return D.13320;
      <D.13327>:
      D.13320 = 1;
      return D.13320;
    }
  finally
    {
      file_handle = {CLOBBER};
    }
}


file_write (void * handle, const void * buffer, guint32 numbytes, guint32 * byteswritten, struct WapiOverlapped * overlapped)
{
  gboolean D.13332;
  struct _WapiHandle_file * file_handle.31;
  long unsigned int D.13336;
  long unsigned int D.13337;
  int lock_while_writing.32;
  long int D.13345;
  int D.13346;
  long unsigned int D.13349;
  long int D.13350;
  int * D.13352;
  int D.13353;
  int D.13355;
  unsigned int ret.33;
  struct _WapiHandle_file * file_handle;
  gboolean ok;
  int ret;
  int fd;
  off_t current_pos;
  static const char __func__[11] = "file_write";

  try
    {
      current_pos = 0;
      ok = _wapi_lookup_handle (handle, 1, &file_handle);
      if (ok == 0) goto <D.13330>; else goto <D.13331>;
      <D.13330>:
      monoeg_g_log (0B, 16, "%s: error looking up file handle %p", &__func__, handle);
      SetLastError (6);
      D.13332 = 0;
      return D.13332;
      <D.13331>:
      file_handle.31 = file_handle;
      fd = file_handle.31->fd;
      if (byteswritten != 0B) goto <D.13334>; else goto <D.13335>;
      <D.13334>:
      *byteswritten = 0;
      <D.13335>:
      file_handle.31 = file_handle;
      D.13336 = BIT_FIELD_REF <*file_handle.31, 64, 192>;
      D.13337 = D.13336 & 1342177280;
      if (D.13337 == 0) goto <D.13338>; else goto <D.13339>;
      <D.13338>:
      SetLastError (5);
      D.13332 = 0;
      return D.13332;
      <D.13339>:
      lock_while_writing.32 = lock_while_writing;
      if (lock_while_writing.32 != 0) goto <D.13341>; else goto <D.13342>;
      <D.13341>:
      current_pos = lseek (fd, 0, 1);
      if (current_pos == -1) goto <D.13343>; else goto <D.13344>;
      <D.13343>:
      _wapi_set_last_error_from_errno ();
      D.13332 = 0;
      return D.13332;
      <D.13344>:
      D.13345 = (long int) numbytes;
      D.13346 = _wapi_lock_file_region (fd, current_pos, D.13345);
      if (D.13346 == 0) goto <D.13347>; else goto <D.13348>;
      <D.13347>:
      D.13332 = 0;
      return D.13332;
      <D.13348>:
      <D.13342>:
      <D.11921>:
      D.13349 = (long unsigned int) numbytes;
      D.13350 = write (fd, buffer, D.13349);
      ret = (int) D.13350;
      if (ret == -1) goto <D.13351>; else goto <D.11922>;
      <D.13351>:
      D.13352 = __errno_location ();
      D.13353 = *D.13352;
      if (D.13353 == 4) goto <D.13354>; else goto <D.11922>;
      <D.13354>:
      D.13355 = _wapi_thread_cur_apc_pending ();
      if (D.13355 == 0) goto <D.11921>; else goto <D.11922>;
      <D.11922>:
      lock_while_writing.32 = lock_while_writing;
      if (lock_while_writing.32 != 0) goto <D.13356>; else goto <D.13357>;
      <D.13356>:
      D.13345 = (long int) numbytes;
      _wapi_unlock_file_region (fd, current_pos, D.13345);
      <D.13357>:
      if (ret == -1) goto <D.13358>; else goto <D.13359>;
      <D.13358>:
      D.13352 = __errno_location ();
      D.13353 = *D.13352;
      if (D.13353 == 4) goto <D.13360>; else goto <D.13361>;
      <D.13360>:
      ret = 0;
      goto <D.13362>;
      <D.13361>:
      _wapi_set_last_error_from_errno ();
      D.13332 = 0;
      return D.13332;
      <D.13362>:
      <D.13359>:
      if (byteswritten != 0B) goto <D.13363>; else goto <D.13364>;
      <D.13363>:
      ret.33 = (unsigned int) ret;
      *byteswritten = ret.33;
      <D.13364>:
      D.13332 = 1;
      return D.13332;
    }
  finally
    {
      file_handle = {CLOBBER};
    }
}


file_read (void * handle, void * buffer, guint32 numbytes, guint32 * bytesread, struct WapiOverlapped * overlapped)
{
  gboolean D.13370;
  struct _WapiHandle_file * file_handle.34;
  unsigned int D.13374;
  signed int D.13375;
  unsigned int D.13378;
  long unsigned int D.13381;
  long int D.13382;
  int * D.13384;
  int D.13385;
  int D.13387;
  int D.13390;
  unsigned int D.13391;
  unsigned int ret.35;
  struct _WapiHandle_file * file_handle;
  gboolean ok;
  int fd;
  int ret;
  static const char __func__[10] = "file_read";

  try
    {
      ok = _wapi_lookup_handle (handle, 1, &file_handle);
      if (ok == 0) goto <D.13368>; else goto <D.13369>;
      <D.13368>:
      monoeg_g_log (0B, 16, "%s: error looking up file handle %p", &__func__, handle);
      SetLastError (6);
      D.13370 = 0;
      return D.13370;
      <D.13369>:
      file_handle.34 = file_handle;
      fd = file_handle.34->fd;
      if (bytesread != 0B) goto <D.13372>; else goto <D.13373>;
      <D.13372>:
      *bytesread = 0;
      <D.13373>:
      file_handle.34 = file_handle;
      D.13374 = file_handle.34->fileaccess;
      D.13375 = (signed int) D.13374;
      if (D.13375 >= 0) goto <D.13376>; else goto <D.13377>;
      <D.13376>:
      file_handle.34 = file_handle;
      D.13374 = file_handle.34->fileaccess;
      D.13378 = D.13374 & 268435456;
      if (D.13378 == 0) goto <D.13379>; else goto <D.13380>;
      <D.13379>:
      SetLastError (5);
      D.13370 = 0;
      return D.13370;
      <D.13380>:
      <D.13377>:
      <D.11905>:
      D.13381 = (long unsigned int) numbytes;
      D.13382 = read (fd, buffer, D.13381);
      ret = (int) D.13382;
      if (ret == -1) goto <D.13383>; else goto <D.11906>;
      <D.13383>:
      D.13384 = __errno_location ();
      D.13385 = *D.13384;
      if (D.13385 == 4) goto <D.13386>; else goto <D.11906>;
      <D.13386>:
      D.13387 = _wapi_thread_cur_apc_pending ();
      if (D.13387 == 0) goto <D.11905>; else goto <D.11906>;
      <D.11906>:
      if (ret == -1) goto <D.13388>; else goto <D.13389>;
      <D.13388>:
      {
        gint err;

        D.13384 = __errno_location ();
        err = *D.13384;
        D.13390 = _wapi_get_win32_file_error (err);
        D.13391 = (unsigned int) D.13390;
        SetLastError (D.13391);
        D.13370 = 0;
        return D.13370;
      }
      <D.13389>:
      if (bytesread != 0B) goto <D.13392>; else goto <D.13393>;
      <D.13392>:
      ret.35 = (unsigned int) ret;
      *bytesread = ret.35;
      <D.13393>:
      D.13370 = 1;
      return D.13370;
    }
  finally
    {
      file_handle = {CLOBBER};
    }
}


file_getfiletype ()
{
  WapiFileType D.13397;

  D.13397 = 1;
  return D.13397;
}


_wapi_handle_type (void * handle)
{
  long int handle.36;
  unsigned int D.13404;
  struct _WapiHandleUnshared * D.13405;
  WapiHandleType D.13406;
  unsigned int D.13407;
  struct _WapiHandleUnshared * D.13408;
  long unsigned int D.13409;
  long unsigned int D.13410;
  long unsigned int D.13411;
  struct _WapiHandleUnshared * D.13412;
  guint32 idx;

  handle.36 = (long int) handle;
  idx = (guint32) handle.36;
  if (idx > 4194303) goto <D.13400>; else goto <D.13402>;
  <D.13402>:
  if (idx > 268435455) goto <D.13400>; else goto <D.13403>;
  <D.13403>:
  D.13404 = idx / 256;
  D.13405 = _wapi_private_handles[D.13404];
  if (D.13405 == 0B) goto <D.13400>; else goto <D.13401>;
  <D.13400>:
  D.13406 = 0;
  return D.13406;
  <D.13401>:
  D.13407 = idx / 256;
  D.13408 = _wapi_private_handles[D.13407];
  D.13409 = (long unsigned int) idx;
  D.13410 = D.13409 & 255;
  D.13411 = D.13410 * 200;
  D.13412 = D.13408 + D.13411;
  D.13406 = D.13412->type;
  return D.13406;
}


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

  type = _wapi_handle_type (handle);
  D.13414 = io_ops[type].writefile;
  if (D.13414 == 0B) goto <D.13415>; else goto <D.13416>;
  <D.13415>:
  SetLastError (6);
  D.13417 = 0;
  return D.13417;
  <D.13416>:
  D.13414 = io_ops[type].writefile;
  D.13417 = D.13414 (handle, buffer, numbytes, byteswritten, overlapped);
  return D.13417;
}


FlushFileBuffers (void * handle)
{
  gboolean (*<T18a2>) (void *) D.13419;
  gboolean D.13422;
  WapiHandleType type;

  type = _wapi_handle_type (handle);
  D.13419 = io_ops[type].flushfile;
  if (D.13419 == 0B) goto <D.13420>; else goto <D.13421>;
  <D.13420>:
  SetLastError (6);
  D.13422 = 0;
  return D.13422;
  <D.13421>:
  D.13419 = io_ops[type].flushfile;
  D.13422 = D.13419 (handle);
  return D.13422;
}


SetEndOfFile (void * handle)
{
  gboolean (*<T18a2>) (void *) D.13424;
  gboolean D.13427;
  WapiHandleType type;

  type = _wapi_handle_type (handle);
  D.13424 = io_ops[type].setendoffile;
  if (D.13424 == 0B) goto <D.13425>; else goto <D.13426>;
  <D.13425>:
  SetLastError (6);
  D.13427 = 0;
  return D.13427;
  <D.13426>:
  D.13424 = io_ops[type].setendoffile;
  D.13427 = D.13424 (handle);
  return D.13427;
}


SetFilePointer (void * handle, gint32 movedistance, gint32 * highmovedistance, WapiSeekMethod method)
{
  guint32 (*<T1b69>) (void *, gint32, gint32 *, WapiSeekMethod) D.13429;
  guint32 D.13432;
  WapiHandleType type;

  type = _wapi_handle_type (handle);
  D.13429 = io_ops[type].seek;
  if (D.13429 == 0B) goto <D.13430>; else goto <D.13431>;
  <D.13430>:
  SetLastError (6);
  D.13432 = 4294967295;
  return D.13432;
  <D.13431>:
  D.13429 = io_ops[type].seek;
  D.13432 = D.13429 (handle, movedistance, highmovedistance, method);
  return D.13432;
}


GetFileType (void * handle)
{
  long int handle.37;
  unsigned int D.13437;
  unsigned int D.13439;
  struct _WapiHandleUnshared * D.13440;
  WapiFileType D.13441;
  WapiFileType (*<T1b5b>) (void) D.13442;
  WapiHandleType type;

  handle.37 = (long int) handle;
  D.13437 = (unsigned int) handle.37;
  if (D.13437 > 268435455) goto <D.13434>; else goto <D.13438>;
  <D.13438>:
  handle.37 = (long int) handle;
  D.13437 = (unsigned int) handle.37;
  D.13439 = D.13437 / 256;
  D.13440 = _wapi_private_handles[D.13439];
  if (D.13440 == 0B) goto <D.13434>; else goto <D.13435>;
  <D.13434>:
  SetLastError (6);
  D.13441 = 0;
  return D.13441;
  <D.13435>:
  type = _wapi_handle_type (handle);
  D.13442 = io_ops[type].getfiletype;
  if (D.13442 == 0B) goto <D.13443>; else goto <D.13444>;
  <D.13443>:
  SetLastError (6);
  D.13441 = 0;
  return D.13441;
  <D.13444>:
  D.13442 = io_ops[type].getfiletype;
  D.13441 = D.13442 ();
  return D.13441;
}


GetFileSize (void * handle, guint32 * highsize)
{
  guint32 (*<T1b6f>) (void *, guint32 *) D.13446;
  guint32 D.13449;
  WapiHandleType type;

  type = _wapi_handle_type (handle);
  D.13446 = io_ops[type].getfilesize;
  if (D.13446 == 0B) goto <D.13447>; else goto <D.13448>;
  <D.13447>:
  SetLastError (6);
  D.13449 = 4294967295;
  return D.13449;
  <D.13448>:
  D.13446 = io_ops[type].getfilesize;
  D.13449 = D.13446 (handle, highsize);
  return D.13449;
}


GetFileTime (void * handle, struct WapiFileTime * create_time, struct WapiFileTime * last_access, struct WapiFileTime * last_write)
{
  gboolean (*<T1b73>) (void *, struct WapiFileTime *, struct WapiFileTime *, struct WapiFileTime *) D.13451;
  gboolean D.13454;
  WapiHandleType type;

  type = _wapi_handle_type (handle);
  D.13451 = io_ops[type].getfiletime;
  if (D.13451 == 0B) goto <D.13452>; else goto <D.13453>;
  <D.13452>:
  SetLastError (6);
  D.13454 = 0;
  return D.13454;
  <D.13453>:
  D.13451 = io_ops[type].getfiletime;
  D.13454 = D.13451 (handle, create_time, last_access, last_write);
  return D.13454;
}


SetFileTime (void * handle, const struct WapiFileTime * create_time, const struct WapiFileTime * last_access, const struct WapiFileTime * last_write)
{
  gboolean (*<T1b77>) (void *, const struct WapiFileTime *, const struct WapiFileTime *, const struct WapiFileTime *) D.13456;
  gboolean D.13459;
  WapiHandleType type;

  type = _wapi_handle_type (handle);
  D.13456 = io_ops[type].setfiletime;
  if (D.13456 == 0B) goto <D.13457>; else goto <D.13458>;
  <D.13457>:
  SetLastError (6);
  D.13459 = 0;
  return D.13459;
  <D.13458>:
  D.13456 = io_ops[type].setfiletime;
  D.13459 = D.13456 (handle, create_time, last_access, last_write);
  return D.13459;
}


FileTimeToSystemTime (const struct WapiFileTime * file_time, struct WapiSystemTime * system_time)
{
  gboolean D.13463;
  unsigned int D.13464;
  long int D.13465;
  long int D.13466;
  unsigned int D.13467;
  long int D.13468;
  long long int D.13471;
  short unsigned int D.13472;
  long int D.13473;
  short unsigned int D.13474;
  long int D.13475;
  short unsigned int D.13476;
  long int D.13477;
  short unsigned int D.13478;
  long int D.13479;
  long int D.13480;
  short unsigned int D.13481;
  short unsigned int D.13482;
  long int D.13483;
  long int D.13484;
  long int D.13485;
  _Bool D.13486;
  long int D.13487;
  long int D.13488;
  long int D.13489;
  long int D.13490;
  _Bool D.13491;
  long int D.13492;
  long int D.13493;
  long int D.13494;
  _Bool D.13495;
  long int D.13496;
  long int D.13497;
  long int D.13498;
  long int D.13499;
  long int D.13500;
  long int D.13501;
  _Bool D.13502;
  long int D.13503;
  long int D.13504;
  long int D.13505;
  long int D.13506;
  long int D.13507;
  long int D.13508;
  _Bool D.13509;
  long int D.13510;
  long int D.13511;
  long int D.13512;
  _Bool D.13513;
  long int D.13514;
  long int D.13515;
  long int D.13516;
  long int D.13517;
  long int D.13518;
  long int D.13519;
  _Bool D.13520;
  long int D.13521;
  long int D.13522;
  long int D.13523;
  long int D.13524;
  long int D.13525;
  long int D.13526;
  long int D.13527;
  long int D.13528;
  long int D.13529;
  long int D.13530;
  long int D.13531;
  long int D.13532;
  long int D.13533;
  long int D.13534;
  long int D.13535;
  gint64 iftmp.38;
  unsigned long y.39;
  unsigned long D.13542;
  long int D.13544;
  long int D.13546;
  short unsigned int D.13547;
  int iftmp.40;
  long unsigned int y.41;
  long unsigned int D.13555;
  const guint16 * D.13556;
  short unsigned int D.13557;
  long int D.13558;
  short unsigned int D.13559;
  short unsigned int D.13560;
  short unsigned int D.13561;
  gint64 file_ticks;
  gint64 totaldays;
  gint64 rem;
  gint64 y;
  const guint16 * ip;
  static const char __func__[21] = "FileTimeToSystemTime";

  if (system_time == 0B) goto <D.13461>; else goto <D.13462>;
  <D.13461>:
  SetLastError (87);
  D.13463 = 0;
  return D.13463;
  <D.13462>:
  D.13464 = file_time->dwHighDateTime;
  D.13465 = (long int) D.13464;
  D.13466 = D.13465 << 32;
  D.13467 = file_time->dwLowDateTime;
  D.13468 = (long int) D.13467;
  file_ticks = D.13466 + D.13468;
  if (file_ticks < 0) goto <D.13469>; else goto <D.13470>;
  <D.13469>:
  SetLastError (87);
  D.13463 = 0;
  return D.13463;
  <D.13470>:
  totaldays = file_ticks / 864000000000;
  rem = file_ticks % 864000000000;
  D.13471 = rem / 36000000000;
  D.13472 = (short unsigned int) D.13471;
  system_time->wHour = D.13472;
  rem = rem % 36000000000;
  D.13473 = rem / 600000000;
  D.13474 = (short unsigned int) D.13473;
  system_time->wMinute = D.13474;
  rem = rem % 600000000;
  D.13475 = rem / 10000000;
  D.13476 = (short unsigned int) D.13475;
  system_time->wSecond = D.13476;
  rem = rem % 10000000;
  D.13477 = rem / 10000;
  D.13478 = (short unsigned int) D.13477;
  system_time->wMilliseconds = D.13478;
  D.13479 = totaldays + 1;
  D.13480 = D.13479 % 7;
  D.13481 = (short unsigned int) D.13480;
  D.13482 = D.13481 + 1;
  system_time->wDayOfWeek = D.13482;
  y = 1601;
  goto <D.12304>;
  <D.12303>:
  {
    gint64 yg;

    D.13483 = totaldays / 365;
    D.13484 = D.13483 + y;
    D.13485 = totaldays % 365;
    D.13486 = D.13485 < 0;
    D.13487 = (long int) D.13486;
    yg = D.13484 - D.13487;
    D.13488 = yg + -1;
    D.13489 = D.13488 / 4;
    D.13488 = yg + -1;
    D.13490 = D.13488 % 4;
    D.13491 = D.13490 < 0;
    D.13492 = (long int) D.13491;
    D.13493 = D.13489 - D.13492;
    D.13488 = yg + -1;
    D.13494 = D.13488 % 100;
    D.13495 = D.13494 < 0;
    D.13496 = (long int) D.13495;
    D.13488 = yg + -1;
    D.13497 = D.13488 / -100;
    D.13498 = D.13496 + D.13497;
    D.13499 = D.13493 + D.13498;
    D.13488 = yg + -1;
    D.13500 = D.13488 / 400;
    D.13488 = yg + -1;
    D.13501 = D.13488 % 400;
    D.13502 = D.13501 < 0;
    D.13503 = (long int) D.13502;
    D.13504 = D.13500 - D.13503;
    D.13505 = D.13499 + D.13504;
    D.13506 = y + -1;
    D.13507 = D.13506 / 4;
    D.13506 = y + -1;
    D.13508 = D.13506 % 4;
    D.13509 = D.13508 < 0;
    D.13510 = (long int) D.13509;
    D.13511 = D.13507 - D.13510;
    D.13506 = y + -1;
    D.13512 = D.13506 % 100;
    D.13513 = D.13512 < 0;
    D.13514 = (long int) D.13513;
    D.13506 = y + -1;
    D.13515 = D.13506 / -100;
    D.13516 = D.13514 + D.13515;
    D.13517 = D.13511 + D.13516;
    D.13506 = y + -1;
    D.13518 = D.13506 / 400;
    D.13506 = y + -1;
    D.13519 = D.13506 % 400;
    D.13520 = D.13519 < 0;
    D.13521 = (long int) D.13520;
    D.13522 = D.13518 - D.13521;
    D.13523 = D.13517 + D.13522;
    monoeg_g_log (0B, 32, "%s: LEAPS(yg): %lld LEAPS(y): %lld", &__func__, D.13505, D.13523);
    D.13506 = y + -1;
    D.13507 = D.13506 / 4;
    D.13506 = y + -1;
    D.13508 = D.13506 % 4;
    D.13509 = D.13508 < 0;
    D.13510 = (long int) D.13509;
    D.13511 = D.13507 - D.13510;
    D.13506 = y + -1;
    D.13512 = D.13506 % 100;
    D.13513 = D.13512 < 0;
    D.13514 = (long int) D.13513;
    D.13506 = y + -1;
    D.13515 = D.13506 / -100;
    D.13516 = D.13514 + D.13515;
    D.13517 = D.13511 + D.13516;
    D.13506 = y + -1;
    D.13518 = D.13506 / 400;
    D.13506 = y + -1;
    D.13519 = D.13506 % 400;
    D.13520 = D.13519 < 0;
    D.13521 = (long int) D.13520;
    D.13522 = D.13518 - D.13521;
    D.13523 = D.13517 + D.13522;
    D.13488 = yg + -1;
    D.13501 = D.13488 % 400;
    D.13502 = D.13501 < 0;
    D.13503 = (long int) D.13502;
    D.13488 = yg + -1;
    D.13524 = D.13488 / -400;
    D.13525 = D.13503 + D.13524;
    D.13488 = yg + -1;
    D.13526 = D.13488 / 100;
    D.13488 = yg + -1;
    D.13494 = D.13488 % 100;
    D.13495 = D.13494 < 0;
    D.13496 = (long int) D.13495;
    D.13527 = D.13526 - D.13496;
    D.13488 = yg + -1;
    D.13490 = D.13488 % 4;
    D.13491 = D.13490 < 0;
    D.13492 = (long int) D.13491;
    D.13488 = yg + -1;
    D.13528 = D.13488 / -4;
    D.13529 = D.13492 + D.13528;
    D.13530 = D.13527 + D.13529;
    D.13531 = D.13525 + D.13530;
    D.13532 = y - yg;
    D.13533 = D.13532 * 365;
    D.13534 = D.13531 + D.13533;
    D.13535 = D.13523 + D.13534;
    totaldays = D.13535 + totaldays;
    y = yg;
  }
  <D.12304>:
  if (totaldays < 0) goto <D.12303>; else goto <D.13536>;
  <D.13536>:
  y.39 = (unsigned long) y;
  D.13542 = y.39 & 3;
  if (D.13542 == 0) goto <D.13543>; else goto <D.13538>;
  <D.13543>:
  D.13544 = y % 100;
  if (D.13544 != 0) goto <D.13539>; else goto <D.13545>;
  <D.13545>:
  D.13546 = y % 400;
  if (D.13546 == 0) goto <D.13539>; else goto <D.13538>;
  <D.13539>:
  iftmp.38 = 366;
  goto <D.13540>;
  <D.13538>:
  iftmp.38 = 365;
  <D.13540>:
  if (iftmp.38 <= totaldays) goto <D.12303>; else goto <D.12305>;
  <D.12305>:
  D.13547 = (short unsigned int) y;
  system_time->wYear = D.13547;
  y.39 = (unsigned long) y;
  D.13542 = y.39 & 3;
  if (D.13542 == 0) goto <D.13552>; else goto <D.13549>;
  <D.13552>:
  D.13544 = y % 100;
  if (D.13544 != 0) goto <D.13550>; else goto <D.13553>;
  <D.13553>:
  D.13546 = y % 400;
  if (D.13546 == 0) goto <D.13550>; else goto <D.13549>;
  <D.13550>:
  iftmp.40 = 1;
  goto <D.13551>;
  <D.13549>:
  iftmp.40 = 0;
  <D.13551>:
  ip = &mon_yday[iftmp.40];
  y = 11;
  goto <D.12308>;
  <D.12307>:
  // predicted unlikely by continue predictor.
  goto <D.12306>;
  <D.12306>:
  y = y + -1;
  <D.12308>:
  y.41 = (long unsigned int) y;
  D.13555 = y.41 * 2;
  D.13556 = ip + D.13555;
  D.13557 = *D.13556;
  D.13558 = (long int) D.13557;
  if (D.13558 > totaldays) goto <D.12307>; else goto <D.12309>;
  <D.12309>:
  y.41 = (long unsigned int) y;
  D.13555 = y.41 * 2;
  D.13556 = ip + D.13555;
  D.13557 = *D.13556;
  D.13558 = (long int) D.13557;
  totaldays = totaldays - D.13558;
  D.13547 = (short unsigned int) y;
  D.13559 = D.13547 + 1;
  system_time->wMonth = D.13559;
  D.13560 = (short unsigned int) totaldays;
  D.13561 = D.13560 + 1;
  system_time->wDay = D.13561;
  D.13463 = 1;
  return D.13463;
}


FindFirstFile (const gunichar2 * pattern, struct WapiFindData * find_data)
{
  void * D.13565;
  int D.13576;
  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.13563>; else goto <D.13564>;
      <D.13563>:
      SetLastError (3);
      D.13565 = -1B;
      return D.13565;
      <D.13564>:
      utf8_pattern = mono_unicode_to_external (pattern);
      if (utf8_pattern == 0B) goto <D.13566>; else goto <D.13567>;
      <D.13566>:
      SetLastError (123);
      D.13565 = -1B;
      return D.13565;
      <D.13567>:
      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.13568>; else goto <D.13569>;
      <D.13568>:
      SetLastError (2);
      monoeg_g_free (utf8_pattern);
      monoeg_g_free (entry_part);
      monoeg_g_free (dir_part);
      D.13565 = -1B;
      return D.13565;
      <D.13569>:
      if (result < 0) goto <D.13570>; else goto <D.13571>;
      <D.13570>:
      _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.13565 = -1B;
      return D.13565;
      <D.13571>:
      monoeg_g_free (utf8_pattern);
      monoeg_g_free (entry_part);
      find_handle.dir_part = dir_part;
      find_handle.num = result;
      find_handle.count = 0;
      handle = _wapi_handle_new (8, &find_handle);
      if (handle == -1B) goto <D.13572>; else goto <D.13573>;
      <D.13572>:
      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.13565 = -1B;
      return D.13565;
      <D.13573>:
      if (handle != -1B) goto <D.13574>; else goto <D.13575>;
      <D.13574>:
      D.13576 = FindNextFile (handle, find_data);
      if (D.13576 == 0) goto <D.13577>; else goto <D.13578>;
      <D.13577>:
      FindClose (handle);
      SetLastError (18);
      handle = -1B;
      <D.13578>:
      <D.13575>:
      D.13565 = handle;
      return D.13565;
    }
  finally
    {
      find_handle = {CLOBBER};
    }
}


FindNextFile (void * handle, struct WapiFindData * find_data)
{
  gboolean D.13583;
  long int D.13584;
  long int D.13585;
  _Bool D.13588;
  long int D.13589;
  long int D.13590;
  struct _WapiHandle_find * find_handle.42;
  long unsigned int D.13594;
  int D.13595;
  long unsigned int D.13596;
  gchar * D.13599;
  gchar * * D.13600;
  long unsigned int D.13601;
  long unsigned int D.13602;
  long unsigned int D.13603;
  gchar * * D.13604;
  gchar * D.13605;
  int * D.13608;
  int D.13609;
  long int D.13618;
  long int D.13619;
  unsigned int D.13623;
  struct WapiFileTime * D.13624;
  long int D.13625;
  struct WapiFileTime * D.13626;
  struct WapiFileTime * D.13627;
  unsigned int D.13628;
  unsigned int D.13629;
  long int D.13633;
  long int D.13634;
  unsigned int D.13635;
  unsigned int D.13636;
  long int bytes.43;
  long int bytes.44;
  gunichar2[260] * D.13641;
  long int D.13642;
  long unsigned int D.13643;
  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.13581>; else goto <D.13582>;
      <D.13581>:
      monoeg_g_log (0B, 16, "%s: error looking up find handle %p", &__func__, handle);
      SetLastError (6);
      D.13583 = 0;
      return D.13583;
      <D.13582>:
      {
        struct __pthread_unwind_buf_t __cancel_buf;
        void (*<Tbf>) (void *) __cancel_routine;
        void * __cancel_arg;
        int __not_first_call;

        try
          {
            __cancel_routine = _wapi_handle_unlock_handle;
            __cancel_arg = handle;
            __not_first_call = __sigsetjmp (&__cancel_buf.__cancel_jmp_buf, 0);
            D.13584 = (long int) __not_first_call;
            D.13585 = __builtin_expect (D.13584, 0);
            if (D.13585 != 0) goto <D.13586>; else goto <D.13587>;
            <D.13586>:
            __cancel_routine (__cancel_arg);
            __pthread_unwind_next (&__cancel_buf);
            <D.13587>:
            __pthread_register_cancel (&__cancel_buf);
            thr_ret = _wapi_handle_lock_handle (handle);
            D.13588 = thr_ret != 0;
            D.13589 = (long int) D.13588;
            D.13590 = __builtin_expect (D.13589, 0);
            if (D.13590 != 0) goto <D.13591>; else goto <D.13592>;
            <D.13591>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "io.c", 2803, "thr_ret == 0");
            <D.13592>:
            retry:
            find_handle.42 = find_handle;
            D.13594 = find_handle.42->count;
            find_handle.42 = find_handle;
            D.13595 = find_handle.42->num;
            D.13596 = (long unsigned int) D.13595;
            if (D.13594 >= D.13596) goto <D.13597>; else goto <D.13598>;
            <D.13597>:
            SetLastError (18);
            goto cleanup;
            <D.13598>:
            find_handle.42 = find_handle;
            D.13599 = find_handle.42->dir_part;
            find_handle.42 = find_handle;
            D.13600 = find_handle.42->namelist;
            find_handle.42 = find_handle;
            D.13594 = find_handle.42->count;
            D.13601 = D.13594;
            D.13602 = D.13601 + 1;
            find_handle.42->count = D.13602;
            D.13603 = D.13601 * 8;
            D.13604 = D.13600 + D.13603;
            D.13605 = *D.13604;
            filename = monoeg_g_build_path ("/", D.13599, D.13605, 0B);
            result = _wapi_stat (filename, &buf);
            if (result == -1) goto <D.13606>; else goto <D.13607>;
            <D.13606>:
            D.13608 = __errno_location ();
            D.13609 = *D.13608;
            if (D.13609 == 2) goto <D.13610>; else goto <D.13611>;
            <D.13610>:
            result = _wapi_lstat (filename, &buf);
            <D.13611>:
            <D.13607>:
            if (result != 0) goto <D.13612>; else goto <D.13613>;
            <D.13612>:
            monoeg_g_free (filename);
            goto retry;
            <D.13613>:
            result = _wapi_lstat (filename, &linkbuf);
            if (result != 0) goto <D.13614>; else goto <D.13615>;
            <D.13614>:
            monoeg_g_free (filename);
            goto retry;
            <D.13615>:
            utf8_filename = mono_utf8_from_external (filename);
            if (utf8_filename == 0B) goto <D.13616>; else goto <D.13617>;
            <D.13616>:
            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.13617>:
            monoeg_g_free (filename);
            D.13618 = buf.st_mtim.tv_sec;
            D.13619 = buf.st_ctim.tv_sec;
            if (D.13618 < D.13619) goto <D.13620>; else goto <D.13621>;
            <D.13620>:
            create_time = buf.st_mtim.tv_sec;
            goto <D.13622>;
            <D.13621>:
            create_time = buf.st_ctim.tv_sec;
            <D.13622>:
            D.13623 = _wapi_stat_to_file_attributes (utf8_filename, &buf, &linkbuf);
            find_data->dwFileAttributes = D.13623;
            D.13624 = &find_data->ftCreationTime;
            _wapi_time_t_to_filetime (create_time, D.13624);
            D.13625 = buf.st_atim.tv_sec;
            D.13626 = &find_data->ftLastAccessTime;
            _wapi_time_t_to_filetime (D.13625, D.13626);
            D.13618 = buf.st_mtim.tv_sec;
            D.13627 = &find_data->ftLastWriteTime;
            _wapi_time_t_to_filetime (D.13618, D.13627);
            D.13628 = find_data->dwFileAttributes;
            D.13629 = D.13628 & 16;
            if (D.13629 != 0) goto <D.13630>; else goto <D.13631>;
            <D.13630>:
            find_data->nFileSizeHigh = 0;
            find_data->nFileSizeLow = 0;
            goto <D.13632>;
            <D.13631>:
            D.13633 = buf.st_size;
            D.13634 = D.13633 >> 32;
            D.13635 = (unsigned int) D.13634;
            find_data->nFileSizeHigh = D.13635;
            D.13633 = buf.st_size;
            D.13636 = (unsigned int) D.13633;
            find_data->nFileSizeLow = D.13636;
            <D.13632>:
            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.13637>; else goto <D.13638>;
            <D.13637>:
            monoeg_g_free (utf8_basename);
            monoeg_g_free (utf8_filename);
            goto retry;
            <D.13638>:
            ret = 1;
            bytes.43 = bytes;
            bytes.44 = bytes.43 * 2;
            bytes = bytes.44;
            D.13641 = &find_data->cFileName;
            memset (D.13641, 0, 520);
            D.13641 = &find_data->cFileName;
            bytes.43 = bytes;
            D.13642 = MIN_EXPR <bytes.43, 518>;
            D.13643 = (long unsigned int) D.13642;
            memcpy (D.13641, utf16_basename, D.13643);
            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.13588 = thr_ret != 0;
            D.13589 = (long int) D.13588;
            D.13590 = __builtin_expect (D.13589, 0);
            if (D.13590 != 0) goto <D.13644>; else goto <D.13645>;
            <D.13644>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "io.c", 2910, "thr_ret == 0");
            <D.13645>:
            __pthread_unregister_cancel (&__cancel_buf);
            if (0 != 0) goto <D.13646>; else goto <D.13647>;
            <D.13646>:
            __cancel_routine (__cancel_arg);
            <D.13647>:
          }
        finally
          {
            __cancel_buf = {CLOBBER};
          }
      }
      D.13583 = ret;
      return D.13583;
    }
  finally
    {
      find_handle = {CLOBBER};
      buf = {CLOBBER};
      linkbuf = {CLOBBER};
      bytes = {CLOBBER};
    }
}


_wapi_handle_lock_handle (void * handle)
{
  long int handle.45;
  int D.13664;
  <unnamed type> D.13667;
  <unnamed type> D.13669;
  <unnamed type> D.13671;
  <unnamed type> D.13673;
  unsigned int D.13674;
  struct _WapiHandleUnshared * D.13675;
  long unsigned int D.13676;
  long unsigned int D.13677;
  long unsigned int D.13678;
  struct _WapiHandleUnshared * D.13679;
  union mono_mutex_t * D.13680;
  guint32 idx;

  handle.45 = (long int) handle;
  idx = (guint32) handle.45;
  if (idx > 4194303) goto <D.13662>; else goto <D.13663>;
  <D.13662>:
  D.13664 = 0;
  return D.13664;
  <D.13663>:
  _wapi_handle_ref (handle);
  D.13667 = _wapi_handle_type (handle);
  if (D.13667 == 9) goto <D.13665>; else goto <D.13668>;
  <D.13668>:
  D.13669 = _wapi_handle_type (handle);
  if (D.13669 == 11) goto <D.13665>; else goto <D.13670>;
  <D.13670>:
  D.13671 = _wapi_handle_type (handle);
  if (D.13671 == 12) goto <D.13665>; else goto <D.13672>;
  <D.13672>:
  D.13673 = _wapi_handle_type (handle);
  if (D.13673 == 13) goto <D.13665>; else goto <D.13666>;
  <D.13665>:
  D.13664 = 0;
  return D.13664;
  <D.13666>:
  D.13674 = idx / 256;
  D.13675 = _wapi_private_handles[D.13674];
  D.13676 = (long unsigned int) idx;
  D.13677 = D.13676 & 255;
  D.13678 = D.13677 * 200;
  D.13679 = D.13675 + D.13678;
  D.13680 = &D.13679->signal_mutex;
  D.13664 = pthread_mutex_lock (D.13680);
  return D.13664;
}


_wapi_stat_to_file_attributes (const gchar * pathname, struct stat * buf, struct stat * lbuf)
{
  unsigned int D.13682;
  unsigned int D.13683;
  unsigned int D.13686;
  int D.13689;
  char D.13692;
  int D.13696;
  unsigned int D.13707;
  unsigned int D.13708;
  guint32 D.13711;
  guint32 attrs;
  gchar * filename;

  attrs = 0;
  D.13682 = buf->st_mode;
  D.13683 = D.13682 & 61440;
  if (D.13683 == 49152) goto <D.13684>; else goto <D.13685>;
  <D.13684>:
  D.13682 = buf->st_mode;
  D.13686 = D.13682 & 4294918143;
  buf->st_mode = D.13686;
  <D.13685>:
  filename = _wapi_basename (pathname);
  D.13682 = buf->st_mode;
  D.13683 = D.13682 & 61440;
  if (D.13683 == 16384) goto <D.13687>; else goto <D.13688>;
  <D.13687>:
  attrs = 16;
  D.13689 = is_file_writable (buf, pathname);
  if (D.13689 == 0) goto <D.13690>; else goto <D.13691>;
  <D.13690>:
  attrs = attrs | 1;
  <D.13691>:
  D.13692 = *filename;
  if (D.13692 == 46) goto <D.13693>; else goto <D.13694>;
  <D.13693>:
  attrs = attrs | 2;
  <D.13694>:
  goto <D.13695>;
  <D.13688>:
  D.13696 = is_file_writable (buf, pathname);
  if (D.13696 == 0) goto <D.13697>; else goto <D.13698>;
  <D.13697>:
  attrs = 1;
  D.13692 = *filename;
  if (D.13692 == 46) goto <D.13699>; else goto <D.13700>;
  <D.13699>:
  attrs = attrs | 2;
  <D.13700>:
  goto <D.13701>;
  <D.13698>:
  D.13692 = *filename;
  if (D.13692 == 46) goto <D.13702>; else goto <D.13703>;
  <D.13702>:
  attrs = 2;
  goto <D.13704>;
  <D.13703>:
  attrs = 128;
  <D.13704>:
  <D.13701>:
  <D.13695>:
  if (lbuf != 0B) goto <D.13705>; else goto <D.13706>;
  <D.13705>:
  D.13707 = lbuf->st_mode;
  D.13708 = D.13707 & 61440;
  if (D.13708 == 40960) goto <D.13709>; else goto <D.13710>;
  <D.13709>:
  attrs = attrs | 1024;
  <D.13710>:
  <D.13706>:
  monoeg_g_free (filename);
  D.13711 = attrs;
  return D.13711;
}


is_file_writable (struct stat * st, const char * path)
{
  unsigned int D.13713;
  unsigned int D.13714;
  gboolean D.13717;
  unsigned int D.13718;
  unsigned int D.13719;
  unsigned int D.13722;
  unsigned int D.13725;
  unsigned int D.13726;
  unsigned int D.13729;
  int D.13732;
  _Bool D.13733;

  D.13713 = st->st_mode;
  D.13714 = D.13713 & 2;
  if (D.13714 != 0) goto <D.13715>; else goto <D.13716>;
  <D.13715>:
  D.13717 = 1;
  return D.13717;
  <D.13716>:
  D.13718 = st->st_uid;
  D.13719 = geteuid ();
  if (D.13718 == D.13719) goto <D.13720>; else goto <D.13721>;
  <D.13720>:
  D.13713 = st->st_mode;
  D.13722 = D.13713 & 128;
  if (D.13722 != 0) goto <D.13723>; else goto <D.13724>;
  <D.13723>:
  D.13717 = 1;
  return D.13717;
  <D.13724>:
  <D.13721>:
  D.13725 = st->st_gid;
  D.13726 = getegid ();
  if (D.13725 == D.13726) goto <D.13727>; else goto <D.13728>;
  <D.13727>:
  D.13713 = st->st_mode;
  D.13729 = D.13713 & 16;
  if (D.13729 != 0) goto <D.13730>; else goto <D.13731>;
  <D.13730>:
  D.13717 = 1;
  return D.13717;
  <D.13731>:
  <D.13728>:
  D.13732 = access (path, 2);
  D.13733 = D.13732 == 0;
  D.13717 = (gboolean) D.13733;
  return D.13717;
}


memset (void * __dest, int __ch, size_t __len)
{
  int D.13737;
  int D.13742;
  void * D.13744;
  long unsigned int D.13745;

  D.13737 = __builtin_constant_p (__len);
  if (D.13737 != 0) goto <D.13738>; else goto <D.13739>;
  <D.13738>:
  if (__len == 0) goto <D.13740>; else goto <D.13741>;
  <D.13740>:
  D.13742 = __builtin_constant_p (__ch);
  if (D.13742 == 0) goto <D.13735>; else goto <D.13743>;
  <D.13743>:
  if (__ch != 0) goto <D.13735>; else goto <D.13736>;
  <D.13735>:
  __warn_memset_zero_len ();
  D.13744 = __dest;
  return D.13744;
  <D.13736>:
  <D.13741>:
  <D.13739>:
  D.13745 = __builtin_object_size (__dest, 0);
  D.13744 = __builtin___memset_chk (__dest, __ch, __len, D.13745);
  return D.13744;
}


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

  D.13748 = __builtin_object_size (__dest, 0);
  D.13747 = __builtin___memcpy_chk (__dest, __src, __len, D.13748);
  return D.13747;
}


_wapi_handle_unlock_handle (void * handle)
{
  long int handle.46;
  int D.13753;
  <unnamed type> D.13756;
  <unnamed type> D.13758;
  <unnamed type> D.13760;
  <unnamed type> D.13762;
  unsigned int D.13763;
  struct _WapiHandleUnshared * D.13764;
  long unsigned int D.13765;
  long unsigned int D.13766;
  long unsigned int D.13767;
  struct _WapiHandleUnshared * D.13768;
  union mono_mutex_t * D.13769;
  guint32 idx;
  int ret;

  handle.46 = (long int) handle;
  idx = (guint32) handle.46;
  if (idx > 4194303) goto <D.13751>; else goto <D.13752>;
  <D.13751>:
  D.13753 = 0;
  return D.13753;
  <D.13752>:
  D.13756 = _wapi_handle_type (handle);
  if (D.13756 == 9) goto <D.13754>; else goto <D.13757>;
  <D.13757>:
  D.13758 = _wapi_handle_type (handle);
  if (D.13758 == 11) goto <D.13754>; else goto <D.13759>;
  <D.13759>:
  D.13760 = _wapi_handle_type (handle);
  if (D.13760 == 12) goto <D.13754>; else goto <D.13761>;
  <D.13761>:
  D.13762 = _wapi_handle_type (handle);
  if (D.13762 == 13) goto <D.13754>; else goto <D.13755>;
  <D.13754>:
  _wapi_handle_unref (handle);
  D.13753 = 0;
  return D.13753;
  <D.13755>:
  D.13763 = idx / 256;
  D.13764 = _wapi_private_handles[D.13763];
  D.13765 = (long unsigned int) idx;
  D.13766 = D.13765 & 255;
  D.13767 = D.13766 * 200;
  D.13768 = D.13764 + D.13767;
  D.13769 = &D.13768->signal_mutex;
  ret = pthread_mutex_unlock (D.13769);
  _wapi_handle_unref (handle);
  D.13753 = ret;
  return D.13753;
}


FindClose (void * handle)
{
  gboolean D.13773;
  long int D.13776;
  long int D.13777;
  _Bool D.13780;
  long int D.13781;
  long int D.13782;
  struct _WapiHandle_find * find_handle.47;
  gchar * * D.13786;
  gchar * D.13787;
  struct _WapiHandle_find * find_handle;
  gboolean ok;
  int thr_ret;
  static const char __func__[10] = "FindClose";

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

        try
          {
            __cancel_routine = _wapi_handle_unlock_handle;
            __cancel_arg = handle;
            __not_first_call = __sigsetjmp (&__cancel_buf.__cancel_jmp_buf, 0);
            D.13776 = (long int) __not_first_call;
            D.13777 = __builtin_expect (D.13776, 0);
            if (D.13777 != 0) goto <D.13778>; else goto <D.13779>;
            <D.13778>:
            __cancel_routine (__cancel_arg);
            __pthread_unwind_next (&__cancel_buf);
            <D.13779>:
            __pthread_register_cancel (&__cancel_buf);
            thr_ret = _wapi_handle_lock_handle (handle);
            D.13780 = thr_ret != 0;
            D.13781 = (long int) D.13780;
            D.13782 = __builtin_expect (D.13781, 0);
            if (D.13782 != 0) goto <D.13783>; else goto <D.13784>;
            <D.13783>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "io.c", 2947, "thr_ret == 0");
            <D.13784>:
            find_handle.47 = find_handle;
            D.13786 = find_handle.47->namelist;
            monoeg_g_strfreev (D.13786);
            find_handle.47 = find_handle;
            D.13787 = find_handle.47->dir_part;
            monoeg_g_free (D.13787);
            thr_ret = _wapi_handle_unlock_handle (handle);
            D.13780 = thr_ret != 0;
            D.13781 = (long int) D.13780;
            D.13782 = __builtin_expect (D.13781, 0);
            if (D.13782 != 0) goto <D.13788>; else goto <D.13789>;
            <D.13788>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "io.c", 2953, "thr_ret == 0");
            <D.13789>:
            __pthread_unregister_cancel (&__cancel_buf);
            if (0 != 0) goto <D.13790>; else goto <D.13791>;
            <D.13790>:
            __cancel_routine (__cancel_arg);
            <D.13791>:
          }
        finally
          {
            __cancel_buf = {CLOBBER};
          }
      }
      _wapi_handle_unref (handle);
      D.13773 = 1;
      return D.13773;
    }
  finally
    {
      find_handle = {CLOBBER};
    }
}


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

  if (name == 0B) goto <D.13797>; else goto <D.13798>;
  <D.13797>:
  SetLastError (123);
  D.13799 = 0;
  return D.13799;
  <D.13798>:
  utf8_name = mono_unicode_to_external (name);
  if (utf8_name == 0B) goto <D.13800>; else goto <D.13801>;
  <D.13800>:
  SetLastError (123);
  D.13799 = 0;
  return D.13799;
  <D.13801>:
  result = _wapi_mkdir (utf8_name, 511);
  if (result == 0) goto <D.13802>; else goto <D.13803>;
  <D.13802>:
  monoeg_g_free (utf8_name);
  D.13799 = 1;
  return D.13799;
  <D.13803>:
  _wapi_set_last_path_error_from_errno (0B, utf8_name);
  monoeg_g_free (utf8_name);
  D.13799 = 0;
  return D.13799;
}


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

  if (name == 0B) goto <D.13805>; else goto <D.13806>;
  <D.13805>:
  SetLastError (123);
  D.13807 = 0;
  return D.13807;
  <D.13806>:
  utf8_name = mono_unicode_to_external (name);
  if (utf8_name == 0B) goto <D.13808>; else goto <D.13809>;
  <D.13808>:
  SetLastError (123);
  D.13807 = 0;
  return D.13807;
  <D.13809>:
  result = _wapi_rmdir (utf8_name);
  if (result == -1) goto <D.13810>; else goto <D.13811>;
  <D.13810>:
  _wapi_set_last_path_error_from_errno (0B, utf8_name);
  monoeg_g_free (utf8_name);
  D.13807 = 0;
  return D.13807;
  <D.13811>:
  monoeg_g_free (utf8_name);
  D.13807 = 1;
  return D.13807;
}


GetFileAttributes (const gunichar2 * name)
{
  guint32 D.13815;
  int * D.13820;
  int D.13821;
  gchar * utf8_name;
  struct stat buf;
  struct stat linkbuf;
  int result;
  guint32 ret;

  try
    {
      if (name == 0B) goto <D.13813>; else goto <D.13814>;
      <D.13813>:
      SetLastError (123);
      D.13815 = 0;
      return D.13815;
      <D.13814>:
      utf8_name = mono_unicode_to_external (name);
      if (utf8_name == 0B) goto <D.13816>; else goto <D.13817>;
      <D.13816>:
      SetLastError (87);
      D.13815 = 4294967295;
      return D.13815;
      <D.13817>:
      result = _wapi_stat (utf8_name, &buf);
      if (result == -1) goto <D.13818>; else goto <D.13819>;
      <D.13818>:
      D.13820 = __errno_location ();
      D.13821 = *D.13820;
      if (D.13821 == 2) goto <D.13822>; else goto <D.13823>;
      <D.13822>:
      result = _wapi_lstat (utf8_name, &buf);
      <D.13823>:
      <D.13819>:
      if (result != 0) goto <D.13824>; else goto <D.13825>;
      <D.13824>:
      _wapi_set_last_path_error_from_errno (0B, utf8_name);
      monoeg_g_free (utf8_name);
      D.13815 = 4294967295;
      return D.13815;
      <D.13825>:
      result = _wapi_lstat (utf8_name, &linkbuf);
      if (result != 0) goto <D.13826>; else goto <D.13827>;
      <D.13826>:
      _wapi_set_last_path_error_from_errno (0B, utf8_name);
      monoeg_g_free (utf8_name);
      D.13815 = 4294967295;
      return D.13815;
      <D.13827>:
      ret = _wapi_stat_to_file_attributes (utf8_name, &buf, &linkbuf);
      monoeg_g_free (utf8_name);
      D.13815 = ret;
      return D.13815;
    }
  finally
    {
      buf = {CLOBBER};
      linkbuf = {CLOBBER};
    }
}


GetFileAttributesEx (const gunichar2 * name, WapiGetFileExInfoLevels level, void * info)
{
  gboolean D.13832;
  int * D.13839;
  int D.13840;
  long int D.13847;
  long int D.13848;
  unsigned int D.13852;
  struct WapiFileTime * D.13853;
  long int D.13854;
  struct WapiFileTime * D.13855;
  struct WapiFileTime * D.13856;
  unsigned int D.13857;
  unsigned int D.13858;
  long int D.13862;
  long int D.13863;
  unsigned int D.13864;
  unsigned int D.13865;
  gchar * utf8_name;
  struct WapiFileAttributesData * data;
  struct stat buf;
  struct stat linkbuf;
  time_t create_time;
  int result;

  try
    {
      if (level != 0) goto <D.13830>; else goto <D.13831>;
      <D.13830>:
      SetLastError (87);
      D.13832 = 0;
      return D.13832;
      <D.13831>:
      if (name == 0B) goto <D.13833>; else goto <D.13834>;
      <D.13833>:
      SetLastError (123);
      D.13832 = 0;
      return D.13832;
      <D.13834>:
      utf8_name = mono_unicode_to_external (name);
      if (utf8_name == 0B) goto <D.13835>; else goto <D.13836>;
      <D.13835>:
      SetLastError (87);
      D.13832 = 0;
      return D.13832;
      <D.13836>:
      result = _wapi_stat (utf8_name, &buf);
      if (result == -1) goto <D.13837>; else goto <D.13838>;
      <D.13837>:
      D.13839 = __errno_location ();
      D.13840 = *D.13839;
      if (D.13840 == 2) goto <D.13841>; else goto <D.13842>;
      <D.13841>:
      result = _wapi_lstat (utf8_name, &buf);
      <D.13842>:
      <D.13838>:
      if (result != 0) goto <D.13843>; else goto <D.13844>;
      <D.13843>:
      _wapi_set_last_path_error_from_errno (0B, utf8_name);
      monoeg_g_free (utf8_name);
      D.13832 = 0;
      return D.13832;
      <D.13844>:
      result = _wapi_lstat (utf8_name, &linkbuf);
      if (result != 0) goto <D.13845>; else goto <D.13846>;
      <D.13845>:
      _wapi_set_last_path_error_from_errno (0B, utf8_name);
      monoeg_g_free (utf8_name);
      D.13832 = 0;
      return D.13832;
      <D.13846>:
      data = info;
      D.13847 = buf.st_mtim.tv_sec;
      D.13848 = buf.st_ctim.tv_sec;
      if (D.13847 < D.13848) goto <D.13849>; else goto <D.13850>;
      <D.13849>:
      create_time = buf.st_mtim.tv_sec;
      goto <D.13851>;
      <D.13850>:
      create_time = buf.st_ctim.tv_sec;
      <D.13851>:
      D.13852 = _wapi_stat_to_file_attributes (utf8_name, &buf, &linkbuf);
      data->dwFileAttributes = D.13852;
      monoeg_g_free (utf8_name);
      D.13853 = &data->ftCreationTime;
      _wapi_time_t_to_filetime (create_time, D.13853);
      D.13854 = buf.st_atim.tv_sec;
      D.13855 = &data->ftLastAccessTime;
      _wapi_time_t_to_filetime (D.13854, D.13855);
      D.13847 = buf.st_mtim.tv_sec;
      D.13856 = &data->ftLastWriteTime;
      _wapi_time_t_to_filetime (D.13847, D.13856);
      D.13857 = data->dwFileAttributes;
      D.13858 = D.13857 & 16;
      if (D.13858 != 0) goto <D.13859>; else goto <D.13860>;
      <D.13859>:
      data->nFileSizeHigh = 0;
      data->nFileSizeLow = 0;
      goto <D.13861>;
      <D.13860>:
      D.13862 = buf.st_size;
      D.13863 = D.13862 >> 32;
      D.13864 = (unsigned int) D.13863;
      data->nFileSizeHigh = D.13864;
      D.13862 = buf.st_size;
      D.13865 = (unsigned int) D.13862;
      data->nFileSizeLow = D.13865;
      <D.13861>:
      D.13832 = 1;
      return D.13832;
    }
  finally
    {
      buf = {CLOBBER};
      linkbuf = {CLOBBER};
    }
}


SetFileAttributes (const gunichar2 * name, guint32 attrs)
{
  gboolean D.13870;
  int * D.13875;
  int D.13876;
  unsigned int D.13881;
  unsigned int D.13884;
  unsigned int D.13885;
  unsigned int D.13887;
  signed int attrs.48;
  unsigned int D.13891;
  unsigned int D.13894;
  unsigned int D.13897;
  unsigned int D.13900;
  gchar * utf8_name;
  struct stat buf;
  int result;

  try
    {
      if (name == 0B) goto <D.13868>; else goto <D.13869>;
      <D.13868>:
      SetLastError (123);
      D.13870 = 0;
      return D.13870;
      <D.13869>:
      utf8_name = mono_unicode_to_external (name);
      if (utf8_name == 0B) goto <D.13871>; else goto <D.13872>;
      <D.13871>:
      SetLastError (123);
      D.13870 = 0;
      return D.13870;
      <D.13872>:
      result = _wapi_stat (utf8_name, &buf);
      if (result == -1) goto <D.13873>; else goto <D.13874>;
      <D.13873>:
      D.13875 = __errno_location ();
      D.13876 = *D.13875;
      if (D.13876 == 2) goto <D.13877>; else goto <D.13878>;
      <D.13877>:
      result = _wapi_lstat (utf8_name, &buf);
      <D.13878>:
      <D.13874>:
      if (result != 0) goto <D.13879>; else goto <D.13880>;
      <D.13879>:
      _wapi_set_last_path_error_from_errno (0B, utf8_name);
      monoeg_g_free (utf8_name);
      D.13870 = 0;
      return D.13870;
      <D.13880>:
      D.13881 = attrs & 1;
      if (D.13881 != 0) goto <D.13882>; else goto <D.13883>;
      <D.13882>:
      D.13884 = buf.st_mode;
      D.13885 = D.13884 & 4294967149;
      result = _wapi_chmod (utf8_name, D.13885);
      goto <D.13886>;
      <D.13883>:
      D.13884 = buf.st_mode;
      D.13887 = D.13884 | 128;
      result = _wapi_chmod (utf8_name, D.13887);
      <D.13886>:
      attrs.48 = (signed int) attrs;
      if (attrs.48 < 0) goto <D.13889>; else goto <D.13890>;
      <D.13889>:
      {
        mode_t exec_mask;

        exec_mask = 0;
        D.13884 = buf.st_mode;
        D.13891 = D.13884 & 256;
        if (D.13891 != 0) goto <D.13892>; else goto <D.13893>;
        <D.13892>:
        exec_mask = exec_mask | 64;
        <D.13893>:
        D.13884 = buf.st_mode;
        D.13894 = D.13884 & 32;
        if (D.13894 != 0) goto <D.13895>; else goto <D.13896>;
        <D.13895>:
        exec_mask = exec_mask | 8;
        <D.13896>:
        D.13884 = buf.st_mode;
        D.13897 = D.13884 & 4;
        if (D.13897 != 0) goto <D.13898>; else goto <D.13899>;
        <D.13898>:
        exec_mask = exec_mask | 1;
        <D.13899>:
        D.13884 = buf.st_mode;
        D.13900 = D.13884 | exec_mask;
        result = chmod (utf8_name, D.13900);
      }
      <D.13890>:
      monoeg_g_free (utf8_name);
      D.13870 = 1;
      return D.13870;
    }
  finally
    {
      buf = {CLOBBER};
    }
}


GetCurrentDirectory (guint32 length, gunichar2 * buffer)
{
  long unsigned int D.13903;
  char * D.13904;
  int * D.13907;
  int D.13908;
  guint32 D.13913;
  long unsigned int bytes.49;
  long unsigned int D.13915;
  unsigned int D.13916;
  long unsigned int D.13917;
  long int D.13918;
  _Bool D.13919;
  long int D.13920;
  long int D.13921;
  long unsigned int D.13924;
  gunichar2 * utf16_path;
  glong count;
  gsize bytes;

  try
    {
      D.13903 = (long unsigned int) length;
      D.13904 = getcwd (buffer, D.13903);
      if (D.13904 == 0B) goto <D.13905>; else goto <D.13906>;
      <D.13905>:
      D.13907 = __errno_location ();
      D.13908 = *D.13907;
      if (D.13908 == 34) goto <D.13909>; else goto <D.13910>;
      <D.13909>:
      {
        gchar * path;

        path = monoeg_g_get_current_dir ();
        if (path == 0B) goto <D.13911>; else goto <D.13912>;
        <D.13911>:
        D.13913 = 0;
        return D.13913;
        <D.13912>:
        utf16_path = mono_unicode_from_external (path, &bytes);
        monoeg_g_free (utf16_path);
        monoeg_g_free (path);
        bytes.49 = bytes;
        D.13915 = bytes.49 / 2;
        D.13916 = (unsigned int) D.13915;
        D.13913 = D.13916 + 1;
        return D.13913;
      }
      <D.13910>:
      _wapi_set_last_error_from_errno ();
      D.13913 = 0;
      return D.13913;
      <D.13906>:
      utf16_path = mono_unicode_from_external (buffer, &bytes);
      bytes.49 = bytes;
      D.13915 = bytes.49 / 2;
      D.13917 = D.13915 + 1;
      count = (glong) D.13917;
      D.13918 = (long int) length;
      D.13919 = D.13918 < count;
      D.13920 = (long int) D.13919;
      D.13921 = __builtin_expect (D.13920, 0);
      if (D.13921 != 0) goto <D.13922>; else goto <D.13923>;
      <D.13922>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "io.c", 3320, "count <= length");
      <D.13923>:
      bytes.49 = bytes;
      D.13924 = bytes.49 + 2;
      memset (buffer, 0, D.13924);
      bytes.49 = bytes;
      memcpy (buffer, utf16_path, bytes.49);
      monoeg_g_free (utf16_path);
      D.13913 = (guint32) count;
      return D.13913;
    }
  finally
    {
      bytes = {CLOBBER};
    }
}


getcwd (char * __buf, size_t __size)
{
  long unsigned int D.13927;
  int D.13930;
  char * D.13933;
  long unsigned int D.13934;
  long unsigned int D.13935;
  long unsigned int D.13938;

  D.13927 = __builtin_object_size (__buf, 1);
  if (D.13927 != 18446744073709551615) goto <D.13928>; else goto <D.13929>;
  <D.13928>:
  D.13930 = __builtin_constant_p (__size);
  if (D.13930 == 0) goto <D.13931>; else goto <D.13932>;
  <D.13931>:
  D.13934 = __builtin_object_size (__buf, 1);
  D.13933 = __getcwd_chk (__buf, __size, D.13934);
  return D.13933;
  <D.13932>:
  D.13935 = __builtin_object_size (__buf, 1);
  if (D.13935 < __size) goto <D.13936>; else goto <D.13937>;
  <D.13936>:
  D.13938 = __builtin_object_size (__buf, 1);
  D.13933 = __getcwd_chk_warn (__buf, __size, D.13938);
  return D.13933;
  <D.13937>:
  <D.13929>:
  D.13933 = __getcwd_alias (__buf, __size);
  return D.13933;
}


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

  if (path == 0B) goto <D.13940>; else goto <D.13941>;
  <D.13940>:
  SetLastError (87);
  D.13942 = 0;
  return D.13942;
  <D.13941>:
  utf8_path = mono_unicode_to_external (path);
  D.13943 = _wapi_chdir (utf8_path);
  if (D.13943 != 0) goto <D.13944>; else goto <D.13945>;
  <D.13944>:
  _wapi_set_last_error_from_errno ();
  result = 0;
  goto <D.13946>;
  <D.13945>:
  result = 1;
  <D.13946>:
  monoeg_g_free (utf8_path);
  D.13942 = result;
  return D.13942;
}


CreatePipe (void * * readpipe, void * * writepipe, struct WapiSecurityAttributes * security, guint32 size)
{
  gboolean D.13950;
  int D.13953;
  unsigned int D.13954;
  unsigned int _wapi_fd_reserve.50;
  int D.13957;
  unsigned int D.13958;
  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.13948>; else goto <D.13949>;
      <D.13948>:
      _wapi_set_last_error_from_errno ();
      D.13950 = 0;
      return D.13950;
      <D.13949>:
      D.13953 = filedes[0];
      D.13954 = (unsigned int) D.13953;
      _wapi_fd_reserve.50 = _wapi_fd_reserve;
      if (D.13954 >= _wapi_fd_reserve.50) goto <D.13951>; else goto <D.13956>;
      <D.13956>:
      D.13957 = filedes[1];
      D.13958 = (unsigned int) D.13957;
      _wapi_fd_reserve.50 = _wapi_fd_reserve;
      if (D.13958 >= _wapi_fd_reserve.50) goto <D.13951>; else goto <D.13952>;
      <D.13951>:
      SetLastError (4);
      D.13953 = filedes[0];
      close (D.13953);
      D.13957 = filedes[1];
      close (D.13957);
      D.13950 = 0;
      return D.13950;
      <D.13952>:
      D.13953 = filedes[0];
      pipe_read_handle.fd = D.13953;
      pipe_read_handle.fileaccess = 2147483648;
      D.13953 = filedes[0];
      read_handle = _wapi_handle_new_fd (10, D.13953, &pipe_read_handle);
      if (read_handle == -1B) goto <D.13959>; else goto <D.13960>;
      <D.13959>:
      monoeg_g_log (0B, 16, "%s: error creating pipe read handle", &__func__);
      D.13953 = filedes[0];
      close (D.13953);
      D.13957 = filedes[1];
      close (D.13957);
      SetLastError (31);
      D.13950 = 0;
      return D.13950;
      <D.13960>:
      D.13957 = filedes[1];
      pipe_write_handle.fd = D.13957;
      pipe_write_handle.fileaccess = 1073741824;
      D.13957 = filedes[1];
      write_handle = _wapi_handle_new_fd (10, D.13957, &pipe_write_handle);
      if (write_handle == -1B) goto <D.13961>; else goto <D.13962>;
      <D.13961>:
      monoeg_g_log (0B, 16, "%s: error creating pipe write handle", &__func__);
      _wapi_handle_unref (read_handle);
      D.13953 = filedes[0];
      close (D.13953);
      D.13957 = filedes[1];
      close (D.13957);
      SetLastError (31);
      D.13950 = 0;
      return D.13950;
      <D.13962>:
      *readpipe = read_handle;
      *writepipe = write_handle;
      D.13950 = 1;
      return D.13950;
    }
  finally
    {
      pipe_read_handle = {CLOBBER};
      pipe_write_handle = {CLOBBER};
      filedes = {CLOBBER};
    }
}


GetTempPath (guint32 len, gunichar2 * buf)
{
  const gchar * D.13965;
  long unsigned int D.13966;
  gchar * D.13967;
  char D.13968;
  const gchar * D.13971;
  guint32 D.13974;
  long unsigned int bytes.51;
  long unsigned int D.13976;
  long int D.13977;
  unsigned int D.13980;
  long unsigned int D.13982;
  gchar * tmpdir;
  gunichar2 * tmpdir16;
  glong dirlen;
  gsize bytes;
  guint32 ret;

  try
    {
      D.13965 = monoeg_g_get_tmp_dir ();
      tmpdir = monoeg_strdup (D.13965);
      tmpdir16 = 0B;
      D.13966 = strlen (tmpdir);
      D.13967 = tmpdir + D.13966;
      D.13968 = *D.13967;
      if (D.13968 != 47) goto <D.13969>; else goto <D.13970>;
      <D.13969>:
      monoeg_g_free (tmpdir);
      D.13971 = monoeg_g_get_tmp_dir ();
      tmpdir = monoeg_g_strdup_printf ("%s/", D.13971);
      <D.13970>:
      tmpdir16 = mono_unicode_from_external (tmpdir, &bytes);
      if (tmpdir16 == 0B) goto <D.13972>; else goto <D.13973>;
      <D.13972>:
      monoeg_g_free (tmpdir);
      D.13974 = 0;
      return D.13974;
      <D.13973>:
      bytes.51 = bytes;
      D.13976 = bytes.51 / 2;
      dirlen = (glong) D.13976;
      D.13977 = (long int) len;
      if (D.13977 <= dirlen) goto <D.13978>; else goto <D.13979>;
      <D.13978>:
      D.13980 = (unsigned int) dirlen;
      ret = D.13980 + 1;
      goto <D.13981>;
      <D.13979>:
      bytes.51 = bytes;
      D.13982 = bytes.51 + 2;
      memset (buf, 0, D.13982);
      bytes.51 = bytes;
      memcpy (buf, tmpdir16, bytes.51);
      ret = (guint32) dirlen;
      <D.13981>:
      if (tmpdir16 != 0B) goto <D.13983>; else goto <D.13984>;
      <D.13983>:
      monoeg_g_free (tmpdir16);
      <D.13984>:
      monoeg_g_free (tmpdir);
      D.13974 = ret;
      return D.13974;
    }
  finally
    {
      bytes = {CLOBBER};
    }
}


GetLogicalDriveStrings (guint32 len, gunichar2 * buf)
{
  long unsigned int D.13987;
  long unsigned int D.13988;
  unsigned int D.13996;
  char D.13997;
  unsigned int D.14000;
  gchar * D.14001;
  long int D.14006;
  int D.14007;
  long int D.14008;
  long int D.14009;
  gint32 D.14012;
  int fd;
  gint32 ret;
  struct LinuxMountInfoParseState state;
  gboolean (*<T1d46>) (guint32, gunichar2 *, struct LinuxMountInfoParseState *) parser;
  void done_and_out = <<< error >>>;

  try
    {
      ret = 0;
      parser = 0B;
      D.13987 = (long unsigned int) len;
      D.13988 = D.13987 * 2;
      memset (buf, 0, D.13988);
      fd = open ("/proc/self/mountinfo", 0);
      if (fd != -1) goto <D.13989>; else goto <D.13990>;
      <D.13989>:
      parser = GetLogicalDriveStrings_MountInfo;
      goto <D.13991>;
      <D.13990>:
      fd = open ("/proc/mounts", 0);
      if (fd != -1) goto <D.13992>; else goto <D.13993>;
      <D.13992>:
      parser = GetLogicalDriveStrings_Mounts;
      <D.13993>:
      <D.13991>:
      if (parser == 0B) goto <D.13994>; else goto <D.13995>;
      <D.13994>:
      ret = GetLogicalDriveStrings_Mtab (len, buf);
      goto done_and_out;
      <D.13995>:
      memset (&state, 0, 1224);
      state.field_number = 1;
      state.delimiter = 32;
      goto <D.12493>;
      <D.12492>:
      state.buffer_index = 0;
      goto <D.12490>;
      <D.12489>:
      D.13996 = state.buffer_index;
      D.13997 = state.buffer[D.13996];
      if (D.13997 == 10) goto <D.13998>; else goto <D.13999>;
      <D.13998>:
      {
        gboolean quit;

        quit = add_drive_string (len, buf, &state);
        state.field_number = 1;
        D.13996 = state.buffer_index;
        D.14000 = D.13996 + 1;
        state.buffer_index = D.14000;
        D.14001 = state.mountpoint_allocated;
        if (D.14001 != 0B) goto <D.14002>; else goto <D.14003>;
        <D.14002>:
        D.14001 = state.mountpoint_allocated;
        monoeg_g_free (D.14001);
        state.mountpoint_allocated = 0B;
        <D.14003>:
        if (quit != 0) goto <D.14004>; else goto <D.14005>;
        <D.14004>:
        D.14006 = state.total;
        ret = (gint32) D.14006;
        goto done_and_out;
        <D.14005>:
      }
      <D.13999>:
      <D.12490>:
      D.14007 = parser (len, buf, &state);
      if (D.14007 != 0) goto <D.12489>; else goto <D.12491>;
      <D.12491>:
      <D.12493>:
      D.14008 = read (fd, &state.buffer, 512);
      state.nbytes = D.14008;
      D.14009 = state.nbytes;
      if (D.14009 > 0) goto <D.12492>; else goto <D.12494>;
      <D.12494>:
      D.14006 = state.total;
      ret = (gint32) D.14006;
      done_and_out:
      if (fd != -1) goto <D.14010>; else goto <D.14011>;
      <D.14010>:
      close (fd);
      <D.14011>:
      D.14012 = ret;
      return D.14012;
    }
  finally
    {
      state = {CLOBBER};
    }
}


GetLogicalDriveStrings_Mounts (guint32 len, gunichar2 * buf, struct LinuxMountInfoParseState * state)
{
  unsigned int D.14015;
  unsigned int D.14018;
  char D.14019;
  char D.14020;
  unsigned int D.14023;
  gchar * D.14024;
  unsigned int D.14027;
  sizetype D.14028;
  gchar * D.14029;
  sizetype D.14031;
  gchar * D.14032;
  unsigned int D.14033;
  long unsigned int D.14034;
  long int ptr.52;
  gchar[512] * D.14038;
  long int D.14039;
  long int D.14040;
  unsigned int D.14041;
  unsigned int D.14042;
  long int D.14044;
  unsigned int D.14045;
  gboolean D.14046;
  unsigned int D.14047;
  int D.14050;
  unsigned int D.14053;
  unsigned int D.14058;
  unsigned int D.14059;
  unsigned int D.14062;
  unsigned int D.14063;
  unsigned int D.14064;
  unsigned int D.14067;
  unsigned int D.14068;
  unsigned int D.14070;
  gchar * ptr;

  D.14015 = state->field_number;
  if (D.14015 == 1) goto <D.14016>; else goto <D.14017>;
  <D.14016>:
  state->check_mount_source = 1;
  <D.14017>:
  goto <D.12505>;
  <D.12510>:
  D.14018 = state->buffer_index;
  D.14019 = state->buffer[D.14018];
  D.14020 = state->delimiter;
  if (D.14019 == D.14020) goto <D.14021>; else goto <D.14022>;
  <D.14021>:
  D.14015 = state->field_number;
  D.14023 = D.14015 + 1;
  state->field_number = D.14023;
  D.14015 = state->field_number;
  switch (D.14015) <default: <D.12504>, case 2: <D.12501>, case 3: <D.12503>>
  <D.12501>:
  state->mountpoint_index = 0;
  goto <D.12502>;
  <D.12503>:
  D.14024 = state->mountpoint_allocated;
  if (D.14024 != 0B) goto <D.14025>; else goto <D.14026>;
  <D.14025>:
  D.14024 = state->mountpoint_allocated;
  D.14027 = state->mountpoint_index;
  D.14028 = (sizetype) D.14027;
  D.14029 = D.14024 + D.14028;
  *D.14029 = 0;
  goto <D.14030>;
  <D.14026>:
  D.14027 = state->mountpoint_index;
  state->mountpoint[D.14027] = 0;
  <D.14030>:
  goto <D.12502>;
  <D.12504>:
  D.14018 = state->buffer_index;
  D.14031 = (sizetype) D.14018;
  D.14032 = &state->buffer[D.14031];
  D.14018 = state->buffer_index;
  D.14033 = 512 - D.14018;
  D.14034 = (long unsigned int) D.14033;
  ptr = memchr (D.14032, 10, D.14034);
  if (ptr != 0B) goto <D.14035>; else goto <D.14036>;
  <D.14035>:
  ptr.52 = (long int) ptr;
  D.14038 = &state->buffer;
  D.14039 = (long int) D.14038;
  D.14040 = ptr.52 - D.14039;
  D.14041 = (unsigned int) D.14040;
  D.14042 = D.14041 + 4294967295;
  state->buffer_index = D.14042;
  goto <D.14043>;
  <D.14036>:
  D.14044 = state->nbytes;
  D.14045 = (unsigned int) D.14044;
  state->buffer_index = D.14045;
  <D.14043>:
  D.14046 = 1;
  return D.14046;
  <D.12502>:
  D.14018 = state->buffer_index;
  D.14047 = D.14018 + 1;
  state->buffer_index = D.14047;
  // predicted unlikely by continue predictor.
  goto <D.12505>;
  <D.14022>:
  D.14018 = state->buffer_index;
  D.14019 = state->buffer[D.14018];
  if (D.14019 == 10) goto <D.14048>; else goto <D.14049>;
  <D.14048>:
  D.14046 = 1;
  return D.14046;
  <D.14049>:
  D.14015 = state->field_number;
  switch (D.14015) <default: <D.14069>, case 1: <D.12506>, case 2: <D.12508>, case 3: <D.12509>>
  <D.12506>:
  D.14050 = state->check_mount_source;
  if (D.14050 != 0) goto <D.14051>; else goto <D.14052>;
  <D.14051>:
  D.14053 = state->fsname_index;
  if (D.14053 == 0) goto <D.14054>; else goto <D.14055>;
  <D.14054>:
  D.14018 = state->buffer_index;
  D.14019 = state->buffer[D.14018];
  if (D.14019 == 47) goto <D.14056>; else goto <D.14057>;
  <D.14056>:
  state->check_mount_source = 0;
  D.14053 = state->fsname_index;
  D.14058 = D.14053;
  D.14059 = D.14058 + 1;
  state->fsname_index = D.14059;
  state->fsname[D.14058] = 47;
  goto <D.12507>;
  <D.14057>:
  <D.14055>:
  D.14053 = state->fsname_index;
  if (D.14053 <= 63) goto <D.14060>; else goto <D.14061>;
  <D.14060>:
  D.14053 = state->fsname_index;
  D.14062 = D.14053;
  D.14063 = D.14062 + 1;
  state->fsname_index = D.14063;
  D.14018 = state->buffer_index;
  D.14019 = state->buffer[D.14018];
  state->fsname[D.14062] = D.14019;
  <D.14061>:
  <D.14052>:
  goto <D.12507>;
  <D.12508>:
  append_to_mountpoint (state);
  goto <D.12507>;
  <D.12509>:
  D.14064 = state->fstype_index;
  if (D.14064 <= 63) goto <D.14065>; else goto <D.14066>;
  <D.14065>:
  D.14064 = state->fstype_index;
  D.14067 = D.14064;
  D.14068 = D.14067 + 1;
  state->fstype_index = D.14068;
  D.14018 = state->buffer_index;
  D.14019 = state->buffer[D.14018];
  state->fstype[D.14067] = D.14019;
  <D.14066>:
  goto <D.12507>;
  <D.14069>:
  <D.12507>:
  D.14018 = state->buffer_index;
  D.14047 = D.14018 + 1;
  state->buffer_index = D.14047;
  <D.12505>:
  D.14018 = state->buffer_index;
  D.14044 = state->nbytes;
  D.14070 = (unsigned int) D.14044;
  if (D.14018 < D.14070) goto <D.12510>; else goto <D.12511>;
  <D.12511>:
  D.14046 = 0;
  return D.14046;
}


append_to_mountpoint (struct LinuxMountInfoParseState * state)
{
  unsigned int D.14072;
  gchar * D.14073;
  unsigned int D.14076;
  unsigned int D.14077;
  unsigned int D.14080;
  long unsigned int D.14081;
  long unsigned int D.14082;
  unsigned int D.14083;
  unsigned int D.14084;
  sizetype D.14085;
  gchar * D.14086;
  unsigned int D.14090;
  unsigned int D.14091;
  long unsigned int D.14092;
  void * D.14093;
  gchar[513] * D.14094;
  unsigned int D.14095;
  unsigned int D.14096;
  sizetype D.14097;
  gchar * D.14098;
  unsigned int D.14100;
  unsigned int D.14101;
  gchar ch;

  D.14072 = state->buffer_index;
  ch = state->buffer[D.14072];
  D.14073 = state->mountpoint_allocated;
  if (D.14073 != 0B) goto <D.14074>; else goto <D.14075>;
  <D.14074>:
  D.14076 = state->mountpoint_index;
  D.14077 = state->allocated_size;
  if (D.14076 >= D.14077) goto <D.14078>; else goto <D.14079>;
  <D.14078>:
  {
    guint32 newsize;
    gchar * newbuf;

    D.14077 = state->allocated_size;
    D.14080 = D.14077 << 1;
    newsize = D.14080 + 1;
    D.14081 = (long unsigned int) newsize;
    newbuf = monoeg_malloc0 (D.14081);
    D.14073 = state->mountpoint_allocated;
    D.14076 = state->mountpoint_index;
    D.14082 = (long unsigned int) D.14076;
    memcpy (newbuf, D.14073, D.14082);
    D.14073 = state->mountpoint_allocated;
    monoeg_g_free (D.14073);
    state->mountpoint_allocated = newbuf;
    state->allocated_size = newsize;
  }
  <D.14079>:
  D.14073 = state->mountpoint_allocated;
  D.14076 = state->mountpoint_index;
  D.14083 = D.14076;
  D.14084 = D.14083 + 1;
  state->mountpoint_index = D.14084;
  D.14085 = (sizetype) D.14083;
  D.14086 = D.14073 + D.14085;
  *D.14086 = ch;
  goto <D.14087>;
  <D.14075>:
  D.14076 = state->mountpoint_index;
  if (D.14076 > 511) goto <D.14088>; else goto <D.14089>;
  <D.14088>:
  D.14076 = state->mountpoint_index;
  D.14090 = D.14076 << 1;
  D.14091 = D.14090 + 1;
  state->allocated_size = D.14091;
  D.14077 = state->allocated_size;
  D.14092 = (long unsigned int) D.14077;
  D.14093 = monoeg_malloc0 (D.14092);
  state->mountpoint_allocated = D.14093;
  D.14073 = state->mountpoint_allocated;
  D.14094 = &state->mountpoint;
  D.14076 = state->mountpoint_index;
  D.14082 = (long unsigned int) D.14076;
  memcpy (D.14073, D.14094, D.14082);
  D.14073 = state->mountpoint_allocated;
  D.14076 = state->mountpoint_index;
  D.14095 = D.14076;
  D.14096 = D.14095 + 1;
  state->mountpoint_index = D.14096;
  D.14097 = (sizetype) D.14095;
  D.14098 = D.14073 + D.14097;
  *D.14098 = ch;
  goto <D.14099>;
  <D.14089>:
  D.14076 = state->mountpoint_index;
  D.14100 = D.14076;
  D.14101 = D.14100 + 1;
  state->mountpoint_index = D.14101;
  state->mountpoint[D.14100] = ch;
  <D.14099>:
  <D.14087>:
}


GetLogicalDriveStrings_MountInfo (guint32 len, gunichar2 * buf, struct LinuxMountInfoParseState * state)
{
  unsigned int D.14102;
  char D.14103;
  char D.14104;
  unsigned int D.14107;
  unsigned int D.14108;
  gchar * D.14109;
  unsigned int D.14112;
  sizetype D.14113;
  gchar * D.14114;
  unsigned int D.14117;
  gboolean D.14120;
  unsigned int D.14121;
  unsigned int D.14124;
  unsigned int D.14125;
  int D.14126;
  unsigned int D.14129;
  unsigned int D.14134;
  unsigned int D.14135;
  unsigned int D.14138;
  unsigned int D.14139;
  long int D.14141;
  unsigned int D.14142;

  goto <D.12523>;
  <D.12528>:
  D.14102 = state->buffer_index;
  D.14103 = state->buffer[D.14102];
  D.14104 = state->delimiter;
  if (D.14103 == D.14104) goto <D.14105>; else goto <D.14106>;
  <D.14105>:
  D.14107 = state->field_number;
  D.14108 = D.14107 + 1;
  state->field_number = D.14108;
  D.14107 = state->field_number;
  switch (D.14107) <default: <D.14116>, case 5: <D.12517>, case 6: <D.12519>, case 7: <D.12520>, case 8: <D.12521>, case 10: <D.12522>>
  <D.12517>:
  state->mountpoint_index = 0;
  goto <D.12518>;
  <D.12519>:
  D.14109 = state->mountpoint_allocated;
  if (D.14109 != 0B) goto <D.14110>; else goto <D.14111>;
  <D.14110>:
  D.14109 = state->mountpoint_allocated;
  D.14112 = state->mountpoint_index;
  D.14113 = (sizetype) D.14112;
  D.14114 = D.14109 + D.14113;
  *D.14114 = 0;
  goto <D.14115>;
  <D.14111>:
  D.14112 = state->mountpoint_index;
  state->mountpoint[D.14112] = 0;
  <D.14115>:
  goto <D.12518>;
  <D.12520>:
  state->delimiter = 45;
  goto <D.12518>;
  <D.12521>:
  state->delimiter = 32;
  goto <D.12518>;
  <D.12522>:
  state->check_mount_source = 1;
  goto <D.12518>;
  <D.14116>:
  <D.12518>:
  D.14102 = state->buffer_index;
  D.14117 = D.14102 + 1;
  state->buffer_index = D.14117;
  // predicted unlikely by continue predictor.
  goto <D.12523>;
  <D.14106>:
  D.14102 = state->buffer_index;
  D.14103 = state->buffer[D.14102];
  if (D.14103 == 10) goto <D.14118>; else goto <D.14119>;
  <D.14118>:
  D.14120 = 1;
  return D.14120;
  <D.14119>:
  D.14107 = state->field_number;
  switch (D.14107) <default: <D.14140>, case 5: <D.12524>, case 9: <D.12526>, case 10: <D.12527>>
  <D.12524>:
  append_to_mountpoint (state);
  goto <D.12525>;
  <D.12526>:
  D.14121 = state->fstype_index;
  if (D.14121 <= 63) goto <D.14122>; else goto <D.14123>;
  <D.14122>:
  D.14121 = state->fstype_index;
  D.14124 = D.14121;
  D.14125 = D.14124 + 1;
  state->fstype_index = D.14125;
  D.14102 = state->buffer_index;
  D.14103 = state->buffer[D.14102];
  state->fstype[D.14124] = D.14103;
  <D.14123>:
  goto <D.12525>;
  <D.12527>:
  D.14126 = state->check_mount_source;
  if (D.14126 != 0) goto <D.14127>; else goto <D.14128>;
  <D.14127>:
  D.14129 = state->fsname_index;
  if (D.14129 == 0) goto <D.14130>; else goto <D.14131>;
  <D.14130>:
  D.14102 = state->buffer_index;
  D.14103 = state->buffer[D.14102];
  if (D.14103 == 47) goto <D.14132>; else goto <D.14133>;
  <D.14132>:
  state->check_mount_source = 0;
  D.14129 = state->fsname_index;
  D.14134 = D.14129;
  D.14135 = D.14134 + 1;
  state->fsname_index = D.14135;
  state->fsname[D.14134] = 47;
  goto <D.12525>;
  <D.14133>:
  <D.14131>:
  D.14129 = state->fsname_index;
  if (D.14129 <= 63) goto <D.14136>; else goto <D.14137>;
  <D.14136>:
  D.14129 = state->fsname_index;
  D.14138 = D.14129;
  D.14139 = D.14138 + 1;
  state->fsname_index = D.14139;
  D.14102 = state->buffer_index;
  D.14103 = state->buffer[D.14102];
  state->fsname[D.14138] = D.14103;
  <D.14137>:
  <D.14128>:
  goto <D.12525>;
  <D.14140>:
  <D.12525>:
  D.14102 = state->buffer_index;
  D.14117 = D.14102 + 1;
  state->buffer_index = D.14117;
  <D.12523>:
  D.14102 = state->buffer_index;
  D.14141 = state->nbytes;
  D.14142 = (unsigned int) D.14141;
  if (D.14102 < D.14142) goto <D.12528>; else goto <D.12529>;
  <D.12529>:
  D.14120 = 0;
  return D.14120;
}


open (const char * __path, int __oflag)
{
  int D.14144;
  int D.14147;
  int D.14152;
  int D.14154;
  int D.14155;
  int D.14158;
  int D.14159;

  D.14144 = __builtin_va_arg_pack_len ();
  if (D.14144 > 1) goto <D.14145>; else goto <D.14146>;
  <D.14145>:
  __open_too_many_args ();
  <D.14146>:
  D.14147 = __builtin_constant_p (__oflag);
  if (D.14147 != 0) goto <D.14148>; else goto <D.14149>;
  <D.14148>:
  D.14152 = __oflag & 64;
  if (D.14152 != 0) goto <D.14150>; else goto <D.14153>;
  <D.14153>:
  D.14154 = __oflag & 4259840;
  if (D.14154 == 4259840) goto <D.14150>; else goto <D.14151>;
  <D.14150>:
  D.14155 = __builtin_va_arg_pack_len ();
  if (D.14155 <= 0) goto <D.14156>; else goto <D.14157>;
  <D.14156>:
  __open_missing_mode ();
  D.14158 = __open_2 (__path, __oflag);
  return D.14158;
  <D.14157>:
  <D.14151>:
  D.14158 = __open_alias (__path, __oflag, __builtin_va_arg_pack ());
  return D.14158;
  <D.14149>:
  D.14159 = __builtin_va_arg_pack_len ();
  if (D.14159 <= 0) goto <D.14160>; else goto <D.14161>;
  <D.14160>:
  D.14158 = __open_2 (__path, __oflag);
  return D.14158;
  <D.14161>:
  D.14158 = __open_alias (__path, __oflag, __builtin_va_arg_pack ());
  return D.14158;
}


GetLogicalDriveStrings_Mtab (guint32 len, gunichar2 * buf)
{
  unsigned int D.14163;
  long unsigned int D.14164;
  long unsigned int D.14165;
  gunichar2 * D.14166;
  gunichar2 * D.14167;
  gint32 D.14172;
  char D.14173;
  gchar * D.14178;
  gchar * * D.14180;
  gchar * D.14181;
  long int length.53;
  long int D.14183;
  long int D.14184;
  unsigned int D.14187;
  long unsigned int total.54;
  long unsigned int D.14189;
  gunichar2 * D.14190;
  long unsigned int length.55;
  long unsigned int D.14192;
  long int D.14193;
  char * D.14194;
  struct FILE * fp;
  gunichar2 * ptr;
  gunichar2 * dir;
  glong length;
  glong total;
  gchar buffer[512];
  gchar * * splitted;

  try
    {
      total = 0;
      D.14163 = len + 1;
      D.14164 = (long unsigned int) D.14163;
      D.14165 = D.14164 * 2;
      memset (buf, 0, D.14165);
      *buf = 47;
      D.14166 = buf + 2;
      *D.14166 = 0;
      D.14167 = buf + 4;
      *D.14167 = 0;
      fp = fopen ("/etc/mtab", "rt");
      if (fp == 0B) goto <D.14168>; else goto <D.14169>;
      <D.14168>:
      fp = fopen ("/etc/mnttab", "rt");
      if (fp == 0B) goto <D.14170>; else goto <D.14171>;
      <D.14170>:
      D.14172 = 1;
      return D.14172;
      <D.14171>:
      <D.14169>:
      ptr = buf;
      goto <D.12557>;
      <D.12558>:
      D.14173 = buffer[0];
      if (D.14173 != 47) goto <D.14174>; else goto <D.14175>;
      <D.14174>:
      // predicted unlikely by continue predictor.
      goto <D.12557>;
      <D.14175>:
      splitted = monoeg_g_strsplit (&buffer, " ", 0);
      D.14178 = *splitted;
      if (D.14178 == 0B) goto <D.14176>; else goto <D.14179>;
      <D.14179>:
      D.14180 = splitted + 8;
      D.14181 = *D.14180;
      if (D.14181 == 0B) goto <D.14176>; else goto <D.14177>;
      <D.14176>:
      monoeg_g_strfreev (splitted);
      // predicted unlikely by continue predictor.
      goto <D.12557>;
      <D.14177>:
      D.14180 = splitted + 8;
      D.14181 = *D.14180;
      unescape_octal (D.14181);
      D.14180 = splitted + 8;
      D.14181 = *D.14180;
      dir = monoeg_g_utf8_to_utf16 (D.14181, -1, 0B, &length, 0B);
      monoeg_g_strfreev (splitted);
      length.53 = length;
      D.14183 = total + length.53;
      D.14184 = (long int) len;
      if (D.14183 >= D.14184) goto <D.14185>; else goto <D.14186>;
      <D.14185>:
      fclose (fp);
      monoeg_g_free (dir);
      D.14187 = len * 2;
      D.14172 = (gint32) D.14187;
      return D.14172;
      <D.14186>:
      total.54 = (long unsigned int) total;
      D.14189 = total.54 * 2;
      D.14190 = ptr + D.14189;
      length.53 = length;
      length.55 = (long unsigned int) length.53;
      D.14192 = length.55 * 2;
      memcpy (D.14190, dir, D.14192);
      monoeg_g_free (dir);
      length.53 = length;
      D.14193 = length.53 + 1;
      total = D.14193 + total;
      <D.12557>:
      D.14194 = fgets (&buffer, 512, fp);
      if (D.14194 != 0B) goto <D.12558>; else goto <D.12559>;
      <D.12559>:
      fclose (fp);
      D.14172 = (gint32) total;
      return D.14172;
    }
  finally
    {
      length = {CLOBBER};
      buffer = {CLOBBER};
    }
}


unescape_octal (gchar * str)
{
  char D.14199;
  gchar * rptr.56;
  char D.14203;
  char D.14204;
  gchar * rptr.57;
  char D.14206;
  int D.14207;
  int D.14208;
  int D.14209;
  char D.14210;
  gchar * rptr.58;
  char D.14212;
  int D.14213;
  int D.14214;
  char D.14215;
  gchar * wptr.59;
  gchar * wptr.60;
  gchar * rptr.61;
  char D.14222;
  gchar * rptr;
  gchar * wptr;

  if (str == 0B) goto <D.14197>; else goto <D.14198>;
  <D.14197>:
  return;
  <D.14198>:
  wptr = str;
  rptr = wptr;
  goto <D.12440>;
  <D.12439>:
  D.14199 = *rptr;
  if (D.14199 == 92) goto <D.14200>; else goto <D.14201>;
  <D.14200>:
  {
    char c;

    rptr = rptr + 1;
    rptr.56 = rptr;
    rptr = rptr.56 + 1;
    D.14203 = *rptr.56;
    D.14204 = D.14203 + 208;
    c = D.14204 << 6;
    rptr.57 = rptr;
    rptr = rptr.57 + 1;
    D.14206 = *rptr.57;
    D.14207 = (int) D.14206;
    D.14208 = D.14207 + -48;
    D.14209 = D.14208 << 3;
    D.14210 = (char) D.14209;
    c = D.14210 + c;
    rptr.58 = rptr;
    rptr = rptr.58 + 1;
    D.14212 = *rptr.58;
    D.14213 = (int) D.14212;
    D.14214 = D.14213 + -48;
    D.14215 = (char) D.14214;
    c = D.14215 + c;
    wptr.59 = wptr;
    wptr = wptr.59 + 1;
    *wptr.59 = c;
  }
  goto <D.14217>;
  <D.14201>:
  if (wptr != rptr) goto <D.14218>; else goto <D.14219>;
  <D.14218>:
  wptr.60 = wptr;
  wptr = wptr.60 + 1;
  rptr.61 = rptr;
  rptr = rptr.61 + 1;
  D.14222 = *rptr.61;
  *wptr.60 = D.14222;
  goto <D.14223>;
  <D.14219>:
  rptr = rptr + 1;
  wptr = wptr + 1;
  <D.14223>:
  <D.14217>:
  <D.12440>:
  D.14199 = *rptr;
  if (D.14199 != 0) goto <D.12439>; else goto <D.12441>;
  <D.12441>:
  *wptr = 0;
}


fgets (char * restrict __s, int __n, struct FILE * restrict __stream)
{
  long unsigned int D.14225;
  int D.14230;
  char * D.14232;
  long unsigned int D.14233;
  long unsigned int D.14234;
  long unsigned int D.14235;
  long unsigned int D.14238;

  D.14225 = __builtin_object_size (__s, 1);
  if (D.14225 != 18446744073709551615) goto <D.14226>; else goto <D.14227>;
  <D.14226>:
  D.14230 = __builtin_constant_p (__n);
  if (D.14230 == 0) goto <D.14228>; else goto <D.14231>;
  <D.14231>:
  if (__n <= 0) goto <D.14228>; else goto <D.14229>;
  <D.14228>:
  D.14233 = __builtin_object_size (__s, 1);
  D.14232 = __fgets_chk (__s, D.14233, __n, __stream);
  return D.14232;
  <D.14229>:
  D.14234 = (long unsigned int) __n;
  D.14235 = __builtin_object_size (__s, 1);
  if (D.14234 > D.14235) goto <D.14236>; else goto <D.14237>;
  <D.14236>:
  D.14238 = __builtin_object_size (__s, 1);
  D.14232 = __fgets_chk_warn (__s, D.14238, __n, __stream);
  return D.14232;
  <D.14237>:
  <D.14227>:
  D.14232 = __fgets_alias (__s, __n, __stream);
  return D.14232;
}


add_drive_string (guint32 len, gunichar2 * buf, struct LinuxMountInfoParseState * state)
{
  unsigned int D.14242;
  char D.14244;
  gchar[65] * D.14250;
  long unsigned int D.14251;
  int D.14252;
  unsigned int D.14255;
  gchar[65] * D.14257;
  int D.14258;
  long unsigned int D.14263;
  int D.14264;
  gchar * iftmp.62;
  gchar * D.14269;
  long int D.14273;
  long int length.63;
  long int D.14275;
  long int D.14276;
  unsigned int D.14279;
  long int D.14280;
  long int length.64;
  long unsigned int D.14283;
  long unsigned int D.14284;
  gunichar2 * D.14285;
  long unsigned int length.65;
  long unsigned int D.14287;
  gboolean D.14288;
  gboolean quit;
  gboolean ignore_entry;

  quit = 0;
  D.14242 = state->fsname_index;
  if (D.14242 == 1) goto <D.14243>; else goto <D.14240>;
  <D.14243>:
  D.14244 = state->fsname[0];
  if (D.14244 == 47) goto <D.14245>; else goto <D.14240>;
  <D.14245>:
  ignore_entry = 0;
  goto <D.14241>;
  <D.14240>:
  D.14242 = state->fsname_index;
  if (D.14242 == 0) goto <D.14246>; else goto <D.14249>;
  <D.14249>:
  D.14250 = &state->fsname;
  D.14242 = state->fsname_index;
  D.14251 = (long unsigned int) D.14242;
  D.14252 = memcmp ("none", D.14250, D.14251);
  if (D.14252 == 0) goto <D.14246>; else goto <D.14247>;
  <D.14246>:
  ignore_entry = 1;
  goto <D.14248>;
  <D.14247>:
  D.14255 = state->fstype_index;
  if (D.14255 > 4) goto <D.14256>; else goto <D.14253>;
  <D.14256>:
  D.14257 = &state->fstype;
  D.14258 = memcmp ("fuse.", D.14257, 5);
  if (D.14258 == 0) goto <D.14259>; else goto <D.14253>;
  <D.14259>:
  D.14255 = state->fstype_index;
  if (D.14255 == 21) goto <D.14262>; else goto <D.14260>;
  <D.14262>:
  D.14257 = &state->fstype;
  D.14255 = state->fstype_index;
  D.14263 = (long unsigned int) D.14255;
  D.14264 = memcmp ("fuse.gvfs-fuse-daemon", D.14257, D.14263);
  if (D.14264 == 0) goto <D.14265>; else goto <D.14260>;
  <D.14265>:
  ignore_entry = 1;
  goto <D.14261>;
  <D.14260>:
  ignore_entry = 0;
  <D.14261>:
  goto <D.14254>;
  <D.14253>:
  ignore_entry = 1;
  <D.14254>:
  <D.14248>:
  <D.14241>:
  if (ignore_entry == 0) goto <D.14266>; else goto <D.14267>;
  <D.14266>:
  {
    gunichar2 * dir;
    glong length;
    gchar * mountpoint;

    try
      {
        D.14269 = state->mountpoint_allocated;
        if (D.14269 != 0B) goto <D.14270>; else goto <D.14271>;
        <D.14270>:
        iftmp.62 = state->mountpoint_allocated;
        goto <D.14272>;
        <D.14271>:
        iftmp.62 = &state->mountpoint;
        <D.14272>:
        mountpoint = iftmp.62;
        unescape_octal (mountpoint);
        dir = monoeg_g_utf8_to_utf16 (mountpoint, -1, 0B, &length, 0B);
        D.14273 = state->total;
        length.63 = length;
        D.14275 = D.14273 + length.63;
        D.14276 = (long int) len;
        if (D.14275 >= D.14276) goto <D.14277>; else goto <D.14278>;
        <D.14277>:
        quit = 1;
        D.14279 = len * 2;
        D.14280 = (long int) D.14279;
        state->total = D.14280;
        goto <D.14281>;
        <D.14278>:
        length.63 = length;
        length.64 = length.63 + 1;
        length = length.64;
        D.14273 = state->total;
        D.14283 = (long unsigned int) D.14273;
        D.14284 = D.14283 * 2;
        D.14285 = buf + D.14284;
        length.63 = length;
        length.65 = (long unsigned int) length.63;
        D.14287 = length.65 * 2;
        memcpy (D.14285, dir, D.14287);
        D.14273 = state->total;
        length.63 = length;
        D.14275 = D.14273 + length.63;
        state->total = D.14275;
        <D.14281>:
        monoeg_g_free (dir);
      }
    finally
      {
        length = {CLOBBER};
      }
  }
  <D.14267>:
  state->fsname_index = 0;
  state->fstype_index = 0;
  D.14288 = quit;
  return D.14288;
}


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.14292;
  gboolean D.14295;
  long unsigned int D.14299;
  long unsigned int D.14300;
  _Bool D.14301;
  int * D.14303;
  int D.14304;
  long unsigned int D.14312;
  long unsigned int D.14313;
  long unsigned int D.14316;
  long unsigned int D.14317;
  long unsigned int D.14323;
  long unsigned int D.14324;
  struct statvfs fsstat;
  gboolean isreadonly;
  gchar * utf8_path_name;
  int ret;
  long unsigned int block_size;

  try
    {
      if (path_name == 0B) goto <D.14290>; else goto <D.14291>;
      <D.14290>:
      D.14292 = monoeg_g_get_current_dir ();
      utf8_path_name = monoeg_strdup (D.14292);
      if (utf8_path_name == 0B) goto <D.14293>; else goto <D.14294>;
      <D.14293>:
      SetLastError (267);
      D.14295 = 0;
      return D.14295;
      <D.14294>:
      goto <D.14296>;
      <D.14291>:
      utf8_path_name = mono_unicode_to_external (path_name);
      if (utf8_path_name == 0B) goto <D.14297>; else goto <D.14298>;
      <D.14297>:
      SetLastError (123);
      D.14295 = 0;
      return D.14295;
      <D.14298>:
      <D.14296>:
      <D.12571>:
      ret = statvfs (utf8_path_name, &fsstat);
      D.14299 = fsstat.f_flag;
      D.14300 = D.14299 & 1;
      D.14301 = D.14300 != 0;
      isreadonly = (gboolean) D.14301;
      block_size = fsstat.f_frsize;
      if (ret == -1) goto <D.14302>; else goto <D.12572>;
      <D.14302>:
      D.14303 = __errno_location ();
      D.14304 = *D.14303;
      if (D.14304 == 4) goto <D.12571>; else goto <D.12572>;
      <D.12572>:
      monoeg_g_free (utf8_path_name);
      if (ret == -1) goto <D.14305>; else goto <D.14306>;
      <D.14305>:
      _wapi_set_last_error_from_errno ();
      D.14295 = 0;
      return D.14295;
      <D.14306>:
      if (free_bytes_avail != 0B) goto <D.14307>; else goto <D.14308>;
      <D.14307>:
      if (isreadonly != 0) goto <D.14309>; else goto <D.14310>;
      <D.14309>:
      free_bytes_avail->QuadPart = 0;
      goto <D.14311>;
      <D.14310>:
      D.14312 = fsstat.f_bavail;
      D.14313 = D.14312 * block_size;
      free_bytes_avail->QuadPart = D.14313;
      <D.14311>:
      <D.14308>:
      if (total_number_of_bytes != 0B) goto <D.14314>; else goto <D.14315>;
      <D.14314>:
      D.14316 = fsstat.f_blocks;
      D.14317 = D.14316 * block_size;
      total_number_of_bytes->QuadPart = D.14317;
      <D.14315>:
      if (total_number_of_free_bytes != 0B) goto <D.14318>; else goto <D.14319>;
      <D.14318>:
      if (isreadonly != 0) goto <D.14320>; else goto <D.14321>;
      <D.14320>:
      total_number_of_free_bytes->QuadPart = 0;
      goto <D.14322>;
      <D.14321>:
      D.14323 = fsstat.f_bfree;
      D.14324 = D.14323 * block_size;
      total_number_of_free_bytes->QuadPart = D.14324;
      <D.14322>:
      <D.14319>:
      D.14295 = 1;
      return D.14295;
    }
  finally
    {
      fsstat = {CLOBBER};
    }
}


GetDriveType (const gunichar2 * root_path_name)
{
  gchar * D.14329;
  guint32 D.14332;
  int D.14336;
  gchar * D.14339;
  char D.14340;
  long unsigned int D.14343;
  sizetype D.14344;
  gchar * D.14345;
  gchar * utf8_root_path_name;
  guint32 drive_type;

  if (root_path_name == 0B) goto <D.14327>; else goto <D.14328>;
  <D.14327>:
  D.14329 = monoeg_g_get_current_dir ();
  utf8_root_path_name = monoeg_strdup (D.14329);
  if (utf8_root_path_name == 0B) goto <D.14330>; else goto <D.14331>;
  <D.14330>:
  D.14332 = 1;
  return D.14332;
  <D.14331>:
  goto <D.14333>;
  <D.14328>:
  utf8_root_path_name = mono_unicode_to_external (root_path_name);
  if (utf8_root_path_name == 0B) goto <D.14334>; else goto <D.14335>;
  <D.14334>:
  D.14332 = 1;
  return D.14332;
  <D.14335>:
  D.14336 = monoeg_g_str_has_suffix (utf8_root_path_name, "/");
  if (D.14336 != 0) goto <D.14337>; else goto <D.14338>;
  <D.14337>:
  D.14339 = utf8_root_path_name + 1;
  D.14340 = *D.14339;
  if (D.14340 != 0) goto <D.14341>; else goto <D.14342>;
  <D.14341>:
  D.14343 = strlen (utf8_root_path_name);
  D.14344 = D.14343 + 18446744073709551615;
  D.14345 = utf8_root_path_name + D.14344;
  *D.14345 = 0;
  <D.14342>:
  <D.14338>:
  <D.14333>:
  drive_type = GetDriveTypeFromPath (utf8_root_path_name);
  monoeg_g_free (utf8_root_path_name);
  D.14332 = drive_type;
  return D.14332;
}


GetDriveTypeFromPath (const char * utf8_root_path_name)
{
  int D.14347;
  guint32 D.14350;
  long int D.14351;
  struct statfs buf;

  try
    {
      D.14347 = statfs (utf8_root_path_name, &buf);
      if (D.14347 == -1) goto <D.14348>; else goto <D.14349>;
      <D.14348>:
      D.14350 = 0;
      return D.14350;
      <D.14349>:
      D.14351 = buf.f_type;
      D.14350 = _wapi_get_drive_type (D.14351);
      return D.14350;
    }
  finally
    {
      buf = {CLOBBER};
    }
}


_wapi_get_drive_type (long int f_type)
{
  long int D.14354;
  guint32 D.14357;
  unsigned int D.14358;
  struct _wapi_drive_type * current;

  current = &_wapi_drive_types[0];
  goto <D.12584>;
  <D.12583>:
  D.14354 = current->fstypeid;
  if (D.14354 == f_type) goto <D.14355>; else goto <D.14356>;
  <D.14355>:
  D.14357 = current->drive_type;
  return D.14357;
  <D.14356>:
  current = current + 24;
  <D.12584>:
  D.14358 = current->drive_type;
  if (D.14358 != 0) goto <D.12583>; else goto <D.12585>;
  <D.12585>:
  D.14357 = 0;
  return D.14357;
}


GetVolumeInformation (const gunichar2 * path, gunichar2 * volumename, int volumesize, int * outserial, int * maxcomp, int * fsflags, gunichar2 * fsbuffer, int fsbuffersize)
{
  gboolean D.14362;
  long int D.14367;
  long int len.66;
  long unsigned int len.67;
  long unsigned int D.14372;
  gunichar2 * D.14373;
  gchar * utfpath;
  gchar * fstypename;
  gboolean status;
  glong len;

  try
    {
      status = 0;
      if (fsbuffer == 0B) goto <D.14360>; else goto <D.14361>;
      <D.14360>:
      D.14362 = 0;
      return D.14362;
      <D.14361>:
      utfpath = mono_unicode_to_external (path);
      fstypename = get_fstypename (utfpath);
      if (fstypename != 0B) goto <D.14363>; else goto <D.14364>;
      <D.14363>:
      {
        gunichar2 * ret;

        ret = monoeg_g_utf8_to_utf16 (fstypename, -1, 0B, &len, 0B);
        if (ret != 0B) goto <D.14365>; else goto <D.14366>;
        <D.14365>:
        D.14367 = (long int) fsbuffersize;
        len.66 = len;
        if (D.14367 > len.66) goto <D.14369>; else goto <D.14370>;
        <D.14369>:
        len.66 = len;
        len.67 = (long unsigned int) len.66;
        D.14372 = len.67 * 2;
        memcpy (fsbuffer, ret, D.14372);
        len.66 = len;
        len.67 = (long unsigned int) len.66;
        D.14372 = len.67 * 2;
        D.14373 = fsbuffer + D.14372;
        *D.14373 = 0;
        status = 1;
        <D.14370>:
        <D.14366>:
        if (ret != 0B) goto <D.14374>; else goto <D.14375>;
        <D.14374>:
        monoeg_g_free (ret);
        <D.14375>:
        monoeg_g_free (fstypename);
      }
      <D.14364>:
      monoeg_g_free (utfpath);
      D.14362 = status;
      return D.14362;
    }
  finally
    {
      len = {CLOBBER};
    }
}


get_fstypename (gchar * utfpath)
{
  int D.14378;
  gchar * D.14381;
  long int D.14382;
  long int D.14383;
  const gchar * D.14386;
  unsigned int D.14387;
  struct statfs stat;
  struct _wapi_drive_type * current;

  try
    {
      D.14378 = statfs (utfpath, &stat);
      if (D.14378 == -1) goto <D.14379>; else goto <D.14380>;
      <D.14379>:
      D.14381 = 0B;
      return D.14381;
      <D.14380>:
      current = &_wapi_drive_types[0];
      goto <D.12601>;
      <D.12600>:
      D.14382 = stat.f_type;
      D.14383 = current->fstypeid;
      if (D.14382 == D.14383) goto <D.14384>; else goto <D.14385>;
      <D.14384>:
      D.14386 = current->fstype;
      D.14381 = monoeg_strdup (D.14386);
      return D.14381;
      <D.14385>:
      current = current + 24;
      <D.12601>:
      D.14387 = current->drive_type;
      if (D.14387 != 0) goto <D.12600>; else goto <D.12602>;
      <D.12602>:
      D.14381 = 0B;
      return D.14381;
    }
  finally
    {
      stat = {CLOBBER};
    }
}


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


