_wapi_shm_enabled ()
{
  int env_checked.0;
  const gchar * D.10751;
  gboolean D.10754;
  int _wapi_shm_disabled.1;
  _Bool D.10756;
  static gboolean env_checked;

  env_checked.0 = env_checked;
  if (env_checked.0 == 0) goto <D.10749>; else goto <D.10750>;
  <D.10749>:
  D.10751 = monoeg_g_getenv ("MONO_ENABLE_SHM");
  if (D.10751 != 0B) goto <D.10752>; else goto <D.10753>;
  <D.10752>:
  _wapi_shm_disabled = 0;
  <D.10753>:
  env_checked = 1;
  <D.10750>:
  _wapi_shm_disabled.1 = _wapi_shm_disabled;
  D.10756 = _wapi_shm_disabled.1 == 0;
  D.10754 = (gboolean) D.10756;
  return D.10754;
}


_wapi_shm_attach (_wapi_shm_t type)
{
  void * D.10758;
  int D.10759;
  long unsigned int D.10762;
  void * D.10763;
  int size.2;
  int D.10769;
  int * D.10772;
  int D.10773;
  const gchar * D.10774;
  long int D.10775;
  long unsigned int D.10776;
  const gchar * D.10781;
  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.10668>, case 0: <D.10665>, case 1: <D.10667>>
      <D.10665>:
      size = 86024;
      goto <D.10666>;
      <D.10667>:
      size = 4096008;
      goto <D.10666>;
      <D.10668>:
      monoeg_g_log (0B, 4, "Invalid type in _wapi_shm_attach ()");
      <D.10669>:
      goto <D.10669>;
      D.10758 = 0B;
      return D.10758;
      <D.10666>:
      D.10759 = _wapi_shm_enabled ();
      if (D.10759 == 0) goto <D.10760>; else goto <D.10761>;
      <D.10760>:
      D.10762 = (long unsigned int) size;
      D.10763 = monoeg_malloc0 (D.10762);
      wapi_storage[type] = D.10763;
      D.10758 = wapi_storage[type];
      return D.10758;
      <D.10761>:
      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.10765>; else goto <D.10766>;
      <D.10765>:
      fd = _wapi_shm_file_open (filename, size);
      <D.10766>:
      if (fd == -1) goto <D.10767>; else goto <D.10768>;
      <D.10767>:
      monoeg_g_log (0B, 8, "%s: shared file [%s] open error", &__func__, filename);
      D.10758 = 0B;
      return D.10758;
      <D.10768>:
      D.10769 = fstat (fd, &statbuf);
      if (D.10769 == -1) goto <D.10770>; else goto <D.10771>;
      <D.10770>:
      D.10772 = __errno_location ();
      D.10773 = *D.10772;
      D.10774 = monoeg_g_strerror (D.10773);
      monoeg_g_log (0B, 8, "%s: fstat error: %s", &__func__, D.10774);
      close (fd);
      D.10758 = 0B;
      return D.10758;
      <D.10771>:
      D.10775 = statbuf.st_size;
      D.10776 = (long unsigned int) D.10775;
      shm_seg = mmap (0B, D.10776, 3, 1, fd, 0);
      if (shm_seg == -1B) goto <D.10777>; else goto <D.10778>;
      <D.10777>:
      D.10775 = statbuf.st_size;
      D.10776 = (long unsigned int) D.10775;
      shm_seg = mmap (0B, D.10776, 3, 2, fd, 0);
      if (shm_seg == -1B) goto <D.10779>; else goto <D.10780>;
      <D.10779>:
      D.10772 = __errno_location ();
      D.10773 = *D.10772;
      D.10781 = monoeg_g_strerror (D.10773);
      monoeg_g_log (0B, 8, "%s: mmap error: %s", &__func__, D.10781);
      close (fd);
      D.10758 = 0B;
      return D.10758;
      <D.10780>:
      <D.10778>:
      close (fd);
      D.10758 = shm_seg;
      return D.10758;
    }
  finally
    {
      statbuf = {CLOBBER};
    }
}


