_wapi_shm_enabled ()
{
  int env_checked.0;
  const gchar * D.10924;
  gboolean D.10927;
  int _wapi_shm_disabled.1;
  _Bool D.10929;
  static gboolean env_checked;

  env_checked.0 = env_checked;
  if (env_checked.0 == 0) goto <D.10922>; else goto <D.10923>;
  <D.10922>:
  D.10924 = monoeg_g_getenv ("MONO_ENABLE_SHM");
  if (D.10924 != 0B) goto <D.10925>; else goto <D.10926>;
  <D.10925>:
  _wapi_shm_disabled = 0;
  <D.10926>:
  env_checked = 1;
  <D.10923>:
  _wapi_shm_disabled.1 = _wapi_shm_disabled;
  D.10929 = _wapi_shm_disabled.1 == 0;
  D.10927 = (gboolean) D.10929;
  return D.10927;
}


_wapi_shm_attach (_wapi_shm_t type)
{
  void * D.10931;
  int D.10932;
  long unsigned int D.10935;
  void * D.10936;
  int size.2;
  int D.10942;
  int * D.10945;
  int D.10946;
  const gchar * D.10947;
  long int D.10948;
  long unsigned int D.10949;
  const gchar * D.10954;
  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.10841>, case 0: <D.10838>, case 1: <D.10840>>
      <D.10838>:
      size = 86024;
      goto <D.10839>;
      <D.10840>:
      size = 4096008;
      goto <D.10839>;
      <D.10841>:
      monoeg_g_log (0B, 4, "Invalid type in _wapi_shm_attach ()");
      <D.10842>:
      goto <D.10842>;
      D.10931 = 0B;
      return D.10931;
      <D.10839>:
      D.10932 = _wapi_shm_enabled ();
      if (D.10932 == 0) goto <D.10933>; else goto <D.10934>;
      <D.10933>:
      D.10935 = (long unsigned int) size;
      D.10936 = monoeg_malloc0 (D.10935);
      wapi_storage[type] = D.10936;
      D.10931 = wapi_storage[type];
      return D.10931;
      <D.10934>:
      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.10938>; else goto <D.10939>;
      <D.10938>:
      fd = _wapi_shm_file_open (filename, size);
      <D.10939>:
      if (fd == -1) goto <D.10940>; else goto <D.10941>;
      <D.10940>:
      monoeg_g_log (0B, 8, "%s: shared file [%s] open error", &__func__, filename);
      D.10931 = 0B;
      return D.10931;
      <D.10941>:
      D.10942 = fstat (fd, &statbuf);
      if (D.10942 == -1) goto <D.10943>; else goto <D.10944>;
      <D.10943>:
      D.10945 = __errno_location ();
      D.10946 = *D.10945;
      D.10947 = monoeg_g_strerror (D.10946);
      monoeg_g_log (0B, 8, "%s: fstat error: %s", &__func__, D.10947);
      close (fd);
      D.10931 = 0B;
      return D.10931;
      <D.10944>:
      D.10948 = statbuf.st_size;
      D.10949 = (long unsigned int) D.10948;
      shm_seg = mmap (0B, D.10949, 3, 1, fd, 0);
      if (shm_seg == -1B) goto <D.10950>; else goto <D.10951>;
      <D.10950>:
      D.10948 = statbuf.st_size;
      D.10949 = (long unsigned int) D.10948;
      shm_seg = mmap (0B, D.10949, 3, 2, fd, 0);
      if (shm_seg == -1B) goto <D.10952>; else goto <D.10953>;
      <D.10952>:
      D.10945 = __errno_location ();
      D.10946 = *D.10945;
      D.10954 = monoeg_g_strerror (D.10946);
      monoeg_g_log (0B, 8, "%s: mmap error: %s", &__func__, D.10954);
      close (fd);
      D.10931 = 0B;
      return D.10931;
      <D.10953>:
      <D.10951>:
      close (fd);
      D.10931 = shm_seg;
      return D.10931;
    }
  finally
    {
      statbuf = {CLOBBER};
    }
}


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


