_wapi_getpid ()
{
  pid_t D.12234;

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


pid_init ()
{
  int _wapi_pid.0;

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


wapi_init ()
{
  int D.12239;
  unsigned int _wapi_fd_reserve.1;
  unsigned int _wapi_fd_reserve.2;
  unsigned int D.12242;
  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.12250;
  long int D.12251;
  long int D.12252;
  int D.12255;
  void * _wapi_fileshare_layout.10;
  struct _WapiFileShareLayout * _wapi_fileshare_layout.11;
  _Bool D.12260;
  long int D.12261;
  long int D.12262;
  int D.12265;
  void * _wapi_global_signal_handle.12;
  void * _wapi_global_signal_handle.13;
  long int _wapi_global_signal_handle.14;
  unsigned int D.12271;
  unsigned int D.12272;
  struct _WapiHandleUnshared * D.12273;
  long unsigned int D.12274;
  long unsigned int D.12275;
  long unsigned int D.12276;
  struct _WapiHandleUnshared * D.12277;
  union pthread_cond_t * _wapi_global_signal_cond.15;
  union mono_mutex_t * _wapi_global_signal_mutex.16;

  if (0 != 0) goto <D.12237>; else goto <D.12238>;
  <D.12237>:
  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.12238>:
  D.12239 = getdtablesize ();
  _wapi_fd_reserve.1 = (unsigned int) D.12239;
  _wapi_fd_reserve = _wapi_fd_reserve.1;
  _wapi_fd_reserve.2 = _wapi_fd_reserve;
  D.12242 = _wapi_fd_reserve.2 + 255;
  _wapi_fd_reserve.3 = D.12242 & 4294967040;
  _wapi_fd_reserve = _wapi_fd_reserve.3;
  <D.11727>:
  _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.11727>; else goto <D.11728>;
  <D.11728>:
  _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.12250 = _wapi_shared_layout.9 == 0B;
  D.12251 = (long int) D.12250;
  D.12252 = __builtin_expect (D.12251, 0);
  if (D.12252 != 0) goto <D.12253>; else goto <D.12254>;
  <D.12253>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 271, "_wapi_shared_layout != NULL");
  <D.12254>:
  D.12255 = _wapi_shm_enabled ();
  if (D.12255 != 0) goto <D.12256>; else goto <D.12257>;
  <D.12256>:
  _wapi_fileshare_layout.10 = _wapi_shm_attach (1);
  _wapi_fileshare_layout = _wapi_fileshare_layout.10;
  _wapi_fileshare_layout.11 = _wapi_fileshare_layout;
  D.12260 = _wapi_fileshare_layout.11 == 0B;
  D.12261 = (long int) D.12260;
  D.12262 = __builtin_expect (D.12261, 0);
  if (D.12262 != 0) goto <D.12263>; else goto <D.12264>;
  <D.12263>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 276, "_wapi_fileshare_layout != NULL");
  <D.12264>:
  <D.12257>:
  D.12265 = _wapi_shm_enabled ();
  if (D.12265 != 0) goto <D.12266>; else goto <D.12267>;
  <D.12266>:
  _wapi_collection_init ();
  <D.12267>:
  _wapi_io_init ();
  pthread_mutex_init (&scan_mutex, 0B);
  _wapi_global_signal_handle.12 = _wapi_handle_new (6, 0B);
  _wapi_global_signal_handle = _wapi_global_signal_handle.12;
  _wapi_global_signal_handle.13 = _wapi_global_signal_handle;
  _wapi_global_signal_handle.14 = (long int) _wapi_global_signal_handle.13;
  D.12271 = (unsigned int) _wapi_global_signal_handle.14;
  D.12272 = D.12271 / 256;
  D.12273 = _wapi_private_handles[D.12272];
  _wapi_global_signal_handle.13 = _wapi_global_signal_handle;
  _wapi_global_signal_handle.14 = (long int) _wapi_global_signal_handle.13;
  D.12271 = (unsigned int) _wapi_global_signal_handle.14;
  D.12274 = (long unsigned int) D.12271;
  D.12275 = D.12274 & 255;
  D.12276 = D.12275 * 200;
  D.12277 = D.12273 + D.12276;
  _wapi_global_signal_cond.15 = &D.12277->signal_cond;
  _wapi_global_signal_cond = _wapi_global_signal_cond.15;
  _wapi_global_signal_handle.13 = _wapi_global_signal_handle;
  _wapi_global_signal_handle.14 = (long int) _wapi_global_signal_handle.13;
  D.12271 = (unsigned int) _wapi_global_signal_handle.14;
  D.12272 = D.12271 / 256;
  D.12273 = _wapi_private_handles[D.12272];
  _wapi_global_signal_handle.13 = _wapi_global_signal_handle;
  _wapi_global_signal_handle.14 = (long int) _wapi_global_signal_handle.13;
  D.12271 = (unsigned int) _wapi_global_signal_handle.14;
  D.12274 = (long unsigned int) D.12271;
  D.12275 = D.12274 & 255;
  D.12276 = D.12275 * 200;
  D.12277 = D.12273 + D.12276;
  _wapi_global_signal_mutex.16 = &D.12277->signal_mutex;
  _wapi_global_signal_mutex = _wapi_global_signal_mutex.16;
  atexit (handle_cleanup);
}


handle_cleanup ()
{
  struct _WapiHandleUnshared * D.12280;
  long unsigned int D.12281;
  long unsigned int D.12282;
  <unnamed type> D.12283;
  int D.12284;
  int D.12285;
  long int D.12286;
  unsigned int D.12296;
  struct GHashTable * file_share_hash.17;
  int i;
  int j;
  int k;

  i = 0;
  goto <D.11719>;
  <D.11718>:
  j = 0;
  goto <D.11716>;
  <D.11715>:
  {
    struct _WapiHandleUnshared * handle_data;
    int type;
    void * handle;

    D.12280 = _wapi_private_handles[i];
    D.12281 = (long unsigned int) j;
    D.12282 = D.12281 * 200;
    handle_data = D.12280 + D.12282;
    D.12283 = handle_data->type;
    type = (int) D.12283;
    D.12284 = i * 256;
    D.12285 = D.12284 + j;
    D.12286 = (long int) D.12285;
    handle = (void *) D.12286;
    if (type == 9) goto <D.12287>; else goto <D.12289>;
    <D.12289>:
    if (type == 11) goto <D.12287>; else goto <D.12290>;
    <D.12290>:
    if (type == 12) goto <D.12287>; else goto <D.12291>;
    <D.12291>:
    if (type == 13) goto <D.12287>; else goto <D.12288>;
    <D.12287>:
    if (type == 3) goto <D.12292>; else goto <D.12293>;
    <D.12292>:
    if (1 != 0) goto <D.12294>; else goto <D.12295>;
    <D.12294>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 211, "0");
    <D.12295>:
    _wapi_thread_set_termination_details (handle, 0);
    <D.12293>:
    <D.12288>:
    D.12296 = handle_data->ref;
    k = (int) D.12296;
    goto <D.11713>;
    <D.11712>:
    _wapi_handle_unref_full (handle, 1);
    k = k + -1;
    <D.11713>:
    if (k > 0) goto <D.11712>; else goto <D.11714>;
    <D.11714>:
  }
  j = j + 1;
  <D.11716>:
  if (j <= 255) goto <D.11715>; else goto <D.11717>;
  <D.11717>:
  i = i + 1;
  <D.11719>:
  D.12280 = _wapi_private_handles[i];
  if (D.12280 != 0B) goto <D.11718>; else goto <D.11720>;
  <D.11720>:
  _wapi_shm_semaphores_remove ();
  _wapi_shm_detach (0);
  _wapi_shm_detach (1);
  file_share_hash.17 = file_share_hash;
  if (file_share_hash.17 != 0B) goto <D.12298>; else goto <D.12299>;
  <D.12298>:
  file_share_hash.17 = file_share_hash;
  monoeg_g_hash_table_destroy (file_share_hash.17);
  DeleteCriticalSection (&file_share_hash_mutex);
  <D.12299>:
  i = 0;
  goto <D.11722>;
  <D.11721>:
  D.12280 = _wapi_private_handles[i];
  monoeg_g_free (D.12280);
  i = i + 1;
  <D.11722>:
  if (i <= 16383) goto <D.11721>; else goto <D.11723>;
  <D.11723>:
}


_wapi_handle_unref_full (void * handle, gboolean ignore_private_busy_handles)
{
  long int handle.18;
  <unnamed type> D.12303;
  unsigned int D.12306;
  struct _WapiHandleUnshared * D.12307;
  long unsigned int D.12308;
  long unsigned int D.12309;
  long unsigned int D.12310;
  struct _WapiHandleUnshared * D.12311;
  guint * D.12312;
  int D.12313;
  _Bool D.12314;
  int iftmp.19;
  _Bool D.12326;
  long int D.12327;
  long int D.12328;
  long int D.12331;
  long int D.12332;
  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.12335;
  union mono_mutex_t * D.12338;
  union pthread_cond_t * D.12345;
  struct _WapiHandleSharedLayout * _wapi_shared_layout.20;
  unsigned int D.12354;
  unsigned int D.12355;
  unsigned int D.12358;
  guint32 idx;
  gboolean destroy;
  gboolean early_exit;
  int thr_ret;
  static const char __func__[24] = "_wapi_handle_unref_full";

  handle.18 = (long int) handle;
  idx = (guint32) handle.18;
  destroy = 0;
  early_exit = 0;
  if (idx > 4194303) goto <D.12301>; else goto <D.12302>;
  <D.12301>:
  return;
  <D.12302>:
  D.12303 = _wapi_handle_type (handle);
  if (D.12303 == 0) goto <D.12304>; else goto <D.12305>;
  <D.12304>:
  monoeg_g_log (0B, 16, "%s: Attempting to unref unused handle %p", &__func__, handle);
  return;
  <D.12305>:
  D.12306 = idx / 256;
  D.12307 = _wapi_private_handles[D.12306];
  D.12308 = (long unsigned int) idx;
  D.12309 = D.12308 & 255;
  D.12310 = D.12309 * 200;
  D.12311 = D.12307 + D.12310;
  D.12312 = &D.12311->ref;
  D.12313 = InterlockedDecrement (D.12312);
  D.12314 = D.12313 == 0;
  destroy = (gboolean) D.12314;
  if (destroy == 1) goto <D.12315>; else goto <D.12316>;
  <D.12315>:
  {
    struct _WapiHandleUnshared handle_data;
    struct _WapiHandleShared shared_handle_data;
    WapiHandleType type;
    void (*<Tc9c>) (void *, void *) close_func;
    gboolean is_shared;

    try
      {
        D.12306 = idx / 256;
        D.12307 = _wapi_private_handles[D.12306];
        D.12308 = (long unsigned int) idx;
        D.12309 = D.12308 & 255;
        D.12310 = D.12309 * 200;
        D.12311 = D.12307 + D.12310;
        type = D.12311->type;
        close_func = _wapi_handle_ops_get_close_func (type);
        if (type == 9) goto <D.12318>; else goto <D.12321>;
        <D.12321>:
        if (type == 11) goto <D.12318>; else goto <D.12322>;
        <D.12322>:
        if (type == 12) goto <D.12318>; else goto <D.12323>;
        <D.12323>:
        if (type == 13) goto <D.12318>; else goto <D.12319>;
        <D.12318>:
        iftmp.19 = 1;
        goto <D.12320>;
        <D.12319>:
        iftmp.19 = 0;
        <D.12320>:
        is_shared = iftmp.19;
        if (is_shared != 0) goto <D.12324>; else goto <D.12325>;
        <D.12324>:
        thr_ret = _wapi_handle_lock_shared_handles ();
        D.12326 = thr_ret != 0;
        D.12327 = (long int) D.12326;
        D.12328 = __builtin_expect (D.12327, 0);
        if (D.12328 != 0) goto <D.12329>; else goto <D.12330>;
        <D.12329>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 1080, "thr_ret == 0");
        <D.12330>:
        <D.12325>:
        {
          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.12331 = (long int) __not_first_call;
              D.12332 = __builtin_expect (D.12331, 0);
              if (D.12332 != 0) goto <D.12333>; else goto <D.12334>;
              <D.12333>:
              __cancel_routine (__cancel_arg);
              __pthread_unwind_next (&__cancel_buf);
              <D.12334>:
              __pthread_register_cancel (&__cancel_buf);
              thr_ret = pthread_mutex_lock (&scan_mutex);
              D.12306 = idx / 256;
              D.12307 = _wapi_private_handles[D.12306];
              D.12308 = (long unsigned int) idx;
              D.12309 = D.12308 & 255;
              D.12310 = D.12309 * 200;
              D.12311 = D.12307 + D.12310;
              memcpy (&handle_data, D.12311, 200);
              D.12306 = idx / 256;
              D.12307 = _wapi_private_handles[D.12306];
              D.12308 = (long unsigned int) idx;
              D.12309 = D.12308 & 255;
              D.12310 = D.12309 * 200;
              D.12311 = D.12307 + D.12310;
              D.12335 = &D.12311->u;
              memset (D.12335, 0, 96);
              D.12306 = idx / 256;
              D.12307 = _wapi_private_handles[D.12306];
              D.12308 = (long unsigned int) idx;
              D.12309 = D.12308 & 255;
              D.12310 = D.12309 * 200;
              D.12311 = D.12307 + D.12310;
              D.12311->type = 0;
              if (is_shared == 0) goto <D.12336>; else goto <D.12337>;
              <D.12336>:
              D.12306 = idx / 256;
              D.12307 = _wapi_private_handles[D.12306];
              D.12308 = (long unsigned int) idx;
              D.12309 = D.12308 & 255;
              D.12310 = D.12309 * 200;
              D.12311 = D.12307 + D.12310;
              D.12338 = &D.12311->signal_mutex;
              thr_ret = pthread_mutex_destroy (D.12338);
              if (thr_ret == 16) goto <D.12341>; else goto <D.12339>;
              <D.12341>:
              if (ignore_private_busy_handles != 0) goto <D.12342>; else goto <D.12339>;
              <D.12342>:
              early_exit = 1;
              goto <D.12340>;
              <D.12339>:
              if (thr_ret != 0) goto <D.12343>; else goto <D.12344>;
              <D.12343>:
              monoeg_g_log (0B, 4, "Error destroying handle %p mutex due to %d\n", handle, thr_ret);
              <D.11965>:
              goto <D.11965>;
              <D.12344>:
              D.12306 = idx / 256;
              D.12307 = _wapi_private_handles[D.12306];
              D.12308 = (long unsigned int) idx;
              D.12309 = D.12308 & 255;
              D.12310 = D.12309 * 200;
              D.12311 = D.12307 + D.12310;
              D.12345 = &D.12311->signal_cond;
              thr_ret = pthread_cond_destroy (D.12345);
              if (thr_ret == 16) goto <D.12348>; else goto <D.12346>;
              <D.12348>:
              if (ignore_private_busy_handles != 0) goto <D.12349>; else goto <D.12346>;
              <D.12349>:
              early_exit = 1;
              goto <D.12347>;
              <D.12346>:
              if (thr_ret != 0) goto <D.12350>; else goto <D.12351>;
              <D.12350>:
              monoeg_g_log (0B, 4, "Error destroying handle %p cond var due to %d\n", handle, thr_ret);
              <D.11966>:
              goto <D.11966>;
              <D.12351>:
              <D.12347>:
              <D.12340>:
              goto <D.12352>;
              <D.12337>:
              {
                struct _WapiHandleShared * shared;

                _wapi_shared_layout.20 = _wapi_shared_layout;
                D.12354 = handle_data.u.shared.offset;
                shared = &_wapi_shared_layout.20->handles[D.12354];
                memcpy (&shared_handle_data, shared, 336);
                D.12355 = shared->handle_refs;
                if (D.12355 != 0) goto <D.12356>; else goto <D.12357>;
                <D.12356>:
                D.12355 = shared->handle_refs;
                D.12358 = D.12355 + 4294967295;
                shared->handle_refs = D.12358;
                D.12355 = shared->handle_refs;
                if (D.12355 == 0) goto <D.12359>; else goto <D.12360>;
                <D.12359>:
                memset (shared, 0, 336);
                <D.12360>:
                <D.12357>:
              }
              <D.12352>:
              thr_ret = pthread_mutex_unlock (&scan_mutex);
              D.12326 = thr_ret != 0;
              D.12327 = (long int) D.12326;
              D.12328 = __builtin_expect (D.12327, 0);
              if (D.12328 != 0) goto <D.12361>; else goto <D.12362>;
              <D.12361>:
              monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 1138, "thr_ret == 0");
              <D.12362>:
              __pthread_unregister_cancel (&__cancel_buf);
              if (0 != 0) goto <D.12363>; else goto <D.12364>;
              <D.12363>:
              __cancel_routine (__cancel_arg);
              <D.12364>:
            }
          finally
            {
              __cancel_buf = {CLOBBER};
            }
        }
        if (early_exit != 0) goto <D.12365>; else goto <D.12366>;
        <D.12365>:
        return;
        <D.12366>:
        if (is_shared != 0) goto <D.12367>; else goto <D.12368>;
        <D.12367>:
        _wapi_handle_unlock_shared_handles ();
        <D.12368>:
        if (close_func != 0B) goto <D.12369>; else goto <D.12370>;
        <D.12369>:
        if (is_shared != 0) goto <D.12371>; else goto <D.12372>;
        <D.12371>:
        close_func (handle, &shared_handle_data.u);
        goto <D.12373>;
        <D.12372>:
        close_func (handle, &handle_data.u);
        <D.12373>:
        <D.12370>:
      }
    finally
      {
        handle_data = {CLOBBER};
        shared_handle_data = {CLOBBER};
      }
  }
  <D.12316>:
}


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

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


