_wapi_getpid ()
{
  pid_t D.13907;

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


pid_init ()
{
  int _wapi_pid.0;

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


wapi_init ()
{
  int D.13912;
  unsigned int _wapi_fd_reserve.1;
  unsigned int _wapi_fd_reserve.2;
  unsigned int D.13915;
  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.13923;
  long int D.13924;
  long int D.13925;
  int D.13928;
  void * _wapi_fileshare_layout.10;
  struct _WapiFileShareLayout * _wapi_fileshare_layout.11;
  _Bool D.13933;
  long int D.13934;
  long int D.13935;
  int D.13938;
  void * _wapi_global_signal_handle.12;
  void * _wapi_global_signal_handle.13;
  unsigned int _wapi_global_signal_handle.14;
  unsigned int D.13944;
  struct _WapiHandleUnshared * D.13945;
  unsigned int D.13946;
  unsigned int D.13947;
  struct _WapiHandleUnshared * D.13948;
  union pthread_cond_t * _wapi_global_signal_cond.15;
  union mono_mutex_t * _wapi_global_signal_mutex.16;

  if (0 != 0) goto <D.13910>; else goto <D.13911>;
  <D.13910>:
  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.13911>:
  D.13912 = getdtablesize ();
  _wapi_fd_reserve.1 = (unsigned int) D.13912;
  _wapi_fd_reserve = _wapi_fd_reserve.1;
  _wapi_fd_reserve.2 = _wapi_fd_reserve;
  D.13915 = _wapi_fd_reserve.2 + 255;
  _wapi_fd_reserve.3 = D.13915 & 4294967040;
  _wapi_fd_reserve = _wapi_fd_reserve.3;
  <D.13398>:
  _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.13398>; else goto <D.13399>;
  <D.13399>:
  _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.13923 = _wapi_shared_layout.9 == 0B;
  D.13924 = (long int) D.13923;
  D.13925 = __builtin_expect (D.13924, 0);
  if (D.13925 != 0) goto <D.13926>; else goto <D.13927>;
  <D.13926>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 271, "_wapi_shared_layout != NULL");
  <D.13927>:
  D.13928 = _wapi_shm_enabled ();
  if (D.13928 != 0) goto <D.13929>; else goto <D.13930>;
  <D.13929>:
  _wapi_fileshare_layout.10 = _wapi_shm_attach (1);
  _wapi_fileshare_layout = _wapi_fileshare_layout.10;
  _wapi_fileshare_layout.11 = _wapi_fileshare_layout;
  D.13933 = _wapi_fileshare_layout.11 == 0B;
  D.13934 = (long int) D.13933;
  D.13935 = __builtin_expect (D.13934, 0);
  if (D.13935 != 0) goto <D.13936>; else goto <D.13937>;
  <D.13936>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 276, "_wapi_fileshare_layout != NULL");
  <D.13937>:
  <D.13930>:
  D.13938 = _wapi_shm_enabled ();
  if (D.13938 != 0) goto <D.13939>; else goto <D.13940>;
  <D.13939>:
  _wapi_collection_init ();
  <D.13940>:
  _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 = (unsigned int) _wapi_global_signal_handle.13;
  D.13944 = _wapi_global_signal_handle.14 / 256;
  D.13945 = _wapi_private_handles[D.13944];
  _wapi_global_signal_handle.13 = _wapi_global_signal_handle;
  _wapi_global_signal_handle.14 = (unsigned int) _wapi_global_signal_handle.13;
  D.13946 = _wapi_global_signal_handle.14 & 255;
  D.13947 = D.13946 * 144;
  D.13948 = D.13945 + D.13947;
  _wapi_global_signal_cond.15 = &D.13948->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 = (unsigned int) _wapi_global_signal_handle.13;
  D.13944 = _wapi_global_signal_handle.14 / 256;
  D.13945 = _wapi_private_handles[D.13944];
  _wapi_global_signal_handle.13 = _wapi_global_signal_handle;
  _wapi_global_signal_handle.14 = (unsigned int) _wapi_global_signal_handle.13;
  D.13946 = _wapi_global_signal_handle.14 & 255;
  D.13947 = D.13946 * 144;
  D.13948 = D.13945 + D.13947;
  _wapi_global_signal_mutex.16 = &D.13948->signal_mutex;
  _wapi_global_signal_mutex = _wapi_global_signal_mutex.16;
  atexit (handle_cleanup);
}


handle_cleanup ()
{
  struct _WapiHandleUnshared * D.13951;
  unsigned int j.17;
  unsigned int D.13953;
  <unnamed type> D.13954;
  int D.13955;
  int D.13956;
  _Bool D.13959;
  _Bool D.13960;
  _Bool D.13961;
  unsigned int type.18;
  unsigned int D.13964;
  unsigned int D.13969;
  struct GHashTable * file_share_hash.19;
  int i;
  int j;
  int k;

  i = 0;
  goto <D.13390>;
  <D.13389>:
  j = 0;
  goto <D.13387>;
  <D.13386>:
  {
    struct _WapiHandleUnshared * handle_data;
    int type;
    void * handle;

    D.13951 = _wapi_private_handles[i];
    j.17 = (unsigned int) j;
    D.13953 = j.17 * 144;
    handle_data = D.13951 + D.13953;
    D.13954 = handle_data->type;
    type = (int) D.13954;
    D.13955 = i * 256;
    D.13956 = D.13955 + j;
    handle = (void *) D.13956;
    D.13959 = type == 9;
    D.13960 = type == 11;
    D.13961 = D.13959 | D.13960;
    if (D.13961 != 0) goto <D.13957>; else goto <D.13962>;
    <D.13962>:
    type.18 = (unsigned int) type;
    D.13964 = type.18 + 4294967284;
    if (D.13964 <= 1) goto <D.13957>; else goto <D.13958>;
    <D.13957>:
    if (type == 3) goto <D.13965>; else goto <D.13966>;
    <D.13965>:
    if (1 != 0) goto <D.13967>; else goto <D.13968>;
    <D.13967>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 211, "0");
    <D.13968>:
    _wapi_thread_set_termination_details (handle, 0);
    <D.13966>:
    <D.13958>:
    D.13969 = handle_data->ref;
    k = (int) D.13969;
    goto <D.13384>;
    <D.13383>:
    _wapi_handle_unref_full (handle, 1);
    k = k + -1;
    <D.13384>:
    if (k > 0) goto <D.13383>; else goto <D.13385>;
    <D.13385>:
  }
  j = j + 1;
  <D.13387>:
  if (j <= 255) goto <D.13386>; else goto <D.13388>;
  <D.13388>:
  i = i + 1;
  <D.13390>:
  D.13951 = _wapi_private_handles[i];
  if (D.13951 != 0B) goto <D.13389>; else goto <D.13391>;
  <D.13391>:
  _wapi_shm_semaphores_remove ();
  _wapi_shm_detach (0);
  _wapi_shm_detach (1);
  file_share_hash.19 = file_share_hash;
  if (file_share_hash.19 != 0B) goto <D.13971>; else goto <D.13972>;
  <D.13971>:
  file_share_hash.19 = file_share_hash;
  monoeg_g_hash_table_destroy (file_share_hash.19);
  DeleteCriticalSection (&file_share_hash_mutex);
  <D.13972>:
  i = 0;
  goto <D.13393>;
  <D.13392>:
  D.13951 = _wapi_private_handles[i];
  monoeg_g_free (D.13951);
  i = i + 1;
  <D.13393>:
  if (i <= 16383) goto <D.13392>; else goto <D.13394>;
  <D.13394>:
}


_wapi_handle_unref_full (void * handle, gboolean ignore_private_busy_handles)
{
  <unnamed type> D.13975;
  unsigned int D.13978;
  struct _WapiHandleUnshared * D.13979;
  unsigned int D.13980;
  unsigned int D.13981;
  struct _WapiHandleUnshared * D.13982;
  guint * D.13983;
  int D.13984;
  _Bool D.13985;
  int iftmp.20;
  _Bool D.13992;
  _Bool D.13993;
  _Bool D.13994;
  unsigned int D.13996;
  _Bool D.13999;
  long int D.14000;
  long int D.14001;
  long int D.14004;
  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.14007;
  union mono_mutex_t * D.14010;
  _Bool D.14011;
  _Bool D.14012;
  _Bool D.14013;
  union pthread_cond_t * D.14019;
  struct _WapiHandleSharedLayout * _wapi_shared_layout.21;
  unsigned int D.14027;
  unsigned int D.14028;
  unsigned int D.14031;
  guint32 idx;
  gboolean destroy;
  gboolean early_exit;
  int thr_ret;
  static const char __func__[24] = "_wapi_handle_unref_full";

  idx = (guint32) handle;
  destroy = 0;
  early_exit = 0;
  if (idx > 4194303) goto <D.13973>; else goto <D.13974>;
  <D.13973>:
  return;
  <D.13974>:
  D.13975 = _wapi_handle_type (handle);
  if (D.13975 == 0) goto <D.13976>; else goto <D.13977>;
  <D.13976>:
  monoeg_g_log (0B, 16, "%s: Attempting to unref unused handle %p", &__func__, handle);
  return;
  <D.13977>:
  D.13978 = idx / 256;
  D.13979 = _wapi_private_handles[D.13978];
  D.13980 = idx & 255;
  D.13981 = D.13980 * 144;
  D.13982 = D.13979 + D.13981;
  D.13983 = &D.13982->ref;
  D.13984 = InterlockedDecrement (D.13983);
  D.13985 = D.13984 == 0;
  destroy = (gboolean) D.13985;
  if (destroy == 1) goto <D.13986>; else goto <D.13987>;
  <D.13986>:
  {
    struct _WapiHandleUnshared handle_data;
    struct _WapiHandleShared shared_handle_data;
    WapiHandleType type;
    void (*<T1653>) (void *, void *) close_func;
    gboolean is_shared;

    try
      {
        D.13978 = idx / 256;
        D.13979 = _wapi_private_handles[D.13978];
        D.13980 = idx & 255;
        D.13981 = D.13980 * 144;
        D.13982 = D.13979 + D.13981;
        type = D.13982->type;
        close_func = _wapi_handle_ops_get_close_func (type);
        D.13992 = type == 9;
        D.13993 = type == 11;
        D.13994 = D.13992 | D.13993;
        if (D.13994 != 0) goto <D.13989>; else goto <D.13995>;
        <D.13995>:
        D.13996 = type + 4294967284;
        if (D.13996 <= 1) goto <D.13989>; else goto <D.13990>;
        <D.13989>:
        iftmp.20 = 1;
        goto <D.13991>;
        <D.13990>:
        iftmp.20 = 0;
        <D.13991>:
        is_shared = iftmp.20;
        if (is_shared != 0) goto <D.13997>; else goto <D.13998>;
        <D.13997>:
        thr_ret = _wapi_handle_lock_shared_handles ();
        D.13999 = thr_ret != 0;
        D.14000 = (long int) D.13999;
        D.14001 = __builtin_expect (D.14000, 0);
        if (D.14001 != 0) goto <D.14002>; else goto <D.14003>;
        <D.14002>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 1080, "thr_ret == 0");
        <D.14003>:
        <D.13998>:
        {
          struct __pthread_unwind_buf_t __cancel_buf;
          void (*<Tc1>) (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.14004 = __builtin_expect (__not_first_call, 0);
              if (D.14004 != 0) goto <D.14005>; else goto <D.14006>;
              <D.14005>:
              __cancel_routine (__cancel_arg);
              __pthread_unwind_next (&__cancel_buf);
              <D.14006>:
              __pthread_register_cancel (&__cancel_buf);
              thr_ret = pthread_mutex_lock (&scan_mutex);
              D.13978 = idx / 256;
              D.13979 = _wapi_private_handles[D.13978];
              D.13980 = idx & 255;
              D.13981 = D.13980 * 144;
              D.13982 = D.13979 + D.13981;
              memcpy (&handle_data, D.13982, 144);
              D.13978 = idx / 256;
              D.13979 = _wapi_private_handles[D.13978];
              D.13980 = idx & 255;
              D.13981 = D.13980 * 144;
              D.13982 = D.13979 + D.13981;
              D.14007 = &D.13982->u;
              memset (D.14007, 0, 52);
              D.13978 = idx / 256;
              D.13979 = _wapi_private_handles[D.13978];
              D.13980 = idx & 255;
              D.13981 = D.13980 * 144;
              D.13982 = D.13979 + D.13981;
              D.13982->type = 0;
              if (is_shared == 0) goto <D.14008>; else goto <D.14009>;
              <D.14008>:
              D.13978 = idx / 256;
              D.13979 = _wapi_private_handles[D.13978];
              D.13980 = idx & 255;
              D.13981 = D.13980 * 144;
              D.13982 = D.13979 + D.13981;
              D.14010 = &D.13982->signal_mutex;
              thr_ret = pthread_mutex_destroy (D.14010);
              D.14011 = thr_ret == 16;
              D.14012 = ignore_private_busy_handles != 0;
              D.14013 = D.14011 & D.14012;
              if (D.14013 != 0) goto <D.14014>; else goto <D.14015>;
              <D.14014>:
              early_exit = 1;
              goto <D.14016>;
              <D.14015>:
              if (thr_ret != 0) goto <D.14017>; else goto <D.14018>;
              <D.14017>:
              monoeg_g_log (0B, 4, "Error destroying handle %p mutex due to %d\n", handle, thr_ret);
              <D.13636>:
              goto <D.13636>;
              <D.14018>:
              D.13978 = idx / 256;
              D.13979 = _wapi_private_handles[D.13978];
              D.13980 = idx & 255;
              D.13981 = D.13980 * 144;
              D.13982 = D.13979 + D.13981;
              D.14019 = &D.13982->signal_cond;
              thr_ret = pthread_cond_destroy (D.14019);
              D.14011 = thr_ret == 16;
              D.14012 = ignore_private_busy_handles != 0;
              D.14013 = D.14011 & D.14012;
              if (D.14013 != 0) goto <D.14020>; else goto <D.14021>;
              <D.14020>:
              early_exit = 1;
              goto <D.14022>;
              <D.14021>:
              if (thr_ret != 0) goto <D.14023>; else goto <D.14024>;
              <D.14023>:
              monoeg_g_log (0B, 4, "Error destroying handle %p cond var due to %d\n", handle, thr_ret);
              <D.13637>:
              goto <D.13637>;
              <D.14024>:
              <D.14022>:
              <D.14016>:
              goto <D.14025>;
              <D.14009>:
              {
                struct _WapiHandleShared * shared;

                _wapi_shared_layout.21 = _wapi_shared_layout;
                D.14027 = handle_data.u.shared.offset;
                shared = &_wapi_shared_layout.21->handles[D.14027];
                memcpy (&shared_handle_data, shared, 320);
                D.14028 = shared->handle_refs;
                if (D.14028 != 0) goto <D.14029>; else goto <D.14030>;
                <D.14029>:
                D.14028 = shared->handle_refs;
                D.14031 = D.14028 + 4294967295;
                shared->handle_refs = D.14031;
                D.14028 = shared->handle_refs;
                if (D.14028 == 0) goto <D.14032>; else goto <D.14033>;
                <D.14032>:
                memset (shared, 0, 320);
                <D.14033>:
                <D.14030>:
              }
              <D.14025>:
              thr_ret = pthread_mutex_unlock (&scan_mutex);
              D.13999 = thr_ret != 0;
              D.14000 = (long int) D.13999;
              D.14001 = __builtin_expect (D.14000, 0);
              if (D.14001 != 0) goto <D.14034>; else goto <D.14035>;
              <D.14034>:
              monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 1138, "thr_ret == 0");
              <D.14035>:
              __pthread_unregister_cancel (&__cancel_buf);
              if (0 != 0) goto <D.14036>; else goto <D.14037>;
              <D.14036>:
              __cancel_routine (__cancel_arg);
              <D.14037>:
            }
          finally
            {
              __cancel_buf = {CLOBBER};
            }
        }
        if (early_exit != 0) goto <D.14038>; else goto <D.14039>;
        <D.14038>:
        return;
        <D.14039>:
        if (is_shared != 0) goto <D.14040>; else goto <D.14041>;
        <D.14040>:
        _wapi_handle_unlock_shared_handles ();
        <D.14041>:
        if (close_func != 0B) goto <D.14042>; else goto <D.14043>;
        <D.14042>:
        if (is_shared != 0) goto <D.14044>; else goto <D.14045>;
        <D.14044>:
        close_func (handle, &shared_handle_data.u);
        goto <D.14046>;
        <D.14045>:
        close_func (handle, &handle_data.u);
        <D.14046>:
        <D.14043>:
      }
    finally
      {
        handle_data = {CLOBBER};
        shared_handle_data = {CLOBBER};
      }
  }
  <D.13987>:
}


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

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


_wapi_handle_type (void * handle)
{
  unsigned int D.14061;
  struct _WapiHandleUnshared * D.14062;
  WapiHandleType D.14063;
  unsigned int D.14064;
  unsigned int D.14065;
  struct _WapiHandleUnshared * D.14066;
  guint32 idx;

  idx = (guint32) handle;
  if (idx > 4194303) goto <D.14058>; else goto <D.14060>;
  <D.14060>:
  D.14061 = idx / 256;
  D.14062 = _wapi_private_handles[D.14061];
  if (D.14062 == 0B) goto <D.14058>; else goto <D.14059>;
  <D.14058>:
  D.14063 = 0;
  return D.14063;
  <D.14059>:
  D.14061 = idx / 256;
  D.14062 = _wapi_private_handles[D.14061];
  D.14064 = idx & 255;
  D.14065 = D.14064 * 144;
  D.14066 = D.14062 + D.14065;
  D.14063 = D.14066->type;
  return D.14063;
}


InterlockedDecrement (volatile gint32 * val)
{
  gint32 D.14068;
  unsigned int D.14069;

  D.14069 = __sync_sub_and_fetch_4 (val, 1);
  D.14068 = (gint32) D.14069;
  return D.14068;
}


