_wapi_getpid ()
{
  pid_t D.11824;

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


pid_init ()
{
  int D.11826;

  D.11826 = getpid ();
  _wapi_pid = D.11826;
}


wapi_init ()
{
  int D.11829;
  unsigned int D.11830;
  unsigned int _wapi_fd_reserve.0;
  unsigned int D.11832;
  unsigned int D.11833;
  unsigned int _wapi_private_handle_count.1;
  unsigned int D.11835;
  unsigned int _wapi_private_handle_slot_count.2;
  unsigned int D.11837;
  void * D.11838;
  struct _WapiHandleSharedLayout * _wapi_shared_layout.3;
  _Bool D.11840;
  long int D.11841;
  long int D.11842;
  int D.11845;
  void * D.11848;
  struct _WapiFileShareLayout * _wapi_fileshare_layout.4;
  _Bool D.11850;
  long int D.11851;
  long int D.11852;
  int D.11855;
  void * D.11858;
  void * _wapi_global_signal_handle.5;
  long int _wapi_global_signal_handle.6;
  unsigned int D.11861;
  unsigned int D.11862;
  struct _WapiHandleUnshared * D.11863;
  long unsigned int D.11864;
  long unsigned int D.11865;
  long unsigned int D.11866;
  struct _WapiHandleUnshared * D.11867;
  union pthread_cond_t * D.11868;
  union mono_mutex_t * D.11869;

  if (0 != 0) goto <D.11827>; else goto <D.11828>;
  <D.11827>:
  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.11828>:
  D.11829 = getdtablesize ();
  D.11830 = (unsigned int) D.11829;
  _wapi_fd_reserve = D.11830;
  _wapi_fd_reserve.0 = _wapi_fd_reserve;
  D.11832 = _wapi_fd_reserve.0 + 255;
  D.11833 = D.11832 & 4294967040;
  _wapi_fd_reserve = D.11833;
  <D.11344>:
  _wapi_private_handle_count.1 = _wapi_private_handle_count;
  D.11835 = _wapi_private_handle_count.1 + 256;
  _wapi_private_handle_count = D.11835;
  _wapi_private_handle_slot_count.2 = _wapi_private_handle_slot_count;
  D.11837 = _wapi_private_handle_slot_count.2 + 1;
  _wapi_private_handle_slot_count = D.11837;
  _wapi_fd_reserve.0 = _wapi_fd_reserve;
  _wapi_private_handle_count.1 = _wapi_private_handle_count;
  if (_wapi_fd_reserve.0 > _wapi_private_handle_count.1) goto <D.11344>; else goto <D.11345>;
  <D.11345>:
  _wapi_shm_semaphores_init ();
  D.11838 = _wapi_shm_attach (0);
  _wapi_shared_layout = D.11838;
  _wapi_shared_layout.3 = _wapi_shared_layout;
  D.11840 = _wapi_shared_layout.3 == 0B;
  D.11841 = (long int) D.11840;
  D.11842 = __builtin_expect (D.11841, 0);
  if (D.11842 != 0) goto <D.11843>; else goto <D.11844>;
  <D.11843>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 271, "_wapi_shared_layout != NULL");
  <D.11844>:
  D.11845 = _wapi_shm_enabled ();
  if (D.11845 != 0) goto <D.11846>; else goto <D.11847>;
  <D.11846>:
  D.11848 = _wapi_shm_attach (1);
  _wapi_fileshare_layout = D.11848;
  _wapi_fileshare_layout.4 = _wapi_fileshare_layout;
  D.11850 = _wapi_fileshare_layout.4 == 0B;
  D.11851 = (long int) D.11850;
  D.11852 = __builtin_expect (D.11851, 0);
  if (D.11852 != 0) goto <D.11853>; else goto <D.11854>;
  <D.11853>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 276, "_wapi_fileshare_layout != NULL");
  <D.11854>:
  <D.11847>:
  D.11855 = _wapi_shm_enabled ();
  if (D.11855 != 0) goto <D.11856>; else goto <D.11857>;
  <D.11856>:
  _wapi_collection_init ();
  <D.11857>:
  _wapi_io_init ();
  pthread_mutex_init (&scan_mutex, 0B);
  D.11858 = _wapi_handle_new (6, 0B);
  _wapi_global_signal_handle = D.11858;
  _wapi_global_signal_handle.5 = _wapi_global_signal_handle;
  _wapi_global_signal_handle.6 = (long int) _wapi_global_signal_handle.5;
  D.11861 = (unsigned int) _wapi_global_signal_handle.6;
  D.11862 = D.11861 / 256;
  D.11863 = _wapi_private_handles[D.11862];
  _wapi_global_signal_handle.5 = _wapi_global_signal_handle;
  _wapi_global_signal_handle.6 = (long int) _wapi_global_signal_handle.5;
  D.11861 = (unsigned int) _wapi_global_signal_handle.6;
  D.11864 = (long unsigned int) D.11861;
  D.11865 = D.11864 & 255;
  D.11866 = D.11865 * 200;
  D.11867 = D.11863 + D.11866;
  D.11868 = &D.11867->signal_cond;
  _wapi_global_signal_cond = D.11868;
  _wapi_global_signal_handle.5 = _wapi_global_signal_handle;
  _wapi_global_signal_handle.6 = (long int) _wapi_global_signal_handle.5;
  D.11861 = (unsigned int) _wapi_global_signal_handle.6;
  D.11862 = D.11861 / 256;
  D.11863 = _wapi_private_handles[D.11862];
  _wapi_global_signal_handle.5 = _wapi_global_signal_handle;
  _wapi_global_signal_handle.6 = (long int) _wapi_global_signal_handle.5;
  D.11861 = (unsigned int) _wapi_global_signal_handle.6;
  D.11864 = (long unsigned int) D.11861;
  D.11865 = D.11864 & 255;
  D.11866 = D.11865 * 200;
  D.11867 = D.11863 + D.11866;
  D.11869 = &D.11867->signal_mutex;
  _wapi_global_signal_mutex = D.11869;
  atexit (handle_cleanup);
}


handle_cleanup ()
{
  struct _WapiHandleUnshared * D.11870;
  long unsigned int D.11871;
  long unsigned int D.11872;
  <unnamed type> D.11873;
  int D.11874;
  int D.11875;
  long int D.11876;
  unsigned int D.11886;
  struct GHashTable * file_share_hash.7;
  int i;
  int j;
  int k;

  i = 0;
  goto <D.11336>;
  <D.11335>:
  j = 0;
  goto <D.11333>;
  <D.11332>:
  {
    struct _WapiHandleUnshared * handle_data;
    int type;
    void * handle;

    D.11870 = _wapi_private_handles[i];
    D.11871 = (long unsigned int) j;
    D.11872 = D.11871 * 200;
    handle_data = D.11870 + D.11872;
    D.11873 = handle_data->type;
    type = (int) D.11873;
    D.11874 = i * 256;
    D.11875 = D.11874 + j;
    D.11876 = (long int) D.11875;
    handle = (void *) D.11876;
    if (type == 9) goto <D.11877>; else goto <D.11879>;
    <D.11879>:
    if (type == 11) goto <D.11877>; else goto <D.11880>;
    <D.11880>:
    if (type == 12) goto <D.11877>; else goto <D.11881>;
    <D.11881>:
    if (type == 13) goto <D.11877>; else goto <D.11878>;
    <D.11877>:
    if (type == 3) goto <D.11882>; else goto <D.11883>;
    <D.11882>:
    if (1 != 0) goto <D.11884>; else goto <D.11885>;
    <D.11884>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 211, "0");
    <D.11885>:
    _wapi_thread_set_termination_details (handle, 0);
    <D.11883>:
    <D.11878>:
    D.11886 = handle_data->ref;
    k = (int) D.11886;
    goto <D.11330>;
    <D.11329>:
    _wapi_handle_unref_full (handle, 1);
    k = k + -1;
    <D.11330>:
    if (k > 0) goto <D.11329>; else goto <D.11331>;
    <D.11331>:
  }
  j = j + 1;
  <D.11333>:
  if (j <= 255) goto <D.11332>; else goto <D.11334>;
  <D.11334>:
  i = i + 1;
  <D.11336>:
  D.11870 = _wapi_private_handles[i];
  if (D.11870 != 0B) goto <D.11335>; else goto <D.11337>;
  <D.11337>:
  _wapi_shm_semaphores_remove ();
  _wapi_shm_detach (0);
  _wapi_shm_detach (1);
  file_share_hash.7 = file_share_hash;
  if (file_share_hash.7 != 0B) goto <D.11888>; else goto <D.11889>;
  <D.11888>:
  file_share_hash.7 = file_share_hash;
  monoeg_g_hash_table_destroy (file_share_hash.7);
  DeleteCriticalSection (&file_share_hash_mutex);
  <D.11889>:
  i = 0;
  goto <D.11339>;
  <D.11338>:
  D.11870 = _wapi_private_handles[i];
  monoeg_g_free (D.11870);
  i = i + 1;
  <D.11339>:
  if (i <= 16383) goto <D.11338>; else goto <D.11340>;
  <D.11340>:
}


_wapi_handle_unref_full (void * handle, gboolean ignore_private_busy_handles)
{
  long int handle.8;
  <unnamed type> D.11893;
  unsigned int D.11896;
  struct _WapiHandleUnshared * D.11897;
  long unsigned int D.11898;
  long unsigned int D.11899;
  long unsigned int D.11900;
  struct _WapiHandleUnshared * D.11901;
  guint * D.11902;
  int D.11903;
  _Bool D.11904;
  int iftmp.9;
  _Bool D.11916;
  long int D.11917;
  long int D.11918;
  long int D.11921;
  long int D.11922;
  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.11925;
  union mono_mutex_t * D.11928;
  union pthread_cond_t * D.11935;
  struct _WapiHandleSharedLayout * _wapi_shared_layout.10;
  unsigned int D.11944;
  unsigned int D.11945;
  unsigned int D.11948;
  guint32 idx;
  gboolean destroy;
  gboolean early_exit;
  int thr_ret;
  static const char __func__[24] = "_wapi_handle_unref_full";

  handle.8 = (long int) handle;
  idx = (guint32) handle.8;
  destroy = 0;
  early_exit = 0;
  if (idx > 4194303) goto <D.11891>; else goto <D.11892>;
  <D.11891>:
  return;
  <D.11892>:
  D.11893 = _wapi_handle_type (handle);
  if (D.11893 == 0) goto <D.11894>; else goto <D.11895>;
  <D.11894>:
  monoeg_g_log (0B, 16, "%s: Attempting to unref unused handle %p", &__func__, handle);
  return;
  <D.11895>:
  D.11896 = idx / 256;
  D.11897 = _wapi_private_handles[D.11896];
  D.11898 = (long unsigned int) idx;
  D.11899 = D.11898 & 255;
  D.11900 = D.11899 * 200;
  D.11901 = D.11897 + D.11900;
  D.11902 = &D.11901->ref;
  D.11903 = InterlockedDecrement (D.11902);
  D.11904 = D.11903 == 0;
  destroy = (gboolean) D.11904;
  if (destroy == 1) goto <D.11905>; else goto <D.11906>;
  <D.11905>:
  {
    struct _WapiHandleUnshared handle_data;
    struct _WapiHandleShared shared_handle_data;
    WapiHandleType type;
    void (*<Td75>) (void *, void *) close_func;
    gboolean is_shared;

    try
      {
        D.11896 = idx / 256;
        D.11897 = _wapi_private_handles[D.11896];
        D.11898 = (long unsigned int) idx;
        D.11899 = D.11898 & 255;
        D.11900 = D.11899 * 200;
        D.11901 = D.11897 + D.11900;
        type = D.11901->type;
        close_func = _wapi_handle_ops_get_close_func (type);
        if (type == 9) goto <D.11908>; else goto <D.11911>;
        <D.11911>:
        if (type == 11) goto <D.11908>; else goto <D.11912>;
        <D.11912>:
        if (type == 12) goto <D.11908>; else goto <D.11913>;
        <D.11913>:
        if (type == 13) goto <D.11908>; else goto <D.11909>;
        <D.11908>:
        iftmp.9 = 1;
        goto <D.11910>;
        <D.11909>:
        iftmp.9 = 0;
        <D.11910>:
        is_shared = iftmp.9;
        if (is_shared != 0) goto <D.11914>; else goto <D.11915>;
        <D.11914>:
        thr_ret = _wapi_handle_lock_shared_handles ();
        D.11916 = thr_ret != 0;
        D.11917 = (long int) D.11916;
        D.11918 = __builtin_expect (D.11917, 0);
        if (D.11918 != 0) goto <D.11919>; else goto <D.11920>;
        <D.11919>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 1080, "thr_ret == 0");
        <D.11920>:
        <D.11915>:
        {
          struct __pthread_unwind_buf_t __cancel_buf;
          void (*<Tc6>) (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.11921 = (long int) __not_first_call;
              D.11922 = __builtin_expect (D.11921, 0);
              if (D.11922 != 0) goto <D.11923>; else goto <D.11924>;
              <D.11923>:
              __cancel_routine (__cancel_arg);
              __pthread_unwind_next (&__cancel_buf);
              <D.11924>:
              __pthread_register_cancel (&__cancel_buf);
              thr_ret = pthread_mutex_lock (&scan_mutex);
              D.11896 = idx / 256;
              D.11897 = _wapi_private_handles[D.11896];
              D.11898 = (long unsigned int) idx;
              D.11899 = D.11898 & 255;
              D.11900 = D.11899 * 200;
              D.11901 = D.11897 + D.11900;
              memcpy (&handle_data, D.11901, 200);
              D.11896 = idx / 256;
              D.11897 = _wapi_private_handles[D.11896];
              D.11898 = (long unsigned int) idx;
              D.11899 = D.11898 & 255;
              D.11900 = D.11899 * 200;
              D.11901 = D.11897 + D.11900;
              D.11925 = &D.11901->u;
              memset (D.11925, 0, 96);
              D.11896 = idx / 256;
              D.11897 = _wapi_private_handles[D.11896];
              D.11898 = (long unsigned int) idx;
              D.11899 = D.11898 & 255;
              D.11900 = D.11899 * 200;
              D.11901 = D.11897 + D.11900;
              D.11901->type = 0;
              if (is_shared == 0) goto <D.11926>; else goto <D.11927>;
              <D.11926>:
              D.11896 = idx / 256;
              D.11897 = _wapi_private_handles[D.11896];
              D.11898 = (long unsigned int) idx;
              D.11899 = D.11898 & 255;
              D.11900 = D.11899 * 200;
              D.11901 = D.11897 + D.11900;
              D.11928 = &D.11901->signal_mutex;
              thr_ret = pthread_mutex_destroy (D.11928);
              if (thr_ret == 16) goto <D.11931>; else goto <D.11929>;
              <D.11931>:
              if (ignore_private_busy_handles != 0) goto <D.11932>; else goto <D.11929>;
              <D.11932>:
              early_exit = 1;
              goto <D.11930>;
              <D.11929>:
              if (thr_ret != 0) goto <D.11933>; else goto <D.11934>;
              <D.11933>:
              monoeg_g_log (0B, 4, "Error destroying handle %p mutex due to %d\n", handle, thr_ret);
              <D.11573>:
              goto <D.11573>;
              <D.11934>:
              D.11896 = idx / 256;
              D.11897 = _wapi_private_handles[D.11896];
              D.11898 = (long unsigned int) idx;
              D.11899 = D.11898 & 255;
              D.11900 = D.11899 * 200;
              D.11901 = D.11897 + D.11900;
              D.11935 = &D.11901->signal_cond;
              thr_ret = pthread_cond_destroy (D.11935);
              if (thr_ret == 16) goto <D.11938>; else goto <D.11936>;
              <D.11938>:
              if (ignore_private_busy_handles != 0) goto <D.11939>; else goto <D.11936>;
              <D.11939>:
              early_exit = 1;
              goto <D.11937>;
              <D.11936>:
              if (thr_ret != 0) goto <D.11940>; else goto <D.11941>;
              <D.11940>:
              monoeg_g_log (0B, 4, "Error destroying handle %p cond var due to %d\n", handle, thr_ret);
              <D.11574>:
              goto <D.11574>;
              <D.11941>:
              <D.11937>:
              <D.11930>:
              goto <D.11942>;
              <D.11927>:
              {
                struct _WapiHandleShared * shared;

                _wapi_shared_layout.10 = _wapi_shared_layout;
                D.11944 = handle_data.u.shared.offset;
                shared = &_wapi_shared_layout.10->handles[D.11944];
                memcpy (&shared_handle_data, shared, 336);
                D.11945 = shared->handle_refs;
                if (D.11945 != 0) goto <D.11946>; else goto <D.11947>;
                <D.11946>:
                D.11945 = shared->handle_refs;
                D.11948 = D.11945 + 4294967295;
                shared->handle_refs = D.11948;
                D.11945 = shared->handle_refs;
                if (D.11945 == 0) goto <D.11949>; else goto <D.11950>;
                <D.11949>:
                memset (shared, 0, 336);
                <D.11950>:
                <D.11947>:
              }
              <D.11942>:
              thr_ret = pthread_mutex_unlock (&scan_mutex);
              D.11916 = thr_ret != 0;
              D.11917 = (long int) D.11916;
              D.11918 = __builtin_expect (D.11917, 0);
              if (D.11918 != 0) goto <D.11951>; else goto <D.11952>;
              <D.11951>:
              monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 1138, "thr_ret == 0");
              <D.11952>:
              __pthread_unregister_cancel (&__cancel_buf);
              if (0 != 0) goto <D.11953>; else goto <D.11954>;
              <D.11953>:
              __cancel_routine (__cancel_arg);
              <D.11954>:
            }
          finally
            {
              __cancel_buf = {CLOBBER};
            }
        }
        if (early_exit != 0) goto <D.11955>; else goto <D.11956>;
        <D.11955>:
        return;
        <D.11956>:
        if (is_shared != 0) goto <D.11957>; else goto <D.11958>;
        <D.11957>:
        _wapi_handle_unlock_shared_handles ();
        <D.11958>:
        if (close_func != 0B) goto <D.11959>; else goto <D.11960>;
        <D.11959>:
        if (is_shared != 0) goto <D.11961>; else goto <D.11962>;
        <D.11961>:
        close_func (handle, &shared_handle_data.u);
        goto <D.11963>;
        <D.11962>:
        close_func (handle, &handle_data.u);
        <D.11963>:
        <D.11960>:
      }
    finally
      {
        handle_data = {CLOBBER};
        shared_handle_data = {CLOBBER};
      }
  }
  <D.11906>:
}