_wapi_handle_type (void * handle)
{
  long int handle.21;
  unsigned int D.12390;
  struct _WapiHandleUnshared * D.12391;
  WapiHandleType D.12392;
  unsigned int D.12393;
  struct _WapiHandleUnshared * D.12394;
  long unsigned int D.12395;
  long unsigned int D.12396;
  long unsigned int D.12397;
  struct _WapiHandleUnshared * D.12398;
  guint32 idx;

  handle.21 = (long int) handle;
  idx = (guint32) handle.21;
  if (idx > 4194303) goto <D.12386>; else goto <D.12388>;
  <D.12388>:
  if (idx > 268435455) goto <D.12386>; else goto <D.12389>;
  <D.12389>:
  D.12390 = idx / 256;
  D.12391 = _wapi_private_handles[D.12390];
  if (D.12391 == 0B) goto <D.12386>; else goto <D.12387>;
  <D.12386>:
  D.12392 = 0;
  return D.12392;
  <D.12387>:
  D.12393 = idx / 256;
  D.12394 = _wapi_private_handles[D.12393];
  D.12395 = (long unsigned int) idx;
  D.12396 = D.12395 & 255;
  D.12397 = D.12396 * 200;
  D.12398 = D.12394 + D.12397;
  D.12392 = D.12398->type;
  return D.12392;
}


InterlockedDecrement (volatile gint32 * val)
{
  gint32 D.12400;
  unsigned int D.12401;

  D.12401 = __sync_sub_and_fetch_4 (val, 1);
  D.12400 = (gint32) D.12401;
  return D.12400;
}


_wapi_handle_ops_get_close_func (WapiHandleType type)
{
  struct _WapiHandleOps * D.12403;
  void (*<Tc9c>) (void *, void *) D.12406;
  void (*<Tc9c>) (void *, void *) D.12409;

  D.12403 = handle_ops[type];
  if (D.12403 != 0B) goto <D.12404>; else goto <D.12405>;
  <D.12404>:
  D.12403 = handle_ops[type];
  D.12406 = D.12403->close;
  if (D.12406 != 0B) goto <D.12407>; else goto <D.12408>;
  <D.12407>:
  D.12403 = handle_ops[type];
  D.12409 = D.12403->close;
  return D.12409;
  <D.12408>:
  <D.12405>:
  D.12409 = 0B;
  return D.12409;
}


_wapi_handle_lock_shared_handles ()
{
  int D.12411;

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


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

  D.12414 = __builtin_object_size (__dest, 0);
  D.12413 = __builtin___memcpy_chk (__dest, __src, __len, D.12414);
  return D.12413;
}


memset (void * __dest, int __ch, size_t __len)
{
  int D.12418;
  int D.12423;
  void * D.12425;
  long unsigned int D.12426;

  D.12418 = __builtin_constant_p (__len);
  if (D.12418 != 0) goto <D.12419>; else goto <D.12420>;
  <D.12419>:
  if (__len == 0) goto <D.12421>; else goto <D.12422>;
  <D.12421>:
  D.12423 = __builtin_constant_p (__ch);
  if (D.12423 == 0) goto <D.12416>; else goto <D.12424>;
  <D.12424>:
  if (__ch != 0) goto <D.12416>; else goto <D.12417>;
  <D.12416>:
  __warn_memset_zero_len ();
  D.12425 = __dest;
  return D.12425;
  <D.12417>:
  <D.12422>:
  <D.12420>:
  D.12426 = __builtin_object_size (__dest, 0);
  D.12425 = __builtin___memset_chk (__dest, __ch, __len, D.12426);
  return D.12425;
}


_wapi_handle_unlock_shared_handles ()
{
  int D.12428;

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


wapi_cleanup ()
{
  int _wapi_has_shut_down.22;
  _Bool D.12431;
  long int D.12432;
  long int D.12433;

  _wapi_has_shut_down.22 = _wapi_has_shut_down;
  D.12431 = _wapi_has_shut_down.22 != 0;
  D.12432 = (long int) D.12431;
  D.12433 = __builtin_expect (D.12432, 0);
  if (D.12433 != 0) goto <D.12434>; else goto <D.12435>;
  <D.12434>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 303, "_wapi_has_shut_down == FALSE");
  <D.12435>:
  _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.12437;
  long int D.12438;
  long int D.12439;
  int iftmp.24;
  unsigned int D.12446;
  _Bool D.12449;
  long int D.12450;
  long int D.12451;
  long int D.12454;
  long int D.12455;
  _Bool D.12458;
  long int D.12459;
  long int D.12460;
  unsigned int _wapi_private_handle_count.25;
  unsigned int D.12464;
  void * D.12466;
  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.12477;
  long int D.12478;
  long int D.12479;
  long unsigned int D.12482;
  unsigned int D.12492;
  struct _WapiHandleUnshared * D.12493;
  long unsigned int D.12494;
  long unsigned int D.12495;
  struct _WapiHandleUnshared * D.12496;
  void * D.12497;
  guint32 handle_idx;
  void * handle;
  int thr_ret;
  void done = <<< error >>>;

  handle_idx = 0;
  _wapi_has_shut_down.23 = _wapi_has_shut_down;
  D.12437 = _wapi_has_shut_down.23 != 0;
  D.12438 = (long int) D.12437;
  D.12439 = __builtin_expect (D.12438, 0);
  if (D.12439 != 0) goto <D.12440>; else goto <D.12441>;
  <D.12440>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 466, "_wapi_has_shut_down == FALSE");
  <D.12441>:
  D.12446 = type + 4294967295;
  if (D.12446 <= 1) goto <D.12443>; else goto <D.12447>;
  <D.12447>:
  if (type == 7) goto <D.12443>; else goto <D.12448>;
  <D.12448>:
  if (type == 10) goto <D.12443>; else goto <D.12444>;
  <D.12443>:
  iftmp.24 = 1;
  goto <D.12445>;
  <D.12444>:
  iftmp.24 = 0;
  <D.12445>:
  D.12449 = iftmp.24 != 0;
  D.12450 = (long int) D.12449;
  D.12451 = __builtin_expect (D.12450, 0);
  if (D.12451 != 0) goto <D.12452>; else goto <D.12453>;
  <D.12452>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 471, "!_WAPI_FD_HANDLE(type)");
  <D.12453>:
  {
    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.12454 = (long int) __not_first_call;
        D.12455 = __builtin_expect (D.12454, 0);
        if (D.12455 != 0) goto <D.12456>; else goto <D.12457>;
        <D.12456>:
        __cancel_routine (__cancel_arg);
        __pthread_unwind_next (&__cancel_buf);
        <D.12457>:
        __pthread_register_cancel (&__cancel_buf);
        thr_ret = pthread_mutex_lock (&scan_mutex);
        D.12458 = thr_ret != 0;
        D.12459 = (long int) D.12458;
        D.12460 = __builtin_expect (D.12459, 0);
        if (D.12460 != 0) goto <D.12461>; else goto <D.12462>;
        <D.12461>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 476, "thr_ret == 0");
        <D.12462>:
        goto <D.11788>;
        <D.11787>:
        {
          int idx;

          _wapi_private_handle_count.25 = _wapi_private_handle_count;
          D.12464 = _wapi_private_handle_count.25 / 256;
          idx = (int) D.12464;
          if (idx > 16383) goto <D.11786>; else goto <D.12465>;
          <D.12465>:
          D.12466 = monoeg_malloc0 (51200);
          _wapi_private_handles[idx] = D.12466;
          _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.11788>:
        handle_idx = _wapi_handle_new_internal (type, handle_specific);
        if (handle_idx == 0) goto <D.11787>; else goto <D.11786>;
        <D.11786>:
        thr_ret = pthread_mutex_unlock (&scan_mutex);
        D.12458 = thr_ret != 0;
        D.12459 = (long int) D.12458;
        D.12460 = __builtin_expect (D.12459, 0);
        if (D.12460 != 0) goto <D.12470>; else goto <D.12471>;
        <D.12470>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 493, "thr_ret == 0");
        <D.12471>:
        __pthread_unregister_cancel (&__cancel_buf);
        if (0 != 0) goto <D.12472>; else goto <D.12473>;
        <D.12472>:
        __cancel_routine (__cancel_arg);
        <D.12473>:
      }
    finally
      {
        __cancel_buf = {CLOBBER};
      }
  }
  if (handle_idx == 0) goto <D.12474>; else goto <D.12475>;
  <D.12474>:
  handle = -1B;
  goto done;
  <D.12475>:
  _wapi_fd_reserve.29 = _wapi_fd_reserve;
  D.12477 = handle_idx < _wapi_fd_reserve.29;
  D.12478 = (long int) D.12477;
  D.12479 = __builtin_expect (D.12478, 0);
  if (D.12479 != 0) goto <D.12480>; else goto <D.12481>;
  <D.12480>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 503, "handle_idx >= _wapi_fd_reserve");
  <D.12481>:
  D.12482 = (long unsigned int) handle_idx;
  handle = (void *) D.12482;
  if (type == 9) goto <D.12483>; else goto <D.12485>;
  <D.12485>:
  if (type == 11) goto <D.12483>; else goto <D.12486>;
  <D.12486>:
  if (type == 12) goto <D.12483>; else goto <D.12487>;
  <D.12487>:
  if (type == 13) goto <D.12483>; else goto <D.12484>;
  <D.12483>:
  {
    guint32 ref;

    ref = _wapi_handle_new_shared (type, handle_specific);
    if (ref == 0) goto <D.12488>; else goto <D.12489>;
    <D.12488>:
    _wapi_handle_collect ();
    ref = _wapi_handle_new_shared (type, handle_specific);
    if (ref == 0) goto <D.12490>; else goto <D.12491>;
    <D.12490>:
    handle = -1B;
    goto done;
    <D.12491>:
    <D.12489>:
    D.12492 = handle_idx / 256;
    D.12493 = _wapi_private_handles[D.12492];
    D.12482 = (long unsigned int) handle_idx;
    D.12494 = D.12482 & 255;
    D.12495 = D.12494 * 200;
    D.12496 = D.12493 + D.12495;
    D.12496->u.shared.offset = ref;
  }
  <D.12484>:
  done:
  D.12497 = handle;
  return D.12497;
}


_wapi_handle_new_internal (WapiHandleType type, void * handle_specific)
{
  int _wapi_has_shut_down.30;
  _Bool D.12506;
  long int D.12507;
  long int D.12508;
  unsigned int last.31;
  unsigned int _wapi_fd_reserve.32;
  struct _WapiHandleUnshared * D.12516;
  long unsigned int D.12519;
  long unsigned int D.12520;
  <unnamed type> D.12521;
  unsigned int last.33;
  guint32 D.12525;
  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.12506 = _wapi_has_shut_down.30 != 0;
  D.12507 = (long int) D.12506;
  D.12508 = __builtin_expect (D.12507, 0);
  if (D.12508 != 0) goto <D.12509>; else goto <D.12510>;
  <D.12509>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 416, "_wapi_has_shut_down == FALSE");
  <D.12510>:
  last.31 = last;
  _wapi_fd_reserve.32 = _wapi_fd_reserve;
  if (last.31 < _wapi_fd_reserve.32) goto <D.12513>; else goto <D.12514>;
  <D.12513>:
  _wapi_fd_reserve.32 = _wapi_fd_reserve;
  last = _wapi_fd_reserve.32;
  goto <D.12515>;
  <D.12514>:
  retry = 1;
  <D.12515>:
  again:
  count = last;
  i = count / 256;
  goto <D.11770>;
  <D.11769>:
  D.12516 = _wapi_private_handles[i];
  if (D.12516 != 0B) goto <D.12517>; else goto <D.12518>;
  <D.12517>:
  k = count & 255;
  goto <D.11767>;
  <D.11766>:
  {
    struct _WapiHandleUnshared * handle;

    D.12516 = _wapi_private_handles[i];
    D.12519 = (long unsigned int) k;
    D.12520 = D.12519 * 200;
    handle = D.12516 + D.12520;
    D.12521 = handle->type;
    if (D.12521 == 0) goto <D.12522>; else goto <D.12523>;
    <D.12522>:
    last.33 = count + 1;
    last = last.33;
    _wapi_handle_init (handle, type, handle_specific);
    D.12525 = count;
    return D.12525;
    <D.12523>:
    count = count + 1;
  }
  k = k + 1;
  <D.11767>:
  if (k <= 255) goto <D.11766>; else goto <D.11768>;
  <D.11768>:
  <D.12518>:
  i = i + 1;
  <D.11770>:
  _wapi_private_handle_slot_count.34 = _wapi_private_handle_slot_count;
  if (i < _wapi_private_handle_slot_count.34) goto <D.11769>; else goto <D.11771>;
  <D.11771>:
  if (retry != 0) goto <D.12527>; else goto <D.12528>;
  <D.12527>:
  last.31 = last;
  _wapi_fd_reserve.32 = _wapi_fd_reserve;
  if (last.31 > _wapi_fd_reserve.32) goto <D.12529>; else goto <D.12530>;
  <D.12529>:
  _wapi_fd_reserve.32 = _wapi_fd_reserve;
  last = _wapi_fd_reserve.32;
  goto again;
  <D.12530>:
  <D.12528>:
  D.12525 = 0;
  return D.12525;
}


_wapi_handle_init (struct _WapiHandleUnshared * handle, WapiHandleType type, void * handle_specific)
{
  int _wapi_has_shut_down.35;
  _Bool D.12533;
  long int D.12534;
  long int D.12535;
  union pthread_cond_t * D.12546;
  _Bool D.12547;
  long int D.12548;
  long int D.12549;
  union mono_mutex_t * D.12552;
  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.12557;
  int thr_ret;

  _wapi_has_shut_down.35 = _wapi_has_shut_down;
  D.12533 = _wapi_has_shut_down.35 != 0;
  D.12534 = (long int) D.12533;
  D.12535 = __builtin_expect (D.12534, 0);
  if (D.12535 != 0) goto <D.12536>; else goto <D.12537>;
  <D.12536>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 332, "_wapi_has_shut_down == FALSE");
  <D.12537>:
  handle->type = type;
  handle->signalled = 0;
  handle->ref = 1;
  if (type != 9) goto <D.12538>; else goto <D.12539>;
  <D.12538>:
  if (type != 11) goto <D.12540>; else goto <D.12541>;
  <D.12540>:
  if (type != 12) goto <D.12542>; else goto <D.12543>;
  <D.12542>:
  if (type != 13) goto <D.12544>; else goto <D.12545>;
  <D.12544>:
  D.12546 = &handle->signal_cond;
  thr_ret = pthread_cond_init (D.12546, 0B);
  D.12547 = thr_ret != 0;
  D.12548 = (long int) D.12547;
  D.12549 = __builtin_expect (D.12548, 0);
  if (D.12549 != 0) goto <D.12550>; else goto <D.12551>;
  <D.12550>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 340, "thr_ret == 0");
  <D.12551>:
  D.12552 = &handle->signal_mutex;
  thr_ret = pthread_mutex_init (D.12552, 0B);
  D.12547 = thr_ret != 0;
  D.12548 = (long int) D.12547;
  D.12549 = __builtin_expect (D.12548, 0);
  if (D.12549 != 0) goto <D.12553>; else goto <D.12554>;
  <D.12553>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 343, "thr_ret == 0");
  <D.12554>:
  if (handle_specific != 0B) goto <D.12555>; else goto <D.12556>;
  <D.12555>:
  D.12557 = &handle->u;
  memcpy (D.12557, handle_specific, 96);
  <D.12556>:
  <D.12545>:
  <D.12543>:
  <D.12541>:
  <D.12539>:
}


_wapi_handle_new_shared (WapiHandleType type, void * handle_specific)
{
  int _wapi_has_shut_down.36;
  _Bool D.12559;
  long int D.12560;
  long int D.12561;
  struct _WapiHandleSharedLayout * _wapi_shared_layout.37;
  <unnamed type> D.12565;
  _Bool D.12568;
  long int D.12569;
  long int D.12570;
  WapiHandleType * D.12573;
  int type.38;
  int D.12575;
  unsigned int last.39;
  guint32 D.12579;
  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.12559 = _wapi_has_shut_down.36 != 0;
  D.12560 = (long int) D.12559;
  D.12561 = __builtin_expect (D.12560, 0);
  if (D.12561 != 0) goto <D.12562>; else goto <D.12563>;
  <D.12562>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 359, "_wapi_has_shut_down == FALSE");
  <D.12563>:
  again:
  offset = last;
  goto <D.11753>;
  <D.11752>:
  {
    struct _WapiHandleShared * handle;

    _wapi_shared_layout.37 = _wapi_shared_layout;
    handle = &_wapi_shared_layout.37->handles[offset];
    D.12565 = handle->type;
    if (D.12565 == 0) goto <D.12566>; else goto <D.12567>;
    <D.12566>:
    thr_ret = _wapi_handle_lock_shared_handles ();
    D.12568 = thr_ret != 0;
    D.12569 = (long int) D.12568;
    D.12570 = __builtin_expect (D.12569, 0);
    if (D.12570 != 0) goto <D.12571>; else goto <D.12572>;
    <D.12571>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 369, "thr_ret == 0");
    <D.12572>:
    D.12573 = &handle->type;
    type.38 = (int) type;
    D.12575 = InterlockedCompareExchange (D.12573, type.38, 0);
    if (D.12575 == 0) goto <D.12576>; else goto <D.12577>;
    <D.12576>:
    last.39 = offset + 1;
    last = last.39;
    _wapi_handle_init_shared (handle, type, handle_specific);
    _wapi_handle_unlock_shared_handles ();
    D.12579 = offset;
    return D.12579;
    <D.12577>:
    _wapi_handle_unlock_shared_handles ();
    <D.12567>:
  }
  offset = offset + 1;
  <D.11753>:
  if (offset <= 255) goto <D.11752>; else goto <D.11754>;
  <D.11754>:
  last.40 = last;
  if (last.40 > 1) goto <D.12581>; else goto <D.12582>;
  <D.12581>:
  last = 1;
  goto again;
  <D.12582>:
  D.12579 = 0;
  return D.12579;
}


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

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


_wapi_handle_init_shared (struct _WapiHandleShared * handle, WapiHandleType type, void * handle_specific)
{
  int _wapi_has_shut_down.43;
  _Bool D.12590;
  long int D.12591;
  long int D.12592;
  long int D.12595;
  unsigned int D.12596;
  union 
{
  struct _WapiHandle_process process;
  struct _WapiHandle_namedmutex namedmutex;
  struct _WapiHandle_namedsem namedsem;
  struct _WapiHandle_namedevent namedevent;
} * D.12599;

  _wapi_has_shut_down.43 = _wapi_has_shut_down;
  D.12590 = _wapi_has_shut_down.43 != 0;
  D.12591 = (long int) D.12590;
  D.12592 = __builtin_expect (D.12591, 0);
  if (D.12592 != 0) goto <D.12593>; else goto <D.12594>;
  <D.12593>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 315, "_wapi_has_shut_down == FALSE");
  <D.12594>:
  handle->type = type;
  D.12595 = time (0B);
  D.12596 = (unsigned int) D.12595;
  handle->timestamp = D.12596;
  handle->signalled = 0;
  handle->handle_refs = 1;
  if (handle_specific != 0B) goto <D.12597>; else goto <D.12598>;
  <D.12597>:
  D.12599 = &handle->u;
  memcpy (D.12599, handle_specific, 320);
  <D.12598>:
}


