_wapi_thread_cleanup ()
{
  unsigned int thread_hash_key.0;
  _Bool D.13855;
  long int D.13856;
  long int D.13857;
  unsigned int thread_attached_key.1;
  int ret;

  thread_hash_key.0 = thread_hash_key;
  ret = pthread_key_delete (thread_hash_key.0);
  D.13855 = ret != 0;
  D.13856 = (long int) D.13855;
  D.13857 = __builtin_expect (D.13856, 0);
  if (D.13857 != 0) goto <D.13858>; else goto <D.13859>;
  <D.13858>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "wthreads.c", 86, "ret == 0");
  <D.13859>:
  thread_attached_key.1 = thread_attached_key;
  ret = pthread_key_delete (thread_attached_key.1);
  D.13855 = ret != 0;
  D.13856 = (long int) D.13855;
  D.13857 = __builtin_expect (D.13856, 0);
  if (D.13857 != 0) goto <D.13861>; else goto <D.13862>;
  <D.13861>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "wthreads.c", 89, "ret == 0");
  <D.13862>:
}


_wapi_thread_set_termination_details (void * handle, guint32 exitstatus)
{
  int D.13865;
  <unnamed type> D.13867;
  long int D.13870;
  long int D.13871;
  _Bool D.13874;
  long int D.13875;
  long int D.13876;
  struct _WapiHandle_thread * thread_handle.2;
  union MonoSemType * D.13880;
  struct GPtrArray * D.13881;
  struct _WapiHandle_thread * thread_handle;
  gboolean ok;
  int thr_ret;
  static const char __func__[37] = "_wapi_thread_set_termination_details";

  try
    {
      D.13865 = _wapi_handle_issignalled (handle);
      if (D.13865 != 0) goto <D.13863>; else goto <D.13866>;
      <D.13866>:
      D.13867 = _wapi_handle_type (handle);
      if (D.13867 == 0) goto <D.13863>; else goto <D.13864>;
      <D.13863>:
      return;
      <D.13864>:
      _wapi_thread_abandon_mutexes (handle);
      ok = _wapi_lookup_handle (handle, 3, &thread_handle);
      if (ok == 0) goto <D.13868>; else goto <D.13869>;
      <D.13868>:
      monoeg_g_log (0B, 16, "%s: error looking up thread handle %p", &__func__, handle);
      return;
      <D.13869>:
      {
        struct __pthread_unwind_buf_t __cancel_buf;
        void (*<Tbf>) (void *) __cancel_routine;
        void * __cancel_arg;
        int __not_first_call;

        try
          {
            __cancel_routine = _wapi_handle_unlock_handle;
            __cancel_arg = handle;
            __not_first_call = __sigsetjmp (&__cancel_buf.__cancel_jmp_buf, 0);
            D.13870 = (long int) __not_first_call;
            D.13871 = __builtin_expect (D.13870, 0);
            if (D.13871 != 0) goto <D.13872>; else goto <D.13873>;
            <D.13872>:
            __cancel_routine (__cancel_arg);
            __pthread_unwind_next (&__cancel_buf);
            <D.13873>:
            __pthread_register_cancel (&__cancel_buf);
            thr_ret = _wapi_handle_lock_handle (handle);
            D.13874 = thr_ret != 0;
            D.13875 = (long int) D.13874;
            D.13876 = __builtin_expect (D.13875, 0);
            if (D.13876 != 0) goto <D.13877>; else goto <D.13878>;
            <D.13877>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "wthreads.c", 164, "thr_ret == 0");
            <D.13878>:
            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.13880 = &thread_handle.2->suspend_sem;
            sem_destroy (D.13880);
            thread_handle.2 = thread_handle;
            D.13881 = thread_handle.2->owned_mutexes;
            monoeg_g_ptr_array_free (D.13881, 1);
            _wapi_handle_set_signal_state (handle, 1, 1);
            thr_ret = _wapi_handle_unlock_handle (handle);
            D.13874 = thr_ret != 0;
            D.13875 = (long int) D.13874;
            D.13876 = __builtin_expect (D.13875, 0);
            if (D.13876 != 0) goto <D.13882>; else goto <D.13883>;
            <D.13882>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "wthreads.c", 174, "thr_ret == 0");
            <D.13883>:
            __pthread_unregister_cancel (&__cancel_buf);
            if (0 != 0) goto <D.13884>; else goto <D.13885>;
            <D.13884>:
            __cancel_routine (__cancel_arg);
            <D.13885>:
          }
        finally
          {
            __cancel_buf = {CLOBBER};
          }
      }
      _wapi_handle_unref (handle);
    }
  finally
    {
      thread_handle = {CLOBBER};
    }
}


_wapi_handle_issignalled (void * handle)
{
  long int handle.3;
  gboolean D.13897;
  <unnamed type> D.13900;
  <unnamed type> D.13902;
  <unnamed type> D.13904;
  <unnamed type> D.13906;
  struct _WapiHandleSharedLayout * _wapi_shared_layout.4;
  unsigned int D.13908;
  unsigned int D.13909;
  struct _WapiHandleUnshared * D.13910;
  long unsigned int D.13911;
  long unsigned int D.13912;
  long unsigned int D.13913;
  struct _WapiHandleUnshared * D.13914;
  unsigned int D.13915;
  unsigned int D.13916;
  struct _WapiHandleUnshared * D.13917;
  long unsigned int D.13918;
  long unsigned int D.13919;
  long unsigned int D.13920;
  struct _WapiHandleUnshared * D.13921;
  guint32 idx;

  handle.3 = (long int) handle;
  idx = (guint32) handle.3;
  if (idx > 4194303) goto <D.13895>; else goto <D.13896>;
  <D.13895>:
  D.13897 = 0;
  return D.13897;
  <D.13896>:
  D.13900 = _wapi_handle_type (handle);
  if (D.13900 == 9) goto <D.13898>; else goto <D.13901>;
  <D.13901>:
  D.13902 = _wapi_handle_type (handle);
  if (D.13902 == 11) goto <D.13898>; else goto <D.13903>;
  <D.13903>:
  D.13904 = _wapi_handle_type (handle);
  if (D.13904 == 12) goto <D.13898>; else goto <D.13905>;
  <D.13905>:
  D.13906 = _wapi_handle_type (handle);
  if (D.13906 == 13) goto <D.13898>; else goto <D.13899>;
  <D.13898>:
  _wapi_shared_layout.4 = _wapi_shared_layout;
  handle.3 = (long int) handle;
  D.13908 = (unsigned int) handle.3;
  D.13909 = D.13908 / 256;
  D.13910 = _wapi_private_handles[D.13909];
  handle.3 = (long int) handle;
  D.13908 = (unsigned int) handle.3;
  D.13911 = (long unsigned int) D.13908;
  D.13912 = D.13911 & 255;
  D.13913 = D.13912 * 200;
  D.13914 = D.13910 + D.13913;
  D.13915 = D.13914->u.shared.offset;
  D.13897 = _wapi_shared_layout.4->handles[D.13915].signalled;
  return D.13897;
  <D.13899>:
  D.13916 = idx / 256;
  D.13917 = _wapi_private_handles[D.13916];
  D.13918 = (long unsigned int) idx;
  D.13919 = D.13918 & 255;
  D.13920 = D.13919 * 200;
  D.13921 = D.13917 + D.13920;
  D.13897 = D.13921->signalled;
  return D.13897;
}