_wapi_handle_ops_get_close_func (WapiHandleType type)
{
  struct _WapiHandleOps * D.14071;
  void (*<T1653>) (void *, void *) D.14074;
  void (*<T1653>) (void *, void *) D.14077;

  D.14071 = handle_ops[type];
  if (D.14071 != 0B) goto <D.14072>; else goto <D.14073>;
  <D.14072>:
  D.14071 = handle_ops[type];
  D.14074 = D.14071->close;
  if (D.14074 != 0B) goto <D.14075>; else goto <D.14076>;
  <D.14075>:
  D.14071 = handle_ops[type];
  D.14077 = D.14071->close;
  return D.14077;
  <D.14076>:
  <D.14073>:
  D.14077 = 0B;
  return D.14077;
}


_wapi_handle_lock_shared_handles ()
{
  int D.14079;

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


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

  D.14082 = __builtin_object_size (__dest, 0);
  D.14081 = __builtin___memcpy_chk (__dest, __src, __len, D.14082);
  return D.14081;
}


memset (void * __dest, int __ch, size_t __len)
{
  int D.14086;
  int D.14091;
  void * D.14093;
  unsigned int D.14094;

  D.14086 = __builtin_constant_p (__len);
  if (D.14086 != 0) goto <D.14087>; else goto <D.14088>;
  <D.14087>:
  if (__len == 0) goto <D.14089>; else goto <D.14090>;
  <D.14089>:
  D.14091 = __builtin_constant_p (__ch);
  if (D.14091 == 0) goto <D.14084>; else goto <D.14092>;
  <D.14092>:
  if (__ch != 0) goto <D.14084>; else goto <D.14085>;
  <D.14084>:
  __warn_memset_zero_len ();
  D.14093 = __dest;
  return D.14093;
  <D.14085>:
  <D.14090>:
  <D.14088>:
  D.14094 = __builtin_object_size (__dest, 0);
  D.14093 = __builtin___memset_chk (__dest, __ch, __len, D.14094);
  return D.14093;
}


_wapi_handle_unlock_shared_handles ()
{
  int D.14096;

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


wapi_cleanup ()
{
  int _wapi_has_shut_down.22;
  _Bool D.14099;
  long int D.14100;
  long int D.14101;

  _wapi_has_shut_down.22 = _wapi_has_shut_down;
  D.14099 = _wapi_has_shut_down.22 != 0;
  D.14100 = (long int) D.14099;
  D.14101 = __builtin_expect (D.14100, 0);
  if (D.14101 != 0) goto <D.14102>; else goto <D.14103>;
  <D.14102>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 303, "_wapi_has_shut_down == FALSE");
  <D.14103>:
  _wapi_has_shut_down = 1;
  _wapi_error_cleanup ();
  _wapi_thread_cleanup ();
}


_wapi_handle_new (WapiHandleType type, void * handle_specific)
{
  int _wapi_has_shut_down.23;
  _Bool D.14105;
  long int D.14106;
  long int D.14107;
  int iftmp.24;
  unsigned int D.14114;
  _Bool D.14115;
  _Bool D.14116;
  _Bool D.14117;
  _Bool D.14119;
  long int D.14120;
  long int D.14121;
  long int D.14124;
  _Bool D.14127;
  long int D.14128;
  long int D.14129;
  unsigned int _wapi_private_handle_count.25;
  unsigned int D.14133;
  void * D.14135;
  unsigned int _wapi_private_handle_count.26;
  unsigned int _wapi_private_handle_slot_count.27;
  unsigned int _wapi_private_handle_slot_count.28;
  unsigned int _wapi_fd_reserve.29;
  _Bool D.14146;
  long int D.14147;
  long int D.14148;
  _Bool D.14153;
  _Bool D.14154;
  _Bool D.14155;
  unsigned int D.14157;
  unsigned int D.14162;
  struct _WapiHandleUnshared * D.14163;
  unsigned int D.14164;
  unsigned int D.14165;
  struct _WapiHandleUnshared * D.14166;
  void * D.14167;
  guint32 handle_idx;
  void * handle;
  int thr_ret;
  void done = <<< error >>>;

  handle_idx = 0;
  _wapi_has_shut_down.23 = _wapi_has_shut_down;
  D.14105 = _wapi_has_shut_down.23 != 0;
  D.14106 = (long int) D.14105;
  D.14107 = __builtin_expect (D.14106, 0);
  if (D.14107 != 0) goto <D.14108>; else goto <D.14109>;
  <D.14108>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 466, "_wapi_has_shut_down == FALSE");
  <D.14109>:
  D.14114 = type + 4294967295;
  D.14115 = D.14114 <= 1;
  D.14116 = type == 7;
  D.14117 = D.14115 | D.14116;
  if (D.14117 != 0) goto <D.14111>; else goto <D.14118>;
  <D.14118>:
  if (type == 10) goto <D.14111>; else goto <D.14112>;
  <D.14111>:
  iftmp.24 = 1;
  goto <D.14113>;
  <D.14112>:
  iftmp.24 = 0;
  <D.14113>:
  D.14119 = iftmp.24 != 0;
  D.14120 = (long int) D.14119;
  D.14121 = __builtin_expect (D.14120, 0);
  if (D.14121 != 0) goto <D.14122>; else goto <D.14123>;
  <D.14122>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 471, "!_WAPI_FD_HANDLE(type)");
  <D.14123>:
  {
    struct __pthread_unwind_buf_t __cancel_buf;
    void (*<Tc1>) (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.14124 = __builtin_expect (__not_first_call, 0);
        if (D.14124 != 0) goto <D.14125>; else goto <D.14126>;
        <D.14125>:
        __cancel_routine (__cancel_arg);
        __pthread_unwind_next (&__cancel_buf);
        <D.14126>:
        __pthread_register_cancel (&__cancel_buf);
        thr_ret = pthread_mutex_lock (&scan_mutex);
        D.14127 = thr_ret != 0;
        D.14128 = (long int) D.14127;
        D.14129 = __builtin_expect (D.14128, 0);
        if (D.14129 != 0) goto <D.14130>; else goto <D.14131>;
        <D.14130>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 476, "thr_ret == 0");
        <D.14131>:
        goto <D.13459>;
        <D.13458>:
        {
          int idx;

          _wapi_private_handle_count.25 = _wapi_private_handle_count;
          D.14133 = _wapi_private_handle_count.25 / 256;
          idx = (int) D.14133;
          if (idx > 16383) goto <D.13457>; else goto <D.14134>;
          <D.14134>:
          D.14135 = monoeg_malloc0 (36864);
          _wapi_private_handles[idx] = D.14135;
          _wapi_private_handle_count.25 = _wapi_private_handle_count;
          _wapi_private_handle_count.26 = _wapi_private_handle_count.25 + 256;
          _wapi_private_handle_count = _wapi_private_handle_count.26;
          _wapi_private_handle_slot_count.27 = _wapi_private_handle_slot_count;
          _wapi_private_handle_slot_count.28 = _wapi_private_handle_slot_count.27 + 1;
          _wapi_private_handle_slot_count = _wapi_private_handle_slot_count.28;
        }
        <D.13459>:
        handle_idx = _wapi_handle_new_internal (type, handle_specific);
        if (handle_idx == 0) goto <D.13458>; else goto <D.13457>;
        <D.13457>:
        thr_ret = pthread_mutex_unlock (&scan_mutex);
        D.14127 = thr_ret != 0;
        D.14128 = (long int) D.14127;
        D.14129 = __builtin_expect (D.14128, 0);
        if (D.14129 != 0) goto <D.14139>; else goto <D.14140>;
        <D.14139>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 493, "thr_ret == 0");
        <D.14140>:
        __pthread_unregister_cancel (&__cancel_buf);
        if (0 != 0) goto <D.14141>; else goto <D.14142>;
        <D.14141>:
        __cancel_routine (__cancel_arg);
        <D.14142>:
      }
    finally
      {
        __cancel_buf = {CLOBBER};
      }
  }
  if (handle_idx == 0) goto <D.14143>; else goto <D.14144>;
  <D.14143>:
  handle = 4294967295B;
  goto done;
  <D.14144>:
  _wapi_fd_reserve.29 = _wapi_fd_reserve;
  D.14146 = handle_idx < _wapi_fd_reserve.29;
  D.14147 = (long int) D.14146;
  D.14148 = __builtin_expect (D.14147, 0);
  if (D.14148 != 0) goto <D.14149>; else goto <D.14150>;
  <D.14149>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 503, "handle_idx >= _wapi_fd_reserve");
  <D.14150>:
  handle = (void *) handle_idx;
  D.14153 = type == 9;
  D.14154 = type == 11;
  D.14155 = D.14153 | D.14154;
  if (D.14155 != 0) goto <D.14151>; else goto <D.14156>;
  <D.14156>:
  D.14157 = type + 4294967284;
  if (D.14157 <= 1) goto <D.14151>; else goto <D.14152>;
  <D.14151>:
  {
    guint32 ref;

    ref = _wapi_handle_new_shared (type, handle_specific);
    if (ref == 0) goto <D.14158>; else goto <D.14159>;
    <D.14158>:
    _wapi_handle_collect ();
    ref = _wapi_handle_new_shared (type, handle_specific);
    if (ref == 0) goto <D.14160>; else goto <D.14161>;
    <D.14160>:
    handle = 4294967295B;
    goto done;
    <D.14161>:
    <D.14159>:
    D.14162 = handle_idx / 256;
    D.14163 = _wapi_private_handles[D.14162];
    D.14164 = handle_idx & 255;
    D.14165 = D.14164 * 144;
    D.14166 = D.14163 + D.14165;
    D.14166->u.shared.offset = ref;
  }
  <D.14152>:
  done:
  D.14167 = handle;
  return D.14167;
}


_wapi_handle_new_internal (WapiHandleType type, void * handle_specific)
{
  int _wapi_has_shut_down.30;
  _Bool D.14176;
  long int D.14177;
  long int D.14178;
  unsigned int last.31;
  unsigned int _wapi_fd_reserve.32;
  struct _WapiHandleUnshared * D.14186;
  unsigned int D.14189;
  <unnamed type> D.14190;
  unsigned int last.33;
  guint32 D.14194;
  unsigned int _wapi_private_handle_slot_count.34;
  guint32 i;
  guint32 k;
  guint32 count;
  static guint32 last = 0;
  gboolean retry;
  void again = <<< error >>>;

  retry = 0;
  _wapi_has_shut_down.30 = _wapi_has_shut_down;
  D.14176 = _wapi_has_shut_down.30 != 0;
  D.14177 = (long int) D.14176;
  D.14178 = __builtin_expect (D.14177, 0);
  if (D.14178 != 0) goto <D.14179>; else goto <D.14180>;
  <D.14179>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 416, "_wapi_has_shut_down == FALSE");
  <D.14180>:
  last.31 = last;
  _wapi_fd_reserve.32 = _wapi_fd_reserve;
  if (last.31 < _wapi_fd_reserve.32) goto <D.14183>; else goto <D.14184>;
  <D.14183>:
  _wapi_fd_reserve.32 = _wapi_fd_reserve;
  last = _wapi_fd_reserve.32;
  goto <D.14185>;
  <D.14184>:
  retry = 1;
  <D.14185>:
  again:
  count = last;
  i = count / 256;
  goto <D.13441>;
  <D.13440>:
  D.14186 = _wapi_private_handles[i];
  if (D.14186 != 0B) goto <D.14187>; else goto <D.14188>;
  <D.14187>:
  k = count & 255;
  goto <D.13438>;
  <D.13437>:
  {
    struct _WapiHandleUnshared * handle;

    D.14186 = _wapi_private_handles[i];
    D.14189 = k * 144;
    handle = D.14186 + D.14189;
    D.14190 = handle->type;
    if (D.14190 == 0) goto <D.14191>; else goto <D.14192>;
    <D.14191>:
    last.33 = count + 1;
    last = last.33;
    _wapi_handle_init (handle, type, handle_specific);
    D.14194 = count;
    return D.14194;
    <D.14192>:
    count = count + 1;
  }
  k = k + 1;
  <D.13438>:
  if (k <= 255) goto <D.13437>; else goto <D.13439>;
  <D.13439>:
  <D.14188>:
  i = i + 1;
  <D.13441>:
  _wapi_private_handle_slot_count.34 = _wapi_private_handle_slot_count;
  if (i < _wapi_private_handle_slot_count.34) goto <D.13440>; else goto <D.13442>;
  <D.13442>:
  if (retry != 0) goto <D.14196>; else goto <D.14197>;
  <D.14196>:
  last.31 = last;
  _wapi_fd_reserve.32 = _wapi_fd_reserve;
  if (last.31 > _wapi_fd_reserve.32) goto <D.14198>; else goto <D.14199>;
  <D.14198>:
  _wapi_fd_reserve.32 = _wapi_fd_reserve;
  last = _wapi_fd_reserve.32;
  goto again;
  <D.14199>:
  <D.14197>:
  D.14194 = 0;
  return D.14194;
}


_wapi_handle_init (struct _WapiHandleUnshared * handle, WapiHandleType type, void * handle_specific)
{
  int _wapi_has_shut_down.35;
  _Bool D.14202;
  long int D.14203;
  long int D.14204;
  _Bool D.14207;
  _Bool D.14208;
  _Bool D.14209;
  unsigned int D.14212;
  union pthread_cond_t * D.14215;
  _Bool D.14216;
  long int D.14217;
  long int D.14218;
  union mono_mutex_t * D.14221;
  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.14226;
  int thr_ret;

  _wapi_has_shut_down.35 = _wapi_has_shut_down;
  D.14202 = _wapi_has_shut_down.35 != 0;
  D.14203 = (long int) D.14202;
  D.14204 = __builtin_expect (D.14203, 0);
  if (D.14204 != 0) goto <D.14205>; else goto <D.14206>;
  <D.14205>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 332, "_wapi_has_shut_down == FALSE");
  <D.14206>:
  handle->type = type;
  handle->signalled = 0;
  handle->ref = 1;
  D.14207 = type != 9;
  D.14208 = type != 11;
  D.14209 = D.14207 & D.14208;
  if (D.14209 != 0) goto <D.14210>; else goto <D.14211>;
  <D.14210>:
  D.14212 = type + 4294967284;
  if (D.14212 > 1) goto <D.14213>; else goto <D.14214>;
  <D.14213>:
  D.14215 = &handle->signal_cond;
  thr_ret = pthread_cond_init (D.14215, 0B);
  D.14216 = thr_ret != 0;
  D.14217 = (long int) D.14216;
  D.14218 = __builtin_expect (D.14217, 0);
  if (D.14218 != 0) goto <D.14219>; else goto <D.14220>;
  <D.14219>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 340, "thr_ret == 0");
  <D.14220>:
  D.14221 = &handle->signal_mutex;
  thr_ret = pthread_mutex_init (D.14221, 0B);
  D.14216 = thr_ret != 0;
  D.14217 = (long int) D.14216;
  D.14218 = __builtin_expect (D.14217, 0);
  if (D.14218 != 0) goto <D.14222>; else goto <D.14223>;
  <D.14222>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 343, "thr_ret == 0");
  <D.14223>:
  if (handle_specific != 0B) goto <D.14224>; else goto <D.14225>;
  <D.14224>:
  D.14226 = &handle->u;
  memcpy (D.14226, handle_specific, 52);
  <D.14225>:
  <D.14214>:
  <D.14211>:
}


_wapi_handle_new_shared (WapiHandleType type, void * handle_specific)
{
  int _wapi_has_shut_down.36;
  _Bool D.14228;
  long int D.14229;
  long int D.14230;
  struct _WapiHandleSharedLayout * _wapi_shared_layout.37;
  <unnamed type> D.14234;
  _Bool D.14237;
  long int D.14238;
  long int D.14239;
  WapiHandleType * D.14242;
  int type.38;
  int D.14244;
  unsigned int last.39;
  guint32 D.14248;
  unsigned int last.40;
  guint32 offset;
  static guint32 last = 1;
  int thr_ret;
  void again = <<< error >>>;

  _wapi_has_shut_down.36 = _wapi_has_shut_down;
  D.14228 = _wapi_has_shut_down.36 != 0;
  D.14229 = (long int) D.14228;
  D.14230 = __builtin_expect (D.14229, 0);
  if (D.14230 != 0) goto <D.14231>; else goto <D.14232>;
  <D.14231>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 359, "_wapi_has_shut_down == FALSE");
  <D.14232>:
  again:
  offset = last;
  goto <D.13424>;
  <D.13423>:
  {
    struct _WapiHandleShared * handle;

    _wapi_shared_layout.37 = _wapi_shared_layout;
    handle = &_wapi_shared_layout.37->handles[offset];
    D.14234 = handle->type;
    if (D.14234 == 0) goto <D.14235>; else goto <D.14236>;
    <D.14235>:
    thr_ret = _wapi_handle_lock_shared_handles ();
    D.14237 = thr_ret != 0;
    D.14238 = (long int) D.14237;
    D.14239 = __builtin_expect (D.14238, 0);
    if (D.14239 != 0) goto <D.14240>; else goto <D.14241>;
    <D.14240>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 369, "thr_ret == 0");
    <D.14241>:
    D.14242 = &handle->type;
    type.38 = (int) type;
    D.14244 = InterlockedCompareExchange (D.14242, type.38, 0);
    if (D.14244 == 0) goto <D.14245>; else goto <D.14246>;
    <D.14245>:
    last.39 = offset + 1;
    last = last.39;
    _wapi_handle_init_shared (handle, type, handle_specific);
    _wapi_handle_unlock_shared_handles ();
    D.14248 = offset;
    return D.14248;
    <D.14246>:
    _wapi_handle_unlock_shared_handles ();
    <D.14236>:
  }
  offset = offset + 1;
  <D.13424>:
  if (offset <= 255) goto <D.13423>; else goto <D.13425>;
  <D.13425>:
  last.40 = last;
  if (last.40 > 1) goto <D.14250>; else goto <D.14251>;
  <D.14250>:
  last = 1;
  goto again;
  <D.14251>:
  D.14248 = 0;
  return D.14248;
}


