mutex_is_owned (void * handle)
{
  gboolean D.10112;
  struct _WapiHandle_mutex * mutex_handle.0;
  unsigned int D.10115;
  int D.10117;
  int D.10118;
  long unsigned int D.10120;
  long unsigned int D.10121;
  int D.10122;
  struct _WapiHandle_mutex * mutex_handle;
  gboolean ok;
  static const char __func__[15] = "mutex_is_owned";

  try
    {
      ok = _wapi_lookup_handle (handle, 5, &mutex_handle);
      if (ok == 0) goto <D.10110>; else goto <D.10111>;
      <D.10110>:
      monoeg_g_log (0B, 16, "%s: error looking up mutex handle %p", &__func__, handle);
      D.10112 = 0;
      return D.10112;
      <D.10111>:
      mutex_handle.0 = mutex_handle;
      D.10115 = mutex_handle.0->recursion;
      if (D.10115 != 0) goto <D.10116>; else goto <D.10113>;
      <D.10116>:
      mutex_handle.0 = mutex_handle;
      D.10117 = mutex_handle.0->pid;
      D.10118 = _wapi_getpid ();
      if (D.10117 == D.10118) goto <D.10119>; else goto <D.10113>;
      <D.10119>:
      D.10120 = pthread_self ();
      mutex_handle.0 = mutex_handle;
      D.10121 = mutex_handle.0->tid;
      D.10122 = pthread_equal (D.10121, D.10120);
      if (D.10122 != 0) goto <D.10123>; else goto <D.10113>;
      <D.10123>:
      D.10112 = 1;
      return D.10112;
      <D.10113>:
      D.10112 = 0;
      return D.10112;
    }
  finally
    {
      mutex_handle = {CLOBBER};
    }
}


pthread_equal (pthread_t __thread1, pthread_t __thread2)
{
  int D.10126;
  _Bool D.10127;

  D.10127 = __thread1 == __thread2;
  D.10126 = (int) D.10127;
  return D.10126;
}


mutex_own (void * handle)
{
  gboolean D.10131;
  struct _WapiHandle_mutex * mutex_handle.1;
  int D.10133;
  long unsigned int D.10134;
  unsigned int D.10135;
  unsigned int D.10136;
  struct _WapiHandle_mutex * mutex_handle;
  gboolean ok;
  static const char __func__[10] = "mutex_own";

  try
    {
      ok = _wapi_lookup_handle (handle, 5, &mutex_handle);
      if (ok == 0) goto <D.10129>; else goto <D.10130>;
      <D.10129>:
      monoeg_g_log (0B, 16, "%s: error looking up mutex handle %p", &__func__, handle);
      D.10131 = 0;
      return D.10131;
      <D.10130>:
      _wapi_thread_own_mutex (handle);
      _wapi_handle_set_signal_state (handle, 0, 0);
      mutex_handle.1 = mutex_handle;
      D.10133 = _wapi_getpid ();
      mutex_handle.1->pid = D.10133;
      mutex_handle.1 = mutex_handle;
      D.10134 = pthread_self ();
      mutex_handle.1->tid = D.10134;
      mutex_handle.1 = mutex_handle;
      D.10135 = mutex_handle.1->recursion;
      D.10136 = D.10135 + 1;
      mutex_handle.1->recursion = D.10136;
      D.10131 = 1;
      return D.10131;
    }
  finally
    {
      mutex_handle = {CLOBBER};
    }
}


