_wapi_getpid ()
{
  pid_t D.11700;

  mono_once (&pid_init_once, pid_init);
  D.11700 = _wapi_pid;
  return D.11700;
}


pid_init ()
{
  int _wapi_pid.0;

  _wapi_pid.0 = getpid ();
  _wapi_pid = _wapi_pid.0;
}


wapi_init ()
{
  int D.11705;
  unsigned int _wapi_fd_reserve.1;
  unsigned int _wapi_fd_reserve.2;
  unsigned int D.11708;
  unsigned int _wapi_fd_reserve.3;
  unsigned int _wapi_private_handle_count.4;
  unsigned int _wapi_private_handle_count.5;
  unsigned int _wapi_private_handle_slot_count.6;
  unsigned int _wapi_private_handle_slot_count.7;
  void * _wapi_shared_layout.8;
  struct _WapiHandleSharedLayout * _wapi_shared_layout.9;
  _Bool D.11716;
  long int D.11717;
  long int D.11718;
  int D.11721;
  void * _wapi_fileshare_layout.10;
  struct _WapiFileShareLayout * _wapi_fileshare_layout.11;
  _Bool D.11726;
  long int D.11727;
  long int D.11728;
  int D.11731;
  void * _wapi_global_signal_handle.12;
  void * _wapi_global_signal_handle.13;
  long int _wapi_global_signal_handle.14;
  unsigned int D.11737;
  unsigned int D.11738;
  struct _WapiHandleUnshared * D.11739;
  long unsigned int D.11740;
  long unsigned int D.11741;
  long unsigned int D.11742;
  struct _WapiHandleUnshared * D.11743;
  union pthread_cond_t * _wapi_global_signal_cond.15;
  union mono_mutex_t * _wapi_global_signal_mutex.16;

  if (0 != 0) goto <D.11703>; else goto <D.11704>;
  <D.11703>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 247, "(sizeof (handle_ops) / sizeof (handle_ops[0])) == WAPI_HANDLE_COUNT");
  <D.11704>:
  D.11705 = getdtablesize ();
  _wapi_fd_reserve.1 = (unsigned int) D.11705;
  _wapi_fd_reserve = _wapi_fd_reserve.1;
  _wapi_fd_reserve.2 = _wapi_fd_reserve;
  D.11708 = _wapi_fd_reserve.2 + 255;
  _wapi_fd_reserve.3 = D.11708 & 4294967040;
  _wapi_fd_reserve = _wapi_fd_reserve.3;
  <D.11193>:
  _wapi_private_handle_count.4 = _wapi_private_handle_count;
  _wapi_private_handle_count.5 = _wapi_private_handle_count.4 + 256;
  _wapi_private_handle_count = _wapi_private_handle_count.5;
  _wapi_private_handle_slot_count.6 = _wapi_private_handle_slot_count;
  _wapi_private_handle_slot_count.7 = _wapi_private_handle_slot_count.6 + 1;
  _wapi_private_handle_slot_count = _wapi_private_handle_slot_count.7;
  _wapi_fd_reserve.2 = _wapi_fd_reserve;
  _wapi_private_handle_count.4 = _wapi_private_handle_count;
  if (_wapi_fd_reserve.2 > _wapi_private_handle_count.4) goto <D.11193>; else goto <D.11194>;
  <D.11194>:
  _wapi_shm_semaphores_init ();
  _wapi_shared_layout.8 = _wapi_shm_attach (0);
  _wapi_shared_layout = _wapi_shared_layout.8;
  _wapi_shared_layout.9 = _wapi_shared_layout;
  D.11716 = _wapi_shared_layout.9 == 0B;
  D.11717 = (long int) D.11716;
  D.11718 = __builtin_expect (D.11717, 0);
  if (D.11718 != 0) goto <D.11719>; else goto <D.11720>;
  <D.11719>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 271, "_wapi_shared_layout != NULL");
  <D.11720>:
  D.11721 = _wapi_shm_enabled ();
  if (D.11721 != 0) goto <D.11722>; else goto <D.11723>;
  <D.11722>:
  _wapi_fileshare_layout.10 = _wapi_shm_attach (1);
  _wapi_fileshare_layout = _wapi_fileshare_layout.10;
  _wapi_fileshare_layout.11 = _wapi_fileshare_layout;
  D.11726 = _wapi_fileshare_layout.11 == 0B;
  D.11727 = (long int) D.11726;
  D.11728 = __builtin_expect (D.11727, 0);
  if (D.11728 != 0) goto <D.11729>; else goto <D.11730>;
  <D.11729>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 276, "_wapi_fileshare_layout != NULL");
  <D.11730>:
  <D.11723>:
  D.11731 = _wapi_shm_enabled ();
  if (D.11731 != 0) goto <D.11732>; else goto <D.11733>;
  <D.11732>:
  _wapi_collection_init ();
  <D.11733>:
  _wapi_io_init ();
  pthread_mutex_init (&scan_mutex, 0B);
  _wapi_global_signal_handle.12 = _wapi_handle_new (6, 0B);
  _wapi_global_signal_handle = _wapi_global_signal_handle.12;
  _wapi_global_signal_handle.13 = _wapi_global_signal_handle;
  _wapi_global_signal_handle.14 = (long int) _wapi_global_signal_handle.13;
  D.11737 = (unsigned int) _wapi_global_signal_handle.14;
  D.11738 = D.11737 / 256;
  D.11739 = _wapi_private_handles[D.11738];
  _wapi_global_signal_handle.13 = _wapi_global_signal_handle;
  _wapi_global_signal_handle.14 = (long int) _wapi_global_signal_handle.13;
  D.11737 = (unsigned int) _wapi_global_signal_handle.14;
  D.11740 = (long unsigned int) D.11737;
  D.11741 = D.11740 & 255;
  D.11742 = D.11741 * 200;
  D.11743 = D.11739 + D.11742;
  _wapi_global_signal_cond.15 = &D.11743->signal_cond;
  _wapi_global_signal_cond = _wapi_global_signal_cond.15;
  _wapi_global_signal_handle.13 = _wapi_global_signal_handle;
  _wapi_global_signal_handle.14 = (long int) _wapi_global_signal_handle.13;
  D.11737 = (unsigned int) _wapi_global_signal_handle.14;
  D.11738 = D.11737 / 256;
  D.11739 = _wapi_private_handles[D.11738];
  _wapi_global_signal_handle.13 = _wapi_global_signal_handle;
  _wapi_global_signal_handle.14 = (long int) _wapi_global_signal_handle.13;
  D.11737 = (unsigned int) _wapi_global_signal_handle.14;
  D.11740 = (long unsigned int) D.11737;
  D.11741 = D.11740 & 255;
  D.11742 = D.11741 * 200;
  D.11743 = D.11739 + D.11742;
  _wapi_global_signal_mutex.16 = &D.11743->signal_mutex;
  _wapi_global_signal_mutex = _wapi_global_signal_mutex.16;
  atexit (handle_cleanup);
}


handle_cleanup ()
{
  struct _WapiHandleUnshared * D.11746;
  long unsigned int D.11747;
  long unsigned int D.11748;
  <unnamed type> D.11749;
  int D.11750;
  int D.11751;
  long int D.11752;
  _Bool D.11755;
  _Bool D.11756;
  _Bool D.11757;
  unsigned int type.17;
  unsigned int D.11760;
  unsigned int D.11765;
  struct GHashTable * file_share_hash.18;
  int i;
  int j;
  int k;

  i = 0;
  goto <D.11185>;
  <D.11184>:
  j = 0;
  goto <D.11182>;
  <D.11181>:
  {
    struct _WapiHandleUnshared * handle_data;
    int type;
    void * handle;

    D.11746 = _wapi_private_handles[i];
    D.11747 = (long unsigned int) j;
    D.11748 = D.11747 * 200;
    handle_data = D.11746 + D.11748;
    D.11749 = handle_data->type;
    type = (int) D.11749;
    D.11750 = i * 256;
    D.11751 = D.11750 + j;
    D.11752 = (long int) D.11751;
    handle = (void *) D.11752;
    D.11755 = type == 9;
    D.11756 = type == 11;
    D.11757 = D.11755 | D.11756;
    if (D.11757 != 0) goto <D.11753>; else goto <D.11758>;
    <D.11758>:
    type.17 = (unsigned int) type;
    D.11760 = type.17 + 4294967284;
    if (D.11760 <= 1) goto <D.11753>; else goto <D.11754>;
    <D.11753>:
    if (type == 3) goto <D.11761>; else goto <D.11762>;
    <D.11761>:
    if (1 != 0) goto <D.11763>; else goto <D.11764>;
    <D.11763>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 211, "0");
    <D.11764>:
    _wapi_thread_set_termination_details (handle, 0);
    <D.11762>:
    <D.11754>:
    D.11765 = handle_data->ref;
    k = (int) D.11765;
    goto <D.11179>;
    <D.11178>:
    _wapi_handle_unref_full (handle, 1);
    k = k + -1;
    <D.11179>:
    if (k > 0) goto <D.11178>; else goto <D.11180>;
    <D.11180>:
  }
  j = j + 1;
  <D.11182>:
  if (j <= 255) goto <D.11181>; else goto <D.11183>;
  <D.11183>:
  i = i + 1;
  <D.11185>:
  D.11746 = _wapi_private_handles[i];
  if (D.11746 != 0B) goto <D.11184>; else goto <D.11186>;
  <D.11186>:
  _wapi_shm_semaphores_remove ();
  _wapi_shm_detach (0);
  _wapi_shm_detach (1);
  file_share_hash.18 = file_share_hash;
  if (file_share_hash.18 != 0B) goto <D.11767>; else goto <D.11768>;
  <D.11767>:
  file_share_hash.18 = file_share_hash;
  monoeg_g_hash_table_destroy (file_share_hash.18);
  DeleteCriticalSection (&file_share_hash_mutex);
  <D.11768>:
  i = 0;
  goto <D.11188>;
  <D.11187>:
  D.11746 = _wapi_private_handles[i];
  monoeg_g_free (D.11746);
  i = i + 1;
  <D.11188>:
  if (i <= 16383) goto <D.11187>; else goto <D.11189>;
  <D.11189>:
}


_wapi_handle_unref_full (void * handle, gboolean ignore_private_busy_handles)
{
  long int handle.19;
  <unnamed type> D.11772;
  unsigned int D.11775;
  struct _WapiHandleUnshared * D.11776;
  long unsigned int D.11777;
  long unsigned int D.11778;
  long unsigned int D.11779;
  struct _WapiHandleUnshared * D.11780;
  guint * D.11781;
  int D.11782;
  _Bool D.11783;
  int iftmp.20;
  _Bool D.11790;
  _Bool D.11791;
  _Bool D.11792;
  unsigned int D.11794;
  _Bool D.11797;
  long int D.11798;
  long int D.11799;
  long int D.11802;
  long int D.11803;
  union 
{
  struct _WapiHandle_event event;
  struct _WapiHandle_file file;
  struct _WapiHandle_find find;
  struct _WapiHandle_mutex mutex;
  struct _WapiHandle_sem sem;
  struct _WapiHandle_socket sock;
  struct _WapiHandle_thread thread;
  struct _WapiHandle_shared_ref shared;
} * D.11806;
  union mono_mutex_t * D.11809;
  _Bool D.11810;
  _Bool D.11811;
  _Bool D.11812;
  union pthread_cond_t * D.11818;
  struct _WapiHandleSharedLayout * _wapi_shared_layout.21;
  unsigned int D.11826;
  unsigned int D.11827;
  unsigned int D.11830;
  guint32 idx;
  gboolean destroy;
  gboolean early_exit;
  int thr_ret;
  static const char __func__[24] = "_wapi_handle_unref_full";

  handle.19 = (long int) handle;
  idx = (guint32) handle.19;
  destroy = 0;
  early_exit = 0;
  if (idx > 4194303) goto <D.11770>; else goto <D.11771>;
  <D.11770>:
  return;
  <D.11771>:
  D.11772 = _wapi_handle_type (handle);
  if (D.11772 == 0) goto <D.11773>; else goto <D.11774>;
  <D.11773>:
  monoeg_g_log (0B, 16, "%s: Attempting to unref unused handle %p", &__func__, handle);
  return;
  <D.11774>:
  D.11775 = idx / 256;
  D.11776 = _wapi_private_handles[D.11775];
  D.11777 = (long unsigned int) idx;
  D.11778 = D.11777 & 255;
  D.11779 = D.11778 * 200;
  D.11780 = D.11776 + D.11779;
  D.11781 = &D.11780->ref;
  D.11782 = InterlockedDecrement (D.11781);
  D.11783 = D.11782 == 0;
  destroy = (gboolean) D.11783;
  if (destroy == 1) goto <D.11784>; else goto <D.11785>;
  <D.11784>:
  {
    struct _WapiHandleUnshared handle_data;
    struct _WapiHandleShared shared_handle_data;
    WapiHandleType type;
    void (*<Tc67>) (void *, void *) close_func;
    gboolean is_shared;

    try
      {
        D.11775 = idx / 256;
        D.11776 = _wapi_private_handles[D.11775];
        D.11777 = (long unsigned int) idx;
        D.11778 = D.11777 & 255;
        D.11779 = D.11778 * 200;
        D.11780 = D.11776 + D.11779;
        type = D.11780->type;
        close_func = _wapi_handle_ops_get_close_func (type);
        D.11790 = type == 9;
        D.11791 = type == 11;
        D.11792 = D.11790 | D.11791;
        if (D.11792 != 0) goto <D.11787>; else goto <D.11793>;
        <D.11793>:
        D.11794 = type + 4294967284;
        if (D.11794 <= 1) goto <D.11787>; else goto <D.11788>;
        <D.11787>:
        iftmp.20 = 1;
        goto <D.11789>;
        <D.11788>:
        iftmp.20 = 0;
        <D.11789>:
        is_shared = iftmp.20;
        if (is_shared != 0) goto <D.11795>; else goto <D.11796>;
        <D.11795>:
        thr_ret = _wapi_handle_lock_shared_handles ();
        D.11797 = thr_ret != 0;
        D.11798 = (long int) D.11797;
        D.11799 = __builtin_expect (D.11798, 0);
        if (D.11799 != 0) goto <D.11800>; else goto <D.11801>;
        <D.11800>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 1080, "thr_ret == 0");
        <D.11801>:
        <D.11796>:
        {
          struct __pthread_unwind_buf_t __cancel_buf;
          void (*<Tc2>) (void *) __cancel_routine;
          void * __cancel_arg;
          int __not_first_call;

          try
            {
              __cancel_routine = mono_mutex_unlock_in_cleanup;
              __cancel_arg = &scan_mutex;
              __not_first_call = __sigsetjmp (&__cancel_buf.__cancel_jmp_buf, 0);
              D.11802 = (long int) __not_first_call;
              D.11803 = __builtin_expect (D.11802, 0);
              if (D.11803 != 0) goto <D.11804>; else goto <D.11805>;
              <D.11804>:
              __cancel_routine (__cancel_arg);
              __pthread_unwind_next (&__cancel_buf);
              <D.11805>:
              __pthread_register_cancel (&__cancel_buf);
              thr_ret = pthread_mutex_lock (&scan_mutex);
              D.11775 = idx / 256;
              D.11776 = _wapi_private_handles[D.11775];
              D.11777 = (long unsigned int) idx;
              D.11778 = D.11777 & 255;
              D.11779 = D.11778 * 200;
              D.11780 = D.11776 + D.11779;
              memcpy (&handle_data, D.11780, 200);
              D.11775 = idx / 256;
              D.11776 = _wapi_private_handles[D.11775];
              D.11777 = (long unsigned int) idx;
              D.11778 = D.11777 & 255;
              D.11779 = D.11778 * 200;
              D.11780 = D.11776 + D.11779;
              D.11806 = &D.11780->u;
              memset (D.11806, 0, 96);
              D.11775 = idx / 256;
              D.11776 = _wapi_private_handles[D.11775];
              D.11777 = (long unsigned int) idx;
              D.11778 = D.11777 & 255;
              D.11779 = D.11778 * 200;
              D.11780 = D.11776 + D.11779;
              D.11780->type = 0;
              if (is_shared == 0) goto <D.11807>; else goto <D.11808>;
              <D.11807>:
              D.11775 = idx / 256;
              D.11776 = _wapi_private_handles[D.11775];
              D.11777 = (long unsigned int) idx;
              D.11778 = D.11777 & 255;
              D.11779 = D.11778 * 200;
              D.11780 = D.11776 + D.11779;
              D.11809 = &D.11780->signal_mutex;
              thr_ret = pthread_mutex_destroy (D.11809);
              D.11810 = thr_ret == 16;
              D.11811 = ignore_private_busy_handles != 0;
              D.11812 = D.11810 & D.11811;
              if (D.11812 != 0) goto <D.11813>; else goto <D.11814>;
              <D.11813>:
              early_exit = 1;
              goto <D.11815>;
              <D.11814>:
              if (thr_ret != 0) goto <D.11816>; else goto <D.11817>;
              <D.11816>:
              monoeg_g_log (0B, 4, "Error destroying handle %p mutex due to %d\n", handle, thr_ret);
              <D.11431>:
              goto <D.11431>;
              <D.11817>:
              D.11775 = idx / 256;
              D.11776 = _wapi_private_handles[D.11775];
              D.11777 = (long unsigned int) idx;
              D.11778 = D.11777 & 255;
              D.11779 = D.11778 * 200;
              D.11780 = D.11776 + D.11779;
              D.11818 = &D.11780->signal_cond;
              thr_ret = pthread_cond_destroy (D.11818);
              D.11810 = thr_ret == 16;
              D.11811 = ignore_private_busy_handles != 0;
              D.11812 = D.11810 & D.11811;
              if (D.11812 != 0) goto <D.11819>; else goto <D.11820>;
              <D.11819>:
              early_exit = 1;
              goto <D.11821>;
              <D.11820>:
              if (thr_ret != 0) goto <D.11822>; else goto <D.11823>;
              <D.11822>:
              monoeg_g_log (0B, 4, "Error destroying handle %p cond var due to %d\n", handle, thr_ret);
              <D.11432>:
              goto <D.11432>;
              <D.11823>:
              <D.11821>:
              <D.11815>:
              goto <D.11824>;
              <D.11808>:
              {
                struct _WapiHandleShared * shared;

                _wapi_shared_layout.21 = _wapi_shared_layout;
                D.11826 = handle_data.u.shared.offset;
                shared = &_wapi_shared_layout.21->handles[D.11826];
                memcpy (&shared_handle_data, shared, 336);
                D.11827 = shared->handle_refs;
                if (D.11827 != 0) goto <D.11828>; else goto <D.11829>;
                <D.11828>:
                D.11827 = shared->handle_refs;
                D.11830 = D.11827 + 4294967295;
                shared->handle_refs = D.11830;
                D.11827 = shared->handle_refs;
                if (D.11827 == 0) goto <D.11831>; else goto <D.11832>;
                <D.11831>:
                memset (shared, 0, 336);
                <D.11832>:
                <D.11829>:
              }
              <D.11824>:
              thr_ret = pthread_mutex_unlock (&scan_mutex);
              D.11797 = thr_ret != 0;
              D.11798 = (long int) D.11797;
              D.11799 = __builtin_expect (D.11798, 0);
              if (D.11799 != 0) goto <D.11833>; else goto <D.11834>;
              <D.11833>:
              monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 1138, "thr_ret == 0");
              <D.11834>:
              __pthread_unregister_cancel (&__cancel_buf);
              if (0 != 0) goto <D.11835>; else goto <D.11836>;
              <D.11835>:
              __cancel_routine (__cancel_arg);
              <D.11836>:
            }
          finally
            {
              __cancel_buf = {CLOBBER};
            }
        }
        if (early_exit != 0) goto <D.11837>; else goto <D.11838>;
        <D.11837>:
        return;
        <D.11838>:
        if (is_shared != 0) goto <D.11839>; else goto <D.11840>;
        <D.11839>:
        _wapi_handle_unlock_shared_handles ();
        <D.11840>:
        if (close_func != 0B) goto <D.11841>; else goto <D.11842>;
        <D.11841>:
        if (is_shared != 0) goto <D.11843>; else goto <D.11844>;
        <D.11843>:
        close_func (handle, &shared_handle_data.u);
        goto <D.11845>;
        <D.11844>:
        close_func (handle, &handle_data.u);
        <D.11845>:
        <D.11842>:
      }
    finally
      {
        handle_data = {CLOBBER};
        shared_handle_data = {CLOBBER};
      }
  }
  <D.11785>:
}


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

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


