_wapi_getpid ()
{
  pid_t D.11322;

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


pid_init ()
{
  int _wapi_pid.0;

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


wapi_init ()
{
  int D.11327;
  unsigned int _wapi_fd_reserve.1;
  unsigned int _wapi_fd_reserve.2;
  unsigned int D.11330;
  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.11338;
  long int D.11339;
  long int D.11340;
  int D.11343;
  void * _wapi_fileshare_layout.10;
  struct _WapiFileShareLayout * _wapi_fileshare_layout.11;
  _Bool D.11348;
  long int D.11349;
  long int D.11350;
  int D.11353;
  void * _wapi_global_signal_handle.12;
  void * _wapi_global_signal_handle.13;
  unsigned int _wapi_global_signal_handle.14;
  unsigned int D.11359;
  struct _WapiHandleUnshared * D.11360;
  unsigned int D.11361;
  unsigned int D.11362;
  struct _WapiHandleUnshared * D.11363;
  union pthread_cond_t * _wapi_global_signal_cond.15;
  union mono_mutex_t * _wapi_global_signal_mutex.16;

  if (0 != 0) goto <D.11325>; else goto <D.11326>;
  <D.11325>:
  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.11326>:
  D.11327 = getdtablesize ();
  _wapi_fd_reserve.1 = (unsigned int) D.11327;
  _wapi_fd_reserve = _wapi_fd_reserve.1;
  _wapi_fd_reserve.2 = _wapi_fd_reserve;
  D.11330 = _wapi_fd_reserve.2 + 255;
  _wapi_fd_reserve.3 = D.11330 & 4294967040;
  _wapi_fd_reserve = _wapi_fd_reserve.3;
  <D.10815>:
  _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.10815>; else goto <D.10816>;
  <D.10816>:
  _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.11338 = _wapi_shared_layout.9 == 0B;
  D.11339 = (long int) D.11338;
  D.11340 = __builtin_expect (D.11339, 0);
  if (D.11340 != 0) goto <D.11341>; else goto <D.11342>;
  <D.11341>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 271, "_wapi_shared_layout != NULL");
  <D.11342>:
  D.11343 = _wapi_shm_enabled ();
  if (D.11343 != 0) goto <D.11344>; else goto <D.11345>;
  <D.11344>:
  _wapi_fileshare_layout.10 = _wapi_shm_attach (1);
  _wapi_fileshare_layout = _wapi_fileshare_layout.10;
  _wapi_fileshare_layout.11 = _wapi_fileshare_layout;
  D.11348 = _wapi_fileshare_layout.11 == 0B;
  D.11349 = (long int) D.11348;
  D.11350 = __builtin_expect (D.11349, 0);
  if (D.11350 != 0) goto <D.11351>; else goto <D.11352>;
  <D.11351>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 276, "_wapi_fileshare_layout != NULL");
  <D.11352>:
  <D.11345>:
  D.11353 = _wapi_shm_enabled ();
  if (D.11353 != 0) goto <D.11354>; else goto <D.11355>;
  <D.11354>:
  _wapi_collection_init ();
  <D.11355>:
  _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.11359 = _wapi_global_signal_handle.14 / 256;
  D.11360 = _wapi_private_handles[D.11359];
  _wapi_global_signal_handle.13 = _wapi_global_signal_handle;
  _wapi_global_signal_handle.14 = (unsigned int) _wapi_global_signal_handle.13;
  D.11361 = _wapi_global_signal_handle.14 & 255;
  D.11362 = D.11361 * 144;
  D.11363 = D.11360 + D.11362;
  _wapi_global_signal_cond.15 = &D.11363->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.11359 = _wapi_global_signal_handle.14 / 256;
  D.11360 = _wapi_private_handles[D.11359];
  _wapi_global_signal_handle.13 = _wapi_global_signal_handle;
  _wapi_global_signal_handle.14 = (unsigned int) _wapi_global_signal_handle.13;
  D.11361 = _wapi_global_signal_handle.14 & 255;
  D.11362 = D.11361 * 144;
  D.11363 = D.11360 + D.11362;
  _wapi_global_signal_mutex.16 = &D.11363->signal_mutex;
  _wapi_global_signal_mutex = _wapi_global_signal_mutex.16;
  atexit (handle_cleanup);
}


handle_cleanup ()
{
  struct _WapiHandleUnshared * D.11366;
  unsigned int j.17;
  unsigned int D.11368;
  <unnamed type> D.11369;
  int D.11370;
  int D.11371;
  unsigned int D.11381;
  struct GHashTable * file_share_hash.18;
  int i;
  int j;
  int k;

  i = 0;
  goto <D.10807>;
  <D.10806>:
  j = 0;
  goto <D.10804>;
  <D.10803>:
  {
    struct _WapiHandleUnshared * handle_data;
    int type;
    void * handle;

    D.11366 = _wapi_private_handles[i];
    j.17 = (unsigned int) j;
    D.11368 = j.17 * 144;
    handle_data = D.11366 + D.11368;
    D.11369 = handle_data->type;
    type = (int) D.11369;
    D.11370 = i * 256;
    D.11371 = D.11370 + j;
    handle = (void *) D.11371;
    if (type == 9) goto <D.11372>; else goto <D.11374>;
    <D.11374>:
    if (type == 11) goto <D.11372>; else goto <D.11375>;
    <D.11375>:
    if (type == 12) goto <D.11372>; else goto <D.11376>;
    <D.11376>:
    if (type == 13) goto <D.11372>; else goto <D.11373>;
    <D.11372>:
    if (type == 3) goto <D.11377>; else goto <D.11378>;
    <D.11377>:
    if (1 != 0) goto <D.11379>; else goto <D.11380>;
    <D.11379>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 211, "0");
    <D.11380>:
    _wapi_thread_set_termination_details (handle, 0);
    <D.11378>:
    <D.11373>:
    D.11381 = handle_data->ref;
    k = (int) D.11381;
    goto <D.10801>;
    <D.10800>:
    _wapi_handle_unref_full (handle, 1);
    k = k + -1;
    <D.10801>:
    if (k > 0) goto <D.10800>; else goto <D.10802>;
    <D.10802>:
  }
  j = j + 1;
  <D.10804>:
  if (j <= 255) goto <D.10803>; else goto <D.10805>;
  <D.10805>:
  i = i + 1;
  <D.10807>:
  D.11366 = _wapi_private_handles[i];
  if (D.11366 != 0B) goto <D.10806>; else goto <D.10808>;
  <D.10808>:
  _wapi_shm_semaphores_remove ();
  _wapi_shm_detach (0);
  _wapi_shm_detach (1);
  file_share_hash.18 = file_share_hash;
  if (file_share_hash.18 != 0B) goto <D.11383>; else goto <D.11384>;
  <D.11383>:
  file_share_hash.18 = file_share_hash;
  monoeg_g_hash_table_destroy (file_share_hash.18);
  DeleteCriticalSection (&file_share_hash_mutex);
  <D.11384>:
  i = 0;
  goto <D.10810>;
  <D.10809>:
  D.11366 = _wapi_private_handles[i];
  monoeg_g_free (D.11366);
  i = i + 1;
  <D.10810>:
  if (i <= 16383) goto <D.10809>; else goto <D.10811>;
  <D.10811>:
}


_wapi_handle_unref_full (void * handle, gboolean ignore_private_busy_handles)
{
  <unnamed type> D.11387;
  unsigned int D.11390;
  struct _WapiHandleUnshared * D.11391;
  unsigned int D.11392;
  unsigned int D.11393;
  struct _WapiHandleUnshared * D.11394;
  guint * D.11395;
  int D.11396;
  _Bool D.11397;
  int iftmp.19;
  _Bool D.11409;
  long int D.11410;
  long int D.11411;
  long int D.11414;
  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.11417;
  union mono_mutex_t * D.11420;
  union pthread_cond_t * D.11427;
  struct _WapiHandleSharedLayout * _wapi_shared_layout.20;
  unsigned int D.11436;
  unsigned int D.11437;
  unsigned int D.11440;
  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.11385>; else goto <D.11386>;
  <D.11385>:
  return;
  <D.11386>:
  D.11387 = _wapi_handle_type (handle);
  if (D.11387 == 0) goto <D.11388>; else goto <D.11389>;
  <D.11388>:
  monoeg_g_log (0B, 16, "%s: Attempting to unref unused handle %p", &__func__, handle);
  return;
  <D.11389>:
  D.11390 = idx / 256;
  D.11391 = _wapi_private_handles[D.11390];
  D.11392 = idx & 255;
  D.11393 = D.11392 * 144;
  D.11394 = D.11391 + D.11393;
  D.11395 = &D.11394->ref;
  D.11396 = InterlockedDecrement (D.11395);
  D.11397 = D.11396 == 0;
  destroy = (gboolean) D.11397;
  if (destroy == 1) goto <D.11398>; else goto <D.11399>;
  <D.11398>:
  {
    struct _WapiHandleUnshared handle_data;
    struct _WapiHandleShared shared_handle_data;
    WapiHandleType type;
    void (*<Tbc3>) (void *, void *) close_func;
    gboolean is_shared;

    try
      {
        D.11390 = idx / 256;
        D.11391 = _wapi_private_handles[D.11390];
        D.11392 = idx & 255;
        D.11393 = D.11392 * 144;
        D.11394 = D.11391 + D.11393;
        type = D.11394->type;
        close_func = _wapi_handle_ops_get_close_func (type);
        if (type == 9) goto <D.11401>; else goto <D.11404>;
        <D.11404>:
        if (type == 11) goto <D.11401>; else goto <D.11405>;
        <D.11405>:
        if (type == 12) goto <D.11401>; else goto <D.11406>;
        <D.11406>:
        if (type == 13) goto <D.11401>; else goto <D.11402>;
        <D.11401>:
        iftmp.19 = 1;
        goto <D.11403>;
        <D.11402>:
        iftmp.19 = 0;
        <D.11403>:
        is_shared = iftmp.19;
        if (is_shared != 0) goto <D.11407>; else goto <D.11408>;
        <D.11407>:
        thr_ret = _wapi_handle_lock_shared_handles ();
        D.11409 = thr_ret != 0;
        D.11410 = (long int) D.11409;
        D.11411 = __builtin_expect (D.11410, 0);
        if (D.11411 != 0) goto <D.11412>; else goto <D.11413>;
        <D.11412>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 1080, "thr_ret == 0");
        <D.11413>:
        <D.11408>:
        {
          struct __pthread_unwind_buf_t __cancel_buf;
          void (*<Tc3>) (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.11414 = __builtin_expect (__not_first_call, 0);
              if (D.11414 != 0) goto <D.11415>; else goto <D.11416>;
              <D.11415>:
              __cancel_routine (__cancel_arg);
              __pthread_unwind_next (&__cancel_buf);
              <D.11416>:
              __pthread_register_cancel (&__cancel_buf);
              thr_ret = pthread_mutex_lock (&scan_mutex);
              D.11390 = idx / 256;
              D.11391 = _wapi_private_handles[D.11390];
              D.11392 = idx & 255;
              D.11393 = D.11392 * 144;
              D.11394 = D.11391 + D.11393;
              memcpy (&handle_data, D.11394, 144);
              D.11390 = idx / 256;
              D.11391 = _wapi_private_handles[D.11390];
              D.11392 = idx & 255;
              D.11393 = D.11392 * 144;
              D.11394 = D.11391 + D.11393;
              D.11417 = &D.11394->u;
              memset (D.11417, 0, 52);
              D.11390 = idx / 256;
              D.11391 = _wapi_private_handles[D.11390];
              D.11392 = idx & 255;
              D.11393 = D.11392 * 144;
              D.11394 = D.11391 + D.11393;
              D.11394->type = 0;
              if (is_shared == 0) goto <D.11418>; else goto <D.11419>;
              <D.11418>:
              D.11390 = idx / 256;
              D.11391 = _wapi_private_handles[D.11390];
              D.11392 = idx & 255;
              D.11393 = D.11392 * 144;
              D.11394 = D.11391 + D.11393;
              D.11420 = &D.11394->signal_mutex;
              thr_ret = pthread_mutex_destroy (D.11420);
              if (thr_ret == 16) goto <D.11423>; else goto <D.11421>;
              <D.11423>:
              if (ignore_private_busy_handles != 0) goto <D.11424>; else goto <D.11421>;
              <D.11424>:
              early_exit = 1;
              goto <D.11422>;
              <D.11421>:
              if (thr_ret != 0) goto <D.11425>; else goto <D.11426>;
              <D.11425>:
              monoeg_g_log (0B, 4, "Error destroying handle %p mutex due to %d\n", handle, thr_ret);
              <D.11053>:
              goto <D.11053>;
              <D.11426>:
              D.11390 = idx / 256;
              D.11391 = _wapi_private_handles[D.11390];
              D.11392 = idx & 255;
              D.11393 = D.11392 * 144;
              D.11394 = D.11391 + D.11393;
              D.11427 = &D.11394->signal_cond;
              thr_ret = pthread_cond_destroy (D.11427);
              if (thr_ret == 16) goto <D.11430>; else goto <D.11428>;
              <D.11430>:
              if (ignore_private_busy_handles != 0) goto <D.11431>; else goto <D.11428>;
              <D.11431>:
              early_exit = 1;
              goto <D.11429>;
              <D.11428>:
              if (thr_ret != 0) goto <D.11432>; else goto <D.11433>;
              <D.11432>:
              monoeg_g_log (0B, 4, "Error destroying handle %p cond var due to %d\n", handle, thr_ret);
              <D.11054>:
              goto <D.11054>;
              <D.11433>:
              <D.11429>:
              <D.11422>:
              goto <D.11434>;
              <D.11419>:
              {
                struct _WapiHandleShared * shared;

                _wapi_shared_layout.20 = _wapi_shared_layout;
                D.11436 = handle_data.u.shared.offset;
                shared = &_wapi_shared_layout.20->handles[D.11436];
                memcpy (&shared_handle_data, shared, 320);
                D.11437 = shared->handle_refs;
                if (D.11437 != 0) goto <D.11438>; else goto <D.11439>;
                <D.11438>:
                D.11437 = shared->handle_refs;
                D.11440 = D.11437 + 4294967295;
                shared->handle_refs = D.11440;
                D.11437 = shared->handle_refs;
                if (D.11437 == 0) goto <D.11441>; else goto <D.11442>;
                <D.11441>:
                memset (shared, 0, 320);
                <D.11442>:
                <D.11439>:
              }
              <D.11434>:
              thr_ret = pthread_mutex_unlock (&scan_mutex);
              D.11409 = thr_ret != 0;
              D.11410 = (long int) D.11409;
              D.11411 = __builtin_expect (D.11410, 0);
              if (D.11411 != 0) goto <D.11443>; else goto <D.11444>;
              <D.11443>:
              monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 1138, "thr_ret == 0");
              <D.11444>:
              __pthread_unregister_cancel (&__cancel_buf);
              if (0 != 0) goto <D.11445>; else goto <D.11446>;
              <D.11445>:
              __cancel_routine (__cancel_arg);
              <D.11446>:
            }
          finally
            {
              __cancel_buf = {CLOBBER};
            }
        }
        if (early_exit != 0) goto <D.11447>; else goto <D.11448>;
        <D.11447>:
        return;
        <D.11448>:
        if (is_shared != 0) goto <D.11449>; else goto <D.11450>;
        <D.11449>:
        _wapi_handle_unlock_shared_handles ();
        <D.11450>:
        if (close_func != 0B) goto <D.11451>; else goto <D.11452>;
        <D.11451>:
        if (is_shared != 0) goto <D.11453>; else goto <D.11454>;
        <D.11453>:
        close_func (handle, &shared_handle_data.u);
        goto <D.11455>;
        <D.11454>:
        close_func (handle, &handle_data.u);
        <D.11455>:
        <D.11452>:
      }
    finally
      {
        handle_data = {CLOBBER};
        shared_handle_data = {CLOBBER};
      }
  }
  <D.11399>:
}


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

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


_wapi_handle_type (void * handle)
{
  unsigned int D.11471;
  struct _WapiHandleUnshared * D.11472;
  WapiHandleType D.11473;
  unsigned int D.11474;
  unsigned int D.11475;
  struct _WapiHandleUnshared * D.11476;
  guint32 idx;

  idx = (guint32) handle;
  if (idx > 4194303) goto <D.11467>; else goto <D.11469>;
  <D.11469>:
  if (idx > 268435455) goto <D.11467>; else goto <D.11470>;
  <D.11470>:
  D.11471 = idx / 256;
  D.11472 = _wapi_private_handles[D.11471];
  if (D.11472 == 0B) goto <D.11467>; else goto <D.11468>;
  <D.11467>:
  D.11473 = 0;
  return D.11473;
  <D.11468>:
  D.11471 = idx / 256;
  D.11472 = _wapi_private_handles[D.11471];
  D.11474 = idx & 255;
  D.11475 = D.11474 * 144;
  D.11476 = D.11472 + D.11475;
  D.11473 = D.11476->type;
  return D.11473;
}


InterlockedDecrement (volatile gint32 * val)
{
  gint32 D.11478;
  unsigned int D.11479;

  D.11479 = __sync_sub_and_fetch_4 (val, 1);
  D.11478 = (gint32) D.11479;
  return D.11478;
}


_wapi_handle_ops_get_close_func (WapiHandleType type)
{
  struct _WapiHandleOps * D.11481;
  void (*<Tbc3>) (void *, void *) D.11484;
  void (*<Tbc3>) (void *, void *) D.11487;

  D.11481 = handle_ops[type];
  if (D.11481 != 0B) goto <D.11482>; else goto <D.11483>;
  <D.11482>:
  D.11481 = handle_ops[type];
  D.11484 = D.11481->close;
  if (D.11484 != 0B) goto <D.11485>; else goto <D.11486>;
  <D.11485>:
  D.11481 = handle_ops[type];
  D.11487 = D.11481->close;
  return D.11487;
  <D.11486>:
  <D.11483>:
  D.11487 = 0B;
  return D.11487;
}


