file_close (void * handle, void * data)
{
  unsigned int D.14314;
  unsigned int D.14315;
  gchar * D.14318;
  struct _WapiFileShare * D.14319;
  struct _WapiHandle_file * file_handle;
  int fd;

  file_handle = data;
  fd = file_handle->fd;
  D.14314 = file_handle->attrs;
  D.14315 = D.14314 & 67108864;
  if (D.14315 != 0) goto <D.14316>; else goto <D.14317>;
  <D.14316>:
  D.14318 = file_handle->filename;
  _wapi_unlink (D.14318);
  <D.14317>:
  D.14318 = file_handle->filename;
  monoeg_g_free (D.14318);
  D.14319 = file_handle->share_info;
  if (D.14319 != 0B) goto <D.14320>; else goto <D.14321>;
  <D.14320>:
  D.14319 = file_handle->share_info;
  _wapi_handle_share_release (D.14319);
  <D.14321>:
  close (fd);
}


_wapi_handle_share_release (struct _WapiFileShare * info)
{
  unsigned int D.14322;
  _Bool D.14323;
  long int D.14324;
  long int D.14325;
  _Bool D.14328;
  long int D.14329;
  long int D.14330;
  guint32 * D.14333;
  int D.14334;
  int thr_ret;

  D.14322 = info->handle_refs;
  D.14323 = D.14322 == 0;
  D.14324 = (long int) D.14323;
  D.14325 = __builtin_expect (D.14324, 0);
  if (D.14325 != 0) goto <D.14326>; else goto <D.14327>;
  <D.14326>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "../../mono/io-layer/handles-private.h", 364, "info->handle_refs > 0");
  <D.14327>:
  thr_ret = _wapi_shm_sem_lock (2);
  D.14328 = thr_ret != 0;
  D.14329 = (long int) D.14328;
  D.14330 = __builtin_expect (D.14329, 0);
  if (D.14330 != 0) goto <D.14331>; else goto <D.14332>;
  <D.14331>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "../../mono/io-layer/handles-private.h", 368, "thr_ret == 0");
  <D.14332>:
  D.14333 = &info->handle_refs;
  D.14334 = InterlockedDecrement (D.14333);
  if (D.14334 == 0) goto <D.14335>; else goto <D.14336>;
  <D.14335>:
  _wapi_free_share_info (info);
  <D.14336>:
  thr_ret = _wapi_shm_sem_unlock (2);
}


InterlockedDecrement (volatile gint32 * val)
{
  gint32 D.14337;
  unsigned int D.14338;

  D.14338 = __sync_sub_and_fetch_4 (val, 1);
  D.14337 = (gint32) D.14338;
  return D.14337;
}


_wapi_file_details (void * handle_info)
{
  gchar * D.14340;
  int iftmp.0;
  unsigned int D.14342;
  signed int D.14343;
  int iftmp.1;
  unsigned int D.14348;
  int iftmp.2;
  unsigned int D.14353;
  int iftmp.3;
  unsigned int D.14358;
  unsigned int D.14359;
  int iftmp.4;
  unsigned int D.14364;
  int iftmp.5;
  unsigned int D.14369;
  unsigned int D.14373;
  struct _WapiHandle_file * file;

  file = handle_info;
  D.14340 = file->filename;
  D.14342 = file->fileaccess;
  D.14343 = (signed int) D.14342;
  if (D.14343 < 0) goto <D.14344>; else goto <D.14345>;
  <D.14344>:
  iftmp.0 = 82;
  goto <D.14346>;
  <D.14345>:
  iftmp.0 = 46;
  <D.14346>:
  D.14342 = file->fileaccess;
  D.14348 = D.14342 & 1073741824;
  if (D.14348 != 0) goto <D.14349>; else goto <D.14350>;
  <D.14349>:
  iftmp.1 = 87;
  goto <D.14351>;
  <D.14350>:
  iftmp.1 = 46;
  <D.14351>:
  D.14342 = file->fileaccess;
  D.14353 = D.14342 & 536870912;
  if (D.14353 != 0) goto <D.14354>; else goto <D.14355>;
  <D.14354>:
  iftmp.2 = 88;
  goto <D.14356>;
  <D.14355>:
  iftmp.2 = 46;
  <D.14356>:
  D.14358 = file->sharemode;
  D.14359 = D.14358 & 1;
  if (D.14359 != 0) goto <D.14360>; else goto <D.14361>;
  <D.14360>:
  iftmp.3 = 82;
  goto <D.14362>;
  <D.14361>:
  iftmp.3 = 46;
  <D.14362>:
  D.14358 = file->sharemode;
  D.14364 = D.14358 & 2;
  if (D.14364 != 0) goto <D.14365>; else goto <D.14366>;
  <D.14365>:
  iftmp.4 = 87;
  goto <D.14367>;
  <D.14366>:
  iftmp.4 = 46;
  <D.14367>:
  D.14358 = file->sharemode;
  D.14369 = D.14358 & 4;
  if (D.14369 != 0) goto <D.14370>; else goto <D.14371>;
  <D.14370>:
  iftmp.5 = 68;
  goto <D.14372>;
  <D.14371>:
  iftmp.5 = 46;
  <D.14372>:
  D.14373 = file->attrs;
  monoeg_g_print ("[%20s] acc: %c%c%c, shr: %c%c%c, attrs: %5u", D.14340, iftmp.0, iftmp.1, iftmp.2, iftmp.3, iftmp.4, iftmp.5, D.14373);
}


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

  console_handle = data;
  fd = console_handle->fd;
  D.14374 = console_handle->filename;
  monoeg_g_free (D.14374);
  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.14375;
  unsigned int D.14378;
  void * D.14381;
  int * D.14388;
  int D.14389;
  int D.14392;
  unsigned int fd.6;
  unsigned int _wapi_fd_reserve.7;
  int D.14401;
  struct _WapiFileShare * D.14404;
  unsigned int D.14409;
  unsigned int D.14412;
  unsigned int D.14415;
  unsigned int D.14416;
  <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.14375 = attrs & 256;
      if (D.14375 != 0) goto <D.14376>; else goto <D.14377>;
      <D.14376>:
      perms = 384;
      <D.14377>:
      D.14378 = attrs & 64;
      if (D.14378 != 0) goto <D.14379>; else goto <D.14380>;
      <D.14379>:
      SetLastError (6000);
      D.14381 = 4294967295B;
      return D.14381;
      <D.14380>:
      if (name == 0B) goto <D.14382>; else goto <D.14383>;
      <D.14382>:
      SetLastError (123);
      D.14381 = 4294967295B;
      return D.14381;
      <D.14383>:
      filename = mono_unicode_to_external (name);
      if (filename == 0B) goto <D.14384>; else goto <D.14385>;
      <D.14384>:
      SetLastError (123);
      D.14381 = 4294967295B;
      return D.14381;
      <D.14385>:
      fd = _wapi_open (filename, flags, perms);
      if (fd == -1) goto <D.14386>; else goto <D.14387>;
      <D.14386>:
      D.14388 = __errno_location ();
      D.14389 = *D.14388;
      if (D.14389 == 21) goto <D.14390>; else goto <D.14391>;
      <D.14390>:
      D.14392 = flags & -4;
      fd = _wapi_open (filename, D.14392, perms);
      <D.14391>:
      <D.14387>:
      if (fd == -1) goto <D.14393>; else goto <D.14394>;
      <D.14393>:
      _wapi_set_last_path_error_from_errno (0B, filename);
      monoeg_g_free (filename);
      D.14381 = 4294967295B;
      return D.14381;
      <D.14394>:
      fd.6 = (unsigned int) fd;
      _wapi_fd_reserve.7 = _wapi_fd_reserve;
      if (fd.6 >= _wapi_fd_reserve.7) goto <D.14397>; else goto <D.14398>;
      <D.14397>:
      SetLastError (4);
      close (fd);
      monoeg_g_free (filename);
      D.14381 = 4294967295B;
      return D.14381;
      <D.14398>:
      ret = fstat (fd, &statbuf);
      if (ret == -1) goto <D.14399>; else goto <D.14400>;
      <D.14399>:
      _wapi_set_last_error_from_errno ();
      monoeg_g_free (filename);
      close (fd);
      D.14381 = 4294967295B;
      return D.14381;
      <D.14400>:
      D.14401 = share_check (&statbuf, sharemode, fileaccess, &file_handle.share_info, fd);
      if (D.14401 == 0) goto <D.14402>; else goto <D.14403>;
      <D.14402>:
      SetLastError (32);
      monoeg_g_free (filename);
      close (fd);
      D.14381 = 4294967295B;
      return D.14381;
      <D.14403>:
      D.14404 = file_handle.share_info;
      if (D.14404 == 0B) goto <D.14405>; else goto <D.14406>;
      <D.14405>:
      SetLastError (4);
      close (fd);
      monoeg_g_free (filename);
      D.14381 = 4294967295B;
      return D.14381;
      <D.14406>:
      file_handle.filename = filename;
      if (security != 0B) goto <D.14407>; else goto <D.14408>;
      <D.14407>:
      <D.14408>:
      file_handle.fd = fd;
      file_handle.fileaccess = fileaccess;
      file_handle.sharemode = sharemode;
      file_handle.attrs = attrs;
      D.14409 = attrs & 134217728;
      if (D.14409 != 0) goto <D.14410>; else goto <D.14411>;
      <D.14410>:
      posix_fadvise (fd, 0, 0, 2);
      <D.14411>:
      D.14412 = attrs & 268435456;
      if (D.14412 != 0) goto <D.14413>; else goto <D.14414>;
      <D.14413>:
      posix_fadvise (fd, 0, 0, 1);
      <D.14414>:
      D.14415 = statbuf.st_mode;
      D.14416 = D.14415 & 61440;
      if (D.14416 == 4096) goto <D.14417>; else goto <D.14418>;
      <D.14417>:
      handle_type = 10;
      goto <D.14419>;
      <D.14418>:
      D.14415 = statbuf.st_mode;
      D.14416 = D.14415 & 61440;
      if (D.14416 == 8192) goto <D.14420>; else goto <D.14421>;
      <D.14420>:
      handle_type = 2;
      goto <D.14422>;
      <D.14421>:
      handle_type = 1;
      <D.14422>:
      <D.14419>:
      handle_type.8 = (<unnamed type>) handle_type;
      handle = _wapi_handle_new_fd (handle_type.8, fd, &file_handle);
      if (handle == 4294967295B) goto <D.14424>; else goto <D.14425>;
      <D.14424>:
      monoeg_g_log (0B, 16, "%s: error creating file handle", &__func__);
      monoeg_g_free (filename);
      close (fd);
      SetLastError (31);
      D.14381 = 4294967295B;
      return D.14381;
      <D.14425>:
      D.14381 = handle;
      return D.14381;
    }
  finally
    {
      file_handle = {CLOBBER};
      statbuf = {CLOBBER};
    }
}


io_ops_init ()
{
  const gchar * D.14428;

  D.14428 = monoeg_g_getenv ("MONO_STRICT_IO_EMULATION");
  if (D.14428 != 0B) goto <D.14429>; else goto <D.14430>;
  <D.14429>:
  lock_while_writing = 1;
  <D.14430>:
}


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

  flags = 0;
  switch (fileaccess) <default: <D.13778>, case 1073741824: <D.13776>, case 2147483648: <D.13774>, case 3221225472: <D.13777>>
  <D.13774>:
  flags = 0;
  goto <D.13775>;
  <D.13776>:
  flags = 1;
  goto <D.13775>;
  <D.13777>:
  flags = 2;
  goto <D.13775>;
  <D.13778>:
  goto <D.13775>;
  <D.13775>:
  switch (createmode) <default: <D.13785>, case 1: <D.13779>, case 2: <D.13781>, case 3: <D.13782>, case 4: <D.13783>, case 5: <D.13784>>
  <D.13779>:
  flags = flags | 192;
  goto <D.13780>;
  <D.13781>:
  flags = flags | 576;
  goto <D.13780>;
  <D.13782>:
  goto <D.13780>;
  <D.13783>:
  flags = flags | 64;
  goto <D.13780>;
  <D.13784>:
  flags = flags | 512;
  goto <D.13780>;
  <D.13785>:
  goto <D.13780>;
  <D.13780>:
  D.14431 = flags;
  return D.14431;
}


_wapi_set_last_path_error_from_errno (const gchar * dir, const gchar * path)
{
  int * D.14435;
  int D.14436;
  int D.14442;

  D.14435 = __errno_location ();
  D.14436 = *D.14435;
  if (D.14436 == 2) goto <D.14437>; else goto <D.14438>;
  <D.14437>:
  {
    gchar * dirname;

    if (dir == 0B) goto <D.14439>; else goto <D.14440>;
    <D.14439>:
    dirname = _wapi_dirname (path);
    goto <D.14441>;
    <D.14440>:
    dirname = monoeg_strdup (dir);
    <D.14441>:
    D.14442 = _wapi_access (dirname, 0);
    if (D.14442 == 0) goto <D.14443>; else goto <D.14444>;
    <D.14443>:
    SetLastError (2);
    goto <D.14445>;
    <D.14444>:
    SetLastError (3);
    <D.14445>:
    monoeg_g_free (dirname);
  }
  goto <D.14446>;
  <D.14438>:
  _wapi_set_last_error_from_errno ();
  <D.14446>:
}


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

  if (str != 0B) goto <D.14447>; else goto <D.14448>;
  <D.14447>:
  D.14449 = __strdup (str);
  return D.14449;
  <D.14448>:
  D.14449 = 0B;
  return D.14449;
}


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

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


_wapi_set_last_error_from_errno ()
{
  int * D.14453;
  int D.14454;
  int D.14455;
  unsigned int D.14456;

  D.14453 = __errno_location ();
  D.14454 = *D.14453;
  D.14455 = _wapi_get_win32_file_error (D.14454);
  D.14456 = (unsigned int) D.14455;
  SetLastError (D.14456);
}


share_check (struct stat * statbuf, guint32 sharemode, guint32 fileaccess, struct _WapiFileShare * * share_info, int fd)
{
  int D.14457;
  gboolean D.14460;
  struct _WapiFileShare * D.14461;
  int D.14462;

  D.14457 = share_allows_open (statbuf, sharemode, fileaccess, share_info);
  if (D.14457 == 1) goto <D.14458>; else goto <D.14459>;
  <D.14458>:
  D.14460 = 1;
  return D.14460;
  <D.14459>:
  D.14461 = *share_info;
  _wapi_handle_check_share (D.14461, fd);
  D.14462 = share_allows_open (statbuf, sharemode, fileaccess, share_info);
  if (D.14462 == 1) goto <D.14463>; else goto <D.14464>;
  <D.14463>:
  D.14460 = 1;
  return D.14460;
  <D.14464>:
  _wapi_handle_collect ();
  D.14460 = share_allows_open (statbuf, sharemode, fileaccess, share_info);
  return D.14460;
}


share_allows_open (struct stat * statbuf, guint32 sharemode, guint32 fileaccess, struct _WapiFileShare * * share_info)
{
  long long unsigned int D.14466;
  long long unsigned int D.14467;
  unsigned int file_existing_share.9;
  struct _WapiFileShare * D.14473;
  gboolean D.14474;
  unsigned int file_existing_access.10;
  signed int file_existing_access.11;
  unsigned int D.14486;
  unsigned int D.14487;
  unsigned int D.14489;
  gboolean file_already_shared;
  guint32 file_existing_share;
  guint32 file_existing_access;

  try
    {
      D.14466 = statbuf->st_dev;
      D.14467 = statbuf->st_ino;
      file_already_shared = _wapi_handle_get_or_set_share (D.14466, D.14467, sharemode, fileaccess, &file_existing_share, &file_existing_access, share_info);
      if (file_already_shared != 0) goto <D.14468>; else goto <D.14469>;
      <D.14468>:
      file_existing_share.9 = file_existing_share;
      if (file_existing_share.9 == 0) goto <D.14471>; else goto <D.14472>;
      <D.14471>:
      D.14473 = *share_info;
      _wapi_handle_share_release (D.14473);
      D.14474 = 0;
      return D.14474;
      <D.14472>:
      file_existing_share.9 = file_existing_share;
      if (file_existing_share.9 == 1) goto <D.14478>; else goto <D.14475>;
      <D.14478>:
      if (fileaccess != 2147483648) goto <D.14476>; else goto <D.14475>;
      <D.14475>:
      file_existing_share.9 = file_existing_share;
      if (file_existing_share.9 == 2) goto <D.14479>; else goto <D.14477>;
      <D.14479>:
      if (fileaccess != 1073741824) goto <D.14476>; else goto <D.14477>;
      <D.14476>:
      D.14473 = *share_info;
      _wapi_handle_share_release (D.14473);
      D.14474 = 0;
      return D.14474;
      <D.14477>:
      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.14485>; else goto <D.14480>;
      <D.14485>:
      D.14486 = sharemode & 1;
      if (D.14486 == 0) goto <D.14481>; else goto <D.14480>;
      <D.14480>:
      file_existing_access.10 = file_existing_access;
      D.14487 = file_existing_access.10 & 1073741824;
      if (D.14487 != 0) goto <D.14488>; else goto <D.14482>;
      <D.14488>:
      D.14489 = sharemode & 2;
      if (D.14489 == 0) goto <D.14481>; else goto <D.14482>;
      <D.14481>:
      D.14473 = *share_info;
      _wapi_handle_share_release (D.14473);
      D.14474 = 0;
      return D.14474;
      <D.14482>:
      goto <D.14490>;
      <D.14469>:
      <D.14490>:
      D.14474 = 1;
      return D.14474;
    }
  finally
    {
      file_existing_share = {CLOBBER};
      file_existing_access = {CLOBBER};
    }
}


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

  ret = 0;
  if (name == 0B) goto <D.14493>; else goto <D.14494>;
  <D.14493>:
  SetLastError (123);
  D.14495 = 0;
  return D.14495;
  <D.14494>:
  filename = mono_unicode_to_external (name);
  if (filename == 0B) goto <D.14496>; else goto <D.14497>;
  <D.14496>:
  SetLastError (123);
  D.14495 = 0;
  return D.14495;
  <D.14497>:
  attrs = GetFileAttributes (name);
  if (attrs == 4294967295) goto <D.14498>; else goto <D.14499>;
  <D.14498>:
  monoeg_g_free (filename);
  D.14495 = 0;
  return D.14495;
  <D.14499>:
  retval = _wapi_unlink (filename);
  if (retval == -1) goto <D.14500>; else goto <D.14501>;
  <D.14500>:
  _wapi_set_last_path_error_from_errno (0B, filename);
  goto <D.14502>;
  <D.14501>:
  ret = 1;
  <D.14502>:
  monoeg_g_free (filename);
  D.14495 = ret;
  return D.14495;
}


MoveFile (const gunichar2 * name, const gunichar2 * dest_name)
{
  gboolean D.14506;
  int D.14513;
  int * D.14518;
  int D.14519;
  int D.14521;
  int D.14522;
  long long unsigned int D.14527;
  long long unsigned int D.14528;
  long long unsigned int D.14530;
  long long unsigned int D.14531;
  int D.14532;
  struct _WapiFileShare * shareinfo.12;
  _Bool D.14540;
  _Bool D.14541;
  _Bool D.14542;
  unsigned int D.14545;
  unsigned int D.14546;
  int D.14549;
  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.14504>; else goto <D.14505>;
      <D.14504>:
      SetLastError (123);
      D.14506 = 0;
      return D.14506;
      <D.14505>:
      utf8_name = mono_unicode_to_external (name);
      if (utf8_name == 0B) goto <D.14507>; else goto <D.14508>;
      <D.14507>:
      SetLastError (123);
      D.14506 = 0;
      return D.14506;
      <D.14508>:
      if (dest_name == 0B) goto <D.14509>; else goto <D.14510>;
      <D.14509>:
      monoeg_g_free (utf8_name);
      SetLastError (123);
      D.14506 = 0;
      return D.14506;
      <D.14510>:
      utf8_dest_name = mono_unicode_to_external (dest_name);
      if (utf8_dest_name == 0B) goto <D.14511>; else goto <D.14512>;
      <D.14511>:
      monoeg_g_free (utf8_name);
      SetLastError (123);
      D.14506 = 0;
      return D.14506;
      <D.14512>:
      D.14513 = _wapi_stat (utf8_name, &stat_src);
      if (D.14513 < 0) goto <D.14514>; else goto <D.14515>;
      <D.14514>:
      D.14518 = __errno_location ();
      D.14519 = *D.14518;
      if (D.14519 != 2) goto <D.14516>; else goto <D.14520>;
      <D.14520>:
      D.14521 = _wapi_lstat (utf8_name, &stat_src);
      if (D.14521 < 0) goto <D.14516>; else goto <D.14517>;
      <D.14516>:
      _wapi_set_last_path_error_from_errno (0B, utf8_name);
      monoeg_g_free (utf8_name);
      monoeg_g_free (utf8_dest_name);
      D.14506 = 0;
      return D.14506;
      <D.14517>:
      <D.14515>:
      D.14522 = _wapi_stat (utf8_dest_name, &stat_dest);
      if (D.14522 == 0) goto <D.14523>; else goto <D.14524>;
      <D.14523>:
      D.14527 = stat_dest.st_dev;
      D.14528 = stat_src.st_dev;
      if (D.14527 != D.14528) goto <D.14525>; else goto <D.14529>;
      <D.14529>:
      D.14530 = stat_dest.st_ino;
      D.14531 = stat_src.st_ino;
      if (D.14530 != D.14531) goto <D.14525>; else goto <D.14526>;
      <D.14525>:
      monoeg_g_free (utf8_name);
      monoeg_g_free (utf8_dest_name);
      SetLastError (183);
      D.14506 = 0;
      return D.14506;
      <D.14526>:
      <D.14524>:
      D.14532 = share_allows_delete (&stat_src, &shareinfo);
      if (D.14532 == 0) goto <D.14533>; else goto <D.14534>;
      <D.14533>:
      SetLastError (32);
      D.14506 = 0;
      return D.14506;
      <D.14534>:
      shareinfo.12 = shareinfo;
      if (shareinfo.12 != 0B) goto <D.14536>; else goto <D.14537>;
      <D.14536>:
      shareinfo.12 = shareinfo;
      _wapi_handle_share_release (shareinfo.12);
      <D.14537>:
      result = _wapi_rename (utf8_name, utf8_dest_name);
      D.14518 = __errno_location ();
      errno_copy = *D.14518;
      if (result == -1) goto <D.14538>; else goto <D.14539>;
      <D.14538>:
      switch (errno_copy) <default: <D.13850>, case 17: <D.13847>, case 18: <D.13849>>
      <D.13847>:
      SetLastError (183);
      goto <D.13848>;
      <D.13849>:
      goto <D.13848>;
      <D.13850>:
      _wapi_set_last_path_error_from_errno (0B, utf8_name);
      <D.13848>:
      <D.14539>:
      monoeg_g_free (utf8_name);
      monoeg_g_free (utf8_dest_name);
      D.14540 = result != 0;
      D.14541 = errno_copy == 18;
      D.14542 = D.14540 & D.14541;
      if (D.14542 != 0) goto <D.14543>; else goto <D.14544>;
      <D.14543>:
      D.14545 = stat_src.st_mode;
      D.14546 = D.14545 & 61440;
      if (D.14546 == 16384) goto <D.14547>; else goto <D.14548>;
      <D.14547>:
      SetLastError (17);
      D.14506 = 0;
      return D.14506;
      <D.14548>:
      D.14549 = CopyFile (name, dest_name, 1);
      if (D.14549 == 0) goto <D.14550>; else goto <D.14551>;
      <D.14550>:
      D.14506 = 0;
      return D.14506;
      <D.14551>:
      D.14506 = DeleteFile (name);
      return D.14506;
      <D.14544>:
      if (result == 0) goto <D.14552>; else goto <D.14553>;
      <D.14552>:
      ret = 1;
      <D.14553>:
      D.14506 = ret;
      return D.14506;
    }
  finally
    {
      stat_src = {CLOBBER};
      stat_dest = {CLOBBER};
      shareinfo = {CLOBBER};
    }
}


