_wapi_thread_cleanup ()
{
  unsigned int thread_hash_key.0;
  _Bool D.13465;
  long int D.13466;
  long int D.13467;
  unsigned int thread_attached_key.1;
  int ret;

  thread_hash_key.0 = thread_hash_key;
  ret = pthread_key_delete (thread_hash_key.0);
  D.13465 = ret != 0;
  D.13466 = (long int) D.13465;
  D.13467 = __builtin_expect (D.13466, 0);
  if (D.13467 != 0) goto <D.13468>; else goto <D.13469>;
  <D.13468>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "wthreads.c", 86, "ret == 0");
  <D.13469>:
  thread_attached_key.1 = thread_attached_key;
  ret = pthread_key_delete (thread_attached_key.1);
  D.13465 = ret != 0;
  D.13466 = (long int) D.13465;
  D.13467 = __builtin_expect (D.13466, 0);
  if (D.13467 != 0) goto <D.13471>; else goto <D.13472>;
  <D.13471>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "wthreads.c", 89, "ret == 0");
  <D.13472>:
}


_wapi_thread_set_termination_details (void * handle, guint32 exitstatus)
{
  int D.13475;
  <unnamed type> D.13477;
  long int D.13480;
  long int D.13481;
  _Bool D.13484;
  long int D.13485;
  long int D.13486;
  struct _WapiHandle_thread * thread_handle.2;
  union MonoSemType * D.13490;
  struct GPtrArray * D.13491;
  struct _WapiHandle_thread * thread_handle;
  gboolean ok;
  int thr_ret;
  static const char __func__[37] = "_wapi_thread_set_termination_details";

  try
    {
      D.13475 = _wapi_handle_issignalled (handle);
      if (D.13475 != 0) goto <D.13473>; else goto <D.13476>;
      <D.13476>:
      D.13477 = _wapi_handle_type (handle);
      if (D.13477 == 0) goto <D.13473>; else goto <D.13474>;
      <D.13473>:
      return;
      <D.13474>:
      _wapi_thread_abandon_mutexes (handle);
      ok = _wapi_lookup_handle (handle, 3, &thread_handle);
      if (ok == 0) goto <D.13478>; else goto <D.13479>;
      <D.13478>:
      monoeg_g_log (0B, 16, "%s: error looking up thread handle %p", &__func__, handle);
      return;
      <D.13479>:
      {
        struct __pthread_unwind_buf_t __cancel_buf;
        void (*<Tc6>) (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.13480 = (long int) __not_first_call;
            D.13481 = __builtin_expect (D.13480, 0);
            if (D.13481 != 0) goto <D.13482>; else goto <D.13483>;
            <D.13482>:
            __cancel_routine (__cancel_arg);
            __pthread_unwind_next (&__cancel_buf);
            <D.13483>:
            __pthread_register_cancel (&__cancel_buf);
            thr_ret = _wapi_handle_lock_handle (handle);
            D.13484 = thr_ret != 0;
            D.13485 = (long int) D.13484;
            D.13486 = __builtin_expect (D.13485, 0);
            if (D.13486 != 0) goto <D.13487>; else goto <D.13488>;
            <D.13487>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "wthreads.c", 164, "thr_ret == 0");
            <D.13488>:
            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.13490 = &thread_handle.2->suspend_sem;
            sem_destroy (D.13490);
            thread_handle.2 = thread_handle;
            D.13491 = thread_handle.2->owned_mutexes;
            monoeg_g_ptr_array_free (D.13491, 1);
            _wapi_handle_set_signal_state (handle, 1, 1);
            thr_ret = _wapi_handle_unlock_handle (handle);
            D.13484 = thr_ret != 0;
            D.13485 = (long int) D.13484;
            D.13486 = __builtin_expect (D.13485, 0);
            if (D.13486 != 0) goto <D.13492>; else goto <D.13493>;
            <D.13492>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "wthreads.c", 174, "thr_ret == 0");
            <D.13493>:
            __pthread_unregister_cancel (&__cancel_buf);
            if (0 != 0) goto <D.13494>; else goto <D.13495>;
            <D.13494>:
            __cancel_routine (__cancel_arg);
            <D.13495>:
          }
        finally
          {
            __cancel_buf = {CLOBBER};
          }
      }
      _wapi_handle_unref (handle);
    }
  finally
    {
      thread_handle = {CLOBBER};
    }
}


_wapi_handle_issignalled (void * handle)
{
  long int handle.3;
  gboolean D.13507;
  <unnamed type> D.13510;
  <unnamed type> D.13512;
  <unnamed type> D.13514;
  <unnamed type> D.13516;
  struct _WapiHandleSharedLayout * _wapi_shared_layout.4;
  unsigned int D.13518;
  unsigned int D.13519;
  struct _WapiHandleUnshared * D.13520;
  long unsigned int D.13521;
  long unsigned int D.13522;
  long unsigned int D.13523;
  struct _WapiHandleUnshared * D.13524;
  unsigned int D.13525;
  unsigned int D.13526;
  struct _WapiHandleUnshared * D.13527;
  long unsigned int D.13528;
  long unsigned int D.13529;
  long unsigned int D.13530;
  struct _WapiHandleUnshared * D.13531;
  guint32 idx;

  handle.3 = (long int) handle;
  idx = (guint32) handle.3;
  if (idx > 4194303) goto <D.13505>; else goto <D.13506>;
  <D.13505>:
  D.13507 = 0;
  return D.13507;
  <D.13506>:
  D.13510 = _wapi_handle_type (handle);
  if (D.13510 == 9) goto <D.13508>; else goto <D.13511>;
  <D.13511>:
  D.13512 = _wapi_handle_type (handle);
  if (D.13512 == 11) goto <D.13508>; else goto <D.13513>;
  <D.13513>:
  D.13514 = _wapi_handle_type (handle);
  if (D.13514 == 12) goto <D.13508>; else goto <D.13515>;
  <D.13515>:
  D.13516 = _wapi_handle_type (handle);
  if (D.13516 == 13) goto <D.13508>; else goto <D.13509>;
  <D.13508>:
  _wapi_shared_layout.4 = _wapi_shared_layout;
  handle.3 = (long int) handle;
  D.13518 = (unsigned int) handle.3;
  D.13519 = D.13518 / 256;
  D.13520 = _wapi_private_handles[D.13519];
  handle.3 = (long int) handle;
  D.13518 = (unsigned int) handle.3;
  D.13521 = (long unsigned int) D.13518;
  D.13522 = D.13521 & 255;
  D.13523 = D.13522 * 200;
  D.13524 = D.13520 + D.13523;
  D.13525 = D.13524->u.shared.offset;
  D.13507 = _wapi_shared_layout.4->handles[D.13525].signalled;
  return D.13507;
  <D.13509>:
  D.13526 = idx / 256;
  D.13527 = _wapi_private_handles[D.13526];
  D.13528 = (long unsigned int) idx;
  D.13529 = D.13528 & 255;
  D.13530 = D.13529 * 200;
  D.13531 = D.13527 + D.13530;
  D.13507 = D.13531->signalled;
  return D.13507;
}


_wapi_handle_type (void * handle)
{
  long int handle.5;
  unsigned int D.13538;
  struct _WapiHandleUnshared * D.13539;
  WapiHandleType D.13540;
  unsigned int D.13541;
  struct _WapiHandleUnshared * D.13542;
  long unsigned int D.13543;
  long unsigned int D.13544;
  long unsigned int D.13545;
  struct _WapiHandleUnshared * D.13546;
  guint32 idx;

  handle.5 = (long int) handle;
  idx = (guint32) handle.5;
  if (idx > 4194303) goto <D.13534>; else goto <D.13536>;
  <D.13536>:
  if (idx > 268435455) goto <D.13534>; else goto <D.13537>;
  <D.13537>:
  D.13538 = idx / 256;
  D.13539 = _wapi_private_handles[D.13538];
  if (D.13539 == 0B) goto <D.13534>; else goto <D.13535>;
  <D.13534>:
  D.13540 = 0;
  return D.13540;
  <D.13535>:
  D.13541 = idx / 256;
  D.13542 = _wapi_private_handles[D.13541];
  D.13543 = (long unsigned int) idx;
  D.13544 = D.13543 & 255;
  D.13545 = D.13544 * 200;
  D.13546 = D.13542 + D.13545;
  D.13540 = D.13546->type;
  return D.13540;
}