_wapi_shm_base_name (_wapi_shm_t type)
{
  int D.10968;
  int iftmp.3;
  long unsigned int D.10973;
  long unsigned int D.10976;
  long unsigned int D.10978;
  gchar * D.10980;
  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.10963>; else goto <D.10964>;
      <D.10963>:
      ubuf.machine[0] = 0;
      ubuf.sysname[0] = 0;
      goto <D.10965>;
      <D.10964>:
      monoeg_g_strdelimit (&ubuf.sysname, "/", 95);
      monoeg_g_strdelimit (&ubuf.machine, "/", 95);
      <D.10965>:
      fake_name = monoeg_g_getenv ("MONO_SHARED_HOSTNAME");
      if (fake_name == 0B) goto <D.10966>; else goto <D.10967>;
      <D.10966>:
      D.10968 = gethostname (&machine_name, 256);
      if (D.10968 != 0) goto <D.10969>; else goto <D.10970>;
      <D.10969>:
      machine_name[0] = 0;
      <D.10970>:
      goto <D.10971>;
      <D.10967>:
      D.10973 = __strlen_g (fake_name);
      if (D.10973 <= 254) goto <D.10974>; else goto <D.10975>;
      <D.10974>:
      D.10976 = __strlen_g (fake_name);
      iftmp.3 = (int) D.10976;
      goto <D.10977>;
      <D.10975>:
      iftmp.3 = 255;
      <D.10977>:
      len = iftmp.3;
      D.10978 = (long unsigned int) len;
      strncpy (&machine_name, fake_name, D.10978);
      machine_name[len] = 0;
      <D.10971>:
      switch (type) <default: <D.10979>, case 0: <D.10790>, case 1: <D.10792>>
      <D.10790>:
      name = monoeg_g_strdup_printf ("shared_data-%s-%s-%s-%d-%d-%d", &machine_name, &ubuf.sysname, &ubuf.machine, 336, 12, 0);
      goto <D.10791>;
      <D.10792>:
      name = monoeg_g_strdup_printf ("shared_fileshare-%s-%s-%s-%d-%d-%d", &machine_name, &ubuf.sysname, &ubuf.machine, 40, 12, 0);
      goto <D.10791>;
      <D.10979>:
      <D.10791>:
      D.10980 = name;
      return D.10980;
    }
  finally
    {
      machine_name = {CLOBBER};
      ubuf = {CLOBBER};
    }
}


__attribute__((__artificial__, __gnu_inline__, __always_inline__, __leaf__, __nothrow__))
gethostname (char * __buf, size_t __buflen)
{
  long unsigned int D.10983;
  int D.10986;
  int D.10989;
  long unsigned int D.10990;
  long unsigned int D.10991;
  long unsigned int D.10994;

  D.10983 = __builtin_object_size (__buf, 1);
  if (D.10983 != 18446744073709551615) goto <D.10984>; else goto <D.10985>;
  <D.10984>:
  D.10986 = __builtin_constant_p (__buflen);
  if (D.10986 == 0) goto <D.10987>; else goto <D.10988>;
  <D.10987>:
  D.10990 = __builtin_object_size (__buf, 1);
  D.10989 = __gethostname_chk (__buf, __buflen, D.10990);
  return D.10989;
  <D.10988>:
  D.10991 = __builtin_object_size (__buf, 1);
  if (D.10991 < __buflen) goto <D.10992>; else goto <D.10993>;
  <D.10992>:
  D.10994 = __builtin_object_size (__buf, 1);
  D.10989 = __gethostname_chk_warn (__buf, __buflen, D.10994);
  return D.10989;
  <D.10993>:
  <D.10985>:
  D.10989 = __gethostname_alias (__buf, __buflen);
  return D.10989;
}


