event_own (void * handle)
{
  gboolean D.10083;
  struct _WapiHandle_event * event_handle.0;
  int D.10085;
  unsigned int D.10088;
  _Bool D.10089;
  long int D.10090;
  long int D.10091;
  unsigned int D.10094;
  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.10081>; else goto <D.10082>;
      <D.10081>:
      monoeg_g_log (0B, 16, "%s: error looking up event handle %p", &__func__, handle);
      D.10083 = 0;
      return D.10083;
      <D.10082>:
      event_handle.0 = event_handle;
      D.10085 = event_handle.0->manual;
      if (D.10085 == 0) goto <D.10086>; else goto <D.10087>;
      <D.10086>:
      event_handle.0 = event_handle;
      D.10088 = event_handle.0->set_count;
      D.10089 = D.10088 == 0;
      D.10090 = (long int) D.10089;
      D.10091 = __builtin_expect (D.10090, 0);
      if (D.10091 != 0) goto <D.10092>; else goto <D.10093>;
      <D.10092>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "events.c", 121, "event_handle->set_count > 0");
      <D.10093>:
      event_handle.0 = event_handle;
      D.10088 = event_handle.0->set_count;
      D.10094 = D.10088 + 4294967295;
      event_handle.0->set_count = D.10094;
      D.10088 = event_handle.0->set_count;
      if (D.10088 == 0) goto <D.10095>; else goto <D.10096>;
      <D.10095>:
      _wapi_handle_set_signal_state (handle, 0, 0);
      <D.10096>:
      <D.10087>:
      D.10083 = 1;
      return D.10083;
    }
  finally
    {
      event_handle = {CLOBBER};
    }
}


_wapi_handle_set_signal_state (void * handle, gboolean state, gboolean broadcast)
{
  long int handle.1;
  int iftmp.2;
  <unnamed type> D.10106;
  <unnamed type> D.10108;
  <unnamed type> D.10110;
  <unnamed type> D.10112;
  _Bool D.10113;
  long int D.10114;
  long int D.10115;
  unsigned int D.10118;
  struct _WapiHandleUnshared * D.10119;
  long unsigned int D.10120;
  long unsigned int D.10121;
  long unsigned int D.10122;
  long int D.10125;
  long int D.10126;
  union mono_mutex_t * _wapi_global_signal_mutex.3;
  _Bool D.10132;
  long int D.10133;
  long int D.10134;
  union pthread_cond_t * D.10139;
  union pthread_cond_t * _wapi_global_signal_cond.4;
  guint32 idx;
  struct _WapiHandleUnshared * handle_data;
  int thr_ret;

  handle.1 = (long int) handle;
  idx = (guint32) handle.1;
  if (idx > 4194303) goto <D.10100>; else goto <D.10101>;
  <D.10100>:
  return;
  <D.10101>:
  D.10106 = _wapi_handle_type (handle);
  if (D.10106 == 9) goto <D.10103>; else goto <D.10107>;
  <D.10107>:
  D.10108 = _wapi_handle_type (handle);
  if (D.10108 == 11) goto <D.10103>; else goto <D.10109>;
  <D.10109>:
  D.10110 = _wapi_handle_type (handle);
  if (D.10110 == 12) goto <D.10103>; else goto <D.10111>;
  <D.10111>:
  D.10112 = _wapi_handle_type (handle);
  if (D.10112 == 13) goto <D.10103>; else goto <D.10104>;
  <D.10103>:
  iftmp.2 = 1;
  goto <D.10105>;
  <D.10104>:
  iftmp.2 = 0;
  <D.10105>:
  D.10113 = iftmp.2 != 0;
  D.10114 = (long int) D.10113;
  D.10115 = __builtin_expect (D.10114, 0);
  if (D.10115 != 0) goto <D.10116>; else goto <D.10117>;
  <D.10116>:
  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.10117>:
  D.10118 = idx / 256;
  D.10119 = _wapi_private_handles[D.10118];
  D.10120 = (long unsigned int) idx;
  D.10121 = D.10120 & 255;
  D.10122 = D.10121 * 200;
  handle_data = D.10119 + D.10122;
  if (state == 1) goto <D.10123>; else goto <D.10124>;
  <D.10123>:
  {
    struct __pthread_unwind_buf_t __cancel_buf;
    void (*<Tbf>) (void *) __cancel_routine;
    void * __cancel_arg;
    int __not_first_call;

    try
      {
        __cancel_routine = mono_mutex_unlock_in_cleanup;
        __cancel_arg = _wapi_global_signal_mutex;
        __not_first_call = __sigsetjmp (&__cancel_buf.__cancel_jmp_buf, 0);
        D.10125 = (long int) __not_first_call;
        D.10126 = __builtin_expect (D.10125, 0);
        if (D.10126 != 0) goto <D.10127>; else goto <D.10128>;
        <D.10127>:
        __cancel_routine (__cancel_arg);
        __pthread_unwind_next (&__cancel_buf);
        <D.10128>:
        __pthread_register_cancel (&__cancel_buf);
        _wapi_global_signal_mutex.3 = _wapi_global_signal_mutex;
        thr_ret = pthread_mutex_lock (_wapi_global_signal_mutex.3);
        if (thr_ret != 0) goto <D.10130>; else goto <D.10131>;
        <D.10130>:
        monoeg_g_log (0B, 16, "Bad call to mono_mutex_lock result %d for global signal mutex", thr_ret);
        <D.10131>:
        D.10132 = thr_ret != 0;
        D.10133 = (long int) D.10132;
        D.10134 = __builtin_expect (D.10133, 0);
        if (D.10134 != 0) goto <D.10135>; else goto <D.10136>;
        <D.10135>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "../../mono/io-layer/handles-private.h", 151, "thr_ret == 0");
        <D.10136>:
        handle_data->signalled = state;
        if (broadcast == 1) goto <D.10137>; else goto <D.10138>;
        <D.10137>:
        D.10139 = &handle_data->signal_cond;
        thr_ret = pthread_cond_broadcast (D.10139);
        if (thr_ret != 0) goto <D.10140>; else goto <D.10141>;
        <D.10140>:
        monoeg_g_log (0B, 16, "Bad call to pthread_cond_broadcast result %d for handle %p", thr_ret, handle);
        <D.10141>:
        D.10132 = thr_ret != 0;
        D.10133 = (long int) D.10132;
        D.10134 = __builtin_expect (D.10133, 0);
        if (D.10134 != 0) goto <D.10142>; else goto <D.10143>;
        <D.10142>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "../../mono/io-layer/handles-private.h", 162, "thr_ret == 0");
        <D.10143>:
        goto <D.10144>;
        <D.10138>:
        D.10139 = &handle_data->signal_cond;
        thr_ret = pthread_cond_signal (D.10139);
        if (thr_ret != 0) goto <D.10145>; else goto <D.10146>;
        <D.10145>:
        monoeg_g_log (0B, 16, "Bad call to pthread_cond_signal result %d for handle %p", thr_ret, handle);
        <D.10146>:
        D.10132 = thr_ret != 0;
        D.10133 = (long int) D.10132;
        D.10134 = __builtin_expect (D.10133, 0);
        if (D.10134 != 0) goto <D.10147>; else goto <D.10148>;
        <D.10147>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "../../mono/io-layer/handles-private.h", 167, "thr_ret == 0");
        <D.10148>:
        <D.10144>:
        _wapi_global_signal_cond.4 = _wapi_global_signal_cond;
        thr_ret = pthread_cond_broadcast (_wapi_global_signal_cond.4);
        if (thr_ret != 0) goto <D.10150>; else goto <D.10151>;
        <D.10150>:
        monoeg_g_log (0B, 16, "Bad call to pthread_cond_broadcast result %d for handle %p", thr_ret, handle);
        <D.10151>:
        D.10132 = thr_ret != 0;
        D.10133 = (long int) D.10132;
        D.10134 = __builtin_expect (D.10133, 0);
        if (D.10134 != 0) goto <D.10152>; else goto <D.10153>;
        <D.10152>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "../../mono/io-layer/handles-private.h", 176, "thr_ret == 0");
        <D.10153>:
        _wapi_global_signal_mutex.3 = _wapi_global_signal_mutex;
        thr_ret = pthread_mutex_unlock (_wapi_global_signal_mutex.3);
        if (thr_ret != 0) goto <D.10154>; else goto <D.10155>;
        <D.10154>:
        monoeg_g_log (0B, 16, "Bad call to mono_mutex_unlock result %d for global signal mutex", thr_ret);
        <D.10155>:
        D.10132 = thr_ret != 0;
        D.10133 = (long int) D.10132;
        D.10134 = __builtin_expect (D.10133, 0);
        if (D.10134 != 0) goto <D.10156>; else goto <D.10157>;
        <D.10156>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "../../mono/io-layer/handles-private.h", 181, "thr_ret == 0");
        <D.10157>:
        __pthread_unregister_cancel (&__cancel_buf);
        if (0 != 0) goto <D.10158>; else goto <D.10159>;
        <D.10158>:
        __cancel_routine (__cancel_arg);
        <D.10159>:
      }
    finally
      {
        __cancel_buf = {CLOBBER};
      }
  }
  goto <D.10160>;
  <D.10124>:
  handle_data->signalled = state;
  <D.10160>:
}


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

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