_wapi_thread_abandon_mutexes (void * handle)
{
  long unsigned int D.13550;
  struct _WapiHandle_thread * thread_handle.6;
  long unsigned int D.13556;
  int D.13557;
  struct GPtrArray * D.13560;
  void * * D.13561;
  long unsigned int D.13562;
  long unsigned int D.13563;
  void * * D.13564;
  unsigned int D.13565;
  unsigned int i.7;
  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.13548>; else goto <D.13549>;
      <D.13548>:
      D.13550 = pthread_self ();
      handle = _wapi_thread_handle_from_id (D.13550);
      if (handle == 0B) goto <D.13551>; else goto <D.13552>;
      <D.13551>:
      return;
      <D.13552>:
      <D.13549>:
      ok = _wapi_lookup_handle (handle, 3, &thread_handle);
      if (ok == 0) goto <D.13553>; else goto <D.13554>;
      <D.13553>:
      monoeg_g_log (0B, 16, "%s: error looking up thread handle %p", &__func__, handle);
      return;
      <D.13554>:
      thread_handle.6 = thread_handle;
      D.13556 = thread_handle.6->id;
      D.13557 = pthread_equal (D.13556, tid);
      if (D.13557 == 0) goto <D.13558>; else goto <D.13559>;
      <D.13558>:
      return;
      <D.13559>:
      i = 0;
      goto <D.13199>;
      <D.13198>:
      {
        void * mutex;

        thread_handle.6 = thread_handle;
        D.13560 = thread_handle.6->owned_mutexes;
        D.13561 = D.13560->pdata;
        D.13562 = (long unsigned int) i;
        D.13563 = D.13562 * 8;
        D.13564 = D.13561 + D.13563;
        mutex = *D.13564;
        _wapi_mutex_abandon (mutex, pid, tid);
        _wapi_thread_disown_mutex (mutex);
      }
      i = i + 1;
      <D.13199>:
      thread_handle.6 = thread_handle;
      D.13560 = thread_handle.6->owned_mutexes;
      D.13565 = D.13560->len;
      i.7 = (unsigned int) i;
      if (D.13565 > i.7) goto <D.13198>; else goto <D.13200>;
      <D.13200>:
    }
  finally
    {
      thread_handle = {CLOBBER};
    }
}


__attribute__((__gnu_inline__, const, __leaf__, __nothrow__))
pthread_equal (pthread_t __thread1, pthread_t __thread2)
{
  int D.13570;
  _Bool D.13571;

  D.13571 = __thread1 == __thread2;
  D.13570 = (int) D.13571;
  return D.13570;
}


_wapi_handle_lock_handle (void * handle)
{
  long int handle.8;
  int D.13576;
  <unnamed type> D.13579;
  <unnamed type> D.13581;
  <unnamed type> D.13583;
  <unnamed type> D.13585;
  unsigned int D.13586;
  struct _WapiHandleUnshared * D.13587;
  long unsigned int D.13588;
  long unsigned int D.13589;
  long unsigned int D.13590;
  struct _WapiHandleUnshared * D.13591;
  union mono_mutex_t * D.13592;
  guint32 idx;

  handle.8 = (long int) handle;
  idx = (guint32) handle.8;
  if (idx > 4194303) goto <D.13574>; else goto <D.13575>;
  <D.13574>:
  D.13576 = 0;
  return D.13576;
  <D.13575>:
  _wapi_handle_ref (handle);
  D.13579 = _wapi_handle_type (handle);
  if (D.13579 == 9) goto <D.13577>; else goto <D.13580>;
  <D.13580>:
  D.13581 = _wapi_handle_type (handle);
  if (D.13581 == 11) goto <D.13577>; else goto <D.13582>;
  <D.13582>:
  D.13583 = _wapi_handle_type (handle);
  if (D.13583 == 12) goto <D.13577>; else goto <D.13584>;
  <D.13584>:
  D.13585 = _wapi_handle_type (handle);
  if (D.13585 == 13) goto <D.13577>; else goto <D.13578>;
  <D.13577>:
  D.13576 = 0;
  return D.13576;
  <D.13578>:
  D.13586 = idx / 256;
  D.13587 = _wapi_private_handles[D.13586];
  D.13588 = (long unsigned int) idx;
  D.13589 = D.13588 & 255;
  D.13590 = D.13589 * 200;
  D.13591 = D.13587 + D.13590;
  D.13592 = &D.13591->signal_mutex;
  D.13576 = pthread_mutex_lock (D.13592);
  return D.13576;
}


_wapi_handle_set_signal_state (void * handle, gboolean state, gboolean broadcast)
{
  long int handle.9;
  int iftmp.10;
  <unnamed type> D.13601;
  <unnamed type> D.13603;
  <unnamed type> D.13605;
  <unnamed type> D.13607;
  _Bool D.13608;
  long int D.13609;
  long int D.13610;
  unsigned int D.13613;
  struct _WapiHandleUnshared * D.13614;
  long unsigned int D.13615;
  long unsigned int D.13616;
  long unsigned int D.13617;
  long int D.13620;
  long int D.13621;
  union mono_mutex_t * _wapi_global_signal_mutex.11;
  _Bool D.13627;
  long int D.13628;
  long int D.13629;
  union pthread_cond_t * D.13634;
  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.13595>; else goto <D.13596>;
  <D.13595>:
  return;
  <D.13596>:
  D.13601 = _wapi_handle_type (handle);
  if (D.13601 == 9) goto <D.13598>; else goto <D.13602>;
  <D.13602>:
  D.13603 = _wapi_handle_type (handle);
  if (D.13603 == 11) goto <D.13598>; else goto <D.13604>;
  <D.13604>:
  D.13605 = _wapi_handle_type (handle);
  if (D.13605 == 12) goto <D.13598>; else goto <D.13606>;
  <D.13606>:
  D.13607 = _wapi_handle_type (handle);
  if (D.13607 == 13) goto <D.13598>; else goto <D.13599>;
  <D.13598>:
  iftmp.10 = 1;
  goto <D.13600>;
  <D.13599>:
  iftmp.10 = 0;
  <D.13600>:
  D.13608 = iftmp.10 != 0;
  D.13609 = (long int) D.13608;
  D.13610 = __builtin_expect (D.13609, 0);
  if (D.13610 != 0) goto <D.13611>; else goto <D.13612>;
  <D.13611>:
  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.13612>:
  D.13613 = idx / 256;
  D.13614 = _wapi_private_handles[D.13613];
  D.13615 = (long unsigned int) idx;
  D.13616 = D.13615 & 255;
  D.13617 = D.13616 * 200;
  handle_data = D.13614 + D.13617;
  if (state == 1) goto <D.13618>; else goto <D.13619>;
  <D.13618>:
  {
    struct __pthread_unwind_buf_t __cancel_buf;
    void (*<Tc6>) (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.13620 = (long int) __not_first_call;
        D.13621 = __builtin_expect (D.13620, 0);
        if (D.13621 != 0) goto <D.13622>; else goto <D.13623>;
        <D.13622>:
        __cancel_routine (__cancel_arg);
        __pthread_unwind_next (&__cancel_buf);
        <D.13623>:
        __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.13625>; else goto <D.13626>;
        <D.13625>:
        monoeg_g_log (0B, 16, "Bad call to mono_mutex_lock result %d for global signal mutex", thr_ret);
        <D.13626>:
        D.13627 = thr_ret != 0;
        D.13628 = (long int) D.13627;
        D.13629 = __builtin_expect (D.13628, 0);
        if (D.13629 != 0) goto <D.13630>; else goto <D.13631>;
        <D.13630>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "../../mono/io-layer/handles-private.h", 151, "thr_ret == 0");
        <D.13631>:
        handle_data->signalled = state;
        if (broadcast == 1) goto <D.13632>; else goto <D.13633>;
        <D.13632>:
        D.13634 = &handle_data->signal_cond;
        thr_ret = pthread_cond_broadcast (D.13634);
        if (thr_ret != 0) goto <D.13635>; else goto <D.13636>;
        <D.13635>:
        monoeg_g_log (0B, 16, "Bad call to pthread_cond_broadcast result %d for handle %p", thr_ret, handle);
        <D.13636>:
        D.13627 = thr_ret != 0;
        D.13628 = (long int) D.13627;
        D.13629 = __builtin_expect (D.13628, 0);
        if (D.13629 != 0) goto <D.13637>; else goto <D.13638>;
        <D.13637>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "../../mono/io-layer/handles-private.h", 162, "thr_ret == 0");
        <D.13638>:
        goto <D.13639>;
        <D.13633>:
        D.13634 = &handle_data->signal_cond;
        thr_ret = pthread_cond_signal (D.13634);
        if (thr_ret != 0) goto <D.13640>; else goto <D.13641>;
        <D.13640>:
        monoeg_g_log (0B, 16, "Bad call to pthread_cond_signal result %d for handle %p", thr_ret, handle);
        <D.13641>:
        D.13627 = thr_ret != 0;
        D.13628 = (long int) D.13627;
        D.13629 = __builtin_expect (D.13628, 0);
        if (D.13629 != 0) goto <D.13642>; else goto <D.13643>;
        <D.13642>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "../../mono/io-layer/handles-private.h", 167, "thr_ret == 0");
        <D.13643>:
        <D.13639>:
        _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.13645>; else goto <D.13646>;
        <D.13645>:
        monoeg_g_log (0B, 16, "Bad call to pthread_cond_broadcast result %d for handle %p", thr_ret, handle);
        <D.13646>:
        D.13627 = thr_ret != 0;
        D.13628 = (long int) D.13627;
        D.13629 = __builtin_expect (D.13628, 0);
        if (D.13629 != 0) goto <D.13647>; else goto <D.13648>;
        <D.13647>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "../../mono/io-layer/handles-private.h", 176, "thr_ret == 0");
        <D.13648>:
        _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.13649>; else goto <D.13650>;
        <D.13649>:
        monoeg_g_log (0B, 16, "Bad call to mono_mutex_unlock result %d for global signal mutex", thr_ret);
        <D.13650>:
        D.13627 = thr_ret != 0;
        D.13628 = (long int) D.13627;
        D.13629 = __builtin_expect (D.13628, 0);
        if (D.13629 != 0) goto <D.13651>; else goto <D.13652>;
        <D.13651>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "../../mono/io-layer/handles-private.h", 181, "thr_ret == 0");
        <D.13652>:
        __pthread_unregister_cancel (&__cancel_buf);
        if (0 != 0) goto <D.13653>; else goto <D.13654>;
        <D.13653>:
        __cancel_routine (__cancel_arg);
        <D.13654>:
      }
    finally
      {
        __cancel_buf = {CLOBBER};
      }
  }
  goto <D.13655>;
  <D.13619>:
  handle_data->signalled = state;
  <D.13655>:
}


