_wapi_shm_enabled ()
{
  int env_checked.0;
  const gchar * D.10445;
  gboolean D.10448;
  int _wapi_shm_disabled.1;
  _Bool D.10450;
  static gboolean env_checked;

  env_checked.0 = env_checked;
  if (env_checked.0 == 0) goto <D.10443>; else goto <D.10444>;
  <D.10443>:
  D.10445 = monoeg_g_getenv ("MONO_ENABLE_SHM");
  if (D.10445 != 0B) goto <D.10446>; else goto <D.10447>;
  <D.10446>:
  _wapi_shm_disabled = 0;
  <D.10447>:
  env_checked = 1;
  <D.10444>:
  _wapi_shm_disabled.1 = _wapi_shm_disabled;
  D.10450 = _wapi_shm_disabled.1 == 0;
  D.10448 = (gboolean) D.10450;
  return D.10448;
}


_wapi_shm_attach (_wapi_shm_t type)
{
  void * D.10452;
  int D.10453;
  void * D.10456;
  int size.2;
  int D.10462;
  int * D.10465;
  int D.10466;
  const gchar * D.10467;
  long long int D.10468;
  unsigned int D.10469;
  const gchar * D.10474;
  void * shm_seg;
  int fd;
  struct stat statbuf;
  gchar * filename;
  gchar * shm_name;
  guint32 size;
  static const char __func__[17] = "_wapi_shm_attach";

  try
    {
      filename = _wapi_shm_file (type);
      switch (type) <default: <D.10362>, case 0: <D.10359>, case 1: <D.10361>>
      <D.10359>:
      size = 81928;
      goto <D.10360>;
      <D.10361>:
      size = 4096008;
      goto <D.10360>;
      <D.10362>:
      monoeg_g_log (0B, 4, "Invalid type in _wapi_shm_attach ()");
      <D.10363>:
      goto <D.10363>;
      D.10452 = 0B;
      return D.10452;
      <D.10360>:
      D.10453 = _wapi_shm_enabled ();
      if (D.10453 == 0) goto <D.10454>; else goto <D.10455>;
      <D.10454>:
      D.10456 = monoeg_malloc0 (size);
      wapi_storage[type] = D.10456;
      D.10452 = wapi_storage[type];
      return D.10452;
      <D.10455>:
      shm_name = _wapi_shm_shm_name (type);
      size.2 = (int) size;
      fd = _wapi_shm_open (shm_name, size.2);
      monoeg_g_free (shm_name);
      if (fd == -1) goto <D.10458>; else goto <D.10459>;
      <D.10458>:
      fd = _wapi_shm_file_open (filename, size);
      <D.10459>:
      if (fd == -1) goto <D.10460>; else goto <D.10461>;
      <D.10460>:
      monoeg_g_log (0B, 8, "%s: shared file [%s] open error", &__func__, filename);
      D.10452 = 0B;
      return D.10452;
      <D.10461>:
      D.10462 = fstat (fd, &statbuf);
      if (D.10462 == -1) goto <D.10463>; else goto <D.10464>;
      <D.10463>:
      D.10465 = __errno_location ();
      D.10466 = *D.10465;
      D.10467 = monoeg_g_strerror (D.10466);
      monoeg_g_log (0B, 8, "%s: fstat error: %s", &__func__, D.10467);
      close (fd);
      D.10452 = 0B;
      return D.10452;
      <D.10464>:
      D.10468 = statbuf.st_size;
      D.10469 = (unsigned int) D.10468;
      shm_seg = mmap (0B, D.10469, 3, 1, fd, 0);
      if (shm_seg == 4294967295B) goto <D.10470>; else goto <D.10471>;
      <D.10470>:
      D.10468 = statbuf.st_size;
      D.10469 = (unsigned int) D.10468;
      shm_seg = mmap (0B, D.10469, 3, 2, fd, 0);
      if (shm_seg == 4294967295B) goto <D.10472>; else goto <D.10473>;
      <D.10472>:
      D.10465 = __errno_location ();
      D.10466 = *D.10465;
      D.10474 = monoeg_g_strerror (D.10466);
      monoeg_g_log (0B, 8, "%s: mmap error: %s", &__func__, D.10474);
      close (fd);
      D.10452 = 0B;
      return D.10452;
      <D.10473>:
      <D.10471>:
      close (fd);
      D.10452 = shm_seg;
      return D.10452;
    }
  finally
    {
      statbuf = {CLOBBER};
    }
}