__attribute__((__unused__))
mono_mutex_unlock_in_cleanup (union mono_mutex_t * mutex)
{
  int D.11973;

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


_wapi_handle_type (void * handle)
{
  long int handle.11;
  unsigned int D.11980;
  struct _WapiHandleUnshared * D.11981;
  WapiHandleType D.11982;
  unsigned int D.11983;
  struct _WapiHandleUnshared * D.11984;
  long unsigned int D.11985;
  long unsigned int D.11986;
  long unsigned int D.11987;
  struct _WapiHandleUnshared * D.11988;
  guint32 idx;

  handle.11 = (long int) handle;
  idx = (guint32) handle.11;
  if (idx > 4194303) goto <D.11976>; else goto <D.11978>;
  <D.11978>:
  if (idx > 268435455) goto <D.11976>; else goto <D.11979>;
  <D.11979>:
  D.11980 = idx / 256;
  D.11981 = _wapi_private_handles[D.11980];
  if (D.11981 == 0B) goto <D.11976>; else goto <D.11977>;
  <D.11976>:
  D.11982 = 0;
  return D.11982;
  <D.11977>:
  D.11983 = idx / 256;
  D.11984 = _wapi_private_handles[D.11983];
  D.11985 = (long unsigned int) idx;
  D.11986 = D.11985 & 255;
  D.11987 = D.11986 * 200;
  D.11988 = D.11984 + D.11987;
  D.11982 = D.11988->type;
  return D.11982;
}


InterlockedDecrement (volatile gint32 * val)
{
  gint32 D.11990;
  unsigned int D.11991;

  D.11991 = __sync_sub_and_fetch_4 (val, 1);
  D.11990 = (gint32) D.11991;
  return D.11990;
}


_wapi_handle_ops_get_close_func (WapiHandleType type)
{
  struct _WapiHandleOps * D.11993;
  void (*<Td75>) (void *, void *) D.11996;
  void (*<Td75>) (void *, void *) D.11999;

  D.11993 = handle_ops[type];
  if (D.11993 != 0B) goto <D.11994>; else goto <D.11995>;
  <D.11994>:
  D.11993 = handle_ops[type];
  D.11996 = D.11993->close;
  if (D.11996 != 0B) goto <D.11997>; else goto <D.11998>;
  <D.11997>:
  D.11993 = handle_ops[type];
  D.11999 = D.11993->close;
  return D.11999;
  <D.11998>:
  <D.11995>:
  D.11999 = 0B;
  return D.11999;
}


_wapi_handle_lock_shared_handles ()
{
  int D.12001;

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


__attribute__((__artificial__, __gnu_inline__, __always_inline__, __nothrow__, __leaf__))
memcpy (void * restrict __dest, const void * restrict __src, size_t __len)
{
  void * D.12003;
  long unsigned int D.12004;

  D.12004 = __builtin_object_size (__dest, 0);
  D.12003 = __builtin___memcpy_chk (__dest, __src, __len, D.12004);
  return D.12003;
}


__attribute__((__artificial__, __gnu_inline__, __always_inline__, __nothrow__, __leaf__))
memset (void * __dest, int __ch, size_t __len)
{
  void * D.12006;
  long unsigned int D.12007;

  D.12007 = __builtin_object_size (__dest, 0);
  D.12006 = __builtin___memset_chk (__dest, __ch, __len, D.12007);
  return D.12006;
}


_wapi_handle_unlock_shared_handles ()
{
  int D.12009;

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


wapi_cleanup ()
{
  int _wapi_has_shut_down.12;
  _Bool D.12012;
  long int D.12013;
  long int D.12014;

  _wapi_has_shut_down.12 = _wapi_has_shut_down;
  D.12012 = _wapi_has_shut_down.12 != 0;
  D.12013 = (long int) D.12012;
  D.12014 = __builtin_expect (D.12013, 0);
  if (D.12014 != 0) goto <D.12015>; else goto <D.12016>;
  <D.12015>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 303, "_wapi_has_shut_down == FALSE");
  <D.12016>:
  _wapi_has_shut_down = 1;
  _wapi_error_cleanup ();
  _wapi_thread_cleanup ();
}


_wapi_handle_new (WapiHandleType type, void * handle_specific)
{
  int _wapi_has_shut_down.13;
  _Bool D.12018;
  long int D.12019;
  long int D.12020;
  int iftmp.14;
  unsigned int D.12027;
  _Bool D.12030;
  long int D.12031;
  long int D.12032;
  long int D.12035;
  long int D.12036;
  _Bool D.12039;
  long int D.12040;
  long int D.12041;
  unsigned int _wapi_private_handle_count.15;
  unsigned int D.12045;
  void * D.12047;
  unsigned int D.12048;
  unsigned int _wapi_private_handle_slot_count.16;
  unsigned int D.12050;
  unsigned int _wapi_fd_reserve.17;
  _Bool D.12058;
  long int D.12059;
  long int D.12060;
  long unsigned int D.12063;
  unsigned int D.12073;
  struct _WapiHandleUnshared * D.12074;
  long unsigned int D.12075;
  long unsigned int D.12076;
  struct _WapiHandleUnshared * D.12077;
  void * D.12078;
  guint32 handle_idx;
  void * handle;
  int thr_ret;
  void done = <<< error >>>;

  handle_idx = 0;
  _wapi_has_shut_down.13 = _wapi_has_shut_down;
  D.12018 = _wapi_has_shut_down.13 != 0;
  D.12019 = (long int) D.12018;
  D.12020 = __builtin_expect (D.12019, 0);
  if (D.12020 != 0) goto <D.12021>; else goto <D.12022>;
  <D.12021>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 466, "_wapi_has_shut_down == FALSE");
  <D.12022>:
  D.12027 = type + 4294967295;
  if (D.12027 <= 1) goto <D.12024>; else goto <D.12028>;
  <D.12028>:
  if (type == 7) goto <D.12024>; else goto <D.12029>;
  <D.12029>:
  if (type == 10) goto <D.12024>; else goto <D.12025>;
  <D.12024>:
  iftmp.14 = 1;
  goto <D.12026>;
  <D.12025>:
  iftmp.14 = 0;
  <D.12026>:
  D.12030 = iftmp.14 != 0;
  D.12031 = (long int) D.12030;
  D.12032 = __builtin_expect (D.12031, 0);
  if (D.12032 != 0) goto <D.12033>; else goto <D.12034>;
  <D.12033>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 471, "!_WAPI_FD_HANDLE(type)");
  <D.12034>:
  {
    struct __pthread_unwind_buf_t __cancel_buf;
    void (*<Tc6>) (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.12035 = (long int) __not_first_call;
        D.12036 = __builtin_expect (D.12035, 0);
        if (D.12036 != 0) goto <D.12037>; else goto <D.12038>;
        <D.12037>:
        __cancel_routine (__cancel_arg);
        __pthread_unwind_next (&__cancel_buf);
        <D.12038>:
        __pthread_register_cancel (&__cancel_buf);
        thr_ret = pthread_mutex_lock (&scan_mutex);
        D.12039 = thr_ret != 0;
        D.12040 = (long int) D.12039;
        D.12041 = __builtin_expect (D.12040, 0);
        if (D.12041 != 0) goto <D.12042>; else goto <D.12043>;
        <D.12042>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 476, "thr_ret == 0");
        <D.12043>:
        goto <D.11405>;
        <D.11404>:
        {
          int idx;

          _wapi_private_handle_count.15 = _wapi_private_handle_count;
          D.12045 = _wapi_private_handle_count.15 / 256;
          idx = (int) D.12045;
          if (idx > 16383) goto <D.11403>; else goto <D.12046>;
          <D.12046>:
          D.12047 = monoeg_malloc0 (51200);
          _wapi_private_handles[idx] = D.12047;
          _wapi_private_handle_count.15 = _wapi_private_handle_count;
          D.12048 = _wapi_private_handle_count.15 + 256;
          _wapi_private_handle_count = D.12048;
          _wapi_private_handle_slot_count.16 = _wapi_private_handle_slot_count;
          D.12050 = _wapi_private_handle_slot_count.16 + 1;
          _wapi_private_handle_slot_count = D.12050;
        }
        <D.11405>:
        handle_idx = _wapi_handle_new_internal (type, handle_specific);
        if (handle_idx == 0) goto <D.11404>; else goto <D.11403>;
        <D.11403>:
        thr_ret = pthread_mutex_unlock (&scan_mutex);
        D.12039 = thr_ret != 0;
        D.12040 = (long int) D.12039;
        D.12041 = __builtin_expect (D.12040, 0);
        if (D.12041 != 0) goto <D.12051>; else goto <D.12052>;
        <D.12051>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 493, "thr_ret == 0");
        <D.12052>:
        __pthread_unregister_cancel (&__cancel_buf);
        if (0 != 0) goto <D.12053>; else goto <D.12054>;
        <D.12053>:
        __cancel_routine (__cancel_arg);
        <D.12054>:
      }
    finally
      {
        __cancel_buf = {CLOBBER};
      }
  }
  if (handle_idx == 0) goto <D.12055>; else goto <D.12056>;
  <D.12055>:
  handle = -1B;
  goto done;
  <D.12056>:
  _wapi_fd_reserve.17 = _wapi_fd_reserve;
  D.12058 = handle_idx < _wapi_fd_reserve.17;
  D.12059 = (long int) D.12058;
  D.12060 = __builtin_expect (D.12059, 0);
  if (D.12060 != 0) goto <D.12061>; else goto <D.12062>;
  <D.12061>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 503, "handle_idx >= _wapi_fd_reserve");
  <D.12062>:
  D.12063 = (long unsigned int) handle_idx;
  handle = (void *) D.12063;
  if (type == 9) goto <D.12064>; else goto <D.12066>;
  <D.12066>:
  if (type == 11) goto <D.12064>; else goto <D.12067>;
  <D.12067>:
  if (type == 12) goto <D.12064>; else goto <D.12068>;
  <D.12068>:
  if (type == 13) goto <D.12064>; else goto <D.12065>;
  <D.12064>:
  {
    guint32 ref;

    ref = _wapi_handle_new_shared (type, handle_specific);
    if (ref == 0) goto <D.12069>; else goto <D.12070>;
    <D.12069>:
    _wapi_handle_collect ();
    ref = _wapi_handle_new_shared (type, handle_specific);
    if (ref == 0) goto <D.12071>; else goto <D.12072>;
    <D.12071>:
    handle = -1B;
    goto done;
    <D.12072>:
    <D.12070>:
    D.12073 = handle_idx / 256;
    D.12074 = _wapi_private_handles[D.12073];
    D.12063 = (long unsigned int) handle_idx;
    D.12075 = D.12063 & 255;
    D.12076 = D.12075 * 200;
    D.12077 = D.12074 + D.12076;
    D.12077->u.shared.offset = ref;
  }
  <D.12065>:
  done:
  D.12078 = handle;
  return D.12078;
}


_wapi_handle_new_internal (WapiHandleType type, void * handle_specific)
{
  int _wapi_has_shut_down.18;
  _Bool D.12087;
  long int D.12088;
  long int D.12089;
  unsigned int last.19;
  unsigned int _wapi_fd_reserve.20;
  struct _WapiHandleUnshared * D.12097;
  long unsigned int D.12100;
  long unsigned int D.12101;
  <unnamed type> D.12102;
  unsigned int last.21;
  guint32 D.12106;
  unsigned int _wapi_private_handle_slot_count.22;
  guint32 i;
  guint32 k;
  guint32 count;
  static guint32 last = 0;
  gboolean retry;
  void again = <<< error >>>;

  retry = 0;
  _wapi_has_shut_down.18 = _wapi_has_shut_down;
  D.12087 = _wapi_has_shut_down.18 != 0;
  D.12088 = (long int) D.12087;
  D.12089 = __builtin_expect (D.12088, 0);
  if (D.12089 != 0) goto <D.12090>; else goto <D.12091>;
  <D.12090>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 416, "_wapi_has_shut_down == FALSE");
  <D.12091>:
  last.19 = last;
  _wapi_fd_reserve.20 = _wapi_fd_reserve;
  if (last.19 < _wapi_fd_reserve.20) goto <D.12094>; else goto <D.12095>;
  <D.12094>:
  _wapi_fd_reserve.20 = _wapi_fd_reserve;
  last = _wapi_fd_reserve.20;
  goto <D.12096>;
  <D.12095>:
  retry = 1;
  <D.12096>:
  again:
  count = last;
  i = count / 256;
  goto <D.11387>;
  <D.11386>:
  D.12097 = _wapi_private_handles[i];
  if (D.12097 != 0B) goto <D.12098>; else goto <D.12099>;
  <D.12098>:
  k = count & 255;
  goto <D.11384>;
  <D.11383>:
  {
    struct _WapiHandleUnshared * handle;

    D.12097 = _wapi_private_handles[i];
    D.12100 = (long unsigned int) k;
    D.12101 = D.12100 * 200;
    handle = D.12097 + D.12101;
    D.12102 = handle->type;
    if (D.12102 == 0) goto <D.12103>; else goto <D.12104>;
    <D.12103>:
    last.21 = count + 1;
    last = last.21;
    _wapi_handle_init (handle, type, handle_specific);
    D.12106 = count;
    return D.12106;
    <D.12104>:
    count = count + 1;
  }
  k = k + 1;
  <D.11384>:
  if (k <= 255) goto <D.11383>; else goto <D.11385>;
  <D.11385>:
  <D.12099>:
  i = i + 1;
  <D.11387>:
  _wapi_private_handle_slot_count.22 = _wapi_private_handle_slot_count;
  if (i < _wapi_private_handle_slot_count.22) goto <D.11386>; else goto <D.11388>;
  <D.11388>:
  if (retry != 0) goto <D.12108>; else goto <D.12109>;
  <D.12108>:
  last.19 = last;
  _wapi_fd_reserve.20 = _wapi_fd_reserve;
  if (last.19 > _wapi_fd_reserve.20) goto <D.12110>; else goto <D.12111>;
  <D.12110>:
  _wapi_fd_reserve.20 = _wapi_fd_reserve;
  last = _wapi_fd_reserve.20;
  goto again;
  <D.12111>:
  <D.12109>:
  D.12106 = 0;
  return D.12106;
}


_wapi_handle_init (struct _WapiHandleUnshared * handle, WapiHandleType type, void * handle_specific)
{
  int _wapi_has_shut_down.23;
  _Bool D.12114;
  long int D.12115;
  long int D.12116;
  union pthread_cond_t * D.12127;
  _Bool D.12128;
  long int D.12129;
  long int D.12130;
  union mono_mutex_t * D.12133;
  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.12138;
  int thr_ret;

  _wapi_has_shut_down.23 = _wapi_has_shut_down;
  D.12114 = _wapi_has_shut_down.23 != 0;
  D.12115 = (long int) D.12114;
  D.12116 = __builtin_expect (D.12115, 0);
  if (D.12116 != 0) goto <D.12117>; else goto <D.12118>;
  <D.12117>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 332, "_wapi_has_shut_down == FALSE");
  <D.12118>:
  handle->type = type;
  handle->signalled = 0;
  handle->ref = 1;
  if (type != 9) goto <D.12119>; else goto <D.12120>;
  <D.12119>:
  if (type != 11) goto <D.12121>; else goto <D.12122>;
  <D.12121>:
  if (type != 12) goto <D.12123>; else goto <D.12124>;
  <D.12123>:
  if (type != 13) goto <D.12125>; else goto <D.12126>;
  <D.12125>:
  D.12127 = &handle->signal_cond;
  thr_ret = pthread_cond_init (D.12127, 0B);
  D.12128 = thr_ret != 0;
  D.12129 = (long int) D.12128;
  D.12130 = __builtin_expect (D.12129, 0);
  if (D.12130 != 0) goto <D.12131>; else goto <D.12132>;
  <D.12131>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 340, "thr_ret == 0");
  <D.12132>:
  D.12133 = &handle->signal_mutex;
  thr_ret = pthread_mutex_init (D.12133, 0B);
  D.12128 = thr_ret != 0;
  D.12129 = (long int) D.12128;
  D.12130 = __builtin_expect (D.12129, 0);
  if (D.12130 != 0) goto <D.12134>; else goto <D.12135>;
  <D.12134>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 343, "thr_ret == 0");
  <D.12135>:
  if (handle_specific != 0B) goto <D.12136>; else goto <D.12137>;
  <D.12136>:
  D.12138 = &handle->u;
  memcpy (D.12138, handle_specific, 96);
  <D.12137>:
  <D.12126>:
  <D.12124>:
  <D.12122>:
  <D.12120>:
}