__attribute__((__gnu_inline__))
__strlen_g (const char * __str)
{
  size_t D.10996;
  long int __ptr.4;
  long int __str.5;
  long int D.10999;
  char * __ptr;
  char * __tmp;

  __ptr = 0B;
  __tmp = __str;
  __asm__ __volatile__("   la    0,0
0: srst  %0,%1
   jo    0b
" : "=&a" __ptr, "=&a" __tmp : "0" __ptr, "1" __tmp : "0", "memory", "cc");
  __ptr.4 = (long int) __ptr;
  __str.5 = (long int) __str;
  D.10999 = __ptr.4 - __str.5;
  D.10996 = (size_t) D.10999;
  return D.10996;
}


__attribute__((__artificial__, __gnu_inline__, __always_inline__, __nothrow__, __leaf__))
strncpy (char * restrict __dest, const char * restrict __src, size_t __len)
{
  char * D.11001;
  long unsigned int D.11002;

  D.11002 = __builtin_object_size (__dest, 1);
  D.11001 = __builtin___strncpy_chk (__dest, __src, __len, D.11002);
  return D.11001;
}


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

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


_wapi_shm_open (const char * filename, int size)
{
  int D.11009;
  long int D.11010;
  int D.11011;
  int fd;

  fd = shm_open (filename, 66, 416);
  if (fd == -1) goto <D.11007>; else goto <D.11008>;
  <D.11007>:
  D.11009 = -1;
  return D.11009;
  <D.11008>:
  D.11010 = (long int) size;
  D.11011 = ftruncate (fd, D.11010);
  if (D.11011 != 0) goto <D.11012>; else goto <D.11013>;
  <D.11012>:
  perror ("_wapi_shm_open (): ftruncate ()");
  monoeg_assertion_message ("* Assertion: should not be reached at %s:%d\n", "shared.c", 245);
  <D.11013>:
  D.11009 = fd;
  return D.11009;
}


_wapi_shm_file_open (const gchar * filename, guint32 wanted_size)
{
  int tries.6;
  int D.11018;
  int * D.11024;
  int D.11025;
  const gchar * D.11032;
  unsigned int D.11033;
  long int D.11034;
  long int D.11035;
  const gchar * D.11038;
  long int D.11039;
  const gchar * D.11043;
  const gchar * D.11046;
  int D.11047;
  const gchar * D.11050;
  long int D.11053;
  long int D.11054;
  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.6 = tries;
      tries = tries.6 + 1;
      if (tries.6 > 10) goto <D.11016>; else goto <D.11017>;
      <D.11016>:
      D.11018 = -1;
      return D.11018;
      <D.11017>:
      if (tries > 5) goto <D.11019>; else goto <D.11020>;
      <D.11019>:
      unlink (filename);
      <D.11020>:
      oldmask = umask (54);
      fd = open (filename, 2, 384);
      umask (oldmask);
      if (fd == -1) goto <D.11023>; else goto <D.11021>;
      <D.11023>:
      D.11024 = __errno_location ();
      D.11025 = *D.11024;
      if (D.11025 == 2) goto <D.11026>; else goto <D.11021>;
      <D.11026>:
      oldmask = umask (54);
      fd = open (filename, 194, 384);
      umask (oldmask);
      if (fd == -1) goto <D.11029>; else goto <D.11027>;
      <D.11029>:
      D.11024 = __errno_location ();
      D.11025 = *D.11024;
      if (D.11025 == 17) goto try_again; else goto <D.11027>;
      goto <D.11028>;
      <D.11027>:
      if (fd == -1) goto <D.11030>; else goto <D.11031>;
      <D.11030>:
      D.11024 = __errno_location ();
      D.11025 = *D.11024;
      D.11032 = monoeg_g_strerror (D.11025);
      monoeg_g_log (0B, 8, "%s: shared file [%s] open error: %s", &__func__, filename, D.11032);
      D.11018 = -1;
      return D.11018;
      <D.11031>:
      D.11033 = wanted_size + 4294967295;
      D.11034 = (long int) D.11033;
      D.11035 = lseek (fd, D.11034, 0);
      if (D.11035 == -1) goto <D.11036>; else goto <D.11037>;
      <D.11036>:
      D.11024 = __errno_location ();
      D.11025 = *D.11024;
      D.11038 = monoeg_g_strerror (D.11025);
      monoeg_g_log (0B, 8, "%s: shared file [%s] lseek error: %s", &__func__, filename, D.11038);
      close (fd);
      unlink (filename);
      D.11018 = -1;
      return D.11018;
      <D.11037>:
      <D.10823>:
      D.11039 = write (fd, "", 1);
      ret = (int) D.11039;
      if (ret == -1) goto <D.11040>; else goto <D.10824>;
      <D.11040>:
      D.11024 = __errno_location ();
      D.11025 = *D.11024;
      if (D.11025 == 4) goto <D.10823>; else goto <D.10824>;
      <D.10824>:
      if (ret == -1) goto <D.11041>; else goto <D.11042>;
      <D.11041>:
      D.11024 = __errno_location ();
      D.11025 = *D.11024;
      D.11043 = monoeg_g_strerror (D.11025);
      monoeg_g_log (0B, 8, "%s: shared file [%s] write error: %s", &__func__, filename, D.11043);
      close (fd);
      unlink (filename);
      D.11018 = -1;
      return D.11018;
      <D.11042>:
      created = 1;
      <D.11028>:
      goto <D.11022>;
      <D.11021>:
      if (fd == -1) goto <D.11044>; else goto <D.11045>;
      <D.11044>:
      D.11024 = __errno_location ();
      D.11025 = *D.11024;
      D.11046 = monoeg_g_strerror (D.11025);
      monoeg_g_log (0B, 8, "%s: shared file [%s] open error: %s", &__func__, filename, D.11046);
      D.11018 = -1;
      return D.11018;
      <D.11045>:
      <D.11022>:
      D.11047 = fstat (fd, &statbuf);
      if (D.11047 == -1) goto <D.11048>; else goto <D.11049>;
      <D.11048>:
      D.11024 = __errno_location ();
      D.11025 = *D.11024;
      D.11050 = monoeg_g_strerror (D.11025);
      monoeg_g_log (0B, 8, "%s: fstat error: %s", &__func__, D.11050);
      if (created == 1) goto <D.11051>; else goto <D.11052>;
      <D.11051>:
      unlink (filename);
      <D.11052>:
      close (fd);
      D.11018 = -1;
      return D.11018;
      <D.11049>:
      D.11053 = statbuf.st_size;
      D.11054 = (long int) wanted_size;
      if (D.11053 < D.11054) goto <D.11055>; else goto <D.11056>;
      <D.11055>:
      close (fd);
      if (created == 1) goto <D.11057>; else goto <D.11058>;
      <D.11057>:
      D.11053 = statbuf.st_size;
      monoeg_g_log (0B, 8, "%s: shared file [%s] is not big enough! (found %ld, need %d bytes)", &__func__, filename, D.11053, wanted_size);
      unlink (filename);
      D.11018 = -1;
      return D.11018;
      <D.11058>:
      _wapi_handle_spin (100);
      goto try_again;
      <D.11056>:
      D.11018 = fd;
      return D.11018;
    }
  finally
    {
      statbuf = {CLOBBER};
    }
}