share_allows_delete (struct stat * statbuf, struct _WapiFileShare * * share_info)
{
  long long unsigned int D.14557;
  long long unsigned int D.14558;
  unsigned int file_existing_share.13;
  struct _WapiFileShare * D.14564;
  gboolean D.14565;
  unsigned int D.14566;
  gboolean file_already_shared;
  guint32 file_existing_share;
  guint32 file_existing_access;

  try
    {
      D.14557 = statbuf->st_dev;
      D.14558 = statbuf->st_ino;
      file_already_shared = _wapi_handle_get_or_set_share (D.14557, D.14558, 4, 2147483648, &file_existing_share, &file_existing_access, share_info);
      if (file_already_shared != 0) goto <D.14559>; else goto <D.14560>;
      <D.14559>:
      file_existing_share.13 = file_existing_share;
      if (file_existing_share.13 == 0) goto <D.14562>; else goto <D.14563>;
      <D.14562>:
      D.14564 = *share_info;
      _wapi_handle_share_release (D.14564);
      D.14565 = 0;
      return D.14565;
      <D.14563>:
      file_existing_share.13 = file_existing_share;
      D.14566 = file_existing_share.13 & 4;
      if (D.14566 == 0) goto <D.14567>; else goto <D.14568>;
      <D.14567>:
      D.14564 = *share_info;
      _wapi_handle_share_release (D.14564);
      D.14565 = 0;
      return D.14565;
      <D.14568>:
      goto <D.14569>;
      <D.14560>:
      <D.14569>:
      D.14565 = 1;
      return D.14565;
    }
  finally
    {
      file_existing_share = {CLOBBER};
      file_existing_access = {CLOBBER};
    }
}


CopyFile (const gunichar2 * name, const gunichar2 * dest_name, gboolean fail_if_exists)
{
  gboolean D.14574;
  int D.14583;
  int D.14586;
  long long unsigned int D.14589;
  long long unsigned int D.14590;
  long long unsigned int D.14593;
  long long unsigned int D.14594;
  unsigned int D.14599;
  int D.14606;
  long int D.14609;
  long int D.14610;
  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.14572>; else goto <D.14573>;
      <D.14572>:
      SetLastError (123);
      D.14574 = 0;
      return D.14574;
      <D.14573>:
      utf8_src = mono_unicode_to_external (name);
      if (utf8_src == 0B) goto <D.14575>; else goto <D.14576>;
      <D.14575>:
      SetLastError (87);
      D.14574 = 0;
      return D.14574;
      <D.14576>:
      if (dest_name == 0B) goto <D.14577>; else goto <D.14578>;
      <D.14577>:
      monoeg_g_free (utf8_src);
      SetLastError (123);
      D.14574 = 0;
      return D.14574;
      <D.14578>:
      utf8_dest = mono_unicode_to_external (dest_name);
      if (utf8_dest == 0B) goto <D.14579>; else goto <D.14580>;
      <D.14579>:
      SetLastError (87);
      monoeg_g_free (utf8_src);
      D.14574 = 0;
      return D.14574;
      <D.14580>:
      src_fd = _wapi_open (utf8_src, 0, 0);
      if (src_fd < 0) goto <D.14581>; else goto <D.14582>;
      <D.14581>:
      _wapi_set_last_path_error_from_errno (0B, utf8_src);
      monoeg_g_free (utf8_src);
      monoeg_g_free (utf8_dest);
      D.14574 = 0;
      return D.14574;
      <D.14582>:
      D.14583 = fstat (src_fd, &st);
      if (D.14583 < 0) goto <D.14584>; else goto <D.14585>;
      <D.14584>:
      _wapi_set_last_error_from_errno ();
      monoeg_g_free (utf8_src);
      monoeg_g_free (utf8_dest);
      close (src_fd);
      D.14574 = 0;
      return D.14574;
      <D.14585>:
      D.14586 = _wapi_stat (utf8_dest, &dest_st);
      if (D.14586 == 0) goto <D.14587>; else goto <D.14588>;
      <D.14587>:
      D.14589 = st.st_dev;
      D.14590 = dest_st.st_dev;
      if (D.14589 == D.14590) goto <D.14591>; else goto <D.14592>;
      <D.14591>:
      D.14593 = st.st_ino;
      D.14594 = dest_st.st_ino;
      if (D.14593 == D.14594) goto <D.14595>; else goto <D.14596>;
      <D.14595>:
      monoeg_g_free (utf8_src);
      monoeg_g_free (utf8_dest);
      close (src_fd);
      SetLastError (32);
      D.14574 = 0;
      return D.14574;
      <D.14596>:
      <D.14592>:
      <D.14588>:
      if (fail_if_exists != 0) goto <D.14597>; else goto <D.14598>;
      <D.14597>:
      D.14599 = st.st_mode;
      dest_fd = _wapi_open (utf8_dest, 193, D.14599);
      goto <D.14600>;
      <D.14598>:
      D.14599 = st.st_mode;
      dest_fd = _wapi_open (utf8_dest, 513, D.14599);
      if (dest_fd < 0) goto <D.14601>; else goto <D.14602>;
      <D.14601>:
      D.14599 = st.st_mode;
      dest_fd = _wapi_open (utf8_dest, 577, D.14599);
      goto <D.14603>;
      <D.14602>:
      SetLastError (183);
      <D.14603>:
      <D.14600>:
      if (dest_fd < 0) goto <D.14604>; else goto <D.14605>;
      <D.14604>:
      _wapi_set_last_error_from_errno ();
      monoeg_g_free (utf8_src);
      monoeg_g_free (utf8_dest);
      close (src_fd);
      D.14574 = 0;
      return D.14574;
      <D.14605>:
      D.14606 = write_file (src_fd, dest_fd, &st, 1);
      if (D.14606 == 0) goto <D.14607>; else goto <D.14608>;
      <D.14607>:
      ret = 0;
      <D.14608>:
      close (src_fd);
      close (dest_fd);
      D.14609 = st.st_mtim.tv_sec;
      dest_time.modtime = D.14609;
      D.14610 = st.st_atim.tv_sec;
      dest_time.actime = D.14610;
      ret_utime = utime (utf8_dest, &dest_time);
      if (ret_utime == -1) goto <D.14611>; else goto <D.14612>;
      <D.14611>:
      <D.14612>:
      monoeg_g_free (utf8_src);
      monoeg_g_free (utf8_dest);
      D.14574 = ret;
      return D.14574;
    }
  finally
    {
      st = {CLOBBER};
      dest_st = {CLOBBER};
      dest_time = {CLOBBER};
    }
}


write_file (int src_fd, int dest_fd, struct stat * st_src, gboolean report_errors)
{
  int iftmp.14;
  unsigned int buf_size.15;
  int * D.14622;
  int D.14623;
  int D.14626;
  gboolean D.14631;
  unsigned int remain.16;
  int D.14638;
  sizetype n.17;
  int remain;
  int n;
  char * buf;
  char * wbuf;
  int buf_size;

  buf_size = st_src->st_blksize;
  if (buf_size > 8191) goto <D.14616>; else goto <D.14617>;
  <D.14616>:
  iftmp.14 = MIN_EXPR <buf_size, 65536>;
  goto <D.14618>;
  <D.14617>:
  iftmp.14 = 8192;
  <D.14618>:
  buf_size = iftmp.14;
  buf_size.15 = (unsigned int) buf_size;
  buf = malloc (buf_size.15);
  <D.13867>:
  buf_size.15 = (unsigned int) buf_size;
  remain = read (src_fd, buf, buf_size.15);
  if (remain < 0) goto <D.14620>; else goto <D.14621>;
  <D.14620>:
  D.14622 = __errno_location ();
  D.14623 = *D.14622;
  if (D.14623 == 4) goto <D.14624>; else goto <D.14625>;
  <D.14624>:
  D.14626 = _wapi_thread_cur_apc_pending ();
  if (D.14626 == 0) goto <D.14627>; else goto <D.14628>;
  <D.14627>:
  // predicted unlikely by continue predictor.
  goto <D.13862>;
  <D.14628>:
  <D.14625>:
  if (report_errors != 0) goto <D.14629>; else goto <D.14630>;
  <D.14629>:
  _wapi_set_last_error_from_errno ();
  <D.14630>:
  free (buf);
  D.14631 = 0;
  return D.14631;
  <D.14621>:
  if (remain == 0) goto <D.13863>; else goto <D.14632>;
  <D.14632>:
  wbuf = buf;
  goto <D.13864>;
  <D.13865>:
  remain.16 = (unsigned int) remain;
  n = write (dest_fd, wbuf, remain.16);
  if (n < 0) goto <D.14634>; else goto <D.14635>;
  <D.14634>:
  D.14622 = __errno_location ();
  D.14623 = *D.14622;
  if (D.14623 == 4) goto <D.14636>; else goto <D.14637>;
  <D.14636>:
  D.14638 = _wapi_thread_cur_apc_pending ();
  if (D.14638 == 0) goto <D.14639>; else goto <D.14640>;
  <D.14639>:
  // predicted unlikely by continue predictor.
  goto <D.13864>;
  <D.14640>:
  <D.14637>:
  if (report_errors != 0) goto <D.14641>; else goto <D.14642>;
  <D.14641>:
  _wapi_set_last_error_from_errno ();
  <D.14642>:
  free (buf);
  D.14631 = 0;
  return D.14631;
  <D.14635>:
  remain = remain - n;
  n.17 = (sizetype) n;
  wbuf = wbuf + n.17;
  <D.13864>:
  if (remain > 0) goto <D.13865>; else goto <D.13866>;
  <D.13866>:
  <D.13862>:
  goto <D.13867>;
  <D.13863>:
  free (buf);
  D.14631 = 1;
  return D.14631;
}


read (int __fd, void * __buf, size_t __nbytes)
{
  unsigned int D.14645;
  int D.14648;
  ssize_t D.14651;
  unsigned int D.14652;
  unsigned int D.14653;
  unsigned int D.14656;

  D.14645 = __builtin_object_size (__buf, 0);
  if (D.14645 != 4294967295) goto <D.14646>; else goto <D.14647>;
  <D.14646>:
  D.14648 = __builtin_constant_p (__nbytes);
  if (D.14648 == 0) goto <D.14649>; else goto <D.14650>;
  <D.14649>:
  D.14652 = __builtin_object_size (__buf, 0);
  D.14651 = __read_chk (__fd, __buf, __nbytes, D.14652);
  return D.14651;
  <D.14650>:
  D.14653 = __builtin_object_size (__buf, 0);
  if (D.14653 < __nbytes) goto <D.14654>; else goto <D.14655>;
  <D.14654>:
  D.14656 = __builtin_object_size (__buf, 0);
  D.14651 = __read_chk_warn (__fd, __buf, __nbytes, D.14656);
  return D.14651;
  <D.14655>:
  <D.14647>:
  D.14651 = __read_alias (__fd, __buf, __nbytes);
  return D.14651;
}


ReplaceFile (const gunichar2 * replacedFileName, const gunichar2 * replacementFileName, const gunichar2 * backupFileName, guint32 replaceFlags, void * exclude, void * reserved)
{
  gboolean D.14660;
  int * D.14667;
  int D.14673;
  unsigned int D.14676;
  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.14658>; else goto <D.14659>;
      <D.14658>:
      D.14660 = 0;
      return D.14660;
      <D.14659>:
      utf8_replacementFileName = convert_arg_to_utf8 (replacementFileName, "replacementFileName");
      if (utf8_replacementFileName == 0B) goto replace_cleanup; else goto <D.14661>;
      <D.14661>:
      if (backupFileName != 0B) goto <D.14662>; else goto <D.14663>;
      <D.14662>:
      utf8_backupFileName = convert_arg_to_utf8 (backupFileName, "backupFileName");
      if (utf8_backupFileName == 0B) goto replace_cleanup; else goto <D.14664>;
      <D.14664>:
      <D.14663>:
      if (utf8_backupFileName != 0B) goto <D.14665>; else goto <D.14666>;
      <D.14665>:
      backup_fd = _wapi_open (utf8_backupFileName, 0, 0);
      result = _wapi_rename (utf8_replacedFileName, utf8_backupFileName);
      D.14667 = __errno_location ();
      errno_copy = *D.14667;
      if (result == -1) goto replace_cleanup; else goto <D.14668>;
      <D.14668>:
      <D.14666>:
      result = _wapi_rename (utf8_replacementFileName, utf8_replacedFileName);
      D.14667 = __errno_location ();
      errno_copy = *D.14667;
      if (result == -1) goto <D.14669>; else goto <D.14670>;
      <D.14669>:
      _wapi_set_last_path_error_from_errno (0B, utf8_replacementFileName);
      _wapi_rename (utf8_backupFileName, utf8_replacedFileName);
      if (backup_fd != -1) goto <D.14671>; else goto <D.14672>;
      <D.14671>:
      D.14673 = fstat (backup_fd, &stBackup);
      if (D.14673 == 0) goto <D.14674>; else goto <D.14675>;
      <D.14674>:
      D.14676 = stBackup.st_mode;
      replaced_fd = _wapi_open (utf8_backupFileName, 577, D.14676);
      if (replaced_fd == -1) goto replace_cleanup; else goto <D.14677>;
      <D.14677>:
      write_file (backup_fd, replaced_fd, &stBackup, 0);
      <D.14675>:
      <D.14672>:
      goto replace_cleanup;
      <D.14670>:
      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.14678>; else goto <D.14679>;
      <D.14678>:
      close (backup_fd);
      <D.14679>:
      if (replaced_fd != -1) goto <D.14680>; else goto <D.14681>;
      <D.14680>:
      close (replaced_fd);
      <D.14681>:
      D.14660 = ret;
      return D.14660;
    }
  finally
    {
      stBackup = {CLOBBER};
    }
}


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

  if (arg == 0B) goto <D.14684>; else goto <D.14685>;
  <D.14684>:
  SetLastError (123);
  D.14686 = 0B;
  return D.14686;
  <D.14685>:
  utf8_ret = mono_unicode_to_external (arg);
  if (utf8_ret == 0B) goto <D.14687>; else goto <D.14688>;
  <D.14687>:
  SetLastError (87);
  D.14686 = 0B;
  return D.14686;
  <D.14688>:
  D.14686 = utf8_ret;
  return D.14686;
}


GetStdHandle (WapiStdHandle stdhandle)
{
  void * D.14690;
  long int D.14691;
  _Bool D.14694;
  long int D.14695;
  long int D.14696;
  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.13919>, case -12: <D.13918>, case -11: <D.13917>, case -10: <D.13915>>
      <D.13915>:
      fd = 0;
      name = "<stdin>";
      goto <D.13916>;
      <D.13917>:
      fd = 1;
      name = "<stdout>";
      goto <D.13916>;
      <D.13918>:
      fd = 2;
      name = "<stderr>";
      goto <D.13916>;
      <D.13919>:
      SetLastError (87);
      D.14690 = 4294967295B;
      return D.14690;
      <D.13916>:
      handle = (void *) fd;
      {
        struct __pthread_unwind_buf_t __cancel_buf;
        void (*<Tc1>) (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.14691 = __builtin_expect (__not_first_call, 0);
            if (D.14691 != 0) goto <D.14692>; else goto <D.14693>;
            <D.14692>:
            __cancel_routine (__cancel_arg);
            __pthread_unwind_next (&__cancel_buf);
            <D.14693>:
            __pthread_register_cancel (&__cancel_buf);
            thr_ret = pthread_mutex_lock (&stdhandle_mutex);
            D.14694 = thr_ret != 0;
            D.14695 = (long int) D.14694;
            D.14696 = __builtin_expect (D.14695, 0);
            if (D.14696 != 0) goto <D.14697>; else goto <D.14698>;
            <D.14697>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "io.c", 2187, "thr_ret == 0");
            <D.14698>:
            ok = _wapi_lookup_handle (handle, 2, &file_handle);
            if (ok == 0) goto <D.14699>; else goto <D.14700>;
            <D.14699>:
            handle = _wapi_stdhandle_create (fd, name);
            if (handle == 4294967295B) goto <D.14701>; else goto <D.14702>;
            <D.14701>:
            SetLastError (18);
            goto done;
            <D.14702>:
            goto <D.14703>;
            <D.14700>:
            _wapi_handle_ref (handle);
            <D.14703>:
            done:
            thr_ret = pthread_mutex_unlock (&stdhandle_mutex);
            D.14694 = thr_ret != 0;
            D.14695 = (long int) D.14694;
            D.14696 = __builtin_expect (D.14695, 0);
            if (D.14696 != 0) goto <D.14704>; else goto <D.14705>;
            <D.14704>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "io.c", 2206, "thr_ret == 0");
            <D.14705>:
            __pthread_unregister_cancel (&__cancel_buf);
            if (0 != 0) goto <D.14706>; else goto <D.14707>;
            <D.14706>:
            __cancel_routine (__cancel_arg);
            <D.14707>:
          }
        finally
          {
            __cancel_buf = {CLOBBER};
          }
      }
      D.14690 = handle;
      return D.14690;
    }
  finally
    {
      file_handle = {CLOBBER};
    }
}


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

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


ReadFile (void * handle, void * buffer, guint32 numbytes, guint32 * bytesread, struct WapiOverlapped * overlapped)
{
  gboolean (*<T2501>) (void *, void *, guint32, guint32 *, struct WapiOverlapped *) D.14716;
  gboolean D.14719;
  WapiHandleType type;

  type = _wapi_handle_type (handle);
  D.14716 = io_ops[type].readfile;
  if (D.14716 == 0B) goto <D.14717>; else goto <D.14718>;
  <D.14717>:
  SetLastError (6);
  D.14719 = 0;
  return D.14719;
  <D.14718>:
  D.14716 = io_ops[type].readfile;
  D.14719 = D.14716 (handle, buffer, numbytes, bytesread, overlapped);
  return D.14719;
}


pipe_write (void * handle, const void * buffer, guint32 numbytes, guint32 * byteswritten, struct WapiOverlapped * overlapped)
{
  gboolean D.14723;
  struct _WapiHandle_file * pipe_handle.18;
  unsigned int D.14727;
  unsigned int D.14728;
  int * D.14732;
  int D.14733;
  int D.14735;
  unsigned int ret.19;
  struct _WapiHandle_file * pipe_handle;
  gboolean ok;
  int ret;
  int fd;
  static const char __func__[11] = "pipe_write";

  try
    {
      ok = _wapi_lookup_handle (handle, 10, &pipe_handle);
      if (ok == 0) goto <D.14721>; else goto <D.14722>;
      <D.14721>:
      monoeg_g_log (0B, 16, "%s: error looking up pipe handle %p", &__func__, handle);
      SetLastError (6);
      D.14723 = 0;
      return D.14723;
      <D.14722>:
      pipe_handle.18 = pipe_handle;
      fd = pipe_handle.18->fd;
      if (byteswritten != 0B) goto <D.14725>; else goto <D.14726>;
      <D.14725>:
      *byteswritten = 0;
      <D.14726>:
      pipe_handle.18 = pipe_handle;
      D.14727 = BIT_FIELD_REF <*pipe_handle.18, 32, 128>;
      D.14728 = D.14727 & 1342177280;
      if (D.14728 == 0) goto <D.14729>; else goto <D.14730>;
      <D.14729>:
      SetLastError (5);
      D.14723 = 0;
      return D.14723;
      <D.14730>:
      <D.13767>:
      ret = write (fd, buffer, numbytes);
      if (ret == -1) goto <D.14731>; else goto <D.13768>;
      <D.14731>:
      D.14732 = __errno_location ();
      D.14733 = *D.14732;
      if (D.14733 == 4) goto <D.14734>; else goto <D.13768>;
      <D.14734>:
      D.14735 = _wapi_thread_cur_apc_pending ();
      if (D.14735 == 0) goto <D.13767>; else goto <D.13768>;
      <D.13768>:
      if (ret == -1) goto <D.14736>; else goto <D.14737>;
      <D.14736>:
      D.14732 = __errno_location ();
      D.14733 = *D.14732;
      if (D.14733 == 4) goto <D.14738>; else goto <D.14739>;
      <D.14738>:
      ret = 0;
      goto <D.14740>;
      <D.14739>:
      _wapi_set_last_error_from_errno ();
      D.14723 = 0;
      return D.14723;
      <D.14740>:
      <D.14737>:
      if (byteswritten != 0B) goto <D.14741>; else goto <D.14742>;
      <D.14741>:
      ret.19 = (unsigned int) ret;
      *byteswritten = ret.19;
      <D.14742>:
      D.14723 = 1;
      return D.14723;
    }
  finally
    {
      pipe_handle = {CLOBBER};
    }
}