_wapi_handle_set_signal_state (void * handle, gboolean state, gboolean broadcast)
{
  int iftmp.2;
  <unnamed type> D.10145;
  <unnamed type> D.10147;
  <unnamed type> D.10149;
  <unnamed type> D.10151;
  _Bool D.10152;
  long int D.10153;
  long int D.10154;
  unsigned int D.10157;
  struct _WapiHandleUnshared * D.10158;
  unsigned int D.10159;
  unsigned int D.10160;
  long int D.10163;
  union mono_mutex_t * _wapi_global_signal_mutex.3;
  _Bool D.10169;
  long int D.10170;
  long int D.10171;
  union pthread_cond_t * D.10176;
  union pthread_cond_t * _wapi_global_signal_cond.4;
  guint32 idx;
  struct _WapiHandleUnshared * handle_data;
  int thr_ret;

  idx = (guint32) handle;
  if (idx > 4194303) goto <D.10139>; else goto <D.10140>;
  <D.10139>:
  return;
  <D.10140>:
  D.10145 = _wapi_handle_type (handle);
  if (D.10145 == 9) goto <D.10142>; else goto <D.10146>;
  <D.10146>:
  D.10147 = _wapi_handle_type (handle);
  if (D.10147 == 11) goto <D.10142>; else goto <D.10148>;
  <D.10148>:
  D.10149 = _wapi_handle_type (handle);
  if (D.10149 == 12) goto <D.10142>; else goto <D.10150>;
  <D.10150>:
  D.10151 = _wapi_handle_type (handle);
  if (D.10151 == 13) goto <D.10142>; else goto <D.10143>;
  <D.10142>:
  iftmp.2 = 1;
  goto <D.10144>;
  <D.10143>:
  iftmp.2 = 0;
  <D.10144>:
  D.10152 = iftmp.2 != 0;
  D.10153 = (long int) D.10152;
  D.10154 = __builtin_expect (D.10153, 0);
  if (D.10154 != 0) goto <D.10155>; else goto <D.10156>;
  <D.10155>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "../../mono/io-layer/handles-private.h", 132, "!_WAPI_SHARED_HANDLE(_wapi_handle_type (handle))");
  <D.10156>:
  D.10157 = idx / 256;
  D.10158 = _wapi_private_handles[D.10157];
  D.10159 = idx & 255;
  D.10160 = D.10159 * 136;
  handle_data = D.10158 + D.10160;
  if (state == 1) goto <D.10161>; else goto <D.10162>;
  <D.10161>:
  {
    struct __pthread_unwind_buf_t __cancel_buf;
    void (*<Tbf>) (void *) __cancel_routine;
    void * __cancel_arg;
    int __not_first_call;

    try
      {
        __cancel_routine = mono_mutex_unlock_in_cleanup;
        __cancel_arg = _wapi_global_signal_mutex;
        __not_first_call = __sigsetjmp (&__cancel_buf.__cancel_jmp_buf, 0);
        D.10163 = __builtin_expect (__not_first_call, 0);
        if (D.10163 != 0) goto <D.10164>; else goto <D.10165>;
        <D.10164>:
        __cancel_routine (__cancel_arg);
        __pthread_unwind_next (&__cancel_buf);
        <D.10165>:
        __pthread_register_cancel (&__cancel_buf);
        _wapi_global_signal_mutex.3 = _wapi_global_signal_mutex;
        thr_ret = pthread_mutex_lock (_wapi_global_signal_mutex.3);
        if (thr_ret != 0) goto <D.10167>; else goto <D.10168>;
        <D.10167>:
        monoeg_g_log (0B, 16, "Bad call to mono_mutex_lock result %d for global signal mutex", thr_ret);
        <D.10168>:
        D.10169 = thr_ret != 0;
        D.10170 = (long int) D.10169;
        D.10171 = __builtin_expect (D.10170, 0);
        if (D.10171 != 0) goto <D.10172>; else goto <D.10173>;
        <D.10172>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "../../mono/io-layer/handles-private.h", 151, "thr_ret == 0");
        <D.10173>:
        handle_data->signalled = state;
        if (broadcast == 1) goto <D.10174>; else goto <D.10175>;
        <D.10174>:
        D.10176 = &handle_data->signal_cond;
        thr_ret = pthread_cond_broadcast (D.10176);
        if (thr_ret != 0) goto <D.10177>; else goto <D.10178>;
        <D.10177>:
        monoeg_g_log (0B, 16, "Bad call to pthread_cond_broadcast result %d for handle %p", thr_ret, handle);
        <D.10178>:
        D.10169 = thr_ret != 0;
        D.10170 = (long int) D.10169;
        D.10171 = __builtin_expect (D.10170, 0);
        if (D.10171 != 0) goto <D.10179>; else goto <D.10180>;
        <D.10179>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "../../mono/io-layer/handles-private.h", 162, "thr_ret == 0");
        <D.10180>:
        goto <D.10181>;
        <D.10175>:
        D.10176 = &handle_data->signal_cond;
        thr_ret = pthread_cond_signal (D.10176);
        if (thr_ret != 0) goto <D.10182>; else goto <D.10183>;
        <D.10182>:
        monoeg_g_log (0B, 16, "Bad call to pthread_cond_signal result %d for handle %p", thr_ret, handle);
        <D.10183>:
        D.10169 = thr_ret != 0;
        D.10170 = (long int) D.10169;
        D.10171 = __builtin_expect (D.10170, 0);
        if (D.10171 != 0) goto <D.10184>; else goto <D.10185>;
        <D.10184>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "../../mono/io-layer/handles-private.h", 167, "thr_ret == 0");
        <D.10185>:
        <D.10181>:
        _wapi_global_signal_cond.4 = _wapi_global_signal_cond;
        thr_ret = pthread_cond_broadcast (_wapi_global_signal_cond.4);
        if (thr_ret != 0) goto <D.10187>; else goto <D.10188>;
        <D.10187>:
        monoeg_g_log (0B, 16, "Bad call to pthread_cond_broadcast result %d for handle %p", thr_ret, handle);
        <D.10188>:
        D.10169 = thr_ret != 0;
        D.10170 = (long int) D.10169;
        D.10171 = __builtin_expect (D.10170, 0);
        if (D.10171 != 0) goto <D.10189>; else goto <D.10190>;
        <D.10189>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "../../mono/io-layer/handles-private.h", 176, "thr_ret == 0");
        <D.10190>:
        _wapi_global_signal_mutex.3 = _wapi_global_signal_mutex;
        thr_ret = pthread_mutex_unlock (_wapi_global_signal_mutex.3);
        if (thr_ret != 0) goto <D.10191>; else goto <D.10192>;
        <D.10191>:
        monoeg_g_log (0B, 16, "Bad call to mono_mutex_unlock result %d for global signal mutex", thr_ret);
        <D.10192>:
        D.10169 = thr_ret != 0;
        D.10170 = (long int) D.10169;
        D.10171 = __builtin_expect (D.10170, 0);
        if (D.10171 != 0) goto <D.10193>; else goto <D.10194>;
        <D.10193>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "../../mono/io-layer/handles-private.h", 181, "thr_ret == 0");
        <D.10194>:
        __pthread_unregister_cancel (&__cancel_buf);
        if (0 != 0) goto <D.10195>; else goto <D.10196>;
        <D.10195>:
        __cancel_routine (__cancel_arg);
        <D.10196>:
      }
    finally
      {
        __cancel_buf = {CLOBBER};
      }
  }
  goto <D.10197>;
  <D.10162>:
  handle_data->signalled = state;
  <D.10197>:
}


mono_mutex_unlock_in_cleanup (union mono_mutex_t * mutex)
{
  int D.10208;

  D.10208 = pthread_mutex_unlock (mutex);
  return D.10208;
}


_wapi_handle_type (void * handle)
{
  unsigned int D.10213;
  struct _WapiHandleUnshared * D.10214;
  WapiHandleType D.10215;
  unsigned int D.10216;
  unsigned int D.10217;
  struct _WapiHandleUnshared * D.10218;
  guint32 idx;

  idx = (guint32) handle;
  if (idx > 4194303) goto <D.10210>; else goto <D.10212>;
  <D.10212>:
  D.10213 = idx / 256;
  D.10214 = _wapi_private_handles[D.10213];
  if (D.10214 == 0B) goto <D.10210>; else goto <D.10211>;
  <D.10210>:
  D.10215 = 0;
  return D.10215;
  <D.10211>:
  D.10213 = idx / 256;
  D.10214 = _wapi_private_handles[D.10213];
  D.10216 = idx & 255;
  D.10217 = D.10216 * 136;
  D.10218 = D.10214 + D.10217;
  D.10215 = D.10218->type;
  return D.10215;
}


mutex_signal (void * handle)
{
  ReleaseMutex (handle);
}