_wapi_handle_lock_shared_handles ()
{
  int D.11489;

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


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

  D.11492 = __builtin_object_size (__dest, 0);
  D.11491 = __builtin___memcpy_chk (__dest, __src, __len, D.11492);
  return D.11491;
}


memset (void * __dest, int __ch, size_t __len)
{
  int D.11496;
  int D.11501;
  void * D.11503;
  unsigned int D.11504;

  D.11496 = __builtin_constant_p (__len);
  if (D.11496 != 0) goto <D.11497>; else goto <D.11498>;
  <D.11497>:
  if (__len == 0) goto <D.11499>; else goto <D.11500>;
  <D.11499>:
  D.11501 = __builtin_constant_p (__ch);
  if (D.11501 == 0) goto <D.11494>; else goto <D.11502>;
  <D.11502>:
  if (__ch != 0) goto <D.11494>; else goto <D.11495>;
  <D.11494>:
  __warn_memset_zero_len ();
  D.11503 = __dest;
  return D.11503;
  <D.11495>:
  <D.11500>:
  <D.11498>:
  D.11504 = __builtin_object_size (__dest, 0);
  D.11503 = __builtin___memset_chk (__dest, __ch, __len, D.11504);
  return D.11503;
}


_wapi_handle_unlock_shared_handles ()
{
  int D.11506;

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


wapi_cleanup ()
{
  int _wapi_has_shut_down.21;
  _Bool D.11509;
  long int D.11510;
  long int D.11511;

  _wapi_has_shut_down.21 = _wapi_has_shut_down;
  D.11509 = _wapi_has_shut_down.21 != 0;
  D.11510 = (long int) D.11509;
  D.11511 = __builtin_expect (D.11510, 0);
  if (D.11511 != 0) goto <D.11512>; else goto <D.11513>;
  <D.11512>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 303, "_wapi_has_shut_down == FALSE");
  <D.11513>:
  _wapi_has_shut_down = 1;
  _wapi_error_cleanup ();
  _wapi_thread_cleanup ();
}


_wapi_handle_new (WapiHandleType type, void * handle_specific)
{
  int _wapi_has_shut_down.22;
  _Bool D.11515;
  long int D.11516;
  long int D.11517;
  int iftmp.23;
  unsigned int D.11524;
  _Bool D.11527;
  long int D.11528;
  long int D.11529;
  long int D.11532;
  _Bool D.11535;
  long int D.11536;
  long int D.11537;
  unsigned int _wapi_private_handle_count.24;
  unsigned int D.11541;
  void * D.11543;
  unsigned int _wapi_private_handle_count.25;
  unsigned int _wapi_private_handle_slot_count.26;
  unsigned int _wapi_private_handle_slot_count.27;
  unsigned int _wapi_fd_reserve.28;
  _Bool D.11554;
  long int D.11555;
  long int D.11556;
  unsigned int D.11568;
  struct _WapiHandleUnshared * D.11569;
  unsigned int D.11570;
  unsigned int D.11571;
  struct _WapiHandleUnshared * D.11572;
  void * D.11573;
  guint32 handle_idx;
  void * handle;
  int thr_ret;
  void done = <<< error >>>;

  handle_idx = 0;
  _wapi_has_shut_down.22 = _wapi_has_shut_down;
  D.11515 = _wapi_has_shut_down.22 != 0;
  D.11516 = (long int) D.11515;
  D.11517 = __builtin_expect (D.11516, 0);
  if (D.11517 != 0) goto <D.11518>; else goto <D.11519>;
  <D.11518>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 466, "_wapi_has_shut_down == FALSE");
  <D.11519>:
  D.11524 = type + 4294967295;
  if (D.11524 <= 1) goto <D.11521>; else goto <D.11525>;
  <D.11525>:
  if (type == 7) goto <D.11521>; else goto <D.11526>;
  <D.11526>:
  if (type == 10) goto <D.11521>; else goto <D.11522>;
  <D.11521>:
  iftmp.23 = 1;
  goto <D.11523>;
  <D.11522>:
  iftmp.23 = 0;
  <D.11523>:
  D.11527 = iftmp.23 != 0;
  D.11528 = (long int) D.11527;
  D.11529 = __builtin_expect (D.11528, 0);
  if (D.11529 != 0) goto <D.11530>; else goto <D.11531>;
  <D.11530>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 471, "!_WAPI_FD_HANDLE(type)");
  <D.11531>:
  {
    struct __pthread_unwind_buf_t __cancel_buf;
    void (*<Tc3>) (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.11532 = __builtin_expect (__not_first_call, 0);
        if (D.11532 != 0) goto <D.11533>; else goto <D.11534>;
        <D.11533>:
        __cancel_routine (__cancel_arg);
        __pthread_unwind_next (&__cancel_buf);
        <D.11534>:
        __pthread_register_cancel (&__cancel_buf);
        thr_ret = pthread_mutex_lock (&scan_mutex);
        D.11535 = thr_ret != 0;
        D.11536 = (long int) D.11535;
        D.11537 = __builtin_expect (D.11536, 0);
        if (D.11537 != 0) goto <D.11538>; else goto <D.11539>;
        <D.11538>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 476, "thr_ret == 0");
        <D.11539>:
        goto <D.10876>;
        <D.10875>:
        {
          int idx;

          _wapi_private_handle_count.24 = _wapi_private_handle_count;
          D.11541 = _wapi_private_handle_count.24 / 256;
          idx = (int) D.11541;
          if (idx > 16383) goto <D.10874>; else goto <D.11542>;
          <D.11542>:
          D.11543 = monoeg_malloc0 (36864);
          _wapi_private_handles[idx] = D.11543;
          _wapi_private_handle_count.24 = _wapi_private_handle_count;
          _wapi_private_handle_count.25 = _wapi_private_handle_count.24 + 256;
          _wapi_private_handle_count = _wapi_private_handle_count.25;
          _wapi_private_handle_slot_count.26 = _wapi_private_handle_slot_count;
          _wapi_private_handle_slot_count.27 = _wapi_private_handle_slot_count.26 + 1;
          _wapi_private_handle_slot_count = _wapi_private_handle_slot_count.27;
        }
        <D.10876>:
        handle_idx = _wapi_handle_new_internal (type, handle_specific);
        if (handle_idx == 0) goto <D.10875>; else goto <D.10874>;
        <D.10874>:
        thr_ret = pthread_mutex_unlock (&scan_mutex);
        D.11535 = thr_ret != 0;
        D.11536 = (long int) D.11535;
        D.11537 = __builtin_expect (D.11536, 0);
        if (D.11537 != 0) goto <D.11547>; else goto <D.11548>;
        <D.11547>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 493, "thr_ret == 0");
        <D.11548>:
        __pthread_unregister_cancel (&__cancel_buf);
        if (0 != 0) goto <D.11549>; else goto <D.11550>;
        <D.11549>:
        __cancel_routine (__cancel_arg);
        <D.11550>:
      }
    finally
      {
        __cancel_buf = {CLOBBER};
      }
  }
  if (handle_idx == 0) goto <D.11551>; else goto <D.11552>;
  <D.11551>:
  handle = 4294967295B;
  goto done;
  <D.11552>:
  _wapi_fd_reserve.28 = _wapi_fd_reserve;
  D.11554 = handle_idx < _wapi_fd_reserve.28;
  D.11555 = (long int) D.11554;
  D.11556 = __builtin_expect (D.11555, 0);
  if (D.11556 != 0) goto <D.11557>; else goto <D.11558>;
  <D.11557>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 503, "handle_idx >= _wapi_fd_reserve");
  <D.11558>:
  handle = (void *) handle_idx;
  if (type == 9) goto <D.11559>; else goto <D.11561>;
  <D.11561>:
  if (type == 11) goto <D.11559>; else goto <D.11562>;
  <D.11562>:
  if (type == 12) goto <D.11559>; else goto <D.11563>;
  <D.11563>:
  if (type == 13) goto <D.11559>; else goto <D.11560>;
  <D.11559>:
  {
    guint32 ref;

    ref = _wapi_handle_new_shared (type, handle_specific);
    if (ref == 0) goto <D.11564>; else goto <D.11565>;
    <D.11564>:
    _wapi_handle_collect ();
    ref = _wapi_handle_new_shared (type, handle_specific);
    if (ref == 0) goto <D.11566>; else goto <D.11567>;
    <D.11566>:
    handle = 4294967295B;
    goto done;
    <D.11567>:
    <D.11565>:
    D.11568 = handle_idx / 256;
    D.11569 = _wapi_private_handles[D.11568];
    D.11570 = handle_idx & 255;
    D.11571 = D.11570 * 144;
    D.11572 = D.11569 + D.11571;
    D.11572->u.shared.offset = ref;
  }
  <D.11560>:
  done:
  D.11573 = handle;
  return D.11573;
}


_wapi_handle_new_internal (WapiHandleType type, void * handle_specific)
{
  int _wapi_has_shut_down.29;
  _Bool D.11582;
  long int D.11583;
  long int D.11584;
  unsigned int last.30;
  unsigned int _wapi_fd_reserve.31;
  struct _WapiHandleUnshared * D.11592;
  unsigned int D.11595;
  <unnamed type> D.11596;
  unsigned int last.32;
  guint32 D.11600;
  unsigned int _wapi_private_handle_slot_count.33;
  guint32 i;
  guint32 k;
  guint32 count;
  static guint32 last = 0;
  gboolean retry;
  void again = <<< error >>>;

  retry = 0;
  _wapi_has_shut_down.29 = _wapi_has_shut_down;
  D.11582 = _wapi_has_shut_down.29 != 0;
  D.11583 = (long int) D.11582;
  D.11584 = __builtin_expect (D.11583, 0);
  if (D.11584 != 0) goto <D.11585>; else goto <D.11586>;
  <D.11585>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 416, "_wapi_has_shut_down == FALSE");
  <D.11586>:
  last.30 = last;
  _wapi_fd_reserve.31 = _wapi_fd_reserve;
  if (last.30 < _wapi_fd_reserve.31) goto <D.11589>; else goto <D.11590>;
  <D.11589>:
  _wapi_fd_reserve.31 = _wapi_fd_reserve;
  last = _wapi_fd_reserve.31;
  goto <D.11591>;
  <D.11590>:
  retry = 1;
  <D.11591>:
  again:
  count = last;
  i = count / 256;
  goto <D.10858>;
  <D.10857>:
  D.11592 = _wapi_private_handles[i];
  if (D.11592 != 0B) goto <D.11593>; else goto <D.11594>;
  <D.11593>:
  k = count & 255;
  goto <D.10855>;
  <D.10854>:
  {
    struct _WapiHandleUnshared * handle;

    D.11592 = _wapi_private_handles[i];
    D.11595 = k * 144;
    handle = D.11592 + D.11595;
    D.11596 = handle->type;
    if (D.11596 == 0) goto <D.11597>; else goto <D.11598>;
    <D.11597>:
    last.32 = count + 1;
    last = last.32;
    _wapi_handle_init (handle, type, handle_specific);
    D.11600 = count;
    return D.11600;
    <D.11598>:
    count = count + 1;
  }
  k = k + 1;
  <D.10855>:
  if (k <= 255) goto <D.10854>; else goto <D.10856>;
  <D.10856>:
  <D.11594>:
  i = i + 1;
  <D.10858>:
  _wapi_private_handle_slot_count.33 = _wapi_private_handle_slot_count;
  if (i < _wapi_private_handle_slot_count.33) goto <D.10857>; else goto <D.10859>;
  <D.10859>:
  if (retry != 0) goto <D.11602>; else goto <D.11603>;
  <D.11602>:
  last.30 = last;
  _wapi_fd_reserve.31 = _wapi_fd_reserve;
  if (last.30 > _wapi_fd_reserve.31) goto <D.11604>; else goto <D.11605>;
  <D.11604>:
  _wapi_fd_reserve.31 = _wapi_fd_reserve;
  last = _wapi_fd_reserve.31;
  goto again;
  <D.11605>:
  <D.11603>:
  D.11600 = 0;
  return D.11600;
}


_wapi_handle_init (struct _WapiHandleUnshared * handle, WapiHandleType type, void * handle_specific)
{
  int _wapi_has_shut_down.34;
  _Bool D.11608;
  long int D.11609;
  long int D.11610;
  union pthread_cond_t * D.11621;
  _Bool D.11622;
  long int D.11623;
  long int D.11624;
  union mono_mutex_t * D.11627;
  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.11632;
  int thr_ret;

  _wapi_has_shut_down.34 = _wapi_has_shut_down;
  D.11608 = _wapi_has_shut_down.34 != 0;
  D.11609 = (long int) D.11608;
  D.11610 = __builtin_expect (D.11609, 0);
  if (D.11610 != 0) goto <D.11611>; else goto <D.11612>;
  <D.11611>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 332, "_wapi_has_shut_down == FALSE");
  <D.11612>:
  handle->type = type;
  handle->signalled = 0;
  handle->ref = 1;
  if (type != 9) goto <D.11613>; else goto <D.11614>;
  <D.11613>:
  if (type != 11) goto <D.11615>; else goto <D.11616>;
  <D.11615>:
  if (type != 12) goto <D.11617>; else goto <D.11618>;
  <D.11617>:
  if (type != 13) goto <D.11619>; else goto <D.11620>;
  <D.11619>:
  D.11621 = &handle->signal_cond;
  thr_ret = pthread_cond_init (D.11621, 0B);
  D.11622 = thr_ret != 0;
  D.11623 = (long int) D.11622;
  D.11624 = __builtin_expect (D.11623, 0);
  if (D.11624 != 0) goto <D.11625>; else goto <D.11626>;
  <D.11625>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 340, "thr_ret == 0");
  <D.11626>:
  D.11627 = &handle->signal_mutex;
  thr_ret = pthread_mutex_init (D.11627, 0B);
  D.11622 = thr_ret != 0;
  D.11623 = (long int) D.11622;
  D.11624 = __builtin_expect (D.11623, 0);
  if (D.11624 != 0) goto <D.11628>; else goto <D.11629>;
  <D.11628>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 343, "thr_ret == 0");
  <D.11629>:
  if (handle_specific != 0B) goto <D.11630>; else goto <D.11631>;
  <D.11630>:
  D.11632 = &handle->u;
  memcpy (D.11632, handle_specific, 52);
  <D.11631>:
  <D.11620>:
  <D.11618>:
  <D.11616>:
  <D.11614>:
}


_wapi_handle_new_shared (WapiHandleType type, void * handle_specific)
{
  int _wapi_has_shut_down.35;
  _Bool D.11634;
  long int D.11635;
  long int D.11636;
  struct _WapiHandleSharedLayout * _wapi_shared_layout.36;
  <unnamed type> D.11640;
  _Bool D.11643;
  long int D.11644;
  long int D.11645;
  WapiHandleType * D.11648;
  int type.37;
  int D.11650;
  unsigned int last.38;
  guint32 D.11654;
  unsigned int last.39;
  guint32 offset;
  static guint32 last = 1;
  int thr_ret;
  void again = <<< error >>>;

  _wapi_has_shut_down.35 = _wapi_has_shut_down;
  D.11634 = _wapi_has_shut_down.35 != 0;
  D.11635 = (long int) D.11634;
  D.11636 = __builtin_expect (D.11635, 0);
  if (D.11636 != 0) goto <D.11637>; else goto <D.11638>;
  <D.11637>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 359, "_wapi_has_shut_down == FALSE");
  <D.11638>:
  again:
  offset = last;
  goto <D.10841>;
  <D.10840>:
  {
    struct _WapiHandleShared * handle;

    _wapi_shared_layout.36 = _wapi_shared_layout;
    handle = &_wapi_shared_layout.36->handles[offset];
    D.11640 = handle->type;
    if (D.11640 == 0) goto <D.11641>; else goto <D.11642>;
    <D.11641>:
    thr_ret = _wapi_handle_lock_shared_handles ();
    D.11643 = thr_ret != 0;
    D.11644 = (long int) D.11643;
    D.11645 = __builtin_expect (D.11644, 0);
    if (D.11645 != 0) goto <D.11646>; else goto <D.11647>;
    <D.11646>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 369, "thr_ret == 0");
    <D.11647>:
    D.11648 = &handle->type;
    type.37 = (int) type;
    D.11650 = InterlockedCompareExchange (D.11648, type.37, 0);
    if (D.11650 == 0) goto <D.11651>; else goto <D.11652>;
    <D.11651>:
    last.38 = offset + 1;
    last = last.38;
    _wapi_handle_init_shared (handle, type, handle_specific);
    _wapi_handle_unlock_shared_handles ();
    D.11654 = offset;
    return D.11654;
    <D.11652>:
    _wapi_handle_unlock_shared_handles ();
    <D.11642>:
  }
  offset = offset + 1;
  <D.10841>:
  if (offset <= 255) goto <D.10840>; else goto <D.10842>;
  <D.10842>:
  last.39 = last;
  if (last.39 > 1) goto <D.11656>; else goto <D.11657>;
  <D.11656>:
  last = 1;
  goto again;
  <D.11657>:
  D.11654 = 0;
  return D.11654;
}


InterlockedCompareExchange (volatile gint32 * dest, gint32 exch, gint32 comp)
{
  gint32 D.11659;
  unsigned int comp.40;
  unsigned int exch.41;
  unsigned int D.11662;

  comp.40 = (unsigned int) comp;
  exch.41 = (unsigned int) exch;
  D.11662 = __sync_val_compare_and_swap_4 (dest, comp.40, exch.41);
  D.11659 = (gint32) D.11662;
  return D.11659;
}