__attribute__((__unused__))
mono_mutex_unlock_in_cleanup (union mono_mutex_t * mutex)
{
  int D.13666;

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


_wapi_handle_unlock_handle (void * handle)
{
  long int handle.13;
  int D.13671;
  <unnamed type> D.13674;
  <unnamed type> D.13676;
  <unnamed type> D.13678;
  <unnamed type> D.13680;
  unsigned int D.13681;
  struct _WapiHandleUnshared * D.13682;
  long unsigned int D.13683;
  long unsigned int D.13684;
  long unsigned int D.13685;
  struct _WapiHandleUnshared * D.13686;
  union mono_mutex_t * D.13687;
  guint32 idx;
  int ret;

  handle.13 = (long int) handle;
  idx = (guint32) handle.13;
  if (idx > 4194303) goto <D.13669>; else goto <D.13670>;
  <D.13669>:
  D.13671 = 0;
  return D.13671;
  <D.13670>:
  D.13674 = _wapi_handle_type (handle);
  if (D.13674 == 9) goto <D.13672>; else goto <D.13675>;
  <D.13675>:
  D.13676 = _wapi_handle_type (handle);
  if (D.13676 == 11) goto <D.13672>; else goto <D.13677>;
  <D.13677>:
  D.13678 = _wapi_handle_type (handle);
  if (D.13678 == 12) goto <D.13672>; else goto <D.13679>;
  <D.13679>:
  D.13680 = _wapi_handle_type (handle);
  if (D.13680 == 13) goto <D.13672>; else goto <D.13673>;
  <D.13672>:
  _wapi_handle_unref (handle);
  D.13671 = 0;
  return D.13671;
  <D.13673>:
  D.13681 = idx / 256;
  D.13682 = _wapi_private_handles[D.13681];
  D.13683 = (long unsigned int) idx;
  D.13684 = D.13683 & 255;
  D.13685 = D.13684 * 200;
  D.13686 = D.13682 + D.13685;
  D.13687 = &D.13686->signal_mutex;
  ret = pthread_mutex_unlock (D.13687);
  _wapi_handle_unref (handle);
  D.13671 = ret;
  return D.13671;
}


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

  D.13689 = pthread_self ();
  handle = _wapi_thread_handle_from_id (D.13689);
  if (handle == 0B) goto <D.13690>; else goto <D.13691>;
  <D.13690>:
  return;
  <D.13691>:
  _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.13695;
  struct GPtrArray * D.13696;
  long int D.13699;
  long int D.13700;
  _Bool D.13703;
  long int D.13704;
  long int D.13705;
  long unsigned int D.13716;
  struct _WapiHandle_thread * thread_handle_p.14;
  union MonoSemType * D.13720;
  pthread_t * D.13721;
  char * D.13724;
  long unsigned int D.13727;
  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.13693>; else goto <D.13694>;
      <D.13693>:
      D.13695 = 0B;
      return D.13695;
      <D.13694>:
      thread_handle.state = 0;
      D.13696 = monoeg_g_ptr_array_new ();
      thread_handle.owned_mutexes = D.13696;
      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.13697>; else goto <D.13698>;
      <D.13697>:
      monoeg_g_log (0B, 16, "%s: error creating thread handle", &__func__);
      SetLastError (31);
      D.13695 = 0B;
      return D.13695;
      <D.13698>:
      {
        struct __pthread_unwind_buf_t __cancel_buf;
        void (*<Tc6>) (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.13699 = (long int) __not_first_call;
            D.13700 = __builtin_expect (D.13699, 0);
            if (D.13700 != 0) goto <D.13701>; else goto <D.13702>;
            <D.13701>:
            __cancel_routine (__cancel_arg);
            __pthread_unwind_next (&__cancel_buf);
            <D.13702>:
            __pthread_register_cancel (&__cancel_buf);
            thr_ret = _wapi_handle_lock_handle (handle);
            D.13703 = thr_ret != 0;
            D.13704 = (long int) D.13703;
            D.13705 = __builtin_expect (D.13704, 0);
            if (D.13705 != 0) goto <D.13706>; else goto <D.13707>;
            <D.13706>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "wthreads.c", 360, "thr_ret == 0");
            <D.13707>:
            ok = _wapi_lookup_handle (handle, 3, &thread_handle_p);
            if (ok == 0) goto <D.13708>; else goto <D.13709>;
            <D.13708>:
            monoeg_g_log (0B, 16, "%s: error looking up thread handle %p", &__func__, handle);
            SetLastError (31);
            goto cleanup;
            <D.13709>:
            _wapi_handle_ref (handle);
            thr_ret = pthread_attr_init (&attr);
            D.13703 = thr_ret != 0;
            D.13704 = (long int) D.13703;
            D.13705 = __builtin_expect (D.13704, 0);
            if (D.13705 != 0) goto <D.13710>; else goto <D.13711>;
            <D.13710>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "wthreads.c", 383, "thr_ret == 0");
            <D.13711>:
            if (stacksize == 0) goto <D.13712>; else goto <D.13713>;
            <D.13712>:
            stacksize = 2097152;
            <D.13713>:
            if (stacksize <= 16383) goto <D.13714>; else goto <D.13715>;
            <D.13714>:
            stacksize = 16384;
            <D.13715>:
            D.13716 = (long unsigned int) stacksize;
            thr_ret = pthread_attr_setstacksize (&attr, D.13716);
            D.13703 = thr_ret != 0;
            D.13704 = (long int) D.13703;
            D.13705 = __builtin_expect (D.13704, 0);
            if (D.13705 != 0) goto <D.13717>; else goto <D.13718>;
            <D.13717>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "wthreads.c", 409, "thr_ret == 0");
            <D.13718>:
            thread_handle_p.14 = thread_handle_p;
            D.13720 = &thread_handle_p.14->suspend_sem;
            sem_init (D.13720, 0, 0);
            thread_handle_p.14 = thread_handle_p;
            thread_handle_p.14->handle = handle;
            thread_handle_p.14 = thread_handle_p;
            D.13721 = &thread_handle_p.14->id;
            thread_handle_p.14 = thread_handle_p;
            ret = mono_threads_pthread_create (D.13721, &attr, thread_start_routine, thread_handle_p.14);
            if (ret != 0) goto <D.13722>; else goto <D.13723>;
            <D.13722>:
            D.13724 = strerror (ret);
            monoeg_g_log (0B, 16, "%s: Error creating native thread handle %s (%d)", &__func__, D.13724, ret);
            SetLastError (31);
            unrefs = 2;
            goto cleanup;
            <D.13723>:
            ct_ret = handle;
            if (tid != 0B) goto <D.13725>; else goto <D.13726>;
            <D.13725>:
            thread_handle_p.14 = thread_handle_p;
            D.13727 = thread_handle_p.14->id;
            *tid = D.13727;
            <D.13726>:
            cleanup:
            thr_ret = _wapi_handle_unlock_handle (handle);
            D.13703 = thr_ret != 0;
            D.13704 = (long int) D.13703;
            D.13705 = __builtin_expect (D.13704, 0);
            if (D.13705 != 0) goto <D.13728>; else goto <D.13729>;
            <D.13728>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "wthreads.c", 448, "thr_ret == 0");
            <D.13729>:
            __pthread_unregister_cancel (&__cancel_buf);
            if (0 != 0) goto <D.13730>; else goto <D.13731>;
            <D.13730>:
            __cancel_routine (__cancel_arg);
            <D.13731>:
          }
        finally
          {
            __cancel_buf = {CLOBBER};
          }
      }
      i = 0;
      goto <D.13276>;
      <D.13275>:
      _wapi_handle_unref (handle);
      i = i + 1;
      <D.13276>:
      if (i < unrefs) goto <D.13275>; else goto <D.13277>;
      <D.13277>:
      D.13695 = ct_ret;
      return D.13695;
    }
  finally
    {
      thread_handle = {CLOBBER};
      thread_handle_p = {CLOBBER};
      attr = {CLOBBER};
    }
}