_wapi_handle_type (void * handle)
{
  long int handle.5;
  unsigned int D.13928;
  struct _WapiHandleUnshared * D.13929;
  WapiHandleType D.13930;
  unsigned int D.13931;
  struct _WapiHandleUnshared * D.13932;
  long unsigned int D.13933;
  long unsigned int D.13934;
  long unsigned int D.13935;
  struct _WapiHandleUnshared * D.13936;
  guint32 idx;

  handle.5 = (long int) handle;
  idx = (guint32) handle.5;
  if (idx > 4194303) goto <D.13924>; else goto <D.13926>;
  <D.13926>:
  if (idx > 268435455) goto <D.13924>; else goto <D.13927>;
  <D.13927>:
  D.13928 = idx / 256;
  D.13929 = _wapi_private_handles[D.13928];
  if (D.13929 == 0B) goto <D.13924>; else goto <D.13925>;
  <D.13924>:
  D.13930 = 0;
  return D.13930;
  <D.13925>:
  D.13931 = idx / 256;
  D.13932 = _wapi_private_handles[D.13931];
  D.13933 = (long unsigned int) idx;
  D.13934 = D.13933 & 255;
  D.13935 = D.13934 * 200;
  D.13936 = D.13932 + D.13935;
  D.13930 = D.13936->type;
  return D.13930;
}


_wapi_thread_abandon_mutexes (void * handle)
{
  long unsigned int D.13940;
  struct _WapiHandle_thread * thread_handle.6;
  long unsigned int D.13946;
  int D.13947;
  struct GPtrArray * D.13950;
  void * * D.13951;
  long unsigned int D.13952;
  long unsigned int D.13953;
  void * * D.13954;
  unsigned int i.7;
  unsigned int D.13956;
  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.13938>; else goto <D.13939>;
      <D.13938>:
      D.13940 = pthread_self ();
      handle = _wapi_thread_handle_from_id (D.13940);
      if (handle == 0B) goto <D.13941>; else goto <D.13942>;
      <D.13941>:
      return;
      <D.13942>:
      <D.13939>:
      ok = _wapi_lookup_handle (handle, 3, &thread_handle);
      if (ok == 0) goto <D.13943>; else goto <D.13944>;
      <D.13943>:
      monoeg_g_log (0B, 16, "%s: error looking up thread handle %p", &__func__, handle);
      return;
      <D.13944>:
      thread_handle.6 = thread_handle;
      D.13946 = thread_handle.6->id;
      D.13947 = pthread_equal (D.13946, tid);
      if (D.13947 == 0) goto <D.13948>; else goto <D.13949>;
      <D.13948>:
      return;
      <D.13949>:
      i = 0;
      goto <D.13589>;
      <D.13588>:
      {
        void * mutex;

        thread_handle.6 = thread_handle;
        D.13950 = thread_handle.6->owned_mutexes;
        D.13951 = D.13950->pdata;
        D.13952 = (long unsigned int) i;
        D.13953 = D.13952 * 8;
        D.13954 = D.13951 + D.13953;
        mutex = *D.13954;
        _wapi_mutex_abandon (mutex, pid, tid);
        _wapi_thread_disown_mutex (mutex);
      }
      i = i + 1;
      <D.13589>:
      i.7 = (unsigned int) i;
      thread_handle.6 = thread_handle;
      D.13950 = thread_handle.6->owned_mutexes;
      D.13956 = D.13950->len;
      if (i.7 < D.13956) goto <D.13588>; else goto <D.13590>;
      <D.13590>:
    }
  finally
    {
      thread_handle = {CLOBBER};
    }
}


pthread_equal (pthread_t __thread1, pthread_t __thread2)
{
  int D.13960;
  _Bool D.13961;

  D.13961 = __thread1 == __thread2;
  D.13960 = (int) D.13961;
  return D.13960;
}


_wapi_handle_lock_handle (void * handle)
{
  long int handle.8;
  int D.13966;
  <unnamed type> D.13969;
  <unnamed type> D.13971;
  <unnamed type> D.13973;
  <unnamed type> D.13975;
  unsigned int D.13976;
  struct _WapiHandleUnshared * D.13977;
  long unsigned int D.13978;
  long unsigned int D.13979;
  long unsigned int D.13980;
  struct _WapiHandleUnshared * D.13981;
  union mono_mutex_t * D.13982;
  guint32 idx;

  handle.8 = (long int) handle;
  idx = (guint32) handle.8;
  if (idx > 4194303) goto <D.13964>; else goto <D.13965>;
  <D.13964>:
  D.13966 = 0;
  return D.13966;
  <D.13965>:
  _wapi_handle_ref (handle);
  D.13969 = _wapi_handle_type (handle);
  if (D.13969 == 9) goto <D.13967>; else goto <D.13970>;
  <D.13970>:
  D.13971 = _wapi_handle_type (handle);
  if (D.13971 == 11) goto <D.13967>; else goto <D.13972>;
  <D.13972>:
  D.13973 = _wapi_handle_type (handle);
  if (D.13973 == 12) goto <D.13967>; else goto <D.13974>;
  <D.13974>:
  D.13975 = _wapi_handle_type (handle);
  if (D.13975 == 13) goto <D.13967>; else goto <D.13968>;
  <D.13967>:
  D.13966 = 0;
  return D.13966;
  <D.13968>:
  D.13976 = idx / 256;
  D.13977 = _wapi_private_handles[D.13976];
  D.13978 = (long unsigned int) idx;
  D.13979 = D.13978 & 255;
  D.13980 = D.13979 * 200;
  D.13981 = D.13977 + D.13980;
  D.13982 = &D.13981->signal_mutex;
  D.13966 = pthread_mutex_lock (D.13982);
  return D.13966;
}


