_wapi_thread_cleanup ()
{
  unsigned int thread_hash_key.0;
  _Bool D.13321;
  long int D.13322;
  long int D.13323;
  unsigned int thread_attached_key.1;
  int ret;

  thread_hash_key.0 = thread_hash_key;
  ret = pthread_key_delete (thread_hash_key.0);
  D.13321 = ret != 0;
  D.13322 = (long int) D.13321;
  D.13323 = __builtin_expect (D.13322, 0);
  if (D.13323 != 0) goto <D.13324>; else goto <D.13325>;
  <D.13324>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "wthreads.c", 86, "ret == 0");
  <D.13325>:
  thread_attached_key.1 = thread_attached_key;
  ret = pthread_key_delete (thread_attached_key.1);
  D.13321 = ret != 0;
  D.13322 = (long int) D.13321;
  D.13323 = __builtin_expect (D.13322, 0);
  if (D.13323 != 0) goto <D.13327>; else goto <D.13328>;
  <D.13327>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "wthreads.c", 89, "ret == 0");
  <D.13328>:
}


_wapi_thread_set_termination_details (void * handle, guint32 exitstatus)
{
  int D.13331;
  <unnamed type> D.13333;
  long int D.13336;
  long int D.13337;
  _Bool D.13340;
  long int D.13341;
  long int D.13342;
  struct _WapiHandle_thread * thread_handle.2;
  union MonoSemType * D.13346;
  struct GPtrArray * D.13347;
  struct _WapiHandle_thread * thread_handle;
  gboolean ok;
  int thr_ret;
  static const char __func__[37] = "_wapi_thread_set_termination_details";

  try
    {
      D.13331 = _wapi_handle_issignalled (handle);
      if (D.13331 != 0) goto <D.13329>; else goto <D.13332>;
      <D.13332>:
      D.13333 = _wapi_handle_type (handle);
      if (D.13333 == 0) goto <D.13329>; else goto <D.13330>;
      <D.13329>:
      return;
      <D.13330>:
      _wapi_thread_abandon_mutexes (handle);
      ok = _wapi_lookup_handle (handle, 3, &thread_handle);
      if (ok == 0) goto <D.13334>; else goto <D.13335>;
      <D.13334>:
      monoeg_g_log (0B, 16, "%s: error looking up thread handle %p", &__func__, handle);
      return;
      <D.13335>:
      {
        struct __pthread_unwind_buf_t __cancel_buf;
        void (*<Tc2>) (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.13336 = (long int) __not_first_call;
            D.13337 = __builtin_expect (D.13336, 0);
            if (D.13337 != 0) goto <D.13338>; else goto <D.13339>;
            <D.13338>:
            __cancel_routine (__cancel_arg);
            __pthread_unwind_next (&__cancel_buf);
            <D.13339>:
            __pthread_register_cancel (&__cancel_buf);
            thr_ret = _wapi_handle_lock_handle (handle);
            D.13340 = thr_ret != 0;
            D.13341 = (long int) D.13340;
            D.13342 = __builtin_expect (D.13341, 0);
            if (D.13342 != 0) goto <D.13343>; else goto <D.13344>;
            <D.13343>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "wthreads.c", 164, "thr_ret == 0");
            <D.13344>:
            thread_handle.2 = thread_handle;
            thread_handle.2->exitstatus = exitstatus;
            thread_handle.2 = thread_handle;
            thread_handle.2->state = 1;
            thread_handle.2 = thread_handle;
            D.13346 = &thread_handle.2->suspend_sem;
            sem_destroy (D.13346);
            thread_handle.2 = thread_handle;
            D.13347 = thread_handle.2->owned_mutexes;
            monoeg_g_ptr_array_free (D.13347, 1);
            _wapi_handle_set_signal_state (handle, 1, 1);
            thr_ret = _wapi_handle_unlock_handle (handle);
            D.13340 = thr_ret != 0;
            D.13341 = (long int) D.13340;
            D.13342 = __builtin_expect (D.13341, 0);
            if (D.13342 != 0) goto <D.13348>; else goto <D.13349>;
            <D.13348>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "wthreads.c", 174, "thr_ret == 0");
            <D.13349>:
            __pthread_unregister_cancel (&__cancel_buf);
            if (0 != 0) goto <D.13350>; else goto <D.13351>;
            <D.13350>:
            __cancel_routine (__cancel_arg);
            <D.13351>:
          }
        finally
          {
            __cancel_buf = {CLOBBER};
          }
      }
      _wapi_handle_unref (handle);
    }
  finally
    {
      thread_handle = {CLOBBER};
    }
}


_wapi_handle_issignalled (void * handle)
{
  long int handle.3;
  gboolean D.13363;
  <unnamed type> D.13366;
  <unnamed type> D.13368;
  <unnamed type> D.13370;
  <unnamed type> D.13372;
  struct _WapiHandleSharedLayout * _wapi_shared_layout.4;
  unsigned int D.13374;
  unsigned int D.13375;
  struct _WapiHandleUnshared * D.13376;
  long unsigned int D.13377;
  long unsigned int D.13378;
  long unsigned int D.13379;
  struct _WapiHandleUnshared * D.13380;
  unsigned int D.13381;
  unsigned int D.13382;
  struct _WapiHandleUnshared * D.13383;
  long unsigned int D.13384;
  long unsigned int D.13385;
  long unsigned int D.13386;
  struct _WapiHandleUnshared * D.13387;
  guint32 idx;

  handle.3 = (long int) handle;
  idx = (guint32) handle.3;
  if (idx > 4194303) goto <D.13361>; else goto <D.13362>;
  <D.13361>:
  D.13363 = 0;
  return D.13363;
  <D.13362>:
  D.13366 = _wapi_handle_type (handle);
  if (D.13366 == 9) goto <D.13364>; else goto <D.13367>;
  <D.13367>:
  D.13368 = _wapi_handle_type (handle);
  if (D.13368 == 11) goto <D.13364>; else goto <D.13369>;
  <D.13369>:
  D.13370 = _wapi_handle_type (handle);
  if (D.13370 == 12) goto <D.13364>; else goto <D.13371>;
  <D.13371>:
  D.13372 = _wapi_handle_type (handle);
  if (D.13372 == 13) goto <D.13364>; else goto <D.13365>;
  <D.13364>:
  _wapi_shared_layout.4 = _wapi_shared_layout;
  handle.3 = (long int) handle;
  D.13374 = (unsigned int) handle.3;
  D.13375 = D.13374 / 256;
  D.13376 = _wapi_private_handles[D.13375];
  handle.3 = (long int) handle;
  D.13374 = (unsigned int) handle.3;
  D.13377 = (long unsigned int) D.13374;
  D.13378 = D.13377 & 255;
  D.13379 = D.13378 * 200;
  D.13380 = D.13376 + D.13379;
  D.13381 = D.13380->u.shared.offset;
  D.13363 = _wapi_shared_layout.4->handles[D.13381].signalled;
  return D.13363;
  <D.13365>:
  D.13382 = idx / 256;
  D.13383 = _wapi_private_handles[D.13382];
  D.13384 = (long unsigned int) idx;
  D.13385 = D.13384 & 255;
  D.13386 = D.13385 * 200;
  D.13387 = D.13383 + D.13386;
  D.13363 = D.13387->signalled;
  return D.13363;
}


_wapi_handle_type (void * handle)
{
  long int handle.5;
  unsigned int D.13393;
  struct _WapiHandleUnshared * D.13394;
  WapiHandleType D.13395;
  unsigned int D.13396;
  struct _WapiHandleUnshared * D.13397;
  long unsigned int D.13398;
  long unsigned int D.13399;
  long unsigned int D.13400;
  struct _WapiHandleUnshared * D.13401;
  guint32 idx;

  handle.5 = (long int) handle;
  idx = (guint32) handle.5;
  if (idx > 4194303) goto <D.13390>; else goto <D.13392>;
  <D.13392>:
  D.13393 = idx / 256;
  D.13394 = _wapi_private_handles[D.13393];
  if (D.13394 == 0B) goto <D.13390>; else goto <D.13391>;
  <D.13390>:
  D.13395 = 0;
  return D.13395;
  <D.13391>:
  D.13396 = idx / 256;
  D.13397 = _wapi_private_handles[D.13396];
  D.13398 = (long unsigned int) idx;
  D.13399 = D.13398 & 255;
  D.13400 = D.13399 * 200;
  D.13401 = D.13397 + D.13400;
  D.13395 = D.13401->type;
  return D.13395;
}