InterlockedCompareExchange (volatile gint32 * dest, gint32 exch, gint32 comp)
{
  gint32 D.14253;
  unsigned int comp.41;
  unsigned int exch.42;
  unsigned int D.14256;

  comp.41 = (unsigned int) comp;
  exch.42 = (unsigned int) exch;
  D.14256 = __sync_val_compare_and_swap_4 (dest, comp.41, exch.42);
  D.14253 = (gint32) D.14256;
  return D.14253;
}


_wapi_handle_init_shared (struct _WapiHandleShared * handle, WapiHandleType type, void * handle_specific)
{
  int _wapi_has_shut_down.43;
  _Bool D.14259;
  long int D.14260;
  long int D.14261;
  long int D.14264;
  unsigned int D.14265;
  union 
{
  struct _WapiHandle_process process;
  struct _WapiHandle_namedmutex namedmutex;
  struct _WapiHandle_namedsem namedsem;
  struct _WapiHandle_namedevent namedevent;
} * D.14268;

  _wapi_has_shut_down.43 = _wapi_has_shut_down;
  D.14259 = _wapi_has_shut_down.43 != 0;
  D.14260 = (long int) D.14259;
  D.14261 = __builtin_expect (D.14260, 0);
  if (D.14261 != 0) goto <D.14262>; else goto <D.14263>;
  <D.14262>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 315, "_wapi_has_shut_down == FALSE");
  <D.14263>:
  handle->type = type;
  D.14264 = time (0B);
  D.14265 = (unsigned int) D.14264;
  handle->timestamp = D.14265;
  handle->signalled = 0;
  handle->handle_refs = 1;
  if (handle_specific != 0B) goto <D.14266>; else goto <D.14267>;
  <D.14266>:
  D.14268 = &handle->u;
  memcpy (D.14268, handle_specific, 304);
  <D.14267>:
}


_wapi_handle_new_from_offset (WapiHandleType type, guint32 offset, gboolean timestamp)
{
  int _wapi_has_shut_down.44;
  _Bool D.14270;
  long int D.14271;
  long int D.14272;
  int iftmp.45;
  unsigned int D.14279;
  _Bool D.14280;
  _Bool D.14281;
  _Bool D.14282;
  _Bool D.14284;
  long int D.14285;
  long int D.14286;
  int iftmp.46;
  _Bool D.14292;
  _Bool D.14293;
  _Bool D.14294;
  unsigned int D.14296;
  _Bool D.14298;
  long int D.14299;
  long int D.14300;
  _Bool D.14303;
  long int D.14304;
  long int D.14305;
  struct _WapiHandleSharedLayout * _wapi_shared_layout.47;
  long int D.14311;
  guint32 * D.14312;
  int now.48;
  long int D.14314;
  _Bool D.14317;
  long int D.14318;
  long int D.14319;
  struct _WapiHandleUnshared * D.14322;
  unsigned int k.49;
  unsigned int D.14326;
  <unnamed type> D.14327;
  unsigned int D.14330;
  int D.14333;
  int D.14334;
  unsigned int i.50;
  unsigned int _wapi_private_handle_slot_count.51;
  void * D.14343;
  <unnamed type> D.14346;
  long int D.14349;
  unsigned int _wapi_private_handle_count.52;
  unsigned int D.14355;
  void * D.14356;
  unsigned int _wapi_private_handle_count.53;
  unsigned int _wapi_private_handle_slot_count.54;
  unsigned int _wapi_fd_reserve.55;
  _Bool D.14364;
  long int D.14365;
  long int D.14366;
  unsigned int D.14369;
  struct _WapiHandleUnshared * D.14370;
  unsigned int D.14371;
  unsigned int D.14372;
  struct _WapiHandleUnshared * D.14373;
  guint32 * D.14374;
  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 = 4294967295B;
  _wapi_has_shut_down.44 = _wapi_has_shut_down;
  D.14270 = _wapi_has_shut_down.44 != 0;
  D.14271 = (long int) D.14270;
  D.14272 = __builtin_expect (D.14271, 0);
  if (D.14272 != 0) goto <D.14273>; else goto <D.14274>;
  <D.14273>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 541, "_wapi_has_shut_down == FALSE");
  <D.14274>:
  D.14279 = type + 4294967295;
  D.14280 = D.14279 <= 1;
  D.14281 = type == 7;
  D.14282 = D.14280 | D.14281;
  if (D.14282 != 0) goto <D.14276>; else goto <D.14283>;
  <D.14283>:
  if (type == 10) goto <D.14276>; else goto <D.14277>;
  <D.14276>:
  iftmp.45 = 1;
  goto <D.14278>;
  <D.14277>:
  iftmp.45 = 0;
  <D.14278>:
  D.14284 = iftmp.45 != 0;
  D.14285 = (long int) D.14284;
  D.14286 = __builtin_expect (D.14285, 0);
  if (D.14286 != 0) goto <D.14287>; else goto <D.14288>;
  <D.14287>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 546, "!_WAPI_FD_HANDLE(type)");
  <D.14288>:
  D.14292 = type != 9;
  D.14293 = type != 11;
  D.14294 = D.14292 & D.14293;
  if (D.14294 != 0) goto <D.14295>; else goto <D.14290>;
  <D.14295>:
  D.14296 = type + 4294967284;
  if (D.14296 > 1) goto <D.14297>; else goto <D.14290>;
  <D.14297>:
  iftmp.46 = 1;
  goto <D.14291>;
  <D.14290>:
  iftmp.46 = 0;
  <D.14291>:
  D.14298 = iftmp.46 != 0;
  D.14299 = (long int) D.14298;
  D.14300 = __builtin_expect (D.14299, 0);
  if (D.14300 != 0) goto <D.14301>; else goto <D.14302>;
  <D.14301>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 547, "_WAPI_SHARED_HANDLE(type)");
  <D.14302>:
  D.14303 = offset == 0;
  D.14304 = (long int) D.14303;
  D.14305 = __builtin_expect (D.14304, 0);
  if (D.14305 != 0) goto <D.14306>; else goto <D.14307>;
  <D.14306>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 548, "offset != 0");
  <D.14307>:
  _wapi_shared_layout.47 = _wapi_shared_layout;
  shared = &_wapi_shared_layout.47->handles[offset];
  if (timestamp != 0) goto <D.14309>; else goto <D.14310>;
  <D.14309>:
  {
    guint32 now;

    D.14311 = time (0B);
    now = (guint32) D.14311;
    D.14312 = &shared->timestamp;
    now.48 = (int) now;
    InterlockedExchange (D.14312, now.48);
  }
  <D.14310>:
  {
    struct __pthread_unwind_buf_t __cancel_buf;
    void (*<Tc1>) (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.14314 = __builtin_expect (__not_first_call, 0);
        if (D.14314 != 0) goto <D.14315>; else goto <D.14316>;
        <D.14315>:
        __cancel_routine (__cancel_arg);
        __pthread_unwind_next (&__cancel_buf);
        <D.14316>:
        __pthread_register_cancel (&__cancel_buf);
        thr_ret = pthread_mutex_lock (&scan_mutex);
        D.14317 = thr_ret != 0;
        D.14318 = (long int) D.14317;
        D.14319 = __builtin_expect (D.14318, 0);
        if (D.14319 != 0) goto <D.14320>; else goto <D.14321>;
        <D.14320>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 560, "thr_ret == 0");
        <D.14321>:
        i = 0;
        goto <D.13486>;
        <D.13485>:
        D.14322 = _wapi_private_handles[i];
        if (D.14322 != 0B) goto <D.14323>; else goto <D.14324>;
        <D.14323>:
        k = 0;
        goto <D.13483>;
        <D.13482>:
        {
          struct _WapiHandleUnshared * handle_data;

          D.14322 = _wapi_private_handles[i];
          k.49 = (unsigned int) k;
          D.14326 = k.49 * 144;
          handle_data = D.14322 + D.14326;
          D.14327 = handle_data->type;
          if (D.14327 == type) goto <D.14328>; else goto <D.14329>;
          <D.14328>:
          D.14330 = handle_data->u.shared.offset;
          if (D.14330 == offset) goto <D.14331>; else goto <D.14332>;
          <D.14331>:
          D.14333 = i * 256;
          D.14334 = D.14333 + k;
          handle = (void *) D.14334;
          goto first_pass_done;
          <D.14332>:
          <D.14329>:
        }
        k = k + 1;
        <D.13483>:
        if (k <= 255) goto <D.13482>; else goto <D.13484>;
        <D.13484>:
        <D.14324>:
        i = i + 1;
        <D.13486>:
        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.13485>; else goto <D.13487>;
        <D.13487>:
        first_pass_done:
        thr_ret = pthread_mutex_unlock (&scan_mutex);
        D.14317 = thr_ret != 0;
        D.14318 = (long int) D.14317;
        D.14319 = __builtin_expect (D.14318, 0);
        if (D.14319 != 0) goto <D.14337>; else goto <D.14338>;
        <D.14337>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 578, "thr_ret == 0");
        <D.14338>:
        __pthread_unregister_cancel (&__cancel_buf);
        if (0 != 0) goto <D.14339>; else goto <D.14340>;
        <D.14339>:
        __cancel_routine (__cancel_arg);
        <D.14340>:
      }
    finally
      {
        __cancel_buf = {CLOBBER};
      }
  }
  if (handle != 4294967295B) goto <D.14341>; else goto <D.14342>;
  <D.14341>:
  _wapi_handle_ref (handle);
  D.14343 = handle;
  return D.14343;
  <D.14342>:
  thr_ret = _wapi_handle_lock_shared_handles ();
  D.14317 = thr_ret != 0;
  D.14318 = (long int) D.14317;
  D.14319 = __builtin_expect (D.14318, 0);
  if (D.14319 != 0) goto <D.14344>; else goto <D.14345>;
  <D.14344>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 591, "thr_ret == 0");
  <D.14345>:
  D.14346 = shared->type;
  if (D.14346 == 0) goto done; else goto <D.14347>;
  <D.14347>:
  D.14346 = shared->type;
  if (D.14346 != type) goto done; else goto <D.14348>;
  <D.14348>:
  {
    struct __pthread_unwind_buf_t __cancel_buf;
    void (*<Tc1>) (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.14349 = __builtin_expect (__not_first_call, 0);
        if (D.14349 != 0) goto <D.14350>; else goto <D.14351>;
        <D.14350>:
        __cancel_routine (__cancel_arg);
        __pthread_unwind_next (&__cancel_buf);
        <D.14351>:
        __pthread_register_cancel (&__cancel_buf);
        thr_ret = pthread_mutex_lock (&scan_mutex);
        D.14317 = thr_ret != 0;
        D.14318 = (long int) D.14317;
        D.14319 = __builtin_expect (D.14318, 0);
        if (D.14319 != 0) goto <D.14352>; else goto <D.14353>;
        <D.14352>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 610, "thr_ret == 0");
        <D.14353>:
        goto <D.13497>;
        <D.13496>:
        {
          int idx;

          _wapi_private_handle_count.52 = _wapi_private_handle_count;
          D.14355 = _wapi_private_handle_count.52 / 256;
          idx = (int) D.14355;
          D.14356 = monoeg_malloc0 (36864);
          _wapi_private_handles[idx] = D.14356;
          _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.13497>:
        handle_idx = _wapi_handle_new_internal (type, 0B);
        if (handle_idx == 0) goto <D.13496>; else goto <D.13498>;
        <D.13498>:
        thr_ret = pthread_mutex_unlock (&scan_mutex);
        D.14317 = thr_ret != 0;
        D.14318 = (long int) D.14317;
        D.14319 = __builtin_expect (D.14318, 0);
        if (D.14319 != 0) goto <D.14359>; else goto <D.14360>;
        <D.14359>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 623, "thr_ret == 0");
        <D.14360>:
        __pthread_unregister_cancel (&__cancel_buf);
        if (0 != 0) goto <D.14361>; else goto <D.14362>;
        <D.14361>:
        __cancel_routine (__cancel_arg);
        <D.14362>:
      }
    finally
      {
        __cancel_buf = {CLOBBER};
      }
  }
  _wapi_fd_reserve.55 = _wapi_fd_reserve;
  D.14364 = handle_idx < _wapi_fd_reserve.55;
  D.14365 = (long int) D.14364;
  D.14366 = __builtin_expect (D.14365, 0);
  if (D.14366 != 0) goto <D.14367>; else goto <D.14368>;
  <D.14367>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 627, "handle_idx >= _wapi_fd_reserve");
  <D.14368>:
  handle = (void *) handle_idx;
  D.14369 = handle_idx / 256;
  D.14370 = _wapi_private_handles[D.14369];
  D.14371 = handle_idx & 255;
  D.14372 = D.14371 * 144;
  D.14373 = D.14370 + D.14372;
  D.14373->u.shared.offset = offset;
  D.14374 = &shared->handle_refs;
  InterlockedIncrement (D.14374);
  done:
  _wapi_handle_unlock_shared_handles ();
  D.14343 = handle;
  return D.14343;
}


InterlockedExchange (volatile gint32 * val, gint32 new_val)
{
  unsigned int old_val.56;
  unsigned int new_val.57;
  unsigned int D.14385;
  int D.14386;
  gint32 D.14387;
  gint32 old_val;

  <D.13060>:
  old_val = *val;
  old_val.56 = (unsigned int) old_val;
  new_val.57 = (unsigned int) new_val;
  D.14385 = __sync_val_compare_and_swap_4 (val, old_val.56, new_val.57);
  D.14386 = (int) D.14385;
  if (D.14386 != old_val) goto <D.13060>; else goto <D.13061>;
  <D.13061>:
  D.14387 = old_val;
  return D.14387;
}


InterlockedIncrement (volatile gint32 * val)
{
  gint32 D.14389;
  unsigned int D.14390;

  D.14390 = __sync_add_and_fetch_4 (val, 1);
  D.14389 = (gint32) D.14390;
  return D.14389;
}


_wapi_handle_new_fd (WapiHandleType type, int fd, void * handle_specific)
{
  int _wapi_has_shut_down.58;
  _Bool D.14393;
  long int D.14394;
  long int D.14395;
  int iftmp.59;
  unsigned int D.14401;
  _Bool D.14402;
  _Bool D.14403;
  _Bool D.14404;
  _Bool D.14407;
  long int D.14408;
  long int D.14409;
  int iftmp.60;
  _Bool D.14416;
  _Bool D.14417;
  _Bool D.14418;
  unsigned int D.14420;
  _Bool D.14421;
  long int D.14422;
  long int D.14423;
  unsigned int fd.61;
  unsigned int _wapi_fd_reserve.62;
  void * D.14430;
  int D.14431;
  struct _WapiHandleUnshared * D.14432;
  int D.14435;
  unsigned int D.14436;
  unsigned int D.14437;
  <unnamed type> D.14438;
  _Bool D.14441;
  long int D.14442;
  long int D.14443;
  struct _WapiHandleUnshared * handle;
  int thr_ret;

  _wapi_has_shut_down.58 = _wapi_has_shut_down;
  D.14393 = _wapi_has_shut_down.58 != 0;
  D.14394 = (long int) D.14393;
  D.14395 = __builtin_expect (D.14394, 0);
  if (D.14395 != 0) goto <D.14396>; else goto <D.14397>;
  <D.14396>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 669, "_wapi_has_shut_down == FALSE");
  <D.14397>:
  D.14401 = type + 4294967295;
  D.14402 = D.14401 > 1;
  D.14403 = type != 7;
  D.14404 = D.14402 & D.14403;
  if (D.14404 != 0) goto <D.14405>; else goto <D.14399>;
  <D.14405>:
  if (type != 10) goto <D.14406>; else goto <D.14399>;
  <D.14406>:
  iftmp.59 = 1;
  goto <D.14400>;
  <D.14399>:
  iftmp.59 = 0;
  <D.14400>:
  D.14407 = iftmp.59 != 0;
  D.14408 = (long int) D.14407;
  D.14409 = __builtin_expect (D.14408, 0);
  if (D.14409 != 0) goto <D.14410>; else goto <D.14411>;
  <D.14410>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 674, "_WAPI_FD_HANDLE(type)");
  <D.14411>:
  D.14416 = type == 9;
  D.14417 = type == 11;
  D.14418 = D.14416 | D.14417;
  if (D.14418 != 0) goto <D.14413>; else goto <D.14419>;
  <D.14419>:
  D.14420 = type + 4294967284;
  if (D.14420 <= 1) goto <D.14413>; else goto <D.14414>;
  <D.14413>:
  iftmp.60 = 1;
  goto <D.14415>;
  <D.14414>:
  iftmp.60 = 0;
  <D.14415>:
  D.14421 = iftmp.60 != 0;
  D.14422 = (long int) D.14421;
  D.14423 = __builtin_expect (D.14422, 0);
  if (D.14423 != 0) goto <D.14424>; else goto <D.14425>;
  <D.14424>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 675, "!_WAPI_SHARED_HANDLE(type)");
  <D.14425>:
  fd.61 = (unsigned int) fd;
  _wapi_fd_reserve.62 = _wapi_fd_reserve;
  if (fd.61 >= _wapi_fd_reserve.62) goto <D.14428>; else goto <D.14429>;
  <D.14428>:
  D.14430 = 4294967295B;
  return D.14430;
  <D.14429>:
  D.14431 = fd / 256;
  D.14432 = _wapi_private_handles[D.14431];
  if (D.14432 == 0B) goto <D.14433>; else goto <D.14434>;
  <D.14433>:
  D.14431 = fd / 256;
  init_handles_slot (D.14431);
  <D.14434>:
  D.14431 = fd / 256;
  D.14432 = _wapi_private_handles[D.14431];
  D.14435 = fd % 256;
  D.14436 = (unsigned int) D.14435;
  D.14437 = D.14436 * 144;
  handle = D.14432 + D.14437;
  D.14438 = handle->type;
  if (D.14438 != 0) goto <D.14439>; else goto <D.14440>;
  <D.14439>:
  <D.14440>:
  thr_ret = _wapi_shm_sem_lock (2);
  D.14441 = thr_ret != 0;
  D.14442 = (long int) D.14441;
  D.14443 = __builtin_expect (D.14442, 0);
  if (D.14443 != 0) goto <D.14444>; else goto <D.14445>;
  <D.14444>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 702, "thr_ret == 0");
  <D.14445>:
  _wapi_handle_init (handle, type, handle_specific);
  thr_ret = _wapi_shm_sem_unlock (2);
  D.14430 = (void *) fd;
  return D.14430;
}