_wapi_shm_file (_wapi_shm_t type)
{
  const gchar * D.10479;
  gchar * D.10481;
  static gchar file[256];
  gchar * name;
  gchar * filename;
  const gchar * wapi_dir;

  name = 0B;
  name = _wapi_shm_base_name (type);
  wapi_dir = monoeg_g_getenv ("MONO_SHARED_DIR");
  if (wapi_dir == 0B) goto <D.10477>; else goto <D.10478>;
  <D.10477>:
  D.10479 = monoeg_g_get_home_dir ();
  filename = monoeg_g_build_path ("/", D.10479, ".wapi", name, 0B);
  goto <D.10480>;
  <D.10478>:
  filename = monoeg_g_build_path ("/", wapi_dir, ".wapi", name, 0B);
  <D.10480>:
  monoeg_g_free (name);
  monoeg_g_snprintf (&file, 256, "%s", filename);
  monoeg_g_free (filename);
  D.10481 = &file;
  return D.10481;
}


_wapi_shm_base_name (_wapi_shm_t type)
{
  int D.10488;
  int iftmp.3;
  unsigned int D.10493;
  unsigned int D.10496;
  unsigned int len.4;
  gchar * D.10500;
  gchar * name;
  gchar machine_name[256];
  const gchar * fake_name;
  struct utsname ubuf;
  int ret;
  int len;

  try
    {
      name = 0B;
      ret = uname (&ubuf);
      if (ret == -1) goto <D.10483>; else goto <D.10484>;
      <D.10483>:
      ubuf.machine[0] = 0;
      ubuf.sysname[0] = 0;
      goto <D.10485>;
      <D.10484>:
      monoeg_g_strdelimit (&ubuf.sysname, "/", 95);
      monoeg_g_strdelimit (&ubuf.machine, "/", 95);
      <D.10485>:
      fake_name = monoeg_g_getenv ("MONO_SHARED_HOSTNAME");
      if (fake_name == 0B) goto <D.10486>; else goto <D.10487>;
      <D.10486>:
      D.10488 = gethostname (&machine_name, 256);
      if (D.10488 != 0) goto <D.10489>; else goto <D.10490>;
      <D.10489>:
      machine_name[0] = 0;
      <D.10490>:
      goto <D.10491>;
      <D.10487>:
      D.10493 = strlen (fake_name);
      if (D.10493 <= 254) goto <D.10494>; else goto <D.10495>;
      <D.10494>:
      D.10496 = strlen (fake_name);
      iftmp.3 = (int) D.10496;
      goto <D.10497>;
      <D.10495>:
      iftmp.3 = 255;
      <D.10497>:
      len = iftmp.3;
      len.4 = (unsigned int) len;
      strncpy (&machine_name, fake_name, len.4);
      machine_name[len] = 0;
      <D.10491>:
      switch (type) <default: <D.10499>, case 0: <D.10311>, case 1: <D.10313>>
      <D.10311>:
      name = monoeg_g_strdup_printf ("shared_data-%s-%s-%s-%d-%d-%d", &machine_name, &ubuf.sysname, &ubuf.machine, 320, 12, 0);
      goto <D.10312>;
      <D.10313>:
      name = monoeg_g_strdup_printf ("shared_fileshare-%s-%s-%s-%d-%d-%d", &machine_name, &ubuf.sysname, &ubuf.machine, 40, 12, 0);
      goto <D.10312>;
      <D.10499>:
      <D.10312>:
      D.10500 = name;
      return D.10500;
    }
  finally
    {
      machine_name = {CLOBBER};
      ubuf = {CLOBBER};
    }
}


gethostname (char * __buf, size_t __buflen)
{
  unsigned int D.10503;
  int D.10506;
  int D.10509;
  unsigned int D.10510;
  unsigned int D.10511;
  unsigned int D.10514;

  D.10503 = __builtin_object_size (__buf, 1);
  if (D.10503 != 4294967295) goto <D.10504>; else goto <D.10505>;
  <D.10504>:
  D.10506 = __builtin_constant_p (__buflen);
  if (D.10506 == 0) goto <D.10507>; else goto <D.10508>;
  <D.10507>:
  D.10510 = __builtin_object_size (__buf, 1);
  D.10509 = __gethostname_chk (__buf, __buflen, D.10510);
  return D.10509;
  <D.10508>:
  D.10511 = __builtin_object_size (__buf, 1);
  if (D.10511 < __buflen) goto <D.10512>; else goto <D.10513>;
  <D.10512>:
  D.10514 = __builtin_object_size (__buf, 1);
  D.10509 = __gethostname_chk_warn (__buf, __buflen, D.10514);
  return D.10509;
  <D.10513>:
  <D.10505>:
  D.10509 = __gethostname_alias (__buf, __buflen);
  return D.10509;
}


strncpy (char * restrict __dest, const char * restrict __src, size_t __len)
{
  char * D.10516;
  unsigned int D.10517;

  D.10517 = __builtin_object_size (__dest, 1);
  D.10516 = __builtin___strncpy_chk (__dest, __src, __len, D.10517);
  return D.10516;
}