_wapi_thread_abandon_mutexes (void * handle)
{
  long unsigned int D.13405;
  struct _WapiHandle_thread * thread_handle.6;
  long unsigned int D.13411;
  int D.13412;
  struct GPtrArray * D.13415;
  void * * D.13416;
  long unsigned int D.13417;
  long unsigned int D.13418;
  void * * D.13419;
  unsigned int i.7;
  unsigned int D.13421;
  struct _WapiHandle_thread * thread_handle;
  gboolean ok;
  int i;
  pid_t pid;
  pthread_t tid;
  static const char __func__[29] = "_wapi_thread_abandon_mutexes";

  try
    {
      pid = _wapi_getpid ();
      tid = pthread_self ();
      if (handle == 0B) goto <D.13403>; else goto <D.13404>;
      <D.13403>:
      D.13405 = pthread_self ();
      handle = _wapi_thread_handle_from_id (D.13405);
      if (handle == 0B) goto <D.13406>; else goto <D.13407>;
      <D.13406>:
      return;
      <D.13407>:
      <D.13404>:
      ok = _wapi_lookup_handle (handle, 3, &thread_handle);
      if (ok == 0) goto <D.13408>; else goto <D.13409>;
      <D.13408>:
      monoeg_g_log (0B, 16, "%s: error looking up thread handle %p", &__func__, handle);
      return;
      <D.13409>:
      thread_handle.6 = thread_handle;
      D.13411 = thread_handle.6->id;
      D.13412 = pthread_equal (D.13411, tid);
      if (D.13412 == 0) goto <D.13413>; else goto <D.13414>;
      <D.13413>:
      return;
      <D.13414>:
      i = 0;
      goto <D.13055>;
      <D.13054>:
      {
        void * mutex;

        thread_handle.6 = thread_handle;
        D.13415 = thread_handle.6->owned_mutexes;
        D.13416 = D.13415->pdata;
        D.13417 = (long unsigned int) i;
        D.13418 = D.13417 * 8;
        D.13419 = D.13416 + D.13418;
        mutex = *D.13419;
        _wapi_mutex_abandon (mutex, pid, tid);
        _wapi_thread_disown_mutex (mutex);
      }
      i = i + 1;
      <D.13055>:
      i.7 = (unsigned int) i;
      thread_handle.6 = thread_handle;
      D.13415 = thread_handle.6->owned_mutexes;
      D.13421 = D.13415->len;
      if (i.7 < D.13421) goto <D.13054>; else goto <D.13056>;
      <D.13056>:
    }
  finally
    {
      thread_handle = {CLOBBER};
    }
}


pthread_equal (pthread_t __thread1, pthread_t __thread2)
{
  int D.13425;
  _Bool D.13426;

  D.13426 = __thread1 == __thread2;
  D.13425 = (int) D.13426;
  return D.13425;
}


_wapi_handle_lock_handle (void * handle)
{
  long int handle.8;
  int D.13431;
  <unnamed type> D.13434;
  <unnamed type> D.13436;
  <unnamed type> D.13438;
  <unnamed type> D.13440;
  unsigned int D.13441;
  struct _WapiHandleUnshared * D.13442;
  long unsigned int D.13443;
  long unsigned int D.13444;
  long unsigned int D.13445;
  struct _WapiHandleUnshared * D.13446;
  union mono_mutex_t * D.13447;
  guint32 idx;

  handle.8 = (long int) handle;
  idx = (guint32) handle.8;
  if (idx > 4194303) goto <D.13429>; else goto <D.13430>;
  <D.13429>:
  D.13431 = 0;
  return D.13431;
  <D.13430>:
  _wapi_handle_ref (handle);
  D.13434 = _wapi_handle_type (handle);
  if (D.13434 == 9) goto <D.13432>; else goto <D.13435>;
  <D.13435>:
  D.13436 = _wapi_handle_type (handle);
  if (D.13436 == 11) goto <D.13432>; else goto <D.13437>;
  <D.13437>:
  D.13438 = _wapi_handle_type (handle);
  if (D.13438 == 12) goto <D.13432>; else goto <D.13439>;
  <D.13439>:
  D.13440 = _wapi_handle_type (handle);
  if (D.13440 == 13) goto <D.13432>; else goto <D.13433>;
  <D.13432>:
  D.13431 = 0;
  return D.13431;
  <D.13433>:
  D.13441 = idx / 256;
  D.13442 = _wapi_private_handles[D.13441];
  D.13443 = (long unsigned int) idx;
  D.13444 = D.13443 & 255;
  D.13445 = D.13444 * 200;
  D.13446 = D.13442 + D.13445;
  D.13447 = &D.13446->signal_mutex;
  D.13431 = pthread_mutex_lock (D.13447);
  return D.13431;
}


_wapi_handle_set_signal_state (void * handle, gboolean state, gboolean broadcast)
{
  long int handle.9;
  int iftmp.10;
  <unnamed type> D.13456;
  <unnamed type> D.13458;
  <unnamed type> D.13460;
  <unnamed type> D.13462;
  _Bool D.13463;
  long int D.13464;
  long int D.13465;
  unsigned int D.13468;
  struct _WapiHandleUnshared * D.13469;
  long unsigned int D.13470;
  long unsigned int D.13471;
  long unsigned int D.13472;
  long int D.13475;
  long int D.13476;
  union mono_mutex_t * _wapi_global_signal_mutex.11;
  _Bool D.13482;
  long int D.13483;
  long int D.13484;
  union pthread_cond_t * D.13489;
  union pthread_cond_t * _wapi_global_signal_cond.12;
  guint32 idx;
  struct _WapiHandleUnshared * handle_data;
  int thr_ret;

  handle.9 = (long int) handle;
  idx = (guint32) handle.9;
  if (idx > 4194303) goto <D.13450>; else goto <D.13451>;
  <D.13450>:
  return;
  <D.13451>:
  D.13456 = _wapi_handle_type (handle);
  if (D.13456 == 9) goto <D.13453>; else goto <D.13457>;
  <D.13457>:
  D.13458 = _wapi_handle_type (handle);
  if (D.13458 == 11) goto <D.13453>; else goto <D.13459>;
  <D.13459>:
  D.13460 = _wapi_handle_type (handle);
  if (D.13460 == 12) goto <D.13453>; else goto <D.13461>;
  <D.13461>:
  D.13462 = _wapi_handle_type (handle);
  if (D.13462 == 13) goto <D.13453>; else goto <D.13454>;
  <D.13453>:
  iftmp.10 = 1;
  goto <D.13455>;
  <D.13454>:
  iftmp.10 = 0;
  <D.13455>:
  D.13463 = iftmp.10 != 0;
  D.13464 = (long int) D.13463;
  D.13465 = __builtin_expect (D.13464, 0);
  if (D.13465 != 0) goto <D.13466>; else goto <D.13467>;
  <D.13466>:
  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.13467>:
  D.13468 = idx / 256;
  D.13469 = _wapi_private_handles[D.13468];
  D.13470 = (long unsigned int) idx;
  D.13471 = D.13470 & 255;
  D.13472 = D.13471 * 200;
  handle_data = D.13469 + D.13472;
  if (state == 1) goto <D.13473>; else goto <D.13474>;
  <D.13473>:
  {
    struct __pthread_unwind_buf_t __cancel_buf;
    void (*<Tc2>) (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.13475 = (long int) __not_first_call;
        D.13476 = __builtin_expect (D.13475, 0);
        if (D.13476 != 0) goto <D.13477>; else goto <D.13478>;
        <D.13477>:
        __cancel_routine (__cancel_arg);
        __pthread_unwind_next (&__cancel_buf);
        <D.13478>:
        __pthread_register_cancel (&__cancel_buf);
        _wapi_global_signal_mutex.11 = _wapi_global_signal_mutex;
        thr_ret = pthread_mutex_lock (_wapi_global_signal_mutex.11);
        if (thr_ret != 0) goto <D.13480>; else goto <D.13481>;
        <D.13480>:
        monoeg_g_log (0B, 16, "Bad call to mono_mutex_lock result %d for global signal mutex", thr_ret);
        <D.13481>:
        D.13482 = thr_ret != 0;
        D.13483 = (long int) D.13482;
        D.13484 = __builtin_expect (D.13483, 0);
        if (D.13484 != 0) goto <D.13485>; else goto <D.13486>;
        <D.13485>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "../../mono/io-layer/handles-private.h", 151, "thr_ret == 0");
        <D.13486>:
        handle_data->signalled = state;
        if (broadcast == 1) goto <D.13487>; else goto <D.13488>;
        <D.13487>:
        D.13489 = &handle_data->signal_cond;
        thr_ret = pthread_cond_broadcast (D.13489);
        if (thr_ret != 0) goto <D.13490>; else goto <D.13491>;
        <D.13490>:
        monoeg_g_log (0B, 16, "Bad call to pthread_cond_broadcast result %d for handle %p", thr_ret, handle);
        <D.13491>:
        D.13482 = thr_ret != 0;
        D.13483 = (long int) D.13482;
        D.13484 = __builtin_expect (D.13483, 0);
        if (D.13484 != 0) goto <D.13492>; else goto <D.13493>;
        <D.13492>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "../../mono/io-layer/handles-private.h", 162, "thr_ret == 0");
        <D.13493>:
        goto <D.13494>;
        <D.13488>:
        D.13489 = &handle_data->signal_cond;
        thr_ret = pthread_cond_signal (D.13489);
        if (thr_ret != 0) goto <D.13495>; else goto <D.13496>;
        <D.13495>:
        monoeg_g_log (0B, 16, "Bad call to pthread_cond_signal result %d for handle %p", thr_ret, handle);
        <D.13496>:
        D.13482 = thr_ret != 0;
        D.13483 = (long int) D.13482;
        D.13484 = __builtin_expect (D.13483, 0);
        if (D.13484 != 0) goto <D.13497>; else goto <D.13498>;
        <D.13497>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "../../mono/io-layer/handles-private.h", 167, "thr_ret == 0");
        <D.13498>:
        <D.13494>:
        _wapi_global_signal_cond.12 = _wapi_global_signal_cond;
        thr_ret = pthread_cond_broadcast (_wapi_global_signal_cond.12);
        if (thr_ret != 0) goto <D.13500>; else goto <D.13501>;
        <D.13500>:
        monoeg_g_log (0B, 16, "Bad call to pthread_cond_broadcast result %d for handle %p", thr_ret, handle);
        <D.13501>:
        D.13482 = thr_ret != 0;
        D.13483 = (long int) D.13482;
        D.13484 = __builtin_expect (D.13483, 0);
        if (D.13484 != 0) goto <D.13502>; else goto <D.13503>;
        <D.13502>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "../../mono/io-layer/handles-private.h", 176, "thr_ret == 0");
        <D.13503>:
        _wapi_global_signal_mutex.11 = _wapi_global_signal_mutex;
        thr_ret = pthread_mutex_unlock (_wapi_global_signal_mutex.11);
        if (thr_ret != 0) goto <D.13504>; else goto <D.13505>;
        <D.13504>:
        monoeg_g_log (0B, 16, "Bad call to mono_mutex_unlock result %d for global signal mutex", thr_ret);
        <D.13505>:
        D.13482 = thr_ret != 0;
        D.13483 = (long int) D.13482;
        D.13484 = __builtin_expect (D.13483, 0);
        if (D.13484 != 0) goto <D.13506>; else goto <D.13507>;
        <D.13506>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "../../mono/io-layer/handles-private.h", 181, "thr_ret == 0");
        <D.13507>:
        __pthread_unregister_cancel (&__cancel_buf);
        if (0 != 0) goto <D.13508>; else goto <D.13509>;
        <D.13508>:
        __cancel_routine (__cancel_arg);
        <D.13509>:
      }
    finally
      {
        __cancel_buf = {CLOBBER};
      }
  }
  goto <D.13510>;
  <D.13474>:
  handle_data->signalled = state;
  <D.13510>:
}


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

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