_wapi_handle_set_signal_state (void * handle, gboolean state, gboolean broadcast)
{
  long int handle.9;
  int iftmp.10;
  <unnamed type> D.13991;
  <unnamed type> D.13993;
  <unnamed type> D.13995;
  <unnamed type> D.13997;
  _Bool D.13998;
  long int D.13999;
  long int D.14000;
  unsigned int D.14003;
  struct _WapiHandleUnshared * D.14004;
  long unsigned int D.14005;
  long unsigned int D.14006;
  long unsigned int D.14007;
  long int D.14010;
  long int D.14011;
  union mono_mutex_t * _wapi_global_signal_mutex.11;
  _Bool D.14017;
  long int D.14018;
  long int D.14019;
  union pthread_cond_t * D.14024;
  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.13985>; else goto <D.13986>;
  <D.13985>:
  return;
  <D.13986>:
  D.13991 = _wapi_handle_type (handle);
  if (D.13991 == 9) goto <D.13988>; else goto <D.13992>;
  <D.13992>:
  D.13993 = _wapi_handle_type (handle);
  if (D.13993 == 11) goto <D.13988>; else goto <D.13994>;
  <D.13994>:
  D.13995 = _wapi_handle_type (handle);
  if (D.13995 == 12) goto <D.13988>; else goto <D.13996>;
  <D.13996>:
  D.13997 = _wapi_handle_type (handle);
  if (D.13997 == 13) goto <D.13988>; else goto <D.13989>;
  <D.13988>:
  iftmp.10 = 1;
  goto <D.13990>;
  <D.13989>:
  iftmp.10 = 0;
  <D.13990>:
  D.13998 = iftmp.10 != 0;
  D.13999 = (long int) D.13998;
  D.14000 = __builtin_expect (D.13999, 0);
  if (D.14000 != 0) goto <D.14001>; else goto <D.14002>;
  <D.14001>:
  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.14002>:
  D.14003 = idx / 256;
  D.14004 = _wapi_private_handles[D.14003];
  D.14005 = (long unsigned int) idx;
  D.14006 = D.14005 & 255;
  D.14007 = D.14006 * 200;
  handle_data = D.14004 + D.14007;
  if (state == 1) goto <D.14008>; else goto <D.14009>;
  <D.14008>:
  {
    struct __pthread_unwind_buf_t __cancel_buf;
    void (*<Tbf>) (void *) __cancel_routine;
    void * __cancel_arg;
    int __not_first_call;

    try
      {
        __cancel_routine = mono_mutex_unlock_in_cleanup;
        __cancel_arg = _wapi_global_signal_mutex;
        __not_first_call = __sigsetjmp (&__cancel_buf.__cancel_jmp_buf, 0);
        D.14010 = (long int) __not_first_call;
        D.14011 = __builtin_expect (D.14010, 0);
        if (D.14011 != 0) goto <D.14012>; else goto <D.14013>;
        <D.14012>:
        __cancel_routine (__cancel_arg);
        __pthread_unwind_next (&__cancel_buf);
        <D.14013>:
        __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.14015>; else goto <D.14016>;
        <D.14015>:
        monoeg_g_log (0B, 16, "Bad call to mono_mutex_lock result %d for global signal mutex", thr_ret);
        <D.14016>:
        D.14017 = thr_ret != 0;
        D.14018 = (long int) D.14017;
        D.14019 = __builtin_expect (D.14018, 0);
        if (D.14019 != 0) goto <D.14020>; else goto <D.14021>;
        <D.14020>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "../../mono/io-layer/handles-private.h", 151, "thr_ret == 0");
        <D.14021>:
        handle_data->signalled = state;
        if (broadcast == 1) goto <D.14022>; else goto <D.14023>;
        <D.14022>:
        D.14024 = &handle_data->signal_cond;
        thr_ret = pthread_cond_broadcast (D.14024);
        if (thr_ret != 0) goto <D.14025>; else goto <D.14026>;
        <D.14025>:
        monoeg_g_log (0B, 16, "Bad call to pthread_cond_broadcast result %d for handle %p", thr_ret, handle);
        <D.14026>:
        D.14017 = thr_ret != 0;
        D.14018 = (long int) D.14017;
        D.14019 = __builtin_expect (D.14018, 0);
        if (D.14019 != 0) goto <D.14027>; else goto <D.14028>;
        <D.14027>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "../../mono/io-layer/handles-private.h", 162, "thr_ret == 0");
        <D.14028>:
        goto <D.14029>;
        <D.14023>:
        D.14024 = &handle_data->signal_cond;
        thr_ret = pthread_cond_signal (D.14024);
        if (thr_ret != 0) goto <D.14030>; else goto <D.14031>;
        <D.14030>:
        monoeg_g_log (0B, 16, "Bad call to pthread_cond_signal result %d for handle %p", thr_ret, handle);
        <D.14031>:
        D.14017 = thr_ret != 0;
        D.14018 = (long int) D.14017;
        D.14019 = __builtin_expect (D.14018, 0);
        if (D.14019 != 0) goto <D.14032>; else goto <D.14033>;
        <D.14032>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "../../mono/io-layer/handles-private.h", 167, "thr_ret == 0");
        <D.14033>:
        <D.14029>:
        _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.14035>; else goto <D.14036>;
        <D.14035>:
        monoeg_g_log (0B, 16, "Bad call to pthread_cond_broadcast result %d for handle %p", thr_ret, handle);
        <D.14036>:
        D.14017 = thr_ret != 0;
        D.14018 = (long int) D.14017;
        D.14019 = __builtin_expect (D.14018, 0);
        if (D.14019 != 0) goto <D.14037>; else goto <D.14038>;
        <D.14037>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "../../mono/io-layer/handles-private.h", 176, "thr_ret == 0");
        <D.14038>:
        _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.14039>; else goto <D.14040>;
        <D.14039>:
        monoeg_g_log (0B, 16, "Bad call to mono_mutex_unlock result %d for global signal mutex", thr_ret);
        <D.14040>:
        D.14017 = thr_ret != 0;
        D.14018 = (long int) D.14017;
        D.14019 = __builtin_expect (D.14018, 0);
        if (D.14019 != 0) goto <D.14041>; else goto <D.14042>;
        <D.14041>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "../../mono/io-layer/handles-private.h", 181, "thr_ret == 0");
        <D.14042>:
        __pthread_unregister_cancel (&__cancel_buf);
        if (0 != 0) goto <D.14043>; else goto <D.14044>;
        <D.14043>:
        __cancel_routine (__cancel_arg);
        <D.14044>:
      }
    finally
      {
        __cancel_buf = {CLOBBER};
      }
  }
  goto <D.14045>;
  <D.14009>:
  handle_data->signalled = state;
  <D.14045>:
}


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

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