_wapi_handle_type (void * handle)
{
  long int handle.5;
  unsigned int D.10178;
  struct _WapiHandleUnshared * D.10179;
  WapiHandleType D.10180;
  unsigned int D.10181;
  struct _WapiHandleUnshared * D.10182;
  long unsigned int D.10183;
  long unsigned int D.10184;
  long unsigned int D.10185;
  struct _WapiHandleUnshared * D.10186;
  guint32 idx;

  handle.5 = (long int) handle;
  idx = (guint32) handle.5;
  if (idx > 4194303) goto <D.10174>; else goto <D.10176>;
  <D.10176>:
  if (idx > 268435455) goto <D.10174>; else goto <D.10177>;
  <D.10177>:
  D.10178 = idx / 256;
  D.10179 = _wapi_private_handles[D.10178];
  if (D.10179 == 0B) goto <D.10174>; else goto <D.10175>;
  <D.10174>:
  D.10180 = 0;
  return D.10180;
  <D.10175>:
  D.10181 = idx / 256;
  D.10182 = _wapi_private_handles[D.10181];
  D.10183 = (long unsigned int) idx;
  D.10184 = D.10183 & 255;
  D.10185 = D.10184 * 200;
  D.10186 = D.10182 + D.10185;
  D.10180 = D.10186->type;
  return D.10180;
}


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


namedevent_own (void * handle)
{
  gboolean D.10190;
  struct _WapiHandle_namedevent * namedevent_handle.6;
  int D.10192;
  unsigned int D.10195;
  _Bool D.10196;
  long int D.10197;
  long int D.10198;
  unsigned int D.10201;
  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.10188>; else goto <D.10189>;
      <D.10188>:
      monoeg_g_log (0B, 16, "%s: error looking up named event handle %p", &__func__, handle);
      D.10190 = 0;
      return D.10190;
      <D.10189>:
      namedevent_handle.6 = namedevent_handle;
      D.10192 = namedevent_handle.6->manual;
      if (D.10192 == 0) goto <D.10193>; else goto <D.10194>;
      <D.10193>:
      namedevent_handle.6 = namedevent_handle;
      D.10195 = namedevent_handle.6->set_count;
      D.10196 = D.10195 == 0;
      D.10197 = (long int) D.10196;
      D.10198 = __builtin_expect (D.10197, 0);
      if (D.10198 != 0) goto <D.10199>; else goto <D.10200>;
      <D.10199>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "events.c", 153, "namedevent_handle->set_count > 0");
      <D.10200>:
      namedevent_handle.6 = namedevent_handle;
      D.10195 = namedevent_handle.6->set_count;
      D.10201 = D.10195 + 4294967295;
      namedevent_handle.6->set_count = D.10201;
      D.10195 = namedevent_handle.6->set_count;
      if (D.10195 == 0) goto <D.10202>; else goto <D.10203>;
      <D.10202>:
      _wapi_shared_handle_set_signal_state (handle, 0);
      <D.10203>:
      <D.10194>:
      D.10190 = 1;
      return D.10190;
    }
  finally
    {
      namedevent_handle = {CLOBBER};
    }
}