_wapi_handle_new_shared (WapiHandleType type, void * handle_specific)
{
  int _wapi_has_shut_down.24;
  _Bool D.12140;
  long int D.12141;
  long int D.12142;
  struct _WapiHandleSharedLayout * _wapi_shared_layout.25;
  <unnamed type> D.12146;
  _Bool D.12149;
  long int D.12150;
  long int D.12151;
  WapiHandleType * D.12154;
  int type.26;
  int D.12156;
  unsigned int last.27;
  guint32 D.12160;
  unsigned int last.28;
  guint32 offset;
  static guint32 last = 1;
  int thr_ret;
  void again = <<< error >>>;

  _wapi_has_shut_down.24 = _wapi_has_shut_down;
  D.12140 = _wapi_has_shut_down.24 != 0;
  D.12141 = (long int) D.12140;
  D.12142 = __builtin_expect (D.12141, 0);
  if (D.12142 != 0) goto <D.12143>; else goto <D.12144>;
  <D.12143>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 359, "_wapi_has_shut_down == FALSE");
  <D.12144>:
  again:
  offset = last;
  goto <D.11370>;
  <D.11369>:
  {
    struct _WapiHandleShared * handle;

    _wapi_shared_layout.25 = _wapi_shared_layout;
    handle = &_wapi_shared_layout.25->handles[offset];
    D.12146 = handle->type;
    if (D.12146 == 0) goto <D.12147>; else goto <D.12148>;
    <D.12147>:
    thr_ret = _wapi_handle_lock_shared_handles ();
    D.12149 = thr_ret != 0;
    D.12150 = (long int) D.12149;
    D.12151 = __builtin_expect (D.12150, 0);
    if (D.12151 != 0) goto <D.12152>; else goto <D.12153>;
    <D.12152>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 369, "thr_ret == 0");
    <D.12153>:
    D.12154 = &handle->type;
    type.26 = (int) type;
    D.12156 = InterlockedCompareExchange (D.12154, type.26, 0);
    if (D.12156 == 0) goto <D.12157>; else goto <D.12158>;
    <D.12157>:
    last.27 = offset + 1;
    last = last.27;
    _wapi_handle_init_shared (handle, type, handle_specific);
    _wapi_handle_unlock_shared_handles ();
    D.12160 = offset;
    return D.12160;
    <D.12158>:
    _wapi_handle_unlock_shared_handles ();
    <D.12148>:
  }
  offset = offset + 1;
  <D.11370>:
  if (offset <= 255) goto <D.11369>; else goto <D.11371>;
  <D.11371>:
  last.28 = last;
  if (last.28 > 1) goto <D.12162>; else goto <D.12163>;
  <D.12162>:
  last = 1;
  goto again;
  <D.12163>:
  D.12160 = 0;
  return D.12160;
}


InterlockedCompareExchange (volatile gint32 * dest, gint32 exch, gint32 comp)
{
  gint32 D.12165;
  unsigned int comp.29;
  unsigned int exch.30;
  unsigned int D.12168;

  comp.29 = (unsigned int) comp;
  exch.30 = (unsigned int) exch;
  D.12168 = __sync_val_compare_and_swap_4 (dest, comp.29, exch.30);
  D.12165 = (gint32) D.12168;
  return D.12165;
}


_wapi_handle_init_shared (struct _WapiHandleShared * handle, WapiHandleType type, void * handle_specific)
{
  int _wapi_has_shut_down.31;
  _Bool D.12171;
  long int D.12172;
  long int D.12173;
  long int D.12176;
  unsigned int D.12177;
  union 
{
  struct _WapiHandle_process process;
  struct _WapiHandle_namedmutex namedmutex;
  struct _WapiHandle_namedsem namedsem;
  struct _WapiHandle_namedevent namedevent;
} * D.12180;

  _wapi_has_shut_down.31 = _wapi_has_shut_down;
  D.12171 = _wapi_has_shut_down.31 != 0;
  D.12172 = (long int) D.12171;
  D.12173 = __builtin_expect (D.12172, 0);
  if (D.12173 != 0) goto <D.12174>; else goto <D.12175>;
  <D.12174>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 315, "_wapi_has_shut_down == FALSE");
  <D.12175>:
  handle->type = type;
  D.12176 = time (0B);
  D.12177 = (unsigned int) D.12176;
  handle->timestamp = D.12177;
  handle->signalled = 0;
  handle->handle_refs = 1;
  if (handle_specific != 0B) goto <D.12178>; else goto <D.12179>;
  <D.12178>:
  D.12180 = &handle->u;
  memcpy (D.12180, handle_specific, 320);
  <D.12179>:
}


_wapi_handle_new_from_offset (WapiHandleType type, guint32 offset, gboolean timestamp)
{
  int _wapi_has_shut_down.32;
  _Bool D.12182;
  long int D.12183;
  long int D.12184;
  int iftmp.33;
  unsigned int D.12191;
  _Bool D.12194;
  long int D.12195;
  long int D.12196;
  int iftmp.34;
  _Bool D.12206;
  long int D.12207;
  long int D.12208;
  _Bool D.12211;
  long int D.12212;
  long int D.12213;
  struct _WapiHandleSharedLayout * _wapi_shared_layout.35;
  long int D.12219;
  guint32 * D.12220;
  int now.36;
  long int D.12222;
  long int D.12223;
  _Bool D.12226;
  long int D.12227;
  long int D.12228;
  struct _WapiHandleUnshared * D.12231;
  long unsigned int D.12234;
  long unsigned int D.12235;
  <unnamed type> D.12236;
  unsigned int D.12239;
  int D.12242;
  int D.12243;
  long unsigned int D.12244;
  unsigned int i.37;
  unsigned int _wapi_private_handle_slot_count.38;
  void * D.12253;
  <unnamed type> D.12256;
  long int D.12259;
  long int D.12260;
  unsigned int _wapi_private_handle_count.39;
  unsigned int D.12266;
  void * D.12267;
  unsigned int D.12268;
  unsigned int D.12269;
  unsigned int _wapi_fd_reserve.40;
  _Bool D.12275;
  long int D.12276;
  long int D.12277;
  long unsigned int D.12280;
  unsigned int D.12281;
  struct _WapiHandleUnshared * D.12282;
  long unsigned int D.12283;
  long unsigned int D.12284;
  struct _WapiHandleUnshared * D.12285;
  guint32 * D.12286;
  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.32 = _wapi_has_shut_down;
  D.12182 = _wapi_has_shut_down.32 != 0;
  D.12183 = (long int) D.12182;
  D.12184 = __builtin_expect (D.12183, 0);
  if (D.12184 != 0) goto <D.12185>; else goto <D.12186>;
  <D.12185>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 541, "_wapi_has_shut_down == FALSE");
  <D.12186>:
  D.12191 = type + 4294967295;
  if (D.12191 <= 1) goto <D.12188>; else goto <D.12192>;
  <D.12192>:
  if (type == 7) goto <D.12188>; else goto <D.12193>;
  <D.12193>:
  if (type == 10) goto <D.12188>; else goto <D.12189>;
  <D.12188>:
  iftmp.33 = 1;
  goto <D.12190>;
  <D.12189>:
  iftmp.33 = 0;
  <D.12190>:
  D.12194 = iftmp.33 != 0;
  D.12195 = (long int) D.12194;
  D.12196 = __builtin_expect (D.12195, 0);
  if (D.12196 != 0) goto <D.12197>; else goto <D.12198>;
  <D.12197>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 546, "!_WAPI_FD_HANDLE(type)");
  <D.12198>:
  if (type != 9) goto <D.12202>; else goto <D.12200>;
  <D.12202>:
  if (type != 11) goto <D.12203>; else goto <D.12200>;
  <D.12203>:
  if (type != 12) goto <D.12204>; else goto <D.12200>;
  <D.12204>:
  if (type != 13) goto <D.12205>; else goto <D.12200>;
  <D.12205>:
  iftmp.34 = 1;
  goto <D.12201>;
  <D.12200>:
  iftmp.34 = 0;
  <D.12201>:
  D.12206 = iftmp.34 != 0;
  D.12207 = (long int) D.12206;
  D.12208 = __builtin_expect (D.12207, 0);
  if (D.12208 != 0) goto <D.12209>; else goto <D.12210>;
  <D.12209>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 547, "_WAPI_SHARED_HANDLE(type)");
  <D.12210>:
  D.12211 = offset == 0;
  D.12212 = (long int) D.12211;
  D.12213 = __builtin_expect (D.12212, 0);
  if (D.12213 != 0) goto <D.12214>; else goto <D.12215>;
  <D.12214>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 548, "offset != 0");
  <D.12215>:
  _wapi_shared_layout.35 = _wapi_shared_layout;
  shared = &_wapi_shared_layout.35->handles[offset];
  if (timestamp != 0) goto <D.12217>; else goto <D.12218>;
  <D.12217>:
  {
    guint32 now;

    D.12219 = time (0B);
    now = (guint32) D.12219;
    D.12220 = &shared->timestamp;
    now.36 = (int) now;
    InterlockedExchange (D.12220, now.36);
  }
  <D.12218>:
  {
    struct __pthread_unwind_buf_t __cancel_buf;
    void (*<Tc6>) (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.12222 = (long int) __not_first_call;
        D.12223 = __builtin_expect (D.12222, 0);
        if (D.12223 != 0) goto <D.12224>; else goto <D.12225>;
        <D.12224>:
        __cancel_routine (__cancel_arg);
        __pthread_unwind_next (&__cancel_buf);
        <D.12225>:
        __pthread_register_cancel (&__cancel_buf);
        thr_ret = pthread_mutex_lock (&scan_mutex);
        D.12226 = thr_ret != 0;
        D.12227 = (long int) D.12226;
        D.12228 = __builtin_expect (D.12227, 0);
        if (D.12228 != 0) goto <D.12229>; else goto <D.12230>;
        <D.12229>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 560, "thr_ret == 0");
        <D.12230>:
        i = 0;
        goto <D.11432>;
        <D.11431>:
        D.12231 = _wapi_private_handles[i];
        if (D.12231 != 0B) goto <D.12232>; else goto <D.12233>;
        <D.12232>:
        k = 0;
        goto <D.11429>;
        <D.11428>:
        {
          struct _WapiHandleUnshared * handle_data;

          D.12231 = _wapi_private_handles[i];
          D.12234 = (long unsigned int) k;
          D.12235 = D.12234 * 200;
          handle_data = D.12231 + D.12235;
          D.12236 = handle_data->type;
          if (D.12236 == type) goto <D.12237>; else goto <D.12238>;
          <D.12237>:
          D.12239 = handle_data->u.shared.offset;
          if (D.12239 == offset) goto <D.12240>; else goto <D.12241>;
          <D.12240>:
          D.12242 = i * 256;
          D.12243 = D.12242 + k;
          D.12244 = (long unsigned int) D.12243;
          handle = (void *) D.12244;
          goto first_pass_done;
          <D.12241>:
          <D.12238>:
        }
        k = k + 1;
        <D.11429>:
        if (k <= 255) goto <D.11428>; else goto <D.11430>;
        <D.11430>:
        <D.12233>:
        i = i + 1;
        <D.11432>:
        i.37 = (unsigned int) i;
        _wapi_private_handle_slot_count.38 = _wapi_private_handle_slot_count;
        if (i.37 < _wapi_private_handle_slot_count.38) goto <D.11431>; else goto <D.11433>;
        <D.11433>:
        first_pass_done:
        thr_ret = pthread_mutex_unlock (&scan_mutex);
        D.12226 = thr_ret != 0;
        D.12227 = (long int) D.12226;
        D.12228 = __builtin_expect (D.12227, 0);
        if (D.12228 != 0) goto <D.12247>; else goto <D.12248>;
        <D.12247>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 578, "thr_ret == 0");
        <D.12248>:
        __pthread_unregister_cancel (&__cancel_buf);
        if (0 != 0) goto <D.12249>; else goto <D.12250>;
        <D.12249>:
        __cancel_routine (__cancel_arg);
        <D.12250>:
      }
    finally
      {
        __cancel_buf = {CLOBBER};
      }
  }
  if (handle != -1B) goto <D.12251>; else goto <D.12252>;
  <D.12251>:
  _wapi_handle_ref (handle);
  D.12253 = handle;
  return D.12253;
  <D.12252>:
  thr_ret = _wapi_handle_lock_shared_handles ();
  D.12226 = thr_ret != 0;
  D.12227 = (long int) D.12226;
  D.12228 = __builtin_expect (D.12227, 0);
  if (D.12228 != 0) goto <D.12254>; else goto <D.12255>;
  <D.12254>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 591, "thr_ret == 0");
  <D.12255>:
  D.12256 = shared->type;
  if (D.12256 == 0) goto done; else goto <D.12257>;
  <D.12257>:
  D.12256 = shared->type;
  if (D.12256 != type) goto done; else goto <D.12258>;
  <D.12258>:
  {
    struct __pthread_unwind_buf_t __cancel_buf;
    void (*<Tc6>) (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.12259 = (long int) __not_first_call;
        D.12260 = __builtin_expect (D.12259, 0);
        if (D.12260 != 0) goto <D.12261>; else goto <D.12262>;
        <D.12261>:
        __cancel_routine (__cancel_arg);
        __pthread_unwind_next (&__cancel_buf);
        <D.12262>:
        __pthread_register_cancel (&__cancel_buf);
        thr_ret = pthread_mutex_lock (&scan_mutex);
        D.12226 = thr_ret != 0;
        D.12227 = (long int) D.12226;
        D.12228 = __builtin_expect (D.12227, 0);
        if (D.12228 != 0) goto <D.12263>; else goto <D.12264>;
        <D.12263>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 610, "thr_ret == 0");
        <D.12264>:
        goto <D.11443>;
        <D.11442>:
        {
          int idx;

          _wapi_private_handle_count.39 = _wapi_private_handle_count;
          D.12266 = _wapi_private_handle_count.39 / 256;
          idx = (int) D.12266;
          D.12267 = monoeg_malloc0 (51200);
          _wapi_private_handles[idx] = D.12267;
          _wapi_private_handle_count.39 = _wapi_private_handle_count;
          D.12268 = _wapi_private_handle_count.39 + 256;
          _wapi_private_handle_count = D.12268;
          _wapi_private_handle_slot_count.38 = _wapi_private_handle_slot_count;
          D.12269 = _wapi_private_handle_slot_count.38 + 1;
          _wapi_private_handle_slot_count = D.12269;
        }
        <D.11443>:
        handle_idx = _wapi_handle_new_internal (type, 0B);
        if (handle_idx == 0) goto <D.11442>; else goto <D.11444>;
        <D.11444>:
        thr_ret = pthread_mutex_unlock (&scan_mutex);
        D.12226 = thr_ret != 0;
        D.12227 = (long int) D.12226;
        D.12228 = __builtin_expect (D.12227, 0);
        if (D.12228 != 0) goto <D.12270>; else goto <D.12271>;
        <D.12270>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 623, "thr_ret == 0");
        <D.12271>:
        __pthread_unregister_cancel (&__cancel_buf);
        if (0 != 0) goto <D.12272>; else goto <D.12273>;
        <D.12272>:
        __cancel_routine (__cancel_arg);
        <D.12273>:
      }
    finally
      {
        __cancel_buf = {CLOBBER};
      }
  }
  _wapi_fd_reserve.40 = _wapi_fd_reserve;
  D.12275 = handle_idx < _wapi_fd_reserve.40;
  D.12276 = (long int) D.12275;
  D.12277 = __builtin_expect (D.12276, 0);
  if (D.12277 != 0) goto <D.12278>; else goto <D.12279>;
  <D.12278>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 627, "handle_idx >= _wapi_fd_reserve");
  <D.12279>:
  D.12280 = (long unsigned int) handle_idx;
  handle = (void *) D.12280;
  D.12281 = handle_idx / 256;
  D.12282 = _wapi_private_handles[D.12281];
  D.12280 = (long unsigned int) handle_idx;
  D.12283 = D.12280 & 255;
  D.12284 = D.12283 * 200;
  D.12285 = D.12282 + D.12284;
  D.12285->u.shared.offset = offset;
  D.12286 = &shared->handle_refs;
  InterlockedIncrement (D.12286);
  done:
  _wapi_handle_unlock_shared_handles ();
  D.12253 = handle;
  return D.12253;
}


InterlockedExchange (volatile gint32 * val, gint32 new_val)
{
  unsigned int old_val.41;
  unsigned int new_val.42;
  unsigned int D.12297;
  int D.12298;
  gint32 D.12299;
  gint32 old_val;

  <D.11020>:
  old_val = *val;
  old_val.41 = (unsigned int) old_val;
  new_val.42 = (unsigned int) new_val;
  D.12297 = __sync_val_compare_and_swap_4 (val, old_val.41, new_val.42);
  D.12298 = (int) D.12297;
  if (D.12298 != old_val) goto <D.11020>; else goto <D.11021>;
  <D.11021>:
  D.12299 = old_val;
  return D.12299;
}


InterlockedIncrement (volatile gint32 * val)
{
  gint32 D.12301;
  unsigned int D.12302;

  D.12302 = __sync_add_and_fetch_4 (val, 1);
  D.12301 = (gint32) D.12302;
  return D.12301;
}


