_wapi_getpid ()
{
  pid_t D.11346;

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


pid_init ()
{
  int _wapi_pid.0;

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


wapi_init ()
{
  int D.11351;
  unsigned int _wapi_fd_reserve.1;
  unsigned int _wapi_fd_reserve.2;
  unsigned int D.11354;
  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.11362;
  long int D.11363;
  long int D.11364;
  int D.11367;
  void * _wapi_fileshare_layout.10;
  struct _WapiFileShareLayout * _wapi_fileshare_layout.11;
  _Bool D.11372;
  long int D.11373;
  long int D.11374;
  int D.11377;
  void * _wapi_global_signal_handle.12;
  void * _wapi_global_signal_handle.13;
  unsigned int _wapi_global_signal_handle.14;
  unsigned int D.11383;
  struct _WapiHandleUnshared * D.11384;
  unsigned int D.11385;
  unsigned int D.11386;
  struct _WapiHandleUnshared * D.11387;
  union pthread_cond_t * _wapi_global_signal_cond.15;
  union mono_mutex_t * _wapi_global_signal_mutex.16;

  if (0 != 0) goto <D.11349>; else goto <D.11350>;
  <D.11349>:
  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.11350>:
  D.11351 = getdtablesize ();
  _wapi_fd_reserve.1 = (unsigned int) D.11351;
  _wapi_fd_reserve = _wapi_fd_reserve.1;
  _wapi_fd_reserve.2 = _wapi_fd_reserve;
  D.11354 = _wapi_fd_reserve.2 + 255;
  _wapi_fd_reserve.3 = D.11354 & 4294967040;
  _wapi_fd_reserve = _wapi_fd_reserve.3;
  <D.10839>:
  _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.10839>; else goto <D.10840>;
  <D.10840>:
  _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.11362 = _wapi_shared_layout.9 == 0B;
  D.11363 = (long int) D.11362;
  D.11364 = __builtin_expect (D.11363, 0);
  if (D.11364 != 0) goto <D.11365>; else goto <D.11366>;
  <D.11365>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 271, "_wapi_shared_layout != NULL");
  <D.11366>:
  D.11367 = _wapi_shm_enabled ();
  if (D.11367 != 0) goto <D.11368>; else goto <D.11369>;
  <D.11368>:
  _wapi_fileshare_layout.10 = _wapi_shm_attach (1);
  _wapi_fileshare_layout = _wapi_fileshare_layout.10;
  _wapi_fileshare_layout.11 = _wapi_fileshare_layout;
  D.11372 = _wapi_fileshare_layout.11 == 0B;
  D.11373 = (long int) D.11372;
  D.11374 = __builtin_expect (D.11373, 0);
  if (D.11374 != 0) goto <D.11375>; else goto <D.11376>;
  <D.11375>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 276, "_wapi_fileshare_layout != NULL");
  <D.11376>:
  <D.11369>:
  D.11377 = _wapi_shm_enabled ();
  if (D.11377 != 0) goto <D.11378>; else goto <D.11379>;
  <D.11378>:
  _wapi_collection_init ();
  <D.11379>:
  _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.11383 = _wapi_global_signal_handle.14 / 256;
  D.11384 = _wapi_private_handles[D.11383];
  _wapi_global_signal_handle.13 = _wapi_global_signal_handle;
  _wapi_global_signal_handle.14 = (unsigned int) _wapi_global_signal_handle.13;
  D.11385 = _wapi_global_signal_handle.14 & 255;
  D.11386 = D.11385 * 136;
  D.11387 = D.11384 + D.11386;
  _wapi_global_signal_cond.15 = &D.11387->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.11383 = _wapi_global_signal_handle.14 / 256;
  D.11384 = _wapi_private_handles[D.11383];
  _wapi_global_signal_handle.13 = _wapi_global_signal_handle;
  _wapi_global_signal_handle.14 = (unsigned int) _wapi_global_signal_handle.13;
  D.11385 = _wapi_global_signal_handle.14 & 255;
  D.11386 = D.11385 * 136;
  D.11387 = D.11384 + D.11386;
  _wapi_global_signal_mutex.16 = &D.11387->signal_mutex;
  _wapi_global_signal_mutex = _wapi_global_signal_mutex.16;
  atexit (handle_cleanup);
}


handle_cleanup ()
{
  struct _WapiHandleUnshared * D.11390;
  unsigned int j.17;
  unsigned int D.11392;
  <unnamed type> D.11393;
  int D.11394;
  int D.11395;
  _Bool D.11398;
  _Bool D.11399;
  _Bool D.11400;
  unsigned int type.18;
  unsigned int D.11403;
  unsigned int D.11408;
  struct GHashTable * file_share_hash.19;
  int i;
  int j;
  int k;

  i = 0;
  goto <D.10831>;
  <D.10830>:
  j = 0;
  goto <D.10828>;
  <D.10827>:
  {
    struct _WapiHandleUnshared * handle_data;
    int type;
    void * handle;

    D.11390 = _wapi_private_handles[i];
    j.17 = (unsigned int) j;
    D.11392 = j.17 * 136;
    handle_data = D.11390 + D.11392;
    D.11393 = handle_data->type;
    type = (int) D.11393;
    D.11394 = i * 256;
    D.11395 = D.11394 + j;
    handle = (void *) D.11395;
    D.11398 = type == 9;
    D.11399 = type == 11;
    D.11400 = D.11398 | D.11399;
    if (D.11400 != 0) goto <D.11396>; else goto <D.11401>;
    <D.11401>:
    type.18 = (unsigned int) type;
    D.11403 = type.18 + 4294967284;
    if (D.11403 <= 1) goto <D.11396>; else goto <D.11397>;
    <D.11396>:
    if (type == 3) goto <D.11404>; else goto <D.11405>;
    <D.11404>:
    if (1 != 0) goto <D.11406>; else goto <D.11407>;
    <D.11406>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 211, "0");
    <D.11407>:
    _wapi_thread_set_termination_details (handle, 0);
    <D.11405>:
    <D.11397>:
    D.11408 = handle_data->ref;
    k = (int) D.11408;
    goto <D.10825>;
    <D.10824>:
    _wapi_handle_unref_full (handle, 1);
    k = k + -1;
    <D.10825>:
    if (k > 0) goto <D.10824>; else goto <D.10826>;
    <D.10826>:
  }
  j = j + 1;
  <D.10828>:
  if (j <= 255) goto <D.10827>; else goto <D.10829>;
  <D.10829>:
  i = i + 1;
  <D.10831>:
  D.11390 = _wapi_private_handles[i];
  if (D.11390 != 0B) goto <D.10830>; else goto <D.10832>;
  <D.10832>:
  _wapi_shm_semaphores_remove ();
  _wapi_shm_detach (0);
  _wapi_shm_detach (1);
  file_share_hash.19 = file_share_hash;
  if (file_share_hash.19 != 0B) goto <D.11410>; else goto <D.11411>;
  <D.11410>:
  file_share_hash.19 = file_share_hash;
  monoeg_g_hash_table_destroy (file_share_hash.19);
  DeleteCriticalSection (&file_share_hash_mutex);
  <D.11411>:
  i = 0;
  goto <D.10834>;
  <D.10833>:
  D.11390 = _wapi_private_handles[i];
  monoeg_g_free (D.11390);
  i = i + 1;
  <D.10834>:
  if (i <= 16383) goto <D.10833>; else goto <D.10835>;
  <D.10835>:
}


_wapi_handle_unref_full (void * handle, gboolean ignore_private_busy_handles)
{
  <unnamed type> D.11414;
  unsigned int D.11417;
  struct _WapiHandleUnshared * D.11418;
  unsigned int D.11419;
  unsigned int D.11420;
  struct _WapiHandleUnshared * D.11421;
  guint * D.11422;
  int D.11423;
  _Bool D.11424;
  int iftmp.20;
  _Bool D.11431;
  _Bool D.11432;
  _Bool D.11433;
  unsigned int D.11435;
  _Bool D.11438;
  long int D.11439;
  long int D.11440;
  long int D.11443;
  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.11446;
  union mono_mutex_t * D.11449;
  _Bool D.11450;
  _Bool D.11451;
  _Bool D.11452;
  union pthread_cond_t * D.11458;
  struct _WapiHandleSharedLayout * _wapi_shared_layout.21;
  unsigned int D.11466;
  unsigned int D.11467;
  unsigned int D.11470;
  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.11412>; else goto <D.11413>;
  <D.11412>:
  return;
  <D.11413>:
  D.11414 = _wapi_handle_type (handle);
  if (D.11414 == 0) goto <D.11415>; else goto <D.11416>;
  <D.11415>:
  monoeg_g_log (0B, 16, "%s: Attempting to unref unused handle %p", &__func__, handle);
  return;
  <D.11416>:
  D.11417 = idx / 256;
  D.11418 = _wapi_private_handles[D.11417];
  D.11419 = idx & 255;
  D.11420 = D.11419 * 136;
  D.11421 = D.11418 + D.11420;
  D.11422 = &D.11421->ref;
  D.11423 = InterlockedDecrement (D.11422);
  D.11424 = D.11423 == 0;
  destroy = (gboolean) D.11424;
  if (destroy == 1) goto <D.11425>; else goto <D.11426>;
  <D.11425>:
  {
    struct _WapiHandleUnshared handle_data;
    struct _WapiHandleShared shared_handle_data;
    WapiHandleType type;
    void (*<Tbba>) (void *, void *) close_func;
    gboolean is_shared;

    try
      {
        D.11417 = idx / 256;
        D.11418 = _wapi_private_handles[D.11417];
        D.11419 = idx & 255;
        D.11420 = D.11419 * 136;
        D.11421 = D.11418 + D.11420;
        type = D.11421->type;
        close_func = _wapi_handle_ops_get_close_func (type);
        D.11431 = type == 9;
        D.11432 = type == 11;
        D.11433 = D.11431 | D.11432;
        if (D.11433 != 0) goto <D.11428>; else goto <D.11434>;
        <D.11434>:
        D.11435 = type + 4294967284;
        if (D.11435 <= 1) goto <D.11428>; else goto <D.11429>;
        <D.11428>:
        iftmp.20 = 1;
        goto <D.11430>;
        <D.11429>:
        iftmp.20 = 0;
        <D.11430>:
        is_shared = iftmp.20;
        if (is_shared != 0) goto <D.11436>; else goto <D.11437>;
        <D.11436>:
        thr_ret = _wapi_handle_lock_shared_handles ();
        D.11438 = thr_ret != 0;
        D.11439 = (long int) D.11438;
        D.11440 = __builtin_expect (D.11439, 0);
        if (D.11440 != 0) goto <D.11441>; else goto <D.11442>;
        <D.11441>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 1080, "thr_ret == 0");
        <D.11442>:
        <D.11437>:
        {
          struct __pthread_unwind_buf_t __cancel_buf;
          void (*<Tbf>) (void *) __cancel_routine;
          void * __cancel_arg;
          int __not_first_call;

          try
            {
              __cancel_routine = mono_mutex_unlock_in_cleanup;
              __cancel_arg = &scan_mutex;
              __not_first_call = __sigsetjmp (&__cancel_buf.__cancel_jmp_buf, 0);
              D.11443 = __builtin_expect (__not_first_call, 0);
              if (D.11443 != 0) goto <D.11444>; else goto <D.11445>;
              <D.11444>:
              __cancel_routine (__cancel_arg);
              __pthread_unwind_next (&__cancel_buf);
              <D.11445>:
              __pthread_register_cancel (&__cancel_buf);
              thr_ret = pthread_mutex_lock (&scan_mutex);
              D.11417 = idx / 256;
              D.11418 = _wapi_private_handles[D.11417];
              D.11419 = idx & 255;
              D.11420 = D.11419 * 136;
              D.11421 = D.11418 + D.11420;
              memcpy (&handle_data, D.11421, 136);
              D.11417 = idx / 256;
              D.11418 = _wapi_private_handles[D.11417];
              D.11419 = idx & 255;
              D.11420 = D.11419 * 136;
              D.11421 = D.11418 + D.11420;
              D.11446 = &D.11421->u;
              memset (D.11446, 0, 52);
              D.11417 = idx / 256;
              D.11418 = _wapi_private_handles[D.11417];
              D.11419 = idx & 255;
              D.11420 = D.11419 * 136;
              D.11421 = D.11418 + D.11420;
              D.11421->type = 0;
              if (is_shared == 0) goto <D.11447>; else goto <D.11448>;
              <D.11447>:
              D.11417 = idx / 256;
              D.11418 = _wapi_private_handles[D.11417];
              D.11419 = idx & 255;
              D.11420 = D.11419 * 136;
              D.11421 = D.11418 + D.11420;
              D.11449 = &D.11421->signal_mutex;
              thr_ret = pthread_mutex_destroy (D.11449);
              D.11450 = thr_ret == 16;
              D.11451 = ignore_private_busy_handles != 0;
              D.11452 = D.11450 & D.11451;
              if (D.11452 != 0) goto <D.11453>; else goto <D.11454>;
              <D.11453>:
              early_exit = 1;
              goto <D.11455>;
              <D.11454>:
              if (thr_ret != 0) goto <D.11456>; else goto <D.11457>;
              <D.11456>:
              monoeg_g_log (0B, 4, "Error destroying handle %p mutex due to %d\n", handle, thr_ret);
              <D.11077>:
              goto <D.11077>;
              <D.11457>:
              D.11417 = idx / 256;
              D.11418 = _wapi_private_handles[D.11417];
              D.11419 = idx & 255;
              D.11420 = D.11419 * 136;
              D.11421 = D.11418 + D.11420;
              D.11458 = &D.11421->signal_cond;
              thr_ret = pthread_cond_destroy (D.11458);
              D.11450 = thr_ret == 16;
              D.11451 = ignore_private_busy_handles != 0;
              D.11452 = D.11450 & D.11451;
              if (D.11452 != 0) goto <D.11459>; else goto <D.11460>;
              <D.11459>:
              early_exit = 1;
              goto <D.11461>;
              <D.11460>:
              if (thr_ret != 0) goto <D.11462>; else goto <D.11463>;
              <D.11462>:
              monoeg_g_log (0B, 4, "Error destroying handle %p cond var due to %d\n", handle, thr_ret);
              <D.11078>:
              goto <D.11078>;
              <D.11463>:
              <D.11461>:
              <D.11455>:
              goto <D.11464>;
              <D.11448>:
              {
                struct _WapiHandleShared * shared;

                _wapi_shared_layout.21 = _wapi_shared_layout;
                D.11466 = handle_data.u.shared.offset;
                shared = &_wapi_shared_layout.21->handles[D.11466];
                memcpy (&shared_handle_data, shared, 320);
                D.11467 = shared->handle_refs;
                if (D.11467 != 0) goto <D.11468>; else goto <D.11469>;
                <D.11468>:
                D.11467 = shared->handle_refs;
                D.11470 = D.11467 + 4294967295;
                shared->handle_refs = D.11470;
                D.11467 = shared->handle_refs;
                if (D.11467 == 0) goto <D.11471>; else goto <D.11472>;
                <D.11471>:
                memset (shared, 0, 320);
                <D.11472>:
                <D.11469>:
              }
              <D.11464>:
              thr_ret = pthread_mutex_unlock (&scan_mutex);
              D.11438 = thr_ret != 0;
              D.11439 = (long int) D.11438;
              D.11440 = __builtin_expect (D.11439, 0);
              if (D.11440 != 0) goto <D.11473>; else goto <D.11474>;
              <D.11473>:
              monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 1138, "thr_ret == 0");
              <D.11474>:
              __pthread_unregister_cancel (&__cancel_buf);
              if (0 != 0) goto <D.11475>; else goto <D.11476>;
              <D.11475>:
              __cancel_routine (__cancel_arg);
              <D.11476>:
            }
          finally
            {
              __cancel_buf = {CLOBBER};
            }
        }
        if (early_exit != 0) goto <D.11477>; else goto <D.11478>;
        <D.11477>:
        return;
        <D.11478>:
        if (is_shared != 0) goto <D.11479>; else goto <D.11480>;
        <D.11479>:
        _wapi_handle_unlock_shared_handles ();
        <D.11480>:
        if (close_func != 0B) goto <D.11481>; else goto <D.11482>;
        <D.11481>:
        if (is_shared != 0) goto <D.11483>; else goto <D.11484>;
        <D.11483>:
        close_func (handle, &shared_handle_data.u);
        goto <D.11485>;
        <D.11484>:
        close_func (handle, &handle_data.u);
        <D.11485>:
        <D.11482>:
      }
    finally
      {
        handle_data = {CLOBBER};
        shared_handle_data = {CLOBBER};
      }
  }
  <D.11426>:
}


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

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


_wapi_handle_type (void * handle)
{
  unsigned int D.11500;
  struct _WapiHandleUnshared * D.11501;
  WapiHandleType D.11502;
  unsigned int D.11503;
  unsigned int D.11504;
  struct _WapiHandleUnshared * D.11505;
  guint32 idx;

  idx = (guint32) handle;
  if (idx > 4194303) goto <D.11497>; else goto <D.11499>;
  <D.11499>:
  D.11500 = idx / 256;
  D.11501 = _wapi_private_handles[D.11500];
  if (D.11501 == 0B) goto <D.11497>; else goto <D.11498>;
  <D.11497>:
  D.11502 = 0;
  return D.11502;
  <D.11498>:
  D.11500 = idx / 256;
  D.11501 = _wapi_private_handles[D.11500];
  D.11503 = idx & 255;
  D.11504 = D.11503 * 136;
  D.11505 = D.11501 + D.11504;
  D.11502 = D.11505->type;
  return D.11502;
}


InterlockedDecrement (volatile gint32 * val)
{
  gint32 D.11507;
  unsigned int D.11508;

  D.11508 = __sync_sub_and_fetch_4 (val, 1);
  D.11507 = (gint32) D.11508;
  return D.11507;
}