__attribute__((__noreturn__))
thread_start_routine (void * args)
{
  unsigned int D.13740;
  unsigned int D.13741;
  long unsigned int D.13744;
  _Bool D.13745;
  long int D.13746;
  long int D.13747;
  unsigned int thread_hash_key.15;
  void * D.13751;
  unsigned int D.13754;
  guint32 (*<T1768>) (void *) D.13757;
  void * D.13758;
  unsigned int D.13759;
  struct _WapiHandle_thread * thread;
  int thr_ret;

  thread = args;
  D.13740 = thread->create_flags;
  D.13741 = D.13740 & 268435456;
  if (D.13741 == 0) goto <D.13742>; else goto <D.13743>;
  <D.13742>:
  D.13744 = pthread_self ();
  thr_ret = mono_gc_pthread_detach (D.13744);
  D.13745 = thr_ret != 0;
  D.13746 = (long int) D.13745;
  D.13747 = __builtin_expect (D.13746, 0);
  if (D.13747 != 0) goto <D.13748>; else goto <D.13749>;
  <D.13748>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "wthreads.c", 259, "thr_ret == 0");
  <D.13749>:
  <D.13743>:
  thread_hash_key.15 = thread_hash_key;
  D.13751 = thread->handle;
  thr_ret = pthread_setspecific (thread_hash_key.15, D.13751);
  if (thr_ret != 0) goto <D.13752>; else goto <D.13753>;
  <D.13752>:
  mono_gc_pthread_exit (0B);
  <D.13753>:
  D.13744 = pthread_self ();
  thread->id = D.13744;
  D.13740 = thread->create_flags;
  D.13754 = D.13740 & 4;
  if (D.13754 != 0) goto <D.13755>; else goto <D.13756>;
  <D.13755>:
  _wapi_thread_suspend (thread);
  <D.13756>:
  D.13757 = thread->start_routine;
  D.13758 = thread->start_arg;
  D.13759 = D.13757 (D.13758);
  D.13751 = thread->handle;
  thread_exit (D.13759, D.13751);
}


_wapi_thread_suspend (struct _WapiHandle_thread * thread)
{
  long unsigned int D.13760;
  long unsigned int D.13761;
  int D.13762;
  _Bool D.13763;
  long int D.13764;
  long int D.13765;
  union MonoSemType * D.13768;
  int D.13769;
  int * D.13771;
  int D.13772;

  D.13760 = thread->id;
  D.13761 = pthread_self ();
  D.13762 = pthread_equal (D.13760, D.13761);
  D.13763 = D.13762 == 0;
  D.13764 = (long int) D.13763;
  D.13765 = __builtin_expect (D.13764, 0);
  if (D.13765 != 0) goto <D.13766>; else goto <D.13767>;
  <D.13766>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "wthreads.c", 240, "pthread_equal (thread->id, pthread_self ())");
  <D.13767>:
  goto <D.13237>;
  <D.13236>:
  <D.13237>:
  D.13768 = &thread->suspend_sem;
  D.13769 = mono_sem_wait (D.13768, 0);
  if (D.13769 != 0) goto <D.13770>; else goto <D.13238>;
  <D.13770>:
  D.13771 = __errno_location ();
  D.13772 = *D.13771;
  if (D.13772 == 4) goto <D.13236>; else goto <D.13238>;
  <D.13238>:
}


__attribute__((__noreturn__))
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.13773;
  long int D.13774;
  long int D.13775;
  int thr_ret;

  thr_ret = pthread_key_create (&thread_hash_key, 0B);
  D.13773 = thr_ret != 0;
  D.13774 = (long int) D.13773;
  D.13775 = __builtin_expect (D.13774, 0);
  if (D.13775 != 0) goto <D.13776>; else goto <D.13777>;
  <D.13776>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "wthreads.c", 231, "thr_ret == 0");
  <D.13777>:
  thr_ret = pthread_key_create (&thread_attached_key, thread_attached_exit);
  D.13773 = thr_ret != 0;
  D.13774 = (long int) D.13773;
  D.13775 = __builtin_expect (D.13774, 0);
  if (D.13775 != 0) goto <D.13778>; else goto <D.13779>;
  <D.13778>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "wthreads.c", 235, "thr_ret == 0");
  <D.13779>:
}


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


_wapi_thread_handle_from_id (pthread_t tid)
{
  long unsigned int D.13780;
  int D.13781;
  unsigned int thread_hash_key.16;
  void * D.13787;
  void * ret;

  D.13780 = pthread_self ();
  D.13781 = pthread_equal (tid, D.13780);
  if (D.13781 != 0) goto <D.13782>; else goto <D.13783>;
  <D.13782>:
  thread_hash_key.16 = thread_hash_key;
  ret = pthread_getspecific (thread_hash_key.16);
  if (ret != 0B) goto <D.13785>; else goto <D.13786>;
  <D.13785>:
  D.13787 = ret;
  return D.13787;
  <D.13786>:
  <D.13783>:
  D.13787 = 0B;
  return D.13787;
}


