event_own (void * handle)
{
  gboolean D.11840;
  struct _WapiHandle_event * event_handle.0;
  int D.11842;
  unsigned int D.11845;
  _Bool D.11846;
  long int D.11847;
  long int D.11848;
  unsigned int D.11851;
  struct _WapiHandle_event * event_handle;
  gboolean ok;
  static const char __func__[10] = "event_own";

  try
    {
      ok = _wapi_lookup_handle (handle, 6, &event_handle);
      if (ok == 0) goto <D.11838>; else goto <D.11839>;
      <D.11838>:
      monoeg_g_log (0B, 16, "%s: error looking up event handle %p", &__func__, handle);
      D.11840 = 0;
      return D.11840;
      <D.11839>:
      event_handle.0 = event_handle;
      D.11842 = event_handle.0->manual;
      if (D.11842 == 0) goto <D.11843>; else goto <D.11844>;
      <D.11843>:
      event_handle.0 = event_handle;
      D.11845 = event_handle.0->set_count;
      D.11846 = D.11845 == 0;
      D.11847 = (long int) D.11846;
      D.11848 = __builtin_expect (D.11847, 0);
      if (D.11848 != 0) goto <D.11849>; else goto <D.11850>;
      <D.11849>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "events.c", 121, "event_handle->set_count > 0");
      <D.11850>:
      event_handle.0 = event_handle;
      D.11845 = event_handle.0->set_count;
      D.11851 = D.11845 + 4294967295;
      event_handle.0->set_count = D.11851;
      D.11845 = event_handle.0->set_count;
      if (D.11845 == 0) goto <D.11852>; else goto <D.11853>;
      <D.11852>:
      _wapi_handle_set_signal_state (handle, 0, 0);
      <D.11853>:
      <D.11844>:
      D.11840 = 1;
      return D.11840;
    }
  finally
    {
      event_handle = {CLOBBER};
    }
}


_wapi_handle_set_signal_state (void * handle, gboolean state, gboolean broadcast)
{
  int iftmp.1;
  <unnamed type> D.11862;
  <unnamed type> D.11864;
  <unnamed type> D.11866;
  <unnamed type> D.11868;
  _Bool D.11869;
  long int D.11870;
  long int D.11871;
  unsigned int D.11874;
  struct _WapiHandleUnshared * D.11875;
  unsigned int D.11876;
  unsigned int D.11877;
  long int D.11880;
  union mono_mutex_t * _wapi_global_signal_mutex.2;
  _Bool D.11886;
  long int D.11887;
  long int D.11888;
  union pthread_cond_t * D.11893;
  union pthread_cond_t * _wapi_global_signal_cond.3;
  guint32 idx;
  struct _WapiHandleUnshared * handle_data;
  int thr_ret;

  idx = (guint32) handle;
  if (idx > 4194303) goto <D.11856>; else goto <D.11857>;
  <D.11856>:
  return;
  <D.11857>:
  D.11862 = _wapi_handle_type (handle);
  if (D.11862 == 9) goto <D.11859>; else goto <D.11863>;
  <D.11863>:
  D.11864 = _wapi_handle_type (handle);
  if (D.11864 == 11) goto <D.11859>; else goto <D.11865>;
  <D.11865>:
  D.11866 = _wapi_handle_type (handle);
  if (D.11866 == 12) goto <D.11859>; else goto <D.11867>;
  <D.11867>:
  D.11868 = _wapi_handle_type (handle);
  if (D.11868 == 13) goto <D.11859>; else goto <D.11860>;
  <D.11859>:
  iftmp.1 = 1;
  goto <D.11861>;
  <D.11860>:
  iftmp.1 = 0;
  <D.11861>:
  D.11869 = iftmp.1 != 0;
  D.11870 = (long int) D.11869;
  D.11871 = __builtin_expect (D.11870, 0);
  if (D.11871 != 0) goto <D.11872>; else goto <D.11873>;
  <D.11872>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "../../mono/io-layer/handles-private.h", 132, "!_WAPI_SHARED_HANDLE(_wapi_handle_type (handle))");
  <D.11873>:
  D.11874 = idx / 256;
  D.11875 = _wapi_private_handles[D.11874];
  D.11876 = idx & 255;
  D.11877 = D.11876 * 144;
  handle_data = D.11875 + D.11877;
  if (state == 1) goto <D.11878>; else goto <D.11879>;
  <D.11878>:
  {
    struct __pthread_unwind_buf_t __cancel_buf;
    void (*<Tc1>) (void *) __cancel_routine;
    void * __cancel_arg;
    int __not_first_call;

    try
      {
        __cancel_routine = mono_mutex_unlock_in_cleanup;
        __cancel_arg = _wapi_global_signal_mutex;
        __not_first_call = __sigsetjmp (&__cancel_buf.__cancel_jmp_buf, 0);
        D.11880 = __builtin_expect (__not_first_call, 0);
        if (D.11880 != 0) goto <D.11881>; else goto <D.11882>;
        <D.11881>:
        __cancel_routine (__cancel_arg);
        __pthread_unwind_next (&__cancel_buf);
        <D.11882>:
        __pthread_register_cancel (&__cancel_buf);
        _wapi_global_signal_mutex.2 = _wapi_global_signal_mutex;
        thr_ret = pthread_mutex_lock (_wapi_global_signal_mutex.2);
        if (thr_ret != 0) goto <D.11884>; else goto <D.11885>;
        <D.11884>:
        monoeg_g_log (0B, 16, "Bad call to mono_mutex_lock result %d for global signal mutex", thr_ret);
        <D.11885>:
        D.11886 = thr_ret != 0;
        D.11887 = (long int) D.11886;
        D.11888 = __builtin_expect (D.11887, 0);
        if (D.11888 != 0) goto <D.11889>; else goto <D.11890>;
        <D.11889>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "../../mono/io-layer/handles-private.h", 151, "thr_ret == 0");
        <D.11890>:
        handle_data->signalled = state;
        if (broadcast == 1) goto <D.11891>; else goto <D.11892>;
        <D.11891>:
        D.11893 = &handle_data->signal_cond;
        thr_ret = pthread_cond_broadcast (D.11893);
        if (thr_ret != 0) goto <D.11894>; else goto <D.11895>;
        <D.11894>:
        monoeg_g_log (0B, 16, "Bad call to pthread_cond_broadcast result %d for handle %p", thr_ret, handle);
        <D.11895>:
        D.11886 = thr_ret != 0;
        D.11887 = (long int) D.11886;
        D.11888 = __builtin_expect (D.11887, 0);
        if (D.11888 != 0) goto <D.11896>; else goto <D.11897>;
        <D.11896>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "../../mono/io-layer/handles-private.h", 162, "thr_ret == 0");
        <D.11897>:
        goto <D.11898>;
        <D.11892>:
        D.11893 = &handle_data->signal_cond;
        thr_ret = pthread_cond_signal (D.11893);
        if (thr_ret != 0) goto <D.11899>; else goto <D.11900>;
        <D.11899>:
        monoeg_g_log (0B, 16, "Bad call to pthread_cond_signal result %d for handle %p", thr_ret, handle);
        <D.11900>:
        D.11886 = thr_ret != 0;
        D.11887 = (long int) D.11886;
        D.11888 = __builtin_expect (D.11887, 0);
        if (D.11888 != 0) goto <D.11901>; else goto <D.11902>;
        <D.11901>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "../../mono/io-layer/handles-private.h", 167, "thr_ret == 0");
        <D.11902>:
        <D.11898>:
        _wapi_global_signal_cond.3 = _wapi_global_signal_cond;
        thr_ret = pthread_cond_broadcast (_wapi_global_signal_cond.3);
        if (thr_ret != 0) goto <D.11904>; else goto <D.11905>;
        <D.11904>:
        monoeg_g_log (0B, 16, "Bad call to pthread_cond_broadcast result %d for handle %p", thr_ret, handle);
        <D.11905>:
        D.11886 = thr_ret != 0;
        D.11887 = (long int) D.11886;
        D.11888 = __builtin_expect (D.11887, 0);
        if (D.11888 != 0) goto <D.11906>; else goto <D.11907>;
        <D.11906>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "../../mono/io-layer/handles-private.h", 176, "thr_ret == 0");
        <D.11907>:
        _wapi_global_signal_mutex.2 = _wapi_global_signal_mutex;
        thr_ret = pthread_mutex_unlock (_wapi_global_signal_mutex.2);
        if (thr_ret != 0) goto <D.11908>; else goto <D.11909>;
        <D.11908>:
        monoeg_g_log (0B, 16, "Bad call to mono_mutex_unlock result %d for global signal mutex", thr_ret);
        <D.11909>:
        D.11886 = thr_ret != 0;
        D.11887 = (long int) D.11886;
        D.11888 = __builtin_expect (D.11887, 0);
        if (D.11888 != 0) goto <D.11910>; else goto <D.11911>;
        <D.11910>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "../../mono/io-layer/handles-private.h", 181, "thr_ret == 0");
        <D.11911>:
        __pthread_unregister_cancel (&__cancel_buf);
        if (0 != 0) goto <D.11912>; else goto <D.11913>;
        <D.11912>:
        __cancel_routine (__cancel_arg);
        <D.11913>:
      }
    finally
      {
        __cancel_buf = {CLOBBER};
      }
  }
  goto <D.11914>;
  <D.11879>:
  handle_data->signalled = state;
  <D.11914>:
}


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

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