_wapi_handle_ops_get_close_func (WapiHandleType type)
{
  struct _WapiHandleOps * D.11510;
  void (*<Tbba>) (void *, void *) D.11513;
  void (*<Tbba>) (void *, void *) D.11516;

  D.11510 = handle_ops[type];
  if (D.11510 != 0B) goto <D.11511>; else goto <D.11512>;
  <D.11511>:
  D.11510 = handle_ops[type];
  D.11513 = D.11510->close;
  if (D.11513 != 0B) goto <D.11514>; else goto <D.11515>;
  <D.11514>:
  D.11510 = handle_ops[type];
  D.11516 = D.11510->close;
  return D.11516;
  <D.11515>:
  <D.11512>:
  D.11516 = 0B;
  return D.11516;
}


_wapi_handle_lock_shared_handles ()
{
  int D.11518;

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


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

  D.11521 = __builtin_object_size (__dest, 0);
  D.11520 = __builtin___memcpy_chk (__dest, __src, __len, D.11521);
  return D.11520;
}


memset (void * __dest, int __ch, size_t __len)
{
  int D.11525;
  int D.11530;
  void * D.11532;
  unsigned int D.11533;

  D.11525 = __builtin_constant_p (__len);
  if (D.11525 != 0) goto <D.11526>; else goto <D.11527>;
  <D.11526>:
  if (__len == 0) goto <D.11528>; else goto <D.11529>;
  <D.11528>:
  D.11530 = __builtin_constant_p (__ch);
  if (D.11530 == 0) goto <D.11523>; else goto <D.11531>;
  <D.11531>:
  if (__ch != 0) goto <D.11523>; else goto <D.11524>;
  <D.11523>:
  __warn_memset_zero_len ();
  D.11532 = __dest;
  return D.11532;
  <D.11524>:
  <D.11529>:
  <D.11527>:
  D.11533 = __builtin_object_size (__dest, 0);
  D.11532 = __builtin___memset_chk (__dest, __ch, __len, D.11533);
  return D.11532;
}


_wapi_handle_unlock_shared_handles ()
{
  int D.11535;

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


wapi_cleanup ()
{
  int _wapi_has_shut_down.22;
  _Bool D.11538;
  long int D.11539;
  long int D.11540;

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


_wapi_handle_new (WapiHandleType type, void * handle_specific)
{
  int _wapi_has_shut_down.23;
  _Bool D.11544;
  long int D.11545;
  long int D.11546;
  int iftmp.24;
  unsigned int D.11553;
  _Bool D.11554;
  _Bool D.11555;
  _Bool D.11556;
  _Bool D.11558;
  long int D.11559;
  long int D.11560;
  long int D.11563;
  _Bool D.11566;
  long int D.11567;
  long int D.11568;
  unsigned int _wapi_private_handle_count.25;
  unsigned int D.11572;
  void * D.11574;
  unsigned int _wapi_private_handle_count.26;
  unsigned int _wapi_private_handle_slot_count.27;
  unsigned int _wapi_private_handle_slot_count.28;
  unsigned int _wapi_fd_reserve.29;
  _Bool D.11585;
  long int D.11586;
  long int D.11587;
  _Bool D.11592;
  _Bool D.11593;
  _Bool D.11594;
  unsigned int D.11596;
  unsigned int D.11601;
  struct _WapiHandleUnshared * D.11602;
  unsigned int D.11603;
  unsigned int D.11604;
  struct _WapiHandleUnshared * D.11605;
  void * D.11606;
  guint32 handle_idx;
  void * handle;
  int thr_ret;
  void done = <<< error >>>;

  handle_idx = 0;
  _wapi_has_shut_down.23 = _wapi_has_shut_down;
  D.11544 = _wapi_has_shut_down.23 != 0;
  D.11545 = (long int) D.11544;
  D.11546 = __builtin_expect (D.11545, 0);
  if (D.11546 != 0) goto <D.11547>; else goto <D.11548>;
  <D.11547>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 466, "_wapi_has_shut_down == FALSE");
  <D.11548>:
  D.11553 = type + 4294967295;
  D.11554 = D.11553 <= 1;
  D.11555 = type == 7;
  D.11556 = D.11554 | D.11555;
  if (D.11556 != 0) goto <D.11550>; else goto <D.11557>;
  <D.11557>:
  if (type == 10) goto <D.11550>; else goto <D.11551>;
  <D.11550>:
  iftmp.24 = 1;
  goto <D.11552>;
  <D.11551>:
  iftmp.24 = 0;
  <D.11552>:
  D.11558 = iftmp.24 != 0;
  D.11559 = (long int) D.11558;
  D.11560 = __builtin_expect (D.11559, 0);
  if (D.11560 != 0) goto <D.11561>; else goto <D.11562>;
  <D.11561>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 471, "!_WAPI_FD_HANDLE(type)");
  <D.11562>:
  {
    struct __pthread_unwind_buf_t __cancel_buf;
    void (*<Tbf>) (void *) __cancel_routine;
    void * __cancel_arg;
    int __not_first_call;

    try
      {
        __cancel_routine = mono_mutex_unlock_in_cleanup;
        __cancel_arg = &scan_mutex;
        __not_first_call = __sigsetjmp (&__cancel_buf.__cancel_jmp_buf, 0);
        D.11563 = __builtin_expect (__not_first_call, 0);
        if (D.11563 != 0) goto <D.11564>; else goto <D.11565>;
        <D.11564>:
        __cancel_routine (__cancel_arg);
        __pthread_unwind_next (&__cancel_buf);
        <D.11565>:
        __pthread_register_cancel (&__cancel_buf);
        thr_ret = pthread_mutex_lock (&scan_mutex);
        D.11566 = thr_ret != 0;
        D.11567 = (long int) D.11566;
        D.11568 = __builtin_expect (D.11567, 0);
        if (D.11568 != 0) goto <D.11569>; else goto <D.11570>;
        <D.11569>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 476, "thr_ret == 0");
        <D.11570>:
        goto <D.10900>;
        <D.10899>:
        {
          int idx;

          _wapi_private_handle_count.25 = _wapi_private_handle_count;
          D.11572 = _wapi_private_handle_count.25 / 256;
          idx = (int) D.11572;
          if (idx > 16383) goto <D.10898>; else goto <D.11573>;
          <D.11573>:
          D.11574 = monoeg_malloc0 (34816);
          _wapi_private_handles[idx] = D.11574;
          _wapi_private_handle_count.25 = _wapi_private_handle_count;
          _wapi_private_handle_count.26 = _wapi_private_handle_count.25 + 256;
          _wapi_private_handle_count = _wapi_private_handle_count.26;
          _wapi_private_handle_slot_count.27 = _wapi_private_handle_slot_count;
          _wapi_private_handle_slot_count.28 = _wapi_private_handle_slot_count.27 + 1;
          _wapi_private_handle_slot_count = _wapi_private_handle_slot_count.28;
        }
        <D.10900>:
        handle_idx = _wapi_handle_new_internal (type, handle_specific);
        if (handle_idx == 0) goto <D.10899>; else goto <D.10898>;
        <D.10898>:
        thr_ret = pthread_mutex_unlock (&scan_mutex);
        D.11566 = thr_ret != 0;
        D.11567 = (long int) D.11566;
        D.11568 = __builtin_expect (D.11567, 0);
        if (D.11568 != 0) goto <D.11578>; else goto <D.11579>;
        <D.11578>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 493, "thr_ret == 0");
        <D.11579>:
        __pthread_unregister_cancel (&__cancel_buf);
        if (0 != 0) goto <D.11580>; else goto <D.11581>;
        <D.11580>:
        __cancel_routine (__cancel_arg);
        <D.11581>:
      }
    finally
      {
        __cancel_buf = {CLOBBER};
      }
  }
  if (handle_idx == 0) goto <D.11582>; else goto <D.11583>;
  <D.11582>:
  handle = 4294967295B;
  goto done;
  <D.11583>:
  _wapi_fd_reserve.29 = _wapi_fd_reserve;
  D.11585 = handle_idx < _wapi_fd_reserve.29;
  D.11586 = (long int) D.11585;
  D.11587 = __builtin_expect (D.11586, 0);
  if (D.11587 != 0) goto <D.11588>; else goto <D.11589>;
  <D.11588>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 503, "handle_idx >= _wapi_fd_reserve");
  <D.11589>:
  handle = (void *) handle_idx;
  D.11592 = type == 9;
  D.11593 = type == 11;
  D.11594 = D.11592 | D.11593;
  if (D.11594 != 0) goto <D.11590>; else goto <D.11595>;
  <D.11595>:
  D.11596 = type + 4294967284;
  if (D.11596 <= 1) goto <D.11590>; else goto <D.11591>;
  <D.11590>:
  {
    guint32 ref;

    ref = _wapi_handle_new_shared (type, handle_specific);
    if (ref == 0) goto <D.11597>; else goto <D.11598>;
    <D.11597>:
    _wapi_handle_collect ();
    ref = _wapi_handle_new_shared (type, handle_specific);
    if (ref == 0) goto <D.11599>; else goto <D.11600>;
    <D.11599>:
    handle = 4294967295B;
    goto done;
    <D.11600>:
    <D.11598>:
    D.11601 = handle_idx / 256;
    D.11602 = _wapi_private_handles[D.11601];
    D.11603 = handle_idx & 255;
    D.11604 = D.11603 * 136;
    D.11605 = D.11602 + D.11604;
    D.11605->u.shared.offset = ref;
  }
  <D.11591>:
  done:
  D.11606 = handle;
  return D.11606;
}


_wapi_handle_new_internal (WapiHandleType type, void * handle_specific)
{
  int _wapi_has_shut_down.30;
  _Bool D.11615;
  long int D.11616;
  long int D.11617;
  unsigned int last.31;
  unsigned int _wapi_fd_reserve.32;
  struct _WapiHandleUnshared * D.11625;
  unsigned int D.11628;
  <unnamed type> D.11629;
  unsigned int last.33;
  guint32 D.11633;
  unsigned int _wapi_private_handle_slot_count.34;
  guint32 i;
  guint32 k;
  guint32 count;
  static guint32 last = 0;
  gboolean retry;
  void again = <<< error >>>;

  retry = 0;
  _wapi_has_shut_down.30 = _wapi_has_shut_down;
  D.11615 = _wapi_has_shut_down.30 != 0;
  D.11616 = (long int) D.11615;
  D.11617 = __builtin_expect (D.11616, 0);
  if (D.11617 != 0) goto <D.11618>; else goto <D.11619>;
  <D.11618>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 416, "_wapi_has_shut_down == FALSE");
  <D.11619>:
  last.31 = last;
  _wapi_fd_reserve.32 = _wapi_fd_reserve;
  if (last.31 < _wapi_fd_reserve.32) goto <D.11622>; else goto <D.11623>;
  <D.11622>:
  _wapi_fd_reserve.32 = _wapi_fd_reserve;
  last = _wapi_fd_reserve.32;
  goto <D.11624>;
  <D.11623>:
  retry = 1;
  <D.11624>:
  again:
  count = last;
  i = count / 256;
  goto <D.10882>;
  <D.10881>:
  D.11625 = _wapi_private_handles[i];
  if (D.11625 != 0B) goto <D.11626>; else goto <D.11627>;
  <D.11626>:
  k = count & 255;
  goto <D.10879>;
  <D.10878>:
  {
    struct _WapiHandleUnshared * handle;

    D.11625 = _wapi_private_handles[i];
    D.11628 = k * 136;
    handle = D.11625 + D.11628;
    D.11629 = handle->type;
    if (D.11629 == 0) goto <D.11630>; else goto <D.11631>;
    <D.11630>:
    last.33 = count + 1;
    last = last.33;
    _wapi_handle_init (handle, type, handle_specific);
    D.11633 = count;
    return D.11633;
    <D.11631>:
    count = count + 1;
  }
  k = k + 1;
  <D.10879>:
  if (k <= 255) goto <D.10878>; else goto <D.10880>;
  <D.10880>:
  <D.11627>:
  i = i + 1;
  <D.10882>:
  _wapi_private_handle_slot_count.34 = _wapi_private_handle_slot_count;
  if (i < _wapi_private_handle_slot_count.34) goto <D.10881>; else goto <D.10883>;
  <D.10883>:
  if (retry != 0) goto <D.11635>; else goto <D.11636>;
  <D.11635>:
  last.31 = last;
  _wapi_fd_reserve.32 = _wapi_fd_reserve;
  if (last.31 > _wapi_fd_reserve.32) goto <D.11637>; else goto <D.11638>;
  <D.11637>:
  _wapi_fd_reserve.32 = _wapi_fd_reserve;
  last = _wapi_fd_reserve.32;
  goto again;
  <D.11638>:
  <D.11636>:
  D.11633 = 0;
  return D.11633;
}


_wapi_handle_init (struct _WapiHandleUnshared * handle, WapiHandleType type, void * handle_specific)
{
  int _wapi_has_shut_down.35;
  _Bool D.11641;
  long int D.11642;
  long int D.11643;
  _Bool D.11646;
  _Bool D.11647;
  _Bool D.11648;
  unsigned int D.11651;
  union pthread_cond_t * D.11654;
  _Bool D.11655;
  long int D.11656;
  long int D.11657;
  union mono_mutex_t * D.11660;
  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.11665;
  int thr_ret;

  _wapi_has_shut_down.35 = _wapi_has_shut_down;
  D.11641 = _wapi_has_shut_down.35 != 0;
  D.11642 = (long int) D.11641;
  D.11643 = __builtin_expect (D.11642, 0);
  if (D.11643 != 0) goto <D.11644>; else goto <D.11645>;
  <D.11644>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 332, "_wapi_has_shut_down == FALSE");
  <D.11645>:
  handle->type = type;
  handle->signalled = 0;
  handle->ref = 1;
  D.11646 = type != 9;
  D.11647 = type != 11;
  D.11648 = D.11646 & D.11647;
  if (D.11648 != 0) goto <D.11649>; else goto <D.11650>;
  <D.11649>:
  D.11651 = type + 4294967284;
  if (D.11651 > 1) goto <D.11652>; else goto <D.11653>;
  <D.11652>:
  D.11654 = &handle->signal_cond;
  thr_ret = pthread_cond_init (D.11654, 0B);
  D.11655 = thr_ret != 0;
  D.11656 = (long int) D.11655;
  D.11657 = __builtin_expect (D.11656, 0);
  if (D.11657 != 0) goto <D.11658>; else goto <D.11659>;
  <D.11658>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 340, "thr_ret == 0");
  <D.11659>:
  D.11660 = &handle->signal_mutex;
  thr_ret = pthread_mutex_init (D.11660, 0B);
  D.11655 = thr_ret != 0;
  D.11656 = (long int) D.11655;
  D.11657 = __builtin_expect (D.11656, 0);
  if (D.11657 != 0) goto <D.11661>; else goto <D.11662>;
  <D.11661>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 343, "thr_ret == 0");
  <D.11662>:
  if (handle_specific != 0B) goto <D.11663>; else goto <D.11664>;
  <D.11663>:
  D.11665 = &handle->u;
  memcpy (D.11665, handle_specific, 52);
  <D.11664>:
  <D.11653>:
  <D.11650>:
}


_wapi_handle_new_shared (WapiHandleType type, void * handle_specific)
{
  int _wapi_has_shut_down.36;
  _Bool D.11667;
  long int D.11668;
  long int D.11669;
  struct _WapiHandleSharedLayout * _wapi_shared_layout.37;
  <unnamed type> D.11673;
  _Bool D.11676;
  long int D.11677;
  long int D.11678;
  int type.38;
  WapiHandleType * D.11682;
  int D.11683;
  unsigned int last.39;
  guint32 D.11687;
  unsigned int last.40;
  guint32 offset;
  static guint32 last = 1;
  int thr_ret;
  void again = <<< error >>>;

  _wapi_has_shut_down.36 = _wapi_has_shut_down;
  D.11667 = _wapi_has_shut_down.36 != 0;
  D.11668 = (long int) D.11667;
  D.11669 = __builtin_expect (D.11668, 0);
  if (D.11669 != 0) goto <D.11670>; else goto <D.11671>;
  <D.11670>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 359, "_wapi_has_shut_down == FALSE");
  <D.11671>:
  again:
  offset = last;
  goto <D.10865>;
  <D.10864>:
  {
    struct _WapiHandleShared * handle;

    _wapi_shared_layout.37 = _wapi_shared_layout;
    handle = &_wapi_shared_layout.37->handles[offset];
    D.11673 = handle->type;
    if (D.11673 == 0) goto <D.11674>; else goto <D.11675>;
    <D.11674>:
    thr_ret = _wapi_handle_lock_shared_handles ();
    D.11676 = thr_ret != 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", 369, "thr_ret == 0");
    <D.11680>:
    type.38 = (int) type;
    D.11682 = &handle->type;
    D.11683 = InterlockedCompareExchange (D.11682, type.38, 0);
    if (D.11683 == 0) goto <D.11684>; else goto <D.11685>;
    <D.11684>:
    last.39 = offset + 1;
    last = last.39;
    _wapi_handle_init_shared (handle, type, handle_specific);
    _wapi_handle_unlock_shared_handles ();
    D.11687 = offset;
    return D.11687;
    <D.11685>:
    _wapi_handle_unlock_shared_handles ();
    <D.11675>:
  }
  offset = offset + 1;
  <D.10865>:
  if (offset <= 255) goto <D.10864>; else goto <D.10866>;
  <D.10866>:
  last.40 = last;
  if (last.40 > 1) goto <D.11689>; else goto <D.11690>;
  <D.11689>:
  last = 1;
  goto again;
  <D.11690>:
  D.11687 = 0;
  return D.11687;
}


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

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