_wapi_shared_handle_set_signal_state (void * handle, gboolean state)
{
  long int handle.7;
  int iftmp.8;
  <unnamed type> D.10212;
  <unnamed type> D.10214;
  <unnamed type> D.10216;
  <unnamed type> D.10218;
  _Bool D.10220;
  long int D.10221;
  long int D.10222;
  unsigned int D.10225;
  struct _WapiHandleUnshared * D.10226;
  long unsigned int D.10227;
  long unsigned int D.10228;
  long unsigned int D.10229;
  struct _WapiHandleSharedLayout * _wapi_shared_layout.9;
  unsigned int D.10231;
  guint32 idx;
  struct _WapiHandleUnshared * handle_data;
  struct _WapiHandle_shared_ref * ref;
  struct _WapiHandleShared * shared_data;

  handle.7 = (long int) handle;
  idx = (guint32) handle.7;
  if (idx > 4194303) goto <D.10207>; else goto <D.10208>;
  <D.10207>:
  return;
  <D.10208>:
  D.10212 = _wapi_handle_type (handle);
  if (D.10212 != 9) goto <D.10213>; else goto <D.10210>;
  <D.10213>:
  D.10214 = _wapi_handle_type (handle);
  if (D.10214 != 11) goto <D.10215>; else goto <D.10210>;
  <D.10215>:
  D.10216 = _wapi_handle_type (handle);
  if (D.10216 != 12) goto <D.10217>; else goto <D.10210>;
  <D.10217>:
  D.10218 = _wapi_handle_type (handle);
  if (D.10218 != 13) goto <D.10219>; else goto <D.10210>;
  <D.10219>:
  iftmp.8 = 1;
  goto <D.10211>;
  <D.10210>:
  iftmp.8 = 0;
  <D.10211>:
  D.10220 = iftmp.8 != 0;
  D.10221 = (long int) D.10220;
  D.10222 = __builtin_expect (D.10221, 0);
  if (D.10222 != 0) goto <D.10223>; else goto <D.10224>;
  <D.10223>:
  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.10224>:
  D.10225 = idx / 256;
  D.10226 = _wapi_private_handles[D.10225];
  D.10227 = (long unsigned int) idx;
  D.10228 = D.10227 & 255;
  D.10229 = D.10228 * 200;
  handle_data = D.10226 + D.10229;
  ref = &handle_data->u.shared;
  _wapi_shared_layout.9 = _wapi_shared_layout;
  D.10231 = ref->offset;
  shared_data = &_wapi_shared_layout.9->handles[D.10231];
  shared_data->signalled = state;
}


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


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

  event = handle_info;
  D.10234 = event->manual;
  if (D.10234 != 0) goto <D.10235>; else goto <D.10236>;
  <D.10235>:
  iftmp.10 = "TRUE";
  goto <D.10237>;
  <D.10236>:
  iftmp.10 = "FALSE";
  <D.10237>:
  monoeg_g_print ("manual: %s", iftmp.10);
}


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

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


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.10248;
  long int D.10249;
  long int D.10250;
  _Bool D.10253;
  long int D.10254;
  long int D.10255;
  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.10242>; else goto <D.10243>;
      <D.10242>:
      if (manual == 0) goto <D.10244>; else goto <D.10245>;
      <D.10244>:
      event_handle.set_count = 1;
      <D.10245>:
      <D.10243>:
      handle = _wapi_handle_new (6, &event_handle);
      if (handle == -1B) goto <D.10246>; else goto <D.10247>;
      <D.10246>:
      monoeg_g_log (0B, 16, "%s: error creating event handle", &__func__);
      SetLastError (31);
      D.10248 = 0B;
      return D.10248;
      <D.10247>:
      {
        struct __pthread_unwind_buf_t __cancel_buf;
        void (*<Tbf>) (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.10249 = (long int) __not_first_call;
            D.10250 = __builtin_expect (D.10249, 0);
            if (D.10250 != 0) goto <D.10251>; else goto <D.10252>;
            <D.10251>:
            __cancel_routine (__cancel_arg);
            __pthread_unwind_next (&__cancel_buf);
            <D.10252>:
            __pthread_register_cancel (&__cancel_buf);
            thr_ret = _wapi_handle_lock_handle (handle);
            D.10253 = thr_ret != 0;
            D.10254 = (long int) D.10253;
            D.10255 = __builtin_expect (D.10254, 0);
            if (D.10255 != 0) goto <D.10256>; else goto <D.10257>;
            <D.10256>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "events.c", 196, "thr_ret == 0");
            <D.10257>:
            if (initial == 1) goto <D.10258>; else goto <D.10259>;
            <D.10258>:
            _wapi_handle_set_signal_state (handle, 1, 0);
            <D.10259>:
            thr_ret = _wapi_handle_unlock_handle (handle);
            D.10253 = thr_ret != 0;
            D.10254 = (long int) D.10253;
            D.10255 = __builtin_expect (D.10254, 0);
            if (D.10255 != 0) goto <D.10260>; else goto <D.10261>;
            <D.10260>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "events.c", 205, "thr_ret == 0");
            <D.10261>:
            __pthread_unregister_cancel (&__cancel_buf);
            if (0 != 0) goto <D.10262>; else goto <D.10263>;
            <D.10262>:
            __cancel_routine (__cancel_arg);
            <D.10263>:
          }
        finally
          {
            __cancel_buf = {CLOBBER};
          }
      }
      D.10248 = handle;
      return D.10248;
    }
  finally
    {
      event_handle = {CLOBBER};
    }
}