_wapi_shm_shm_name (_wapi_shm_t type)
{
  unsigned int D.10519;
  gchar * D.10520;
  char * base_name;
  char * res;

  base_name = _wapi_shm_base_name (type);
  D.10519 = getuid ();
  res = monoeg_g_strdup_printf ("/mono-shared-%d-%s", D.10519, base_name);
  monoeg_g_free (base_name);
  D.10520 = res;
  return D.10520;
}


_wapi_shm_open (const char * filename, int size)
{
  int D.10524;
  long long int D.10525;
  int D.10526;
  int fd;

  fd = shm_open (filename, 258, 416);
  if (fd == -1) goto <D.10522>; else goto <D.10523>;
  <D.10522>:
  D.10524 = -1;
  return D.10524;
  <D.10523>:
  D.10525 = (long long int) size;
  D.10526 = ftruncate (fd, D.10525);
  if (D.10526 != 0) goto <D.10527>; else goto <D.10528>;
  <D.10527>:
  perror ("_wapi_shm_open (): ftruncate ()");
  monoeg_assertion_message ("* Assertion: should not be reached at %s:%d\n", "shared.c", 245);
  <D.10528>:
  D.10524 = fd;
  return D.10524;
}


_wapi_shm_file_open (const gchar * filename, guint32 wanted_size)
{
  int tries.5;
  int D.10533;
  int * D.10539;
  int D.10540;
  const gchar * D.10547;
  unsigned int D.10548;
  long long int D.10549;
  long long int D.10550;
  const gchar * D.10553;
  const gchar * D.10557;
  const gchar * D.10560;
  int D.10561;
  const gchar * D.10564;
  long long int D.10567;
  long long int D.10568;
  long int D.10573;
  int fd;
  struct stat statbuf;
  int ret;
  int tries;
  gboolean created;
  mode_t oldmask;
  gchar * dir;
  void try_again = <<< error >>>;
  static const char __func__[20] = "_wapi_shm_file_open";

  try
    {
      tries = 0;
      created = 0;
      dir = monoeg_g_path_get_dirname (filename);
      mkdir (dir, 493);
      monoeg_g_free (dir);
      try_again:
      tries.5 = tries;
      tries = tries.5 + 1;
      if (tries.5 > 10) goto <D.10531>; else goto <D.10532>;
      <D.10531>:
      D.10533 = -1;
      return D.10533;
      <D.10532>:
      if (tries > 5) goto <D.10534>; else goto <D.10535>;
      <D.10534>:
      unlink (filename);
      <D.10535>:
      oldmask = umask (54);
      fd = open (filename, 2, 384);
      umask (oldmask);
      if (fd == -1) goto <D.10538>; else goto <D.10536>;
      <D.10538>:
      D.10539 = __errno_location ();
      D.10540 = *D.10539;
      if (D.10540 == 2) goto <D.10541>; else goto <D.10536>;
      <D.10541>:
      oldmask = umask (54);
      fd = open (filename, 1282, 384);
      umask (oldmask);
      if (fd == -1) goto <D.10544>; else goto <D.10542>;
      <D.10544>:
      D.10539 = __errno_location ();
      D.10540 = *D.10539;
      if (D.10540 == 17) goto try_again; else goto <D.10542>;
      goto <D.10543>;
      <D.10542>:
      if (fd == -1) goto <D.10545>; else goto <D.10546>;
      <D.10545>:
      D.10539 = __errno_location ();
      D.10540 = *D.10539;
      D.10547 = monoeg_g_strerror (D.10540);
      monoeg_g_log (0B, 8, "%s: shared file [%s] open error: %s", &__func__, filename, D.10547);
      D.10533 = -1;
      return D.10533;
      <D.10546>:
      D.10548 = wanted_size + 4294967295;
      D.10549 = (long long int) D.10548;
      D.10550 = lseek (fd, D.10549, 0);
      if (D.10550 == -1) goto <D.10551>; else goto <D.10552>;
      <D.10551>:
      D.10539 = __errno_location ();
      D.10540 = *D.10539;
      D.10553 = monoeg_g_strerror (D.10540);
      monoeg_g_log (0B, 8, "%s: shared file [%s] lseek error: %s", &__func__, filename, D.10553);
      close (fd);
      unlink (filename);
      D.10533 = -1;
      return D.10533;
      <D.10552>:
      <D.10344>:
      ret = write (fd, "", 1);
      if (ret == -1) goto <D.10554>; else goto <D.10345>;
      <D.10554>:
      D.10539 = __errno_location ();
      D.10540 = *D.10539;
      if (D.10540 == 4) goto <D.10344>; else goto <D.10345>;
      <D.10345>:
      if (ret == -1) goto <D.10555>; else goto <D.10556>;
      <D.10555>:
      D.10539 = __errno_location ();
      D.10540 = *D.10539;
      D.10557 = monoeg_g_strerror (D.10540);
      monoeg_g_log (0B, 8, "%s: shared file [%s] write error: %s", &__func__, filename, D.10557);
      close (fd);
      unlink (filename);
      D.10533 = -1;
      return D.10533;
      <D.10556>:
      created = 1;
      <D.10543>:
      goto <D.10537>;
      <D.10536>:
      if (fd == -1) goto <D.10558>; else goto <D.10559>;
      <D.10558>:
      D.10539 = __errno_location ();
      D.10540 = *D.10539;
      D.10560 = monoeg_g_strerror (D.10540);
      monoeg_g_log (0B, 8, "%s: shared file [%s] open error: %s", &__func__, filename, D.10560);
      D.10533 = -1;
      return D.10533;
      <D.10559>:
      <D.10537>:
      D.10561 = fstat (fd, &statbuf);
      if (D.10561 == -1) goto <D.10562>; else goto <D.10563>;
      <D.10562>:
      D.10539 = __errno_location ();
      D.10540 = *D.10539;
      D.10564 = monoeg_g_strerror (D.10540);
      monoeg_g_log (0B, 8, "%s: fstat error: %s", &__func__, D.10564);
      if (created == 1) goto <D.10565>; else goto <D.10566>;
      <D.10565>:
      unlink (filename);
      <D.10566>:
      close (fd);
      D.10533 = -1;
      return D.10533;
      <D.10563>:
      D.10567 = statbuf.st_size;
      D.10568 = (long long int) wanted_size;
      if (D.10567 < D.10568) goto <D.10569>; else goto <D.10570>;
      <D.10569>:
      close (fd);
      if (created == 1) goto <D.10571>; else goto <D.10572>;
      <D.10571>:
      D.10567 = statbuf.st_size;
      D.10573 = (long int) D.10567;
      monoeg_g_log (0B, 8, "%s: shared file [%s] is not big enough! (found %ld, need %d bytes)", &__func__, filename, D.10573, wanted_size);
      unlink (filename);
      D.10533 = -1;
      return D.10533;
      <D.10572>:
      _wapi_handle_spin (100);
      goto try_again;
      <D.10570>:
      D.10533 = fd;
      return D.10533;
    }
  finally
    {
      statbuf = {CLOBBER};
    }
}