init_handles_slot (int idx)
{
  long int D.14447;
  _Bool D.14450;
  long int D.14451;
  long int D.14452;
  struct _WapiHandleUnshared * D.14455;
  void * D.14458;
  _Bool D.14459;
  long int D.14460;
  long int D.14461;
  int thr_ret;

  {
    struct __pthread_unwind_buf_t __cancel_buf;
    void (*<Tc1>) (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.14447 = __builtin_expect (__not_first_call, 0);
        if (D.14447 != 0) goto <D.14448>; else goto <D.14449>;
        <D.14448>:
        __cancel_routine (__cancel_arg);
        __pthread_unwind_next (&__cancel_buf);
        <D.14449>:
        __pthread_register_cancel (&__cancel_buf);
        thr_ret = pthread_mutex_lock (&scan_mutex);
        D.14450 = thr_ret != 0;
        D.14451 = (long int) D.14450;
        D.14452 = __builtin_expect (D.14451, 0);
        if (D.14452 != 0) goto <D.14453>; else goto <D.14454>;
        <D.14453>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 650, "thr_ret == 0");
        <D.14454>:
        D.14455 = _wapi_private_handles[idx];
        if (D.14455 == 0B) goto <D.14456>; else goto <D.14457>;
        <D.14456>:
        D.14458 = monoeg_malloc0 (36864);
        _wapi_private_handles[idx] = D.14458;
        D.14455 = _wapi_private_handles[idx];
        D.14459 = D.14455 == 0B;
        D.14460 = (long int) D.14459;
        D.14461 = __builtin_expect (D.14460, 0);
        if (D.14461 != 0) goto <D.14462>; else goto <D.14463>;
        <D.14462>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 655, "_wapi_private_handles [idx]");
        <D.14463>:
        <D.14457>:
        thr_ret = pthread_mutex_unlock (&scan_mutex);
        D.14450 = thr_ret != 0;
        D.14451 = (long int) D.14450;
        D.14452 = __builtin_expect (D.14451, 0);
        if (D.14452 != 0) goto <D.14464>; else goto <D.14465>;
        <D.14464>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 659, "thr_ret == 0");
        <D.14465>:
        __pthread_unregister_cancel (&__cancel_buf);
        if (0 != 0) goto <D.14466>; else goto <D.14467>;
        <D.14466>:
        __cancel_routine (__cancel_arg);
        <D.14467>:
      }
    finally
      {
        __cancel_buf = {CLOBBER};
      }
  }
}


_wapi_lookup_handle (void * handle, WapiHandleType type, void * * handle_specific)
{
  gboolean D.14473;
  unsigned int D.14474;
  struct _WapiHandleUnshared * D.14475;
  int D.14478;
  unsigned int D.14479;
  unsigned int D.14480;
  <unnamed type> D.14481;
  _Bool D.14489;
  _Bool D.14490;
  _Bool D.14491;
  unsigned int D.14493;
  struct _WapiHandleSharedLayout * _wapi_shared_layout.63;
  unsigned int D.14495;
  <unnamed type> D.14496;
  union 
{
  struct _WapiHandle_process process;
  struct _WapiHandle_namedmutex namedmutex;
  struct _WapiHandle_namedsem namedsem;
  struct _WapiHandle_namedevent namedevent;
} * D.14499;
  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.14500;
  struct _WapiHandleUnshared * handle_data;
  guint32 handle_idx;

  handle_idx = (guint32) handle;
  if (handle_idx > 4194303) goto <D.14471>; else goto <D.14472>;
  <D.14471>:
  D.14473 = 0;
  return D.14473;
  <D.14472>:
  D.14474 = handle_idx / 256;
  D.14475 = _wapi_private_handles[D.14474];
  if (D.14475 == 0B) goto <D.14476>; else goto <D.14477>;
  <D.14476>:
  D.14474 = handle_idx / 256;
  D.14478 = (int) D.14474;
  init_handles_slot (D.14478);
  <D.14477>:
  D.14474 = handle_idx / 256;
  D.14475 = _wapi_private_handles[D.14474];
  D.14479 = handle_idx & 255;
  D.14480 = D.14479 * 144;
  handle_data = D.14475 + D.14480;
  D.14481 = handle_data->type;
  if (D.14481 != type) goto <D.14482>; else goto <D.14483>;
  <D.14482>:
  D.14473 = 0;
  return D.14473;
  <D.14483>:
  if (handle_specific == 0B) goto <D.14484>; else goto <D.14485>;
  <D.14484>:
  D.14473 = 0;
  return D.14473;
  <D.14485>:
  D.14489 = type == 9;
  D.14490 = type == 11;
  D.14491 = D.14489 | D.14490;
  if (D.14491 != 0) goto <D.14486>; else goto <D.14492>;
  <D.14492>:
  D.14493 = type + 4294967284;
  if (D.14493 <= 1) goto <D.14486>; else goto <D.14487>;
  <D.14486>:
  {
    struct _WapiHandle_shared_ref * ref;
    struct _WapiHandleShared * shared_handle_data;

    ref = &handle_data->u.shared;
    _wapi_shared_layout.63 = _wapi_shared_layout;
    D.14495 = ref->offset;
    shared_handle_data = &_wapi_shared_layout.63->handles[D.14495];
    D.14496 = shared_handle_data->type;
    if (D.14496 != type) goto <D.14497>; else goto <D.14498>;
    <D.14497>:
    D.14473 = 0;
    return D.14473;
    <D.14498>:
    D.14499 = &shared_handle_data->u;
    *handle_specific = D.14499;
  }
  goto <D.14488>;
  <D.14487>:
  D.14500 = &handle_data->u;
  *handle_specific = D.14500;
  <D.14488>:
  D.14473 = 1;
  return D.14473;
}


_wapi_handle_foreach (WapiHandleType type, gboolean (*<T23c4>) (void *, void *) on_each, void * user_data)
{
  long int D.14502;
  _Bool D.14505;
  long int D.14506;
  long int D.14507;
  struct _WapiHandleUnshared * D.14510;
  unsigned int D.14513;
  <unnamed type> D.14514;
  unsigned int D.14517;
  unsigned int D.14518;
  int D.14519;
  unsigned int _wapi_private_handle_slot_count.64;
  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 (*<Tc1>) (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.14502 = __builtin_expect (__not_first_call, 0);
        if (D.14502 != 0) goto <D.14503>; else goto <D.14504>;
        <D.14503>:
        __cancel_routine (__cancel_arg);
        __pthread_unwind_next (&__cancel_buf);
        <D.14504>:
        __pthread_register_cancel (&__cancel_buf);
        thr_ret = pthread_mutex_lock (&scan_mutex);
        D.14505 = thr_ret != 0;
        D.14506 = (long int) D.14505;
        D.14507 = __builtin_expect (D.14506, 0);
        if (D.14507 != 0) goto <D.14508>; else goto <D.14509>;
        <D.14508>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 769, "thr_ret == 0");
        <D.14509>:
        i = 0;
        goto <D.13547>;
        <D.13546>:
        D.14510 = _wapi_private_handles[i];
        if (D.14510 != 0B) goto <D.14511>; else goto <D.14512>;
        <D.14511>:
        k = 0;
        goto <D.13545>;
        <D.13544>:
        D.14510 = _wapi_private_handles[i];
        D.14513 = k * 144;
        handle_data = D.14510 + D.14513;
        D.14514 = handle_data->type;
        if (D.14514 == type) goto <D.14515>; else goto <D.14516>;
        <D.14515>:
        D.14517 = i * 256;
        D.14518 = D.14517 + k;
        ret = (void *) D.14518;
        D.14519 = on_each (ret, user_data);
        if (D.14519 == 1) goto <D.13543>; else goto <D.14520>;
        <D.14520>:
        <D.14516>:
        k = k + 1;
        <D.13545>:
        if (k <= 255) goto <D.13544>; else goto <D.13543>;
        <D.13543>:
        <D.14512>:
        i = i + 1;
        <D.13547>:
        _wapi_private_handle_slot_count.64 = _wapi_private_handle_slot_count;
        if (i < _wapi_private_handle_slot_count.64) goto <D.13546>; else goto <D.13548>;
        <D.13548>:
        thr_ret = pthread_mutex_unlock (&scan_mutex);
        D.14505 = thr_ret != 0;
        D.14506 = (long int) D.14505;
        D.14507 = __builtin_expect (D.14506, 0);
        if (D.14507 != 0) goto <D.14522>; else goto <D.14523>;
        <D.14522>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 786, "thr_ret == 0");
        <D.14523>:
        __pthread_unregister_cancel (&__cancel_buf);
        if (0 != 0) goto <D.14524>; else goto <D.14525>;
        <D.14524>:
        __cancel_routine (__cancel_arg);
        <D.14525>:
      }
    finally
      {
        __cancel_buf = {CLOBBER};
      }
  }
}


_wapi_search_handle (WapiHandleType type, gboolean (*<T23c4>) (void *, void *) check, void * user_data, void * * handle_specific, gboolean search_shared)
{
  long int D.14529;
  _Bool D.14532;
  long int D.14533;
  long int D.14534;
  struct _WapiHandleUnshared * D.14537;
  unsigned int D.14540;
  <unnamed type> D.14541;
  unsigned int D.14544;
  unsigned int D.14545;
  int D.14546;
  _Bool D.14551;
  _Bool D.14552;
  _Bool D.14553;
  unsigned int D.14555;
  struct _WapiHandleSharedLayout * _wapi_shared_layout.65;
  unsigned int _wapi_private_handle_slot_count.66;
  _Bool D.14564;
  _Bool D.14565;
  _Bool D.14566;
  <unnamed type> D.14570;
  int D.14575;
  long int D.14582;
  guint32 * D.14583;
  int now.67;
  unsigned int ret.68;
  unsigned int D.14586;
  struct _WapiHandleUnshared * D.14587;
  unsigned int D.14588;
  unsigned int D.14589;
  _Bool D.14598;
  long int D.14599;
  long int D.14600;
  union 
{
  struct _WapiHandle_process process;
  struct _WapiHandle_namedmutex namedmutex;
  struct _WapiHandle_namedsem namedsem;
  struct _WapiHandle_namedevent namedevent;
} * D.14603;
  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.14604;
  void * D.14605;
  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 (*<Tc1>) (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.14529 = __builtin_expect (__not_first_call, 0);
        if (D.14529 != 0) goto <D.14530>; else goto <D.14531>;
        <D.14530>:
        __cancel_routine (__cancel_arg);
        __pthread_unwind_next (&__cancel_buf);
        <D.14531>:
        __pthread_register_cancel (&__cancel_buf);
        thr_ret = pthread_mutex_lock (&scan_mutex);
        D.14532 = thr_ret != 0;
        D.14533 = (long int) D.14532;
        D.14534 = __builtin_expect (D.14533, 0);
        if (D.14534 != 0) goto <D.14535>; else goto <D.14536>;
        <D.14535>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 814, "thr_ret == 0");
        <D.14536>:
        i = 0;
        goto <D.13575>;
        <D.13574>:
        D.14537 = _wapi_private_handles[i];
        if (D.14537 != 0B) goto <D.14538>; else goto <D.14539>;
        <D.14538>:
        k = 0;
        goto <D.13573>;
        <D.13572>:
        D.14537 = _wapi_private_handles[i];
        D.14540 = k * 144;
        handle_data = D.14537 + D.14540;
        D.14541 = handle_data->type;
        if (D.14541 == type) goto <D.14542>; else goto <D.14543>;
        <D.14542>:
        D.14544 = i * 256;
        D.14545 = D.14544 + k;
        ret = (void *) D.14545;
        D.14546 = check (ret, user_data);
        if (D.14546 == 1) goto <D.14547>; else goto <D.14548>;
        <D.14547>:
        _wapi_handle_ref (ret);
        found = 1;
        D.14551 = type == 9;
        D.14552 = type == 11;
        D.14553 = D.14551 | D.14552;
        if (D.14553 != 0) goto <D.14549>; else goto <D.14554>;
        <D.14554>:
        D.14555 = type + 4294967284;
        if (D.14555 <= 1) goto <D.14549>; else goto <D.14550>;
        <D.14549>:
        _wapi_shared_layout.65 = _wapi_shared_layout;
        shared = &_wapi_shared_layout.65->handles[i];
        <D.14550>:
        goto <D.13571>;
        <D.14548>:
        <D.14543>:
        k = k + 1;
        <D.13573>:
        if (k <= 255) goto <D.13572>; else goto <D.13571>;
        <D.13571>:
        <D.14539>:
        i = i + 1;
        <D.13575>:
        if (found == 0) goto <D.14557>; else goto <D.13576>;
        <D.14557>:
        _wapi_private_handle_slot_count.66 = _wapi_private_handle_slot_count;
        if (i < _wapi_private_handle_slot_count.66) goto <D.13574>; else goto <D.13576>;
        <D.13576>:
        thr_ret = pthread_mutex_unlock (&scan_mutex);
        D.14532 = thr_ret != 0;
        D.14533 = (long int) D.14532;
        D.14534 = __builtin_expect (D.14533, 0);
        if (D.14534 != 0) goto <D.14559>; else goto <D.14560>;
        <D.14559>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 839, "thr_ret == 0");
        <D.14560>:
        __pthread_unregister_cancel (&__cancel_buf);
        if (0 != 0) goto <D.14561>; else goto <D.14562>;
        <D.14561>:
        __cancel_routine (__cancel_arg);
        <D.14562>:
      }
    finally
      {
        __cancel_buf = {CLOBBER};
      }
  }
  D.14564 = found == 0;
  D.14565 = search_shared != 0;
  D.14566 = D.14564 & D.14565;
  if (D.14566 != 0) goto <D.14567>; else goto <D.14568>;
  <D.14567>:
  D.14551 = type == 9;
  D.14552 = type == 11;
  D.14553 = D.14551 | D.14552;
  if (D.14553 != 0) goto <D.14563>; else goto <D.14569>;
  <D.14569>:
  D.14555 = type + 4294967284;
  if (D.14555 <= 1) goto <D.14563>; else goto <D.13579>;
  <D.14563>:
  i = 0;
  goto <D.13581>;
  <D.13580>:
  _wapi_shared_layout.65 = _wapi_shared_layout;
  shared = &_wapi_shared_layout.65->handles[i];
  D.14570 = shared->type;
  if (D.14570 == type) goto <D.14571>; else goto <D.14572>;
  <D.14571>:
  ret = _wapi_handle_new_from_offset (type, i, 0);
  if (ret == 4294967295B) goto <D.14573>; else goto <D.14574>;
  <D.14573>:
  // predicted unlikely by continue predictor.
  goto <D.13577>;
  <D.14574>:
  D.14575 = check (ret, user_data);
  if (D.14575 == 1) goto <D.14576>; else goto <D.14577>;
  <D.14576>:
  thr_ret = _wapi_handle_lock_shared_handles ();
  D.14532 = thr_ret != 0;
  D.14533 = (long int) D.14532;
  D.14534 = __builtin_expect (D.14533, 0);
  if (D.14534 != 0) goto <D.14578>; else goto <D.14579>;
  <D.14578>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 881, "thr_ret == 0");
  <D.14579>:
  D.14570 = shared->type;
  if (D.14570 == type) goto <D.14580>; else goto <D.14581>;
  <D.14580>:
  {
    guint32 now;

    D.14582 = time (0B);
    now = (guint32) D.14582;
    D.14583 = &shared->timestamp;
    now.67 = (int) now;
    InterlockedExchange (D.14583, now.67);
    found = 1;
    ret.68 = (unsigned int) ret;
    D.14586 = ret.68 / 256;
    D.14587 = _wapi_private_handles[D.14586];
    ret.68 = (unsigned int) ret;
    D.14588 = ret.68 & 255;
    D.14589 = D.14588 * 144;
    handle_data = D.14587 + D.14589;
    _wapi_handle_unlock_shared_handles ();
    goto <D.13579>;
  }
  <D.14581>:
  _wapi_handle_unlock_shared_handles ();
  <D.14577>:
  _wapi_handle_unref (ret);
  <D.14572>:
  <D.13577>:
  i = i + 1;
  <D.13581>:
  if (i <= 255) goto <D.13580>; else goto <D.13579>;
  <D.13579>:
  <D.14568>:
  if (found == 0) goto <D.14590>; else goto <D.14591>;
  <D.14590>:
  ret = 0B;
  goto done;
  <D.14591>:
  if (handle_specific != 0B) goto <D.14592>; else goto <D.14593>;
  <D.14592>:
  D.14551 = type == 9;
  D.14552 = type == 11;
  D.14553 = D.14551 | D.14552;
  if (D.14553 != 0) goto <D.14594>; else goto <D.14597>;
  <D.14597>:
  D.14555 = type + 4294967284;
  if (D.14555 <= 1) goto <D.14594>; else goto <D.14595>;
  <D.14594>:
  D.14570 = shared->type;
  D.14598 = D.14570 != type;
  D.14599 = (long int) D.14598;
  D.14600 = __builtin_expect (D.14599, 0);
  if (D.14600 != 0) goto <D.14601>; else goto <D.14602>;
  <D.14601>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 917, "shared->type == type");
  <D.14602>:
  D.14603 = &shared->u;
  *handle_specific = D.14603;
  goto <D.14596>;
  <D.14595>:
  D.14604 = &handle_data->u;
  *handle_specific = D.14604;
  <D.14596>:
  <D.14593>:
  done:
  D.14605 = ret;
  return D.14605;
}