_wapi_handle_type (void * handle)
{
  long int handle.22;
  unsigned int D.11861;
  struct _WapiHandleUnshared * D.11862;
  WapiHandleType D.11863;
  unsigned int D.11864;
  struct _WapiHandleUnshared * D.11865;
  long unsigned int D.11866;
  long unsigned int D.11867;
  long unsigned int D.11868;
  struct _WapiHandleUnshared * D.11869;
  guint32 idx;

  handle.22 = (long int) handle;
  idx = (guint32) handle.22;
  if (idx > 4194303) goto <D.11858>; else goto <D.11860>;
  <D.11860>:
  D.11861 = idx / 256;
  D.11862 = _wapi_private_handles[D.11861];
  if (D.11862 == 0B) goto <D.11858>; else goto <D.11859>;
  <D.11858>:
  D.11863 = 0;
  return D.11863;
  <D.11859>:
  D.11864 = idx / 256;
  D.11865 = _wapi_private_handles[D.11864];
  D.11866 = (long unsigned int) idx;
  D.11867 = D.11866 & 255;
  D.11868 = D.11867 * 200;
  D.11869 = D.11865 + D.11868;
  D.11863 = D.11869->type;
  return D.11863;
}


InterlockedDecrement (volatile gint32 * val)
{
  gint32 D.11871;
  unsigned int D.11872;

  D.11872 = __sync_sub_and_fetch_4 (val, 1);
  D.11871 = (gint32) D.11872;
  return D.11871;
}


_wapi_handle_ops_get_close_func (WapiHandleType type)
{
  struct _WapiHandleOps * D.11874;
  void (*<Tc67>) (void *, void *) D.11877;
  void (*<Tc67>) (void *, void *) D.11880;

  D.11874 = handle_ops[type];
  if (D.11874 != 0B) goto <D.11875>; else goto <D.11876>;
  <D.11875>:
  D.11874 = handle_ops[type];
  D.11877 = D.11874->close;
  if (D.11877 != 0B) goto <D.11878>; else goto <D.11879>;
  <D.11878>:
  D.11874 = handle_ops[type];
  D.11880 = D.11874->close;
  return D.11880;
  <D.11879>:
  <D.11876>:
  D.11880 = 0B;
  return D.11880;
}


_wapi_handle_lock_shared_handles ()
{
  int D.11882;

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


memcpy (void * restrict __dest, const void * restrict __src, size_t __len)
{
  void * D.11884;
  long unsigned int D.11885;

  D.11885 = __builtin_object_size (__dest, 0);
  D.11884 = __builtin___memcpy_chk (__dest, __src, __len, D.11885);
  return D.11884;
}


memset (void * __dest, int __ch, size_t __len)
{
  int D.11889;
  int D.11894;
  void * D.11896;
  long unsigned int D.11897;

  D.11889 = __builtin_constant_p (__len);
  if (D.11889 != 0) goto <D.11890>; else goto <D.11891>;
  <D.11890>:
  if (__len == 0) goto <D.11892>; else goto <D.11893>;
  <D.11892>:
  D.11894 = __builtin_constant_p (__ch);
  if (D.11894 == 0) goto <D.11887>; else goto <D.11895>;
  <D.11895>:
  if (__ch != 0) goto <D.11887>; else goto <D.11888>;
  <D.11887>:
  __warn_memset_zero_len ();
  D.11896 = __dest;
  return D.11896;
  <D.11888>:
  <D.11893>:
  <D.11891>:
  D.11897 = __builtin_object_size (__dest, 0);
  D.11896 = __builtin___memset_chk (__dest, __ch, __len, D.11897);
  return D.11896;
}


_wapi_handle_unlock_shared_handles ()
{
  int D.11899;

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


wapi_cleanup ()
{
  int _wapi_has_shut_down.23;
  _Bool D.11902;
  long int D.11903;
  long int D.11904;

  _wapi_has_shut_down.23 = _wapi_has_shut_down;
  D.11902 = _wapi_has_shut_down.23 != 0;
  D.11903 = (long int) D.11902;
  D.11904 = __builtin_expect (D.11903, 0);
  if (D.11904 != 0) goto <D.11905>; else goto <D.11906>;
  <D.11905>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 303, "_wapi_has_shut_down == FALSE");
  <D.11906>:
  _wapi_has_shut_down = 1;
  _wapi_error_cleanup ();
  _wapi_thread_cleanup ();
}


_wapi_handle_new (WapiHandleType type, void * handle_specific)
{
  int _wapi_has_shut_down.24;
  _Bool D.11908;
  long int D.11909;
  long int D.11910;
  int iftmp.25;
  unsigned int D.11917;
  _Bool D.11918;
  _Bool D.11919;
  _Bool D.11920;
  _Bool D.11922;
  long int D.11923;
  long int D.11924;
  long int D.11927;
  long int D.11928;
  _Bool D.11931;
  long int D.11932;
  long int D.11933;
  unsigned int _wapi_private_handle_count.26;
  unsigned int D.11937;
  void * D.11939;
  unsigned int _wapi_private_handle_count.27;
  unsigned int _wapi_private_handle_slot_count.28;
  unsigned int _wapi_private_handle_slot_count.29;
  unsigned int _wapi_fd_reserve.30;
  _Bool D.11950;
  long int D.11951;
  long int D.11952;
  long unsigned int D.11955;
  _Bool D.11958;
  _Bool D.11959;
  _Bool D.11960;
  unsigned int D.11962;
  unsigned int D.11967;
  struct _WapiHandleUnshared * D.11968;
  long unsigned int D.11969;
  long unsigned int D.11970;
  struct _WapiHandleUnshared * D.11971;
  void * D.11972;
  guint32 handle_idx;
  void * handle;
  int thr_ret;
  void done = <<< error >>>;

  handle_idx = 0;
  _wapi_has_shut_down.24 = _wapi_has_shut_down;
  D.11908 = _wapi_has_shut_down.24 != 0;
  D.11909 = (long int) D.11908;
  D.11910 = __builtin_expect (D.11909, 0);
  if (D.11910 != 0) goto <D.11911>; else goto <D.11912>;
  <D.11911>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 466, "_wapi_has_shut_down == FALSE");
  <D.11912>:
  D.11917 = type + 4294967295;
  D.11918 = D.11917 <= 1;
  D.11919 = type == 7;
  D.11920 = D.11918 | D.11919;
  if (D.11920 != 0) goto <D.11914>; else goto <D.11921>;
  <D.11921>:
  if (type == 10) goto <D.11914>; else goto <D.11915>;
  <D.11914>:
  iftmp.25 = 1;
  goto <D.11916>;
  <D.11915>:
  iftmp.25 = 0;
  <D.11916>:
  D.11922 = iftmp.25 != 0;
  D.11923 = (long int) D.11922;
  D.11924 = __builtin_expect (D.11923, 0);
  if (D.11924 != 0) goto <D.11925>; else goto <D.11926>;
  <D.11925>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 471, "!_WAPI_FD_HANDLE(type)");
  <D.11926>:
  {
    struct __pthread_unwind_buf_t __cancel_buf;
    void (*<Tc2>) (void *) __cancel_routine;
    void * __cancel_arg;
    int __not_first_call;

    try
      {
        __cancel_routine = mono_mutex_unlock_in_cleanup;
        __cancel_arg = &scan_mutex;
        __not_first_call = __sigsetjmp (&__cancel_buf.__cancel_jmp_buf, 0);
        D.11927 = (long int) __not_first_call;
        D.11928 = __builtin_expect (D.11927, 0);
        if (D.11928 != 0) goto <D.11929>; else goto <D.11930>;
        <D.11929>:
        __cancel_routine (__cancel_arg);
        __pthread_unwind_next (&__cancel_buf);
        <D.11930>:
        __pthread_register_cancel (&__cancel_buf);
        thr_ret = pthread_mutex_lock (&scan_mutex);
        D.11931 = thr_ret != 0;
        D.11932 = (long int) D.11931;
        D.11933 = __builtin_expect (D.11932, 0);
        if (D.11933 != 0) goto <D.11934>; else goto <D.11935>;
        <D.11934>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 476, "thr_ret == 0");
        <D.11935>:
        goto <D.11254>;
        <D.11253>:
        {
          int idx;

          _wapi_private_handle_count.26 = _wapi_private_handle_count;
          D.11937 = _wapi_private_handle_count.26 / 256;
          idx = (int) D.11937;
          if (idx > 16383) goto <D.11252>; else goto <D.11938>;
          <D.11938>:
          D.11939 = monoeg_malloc0 (51200);
          _wapi_private_handles[idx] = D.11939;
          _wapi_private_handle_count.26 = _wapi_private_handle_count;
          _wapi_private_handle_count.27 = _wapi_private_handle_count.26 + 256;
          _wapi_private_handle_count = _wapi_private_handle_count.27;
          _wapi_private_handle_slot_count.28 = _wapi_private_handle_slot_count;
          _wapi_private_handle_slot_count.29 = _wapi_private_handle_slot_count.28 + 1;
          _wapi_private_handle_slot_count = _wapi_private_handle_slot_count.29;
        }
        <D.11254>:
        handle_idx = _wapi_handle_new_internal (type, handle_specific);
        if (handle_idx == 0) goto <D.11253>; else goto <D.11252>;
        <D.11252>:
        thr_ret = pthread_mutex_unlock (&scan_mutex);
        D.11931 = thr_ret != 0;
        D.11932 = (long int) D.11931;
        D.11933 = __builtin_expect (D.11932, 0);
        if (D.11933 != 0) goto <D.11943>; else goto <D.11944>;
        <D.11943>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 493, "thr_ret == 0");
        <D.11944>:
        __pthread_unregister_cancel (&__cancel_buf);
        if (0 != 0) goto <D.11945>; else goto <D.11946>;
        <D.11945>:
        __cancel_routine (__cancel_arg);
        <D.11946>:
      }
    finally
      {
        __cancel_buf = {CLOBBER};
      }
  }
  if (handle_idx == 0) goto <D.11947>; else goto <D.11948>;
  <D.11947>:
  handle = -1B;
  goto done;
  <D.11948>:
  _wapi_fd_reserve.30 = _wapi_fd_reserve;
  D.11950 = handle_idx < _wapi_fd_reserve.30;
  D.11951 = (long int) D.11950;
  D.11952 = __builtin_expect (D.11951, 0);
  if (D.11952 != 0) goto <D.11953>; else goto <D.11954>;
  <D.11953>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 503, "handle_idx >= _wapi_fd_reserve");
  <D.11954>:
  D.11955 = (long unsigned int) handle_idx;
  handle = (void *) D.11955;
  D.11958 = type == 9;
  D.11959 = type == 11;
  D.11960 = D.11958 | D.11959;
  if (D.11960 != 0) goto <D.11956>; else goto <D.11961>;
  <D.11961>:
  D.11962 = type + 4294967284;
  if (D.11962 <= 1) goto <D.11956>; else goto <D.11957>;
  <D.11956>:
  {
    guint32 ref;

    ref = _wapi_handle_new_shared (type, handle_specific);
    if (ref == 0) goto <D.11963>; else goto <D.11964>;
    <D.11963>:
    _wapi_handle_collect ();
    ref = _wapi_handle_new_shared (type, handle_specific);
    if (ref == 0) goto <D.11965>; else goto <D.11966>;
    <D.11965>:
    handle = -1B;
    goto done;
    <D.11966>:
    <D.11964>:
    D.11967 = handle_idx / 256;
    D.11968 = _wapi_private_handles[D.11967];
    D.11955 = (long unsigned int) handle_idx;
    D.11969 = D.11955 & 255;
    D.11970 = D.11969 * 200;
    D.11971 = D.11968 + D.11970;
    D.11971->u.shared.offset = ref;
  }
  <D.11957>:
  done:
  D.11972 = handle;
  return D.11972;
}


_wapi_handle_new_internal (WapiHandleType type, void * handle_specific)
{
  int _wapi_has_shut_down.31;
  _Bool D.11981;
  long int D.11982;
  long int D.11983;
  unsigned int last.32;
  unsigned int _wapi_fd_reserve.33;
  struct _WapiHandleUnshared * D.11991;
  long unsigned int D.11994;
  long unsigned int D.11995;
  <unnamed type> D.11996;
  unsigned int last.34;
  guint32 D.12000;
  unsigned int _wapi_private_handle_slot_count.35;
  guint32 i;
  guint32 k;
  guint32 count;
  static guint32 last = 0;
  gboolean retry;
  void again = <<< error >>>;

  retry = 0;
  _wapi_has_shut_down.31 = _wapi_has_shut_down;
  D.11981 = _wapi_has_shut_down.31 != 0;
  D.11982 = (long int) D.11981;
  D.11983 = __builtin_expect (D.11982, 0);
  if (D.11983 != 0) goto <D.11984>; else goto <D.11985>;
  <D.11984>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 416, "_wapi_has_shut_down == FALSE");
  <D.11985>:
  last.32 = last;
  _wapi_fd_reserve.33 = _wapi_fd_reserve;
  if (last.32 < _wapi_fd_reserve.33) goto <D.11988>; else goto <D.11989>;
  <D.11988>:
  _wapi_fd_reserve.33 = _wapi_fd_reserve;
  last = _wapi_fd_reserve.33;
  goto <D.11990>;
  <D.11989>:
  retry = 1;
  <D.11990>:
  again:
  count = last;
  i = count / 256;
  goto <D.11236>;
  <D.11235>:
  D.11991 = _wapi_private_handles[i];
  if (D.11991 != 0B) goto <D.11992>; else goto <D.11993>;
  <D.11992>:
  k = count & 255;
  goto <D.11233>;
  <D.11232>:
  {
    struct _WapiHandleUnshared * handle;

    D.11991 = _wapi_private_handles[i];
    D.11994 = (long unsigned int) k;
    D.11995 = D.11994 * 200;
    handle = D.11991 + D.11995;
    D.11996 = handle->type;
    if (D.11996 == 0) goto <D.11997>; else goto <D.11998>;
    <D.11997>:
    last.34 = count + 1;
    last = last.34;
    _wapi_handle_init (handle, type, handle_specific);
    D.12000 = count;
    return D.12000;
    <D.11998>:
    count = count + 1;
  }
  k = k + 1;
  <D.11233>:
  if (k <= 255) goto <D.11232>; else goto <D.11234>;
  <D.11234>:
  <D.11993>:
  i = i + 1;
  <D.11236>:
  _wapi_private_handle_slot_count.35 = _wapi_private_handle_slot_count;
  if (i < _wapi_private_handle_slot_count.35) goto <D.11235>; else goto <D.11237>;
  <D.11237>:
  if (retry != 0) goto <D.12002>; else goto <D.12003>;
  <D.12002>:
  last.32 = last;
  _wapi_fd_reserve.33 = _wapi_fd_reserve;
  if (last.32 > _wapi_fd_reserve.33) goto <D.12004>; else goto <D.12005>;
  <D.12004>:
  _wapi_fd_reserve.33 = _wapi_fd_reserve;
  last = _wapi_fd_reserve.33;
  goto again;
  <D.12005>:
  <D.12003>:
  D.12000 = 0;
  return D.12000;
}


_wapi_handle_init (struct _WapiHandleUnshared * handle, WapiHandleType type, void * handle_specific)
{
  int _wapi_has_shut_down.36;
  _Bool D.12008;
  long int D.12009;
  long int D.12010;
  _Bool D.12013;
  _Bool D.12014;
  _Bool D.12015;
  unsigned int D.12018;
  union pthread_cond_t * D.12021;
  _Bool D.12022;
  long int D.12023;
  long int D.12024;
  union mono_mutex_t * D.12027;
  union 
{
  struct _WapiHandle_event event;
  struct _WapiHandle_file file;
  struct _WapiHandle_find find;
  struct _WapiHandle_mutex mutex;
  struct _WapiHandle_sem sem;
  struct _WapiHandle_socket sock;
  struct _WapiHandle_thread thread;
  struct _WapiHandle_shared_ref shared;
} * D.12032;
  int thr_ret;

  _wapi_has_shut_down.36 = _wapi_has_shut_down;
  D.12008 = _wapi_has_shut_down.36 != 0;
  D.12009 = (long int) D.12008;
  D.12010 = __builtin_expect (D.12009, 0);
  if (D.12010 != 0) goto <D.12011>; else goto <D.12012>;
  <D.12011>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 332, "_wapi_has_shut_down == FALSE");
  <D.12012>:
  handle->type = type;
  handle->signalled = 0;
  handle->ref = 1;
  D.12013 = type != 9;
  D.12014 = type != 11;
  D.12015 = D.12013 & D.12014;
  if (D.12015 != 0) goto <D.12016>; else goto <D.12017>;
  <D.12016>:
  D.12018 = type + 4294967284;
  if (D.12018 > 1) goto <D.12019>; else goto <D.12020>;
  <D.12019>:
  D.12021 = &handle->signal_cond;
  thr_ret = pthread_cond_init (D.12021, 0B);
  D.12022 = thr_ret != 0;
  D.12023 = (long int) D.12022;
  D.12024 = __builtin_expect (D.12023, 0);
  if (D.12024 != 0) goto <D.12025>; else goto <D.12026>;
  <D.12025>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 340, "thr_ret == 0");
  <D.12026>:
  D.12027 = &handle->signal_mutex;
  thr_ret = pthread_mutex_init (D.12027, 0B);
  D.12022 = thr_ret != 0;
  D.12023 = (long int) D.12022;
  D.12024 = __builtin_expect (D.12023, 0);
  if (D.12024 != 0) goto <D.12028>; else goto <D.12029>;
  <D.12028>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 343, "thr_ret == 0");
  <D.12029>:
  if (handle_specific != 0B) goto <D.12030>; else goto <D.12031>;
  <D.12030>:
  D.12032 = &handle->u;
  memcpy (D.12032, handle_specific, 96);
  <D.12031>:
  <D.12020>:
  <D.12017>:
}


_wapi_handle_new_shared (WapiHandleType type, void * handle_specific)
{
  int _wapi_has_shut_down.37;
  _Bool D.12034;
  long int D.12035;
  long int D.12036;
  struct _WapiHandleSharedLayout * _wapi_shared_layout.38;
  <unnamed type> D.12040;
  _Bool D.12043;
  long int D.12044;
  long int D.12045;
  int type.39;
  WapiHandleType * D.12049;
  int D.12050;
  unsigned int last.40;
  guint32 D.12054;
  unsigned int last.41;
  guint32 offset;
  static guint32 last = 1;
  int thr_ret;
  void again = <<< error >>>;

  _wapi_has_shut_down.37 = _wapi_has_shut_down;
  D.12034 = _wapi_has_shut_down.37 != 0;
  D.12035 = (long int) D.12034;
  D.12036 = __builtin_expect (D.12035, 0);
  if (D.12036 != 0) goto <D.12037>; else goto <D.12038>;
  <D.12037>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 359, "_wapi_has_shut_down == FALSE");
  <D.12038>:
  again:
  offset = last;
  goto <D.11219>;
  <D.11218>:
  {
    struct _WapiHandleShared * handle;

    _wapi_shared_layout.38 = _wapi_shared_layout;
    handle = &_wapi_shared_layout.38->handles[offset];
    D.12040 = handle->type;
    if (D.12040 == 0) goto <D.12041>; else goto <D.12042>;
    <D.12041>:
    thr_ret = _wapi_handle_lock_shared_handles ();
    D.12043 = thr_ret != 0;
    D.12044 = (long int) D.12043;
    D.12045 = __builtin_expect (D.12044, 0);
    if (D.12045 != 0) goto <D.12046>; else goto <D.12047>;
    <D.12046>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 369, "thr_ret == 0");
    <D.12047>:
    type.39 = (int) type;
    D.12049 = &handle->type;
    D.12050 = InterlockedCompareExchange (D.12049, type.39, 0);
    if (D.12050 == 0) goto <D.12051>; else goto <D.12052>;
    <D.12051>:
    last.40 = offset + 1;
    last = last.40;
    _wapi_handle_init_shared (handle, type, handle_specific);
    _wapi_handle_unlock_shared_handles ();
    D.12054 = offset;
    return D.12054;
    <D.12052>:
    _wapi_handle_unlock_shared_handles ();
    <D.12042>:
  }
  offset = offset + 1;
  <D.11219>:
  if (offset <= 255) goto <D.11218>; else goto <D.11220>;
  <D.11220>:
  last.41 = last;
  if (last.41 > 1) goto <D.12056>; else goto <D.12057>;
  <D.12056>:
  last = 1;
  goto again;
  <D.12057>:
  D.12054 = 0;
  return D.12054;
}