pipe_read (void * handle, void * buffer, guint32 numbytes, guint32 * bytesread, struct WapiOverlapped * overlapped)
{
  gboolean D.14748;
  struct _WapiHandle_file * pipe_handle.20;
  unsigned int D.14752;
  signed int D.14753;
  unsigned int D.14756;
  int * D.14760;
  int D.14761;
  int D.14763;
  unsigned int ret.21;
  struct _WapiHandle_file * pipe_handle;
  gboolean ok;
  int ret;
  int fd;
  static const char __func__[10] = "pipe_read";

  try
    {
      ok = _wapi_lookup_handle (handle, 10, &pipe_handle);
      if (ok == 0) goto <D.14746>; else goto <D.14747>;
      <D.14746>:
      monoeg_g_log (0B, 16, "%s: error looking up pipe handle %p", &__func__, handle);
      SetLastError (6);
      D.14748 = 0;
      return D.14748;
      <D.14747>:
      pipe_handle.20 = pipe_handle;
      fd = pipe_handle.20->fd;
      if (bytesread != 0B) goto <D.14750>; else goto <D.14751>;
      <D.14750>:
      *bytesread = 0;
      <D.14751>:
      pipe_handle.20 = pipe_handle;
      D.14752 = pipe_handle.20->fileaccess;
      D.14753 = (signed int) D.14752;
      if (D.14753 >= 0) goto <D.14754>; else goto <D.14755>;
      <D.14754>:
      pipe_handle.20 = pipe_handle;
      D.14752 = pipe_handle.20->fileaccess;
      D.14756 = D.14752 & 268435456;
      if (D.14756 == 0) goto <D.14757>; else goto <D.14758>;
      <D.14757>:
      SetLastError (5);
      D.14748 = 0;
      return D.14748;
      <D.14758>:
      <D.14755>:
      <D.13753>:
      ret = read (fd, buffer, numbytes);
      if (ret == -1) goto <D.14759>; else goto <D.13754>;
      <D.14759>:
      D.14760 = __errno_location ();
      D.14761 = *D.14760;
      if (D.14761 == 4) goto <D.14762>; else goto <D.13754>;
      <D.14762>:
      D.14763 = _wapi_thread_cur_apc_pending ();
      if (D.14763 == 0) goto <D.13753>; else goto <D.13754>;
      <D.13754>:
      if (ret == -1) goto <D.14764>; else goto <D.14765>;
      <D.14764>:
      D.14760 = __errno_location ();
      D.14761 = *D.14760;
      if (D.14761 == 4) goto <D.14766>; else goto <D.14767>;
      <D.14766>:
      ret = 0;
      goto <D.14768>;
      <D.14767>:
      _wapi_set_last_error_from_errno ();
      D.14748 = 0;
      return D.14748;
      <D.14768>:
      <D.14765>:
      if (bytesread != 0B) goto <D.14769>; else goto <D.14770>;
      <D.14769>:
      ret.21 = (unsigned int) ret;
      *bytesread = ret.21;
      <D.14770>:
      D.14748 = 1;
      return D.14748;
    }
  finally
    {
      pipe_handle = {CLOBBER};
    }
}


pipe_getfiletype ()
{
  WapiFileType D.14774;

  D.14774 = 3;
  return D.14774;
}


console_write (void * handle, const void * buffer, guint32 numbytes, guint32 * byteswritten, struct WapiOverlapped * overlapped)
{
  gboolean D.14778;
  struct _WapiHandle_file * console_handle.22;
  unsigned int D.14782;
  unsigned int D.14783;
  int * D.14787;
  int D.14788;
  int D.14790;
  unsigned int ret.23;
  struct _WapiHandle_file * console_handle;
  gboolean ok;
  int ret;
  int fd;
  static const char __func__[14] = "console_write";

  try
    {
      ok = _wapi_lookup_handle (handle, 2, &console_handle);
      if (ok == 0) goto <D.14776>; else goto <D.14777>;
      <D.14776>:
      monoeg_g_log (0B, 16, "%s: error looking up console handle %p", &__func__, handle);
      SetLastError (6);
      D.14778 = 0;
      return D.14778;
      <D.14777>:
      console_handle.22 = console_handle;
      fd = console_handle.22->fd;
      if (byteswritten != 0B) goto <D.14780>; else goto <D.14781>;
      <D.14780>:
      *byteswritten = 0;
      <D.14781>:
      console_handle.22 = console_handle;
      D.14782 = BIT_FIELD_REF <*console_handle.22, 32, 128>;
      D.14783 = D.14782 & 1342177280;
      if (D.14783 == 0) goto <D.14784>; else goto <D.14785>;
      <D.14784>:
      SetLastError (5);
      D.14778 = 0;
      return D.14778;
      <D.14785>:
      <D.13730>:
      ret = write (fd, buffer, numbytes);
      if (ret == -1) goto <D.14786>; else goto <D.13731>;
      <D.14786>:
      D.14787 = __errno_location ();
      D.14788 = *D.14787;
      if (D.14788 == 4) goto <D.14789>; else goto <D.13731>;
      <D.14789>:
      D.14790 = _wapi_thread_cur_apc_pending ();
      if (D.14790 == 0) goto <D.13730>; else goto <D.13731>;
      <D.13731>:
      if (ret == -1) goto <D.14791>; else goto <D.14792>;
      <D.14791>:
      D.14787 = __errno_location ();
      D.14788 = *D.14787;
      if (D.14788 == 4) goto <D.14793>; else goto <D.14794>;
      <D.14793>:
      ret = 0;
      goto <D.14795>;
      <D.14794>:
      _wapi_set_last_error_from_errno ();
      D.14778 = 0;
      return D.14778;
      <D.14795>:
      <D.14792>:
      if (byteswritten != 0B) goto <D.14796>; else goto <D.14797>;
      <D.14796>:
      ret.23 = (unsigned int) ret;
      *byteswritten = ret.23;
      <D.14797>:
      D.14778 = 1;
      return D.14778;
    }
  finally
    {
      console_handle = {CLOBBER};
    }
}


console_read (void * handle, void * buffer, guint32 numbytes, guint32 * bytesread, struct WapiOverlapped * overlapped)
{
  gboolean D.14803;
  struct _WapiHandle_file * console_handle.24;
  unsigned int D.14807;
  signed int D.14808;
  unsigned int D.14811;
  int * D.14815;
  int D.14816;
  int D.14818;
  unsigned int ret.25;
  struct _WapiHandle_file * console_handle;
  gboolean ok;
  int ret;
  int fd;
  static const char __func__[13] = "console_read";

  try
    {
      ok = _wapi_lookup_handle (handle, 2, &console_handle);
      if (ok == 0) goto <D.14801>; else goto <D.14802>;
      <D.14801>:
      monoeg_g_log (0B, 16, "%s: error looking up console handle %p", &__func__, handle);
      SetLastError (6);
      D.14803 = 0;
      return D.14803;
      <D.14802>:
      console_handle.24 = console_handle;
      fd = console_handle.24->fd;
      if (bytesread != 0B) goto <D.14805>; else goto <D.14806>;
      <D.14805>:
      *bytesread = 0;
      <D.14806>:
      console_handle.24 = console_handle;
      D.14807 = console_handle.24->fileaccess;
      D.14808 = (signed int) D.14807;
      if (D.14808 >= 0) goto <D.14809>; else goto <D.14810>;
      <D.14809>:
      console_handle.24 = console_handle;
      D.14807 = console_handle.24->fileaccess;
      D.14811 = D.14807 & 268435456;
      if (D.14811 == 0) goto <D.14812>; else goto <D.14813>;
      <D.14812>:
      SetLastError (5);
      D.14803 = 0;
      return D.14803;
      <D.14813>:
      <D.14810>:
      <D.13716>:
      ret = read (fd, buffer, numbytes);
      if (ret == -1) goto <D.14814>; else goto <D.13717>;
      <D.14814>:
      D.14815 = __errno_location ();
      D.14816 = *D.14815;
      if (D.14816 == 4) goto <D.14817>; else goto <D.13717>;
      <D.14817>:
      D.14818 = _wapi_thread_cur_apc_pending ();
      if (D.14818 == 0) goto <D.13716>; else goto <D.13717>;
      <D.13717>:
      if (ret == -1) goto <D.14819>; else goto <D.14820>;
      <D.14819>:
      _wapi_set_last_error_from_errno ();
      D.14803 = 0;
      return D.14803;
      <D.14820>:
      if (bytesread != 0B) goto <D.14821>; else goto <D.14822>;
      <D.14821>:
      ret.25 = (unsigned int) ret;
      *bytesread = ret.25;
      <D.14822>:
      D.14803 = 1;
      return D.14803;
    }
  finally
    {
      console_handle = {CLOBBER};
    }
}


console_getfiletype ()
{
  WapiFileType D.14826;

  D.14826 = 2;
  return D.14826;
}


file_setfiletime (void * handle, const struct WapiFileTime * create_time, const struct WapiFileTime * last_access, const struct WapiFileTime * last_write)
{
  gboolean D.14830;
  struct _WapiHandle_file * file_handle.26;
  unsigned int D.14832;
  unsigned int D.14833;
  gchar * D.14836;
  unsigned int D.14843;
  long long unsigned int D.14844;
  long long unsigned int D.14845;
  unsigned int D.14846;
  long long unsigned int D.14847;
  long long unsigned int D.14850;
  long long unsigned int D.14851;
  long int D.14852;
  long int D.14854;
  unsigned int D.14857;
  long long unsigned int D.14858;
  long long unsigned int D.14859;
  unsigned int D.14860;
  long long unsigned int D.14861;
  long long unsigned int D.14864;
  long long unsigned int D.14865;
  long int D.14866;
  long int D.14868;
  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.14828>; else goto <D.14829>;
      <D.14828>:
      monoeg_g_log (0B, 16, "%s: error looking up file handle %p", &__func__, handle);
      SetLastError (6);
      D.14830 = 0;
      return D.14830;
      <D.14829>:
      file_handle.26 = file_handle;
      fd = file_handle.26->fd;
      file_handle.26 = file_handle;
      D.14832 = BIT_FIELD_REF <*file_handle.26, 32, 128>;
      D.14833 = D.14832 & 1342177280;
      if (D.14833 == 0) goto <D.14834>; else goto <D.14835>;
      <D.14834>:
      SetLastError (5);
      D.14830 = 0;
      return D.14830;
      <D.14835>:
      file_handle.26 = file_handle;
      D.14836 = file_handle.26->filename;
      if (D.14836 == 0B) goto <D.14837>; else goto <D.14838>;
      <D.14837>:
      SetLastError (6);
      D.14830 = 0;
      return D.14830;
      <D.14838>:
      ret = fstat (fd, &statbuf);
      if (ret == -1) goto <D.14839>; else goto <D.14840>;
      <D.14839>:
      SetLastError (87);
      D.14830 = 0;
      return D.14830;
      <D.14840>:
      if (last_access != 0B) goto <D.14841>; else goto <D.14842>;
      <D.14841>:
      D.14843 = last_access->dwHighDateTime;
      D.14844 = (long long unsigned int) D.14843;
      D.14845 = D.14844 << 32;
      D.14846 = last_access->dwLowDateTime;
      D.14847 = (long long unsigned int) D.14846;
      access_ticks = D.14845 + D.14847;
      if (access_ticks <= 116444735999999999) goto <D.14848>; else goto <D.14849>;
      <D.14848>:
      SetLastError (87);
      D.14830 = 0;
      return D.14830;
      <D.14849>:
      D.14850 = access_ticks + 18330299337709551616;
      D.14851 = D.14850 / 10000000;
      D.14852 = (long int) D.14851;
      utbuf.actime = D.14852;
      goto <D.14853>;
      <D.14842>:
      D.14854 = statbuf.st_atim.tv_sec;
      utbuf.actime = D.14854;
      <D.14853>:
      if (last_write != 0B) goto <D.14855>; else goto <D.14856>;
      <D.14855>:
      D.14857 = last_write->dwHighDateTime;
      D.14858 = (long long unsigned int) D.14857;
      D.14859 = D.14858 << 32;
      D.14860 = last_write->dwLowDateTime;
      D.14861 = (long long unsigned int) D.14860;
      write_ticks = D.14859 + D.14861;
      if (write_ticks <= 116444735999999999) goto <D.14862>; else goto <D.14863>;
      <D.14862>:
      SetLastError (87);
      D.14830 = 0;
      return D.14830;
      <D.14863>:
      D.14864 = write_ticks + 18330299337709551616;
      D.14865 = D.14864 / 10000000;
      D.14866 = (long int) D.14865;
      utbuf.modtime = D.14866;
      goto <D.14867>;
      <D.14856>:
      D.14868 = statbuf.st_mtim.tv_sec;
      utbuf.modtime = D.14868;
      <D.14867>:
      file_handle.26 = file_handle;
      D.14836 = file_handle.26->filename;
      ret = _wapi_utime (D.14836, &utbuf);
      if (ret == -1) goto <D.14869>; else goto <D.14870>;
      <D.14869>:
      SetLastError (87);
      D.14830 = 0;
      return D.14830;
      <D.14870>:
      D.14830 = 1;
      return D.14830;
    }
  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.14875;
  struct _WapiHandle_file * file_handle.27;
  unsigned int D.14877;
  signed int D.14878;
  unsigned int D.14881;
  long int D.14886;
  long int D.14887;
  long long unsigned int D.14890;
  long long unsigned int D.14891;
  long long unsigned int D.14893;
  long long unsigned int D.14894;
  long int D.14895;
  long long unsigned int D.14896;
  long long unsigned int D.14897;
  unsigned int D.14900;
  long long unsigned int D.14901;
  unsigned int D.14902;
  unsigned int D.14905;
  long long unsigned int D.14906;
  unsigned int D.14907;
  unsigned int D.14910;
  long long unsigned int D.14911;
  unsigned int D.14912;
  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.14873>; else goto <D.14874>;
      <D.14873>:
      monoeg_g_log (0B, 16, "%s: error looking up file handle %p", &__func__, handle);
      SetLastError (6);
      D.14875 = 0;
      return D.14875;
      <D.14874>:
      file_handle.27 = file_handle;
      fd = file_handle.27->fd;
      file_handle.27 = file_handle;
      D.14877 = file_handle.27->fileaccess;
      D.14878 = (signed int) D.14877;
      if (D.14878 >= 0) goto <D.14879>; else goto <D.14880>;
      <D.14879>:
      file_handle.27 = file_handle;
      D.14877 = file_handle.27->fileaccess;
      D.14881 = D.14877 & 268435456;
      if (D.14881 == 0) goto <D.14882>; else goto <D.14883>;
      <D.14882>:
      SetLastError (5);
      D.14875 = 0;
      return D.14875;
      <D.14883>:
      <D.14880>:
      ret = fstat (fd, &statbuf);
      if (ret == -1) goto <D.14884>; else goto <D.14885>;
      <D.14884>:
      _wapi_set_last_error_from_errno ();
      D.14875 = 0;
      return D.14875;
      <D.14885>:
      D.14886 = statbuf.st_atim.tv_sec;
      D.14887 = statbuf.st_ctim.tv_sec;
      if (D.14886 < D.14887) goto <D.14888>; else goto <D.14889>;
      <D.14888>:
      D.14886 = statbuf.st_atim.tv_sec;
      D.14890 = (long long unsigned int) D.14886;
      D.14891 = D.14890 * 10000000;
      create_ticks = D.14891 + 116444736000000000;
      goto <D.14892>;
      <D.14889>:
      D.14887 = statbuf.st_ctim.tv_sec;
      D.14893 = (long long unsigned int) D.14887;
      D.14894 = D.14893 * 10000000;
      create_ticks = D.14894 + 116444736000000000;
      <D.14892>:
      D.14886 = statbuf.st_atim.tv_sec;
      D.14890 = (long long unsigned int) D.14886;
      D.14891 = D.14890 * 10000000;
      access_ticks = D.14891 + 116444736000000000;
      D.14895 = statbuf.st_mtim.tv_sec;
      D.14896 = (long long unsigned int) D.14895;
      D.14897 = D.14896 * 10000000;
      write_ticks = D.14897 + 116444736000000000;
      if (create_time != 0B) goto <D.14898>; else goto <D.14899>;
      <D.14898>:
      D.14900 = (unsigned int) create_ticks;
      create_time->dwLowDateTime = D.14900;
      D.14901 = create_ticks >> 32;
      D.14902 = (unsigned int) D.14901;
      create_time->dwHighDateTime = D.14902;
      <D.14899>:
      if (last_access != 0B) goto <D.14903>; else goto <D.14904>;
      <D.14903>:
      D.14905 = (unsigned int) access_ticks;
      last_access->dwLowDateTime = D.14905;
      D.14906 = access_ticks >> 32;
      D.14907 = (unsigned int) D.14906;
      last_access->dwHighDateTime = D.14907;
      <D.14904>:
      if (last_write != 0B) goto <D.14908>; else goto <D.14909>;
      <D.14908>:
      D.14910 = (unsigned int) write_ticks;
      last_write->dwLowDateTime = D.14910;
      D.14911 = write_ticks >> 32;
      D.14912 = (unsigned int) D.14911;
      last_write->dwHighDateTime = D.14912;
      <D.14909>:
      D.14875 = 1;
      return D.14875;
    }
  finally
    {
      file_handle = {CLOBBER};
      statbuf = {CLOBBER};
    }
}


file_getfilesize (void * handle, guint32 * highsize)
{
  guint32 D.14917;
  struct _WapiHandle_file * file_handle.28;
  unsigned int D.14919;
  signed int D.14920;
  unsigned int D.14923;
  unsigned int D.14924;
  unsigned int D.14929;
  unsigned int D.14930;
  int D.14933;
  long long unsigned int bigsize.29;
  long long unsigned int D.14939;
  unsigned int D.14940;
  long long int D.14941;
  long long int D.14944;
  unsigned int D.14945;
  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.14915>; else goto <D.14916>;
      <D.14915>:
      monoeg_g_log (0B, 16, "%s: error looking up file handle %p", &__func__, handle);
      SetLastError (6);
      D.14917 = 4294967295;
      return D.14917;
      <D.14916>:
      file_handle.28 = file_handle;
      fd = file_handle.28->fd;
      file_handle.28 = file_handle;
      D.14919 = file_handle.28->fileaccess;
      D.14920 = (signed int) D.14919;
      if (D.14920 >= 0) goto <D.14921>; else goto <D.14922>;
      <D.14921>:
      file_handle.28 = file_handle;
      D.14923 = BIT_FIELD_REF <*file_handle.28, 32, 128>;
      D.14924 = D.14923 & 1342177280;
      if (D.14924 == 0) goto <D.14925>; else goto <D.14926>;
      <D.14925>:
      SetLastError (5);
      D.14917 = 4294967295;
      return D.14917;
      <D.14926>:
      <D.14922>:
      SetLastError (0);
      ret = fstat (fd, &statbuf);
      if (ret == -1) goto <D.14927>; else goto <D.14928>;
      <D.14927>:
      _wapi_set_last_error_from_errno ();
      D.14917 = 4294967295;
      return D.14917;
      <D.14928>:
      D.14929 = statbuf.st_mode;
      D.14930 = D.14929 & 61440;
      if (D.14930 == 24576) goto <D.14931>; else goto <D.14932>;
      <D.14931>:
      {
        guint64 bigsize;

        try
          {
            D.14933 = ioctl (fd, 2147750514, &bigsize);
            if (D.14933 < 0) goto <D.14934>; else goto <D.14935>;
            <D.14934>:
            _wapi_set_last_error_from_errno ();
            D.14917 = 4294967295;
            return D.14917;
            <D.14935>:
            bigsize.29 = bigsize;
            size = (guint32) bigsize.29;
            if (highsize != 0B) goto <D.14937>; else goto <D.14938>;
            <D.14937>:
            bigsize.29 = bigsize;
            D.14939 = bigsize.29 >> 32;
            D.14940 = (unsigned int) D.14939;
            *highsize = D.14940;
            <D.14938>:
            D.14917 = size;
            return D.14917;
          }
        finally
          {
            bigsize = {CLOBBER};
          }
      }
      <D.14932>:
      D.14941 = statbuf.st_size;
      size = (guint32) D.14941;
      if (highsize != 0B) goto <D.14942>; else goto <D.14943>;
      <D.14942>:
      D.14941 = statbuf.st_size;
      D.14944 = D.14941 >> 32;
      D.14945 = (unsigned int) D.14944;
      *highsize = D.14945;
      <D.14943>:
      D.14917 = size;
      return D.14917;
    }
  finally
    {
      file_handle = {CLOBBER};
      statbuf = {CLOBBER};
    }
}


file_setendoffile (void * handle)
{
  gboolean D.14951;
  struct _WapiHandle_file * file_handle.30;
  unsigned int D.14953;
  unsigned int D.14954;
  int * D.14962;
  int D.14963;
  int D.14965;
  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.14949>; else goto <D.14950>;
      <D.14949>:
      monoeg_g_log (0B, 16, "%s: error looking up file handle %p", &__func__, handle);
      SetLastError (6);
      D.14951 = 0;
      return D.14951;
      <D.14950>:
      file_handle.30 = file_handle;
      fd = file_handle.30->fd;
      file_handle.30 = file_handle;
      D.14953 = BIT_FIELD_REF <*file_handle.30, 32, 128>;
      D.14954 = D.14953 & 1342177280;
      if (D.14954 == 0) goto <D.14955>; else goto <D.14956>;
      <D.14955>:
      SetLastError (5);
      D.14951 = 0;
      return D.14951;
      <D.14956>:
      ret = fstat (fd, &statbuf);
      if (ret == -1) goto <D.14957>; else goto <D.14958>;
      <D.14957>:
      _wapi_set_last_error_from_errno ();
      D.14951 = 0;
      return D.14951;
      <D.14958>:
      size = statbuf.st_size;
      pos = lseek (fd, 0, 1);
      if (pos == -1) goto <D.14959>; else goto <D.14960>;
      <D.14959>:
      _wapi_set_last_error_from_errno ();
      D.14951 = 0;
      return D.14951;
      <D.14960>:
      <D.13651>:
      ret = ftruncate (fd, pos);
      if (ret == -1) goto <D.14961>; else goto <D.13652>;
      <D.14961>:
      D.14962 = __errno_location ();
      D.14963 = *D.14962;
      if (D.14963 == 4) goto <D.14964>; else goto <D.13652>;
      <D.14964>:
      D.14965 = _wapi_thread_cur_apc_pending ();
      if (D.14965 == 0) goto <D.13651>; else goto <D.13652>;
      <D.13652>:
      if (ret == -1) goto <D.14966>; else goto <D.14967>;
      <D.14966>:
      _wapi_set_last_error_from_errno ();
      D.14951 = 0;
      return D.14951;
      <D.14967>:
      D.14951 = 1;
      return D.14951;
    }
  finally
    {
      file_handle = {CLOBBER};
      statbuf = {CLOBBER};
    }
}