_wapi_handle_type (void * handle)
{
  unsigned int D.11930;
  struct _WapiHandleUnshared * D.11931;
  WapiHandleType D.11932;
  unsigned int D.11933;
  unsigned int D.11934;
  struct _WapiHandleUnshared * D.11935;
  guint32 idx;

  idx = (guint32) handle;
  if (idx > 4194303) goto <D.11927>; else goto <D.11929>;
  <D.11929>:
  D.11930 = idx / 256;
  D.11931 = _wapi_private_handles[D.11930];
  if (D.11931 == 0B) goto <D.11927>; else goto <D.11928>;
  <D.11927>:
  D.11932 = 0;
  return D.11932;
  <D.11928>:
  D.11930 = idx / 256;
  D.11931 = _wapi_private_handles[D.11930];
  D.11933 = idx & 255;
  D.11934 = D.11933 * 144;
  D.11935 = D.11931 + D.11934;
  D.11932 = D.11935->type;
  return D.11932;
}


event_signal (void * handle)
{
  SetEvent (handle);
}


namedevent_own (void * handle)
{
  gboolean D.11939;
  struct _WapiHandle_namedevent * namedevent_handle.4;
  int D.11941;
  unsigned int D.11944;
  _Bool D.11945;
  long int D.11946;
  long int D.11947;
  unsigned int D.11950;
  struct _WapiHandle_namedevent * namedevent_handle;
  gboolean ok;
  static const char __func__[15] = "namedevent_own";

  try
    {
      ok = _wapi_lookup_handle (handle, 13, &namedevent_handle);
      if (ok == 0) goto <D.11937>; else goto <D.11938>;
      <D.11937>:
      monoeg_g_log (0B, 16, "%s: error looking up named event handle %p", &__func__, handle);
      D.11939 = 0;
      return D.11939;
      <D.11938>:
      namedevent_handle.4 = namedevent_handle;
      D.11941 = namedevent_handle.4->manual;
      if (D.11941 == 0) goto <D.11942>; else goto <D.11943>;
      <D.11942>:
      namedevent_handle.4 = namedevent_handle;
      D.11944 = namedevent_handle.4->set_count;
      D.11945 = D.11944 == 0;
      D.11946 = (long int) D.11945;
      D.11947 = __builtin_expect (D.11946, 0);
      if (D.11947 != 0) goto <D.11948>; else goto <D.11949>;
      <D.11948>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "events.c", 153, "namedevent_handle->set_count > 0");
      <D.11949>:
      namedevent_handle.4 = namedevent_handle;
      D.11944 = namedevent_handle.4->set_count;
      D.11950 = D.11944 + 4294967295;
      namedevent_handle.4->set_count = D.11950;
      D.11944 = namedevent_handle.4->set_count;
      if (D.11944 == 0) goto <D.11951>; else goto <D.11952>;
      <D.11951>:
      _wapi_shared_handle_set_signal_state (handle, 0);
      <D.11952>:
      <D.11943>:
      D.11939 = 1;
      return D.11939;
    }
  finally
    {
      namedevent_handle = {CLOBBER};
    }
}