_wapi_shm_file (_wapi_shm_t type)
{
  const gchar * D.10786;
  gchar * D.10788;
  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.10784>; else goto <D.10785>;
  <D.10784>:
  D.10786 = monoeg_g_get_home_dir ();
  filename = monoeg_g_build_path ("/", D.10786, ".wapi", name, 0B);
  goto <D.10787>;
  <D.10785>:
  filename = monoeg_g_build_path ("/", wapi_dir, ".wapi", name, 0B);
  <D.10787>:
  monoeg_g_free (name);
  monoeg_g_snprintf (&file, 256, "%s", filename);
  monoeg_g_free (filename);
  D.10788 = &file;
  return D.10788;
}


_wapi_shm_base_name (_wapi_shm_t type)
{
  int D.10795;
  int iftmp.3;
  long unsigned int D.10800;
  long unsigned int D.10803;
  long unsigned int D.10805;
  gchar * D.10807;
  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.10790>; else goto <D.10791>;
      <D.10790>:
      ubuf.machine[0] = 0;
      ubuf.sysname[0] = 0;
      goto <D.10792>;
      <D.10791>:
      monoeg_g_strdelimit (&ubuf.sysname, "/", 95);
      monoeg_g_strdelimit (&ubuf.machine, "/", 95);
      <D.10792>:
      fake_name = monoeg_g_getenv ("MONO_SHARED_HOSTNAME");
      if (fake_name == 0B) goto <D.10793>; else goto <D.10794>;
      <D.10793>:
      D.10795 = gethostname (&machine_name, 256);
      if (D.10795 != 0) goto <D.10796>; else goto <D.10797>;
      <D.10796>:
      machine_name[0] = 0;
      <D.10797>:
      goto <D.10798>;
      <D.10794>:
      D.10800 = strlen (fake_name);
      if (D.10800 <= 254) goto <D.10801>; else goto <D.10802>;
      <D.10801>:
      D.10803 = strlen (fake_name);
      iftmp.3 = (int) D.10803;
      goto <D.10804>;
      <D.10802>:
      iftmp.3 = 255;
      <D.10804>:
      len = iftmp.3;
      D.10805 = (long unsigned int) len;
      strncpy (&machine_name, fake_name, D.10805);
      machine_name[len] = 0;
      <D.10798>:
      switch (type) <default: <D.10806>, case 0: <D.10617>, case 1: <D.10619>>
      <D.10617>:
      name = monoeg_g_strdup_printf ("shared_data-%s-%s-%s-%d-%d-%d", &machine_name, &ubuf.sysname, &ubuf.machine, 336, 12, 0);
      goto <D.10618>;
      <D.10619>:
      name = monoeg_g_strdup_printf ("shared_fileshare-%s-%s-%s-%d-%d-%d", &machine_name, &ubuf.sysname, &ubuf.machine, 40, 12, 0);
      goto <D.10618>;
      <D.10806>:
      <D.10618>:
      D.10807 = name;
      return D.10807;
    }
  finally
    {
      machine_name = {CLOBBER};
      ubuf = {CLOBBER};
    }
}


gethostname (char * __buf, size_t __buflen)
{
  long unsigned int D.10810;
  int D.10813;
  int D.10816;
  long unsigned int D.10817;
  long unsigned int D.10818;
  long unsigned int D.10821;

  D.10810 = __builtin_object_size (__buf, 1);
  if (D.10810 != 18446744073709551615) goto <D.10811>; else goto <D.10812>;
  <D.10811>:
  D.10813 = __builtin_constant_p (__buflen);
  if (D.10813 == 0) goto <D.10814>; else goto <D.10815>;
  <D.10814>:
  D.10817 = __builtin_object_size (__buf, 1);
  D.10816 = __gethostname_chk (__buf, __buflen, D.10817);
  return D.10816;
  <D.10815>:
  D.10818 = __builtin_object_size (__buf, 1);
  if (D.10818 < __buflen) goto <D.10819>; else goto <D.10820>;
  <D.10819>:
  D.10821 = __builtin_object_size (__buf, 1);
  D.10816 = __gethostname_chk_warn (__buf, __buflen, D.10821);
  return D.10816;
  <D.10820>:
  <D.10812>:
  D.10816 = __gethostname_alias (__buf, __buflen);
  return D.10816;
}


strncpy (char * restrict __dest, const char * restrict __src, size_t __len)
{
  char * D.10823;
  long unsigned int D.10824;

  D.10824 = __builtin_object_size (__dest, 1);
  D.10823 = __builtin___strncpy_chk (__dest, __src, __len, D.10824);
  return D.10823;
}


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

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