_wapi_search_handle_namespace (WapiHandleType type, gchar * utf8_name)
{
  int iftmp.69;
  _Bool D.14616;
  _Bool D.14617;
  _Bool D.14618;
  unsigned int D.14620;
  _Bool D.14622;
  long int D.14623;
  long int D.14624;
  _Bool D.14627;
  long int D.14628;
  long int D.14629;
  struct _WapiHandleSharedLayout * _wapi_shared_layout.70;
  <unnamed type> D.14633;
  unsigned int D.14634;
  int D.13601;
  gchar[261] * D.14637;
  gint32 D.14642;
  struct _WapiHandleShared * shared_handle_data;
  guint32 i;
  gint32 ret;
  int thr_ret;
  void done = <<< error >>>;

  ret = 0;
  D.14616 = type != 9;
  D.14617 = type != 11;
  D.14618 = D.14616 & D.14617;
  if (D.14618 != 0) goto <D.14619>; else goto <D.14614>;
  <D.14619>:
  D.14620 = type + 4294967284;
  if (D.14620 > 1) goto <D.14621>; else goto <D.14614>;
  <D.14621>:
  iftmp.69 = 1;
  goto <D.14615>;
  <D.14614>:
  iftmp.69 = 0;
  <D.14615>:
  D.14622 = iftmp.69 != 0;
  D.14623 = (long int) D.14622;
  D.14624 = __builtin_expect (D.14623, 0);
  if (D.14624 != 0) goto <D.14625>; else goto <D.14626>;
  <D.14625>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 940, "_WAPI_SHARED_HANDLE(type)");
  <D.14626>:
  _wapi_handle_collect ();
  thr_ret = _wapi_handle_lock_shared_handles ();
  D.14627 = thr_ret != 0;
  D.14628 = (long int) D.14627;
  D.14629 = __builtin_expect (D.14628, 0);
  if (D.14629 != 0) goto <D.14630>; else goto <D.14631>;
  <D.14630>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 951, "thr_ret == 0");
  <D.14631>:
  i = 1;
  goto <D.13604>;
  <D.13603>:
  {
    struct WapiSharedNamespace * sharedns;

    _wapi_shared_layout.70 = _wapi_shared_layout;
    shared_handle_data = &_wapi_shared_layout.70->handles[i];
    D.14633 = shared_handle_data->type;
    D.14634 = D.14633 + 4294967285;
    if (D.14634 > 2) goto <D.14635>; else goto <D.14636>;
    <D.14635>:
    // predicted unlikely by continue predictor.
    goto <D.13592>;
    <D.14636>:
    sharedns = &shared_handle_data->u;
    {
      size_t __s1_len;
      size_t __s2_len;

      D.14637 = &sharedns->name;
      D.13601 = __builtin_strcmp (D.14637, utf8_name);
    }
    if (D.13601 == 0) goto <D.14638>; else goto <D.14639>;
    <D.14638>:
    D.14633 = shared_handle_data->type;
    if (D.14633 != type) goto <D.14640>; else goto <D.14641>;
    <D.14640>:
    ret = -1;
    goto done;
    <D.14641>:
    ret = (gint32) i;
    goto done;
    <D.14639>:
  }
  <D.13592>:
  i = i + 1;
  <D.13604>:
  if (i <= 255) goto <D.13603>; else goto <D.13605>;
  <D.13605>:
  done:
  _wapi_handle_unlock_shared_handles ();
  D.14642 = ret;
  return D.14642;
}


_wapi_handle_ref (void * handle)
{
  <unnamed type> D.14646;
  unsigned int D.14649;
  struct _WapiHandleUnshared * D.14650;
  unsigned int D.14651;
  unsigned int D.14652;
  guint * D.14653;
  <unnamed type> D.14656;
  _Bool D.14657;
  _Bool D.14658;
  _Bool D.14659;
  <unnamed type> D.14661;
  struct _WapiHandleSharedLayout * _wapi_shared_layout.71;
  unsigned int D.14664;
  long int D.14665;
  guint32 * D.14666;
  int now.72;
  guint32 idx;
  struct _WapiHandleUnshared * handle_data;
  static const char __func__[17] = "_wapi_handle_ref";

  idx = (guint32) handle;
  if (idx > 4194303) goto <D.14644>; else goto <D.14645>;
  <D.14644>:
  return;
  <D.14645>:
  D.14646 = _wapi_handle_type (handle);
  if (D.14646 == 0) goto <D.14647>; else goto <D.14648>;
  <D.14647>:
  monoeg_g_log (0B, 16, "%s: Attempting to ref unused handle %p", &__func__, handle);
  return;
  <D.14648>:
  D.14649 = idx / 256;
  D.14650 = _wapi_private_handles[D.14649];
  D.14651 = idx & 255;
  D.14652 = D.14651 * 144;
  handle_data = D.14650 + D.14652;
  D.14653 = &handle_data->ref;
  InterlockedIncrement (D.14653);
  D.14656 = handle_data->type;
  D.14657 = D.14656 == 9;
  D.14658 = D.14656 == 11;
  D.14659 = D.14657 | D.14658;
  if (D.14659 != 0) goto <D.14654>; else goto <D.14660>;
  <D.14660>:
  D.14661 = handle_data->type;
  if (D.14661 == 12) goto <D.14654>; else goto <D.14662>;
  <D.14662>:
  D.14661 = handle_data->type;
  if (D.14661 == 13) goto <D.14654>; else goto <D.14655>;
  <D.14654>:
  {
    struct _WapiHandleShared * shared_data;
    guint32 now;

    _wapi_shared_layout.71 = _wapi_shared_layout;
    D.14664 = handle_data->u.shared.offset;
    shared_data = &_wapi_shared_layout.71->handles[D.14664];
    D.14665 = time (0B);
    now = (guint32) D.14665;
    D.14666 = &shared_data->timestamp;
    now.72 = (int) now;
    InterlockedExchange (D.14666, now.72);
  }
  <D.14655>:
}


_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)
{
  gboolean D.14671;
  unsigned int D.14672;
  struct _WapiHandleUnshared * D.14673;
  unsigned int D.14674;
  unsigned int D.14675;
  struct _WapiHandleUnshared * D.14676;
  <unnamed type> D.14677;
  unsigned int D.14678;
  _Bool D.14679;
  guint32 idx;
  WapiHandleType type;

  idx = (guint32) handle;
  if (idx > 4194303) goto <D.14669>; else goto <D.14670>;
  <D.14669>:
  D.14671 = 0;
  return D.14671;
  <D.14670>:
  D.14672 = idx / 256;
  D.14673 = _wapi_private_handles[D.14672];
  D.14674 = idx & 255;
  D.14675 = D.14674 * 144;
  D.14676 = D.14673 + D.14675;
  type = D.14676->type;
  D.14677 = handle_caps[type];
  D.14678 = D.14677 & caps;
  D.14679 = D.14678 != 0;
  D.14671 = (gboolean) D.14679;
  return D.14671;
}


_wapi_handle_ops_close (void * handle, void * data)
{
  unsigned int D.14683;
  struct _WapiHandleUnshared * D.14684;
  unsigned int D.14685;
  unsigned int D.14686;
  struct _WapiHandleUnshared * D.14687;
  struct _WapiHandleOps * D.14688;
  void (*<T1653>) (void *, void *) D.14691;
  guint32 idx;
  WapiHandleType type;

  idx = (guint32) handle;
  if (idx > 4194303) goto <D.14681>; else goto <D.14682>;
  <D.14681>:
  return;
  <D.14682>:
  D.14683 = idx / 256;
  D.14684 = _wapi_private_handles[D.14683];
  D.14685 = idx & 255;
  D.14686 = D.14685 * 144;
  D.14687 = D.14684 + D.14686;
  type = D.14687->type;
  D.14688 = handle_ops[type];
  if (D.14688 != 0B) goto <D.14689>; else goto <D.14690>;
  <D.14689>:
  D.14688 = handle_ops[type];
  D.14691 = D.14688->close;
  if (D.14691 != 0B) goto <D.14692>; else goto <D.14693>;
  <D.14692>:
  D.14688 = handle_ops[type];
  D.14691 = D.14688->close;
  D.14691 (handle, data);
  <D.14693>:
  <D.14690>:
}


_wapi_handle_ops_signal (void * handle)
{
  unsigned int D.14697;
  struct _WapiHandleUnshared * D.14698;
  unsigned int D.14699;
  unsigned int D.14700;
  struct _WapiHandleUnshared * D.14701;
  struct _WapiHandleOps * D.14702;
  void (*<T15c0>) (void *) D.14705;
  guint32 idx;
  WapiHandleType type;

  idx = (guint32) handle;
  if (idx > 4194303) goto <D.14695>; else goto <D.14696>;
  <D.14695>:
  return;
  <D.14696>:
  D.14697 = idx / 256;
  D.14698 = _wapi_private_handles[D.14697];
  D.14699 = idx & 255;
  D.14700 = D.14699 * 144;
  D.14701 = D.14698 + D.14700;
  type = D.14701->type;
  D.14702 = handle_ops[type];
  if (D.14702 != 0B) goto <D.14703>; else goto <D.14704>;
  <D.14703>:
  D.14702 = handle_ops[type];
  D.14705 = D.14702->signal;
  if (D.14705 != 0B) goto <D.14706>; else goto <D.14707>;
  <D.14706>:
  D.14702 = handle_ops[type];
  D.14705 = D.14702->signal;
  D.14705 (handle);
  <D.14707>:
  <D.14704>:
}


_wapi_handle_ops_own (void * handle)
{
  gboolean D.14711;
  unsigned int D.14712;
  struct _WapiHandleUnshared * D.14713;
  unsigned int D.14714;
  unsigned int D.14715;
  struct _WapiHandleUnshared * D.14716;
  struct _WapiHandleOps * D.14718;
  gboolean (*<T2227>) (void *) D.14720;
  guint32 idx;
  WapiHandleType type;

  idx = (guint32) handle;
  if (idx > 4194303) goto <D.14709>; else goto <D.14710>;
  <D.14709>:
  D.14711 = 0;
  return D.14711;
  <D.14710>:
  D.14712 = idx / 256;
  D.14713 = _wapi_private_handles[D.14712];
  D.14714 = idx & 255;
  D.14715 = D.14714 * 144;
  D.14716 = D.14713 + D.14715;
  type = D.14716->type;
  D.14718 = handle_ops[type];
  if (D.14718 != 0B) goto <D.14719>; else goto <D.14717>;
  <D.14719>:
  D.14718 = handle_ops[type];
  D.14720 = D.14718->own_handle;
  if (D.14720 != 0B) goto <D.14721>; else goto <D.14717>;
  <D.14721>:
  D.14718 = handle_ops[type];
  D.14720 = D.14718->own_handle;
  D.14711 = D.14720 (handle);
  return D.14711;
  <D.14717>:
  D.14711 = 0;
  return D.14711;
}


_wapi_handle_ops_isowned (void * handle)
{
  gboolean D.14725;
  unsigned int D.14726;
  struct _WapiHandleUnshared * D.14727;
  unsigned int D.14728;
  unsigned int D.14729;
  struct _WapiHandleUnshared * D.14730;
  struct _WapiHandleOps * D.14732;
  gboolean (*<T2227>) (void *) D.14734;
  guint32 idx;
  WapiHandleType type;

  idx = (guint32) handle;
  if (idx > 4194303) goto <D.14723>; else goto <D.14724>;
  <D.14723>:
  D.14725 = 0;
  return D.14725;
  <D.14724>:
  D.14726 = idx / 256;
  D.14727 = _wapi_private_handles[D.14726];
  D.14728 = idx & 255;
  D.14729 = D.14728 * 144;
  D.14730 = D.14727 + D.14729;
  type = D.14730->type;
  D.14732 = handle_ops[type];
  if (D.14732 != 0B) goto <D.14733>; else goto <D.14731>;
  <D.14733>:
  D.14732 = handle_ops[type];
  D.14734 = D.14732->is_owned;
  if (D.14734 != 0B) goto <D.14735>; else goto <D.14731>;
  <D.14735>:
  D.14732 = handle_ops[type];
  D.14734 = D.14732->is_owned;
  D.14725 = D.14734 (handle);
  return D.14725;
  <D.14731>:
  D.14725 = 0;
  return D.14725;
}


_wapi_handle_ops_special_wait (void * handle, guint32 timeout, gboolean alertable)
{
  guint32 D.14739;
  unsigned int D.14740;
  struct _WapiHandleUnshared * D.14741;
  unsigned int D.14742;
  unsigned int D.14743;
  struct _WapiHandleUnshared * D.14744;
  struct _WapiHandleOps * D.14746;
  guint32 (*<T222c>) (void *, guint32, gboolean) D.14748;
  guint32 idx;
  WapiHandleType type;

  idx = (guint32) handle;
  if (idx > 4194303) goto <D.14737>; else goto <D.14738>;
  <D.14737>:
  D.14739 = 4294967295;
  return D.14739;
  <D.14738>:
  D.14740 = idx / 256;
  D.14741 = _wapi_private_handles[D.14740];
  D.14742 = idx & 255;
  D.14743 = D.14742 * 144;
  D.14744 = D.14741 + D.14743;
  type = D.14744->type;
  D.14746 = handle_ops[type];
  if (D.14746 != 0B) goto <D.14747>; else goto <D.14745>;
  <D.14747>:
  D.14746 = handle_ops[type];
  D.14748 = D.14746->special_wait;
  if (D.14748 != 0B) goto <D.14749>; else goto <D.14745>;
  <D.14749>:
  D.14746 = handle_ops[type];
  D.14748 = D.14746->special_wait;
  D.14739 = D.14748 (handle, timeout, alertable);
  return D.14739;
  <D.14745>:
  D.14739 = 4294967295;
  return D.14739;
}


_wapi_handle_ops_prewait (void * handle)
{
  unsigned int D.14753;
  struct _WapiHandleUnshared * D.14754;
  unsigned int D.14755;
  unsigned int D.14756;
  struct _WapiHandleUnshared * D.14757;
  struct _WapiHandleOps * D.14758;
  void (*<T15c0>) (void *) D.14761;
  guint32 idx;
  WapiHandleType type;

  idx = (guint32) handle;
  if (idx > 4194303) goto <D.14751>; else goto <D.14752>;
  <D.14751>:
  return;
  <D.14752>:
  D.14753 = idx / 256;
  D.14754 = _wapi_private_handles[D.14753];
  D.14755 = idx & 255;
  D.14756 = D.14755 * 144;
  D.14757 = D.14754 + D.14756;
  type = D.14757->type;
  D.14758 = handle_ops[type];
  if (D.14758 != 0B) goto <D.14759>; else goto <D.14760>;
  <D.14759>:
  D.14758 = handle_ops[type];
  D.14761 = D.14758->prewait;
  if (D.14761 != 0B) goto <D.14762>; else goto <D.14763>;
  <D.14762>:
  D.14758 = handle_ops[type];
  D.14761 = D.14758->prewait;
  D.14761 (handle);
  <D.14763>:
  <D.14760>:
}


CloseHandle (void * handle)
{
  struct _WapiHandleUnshared * D.14767;
  <unnamed type> D.14768;
  gboolean D.14771;

  if (handle == 0B) goto <D.14765>; else goto <D.14766>;
  <D.14765>:
  D.14767 = _wapi_private_handles[0];
  D.14768 = D.14767->type;
  if (D.14768 != 2) goto <D.14769>; else goto <D.14770>;
  <D.14769>:
  SetLastError (87);
  D.14771 = 0;
  return D.14771;
  <D.14770>:
  <D.14766>:
  if (handle == 4294967295B) goto <D.14772>; else goto <D.14773>;
  <D.14772>:
  SetLastError (87);
  D.14771 = 0;
  return D.14771;
  <D.14773>:
  _wapi_handle_unref (handle);
  D.14771 = 1;
  return D.14771;
}


DuplicateHandle (void * srcprocess, void * src, void * targetprocess, void * * target, guint32 access, gboolean inherit, guint32 options)
{
  _Bool D.14775;
  _Bool D.14776;
  _Bool D.14777;
  gboolean D.14780;
  void * D.14783;
  void * D.14787;

  D.14775 = srcprocess != 4294967295B;
  D.14776 = targetprocess != 4294967295B;
  D.14777 = D.14775 | D.14776;
  if (D.14777 != 0) goto <D.14778>; else goto <D.14779>;
  <D.14778>:
  SetLastError (6);
  D.14780 = 0;
  return D.14780;
  <D.14779>:
  if (src == 4294967295B) goto <D.14781>; else goto <D.14782>;
  <D.14781>:
  D.14783 = _wapi_process_duplicate ();
  *target = D.14783;
  goto <D.14784>;
  <D.14782>:
  if (src == 4294967294B) goto <D.14785>; else goto <D.14786>;
  <D.14785>:
  D.14787 = _wapi_thread_duplicate ();
  *target = D.14787;
  goto <D.14788>;
  <D.14786>:
  _wapi_handle_ref (src);
  *target = src;
  <D.14788>:
  <D.14784>:
  D.14780 = 1;
  return D.14780;
}