_wapi_handle_unlock_handle (void * handle)
{
  long int handle.13;
  int D.13526;
  <unnamed type> D.13529;
  <unnamed type> D.13531;
  <unnamed type> D.13533;
  <unnamed type> D.13535;
  unsigned int D.13536;
  struct _WapiHandleUnshared * D.13537;
  long unsigned int D.13538;
  long unsigned int D.13539;
  long unsigned int D.13540;
  struct _WapiHandleUnshared * D.13541;
  union mono_mutex_t * D.13542;
  guint32 idx;
  int ret;

  handle.13 = (long int) handle;
  idx = (guint32) handle.13;
  if (idx > 4194303) goto <D.13524>; else goto <D.13525>;
  <D.13524>:
  D.13526 = 0;
  return D.13526;
  <D.13525>:
  D.13529 = _wapi_handle_type (handle);
  if (D.13529 == 9) goto <D.13527>; else goto <D.13530>;
  <D.13530>:
  D.13531 = _wapi_handle_type (handle);
  if (D.13531 == 11) goto <D.13527>; else goto <D.13532>;
  <D.13532>:
  D.13533 = _wapi_handle_type (handle);
  if (D.13533 == 12) goto <D.13527>; else goto <D.13534>;
  <D.13534>:
  D.13535 = _wapi_handle_type (handle);
  if (D.13535 == 13) goto <D.13527>; else goto <D.13528>;
  <D.13527>:
  _wapi_handle_unref (handle);
  D.13526 = 0;
  return D.13526;
  <D.13528>:
  D.13536 = idx / 256;
  D.13537 = _wapi_private_handles[D.13536];
  D.13538 = (long unsigned int) idx;
  D.13539 = D.13538 & 255;
  D.13540 = D.13539 * 200;
  D.13541 = D.13537 + D.13540;
  D.13542 = &D.13541->signal_mutex;
  ret = pthread_mutex_unlock (D.13542);
  _wapi_handle_unref (handle);
  D.13526 = ret;
  return D.13526;
}


_wapi_thread_signal_self (guint32 exitstatus)
{
  long unsigned int D.13544;
  void * handle;

  D.13544 = pthread_self ();
  handle = _wapi_thread_handle_from_id (D.13544);
  if (handle == 0B) goto <D.13545>; else goto <D.13546>;
  <D.13545>:
  return;
  <D.13546>:
  _wapi_thread_set_termination_details (handle, exitstatus);
}


CreateThread (struct WapiSecurityAttributes * security, guint32 stacksize, guint32 (*WapiThreadStart) (void *) start, void * param, guint32 create, gsize * tid)
{
  void * D.13550;
  struct GPtrArray * D.13551;
  long int D.13554;
  long int D.13555;
  _Bool D.13558;
  long int D.13559;
  long int D.13560;
  long unsigned int D.13571;
  struct _WapiHandle_thread * thread_handle_p.14;
  union MonoSemType * D.13575;
  pthread_t * D.13576;
  char * D.13579;
  long unsigned int D.13582;
  struct _WapiHandle_thread thread_handle;
  struct _WapiHandle_thread * thread_handle_p;
  union pthread_attr_t attr;
  void * handle;
  gboolean ok;
  int ret;
  int thr_ret;
  int i;
  int unrefs;
  void * ct_ret;
  static const char __func__[13] = "CreateThread";
  void cleanup = <<< error >>>;

  try
    {
      thread_handle = {};
      unrefs = 0;
      ct_ret = 0B;
      mono_once (&thread_hash_once, thread_hash_init);
      mono_once (&thread_ops_once, thread_ops_init);
      if (start == 0B) goto <D.13548>; else goto <D.13549>;
      <D.13548>:
      D.13550 = 0B;
      return D.13550;
      <D.13549>:
      thread_handle.state = 0;
      D.13551 = monoeg_g_ptr_array_new ();
      thread_handle.owned_mutexes = D.13551;
      thread_handle.create_flags = create;
      thread_handle.start_routine = start;
      thread_handle.start_arg = param;
      handle = _wapi_handle_new (3, &thread_handle);
      if (handle == -1B) goto <D.13552>; else goto <D.13553>;
      <D.13552>:
      monoeg_g_log (0B, 16, "%s: error creating thread handle", &__func__);
      SetLastError (31);
      D.13550 = 0B;
      return D.13550;
      <D.13553>:
      {
        struct __pthread_unwind_buf_t __cancel_buf;
        void (*<Tc2>) (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.13554 = (long int) __not_first_call;
            D.13555 = __builtin_expect (D.13554, 0);
            if (D.13555 != 0) goto <D.13556>; else goto <D.13557>;
            <D.13556>:
            __cancel_routine (__cancel_arg);
            __pthread_unwind_next (&__cancel_buf);
            <D.13557>:
            __pthread_register_cancel (&__cancel_buf);
            thr_ret = _wapi_handle_lock_handle (handle);
            D.13558 = thr_ret != 0;
            D.13559 = (long int) D.13558;
            D.13560 = __builtin_expect (D.13559, 0);
            if (D.13560 != 0) goto <D.13561>; else goto <D.13562>;
            <D.13561>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "wthreads.c", 360, "thr_ret == 0");
            <D.13562>:
            ok = _wapi_lookup_handle (handle, 3, &thread_handle_p);
            if (ok == 0) goto <D.13563>; else goto <D.13564>;
            <D.13563>:
            monoeg_g_log (0B, 16, "%s: error looking up thread handle %p", &__func__, handle);
            SetLastError (31);
            goto cleanup;
            <D.13564>:
            _wapi_handle_ref (handle);
            thr_ret = pthread_attr_init (&attr);
            D.13558 = thr_ret != 0;
            D.13559 = (long int) D.13558;
            D.13560 = __builtin_expect (D.13559, 0);
            if (D.13560 != 0) goto <D.13565>; else goto <D.13566>;
            <D.13565>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "wthreads.c", 383, "thr_ret == 0");
            <D.13566>:
            if (stacksize == 0) goto <D.13567>; else goto <D.13568>;
            <D.13567>:
            stacksize = 2097152;
            <D.13568>:
            if (stacksize <= 16383) goto <D.13569>; else goto <D.13570>;
            <D.13569>:
            stacksize = 16384;
            <D.13570>:
            D.13571 = (long unsigned int) stacksize;
            thr_ret = pthread_attr_setstacksize (&attr, D.13571);
            D.13558 = thr_ret != 0;
            D.13559 = (long int) D.13558;
            D.13560 = __builtin_expect (D.13559, 0);
            if (D.13560 != 0) goto <D.13572>; else goto <D.13573>;
            <D.13572>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "wthreads.c", 409, "thr_ret == 0");
            <D.13573>:
            thread_handle_p.14 = thread_handle_p;
            D.13575 = &thread_handle_p.14->suspend_sem;
            sem_init (D.13575, 0, 0);
            thread_handle_p.14 = thread_handle_p;
            thread_handle_p.14->handle = handle;
            thread_handle_p.14 = thread_handle_p;
            thread_handle_p.14 = thread_handle_p;
            D.13576 = &thread_handle_p.14->id;
            ret = mono_threads_pthread_create (D.13576, &attr, thread_start_routine, thread_handle_p.14);
            if (ret != 0) goto <D.13577>; else goto <D.13578>;
            <D.13577>:
            D.13579 = strerror (ret);
            monoeg_g_log (0B, 16, "%s: Error creating native thread handle %s (%d)", &__func__, D.13579, ret);
            SetLastError (31);
            unrefs = 2;
            goto cleanup;
            <D.13578>:
            ct_ret = handle;
            if (tid != 0B) goto <D.13580>; else goto <D.13581>;
            <D.13580>:
            thread_handle_p.14 = thread_handle_p;
            D.13582 = thread_handle_p.14->id;
            *tid = D.13582;
            <D.13581>:
            cleanup:
            thr_ret = _wapi_handle_unlock_handle (handle);
            D.13558 = thr_ret != 0;
            D.13559 = (long int) D.13558;
            D.13560 = __builtin_expect (D.13559, 0);
            if (D.13560 != 0) goto <D.13583>; else goto <D.13584>;
            <D.13583>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "wthreads.c", 448, "thr_ret == 0");
            <D.13584>:
            __pthread_unregister_cancel (&__cancel_buf);
            if (0 != 0) goto <D.13585>; else goto <D.13586>;
            <D.13585>:
            __cancel_routine (__cancel_arg);
            <D.13586>:
          }
        finally
          {
            __cancel_buf = {CLOBBER};
          }
      }
      i = 0;
      goto <D.13132>;
      <D.13131>:
      _wapi_handle_unref (handle);
      i = i + 1;
      <D.13132>:
      if (i < unrefs) goto <D.13131>; else goto <D.13133>;
      <D.13133>:
      D.13550 = ct_ret;
      return D.13550;
    }
  finally
    {
      thread_handle = {CLOBBER};
      thread_handle_p = {CLOBBER};
      attr = {CLOBBER};
    }
}