_wapi_shm_open (const char * filename, int size)
{
  int D.10831;
  long int D.10832;
  int D.10833;
  int fd;

  fd = shm_open (filename, 66, 416);
  if (fd == -1) goto <D.10829>; else goto <D.10830>;
  <D.10829>:
  D.10831 = -1;
  return D.10831;
  <D.10830>:
  D.10832 = (long int) size;
  D.10833 = ftruncate (fd, D.10832);
  if (D.10833 != 0) goto <D.10834>; else goto <D.10835>;
  <D.10834>:
  perror ("_wapi_shm_open (): ftruncate ()");
  monoeg_assertion_message ("* Assertion: should not be reached at %s:%d\n", "shared.c", 245);
  <D.10835>:
  D.10831 = fd;
  return D.10831;
}


_wapi_shm_file_open (const gchar * filename, guint32 wanted_size)
{
  int tries.4;
  int D.10840;
  int * D.10846;
  int D.10847;
  const gchar * D.10854;
  unsigned int D.10855;
  long int D.10856;
  long int D.10857;
  const gchar * D.10860;
  long int D.10861;
  const gchar * D.10865;
  const gchar * D.10868;
  int D.10869;
  const gchar * D.10872;
  long int D.10875;
  long int D.10876;
  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.4 = tries;
      tries = tries.4 + 1;
      if (tries.4 > 10) goto <D.10838>; else goto <D.10839>;
      <D.10838>:
      D.10840 = -1;
      return D.10840;
      <D.10839>:
      if (tries > 5) goto <D.10841>; else goto <D.10842>;
      <D.10841>:
      unlink (filename);
      <D.10842>:
      oldmask = umask (54);
      fd = open (filename, 2, 384);
      umask (oldmask);
      if (fd == -1) goto <D.10845>; else goto <D.10843>;
      <D.10845>:
      D.10846 = __errno_location ();
      D.10847 = *D.10846;
      if (D.10847 == 2) goto <D.10848>; else goto <D.10843>;
      <D.10848>:
      oldmask = umask (54);
      fd = open (filename, 194, 384);
      umask (oldmask);
      if (fd == -1) goto <D.10851>; else goto <D.10849>;
      <D.10851>:
      D.10846 = __errno_location ();
      D.10847 = *D.10846;
      if (D.10847 == 17) goto try_again; else goto <D.10849>;
      goto <D.10850>;
      <D.10849>:
      if (fd == -1) goto <D.10852>; else goto <D.10853>;
      <D.10852>:
      D.10846 = __errno_location ();
      D.10847 = *D.10846;
      D.10854 = monoeg_g_strerror (D.10847);
      monoeg_g_log (0B, 8, "%s: shared file [%s] open error: %s", &__func__, filename, D.10854);
      D.10840 = -1;
      return D.10840;
      <D.10853>:
      D.10855 = wanted_size + 4294967295;
      D.10856 = (long int) D.10855;
      D.10857 = lseek (fd, D.10856, 0);
      if (D.10857 == -1) goto <D.10858>; else goto <D.10859>;
      <D.10858>:
      D.10846 = __errno_location ();
      D.10847 = *D.10846;
      D.10860 = monoeg_g_strerror (D.10847);
      monoeg_g_log (0B, 8, "%s: shared file [%s] lseek error: %s", &__func__, filename, D.10860);
      close (fd);
      unlink (filename);
      D.10840 = -1;
      return D.10840;
      <D.10859>:
      <D.10650>:
      D.10861 = write (fd, "", 1);
      ret = (int) D.10861;
      if (ret == -1) goto <D.10862>; else goto <D.10651>;
      <D.10862>:
      D.10846 = __errno_location ();
      D.10847 = *D.10846;
      if (D.10847 == 4) goto <D.10650>; else goto <D.10651>;
      <D.10651>:
      if (ret == -1) goto <D.10863>; else goto <D.10864>;
      <D.10863>:
      D.10846 = __errno_location ();
      D.10847 = *D.10846;
      D.10865 = monoeg_g_strerror (D.10847);
      monoeg_g_log (0B, 8, "%s: shared file [%s] write error: %s", &__func__, filename, D.10865);
      close (fd);
      unlink (filename);
      D.10840 = -1;
      return D.10840;
      <D.10864>:
      created = 1;
      <D.10850>:
      goto <D.10844>;
      <D.10843>:
      if (fd == -1) goto <D.10866>; else goto <D.10867>;
      <D.10866>:
      D.10846 = __errno_location ();
      D.10847 = *D.10846;
      D.10868 = monoeg_g_strerror (D.10847);
      monoeg_g_log (0B, 8, "%s: shared file [%s] open error: %s", &__func__, filename, D.10868);
      D.10840 = -1;
      return D.10840;
      <D.10867>:
      <D.10844>:
      D.10869 = fstat (fd, &statbuf);
      if (D.10869 == -1) goto <D.10870>; else goto <D.10871>;
      <D.10870>:
      D.10846 = __errno_location ();
      D.10847 = *D.10846;
      D.10872 = monoeg_g_strerror (D.10847);
      monoeg_g_log (0B, 8, "%s: fstat error: %s", &__func__, D.10872);
      if (created == 1) goto <D.10873>; else goto <D.10874>;
      <D.10873>:
      unlink (filename);
      <D.10874>:
      close (fd);
      D.10840 = -1;
      return D.10840;
      <D.10871>:
      D.10875 = statbuf.st_size;
      D.10876 = (long int) wanted_size;
      if (D.10875 < D.10876) goto <D.10877>; else goto <D.10878>;
      <D.10877>:
      close (fd);
      if (created == 1) goto <D.10879>; else goto <D.10880>;
      <D.10879>:
      D.10875 = statbuf.st_size;
      monoeg_g_log (0B, 8, "%s: shared file [%s] is not big enough! (found %ld, need %d bytes)", &__func__, filename, D.10875, wanted_size);
      unlink (filename);
      D.10840 = -1;
      return D.10840;
      <D.10880>:
      _wapi_handle_spin (100);
      goto try_again;
      <D.10878>:
      D.10840 = fd;
      return D.10840;
    }
  finally
    {
      statbuf = {CLOBBER};
    }
}