open (const char * __path, int __oflag)
{
  int D.10576;
  int D.10579;
  int D.10584;
  int D.10586;
  int D.10587;
  int D.10590;
  int D.10591;

  D.10576 = __builtin_va_arg_pack_len ();
  if (D.10576 > 1) goto <D.10577>; else goto <D.10578>;
  <D.10577>:
  __open_too_many_args ();
  <D.10578>:
  D.10579 = __builtin_constant_p (__oflag);
  if (D.10579 != 0) goto <D.10580>; else goto <D.10581>;
  <D.10580>:
  D.10584 = __oflag & 256;
  if (D.10584 != 0) goto <D.10582>; else goto <D.10585>;
  <D.10585>:
  D.10586 = __oflag & 4259840;
  if (D.10586 == 4259840) goto <D.10582>; else goto <D.10583>;
  <D.10582>:
  D.10587 = __builtin_va_arg_pack_len ();
  if (D.10587 <= 0) goto <D.10588>; else goto <D.10589>;
  <D.10588>:
  __open_missing_mode ();
  D.10590 = __open_2 (__path, __oflag);
  return D.10590;
  <D.10589>:
  <D.10583>:
  D.10590 = __open_alias (__path, __oflag, __builtin_va_arg_pack ());
  return D.10590;
  <D.10581>:
  D.10591 = __builtin_va_arg_pack_len ();
  if (D.10591 <= 0) goto <D.10592>; else goto <D.10593>;
  <D.10592>:
  D.10590 = __open_2 (__path, __oflag);
  return D.10590;
  <D.10593>:
  D.10590 = __open_alias (__path, __oflag, __builtin_va_arg_pack ());
  return D.10590;
}


_wapi_handle_spin (guint32 ms)
{
  _Bool D.10595;
  long int D.10596;
  long int D.10597;
  unsigned int D.10600;
  long int D.10601;
  struct timespec sleepytime;

  try
    {
      D.10595 = ms > 999;
      D.10596 = (long int) D.10595;
      D.10597 = __builtin_expect (D.10596, 0);
      if (D.10597 != 0) goto <D.10598>; else goto <D.10599>;
      <D.10598>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "../../mono/io-layer/handles-private.h", 326, "ms < 1000");
      <D.10599>:
      sleepytime.tv_sec = 0;
      D.10600 = ms * 1000000;
      D.10601 = (long int) D.10600;
      sleepytime.tv_nsec = D.10601;
      nanosleep (&sleepytime, 0B);
    }
  finally
    {
      sleepytime = {CLOBBER};
    }
}


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

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