OpenThread (guint32 access, gboolean inherit, gsize tid)
{
  void * tid.17;
  void * D.13793;
  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.13789>; else goto <D.13790>;
  <D.13789>:
  tid.17 = (void *) tid;
  ret = _wapi_search_handle (3, find_thread_by_id, tid.17, 0B, 0);
  goto <D.13792>;
  <D.13790>:
  _wapi_handle_ref (ret);
  <D.13792>:
  D.13793 = ret;
  return D.13793;
}


find_thread_by_id (void * handle, void * user_data)
{
  int D.13795;
  gboolean D.13800;
  struct _WapiHandle_thread * thread_handle.18;
  long unsigned int D.13802;
  int D.13803;
  pthread_t tid;
  struct _WapiHandle_thread * thread_handle;
  gboolean ok;

  try
    {
      tid = (pthread_t) user_data;
      D.13795 = _wapi_handle_issignalled (handle);
      if (D.13795 == 0) goto <D.13796>; else goto <D.13797>;
      <D.13796>:
      ok = _wapi_lookup_handle (handle, 3, &thread_handle);
      if (ok == 0) goto <D.13798>; else goto <D.13799>;
      <D.13798>:
      D.13800 = 0;
      return D.13800;
      <D.13799>:
      thread_handle.18 = thread_handle;
      D.13802 = thread_handle.18->id;
      D.13803 = pthread_equal (D.13802, tid);
      if (D.13803 != 0) goto <D.13804>; else goto <D.13805>;
      <D.13804>:
      D.13800 = 1;
      return D.13800;
      <D.13805>:
      <D.13797>:
      D.13800 = 0;
      return D.13800;
    }
  finally
    {
      thread_handle = {CLOBBER};
    }
}


__attribute__((__noreturn__))
ExitThread (guint32 exitcode)
{
  long unsigned int D.13808;
  void * thread;

  D.13808 = pthread_self ();
  thread = _wapi_thread_handle_from_id (D.13808);
  if (thread != 0B) goto <D.13809>; else goto <D.13810>;
  <D.13809>:
  thread_exit (exitcode, thread);
  <D.13810>:
  mono_gc_pthread_exit (0B);
}


GetExitCodeThread (void * handle, guint32 * exitcode)
{
  gboolean D.13813;
  struct _WapiHandle_thread * thread_handle.19;
  long unsigned int D.13817;
  long unsigned int D.13818;
  unsigned int D.13821;
  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.13811>; else goto <D.13812>;
      <D.13811>:
      monoeg_g_log (0B, 16, "%s: error looking up thread handle %p", &__func__, handle);
      D.13813 = 0;
      return D.13813;
      <D.13812>:
      if (exitcode == 0B) goto <D.13814>; else goto <D.13815>;
      <D.13814>:
      D.13813 = 0;
      return D.13813;
      <D.13815>:
      thread_handle.19 = thread_handle;
      D.13817 = BIT_FIELD_REF <*thread_handle.19, 64, 0>;
      D.13818 = D.13817 & 3221225472;
      if (D.13818 != 1073741824) goto <D.13819>; else goto <D.13820>;
      <D.13819>:
      *exitcode = 259;
      D.13813 = 1;
      return D.13813;
      <D.13820>:
      thread_handle.19 = thread_handle;
      D.13821 = thread_handle.19->exitstatus;
      *exitcode = D.13821;
      D.13813 = 1;
      return D.13813;
    }
  finally
    {
      thread_handle = {CLOBBER};
    }
}


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

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


_wapi_thread_duplicate ()
{
  long unsigned int D.13826;
  void * D.13830;
  void * ret;

  ret = 0B;
  mono_once (&thread_hash_once, thread_hash_init);
  mono_once (&thread_ops_once, thread_ops_init);
  D.13826 = pthread_self ();
  ret = _wapi_thread_handle_from_id (D.13826);
  if (ret == 0B) goto <D.13827>; else goto <D.13828>;
  <D.13827>:
  ret = thread_attach (0B);
  goto <D.13829>;
  <D.13828>:
  _wapi_handle_ref (ret);
  <D.13829>:
  D.13830 = ret;
  return D.13830;
}


thread_attach (gsize * tid)
{
  struct GPtrArray * D.13832;
  void * D.13835;
  long int D.13836;
  long int D.13837;
  _Bool D.13840;
  long int D.13841;
  long int D.13842;
  struct _WapiHandle_thread * thread_handle_p.20;
  union MonoSemType * D.13848;
  long unsigned int D.13849;
  unsigned int thread_hash_key.21;
  unsigned int thread_attached_key.22;
  long unsigned int D.13858;
  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.13832 = monoeg_g_ptr_array_new ();
      thread_handle.owned_mutexes = D.13832;
      handle = _wapi_handle_new (3, &thread_handle);
      if (handle == -1B) goto <D.13833>; else goto <D.13834>;
      <D.13833>:
      monoeg_g_log (0B, 16, "%s: error creating thread handle", &__func__);
      SetLastError (31);
      D.13835 = 0B;
      return D.13835;
      <D.13834>:
      {
        struct __pthread_unwind_buf_t __cancel_buf;
        void (*<Tc6>) (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.13836 = (long int) __not_first_call;
            D.13837 = __builtin_expect (D.13836, 0);
            if (D.13837 != 0) goto <D.13838>; else goto <D.13839>;
            <D.13838>:
            __cancel_routine (__cancel_arg);
            __pthread_unwind_next (&__cancel_buf);
            <D.13839>:
            __pthread_register_cancel (&__cancel_buf);
            thr_ret = _wapi_handle_lock_handle (handle);
            D.13840 = thr_ret != 0;
            D.13841 = (long int) D.13840;
            D.13842 = __builtin_expect (D.13841, 0);
            if (D.13842 != 0) goto <D.13843>; else goto <D.13844>;
            <D.13843>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "wthreads.c", 663, "thr_ret == 0");
            <D.13844>:
            ok = _wapi_lookup_handle (handle, 3, &thread_handle_p);
            if (ok == 0) goto <D.13845>; else goto <D.13846>;
            <D.13845>:
            monoeg_g_log (0B, 16, "%s: error looking up thread handle %p", &__func__, handle);
            SetLastError (31);
            goto cleanup;
            <D.13846>:
            _wapi_handle_ref (handle);
            thread_handle_p.20 = thread_handle_p;
            D.13848 = &thread_handle_p.20->suspend_sem;
            sem_init (D.13848, 0, 0);
            thread_handle_p.20 = thread_handle_p;
            thread_handle_p.20->handle = handle;
            thread_handle_p.20 = thread_handle_p;
            D.13849 = pthread_self ();
            thread_handle_p.20->id = D.13849;
            thread_hash_key.21 = thread_hash_key;
            thr_ret = pthread_setspecific (thread_hash_key.21, handle);
            D.13840 = thr_ret != 0;
            D.13841 = (long int) D.13840;
            D.13842 = __builtin_expect (D.13841, 0);
            if (D.13842 != 0) goto <D.13851>; else goto <D.13852>;
            <D.13851>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "wthreads.c", 688, "thr_ret == 0");
            <D.13852>:
            thread_attached_key.22 = thread_attached_key;
            thr_ret = pthread_setspecific (thread_attached_key.22, handle);
            D.13840 = thr_ret != 0;
            D.13841 = (long int) D.13840;
            D.13842 = __builtin_expect (D.13841, 0);
            if (D.13842 != 0) goto <D.13854>; else goto <D.13855>;
            <D.13854>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "wthreads.c", 691, "thr_ret == 0");
            <D.13855>:
            if (tid != 0B) goto <D.13856>; else goto <D.13857>;
            <D.13856>:
            thread_handle_p.20 = thread_handle_p;
            D.13858 = thread_handle_p.20->id;
            *tid = D.13858;
            <D.13857>:
            cleanup:
            thr_ret = _wapi_handle_unlock_handle (handle);
            D.13840 = thr_ret != 0;
            D.13841 = (long int) D.13840;
            D.13842 = __builtin_expect (D.13841, 0);
            if (D.13842 != 0) goto <D.13859>; else goto <D.13860>;
            <D.13859>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "wthreads.c", 710, "thr_ret == 0");
            <D.13860>:
            __pthread_unregister_cancel (&__cancel_buf);
            if (0 != 0) goto <D.13861>; else goto <D.13862>;
            <D.13861>:
            __cancel_routine (__cancel_arg);
            <D.13862>:
          }
        finally
          {
            __cancel_buf = {CLOBBER};
          }
      }
      D.13835 = handle;
      return D.13835;
    }
  finally
    {
      thread_handle = {CLOBBER};
      thread_handle_p = {CLOBBER};
    }
}