_wapi_mutex_details (void * handle_info)
{
  unsigned int D.10220;
  long unsigned int D.10221;
  int D.10222;
  struct _WapiHandle_mutex * mut;

  mut = handle_info;
  D.10220 = mut->recursion;
  D.10221 = mut->tid;
  D.10222 = mut->pid;
  monoeg_g_print ("own: %5d:%5ld, count: %5u", D.10222, D.10221, D.10220);
}


namedmutex_prewait (void * handle)
{
  struct _WapiHandle_namedmutex * namedmutex_handle.5;
  unsigned int D.10226;
  int D.10230;
  int D.10231;
  unsigned int D.10235;
  _Bool D.10238;
  long int D.10239;
  long int D.10240;
  struct _WapiHandle_namedmutex * namedmutex_handle;
  gboolean ok;
  static const char __func__[19] = "namedmutex_prewait";

  try
    {
      ok = _wapi_lookup_handle (handle, 11, &namedmutex_handle);
      if (ok == 0) goto <D.10223>; else goto <D.10224>;
      <D.10223>:
      monoeg_g_log (0B, 16, "%s: error looking up named mutex handle %p", &__func__, handle);
      return;
      <D.10224>:
      namedmutex_handle.5 = namedmutex_handle;
      D.10226 = namedmutex_handle.5->recursion;
      if (D.10226 == 0) goto <D.10227>; else goto <D.10228>;
      <D.10227>:
      goto <D.10229>;
      <D.10228>:
      namedmutex_handle.5 = namedmutex_handle;
      D.10230 = namedmutex_handle.5->pid;
      D.10231 = _wapi_getpid ();
      if (D.10230 == D.10231) goto <D.10232>; else goto <D.10233>;
      <D.10232>:
      goto <D.10234>;
      <D.10233>:
      {
        int thr_ret;
        void * proc_handle;

        namedmutex_handle.5 = namedmutex_handle;
        D.10230 = namedmutex_handle.5->pid;
        D.10235 = (unsigned int) D.10230;
        proc_handle = OpenProcess (0, 0, D.10235);
        if (proc_handle == 0B) goto <D.10236>; else goto <D.10237>;
        <D.10236>:
        thr_ret = _wapi_handle_lock_shared_handles ();
        D.10238 = thr_ret != 0;
        D.10239 = (long int) D.10238;
        D.10240 = __builtin_expect (D.10239, 0);
        if (D.10240 != 0) goto <D.10241>; else goto <D.10242>;
        <D.10241>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "mutexes.c", 274, "thr_ret == 0");
        <D.10242>:
        namedmutex_handle.5 = namedmutex_handle;
        namedmutex_handle.5->pid = 0;
        namedmutex_handle.5 = namedmutex_handle;
        namedmutex_handle.5->tid = 0;
        namedmutex_handle.5 = namedmutex_handle;
        namedmutex_handle.5->recursion = 0;
        _wapi_shared_handle_set_signal_state (handle, 1);
        _wapi_handle_unlock_shared_handles ();
        goto <D.10243>;
        <D.10237>:
        <D.10243>:
        if (proc_handle != 0B) goto <D.10244>; else goto <D.10245>;
        <D.10244>:
        CloseProcess (proc_handle);
        <D.10245>:
      }
      <D.10234>:
      <D.10229>:
    }
  finally
    {
      namedmutex_handle = {CLOBBER};
    }
}


_wapi_handle_lock_shared_handles ()
{
  int D.10249;

  D.10249 = _wapi_shm_sem_lock (3);
  return D.10249;
}


_wapi_shared_handle_set_signal_state (void * handle, gboolean state)
{
  int iftmp.6;
  <unnamed type> D.10256;
  <unnamed type> D.10258;
  <unnamed type> D.10260;
  <unnamed type> D.10262;
  _Bool D.10264;
  long int D.10265;
  long int D.10266;
  unsigned int D.10269;
  struct _WapiHandleUnshared * D.10270;
  unsigned int D.10271;
  unsigned int D.10272;
  struct _WapiHandleSharedLayout * _wapi_shared_layout.7;
  unsigned int D.10274;
  guint32 idx;
  struct _WapiHandleUnshared * handle_data;
  struct _WapiHandle_shared_ref * ref;
  struct _WapiHandleShared * shared_data;

  idx = (guint32) handle;
  if (idx > 4194303) goto <D.10251>; else goto <D.10252>;
  <D.10251>:
  return;
  <D.10252>:
  D.10256 = _wapi_handle_type (handle);
  if (D.10256 != 9) goto <D.10257>; else goto <D.10254>;
  <D.10257>:
  D.10258 = _wapi_handle_type (handle);
  if (D.10258 != 11) goto <D.10259>; else goto <D.10254>;
  <D.10259>:
  D.10260 = _wapi_handle_type (handle);
  if (D.10260 != 12) goto <D.10261>; else goto <D.10254>;
  <D.10261>:
  D.10262 = _wapi_handle_type (handle);
  if (D.10262 != 13) goto <D.10263>; else goto <D.10254>;
  <D.10263>:
  iftmp.6 = 1;
  goto <D.10255>;
  <D.10254>:
  iftmp.6 = 0;
  <D.10255>:
  D.10264 = iftmp.6 != 0;
  D.10265 = (long int) D.10264;
  D.10266 = __builtin_expect (D.10265, 0);
  if (D.10266 != 0) goto <D.10267>; else goto <D.10268>;
  <D.10267>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "../../mono/io-layer/handles-private.h", 201, "_WAPI_SHARED_HANDLE(_wapi_handle_type (handle))");
  <D.10268>:
  D.10269 = idx / 256;
  D.10270 = _wapi_private_handles[D.10269];
  D.10271 = idx & 255;
  D.10272 = D.10271 * 136;
  handle_data = D.10270 + D.10272;
  ref = &handle_data->u.shared;
  _wapi_shared_layout.7 = _wapi_shared_layout;
  D.10274 = ref->offset;
  shared_data = &_wapi_shared_layout.7->handles[D.10274];
  shared_data->signalled = state;
}


_wapi_handle_unlock_shared_handles ()
{
  int D.10276;

  D.10276 = _wapi_shm_sem_unlock (3);
  return D.10276;
}