InterlockedCompareExchange (volatile gint32 * dest, gint32 exch, gint32 comp)
{
  gint32 D.12059;
  unsigned int exch.42;
  unsigned int comp.43;
  unsigned int D.12062;

  exch.42 = (unsigned int) exch;
  comp.43 = (unsigned int) comp;
  D.12062 = __sync_val_compare_and_swap_4 (dest, comp.43, exch.42);
  D.12059 = (gint32) D.12062;
  return D.12059;
}


_wapi_handle_init_shared (struct _WapiHandleShared * handle, WapiHandleType type, void * handle_specific)
{
  int _wapi_has_shut_down.44;
  _Bool D.12065;
  long int D.12066;
  long int D.12067;
  long int D.12070;
  unsigned int D.12071;
  union 
{
  struct _WapiHandle_process process;
  struct _WapiHandle_namedmutex namedmutex;
  struct _WapiHandle_namedsem namedsem;
  struct _WapiHandle_namedevent namedevent;
} * D.12074;

  _wapi_has_shut_down.44 = _wapi_has_shut_down;
  D.12065 = _wapi_has_shut_down.44 != 0;
  D.12066 = (long int) D.12065;
  D.12067 = __builtin_expect (D.12066, 0);
  if (D.12067 != 0) goto <D.12068>; else goto <D.12069>;
  <D.12068>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 315, "_wapi_has_shut_down == FALSE");
  <D.12069>:
  handle->type = type;
  D.12070 = time (0B);
  D.12071 = (unsigned int) D.12070;
  handle->timestamp = D.12071;
  handle->signalled = 0;
  handle->handle_refs = 1;
  if (handle_specific != 0B) goto <D.12072>; else goto <D.12073>;
  <D.12072>:
  D.12074 = &handle->u;
  memcpy (D.12074, handle_specific, 320);
  <D.12073>:
}


_wapi_handle_new_from_offset (WapiHandleType type, guint32 offset, gboolean timestamp)
{
  int _wapi_has_shut_down.45;
  _Bool D.12076;
  long int D.12077;
  long int D.12078;
  int iftmp.46;
  unsigned int D.12085;
  _Bool D.12086;
  _Bool D.12087;
  _Bool D.12088;
  _Bool D.12090;
  long int D.12091;
  long int D.12092;
  int iftmp.47;
  _Bool D.12098;
  _Bool D.12099;
  _Bool D.12100;
  unsigned int D.12102;
  _Bool D.12104;
  long int D.12105;
  long int D.12106;
  _Bool D.12109;
  long int D.12110;
  long int D.12111;
  struct _WapiHandleSharedLayout * _wapi_shared_layout.48;
  long int D.12117;
  int now.49;
  guint32 * D.12119;
  long int D.12120;
  long int D.12121;
  _Bool D.12124;
  long int D.12125;
  long int D.12126;
  struct _WapiHandleUnshared * D.12129;
  long unsigned int D.12132;
  long unsigned int D.12133;
  <unnamed type> D.12134;
  unsigned int D.12137;
  int D.12140;
  int D.12141;
  long unsigned int D.12142;
  unsigned int i.50;
  unsigned int _wapi_private_handle_slot_count.51;
  void * D.12151;
  <unnamed type> D.12154;
  long int D.12157;
  long int D.12158;
  unsigned int _wapi_private_handle_count.52;
  unsigned int D.12164;
  void * D.12165;
  unsigned int _wapi_private_handle_count.53;
  unsigned int _wapi_private_handle_slot_count.54;
  unsigned int _wapi_fd_reserve.55;
  _Bool D.12173;
  long int D.12174;
  long int D.12175;
  long unsigned int D.12178;
  unsigned int D.12179;
  struct _WapiHandleUnshared * D.12180;
  long unsigned int D.12181;
  long unsigned int D.12182;
  struct _WapiHandleUnshared * D.12183;
  guint32 * D.12184;
  guint32 handle_idx;
  void * handle;
  int thr_ret;
  int i;
  int k;
  struct _WapiHandleShared * shared;
  void first_pass_done = <<< error >>>;
  void done = <<< error >>>;

  handle_idx = 0;
  handle = -1B;
  _wapi_has_shut_down.45 = _wapi_has_shut_down;
  D.12076 = _wapi_has_shut_down.45 != 0;
  D.12077 = (long int) D.12076;
  D.12078 = __builtin_expect (D.12077, 0);
  if (D.12078 != 0) goto <D.12079>; else goto <D.12080>;
  <D.12079>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 541, "_wapi_has_shut_down == FALSE");
  <D.12080>:
  D.12085 = type + 4294967295;
  D.12086 = D.12085 <= 1;
  D.12087 = type == 7;
  D.12088 = D.12086 | D.12087;
  if (D.12088 != 0) goto <D.12082>; else goto <D.12089>;
  <D.12089>:
  if (type == 10) goto <D.12082>; else goto <D.12083>;
  <D.12082>:
  iftmp.46 = 1;
  goto <D.12084>;
  <D.12083>:
  iftmp.46 = 0;
  <D.12084>:
  D.12090 = iftmp.46 != 0;
  D.12091 = (long int) D.12090;
  D.12092 = __builtin_expect (D.12091, 0);
  if (D.12092 != 0) goto <D.12093>; else goto <D.12094>;
  <D.12093>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 546, "!_WAPI_FD_HANDLE(type)");
  <D.12094>:
  D.12098 = type != 9;
  D.12099 = type != 11;
  D.12100 = D.12098 & D.12099;
  if (D.12100 != 0) goto <D.12101>; else goto <D.12096>;
  <D.12101>:
  D.12102 = type + 4294967284;
  if (D.12102 > 1) goto <D.12103>; else goto <D.12096>;
  <D.12103>:
  iftmp.47 = 1;
  goto <D.12097>;
  <D.12096>:
  iftmp.47 = 0;
  <D.12097>:
  D.12104 = iftmp.47 != 0;
  D.12105 = (long int) D.12104;
  D.12106 = __builtin_expect (D.12105, 0);
  if (D.12106 != 0) goto <D.12107>; else goto <D.12108>;
  <D.12107>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 547, "_WAPI_SHARED_HANDLE(type)");
  <D.12108>:
  D.12109 = offset == 0;
  D.12110 = (long int) D.12109;
  D.12111 = __builtin_expect (D.12110, 0);
  if (D.12111 != 0) goto <D.12112>; else goto <D.12113>;
  <D.12112>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 548, "offset != 0");
  <D.12113>:
  _wapi_shared_layout.48 = _wapi_shared_layout;
  shared = &_wapi_shared_layout.48->handles[offset];
  if (timestamp != 0) goto <D.12115>; else goto <D.12116>;
  <D.12115>:
  {
    guint32 now;

    D.12117 = time (0B);
    now = (guint32) D.12117;
    now.49 = (int) now;
    D.12119 = &shared->timestamp;
    InterlockedExchange (D.12119, now.49);
  }
  <D.12116>:
  {
    struct __pthread_unwind_buf_t __cancel_buf;
    void (*<Tc2>) (void *) __cancel_routine;
    void * __cancel_arg;
    int __not_first_call;

    try
      {
        __cancel_routine = mono_mutex_unlock_in_cleanup;
        __cancel_arg = &scan_mutex;
        __not_first_call = __sigsetjmp (&__cancel_buf.__cancel_jmp_buf, 0);
        D.12120 = (long int) __not_first_call;
        D.12121 = __builtin_expect (D.12120, 0);
        if (D.12121 != 0) goto <D.12122>; else goto <D.12123>;
        <D.12122>:
        __cancel_routine (__cancel_arg);
        __pthread_unwind_next (&__cancel_buf);
        <D.12123>:
        __pthread_register_cancel (&__cancel_buf);
        thr_ret = pthread_mutex_lock (&scan_mutex);
        D.12124 = thr_ret != 0;
        D.12125 = (long int) D.12124;
        D.12126 = __builtin_expect (D.12125, 0);
        if (D.12126 != 0) goto <D.12127>; else goto <D.12128>;
        <D.12127>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 560, "thr_ret == 0");
        <D.12128>:
        i = 0;
        goto <D.11281>;
        <D.11280>:
        D.12129 = _wapi_private_handles[i];
        if (D.12129 != 0B) goto <D.12130>; else goto <D.12131>;
        <D.12130>:
        k = 0;
        goto <D.11278>;
        <D.11277>:
        {
          struct _WapiHandleUnshared * handle_data;

          D.12129 = _wapi_private_handles[i];
          D.12132 = (long unsigned int) k;
          D.12133 = D.12132 * 200;
          handle_data = D.12129 + D.12133;
          D.12134 = handle_data->type;
          if (D.12134 == type) goto <D.12135>; else goto <D.12136>;
          <D.12135>:
          D.12137 = handle_data->u.shared.offset;
          if (D.12137 == offset) goto <D.12138>; else goto <D.12139>;
          <D.12138>:
          D.12140 = i * 256;
          D.12141 = D.12140 + k;
          D.12142 = (long unsigned int) D.12141;
          handle = (void *) D.12142;
          goto first_pass_done;
          <D.12139>:
          <D.12136>:
        }
        k = k + 1;
        <D.11278>:
        if (k <= 255) goto <D.11277>; else goto <D.11279>;
        <D.11279>:
        <D.12131>:
        i = i + 1;
        <D.11281>:
        i.50 = (unsigned int) i;
        _wapi_private_handle_slot_count.51 = _wapi_private_handle_slot_count;
        if (i.50 < _wapi_private_handle_slot_count.51) goto <D.11280>; else goto <D.11282>;
        <D.11282>:
        first_pass_done:
        thr_ret = pthread_mutex_unlock (&scan_mutex);
        D.12124 = thr_ret != 0;
        D.12125 = (long int) D.12124;
        D.12126 = __builtin_expect (D.12125, 0);
        if (D.12126 != 0) goto <D.12145>; else goto <D.12146>;
        <D.12145>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 578, "thr_ret == 0");
        <D.12146>:
        __pthread_unregister_cancel (&__cancel_buf);
        if (0 != 0) goto <D.12147>; else goto <D.12148>;
        <D.12147>:
        __cancel_routine (__cancel_arg);
        <D.12148>:
      }
    finally
      {
        __cancel_buf = {CLOBBER};
      }
  }
  if (handle != -1B) goto <D.12149>; else goto <D.12150>;
  <D.12149>:
  _wapi_handle_ref (handle);
  D.12151 = handle;
  return D.12151;
  <D.12150>:
  thr_ret = _wapi_handle_lock_shared_handles ();
  D.12124 = thr_ret != 0;
  D.12125 = (long int) D.12124;
  D.12126 = __builtin_expect (D.12125, 0);
  if (D.12126 != 0) goto <D.12152>; else goto <D.12153>;
  <D.12152>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 591, "thr_ret == 0");
  <D.12153>:
  D.12154 = shared->type;
  if (D.12154 == 0) goto done; else goto <D.12155>;
  <D.12155>:
  D.12154 = shared->type;
  if (D.12154 != type) goto done; else goto <D.12156>;
  <D.12156>:
  {
    struct __pthread_unwind_buf_t __cancel_buf;
    void (*<Tc2>) (void *) __cancel_routine;
    void * __cancel_arg;
    int __not_first_call;

    try
      {
        __cancel_routine = mono_mutex_unlock_in_cleanup;
        __cancel_arg = &scan_mutex;
        __not_first_call = __sigsetjmp (&__cancel_buf.__cancel_jmp_buf, 0);
        D.12157 = (long int) __not_first_call;
        D.12158 = __builtin_expect (D.12157, 0);
        if (D.12158 != 0) goto <D.12159>; else goto <D.12160>;
        <D.12159>:
        __cancel_routine (__cancel_arg);
        __pthread_unwind_next (&__cancel_buf);
        <D.12160>:
        __pthread_register_cancel (&__cancel_buf);
        thr_ret = pthread_mutex_lock (&scan_mutex);
        D.12124 = thr_ret != 0;
        D.12125 = (long int) D.12124;
        D.12126 = __builtin_expect (D.12125, 0);
        if (D.12126 != 0) goto <D.12161>; else goto <D.12162>;
        <D.12161>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 610, "thr_ret == 0");
        <D.12162>:
        goto <D.11292>;
        <D.11291>:
        {
          int idx;

          _wapi_private_handle_count.52 = _wapi_private_handle_count;
          D.12164 = _wapi_private_handle_count.52 / 256;
          idx = (int) D.12164;
          D.12165 = monoeg_malloc0 (51200);
          _wapi_private_handles[idx] = D.12165;
          _wapi_private_handle_count.52 = _wapi_private_handle_count;
          _wapi_private_handle_count.53 = _wapi_private_handle_count.52 + 256;
          _wapi_private_handle_count = _wapi_private_handle_count.53;
          _wapi_private_handle_slot_count.51 = _wapi_private_handle_slot_count;
          _wapi_private_handle_slot_count.54 = _wapi_private_handle_slot_count.51 + 1;
          _wapi_private_handle_slot_count = _wapi_private_handle_slot_count.54;
        }
        <D.11292>:
        handle_idx = _wapi_handle_new_internal (type, 0B);
        if (handle_idx == 0) goto <D.11291>; else goto <D.11293>;
        <D.11293>:
        thr_ret = pthread_mutex_unlock (&scan_mutex);
        D.12124 = thr_ret != 0;
        D.12125 = (long int) D.12124;
        D.12126 = __builtin_expect (D.12125, 0);
        if (D.12126 != 0) goto <D.12168>; else goto <D.12169>;
        <D.12168>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 623, "thr_ret == 0");
        <D.12169>:
        __pthread_unregister_cancel (&__cancel_buf);
        if (0 != 0) goto <D.12170>; else goto <D.12171>;
        <D.12170>:
        __cancel_routine (__cancel_arg);
        <D.12171>:
      }
    finally
      {
        __cancel_buf = {CLOBBER};
      }
  }
  _wapi_fd_reserve.55 = _wapi_fd_reserve;
  D.12173 = handle_idx < _wapi_fd_reserve.55;
  D.12174 = (long int) D.12173;
  D.12175 = __builtin_expect (D.12174, 0);
  if (D.12175 != 0) goto <D.12176>; else goto <D.12177>;
  <D.12176>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 627, "handle_idx >= _wapi_fd_reserve");
  <D.12177>:
  D.12178 = (long unsigned int) handle_idx;
  handle = (void *) D.12178;
  D.12179 = handle_idx / 256;
  D.12180 = _wapi_private_handles[D.12179];
  D.12178 = (long unsigned int) handle_idx;
  D.12181 = D.12178 & 255;
  D.12182 = D.12181 * 200;
  D.12183 = D.12180 + D.12182;
  D.12183->u.shared.offset = offset;
  D.12184 = &shared->handle_refs;
  InterlockedIncrement (D.12184);
  done:
  _wapi_handle_unlock_shared_handles ();
  D.12151 = handle;
  return D.12151;
}


InterlockedExchange (volatile gint32 * val, gint32 new_val)
{
  unsigned int new_val.56;
  unsigned int old_val.57;
  unsigned int D.12195;
  int D.12196;
  gint32 D.12197;
  gint32 old_val;

  <D.10869>:
  old_val = *val;
  new_val.56 = (unsigned int) new_val;
  old_val.57 = (unsigned int) old_val;
  D.12195 = __sync_val_compare_and_swap_4 (val, old_val.57, new_val.56);
  D.12196 = (int) D.12195;
  if (D.12196 != old_val) goto <D.10869>; else goto <D.10870>;
  <D.10870>:
  D.12197 = old_val;
  return D.12197;
}


InterlockedIncrement (volatile gint32 * val)
{
  gint32 D.12199;
  unsigned int D.12200;

  D.12200 = __sync_add_and_fetch_4 (val, 1);
  D.12199 = (gint32) D.12200;
  return D.12199;
}


_wapi_handle_new_fd (WapiHandleType type, int fd, void * handle_specific)
{
  int _wapi_has_shut_down.58;
  _Bool D.12203;
  long int D.12204;
  long int D.12205;
  int iftmp.59;
  unsigned int D.12211;
  _Bool D.12212;
  _Bool D.12213;
  _Bool D.12214;
  _Bool D.12217;
  long int D.12218;
  long int D.12219;
  int iftmp.60;
  _Bool D.12226;
  _Bool D.12227;
  _Bool D.12228;
  unsigned int D.12230;
  _Bool D.12231;
  long int D.12232;
  long int D.12233;
  unsigned int fd.61;
  unsigned int _wapi_fd_reserve.62;
  void * D.12240;
  int D.12241;
  struct _WapiHandleUnshared * D.12242;
  int D.12245;
  long unsigned int D.12246;
  long unsigned int D.12247;
  <unnamed type> D.12248;
  _Bool D.12251;
  long int D.12252;
  long int D.12253;
  long unsigned int D.12256;
  struct _WapiHandleUnshared * handle;
  int thr_ret;

  _wapi_has_shut_down.58 = _wapi_has_shut_down;
  D.12203 = _wapi_has_shut_down.58 != 0;
  D.12204 = (long int) D.12203;
  D.12205 = __builtin_expect (D.12204, 0);
  if (D.12205 != 0) goto <D.12206>; else goto <D.12207>;
  <D.12206>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 669, "_wapi_has_shut_down == FALSE");
  <D.12207>:
  D.12211 = type + 4294967295;
  D.12212 = D.12211 > 1;
  D.12213 = type != 7;
  D.12214 = D.12212 & D.12213;
  if (D.12214 != 0) goto <D.12215>; else goto <D.12209>;
  <D.12215>:
  if (type != 10) goto <D.12216>; else goto <D.12209>;
  <D.12216>:
  iftmp.59 = 1;
  goto <D.12210>;
  <D.12209>:
  iftmp.59 = 0;
  <D.12210>:
  D.12217 = iftmp.59 != 0;
  D.12218 = (long int) D.12217;
  D.12219 = __builtin_expect (D.12218, 0);
  if (D.12219 != 0) goto <D.12220>; else goto <D.12221>;
  <D.12220>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 674, "_WAPI_FD_HANDLE(type)");
  <D.12221>:
  D.12226 = type == 9;
  D.12227 = type == 11;
  D.12228 = D.12226 | D.12227;
  if (D.12228 != 0) goto <D.12223>; else goto <D.12229>;
  <D.12229>:
  D.12230 = type + 4294967284;
  if (D.12230 <= 1) goto <D.12223>; else goto <D.12224>;
  <D.12223>:
  iftmp.60 = 1;
  goto <D.12225>;
  <D.12224>:
  iftmp.60 = 0;
  <D.12225>:
  D.12231 = iftmp.60 != 0;
  D.12232 = (long int) D.12231;
  D.12233 = __builtin_expect (D.12232, 0);
  if (D.12233 != 0) goto <D.12234>; else goto <D.12235>;
  <D.12234>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 675, "!_WAPI_SHARED_HANDLE(type)");
  <D.12235>:
  fd.61 = (unsigned int) fd;
  _wapi_fd_reserve.62 = _wapi_fd_reserve;
  if (fd.61 >= _wapi_fd_reserve.62) goto <D.12238>; else goto <D.12239>;
  <D.12238>:
  D.12240 = -1B;
  return D.12240;
  <D.12239>:
  D.12241 = fd / 256;
  D.12242 = _wapi_private_handles[D.12241];
  if (D.12242 == 0B) goto <D.12243>; else goto <D.12244>;
  <D.12243>:
  D.12241 = fd / 256;
  init_handles_slot (D.12241);
  <D.12244>:
  D.12241 = fd / 256;
  D.12242 = _wapi_private_handles[D.12241];
  D.12245 = fd % 256;
  D.12246 = (long unsigned int) D.12245;
  D.12247 = D.12246 * 200;
  handle = D.12242 + D.12247;
  D.12248 = handle->type;
  if (D.12248 != 0) goto <D.12249>; else goto <D.12250>;
  <D.12249>:
  <D.12250>:
  thr_ret = _wapi_shm_sem_lock (2);
  D.12251 = thr_ret != 0;
  D.12252 = (long int) D.12251;
  D.12253 = __builtin_expect (D.12252, 0);
  if (D.12253 != 0) goto <D.12254>; else goto <D.12255>;
  <D.12254>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 702, "thr_ret == 0");
  <D.12255>:
  _wapi_handle_init (handle, type, handle_specific);
  thr_ret = _wapi_shm_sem_unlock (2);
  D.12256 = (long unsigned int) fd;
  D.12240 = (void *) D.12256;
  return D.12240;
}