_wapi_handle_unlock_handle (void * handle)
{
  long int handle.13;
  int D.14061;
  <unnamed type> D.14064;
  <unnamed type> D.14066;
  <unnamed type> D.14068;
  <unnamed type> D.14070;
  unsigned int D.14071;
  struct _WapiHandleUnshared * D.14072;
  long unsigned int D.14073;
  long unsigned int D.14074;
  long unsigned int D.14075;
  struct _WapiHandleUnshared * D.14076;
  union mono_mutex_t * D.14077;
  guint32 idx;
  int ret;

  handle.13 = (long int) handle;
  idx = (guint32) handle.13;
  if (idx > 4194303) goto <D.14059>; else goto <D.14060>;
  <D.14059>:
  D.14061 = 0;
  return D.14061;
  <D.14060>:
  D.14064 = _wapi_handle_type (handle);
  if (D.14064 == 9) goto <D.14062>; else goto <D.14065>;
  <D.14065>:
  D.14066 = _wapi_handle_type (handle);
  if (D.14066 == 11) goto <D.14062>; else goto <D.14067>;
  <D.14067>:
  D.14068 = _wapi_handle_type (handle);
  if (D.14068 == 12) goto <D.14062>; else goto <D.14069>;
  <D.14069>:
  D.14070 = _wapi_handle_type (handle);
  if (D.14070 == 13) goto <D.14062>; else goto <D.14063>;
  <D.14062>:
  _wapi_handle_unref (handle);
  D.14061 = 0;
  return D.14061;
  <D.14063>:
  D.14071 = idx / 256;
  D.14072 = _wapi_private_handles[D.14071];
  D.14073 = (long unsigned int) idx;
  D.14074 = D.14073 & 255;
  D.14075 = D.14074 * 200;
  D.14076 = D.14072 + D.14075;
  D.14077 = &D.14076->signal_mutex;
  ret = pthread_mutex_unlock (D.14077);
  _wapi_handle_unref (handle);
  D.14061 = ret;
  return D.14061;
}


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

  D.14079 = pthread_self ();
  handle = _wapi_thread_handle_from_id (D.14079);
  if (handle == 0B) goto <D.14080>; else goto <D.14081>;
  <D.14080>:
  return;
  <D.14081>:
  _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.14085;
  struct GPtrArray * D.14086;
  long int D.14089;
  long int D.14090;
  _Bool D.14093;
  long int D.14094;
  long int D.14095;
  long unsigned int D.14106;
  struct _WapiHandle_thread * thread_handle_p.14;
  union MonoSemType * D.14110;
  pthread_t * D.14111;
  char * D.14114;
  long unsigned int D.14117;
  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.14083>; else goto <D.14084>;
      <D.14083>:
      D.14085 = 0B;
      return D.14085;
      <D.14084>:
      thread_handle.state = 0;
      D.14086 = monoeg_g_ptr_array_new ();
      thread_handle.owned_mutexes = D.14086;
      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.14087>; else goto <D.14088>;
      <D.14087>:
      monoeg_g_log (0B, 16, "%s: error creating thread handle", &__func__);
      SetLastError (31);
      D.14085 = 0B;
      return D.14085;
      <D.14088>:
      {
        struct __pthread_unwind_buf_t __cancel_buf;
        void (*<Tbf>) (void *) __cancel_routine;
        void * __cancel_arg;
        int __not_first_call;

        try
          {
            __cancel_routine = _wapi_handle_unlock_handle;
            __cancel_arg = handle;
            __not_first_call = __sigsetjmp (&__cancel_buf.__cancel_jmp_buf, 0);
            D.14089 = (long int) __not_first_call;
            D.14090 = __builtin_expect (D.14089, 0);
            if (D.14090 != 0) goto <D.14091>; else goto <D.14092>;
            <D.14091>:
            __cancel_routine (__cancel_arg);
            __pthread_unwind_next (&__cancel_buf);
            <D.14092>:
            __pthread_register_cancel (&__cancel_buf);
            thr_ret = _wapi_handle_lock_handle (handle);
            D.14093 = thr_ret != 0;
            D.14094 = (long int) D.14093;
            D.14095 = __builtin_expect (D.14094, 0);
            if (D.14095 != 0) goto <D.14096>; else goto <D.14097>;
            <D.14096>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "wthreads.c", 360, "thr_ret == 0");
            <D.14097>:
            ok = _wapi_lookup_handle (handle, 3, &thread_handle_p);
            if (ok == 0) goto <D.14098>; else goto <D.14099>;
            <D.14098>:
            monoeg_g_log (0B, 16, "%s: error looking up thread handle %p", &__func__, handle);
            SetLastError (31);
            goto cleanup;
            <D.14099>:
            _wapi_handle_ref (handle);
            thr_ret = pthread_attr_init (&attr);
            D.14093 = thr_ret != 0;
            D.14094 = (long int) D.14093;
            D.14095 = __builtin_expect (D.14094, 0);
            if (D.14095 != 0) goto <D.14100>; else goto <D.14101>;
            <D.14100>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "wthreads.c", 383, "thr_ret == 0");
            <D.14101>:
            if (stacksize == 0) goto <D.14102>; else goto <D.14103>;
            <D.14102>:
            stacksize = 2097152;
            <D.14103>:
            if (stacksize <= 131071) goto <D.14104>; else goto <D.14105>;
            <D.14104>:
            stacksize = 131072;
            <D.14105>:
            D.14106 = (long unsigned int) stacksize;
            thr_ret = pthread_attr_setstacksize (&attr, D.14106);
            D.14093 = thr_ret != 0;
            D.14094 = (long int) D.14093;
            D.14095 = __builtin_expect (D.14094, 0);
            if (D.14095 != 0) goto <D.14107>; else goto <D.14108>;
            <D.14107>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "wthreads.c", 409, "thr_ret == 0");
            <D.14108>:
            thread_handle_p.14 = thread_handle_p;
            D.14110 = &thread_handle_p.14->suspend_sem;
            sem_init (D.14110, 0, 0);
            thread_handle_p.14 = thread_handle_p;
            thread_handle_p.14->handle = handle;
            thread_handle_p.14 = thread_handle_p;
            D.14111 = &thread_handle_p.14->id;
            thread_handle_p.14 = thread_handle_p;
            ret = mono_threads_pthread_create (D.14111, &attr, thread_start_routine, thread_handle_p.14);
            if (ret != 0) goto <D.14112>; else goto <D.14113>;
            <D.14112>:
            D.14114 = strerror (ret);
            monoeg_g_log (0B, 16, "%s: Error creating native thread handle %s (%d)", &__func__, D.14114, ret);
            SetLastError (31);
            unrefs = 2;
            goto cleanup;
            <D.14113>:
            ct_ret = handle;
            if (tid != 0B) goto <D.14115>; else goto <D.14116>;
            <D.14115>:
            thread_handle_p.14 = thread_handle_p;
            D.14117 = thread_handle_p.14->id;
            *tid = D.14117;
            <D.14116>:
            cleanup:
            thr_ret = _wapi_handle_unlock_handle (handle);
            D.14093 = thr_ret != 0;
            D.14094 = (long int) D.14093;
            D.14095 = __builtin_expect (D.14094, 0);
            if (D.14095 != 0) goto <D.14118>; else goto <D.14119>;
            <D.14118>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "wthreads.c", 448, "thr_ret == 0");
            <D.14119>:
            __pthread_unregister_cancel (&__cancel_buf);
            if (0 != 0) goto <D.14120>; else goto <D.14121>;
            <D.14120>:
            __cancel_routine (__cancel_arg);
            <D.14121>:
          }
        finally
          {
            __cancel_buf = {CLOBBER};
          }
      }
      i = 0;
      goto <D.13666>;
      <D.13665>:
      _wapi_handle_unref (handle);
      i = i + 1;
      <D.13666>:
      if (i < unrefs) goto <D.13665>; else goto <D.13667>;
      <D.13667>:
      D.14085 = ct_ret;
      return D.14085;
    }
  finally
    {
      thread_handle = {CLOBBER};
      thread_handle_p = {CLOBBER};
      attr = {CLOBBER};
    }
}


thread_start_routine (void * args)
{
  unsigned int D.14130;
  unsigned int D.14131;
  long unsigned int D.14134;
  _Bool D.14135;
  long int D.14136;
  long int D.14137;
  unsigned int thread_hash_key.15;
  void * D.14141;
  unsigned int D.14144;
  guint32 (*<T16a2>) (void *) D.14147;
  void * D.14148;
  unsigned int D.14149;
  struct _WapiHandle_thread * thread;
  int thr_ret;

  thread = args;
  D.14130 = thread->create_flags;
  D.14131 = D.14130 & 268435456;
  if (D.14131 == 0) goto <D.14132>; else goto <D.14133>;
  <D.14132>:
  D.14134 = pthread_self ();
  thr_ret = mono_gc_pthread_detach (D.14134);
  D.14135 = thr_ret != 0;
  D.14136 = (long int) D.14135;
  D.14137 = __builtin_expect (D.14136, 0);
  if (D.14137 != 0) goto <D.14138>; else goto <D.14139>;
  <D.14138>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "wthreads.c", 259, "thr_ret == 0");
  <D.14139>:
  <D.14133>:
  thread_hash_key.15 = thread_hash_key;
  D.14141 = thread->handle;
  thr_ret = pthread_setspecific (thread_hash_key.15, D.14141);
  if (thr_ret != 0) goto <D.14142>; else goto <D.14143>;
  <D.14142>:
  mono_gc_pthread_exit (0B);
  <D.14143>:
  D.14134 = pthread_self ();
  thread->id = D.14134;
  D.14130 = thread->create_flags;
  D.14144 = D.14130 & 4;
  if (D.14144 != 0) goto <D.14145>; else goto <D.14146>;
  <D.14145>:
  _wapi_thread_suspend (thread);
  <D.14146>:
  D.14147 = thread->start_routine;
  D.14148 = thread->start_arg;
  D.14149 = D.14147 (D.14148);
  D.14141 = thread->handle;
  thread_exit (D.14149, D.14141);
}


_wapi_thread_suspend (struct _WapiHandle_thread * thread)
{
  long unsigned int D.14150;
  long unsigned int D.14151;
  int D.14152;
  _Bool D.14153;
  long int D.14154;
  long int D.14155;
  union MonoSemType * D.14158;
  int D.14159;
  int * D.14161;
  int D.14162;

  D.14150 = thread->id;
  D.14151 = pthread_self ();
  D.14152 = pthread_equal (D.14150, D.14151);
  D.14153 = D.14152 == 0;
  D.14154 = (long int) D.14153;
  D.14155 = __builtin_expect (D.14154, 0);
  if (D.14155 != 0) goto <D.14156>; else goto <D.14157>;
  <D.14156>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "wthreads.c", 240, "pthread_equal (thread->id, pthread_self ())");
  <D.14157>:
  goto <D.13627>;
  <D.13626>:
  <D.13627>:
  D.14158 = &thread->suspend_sem;
  D.14159 = mono_sem_wait (D.14158, 0);
  if (D.14159 != 0) goto <D.14160>; else goto <D.13628>;
  <D.14160>:
  D.14161 = __errno_location ();
  D.14162 = *D.14161;
  if (D.14162 == 4) goto <D.13626>; else goto <D.13628>;
  <D.13628>:
}


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.14163;
  long int D.14164;
  long int D.14165;
  int thr_ret;

  thr_ret = pthread_key_create (&thread_hash_key, 0B);
  D.14163 = thr_ret != 0;
  D.14164 = (long int) D.14163;
  D.14165 = __builtin_expect (D.14164, 0);
  if (D.14165 != 0) goto <D.14166>; else goto <D.14167>;
  <D.14166>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "wthreads.c", 231, "thr_ret == 0");
  <D.14167>:
  thr_ret = pthread_key_create (&thread_attached_key, thread_attached_exit);
  D.14163 = thr_ret != 0;
  D.14164 = (long int) D.14163;
  D.14165 = __builtin_expect (D.14164, 0);
  if (D.14165 != 0) goto <D.14168>; else goto <D.14169>;
  <D.14168>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "wthreads.c", 235, "thr_ret == 0");
  <D.14169>:
}


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