_wapi_handle_init_shared (struct _WapiHandleShared * handle, WapiHandleType type, void * handle_specific)
{
  int _wapi_has_shut_down.42;
  _Bool D.11665;
  long int D.11666;
  long int D.11667;
  long int D.11670;
  unsigned int D.11671;
  union 
{
  struct _WapiHandle_process process;
  struct _WapiHandle_namedmutex namedmutex;
  struct _WapiHandle_namedsem namedsem;
  struct _WapiHandle_namedevent namedevent;
} * D.11674;

  _wapi_has_shut_down.42 = _wapi_has_shut_down;
  D.11665 = _wapi_has_shut_down.42 != 0;
  D.11666 = (long int) D.11665;
  D.11667 = __builtin_expect (D.11666, 0);
  if (D.11667 != 0) goto <D.11668>; else goto <D.11669>;
  <D.11668>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 315, "_wapi_has_shut_down == FALSE");
  <D.11669>:
  handle->type = type;
  D.11670 = time (0B);
  D.11671 = (unsigned int) D.11670;
  handle->timestamp = D.11671;
  handle->signalled = 0;
  handle->handle_refs = 1;
  if (handle_specific != 0B) goto <D.11672>; else goto <D.11673>;
  <D.11672>:
  D.11674 = &handle->u;
  memcpy (D.11674, handle_specific, 304);
  <D.11673>:
}


_wapi_handle_new_from_offset (WapiHandleType type, guint32 offset, gboolean timestamp)
{
  int _wapi_has_shut_down.43;
  _Bool D.11676;
  long int D.11677;
  long int D.11678;
  int iftmp.44;
  unsigned int D.11685;
  _Bool D.11688;
  long int D.11689;
  long int D.11690;
  int iftmp.45;
  _Bool D.11700;
  long int D.11701;
  long int D.11702;
  _Bool D.11705;
  long int D.11706;
  long int D.11707;
  struct _WapiHandleSharedLayout * _wapi_shared_layout.46;
  long int D.11713;
  guint32 * D.11714;
  int now.47;
  long int D.11716;
  _Bool D.11719;
  long int D.11720;
  long int D.11721;
  struct _WapiHandleUnshared * D.11724;
  unsigned int k.48;
  unsigned int D.11728;
  <unnamed type> D.11729;
  unsigned int D.11732;
  int D.11735;
  int D.11736;
  unsigned int i.49;
  unsigned int _wapi_private_handle_slot_count.50;
  void * D.11745;
  <unnamed type> D.11748;
  long int D.11751;
  unsigned int _wapi_private_handle_count.51;
  unsigned int D.11757;
  void * D.11758;
  unsigned int _wapi_private_handle_count.52;
  unsigned int _wapi_private_handle_slot_count.53;
  unsigned int _wapi_fd_reserve.54;
  _Bool D.11766;
  long int D.11767;
  long int D.11768;
  unsigned int D.11771;
  struct _WapiHandleUnshared * D.11772;
  unsigned int D.11773;
  unsigned int D.11774;
  struct _WapiHandleUnshared * D.11775;
  guint32 * D.11776;
  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.43 = _wapi_has_shut_down;
  D.11676 = _wapi_has_shut_down.43 != 0;
  D.11677 = (long int) D.11676;
  D.11678 = __builtin_expect (D.11677, 0);
  if (D.11678 != 0) goto <D.11679>; else goto <D.11680>;
  <D.11679>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 541, "_wapi_has_shut_down == FALSE");
  <D.11680>:
  D.11685 = type + 4294967295;
  if (D.11685 <= 1) goto <D.11682>; else goto <D.11686>;
  <D.11686>:
  if (type == 7) goto <D.11682>; else goto <D.11687>;
  <D.11687>:
  if (type == 10) goto <D.11682>; else goto <D.11683>;
  <D.11682>:
  iftmp.44 = 1;
  goto <D.11684>;
  <D.11683>:
  iftmp.44 = 0;
  <D.11684>:
  D.11688 = iftmp.44 != 0;
  D.11689 = (long int) D.11688;
  D.11690 = __builtin_expect (D.11689, 0);
  if (D.11690 != 0) goto <D.11691>; else goto <D.11692>;
  <D.11691>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 546, "!_WAPI_FD_HANDLE(type)");
  <D.11692>:
  if (type != 9) goto <D.11696>; else goto <D.11694>;
  <D.11696>:
  if (type != 11) goto <D.11697>; else goto <D.11694>;
  <D.11697>:
  if (type != 12) goto <D.11698>; else goto <D.11694>;
  <D.11698>:
  if (type != 13) goto <D.11699>; else goto <D.11694>;
  <D.11699>:
  iftmp.45 = 1;
  goto <D.11695>;
  <D.11694>:
  iftmp.45 = 0;
  <D.11695>:
  D.11700 = iftmp.45 != 0;
  D.11701 = (long int) D.11700;
  D.11702 = __builtin_expect (D.11701, 0);
  if (D.11702 != 0) goto <D.11703>; else goto <D.11704>;
  <D.11703>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 547, "_WAPI_SHARED_HANDLE(type)");
  <D.11704>:
  D.11705 = offset == 0;
  D.11706 = (long int) D.11705;
  D.11707 = __builtin_expect (D.11706, 0);
  if (D.11707 != 0) goto <D.11708>; else goto <D.11709>;
  <D.11708>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 548, "offset != 0");
  <D.11709>:
  _wapi_shared_layout.46 = _wapi_shared_layout;
  shared = &_wapi_shared_layout.46->handles[offset];
  if (timestamp != 0) goto <D.11711>; else goto <D.11712>;
  <D.11711>:
  {
    guint32 now;

    D.11713 = time (0B);
    now = (guint32) D.11713;
    D.11714 = &shared->timestamp;
    now.47 = (int) now;
    InterlockedExchange (D.11714, now.47);
  }
  <D.11712>:
  {
    struct __pthread_unwind_buf_t __cancel_buf;
    void (*<Tc3>) (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.11716 = __builtin_expect (__not_first_call, 0);
        if (D.11716 != 0) goto <D.11717>; else goto <D.11718>;
        <D.11717>:
        __cancel_routine (__cancel_arg);
        __pthread_unwind_next (&__cancel_buf);
        <D.11718>:
        __pthread_register_cancel (&__cancel_buf);
        thr_ret = pthread_mutex_lock (&scan_mutex);
        D.11719 = thr_ret != 0;
        D.11720 = (long int) D.11719;
        D.11721 = __builtin_expect (D.11720, 0);
        if (D.11721 != 0) goto <D.11722>; else goto <D.11723>;
        <D.11722>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 560, "thr_ret == 0");
        <D.11723>:
        i = 0;
        goto <D.10903>;
        <D.10902>:
        D.11724 = _wapi_private_handles[i];
        if (D.11724 != 0B) goto <D.11725>; else goto <D.11726>;
        <D.11725>:
        k = 0;
        goto <D.10900>;
        <D.10899>:
        {
          struct _WapiHandleUnshared * handle_data;

          D.11724 = _wapi_private_handles[i];
          k.48 = (unsigned int) k;
          D.11728 = k.48 * 144;
          handle_data = D.11724 + D.11728;
          D.11729 = handle_data->type;
          if (D.11729 == type) goto <D.11730>; else goto <D.11731>;
          <D.11730>:
          D.11732 = handle_data->u.shared.offset;
          if (D.11732 == offset) goto <D.11733>; else goto <D.11734>;
          <D.11733>:
          D.11735 = i * 256;
          D.11736 = D.11735 + k;
          handle = (void *) D.11736;
          goto first_pass_done;
          <D.11734>:
          <D.11731>:
        }
        k = k + 1;
        <D.10900>:
        if (k <= 255) goto <D.10899>; else goto <D.10901>;
        <D.10901>:
        <D.11726>:
        i = i + 1;
        <D.10903>:
        i.49 = (unsigned int) i;
        _wapi_private_handle_slot_count.50 = _wapi_private_handle_slot_count;
        if (i.49 < _wapi_private_handle_slot_count.50) goto <D.10902>; else goto <D.10904>;
        <D.10904>:
        first_pass_done:
        thr_ret = pthread_mutex_unlock (&scan_mutex);
        D.11719 = thr_ret != 0;
        D.11720 = (long int) D.11719;
        D.11721 = __builtin_expect (D.11720, 0);
        if (D.11721 != 0) goto <D.11739>; else goto <D.11740>;
        <D.11739>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 578, "thr_ret == 0");
        <D.11740>:
        __pthread_unregister_cancel (&__cancel_buf);
        if (0 != 0) goto <D.11741>; else goto <D.11742>;
        <D.11741>:
        __cancel_routine (__cancel_arg);
        <D.11742>:
      }
    finally
      {
        __cancel_buf = {CLOBBER};
      }
  }
  if (handle != 4294967295B) goto <D.11743>; else goto <D.11744>;
  <D.11743>:
  _wapi_handle_ref (handle);
  D.11745 = handle;
  return D.11745;
  <D.11744>:
  thr_ret = _wapi_handle_lock_shared_handles ();
  D.11719 = thr_ret != 0;
  D.11720 = (long int) D.11719;
  D.11721 = __builtin_expect (D.11720, 0);
  if (D.11721 != 0) goto <D.11746>; else goto <D.11747>;
  <D.11746>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 591, "thr_ret == 0");
  <D.11747>:
  D.11748 = shared->type;
  if (D.11748 == 0) goto done; else goto <D.11749>;
  <D.11749>:
  D.11748 = shared->type;
  if (D.11748 != type) goto done; else goto <D.11750>;
  <D.11750>:
  {
    struct __pthread_unwind_buf_t __cancel_buf;
    void (*<Tc3>) (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.11751 = __builtin_expect (__not_first_call, 0);
        if (D.11751 != 0) goto <D.11752>; else goto <D.11753>;
        <D.11752>:
        __cancel_routine (__cancel_arg);
        __pthread_unwind_next (&__cancel_buf);
        <D.11753>:
        __pthread_register_cancel (&__cancel_buf);
        thr_ret = pthread_mutex_lock (&scan_mutex);
        D.11719 = thr_ret != 0;
        D.11720 = (long int) D.11719;
        D.11721 = __builtin_expect (D.11720, 0);
        if (D.11721 != 0) goto <D.11754>; else goto <D.11755>;
        <D.11754>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 610, "thr_ret == 0");
        <D.11755>:
        goto <D.10914>;
        <D.10913>:
        {
          int idx;

          _wapi_private_handle_count.51 = _wapi_private_handle_count;
          D.11757 = _wapi_private_handle_count.51 / 256;
          idx = (int) D.11757;
          D.11758 = monoeg_malloc0 (36864);
          _wapi_private_handles[idx] = D.11758;
          _wapi_private_handle_count.51 = _wapi_private_handle_count;
          _wapi_private_handle_count.52 = _wapi_private_handle_count.51 + 256;
          _wapi_private_handle_count = _wapi_private_handle_count.52;
          _wapi_private_handle_slot_count.50 = _wapi_private_handle_slot_count;
          _wapi_private_handle_slot_count.53 = _wapi_private_handle_slot_count.50 + 1;
          _wapi_private_handle_slot_count = _wapi_private_handle_slot_count.53;
        }
        <D.10914>:
        handle_idx = _wapi_handle_new_internal (type, 0B);
        if (handle_idx == 0) goto <D.10913>; else goto <D.10915>;
        <D.10915>:
        thr_ret = pthread_mutex_unlock (&scan_mutex);
        D.11719 = thr_ret != 0;
        D.11720 = (long int) D.11719;
        D.11721 = __builtin_expect (D.11720, 0);
        if (D.11721 != 0) goto <D.11761>; else goto <D.11762>;
        <D.11761>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 623, "thr_ret == 0");
        <D.11762>:
        __pthread_unregister_cancel (&__cancel_buf);
        if (0 != 0) goto <D.11763>; else goto <D.11764>;
        <D.11763>:
        __cancel_routine (__cancel_arg);
        <D.11764>:
      }
    finally
      {
        __cancel_buf = {CLOBBER};
      }
  }
  _wapi_fd_reserve.54 = _wapi_fd_reserve;
  D.11766 = handle_idx < _wapi_fd_reserve.54;
  D.11767 = (long int) D.11766;
  D.11768 = __builtin_expect (D.11767, 0);
  if (D.11768 != 0) goto <D.11769>; else goto <D.11770>;
  <D.11769>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 627, "handle_idx >= _wapi_fd_reserve");
  <D.11770>:
  handle = (void *) handle_idx;
  D.11771 = handle_idx / 256;
  D.11772 = _wapi_private_handles[D.11771];
  D.11773 = handle_idx & 255;
  D.11774 = D.11773 * 144;
  D.11775 = D.11772 + D.11774;
  D.11775->u.shared.offset = offset;
  D.11776 = &shared->handle_refs;
  InterlockedIncrement (D.11776);
  done:
  _wapi_handle_unlock_shared_handles ();
  D.11745 = handle;
  return D.11745;
}


InterlockedExchange (volatile gint32 * val, gint32 new_val)
{
  unsigned int old_val.55;
  unsigned int new_val.56;
  unsigned int D.11787;
  int D.11788;
  gint32 D.11789;
  gint32 old_val;

  <D.10477>:
  old_val = *val;
  old_val.55 = (unsigned int) old_val;
  new_val.56 = (unsigned int) new_val;
  D.11787 = __sync_val_compare_and_swap_4 (val, old_val.55, new_val.56);
  D.11788 = (int) D.11787;
  if (D.11788 != old_val) goto <D.10477>; else goto <D.10478>;
  <D.10478>:
  D.11789 = old_val;
  return D.11789;
}


InterlockedIncrement (volatile gint32 * val)
{
  gint32 D.11791;
  unsigned int D.11792;

  D.11792 = __sync_add_and_fetch_4 (val, 1);
  D.11791 = (gint32) D.11792;
  return D.11791;
}


_wapi_handle_new_fd (WapiHandleType type, int fd, void * handle_specific)
{
  int _wapi_has_shut_down.57;
  _Bool D.11795;
  long int D.11796;
  long int D.11797;
  int iftmp.58;
  unsigned int D.11803;
  _Bool D.11807;
  long int D.11808;
  long int D.11809;
  int iftmp.59;
  _Bool D.11819;
  long int D.11820;
  long int D.11821;
  unsigned int fd.60;
  unsigned int _wapi_fd_reserve.61;
  void * D.11828;
  int D.11829;
  struct _WapiHandleUnshared * D.11830;
  int D.11833;
  unsigned int D.11834;
  unsigned int D.11835;
  <unnamed type> D.11836;
  _Bool D.11839;
  long int D.11840;
  long int D.11841;
  struct _WapiHandleUnshared * handle;
  int thr_ret;

  _wapi_has_shut_down.57 = _wapi_has_shut_down;
  D.11795 = _wapi_has_shut_down.57 != 0;
  D.11796 = (long int) D.11795;
  D.11797 = __builtin_expect (D.11796, 0);
  if (D.11797 != 0) goto <D.11798>; else goto <D.11799>;
  <D.11798>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 669, "_wapi_has_shut_down == FALSE");
  <D.11799>:
  D.11803 = type + 4294967295;
  if (D.11803 > 1) goto <D.11804>; else goto <D.11801>;
  <D.11804>:
  if (type != 7) goto <D.11805>; else goto <D.11801>;
  <D.11805>:
  if (type != 10) goto <D.11806>; else goto <D.11801>;
  <D.11806>:
  iftmp.58 = 1;
  goto <D.11802>;
  <D.11801>:
  iftmp.58 = 0;
  <D.11802>:
  D.11807 = iftmp.58 != 0;
  D.11808 = (long int) D.11807;
  D.11809 = __builtin_expect (D.11808, 0);
  if (D.11809 != 0) goto <D.11810>; else goto <D.11811>;
  <D.11810>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 674, "_WAPI_FD_HANDLE(type)");
  <D.11811>:
  if (type == 9) goto <D.11813>; else goto <D.11816>;
  <D.11816>:
  if (type == 11) goto <D.11813>; else goto <D.11817>;
  <D.11817>:
  if (type == 12) goto <D.11813>; else goto <D.11818>;
  <D.11818>:
  if (type == 13) goto <D.11813>; else goto <D.11814>;
  <D.11813>:
  iftmp.59 = 1;
  goto <D.11815>;
  <D.11814>:
  iftmp.59 = 0;
  <D.11815>:
  D.11819 = iftmp.59 != 0;
  D.11820 = (long int) D.11819;
  D.11821 = __builtin_expect (D.11820, 0);
  if (D.11821 != 0) goto <D.11822>; else goto <D.11823>;
  <D.11822>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 675, "!_WAPI_SHARED_HANDLE(type)");
  <D.11823>:
  fd.60 = (unsigned int) fd;
  _wapi_fd_reserve.61 = _wapi_fd_reserve;
  if (fd.60 >= _wapi_fd_reserve.61) goto <D.11826>; else goto <D.11827>;
  <D.11826>:
  D.11828 = 4294967295B;
  return D.11828;
  <D.11827>:
  D.11829 = fd / 256;
  D.11830 = _wapi_private_handles[D.11829];
  if (D.11830 == 0B) goto <D.11831>; else goto <D.11832>;
  <D.11831>:
  D.11829 = fd / 256;
  init_handles_slot (D.11829);
  <D.11832>:
  D.11829 = fd / 256;
  D.11830 = _wapi_private_handles[D.11829];
  D.11833 = fd % 256;
  D.11834 = (unsigned int) D.11833;
  D.11835 = D.11834 * 144;
  handle = D.11830 + D.11835;
  D.11836 = handle->type;
  if (D.11836 != 0) goto <D.11837>; else goto <D.11838>;
  <D.11837>:
  <D.11838>:
  thr_ret = _wapi_shm_sem_lock (2);
  D.11839 = thr_ret != 0;
  D.11840 = (long int) D.11839;
  D.11841 = __builtin_expect (D.11840, 0);
  if (D.11841 != 0) goto <D.11842>; else goto <D.11843>;
  <D.11842>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 702, "thr_ret == 0");
  <D.11843>:
  _wapi_handle_init (handle, type, handle_specific);
  thr_ret = _wapi_shm_sem_unlock (2);
  D.11828 = (void *) fd;
  return D.11828;
}