namedmutex_is_owned (void * handle)
{
  gboolean D.10280;
  struct _WapiHandle_namedmutex * namedmutex_handle.8;
  unsigned int D.10283;
  int D.10285;
  int D.10286;
  long unsigned int D.10288;
  long unsigned int D.10289;
  int D.10290;
  struct _WapiHandle_namedmutex * namedmutex_handle;
  gboolean ok;
  static const char __func__[20] = "namedmutex_is_owned";

  try
    {
      ok = _wapi_lookup_handle (handle, 11, &namedmutex_handle);
      if (ok == 0) goto <D.10278>; else goto <D.10279>;
      <D.10278>:
      monoeg_g_log (0B, 16, "%s: error looking up mutex handle %p", &__func__, handle);
      D.10280 = 0;
      return D.10280;
      <D.10279>:
      namedmutex_handle.8 = namedmutex_handle;
      D.10283 = namedmutex_handle.8->recursion;
      if (D.10283 != 0) goto <D.10284>; else goto <D.10281>;
      <D.10284>:
      namedmutex_handle.8 = namedmutex_handle;
      D.10285 = namedmutex_handle.8->pid;
      D.10286 = _wapi_getpid ();
      if (D.10285 == D.10286) goto <D.10287>; else goto <D.10281>;
      <D.10287>:
      D.10288 = pthread_self ();
      namedmutex_handle.8 = namedmutex_handle;
      D.10289 = namedmutex_handle.8->tid;
      D.10290 = pthread_equal (D.10289, D.10288);
      if (D.10290 != 0) goto <D.10291>; else goto <D.10281>;
      <D.10291>:
      D.10280 = 1;
      return D.10280;
      <D.10281>:
      D.10280 = 0;
      return D.10280;
    }
  finally
    {
      namedmutex_handle = {CLOBBER};
    }
}


namedmutex_own (void * handle)
{
  gboolean D.10296;
  struct _WapiHandle_namedmutex * namedmutex_handle.9;
  int D.10298;
  long unsigned int D.10299;
  unsigned int D.10300;
  unsigned int D.10301;
  struct _WapiHandle_namedmutex * namedmutex_handle;
  gboolean ok;
  static const char __func__[15] = "namedmutex_own";

  try
    {
      ok = _wapi_lookup_handle (handle, 11, &namedmutex_handle);
      if (ok == 0) goto <D.10294>; else goto <D.10295>;
      <D.10294>:
      monoeg_g_log (0B, 16, "%s: error looking up named mutex handle %p", &__func__, handle);
      D.10296 = 0;
      return D.10296;
      <D.10295>:
      _wapi_thread_own_mutex (handle);
      namedmutex_handle.9 = namedmutex_handle;
      D.10298 = _wapi_getpid ();
      namedmutex_handle.9->pid = D.10298;
      namedmutex_handle.9 = namedmutex_handle;
      D.10299 = pthread_self ();
      namedmutex_handle.9->tid = D.10299;
      namedmutex_handle.9 = namedmutex_handle;
      D.10300 = namedmutex_handle.9->recursion;
      D.10301 = D.10300 + 1;
      namedmutex_handle.9->recursion = D.10301;
      _wapi_shared_handle_set_signal_state (handle, 0);
      D.10296 = 1;
      return D.10296;
    }
  finally
    {
      namedmutex_handle = {CLOBBER};
    }
}


namedmutex_signal (void * handle)
{
  ReleaseMutex (handle);
}


_wapi_mutex_abandon (void * data, pid_t pid, pthread_t tid)
{
  WapiHandleType type;

  type = _wapi_handle_type (data);
  if (type == 5) goto <D.10304>; else goto <D.10305>;
  <D.10304>:
  mutex_abandon (data, pid, tid);
  goto <D.10306>;
  <D.10305>:
  if (type == 11) goto <D.10307>; else goto <D.10308>;
  <D.10307>:
  namedmutex_abandon (data, pid, tid);
  goto <D.10309>;
  <D.10308>:
  monoeg_assertion_message ("* Assertion: should not be reached at %s:%d\n", "mutexes.c", 369);
  <D.10309>:
  <D.10306>:
}


mutex_abandon (void * handle, pid_t pid, pthread_t tid)
{
  long int D.10312;
  _Bool D.10315;
  long int D.10316;
  long int D.10317;
  struct _WapiHandle_mutex * mutex_handle.10;
  int D.10321;
  long unsigned int D.10324;
  int D.10325;
  struct _WapiHandle_mutex * mutex_handle;
  gboolean ok;
  int thr_ret;
  static const char __func__[14] = "mutex_abandon";

  try
    {
      ok = _wapi_lookup_handle (handle, 5, &mutex_handle);
      if (ok == 0) goto <D.10310>; else goto <D.10311>;
      <D.10310>:
      monoeg_g_log (0B, 16, "%s: error looking up mutex handle %p", &__func__, handle);
      return;
      <D.10311>:
      {
        struct __pthread_unwind_buf_t __cancel_buf;
        void (*<Tbf>) (void *) __cancel_routine;
        void * __cancel_arg;
        int __not_first_call;

        try
          {
            __cancel_routine = _wapi_handle_unlock_handle;
            __cancel_arg = handle;
            __not_first_call = __sigsetjmp (&__cancel_buf.__cancel_jmp_buf, 0);
            D.10312 = __builtin_expect (__not_first_call, 0);
            if (D.10312 != 0) goto <D.10313>; else goto <D.10314>;
            <D.10313>:
            __cancel_routine (__cancel_arg);
            __pthread_unwind_next (&__cancel_buf);
            <D.10314>:
            __pthread_register_cancel (&__cancel_buf);
            thr_ret = _wapi_handle_lock_handle (handle);
            D.10315 = thr_ret != 0;
            D.10316 = (long int) D.10315;
            D.10317 = __builtin_expect (D.10316, 0);
            if (D.10317 != 0) goto <D.10318>; else goto <D.10319>;
            <D.10318>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "mutexes.c", 307, "thr_ret == 0");
            <D.10319>:
            mutex_handle.10 = mutex_handle;
            D.10321 = mutex_handle.10->pid;
            if (D.10321 == pid) goto <D.10322>; else goto <D.10323>;
            <D.10322>:
            mutex_handle.10 = mutex_handle;
            D.10324 = mutex_handle.10->tid;
            D.10325 = pthread_equal (D.10324, tid);
            if (D.10325 != 0) goto <D.10326>; else goto <D.10327>;
            <D.10326>:
            mutex_handle.10 = mutex_handle;
            mutex_handle.10->recursion = 0;
            mutex_handle.10 = mutex_handle;
            mutex_handle.10->pid = 0;
            mutex_handle.10 = mutex_handle;
            mutex_handle.10->tid = 0;
            _wapi_handle_set_signal_state (handle, 1, 0);
            <D.10327>:
            <D.10323>:
            thr_ret = _wapi_handle_unlock_handle (handle);
            D.10315 = thr_ret != 0;
            D.10316 = (long int) D.10315;
            D.10317 = __builtin_expect (D.10316, 0);
            if (D.10317 != 0) goto <D.10328>; else goto <D.10329>;
            <D.10328>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "mutexes.c", 321, "thr_ret == 0");
            <D.10329>:
            __pthread_unregister_cancel (&__cancel_buf);
            if (0 != 0) goto <D.10330>; else goto <D.10331>;
            <D.10330>:
            __cancel_routine (__cancel_arg);
            <D.10331>:
          }
        finally
          {
            __cancel_buf = {CLOBBER};
          }
      }
    }
  finally
    {
      mutex_handle = {CLOBBER};
    }
}