GetCurrentThread ()
{
  void * D.13870;

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


ResumeThread (void * handle)
{
  guint32 D.13874;
  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.13872>; else goto <D.13873>;
      <D.13872>:
      monoeg_g_log (0B, 16, "%s: error looking up thread handle %p", &__func__, handle);
      D.13874 = 4294967295;
      return D.13874;
      <D.13873>:
      thread_handle.23 = thread_handle;
      _wapi_thread_resume (thread_handle.23);
      D.13874 = 4294967295;
      return D.13874;
    }
  finally
    {
      thread_handle = {CLOBBER};
    }
}


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

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


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

  D.13879 = 4294967295;
  return D.13879;
}


SleepEx (guint32 ms, gboolean alertable)
{
  long unsigned int D.13883;
  guint32 D.13886;
  int D.13887;
  unsigned int D.13892;
  unsigned int D.13893;
  long int D.13894;
  int D.13895;
  long int D.13896;
  int D.13899;
  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.13881>; else goto <D.13882>;
      <D.13881>:
      D.13883 = pthread_self ();
      current_thread = _wapi_thread_handle_from_id (D.13883);
      if (current_thread == 0B) goto <D.13884>; else goto <D.13885>;
      <D.13884>:
      SetLastError (6);
      D.13886 = 4294967295;
      return D.13886;
      <D.13885>:
      D.13887 = _wapi_thread_apc_pending (current_thread);
      if (D.13887 != 0) goto <D.13888>; else goto <D.13889>;
      <D.13888>:
      _wapi_thread_dispatch_apc_queue (current_thread);
      D.13886 = 192;
      return D.13886;
      <D.13889>:
      <D.13882>:
      if (ms == 0) goto <D.13890>; else goto <D.13891>;
      <D.13890>:
      sched_yield ();
      D.13886 = 0;
      return D.13886;
      <D.13891>:
      D.13892 = ms / 1000;
      ms_quot = (int) D.13892;
      D.13893 = ms % 1000;
      ms_rem = (int) D.13893;
      D.13894 = (long int) ms_quot;
      req.tv_sec = D.13894;
      D.13895 = ms_rem * 1000000;
      D.13896 = (long int) D.13895;
      req.tv_nsec = D.13896;
      again:
      memset (&rem, 0, 16);
      ret = nanosleep (&req, &rem);
      if (alertable != 0) goto <D.13897>; else goto <D.13898>;
      <D.13897>:
      D.13899 = _wapi_thread_apc_pending (current_thread);
      if (D.13899 != 0) goto <D.13900>; else goto <D.13901>;
      <D.13900>:
      _wapi_thread_dispatch_apc_queue (current_thread);
      D.13886 = 192;
      return D.13886;
      <D.13901>:
      <D.13898>:
      if (ret == -1) goto <D.13902>; else goto <D.13903>;
      <D.13902>:
      req = rem;
      goto again;
      <D.13903>:
      D.13886 = 0;
      return D.13886;
    }
  finally
    {
      req = {CLOBBER};
      rem = {CLOBBER};
    }
}


__attribute__((__artificial__, __gnu_inline__, __always_inline__, __nothrow__, __leaf__))
memset (void * __dest, int __ch, size_t __len)
{
  void * D.13906;
  long unsigned int D.13907;

  D.13907 = __builtin_object_size (__dest, 0);
  D.13906 = __builtin___memset_chk (__dest, __ch, __len, D.13907);
  return D.13906;
}


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


_wapi_thread_cur_apc_pending ()
{
  long unsigned int D.13909;
  gboolean D.13912;
  void * thread;

  D.13909 = pthread_self ();
  thread = _wapi_thread_handle_from_id (D.13909);
  if (thread == 0B) goto <D.13910>; else goto <D.13911>;
  <D.13910>:
  SetLastError (6);
  D.13912 = 0;
  return D.13912;
  <D.13911>:
  D.13912 = _wapi_thread_apc_pending (thread);
  return D.13912;
}


_wapi_thread_apc_pending (void * handle)
{
  gboolean D.13916;
  int iftmp.24;
  struct _WapiHandle_thread * thread.25;
  long unsigned int D.13922;
  long unsigned int D.13923;
  void * D.13925;
  struct _WapiHandle_thread * thread;
  gboolean ok;

  try
    {
      ok = _wapi_lookup_handle (handle, 3, &thread);
      if (ok == 0) goto <D.13914>; else goto <D.13915>;
      <D.13914>:
      D.13916 = 0;
      return D.13916;
      <D.13915>:
      thread.25 = thread;
      D.13922 = BIT_FIELD_REF <*thread.25, 64, 0>;
      D.13923 = D.13922 & 268435456;
      if (D.13923 != 0) goto <D.13918>; else goto <D.13924>;
      <D.13924>:
      thread.25 = thread;
      D.13925 = thread.25->wait_handle;
      if (D.13925 == 4294967294B) goto <D.13918>; else goto <D.13919>;
      <D.13918>:
      iftmp.24 = 1;
      goto <D.13920>;
      <D.13919>:
      iftmp.24 = 0;
      <D.13920>:
      D.13916 = iftmp.24;
      return D.13916;
    }
  finally
    {
      thread = {CLOBBER};
    }
}


_wapi_thread_dispatch_apc_queue (void * handle)
{
  _Bool D.13928;
  long int D.13929;
  long int D.13930;
  struct _WapiHandle_thread * thread.26;
  gboolean D.13934;
  struct _WapiHandle_thread * thread;
  gboolean ok;

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


QueueUserAPC (guint32 (*WapiApcProc) (void *) apc_callback, void * handle, void * param)
{
  guint32 D.13939;
  struct _WapiHandle_thread * thread_handle.27;
  long unsigned int D.13941;
  long unsigned int D.13942;
  _Bool D.13943;
  long int D.13944;
  long int D.13945;
  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.13937>; else goto <D.13938>;
      <D.13937>:
      monoeg_g_log (0B, 16, "%s: error looking up thread handle %p", &__func__, handle);
      D.13939 = 0;
      return D.13939;
      <D.13938>:
      thread_handle.27 = thread_handle;
      D.13941 = thread_handle.27->id;
      D.13942 = GetCurrentThreadId ();
      D.13943 = D.13941 != D.13942;
      D.13944 = (long int) D.13943;
      D.13945 = __builtin_expect (D.13944, 0);
      if (D.13945 != 0) goto <D.13946>; else goto <D.13947>;
      <D.13946>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "wthreads.c", 938, "thread_handle->id == (pthread_t)GetCurrentThreadId ()");
      <D.13947>:
      thread_handle.27 = thread_handle;
      thread_handle.27->has_apc = 1;
      D.13939 = 1;
      return D.13939;
    }
  finally
    {
      thread_handle = {CLOBBER};
    }
}