init_handles_slot (int idx)
{
  long int D.11845;
  _Bool D.11848;
  long int D.11849;
  long int D.11850;
  struct _WapiHandleUnshared * D.11853;
  void * D.11856;
  _Bool D.11857;
  long int D.11858;
  long int D.11859;
  int thr_ret;

  {
    struct __pthread_unwind_buf_t __cancel_buf;
    void (*<Tc3>) (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.11845 = __builtin_expect (__not_first_call, 0);
        if (D.11845 != 0) goto <D.11846>; else goto <D.11847>;
        <D.11846>:
        __cancel_routine (__cancel_arg);
        __pthread_unwind_next (&__cancel_buf);
        <D.11847>:
        __pthread_register_cancel (&__cancel_buf);
        thr_ret = pthread_mutex_lock (&scan_mutex);
        D.11848 = thr_ret != 0;
        D.11849 = (long int) D.11848;
        D.11850 = __builtin_expect (D.11849, 0);
        if (D.11850 != 0) goto <D.11851>; else goto <D.11852>;
        <D.11851>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 650, "thr_ret == 0");
        <D.11852>:
        D.11853 = _wapi_private_handles[idx];
        if (D.11853 == 0B) goto <D.11854>; else goto <D.11855>;
        <D.11854>:
        D.11856 = monoeg_malloc0 (36864);
        _wapi_private_handles[idx] = D.11856;
        D.11853 = _wapi_private_handles[idx];
        D.11857 = D.11853 == 0B;
        D.11858 = (long int) D.11857;
        D.11859 = __builtin_expect (D.11858, 0);
        if (D.11859 != 0) goto <D.11860>; else goto <D.11861>;
        <D.11860>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 655, "_wapi_private_handles [idx]");
        <D.11861>:
        <D.11855>:
        thr_ret = pthread_mutex_unlock (&scan_mutex);
        D.11848 = thr_ret != 0;
        D.11849 = (long int) D.11848;
        D.11850 = __builtin_expect (D.11849, 0);
        if (D.11850 != 0) goto <D.11862>; else goto <D.11863>;
        <D.11862>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 659, "thr_ret == 0");
        <D.11863>:
        __pthread_unregister_cancel (&__cancel_buf);
        if (0 != 0) goto <D.11864>; else goto <D.11865>;
        <D.11864>:
        __cancel_routine (__cancel_arg);
        <D.11865>:
      }
    finally
      {
        __cancel_buf = {CLOBBER};
      }
  }
}


_wapi_lookup_handle (void * handle, WapiHandleType type, void * * handle_specific)
{
  gboolean D.11871;
  unsigned int D.11872;
  struct _WapiHandleUnshared * D.11873;
  int D.11876;
  unsigned int D.11877;
  unsigned int D.11878;
  <unnamed type> D.11879;
  struct _WapiHandleSharedLayout * _wapi_shared_layout.62;
  unsigned int D.11891;
  <unnamed type> D.11892;
  union 
{
  struct _WapiHandle_process process;
  struct _WapiHandle_namedmutex namedmutex;
  struct _WapiHandle_namedsem namedsem;
  struct _WapiHandle_namedevent namedevent;
} * D.11895;
  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.11896;
  struct _WapiHandleUnshared * handle_data;
  guint32 handle_idx;

  handle_idx = (guint32) handle;
  if (handle_idx > 4194303) goto <D.11869>; else goto <D.11870>;
  <D.11869>:
  D.11871 = 0;
  return D.11871;
  <D.11870>:
  D.11872 = handle_idx / 256;
  D.11873 = _wapi_private_handles[D.11872];
  if (D.11873 == 0B) goto <D.11874>; else goto <D.11875>;
  <D.11874>:
  D.11872 = handle_idx / 256;
  D.11876 = (int) D.11872;
  init_handles_slot (D.11876);
  <D.11875>:
  D.11872 = handle_idx / 256;
  D.11873 = _wapi_private_handles[D.11872];
  D.11877 = handle_idx & 255;
  D.11878 = D.11877 * 144;
  handle_data = D.11873 + D.11878;
  D.11879 = handle_data->type;
  if (D.11879 != type) goto <D.11880>; else goto <D.11881>;
  <D.11880>:
  D.11871 = 0;
  return D.11871;
  <D.11881>:
  if (handle_specific == 0B) goto <D.11882>; else goto <D.11883>;
  <D.11882>:
  D.11871 = 0;
  return D.11871;
  <D.11883>:
  if (type == 9) goto <D.11884>; else goto <D.11887>;
  <D.11887>:
  if (type == 11) goto <D.11884>; else goto <D.11888>;
  <D.11888>:
  if (type == 12) goto <D.11884>; else goto <D.11889>;
  <D.11889>:
  if (type == 13) goto <D.11884>; else goto <D.11885>;
  <D.11884>:
  {
    struct _WapiHandle_shared_ref * ref;
    struct _WapiHandleShared * shared_handle_data;

    ref = &handle_data->u.shared;
    _wapi_shared_layout.62 = _wapi_shared_layout;
    D.11891 = ref->offset;
    shared_handle_data = &_wapi_shared_layout.62->handles[D.11891];
    D.11892 = shared_handle_data->type;
    if (D.11892 != type) goto <D.11893>; else goto <D.11894>;
    <D.11893>:
    D.11871 = 0;
    return D.11871;
    <D.11894>:
    D.11895 = &shared_handle_data->u;
    *handle_specific = D.11895;
  }
  goto <D.11886>;
  <D.11885>:
  D.11896 = &handle_data->u;
  *handle_specific = D.11896;
  <D.11886>:
  D.11871 = 1;
  return D.11871;
}


_wapi_handle_foreach (WapiHandleType type, gboolean (*<T194f>) (void *, void *) on_each, void * user_data)
{
  long int D.11898;
  _Bool D.11901;
  long int D.11902;
  long int D.11903;
  struct _WapiHandleUnshared * D.11906;
  unsigned int D.11909;
  <unnamed type> D.11910;
  unsigned int D.11913;
  unsigned int D.11914;
  int D.11915;
  unsigned int _wapi_private_handle_slot_count.63;
  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 (*<Tc3>) (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.11898 = __builtin_expect (__not_first_call, 0);
        if (D.11898 != 0) goto <D.11899>; else goto <D.11900>;
        <D.11899>:
        __cancel_routine (__cancel_arg);
        __pthread_unwind_next (&__cancel_buf);
        <D.11900>:
        __pthread_register_cancel (&__cancel_buf);
        thr_ret = pthread_mutex_lock (&scan_mutex);
        D.11901 = thr_ret != 0;
        D.11902 = (long int) D.11901;
        D.11903 = __builtin_expect (D.11902, 0);
        if (D.11903 != 0) goto <D.11904>; else goto <D.11905>;
        <D.11904>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 769, "thr_ret == 0");
        <D.11905>:
        i = 0;
        goto <D.10964>;
        <D.10963>:
        D.11906 = _wapi_private_handles[i];
        if (D.11906 != 0B) goto <D.11907>; else goto <D.11908>;
        <D.11907>:
        k = 0;
        goto <D.10962>;
        <D.10961>:
        D.11906 = _wapi_private_handles[i];
        D.11909 = k * 144;
        handle_data = D.11906 + D.11909;
        D.11910 = handle_data->type;
        if (D.11910 == type) goto <D.11911>; else goto <D.11912>;
        <D.11911>:
        D.11913 = i * 256;
        D.11914 = D.11913 + k;
        ret = (void *) D.11914;
        D.11915 = on_each (ret, user_data);
        if (D.11915 == 1) goto <D.10960>; else goto <D.11916>;
        <D.11916>:
        <D.11912>:
        k = k + 1;
        <D.10962>:
        if (k <= 255) goto <D.10961>; else goto <D.10960>;
        <D.10960>:
        <D.11908>:
        i = i + 1;
        <D.10964>:
        _wapi_private_handle_slot_count.63 = _wapi_private_handle_slot_count;
        if (i < _wapi_private_handle_slot_count.63) goto <D.10963>; else goto <D.10965>;
        <D.10965>:
        thr_ret = pthread_mutex_unlock (&scan_mutex);
        D.11901 = thr_ret != 0;
        D.11902 = (long int) D.11901;
        D.11903 = __builtin_expect (D.11902, 0);
        if (D.11903 != 0) goto <D.11918>; else goto <D.11919>;
        <D.11918>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 786, "thr_ret == 0");
        <D.11919>:
        __pthread_unregister_cancel (&__cancel_buf);
        if (0 != 0) goto <D.11920>; else goto <D.11921>;
        <D.11920>:
        __cancel_routine (__cancel_arg);
        <D.11921>:
      }
    finally
      {
        __cancel_buf = {CLOBBER};
      }
  }
}


_wapi_search_handle (WapiHandleType type, gboolean (*<T194f>) (void *, void *) check, void * user_data, void * * handle_specific, gboolean search_shared)
{
  long int D.11925;
  _Bool D.11928;
  long int D.11929;
  long int D.11930;
  struct _WapiHandleUnshared * D.11933;
  unsigned int D.11936;
  <unnamed type> D.11937;
  unsigned int D.11940;
  unsigned int D.11941;
  int D.11942;
  struct _WapiHandleSharedLayout * _wapi_shared_layout.64;
  unsigned int _wapi_private_handle_slot_count.65;
  <unnamed type> D.11965;
  int D.11970;
  long int D.11977;
  guint32 * D.11978;
  int now.66;
  unsigned int ret.67;
  unsigned int D.11981;
  struct _WapiHandleUnshared * D.11982;
  unsigned int D.11983;
  unsigned int D.11984;
  _Bool D.11995;
  long int D.11996;
  long int D.11997;
  union 
{
  struct _WapiHandle_process process;
  struct _WapiHandle_namedmutex namedmutex;
  struct _WapiHandle_namedsem namedsem;
  struct _WapiHandle_namedevent namedevent;
} * D.12000;
  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.12001;
  void * D.12002;
  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 (*<Tc3>) (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.11925 = __builtin_expect (__not_first_call, 0);
        if (D.11925 != 0) goto <D.11926>; else goto <D.11927>;
        <D.11926>:
        __cancel_routine (__cancel_arg);
        __pthread_unwind_next (&__cancel_buf);
        <D.11927>:
        __pthread_register_cancel (&__cancel_buf);
        thr_ret = pthread_mutex_lock (&scan_mutex);
        D.11928 = thr_ret != 0;
        D.11929 = (long int) D.11928;
        D.11930 = __builtin_expect (D.11929, 0);
        if (D.11930 != 0) goto <D.11931>; else goto <D.11932>;
        <D.11931>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 814, "thr_ret == 0");
        <D.11932>:
        i = 0;
        goto <D.10992>;
        <D.10991>:
        D.11933 = _wapi_private_handles[i];
        if (D.11933 != 0B) goto <D.11934>; else goto <D.11935>;
        <D.11934>:
        k = 0;
        goto <D.10990>;
        <D.10989>:
        D.11933 = _wapi_private_handles[i];
        D.11936 = k * 144;
        handle_data = D.11933 + D.11936;
        D.11937 = handle_data->type;
        if (D.11937 == type) goto <D.11938>; else goto <D.11939>;
        <D.11938>:
        D.11940 = i * 256;
        D.11941 = D.11940 + k;
        ret = (void *) D.11941;
        D.11942 = check (ret, user_data);
        if (D.11942 == 1) goto <D.11943>; else goto <D.11944>;
        <D.11943>:
        _wapi_handle_ref (ret);
        found = 1;
        if (type == 9) goto <D.11945>; else goto <D.11947>;
        <D.11947>:
        if (type == 11) goto <D.11945>; else goto <D.11948>;
        <D.11948>:
        if (type == 12) goto <D.11945>; else goto <D.11949>;
        <D.11949>:
        if (type == 13) goto <D.11945>; else goto <D.11946>;
        <D.11945>:
        _wapi_shared_layout.64 = _wapi_shared_layout;
        shared = &_wapi_shared_layout.64->handles[i];
        <D.11946>:
        goto <D.10988>;
        <D.11944>:
        <D.11939>:
        k = k + 1;
        <D.10990>:
        if (k <= 255) goto <D.10989>; else goto <D.10988>;
        <D.10988>:
        <D.11935>:
        i = i + 1;
        <D.10992>:
        if (found == 0) goto <D.11951>; else goto <D.10993>;
        <D.11951>:
        _wapi_private_handle_slot_count.65 = _wapi_private_handle_slot_count;
        if (i < _wapi_private_handle_slot_count.65) goto <D.10991>; else goto <D.10993>;
        <D.10993>:
        thr_ret = pthread_mutex_unlock (&scan_mutex);
        D.11928 = thr_ret != 0;
        D.11929 = (long int) D.11928;
        D.11930 = __builtin_expect (D.11929, 0);
        if (D.11930 != 0) goto <D.11953>; else goto <D.11954>;
        <D.11953>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 839, "thr_ret == 0");
        <D.11954>:
        __pthread_unregister_cancel (&__cancel_buf);
        if (0 != 0) goto <D.11955>; else goto <D.11956>;
        <D.11955>:
        __cancel_routine (__cancel_arg);
        <D.11956>:
      }
    finally
      {
        __cancel_buf = {CLOBBER};
      }
  }
  if (found == 0) goto <D.11958>; else goto <D.11959>;
  <D.11958>:
  if (search_shared != 0) goto <D.11960>; else goto <D.11961>;
  <D.11960>:
  if (type == 9) goto <D.11957>; else goto <D.11962>;
  <D.11962>:
  if (type == 11) goto <D.11957>; else goto <D.11963>;
  <D.11963>:
  if (type == 12) goto <D.11957>; else goto <D.11964>;
  <D.11964>:
  if (type == 13) goto <D.11957>; else goto <D.10996>;
  <D.11957>:
  i = 0;
  goto <D.10998>;
  <D.10997>:
  _wapi_shared_layout.64 = _wapi_shared_layout;
  shared = &_wapi_shared_layout.64->handles[i];
  D.11965 = shared->type;
  if (D.11965 == type) goto <D.11966>; else goto <D.11967>;
  <D.11966>:
  ret = _wapi_handle_new_from_offset (type, i, 0);
  if (ret == 4294967295B) goto <D.11968>; else goto <D.11969>;
  <D.11968>:
  // predicted unlikely by continue predictor.
  goto <D.10994>;
  <D.11969>:
  D.11970 = check (ret, user_data);
  if (D.11970 == 1) goto <D.11971>; else goto <D.11972>;
  <D.11971>:
  thr_ret = _wapi_handle_lock_shared_handles ();
  D.11928 = thr_ret != 0;
  D.11929 = (long int) D.11928;
  D.11930 = __builtin_expect (D.11929, 0);
  if (D.11930 != 0) goto <D.11973>; else goto <D.11974>;
  <D.11973>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 881, "thr_ret == 0");
  <D.11974>:
  D.11965 = shared->type;
  if (D.11965 == type) goto <D.11975>; else goto <D.11976>;
  <D.11975>:
  {
    guint32 now;

    D.11977 = time (0B);
    now = (guint32) D.11977;
    D.11978 = &shared->timestamp;
    now.66 = (int) now;
    InterlockedExchange (D.11978, now.66);
    found = 1;
    ret.67 = (unsigned int) ret;
    D.11981 = ret.67 / 256;
    D.11982 = _wapi_private_handles[D.11981];
    ret.67 = (unsigned int) ret;
    D.11983 = ret.67 & 255;
    D.11984 = D.11983 * 144;
    handle_data = D.11982 + D.11984;
    _wapi_handle_unlock_shared_handles ();
    goto <D.10996>;
  }
  <D.11976>:
  _wapi_handle_unlock_shared_handles ();
  <D.11972>:
  _wapi_handle_unref (ret);
  <D.11967>:
  <D.10994>:
  i = i + 1;
  <D.10998>:
  if (i <= 255) goto <D.10997>; else goto <D.10996>;
  <D.10996>:
  <D.11961>:
  <D.11959>:
  if (found == 0) goto <D.11985>; else goto <D.11986>;
  <D.11985>:
  ret = 0B;
  goto done;
  <D.11986>:
  if (handle_specific != 0B) goto <D.11987>; else goto <D.11988>;
  <D.11987>:
  if (type == 9) goto <D.11989>; else goto <D.11992>;
  <D.11992>:
  if (type == 11) goto <D.11989>; else goto <D.11993>;
  <D.11993>:
  if (type == 12) goto <D.11989>; else goto <D.11994>;
  <D.11994>:
  if (type == 13) goto <D.11989>; else goto <D.11990>;
  <D.11989>:
  D.11965 = shared->type;
  D.11995 = D.11965 != type;
  D.11996 = (long int) D.11995;
  D.11997 = __builtin_expect (D.11996, 0);
  if (D.11997 != 0) goto <D.11998>; else goto <D.11999>;
  <D.11998>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 917, "shared->type == type");
  <D.11999>:
  D.12000 = &shared->u;
  *handle_specific = D.12000;
  goto <D.11991>;
  <D.11990>:
  D.12001 = &handle_data->u;
  *handle_specific = D.12001;
  <D.11991>:
  <D.11988>:
  done:
  D.12002 = ret;
  return D.12002;
}