_wapi_shared_handle_set_signal_state (void * handle, gboolean state)
{
  int iftmp.5;
  <unnamed type> D.11960;
  <unnamed type> D.11962;
  <unnamed type> D.11964;
  <unnamed type> D.11966;
  _Bool D.11968;
  long int D.11969;
  long int D.11970;
  unsigned int D.11973;
  struct _WapiHandleUnshared * D.11974;
  unsigned int D.11975;
  unsigned int D.11976;
  struct _WapiHandleSharedLayout * _wapi_shared_layout.6;
  unsigned int D.11978;
  guint32 idx;
  struct _WapiHandleUnshared * handle_data;
  struct _WapiHandle_shared_ref * ref;
  struct _WapiHandleShared * shared_data;

  idx = (guint32) handle;
  if (idx > 4194303) goto <D.11955>; else goto <D.11956>;
  <D.11955>:
  return;
  <D.11956>:
  D.11960 = _wapi_handle_type (handle);
  if (D.11960 != 9) goto <D.11961>; else goto <D.11958>;
  <D.11961>:
  D.11962 = _wapi_handle_type (handle);
  if (D.11962 != 11) goto <D.11963>; else goto <D.11958>;
  <D.11963>:
  D.11964 = _wapi_handle_type (handle);
  if (D.11964 != 12) goto <D.11965>; else goto <D.11958>;
  <D.11965>:
  D.11966 = _wapi_handle_type (handle);
  if (D.11966 != 13) goto <D.11967>; else goto <D.11958>;
  <D.11967>:
  iftmp.5 = 1;
  goto <D.11959>;
  <D.11958>:
  iftmp.5 = 0;
  <D.11959>:
  D.11968 = iftmp.5 != 0;
  D.11969 = (long int) D.11968;
  D.11970 = __builtin_expect (D.11969, 0);
  if (D.11970 != 0) goto <D.11971>; else goto <D.11972>;
  <D.11971>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "../../mono/io-layer/handles-private.h", 201, "_WAPI_SHARED_HANDLE(_wapi_handle_type (handle))");
  <D.11972>:
  D.11973 = idx / 256;
  D.11974 = _wapi_private_handles[D.11973];
  D.11975 = idx & 255;
  D.11976 = D.11975 * 144;
  handle_data = D.11974 + D.11976;
  ref = &handle_data->u.shared;
  _wapi_shared_layout.6 = _wapi_shared_layout;
  D.11978 = ref->offset;
  shared_data = &_wapi_shared_layout.6->handles[D.11978];
  shared_data->signalled = state;
}


namedevent_signal (void * handle)
{
  SetEvent (handle);
}


_wapi_event_details (void * handle_info)
{
  const char * iftmp.7;
  int D.11981;
  struct _WapiHandle_event * event;

  event = handle_info;
  D.11981 = event->manual;
  if (D.11981 != 0) goto <D.11982>; else goto <D.11983>;
  <D.11982>:
  iftmp.7 = "TRUE";
  goto <D.11984>;
  <D.11983>:
  iftmp.7 = "FALSE";
  <D.11984>:
  monoeg_g_print ("manual: %s", iftmp.7);
}


CreateEvent (struct WapiSecurityAttributes * security, gboolean manual, gboolean initial, const gunichar2 * name)
{
  void * D.11987;

  mono_once (&event_ops_once, event_ops_init);
  if (name == 0B) goto <D.11985>; else goto <D.11986>;
  <D.11985>:
  D.11987 = event_create (security, manual, initial);
  return D.11987;
  <D.11986>:
  D.11987 = namedevent_create (security, manual, initial, name);
  return D.11987;
}


event_ops_init ()
{
  _wapi_handle_register_capabilities (6, 3);
  _wapi_handle_register_capabilities (13, 3);
}


event_create (struct WapiSecurityAttributes * security, gboolean manual, gboolean initial)
{
  void * D.11995;
  long int D.11996;
  _Bool D.11999;
  long int D.12000;
  long int D.12001;
  struct _WapiHandle_event event_handle;
  void * handle;
  int thr_ret;
  static const char __func__[13] = "event_create";

  try
    {
      event_handle = {};
      SetLastError (0);
      event_handle.manual = manual;
      event_handle.set_count = 0;
      if (initial == 1) goto <D.11989>; else goto <D.11990>;
      <D.11989>:
      if (manual == 0) goto <D.11991>; else goto <D.11992>;
      <D.11991>:
      event_handle.set_count = 1;
      <D.11992>:
      <D.11990>:
      handle = _wapi_handle_new (6, &event_handle);
      if (handle == 4294967295B) goto <D.11993>; else goto <D.11994>;
      <D.11993>:
      monoeg_g_log (0B, 16, "%s: error creating event handle", &__func__);
      SetLastError (31);
      D.11995 = 0B;
      return D.11995;
      <D.11994>:
      {
        struct __pthread_unwind_buf_t __cancel_buf;
        void (*<Tc1>) (void *) __cancel_routine;
        void * __cancel_arg;
        int __not_first_call;

        try
          {
            __cancel_routine = _wapi_handle_unlock_handle;
            __cancel_arg = handle;
            __not_first_call = __sigsetjmp (&__cancel_buf.__cancel_jmp_buf, 0);
            D.11996 = __builtin_expect (__not_first_call, 0);
            if (D.11996 != 0) goto <D.11997>; else goto <D.11998>;
            <D.11997>:
            __cancel_routine (__cancel_arg);
            __pthread_unwind_next (&__cancel_buf);
            <D.11998>:
            __pthread_register_cancel (&__cancel_buf);
            thr_ret = _wapi_handle_lock_handle (handle);
            D.11999 = thr_ret != 0;
            D.12000 = (long int) D.11999;
            D.12001 = __builtin_expect (D.12000, 0);
            if (D.12001 != 0) goto <D.12002>; else goto <D.12003>;
            <D.12002>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "events.c", 196, "thr_ret == 0");
            <D.12003>:
            if (initial == 1) goto <D.12004>; else goto <D.12005>;
            <D.12004>:
            _wapi_handle_set_signal_state (handle, 1, 0);
            <D.12005>:
            thr_ret = _wapi_handle_unlock_handle (handle);
            D.11999 = thr_ret != 0;
            D.12000 = (long int) D.11999;
            D.12001 = __builtin_expect (D.12000, 0);
            if (D.12001 != 0) goto <D.12006>; else goto <D.12007>;
            <D.12006>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "events.c", 205, "thr_ret == 0");
            <D.12007>:
            __pthread_unregister_cancel (&__cancel_buf);
            if (0 != 0) goto <D.12008>; else goto <D.12009>;
            <D.12008>:
            __cancel_routine (__cancel_arg);
            <D.12009>:
          }
        finally
          {
            __cancel_buf = {CLOBBER};
          }
      }
      D.11995 = handle;
      return D.11995;
    }
  finally
    {
      event_handle = {CLOBBER};
    }
}