init_handles_slot (int idx)
{
  long int D.12258;
  long int D.12259;
  _Bool D.12262;
  long int D.12263;
  long int D.12264;
  struct _WapiHandleUnshared * D.12267;
  void * D.12270;
  _Bool D.12271;
  long int D.12272;
  long int D.12273;
  int thr_ret;

  {
    struct __pthread_unwind_buf_t __cancel_buf;
    void (*<Tc2>) (void *) __cancel_routine;
    void * __cancel_arg;
    int __not_first_call;

    try
      {
        __cancel_routine = mono_mutex_unlock_in_cleanup;
        __cancel_arg = &scan_mutex;
        __not_first_call = __sigsetjmp (&__cancel_buf.__cancel_jmp_buf, 0);
        D.12258 = (long int) __not_first_call;
        D.12259 = __builtin_expect (D.12258, 0);
        if (D.12259 != 0) goto <D.12260>; else goto <D.12261>;
        <D.12260>:
        __cancel_routine (__cancel_arg);
        __pthread_unwind_next (&__cancel_buf);
        <D.12261>:
        __pthread_register_cancel (&__cancel_buf);
        thr_ret = pthread_mutex_lock (&scan_mutex);
        D.12262 = thr_ret != 0;
        D.12263 = (long int) D.12262;
        D.12264 = __builtin_expect (D.12263, 0);
        if (D.12264 != 0) goto <D.12265>; else goto <D.12266>;
        <D.12265>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 650, "thr_ret == 0");
        <D.12266>:
        D.12267 = _wapi_private_handles[idx];
        if (D.12267 == 0B) goto <D.12268>; else goto <D.12269>;
        <D.12268>:
        D.12270 = monoeg_malloc0 (51200);
        _wapi_private_handles[idx] = D.12270;
        D.12267 = _wapi_private_handles[idx];
        D.12271 = D.12267 == 0B;
        D.12272 = (long int) D.12271;
        D.12273 = __builtin_expect (D.12272, 0);
        if (D.12273 != 0) goto <D.12274>; else goto <D.12275>;
        <D.12274>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 655, "_wapi_private_handles [idx]");
        <D.12275>:
        <D.12269>:
        thr_ret = pthread_mutex_unlock (&scan_mutex);
        D.12262 = thr_ret != 0;
        D.12263 = (long int) D.12262;
        D.12264 = __builtin_expect (D.12263, 0);
        if (D.12264 != 0) goto <D.12276>; else goto <D.12277>;
        <D.12276>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 659, "thr_ret == 0");
        <D.12277>:
        __pthread_unregister_cancel (&__cancel_buf);
        if (0 != 0) goto <D.12278>; else goto <D.12279>;
        <D.12278>:
        __cancel_routine (__cancel_arg);
        <D.12279>:
      }
    finally
      {
        __cancel_buf = {CLOBBER};
      }
  }
}


_wapi_lookup_handle (void * handle, WapiHandleType type, void * * handle_specific)
{
  long int handle.63;
  gboolean D.12286;
  unsigned int D.12287;
  struct _WapiHandleUnshared * D.12288;
  int D.12291;
  long unsigned int D.12292;
  long unsigned int D.12293;
  long unsigned int D.12294;
  <unnamed type> D.12295;
  _Bool D.12303;
  _Bool D.12304;
  _Bool D.12305;
  unsigned int D.12307;
  struct _WapiHandleSharedLayout * _wapi_shared_layout.64;
  unsigned int D.12309;
  <unnamed type> D.12310;
  union 
{
  struct _WapiHandle_process process;
  struct _WapiHandle_namedmutex namedmutex;
  struct _WapiHandle_namedsem namedsem;
  struct _WapiHandle_namedevent namedevent;
} * D.12313;
  union 
{
  struct _WapiHandle_event event;
  struct _WapiHandle_file file;
  struct _WapiHandle_find find;
  struct _WapiHandle_mutex mutex;
  struct _WapiHandle_sem sem;
  struct _WapiHandle_socket sock;
  struct _WapiHandle_thread thread;
  struct _WapiHandle_shared_ref shared;
} * D.12314;
  struct _WapiHandleUnshared * handle_data;
  guint32 handle_idx;

  handle.63 = (long int) handle;
  handle_idx = (guint32) handle.63;
  if (handle_idx > 4194303) goto <D.12284>; else goto <D.12285>;
  <D.12284>:
  D.12286 = 0;
  return D.12286;
  <D.12285>:
  D.12287 = handle_idx / 256;
  D.12288 = _wapi_private_handles[D.12287];
  if (D.12288 == 0B) goto <D.12289>; else goto <D.12290>;
  <D.12289>:
  D.12287 = handle_idx / 256;
  D.12291 = (int) D.12287;
  init_handles_slot (D.12291);
  <D.12290>:
  D.12287 = handle_idx / 256;
  D.12288 = _wapi_private_handles[D.12287];
  D.12292 = (long unsigned int) handle_idx;
  D.12293 = D.12292 & 255;
  D.12294 = D.12293 * 200;
  handle_data = D.12288 + D.12294;
  D.12295 = handle_data->type;
  if (D.12295 != type) goto <D.12296>; else goto <D.12297>;
  <D.12296>:
  D.12286 = 0;
  return D.12286;
  <D.12297>:
  if (handle_specific == 0B) goto <D.12298>; else goto <D.12299>;
  <D.12298>:
  D.12286 = 0;
  return D.12286;
  <D.12299>:
  D.12303 = type == 9;
  D.12304 = type == 11;
  D.12305 = D.12303 | D.12304;
  if (D.12305 != 0) goto <D.12300>; else goto <D.12306>;
  <D.12306>:
  D.12307 = type + 4294967284;
  if (D.12307 <= 1) goto <D.12300>; else goto <D.12301>;
  <D.12300>:
  {
    struct _WapiHandle_shared_ref * ref;
    struct _WapiHandleShared * shared_handle_data;

    ref = &handle_data->u.shared;
    _wapi_shared_layout.64 = _wapi_shared_layout;
    D.12309 = ref->offset;
    shared_handle_data = &_wapi_shared_layout.64->handles[D.12309];
    D.12310 = shared_handle_data->type;
    if (D.12310 != type) goto <D.12311>; else goto <D.12312>;
    <D.12311>:
    D.12286 = 0;
    return D.12286;
    <D.12312>:
    D.12313 = &shared_handle_data->u;
    *handle_specific = D.12313;
  }
  goto <D.12302>;
  <D.12301>:
  D.12314 = &handle_data->u;
  *handle_specific = D.12314;
  <D.12302>:
  D.12286 = 1;
  return D.12286;
}


_wapi_handle_foreach (WapiHandleType type, gboolean (*<T19f0>) (void *, void *) on_each, void * user_data)
{
  long int D.12316;
  long int D.12317;
  _Bool D.12320;
  long int D.12321;
  long int D.12322;
  struct _WapiHandleUnshared * D.12325;
  long unsigned int D.12328;
  long unsigned int D.12329;
  <unnamed type> D.12330;
  unsigned int D.12333;
  unsigned int D.12334;
  long unsigned int D.12335;
  int D.12336;
  unsigned int _wapi_private_handle_slot_count.65;
  struct _WapiHandleUnshared * handle_data;
  void * ret;
  guint32 i;
  guint32 k;
  int thr_ret;

  handle_data = 0B;
  ret = 0B;
  {
    struct __pthread_unwind_buf_t __cancel_buf;
    void (*<Tc2>) (void *) __cancel_routine;
    void * __cancel_arg;
    int __not_first_call;

    try
      {
        __cancel_routine = mono_mutex_unlock_in_cleanup;
        __cancel_arg = &scan_mutex;
        __not_first_call = __sigsetjmp (&__cancel_buf.__cancel_jmp_buf, 0);
        D.12316 = (long int) __not_first_call;
        D.12317 = __builtin_expect (D.12316, 0);
        if (D.12317 != 0) goto <D.12318>; else goto <D.12319>;
        <D.12318>:
        __cancel_routine (__cancel_arg);
        __pthread_unwind_next (&__cancel_buf);
        <D.12319>:
        __pthread_register_cancel (&__cancel_buf);
        thr_ret = pthread_mutex_lock (&scan_mutex);
        D.12320 = thr_ret != 0;
        D.12321 = (long int) D.12320;
        D.12322 = __builtin_expect (D.12321, 0);
        if (D.12322 != 0) goto <D.12323>; else goto <D.12324>;
        <D.12323>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 769, "thr_ret == 0");
        <D.12324>:
        i = 0;
        goto <D.11342>;
        <D.11341>:
        D.12325 = _wapi_private_handles[i];
        if (D.12325 != 0B) goto <D.12326>; else goto <D.12327>;
        <D.12326>:
        k = 0;
        goto <D.11340>;
        <D.11339>:
        D.12325 = _wapi_private_handles[i];
        D.12328 = (long unsigned int) k;
        D.12329 = D.12328 * 200;
        handle_data = D.12325 + D.12329;
        D.12330 = handle_data->type;
        if (D.12330 == type) goto <D.12331>; else goto <D.12332>;
        <D.12331>:
        D.12333 = i * 256;
        D.12334 = D.12333 + k;
        D.12335 = (long unsigned int) D.12334;
        ret = (void *) D.12335;
        D.12336 = on_each (ret, user_data);
        if (D.12336 == 1) goto <D.11338>; else goto <D.12337>;
        <D.12337>:
        <D.12332>:
        k = k + 1;
        <D.11340>:
        if (k <= 255) goto <D.11339>; else goto <D.11338>;
        <D.11338>:
        <D.12327>:
        i = i + 1;
        <D.11342>:
        _wapi_private_handle_slot_count.65 = _wapi_private_handle_slot_count;
        if (i < _wapi_private_handle_slot_count.65) goto <D.11341>; else goto <D.11343>;
        <D.11343>:
        thr_ret = pthread_mutex_unlock (&scan_mutex);
        D.12320 = thr_ret != 0;
        D.12321 = (long int) D.12320;
        D.12322 = __builtin_expect (D.12321, 0);
        if (D.12322 != 0) goto <D.12339>; else goto <D.12340>;
        <D.12339>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 786, "thr_ret == 0");
        <D.12340>:
        __pthread_unregister_cancel (&__cancel_buf);
        if (0 != 0) goto <D.12341>; else goto <D.12342>;
        <D.12341>:
        __cancel_routine (__cancel_arg);
        <D.12342>:
      }
    finally
      {
        __cancel_buf = {CLOBBER};
      }
  }
}


_wapi_search_handle (WapiHandleType type, gboolean (*<T19f0>) (void *, void *) check, void * user_data, void * * handle_specific, gboolean search_shared)
{
  long int D.12346;
  long int D.12347;
  _Bool D.12350;
  long int D.12351;
  long int D.12352;
  struct _WapiHandleUnshared * D.12355;
  long unsigned int D.12358;
  long unsigned int D.12359;
  <unnamed type> D.12360;
  unsigned int D.12363;
  unsigned int D.12364;
  long unsigned int D.12365;
  int D.12366;
  _Bool D.12371;
  _Bool D.12372;
  _Bool D.12373;
  unsigned int D.12375;
  struct _WapiHandleSharedLayout * _wapi_shared_layout.66;
  unsigned int _wapi_private_handle_slot_count.67;
  _Bool D.12384;
  _Bool D.12385;
  _Bool D.12386;
  <unnamed type> D.12390;
  int D.12395;
  long int D.12402;
  int now.68;
  guint32 * D.12404;
  long int ret.69;
  unsigned int D.12406;
  unsigned int D.12407;
  struct _WapiHandleUnshared * D.12408;
  long unsigned int D.12409;
  long unsigned int D.12410;
  long unsigned int D.12411;
  _Bool D.12420;
  long int D.12421;
  long int D.12422;
  union 
{
  struct _WapiHandle_process process;
  struct _WapiHandle_namedmutex namedmutex;
  struct _WapiHandle_namedsem namedsem;
  struct _WapiHandle_namedevent namedevent;
} * D.12425;
  union 
{
  struct _WapiHandle_event event;
  struct _WapiHandle_file file;
  struct _WapiHandle_find find;
  struct _WapiHandle_mutex mutex;
  struct _WapiHandle_sem sem;
  struct _WapiHandle_socket sock;
  struct _WapiHandle_thread thread;
  struct _WapiHandle_shared_ref shared;
} * D.12426;
  void * D.12427;
  struct _WapiHandleUnshared * handle_data;
  struct _WapiHandleShared * shared;
  void * ret;
  guint32 i;
  guint32 k;
  gboolean found;
  int thr_ret;
  void done = <<< error >>>;

  handle_data = 0B;
  shared = 0B;
  ret = 0B;
  found = 0;
  {
    struct __pthread_unwind_buf_t __cancel_buf;
    void (*<Tc2>) (void *) __cancel_routine;
    void * __cancel_arg;
    int __not_first_call;

    try
      {
        __cancel_routine = mono_mutex_unlock_in_cleanup;
        __cancel_arg = &scan_mutex;
        __not_first_call = __sigsetjmp (&__cancel_buf.__cancel_jmp_buf, 0);
        D.12346 = (long int) __not_first_call;
        D.12347 = __builtin_expect (D.12346, 0);
        if (D.12347 != 0) goto <D.12348>; else goto <D.12349>;
        <D.12348>:
        __cancel_routine (__cancel_arg);
        __pthread_unwind_next (&__cancel_buf);
        <D.12349>:
        __pthread_register_cancel (&__cancel_buf);
        thr_ret = pthread_mutex_lock (&scan_mutex);
        D.12350 = thr_ret != 0;
        D.12351 = (long int) D.12350;
        D.12352 = __builtin_expect (D.12351, 0);
        if (D.12352 != 0) goto <D.12353>; else goto <D.12354>;
        <D.12353>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 814, "thr_ret == 0");
        <D.12354>:
        i = 0;
        goto <D.11370>;
        <D.11369>:
        D.12355 = _wapi_private_handles[i];
        if (D.12355 != 0B) goto <D.12356>; else goto <D.12357>;
        <D.12356>:
        k = 0;
        goto <D.11368>;
        <D.11367>:
        D.12355 = _wapi_private_handles[i];
        D.12358 = (long unsigned int) k;
        D.12359 = D.12358 * 200;
        handle_data = D.12355 + D.12359;
        D.12360 = handle_data->type;
        if (D.12360 == type) goto <D.12361>; else goto <D.12362>;
        <D.12361>:
        D.12363 = i * 256;
        D.12364 = D.12363 + k;
        D.12365 = (long unsigned int) D.12364;
        ret = (void *) D.12365;
        D.12366 = check (ret, user_data);
        if (D.12366 == 1) goto <D.12367>; else goto <D.12368>;
        <D.12367>:
        _wapi_handle_ref (ret);
        found = 1;
        D.12371 = type == 9;
        D.12372 = type == 11;
        D.12373 = D.12371 | D.12372;
        if (D.12373 != 0) goto <D.12369>; else goto <D.12374>;
        <D.12374>:
        D.12375 = type + 4294967284;
        if (D.12375 <= 1) goto <D.12369>; else goto <D.12370>;
        <D.12369>:
        _wapi_shared_layout.66 = _wapi_shared_layout;
        shared = &_wapi_shared_layout.66->handles[i];
        <D.12370>:
        goto <D.11366>;
        <D.12368>:
        <D.12362>:
        k = k + 1;
        <D.11368>:
        if (k <= 255) goto <D.11367>; else goto <D.11366>;
        <D.11366>:
        <D.12357>:
        i = i + 1;
        <D.11370>:
        if (found == 0) goto <D.12377>; else goto <D.11371>;
        <D.12377>:
        _wapi_private_handle_slot_count.67 = _wapi_private_handle_slot_count;
        if (i < _wapi_private_handle_slot_count.67) goto <D.11369>; else goto <D.11371>;
        <D.11371>:
        thr_ret = pthread_mutex_unlock (&scan_mutex);
        D.12350 = thr_ret != 0;
        D.12351 = (long int) D.12350;
        D.12352 = __builtin_expect (D.12351, 0);
        if (D.12352 != 0) goto <D.12379>; else goto <D.12380>;
        <D.12379>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 839, "thr_ret == 0");
        <D.12380>:
        __pthread_unregister_cancel (&__cancel_buf);
        if (0 != 0) goto <D.12381>; else goto <D.12382>;
        <D.12381>:
        __cancel_routine (__cancel_arg);
        <D.12382>:
      }
    finally
      {
        __cancel_buf = {CLOBBER};
      }
  }
  D.12384 = found == 0;
  D.12385 = search_shared != 0;
  D.12386 = D.12384 & D.12385;
  if (D.12386 != 0) goto <D.12387>; else goto <D.12388>;
  <D.12387>:
  D.12371 = type == 9;
  D.12372 = type == 11;
  D.12373 = D.12371 | D.12372;
  if (D.12373 != 0) goto <D.12383>; else goto <D.12389>;
  <D.12389>:
  D.12375 = type + 4294967284;
  if (D.12375 <= 1) goto <D.12383>; else goto <D.11374>;
  <D.12383>:
  i = 0;
  goto <D.11376>;
  <D.11375>:
  _wapi_shared_layout.66 = _wapi_shared_layout;
  shared = &_wapi_shared_layout.66->handles[i];
  D.12390 = shared->type;
  if (D.12390 == type) goto <D.12391>; else goto <D.12392>;
  <D.12391>:
  ret = _wapi_handle_new_from_offset (type, i, 0);
  if (ret == -1B) goto <D.12393>; else goto <D.12394>;
  <D.12393>:
  // predicted unlikely by continue predictor.
  goto <D.11372>;
  <D.12394>:
  D.12395 = check (ret, user_data);
  if (D.12395 == 1) goto <D.12396>; else goto <D.12397>;
  <D.12396>:
  thr_ret = _wapi_handle_lock_shared_handles ();
  D.12350 = thr_ret != 0;
  D.12351 = (long int) D.12350;
  D.12352 = __builtin_expect (D.12351, 0);
  if (D.12352 != 0) goto <D.12398>; else goto <D.12399>;
  <D.12398>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 881, "thr_ret == 0");
  <D.12399>:
  D.12390 = shared->type;
  if (D.12390 == type) goto <D.12400>; else goto <D.12401>;
  <D.12400>:
  {
    guint32 now;

    D.12402 = time (0B);
    now = (guint32) D.12402;
    now.68 = (int) now;
    D.12404 = &shared->timestamp;
    InterlockedExchange (D.12404, now.68);
    found = 1;
    ret.69 = (long int) ret;
    D.12406 = (unsigned int) ret.69;
    D.12407 = D.12406 / 256;
    D.12408 = _wapi_private_handles[D.12407];
    ret.69 = (long int) ret;
    D.12406 = (unsigned int) ret.69;
    D.12409 = (long unsigned int) D.12406;
    D.12410 = D.12409 & 255;
    D.12411 = D.12410 * 200;
    handle_data = D.12408 + D.12411;
    _wapi_handle_unlock_shared_handles ();
    goto <D.11374>;
  }
  <D.12401>:
  _wapi_handle_unlock_shared_handles ();
  <D.12397>:
  _wapi_handle_unref (ret);
  <D.12392>:
  <D.11372>:
  i = i + 1;
  <D.11376>:
  if (i <= 255) goto <D.11375>; else goto <D.11374>;
  <D.11374>:
  <D.12388>:
  if (found == 0) goto <D.12412>; else goto <D.12413>;
  <D.12412>:
  ret = 0B;
  goto done;
  <D.12413>:
  if (handle_specific != 0B) goto <D.12414>; else goto <D.12415>;
  <D.12414>:
  D.12371 = type == 9;
  D.12372 = type == 11;
  D.12373 = D.12371 | D.12372;
  if (D.12373 != 0) goto <D.12416>; else goto <D.12419>;
  <D.12419>:
  D.12375 = type + 4294967284;
  if (D.12375 <= 1) goto <D.12416>; else goto <D.12417>;
  <D.12416>:
  D.12390 = shared->type;
  D.12420 = D.12390 != type;
  D.12421 = (long int) D.12420;
  D.12422 = __builtin_expect (D.12421, 0);
  if (D.12422 != 0) goto <D.12423>; else goto <D.12424>;
  <D.12423>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 917, "shared->type == type");
  <D.12424>:
  D.12425 = &shared->u;
  *handle_specific = D.12425;
  goto <D.12418>;
  <D.12417>:
  D.12426 = &handle_data->u;
  *handle_specific = D.12426;
  <D.12418>:
  <D.12415>:
  done:
  D.12427 = ret;
  return D.12427;
}