file_seek (void * handle, gint32 movedistance, gint32 * highmovedistance, WapiSeekMethod method)
{
  guint32 D.14972;
  struct _WapiHandle_file * file_handle.31;
  unsigned int D.14974;
  signed int D.14975;
  unsigned int D.14978;
  unsigned int D.14979;
  int D.14985;
  long long int D.14986;
  long long int D.14987;
  unsigned int movedistance.32;
  long long int D.14989;
  long long int D.14994;
  int D.14995;
  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.14970>; else goto <D.14971>;
      <D.14970>:
      monoeg_g_log (0B, 16, "%s: error looking up file handle %p", &__func__, handle);
      SetLastError (6);
      D.14972 = 4294967295;
      return D.14972;
      <D.14971>:
      file_handle.31 = file_handle;
      fd = file_handle.31->fd;
      file_handle.31 = file_handle;
      D.14974 = file_handle.31->fileaccess;
      D.14975 = (signed int) D.14974;
      if (D.14975 >= 0) goto <D.14976>; else goto <D.14977>;
      <D.14976>:
      file_handle.31 = file_handle;
      D.14978 = BIT_FIELD_REF <*file_handle.31, 32, 128>;
      D.14979 = D.14978 & 1342177280;
      if (D.14979 == 0) goto <D.14980>; else goto <D.14981>;
      <D.14980>:
      SetLastError (5);
      D.14972 = 4294967295;
      return D.14972;
      <D.14981>:
      <D.14977>:
      switch (method) <default: <D.13639>, case 0: <D.13635>, case 1: <D.13637>, case 2: <D.13638>>
      <D.13635>:
      whence = 0;
      goto <D.13636>;
      <D.13637>:
      whence = 1;
      goto <D.13636>;
      <D.13638>:
      whence = 2;
      goto <D.13636>;
      <D.13639>:
      SetLastError (87);
      D.14972 = 4294967295;
      return D.14972;
      <D.13636>:
      if (highmovedistance == 0B) goto <D.14982>; else goto <D.14983>;
      <D.14982>:
      offset = (gint64) movedistance;
      goto <D.14984>;
      <D.14983>:
      D.14985 = *highmovedistance;
      D.14986 = (long long int) D.14985;
      D.14987 = D.14986 << 32;
      movedistance.32 = (unsigned int) movedistance;
      D.14989 = (long long int) movedistance.32;
      offset = D.14987 | D.14989;
      <D.14984>:
      newpos = lseek (fd, offset, whence);
      if (newpos == -1) goto <D.14990>; else goto <D.14991>;
      <D.14990>:
      _wapi_set_last_error_from_errno ();
      D.14972 = 4294967295;
      return D.14972;
      <D.14991>:
      ret = (guint32) newpos;
      if (highmovedistance != 0B) goto <D.14992>; else goto <D.14993>;
      <D.14992>:
      D.14994 = newpos >> 32;
      D.14995 = (int) D.14994;
      *highmovedistance = D.14995;
      <D.14993>:
      D.14972 = ret;
      return D.14972;
    }
  finally
    {
      file_handle = {CLOBBER};
    }
}


file_flush (void * handle)
{
  gboolean D.15000;
  struct _WapiHandle_file * file_handle.33;
  unsigned int D.15002;
  unsigned int D.15003;
  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.14998>; else goto <D.14999>;
      <D.14998>:
      monoeg_g_log (0B, 16, "%s: error looking up file handle %p", &__func__, handle);
      SetLastError (6);
      D.15000 = 0;
      return D.15000;
      <D.14999>:
      file_handle.33 = file_handle;
      fd = file_handle.33->fd;
      file_handle.33 = file_handle;
      D.15002 = BIT_FIELD_REF <*file_handle.33, 32, 128>;
      D.15003 = D.15002 & 1342177280;
      if (D.15003 == 0) goto <D.15004>; else goto <D.15005>;
      <D.15004>:
      SetLastError (5);
      D.15000 = 0;
      return D.15000;
      <D.15005>:
      ret = fsync (fd);
      if (ret == -1) goto <D.15006>; else goto <D.15007>;
      <D.15006>:
      _wapi_set_last_error_from_errno ();
      D.15000 = 0;
      return D.15000;
      <D.15007>:
      D.15000 = 1;
      return D.15000;
    }
  finally
    {
      file_handle = {CLOBBER};
    }
}


file_write (void * handle, const void * buffer, guint32 numbytes, guint32 * byteswritten, struct WapiOverlapped * overlapped)
{
  gboolean D.15012;
  struct _WapiHandle_file * file_handle.34;
  unsigned int D.15016;
  unsigned int D.15017;
  int lock_while_writing.35;
  long long int D.15025;
  int D.15026;
  int * D.15030;
  int D.15031;
  int D.15033;
  unsigned int ret.36;
  struct _WapiHandle_file * file_handle;
  gboolean ok;
  int ret;
  int fd;
  off_t current_pos;
  static const char __func__[11] = "file_write";

  try
    {
      current_pos = 0;
      ok = _wapi_lookup_handle (handle, 1, &file_handle);
      if (ok == 0) goto <D.15010>; else goto <D.15011>;
      <D.15010>:
      monoeg_g_log (0B, 16, "%s: error looking up file handle %p", &__func__, handle);
      SetLastError (6);
      D.15012 = 0;
      return D.15012;
      <D.15011>:
      file_handle.34 = file_handle;
      fd = file_handle.34->fd;
      if (byteswritten != 0B) goto <D.15014>; else goto <D.15015>;
      <D.15014>:
      *byteswritten = 0;
      <D.15015>:
      file_handle.34 = file_handle;
      D.15016 = BIT_FIELD_REF <*file_handle.34, 32, 128>;
      D.15017 = D.15016 & 1342177280;
      if (D.15017 == 0) goto <D.15018>; else goto <D.15019>;
      <D.15018>:
      SetLastError (5);
      D.15012 = 0;
      return D.15012;
      <D.15019>:
      lock_while_writing.35 = lock_while_writing;
      if (lock_while_writing.35 != 0) goto <D.15021>; else goto <D.15022>;
      <D.15021>:
      current_pos = lseek (fd, 0, 1);
      if (current_pos == -1) goto <D.15023>; else goto <D.15024>;
      <D.15023>:
      _wapi_set_last_error_from_errno ();
      D.15012 = 0;
      return D.15012;
      <D.15024>:
      D.15025 = (long long int) numbytes;
      D.15026 = _wapi_lock_file_region (fd, current_pos, D.15025);
      if (D.15026 == 0) goto <D.15027>; else goto <D.15028>;
      <D.15027>:
      D.15012 = 0;
      return D.15012;
      <D.15028>:
      <D.15022>:
      <D.13611>:
      ret = write (fd, buffer, numbytes);
      if (ret == -1) goto <D.15029>; else goto <D.13612>;
      <D.15029>:
      D.15030 = __errno_location ();
      D.15031 = *D.15030;
      if (D.15031 == 4) goto <D.15032>; else goto <D.13612>;
      <D.15032>:
      D.15033 = _wapi_thread_cur_apc_pending ();
      if (D.15033 == 0) goto <D.13611>; else goto <D.13612>;
      <D.13612>:
      lock_while_writing.35 = lock_while_writing;
      if (lock_while_writing.35 != 0) goto <D.15034>; else goto <D.15035>;
      <D.15034>:
      D.15025 = (long long int) numbytes;
      _wapi_unlock_file_region (fd, current_pos, D.15025);
      <D.15035>:
      if (ret == -1) goto <D.15036>; else goto <D.15037>;
      <D.15036>:
      D.15030 = __errno_location ();
      D.15031 = *D.15030;
      if (D.15031 == 4) goto <D.15038>; else goto <D.15039>;
      <D.15038>:
      ret = 0;
      goto <D.15040>;
      <D.15039>:
      _wapi_set_last_error_from_errno ();
      D.15012 = 0;
      return D.15012;
      <D.15040>:
      <D.15037>:
      if (byteswritten != 0B) goto <D.15041>; else goto <D.15042>;
      <D.15041>:
      ret.36 = (unsigned int) ret;
      *byteswritten = ret.36;
      <D.15042>:
      D.15012 = 1;
      return D.15012;
    }
  finally
    {
      file_handle = {CLOBBER};
    }
}


file_read (void * handle, void * buffer, guint32 numbytes, guint32 * bytesread, struct WapiOverlapped * overlapped)
{
  gboolean D.15048;
  struct _WapiHandle_file * file_handle.37;
  unsigned int D.15052;
  signed int D.15053;
  unsigned int D.15056;
  int * D.15060;
  int D.15061;
  int D.15063;
  int D.15066;
  unsigned int D.15067;
  unsigned int ret.38;
  struct _WapiHandle_file * file_handle;
  gboolean ok;
  int fd;
  int ret;
  static const char __func__[10] = "file_read";

  try
    {
      ok = _wapi_lookup_handle (handle, 1, &file_handle);
      if (ok == 0) goto <D.15046>; else goto <D.15047>;
      <D.15046>:
      monoeg_g_log (0B, 16, "%s: error looking up file handle %p", &__func__, handle);
      SetLastError (6);
      D.15048 = 0;
      return D.15048;
      <D.15047>:
      file_handle.37 = file_handle;
      fd = file_handle.37->fd;
      if (bytesread != 0B) goto <D.15050>; else goto <D.15051>;
      <D.15050>:
      *bytesread = 0;
      <D.15051>:
      file_handle.37 = file_handle;
      D.15052 = file_handle.37->fileaccess;
      D.15053 = (signed int) D.15052;
      if (D.15053 >= 0) goto <D.15054>; else goto <D.15055>;
      <D.15054>:
      file_handle.37 = file_handle;
      D.15052 = file_handle.37->fileaccess;
      D.15056 = D.15052 & 268435456;
      if (D.15056 == 0) goto <D.15057>; else goto <D.15058>;
      <D.15057>:
      SetLastError (5);
      D.15048 = 0;
      return D.15048;
      <D.15058>:
      <D.15055>:
      <D.13595>:
      ret = read (fd, buffer, numbytes);
      if (ret == -1) goto <D.15059>; else goto <D.13596>;
      <D.15059>:
      D.15060 = __errno_location ();
      D.15061 = *D.15060;
      if (D.15061 == 4) goto <D.15062>; else goto <D.13596>;
      <D.15062>:
      D.15063 = _wapi_thread_cur_apc_pending ();
      if (D.15063 == 0) goto <D.13595>; else goto <D.13596>;
      <D.13596>:
      if (ret == -1) goto <D.15064>; else goto <D.15065>;
      <D.15064>:
      {
        gint err;

        D.15060 = __errno_location ();
        err = *D.15060;
        D.15066 = _wapi_get_win32_file_error (err);
        D.15067 = (unsigned int) D.15066;
        SetLastError (D.15067);
        D.15048 = 0;
        return D.15048;
      }
      <D.15065>:
      if (bytesread != 0B) goto <D.15068>; else goto <D.15069>;
      <D.15068>:
      ret.38 = (unsigned int) ret;
      *bytesread = ret.38;
      <D.15069>:
      D.15048 = 1;
      return D.15048;
    }
  finally
    {
      file_handle = {CLOBBER};
    }
}


file_getfiletype ()
{
  WapiFileType D.15073;

  D.15073 = 1;
  return D.15073;
}


_wapi_handle_type (void * handle)
{
  unsigned int D.15078;
  struct _WapiHandleUnshared * D.15079;
  WapiHandleType D.15080;
  unsigned int D.15081;
  unsigned int D.15082;
  struct _WapiHandleUnshared * D.15083;
  guint32 idx;

  idx = (guint32) handle;
  if (idx > 4194303) goto <D.15075>; else goto <D.15077>;
  <D.15077>:
  D.15078 = idx / 256;
  D.15079 = _wapi_private_handles[D.15078];
  if (D.15079 == 0B) goto <D.15075>; else goto <D.15076>;
  <D.15075>:
  D.15080 = 0;
  return D.15080;
  <D.15076>:
  D.15078 = idx / 256;
  D.15079 = _wapi_private_handles[D.15078];
  D.15081 = idx & 255;
  D.15082 = D.15081 * 144;
  D.15083 = D.15079 + D.15082;
  D.15080 = D.15083->type;
  return D.15080;
}


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

  type = _wapi_handle_type (handle);
  D.15085 = io_ops[type].writefile;
  if (D.15085 == 0B) goto <D.15086>; else goto <D.15087>;
  <D.15086>:
  SetLastError (6);
  D.15088 = 0;
  return D.15088;
  <D.15087>:
  D.15085 = io_ops[type].writefile;
  D.15088 = D.15085 (handle, buffer, numbytes, byteswritten, overlapped);
  return D.15088;
}


FlushFileBuffers (void * handle)
{
  gboolean (*<T2246>) (void *) D.15090;
  gboolean D.15093;
  WapiHandleType type;

  type = _wapi_handle_type (handle);
  D.15090 = io_ops[type].flushfile;
  if (D.15090 == 0B) goto <D.15091>; else goto <D.15092>;
  <D.15091>:
  SetLastError (6);
  D.15093 = 0;
  return D.15093;
  <D.15092>:
  D.15090 = io_ops[type].flushfile;
  D.15093 = D.15090 (handle);
  return D.15093;
}


SetEndOfFile (void * handle)
{
  gboolean (*<T2246>) (void *) D.15095;
  gboolean D.15098;
  WapiHandleType type;

  type = _wapi_handle_type (handle);
  D.15095 = io_ops[type].setendoffile;
  if (D.15095 == 0B) goto <D.15096>; else goto <D.15097>;
  <D.15096>:
  SetLastError (6);
  D.15098 = 0;
  return D.15098;
  <D.15097>:
  D.15095 = io_ops[type].setendoffile;
  D.15098 = D.15095 (handle);
  return D.15098;
}


SetFilePointer (void * handle, gint32 movedistance, gint32 * highmovedistance, WapiSeekMethod method)
{
  guint32 (*<T250b>) (void *, gint32, gint32 *, WapiSeekMethod) D.15100;
  guint32 D.15103;
  WapiHandleType type;

  type = _wapi_handle_type (handle);
  D.15100 = io_ops[type].seek;
  if (D.15100 == 0B) goto <D.15101>; else goto <D.15102>;
  <D.15101>:
  SetLastError (6);
  D.15103 = 4294967295;
  return D.15103;
  <D.15102>:
  D.15100 = io_ops[type].seek;
  D.15103 = D.15100 (handle, movedistance, highmovedistance, method);
  return D.15103;
}


GetFileType (void * handle)
{
  unsigned int handle.39;
  unsigned int D.15109;
  struct _WapiHandleUnshared * D.15110;
  WapiFileType D.15111;
  WapiFileType (*<T24fd>) (void) D.15112;
  WapiHandleType type;

  handle.39 = (unsigned int) handle;
  if (handle.39 > 268435455) goto <D.15105>; else goto <D.15108>;
  <D.15108>:
  handle.39 = (unsigned int) handle;
  D.15109 = handle.39 / 256;
  D.15110 = _wapi_private_handles[D.15109];
  if (D.15110 == 0B) goto <D.15105>; else goto <D.15106>;
  <D.15105>:
  SetLastError (6);
  D.15111 = 0;
  return D.15111;
  <D.15106>:
  type = _wapi_handle_type (handle);
  D.15112 = io_ops[type].getfiletype;
  if (D.15112 == 0B) goto <D.15113>; else goto <D.15114>;
  <D.15113>:
  SetLastError (6);
  D.15111 = 0;
  return D.15111;
  <D.15114>:
  D.15112 = io_ops[type].getfiletype;
  D.15111 = D.15112 ();
  return D.15111;
}


GetFileSize (void * handle, guint32 * highsize)
{
  guint32 (*<T2511>) (void *, guint32 *) D.15116;
  guint32 D.15119;
  WapiHandleType type;

  type = _wapi_handle_type (handle);
  D.15116 = io_ops[type].getfilesize;
  if (D.15116 == 0B) goto <D.15117>; else goto <D.15118>;
  <D.15117>:
  SetLastError (6);
  D.15119 = 4294967295;
  return D.15119;
  <D.15118>:
  D.15116 = io_ops[type].getfilesize;
  D.15119 = D.15116 (handle, highsize);
  return D.15119;
}


GetFileTime (void * handle, struct WapiFileTime * create_time, struct WapiFileTime * last_access, struct WapiFileTime * last_write)
{
  gboolean (*<T2515>) (void *, struct WapiFileTime *, struct WapiFileTime *, struct WapiFileTime *) D.15121;
  gboolean D.15124;
  WapiHandleType type;

  type = _wapi_handle_type (handle);
  D.15121 = io_ops[type].getfiletime;
  if (D.15121 == 0B) goto <D.15122>; else goto <D.15123>;
  <D.15122>:
  SetLastError (6);
  D.15124 = 0;
  return D.15124;
  <D.15123>:
  D.15121 = io_ops[type].getfiletime;
  D.15124 = D.15121 (handle, create_time, last_access, last_write);
  return D.15124;
}


SetFileTime (void * handle, const struct WapiFileTime * create_time, const struct WapiFileTime * last_access, const struct WapiFileTime * last_write)
{
  gboolean (*<T2519>) (void *, const struct WapiFileTime *, const struct WapiFileTime *, const struct WapiFileTime *) D.15126;
  gboolean D.15129;
  WapiHandleType type;

  type = _wapi_handle_type (handle);
  D.15126 = io_ops[type].setfiletime;
  if (D.15126 == 0B) goto <D.15127>; else goto <D.15128>;
  <D.15127>:
  SetLastError (6);
  D.15129 = 0;
  return D.15129;
  <D.15128>:
  D.15126 = io_ops[type].setfiletime;
  D.15129 = D.15126 (handle, create_time, last_access, last_write);
  return D.15129;
}


