_wapi_shm_enabled ()
{
  int env_checked.0;
  const gchar * D.13029;
  gboolean D.13032;
  int _wapi_shm_disabled.1;
  _Bool D.13034;
  static gboolean env_checked;

  env_checked.0 = env_checked;
  if (env_checked.0 == 0) goto <D.13027>; else goto <D.13028>;
  <D.13027>:
  D.13029 = monoeg_g_getenv ("MONO_ENABLE_SHM");
  if (D.13029 != 0B) goto <D.13030>; else goto <D.13031>;
  <D.13030>:
  _wapi_shm_disabled = 0;
  <D.13031>:
  env_checked = 1;
  <D.13028>:
  _wapi_shm_disabled.1 = _wapi_shm_disabled;
  D.13034 = _wapi_shm_disabled.1 == 0;
  D.13032 = (gboolean) D.13034;
  return D.13032;
}


_wapi_shm_attach (_wapi_shm_t type)
{
  void * D.13036;
  int D.13037;
  void * D.13040;
  int size.2;
  int D.13046;
  int * D.13049;
  int D.13050;
  const gchar * D.13051;
  long long int D.13052;
  unsigned int D.13053;
  const gchar * D.13058;
  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.12944>, case 0: <D.12941>, case 1: <D.12943>>
      <D.12941>:
      size = 81928;
      goto <D.12942>;
      <D.12943>:
      size = 4096008;
      goto <D.12942>;
      <D.12944>:
      monoeg_g_log (0B, 4, "Invalid type in _wapi_shm_attach ()");
      <D.12945>:
      goto <D.12945>;
      D.13036 = 0B;
      return D.13036;
      <D.12942>:
      D.13037 = _wapi_shm_enabled ();
      if (D.13037 == 0) goto <D.13038>; else goto <D.13039>;
      <D.13038>:
      D.13040 = monoeg_malloc0 (size);
      wapi_storage[type] = D.13040;
      D.13036 = wapi_storage[type];
      return D.13036;
      <D.13039>:
      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.13042>; else goto <D.13043>;
      <D.13042>:
      fd = _wapi_shm_file_open (filename, size);
      <D.13043>:
      if (fd == -1) goto <D.13044>; else goto <D.13045>;
      <D.13044>:
      monoeg_g_log (0B, 8, "%s: shared file [%s] open error", &__func__, filename);
      D.13036 = 0B;
      return D.13036;
      <D.13045>:
      D.13046 = fstat (fd, &statbuf);
      if (D.13046 == -1) goto <D.13047>; else goto <D.13048>;
      <D.13047>:
      D.13049 = __errno_location ();
      D.13050 = *D.13049;
      D.13051 = monoeg_g_strerror (D.13050);
      monoeg_g_log (0B, 8, "%s: fstat error: %s", &__func__, D.13051);
      close (fd);
      D.13036 = 0B;
      return D.13036;
      <D.13048>:
      D.13052 = statbuf.st_size;
      D.13053 = (unsigned int) D.13052;
      shm_seg = mmap (0B, D.13053, 3, 1, fd, 0);
      if (shm_seg == 4294967295B) goto <D.13054>; else goto <D.13055>;
      <D.13054>:
      D.13052 = statbuf.st_size;
      D.13053 = (unsigned int) D.13052;
      shm_seg = mmap (0B, D.13053, 3, 2, fd, 0);
      if (shm_seg == 4294967295B) goto <D.13056>; else goto <D.13057>;
      <D.13056>:
      D.13049 = __errno_location ();
      D.13050 = *D.13049;
      D.13058 = monoeg_g_strerror (D.13050);
      monoeg_g_log (0B, 8, "%s: mmap error: %s", &__func__, D.13058);
      close (fd);
      D.13036 = 0B;
      return D.13036;
      <D.13057>:
      <D.13055>:
      close (fd);
      D.13036 = shm_seg;
      return D.13036;
    }
  finally
    {
      statbuf = {CLOBBER};
    }
}


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