_wapi_handle_count_signalled_handles (guint32 numhandles, void * * handles, gboolean waitall, guint32 * retcount, guint32 * lowest)
{
  _Bool D.14790;
  long int D.14791;
  long int D.14792;
  unsigned int D.14795;
  void * * D.14796;
  unsigned int D.14797;
  struct _WapiHandleUnshared * D.14798;
  unsigned int D.14799;
  unsigned int D.14800;
  struct _WapiHandleUnshared * D.14801;
  unsigned int i.73;
  unsigned int D.14811;
  unsigned int D.14812;
  struct _WapiHandleUnshared * D.14813;
  unsigned int D.14814;
  unsigned int D.14815;
  struct _WapiHandleUnshared * D.14816;
  int D.14822;
  int D.14824;
  _Bool D.14825;
  _Bool D.14826;
  _Bool D.14827;
  unsigned int D.14829;
  struct _WapiHandleSharedLayout * _wapi_shared_layout.74;
  unsigned int handle.75;
  unsigned int D.14832;
  struct _WapiHandleUnshared * D.14833;
  unsigned int D.14834;
  unsigned int D.14835;
  struct _WapiHandleUnshared * D.14836;
  unsigned int D.14837;
  int D.14838;
  _Bool D.14839;
  _Bool D.14840;
  _Bool D.14841;
  int D.14844;
  unsigned int D.14845;
  _Bool D.14851;
  _Bool D.14852;
  _Bool D.14853;
  _Bool D.14855;
  _Bool D.14856;
  _Bool D.14857;
  gboolean D.14858;
  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.14790 = thr_ret != 0;
  D.14791 = (long int) D.14790;
  D.14792 = __builtin_expect (D.14791, 0);
  if (D.14792 != 0) goto <D.14793>; else goto <D.14794>;
  <D.14793>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 1375, "thr_ret == 0");
  <D.14794>:
  i = 0;
  goto <D.13723>;
  <D.13722>:
  {
    void * handle;
    guint32 idx;

    D.14795 = i * 4;
    D.14796 = handles + D.14795;
    handle = *D.14796;
    idx = (guint32) handle;
    D.14797 = idx / 256;
    D.14798 = _wapi_private_handles[D.14797];
    D.14799 = idx & 255;
    D.14800 = D.14799 * 144;
    D.14801 = D.14798 + D.14800;
    type = D.14801->type;
    thr_ret = _wapi_handle_trylock_handle (handle);
    if (thr_ret != 0) goto <D.14802>; else goto <D.14803>;
    <D.14802>:
    thr_ret = _wapi_handle_unlock_shared_handles ();
    D.14790 = thr_ret != 0;
    D.14791 = (long int) D.14790;
    D.14792 = __builtin_expect (D.14791, 0);
    if (D.14792 != 0) goto <D.14804>; else goto <D.14805>;
    <D.14804>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 1394, "thr_ret == 0");
    <D.14805>:
    goto <D.13719>;
    <D.13718>:
    D.14795 = i * 4;
    D.14796 = handles + D.14795;
    handle = *D.14796;
    idx = (guint32) handle;
    thr_ret = _wapi_handle_unlock_handle (handle);
    D.14790 = thr_ret != 0;
    D.14791 = (long int) D.14790;
    D.14792 = __builtin_expect (D.14791, 0);
    if (D.14792 != 0) goto <D.14806>; else goto <D.14807>;
    <D.14806>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 1401, "thr_ret == 0");
    <D.14807>:
    <D.13719>:
    i.73 = i;
    i = i.73 + 4294967295;
    if (i.73 != 0) goto <D.13718>; else goto <D.13720>;
    <D.13720>:
    iter = iter + 1;
    if (iter == 100) goto <D.14809>; else goto <D.14810>;
    <D.14809>:
    monoeg_g_log (0B, 16, "%s: iteration overflow!", &__func__);
    iter = 1;
    <D.14810>:
    D.14811 = iter * 10;
    _wapi_handle_spin (D.14811);
    goto again;
    <D.14803>:
  }
  i = i + 1;
  <D.13723>:
  if (i < numhandles) goto <D.13722>; else goto <D.13724>;
  <D.13724>:
  count = 0;
  *lowest = numhandles;
  i = 0;
  goto <D.13728>;
  <D.13727>:
  {
    void * handle;
    guint32 idx;

    D.14795 = i * 4;
    D.14796 = handles + D.14795;
    handle = *D.14796;
    idx = (guint32) handle;
    D.14812 = idx / 256;
    D.14813 = _wapi_private_handles[D.14812];
    D.14814 = idx & 255;
    D.14815 = D.14814 * 144;
    D.14816 = D.14813 + D.14815;
    type = D.14816->type;
    D.14822 = _wapi_handle_test_capabilities (handle, 4);
    if (D.14822 == 1) goto <D.14823>; else goto <D.14817>;
    <D.14823>:
    D.14824 = _wapi_handle_ops_isowned (handle);
    if (D.14824 == 1) goto <D.14818>; else goto <D.14817>;
    <D.14817>:
    D.14825 = type == 9;
    D.14826 = type == 11;
    D.14827 = D.14825 | D.14826;
    if (D.14827 != 0) goto <D.14819>; else goto <D.14828>;
    <D.14828>:
    D.14829 = type + 4294967284;
    if (D.14829 <= 1) goto <D.14819>; else goto <D.14820>;
    <D.14819>:
    _wapi_shared_layout.74 = _wapi_shared_layout;
    handle.75 = (unsigned int) handle;
    D.14832 = handle.75 / 256;
    D.14833 = _wapi_private_handles[D.14832];
    handle.75 = (unsigned int) handle;
    D.14834 = handle.75 & 255;
    D.14835 = D.14834 * 144;
    D.14836 = D.14833 + D.14835;
    D.14837 = D.14836->u.shared.offset;
    D.14838 = _wapi_shared_layout.74->handles[D.14837].signalled;
    if (D.14838 == 1) goto <D.14818>; else goto <D.14820>;
    <D.14820>:
    D.14839 = type != 9;
    D.14840 = type != 11;
    D.14841 = D.14839 & D.14840;
    if (D.14841 != 0) goto <D.14842>; else goto <D.14821>;
    <D.14842>:
    D.14829 = type + 4294967284;
    if (D.14829 > 1) goto <D.14843>; else goto <D.14821>;
    <D.14843>:
    D.14812 = idx / 256;
    D.14813 = _wapi_private_handles[D.14812];
    D.14814 = idx & 255;
    D.14815 = D.14814 * 144;
    D.14816 = D.14813 + D.14815;
    D.14844 = D.14816->signalled;
    if (D.14844 == 1) goto <D.14818>; else goto <D.14821>;
    <D.14818>:
    count = count + 1;
    D.14845 = *lowest;
    if (D.14845 > i) goto <D.14846>; else goto <D.14847>;
    <D.14846>:
    *lowest = i;
    <D.14847>:
    <D.14821>:
  }
  i = i + 1;
  <D.13728>:
  if (i < numhandles) goto <D.13727>; else goto <D.13729>;
  <D.13729>:
  D.14851 = waitall == 1;
  D.14852 = count == numhandles;
  D.14853 = D.14851 & D.14852;
  if (D.14853 != 0) goto <D.14848>; else goto <D.14854>;
  <D.14854>:
  D.14855 = waitall == 0;
  D.14856 = count != 0;
  D.14857 = D.14855 & D.14856;
  if (D.14857 != 0) goto <D.14848>; else goto <D.14849>;
  <D.14848>:
  ret = 1;
  goto <D.14850>;
  <D.14849>:
  ret = 0;
  <D.14850>:
  *retcount = count;
  D.14858 = ret;
  return D.14858;
}


_wapi_handle_trylock_handle (void * handle)
{
  int D.14862;
  <unnamed type> D.14865;
  <unnamed type> D.14867;
  <unnamed type> D.14869;
  <unnamed type> D.14871;
  unsigned int D.14872;
  struct _WapiHandleUnshared * D.14873;
  unsigned int D.14874;
  unsigned int D.14875;
  struct _WapiHandleUnshared * D.14876;
  union mono_mutex_t * D.14877;
  guint32 idx;
  int ret;

  idx = (guint32) handle;
  if (idx > 4194303) goto <D.14860>; else goto <D.14861>;
  <D.14860>:
  D.14862 = 0;
  return D.14862;
  <D.14861>:
  _wapi_handle_ref (handle);
  D.14865 = _wapi_handle_type (handle);
  if (D.14865 == 9) goto <D.14863>; else goto <D.14866>;
  <D.14866>:
  D.14867 = _wapi_handle_type (handle);
  if (D.14867 == 11) goto <D.14863>; else goto <D.14868>;
  <D.14868>:
  D.14869 = _wapi_handle_type (handle);
  if (D.14869 == 12) goto <D.14863>; else goto <D.14870>;
  <D.14870>:
  D.14871 = _wapi_handle_type (handle);
  if (D.14871 == 13) goto <D.14863>; else goto <D.14864>;
  <D.14863>:
  D.14862 = 0;
  return D.14862;
  <D.14864>:
  D.14872 = idx / 256;
  D.14873 = _wapi_private_handles[D.14872];
  D.14874 = idx & 255;
  D.14875 = D.14874 * 144;
  D.14876 = D.14873 + D.14875;
  D.14877 = &D.14876->signal_mutex;
  ret = pthread_mutex_trylock (D.14877);
  if (ret != 0) goto <D.14878>; else goto <D.14879>;
  <D.14878>:
  _wapi_handle_unref (handle);
  <D.14879>:
  D.14862 = ret;
  return D.14862;
}


_wapi_handle_unlock_handle (void * handle)
{
  int D.14883;
  <unnamed type> D.14886;
  <unnamed type> D.14888;
  <unnamed type> D.14890;
  <unnamed type> D.14892;
  unsigned int D.14893;
  struct _WapiHandleUnshared * D.14894;
  unsigned int D.14895;
  unsigned int D.14896;
  struct _WapiHandleUnshared * D.14897;
  union mono_mutex_t * D.14898;
  guint32 idx;
  int ret;

  idx = (guint32) handle;
  if (idx > 4194303) goto <D.14881>; else goto <D.14882>;
  <D.14881>:
  D.14883 = 0;
  return D.14883;
  <D.14882>:
  D.14886 = _wapi_handle_type (handle);
  if (D.14886 == 9) goto <D.14884>; else goto <D.14887>;
  <D.14887>:
  D.14888 = _wapi_handle_type (handle);
  if (D.14888 == 11) goto <D.14884>; else goto <D.14889>;
  <D.14889>:
  D.14890 = _wapi_handle_type (handle);
  if (D.14890 == 12) goto <D.14884>; else goto <D.14891>;
  <D.14891>:
  D.14892 = _wapi_handle_type (handle);
  if (D.14892 == 13) goto <D.14884>; else goto <D.14885>;
  <D.14884>:
  _wapi_handle_unref (handle);
  D.14883 = 0;
  return D.14883;
  <D.14885>:
  D.14893 = idx / 256;
  D.14894 = _wapi_private_handles[D.14893];
  D.14895 = idx & 255;
  D.14896 = D.14895 * 144;
  D.14897 = D.14894 + D.14896;
  D.14898 = &D.14897->signal_mutex;
  ret = pthread_mutex_unlock (D.14898);
  _wapi_handle_unref (handle);
  D.14883 = ret;
  return D.14883;
}


_wapi_handle_spin (guint32 ms)
{
  _Bool D.14900;
  long int D.14901;
  long int D.14902;
  unsigned int D.14905;
  long int D.14906;
  struct timespec sleepytime;

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


_wapi_handle_unlock_handles (guint32 numhandles, void * * handles)
{
  _Bool D.14907;
  long int D.14908;
  long int D.14909;
  unsigned int D.14912;
  void * * D.14913;
  guint32 i;
  int thr_ret;

  thr_ret = _wapi_handle_unlock_shared_handles ();
  D.14907 = thr_ret != 0;
  D.14908 = (long int) D.14907;
  D.14909 = __builtin_expect (D.14908, 0);
  if (D.14909 != 0) goto <D.14910>; else goto <D.14911>;
  <D.14910>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 1474, "thr_ret == 0");
  <D.14911>:
  i = 0;
  goto <D.13738>;
  <D.13737>:
  {
    void * handle;

    D.14912 = i * 4;
    D.14913 = handles + D.14912;
    handle = *D.14913;
    thr_ret = _wapi_handle_unlock_handle (handle);
    D.14907 = thr_ret != 0;
    D.14908 = (long int) D.14907;
    D.14909 = __builtin_expect (D.14908, 0);
    if (D.14909 != 0) goto <D.14914>; else goto <D.14915>;
    <D.14914>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 1482, "thr_ret == 0");
    <D.14915>:
  }
  i = i + 1;
  <D.13738>:
  if (i < numhandles) goto <D.13737>; else goto <D.13739>;
  <D.13739>:
}


_wapi_handle_wait_signal (gboolean poll)
{
  int D.14916;
  void * _wapi_global_signal_handle.76;

  _wapi_global_signal_handle.76 = _wapi_global_signal_handle;
  D.14916 = _wapi_handle_timedwait_signal_handle (_wapi_global_signal_handle.76, 0B, 1, poll);
  return D.14916;
}


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

  _wapi_global_signal_handle.77 = _wapi_global_signal_handle;
  D.14919 = _wapi_handle_timedwait_signal_handle (_wapi_global_signal_handle.77, timeout, 1, poll);
  return D.14919;
}


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

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


_wapi_handle_timedwait_signal_handle (void * handle, struct timespec * timeout, gboolean alertable, gboolean poll)
{
  <unnamed type> D.14926;
  <unnamed type> D.14928;
  <unnamed type> D.14930;
  <unnamed type> D.14932;
  struct _WapiHandleSharedLayout * _wapi_shared_layout.78;
  unsigned int handle.79;
  unsigned int D.14935;
  struct _WapiHandleUnshared * D.14936;
  unsigned int D.14937;
  unsigned int D.14938;
  struct _WapiHandleUnshared * D.14939;
  unsigned int D.14940;
  int D.14941;
  int D.14944;
  long int D.14949;
  long int D.14950;
  long int D.14953;
  long int D.14954;
  int D.14955;
  int D.14960;
  unsigned int D.14963;
  struct _WapiHandleUnshared * D.14964;
  unsigned int D.14965;
  unsigned int D.14966;
  struct _WapiHandleUnshared * D.14967;

  D.14926 = _wapi_handle_type (handle);
  if (D.14926 == 9) goto <D.14924>; else goto <D.14927>;
  <D.14927>:
  D.14928 = _wapi_handle_type (handle);
  if (D.14928 == 11) goto <D.14924>; else goto <D.14929>;
  <D.14929>:
  D.14930 = _wapi_handle_type (handle);
  if (D.14930 == 12) goto <D.14924>; else goto <D.14931>;
  <D.14931>:
  D.14932 = _wapi_handle_type (handle);
  if (D.14932 == 13) goto <D.14924>; else goto <D.14925>;
  <D.14924>:
  _wapi_shared_layout.78 = _wapi_shared_layout;
  handle.79 = (unsigned int) handle;
  D.14935 = handle.79 / 256;
  D.14936 = _wapi_private_handles[D.14935];
  handle.79 = (unsigned int) handle;
  D.14937 = handle.79 & 255;
  D.14938 = D.14937 * 144;
  D.14939 = D.14936 + D.14938;
  D.14940 = D.14939->u.shared.offset;
  D.14941 = _wapi_shared_layout.78->handles[D.14940].signalled;
  if (D.14941 == 1) goto <D.14942>; else goto <D.14943>;
  <D.14942>:
  D.14944 = 0;
  return D.14944;
  <D.14943>:
  if (timeout != 0B) goto <D.14945>; else goto <D.14946>;
  <D.14945>:
  {
    struct timespec fake_timeout;

    try
      {
        _wapi_calc_timeout (&fake_timeout, 100);
        D.14949 = fake_timeout.tv_sec;
        D.14950 = timeout->tv_sec;
        if (D.14949 > D.14950) goto <D.14947>; else goto <D.14951>;
        <D.14951>:
        D.14949 = fake_timeout.tv_sec;
        D.14950 = timeout->tv_sec;
        if (D.14949 == D.14950) goto <D.14952>; else goto <D.14948>;
        <D.14952>:
        D.14953 = fake_timeout.tv_nsec;
        D.14954 = timeout->tv_nsec;
        if (D.14953 > D.14954) goto <D.14947>; else goto <D.14948>;
        <D.14947>:
        _wapi_handle_spin (100);
        _wapi_shared_layout.78 = _wapi_shared_layout;
        handle.79 = (unsigned int) handle;
        D.14935 = handle.79 / 256;
        D.14936 = _wapi_private_handles[D.14935];
        handle.79 = (unsigned int) handle;
        D.14937 = handle.79 & 255;
        D.14938 = D.14937 * 144;
        D.14939 = D.14936 + D.14938;
        D.14940 = D.14939->u.shared.offset;
        D.14955 = _wapi_shared_layout.78->handles[D.14940].signalled;
        if (D.14955 == 1) goto <D.14956>; else goto <D.14957>;
        <D.14956>:
        D.14944 = 0;
        return D.14944;
        <D.14957>:
        D.14944 = 110;
        return D.14944;
        <D.14948>:
      }
    finally
      {
        fake_timeout = {CLOBBER};
      }
  }
  <D.14946>:
  _wapi_handle_spin (100);
  D.14944 = 0;
  return D.14944;
  <D.14925>:
  {
    guint32 idx;
    int res;
    union pthread_cond_t * cond;
    union mono_mutex_t * mutex;

    idx = (guint32) handle;
    if (alertable != 0) goto <D.14958>; else goto <D.14959>;
    <D.14958>:
    D.14960 = wapi_thread_set_wait_handle (handle);
    if (D.14960 == 0) goto <D.14961>; else goto <D.14962>;
    <D.14961>:
    D.14944 = 0;
    return D.14944;
    <D.14962>:
    <D.14959>:
    D.14963 = idx / 256;
    D.14964 = _wapi_private_handles[D.14963];
    D.14965 = idx & 255;
    D.14966 = D.14965 * 144;
    D.14967 = D.14964 + D.14966;
    cond = &D.14967->signal_cond;
    D.14963 = idx / 256;
    D.14964 = _wapi_private_handles[D.14963];
    D.14965 = idx & 255;
    D.14966 = D.14965 * 144;
    D.14967 = D.14964 + D.14966;
    mutex = &D.14967->signal_mutex;
    if (poll != 0) goto <D.14968>; else goto <D.14969>;
    <D.14968>:
    res = timedwait_signal_poll_cond (cond, mutex, timeout, alertable);
    goto <D.14970>;
    <D.14969>:
    if (timeout != 0B) goto <D.14971>; else goto <D.14972>;
    <D.14971>:
    res = pthread_cond_timedwait (cond, mutex, timeout);
    goto <D.14973>;
    <D.14972>:
    res = pthread_cond_wait (cond, mutex);
    <D.14973>:
    <D.14970>:
    if (alertable != 0) goto <D.14974>; else goto <D.14975>;
    <D.14974>:
    wapi_thread_clear_wait_handle (handle);
    <D.14975>:
    D.14944 = res;
    return D.14944;
  }
}