__attribute__((__artificial__, __gnu_inline__, __always_inline__))
open (const char * __path, int __oflag)
{
  int D.11061;
  int D.11064;
  int D.11069;
  int D.11071;
  int D.11072;
  int D.11075;
  int D.11076;

  D.11061 = __builtin_va_arg_pack_len ();
  if (D.11061 > 1) goto <D.11062>; else goto <D.11063>;
  <D.11062>:
  __open_too_many_args ();
  <D.11063>:
  D.11064 = __builtin_constant_p (__oflag);
  if (D.11064 != 0) goto <D.11065>; else goto <D.11066>;
  <D.11065>:
  D.11069 = __oflag & 64;
  if (D.11069 != 0) goto <D.11067>; else goto <D.11070>;
  <D.11070>:
  D.11071 = __oflag & 4259840;
  if (D.11071 == 4259840) goto <D.11067>; else goto <D.11068>;
  <D.11067>:
  D.11072 = __builtin_va_arg_pack_len ();
  if (D.11072 <= 0) goto <D.11073>; else goto <D.11074>;
  <D.11073>:
  __open_missing_mode ();
  D.11075 = __open_2 (__path, __oflag);
  return D.11075;
  <D.11074>:
  <D.11068>:
  D.11075 = __open_alias (__path, __oflag, __builtin_va_arg_pack ());
  return D.11075;
  <D.11066>:
  D.11076 = __builtin_va_arg_pack_len ();
  if (D.11076 <= 0) goto <D.11077>; else goto <D.11078>;
  <D.11077>:
  D.11075 = __open_2 (__path, __oflag);
  return D.11075;
  <D.11078>:
  D.11075 = __open_alias (__path, __oflag, __builtin_va_arg_pack ());
  return D.11075;
}