_wapi_shm_base_name (_wapi_shm_t type)
{
  int D.13072;
  int iftmp.3;
  unsigned int D.13077;
  unsigned int D.13080;
  unsigned int len.4;
  gchar * D.13084;
  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.13067>; else goto <D.13068>;
      <D.13067>:
      ubuf.machine[0] = 0;
      ubuf.sysname[0] = 0;
      goto <D.13069>;
      <D.13068>:
      monoeg_g_strdelimit (&ubuf.sysname, "/", 95);
      monoeg_g_strdelimit (&ubuf.machine, "/", 95);
      <D.13069>:
      fake_name = monoeg_g_getenv ("MONO_SHARED_HOSTNAME");
      if (fake_name == 0B) goto <D.13070>; else goto <D.13071>;
      <D.13070>:
      D.13072 = gethostname (&machine_name, 256);
      if (D.13072 != 0) goto <D.13073>; else goto <D.13074>;
      <D.13073>:
      machine_name[0] = 0;
      <D.13074>:
      goto <D.13075>;
      <D.13071>:
      D.13077 = strlen (fake_name);
      if (D.13077 <= 254) goto <D.13078>; else goto <D.13079>;
      <D.13078>:
      D.13080 = strlen (fake_name);
      iftmp.3 = (int) D.13080;
      goto <D.13081>;
      <D.13079>:
      iftmp.3 = 255;
      <D.13081>:
      len = iftmp.3;
      len.4 = (unsigned int) len;
      strncpy (&machine_name, fake_name, len.4);
      machine_name[len] = 0;
      <D.13075>:
      switch (type) <default: <D.13083>, case 0: <D.12893>, case 1: <D.12895>>
      <D.12893>:
      name = monoeg_g_strdup_printf ("shared_data-%s-%s-%s-%d-%d-%d", &machine_name, &ubuf.sysname, &ubuf.machine, 320, 12, 0);
      goto <D.12894>;
      <D.12895>:
      name = monoeg_g_strdup_printf ("shared_fileshare-%s-%s-%s-%d-%d-%d", &machine_name, &ubuf.sysname, &ubuf.machine, 40, 12, 0);
      goto <D.12894>;
      <D.13083>:
      <D.12894>:
      D.13084 = name;
      return D.13084;
    }
  finally
    {
      machine_name = {CLOBBER};
      ubuf = {CLOBBER};
    }
}


gethostname (char * __buf, size_t __buflen)
{
  unsigned int D.13087;
  int D.13090;
  int D.13093;
  unsigned int D.13094;
  unsigned int D.13095;
  unsigned int D.13098;

  D.13087 = __builtin_object_size (__buf, 1);
  if (D.13087 != 4294967295) goto <D.13088>; else goto <D.13089>;
  <D.13088>:
  D.13090 = __builtin_constant_p (__buflen);
  if (D.13090 == 0) goto <D.13091>; else goto <D.13092>;
  <D.13091>:
  D.13094 = __builtin_object_size (__buf, 1);
  D.13093 = __gethostname_chk (__buf, __buflen, D.13094);
  return D.13093;
  <D.13092>:
  D.13095 = __builtin_object_size (__buf, 1);
  if (D.13095 < __buflen) goto <D.13096>; else goto <D.13097>;
  <D.13096>:
  D.13098 = __builtin_object_size (__buf, 1);
  D.13093 = __gethostname_chk_warn (__buf, __buflen, D.13098);
  return D.13093;
  <D.13097>:
  <D.13089>:
  D.13093 = __gethostname_alias (__buf, __buflen);
  return D.13093;
}


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

  D.13101 = __builtin_object_size (__dest, 1);
  D.13100 = __builtin___strncpy_chk (__dest, __src, __len, D.13101);
  return D.13100;
}


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

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