timedwait_signal_poll_cond (union pthread_cond_t * cond, union mono_mutex_t * mutex, struct timespec * timeout, gboolean alertable)
{
  long int D.14989;
  long int D.14990;
  long int D.14993;
  long int D.14994;
  int D.14997;
  struct timespec fake_timeout;
  int ret;

  try
    {
      if (alertable == 0) goto <D.14979>; else goto <D.14980>;
      <D.14979>:
      if (timeout != 0B) goto <D.14981>; else goto <D.14982>;
      <D.14981>:
      ret = pthread_cond_timedwait (cond, mutex, timeout);
      goto <D.14983>;
      <D.14982>:
      ret = pthread_cond_wait (cond, mutex);
      <D.14983>:
      goto <D.14984>;
      <D.14980>:
      _wapi_calc_timeout (&fake_timeout, 100);
      if (timeout != 0B) goto <D.14988>; else goto <D.14985>;
      <D.14988>:
      D.14989 = fake_timeout.tv_sec;
      D.14990 = timeout->tv_sec;
      if (D.14989 > D.14990) goto <D.14986>; else goto <D.14991>;
      <D.14991>:
      D.14989 = fake_timeout.tv_sec;
      D.14990 = timeout->tv_sec;
      if (D.14989 == D.14990) goto <D.14992>; else goto <D.14985>;
      <D.14992>:
      D.14993 = fake_timeout.tv_nsec;
      D.14994 = timeout->tv_nsec;
      if (D.14993 > D.14994) goto <D.14986>; else goto <D.14985>;
      <D.14986>:
      ret = pthread_cond_timedwait (cond, mutex, timeout);
      goto <D.14987>;
      <D.14985>:
      ret = pthread_cond_timedwait (cond, mutex, &fake_timeout);
      if (ret == 110) goto <D.14995>; else goto <D.14996>;
      <D.14995>:
      ret = 0;
      <D.14996>:
      <D.14987>:
      <D.14984>:
      D.14997 = ret;
      return D.14997;
    }
  finally
    {
      fake_timeout = {CLOBBER};
    }
}


_wapi_free_share_info (struct _WapiFileShare * share_info)
{
  int D.15000;
  _Bool D.15005;
  long int D.15006;
  long int D.15007;
  struct GHashTable * file_share_hash.80;
  _Bool D.15013;
  long int D.15014;
  long int D.15015;

  D.15000 = _wapi_shm_enabled ();
  if (D.15000 == 0) goto <D.15001>; else goto <D.15002>;
  <D.15001>:
  {
    int ret;

    ret = pthread_mutex_lock (&file_share_hash_mutex.mutex);
    if (ret != 0) goto <D.15003>; else goto <D.15004>;
    <D.15003>:
    monoeg_g_log (0B, 16, "Bad call to mono_mutex_lock result %d", ret);
    <D.15004>:
    D.15005 = ret != 0;
    D.15006 = (long int) D.15005;
    D.15007 = __builtin_expect (D.15006, 0);
    if (D.15007 != 0) goto <D.15008>; else goto <D.15009>;
    <D.15008>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 1602, "ret == 0");
    <D.15009>:
  }
  file_share_hash.80 = file_share_hash;
  monoeg_g_hash_table_remove (file_share_hash.80, share_info);
  {
    int ret;

    ret = pthread_mutex_unlock (&file_share_hash_mutex.mutex);
    if (ret != 0) goto <D.15011>; else goto <D.15012>;
    <D.15011>:
    monoeg_g_log (0B, 16, "Bad call to mono_mutex_unlock result %d", ret);
    <D.15012>:
    D.15013 = ret != 0;
    D.15014 = (long int) D.15013;
    D.15015 = __builtin_expect (D.15014, 0);
    if (D.15015 != 0) goto <D.15016>; else goto <D.15017>;
    <D.15016>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 1604, "ret == 0");
    <D.15017>:
  }
  goto <D.15018>;
  <D.15002>:
  memset (share_info, 0, 40);
  <D.15018>:
}


_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.15019;
  _Bool D.15020;
  long int D.15021;
  long int D.15022;
  int D.15027;
  struct GHashTable * file_share_hash.81;
  struct GHashTable * file_share_hash.82;
  _Bool D.15036;
  long int D.15037;
  long int D.15038;
  unsigned int D.15043;
  unsigned int D.15044;
  guint32 * D.15045;
  int D.15047;
  _Bool D.15050;
  long int D.15051;
  long int D.15052;
  struct _WapiFileShareLayout * _wapi_fileshare_layout.83;
  unsigned int D.15059;
  long long unsigned int D.15064;
  long long unsigned int D.15067;
  unsigned int i.84;
  unsigned int D.15071;
  _Bool D.15074;
  _Bool D.15075;
  _Bool D.15076;
  int D.15083;
  struct _WapiFileShare * D.15084;
  guint32 * D.15087;
  int now.85;
  gboolean D.15089;
  struct _WapiFileShare * file_share;
  guint32 now;
  int thr_ret;
  int i;
  int first_unused;
  gboolean exists;

  D.15019 = time (0B);
  now = (guint32) D.15019;
  first_unused = -1;
  exists = 0;
  thr_ret = _wapi_handle_lock_shared_handles ();
  D.15020 = thr_ret != 0;
  D.15021 = (long int) D.15020;
  D.15022 = __builtin_expect (D.15021, 0);
  if (D.15022 != 0) goto <D.15023>; else goto <D.15024>;
  <D.15023>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 1643, "thr_ret == 0");
  <D.15024>:
  thr_ret = _wapi_shm_sem_lock (2);
  D.15020 = thr_ret != 0;
  D.15021 = (long int) D.15020;
  D.15022 = __builtin_expect (D.15021, 0);
  if (D.15022 != 0) goto <D.15025>; else goto <D.15026>;
  <D.15025>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 1647, "thr_ret == 0");
  <D.15026>:
  D.15027 = _wapi_shm_enabled ();
  if (D.15027 == 0) goto <D.15028>; else goto <D.15029>;
  <D.15028>:
  {
    struct _WapiFileShare tmp;

    try
      {
        file_share_hash.81 = file_share_hash;
        if (file_share_hash.81 == 0B) goto <D.15031>; else goto <D.15032>;
        <D.15031>:
        file_share_hash.82 = monoeg_g_hash_table_new_full (wapi_share_info_hash, wapi_share_info_equal, 0B, monoeg_g_free);
        file_share_hash = file_share_hash.82;
        InitializeCriticalSection (&file_share_hash_mutex);
        <D.15032>:
        tmp.device = device;
        tmp.inode = inode;
        {
          int ret;

          ret = pthread_mutex_lock (&file_share_hash_mutex.mutex);
          if (ret != 0) goto <D.15034>; else goto <D.15035>;
          <D.15034>:
          monoeg_g_log (0B, 16, "Bad call to mono_mutex_lock result %d", ret);
          <D.15035>:
          D.15036 = ret != 0;
          D.15037 = (long int) D.15036;
          D.15038 = __builtin_expect (D.15037, 0);
          if (D.15038 != 0) goto <D.15039>; else goto <D.15040>;
          <D.15039>:
          monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 1665, "ret == 0");
          <D.15040>:
        }
        file_share_hash.81 = file_share_hash;
        file_share = monoeg_g_hash_table_lookup (file_share_hash.81, &tmp);
        if (file_share != 0B) goto <D.15041>; else goto <D.15042>;
        <D.15041>:
        D.15043 = file_share->sharemode;
        *old_sharemode = D.15043;
        D.15044 = file_share->access;
        *old_access = D.15044;
        *share_info = file_share;
        D.15045 = &file_share->handle_refs;
        InterlockedIncrement (D.15045);
        exists = 1;
        goto <D.15046>;
        <D.15042>:
        file_share = monoeg_malloc0 (40);
        file_share->device = device;
        file_share->inode = inode;
        D.15047 = _wapi_getpid ();
        file_share->opened_by_pid = D.15047;
        file_share->sharemode = new_sharemode;
        file_share->access = new_access;
        file_share->handle_refs = 1;
        *share_info = file_share;
        file_share_hash.81 = file_share_hash;
        monoeg_g_hash_table_insert_replace (file_share_hash.81, file_share, file_share, 0);
        <D.15046>:
        {
          int ret;

          ret = pthread_mutex_unlock (&file_share_hash_mutex.mutex);
          if (ret != 0) goto <D.15048>; else goto <D.15049>;
          <D.15048>:
          monoeg_g_log (0B, 16, "Bad call to mono_mutex_unlock result %d", ret);
          <D.15049>:
          D.15050 = ret != 0;
          D.15051 = (long int) D.15050;
          D.15052 = __builtin_expect (D.15051, 0);
          if (D.15052 != 0) goto <D.15053>; else goto <D.15054>;
          <D.15053>:
          monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 1689, "ret == 0");
          <D.15054>:
        }
      }
    finally
      {
        tmp = {CLOBBER};
      }
  }
  goto <D.15055>;
  <D.15029>:
  *share_info = 0B;
  i = 0;
  goto <D.13806>;
  <D.13805>:
  _wapi_fileshare_layout.83 = _wapi_fileshare_layout;
  file_share = &_wapi_fileshare_layout.83->share_info[i];
  if (first_unused == -1) goto <D.15057>; else goto <D.15058>;
  <D.15057>:
  D.15059 = file_share->handle_refs;
  if (D.15059 == 0) goto <D.15060>; else goto <D.15061>;
  <D.15060>:
  first_unused = i;
  // predicted unlikely by continue predictor.
  goto <D.13803>;
  <D.15061>:
  <D.15058>:
  D.15059 = file_share->handle_refs;
  if (D.15059 == 0) goto <D.15062>; else goto <D.15063>;
  <D.15062>:
  // predicted unlikely by continue predictor.
  goto <D.13803>;
  <D.15063>:
  D.15064 = file_share->device;
  if (D.15064 == device) goto <D.15065>; else goto <D.15066>;
  <D.15065>:
  D.15067 = file_share->inode;
  if (D.15067 == inode) goto <D.15068>; else goto <D.15069>;
  <D.15068>:
  D.15043 = file_share->sharemode;
  *old_sharemode = D.15043;
  D.15044 = file_share->access;
  *old_access = D.15044;
  *share_info = file_share;
  D.15045 = &file_share->handle_refs;
  InterlockedIncrement (D.15045);
  exists = 1;
  goto <D.13804>;
  <D.15069>:
  <D.15066>:
  <D.13803>:
  i = i + 1;
  <D.13806>:
  i.84 = (unsigned int) i;
  _wapi_fileshare_layout.83 = _wapi_fileshare_layout;
  D.15071 = _wapi_fileshare_layout.83->hwm;
  if (i.84 <= D.15071) goto <D.13805>; else goto <D.13804>;
  <D.13804>:
  if (exists == 0) goto <D.15072>; else goto <D.15073>;
  <D.15072>:
  D.15074 = i == 102400;
  D.15075 = first_unused == -1;
  D.15076 = D.15074 & D.15075;
  if (D.15076 != 0) goto <D.15077>; else goto <D.15078>;
  <D.15077>:
  goto <D.15079>;
  <D.15078>:
  if (first_unused == -1) goto <D.15080>; else goto <D.15081>;
  <D.15080>:
  _wapi_fileshare_layout.83 = _wapi_fileshare_layout;
  i = i + 1;
  file_share = &_wapi_fileshare_layout.83->share_info[i];
  _wapi_fileshare_layout.83 = _wapi_fileshare_layout;
  i.84 = (unsigned int) i;
  _wapi_fileshare_layout.83->hwm = i.84;
  goto <D.15082>;
  <D.15081>:
  _wapi_fileshare_layout.83 = _wapi_fileshare_layout;
  file_share = &_wapi_fileshare_layout.83->share_info[first_unused];
  <D.15082>:
  file_share->device = device;
  file_share->inode = inode;
  D.15083 = _wapi_getpid ();
  file_share->opened_by_pid = D.15083;
  file_share->sharemode = new_sharemode;
  file_share->access = new_access;
  file_share->handle_refs = 1;
  *share_info = file_share;
  <D.15079>:
  <D.15073>:
  D.15084 = *share_info;
  if (D.15084 != 0B) goto <D.15085>; else goto <D.15086>;
  <D.15085>:
  D.15084 = *share_info;
  D.15087 = &D.15084->timestamp;
  now.85 = (int) now;
  InterlockedExchange (D.15087, now.85);
  <D.15086>:
  <D.15055>:
  thr_ret = _wapi_shm_sem_unlock (2);
  _wapi_handle_unlock_shared_handles ();
  D.15089 = exists;
  return D.15089;
}


wapi_share_info_equal (const void * ka, const void * kb)
{
  gint D.15091;
  int iftmp.86;
  long long unsigned int D.15095;
  long long unsigned int D.15096;
  long long unsigned int D.15098;
  long long unsigned int D.15099;
  const struct _WapiFileShare * s1;
  const struct _WapiFileShare * s2;

  s1 = ka;
  s2 = kb;
  D.15095 = s1->device;
  D.15096 = s2->device;
  if (D.15095 == D.15096) goto <D.15097>; else goto <D.15093>;
  <D.15097>:
  D.15098 = s1->inode;
  D.15099 = s2->inode;
  if (D.15098 == D.15099) goto <D.15100>; else goto <D.15093>;
  <D.15100>:
  iftmp.86 = 1;
  goto <D.15094>;
  <D.15093>:
  iftmp.86 = 0;
  <D.15094>:
  D.15091 = iftmp.86;
  return D.15091;
}


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

  s = data;
  D.15103 = s->inode;
  D.15102 = (guint) D.15103;
  return D.15102;
}