_wapi_handle_spin (guint32 ms)
{
  _Bool D.11080;
  long int D.11081;
  long int D.11082;
  unsigned int D.11085;
  long int D.11086;
  struct timespec sleepytime;

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


__attribute__((__gnu_inline__, __leaf__, __nothrow__))
fstat (int __fd, struct stat * __statbuf)
{
  int D.11087;

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


_wapi_shm_detach (_wapi_shm_t type)
{
  int D.11089;
  void * D.11092;

  D.11089 = _wapi_shm_enabled ();
  if (D.11089 == 0) goto <D.11090>; else goto <D.11091>;
  <D.11090>:
  D.11092 = wapi_storage[type];
  monoeg_g_free (D.11092);
  <D.11091>:
}


_wapi_shm_semaphores_init ()
{
  int D.11093;

  D.11093 = _wapi_shm_enabled ();
  if (D.11093 == 0) goto <D.11094>; else goto <D.11095>;
  <D.11094>:
  noshm_semaphores_init ();
  goto <D.11096>;
  <D.11095>:
  shm_semaphores_init ();
  <D.11096>:
}


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

  i = 0;
  goto <D.10767>;
  <D.10766>:
  D.11097 = &noshm_sems[i];
  pthread_mutex_init (D.11097, 0B);
  i = i + 1;
  <D.10767>:
  if (i <= 7) goto <D.10766>; else goto <D.10768>;
  <D.10768>:
}


shm_semaphores_init ()
{
  _Bool D.11098;
  long int D.11099;
  long int D.11100;
  _Bool D.11103;
  long int D.11104;
  long int D.11105;
  int * D.11110;
  int D.11111;
  const gchar * D.11114;
  const gchar * D.11117;
  const gchar * D.11122;
  int D.11123;
  int _wapi_sem_id.7;
  int D.11125;
  const gchar * D.11130;
  volatile key_t * D.11131;
  int D.11132;
  int D.11134;
  const gchar * D.11139;
  volatile key_t * D.11140;
  _Bool D.11141;
  long int D.11142;
  long int D.11143;
  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.10865>;
      <D.10864>:
      def_vals[i] = 1;
      i = i + 1;
      <D.10865>:
      if (i <= 7) goto <D.10864>; else goto <D.10866>;
      <D.10866>:
      def_vals[7] = 0;
      defs.array = &def_vals;
      tmp_shared = _wapi_shm_attach (0);
      D.11098 = tmp_shared == 0B;
      D.11099 = (long int) D.11098;
      D.11100 = __builtin_expect (D.11099, 0);
      if (D.11100 != 0) goto <D.11101>; else goto <D.11102>;
      <D.11101>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "shared.c", 547, "tmp_shared != NULL");
      <D.11102>:
      ftmp = _wapi_shm_shm_name (0);
      filename = monoeg_g_build_path ("/", "/dev/shm", ftmp, 0B);
      D.11103 = filename == 0B;
      D.11104 = (long int) D.11103;
      D.11105 = __builtin_expect (D.11104, 0);
      if (D.11105 != 0) goto <D.11106>; else goto <D.11107>;
      <D.11106>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "shared.c", 552, "filename!=NULL");
      <D.11107>:
      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.11108>; else goto <D.11109>;
      <D.11108>:
      goto <D.10872>;
      <D.10871>:
      D.11110 = __errno_location ();
      D.11111 = *D.11110;
      if (D.11111 == 12) goto <D.11112>; else goto <D.11113>;
      <D.11112>:
      D.11110 = __errno_location ();
      D.11111 = *D.11110;
      D.11114 = monoeg_g_strerror (D.11111);
      monoeg_g_log (0B, 4, "%s: semget error: %s", &__func__, D.11114);
      <D.10869>:
      goto <D.10869>;
      <D.11113>:
      D.11110 = __errno_location ();
      D.11111 = *D.11110;
      if (D.11111 == 28) goto <D.11115>; else goto <D.11116>;
      <D.11115>:
      D.11110 = __errno_location ();
      D.11111 = *D.11110;
      D.11117 = monoeg_g_strerror (D.11111);
      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.11117);
      <D.10870>:
      goto <D.10870>;
      <D.11116>:
      D.11110 = __errno_location ();
      D.11111 = *D.11110;
      if (D.11111 != 17) goto <D.11118>; else goto <D.11119>;
      <D.11118>:
      if (retries > 3) goto <D.11120>; else goto <D.11121>;
      <D.11120>:
      D.11110 = __errno_location ();
      D.11111 = *D.11110;
      D.11122 = monoeg_g_strerror (D.11111);
      monoeg_g_log (0B, 16, "%s: semget error: %s key 0x%x - trying again", &__func__, D.11122, key);
      <D.11121>:
      <D.11119>:
      key = key + 1;
      <D.10872>:
      D.11123 = semget (key, 8, 1920);
      _wapi_sem_id = D.11123;
      _wapi_sem_id.7 = _wapi_sem_id;
      if (_wapi_sem_id.7 == -1) goto <D.10871>; else goto <D.10873>;
      <D.10873>:
      _wapi_sem_id.7 = _wapi_sem_id;
      D.11125 = semctl (_wapi_sem_id.7, 0, 17, defs);
      if (D.11125 == -1) goto <D.11126>; else goto <D.11127>;
      <D.11126>:
      if (retries > 3) goto <D.11128>; else goto <D.11129>;
      <D.11128>:
      D.11110 = __errno_location ();
      D.11111 = *D.11110;
      D.11130 = monoeg_g_strerror (D.11111);
      monoeg_g_log (0B, 16, "%s: semctl init error: %s - trying again", &__func__, D.11130);
      <D.11129>:
      _wapi_sem_id.7 = _wapi_sem_id;
      semctl (_wapi_sem_id.7, 0, 0);
      goto again;
      <D.11127>:
      D.11131 = &tmp_shared->sem_key;
      D.11132 = InterlockedCompareExchange (D.11131, key, 0);
      if (D.11132 != 0) goto <D.11133>; else goto done;
      <D.11133>:
      _wapi_sem_id.7 = _wapi_sem_id;
      semctl (_wapi_sem_id.7, 0, 0);
      oldkey = tmp_shared->sem_key;
      <D.11109>:
      D.11134 = semget (oldkey, 8, 384);
      _wapi_sem_id = D.11134;
      _wapi_sem_id.7 = _wapi_sem_id;
      if (_wapi_sem_id.7 == -1) goto <D.11135>; else goto <D.11136>;
      <D.11135>:
      if (retries > 3) goto <D.11137>; else goto <D.11138>;
      <D.11137>:
      D.11110 = __errno_location ();
      D.11111 = *D.11110;
      D.11139 = monoeg_g_strerror (D.11111);
      monoeg_g_log (0B, 16, "%s: semget error opening old key 0x%x (%s) - trying again", &__func__, oldkey, D.11139);
      <D.11138>:
      D.11140 = &tmp_shared->sem_key;
      InterlockedCompareExchange (D.11140, 0, oldkey);
      goto again;
      <D.11136>:
      done:
      thr_ret = _wapi_shm_sem_lock (6);
      D.11141 = thr_ret != 0;
      D.11142 = (long int) D.11141;
      D.11143 = __builtin_expect (D.11142, 0);
      if (D.11143 != 0) goto <D.11144>; else goto <D.11145>;
      <D.11144>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "shared.c", 645, "thr_ret == 0");
      <D.11145>:
      _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.11147>; else goto <D.11148>;
      <D.11147>:
      monoeg_g_free (tmp_shared);
      goto <D.11149>;
      <D.11148>:
      munmap (tmp_shared, 86024);
      <D.11149>:
    }
  finally
    {
      defs = {CLOBBER};
      def_vals = {CLOBBER};
    }
}


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

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


