ves_icall_System_IO_MonoIO_CreateDirectory (struct MonoString * path, gint32 * error)
{
  mono_unichar2 * D.17363;
  unsigned int D.17366;
  int D.17367;
  MonoBoolean D.17368;
  gboolean ret;

  *error = 0;
  D.17363 = mono_string_chars (path);
  ret = CreateDirectory (D.17363, 0B);
  if (ret == 0) goto <D.17364>; else goto <D.17365>;
  <D.17364>:
  D.17366 = GetLastError ();
  D.17367 = (int) D.17366;
  *error = D.17367;
  <D.17365>:
  D.17368 = (MonoBoolean) ret;
  return D.17368;
}


ves_icall_System_IO_MonoIO_RemoveDirectory (struct MonoString * path, gint32 * error)
{
  mono_unichar2 * D.17370;
  unsigned int D.17373;
  int D.17374;
  MonoBoolean D.17375;
  gboolean ret;

  *error = 0;
  D.17370 = mono_string_chars (path);
  ret = RemoveDirectory (D.17370);
  if (ret == 0) goto <D.17371>; else goto <D.17372>;
  <D.17371>:
  D.17373 = GetLastError ();
  D.17374 = (int) D.17373;
  *error = D.17374;
  <D.17372>:
  D.17375 = (MonoBoolean) ret;
  return D.17375;
}


ves_icall_System_IO_MonoIO_GetFileSystemEntries (struct MonoString * path, struct MonoString * path_with_pattern, gint attrs, gint mask, gint32 * error)
{
  unsigned int D.17377;
  mono_unichar2 * D.17378;
  unsigned int D.17379;
  int D.17382;
  unsigned int D.17386;
  int D.17387;
  mono_unichar2 * D.17388;
  unsigned int D.17391;
  unsigned int D.17396;
  unsigned int D.17397;
  short unsigned int D.17400;
  unsigned int D.17401;
  unsigned int mask.0;
  unsigned int D.17403;
  unsigned int attrs.1;
  int D.17409;
  int D.17410;
  unsigned int D.17413;
  int D.17414;
  struct MonoClass * D.17416;
  unsigned int D.17417;
  unsigned int i.2;
  void * * D.17419;
  unsigned int i.3;
  unsigned int D.17421;
  void * * D.17422;
  void * D.17423;
  struct MonoString * D.17424;
  unsigned int i.4;
  int D.17428;
  struct MonoArray * D.17431;
  struct MonoDomain * domain;
  struct MonoArray * result;
  int i;
  struct WIN32_FIND_DATA data;
  void * find_handle;
  struct GPtrArray * names;
  gchar * utf8_path;
  gchar * utf8_result;
  gchar * full_name;
  gint32 attributes;
  void leave = <<< error >>>;

  try
    {
      result = 0B;
      *error = 0;
      domain = mono_domain_get ();
      D.17377 = convert_attrs (mask);
      mask = (gint) D.17377;
      D.17378 = mono_string_chars (path);
      D.17379 = get_file_attributes (D.17378);
      attributes = (gint32) D.17379;
      if (attributes != -1) goto <D.17380>; else goto <D.17381>;
      <D.17380>:
      D.17382 = attributes & 16;
      if (D.17382 == 0) goto <D.17383>; else goto <D.17384>;
      <D.17383>:
      *error = 123;
      goto leave;
      <D.17384>:
      goto <D.17385>;
      <D.17381>:
      D.17386 = GetLastError ();
      D.17387 = (int) D.17386;
      *error = D.17387;
      goto leave;
      <D.17385>:
      D.17388 = mono_string_chars (path_with_pattern);
      find_handle = FindFirstFile (D.17388, &data);
      if (find_handle == 4294967295B) goto <D.17389>; else goto <D.17390>;
      <D.17389>:
      {
        gint32 find_error;

        D.17391 = GetLastError ();
        find_error = (gint32) D.17391;
        if (find_error == 2) goto leave; else goto <D.17392>;
        <D.17392>:
        if (find_error == 18) goto leave; else goto <D.17393>;
        <D.17393>:
        *error = find_error;
        goto leave;
      }
      <D.17390>:
      utf8_path = get_search_dir (path_with_pattern);
      names = monoeg_g_ptr_array_new ();
      <D.17102>:
      D.17396 = BIT_FIELD_REF <data, 32, 352>;
      D.17397 = D.17396;
      if (D.17397 == 46) goto <D.17394>; else goto <D.17398>;
      <D.17398>:
      D.17396 = BIT_FIELD_REF <data, 32, 352>;
      D.17397 = D.17396;
      if (D.17397 == 3014702) goto <D.17399>; else goto <D.17395>;
      <D.17399>:
      D.17400 = data.cFileName[2];
      if (D.17400 == 0) goto <D.17394>; else goto <D.17395>;
      <D.17394>:
      // predicted unlikely by continue predictor.
      goto <D.17101>;
      <D.17395>:
      D.17401 = data.dwFileAttributes;
      mask.0 = (unsigned int) mask;
      D.17403 = D.17401 & mask.0;
      attrs.1 = (unsigned int) attrs;
      if (D.17403 == attrs.1) goto <D.17405>; else goto <D.17406>;
      <D.17405>:
      utf8_result = monoeg_g_utf16_to_utf8 (&data.cFileName, -1, 0B, 0B, 0B);
      if (utf8_result == 0B) goto <D.17407>; else goto <D.17408>;
      <D.17407>:
      // predicted unlikely by continue predictor.
      goto <D.17101>;
      <D.17408>:
      full_name = monoeg_g_build_path ("/", utf8_path, utf8_result, 0B);
      monoeg_g_ptr_array_add (names, full_name);
      monoeg_g_free (utf8_result);
      <D.17406>:
      <D.17101>:
      D.17409 = FindNextFile (find_handle, &data);
      if (D.17409 != 0) goto <D.17102>; else goto <D.17103>;
      <D.17103>:
      D.17410 = FindClose (find_handle);
      if (D.17410 == 0) goto <D.17411>; else goto <D.17412>;
      <D.17411>:
      D.17413 = GetLastError ();
      D.17414 = (int) D.17413;
      *error = D.17414;
      result = 0B;
      goto <D.17415>;
      <D.17412>:
      D.17416 = mono_defaults.string_class;
      D.17417 = names->len;
      result = mono_array_new (domain, D.17416, D.17417);
      i = 0;
      goto <D.17106>;
      <D.17105>:
      {
        void * * __p;

        i.2 = (unsigned int) i;
        __p = mono_array_addr_with_size (result, 4, i.2);
        D.17419 = names->pdata;
        i.3 = (unsigned int) i;
        D.17421 = i.3 * 4;
        D.17422 = D.17419 + D.17421;
        D.17423 = *D.17422;
        D.17424 = mono_string_new (domain, D.17423);
        mono_gc_wbarrier_set_arrayref (result, __p, D.17424);
      }
      i = i + 1;
      <D.17106>:
      i.4 = (unsigned int) i;
      D.17417 = names->len;
      if (i.4 < D.17417) goto <D.17105>; else goto <D.17107>;
      <D.17107>:
      <D.17415>:
      i = 0;
      goto <D.17109>;
      <D.17108>:
      D.17419 = names->pdata;
      i.3 = (unsigned int) i;
      D.17421 = i.3 * 4;
      D.17422 = D.17419 + D.17421;
      D.17423 = *D.17422;
      monoeg_g_free (D.17423);
      i = i + 1;
      <D.17109>:
      i.4 = (unsigned int) i;
      D.17417 = names->len;
      if (i.4 < D.17417) goto <D.17108>; else goto <D.17110>;
      <D.17110>:
      monoeg_g_ptr_array_free (names, 1);
      monoeg_g_free (utf8_path);
      leave:
      if (result == 0B) goto <D.17426>; else goto <D.17427>;
      <D.17426>:
      D.17428 = *error;
      if (D.17428 == 0) goto <D.17429>; else goto <D.17430>;
      <D.17429>:
      D.17416 = mono_defaults.string_class;
      result = mono_array_new (domain, D.17416, 0);
      <D.17430>:
      <D.17427>:
      D.17431 = result;
      return D.17431;
    }
  finally
    {
      data = {CLOBBER};
    }
}