_wapi_search_handle_namespace (WapiHandleType type, gchar * utf8_name)
{
  int iftmp.68;
  _Bool D.12017;
  long int D.12018;
  long int D.12019;
  _Bool D.12022;
  long int D.12023;
  long int D.12024;
  struct _WapiHandleSharedLayout * _wapi_shared_layout.69;
  <unnamed type> D.12028;
  unsigned int D.12029;
  int D.11018;
  gchar[261] * D.12032;
  gint32 D.12037;
  struct _WapiHandleShared * shared_handle_data;
  guint32 i;
  gint32 ret;
  int thr_ret;
  void done = <<< error >>>;

  ret = 0;
  if (type != 9) goto <D.12013>; else goto <D.12011>;
  <D.12013>:
  if (type != 11) goto <D.12014>; else goto <D.12011>;
  <D.12014>:
  if (type != 12) goto <D.12015>; else goto <D.12011>;
  <D.12015>:
  if (type != 13) goto <D.12016>; else goto <D.12011>;
  <D.12016>:
  iftmp.68 = 1;
  goto <D.12012>;
  <D.12011>:
  iftmp.68 = 0;
  <D.12012>:
  D.12017 = iftmp.68 != 0;
  D.12018 = (long int) D.12017;
  D.12019 = __builtin_expect (D.12018, 0);
  if (D.12019 != 0) goto <D.12020>; else goto <D.12021>;
  <D.12020>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 940, "_WAPI_SHARED_HANDLE(type)");
  <D.12021>:
  _wapi_handle_collect ();
  thr_ret = _wapi_handle_lock_shared_handles ();
  D.12022 = thr_ret != 0;
  D.12023 = (long int) D.12022;
  D.12024 = __builtin_expect (D.12023, 0);
  if (D.12024 != 0) goto <D.12025>; else goto <D.12026>;
  <D.12025>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 951, "thr_ret == 0");
  <D.12026>:
  i = 1;
  goto <D.11021>;
  <D.11020>:
  {
    struct WapiSharedNamespace * sharedns;

    _wapi_shared_layout.69 = _wapi_shared_layout;
    shared_handle_data = &_wapi_shared_layout.69->handles[i];
    D.12028 = shared_handle_data->type;
    D.12029 = D.12028 + 4294967285;
    if (D.12029 > 2) goto <D.12030>; else goto <D.12031>;
    <D.12030>:
    // predicted unlikely by continue predictor.
    goto <D.11009>;
    <D.12031>:
    sharedns = &shared_handle_data->u;
    {
      size_t __s1_len;
      size_t __s2_len;

      D.12032 = &sharedns->name;
      D.11018 = __builtin_strcmp (D.12032, utf8_name);
    }
    if (D.11018 == 0) goto <D.12033>; else goto <D.12034>;
    <D.12033>:
    D.12028 = shared_handle_data->type;
    if (D.12028 != type) goto <D.12035>; else goto <D.12036>;
    <D.12035>:
    ret = -1;
    goto done;
    <D.12036>:
    ret = (gint32) i;
    goto done;
    <D.12034>:
  }
  <D.11009>:
  i = i + 1;
  <D.11021>:
  if (i <= 255) goto <D.11020>; else goto <D.11022>;
  <D.11022>:
  done:
  _wapi_handle_unlock_shared_handles ();
  D.12037 = ret;
  return D.12037;
}


_wapi_handle_ref (void * handle)
{
  <unnamed type> D.12041;
  unsigned int D.12044;
  struct _WapiHandleUnshared * D.12045;
  unsigned int D.12046;
  unsigned int D.12047;
  guint * D.12048;
  <unnamed type> D.12051;
  struct _WapiHandleSharedLayout * _wapi_shared_layout.70;
  unsigned int D.12056;
  long int D.12057;
  guint32 * D.12058;
  int now.71;
  guint32 idx;
  struct _WapiHandleUnshared * handle_data;
  static const char __func__[17] = "_wapi_handle_ref";

  idx = (guint32) handle;
  if (idx > 4194303) goto <D.12039>; else goto <D.12040>;
  <D.12039>:
  return;
  <D.12040>:
  D.12041 = _wapi_handle_type (handle);
  if (D.12041 == 0) goto <D.12042>; else goto <D.12043>;
  <D.12042>:
  monoeg_g_log (0B, 16, "%s: Attempting to ref unused handle %p", &__func__, handle);
  return;
  <D.12043>:
  D.12044 = idx / 256;
  D.12045 = _wapi_private_handles[D.12044];
  D.12046 = idx & 255;
  D.12047 = D.12046 * 144;
  handle_data = D.12045 + D.12047;
  D.12048 = &handle_data->ref;
  InterlockedIncrement (D.12048);
  D.12051 = handle_data->type;
  if (D.12051 == 9) goto <D.12049>; else goto <D.12052>;
  <D.12052>:
  D.12051 = handle_data->type;
  if (D.12051 == 11) goto <D.12049>; else goto <D.12053>;
  <D.12053>:
  D.12051 = handle_data->type;
  if (D.12051 == 12) goto <D.12049>; else goto <D.12054>;
  <D.12054>:
  D.12051 = handle_data->type;
  if (D.12051 == 13) goto <D.12049>; else goto <D.12050>;
  <D.12049>:
  {
    struct _WapiHandleShared * shared_data;
    guint32 now;

    _wapi_shared_layout.70 = _wapi_shared_layout;
    D.12056 = handle_data->u.shared.offset;
    shared_data = &_wapi_shared_layout.70->handles[D.12056];
    D.12057 = time (0B);
    now = (guint32) D.12057;
    D.12058 = &shared_data->timestamp;
    now.71 = (int) now;
    InterlockedExchange (D.12058, now.71);
  }
  <D.12050>:
}


_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.12063;
  unsigned int D.12064;
  struct _WapiHandleUnshared * D.12065;
  unsigned int D.12066;
  unsigned int D.12067;
  struct _WapiHandleUnshared * D.12068;
  <unnamed type> D.12069;
  unsigned int D.12070;
  _Bool D.12071;
  guint32 idx;
  WapiHandleType type;

  idx = (guint32) handle;
  if (idx > 4194303) goto <D.12061>; else goto <D.12062>;
  <D.12061>:
  D.12063 = 0;
  return D.12063;
  <D.12062>:
  D.12064 = idx / 256;
  D.12065 = _wapi_private_handles[D.12064];
  D.12066 = idx & 255;
  D.12067 = D.12066 * 144;
  D.12068 = D.12065 + D.12067;
  type = D.12068->type;
  D.12069 = handle_caps[type];
  D.12070 = D.12069 & caps;
  D.12071 = D.12070 != 0;
  D.12063 = (gboolean) D.12071;
  return D.12063;
}


_wapi_handle_ops_close (void * handle, void * data)
{
  unsigned int D.12075;
  struct _WapiHandleUnshared * D.12076;
  unsigned int D.12077;
  unsigned int D.12078;
  struct _WapiHandleUnshared * D.12079;
  struct _WapiHandleOps * D.12080;
  void (*<Tbc3>) (void *, void *) D.12083;
  guint32 idx;
  WapiHandleType type;

  idx = (guint32) handle;
  if (idx > 4194303) goto <D.12073>; else goto <D.12074>;
  <D.12073>:
  return;
  <D.12074>:
  D.12075 = idx / 256;
  D.12076 = _wapi_private_handles[D.12075];
  D.12077 = idx & 255;
  D.12078 = D.12077 * 144;
  D.12079 = D.12076 + D.12078;
  type = D.12079->type;
  D.12080 = handle_ops[type];
  if (D.12080 != 0B) goto <D.12081>; else goto <D.12082>;
  <D.12081>:
  D.12080 = handle_ops[type];
  D.12083 = D.12080->close;
  if (D.12083 != 0B) goto <D.12084>; else goto <D.12085>;
  <D.12084>:
  D.12080 = handle_ops[type];
  D.12083 = D.12080->close;
  D.12083 (handle, data);
  <D.12085>:
  <D.12082>:
}


_wapi_handle_ops_signal (void * handle)
{
  unsigned int D.12089;
  struct _WapiHandleUnshared * D.12090;
  unsigned int D.12091;
  unsigned int D.12092;
  struct _WapiHandleUnshared * D.12093;
  struct _WapiHandleOps * D.12094;
  void (*<Tb30>) (void *) D.12097;
  guint32 idx;
  WapiHandleType type;

  idx = (guint32) handle;
  if (idx > 4194303) goto <D.12087>; else goto <D.12088>;
  <D.12087>:
  return;
  <D.12088>:
  D.12089 = idx / 256;
  D.12090 = _wapi_private_handles[D.12089];
  D.12091 = idx & 255;
  D.12092 = D.12091 * 144;
  D.12093 = D.12090 + D.12092;
  type = D.12093->type;
  D.12094 = handle_ops[type];
  if (D.12094 != 0B) goto <D.12095>; else goto <D.12096>;
  <D.12095>:
  D.12094 = handle_ops[type];
  D.12097 = D.12094->signal;
  if (D.12097 != 0B) goto <D.12098>; else goto <D.12099>;
  <D.12098>:
  D.12094 = handle_ops[type];
  D.12097 = D.12094->signal;
  D.12097 (handle);
  <D.12099>:
  <D.12096>:
}


_wapi_handle_ops_own (void * handle)
{
  gboolean D.12103;
  unsigned int D.12104;
  struct _WapiHandleUnshared * D.12105;
  unsigned int D.12106;
  unsigned int D.12107;
  struct _WapiHandleUnshared * D.12108;
  struct _WapiHandleOps * D.12110;
  gboolean (*<T17b2>) (void *) D.12112;
  guint32 idx;
  WapiHandleType type;

  idx = (guint32) handle;
  if (idx > 4194303) goto <D.12101>; else goto <D.12102>;
  <D.12101>:
  D.12103 = 0;
  return D.12103;
  <D.12102>:
  D.12104 = idx / 256;
  D.12105 = _wapi_private_handles[D.12104];
  D.12106 = idx & 255;
  D.12107 = D.12106 * 144;
  D.12108 = D.12105 + D.12107;
  type = D.12108->type;
  D.12110 = handle_ops[type];
  if (D.12110 != 0B) goto <D.12111>; else goto <D.12109>;
  <D.12111>:
  D.12110 = handle_ops[type];
  D.12112 = D.12110->own_handle;
  if (D.12112 != 0B) goto <D.12113>; else goto <D.12109>;
  <D.12113>:
  D.12110 = handle_ops[type];
  D.12112 = D.12110->own_handle;
  D.12103 = D.12112 (handle);
  return D.12103;
  <D.12109>:
  D.12103 = 0;
  return D.12103;
}


_wapi_handle_ops_isowned (void * handle)
{
  gboolean D.12117;
  unsigned int D.12118;
  struct _WapiHandleUnshared * D.12119;
  unsigned int D.12120;
  unsigned int D.12121;
  struct _WapiHandleUnshared * D.12122;
  struct _WapiHandleOps * D.12124;
  gboolean (*<T17b2>) (void *) D.12126;
  guint32 idx;
  WapiHandleType type;

  idx = (guint32) handle;
  if (idx > 4194303) goto <D.12115>; else goto <D.12116>;
  <D.12115>:
  D.12117 = 0;
  return D.12117;
  <D.12116>:
  D.12118 = idx / 256;
  D.12119 = _wapi_private_handles[D.12118];
  D.12120 = idx & 255;
  D.12121 = D.12120 * 144;
  D.12122 = D.12119 + D.12121;
  type = D.12122->type;
  D.12124 = handle_ops[type];
  if (D.12124 != 0B) goto <D.12125>; else goto <D.12123>;
  <D.12125>:
  D.12124 = handle_ops[type];
  D.12126 = D.12124->is_owned;
  if (D.12126 != 0B) goto <D.12127>; else goto <D.12123>;
  <D.12127>:
  D.12124 = handle_ops[type];
  D.12126 = D.12124->is_owned;
  D.12117 = D.12126 (handle);
  return D.12117;
  <D.12123>:
  D.12117 = 0;
  return D.12117;
}


_wapi_handle_ops_special_wait (void * handle, guint32 timeout, gboolean alertable)
{
  guint32 D.12131;
  unsigned int D.12132;
  struct _WapiHandleUnshared * D.12133;
  unsigned int D.12134;
  unsigned int D.12135;
  struct _WapiHandleUnshared * D.12136;
  struct _WapiHandleOps * D.12138;
  guint32 (*<T17b7>) (void *, guint32, gboolean) D.12140;
  guint32 idx;
  WapiHandleType type;

  idx = (guint32) handle;
  if (idx > 4194303) goto <D.12129>; else goto <D.12130>;
  <D.12129>:
  D.12131 = 4294967295;
  return D.12131;
  <D.12130>:
  D.12132 = idx / 256;
  D.12133 = _wapi_private_handles[D.12132];
  D.12134 = idx & 255;
  D.12135 = D.12134 * 144;
  D.12136 = D.12133 + D.12135;
  type = D.12136->type;
  D.12138 = handle_ops[type];
  if (D.12138 != 0B) goto <D.12139>; else goto <D.12137>;
  <D.12139>:
  D.12138 = handle_ops[type];
  D.12140 = D.12138->special_wait;
  if (D.12140 != 0B) goto <D.12141>; else goto <D.12137>;
  <D.12141>:
  D.12138 = handle_ops[type];
  D.12140 = D.12138->special_wait;
  D.12131 = D.12140 (handle, timeout, alertable);
  return D.12131;
  <D.12137>:
  D.12131 = 4294967295;
  return D.12131;
}


_wapi_handle_ops_prewait (void * handle)
{
  unsigned int D.12145;
  struct _WapiHandleUnshared * D.12146;
  unsigned int D.12147;
  unsigned int D.12148;
  struct _WapiHandleUnshared * D.12149;
  struct _WapiHandleOps * D.12150;
  void (*<Tb30>) (void *) D.12153;
  guint32 idx;
  WapiHandleType type;

  idx = (guint32) handle;
  if (idx > 4194303) goto <D.12143>; else goto <D.12144>;
  <D.12143>:
  return;
  <D.12144>:
  D.12145 = idx / 256;
  D.12146 = _wapi_private_handles[D.12145];
  D.12147 = idx & 255;
  D.12148 = D.12147 * 144;
  D.12149 = D.12146 + D.12148;
  type = D.12149->type;
  D.12150 = handle_ops[type];
  if (D.12150 != 0B) goto <D.12151>; else goto <D.12152>;
  <D.12151>:
  D.12150 = handle_ops[type];
  D.12153 = D.12150->prewait;
  if (D.12153 != 0B) goto <D.12154>; else goto <D.12155>;
  <D.12154>:
  D.12150 = handle_ops[type];
  D.12153 = D.12150->prewait;
  D.12153 (handle);
  <D.12155>:
  <D.12152>:
}


CloseHandle (void * handle)
{
  struct _WapiHandleUnshared * D.12159;
  <unnamed type> D.12160;
  gboolean D.12163;

  if (handle == 0B) goto <D.12157>; else goto <D.12158>;
  <D.12157>:
  D.12159 = _wapi_private_handles[0];
  D.12160 = D.12159->type;
  if (D.12160 != 2) goto <D.12161>; else goto <D.12162>;
  <D.12161>:
  SetLastError (87);
  D.12163 = 0;
  return D.12163;
  <D.12162>:
  <D.12158>:
  if (handle == 4294967295B) goto <D.12164>; else goto <D.12165>;
  <D.12164>:
  SetLastError (87);
  D.12163 = 0;
  return D.12163;
  <D.12165>:
  _wapi_handle_unref (handle);
  D.12163 = 1;
  return D.12163;
}


DuplicateHandle (void * srcprocess, void * src, void * targetprocess, void * * target, guint32 access, gboolean inherit, guint32 options)
{
  gboolean D.12170;
  void * D.12173;
  void * D.12177;

  if (srcprocess != 4294967295B) goto <D.12167>; else goto <D.12169>;
  <D.12169>:
  if (targetprocess != 4294967295B) goto <D.12167>; else goto <D.12168>;
  <D.12167>:
  SetLastError (6);
  D.12170 = 0;
  return D.12170;
  <D.12168>:
  if (src == 4294967295B) goto <D.12171>; else goto <D.12172>;
  <D.12171>:
  D.12173 = _wapi_process_duplicate ();
  *target = D.12173;
  goto <D.12174>;
  <D.12172>:
  if (src == 4294967294B) goto <D.12175>; else goto <D.12176>;
  <D.12175>:
  D.12177 = _wapi_thread_duplicate ();
  *target = D.12177;
  goto <D.12178>;
  <D.12176>:
  _wapi_handle_ref (src);
  *target = src;
  <D.12178>:
  <D.12174>:
  D.12170 = 1;
  return D.12170;
}