FileTimeToSystemTime (const struct WapiFileTime * file_time, struct WapiSystemTime * system_time)
{
  gboolean D.15133;
  unsigned int D.15134;
  long long int D.15135;
  long long int D.15136;
  unsigned int D.15137;
  long long int D.15138;
  long long int D.15141;
  short unsigned int D.15142;
  long long int D.15143;
  short unsigned int D.15144;
  long long int D.15145;
  short unsigned int D.15146;
  long long int D.15147;
  short unsigned int D.15148;
  long long int D.15149;
  long long int D.15150;
  short unsigned int D.15151;
  short unsigned int D.15152;
  long long int D.15153;
  long long int D.15154;
  long long int D.15155;
  _Bool D.15156;
  long long int D.15157;
  long long int D.15158;
  long long int D.15159;
  long long int D.15160;
  _Bool D.15161;
  long long int D.15162;
  long long int D.15163;
  long long int D.15164;
  _Bool D.15165;
  long long int D.15166;
  long long int D.15167;
  long long int D.15168;
  long long int D.15169;
  long long int D.15170;
  long long int D.15171;
  _Bool D.15172;
  long long int D.15173;
  long long int D.15174;
  long long int D.15175;
  long long int D.15176;
  long long int D.15177;
  long long int D.15178;
  _Bool D.15179;
  long long int D.15180;
  long long int D.15181;
  long long int D.15182;
  _Bool D.15183;
  long long int D.15184;
  long long int D.15185;
  long long int D.15186;
  long long int D.15187;
  long long int D.15188;
  long long int D.15189;
  _Bool D.15190;
  long long int D.15191;
  long long int D.15192;
  long long int D.15193;
  long long int D.15194;
  long long int D.15195;
  long long int D.15196;
  long long int D.15197;
  long long int D.15198;
  long long int D.15199;
  long long int D.15200;
  long long int D.15201;
  long long int D.15202;
  long long int D.15203;
  long long int D.15204;
  long long int D.15205;
  gint64 iftmp.40;
  unsigned long long y.41;
  unsigned long long D.15212;
  long long int D.15214;
  long long int D.15216;
  short unsigned int D.15217;
  int iftmp.42;
  unsigned int D.15224;
  unsigned int D.15225;
  const guint16 * D.15226;
  short unsigned int D.15227;
  long long int D.15228;
  short unsigned int D.15229;
  short unsigned int D.15230;
  short unsigned int D.15231;
  gint64 file_ticks;
  gint64 totaldays;
  gint64 rem;
  gint64 y;
  const guint16 * ip;
  static const char __func__[21] = "FileTimeToSystemTime";

  if (system_time == 0B) goto <D.15131>; else goto <D.15132>;
  <D.15131>:
  SetLastError (87);
  D.15133 = 0;
  return D.15133;
  <D.15132>:
  D.15134 = file_time->dwHighDateTime;
  D.15135 = (long long int) D.15134;
  D.15136 = D.15135 << 32;
  D.15137 = file_time->dwLowDateTime;
  D.15138 = (long long int) D.15137;
  file_ticks = D.15136 + D.15138;
  if (file_ticks < 0) goto <D.15139>; else goto <D.15140>;
  <D.15139>:
  SetLastError (87);
  D.15133 = 0;
  return D.15133;
  <D.15140>:
  totaldays = file_ticks / 864000000000;
  rem = file_ticks % 864000000000;
  D.15141 = rem / 36000000000;
  D.15142 = (short unsigned int) D.15141;
  system_time->wHour = D.15142;
  rem = rem % 36000000000;
  D.15143 = rem / 600000000;
  D.15144 = (short unsigned int) D.15143;
  system_time->wMinute = D.15144;
  rem = rem % 600000000;
  D.15145 = rem / 10000000;
  D.15146 = (short unsigned int) D.15145;
  system_time->wSecond = D.15146;
  rem = rem % 10000000;
  D.15147 = rem / 10000;
  D.15148 = (short unsigned int) D.15147;
  system_time->wMilliseconds = D.15148;
  D.15149 = totaldays + 1;
  D.15150 = D.15149 % 7;
  D.15151 = (short unsigned int) D.15150;
  D.15152 = D.15151 + 1;
  system_time->wDayOfWeek = D.15152;
  y = 1601;
  goto <D.13994>;
  <D.13993>:
  {
    gint64 yg;

    D.15153 = totaldays / 365;
    D.15154 = D.15153 + y;
    D.15155 = totaldays % 365;
    D.15156 = D.15155 < 0;
    D.15157 = (long long int) D.15156;
    yg = D.15154 - D.15157;
    D.15158 = yg + -1;
    D.15159 = D.15158 / 4;
    D.15158 = yg + -1;
    D.15160 = D.15158 % 4;
    D.15161 = D.15160 < 0;
    D.15162 = (long long int) D.15161;
    D.15163 = D.15159 - D.15162;
    D.15158 = yg + -1;
    D.15164 = D.15158 % 100;
    D.15165 = D.15164 < 0;
    D.15166 = (long long int) D.15165;
    D.15158 = yg + -1;
    D.15167 = D.15158 / -100;
    D.15168 = D.15166 + D.15167;
    D.15169 = D.15163 + D.15168;
    D.15158 = yg + -1;
    D.15170 = D.15158 / 400;
    D.15158 = yg + -1;
    D.15171 = D.15158 % 400;
    D.15172 = D.15171 < 0;
    D.15173 = (long long int) D.15172;
    D.15174 = D.15170 - D.15173;
    D.15175 = D.15169 + D.15174;
    D.15176 = y + -1;
    D.15177 = D.15176 / 4;
    D.15176 = y + -1;
    D.15178 = D.15176 % 4;
    D.15179 = D.15178 < 0;
    D.15180 = (long long int) D.15179;
    D.15181 = D.15177 - D.15180;
    D.15176 = y + -1;
    D.15182 = D.15176 % 100;
    D.15183 = D.15182 < 0;
    D.15184 = (long long int) D.15183;
    D.15176 = y + -1;
    D.15185 = D.15176 / -100;
    D.15186 = D.15184 + D.15185;
    D.15187 = D.15181 + D.15186;
    D.15176 = y + -1;
    D.15188 = D.15176 / 400;
    D.15176 = y + -1;
    D.15189 = D.15176 % 400;
    D.15190 = D.15189 < 0;
    D.15191 = (long long int) D.15190;
    D.15192 = D.15188 - D.15191;
    D.15193 = D.15187 + D.15192;
    monoeg_g_log (0B, 32, "%s: LEAPS(yg): %lld LEAPS(y): %lld", &__func__, D.15175, D.15193);
    D.15176 = y + -1;
    D.15177 = D.15176 / 4;
    D.15176 = y + -1;
    D.15178 = D.15176 % 4;
    D.15179 = D.15178 < 0;
    D.15180 = (long long int) D.15179;
    D.15181 = D.15177 - D.15180;
    D.15176 = y + -1;
    D.15182 = D.15176 % 100;
    D.15183 = D.15182 < 0;
    D.15184 = (long long int) D.15183;
    D.15176 = y + -1;
    D.15185 = D.15176 / -100;
    D.15186 = D.15184 + D.15185;
    D.15187 = D.15181 + D.15186;
    D.15176 = y + -1;
    D.15188 = D.15176 / 400;
    D.15176 = y + -1;
    D.15189 = D.15176 % 400;
    D.15190 = D.15189 < 0;
    D.15191 = (long long int) D.15190;
    D.15192 = D.15188 - D.15191;
    D.15193 = D.15187 + D.15192;
    D.15158 = yg + -1;
    D.15171 = D.15158 % 400;
    D.15172 = D.15171 < 0;
    D.15173 = (long long int) D.15172;
    D.15158 = yg + -1;
    D.15194 = D.15158 / -400;
    D.15195 = D.15173 + D.15194;
    D.15158 = yg + -1;
    D.15196 = D.15158 / 100;
    D.15158 = yg + -1;
    D.15164 = D.15158 % 100;
    D.15165 = D.15164 < 0;
    D.15166 = (long long int) D.15165;
    D.15197 = D.15196 - D.15166;
    D.15158 = yg + -1;
    D.15160 = D.15158 % 4;
    D.15161 = D.15160 < 0;
    D.15162 = (long long int) D.15161;
    D.15158 = yg + -1;
    D.15198 = D.15158 / -4;
    D.15199 = D.15162 + D.15198;
    D.15200 = D.15197 + D.15199;
    D.15201 = D.15195 + D.15200;
    D.15202 = y - yg;
    D.15203 = D.15202 * 365;
    D.15204 = D.15201 + D.15203;
    D.15205 = D.15193 + D.15204;
    totaldays = D.15205 + totaldays;
    y = yg;
  }
  <D.13994>:
  if (totaldays < 0) goto <D.13993>; else goto <D.15206>;
  <D.15206>:
  y.41 = (unsigned long long) y;
  D.15212 = y.41 & 3;
  if (D.15212 == 0) goto <D.15213>; else goto <D.15208>;
  <D.15213>:
  D.15214 = y % 100;
  if (D.15214 != 0) goto <D.15209>; else goto <D.15215>;
  <D.15215>:
  D.15216 = y % 400;
  if (D.15216 == 0) goto <D.15209>; else goto <D.15208>;
  <D.15209>:
  iftmp.40 = 366;
  goto <D.15210>;
  <D.15208>:
  iftmp.40 = 365;
  <D.15210>:
  if (iftmp.40 <= totaldays) goto <D.13993>; else goto <D.13995>;
  <D.13995>:
  D.15217 = (short unsigned int) y;
  system_time->wYear = D.15217;
  y.41 = (unsigned long long) y;
  D.15212 = y.41 & 3;
  if (D.15212 == 0) goto <D.15222>; else goto <D.15219>;
  <D.15222>:
  D.15214 = y % 100;
  if (D.15214 != 0) goto <D.15220>; else goto <D.15223>;
  <D.15223>:
  D.15216 = y % 400;
  if (D.15216 == 0) goto <D.15220>; else goto <D.15219>;
  <D.15220>:
  iftmp.42 = 1;
  goto <D.15221>;
  <D.15219>:
  iftmp.42 = 0;
  <D.15221>:
  ip = &mon_yday[iftmp.42];
  y = 11;
  goto <D.13998>;
  <D.13997>:
  // predicted unlikely by continue predictor.
  goto <D.13996>;
  <D.13996>:
  y = y + -1;
  <D.13998>:
  D.15224 = (unsigned int) y;
  D.15225 = D.15224 * 2;
  D.15226 = ip + D.15225;
  D.15227 = *D.15226;
  D.15228 = (long long int) D.15227;
  if (D.15228 > totaldays) goto <D.13997>; else goto <D.13999>;
  <D.13999>:
  D.15224 = (unsigned int) y;
  D.15225 = D.15224 * 2;
  D.15226 = ip + D.15225;
  D.15227 = *D.15226;
  D.15228 = (long long int) D.15227;
  totaldays = totaldays - D.15228;
  D.15217 = (short unsigned int) y;
  D.15229 = D.15217 + 1;
  system_time->wMonth = D.15229;
  D.15230 = (short unsigned int) totaldays;
  D.15231 = D.15230 + 1;
  system_time->wDay = D.15231;
  D.15133 = 1;
  return D.15133;
}


FindFirstFile (const gunichar2 * pattern, struct WapiFindData * find_data)
{
  void * D.15235;
  int D.15246;
  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.15233>; else goto <D.15234>;
      <D.15233>:
      SetLastError (3);
      D.15235 = 4294967295B;
      return D.15235;
      <D.15234>:
      utf8_pattern = mono_unicode_to_external (pattern);
      if (utf8_pattern == 0B) goto <D.15236>; else goto <D.15237>;
      <D.15236>:
      SetLastError (123);
      D.15235 = 4294967295B;
      return D.15235;
      <D.15237>:
      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.15238>; else goto <D.15239>;
      <D.15238>:
      SetLastError (2);
      monoeg_g_free (utf8_pattern);
      monoeg_g_free (entry_part);
      monoeg_g_free (dir_part);
      D.15235 = 4294967295B;
      return D.15235;
      <D.15239>:
      if (result < 0) goto <D.15240>; else goto <D.15241>;
      <D.15240>:
      _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.15235 = 4294967295B;
      return D.15235;
      <D.15241>:
      monoeg_g_free (utf8_pattern);
      monoeg_g_free (entry_part);
      find_handle.dir_part = dir_part;
      find_handle.num = result;
      find_handle.count = 0;
      handle = _wapi_handle_new (8, &find_handle);
      if (handle == 4294967295B) goto <D.15242>; else goto <D.15243>;
      <D.15242>:
      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.15235 = 4294967295B;
      return D.15235;
      <D.15243>:
      if (handle != 4294967295B) goto <D.15244>; else goto <D.15245>;
      <D.15244>:
      D.15246 = FindNextFile (handle, find_data);
      if (D.15246 == 0) goto <D.15247>; else goto <D.15248>;
      <D.15247>:
      FindClose (handle);
      SetLastError (18);
      handle = 4294967295B;
      <D.15248>:
      <D.15245>:
      D.15235 = handle;
      return D.15235;
    }
  finally
    {
      find_handle = {CLOBBER};
    }
}


FindNextFile (void * handle, struct WapiFindData * find_data)
{
  gboolean D.15253;
  long int D.15254;
  _Bool D.15257;
  long int D.15258;
  long int D.15259;
  struct _WapiHandle_find * find_handle.43;
  unsigned int D.15263;
  int D.15264;
  unsigned int D.15265;
  gchar * D.15268;
  gchar * * D.15269;
  unsigned int D.15270;
  unsigned int D.15271;
  unsigned int D.15272;
  gchar * * D.15273;
  gchar * D.15274;
  int * D.15277;
  int D.15278;
  long int D.15287;
  long int D.15288;
  unsigned int D.15292;
  struct WapiFileTime * D.15293;
  long int D.15294;
  struct WapiFileTime * D.15295;
  struct WapiFileTime * D.15296;
  unsigned int D.15297;
  unsigned int D.15298;
  long long int D.15302;
  long long int D.15303;
  unsigned int D.15304;
  unsigned int D.15305;
  long int bytes.44;
  long int bytes.45;
  gunichar2[260] * D.15310;
  long int D.15311;
  unsigned int D.15312;
  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.15251>; else goto <D.15252>;
      <D.15251>:
      monoeg_g_log (0B, 16, "%s: error looking up find handle %p", &__func__, handle);
      SetLastError (6);
      D.15253 = 0;
      return D.15253;
      <D.15252>:
      {
        struct __pthread_unwind_buf_t __cancel_buf;
        void (*<Tc1>) (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.15254 = __builtin_expect (__not_first_call, 0);
            if (D.15254 != 0) goto <D.15255>; else goto <D.15256>;
            <D.15255>:
            __cancel_routine (__cancel_arg);
            __pthread_unwind_next (&__cancel_buf);
            <D.15256>:
            __pthread_register_cancel (&__cancel_buf);
            thr_ret = _wapi_handle_lock_handle (handle);
            D.15257 = thr_ret != 0;
            D.15258 = (long int) D.15257;
            D.15259 = __builtin_expect (D.15258, 0);
            if (D.15259 != 0) goto <D.15260>; else goto <D.15261>;
            <D.15260>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "io.c", 2803, "thr_ret == 0");
            <D.15261>:
            retry:
            find_handle.43 = find_handle;
            D.15263 = find_handle.43->count;
            find_handle.43 = find_handle;
            D.15264 = find_handle.43->num;
            D.15265 = (unsigned int) D.15264;
            if (D.15263 >= D.15265) goto <D.15266>; else goto <D.15267>;
            <D.15266>:
            SetLastError (18);
            goto cleanup;
            <D.15267>:
            find_handle.43 = find_handle;
            D.15268 = find_handle.43->dir_part;
            find_handle.43 = find_handle;
            D.15269 = find_handle.43->namelist;
            find_handle.43 = find_handle;
            D.15263 = find_handle.43->count;
            D.15270 = D.15263;
            D.15271 = D.15270 + 1;
            find_handle.43->count = D.15271;
            D.15272 = D.15270 * 4;
            D.15273 = D.15269 + D.15272;
            D.15274 = *D.15273;
            filename = monoeg_g_build_path ("/", D.15268, D.15274, 0B);
            result = _wapi_stat (filename, &buf);
            if (result == -1) goto <D.15275>; else goto <D.15276>;
            <D.15275>:
            D.15277 = __errno_location ();
            D.15278 = *D.15277;
            if (D.15278 == 2) goto <D.15279>; else goto <D.15280>;
            <D.15279>:
            result = _wapi_lstat (filename, &buf);
            <D.15280>:
            <D.15276>:
            if (result != 0) goto <D.15281>; else goto <D.15282>;
            <D.15281>:
            monoeg_g_free (filename);
            goto retry;
            <D.15282>:
            result = _wapi_lstat (filename, &linkbuf);
            if (result != 0) goto <D.15283>; else goto <D.15284>;
            <D.15283>:
            monoeg_g_free (filename);
            goto retry;
            <D.15284>:
            utf8_filename = mono_utf8_from_external (filename);
            if (utf8_filename == 0B) goto <D.15285>; else goto <D.15286>;
            <D.15285>:
            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.15286>:
            monoeg_g_free (filename);
            D.15287 = buf.st_mtim.tv_sec;
            D.15288 = buf.st_ctim.tv_sec;
            if (D.15287 < D.15288) goto <D.15289>; else goto <D.15290>;
            <D.15289>:
            create_time = buf.st_mtim.tv_sec;
            goto <D.15291>;
            <D.15290>:
            create_time = buf.st_ctim.tv_sec;
            <D.15291>:
            D.15292 = _wapi_stat_to_file_attributes (utf8_filename, &buf, &linkbuf);
            find_data->dwFileAttributes = D.15292;
            D.15293 = &find_data->ftCreationTime;
            _wapi_time_t_to_filetime (create_time, D.15293);
            D.15294 = buf.st_atim.tv_sec;
            D.15295 = &find_data->ftLastAccessTime;
            _wapi_time_t_to_filetime (D.15294, D.15295);
            D.15287 = buf.st_mtim.tv_sec;
            D.15296 = &find_data->ftLastWriteTime;
            _wapi_time_t_to_filetime (D.15287, D.15296);
            D.15297 = find_data->dwFileAttributes;
            D.15298 = D.15297 & 16;
            if (D.15298 != 0) goto <D.15299>; else goto <D.15300>;
            <D.15299>:
            find_data->nFileSizeHigh = 0;
            find_data->nFileSizeLow = 0;
            goto <D.15301>;
            <D.15300>:
            D.15302 = buf.st_size;
            D.15303 = D.15302 >> 32;
            D.15304 = (unsigned int) D.15303;
            find_data->nFileSizeHigh = D.15304;
            D.15302 = buf.st_size;
            D.15305 = (unsigned int) D.15302;
            find_data->nFileSizeLow = D.15305;
            <D.15301>:
            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.15306>; else goto <D.15307>;
            <D.15306>:
            monoeg_g_free (utf8_basename);
            monoeg_g_free (utf8_filename);
            goto retry;
            <D.15307>:
            ret = 1;
            bytes.44 = bytes;
            bytes.45 = bytes.44 * 2;
            bytes = bytes.45;
            D.15310 = &find_data->cFileName;
            memset (D.15310, 0, 520);
            D.15310 = &find_data->cFileName;
            bytes.44 = bytes;
            D.15311 = MIN_EXPR <bytes.44, 518>;
            D.15312 = (unsigned int) D.15311;
            memcpy (D.15310, utf16_basename, D.15312);
            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.15257 = thr_ret != 0;
            D.15258 = (long int) D.15257;
            D.15259 = __builtin_expect (D.15258, 0);
            if (D.15259 != 0) goto <D.15313>; else goto <D.15314>;
            <D.15313>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "io.c", 2910, "thr_ret == 0");
            <D.15314>:
            __pthread_unregister_cancel (&__cancel_buf);
            if (0 != 0) goto <D.15315>; else goto <D.15316>;
            <D.15315>:
            __cancel_routine (__cancel_arg);
            <D.15316>:
          }
        finally
          {
            __cancel_buf = {CLOBBER};
          }
      }
      D.15253 = ret;
      return D.15253;
    }
  finally
    {
      find_handle = {CLOBBER};
      buf = {CLOBBER};
      linkbuf = {CLOBBER};
      bytes = {CLOBBER};
    }
}


_wapi_handle_lock_handle (void * handle)
{
  int D.15332;
  <unnamed type> D.15335;
  <unnamed type> D.15337;
  <unnamed type> D.15339;
  <unnamed type> D.15341;
  unsigned int D.15342;
  struct _WapiHandleUnshared * D.15343;
  unsigned int D.15344;
  unsigned int D.15345;
  struct _WapiHandleUnshared * D.15346;
  union mono_mutex_t * D.15347;
  guint32 idx;

  idx = (guint32) handle;
  if (idx > 4194303) goto <D.15330>; else goto <D.15331>;
  <D.15330>:
  D.15332 = 0;
  return D.15332;
  <D.15331>:
  _wapi_handle_ref (handle);
  D.15335 = _wapi_handle_type (handle);
  if (D.15335 == 9) goto <D.15333>; else goto <D.15336>;
  <D.15336>:
  D.15337 = _wapi_handle_type (handle);
  if (D.15337 == 11) goto <D.15333>; else goto <D.15338>;
  <D.15338>:
  D.15339 = _wapi_handle_type (handle);
  if (D.15339 == 12) goto <D.15333>; else goto <D.15340>;
  <D.15340>:
  D.15341 = _wapi_handle_type (handle);
  if (D.15341 == 13) goto <D.15333>; else goto <D.15334>;
  <D.15333>:
  D.15332 = 0;
  return D.15332;
  <D.15334>:
  D.15342 = idx / 256;
  D.15343 = _wapi_private_handles[D.15342];
  D.15344 = idx & 255;
  D.15345 = D.15344 * 144;
  D.15346 = D.15343 + D.15345;
  D.15347 = &D.15346->signal_mutex;
  D.15332 = pthread_mutex_lock (D.15347);
  return D.15332;
}


_wapi_stat_to_file_attributes (const gchar * pathname, struct stat * buf, struct stat * lbuf)
{
  unsigned int D.15349;
  unsigned int D.15350;
  unsigned int D.15353;
  int D.15356;
  char D.15359;
  int D.15363;
  unsigned int D.15374;
  unsigned int D.15375;
  guint32 D.15378;
  guint32 attrs;
  gchar * filename;

  attrs = 0;
  D.15349 = buf->st_mode;
  D.15350 = D.15349 & 61440;
  if (D.15350 == 49152) goto <D.15351>; else goto <D.15352>;
  <D.15351>:
  D.15349 = buf->st_mode;
  D.15353 = D.15349 & 4294918143;
  buf->st_mode = D.15353;
  <D.15352>:
  filename = _wapi_basename (pathname);
  D.15349 = buf->st_mode;
  D.15350 = D.15349 & 61440;
  if (D.15350 == 16384) goto <D.15354>; else goto <D.15355>;
  <D.15354>:
  attrs = 16;
  D.15356 = is_file_writable (buf, pathname);
  if (D.15356 == 0) goto <D.15357>; else goto <D.15358>;
  <D.15357>:
  attrs = attrs | 1;
  <D.15358>:
  D.15359 = *filename;
  if (D.15359 == 46) goto <D.15360>; else goto <D.15361>;
  <D.15360>:
  attrs = attrs | 2;
  <D.15361>:
  goto <D.15362>;
  <D.15355>:
  D.15363 = is_file_writable (buf, pathname);
  if (D.15363 == 0) goto <D.15364>; else goto <D.15365>;
  <D.15364>:
  attrs = 1;
  D.15359 = *filename;
  if (D.15359 == 46) goto <D.15366>; else goto <D.15367>;
  <D.15366>:
  attrs = attrs | 2;
  <D.15367>:
  goto <D.15368>;
  <D.15365>:
  D.15359 = *filename;
  if (D.15359 == 46) goto <D.15369>; else goto <D.15370>;
  <D.15369>:
  attrs = 2;
  goto <D.15371>;
  <D.15370>:
  attrs = 128;
  <D.15371>:
  <D.15368>:
  <D.15362>:
  if (lbuf != 0B) goto <D.15372>; else goto <D.15373>;
  <D.15372>:
  D.15374 = lbuf->st_mode;
  D.15375 = D.15374 & 61440;
  if (D.15375 == 40960) goto <D.15376>; else goto <D.15377>;
  <D.15376>:
  attrs = attrs | 1024;
  <D.15377>:
  <D.15373>:
  monoeg_g_free (filename);
  D.15378 = attrs;
  return D.15378;
}


is_file_writable (struct stat * st, const char * path)
{
  unsigned int D.15380;
  unsigned int D.15381;
  gboolean D.15384;
  unsigned int D.15385;
  unsigned int D.15386;
  unsigned int D.15389;
  unsigned int D.15392;
  unsigned int D.15393;
  unsigned int D.15396;
  int D.15399;
  _Bool D.15400;

  D.15380 = st->st_mode;
  D.15381 = D.15380 & 2;
  if (D.15381 != 0) goto <D.15382>; else goto <D.15383>;
  <D.15382>:
  D.15384 = 1;
  return D.15384;
  <D.15383>:
  D.15385 = st->st_uid;
  D.15386 = geteuid ();
  if (D.15385 == D.15386) goto <D.15387>; else goto <D.15388>;
  <D.15387>:
  D.15380 = st->st_mode;
  D.15389 = D.15380 & 128;
  if (D.15389 != 0) goto <D.15390>; else goto <D.15391>;
  <D.15390>:
  D.15384 = 1;
  return D.15384;
  <D.15391>:
  <D.15388>:
  D.15392 = st->st_gid;
  D.15393 = getegid ();
  if (D.15392 == D.15393) goto <D.15394>; else goto <D.15395>;
  <D.15394>:
  D.15380 = st->st_mode;
  D.15396 = D.15380 & 16;
  if (D.15396 != 0) goto <D.15397>; else goto <D.15398>;
  <D.15397>:
  D.15384 = 1;
  return D.15384;
  <D.15398>:
  <D.15395>:
  D.15399 = access (path, 2);
  D.15400 = D.15399 == 0;
  D.15384 = (gboolean) D.15400;
  return D.15384;
}


memset (void * __dest, int __ch, size_t __len)
{
  int D.15404;
  int D.15409;
  void * D.15411;
  unsigned int D.15412;

  D.15404 = __builtin_constant_p (__len);
  if (D.15404 != 0) goto <D.15405>; else goto <D.15406>;
  <D.15405>:
  if (__len == 0) goto <D.15407>; else goto <D.15408>;
  <D.15407>:
  D.15409 = __builtin_constant_p (__ch);
  if (D.15409 == 0) goto <D.15402>; else goto <D.15410>;
  <D.15410>:
  if (__ch != 0) goto <D.15402>; else goto <D.15403>;
  <D.15402>:
  __warn_memset_zero_len ();
  D.15411 = __dest;
  return D.15411;
  <D.15403>:
  <D.15408>:
  <D.15406>:
  D.15412 = __builtin_object_size (__dest, 0);
  D.15411 = __builtin___memset_chk (__dest, __ch, __len, D.15412);
  return D.15411;
}


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

  D.15415 = __builtin_object_size (__dest, 0);
  D.15414 = __builtin___memcpy_chk (__dest, __src, __len, D.15415);
  return D.15414;
}