convert_attrs (MonoFileAttributes attrs)
{
  int D.17434;
  guint32 D.17437;

  D.17434 = attrs & 16384;
  if (D.17434 != 0) goto <D.17435>; else goto <D.17436>;
  <D.17435>:
  attrs = attrs | 64;
  <D.17436>:
  D.17437 = (guint32) attrs;
  return D.17437;
}


get_file_attributes (const gunichar2 * path)
{
  guint32 D.17441;
  unsigned int D.17442;
  guint32 res;
  struct WIN32_FIND_DATA find_data;
  void * find_handle;
  gint32 error;

  try
    {
      res = GetFileAttributes (path);
      if (res != 4294967295) goto <D.17439>; else goto <D.17440>;
      <D.17439>:
      D.17441 = res;
      return D.17441;
      <D.17440>:
      D.17442 = GetLastError ();
      error = (gint32) D.17442;
      if (error != 32) goto <D.17443>; else goto <D.17444>;
      <D.17443>:
      D.17441 = res;
      return D.17441;
      <D.17444>:
      find_handle = FindFirstFile (path, &find_data);
      if (find_handle == 4294967295B) goto <D.17445>; else goto <D.17446>;
      <D.17445>:
      D.17441 = res;
      return D.17441;
      <D.17446>:
      FindClose (find_handle);
      D.17441 = find_data.dwFileAttributes;
      return D.17441;
    }
  finally
    {
      find_data = {CLOBBER};
    }
}


get_search_dir (struct MonoString * pattern)
{
  gchar * D.17449;
  gchar * p;
  gchar * result;

  p = mono_string_to_utf8 (pattern);
  result = monoeg_g_path_get_dirname (p);
  monoeg_g_free (p);
  D.17449 = result;
  return D.17449;
}


ves_icall_System_IO_MonoIO_FindFirst (struct MonoString * path, struct MonoString * path_with_pattern, gint32 * result_attr, gint32 * error, void * * handle)
{
  mono_unichar2 * D.17451;
  unsigned int D.17454;
  struct MonoString * D.17457;
  char * D.17458;
  struct MonoDomain * D.17459;
  int D.17460;
  unsigned int D.17463;
  int D.17466;
  unsigned int D.17467;
  int D.17468;
  struct WIN32_FIND_DATA data;
  void * find_handle;
  struct IncrementalFind * ifh;
  struct MonoString * result;

  try
    {
      *error = 0;
      D.17451 = mono_string_chars (path_with_pattern);
      find_handle = FindFirstFile (D.17451, &data);
      if (find_handle == 4294967295B) goto <D.17452>; else goto <D.17453>;
      <D.17452>:
      {
        gint32 find_error;

        D.17454 = GetLastError ();
        find_error = (gint32) D.17454;
        *handle = 0B;
        if (find_error == 2) goto <D.17455>; else goto <D.17456>;
        <D.17455>:
        D.17457 = 0B;
        return D.17457;
        <D.17456>:
        *error = find_error;
        D.17457 = 0B;
        return D.17457;
      }
      <D.17453>:
      ifh = monoeg_malloc (12);
      ifh->find_handle = find_handle;
      D.17458 = mono_string_to_utf8 (path);
      ifh->utf8_path = D.17458;
      D.17459 = mono_domain_get ();
      ifh->domain = D.17459;
      *handle = ifh;
      goto <D.17137>;
      <D.17136>:
      D.17460 = FindNextFile (find_handle, &data);
      if (D.17460 == 0) goto <D.17461>; else goto <D.17462>;
      <D.17461>:
      {
        int e;

        D.17463 = GetLastError ();
        e = (int) D.17463;
        if (e != 18) goto <D.17464>; else goto <D.17465>;
        <D.17464>:
        *error = e;
        <D.17465>:
        D.17457 = 0B;
        return D.17457;
      }
      <D.17462>:
      <D.17137>:
      D.17466 = incremental_find_check_match (ifh, &data, &result);
      if (D.17466 == 0) goto <D.17136>; else goto <D.17138>;
      <D.17138>:
      D.17467 = data.dwFileAttributes;
      D.17468 = (int) D.17467;
      *result_attr = D.17468;
      D.17457 = result;
      return D.17457;
    }
  finally
    {
      data = {CLOBBER};
      result = {CLOBBER};
    }
}


incremental_find_check_match (struct IncrementalFind * handle, struct WIN32_FIND_DATA * data, struct MonoString * * result)
{
  unsigned int D.17473;
  unsigned int D.17474;
  short unsigned int D.17477;
  gboolean D.17478;
  gunichar2[260] * D.17479;
  gchar * D.17482;
  struct MonoDomain * D.17483;
  struct MonoString * D.17484;
  gchar * utf8_result;
  gchar * full_name;

  D.17473 = BIT_FIELD_REF <*data, 32, 352>;
  D.17474 = D.17473;
  if (D.17474 == 46) goto <D.17471>; else goto <D.17475>;
  <D.17475>:
  D.17473 = BIT_FIELD_REF <*data, 32, 352>;
  D.17474 = D.17473;
  if (D.17474 == 3014702) goto <D.17476>; else goto <D.17472>;
  <D.17476>:
  D.17477 = data->cFileName[2];
  if (D.17477 == 0) goto <D.17471>; else goto <D.17472>;
  <D.17471>:
  D.17478 = 0;
  return D.17478;
  <D.17472>:
  D.17479 = &data->cFileName;
  utf8_result = monoeg_g_utf16_to_utf8 (D.17479, -1, 0B, 0B, 0B);
  if (utf8_result == 0B) goto <D.17480>; else goto <D.17481>;
  <D.17480>:
  D.17478 = 0;
  return D.17478;
  <D.17481>:
  D.17482 = handle->utf8_path;
  full_name = monoeg_g_build_path ("/", D.17482, utf8_result, 0B);
  monoeg_g_free (utf8_result);
  D.17483 = mono_domain_get ();
  D.17484 = mono_string_new (D.17483, full_name);
  *result = D.17484;
  monoeg_g_free (full_name);
  D.17478 = 1;
  return D.17478;
}