_wapi_handle_lock_handle (void * handle)
{
  long int handle.11;
  int D.10272;
  <unnamed type> D.10275;
  <unnamed type> D.10277;
  <unnamed type> D.10279;
  <unnamed type> D.10281;
  unsigned int D.10282;
  struct _WapiHandleUnshared * D.10283;
  long unsigned int D.10284;
  long unsigned int D.10285;
  long unsigned int D.10286;
  struct _WapiHandleUnshared * D.10287;
  union mono_mutex_t * D.10288;
  guint32 idx;

  handle.11 = (long int) handle;
  idx = (guint32) handle.11;
  if (idx > 4194303) goto <D.10270>; else goto <D.10271>;
  <D.10270>:
  D.10272 = 0;
  return D.10272;
  <D.10271>:
  _wapi_handle_ref (handle);
  D.10275 = _wapi_handle_type (handle);
  if (D.10275 == 9) goto <D.10273>; else goto <D.10276>;
  <D.10276>:
  D.10277 = _wapi_handle_type (handle);
  if (D.10277 == 11) goto <D.10273>; else goto <D.10278>;
  <D.10278>:
  D.10279 = _wapi_handle_type (handle);
  if (D.10279 == 12) goto <D.10273>; else goto <D.10280>;
  <D.10280>:
  D.10281 = _wapi_handle_type (handle);
  if (D.10281 == 13) goto <D.10273>; else goto <D.10274>;
  <D.10273>:
  D.10272 = 0;
  return D.10272;
  <D.10274>:
  D.10282 = idx / 256;
  D.10283 = _wapi_private_handles[D.10282];
  D.10284 = (long unsigned int) idx;
  D.10285 = D.10284 & 255;
  D.10286 = D.10285 * 200;
  D.10287 = D.10283 + D.10286;
  D.10288 = &D.10287->signal_mutex;
  D.10272 = pthread_mutex_lock (D.10288);
  return D.10272;
}


_wapi_handle_unlock_handle (void * handle)
{
  long int handle.12;
  int D.10293;
  <unnamed type> D.10296;
  <unnamed type> D.10298;
  <unnamed type> D.10300;
  <unnamed type> D.10302;
  unsigned int D.10303;
  struct _WapiHandleUnshared * D.10304;
  long unsigned int D.10305;
  long unsigned int D.10306;
  long unsigned int D.10307;
  struct _WapiHandleUnshared * D.10308;
  union mono_mutex_t * D.10309;
  guint32 idx;
  int ret;

  handle.12 = (long int) handle;
  idx = (guint32) handle.12;
  if (idx > 4194303) goto <D.10291>; else goto <D.10292>;
  <D.10291>:
  D.10293 = 0;
  return D.10293;
  <D.10292>:
  D.10296 = _wapi_handle_type (handle);
  if (D.10296 == 9) goto <D.10294>; else goto <D.10297>;
  <D.10297>:
  D.10298 = _wapi_handle_type (handle);
  if (D.10298 == 11) goto <D.10294>; else goto <D.10299>;
  <D.10299>:
  D.10300 = _wapi_handle_type (handle);
  if (D.10300 == 12) goto <D.10294>; else goto <D.10301>;
  <D.10301>:
  D.10302 = _wapi_handle_type (handle);
  if (D.10302 == 13) goto <D.10294>; else goto <D.10295>;
  <D.10294>:
  _wapi_handle_unref (handle);
  D.10293 = 0;
  return D.10293;
  <D.10295>:
  D.10303 = idx / 256;
  D.10304 = _wapi_private_handles[D.10303];
  D.10305 = (long unsigned int) idx;
  D.10306 = D.10305 & 255;
  D.10307 = D.10306 * 200;
  D.10308 = D.10304 + D.10307;
  D.10309 = &D.10308->signal_mutex;
  ret = pthread_mutex_unlock (D.10309);
  _wapi_handle_unref (handle);
  D.10293 = ret;
  return D.10293;
}


namedevent_create (struct WapiSecurityAttributes * security, gboolean manual, gboolean initial, const gunichar2 * name)
{
  _Bool D.10311;
  long int D.10312;
  long int D.10313;
  long unsigned int D.10322;
  long unsigned int D.10325;
  long unsigned int D.10327;
  unsigned int offset.13;
  void * D.10342;
  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.10311 = thr_ret != 0;
      D.10312 = (long int) D.10311;
      D.10313 = __builtin_expect (D.10312, 0);
      if (D.10313 != 0) goto <D.10314>; else goto <D.10315>;
      <D.10314>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "events.c", 227, "thr_ret == 0");
      <D.10315>:
      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.10316>; else goto <D.10317>;
      <D.10316>:
      SetLastError (6);
      goto cleanup;
      <D.10317>:
      if (offset != 0) goto <D.10318>; else goto <D.10319>;
      <D.10318>:
      SetLastError (183);
      <D.10319>:
      if (offset == 0) goto <D.10320>; else goto <D.10321>;
      <D.10320>:
      D.10322 = strlen (utf8_name);
      if (D.10322 <= 259) goto <D.10323>; else goto <D.10324>;
      <D.10323>:
      D.10325 = strlen (utf8_name);
      namelen = (guint32) D.10325;
      goto <D.10326>;
      <D.10324>:
      namelen = 260;
      <D.10326>:
      D.10327 = (long unsigned int) namelen;
      memcpy (&namedevent_handle.sharedns.name, utf8_name, D.10327);
      namedevent_handle.manual = manual;
      namedevent_handle.set_count = 0;
      if (initial == 1) goto <D.10328>; else goto <D.10329>;
      <D.10328>:
      if (manual == 0) goto <D.10330>; else goto <D.10331>;
      <D.10330>:
      namedevent_handle.set_count = 1;
      <D.10331>:
      <D.10329>:
      handle = _wapi_handle_new (13, &namedevent_handle);
      goto <D.10332>;
      <D.10321>:
      offset.13 = (unsigned int) offset;
      handle = _wapi_handle_new_from_offset (13, offset.13, 1);
      <D.10332>:
      if (handle == -1B) goto <D.10334>; else goto <D.10335>;
      <D.10334>:
      monoeg_g_log (0B, 16, "%s: error creating event handle", &__func__);
      SetLastError (31);
      goto cleanup;
      <D.10335>:
      ret = handle;
      if (offset == 0) goto <D.10336>; else goto <D.10337>;
      <D.10336>:
      thr_ret = _wapi_handle_lock_shared_handles ();
      D.10311 = thr_ret != 0;
      D.10312 = (long int) D.10311;
      D.10313 = __builtin_expect (D.10312, 0);
      if (D.10313 != 0) goto <D.10338>; else goto <D.10339>;
      <D.10338>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "events.c", 299, "thr_ret == 0");
      <D.10339>:
      if (initial == 1) goto <D.10340>; else goto <D.10341>;
      <D.10340>:
      _wapi_shared_handle_set_signal_state (handle, 1);
      <D.10341>:
      _wapi_handle_unlock_shared_handles ();
      <D.10337>:
      cleanup:
      monoeg_g_free (utf8_name);
      _wapi_namespace_unlock (0B);
      D.10342 = ret;
      return D.10342;
    }
  finally
    {
      namedevent_handle = {CLOBBER};
    }
}