_wapi_handle_init_shared (struct _WapiHandleShared * handle, WapiHandleType type, void * handle_specific)
{
  int _wapi_has_shut_down.43;
  _Bool D.11698;
  long int D.11699;
  long int D.11700;
  long int D.11703;
  unsigned int D.11704;
  union 
{
  struct _WapiHandle_process process;
  struct _WapiHandle_namedmutex namedmutex;
  struct _WapiHandle_namedsem namedsem;
  struct _WapiHandle_namedevent namedevent;
} * D.11707;

  _wapi_has_shut_down.43 = _wapi_has_shut_down;
  D.11698 = _wapi_has_shut_down.43 != 0;
  D.11699 = (long int) D.11698;
  D.11700 = __builtin_expect (D.11699, 0);
  if (D.11700 != 0) goto <D.11701>; else goto <D.11702>;
  <D.11701>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 315, "_wapi_has_shut_down == FALSE");
  <D.11702>:
  handle->type = type;
  D.11703 = time (0B);
  D.11704 = (unsigned int) D.11703;
  handle->timestamp = D.11704;
  handle->signalled = 0;
  handle->handle_refs = 1;
  if (handle_specific != 0B) goto <D.11705>; else goto <D.11706>;
  <D.11705>:
  D.11707 = &handle->u;
  memcpy (D.11707, handle_specific, 304);
  <D.11706>:
}


_wapi_handle_new_from_offset (WapiHandleType type, guint32 offset, gboolean timestamp)
{
  int _wapi_has_shut_down.44;
  _Bool D.11709;
  long int D.11710;
  long int D.11711;
  int iftmp.45;
  unsigned int D.11718;
  _Bool D.11719;
  _Bool D.11720;
  _Bool D.11721;
  _Bool D.11723;
  long int D.11724;
  long int D.11725;
  int iftmp.46;
  _Bool D.11731;
  _Bool D.11732;
  _Bool D.11733;
  unsigned int D.11735;
  _Bool D.11737;
  long int D.11738;
  long int D.11739;
  _Bool D.11742;
  long int D.11743;
  long int D.11744;
  struct _WapiHandleSharedLayout * _wapi_shared_layout.47;
  long int D.11750;
  int now.48;
  guint32 * D.11752;
  long int D.11753;
  _Bool D.11756;
  long int D.11757;
  long int D.11758;
  struct _WapiHandleUnshared * D.11761;
  unsigned int k.49;
  unsigned int D.11765;
  <unnamed type> D.11766;
  unsigned int D.11769;
  int D.11772;
  int D.11773;
  unsigned int i.50;
  unsigned int _wapi_private_handle_slot_count.51;
  void * D.11782;
  <unnamed type> D.11785;
  long int D.11788;
  unsigned int _wapi_private_handle_count.52;
  unsigned int D.11794;
  void * D.11795;
  unsigned int _wapi_private_handle_count.53;
  unsigned int _wapi_private_handle_slot_count.54;
  unsigned int _wapi_fd_reserve.55;
  _Bool D.11803;
  long int D.11804;
  long int D.11805;
  unsigned int D.11808;
  struct _WapiHandleUnshared * D.11809;
  unsigned int D.11810;
  unsigned int D.11811;
  struct _WapiHandleUnshared * D.11812;
  guint32 * D.11813;
  guint32 handle_idx;
  void * handle;
  int thr_ret;
  int i;
  int k;
  struct _WapiHandleShared * shared;
  void first_pass_done = <<< error >>>;
  void done = <<< error >>>;

  handle_idx = 0;
  handle = 4294967295B;
  _wapi_has_shut_down.44 = _wapi_has_shut_down;
  D.11709 = _wapi_has_shut_down.44 != 0;
  D.11710 = (long int) D.11709;
  D.11711 = __builtin_expect (D.11710, 0);
  if (D.11711 != 0) goto <D.11712>; else goto <D.11713>;
  <D.11712>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 541, "_wapi_has_shut_down == FALSE");
  <D.11713>:
  D.11718 = type + 4294967295;
  D.11719 = D.11718 <= 1;
  D.11720 = type == 7;
  D.11721 = D.11719 | D.11720;
  if (D.11721 != 0) goto <D.11715>; else goto <D.11722>;
  <D.11722>:
  if (type == 10) goto <D.11715>; else goto <D.11716>;
  <D.11715>:
  iftmp.45 = 1;
  goto <D.11717>;
  <D.11716>:
  iftmp.45 = 0;
  <D.11717>:
  D.11723 = iftmp.45 != 0;
  D.11724 = (long int) D.11723;
  D.11725 = __builtin_expect (D.11724, 0);
  if (D.11725 != 0) goto <D.11726>; else goto <D.11727>;
  <D.11726>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 546, "!_WAPI_FD_HANDLE(type)");
  <D.11727>:
  D.11731 = type != 9;
  D.11732 = type != 11;
  D.11733 = D.11731 & D.11732;
  if (D.11733 != 0) goto <D.11734>; else goto <D.11729>;
  <D.11734>:
  D.11735 = type + 4294967284;
  if (D.11735 > 1) goto <D.11736>; else goto <D.11729>;
  <D.11736>:
  iftmp.46 = 1;
  goto <D.11730>;
  <D.11729>:
  iftmp.46 = 0;
  <D.11730>:
  D.11737 = iftmp.46 != 0;
  D.11738 = (long int) D.11737;
  D.11739 = __builtin_expect (D.11738, 0);
  if (D.11739 != 0) goto <D.11740>; else goto <D.11741>;
  <D.11740>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 547, "_WAPI_SHARED_HANDLE(type)");
  <D.11741>:
  D.11742 = offset == 0;
  D.11743 = (long int) D.11742;
  D.11744 = __builtin_expect (D.11743, 0);
  if (D.11744 != 0) goto <D.11745>; else goto <D.11746>;
  <D.11745>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 548, "offset != 0");
  <D.11746>:
  _wapi_shared_layout.47 = _wapi_shared_layout;
  shared = &_wapi_shared_layout.47->handles[offset];
  if (timestamp != 0) goto <D.11748>; else goto <D.11749>;
  <D.11748>:
  {
    guint32 now;

    D.11750 = time (0B);
    now = (guint32) D.11750;
    now.48 = (int) now;
    D.11752 = &shared->timestamp;
    InterlockedExchange (D.11752, now.48);
  }
  <D.11749>:
  {
    struct __pthread_unwind_buf_t __cancel_buf;
    void (*<Tbf>) (void *) __cancel_routine;
    void * __cancel_arg;
    int __not_first_call;

    try
      {
        __cancel_routine = mono_mutex_unlock_in_cleanup;
        __cancel_arg = &scan_mutex;
        __not_first_call = __sigsetjmp (&__cancel_buf.__cancel_jmp_buf, 0);
        D.11753 = __builtin_expect (__not_first_call, 0);
        if (D.11753 != 0) goto <D.11754>; else goto <D.11755>;
        <D.11754>:
        __cancel_routine (__cancel_arg);
        __pthread_unwind_next (&__cancel_buf);
        <D.11755>:
        __pthread_register_cancel (&__cancel_buf);
        thr_ret = pthread_mutex_lock (&scan_mutex);
        D.11756 = thr_ret != 0;
        D.11757 = (long int) D.11756;
        D.11758 = __builtin_expect (D.11757, 0);
        if (D.11758 != 0) goto <D.11759>; else goto <D.11760>;
        <D.11759>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 560, "thr_ret == 0");
        <D.11760>:
        i = 0;
        goto <D.10927>;
        <D.10926>:
        D.11761 = _wapi_private_handles[i];
        if (D.11761 != 0B) goto <D.11762>; else goto <D.11763>;
        <D.11762>:
        k = 0;
        goto <D.10924>;
        <D.10923>:
        {
          struct _WapiHandleUnshared * handle_data;

          D.11761 = _wapi_private_handles[i];
          k.49 = (unsigned int) k;
          D.11765 = k.49 * 136;
          handle_data = D.11761 + D.11765;
          D.11766 = handle_data->type;
          if (D.11766 == type) goto <D.11767>; else goto <D.11768>;
          <D.11767>:
          D.11769 = handle_data->u.shared.offset;
          if (D.11769 == offset) goto <D.11770>; else goto <D.11771>;
          <D.11770>:
          D.11772 = i * 256;
          D.11773 = D.11772 + k;
          handle = (void *) D.11773;
          goto first_pass_done;
          <D.11771>:
          <D.11768>:
        }
        k = k + 1;
        <D.10924>:
        if (k <= 255) goto <D.10923>; else goto <D.10925>;
        <D.10925>:
        <D.11763>:
        i = i + 1;
        <D.10927>:
        i.50 = (unsigned int) i;
        _wapi_private_handle_slot_count.51 = _wapi_private_handle_slot_count;
        if (i.50 < _wapi_private_handle_slot_count.51) goto <D.10926>; else goto <D.10928>;
        <D.10928>:
        first_pass_done:
        thr_ret = pthread_mutex_unlock (&scan_mutex);
        D.11756 = thr_ret != 0;
        D.11757 = (long int) D.11756;
        D.11758 = __builtin_expect (D.11757, 0);
        if (D.11758 != 0) goto <D.11776>; else goto <D.11777>;
        <D.11776>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 578, "thr_ret == 0");
        <D.11777>:
        __pthread_unregister_cancel (&__cancel_buf);
        if (0 != 0) goto <D.11778>; else goto <D.11779>;
        <D.11778>:
        __cancel_routine (__cancel_arg);
        <D.11779>:
      }
    finally
      {
        __cancel_buf = {CLOBBER};
      }
  }
  if (handle != 4294967295B) goto <D.11780>; else goto <D.11781>;
  <D.11780>:
  _wapi_handle_ref (handle);
  D.11782 = handle;
  return D.11782;
  <D.11781>:
  thr_ret = _wapi_handle_lock_shared_handles ();
  D.11756 = thr_ret != 0;
  D.11757 = (long int) D.11756;
  D.11758 = __builtin_expect (D.11757, 0);
  if (D.11758 != 0) goto <D.11783>; else goto <D.11784>;
  <D.11783>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 591, "thr_ret == 0");
  <D.11784>:
  D.11785 = shared->type;
  if (D.11785 == 0) goto done; else goto <D.11786>;
  <D.11786>:
  D.11785 = shared->type;
  if (D.11785 != type) goto done; else goto <D.11787>;
  <D.11787>:
  {
    struct __pthread_unwind_buf_t __cancel_buf;
    void (*<Tbf>) (void *) __cancel_routine;
    void * __cancel_arg;
    int __not_first_call;

    try
      {
        __cancel_routine = mono_mutex_unlock_in_cleanup;
        __cancel_arg = &scan_mutex;
        __not_first_call = __sigsetjmp (&__cancel_buf.__cancel_jmp_buf, 0);
        D.11788 = __builtin_expect (__not_first_call, 0);
        if (D.11788 != 0) goto <D.11789>; else goto <D.11790>;
        <D.11789>:
        __cancel_routine (__cancel_arg);
        __pthread_unwind_next (&__cancel_buf);
        <D.11790>:
        __pthread_register_cancel (&__cancel_buf);
        thr_ret = pthread_mutex_lock (&scan_mutex);
        D.11756 = thr_ret != 0;
        D.11757 = (long int) D.11756;
        D.11758 = __builtin_expect (D.11757, 0);
        if (D.11758 != 0) goto <D.11791>; else goto <D.11792>;
        <D.11791>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 610, "thr_ret == 0");
        <D.11792>:
        goto <D.10938>;
        <D.10937>:
        {
          int idx;

          _wapi_private_handle_count.52 = _wapi_private_handle_count;
          D.11794 = _wapi_private_handle_count.52 / 256;
          idx = (int) D.11794;
          D.11795 = monoeg_malloc0 (34816);
          _wapi_private_handles[idx] = D.11795;
          _wapi_private_handle_count.52 = _wapi_private_handle_count;
          _wapi_private_handle_count.53 = _wapi_private_handle_count.52 + 256;
          _wapi_private_handle_count = _wapi_private_handle_count.53;
          _wapi_private_handle_slot_count.51 = _wapi_private_handle_slot_count;
          _wapi_private_handle_slot_count.54 = _wapi_private_handle_slot_count.51 + 1;
          _wapi_private_handle_slot_count = _wapi_private_handle_slot_count.54;
        }
        <D.10938>:
        handle_idx = _wapi_handle_new_internal (type, 0B);
        if (handle_idx == 0) goto <D.10937>; else goto <D.10939>;
        <D.10939>:
        thr_ret = pthread_mutex_unlock (&scan_mutex);
        D.11756 = thr_ret != 0;
        D.11757 = (long int) D.11756;
        D.11758 = __builtin_expect (D.11757, 0);
        if (D.11758 != 0) goto <D.11798>; else goto <D.11799>;
        <D.11798>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 623, "thr_ret == 0");
        <D.11799>:
        __pthread_unregister_cancel (&__cancel_buf);
        if (0 != 0) goto <D.11800>; else goto <D.11801>;
        <D.11800>:
        __cancel_routine (__cancel_arg);
        <D.11801>:
      }
    finally
      {
        __cancel_buf = {CLOBBER};
      }
  }
  _wapi_fd_reserve.55 = _wapi_fd_reserve;
  D.11803 = handle_idx < _wapi_fd_reserve.55;
  D.11804 = (long int) D.11803;
  D.11805 = __builtin_expect (D.11804, 0);
  if (D.11805 != 0) goto <D.11806>; else goto <D.11807>;
  <D.11806>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 627, "handle_idx >= _wapi_fd_reserve");
  <D.11807>:
  handle = (void *) handle_idx;
  D.11808 = handle_idx / 256;
  D.11809 = _wapi_private_handles[D.11808];
  D.11810 = handle_idx & 255;
  D.11811 = D.11810 * 136;
  D.11812 = D.11809 + D.11811;
  D.11812->u.shared.offset = offset;
  D.11813 = &shared->handle_refs;
  InterlockedIncrement (D.11813);
  done:
  _wapi_handle_unlock_shared_handles ();
  D.11782 = handle;
  return D.11782;
}


InterlockedExchange (volatile gint32 * val, gint32 new_val)
{
  unsigned int new_val.56;
  unsigned int old_val.57;
  unsigned int D.11824;
  int D.11825;
  gint32 D.11826;
  gint32 old_val;

  <D.10515>:
  old_val = *val;
  new_val.56 = (unsigned int) new_val;
  old_val.57 = (unsigned int) old_val;
  D.11824 = __sync_val_compare_and_swap_4 (val, old_val.57, new_val.56);
  D.11825 = (int) D.11824;
  if (D.11825 != old_val) goto <D.10515>; else goto <D.10516>;
  <D.10516>:
  D.11826 = old_val;
  return D.11826;
}


InterlockedIncrement (volatile gint32 * val)
{
  gint32 D.11828;
  unsigned int D.11829;

  D.11829 = __sync_add_and_fetch_4 (val, 1);
  D.11828 = (gint32) D.11829;
  return D.11828;
}


_wapi_handle_new_fd (WapiHandleType type, int fd, void * handle_specific)
{
  int _wapi_has_shut_down.58;
  _Bool D.11832;
  long int D.11833;
  long int D.11834;
  int iftmp.59;
  unsigned int D.11840;
  _Bool D.11841;
  _Bool D.11842;
  _Bool D.11843;
  _Bool D.11846;
  long int D.11847;
  long int D.11848;
  int iftmp.60;
  _Bool D.11855;
  _Bool D.11856;
  _Bool D.11857;
  unsigned int D.11859;
  _Bool D.11860;
  long int D.11861;
  long int D.11862;
  unsigned int fd.61;
  unsigned int _wapi_fd_reserve.62;
  void * D.11869;
  int D.11870;
  struct _WapiHandleUnshared * D.11871;
  int D.11874;
  unsigned int D.11875;
  unsigned int D.11876;
  <unnamed type> D.11877;
  _Bool D.11880;
  long int D.11881;
  long int D.11882;
  struct _WapiHandleUnshared * handle;
  int thr_ret;

  _wapi_has_shut_down.58 = _wapi_has_shut_down;
  D.11832 = _wapi_has_shut_down.58 != 0;
  D.11833 = (long int) D.11832;
  D.11834 = __builtin_expect (D.11833, 0);
  if (D.11834 != 0) goto <D.11835>; else goto <D.11836>;
  <D.11835>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 669, "_wapi_has_shut_down == FALSE");
  <D.11836>:
  D.11840 = type + 4294967295;
  D.11841 = D.11840 > 1;
  D.11842 = type != 7;
  D.11843 = D.11841 & D.11842;
  if (D.11843 != 0) goto <D.11844>; else goto <D.11838>;
  <D.11844>:
  if (type != 10) goto <D.11845>; else goto <D.11838>;
  <D.11845>:
  iftmp.59 = 1;
  goto <D.11839>;
  <D.11838>:
  iftmp.59 = 0;
  <D.11839>:
  D.11846 = iftmp.59 != 0;
  D.11847 = (long int) D.11846;
  D.11848 = __builtin_expect (D.11847, 0);
  if (D.11848 != 0) goto <D.11849>; else goto <D.11850>;
  <D.11849>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 674, "_WAPI_FD_HANDLE(type)");
  <D.11850>:
  D.11855 = type == 9;
  D.11856 = type == 11;
  D.11857 = D.11855 | D.11856;
  if (D.11857 != 0) goto <D.11852>; else goto <D.11858>;
  <D.11858>:
  D.11859 = type + 4294967284;
  if (D.11859 <= 1) goto <D.11852>; else goto <D.11853>;
  <D.11852>:
  iftmp.60 = 1;
  goto <D.11854>;
  <D.11853>:
  iftmp.60 = 0;
  <D.11854>:
  D.11860 = iftmp.60 != 0;
  D.11861 = (long int) D.11860;
  D.11862 = __builtin_expect (D.11861, 0);
  if (D.11862 != 0) goto <D.11863>; else goto <D.11864>;
  <D.11863>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 675, "!_WAPI_SHARED_HANDLE(type)");
  <D.11864>:
  fd.61 = (unsigned int) fd;
  _wapi_fd_reserve.62 = _wapi_fd_reserve;
  if (fd.61 >= _wapi_fd_reserve.62) goto <D.11867>; else goto <D.11868>;
  <D.11867>:
  D.11869 = 4294967295B;
  return D.11869;
  <D.11868>:
  D.11870 = fd / 256;
  D.11871 = _wapi_private_handles[D.11870];
  if (D.11871 == 0B) goto <D.11872>; else goto <D.11873>;
  <D.11872>:
  D.11870 = fd / 256;
  init_handles_slot (D.11870);
  <D.11873>:
  D.11870 = fd / 256;
  D.11871 = _wapi_private_handles[D.11870];
  D.11874 = fd % 256;
  D.11875 = (unsigned int) D.11874;
  D.11876 = D.11875 * 136;
  handle = D.11871 + D.11876;
  D.11877 = handle->type;
  if (D.11877 != 0) goto <D.11878>; else goto <D.11879>;
  <D.11878>:
  <D.11879>:
  thr_ret = _wapi_shm_sem_lock (2);
  D.11880 = thr_ret != 0;
  D.11881 = (long int) D.11880;
  D.11882 = __builtin_expect (D.11881, 0);
  if (D.11882 != 0) goto <D.11883>; else goto <D.11884>;
  <D.11883>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 702, "thr_ret == 0");
  <D.11884>:
  _wapi_handle_init (handle, type, handle_specific);
  thr_ret = _wapi_shm_sem_unlock (2);
  D.11869 = (void *) fd;
  return D.11869;
}