_wapi_handle_new_fd (WapiHandleType type, int fd, void * handle_specific)
{
  int _wapi_has_shut_down.43;
  _Bool D.12305;
  long int D.12306;
  long int D.12307;
  int iftmp.44;
  unsigned int D.12313;
  _Bool D.12317;
  long int D.12318;
  long int D.12319;
  int iftmp.45;
  _Bool D.12329;
  long int D.12330;
  long int D.12331;
  unsigned int fd.46;
  unsigned int _wapi_fd_reserve.47;
  void * D.12338;
  int D.12339;
  struct _WapiHandleUnshared * D.12340;
  int D.12343;
  long unsigned int D.12344;
  long unsigned int D.12345;
  <unnamed type> D.12346;
  _Bool D.12349;
  long int D.12350;
  long int D.12351;
  long unsigned int D.12354;
  struct _WapiHandleUnshared * handle;
  int thr_ret;

  _wapi_has_shut_down.43 = _wapi_has_shut_down;
  D.12305 = _wapi_has_shut_down.43 != 0;
  D.12306 = (long int) D.12305;
  D.12307 = __builtin_expect (D.12306, 0);
  if (D.12307 != 0) goto <D.12308>; else goto <D.12309>;
  <D.12308>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 669, "_wapi_has_shut_down == FALSE");
  <D.12309>:
  D.12313 = type + 4294967295;
  if (D.12313 > 1) goto <D.12314>; else goto <D.12311>;
  <D.12314>:
  if (type != 7) goto <D.12315>; else goto <D.12311>;
  <D.12315>:
  if (type != 10) goto <D.12316>; else goto <D.12311>;
  <D.12316>:
  iftmp.44 = 1;
  goto <D.12312>;
  <D.12311>:
  iftmp.44 = 0;
  <D.12312>:
  D.12317 = iftmp.44 != 0;
  D.12318 = (long int) D.12317;
  D.12319 = __builtin_expect (D.12318, 0);
  if (D.12319 != 0) goto <D.12320>; else goto <D.12321>;
  <D.12320>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 674, "_WAPI_FD_HANDLE(type)");
  <D.12321>:
  if (type == 9) goto <D.12323>; else goto <D.12326>;
  <D.12326>:
  if (type == 11) goto <D.12323>; else goto <D.12327>;
  <D.12327>:
  if (type == 12) goto <D.12323>; else goto <D.12328>;
  <D.12328>:
  if (type == 13) goto <D.12323>; else goto <D.12324>;
  <D.12323>:
  iftmp.45 = 1;
  goto <D.12325>;
  <D.12324>:
  iftmp.45 = 0;
  <D.12325>:
  D.12329 = iftmp.45 != 0;
  D.12330 = (long int) D.12329;
  D.12331 = __builtin_expect (D.12330, 0);
  if (D.12331 != 0) goto <D.12332>; else goto <D.12333>;
  <D.12332>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 675, "!_WAPI_SHARED_HANDLE(type)");
  <D.12333>:
  fd.46 = (unsigned int) fd;
  _wapi_fd_reserve.47 = _wapi_fd_reserve;
  if (fd.46 >= _wapi_fd_reserve.47) goto <D.12336>; else goto <D.12337>;
  <D.12336>:
  D.12338 = -1B;
  return D.12338;
  <D.12337>:
  D.12339 = fd / 256;
  D.12340 = _wapi_private_handles[D.12339];
  if (D.12340 == 0B) goto <D.12341>; else goto <D.12342>;
  <D.12341>:
  D.12339 = fd / 256;
  init_handles_slot (D.12339);
  <D.12342>:
  D.12339 = fd / 256;
  D.12340 = _wapi_private_handles[D.12339];
  D.12343 = fd % 256;
  D.12344 = (long unsigned int) D.12343;
  D.12345 = D.12344 * 200;
  handle = D.12340 + D.12345;
  D.12346 = handle->type;
  if (D.12346 != 0) goto <D.12347>; else goto <D.12348>;
  <D.12347>:
  <D.12348>:
  thr_ret = _wapi_shm_sem_lock (2);
  D.12349 = thr_ret != 0;
  D.12350 = (long int) D.12349;
  D.12351 = __builtin_expect (D.12350, 0);
  if (D.12351 != 0) goto <D.12352>; else goto <D.12353>;
  <D.12352>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 702, "thr_ret == 0");
  <D.12353>:
  _wapi_handle_init (handle, type, handle_specific);
  thr_ret = _wapi_shm_sem_unlock (2);
  D.12354 = (long unsigned int) fd;
  D.12338 = (void *) D.12354;
  return D.12338;
}


init_handles_slot (int idx)
{
  long int D.12356;
  long int D.12357;
  _Bool D.12360;
  long int D.12361;
  long int D.12362;
  struct _WapiHandleUnshared * D.12365;
  void * D.12368;
  _Bool D.12369;
  long int D.12370;
  long int D.12371;
  int thr_ret;

  {
    struct __pthread_unwind_buf_t __cancel_buf;
    void (*<Tc6>) (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.12356 = (long int) __not_first_call;
        D.12357 = __builtin_expect (D.12356, 0);
        if (D.12357 != 0) goto <D.12358>; else goto <D.12359>;
        <D.12358>:
        __cancel_routine (__cancel_arg);
        __pthread_unwind_next (&__cancel_buf);
        <D.12359>:
        __pthread_register_cancel (&__cancel_buf);
        thr_ret = pthread_mutex_lock (&scan_mutex);
        D.12360 = thr_ret != 0;
        D.12361 = (long int) D.12360;
        D.12362 = __builtin_expect (D.12361, 0);
        if (D.12362 != 0) goto <D.12363>; else goto <D.12364>;
        <D.12363>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 650, "thr_ret == 0");
        <D.12364>:
        D.12365 = _wapi_private_handles[idx];
        if (D.12365 == 0B) goto <D.12366>; else goto <D.12367>;
        <D.12366>:
        D.12368 = monoeg_malloc0 (51200);
        _wapi_private_handles[idx] = D.12368;
        D.12365 = _wapi_private_handles[idx];
        D.12369 = D.12365 == 0B;
        D.12370 = (long int) D.12369;
        D.12371 = __builtin_expect (D.12370, 0);
        if (D.12371 != 0) goto <D.12372>; else goto <D.12373>;
        <D.12372>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 655, "_wapi_private_handles [idx]");
        <D.12373>:
        <D.12367>:
        thr_ret = pthread_mutex_unlock (&scan_mutex);
        D.12360 = thr_ret != 0;
        D.12361 = (long int) D.12360;
        D.12362 = __builtin_expect (D.12361, 0);
        if (D.12362 != 0) goto <D.12374>; else goto <D.12375>;
        <D.12374>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 659, "thr_ret == 0");
        <D.12375>:
        __pthread_unregister_cancel (&__cancel_buf);
        if (0 != 0) goto <D.12376>; else goto <D.12377>;
        <D.12376>:
        __cancel_routine (__cancel_arg);
        <D.12377>:
      }
    finally
      {
        __cancel_buf = {CLOBBER};
      }
  }
}


_wapi_lookup_handle (void * handle, WapiHandleType type, void * * handle_specific)
{
  long int handle.48;
  gboolean D.12384;
  unsigned int D.12385;
  struct _WapiHandleUnshared * D.12386;
  int D.12389;
  long unsigned int D.12390;
  long unsigned int D.12391;
  long unsigned int D.12392;
  <unnamed type> D.12393;
  struct _WapiHandleSharedLayout * _wapi_shared_layout.49;
  unsigned int D.12405;
  <unnamed type> D.12406;
  union 
{
  struct _WapiHandle_process process;
  struct _WapiHandle_namedmutex namedmutex;
  struct _WapiHandle_namedsem namedsem;
  struct _WapiHandle_namedevent namedevent;
} * D.12409;
  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.12410;
  struct _WapiHandleUnshared * handle_data;
  guint32 handle_idx;

  handle.48 = (long int) handle;
  handle_idx = (guint32) handle.48;
  if (handle_idx > 4194303) goto <D.12382>; else goto <D.12383>;
  <D.12382>:
  D.12384 = 0;
  return D.12384;
  <D.12383>:
  D.12385 = handle_idx / 256;
  D.12386 = _wapi_private_handles[D.12385];
  if (D.12386 == 0B) goto <D.12387>; else goto <D.12388>;
  <D.12387>:
  D.12385 = handle_idx / 256;
  D.12389 = (int) D.12385;
  init_handles_slot (D.12389);
  <D.12388>:
  D.12385 = handle_idx / 256;
  D.12386 = _wapi_private_handles[D.12385];
  D.12390 = (long unsigned int) handle_idx;
  D.12391 = D.12390 & 255;
  D.12392 = D.12391 * 200;
  handle_data = D.12386 + D.12392;
  D.12393 = handle_data->type;
  if (D.12393 != type) goto <D.12394>; else goto <D.12395>;
  <D.12394>:
  D.12384 = 0;
  return D.12384;
  <D.12395>:
  if (handle_specific == 0B) goto <D.12396>; else goto <D.12397>;
  <D.12396>:
  D.12384 = 0;
  return D.12384;
  <D.12397>:
  if (type == 9) goto <D.12398>; else goto <D.12401>;
  <D.12401>:
  if (type == 11) goto <D.12398>; else goto <D.12402>;
  <D.12402>:
  if (type == 12) goto <D.12398>; else goto <D.12403>;
  <D.12403>:
  if (type == 13) goto <D.12398>; else goto <D.12399>;
  <D.12398>:
  {
    struct _WapiHandle_shared_ref * ref;
    struct _WapiHandleShared * shared_handle_data;

    ref = &handle_data->u.shared;
    _wapi_shared_layout.49 = _wapi_shared_layout;
    D.12405 = ref->offset;
    shared_handle_data = &_wapi_shared_layout.49->handles[D.12405];
    D.12406 = shared_handle_data->type;
    if (D.12406 != type) goto <D.12407>; else goto <D.12408>;
    <D.12407>:
    D.12384 = 0;
    return D.12384;
    <D.12408>:
    D.12409 = &shared_handle_data->u;
    *handle_specific = D.12409;
  }
  goto <D.12400>;
  <D.12399>:
  D.12410 = &handle_data->u;
  *handle_specific = D.12410;
  <D.12400>:
  D.12384 = 1;
  return D.12384;
}


_wapi_handle_foreach (WapiHandleType type, gboolean (*<T1b24>) (void *, void *) on_each, void * user_data)
{
  long int D.12412;
  long int D.12413;
  _Bool D.12416;
  long int D.12417;
  long int D.12418;
  struct _WapiHandleUnshared * D.12421;
  long unsigned int D.12424;
  long unsigned int D.12425;
  <unnamed type> D.12426;
  unsigned int D.12429;
  unsigned int D.12430;
  long unsigned int D.12431;
  int D.12432;
  unsigned int _wapi_private_handle_slot_count.50;
  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 (*<Tc6>) (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.12412 = (long int) __not_first_call;
        D.12413 = __builtin_expect (D.12412, 0);
        if (D.12413 != 0) goto <D.12414>; else goto <D.12415>;
        <D.12414>:
        __cancel_routine (__cancel_arg);
        __pthread_unwind_next (&__cancel_buf);
        <D.12415>:
        __pthread_register_cancel (&__cancel_buf);
        thr_ret = pthread_mutex_lock (&scan_mutex);
        D.12416 = thr_ret != 0;
        D.12417 = (long int) D.12416;
        D.12418 = __builtin_expect (D.12417, 0);
        if (D.12418 != 0) goto <D.12419>; else goto <D.12420>;
        <D.12419>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 769, "thr_ret == 0");
        <D.12420>:
        i = 0;
        goto <D.11493>;
        <D.11492>:
        D.12421 = _wapi_private_handles[i];
        if (D.12421 != 0B) goto <D.12422>; else goto <D.12423>;
        <D.12422>:
        k = 0;
        goto <D.11491>;
        <D.11490>:
        D.12421 = _wapi_private_handles[i];
        D.12424 = (long unsigned int) k;
        D.12425 = D.12424 * 200;
        handle_data = D.12421 + D.12425;
        D.12426 = handle_data->type;
        if (D.12426 == type) goto <D.12427>; else goto <D.12428>;
        <D.12427>:
        D.12429 = i * 256;
        D.12430 = D.12429 + k;
        D.12431 = (long unsigned int) D.12430;
        ret = (void *) D.12431;
        D.12432 = on_each (ret, user_data);
        if (D.12432 == 1) goto <D.11489>; else goto <D.12433>;
        <D.12433>:
        <D.12428>:
        k = k + 1;
        <D.11491>:
        if (k <= 255) goto <D.11490>; else goto <D.11489>;
        <D.11489>:
        <D.12423>:
        i = i + 1;
        <D.11493>:
        _wapi_private_handle_slot_count.50 = _wapi_private_handle_slot_count;
        if (i < _wapi_private_handle_slot_count.50) goto <D.11492>; else goto <D.11494>;
        <D.11494>:
        thr_ret = pthread_mutex_unlock (&scan_mutex);
        D.12416 = thr_ret != 0;
        D.12417 = (long int) D.12416;
        D.12418 = __builtin_expect (D.12417, 0);
        if (D.12418 != 0) goto <D.12435>; else goto <D.12436>;
        <D.12435>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 786, "thr_ret == 0");
        <D.12436>:
        __pthread_unregister_cancel (&__cancel_buf);
        if (0 != 0) goto <D.12437>; else goto <D.12438>;
        <D.12437>:
        __cancel_routine (__cancel_arg);
        <D.12438>:
      }
    finally
      {
        __cancel_buf = {CLOBBER};
      }
  }
}


_wapi_search_handle (WapiHandleType type, gboolean (*<T1b24>) (void *, void *) check, void * user_data, void * * handle_specific, gboolean search_shared)
{
  long int D.12442;
  long int D.12443;
  _Bool D.12446;
  long int D.12447;
  long int D.12448;
  struct _WapiHandleUnshared * D.12451;
  long unsigned int D.12454;
  long unsigned int D.12455;
  <unnamed type> D.12456;
  unsigned int D.12459;
  unsigned int D.12460;
  long unsigned int D.12461;
  int D.12462;
  struct _WapiHandleSharedLayout * _wapi_shared_layout.51;
  unsigned int _wapi_private_handle_slot_count.52;
  <unnamed type> D.12485;
  int D.12490;
  long int D.12497;
  guint32 * D.12498;
  int now.53;
  long int ret.54;
  unsigned int D.12501;
  unsigned int D.12502;
  struct _WapiHandleUnshared * D.12503;
  long unsigned int D.12504;
  long unsigned int D.12505;
  long unsigned int D.12506;
  _Bool D.12517;
  long int D.12518;
  long int D.12519;
  union 
{
  struct _WapiHandle_process process;
  struct _WapiHandle_namedmutex namedmutex;
  struct _WapiHandle_namedsem namedsem;
  struct _WapiHandle_namedevent namedevent;
} * D.12522;
  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.12523;
  void * D.12524;
  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 (*<Tc6>) (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.12442 = (long int) __not_first_call;
        D.12443 = __builtin_expect (D.12442, 0);
        if (D.12443 != 0) goto <D.12444>; else goto <D.12445>;
        <D.12444>:
        __cancel_routine (__cancel_arg);
        __pthread_unwind_next (&__cancel_buf);
        <D.12445>:
        __pthread_register_cancel (&__cancel_buf);
        thr_ret = pthread_mutex_lock (&scan_mutex);
        D.12446 = thr_ret != 0;
        D.12447 = (long int) D.12446;
        D.12448 = __builtin_expect (D.12447, 0);
        if (D.12448 != 0) goto <D.12449>; else goto <D.12450>;
        <D.12449>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 814, "thr_ret == 0");
        <D.12450>:
        i = 0;
        goto <D.11521>;
        <D.11520>:
        D.12451 = _wapi_private_handles[i];
        if (D.12451 != 0B) goto <D.12452>; else goto <D.12453>;
        <D.12452>:
        k = 0;
        goto <D.11519>;
        <D.11518>:
        D.12451 = _wapi_private_handles[i];
        D.12454 = (long unsigned int) k;
        D.12455 = D.12454 * 200;
        handle_data = D.12451 + D.12455;
        D.12456 = handle_data->type;
        if (D.12456 == type) goto <D.12457>; else goto <D.12458>;
        <D.12457>:
        D.12459 = i * 256;
        D.12460 = D.12459 + k;
        D.12461 = (long unsigned int) D.12460;
        ret = (void *) D.12461;
        D.12462 = check (ret, user_data);
        if (D.12462 == 1) goto <D.12463>; else goto <D.12464>;
        <D.12463>:
        _wapi_handle_ref (ret);
        found = 1;
        if (type == 9) goto <D.12465>; else goto <D.12467>;
        <D.12467>:
        if (type == 11) goto <D.12465>; else goto <D.12468>;
        <D.12468>:
        if (type == 12) goto <D.12465>; else goto <D.12469>;
        <D.12469>:
        if (type == 13) goto <D.12465>; else goto <D.12466>;
        <D.12465>:
        _wapi_shared_layout.51 = _wapi_shared_layout;
        shared = &_wapi_shared_layout.51->handles[i];
        <D.12466>:
        goto <D.11517>;
        <D.12464>:
        <D.12458>:
        k = k + 1;
        <D.11519>:
        if (k <= 255) goto <D.11518>; else goto <D.11517>;
        <D.11517>:
        <D.12453>:
        i = i + 1;
        <D.11521>:
        if (found == 0) goto <D.12471>; else goto <D.11522>;
        <D.12471>:
        _wapi_private_handle_slot_count.52 = _wapi_private_handle_slot_count;
        if (i < _wapi_private_handle_slot_count.52) goto <D.11520>; else goto <D.11522>;
        <D.11522>:
        thr_ret = pthread_mutex_unlock (&scan_mutex);
        D.12446 = thr_ret != 0;
        D.12447 = (long int) D.12446;
        D.12448 = __builtin_expect (D.12447, 0);
        if (D.12448 != 0) goto <D.12473>; else goto <D.12474>;
        <D.12473>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 839, "thr_ret == 0");
        <D.12474>:
        __pthread_unregister_cancel (&__cancel_buf);
        if (0 != 0) goto <D.12475>; else goto <D.12476>;
        <D.12475>:
        __cancel_routine (__cancel_arg);
        <D.12476>:
      }
    finally
      {
        __cancel_buf = {CLOBBER};
      }
  }
  if (found == 0) goto <D.12478>; else goto <D.12479>;
  <D.12478>:
  if (search_shared != 0) goto <D.12480>; else goto <D.12481>;
  <D.12480>:
  if (type == 9) goto <D.12477>; else goto <D.12482>;
  <D.12482>:
  if (type == 11) goto <D.12477>; else goto <D.12483>;
  <D.12483>:
  if (type == 12) goto <D.12477>; else goto <D.12484>;
  <D.12484>:
  if (type == 13) goto <D.12477>; else goto <D.11525>;
  <D.12477>:
  i = 0;
  goto <D.11527>;
  <D.11526>:
  _wapi_shared_layout.51 = _wapi_shared_layout;
  shared = &_wapi_shared_layout.51->handles[i];
  D.12485 = shared->type;
  if (D.12485 == type) goto <D.12486>; else goto <D.12487>;
  <D.12486>:
  ret = _wapi_handle_new_from_offset (type, i, 0);
  if (ret == -1B) goto <D.12488>; else goto <D.12489>;
  <D.12488>:
  // predicted unlikely by continue predictor.
  goto <D.11523>;
  <D.12489>:
  D.12490 = check (ret, user_data);
  if (D.12490 == 1) goto <D.12491>; else goto <D.12492>;
  <D.12491>:
  thr_ret = _wapi_handle_lock_shared_handles ();
  D.12446 = thr_ret != 0;
  D.12447 = (long int) D.12446;
  D.12448 = __builtin_expect (D.12447, 0);
  if (D.12448 != 0) goto <D.12493>; else goto <D.12494>;
  <D.12493>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 881, "thr_ret == 0");
  <D.12494>:
  D.12485 = shared->type;
  if (D.12485 == type) goto <D.12495>; else goto <D.12496>;
  <D.12495>:
  {
    guint32 now;

    D.12497 = time (0B);
    now = (guint32) D.12497;
    D.12498 = &shared->timestamp;
    now.53 = (int) now;
    InterlockedExchange (D.12498, now.53);
    found = 1;
    ret.54 = (long int) ret;
    D.12501 = (unsigned int) ret.54;
    D.12502 = D.12501 / 256;
    D.12503 = _wapi_private_handles[D.12502];
    ret.54 = (long int) ret;
    D.12501 = (unsigned int) ret.54;
    D.12504 = (long unsigned int) D.12501;
    D.12505 = D.12504 & 255;
    D.12506 = D.12505 * 200;
    handle_data = D.12503 + D.12506;
    _wapi_handle_unlock_shared_handles ();
    goto <D.11525>;
  }
  <D.12496>:
  _wapi_handle_unlock_shared_handles ();
  <D.12492>:
  _wapi_handle_unref (ret);
  <D.12487>:
  <D.11523>:
  i = i + 1;
  <D.11527>:
  if (i <= 255) goto <D.11526>; else goto <D.11525>;
  <D.11525>:
  <D.12481>:
  <D.12479>:
  if (found == 0) goto <D.12507>; else goto <D.12508>;
  <D.12507>:
  ret = 0B;
  goto done;
  <D.12508>:
  if (handle_specific != 0B) goto <D.12509>; else goto <D.12510>;
  <D.12509>:
  if (type == 9) goto <D.12511>; else goto <D.12514>;
  <D.12514>:
  if (type == 11) goto <D.12511>; else goto <D.12515>;
  <D.12515>:
  if (type == 12) goto <D.12511>; else goto <D.12516>;
  <D.12516>:
  if (type == 13) goto <D.12511>; else goto <D.12512>;
  <D.12511>:
  D.12485 = shared->type;
  D.12517 = D.12485 != type;
  D.12518 = (long int) D.12517;
  D.12519 = __builtin_expect (D.12518, 0);
  if (D.12519 != 0) goto <D.12520>; else goto <D.12521>;
  <D.12520>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 917, "shared->type == type");
  <D.12521>:
  D.12522 = &shared->u;
  *handle_specific = D.12522;
  goto <D.12513>;
  <D.12512>:
  D.12523 = &handle_data->u;
  *handle_specific = D.12523;
  <D.12513>:
  <D.12510>:
  done:
  D.12524 = ret;
  return D.12524;
}