_wapi_handle_lock_handle (void * handle)
{
  int D.12017;
  <unnamed type> D.12020;
  <unnamed type> D.12022;
  <unnamed type> D.12024;
  <unnamed type> D.12026;
  unsigned int D.12027;
  struct _WapiHandleUnshared * D.12028;
  unsigned int D.12029;
  unsigned int D.12030;
  struct _WapiHandleUnshared * D.12031;
  union mono_mutex_t * D.12032;
  guint32 idx;

  idx = (guint32) handle;
  if (idx > 4194303) goto <D.12015>; else goto <D.12016>;
  <D.12015>:
  D.12017 = 0;
  return D.12017;
  <D.12016>:
  _wapi_handle_ref (handle);
  D.12020 = _wapi_handle_type (handle);
  if (D.12020 == 9) goto <D.12018>; else goto <D.12021>;
  <D.12021>:
  D.12022 = _wapi_handle_type (handle);
  if (D.12022 == 11) goto <D.12018>; else goto <D.12023>;
  <D.12023>:
  D.12024 = _wapi_handle_type (handle);
  if (D.12024 == 12) goto <D.12018>; else goto <D.12025>;
  <D.12025>:
  D.12026 = _wapi_handle_type (handle);
  if (D.12026 == 13) goto <D.12018>; else goto <D.12019>;
  <D.12018>:
  D.12017 = 0;
  return D.12017;
  <D.12019>:
  D.12027 = idx / 256;
  D.12028 = _wapi_private_handles[D.12027];
  D.12029 = idx & 255;
  D.12030 = D.12029 * 144;
  D.12031 = D.12028 + D.12030;
  D.12032 = &D.12031->signal_mutex;
  D.12017 = pthread_mutex_lock (D.12032);
  return D.12017;
}


_wapi_handle_unlock_handle (void * handle)
{
  int D.12036;
  <unnamed type> D.12039;
  <unnamed type> D.12041;
  <unnamed type> D.12043;
  <unnamed type> D.12045;
  unsigned int D.12046;
  struct _WapiHandleUnshared * D.12047;
  unsigned int D.12048;
  unsigned int D.12049;
  struct _WapiHandleUnshared * D.12050;
  union mono_mutex_t * D.12051;
  guint32 idx;
  int ret;

  idx = (guint32) handle;
  if (idx > 4194303) goto <D.12034>; else goto <D.12035>;
  <D.12034>:
  D.12036 = 0;
  return D.12036;
  <D.12035>:
  D.12039 = _wapi_handle_type (handle);
  if (D.12039 == 9) goto <D.12037>; else goto <D.12040>;
  <D.12040>:
  D.12041 = _wapi_handle_type (handle);
  if (D.12041 == 11) goto <D.12037>; else goto <D.12042>;
  <D.12042>:
  D.12043 = _wapi_handle_type (handle);
  if (D.12043 == 12) goto <D.12037>; else goto <D.12044>;
  <D.12044>:
  D.12045 = _wapi_handle_type (handle);
  if (D.12045 == 13) goto <D.12037>; else goto <D.12038>;
  <D.12037>:
  _wapi_handle_unref (handle);
  D.12036 = 0;
  return D.12036;
  <D.12038>:
  D.12046 = idx / 256;
  D.12047 = _wapi_private_handles[D.12046];
  D.12048 = idx & 255;
  D.12049 = D.12048 * 144;
  D.12050 = D.12047 + D.12049;
  D.12051 = &D.12050->signal_mutex;
  ret = pthread_mutex_unlock (D.12051);
  _wapi_handle_unref (handle);
  D.12036 = ret;
  return D.12036;
}


namedevent_create (struct WapiSecurityAttributes * security, gboolean manual, gboolean initial, const gunichar2 * name)
{
  _Bool D.12053;
  long int D.12054;
  long int D.12055;
  unsigned int D.12064;
  unsigned int offset.8;
  void * D.12082;
  struct _WapiHandle_namedevent namedevent_handle;
  void * handle;
  gchar * utf8_name;
  int thr_ret;
  void * ret;
  guint32 namelen;
  gint32 offset;
  void cleanup = <<< error >>>;
  static const char __func__[18] = "namedevent_create";

  try
    {
      namedevent_handle = {};
      ret = 0B;
      thr_ret = _wapi_namespace_lock ();
      D.12053 = thr_ret != 0;
      D.12054 = (long int) D.12053;
      D.12055 = __builtin_expect (D.12054, 0);
      if (D.12055 != 0) goto <D.12056>; else goto <D.12057>;
      <D.12056>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "events.c", 227, "thr_ret == 0");
      <D.12057>:
      SetLastError (0);
      utf8_name = monoeg_g_utf16_to_utf8 (name, -1, 0B, 0B, 0B);
      offset = _wapi_search_handle_namespace (13, utf8_name);
      if (offset == -1) goto <D.12058>; else goto <D.12059>;
      <D.12058>:
      SetLastError (6);
      goto cleanup;
      <D.12059>:
      if (offset != 0) goto <D.12060>; else goto <D.12061>;
      <D.12060>:
      SetLastError (183);
      <D.12061>:
      if (offset == 0) goto <D.12062>; else goto <D.12063>;
      <D.12062>:
      D.12064 = strlen (utf8_name);
      if (D.12064 <= 259) goto <D.12065>; else goto <D.12066>;
      <D.12065>:
      namelen = strlen (utf8_name);
      goto <D.12067>;
      <D.12066>:
      namelen = 260;
      <D.12067>:
      memcpy (&namedevent_handle.sharedns.name, utf8_name, namelen);
      namedevent_handle.manual = manual;
      namedevent_handle.set_count = 0;
      if (initial == 1) goto <D.12068>; else goto <D.12069>;
      <D.12068>:
      if (manual == 0) goto <D.12070>; else goto <D.12071>;
      <D.12070>:
      namedevent_handle.set_count = 1;
      <D.12071>:
      <D.12069>:
      handle = _wapi_handle_new (13, &namedevent_handle);
      goto <D.12072>;
      <D.12063>:
      offset.8 = (unsigned int) offset;
      handle = _wapi_handle_new_from_offset (13, offset.8, 1);
      <D.12072>:
      if (handle == 4294967295B) goto <D.12074>; else goto <D.12075>;
      <D.12074>:
      monoeg_g_log (0B, 16, "%s: error creating event handle", &__func__);
      SetLastError (31);
      goto cleanup;
      <D.12075>:
      ret = handle;
      if (offset == 0) goto <D.12076>; else goto <D.12077>;
      <D.12076>:
      thr_ret = _wapi_handle_lock_shared_handles ();
      D.12053 = thr_ret != 0;
      D.12054 = (long int) D.12053;
      D.12055 = __builtin_expect (D.12054, 0);
      if (D.12055 != 0) goto <D.12078>; else goto <D.12079>;
      <D.12078>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "events.c", 299, "thr_ret == 0");
      <D.12079>:
      if (initial == 1) goto <D.12080>; else goto <D.12081>;
      <D.12080>:
      _wapi_shared_handle_set_signal_state (handle, 1);
      <D.12081>:
      _wapi_handle_unlock_shared_handles ();
      <D.12077>:
      cleanup:
      monoeg_g_free (utf8_name);
      _wapi_namespace_unlock (0B);
      D.12082 = ret;
      return D.12082;
    }
  finally
    {
      namedevent_handle = {CLOBBER};
    }
}