_wapi_search_handle_namespace (WapiHandleType type, gchar * utf8_name)
{
  int iftmp.70;
  _Bool D.12438;
  _Bool D.12439;
  _Bool D.12440;
  unsigned int D.12442;
  _Bool D.12444;
  long int D.12445;
  long int D.12446;
  _Bool D.12449;
  long int D.12450;
  long int D.12451;
  struct _WapiHandleSharedLayout * _wapi_shared_layout.71;
  <unnamed type> D.12455;
  unsigned int D.12456;
  int D.11396;
  gchar[261] * D.12459;
  gint32 D.12464;
  struct _WapiHandleShared * shared_handle_data;
  guint32 i;
  gint32 ret;
  int thr_ret;
  void done = <<< error >>>;

  ret = 0;
  D.12438 = type != 9;
  D.12439 = type != 11;
  D.12440 = D.12438 & D.12439;
  if (D.12440 != 0) goto <D.12441>; else goto <D.12436>;
  <D.12441>:
  D.12442 = type + 4294967284;
  if (D.12442 > 1) goto <D.12443>; else goto <D.12436>;
  <D.12443>:
  iftmp.70 = 1;
  goto <D.12437>;
  <D.12436>:
  iftmp.70 = 0;
  <D.12437>:
  D.12444 = iftmp.70 != 0;
  D.12445 = (long int) D.12444;
  D.12446 = __builtin_expect (D.12445, 0);
  if (D.12446 != 0) goto <D.12447>; else goto <D.12448>;
  <D.12447>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 940, "_WAPI_SHARED_HANDLE(type)");
  <D.12448>:
  _wapi_handle_collect ();
  thr_ret = _wapi_handle_lock_shared_handles ();
  D.12449 = thr_ret != 0;
  D.12450 = (long int) D.12449;
  D.12451 = __builtin_expect (D.12450, 0);
  if (D.12451 != 0) goto <D.12452>; else goto <D.12453>;
  <D.12452>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 951, "thr_ret == 0");
  <D.12453>:
  i = 1;
  goto <D.11399>;
  <D.11398>:
  {
    struct WapiSharedNamespace * sharedns;

    _wapi_shared_layout.71 = _wapi_shared_layout;
    shared_handle_data = &_wapi_shared_layout.71->handles[i];
    D.12455 = shared_handle_data->type;
    D.12456 = D.12455 + 4294967285;
    if (D.12456 > 2) goto <D.12457>; else goto <D.12458>;
    <D.12457>:
    // predicted unlikely by continue predictor.
    goto <D.11387>;
    <D.12458>:
    sharedns = &shared_handle_data->u;
    {
      size_t __s1_len;
      size_t __s2_len;

      D.12459 = &sharedns->name;
      D.11396 = __builtin_strcmp (D.12459, utf8_name);
    }
    if (D.11396 == 0) goto <D.12460>; else goto <D.12461>;
    <D.12460>:
    D.12455 = shared_handle_data->type;
    if (D.12455 != type) goto <D.12462>; else goto <D.12463>;
    <D.12462>:
    ret = -1;
    goto done;
    <D.12463>:
    ret = (gint32) i;
    goto done;
    <D.12461>:
  }
  <D.11387>:
  i = i + 1;
  <D.11399>:
  if (i <= 255) goto <D.11398>; else goto <D.11400>;
  <D.11400>:
  done:
  _wapi_handle_unlock_shared_handles ();
  D.12464 = ret;
  return D.12464;
}


_wapi_handle_ref (void * handle)
{
  long int handle.72;
  <unnamed type> D.12469;
  unsigned int D.12472;
  struct _WapiHandleUnshared * D.12473;
  long unsigned int D.12474;
  long unsigned int D.12475;
  long unsigned int D.12476;
  guint * D.12477;
  <unnamed type> D.12480;
  _Bool D.12481;
  _Bool D.12482;
  _Bool D.12483;
  <unnamed type> D.12485;
  struct _WapiHandleSharedLayout * _wapi_shared_layout.73;
  unsigned int D.12488;
  long int D.12489;
  int now.74;
  guint32 * D.12491;
  guint32 idx;
  struct _WapiHandleUnshared * handle_data;
  static const char __func__[17] = "_wapi_handle_ref";

  handle.72 = (long int) handle;
  idx = (guint32) handle.72;
  if (idx > 4194303) goto <D.12467>; else goto <D.12468>;
  <D.12467>:
  return;
  <D.12468>:
  D.12469 = _wapi_handle_type (handle);
  if (D.12469 == 0) goto <D.12470>; else goto <D.12471>;
  <D.12470>:
  monoeg_g_log (0B, 16, "%s: Attempting to ref unused handle %p", &__func__, handle);
  return;
  <D.12471>:
  D.12472 = idx / 256;
  D.12473 = _wapi_private_handles[D.12472];
  D.12474 = (long unsigned int) idx;
  D.12475 = D.12474 & 255;
  D.12476 = D.12475 * 200;
  handle_data = D.12473 + D.12476;
  D.12477 = &handle_data->ref;
  InterlockedIncrement (D.12477);
  D.12480 = handle_data->type;
  D.12481 = D.12480 == 9;
  D.12482 = D.12480 == 11;
  D.12483 = D.12481 | D.12482;
  if (D.12483 != 0) goto <D.12478>; else goto <D.12484>;
  <D.12484>:
  D.12485 = handle_data->type;
  if (D.12485 == 12) goto <D.12478>; else goto <D.12486>;
  <D.12486>:
  D.12485 = handle_data->type;
  if (D.12485 == 13) goto <D.12478>; else goto <D.12479>;
  <D.12478>:
  {
    struct _WapiHandleShared * shared_data;
    guint32 now;

    _wapi_shared_layout.73 = _wapi_shared_layout;
    D.12488 = handle_data->u.shared.offset;
    shared_data = &_wapi_shared_layout.73->handles[D.12488];
    D.12489 = time (0B);
    now = (guint32) D.12489;
    now.74 = (int) now;
    D.12491 = &shared_data->timestamp;
    InterlockedExchange (D.12491, now.74);
  }
  <D.12479>:
}


_wapi_handle_unref (void * handle)
{
  _wapi_handle_unref_full (handle, 0);
}


_wapi_handle_register_capabilities (WapiHandleType type, WapiHandleCapability caps)
{
  handle_caps[type] = caps;
}


_wapi_handle_test_capabilities (void * handle, WapiHandleCapability caps)
{
  long int handle.75;
  gboolean D.12496;
  unsigned int D.12497;
  struct _WapiHandleUnshared * D.12498;
  long unsigned int D.12499;
  long unsigned int D.12500;
  long unsigned int D.12501;
  struct _WapiHandleUnshared * D.12502;
  <unnamed type> D.12503;
  unsigned int D.12504;
  _Bool D.12505;
  guint32 idx;
  WapiHandleType type;

  handle.75 = (long int) handle;
  idx = (guint32) handle.75;
  if (idx > 4194303) goto <D.12494>; else goto <D.12495>;
  <D.12494>:
  D.12496 = 0;
  return D.12496;
  <D.12495>:
  D.12497 = idx / 256;
  D.12498 = _wapi_private_handles[D.12497];
  D.12499 = (long unsigned int) idx;
  D.12500 = D.12499 & 255;
  D.12501 = D.12500 * 200;
  D.12502 = D.12498 + D.12501;
  type = D.12502->type;
  D.12503 = handle_caps[type];
  D.12504 = D.12503 & caps;
  D.12505 = D.12504 != 0;
  D.12496 = (gboolean) D.12505;
  return D.12496;
}


_wapi_handle_ops_close (void * handle, void * data)
{
  long int handle.76;
  unsigned int D.12510;
  struct _WapiHandleUnshared * D.12511;
  long unsigned int D.12512;
  long unsigned int D.12513;
  long unsigned int D.12514;
  struct _WapiHandleUnshared * D.12515;
  struct _WapiHandleOps * D.12516;
  void (*<Tc67>) (void *, void *) D.12519;
  guint32 idx;
  WapiHandleType type;

  handle.76 = (long int) handle;
  idx = (guint32) handle.76;
  if (idx > 4194303) goto <D.12508>; else goto <D.12509>;
  <D.12508>:
  return;
  <D.12509>:
  D.12510 = idx / 256;
  D.12511 = _wapi_private_handles[D.12510];
  D.12512 = (long unsigned int) idx;
  D.12513 = D.12512 & 255;
  D.12514 = D.12513 * 200;
  D.12515 = D.12511 + D.12514;
  type = D.12515->type;
  D.12516 = handle_ops[type];
  if (D.12516 != 0B) goto <D.12517>; else goto <D.12518>;
  <D.12517>:
  D.12516 = handle_ops[type];
  D.12519 = D.12516->close;
  if (D.12519 != 0B) goto <D.12520>; else goto <D.12521>;
  <D.12520>:
  D.12516 = handle_ops[type];
  D.12519 = D.12516->close;
  D.12519 (handle, data);
  <D.12521>:
  <D.12518>:
}


_wapi_handle_ops_signal (void * handle)
{
  long int handle.77;
  unsigned int D.12526;
  struct _WapiHandleUnshared * D.12527;
  long unsigned int D.12528;
  long unsigned int D.12529;
  long unsigned int D.12530;
  struct _WapiHandleUnshared * D.12531;
  struct _WapiHandleOps * D.12532;
  void (*<Tbd4>) (void *) D.12535;
  guint32 idx;
  WapiHandleType type;

  handle.77 = (long int) handle;
  idx = (guint32) handle.77;
  if (idx > 4194303) goto <D.12524>; else goto <D.12525>;
  <D.12524>:
  return;
  <D.12525>:
  D.12526 = idx / 256;
  D.12527 = _wapi_private_handles[D.12526];
  D.12528 = (long unsigned int) idx;
  D.12529 = D.12528 & 255;
  D.12530 = D.12529 * 200;
  D.12531 = D.12527 + D.12530;
  type = D.12531->type;
  D.12532 = handle_ops[type];
  if (D.12532 != 0B) goto <D.12533>; else goto <D.12534>;
  <D.12533>:
  D.12532 = handle_ops[type];
  D.12535 = D.12532->signal;
  if (D.12535 != 0B) goto <D.12536>; else goto <D.12537>;
  <D.12536>:
  D.12532 = handle_ops[type];
  D.12535 = D.12532->signal;
  D.12535 (handle);
  <D.12537>:
  <D.12534>:
}


_wapi_handle_ops_own (void * handle)
{
  long int handle.78;
  gboolean D.12542;
  unsigned int D.12543;
  struct _WapiHandleUnshared * D.12544;
  long unsigned int D.12545;
  long unsigned int D.12546;
  long unsigned int D.12547;
  struct _WapiHandleUnshared * D.12548;
  struct _WapiHandleOps * D.12550;
  gboolean (*<T1851>) (void *) D.12552;
  guint32 idx;
  WapiHandleType type;

  handle.78 = (long int) handle;
  idx = (guint32) handle.78;
  if (idx > 4194303) goto <D.12540>; else goto <D.12541>;
  <D.12540>:
  D.12542 = 0;
  return D.12542;
  <D.12541>:
  D.12543 = idx / 256;
  D.12544 = _wapi_private_handles[D.12543];
  D.12545 = (long unsigned int) idx;
  D.12546 = D.12545 & 255;
  D.12547 = D.12546 * 200;
  D.12548 = D.12544 + D.12547;
  type = D.12548->type;
  D.12550 = handle_ops[type];
  if (D.12550 != 0B) goto <D.12551>; else goto <D.12549>;
  <D.12551>:
  D.12550 = handle_ops[type];
  D.12552 = D.12550->own_handle;
  if (D.12552 != 0B) goto <D.12553>; else goto <D.12549>;
  <D.12553>:
  D.12550 = handle_ops[type];
  D.12552 = D.12550->own_handle;
  D.12542 = D.12552 (handle);
  return D.12542;
  <D.12549>:
  D.12542 = 0;
  return D.12542;
}


_wapi_handle_ops_isowned (void * handle)
{
  long int handle.79;
  gboolean D.12558;
  unsigned int D.12559;
  struct _WapiHandleUnshared * D.12560;
  long unsigned int D.12561;
  long unsigned int D.12562;
  long unsigned int D.12563;
  struct _WapiHandleUnshared * D.12564;
  struct _WapiHandleOps * D.12566;
  gboolean (*<T1851>) (void *) D.12568;
  guint32 idx;
  WapiHandleType type;

  handle.79 = (long int) handle;
  idx = (guint32) handle.79;
  if (idx > 4194303) goto <D.12556>; else goto <D.12557>;
  <D.12556>:
  D.12558 = 0;
  return D.12558;
  <D.12557>:
  D.12559 = idx / 256;
  D.12560 = _wapi_private_handles[D.12559];
  D.12561 = (long unsigned int) idx;
  D.12562 = D.12561 & 255;
  D.12563 = D.12562 * 200;
  D.12564 = D.12560 + D.12563;
  type = D.12564->type;
  D.12566 = handle_ops[type];
  if (D.12566 != 0B) goto <D.12567>; else goto <D.12565>;
  <D.12567>:
  D.12566 = handle_ops[type];
  D.12568 = D.12566->is_owned;
  if (D.12568 != 0B) goto <D.12569>; else goto <D.12565>;
  <D.12569>:
  D.12566 = handle_ops[type];
  D.12568 = D.12566->is_owned;
  D.12558 = D.12568 (handle);
  return D.12558;
  <D.12565>:
  D.12558 = 0;
  return D.12558;
}


_wapi_handle_ops_special_wait (void * handle, guint32 timeout, gboolean alertable)
{
  long int handle.80;
  guint32 D.12574;
  unsigned int D.12575;
  struct _WapiHandleUnshared * D.12576;
  long unsigned int D.12577;
  long unsigned int D.12578;
  long unsigned int D.12579;
  struct _WapiHandleUnshared * D.12580;
  struct _WapiHandleOps * D.12582;
  guint32 (*<T1856>) (void *, guint32, gboolean) D.12584;
  guint32 idx;
  WapiHandleType type;

  handle.80 = (long int) handle;
  idx = (guint32) handle.80;
  if (idx > 4194303) goto <D.12572>; else goto <D.12573>;
  <D.12572>:
  D.12574 = 4294967295;
  return D.12574;
  <D.12573>:
  D.12575 = idx / 256;
  D.12576 = _wapi_private_handles[D.12575];
  D.12577 = (long unsigned int) idx;
  D.12578 = D.12577 & 255;
  D.12579 = D.12578 * 200;
  D.12580 = D.12576 + D.12579;
  type = D.12580->type;
  D.12582 = handle_ops[type];
  if (D.12582 != 0B) goto <D.12583>; else goto <D.12581>;
  <D.12583>:
  D.12582 = handle_ops[type];
  D.12584 = D.12582->special_wait;
  if (D.12584 != 0B) goto <D.12585>; else goto <D.12581>;
  <D.12585>:
  D.12582 = handle_ops[type];
  D.12584 = D.12582->special_wait;
  D.12574 = D.12584 (handle, timeout, alertable);
  return D.12574;
  <D.12581>:
  D.12574 = 4294967295;
  return D.12574;
}


_wapi_handle_ops_prewait (void * handle)
{
  long int handle.81;
  unsigned int D.12590;
  struct _WapiHandleUnshared * D.12591;
  long unsigned int D.12592;
  long unsigned int D.12593;
  long unsigned int D.12594;
  struct _WapiHandleUnshared * D.12595;
  struct _WapiHandleOps * D.12596;
  void (*<Tbd4>) (void *) D.12599;
  guint32 idx;
  WapiHandleType type;

  handle.81 = (long int) handle;
  idx = (guint32) handle.81;
  if (idx > 4194303) goto <D.12588>; else goto <D.12589>;
  <D.12588>:
  return;
  <D.12589>:
  D.12590 = idx / 256;
  D.12591 = _wapi_private_handles[D.12590];
  D.12592 = (long unsigned int) idx;
  D.12593 = D.12592 & 255;
  D.12594 = D.12593 * 200;
  D.12595 = D.12591 + D.12594;
  type = D.12595->type;
  D.12596 = handle_ops[type];
  if (D.12596 != 0B) goto <D.12597>; else goto <D.12598>;
  <D.12597>:
  D.12596 = handle_ops[type];
  D.12599 = D.12596->prewait;
  if (D.12599 != 0B) goto <D.12600>; else goto <D.12601>;
  <D.12600>:
  D.12596 = handle_ops[type];
  D.12599 = D.12596->prewait;
  D.12599 (handle);
  <D.12601>:
  <D.12598>:
}


CloseHandle (void * handle)
{
  struct _WapiHandleUnshared * D.12605;
  <unnamed type> D.12606;
  gboolean D.12609;

  if (handle == 0B) goto <D.12603>; else goto <D.12604>;
  <D.12603>:
  D.12605 = _wapi_private_handles[0];
  D.12606 = D.12605->type;
  if (D.12606 != 2) goto <D.12607>; else goto <D.12608>;
  <D.12607>:
  SetLastError (87);
  D.12609 = 0;
  return D.12609;
  <D.12608>:
  <D.12604>:
  if (handle == -1B) goto <D.12610>; else goto <D.12611>;
  <D.12610>:
  SetLastError (87);
  D.12609 = 0;
  return D.12609;
  <D.12611>:
  _wapi_handle_unref (handle);
  D.12609 = 1;
  return D.12609;
}


DuplicateHandle (void * srcprocess, void * src, void * targetprocess, void * * target, guint32 access, gboolean inherit, guint32 options)
{
  _Bool D.12613;
  _Bool D.12614;
  _Bool D.12615;
  gboolean D.12618;
  void * D.12621;
  void * D.12625;

  D.12613 = srcprocess != 4294967295B;
  D.12614 = targetprocess != 4294967295B;
  D.12615 = D.12613 | D.12614;
  if (D.12615 != 0) goto <D.12616>; else goto <D.12617>;
  <D.12616>:
  SetLastError (6);
  D.12618 = 0;
  return D.12618;
  <D.12617>:
  if (src == 4294967295B) goto <D.12619>; else goto <D.12620>;
  <D.12619>:
  D.12621 = _wapi_process_duplicate ();
  *target = D.12621;
  goto <D.12622>;
  <D.12620>:
  if (src == 4294967294B) goto <D.12623>; else goto <D.12624>;
  <D.12623>:
  D.12625 = _wapi_thread_duplicate ();
  *target = D.12625;
  goto <D.12626>;
  <D.12624>:
  _wapi_handle_ref (src);
  *target = src;
  <D.12626>:
  <D.12622>:
  D.12618 = 1;
  return D.12618;
}