_wapi_search_handle_namespace (WapiHandleType type, gchar * utf8_name)
{
  int iftmp.55;
  _Bool D.12539;
  long int D.12540;
  long int D.12541;
  _Bool D.12544;
  long int D.12545;
  long int D.12546;
  struct _WapiHandleSharedLayout * _wapi_shared_layout.56;
  <unnamed type> D.12550;
  unsigned int D.12551;
  gchar[261] * D.12554;
  int D.12555;
  gint32 D.12560;
  struct _WapiHandleShared * shared_handle_data;
  guint32 i;
  gint32 ret;
  int thr_ret;
  void done = <<< error >>>;

  ret = 0;
  if (type != 9) goto <D.12535>; else goto <D.12533>;
  <D.12535>:
  if (type != 11) goto <D.12536>; else goto <D.12533>;
  <D.12536>:
  if (type != 12) goto <D.12537>; else goto <D.12533>;
  <D.12537>:
  if (type != 13) goto <D.12538>; else goto <D.12533>;
  <D.12538>:
  iftmp.55 = 1;
  goto <D.12534>;
  <D.12533>:
  iftmp.55 = 0;
  <D.12534>:
  D.12539 = iftmp.55 != 0;
  D.12540 = (long int) D.12539;
  D.12541 = __builtin_expect (D.12540, 0);
  if (D.12541 != 0) goto <D.12542>; else goto <D.12543>;
  <D.12542>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 940, "_WAPI_SHARED_HANDLE(type)");
  <D.12543>:
  _wapi_handle_collect ();
  thr_ret = _wapi_handle_lock_shared_handles ();
  D.12544 = thr_ret != 0;
  D.12545 = (long int) D.12544;
  D.12546 = __builtin_expect (D.12545, 0);
  if (D.12546 != 0) goto <D.12547>; else goto <D.12548>;
  <D.12547>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 951, "thr_ret == 0");
  <D.12548>:
  i = 1;
  goto <D.11541>;
  <D.11540>:
  {
    struct WapiSharedNamespace * sharedns;

    _wapi_shared_layout.56 = _wapi_shared_layout;
    shared_handle_data = &_wapi_shared_layout.56->handles[i];
    D.12550 = shared_handle_data->type;
    D.12551 = D.12550 + 4294967285;
    if (D.12551 > 2) goto <D.12552>; else goto <D.12553>;
    <D.12552>:
    // predicted unlikely by continue predictor.
    goto <D.11538>;
    <D.12553>:
    sharedns = &shared_handle_data->u;
    D.12554 = &sharedns->name;
    D.12555 = strcmp (D.12554, utf8_name);
    if (D.12555 == 0) goto <D.12556>; else goto <D.12557>;
    <D.12556>:
    D.12550 = shared_handle_data->type;
    if (D.12550 != type) goto <D.12558>; else goto <D.12559>;
    <D.12558>:
    ret = -1;
    goto done;
    <D.12559>:
    ret = (gint32) i;
    goto done;
    <D.12557>:
  }
  <D.11538>:
  i = i + 1;
  <D.11541>:
  if (i <= 255) goto <D.11540>; else goto <D.11542>;
  <D.11542>:
  done:
  _wapi_handle_unlock_shared_handles ();
  D.12560 = ret;
  return D.12560;
}


__attribute__((__gnu_inline__, nothrow, leaf, pure))
strcmp (const char * __s1, const char * __s2)
{
  int iftmp.57;
  int iftmp.58;
  int D.12570;
  char * __p1;
  char * __p2;
  int __ret;

  __p1 = __s1;
  __p2 = __s2;
  __asm__ __volatile__("   slr   0,0
0: clst  %1,%2
   jo    0b
   ipm   %0
   srl   %0,28" : "=d" __ret, "=&a" __p1, "=&a" __p2 : "1" __p1, "2" __p2 : "0", "memory", "cc");
  if (__ret != 0) goto <D.12563>; else goto <D.12564>;
  <D.12563>:
  if (__ret == 1) goto <D.12566>; else goto <D.12567>;
  <D.12566>:
  iftmp.58 = -1;
  goto <D.12568>;
  <D.12567>:
  iftmp.58 = 1;
  <D.12568>:
  iftmp.57 = iftmp.58;
  goto <D.12569>;
  <D.12564>:
  iftmp.57 = 0;
  <D.12569>:
  __ret = iftmp.57;
  D.12570 = __ret;
  return D.12570;
}


_wapi_handle_ref (void * handle)
{
  long int handle.59;
  <unnamed type> D.12575;
  unsigned int D.12578;
  struct _WapiHandleUnshared * D.12579;
  long unsigned int D.12580;
  long unsigned int D.12581;
  long unsigned int D.12582;
  guint * D.12583;
  <unnamed type> D.12586;
  struct _WapiHandleSharedLayout * _wapi_shared_layout.60;
  unsigned int D.12591;
  long int D.12592;
  guint32 * D.12593;
  int now.61;
  guint32 idx;
  struct _WapiHandleUnshared * handle_data;
  static const char __func__[17] = "_wapi_handle_ref";

  handle.59 = (long int) handle;
  idx = (guint32) handle.59;
  if (idx > 4194303) goto <D.12573>; else goto <D.12574>;
  <D.12573>:
  return;
  <D.12574>:
  D.12575 = _wapi_handle_type (handle);
  if (D.12575 == 0) goto <D.12576>; else goto <D.12577>;
  <D.12576>:
  monoeg_g_log (0B, 16, "%s: Attempting to ref unused handle %p", &__func__, handle);
  return;
  <D.12577>:
  D.12578 = idx / 256;
  D.12579 = _wapi_private_handles[D.12578];
  D.12580 = (long unsigned int) idx;
  D.12581 = D.12580 & 255;
  D.12582 = D.12581 * 200;
  handle_data = D.12579 + D.12582;
  D.12583 = &handle_data->ref;
  InterlockedIncrement (D.12583);
  D.12586 = handle_data->type;
  if (D.12586 == 9) goto <D.12584>; else goto <D.12587>;
  <D.12587>:
  D.12586 = handle_data->type;
  if (D.12586 == 11) goto <D.12584>; else goto <D.12588>;
  <D.12588>:
  D.12586 = handle_data->type;
  if (D.12586 == 12) goto <D.12584>; else goto <D.12589>;
  <D.12589>:
  D.12586 = handle_data->type;
  if (D.12586 == 13) goto <D.12584>; else goto <D.12585>;
  <D.12584>:
  {
    struct _WapiHandleShared * shared_data;
    guint32 now;

    _wapi_shared_layout.60 = _wapi_shared_layout;
    D.12591 = handle_data->u.shared.offset;
    shared_data = &_wapi_shared_layout.60->handles[D.12591];
    D.12592 = time (0B);
    now = (guint32) D.12592;
    D.12593 = &shared_data->timestamp;
    now.61 = (int) now;
    InterlockedExchange (D.12593, now.61);
  }
  <D.12585>:
}


_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.62;
  gboolean D.12599;
  unsigned int D.12600;
  struct _WapiHandleUnshared * D.12601;
  long unsigned int D.12602;
  long unsigned int D.12603;
  long unsigned int D.12604;
  struct _WapiHandleUnshared * D.12605;
  <unnamed type> D.12606;
  unsigned int D.12607;
  _Bool D.12608;
  guint32 idx;
  WapiHandleType type;

  handle.62 = (long int) handle;
  idx = (guint32) handle.62;
  if (idx > 4194303) goto <D.12597>; else goto <D.12598>;
  <D.12597>:
  D.12599 = 0;
  return D.12599;
  <D.12598>:
  D.12600 = idx / 256;
  D.12601 = _wapi_private_handles[D.12600];
  D.12602 = (long unsigned int) idx;
  D.12603 = D.12602 & 255;
  D.12604 = D.12603 * 200;
  D.12605 = D.12601 + D.12604;
  type = D.12605->type;
  D.12606 = handle_caps[type];
  D.12607 = D.12606 & caps;
  D.12608 = D.12607 != 0;
  D.12599 = (gboolean) D.12608;
  return D.12599;
}


_wapi_handle_ops_close (void * handle, void * data)
{
  long int handle.63;
  unsigned int D.12613;
  struct _WapiHandleUnshared * D.12614;
  long unsigned int D.12615;
  long unsigned int D.12616;
  long unsigned int D.12617;
  struct _WapiHandleUnshared * D.12618;
  struct _WapiHandleOps * D.12619;
  void (*<Td75>) (void *, void *) D.12622;
  guint32 idx;
  WapiHandleType type;

  handle.63 = (long int) handle;
  idx = (guint32) handle.63;
  if (idx > 4194303) goto <D.12611>; else goto <D.12612>;
  <D.12611>:
  return;
  <D.12612>:
  D.12613 = idx / 256;
  D.12614 = _wapi_private_handles[D.12613];
  D.12615 = (long unsigned int) idx;
  D.12616 = D.12615 & 255;
  D.12617 = D.12616 * 200;
  D.12618 = D.12614 + D.12617;
  type = D.12618->type;
  D.12619 = handle_ops[type];
  if (D.12619 != 0B) goto <D.12620>; else goto <D.12621>;
  <D.12620>:
  D.12619 = handle_ops[type];
  D.12622 = D.12619->close;
  if (D.12622 != 0B) goto <D.12623>; else goto <D.12624>;
  <D.12623>:
  D.12619 = handle_ops[type];
  D.12622 = D.12619->close;
  D.12622 (handle, data);
  <D.12624>:
  <D.12621>:
}


_wapi_handle_ops_signal (void * handle)
{
  long int handle.64;
  unsigned int D.12629;
  struct _WapiHandleUnshared * D.12630;
  long unsigned int D.12631;
  long unsigned int D.12632;
  long unsigned int D.12633;
  struct _WapiHandleUnshared * D.12634;
  struct _WapiHandleOps * D.12635;
  void (*<Tce2>) (void *) D.12638;
  guint32 idx;
  WapiHandleType type;

  handle.64 = (long int) handle;
  idx = (guint32) handle.64;
  if (idx > 4194303) goto <D.12627>; else goto <D.12628>;
  <D.12627>:
  return;
  <D.12628>:
  D.12629 = idx / 256;
  D.12630 = _wapi_private_handles[D.12629];
  D.12631 = (long unsigned int) idx;
  D.12632 = D.12631 & 255;
  D.12633 = D.12632 * 200;
  D.12634 = D.12630 + D.12633;
  type = D.12634->type;
  D.12635 = handle_ops[type];
  if (D.12635 != 0B) goto <D.12636>; else goto <D.12637>;
  <D.12636>:
  D.12635 = handle_ops[type];
  D.12638 = D.12635->signal;
  if (D.12638 != 0B) goto <D.12639>; else goto <D.12640>;
  <D.12639>:
  D.12635 = handle_ops[type];
  D.12638 = D.12635->signal;
  D.12638 (handle);
  <D.12640>:
  <D.12637>:
}


_wapi_handle_ops_own (void * handle)
{
  long int handle.65;
  gboolean D.12645;
  unsigned int D.12646;
  struct _WapiHandleUnshared * D.12647;
  long unsigned int D.12648;
  long unsigned int D.12649;
  long unsigned int D.12650;
  struct _WapiHandleUnshared * D.12651;
  struct _WapiHandleOps * D.12653;
  gboolean (*<T1985>) (void *) D.12655;
  guint32 idx;
  WapiHandleType type;

  handle.65 = (long int) handle;
  idx = (guint32) handle.65;
  if (idx > 4194303) goto <D.12643>; else goto <D.12644>;
  <D.12643>:
  D.12645 = 0;
  return D.12645;
  <D.12644>:
  D.12646 = idx / 256;
  D.12647 = _wapi_private_handles[D.12646];
  D.12648 = (long unsigned int) idx;
  D.12649 = D.12648 & 255;
  D.12650 = D.12649 * 200;
  D.12651 = D.12647 + D.12650;
  type = D.12651->type;
  D.12653 = handle_ops[type];
  if (D.12653 != 0B) goto <D.12654>; else goto <D.12652>;
  <D.12654>:
  D.12653 = handle_ops[type];
  D.12655 = D.12653->own_handle;
  if (D.12655 != 0B) goto <D.12656>; else goto <D.12652>;
  <D.12656>:
  D.12653 = handle_ops[type];
  D.12655 = D.12653->own_handle;
  D.12645 = D.12655 (handle);
  return D.12645;
  <D.12652>:
  D.12645 = 0;
  return D.12645;
}


_wapi_handle_ops_isowned (void * handle)
{
  long int handle.66;
  gboolean D.12661;
  unsigned int D.12662;
  struct _WapiHandleUnshared * D.12663;
  long unsigned int D.12664;
  long unsigned int D.12665;
  long unsigned int D.12666;
  struct _WapiHandleUnshared * D.12667;
  struct _WapiHandleOps * D.12669;
  gboolean (*<T1985>) (void *) D.12671;
  guint32 idx;
  WapiHandleType type;

  handle.66 = (long int) handle;
  idx = (guint32) handle.66;
  if (idx > 4194303) goto <D.12659>; else goto <D.12660>;
  <D.12659>:
  D.12661 = 0;
  return D.12661;
  <D.12660>:
  D.12662 = idx / 256;
  D.12663 = _wapi_private_handles[D.12662];
  D.12664 = (long unsigned int) idx;
  D.12665 = D.12664 & 255;
  D.12666 = D.12665 * 200;
  D.12667 = D.12663 + D.12666;
  type = D.12667->type;
  D.12669 = handle_ops[type];
  if (D.12669 != 0B) goto <D.12670>; else goto <D.12668>;
  <D.12670>:
  D.12669 = handle_ops[type];
  D.12671 = D.12669->is_owned;
  if (D.12671 != 0B) goto <D.12672>; else goto <D.12668>;
  <D.12672>:
  D.12669 = handle_ops[type];
  D.12671 = D.12669->is_owned;
  D.12661 = D.12671 (handle);
  return D.12661;
  <D.12668>:
  D.12661 = 0;
  return D.12661;
}


_wapi_handle_ops_special_wait (void * handle, guint32 timeout, gboolean alertable)
{
  long int handle.67;
  guint32 D.12677;
  unsigned int D.12678;
  struct _WapiHandleUnshared * D.12679;
  long unsigned int D.12680;
  long unsigned int D.12681;
  long unsigned int D.12682;
  struct _WapiHandleUnshared * D.12683;
  struct _WapiHandleOps * D.12685;
  guint32 (*<T198a>) (void *, guint32, gboolean) D.12687;
  guint32 idx;
  WapiHandleType type;

  handle.67 = (long int) handle;
  idx = (guint32) handle.67;
  if (idx > 4194303) goto <D.12675>; else goto <D.12676>;
  <D.12675>:
  D.12677 = 4294967295;
  return D.12677;
  <D.12676>:
  D.12678 = idx / 256;
  D.12679 = _wapi_private_handles[D.12678];
  D.12680 = (long unsigned int) idx;
  D.12681 = D.12680 & 255;
  D.12682 = D.12681 * 200;
  D.12683 = D.12679 + D.12682;
  type = D.12683->type;
  D.12685 = handle_ops[type];
  if (D.12685 != 0B) goto <D.12686>; else goto <D.12684>;
  <D.12686>:
  D.12685 = handle_ops[type];
  D.12687 = D.12685->special_wait;
  if (D.12687 != 0B) goto <D.12688>; else goto <D.12684>;
  <D.12688>:
  D.12685 = handle_ops[type];
  D.12687 = D.12685->special_wait;
  D.12677 = D.12687 (handle, timeout, alertable);
  return D.12677;
  <D.12684>:
  D.12677 = 4294967295;
  return D.12677;
}