_wapi_namespace_lock ()
{
  int D.12085;

  D.12085 = _wapi_shm_sem_lock (0);
  return D.12085;
}


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

  D.12088 = __builtin_object_size (__dest, 0);
  D.12087 = __builtin___memcpy_chk (__dest, __src, __len, D.12088);
  return D.12087;
}


_wapi_handle_lock_shared_handles ()
{
  int D.12090;

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


_wapi_handle_unlock_shared_handles ()
{
  int D.12092;

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


_wapi_namespace_unlock (void * data)
{
  int D.12094;

  D.12094 = _wapi_shm_sem_unlock (0);
  return D.12094;
}


PulseEvent (void * handle)
{
  gboolean D.12098;
  gboolean (*<T1d61>) (void *) D.12099;
  WapiHandleType type;

  if (handle == 0B) goto <D.12096>; else goto <D.12097>;
  <D.12096>:
  SetLastError (6);
  D.12098 = 0;
  return D.12098;
  <D.12097>:
  type = _wapi_handle_type (handle);
  D.12099 = event_ops[type].pulse;
  if (D.12099 == 0B) goto <D.12100>; else goto <D.12101>;
  <D.12100>:
  SetLastError (6);
  D.12098 = 0;
  return D.12098;
  <D.12101>:
  D.12099 = event_ops[type].pulse;
  D.12098 = D.12099 (handle);
  return D.12098;
}


namedevent_set (void * handle)
{
  gboolean D.12105;
  _Bool D.12106;
  long int D.12107;
  long int D.12108;
  struct _WapiHandle_namedevent * namedevent_handle.9;
  int D.12112;
  struct _WapiHandle_namedevent * namedevent_handle;
  gboolean ok;
  int thr_ret;
  static const char __func__[15] = "namedevent_set";

  try
    {
      ok = _wapi_lookup_handle (handle, 13, &namedevent_handle);
      if (ok == 0) goto <D.12103>; else goto <D.12104>;
      <D.12103>:
      monoeg_g_log (0B, 16, "%s: error looking up named event handle %p", &__func__, handle);
      D.12105 = 0;
      return D.12105;
      <D.12104>:
      thr_ret = _wapi_handle_lock_shared_handles ();
      D.12106 = thr_ret != 0;
      D.12107 = (long int) D.12106;
      D.12108 = __builtin_expect (D.12107, 0);
      if (D.12108 != 0) goto <D.12109>; else goto <D.12110>;
      <D.12109>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "events.c", 661, "thr_ret == 0");
      <D.12110>:
      namedevent_handle.9 = namedevent_handle;
      D.12112 = namedevent_handle.9->manual;
      if (D.12112 == 1) goto <D.12113>; else goto <D.12114>;
      <D.12113>:
      _wapi_shared_handle_set_signal_state (handle, 1);
      goto <D.12115>;
      <D.12114>:
      namedevent_handle.9 = namedevent_handle;
      namedevent_handle.9->set_count = 1;
      _wapi_shared_handle_set_signal_state (handle, 1);
      <D.12115>:
      _wapi_handle_unlock_shared_handles ();
      D.12105 = 1;
      return D.12105;
    }
  finally
    {
      namedevent_handle = {CLOBBER};
    }
}


namedevent_reset (void * handle)
{
  gboolean D.12120;
  _Bool D.12121;
  long int D.12122;
  long int D.12123;
  int D.12126;
  struct _WapiHandle_namedevent * namedevent_handle.10;
  struct _WapiHandle_namedevent * namedevent_handle;
  gboolean ok;
  int thr_ret;
  static const char __func__[17] = "namedevent_reset";

  try
    {
      ok = _wapi_lookup_handle (handle, 13, &namedevent_handle);
      if (ok == 0) goto <D.12118>; else goto <D.12119>;
      <D.12118>:
      monoeg_g_log (0B, 16, "%s: error looking up named event handle %p", &__func__, handle);
      D.12120 = 0;
      return D.12120;
      <D.12119>:
      thr_ret = _wapi_handle_lock_shared_handles ();
      D.12121 = thr_ret != 0;
      D.12122 = (long int) D.12121;
      D.12123 = __builtin_expect (D.12122, 0);
      if (D.12123 != 0) goto <D.12124>; else goto <D.12125>;
      <D.12124>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "events.c", 563, "thr_ret == 0");
      <D.12125>:
      D.12126 = _wapi_handle_issignalled (handle);
      if (D.12126 == 0) goto <D.12127>; else goto <D.12128>;
      <D.12127>:
      goto <D.12129>;
      <D.12128>:
      _wapi_shared_handle_set_signal_state (handle, 0);
      <D.12129>:
      namedevent_handle.10 = namedevent_handle;
      namedevent_handle.10->set_count = 0;
      _wapi_handle_unlock_shared_handles ();
      D.12120 = 1;
      return D.12120;
    }
  finally
    {
      namedevent_handle = {CLOBBER};
    }
}