_wapi_handle_count_signalled_handles (guint32 numhandles, void * * handles, gboolean waitall, guint32 * retcount, guint32 * lowest)
{
  _Bool D.12628;
  long int D.12629;
  long int D.12630;
  long unsigned int D.12633;
  long unsigned int D.12634;
  void * * D.12635;
  long int handle.82;
  unsigned int D.12637;
  struct _WapiHandleUnshared * D.12638;
  long unsigned int D.12639;
  long unsigned int D.12640;
  long unsigned int D.12641;
  struct _WapiHandleUnshared * D.12642;
  unsigned int i.83;
  unsigned int D.12652;
  long int handle.84;
  unsigned int D.12654;
  struct _WapiHandleUnshared * D.12655;
  long unsigned int D.12656;
  long unsigned int D.12657;
  long unsigned int D.12658;
  struct _WapiHandleUnshared * D.12659;
  int D.12665;
  int D.12667;
  _Bool D.12668;
  _Bool D.12669;
  _Bool D.12670;
  unsigned int D.12672;
  struct _WapiHandleSharedLayout * _wapi_shared_layout.85;
  unsigned int D.12674;
  unsigned int D.12675;
  struct _WapiHandleUnshared * D.12676;
  long unsigned int D.12677;
  long unsigned int D.12678;
  long unsigned int D.12679;
  struct _WapiHandleUnshared * D.12680;
  unsigned int D.12681;
  int D.12682;
  _Bool D.12683;
  _Bool D.12684;
  _Bool D.12685;
  int D.12688;
  unsigned int D.12689;
  _Bool D.12695;
  _Bool D.12696;
  _Bool D.12697;
  _Bool D.12699;
  _Bool D.12700;
  _Bool D.12701;
  gboolean D.12702;
  guint32 count;
  guint32 i;
  guint32 iter;
  gboolean ret;
  int thr_ret;
  WapiHandleType type;
  void again = <<< error >>>;
  static const char __func__[37] = "_wapi_handle_count_signalled_handles";

  iter = 0;
  again:
  thr_ret = _wapi_handle_lock_shared_handles ();
  D.12628 = thr_ret != 0;
  D.12629 = (long int) D.12628;
  D.12630 = __builtin_expect (D.12629, 0);
  if (D.12630 != 0) goto <D.12631>; else goto <D.12632>;
  <D.12631>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 1375, "thr_ret == 0");
  <D.12632>:
  i = 0;
  goto <D.11518>;
  <D.11517>:
  {
    void * handle;
    guint32 idx;

    D.12633 = (long unsigned int) i;
    D.12634 = D.12633 * 8;
    D.12635 = handles + D.12634;
    handle = *D.12635;
    handle.82 = (long int) handle;
    idx = (guint32) handle.82;
    D.12637 = idx / 256;
    D.12638 = _wapi_private_handles[D.12637];
    D.12639 = (long unsigned int) idx;
    D.12640 = D.12639 & 255;
    D.12641 = D.12640 * 200;
    D.12642 = D.12638 + D.12641;
    type = D.12642->type;
    thr_ret = _wapi_handle_trylock_handle (handle);
    if (thr_ret != 0) goto <D.12643>; else goto <D.12644>;
    <D.12643>:
    thr_ret = _wapi_handle_unlock_shared_handles ();
    D.12628 = thr_ret != 0;
    D.12629 = (long int) D.12628;
    D.12630 = __builtin_expect (D.12629, 0);
    if (D.12630 != 0) goto <D.12645>; else goto <D.12646>;
    <D.12645>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 1394, "thr_ret == 0");
    <D.12646>:
    goto <D.11514>;
    <D.11513>:
    D.12633 = (long unsigned int) i;
    D.12634 = D.12633 * 8;
    D.12635 = handles + D.12634;
    handle = *D.12635;
    handle.82 = (long int) handle;
    idx = (guint32) handle.82;
    thr_ret = _wapi_handle_unlock_handle (handle);
    D.12628 = thr_ret != 0;
    D.12629 = (long int) D.12628;
    D.12630 = __builtin_expect (D.12629, 0);
    if (D.12630 != 0) goto <D.12647>; else goto <D.12648>;
    <D.12647>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 1401, "thr_ret == 0");
    <D.12648>:
    <D.11514>:
    i.83 = i;
    i = i.83 + 4294967295;
    if (i.83 != 0) goto <D.11513>; else goto <D.11515>;
    <D.11515>:
    iter = iter + 1;
    if (iter == 100) goto <D.12650>; else goto <D.12651>;
    <D.12650>:
    monoeg_g_log (0B, 16, "%s: iteration overflow!", &__func__);
    iter = 1;
    <D.12651>:
    D.12652 = iter * 10;
    _wapi_handle_spin (D.12652);
    goto again;
    <D.12644>:
  }
  i = i + 1;
  <D.11518>:
  if (i < numhandles) goto <D.11517>; else goto <D.11519>;
  <D.11519>:
  count = 0;
  *lowest = numhandles;
  i = 0;
  goto <D.11523>;
  <D.11522>:
  {
    void * handle;
    guint32 idx;

    D.12633 = (long unsigned int) i;
    D.12634 = D.12633 * 8;
    D.12635 = handles + D.12634;
    handle = *D.12635;
    handle.84 = (long int) handle;
    idx = (guint32) handle.84;
    D.12654 = idx / 256;
    D.12655 = _wapi_private_handles[D.12654];
    D.12656 = (long unsigned int) idx;
    D.12657 = D.12656 & 255;
    D.12658 = D.12657 * 200;
    D.12659 = D.12655 + D.12658;
    type = D.12659->type;
    D.12665 = _wapi_handle_test_capabilities (handle, 4);
    if (D.12665 == 1) goto <D.12666>; else goto <D.12660>;
    <D.12666>:
    D.12667 = _wapi_handle_ops_isowned (handle);
    if (D.12667 == 1) goto <D.12661>; else goto <D.12660>;
    <D.12660>:
    D.12668 = type == 9;
    D.12669 = type == 11;
    D.12670 = D.12668 | D.12669;
    if (D.12670 != 0) goto <D.12662>; else goto <D.12671>;
    <D.12671>:
    D.12672 = type + 4294967284;
    if (D.12672 <= 1) goto <D.12662>; else goto <D.12663>;
    <D.12662>:
    _wapi_shared_layout.85 = _wapi_shared_layout;
    handle.84 = (long int) handle;
    D.12674 = (unsigned int) handle.84;
    D.12675 = D.12674 / 256;
    D.12676 = _wapi_private_handles[D.12675];
    handle.84 = (long int) handle;
    D.12674 = (unsigned int) handle.84;
    D.12677 = (long unsigned int) D.12674;
    D.12678 = D.12677 & 255;
    D.12679 = D.12678 * 200;
    D.12680 = D.12676 + D.12679;
    D.12681 = D.12680->u.shared.offset;
    D.12682 = _wapi_shared_layout.85->handles[D.12681].signalled;
    if (D.12682 == 1) goto <D.12661>; else goto <D.12663>;
    <D.12663>:
    D.12683 = type != 9;
    D.12684 = type != 11;
    D.12685 = D.12683 & D.12684;
    if (D.12685 != 0) goto <D.12686>; else goto <D.12664>;
    <D.12686>:
    D.12672 = type + 4294967284;
    if (D.12672 > 1) goto <D.12687>; else goto <D.12664>;
    <D.12687>:
    D.12654 = idx / 256;
    D.12655 = _wapi_private_handles[D.12654];
    D.12656 = (long unsigned int) idx;
    D.12657 = D.12656 & 255;
    D.12658 = D.12657 * 200;
    D.12659 = D.12655 + D.12658;
    D.12688 = D.12659->signalled;
    if (D.12688 == 1) goto <D.12661>; else goto <D.12664>;
    <D.12661>:
    count = count + 1;
    D.12689 = *lowest;
    if (D.12689 > i) goto <D.12690>; else goto <D.12691>;
    <D.12690>:
    *lowest = i;
    <D.12691>:
    <D.12664>:
  }
  i = i + 1;
  <D.11523>:
  if (i < numhandles) goto <D.11522>; else goto <D.11524>;
  <D.11524>:
  D.12695 = waitall == 1;
  D.12696 = count == numhandles;
  D.12697 = D.12695 & D.12696;
  if (D.12697 != 0) goto <D.12692>; else goto <D.12698>;
  <D.12698>:
  D.12699 = waitall == 0;
  D.12700 = count != 0;
  D.12701 = D.12699 & D.12700;
  if (D.12701 != 0) goto <D.12692>; else goto <D.12693>;
  <D.12692>:
  ret = 1;
  goto <D.12694>;
  <D.12693>:
  ret = 0;
  <D.12694>:
  *retcount = count;
  D.12702 = ret;
  return D.12702;
}


_wapi_handle_trylock_handle (void * handle)
{
  long int handle.86;
  int D.12707;
  <unnamed type> D.12710;
  <unnamed type> D.12712;
  <unnamed type> D.12714;
  <unnamed type> D.12716;
  unsigned int D.12717;
  struct _WapiHandleUnshared * D.12718;
  long unsigned int D.12719;
  long unsigned int D.12720;
  long unsigned int D.12721;
  struct _WapiHandleUnshared * D.12722;
  union mono_mutex_t * D.12723;
  guint32 idx;
  int ret;

  handle.86 = (long int) handle;
  idx = (guint32) handle.86;
  if (idx > 4194303) goto <D.12705>; else goto <D.12706>;
  <D.12705>:
  D.12707 = 0;
  return D.12707;
  <D.12706>:
  _wapi_handle_ref (handle);
  D.12710 = _wapi_handle_type (handle);
  if (D.12710 == 9) goto <D.12708>; else goto <D.12711>;
  <D.12711>:
  D.12712 = _wapi_handle_type (handle);
  if (D.12712 == 11) goto <D.12708>; else goto <D.12713>;
  <D.12713>:
  D.12714 = _wapi_handle_type (handle);
  if (D.12714 == 12) goto <D.12708>; else goto <D.12715>;
  <D.12715>:
  D.12716 = _wapi_handle_type (handle);
  if (D.12716 == 13) goto <D.12708>; else goto <D.12709>;
  <D.12708>:
  D.12707 = 0;
  return D.12707;
  <D.12709>:
  D.12717 = idx / 256;
  D.12718 = _wapi_private_handles[D.12717];
  D.12719 = (long unsigned int) idx;
  D.12720 = D.12719 & 255;
  D.12721 = D.12720 * 200;
  D.12722 = D.12718 + D.12721;
  D.12723 = &D.12722->signal_mutex;
  ret = pthread_mutex_trylock (D.12723);
  if (ret != 0) goto <D.12724>; else goto <D.12725>;
  <D.12724>:
  _wapi_handle_unref (handle);
  <D.12725>:
  D.12707 = ret;
  return D.12707;
}


_wapi_handle_unlock_handle (void * handle)
{
  long int handle.87;
  int D.12730;
  <unnamed type> D.12733;
  <unnamed type> D.12735;
  <unnamed type> D.12737;
  <unnamed type> D.12739;
  unsigned int D.12740;
  struct _WapiHandleUnshared * D.12741;
  long unsigned int D.12742;
  long unsigned int D.12743;
  long unsigned int D.12744;
  struct _WapiHandleUnshared * D.12745;
  union mono_mutex_t * D.12746;
  guint32 idx;
  int ret;

  handle.87 = (long int) handle;
  idx = (guint32) handle.87;
  if (idx > 4194303) goto <D.12728>; else goto <D.12729>;
  <D.12728>:
  D.12730 = 0;
  return D.12730;
  <D.12729>:
  D.12733 = _wapi_handle_type (handle);
  if (D.12733 == 9) goto <D.12731>; else goto <D.12734>;
  <D.12734>:
  D.12735 = _wapi_handle_type (handle);
  if (D.12735 == 11) goto <D.12731>; else goto <D.12736>;
  <D.12736>:
  D.12737 = _wapi_handle_type (handle);
  if (D.12737 == 12) goto <D.12731>; else goto <D.12738>;
  <D.12738>:
  D.12739 = _wapi_handle_type (handle);
  if (D.12739 == 13) goto <D.12731>; else goto <D.12732>;
  <D.12731>:
  _wapi_handle_unref (handle);
  D.12730 = 0;
  return D.12730;
  <D.12732>:
  D.12740 = idx / 256;
  D.12741 = _wapi_private_handles[D.12740];
  D.12742 = (long unsigned int) idx;
  D.12743 = D.12742 & 255;
  D.12744 = D.12743 * 200;
  D.12745 = D.12741 + D.12744;
  D.12746 = &D.12745->signal_mutex;
  ret = pthread_mutex_unlock (D.12746);
  _wapi_handle_unref (handle);
  D.12730 = ret;
  return D.12730;
}


_wapi_handle_spin (guint32 ms)
{
  _Bool D.12748;
  long int D.12749;
  long int D.12750;
  unsigned int D.12753;
  long int D.12754;
  struct timespec sleepytime;

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


_wapi_handle_unlock_handles (guint32 numhandles, void * * handles)
{
  _Bool D.12755;
  long int D.12756;
  long int D.12757;
  long unsigned int D.12760;
  long unsigned int D.12761;
  void * * D.12762;
  guint32 i;
  int thr_ret;

  thr_ret = _wapi_handle_unlock_shared_handles ();
  D.12755 = thr_ret != 0;
  D.12756 = (long int) D.12755;
  D.12757 = __builtin_expect (D.12756, 0);
  if (D.12757 != 0) goto <D.12758>; else goto <D.12759>;
  <D.12758>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 1474, "thr_ret == 0");
  <D.12759>:
  i = 0;
  goto <D.11533>;
  <D.11532>:
  {
    void * handle;

    D.12760 = (long unsigned int) i;
    D.12761 = D.12760 * 8;
    D.12762 = handles + D.12761;
    handle = *D.12762;
    thr_ret = _wapi_handle_unlock_handle (handle);
    D.12755 = thr_ret != 0;
    D.12756 = (long int) D.12755;
    D.12757 = __builtin_expect (D.12756, 0);
    if (D.12757 != 0) goto <D.12763>; else goto <D.12764>;
    <D.12763>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 1482, "thr_ret == 0");
    <D.12764>:
  }
  i = i + 1;
  <D.11533>:
  if (i < numhandles) goto <D.11532>; else goto <D.11534>;
  <D.11534>:
}


_wapi_handle_wait_signal (gboolean poll)
{
  int D.12765;
  void * _wapi_global_signal_handle.88;

  _wapi_global_signal_handle.88 = _wapi_global_signal_handle;
  D.12765 = _wapi_handle_timedwait_signal_handle (_wapi_global_signal_handle.88, 0B, 1, poll);
  return D.12765;
}


_wapi_handle_timedwait_signal (struct timespec * timeout, gboolean poll)
{
  int D.12768;
  void * _wapi_global_signal_handle.89;

  _wapi_global_signal_handle.89 = _wapi_global_signal_handle;
  D.12768 = _wapi_handle_timedwait_signal_handle (_wapi_global_signal_handle.89, timeout, 1, poll);
  return D.12768;
}


_wapi_handle_wait_signal_handle (void * handle, gboolean alertable)
{
  int D.12771;

  D.12771 = _wapi_handle_timedwait_signal_handle (handle, 0B, alertable, 0);
  return D.12771;
}


_wapi_handle_timedwait_signal_handle (void * handle, struct timespec * timeout, gboolean alertable, gboolean poll)
{
  <unnamed type> D.12775;
  <unnamed type> D.12777;
  <unnamed type> D.12779;
  <unnamed type> D.12781;
  struct _WapiHandleSharedLayout * _wapi_shared_layout.90;
  long int handle.91;
  unsigned int D.12784;
  unsigned int D.12785;
  struct _WapiHandleUnshared * D.12786;
  long unsigned int D.12787;
  long unsigned int D.12788;
  long unsigned int D.12789;
  struct _WapiHandleUnshared * D.12790;
  unsigned int D.12791;
  int D.12792;
  int D.12795;
  long int D.12800;
  long int D.12801;
  long int D.12804;
  long int D.12805;
  int D.12806;
  int D.12811;
  unsigned int D.12814;
  struct _WapiHandleUnshared * D.12815;
  long unsigned int D.12816;
  long unsigned int D.12817;
  long unsigned int D.12818;
  struct _WapiHandleUnshared * D.12819;

  D.12775 = _wapi_handle_type (handle);
  if (D.12775 == 9) goto <D.12773>; else goto <D.12776>;
  <D.12776>:
  D.12777 = _wapi_handle_type (handle);
  if (D.12777 == 11) goto <D.12773>; else goto <D.12778>;
  <D.12778>:
  D.12779 = _wapi_handle_type (handle);
  if (D.12779 == 12) goto <D.12773>; else goto <D.12780>;
  <D.12780>:
  D.12781 = _wapi_handle_type (handle);
  if (D.12781 == 13) goto <D.12773>; else goto <D.12774>;
  <D.12773>:
  _wapi_shared_layout.90 = _wapi_shared_layout;
  handle.91 = (long int) handle;
  D.12784 = (unsigned int) handle.91;
  D.12785 = D.12784 / 256;
  D.12786 = _wapi_private_handles[D.12785];
  handle.91 = (long int) handle;
  D.12784 = (unsigned int) handle.91;
  D.12787 = (long unsigned int) D.12784;
  D.12788 = D.12787 & 255;
  D.12789 = D.12788 * 200;
  D.12790 = D.12786 + D.12789;
  D.12791 = D.12790->u.shared.offset;
  D.12792 = _wapi_shared_layout.90->handles[D.12791].signalled;
  if (D.12792 == 1) goto <D.12793>; else goto <D.12794>;
  <D.12793>:
  D.12795 = 0;
  return D.12795;
  <D.12794>:
  if (timeout != 0B) goto <D.12796>; else goto <D.12797>;
  <D.12796>:
  {
    struct timespec fake_timeout;

    try
      {
        _wapi_calc_timeout (&fake_timeout, 100);
        D.12800 = fake_timeout.tv_sec;
        D.12801 = timeout->tv_sec;
        if (D.12800 > D.12801) goto <D.12798>; else goto <D.12802>;
        <D.12802>:
        D.12800 = fake_timeout.tv_sec;
        D.12801 = timeout->tv_sec;
        if (D.12800 == D.12801) goto <D.12803>; else goto <D.12799>;
        <D.12803>:
        D.12804 = fake_timeout.tv_nsec;
        D.12805 = timeout->tv_nsec;
        if (D.12804 > D.12805) goto <D.12798>; else goto <D.12799>;
        <D.12798>:
        _wapi_handle_spin (100);
        _wapi_shared_layout.90 = _wapi_shared_layout;
        handle.91 = (long int) handle;
        D.12784 = (unsigned int) handle.91;
        D.12785 = D.12784 / 256;
        D.12786 = _wapi_private_handles[D.12785];
        handle.91 = (long int) handle;
        D.12784 = (unsigned int) handle.91;
        D.12787 = (long unsigned int) D.12784;
        D.12788 = D.12787 & 255;
        D.12789 = D.12788 * 200;
        D.12790 = D.12786 + D.12789;
        D.12791 = D.12790->u.shared.offset;
        D.12806 = _wapi_shared_layout.90->handles[D.12791].signalled;
        if (D.12806 == 1) goto <D.12807>; else goto <D.12808>;
        <D.12807>:
        D.12795 = 0;
        return D.12795;
        <D.12808>:
        D.12795 = 110;
        return D.12795;
        <D.12799>:
      }
    finally
      {
        fake_timeout = {CLOBBER};
      }
  }
  <D.12797>:
  _wapi_handle_spin (100);
  D.12795 = 0;
  return D.12795;
  <D.12774>:
  {
    guint32 idx;
    int res;
    union pthread_cond_t * cond;
    union mono_mutex_t * mutex;

    handle.91 = (long int) handle;
    idx = (guint32) handle.91;
    if (alertable != 0) goto <D.12809>; else goto <D.12810>;
    <D.12809>:
    D.12811 = wapi_thread_set_wait_handle (handle);
    if (D.12811 == 0) goto <D.12812>; else goto <D.12813>;
    <D.12812>:
    D.12795 = 0;
    return D.12795;
    <D.12813>:
    <D.12810>:
    D.12814 = idx / 256;
    D.12815 = _wapi_private_handles[D.12814];
    D.12816 = (long unsigned int) idx;
    D.12817 = D.12816 & 255;
    D.12818 = D.12817 * 200;
    D.12819 = D.12815 + D.12818;
    cond = &D.12819->signal_cond;
    D.12814 = idx / 256;
    D.12815 = _wapi_private_handles[D.12814];
    D.12816 = (long unsigned int) idx;
    D.12817 = D.12816 & 255;
    D.12818 = D.12817 * 200;
    D.12819 = D.12815 + D.12818;
    mutex = &D.12819->signal_mutex;
    if (poll != 0) goto <D.12820>; else goto <D.12821>;
    <D.12820>:
    res = timedwait_signal_poll_cond (cond, mutex, timeout, alertable);
    goto <D.12822>;
    <D.12821>:
    if (timeout != 0B) goto <D.12823>; else goto <D.12824>;
    <D.12823>:
    res = pthread_cond_timedwait (cond, mutex, timeout);
    goto <D.12825>;
    <D.12824>:
    res = pthread_cond_wait (cond, mutex);
    <D.12825>:
    <D.12822>:
    if (alertable != 0) goto <D.12826>; else goto <D.12827>;
    <D.12826>:
    wapi_thread_clear_wait_handle (handle);
    <D.12827>:
    D.12795 = res;
    return D.12795;
  }
}