_wapi_shm_detach (_wapi_shm_t type)
{
  int D.10604;
  void * D.10607;

  D.10604 = _wapi_shm_enabled ();
  if (D.10604 == 0) goto <D.10605>; else goto <D.10606>;
  <D.10605>:
  D.10607 = wapi_storage[type];
  monoeg_g_free (D.10607);
  <D.10606>:
}


_wapi_shm_semaphores_init ()
{
  int D.10608;

  D.10608 = _wapi_shm_enabled ();
  if (D.10608 == 0) goto <D.10609>; else goto <D.10610>;
  <D.10609>:
  noshm_semaphores_init ();
  goto <D.10611>;
  <D.10610>:
  shm_semaphores_init ();
  <D.10611>:
}


noshm_semaphores_init ()
{
  union mono_mutex_t * D.10612;
  int i;

  i = 0;
  goto <D.10288>;
  <D.10287>:
  D.10612 = &noshm_sems[i];
  pthread_mutex_init (D.10612, 0B);
  i = i + 1;
  <D.10288>:
  if (i <= 7) goto <D.10287>; else goto <D.10289>;
  <D.10289>:
}


shm_semaphores_init ()
{
  _Bool D.10613;
  long int D.10614;
  long int D.10615;
  _Bool D.10618;
  long int D.10619;
  long int D.10620;
  int * D.10625;
  int D.10626;
  const gchar * D.10629;
  const gchar * D.10632;
  const gchar * D.10637;
  int _wapi_sem_id.6;
  int _wapi_sem_id.7;
  int D.10640;
  const gchar * D.10645;
  volatile key_t * D.10646;
  int D.10647;
  int _wapi_sem_id.8;
  const gchar * D.10654;
  volatile key_t * D.10655;
  _Bool D.10656;
  long int D.10657;
  long int D.10658;
  int _wapi_shm_disabled.9;
  key_t key;
  key_t oldkey;
  int thr_ret;
  struct _WapiHandleSharedLayout * tmp_shared;
  gchar * ftmp;
  gchar * filename;
  typedef union semun unionunion semun;
  union semun defs;
  ushort def_vals[8];
  int i;
  int retries;
  void again = <<< error >>>;
  static const char __func__[20] = "shm_semaphores_init";
  void done = <<< error >>>;

  try
    {
      retries = 0;
      i = 0;
      goto <D.10386>;
      <D.10385>:
      def_vals[i] = 1;
      i = i + 1;
      <D.10386>:
      if (i <= 7) goto <D.10385>; else goto <D.10387>;
      <D.10387>:
      def_vals[7] = 0;
      defs.array = &def_vals;
      tmp_shared = _wapi_shm_attach (0);
      D.10613 = tmp_shared == 0B;
      D.10614 = (long int) D.10613;
      D.10615 = __builtin_expect (D.10614, 0);
      if (D.10615 != 0) goto <D.10616>; else goto <D.10617>;
      <D.10616>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "shared.c", 547, "tmp_shared != NULL");
      <D.10617>:
      ftmp = _wapi_shm_shm_name (0);
      filename = monoeg_g_build_path ("/", "/dev/shm", ftmp, 0B);
      D.10618 = filename == 0B;
      D.10619 = (long int) D.10618;
      D.10620 = __builtin_expect (D.10619, 0);
      if (D.10620 != 0) goto <D.10621>; else goto <D.10622>;
      <D.10621>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "shared.c", 552, "filename!=NULL");
      <D.10622>:
      key = ftok (filename, 77);
      monoeg_g_free (ftmp);
      monoeg_g_free (filename);
      again:
      retries = retries + 1;
      oldkey = tmp_shared->sem_key;
      if (oldkey == 0) goto <D.10623>; else goto <D.10624>;
      <D.10623>:
      goto <D.10393>;
      <D.10392>:
      D.10625 = __errno_location ();
      D.10626 = *D.10625;
      if (D.10626 == 12) goto <D.10627>; else goto <D.10628>;
      <D.10627>:
      D.10625 = __errno_location ();
      D.10626 = *D.10625;
      D.10629 = monoeg_g_strerror (D.10626);
      monoeg_g_log (0B, 4, "%s: semget error: %s", &__func__, D.10629);
      <D.10390>:
      goto <D.10390>;
      <D.10628>:
      D.10625 = __errno_location ();
      D.10626 = *D.10625;
      if (D.10626 == 28) goto <D.10630>; else goto <D.10631>;
      <D.10630>:
      D.10625 = __errno_location ();
      D.10626 = *D.10625;
      D.10632 = monoeg_g_strerror (D.10626);
      monoeg_g_log (0B, 4, "%s: semget error: %s.  Try deleting some semaphores with ipcs and ipcrm\nor increase the maximum number of semaphore in the system.", &__func__, D.10632);
      <D.10391>:
      goto <D.10391>;
      <D.10631>:
      D.10625 = __errno_location ();
      D.10626 = *D.10625;
      if (D.10626 != 17) goto <D.10633>; else goto <D.10634>;
      <D.10633>:
      if (retries > 3) goto <D.10635>; else goto <D.10636>;
      <D.10635>:
      D.10625 = __errno_location ();
      D.10626 = *D.10625;
      D.10637 = monoeg_g_strerror (D.10626);
      monoeg_g_log (0B, 16, "%s: semget error: %s key 0x%x - trying again", &__func__, D.10637, key);
      <D.10636>:
      <D.10634>:
      key = key + 1;
      <D.10393>:
      _wapi_sem_id.6 = semget (key, 8, 1920);
      _wapi_sem_id = _wapi_sem_id.6;
      _wapi_sem_id.7 = _wapi_sem_id;
      if (_wapi_sem_id.7 == -1) goto <D.10392>; else goto <D.10394>;
      <D.10394>:
      _wapi_sem_id.7 = _wapi_sem_id;
      D.10640 = semctl (_wapi_sem_id.7, 0, 17, defs);
      if (D.10640 == -1) goto <D.10641>; else goto <D.10642>;
      <D.10641>:
      if (retries > 3) goto <D.10643>; else goto <D.10644>;
      <D.10643>:
      D.10625 = __errno_location ();
      D.10626 = *D.10625;
      D.10645 = monoeg_g_strerror (D.10626);
      monoeg_g_log (0B, 16, "%s: semctl init error: %s - trying again", &__func__, D.10645);
      <D.10644>:
      _wapi_sem_id.7 = _wapi_sem_id;
      semctl (_wapi_sem_id.7, 0, 0);
      goto again;
      <D.10642>:
      D.10646 = &tmp_shared->sem_key;
      D.10647 = InterlockedCompareExchange (D.10646, key, 0);
      if (D.10647 != 0) goto <D.10648>; else goto done;
      <D.10648>:
      _wapi_sem_id.7 = _wapi_sem_id;
      semctl (_wapi_sem_id.7, 0, 0);
      oldkey = tmp_shared->sem_key;
      <D.10624>:
      _wapi_sem_id.8 = semget (oldkey, 8, 384);
      _wapi_sem_id = _wapi_sem_id.8;
      _wapi_sem_id.7 = _wapi_sem_id;
      if (_wapi_sem_id.7 == -1) goto <D.10650>; else goto <D.10651>;
      <D.10650>:
      if (retries > 3) goto <D.10652>; else goto <D.10653>;
      <D.10652>:
      D.10625 = __errno_location ();
      D.10626 = *D.10625;
      D.10654 = monoeg_g_strerror (D.10626);
      monoeg_g_log (0B, 16, "%s: semget error opening old key 0x%x (%s) - trying again", &__func__, oldkey, D.10654);
      <D.10653>:
      D.10655 = &tmp_shared->sem_key;
      InterlockedCompareExchange (D.10655, 0, oldkey);
      goto again;
      <D.10651>:
      done:
      thr_ret = _wapi_shm_sem_lock (6);
      D.10656 = thr_ret != 0;
      D.10657 = (long int) D.10656;
      D.10658 = __builtin_expect (D.10657, 0);
      if (D.10658 != 0) goto <D.10659>; else goto <D.10660>;
      <D.10659>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "shared.c", 645, "thr_ret == 0");
      <D.10660>:
      _wapi_shm_sem_unlock (7);
      _wapi_shm_sem_unlock (6);
      _wapi_shm_disabled.9 = _wapi_shm_disabled;
      if (_wapi_shm_disabled.9 != 0) goto <D.10662>; else goto <D.10663>;
      <D.10662>:
      monoeg_g_free (tmp_shared);
      goto <D.10664>;
      <D.10663>:
      munmap (tmp_shared, 81928);
      <D.10664>:
    }
  finally
    {
      defs = {CLOBBER};
      def_vals = {CLOBBER};
    }
}