_wapi_handle_new_from_offset (WapiHandleType type, guint32 offset, gboolean timestamp)
{
  int _wapi_has_shut_down.44;
  _Bool D.12601;
  long int D.12602;
  long int D.12603;
  int iftmp.45;
  unsigned int D.12610;
  _Bool D.12613;
  long int D.12614;
  long int D.12615;
  int iftmp.46;
  _Bool D.12625;
  long int D.12626;
  long int D.12627;
  _Bool D.12630;
  long int D.12631;
  long int D.12632;
  struct _WapiHandleSharedLayout * _wapi_shared_layout.47;
  long int D.12638;
  guint32 * D.12639;
  int now.48;
  long int D.12641;
  long int D.12642;
  _Bool D.12645;
  long int D.12646;
  long int D.12647;
  struct _WapiHandleUnshared * D.12650;
  long unsigned int D.12653;
  long unsigned int D.12654;
  <unnamed type> D.12655;
  unsigned int D.12658;
  int D.12661;
  int D.12662;
  long unsigned int D.12663;
  unsigned int i.49;
  unsigned int _wapi_private_handle_slot_count.50;
  void * D.12672;
  <unnamed type> D.12675;
  long int D.12678;
  long int D.12679;
  unsigned int _wapi_private_handle_count.51;
  unsigned int D.12685;
  void * D.12686;
  unsigned int _wapi_private_handle_count.52;
  unsigned int _wapi_private_handle_slot_count.53;
  unsigned int _wapi_fd_reserve.54;
  _Bool D.12694;
  long int D.12695;
  long int D.12696;
  long unsigned int D.12699;
  unsigned int D.12700;
  struct _WapiHandleUnshared * D.12701;
  long unsigned int D.12702;
  long unsigned int D.12703;
  struct _WapiHandleUnshared * D.12704;
  guint32 * D.12705;
  guint32 handle_idx;
  void * handle;
  int thr_ret;
  int i;
  int k;
  struct _WapiHandleShared * shared;
  void first_pass_done = <<< error >>>;
  void done = <<< error >>>;

  handle_idx = 0;
  handle = -1B;
  _wapi_has_shut_down.44 = _wapi_has_shut_down;
  D.12601 = _wapi_has_shut_down.44 != 0;
  D.12602 = (long int) D.12601;
  D.12603 = __builtin_expect (D.12602, 0);
  if (D.12603 != 0) goto <D.12604>; else goto <D.12605>;
  <D.12604>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 541, "_wapi_has_shut_down == FALSE");
  <D.12605>:
  D.12610 = type + 4294967295;
  if (D.12610 <= 1) goto <D.12607>; else goto <D.12611>;
  <D.12611>:
  if (type == 7) goto <D.12607>; else goto <D.12612>;
  <D.12612>:
  if (type == 10) goto <D.12607>; else goto <D.12608>;
  <D.12607>:
  iftmp.45 = 1;
  goto <D.12609>;
  <D.12608>:
  iftmp.45 = 0;
  <D.12609>:
  D.12613 = iftmp.45 != 0;
  D.12614 = (long int) D.12613;
  D.12615 = __builtin_expect (D.12614, 0);
  if (D.12615 != 0) goto <D.12616>; else goto <D.12617>;
  <D.12616>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 546, "!_WAPI_FD_HANDLE(type)");
  <D.12617>:
  if (type != 9) goto <D.12621>; else goto <D.12619>;
  <D.12621>:
  if (type != 11) goto <D.12622>; else goto <D.12619>;
  <D.12622>:
  if (type != 12) goto <D.12623>; else goto <D.12619>;
  <D.12623>:
  if (type != 13) goto <D.12624>; else goto <D.12619>;
  <D.12624>:
  iftmp.46 = 1;
  goto <D.12620>;
  <D.12619>:
  iftmp.46 = 0;
  <D.12620>:
  D.12625 = iftmp.46 != 0;
  D.12626 = (long int) D.12625;
  D.12627 = __builtin_expect (D.12626, 0);
  if (D.12627 != 0) goto <D.12628>; else goto <D.12629>;
  <D.12628>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 547, "_WAPI_SHARED_HANDLE(type)");
  <D.12629>:
  D.12630 = offset == 0;
  D.12631 = (long int) D.12630;
  D.12632 = __builtin_expect (D.12631, 0);
  if (D.12632 != 0) goto <D.12633>; else goto <D.12634>;
  <D.12633>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 548, "offset != 0");
  <D.12634>:
  _wapi_shared_layout.47 = _wapi_shared_layout;
  shared = &_wapi_shared_layout.47->handles[offset];
  if (timestamp != 0) goto <D.12636>; else goto <D.12637>;
  <D.12636>:
  {
    guint32 now;

    D.12638 = time (0B);
    now = (guint32) D.12638;
    D.12639 = &shared->timestamp;
    now.48 = (int) now;
    InterlockedExchange (D.12639, now.48);
  }
  <D.12637>:
  {
    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.12641 = (long int) __not_first_call;
        D.12642 = __builtin_expect (D.12641, 0);
        if (D.12642 != 0) goto <D.12643>; else goto <D.12644>;
        <D.12643>:
        __cancel_routine (__cancel_arg);
        __pthread_unwind_next (&__cancel_buf);
        <D.12644>:
        __pthread_register_cancel (&__cancel_buf);
        thr_ret = pthread_mutex_lock (&scan_mutex);
        D.12645 = thr_ret != 0;
        D.12646 = (long int) D.12645;
        D.12647 = __builtin_expect (D.12646, 0);
        if (D.12647 != 0) goto <D.12648>; else goto <D.12649>;
        <D.12648>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 560, "thr_ret == 0");
        <D.12649>:
        i = 0;
        goto <D.11815>;
        <D.11814>:
        D.12650 = _wapi_private_handles[i];
        if (D.12650 != 0B) goto <D.12651>; else goto <D.12652>;
        <D.12651>:
        k = 0;
        goto <D.11812>;
        <D.11811>:
        {
          struct _WapiHandleUnshared * handle_data;

          D.12650 = _wapi_private_handles[i];
          D.12653 = (long unsigned int) k;
          D.12654 = D.12653 * 200;
          handle_data = D.12650 + D.12654;
          D.12655 = handle_data->type;
          if (D.12655 == type) goto <D.12656>; else goto <D.12657>;
          <D.12656>:
          D.12658 = handle_data->u.shared.offset;
          if (D.12658 == offset) goto <D.12659>; else goto <D.12660>;
          <D.12659>:
          D.12661 = i * 256;
          D.12662 = D.12661 + k;
          D.12663 = (long unsigned int) D.12662;
          handle = (void *) D.12663;
          goto first_pass_done;
          <D.12660>:
          <D.12657>:
        }
        k = k + 1;
        <D.11812>:
        if (k <= 255) goto <D.11811>; else goto <D.11813>;
        <D.11813>:
        <D.12652>:
        i = i + 1;
        <D.11815>:
        i.49 = (unsigned int) i;
        _wapi_private_handle_slot_count.50 = _wapi_private_handle_slot_count;
        if (i.49 < _wapi_private_handle_slot_count.50) goto <D.11814>; else goto <D.11816>;
        <D.11816>:
        first_pass_done:
        thr_ret = pthread_mutex_unlock (&scan_mutex);
        D.12645 = thr_ret != 0;
        D.12646 = (long int) D.12645;
        D.12647 = __builtin_expect (D.12646, 0);
        if (D.12647 != 0) goto <D.12666>; else goto <D.12667>;
        <D.12666>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 578, "thr_ret == 0");
        <D.12667>:
        __pthread_unregister_cancel (&__cancel_buf);
        if (0 != 0) goto <D.12668>; else goto <D.12669>;
        <D.12668>:
        __cancel_routine (__cancel_arg);
        <D.12669>:
      }
    finally
      {
        __cancel_buf = {CLOBBER};
      }
  }
  if (handle != -1B) goto <D.12670>; else goto <D.12671>;
  <D.12670>:
  _wapi_handle_ref (handle);
  D.12672 = handle;
  return D.12672;
  <D.12671>:
  thr_ret = _wapi_handle_lock_shared_handles ();
  D.12645 = thr_ret != 0;
  D.12646 = (long int) D.12645;
  D.12647 = __builtin_expect (D.12646, 0);
  if (D.12647 != 0) goto <D.12673>; else goto <D.12674>;
  <D.12673>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 591, "thr_ret == 0");
  <D.12674>:
  D.12675 = shared->type;
  if (D.12675 == 0) goto done; else goto <D.12676>;
  <D.12676>:
  D.12675 = shared->type;
  if (D.12675 != type) goto done; else goto <D.12677>;
  <D.12677>:
  {
    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.12678 = (long int) __not_first_call;
        D.12679 = __builtin_expect (D.12678, 0);
        if (D.12679 != 0) goto <D.12680>; else goto <D.12681>;
        <D.12680>:
        __cancel_routine (__cancel_arg);
        __pthread_unwind_next (&__cancel_buf);
        <D.12681>:
        __pthread_register_cancel (&__cancel_buf);
        thr_ret = pthread_mutex_lock (&scan_mutex);
        D.12645 = thr_ret != 0;
        D.12646 = (long int) D.12645;
        D.12647 = __builtin_expect (D.12646, 0);
        if (D.12647 != 0) goto <D.12682>; else goto <D.12683>;
        <D.12682>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 610, "thr_ret == 0");
        <D.12683>:
        goto <D.11826>;
        <D.11825>:
        {
          int idx;

          _wapi_private_handle_count.51 = _wapi_private_handle_count;
          D.12685 = _wapi_private_handle_count.51 / 256;
          idx = (int) D.12685;
          D.12686 = monoeg_malloc0 (51200);
          _wapi_private_handles[idx] = D.12686;
          _wapi_private_handle_count.51 = _wapi_private_handle_count;
          _wapi_private_handle_count.52 = _wapi_private_handle_count.51 + 256;
          _wapi_private_handle_count = _wapi_private_handle_count.52;
          _wapi_private_handle_slot_count.50 = _wapi_private_handle_slot_count;
          _wapi_private_handle_slot_count.53 = _wapi_private_handle_slot_count.50 + 1;
          _wapi_private_handle_slot_count = _wapi_private_handle_slot_count.53;
        }
        <D.11826>:
        handle_idx = _wapi_handle_new_internal (type, 0B);
        if (handle_idx == 0) goto <D.11825>; else goto <D.11827>;
        <D.11827>:
        thr_ret = pthread_mutex_unlock (&scan_mutex);
        D.12645 = thr_ret != 0;
        D.12646 = (long int) D.12645;
        D.12647 = __builtin_expect (D.12646, 0);
        if (D.12647 != 0) goto <D.12689>; else goto <D.12690>;
        <D.12689>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 623, "thr_ret == 0");
        <D.12690>:
        __pthread_unregister_cancel (&__cancel_buf);
        if (0 != 0) goto <D.12691>; else goto <D.12692>;
        <D.12691>:
        __cancel_routine (__cancel_arg);
        <D.12692>:
      }
    finally
      {
        __cancel_buf = {CLOBBER};
      }
  }
  _wapi_fd_reserve.54 = _wapi_fd_reserve;
  D.12694 = handle_idx < _wapi_fd_reserve.54;
  D.12695 = (long int) D.12694;
  D.12696 = __builtin_expect (D.12695, 0);
  if (D.12696 != 0) goto <D.12697>; else goto <D.12698>;
  <D.12697>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 627, "handle_idx >= _wapi_fd_reserve");
  <D.12698>:
  D.12699 = (long unsigned int) handle_idx;
  handle = (void *) D.12699;
  D.12700 = handle_idx / 256;
  D.12701 = _wapi_private_handles[D.12700];
  D.12699 = (long unsigned int) handle_idx;
  D.12702 = D.12699 & 255;
  D.12703 = D.12702 * 200;
  D.12704 = D.12701 + D.12703;
  D.12704->u.shared.offset = offset;
  D.12705 = &shared->handle_refs;
  InterlockedIncrement (D.12705);
  done:
  _wapi_handle_unlock_shared_handles ();
  D.12672 = handle;
  return D.12672;
}


InterlockedExchange (volatile gint32 * val, gint32 new_val)
{
  unsigned int old_val.55;
  unsigned int new_val.56;
  unsigned int D.12716;
  int D.12717;
  gint32 D.12718;
  gint32 old_val;

  <D.11403>:
  old_val = *val;
  old_val.55 = (unsigned int) old_val;
  new_val.56 = (unsigned int) new_val;
  D.12716 = __sync_val_compare_and_swap_4 (val, old_val.55, new_val.56);
  D.12717 = (int) D.12716;
  if (D.12717 != old_val) goto <D.11403>; else goto <D.11404>;
  <D.11404>:
  D.12718 = old_val;
  return D.12718;
}


InterlockedIncrement (volatile gint32 * val)
{
  gint32 D.12720;
  unsigned int D.12721;

  D.12721 = __sync_add_and_fetch_4 (val, 1);
  D.12720 = (gint32) D.12721;
  return D.12720;
}


_wapi_handle_new_fd (WapiHandleType type, int fd, void * handle_specific)
{
  int _wapi_has_shut_down.57;
  _Bool D.12724;
  long int D.12725;
  long int D.12726;
  int iftmp.58;
  unsigned int D.12732;
  _Bool D.12736;
  long int D.12737;
  long int D.12738;
  int iftmp.59;
  _Bool D.12748;
  long int D.12749;
  long int D.12750;
  unsigned int fd.60;
  unsigned int _wapi_fd_reserve.61;
  void * D.12757;
  int D.12758;
  struct _WapiHandleUnshared * D.12759;
  int D.12762;
  long unsigned int D.12763;
  long unsigned int D.12764;
  <unnamed type> D.12765;
  _Bool D.12768;
  long int D.12769;
  long int D.12770;
  long unsigned int D.12773;
  struct _WapiHandleUnshared * handle;
  int thr_ret;

  _wapi_has_shut_down.57 = _wapi_has_shut_down;
  D.12724 = _wapi_has_shut_down.57 != 0;
  D.12725 = (long int) D.12724;
  D.12726 = __builtin_expect (D.12725, 0);
  if (D.12726 != 0) goto <D.12727>; else goto <D.12728>;
  <D.12727>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 669, "_wapi_has_shut_down == FALSE");
  <D.12728>:
  D.12732 = type + 4294967295;
  if (D.12732 > 1) goto <D.12733>; else goto <D.12730>;
  <D.12733>:
  if (type != 7) goto <D.12734>; else goto <D.12730>;
  <D.12734>:
  if (type != 10) goto <D.12735>; else goto <D.12730>;
  <D.12735>:
  iftmp.58 = 1;
  goto <D.12731>;
  <D.12730>:
  iftmp.58 = 0;
  <D.12731>:
  D.12736 = iftmp.58 != 0;
  D.12737 = (long int) D.12736;
  D.12738 = __builtin_expect (D.12737, 0);
  if (D.12738 != 0) goto <D.12739>; else goto <D.12740>;
  <D.12739>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 674, "_WAPI_FD_HANDLE(type)");
  <D.12740>:
  if (type == 9) goto <D.12742>; else goto <D.12745>;
  <D.12745>:
  if (type == 11) goto <D.12742>; else goto <D.12746>;
  <D.12746>:
  if (type == 12) goto <D.12742>; else goto <D.12747>;
  <D.12747>:
  if (type == 13) goto <D.12742>; else goto <D.12743>;
  <D.12742>:
  iftmp.59 = 1;
  goto <D.12744>;
  <D.12743>:
  iftmp.59 = 0;
  <D.12744>:
  D.12748 = iftmp.59 != 0;
  D.12749 = (long int) D.12748;
  D.12750 = __builtin_expect (D.12749, 0);
  if (D.12750 != 0) goto <D.12751>; else goto <D.12752>;
  <D.12751>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 675, "!_WAPI_SHARED_HANDLE(type)");
  <D.12752>:
  fd.60 = (unsigned int) fd;
  _wapi_fd_reserve.61 = _wapi_fd_reserve;
  if (fd.60 >= _wapi_fd_reserve.61) goto <D.12755>; else goto <D.12756>;
  <D.12755>:
  D.12757 = -1B;
  return D.12757;
  <D.12756>:
  D.12758 = fd / 256;
  D.12759 = _wapi_private_handles[D.12758];
  if (D.12759 == 0B) goto <D.12760>; else goto <D.12761>;
  <D.12760>:
  D.12758 = fd / 256;
  init_handles_slot (D.12758);
  <D.12761>:
  D.12758 = fd / 256;
  D.12759 = _wapi_private_handles[D.12758];
  D.12762 = fd % 256;
  D.12763 = (long unsigned int) D.12762;
  D.12764 = D.12763 * 200;
  handle = D.12759 + D.12764;
  D.12765 = handle->type;
  if (D.12765 != 0) goto <D.12766>; else goto <D.12767>;
  <D.12766>:
  <D.12767>:
  thr_ret = _wapi_shm_sem_lock (2);
  D.12768 = thr_ret != 0;
  D.12769 = (long int) D.12768;
  D.12770 = __builtin_expect (D.12769, 0);
  if (D.12770 != 0) goto <D.12771>; else goto <D.12772>;
  <D.12771>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 702, "thr_ret == 0");
  <D.12772>:
  _wapi_handle_init (handle, type, handle_specific);
  thr_ret = _wapi_shm_sem_unlock (2);
  D.12773 = (long unsigned int) fd;
  D.12757 = (void *) D.12773;
  return D.12757;
}