_wapi_handle_ops_prewait (void * handle)
{
  long int handle.68;
  unsigned int D.12693;
  struct _WapiHandleUnshared * D.12694;
  long unsigned int D.12695;
  long unsigned int D.12696;
  long unsigned int D.12697;
  struct _WapiHandleUnshared * D.12698;
  struct _WapiHandleOps * D.12699;
  void (*<Tce2>) (void *) D.12702;
  guint32 idx;
  WapiHandleType type;

  handle.68 = (long int) handle;
  idx = (guint32) handle.68;
  if (idx > 4194303) goto <D.12691>; else goto <D.12692>;
  <D.12691>:
  return;
  <D.12692>:
  D.12693 = idx / 256;
  D.12694 = _wapi_private_handles[D.12693];
  D.12695 = (long unsigned int) idx;
  D.12696 = D.12695 & 255;
  D.12697 = D.12696 * 200;
  D.12698 = D.12694 + D.12697;
  type = D.12698->type;
  D.12699 = handle_ops[type];
  if (D.12699 != 0B) goto <D.12700>; else goto <D.12701>;
  <D.12700>:
  D.12699 = handle_ops[type];
  D.12702 = D.12699->prewait;
  if (D.12702 != 0B) goto <D.12703>; else goto <D.12704>;
  <D.12703>:
  D.12699 = handle_ops[type];
  D.12702 = D.12699->prewait;
  D.12702 (handle);
  <D.12704>:
  <D.12701>:
}


CloseHandle (void * handle)
{
  struct _WapiHandleUnshared * D.12708;
  <unnamed type> D.12709;
  gboolean D.12712;

  if (handle == 0B) goto <D.12706>; else goto <D.12707>;
  <D.12706>:
  D.12708 = _wapi_private_handles[0];
  D.12709 = D.12708->type;
  if (D.12709 != 2) goto <D.12710>; else goto <D.12711>;
  <D.12710>:
  SetLastError (87);
  D.12712 = 0;
  return D.12712;
  <D.12711>:
  <D.12707>:
  if (handle == -1B) goto <D.12713>; else goto <D.12714>;
  <D.12713>:
  SetLastError (87);
  D.12712 = 0;
  return D.12712;
  <D.12714>:
  _wapi_handle_unref (handle);
  D.12712 = 1;
  return D.12712;
}


DuplicateHandle (void * srcprocess, void * src, void * targetprocess, void * * target, guint32 access, gboolean inherit, guint32 options)
{
  gboolean D.12719;
  void * D.12722;
  void * D.12726;

  if (srcprocess != 4294967295B) goto <D.12716>; else goto <D.12718>;
  <D.12718>:
  if (targetprocess != 4294967295B) goto <D.12716>; else goto <D.12717>;
  <D.12716>:
  SetLastError (6);
  D.12719 = 0;
  return D.12719;
  <D.12717>:
  if (src == 4294967295B) goto <D.12720>; else goto <D.12721>;
  <D.12720>:
  D.12722 = _wapi_process_duplicate ();
  *target = D.12722;
  goto <D.12723>;
  <D.12721>:
  if (src == 4294967294B) goto <D.12724>; else goto <D.12725>;
  <D.12724>:
  D.12726 = _wapi_thread_duplicate ();
  *target = D.12726;
  goto <D.12727>;
  <D.12725>:
  _wapi_handle_ref (src);
  *target = src;
  <D.12727>:
  <D.12723>:
  D.12719 = 1;
  return D.12719;
}


_wapi_handle_count_signalled_handles (guint32 numhandles, void * * handles, gboolean waitall, guint32 * retcount, guint32 * lowest)
{
  _Bool D.12729;
  long int D.12730;
  long int D.12731;
  long unsigned int D.12734;
  long unsigned int D.12735;
  void * * D.12736;
  long int handle.69;
  unsigned int D.12738;
  struct _WapiHandleUnshared * D.12739;
  long unsigned int D.12740;
  long unsigned int D.12741;
  long unsigned int D.12742;
  struct _WapiHandleUnshared * D.12743;
  unsigned int i.70;
  unsigned int D.12753;
  long int handle.71;
  unsigned int D.12755;
  struct _WapiHandleUnshared * D.12756;
  long unsigned int D.12757;
  long unsigned int D.12758;
  long unsigned int D.12759;
  struct _WapiHandleUnshared * D.12760;
  int D.12766;
  int D.12768;
  struct _WapiHandleSharedLayout * _wapi_shared_layout.72;
  unsigned int D.12773;
  unsigned int D.12774;
  struct _WapiHandleUnshared * D.12775;
  long unsigned int D.12776;
  long unsigned int D.12777;
  long unsigned int D.12778;
  struct _WapiHandleUnshared * D.12779;
  unsigned int D.12780;
  int D.12781;
  int D.12786;
  unsigned int D.12787;
  gboolean D.12796;
  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.12729 = thr_ret != 0;
  D.12730 = (long int) D.12729;
  D.12731 = __builtin_expect (D.12730, 0);
  if (D.12731 != 0) goto <D.12732>; else goto <D.12733>;
  <D.12732>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 1375, "thr_ret == 0");
  <D.12733>:
  i = 0;
  goto <D.11660>;
  <D.11659>:
  {
    void * handle;
    guint32 idx;

    D.12734 = (long unsigned int) i;
    D.12735 = D.12734 * 8;
    D.12736 = handles + D.12735;
    handle = *D.12736;
    handle.69 = (long int) handle;
    idx = (guint32) handle.69;
    D.12738 = idx / 256;
    D.12739 = _wapi_private_handles[D.12738];
    D.12740 = (long unsigned int) idx;
    D.12741 = D.12740 & 255;
    D.12742 = D.12741 * 200;
    D.12743 = D.12739 + D.12742;
    type = D.12743->type;
    thr_ret = _wapi_handle_trylock_handle (handle);
    if (thr_ret != 0) goto <D.12744>; else goto <D.12745>;
    <D.12744>:
    thr_ret = _wapi_handle_unlock_shared_handles ();
    D.12729 = thr_ret != 0;
    D.12730 = (long int) D.12729;
    D.12731 = __builtin_expect (D.12730, 0);
    if (D.12731 != 0) goto <D.12746>; else goto <D.12747>;
    <D.12746>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 1394, "thr_ret == 0");
    <D.12747>:
    goto <D.11656>;
    <D.11655>:
    D.12734 = (long unsigned int) i;
    D.12735 = D.12734 * 8;
    D.12736 = handles + D.12735;
    handle = *D.12736;
    handle.69 = (long int) handle;
    idx = (guint32) handle.69;
    thr_ret = _wapi_handle_unlock_handle (handle);
    D.12729 = thr_ret != 0;
    D.12730 = (long int) D.12729;
    D.12731 = __builtin_expect (D.12730, 0);
    if (D.12731 != 0) goto <D.12748>; else goto <D.12749>;
    <D.12748>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 1401, "thr_ret == 0");
    <D.12749>:
    <D.11656>:
    i.70 = i;
    i = i.70 + 4294967295;
    if (i.70 != 0) goto <D.11655>; else goto <D.11657>;
    <D.11657>:
    iter = iter + 1;
    if (iter == 100) goto <D.12751>; else goto <D.12752>;
    <D.12751>:
    monoeg_g_log (0B, 16, "%s: iteration overflow!", &__func__);
    iter = 1;
    <D.12752>:
    D.12753 = iter * 10;
    _wapi_handle_spin (D.12753);
    goto again;
    <D.12745>:
  }
  i = i + 1;
  <D.11660>:
  if (i < numhandles) goto <D.11659>; else goto <D.11661>;
  <D.11661>:
  count = 0;
  *lowest = numhandles;
  i = 0;
  goto <D.11665>;
  <D.11664>:
  {
    void * handle;
    guint32 idx;

    D.12734 = (long unsigned int) i;
    D.12735 = D.12734 * 8;
    D.12736 = handles + D.12735;
    handle = *D.12736;
    handle.71 = (long int) handle;
    idx = (guint32) handle.71;
    D.12755 = idx / 256;
    D.12756 = _wapi_private_handles[D.12755];
    D.12757 = (long unsigned int) idx;
    D.12758 = D.12757 & 255;
    D.12759 = D.12758 * 200;
    D.12760 = D.12756 + D.12759;
    type = D.12760->type;
    D.12766 = _wapi_handle_test_capabilities (handle, 4);
    if (D.12766 == 1) goto <D.12767>; else goto <D.12761>;
    <D.12767>:
    D.12768 = _wapi_handle_ops_isowned (handle);
    if (D.12768 == 1) goto <D.12762>; else goto <D.12761>;
    <D.12761>:
    if (type == 9) goto <D.12763>; else goto <D.12769>;
    <D.12769>:
    if (type == 11) goto <D.12763>; else goto <D.12770>;
    <D.12770>:
    if (type == 12) goto <D.12763>; else goto <D.12771>;
    <D.12771>:
    if (type == 13) goto <D.12763>; else goto <D.12764>;
    <D.12763>:
    _wapi_shared_layout.72 = _wapi_shared_layout;
    handle.71 = (long int) handle;
    D.12773 = (unsigned int) handle.71;
    D.12774 = D.12773 / 256;
    D.12775 = _wapi_private_handles[D.12774];
    handle.71 = (long int) handle;
    D.12773 = (unsigned int) handle.71;
    D.12776 = (long unsigned int) D.12773;
    D.12777 = D.12776 & 255;
    D.12778 = D.12777 * 200;
    D.12779 = D.12775 + D.12778;
    D.12780 = D.12779->u.shared.offset;
    D.12781 = _wapi_shared_layout.72->handles[D.12780].signalled;
    if (D.12781 == 1) goto <D.12762>; else goto <D.12764>;
    <D.12764>:
    if (type != 9) goto <D.12782>; else goto <D.12765>;
    <D.12782>:
    if (type != 11) goto <D.12783>; else goto <D.12765>;
    <D.12783>:
    if (type != 12) goto <D.12784>; else goto <D.12765>;
    <D.12784>:
    if (type != 13) goto <D.12785>; else goto <D.12765>;
    <D.12785>:
    D.12755 = idx / 256;
    D.12756 = _wapi_private_handles[D.12755];
    D.12757 = (long unsigned int) idx;
    D.12758 = D.12757 & 255;
    D.12759 = D.12758 * 200;
    D.12760 = D.12756 + D.12759;
    D.12786 = D.12760->signalled;
    if (D.12786 == 1) goto <D.12762>; else goto <D.12765>;
    <D.12762>:
    count = count + 1;
    D.12787 = *lowest;
    if (D.12787 > i) goto <D.12788>; else goto <D.12789>;
    <D.12788>:
    *lowest = i;
    <D.12789>:
    <D.12765>:
  }
  i = i + 1;
  <D.11665>:
  if (i < numhandles) goto <D.11664>; else goto <D.11666>;
  <D.11666>:
  if (waitall == 1) goto <D.12794>; else goto <D.12790>;
  <D.12794>:
  if (count == numhandles) goto <D.12791>; else goto <D.12790>;
  <D.12790>:
  if (waitall == 0) goto <D.12795>; else goto <D.12792>;
  <D.12795>:
  if (count != 0) goto <D.12791>; else goto <D.12792>;
  <D.12791>:
  ret = 1;
  goto <D.12793>;
  <D.12792>:
  ret = 0;
  <D.12793>:
  *retcount = count;
  D.12796 = ret;
  return D.12796;
}


_wapi_handle_trylock_handle (void * handle)
{
  long int handle.73;
  int D.12801;
  <unnamed type> D.12804;
  <unnamed type> D.12806;
  <unnamed type> D.12808;
  <unnamed type> D.12810;
  unsigned int D.12811;
  struct _WapiHandleUnshared * D.12812;
  long unsigned int D.12813;
  long unsigned int D.12814;
  long unsigned int D.12815;
  struct _WapiHandleUnshared * D.12816;
  union mono_mutex_t * D.12817;
  guint32 idx;
  int ret;

  handle.73 = (long int) handle;
  idx = (guint32) handle.73;
  if (idx > 4194303) goto <D.12799>; else goto <D.12800>;
  <D.12799>:
  D.12801 = 0;
  return D.12801;
  <D.12800>:
  _wapi_handle_ref (handle);
  D.12804 = _wapi_handle_type (handle);
  if (D.12804 == 9) goto <D.12802>; else goto <D.12805>;
  <D.12805>:
  D.12806 = _wapi_handle_type (handle);
  if (D.12806 == 11) goto <D.12802>; else goto <D.12807>;
  <D.12807>:
  D.12808 = _wapi_handle_type (handle);
  if (D.12808 == 12) goto <D.12802>; else goto <D.12809>;
  <D.12809>:
  D.12810 = _wapi_handle_type (handle);
  if (D.12810 == 13) goto <D.12802>; else goto <D.12803>;
  <D.12802>:
  D.12801 = 0;
  return D.12801;
  <D.12803>:
  D.12811 = idx / 256;
  D.12812 = _wapi_private_handles[D.12811];
  D.12813 = (long unsigned int) idx;
  D.12814 = D.12813 & 255;
  D.12815 = D.12814 * 200;
  D.12816 = D.12812 + D.12815;
  D.12817 = &D.12816->signal_mutex;
  ret = pthread_mutex_trylock (D.12817);
  if (ret != 0) goto <D.12818>; else goto <D.12819>;
  <D.12818>:
  _wapi_handle_unref (handle);
  <D.12819>:
  D.12801 = ret;
  return D.12801;
}


_wapi_handle_unlock_handle (void * handle)
{
  long int handle.74;
  int D.12824;
  <unnamed type> D.12827;
  <unnamed type> D.12829;
  <unnamed type> D.12831;
  <unnamed type> D.12833;
  unsigned int D.12834;
  struct _WapiHandleUnshared * D.12835;
  long unsigned int D.12836;
  long unsigned int D.12837;
  long unsigned int D.12838;
  struct _WapiHandleUnshared * D.12839;
  union mono_mutex_t * D.12840;
  guint32 idx;
  int ret;

  handle.74 = (long int) handle;
  idx = (guint32) handle.74;
  if (idx > 4194303) goto <D.12822>; else goto <D.12823>;
  <D.12822>:
  D.12824 = 0;
  return D.12824;
  <D.12823>:
  D.12827 = _wapi_handle_type (handle);
  if (D.12827 == 9) goto <D.12825>; else goto <D.12828>;
  <D.12828>:
  D.12829 = _wapi_handle_type (handle);
  if (D.12829 == 11) goto <D.12825>; else goto <D.12830>;
  <D.12830>:
  D.12831 = _wapi_handle_type (handle);
  if (D.12831 == 12) goto <D.12825>; else goto <D.12832>;
  <D.12832>:
  D.12833 = _wapi_handle_type (handle);
  if (D.12833 == 13) goto <D.12825>; else goto <D.12826>;
  <D.12825>:
  _wapi_handle_unref (handle);
  D.12824 = 0;
  return D.12824;
  <D.12826>:
  D.12834 = idx / 256;
  D.12835 = _wapi_private_handles[D.12834];
  D.12836 = (long unsigned int) idx;
  D.12837 = D.12836 & 255;
  D.12838 = D.12837 * 200;
  D.12839 = D.12835 + D.12838;
  D.12840 = &D.12839->signal_mutex;
  ret = pthread_mutex_unlock (D.12840);
  _wapi_handle_unref (handle);
  D.12824 = ret;
  return D.12824;
}


_wapi_handle_spin (guint32 ms)
{
  _Bool D.12842;
  long int D.12843;
  long int D.12844;
  unsigned int D.12847;
  long int D.12848;
  struct timespec sleepytime;

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


_wapi_handle_unlock_handles (guint32 numhandles, void * * handles)
{
  _Bool D.12849;
  long int D.12850;
  long int D.12851;
  long unsigned int D.12854;
  long unsigned int D.12855;
  void * * D.12856;
  guint32 i;
  int thr_ret;

  thr_ret = _wapi_handle_unlock_shared_handles ();
  D.12849 = thr_ret != 0;
  D.12850 = (long int) D.12849;
  D.12851 = __builtin_expect (D.12850, 0);
  if (D.12851 != 0) goto <D.12852>; else goto <D.12853>;
  <D.12852>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 1474, "thr_ret == 0");
  <D.12853>:
  i = 0;
  goto <D.11675>;
  <D.11674>:
  {
    void * handle;

    D.12854 = (long unsigned int) i;
    D.12855 = D.12854 * 8;
    D.12856 = handles + D.12855;
    handle = *D.12856;
    thr_ret = _wapi_handle_unlock_handle (handle);
    D.12849 = thr_ret != 0;
    D.12850 = (long int) D.12849;
    D.12851 = __builtin_expect (D.12850, 0);
    if (D.12851 != 0) goto <D.12857>; else goto <D.12858>;
    <D.12857>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 1482, "thr_ret == 0");
    <D.12858>:
  }
  i = i + 1;
  <D.11675>:
  if (i < numhandles) goto <D.11674>; else goto <D.11676>;
  <D.11676>:
}


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

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


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

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


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

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