open (const char * __path, int __oflag)
{
  int D.10883;
  int D.10886;
  int D.10891;
  int D.10893;
  int D.10894;
  int D.10897;
  int D.10898;

  D.10883 = __builtin_va_arg_pack_len ();
  if (D.10883 > 1) goto <D.10884>; else goto <D.10885>;
  <D.10884>:
  __open_too_many_args ();
  <D.10885>:
  D.10886 = __builtin_constant_p (__oflag);
  if (D.10886 != 0) goto <D.10887>; else goto <D.10888>;
  <D.10887>:
  D.10891 = __oflag & 64;
  if (D.10891 != 0) goto <D.10889>; else goto <D.10892>;
  <D.10892>:
  D.10893 = __oflag & 4259840;
  if (D.10893 == 4259840) goto <D.10889>; else goto <D.10890>;
  <D.10889>:
  D.10894 = __builtin_va_arg_pack_len ();
  if (D.10894 <= 0) goto <D.10895>; else goto <D.10896>;
  <D.10895>:
  __open_missing_mode ();
  D.10897 = __open_2 (__path, __oflag);
  return D.10897;
  <D.10896>:
  <D.10890>:
  D.10897 = __open_alias (__path, __oflag, __builtin_va_arg_pack ());
  return D.10897;
  <D.10888>:
  D.10898 = __builtin_va_arg_pack_len ();
  if (D.10898 <= 0) goto <D.10899>; else goto <D.10900>;
  <D.10899>:
  D.10897 = __open_2 (__path, __oflag);
  return D.10897;
  <D.10900>:
  D.10897 = __open_alias (__path, __oflag, __builtin_va_arg_pack ());
  return D.10897;
}


_wapi_handle_spin (guint32 ms)
{
  _Bool D.10902;
  long int D.10903;
  long int D.10904;
  unsigned int D.10907;
  long int D.10908;
  struct timespec sleepytime;

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


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

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


_wapi_shm_detach (_wapi_shm_t type)
{
  int D.10911;
  void * D.10914;

  D.10911 = _wapi_shm_enabled ();
  if (D.10911 == 0) goto <D.10912>; else goto <D.10913>;
  <D.10912>:
  D.10914 = wapi_storage[type];
  monoeg_g_free (D.10914);
  <D.10913>:
}


_wapi_shm_semaphores_init ()
{
  int D.10915;

  D.10915 = _wapi_shm_enabled ();
  if (D.10915 == 0) goto <D.10916>; else goto <D.10917>;
  <D.10916>:
  noshm_semaphores_init ();
  goto <D.10918>;
  <D.10917>:
  shm_semaphores_init ();
  <D.10918>:
}


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

  i = 0;
  goto <D.10594>;
  <D.10593>:
  D.10919 = &noshm_sems[i];
  pthread_mutex_init (D.10919, 0B);
  i = i + 1;
  <D.10594>:
  if (i <= 7) goto <D.10593>; else goto <D.10595>;
  <D.10595>:
}