_wapi_handle_lock_handle (void * handle)
{
  int D.10340;
  <unnamed type> D.10343;
  <unnamed type> D.10345;
  <unnamed type> D.10347;
  <unnamed type> D.10349;
  unsigned int D.10350;
  struct _WapiHandleUnshared * D.10351;
  unsigned int D.10352;
  unsigned int D.10353;
  struct _WapiHandleUnshared * D.10354;
  union mono_mutex_t * D.10355;
  guint32 idx;

  idx = (guint32) handle;
  if (idx > 4194303) goto <D.10338>; else goto <D.10339>;
  <D.10338>:
  D.10340 = 0;
  return D.10340;
  <D.10339>:
  _wapi_handle_ref (handle);
  D.10343 = _wapi_handle_type (handle);
  if (D.10343 == 9) goto <D.10341>; else goto <D.10344>;
  <D.10344>:
  D.10345 = _wapi_handle_type (handle);
  if (D.10345 == 11) goto <D.10341>; else goto <D.10346>;
  <D.10346>:
  D.10347 = _wapi_handle_type (handle);
  if (D.10347 == 12) goto <D.10341>; else goto <D.10348>;
  <D.10348>:
  D.10349 = _wapi_handle_type (handle);
  if (D.10349 == 13) goto <D.10341>; else goto <D.10342>;
  <D.10341>:
  D.10340 = 0;
  return D.10340;
  <D.10342>:
  D.10350 = idx / 256;
  D.10351 = _wapi_private_handles[D.10350];
  D.10352 = idx & 255;
  D.10353 = D.10352 * 136;
  D.10354 = D.10351 + D.10353;
  D.10355 = &D.10354->signal_mutex;
  D.10340 = pthread_mutex_lock (D.10355);
  return D.10340;
}


_wapi_handle_unlock_handle (void * handle)
{
  int D.10359;
  <unnamed type> D.10362;
  <unnamed type> D.10364;
  <unnamed type> D.10366;
  <unnamed type> D.10368;
  unsigned int D.10369;
  struct _WapiHandleUnshared * D.10370;
  unsigned int D.10371;
  unsigned int D.10372;
  struct _WapiHandleUnshared * D.10373;
  union mono_mutex_t * D.10374;
  guint32 idx;
  int ret;

  idx = (guint32) handle;
  if (idx > 4194303) goto <D.10357>; else goto <D.10358>;
  <D.10357>:
  D.10359 = 0;
  return D.10359;
  <D.10358>:
  D.10362 = _wapi_handle_type (handle);
  if (D.10362 == 9) goto <D.10360>; else goto <D.10363>;
  <D.10363>:
  D.10364 = _wapi_handle_type (handle);
  if (D.10364 == 11) goto <D.10360>; else goto <D.10365>;
  <D.10365>:
  D.10366 = _wapi_handle_type (handle);
  if (D.10366 == 12) goto <D.10360>; else goto <D.10367>;
  <D.10367>:
  D.10368 = _wapi_handle_type (handle);
  if (D.10368 == 13) goto <D.10360>; else goto <D.10361>;
  <D.10360>:
  _wapi_handle_unref (handle);
  D.10359 = 0;
  return D.10359;
  <D.10361>:
  D.10369 = idx / 256;
  D.10370 = _wapi_private_handles[D.10369];
  D.10371 = idx & 255;
  D.10372 = D.10371 * 136;
  D.10373 = D.10370 + D.10372;
  D.10374 = &D.10373->signal_mutex;
  ret = pthread_mutex_unlock (D.10374);
  _wapi_handle_unref (handle);
  D.10359 = ret;
  return D.10359;
}


namedmutex_abandon (void * handle, pid_t pid, pthread_t tid)
{
  _Bool D.10378;
  long int D.10379;
  long int D.10380;
  struct _WapiHandle_namedmutex * mutex_handle.11;
  int D.10384;
  long unsigned int D.10387;
  int D.10388;
  struct _WapiHandle_namedmutex * mutex_handle;
  gboolean ok;
  int thr_ret;
  static const char __func__[19] = "namedmutex_abandon";

  try
    {
      ok = _wapi_lookup_handle (handle, 11, &mutex_handle);
      if (ok == 0) goto <D.10376>; else goto <D.10377>;
      <D.10376>:
      monoeg_g_log (0B, 16, "%s: error looking up named mutex handle %p", &__func__, handle);
      return;
      <D.10377>:
      thr_ret = _wapi_handle_lock_shared_handles ();
      D.10378 = thr_ret != 0;
      D.10379 = (long int) D.10378;
      D.10380 = __builtin_expect (D.10379, 0);
      if (D.10380 != 0) goto <D.10381>; else goto <D.10382>;
      <D.10381>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "mutexes.c", 340, "thr_ret == 0");
      <D.10382>:
      mutex_handle.11 = mutex_handle;
      D.10384 = mutex_handle.11->pid;
      if (D.10384 == pid) goto <D.10385>; else goto <D.10386>;
      <D.10385>:
      mutex_handle.11 = mutex_handle;
      D.10387 = mutex_handle.11->tid;
      D.10388 = pthread_equal (D.10387, tid);
      if (D.10388 != 0) goto <D.10389>; else goto <D.10390>;
      <D.10389>:
      mutex_handle.11 = mutex_handle;
      mutex_handle.11->recursion = 0;
      mutex_handle.11 = mutex_handle;
      mutex_handle.11->pid = 0;
      mutex_handle.11 = mutex_handle;
      mutex_handle.11->tid = 0;
      _wapi_shared_handle_set_signal_state (handle, 1);
      <D.10390>:
      <D.10386>:
      _wapi_handle_unlock_shared_handles ();
    }
  finally
    {
      mutex_handle = {CLOBBER};
    }
}