_wapi_shm_semaphores_remove ()
{
  int _wapi_shm_disabled.11;

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


shm_semaphores_remove ()
{
  _Bool D.11158;
  long int D.11159;
  long int D.11160;
  int _wapi_sem_id.12;
  _Bool D.11164;
  long int D.11165;
  long int D.11166;
  gchar * D.11171;
  gchar * D.11172;
  int thr_ret;
  int proc_count;
  gchar * shm_name;

  thr_ret = _wapi_shm_sem_lock (6);
  D.11158 = thr_ret != 0;
  D.11159 = (long int) D.11158;
  D.11160 = __builtin_expect (D.11159, 0);
  if (D.11160 != 0) goto <D.11161>; else goto <D.11162>;
  <D.11161>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "shared.c", 678, "thr_ret == 0");
  <D.11162>:
  _wapi_sem_id.12 = _wapi_sem_id;
  proc_count = semctl (_wapi_sem_id.12, 7, 12);
  D.11164 = proc_count <= 0;
  D.11165 = (long int) D.11164;
  D.11166 = __builtin_expect (D.11165, 0);
  if (D.11166 != 0) goto <D.11167>; else goto <D.11168>;
  <D.11167>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "shared.c", 683, "proc_count > 0");
  <D.11168>:
  if (proc_count == 1) goto <D.11169>; else goto <D.11170>;
  <D.11169>:
  _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.11171 = _wapi_shm_file (0);
  unlink (D.11171);
  D.11172 = _wapi_shm_file (1);
  unlink (D.11172);
  goto <D.11173>;
  <D.11170>:
  _wapi_shm_sem_unlock (6);
  <D.11173>:
}


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

  _wapi_shm_disabled.13 = _wapi_shm_disabled;
  if (_wapi_shm_disabled.13 != 0) goto <D.11175>; else goto <D.11176>;
  <D.11175>:
  D.11177 = noshm_sem_lock (sem);
  return D.11177;
  <D.11176>:
  D.11177 = shm_sem_lock (sem);
  return D.11177;
}