InterlockedCompareExchange (volatile gint32 * dest, gint32 exch, gint32 comp)
{
  gint32 D.10665;
  unsigned int comp.10;
  unsigned int exch.11;
  unsigned int D.10668;

  comp.10 = (unsigned int) comp;
  exch.11 = (unsigned int) exch;
  D.10668 = __sync_val_compare_and_swap_4 (dest, comp.10, exch.11);
  D.10665 = (gint32) D.10668;
  return D.10665;
}


_wapi_shm_semaphores_remove ()
{
  int _wapi_shm_disabled.12;

  _wapi_shm_disabled.12 = _wapi_shm_disabled;
  if (_wapi_shm_disabled.12 == 0) goto <D.10671>; else goto <D.10672>;
  <D.10671>:
  shm_semaphores_remove ();
  <D.10672>:
}


shm_semaphores_remove ()
{
  _Bool D.10673;
  long int D.10674;
  long int D.10675;
  int _wapi_sem_id.13;
  _Bool D.10679;
  long int D.10680;
  long int D.10681;
  gchar * D.10686;
  gchar * D.10687;
  int thr_ret;
  int proc_count;
  gchar * shm_name;

  thr_ret = _wapi_shm_sem_lock (6);
  D.10673 = thr_ret != 0;
  D.10674 = (long int) D.10673;
  D.10675 = __builtin_expect (D.10674, 0);
  if (D.10675 != 0) goto <D.10676>; else goto <D.10677>;
  <D.10676>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "shared.c", 678, "thr_ret == 0");
  <D.10677>:
  _wapi_sem_id.13 = _wapi_sem_id;
  proc_count = semctl (_wapi_sem_id.13, 7, 12);
  D.10679 = proc_count <= 0;
  D.10680 = (long int) D.10679;
  D.10681 = __builtin_expect (D.10680, 0);
  if (D.10681 != 0) goto <D.10682>; else goto <D.10683>;
  <D.10682>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "shared.c", 683, "proc_count > 0");
  <D.10683>:
  if (proc_count == 1) goto <D.10684>; else goto <D.10685>;
  <D.10684>:
  _wapi_sem_id.13 = _wapi_sem_id;
  semctl (_wapi_sem_id.13, 0, 0);
  shm_name = _wapi_shm_shm_name (0);
  shm_unlink (shm_name);
  monoeg_g_free (shm_name);
  shm_name = _wapi_shm_shm_name (1);
  shm_unlink (shm_name);
  monoeg_g_free (shm_name);
  D.10686 = _wapi_shm_file (0);
  unlink (D.10686);
  D.10687 = _wapi_shm_file (1);
  unlink (D.10687);
  goto <D.10688>;
  <D.10685>:
  _wapi_shm_sem_unlock (6);
  <D.10688>:
}