_wapi_shm_open (const char * filename, int size)
{
  int D.13108;
  long long int D.13109;
  int D.13110;
  int fd;

  fd = shm_open (filename, 66, 416);
  if (fd == -1) goto <D.13106>; else goto <D.13107>;
  <D.13106>:
  D.13108 = -1;
  return D.13108;
  <D.13107>:
  D.13109 = (long long int) size;
  D.13110 = ftruncate (fd, D.13109);
  if (D.13110 != 0) goto <D.13111>; else goto <D.13112>;
  <D.13111>:
  perror ("_wapi_shm_open (): ftruncate ()");
  monoeg_assertion_message ("* Assertion: should not be reached at %s:%d\n", "shared.c", 245);
  <D.13112>:
  D.13108 = fd;
  return D.13108;
}


_wapi_shm_file_open (const gchar * filename, guint32 wanted_size)
{
  int tries.5;
  int D.13117;
  int * D.13123;
  int D.13124;
  const gchar * D.13131;
  unsigned int D.13132;
  long long int D.13133;
  long long int D.13134;
  const gchar * D.13137;
  const gchar * D.13141;
  const gchar * D.13144;
  int D.13145;
  const gchar * D.13148;
  long long int D.13151;
  long long int D.13152;
  long int D.13157;
  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.13115>; else goto <D.13116>;
      <D.13115>:
      D.13117 = -1;
      return D.13117;
      <D.13116>:
      if (tries > 5) goto <D.13118>; else goto <D.13119>;
      <D.13118>:
      unlink (filename);
      <D.13119>:
      oldmask = umask (54);
      fd = open (filename, 2, 384);
      umask (oldmask);
      if (fd == -1) goto <D.13122>; else goto <D.13120>;
      <D.13122>:
      D.13123 = __errno_location ();
      D.13124 = *D.13123;
      if (D.13124 == 2) goto <D.13125>; else goto <D.13120>;
      <D.13125>:
      oldmask = umask (54);
      fd = open (filename, 194, 384);
      umask (oldmask);
      if (fd == -1) goto <D.13128>; else goto <D.13126>;
      <D.13128>:
      D.13123 = __errno_location ();
      D.13124 = *D.13123;
      if (D.13124 == 17) goto try_again; else goto <D.13126>;
      goto <D.13127>;
      <D.13126>:
      if (fd == -1) goto <D.13129>; else goto <D.13130>;
      <D.13129>:
      D.13123 = __errno_location ();
      D.13124 = *D.13123;
      D.13131 = monoeg_g_strerror (D.13124);
      monoeg_g_log (0B, 8, "%s: shared file [%s] open error: %s", &__func__, filename, D.13131);
      D.13117 = -1;
      return D.13117;
      <D.13130>:
      D.13132 = wanted_size + 4294967295;
      D.13133 = (long long int) D.13132;
      D.13134 = lseek (fd, D.13133, 0);
      if (D.13134 == -1) goto <D.13135>; else goto <D.13136>;
      <D.13135>:
      D.13123 = __errno_location ();
      D.13124 = *D.13123;
      D.13137 = monoeg_g_strerror (D.13124);
      monoeg_g_log (0B, 8, "%s: shared file [%s] lseek error: %s", &__func__, filename, D.13137);
      close (fd);
      unlink (filename);
      D.13117 = -1;
      return D.13117;
      <D.13136>:
      <D.12926>:
      ret = write (fd, "", 1);
      if (ret == -1) goto <D.13138>; else goto <D.12927>;
      <D.13138>:
      D.13123 = __errno_location ();
      D.13124 = *D.13123;
      if (D.13124 == 4) goto <D.12926>; else goto <D.12927>;
      <D.12927>:
      if (ret == -1) goto <D.13139>; else goto <D.13140>;
      <D.13139>:
      D.13123 = __errno_location ();
      D.13124 = *D.13123;
      D.13141 = monoeg_g_strerror (D.13124);
      monoeg_g_log (0B, 8, "%s: shared file [%s] write error: %s", &__func__, filename, D.13141);
      close (fd);
      unlink (filename);
      D.13117 = -1;
      return D.13117;
      <D.13140>:
      created = 1;
      <D.13127>:
      goto <D.13121>;
      <D.13120>:
      if (fd == -1) goto <D.13142>; else goto <D.13143>;
      <D.13142>:
      D.13123 = __errno_location ();
      D.13124 = *D.13123;
      D.13144 = monoeg_g_strerror (D.13124);
      monoeg_g_log (0B, 8, "%s: shared file [%s] open error: %s", &__func__, filename, D.13144);
      D.13117 = -1;
      return D.13117;
      <D.13143>:
      <D.13121>:
      D.13145 = fstat (fd, &statbuf);
      if (D.13145 == -1) goto <D.13146>; else goto <D.13147>;
      <D.13146>:
      D.13123 = __errno_location ();
      D.13124 = *D.13123;
      D.13148 = monoeg_g_strerror (D.13124);
      monoeg_g_log (0B, 8, "%s: fstat error: %s", &__func__, D.13148);
      if (created == 1) goto <D.13149>; else goto <D.13150>;
      <D.13149>:
      unlink (filename);
      <D.13150>:
      close (fd);
      D.13117 = -1;
      return D.13117;
      <D.13147>:
      D.13151 = statbuf.st_size;
      D.13152 = (long long int) wanted_size;
      if (D.13151 < D.13152) goto <D.13153>; else goto <D.13154>;
      <D.13153>:
      close (fd);
      if (created == 1) goto <D.13155>; else goto <D.13156>;
      <D.13155>:
      D.13151 = statbuf.st_size;
      D.13157 = (long int) D.13151;
      monoeg_g_log (0B, 8, "%s: shared file [%s] is not big enough! (found %ld, need %d bytes)", &__func__, filename, D.13157, wanted_size);
      unlink (filename);
      D.13117 = -1;
      return D.13117;
      <D.13156>:
      _wapi_handle_spin (100);
      goto try_again;
      <D.13154>:
      D.13117 = fd;
      return D.13117;
    }
  finally
    {
      statbuf = {CLOBBER};
    }
}