init_handles_slot (int idx)
{
  long int D.11886;
  _Bool D.11889;
  long int D.11890;
  long int D.11891;
  struct _WapiHandleUnshared * D.11894;
  void * D.11897;
  _Bool D.11898;
  long int D.11899;
  long int D.11900;
  int thr_ret;

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

    try
      {
        __cancel_routine = mono_mutex_unlock_in_cleanup;
        __cancel_arg = &scan_mutex;
        __not_first_call = __sigsetjmp (&__cancel_buf.__cancel_jmp_buf, 0);
        D.11886 = __builtin_expect (__not_first_call, 0);
        if (D.11886 != 0) goto <D.11887>; else goto <D.11888>;
        <D.11887>:
        __cancel_routine (__cancel_arg);
        __pthread_unwind_next (&__cancel_buf);
        <D.11888>:
        __pthread_register_cancel (&__cancel_buf);
        thr_ret = pthread_mutex_lock (&scan_mutex);
        D.11889 = thr_ret != 0;
        D.11890 = (long int) D.11889;
        D.11891 = __builtin_expect (D.11890, 0);
        if (D.11891 != 0) goto <D.11892>; else goto <D.11893>;
        <D.11892>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 650, "thr_ret == 0");
        <D.11893>:
        D.11894 = _wapi_private_handles[idx];
        if (D.11894 == 0B) goto <D.11895>; else goto <D.11896>;
        <D.11895>:
        D.11897 = monoeg_malloc0 (34816);
        _wapi_private_handles[idx] = D.11897;
        D.11894 = _wapi_private_handles[idx];
        D.11898 = D.11894 == 0B;
        D.11899 = (long int) D.11898;
        D.11900 = __builtin_expect (D.11899, 0);
        if (D.11900 != 0) goto <D.11901>; else goto <D.11902>;
        <D.11901>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 655, "_wapi_private_handles [idx]");
        <D.11902>:
        <D.11896>:
        thr_ret = pthread_mutex_unlock (&scan_mutex);
        D.11889 = thr_ret != 0;
        D.11890 = (long int) D.11889;
        D.11891 = __builtin_expect (D.11890, 0);
        if (D.11891 != 0) goto <D.11903>; else goto <D.11904>;
        <D.11903>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 659, "thr_ret == 0");
        <D.11904>:
        __pthread_unregister_cancel (&__cancel_buf);
        if (0 != 0) goto <D.11905>; else goto <D.11906>;
        <D.11905>:
        __cancel_routine (__cancel_arg);
        <D.11906>:
      }
    finally
      {
        __cancel_buf = {CLOBBER};
      }
  }
}


_wapi_lookup_handle (void * handle, WapiHandleType type, void * * handle_specific)
{
  gboolean D.11912;
  unsigned int D.11913;
  struct _WapiHandleUnshared * D.11914;
  int D.11917;
  unsigned int D.11918;
  unsigned int D.11919;
  <unnamed type> D.11920;
  _Bool D.11928;
  _Bool D.11929;
  _Bool D.11930;
  unsigned int D.11932;
  struct _WapiHandleSharedLayout * _wapi_shared_layout.63;
  unsigned int D.11934;
  <unnamed type> D.11935;
  union 
{
  struct _WapiHandle_process process;
  struct _WapiHandle_namedmutex namedmutex;
  struct _WapiHandle_namedsem namedsem;
  struct _WapiHandle_namedevent namedevent;
} * D.11938;
  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.11939;
  struct _WapiHandleUnshared * handle_data;
  guint32 handle_idx;

  handle_idx = (guint32) handle;
  if (handle_idx > 4194303) goto <D.11910>; else goto <D.11911>;
  <D.11910>:
  D.11912 = 0;
  return D.11912;
  <D.11911>:
  D.11913 = handle_idx / 256;
  D.11914 = _wapi_private_handles[D.11913];
  if (D.11914 == 0B) goto <D.11915>; else goto <D.11916>;
  <D.11915>:
  D.11913 = handle_idx / 256;
  D.11917 = (int) D.11913;
  init_handles_slot (D.11917);
  <D.11916>:
  D.11913 = handle_idx / 256;
  D.11914 = _wapi_private_handles[D.11913];
  D.11918 = handle_idx & 255;
  D.11919 = D.11918 * 136;
  handle_data = D.11914 + D.11919;
  D.11920 = handle_data->type;
  if (D.11920 != type) goto <D.11921>; else goto <D.11922>;
  <D.11921>:
  D.11912 = 0;
  return D.11912;
  <D.11922>:
  if (handle_specific == 0B) goto <D.11923>; else goto <D.11924>;
  <D.11923>:
  D.11912 = 0;
  return D.11912;
  <D.11924>:
  D.11928 = type == 9;
  D.11929 = type == 11;
  D.11930 = D.11928 | D.11929;
  if (D.11930 != 0) goto <D.11925>; else goto <D.11931>;
  <D.11931>:
  D.11932 = type + 4294967284;
  if (D.11932 <= 1) goto <D.11925>; else goto <D.11926>;
  <D.11925>:
  {
    struct _WapiHandle_shared_ref * ref;
    struct _WapiHandleShared * shared_handle_data;

    ref = &handle_data->u.shared;
    _wapi_shared_layout.63 = _wapi_shared_layout;
    D.11934 = ref->offset;
    shared_handle_data = &_wapi_shared_layout.63->handles[D.11934];
    D.11935 = shared_handle_data->type;
    if (D.11935 != type) goto <D.11936>; else goto <D.11937>;
    <D.11936>:
    D.11912 = 0;
    return D.11912;
    <D.11937>:
    D.11938 = &shared_handle_data->u;
    *handle_specific = D.11938;
  }
  goto <D.11927>;
  <D.11926>:
  D.11939 = &handle_data->u;
  *handle_specific = D.11939;
  <D.11927>:
  D.11912 = 1;
  return D.11912;
}


_wapi_handle_foreach (WapiHandleType type, gboolean (*<T1961>) (void *, void *) on_each, void * user_data)
{
  long int D.11941;
  _Bool D.11944;
  long int D.11945;
  long int D.11946;
  struct _WapiHandleUnshared * D.11949;
  unsigned int D.11952;
  <unnamed type> D.11953;
  unsigned int D.11956;
  unsigned int D.11957;
  int D.11958;
  unsigned int _wapi_private_handle_slot_count.64;
  struct _WapiHandleUnshared * handle_data;
  void * ret;
  guint32 i;
  guint32 k;
  int thr_ret;

  handle_data = 0B;
  ret = 0B;
  {
    struct __pthread_unwind_buf_t __cancel_buf;
    void (*<Tbf>) (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.11941 = __builtin_expect (__not_first_call, 0);
        if (D.11941 != 0) goto <D.11942>; else goto <D.11943>;
        <D.11942>:
        __cancel_routine (__cancel_arg);
        __pthread_unwind_next (&__cancel_buf);
        <D.11943>:
        __pthread_register_cancel (&__cancel_buf);
        thr_ret = pthread_mutex_lock (&scan_mutex);
        D.11944 = thr_ret != 0;
        D.11945 = (long int) D.11944;
        D.11946 = __builtin_expect (D.11945, 0);
        if (D.11946 != 0) goto <D.11947>; else goto <D.11948>;
        <D.11947>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 769, "thr_ret == 0");
        <D.11948>:
        i = 0;
        goto <D.10988>;
        <D.10987>:
        D.11949 = _wapi_private_handles[i];
        if (D.11949 != 0B) goto <D.11950>; else goto <D.11951>;
        <D.11950>:
        k = 0;
        goto <D.10986>;
        <D.10985>:
        D.11949 = _wapi_private_handles[i];
        D.11952 = k * 136;
        handle_data = D.11949 + D.11952;
        D.11953 = handle_data->type;
        if (D.11953 == type) goto <D.11954>; else goto <D.11955>;
        <D.11954>:
        D.11956 = i * 256;
        D.11957 = D.11956 + k;
        ret = (void *) D.11957;
        D.11958 = on_each (ret, user_data);
        if (D.11958 == 1) goto <D.10984>; else goto <D.11959>;
        <D.11959>:
        <D.11955>:
        k = k + 1;
        <D.10986>:
        if (k <= 255) goto <D.10985>; else goto <D.10984>;
        <D.10984>:
        <D.11951>:
        i = i + 1;
        <D.10988>:
        _wapi_private_handle_slot_count.64 = _wapi_private_handle_slot_count;
        if (i < _wapi_private_handle_slot_count.64) goto <D.10987>; else goto <D.10989>;
        <D.10989>:
        thr_ret = pthread_mutex_unlock (&scan_mutex);
        D.11944 = thr_ret != 0;
        D.11945 = (long int) D.11944;
        D.11946 = __builtin_expect (D.11945, 0);
        if (D.11946 != 0) goto <D.11961>; else goto <D.11962>;
        <D.11961>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 786, "thr_ret == 0");
        <D.11962>:
        __pthread_unregister_cancel (&__cancel_buf);
        if (0 != 0) goto <D.11963>; else goto <D.11964>;
        <D.11963>:
        __cancel_routine (__cancel_arg);
        <D.11964>:
      }
    finally
      {
        __cancel_buf = {CLOBBER};
      }
  }
}


_wapi_search_handle (WapiHandleType type, gboolean (*<T1961>) (void *, void *) check, void * user_data, void * * handle_specific, gboolean search_shared)
{
  long int D.11968;
  _Bool D.11971;
  long int D.11972;
  long int D.11973;
  struct _WapiHandleUnshared * D.11976;
  unsigned int D.11979;
  <unnamed type> D.11980;
  unsigned int D.11983;
  unsigned int D.11984;
  int D.11985;
  _Bool D.11990;
  _Bool D.11991;
  _Bool D.11992;
  unsigned int D.11994;
  struct _WapiHandleSharedLayout * _wapi_shared_layout.65;
  unsigned int _wapi_private_handle_slot_count.66;
  _Bool D.12003;
  _Bool D.12004;
  _Bool D.12005;
  <unnamed type> D.12009;
  int D.12014;
  long int D.12021;
  int now.67;
  guint32 * D.12023;
  unsigned int ret.68;
  unsigned int D.12025;
  struct _WapiHandleUnshared * D.12026;
  unsigned int D.12027;
  unsigned int D.12028;
  _Bool D.12037;
  long int D.12038;
  long int D.12039;
  union 
{
  struct _WapiHandle_process process;
  struct _WapiHandle_namedmutex namedmutex;
  struct _WapiHandle_namedsem namedsem;
  struct _WapiHandle_namedevent namedevent;
} * D.12042;
  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.12043;
  void * D.12044;
  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 (*<Tbf>) (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.11968 = __builtin_expect (__not_first_call, 0);
        if (D.11968 != 0) goto <D.11969>; else goto <D.11970>;
        <D.11969>:
        __cancel_routine (__cancel_arg);
        __pthread_unwind_next (&__cancel_buf);
        <D.11970>:
        __pthread_register_cancel (&__cancel_buf);
        thr_ret = pthread_mutex_lock (&scan_mutex);
        D.11971 = thr_ret != 0;
        D.11972 = (long int) D.11971;
        D.11973 = __builtin_expect (D.11972, 0);
        if (D.11973 != 0) goto <D.11974>; else goto <D.11975>;
        <D.11974>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 814, "thr_ret == 0");
        <D.11975>:
        i = 0;
        goto <D.11016>;
        <D.11015>:
        D.11976 = _wapi_private_handles[i];
        if (D.11976 != 0B) goto <D.11977>; else goto <D.11978>;
        <D.11977>:
        k = 0;
        goto <D.11014>;
        <D.11013>:
        D.11976 = _wapi_private_handles[i];
        D.11979 = k * 136;
        handle_data = D.11976 + D.11979;
        D.11980 = handle_data->type;
        if (D.11980 == type) goto <D.11981>; else goto <D.11982>;
        <D.11981>:
        D.11983 = i * 256;
        D.11984 = D.11983 + k;
        ret = (void *) D.11984;
        D.11985 = check (ret, user_data);
        if (D.11985 == 1) goto <D.11986>; else goto <D.11987>;
        <D.11986>:
        _wapi_handle_ref (ret);
        found = 1;
        D.11990 = type == 9;
        D.11991 = type == 11;
        D.11992 = D.11990 | D.11991;
        if (D.11992 != 0) goto <D.11988>; else goto <D.11993>;
        <D.11993>:
        D.11994 = type + 4294967284;
        if (D.11994 <= 1) goto <D.11988>; else goto <D.11989>;
        <D.11988>:
        _wapi_shared_layout.65 = _wapi_shared_layout;
        shared = &_wapi_shared_layout.65->handles[i];
        <D.11989>:
        goto <D.11012>;
        <D.11987>:
        <D.11982>:
        k = k + 1;
        <D.11014>:
        if (k <= 255) goto <D.11013>; else goto <D.11012>;
        <D.11012>:
        <D.11978>:
        i = i + 1;
        <D.11016>:
        if (found == 0) goto <D.11996>; else goto <D.11017>;
        <D.11996>:
        _wapi_private_handle_slot_count.66 = _wapi_private_handle_slot_count;
        if (i < _wapi_private_handle_slot_count.66) goto <D.11015>; else goto <D.11017>;
        <D.11017>:
        thr_ret = pthread_mutex_unlock (&scan_mutex);
        D.11971 = thr_ret != 0;
        D.11972 = (long int) D.11971;
        D.11973 = __builtin_expect (D.11972, 0);
        if (D.11973 != 0) goto <D.11998>; else goto <D.11999>;
        <D.11998>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 839, "thr_ret == 0");
        <D.11999>:
        __pthread_unregister_cancel (&__cancel_buf);
        if (0 != 0) goto <D.12000>; else goto <D.12001>;
        <D.12000>:
        __cancel_routine (__cancel_arg);
        <D.12001>:
      }
    finally
      {
        __cancel_buf = {CLOBBER};
      }
  }
  D.12003 = found == 0;
  D.12004 = search_shared != 0;
  D.12005 = D.12003 & D.12004;
  if (D.12005 != 0) goto <D.12006>; else goto <D.12007>;
  <D.12006>:
  D.11990 = type == 9;
  D.11991 = type == 11;
  D.11992 = D.11990 | D.11991;
  if (D.11992 != 0) goto <D.12002>; else goto <D.12008>;
  <D.12008>:
  D.11994 = type + 4294967284;
  if (D.11994 <= 1) goto <D.12002>; else goto <D.11020>;
  <D.12002>:
  i = 0;
  goto <D.11022>;
  <D.11021>:
  _wapi_shared_layout.65 = _wapi_shared_layout;
  shared = &_wapi_shared_layout.65->handles[i];
  D.12009 = shared->type;
  if (D.12009 == type) goto <D.12010>; else goto <D.12011>;
  <D.12010>:
  ret = _wapi_handle_new_from_offset (type, i, 0);
  if (ret == 4294967295B) goto <D.12012>; else goto <D.12013>;
  <D.12012>:
  // predicted unlikely by continue predictor.
  goto <D.11018>;
  <D.12013>:
  D.12014 = check (ret, user_data);
  if (D.12014 == 1) goto <D.12015>; else goto <D.12016>;
  <D.12015>:
  thr_ret = _wapi_handle_lock_shared_handles ();
  D.11971 = thr_ret != 0;
  D.11972 = (long int) D.11971;
  D.11973 = __builtin_expect (D.11972, 0);
  if (D.11973 != 0) goto <D.12017>; else goto <D.12018>;
  <D.12017>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 881, "thr_ret == 0");
  <D.12018>:
  D.12009 = shared->type;
  if (D.12009 == type) goto <D.12019>; else goto <D.12020>;
  <D.12019>:
  {
    guint32 now;

    D.12021 = time (0B);
    now = (guint32) D.12021;
    now.67 = (int) now;
    D.12023 = &shared->timestamp;
    InterlockedExchange (D.12023, now.67);
    found = 1;
    ret.68 = (unsigned int) ret;
    D.12025 = ret.68 / 256;
    D.12026 = _wapi_private_handles[D.12025];
    ret.68 = (unsigned int) ret;
    D.12027 = ret.68 & 255;
    D.12028 = D.12027 * 136;
    handle_data = D.12026 + D.12028;
    _wapi_handle_unlock_shared_handles ();
    goto <D.11020>;
  }
  <D.12020>:
  _wapi_handle_unlock_shared_handles ();
  <D.12016>:
  _wapi_handle_unref (ret);
  <D.12011>:
  <D.11018>:
  i = i + 1;
  <D.11022>:
  if (i <= 255) goto <D.11021>; else goto <D.11020>;
  <D.11020>:
  <D.12007>:
  if (found == 0) goto <D.12029>; else goto <D.12030>;
  <D.12029>:
  ret = 0B;
  goto done;
  <D.12030>:
  if (handle_specific != 0B) goto <D.12031>; else goto <D.12032>;
  <D.12031>:
  D.11990 = type == 9;
  D.11991 = type == 11;
  D.11992 = D.11990 | D.11991;
  if (D.11992 != 0) goto <D.12033>; else goto <D.12036>;
  <D.12036>:
  D.11994 = type + 4294967284;
  if (D.11994 <= 1) goto <D.12033>; else goto <D.12034>;
  <D.12033>:
  D.12009 = shared->type;
  D.12037 = D.12009 != type;
  D.12038 = (long int) D.12037;
  D.12039 = __builtin_expect (D.12038, 0);
  if (D.12039 != 0) goto <D.12040>; else goto <D.12041>;
  <D.12040>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 917, "shared->type == type");
  <D.12041>:
  D.12042 = &shared->u;
  *handle_specific = D.12042;
  goto <D.12035>;
  <D.12034>:
  D.12043 = &handle_data->u;
  *handle_specific = D.12043;
  <D.12035>:
  <D.12032>:
  done:
  D.12044 = ret;
  return D.12044;
}