_wapi_shm_sem_lock (int sem)
{
  int _wapi_shm_disabled.14;
  int D.10692;

  _wapi_shm_disabled.14 = _wapi_shm_disabled;
  if (_wapi_shm_disabled.14 != 0) goto <D.10690>; else goto <D.10691>;
  <D.10690>:
  D.10692 = noshm_sem_lock (sem);
  return D.10692;
  <D.10691>:
  D.10692 = shm_sem_lock (sem);
  return D.10692;
}


noshm_sem_lock (int sem)
{
  union mono_mutex_t * D.10694;
  int D.10695;
  int ret;

  D.10694 = &noshm_sems[sem];
  ret = pthread_mutex_lock (D.10694);
  D.10695 = ret;
  return D.10695;
}


shm_sem_lock (int sem)
{
  short unsigned int D.10697;
  int _wapi_sem_id.15;
  int * D.10700;
  int D.10701;
  int D.10707;
  struct sembuf ops;
  int ret;
  void retry = <<< error >>>;

  try
    {
      D.10697 = (short unsigned int) sem;
      ops.sem_num = D.10697;
      ops.sem_op = -1;
      ops.sem_flg = 4096;
      retry:
      <D.10408>:
      _wapi_sem_id.15 = _wapi_sem_id;
      ret = semop (_wapi_sem_id.15, &ops, 1);
      if (ret == -1) goto <D.10699>; else goto <D.10409>;
      <D.10699>:
      D.10700 = __errno_location ();
      D.10701 = *D.10700;
      if (D.10701 == 4) goto <D.10408>; else goto <D.10409>;
      <D.10409>:
      if (ret == -1) goto <D.10702>; else goto <D.10703>;
      <D.10702>:
      D.10700 = __errno_location ();
      D.10701 = *D.10700;
      if (D.10701 == 36) goto <D.10704>; else goto <D.10706>;
      <D.10706>:
      D.10700 = __errno_location ();
      D.10701 = *D.10700;
      if (D.10701 == 22) goto <D.10704>; else goto <D.10705>;
      <D.10704>:
      _wapi_shm_semaphores_init ();
      goto retry;
      <D.10705>:
      D.10700 = __errno_location ();
      ret = *D.10700;
      <D.10703>:
      D.10707 = ret;
      return D.10707;
    }
  finally
    {
      ops = {CLOBBER};
    }
}