thread_start_routine (void * args)
{
  unsigned int D.13595;
  unsigned int D.13596;
  long unsigned int D.13599;
  _Bool D.13600;
  long int D.13601;
  long int D.13602;
  void * D.13605;
  unsigned int thread_hash_key.15;
  unsigned int D.13609;
  guint32 (*<T1632>) (void *) D.13612;
  void * D.13613;
  unsigned int D.13614;
  struct _WapiHandle_thread * thread;
  int thr_ret;

  thread = args;
  D.13595 = thread->create_flags;
  D.13596 = D.13595 & 268435456;
  if (D.13596 == 0) goto <D.13597>; else goto <D.13598>;
  <D.13597>:
  D.13599 = pthread_self ();
  thr_ret = mono_gc_pthread_detach (D.13599);
  D.13600 = thr_ret != 0;
  D.13601 = (long int) D.13600;
  D.13602 = __builtin_expect (D.13601, 0);
  if (D.13602 != 0) goto <D.13603>; else goto <D.13604>;
  <D.13603>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "wthreads.c", 259, "thr_ret == 0");
  <D.13604>:
  <D.13598>:
  D.13605 = thread->handle;
  thread_hash_key.15 = thread_hash_key;
  thr_ret = pthread_setspecific (thread_hash_key.15, D.13605);
  if (thr_ret != 0) goto <D.13607>; else goto <D.13608>;
  <D.13607>:
  mono_gc_pthread_exit (0B);
  <D.13608>:
  D.13599 = pthread_self ();
  thread->id = D.13599;
  D.13595 = thread->create_flags;
  D.13609 = D.13595 & 4;
  if (D.13609 != 0) goto <D.13610>; else goto <D.13611>;
  <D.13610>:
  _wapi_thread_suspend (thread);
  <D.13611>:
  D.13605 = thread->handle;
  D.13612 = thread->start_routine;
  D.13613 = thread->start_arg;
  D.13614 = D.13612 (D.13613);
  thread_exit (D.13614, D.13605);
}


_wapi_thread_suspend (struct _WapiHandle_thread * thread)
{
  long unsigned int D.13615;
  long unsigned int D.13616;
  int D.13617;
  _Bool D.13618;
  long int D.13619;
  long int D.13620;
  union MonoSemType * D.13623;
  int D.13624;
  int * D.13626;
  int D.13627;

  D.13615 = pthread_self ();
  D.13616 = thread->id;
  D.13617 = pthread_equal (D.13616, D.13615);
  D.13618 = D.13617 == 0;
  D.13619 = (long int) D.13618;
  D.13620 = __builtin_expect (D.13619, 0);
  if (D.13620 != 0) goto <D.13621>; else goto <D.13622>;
  <D.13621>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "wthreads.c", 240, "pthread_equal (thread->id, pthread_self ())");
  <D.13622>:
  goto <D.13093>;
  <D.13092>:
  <D.13093>:
  D.13623 = &thread->suspend_sem;
  D.13624 = mono_sem_wait (D.13623, 0);
  if (D.13624 != 0) goto <D.13625>; else goto <D.13094>;
  <D.13625>:
  D.13626 = __errno_location ();
  D.13627 = *D.13626;
  if (D.13627 == 4) goto <D.13092>; else goto <D.13094>;
  <D.13094>:
}


thread_exit (guint32 exitstatus, void * handle)
{
  _wapi_thread_set_termination_details (handle, exitstatus);
  mono_gc_pthread_exit (0B);
}


thread_ops_init ()
{
  _wapi_handle_register_capabilities (3, 1);
}


thread_hash_init ()
{
  _Bool D.13628;
  long int D.13629;
  long int D.13630;
  int thr_ret;

  thr_ret = pthread_key_create (&thread_hash_key, 0B);
  D.13628 = thr_ret != 0;
  D.13629 = (long int) D.13628;
  D.13630 = __builtin_expect (D.13629, 0);
  if (D.13630 != 0) goto <D.13631>; else goto <D.13632>;
  <D.13631>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "wthreads.c", 231, "thr_ret == 0");
  <D.13632>:
  thr_ret = pthread_key_create (&thread_attached_key, thread_attached_exit);
  D.13628 = thr_ret != 0;
  D.13629 = (long int) D.13628;
  D.13630 = __builtin_expect (D.13629, 0);
  if (D.13630 != 0) goto <D.13633>; else goto <D.13634>;
  <D.13633>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "wthreads.c", 235, "thr_ret == 0");
  <D.13634>:
}


thread_attached_exit (void * handle)
{
  _wapi_thread_set_termination_details (handle, 0);
}


_wapi_thread_handle_from_id (pthread_t tid)
{
  long unsigned int D.13635;
  int D.13636;
  unsigned int thread_hash_key.16;
  void * D.13642;
  void * ret;

  D.13635 = pthread_self ();
  D.13636 = pthread_equal (tid, D.13635);
  if (D.13636 != 0) goto <D.13637>; else goto <D.13638>;
  <D.13637>:
  thread_hash_key.16 = thread_hash_key;
  ret = pthread_getspecific (thread_hash_key.16);
  if (ret != 0B) goto <D.13640>; else goto <D.13641>;
  <D.13640>:
  D.13642 = ret;
  return D.13642;
  <D.13641>:
  <D.13638>:
  D.13642 = 0B;
  return D.13642;
}


OpenThread (guint32 access, gboolean inherit, gsize tid)
{
  void * tid.17;
  void * D.13648;
  void * ret;

  ret = 0B;
  mono_once (&thread_hash_once, thread_hash_init);
  mono_once (&thread_ops_once, thread_ops_init);
  ret = _wapi_thread_handle_from_id (tid);
  if (ret == 0B) goto <D.13644>; else goto <D.13645>;
  <D.13644>:
  tid.17 = (void *) tid;
  ret = _wapi_search_handle (3, find_thread_by_id, tid.17, 0B, 0);
  goto <D.13647>;
  <D.13645>:
  _wapi_handle_ref (ret);
  <D.13647>:
  D.13648 = ret;
  return D.13648;
}


find_thread_by_id (void * handle, void * user_data)
{
  int D.13650;
  gboolean D.13655;
  struct _WapiHandle_thread * thread_handle.18;
  long unsigned int D.13657;
  int D.13658;
  pthread_t tid;
  struct _WapiHandle_thread * thread_handle;
  gboolean ok;

  try
    {
      tid = (pthread_t) user_data;
      D.13650 = _wapi_handle_issignalled (handle);
      if (D.13650 == 0) goto <D.13651>; else goto <D.13652>;
      <D.13651>:
      ok = _wapi_lookup_handle (handle, 3, &thread_handle);
      if (ok == 0) goto <D.13653>; else goto <D.13654>;
      <D.13653>:
      D.13655 = 0;
      return D.13655;
      <D.13654>:
      thread_handle.18 = thread_handle;
      D.13657 = thread_handle.18->id;
      D.13658 = pthread_equal (D.13657, tid);
      if (D.13658 != 0) goto <D.13659>; else goto <D.13660>;
      <D.13659>:
      D.13655 = 1;
      return D.13655;
      <D.13660>:
      <D.13652>:
      D.13655 = 0;
      return D.13655;
    }
  finally
    {
      thread_handle = {CLOBBER};
    }
}