CreateMutex (struct WapiSecurityAttributes * security, gboolean owned, const gunichar2 * name)
{
  void * D.10396;

  mono_once (&mutex_ops_once, mutex_ops_init);
  if (name == 0B) goto <D.10394>; else goto <D.10395>;
  <D.10394>:
  D.10396 = mutex_create (security, owned);
  return D.10396;
  <D.10395>:
  D.10396 = namedmutex_create (security, owned, name);
  return D.10396;
}


mutex_ops_init ()
{
  _wapi_handle_register_capabilities (5, 7);
  _wapi_handle_register_capabilities (11, 7);
}


mutex_create (struct WapiSecurityAttributes * security, gboolean owned)
{
  void * D.10400;
  long int D.10401;
  _Bool D.10404;
  long int D.10405;
  long int D.10406;
  struct _WapiHandle_mutex mutex_handle;
  void * handle;
  int thr_ret;
  static const char __func__[13] = "mutex_create";

  try
    {
      mutex_handle = {};
      SetLastError (0);
      handle = _wapi_handle_new (5, &mutex_handle);
      if (handle == 4294967295B) goto <D.10398>; else goto <D.10399>;
      <D.10398>:
      monoeg_g_log (0B, 16, "%s: error creating mutex handle", &__func__);
      SetLastError (31);
      D.10400 = 0B;
      return D.10400;
      <D.10399>:
      {
        struct __pthread_unwind_buf_t __cancel_buf;
        void (*<Tbf>) (void *) __cancel_routine;
        void * __cancel_arg;
        int __not_first_call;

        try
          {
            __cancel_routine = _wapi_handle_unlock_handle;
            __cancel_arg = handle;
            __not_first_call = __sigsetjmp (&__cancel_buf.__cancel_jmp_buf, 0);
            D.10401 = __builtin_expect (__not_first_call, 0);
            if (D.10401 != 0) goto <D.10402>; else goto <D.10403>;
            <D.10402>:
            __cancel_routine (__cancel_arg);
            __pthread_unwind_next (&__cancel_buf);
            <D.10403>:
            __pthread_register_cancel (&__cancel_buf);
            thr_ret = _wapi_handle_lock_handle (handle);
            D.10404 = thr_ret != 0;
            D.10405 = (long int) D.10404;
            D.10406 = __builtin_expect (D.10405, 0);
            if (D.10406 != 0) goto <D.10407>; else goto <D.10408>;
            <D.10407>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "mutexes.c", 398, "thr_ret == 0");
            <D.10408>:
            if (owned == 1) goto <D.10409>; else goto <D.10410>;
            <D.10409>:
            mutex_own (handle);
            goto <D.10411>;
            <D.10410>:
            _wapi_handle_set_signal_state (handle, 1, 0);
            <D.10411>:
            thr_ret = _wapi_handle_unlock_handle (handle);
            D.10404 = thr_ret != 0;
            D.10405 = (long int) D.10404;
            D.10406 = __builtin_expect (D.10405, 0);
            if (D.10406 != 0) goto <D.10412>; else goto <D.10413>;
            <D.10412>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "mutexes.c", 409, "thr_ret == 0");
            <D.10413>:
            __pthread_unregister_cancel (&__cancel_buf);
            if (0 != 0) goto <D.10414>; else goto <D.10415>;
            <D.10414>:
            __cancel_routine (__cancel_arg);
            <D.10415>:
          }
        finally
          {
            __cancel_buf = {CLOBBER};
          }
      }
      D.10400 = handle;
      return D.10400;
    }
  finally
    {
      mutex_handle = {CLOBBER};
    }
}