_wapi_namespace_lock ()
{
  int D.10345;

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


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

  D.10348 = __builtin_object_size (__dest, 0);
  D.10347 = __builtin___memcpy_chk (__dest, __src, __len, D.10348);
  return D.10347;
}


_wapi_handle_lock_shared_handles ()
{
  int D.10350;

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


_wapi_handle_unlock_shared_handles ()
{
  int D.10352;

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


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

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


PulseEvent (void * handle)
{
  gboolean D.10358;
  gboolean (*<T1399>) (void *) D.10359;
  WapiHandleType type;

  if (handle == 0B) goto <D.10356>; else goto <D.10357>;
  <D.10356>:
  SetLastError (6);
  D.10358 = 0;
  return D.10358;
  <D.10357>:
  type = _wapi_handle_type (handle);
  D.10359 = event_ops[type].pulse;
  if (D.10359 == 0B) goto <D.10360>; else goto <D.10361>;
  <D.10360>:
  SetLastError (6);
  D.10358 = 0;
  return D.10358;
  <D.10361>:
  D.10359 = event_ops[type].pulse;
  D.10358 = D.10359 (handle);
  return D.10358;
}


namedevent_set (void * handle)
{
  gboolean D.10365;
  _Bool D.10366;
  long int D.10367;
  long int D.10368;
  struct _WapiHandle_namedevent * namedevent_handle.14;
  int D.10372;
  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.10363>; else goto <D.10364>;
      <D.10363>:
      monoeg_g_log (0B, 16, "%s: error looking up named event handle %p", &__func__, handle);
      D.10365 = 0;
      return D.10365;
      <D.10364>:
      thr_ret = _wapi_handle_lock_shared_handles ();
      D.10366 = thr_ret != 0;
      D.10367 = (long int) D.10366;
      D.10368 = __builtin_expect (D.10367, 0);
      if (D.10368 != 0) goto <D.10369>; else goto <D.10370>;
      <D.10369>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "events.c", 661, "thr_ret == 0");
      <D.10370>:
      namedevent_handle.14 = namedevent_handle;
      D.10372 = namedevent_handle.14->manual;
      if (D.10372 == 1) goto <D.10373>; else goto <D.10374>;
      <D.10373>:
      _wapi_shared_handle_set_signal_state (handle, 1);
      goto <D.10375>;
      <D.10374>:
      namedevent_handle.14 = namedevent_handle;
      namedevent_handle.14->set_count = 1;
      _wapi_shared_handle_set_signal_state (handle, 1);
      <D.10375>:
      _wapi_handle_unlock_shared_handles ();
      D.10365 = 1;
      return D.10365;
    }
  finally
    {
      namedevent_handle = {CLOBBER};
    }
}


namedevent_reset (void * handle)
{
  gboolean D.10380;
  _Bool D.10381;
  long int D.10382;
  long int D.10383;
  int D.10386;
  struct _WapiHandle_namedevent * namedevent_handle.15;
  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.10378>; else goto <D.10379>;
      <D.10378>:
      monoeg_g_log (0B, 16, "%s: error looking up named event handle %p", &__func__, handle);
      D.10380 = 0;
      return D.10380;
      <D.10379>:
      thr_ret = _wapi_handle_lock_shared_handles ();
      D.10381 = thr_ret != 0;
      D.10382 = (long int) D.10381;
      D.10383 = __builtin_expect (D.10382, 0);
      if (D.10383 != 0) goto <D.10384>; else goto <D.10385>;
      <D.10384>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "events.c", 563, "thr_ret == 0");
      <D.10385>:
      D.10386 = _wapi_handle_issignalled (handle);
      if (D.10386 == 0) goto <D.10387>; else goto <D.10388>;
      <D.10387>:
      goto <D.10389>;
      <D.10388>:
      _wapi_shared_handle_set_signal_state (handle, 0);
      <D.10389>:
      namedevent_handle.15 = namedevent_handle;
      namedevent_handle.15->set_count = 0;
      _wapi_handle_unlock_shared_handles ();
      D.10380 = 1;
      return D.10380;
    }
  finally
    {
      namedevent_handle = {CLOBBER};
    }
}