ves_icall_System_IO_MonoIO_FindNext (void * handle, gint32 * result_attr, gint32 * error)
{
  void * D.17486;
  int D.17487;
  unsigned int D.17490;
  struct MonoString * D.17493;
  int D.17494;
  unsigned int D.17495;
  int D.17496;
  struct IncrementalFind * ifh;
  struct WIN32_FIND_DATA data;
  struct MonoString * result;

  try
    {
      ifh = handle;
      *error = 0;
      <D.17148>:
      D.17486 = ifh->find_handle;
      D.17487 = FindNextFile (D.17486, &data);
      if (D.17487 == 0) goto <D.17488>; else goto <D.17489>;
      <D.17488>:
      {
        int e;

        D.17490 = GetLastError ();
        e = (int) D.17490;
        if (e != 18) goto <D.17491>; else goto <D.17492>;
        <D.17491>:
        *error = e;
        <D.17492>:
        D.17493 = 0B;
        return D.17493;
      }
      <D.17489>:
      D.17494 = incremental_find_check_match (ifh, &data, &result);
      if (D.17494 == 0) goto <D.17148>; else goto <D.17149>;
      <D.17149>:
      D.17495 = data.dwFileAttributes;
      D.17496 = (int) D.17495;
      *result_attr = D.17496;
      D.17493 = result;
      return D.17493;
    }
  finally
    {
      data = {CLOBBER};
      result = {CLOBBER};
    }
}


ves_icall_System_IO_MonoIO_FindClose (void * handle)
{
  void * D.17499;
  int D.17500;
  unsigned int D.17503;
  gchar * D.17505;
  int D.17506;
  struct IncrementalFind * ifh;
  gint32 error;

  ifh = handle;
  D.17499 = ifh->find_handle;
  D.17500 = FindClose (D.17499);
  if (D.17500 == 0) goto <D.17501>; else goto <D.17502>;
  <D.17501>:
  D.17503 = GetLastError ();
  error = (gint32) D.17503;
  goto <D.17504>;
  <D.17502>:
  error = 0;
  <D.17504>:
  D.17505 = ifh->utf8_path;
  monoeg_g_free (D.17505);
  monoeg_g_free (ifh);
  D.17506 = error;
  return D.17506;
}


ves_icall_System_IO_MonoIO_GetCurrentDirectory (gint32 * error)
{
  unsigned int len.5;
  unsigned int D.17509;
  unsigned int len.6;
  unsigned int D.17511;
  unsigned int res_len.7;
  unsigned int D.17515;
  unsigned int res_len.8;
  unsigned int D.17517;
  unsigned int old_res_len.9;
  _Bool D.17519;
  gunichar2 * D.17522;
  short unsigned int D.17523;
  struct MonoDomain * D.17524;
  unsigned int D.17526;
  int D.17527;
  struct MonoString * D.17528;
  struct MonoString * result;
  gunichar2 * buf;
  int len;
  int res_len;

  len = 261;
  len.5 = (unsigned int) len;
  D.17509 = len.5 * 2;
  buf = monoeg_malloc (D.17509);
  *error = 0;
  result = 0B;
  len.6 = (unsigned int) len;
  D.17511 = GetCurrentDirectory (len.6, buf);
  res_len = (int) D.17511;
  if (res_len > len) goto <D.17512>; else goto <D.17513>;
  <D.17512>:
  {
    int old_res_len;

    old_res_len = res_len;
    monoeg_g_free (buf);
    res_len.7 = (unsigned int) res_len;
    D.17515 = res_len.7 * 2;
    buf = monoeg_malloc (D.17515);
    res_len.8 = (unsigned int) res_len;
    D.17517 = GetCurrentDirectory (res_len.8, buf);
    old_res_len.9 = (unsigned int) old_res_len;
    D.17519 = D.17517 == old_res_len.9;
    res_len = (int) D.17519;
  }
  <D.17513>:
  if (res_len != 0) goto <D.17520>; else goto <D.17521>;
  <D.17520>:
  len = 0;
  goto <D.17164>;
  <D.17163>:
  len = len + 1;
  <D.17164>:
  len.5 = (unsigned int) len;
  D.17509 = len.5 * 2;
  D.17522 = buf + D.17509;
  D.17523 = *D.17522;
  if (D.17523 != 0) goto <D.17163>; else goto <D.17165>;
  <D.17165>:
  D.17524 = mono_domain_get ();
  result = mono_string_new_utf16 (D.17524, buf, len);
  goto <D.17525>;
  <D.17521>:
  D.17526 = GetLastError ();
  D.17527 = (int) D.17526;
  *error = D.17527;
  <D.17525>:
  monoeg_g_free (buf);
  D.17528 = result;
  return D.17528;
}


ves_icall_System_IO_MonoIO_SetCurrentDirectory (struct MonoString * path, gint32 * error)
{
  mono_unichar2 * D.17530;
  unsigned int D.17533;
  int D.17534;
  MonoBoolean D.17535;
  gboolean ret;

  *error = 0;
  D.17530 = mono_string_chars (path);
  ret = SetCurrentDirectory (D.17530);
  if (ret == 0) goto <D.17531>; else goto <D.17532>;
  <D.17531>:
  D.17533 = GetLastError ();
  D.17534 = (int) D.17533;
  *error = D.17534;
  <D.17532>:
  D.17535 = (MonoBoolean) ret;
  return D.17535;
}


ves_icall_System_IO_MonoIO_MoveFile (struct MonoString * path, struct MonoString * dest, gint32 * error)
{
  mono_unichar2 * D.17537;
  mono_unichar2 * D.17538;
  unsigned int D.17541;
  int D.17542;
  MonoBoolean D.17543;
  gboolean ret;

  *error = 0;
  D.17537 = mono_string_chars (path);
  D.17538 = mono_string_chars (dest);
  ret = MoveFile (D.17537, D.17538);
  if (ret == 0) goto <D.17539>; else goto <D.17540>;
  <D.17539>:
  D.17541 = GetLastError ();
  D.17542 = (int) D.17541;
  *error = D.17542;
  <D.17540>:
  D.17543 = (MonoBoolean) ret;
  return D.17543;
}


ves_icall_System_IO_MonoIO_ReplaceFile (struct MonoString * sourceFileName, struct MonoString * destinationFileName, struct MonoString * destinationBackupFileName, MonoBoolean ignoreMetadataErrors, gint32 * error)
{
  unsigned int D.17555;
  int D.17556;
  MonoBoolean D.17557;
  gboolean ret;
  gunichar2 * utf16_sourceFileName;
  gunichar2 * utf16_destinationFileName;
  gunichar2 * utf16_destinationBackupFileName;
  guint32 replaceFlags;

  utf16_sourceFileName = 0B;
  utf16_destinationFileName = 0B;
  utf16_destinationBackupFileName = 0B;
  replaceFlags = 1;
  if (sourceFileName != 0B) goto <D.17545>; else goto <D.17546>;
  <D.17545>:
  utf16_sourceFileName = mono_string_chars (sourceFileName);
  <D.17546>:
  if (destinationFileName != 0B) goto <D.17547>; else goto <D.17548>;
  <D.17547>:
  utf16_destinationFileName = mono_string_chars (destinationFileName);
  <D.17548>:
  if (destinationBackupFileName != 0B) goto <D.17549>; else goto <D.17550>;
  <D.17549>:
  utf16_destinationBackupFileName = mono_string_chars (destinationBackupFileName);
  <D.17550>:
  *error = 0;
  if (ignoreMetadataErrors != 0) goto <D.17551>; else goto <D.17552>;
  <D.17551>:
  replaceFlags = replaceFlags | 2;
  <D.17552>:
  ret = ReplaceFile (utf16_destinationFileName, utf16_sourceFileName, utf16_destinationBackupFileName, replaceFlags, 0B, 0B);
  if (ret == 0) goto <D.17553>; else goto <D.17554>;
  <D.17553>:
  D.17555 = GetLastError ();
  D.17556 = (int) D.17555;
  *error = D.17556;
  <D.17554>:
  D.17557 = (MonoBoolean) ret;
  return D.17557;
}