_wapi_thread_handle_from_id (pthread_t tid)
{
  long unsigned int D.14170;
  int D.14171;
  unsigned int thread_hash_key.16;
  void * D.14177;
  void * ret;

  D.14170 = pthread_self ();
  D.14171 = pthread_equal (tid, D.14170);
  if (D.14171 != 0) goto <D.14172>; else goto <D.14173>;
  <D.14172>:
  thread_hash_key.16 = thread_hash_key;
  ret = pthread_getspecific (thread_hash_key.16);
  if (ret != 0B) goto <D.14175>; else goto <D.14176>;
  <D.14175>:
  D.14177 = ret;
  return D.14177;
  <D.14176>:
  <D.14173>:
  D.14177 = 0B;
  return D.14177;
}


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


find_thread_by_id (void * handle, void * user_data)
{
  int D.14185;
  gboolean D.14190;
  struct _WapiHandle_thread * thread_handle.18;
  long unsigned int D.14192;
  int D.14193;
  pthread_t tid;
  struct _WapiHandle_thread * thread_handle;
  gboolean ok;

  try
    {
      tid = (pthread_t) user_data;
      D.14185 = _wapi_handle_issignalled (handle);
      if (D.14185 == 0) goto <D.14186>; else goto <D.14187>;
      <D.14186>:
      ok = _wapi_lookup_handle (handle, 3, &thread_handle);
      if (ok == 0) goto <D.14188>; else goto <D.14189>;
      <D.14188>:
      D.14190 = 0;
      return D.14190;
      <D.14189>:
      thread_handle.18 = thread_handle;
      D.14192 = thread_handle.18->id;
      D.14193 = pthread_equal (D.14192, tid);
      if (D.14193 != 0) goto <D.14194>; else goto <D.14195>;
      <D.14194>:
      D.14190 = 1;
      return D.14190;
      <D.14195>:
      <D.14187>:
      D.14190 = 0;
      return D.14190;
    }
  finally
    {
      thread_handle = {CLOBBER};
    }
}


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

  D.14198 = pthread_self ();
  thread = _wapi_thread_handle_from_id (D.14198);
  if (thread != 0B) goto <D.14199>; else goto <D.14200>;
  <D.14199>:
  thread_exit (exitcode, thread);
  <D.14200>:
  mono_gc_pthread_exit (0B);
}


GetExitCodeThread (void * handle, guint32 * exitcode)
{
  gboolean D.14203;
  struct _WapiHandle_thread * thread_handle.19;
  long unsigned int D.14207;
  long unsigned int D.14208;
  unsigned int D.14211;
  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.14201>; else goto <D.14202>;
      <D.14201>:
      monoeg_g_log (0B, 16, "%s: error looking up thread handle %p", &__func__, handle);
      D.14203 = 0;
      return D.14203;
      <D.14202>:
      if (exitcode == 0B) goto <D.14204>; else goto <D.14205>;
      <D.14204>:
      D.14203 = 0;
      return D.14203;
      <D.14205>:
      thread_handle.19 = thread_handle;
      D.14207 = BIT_FIELD_REF <*thread_handle.19, 64, 0>;
      D.14208 = D.14207 & 12884901888;
      if (D.14208 != 4294967296) goto <D.14209>; else goto <D.14210>;
      <D.14209>:
      *exitcode = 259;
      D.14203 = 1;
      return D.14203;
      <D.14210>:
      thread_handle.19 = thread_handle;
      D.14211 = thread_handle.19->exitstatus;
      *exitcode = D.14211;
      D.14203 = 1;
      return D.14203;
    }
  finally
    {
      thread_handle = {CLOBBER};
    }
}


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

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


_wapi_thread_duplicate ()
{
  long unsigned int D.14216;
  void * D.14220;
  void * ret;

  ret = 0B;
  mono_once (&thread_hash_once, thread_hash_init);
  mono_once (&thread_ops_once, thread_ops_init);
  D.14216 = pthread_self ();
  ret = _wapi_thread_handle_from_id (D.14216);
  if (ret == 0B) goto <D.14217>; else goto <D.14218>;
  <D.14217>:
  ret = thread_attach (0B);
  goto <D.14219>;
  <D.14218>:
  _wapi_handle_ref (ret);
  <D.14219>:
  D.14220 = ret;
  return D.14220;
}


thread_attach (gsize * tid)
{
  struct GPtrArray * D.14222;
  void * D.14225;
  long int D.14226;
  long int D.14227;
  _Bool D.14230;
  long int D.14231;
  long int D.14232;
  struct _WapiHandle_thread * thread_handle_p.20;
  union MonoSemType * D.14238;
  long unsigned int D.14239;
  unsigned int thread_hash_key.21;
  unsigned int thread_attached_key.22;
  long unsigned int D.14248;
  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.14222 = monoeg_g_ptr_array_new ();
      thread_handle.owned_mutexes = D.14222;
      handle = _wapi_handle_new (3, &thread_handle);
      if (handle == -1B) goto <D.14223>; else goto <D.14224>;
      <D.14223>:
      monoeg_g_log (0B, 16, "%s: error creating thread handle", &__func__);
      SetLastError (31);
      D.14225 = 0B;
      return D.14225;
      <D.14224>:
      {
        struct __pthread_unwind_buf_t __cancel_buf;
        void (*<Tbf>) (void *) __cancel_routine;
        void * __cancel_arg;
        int __not_first_call;

        try
          {
            __cancel_routine = _wapi_handle_unlock_handle;
            __cancel_arg = handle;
            __not_first_call = __sigsetjmp (&__cancel_buf.__cancel_jmp_buf, 0);
            D.14226 = (long int) __not_first_call;
            D.14227 = __builtin_expect (D.14226, 0);
            if (D.14227 != 0) goto <D.14228>; else goto <D.14229>;
            <D.14228>:
            __cancel_routine (__cancel_arg);
            __pthread_unwind_next (&__cancel_buf);
            <D.14229>:
            __pthread_register_cancel (&__cancel_buf);
            thr_ret = _wapi_handle_lock_handle (handle);
            D.14230 = thr_ret != 0;
            D.14231 = (long int) D.14230;
            D.14232 = __builtin_expect (D.14231, 0);
            if (D.14232 != 0) goto <D.14233>; else goto <D.14234>;
            <D.14233>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "wthreads.c", 663, "thr_ret == 0");
            <D.14234>:
            ok = _wapi_lookup_handle (handle, 3, &thread_handle_p);
            if (ok == 0) goto <D.14235>; else goto <D.14236>;
            <D.14235>:
            monoeg_g_log (0B, 16, "%s: error looking up thread handle %p", &__func__, handle);
            SetLastError (31);
            goto cleanup;
            <D.14236>:
            _wapi_handle_ref (handle);
            thread_handle_p.20 = thread_handle_p;
            D.14238 = &thread_handle_p.20->suspend_sem;
            sem_init (D.14238, 0, 0);
            thread_handle_p.20 = thread_handle_p;
            thread_handle_p.20->handle = handle;
            thread_handle_p.20 = thread_handle_p;
            D.14239 = pthread_self ();
            thread_handle_p.20->id = D.14239;
            thread_hash_key.21 = thread_hash_key;
            thr_ret = pthread_setspecific (thread_hash_key.21, handle);
            D.14230 = thr_ret != 0;
            D.14231 = (long int) D.14230;
            D.14232 = __builtin_expect (D.14231, 0);
            if (D.14232 != 0) goto <D.14241>; else goto <D.14242>;
            <D.14241>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "wthreads.c", 688, "thr_ret == 0");
            <D.14242>:
            thread_attached_key.22 = thread_attached_key;
            thr_ret = pthread_setspecific (thread_attached_key.22, handle);
            D.14230 = thr_ret != 0;
            D.14231 = (long int) D.14230;
            D.14232 = __builtin_expect (D.14231, 0);
            if (D.14232 != 0) goto <D.14244>; else goto <D.14245>;
            <D.14244>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "wthreads.c", 691, "thr_ret == 0");
            <D.14245>:
            if (tid != 0B) goto <D.14246>; else goto <D.14247>;
            <D.14246>:
            thread_handle_p.20 = thread_handle_p;
            D.14248 = thread_handle_p.20->id;
            *tid = D.14248;
            <D.14247>:
            cleanup:
            thr_ret = _wapi_handle_unlock_handle (handle);
            D.14230 = thr_ret != 0;
            D.14231 = (long int) D.14230;
            D.14232 = __builtin_expect (D.14231, 0);
            if (D.14232 != 0) goto <D.14249>; else goto <D.14250>;
            <D.14249>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "wthreads.c", 710, "thr_ret == 0");
            <D.14250>:
            __pthread_unregister_cancel (&__cancel_buf);
            if (0 != 0) goto <D.14251>; else goto <D.14252>;
            <D.14251>:
            __cancel_routine (__cancel_arg);
            <D.14252>:
          }
        finally
          {
            __cancel_buf = {CLOBBER};
          }
      }
      D.14225 = handle;
      return D.14225;
    }
  finally
    {
      thread_handle = {CLOBBER};
      thread_handle_p = {CLOBBER};
    }
}