init_handles_slot (int idx)
{
  long int D.12775;
  long int D.12776;
  _Bool D.12779;
  long int D.12780;
  long int D.12781;
  struct _WapiHandleUnshared * D.12784;
  void * D.12787;
  _Bool D.12788;
  long int D.12789;
  long int D.12790;
  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.12775 = (long int) __not_first_call;
        D.12776 = __builtin_expect (D.12775, 0);
        if (D.12776 != 0) goto <D.12777>; else goto <D.12778>;
        <D.12777>:
        __cancel_routine (__cancel_arg);
        __pthread_unwind_next (&__cancel_buf);
        <D.12778>:
        __pthread_register_cancel (&__cancel_buf);
        thr_ret = pthread_mutex_lock (&scan_mutex);
        D.12779 = thr_ret != 0;
        D.12780 = (long int) D.12779;
        D.12781 = __builtin_expect (D.12780, 0);
        if (D.12781 != 0) goto <D.12782>; else goto <D.12783>;
        <D.12782>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 650, "thr_ret == 0");
        <D.12783>:
        D.12784 = _wapi_private_handles[idx];
        if (D.12784 == 0B) goto <D.12785>; else goto <D.12786>;
        <D.12785>:
        D.12787 = monoeg_malloc0 (51200);
        _wapi_private_handles[idx] = D.12787;
        D.12784 = _wapi_private_handles[idx];
        D.12788 = D.12784 == 0B;
        D.12789 = (long int) D.12788;
        D.12790 = __builtin_expect (D.12789, 0);
        if (D.12790 != 0) goto <D.12791>; else goto <D.12792>;
        <D.12791>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 655, "_wapi_private_handles [idx]");
        <D.12792>:
        <D.12786>:
        thr_ret = pthread_mutex_unlock (&scan_mutex);
        D.12779 = thr_ret != 0;
        D.12780 = (long int) D.12779;
        D.12781 = __builtin_expect (D.12780, 0);
        if (D.12781 != 0) goto <D.12793>; else goto <D.12794>;
        <D.12793>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 659, "thr_ret == 0");
        <D.12794>:
        __pthread_unregister_cancel (&__cancel_buf);
        if (0 != 0) goto <D.12795>; else goto <D.12796>;
        <D.12795>:
        __cancel_routine (__cancel_arg);
        <D.12796>:
      }
    finally
      {
        __cancel_buf = {CLOBBER};
      }
  }
}


_wapi_lookup_handle (void * handle, WapiHandleType type, void * * handle_specific)
{
  long int handle.62;
  gboolean D.12803;
  unsigned int D.12804;
  struct _WapiHandleUnshared * D.12805;
  int D.12808;
  long unsigned int D.12809;
  long unsigned int D.12810;
  long unsigned int D.12811;
  <unnamed type> D.12812;
  struct _WapiHandleSharedLayout * _wapi_shared_layout.63;
  unsigned int D.12824;
  <unnamed type> D.12825;
  union 
{
  struct _WapiHandle_process process;
  struct _WapiHandle_namedmutex namedmutex;
  struct _WapiHandle_namedsem namedsem;
  struct _WapiHandle_namedevent namedevent;
} * D.12828;
  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.12829;
  struct _WapiHandleUnshared * handle_data;
  guint32 handle_idx;

  handle.62 = (long int) handle;
  handle_idx = (guint32) handle.62;
  if (handle_idx > 4194303) goto <D.12801>; else goto <D.12802>;
  <D.12801>:
  D.12803 = 0;
  return D.12803;
  <D.12802>:
  D.12804 = handle_idx / 256;
  D.12805 = _wapi_private_handles[D.12804];
  if (D.12805 == 0B) goto <D.12806>; else goto <D.12807>;
  <D.12806>:
  D.12804 = handle_idx / 256;
  D.12808 = (int) D.12804;
  init_handles_slot (D.12808);
  <D.12807>:
  D.12804 = handle_idx / 256;
  D.12805 = _wapi_private_handles[D.12804];
  D.12809 = (long unsigned int) handle_idx;
  D.12810 = D.12809 & 255;
  D.12811 = D.12810 * 200;
  handle_data = D.12805 + D.12811;
  D.12812 = handle_data->type;
  if (D.12812 != type) goto <D.12813>; else goto <D.12814>;
  <D.12813>:
  D.12803 = 0;
  return D.12803;
  <D.12814>:
  if (handle_specific == 0B) goto <D.12815>; else goto <D.12816>;
  <D.12815>:
  D.12803 = 0;
  return D.12803;
  <D.12816>:
  if (type == 9) goto <D.12817>; else goto <D.12820>;
  <D.12820>:
  if (type == 11) goto <D.12817>; else goto <D.12821>;
  <D.12821>:
  if (type == 12) goto <D.12817>; else goto <D.12822>;
  <D.12822>:
  if (type == 13) goto <D.12817>; else goto <D.12818>;
  <D.12817>:
  {
    struct _WapiHandle_shared_ref * ref;
    struct _WapiHandleShared * shared_handle_data;

    ref = &handle_data->u.shared;
    _wapi_shared_layout.63 = _wapi_shared_layout;
    D.12824 = ref->offset;
    shared_handle_data = &_wapi_shared_layout.63->handles[D.12824];
    D.12825 = shared_handle_data->type;
    if (D.12825 != type) goto <D.12826>; else goto <D.12827>;
    <D.12826>:
    D.12803 = 0;
    return D.12803;
    <D.12827>:
    D.12828 = &shared_handle_data->u;
    *handle_specific = D.12828;
  }
  goto <D.12819>;
  <D.12818>:
  D.12829 = &handle_data->u;
  *handle_specific = D.12829;
  <D.12819>:
  D.12803 = 1;
  return D.12803;
}


_wapi_handle_foreach (WapiHandleType type, gboolean (*<T1a5a>) (void *, void *) on_each, void * user_data)
{
  long int D.12831;
  long int D.12832;
  _Bool D.12835;
  long int D.12836;
  long int D.12837;
  struct _WapiHandleUnshared * D.12840;
  long unsigned int D.12843;
  long unsigned int D.12844;
  <unnamed type> D.12845;
  unsigned int D.12848;
  unsigned int D.12849;
  long unsigned int D.12850;
  int D.12851;
  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.12831 = (long int) __not_first_call;
        D.12832 = __builtin_expect (D.12831, 0);
        if (D.12832 != 0) goto <D.12833>; else goto <D.12834>;
        <D.12833>:
        __cancel_routine (__cancel_arg);
        __pthread_unwind_next (&__cancel_buf);
        <D.12834>:
        __pthread_register_cancel (&__cancel_buf);
        thr_ret = pthread_mutex_lock (&scan_mutex);
        D.12835 = thr_ret != 0;
        D.12836 = (long int) D.12835;
        D.12837 = __builtin_expect (D.12836, 0);
        if (D.12837 != 0) goto <D.12838>; else goto <D.12839>;
        <D.12838>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 769, "thr_ret == 0");
        <D.12839>:
        i = 0;
        goto <D.11876>;
        <D.11875>:
        D.12840 = _wapi_private_handles[i];
        if (D.12840 != 0B) goto <D.12841>; else goto <D.12842>;
        <D.12841>:
        k = 0;
        goto <D.11874>;
        <D.11873>:
        D.12840 = _wapi_private_handles[i];
        D.12843 = (long unsigned int) k;
        D.12844 = D.12843 * 200;
        handle_data = D.12840 + D.12844;
        D.12845 = handle_data->type;
        if (D.12845 == type) goto <D.12846>; else goto <D.12847>;
        <D.12846>:
        D.12848 = i * 256;
        D.12849 = D.12848 + k;
        D.12850 = (long unsigned int) D.12849;
        ret = (void *) D.12850;
        D.12851 = on_each (ret, user_data);
        if (D.12851 == 1) goto <D.11872>; else goto <D.12852>;
        <D.12852>:
        <D.12847>:
        k = k + 1;
        <D.11874>:
        if (k <= 255) goto <D.11873>; else goto <D.11872>;
        <D.11872>:
        <D.12842>:
        i = i + 1;
        <D.11876>:
        _wapi_private_handle_slot_count.64 = _wapi_private_handle_slot_count;
        if (i < _wapi_private_handle_slot_count.64) goto <D.11875>; else goto <D.11877>;
        <D.11877>:
        thr_ret = pthread_mutex_unlock (&scan_mutex);
        D.12835 = thr_ret != 0;
        D.12836 = (long int) D.12835;
        D.12837 = __builtin_expect (D.12836, 0);
        if (D.12837 != 0) goto <D.12854>; else goto <D.12855>;
        <D.12854>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 786, "thr_ret == 0");
        <D.12855>:
        __pthread_unregister_cancel (&__cancel_buf);
        if (0 != 0) goto <D.12856>; else goto <D.12857>;
        <D.12856>:
        __cancel_routine (__cancel_arg);
        <D.12857>:
      }
    finally
      {
        __cancel_buf = {CLOBBER};
      }
  }
}


_wapi_search_handle (WapiHandleType type, gboolean (*<T1a5a>) (void *, void *) check, void * user_data, void * * handle_specific, gboolean search_shared)
{
  long int D.12861;
  long int D.12862;
  _Bool D.12865;
  long int D.12866;
  long int D.12867;
  struct _WapiHandleUnshared * D.12870;
  long unsigned int D.12873;
  long unsigned int D.12874;
  <unnamed type> D.12875;
  unsigned int D.12878;
  unsigned int D.12879;
  long unsigned int D.12880;
  int D.12881;
  struct _WapiHandleSharedLayout * _wapi_shared_layout.65;
  unsigned int _wapi_private_handle_slot_count.66;
  <unnamed type> D.12904;
  int D.12909;
  long int D.12916;
  guint32 * D.12917;
  int now.67;
  long int ret.68;
  unsigned int D.12920;
  unsigned int D.12921;
  struct _WapiHandleUnshared * D.12922;
  long unsigned int D.12923;
  long unsigned int D.12924;
  long unsigned int D.12925;
  _Bool D.12936;
  long int D.12937;
  long int D.12938;
  union 
{
  struct _WapiHandle_process process;
  struct _WapiHandle_namedmutex namedmutex;
  struct _WapiHandle_namedsem namedsem;
  struct _WapiHandle_namedevent namedevent;
} * D.12941;
  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.12942;
  void * D.12943;
  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.12861 = (long int) __not_first_call;
        D.12862 = __builtin_expect (D.12861, 0);
        if (D.12862 != 0) goto <D.12863>; else goto <D.12864>;
        <D.12863>:
        __cancel_routine (__cancel_arg);
        __pthread_unwind_next (&__cancel_buf);
        <D.12864>:
        __pthread_register_cancel (&__cancel_buf);
        thr_ret = pthread_mutex_lock (&scan_mutex);
        D.12865 = thr_ret != 0;
        D.12866 = (long int) D.12865;
        D.12867 = __builtin_expect (D.12866, 0);
        if (D.12867 != 0) goto <D.12868>; else goto <D.12869>;
        <D.12868>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 814, "thr_ret == 0");
        <D.12869>:
        i = 0;
        goto <D.11904>;
        <D.11903>:
        D.12870 = _wapi_private_handles[i];
        if (D.12870 != 0B) goto <D.12871>; else goto <D.12872>;
        <D.12871>:
        k = 0;
        goto <D.11902>;
        <D.11901>:
        D.12870 = _wapi_private_handles[i];
        D.12873 = (long unsigned int) k;
        D.12874 = D.12873 * 200;
        handle_data = D.12870 + D.12874;
        D.12875 = handle_data->type;
        if (D.12875 == type) goto <D.12876>; else goto <D.12877>;
        <D.12876>:
        D.12878 = i * 256;
        D.12879 = D.12878 + k;
        D.12880 = (long unsigned int) D.12879;
        ret = (void *) D.12880;
        D.12881 = check (ret, user_data);
        if (D.12881 == 1) goto <D.12882>; else goto <D.12883>;
        <D.12882>:
        _wapi_handle_ref (ret);
        found = 1;
        if (type == 9) goto <D.12884>; else goto <D.12886>;
        <D.12886>:
        if (type == 11) goto <D.12884>; else goto <D.12887>;
        <D.12887>:
        if (type == 12) goto <D.12884>; else goto <D.12888>;
        <D.12888>:
        if (type == 13) goto <D.12884>; else goto <D.12885>;
        <D.12884>:
        _wapi_shared_layout.65 = _wapi_shared_layout;
        shared = &_wapi_shared_layout.65->handles[i];
        <D.12885>:
        goto <D.11900>;
        <D.12883>:
        <D.12877>:
        k = k + 1;
        <D.11902>:
        if (k <= 255) goto <D.11901>; else goto <D.11900>;
        <D.11900>:
        <D.12872>:
        i = i + 1;
        <D.11904>:
        if (found == 0) goto <D.12890>; else goto <D.11905>;
        <D.12890>:
        _wapi_private_handle_slot_count.66 = _wapi_private_handle_slot_count;
        if (i < _wapi_private_handle_slot_count.66) goto <D.11903>; else goto <D.11905>;
        <D.11905>:
        thr_ret = pthread_mutex_unlock (&scan_mutex);
        D.12865 = thr_ret != 0;
        D.12866 = (long int) D.12865;
        D.12867 = __builtin_expect (D.12866, 0);
        if (D.12867 != 0) goto <D.12892>; else goto <D.12893>;
        <D.12892>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 839, "thr_ret == 0");
        <D.12893>:
        __pthread_unregister_cancel (&__cancel_buf);
        if (0 != 0) goto <D.12894>; else goto <D.12895>;
        <D.12894>:
        __cancel_routine (__cancel_arg);
        <D.12895>:
      }
    finally
      {
        __cancel_buf = {CLOBBER};
      }
  }
  if (found == 0) goto <D.12897>; else goto <D.12898>;
  <D.12897>:
  if (search_shared != 0) goto <D.12899>; else goto <D.12900>;
  <D.12899>:
  if (type == 9) goto <D.12896>; else goto <D.12901>;
  <D.12901>:
  if (type == 11) goto <D.12896>; else goto <D.12902>;
  <D.12902>:
  if (type == 12) goto <D.12896>; else goto <D.12903>;
  <D.12903>:
  if (type == 13) goto <D.12896>; else goto <D.11908>;
  <D.12896>:
  i = 0;
  goto <D.11910>;
  <D.11909>:
  _wapi_shared_layout.65 = _wapi_shared_layout;
  shared = &_wapi_shared_layout.65->handles[i];
  D.12904 = shared->type;
  if (D.12904 == type) goto <D.12905>; else goto <D.12906>;
  <D.12905>:
  ret = _wapi_handle_new_from_offset (type, i, 0);
  if (ret == -1B) goto <D.12907>; else goto <D.12908>;
  <D.12907>:
  // predicted unlikely by continue predictor.
  goto <D.11906>;
  <D.12908>:
  D.12909 = check (ret, user_data);
  if (D.12909 == 1) goto <D.12910>; else goto <D.12911>;
  <D.12910>:
  thr_ret = _wapi_handle_lock_shared_handles ();
  D.12865 = thr_ret != 0;
  D.12866 = (long int) D.12865;
  D.12867 = __builtin_expect (D.12866, 0);
  if (D.12867 != 0) goto <D.12912>; else goto <D.12913>;
  <D.12912>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 881, "thr_ret == 0");
  <D.12913>:
  D.12904 = shared->type;
  if (D.12904 == type) goto <D.12914>; else goto <D.12915>;
  <D.12914>:
  {
    guint32 now;

    D.12916 = time (0B);
    now = (guint32) D.12916;
    D.12917 = &shared->timestamp;
    now.67 = (int) now;
    InterlockedExchange (D.12917, now.67);
    found = 1;
    ret.68 = (long int) ret;
    D.12920 = (unsigned int) ret.68;
    D.12921 = D.12920 / 256;
    D.12922 = _wapi_private_handles[D.12921];
    ret.68 = (long int) ret;
    D.12920 = (unsigned int) ret.68;
    D.12923 = (long unsigned int) D.12920;
    D.12924 = D.12923 & 255;
    D.12925 = D.12924 * 200;
    handle_data = D.12922 + D.12925;
    _wapi_handle_unlock_shared_handles ();
    goto <D.11908>;
  }
  <D.12915>:
  _wapi_handle_unlock_shared_handles ();
  <D.12911>:
  _wapi_handle_unref (ret);
  <D.12906>:
  <D.11906>:
  i = i + 1;
  <D.11910>:
  if (i <= 255) goto <D.11909>; else goto <D.11908>;
  <D.11908>:
  <D.12900>:
  <D.12898>:
  if (found == 0) goto <D.12926>; else goto <D.12927>;
  <D.12926>:
  ret = 0B;
  goto done;
  <D.12927>:
  if (handle_specific != 0B) goto <D.12928>; else goto <D.12929>;
  <D.12928>:
  if (type == 9) goto <D.12930>; else goto <D.12933>;
  <D.12933>:
  if (type == 11) goto <D.12930>; else goto <D.12934>;
  <D.12934>:
  if (type == 12) goto <D.12930>; else goto <D.12935>;
  <D.12935>:
  if (type == 13) goto <D.12930>; else goto <D.12931>;
  <D.12930>:
  D.12904 = shared->type;
  D.12936 = D.12904 != type;
  D.12937 = (long int) D.12936;
  D.12938 = __builtin_expect (D.12937, 0);
  if (D.12938 != 0) goto <D.12939>; else goto <D.12940>;
  <D.12939>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 917, "shared->type == type");
  <D.12940>:
  D.12941 = &shared->u;
  *handle_specific = D.12941;
  goto <D.12932>;
  <D.12931>:
  D.12942 = &handle_data->u;
  *handle_specific = D.12942;
  <D.12932>:
  <D.12929>:
  done:
  D.12943 = ret;
  return D.12943;
}