_wapi_handle_issignalled (void * handle)
{
  gboolean D.12135;
  <unnamed type> D.12138;
  <unnamed type> D.12140;
  <unnamed type> D.12142;
  <unnamed type> D.12144;
  struct _WapiHandleSharedLayout * _wapi_shared_layout.11;
  unsigned int handle.12;
  unsigned int D.12147;
  struct _WapiHandleUnshared * D.12148;
  unsigned int D.12149;
  unsigned int D.12150;
  struct _WapiHandleUnshared * D.12151;
  unsigned int D.12152;
  unsigned int D.12153;
  struct _WapiHandleUnshared * D.12154;
  unsigned int D.12155;
  unsigned int D.12156;
  struct _WapiHandleUnshared * D.12157;
  guint32 idx;

  idx = (guint32) handle;
  if (idx > 4194303) goto <D.12133>; else goto <D.12134>;
  <D.12133>:
  D.12135 = 0;
  return D.12135;
  <D.12134>:
  D.12138 = _wapi_handle_type (handle);
  if (D.12138 == 9) goto <D.12136>; else goto <D.12139>;
  <D.12139>:
  D.12140 = _wapi_handle_type (handle);
  if (D.12140 == 11) goto <D.12136>; else goto <D.12141>;
  <D.12141>:
  D.12142 = _wapi_handle_type (handle);
  if (D.12142 == 12) goto <D.12136>; else goto <D.12143>;
  <D.12143>:
  D.12144 = _wapi_handle_type (handle);
  if (D.12144 == 13) goto <D.12136>; else goto <D.12137>;
  <D.12136>:
  _wapi_shared_layout.11 = _wapi_shared_layout;
  handle.12 = (unsigned int) handle;
  D.12147 = handle.12 / 256;
  D.12148 = _wapi_private_handles[D.12147];
  handle.12 = (unsigned int) handle;
  D.12149 = handle.12 & 255;
  D.12150 = D.12149 * 144;
  D.12151 = D.12148 + D.12150;
  D.12152 = D.12151->u.shared.offset;
  D.12135 = _wapi_shared_layout.11->handles[D.12152].signalled;
  return D.12135;
  <D.12137>:
  D.12153 = idx / 256;
  D.12154 = _wapi_private_handles[D.12153];
  D.12155 = idx & 255;
  D.12156 = D.12155 * 144;
  D.12157 = D.12154 + D.12156;
  D.12135 = D.12157->signalled;
  return D.12135;
}


namedevent_pulse (void * handle)
{
  gboolean D.12161;
  _Bool D.12162;
  long int D.12163;
  long int D.12164;
  struct _WapiHandle_namedevent * namedevent_handle.13;
  int D.12168;
  struct _WapiHandle_namedevent * namedevent_handle;
  gboolean ok;
  int thr_ret;
  static const char __func__[17] = "namedevent_pulse";

  try
    {
      ok = _wapi_lookup_handle (handle, 13, &namedevent_handle);
      if (ok == 0) goto <D.12159>; else goto <D.12160>;
      <D.12159>:
      monoeg_g_log (0B, 16, "%s: error looking up named event handle %p", &__func__, handle);
      D.12161 = 0;
      return D.12161;
      <D.12160>:
      thr_ret = _wapi_handle_lock_shared_handles ();
      D.12162 = thr_ret != 0;
      D.12163 = (long int) D.12162;
      D.12164 = __builtin_expect (D.12163, 0);
      if (D.12164 != 0) goto <D.12165>; else goto <D.12166>;
      <D.12165>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "events.c", 431, "thr_ret == 0");
      <D.12166>:
      namedevent_handle.13 = namedevent_handle;
      D.12168 = namedevent_handle.13->manual;
      if (D.12168 == 1) goto <D.12169>; else goto <D.12170>;
      <D.12169>:
      _wapi_shared_handle_set_signal_state (handle, 1);
      goto <D.12171>;
      <D.12170>:
      namedevent_handle.13 = namedevent_handle;
      namedevent_handle.13->set_count = 1;
      _wapi_shared_handle_set_signal_state (handle, 1);
      <D.12171>:
      _wapi_handle_unlock_shared_handles ();
      namedevent_handle.13 = namedevent_handle;
      D.12168 = namedevent_handle.13->manual;
      if (D.12168 == 1) goto <D.12172>; else goto <D.12173>;
      <D.12172>:
      _wapi_handle_spin (200);
      thr_ret = _wapi_handle_lock_shared_handles ();
      D.12162 = thr_ret != 0;
      D.12163 = (long int) D.12162;
      D.12164 = __builtin_expect (D.12163, 0);
      if (D.12164 != 0) goto <D.12174>; else goto <D.12175>;
      <D.12174>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "events.c", 461, "thr_ret == 0");
      <D.12175>:
      _wapi_shared_handle_set_signal_state (handle, 0);
      _wapi_handle_unlock_shared_handles ();
      <D.12173>:
      D.12161 = 1;
      return D.12161;
    }
  finally
    {
      namedevent_handle = {CLOBBER};
    }
}


_wapi_handle_spin (guint32 ms)
{
  _Bool D.12178;
  long int D.12179;
  long int D.12180;
  unsigned int D.12183;
  long int D.12184;
  struct timespec sleepytime;

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


event_set (void * handle)
{
  gboolean D.12187;
  long int D.12188;
  _Bool D.12191;
  long int D.12192;
  long int D.12193;
  struct _WapiHandle_event * event_handle.14;
  int D.12197;
  struct _WapiHandle_event * event_handle;
  gboolean ok;
  int thr_ret;
  static const char __func__[10] = "event_set";

  try
    {
      ok = _wapi_lookup_handle (handle, 6, &event_handle);
      if (ok == 0) goto <D.12185>; else goto <D.12186>;
      <D.12185>:
      monoeg_g_log (0B, 16, "%s: error looking up event handle %p", &__func__, handle);
      D.12187 = 0;
      return D.12187;
      <D.12186>:
      {
        struct __pthread_unwind_buf_t __cancel_buf;
        void (*<Tc1>) (void *) __cancel_routine;
        void * __cancel_arg;
        int __not_first_call;

        try
          {
            __cancel_routine = _wapi_handle_unlock_handle;
            __cancel_arg = handle;
            __not_first_call = __sigsetjmp (&__cancel_buf.__cancel_jmp_buf, 0);
            D.12188 = __builtin_expect (__not_first_call, 0);
            if (D.12188 != 0) goto <D.12189>; else goto <D.12190>;
            <D.12189>:
            __cancel_routine (__cancel_arg);
            __pthread_unwind_next (&__cancel_buf);
            <D.12190>:
            __pthread_register_cancel (&__cancel_buf);
            thr_ret = _wapi_handle_lock_handle (handle);
            D.12191 = thr_ret != 0;
            D.12192 = (long int) D.12191;
            D.12193 = __builtin_expect (D.12192, 0);
            if (D.12193 != 0) goto <D.12194>; else goto <D.12195>;
            <D.12194>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "events.c", 627, "thr_ret == 0");
            <D.12195>:
            event_handle.14 = event_handle;
            D.12197 = event_handle.14->manual;
            if (D.12197 == 1) goto <D.12198>; else goto <D.12199>;
            <D.12198>:
            _wapi_handle_set_signal_state (handle, 1, 1);
            goto <D.12200>;
            <D.12199>:
            event_handle.14 = event_handle;
            event_handle.14->set_count = 1;
            _wapi_handle_set_signal_state (handle, 1, 0);
            <D.12200>:
            thr_ret = _wapi_handle_unlock_handle (handle);
            D.12191 = thr_ret != 0;
            D.12192 = (long int) D.12191;
            D.12193 = __builtin_expect (D.12192, 0);
            if (D.12193 != 0) goto <D.12201>; else goto <D.12202>;
            <D.12201>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "events.c", 639, "thr_ret == 0");
            <D.12202>:
            __pthread_unregister_cancel (&__cancel_buf);
            if (0 != 0) goto <D.12203>; else goto <D.12204>;
            <D.12203>:
            __cancel_routine (__cancel_arg);
            <D.12204>:
          }
        finally
          {
            __cancel_buf = {CLOBBER};
          }
      }
      D.12187 = 1;
      return D.12187;
    }
  finally
    {
      event_handle = {CLOBBER};
    }
}