ExitThread (guint32 exitcode)
{
  long unsigned int D.13663;
  void * thread;

  D.13663 = pthread_self ();
  thread = _wapi_thread_handle_from_id (D.13663);
  if (thread != 0B) goto <D.13664>; else goto <D.13665>;
  <D.13664>:
  thread_exit (exitcode, thread);
  <D.13665>:
  mono_gc_pthread_exit (0B);
}


GetExitCodeThread (void * handle, guint32 * exitcode)
{
  gboolean D.13668;
  struct _WapiHandle_thread * thread_handle.19;
  unsigned char D.13672;
  unsigned char D.13673;
  unsigned int D.13676;
  struct _WapiHandle_thread * thread_handle;
  gboolean ok;
  static const char __func__[18] = "GetExitCodeThread";

  try
    {
      ok = _wapi_lookup_handle (handle, 3, &thread_handle);
      if (ok == 0) goto <D.13666>; else goto <D.13667>;
      <D.13666>:
      monoeg_g_log (0B, 16, "%s: error looking up thread handle %p", &__func__, handle);
      D.13668 = 0;
      return D.13668;
      <D.13667>:
      if (exitcode == 0B) goto <D.13669>; else goto <D.13670>;
      <D.13669>:
      D.13668 = 0;
      return D.13668;
      <D.13670>:
      thread_handle.19 = thread_handle;
      D.13672 = BIT_FIELD_REF <*thread_handle.19, 8, 32>;
      D.13673 = D.13672 & 3;
      if (D.13673 != 1) goto <D.13674>; else goto <D.13675>;
      <D.13674>:
      *exitcode = 259;
      D.13668 = 1;
      return D.13668;
      <D.13675>:
      thread_handle.19 = thread_handle;
      D.13676 = thread_handle.19->exitstatus;
      *exitcode = D.13676;
      D.13668 = 1;
      return D.13668;
    }
  finally
    {
      thread_handle = {CLOBBER};
    }
}


GetCurrentThreadId ()
{
  gsize D.13679;
  pthread_t tid;

  tid = pthread_self ();
  D.13679 = tid;
  return D.13679;
}


_wapi_thread_duplicate ()
{
  long unsigned int D.13681;
  void * D.13685;
  void * ret;

  ret = 0B;
  mono_once (&thread_hash_once, thread_hash_init);
  mono_once (&thread_ops_once, thread_ops_init);
  D.13681 = pthread_self ();
  ret = _wapi_thread_handle_from_id (D.13681);
  if (ret == 0B) goto <D.13682>; else goto <D.13683>;
  <D.13682>:
  ret = thread_attach (0B);
  goto <D.13684>;
  <D.13683>:
  _wapi_handle_ref (ret);
  <D.13684>:
  D.13685 = ret;
  return D.13685;
}


thread_attach (gsize * tid)
{
  struct GPtrArray * D.13687;
  void * D.13690;
  long int D.13691;
  long int D.13692;
  _Bool D.13695;
  long int D.13696;
  long int D.13697;
  struct _WapiHandle_thread * thread_handle_p.20;
  union MonoSemType * D.13703;
  long unsigned int D.13704;
  unsigned int thread_hash_key.21;
  unsigned int thread_attached_key.22;
  long unsigned int D.13713;
  struct _WapiHandle_thread thread_handle;
  struct _WapiHandle_thread * thread_handle_p;
  void * handle;
  gboolean ok;
  int thr_ret;
  static const char __func__[14] = "thread_attach";
  void cleanup = <<< error >>>;

  try
    {
      thread_handle = {};
      mono_once (&thread_hash_once, thread_hash_init);
      mono_once (&thread_ops_once, thread_ops_init);
      thread_handle.state = 0;
      D.13687 = monoeg_g_ptr_array_new ();
      thread_handle.owned_mutexes = D.13687;
      handle = _wapi_handle_new (3, &thread_handle);
      if (handle == -1B) goto <D.13688>; else goto <D.13689>;
      <D.13688>:
      monoeg_g_log (0B, 16, "%s: error creating thread handle", &__func__);
      SetLastError (31);
      D.13690 = 0B;
      return D.13690;
      <D.13689>:
      {
        struct __pthread_unwind_buf_t __cancel_buf;
        void (*<Tc2>) (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.13691 = (long int) __not_first_call;
            D.13692 = __builtin_expect (D.13691, 0);
            if (D.13692 != 0) goto <D.13693>; else goto <D.13694>;
            <D.13693>:
            __cancel_routine (__cancel_arg);
            __pthread_unwind_next (&__cancel_buf);
            <D.13694>:
            __pthread_register_cancel (&__cancel_buf);
            thr_ret = _wapi_handle_lock_handle (handle);
            D.13695 = thr_ret != 0;
            D.13696 = (long int) D.13695;
            D.13697 = __builtin_expect (D.13696, 0);
            if (D.13697 != 0) goto <D.13698>; else goto <D.13699>;
            <D.13698>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "wthreads.c", 663, "thr_ret == 0");
            <D.13699>:
            ok = _wapi_lookup_handle (handle, 3, &thread_handle_p);
            if (ok == 0) goto <D.13700>; else goto <D.13701>;
            <D.13700>:
            monoeg_g_log (0B, 16, "%s: error looking up thread handle %p", &__func__, handle);
            SetLastError (31);
            goto cleanup;
            <D.13701>:
            _wapi_handle_ref (handle);
            thread_handle_p.20 = thread_handle_p;
            D.13703 = &thread_handle_p.20->suspend_sem;
            sem_init (D.13703, 0, 0);
            thread_handle_p.20 = thread_handle_p;
            thread_handle_p.20->handle = handle;
            thread_handle_p.20 = thread_handle_p;
            D.13704 = pthread_self ();
            thread_handle_p.20->id = D.13704;
            thread_hash_key.21 = thread_hash_key;
            thr_ret = pthread_setspecific (thread_hash_key.21, handle);
            D.13695 = thr_ret != 0;
            D.13696 = (long int) D.13695;
            D.13697 = __builtin_expect (D.13696, 0);
            if (D.13697 != 0) goto <D.13706>; else goto <D.13707>;
            <D.13706>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "wthreads.c", 688, "thr_ret == 0");
            <D.13707>:
            thread_attached_key.22 = thread_attached_key;
            thr_ret = pthread_setspecific (thread_attached_key.22, handle);
            D.13695 = thr_ret != 0;
            D.13696 = (long int) D.13695;
            D.13697 = __builtin_expect (D.13696, 0);
            if (D.13697 != 0) goto <D.13709>; else goto <D.13710>;
            <D.13709>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "wthreads.c", 691, "thr_ret == 0");
            <D.13710>:
            if (tid != 0B) goto <D.13711>; else goto <D.13712>;
            <D.13711>:
            thread_handle_p.20 = thread_handle_p;
            D.13713 = thread_handle_p.20->id;
            *tid = D.13713;
            <D.13712>:
            cleanup:
            thr_ret = _wapi_handle_unlock_handle (handle);
            D.13695 = thr_ret != 0;
            D.13696 = (long int) D.13695;
            D.13697 = __builtin_expect (D.13696, 0);
            if (D.13697 != 0) goto <D.13714>; else goto <D.13715>;
            <D.13714>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "wthreads.c", 710, "thr_ret == 0");
            <D.13715>:
            __pthread_unregister_cancel (&__cancel_buf);
            if (0 != 0) goto <D.13716>; else goto <D.13717>;
            <D.13716>:
            __cancel_routine (__cancel_arg);
            <D.13717>:
          }
        finally
          {
            __cancel_buf = {CLOBBER};
          }
      }
      D.13690 = handle;
      return D.13690;
    }
  finally
    {
      thread_handle = {CLOBBER};
      thread_handle_p = {CLOBBER};
    }
}


GetCurrentThread ()
{
  void * D.13725;

  mono_once (&thread_hash_once, thread_hash_init);
  mono_once (&thread_ops_once, thread_ops_init);
  D.13725 = 4294967294B;
  return D.13725;
}


ResumeThread (void * handle)
{
  guint32 D.13729;
  struct _WapiHandle_thread * thread_handle.23;
  struct _WapiHandle_thread * thread_handle;
  gboolean ok;
  static const char __func__[13] = "ResumeThread";

  try
    {
      ok = _wapi_lookup_handle (handle, 3, &thread_handle);
      if (ok == 0) goto <D.13727>; else goto <D.13728>;
      <D.13727>:
      monoeg_g_log (0B, 16, "%s: error looking up thread handle %p", &__func__, handle);
      D.13729 = 4294967295;
      return D.13729;
      <D.13728>:
      thread_handle.23 = thread_handle;
      _wapi_thread_resume (thread_handle.23);
      D.13729 = 4294967295;
      return D.13729;
    }
  finally
    {
      thread_handle = {CLOBBER};
    }
}