open (const char * __path, int __oflag)
{
  int D.13160;
  int D.13163;
  int D.13168;
  int D.13170;
  int D.13171;
  int D.13174;
  int D.13175;

  D.13160 = __builtin_va_arg_pack_len ();
  if (D.13160 > 1) goto <D.13161>; else goto <D.13162>;
  <D.13161>:
  __open_too_many_args ();
  <D.13162>:
  D.13163 = __builtin_constant_p (__oflag);
  if (D.13163 != 0) goto <D.13164>; else goto <D.13165>;
  <D.13164>:
  D.13168 = __oflag & 64;
  if (D.13168 != 0) goto <D.13166>; else goto <D.13169>;
  <D.13169>:
  D.13170 = __oflag & 4210688;
  if (D.13170 == 4210688) goto <D.13166>; else goto <D.13167>;
  <D.13166>:
  D.13171 = __builtin_va_arg_pack_len ();
  if (D.13171 <= 0) goto <D.13172>; else goto <D.13173>;
  <D.13172>:
  __open_missing_mode ();
  D.13174 = __open_2 (__path, __oflag);
  return D.13174;
  <D.13173>:
  <D.13167>:
  D.13174 = __open_alias (__path, __oflag, __builtin_va_arg_pack ());
  return D.13174;
  <D.13165>:
  D.13175 = __builtin_va_arg_pack_len ();
  if (D.13175 <= 0) goto <D.13176>; else goto <D.13177>;
  <D.13176>:
  D.13174 = __open_2 (__path, __oflag);
  return D.13174;
  <D.13177>:
  D.13174 = __open_alias (__path, __oflag, __builtin_va_arg_pack ());
  return D.13174;
}