wapi_interrupt_thread (void * thread_handle)
{
  _Bool D.13950;
  long int D.13951;
  long int D.13952;
  struct _WapiHandle_thread * thread.28;
  void * * D.13956;
  long int wait_handle.29;
  unsigned int D.13963;
  struct _WapiHandleUnshared * D.13964;
  long unsigned int D.13965;
  long unsigned int D.13966;
  long unsigned int D.13967;
  struct _WapiHandleUnshared * D.13968;
  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.13950 = ok == 0;
      D.13951 = (long int) D.13950;
      D.13952 = __builtin_expect (D.13951, 0);
      if (D.13952 != 0) goto <D.13953>; else goto <D.13954>;
      <D.13953>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "wthreads.c", 969, "ok");
      <D.13954>:
      <D.13388>:
      thread.28 = thread;
      wait_handle = thread.28->wait_handle;
      thread.28 = thread;
      D.13956 = &thread.28->wait_handle;
      prev_handle = InterlockedCompareExchangePointer (D.13956, 4294967294B, wait_handle);
      if (prev_handle == 4294967294B) goto <D.13957>; else goto <D.13958>;
      <D.13957>:
      return;
      <D.13958>:
      if (prev_handle == wait_handle) goto <D.13387>; else goto <D.13959>;
      <D.13959>:
      goto <D.13388>;
      <D.13387>:
      if (wait_handle == 0B) goto <D.13960>; else goto <D.13961>;
      <D.13960>:
      return;
      <D.13961>:
      wait_handle.29 = (long int) wait_handle;
      idx = (guint32) wait_handle.29;
      D.13963 = idx / 256;
      D.13964 = _wapi_private_handles[D.13963];
      D.13965 = (long unsigned int) idx;
      D.13966 = D.13965 & 255;
      D.13967 = D.13966 * 200;
      D.13968 = D.13964 + D.13967;
      cond = &D.13968->signal_cond;
      D.13963 = idx / 256;
      D.13964 = _wapi_private_handles[D.13963];
      D.13965 = (long unsigned int) idx;
      D.13966 = D.13965 & 255;
      D.13967 = D.13966 * 200;
      D.13968 = D.13964 + D.13967;
      mutex = &D.13968->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.13972;
  long unsigned int comp.30;
  long unsigned int exch.31;
  long unsigned int D.13975;

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


wapi_prepare_interrupt_thread (void * thread_handle)
{
  _Bool D.13977;
  long int D.13978;
  long int D.13979;
  struct _WapiHandle_thread * thread.32;
  void * * D.13983;
  void * D.13986;
  struct _WapiHandle_thread * thread;
  gboolean ok;
  void * prev_handle;
  void * wait_handle;

  try
    {
      ok = _wapi_lookup_handle (thread_handle, 3, &thread);
      D.13977 = ok == 0;
      D.13978 = (long int) D.13977;
      D.13979 = __builtin_expect (D.13978, 0);
      if (D.13979 != 0) goto <D.13980>; else goto <D.13981>;
      <D.13980>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "wthreads.c", 1023, "ok");
      <D.13981>:
      <D.13397>:
      thread.32 = thread;
      wait_handle = thread.32->wait_handle;
      thread.32 = thread;
      D.13983 = &thread.32->wait_handle;
      prev_handle = InterlockedCompareExchangePointer (D.13983, 4294967294B, wait_handle);
      if (prev_handle == 4294967294B) goto <D.13984>; else goto <D.13985>;
      <D.13984>:
      D.13986 = 0B;
      return D.13986;
      <D.13985>:
      if (prev_handle == wait_handle) goto <D.13396>; else goto <D.13987>;
      <D.13987>:
      goto <D.13397>;
      <D.13396>:
      D.13986 = wait_handle;
      return D.13986;
    }
  finally
    {
      thread = {CLOBBER};
    }
}


wapi_finish_interrupt_thread (void * wait_handle)
{
  long int wait_handle.33;
  unsigned int D.13993;
  struct _WapiHandleUnshared * D.13994;
  long unsigned int D.13995;
  long unsigned int D.13996;
  long unsigned int D.13997;
  struct _WapiHandleUnshared * D.13998;
  union pthread_cond_t * cond;
  union mono_mutex_t * mutex;
  guint32 idx;

  if (wait_handle == 0B) goto <D.13990>; else goto <D.13991>;
  <D.13990>:
  return;
  <D.13991>:
  wait_handle.33 = (long int) wait_handle;
  idx = (guint32) wait_handle.33;
  D.13993 = idx / 256;
  D.13994 = _wapi_private_handles[D.13993];
  D.13995 = (long unsigned int) idx;
  D.13996 = D.13995 & 255;
  D.13997 = D.13996 * 200;
  D.13998 = D.13994 + D.13997;
  cond = &D.13998->signal_cond;
  D.13993 = idx / 256;
  D.13994 = _wapi_private_handles[D.13993];
  D.13995 = (long unsigned int) idx;
  D.13996 = D.13995 & 255;
  D.13997 = D.13996 * 200;
  D.13998 = D.13994 + D.13997;
  mutex = &D.13998->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.14000;
  _Bool D.14001;
  long int D.14002;
  long int D.14003;
  struct _WapiHandle_thread * thread.34;
  void * * D.14007;
  struct _WapiHandle_thread * thread;
  gboolean ok;
  void * prev_handle;
  void * wait_handle;
  void * thread_handle;
  void cleanup = <<< error >>>;

  try
    {
      D.14000 = GetCurrentThreadId ();
      thread_handle = OpenThread (0, 0, D.14000);
      ok = _wapi_lookup_handle (thread_handle, 3, &thread);
      D.14001 = ok == 0;
      D.14002 = (long int) D.14001;
      D.14003 = __builtin_expect (D.14002, 0);
      if (D.14003 != 0) goto <D.14004>; else goto <D.14005>;
      <D.14004>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "wthreads.c", 1095, "ok");
      <D.14005>:
      <D.13414>:
      thread.34 = thread;
      wait_handle = thread.34->wait_handle;
      thread.34 = thread;
      D.14007 = &thread.34->wait_handle;
      prev_handle = InterlockedCompareExchangePointer (D.14007, 4294967294B, wait_handle);
      if (prev_handle == 4294967294B) goto cleanup; else goto <D.14008>;
      <D.14008>:
      if (prev_handle == wait_handle) goto <D.13413>; else goto <D.14009>;
      <D.14009>:
      goto <D.13414>;
      <D.13413>:
      if (wait_handle != 0B) goto <D.14010>; else goto <D.14011>;
      <D.14010>:
      _wapi_handle_unref (wait_handle);
      <D.14011>:
      cleanup:
      _wapi_handle_unref (thread_handle);
    }
  finally
    {
      thread = {CLOBBER};
    }
}


wapi_clear_interruption ()
{
  long unsigned int D.14012;
  _Bool D.14013;
  long int D.14014;
  long int D.14015;
  struct _WapiHandle_thread * thread.35;
  void * * D.14019;
  struct _WapiHandle_thread * thread;
  gboolean ok;
  void * prev_handle;
  void * thread_handle;

  try
    {
      D.14012 = GetCurrentThreadId ();
      thread_handle = OpenThread (0, 0, D.14012);
      ok = _wapi_lookup_handle (thread_handle, 3, &thread);
      D.14013 = ok == 0;
      D.14014 = (long int) D.14013;
      D.14015 = __builtin_expect (D.14014, 0);
      if (D.14015 != 0) goto <D.14016>; else goto <D.14017>;
      <D.14016>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "wthreads.c", 1142, "ok");
      <D.14017>:
      thread.35 = thread;
      D.14019 = &thread.35->wait_handle;
      prev_handle = InterlockedCompareExchangePointer (D.14019, 0B, 4294967294B);
      if (prev_handle == 4294967294B) goto <D.14020>; else goto <D.14021>;
      <D.14020>:
      <D.14021>:
      _wapi_handle_unref (thread_handle);
    }
  finally
    {
      thread = {CLOBBER};
    }
}