_wapi_handle_timedwait_signal_handle (void * handle, struct timespec * timeout, gboolean alertable, gboolean poll)
{
  <unnamed type> D.12869;
  <unnamed type> D.12871;
  <unnamed type> D.12873;
  <unnamed type> D.12875;
  struct _WapiHandleSharedLayout * _wapi_shared_layout.77;
  long int handle.78;
  unsigned int D.12878;
  unsigned int D.12879;
  struct _WapiHandleUnshared * D.12880;
  long unsigned int D.12881;
  long unsigned int D.12882;
  long unsigned int D.12883;
  struct _WapiHandleUnshared * D.12884;
  unsigned int D.12885;
  int D.12886;
  int D.12889;
  long int D.12894;
  long int D.12895;
  long int D.12898;
  long int D.12899;
  int D.12900;
  int D.12905;
  unsigned int D.12908;
  struct _WapiHandleUnshared * D.12909;
  long unsigned int D.12910;
  long unsigned int D.12911;
  long unsigned int D.12912;
  struct _WapiHandleUnshared * D.12913;

  D.12869 = _wapi_handle_type (handle);
  if (D.12869 == 9) goto <D.12867>; else goto <D.12870>;
  <D.12870>:
  D.12871 = _wapi_handle_type (handle);
  if (D.12871 == 11) goto <D.12867>; else goto <D.12872>;
  <D.12872>:
  D.12873 = _wapi_handle_type (handle);
  if (D.12873 == 12) goto <D.12867>; else goto <D.12874>;
  <D.12874>:
  D.12875 = _wapi_handle_type (handle);
  if (D.12875 == 13) goto <D.12867>; else goto <D.12868>;
  <D.12867>:
  _wapi_shared_layout.77 = _wapi_shared_layout;
  handle.78 = (long int) handle;
  D.12878 = (unsigned int) handle.78;
  D.12879 = D.12878 / 256;
  D.12880 = _wapi_private_handles[D.12879];
  handle.78 = (long int) handle;
  D.12878 = (unsigned int) handle.78;
  D.12881 = (long unsigned int) D.12878;
  D.12882 = D.12881 & 255;
  D.12883 = D.12882 * 200;
  D.12884 = D.12880 + D.12883;
  D.12885 = D.12884->u.shared.offset;
  D.12886 = _wapi_shared_layout.77->handles[D.12885].signalled;
  if (D.12886 == 1) goto <D.12887>; else goto <D.12888>;
  <D.12887>:
  D.12889 = 0;
  return D.12889;
  <D.12888>:
  if (timeout != 0B) goto <D.12890>; else goto <D.12891>;
  <D.12890>:
  {
    struct timespec fake_timeout;

    try
      {
        _wapi_calc_timeout (&fake_timeout, 100);
        D.12894 = fake_timeout.tv_sec;
        D.12895 = timeout->tv_sec;
        if (D.12894 > D.12895) goto <D.12892>; else goto <D.12896>;
        <D.12896>:
        D.12894 = fake_timeout.tv_sec;
        D.12895 = timeout->tv_sec;
        if (D.12894 == D.12895) goto <D.12897>; else goto <D.12893>;
        <D.12897>:
        D.12898 = fake_timeout.tv_nsec;
        D.12899 = timeout->tv_nsec;
        if (D.12898 > D.12899) goto <D.12892>; else goto <D.12893>;
        <D.12892>:
        _wapi_handle_spin (100);
        _wapi_shared_layout.77 = _wapi_shared_layout;
        handle.78 = (long int) handle;
        D.12878 = (unsigned int) handle.78;
        D.12879 = D.12878 / 256;
        D.12880 = _wapi_private_handles[D.12879];
        handle.78 = (long int) handle;
        D.12878 = (unsigned int) handle.78;
        D.12881 = (long unsigned int) D.12878;
        D.12882 = D.12881 & 255;
        D.12883 = D.12882 * 200;
        D.12884 = D.12880 + D.12883;
        D.12885 = D.12884->u.shared.offset;
        D.12900 = _wapi_shared_layout.77->handles[D.12885].signalled;
        if (D.12900 == 1) goto <D.12901>; else goto <D.12902>;
        <D.12901>:
        D.12889 = 0;
        return D.12889;
        <D.12902>:
        D.12889 = 110;
        return D.12889;
        <D.12893>:
      }
    finally
      {
        fake_timeout = {CLOBBER};
      }
  }
  <D.12891>:
  _wapi_handle_spin (100);
  D.12889 = 0;
  return D.12889;
  <D.12868>:
  {
    guint32 idx;
    int res;
    union pthread_cond_t * cond;
    union mono_mutex_t * mutex;

    handle.78 = (long int) handle;
    idx = (guint32) handle.78;
    if (alertable != 0) goto <D.12903>; else goto <D.12904>;
    <D.12903>:
    D.12905 = wapi_thread_set_wait_handle (handle);
    if (D.12905 == 0) goto <D.12906>; else goto <D.12907>;
    <D.12906>:
    D.12889 = 0;
    return D.12889;
    <D.12907>:
    <D.12904>:
    D.12908 = idx / 256;
    D.12909 = _wapi_private_handles[D.12908];
    D.12910 = (long unsigned int) idx;
    D.12911 = D.12910 & 255;
    D.12912 = D.12911 * 200;
    D.12913 = D.12909 + D.12912;
    cond = &D.12913->signal_cond;
    D.12908 = idx / 256;
    D.12909 = _wapi_private_handles[D.12908];
    D.12910 = (long unsigned int) idx;
    D.12911 = D.12910 & 255;
    D.12912 = D.12911 * 200;
    D.12913 = D.12909 + D.12912;
    mutex = &D.12913->signal_mutex;
    if (poll != 0) goto <D.12914>; else goto <D.12915>;
    <D.12914>:
    res = timedwait_signal_poll_cond (cond, mutex, timeout, alertable);
    goto <D.12916>;
    <D.12915>:
    if (timeout != 0B) goto <D.12917>; else goto <D.12918>;
    <D.12917>:
    res = pthread_cond_timedwait (cond, mutex, timeout);
    goto <D.12919>;
    <D.12918>:
    res = pthread_cond_wait (cond, mutex);
    <D.12919>:
    <D.12916>:
    if (alertable != 0) goto <D.12920>; else goto <D.12921>;
    <D.12920>:
    wapi_thread_clear_wait_handle (handle);
    <D.12921>:
    D.12889 = res;
    return D.12889;
  }
}


timedwait_signal_poll_cond (union pthread_cond_t * cond, union mono_mutex_t * mutex, struct timespec * timeout, gboolean alertable)
{
  long int D.12935;
  long int D.12936;
  long int D.12939;
  long int D.12940;
  int D.12943;
  struct timespec fake_timeout;
  int ret;

  try
    {
      if (alertable == 0) goto <D.12925>; else goto <D.12926>;
      <D.12925>:
      if (timeout != 0B) goto <D.12927>; else goto <D.12928>;
      <D.12927>:
      ret = pthread_cond_timedwait (cond, mutex, timeout);
      goto <D.12929>;
      <D.12928>:
      ret = pthread_cond_wait (cond, mutex);
      <D.12929>:
      goto <D.12930>;
      <D.12926>:
      _wapi_calc_timeout (&fake_timeout, 100);
      if (timeout != 0B) goto <D.12934>; else goto <D.12931>;
      <D.12934>:
      D.12935 = fake_timeout.tv_sec;
      D.12936 = timeout->tv_sec;
      if (D.12935 > D.12936) goto <D.12932>; else goto <D.12937>;
      <D.12937>:
      D.12935 = fake_timeout.tv_sec;
      D.12936 = timeout->tv_sec;
      if (D.12935 == D.12936) goto <D.12938>; else goto <D.12931>;
      <D.12938>:
      D.12939 = fake_timeout.tv_nsec;
      D.12940 = timeout->tv_nsec;
      if (D.12939 > D.12940) goto <D.12932>; else goto <D.12931>;
      <D.12932>:
      ret = pthread_cond_timedwait (cond, mutex, timeout);
      goto <D.12933>;
      <D.12931>:
      ret = pthread_cond_timedwait (cond, mutex, &fake_timeout);
      if (ret == 110) goto <D.12941>; else goto <D.12942>;
      <D.12941>:
      ret = 0;
      <D.12942>:
      <D.12933>:
      <D.12930>:
      D.12943 = ret;
      return D.12943;
    }
  finally
    {
      fake_timeout = {CLOBBER};
    }
}


_wapi_free_share_info (struct _WapiFileShare * share_info)
{
  int D.12946;
  _Bool D.12951;
  long int D.12952;
  long int D.12953;
  struct GHashTable * file_share_hash.79;
  _Bool D.12959;
  long int D.12960;
  long int D.12961;

  D.12946 = _wapi_shm_enabled ();
  if (D.12946 == 0) goto <D.12947>; else goto <D.12948>;
  <D.12947>:
  {
    int ret;

    ret = pthread_mutex_lock (&file_share_hash_mutex.mutex);
    if (ret != 0) goto <D.12949>; else goto <D.12950>;
    <D.12949>:
    monoeg_g_log (0B, 16, "Bad call to mono_mutex_lock result %d", ret);
    <D.12950>:
    D.12951 = ret != 0;
    D.12952 = (long int) D.12951;
    D.12953 = __builtin_expect (D.12952, 0);
    if (D.12953 != 0) goto <D.12954>; else goto <D.12955>;
    <D.12954>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 1602, "ret == 0");
    <D.12955>:
  }
  file_share_hash.79 = file_share_hash;
  monoeg_g_hash_table_remove (file_share_hash.79, share_info);
  {
    int ret;

    ret = pthread_mutex_unlock (&file_share_hash_mutex.mutex);
    if (ret != 0) goto <D.12957>; else goto <D.12958>;
    <D.12957>:
    monoeg_g_log (0B, 16, "Bad call to mono_mutex_unlock result %d", ret);
    <D.12958>:
    D.12959 = ret != 0;
    D.12960 = (long int) D.12959;
    D.12961 = __builtin_expect (D.12960, 0);
    if (D.12961 != 0) goto <D.12962>; else goto <D.12963>;
    <D.12962>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 1604, "ret == 0");
    <D.12963>:
  }
  goto <D.12964>;
  <D.12948>:
  memset (share_info, 0, 40);
  <D.12964>:
}


_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.12965;
  _Bool D.12966;
  long int D.12967;
  long int D.12968;
  int D.12973;
  struct GHashTable * file_share_hash.80;
  struct GHashTable * D.12979;
  _Bool D.12982;
  long int D.12983;
  long int D.12984;
  unsigned int D.12989;
  unsigned int D.12990;
  guint32 * D.12991;
  int D.12993;
  _Bool D.12996;
  long int D.12997;
  long int D.12998;
  struct _WapiFileShareLayout * _wapi_fileshare_layout.81;
  unsigned int D.13005;
  long unsigned int D.13010;
  long unsigned int D.13013;
  unsigned int D.13016;
  unsigned int i.82;
  int D.13027;
  struct _WapiFileShare * D.13028;
  guint32 * D.13031;
  int now.83;
  gboolean D.13033;
  struct _WapiFileShare * file_share;
  guint32 now;
  int thr_ret;
  int i;
  int first_unused;
  gboolean exists;

  D.12965 = time (0B);
  now = (guint32) D.12965;
  first_unused = -1;
  exists = 0;
  thr_ret = _wapi_handle_lock_shared_handles ();
  D.12966 = thr_ret != 0;
  D.12967 = (long int) D.12966;
  D.12968 = __builtin_expect (D.12967, 0);
  if (D.12968 != 0) goto <D.12969>; else goto <D.12970>;
  <D.12969>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 1643, "thr_ret == 0");
  <D.12970>:
  thr_ret = _wapi_shm_sem_lock (2);
  D.12966 = thr_ret != 0;
  D.12967 = (long int) D.12966;
  D.12968 = __builtin_expect (D.12967, 0);
  if (D.12968 != 0) goto <D.12971>; else goto <D.12972>;
  <D.12971>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 1647, "thr_ret == 0");
  <D.12972>:
  D.12973 = _wapi_shm_enabled ();
  if (D.12973 == 0) goto <D.12974>; else goto <D.12975>;
  <D.12974>:
  {
    struct _WapiFileShare tmp;

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

          ret = pthread_mutex_lock (&file_share_hash_mutex.mutex);
          if (ret != 0) goto <D.12980>; else goto <D.12981>;
          <D.12980>:
          monoeg_g_log (0B, 16, "Bad call to mono_mutex_lock result %d", ret);
          <D.12981>:
          D.12982 = ret != 0;
          D.12983 = (long int) D.12982;
          D.12984 = __builtin_expect (D.12983, 0);
          if (D.12984 != 0) goto <D.12985>; else goto <D.12986>;
          <D.12985>:
          monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 1665, "ret == 0");
          <D.12986>:
        }
        file_share_hash.80 = file_share_hash;
        file_share = monoeg_g_hash_table_lookup (file_share_hash.80, &tmp);
        if (file_share != 0B) goto <D.12987>; else goto <D.12988>;
        <D.12987>:
        D.12989 = file_share->sharemode;
        *old_sharemode = D.12989;
        D.12990 = file_share->access;
        *old_access = D.12990;
        *share_info = file_share;
        D.12991 = &file_share->handle_refs;
        InterlockedIncrement (D.12991);
        exists = 1;
        goto <D.12992>;
        <D.12988>:
        file_share = monoeg_malloc0 (40);
        file_share->device = device;
        file_share->inode = inode;
        D.12993 = _wapi_getpid ();
        file_share->opened_by_pid = D.12993;
        file_share->sharemode = new_sharemode;
        file_share->access = new_access;
        file_share->handle_refs = 1;
        *share_info = file_share;
        file_share_hash.80 = file_share_hash;
        monoeg_g_hash_table_insert_replace (file_share_hash.80, file_share, file_share, 0);
        <D.12992>:
        {
          int ret;

          ret = pthread_mutex_unlock (&file_share_hash_mutex.mutex);
          if (ret != 0) goto <D.12994>; else goto <D.12995>;
          <D.12994>:
          monoeg_g_log (0B, 16, "Bad call to mono_mutex_unlock result %d", ret);
          <D.12995>:
          D.12996 = ret != 0;
          D.12997 = (long int) D.12996;
          D.12998 = __builtin_expect (D.12997, 0);
          if (D.12998 != 0) goto <D.12999>; else goto <D.13000>;
          <D.12999>:
          monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 1689, "ret == 0");
          <D.13000>:
        }
      }
    finally
      {
        tmp = {CLOBBER};
      }
  }
  goto <D.13001>;
  <D.12975>:
  *share_info = 0B;
  i = 0;
  goto <D.11743>;
  <D.11742>:
  _wapi_fileshare_layout.81 = _wapi_fileshare_layout;
  file_share = &_wapi_fileshare_layout.81->share_info[i];
  if (first_unused == -1) goto <D.13003>; else goto <D.13004>;
  <D.13003>:
  D.13005 = file_share->handle_refs;
  if (D.13005 == 0) goto <D.13006>; else goto <D.13007>;
  <D.13006>:
  first_unused = i;
  // predicted unlikely by continue predictor.
  goto <D.11740>;
  <D.13007>:
  <D.13004>:
  D.13005 = file_share->handle_refs;
  if (D.13005 == 0) goto <D.13008>; else goto <D.13009>;
  <D.13008>:
  // predicted unlikely by continue predictor.
  goto <D.11740>;
  <D.13009>:
  D.13010 = file_share->device;
  if (D.13010 == device) goto <D.13011>; else goto <D.13012>;
  <D.13011>:
  D.13013 = file_share->inode;
  if (D.13013 == inode) goto <D.13014>; else goto <D.13015>;
  <D.13014>:
  D.12989 = file_share->sharemode;
  *old_sharemode = D.12989;
  D.12990 = file_share->access;
  *old_access = D.12990;
  *share_info = file_share;
  D.12991 = &file_share->handle_refs;
  InterlockedIncrement (D.12991);
  exists = 1;
  goto <D.11741>;
  <D.13015>:
  <D.13012>:
  <D.11740>:
  i = i + 1;
  <D.11743>:
  _wapi_fileshare_layout.81 = _wapi_fileshare_layout;
  D.13016 = _wapi_fileshare_layout.81->hwm;
  i.82 = (unsigned int) i;
  if (D.13016 >= i.82) goto <D.11742>; else goto <D.11741>;
  <D.11741>:
  if (exists == 0) goto <D.13018>; else goto <D.13019>;
  <D.13018>:
  if (i == 102400) goto <D.13022>; else goto <D.13020>;
  <D.13022>:
  if (first_unused == -1) goto <D.13023>; else goto <D.13020>;
  <D.13023>:
  goto <D.13021>;
  <D.13020>:
  if (first_unused == -1) goto <D.13024>; else goto <D.13025>;
  <D.13024>:
  _wapi_fileshare_layout.81 = _wapi_fileshare_layout;
  i = i + 1;
  file_share = &_wapi_fileshare_layout.81->share_info[i];
  _wapi_fileshare_layout.81 = _wapi_fileshare_layout;
  i.82 = (unsigned int) i;
  _wapi_fileshare_layout.81->hwm = i.82;
  goto <D.13026>;
  <D.13025>:
  _wapi_fileshare_layout.81 = _wapi_fileshare_layout;
  file_share = &_wapi_fileshare_layout.81->share_info[first_unused];
  <D.13026>:
  file_share->device = device;
  file_share->inode = inode;
  D.13027 = _wapi_getpid ();
  file_share->opened_by_pid = D.13027;
  file_share->sharemode = new_sharemode;
  file_share->access = new_access;
  file_share->handle_refs = 1;
  *share_info = file_share;
  <D.13021>:
  <D.13019>:
  D.13028 = *share_info;
  if (D.13028 != 0B) goto <D.13029>; else goto <D.13030>;
  <D.13029>:
  D.13028 = *share_info;
  D.13031 = &D.13028->timestamp;
  now.83 = (int) now;
  InterlockedExchange (D.13031, now.83);
  <D.13030>:
  <D.13001>:
  thr_ret = _wapi_shm_sem_unlock (2);
  _wapi_handle_unlock_shared_handles ();
  D.13033 = exists;
  return D.13033;
}