_wapi_thread_resume (struct _WapiHandle_thread * thread)
{
  union MonoSemType * D.13733;

  D.13733 = &thread->suspend_sem;
  mono_sem_post (D.13733);
}


SuspendThread (void * handle)
{
  guint32 D.13734;

  D.13734 = 4294967295;
  return D.13734;
}


SleepEx (guint32 ms, gboolean alertable)
{
  long unsigned int D.13738;
  guint32 D.13741;
  int D.13742;
  unsigned int D.13747;
  unsigned int D.13748;
  long int D.13749;
  int D.13750;
  long int D.13751;
  int D.13754;
  struct timespec req;
  struct timespec rem;
  int ms_quot;
  int ms_rem;
  int ret;
  void * current_thread;
  void again = <<< error >>>;

  try
    {
      current_thread = 0B;
      if (alertable != 0) goto <D.13736>; else goto <D.13737>;
      <D.13736>:
      D.13738 = pthread_self ();
      current_thread = _wapi_thread_handle_from_id (D.13738);
      if (current_thread == 0B) goto <D.13739>; else goto <D.13740>;
      <D.13739>:
      SetLastError (6);
      D.13741 = 4294967295;
      return D.13741;
      <D.13740>:
      D.13742 = _wapi_thread_apc_pending (current_thread);
      if (D.13742 != 0) goto <D.13743>; else goto <D.13744>;
      <D.13743>:
      _wapi_thread_dispatch_apc_queue (current_thread);
      D.13741 = 192;
      return D.13741;
      <D.13744>:
      <D.13737>:
      if (ms == 0) goto <D.13745>; else goto <D.13746>;
      <D.13745>:
      sched_yield ();
      D.13741 = 0;
      return D.13741;
      <D.13746>:
      D.13747 = ms / 1000;
      ms_quot = (int) D.13747;
      D.13748 = ms % 1000;
      ms_rem = (int) D.13748;
      D.13749 = (long int) ms_quot;
      req.tv_sec = D.13749;
      D.13750 = ms_rem * 1000000;
      D.13751 = (long int) D.13750;
      req.tv_nsec = D.13751;
      again:
      memset (&rem, 0, 16);
      ret = nanosleep (&req, &rem);
      if (alertable != 0) goto <D.13752>; else goto <D.13753>;
      <D.13752>:
      D.13754 = _wapi_thread_apc_pending (current_thread);
      if (D.13754 != 0) goto <D.13755>; else goto <D.13756>;
      <D.13755>:
      _wapi_thread_dispatch_apc_queue (current_thread);
      D.13741 = 192;
      return D.13741;
      <D.13756>:
      <D.13753>:
      if (ret == -1) goto <D.13757>; else goto <D.13758>;
      <D.13757>:
      req = rem;
      goto again;
      <D.13758>:
      D.13741 = 0;
      return D.13741;
    }
  finally
    {
      req = {CLOBBER};
      rem = {CLOBBER};
    }
}


memset (void * __dest, int __ch, size_t __len)
{
  int D.13763;
  int D.13768;
  void * D.13770;
  long unsigned int D.13771;

  D.13763 = __builtin_constant_p (__len);
  if (D.13763 != 0) goto <D.13764>; else goto <D.13765>;
  <D.13764>:
  if (__len == 0) goto <D.13766>; else goto <D.13767>;
  <D.13766>:
  D.13768 = __builtin_constant_p (__ch);
  if (D.13768 == 0) goto <D.13761>; else goto <D.13769>;
  <D.13769>:
  if (__ch != 0) goto <D.13761>; else goto <D.13762>;
  <D.13761>:
  __warn_memset_zero_len ();
  D.13770 = __dest;
  return D.13770;
  <D.13762>:
  <D.13767>:
  <D.13765>:
  D.13771 = __builtin_object_size (__dest, 0);
  D.13770 = __builtin___memset_chk (__dest, __ch, __len, D.13771);
  return D.13770;
}


Sleep (guint32 ms)
{
  SleepEx (ms, 0);
}


_wapi_thread_cur_apc_pending ()
{
  long unsigned int D.13773;
  gboolean D.13776;
  void * thread;

  D.13773 = pthread_self ();
  thread = _wapi_thread_handle_from_id (D.13773);
  if (thread == 0B) goto <D.13774>; else goto <D.13775>;
  <D.13774>:
  SetLastError (6);
  D.13776 = 0;
  return D.13776;
  <D.13775>:
  D.13776 = _wapi_thread_apc_pending (thread);
  return D.13776;
}


_wapi_thread_apc_pending (void * handle)
{
  gboolean D.13780;
  int iftmp.24;
  struct _WapiHandle_thread * thread.25;
  unsigned char D.13786;
  unsigned char D.13787;
  void * D.13789;
  struct _WapiHandle_thread * thread;
  gboolean ok;

  try
    {
      ok = _wapi_lookup_handle (handle, 3, &thread);
      if (ok == 0) goto <D.13778>; else goto <D.13779>;
      <D.13778>:
      D.13780 = 0;
      return D.13780;
      <D.13779>:
      thread.25 = thread;
      D.13786 = BIT_FIELD_REF <*thread.25, 8, 32>;
      D.13787 = D.13786 & 8;
      if (D.13787 != 0) goto <D.13782>; else goto <D.13788>;
      <D.13788>:
      thread.25 = thread;
      D.13789 = thread.25->wait_handle;
      if (D.13789 == 4294967294B) goto <D.13782>; else goto <D.13783>;
      <D.13782>:
      iftmp.24 = 1;
      goto <D.13784>;
      <D.13783>:
      iftmp.24 = 0;
      <D.13784>:
      D.13780 = iftmp.24;
      return D.13780;
    }
  finally
    {
      thread = {CLOBBER};
    }
}


_wapi_thread_dispatch_apc_queue (void * handle)
{
  _Bool D.13792;
  long int D.13793;
  long int D.13794;
  struct _WapiHandle_thread * thread.26;
  gboolean D.13798;
  struct _WapiHandle_thread * thread;
  gboolean ok;

  try
    {
      ok = _wapi_lookup_handle (handle, 3, &thread);
      D.13792 = ok == 0;
      D.13793 = (long int) D.13792;
      D.13794 = __builtin_expect (D.13793, 0);
      if (D.13794 != 0) goto <D.13795>; else goto <D.13796>;
      <D.13795>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "wthreads.c", 910, "ok");
      <D.13796>:
      thread.26 = thread;
      thread.26->has_apc = 0;
      D.13798 = 1;
      return D.13798;
    }
  finally
    {
      thread = {CLOBBER};
    }
}


QueueUserAPC (guint32 (*WapiApcProc) (void *) apc_callback, void * handle, void * param)
{
  guint32 D.13803;
  struct _WapiHandle_thread * thread_handle.27;
  long unsigned int D.13805;
  long unsigned int D.13806;
  _Bool D.13807;
  long int D.13808;
  long int D.13809;
  struct _WapiHandle_thread * thread_handle;
  gboolean ok;
  static const char __func__[13] = "QueueUserAPC";

  try
    {
      ok = _wapi_lookup_handle (handle, 3, &thread_handle);
      if (ok == 0) goto <D.13801>; else goto <D.13802>;
      <D.13801>:
      monoeg_g_log (0B, 16, "%s: error looking up thread handle %p", &__func__, handle);
      D.13803 = 0;
      return D.13803;
      <D.13802>:
      thread_handle.27 = thread_handle;
      D.13805 = thread_handle.27->id;
      D.13806 = GetCurrentThreadId ();
      D.13807 = D.13805 != D.13806;
      D.13808 = (long int) D.13807;
      D.13809 = __builtin_expect (D.13808, 0);
      if (D.13809 != 0) goto <D.13810>; else goto <D.13811>;
      <D.13810>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "wthreads.c", 938, "thread_handle->id == (pthread_t)GetCurrentThreadId ()");
      <D.13811>:
      thread_handle.27 = thread_handle;
      thread_handle.27->has_apc = 1;
      D.13803 = 1;
      return D.13803;
    }
  finally
    {
      thread_handle = {CLOBBER};
    }
}