_wapi_handle_unlock_handle (void * handle)
{
  int D.15419;
  <unnamed type> D.15422;
  <unnamed type> D.15424;
  <unnamed type> D.15426;
  <unnamed type> D.15428;
  unsigned int D.15429;
  struct _WapiHandleUnshared * D.15430;
  unsigned int D.15431;
  unsigned int D.15432;
  struct _WapiHandleUnshared * D.15433;
  union mono_mutex_t * D.15434;
  guint32 idx;
  int ret;

  idx = (guint32) handle;
  if (idx > 4194303) goto <D.15417>; else goto <D.15418>;
  <D.15417>:
  D.15419 = 0;
  return D.15419;
  <D.15418>:
  D.15422 = _wapi_handle_type (handle);
  if (D.15422 == 9) goto <D.15420>; else goto <D.15423>;
  <D.15423>:
  D.15424 = _wapi_handle_type (handle);
  if (D.15424 == 11) goto <D.15420>; else goto <D.15425>;
  <D.15425>:
  D.15426 = _wapi_handle_type (handle);
  if (D.15426 == 12) goto <D.15420>; else goto <D.15427>;
  <D.15427>:
  D.15428 = _wapi_handle_type (handle);
  if (D.15428 == 13) goto <D.15420>; else goto <D.15421>;
  <D.15420>:
  _wapi_handle_unref (handle);
  D.15419 = 0;
  return D.15419;
  <D.15421>:
  D.15429 = idx / 256;
  D.15430 = _wapi_private_handles[D.15429];
  D.15431 = idx & 255;
  D.15432 = D.15431 * 144;
  D.15433 = D.15430 + D.15432;
  D.15434 = &D.15433->signal_mutex;
  ret = pthread_mutex_unlock (D.15434);
  _wapi_handle_unref (handle);
  D.15419 = ret;
  return D.15419;
}


FindClose (void * handle)
{
  gboolean D.15438;
  long int D.15441;
  _Bool D.15444;
  long int D.15445;
  long int D.15446;
  struct _WapiHandle_find * find_handle.46;
  gchar * * D.15450;
  gchar * D.15451;
  struct _WapiHandle_find * find_handle;
  gboolean ok;
  int thr_ret;
  static const char __func__[10] = "FindClose";

  try
    {
      if (handle == 0B) goto <D.15436>; else goto <D.15437>;
      <D.15436>:
      SetLastError (6);
      D.15438 = 0;
      return D.15438;
      <D.15437>:
      ok = _wapi_lookup_handle (handle, 8, &find_handle);
      if (ok == 0) goto <D.15439>; else goto <D.15440>;
      <D.15439>:
      monoeg_g_log (0B, 16, "%s: error looking up find handle %p", &__func__, handle);
      SetLastError (6);
      D.15438 = 0;
      return D.15438;
      <D.15440>:
      {
        struct __pthread_unwind_buf_t __cancel_buf;
        void (*<Tc1>) (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.15441 = __builtin_expect (__not_first_call, 0);
            if (D.15441 != 0) goto <D.15442>; else goto <D.15443>;
            <D.15442>:
            __cancel_routine (__cancel_arg);
            __pthread_unwind_next (&__cancel_buf);
            <D.15443>:
            __pthread_register_cancel (&__cancel_buf);
            thr_ret = _wapi_handle_lock_handle (handle);
            D.15444 = thr_ret != 0;
            D.15445 = (long int) D.15444;
            D.15446 = __builtin_expect (D.15445, 0);
            if (D.15446 != 0) goto <D.15447>; else goto <D.15448>;
            <D.15447>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "io.c", 2947, "thr_ret == 0");
            <D.15448>:
            find_handle.46 = find_handle;
            D.15450 = find_handle.46->namelist;
            monoeg_g_strfreev (D.15450);
            find_handle.46 = find_handle;
            D.15451 = find_handle.46->dir_part;
            monoeg_g_free (D.15451);
            thr_ret = _wapi_handle_unlock_handle (handle);
            D.15444 = thr_ret != 0;
            D.15445 = (long int) D.15444;
            D.15446 = __builtin_expect (D.15445, 0);
            if (D.15446 != 0) goto <D.15452>; else goto <D.15453>;
            <D.15452>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "io.c", 2953, "thr_ret == 0");
            <D.15453>:
            __pthread_unregister_cancel (&__cancel_buf);
            if (0 != 0) goto <D.15454>; else goto <D.15455>;
            <D.15454>:
            __cancel_routine (__cancel_arg);
            <D.15455>:
          }
        finally
          {
            __cancel_buf = {CLOBBER};
          }
      }
      _wapi_handle_unref (handle);
      D.15438 = 1;
      return D.15438;
    }
  finally
    {
      find_handle = {CLOBBER};
    }
}


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

  if (name == 0B) goto <D.15461>; else goto <D.15462>;
  <D.15461>:
  SetLastError (123);
  D.15463 = 0;
  return D.15463;
  <D.15462>:
  utf8_name = mono_unicode_to_external (name);
  if (utf8_name == 0B) goto <D.15464>; else goto <D.15465>;
  <D.15464>:
  SetLastError (123);
  D.15463 = 0;
  return D.15463;
  <D.15465>:
  result = _wapi_mkdir (utf8_name, 511);
  if (result == 0) goto <D.15466>; else goto <D.15467>;
  <D.15466>:
  monoeg_g_free (utf8_name);
  D.15463 = 1;
  return D.15463;
  <D.15467>:
  _wapi_set_last_path_error_from_errno (0B, utf8_name);
  monoeg_g_free (utf8_name);
  D.15463 = 0;
  return D.15463;
}


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

  if (name == 0B) goto <D.15469>; else goto <D.15470>;
  <D.15469>:
  SetLastError (123);
  D.15471 = 0;
  return D.15471;
  <D.15470>:
  utf8_name = mono_unicode_to_external (name);
  if (utf8_name == 0B) goto <D.15472>; else goto <D.15473>;
  <D.15472>:
  SetLastError (123);
  D.15471 = 0;
  return D.15471;
  <D.15473>:
  result = _wapi_rmdir (utf8_name);
  if (result == -1) goto <D.15474>; else goto <D.15475>;
  <D.15474>:
  _wapi_set_last_path_error_from_errno (0B, utf8_name);
  monoeg_g_free (utf8_name);
  D.15471 = 0;
  return D.15471;
  <D.15475>:
  monoeg_g_free (utf8_name);
  D.15471 = 1;
  return D.15471;
}


GetFileAttributes (const gunichar2 * name)
{
  guint32 D.15479;
  int * D.15484;
  int D.15485;
  gchar * utf8_name;
  struct stat buf;
  struct stat linkbuf;
  int result;
  guint32 ret;

  try
    {
      if (name == 0B) goto <D.15477>; else goto <D.15478>;
      <D.15477>:
      SetLastError (123);
      D.15479 = 0;
      return D.15479;
      <D.15478>:
      utf8_name = mono_unicode_to_external (name);
      if (utf8_name == 0B) goto <D.15480>; else goto <D.15481>;
      <D.15480>:
      SetLastError (87);
      D.15479 = 4294967295;
      return D.15479;
      <D.15481>:
      result = _wapi_stat (utf8_name, &buf);
      if (result == -1) goto <D.15482>; else goto <D.15483>;
      <D.15482>:
      D.15484 = __errno_location ();
      D.15485 = *D.15484;
      if (D.15485 == 2) goto <D.15486>; else goto <D.15487>;
      <D.15486>:
      result = _wapi_lstat (utf8_name, &buf);
      <D.15487>:
      <D.15483>:
      if (result != 0) goto <D.15488>; else goto <D.15489>;
      <D.15488>:
      _wapi_set_last_path_error_from_errno (0B, utf8_name);
      monoeg_g_free (utf8_name);
      D.15479 = 4294967295;
      return D.15479;
      <D.15489>:
      result = _wapi_lstat (utf8_name, &linkbuf);
      if (result != 0) goto <D.15490>; else goto <D.15491>;
      <D.15490>:
      _wapi_set_last_path_error_from_errno (0B, utf8_name);
      monoeg_g_free (utf8_name);
      D.15479 = 4294967295;
      return D.15479;
      <D.15491>:
      ret = _wapi_stat_to_file_attributes (utf8_name, &buf, &linkbuf);
      monoeg_g_free (utf8_name);
      D.15479 = ret;
      return D.15479;
    }
  finally
    {
      buf = {CLOBBER};
      linkbuf = {CLOBBER};
    }
}


GetFileAttributesEx (const gunichar2 * name, WapiGetFileExInfoLevels level, void * info)
{
  gboolean D.15496;
  int * D.15503;
  int D.15504;
  long int D.15511;
  long int D.15512;
  unsigned int D.15516;
  struct WapiFileTime * D.15517;
  long int D.15518;
  struct WapiFileTime * D.15519;
  struct WapiFileTime * D.15520;
  unsigned int D.15521;
  unsigned int D.15522;
  long long int D.15526;
  long long int D.15527;
  unsigned int D.15528;
  unsigned int D.15529;
  gchar * utf8_name;
  struct WapiFileAttributesData * data;
  struct stat buf;
  struct stat linkbuf;
  time_t create_time;
  int result;

  try
    {
      if (level != 0) goto <D.15494>; else goto <D.15495>;
      <D.15494>:
      SetLastError (87);
      D.15496 = 0;
      return D.15496;
      <D.15495>:
      if (name == 0B) goto <D.15497>; else goto <D.15498>;
      <D.15497>:
      SetLastError (123);
      D.15496 = 0;
      return D.15496;
      <D.15498>:
      utf8_name = mono_unicode_to_external (name);
      if (utf8_name == 0B) goto <D.15499>; else goto <D.15500>;
      <D.15499>:
      SetLastError (87);
      D.15496 = 0;
      return D.15496;
      <D.15500>:
      result = _wapi_stat (utf8_name, &buf);
      if (result == -1) goto <D.15501>; else goto <D.15502>;
      <D.15501>:
      D.15503 = __errno_location ();
      D.15504 = *D.15503;
      if (D.15504 == 2) goto <D.15505>; else goto <D.15506>;
      <D.15505>:
      result = _wapi_lstat (utf8_name, &buf);
      <D.15506>:
      <D.15502>:
      if (result != 0) goto <D.15507>; else goto <D.15508>;
      <D.15507>:
      _wapi_set_last_path_error_from_errno (0B, utf8_name);
      monoeg_g_free (utf8_name);
      D.15496 = 0;
      return D.15496;
      <D.15508>:
      result = _wapi_lstat (utf8_name, &linkbuf);
      if (result != 0) goto <D.15509>; else goto <D.15510>;
      <D.15509>:
      _wapi_set_last_path_error_from_errno (0B, utf8_name);
      monoeg_g_free (utf8_name);
      D.15496 = 0;
      return D.15496;
      <D.15510>:
      data = info;
      D.15511 = buf.st_mtim.tv_sec;
      D.15512 = buf.st_ctim.tv_sec;
      if (D.15511 < D.15512) goto <D.15513>; else goto <D.15514>;
      <D.15513>:
      create_time = buf.st_mtim.tv_sec;
      goto <D.15515>;
      <D.15514>:
      create_time = buf.st_ctim.tv_sec;
      <D.15515>:
      D.15516 = _wapi_stat_to_file_attributes (utf8_name, &buf, &linkbuf);
      data->dwFileAttributes = D.15516;
      monoeg_g_free (utf8_name);
      D.15517 = &data->ftCreationTime;
      _wapi_time_t_to_filetime (create_time, D.15517);
      D.15518 = buf.st_atim.tv_sec;
      D.15519 = &data->ftLastAccessTime;
      _wapi_time_t_to_filetime (D.15518, D.15519);
      D.15511 = buf.st_mtim.tv_sec;
      D.15520 = &data->ftLastWriteTime;
      _wapi_time_t_to_filetime (D.15511, D.15520);
      D.15521 = data->dwFileAttributes;
      D.15522 = D.15521 & 16;
      if (D.15522 != 0) goto <D.15523>; else goto <D.15524>;
      <D.15523>:
      data->nFileSizeHigh = 0;
      data->nFileSizeLow = 0;
      goto <D.15525>;
      <D.15524>:
      D.15526 = buf.st_size;
      D.15527 = D.15526 >> 32;
      D.15528 = (unsigned int) D.15527;
      data->nFileSizeHigh = D.15528;
      D.15526 = buf.st_size;
      D.15529 = (unsigned int) D.15526;
      data->nFileSizeLow = D.15529;
      <D.15525>:
      D.15496 = 1;
      return D.15496;
    }
  finally
    {
      buf = {CLOBBER};
      linkbuf = {CLOBBER};
    }
}


SetFileAttributes (const gunichar2 * name, guint32 attrs)
{
  gboolean D.15534;
  int * D.15539;
  int D.15540;
  unsigned int D.15545;
  unsigned int D.15548;
  unsigned int D.15549;
  unsigned int D.15551;
  signed int attrs.47;
  unsigned int D.15555;
  unsigned int D.15558;
  unsigned int D.15561;
  unsigned int D.15564;
  gchar * utf8_name;
  struct stat buf;
  int result;

  try
    {
      if (name == 0B) goto <D.15532>; else goto <D.15533>;
      <D.15532>:
      SetLastError (123);
      D.15534 = 0;
      return D.15534;
      <D.15533>:
      utf8_name = mono_unicode_to_external (name);
      if (utf8_name == 0B) goto <D.15535>; else goto <D.15536>;
      <D.15535>:
      SetLastError (123);
      D.15534 = 0;
      return D.15534;
      <D.15536>:
      result = _wapi_stat (utf8_name, &buf);
      if (result == -1) goto <D.15537>; else goto <D.15538>;
      <D.15537>:
      D.15539 = __errno_location ();
      D.15540 = *D.15539;
      if (D.15540 == 2) goto <D.15541>; else goto <D.15542>;
      <D.15541>:
      result = _wapi_lstat (utf8_name, &buf);
      <D.15542>:
      <D.15538>:
      if (result != 0) goto <D.15543>; else goto <D.15544>;
      <D.15543>:
      _wapi_set_last_path_error_from_errno (0B, utf8_name);
      monoeg_g_free (utf8_name);
      D.15534 = 0;
      return D.15534;
      <D.15544>:
      D.15545 = attrs & 1;
      if (D.15545 != 0) goto <D.15546>; else goto <D.15547>;
      <D.15546>:
      D.15548 = buf.st_mode;
      D.15549 = D.15548 & 4294967149;
      result = _wapi_chmod (utf8_name, D.15549);
      goto <D.15550>;
      <D.15547>:
      D.15548 = buf.st_mode;
      D.15551 = D.15548 | 128;
      result = _wapi_chmod (utf8_name, D.15551);
      <D.15550>:
      attrs.47 = (signed int) attrs;
      if (attrs.47 < 0) goto <D.15553>; else goto <D.15554>;
      <D.15553>:
      {
        mode_t exec_mask;

        exec_mask = 0;
        D.15548 = buf.st_mode;
        D.15555 = D.15548 & 256;
        if (D.15555 != 0) goto <D.15556>; else goto <D.15557>;
        <D.15556>:
        exec_mask = exec_mask | 64;
        <D.15557>:
        D.15548 = buf.st_mode;
        D.15558 = D.15548 & 32;
        if (D.15558 != 0) goto <D.15559>; else goto <D.15560>;
        <D.15559>:
        exec_mask = exec_mask | 8;
        <D.15560>:
        D.15548 = buf.st_mode;
        D.15561 = D.15548 & 4;
        if (D.15561 != 0) goto <D.15562>; else goto <D.15563>;
        <D.15562>:
        exec_mask = exec_mask | 1;
        <D.15563>:
        D.15548 = buf.st_mode;
        D.15564 = D.15548 | exec_mask;
        result = chmod (utf8_name, D.15564);
      }
      <D.15554>:
      monoeg_g_free (utf8_name);
      D.15534 = 1;
      return D.15534;
    }
  finally
    {
      buf = {CLOBBER};
    }
}


GetCurrentDirectory (guint32 length, gunichar2 * buffer)
{
  char * D.15567;
  int * D.15570;
  int D.15571;
  guint32 D.15576;
  unsigned int bytes.48;
  unsigned int D.15578;
  unsigned int D.15579;
  long unsigned int count.49;
  _Bool D.15581;
  long int D.15582;
  long int D.15583;
  unsigned int D.15586;
  gunichar2 * utf16_path;
  glong count;
  gsize bytes;

  try
    {
      D.15567 = getcwd (buffer, length);
      if (D.15567 == 0B) goto <D.15568>; else goto <D.15569>;
      <D.15568>:
      D.15570 = __errno_location ();
      D.15571 = *D.15570;
      if (D.15571 == 34) goto <D.15572>; else goto <D.15573>;
      <D.15572>:
      {
        gchar * path;

        path = monoeg_g_get_current_dir ();
        if (path == 0B) goto <D.15574>; else goto <D.15575>;
        <D.15574>:
        D.15576 = 0;
        return D.15576;
        <D.15575>:
        utf16_path = mono_unicode_from_external (path, &bytes);
        monoeg_g_free (utf16_path);
        monoeg_g_free (path);
        bytes.48 = bytes;
        D.15578 = bytes.48 / 2;
        D.15576 = D.15578 + 1;
        return D.15576;
      }
      <D.15573>:
      _wapi_set_last_error_from_errno ();
      D.15576 = 0;
      return D.15576;
      <D.15569>:
      utf16_path = mono_unicode_from_external (buffer, &bytes);
      bytes.48 = bytes;
      D.15578 = bytes.48 / 2;
      D.15579 = D.15578 + 1;
      count = (glong) D.15579;
      count.49 = (long unsigned int) count;
      D.15581 = count.49 > length;
      D.15582 = (long int) D.15581;
      D.15583 = __builtin_expect (D.15582, 0);
      if (D.15583 != 0) goto <D.15584>; else goto <D.15585>;
      <D.15584>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "io.c", 3320, "count <= length");
      <D.15585>:
      bytes.48 = bytes;
      D.15586 = bytes.48 + 2;
      memset (buffer, 0, D.15586);
      bytes.48 = bytes;
      memcpy (buffer, utf16_path, bytes.48);
      monoeg_g_free (utf16_path);
      D.15576 = (guint32) count;
      return D.15576;
    }
  finally
    {
      bytes = {CLOBBER};
    }
}


getcwd (char * __buf, size_t __size)
{
  unsigned int D.15589;
  int D.15592;
  char * D.15595;
  unsigned int D.15596;
  unsigned int D.15597;
  unsigned int D.15600;

  D.15589 = __builtin_object_size (__buf, 1);
  if (D.15589 != 4294967295) goto <D.15590>; else goto <D.15591>;
  <D.15590>:
  D.15592 = __builtin_constant_p (__size);
  if (D.15592 == 0) goto <D.15593>; else goto <D.15594>;
  <D.15593>:
  D.15596 = __builtin_object_size (__buf, 1);
  D.15595 = __getcwd_chk (__buf, __size, D.15596);
  return D.15595;
  <D.15594>:
  D.15597 = __builtin_object_size (__buf, 1);
  if (D.15597 < __size) goto <D.15598>; else goto <D.15599>;
  <D.15598>:
  D.15600 = __builtin_object_size (__buf, 1);
  D.15595 = __getcwd_chk_warn (__buf, __size, D.15600);
  return D.15595;
  <D.15599>:
  <D.15591>:
  D.15595 = __getcwd_alias (__buf, __size);
  return D.15595;
}


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

  if (path == 0B) goto <D.15602>; else goto <D.15603>;
  <D.15602>:
  SetLastError (87);
  D.15604 = 0;
  return D.15604;
  <D.15603>:
  utf8_path = mono_unicode_to_external (path);
  D.15605 = _wapi_chdir (utf8_path);
  if (D.15605 != 0) goto <D.15606>; else goto <D.15607>;
  <D.15606>:
  _wapi_set_last_error_from_errno ();
  result = 0;
  goto <D.15608>;
  <D.15607>:
  result = 1;
  <D.15608>:
  monoeg_g_free (utf8_path);
  D.15604 = result;
  return D.15604;
}


CreatePipe (void * * readpipe, void * * writepipe, struct WapiSecurityAttributes * security, guint32 size)
{
  gboolean D.15612;
  int D.15615;
  unsigned int D.15616;
  unsigned int _wapi_fd_reserve.50;
  int D.15619;
  unsigned int D.15620;
  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.15610>; else goto <D.15611>;
      <D.15610>:
      _wapi_set_last_error_from_errno ();
      D.15612 = 0;
      return D.15612;
      <D.15611>:
      D.15615 = filedes[0];
      D.15616 = (unsigned int) D.15615;
      _wapi_fd_reserve.50 = _wapi_fd_reserve;
      if (D.15616 >= _wapi_fd_reserve.50) goto <D.15613>; else goto <D.15618>;
      <D.15618>:
      D.15619 = filedes[1];
      D.15620 = (unsigned int) D.15619;
      _wapi_fd_reserve.50 = _wapi_fd_reserve;
      if (D.15620 >= _wapi_fd_reserve.50) goto <D.15613>; else goto <D.15614>;
      <D.15613>:
      SetLastError (4);
      D.15615 = filedes[0];
      close (D.15615);
      D.15619 = filedes[1];
      close (D.15619);
      D.15612 = 0;
      return D.15612;
      <D.15614>:
      D.15615 = filedes[0];
      pipe_read_handle.fd = D.15615;
      pipe_read_handle.fileaccess = 2147483648;
      D.15615 = filedes[0];
      read_handle = _wapi_handle_new_fd (10, D.15615, &pipe_read_handle);
      if (read_handle == 4294967295B) goto <D.15621>; else goto <D.15622>;
      <D.15621>:
      monoeg_g_log (0B, 16, "%s: error creating pipe read handle", &__func__);
      D.15615 = filedes[0];
      close (D.15615);
      D.15619 = filedes[1];
      close (D.15619);
      SetLastError (31);
      D.15612 = 0;
      return D.15612;
      <D.15622>:
      D.15619 = filedes[1];
      pipe_write_handle.fd = D.15619;
      pipe_write_handle.fileaccess = 1073741824;
      D.15619 = filedes[1];
      write_handle = _wapi_handle_new_fd (10, D.15619, &pipe_write_handle);
      if (write_handle == 4294967295B) goto <D.15623>; else goto <D.15624>;
      <D.15623>:
      monoeg_g_log (0B, 16, "%s: error creating pipe write handle", &__func__);
      _wapi_handle_unref (read_handle);
      D.15615 = filedes[0];
      close (D.15615);
      D.15619 = filedes[1];
      close (D.15619);
      SetLastError (31);
      D.15612 = 0;
      return D.15612;
      <D.15624>:
      *readpipe = read_handle;
      *writepipe = write_handle;
      D.15612 = 1;
      return D.15612;
    }
  finally
    {
      pipe_read_handle = {CLOBBER};
      pipe_write_handle = {CLOBBER};
      filedes = {CLOBBER};
    }
}