_wapi_handle_spin (guint32 ms)
{
  _Bool D.13179;
  long int D.13180;
  long int D.13181;
  unsigned int D.13184;
  long int D.13185;
  struct timespec sleepytime;

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


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

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


_wapi_shm_detach (_wapi_shm_t type)
{
  int D.13188;
  void * D.13191;

  D.13188 = _wapi_shm_enabled ();
  if (D.13188 == 0) goto <D.13189>; else goto <D.13190>;
  <D.13189>:
  D.13191 = wapi_storage[type];
  monoeg_g_free (D.13191);
  <D.13190>:
}


_wapi_shm_semaphores_init ()
{
  int D.13192;

  D.13192 = _wapi_shm_enabled ();
  if (D.13192 == 0) goto <D.13193>; else goto <D.13194>;
  <D.13193>:
  noshm_semaphores_init ();
  goto <D.13195>;
  <D.13194>:
  shm_semaphores_init ();
  <D.13195>:
}


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

  i = 0;
  goto <D.12870>;
  <D.12869>:
  D.13196 = &noshm_sems[i];
  pthread_mutex_init (D.13196, 0B);
  i = i + 1;
  <D.12870>:
  if (i <= 7) goto <D.12869>; else goto <D.12871>;
  <D.12871>:
}


shm_semaphores_init ()
{
  _Bool D.13197;
  long int D.13198;
  long int D.13199;
  _Bool D.13202;
  long int D.13203;
  long int D.13204;
  int * D.13209;
  int D.13210;
  const gchar * D.13213;
  const gchar * D.13216;
  const gchar * D.13221;
  int _wapi_sem_id.6;
  int _wapi_sem_id.7;
  int D.13224;
  const gchar * D.13229;
  volatile key_t * D.13230;
  int D.13231;
  int _wapi_sem_id.8;
  const gchar * D.13238;
  volatile key_t * D.13239;
  _Bool D.13240;
  long int D.13241;
  long int D.13242;
  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.12968>;
      <D.12967>:
      def_vals[i] = 1;
      i = i + 1;
      <D.12968>:
      if (i <= 7) goto <D.12967>; else goto <D.12969>;
      <D.12969>:
      def_vals[7] = 0;
      defs.array = &def_vals;
      tmp_shared = _wapi_shm_attach (0);
      D.13197 = tmp_shared == 0B;
      D.13198 = (long int) D.13197;
      D.13199 = __builtin_expect (D.13198, 0);
      if (D.13199 != 0) goto <D.13200>; else goto <D.13201>;
      <D.13200>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "shared.c", 547, "tmp_shared != NULL");
      <D.13201>:
      ftmp = _wapi_shm_shm_name (0);
      filename = monoeg_g_build_path ("/", "/dev/shm", ftmp, 0B);
      D.13202 = filename == 0B;
      D.13203 = (long int) D.13202;
      D.13204 = __builtin_expect (D.13203, 0);
      if (D.13204 != 0) goto <D.13205>; else goto <D.13206>;
      <D.13205>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "shared.c", 552, "filename!=NULL");
      <D.13206>:
      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.13207>; else goto <D.13208>;
      <D.13207>:
      goto <D.12975>;
      <D.12974>:
      D.13209 = __errno_location ();
      D.13210 = *D.13209;
      if (D.13210 == 12) goto <D.13211>; else goto <D.13212>;
      <D.13211>:
      D.13209 = __errno_location ();
      D.13210 = *D.13209;
      D.13213 = monoeg_g_strerror (D.13210);
      monoeg_g_log (0B, 4, "%s: semget error: %s", &__func__, D.13213);
      <D.12972>:
      goto <D.12972>;
      <D.13212>:
      D.13209 = __errno_location ();
      D.13210 = *D.13209;
      if (D.13210 == 28) goto <D.13214>; else goto <D.13215>;
      <D.13214>:
      D.13209 = __errno_location ();
      D.13210 = *D.13209;
      D.13216 = monoeg_g_strerror (D.13210);
      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.13216);
      <D.12973>:
      goto <D.12973>;
      <D.13215>:
      D.13209 = __errno_location ();
      D.13210 = *D.13209;
      if (D.13210 != 17) goto <D.13217>; else goto <D.13218>;
      <D.13217>:
      if (retries > 3) goto <D.13219>; else goto <D.13220>;
      <D.13219>:
      D.13209 = __errno_location ();
      D.13210 = *D.13209;
      D.13221 = monoeg_g_strerror (D.13210);
      monoeg_g_log (0B, 16, "%s: semget error: %s key 0x%x - trying again", &__func__, D.13221, key);
      <D.13220>:
      <D.13218>:
      key = key + 1;
      <D.12975>:
      _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.12974>; else goto <D.12976>;
      <D.12976>:
      _wapi_sem_id.7 = _wapi_sem_id;
      D.13224 = semctl (_wapi_sem_id.7, 0, 17, defs);
      if (D.13224 == -1) goto <D.13225>; else goto <D.13226>;
      <D.13225>:
      if (retries > 3) goto <D.13227>; else goto <D.13228>;
      <D.13227>:
      D.13209 = __errno_location ();
      D.13210 = *D.13209;
      D.13229 = monoeg_g_strerror (D.13210);
      monoeg_g_log (0B, 16, "%s: semctl init error: %s - trying again", &__func__, D.13229);
      <D.13228>:
      _wapi_sem_id.7 = _wapi_sem_id;
      semctl (_wapi_sem_id.7, 0, 0);
      goto again;
      <D.13226>:
      D.13230 = &tmp_shared->sem_key;
      D.13231 = InterlockedCompareExchange (D.13230, key, 0);
      if (D.13231 != 0) goto <D.13232>; else goto done;
      <D.13232>:
      _wapi_sem_id.7 = _wapi_sem_id;
      semctl (_wapi_sem_id.7, 0, 0);
      oldkey = tmp_shared->sem_key;
      <D.13208>:
      _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.13234>; else goto <D.13235>;
      <D.13234>:
      if (retries > 3) goto <D.13236>; else goto <D.13237>;
      <D.13236>:
      D.13209 = __errno_location ();
      D.13210 = *D.13209;
      D.13238 = monoeg_g_strerror (D.13210);
      monoeg_g_log (0B, 16, "%s: semget error opening old key 0x%x (%s) - trying again", &__func__, oldkey, D.13238);
      <D.13237>:
      D.13239 = &tmp_shared->sem_key;
      InterlockedCompareExchange (D.13239, 0, oldkey);
      goto again;
      <D.13235>:
      done:
      thr_ret = _wapi_shm_sem_lock (6);
      D.13240 = thr_ret != 0;
      D.13241 = (long int) D.13240;
      D.13242 = __builtin_expect (D.13241, 0);
      if (D.13242 != 0) goto <D.13243>; else goto <D.13244>;
      <D.13243>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "shared.c", 645, "thr_ret == 0");
      <D.13244>:
      _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.13246>; else goto <D.13247>;
      <D.13246>:
      monoeg_g_free (tmp_shared);
      goto <D.13248>;
      <D.13247>:
      munmap (tmp_shared, 81928);
      <D.13248>:
    }
  finally
    {
      defs = {CLOBBER};
      def_vals = {CLOBBER};
    }
}


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

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