wapi_current_thread_desc ()
{
  long unsigned int D.14022;
  char * D.14025;
  struct _WapiHandle_thread * thread.36;
  <unnamed type> D.14033;
  const char * D.14034;
  struct GPtrArray * D.14035;
  void * * D.14036;
  long unsigned int D.14037;
  long unsigned int D.14038;
  void * * D.14039;
  unsigned int D.14043;
  unsigned int i.37;
  struct _WapiHandle_thread * thread;
  int i;
  gboolean ok;
  void * handle;
  void * thread_handle;
  struct GString * text;
  char * res;

  try
    {
      D.14022 = GetCurrentThreadId ();
      thread_handle = OpenThread (0, 0, D.14022);
      ok = _wapi_lookup_handle (thread_handle, 3, &thread);
      if (ok == 0) goto <D.14023>; else goto <D.14024>;
      <D.14023>:
      D.14025 = monoeg_g_strdup_printf ("thread handle %p state : lookup failure", thread_handle);
      return D.14025;
      <D.14024>:
      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.14027>; else goto <D.14028>;
      <D.14027>:
      monoeg_g_string_append_printf (text, "not waiting");
      goto <D.14029>;
      <D.14028>:
      if (handle == 4294967294B) goto <D.14030>; else goto <D.14031>;
      <D.14030>:
      monoeg_g_string_append_printf (text, "interrupted state");
      goto <D.14032>;
      <D.14031>:
      D.14033 = _wapi_handle_type (handle);
      D.14034 = _wapi_handle_typename[D.14033];
      monoeg_g_string_append_printf (text, "waiting on %p : %s ", handle, D.14034);
      <D.14032>:
      <D.14029>:
      monoeg_g_string_append_printf (text, " owns (");
      i = 0;
      goto <D.13433>;
      <D.13432>:
      {
        void * mutex;

        thread.36 = thread;
        D.14035 = thread.36->owned_mutexes;
        D.14036 = D.14035->pdata;
        D.14037 = (long unsigned int) i;
        D.14038 = D.14037 * 8;
        D.14039 = D.14036 + D.14038;
        mutex = *D.14039;
        if (i > 0) goto <D.14040>; else goto <D.14041>;
        <D.14040>:
        monoeg_g_string_append_printf (text, ", %p", mutex);
        goto <D.14042>;
        <D.14041>:
        monoeg_g_string_append_printf (text, "%p", mutex);
        <D.14042>:
      }
      i = i + 1;
      <D.13433>:
      thread.36 = thread;
      D.14035 = thread.36->owned_mutexes;
      D.14043 = D.14035->len;
      i.37 = (unsigned int) i;
      if (D.14043 > i.37) goto <D.13432>; else goto <D.13434>;
      <D.13434>:
      monoeg_g_string_append_printf (text, ")");
      res = text->str;
      monoeg_g_string_free (text, 0);
      D.14025 = res;
      return D.14025;
    }
  finally
    {
      thread = {CLOBBER};
    }
}


wapi_thread_set_wait_handle (void * handle)
{
  long unsigned int D.14047;
  _Bool D.14048;
  long int D.14049;
  long int D.14050;
  struct _WapiHandle_thread * thread.38;
  void * * D.14054;
  _Bool D.14058;
  long int D.14059;
  long int D.14060;
  gboolean D.14063;
  _Bool D.14064;
  struct _WapiHandle_thread * thread;
  gboolean ok;
  void * prev_handle;
  void * thread_handle;

  try
    {
      D.14047 = GetCurrentThreadId ();
      thread_handle = OpenThread (0, 0, D.14047);
      ok = _wapi_lookup_handle (thread_handle, 3, &thread);
      D.14048 = ok == 0;
      D.14049 = (long int) D.14048;
      D.14050 = __builtin_expect (D.14049, 0);
      if (D.14050 != 0) goto <D.14051>; else goto <D.14052>;
      <D.14051>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "wthreads.c", 1209, "ok");
      <D.14052>:
      thread.38 = thread;
      D.14054 = &thread.38->wait_handle;
      prev_handle = InterlockedCompareExchangePointer (D.14054, handle, 0B);
      _wapi_handle_unref (thread_handle);
      if (prev_handle == 0B) goto <D.14055>; else goto <D.14056>;
      <D.14055>:
      _wapi_handle_ref (handle);
      goto <D.14057>;
      <D.14056>:
      D.14058 = prev_handle != 4294967294B;
      D.14059 = (long int) D.14058;
      D.14060 = __builtin_expect (D.14059, 0);
      if (D.14060 != 0) goto <D.14061>; else goto <D.14062>;
      <D.14061>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "wthreads.c", 1221, "prev_handle == INTERRUPTION_REQUESTED_HANDLE");
      <D.14062>:
      <D.14057>:
      D.14064 = prev_handle == 0B;
      D.14063 = (gboolean) D.14064;
      return D.14063;
    }
  finally
    {
      thread = {CLOBBER};
    }
}


wapi_thread_clear_wait_handle (void * handle)
{
  long unsigned int D.14067;
  _Bool D.14068;
  long int D.14069;
  long int D.14070;
  struct _WapiHandle_thread * thread.39;
  void * * D.14074;
  int iftmp.40;
  _Bool D.14083;
  long int D.14084;
  long int D.14085;
  struct _WapiHandle_thread * thread;
  gboolean ok;
  void * prev_handle;
  void * thread_handle;

  try
    {
      D.14067 = GetCurrentThreadId ();
      thread_handle = OpenThread (0, 0, D.14067);
      ok = _wapi_lookup_handle (thread_handle, 3, &thread);
      D.14068 = ok == 0;
      D.14069 = (long int) D.14068;
      D.14070 = __builtin_expect (D.14069, 0);
      if (D.14070 != 0) goto <D.14071>; else goto <D.14072>;
      <D.14071>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "wthreads.c", 1243, "ok");
      <D.14072>:
      thread.39 = thread;
      D.14074 = &thread.39->wait_handle;
      prev_handle = InterlockedCompareExchangePointer (D.14074, 0B, handle);
      if (prev_handle == handle) goto <D.14075>; else goto <D.14076>;
      <D.14075>:
      _wapi_handle_unref (handle);
      goto <D.14077>;
      <D.14076>:
      if (prev_handle != 4294967294B) goto <D.14081>; else goto <D.14079>;
      <D.14081>:
      if (prev_handle != 0B) goto <D.14082>; else goto <D.14079>;
      <D.14082>:
      iftmp.40 = 1;
      goto <D.14080>;
      <D.14079>:
      iftmp.40 = 0;
      <D.14080>:
      D.14083 = iftmp.40 != 0;
      D.14084 = (long int) D.14083;
      D.14085 = __builtin_expect (D.14084, 0);
      if (D.14085 != 0) goto <D.14086>; else goto <D.14087>;
      <D.14086>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "wthreads.c", 1253, "prev_handle == INTERRUPTION_REQUESTED_HANDLE || prev_handle == NULL");
      <D.14087>:
      <D.14077>:
      _wapi_handle_unref (thread_handle);
    }
  finally
    {
      thread = {CLOBBER};
    }
}


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

  try
    {
      D.14088 = pthread_self ();
      thread = _wapi_thread_handle_from_id (D.14088);
      if (thread == 0B) goto <D.14089>; else goto <D.14090>;
      <D.14089>:
      monoeg_g_log (0B, 16, "%s: error looking up thread by ID", &__func__);
      return;
      <D.14090>:
      ok = _wapi_lookup_handle (thread, 3, &thread_handle);
      if (ok == 0) goto <D.14091>; else goto <D.14092>;
      <D.14091>:
      monoeg_g_log (0B, 16, "%s: error looking up thread handle %p", &__func__, thread);
      return;
      <D.14092>:
      _wapi_handle_ref (mutex);
      thread_handle.41 = thread_handle;
      D.14094 = thread_handle.41->owned_mutexes;
      monoeg_g_ptr_array_add (D.14094, mutex);
    }
  finally
    {
      thread_handle = {CLOBBER};
    }
}


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

  try
    {
      D.14098 = pthread_self ();
      thread = _wapi_thread_handle_from_id (D.14098);
      if (thread == 0B) goto <D.14099>; else goto <D.14100>;
      <D.14099>:
      monoeg_g_log (0B, 16, "%s: error looking up thread by ID", &__func__);
      return;
      <D.14100>:
      ok = _wapi_lookup_handle (thread, 3, &thread_handle);
      if (ok == 0) goto <D.14101>; else goto <D.14102>;
      <D.14101>:
      monoeg_g_log (0B, 16, "%s: error looking up thread handle %p", &__func__, thread);
      return;
      <D.14102>:
      _wapi_handle_unref (mutex);
      thread_handle.42 = thread_handle;
      D.14104 = thread_handle.42->owned_mutexes;
      monoeg_g_ptr_array_remove (D.14104, mutex);
    }
  finally
    {
      thread_handle = {CLOBBER};
    }
}