shm_semaphores_init ()
{
  _Bool D.10920;
  long int D.10921;
  long int D.10922;
  _Bool D.10925;
  long int D.10926;
  long int D.10927;
  int * D.10932;
  int D.10933;
  const gchar * D.10936;
  const gchar * D.10939;
  const gchar * D.10944;
  int _wapi_sem_id.5;
  int _wapi_sem_id.6;
  int D.10947;
  const gchar * D.10952;
  volatile key_t * D.10953;
  int D.10954;
  int _wapi_sem_id.7;
  const gchar * D.10961;
  volatile key_t * D.10962;
  _Bool D.10963;
  long int D.10964;
  long int D.10965;
  int _wapi_shm_disabled.8;
  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.10692>;
      <D.10691>:
      def_vals[i] = 1;
      i = i + 1;
      <D.10692>:
      if (i <= 7) goto <D.10691>; else goto <D.10693>;
      <D.10693>:
      def_vals[7] = 0;
      defs.array = &def_vals;
      tmp_shared = _wapi_shm_attach (0);
      D.10920 = tmp_shared == 0B;
      D.10921 = (long int) D.10920;
      D.10922 = __builtin_expect (D.10921, 0);
      if (D.10922 != 0) goto <D.10923>; else goto <D.10924>;
      <D.10923>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "shared.c", 547, "tmp_shared != NULL");
      <D.10924>:
      ftmp = _wapi_shm_shm_name (0);
      filename = monoeg_g_build_path ("/", "/dev/shm", ftmp, 0B);
      D.10925 = filename == 0B;
      D.10926 = (long int) D.10925;
      D.10927 = __builtin_expect (D.10926, 0);
      if (D.10927 != 0) goto <D.10928>; else goto <D.10929>;
      <D.10928>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "shared.c", 552, "filename!=NULL");
      <D.10929>:
      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.10930>; else goto <D.10931>;
      <D.10930>:
      goto <D.10699>;
      <D.10698>:
      D.10932 = __errno_location ();
      D.10933 = *D.10932;
      if (D.10933 == 12) goto <D.10934>; else goto <D.10935>;
      <D.10934>:
      D.10932 = __errno_location ();
      D.10933 = *D.10932;
      D.10936 = monoeg_g_strerror (D.10933);
      monoeg_g_log (0B, 4, "%s: semget error: %s", &__func__, D.10936);
      <D.10696>:
      goto <D.10696>;
      <D.10935>:
      D.10932 = __errno_location ();
      D.10933 = *D.10932;
      if (D.10933 == 28) goto <D.10937>; else goto <D.10938>;
      <D.10937>:
      D.10932 = __errno_location ();
      D.10933 = *D.10932;
      D.10939 = monoeg_g_strerror (D.10933);
      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.10939);
      <D.10697>:
      goto <D.10697>;
      <D.10938>:
      D.10932 = __errno_location ();
      D.10933 = *D.10932;
      if (D.10933 != 17) goto <D.10940>; else goto <D.10941>;
      <D.10940>:
      if (retries > 3) goto <D.10942>; else goto <D.10943>;
      <D.10942>:
      D.10932 = __errno_location ();
      D.10933 = *D.10932;
      D.10944 = monoeg_g_strerror (D.10933);
      monoeg_g_log (0B, 16, "%s: semget error: %s key 0x%x - trying again", &__func__, D.10944, key);
      <D.10943>:
      <D.10941>:
      key = key + 1;
      <D.10699>:
      _wapi_sem_id.5 = semget (key, 8, 1920);
      _wapi_sem_id = _wapi_sem_id.5;
      _wapi_sem_id.6 = _wapi_sem_id;
      if (_wapi_sem_id.6 == -1) goto <D.10698>; else goto <D.10700>;
      <D.10700>:
      _wapi_sem_id.6 = _wapi_sem_id;
      D.10947 = semctl (_wapi_sem_id.6, 0, 17, defs);
      if (D.10947 == -1) goto <D.10948>; else goto <D.10949>;
      <D.10948>:
      if (retries > 3) goto <D.10950>; else goto <D.10951>;
      <D.10950>:
      D.10932 = __errno_location ();
      D.10933 = *D.10932;
      D.10952 = monoeg_g_strerror (D.10933);
      monoeg_g_log (0B, 16, "%s: semctl init error: %s - trying again", &__func__, D.10952);
      <D.10951>:
      _wapi_sem_id.6 = _wapi_sem_id;
      semctl (_wapi_sem_id.6, 0, 0);
      goto again;
      <D.10949>:
      D.10953 = &tmp_shared->sem_key;
      D.10954 = InterlockedCompareExchange (D.10953, key, 0);
      if (D.10954 != 0) goto <D.10955>; else goto done;
      <D.10955>:
      _wapi_sem_id.6 = _wapi_sem_id;
      semctl (_wapi_sem_id.6, 0, 0);
      oldkey = tmp_shared->sem_key;
      <D.10931>:
      _wapi_sem_id.7 = semget (oldkey, 8, 384);
      _wapi_sem_id = _wapi_sem_id.7;
      _wapi_sem_id.6 = _wapi_sem_id;
      if (_wapi_sem_id.6 == -1) goto <D.10957>; else goto <D.10958>;
      <D.10957>:
      if (retries > 3) goto <D.10959>; else goto <D.10960>;
      <D.10959>:
      D.10932 = __errno_location ();
      D.10933 = *D.10932;
      D.10961 = monoeg_g_strerror (D.10933);
      monoeg_g_log (0B, 16, "%s: semget error opening old key 0x%x (%s) - trying again", &__func__, oldkey, D.10961);
      <D.10960>:
      D.10962 = &tmp_shared->sem_key;
      InterlockedCompareExchange (D.10962, 0, oldkey);
      goto again;
      <D.10958>:
      done:
      thr_ret = _wapi_shm_sem_lock (6);
      D.10963 = thr_ret != 0;
      D.10964 = (long int) D.10963;
      D.10965 = __builtin_expect (D.10964, 0);
      if (D.10965 != 0) goto <D.10966>; else goto <D.10967>;
      <D.10966>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "shared.c", 645, "thr_ret == 0");
      <D.10967>:
      _wapi_shm_sem_unlock (7);
      _wapi_shm_sem_unlock (6);
      _wapi_shm_disabled.8 = _wapi_shm_disabled;
      if (_wapi_shm_disabled.8 != 0) goto <D.10969>; else goto <D.10970>;
      <D.10969>:
      monoeg_g_free (tmp_shared);
      goto <D.10971>;
      <D.10970>:
      munmap (tmp_shared, 86024);
      <D.10971>:
    }
  finally
    {
      defs = {CLOBBER};
      def_vals = {CLOBBER};
    }
}