event_reset (void * handle)
{
  gboolean D.12212;
  long int D.12213;
  _Bool D.12216;
  long int D.12217;
  long int D.12218;
  int D.12221;
  struct _WapiHandle_event * event_handle.15;
  struct _WapiHandle_event * event_handle;
  gboolean ok;
  int thr_ret;
  static const char __func__[12] = "event_reset";

  try
    {
      ok = _wapi_lookup_handle (handle, 6, &event_handle);
      if (ok == 0) goto <D.12210>; else goto <D.12211>;
      <D.12210>:
      monoeg_g_log (0B, 16, "%s: error looking up event handle %p", &__func__, handle);
      D.12212 = 0;
      return D.12212;
      <D.12211>:
      {
        struct __pthread_unwind_buf_t __cancel_buf;
        void (*<Tc1>) (void *) __cancel_routine;
        void * __cancel_arg;
        int __not_first_call;

        try
          {
            __cancel_routine = _wapi_handle_unlock_handle;
            __cancel_arg = handle;
            __not_first_call = __sigsetjmp (&__cancel_buf.__cancel_jmp_buf, 0);
            D.12213 = __builtin_expect (__not_first_call, 0);
            if (D.12213 != 0) goto <D.12214>; else goto <D.12215>;
            <D.12214>:
            __cancel_routine (__cancel_arg);
            __pthread_unwind_next (&__cancel_buf);
            <D.12215>:
            __pthread_register_cancel (&__cancel_buf);
            thr_ret = _wapi_handle_lock_handle (handle);
            D.12216 = thr_ret != 0;
            D.12217 = (long int) D.12216;
            D.12218 = __builtin_expect (D.12217, 0);
            if (D.12218 != 0) goto <D.12219>; else goto <D.12220>;
            <D.12219>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "events.c", 524, "thr_ret == 0");
            <D.12220>:
            D.12221 = _wapi_handle_issignalled (handle);
            if (D.12221 == 0) goto <D.12222>; else goto <D.12223>;
            <D.12222>:
            goto <D.12224>;
            <D.12223>:
            _wapi_handle_set_signal_state (handle, 0, 0);
            <D.12224>:
            event_handle.15 = event_handle;
            event_handle.15->set_count = 0;
            thr_ret = _wapi_handle_unlock_handle (handle);
            D.12216 = thr_ret != 0;
            D.12217 = (long int) D.12216;
            D.12218 = __builtin_expect (D.12217, 0);
            if (D.12218 != 0) goto <D.12226>; else goto <D.12227>;
            <D.12226>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "events.c", 539, "thr_ret == 0");
            <D.12227>:
            __pthread_unregister_cancel (&__cancel_buf);
            if (0 != 0) goto <D.12228>; else goto <D.12229>;
            <D.12228>:
            __cancel_routine (__cancel_arg);
            <D.12229>:
          }
        finally
          {
            __cancel_buf = {CLOBBER};
          }
      }
      D.12212 = 1;
      return D.12212;
    }
  finally
    {
      event_handle = {CLOBBER};
    }
}