_wapi_shm_sem_trylock (int sem)
{
  int _wapi_shm_disabled.16;
  int D.10713;

  _wapi_shm_disabled.16 = _wapi_shm_disabled;
  if (_wapi_shm_disabled.16 != 0) goto <D.10711>; else goto <D.10712>;
  <D.10711>:
  D.10713 = noshm_sem_trylock (sem);
  return D.10713;
  <D.10712>:
  D.10713 = shm_sem_trylock (sem);
  return D.10713;
}


noshm_sem_trylock (int sem)
{
  union mono_mutex_t * D.10715;
  int D.10716;
  int ret;

  D.10715 = &noshm_sems[sem];
  ret = pthread_mutex_trylock (D.10715);
  D.10716 = ret;
  return D.10716;
}


shm_sem_trylock (int sem)
{
  short unsigned int D.10718;
  int _wapi_sem_id.17;
  int * D.10721;
  int D.10722;
  int D.10730;
  struct sembuf ops;
  int ret;
  void retry = <<< error >>>;

  try
    {
      D.10718 = (short unsigned int) sem;
      ops.sem_num = D.10718;
      ops.sem_op = -1;
      ops.sem_flg = 6144;
      retry:
      <D.10416>:
      _wapi_sem_id.17 = _wapi_sem_id;
      ret = semop (_wapi_sem_id.17, &ops, 1);
      if (ret == -1) goto <D.10720>; else goto <D.10417>;
      <D.10720>:
      D.10721 = __errno_location ();
      D.10722 = *D.10721;
      if (D.10722 == 4) goto <D.10416>; else goto <D.10417>;
      <D.10417>:
      if (ret == -1) goto <D.10723>; else goto <D.10724>;
      <D.10723>:
      D.10721 = __errno_location ();
      D.10722 = *D.10721;
      if (D.10722 == 36) goto <D.10725>; else goto <D.10727>;
      <D.10727>:
      D.10721 = __errno_location ();
      D.10722 = *D.10721;
      if (D.10722 == 22) goto <D.10725>; else goto <D.10726>;
      <D.10725>:
      _wapi_shm_semaphores_init ();
      goto retry;
      <D.10726>:
      D.10721 = __errno_location ();
      ret = *D.10721;
      <D.10724>:
      if (ret == 11) goto <D.10728>; else goto <D.10729>;
      <D.10728>:
      ret = 16;
      <D.10729>:
      D.10730 = ret;
      return D.10730;
    }
  finally
    {
      ops = {CLOBBER};
    }
}


_wapi_shm_sem_unlock (int sem)
{
  int _wapi_shm_disabled.18;
  int D.10736;

  _wapi_shm_disabled.18 = _wapi_shm_disabled;
  if (_wapi_shm_disabled.18 != 0) goto <D.10734>; else goto <D.10735>;
  <D.10734>:
  D.10736 = noshm_sem_unlock (sem);
  return D.10736;
  <D.10735>:
  D.10736 = shm_sem_unlock (sem);
  return D.10736;
}


noshm_sem_unlock (int sem)
{
  union mono_mutex_t * D.10738;
  int D.10739;
  int ret;

  D.10738 = &noshm_sems[sem];
  ret = pthread_mutex_unlock (D.10738);
  D.10739 = ret;
  return D.10739;
}


shm_sem_unlock (int sem)
{
  short unsigned int D.10741;
  int _wapi_sem_id.19;
  int * D.10744;
  int D.10745;
  int D.10751;
  struct sembuf ops;
  int ret;
  void retry = <<< error >>>;

  try
    {
      D.10741 = (short unsigned int) sem;
      ops.sem_num = D.10741;
      ops.sem_op = 1;
      ops.sem_flg = 4096;
      retry:
      <D.10424>:
      _wapi_sem_id.19 = _wapi_sem_id;
      ret = semop (_wapi_sem_id.19, &ops, 1);
      if (ret == -1) goto <D.10743>; else goto <D.10425>;
      <D.10743>:
      D.10744 = __errno_location ();
      D.10745 = *D.10744;
      if (D.10745 == 4) goto <D.10424>; else goto <D.10425>;
      <D.10425>:
      if (ret == -1) goto <D.10746>; else goto <D.10747>;
      <D.10746>:
      D.10744 = __errno_location ();
      D.10745 = *D.10744;
      if (D.10745 == 36) goto <D.10748>; else goto <D.10750>;
      <D.10750>:
      D.10744 = __errno_location ();
      D.10745 = *D.10744;
      if (D.10745 == 22) goto <D.10748>; else goto <D.10749>;
      <D.10748>:
      _wapi_shm_semaphores_init ();
      goto retry;
      <D.10749>:
      D.10744 = __errno_location ();
      ret = *D.10744;
      <D.10747>:
      D.10751 = ret;
      return D.10751;
    }
  finally
    {
      ops = {CLOBBER};
    }
}