_wapi_handle_count_signalled_handles (guint32 numhandles, void * * handles, gboolean waitall, guint32 * retcount, guint32 * lowest)
{
  _Bool D.12180;
  long int D.12181;
  long int D.12182;
  unsigned int D.12185;
  void * * D.12186;
  unsigned int D.12187;
  struct _WapiHandleUnshared * D.12188;
  unsigned int D.12189;
  unsigned int D.12190;
  struct _WapiHandleUnshared * D.12191;
  unsigned int i.72;
  unsigned int D.12201;
  unsigned int D.12202;
  struct _WapiHandleUnshared * D.12203;
  unsigned int D.12204;
  unsigned int D.12205;
  struct _WapiHandleUnshared * D.12206;
  int D.12212;
  int D.12214;
  struct _WapiHandleSharedLayout * _wapi_shared_layout.73;
  unsigned int handle.74;
  unsigned int D.12220;
  struct _WapiHandleUnshared * D.12221;
  unsigned int D.12222;
  unsigned int D.12223;
  struct _WapiHandleUnshared * D.12224;
  unsigned int D.12225;
  int D.12226;
  int D.12231;
  unsigned int D.12232;
  gboolean D.12241;
  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.12180 = thr_ret != 0;
  D.12181 = (long int) D.12180;
  D.12182 = __builtin_expect (D.12181, 0);
  if (D.12182 != 0) goto <D.12183>; else goto <D.12184>;
  <D.12183>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 1375, "thr_ret == 0");
  <D.12184>:
  i = 0;
  goto <D.11140>;
  <D.11139>:
  {
    void * handle;
    guint32 idx;

    D.12185 = i * 4;
    D.12186 = handles + D.12185;
    handle = *D.12186;
    idx = (guint32) handle;
    D.12187 = idx / 256;
    D.12188 = _wapi_private_handles[D.12187];
    D.12189 = idx & 255;
    D.12190 = D.12189 * 144;
    D.12191 = D.12188 + D.12190;
    type = D.12191->type;
    thr_ret = _wapi_handle_trylock_handle (handle);
    if (thr_ret != 0) goto <D.12192>; else goto <D.12193>;
    <D.12192>:
    thr_ret = _wapi_handle_unlock_shared_handles ();
    D.12180 = thr_ret != 0;
    D.12181 = (long int) D.12180;
    D.12182 = __builtin_expect (D.12181, 0);
    if (D.12182 != 0) goto <D.12194>; else goto <D.12195>;
    <D.12194>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 1394, "thr_ret == 0");
    <D.12195>:
    goto <D.11136>;
    <D.11135>:
    D.12185 = i * 4;
    D.12186 = handles + D.12185;
    handle = *D.12186;
    idx = (guint32) handle;
    thr_ret = _wapi_handle_unlock_handle (handle);
    D.12180 = thr_ret != 0;
    D.12181 = (long int) D.12180;
    D.12182 = __builtin_expect (D.12181, 0);
    if (D.12182 != 0) goto <D.12196>; else goto <D.12197>;
    <D.12196>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 1401, "thr_ret == 0");
    <D.12197>:
    <D.11136>:
    i.72 = i;
    i = i.72 + 4294967295;
    if (i.72 != 0) goto <D.11135>; else goto <D.11137>;
    <D.11137>:
    iter = iter + 1;
    if (iter == 100) goto <D.12199>; else goto <D.12200>;
    <D.12199>:
    monoeg_g_log (0B, 16, "%s: iteration overflow!", &__func__);
    iter = 1;
    <D.12200>:
    D.12201 = iter * 10;
    _wapi_handle_spin (D.12201);
    goto again;
    <D.12193>:
  }
  i = i + 1;
  <D.11140>:
  if (i < numhandles) goto <D.11139>; else goto <D.11141>;
  <D.11141>:
  count = 0;
  *lowest = numhandles;
  i = 0;
  goto <D.11145>;
  <D.11144>:
  {
    void * handle;
    guint32 idx;

    D.12185 = i * 4;
    D.12186 = handles + D.12185;
    handle = *D.12186;
    idx = (guint32) handle;
    D.12202 = idx / 256;
    D.12203 = _wapi_private_handles[D.12202];
    D.12204 = idx & 255;
    D.12205 = D.12204 * 144;
    D.12206 = D.12203 + D.12205;
    type = D.12206->type;
    D.12212 = _wapi_handle_test_capabilities (handle, 4);
    if (D.12212 == 1) goto <D.12213>; else goto <D.12207>;
    <D.12213>:
    D.12214 = _wapi_handle_ops_isowned (handle);
    if (D.12214 == 1) goto <D.12208>; else goto <D.12207>;
    <D.12207>:
    if (type == 9) goto <D.12209>; else goto <D.12215>;
    <D.12215>:
    if (type == 11) goto <D.12209>; else goto <D.12216>;
    <D.12216>:
    if (type == 12) goto <D.12209>; else goto <D.12217>;
    <D.12217>:
    if (type == 13) goto <D.12209>; else goto <D.12210>;
    <D.12209>:
    _wapi_shared_layout.73 = _wapi_shared_layout;
    handle.74 = (unsigned int) handle;
    D.12220 = handle.74 / 256;
    D.12221 = _wapi_private_handles[D.12220];
    handle.74 = (unsigned int) handle;
    D.12222 = handle.74 & 255;
    D.12223 = D.12222 * 144;
    D.12224 = D.12221 + D.12223;
    D.12225 = D.12224->u.shared.offset;
    D.12226 = _wapi_shared_layout.73->handles[D.12225].signalled;
    if (D.12226 == 1) goto <D.12208>; else goto <D.12210>;
    <D.12210>:
    if (type != 9) goto <D.12227>; else goto <D.12211>;
    <D.12227>:
    if (type != 11) goto <D.12228>; else goto <D.12211>;
    <D.12228>:
    if (type != 12) goto <D.12229>; else goto <D.12211>;
    <D.12229>:
    if (type != 13) goto <D.12230>; else goto <D.12211>;
    <D.12230>:
    D.12202 = idx / 256;
    D.12203 = _wapi_private_handles[D.12202];
    D.12204 = idx & 255;
    D.12205 = D.12204 * 144;
    D.12206 = D.12203 + D.12205;
    D.12231 = D.12206->signalled;
    if (D.12231 == 1) goto <D.12208>; else goto <D.12211>;
    <D.12208>:
    count = count + 1;
    D.12232 = *lowest;
    if (D.12232 > i) goto <D.12233>; else goto <D.12234>;
    <D.12233>:
    *lowest = i;
    <D.12234>:
    <D.12211>:
  }
  i = i + 1;
  <D.11145>:
  if (i < numhandles) goto <D.11144>; else goto <D.11146>;
  <D.11146>:
  if (waitall == 1) goto <D.12239>; else goto <D.12235>;
  <D.12239>:
  if (count == numhandles) goto <D.12236>; else goto <D.12235>;
  <D.12235>:
  if (waitall == 0) goto <D.12240>; else goto <D.12237>;
  <D.12240>:
  if (count != 0) goto <D.12236>; else goto <D.12237>;
  <D.12236>:
  ret = 1;
  goto <D.12238>;
  <D.12237>:
  ret = 0;
  <D.12238>:
  *retcount = count;
  D.12241 = ret;
  return D.12241;
}


_wapi_handle_trylock_handle (void * handle)
{
  int D.12245;
  <unnamed type> D.12248;
  <unnamed type> D.12250;
  <unnamed type> D.12252;
  <unnamed type> D.12254;
  unsigned int D.12255;
  struct _WapiHandleUnshared * D.12256;
  unsigned int D.12257;
  unsigned int D.12258;
  struct _WapiHandleUnshared * D.12259;
  union mono_mutex_t * D.12260;
  guint32 idx;
  int ret;

  idx = (guint32) handle;
  if (idx > 4194303) goto <D.12243>; else goto <D.12244>;
  <D.12243>:
  D.12245 = 0;
  return D.12245;
  <D.12244>:
  _wapi_handle_ref (handle);
  D.12248 = _wapi_handle_type (handle);
  if (D.12248 == 9) goto <D.12246>; else goto <D.12249>;
  <D.12249>:
  D.12250 = _wapi_handle_type (handle);
  if (D.12250 == 11) goto <D.12246>; else goto <D.12251>;
  <D.12251>:
  D.12252 = _wapi_handle_type (handle);
  if (D.12252 == 12) goto <D.12246>; else goto <D.12253>;
  <D.12253>:
  D.12254 = _wapi_handle_type (handle);
  if (D.12254 == 13) goto <D.12246>; else goto <D.12247>;
  <D.12246>:
  D.12245 = 0;
  return D.12245;
  <D.12247>:
  D.12255 = idx / 256;
  D.12256 = _wapi_private_handles[D.12255];
  D.12257 = idx & 255;
  D.12258 = D.12257 * 144;
  D.12259 = D.12256 + D.12258;
  D.12260 = &D.12259->signal_mutex;
  ret = pthread_mutex_trylock (D.12260);
  if (ret != 0) goto <D.12261>; else goto <D.12262>;
  <D.12261>:
  _wapi_handle_unref (handle);
  <D.12262>:
  D.12245 = ret;
  return D.12245;
}


_wapi_handle_unlock_handle (void * handle)
{
  int D.12266;
  <unnamed type> D.12269;
  <unnamed type> D.12271;
  <unnamed type> D.12273;
  <unnamed type> D.12275;
  unsigned int D.12276;
  struct _WapiHandleUnshared * D.12277;
  unsigned int D.12278;
  unsigned int D.12279;
  struct _WapiHandleUnshared * D.12280;
  union mono_mutex_t * D.12281;
  guint32 idx;
  int ret;

  idx = (guint32) handle;
  if (idx > 4194303) goto <D.12264>; else goto <D.12265>;
  <D.12264>:
  D.12266 = 0;
  return D.12266;
  <D.12265>:
  D.12269 = _wapi_handle_type (handle);
  if (D.12269 == 9) goto <D.12267>; else goto <D.12270>;
  <D.12270>:
  D.12271 = _wapi_handle_type (handle);
  if (D.12271 == 11) goto <D.12267>; else goto <D.12272>;
  <D.12272>:
  D.12273 = _wapi_handle_type (handle);
  if (D.12273 == 12) goto <D.12267>; else goto <D.12274>;
  <D.12274>:
  D.12275 = _wapi_handle_type (handle);
  if (D.12275 == 13) goto <D.12267>; else goto <D.12268>;
  <D.12267>:
  _wapi_handle_unref (handle);
  D.12266 = 0;
  return D.12266;
  <D.12268>:
  D.12276 = idx / 256;
  D.12277 = _wapi_private_handles[D.12276];
  D.12278 = idx & 255;
  D.12279 = D.12278 * 144;
  D.12280 = D.12277 + D.12279;
  D.12281 = &D.12280->signal_mutex;
  ret = pthread_mutex_unlock (D.12281);
  _wapi_handle_unref (handle);
  D.12266 = ret;
  return D.12266;
}


_wapi_handle_spin (guint32 ms)
{
  _Bool D.12283;
  long int D.12284;
  long int D.12285;
  unsigned int D.12288;
  long int D.12289;
  struct timespec sleepytime;

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


_wapi_handle_unlock_handles (guint32 numhandles, void * * handles)
{
  _Bool D.12290;
  long int D.12291;
  long int D.12292;
  unsigned int D.12295;
  void * * D.12296;
  guint32 i;
  int thr_ret;

  thr_ret = _wapi_handle_unlock_shared_handles ();
  D.12290 = thr_ret != 0;
  D.12291 = (long int) D.12290;
  D.12292 = __builtin_expect (D.12291, 0);
  if (D.12292 != 0) goto <D.12293>; else goto <D.12294>;
  <D.12293>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 1474, "thr_ret == 0");
  <D.12294>:
  i = 0;
  goto <D.11155>;
  <D.11154>:
  {
    void * handle;

    D.12295 = i * 4;
    D.12296 = handles + D.12295;
    handle = *D.12296;
    thr_ret = _wapi_handle_unlock_handle (handle);
    D.12290 = thr_ret != 0;
    D.12291 = (long int) D.12290;
    D.12292 = __builtin_expect (D.12291, 0);
    if (D.12292 != 0) goto <D.12297>; else goto <D.12298>;
    <D.12297>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 1482, "thr_ret == 0");
    <D.12298>:
  }
  i = i + 1;
  <D.11155>:
  if (i < numhandles) goto <D.11154>; else goto <D.11156>;
  <D.11156>:
}


_wapi_handle_wait_signal (gboolean poll)
{
  int D.12299;
  void * _wapi_global_signal_handle.75;

  _wapi_global_signal_handle.75 = _wapi_global_signal_handle;
  D.12299 = _wapi_handle_timedwait_signal_handle (_wapi_global_signal_handle.75, 0B, 1, poll);
  return D.12299;
}


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

  _wapi_global_signal_handle.76 = _wapi_global_signal_handle;
  D.12302 = _wapi_handle_timedwait_signal_handle (_wapi_global_signal_handle.76, timeout, 1, poll);
  return D.12302;
}


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

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


_wapi_handle_timedwait_signal_handle (void * handle, struct timespec * timeout, gboolean alertable, gboolean poll)
{
  <unnamed type> D.12309;
  <unnamed type> D.12311;
  <unnamed type> D.12313;
  <unnamed type> D.12315;
  struct _WapiHandleSharedLayout * _wapi_shared_layout.77;
  unsigned int handle.78;
  unsigned int D.12318;
  struct _WapiHandleUnshared * D.12319;
  unsigned int D.12320;
  unsigned int D.12321;
  struct _WapiHandleUnshared * D.12322;
  unsigned int D.12323;
  int D.12324;
  int D.12327;
  long int D.12332;
  long int D.12333;
  long int D.12336;
  long int D.12337;
  int D.12338;
  int D.12343;
  unsigned int D.12346;
  struct _WapiHandleUnshared * D.12347;
  unsigned int D.12348;
  unsigned int D.12349;
  struct _WapiHandleUnshared * D.12350;

  D.12309 = _wapi_handle_type (handle);
  if (D.12309 == 9) goto <D.12307>; else goto <D.12310>;
  <D.12310>:
  D.12311 = _wapi_handle_type (handle);
  if (D.12311 == 11) goto <D.12307>; else goto <D.12312>;
  <D.12312>:
  D.12313 = _wapi_handle_type (handle);
  if (D.12313 == 12) goto <D.12307>; else goto <D.12314>;
  <D.12314>:
  D.12315 = _wapi_handle_type (handle);
  if (D.12315 == 13) goto <D.12307>; else goto <D.12308>;
  <D.12307>:
  _wapi_shared_layout.77 = _wapi_shared_layout;
  handle.78 = (unsigned int) handle;
  D.12318 = handle.78 / 256;
  D.12319 = _wapi_private_handles[D.12318];
  handle.78 = (unsigned int) handle;
  D.12320 = handle.78 & 255;
  D.12321 = D.12320 * 144;
  D.12322 = D.12319 + D.12321;
  D.12323 = D.12322->u.shared.offset;
  D.12324 = _wapi_shared_layout.77->handles[D.12323].signalled;
  if (D.12324 == 1) goto <D.12325>; else goto <D.12326>;
  <D.12325>:
  D.12327 = 0;
  return D.12327;
  <D.12326>:
  if (timeout != 0B) goto <D.12328>; else goto <D.12329>;
  <D.12328>:
  {
    struct timespec fake_timeout;

    try
      {
        _wapi_calc_timeout (&fake_timeout, 100);
        D.12332 = fake_timeout.tv_sec;
        D.12333 = timeout->tv_sec;
        if (D.12332 > D.12333) goto <D.12330>; else goto <D.12334>;
        <D.12334>:
        D.12332 = fake_timeout.tv_sec;
        D.12333 = timeout->tv_sec;
        if (D.12332 == D.12333) goto <D.12335>; else goto <D.12331>;
        <D.12335>:
        D.12336 = fake_timeout.tv_nsec;
        D.12337 = timeout->tv_nsec;
        if (D.12336 > D.12337) goto <D.12330>; else goto <D.12331>;
        <D.12330>:
        _wapi_handle_spin (100);
        _wapi_shared_layout.77 = _wapi_shared_layout;
        handle.78 = (unsigned int) handle;
        D.12318 = handle.78 / 256;
        D.12319 = _wapi_private_handles[D.12318];
        handle.78 = (unsigned int) handle;
        D.12320 = handle.78 & 255;
        D.12321 = D.12320 * 144;
        D.12322 = D.12319 + D.12321;
        D.12323 = D.12322->u.shared.offset;
        D.12338 = _wapi_shared_layout.77->handles[D.12323].signalled;
        if (D.12338 == 1) goto <D.12339>; else goto <D.12340>;
        <D.12339>:
        D.12327 = 0;
        return D.12327;
        <D.12340>:
        D.12327 = 145;
        return D.12327;
        <D.12331>:
      }
    finally
      {
        fake_timeout = {CLOBBER};
      }
  }
  <D.12329>:
  _wapi_handle_spin (100);
  D.12327 = 0;
  return D.12327;
  <D.12308>:
  {
    guint32 idx;
    int res;
    union pthread_cond_t * cond;
    union mono_mutex_t * mutex;

    idx = (guint32) handle;
    if (alertable != 0) goto <D.12341>; else goto <D.12342>;
    <D.12341>:
    D.12343 = wapi_thread_set_wait_handle (handle);
    if (D.12343 == 0) goto <D.12344>; else goto <D.12345>;
    <D.12344>:
    D.12327 = 0;
    return D.12327;
    <D.12345>:
    <D.12342>:
    D.12346 = idx / 256;
    D.12347 = _wapi_private_handles[D.12346];
    D.12348 = idx & 255;
    D.12349 = D.12348 * 144;
    D.12350 = D.12347 + D.12349;
    cond = &D.12350->signal_cond;
    D.12346 = idx / 256;
    D.12347 = _wapi_private_handles[D.12346];
    D.12348 = idx & 255;
    D.12349 = D.12348 * 144;
    D.12350 = D.12347 + D.12349;
    mutex = &D.12350->signal_mutex;
    if (poll != 0) goto <D.12351>; else goto <D.12352>;
    <D.12351>:
    res = timedwait_signal_poll_cond (cond, mutex, timeout, alertable);
    goto <D.12353>;
    <D.12352>:
    if (timeout != 0B) goto <D.12354>; else goto <D.12355>;
    <D.12354>:
    res = pthread_cond_timedwait (cond, mutex, timeout);
    goto <D.12356>;
    <D.12355>:
    res = pthread_cond_wait (cond, mutex);
    <D.12356>:
    <D.12353>:
    if (alertable != 0) goto <D.12357>; else goto <D.12358>;
    <D.12357>:
    wapi_thread_clear_wait_handle (handle);
    <D.12358>:
    D.12327 = res;
    return D.12327;
  }
}