GetCurrentThread ()
{
  void * D.14260;

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


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


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

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


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

  D.14269 = 4294967295;
  return D.14269;
}


SleepEx (guint32 ms, gboolean alertable)
{
  long unsigned int D.14273;
  guint32 D.14276;
  int D.14277;
  unsigned int D.14282;
  unsigned int D.14283;
  long int D.14284;
  int D.14285;
  long int D.14286;
  int D.14289;
  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.14271>; else goto <D.14272>;
      <D.14271>:
      D.14273 = pthread_self ();
      current_thread = _wapi_thread_handle_from_id (D.14273);
      if (current_thread == 0B) goto <D.14274>; else goto <D.14275>;
      <D.14274>:
      SetLastError (6);
      D.14276 = 4294967295;
      return D.14276;
      <D.14275>:
      D.14277 = _wapi_thread_apc_pending (current_thread);
      if (D.14277 != 0) goto <D.14278>; else goto <D.14279>;
      <D.14278>:
      _wapi_thread_dispatch_apc_queue (current_thread);
      D.14276 = 192;
      return D.14276;
      <D.14279>:
      <D.14272>:
      if (ms == 0) goto <D.14280>; else goto <D.14281>;
      <D.14280>:
      sched_yield ();
      D.14276 = 0;
      return D.14276;
      <D.14281>:
      D.14282 = ms / 1000;
      ms_quot = (int) D.14282;
      D.14283 = ms % 1000;
      ms_rem = (int) D.14283;
      D.14284 = (long int) ms_quot;
      req.tv_sec = D.14284;
      D.14285 = ms_rem * 1000000;
      D.14286 = (long int) D.14285;
      req.tv_nsec = D.14286;
      again:
      memset (&rem, 0, 16);
      ret = nanosleep (&req, &rem);
      if (alertable != 0) goto <D.14287>; else goto <D.14288>;
      <D.14287>:
      D.14289 = _wapi_thread_apc_pending (current_thread);
      if (D.14289 != 0) goto <D.14290>; else goto <D.14291>;
      <D.14290>:
      _wapi_thread_dispatch_apc_queue (current_thread);
      D.14276 = 192;
      return D.14276;
      <D.14291>:
      <D.14288>:
      if (ret == -1) goto <D.14292>; else goto <D.14293>;
      <D.14292>:
      req = rem;
      goto again;
      <D.14293>:
      D.14276 = 0;
      return D.14276;
    }
  finally
    {
      req = {CLOBBER};
      rem = {CLOBBER};
    }
}


memset (void * __dest, int __ch, size_t __len)
{
  int D.14298;
  int D.14303;
  void * D.14305;
  long unsigned int D.14306;

  D.14298 = __builtin_constant_p (__len);
  if (D.14298 != 0) goto <D.14299>; else goto <D.14300>;
  <D.14299>:
  if (__len == 0) goto <D.14301>; else goto <D.14302>;
  <D.14301>:
  D.14303 = __builtin_constant_p (__ch);
  if (D.14303 == 0) goto <D.14296>; else goto <D.14304>;
  <D.14304>:
  if (__ch != 0) goto <D.14296>; else goto <D.14297>;
  <D.14296>:
  __warn_memset_zero_len ();
  D.14305 = __dest;
  return D.14305;
  <D.14297>:
  <D.14302>:
  <D.14300>:
  D.14306 = __builtin_object_size (__dest, 0);
  D.14305 = __builtin___memset_chk (__dest, __ch, __len, D.14306);
  return D.14305;
}


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


_wapi_thread_cur_apc_pending ()
{
  long unsigned int D.14308;
  gboolean D.14311;
  void * thread;

  D.14308 = pthread_self ();
  thread = _wapi_thread_handle_from_id (D.14308);
  if (thread == 0B) goto <D.14309>; else goto <D.14310>;
  <D.14309>:
  SetLastError (6);
  D.14311 = 0;
  return D.14311;
  <D.14310>:
  D.14311 = _wapi_thread_apc_pending (thread);
  return D.14311;
}


_wapi_thread_apc_pending (void * handle)
{
  gboolean D.14315;
  int iftmp.24;
  struct _WapiHandle_thread * thread.25;
  long unsigned int D.14321;
  long unsigned int D.14322;
  void * D.14324;
  struct _WapiHandle_thread * thread;
  gboolean ok;

  try
    {
      ok = _wapi_lookup_handle (handle, 3, &thread);
      if (ok == 0) goto <D.14313>; else goto <D.14314>;
      <D.14313>:
      D.14315 = 0;
      return D.14315;
      <D.14314>:
      thread.25 = thread;
      D.14321 = BIT_FIELD_REF <*thread.25, 64, 0>;
      D.14322 = D.14321 & 34359738368;
      if (D.14322 != 0) goto <D.14317>; else goto <D.14323>;
      <D.14323>:
      thread.25 = thread;
      D.14324 = thread.25->wait_handle;
      if (D.14324 == 4294967294B) goto <D.14317>; else goto <D.14318>;
      <D.14317>:
      iftmp.24 = 1;
      goto <D.14319>;
      <D.14318>:
      iftmp.24 = 0;
      <D.14319>:
      D.14315 = iftmp.24;
      return D.14315;
    }
  finally
    {
      thread = {CLOBBER};
    }
}


_wapi_thread_dispatch_apc_queue (void * handle)
{
  _Bool D.14327;
  long int D.14328;
  long int D.14329;
  struct _WapiHandle_thread * thread.26;
  gboolean D.14333;
  struct _WapiHandle_thread * thread;
  gboolean ok;

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


QueueUserAPC (guint32 (*WapiApcProc) (void *) apc_callback, void * handle, void * param)
{
  guint32 D.14338;
  struct _WapiHandle_thread * thread_handle.27;
  long unsigned int D.14340;
  long unsigned int D.14341;
  _Bool D.14342;
  long int D.14343;
  long int D.14344;
  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.14336>; else goto <D.14337>;
      <D.14336>:
      monoeg_g_log (0B, 16, "%s: error looking up thread handle %p", &__func__, handle);
      D.14338 = 0;
      return D.14338;
      <D.14337>:
      thread_handle.27 = thread_handle;
      D.14340 = thread_handle.27->id;
      D.14341 = GetCurrentThreadId ();
      D.14342 = D.14340 != D.14341;
      D.14343 = (long int) D.14342;
      D.14344 = __builtin_expect (D.14343, 0);
      if (D.14344 != 0) goto <D.14345>; else goto <D.14346>;
      <D.14345>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "wthreads.c", 938, "thread_handle->id == (pthread_t)GetCurrentThreadId ()");
      <D.14346>:
      thread_handle.27 = thread_handle;
      thread_handle.27->has_apc = 1;
      D.14338 = 1;
      return D.14338;
    }
  finally
    {
      thread_handle = {CLOBBER};
    }
}