event_pulse (void * handle)
{
  gboolean D.12238;
  long int D.12239;
  _Bool D.12242;
  long int D.12243;
  long int D.12244;
  struct _WapiHandle_event * event_handle.16;
  int D.12248;
  long int D.12258;
  struct _WapiHandle_event * event_handle;
  gboolean ok;
  int thr_ret;
  static const char __func__[12] = "event_pulse";

  try
    {
      ok = _wapi_lookup_handle (handle, 6, &event_handle);
      if (ok == 0) goto <D.12236>; else goto <D.12237>;
      <D.12236>:
      monoeg_g_log (0B, 16, "%s: error looking up event handle %p", &__func__, handle);
      D.12238 = 0;
      return D.12238;
      <D.12237>:
      {
        struct __pthread_unwind_buf_t __cancel_buf;
        void (*<Tc1>) (void *) __cancel_routine;
        void * __cancel_arg;
        int __not_first_call;

        try
          {
            __cancel_routine = _wapi_handle_unlock_handle;
            __cancel_arg = handle;
            __not_first_call = __sigsetjmp (&__cancel_buf.__cancel_jmp_buf, 0);
            D.12239 = __builtin_expect (__not_first_call, 0);
            if (D.12239 != 0) goto <D.12240>; else goto <D.12241>;
            <D.12240>:
            __cancel_routine (__cancel_arg);
            __pthread_unwind_next (&__cancel_buf);
            <D.12241>:
            __pthread_register_cancel (&__cancel_buf);
            thr_ret = _wapi_handle_lock_handle (handle);
            D.12242 = thr_ret != 0;
            D.12243 = (long int) D.12242;
            D.12244 = __builtin_expect (D.12243, 0);
            if (D.12244 != 0) goto <D.12245>; else goto <D.12246>;
            <D.12245>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "events.c", 370, "thr_ret == 0");
            <D.12246>:
            event_handle.16 = event_handle;
            D.12248 = event_handle.16->manual;
            if (D.12248 == 1) goto <D.12249>; else goto <D.12250>;
            <D.12249>:
            _wapi_handle_set_signal_state (handle, 1, 1);
            goto <D.12251>;
            <D.12250>:
            event_handle.16 = event_handle;
            event_handle.16->set_count = 1;
            _wapi_handle_set_signal_state (handle, 1, 0);
            <D.12251>:
            thr_ret = _wapi_handle_unlock_handle (handle);
            D.12242 = thr_ret != 0;
            D.12243 = (long int) D.12242;
            D.12244 = __builtin_expect (D.12243, 0);
            if (D.12244 != 0) goto <D.12252>; else goto <D.12253>;
            <D.12252>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "events.c", 382, "thr_ret == 0");
            <D.12253>:
            __pthread_unregister_cancel (&__cancel_buf);
            if (0 != 0) goto <D.12254>; else goto <D.12255>;
            <D.12254>:
            __cancel_routine (__cancel_arg);
            <D.12255>:
          }
        finally
          {
            __cancel_buf = {CLOBBER};
          }
      }
      event_handle.16 = event_handle;
      D.12248 = event_handle.16->manual;
      if (D.12248 == 1) goto <D.12256>; else goto <D.12257>;
      <D.12256>:
      sched_yield ();
      {
        struct __pthread_unwind_buf_t __cancel_buf;
        void (*<Tc1>) (void *) __cancel_routine;
        void * __cancel_arg;
        int __not_first_call;

        try
          {
            __cancel_routine = _wapi_handle_unlock_handle;
            __cancel_arg = handle;
            __not_first_call = __sigsetjmp (&__cancel_buf.__cancel_jmp_buf, 0);
            D.12258 = __builtin_expect (__not_first_call, 0);
            if (D.12258 != 0) goto <D.12259>; else goto <D.12260>;
            <D.12259>:
            __cancel_routine (__cancel_arg);
            __pthread_unwind_next (&__cancel_buf);
            <D.12260>:
            __pthread_register_cancel (&__cancel_buf);
            thr_ret = _wapi_handle_lock_handle (handle);
            D.12242 = thr_ret != 0;
            D.12243 = (long int) D.12242;
            D.12244 = __builtin_expect (D.12243, 0);
            if (D.12244 != 0) goto <D.12261>; else goto <D.12262>;
            <D.12261>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "events.c", 404, "thr_ret == 0");
            <D.12262>:
            _wapi_handle_set_signal_state (handle, 0, 0);
            thr_ret = _wapi_handle_unlock_handle (handle);
            D.12242 = thr_ret != 0;
            D.12243 = (long int) D.12242;
            D.12244 = __builtin_expect (D.12243, 0);
            if (D.12244 != 0) goto <D.12263>; else goto <D.12264>;
            <D.12263>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "events.c", 409, "thr_ret == 0");
            <D.12264>:
            __pthread_unregister_cancel (&__cancel_buf);
            if (0 != 0) goto <D.12265>; else goto <D.12266>;
            <D.12265>:
            __cancel_routine (__cancel_arg);
            <D.12266>:
          }
        finally
          {
            __cancel_buf = {CLOBBER};
          }
      }
      <D.12257>:
      D.12238 = 1;
      return D.12238;
    }
  finally
    {
      event_handle = {CLOBBER};
    }
}


ResetEvent (void * handle)
{
  gboolean D.12276;
  gboolean (*<T1d61>) (void *) D.12277;
  WapiHandleType type;

  if (handle == 0B) goto <D.12274>; else goto <D.12275>;
  <D.12274>:
  SetLastError (6);
  D.12276 = 0;
  return D.12276;
  <D.12275>:
  type = _wapi_handle_type (handle);
  D.12277 = event_ops[type].reset;
  if (D.12277 == 0B) goto <D.12278>; else goto <D.12279>;
  <D.12278>:
  SetLastError (6);
  D.12276 = 0;
  return D.12276;
  <D.12279>:
  D.12277 = event_ops[type].reset;
  D.12276 = D.12277 (handle);
  return D.12276;
}


SetEvent (void * handle)
{
  gboolean D.12283;
  gboolean (*<T1d61>) (void *) D.12284;
  WapiHandleType type;

  if (handle == 0B) goto <D.12281>; else goto <D.12282>;
  <D.12281>:
  SetLastError (6);
  D.12283 = 0;
  return D.12283;
  <D.12282>:
  type = _wapi_handle_type (handle);
  D.12284 = event_ops[type].set;
  if (D.12284 == 0B) goto <D.12285>; else goto <D.12286>;
  <D.12285>:
  SetLastError (6);
  D.12283 = 0;
  return D.12283;
  <D.12286>:
  D.12284 = event_ops[type].set;
  D.12283 = D.12284 (handle);
  return D.12283;
}


OpenEvent (guint32 access, gboolean inherit, const gunichar2 * name)
{
  _Bool D.12288;
  long int D.12289;
  long int D.12290;
  unsigned int offset.17;
  void * D.12300;
  void * handle;
  gchar * utf8_name;
  int thr_ret;
  void * ret;
  gint32 offset;
  void cleanup = <<< error >>>;
  static const char __func__[10] = "OpenEvent";

  ret = 0B;
  mono_once (&event_ops_once, event_ops_init);
  thr_ret = _wapi_namespace_lock ();
  D.12288 = thr_ret != 0;
  D.12289 = (long int) D.12288;
  D.12290 = __builtin_expect (D.12289, 0);
  if (D.12290 != 0) goto <D.12291>; else goto <D.12292>;
  <D.12291>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "events.c", 724, "thr_ret == 0");
  <D.12292>:
  utf8_name = monoeg_g_utf16_to_utf8 (name, -1, 0B, 0B, 0B);
  offset = _wapi_search_handle_namespace (13, utf8_name);
  if (offset == -1) goto <D.12293>; else goto <D.12294>;
  <D.12293>:
  SetLastError (6);
  goto cleanup;
  <D.12294>:
  if (offset == 0) goto <D.12295>; else goto <D.12296>;
  <D.12295>:
  SetLastError (2);
  goto cleanup;
  <D.12296>:
  offset.17 = (unsigned int) offset;
  handle = _wapi_handle_new_from_offset (13, offset.17, 1);
  if (handle == 4294967295B) goto <D.12298>; else goto <D.12299>;
  <D.12298>:
  monoeg_g_log (0B, 16, "%s: error opening named event handle", &__func__);
  SetLastError (31);
  goto cleanup;
  <D.12299>:
  ret = handle;
  cleanup:
  monoeg_g_free (utf8_name);
  _wapi_namespace_unlock (0B);
  D.12300 = ret;
  return D.12300;
}