_wapi_search_handle_namespace (WapiHandleType type, gchar * utf8_name)
{
  int iftmp.69;
  _Bool D.12958;
  long int D.12959;
  long int D.12960;
  _Bool D.12963;
  long int D.12964;
  long int D.12965;
  struct _WapiHandleSharedLayout * _wapi_shared_layout.70;
  <unnamed type> D.12969;
  unsigned int D.12970;
  int D.11930;
  gchar[261] * D.12973;
  gint32 D.12978;
  struct _WapiHandleShared * shared_handle_data;
  guint32 i;
  gint32 ret;
  int thr_ret;
  void done = <<< error >>>;

  ret = 0;
  if (type != 9) goto <D.12954>; else goto <D.12952>;
  <D.12954>:
  if (type != 11) goto <D.12955>; else goto <D.12952>;
  <D.12955>:
  if (type != 12) goto <D.12956>; else goto <D.12952>;
  <D.12956>:
  if (type != 13) goto <D.12957>; else goto <D.12952>;
  <D.12957>:
  iftmp.69 = 1;
  goto <D.12953>;
  <D.12952>:
  iftmp.69 = 0;
  <D.12953>:
  D.12958 = iftmp.69 != 0;
  D.12959 = (long int) D.12958;
  D.12960 = __builtin_expect (D.12959, 0);
  if (D.12960 != 0) goto <D.12961>; else goto <D.12962>;
  <D.12961>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 940, "_WAPI_SHARED_HANDLE(type)");
  <D.12962>:
  _wapi_handle_collect ();
  thr_ret = _wapi_handle_lock_shared_handles ();
  D.12963 = thr_ret != 0;
  D.12964 = (long int) D.12963;
  D.12965 = __builtin_expect (D.12964, 0);
  if (D.12965 != 0) goto <D.12966>; else goto <D.12967>;
  <D.12966>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 951, "thr_ret == 0");
  <D.12967>:
  i = 1;
  goto <D.11933>;
  <D.11932>:
  {
    struct WapiSharedNamespace * sharedns;

    _wapi_shared_layout.70 = _wapi_shared_layout;
    shared_handle_data = &_wapi_shared_layout.70->handles[i];
    D.12969 = shared_handle_data->type;
    D.12970 = D.12969 + 4294967285;
    if (D.12970 > 2) goto <D.12971>; else goto <D.12972>;
    <D.12971>:
    // predicted unlikely by continue predictor.
    goto <D.11921>;
    <D.12972>:
    sharedns = &shared_handle_data->u;
    {
      size_t __s1_len;
      size_t __s2_len;

      D.12973 = &sharedns->name;
      D.11930 = __builtin_strcmp (D.12973, utf8_name);
    }
    if (D.11930 == 0) goto <D.12974>; else goto <D.12975>;
    <D.12974>:
    D.12969 = shared_handle_data->type;
    if (D.12969 != type) goto <D.12976>; else goto <D.12977>;
    <D.12976>:
    ret = -1;
    goto done;
    <D.12977>:
    ret = (gint32) i;
    goto done;
    <D.12975>:
  }
  <D.11921>:
  i = i + 1;
  <D.11933>:
  if (i <= 255) goto <D.11932>; else goto <D.11934>;
  <D.11934>:
  done:
  _wapi_handle_unlock_shared_handles ();
  D.12978 = ret;
  return D.12978;
}


_wapi_handle_ref (void * handle)
{
  long int handle.71;
  <unnamed type> D.12983;
  unsigned int D.12986;
  struct _WapiHandleUnshared * D.12987;
  long unsigned int D.12988;
  long unsigned int D.12989;
  long unsigned int D.12990;
  guint * D.12991;
  <unnamed type> D.12994;
  struct _WapiHandleSharedLayout * _wapi_shared_layout.72;
  unsigned int D.12999;
  long int D.13000;
  guint32 * D.13001;
  int now.73;
  guint32 idx;
  struct _WapiHandleUnshared * handle_data;
  static const char __func__[17] = "_wapi_handle_ref";

  handle.71 = (long int) handle;
  idx = (guint32) handle.71;
  if (idx > 4194303) goto <D.12981>; else goto <D.12982>;
  <D.12981>:
  return;
  <D.12982>:
  D.12983 = _wapi_handle_type (handle);
  if (D.12983 == 0) goto <D.12984>; else goto <D.12985>;
  <D.12984>:
  monoeg_g_log (0B, 16, "%s: Attempting to ref unused handle %p", &__func__, handle);
  return;
  <D.12985>:
  D.12986 = idx / 256;
  D.12987 = _wapi_private_handles[D.12986];
  D.12988 = (long unsigned int) idx;
  D.12989 = D.12988 & 255;
  D.12990 = D.12989 * 200;
  handle_data = D.12987 + D.12990;
  D.12991 = &handle_data->ref;
  InterlockedIncrement (D.12991);
  D.12994 = handle_data->type;
  if (D.12994 == 9) goto <D.12992>; else goto <D.12995>;
  <D.12995>:
  D.12994 = handle_data->type;
  if (D.12994 == 11) goto <D.12992>; else goto <D.12996>;
  <D.12996>:
  D.12994 = handle_data->type;
  if (D.12994 == 12) goto <D.12992>; else goto <D.12997>;
  <D.12997>:
  D.12994 = handle_data->type;
  if (D.12994 == 13) goto <D.12992>; else goto <D.12993>;
  <D.12992>:
  {
    struct _WapiHandleShared * shared_data;
    guint32 now;

    _wapi_shared_layout.72 = _wapi_shared_layout;
    D.12999 = handle_data->u.shared.offset;
    shared_data = &_wapi_shared_layout.72->handles[D.12999];
    D.13000 = time (0B);
    now = (guint32) D.13000;
    D.13001 = &shared_data->timestamp;
    now.73 = (int) now;
    InterlockedExchange (D.13001, now.73);
  }
  <D.12993>:
}


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


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


_wapi_handle_test_capabilities (void * handle, WapiHandleCapability caps)
{
  long int handle.74;
  gboolean D.13007;
  unsigned int D.13008;
  struct _WapiHandleUnshared * D.13009;
  long unsigned int D.13010;
  long unsigned int D.13011;
  long unsigned int D.13012;
  struct _WapiHandleUnshared * D.13013;
  <unnamed type> D.13014;
  unsigned int D.13015;
  _Bool D.13016;
  guint32 idx;
  WapiHandleType type;

  handle.74 = (long int) handle;
  idx = (guint32) handle.74;
  if (idx > 4194303) goto <D.13005>; else goto <D.13006>;
  <D.13005>:
  D.13007 = 0;
  return D.13007;
  <D.13006>:
  D.13008 = idx / 256;
  D.13009 = _wapi_private_handles[D.13008];
  D.13010 = (long unsigned int) idx;
  D.13011 = D.13010 & 255;
  D.13012 = D.13011 * 200;
  D.13013 = D.13009 + D.13012;
  type = D.13013->type;
  D.13014 = handle_caps[type];
  D.13015 = D.13014 & caps;
  D.13016 = D.13015 != 0;
  D.13007 = (gboolean) D.13016;
  return D.13007;
}


_wapi_handle_ops_close (void * handle, void * data)
{
  long int handle.75;
  unsigned int D.13021;
  struct _WapiHandleUnshared * D.13022;
  long unsigned int D.13023;
  long unsigned int D.13024;
  long unsigned int D.13025;
  struct _WapiHandleUnshared * D.13026;
  struct _WapiHandleOps * D.13027;
  void (*<Tc9c>) (void *, void *) D.13030;
  guint32 idx;
  WapiHandleType type;

  handle.75 = (long int) handle;
  idx = (guint32) handle.75;
  if (idx > 4194303) goto <D.13019>; else goto <D.13020>;
  <D.13019>:
  return;
  <D.13020>:
  D.13021 = idx / 256;
  D.13022 = _wapi_private_handles[D.13021];
  D.13023 = (long unsigned int) idx;
  D.13024 = D.13023 & 255;
  D.13025 = D.13024 * 200;
  D.13026 = D.13022 + D.13025;
  type = D.13026->type;
  D.13027 = handle_ops[type];
  if (D.13027 != 0B) goto <D.13028>; else goto <D.13029>;
  <D.13028>:
  D.13027 = handle_ops[type];
  D.13030 = D.13027->close;
  if (D.13030 != 0B) goto <D.13031>; else goto <D.13032>;
  <D.13031>:
  D.13027 = handle_ops[type];
  D.13030 = D.13027->close;
  D.13030 (handle, data);
  <D.13032>:
  <D.13029>:
}


_wapi_handle_ops_signal (void * handle)
{
  long int handle.76;
  unsigned int D.13037;
  struct _WapiHandleUnshared * D.13038;
  long unsigned int D.13039;
  long unsigned int D.13040;
  long unsigned int D.13041;
  struct _WapiHandleUnshared * D.13042;
  struct _WapiHandleOps * D.13043;
  void (*<Tc09>) (void *) D.13046;
  guint32 idx;
  WapiHandleType type;

  handle.76 = (long int) handle;
  idx = (guint32) handle.76;
  if (idx > 4194303) goto <D.13035>; else goto <D.13036>;
  <D.13035>:
  return;
  <D.13036>:
  D.13037 = idx / 256;
  D.13038 = _wapi_private_handles[D.13037];
  D.13039 = (long unsigned int) idx;
  D.13040 = D.13039 & 255;
  D.13041 = D.13040 * 200;
  D.13042 = D.13038 + D.13041;
  type = D.13042->type;
  D.13043 = handle_ops[type];
  if (D.13043 != 0B) goto <D.13044>; else goto <D.13045>;
  <D.13044>:
  D.13043 = handle_ops[type];
  D.13046 = D.13043->signal;
  if (D.13046 != 0B) goto <D.13047>; else goto <D.13048>;
  <D.13047>:
  D.13043 = handle_ops[type];
  D.13046 = D.13043->signal;
  D.13046 (handle);
  <D.13048>:
  <D.13045>:
}


_wapi_handle_ops_own (void * handle)
{
  long int handle.77;
  gboolean D.13053;
  unsigned int D.13054;
  struct _WapiHandleUnshared * D.13055;
  long unsigned int D.13056;
  long unsigned int D.13057;
  long unsigned int D.13058;
  struct _WapiHandleUnshared * D.13059;
  struct _WapiHandleOps * D.13061;
  gboolean (*<T18bb>) (void *) D.13063;
  guint32 idx;
  WapiHandleType type;

  handle.77 = (long int) handle;
  idx = (guint32) handle.77;
  if (idx > 4194303) goto <D.13051>; else goto <D.13052>;
  <D.13051>:
  D.13053 = 0;
  return D.13053;
  <D.13052>:
  D.13054 = idx / 256;
  D.13055 = _wapi_private_handles[D.13054];
  D.13056 = (long unsigned int) idx;
  D.13057 = D.13056 & 255;
  D.13058 = D.13057 * 200;
  D.13059 = D.13055 + D.13058;
  type = D.13059->type;
  D.13061 = handle_ops[type];
  if (D.13061 != 0B) goto <D.13062>; else goto <D.13060>;
  <D.13062>:
  D.13061 = handle_ops[type];
  D.13063 = D.13061->own_handle;
  if (D.13063 != 0B) goto <D.13064>; else goto <D.13060>;
  <D.13064>:
  D.13061 = handle_ops[type];
  D.13063 = D.13061->own_handle;
  D.13053 = D.13063 (handle);
  return D.13053;
  <D.13060>:
  D.13053 = 0;
  return D.13053;
}


_wapi_handle_ops_isowned (void * handle)
{
  long int handle.78;
  gboolean D.13069;
  unsigned int D.13070;
  struct _WapiHandleUnshared * D.13071;
  long unsigned int D.13072;
  long unsigned int D.13073;
  long unsigned int D.13074;
  struct _WapiHandleUnshared * D.13075;
  struct _WapiHandleOps * D.13077;
  gboolean (*<T18bb>) (void *) D.13079;
  guint32 idx;
  WapiHandleType type;

  handle.78 = (long int) handle;
  idx = (guint32) handle.78;
  if (idx > 4194303) goto <D.13067>; else goto <D.13068>;
  <D.13067>:
  D.13069 = 0;
  return D.13069;
  <D.13068>:
  D.13070 = idx / 256;
  D.13071 = _wapi_private_handles[D.13070];
  D.13072 = (long unsigned int) idx;
  D.13073 = D.13072 & 255;
  D.13074 = D.13073 * 200;
  D.13075 = D.13071 + D.13074;
  type = D.13075->type;
  D.13077 = handle_ops[type];
  if (D.13077 != 0B) goto <D.13078>; else goto <D.13076>;
  <D.13078>:
  D.13077 = handle_ops[type];
  D.13079 = D.13077->is_owned;
  if (D.13079 != 0B) goto <D.13080>; else goto <D.13076>;
  <D.13080>:
  D.13077 = handle_ops[type];
  D.13079 = D.13077->is_owned;
  D.13069 = D.13079 (handle);
  return D.13069;
  <D.13076>:
  D.13069 = 0;
  return D.13069;
}


_wapi_handle_ops_special_wait (void * handle, guint32 timeout, gboolean alertable)
{
  long int handle.79;
  guint32 D.13085;
  unsigned int D.13086;
  struct _WapiHandleUnshared * D.13087;
  long unsigned int D.13088;
  long unsigned int D.13089;
  long unsigned int D.13090;
  struct _WapiHandleUnshared * D.13091;
  struct _WapiHandleOps * D.13093;
  guint32 (*<T18c0>) (void *, guint32, gboolean) D.13095;
  guint32 idx;
  WapiHandleType type;

  handle.79 = (long int) handle;
  idx = (guint32) handle.79;
  if (idx > 4194303) goto <D.13083>; else goto <D.13084>;
  <D.13083>:
  D.13085 = 4294967295;
  return D.13085;
  <D.13084>:
  D.13086 = idx / 256;
  D.13087 = _wapi_private_handles[D.13086];
  D.13088 = (long unsigned int) idx;
  D.13089 = D.13088 & 255;
  D.13090 = D.13089 * 200;
  D.13091 = D.13087 + D.13090;
  type = D.13091->type;
  D.13093 = handle_ops[type];
  if (D.13093 != 0B) goto <D.13094>; else goto <D.13092>;
  <D.13094>:
  D.13093 = handle_ops[type];
  D.13095 = D.13093->special_wait;
  if (D.13095 != 0B) goto <D.13096>; else goto <D.13092>;
  <D.13096>:
  D.13093 = handle_ops[type];
  D.13095 = D.13093->special_wait;
  D.13085 = D.13095 (handle, timeout, alertable);
  return D.13085;
  <D.13092>:
  D.13085 = 4294967295;
  return D.13085;
}


_wapi_handle_ops_prewait (void * handle)
{
  long int handle.80;
  unsigned int D.13101;
  struct _WapiHandleUnshared * D.13102;
  long unsigned int D.13103;
  long unsigned int D.13104;
  long unsigned int D.13105;
  struct _WapiHandleUnshared * D.13106;
  struct _WapiHandleOps * D.13107;
  void (*<Tc09>) (void *) D.13110;
  guint32 idx;
  WapiHandleType type;

  handle.80 = (long int) handle;
  idx = (guint32) handle.80;
  if (idx > 4194303) goto <D.13099>; else goto <D.13100>;
  <D.13099>:
  return;
  <D.13100>:
  D.13101 = idx / 256;
  D.13102 = _wapi_private_handles[D.13101];
  D.13103 = (long unsigned int) idx;
  D.13104 = D.13103 & 255;
  D.13105 = D.13104 * 200;
  D.13106 = D.13102 + D.13105;
  type = D.13106->type;
  D.13107 = handle_ops[type];
  if (D.13107 != 0B) goto <D.13108>; else goto <D.13109>;
  <D.13108>:
  D.13107 = handle_ops[type];
  D.13110 = D.13107->prewait;
  if (D.13110 != 0B) goto <D.13111>; else goto <D.13112>;
  <D.13111>:
  D.13107 = handle_ops[type];
  D.13110 = D.13107->prewait;
  D.13110 (handle);
  <D.13112>:
  <D.13109>:
}


CloseHandle (void * handle)
{
  struct _WapiHandleUnshared * D.13116;
  <unnamed type> D.13117;
  gboolean D.13120;

  if (handle == 0B) goto <D.13114>; else goto <D.13115>;
  <D.13114>:
  D.13116 = _wapi_private_handles[0];
  D.13117 = D.13116->type;
  if (D.13117 != 2) goto <D.13118>; else goto <D.13119>;
  <D.13118>:
  SetLastError (87);
  D.13120 = 0;
  return D.13120;
  <D.13119>:
  <D.13115>:
  if (handle == -1B) goto <D.13121>; else goto <D.13122>;
  <D.13121>:
  SetLastError (87);
  D.13120 = 0;
  return D.13120;
  <D.13122>:
  _wapi_handle_unref (handle);
  D.13120 = 1;
  return D.13120;
}


DuplicateHandle (void * srcprocess, void * src, void * targetprocess, void * * target, guint32 access, gboolean inherit, guint32 options)
{
  gboolean D.13127;
  void * D.13130;
  void * D.13134;

  if (srcprocess != 4294967295B) goto <D.13124>; else goto <D.13126>;
  <D.13126>:
  if (targetprocess != 4294967295B) goto <D.13124>; else goto <D.13125>;
  <D.13124>:
  SetLastError (6);
  D.13127 = 0;
  return D.13127;
  <D.13125>:
  if (src == 4294967295B) goto <D.13128>; else goto <D.13129>;
  <D.13128>:
  D.13130 = _wapi_process_duplicate ();
  *target = D.13130;
  goto <D.13131>;
  <D.13129>:
  if (src == 4294967294B) goto <D.13132>; else goto <D.13133>;
  <D.13132>:
  D.13134 = _wapi_thread_duplicate ();
  *target = D.13134;
  goto <D.13135>;
  <D.13133>:
  _wapi_handle_ref (src);
  *target = src;
  <D.13135>:
  <D.13131>:
  D.13127 = 1;
  return D.13127;
}