GetTempPath (guint32 len, gunichar2 * buf)
{
  const gchar * D.15627;
  unsigned int D.15628;
  gchar * D.15629;
  char D.15630;
  const gchar * D.15633;
  guint32 D.15636;
  unsigned int bytes.51;
  unsigned int D.15638;
  long int D.15639;
  long unsigned int D.15640;
  unsigned int D.15644;
  gchar * tmpdir;
  gunichar2 * tmpdir16;
  glong dirlen;
  gsize bytes;
  guint32 ret;

  try
    {
      D.15627 = monoeg_g_get_tmp_dir ();
      tmpdir = monoeg_strdup (D.15627);
      tmpdir16 = 0B;
      D.15628 = strlen (tmpdir);
      D.15629 = tmpdir + D.15628;
      D.15630 = *D.15629;
      if (D.15630 != 47) goto <D.15631>; else goto <D.15632>;
      <D.15631>:
      monoeg_g_free (tmpdir);
      D.15633 = monoeg_g_get_tmp_dir ();
      tmpdir = monoeg_g_strdup_printf ("%s/", D.15633);
      <D.15632>:
      tmpdir16 = mono_unicode_from_external (tmpdir, &bytes);
      if (tmpdir16 == 0B) goto <D.15634>; else goto <D.15635>;
      <D.15634>:
      monoeg_g_free (tmpdir);
      D.15636 = 0;
      return D.15636;
      <D.15635>:
      bytes.51 = bytes;
      D.15638 = bytes.51 / 2;
      dirlen = (glong) D.15638;
      D.15639 = dirlen + 1;
      D.15640 = (long unsigned int) D.15639;
      if (D.15640 > len) goto <D.15641>; else goto <D.15642>;
      <D.15641>:
      D.15639 = dirlen + 1;
      ret = (guint32) D.15639;
      goto <D.15643>;
      <D.15642>:
      bytes.51 = bytes;
      D.15644 = bytes.51 + 2;
      memset (buf, 0, D.15644);
      bytes.51 = bytes;
      memcpy (buf, tmpdir16, bytes.51);
      ret = (guint32) dirlen;
      <D.15643>:
      if (tmpdir16 != 0B) goto <D.15645>; else goto <D.15646>;
      <D.15645>:
      monoeg_g_free (tmpdir16);
      <D.15646>:
      monoeg_g_free (tmpdir);
      D.15636 = ret;
      return D.15636;
    }
  finally
    {
      bytes = {CLOBBER};
    }
}


GetLogicalDriveStrings (guint32 len, gunichar2 * buf)
{
  unsigned int D.15649;
  unsigned int D.15657;
  char D.15658;
  unsigned int D.15661;
  gchar * D.15662;
  int D.15667;
  int D.15668;
  int D.15669;
  gint32 D.15672;
  int fd;
  gint32 ret;
  struct LinuxMountInfoParseState state;
  gboolean (*<T26e7>) (guint32, gunichar2 *, struct LinuxMountInfoParseState *) parser;
  void done_and_out = <<< error >>>;

  try
    {
      ret = 0;
      parser = 0B;
      D.15649 = len * 2;
      memset (buf, 0, D.15649);
      fd = open ("/proc/self/mountinfo", 0);
      if (fd != -1) goto <D.15650>; else goto <D.15651>;
      <D.15650>:
      parser = GetLogicalDriveStrings_MountInfo;
      goto <D.15652>;
      <D.15651>:
      fd = open ("/proc/mounts", 0);
      if (fd != -1) goto <D.15653>; else goto <D.15654>;
      <D.15653>:
      parser = GetLogicalDriveStrings_Mounts;
      <D.15654>:
      <D.15652>:
      if (parser == 0B) goto <D.15655>; else goto <D.15656>;
      <D.15655>:
      ret = GetLogicalDriveStrings_Mtab (len, buf);
      goto done_and_out;
      <D.15656>:
      memset (&state, 0, 1204);
      state.field_number = 1;
      state.delimiter = 32;
      goto <D.14183>;
      <D.14182>:
      state.buffer_index = 0;
      goto <D.14180>;
      <D.14179>:
      D.15657 = state.buffer_index;
      D.15658 = state.buffer[D.15657];
      if (D.15658 == 10) goto <D.15659>; else goto <D.15660>;
      <D.15659>:
      {
        gboolean quit;

        quit = add_drive_string (len, buf, &state);
        state.field_number = 1;
        D.15657 = state.buffer_index;
        D.15661 = D.15657 + 1;
        state.buffer_index = D.15661;
        D.15662 = state.mountpoint_allocated;
        if (D.15662 != 0B) goto <D.15663>; else goto <D.15664>;
        <D.15663>:
        D.15662 = state.mountpoint_allocated;
        monoeg_g_free (D.15662);
        state.mountpoint_allocated = 0B;
        <D.15664>:
        if (quit != 0) goto <D.15665>; else goto <D.15666>;
        <D.15665>:
        ret = state.total;
        goto done_and_out;
        <D.15666>:
      }
      <D.15660>:
      <D.14180>:
      D.15667 = parser (len, buf, &state);
      if (D.15667 != 0) goto <D.14179>; else goto <D.14181>;
      <D.14181>:
      <D.14183>:
      D.15668 = read (fd, &state.buffer, 512);
      state.nbytes = D.15668;
      D.15669 = state.nbytes;
      if (D.15669 > 0) goto <D.14182>; else goto <D.14184>;
      <D.14184>:
      ret = state.total;
      done_and_out:
      if (fd != -1) goto <D.15670>; else goto <D.15671>;
      <D.15670>:
      close (fd);
      <D.15671>:
      D.15672 = ret;
      return D.15672;
    }
  finally
    {
      state = {CLOBBER};
    }
}


GetLogicalDriveStrings_Mounts (guint32 len, gunichar2 * buf, struct LinuxMountInfoParseState * state)
{
  unsigned int D.15675;
  unsigned int D.15678;
  char D.15679;
  char D.15680;
  unsigned int D.15683;
  gchar * D.15684;
  unsigned int D.15687;
  gchar * D.15688;
  gchar * D.15690;
  unsigned int D.15691;
  int ptr.52;
  gchar[512] * D.15695;
  int D.15696;
  int D.15697;
  int D.15698;
  unsigned int D.15699;
  int D.15701;
  unsigned int D.15702;
  gboolean D.15703;
  unsigned int D.15704;
  int D.15707;
  unsigned int D.15710;
  unsigned int D.15715;
  unsigned int D.15716;
  unsigned int D.15719;
  unsigned int D.15720;
  unsigned int D.15721;
  unsigned int D.15724;
  unsigned int D.15725;
  gchar * ptr;

  D.15675 = state->field_number;
  if (D.15675 == 1) goto <D.15676>; else goto <D.15677>;
  <D.15676>:
  state->check_mount_source = 1;
  <D.15677>:
  goto <D.14195>;
  <D.14200>:
  D.15678 = state->buffer_index;
  D.15679 = state->buffer[D.15678];
  D.15680 = state->delimiter;
  if (D.15679 == D.15680) goto <D.15681>; else goto <D.15682>;
  <D.15681>:
  D.15675 = state->field_number;
  D.15683 = D.15675 + 1;
  state->field_number = D.15683;
  D.15675 = state->field_number;
  switch (D.15675) <default: <D.14194>, case 2: <D.14191>, case 3: <D.14193>>
  <D.14191>:
  state->mountpoint_index = 0;
  goto <D.14192>;
  <D.14193>:
  D.15684 = state->mountpoint_allocated;
  if (D.15684 != 0B) goto <D.15685>; else goto <D.15686>;
  <D.15685>:
  D.15684 = state->mountpoint_allocated;
  D.15687 = state->mountpoint_index;
  D.15688 = D.15684 + D.15687;
  *D.15688 = 0;
  goto <D.15689>;
  <D.15686>:
  D.15687 = state->mountpoint_index;
  state->mountpoint[D.15687] = 0;
  <D.15689>:
  goto <D.14192>;
  <D.14194>:
  D.15678 = state->buffer_index;
  D.15690 = &state->buffer[D.15678];
  D.15678 = state->buffer_index;
  D.15691 = 512 - D.15678;
  ptr = memchr (D.15690, 10, D.15691);
  if (ptr != 0B) goto <D.15692>; else goto <D.15693>;
  <D.15692>:
  ptr.52 = (int) ptr;
  D.15695 = &state->buffer;
  D.15696 = (int) D.15695;
  D.15697 = ptr.52 - D.15696;
  D.15698 = D.15697 + -1;
  D.15699 = (unsigned int) D.15698;
  state->buffer_index = D.15699;
  goto <D.15700>;
  <D.15693>:
  D.15701 = state->nbytes;
  D.15702 = (unsigned int) D.15701;
  state->buffer_index = D.15702;
  <D.15700>:
  D.15703 = 1;
  return D.15703;
  <D.14192>:
  D.15678 = state->buffer_index;
  D.15704 = D.15678 + 1;
  state->buffer_index = D.15704;
  // predicted unlikely by continue predictor.
  goto <D.14195>;
  <D.15682>:
  D.15678 = state->buffer_index;
  D.15679 = state->buffer[D.15678];
  if (D.15679 == 10) goto <D.15705>; else goto <D.15706>;
  <D.15705>:
  D.15703 = 1;
  return D.15703;
  <D.15706>:
  D.15675 = state->field_number;
  switch (D.15675) <default: <D.15726>, case 1: <D.14196>, case 2: <D.14198>, case 3: <D.14199>>
  <D.14196>:
  D.15707 = state->check_mount_source;
  if (D.15707 != 0) goto <D.15708>; else goto <D.15709>;
  <D.15708>:
  D.15710 = state->fsname_index;
  if (D.15710 == 0) goto <D.15711>; else goto <D.15712>;
  <D.15711>:
  D.15678 = state->buffer_index;
  D.15679 = state->buffer[D.15678];
  if (D.15679 == 47) goto <D.15713>; else goto <D.15714>;
  <D.15713>:
  state->check_mount_source = 0;
  D.15710 = state->fsname_index;
  D.15715 = D.15710;
  D.15716 = D.15715 + 1;
  state->fsname_index = D.15716;
  state->fsname[D.15715] = 47;
  goto <D.14197>;
  <D.15714>:
  <D.15712>:
  D.15710 = state->fsname_index;
  if (D.15710 <= 63) goto <D.15717>; else goto <D.15718>;
  <D.15717>:
  D.15710 = state->fsname_index;
  D.15719 = D.15710;
  D.15720 = D.15719 + 1;
  state->fsname_index = D.15720;
  D.15678 = state->buffer_index;
  D.15679 = state->buffer[D.15678];
  state->fsname[D.15719] = D.15679;
  <D.15718>:
  <D.15709>:
  goto <D.14197>;
  <D.14198>:
  append_to_mountpoint (state);
  goto <D.14197>;
  <D.14199>:
  D.15721 = state->fstype_index;
  if (D.15721 <= 63) goto <D.15722>; else goto <D.15723>;
  <D.15722>:
  D.15721 = state->fstype_index;
  D.15724 = D.15721;
  D.15725 = D.15724 + 1;
  state->fstype_index = D.15725;
  D.15678 = state->buffer_index;
  D.15679 = state->buffer[D.15678];
  state->fstype[D.15724] = D.15679;
  <D.15723>:
  goto <D.14197>;
  <D.15726>:
  <D.14197>:
  D.15678 = state->buffer_index;
  D.15704 = D.15678 + 1;
  state->buffer_index = D.15704;
  <D.14195>:
  D.15678 = state->buffer_index;
  D.15701 = state->nbytes;
  D.15702 = (unsigned int) D.15701;
  if (D.15678 < D.15702) goto <D.14200>; else goto <D.14201>;
  <D.14201>:
  D.15703 = 0;
  return D.15703;
}


append_to_mountpoint (struct LinuxMountInfoParseState * state)
{
  unsigned int D.15728;
  gchar * D.15729;
  unsigned int D.15732;
  unsigned int D.15733;
  unsigned int D.15736;
  unsigned int D.15737;
  unsigned int D.15738;
  gchar * D.15739;
  unsigned int D.15743;
  unsigned int D.15744;
  void * D.15745;
  gchar[513] * D.15746;
  unsigned int D.15747;
  unsigned int D.15748;
  gchar * D.15749;
  unsigned int D.15751;
  unsigned int D.15752;
  gchar ch;

  D.15728 = state->buffer_index;
  ch = state->buffer[D.15728];
  D.15729 = state->mountpoint_allocated;
  if (D.15729 != 0B) goto <D.15730>; else goto <D.15731>;
  <D.15730>:
  D.15732 = state->mountpoint_index;
  D.15733 = state->allocated_size;
  if (D.15732 >= D.15733) goto <D.15734>; else goto <D.15735>;
  <D.15734>:
  {
    guint32 newsize;
    gchar * newbuf;

    D.15733 = state->allocated_size;
    D.15736 = D.15733 << 1;
    newsize = D.15736 + 1;
    newbuf = monoeg_malloc0 (newsize);
    D.15729 = state->mountpoint_allocated;
    D.15732 = state->mountpoint_index;
    memcpy (newbuf, D.15729, D.15732);
    D.15729 = state->mountpoint_allocated;
    monoeg_g_free (D.15729);
    state->mountpoint_allocated = newbuf;
    state->allocated_size = newsize;
  }
  <D.15735>:
  D.15729 = state->mountpoint_allocated;
  D.15732 = state->mountpoint_index;
  D.15737 = D.15732;
  D.15738 = D.15737 + 1;
  state->mountpoint_index = D.15738;
  D.15739 = D.15729 + D.15737;
  *D.15739 = ch;
  goto <D.15740>;
  <D.15731>:
  D.15732 = state->mountpoint_index;
  if (D.15732 > 511) goto <D.15741>; else goto <D.15742>;
  <D.15741>:
  D.15732 = state->mountpoint_index;
  D.15743 = D.15732 << 1;
  D.15744 = D.15743 + 1;
  state->allocated_size = D.15744;
  D.15733 = state->allocated_size;
  D.15745 = monoeg_malloc0 (D.15733);
  state->mountpoint_allocated = D.15745;
  D.15729 = state->mountpoint_allocated;
  D.15746 = &state->mountpoint;
  D.15732 = state->mountpoint_index;
  memcpy (D.15729, D.15746, D.15732);
  D.15729 = state->mountpoint_allocated;
  D.15732 = state->mountpoint_index;
  D.15747 = D.15732;
  D.15748 = D.15747 + 1;
  state->mountpoint_index = D.15748;
  D.15749 = D.15729 + D.15747;
  *D.15749 = ch;
  goto <D.15750>;
  <D.15742>:
  D.15732 = state->mountpoint_index;
  D.15751 = D.15732;
  D.15752 = D.15751 + 1;
  state->mountpoint_index = D.15752;
  state->mountpoint[D.15751] = ch;
  <D.15750>:
  <D.15740>:
}


GetLogicalDriveStrings_MountInfo (guint32 len, gunichar2 * buf, struct LinuxMountInfoParseState * state)
{
  unsigned int D.15753;
  char D.15754;
  char D.15755;
  unsigned int D.15758;
  unsigned int D.15759;
  gchar * D.15760;
  unsigned int D.15763;
  gchar * D.15764;
  unsigned int D.15767;
  gboolean D.15770;
  unsigned int D.15771;
  unsigned int D.15774;
  unsigned int D.15775;
  int D.15776;
  unsigned int D.15779;
  unsigned int D.15784;
  unsigned int D.15785;
  unsigned int D.15788;
  unsigned int D.15789;
  int D.15791;
  unsigned int D.15792;

  goto <D.14213>;
  <D.14218>:
  D.15753 = state->buffer_index;
  D.15754 = state->buffer[D.15753];
  D.15755 = state->delimiter;
  if (D.15754 == D.15755) goto <D.15756>; else goto <D.15757>;
  <D.15756>:
  D.15758 = state->field_number;
  D.15759 = D.15758 + 1;
  state->field_number = D.15759;
  D.15758 = state->field_number;
  switch (D.15758) <default: <D.15766>, case 5: <D.14207>, case 6: <D.14209>, case 7: <D.14210>, case 8: <D.14211>, case 10: <D.14212>>
  <D.14207>:
  state->mountpoint_index = 0;
  goto <D.14208>;
  <D.14209>:
  D.15760 = state->mountpoint_allocated;
  if (D.15760 != 0B) goto <D.15761>; else goto <D.15762>;
  <D.15761>:
  D.15760 = state->mountpoint_allocated;
  D.15763 = state->mountpoint_index;
  D.15764 = D.15760 + D.15763;
  *D.15764 = 0;
  goto <D.15765>;
  <D.15762>:
  D.15763 = state->mountpoint_index;
  state->mountpoint[D.15763] = 0;
  <D.15765>:
  goto <D.14208>;
  <D.14210>:
  state->delimiter = 45;
  goto <D.14208>;
  <D.14211>:
  state->delimiter = 32;
  goto <D.14208>;
  <D.14212>:
  state->check_mount_source = 1;
  goto <D.14208>;
  <D.15766>:
  <D.14208>:
  D.15753 = state->buffer_index;
  D.15767 = D.15753 + 1;
  state->buffer_index = D.15767;
  // predicted unlikely by continue predictor.
  goto <D.14213>;
  <D.15757>:
  D.15753 = state->buffer_index;
  D.15754 = state->buffer[D.15753];
  if (D.15754 == 10) goto <D.15768>; else goto <D.15769>;
  <D.15768>:
  D.15770 = 1;
  return D.15770;
  <D.15769>:
  D.15758 = state->field_number;
  switch (D.15758) <default: <D.15790>, case 5: <D.14214>, case 9: <D.14216>, case 10: <D.14217>>
  <D.14214>:
  append_to_mountpoint (state);
  goto <D.14215>;
  <D.14216>:
  D.15771 = state->fstype_index;
  if (D.15771 <= 63) goto <D.15772>; else goto <D.15773>;
  <D.15772>:
  D.15771 = state->fstype_index;
  D.15774 = D.15771;
  D.15775 = D.15774 + 1;
  state->fstype_index = D.15775;
  D.15753 = state->buffer_index;
  D.15754 = state->buffer[D.15753];
  state->fstype[D.15774] = D.15754;
  <D.15773>:
  goto <D.14215>;
  <D.14217>:
  D.15776 = state->check_mount_source;
  if (D.15776 != 0) goto <D.15777>; else goto <D.15778>;
  <D.15777>:
  D.15779 = state->fsname_index;
  if (D.15779 == 0) goto <D.15780>; else goto <D.15781>;
  <D.15780>:
  D.15753 = state->buffer_index;
  D.15754 = state->buffer[D.15753];
  if (D.15754 == 47) goto <D.15782>; else goto <D.15783>;
  <D.15782>:
  state->check_mount_source = 0;
  D.15779 = state->fsname_index;
  D.15784 = D.15779;
  D.15785 = D.15784 + 1;
  state->fsname_index = D.15785;
  state->fsname[D.15784] = 47;
  goto <D.14215>;
  <D.15783>:
  <D.15781>:
  D.15779 = state->fsname_index;
  if (D.15779 <= 63) goto <D.15786>; else goto <D.15787>;
  <D.15786>:
  D.15779 = state->fsname_index;
  D.15788 = D.15779;
  D.15789 = D.15788 + 1;
  state->fsname_index = D.15789;
  D.15753 = state->buffer_index;
  D.15754 = state->buffer[D.15753];
  state->fsname[D.15788] = D.15754;
  <D.15787>:
  <D.15778>:
  goto <D.14215>;
  <D.15790>:
  <D.14215>:
  D.15753 = state->buffer_index;
  D.15767 = D.15753 + 1;
  state->buffer_index = D.15767;
  <D.14213>:
  D.15753 = state->buffer_index;
  D.15791 = state->nbytes;
  D.15792 = (unsigned int) D.15791;
  if (D.15753 < D.15792) goto <D.14218>; else goto <D.14219>;
  <D.14219>:
  D.15770 = 0;
  return D.15770;
}


open (const char * __path, int __oflag)
{
  int D.15794;
  int D.15797;
  int D.15802;
  int D.15804;
  int D.15805;
  int D.15808;
  int D.15809;

  D.15794 = __builtin_va_arg_pack_len ();
  if (D.15794 > 1) goto <D.15795>; else goto <D.15796>;
  <D.15795>:
  __open_too_many_args ();
  <D.15796>:
  D.15797 = __builtin_constant_p (__oflag);
  if (D.15797 != 0) goto <D.15798>; else goto <D.15799>;
  <D.15798>:
  D.15802 = __oflag & 64;
  if (D.15802 != 0) goto <D.15800>; else goto <D.15803>;
  <D.15803>:
  D.15804 = __oflag & 4210688;
  if (D.15804 == 4210688) goto <D.15800>; else goto <D.15801>;
  <D.15800>:
  D.15805 = __builtin_va_arg_pack_len ();
  if (D.15805 <= 0) goto <D.15806>; else goto <D.15807>;
  <D.15806>:
  __open_missing_mode ();
  D.15808 = __open_2 (__path, __oflag);
  return D.15808;
  <D.15807>:
  <D.15801>:
  D.15808 = __open_alias (__path, __oflag, __builtin_va_arg_pack ());
  return D.15808;
  <D.15799>:
  D.15809 = __builtin_va_arg_pack_len ();
  if (D.15809 <= 0) goto <D.15810>; else goto <D.15811>;
  <D.15810>:
  D.15808 = __open_2 (__path, __oflag);
  return D.15808;
  <D.15811>:
  D.15808 = __open_alias (__path, __oflag, __builtin_va_arg_pack ());
  return D.15808;
}