noshm_sem_lock (int sem)
{
  union mono_mutex_t * D.11179;
  int D.11180;
  int ret;

  D.11179 = &noshm_sems[sem];
  ret = pthread_mutex_lock (D.11179);
  D.11180 = ret;
  return D.11180;
}


shm_sem_lock (int sem)
{
  short unsigned int D.11182;
  int _wapi_sem_id.14;
  int * D.11185;
  int D.11186;
  int D.11192;
  struct sembuf ops;
  int ret;
  void retry = <<< error >>>;

  try
    {
      D.11182 = (short unsigned int) sem;
      ops.sem_num = D.11182;
      ops.sem_op = -1;
      ops.sem_flg = 4096;
      retry:
      <D.10887>:
      _wapi_sem_id.14 = _wapi_sem_id;
      ret = semop (_wapi_sem_id.14, &ops, 1);
      if (ret == -1) goto <D.11184>; else goto <D.10888>;
      <D.11184>:
      D.11185 = __errno_location ();
      D.11186 = *D.11185;
      if (D.11186 == 4) goto <D.10887>; else goto <D.10888>;
      <D.10888>:
      if (ret == -1) goto <D.11187>; else goto <D.11188>;
      <D.11187>:
      D.11185 = __errno_location ();
      D.11186 = *D.11185;
      if (D.11186 == 43) goto <D.11189>; else goto <D.11191>;
      <D.11191>:
      D.11185 = __errno_location ();
      D.11186 = *D.11185;
      if (D.11186 == 22) goto <D.11189>; else goto <D.11190>;
      <D.11189>:
      _wapi_shm_semaphores_init ();
      goto retry;
      <D.11190>:
      D.11185 = __errno_location ();
      ret = *D.11185;
      <D.11188>:
      D.11192 = ret;
      return D.11192;
    }
  finally
    {
      ops = {CLOBBER};
    }
}


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

  _wapi_shm_disabled.15 = _wapi_shm_disabled;
  if (_wapi_shm_disabled.15 != 0) goto <D.11196>; else goto <D.11197>;
  <D.11196>:
  D.11198 = noshm_sem_trylock (sem);
  return D.11198;
  <D.11197>:
  D.11198 = shm_sem_trylock (sem);
  return D.11198;
}