InterlockedCompareExchange (volatile gint32 * dest, gint32 exch, gint32 comp)
{
  gint32 D.10972;
  unsigned int exch.9;
  unsigned int comp.10;
  unsigned int D.10975;

  exch.9 = (unsigned int) exch;
  comp.10 = (unsigned int) comp;
  D.10975 = __sync_val_compare_and_swap_4 (dest, comp.10, exch.9);
  D.10972 = (gint32) D.10975;
  return D.10972;
}


_wapi_shm_semaphores_remove ()
{
  int _wapi_shm_disabled.11;

  _wapi_shm_disabled.11 = _wapi_shm_disabled;
  if (_wapi_shm_disabled.11 == 0) goto <D.10978>; else goto <D.10979>;
  <D.10978>:
  shm_semaphores_remove ();
  <D.10979>:
}


shm_semaphores_remove ()
{
  _Bool D.10980;
  long int D.10981;
  long int D.10982;
  int _wapi_sem_id.12;
  _Bool D.10986;
  long int D.10987;
  long int D.10988;
  gchar * D.10993;
  gchar * D.10994;
  int thr_ret;
  int proc_count;
  gchar * shm_name;

  thr_ret = _wapi_shm_sem_lock (6);
  D.10980 = thr_ret != 0;
  D.10981 = (long int) D.10980;
  D.10982 = __builtin_expect (D.10981, 0);
  if (D.10982 != 0) goto <D.10983>; else goto <D.10984>;
  <D.10983>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "shared.c", 678, "thr_ret == 0");
  <D.10984>:
  _wapi_sem_id.12 = _wapi_sem_id;
  proc_count = semctl (_wapi_sem_id.12, 7, 12);
  D.10986 = proc_count <= 0;
  D.10987 = (long int) D.10986;
  D.10988 = __builtin_expect (D.10987, 0);
  if (D.10988 != 0) goto <D.10989>; else goto <D.10990>;
  <D.10989>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "shared.c", 683, "proc_count > 0");
  <D.10990>:
  if (proc_count == 1) goto <D.10991>; else goto <D.10992>;
  <D.10991>:
  _wapi_sem_id.12 = _wapi_sem_id;
  semctl (_wapi_sem_id.12, 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.10993 = _wapi_shm_file (0);
  unlink (D.10993);
  D.10994 = _wapi_shm_file (1);
  unlink (D.10994);
  goto <D.10995>;
  <D.10992>:
  _wapi_shm_sem_unlock (6);
  <D.10995>:
}