timedwait_signal_poll_cond (union pthread_cond_t * cond, union mono_mutex_t * mutex, struct timespec * timeout, gboolean alertable)
{
  long int D.12372;
  long int D.12373;
  long int D.12376;
  long int D.12377;
  int D.12380;
  struct timespec fake_timeout;
  int ret;

  try
    {
      if (alertable == 0) goto <D.12362>; else goto <D.12363>;
      <D.12362>:
      if (timeout != 0B) goto <D.12364>; else goto <D.12365>;
      <D.12364>:
      ret = pthread_cond_timedwait (cond, mutex, timeout);
      goto <D.12366>;
      <D.12365>:
      ret = pthread_cond_wait (cond, mutex);
      <D.12366>:
      goto <D.12367>;
      <D.12363>:
      _wapi_calc_timeout (&fake_timeout, 100);
      if (timeout != 0B) goto <D.12371>; else goto <D.12368>;
      <D.12371>:
      D.12372 = fake_timeout.tv_sec;
      D.12373 = timeout->tv_sec;
      if (D.12372 > D.12373) goto <D.12369>; else goto <D.12374>;
      <D.12374>:
      D.12372 = fake_timeout.tv_sec;
      D.12373 = timeout->tv_sec;
      if (D.12372 == D.12373) goto <D.12375>; else goto <D.12368>;
      <D.12375>:
      D.12376 = fake_timeout.tv_nsec;
      D.12377 = timeout->tv_nsec;
      if (D.12376 > D.12377) goto <D.12369>; else goto <D.12368>;
      <D.12369>:
      ret = pthread_cond_timedwait (cond, mutex, timeout);
      goto <D.12370>;
      <D.12368>:
      ret = pthread_cond_timedwait (cond, mutex, &fake_timeout);
      if (ret == 145) goto <D.12378>; else goto <D.12379>;
      <D.12378>:
      ret = 0;
      <D.12379>:
      <D.12370>:
      <D.12367>:
      D.12380 = ret;
      return D.12380;
    }
  finally
    {
      fake_timeout = {CLOBBER};
    }
}


_wapi_free_share_info (struct _WapiFileShare * share_info)
{
  int D.12383;
  _Bool D.12388;
  long int D.12389;
  long int D.12390;
  struct GHashTable * file_share_hash.79;
  _Bool D.12396;
  long int D.12397;
  long int D.12398;

  D.12383 = _wapi_shm_enabled ();
  if (D.12383 == 0) goto <D.12384>; else goto <D.12385>;
  <D.12384>:
  {
    int ret;

    ret = pthread_mutex_lock (&file_share_hash_mutex.mutex);
    if (ret != 0) goto <D.12386>; else goto <D.12387>;
    <D.12386>:
    monoeg_g_log (0B, 16, "Bad call to mono_mutex_lock result %d", ret);
    <D.12387>:
    D.12388 = ret != 0;
    D.12389 = (long int) D.12388;
    D.12390 = __builtin_expect (D.12389, 0);
    if (D.12390 != 0) goto <D.12391>; else goto <D.12392>;
    <D.12391>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 1602, "ret == 0");
    <D.12392>:
  }
  file_share_hash.79 = file_share_hash;
  monoeg_g_hash_table_remove (file_share_hash.79, share_info);
  {
    int ret;

    ret = pthread_mutex_unlock (&file_share_hash_mutex.mutex);
    if (ret != 0) goto <D.12394>; else goto <D.12395>;
    <D.12394>:
    monoeg_g_log (0B, 16, "Bad call to mono_mutex_unlock result %d", ret);
    <D.12395>:
    D.12396 = ret != 0;
    D.12397 = (long int) D.12396;
    D.12398 = __builtin_expect (D.12397, 0);
    if (D.12398 != 0) goto <D.12399>; else goto <D.12400>;
    <D.12399>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 1604, "ret == 0");
    <D.12400>:
  }
  goto <D.12401>;
  <D.12385>:
  memset (share_info, 0, 40);
  <D.12401>:
}


_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.12402;
  _Bool D.12403;
  long int D.12404;
  long int D.12405;
  int D.12410;
  struct GHashTable * file_share_hash.80;
  struct GHashTable * file_share_hash.81;
  _Bool D.12419;
  long int D.12420;
  long int D.12421;
  unsigned int D.12426;
  unsigned int D.12427;
  guint32 * D.12428;
  int D.12430;
  _Bool D.12433;
  long int D.12434;
  long int D.12435;
  struct _WapiFileShareLayout * _wapi_fileshare_layout.82;
  unsigned int D.12442;
  long long unsigned int D.12447;
  long long unsigned int D.12450;
  unsigned int i.83;
  unsigned int D.12454;
  int D.12464;
  struct _WapiFileShare * D.12465;
  guint32 * D.12468;
  int now.84;
  gboolean D.12470;
  struct _WapiFileShare * file_share;
  guint32 now;
  int thr_ret;
  int i;
  int first_unused;
  gboolean exists;

  D.12402 = time (0B);
  now = (guint32) D.12402;
  first_unused = -1;
  exists = 0;
  thr_ret = _wapi_handle_lock_shared_handles ();
  D.12403 = thr_ret != 0;
  D.12404 = (long int) D.12403;
  D.12405 = __builtin_expect (D.12404, 0);
  if (D.12405 != 0) goto <D.12406>; else goto <D.12407>;
  <D.12406>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 1643, "thr_ret == 0");
  <D.12407>:
  thr_ret = _wapi_shm_sem_lock (2);
  D.12403 = thr_ret != 0;
  D.12404 = (long int) D.12403;
  D.12405 = __builtin_expect (D.12404, 0);
  if (D.12405 != 0) goto <D.12408>; else goto <D.12409>;
  <D.12408>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 1647, "thr_ret == 0");
  <D.12409>:
  D.12410 = _wapi_shm_enabled ();
  if (D.12410 == 0) goto <D.12411>; else goto <D.12412>;
  <D.12411>:
  {
    struct _WapiFileShare tmp;

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

          ret = pthread_mutex_lock (&file_share_hash_mutex.mutex);
          if (ret != 0) goto <D.12417>; else goto <D.12418>;
          <D.12417>:
          monoeg_g_log (0B, 16, "Bad call to mono_mutex_lock result %d", ret);
          <D.12418>:
          D.12419 = ret != 0;
          D.12420 = (long int) D.12419;
          D.12421 = __builtin_expect (D.12420, 0);
          if (D.12421 != 0) goto <D.12422>; else goto <D.12423>;
          <D.12422>:
          monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 1665, "ret == 0");
          <D.12423>:
        }
        file_share_hash.80 = file_share_hash;
        file_share = monoeg_g_hash_table_lookup (file_share_hash.80, &tmp);
        if (file_share != 0B) goto <D.12424>; else goto <D.12425>;
        <D.12424>:
        D.12426 = file_share->sharemode;
        *old_sharemode = D.12426;
        D.12427 = file_share->access;
        *old_access = D.12427;
        *share_info = file_share;
        D.12428 = &file_share->handle_refs;
        InterlockedIncrement (D.12428);
        exists = 1;
        goto <D.12429>;
        <D.12425>:
        file_share = monoeg_malloc0 (40);
        file_share->device = device;
        file_share->inode = inode;
        D.12430 = _wapi_getpid ();
        file_share->opened_by_pid = D.12430;
        file_share->sharemode = new_sharemode;
        file_share->access = new_access;
        file_share->handle_refs = 1;
        *share_info = file_share;
        file_share_hash.80 = file_share_hash;
        monoeg_g_hash_table_insert_replace (file_share_hash.80, file_share, file_share, 0);
        <D.12429>:
        {
          int ret;

          ret = pthread_mutex_unlock (&file_share_hash_mutex.mutex);
          if (ret != 0) goto <D.12431>; else goto <D.12432>;
          <D.12431>:
          monoeg_g_log (0B, 16, "Bad call to mono_mutex_unlock result %d", ret);
          <D.12432>:
          D.12433 = ret != 0;
          D.12434 = (long int) D.12433;
          D.12435 = __builtin_expect (D.12434, 0);
          if (D.12435 != 0) goto <D.12436>; else goto <D.12437>;
          <D.12436>:
          monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 1689, "ret == 0");
          <D.12437>:
        }
      }
    finally
      {
        tmp = {CLOBBER};
      }
  }
  goto <D.12438>;
  <D.12412>:
  *share_info = 0B;
  i = 0;
  goto <D.11223>;
  <D.11222>:
  _wapi_fileshare_layout.82 = _wapi_fileshare_layout;
  file_share = &_wapi_fileshare_layout.82->share_info[i];
  if (first_unused == -1) goto <D.12440>; else goto <D.12441>;
  <D.12440>:
  D.12442 = file_share->handle_refs;
  if (D.12442 == 0) goto <D.12443>; else goto <D.12444>;
  <D.12443>:
  first_unused = i;
  // predicted unlikely by continue predictor.
  goto <D.11220>;
  <D.12444>:
  <D.12441>:
  D.12442 = file_share->handle_refs;
  if (D.12442 == 0) goto <D.12445>; else goto <D.12446>;
  <D.12445>:
  // predicted unlikely by continue predictor.
  goto <D.11220>;
  <D.12446>:
  D.12447 = file_share->device;
  if (D.12447 == device) goto <D.12448>; else goto <D.12449>;
  <D.12448>:
  D.12450 = file_share->inode;
  if (D.12450 == inode) goto <D.12451>; else goto <D.12452>;
  <D.12451>:
  D.12426 = file_share->sharemode;
  *old_sharemode = D.12426;
  D.12427 = file_share->access;
  *old_access = D.12427;
  *share_info = file_share;
  D.12428 = &file_share->handle_refs;
  InterlockedIncrement (D.12428);
  exists = 1;
  goto <D.11221>;
  <D.12452>:
  <D.12449>:
  <D.11220>:
  i = i + 1;
  <D.11223>:
  i.83 = (unsigned int) i;
  _wapi_fileshare_layout.82 = _wapi_fileshare_layout;
  D.12454 = _wapi_fileshare_layout.82->hwm;
  if (i.83 <= D.12454) goto <D.11222>; else goto <D.11221>;
  <D.11221>:
  if (exists == 0) goto <D.12455>; else goto <D.12456>;
  <D.12455>:
  if (i == 102400) goto <D.12459>; else goto <D.12457>;
  <D.12459>:
  if (first_unused == -1) goto <D.12460>; else goto <D.12457>;
  <D.12460>:
  goto <D.12458>;
  <D.12457>:
  if (first_unused == -1) goto <D.12461>; else goto <D.12462>;
  <D.12461>:
  _wapi_fileshare_layout.82 = _wapi_fileshare_layout;
  i = i + 1;
  file_share = &_wapi_fileshare_layout.82->share_info[i];
  _wapi_fileshare_layout.82 = _wapi_fileshare_layout;
  i.83 = (unsigned int) i;
  _wapi_fileshare_layout.82->hwm = i.83;
  goto <D.12463>;
  <D.12462>:
  _wapi_fileshare_layout.82 = _wapi_fileshare_layout;
  file_share = &_wapi_fileshare_layout.82->share_info[first_unused];
  <D.12463>:
  file_share->device = device;
  file_share->inode = inode;
  D.12464 = _wapi_getpid ();
  file_share->opened_by_pid = D.12464;
  file_share->sharemode = new_sharemode;
  file_share->access = new_access;
  file_share->handle_refs = 1;
  *share_info = file_share;
  <D.12458>:
  <D.12456>:
  D.12465 = *share_info;
  if (D.12465 != 0B) goto <D.12466>; else goto <D.12467>;
  <D.12466>:
  D.12465 = *share_info;
  D.12468 = &D.12465->timestamp;
  now.84 = (int) now;
  InterlockedExchange (D.12468, now.84);
  <D.12467>:
  <D.12438>:
  thr_ret = _wapi_shm_sem_unlock (2);
  _wapi_handle_unlock_shared_handles ();
  D.12470 = exists;
  return D.12470;
}


wapi_share_info_equal (const void * ka, const void * kb)
{
  gint D.12472;
  int iftmp.85;
  long long unsigned int D.12476;
  long long unsigned int D.12477;
  long long unsigned int D.12479;
  long long unsigned int D.12480;
  const struct _WapiFileShare * s1;
  const struct _WapiFileShare * s2;

  s1 = ka;
  s2 = kb;
  D.12476 = s1->device;
  D.12477 = s2->device;
  if (D.12476 == D.12477) goto <D.12478>; else goto <D.12474>;
  <D.12478>:
  D.12479 = s1->inode;
  D.12480 = s2->inode;
  if (D.12479 == D.12480) goto <D.12481>; else goto <D.12474>;
  <D.12481>:
  iftmp.85 = 1;
  goto <D.12475>;
  <D.12474>:
  iftmp.85 = 0;
  <D.12475>:
  D.12472 = iftmp.85;
  return D.12472;
}


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

  s = data;
  D.12484 = s->inode;
  D.12483 = (guint) D.12484;
  return D.12483;
}