_wapi_handle_issignalled (void * handle)
{
  long int handle.16;
  gboolean D.10396;
  <unnamed type> D.10399;
  <unnamed type> D.10401;
  <unnamed type> D.10403;
  <unnamed type> D.10405;
  struct _WapiHandleSharedLayout * _wapi_shared_layout.17;
  unsigned int D.10407;
  unsigned int D.10408;
  struct _WapiHandleUnshared * D.10409;
  long unsigned int D.10410;
  long unsigned int D.10411;
  long unsigned int D.10412;
  struct _WapiHandleUnshared * D.10413;
  unsigned int D.10414;
  unsigned int D.10415;
  struct _WapiHandleUnshared * D.10416;
  long unsigned int D.10417;
  long unsigned int D.10418;
  long unsigned int D.10419;
  struct _WapiHandleUnshared * D.10420;
  guint32 idx;

  handle.16 = (long int) handle;
  idx = (guint32) handle.16;
  if (idx > 4194303) goto <D.10394>; else goto <D.10395>;
  <D.10394>:
  D.10396 = 0;
  return D.10396;
  <D.10395>:
  D.10399 = _wapi_handle_type (handle);
  if (D.10399 == 9) goto <D.10397>; else goto <D.10400>;
  <D.10400>:
  D.10401 = _wapi_handle_type (handle);
  if (D.10401 == 11) goto <D.10397>; else goto <D.10402>;
  <D.10402>:
  D.10403 = _wapi_handle_type (handle);
  if (D.10403 == 12) goto <D.10397>; else goto <D.10404>;
  <D.10404>:
  D.10405 = _wapi_handle_type (handle);
  if (D.10405 == 13) goto <D.10397>; else goto <D.10398>;
  <D.10397>:
  _wapi_shared_layout.17 = _wapi_shared_layout;
  handle.16 = (long int) handle;
  D.10407 = (unsigned int) handle.16;
  D.10408 = D.10407 / 256;
  D.10409 = _wapi_private_handles[D.10408];
  handle.16 = (long int) handle;
  D.10407 = (unsigned int) handle.16;
  D.10410 = (long unsigned int) D.10407;
  D.10411 = D.10410 & 255;
  D.10412 = D.10411 * 200;
  D.10413 = D.10409 + D.10412;
  D.10414 = D.10413->u.shared.offset;
  D.10396 = _wapi_shared_layout.17->handles[D.10414].signalled;
  return D.10396;
  <D.10398>:
  D.10415 = idx / 256;
  D.10416 = _wapi_private_handles[D.10415];
  D.10417 = (long unsigned int) idx;
  D.10418 = D.10417 & 255;
  D.10419 = D.10418 * 200;
  D.10420 = D.10416 + D.10419;
  D.10396 = D.10420->signalled;
  return D.10396;
}


namedevent_pulse (void * handle)
{
  gboolean D.10424;
  _Bool D.10425;
  long int D.10426;
  long int D.10427;
  struct _WapiHandle_namedevent * namedevent_handle.18;
  int D.10431;
  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.10422>; else goto <D.10423>;
      <D.10422>:
      monoeg_g_log (0B, 16, "%s: error looking up named event handle %p", &__func__, handle);
      D.10424 = 0;
      return D.10424;
      <D.10423>:
      thr_ret = _wapi_handle_lock_shared_handles ();
      D.10425 = thr_ret != 0;
      D.10426 = (long int) D.10425;
      D.10427 = __builtin_expect (D.10426, 0);
      if (D.10427 != 0) goto <D.10428>; else goto <D.10429>;
      <D.10428>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "events.c", 431, "thr_ret == 0");
      <D.10429>:
      namedevent_handle.18 = namedevent_handle;
      D.10431 = namedevent_handle.18->manual;
      if (D.10431 == 1) goto <D.10432>; else goto <D.10433>;
      <D.10432>:
      _wapi_shared_handle_set_signal_state (handle, 1);
      goto <D.10434>;
      <D.10433>:
      namedevent_handle.18 = namedevent_handle;
      namedevent_handle.18->set_count = 1;
      _wapi_shared_handle_set_signal_state (handle, 1);
      <D.10434>:
      _wapi_handle_unlock_shared_handles ();
      namedevent_handle.18 = namedevent_handle;
      D.10431 = namedevent_handle.18->manual;
      if (D.10431 == 1) goto <D.10435>; else goto <D.10436>;
      <D.10435>:
      _wapi_handle_spin (200);
      thr_ret = _wapi_handle_lock_shared_handles ();
      D.10425 = thr_ret != 0;
      D.10426 = (long int) D.10425;
      D.10427 = __builtin_expect (D.10426, 0);
      if (D.10427 != 0) goto <D.10437>; else goto <D.10438>;
      <D.10437>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "events.c", 461, "thr_ret == 0");
      <D.10438>:
      _wapi_shared_handle_set_signal_state (handle, 0);
      _wapi_handle_unlock_shared_handles ();
      <D.10436>:
      D.10424 = 1;
      return D.10424;
    }
  finally
    {
      namedevent_handle = {CLOBBER};
    }
}