_wapi_shm_semaphores_remove ()
{
  int _wapi_shm_disabled.12;

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


shm_semaphores_remove ()
{
  _Bool D.13257;
  long int D.13258;
  long int D.13259;
  int _wapi_sem_id.13;
  _Bool D.13263;
  long int D.13264;
  long int D.13265;
  gchar * D.13270;
  gchar * D.13271;
  int thr_ret;
  int proc_count;
  gchar * shm_name;

  thr_ret = _wapi_shm_sem_lock (6);
  D.13257 = thr_ret != 0;
  D.13258 = (long int) D.13257;
  D.13259 = __builtin_expect (D.13258, 0);
  if (D.13259 != 0) goto <D.13260>; else goto <D.13261>;
  <D.13260>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "shared.c", 678, "thr_ret == 0");
  <D.13261>:
  _wapi_sem_id.13 = _wapi_sem_id;
  proc_count = semctl (_wapi_sem_id.13, 7, 12);
  D.13263 = proc_count <= 0;
  D.13264 = (long int) D.13263;
  D.13265 = __builtin_expect (D.13264, 0);
  if (D.13265 != 0) goto <D.13266>; else goto <D.13267>;
  <D.13266>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "shared.c", 683, "proc_count > 0");
  <D.13267>:
  if (proc_count == 1) goto <D.13268>; else goto <D.13269>;
  <D.13268>:
  _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.13270 = _wapi_shm_file (0);
  unlink (D.13270);
  D.13271 = _wapi_shm_file (1);
  unlink (D.13271);
  goto <D.13272>;
  <D.13269>:
  _wapi_shm_sem_unlock (6);
  <D.13272>:
}


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

  _wapi_shm_disabled.14 = _wapi_shm_disabled;
  if (_wapi_shm_disabled.14 != 0) goto <D.13274>; else goto <D.13275>;
  <D.13274>:
  D.13276 = noshm_sem_lock (sem);
  return D.13276;
  <D.13275>:
  D.13276 = shm_sem_lock (sem);
  return D.13276;
}