_wapi_handle_check_share (struct _WapiFileShare * share_info, int fd)
{
  _Bool D.15105;
  long int D.15106;
  long int D.15107;
  int D.15112;
  int D.15115;
  struct _WapiHandleUnshared * D.15116;
  int D.15119;
  unsigned int D.15120;
  unsigned int D.15121;
  <unnamed type> D.15124;
  struct _WapiFileShare * D.15127;
  unsigned int i.87;
  unsigned int _wapi_fd_reserve.88;
  struct _WapiHandleSharedLayout * _wapi_shared_layout.89;
  <unnamed type> D.15132;
  int D.13842;
  int iftmp.90;
  int D.13841;
  const char[2] * D.15142;
  unsigned char D.15143;
  int D.15144;
  unsigned char D.15145;
  int D.15146;
  _Bool D.15147;
  _Bool D.15148;
  _Bool D.15149;
  const unsigned char * D.15152;
  unsigned char D.15153;
  int D.15154;
  const unsigned char * D.15155;
  unsigned char D.15156;
  int D.15157;
  _Bool D.15158;
  _Bool D.15159;
  const unsigned char * D.15162;
  unsigned char D.15163;
  int D.15164;
  const unsigned char * D.15165;
  unsigned char D.15166;
  int D.15167;
  _Bool D.15168;
  _Bool D.15169;
  const unsigned char * D.15172;
  unsigned char D.15173;
  int D.15174;
  const unsigned char * D.15175;
  unsigned char D.15176;
  int D.15177;
  char[256] * D.15179;
  int D.13851;
  int iftmp.91;
  int D.13850;
  const char[3] * D.15184;
  unsigned char D.15185;
  int D.15186;
  unsigned char D.15187;
  int D.15188;
  _Bool D.15189;
  _Bool D.15190;
  _Bool D.15191;
  const unsigned char * D.15194;
  unsigned char D.15195;
  int D.15196;
  const unsigned char * D.15197;
  unsigned char D.15198;
  int D.15199;
  _Bool D.15200;
  _Bool D.15201;
  const unsigned char * D.15204;
  unsigned char D.15205;
  int D.15206;
  const unsigned char * D.15207;
  unsigned char D.15208;
  int D.15209;
  _Bool D.15210;
  _Bool D.15211;
  const unsigned char * D.15214;
  unsigned char D.15215;
  int D.15216;
  const unsigned char * D.15217;
  unsigned char D.15218;
  int D.15219;
  int D.15223;
  long long unsigned int D.15224;
  long long unsigned int D.15225;
  long long unsigned int D.15228;
  long long unsigned int D.15229;
  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.15105 = thr_ret != 0;
  D.15106 = (long int) D.15105;
  D.15107 = __builtin_expect (D.15106, 0);
  if (D.15107 != 0) goto <D.15108>; else goto <D.15109>;
  <D.15108>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 1803, "thr_ret == 0");
  <D.15109>:
  thr_ret = _wapi_shm_sem_lock (2);
  D.15105 = thr_ret != 0;
  D.15106 = (long int) D.15105;
  D.15107 = __builtin_expect (D.15106, 0);
  if (D.15107 != 0) goto <D.15110>; else goto <D.15111>;
  <D.15110>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 1807, "thr_ret == 0");
  <D.15111>:
  D.15112 = access ("/proc", 0);
  if (D.15112 == -1) goto <D.15113>; else goto <D.15114>;
  <D.15113>:
  _wapi_handle_check_share_by_pid (share_info);
  goto done;
  <D.15114>:
  i = 0;
  goto <D.13824>;
  <D.13823>:
  D.15115 = i / 256;
  D.15116 = _wapi_private_handles[D.15115];
  if (D.15116 != 0B) goto <D.15117>; else goto <D.15118>;
  <D.15117>:
  {
    struct _WapiHandleUnshared * handle;

    D.15115 = i / 256;
    D.15116 = _wapi_private_handles[D.15115];
    D.15119 = i % 256;
    D.15120 = (unsigned int) D.15119;
    D.15121 = D.15120 * 144;
    handle = D.15116 + D.15121;
    if (i != fd) goto <D.15122>; else goto <D.15123>;
    <D.15122>:
    D.15124 = handle->type;
    if (D.15124 == 1) goto <D.15125>; else goto <D.15126>;
    <D.15125>:
    {
      struct _WapiHandle_file * file_handle;

      file_handle = &handle->u.file;
      D.15127 = file_handle->share_info;
      if (D.15127 == share_info) goto done; else goto <D.15128>;
      <D.15128>:
    }
    <D.15126>:
    <D.15123>:
  }
  <D.15118>:
  i = i + 1;
  <D.13824>:
  i.87 = (unsigned int) i;
  _wapi_fd_reserve.88 = _wapi_fd_reserve;
  if (i.87 < _wapi_fd_reserve.88) goto <D.13823>; else goto <D.13825>;
  <D.13825>:
  i = 0;
  goto <D.13856>;
  <D.13855>:
  {
    struct _WapiHandleShared * shared;
    struct _WapiHandle_process * process_handle;

    _wapi_shared_layout.89 = _wapi_shared_layout;
    shared = &_wapi_shared_layout.89->handles[i];
    D.15132 = shared->type;
    if (D.15132 == 9) goto <D.15133>; else goto <D.15134>;
    <D.15133>:
    {
      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.15135>; else goto <D.15136>;
          <D.15135>:
          // predicted unlikely by continue predictor.
          goto <D.13831>;
          <D.15136>:
          proc_fds = 1;
          goto <D.13852>;
          <D.13853>:
          {
            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.15140>; else goto <D.15141>;
                  <D.15140>:
                  {
                    const unsigned char * __s2;
                    int __result;

                    __s2 = &fd_entry->d_name;
                    D.15142 = ".";
                    D.15143 = MEM[(const unsigned char *)D.15142];
                    D.15144 = (int) D.15143;
                    D.15145 = *__s2;
                    D.15146 = (int) D.15145;
                    __result = D.15144 - D.15146;
                    {
                      D.15147 = __s2_len != 0;
                      D.15148 = __result == 0;
                      D.15149 = D.15147 & D.15148;
                      if (D.15149 != 0) goto <D.15150>; else goto <D.15151>;
                      <D.15150>:
                      D.15152 = &MEM[(void *)"." + 1B];
                      D.15153 = *D.15152;
                      D.15154 = (int) D.15153;
                      D.15155 = __s2 + 1;
                      D.15156 = *D.15155;
                      D.15157 = (int) D.15156;
                      __result = D.15154 - D.15157;
                      D.15158 = __s2_len > 1;
                      D.15148 = __result == 0;
                      D.15159 = D.15158 & D.15148;
                      if (D.15159 != 0) goto <D.15160>; else goto <D.15161>;
                      <D.15160>:
                      D.15162 = &MEM[(void *)"." + 2B];
                      D.15163 = *D.15162;
                      D.15164 = (int) D.15163;
                      D.15165 = __s2 + 2;
                      D.15166 = *D.15165;
                      D.15167 = (int) D.15166;
                      __result = D.15164 - D.15167;
                      D.15168 = __s2_len > 2;
                      D.15148 = __result == 0;
                      D.15169 = D.15168 & D.15148;
                      if (D.15169 != 0) goto <D.15170>; else goto <D.15171>;
                      <D.15170>:
                      D.15172 = &MEM[(void *)"." + 3B];
                      D.15173 = *D.15172;
                      D.15174 = (int) D.15173;
                      D.15175 = __s2 + 3;
                      D.15176 = *D.15175;
                      D.15177 = (int) D.15176;
                      __result = D.15174 - D.15177;
                      <D.15171>:
                      <D.15161>:
                      <D.15151>:
                    }
                    D.13841 = __result;
                  }
                  iftmp.90 = -D.13841;
                  goto <D.15178>;
                  <D.15141>:
                  D.15179 = &fd_entry->d_name;
                  iftmp.90 = __builtin_strcmp (D.15179, ".");
                  <D.15178>:
                  D.13842 = iftmp.90;
                }
                if (D.13842 == 0) goto <D.15137>; else goto <D.15180>;
                <D.15180>:
                {
                  size_t __s1_len;
                  size_t __s2_len;

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

                    __s2 = &fd_entry->d_name;
                    D.15184 = "..";
                    D.15185 = MEM[(const unsigned char *)D.15184];
                    D.15186 = (int) D.15185;
                    D.15187 = *__s2;
                    D.15188 = (int) D.15187;
                    __result = D.15186 - D.15188;
                    {
                      D.15189 = __s2_len != 0;
                      D.15190 = __result == 0;
                      D.15191 = D.15189 & D.15190;
                      if (D.15191 != 0) goto <D.15192>; else goto <D.15193>;
                      <D.15192>:
                      D.15194 = &MEM[(void *)".." + 1B];
                      D.15195 = *D.15194;
                      D.15196 = (int) D.15195;
                      D.15197 = __s2 + 1;
                      D.15198 = *D.15197;
                      D.15199 = (int) D.15198;
                      __result = D.15196 - D.15199;
                      D.15200 = __s2_len > 1;
                      D.15190 = __result == 0;
                      D.15201 = D.15200 & D.15190;
                      if (D.15201 != 0) goto <D.15202>; else goto <D.15203>;
                      <D.15202>:
                      D.15204 = &MEM[(void *)".." + 2B];
                      D.15205 = *D.15204;
                      D.15206 = (int) D.15205;
                      D.15207 = __s2 + 2;
                      D.15208 = *D.15207;
                      D.15209 = (int) D.15208;
                      __result = D.15206 - D.15209;
                      D.15210 = __s2_len > 2;
                      D.15190 = __result == 0;
                      D.15211 = D.15210 & D.15190;
                      if (D.15211 != 0) goto <D.15212>; else goto <D.15213>;
                      <D.15212>:
                      D.15214 = &MEM[(void *)".." + 3B];
                      D.15215 = *D.15214;
                      D.15216 = (int) D.15215;
                      D.15217 = __s2 + 3;
                      D.15218 = *D.15217;
                      D.15219 = (int) D.15218;
                      __result = D.15216 - D.15219;
                      <D.15213>:
                      <D.15203>:
                      <D.15193>:
                    }
                    D.13850 = __result;
                  }
                  iftmp.91 = -D.13850;
                  goto <D.15220>;
                  <D.15183>:
                  D.15179 = &fd_entry->d_name;
                  iftmp.91 = __builtin_strcmp (D.15179, "..");
                  <D.15220>:
                  D.13851 = iftmp.91;
                }
                if (D.13851 == 0) goto <D.15137>; else goto <D.15221>;
                <D.15221>:
                if (pid == self) goto <D.15222>; else goto <D.15138>;
                <D.15222>:
                D.15179 = &fd_entry->d_name;
                D.15223 = atoi (D.15179);
                if (D.15223 == fd) goto <D.15137>; else goto <D.15138>;
                <D.15137>:
                // predicted unlikely by continue predictor.
                goto <D.13852>;
                <D.15138>:
                D.15179 = &fd_entry->d_name;
                monoeg_g_snprintf (&path, 256, "/proc/%d/fd/%s", pid, D.15179);
                stat (&path, &link_stat);
                D.15224 = link_stat.st_dev;
                D.15225 = share_info->device;
                if (D.15224 == D.15225) goto <D.15226>; else goto <D.15227>;
                <D.15226>:
                D.15228 = link_stat.st_ino;
                D.15229 = share_info->inode;
                if (D.15228 == D.15229) goto <D.15230>; else goto <D.15231>;
                <D.15230>:
                found = 1;
                <D.15231>:
                <D.15227>:
              }
            finally
              {
                path = {CLOBBER};
                link_stat = {CLOBBER};
              }
          }
          <D.13852>:
          fd_entry = readdir (fd_dir);
          if (fd_entry != 0B) goto <D.13853>; else goto <D.13854>;
          <D.13854>:
          closedir (fd_dir);
        }
      finally
        {
          subdir = {CLOBBER};
        }
    }
    <D.15134>:
  }
  <D.13831>:
  i = i + 1;
  <D.13856>:
  if (i <= 255) goto <D.13855>; else goto <D.13857>;
  <D.13857>:
  if (proc_fds == 0) goto <D.15232>; else goto <D.15233>;
  <D.15232>:
  _wapi_handle_check_share_by_pid (share_info);
  goto <D.15234>;
  <D.15233>:
  if (found == 0) goto <D.15235>; else goto <D.15236>;
  <D.15235>:
  _wapi_free_share_info (share_info);
  <D.15236>:
  <D.15234>:
  done:
  thr_ret = _wapi_shm_sem_unlock (2);
  _wapi_handle_unlock_shared_handles ();
}


atoi (const char * __nptr)
{
  int D.15241;

  D.15241 = strtol (__nptr, 0B, 10);
  return D.15241;
}


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

  D.15243 = __xstat (3, __path, __statbuf);
  return D.15243;
}


_wapi_handle_check_share_by_pid (struct _WapiFileShare * share_info)
{
  int D.15245;
  int D.15246;
  int * D.15249;
  int D.15250;
  _Bool D.15251;
  _Bool D.15252;
  _Bool D.15253;

  D.15245 = share_info->opened_by_pid;
  D.15246 = kill (D.15245, 0);
  if (D.15246 == -1) goto <D.15247>; else goto <D.15248>;
  <D.15247>:
  D.15249 = __errno_location ();
  D.15250 = *D.15249;
  D.15251 = D.15250 == 3;
  D.15252 = D.15250 == 1;
  D.15253 = D.15251 | D.15252;
  if (D.15253 != 0) goto <D.15254>; else goto <D.15255>;
  <D.15254>:
  _wapi_free_share_info (share_info);
  <D.15255>:
  <D.15248>:
}


_wapi_handle_dump ()
{
  long int D.15256;
  _Bool D.15259;
  long int D.15260;
  long int D.15261;
  struct _WapiHandleUnshared * D.15264;
  unsigned int D.15267;
  <unnamed type> D.15268;
  unsigned int D.15271;
  unsigned int D.15272;
  const char * D.15273;
  const char * iftmp.92;
  int D.15275;
  unsigned int D.15279;
  void (*<T15c0>) (void *) D.15280;
  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.15281;
  unsigned int _wapi_private_handle_slot_count.93;
  struct _WapiHandleUnshared * handle_data;
  guint32 i;
  guint32 k;
  int thr_ret;

  {
    struct __pthread_unwind_buf_t __cancel_buf;
    void (*<Tc1>) (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.15256 = __builtin_expect (__not_first_call, 0);
        if (D.15256 != 0) goto <D.15257>; else goto <D.15258>;
        <D.15257>:
        __cancel_routine (__cancel_arg);
        __pthread_unwind_next (&__cancel_buf);
        <D.15258>:
        __pthread_register_cancel (&__cancel_buf);
        thr_ret = pthread_mutex_lock (&scan_mutex);
        D.15259 = thr_ret != 0;
        D.15260 = (long int) D.15259;
        D.15261 = __builtin_expect (D.15260, 0);
        if (D.15261 != 0) goto <D.15262>; else goto <D.15263>;
        <D.15262>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 1943, "thr_ret == 0");
        <D.15263>:
        i = 0;
        goto <D.13876>;
        <D.13875>:
        D.15264 = _wapi_private_handles[i];
        if (D.15264 != 0B) goto <D.15265>; else goto <D.15266>;
        <D.15265>:
        k = 0;
        goto <D.13873>;
        <D.13872>:
        D.15264 = _wapi_private_handles[i];
        D.15267 = k * 144;
        handle_data = D.15264 + D.15267;
        D.15268 = handle_data->type;
        if (D.15268 == 0) goto <D.15269>; else goto <D.15270>;
        <D.15269>:
        // predicted unlikely by continue predictor.
        goto <D.13871>;
        <D.15270>:
        D.15271 = i * 256;
        D.15272 = D.15271 + k;
        D.15268 = handle_data->type;
        D.15273 = _wapi_handle_typename[D.15268];
        D.15275 = handle_data->signalled;
        if (D.15275 != 0) goto <D.15276>; else goto <D.15277>;
        <D.15276>:
        iftmp.92 = "Sg";
        goto <D.15278>;
        <D.15277>:
        iftmp.92 = "Un";
        <D.15278>:
        D.15279 = handle_data->ref;
        monoeg_g_print ("%3x [%7s] %s %d ", D.15272, D.15273, iftmp.92, D.15279);
        D.15268 = handle_data->type;
        D.15280 = handle_details[D.15268];
        D.15281 = &handle_data->u;
        D.15280 (D.15281);
        monoeg_g_print ("\n");
        <D.13871>:
        k = k + 1;
        <D.13873>:
        if (k <= 255) goto <D.13872>; else goto <D.13874>;
        <D.13874>:
        <D.15266>:
        i = i + 1;
        <D.13876>:
        _wapi_private_handle_slot_count.93 = _wapi_private_handle_slot_count;
        if (i < _wapi_private_handle_slot_count.93) goto <D.13875>; else goto <D.13877>;
        <D.13877>:
        thr_ret = pthread_mutex_unlock (&scan_mutex);
        D.15259 = thr_ret != 0;
        D.15260 = (long int) D.15259;
        D.15261 = __builtin_expect (D.15260, 0);
        if (D.15261 != 0) goto <D.15283>; else goto <D.15284>;
        <D.15283>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 1966, "thr_ret == 0");
        <D.15284>:
        __pthread_unregister_cancel (&__cancel_buf);
        if (0 != 0) goto <D.15285>; else goto <D.15286>;
        <D.15285>:
        __cancel_routine (__cancel_arg);
        <D.15286>:
      }
    finally
      {
        __cancel_buf = {CLOBBER};
      }
  }
}


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

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


_wapi_handle_update_refs ()
{
  long int D.15290;
  _Bool D.15291;
  long int D.15292;
  long int D.15293;
  long int D.15298;
  struct _WapiHandleUnshared * D.15301;
  unsigned int D.15304;
  <unnamed type> D.15308;
  _Bool D.15309;
  _Bool D.15310;
  _Bool D.15311;
  <unnamed type> D.15313;
  struct _WapiHandleSharedLayout * _wapi_shared_layout.94;
  unsigned int D.15316;
  guint32 * D.15317;
  int now.95;
  struct _WapiFileShare * D.15321;
  _Bool D.15322;
  long int D.15323;
  long int D.15324;
  guint32 * D.15327;
  unsigned int _wapi_private_handle_slot_count.96;
  guint32 i;
  guint32 k;
  int thr_ret;
  guint32 now;

  D.15290 = time (0B);
  now = (guint32) D.15290;
  thr_ret = _wapi_handle_lock_shared_handles ();
  D.15291 = thr_ret != 0;
  D.15292 = (long int) D.15291;
  D.15293 = __builtin_expect (D.15292, 0);
  if (D.15293 != 0) goto <D.15294>; else goto <D.15295>;
  <D.15294>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 1984, "thr_ret == 0");
  <D.15295>:
  thr_ret = _wapi_shm_sem_lock (2);
  D.15291 = thr_ret != 0;
  D.15292 = (long int) D.15291;
  D.15293 = __builtin_expect (D.15292, 0);
  if (D.15293 != 0) goto <D.15296>; else goto <D.15297>;
  <D.15296>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 1988, "thr_ret == 0");
  <D.15297>:
  {
    struct __pthread_unwind_buf_t __cancel_buf;
    void (*<Tc1>) (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.15298 = __builtin_expect (__not_first_call, 0);
        if (D.15298 != 0) goto <D.15299>; else goto <D.15300>;
        <D.15299>:
        __cancel_routine (__cancel_arg);
        __pthread_unwind_next (&__cancel_buf);
        <D.15300>:
        __pthread_register_cancel (&__cancel_buf);
        thr_ret = pthread_mutex_lock (&scan_mutex);
        i = 0;
        goto <D.13902>;
        <D.13901>:
        D.15301 = _wapi_private_handles[i];
        if (D.15301 != 0B) goto <D.15302>; else goto <D.15303>;
        <D.15302>:
        k = 0;
        goto <D.13899>;
        <D.13898>:
        {
          struct _WapiHandleUnshared * handle;

          D.15301 = _wapi_private_handles[i];
          D.15304 = k * 144;
          handle = D.15301 + D.15304;
          D.15308 = handle->type;
          D.15309 = D.15308 == 9;
          D.15310 = D.15308 == 11;
          D.15311 = D.15309 | D.15310;
          if (D.15311 != 0) goto <D.15305>; else goto <D.15312>;
          <D.15312>:
          D.15313 = handle->type;
          if (D.15313 == 12) goto <D.15305>; else goto <D.15314>;
          <D.15314>:
          D.15313 = handle->type;
          if (D.15313 == 13) goto <D.15305>; else goto <D.15306>;
          <D.15305>:
          {
            struct _WapiHandleShared * shared_data;

            _wapi_shared_layout.94 = _wapi_shared_layout;
            D.15316 = handle->u.shared.offset;
            shared_data = &_wapi_shared_layout.94->handles[D.15316];
            D.15317 = &shared_data->timestamp;
            now.95 = (int) now;
            InterlockedExchange (D.15317, now.95);
          }
          goto <D.15307>;
          <D.15306>:
          D.15313 = handle->type;
          if (D.15313 == 1) goto <D.15319>; else goto <D.15320>;
          <D.15319>:
          {
            struct _WapiHandle_file * file_handle;

            file_handle = &handle->u.file;
            D.15321 = file_handle->share_info;
            D.15322 = D.15321 == 0B;
            D.15323 = (long int) D.15322;
            D.15324 = __builtin_expect (D.15323, 0);
            if (D.15324 != 0) goto <D.15325>; else goto <D.15326>;
            <D.15325>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 2014, "file_handle->share_info != NULL");
            <D.15326>:
            D.15321 = file_handle->share_info;
            D.15327 = &D.15321->timestamp;
            now.95 = (int) now;
            InterlockedExchange (D.15327, now.95);
          }
          <D.15320>:
          <D.15307>:
        }
        k = k + 1;
        <D.13899>:
        if (k <= 255) goto <D.13898>; else goto <D.13900>;
        <D.13900>:
        <D.15303>:
        i = i + 1;
        <D.13902>:
        _wapi_private_handle_slot_count.96 = _wapi_private_handle_slot_count;
        if (i < _wapi_private_handle_slot_count.96) goto <D.13901>; else goto <D.13903>;
        <D.13903>:
        thr_ret = pthread_mutex_unlock (&scan_mutex);
        D.15291 = thr_ret != 0;
        D.15292 = (long int) D.15291;
        D.15293 = __builtin_expect (D.15292, 0);
        if (D.15293 != 0) goto <D.15329>; else goto <D.15330>;
        <D.15329>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 2025, "thr_ret == 0");
        <D.15330>:
        __pthread_unregister_cancel (&__cancel_buf);
        if (0 != 0) goto <D.15331>; else goto <D.15332>;
        <D.15331>:
        __cancel_routine (__cancel_arg);
        <D.15332>:
      }
    finally
      {
        __cancel_buf = {CLOBBER};
      }
  }
  thr_ret = _wapi_shm_sem_unlock (2);
  _wapi_handle_unlock_shared_handles ();
}