_wapi_search_handle_namespace (WapiHandleType type, gchar * utf8_name)
{
  int iftmp.69;
  _Bool D.12055;
  _Bool D.12056;
  _Bool D.12057;
  unsigned int D.12059;
  _Bool D.12061;
  long int D.12062;
  long int D.12063;
  _Bool D.12066;
  long int D.12067;
  long int D.12068;
  struct _WapiHandleSharedLayout * _wapi_shared_layout.70;
  <unnamed type> D.12072;
  unsigned int D.12073;
  int D.11042;
  gchar[261] * D.12076;
  gint32 D.12081;
  struct _WapiHandleShared * shared_handle_data;
  guint32 i;
  gint32 ret;
  int thr_ret;
  void done = <<< error >>>;

  ret = 0;
  D.12055 = type != 9;
  D.12056 = type != 11;
  D.12057 = D.12055 & D.12056;
  if (D.12057 != 0) goto <D.12058>; else goto <D.12053>;
  <D.12058>:
  D.12059 = type + 4294967284;
  if (D.12059 > 1) goto <D.12060>; else goto <D.12053>;
  <D.12060>:
  iftmp.69 = 1;
  goto <D.12054>;
  <D.12053>:
  iftmp.69 = 0;
  <D.12054>:
  D.12061 = iftmp.69 != 0;
  D.12062 = (long int) D.12061;
  D.12063 = __builtin_expect (D.12062, 0);
  if (D.12063 != 0) goto <D.12064>; else goto <D.12065>;
  <D.12064>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 940, "_WAPI_SHARED_HANDLE(type)");
  <D.12065>:
  _wapi_handle_collect ();
  thr_ret = _wapi_handle_lock_shared_handles ();
  D.12066 = thr_ret != 0;
  D.12067 = (long int) D.12066;
  D.12068 = __builtin_expect (D.12067, 0);
  if (D.12068 != 0) goto <D.12069>; else goto <D.12070>;
  <D.12069>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 951, "thr_ret == 0");
  <D.12070>:
  i = 1;
  goto <D.11045>;
  <D.11044>:
  {
    struct WapiSharedNamespace * sharedns;

    _wapi_shared_layout.70 = _wapi_shared_layout;
    shared_handle_data = &_wapi_shared_layout.70->handles[i];
    D.12072 = shared_handle_data->type;
    D.12073 = D.12072 + 4294967285;
    if (D.12073 > 2) goto <D.12074>; else goto <D.12075>;
    <D.12074>:
    // predicted unlikely by continue predictor.
    goto <D.11033>;
    <D.12075>:
    sharedns = &shared_handle_data->u;
    {
      size_t __s1_len;
      size_t __s2_len;

      D.12076 = &sharedns->name;
      D.11042 = __builtin_strcmp (D.12076, utf8_name);
    }
    if (D.11042 == 0) goto <D.12077>; else goto <D.12078>;
    <D.12077>:
    D.12072 = shared_handle_data->type;
    if (D.12072 != type) goto <D.12079>; else goto <D.12080>;
    <D.12079>:
    ret = -1;
    goto done;
    <D.12080>:
    ret = (gint32) i;
    goto done;
    <D.12078>:
  }
  <D.11033>:
  i = i + 1;
  <D.11045>:
  if (i <= 255) goto <D.11044>; else goto <D.11046>;
  <D.11046>:
  done:
  _wapi_handle_unlock_shared_handles ();
  D.12081 = ret;
  return D.12081;
}


_wapi_handle_ref (void * handle)
{
  <unnamed type> D.12085;
  unsigned int D.12088;
  struct _WapiHandleUnshared * D.12089;
  unsigned int D.12090;
  unsigned int D.12091;
  guint * D.12092;
  <unnamed type> D.12095;
  _Bool D.12096;
  _Bool D.12097;
  _Bool D.12098;
  <unnamed type> D.12100;
  struct _WapiHandleSharedLayout * _wapi_shared_layout.71;
  unsigned int D.12103;
  long int D.12104;
  int now.72;
  guint32 * D.12106;
  guint32 idx;
  struct _WapiHandleUnshared * handle_data;
  static const char __func__[17] = "_wapi_handle_ref";

  idx = (guint32) handle;
  if (idx > 4194303) goto <D.12083>; else goto <D.12084>;
  <D.12083>:
  return;
  <D.12084>:
  D.12085 = _wapi_handle_type (handle);
  if (D.12085 == 0) goto <D.12086>; else goto <D.12087>;
  <D.12086>:
  monoeg_g_log (0B, 16, "%s: Attempting to ref unused handle %p", &__func__, handle);
  return;
  <D.12087>:
  D.12088 = idx / 256;
  D.12089 = _wapi_private_handles[D.12088];
  D.12090 = idx & 255;
  D.12091 = D.12090 * 136;
  handle_data = D.12089 + D.12091;
  D.12092 = &handle_data->ref;
  InterlockedIncrement (D.12092);
  D.12095 = handle_data->type;
  D.12096 = D.12095 == 9;
  D.12097 = D.12095 == 11;
  D.12098 = D.12096 | D.12097;
  if (D.12098 != 0) goto <D.12093>; else goto <D.12099>;
  <D.12099>:
  D.12100 = handle_data->type;
  if (D.12100 == 12) goto <D.12093>; else goto <D.12101>;
  <D.12101>:
  D.12100 = handle_data->type;
  if (D.12100 == 13) goto <D.12093>; else goto <D.12094>;
  <D.12093>:
  {
    struct _WapiHandleShared * shared_data;
    guint32 now;

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


_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.12110;
  unsigned int D.12111;
  struct _WapiHandleUnshared * D.12112;
  unsigned int D.12113;
  unsigned int D.12114;
  struct _WapiHandleUnshared * D.12115;
  <unnamed type> D.12116;
  unsigned int D.12117;
  _Bool D.12118;
  guint32 idx;
  WapiHandleType type;

  idx = (guint32) handle;
  if (idx > 4194303) goto <D.12108>; else goto <D.12109>;
  <D.12108>:
  D.12110 = 0;
  return D.12110;
  <D.12109>:
  D.12111 = idx / 256;
  D.12112 = _wapi_private_handles[D.12111];
  D.12113 = idx & 255;
  D.12114 = D.12113 * 136;
  D.12115 = D.12112 + D.12114;
  type = D.12115->type;
  D.12116 = handle_caps[type];
  D.12117 = D.12116 & caps;
  D.12118 = D.12117 != 0;
  D.12110 = (gboolean) D.12118;
  return D.12110;
}


_wapi_handle_ops_close (void * handle, void * data)
{
  unsigned int D.12122;
  struct _WapiHandleUnshared * D.12123;
  unsigned int D.12124;
  unsigned int D.12125;
  struct _WapiHandleUnshared * D.12126;
  struct _WapiHandleOps * D.12127;
  void (*<Tbba>) (void *, void *) D.12130;
  guint32 idx;
  WapiHandleType type;

  idx = (guint32) handle;
  if (idx > 4194303) goto <D.12120>; else goto <D.12121>;
  <D.12120>:
  return;
  <D.12121>:
  D.12122 = idx / 256;
  D.12123 = _wapi_private_handles[D.12122];
  D.12124 = idx & 255;
  D.12125 = D.12124 * 136;
  D.12126 = D.12123 + D.12125;
  type = D.12126->type;
  D.12127 = handle_ops[type];
  if (D.12127 != 0B) goto <D.12128>; else goto <D.12129>;
  <D.12128>:
  D.12127 = handle_ops[type];
  D.12130 = D.12127->close;
  if (D.12130 != 0B) goto <D.12131>; else goto <D.12132>;
  <D.12131>:
  D.12127 = handle_ops[type];
  D.12130 = D.12127->close;
  D.12130 (handle, data);
  <D.12132>:
  <D.12129>:
}


_wapi_handle_ops_signal (void * handle)
{
  unsigned int D.12136;
  struct _WapiHandleUnshared * D.12137;
  unsigned int D.12138;
  unsigned int D.12139;
  struct _WapiHandleUnshared * D.12140;
  struct _WapiHandleOps * D.12141;
  void (*<Tb27>) (void *) D.12144;
  guint32 idx;
  WapiHandleType type;

  idx = (guint32) handle;
  if (idx > 4194303) goto <D.12134>; else goto <D.12135>;
  <D.12134>:
  return;
  <D.12135>:
  D.12136 = idx / 256;
  D.12137 = _wapi_private_handles[D.12136];
  D.12138 = idx & 255;
  D.12139 = D.12138 * 136;
  D.12140 = D.12137 + D.12139;
  type = D.12140->type;
  D.12141 = handle_ops[type];
  if (D.12141 != 0B) goto <D.12142>; else goto <D.12143>;
  <D.12142>:
  D.12141 = handle_ops[type];
  D.12144 = D.12141->signal;
  if (D.12144 != 0B) goto <D.12145>; else goto <D.12146>;
  <D.12145>:
  D.12141 = handle_ops[type];
  D.12144 = D.12141->signal;
  D.12144 (handle);
  <D.12146>:
  <D.12143>:
}


_wapi_handle_ops_own (void * handle)
{
  gboolean D.12150;
  unsigned int D.12151;
  struct _WapiHandleUnshared * D.12152;
  unsigned int D.12153;
  unsigned int D.12154;
  struct _WapiHandleUnshared * D.12155;
  struct _WapiHandleOps * D.12157;
  gboolean (*<T17c2>) (void *) D.12159;
  guint32 idx;
  WapiHandleType type;

  idx = (guint32) handle;
  if (idx > 4194303) goto <D.12148>; else goto <D.12149>;
  <D.12148>:
  D.12150 = 0;
  return D.12150;
  <D.12149>:
  D.12151 = idx / 256;
  D.12152 = _wapi_private_handles[D.12151];
  D.12153 = idx & 255;
  D.12154 = D.12153 * 136;
  D.12155 = D.12152 + D.12154;
  type = D.12155->type;
  D.12157 = handle_ops[type];
  if (D.12157 != 0B) goto <D.12158>; else goto <D.12156>;
  <D.12158>:
  D.12157 = handle_ops[type];
  D.12159 = D.12157->own_handle;
  if (D.12159 != 0B) goto <D.12160>; else goto <D.12156>;
  <D.12160>:
  D.12157 = handle_ops[type];
  D.12159 = D.12157->own_handle;
  D.12150 = D.12159 (handle);
  return D.12150;
  <D.12156>:
  D.12150 = 0;
  return D.12150;
}


_wapi_handle_ops_isowned (void * handle)
{
  gboolean D.12164;
  unsigned int D.12165;
  struct _WapiHandleUnshared * D.12166;
  unsigned int D.12167;
  unsigned int D.12168;
  struct _WapiHandleUnshared * D.12169;
  struct _WapiHandleOps * D.12171;
  gboolean (*<T17c2>) (void *) D.12173;
  guint32 idx;
  WapiHandleType type;

  idx = (guint32) handle;
  if (idx > 4194303) goto <D.12162>; else goto <D.12163>;
  <D.12162>:
  D.12164 = 0;
  return D.12164;
  <D.12163>:
  D.12165 = idx / 256;
  D.12166 = _wapi_private_handles[D.12165];
  D.12167 = idx & 255;
  D.12168 = D.12167 * 136;
  D.12169 = D.12166 + D.12168;
  type = D.12169->type;
  D.12171 = handle_ops[type];
  if (D.12171 != 0B) goto <D.12172>; else goto <D.12170>;
  <D.12172>:
  D.12171 = handle_ops[type];
  D.12173 = D.12171->is_owned;
  if (D.12173 != 0B) goto <D.12174>; else goto <D.12170>;
  <D.12174>:
  D.12171 = handle_ops[type];
  D.12173 = D.12171->is_owned;
  D.12164 = D.12173 (handle);
  return D.12164;
  <D.12170>:
  D.12164 = 0;
  return D.12164;
}


_wapi_handle_ops_special_wait (void * handle, guint32 timeout, gboolean alertable)
{
  guint32 D.12178;
  unsigned int D.12179;
  struct _WapiHandleUnshared * D.12180;
  unsigned int D.12181;
  unsigned int D.12182;
  struct _WapiHandleUnshared * D.12183;
  struct _WapiHandleOps * D.12185;
  guint32 (*<T17c7>) (void *, guint32, gboolean) D.12187;
  guint32 idx;
  WapiHandleType type;

  idx = (guint32) handle;
  if (idx > 4194303) goto <D.12176>; else goto <D.12177>;
  <D.12176>:
  D.12178 = 4294967295;
  return D.12178;
  <D.12177>:
  D.12179 = idx / 256;
  D.12180 = _wapi_private_handles[D.12179];
  D.12181 = idx & 255;
  D.12182 = D.12181 * 136;
  D.12183 = D.12180 + D.12182;
  type = D.12183->type;
  D.12185 = handle_ops[type];
  if (D.12185 != 0B) goto <D.12186>; else goto <D.12184>;
  <D.12186>:
  D.12185 = handle_ops[type];
  D.12187 = D.12185->special_wait;
  if (D.12187 != 0B) goto <D.12188>; else goto <D.12184>;
  <D.12188>:
  D.12185 = handle_ops[type];
  D.12187 = D.12185->special_wait;
  D.12178 = D.12187 (handle, timeout, alertable);
  return D.12178;
  <D.12184>:
  D.12178 = 4294967295;
  return D.12178;
}


_wapi_handle_ops_prewait (void * handle)
{
  unsigned int D.12192;
  struct _WapiHandleUnshared * D.12193;
  unsigned int D.12194;
  unsigned int D.12195;
  struct _WapiHandleUnshared * D.12196;
  struct _WapiHandleOps * D.12197;
  void (*<Tb27>) (void *) D.12200;
  guint32 idx;
  WapiHandleType type;

  idx = (guint32) handle;
  if (idx > 4194303) goto <D.12190>; else goto <D.12191>;
  <D.12190>:
  return;
  <D.12191>:
  D.12192 = idx / 256;
  D.12193 = _wapi_private_handles[D.12192];
  D.12194 = idx & 255;
  D.12195 = D.12194 * 136;
  D.12196 = D.12193 + D.12195;
  type = D.12196->type;
  D.12197 = handle_ops[type];
  if (D.12197 != 0B) goto <D.12198>; else goto <D.12199>;
  <D.12198>:
  D.12197 = handle_ops[type];
  D.12200 = D.12197->prewait;
  if (D.12200 != 0B) goto <D.12201>; else goto <D.12202>;
  <D.12201>:
  D.12197 = handle_ops[type];
  D.12200 = D.12197->prewait;
  D.12200 (handle);
  <D.12202>:
  <D.12199>:
}


CloseHandle (void * handle)
{
  struct _WapiHandleUnshared * D.12206;
  <unnamed type> D.12207;
  gboolean D.12210;

  if (handle == 0B) goto <D.12204>; else goto <D.12205>;
  <D.12204>:
  D.12206 = _wapi_private_handles[0];
  D.12207 = D.12206->type;
  if (D.12207 != 2) goto <D.12208>; else goto <D.12209>;
  <D.12208>:
  SetLastError (87);
  D.12210 = 0;
  return D.12210;
  <D.12209>:
  <D.12205>:
  if (handle == 4294967295B) goto <D.12211>; else goto <D.12212>;
  <D.12211>:
  SetLastError (87);
  D.12210 = 0;
  return D.12210;
  <D.12212>:
  _wapi_handle_unref (handle);
  D.12210 = 1;
  return D.12210;
}


DuplicateHandle (void * srcprocess, void * src, void * targetprocess, void * * target, guint32 access, gboolean inherit, guint32 options)
{
  _Bool D.12214;
  _Bool D.12215;
  _Bool D.12216;
  gboolean D.12219;
  void * D.12222;
  void * D.12226;

  D.12214 = srcprocess != 4294967295B;
  D.12215 = targetprocess != 4294967295B;
  D.12216 = D.12214 | D.12215;
  if (D.12216 != 0) goto <D.12217>; else goto <D.12218>;
  <D.12217>:
  SetLastError (6);
  D.12219 = 0;
  return D.12219;
  <D.12218>:
  if (src == 4294967295B) goto <D.12220>; else goto <D.12221>;
  <D.12220>:
  D.12222 = _wapi_process_duplicate ();
  *target = D.12222;
  goto <D.12223>;
  <D.12221>:
  if (src == 4294967294B) goto <D.12224>; else goto <D.12225>;
  <D.12224>:
  D.12226 = _wapi_thread_duplicate ();
  *target = D.12226;
  goto <D.12227>;
  <D.12225>:
  _wapi_handle_ref (src);
  *target = src;
  <D.12227>:
  <D.12223>:
  D.12219 = 1;
  return D.12219;
}


_wapi_handle_count_signalled_handles (guint32 numhandles, void * * handles, gboolean waitall, guint32 * retcount, guint32 * lowest)
{
  _Bool D.12229;
  long int D.12230;
  long int D.12231;
  unsigned int D.12234;
  void * * D.12235;
  unsigned int D.12236;
  struct _WapiHandleUnshared * D.12237;
  unsigned int D.12238;
  unsigned int D.12239;
  struct _WapiHandleUnshared * D.12240;
  unsigned int i.73;
  unsigned int D.12250;
  unsigned int D.12251;
  struct _WapiHandleUnshared * D.12252;
  unsigned int D.12253;
  unsigned int D.12254;
  struct _WapiHandleUnshared * D.12255;
  int D.12261;
  int D.12263;
  _Bool D.12264;
  _Bool D.12265;
  _Bool D.12266;
  unsigned int D.12268;
  struct _WapiHandleSharedLayout * _wapi_shared_layout.74;
  unsigned int handle.75;
  unsigned int D.12271;
  struct _WapiHandleUnshared * D.12272;
  unsigned int D.12273;
  unsigned int D.12274;
  struct _WapiHandleUnshared * D.12275;
  unsigned int D.12276;
  int D.12277;
  _Bool D.12278;
  _Bool D.12279;
  _Bool D.12280;
  int D.12283;
  unsigned int D.12284;
  _Bool D.12290;
  _Bool D.12291;
  _Bool D.12292;
  _Bool D.12294;
  _Bool D.12295;
  _Bool D.12296;
  gboolean D.12297;
  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.12229 = thr_ret != 0;
  D.12230 = (long int) D.12229;
  D.12231 = __builtin_expect (D.12230, 0);
  if (D.12231 != 0) goto <D.12232>; else goto <D.12233>;
  <D.12232>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 1375, "thr_ret == 0");
  <D.12233>:
  i = 0;
  goto <D.11164>;
  <D.11163>:
  {
    void * handle;
    guint32 idx;

    D.12234 = i * 4;
    D.12235 = handles + D.12234;
    handle = *D.12235;
    idx = (guint32) handle;
    D.12236 = idx / 256;
    D.12237 = _wapi_private_handles[D.12236];
    D.12238 = idx & 255;
    D.12239 = D.12238 * 136;
    D.12240 = D.12237 + D.12239;
    type = D.12240->type;
    thr_ret = _wapi_handle_trylock_handle (handle);
    if (thr_ret != 0) goto <D.12241>; else goto <D.12242>;
    <D.12241>:
    thr_ret = _wapi_handle_unlock_shared_handles ();
    D.12229 = thr_ret != 0;
    D.12230 = (long int) D.12229;
    D.12231 = __builtin_expect (D.12230, 0);
    if (D.12231 != 0) goto <D.12243>; else goto <D.12244>;
    <D.12243>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 1394, "thr_ret == 0");
    <D.12244>:
    goto <D.11160>;
    <D.11159>:
    D.12234 = i * 4;
    D.12235 = handles + D.12234;
    handle = *D.12235;
    idx = (guint32) handle;
    thr_ret = _wapi_handle_unlock_handle (handle);
    D.12229 = thr_ret != 0;
    D.12230 = (long int) D.12229;
    D.12231 = __builtin_expect (D.12230, 0);
    if (D.12231 != 0) goto <D.12245>; else goto <D.12246>;
    <D.12245>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 1401, "thr_ret == 0");
    <D.12246>:
    <D.11160>:
    i.73 = i;
    i = i.73 + 4294967295;
    if (i.73 != 0) goto <D.11159>; else goto <D.11161>;
    <D.11161>:
    iter = iter + 1;
    if (iter == 100) goto <D.12248>; else goto <D.12249>;
    <D.12248>:
    monoeg_g_log (0B, 16, "%s: iteration overflow!", &__func__);
    iter = 1;
    <D.12249>:
    D.12250 = iter * 10;
    _wapi_handle_spin (D.12250);
    goto again;
    <D.12242>:
  }
  i = i + 1;
  <D.11164>:
  if (i < numhandles) goto <D.11163>; else goto <D.11165>;
  <D.11165>:
  count = 0;
  *lowest = numhandles;
  i = 0;
  goto <D.11169>;
  <D.11168>:
  {
    void * handle;
    guint32 idx;

    D.12234 = i * 4;
    D.12235 = handles + D.12234;
    handle = *D.12235;
    idx = (guint32) handle;
    D.12251 = idx / 256;
    D.12252 = _wapi_private_handles[D.12251];
    D.12253 = idx & 255;
    D.12254 = D.12253 * 136;
    D.12255 = D.12252 + D.12254;
    type = D.12255->type;
    D.12261 = _wapi_handle_test_capabilities (handle, 4);
    if (D.12261 == 1) goto <D.12262>; else goto <D.12256>;
    <D.12262>:
    D.12263 = _wapi_handle_ops_isowned (handle);
    if (D.12263 == 1) goto <D.12257>; else goto <D.12256>;
    <D.12256>:
    D.12264 = type == 9;
    D.12265 = type == 11;
    D.12266 = D.12264 | D.12265;
    if (D.12266 != 0) goto <D.12258>; else goto <D.12267>;
    <D.12267>:
    D.12268 = type + 4294967284;
    if (D.12268 <= 1) goto <D.12258>; else goto <D.12259>;
    <D.12258>:
    _wapi_shared_layout.74 = _wapi_shared_layout;
    handle.75 = (unsigned int) handle;
    D.12271 = handle.75 / 256;
    D.12272 = _wapi_private_handles[D.12271];
    handle.75 = (unsigned int) handle;
    D.12273 = handle.75 & 255;
    D.12274 = D.12273 * 136;
    D.12275 = D.12272 + D.12274;
    D.12276 = D.12275->u.shared.offset;
    D.12277 = _wapi_shared_layout.74->handles[D.12276].signalled;
    if (D.12277 == 1) goto <D.12257>; else goto <D.12259>;
    <D.12259>:
    D.12278 = type != 9;
    D.12279 = type != 11;
    D.12280 = D.12278 & D.12279;
    if (D.12280 != 0) goto <D.12281>; else goto <D.12260>;
    <D.12281>:
    D.12268 = type + 4294967284;
    if (D.12268 > 1) goto <D.12282>; else goto <D.12260>;
    <D.12282>:
    D.12251 = idx / 256;
    D.12252 = _wapi_private_handles[D.12251];
    D.12253 = idx & 255;
    D.12254 = D.12253 * 136;
    D.12255 = D.12252 + D.12254;
    D.12283 = D.12255->signalled;
    if (D.12283 == 1) goto <D.12257>; else goto <D.12260>;
    <D.12257>:
    count = count + 1;
    D.12284 = *lowest;
    if (D.12284 > i) goto <D.12285>; else goto <D.12286>;
    <D.12285>:
    *lowest = i;
    <D.12286>:
    <D.12260>:
  }
  i = i + 1;
  <D.11169>:
  if (i < numhandles) goto <D.11168>; else goto <D.11170>;
  <D.11170>:
  D.12290 = waitall == 1;
  D.12291 = count == numhandles;
  D.12292 = D.12290 & D.12291;
  if (D.12292 != 0) goto <D.12287>; else goto <D.12293>;
  <D.12293>:
  D.12294 = waitall == 0;
  D.12295 = count != 0;
  D.12296 = D.12294 & D.12295;
  if (D.12296 != 0) goto <D.12287>; else goto <D.12288>;
  <D.12287>:
  ret = 1;
  goto <D.12289>;
  <D.12288>:
  ret = 0;
  <D.12289>:
  *retcount = count;
  D.12297 = ret;
  return D.12297;
}