timedwait_signal_poll_cond (union pthread_cond_t * cond, union mono_mutex_t * mutex, struct timespec * timeout, gboolean alertable)
{
  long int D.12841;
  long int D.12842;
  long int D.12845;
  long int D.12846;
  int D.12849;
  struct timespec fake_timeout;
  int ret;

  try
    {
      if (alertable == 0) goto <D.12831>; else goto <D.12832>;
      <D.12831>:
      if (timeout != 0B) goto <D.12833>; else goto <D.12834>;
      <D.12833>:
      ret = pthread_cond_timedwait (cond, mutex, timeout);
      goto <D.12835>;
      <D.12834>:
      ret = pthread_cond_wait (cond, mutex);
      <D.12835>:
      goto <D.12836>;
      <D.12832>:
      _wapi_calc_timeout (&fake_timeout, 100);
      if (timeout != 0B) goto <D.12840>; else goto <D.12837>;
      <D.12840>:
      D.12841 = fake_timeout.tv_sec;
      D.12842 = timeout->tv_sec;
      if (D.12841 > D.12842) goto <D.12838>; else goto <D.12843>;
      <D.12843>:
      D.12841 = fake_timeout.tv_sec;
      D.12842 = timeout->tv_sec;
      if (D.12841 == D.12842) goto <D.12844>; else goto <D.12837>;
      <D.12844>:
      D.12845 = fake_timeout.tv_nsec;
      D.12846 = timeout->tv_nsec;
      if (D.12845 > D.12846) goto <D.12838>; else goto <D.12837>;
      <D.12838>:
      ret = pthread_cond_timedwait (cond, mutex, timeout);
      goto <D.12839>;
      <D.12837>:
      ret = pthread_cond_timedwait (cond, mutex, &fake_timeout);
      if (ret == 110) goto <D.12847>; else goto <D.12848>;
      <D.12847>:
      ret = 0;
      <D.12848>:
      <D.12839>:
      <D.12836>:
      D.12849 = ret;
      return D.12849;
    }
  finally
    {
      fake_timeout = {CLOBBER};
    }
}


_wapi_free_share_info (struct _WapiFileShare * share_info)
{
  int D.12852;
  _Bool D.12857;
  long int D.12858;
  long int D.12859;
  struct GHashTable * file_share_hash.92;
  _Bool D.12865;
  long int D.12866;
  long int D.12867;

  D.12852 = _wapi_shm_enabled ();
  if (D.12852 == 0) goto <D.12853>; else goto <D.12854>;
  <D.12853>:
  {
    int ret;

    ret = pthread_mutex_lock (&file_share_hash_mutex.mutex);
    if (ret != 0) goto <D.12855>; else goto <D.12856>;
    <D.12855>:
    monoeg_g_log (0B, 16, "Bad call to mono_mutex_lock result %d", ret);
    <D.12856>:
    D.12857 = ret != 0;
    D.12858 = (long int) D.12857;
    D.12859 = __builtin_expect (D.12858, 0);
    if (D.12859 != 0) goto <D.12860>; else goto <D.12861>;
    <D.12860>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 1602, "ret == 0");
    <D.12861>:
  }
  file_share_hash.92 = file_share_hash;
  monoeg_g_hash_table_remove (file_share_hash.92, share_info);
  {
    int ret;

    ret = pthread_mutex_unlock (&file_share_hash_mutex.mutex);
    if (ret != 0) goto <D.12863>; else goto <D.12864>;
    <D.12863>:
    monoeg_g_log (0B, 16, "Bad call to mono_mutex_unlock result %d", ret);
    <D.12864>:
    D.12865 = ret != 0;
    D.12866 = (long int) D.12865;
    D.12867 = __builtin_expect (D.12866, 0);
    if (D.12867 != 0) goto <D.12868>; else goto <D.12869>;
    <D.12868>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 1604, "ret == 0");
    <D.12869>:
  }
  goto <D.12870>;
  <D.12854>:
  memset (share_info, 0, 40);
  <D.12870>:
}


_wapi_handle_get_or_set_share (dev_t device, ino_t inode, guint32 new_sharemode, guint32 new_access, guint32 * old_sharemode, guint32 * old_access, struct _WapiFileShare * * share_info)
{
  long int D.12871;
  _Bool D.12872;
  long int D.12873;
  long int D.12874;
  int D.12879;
  struct GHashTable * file_share_hash.93;
  struct GHashTable * file_share_hash.94;
  _Bool D.12888;
  long int D.12889;
  long int D.12890;
  unsigned int D.12895;
  unsigned int D.12896;
  guint32 * D.12897;
  int D.12899;
  _Bool D.12902;
  long int D.12903;
  long int D.12904;
  struct _WapiFileShareLayout * _wapi_fileshare_layout.95;
  unsigned int D.12911;
  long unsigned int D.12916;
  long unsigned int D.12919;
  unsigned int i.96;
  unsigned int D.12923;
  _Bool D.12926;
  _Bool D.12927;
  _Bool D.12928;
  int D.12935;
  struct _WapiFileShare * D.12936;
  int now.97;
  guint32 * D.12940;
  gboolean D.12941;
  struct _WapiFileShare * file_share;
  guint32 now;
  int thr_ret;
  int i;
  int first_unused;
  gboolean exists;

  D.12871 = time (0B);
  now = (guint32) D.12871;
  first_unused = -1;
  exists = 0;
  thr_ret = _wapi_handle_lock_shared_handles ();
  D.12872 = thr_ret != 0;
  D.12873 = (long int) D.12872;
  D.12874 = __builtin_expect (D.12873, 0);
  if (D.12874 != 0) goto <D.12875>; else goto <D.12876>;
  <D.12875>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 1643, "thr_ret == 0");
  <D.12876>:
  thr_ret = _wapi_shm_sem_lock (2);
  D.12872 = thr_ret != 0;
  D.12873 = (long int) D.12872;
  D.12874 = __builtin_expect (D.12873, 0);
  if (D.12874 != 0) goto <D.12877>; else goto <D.12878>;
  <D.12877>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 1647, "thr_ret == 0");
  <D.12878>:
  D.12879 = _wapi_shm_enabled ();
  if (D.12879 == 0) goto <D.12880>; else goto <D.12881>;
  <D.12880>:
  {
    struct _WapiFileShare tmp;

    try
      {
        file_share_hash.93 = file_share_hash;
        if (file_share_hash.93 == 0B) goto <D.12883>; else goto <D.12884>;
        <D.12883>:
        file_share_hash.94 = monoeg_g_hash_table_new_full (wapi_share_info_hash, wapi_share_info_equal, 0B, monoeg_g_free);
        file_share_hash = file_share_hash.94;
        InitializeCriticalSection (&file_share_hash_mutex);
        <D.12884>:
        tmp.device = device;
        tmp.inode = inode;
        {
          int ret;

          ret = pthread_mutex_lock (&file_share_hash_mutex.mutex);
          if (ret != 0) goto <D.12886>; else goto <D.12887>;
          <D.12886>:
          monoeg_g_log (0B, 16, "Bad call to mono_mutex_lock result %d", ret);
          <D.12887>:
          D.12888 = ret != 0;
          D.12889 = (long int) D.12888;
          D.12890 = __builtin_expect (D.12889, 0);
          if (D.12890 != 0) goto <D.12891>; else goto <D.12892>;
          <D.12891>:
          monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 1665, "ret == 0");
          <D.12892>:
        }
        file_share_hash.93 = file_share_hash;
        file_share = monoeg_g_hash_table_lookup (file_share_hash.93, &tmp);
        if (file_share != 0B) goto <D.12893>; else goto <D.12894>;
        <D.12893>:
        D.12895 = file_share->sharemode;
        *old_sharemode = D.12895;
        D.12896 = file_share->access;
        *old_access = D.12896;
        *share_info = file_share;
        D.12897 = &file_share->handle_refs;
        InterlockedIncrement (D.12897);
        exists = 1;
        goto <D.12898>;
        <D.12894>:
        file_share = monoeg_malloc0 (40);
        file_share->device = device;
        file_share->inode = inode;
        D.12899 = _wapi_getpid ();
        file_share->opened_by_pid = D.12899;
        file_share->sharemode = new_sharemode;
        file_share->access = new_access;
        file_share->handle_refs = 1;
        *share_info = file_share;
        file_share_hash.93 = file_share_hash;
        monoeg_g_hash_table_insert_replace (file_share_hash.93, file_share, file_share, 0);
        <D.12898>:
        {
          int ret;

          ret = pthread_mutex_unlock (&file_share_hash_mutex.mutex);
          if (ret != 0) goto <D.12900>; else goto <D.12901>;
          <D.12900>:
          monoeg_g_log (0B, 16, "Bad call to mono_mutex_unlock result %d", ret);
          <D.12901>:
          D.12902 = ret != 0;
          D.12903 = (long int) D.12902;
          D.12904 = __builtin_expect (D.12903, 0);
          if (D.12904 != 0) goto <D.12905>; else goto <D.12906>;
          <D.12905>:
          monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 1689, "ret == 0");
          <D.12906>:
        }
      }
    finally
      {
        tmp = {CLOBBER};
      }
  }
  goto <D.12907>;
  <D.12881>:
  *share_info = 0B;
  i = 0;
  goto <D.11601>;
  <D.11600>:
  _wapi_fileshare_layout.95 = _wapi_fileshare_layout;
  file_share = &_wapi_fileshare_layout.95->share_info[i];
  if (first_unused == -1) goto <D.12909>; else goto <D.12910>;
  <D.12909>:
  D.12911 = file_share->handle_refs;
  if (D.12911 == 0) goto <D.12912>; else goto <D.12913>;
  <D.12912>:
  first_unused = i;
  // predicted unlikely by continue predictor.
  goto <D.11598>;
  <D.12913>:
  <D.12910>:
  D.12911 = file_share->handle_refs;
  if (D.12911 == 0) goto <D.12914>; else goto <D.12915>;
  <D.12914>:
  // predicted unlikely by continue predictor.
  goto <D.11598>;
  <D.12915>:
  D.12916 = file_share->device;
  if (D.12916 == device) goto <D.12917>; else goto <D.12918>;
  <D.12917>:
  D.12919 = file_share->inode;
  if (D.12919 == inode) goto <D.12920>; else goto <D.12921>;
  <D.12920>:
  D.12895 = file_share->sharemode;
  *old_sharemode = D.12895;
  D.12896 = file_share->access;
  *old_access = D.12896;
  *share_info = file_share;
  D.12897 = &file_share->handle_refs;
  InterlockedIncrement (D.12897);
  exists = 1;
  goto <D.11599>;
  <D.12921>:
  <D.12918>:
  <D.11598>:
  i = i + 1;
  <D.11601>:
  i.96 = (unsigned int) i;
  _wapi_fileshare_layout.95 = _wapi_fileshare_layout;
  D.12923 = _wapi_fileshare_layout.95->hwm;
  if (i.96 <= D.12923) goto <D.11600>; else goto <D.11599>;
  <D.11599>:
  if (exists == 0) goto <D.12924>; else goto <D.12925>;
  <D.12924>:
  D.12926 = i == 102400;
  D.12927 = first_unused == -1;
  D.12928 = D.12926 & D.12927;
  if (D.12928 != 0) goto <D.12929>; else goto <D.12930>;
  <D.12929>:
  goto <D.12931>;
  <D.12930>:
  if (first_unused == -1) goto <D.12932>; else goto <D.12933>;
  <D.12932>:
  _wapi_fileshare_layout.95 = _wapi_fileshare_layout;
  i = i + 1;
  file_share = &_wapi_fileshare_layout.95->share_info[i];
  _wapi_fileshare_layout.95 = _wapi_fileshare_layout;
  i.96 = (unsigned int) i;
  _wapi_fileshare_layout.95->hwm = i.96;
  goto <D.12934>;
  <D.12933>:
  _wapi_fileshare_layout.95 = _wapi_fileshare_layout;
  file_share = &_wapi_fileshare_layout.95->share_info[first_unused];
  <D.12934>:
  file_share->device = device;
  file_share->inode = inode;
  D.12935 = _wapi_getpid ();
  file_share->opened_by_pid = D.12935;
  file_share->sharemode = new_sharemode;
  file_share->access = new_access;
  file_share->handle_refs = 1;
  *share_info = file_share;
  <D.12931>:
  <D.12925>:
  D.12936 = *share_info;
  if (D.12936 != 0B) goto <D.12937>; else goto <D.12938>;
  <D.12937>:
  now.97 = (int) now;
  D.12936 = *share_info;
  D.12940 = &D.12936->timestamp;
  InterlockedExchange (D.12940, now.97);
  <D.12938>:
  <D.12907>:
  thr_ret = _wapi_shm_sem_unlock (2);
  _wapi_handle_unlock_shared_handles ();
  D.12941 = exists;
  return D.12941;
}


wapi_share_info_equal (const void * ka, const void * kb)
{
  gint D.12943;
  int iftmp.98;
  long unsigned int D.12947;
  long unsigned int D.12948;
  long unsigned int D.12950;
  long unsigned int D.12951;
  const struct _WapiFileShare * s1;
  const struct _WapiFileShare * s2;

  s1 = ka;
  s2 = kb;
  D.12947 = s1->device;
  D.12948 = s2->device;
  if (D.12947 == D.12948) goto <D.12949>; else goto <D.12945>;
  <D.12949>:
  D.12950 = s1->inode;
  D.12951 = s2->inode;
  if (D.12950 == D.12951) goto <D.12952>; else goto <D.12945>;
  <D.12952>:
  iftmp.98 = 1;
  goto <D.12946>;
  <D.12945>:
  iftmp.98 = 0;
  <D.12946>:
  D.12943 = iftmp.98;
  return D.12943;
}


wapi_share_info_hash (const void * data)
{
  guint D.12954;
  long unsigned int D.12955;
  const struct _WapiFileShare * s;

  s = data;
  D.12955 = s->inode;
  D.12954 = (guint) D.12955;
  return D.12954;
}