wapi_share_info_equal (const void * ka, const void * kb)
{
  gint D.13035;
  int iftmp.84;
  long unsigned int D.13039;
  long unsigned int D.13040;
  long unsigned int D.13042;
  long unsigned int D.13043;
  const struct _WapiFileShare * s1;
  const struct _WapiFileShare * s2;

  s1 = ka;
  s2 = kb;
  D.13039 = s1->device;
  D.13040 = s2->device;
  if (D.13039 == D.13040) goto <D.13041>; else goto <D.13037>;
  <D.13041>:
  D.13042 = s1->inode;
  D.13043 = s2->inode;
  if (D.13042 == D.13043) goto <D.13044>; else goto <D.13037>;
  <D.13044>:
  iftmp.84 = 1;
  goto <D.13038>;
  <D.13037>:
  iftmp.84 = 0;
  <D.13038>:
  D.13035 = iftmp.84;
  return D.13035;
}


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

  s = data;
  D.13047 = s->inode;
  D.13046 = (guint) D.13047;
  return D.13046;
}


_wapi_handle_check_share (struct _WapiFileShare * share_info, int fd)
{
  _Bool D.13049;
  long int D.13050;
  long int D.13051;
  int D.13056;
  int D.13059;
  struct _WapiHandleUnshared * D.13060;
  int D.13063;
  long unsigned int D.13064;
  long unsigned int D.13065;
  <unnamed type> D.13068;
  struct _WapiFileShare * D.13071;
  unsigned int i.85;
  unsigned int _wapi_fd_reserve.86;
  struct _WapiHandleSharedLayout * _wapi_shared_layout.87;
  <unnamed type> D.13076;
  char[256] * D.13083;
  int D.13084;
  int D.13086;
  int D.13089;
  long unsigned int D.13090;
  long unsigned int D.13091;
  long unsigned int D.13094;
  long unsigned int D.13095;
  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.13049 = thr_ret != 0;
  D.13050 = (long int) D.13049;
  D.13051 = __builtin_expect (D.13050, 0);
  if (D.13051 != 0) goto <D.13052>; else goto <D.13053>;
  <D.13052>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 1803, "thr_ret == 0");
  <D.13053>:
  thr_ret = _wapi_shm_sem_lock (2);
  D.13049 = thr_ret != 0;
  D.13050 = (long int) D.13049;
  D.13051 = __builtin_expect (D.13050, 0);
  if (D.13051 != 0) goto <D.13054>; else goto <D.13055>;
  <D.13054>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 1807, "thr_ret == 0");
  <D.13055>:
  D.13056 = access ("/proc", 0);
  if (D.13056 == -1) goto <D.13057>; else goto <D.13058>;
  <D.13057>:
  _wapi_handle_check_share_by_pid (share_info);
  goto done;
  <D.13058>:
  i = 0;
  goto <D.11761>;
  <D.11760>:
  D.13059 = i / 256;
  D.13060 = _wapi_private_handles[D.13059];
  if (D.13060 != 0B) goto <D.13061>; else goto <D.13062>;
  <D.13061>:
  {
    struct _WapiHandleUnshared * handle;

    D.13059 = i / 256;
    D.13060 = _wapi_private_handles[D.13059];
    D.13063 = i % 256;
    D.13064 = (long unsigned int) D.13063;
    D.13065 = D.13064 * 200;
    handle = D.13060 + D.13065;
    if (i != fd) goto <D.13066>; else goto <D.13067>;
    <D.13066>:
    D.13068 = handle->type;
    if (D.13068 == 1) goto <D.13069>; else goto <D.13070>;
    <D.13069>:
    {
      struct _WapiHandle_file * file_handle;

      file_handle = &handle->u.file;
      D.13071 = file_handle->share_info;
      if (D.13071 == share_info) goto done; else goto <D.13072>;
      <D.13072>:
    }
    <D.13070>:
    <D.13067>:
  }
  <D.13062>:
  i = i + 1;
  <D.11761>:
  i.85 = (unsigned int) i;
  _wapi_fd_reserve.86 = _wapi_fd_reserve;
  if (i.85 < _wapi_fd_reserve.86) goto <D.11760>; else goto <D.11762>;
  <D.11762>:
  i = 0;
  goto <D.11775>;
  <D.11774>:
  {
    struct _WapiHandleShared * shared;
    struct _WapiHandle_process * process_handle;

    _wapi_shared_layout.87 = _wapi_shared_layout;
    shared = &_wapi_shared_layout.87->handles[i];
    D.13076 = shared->type;
    if (D.13076 == 9) goto <D.13077>; else goto <D.13078>;
    <D.13077>:
    {
      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.13079>; else goto <D.13080>;
          <D.13079>:
          // predicted unlikely by continue predictor.
          goto <D.11768>;
          <D.13080>:
          proc_fds = 1;
          goto <D.11771>;
          <D.11772>:
          {
            char path[256];
            struct stat link_stat;

            try
              {
                D.13083 = &fd_entry->d_name;
                D.13084 = strcmp (D.13083, ".");
                if (D.13084 == 0) goto <D.13081>; else goto <D.13085>;
                <D.13085>:
                D.13083 = &fd_entry->d_name;
                D.13086 = strcmp (D.13083, "..");
                if (D.13086 == 0) goto <D.13081>; else goto <D.13087>;
                <D.13087>:
                if (pid == self) goto <D.13088>; else goto <D.13082>;
                <D.13088>:
                D.13083 = &fd_entry->d_name;
                D.13089 = atoi (D.13083);
                if (D.13089 == fd) goto <D.13081>; else goto <D.13082>;
                <D.13081>:
                // predicted unlikely by continue predictor.
                goto <D.11771>;
                <D.13082>:
                D.13083 = &fd_entry->d_name;
                monoeg_g_snprintf (&path, 256, "/proc/%d/fd/%s", pid, D.13083);
                stat (&path, &link_stat);
                D.13090 = link_stat.st_dev;
                D.13091 = share_info->device;
                if (D.13090 == D.13091) goto <D.13092>; else goto <D.13093>;
                <D.13092>:
                D.13094 = link_stat.st_ino;
                D.13095 = share_info->inode;
                if (D.13094 == D.13095) goto <D.13096>; else goto <D.13097>;
                <D.13096>:
                found = 1;
                <D.13097>:
                <D.13093>:
              }
            finally
              {
                path = {CLOBBER};
                link_stat = {CLOBBER};
              }
          }
          <D.11771>:
          fd_entry = readdir (fd_dir);
          if (fd_entry != 0B) goto <D.11772>; else goto <D.11773>;
          <D.11773>:
          closedir (fd_dir);
        }
      finally
        {
          subdir = {CLOBBER};
        }
    }
    <D.13078>:
  }
  <D.11768>:
  i = i + 1;
  <D.11775>:
  if (i <= 255) goto <D.11774>; else goto <D.11776>;
  <D.11776>:
  if (proc_fds == 0) goto <D.13098>; else goto <D.13099>;
  <D.13098>:
  _wapi_handle_check_share_by_pid (share_info);
  goto <D.13100>;
  <D.13099>:
  if (found == 0) goto <D.13101>; else goto <D.13102>;
  <D.13101>:
  _wapi_free_share_info (share_info);
  <D.13102>:
  <D.13100>:
  done:
  thr_ret = _wapi_shm_sem_unlock (2);
  _wapi_handle_unlock_shared_handles ();
}


__attribute__((__gnu_inline__, __pure__, __leaf__, __nothrow__))
atoi (const char * __nptr)
{
  int D.13107;
  long int D.13108;

  D.13108 = strtol (__nptr, 0B, 10);
  D.13107 = (int) D.13108;
  return D.13107;
}


__attribute__((__gnu_inline__, __leaf__, __nothrow__))
stat (const char * __path, struct stat * __statbuf)
{
  int D.13110;

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


_wapi_handle_check_share_by_pid (struct _WapiFileShare * share_info)
{
  int D.13114;
  int D.13115;
  int * D.13118;
  int D.13119;

  D.13114 = share_info->opened_by_pid;
  D.13115 = kill (D.13114, 0);
  if (D.13115 == -1) goto <D.13116>; else goto <D.13117>;
  <D.13116>:
  D.13118 = __errno_location ();
  D.13119 = *D.13118;
  if (D.13119 == 3) goto <D.13112>; else goto <D.13120>;
  <D.13120>:
  D.13118 = __errno_location ();
  D.13119 = *D.13118;
  if (D.13119 == 1) goto <D.13112>; else goto <D.13113>;
  <D.13112>:
  _wapi_free_share_info (share_info);
  <D.13113>:
  <D.13117>:
}


_wapi_handle_dump ()
{
  long int D.13121;
  long int D.13122;
  _Bool D.13125;
  long int D.13126;
  long int D.13127;
  struct _WapiHandleUnshared * D.13130;
  long unsigned int D.13133;
  long unsigned int D.13134;
  <unnamed type> D.13135;
  unsigned int D.13138;
  unsigned int D.13139;
  const char * D.13140;
  const char * iftmp.88;
  int D.13142;
  unsigned int D.13146;
  void (*<Tce2>) (void *) D.13147;
  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.13148;
  unsigned int _wapi_private_handle_slot_count.89;
  struct _WapiHandleUnshared * handle_data;
  guint32 i;
  guint32 k;
  int thr_ret;

  {
    struct __pthread_unwind_buf_t __cancel_buf;
    void (*<Tc6>) (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.13121 = (long int) __not_first_call;
        D.13122 = __builtin_expect (D.13121, 0);
        if (D.13122 != 0) goto <D.13123>; else goto <D.13124>;
        <D.13123>:
        __cancel_routine (__cancel_arg);
        __pthread_unwind_next (&__cancel_buf);
        <D.13124>:
        __pthread_register_cancel (&__cancel_buf);
        thr_ret = pthread_mutex_lock (&scan_mutex);
        D.13125 = thr_ret != 0;
        D.13126 = (long int) D.13125;
        D.13127 = __builtin_expect (D.13126, 0);
        if (D.13127 != 0) goto <D.13128>; else goto <D.13129>;
        <D.13128>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 1943, "thr_ret == 0");
        <D.13129>:
        i = 0;
        goto <D.11795>;
        <D.11794>:
        D.13130 = _wapi_private_handles[i];
        if (D.13130 != 0B) goto <D.13131>; else goto <D.13132>;
        <D.13131>:
        k = 0;
        goto <D.11792>;
        <D.11791>:
        D.13130 = _wapi_private_handles[i];
        D.13133 = (long unsigned int) k;
        D.13134 = D.13133 * 200;
        handle_data = D.13130 + D.13134;
        D.13135 = handle_data->type;
        if (D.13135 == 0) goto <D.13136>; else goto <D.13137>;
        <D.13136>:
        // predicted unlikely by continue predictor.
        goto <D.11790>;
        <D.13137>:
        D.13138 = i * 256;
        D.13139 = D.13138 + k;
        D.13135 = handle_data->type;
        D.13140 = _wapi_handle_typename[D.13135];
        D.13142 = handle_data->signalled;
        if (D.13142 != 0) goto <D.13143>; else goto <D.13144>;
        <D.13143>:
        iftmp.88 = "Sg";
        goto <D.13145>;
        <D.13144>:
        iftmp.88 = "Un";
        <D.13145>:
        D.13146 = handle_data->ref;
        monoeg_g_print ("%3x [%7s] %s %d ", D.13139, D.13140, iftmp.88, D.13146);
        D.13135 = handle_data->type;
        D.13147 = handle_details[D.13135];
        D.13148 = &handle_data->u;
        D.13147 (D.13148);
        monoeg_g_print ("\n");
        <D.11790>:
        k = k + 1;
        <D.11792>:
        if (k <= 255) goto <D.11791>; else goto <D.11793>;
        <D.11793>:
        <D.13132>:
        i = i + 1;
        <D.11795>:
        _wapi_private_handle_slot_count.89 = _wapi_private_handle_slot_count;
        if (i < _wapi_private_handle_slot_count.89) goto <D.11794>; else goto <D.11796>;
        <D.11796>:
        thr_ret = pthread_mutex_unlock (&scan_mutex);
        D.13125 = thr_ret != 0;
        D.13126 = (long int) D.13125;
        D.13127 = __builtin_expect (D.13126, 0);
        if (D.13127 != 0) goto <D.13150>; else goto <D.13151>;
        <D.13150>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 1966, "thr_ret == 0");
        <D.13151>:
        __pthread_unregister_cancel (&__cancel_buf);
        if (0 != 0) goto <D.13152>; else goto <D.13153>;
        <D.13152>:
        __cancel_routine (__cancel_arg);
        <D.13153>:
      }
    finally
      {
        __cancel_buf = {CLOBBER};
      }
  }
}


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

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


_wapi_handle_update_refs ()
{
  long int D.13157;
  _Bool D.13158;
  long int D.13159;
  long int D.13160;
  long int D.13165;
  long int D.13166;
  struct _WapiHandleUnshared * D.13169;
  long unsigned int D.13172;
  long unsigned int D.13173;
  <unnamed type> D.13177;
  struct _WapiHandleSharedLayout * _wapi_shared_layout.90;
  unsigned int D.13182;
  guint32 * D.13183;
  int now.91;
  struct _WapiFileShare * D.13187;
  _Bool D.13188;
  long int D.13189;
  long int D.13190;
  guint32 * D.13193;
  unsigned int _wapi_private_handle_slot_count.92;
  guint32 i;
  guint32 k;
  int thr_ret;
  guint32 now;

  D.13157 = time (0B);
  now = (guint32) D.13157;
  thr_ret = _wapi_handle_lock_shared_handles ();
  D.13158 = thr_ret != 0;
  D.13159 = (long int) D.13158;
  D.13160 = __builtin_expect (D.13159, 0);
  if (D.13160 != 0) goto <D.13161>; else goto <D.13162>;
  <D.13161>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 1984, "thr_ret == 0");
  <D.13162>:
  thr_ret = _wapi_shm_sem_lock (2);
  D.13158 = thr_ret != 0;
  D.13159 = (long int) D.13158;
  D.13160 = __builtin_expect (D.13159, 0);
  if (D.13160 != 0) goto <D.13163>; else goto <D.13164>;
  <D.13163>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 1988, "thr_ret == 0");
  <D.13164>:
  {
    struct __pthread_unwind_buf_t __cancel_buf;
    void (*<Tc6>) (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.13165 = (long int) __not_first_call;
        D.13166 = __builtin_expect (D.13165, 0);
        if (D.13166 != 0) goto <D.13167>; else goto <D.13168>;
        <D.13167>:
        __cancel_routine (__cancel_arg);
        __pthread_unwind_next (&__cancel_buf);
        <D.13168>:
        __pthread_register_cancel (&__cancel_buf);
        thr_ret = pthread_mutex_lock (&scan_mutex);
        i = 0;
        goto <D.11821>;
        <D.11820>:
        D.13169 = _wapi_private_handles[i];
        if (D.13169 != 0B) goto <D.13170>; else goto <D.13171>;
        <D.13170>:
        k = 0;
        goto <D.11818>;
        <D.11817>:
        {
          struct _WapiHandleUnshared * handle;

          D.13169 = _wapi_private_handles[i];
          D.13172 = (long unsigned int) k;
          D.13173 = D.13172 * 200;
          handle = D.13169 + D.13173;
          D.13177 = handle->type;
          if (D.13177 == 9) goto <D.13174>; else goto <D.13178>;
          <D.13178>:
          D.13177 = handle->type;
          if (D.13177 == 11) goto <D.13174>; else goto <D.13179>;
          <D.13179>:
          D.13177 = handle->type;
          if (D.13177 == 12) goto <D.13174>; else goto <D.13180>;
          <D.13180>:
          D.13177 = handle->type;
          if (D.13177 == 13) goto <D.13174>; else goto <D.13175>;
          <D.13174>:
          {
            struct _WapiHandleShared * shared_data;

            _wapi_shared_layout.90 = _wapi_shared_layout;
            D.13182 = handle->u.shared.offset;
            shared_data = &_wapi_shared_layout.90->handles[D.13182];
            D.13183 = &shared_data->timestamp;
            now.91 = (int) now;
            InterlockedExchange (D.13183, now.91);
          }
          goto <D.13176>;
          <D.13175>:
          D.13177 = handle->type;
          if (D.13177 == 1) goto <D.13185>; else goto <D.13186>;
          <D.13185>:
          {
            struct _WapiHandle_file * file_handle;

            file_handle = &handle->u.file;
            D.13187 = file_handle->share_info;
            D.13188 = D.13187 == 0B;
            D.13189 = (long int) D.13188;
            D.13190 = __builtin_expect (D.13189, 0);
            if (D.13190 != 0) goto <D.13191>; else goto <D.13192>;
            <D.13191>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 2014, "file_handle->share_info != NULL");
            <D.13192>:
            D.13187 = file_handle->share_info;
            D.13193 = &D.13187->timestamp;
            now.91 = (int) now;
            InterlockedExchange (D.13193, now.91);
          }
          <D.13186>:
          <D.13176>:
        }
        k = k + 1;
        <D.11818>:
        if (k <= 255) goto <D.11817>; else goto <D.11819>;
        <D.11819>:
        <D.13171>:
        i = i + 1;
        <D.11821>:
        _wapi_private_handle_slot_count.92 = _wapi_private_handle_slot_count;
        if (i < _wapi_private_handle_slot_count.92) goto <D.11820>; else goto <D.11822>;
        <D.11822>:
        thr_ret = pthread_mutex_unlock (&scan_mutex);
        D.13158 = thr_ret != 0;
        D.13159 = (long int) D.13158;
        D.13160 = __builtin_expect (D.13159, 0);
        if (D.13160 != 0) goto <D.13195>; else goto <D.13196>;
        <D.13195>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "handles.c", 2025, "thr_ret == 0");
        <D.13196>:
        __pthread_unregister_cancel (&__cancel_buf);
        if (0 != 0) goto <D.13197>; else goto <D.13198>;
        <D.13197>:
        __cancel_routine (__cancel_arg);
        <D.13198>:
      }
    finally
      {
        __cancel_buf = {CLOBBER};
      }
  }
  thr_ret = _wapi_shm_sem_unlock (2);
  _wapi_handle_unlock_shared_handles ();
}