noshm_sem_trylock (int sem)
{
  union mono_mutex_t * D.11200;
  int D.11201;
  int ret;

  D.11200 = &noshm_sems[sem];
  ret = pthread_mutex_trylock (D.11200);
  D.11201 = ret;
  return D.11201;
}


shm_sem_trylock (int sem)
{
  short unsigned int D.11203;
  int _wapi_sem_id.16;
  int * D.11206;
  int D.11207;
  int D.11215;
  struct sembuf ops;
  int ret;
  void retry = <<< error >>>;

  try
    {
      D.11203 = (short unsigned int) sem;
      ops.sem_num = D.11203;
      ops.sem_op = -1;
      ops.sem_flg = 6144;
      retry:
      <D.10895>:
      _wapi_sem_id.16 = _wapi_sem_id;
      ret = semop (_wapi_sem_id.16, &ops, 1);
      if (ret == -1) goto <D.11205>; else goto <D.10896>;
      <D.11205>:
      D.11206 = __errno_location ();
      D.11207 = *D.11206;
      if (D.11207 == 4) goto <D.10895>; else goto <D.10896>;
      <D.10896>:
      if (ret == -1) goto <D.11208>; else goto <D.11209>;
      <D.11208>:
      D.11206 = __errno_location ();
      D.11207 = *D.11206;
      if (D.11207 == 43) goto <D.11210>; else goto <D.11212>;
      <D.11212>:
      D.11206 = __errno_location ();
      D.11207 = *D.11206;
      if (D.11207 == 22) goto <D.11210>; else goto <D.11211>;
      <D.11210>:
      _wapi_shm_semaphores_init ();
      goto retry;
      <D.11211>:
      D.11206 = __errno_location ();
      ret = *D.11206;
      <D.11209>:
      if (ret == 11) goto <D.11213>; else goto <D.11214>;
      <D.11213>:
      ret = 16;
      <D.11214>:
      D.11215 = ret;
      return D.11215;
    }
  finally
    {
      ops = {CLOBBER};
    }
}


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

  _wapi_shm_disabled.17 = _wapi_shm_disabled;
  if (_wapi_shm_disabled.17 != 0) goto <D.11219>; else goto <D.11220>;
  <D.11219>:
  D.11221 = noshm_sem_unlock (sem);
  return D.11221;
  <D.11220>:
  D.11221 = shm_sem_unlock (sem);
  return D.11221;
}


noshm_sem_unlock (int sem)
{
  union mono_mutex_t * D.11223;
  int D.11224;
  int ret;

  D.11223 = &noshm_sems[sem];
  ret = pthread_mutex_unlock (D.11223);
  D.11224 = ret;
  return D.11224;
}


shm_sem_unlock (int sem)
{
  short unsigned int D.11226;
  int _wapi_sem_id.18;
  int * D.11229;
  int D.11230;
  int D.11236;
  struct sembuf ops;
  int ret;
  void retry = <<< error >>>;

  try
    {
      D.11226 = (short unsigned int) sem;
      ops.sem_num = D.11226;
      ops.sem_op = 1;
      ops.sem_flg = 4096;
      retry:
      <D.10903>:
      _wapi_sem_id.18 = _wapi_sem_id;
      ret = semop (_wapi_sem_id.18, &ops, 1);
      if (ret == -1) goto <D.11228>; else goto <D.10904>;
      <D.11228>:
      D.11229 = __errno_location ();
      D.11230 = *D.11229;
      if (D.11230 == 4) goto <D.10903>; else goto <D.10904>;
      <D.10904>:
      if (ret == -1) goto <D.11231>; else goto <D.11232>;
      <D.11231>:
      D.11229 = __errno_location ();
      D.11230 = *D.11229;
      if (D.11230 == 43) goto <D.11233>; else goto <D.11235>;
      <D.11235>:
      D.11229 = __errno_location ();
      D.11230 = *D.11229;
      if (D.11230 == 22) goto <D.11233>; else goto <D.11234>;
      <D.11233>:
      _wapi_shm_semaphores_init ();
      goto retry;
      <D.11234>:
      D.11229 = __errno_location ();
      ret = *D.11229;
      <D.11232>:
      D.11236 = ret;
      return D.11236;
    }
  finally
    {
      ops = {CLOBBER};
    }
}