wapi_interrupt_thread (void * thread_handle)
{
  _Bool D.14349;
  long int D.14350;
  long int D.14351;
  struct _WapiHandle_thread * thread.28;
  void * * D.14355;
  long int wait_handle.29;
  unsigned int D.14362;
  struct _WapiHandleUnshared * D.14363;
  long unsigned int D.14364;
  long unsigned int D.14365;
  long unsigned int D.14366;
  struct _WapiHandleUnshared * D.14367;
  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.14349 = ok == 0;
      D.14350 = (long int) D.14349;
      D.14351 = __builtin_expect (D.14350, 0);
      if (D.14351 != 0) goto <D.14352>; else goto <D.14353>;
      <D.14352>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "wthreads.c", 969, "ok");
      <D.14353>:
      <D.13778>:
      thread.28 = thread;
      wait_handle = thread.28->wait_handle;
      thread.28 = thread;
      D.14355 = &thread.28->wait_handle;
      prev_handle = InterlockedCompareExchangePointer (D.14355, 4294967294B, wait_handle);
      if (prev_handle == 4294967294B) goto <D.14356>; else goto <D.14357>;
      <D.14356>:
      return;
      <D.14357>:
      if (prev_handle == wait_handle) goto <D.13777>; else goto <D.14358>;
      <D.14358>:
      goto <D.13778>;
      <D.13777>:
      if (wait_handle == 0B) goto <D.14359>; else goto <D.14360>;
      <D.14359>:
      return;
      <D.14360>:
      wait_handle.29 = (long int) wait_handle;
      idx = (guint32) wait_handle.29;
      D.14362 = idx / 256;
      D.14363 = _wapi_private_handles[D.14362];
      D.14364 = (long unsigned int) idx;
      D.14365 = D.14364 & 255;
      D.14366 = D.14365 * 200;
      D.14367 = D.14363 + D.14366;
      cond = &D.14367->signal_cond;
      D.14362 = idx / 256;
      D.14363 = _wapi_private_handles[D.14362];
      D.14364 = (long unsigned int) idx;
      D.14365 = D.14364 & 255;
      D.14366 = D.14365 * 200;
      D.14367 = D.14363 + D.14366;
      mutex = &D.14367->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.14371;
  long unsigned int comp.30;
  long unsigned int exch.31;
  long unsigned int D.14374;

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


wapi_prepare_interrupt_thread (void * thread_handle)
{
  _Bool D.14376;
  long int D.14377;
  long int D.14378;
  struct _WapiHandle_thread * thread.32;
  void * * D.14382;
  void * D.14385;
  struct _WapiHandle_thread * thread;
  gboolean ok;
  void * prev_handle;
  void * wait_handle;

  try
    {
      ok = _wapi_lookup_handle (thread_handle, 3, &thread);
      D.14376 = ok == 0;
      D.14377 = (long int) D.14376;
      D.14378 = __builtin_expect (D.14377, 0);
      if (D.14378 != 0) goto <D.14379>; else goto <D.14380>;
      <D.14379>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "wthreads.c", 1023, "ok");
      <D.14380>:
      <D.13787>:
      thread.32 = thread;
      wait_handle = thread.32->wait_handle;
      thread.32 = thread;
      D.14382 = &thread.32->wait_handle;
      prev_handle = InterlockedCompareExchangePointer (D.14382, 4294967294B, wait_handle);
      if (prev_handle == 4294967294B) goto <D.14383>; else goto <D.14384>;
      <D.14383>:
      D.14385 = 0B;
      return D.14385;
      <D.14384>:
      if (prev_handle == wait_handle) goto <D.13786>; else goto <D.14386>;
      <D.14386>:
      goto <D.13787>;
      <D.13786>:
      D.14385 = wait_handle;
      return D.14385;
    }
  finally
    {
      thread = {CLOBBER};
    }
}


wapi_finish_interrupt_thread (void * wait_handle)
{
  long int wait_handle.33;
  unsigned int D.14392;
  struct _WapiHandleUnshared * D.14393;
  long unsigned int D.14394;
  long unsigned int D.14395;
  long unsigned int D.14396;
  struct _WapiHandleUnshared * D.14397;
  union pthread_cond_t * cond;
  union mono_mutex_t * mutex;
  guint32 idx;

  if (wait_handle == 0B) goto <D.14389>; else goto <D.14390>;
  <D.14389>:
  return;
  <D.14390>:
  wait_handle.33 = (long int) wait_handle;
  idx = (guint32) wait_handle.33;
  D.14392 = idx / 256;
  D.14393 = _wapi_private_handles[D.14392];
  D.14394 = (long unsigned int) idx;
  D.14395 = D.14394 & 255;
  D.14396 = D.14395 * 200;
  D.14397 = D.14393 + D.14396;
  cond = &D.14397->signal_cond;
  D.14392 = idx / 256;
  D.14393 = _wapi_private_handles[D.14392];
  D.14394 = (long unsigned int) idx;
  D.14395 = D.14394 & 255;
  D.14396 = D.14395 * 200;
  D.14397 = D.14393 + D.14396;
  mutex = &D.14397->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.14399;
  _Bool D.14400;
  long int D.14401;
  long int D.14402;
  struct _WapiHandle_thread * thread.34;
  void * * D.14406;
  struct _WapiHandle_thread * thread;
  gboolean ok;
  void * prev_handle;
  void * wait_handle;
  void * thread_handle;
  void cleanup = <<< error >>>;

  try
    {
      D.14399 = GetCurrentThreadId ();
      thread_handle = OpenThread (0, 0, D.14399);
      ok = _wapi_lookup_handle (thread_handle, 3, &thread);
      D.14400 = ok == 0;
      D.14401 = (long int) D.14400;
      D.14402 = __builtin_expect (D.14401, 0);
      if (D.14402 != 0) goto <D.14403>; else goto <D.14404>;
      <D.14403>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "wthreads.c", 1095, "ok");
      <D.14404>:
      <D.13804>:
      thread.34 = thread;
      wait_handle = thread.34->wait_handle;
      thread.34 = thread;
      D.14406 = &thread.34->wait_handle;
      prev_handle = InterlockedCompareExchangePointer (D.14406, 4294967294B, wait_handle);
      if (prev_handle == 4294967294B) goto cleanup; else goto <D.14407>;
      <D.14407>:
      if (prev_handle == wait_handle) goto <D.13803>; else goto <D.14408>;
      <D.14408>:
      goto <D.13804>;
      <D.13803>:
      if (wait_handle != 0B) goto <D.14409>; else goto <D.14410>;
      <D.14409>:
      _wapi_handle_unref (wait_handle);
      <D.14410>:
      cleanup:
      _wapi_handle_unref (thread_handle);
    }
  finally
    {
      thread = {CLOBBER};
    }
}