ves_icall_System_IO_MonoIO_CopyFile (struct MonoString * path, struct MonoString * dest, MonoBoolean overwrite, gint32 * error)
{
  mono_unichar2 * D.17559;
  mono_unichar2 * D.17560;
  _Bool D.17561;
  int D.17562;
  unsigned int D.17565;
  int D.17566;
  MonoBoolean D.17567;
  gboolean ret;

  *error = 0;
  D.17559 = mono_string_chars (path);
  D.17560 = mono_string_chars (dest);
  D.17561 = overwrite == 0;
  D.17562 = (int) D.17561;
  ret = CopyFile (D.17559, D.17560, D.17562);
  if (ret == 0) goto <D.17563>; else goto <D.17564>;
  <D.17563>:
  D.17565 = GetLastError ();
  D.17566 = (int) D.17565;
  *error = D.17566;
  <D.17564>:
  D.17567 = (MonoBoolean) ret;
  return D.17567;
}


ves_icall_System_IO_MonoIO_DeleteFile (struct MonoString * path, gint32 * error)
{
  mono_unichar2 * D.17569;
  unsigned int D.17572;
  int D.17573;
  MonoBoolean D.17574;
  gboolean ret;

  *error = 0;
  D.17569 = mono_string_chars (path);
  ret = DeleteFile (D.17569);
  if (ret == 0) goto <D.17570>; else goto <D.17571>;
  <D.17570>:
  D.17572 = GetLastError ();
  D.17573 = (int) D.17572;
  *error = D.17573;
  <D.17571>:
  D.17574 = (MonoBoolean) ret;
  return D.17574;
}


ves_icall_System_IO_MonoIO_GetFileAttributes (struct MonoString * path, gint32 * error)
{
  mono_unichar2 * D.17576;
  unsigned int D.17577;
  unsigned int D.17580;
  int D.17581;
  gint32 D.17582;
  gint32 ret;

  *error = 0;
  D.17576 = mono_string_chars (path);
  D.17577 = get_file_attributes (D.17576);
  ret = (gint32) D.17577;
  if (ret == -1) goto <D.17578>; else goto <D.17579>;
  <D.17578>:
  D.17580 = GetLastError ();
  D.17581 = (int) D.17580;
  *error = D.17581;
  <D.17579>:
  D.17582 = ret;
  return D.17582;
}


ves_icall_System_IO_MonoIO_SetFileAttributes (struct MonoString * path, gint32 attrs, gint32 * error)
{
  mono_unichar2 * D.17584;
  unsigned int D.17585;
  unsigned int D.17588;
  int D.17589;
  MonoBoolean D.17590;
  gboolean ret;

  *error = 0;
  D.17584 = mono_string_chars (path);
  D.17585 = convert_attrs (attrs);
  ret = SetFileAttributes (D.17584, D.17585);
  if (ret == 0) goto <D.17586>; else goto <D.17587>;
  <D.17586>:
  D.17588 = GetLastError ();
  D.17589 = (int) D.17588;
  *error = D.17589;
  <D.17587>:
  D.17590 = (MonoBoolean) ret;
  return D.17590;
}


ves_icall_System_IO_MonoIO_GetFileType (void * handle, gint32 * error)
{
  <unnamed type> D.17592;
  unsigned int D.17595;
  int D.17596;
  gint32 D.17597;
  gboolean ret;

  *error = 0;
  D.17592 = GetFileType (handle);
  ret = (gboolean) D.17592;
  if (ret == 0) goto <D.17593>; else goto <D.17594>;
  <D.17593>:
  D.17595 = GetLastError ();
  D.17596 = (int) D.17595;
  *error = D.17596;
  <D.17594>:
  D.17597 = ret;
  return D.17597;
}


ves_icall_System_IO_MonoIO_GetFileStat (struct MonoString * path, struct MonoIOStat * stat, gint32 * error)
{
  mono_unichar2 * D.17599;
  unsigned int D.17603;
  int D.17604;
  MonoBoolean D.17605;
  gboolean result;
  struct WIN32_FILE_ATTRIBUTE_DATA data;

  try
    {
      *error = 0;
      D.17599 = mono_string_chars (path);
      result = get_file_attributes_ex (D.17599, &data);
      if (result != 0) goto <D.17600>; else goto <D.17601>;
      <D.17600>:
      convert_win32_file_attribute_data (&data, stat);
      goto <D.17602>;
      <D.17601>:
      D.17603 = GetLastError ();
      D.17604 = (int) D.17603;
      *error = D.17604;
      memset (stat, 0, 40);
      <D.17602>:
      D.17605 = (MonoBoolean) result;
      return D.17605;
    }
  finally
    {
      data = {CLOBBER};
    }
}


get_file_attributes_ex (const gunichar2 * path, struct WIN32_FILE_ATTRIBUTE_DATA * data)
{
  gboolean D.17610;
  unsigned int D.17611;
  unsigned int D.17616;
  unsigned int D.17617;
  unsigned int D.17618;
  gboolean res;
  struct WIN32_FIND_DATA find_data;
  void * find_handle;
  gint32 error;

  try
    {
      res = GetFileAttributesEx (path, 0, data);
      if (res != 0) goto <D.17608>; else goto <D.17609>;
      <D.17608>:
      D.17610 = 1;
      return D.17610;
      <D.17609>:
      D.17611 = GetLastError ();
      error = (gint32) D.17611;
      if (error != 32) goto <D.17612>; else goto <D.17613>;
      <D.17612>:
      D.17610 = 0;
      return D.17610;
      <D.17613>:
      find_handle = FindFirstFile (path, &find_data);
      if (find_handle == 4294967295B) goto <D.17614>; else goto <D.17615>;
      <D.17614>:
      D.17610 = 0;
      return D.17610;
      <D.17615>:
      FindClose (find_handle);
      D.17616 = find_data.dwFileAttributes;
      data->dwFileAttributes = D.17616;
      data->ftCreationTime = find_data.ftCreationTime;
      data->ftLastAccessTime = find_data.ftLastAccessTime;
      data->ftLastWriteTime = find_data.ftLastWriteTime;
      D.17617 = find_data.nFileSizeHigh;
      data->nFileSizeHigh = D.17617;
      D.17618 = find_data.nFileSizeLow;
      data->nFileSizeLow = D.17618;
      D.17610 = 1;
      return D.17610;
    }
  finally
    {
      find_data = {CLOBBER};
    }
}