_wapi_shm_sem_lock (int sem)
{
  int _wapi_shm_disabled.13;
  int D.10999;

  _wapi_shm_disabled.13 = _wapi_shm_disabled;
  if (_wapi_shm_disabled.13 != 0) goto <D.10997>; else goto <D.10998>;
  <D.10997>:
  D.10999 = noshm_sem_lock (sem);
  return D.10999;
  <D.10998>:
  D.10999 = shm_sem_lock (sem);
  return D.10999;
}


noshm_sem_lock (int sem)
{
  union mono_mutex_t * D.11001;
  int D.11002;
  int ret;

  D.11001 = &noshm_sems[sem];
  ret = pthread_mutex_lock (D.11001);
  D.11002 = ret;
  return D.11002;
}


shm_sem_lock (int sem)
{
  short unsigned int D.11004;
  int _wapi_sem_id.14;
  int * D.11007;
  int D.11008;
  int D.11011;
  _Bool D.11012;
  _Bool D.11013;
  _Bool D.11014;
  int D.11017;
  struct sembuf ops;
  int ret;
  void retry = <<< error >>>;

  try
    {
      D.11004 = (short unsigned int) sem;
      ops.sem_num = D.11004;
      ops.sem_op = -1;
      ops.sem_flg = 4096;
      retry:
      <D.10714>:
      _wapi_sem_id.14 = _wapi_sem_id;
      ret = semop (_wapi_sem_id.14, &ops, 1);
      if (ret == -1) goto <D.11006>; else goto <D.10715>;
      <D.11006>:
      D.11007 = __errno_location ();
      D.11008 = *D.11007;
      if (D.11008 == 4) goto <D.10714>; else goto <D.10715>;
      <D.10715>:
      if (ret == -1) goto <D.11009>; else goto <D.11010>;
      <D.11009>:
      D.11007 = __errno_location ();
      D.11011 = *D.11007;
      D.11012 = D.11011 == 43;
      D.11013 = D.11011 == 22;
      D.11014 = D.11012 | D.11013;
      if (D.11014 != 0) goto <D.11015>; else goto <D.11016>;
      <D.11015>:
      _wapi_shm_semaphores_init ();
      goto retry;
      <D.11016>:
      D.11007 = __errno_location ();
      ret = *D.11007;
      <D.11010>:
      D.11017 = ret;
      return D.11017;
    }
  finally
    {
      ops = {CLOBBER};
    }
}


_wapi_shm_sem_trylock (int sem)
{
  int _wapi_shm_disabled.15;
  int D.11023;

  _wapi_shm_disabled.15 = _wapi_shm_disabled;
  if (_wapi_shm_disabled.15 != 0) goto <D.11021>; else goto <D.11022>;
  <D.11021>:
  D.11023 = noshm_sem_trylock (sem);
  return D.11023;
  <D.11022>:
  D.11023 = shm_sem_trylock (sem);
  return D.11023;
}


noshm_sem_trylock (int sem)
{
  union mono_mutex_t * D.11025;
  int D.11026;
  int ret;

  D.11025 = &noshm_sems[sem];
  ret = pthread_mutex_trylock (D.11025);
  D.11026 = ret;
  return D.11026;
}