_wapi_handle_trylock_handle (void * handle)
{
  int D.12301;
  <unnamed type> D.12304;
  <unnamed type> D.12306;
  <unnamed type> D.12308;
  <unnamed type> D.12310;
  unsigned int D.12311;
  struct _WapiHandleUnshared * D.12312;
  unsigned int D.12313;
  unsigned int D.12314;
  struct _WapiHandleUnshared * D.12315;
  union mono_mutex_t * D.12316;
  guint32 idx;
  int ret;

  idx = (guint32) handle;
  if (idx > 4194303) goto <D.12299>; else goto <D.12300>;
  <D.12299>:
  D.12301 = 0;
  return D.12301;
  <D.12300>:
  _wapi_handle_ref (handle);
  D.12304 = _wapi_handle_type (handle);
  if (D.12304 == 9) goto <D.12302>; else goto <D.12305>;
  <D.12305>:
  D.12306 = _wapi_handle_type (handle);
  if (D.12306 == 11) goto <D.12302>; else goto <D.12307>;
  <D.12307>:
  D.12308 = _wapi_handle_type (handle);
  if (D.12308 == 12) goto <D.12302>; else goto <D.12309>;
  <D.12309>:
  D.12310 = _wapi_handle_type (handle);
  if (D.12310 == 13) goto <D.12302>; else goto <D.12303>;
  <D.12302>:
  D.12301 = 0;
  return D.12301;
  <D.12303>:
  D.12311 = idx / 256;
  D.12312 = _wapi_private_handles[D.12311];
  D.12313 = idx & 255;
  D.12314 = D.12313 * 136;
  D.12315 = D.12312 + D.12314;
  D.12316 = &D.12315->signal_mutex;
  ret = pthread_mutex_trylock (D.12316);
  if (ret != 0) goto <D.12317>; else goto <D.12318>;
  <D.12317>:
  _wapi_handle_unref (handle);
  <D.12318>:
  D.12301 = ret;
  return D.12301;
}


_wapi_handle_unlock_handle (void * handle)
{
  int D.12322;
  <unnamed type> D.12325;
  <unnamed type> D.12327;
  <unnamed type> D.12329;
  <unnamed type> D.12331;
  unsigned int D.12332;
  struct _WapiHandleUnshared * D.12333;
  unsigned int D.12334;
  unsigned int D.12335;
  struct _WapiHandleUnshared * D.12336;
  union mono_mutex_t * D.12337;
  guint32 idx;
  int ret;

  idx = (guint32) handle;
  if (idx > 4194303) goto <D.12320>; else goto <D.12321>;
  <D.12320>:
  D.12322 = 0;
  return D.12322;
  <D.12321>:
  D.12325 = _wapi_handle_type (handle);
  if (D.12325 == 9) goto <D.12323>; else goto <D.12326>;
  <D.12326>:
  D.12327 = _wapi_handle_type (handle);
  if (D.12327 == 11) goto <D.12323>; else goto <D.12328>;
  <D.12328>:
  D.12329 = _wapi_handle_type (handle);
  if (D.12329 == 12) goto <D.12323>; else goto <D.12330>;
  <D.12330>:
  D.12331 = _wapi_handle_type (handle);
  if (D.12331 == 13) goto <D.12323>; else goto <D.12324>;
  <D.12323>:
  _wapi_handle_unref (handle);
  D.12322 = 0;
  return D.12322;
  <D.12324>:
  D.12332 = idx / 256;
  D.12333 = _wapi_private_handles[D.12332];
  D.12334 = idx & 255;
  D.12335 = D.12334 * 136;
  D.12336 = D.12333 + D.12335;
  D.12337 = &D.12336->signal_mutex;
  ret = pthread_mutex_unlock (D.12337);
  _wapi_handle_unref (handle);
  D.12322 = ret;
  return D.12322;
}


_wapi_handle_spin (guint32 ms)
{
  _Bool D.12339;
  long int D.12340;
  long int D.12341;
  unsigned int D.12344;
  long int D.12345;
  struct timespec sleepytime;

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


_wapi_handle_unlock_handles (guint32 numhandles, void * * handles)
{
  _Bool D.12346;
  long int D.12347;
  long int D.12348;
  unsigned int D.12351;
  void * * D.12352;
  guint32 i;
  int thr_ret;

  thr_ret = _wapi_handle_unlock_shared_handles ();
  D.12346 = thr_ret != 0;
  D.12347 = (long int) D.12346;
  D.12348 = __builtin_expect (D.12347, 0);
  if (D.12348 != 0) goto <D.12349>; else goto <D.12350>;
  <D.12349>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 1474, "thr_ret == 0");
  <D.12350>:
  i = 0;
  goto <D.11179>;
  <D.11178>:
  {
    void * handle;

    D.12351 = i * 4;
    D.12352 = handles + D.12351;
    handle = *D.12352;
    thr_ret = _wapi_handle_unlock_handle (handle);
    D.12346 = thr_ret != 0;
    D.12347 = (long int) D.12346;
    D.12348 = __builtin_expect (D.12347, 0);
    if (D.12348 != 0) goto <D.12353>; else goto <D.12354>;
    <D.12353>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 1482, "thr_ret == 0");
    <D.12354>:
  }
  i = i + 1;
  <D.11179>:
  if (i < numhandles) goto <D.11178>; else goto <D.11180>;
  <D.11180>:
}


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

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


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

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


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

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


_wapi_handle_timedwait_signal_handle (void * handle, struct timespec * timeout, gboolean alertable, gboolean poll)
{
  <unnamed type> D.12365;
  <unnamed type> D.12367;
  <unnamed type> D.12369;
  <unnamed type> D.12371;
  struct _WapiHandleSharedLayout * _wapi_shared_layout.78;
  unsigned int handle.79;
  unsigned int D.12374;
  struct _WapiHandleUnshared * D.12375;
  unsigned int D.12376;
  unsigned int D.12377;
  struct _WapiHandleUnshared * D.12378;
  unsigned int D.12379;
  int D.12380;
  int D.12383;
  long int D.12388;
  long int D.12389;
  long int D.12392;
  long int D.12393;
  int D.12394;
  int D.12399;
  unsigned int D.12402;
  struct _WapiHandleUnshared * D.12403;
  unsigned int D.12404;
  unsigned int D.12405;
  struct _WapiHandleUnshared * D.12406;

  D.12365 = _wapi_handle_type (handle);
  if (D.12365 == 9) goto <D.12363>; else goto <D.12366>;
  <D.12366>:
  D.12367 = _wapi_handle_type (handle);
  if (D.12367 == 11) goto <D.12363>; else goto <D.12368>;
  <D.12368>:
  D.12369 = _wapi_handle_type (handle);
  if (D.12369 == 12) goto <D.12363>; else goto <D.12370>;
  <D.12370>:
  D.12371 = _wapi_handle_type (handle);
  if (D.12371 == 13) goto <D.12363>; else goto <D.12364>;
  <D.12363>:
  _wapi_shared_layout.78 = _wapi_shared_layout;
  handle.79 = (unsigned int) handle;
  D.12374 = handle.79 / 256;
  D.12375 = _wapi_private_handles[D.12374];
  handle.79 = (unsigned int) handle;
  D.12376 = handle.79 & 255;
  D.12377 = D.12376 * 136;
  D.12378 = D.12375 + D.12377;
  D.12379 = D.12378->u.shared.offset;
  D.12380 = _wapi_shared_layout.78->handles[D.12379].signalled;
  if (D.12380 == 1) goto <D.12381>; else goto <D.12382>;
  <D.12381>:
  D.12383 = 0;
  return D.12383;
  <D.12382>:
  if (timeout != 0B) goto <D.12384>; else goto <D.12385>;
  <D.12384>:
  {
    struct timespec fake_timeout;

    try
      {
        _wapi_calc_timeout (&fake_timeout, 100);
        D.12388 = fake_timeout.tv_sec;
        D.12389 = timeout->tv_sec;
        if (D.12388 > D.12389) goto <D.12386>; else goto <D.12390>;
        <D.12390>:
        D.12388 = fake_timeout.tv_sec;
        D.12389 = timeout->tv_sec;
        if (D.12388 == D.12389) goto <D.12391>; else goto <D.12387>;
        <D.12391>:
        D.12392 = fake_timeout.tv_nsec;
        D.12393 = timeout->tv_nsec;
        if (D.12392 > D.12393) goto <D.12386>; else goto <D.12387>;
        <D.12386>:
        _wapi_handle_spin (100);
        _wapi_shared_layout.78 = _wapi_shared_layout;
        handle.79 = (unsigned int) handle;
        D.12374 = handle.79 / 256;
        D.12375 = _wapi_private_handles[D.12374];
        handle.79 = (unsigned int) handle;
        D.12376 = handle.79 & 255;
        D.12377 = D.12376 * 136;
        D.12378 = D.12375 + D.12377;
        D.12379 = D.12378->u.shared.offset;
        D.12394 = _wapi_shared_layout.78->handles[D.12379].signalled;
        if (D.12394 == 1) goto <D.12395>; else goto <D.12396>;
        <D.12395>:
        D.12383 = 0;
        return D.12383;
        <D.12396>:
        D.12383 = 110;
        return D.12383;
        <D.12387>:
      }
    finally
      {
        fake_timeout = {CLOBBER};
      }
  }
  <D.12385>:
  _wapi_handle_spin (100);
  D.12383 = 0;
  return D.12383;
  <D.12364>:
  {
    guint32 idx;
    int res;
    union pthread_cond_t * cond;
    union mono_mutex_t * mutex;

    idx = (guint32) handle;
    if (alertable != 0) goto <D.12397>; else goto <D.12398>;
    <D.12397>:
    D.12399 = wapi_thread_set_wait_handle (handle);
    if (D.12399 == 0) goto <D.12400>; else goto <D.12401>;
    <D.12400>:
    D.12383 = 0;
    return D.12383;
    <D.12401>:
    <D.12398>:
    D.12402 = idx / 256;
    D.12403 = _wapi_private_handles[D.12402];
    D.12404 = idx & 255;
    D.12405 = D.12404 * 136;
    D.12406 = D.12403 + D.12405;
    cond = &D.12406->signal_cond;
    D.12402 = idx / 256;
    D.12403 = _wapi_private_handles[D.12402];
    D.12404 = idx & 255;
    D.12405 = D.12404 * 136;
    D.12406 = D.12403 + D.12405;
    mutex = &D.12406->signal_mutex;
    if (poll != 0) goto <D.12407>; else goto <D.12408>;
    <D.12407>:
    res = timedwait_signal_poll_cond (cond, mutex, timeout, alertable);
    goto <D.12409>;
    <D.12408>:
    if (timeout != 0B) goto <D.12410>; else goto <D.12411>;
    <D.12410>:
    res = pthread_cond_timedwait (cond, mutex, timeout);
    goto <D.12412>;
    <D.12411>:
    res = pthread_cond_wait (cond, mutex);
    <D.12412>:
    <D.12409>:
    if (alertable != 0) goto <D.12413>; else goto <D.12414>;
    <D.12413>:
    wapi_thread_clear_wait_handle (handle);
    <D.12414>:
    D.12383 = res;
    return D.12383;
  }
}