convert_win32_file_attribute_data (const struct WIN32_FILE_ATTRIBUTE_DATA * data, struct MonoIOStat * stat)
{
  unsigned int D.17621;
  int D.17622;
  const struct WapiFileTime * D.17623;
  long long int D.17624;
  const struct WapiFileTime * D.17625;
  long long int D.17626;
  const struct WapiFileTime * D.17627;
  long long int D.17628;
  unsigned int D.17629;
  long long int D.17630;
  long long int D.17631;
  unsigned int D.17632;
  long long int D.17633;
  long long int D.17634;

  D.17621 = data->dwFileAttributes;
  D.17622 = (int) D.17621;
  stat->attributes = D.17622;
  D.17623 = &data->ftCreationTime;
  D.17624 = convert_filetime (D.17623);
  stat->creation_time = D.17624;
  D.17625 = &data->ftLastAccessTime;
  D.17626 = convert_filetime (D.17625);
  stat->last_access_time = D.17626;
  D.17627 = &data->ftLastWriteTime;
  D.17628 = convert_filetime (D.17627);
  stat->last_write_time = D.17628;
  D.17629 = data->nFileSizeHigh;
  D.17630 = (long long int) D.17629;
  D.17631 = D.17630 << 32;
  D.17632 = data->nFileSizeLow;
  D.17633 = (long long int) D.17632;
  D.17634 = D.17631 | D.17633;
  stat->length = D.17634;
}


convert_filetime (const struct FILETIME * filetime)
{
  unsigned int D.17635;
  unsigned int D.17636;
  long long unsigned int D.17637;
  gint64 D.17638;
  guint64 ticks;

  D.17635 = filetime->dwHighDateTime;
  ticks = (guint64) D.17635;
  ticks = ticks << 32;
  D.17636 = filetime->dwLowDateTime;
  D.17637 = (long long unsigned int) D.17636;
  ticks = D.17637 + ticks;
  D.17638 = (gint64) ticks;
  return D.17638;
}


memset (void * __dest, int __ch, size_t __len)
{
  int D.17642;
  int D.17647;
  void * D.17649;
  unsigned int D.17650;

  D.17642 = __builtin_constant_p (__len);
  if (D.17642 != 0) goto <D.17643>; else goto <D.17644>;
  <D.17643>:
  if (__len == 0) goto <D.17645>; else goto <D.17646>;
  <D.17645>:
  D.17647 = __builtin_constant_p (__ch);
  if (D.17647 == 0) goto <D.17640>; else goto <D.17648>;
  <D.17648>:
  if (__ch != 0) goto <D.17640>; else goto <D.17641>;
  <D.17640>:
  __warn_memset_zero_len ();
  D.17649 = __dest;
  return D.17649;
  <D.17641>:
  <D.17646>:
  <D.17644>:
  D.17650 = __builtin_object_size (__dest, 0);
  D.17649 = __builtin___memset_chk (__dest, __ch, __len, D.17650);
  return D.17649;
}


ves_icall_System_IO_MonoIO_Open (struct MonoString * filename, gint32 mode, gint32 access_mode, gint32 share, gint32 options, gint32 * error)
{
  int D.17654;
  int D.17658;
  int D.17661;
  int D.17664;
  int D.17667;
  int D.17670;
  unsigned int attributes.10;
  unsigned int D.17676;
  unsigned int D.17678;
  int D.17681;
  <unnamed type> access_mode.11;
  unsigned int D.17685;
  <unnamed type> share.12;
  unsigned int D.17687;
  <unnamed type> mode.13;
  unsigned int D.17689;
  unsigned int attributes.14;
  unsigned int D.17693;
  int D.17694;
  void * D.17695;
  void * ret;
  int attributes;
  int attrs;
  gunichar2 * chars;

  chars = mono_string_chars (filename);
  *error = 0;
  if (options != 0) goto <D.17652>; else goto <D.17653>;
  <D.17652>:
  D.17654 = options & 16384;
  if (D.17654 != 0) goto <D.17655>; else goto <D.17656>;
  <D.17655>:
  attributes = 64;
  goto <D.17657>;
  <D.17656>:
  attributes = 128;
  <D.17657>:
  D.17658 = options & 67108864;
  if (D.17658 != 0) goto <D.17659>; else goto <D.17660>;
  <D.17659>:
  attributes = attributes | 67108864;
  <D.17660>:
  D.17661 = options & 134217728;
  if (D.17661 != 0) goto <D.17662>; else goto <D.17663>;
  <D.17662>:
  attributes = attributes | 134217728;
  <D.17663>:
  D.17664 = options & 268435456;
  if (D.17664 != 0) goto <D.17665>; else goto <D.17666>;
  <D.17665>:
  attributes = attributes | 268435456;
  <D.17666>:
  D.17667 = options & 1;
  if (D.17667 != 0) goto <D.17668>; else goto <D.17669>;
  <D.17668>:
  attributes = attributes | 256;
  <D.17669>:
  D.17670 = options & 1073741824;
  if (D.17670 != 0) goto <D.17671>; else goto <D.17672>;
  <D.17671>:
  attributes = attributes | 1073741824;
  <D.17672>:
  if (options < 0) goto <D.17673>; else goto <D.17674>;
  <D.17673>:
  attributes.10 = (unsigned int) attributes;
  D.17676 = attributes.10 | 2147483648;
  attributes = (int) D.17676;
  <D.17674>:
  goto <D.17677>;
  <D.17653>:
  attributes = 128;
  <D.17677>:
  D.17678 = get_file_attributes (chars);
  attrs = (int) D.17678;
  if (attrs != -1) goto <D.17679>; else goto <D.17680>;
  <D.17679>:
  D.17681 = attrs & 16;
  if (D.17681 != 0) goto <D.17682>; else goto <D.17683>;
  <D.17682>:
  attributes = attributes | 33554432;
  <D.17683>:
  <D.17680>:
  access_mode.11 = (<unnamed type>) access_mode;
  D.17685 = convert_access (access_mode.11);
  share.12 = (<unnamed type>) share;
  D.17687 = convert_share (share.12);
  mode.13 = (<unnamed type>) mode;
  D.17689 = convert_mode (mode.13);
  attributes.14 = (unsigned int) attributes;
  ret = CreateFile (chars, D.17685, D.17687, 0B, D.17689, attributes.14, 0B);
  if (ret == 4294967295B) goto <D.17691>; else goto <D.17692>;
  <D.17691>:
  D.17693 = GetLastError ();
  D.17694 = (int) D.17693;
  *error = D.17694;
  <D.17692>:
  D.17695 = ret;
  return D.17695;
}


convert_access (MonoFileAccess mono_access)
{
  guint32 D.17697;
  guint32 access;

  switch (mono_access) <default: <D.17027>, case 1: <D.17023>, case 2: <D.17025>, case 3: <D.17026>>
  <D.17023>:
  access = 2147483648;
  goto <D.17024>;
  <D.17025>:
  access = 1073741824;
  goto <D.17024>;
  <D.17026>:
  access = 3221225472;
  goto <D.17024>;
  <D.17027>:
  monoeg_g_log (0B, 16, "System.IO.FileAccess has unknown value 0x%x", mono_access);
  access = 2147483648;
  <D.17024>:
  D.17697 = access;
  return D.17697;
}