namedmutex_create (struct WapiSecurityAttributes * security, gboolean owned, const gunichar2 * name)
{
  _Bool D.10421;
  long int D.10422;
  long int D.10423;
  unsigned int D.10432;
  unsigned int offset.12;
  void * D.10447;
  struct _WapiHandle_namedmutex namedmutex_handle;
  void * handle;
  gchar * utf8_name;
  int thr_ret;
  void * ret;
  guint32 namelen;
  gint32 offset;
  void cleanup = <<< error >>>;
  static const char __func__[18] = "namedmutex_create";

  try
    {
      namedmutex_handle = {};
      ret = 0B;
      thr_ret = _wapi_namespace_lock ();
      D.10421 = thr_ret != 0;
      D.10422 = (long int) D.10421;
      D.10423 = __builtin_expect (D.10422, 0);
      if (D.10423 != 0) goto <D.10424>; else goto <D.10425>;
      <D.10424>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "mutexes.c", 430, "thr_ret == 0");
      <D.10425>:
      SetLastError (0);
      utf8_name = monoeg_g_utf16_to_utf8 (name, -1, 0B, 0B, 0B);
      offset = _wapi_search_handle_namespace (11, utf8_name);
      if (offset == -1) goto <D.10426>; else goto <D.10427>;
      <D.10426>:
      SetLastError (6);
      goto cleanup;
      <D.10427>:
      if (offset != 0) goto <D.10428>; else goto <D.10429>;
      <D.10428>:
      SetLastError (183);
      <D.10429>:
      if (offset == 0) goto <D.10430>; else goto <D.10431>;
      <D.10430>:
      D.10432 = strlen (utf8_name);
      if (D.10432 <= 259) goto <D.10433>; else goto <D.10434>;
      <D.10433>:
      namelen = strlen (utf8_name);
      goto <D.10435>;
      <D.10434>:
      namelen = 260;
      <D.10435>:
      memcpy (&namedmutex_handle.sharedns.name, utf8_name, namelen);
      handle = _wapi_handle_new (11, &namedmutex_handle);
      goto <D.10436>;
      <D.10431>:
      offset.12 = (unsigned int) offset;
      handle = _wapi_handle_new_from_offset (11, offset.12, 1);
      <D.10436>:
      if (handle == 4294967295B) goto <D.10438>; else goto <D.10439>;
      <D.10438>:
      monoeg_g_log (0B, 16, "%s: error creating mutex handle", &__func__);
      SetLastError (31);
      goto cleanup;
      <D.10439>:
      ret = handle;
      if (offset == 0) goto <D.10440>; else goto <D.10441>;
      <D.10440>:
      thr_ret = _wapi_handle_lock_shared_handles ();
      D.10421 = thr_ret != 0;
      D.10422 = (long int) D.10421;
      D.10423 = __builtin_expect (D.10422, 0);
      if (D.10423 != 0) goto <D.10442>; else goto <D.10443>;
      <D.10442>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "mutexes.c", 493, "thr_ret == 0");
      <D.10443>:
      if (owned == 1) goto <D.10444>; else goto <D.10445>;
      <D.10444>:
      namedmutex_own (handle);
      goto <D.10446>;
      <D.10445>:
      _wapi_shared_handle_set_signal_state (handle, 1);
      <D.10446>:
      _wapi_handle_unlock_shared_handles ();
      <D.10441>:
      cleanup:
      monoeg_g_free (utf8_name);
      _wapi_namespace_unlock (0B);
      D.10447 = ret;
      return D.10447;
    }
  finally
    {
      namedmutex_handle = {CLOBBER};
    }
}


_wapi_namespace_lock ()
{
  int D.10450;

  D.10450 = _wapi_shm_sem_lock (0);
  return D.10450;
}


memcpy (void * restrict __dest, const void * restrict __src, size_t __len)
{
  void * D.10452;
  unsigned int D.10453;

  D.10453 = __builtin_object_size (__dest, 0);
  D.10452 = __builtin___memcpy_chk (__dest, __src, __len, D.10453);
  return D.10452;
}


_wapi_namespace_unlock (void * data)
{
  int D.10455;

  D.10455 = _wapi_shm_sem_unlock (0);
  return D.10455;
}


ReleaseMutex (void * handle)
{
  gboolean D.10459;
  gboolean (*<T1550>) (void *) D.10460;
  WapiHandleType type;

  if (handle == 0B) goto <D.10457>; else goto <D.10458>;
  <D.10457>:
  SetLastError (6);
  D.10459 = 0;
  return D.10459;
  <D.10458>:
  type = _wapi_handle_type (handle);
  D.10460 = mutex_ops[type].release;
  if (D.10460 == 0B) goto <D.10461>; else goto <D.10462>;
  <D.10461>:
  SetLastError (6);
  D.10459 = 0;
  return D.10459;
  <D.10462>:
  D.10460 = mutex_ops[type].release;
  D.10459 = D.10460 (handle);
  return D.10459;
}


namedmutex_release (void * handle)
{
  gboolean D.10466;
  _Bool D.10467;
  long int D.10468;
  long int D.10469;
  struct _WapiHandle_namedmutex * mutex_handle.13;
  long unsigned int D.10473;
  int D.10474;
  int D.10476;
  unsigned int D.10478;
  unsigned int D.10479;
  struct _WapiHandle_namedmutex * mutex_handle;
  gboolean ok;
  pthread_t tid;
  pid_t pid;
  int thr_ret;
  gboolean ret;
  static const char __func__[19] = "namedmutex_release";
  void cleanup = <<< error >>>;

  try
    {
      tid = pthread_self ();
      pid = _wapi_getpid ();
      ret = 0;
      ok = _wapi_lookup_handle (handle, 11, &mutex_handle);
      if (ok == 0) goto <D.10464>; else goto <D.10465>;
      <D.10464>:
      monoeg_g_log (0B, 16, "%s: error looking up named mutex handle %p", &__func__, handle);
      D.10466 = 0;
      return D.10466;
      <D.10465>:
      thr_ret = _wapi_handle_lock_shared_handles ();
      D.10467 = thr_ret != 0;
      D.10468 = (long int) D.10467;
      D.10469 = __builtin_expect (D.10468, 0);
      if (D.10469 != 0) goto <D.10470>; else goto <D.10471>;
      <D.10470>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "mutexes.c", 616, "thr_ret == 0");
      <D.10471>:
      mutex_handle.13 = mutex_handle;
      D.10473 = mutex_handle.13->tid;
      D.10474 = pthread_equal (D.10473, tid);
      if (D.10474 == 0) goto cleanup; else goto <D.10475>;
      <D.10475>:
      mutex_handle.13 = mutex_handle;
      D.10476 = mutex_handle.13->pid;
      if (D.10476 != pid) goto cleanup; else goto <D.10477>;
      <D.10477>:
      ret = 1;
      mutex_handle.13 = mutex_handle;
      D.10478 = mutex_handle.13->recursion;
      D.10479 = D.10478 + 4294967295;
      mutex_handle.13->recursion = D.10479;
      mutex_handle.13 = mutex_handle;
      D.10478 = mutex_handle.13->recursion;
      if (D.10478 == 0) goto <D.10480>; else goto <D.10481>;
      <D.10480>:
      _wapi_thread_disown_mutex (handle);
      mutex_handle.13 = mutex_handle;
      mutex_handle.13->pid = 0;
      mutex_handle.13 = mutex_handle;
      mutex_handle.13->tid = 0;
      _wapi_shared_handle_set_signal_state (handle, 1);
      <D.10481>:
      cleanup:
      _wapi_handle_unlock_shared_handles ();
      D.10466 = ret;
      return D.10466;
    }
  finally
    {
      mutex_handle = {CLOBBER};
    }
}