wapi_clear_interruption ()
{
  long unsigned int D.14411;
  _Bool D.14412;
  long int D.14413;
  long int D.14414;
  struct _WapiHandle_thread * thread.35;
  void * * D.14418;
  struct _WapiHandle_thread * thread;
  gboolean ok;
  void * prev_handle;
  void * thread_handle;

  try
    {
      D.14411 = GetCurrentThreadId ();
      thread_handle = OpenThread (0, 0, D.14411);
      ok = _wapi_lookup_handle (thread_handle, 3, &thread);
      D.14412 = ok == 0;
      D.14413 = (long int) D.14412;
      D.14414 = __builtin_expect (D.14413, 0);
      if (D.14414 != 0) goto <D.14415>; else goto <D.14416>;
      <D.14415>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "wthreads.c", 1142, "ok");
      <D.14416>:
      thread.35 = thread;
      D.14418 = &thread.35->wait_handle;
      prev_handle = InterlockedCompareExchangePointer (D.14418, 0B, 4294967294B);
      if (prev_handle == 4294967294B) goto <D.14419>; else goto <D.14420>;
      <D.14419>:
      <D.14420>:
      _wapi_handle_unref (thread_handle);
    }
  finally
    {
      thread = {CLOBBER};
    }
}


wapi_current_thread_desc ()
{
  long unsigned int D.14421;
  char * D.14424;
  struct _WapiHandle_thread * thread.36;
  <unnamed type> D.14432;
  const char * D.14433;
  struct GPtrArray * D.14434;
  void * * D.14435;
  long unsigned int D.14436;
  long unsigned int D.14437;
  void * * D.14438;
  unsigned int i.37;
  unsigned int D.14443;
  struct _WapiHandle_thread * thread;
  int i;
  gboolean ok;
  void * handle;
  void * thread_handle;
  struct GString * text;
  char * res;

  try
    {
      D.14421 = GetCurrentThreadId ();
      thread_handle = OpenThread (0, 0, D.14421);
      ok = _wapi_lookup_handle (thread_handle, 3, &thread);
      if (ok == 0) goto <D.14422>; else goto <D.14423>;
      <D.14422>:
      D.14424 = monoeg_g_strdup_printf ("thread handle %p state : lookup failure", thread_handle);
      return D.14424;
      <D.14423>:
      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.14426>; else goto <D.14427>;
      <D.14426>:
      monoeg_g_string_append_printf (text, "not waiting");
      goto <D.14428>;
      <D.14427>:
      if (handle == 4294967294B) goto <D.14429>; else goto <D.14430>;
      <D.14429>:
      monoeg_g_string_append_printf (text, "interrupted state");
      goto <D.14431>;
      <D.14430>:
      D.14432 = _wapi_handle_type (handle);
      D.14433 = _wapi_handle_typename[D.14432];
      monoeg_g_string_append_printf (text, "waiting on %p : %s ", handle, D.14433);
      <D.14431>:
      <D.14428>:
      monoeg_g_string_append_printf (text, " owns (");
      i = 0;
      goto <D.13823>;
      <D.13822>:
      {
        void * mutex;

        thread.36 = thread;
        D.14434 = thread.36->owned_mutexes;
        D.14435 = D.14434->pdata;
        D.14436 = (long unsigned int) i;
        D.14437 = D.14436 * 8;
        D.14438 = D.14435 + D.14437;
        mutex = *D.14438;
        if (i > 0) goto <D.14439>; else goto <D.14440>;
        <D.14439>:
        monoeg_g_string_append_printf (text, ", %p", mutex);
        goto <D.14441>;
        <D.14440>:
        monoeg_g_string_append_printf (text, "%p", mutex);
        <D.14441>:
      }
      i = i + 1;
      <D.13823>:
      i.37 = (unsigned int) i;
      thread.36 = thread;
      D.14434 = thread.36->owned_mutexes;
      D.14443 = D.14434->len;
      if (i.37 < D.14443) goto <D.13822>; else goto <D.13824>;
      <D.13824>:
      monoeg_g_string_append_printf (text, ")");
      res = text->str;
      monoeg_g_string_free (text, 0);
      D.14424 = res;
      return D.14424;
    }
  finally
    {
      thread = {CLOBBER};
    }
}


wapi_thread_set_wait_handle (void * handle)
{
  long unsigned int D.14446;
  _Bool D.14447;
  long int D.14448;
  long int D.14449;
  struct _WapiHandle_thread * thread.38;
  void * * D.14453;
  _Bool D.14457;
  long int D.14458;
  long int D.14459;
  gboolean D.14462;
  _Bool D.14463;
  struct _WapiHandle_thread * thread;
  gboolean ok;
  void * prev_handle;
  void * thread_handle;

  try
    {
      D.14446 = GetCurrentThreadId ();
      thread_handle = OpenThread (0, 0, D.14446);
      ok = _wapi_lookup_handle (thread_handle, 3, &thread);
      D.14447 = ok == 0;
      D.14448 = (long int) D.14447;
      D.14449 = __builtin_expect (D.14448, 0);
      if (D.14449 != 0) goto <D.14450>; else goto <D.14451>;
      <D.14450>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "wthreads.c", 1209, "ok");
      <D.14451>:
      thread.38 = thread;
      D.14453 = &thread.38->wait_handle;
      prev_handle = InterlockedCompareExchangePointer (D.14453, handle, 0B);
      _wapi_handle_unref (thread_handle);
      if (prev_handle == 0B) goto <D.14454>; else goto <D.14455>;
      <D.14454>:
      _wapi_handle_ref (handle);
      goto <D.14456>;
      <D.14455>:
      D.14457 = prev_handle != 4294967294B;
      D.14458 = (long int) D.14457;
      D.14459 = __builtin_expect (D.14458, 0);
      if (D.14459 != 0) goto <D.14460>; else goto <D.14461>;
      <D.14460>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "wthreads.c", 1221, "prev_handle == INTERRUPTION_REQUESTED_HANDLE");
      <D.14461>:
      <D.14456>:
      D.14463 = prev_handle == 0B;
      D.14462 = (gboolean) D.14463;
      return D.14462;
    }
  finally
    {
      thread = {CLOBBER};
    }
}


wapi_thread_clear_wait_handle (void * handle)
{
  long unsigned int D.14466;
  _Bool D.14467;
  long int D.14468;
  long int D.14469;
  struct _WapiHandle_thread * thread.39;
  void * * D.14473;
  int iftmp.40;
  _Bool D.14482;
  long int D.14483;
  long int D.14484;
  struct _WapiHandle_thread * thread;
  gboolean ok;
  void * prev_handle;
  void * thread_handle;

  try
    {
      D.14466 = GetCurrentThreadId ();
      thread_handle = OpenThread (0, 0, D.14466);
      ok = _wapi_lookup_handle (thread_handle, 3, &thread);
      D.14467 = ok == 0;
      D.14468 = (long int) D.14467;
      D.14469 = __builtin_expect (D.14468, 0);
      if (D.14469 != 0) goto <D.14470>; else goto <D.14471>;
      <D.14470>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "wthreads.c", 1243, "ok");
      <D.14471>:
      thread.39 = thread;
      D.14473 = &thread.39->wait_handle;
      prev_handle = InterlockedCompareExchangePointer (D.14473, 0B, handle);
      if (prev_handle == handle) goto <D.14474>; else goto <D.14475>;
      <D.14474>:
      _wapi_handle_unref (handle);
      goto <D.14476>;
      <D.14475>:
      if (prev_handle != 4294967294B) goto <D.14480>; else goto <D.14478>;
      <D.14480>:
      if (prev_handle != 0B) goto <D.14481>; else goto <D.14478>;
      <D.14481>:
      iftmp.40 = 1;
      goto <D.14479>;
      <D.14478>:
      iftmp.40 = 0;
      <D.14479>:
      D.14482 = iftmp.40 != 0;
      D.14483 = (long int) D.14482;
      D.14484 = __builtin_expect (D.14483, 0);
      if (D.14484 != 0) goto <D.14485>; else goto <D.14486>;
      <D.14485>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "wthreads.c", 1253, "prev_handle == INTERRUPTION_REQUESTED_HANDLE || prev_handle == NULL");
      <D.14486>:
      <D.14476>:
      _wapi_handle_unref (thread_handle);
    }
  finally
    {
      thread = {CLOBBER};
    }
}


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

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


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

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