convert_share (MonoFileShare mono_share)
{
  unsigned int D.17699;
  unsigned int D.17702;
  unsigned int D.17705;
  unsigned int D.17708;
  guint32 D.17711;
  guint32 share;

  share = 0;
  D.17699 = mono_share & 1;
  if (D.17699 != 0) goto <D.17700>; else goto <D.17701>;
  <D.17700>:
  share = share | 1;
  <D.17701>:
  D.17702 = mono_share & 2;
  if (D.17702 != 0) goto <D.17703>; else goto <D.17704>;
  <D.17703>:
  share = share | 2;
  <D.17704>:
  D.17705 = mono_share & 4;
  if (D.17705 != 0) goto <D.17706>; else goto <D.17707>;
  <D.17706>:
  share = share | 4;
  <D.17707>:
  D.17708 = mono_share & 4294967288;
  if (D.17708 != 0) goto <D.17709>; else goto <D.17710>;
  <D.17709>:
  monoeg_g_log (0B, 16, "System.IO.FileShare has unknown value 0x%x", mono_share);
  share = 0;
  <D.17710>:
  D.17711 = share;
  return D.17711;
}


convert_mode (MonoFileMode mono_mode)
{
  guint32 D.17713;
  guint32 mode;

  switch (mono_mode) <default: <D.17018>, case 1: <D.17011>, case 2: <D.17013>, case 3: <D.17014>, case 4: <D.17015>, case 5: <D.17016>, case 6: <D.17017>>
  <D.17011>:
  mode = 1;
  goto <D.17012>;
  <D.17013>:
  mode = 2;
  goto <D.17012>;
  <D.17014>:
  mode = 3;
  goto <D.17012>;
  <D.17015>:
  mode = 4;
  goto <D.17012>;
  <D.17016>:
  mode = 5;
  goto <D.17012>;
  <D.17017>:
  mode = 4;
  goto <D.17012>;
  <D.17018>:
  monoeg_g_log (0B, 16, "System.IO.FileMode has unknown value 0x%x", mono_mode);
  mode = 3;
  <D.17012>:
  D.17713 = mode;
  return D.17713;
}


ves_icall_System_IO_MonoIO_Close (void * handle, gint32 * error)
{
  unsigned int D.17717;
  int D.17718;
  MonoBoolean D.17719;
  gboolean ret;

  *error = 0;
  ret = CloseHandle (handle);
  if (ret == 0) goto <D.17715>; else goto <D.17716>;
  <D.17715>:
  D.17717 = GetLastError ();
  D.17718 = (int) D.17717;
  *error = D.17718;
  <D.17716>:
  D.17719 = (MonoBoolean) ret;
  return D.17719;
}


ves_icall_System_IO_MonoIO_Read (void * handle, struct MonoArray * dest, gint32 dest_offset, gint32 count, gint32 * error)
{
  _Bool D.17721;
  long int D.17722;
  long int D.17723;
  unsigned int dest_offset.15;
  unsigned int D.17729;
  unsigned int count.16;
  unsigned int D.17731;
  struct MonoException * D.17734;
  unsigned int count.17;
  unsigned int D.17738;
  int D.17739;
  gint32 D.17740;
  unsigned int n.18;
  guchar * buffer;
  gboolean result;
  guint32 n;

  try
    {
      *error = 0;
      D.17721 = dest == 0B;
      D.17722 = (long int) D.17721;
      D.17723 = __builtin_expect (D.17722, 0);
      if (D.17723 != 0) goto <D.17724>; else goto <D.17725>;
      <D.17724>:
      {
        struct MonoException * ex;

        if (dest != 0B) goto <D.17726>; else goto <D.17727>;
        <D.17726>:
        <D.17727>:
        ex = mono_get_exception_argument_null ("dest");
        mono_raise_exception (ex);
      }
      <D.17725>:
      dest_offset.15 = (unsigned int) dest_offset;
      D.17729 = mono_array_length (dest);
      count.16 = (unsigned int) count;
      D.17731 = D.17729 - count.16;
      if (dest_offset.15 > D.17731) goto <D.17732>; else goto <D.17733>;
      <D.17732>:
      D.17734 = mono_get_exception_argument ("array", "array too small. numBytes/offset wrong.");
      mono_raise_exception (D.17734);
      <D.17733>:
      dest_offset.15 = (unsigned int) dest_offset;
      buffer = mono_array_addr_with_size (dest, 1, dest_offset.15);
      count.17 = (unsigned int) count;
      result = ReadFile (handle, buffer, count.17, &n, 0B);
      if (result == 0) goto <D.17736>; else goto <D.17737>;
      <D.17736>:
      D.17738 = GetLastError ();
      D.17739 = (int) D.17738;
      *error = D.17739;
      D.17740 = -1;
      return D.17740;
      <D.17737>:
      n.18 = n;
      D.17740 = (gint32) n.18;
      return D.17740;
    }
  finally
    {
      n = {CLOBBER};
    }
}


ves_icall_System_IO_MonoIO_Write (void * handle, struct MonoArray * src, gint32 src_offset, gint32 count, gint32 * error)
{
  _Bool D.17744;
  long int D.17745;
  long int D.17746;
  unsigned int src_offset.19;
  unsigned int D.17752;
  unsigned int count.20;
  unsigned int D.17754;
  struct MonoException * D.17757;
  unsigned int count.21;
  unsigned int D.17761;
  int D.17762;
  gint32 D.17763;
  unsigned int n.22;
  guchar * buffer;
  gboolean result;
  guint32 n;

  try
    {
      *error = 0;
      D.17744 = src == 0B;
      D.17745 = (long int) D.17744;
      D.17746 = __builtin_expect (D.17745, 0);
      if (D.17746 != 0) goto <D.17747>; else goto <D.17748>;
      <D.17747>:
      {
        struct MonoException * ex;

        if (src != 0B) goto <D.17749>; else goto <D.17750>;
        <D.17749>:
        <D.17750>:
        ex = mono_get_exception_argument_null ("src");
        mono_raise_exception (ex);
      }
      <D.17748>:
      src_offset.19 = (unsigned int) src_offset;
      D.17752 = mono_array_length (src);
      count.20 = (unsigned int) count;
      D.17754 = D.17752 - count.20;
      if (src_offset.19 > D.17754) goto <D.17755>; else goto <D.17756>;
      <D.17755>:
      D.17757 = mono_get_exception_argument ("array", "array too small. numBytes/offset wrong.");
      mono_raise_exception (D.17757);
      <D.17756>:
      src_offset.19 = (unsigned int) src_offset;
      buffer = mono_array_addr_with_size (src, 1, src_offset.19);
      count.21 = (unsigned int) count;
      result = WriteFile (handle, buffer, count.21, &n, 0B);
      if (result == 0) goto <D.17759>; else goto <D.17760>;
      <D.17759>:
      D.17761 = GetLastError ();
      D.17762 = (int) D.17761;
      *error = D.17762;
      D.17763 = -1;
      return D.17763;
      <D.17760>:
      n.22 = n;
      D.17763 = (gint32) n.22;
      return D.17763;
    }
  finally
    {
      n = {CLOBBER};
    }
}