timedwait_signal_poll_cond (union pthread_cond_t * cond, union mono_mutex_t * mutex, struct timespec * timeout, gboolean alertable)
{
  long int D.12428;
  long int D.12429;
  long int D.12432;
  long int D.12433;
  int D.12436;
  struct timespec fake_timeout;
  int ret;

  try
    {
      if (alertable == 0) goto <D.12418>; else goto <D.12419>;
      <D.12418>:
      if (timeout != 0B) goto <D.12420>; else goto <D.12421>;
      <D.12420>:
      ret = pthread_cond_timedwait (cond, mutex, timeout);
      goto <D.12422>;
      <D.12421>:
      ret = pthread_cond_wait (cond, mutex);
      <D.12422>:
      goto <D.12423>;
      <D.12419>:
      _wapi_calc_timeout (&fake_timeout, 100);
      if (timeout != 0B) goto <D.12427>; else goto <D.12424>;
      <D.12427>:
      D.12428 = fake_timeout.tv_sec;
      D.12429 = timeout->tv_sec;
      if (D.12428 > D.12429) goto <D.12425>; else goto <D.12430>;
      <D.12430>:
      D.12428 = fake_timeout.tv_sec;
      D.12429 = timeout->tv_sec;
      if (D.12428 == D.12429) goto <D.12431>; else goto <D.12424>;
      <D.12431>:
      D.12432 = fake_timeout.tv_nsec;
      D.12433 = timeout->tv_nsec;
      if (D.12432 > D.12433) goto <D.12425>; else goto <D.12424>;
      <D.12425>:
      ret = pthread_cond_timedwait (cond, mutex, timeout);
      goto <D.12426>;
      <D.12424>:
      ret = pthread_cond_timedwait (cond, mutex, &fake_timeout);
      if (ret == 110) goto <D.12434>; else goto <D.12435>;
      <D.12434>:
      ret = 0;
      <D.12435>:
      <D.12426>:
      <D.12423>:
      D.12436 = ret;
      return D.12436;
    }
  finally
    {
      fake_timeout = {CLOBBER};
    }
}


_wapi_free_share_info (struct _WapiFileShare * share_info)
{
  int D.12439;
  _Bool D.12444;
  long int D.12445;
  long int D.12446;
  struct GHashTable * file_share_hash.80;
  _Bool D.12452;
  long int D.12453;
  long int D.12454;

  D.12439 = _wapi_shm_enabled ();
  if (D.12439 == 0) goto <D.12440>; else goto <D.12441>;
  <D.12440>:
  {
    int ret;

    ret = pthread_mutex_lock (&file_share_hash_mutex.mutex);
    if (ret != 0) goto <D.12442>; else goto <D.12443>;
    <D.12442>:
    monoeg_g_log (0B, 16, "Bad call to mono_mutex_lock result %d", ret);
    <D.12443>:
    D.12444 = ret != 0;
    D.12445 = (long int) D.12444;
    D.12446 = __builtin_expect (D.12445, 0);
    if (D.12446 != 0) goto <D.12447>; else goto <D.12448>;
    <D.12447>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 1602, "ret == 0");
    <D.12448>:
  }
  file_share_hash.80 = file_share_hash;
  monoeg_g_hash_table_remove (file_share_hash.80, share_info);
  {
    int ret;

    ret = pthread_mutex_unlock (&file_share_hash_mutex.mutex);
    if (ret != 0) goto <D.12450>; else goto <D.12451>;
    <D.12450>:
    monoeg_g_log (0B, 16, "Bad call to mono_mutex_unlock result %d", ret);
    <D.12451>:
    D.12452 = ret != 0;
    D.12453 = (long int) D.12452;
    D.12454 = __builtin_expect (D.12453, 0);
    if (D.12454 != 0) goto <D.12455>; else goto <D.12456>;
    <D.12455>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 1604, "ret == 0");
    <D.12456>:
  }
  goto <D.12457>;
  <D.12441>:
  memset (share_info, 0, 36);
  <D.12457>:
}


_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.12458;
  _Bool D.12459;
  long int D.12460;
  long int D.12461;
  int D.12466;
  struct GHashTable * file_share_hash.81;
  struct GHashTable * file_share_hash.82;
  _Bool D.12475;
  long int D.12476;
  long int D.12477;
  unsigned int D.12482;
  unsigned int D.12483;
  guint32 * D.12484;
  int D.12486;
  _Bool D.12489;
  long int D.12490;
  long int D.12491;
  struct _WapiFileShareLayout * _wapi_fileshare_layout.83;
  unsigned int D.12498;
  long long unsigned int D.12503;
  long long unsigned int D.12506;
  unsigned int i.84;
  unsigned int D.12510;
  _Bool D.12513;
  _Bool D.12514;
  _Bool D.12515;
  int D.12522;
  struct _WapiFileShare * D.12523;
  int now.85;
  guint32 * D.12527;
  gboolean D.12528;
  struct _WapiFileShare * file_share;
  guint32 now;
  int thr_ret;
  int i;
  int first_unused;
  gboolean exists;

  D.12458 = time (0B);
  now = (guint32) D.12458;
  first_unused = -1;
  exists = 0;
  thr_ret = _wapi_handle_lock_shared_handles ();
  D.12459 = thr_ret != 0;
  D.12460 = (long int) D.12459;
  D.12461 = __builtin_expect (D.12460, 0);
  if (D.12461 != 0) goto <D.12462>; else goto <D.12463>;
  <D.12462>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 1643, "thr_ret == 0");
  <D.12463>:
  thr_ret = _wapi_shm_sem_lock (2);
  D.12459 = thr_ret != 0;
  D.12460 = (long int) D.12459;
  D.12461 = __builtin_expect (D.12460, 0);
  if (D.12461 != 0) goto <D.12464>; else goto <D.12465>;
  <D.12464>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 1647, "thr_ret == 0");
  <D.12465>:
  D.12466 = _wapi_shm_enabled ();
  if (D.12466 == 0) goto <D.12467>; else goto <D.12468>;
  <D.12467>:
  {
    struct _WapiFileShare tmp;

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

          ret = pthread_mutex_lock (&file_share_hash_mutex.mutex);
          if (ret != 0) goto <D.12473>; else goto <D.12474>;
          <D.12473>:
          monoeg_g_log (0B, 16, "Bad call to mono_mutex_lock result %d", ret);
          <D.12474>:
          D.12475 = ret != 0;
          D.12476 = (long int) D.12475;
          D.12477 = __builtin_expect (D.12476, 0);
          if (D.12477 != 0) goto <D.12478>; else goto <D.12479>;
          <D.12478>:
          monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 1665, "ret == 0");
          <D.12479>:
        }
        file_share_hash.81 = file_share_hash;
        file_share = monoeg_g_hash_table_lookup (file_share_hash.81, &tmp);
        if (file_share != 0B) goto <D.12480>; else goto <D.12481>;
        <D.12480>:
        D.12482 = file_share->sharemode;
        *old_sharemode = D.12482;
        D.12483 = file_share->access;
        *old_access = D.12483;
        *share_info = file_share;
        D.12484 = &file_share->handle_refs;
        InterlockedIncrement (D.12484);
        exists = 1;
        goto <D.12485>;
        <D.12481>:
        file_share = monoeg_malloc0 (36);
        file_share->device = device;
        file_share->inode = inode;
        D.12486 = _wapi_getpid ();
        file_share->opened_by_pid = D.12486;
        file_share->sharemode = new_sharemode;
        file_share->access = new_access;
        file_share->handle_refs = 1;
        *share_info = file_share;
        file_share_hash.81 = file_share_hash;
        monoeg_g_hash_table_insert_replace (file_share_hash.81, file_share, file_share, 0);
        <D.12485>:
        {
          int ret;

          ret = pthread_mutex_unlock (&file_share_hash_mutex.mutex);
          if (ret != 0) goto <D.12487>; else goto <D.12488>;
          <D.12487>:
          monoeg_g_log (0B, 16, "Bad call to mono_mutex_unlock result %d", ret);
          <D.12488>:
          D.12489 = ret != 0;
          D.12490 = (long int) D.12489;
          D.12491 = __builtin_expect (D.12490, 0);
          if (D.12491 != 0) goto <D.12492>; else goto <D.12493>;
          <D.12492>:
          monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 1689, "ret == 0");
          <D.12493>:
        }
      }
    finally
      {
        tmp = {CLOBBER};
      }
  }
  goto <D.12494>;
  <D.12468>:
  *share_info = 0B;
  i = 0;
  goto <D.11247>;
  <D.11246>:
  _wapi_fileshare_layout.83 = _wapi_fileshare_layout;
  file_share = &_wapi_fileshare_layout.83->share_info[i];
  if (first_unused == -1) goto <D.12496>; else goto <D.12497>;
  <D.12496>:
  D.12498 = file_share->handle_refs;
  if (D.12498 == 0) goto <D.12499>; else goto <D.12500>;
  <D.12499>:
  first_unused = i;
  // predicted unlikely by continue predictor.
  goto <D.11244>;
  <D.12500>:
  <D.12497>:
  D.12498 = file_share->handle_refs;
  if (D.12498 == 0) goto <D.12501>; else goto <D.12502>;
  <D.12501>:
  // predicted unlikely by continue predictor.
  goto <D.11244>;
  <D.12502>:
  D.12503 = file_share->device;
  if (D.12503 == device) goto <D.12504>; else goto <D.12505>;
  <D.12504>:
  D.12506 = file_share->inode;
  if (D.12506 == inode) goto <D.12507>; else goto <D.12508>;
  <D.12507>:
  D.12482 = file_share->sharemode;
  *old_sharemode = D.12482;
  D.12483 = file_share->access;
  *old_access = D.12483;
  *share_info = file_share;
  D.12484 = &file_share->handle_refs;
  InterlockedIncrement (D.12484);
  exists = 1;
  goto <D.11245>;
  <D.12508>:
  <D.12505>:
  <D.11244>:
  i = i + 1;
  <D.11247>:
  i.84 = (unsigned int) i;
  _wapi_fileshare_layout.83 = _wapi_fileshare_layout;
  D.12510 = _wapi_fileshare_layout.83->hwm;
  if (i.84 <= D.12510) goto <D.11246>; else goto <D.11245>;
  <D.11245>:
  if (exists == 0) goto <D.12511>; else goto <D.12512>;
  <D.12511>:
  D.12513 = i == 102400;
  D.12514 = first_unused == -1;
  D.12515 = D.12513 & D.12514;
  if (D.12515 != 0) goto <D.12516>; else goto <D.12517>;
  <D.12516>:
  goto <D.12518>;
  <D.12517>:
  if (first_unused == -1) goto <D.12519>; else goto <D.12520>;
  <D.12519>:
  _wapi_fileshare_layout.83 = _wapi_fileshare_layout;
  i = i + 1;
  file_share = &_wapi_fileshare_layout.83->share_info[i];
  _wapi_fileshare_layout.83 = _wapi_fileshare_layout;
  i.84 = (unsigned int) i;
  _wapi_fileshare_layout.83->hwm = i.84;
  goto <D.12521>;
  <D.12520>:
  _wapi_fileshare_layout.83 = _wapi_fileshare_layout;
  file_share = &_wapi_fileshare_layout.83->share_info[first_unused];
  <D.12521>:
  file_share->device = device;
  file_share->inode = inode;
  D.12522 = _wapi_getpid ();
  file_share->opened_by_pid = D.12522;
  file_share->sharemode = new_sharemode;
  file_share->access = new_access;
  file_share->handle_refs = 1;
  *share_info = file_share;
  <D.12518>:
  <D.12512>:
  D.12523 = *share_info;
  if (D.12523 != 0B) goto <D.12524>; else goto <D.12525>;
  <D.12524>:
  now.85 = (int) now;
  D.12523 = *share_info;
  D.12527 = &D.12523->timestamp;
  InterlockedExchange (D.12527, now.85);
  <D.12525>:
  <D.12494>:
  thr_ret = _wapi_shm_sem_unlock (2);
  _wapi_handle_unlock_shared_handles ();
  D.12528 = exists;
  return D.12528;
}


wapi_share_info_equal (const void * ka, const void * kb)
{
  gint D.12530;
  int iftmp.86;
  long long unsigned int D.12534;
  long long unsigned int D.12535;
  long long unsigned int D.12537;
  long long unsigned int D.12538;
  const struct _WapiFileShare * s1;
  const struct _WapiFileShare * s2;

  s1 = ka;
  s2 = kb;
  D.12534 = s1->device;
  D.12535 = s2->device;
  if (D.12534 == D.12535) goto <D.12536>; else goto <D.12532>;
  <D.12536>:
  D.12537 = s1->inode;
  D.12538 = s2->inode;
  if (D.12537 == D.12538) goto <D.12539>; else goto <D.12532>;
  <D.12539>:
  iftmp.86 = 1;
  goto <D.12533>;
  <D.12532>:
  iftmp.86 = 0;
  <D.12533>:
  D.12530 = iftmp.86;
  return D.12530;
}


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

  s = data;
  D.12542 = s->inode;
  D.12541 = (guint) D.12542;
  return D.12541;
}