mutex_release (void * handle)
{
  gboolean D.10486;
  long int D.10487;
  _Bool D.10490;
  long int D.10491;
  long int D.10492;
  struct _WapiHandle_mutex * mutex_handle.14;
  long unsigned int D.10496;
  int D.10497;
  int D.10499;
  unsigned int D.10501;
  unsigned int D.10502;
  struct _WapiHandle_mutex * mutex_handle;
  gboolean ok;
  pthread_t tid;
  pid_t pid;
  int thr_ret;
  gboolean ret;
  static const char __func__[14] = "mutex_release";
  void cleanup = <<< error >>>;

  try
    {
      tid = pthread_self ();
      pid = _wapi_getpid ();
      ret = 0;
      ok = _wapi_lookup_handle (handle, 5, &mutex_handle);
      if (ok == 0) goto <D.10484>; else goto <D.10485>;
      <D.10484>:
      monoeg_g_log (0B, 16, "%s: error looking up mutex handle %p", &__func__, handle);
      D.10486 = 0;
      return D.10486;
      <D.10485>:
      {
        struct __pthread_unwind_buf_t __cancel_buf;
        void (*<Tbf>) (void *) __cancel_routine;
        void * __cancel_arg;
        int __not_first_call;

        try
          {
            __cancel_routine = _wapi_handle_unlock_handle;
            __cancel_arg = handle;
            __not_first_call = __sigsetjmp (&__cancel_buf.__cancel_jmp_buf, 0);
            D.10487 = __builtin_expect (__not_first_call, 0);
            if (D.10487 != 0) goto <D.10488>; else goto <D.10489>;
            <D.10488>:
            __cancel_routine (__cancel_arg);
            __pthread_unwind_next (&__cancel_buf);
            <D.10489>:
            __pthread_register_cancel (&__cancel_buf);
            thr_ret = _wapi_handle_lock_handle (handle);
            D.10490 = thr_ret != 0;
            D.10491 = (long int) D.10490;
            D.10492 = __builtin_expect (D.10491, 0);
            if (D.10492 != 0) goto <D.10493>; else goto <D.10494>;
            <D.10493>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "mutexes.c", 565, "thr_ret == 0");
            <D.10494>:
            mutex_handle.14 = mutex_handle;
            D.10496 = mutex_handle.14->tid;
            D.10497 = pthread_equal (D.10496, tid);
            if (D.10497 == 0) goto cleanup; else goto <D.10498>;
            <D.10498>:
            mutex_handle.14 = mutex_handle;
            D.10499 = mutex_handle.14->pid;
            if (D.10499 != pid) goto cleanup; else goto <D.10500>;
            <D.10500>:
            ret = 1;
            mutex_handle.14 = mutex_handle;
            D.10501 = mutex_handle.14->recursion;
            D.10502 = D.10501 + 4294967295;
            mutex_handle.14->recursion = D.10502;
            mutex_handle.14 = mutex_handle;
            D.10501 = mutex_handle.14->recursion;
            if (D.10501 == 0) goto <D.10503>; else goto <D.10504>;
            <D.10503>:
            _wapi_thread_disown_mutex (handle);
            mutex_handle.14 = mutex_handle;
            mutex_handle.14->pid = 0;
            mutex_handle.14 = mutex_handle;
            mutex_handle.14->tid = 0;
            _wapi_handle_set_signal_state (handle, 1, 0);
            <D.10504>:
            cleanup:
            thr_ret = _wapi_handle_unlock_handle (handle);
            D.10490 = thr_ret != 0;
            D.10491 = (long int) D.10490;
            D.10492 = __builtin_expect (D.10491, 0);
            if (D.10492 != 0) goto <D.10505>; else goto <D.10506>;
            <D.10505>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "mutexes.c", 592, "thr_ret == 0");
            <D.10506>:
            __pthread_unregister_cancel (&__cancel_buf);
            if (0 != 0) goto <D.10507>; else goto <D.10508>;
            <D.10507>:
            __cancel_routine (__cancel_arg);
            <D.10508>:
          }
        finally
          {
            __cancel_buf = {CLOBBER};
          }
      }
      D.10486 = ret;
      return D.10486;
    }
  finally
    {
      mutex_handle = {CLOBBER};
    }
}


OpenMutex (guint32 access, gboolean inherit, const gunichar2 * name)
{
  _Bool D.10515;
  long int D.10516;
  long int D.10517;
  unsigned int offset.15;
  void * D.10527;
  void * handle;
  gchar * utf8_name;
  int thr_ret;
  void * ret;
  gint32 offset;
  void cleanup = <<< error >>>;
  static const char __func__[10] = "OpenMutex";

  ret = 0B;
  mono_once (&mutex_ops_once, mutex_ops_init);
  thr_ret = _wapi_namespace_lock ();
  D.10515 = thr_ret != 0;
  D.10516 = (long int) D.10515;
  D.10517 = __builtin_expect (D.10516, 0);
  if (D.10517 != 0) goto <D.10518>; else goto <D.10519>;
  <D.10518>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "mutexes.c", 689, "thr_ret == 0");
  <D.10519>:
  utf8_name = monoeg_g_utf16_to_utf8 (name, -1, 0B, 0B, 0B);
  offset = _wapi_search_handle_namespace (11, utf8_name);
  if (offset == -1) goto <D.10520>; else goto <D.10521>;
  <D.10520>:
  SetLastError (6);
  goto cleanup;
  <D.10521>:
  if (offset == 0) goto <D.10522>; else goto <D.10523>;
  <D.10522>:
  SetLastError (2);
  goto cleanup;
  <D.10523>:
  offset.15 = (unsigned int) offset;
  handle = _wapi_handle_new_from_offset (11, offset.15, 1);
  if (handle == 4294967295B) goto <D.10525>; else goto <D.10526>;
  <D.10525>:
  monoeg_g_log (0B, 16, "%s: error opening named mutex handle", &__func__);
  SetLastError (31);
  goto cleanup;
  <D.10526>:
  ret = handle;
  cleanup:
  monoeg_g_free (utf8_name);
  _wapi_namespace_unlock (0B);
  D.10527 = ret;
  return D.10527;
}