_wapi_handle_spin (guint32 ms)
{
  _Bool D.10441;
  long int D.10442;
  long int D.10443;
  unsigned int D.10446;
  long int D.10447;
  struct timespec sleepytime;

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


event_set (void * handle)
{
  gboolean D.10450;
  long int D.10451;
  long int D.10452;
  _Bool D.10455;
  long int D.10456;
  long int D.10457;
  struct _WapiHandle_event * event_handle.19;
  int D.10461;
  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.10448>; else goto <D.10449>;
      <D.10448>:
      monoeg_g_log (0B, 16, "%s: error looking up event handle %p", &__func__, handle);
      D.10450 = 0;
      return D.10450;
      <D.10449>:
      {
        struct __pthread_unwind_buf_t __cancel_buf;
        void (*<Tbf>) (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.10451 = (long int) __not_first_call;
            D.10452 = __builtin_expect (D.10451, 0);
            if (D.10452 != 0) goto <D.10453>; else goto <D.10454>;
            <D.10453>:
            __cancel_routine (__cancel_arg);
            __pthread_unwind_next (&__cancel_buf);
            <D.10454>:
            __pthread_register_cancel (&__cancel_buf);
            thr_ret = _wapi_handle_lock_handle (handle);
            D.10455 = thr_ret != 0;
            D.10456 = (long int) D.10455;
            D.10457 = __builtin_expect (D.10456, 0);
            if (D.10457 != 0) goto <D.10458>; else goto <D.10459>;
            <D.10458>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "events.c", 627, "thr_ret == 0");
            <D.10459>:
            event_handle.19 = event_handle;
            D.10461 = event_handle.19->manual;
            if (D.10461 == 1) goto <D.10462>; else goto <D.10463>;
            <D.10462>:
            _wapi_handle_set_signal_state (handle, 1, 1);
            goto <D.10464>;
            <D.10463>:
            event_handle.19 = event_handle;
            event_handle.19->set_count = 1;
            _wapi_handle_set_signal_state (handle, 1, 0);
            <D.10464>:
            thr_ret = _wapi_handle_unlock_handle (handle);
            D.10455 = thr_ret != 0;
            D.10456 = (long int) D.10455;
            D.10457 = __builtin_expect (D.10456, 0);
            if (D.10457 != 0) goto <D.10465>; else goto <D.10466>;
            <D.10465>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "events.c", 639, "thr_ret == 0");
            <D.10466>:
            __pthread_unregister_cancel (&__cancel_buf);
            if (0 != 0) goto <D.10467>; else goto <D.10468>;
            <D.10467>:
            __cancel_routine (__cancel_arg);
            <D.10468>:
          }
        finally
          {
            __cancel_buf = {CLOBBER};
          }
      }
      D.10450 = 1;
      return D.10450;
    }
  finally
    {
      event_handle = {CLOBBER};
    }
}


event_reset (void * handle)
{
  gboolean D.10476;
  long int D.10477;
  long int D.10478;
  _Bool D.10481;
  long int D.10482;
  long int D.10483;
  int D.10486;
  struct _WapiHandle_event * event_handle.20;
  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.10474>; else goto <D.10475>;
      <D.10474>:
      monoeg_g_log (0B, 16, "%s: error looking up event handle %p", &__func__, handle);
      D.10476 = 0;
      return D.10476;
      <D.10475>:
      {
        struct __pthread_unwind_buf_t __cancel_buf;
        void (*<Tbf>) (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.10477 = (long int) __not_first_call;
            D.10478 = __builtin_expect (D.10477, 0);
            if (D.10478 != 0) goto <D.10479>; else goto <D.10480>;
            <D.10479>:
            __cancel_routine (__cancel_arg);
            __pthread_unwind_next (&__cancel_buf);
            <D.10480>:
            __pthread_register_cancel (&__cancel_buf);
            thr_ret = _wapi_handle_lock_handle (handle);
            D.10481 = thr_ret != 0;
            D.10482 = (long int) D.10481;
            D.10483 = __builtin_expect (D.10482, 0);
            if (D.10483 != 0) goto <D.10484>; else goto <D.10485>;
            <D.10484>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "events.c", 524, "thr_ret == 0");
            <D.10485>:
            D.10486 = _wapi_handle_issignalled (handle);
            if (D.10486 == 0) goto <D.10487>; else goto <D.10488>;
            <D.10487>:
            goto <D.10489>;
            <D.10488>:
            _wapi_handle_set_signal_state (handle, 0, 0);
            <D.10489>:
            event_handle.20 = event_handle;
            event_handle.20->set_count = 0;
            thr_ret = _wapi_handle_unlock_handle (handle);
            D.10481 = thr_ret != 0;
            D.10482 = (long int) D.10481;
            D.10483 = __builtin_expect (D.10482, 0);
            if (D.10483 != 0) goto <D.10491>; else goto <D.10492>;
            <D.10491>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "events.c", 539, "thr_ret == 0");
            <D.10492>:
            __pthread_unregister_cancel (&__cancel_buf);
            if (0 != 0) goto <D.10493>; else goto <D.10494>;
            <D.10493>:
            __cancel_routine (__cancel_arg);
            <D.10494>:
          }
        finally
          {
            __cancel_buf = {CLOBBER};
          }
      }
      D.10476 = 1;
      return D.10476;
    }
  finally
    {
      event_handle = {CLOBBER};
    }
}