_wapi_handle_count_signalled_handles (guint32 numhandles, void * * handles, gboolean waitall, guint32 * retcount, guint32 * lowest)
{
  _Bool D.13137;
  long int D.13138;
  long int D.13139;
  long unsigned int D.13142;
  long unsigned int D.13143;
  void * * D.13144;
  long int handle.81;
  unsigned int D.13146;
  struct _WapiHandleUnshared * D.13147;
  long unsigned int D.13148;
  long unsigned int D.13149;
  long unsigned int D.13150;
  struct _WapiHandleUnshared * D.13151;
  unsigned int i.82;
  unsigned int D.13161;
  long int handle.83;
  unsigned int D.13163;
  struct _WapiHandleUnshared * D.13164;
  long unsigned int D.13165;
  long unsigned int D.13166;
  long unsigned int D.13167;
  struct _WapiHandleUnshared * D.13168;
  int D.13174;
  int D.13176;
  struct _WapiHandleSharedLayout * _wapi_shared_layout.84;
  unsigned int D.13181;
  unsigned int D.13182;
  struct _WapiHandleUnshared * D.13183;
  long unsigned int D.13184;
  long unsigned int D.13185;
  long unsigned int D.13186;
  struct _WapiHandleUnshared * D.13187;
  unsigned int D.13188;
  int D.13189;
  int D.13194;
  unsigned int D.13195;
  gboolean D.13204;
  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.13137 = thr_ret != 0;
  D.13138 = (long int) D.13137;
  D.13139 = __builtin_expect (D.13138, 0);
  if (D.13139 != 0) goto <D.13140>; else goto <D.13141>;
  <D.13140>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 1375, "thr_ret == 0");
  <D.13141>:
  i = 0;
  goto <D.12052>;
  <D.12051>:
  {
    void * handle;
    guint32 idx;

    D.13142 = (long unsigned int) i;
    D.13143 = D.13142 * 8;
    D.13144 = handles + D.13143;
    handle = *D.13144;
    handle.81 = (long int) handle;
    idx = (guint32) handle.81;
    D.13146 = idx / 256;
    D.13147 = _wapi_private_handles[D.13146];
    D.13148 = (long unsigned int) idx;
    D.13149 = D.13148 & 255;
    D.13150 = D.13149 * 200;
    D.13151 = D.13147 + D.13150;
    type = D.13151->type;
    thr_ret = _wapi_handle_trylock_handle (handle);
    if (thr_ret != 0) goto <D.13152>; else goto <D.13153>;
    <D.13152>:
    thr_ret = _wapi_handle_unlock_shared_handles ();
    D.13137 = thr_ret != 0;
    D.13138 = (long int) D.13137;
    D.13139 = __builtin_expect (D.13138, 0);
    if (D.13139 != 0) goto <D.13154>; else goto <D.13155>;
    <D.13154>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 1394, "thr_ret == 0");
    <D.13155>:
    goto <D.12048>;
    <D.12047>:
    D.13142 = (long unsigned int) i;
    D.13143 = D.13142 * 8;
    D.13144 = handles + D.13143;
    handle = *D.13144;
    handle.81 = (long int) handle;
    idx = (guint32) handle.81;
    thr_ret = _wapi_handle_unlock_handle (handle);
    D.13137 = thr_ret != 0;
    D.13138 = (long int) D.13137;
    D.13139 = __builtin_expect (D.13138, 0);
    if (D.13139 != 0) goto <D.13156>; else goto <D.13157>;
    <D.13156>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 1401, "thr_ret == 0");
    <D.13157>:
    <D.12048>:
    i.82 = i;
    i = i.82 + 4294967295;
    if (i.82 != 0) goto <D.12047>; else goto <D.12049>;
    <D.12049>:
    iter = iter + 1;
    if (iter == 100) goto <D.13159>; else goto <D.13160>;
    <D.13159>:
    monoeg_g_log (0B, 16, "%s: iteration overflow!", &__func__);
    iter = 1;
    <D.13160>:
    D.13161 = iter * 10;
    _wapi_handle_spin (D.13161);
    goto again;
    <D.13153>:
  }
  i = i + 1;
  <D.12052>:
  if (i < numhandles) goto <D.12051>; else goto <D.12053>;
  <D.12053>:
  count = 0;
  *lowest = numhandles;
  i = 0;
  goto <D.12057>;
  <D.12056>:
  {
    void * handle;
    guint32 idx;

    D.13142 = (long unsigned int) i;
    D.13143 = D.13142 * 8;
    D.13144 = handles + D.13143;
    handle = *D.13144;
    handle.83 = (long int) handle;
    idx = (guint32) handle.83;
    D.13163 = idx / 256;
    D.13164 = _wapi_private_handles[D.13163];
    D.13165 = (long unsigned int) idx;
    D.13166 = D.13165 & 255;
    D.13167 = D.13166 * 200;
    D.13168 = D.13164 + D.13167;
    type = D.13168->type;
    D.13174 = _wapi_handle_test_capabilities (handle, 4);
    if (D.13174 == 1) goto <D.13175>; else goto <D.13169>;
    <D.13175>:
    D.13176 = _wapi_handle_ops_isowned (handle);
    if (D.13176 == 1) goto <D.13170>; else goto <D.13169>;
    <D.13169>:
    if (type == 9) goto <D.13171>; else goto <D.13177>;
    <D.13177>:
    if (type == 11) goto <D.13171>; else goto <D.13178>;
    <D.13178>:
    if (type == 12) goto <D.13171>; else goto <D.13179>;
    <D.13179>:
    if (type == 13) goto <D.13171>; else goto <D.13172>;
    <D.13171>:
    _wapi_shared_layout.84 = _wapi_shared_layout;
    handle.83 = (long int) handle;
    D.13181 = (unsigned int) handle.83;
    D.13182 = D.13181 / 256;
    D.13183 = _wapi_private_handles[D.13182];
    handle.83 = (long int) handle;
    D.13181 = (unsigned int) handle.83;
    D.13184 = (long unsigned int) D.13181;
    D.13185 = D.13184 & 255;
    D.13186 = D.13185 * 200;
    D.13187 = D.13183 + D.13186;
    D.13188 = D.13187->u.shared.offset;
    D.13189 = _wapi_shared_layout.84->handles[D.13188].signalled;
    if (D.13189 == 1) goto <D.13170>; else goto <D.13172>;
    <D.13172>:
    if (type != 9) goto <D.13190>; else goto <D.13173>;
    <D.13190>:
    if (type != 11) goto <D.13191>; else goto <D.13173>;
    <D.13191>:
    if (type != 12) goto <D.13192>; else goto <D.13173>;
    <D.13192>:
    if (type != 13) goto <D.13193>; else goto <D.13173>;
    <D.13193>:
    D.13163 = idx / 256;
    D.13164 = _wapi_private_handles[D.13163];
    D.13165 = (long unsigned int) idx;
    D.13166 = D.13165 & 255;
    D.13167 = D.13166 * 200;
    D.13168 = D.13164 + D.13167;
    D.13194 = D.13168->signalled;
    if (D.13194 == 1) goto <D.13170>; else goto <D.13173>;
    <D.13170>:
    count = count + 1;
    D.13195 = *lowest;
    if (D.13195 > i) goto <D.13196>; else goto <D.13197>;
    <D.13196>:
    *lowest = i;
    <D.13197>:
    <D.13173>:
  }
  i = i + 1;
  <D.12057>:
  if (i < numhandles) goto <D.12056>; else goto <D.12058>;
  <D.12058>:
  if (waitall == 1) goto <D.13202>; else goto <D.13198>;
  <D.13202>:
  if (count == numhandles) goto <D.13199>; else goto <D.13198>;
  <D.13198>:
  if (waitall == 0) goto <D.13203>; else goto <D.13200>;
  <D.13203>:
  if (count != 0) goto <D.13199>; else goto <D.13200>;
  <D.13199>:
  ret = 1;
  goto <D.13201>;
  <D.13200>:
  ret = 0;
  <D.13201>:
  *retcount = count;
  D.13204 = ret;
  return D.13204;
}


_wapi_handle_trylock_handle (void * handle)
{
  long int handle.85;
  int D.13209;
  <unnamed type> D.13212;
  <unnamed type> D.13214;
  <unnamed type> D.13216;
  <unnamed type> D.13218;
  unsigned int D.13219;
  struct _WapiHandleUnshared * D.13220;
  long unsigned int D.13221;
  long unsigned int D.13222;
  long unsigned int D.13223;
  struct _WapiHandleUnshared * D.13224;
  union mono_mutex_t * D.13225;
  guint32 idx;
  int ret;

  handle.85 = (long int) handle;
  idx = (guint32) handle.85;
  if (idx > 4194303) goto <D.13207>; else goto <D.13208>;
  <D.13207>:
  D.13209 = 0;
  return D.13209;
  <D.13208>:
  _wapi_handle_ref (handle);
  D.13212 = _wapi_handle_type (handle);
  if (D.13212 == 9) goto <D.13210>; else goto <D.13213>;
  <D.13213>:
  D.13214 = _wapi_handle_type (handle);
  if (D.13214 == 11) goto <D.13210>; else goto <D.13215>;
  <D.13215>:
  D.13216 = _wapi_handle_type (handle);
  if (D.13216 == 12) goto <D.13210>; else goto <D.13217>;
  <D.13217>:
  D.13218 = _wapi_handle_type (handle);
  if (D.13218 == 13) goto <D.13210>; else goto <D.13211>;
  <D.13210>:
  D.13209 = 0;
  return D.13209;
  <D.13211>:
  D.13219 = idx / 256;
  D.13220 = _wapi_private_handles[D.13219];
  D.13221 = (long unsigned int) idx;
  D.13222 = D.13221 & 255;
  D.13223 = D.13222 * 200;
  D.13224 = D.13220 + D.13223;
  D.13225 = &D.13224->signal_mutex;
  ret = pthread_mutex_trylock (D.13225);
  if (ret != 0) goto <D.13226>; else goto <D.13227>;
  <D.13226>:
  _wapi_handle_unref (handle);
  <D.13227>:
  D.13209 = ret;
  return D.13209;
}


_wapi_handle_unlock_handle (void * handle)
{
  long int handle.86;
  int D.13232;
  <unnamed type> D.13235;
  <unnamed type> D.13237;
  <unnamed type> D.13239;
  <unnamed type> D.13241;
  unsigned int D.13242;
  struct _WapiHandleUnshared * D.13243;
  long unsigned int D.13244;
  long unsigned int D.13245;
  long unsigned int D.13246;
  struct _WapiHandleUnshared * D.13247;
  union mono_mutex_t * D.13248;
  guint32 idx;
  int ret;

  handle.86 = (long int) handle;
  idx = (guint32) handle.86;
  if (idx > 4194303) goto <D.13230>; else goto <D.13231>;
  <D.13230>:
  D.13232 = 0;
  return D.13232;
  <D.13231>:
  D.13235 = _wapi_handle_type (handle);
  if (D.13235 == 9) goto <D.13233>; else goto <D.13236>;
  <D.13236>:
  D.13237 = _wapi_handle_type (handle);
  if (D.13237 == 11) goto <D.13233>; else goto <D.13238>;
  <D.13238>:
  D.13239 = _wapi_handle_type (handle);
  if (D.13239 == 12) goto <D.13233>; else goto <D.13240>;
  <D.13240>:
  D.13241 = _wapi_handle_type (handle);
  if (D.13241 == 13) goto <D.13233>; else goto <D.13234>;
  <D.13233>:
  _wapi_handle_unref (handle);
  D.13232 = 0;
  return D.13232;
  <D.13234>:
  D.13242 = idx / 256;
  D.13243 = _wapi_private_handles[D.13242];
  D.13244 = (long unsigned int) idx;
  D.13245 = D.13244 & 255;
  D.13246 = D.13245 * 200;
  D.13247 = D.13243 + D.13246;
  D.13248 = &D.13247->signal_mutex;
  ret = pthread_mutex_unlock (D.13248);
  _wapi_handle_unref (handle);
  D.13232 = ret;
  return D.13232;
}


_wapi_handle_spin (guint32 ms)
{
  _Bool D.13250;
  long int D.13251;
  long int D.13252;
  unsigned int D.13255;
  long int D.13256;
  struct timespec sleepytime;

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


_wapi_handle_unlock_handles (guint32 numhandles, void * * handles)
{
  _Bool D.13257;
  long int D.13258;
  long int D.13259;
  long unsigned int D.13262;
  long unsigned int D.13263;
  void * * D.13264;
  guint32 i;
  int thr_ret;

  thr_ret = _wapi_handle_unlock_shared_handles ();
  D.13257 = thr_ret != 0;
  D.13258 = (long int) D.13257;
  D.13259 = __builtin_expect (D.13258, 0);
  if (D.13259 != 0) goto <D.13260>; else goto <D.13261>;
  <D.13260>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 1474, "thr_ret == 0");
  <D.13261>:
  i = 0;
  goto <D.12067>;
  <D.12066>:
  {
    void * handle;

    D.13262 = (long unsigned int) i;
    D.13263 = D.13262 * 8;
    D.13264 = handles + D.13263;
    handle = *D.13264;
    thr_ret = _wapi_handle_unlock_handle (handle);
    D.13257 = thr_ret != 0;
    D.13258 = (long int) D.13257;
    D.13259 = __builtin_expect (D.13258, 0);
    if (D.13259 != 0) goto <D.13265>; else goto <D.13266>;
    <D.13265>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 1482, "thr_ret == 0");
    <D.13266>:
  }
  i = i + 1;
  <D.12067>:
  if (i < numhandles) goto <D.12066>; else goto <D.12068>;
  <D.12068>:
}


_wapi_handle_wait_signal (gboolean poll)
{
  int D.13267;
  void * _wapi_global_signal_handle.87;

  _wapi_global_signal_handle.87 = _wapi_global_signal_handle;
  D.13267 = _wapi_handle_timedwait_signal_handle (_wapi_global_signal_handle.87, 0B, 1, poll);
  return D.13267;
}


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

  _wapi_global_signal_handle.88 = _wapi_global_signal_handle;
  D.13270 = _wapi_handle_timedwait_signal_handle (_wapi_global_signal_handle.88, timeout, 1, poll);
  return D.13270;
}


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

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


_wapi_handle_timedwait_signal_handle (void * handle, struct timespec * timeout, gboolean alertable, gboolean poll)
{
  <unnamed type> D.13277;
  <unnamed type> D.13279;
  <unnamed type> D.13281;
  <unnamed type> D.13283;
  struct _WapiHandleSharedLayout * _wapi_shared_layout.89;
  long int handle.90;
  unsigned int D.13286;
  unsigned int D.13287;
  struct _WapiHandleUnshared * D.13288;
  long unsigned int D.13289;
  long unsigned int D.13290;
  long unsigned int D.13291;
  struct _WapiHandleUnshared * D.13292;
  unsigned int D.13293;
  int D.13294;
  int D.13297;
  long int D.13302;
  long int D.13303;
  long int D.13306;
  long int D.13307;
  int D.13308;
  int D.13313;
  unsigned int D.13316;
  struct _WapiHandleUnshared * D.13317;
  long unsigned int D.13318;
  long unsigned int D.13319;
  long unsigned int D.13320;
  struct _WapiHandleUnshared * D.13321;

  D.13277 = _wapi_handle_type (handle);
  if (D.13277 == 9) goto <D.13275>; else goto <D.13278>;
  <D.13278>:
  D.13279 = _wapi_handle_type (handle);
  if (D.13279 == 11) goto <D.13275>; else goto <D.13280>;
  <D.13280>:
  D.13281 = _wapi_handle_type (handle);
  if (D.13281 == 12) goto <D.13275>; else goto <D.13282>;
  <D.13282>:
  D.13283 = _wapi_handle_type (handle);
  if (D.13283 == 13) goto <D.13275>; else goto <D.13276>;
  <D.13275>:
  _wapi_shared_layout.89 = _wapi_shared_layout;
  handle.90 = (long int) handle;
  D.13286 = (unsigned int) handle.90;
  D.13287 = D.13286 / 256;
  D.13288 = _wapi_private_handles[D.13287];
  handle.90 = (long int) handle;
  D.13286 = (unsigned int) handle.90;
  D.13289 = (long unsigned int) D.13286;
  D.13290 = D.13289 & 255;
  D.13291 = D.13290 * 200;
  D.13292 = D.13288 + D.13291;
  D.13293 = D.13292->u.shared.offset;
  D.13294 = _wapi_shared_layout.89->handles[D.13293].signalled;
  if (D.13294 == 1) goto <D.13295>; else goto <D.13296>;
  <D.13295>:
  D.13297 = 0;
  return D.13297;
  <D.13296>:
  if (timeout != 0B) goto <D.13298>; else goto <D.13299>;
  <D.13298>:
  {
    struct timespec fake_timeout;

    try
      {
        _wapi_calc_timeout (&fake_timeout, 100);
        D.13302 = fake_timeout.tv_sec;
        D.13303 = timeout->tv_sec;
        if (D.13302 > D.13303) goto <D.13300>; else goto <D.13304>;
        <D.13304>:
        D.13302 = fake_timeout.tv_sec;
        D.13303 = timeout->tv_sec;
        if (D.13302 == D.13303) goto <D.13305>; else goto <D.13301>;
        <D.13305>:
        D.13306 = fake_timeout.tv_nsec;
        D.13307 = timeout->tv_nsec;
        if (D.13306 > D.13307) goto <D.13300>; else goto <D.13301>;
        <D.13300>:
        _wapi_handle_spin (100);
        _wapi_shared_layout.89 = _wapi_shared_layout;
        handle.90 = (long int) handle;
        D.13286 = (unsigned int) handle.90;
        D.13287 = D.13286 / 256;
        D.13288 = _wapi_private_handles[D.13287];
        handle.90 = (long int) handle;
        D.13286 = (unsigned int) handle.90;
        D.13289 = (long unsigned int) D.13286;
        D.13290 = D.13289 & 255;
        D.13291 = D.13290 * 200;
        D.13292 = D.13288 + D.13291;
        D.13293 = D.13292->u.shared.offset;
        D.13308 = _wapi_shared_layout.89->handles[D.13293].signalled;
        if (D.13308 == 1) goto <D.13309>; else goto <D.13310>;
        <D.13309>:
        D.13297 = 0;
        return D.13297;
        <D.13310>:
        D.13297 = 110;
        return D.13297;
        <D.13301>:
      }
    finally
      {
        fake_timeout = {CLOBBER};
      }
  }
  <D.13299>:
  _wapi_handle_spin (100);
  D.13297 = 0;
  return D.13297;
  <D.13276>:
  {
    guint32 idx;
    int res;
    union pthread_cond_t * cond;
    union mono_mutex_t * mutex;

    handle.90 = (long int) handle;
    idx = (guint32) handle.90;
    if (alertable != 0) goto <D.13311>; else goto <D.13312>;
    <D.13311>:
    D.13313 = wapi_thread_set_wait_handle (handle);
    if (D.13313 == 0) goto <D.13314>; else goto <D.13315>;
    <D.13314>:
    D.13297 = 0;
    return D.13297;
    <D.13315>:
    <D.13312>:
    D.13316 = idx / 256;
    D.13317 = _wapi_private_handles[D.13316];
    D.13318 = (long unsigned int) idx;
    D.13319 = D.13318 & 255;
    D.13320 = D.13319 * 200;
    D.13321 = D.13317 + D.13320;
    cond = &D.13321->signal_cond;
    D.13316 = idx / 256;
    D.13317 = _wapi_private_handles[D.13316];
    D.13318 = (long unsigned int) idx;
    D.13319 = D.13318 & 255;
    D.13320 = D.13319 * 200;
    D.13321 = D.13317 + D.13320;
    mutex = &D.13321->signal_mutex;
    if (poll != 0) goto <D.13322>; else goto <D.13323>;
    <D.13322>:
    res = timedwait_signal_poll_cond (cond, mutex, timeout, alertable);
    goto <D.13324>;
    <D.13323>:
    if (timeout != 0B) goto <D.13325>; else goto <D.13326>;
    <D.13325>:
    res = pthread_cond_timedwait (cond, mutex, timeout);
    goto <D.13327>;
    <D.13326>:
    res = pthread_cond_wait (cond, mutex);
    <D.13327>:
    <D.13324>:
    if (alertable != 0) goto <D.13328>; else goto <D.13329>;
    <D.13328>:
    wapi_thread_clear_wait_handle (handle);
    <D.13329>:
    D.13297 = res;
    return D.13297;
  }
}