wapi_interrupt_thread (void * thread_handle)
{
  _Bool D.13814;
  long int D.13815;
  long int D.13816;
  struct _WapiHandle_thread * thread.28;
  void * * D.13820;
  long int wait_handle.29;
  unsigned int D.13827;
  struct _WapiHandleUnshared * D.13828;
  long unsigned int D.13829;
  long unsigned int D.13830;
  long unsigned int D.13831;
  struct _WapiHandleUnshared * D.13832;
  struct _WapiHandle_thread * thread;
  gboolean ok;
  void * prev_handle;
  void * wait_handle;
  guint32 idx;
  union pthread_cond_t * cond;
  union mono_mutex_t * mutex;

  try
    {
      ok = _wapi_lookup_handle (thread_handle, 3, &thread);
      D.13814 = ok == 0;
      D.13815 = (long int) D.13814;
      D.13816 = __builtin_expect (D.13815, 0);
      if (D.13816 != 0) goto <D.13817>; else goto <D.13818>;
      <D.13817>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "wthreads.c", 969, "ok");
      <D.13818>:
      <D.13244>:
      thread.28 = thread;
      wait_handle = thread.28->wait_handle;
      thread.28 = thread;
      D.13820 = &thread.28->wait_handle;
      prev_handle = InterlockedCompareExchangePointer (D.13820, 4294967294B, wait_handle);
      if (prev_handle == 4294967294B) goto <D.13821>; else goto <D.13822>;
      <D.13821>:
      return;
      <D.13822>:
      if (prev_handle == wait_handle) goto <D.13243>; else goto <D.13823>;
      <D.13823>:
      goto <D.13244>;
      <D.13243>:
      if (wait_handle == 0B) goto <D.13824>; else goto <D.13825>;
      <D.13824>:
      return;
      <D.13825>:
      wait_handle.29 = (long int) wait_handle;
      idx = (guint32) wait_handle.29;
      D.13827 = idx / 256;
      D.13828 = _wapi_private_handles[D.13827];
      D.13829 = (long unsigned int) idx;
      D.13830 = D.13829 & 255;
      D.13831 = D.13830 * 200;
      D.13832 = D.13828 + D.13831;
      cond = &D.13832->signal_cond;
      D.13827 = idx / 256;
      D.13828 = _wapi_private_handles[D.13827];
      D.13829 = (long unsigned int) idx;
      D.13830 = D.13829 & 255;
      D.13831 = D.13830 * 200;
      D.13832 = D.13828 + D.13831;
      mutex = &D.13832->signal_mutex;
      pthread_mutex_lock (mutex);
      pthread_cond_broadcast (cond);
      pthread_mutex_unlock (mutex);
      _wapi_handle_unref (wait_handle);
    }
  finally
    {
      thread = {CLOBBER};
    }
}


InterlockedCompareExchangePointer (void * volatile * dest, void * exch, void * comp)
{
  void * D.13836;
  long unsigned int exch.30;
  long unsigned int comp.31;
  long unsigned int D.13839;

  exch.30 = (long unsigned int) exch;
  comp.31 = (long unsigned int) comp;
  D.13839 = __sync_val_compare_and_swap_8 (dest, comp.31, exch.30);
  D.13836 = (void *) D.13839;
  return D.13836;
}


wapi_prepare_interrupt_thread (void * thread_handle)
{
  _Bool D.13841;
  long int D.13842;
  long int D.13843;
  struct _WapiHandle_thread * thread.32;
  void * * D.13847;
  void * D.13850;
  struct _WapiHandle_thread * thread;
  gboolean ok;
  void * prev_handle;
  void * wait_handle;

  try
    {
      ok = _wapi_lookup_handle (thread_handle, 3, &thread);
      D.13841 = ok == 0;
      D.13842 = (long int) D.13841;
      D.13843 = __builtin_expect (D.13842, 0);
      if (D.13843 != 0) goto <D.13844>; else goto <D.13845>;
      <D.13844>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "wthreads.c", 1023, "ok");
      <D.13845>:
      <D.13253>:
      thread.32 = thread;
      wait_handle = thread.32->wait_handle;
      thread.32 = thread;
      D.13847 = &thread.32->wait_handle;
      prev_handle = InterlockedCompareExchangePointer (D.13847, 4294967294B, wait_handle);
      if (prev_handle == 4294967294B) goto <D.13848>; else goto <D.13849>;
      <D.13848>:
      D.13850 = 0B;
      return D.13850;
      <D.13849>:
      if (prev_handle == wait_handle) goto <D.13252>; else goto <D.13851>;
      <D.13851>:
      goto <D.13253>;
      <D.13252>:
      D.13850 = wait_handle;
      return D.13850;
    }
  finally
    {
      thread = {CLOBBER};
    }
}


wapi_finish_interrupt_thread (void * wait_handle)
{
  long int wait_handle.33;
  unsigned int D.13857;
  struct _WapiHandleUnshared * D.13858;
  long unsigned int D.13859;
  long unsigned int D.13860;
  long unsigned int D.13861;
  struct _WapiHandleUnshared * D.13862;
  union pthread_cond_t * cond;
  union mono_mutex_t * mutex;
  guint32 idx;

  if (wait_handle == 0B) goto <D.13854>; else goto <D.13855>;
  <D.13854>:
  return;
  <D.13855>:
  wait_handle.33 = (long int) wait_handle;
  idx = (guint32) wait_handle.33;
  D.13857 = idx / 256;
  D.13858 = _wapi_private_handles[D.13857];
  D.13859 = (long unsigned int) idx;
  D.13860 = D.13859 & 255;
  D.13861 = D.13860 * 200;
  D.13862 = D.13858 + D.13861;
  cond = &D.13862->signal_cond;
  D.13857 = idx / 256;
  D.13858 = _wapi_private_handles[D.13857];
  D.13859 = (long unsigned int) idx;
  D.13860 = D.13859 & 255;
  D.13861 = D.13860 * 200;
  D.13862 = D.13858 + D.13861;
  mutex = &D.13862->signal_mutex;
  pthread_mutex_lock (mutex);
  pthread_cond_broadcast (cond);
  pthread_mutex_unlock (mutex);
  _wapi_handle_unref (wait_handle);
}


wapi_self_interrupt ()
{
  long unsigned int D.13864;
  _Bool D.13865;
  long int D.13866;
  long int D.13867;
  struct _WapiHandle_thread * thread.34;
  void * * D.13871;
  struct _WapiHandle_thread * thread;
  gboolean ok;
  void * prev_handle;
  void * wait_handle;
  void * thread_handle;
  void cleanup = <<< error >>>;

  try
    {
      D.13864 = GetCurrentThreadId ();
      thread_handle = OpenThread (0, 0, D.13864);
      ok = _wapi_lookup_handle (thread_handle, 3, &thread);
      D.13865 = ok == 0;
      D.13866 = (long int) D.13865;
      D.13867 = __builtin_expect (D.13866, 0);
      if (D.13867 != 0) goto <D.13868>; else goto <D.13869>;
      <D.13868>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "wthreads.c", 1095, "ok");
      <D.13869>:
      <D.13270>:
      thread.34 = thread;
      wait_handle = thread.34->wait_handle;
      thread.34 = thread;
      D.13871 = &thread.34->wait_handle;
      prev_handle = InterlockedCompareExchangePointer (D.13871, 4294967294B, wait_handle);
      if (prev_handle == 4294967294B) goto cleanup; else goto <D.13872>;
      <D.13872>:
      if (prev_handle == wait_handle) goto <D.13269>; else goto <D.13873>;
      <D.13873>:
      goto <D.13270>;
      <D.13269>:
      if (wait_handle != 0B) goto <D.13874>; else goto <D.13875>;
      <D.13874>:
      _wapi_handle_unref (wait_handle);
      <D.13875>:
      cleanup:
      _wapi_handle_unref (thread_handle);
    }
  finally
    {
      thread = {CLOBBER};
    }
}


wapi_clear_interruption ()
{
  long unsigned int D.13876;
  _Bool D.13877;
  long int D.13878;
  long int D.13879;
  struct _WapiHandle_thread * thread.35;
  void * * D.13883;
  struct _WapiHandle_thread * thread;
  gboolean ok;
  void * prev_handle;
  void * thread_handle;

  try
    {
      D.13876 = GetCurrentThreadId ();
      thread_handle = OpenThread (0, 0, D.13876);
      ok = _wapi_lookup_handle (thread_handle, 3, &thread);
      D.13877 = ok == 0;
      D.13878 = (long int) D.13877;
      D.13879 = __builtin_expect (D.13878, 0);
      if (D.13879 != 0) goto <D.13880>; else goto <D.13881>;
      <D.13880>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "wthreads.c", 1142, "ok");
      <D.13881>:
      thread.35 = thread;
      D.13883 = &thread.35->wait_handle;
      prev_handle = InterlockedCompareExchangePointer (D.13883, 0B, 4294967294B);
      if (prev_handle == 4294967294B) goto <D.13884>; else goto <D.13885>;
      <D.13884>:
      <D.13885>:
      _wapi_handle_unref (thread_handle);
    }
  finally
    {
      thread = {CLOBBER};
    }
}