shm_sem_trylock (int sem)
{
  short unsigned int D.11028;
  int _wapi_sem_id.16;
  int * D.11031;
  int D.11032;
  int D.11035;
  _Bool D.11036;
  _Bool D.11037;
  _Bool D.11038;
  int D.11043;
  struct sembuf ops;
  int ret;
  void retry = <<< error >>>;

  try
    {
      D.11028 = (short unsigned int) sem;
      ops.sem_num = D.11028;
      ops.sem_op = -1;
      ops.sem_flg = 6144;
      retry:
      <D.10722>:
      _wapi_sem_id.16 = _wapi_sem_id;
      ret = semop (_wapi_sem_id.16, &ops, 1);
      if (ret == -1) goto <D.11030>; else goto <D.10723>;
      <D.11030>:
      D.11031 = __errno_location ();
      D.11032 = *D.11031;
      if (D.11032 == 4) goto <D.10722>; else goto <D.10723>;
      <D.10723>:
      if (ret == -1) goto <D.11033>; else goto <D.11034>;
      <D.11033>:
      D.11031 = __errno_location ();
      D.11035 = *D.11031;
      D.11036 = D.11035 == 43;
      D.11037 = D.11035 == 22;
      D.11038 = D.11036 | D.11037;
      if (D.11038 != 0) goto <D.11039>; else goto <D.11040>;
      <D.11039>:
      _wapi_shm_semaphores_init ();
      goto retry;
      <D.11040>:
      D.11031 = __errno_location ();
      ret = *D.11031;
      <D.11034>:
      if (ret == 11) goto <D.11041>; else goto <D.11042>;
      <D.11041>:
      ret = 16;
      <D.11042>:
      D.11043 = ret;
      return D.11043;
    }
  finally
    {
      ops = {CLOBBER};
    }
}


_wapi_shm_sem_unlock (int sem)
{
  int _wapi_shm_disabled.17;
  int D.11049;

  _wapi_shm_disabled.17 = _wapi_shm_disabled;
  if (_wapi_shm_disabled.17 != 0) goto <D.11047>; else goto <D.11048>;
  <D.11047>:
  D.11049 = noshm_sem_unlock (sem);
  return D.11049;
  <D.11048>:
  D.11049 = shm_sem_unlock (sem);
  return D.11049;
}


noshm_sem_unlock (int sem)
{
  union mono_mutex_t * D.11051;
  int D.11052;
  int ret;

  D.11051 = &noshm_sems[sem];
  ret = pthread_mutex_unlock (D.11051);
  D.11052 = ret;
  return D.11052;
}


shm_sem_unlock (int sem)
{
  short unsigned int D.11054;
  int _wapi_sem_id.18;
  int * D.11057;
  int D.11058;
  int D.11061;
  _Bool D.11062;
  _Bool D.11063;
  _Bool D.11064;
  int D.11067;
  struct sembuf ops;
  int ret;
  void retry = <<< error >>>;

  try
    {
      D.11054 = (short unsigned int) sem;
      ops.sem_num = D.11054;
      ops.sem_op = 1;
      ops.sem_flg = 4096;
      retry:
      <D.10730>:
      _wapi_sem_id.18 = _wapi_sem_id;
      ret = semop (_wapi_sem_id.18, &ops, 1);
      if (ret == -1) goto <D.11056>; else goto <D.10731>;
      <D.11056>:
      D.11057 = __errno_location ();
      D.11058 = *D.11057;
      if (D.11058 == 4) goto <D.10730>; else goto <D.10731>;
      <D.10731>:
      if (ret == -1) goto <D.11059>; else goto <D.11060>;
      <D.11059>:
      D.11057 = __errno_location ();
      D.11061 = *D.11057;
      D.11062 = D.11061 == 43;
      D.11063 = D.11061 == 22;
      D.11064 = D.11062 | D.11063;
      if (D.11064 != 0) goto <D.11065>; else goto <D.11066>;
      <D.11065>:
      _wapi_shm_semaphores_init ();
      goto retry;
      <D.11066>:
      D.11057 = __errno_location ();
      ret = *D.11057;
      <D.11060>:
      D.11067 = ret;
      return D.11067;
    }
  finally
    {
      ops = {CLOBBER};
    }
}