ves_icall_System_IO_MonoIO_Seek (void * handle, gint64 offset, gint32 origin, gint32 * error)
{
  long long int D.17767;
  int offset_hi.23;
  int D.17769;
  <unnamed type> origin.24;
  unsigned int D.17771;
  unsigned int D.17772;
  unsigned int D.17775;
  int D.17776;
  gint64 D.17777;
  int offset_hi.25;
  long long int D.17779;
  long long int D.17780;
  gint32 offset_hi;

  try
    {
      *error = 0;
      D.17767 = offset >> 32;
      offset_hi.23 = (int) D.17767;
      offset_hi = offset_hi.23;
      D.17769 = (int) offset;
      origin.24 = (<unnamed type>) origin;
      D.17771 = convert_seekorigin (origin.24);
      D.17772 = SetFilePointer (handle, D.17769, &offset_hi, D.17771);
      offset = (gint64) D.17772;
      if (offset == 4294967295) goto <D.17773>; else goto <D.17774>;
      <D.17773>:
      D.17775 = GetLastError ();
      D.17776 = (int) D.17775;
      *error = D.17776;
      <D.17774>:
      offset_hi.25 = offset_hi;
      D.17779 = (long long int) offset_hi.25;
      D.17780 = D.17779 << 32;
      D.17777 = D.17780 | offset;
      return D.17777;
    }
  finally
    {
      offset_hi = {CLOBBER};
    }
}


convert_seekorigin (MonoSeekOrigin origin)
{
  guint32 D.17783;
  guint32 w32origin;

  switch (origin) <default: <D.17040>, case 0: <D.17036>, case 1: <D.17038>, case 2: <D.17039>>
  <D.17036>:
  w32origin = 0;
  goto <D.17037>;
  <D.17038>:
  w32origin = 1;
  goto <D.17037>;
  <D.17039>:
  w32origin = 2;
  goto <D.17037>;
  <D.17040>:
  monoeg_g_log (0B, 16, "System.IO.SeekOrigin has unknown value 0x%x", origin);
  w32origin = 1;
  <D.17037>:
  D.17783 = w32origin;
  return D.17783;
}


ves_icall_System_IO_MonoIO_Flush (void * handle, gint32 * error)
{
  unsigned int D.17787;
  int D.17788;
  MonoBoolean D.17789;
  gboolean ret;

  *error = 0;
  ret = FlushFileBuffers (handle);
  if (ret == 0) goto <D.17785>; else goto <D.17786>;
  <D.17785>:
  D.17787 = GetLastError ();
  D.17788 = (int) D.17787;
  *error = D.17788;
  <D.17786>:
  D.17789 = (MonoBoolean) ret;
  return D.17789;
}


ves_icall_System_IO_MonoIO_GetLength (void * handle, gint32 * error)
{
  unsigned int D.17791;
  unsigned int D.17794;
  int D.17795;
  gint64 D.17796;
  unsigned int length_hi.26;
  long long int D.17798;
  long long int D.17799;
  gint64 length;
  guint32 length_hi;

  try
    {
      *error = 0;
      D.17791 = GetFileSize (handle, &length_hi);
      length = (gint64) D.17791;
      if (length == 4294967295) goto <D.17792>; else goto <D.17793>;
      <D.17792>:
      D.17794 = GetLastError ();
      D.17795 = (int) D.17794;
      *error = D.17795;
      <D.17793>:
      length_hi.26 = length_hi;
      D.17798 = (long long int) length_hi.26;
      D.17799 = D.17798 << 32;
      D.17796 = D.17799 | length;
      return D.17796;
    }
  finally
    {
      length_hi = {CLOBBER};
    }
}


ves_icall_System_IO_MonoIO_SetLength (void * handle, gint64 length, gint32 * error)
{
  unsigned int D.17802;
  unsigned int D.17805;
  int D.17806;
  MonoBoolean D.17807;
  long long int D.17808;
  int length_hi.27;
  int D.17810;
  unsigned int D.17811;
  unsigned int D.17814;
  int D.17815;
  unsigned int D.17818;
  int D.17819;
  int D.17820;
  unsigned int D.17821;
  unsigned int D.17824;
  int D.17825;
  gint64 offset;
  gint64 offset_set;
  gint32 offset_hi;
  gint32 length_hi;
  gboolean result;

  try
    {
      *error = 0;
      offset_hi = 0;
      D.17802 = SetFilePointer (handle, 0, &offset_hi, 1);
      offset = (gint64) D.17802;
      if (offset == 4294967295) goto <D.17803>; else goto <D.17804>;
      <D.17803>:
      D.17805 = GetLastError ();
      D.17806 = (int) D.17805;
      *error = D.17806;
      D.17807 = 0;
      return D.17807;
      <D.17804>:
      D.17808 = length >> 32;
      length_hi.27 = (int) D.17808;
      length_hi = length_hi.27;
      D.17810 = (int) length;
      D.17811 = SetFilePointer (handle, D.17810, &length_hi, 0);
      offset_set = (gint64) D.17811;
      if (offset_set == 4294967295) goto <D.17812>; else goto <D.17813>;
      <D.17812>:
      D.17814 = GetLastError ();
      D.17815 = (int) D.17814;
      *error = D.17815;
      D.17807 = 0;
      return D.17807;
      <D.17813>:
      result = SetEndOfFile (handle);
      if (result == 0) goto <D.17816>; else goto <D.17817>;
      <D.17816>:
      D.17818 = GetLastError ();
      D.17819 = (int) D.17818;
      *error = D.17819;
      D.17807 = 0;
      return D.17807;
      <D.17817>:
      D.17820 = (int) offset;
      D.17821 = SetFilePointer (handle, D.17820, &offset_hi, 0);
      offset_set = (gint64) D.17821;
      if (offset_set == 4294967295) goto <D.17822>; else goto <D.17823>;
      <D.17822>:
      D.17824 = GetLastError ();
      D.17825 = (int) D.17824;
      *error = D.17825;
      D.17807 = 0;
      return D.17807;
      <D.17823>:
      D.17807 = (MonoBoolean) result;
      return D.17807;
    }
  finally
    {
      offset_hi = {CLOBBER};
      length_hi = {CLOBBER};
    }
}


ves_icall_System_IO_MonoIO_SetFileTime (void * handle, gint64 creation_time, gint64 last_access_time, gint64 last_write_time, gint32 * error)
{
  long long int creation_time.28;
  long long int last_access_time.29;
  long long int last_write_time.30;
  unsigned int D.17842;
  int D.17843;
  MonoBoolean D.17844;
  gboolean ret;
  const struct FILETIME * creation_filetime;
  const struct FILETIME * last_access_filetime;
  const struct FILETIME * last_write_filetime;

  *error = 0;
  creation_time.28 = creation_time;
  if (creation_time.28 < 0) goto <D.17829>; else goto <D.17830>;
  <D.17829>:
  creation_filetime = 0B;
  goto <D.17831>;
  <D.17830>:
  creation_filetime = &creation_time;
  <D.17831>:
  last_access_time.29 = last_access_time;
  if (last_access_time.29 < 0) goto <D.17833>; else goto <D.17834>;
  <D.17833>:
  last_access_filetime = 0B;
  goto <D.17835>;
  <D.17834>:
  last_access_filetime = &last_access_time;
  <D.17835>:
  last_write_time.30 = last_write_time;
  if (last_write_time.30 < 0) goto <D.17837>; else goto <D.17838>;
  <D.17837>:
  last_write_filetime = 0B;
  goto <D.17839>;
  <D.17838>:
  last_write_filetime = &last_write_time;
  <D.17839>:
  ret = SetFileTime (handle, creation_filetime, last_access_filetime, last_write_filetime);
  if (ret == 0) goto <D.17840>; else goto <D.17841>;
  <D.17840>:
  D.17842 = GetLastError ();
  D.17843 = (int) D.17842;
  *error = D.17843;
  <D.17841>:
  D.17844 = (MonoBoolean) ret;
  return D.17844;
}