_wapi_handle_check_share (struct _WapiFileShare * share_info, int fd)
{
  _Bool D.12544;
  long int D.12545;
  long int D.12546;
  int D.12551;
  int D.12554;
  struct _WapiHandleUnshared * D.12555;
  int D.12558;
  unsigned int D.12559;
  unsigned int D.12560;
  <unnamed type> D.12563;
  struct _WapiFileShare * D.12566;
  unsigned int i.87;
  unsigned int _wapi_fd_reserve.88;
  struct _WapiHandleSharedLayout * _wapi_shared_layout.89;
  <unnamed type> D.12571;
  int D.11283;
  int iftmp.90;
  int D.11282;
  const char[2] * D.12581;
  unsigned char D.12582;
  int D.12583;
  unsigned char D.12584;
  int D.12585;
  _Bool D.12586;
  _Bool D.12587;
  _Bool D.12588;
  const unsigned char * D.12591;
  unsigned char D.12592;
  int D.12593;
  const unsigned char * D.12594;
  unsigned char D.12595;
  int D.12596;
  _Bool D.12597;
  _Bool D.12598;
  const unsigned char * D.12601;
  unsigned char D.12602;
  int D.12603;
  const unsigned char * D.12604;
  unsigned char D.12605;
  int D.12606;
  _Bool D.12607;
  _Bool D.12608;
  const unsigned char * D.12611;
  unsigned char D.12612;
  int D.12613;
  const unsigned char * D.12614;
  unsigned char D.12615;
  int D.12616;
  char[256] * D.12618;
  int D.11292;
  int iftmp.91;
  int D.11291;
  const char[3] * D.12623;
  unsigned char D.12624;
  int D.12625;
  unsigned char D.12626;
  int D.12627;
  _Bool D.12628;
  _Bool D.12629;
  _Bool D.12630;
  const unsigned char * D.12633;
  unsigned char D.12634;
  int D.12635;
  const unsigned char * D.12636;
  unsigned char D.12637;
  int D.12638;
  _Bool D.12639;
  _Bool D.12640;
  const unsigned char * D.12643;
  unsigned char D.12644;
  int D.12645;
  const unsigned char * D.12646;
  unsigned char D.12647;
  int D.12648;
  _Bool D.12649;
  _Bool D.12650;
  const unsigned char * D.12653;
  unsigned char D.12654;
  int D.12655;
  const unsigned char * D.12656;
  unsigned char D.12657;
  int D.12658;
  int D.12662;
  long long unsigned int D.12663;
  long long unsigned int D.12664;
  long long unsigned int D.12667;
  long long unsigned int D.12668;
  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.12544 = thr_ret != 0;
  D.12545 = (long int) D.12544;
  D.12546 = __builtin_expect (D.12545, 0);
  if (D.12546 != 0) goto <D.12547>; else goto <D.12548>;
  <D.12547>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 1803, "thr_ret == 0");
  <D.12548>:
  thr_ret = _wapi_shm_sem_lock (2);
  D.12544 = thr_ret != 0;
  D.12545 = (long int) D.12544;
  D.12546 = __builtin_expect (D.12545, 0);
  if (D.12546 != 0) goto <D.12549>; else goto <D.12550>;
  <D.12549>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 1807, "thr_ret == 0");
  <D.12550>:
  D.12551 = access ("/proc", 0);
  if (D.12551 == -1) goto <D.12552>; else goto <D.12553>;
  <D.12552>:
  _wapi_handle_check_share_by_pid (share_info);
  goto done;
  <D.12553>:
  i = 0;
  goto <D.11265>;
  <D.11264>:
  D.12554 = i / 256;
  D.12555 = _wapi_private_handles[D.12554];
  if (D.12555 != 0B) goto <D.12556>; else goto <D.12557>;
  <D.12556>:
  {
    struct _WapiHandleUnshared * handle;

    D.12554 = i / 256;
    D.12555 = _wapi_private_handles[D.12554];
    D.12558 = i % 256;
    D.12559 = (unsigned int) D.12558;
    D.12560 = D.12559 * 136;
    handle = D.12555 + D.12560;
    if (i != fd) goto <D.12561>; else goto <D.12562>;
    <D.12561>:
    D.12563 = handle->type;
    if (D.12563 == 1) goto <D.12564>; else goto <D.12565>;
    <D.12564>:
    {
      struct _WapiHandle_file * file_handle;

      file_handle = &handle->u.file;
      D.12566 = file_handle->share_info;
      if (D.12566 == share_info) goto done; else goto <D.12567>;
      <D.12567>:
    }
    <D.12565>:
    <D.12562>:
  }
  <D.12557>:
  i = i + 1;
  <D.11265>:
  i.87 = (unsigned int) i;
  _wapi_fd_reserve.88 = _wapi_fd_reserve;
  if (i.87 < _wapi_fd_reserve.88) goto <D.11264>; else goto <D.11266>;
  <D.11266>:
  i = 0;
  goto <D.11297>;
  <D.11296>:
  {
    struct _WapiHandleShared * shared;
    struct _WapiHandle_process * process_handle;

    _wapi_shared_layout.89 = _wapi_shared_layout;
    shared = &_wapi_shared_layout.89->handles[i];
    D.12571 = shared->type;
    if (D.12571 == 9) goto <D.12572>; else goto <D.12573>;
    <D.12572>:
    {
      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.12574>; else goto <D.12575>;
          <D.12574>:
          // predicted unlikely by continue predictor.
          goto <D.11272>;
          <D.12575>:
          proc_fds = 1;
          goto <D.11293>;
          <D.11294>:
          {
            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.12579>; else goto <D.12580>;
                  <D.12579>:
                  {
                    const unsigned char * __s2;
                    int __result;

                    __s2 = &fd_entry->d_name;
                    D.12581 = ".";
                    D.12582 = MEM[(const unsigned char *)D.12581];
                    D.12583 = (int) D.12582;
                    D.12584 = *__s2;
                    D.12585 = (int) D.12584;
                    __result = D.12583 - D.12585;
                    {
                      D.12586 = __s2_len != 0;
                      D.12587 = __result == 0;
                      D.12588 = D.12586 & D.12587;
                      if (D.12588 != 0) goto <D.12589>; else goto <D.12590>;
                      <D.12589>:
                      D.12591 = &MEM[(void *)"." + 1B];
                      D.12592 = *D.12591;
                      D.12593 = (int) D.12592;
                      D.12594 = __s2 + 1;
                      D.12595 = *D.12594;
                      D.12596 = (int) D.12595;
                      __result = D.12593 - D.12596;
                      D.12597 = __s2_len > 1;
                      D.12587 = __result == 0;
                      D.12598 = D.12597 & D.12587;
                      if (D.12598 != 0) goto <D.12599>; else goto <D.12600>;
                      <D.12599>:
                      D.12601 = &MEM[(void *)"." + 2B];
                      D.12602 = *D.12601;
                      D.12603 = (int) D.12602;
                      D.12604 = __s2 + 2;
                      D.12605 = *D.12604;
                      D.12606 = (int) D.12605;
                      __result = D.12603 - D.12606;
                      D.12607 = __s2_len > 2;
                      D.12587 = __result == 0;
                      D.12608 = D.12607 & D.12587;
                      if (D.12608 != 0) goto <D.12609>; else goto <D.12610>;
                      <D.12609>:
                      D.12611 = &MEM[(void *)"." + 3B];
                      D.12612 = *D.12611;
                      D.12613 = (int) D.12612;
                      D.12614 = __s2 + 3;
                      D.12615 = *D.12614;
                      D.12616 = (int) D.12615;
                      __result = D.12613 - D.12616;
                      <D.12610>:
                      <D.12600>:
                      <D.12590>:
                    }
                    D.11282 = __result;
                  }
                  iftmp.90 = -D.11282;
                  goto <D.12617>;
                  <D.12580>:
                  D.12618 = &fd_entry->d_name;
                  iftmp.90 = __builtin_strcmp (D.12618, ".");
                  <D.12617>:
                  D.11283 = iftmp.90;
                }
                if (D.11283 == 0) goto <D.12576>; else goto <D.12619>;
                <D.12619>:
                {
                  size_t __s1_len;
                  size_t __s2_len;

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

                    __s2 = &fd_entry->d_name;
                    D.12623 = "..";
                    D.12624 = MEM[(const unsigned char *)D.12623];
                    D.12625 = (int) D.12624;
                    D.12626 = *__s2;
                    D.12627 = (int) D.12626;
                    __result = D.12625 - D.12627;
                    {
                      D.12628 = __s2_len != 0;
                      D.12629 = __result == 0;
                      D.12630 = D.12628 & D.12629;
                      if (D.12630 != 0) goto <D.12631>; else goto <D.12632>;
                      <D.12631>:
                      D.12633 = &MEM[(void *)".." + 1B];
                      D.12634 = *D.12633;
                      D.12635 = (int) D.12634;
                      D.12636 = __s2 + 1;
                      D.12637 = *D.12636;
                      D.12638 = (int) D.12637;
                      __result = D.12635 - D.12638;
                      D.12639 = __s2_len > 1;
                      D.12629 = __result == 0;
                      D.12640 = D.12639 & D.12629;
                      if (D.12640 != 0) goto <D.12641>; else goto <D.12642>;
                      <D.12641>:
                      D.12643 = &MEM[(void *)".." + 2B];
                      D.12644 = *D.12643;
                      D.12645 = (int) D.12644;
                      D.12646 = __s2 + 2;
                      D.12647 = *D.12646;
                      D.12648 = (int) D.12647;
                      __result = D.12645 - D.12648;
                      D.12649 = __s2_len > 2;
                      D.12629 = __result == 0;
                      D.12650 = D.12649 & D.12629;
                      if (D.12650 != 0) goto <D.12651>; else goto <D.12652>;
                      <D.12651>:
                      D.12653 = &MEM[(void *)".." + 3B];
                      D.12654 = *D.12653;
                      D.12655 = (int) D.12654;
                      D.12656 = __s2 + 3;
                      D.12657 = *D.12656;
                      D.12658 = (int) D.12657;
                      __result = D.12655 - D.12658;
                      <D.12652>:
                      <D.12642>:
                      <D.12632>:
                    }
                    D.11291 = __result;
                  }
                  iftmp.91 = -D.11291;
                  goto <D.12659>;
                  <D.12622>:
                  D.12618 = &fd_entry->d_name;
                  iftmp.91 = __builtin_strcmp (D.12618, "..");
                  <D.12659>:
                  D.11292 = iftmp.91;
                }
                if (D.11292 == 0) goto <D.12576>; else goto <D.12660>;
                <D.12660>:
                if (pid == self) goto <D.12661>; else goto <D.12577>;
                <D.12661>:
                D.12618 = &fd_entry->d_name;
                D.12662 = atoi (D.12618);
                if (D.12662 == fd) goto <D.12576>; else goto <D.12577>;
                <D.12576>:
                // predicted unlikely by continue predictor.
                goto <D.11293>;
                <D.12577>:
                D.12618 = &fd_entry->d_name;
                monoeg_g_snprintf (&path, 256, "/proc/%d/fd/%s", pid, D.12618);
                stat (&path, &link_stat);
                D.12663 = link_stat.st_dev;
                D.12664 = share_info->device;
                if (D.12663 == D.12664) goto <D.12665>; else goto <D.12666>;
                <D.12665>:
                D.12667 = link_stat.st_ino;
                D.12668 = share_info->inode;
                if (D.12667 == D.12668) goto <D.12669>; else goto <D.12670>;
                <D.12669>:
                found = 1;
                <D.12670>:
                <D.12666>:
              }
            finally
              {
                path = {CLOBBER};
                link_stat = {CLOBBER};
              }
          }
          <D.11293>:
          fd_entry = readdir (fd_dir);
          if (fd_entry != 0B) goto <D.11294>; else goto <D.11295>;
          <D.11295>:
          closedir (fd_dir);
        }
      finally
        {
          subdir = {CLOBBER};
        }
    }
    <D.12573>:
  }
  <D.11272>:
  i = i + 1;
  <D.11297>:
  if (i <= 255) goto <D.11296>; else goto <D.11298>;
  <D.11298>:
  if (proc_fds == 0) goto <D.12671>; else goto <D.12672>;
  <D.12671>:
  _wapi_handle_check_share_by_pid (share_info);
  goto <D.12673>;
  <D.12672>:
  if (found == 0) goto <D.12674>; else goto <D.12675>;
  <D.12674>:
  _wapi_free_share_info (share_info);
  <D.12675>:
  <D.12673>:
  done:
  thr_ret = _wapi_shm_sem_unlock (2);
  _wapi_handle_unlock_shared_handles ();
}


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

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


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

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


_wapi_handle_check_share_by_pid (struct _WapiFileShare * share_info)
{
  int D.12684;
  int D.12685;
  int * D.12688;
  int D.12689;
  _Bool D.12690;
  _Bool D.12691;
  _Bool D.12692;

  D.12684 = share_info->opened_by_pid;
  D.12685 = kill (D.12684, 0);
  if (D.12685 == -1) goto <D.12686>; else goto <D.12687>;
  <D.12686>:
  D.12688 = __errno_location ();
  D.12689 = *D.12688;
  D.12690 = D.12689 == 3;
  D.12691 = D.12689 == 1;
  D.12692 = D.12690 | D.12691;
  if (D.12692 != 0) goto <D.12693>; else goto <D.12694>;
  <D.12693>:
  _wapi_free_share_info (share_info);
  <D.12694>:
  <D.12687>:
}


_wapi_handle_dump ()
{
  long int D.12695;
  _Bool D.12698;
  long int D.12699;
  long int D.12700;
  struct _WapiHandleUnshared * D.12703;
  unsigned int D.12706;
  <unnamed type> D.12707;
  unsigned int D.12710;
  const char * iftmp.92;
  int D.12712;
  const char * D.12716;
  unsigned int D.12717;
  unsigned int D.12718;
  void (*<Tb27>) (void *) D.12719;
  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.12720;
  unsigned int _wapi_private_handle_slot_count.93;
  struct _WapiHandleUnshared * handle_data;
  guint32 i;
  guint32 k;
  int thr_ret;

  {
    struct __pthread_unwind_buf_t __cancel_buf;
    void (*<Tbf>) (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.12695 = __builtin_expect (__not_first_call, 0);
        if (D.12695 != 0) goto <D.12696>; else goto <D.12697>;
        <D.12696>:
        __cancel_routine (__cancel_arg);
        __pthread_unwind_next (&__cancel_buf);
        <D.12697>:
        __pthread_register_cancel (&__cancel_buf);
        thr_ret = pthread_mutex_lock (&scan_mutex);
        D.12698 = thr_ret != 0;
        D.12699 = (long int) D.12698;
        D.12700 = __builtin_expect (D.12699, 0);
        if (D.12700 != 0) goto <D.12701>; else goto <D.12702>;
        <D.12701>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 1943, "thr_ret == 0");
        <D.12702>:
        i = 0;
        goto <D.11317>;
        <D.11316>:
        D.12703 = _wapi_private_handles[i];
        if (D.12703 != 0B) goto <D.12704>; else goto <D.12705>;
        <D.12704>:
        k = 0;
        goto <D.11314>;
        <D.11313>:
        D.12703 = _wapi_private_handles[i];
        D.12706 = k * 136;
        handle_data = D.12703 + D.12706;
        D.12707 = handle_data->type;
        if (D.12707 == 0) goto <D.12708>; else goto <D.12709>;
        <D.12708>:
        // predicted unlikely by continue predictor.
        goto <D.11312>;
        <D.12709>:
        D.12710 = handle_data->ref;
        D.12712 = handle_data->signalled;
        if (D.12712 != 0) goto <D.12713>; else goto <D.12714>;
        <D.12713>:
        iftmp.92 = "Sg";
        goto <D.12715>;
        <D.12714>:
        iftmp.92 = "Un";
        <D.12715>:
        D.12707 = handle_data->type;
        D.12716 = _wapi_handle_typename[D.12707];
        D.12717 = i * 256;
        D.12718 = D.12717 + k;
        monoeg_g_print ("%3x [%7s] %s %d ", D.12718, D.12716, iftmp.92, D.12710);
        D.12707 = handle_data->type;
        D.12719 = handle_details[D.12707];
        D.12720 = &handle_data->u;
        D.12719 (D.12720);
        monoeg_g_print ("\n");
        <D.11312>:
        k = k + 1;
        <D.11314>:
        if (k <= 255) goto <D.11313>; else goto <D.11315>;
        <D.11315>:
        <D.12705>:
        i = i + 1;
        <D.11317>:
        _wapi_private_handle_slot_count.93 = _wapi_private_handle_slot_count;
        if (i < _wapi_private_handle_slot_count.93) goto <D.11316>; else goto <D.11318>;
        <D.11318>:
        thr_ret = pthread_mutex_unlock (&scan_mutex);
        D.12698 = thr_ret != 0;
        D.12699 = (long int) D.12698;
        D.12700 = __builtin_expect (D.12699, 0);
        if (D.12700 != 0) goto <D.12722>; else goto <D.12723>;
        <D.12722>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 1966, "thr_ret == 0");
        <D.12723>:
        __pthread_unregister_cancel (&__cancel_buf);
        if (0 != 0) goto <D.12724>; else goto <D.12725>;
        <D.12724>:
        __cancel_routine (__cancel_arg);
        <D.12725>:
      }
    finally
      {
        __cancel_buf = {CLOBBER};
      }
  }
}


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

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


_wapi_handle_update_refs ()
{
  long int D.12729;
  _Bool D.12730;
  long int D.12731;
  long int D.12732;
  long int D.12737;
  struct _WapiHandleUnshared * D.12740;
  unsigned int D.12743;
  <unnamed type> D.12747;
  _Bool D.12748;
  _Bool D.12749;
  _Bool D.12750;
  <unnamed type> D.12752;
  struct _WapiHandleSharedLayout * _wapi_shared_layout.94;
  unsigned int D.12755;
  int now.95;
  guint32 * D.12757;
  struct _WapiFileShare * D.12760;
  _Bool D.12761;
  long int D.12762;
  long int D.12763;
  guint32 * D.12766;
  unsigned int _wapi_private_handle_slot_count.96;
  guint32 i;
  guint32 k;
  int thr_ret;
  guint32 now;

  D.12729 = time (0B);
  now = (guint32) D.12729;
  thr_ret = _wapi_handle_lock_shared_handles ();
  D.12730 = thr_ret != 0;
  D.12731 = (long int) D.12730;
  D.12732 = __builtin_expect (D.12731, 0);
  if (D.12732 != 0) goto <D.12733>; else goto <D.12734>;
  <D.12733>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 1984, "thr_ret == 0");
  <D.12734>:
  thr_ret = _wapi_shm_sem_lock (2);
  D.12730 = thr_ret != 0;
  D.12731 = (long int) D.12730;
  D.12732 = __builtin_expect (D.12731, 0);
  if (D.12732 != 0) goto <D.12735>; else goto <D.12736>;
  <D.12735>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 1988, "thr_ret == 0");
  <D.12736>:
  {
    struct __pthread_unwind_buf_t __cancel_buf;
    void (*<Tbf>) (void *) __cancel_routine;
    void * __cancel_arg;
    int __not_first_call;

    try
      {
        __cancel_routine = mono_mutex_unlock_in_cleanup;
        __cancel_arg = &scan_mutex;
        __not_first_call = __sigsetjmp (&__cancel_buf.__cancel_jmp_buf, 0);
        D.12737 = __builtin_expect (__not_first_call, 0);
        if (D.12737 != 0) goto <D.12738>; else goto <D.12739>;
        <D.12738>:
        __cancel_routine (__cancel_arg);
        __pthread_unwind_next (&__cancel_buf);
        <D.12739>:
        __pthread_register_cancel (&__cancel_buf);
        thr_ret = pthread_mutex_lock (&scan_mutex);
        i = 0;
        goto <D.11343>;
        <D.11342>:
        D.12740 = _wapi_private_handles[i];
        if (D.12740 != 0B) goto <D.12741>; else goto <D.12742>;
        <D.12741>:
        k = 0;
        goto <D.11340>;
        <D.11339>:
        {
          struct _WapiHandleUnshared * handle;

          D.12740 = _wapi_private_handles[i];
          D.12743 = k * 136;
          handle = D.12740 + D.12743;
          D.12747 = handle->type;
          D.12748 = D.12747 == 9;
          D.12749 = D.12747 == 11;
          D.12750 = D.12748 | D.12749;
          if (D.12750 != 0) goto <D.12744>; else goto <D.12751>;
          <D.12751>:
          D.12752 = handle->type;
          if (D.12752 == 12) goto <D.12744>; else goto <D.12753>;
          <D.12753>:
          D.12752 = handle->type;
          if (D.12752 == 13) goto <D.12744>; else goto <D.12745>;
          <D.12744>:
          {
            struct _WapiHandleShared * shared_data;

            _wapi_shared_layout.94 = _wapi_shared_layout;
            D.12755 = handle->u.shared.offset;
            shared_data = &_wapi_shared_layout.94->handles[D.12755];
            now.95 = (int) now;
            D.12757 = &shared_data->timestamp;
            InterlockedExchange (D.12757, now.95);
          }
          goto <D.12746>;
          <D.12745>:
          D.12752 = handle->type;
          if (D.12752 == 1) goto <D.12758>; else goto <D.12759>;
          <D.12758>:
          {
            struct _WapiHandle_file * file_handle;

            file_handle = &handle->u.file;
            D.12760 = file_handle->share_info;
            D.12761 = D.12760 == 0B;
            D.12762 = (long int) D.12761;
            D.12763 = __builtin_expect (D.12762, 0);
            if (D.12763 != 0) goto <D.12764>; else goto <D.12765>;
            <D.12764>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 2014, "file_handle->share_info != NULL");
            <D.12765>:
            now.95 = (int) now;
            D.12760 = file_handle->share_info;
            D.12766 = &D.12760->timestamp;
            InterlockedExchange (D.12766, now.95);
          }
          <D.12759>:
          <D.12746>:
        }
        k = k + 1;
        <D.11340>:
        if (k <= 255) goto <D.11339>; else goto <D.11341>;
        <D.11341>:
        <D.12742>:
        i = i + 1;
        <D.11343>:
        _wapi_private_handle_slot_count.96 = _wapi_private_handle_slot_count;
        if (i < _wapi_private_handle_slot_count.96) goto <D.11342>; else goto <D.11344>;
        <D.11344>:
        thr_ret = pthread_mutex_unlock (&scan_mutex);
        D.12730 = thr_ret != 0;
        D.12731 = (long int) D.12730;
        D.12732 = __builtin_expect (D.12731, 0);
        if (D.12732 != 0) goto <D.12768>; else goto <D.12769>;
        <D.12768>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 2025, "thr_ret == 0");
        <D.12769>:
        __pthread_unregister_cancel (&__cancel_buf);
        if (0 != 0) goto <D.12770>; else goto <D.12771>;
        <D.12770>:
        __cancel_routine (__cancel_arg);
        <D.12771>:
      }
    finally
      {
        __cancel_buf = {CLOBBER};
      }
  }
  thr_ret = _wapi_shm_sem_unlock (2);
  _wapi_handle_unlock_shared_handles ();
}