GetLogicalDriveStrings_Mtab (guint32 len, gunichar2 * buf)
{
  unsigned int D.15813;
  unsigned int D.15814;
  gunichar2 * D.15815;
  gunichar2 * D.15816;
  gint32 D.15821;
  char D.15822;
  gchar * D.15827;
  gchar * * D.15829;
  gchar * D.15830;
  long int length.53;
  long int D.15832;
  long int D.15833;
  long unsigned int D.15834;
  unsigned int D.15837;
  unsigned int total.54;
  unsigned int D.15839;
  gunichar2 * D.15840;
  long unsigned int length.55;
  long unsigned int D.15842;
  long int D.15843;
  char * D.15844;
  struct FILE * fp;
  gunichar2 * ptr;
  gunichar2 * dir;
  glong length;
  glong total;
  gchar buffer[512];
  gchar * * splitted;

  try
    {
      total = 0;
      D.15813 = len + 1;
      D.15814 = D.15813 * 2;
      memset (buf, 0, D.15814);
      *buf = 47;
      D.15815 = buf + 2;
      *D.15815 = 0;
      D.15816 = buf + 4;
      *D.15816 = 0;
      fp = fopen ("/etc/mtab", "rt");
      if (fp == 0B) goto <D.15817>; else goto <D.15818>;
      <D.15817>:
      fp = fopen ("/etc/mnttab", "rt");
      if (fp == 0B) goto <D.15819>; else goto <D.15820>;
      <D.15819>:
      D.15821 = 1;
      return D.15821;
      <D.15820>:
      <D.15818>:
      ptr = buf;
      goto <D.14247>;
      <D.14248>:
      D.15822 = buffer[0];
      if (D.15822 != 47) goto <D.15823>; else goto <D.15824>;
      <D.15823>:
      // predicted unlikely by continue predictor.
      goto <D.14247>;
      <D.15824>:
      splitted = monoeg_g_strsplit (&buffer, " ", 0);
      D.15827 = *splitted;
      if (D.15827 == 0B) goto <D.15825>; else goto <D.15828>;
      <D.15828>:
      D.15829 = splitted + 4;
      D.15830 = *D.15829;
      if (D.15830 == 0B) goto <D.15825>; else goto <D.15826>;
      <D.15825>:
      monoeg_g_strfreev (splitted);
      // predicted unlikely by continue predictor.
      goto <D.14247>;
      <D.15826>:
      D.15829 = splitted + 4;
      D.15830 = *D.15829;
      unescape_octal (D.15830);
      D.15829 = splitted + 4;
      D.15830 = *D.15829;
      dir = monoeg_g_utf8_to_utf16 (D.15830, -1, 0B, &length, 0B);
      monoeg_g_strfreev (splitted);
      length.53 = length;
      D.15832 = total + length.53;
      D.15833 = D.15832 + 1;
      D.15834 = (long unsigned int) D.15833;
      if (D.15834 > len) goto <D.15835>; else goto <D.15836>;
      <D.15835>:
      fclose (fp);
      monoeg_g_free (dir);
      D.15837 = len * 2;
      D.15821 = (gint32) D.15837;
      return D.15821;
      <D.15836>:
      total.54 = (unsigned int) total;
      D.15839 = total.54 * 2;
      D.15840 = ptr + D.15839;
      length.53 = length;
      length.55 = (long unsigned int) length.53;
      D.15842 = length.55 * 2;
      memcpy (D.15840, dir, D.15842);
      monoeg_g_free (dir);
      length.53 = length;
      D.15843 = length.53 + 1;
      total = D.15843 + total;
      <D.14247>:
      D.15844 = fgets (&buffer, 512, fp);
      if (D.15844 != 0B) goto <D.14248>; else goto <D.14249>;
      <D.14249>:
      fclose (fp);
      D.15821 = total;
      return D.15821;
    }
  finally
    {
      length = {CLOBBER};
      buffer = {CLOBBER};
    }
}


unescape_octal (gchar * str)
{
  char D.15849;
  gchar * rptr.56;
  char D.15853;
  char D.15854;
  gchar * rptr.57;
  char D.15856;
  int D.15857;
  int D.15858;
  int D.15859;
  char D.15860;
  gchar * rptr.58;
  char D.15862;
  int D.15863;
  int D.15864;
  char D.15865;
  gchar * wptr.59;
  gchar * wptr.60;
  gchar * rptr.61;
  char D.15872;
  gchar * rptr;
  gchar * wptr;

  if (str == 0B) goto <D.15847>; else goto <D.15848>;
  <D.15847>:
  return;
  <D.15848>:
  wptr = str;
  rptr = wptr;
  goto <D.14130>;
  <D.14129>:
  D.15849 = *rptr;
  if (D.15849 == 92) goto <D.15850>; else goto <D.15851>;
  <D.15850>:
  {
    char c;

    rptr = rptr + 1;
    rptr.56 = rptr;
    rptr = rptr.56 + 1;
    D.15853 = *rptr.56;
    D.15854 = D.15853 + 208;
    c = D.15854 << 6;
    rptr.57 = rptr;
    rptr = rptr.57 + 1;
    D.15856 = *rptr.57;
    D.15857 = (int) D.15856;
    D.15858 = D.15857 + -48;
    D.15859 = D.15858 << 3;
    D.15860 = (char) D.15859;
    c = D.15860 + c;
    rptr.58 = rptr;
    rptr = rptr.58 + 1;
    D.15862 = *rptr.58;
    D.15863 = (int) D.15862;
    D.15864 = D.15863 + -48;
    D.15865 = (char) D.15864;
    c = D.15865 + c;
    wptr.59 = wptr;
    wptr = wptr.59 + 1;
    *wptr.59 = c;
  }
  goto <D.15867>;
  <D.15851>:
  if (wptr != rptr) goto <D.15868>; else goto <D.15869>;
  <D.15868>:
  wptr.60 = wptr;
  wptr = wptr.60 + 1;
  rptr.61 = rptr;
  rptr = rptr.61 + 1;
  D.15872 = *rptr.61;
  *wptr.60 = D.15872;
  goto <D.15873>;
  <D.15869>:
  rptr = rptr + 1;
  wptr = wptr + 1;
  <D.15873>:
  <D.15867>:
  <D.14130>:
  D.15849 = *rptr;
  if (D.15849 != 0) goto <D.14129>; else goto <D.14131>;
  <D.14131>:
  *wptr = 0;
}


fgets (char * restrict __s, int __n, struct FILE * restrict __stream)
{
  unsigned int D.15875;
  int D.15880;
  char * D.15882;
  unsigned int D.15883;
  unsigned int __n.62;
  unsigned int D.15885;
  unsigned int D.15888;

  D.15875 = __builtin_object_size (__s, 1);
  if (D.15875 != 4294967295) goto <D.15876>; else goto <D.15877>;
  <D.15876>:
  D.15880 = __builtin_constant_p (__n);
  if (D.15880 == 0) goto <D.15878>; else goto <D.15881>;
  <D.15881>:
  if (__n <= 0) goto <D.15878>; else goto <D.15879>;
  <D.15878>:
  D.15883 = __builtin_object_size (__s, 1);
  D.15882 = __fgets_chk (__s, D.15883, __n, __stream);
  return D.15882;
  <D.15879>:
  __n.62 = (unsigned int) __n;
  D.15885 = __builtin_object_size (__s, 1);
  if (__n.62 > D.15885) goto <D.15886>; else goto <D.15887>;
  <D.15886>:
  D.15888 = __builtin_object_size (__s, 1);
  D.15882 = __fgets_chk_warn (__s, D.15888, __n, __stream);
  return D.15882;
  <D.15887>:
  <D.15877>:
  D.15882 = __fgets_alias (__s, __n, __stream);
  return D.15882;
}


add_drive_string (guint32 len, gunichar2 * buf, struct LinuxMountInfoParseState * state)
{
  unsigned int D.15892;
  char D.15894;
  gchar[65] * D.15900;
  int D.15901;
  unsigned int D.15904;
  gchar[65] * D.15906;
  int D.15907;
  int D.15912;
  gchar * iftmp.63;
  gchar * D.15917;
  long int D.15921;
  long int length.64;
  long int D.15923;
  long int D.15924;
  long unsigned int D.15925;
  unsigned int D.15928;
  long int D.15929;
  long int length.65;
  unsigned int D.15932;
  unsigned int D.15933;
  gunichar2 * D.15934;
  long unsigned int length.66;
  long unsigned int D.15936;
  gboolean D.15937;
  gboolean quit;
  gboolean ignore_entry;

  quit = 0;
  D.15892 = state->fsname_index;
  if (D.15892 == 1) goto <D.15893>; else goto <D.15890>;
  <D.15893>:
  D.15894 = state->fsname[0];
  if (D.15894 == 47) goto <D.15895>; else goto <D.15890>;
  <D.15895>:
  ignore_entry = 0;
  goto <D.15891>;
  <D.15890>:
  D.15892 = state->fsname_index;
  if (D.15892 == 0) goto <D.15896>; else goto <D.15899>;
  <D.15899>:
  D.15900 = &state->fsname;
  D.15892 = state->fsname_index;
  D.15901 = memcmp ("none", D.15900, D.15892);
  if (D.15901 == 0) goto <D.15896>; else goto <D.15897>;
  <D.15896>:
  ignore_entry = 1;
  goto <D.15898>;
  <D.15897>:
  D.15904 = state->fstype_index;
  if (D.15904 > 4) goto <D.15905>; else goto <D.15902>;
  <D.15905>:
  D.15906 = &state->fstype;
  D.15907 = memcmp ("fuse.", D.15906, 5);
  if (D.15907 == 0) goto <D.15908>; else goto <D.15902>;
  <D.15908>:
  D.15904 = state->fstype_index;
  if (D.15904 == 21) goto <D.15911>; else goto <D.15909>;
  <D.15911>:
  D.15906 = &state->fstype;
  D.15904 = state->fstype_index;
  D.15912 = memcmp ("fuse.gvfs-fuse-daemon", D.15906, D.15904);
  if (D.15912 == 0) goto <D.15913>; else goto <D.15909>;
  <D.15913>:
  ignore_entry = 1;
  goto <D.15910>;
  <D.15909>:
  ignore_entry = 0;
  <D.15910>:
  goto <D.15903>;
  <D.15902>:
  ignore_entry = 1;
  <D.15903>:
  <D.15898>:
  <D.15891>:
  if (ignore_entry == 0) goto <D.15914>; else goto <D.15915>;
  <D.15914>:
  {
    gunichar2 * dir;
    glong length;
    gchar * mountpoint;

    try
      {
        D.15917 = state->mountpoint_allocated;
        if (D.15917 != 0B) goto <D.15918>; else goto <D.15919>;
        <D.15918>:
        iftmp.63 = state->mountpoint_allocated;
        goto <D.15920>;
        <D.15919>:
        iftmp.63 = &state->mountpoint;
        <D.15920>:
        mountpoint = iftmp.63;
        unescape_octal (mountpoint);
        dir = monoeg_g_utf8_to_utf16 (mountpoint, -1, 0B, &length, 0B);
        D.15921 = state->total;
        length.64 = length;
        D.15923 = D.15921 + length.64;
        D.15924 = D.15923 + 1;
        D.15925 = (long unsigned int) D.15924;
        if (D.15925 > len) goto <D.15926>; else goto <D.15927>;
        <D.15926>:
        quit = 1;
        D.15928 = len * 2;
        D.15929 = (long int) D.15928;
        state->total = D.15929;
        goto <D.15930>;
        <D.15927>:
        length.64 = length;
        length.65 = length.64 + 1;
        length = length.65;
        D.15921 = state->total;
        D.15932 = (unsigned int) D.15921;
        D.15933 = D.15932 * 2;
        D.15934 = buf + D.15933;
        length.64 = length;
        length.66 = (long unsigned int) length.64;
        D.15936 = length.66 * 2;
        memcpy (D.15934, dir, D.15936);
        D.15921 = state->total;
        length.64 = length;
        D.15923 = D.15921 + length.64;
        state->total = D.15923;
        <D.15930>:
        monoeg_g_free (dir);
      }
    finally
      {
        length = {CLOBBER};
      }
  }
  <D.15915>:
  state->fsname_index = 0;
  state->fstype_index = 0;
  D.15937 = quit;
  return D.15937;
}


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.15941;
  gboolean D.15944;
  long unsigned int D.15948;
  long unsigned int D.15949;
  _Bool D.15950;
  int * D.15952;
  int D.15953;
  long long unsigned int D.15961;
  long long unsigned int D.15962;
  long long unsigned int D.15963;
  long long unsigned int D.15966;
  long long unsigned int D.15967;
  long long unsigned int D.15973;
  long long unsigned int D.15974;
  struct statvfs fsstat;
  gboolean isreadonly;
  gchar * utf8_path_name;
  int ret;
  long unsigned int block_size;

  try
    {
      if (path_name == 0B) goto <D.15939>; else goto <D.15940>;
      <D.15939>:
      D.15941 = monoeg_g_get_current_dir ();
      utf8_path_name = monoeg_strdup (D.15941);
      if (utf8_path_name == 0B) goto <D.15942>; else goto <D.15943>;
      <D.15942>:
      SetLastError (267);
      D.15944 = 0;
      return D.15944;
      <D.15943>:
      goto <D.15945>;
      <D.15940>:
      utf8_path_name = mono_unicode_to_external (path_name);
      if (utf8_path_name == 0B) goto <D.15946>; else goto <D.15947>;
      <D.15946>:
      SetLastError (123);
      D.15944 = 0;
      return D.15944;
      <D.15947>:
      <D.15945>:
      <D.14261>:
      ret = statvfs (utf8_path_name, &fsstat);
      D.15948 = fsstat.f_flag;
      D.15949 = D.15948 & 1;
      D.15950 = D.15949 != 0;
      isreadonly = (gboolean) D.15950;
      block_size = fsstat.f_frsize;
      if (ret == -1) goto <D.15951>; else goto <D.14262>;
      <D.15951>:
      D.15952 = __errno_location ();
      D.15953 = *D.15952;
      if (D.15953 == 4) goto <D.14261>; else goto <D.14262>;
      <D.14262>:
      monoeg_g_free (utf8_path_name);
      if (ret == -1) goto <D.15954>; else goto <D.15955>;
      <D.15954>:
      _wapi_set_last_error_from_errno ();
      D.15944 = 0;
      return D.15944;
      <D.15955>:
      if (free_bytes_avail != 0B) goto <D.15956>; else goto <D.15957>;
      <D.15956>:
      if (isreadonly != 0) goto <D.15958>; else goto <D.15959>;
      <D.15958>:
      free_bytes_avail->QuadPart = 0;
      goto <D.15960>;
      <D.15959>:
      D.15961 = (long long unsigned int) block_size;
      D.15962 = fsstat.f_bavail;
      D.15963 = D.15961 * D.15962;
      free_bytes_avail->QuadPart = D.15963;
      <D.15960>:
      <D.15957>:
      if (total_number_of_bytes != 0B) goto <D.15964>; else goto <D.15965>;
      <D.15964>:
      D.15961 = (long long unsigned int) block_size;
      D.15966 = fsstat.f_blocks;
      D.15967 = D.15961 * D.15966;
      total_number_of_bytes->QuadPart = D.15967;
      <D.15965>:
      if (total_number_of_free_bytes != 0B) goto <D.15968>; else goto <D.15969>;
      <D.15968>:
      if (isreadonly != 0) goto <D.15970>; else goto <D.15971>;
      <D.15970>:
      total_number_of_free_bytes->QuadPart = 0;
      goto <D.15972>;
      <D.15971>:
      D.15961 = (long long unsigned int) block_size;
      D.15973 = fsstat.f_bfree;
      D.15974 = D.15961 * D.15973;
      total_number_of_free_bytes->QuadPart = D.15974;
      <D.15972>:
      <D.15969>:
      D.15944 = 1;
      return D.15944;
    }
  finally
    {
      fsstat = {CLOBBER};
    }
}


GetDriveType (const gunichar2 * root_path_name)
{
  gchar * D.15979;
  guint32 D.15982;
  int D.15986;
  gchar * D.15989;
  char D.15990;
  unsigned int D.15993;
  sizetype D.15994;
  gchar * D.15995;
  gchar * utf8_root_path_name;
  guint32 drive_type;

  if (root_path_name == 0B) goto <D.15977>; else goto <D.15978>;
  <D.15977>:
  D.15979 = monoeg_g_get_current_dir ();
  utf8_root_path_name = monoeg_strdup (D.15979);
  if (utf8_root_path_name == 0B) goto <D.15980>; else goto <D.15981>;
  <D.15980>:
  D.15982 = 1;
  return D.15982;
  <D.15981>:
  goto <D.15983>;
  <D.15978>:
  utf8_root_path_name = mono_unicode_to_external (root_path_name);
  if (utf8_root_path_name == 0B) goto <D.15984>; else goto <D.15985>;
  <D.15984>:
  D.15982 = 1;
  return D.15982;
  <D.15985>:
  D.15986 = monoeg_g_str_has_suffix (utf8_root_path_name, "/");
  if (D.15986 != 0) goto <D.15987>; else goto <D.15988>;
  <D.15987>:
  D.15989 = utf8_root_path_name + 1;
  D.15990 = *D.15989;
  if (D.15990 != 0) goto <D.15991>; else goto <D.15992>;
  <D.15991>:
  D.15993 = strlen (utf8_root_path_name);
  D.15994 = D.15993 + 4294967295;
  D.15995 = utf8_root_path_name + D.15994;
  *D.15995 = 0;
  <D.15992>:
  <D.15988>:
  <D.15983>:
  drive_type = GetDriveTypeFromPath (utf8_root_path_name);
  monoeg_g_free (utf8_root_path_name);
  D.15982 = drive_type;
  return D.15982;
}


GetDriveTypeFromPath (const char * utf8_root_path_name)
{
  int D.15997;
  guint32 D.16000;
  int D.16001;
  struct statfs buf;

  try
    {
      D.15997 = statfs (utf8_root_path_name, &buf);
      if (D.15997 == -1) goto <D.15998>; else goto <D.15999>;
      <D.15998>:
      D.16000 = 0;
      return D.16000;
      <D.15999>:
      D.16001 = buf.f_type;
      D.16000 = _wapi_get_drive_type (D.16001);
      return D.16000;
    }
  finally
    {
      buf = {CLOBBER};
    }
}


_wapi_get_drive_type (long int f_type)
{
  long int D.16004;
  guint32 D.16007;
  unsigned int D.16008;
  struct _wapi_drive_type * current;

  current = &_wapi_drive_types[0];
  goto <D.14274>;
  <D.14273>:
  D.16004 = current->fstypeid;
  if (D.16004 == f_type) goto <D.16005>; else goto <D.16006>;
  <D.16005>:
  D.16007 = current->drive_type;
  return D.16007;
  <D.16006>:
  current = current + 12;
  <D.14274>:
  D.16008 = current->drive_type;
  if (D.16008 != 0) goto <D.14273>; else goto <D.14275>;
  <D.14275>:
  D.16007 = 0;
  return D.16007;
}


GetVolumeInformation (const gunichar2 * path, gunichar2 * volumename, int volumesize, int * outserial, int * maxcomp, int * fsflags, gunichar2 * fsbuffer, int fsbuffersize)
{
  gboolean D.16012;
  long int len.67;
  long unsigned int len.68;
  long unsigned int D.16021;
  unsigned int len.69;
  unsigned int D.16023;
  gunichar2 * D.16024;
  gchar * utfpath;
  gchar * fstypename;
  gboolean status;
  glong len;

  try
    {
      status = 0;
      if (fsbuffer == 0B) goto <D.16010>; else goto <D.16011>;
      <D.16010>:
      D.16012 = 0;
      return D.16012;
      <D.16011>:
      utfpath = mono_unicode_to_external (path);
      fstypename = get_fstypename (utfpath);
      if (fstypename != 0B) goto <D.16013>; else goto <D.16014>;
      <D.16013>:
      {
        gunichar2 * ret;

        ret = monoeg_g_utf8_to_utf16 (fstypename, -1, 0B, &len, 0B);
        if (ret != 0B) goto <D.16015>; else goto <D.16016>;
        <D.16015>:
        len.67 = len;
        if (len.67 < fsbuffersize) goto <D.16018>; else goto <D.16019>;
        <D.16018>:
        len.67 = len;
        len.68 = (long unsigned int) len.67;
        D.16021 = len.68 * 2;
        memcpy (fsbuffer, ret, D.16021);
        len.67 = len;
        len.69 = (unsigned int) len.67;
        D.16023 = len.69 * 2;
        D.16024 = fsbuffer + D.16023;
        *D.16024 = 0;
        status = 1;
        <D.16019>:
        <D.16016>:
        if (ret != 0B) goto <D.16025>; else goto <D.16026>;
        <D.16025>:
        monoeg_g_free (ret);
        <D.16026>:
        monoeg_g_free (fstypename);
      }
      <D.16014>:
      monoeg_g_free (utfpath);
      D.16012 = status;
      return D.16012;
    }
  finally
    {
      len = {CLOBBER};
    }
}


get_fstypename (gchar * utfpath)
{
  int D.16029;
  gchar * D.16032;
  int D.16033;
  long int D.16034;
  const gchar * D.16037;
  unsigned int D.16038;
  struct statfs stat;
  struct _wapi_drive_type * current;

  try
    {
      D.16029 = statfs (utfpath, &stat);
      if (D.16029 == -1) goto <D.16030>; else goto <D.16031>;
      <D.16030>:
      D.16032 = 0B;
      return D.16032;
      <D.16031>:
      current = &_wapi_drive_types[0];
      goto <D.14291>;
      <D.14290>:
      D.16033 = stat.f_type;
      D.16034 = current->fstypeid;
      if (D.16033 == D.16034) goto <D.16035>; else goto <D.16036>;
      <D.16035>:
      D.16037 = current->fstype;
      D.16032 = monoeg_strdup (D.16037);
      return D.16032;
      <D.16036>:
      current = current + 12;
      <D.14291>:
      D.16038 = current->drive_type;
      if (D.16038 != 0) goto <D.14290>; else goto <D.14292>;
      <D.14292>:
      D.16032 = 0B;
      return D.16032;
    }
  finally
    {
      stat = {CLOBBER};
    }
}


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