noshm_sem_lock (int sem)
{
  union mono_mutex_t * D.13278;
  int D.13279;
  int ret;

  D.13278 = &noshm_sems[sem];
  ret = pthread_mutex_lock (D.13278);
  D.13279 = ret;
  return D.13279;
}


shm_sem_lock (int sem)
{
  short unsigned int D.13281;
  int _wapi_sem_id.15;
  int * D.13284;
  int D.13285;
  int D.13288;
  _Bool D.13289;
  _Bool D.13290;
  _Bool D.13291;
  int D.13294;
  struct sembuf ops;
  int ret;
  void retry = <<< error >>>;

  try
    {
      D.13281 = (short unsigned int) sem;
      ops.sem_num = D.13281;
      ops.sem_op = -1;
      ops.sem_flg = 4096;
      retry:
      <D.12990>:
      _wapi_sem_id.15 = _wapi_sem_id;
      ret = semop (_wapi_sem_id.15, &ops, 1);
      if (ret == -1) goto <D.13283>; else goto <D.12991>;
      <D.13283>:
      D.13284 = __errno_location ();
      D.13285 = *D.13284;
      if (D.13285 == 4) goto <D.12990>; else goto <D.12991>;
      <D.12991>:
      if (ret == -1) goto <D.13286>; else goto <D.13287>;
      <D.13286>:
      D.13284 = __errno_location ();
      D.13288 = *D.13284;
      D.13289 = D.13288 == 43;
      D.13290 = D.13288 == 22;
      D.13291 = D.13289 | D.13290;
      if (D.13291 != 0) goto <D.13292>; else goto <D.13293>;
      <D.13292>:
      _wapi_shm_semaphores_init ();
      goto retry;
      <D.13293>:
      D.13284 = __errno_location ();
      ret = *D.13284;
      <D.13287>:
      D.13294 = ret;
      return D.13294;
    }
  finally
    {
      ops = {CLOBBER};
    }
}


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

  _wapi_shm_disabled.16 = _wapi_shm_disabled;
  if (_wapi_shm_disabled.16 != 0) goto <D.13298>; else goto <D.13299>;
  <D.13298>:
  D.13300 = noshm_sem_trylock (sem);
  return D.13300;
  <D.13299>:
  D.13300 = shm_sem_trylock (sem);
  return D.13300;
}


noshm_sem_trylock (int sem)
{
  union mono_mutex_t * D.13302;
  int D.13303;
  int ret;

  D.13302 = &noshm_sems[sem];
  ret = pthread_mutex_trylock (D.13302);
  D.13303 = ret;
  return D.13303;
}