_wapi_handle_check_share (struct _WapiFileShare * share_info, int fd)
{
  _Bool D.12486;
  long int D.12487;
  long int D.12488;
  int D.12493;
  int D.12496;
  struct _WapiHandleUnshared * D.12497;
  int D.12500;
  unsigned int D.12501;
  unsigned int D.12502;
  <unnamed type> D.12505;
  struct _WapiFileShare * D.12508;
  unsigned int i.86;
  unsigned int _wapi_fd_reserve.87;
  struct _WapiHandleSharedLayout * _wapi_shared_layout.88;
  <unnamed type> D.12513;
  int D.11259;
  int iftmp.89;
  int D.11258;
  const char[2] * D.12523;
  unsigned char D.12524;
  int D.12525;
  unsigned char D.12526;
  int D.12527;
  const unsigned char * D.12532;
  unsigned char D.12533;
  int D.12534;
  const unsigned char * D.12535;
  unsigned char D.12536;
  int D.12537;
  const unsigned char * D.12542;
  unsigned char D.12543;
  int D.12544;
  const unsigned char * D.12545;
  unsigned char D.12546;
  int D.12547;
  const unsigned char * D.12552;
  unsigned char D.12553;
  int D.12554;
  const unsigned char * D.12555;
  unsigned char D.12556;
  int D.12557;
  char[256] * D.12559;
  int D.11268;
  int iftmp.90;
  int D.11267;
  const char[3] * D.12564;
  unsigned char D.12565;
  int D.12566;
  unsigned char D.12567;
  int D.12568;
  const unsigned char * D.12573;
  unsigned char D.12574;
  int D.12575;
  const unsigned char * D.12576;
  unsigned char D.12577;
  int D.12578;
  const unsigned char * D.12583;
  unsigned char D.12584;
  int D.12585;
  const unsigned char * D.12586;
  unsigned char D.12587;
  int D.12588;
  const unsigned char * D.12593;
  unsigned char D.12594;
  int D.12595;
  const unsigned char * D.12596;
  unsigned char D.12597;
  int D.12598;
  int D.12602;
  long unsigned int D.12603;
  long long unsigned int D.12604;
  long long unsigned int D.12605;
  long long unsigned int D.12608;
  long long unsigned int D.12609;
  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.12486 = thr_ret != 0;
  D.12487 = (long int) D.12486;
  D.12488 = __builtin_expect (D.12487, 0);
  if (D.12488 != 0) goto <D.12489>; else goto <D.12490>;
  <D.12489>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 1803, "thr_ret == 0");
  <D.12490>:
  thr_ret = _wapi_shm_sem_lock (2);
  D.12486 = thr_ret != 0;
  D.12487 = (long int) D.12486;
  D.12488 = __builtin_expect (D.12487, 0);
  if (D.12488 != 0) goto <D.12491>; else goto <D.12492>;
  <D.12491>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 1807, "thr_ret == 0");
  <D.12492>:
  D.12493 = access ("/proc", 0);
  if (D.12493 == -1) goto <D.12494>; else goto <D.12495>;
  <D.12494>:
  _wapi_handle_check_share_by_pid (share_info);
  goto done;
  <D.12495>:
  i = 0;
  goto <D.11241>;
  <D.11240>:
  D.12496 = i / 256;
  D.12497 = _wapi_private_handles[D.12496];
  if (D.12497 != 0B) goto <D.12498>; else goto <D.12499>;
  <D.12498>:
  {
    struct _WapiHandleUnshared * handle;

    D.12496 = i / 256;
    D.12497 = _wapi_private_handles[D.12496];
    D.12500 = i % 256;
    D.12501 = (unsigned int) D.12500;
    D.12502 = D.12501 * 144;
    handle = D.12497 + D.12502;
    if (i != fd) goto <D.12503>; else goto <D.12504>;
    <D.12503>:
    D.12505 = handle->type;
    if (D.12505 == 1) goto <D.12506>; else goto <D.12507>;
    <D.12506>:
    {
      struct _WapiHandle_file * file_handle;

      file_handle = &handle->u.file;
      D.12508 = file_handle->share_info;
      if (D.12508 == share_info) goto done; else goto <D.12509>;
      <D.12509>:
    }
    <D.12507>:
    <D.12504>:
  }
  <D.12499>:
  i = i + 1;
  <D.11241>:
  i.86 = (unsigned int) i;
  _wapi_fd_reserve.87 = _wapi_fd_reserve;
  if (i.86 < _wapi_fd_reserve.87) goto <D.11240>; else goto <D.11242>;
  <D.11242>:
  i = 0;
  goto <D.11273>;
  <D.11272>:
  {
    struct _WapiHandleShared * shared;
    struct _WapiHandle_process * process_handle;

    _wapi_shared_layout.88 = _wapi_shared_layout;
    shared = &_wapi_shared_layout.88->handles[i];
    D.12513 = shared->type;
    if (D.12513 == 9) goto <D.12514>; else goto <D.12515>;
    <D.12514>:
    {
      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.12516>; else goto <D.12517>;
          <D.12516>:
          // predicted unlikely by continue predictor.
          goto <D.11248>;
          <D.12517>:
          proc_fds = 1;
          goto <D.11269>;
          <D.11270>:
          {
            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.12521>; else goto <D.12522>;
                  <D.12521>:
                  {
                    const unsigned char * __s2;
                    int __result;

                    __s2 = &fd_entry->d_name;
                    D.12523 = ".";
                    D.12524 = MEM[(const unsigned char *)D.12523];
                    D.12525 = (int) D.12524;
                    D.12526 = *__s2;
                    D.12527 = (int) D.12526;
                    __result = D.12525 - D.12527;
                    {
                      if (__s2_len != 0) goto <D.12528>; else goto <D.12529>;
                      <D.12528>:
                      if (__result == 0) goto <D.12530>; else goto <D.12531>;
                      <D.12530>:
                      D.12532 = &MEM[(void *)"." + 1B];
                      D.12533 = *D.12532;
                      D.12534 = (int) D.12533;
                      D.12535 = __s2 + 1;
                      D.12536 = *D.12535;
                      D.12537 = (int) D.12536;
                      __result = D.12534 - D.12537;
                      if (__s2_len > 1) goto <D.12538>; else goto <D.12539>;
                      <D.12538>:
                      if (__result == 0) goto <D.12540>; else goto <D.12541>;
                      <D.12540>:
                      D.12542 = &MEM[(void *)"." + 2B];
                      D.12543 = *D.12542;
                      D.12544 = (int) D.12543;
                      D.12545 = __s2 + 2;
                      D.12546 = *D.12545;
                      D.12547 = (int) D.12546;
                      __result = D.12544 - D.12547;
                      if (__s2_len > 2) goto <D.12548>; else goto <D.12549>;
                      <D.12548>:
                      if (__result == 0) goto <D.12550>; else goto <D.12551>;
                      <D.12550>:
                      D.12552 = &MEM[(void *)"." + 3B];
                      D.12553 = *D.12552;
                      D.12554 = (int) D.12553;
                      D.12555 = __s2 + 3;
                      D.12556 = *D.12555;
                      D.12557 = (int) D.12556;
                      __result = D.12554 - D.12557;
                      <D.12551>:
                      <D.12549>:
                      <D.12541>:
                      <D.12539>:
                      <D.12531>:
                      <D.12529>:
                    }
                    D.11258 = __result;
                  }
                  iftmp.89 = -D.11258;
                  goto <D.12558>;
                  <D.12522>:
                  D.12559 = &fd_entry->d_name;
                  iftmp.89 = __builtin_strcmp (D.12559, ".");
                  <D.12558>:
                  D.11259 = iftmp.89;
                }
                if (D.11259 == 0) goto <D.12518>; else goto <D.12560>;
                <D.12560>:
                {
                  size_t __s1_len;
                  size_t __s2_len;

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

                    __s2 = &fd_entry->d_name;
                    D.12564 = "..";
                    D.12565 = MEM[(const unsigned char *)D.12564];
                    D.12566 = (int) D.12565;
                    D.12567 = *__s2;
                    D.12568 = (int) D.12567;
                    __result = D.12566 - D.12568;
                    {
                      if (__s2_len != 0) goto <D.12569>; else goto <D.12570>;
                      <D.12569>:
                      if (__result == 0) goto <D.12571>; else goto <D.12572>;
                      <D.12571>:
                      D.12573 = &MEM[(void *)".." + 1B];
                      D.12574 = *D.12573;
                      D.12575 = (int) D.12574;
                      D.12576 = __s2 + 1;
                      D.12577 = *D.12576;
                      D.12578 = (int) D.12577;
                      __result = D.12575 - D.12578;
                      if (__s2_len > 1) goto <D.12579>; else goto <D.12580>;
                      <D.12579>:
                      if (__result == 0) goto <D.12581>; else goto <D.12582>;
                      <D.12581>:
                      D.12583 = &MEM[(void *)".." + 2B];
                      D.12584 = *D.12583;
                      D.12585 = (int) D.12584;
                      D.12586 = __s2 + 2;
                      D.12587 = *D.12586;
                      D.12588 = (int) D.12587;
                      __result = D.12585 - D.12588;
                      if (__s2_len > 2) goto <D.12589>; else goto <D.12590>;
                      <D.12589>:
                      if (__result == 0) goto <D.12591>; else goto <D.12592>;
                      <D.12591>:
                      D.12593 = &MEM[(void *)".." + 3B];
                      D.12594 = *D.12593;
                      D.12595 = (int) D.12594;
                      D.12596 = __s2 + 3;
                      D.12597 = *D.12596;
                      D.12598 = (int) D.12597;
                      __result = D.12595 - D.12598;
                      <D.12592>:
                      <D.12590>:
                      <D.12582>:
                      <D.12580>:
                      <D.12572>:
                      <D.12570>:
                    }
                    D.11267 = __result;
                  }
                  iftmp.90 = -D.11267;
                  goto <D.12599>;
                  <D.12563>:
                  D.12559 = &fd_entry->d_name;
                  iftmp.90 = __builtin_strcmp (D.12559, "..");
                  <D.12599>:
                  D.11268 = iftmp.90;
                }
                if (D.11268 == 0) goto <D.12518>; else goto <D.12600>;
                <D.12600>:
                if (pid == self) goto <D.12601>; else goto <D.12519>;
                <D.12601>:
                D.12559 = &fd_entry->d_name;
                D.12602 = atoi (D.12559);
                if (D.12602 == fd) goto <D.12518>; else goto <D.12519>;
                <D.12518>:
                // predicted unlikely by continue predictor.
                goto <D.11269>;
                <D.12519>:
                D.12559 = &fd_entry->d_name;
                monoeg_g_snprintf (&path, 256, "/proc/%d/fd/%s", pid, D.12559);
                stat (&path, &link_stat);
                D.12603 = link_stat.st_dev;
                D.12604 = (long long unsigned int) D.12603;
                D.12605 = share_info->device;
                if (D.12604 == D.12605) goto <D.12606>; else goto <D.12607>;
                <D.12606>:
                D.12608 = link_stat.st_ino;
                D.12609 = share_info->inode;
                if (D.12608 == D.12609) goto <D.12610>; else goto <D.12611>;
                <D.12610>:
                found = 1;
                <D.12611>:
                <D.12607>:
              }
            finally
              {
                path = {CLOBBER};
                link_stat = {CLOBBER};
              }
          }
          <D.11269>:
          fd_entry = readdir (fd_dir);
          if (fd_entry != 0B) goto <D.11270>; else goto <D.11271>;
          <D.11271>:
          closedir (fd_dir);
        }
      finally
        {
          subdir = {CLOBBER};
        }
    }
    <D.12515>:
  }
  <D.11248>:
  i = i + 1;
  <D.11273>:
  if (i <= 255) goto <D.11272>; else goto <D.11274>;
  <D.11274>:
  if (proc_fds == 0) goto <D.12612>; else goto <D.12613>;
  <D.12612>:
  _wapi_handle_check_share_by_pid (share_info);
  goto <D.12614>;
  <D.12613>:
  if (found == 0) goto <D.12615>; else goto <D.12616>;
  <D.12615>:
  _wapi_free_share_info (share_info);
  <D.12616>:
  <D.12614>:
  done:
  thr_ret = _wapi_shm_sem_unlock (2);
  _wapi_handle_unlock_shared_handles ();
}


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

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


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

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


_wapi_handle_check_share_by_pid (struct _WapiFileShare * share_info)
{
  int D.12627;
  int D.12628;
  int * D.12631;
  int D.12632;

  D.12627 = share_info->opened_by_pid;
  D.12628 = kill (D.12627, 0);
  if (D.12628 == -1) goto <D.12629>; else goto <D.12630>;
  <D.12629>:
  D.12631 = __errno_location ();
  D.12632 = *D.12631;
  if (D.12632 == 3) goto <D.12625>; else goto <D.12633>;
  <D.12633>:
  D.12631 = __errno_location ();
  D.12632 = *D.12631;
  if (D.12632 == 1) goto <D.12625>; else goto <D.12626>;
  <D.12625>:
  _wapi_free_share_info (share_info);
  <D.12626>:
  <D.12630>:
}


_wapi_handle_dump ()
{
  long int D.12634;
  _Bool D.12637;
  long int D.12638;
  long int D.12639;
  struct _WapiHandleUnshared * D.12642;
  unsigned int D.12645;
  <unnamed type> D.12646;
  unsigned int D.12649;
  unsigned int D.12650;
  const char * D.12651;
  const char * iftmp.91;
  int D.12653;
  unsigned int D.12657;
  void (*<Tb30>) (void *) D.12658;
  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.12659;
  unsigned int _wapi_private_handle_slot_count.92;
  struct _WapiHandleUnshared * handle_data;
  guint32 i;
  guint32 k;
  int thr_ret;

  {
    struct __pthread_unwind_buf_t __cancel_buf;
    void (*<Tc3>) (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.12634 = __builtin_expect (__not_first_call, 0);
        if (D.12634 != 0) goto <D.12635>; else goto <D.12636>;
        <D.12635>:
        __cancel_routine (__cancel_arg);
        __pthread_unwind_next (&__cancel_buf);
        <D.12636>:
        __pthread_register_cancel (&__cancel_buf);
        thr_ret = pthread_mutex_lock (&scan_mutex);
        D.12637 = thr_ret != 0;
        D.12638 = (long int) D.12637;
        D.12639 = __builtin_expect (D.12638, 0);
        if (D.12639 != 0) goto <D.12640>; else goto <D.12641>;
        <D.12640>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 1943, "thr_ret == 0");
        <D.12641>:
        i = 0;
        goto <D.11293>;
        <D.11292>:
        D.12642 = _wapi_private_handles[i];
        if (D.12642 != 0B) goto <D.12643>; else goto <D.12644>;
        <D.12643>:
        k = 0;
        goto <D.11290>;
        <D.11289>:
        D.12642 = _wapi_private_handles[i];
        D.12645 = k * 144;
        handle_data = D.12642 + D.12645;
        D.12646 = handle_data->type;
        if (D.12646 == 0) goto <D.12647>; else goto <D.12648>;
        <D.12647>:
        // predicted unlikely by continue predictor.
        goto <D.11288>;
        <D.12648>:
        D.12649 = i * 256;
        D.12650 = D.12649 + k;
        D.12646 = handle_data->type;
        D.12651 = _wapi_handle_typename[D.12646];
        D.12653 = handle_data->signalled;
        if (D.12653 != 0) goto <D.12654>; else goto <D.12655>;
        <D.12654>:
        iftmp.91 = "Sg";
        goto <D.12656>;
        <D.12655>:
        iftmp.91 = "Un";
        <D.12656>:
        D.12657 = handle_data->ref;
        monoeg_g_print ("%3x [%7s] %s %d ", D.12650, D.12651, iftmp.91, D.12657);
        D.12646 = handle_data->type;
        D.12658 = handle_details[D.12646];
        D.12659 = &handle_data->u;
        D.12658 (D.12659);
        monoeg_g_print ("\n");
        <D.11288>:
        k = k + 1;
        <D.11290>:
        if (k <= 255) goto <D.11289>; else goto <D.11291>;
        <D.11291>:
        <D.12644>:
        i = i + 1;
        <D.11293>:
        _wapi_private_handle_slot_count.92 = _wapi_private_handle_slot_count;
        if (i < _wapi_private_handle_slot_count.92) goto <D.11292>; else goto <D.11294>;
        <D.11294>:
        thr_ret = pthread_mutex_unlock (&scan_mutex);
        D.12637 = thr_ret != 0;
        D.12638 = (long int) D.12637;
        D.12639 = __builtin_expect (D.12638, 0);
        if (D.12639 != 0) goto <D.12661>; else goto <D.12662>;
        <D.12661>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 1966, "thr_ret == 0");
        <D.12662>:
        __pthread_unregister_cancel (&__cancel_buf);
        if (0 != 0) goto <D.12663>; else goto <D.12664>;
        <D.12663>:
        __cancel_routine (__cancel_arg);
        <D.12664>:
      }
    finally
      {
        __cancel_buf = {CLOBBER};
      }
  }
}


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

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


_wapi_handle_update_refs ()
{
  long int D.12668;
  _Bool D.12669;
  long int D.12670;
  long int D.12671;
  long int D.12676;
  struct _WapiHandleUnshared * D.12679;
  unsigned int D.12682;
  <unnamed type> D.12686;
  struct _WapiHandleSharedLayout * _wapi_shared_layout.93;
  unsigned int D.12691;
  guint32 * D.12692;
  int now.94;
  struct _WapiFileShare * D.12696;
  _Bool D.12697;
  long int D.12698;
  long int D.12699;
  guint32 * D.12702;
  unsigned int _wapi_private_handle_slot_count.95;
  guint32 i;
  guint32 k;
  int thr_ret;
  guint32 now;

  D.12668 = time (0B);
  now = (guint32) D.12668;
  thr_ret = _wapi_handle_lock_shared_handles ();
  D.12669 = thr_ret != 0;
  D.12670 = (long int) D.12669;
  D.12671 = __builtin_expect (D.12670, 0);
  if (D.12671 != 0) goto <D.12672>; else goto <D.12673>;
  <D.12672>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 1984, "thr_ret == 0");
  <D.12673>:
  thr_ret = _wapi_shm_sem_lock (2);
  D.12669 = thr_ret != 0;
  D.12670 = (long int) D.12669;
  D.12671 = __builtin_expect (D.12670, 0);
  if (D.12671 != 0) goto <D.12674>; else goto <D.12675>;
  <D.12674>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 1988, "thr_ret == 0");
  <D.12675>:
  {
    struct __pthread_unwind_buf_t __cancel_buf;
    void (*<Tc3>) (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.12676 = __builtin_expect (__not_first_call, 0);
        if (D.12676 != 0) goto <D.12677>; else goto <D.12678>;
        <D.12677>:
        __cancel_routine (__cancel_arg);
        __pthread_unwind_next (&__cancel_buf);
        <D.12678>:
        __pthread_register_cancel (&__cancel_buf);
        thr_ret = pthread_mutex_lock (&scan_mutex);
        i = 0;
        goto <D.11319>;
        <D.11318>:
        D.12679 = _wapi_private_handles[i];
        if (D.12679 != 0B) goto <D.12680>; else goto <D.12681>;
        <D.12680>:
        k = 0;
        goto <D.11316>;
        <D.11315>:
        {
          struct _WapiHandleUnshared * handle;

          D.12679 = _wapi_private_handles[i];
          D.12682 = k * 144;
          handle = D.12679 + D.12682;
          D.12686 = handle->type;
          if (D.12686 == 9) goto <D.12683>; else goto <D.12687>;
          <D.12687>:
          D.12686 = handle->type;
          if (D.12686 == 11) goto <D.12683>; else goto <D.12688>;
          <D.12688>:
          D.12686 = handle->type;
          if (D.12686 == 12) goto <D.12683>; else goto <D.12689>;
          <D.12689>:
          D.12686 = handle->type;
          if (D.12686 == 13) goto <D.12683>; else goto <D.12684>;
          <D.12683>:
          {
            struct _WapiHandleShared * shared_data;

            _wapi_shared_layout.93 = _wapi_shared_layout;
            D.12691 = handle->u.shared.offset;
            shared_data = &_wapi_shared_layout.93->handles[D.12691];
            D.12692 = &shared_data->timestamp;
            now.94 = (int) now;
            InterlockedExchange (D.12692, now.94);
          }
          goto <D.12685>;
          <D.12684>:
          D.12686 = handle->type;
          if (D.12686 == 1) goto <D.12694>; else goto <D.12695>;
          <D.12694>:
          {
            struct _WapiHandle_file * file_handle;

            file_handle = &handle->u.file;
            D.12696 = file_handle->share_info;
            D.12697 = D.12696 == 0B;
            D.12698 = (long int) D.12697;
            D.12699 = __builtin_expect (D.12698, 0);
            if (D.12699 != 0) goto <D.12700>; else goto <D.12701>;
            <D.12700>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 2014, "file_handle->share_info != NULL");
            <D.12701>:
            D.12696 = file_handle->share_info;
            D.12702 = &D.12696->timestamp;
            now.94 = (int) now;
            InterlockedExchange (D.12702, now.94);
          }
          <D.12695>:
          <D.12685>:
        }
        k = k + 1;
        <D.11316>:
        if (k <= 255) goto <D.11315>; else goto <D.11317>;
        <D.11317>:
        <D.12681>:
        i = i + 1;
        <D.11319>:
        _wapi_private_handle_slot_count.95 = _wapi_private_handle_slot_count;
        if (i < _wapi_private_handle_slot_count.95) goto <D.11318>; else goto <D.11320>;
        <D.11320>:
        thr_ret = pthread_mutex_unlock (&scan_mutex);
        D.12669 = thr_ret != 0;
        D.12670 = (long int) D.12669;
        D.12671 = __builtin_expect (D.12670, 0);
        if (D.12671 != 0) goto <D.12704>; else goto <D.12705>;
        <D.12704>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 2025, "thr_ret == 0");
        <D.12705>:
        __pthread_unregister_cancel (&__cancel_buf);
        if (0 != 0) goto <D.12706>; else goto <D.12707>;
        <D.12706>:
        __cancel_routine (__cancel_arg);
        <D.12707>:
      }
    finally
      {
        __cancel_buf = {CLOBBER};
      }
  }
  thr_ret = _wapi_shm_sem_unlock (2);
  _wapi_handle_unlock_shared_handles ();
}