_wapi_handle_check_share (struct _WapiFileShare * share_info, int fd)
{
  _Bool D.12957;
  long int D.12958;
  long int D.12959;
  int D.12964;
  int D.12967;
  struct _WapiHandleUnshared * D.12968;
  int D.12971;
  long unsigned int D.12972;
  long unsigned int D.12973;
  <unnamed type> D.12976;
  struct _WapiFileShare * D.12979;
  unsigned int i.99;
  unsigned int _wapi_fd_reserve.100;
  struct _WapiHandleSharedLayout * _wapi_shared_layout.101;
  <unnamed type> D.12984;
  int D.11637;
  int iftmp.102;
  int D.11636;
  const char[2] * D.12994;
  unsigned char D.12995;
  int D.12996;
  unsigned char D.12997;
  int D.12998;
  _Bool D.12999;
  _Bool D.13000;
  _Bool D.13001;
  const unsigned char * D.13004;
  unsigned char D.13005;
  int D.13006;
  const unsigned char * D.13007;
  unsigned char D.13008;
  int D.13009;
  _Bool D.13010;
  _Bool D.13011;
  const unsigned char * D.13014;
  unsigned char D.13015;
  int D.13016;
  const unsigned char * D.13017;
  unsigned char D.13018;
  int D.13019;
  _Bool D.13020;
  _Bool D.13021;
  const unsigned char * D.13024;
  unsigned char D.13025;
  int D.13026;
  const unsigned char * D.13027;
  unsigned char D.13028;
  int D.13029;
  char[256] * D.13031;
  int D.11646;
  int iftmp.103;
  int D.11645;
  const char[3] * D.13036;
  unsigned char D.13037;
  int D.13038;
  unsigned char D.13039;
  int D.13040;
  _Bool D.13041;
  _Bool D.13042;
  _Bool D.13043;
  const unsigned char * D.13046;
  unsigned char D.13047;
  int D.13048;
  const unsigned char * D.13049;
  unsigned char D.13050;
  int D.13051;
  _Bool D.13052;
  _Bool D.13053;
  const unsigned char * D.13056;
  unsigned char D.13057;
  int D.13058;
  const unsigned char * D.13059;
  unsigned char D.13060;
  int D.13061;
  _Bool D.13062;
  _Bool D.13063;
  const unsigned char * D.13066;
  unsigned char D.13067;
  int D.13068;
  const unsigned char * D.13069;
  unsigned char D.13070;
  int D.13071;
  int D.13075;
  long unsigned int D.13076;
  long unsigned int D.13077;
  long unsigned int D.13080;
  long unsigned int D.13081;
  gboolean found;
  gboolean proc_fds;
  pid_t self;
  int pid;
  int thr_ret;
  int i;
  void done = <<< error >>>;

  found = 0;
  proc_fds = 0;
  self = _wapi_getpid ();
  thr_ret = _wapi_handle_lock_shared_handles ();
  D.12957 = thr_ret != 0;
  D.12958 = (long int) D.12957;
  D.12959 = __builtin_expect (D.12958, 0);
  if (D.12959 != 0) goto <D.12960>; else goto <D.12961>;
  <D.12960>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 1803, "thr_ret == 0");
  <D.12961>:
  thr_ret = _wapi_shm_sem_lock (2);
  D.12957 = thr_ret != 0;
  D.12958 = (long int) D.12957;
  D.12959 = __builtin_expect (D.12958, 0);
  if (D.12959 != 0) goto <D.12962>; else goto <D.12963>;
  <D.12962>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 1807, "thr_ret == 0");
  <D.12963>:
  D.12964 = access ("/proc", 0);
  if (D.12964 == -1) goto <D.12965>; else goto <D.12966>;
  <D.12965>:
  _wapi_handle_check_share_by_pid (share_info);
  goto done;
  <D.12966>:
  i = 0;
  goto <D.11619>;
  <D.11618>:
  D.12967 = i / 256;
  D.12968 = _wapi_private_handles[D.12967];
  if (D.12968 != 0B) goto <D.12969>; else goto <D.12970>;
  <D.12969>:
  {
    struct _WapiHandleUnshared * handle;

    D.12967 = i / 256;
    D.12968 = _wapi_private_handles[D.12967];
    D.12971 = i % 256;
    D.12972 = (long unsigned int) D.12971;
    D.12973 = D.12972 * 200;
    handle = D.12968 + D.12973;
    if (i != fd) goto <D.12974>; else goto <D.12975>;
    <D.12974>:
    D.12976 = handle->type;
    if (D.12976 == 1) goto <D.12977>; else goto <D.12978>;
    <D.12977>:
    {
      struct _WapiHandle_file * file_handle;

      file_handle = &handle->u.file;
      D.12979 = file_handle->share_info;
      if (D.12979 == share_info) goto done; else goto <D.12980>;
      <D.12980>:
    }
    <D.12978>:
    <D.12975>:
  }
  <D.12970>:
  i = i + 1;
  <D.11619>:
  i.99 = (unsigned int) i;
  _wapi_fd_reserve.100 = _wapi_fd_reserve;
  if (i.99 < _wapi_fd_reserve.100) goto <D.11618>; else goto <D.11620>;
  <D.11620>:
  i = 0;
  goto <D.11651>;
  <D.11650>:
  {
    struct _WapiHandleShared * shared;
    struct _WapiHandle_process * process_handle;

    _wapi_shared_layout.101 = _wapi_shared_layout;
    shared = &_wapi_shared_layout.101->handles[i];
    D.12984 = shared->type;
    if (D.12984 == 9) goto <D.12985>; else goto <D.12986>;
    <D.12985>:
    {
      struct DIR * fd_dir;
      struct dirent * fd_entry;
      char subdir[256];

      try
        {
          process_handle = &shared->u.process;
          pid = process_handle->id;
          monoeg_g_snprintf (&subdir, 256, "/proc/%d/fd", pid);
          fd_dir = opendir (&subdir);
          if (fd_dir == 0B) goto <D.12987>; else goto <D.12988>;
          <D.12987>:
          // predicted unlikely by continue predictor.
          goto <D.11626>;
          <D.12988>:
          proc_fds = 1;
          goto <D.11647>;
          <D.11648>:
          {
            char path[256];
            struct stat link_stat;

            try
              {
                {
                  size_t __s1_len;
                  size_t __s2_len;

                  __s2_len = 1;
                  if (__s2_len <= 3) goto <D.12992>; else goto <D.12993>;
                  <D.12992>:
                  {
                    const unsigned char * __s2;
                    int __result;

                    __s2 = &fd_entry->d_name;
                    D.12994 = ".";
                    D.12995 = MEM[(const unsigned char *)D.12994];
                    D.12996 = (int) D.12995;
                    D.12997 = *__s2;
                    D.12998 = (int) D.12997;
                    __result = D.12996 - D.12998;
                    {
                      D.12999 = __s2_len != 0;
                      D.13000 = __result == 0;
                      D.13001 = D.12999 & D.13000;
                      if (D.13001 != 0) goto <D.13002>; else goto <D.13003>;
                      <D.13002>:
                      D.13004 = &MEM[(void *)"." + 1B];
                      D.13005 = *D.13004;
                      D.13006 = (int) D.13005;
                      D.13007 = __s2 + 1;
                      D.13008 = *D.13007;
                      D.13009 = (int) D.13008;
                      __result = D.13006 - D.13009;
                      D.13010 = __s2_len > 1;
                      D.13000 = __result == 0;
                      D.13011 = D.13010 & D.13000;
                      if (D.13011 != 0) goto <D.13012>; else goto <D.13013>;
                      <D.13012>:
                      D.13014 = &MEM[(void *)"." + 2B];
                      D.13015 = *D.13014;
                      D.13016 = (int) D.13015;
                      D.13017 = __s2 + 2;
                      D.13018 = *D.13017;
                      D.13019 = (int) D.13018;
                      __result = D.13016 - D.13019;
                      D.13020 = __s2_len > 2;
                      D.13000 = __result == 0;
                      D.13021 = D.13020 & D.13000;
                      if (D.13021 != 0) goto <D.13022>; else goto <D.13023>;
                      <D.13022>:
                      D.13024 = &MEM[(void *)"." + 3B];
                      D.13025 = *D.13024;
                      D.13026 = (int) D.13025;
                      D.13027 = __s2 + 3;
                      D.13028 = *D.13027;
                      D.13029 = (int) D.13028;
                      __result = D.13026 - D.13029;
                      <D.13023>:
                      <D.13013>:
                      <D.13003>:
                    }
                    D.11636 = __result;
                  }
                  iftmp.102 = -D.11636;
                  goto <D.13030>;
                  <D.12993>:
                  D.13031 = &fd_entry->d_name;
                  iftmp.102 = __builtin_strcmp (D.13031, ".");
                  <D.13030>:
                  D.11637 = iftmp.102;
                }
                if (D.11637 == 0) goto <D.12989>; else goto <D.13032>;
                <D.13032>:
                {
                  size_t __s1_len;
                  size_t __s2_len;

                  __s2_len = 2;
                  if (__s2_len <= 3) goto <D.13034>; else goto <D.13035>;
                  <D.13034>:
                  {
                    const unsigned char * __s2;
                    int __result;

                    __s2 = &fd_entry->d_name;
                    D.13036 = "..";
                    D.13037 = MEM[(const unsigned char *)D.13036];
                    D.13038 = (int) D.13037;
                    D.13039 = *__s2;
                    D.13040 = (int) D.13039;
                    __result = D.13038 - D.13040;
                    {
                      D.13041 = __s2_len != 0;
                      D.13042 = __result == 0;
                      D.13043 = D.13041 & D.13042;
                      if (D.13043 != 0) goto <D.13044>; else goto <D.13045>;
                      <D.13044>:
                      D.13046 = &MEM[(void *)".." + 1B];
                      D.13047 = *D.13046;
                      D.13048 = (int) D.13047;
                      D.13049 = __s2 + 1;
                      D.13050 = *D.13049;
                      D.13051 = (int) D.13050;
                      __result = D.13048 - D.13051;
                      D.13052 = __s2_len > 1;
                      D.13042 = __result == 0;
                      D.13053 = D.13052 & D.13042;
                      if (D.13053 != 0) goto <D.13054>; else goto <D.13055>;
                      <D.13054>:
                      D.13056 = &MEM[(void *)".." + 2B];
                      D.13057 = *D.13056;
                      D.13058 = (int) D.13057;
                      D.13059 = __s2 + 2;
                      D.13060 = *D.13059;
                      D.13061 = (int) D.13060;
                      __result = D.13058 - D.13061;
                      D.13062 = __s2_len > 2;
                      D.13042 = __result == 0;
                      D.13063 = D.13062 & D.13042;
                      if (D.13063 != 0) goto <D.13064>; else goto <D.13065>;
                      <D.13064>:
                      D.13066 = &MEM[(void *)".." + 3B];
                      D.13067 = *D.13066;
                      D.13068 = (int) D.13067;
                      D.13069 = __s2 + 3;
                      D.13070 = *D.13069;
                      D.13071 = (int) D.13070;
                      __result = D.13068 - D.13071;
                      <D.13065>:
                      <D.13055>:
                      <D.13045>:
                    }
                    D.11645 = __result;
                  }
                  iftmp.103 = -D.11645;
                  goto <D.13072>;
                  <D.13035>:
                  D.13031 = &fd_entry->d_name;
                  iftmp.103 = __builtin_strcmp (D.13031, "..");
                  <D.13072>:
                  D.11646 = iftmp.103;
                }
                if (D.11646 == 0) goto <D.12989>; else goto <D.13073>;
                <D.13073>:
                if (pid == self) goto <D.13074>; else goto <D.12990>;
                <D.13074>:
                D.13031 = &fd_entry->d_name;
                D.13075 = atoi (D.13031);
                if (D.13075 == fd) goto <D.12989>; else goto <D.12990>;
                <D.12989>:
                // predicted unlikely by continue predictor.
                goto <D.11647>;
                <D.12990>:
                D.13031 = &fd_entry->d_name;
                monoeg_g_snprintf (&path, 256, "/proc/%d/fd/%s", pid, D.13031);
                stat (&path, &link_stat);
                D.13076 = link_stat.st_dev;
                D.13077 = share_info->device;
                if (D.13076 == D.13077) goto <D.13078>; else goto <D.13079>;
                <D.13078>:
                D.13080 = link_stat.st_ino;
                D.13081 = share_info->inode;
                if (D.13080 == D.13081) goto <D.13082>; else goto <D.13083>;
                <D.13082>:
                found = 1;
                <D.13083>:
                <D.13079>:
              }
            finally
              {
                path = {CLOBBER};
                link_stat = {CLOBBER};
              }
          }
          <D.11647>:
          fd_entry = readdir (fd_dir);
          if (fd_entry != 0B) goto <D.11648>; else goto <D.11649>;
          <D.11649>:
          closedir (fd_dir);
        }
      finally
        {
          subdir = {CLOBBER};
        }
    }
    <D.12986>:
  }
  <D.11626>:
  i = i + 1;
  <D.11651>:
  if (i <= 255) goto <D.11650>; else goto <D.11652>;
  <D.11652>:
  if (proc_fds == 0) goto <D.13084>; else goto <D.13085>;
  <D.13084>:
  _wapi_handle_check_share_by_pid (share_info);
  goto <D.13086>;
  <D.13085>:
  if (found == 0) goto <D.13087>; else goto <D.13088>;
  <D.13087>:
  _wapi_free_share_info (share_info);
  <D.13088>:
  <D.13086>:
  done:
  thr_ret = _wapi_shm_sem_unlock (2);
  _wapi_handle_unlock_shared_handles ();
}


atoi (const char * __nptr)
{
  int D.13093;
  long int D.13094;

  D.13094 = strtol (__nptr, 0B, 10);
  D.13093 = (int) D.13094;
  return D.13093;
}


stat (const char * __path, struct stat * __statbuf)
{
  int D.13096;

  D.13096 = __xstat (1, __path, __statbuf);
  return D.13096;
}


_wapi_handle_check_share_by_pid (struct _WapiFileShare * share_info)
{
  int D.13098;
  int D.13099;
  int * D.13102;
  int D.13103;
  _Bool D.13104;
  _Bool D.13105;
  _Bool D.13106;

  D.13098 = share_info->opened_by_pid;
  D.13099 = kill (D.13098, 0);
  if (D.13099 == -1) goto <D.13100>; else goto <D.13101>;
  <D.13100>:
  D.13102 = __errno_location ();
  D.13103 = *D.13102;
  D.13104 = D.13103 == 3;
  D.13105 = D.13103 == 1;
  D.13106 = D.13104 | D.13105;
  if (D.13106 != 0) goto <D.13107>; else goto <D.13108>;
  <D.13107>:
  _wapi_free_share_info (share_info);
  <D.13108>:
  <D.13101>:
}


_wapi_handle_dump ()
{
  long int D.13109;
  long int D.13110;
  _Bool D.13113;
  long int D.13114;
  long int D.13115;
  struct _WapiHandleUnshared * D.13118;
  long unsigned int D.13121;
  long unsigned int D.13122;
  <unnamed type> D.13123;
  unsigned int D.13126;
  const char * iftmp.104;
  int D.13128;
  const char * D.13132;
  unsigned int D.13133;
  unsigned int D.13134;
  void (*<Tbd4>) (void *) D.13135;
  union 
{
  struct _WapiHandle_event event;
  struct _WapiHandle_file file;
  struct _WapiHandle_find find;
  struct _WapiHandle_mutex mutex;
  struct _WapiHandle_sem sem;
  struct _WapiHandle_socket sock;
  struct _WapiHandle_thread thread;
  struct _WapiHandle_shared_ref shared;
} * D.13136;
  unsigned int _wapi_private_handle_slot_count.105;
  struct _WapiHandleUnshared * handle_data;
  guint32 i;
  guint32 k;
  int thr_ret;

  {
    struct __pthread_unwind_buf_t __cancel_buf;
    void (*<Tc2>) (void *) __cancel_routine;
    void * __cancel_arg;
    int __not_first_call;

    try
      {
        __cancel_routine = mono_mutex_unlock_in_cleanup;
        __cancel_arg = &scan_mutex;
        __not_first_call = __sigsetjmp (&__cancel_buf.__cancel_jmp_buf, 0);
        D.13109 = (long int) __not_first_call;
        D.13110 = __builtin_expect (D.13109, 0);
        if (D.13110 != 0) goto <D.13111>; else goto <D.13112>;
        <D.13111>:
        __cancel_routine (__cancel_arg);
        __pthread_unwind_next (&__cancel_buf);
        <D.13112>:
        __pthread_register_cancel (&__cancel_buf);
        thr_ret = pthread_mutex_lock (&scan_mutex);
        D.13113 = thr_ret != 0;
        D.13114 = (long int) D.13113;
        D.13115 = __builtin_expect (D.13114, 0);
        if (D.13115 != 0) goto <D.13116>; else goto <D.13117>;
        <D.13116>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 1943, "thr_ret == 0");
        <D.13117>:
        i = 0;
        goto <D.11671>;
        <D.11670>:
        D.13118 = _wapi_private_handles[i];
        if (D.13118 != 0B) goto <D.13119>; else goto <D.13120>;
        <D.13119>:
        k = 0;
        goto <D.11668>;
        <D.11667>:
        D.13118 = _wapi_private_handles[i];
        D.13121 = (long unsigned int) k;
        D.13122 = D.13121 * 200;
        handle_data = D.13118 + D.13122;
        D.13123 = handle_data->type;
        if (D.13123 == 0) goto <D.13124>; else goto <D.13125>;
        <D.13124>:
        // predicted unlikely by continue predictor.
        goto <D.11666>;
        <D.13125>:
        D.13126 = handle_data->ref;
        D.13128 = handle_data->signalled;
        if (D.13128 != 0) goto <D.13129>; else goto <D.13130>;
        <D.13129>:
        iftmp.104 = "Sg";
        goto <D.13131>;
        <D.13130>:
        iftmp.104 = "Un";
        <D.13131>:
        D.13123 = handle_data->type;
        D.13132 = _wapi_handle_typename[D.13123];
        D.13133 = i * 256;
        D.13134 = D.13133 + k;
        monoeg_g_print ("%3x [%7s] %s %d ", D.13134, D.13132, iftmp.104, D.13126);
        D.13123 = handle_data->type;
        D.13135 = handle_details[D.13123];
        D.13136 = &handle_data->u;
        D.13135 (D.13136);
        monoeg_g_print ("\n");
        <D.11666>:
        k = k + 1;
        <D.11668>:
        if (k <= 255) goto <D.11667>; else goto <D.11669>;
        <D.11669>:
        <D.13120>:
        i = i + 1;
        <D.11671>:
        _wapi_private_handle_slot_count.105 = _wapi_private_handle_slot_count;
        if (i < _wapi_private_handle_slot_count.105) goto <D.11670>; else goto <D.11672>;
        <D.11672>:
        thr_ret = pthread_mutex_unlock (&scan_mutex);
        D.13113 = thr_ret != 0;
        D.13114 = (long int) D.13113;
        D.13115 = __builtin_expect (D.13114, 0);
        if (D.13115 != 0) goto <D.13138>; else goto <D.13139>;
        <D.13138>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 1966, "thr_ret == 0");
        <D.13139>:
        __pthread_unregister_cancel (&__cancel_buf);
        if (0 != 0) goto <D.13140>; else goto <D.13141>;
        <D.13140>:
        __cancel_routine (__cancel_arg);
        <D.13141>:
      }
    finally
      {
        __cancel_buf = {CLOBBER};
      }
  }
}


_wapi_shared_details (void * handle_info)
{
  unsigned int D.13144;
  struct _WapiHandle_shared_ref * shared;

  shared = handle_info;
  D.13144 = shared->offset;
  monoeg_g_print ("offset: 0x%x", D.13144);
}


_wapi_handle_update_refs ()
{
  long int D.13145;
  _Bool D.13146;
  long int D.13147;
  long int D.13148;
  long int D.13153;
  long int D.13154;
  struct _WapiHandleUnshared * D.13157;
  long unsigned int D.13160;
  long unsigned int D.13161;
  <unnamed type> D.13165;
  _Bool D.13166;
  _Bool D.13167;
  _Bool D.13168;
  <unnamed type> D.13170;
  struct _WapiHandleSharedLayout * _wapi_shared_layout.106;
  unsigned int D.13173;
  int now.107;
  guint32 * D.13175;
  struct _WapiFileShare * D.13178;
  _Bool D.13179;
  long int D.13180;
  long int D.13181;
  guint32 * D.13184;
  unsigned int _wapi_private_handle_slot_count.108;
  guint32 i;
  guint32 k;
  int thr_ret;
  guint32 now;

  D.13145 = time (0B);
  now = (guint32) D.13145;
  thr_ret = _wapi_handle_lock_shared_handles ();
  D.13146 = thr_ret != 0;
  D.13147 = (long int) D.13146;
  D.13148 = __builtin_expect (D.13147, 0);
  if (D.13148 != 0) goto <D.13149>; else goto <D.13150>;
  <D.13149>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 1984, "thr_ret == 0");
  <D.13150>:
  thr_ret = _wapi_shm_sem_lock (2);
  D.13146 = thr_ret != 0;
  D.13147 = (long int) D.13146;
  D.13148 = __builtin_expect (D.13147, 0);
  if (D.13148 != 0) goto <D.13151>; else goto <D.13152>;
  <D.13151>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 1988, "thr_ret == 0");
  <D.13152>:
  {
    struct __pthread_unwind_buf_t __cancel_buf;
    void (*<Tc2>) (void *) __cancel_routine;
    void * __cancel_arg;
    int __not_first_call;

    try
      {
        __cancel_routine = mono_mutex_unlock_in_cleanup;
        __cancel_arg = &scan_mutex;
        __not_first_call = __sigsetjmp (&__cancel_buf.__cancel_jmp_buf, 0);
        D.13153 = (long int) __not_first_call;
        D.13154 = __builtin_expect (D.13153, 0);
        if (D.13154 != 0) goto <D.13155>; else goto <D.13156>;
        <D.13155>:
        __cancel_routine (__cancel_arg);
        __pthread_unwind_next (&__cancel_buf);
        <D.13156>:
        __pthread_register_cancel (&__cancel_buf);
        thr_ret = pthread_mutex_lock (&scan_mutex);
        i = 0;
        goto <D.11697>;
        <D.11696>:
        D.13157 = _wapi_private_handles[i];
        if (D.13157 != 0B) goto <D.13158>; else goto <D.13159>;
        <D.13158>:
        k = 0;
        goto <D.11694>;
        <D.11693>:
        {
          struct _WapiHandleUnshared * handle;

          D.13157 = _wapi_private_handles[i];
          D.13160 = (long unsigned int) k;
          D.13161 = D.13160 * 200;
          handle = D.13157 + D.13161;
          D.13165 = handle->type;
          D.13166 = D.13165 == 9;
          D.13167 = D.13165 == 11;
          D.13168 = D.13166 | D.13167;
          if (D.13168 != 0) goto <D.13162>; else goto <D.13169>;
          <D.13169>:
          D.13170 = handle->type;
          if (D.13170 == 12) goto <D.13162>; else goto <D.13171>;
          <D.13171>:
          D.13170 = handle->type;
          if (D.13170 == 13) goto <D.13162>; else goto <D.13163>;
          <D.13162>:
          {
            struct _WapiHandleShared * shared_data;

            _wapi_shared_layout.106 = _wapi_shared_layout;
            D.13173 = handle->u.shared.offset;
            shared_data = &_wapi_shared_layout.106->handles[D.13173];
            now.107 = (int) now;
            D.13175 = &shared_data->timestamp;
            InterlockedExchange (D.13175, now.107);
          }
          goto <D.13164>;
          <D.13163>:
          D.13170 = handle->type;
          if (D.13170 == 1) goto <D.13176>; else goto <D.13177>;
          <D.13176>:
          {
            struct _WapiHandle_file * file_handle;

            file_handle = &handle->u.file;
            D.13178 = file_handle->share_info;
            D.13179 = D.13178 == 0B;
            D.13180 = (long int) D.13179;
            D.13181 = __builtin_expect (D.13180, 0);
            if (D.13181 != 0) goto <D.13182>; else goto <D.13183>;
            <D.13182>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 2014, "file_handle->share_info != NULL");
            <D.13183>:
            now.107 = (int) now;
            D.13178 = file_handle->share_info;
            D.13184 = &D.13178->timestamp;
            InterlockedExchange (D.13184, now.107);
          }
          <D.13177>:
          <D.13164>:
        }
        k = k + 1;
        <D.11694>:
        if (k <= 255) goto <D.11693>; else goto <D.11695>;
        <D.11695>:
        <D.13159>:
        i = i + 1;
        <D.11697>:
        _wapi_private_handle_slot_count.108 = _wapi_private_handle_slot_count;
        if (i < _wapi_private_handle_slot_count.108) goto <D.11696>; else goto <D.11698>;
        <D.11698>:
        thr_ret = pthread_mutex_unlock (&scan_mutex);
        D.13146 = thr_ret != 0;
        D.13147 = (long int) D.13146;
        D.13148 = __builtin_expect (D.13147, 0);
        if (D.13148 != 0) goto <D.13186>; else goto <D.13187>;
        <D.13186>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 2025, "thr_ret == 0");
        <D.13187>:
        __pthread_unregister_cancel (&__cancel_buf);
        if (0 != 0) goto <D.13188>; else goto <D.13189>;
        <D.13188>:
        __cancel_routine (__cancel_arg);
        <D.13189>:
      }
    finally
      {
        __cancel_buf = {CLOBBER};
      }
  }
  thr_ret = _wapi_shm_sem_unlock (2);
  _wapi_handle_unlock_shared_handles ();
}