timedwait_signal_poll_cond (union pthread_cond_t * cond, union mono_mutex_t * mutex, struct timespec * timeout, gboolean alertable)
{
  long int D.13343;
  long int D.13344;
  long int D.13347;
  long int D.13348;
  int D.13351;
  struct timespec fake_timeout;
  int ret;

  try
    {
      if (alertable == 0) goto <D.13333>; else goto <D.13334>;
      <D.13333>:
      if (timeout != 0B) goto <D.13335>; else goto <D.13336>;
      <D.13335>:
      ret = pthread_cond_timedwait (cond, mutex, timeout);
      goto <D.13337>;
      <D.13336>:
      ret = pthread_cond_wait (cond, mutex);
      <D.13337>:
      goto <D.13338>;
      <D.13334>:
      _wapi_calc_timeout (&fake_timeout, 100);
      if (timeout != 0B) goto <D.13342>; else goto <D.13339>;
      <D.13342>:
      D.13343 = fake_timeout.tv_sec;
      D.13344 = timeout->tv_sec;
      if (D.13343 > D.13344) goto <D.13340>; else goto <D.13345>;
      <D.13345>:
      D.13343 = fake_timeout.tv_sec;
      D.13344 = timeout->tv_sec;
      if (D.13343 == D.13344) goto <D.13346>; else goto <D.13339>;
      <D.13346>:
      D.13347 = fake_timeout.tv_nsec;
      D.13348 = timeout->tv_nsec;
      if (D.13347 > D.13348) goto <D.13340>; else goto <D.13339>;
      <D.13340>:
      ret = pthread_cond_timedwait (cond, mutex, timeout);
      goto <D.13341>;
      <D.13339>:
      ret = pthread_cond_timedwait (cond, mutex, &fake_timeout);
      if (ret == 110) goto <D.13349>; else goto <D.13350>;
      <D.13349>:
      ret = 0;
      <D.13350>:
      <D.13341>:
      <D.13338>:
      D.13351 = ret;
      return D.13351;
    }
  finally
    {
      fake_timeout = {CLOBBER};
    }
}


_wapi_free_share_info (struct _WapiFileShare * share_info)
{
  int D.13354;
  _Bool D.13359;
  long int D.13360;
  long int D.13361;
  struct GHashTable * file_share_hash.91;
  _Bool D.13367;
  long int D.13368;
  long int D.13369;

  D.13354 = _wapi_shm_enabled ();
  if (D.13354 == 0) goto <D.13355>; else goto <D.13356>;
  <D.13355>:
  {
    int ret;

    ret = pthread_mutex_lock (&file_share_hash_mutex.mutex);
    if (ret != 0) goto <D.13357>; else goto <D.13358>;
    <D.13357>:
    monoeg_g_log (0B, 16, "Bad call to mono_mutex_lock result %d", ret);
    <D.13358>:
    D.13359 = ret != 0;
    D.13360 = (long int) D.13359;
    D.13361 = __builtin_expect (D.13360, 0);
    if (D.13361 != 0) goto <D.13362>; else goto <D.13363>;
    <D.13362>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 1602, "ret == 0");
    <D.13363>:
  }
  file_share_hash.91 = file_share_hash;
  monoeg_g_hash_table_remove (file_share_hash.91, share_info);
  {
    int ret;

    ret = pthread_mutex_unlock (&file_share_hash_mutex.mutex);
    if (ret != 0) goto <D.13365>; else goto <D.13366>;
    <D.13365>:
    monoeg_g_log (0B, 16, "Bad call to mono_mutex_unlock result %d", ret);
    <D.13366>:
    D.13367 = ret != 0;
    D.13368 = (long int) D.13367;
    D.13369 = __builtin_expect (D.13368, 0);
    if (D.13369 != 0) goto <D.13370>; else goto <D.13371>;
    <D.13370>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 1604, "ret == 0");
    <D.13371>:
  }
  goto <D.13372>;
  <D.13356>:
  memset (share_info, 0, 40);
  <D.13372>:
}


_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.13373;
  _Bool D.13374;
  long int D.13375;
  long int D.13376;
  int D.13381;
  struct GHashTable * file_share_hash.92;
  struct GHashTable * file_share_hash.93;
  _Bool D.13390;
  long int D.13391;
  long int D.13392;
  unsigned int D.13397;
  unsigned int D.13398;
  guint32 * D.13399;
  int D.13401;
  _Bool D.13404;
  long int D.13405;
  long int D.13406;
  struct _WapiFileShareLayout * _wapi_fileshare_layout.94;
  unsigned int D.13413;
  long unsigned int D.13418;
  long unsigned int D.13421;
  unsigned int i.95;
  unsigned int D.13425;
  int D.13435;
  struct _WapiFileShare * D.13436;
  guint32 * D.13439;
  int now.96;
  gboolean D.13441;
  struct _WapiFileShare * file_share;
  guint32 now;
  int thr_ret;
  int i;
  int first_unused;
  gboolean exists;

  D.13373 = time (0B);
  now = (guint32) D.13373;
  first_unused = -1;
  exists = 0;
  thr_ret = _wapi_handle_lock_shared_handles ();
  D.13374 = thr_ret != 0;
  D.13375 = (long int) D.13374;
  D.13376 = __builtin_expect (D.13375, 0);
  if (D.13376 != 0) goto <D.13377>; else goto <D.13378>;
  <D.13377>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 1643, "thr_ret == 0");
  <D.13378>:
  thr_ret = _wapi_shm_sem_lock (2);
  D.13374 = thr_ret != 0;
  D.13375 = (long int) D.13374;
  D.13376 = __builtin_expect (D.13375, 0);
  if (D.13376 != 0) goto <D.13379>; else goto <D.13380>;
  <D.13379>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 1647, "thr_ret == 0");
  <D.13380>:
  D.13381 = _wapi_shm_enabled ();
  if (D.13381 == 0) goto <D.13382>; else goto <D.13383>;
  <D.13382>:
  {
    struct _WapiFileShare tmp;

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

          ret = pthread_mutex_lock (&file_share_hash_mutex.mutex);
          if (ret != 0) goto <D.13388>; else goto <D.13389>;
          <D.13388>:
          monoeg_g_log (0B, 16, "Bad call to mono_mutex_lock result %d", ret);
          <D.13389>:
          D.13390 = ret != 0;
          D.13391 = (long int) D.13390;
          D.13392 = __builtin_expect (D.13391, 0);
          if (D.13392 != 0) goto <D.13393>; else goto <D.13394>;
          <D.13393>:
          monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 1665, "ret == 0");
          <D.13394>:
        }
        file_share_hash.92 = file_share_hash;
        file_share = monoeg_g_hash_table_lookup (file_share_hash.92, &tmp);
        if (file_share != 0B) goto <D.13395>; else goto <D.13396>;
        <D.13395>:
        D.13397 = file_share->sharemode;
        *old_sharemode = D.13397;
        D.13398 = file_share->access;
        *old_access = D.13398;
        *share_info = file_share;
        D.13399 = &file_share->handle_refs;
        InterlockedIncrement (D.13399);
        exists = 1;
        goto <D.13400>;
        <D.13396>:
        file_share = monoeg_malloc0 (40);
        file_share->device = device;
        file_share->inode = inode;
        D.13401 = _wapi_getpid ();
        file_share->opened_by_pid = D.13401;
        file_share->sharemode = new_sharemode;
        file_share->access = new_access;
        file_share->handle_refs = 1;
        *share_info = file_share;
        file_share_hash.92 = file_share_hash;
        monoeg_g_hash_table_insert_replace (file_share_hash.92, file_share, file_share, 0);
        <D.13400>:
        {
          int ret;

          ret = pthread_mutex_unlock (&file_share_hash_mutex.mutex);
          if (ret != 0) goto <D.13402>; else goto <D.13403>;
          <D.13402>:
          monoeg_g_log (0B, 16, "Bad call to mono_mutex_unlock result %d", ret);
          <D.13403>:
          D.13404 = ret != 0;
          D.13405 = (long int) D.13404;
          D.13406 = __builtin_expect (D.13405, 0);
          if (D.13406 != 0) goto <D.13407>; else goto <D.13408>;
          <D.13407>:
          monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 1689, "ret == 0");
          <D.13408>:
        }
      }
    finally
      {
        tmp = {CLOBBER};
      }
  }
  goto <D.13409>;
  <D.13383>:
  *share_info = 0B;
  i = 0;
  goto <D.12135>;
  <D.12134>:
  _wapi_fileshare_layout.94 = _wapi_fileshare_layout;
  file_share = &_wapi_fileshare_layout.94->share_info[i];
  if (first_unused == -1) goto <D.13411>; else goto <D.13412>;
  <D.13411>:
  D.13413 = file_share->handle_refs;
  if (D.13413 == 0) goto <D.13414>; else goto <D.13415>;
  <D.13414>:
  first_unused = i;
  // predicted unlikely by continue predictor.
  goto <D.12132>;
  <D.13415>:
  <D.13412>:
  D.13413 = file_share->handle_refs;
  if (D.13413 == 0) goto <D.13416>; else goto <D.13417>;
  <D.13416>:
  // predicted unlikely by continue predictor.
  goto <D.12132>;
  <D.13417>:
  D.13418 = file_share->device;
  if (D.13418 == device) goto <D.13419>; else goto <D.13420>;
  <D.13419>:
  D.13421 = file_share->inode;
  if (D.13421 == inode) goto <D.13422>; else goto <D.13423>;
  <D.13422>:
  D.13397 = file_share->sharemode;
  *old_sharemode = D.13397;
  D.13398 = file_share->access;
  *old_access = D.13398;
  *share_info = file_share;
  D.13399 = &file_share->handle_refs;
  InterlockedIncrement (D.13399);
  exists = 1;
  goto <D.12133>;
  <D.13423>:
  <D.13420>:
  <D.12132>:
  i = i + 1;
  <D.12135>:
  i.95 = (unsigned int) i;
  _wapi_fileshare_layout.94 = _wapi_fileshare_layout;
  D.13425 = _wapi_fileshare_layout.94->hwm;
  if (i.95 <= D.13425) goto <D.12134>; else goto <D.12133>;
  <D.12133>:
  if (exists == 0) goto <D.13426>; else goto <D.13427>;
  <D.13426>:
  if (i == 102400) goto <D.13430>; else goto <D.13428>;
  <D.13430>:
  if (first_unused == -1) goto <D.13431>; else goto <D.13428>;
  <D.13431>:
  goto <D.13429>;
  <D.13428>:
  if (first_unused == -1) goto <D.13432>; else goto <D.13433>;
  <D.13432>:
  _wapi_fileshare_layout.94 = _wapi_fileshare_layout;
  i = i + 1;
  file_share = &_wapi_fileshare_layout.94->share_info[i];
  _wapi_fileshare_layout.94 = _wapi_fileshare_layout;
  i.95 = (unsigned int) i;
  _wapi_fileshare_layout.94->hwm = i.95;
  goto <D.13434>;
  <D.13433>:
  _wapi_fileshare_layout.94 = _wapi_fileshare_layout;
  file_share = &_wapi_fileshare_layout.94->share_info[first_unused];
  <D.13434>:
  file_share->device = device;
  file_share->inode = inode;
  D.13435 = _wapi_getpid ();
  file_share->opened_by_pid = D.13435;
  file_share->sharemode = new_sharemode;
  file_share->access = new_access;
  file_share->handle_refs = 1;
  *share_info = file_share;
  <D.13429>:
  <D.13427>:
  D.13436 = *share_info;
  if (D.13436 != 0B) goto <D.13437>; else goto <D.13438>;
  <D.13437>:
  D.13436 = *share_info;
  D.13439 = &D.13436->timestamp;
  now.96 = (int) now;
  InterlockedExchange (D.13439, now.96);
  <D.13438>:
  <D.13409>:
  thr_ret = _wapi_shm_sem_unlock (2);
  _wapi_handle_unlock_shared_handles ();
  D.13441 = exists;
  return D.13441;
}


wapi_share_info_equal (const void * ka, const void * kb)
{
  gint D.13443;
  int iftmp.97;
  long unsigned int D.13447;
  long unsigned int D.13448;
  long unsigned int D.13450;
  long unsigned int D.13451;
  const struct _WapiFileShare * s1;
  const struct _WapiFileShare * s2;

  s1 = ka;
  s2 = kb;
  D.13447 = s1->device;
  D.13448 = s2->device;
  if (D.13447 == D.13448) goto <D.13449>; else goto <D.13445>;
  <D.13449>:
  D.13450 = s1->inode;
  D.13451 = s2->inode;
  if (D.13450 == D.13451) goto <D.13452>; else goto <D.13445>;
  <D.13452>:
  iftmp.97 = 1;
  goto <D.13446>;
  <D.13445>:
  iftmp.97 = 0;
  <D.13446>:
  D.13443 = iftmp.97;
  return D.13443;
}


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

  s = data;
  D.13455 = s->inode;
  D.13454 = (guint) D.13455;
  return D.13454;
}