shm_sem_trylock (int sem)
{
  short unsigned int D.13305;
  int _wapi_sem_id.17;
  int * D.13308;
  int D.13309;
  int D.13312;
  _Bool D.13313;
  _Bool D.13314;
  _Bool D.13315;
  int D.13320;
  struct sembuf ops;
  int ret;
  void retry = <<< error >>>;

  try
    {
      D.13305 = (short unsigned int) sem;
      ops.sem_num = D.13305;
      ops.sem_op = -1;
      ops.sem_flg = 6144;
      retry:
      <D.12998>:
      _wapi_sem_id.17 = _wapi_sem_id;
      ret = semop (_wapi_sem_id.17, &ops, 1);
      if (ret == -1) goto <D.13307>; else goto <D.12999>;
      <D.13307>:
      D.13308 = __errno_location ();
      D.13309 = *D.13308;
      if (D.13309 == 4) goto <D.12998>; else goto <D.12999>;
      <D.12999>:
      if (ret == -1) goto <D.13310>; else goto <D.13311>;
      <D.13310>:
      D.13308 = __errno_location ();
      D.13312 = *D.13308;
      D.13313 = D.13312 == 43;
      D.13314 = D.13312 == 22;
      D.13315 = D.13313 | D.13314;
      if (D.13315 != 0) goto <D.13316>; else goto <D.13317>;
      <D.13316>:
      _wapi_shm_semaphores_init ();
      goto retry;
      <D.13317>:
      D.13308 = __errno_location ();
      ret = *D.13308;
      <D.13311>:
      if (ret == 11) goto <D.13318>; else goto <D.13319>;
      <D.13318>:
      ret = 16;
      <D.13319>:
      D.13320 = ret;
      return D.13320;
    }
  finally
    {
      ops = {CLOBBER};
    }
}


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

  _wapi_shm_disabled.18 = _wapi_shm_disabled;
  if (_wapi_shm_disabled.18 != 0) goto <D.13324>; else goto <D.13325>;
  <D.13324>:
  D.13326 = noshm_sem_unlock (sem);
  return D.13326;
  <D.13325>:
  D.13326 = shm_sem_unlock (sem);
  return D.13326;
}


noshm_sem_unlock (int sem)
{
  union mono_mutex_t * D.13328;
  int D.13329;
  int ret;

  D.13328 = &noshm_sems[sem];
  ret = pthread_mutex_unlock (D.13328);
  D.13329 = ret;
  return D.13329;
}


shm_sem_unlock (int sem)
{
  short unsigned int D.13331;
  int _wapi_sem_id.19;
  int * D.13334;
  int D.13335;
  int D.13338;
  _Bool D.13339;
  _Bool D.13340;
  _Bool D.13341;
  int D.13344;
  struct sembuf ops;
  int ret;
  void retry = <<< error >>>;

  try
    {
      D.13331 = (short unsigned int) sem;
      ops.sem_num = D.13331;
      ops.sem_op = 1;
      ops.sem_flg = 4096;
      retry:
      <D.13006>:
      _wapi_sem_id.19 = _wapi_sem_id;
      ret = semop (_wapi_sem_id.19, &ops, 1);
      if (ret == -1) goto <D.13333>; else goto <D.13007>;
      <D.13333>:
      D.13334 = __errno_location ();
      D.13335 = *D.13334;
      if (D.13335 == 4) goto <D.13006>; else goto <D.13007>;
      <D.13007>:
      if (ret == -1) goto <D.13336>; else goto <D.13337>;
      <D.13336>:
      D.13334 = __errno_location ();
      D.13338 = *D.13334;
      D.13339 = D.13338 == 43;
      D.13340 = D.13338 == 22;
      D.13341 = D.13339 | D.13340;
      if (D.13341 != 0) goto <D.13342>; else goto <D.13343>;
      <D.13342>:
      _wapi_shm_semaphores_init ();
      goto retry;
      <D.13343>:
      D.13334 = __errno_location ();
      ret = *D.13334;
      <D.13337>:
      D.13344 = ret;
      return D.13344;
    }
  finally
    {
      ops = {CLOBBER};
    }
}