ves_icall_System_IO_MonoIO_get_ConsoleOutput ()
{
  void * D.17846;

  D.17846 = GetStdHandle (-11);
  return D.17846;
}


ves_icall_System_IO_MonoIO_get_ConsoleInput ()
{
  void * D.17848;

  D.17848 = GetStdHandle (-10);
  return D.17848;
}


ves_icall_System_IO_MonoIO_get_ConsoleError ()
{
  void * D.17850;

  D.17850 = GetStdHandle (-12);
  return D.17850;
}


ves_icall_System_IO_MonoIO_CreatePipe (void * * read_handle, void * * write_handle)
{
  MonoBoolean D.17854;
  struct SECURITY_ATTRIBUTES attr;
  gboolean ret;

  try
    {
      attr.nLength = 12;
      attr.bInheritHandle = 1;
      attr.lpSecurityDescriptor = 0B;
      ret = CreatePipe (read_handle, write_handle, &attr, 0);
      if (ret == 0) goto <D.17852>; else goto <D.17853>;
      <D.17852>:
      D.17854 = 0;
      return D.17854;
      <D.17853>:
      D.17854 = 1;
      return D.17854;
    }
  finally
    {
      attr = {CLOBBER};
    }
}


ves_icall_System_IO_MonoIO_DuplicateHandle (void * source_process_handle, void * source_handle, void * target_process_handle, void * * target_handle, gint32 access, gint32 inherit, gint32 options)
{
  unsigned int access.31;
  unsigned int options.32;
  MonoBoolean D.17861;
  gboolean ret;

  access.31 = (unsigned int) access;
  options.32 = (unsigned int) options;
  ret = DuplicateHandle (source_process_handle, source_handle, target_process_handle, target_handle, access.31, inherit, options.32);
  if (ret == 0) goto <D.17859>; else goto <D.17860>;
  <D.17859>:
  D.17861 = 0;
  return D.17861;
  <D.17860>:
  D.17861 = 1;
  return D.17861;
}


ves_icall_System_IO_MonoIO_get_VolumeSeparatorChar ()
{
  gunichar2 D.17863;

  D.17863 = 47;
  return D.17863;
}


ves_icall_System_IO_MonoIO_get_DirectorySeparatorChar ()
{
  gunichar2 D.17865;

  D.17865 = 47;
  return D.17865;
}


ves_icall_System_IO_MonoIO_get_AltDirectorySeparatorChar ()
{
  int __mono_io_portability_helpers.33;
  gunichar2 D.17870;

  __mono_io_portability_helpers.33 = __mono_io_portability_helpers;
  if (__mono_io_portability_helpers.33 > 0) goto <D.17868>; else goto <D.17869>;
  <D.17868>:
  D.17870 = 92;
  return D.17870;
  <D.17869>:
  D.17870 = 47;
  return D.17870;
}


ves_icall_System_IO_MonoIO_get_PathSeparator ()
{
  gunichar2 D.17872;

  D.17872 = 58;
  return D.17872;
}


ves_icall_System_IO_MonoIO_get_InvalidPathChars ()
{
  struct MonoClass * D.17874;
  unsigned int n.34;
  unsigned int i.35;
  short unsigned int D.17877;
  struct MonoArray * D.17878;
  struct MonoArray * chars;
  struct MonoDomain * domain;
  int i;
  int n;

  domain = mono_domain_get ();
  n = 1;
  D.17874 = mono_defaults.char_class;
  n.34 = (unsigned int) n;
  chars = mono_array_new (domain, D.17874, n.34);
  i = 0;
  goto <D.17341>;
  <D.17340>:
  {
    gunichar2 * __p;

    i.35 = (unsigned int) i;
    __p = mono_array_addr_with_size (chars, 2, i.35);
    D.17877 = 0;
    *__p = D.17877;
  }
  i = i + 1;
  <D.17341>:
  if (i < n) goto <D.17340>; else goto <D.17342>;
  <D.17342>:
  D.17878 = chars;
  return D.17878;
}


ves_icall_System_IO_MonoIO_GetTempPath (struct MonoString * * mono_name)
{
  unsigned int D.17880;
  int D.17883;
  unsigned int D.17884;
  unsigned int D.17885;
  unsigned int ret.36;
  unsigned int D.17887;
  struct MonoDomain * D.17890;
  struct MonoString * D.17891;
  gint32 D.17892;
  gunichar2 * name;
  int ret;

  name = monoeg_malloc0 (512);
  D.17880 = GetTempPath (256, name);
  ret = (int) D.17880;
  if (ret > 255) goto <D.17881>; else goto <D.17882>;
  <D.17881>:
  monoeg_g_free (name);
  D.17883 = ret + 2;
  D.17884 = (unsigned int) D.17883;
  D.17885 = D.17884 * 2;
  name = monoeg_malloc0 (D.17885);
  ret.36 = (unsigned int) ret;
  D.17887 = GetTempPath (ret.36, name);
  ret = (int) D.17887;
  <D.17882>:
  if (ret > 0) goto <D.17888>; else goto <D.17889>;
  <D.17888>:
  D.17890 = mono_domain_get ();
  D.17891 = mono_string_new_utf16 (D.17890, name, ret);
  mono_gc_wbarrier_generic_store (mono_name, D.17891);
  <D.17889>:
  monoeg_g_free (name);
  D.17892 = ret;
  return D.17892;
}


ves_icall_System_IO_MonoIO_Lock (void * handle, gint64 position, gint64 length, gint32 * error)
{
  unsigned int D.17894;
  long long int D.17895;
  unsigned int D.17896;
  unsigned int D.17897;
  long long int D.17898;
  unsigned int D.17899;
  unsigned int D.17902;
  int D.17903;
  gboolean ret;

  *error = 0;
  D.17894 = (unsigned int) position;
  D.17895 = position >> 32;
  D.17896 = (unsigned int) D.17895;
  D.17897 = (unsigned int) length;
  D.17898 = length >> 32;
  D.17899 = (unsigned int) D.17898;
  ret = LockFile (handle, D.17894, D.17896, D.17897, D.17899);
  if (ret == 0) goto <D.17900>; else goto <D.17901>;
  <D.17900>:
  D.17902 = GetLastError ();
  D.17903 = (int) D.17902;
  *error = D.17903;
  <D.17901>:
}


ves_icall_System_IO_MonoIO_Unlock (void * handle, gint64 position, gint64 length, gint32 * error)
{
  unsigned int D.17904;
  long long int D.17905;
  unsigned int D.17906;
  unsigned int D.17907;
  long long int D.17908;
  unsigned int D.17909;
  unsigned int D.17912;
  int D.17913;
  gboolean ret;

  *error = 0;
  D.17904 = (unsigned int) position;
  D.17905 = position >> 32;
  D.17906 = (unsigned int) D.17905;
  D.17907 = (unsigned int) length;
  D.17908 = length >> 32;
  D.17909 = (unsigned int) D.17908;
  ret = UnlockFile (handle, D.17904, D.17906, D.17907, D.17909);
  if (ret == 0) goto <D.17910>; else goto <D.17911>;
  <D.17910>:
  D.17912 = GetLastError ();
  D.17913 = (int) D.17912;
  *error = D.17913;
  <D.17911>:
}