event_pulse (void * handle)
{
  gboolean D.10503;
  long int D.10504;
  long int D.10505;
  _Bool D.10508;
  long int D.10509;
  long int D.10510;
  struct _WapiHandle_event * event_handle.21;
  int D.10514;
  long int D.10524;
  long int D.10525;
  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.10501>; else goto <D.10502>;
      <D.10501>:
      monoeg_g_log (0B, 16, "%s: error looking up event handle %p", &__func__, handle);
      D.10503 = 0;
      return D.10503;
      <D.10502>:
      {
        struct __pthread_unwind_buf_t __cancel_buf;
        void (*<Tbf>) (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.10504 = (long int) __not_first_call;
            D.10505 = __builtin_expect (D.10504, 0);
            if (D.10505 != 0) goto <D.10506>; else goto <D.10507>;
            <D.10506>:
            __cancel_routine (__cancel_arg);
            __pthread_unwind_next (&__cancel_buf);
            <D.10507>:
            __pthread_register_cancel (&__cancel_buf);
            thr_ret = _wapi_handle_lock_handle (handle);
            D.10508 = thr_ret != 0;
            D.10509 = (long int) D.10508;
            D.10510 = __builtin_expect (D.10509, 0);
            if (D.10510 != 0) goto <D.10511>; else goto <D.10512>;
            <D.10511>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "events.c", 370, "thr_ret == 0");
            <D.10512>:
            event_handle.21 = event_handle;
            D.10514 = event_handle.21->manual;
            if (D.10514 == 1) goto <D.10515>; else goto <D.10516>;
            <D.10515>:
            _wapi_handle_set_signal_state (handle, 1, 1);
            goto <D.10517>;
            <D.10516>:
            event_handle.21 = event_handle;
            event_handle.21->set_count = 1;
            _wapi_handle_set_signal_state (handle, 1, 0);
            <D.10517>:
            thr_ret = _wapi_handle_unlock_handle (handle);
            D.10508 = thr_ret != 0;
            D.10509 = (long int) D.10508;
            D.10510 = __builtin_expect (D.10509, 0);
            if (D.10510 != 0) goto <D.10518>; else goto <D.10519>;
            <D.10518>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "events.c", 382, "thr_ret == 0");
            <D.10519>:
            __pthread_unregister_cancel (&__cancel_buf);
            if (0 != 0) goto <D.10520>; else goto <D.10521>;
            <D.10520>:
            __cancel_routine (__cancel_arg);
            <D.10521>:
          }
        finally
          {
            __cancel_buf = {CLOBBER};
          }
      }
      event_handle.21 = event_handle;
      D.10514 = event_handle.21->manual;
      if (D.10514 == 1) goto <D.10522>; else goto <D.10523>;
      <D.10522>:
      sched_yield ();
      {
        struct __pthread_unwind_buf_t __cancel_buf;
        void (*<Tbf>) (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.10524 = (long int) __not_first_call;
            D.10525 = __builtin_expect (D.10524, 0);
            if (D.10525 != 0) goto <D.10526>; else goto <D.10527>;
            <D.10526>:
            __cancel_routine (__cancel_arg);
            __pthread_unwind_next (&__cancel_buf);
            <D.10527>:
            __pthread_register_cancel (&__cancel_buf);
            thr_ret = _wapi_handle_lock_handle (handle);
            D.10508 = thr_ret != 0;
            D.10509 = (long int) D.10508;
            D.10510 = __builtin_expect (D.10509, 0);
            if (D.10510 != 0) goto <D.10528>; else goto <D.10529>;
            <D.10528>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "events.c", 404, "thr_ret == 0");
            <D.10529>:
            _wapi_handle_set_signal_state (handle, 0, 0);
            thr_ret = _wapi_handle_unlock_handle (handle);
            D.10508 = thr_ret != 0;
            D.10509 = (long int) D.10508;
            D.10510 = __builtin_expect (D.10509, 0);
            if (D.10510 != 0) goto <D.10530>; else goto <D.10531>;
            <D.10530>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "events.c", 409, "thr_ret == 0");
            <D.10531>:
            __pthread_unregister_cancel (&__cancel_buf);
            if (0 != 0) goto <D.10532>; else goto <D.10533>;
            <D.10532>:
            __cancel_routine (__cancel_arg);
            <D.10533>:
          }
        finally
          {
            __cancel_buf = {CLOBBER};
          }
      }
      <D.10523>:
      D.10503 = 1;
      return D.10503;
    }
  finally
    {
      event_handle = {CLOBBER};
    }
}


ResetEvent (void * handle)
{
  gboolean D.10543;
  gboolean (*<T1399>) (void *) D.10544;
  WapiHandleType type;

  if (handle == 0B) goto <D.10541>; else goto <D.10542>;
  <D.10541>:
  SetLastError (6);
  D.10543 = 0;
  return D.10543;
  <D.10542>:
  type = _wapi_handle_type (handle);
  D.10544 = event_ops[type].reset;
  if (D.10544 == 0B) goto <D.10545>; else goto <D.10546>;
  <D.10545>:
  SetLastError (6);
  D.10543 = 0;
  return D.10543;
  <D.10546>:
  D.10544 = event_ops[type].reset;
  D.10543 = D.10544 (handle);
  return D.10543;
}


SetEvent (void * handle)
{
  gboolean D.10550;
  gboolean (*<T1399>) (void *) D.10551;
  WapiHandleType type;

  if (handle == 0B) goto <D.10548>; else goto <D.10549>;
  <D.10548>:
  SetLastError (6);
  D.10550 = 0;
  return D.10550;
  <D.10549>:
  type = _wapi_handle_type (handle);
  D.10551 = event_ops[type].set;
  if (D.10551 == 0B) goto <D.10552>; else goto <D.10553>;
  <D.10552>:
  SetLastError (6);
  D.10550 = 0;
  return D.10550;
  <D.10553>:
  D.10551 = event_ops[type].set;
  D.10550 = D.10551 (handle);
  return D.10550;
}


OpenEvent (guint32 access, gboolean inherit, const gunichar2 * name)
{
  _Bool D.10555;
  long int D.10556;
  long int D.10557;
  unsigned int offset.22;
  void * D.10567;
  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.10555 = thr_ret != 0;
  D.10556 = (long int) D.10555;
  D.10557 = __builtin_expect (D.10556, 0);
  if (D.10557 != 0) goto <D.10558>; else goto <D.10559>;
  <D.10558>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "events.c", 724, "thr_ret == 0");
  <D.10559>:
  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.10560>; else goto <D.10561>;
  <D.10560>:
  SetLastError (6);
  goto cleanup;
  <D.10561>:
  if (offset == 0) goto <D.10562>; else goto <D.10563>;
  <D.10562>:
  SetLastError (2);
  goto cleanup;
  <D.10563>:
  offset.22 = (unsigned int) offset;
  handle = _wapi_handle_new_from_offset (13, offset.22, 1);
  if (handle == -1B) goto <D.10565>; else goto <D.10566>;
  <D.10565>:
  monoeg_g_log (0B, 16, "%s: error opening named event handle", &__func__);
  SetLastError (31);
  goto cleanup;
  <D.10566>:
  ret = handle;
  cleanup:
  monoeg_g_free (utf8_name);
  _wapi_namespace_unlock (0B);
  D.10567 = ret;
  return D.10567;
}