_wapi_handle_check_share (struct _WapiFileShare * share_info, int fd)
{
  _Bool D.13457;
  long int D.13458;
  long int D.13459;
  int D.13464;
  int D.13467;
  struct _WapiHandleUnshared * D.13468;
  int D.13471;
  long unsigned int D.13472;
  long unsigned int D.13473;
  <unnamed type> D.13476;
  struct _WapiFileShare * D.13479;
  unsigned int i.98;
  unsigned int _wapi_fd_reserve.99;
  struct _WapiHandleSharedLayout * _wapi_shared_layout.100;
  <unnamed type> D.13484;
  int D.12171;
  int iftmp.101;
  int D.12170;
  const char[2] * D.13494;
  unsigned char D.13495;
  int D.13496;
  unsigned char D.13497;
  int D.13498;
  const unsigned char * D.13503;
  unsigned char D.13504;
  int D.13505;
  const unsigned char * D.13506;
  unsigned char D.13507;
  int D.13508;
  const unsigned char * D.13513;
  unsigned char D.13514;
  int D.13515;
  const unsigned char * D.13516;
  unsigned char D.13517;
  int D.13518;
  const unsigned char * D.13523;
  unsigned char D.13524;
  int D.13525;
  const unsigned char * D.13526;
  unsigned char D.13527;
  int D.13528;
  char[256] * D.13530;
  int D.12180;
  int iftmp.102;
  int D.12179;
  const char[3] * D.13535;
  unsigned char D.13536;
  int D.13537;
  unsigned char D.13538;
  int D.13539;
  const unsigned char * D.13544;
  unsigned char D.13545;
  int D.13546;
  const unsigned char * D.13547;
  unsigned char D.13548;
  int D.13549;
  const unsigned char * D.13554;
  unsigned char D.13555;
  int D.13556;
  const unsigned char * D.13557;
  unsigned char D.13558;
  int D.13559;
  const unsigned char * D.13564;
  unsigned char D.13565;
  int D.13566;
  const unsigned char * D.13567;
  unsigned char D.13568;
  int D.13569;
  int D.13573;
  long unsigned int D.13574;
  long unsigned int D.13575;
  long unsigned int D.13578;
  long unsigned int D.13579;
  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.13457 = thr_ret != 0;
  D.13458 = (long int) D.13457;
  D.13459 = __builtin_expect (D.13458, 0);
  if (D.13459 != 0) goto <D.13460>; else goto <D.13461>;
  <D.13460>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 1803, "thr_ret == 0");
  <D.13461>:
  thr_ret = _wapi_shm_sem_lock (2);
  D.13457 = thr_ret != 0;
  D.13458 = (long int) D.13457;
  D.13459 = __builtin_expect (D.13458, 0);
  if (D.13459 != 0) goto <D.13462>; else goto <D.13463>;
  <D.13462>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 1807, "thr_ret == 0");
  <D.13463>:
  D.13464 = access ("/proc", 0);
  if (D.13464 == -1) goto <D.13465>; else goto <D.13466>;
  <D.13465>:
  _wapi_handle_check_share_by_pid (share_info);
  goto done;
  <D.13466>:
  i = 0;
  goto <D.12153>;
  <D.12152>:
  D.13467 = i / 256;
  D.13468 = _wapi_private_handles[D.13467];
  if (D.13468 != 0B) goto <D.13469>; else goto <D.13470>;
  <D.13469>:
  {
    struct _WapiHandleUnshared * handle;

    D.13467 = i / 256;
    D.13468 = _wapi_private_handles[D.13467];
    D.13471 = i % 256;
    D.13472 = (long unsigned int) D.13471;
    D.13473 = D.13472 * 200;
    handle = D.13468 + D.13473;
    if (i != fd) goto <D.13474>; else goto <D.13475>;
    <D.13474>:
    D.13476 = handle->type;
    if (D.13476 == 1) goto <D.13477>; else goto <D.13478>;
    <D.13477>:
    {
      struct _WapiHandle_file * file_handle;

      file_handle = &handle->u.file;
      D.13479 = file_handle->share_info;
      if (D.13479 == share_info) goto done; else goto <D.13480>;
      <D.13480>:
    }
    <D.13478>:
    <D.13475>:
  }
  <D.13470>:
  i = i + 1;
  <D.12153>:
  i.98 = (unsigned int) i;
  _wapi_fd_reserve.99 = _wapi_fd_reserve;
  if (i.98 < _wapi_fd_reserve.99) goto <D.12152>; else goto <D.12154>;
  <D.12154>:
  i = 0;
  goto <D.12185>;
  <D.12184>:
  {
    struct _WapiHandleShared * shared;
    struct _WapiHandle_process * process_handle;

    _wapi_shared_layout.100 = _wapi_shared_layout;
    shared = &_wapi_shared_layout.100->handles[i];
    D.13484 = shared->type;
    if (D.13484 == 9) goto <D.13485>; else goto <D.13486>;
    <D.13485>:
    {
      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.13487>; else goto <D.13488>;
          <D.13487>:
          // predicted unlikely by continue predictor.
          goto <D.12160>;
          <D.13488>:
          proc_fds = 1;
          goto <D.12181>;
          <D.12182>:
          {
            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.13492>; else goto <D.13493>;
                  <D.13492>:
                  {
                    const unsigned char * __s2;
                    int __result;

                    __s2 = &fd_entry->d_name;
                    D.13494 = ".";
                    D.13495 = MEM[(const unsigned char *)D.13494];
                    D.13496 = (int) D.13495;
                    D.13497 = *__s2;
                    D.13498 = (int) D.13497;
                    __result = D.13496 - D.13498;
                    {
                      if (__s2_len != 0) goto <D.13499>; else goto <D.13500>;
                      <D.13499>:
                      if (__result == 0) goto <D.13501>; else goto <D.13502>;
                      <D.13501>:
                      D.13503 = &MEM[(void *)"." + 1B];
                      D.13504 = *D.13503;
                      D.13505 = (int) D.13504;
                      D.13506 = __s2 + 1;
                      D.13507 = *D.13506;
                      D.13508 = (int) D.13507;
                      __result = D.13505 - D.13508;
                      if (__s2_len > 1) goto <D.13509>; else goto <D.13510>;
                      <D.13509>:
                      if (__result == 0) goto <D.13511>; else goto <D.13512>;
                      <D.13511>:
                      D.13513 = &MEM[(void *)"." + 2B];
                      D.13514 = *D.13513;
                      D.13515 = (int) D.13514;
                      D.13516 = __s2 + 2;
                      D.13517 = *D.13516;
                      D.13518 = (int) D.13517;
                      __result = D.13515 - D.13518;
                      if (__s2_len > 2) goto <D.13519>; else goto <D.13520>;
                      <D.13519>:
                      if (__result == 0) goto <D.13521>; else goto <D.13522>;
                      <D.13521>:
                      D.13523 = &MEM[(void *)"." + 3B];
                      D.13524 = *D.13523;
                      D.13525 = (int) D.13524;
                      D.13526 = __s2 + 3;
                      D.13527 = *D.13526;
                      D.13528 = (int) D.13527;
                      __result = D.13525 - D.13528;
                      <D.13522>:
                      <D.13520>:
                      <D.13512>:
                      <D.13510>:
                      <D.13502>:
                      <D.13500>:
                    }
                    D.12170 = __result;
                  }
                  iftmp.101 = -D.12170;
                  goto <D.13529>;
                  <D.13493>:
                  D.13530 = &fd_entry->d_name;
                  iftmp.101 = __builtin_strcmp (D.13530, ".");
                  <D.13529>:
                  D.12171 = iftmp.101;
                }
                if (D.12171 == 0) goto <D.13489>; else goto <D.13531>;
                <D.13531>:
                {
                  size_t __s1_len;
                  size_t __s2_len;

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

                    __s2 = &fd_entry->d_name;
                    D.13535 = "..";
                    D.13536 = MEM[(const unsigned char *)D.13535];
                    D.13537 = (int) D.13536;
                    D.13538 = *__s2;
                    D.13539 = (int) D.13538;
                    __result = D.13537 - D.13539;
                    {
                      if (__s2_len != 0) goto <D.13540>; else goto <D.13541>;
                      <D.13540>:
                      if (__result == 0) goto <D.13542>; else goto <D.13543>;
                      <D.13542>:
                      D.13544 = &MEM[(void *)".." + 1B];
                      D.13545 = *D.13544;
                      D.13546 = (int) D.13545;
                      D.13547 = __s2 + 1;
                      D.13548 = *D.13547;
                      D.13549 = (int) D.13548;
                      __result = D.13546 - D.13549;
                      if (__s2_len > 1) goto <D.13550>; else goto <D.13551>;
                      <D.13550>:
                      if (__result == 0) goto <D.13552>; else goto <D.13553>;
                      <D.13552>:
                      D.13554 = &MEM[(void *)".." + 2B];
                      D.13555 = *D.13554;
                      D.13556 = (int) D.13555;
                      D.13557 = __s2 + 2;
                      D.13558 = *D.13557;
                      D.13559 = (int) D.13558;
                      __result = D.13556 - D.13559;
                      if (__s2_len > 2) goto <D.13560>; else goto <D.13561>;
                      <D.13560>:
                      if (__result == 0) goto <D.13562>; else goto <D.13563>;
                      <D.13562>:
                      D.13564 = &MEM[(void *)".." + 3B];
                      D.13565 = *D.13564;
                      D.13566 = (int) D.13565;
                      D.13567 = __s2 + 3;
                      D.13568 = *D.13567;
                      D.13569 = (int) D.13568;
                      __result = D.13566 - D.13569;
                      <D.13563>:
                      <D.13561>:
                      <D.13553>:
                      <D.13551>:
                      <D.13543>:
                      <D.13541>:
                    }
                    D.12179 = __result;
                  }
                  iftmp.102 = -D.12179;
                  goto <D.13570>;
                  <D.13534>:
                  D.13530 = &fd_entry->d_name;
                  iftmp.102 = __builtin_strcmp (D.13530, "..");
                  <D.13570>:
                  D.12180 = iftmp.102;
                }
                if (D.12180 == 0) goto <D.13489>; else goto <D.13571>;
                <D.13571>:
                if (pid == self) goto <D.13572>; else goto <D.13490>;
                <D.13572>:
                D.13530 = &fd_entry->d_name;
                D.13573 = atoi (D.13530);
                if (D.13573 == fd) goto <D.13489>; else goto <D.13490>;
                <D.13489>:
                // predicted unlikely by continue predictor.
                goto <D.12181>;
                <D.13490>:
                D.13530 = &fd_entry->d_name;
                monoeg_g_snprintf (&path, 256, "/proc/%d/fd/%s", pid, D.13530);
                stat (&path, &link_stat);
                D.13574 = link_stat.st_dev;
                D.13575 = share_info->device;
                if (D.13574 == D.13575) goto <D.13576>; else goto <D.13577>;
                <D.13576>:
                D.13578 = link_stat.st_ino;
                D.13579 = share_info->inode;
                if (D.13578 == D.13579) goto <D.13580>; else goto <D.13581>;
                <D.13580>:
                found = 1;
                <D.13581>:
                <D.13577>:
              }
            finally
              {
                path = {CLOBBER};
                link_stat = {CLOBBER};
              }
          }
          <D.12181>:
          fd_entry = readdir (fd_dir);
          if (fd_entry != 0B) goto <D.12182>; else goto <D.12183>;
          <D.12183>:
          closedir (fd_dir);
        }
      finally
        {
          subdir = {CLOBBER};
        }
    }
    <D.13486>:
  }
  <D.12160>:
  i = i + 1;
  <D.12185>:
  if (i <= 255) goto <D.12184>; else goto <D.12186>;
  <D.12186>:
  if (proc_fds == 0) goto <D.13582>; else goto <D.13583>;
  <D.13582>:
  _wapi_handle_check_share_by_pid (share_info);
  goto <D.13584>;
  <D.13583>:
  if (found == 0) goto <D.13585>; else goto <D.13586>;
  <D.13585>:
  _wapi_free_share_info (share_info);
  <D.13586>:
  <D.13584>:
  done:
  thr_ret = _wapi_shm_sem_unlock (2);
  _wapi_handle_unlock_shared_handles ();
}


atoi (const char * __nptr)
{
  int D.13591;
  long int D.13592;

  D.13592 = strtol (__nptr, 0B, 10);
  D.13591 = (int) D.13592;
  return D.13591;
}


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

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


_wapi_handle_check_share_by_pid (struct _WapiFileShare * share_info)
{
  int D.13598;
  int D.13599;
  int * D.13602;
  int D.13603;

  D.13598 = share_info->opened_by_pid;
  D.13599 = kill (D.13598, 0);
  if (D.13599 == -1) goto <D.13600>; else goto <D.13601>;
  <D.13600>:
  D.13602 = __errno_location ();
  D.13603 = *D.13602;
  if (D.13603 == 3) goto <D.13596>; else goto <D.13604>;
  <D.13604>:
  D.13602 = __errno_location ();
  D.13603 = *D.13602;
  if (D.13603 == 1) goto <D.13596>; else goto <D.13597>;
  <D.13596>:
  _wapi_free_share_info (share_info);
  <D.13597>:
  <D.13601>:
}


_wapi_handle_dump ()
{
  long int D.13605;
  long int D.13606;
  _Bool D.13609;
  long int D.13610;
  long int D.13611;
  struct _WapiHandleUnshared * D.13614;
  long unsigned int D.13617;
  long unsigned int D.13618;
  <unnamed type> D.13619;
  unsigned int D.13622;
  unsigned int D.13623;
  const char * D.13624;
  const char * iftmp.103;
  int D.13626;
  unsigned int D.13630;
  void (*<Tc09>) (void *) D.13631;
  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.13632;
  unsigned int _wapi_private_handle_slot_count.104;
  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.13605 = (long int) __not_first_call;
        D.13606 = __builtin_expect (D.13605, 0);
        if (D.13606 != 0) goto <D.13607>; else goto <D.13608>;
        <D.13607>:
        __cancel_routine (__cancel_arg);
        __pthread_unwind_next (&__cancel_buf);
        <D.13608>:
        __pthread_register_cancel (&__cancel_buf);
        thr_ret = pthread_mutex_lock (&scan_mutex);
        D.13609 = thr_ret != 0;
        D.13610 = (long int) D.13609;
        D.13611 = __builtin_expect (D.13610, 0);
        if (D.13611 != 0) goto <D.13612>; else goto <D.13613>;
        <D.13612>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 1943, "thr_ret == 0");
        <D.13613>:
        i = 0;
        goto <D.12205>;
        <D.12204>:
        D.13614 = _wapi_private_handles[i];
        if (D.13614 != 0B) goto <D.13615>; else goto <D.13616>;
        <D.13615>:
        k = 0;
        goto <D.12202>;
        <D.12201>:
        D.13614 = _wapi_private_handles[i];
        D.13617 = (long unsigned int) k;
        D.13618 = D.13617 * 200;
        handle_data = D.13614 + D.13618;
        D.13619 = handle_data->type;
        if (D.13619 == 0) goto <D.13620>; else goto <D.13621>;
        <D.13620>:
        // predicted unlikely by continue predictor.
        goto <D.12200>;
        <D.13621>:
        D.13622 = i * 256;
        D.13623 = D.13622 + k;
        D.13619 = handle_data->type;
        D.13624 = _wapi_handle_typename[D.13619];
        D.13626 = handle_data->signalled;
        if (D.13626 != 0) goto <D.13627>; else goto <D.13628>;
        <D.13627>:
        iftmp.103 = "Sg";
        goto <D.13629>;
        <D.13628>:
        iftmp.103 = "Un";
        <D.13629>:
        D.13630 = handle_data->ref;
        monoeg_g_print ("%3x [%7s] %s %d ", D.13623, D.13624, iftmp.103, D.13630);
        D.13619 = handle_data->type;
        D.13631 = handle_details[D.13619];
        D.13632 = &handle_data->u;
        D.13631 (D.13632);
        monoeg_g_print ("\n");
        <D.12200>:
        k = k + 1;
        <D.12202>:
        if (k <= 255) goto <D.12201>; else goto <D.12203>;
        <D.12203>:
        <D.13616>:
        i = i + 1;
        <D.12205>:
        _wapi_private_handle_slot_count.104 = _wapi_private_handle_slot_count;
        if (i < _wapi_private_handle_slot_count.104) goto <D.12204>; else goto <D.12206>;
        <D.12206>:
        thr_ret = pthread_mutex_unlock (&scan_mutex);
        D.13609 = thr_ret != 0;
        D.13610 = (long int) D.13609;
        D.13611 = __builtin_expect (D.13610, 0);
        if (D.13611 != 0) goto <D.13634>; else goto <D.13635>;
        <D.13634>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 1966, "thr_ret == 0");
        <D.13635>:
        __pthread_unregister_cancel (&__cancel_buf);
        if (0 != 0) goto <D.13636>; else goto <D.13637>;
        <D.13636>:
        __cancel_routine (__cancel_arg);
        <D.13637>:
      }
    finally
      {
        __cancel_buf = {CLOBBER};
      }
  }
}


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

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


_wapi_handle_update_refs ()
{
  long int D.13641;
  _Bool D.13642;
  long int D.13643;
  long int D.13644;
  long int D.13649;
  long int D.13650;
  struct _WapiHandleUnshared * D.13653;
  long unsigned int D.13656;
  long unsigned int D.13657;
  <unnamed type> D.13661;
  struct _WapiHandleSharedLayout * _wapi_shared_layout.105;
  unsigned int D.13666;
  guint32 * D.13667;
  int now.106;
  struct _WapiFileShare * D.13671;
  _Bool D.13672;
  long int D.13673;
  long int D.13674;
  guint32 * D.13677;
  unsigned int _wapi_private_handle_slot_count.107;
  guint32 i;
  guint32 k;
  int thr_ret;
  guint32 now;

  D.13641 = time (0B);
  now = (guint32) D.13641;
  thr_ret = _wapi_handle_lock_shared_handles ();
  D.13642 = thr_ret != 0;
  D.13643 = (long int) D.13642;
  D.13644 = __builtin_expect (D.13643, 0);
  if (D.13644 != 0) goto <D.13645>; else goto <D.13646>;
  <D.13645>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 1984, "thr_ret == 0");
  <D.13646>:
  thr_ret = _wapi_shm_sem_lock (2);
  D.13642 = thr_ret != 0;
  D.13643 = (long int) D.13642;
  D.13644 = __builtin_expect (D.13643, 0);
  if (D.13644 != 0) goto <D.13647>; else goto <D.13648>;
  <D.13647>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 1988, "thr_ret == 0");
  <D.13648>:
  {
    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.13649 = (long int) __not_first_call;
        D.13650 = __builtin_expect (D.13649, 0);
        if (D.13650 != 0) goto <D.13651>; else goto <D.13652>;
        <D.13651>:
        __cancel_routine (__cancel_arg);
        __pthread_unwind_next (&__cancel_buf);
        <D.13652>:
        __pthread_register_cancel (&__cancel_buf);
        thr_ret = pthread_mutex_lock (&scan_mutex);
        i = 0;
        goto <D.12231>;
        <D.12230>:
        D.13653 = _wapi_private_handles[i];
        if (D.13653 != 0B) goto <D.13654>; else goto <D.13655>;
        <D.13654>:
        k = 0;
        goto <D.12228>;
        <D.12227>:
        {
          struct _WapiHandleUnshared * handle;

          D.13653 = _wapi_private_handles[i];
          D.13656 = (long unsigned int) k;
          D.13657 = D.13656 * 200;
          handle = D.13653 + D.13657;
          D.13661 = handle->type;
          if (D.13661 == 9) goto <D.13658>; else goto <D.13662>;
          <D.13662>:
          D.13661 = handle->type;
          if (D.13661 == 11) goto <D.13658>; else goto <D.13663>;
          <D.13663>:
          D.13661 = handle->type;
          if (D.13661 == 12) goto <D.13658>; else goto <D.13664>;
          <D.13664>:
          D.13661 = handle->type;
          if (D.13661 == 13) goto <D.13658>; else goto <D.13659>;
          <D.13658>:
          {
            struct _WapiHandleShared * shared_data;

            _wapi_shared_layout.105 = _wapi_shared_layout;
            D.13666 = handle->u.shared.offset;
            shared_data = &_wapi_shared_layout.105->handles[D.13666];
            D.13667 = &shared_data->timestamp;
            now.106 = (int) now;
            InterlockedExchange (D.13667, now.106);
          }
          goto <D.13660>;
          <D.13659>:
          D.13661 = handle->type;
          if (D.13661 == 1) goto <D.13669>; else goto <D.13670>;
          <D.13669>:
          {
            struct _WapiHandle_file * file_handle;

            file_handle = &handle->u.file;
            D.13671 = file_handle->share_info;
            D.13672 = D.13671 == 0B;
            D.13673 = (long int) D.13672;
            D.13674 = __builtin_expect (D.13673, 0);
            if (D.13674 != 0) goto <D.13675>; else goto <D.13676>;
            <D.13675>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 2014, "file_handle->share_info != NULL");
            <D.13676>:
            D.13671 = file_handle->share_info;
            D.13677 = &D.13671->timestamp;
            now.106 = (int) now;
            InterlockedExchange (D.13677, now.106);
          }
          <D.13670>:
          <D.13660>:
        }
        k = k + 1;
        <D.12228>:
        if (k <= 255) goto <D.12227>; else goto <D.12229>;
        <D.12229>:
        <D.13655>:
        i = i + 1;
        <D.12231>:
        _wapi_private_handle_slot_count.107 = _wapi_private_handle_slot_count;
        if (i < _wapi_private_handle_slot_count.107) goto <D.12230>; else goto <D.12232>;
        <D.12232>:
        thr_ret = pthread_mutex_unlock (&scan_mutex);
        D.13642 = thr_ret != 0;
        D.13643 = (long int) D.13642;
        D.13644 = __builtin_expect (D.13643, 0);
        if (D.13644 != 0) goto <D.13679>; else goto <D.13680>;
        <D.13679>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 2025, "thr_ret == 0");
        <D.13680>:
        __pthread_unregister_cancel (&__cancel_buf);
        if (0 != 0) goto <D.13681>; else goto <D.13682>;
        <D.13681>:
        __cancel_routine (__cancel_arg);
        <D.13682>:
      }
    finally
      {
        __cancel_buf = {CLOBBER};
      }
  }
  thr_ret = _wapi_shm_sem_unlock (2);
  _wapi_handle_unlock_shared_handles ();
}