wapi_current_thread_desc ()
{
  long unsigned int D.13886;
  char * D.13889;
  struct _WapiHandle_thread * thread.36;
  <unnamed type> D.13897;
  const char * D.13898;
  struct GPtrArray * D.13899;
  void * * D.13900;
  long unsigned int D.13901;
  long unsigned int D.13902;
  void * * D.13903;
  unsigned int i.37;
  unsigned int D.13908;
  struct _WapiHandle_thread * thread;
  int i;
  gboolean ok;
  void * handle;
  void * thread_handle;
  struct GString * text;
  char * res;

  try
    {
      D.13886 = GetCurrentThreadId ();
      thread_handle = OpenThread (0, 0, D.13886);
      ok = _wapi_lookup_handle (thread_handle, 3, &thread);
      if (ok == 0) goto <D.13887>; else goto <D.13888>;
      <D.13887>:
      D.13889 = monoeg_g_strdup_printf ("thread handle %p state : lookup failure", thread_handle);
      return D.13889;
      <D.13888>:
      thread.36 = thread;
      handle = thread.36->wait_handle;
      text = monoeg_g_string_new (0B);
      monoeg_g_string_append_printf (text, "thread handle %p state : ", thread_handle);
      if (handle == 0B) goto <D.13891>; else goto <D.13892>;
      <D.13891>:
      monoeg_g_string_append_printf (text, "not waiting");
      goto <D.13893>;
      <D.13892>:
      if (handle == 4294967294B) goto <D.13894>; else goto <D.13895>;
      <D.13894>:
      monoeg_g_string_append_printf (text, "interrupted state");
      goto <D.13896>;
      <D.13895>:
      D.13897 = _wapi_handle_type (handle);
      D.13898 = _wapi_handle_typename[D.13897];
      monoeg_g_string_append_printf (text, "waiting on %p : %s ", handle, D.13898);
      <D.13896>:
      <D.13893>:
      monoeg_g_string_append_printf (text, " owns (");
      i = 0;
      goto <D.13289>;
      <D.13288>:
      {
        void * mutex;

        thread.36 = thread;
        D.13899 = thread.36->owned_mutexes;
        D.13900 = D.13899->pdata;
        D.13901 = (long unsigned int) i;
        D.13902 = D.13901 * 8;
        D.13903 = D.13900 + D.13902;
        mutex = *D.13903;
        if (i > 0) goto <D.13904>; else goto <D.13905>;
        <D.13904>:
        monoeg_g_string_append_printf (text, ", %p", mutex);
        goto <D.13906>;
        <D.13905>:
        monoeg_g_string_append_printf (text, "%p", mutex);
        <D.13906>:
      }
      i = i + 1;
      <D.13289>:
      i.37 = (unsigned int) i;
      thread.36 = thread;
      D.13899 = thread.36->owned_mutexes;
      D.13908 = D.13899->len;
      if (i.37 < D.13908) goto <D.13288>; else goto <D.13290>;
      <D.13290>:
      monoeg_g_string_append_printf (text, ")");
      res = text->str;
      monoeg_g_string_free (text, 0);
      D.13889 = res;
      return D.13889;
    }
  finally
    {
      thread = {CLOBBER};
    }
}


wapi_thread_set_wait_handle (void * handle)
{
  long unsigned int D.13911;
  _Bool D.13912;
  long int D.13913;
  long int D.13914;
  struct _WapiHandle_thread * thread.38;
  void * * D.13918;
  _Bool D.13922;
  long int D.13923;
  long int D.13924;
  gboolean D.13927;
  _Bool D.13928;
  struct _WapiHandle_thread * thread;
  gboolean ok;
  void * prev_handle;
  void * thread_handle;

  try
    {
      D.13911 = GetCurrentThreadId ();
      thread_handle = OpenThread (0, 0, D.13911);
      ok = _wapi_lookup_handle (thread_handle, 3, &thread);
      D.13912 = ok == 0;
      D.13913 = (long int) D.13912;
      D.13914 = __builtin_expect (D.13913, 0);
      if (D.13914 != 0) goto <D.13915>; else goto <D.13916>;
      <D.13915>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "wthreads.c", 1209, "ok");
      <D.13916>:
      thread.38 = thread;
      D.13918 = &thread.38->wait_handle;
      prev_handle = InterlockedCompareExchangePointer (D.13918, handle, 0B);
      _wapi_handle_unref (thread_handle);
      if (prev_handle == 0B) goto <D.13919>; else goto <D.13920>;
      <D.13919>:
      _wapi_handle_ref (handle);
      goto <D.13921>;
      <D.13920>:
      D.13922 = prev_handle != 4294967294B;
      D.13923 = (long int) D.13922;
      D.13924 = __builtin_expect (D.13923, 0);
      if (D.13924 != 0) goto <D.13925>; else goto <D.13926>;
      <D.13925>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "wthreads.c", 1221, "prev_handle == INTERRUPTION_REQUESTED_HANDLE");
      <D.13926>:
      <D.13921>:
      D.13928 = prev_handle == 0B;
      D.13927 = (gboolean) D.13928;
      return D.13927;
    }
  finally
    {
      thread = {CLOBBER};
    }
}


wapi_thread_clear_wait_handle (void * handle)
{
  long unsigned int D.13931;
  _Bool D.13932;
  long int D.13933;
  long int D.13934;
  struct _WapiHandle_thread * thread.39;
  void * * D.13938;
  _Bool D.13942;
  _Bool D.13943;
  _Bool D.13944;
  int D.13945;
  _Bool D.13946;
  long int D.13947;
  long int D.13948;
  struct _WapiHandle_thread * thread;
  gboolean ok;
  void * prev_handle;
  void * thread_handle;

  try
    {
      D.13931 = GetCurrentThreadId ();
      thread_handle = OpenThread (0, 0, D.13931);
      ok = _wapi_lookup_handle (thread_handle, 3, &thread);
      D.13932 = ok == 0;
      D.13933 = (long int) D.13932;
      D.13934 = __builtin_expect (D.13933, 0);
      if (D.13934 != 0) goto <D.13935>; else goto <D.13936>;
      <D.13935>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "wthreads.c", 1243, "ok");
      <D.13936>:
      thread.39 = thread;
      D.13938 = &thread.39->wait_handle;
      prev_handle = InterlockedCompareExchangePointer (D.13938, 0B, handle);
      if (prev_handle == handle) goto <D.13939>; else goto <D.13940>;
      <D.13939>:
      _wapi_handle_unref (handle);
      goto <D.13941>;
      <D.13940>:
      D.13942 = prev_handle != 4294967294B;
      D.13943 = prev_handle != 0B;
      D.13944 = D.13942 & D.13943;
      D.13945 = (int) D.13944;
      D.13946 = D.13945 != 0;
      D.13947 = (long int) D.13946;
      D.13948 = __builtin_expect (D.13947, 0);
      if (D.13948 != 0) goto <D.13949>; else goto <D.13950>;
      <D.13949>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "wthreads.c", 1253, "prev_handle == INTERRUPTION_REQUESTED_HANDLE || prev_handle == NULL");
      <D.13950>:
      <D.13941>:
      _wapi_handle_unref (thread_handle);
    }
  finally
    {
      thread = {CLOBBER};
    }
}


_wapi_thread_own_mutex (void * mutex)
{
  long unsigned int D.13951;
  struct _WapiHandle_thread * thread_handle.40;
  struct GPtrArray * D.13957;
  struct _WapiHandle_thread * thread_handle;
  gboolean ok;
  void * thread;
  static const char __func__[23] = "_wapi_thread_own_mutex";

  try
    {
      D.13951 = pthread_self ();
      thread = _wapi_thread_handle_from_id (D.13951);
      if (thread == 0B) goto <D.13952>; else goto <D.13953>;
      <D.13952>:
      monoeg_g_log (0B, 16, "%s: error looking up thread by ID", &__func__);
      return;
      <D.13953>:
      ok = _wapi_lookup_handle (thread, 3, &thread_handle);
      if (ok == 0) goto <D.13954>; else goto <D.13955>;
      <D.13954>:
      monoeg_g_log (0B, 16, "%s: error looking up thread handle %p", &__func__, thread);
      return;
      <D.13955>:
      _wapi_handle_ref (mutex);
      thread_handle.40 = thread_handle;
      D.13957 = thread_handle.40->owned_mutexes;
      monoeg_g_ptr_array_add (D.13957, mutex);
    }
  finally
    {
      thread_handle = {CLOBBER};
    }
}


_wapi_thread_disown_mutex (void * mutex)
{
  long unsigned int D.13961;
  struct _WapiHandle_thread * thread_handle.41;
  struct GPtrArray * D.13967;
  struct _WapiHandle_thread * thread_handle;
  gboolean ok;
  void * thread;
  static const char __func__[26] = "_wapi_thread_disown_mutex";

  try
    {
      D.13961 = pthread_self ();
      thread = _wapi_thread_handle_from_id (D.13961);
      if (thread == 0B) goto <D.13962>; else goto <D.13963>;
      <D.13962>:
      monoeg_g_log (0B, 16, "%s: error looking up thread by ID", &__func__);
      return;
      <D.13963>:
      ok = _wapi_lookup_handle (thread, 3, &thread_handle);
      if (ok == 0) goto <D.13964>; else goto <D.13965>;
      <D.13964>:
      monoeg_g_log (0B, 16, "%s: error looking up thread handle %p", &__func__, thread);
      return;
      <D.13965>:
      _wapi_handle_unref (mutex);
      thread_handle.41 = thread_handle;
      D.13967 = thread_handle.41->owned_mutexes;
      monoeg_g_ptr_array_remove (D.13967, mutex);
    }
  finally
    {
      thread_handle = {CLOBBER};
    }
}


