event_own (void * handle)
{
  gboolean D.9217;
  struct _WapiHandle_event * event_handle.0;
  int D.9219;
  unsigned int D.9222;
  _Bool D.9223;
  long int D.9224;
  long int D.9225;
  unsigned int D.9228;
  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.9215>; else goto <D.9216>;
      <D.9215>:
      monoeg_g_log (0B, 16, "%s: error looking up event handle %p", &__func__, handle);
      D.9217 = 0;
      return D.9217;
      <D.9216>:
      event_handle.0 = event_handle;
      D.9219 = event_handle.0->manual;
      if (D.9219 == 0) goto <D.9220>; else goto <D.9221>;
      <D.9220>:
      event_handle.0 = event_handle;
      D.9222 = event_handle.0->set_count;
      D.9223 = D.9222 == 0;
      D.9224 = (long int) D.9223;
      D.9225 = __builtin_expect (D.9224, 0);
      if (D.9225 != 0) goto <D.9226>; else goto <D.9227>;
      <D.9226>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "events.c", 121, "event_handle->set_count > 0");
      <D.9227>:
      event_handle.0 = event_handle;
      D.9222 = event_handle.0->set_count;
      D.9228 = D.9222 + 4294967295;
      event_handle.0->set_count = D.9228;
      D.9222 = event_handle.0->set_count;
      if (D.9222 == 0) goto <D.9229>; else goto <D.9230>;
      <D.9229>:
      _wapi_handle_set_signal_state (handle, 0, 0);
      <D.9230>:
      <D.9221>:
      D.9217 = 1;
      return D.9217;
    }
  finally
    {
      event_handle = {CLOBBER};
    }
}


_wapi_handle_set_signal_state (void * handle, gboolean state, gboolean broadcast)
{
  int iftmp.1;
  <unnamed type> D.9239;
  <unnamed type> D.9241;
  <unnamed type> D.9243;
  <unnamed type> D.9245;
  _Bool D.9246;
  long int D.9247;
  long int D.9248;
  unsigned int D.9251;
  struct _WapiHandleUnshared * D.9252;
  unsigned int D.9253;
  unsigned int D.9254;
  long int D.9257;
  union mono_mutex_t * _wapi_global_signal_mutex.2;
  _Bool D.9263;
  long int D.9264;
  long int D.9265;
  union pthread_cond_t * D.9270;
  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.9233>; else goto <D.9234>;
  <D.9233>:
  return;
  <D.9234>:
  D.9239 = _wapi_handle_type (handle);
  if (D.9239 == 9) goto <D.9236>; else goto <D.9240>;
  <D.9240>:
  D.9241 = _wapi_handle_type (handle);
  if (D.9241 == 11) goto <D.9236>; else goto <D.9242>;
  <D.9242>:
  D.9243 = _wapi_handle_type (handle);
  if (D.9243 == 12) goto <D.9236>; else goto <D.9244>;
  <D.9244>:
  D.9245 = _wapi_handle_type (handle);
  if (D.9245 == 13) goto <D.9236>; else goto <D.9237>;
  <D.9236>:
  iftmp.1 = 1;
  goto <D.9238>;
  <D.9237>:
  iftmp.1 = 0;
  <D.9238>:
  D.9246 = iftmp.1 != 0;
  D.9247 = (long int) D.9246;
  D.9248 = __builtin_expect (D.9247, 0);
  if (D.9248 != 0) goto <D.9249>; else goto <D.9250>;
  <D.9249>:
  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.9250>:
  D.9251 = idx / 256;
  D.9252 = _wapi_private_handles[D.9251];
  D.9253 = idx & 255;
  D.9254 = D.9253 * 136;
  handle_data = D.9252 + D.9254;
  if (state == 1) goto <D.9255>; else goto <D.9256>;
  <D.9255>:
  {
    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.9257 = __builtin_expect (__not_first_call, 0);
        if (D.9257 != 0) goto <D.9258>; else goto <D.9259>;
        <D.9258>:
        __cancel_routine (__cancel_arg);
        __pthread_unwind_next (&__cancel_buf);
        <D.9259>:
        __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.9261>; else goto <D.9262>;
        <D.9261>:
        monoeg_g_log (0B, 16, "Bad call to mono_mutex_lock result %d for global signal mutex", thr_ret);
        <D.9262>:
        D.9263 = thr_ret != 0;
        D.9264 = (long int) D.9263;
        D.9265 = __builtin_expect (D.9264, 0);
        if (D.9265 != 0) goto <D.9266>; else goto <D.9267>;
        <D.9266>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "../../mono/io-layer/handles-private.h", 151, "thr_ret == 0");
        <D.9267>:
        handle_data->signalled = state;
        if (broadcast == 1) goto <D.9268>; else goto <D.9269>;
        <D.9268>:
        D.9270 = &handle_data->signal_cond;
        thr_ret = pthread_cond_broadcast (D.9270);
        if (thr_ret != 0) goto <D.9271>; else goto <D.9272>;
        <D.9271>:
        monoeg_g_log (0B, 16, "Bad call to pthread_cond_broadcast result %d for handle %p", thr_ret, handle);
        <D.9272>:
        D.9263 = thr_ret != 0;
        D.9264 = (long int) D.9263;
        D.9265 = __builtin_expect (D.9264, 0);
        if (D.9265 != 0) goto <D.9273>; else goto <D.9274>;
        <D.9273>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "../../mono/io-layer/handles-private.h", 162, "thr_ret == 0");
        <D.9274>:
        goto <D.9275>;
        <D.9269>:
        D.9270 = &handle_data->signal_cond;
        thr_ret = pthread_cond_signal (D.9270);
        if (thr_ret != 0) goto <D.9276>; else goto <D.9277>;
        <D.9276>:
        monoeg_g_log (0B, 16, "Bad call to pthread_cond_signal result %d for handle %p", thr_ret, handle);
        <D.9277>:
        D.9263 = thr_ret != 0;
        D.9264 = (long int) D.9263;
        D.9265 = __builtin_expect (D.9264, 0);
        if (D.9265 != 0) goto <D.9278>; else goto <D.9279>;
        <D.9278>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "../../mono/io-layer/handles-private.h", 167, "thr_ret == 0");
        <D.9279>:
        <D.9275>:
        _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.9281>; else goto <D.9282>;
        <D.9281>:
        monoeg_g_log (0B, 16, "Bad call to pthread_cond_broadcast result %d for handle %p", thr_ret, handle);
        <D.9282>:
        D.9263 = thr_ret != 0;
        D.9264 = (long int) D.9263;
        D.9265 = __builtin_expect (D.9264, 0);
        if (D.9265 != 0) goto <D.9283>; else goto <D.9284>;
        <D.9283>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "../../mono/io-layer/handles-private.h", 176, "thr_ret == 0");
        <D.9284>:
        _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.9285>; else goto <D.9286>;
        <D.9285>:
        monoeg_g_log (0B, 16, "Bad call to mono_mutex_unlock result %d for global signal mutex", thr_ret);
        <D.9286>:
        D.9263 = thr_ret != 0;
        D.9264 = (long int) D.9263;
        D.9265 = __builtin_expect (D.9264, 0);
        if (D.9265 != 0) goto <D.9287>; else goto <D.9288>;
        <D.9287>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "../../mono/io-layer/handles-private.h", 181, "thr_ret == 0");
        <D.9288>:
        __pthread_unregister_cancel (&__cancel_buf);
        if (0 != 0) goto <D.9289>; else goto <D.9290>;
        <D.9289>:
        __cancel_routine (__cancel_arg);
        <D.9290>:
      }
    finally
      {
        __cancel_buf = {CLOBBER};
      }
  }
  goto <D.9291>;
  <D.9256>:
  handle_data->signalled = state;
  <D.9291>:
}


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

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


_wapi_handle_type (void * handle)
{
  unsigned int D.9307;
  struct _WapiHandleUnshared * D.9308;
  WapiHandleType D.9309;
  unsigned int D.9310;
  unsigned int D.9311;
  struct _WapiHandleUnshared * D.9312;
  guint32 idx;

  idx = (guint32) handle;
  if (idx > 4194303) goto <D.9304>; else goto <D.9306>;
  <D.9306>:
  D.9307 = idx / 256;
  D.9308 = _wapi_private_handles[D.9307];
  if (D.9308 == 0B) goto <D.9304>; else goto <D.9305>;
  <D.9304>:
  D.9309 = 0;
  return D.9309;
  <D.9305>:
  D.9307 = idx / 256;
  D.9308 = _wapi_private_handles[D.9307];
  D.9310 = idx & 255;
  D.9311 = D.9310 * 136;
  D.9312 = D.9308 + D.9311;
  D.9309 = D.9312->type;
  return D.9309;
}


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


namedevent_own (void * handle)
{
  gboolean D.9316;
  struct _WapiHandle_namedevent * namedevent_handle.4;
  int D.9318;
  unsigned int D.9321;
  _Bool D.9322;
  long int D.9323;
  long int D.9324;
  unsigned int D.9327;
  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.9314>; else goto <D.9315>;
      <D.9314>:
      monoeg_g_log (0B, 16, "%s: error looking up named event handle %p", &__func__, handle);
      D.9316 = 0;
      return D.9316;
      <D.9315>:
      namedevent_handle.4 = namedevent_handle;
      D.9318 = namedevent_handle.4->manual;
      if (D.9318 == 0) goto <D.9319>; else goto <D.9320>;
      <D.9319>:
      namedevent_handle.4 = namedevent_handle;
      D.9321 = namedevent_handle.4->set_count;
      D.9322 = D.9321 == 0;
      D.9323 = (long int) D.9322;
      D.9324 = __builtin_expect (D.9323, 0);
      if (D.9324 != 0) goto <D.9325>; else goto <D.9326>;
      <D.9325>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "events.c", 153, "namedevent_handle->set_count > 0");
      <D.9326>:
      namedevent_handle.4 = namedevent_handle;
      D.9321 = namedevent_handle.4->set_count;
      D.9327 = D.9321 + 4294967295;
      namedevent_handle.4->set_count = D.9327;
      D.9321 = namedevent_handle.4->set_count;
      if (D.9321 == 0) goto <D.9328>; else goto <D.9329>;
      <D.9328>:
      _wapi_shared_handle_set_signal_state (handle, 0);
      <D.9329>:
      <D.9320>:
      D.9316 = 1;
      return D.9316;
    }
  finally
    {
      namedevent_handle = {CLOBBER};
    }
}


_wapi_shared_handle_set_signal_state (void * handle, gboolean state)
{
  int iftmp.5;
  <unnamed type> D.9337;
  <unnamed type> D.9339;
  <unnamed type> D.9341;
  <unnamed type> D.9343;
  _Bool D.9345;
  long int D.9346;
  long int D.9347;
  unsigned int D.9350;
  struct _WapiHandleUnshared * D.9351;
  unsigned int D.9352;
  unsigned int D.9353;
  struct _WapiHandleSharedLayout * _wapi_shared_layout.6;
  unsigned int D.9355;
  guint32 idx;
  struct _WapiHandleUnshared * handle_data;
  struct _WapiHandle_shared_ref * ref;
  struct _WapiHandleShared * shared_data;

  idx = (guint32) handle;
  if (idx > 4194303) goto <D.9332>; else goto <D.9333>;
  <D.9332>:
  return;
  <D.9333>:
  D.9337 = _wapi_handle_type (handle);
  if (D.9337 != 9) goto <D.9338>; else goto <D.9335>;
  <D.9338>:
  D.9339 = _wapi_handle_type (handle);
  if (D.9339 != 11) goto <D.9340>; else goto <D.9335>;
  <D.9340>:
  D.9341 = _wapi_handle_type (handle);
  if (D.9341 != 12) goto <D.9342>; else goto <D.9335>;
  <D.9342>:
  D.9343 = _wapi_handle_type (handle);
  if (D.9343 != 13) goto <D.9344>; else goto <D.9335>;
  <D.9344>:
  iftmp.5 = 1;
  goto <D.9336>;
  <D.9335>:
  iftmp.5 = 0;
  <D.9336>:
  D.9345 = iftmp.5 != 0;
  D.9346 = (long int) D.9345;
  D.9347 = __builtin_expect (D.9346, 0);
  if (D.9347 != 0) goto <D.9348>; else goto <D.9349>;
  <D.9348>:
  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.9349>:
  D.9350 = idx / 256;
  D.9351 = _wapi_private_handles[D.9350];
  D.9352 = idx & 255;
  D.9353 = D.9352 * 136;
  handle_data = D.9351 + D.9353;
  ref = &handle_data->u.shared;
  _wapi_shared_layout.6 = _wapi_shared_layout;
  D.9355 = ref->offset;
  shared_data = &_wapi_shared_layout.6->handles[D.9355];
  shared_data->signalled = state;
}


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


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

  event = handle_info;
  D.9358 = event->manual;
  if (D.9358 != 0) goto <D.9359>; else goto <D.9360>;
  <D.9359>:
  iftmp.7 = "TRUE";
  goto <D.9361>;
  <D.9360>:
  iftmp.7 = "FALSE";
  <D.9361>:
  monoeg_g_print ("manual: %s", iftmp.7);
}


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

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


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.9372;
  long int D.9373;
  _Bool D.9376;
  long int D.9377;
  long int D.9378;
  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.9366>; else goto <D.9367>;
      <D.9366>:
      if (manual == 0) goto <D.9368>; else goto <D.9369>;
      <D.9368>:
      event_handle.set_count = 1;
      <D.9369>:
      <D.9367>:
      handle = _wapi_handle_new (6, &event_handle);
      if (handle == 4294967295B) goto <D.9370>; else goto <D.9371>;
      <D.9370>:
      monoeg_g_log (0B, 16, "%s: error creating event handle", &__func__);
      SetLastError (31);
      D.9372 = 0B;
      return D.9372;
      <D.9371>:
      {
        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.9373 = __builtin_expect (__not_first_call, 0);
            if (D.9373 != 0) goto <D.9374>; else goto <D.9375>;
            <D.9374>:
            __cancel_routine (__cancel_arg);
            __pthread_unwind_next (&__cancel_buf);
            <D.9375>:
            __pthread_register_cancel (&__cancel_buf);
            thr_ret = _wapi_handle_lock_handle (handle);
            D.9376 = thr_ret != 0;
            D.9377 = (long int) D.9376;
            D.9378 = __builtin_expect (D.9377, 0);
            if (D.9378 != 0) goto <D.9379>; else goto <D.9380>;
            <D.9379>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "events.c", 196, "thr_ret == 0");
            <D.9380>:
            if (initial == 1) goto <D.9381>; else goto <D.9382>;
            <D.9381>:
            _wapi_handle_set_signal_state (handle, 1, 0);
            <D.9382>:
            thr_ret = _wapi_handle_unlock_handle (handle);
            D.9376 = thr_ret != 0;
            D.9377 = (long int) D.9376;
            D.9378 = __builtin_expect (D.9377, 0);
            if (D.9378 != 0) goto <D.9383>; else goto <D.9384>;
            <D.9383>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "events.c", 205, "thr_ret == 0");
            <D.9384>:
            __pthread_unregister_cancel (&__cancel_buf);
            if (0 != 0) goto <D.9385>; else goto <D.9386>;
            <D.9385>:
            __cancel_routine (__cancel_arg);
            <D.9386>:
          }
        finally
          {
            __cancel_buf = {CLOBBER};
          }
      }
      D.9372 = handle;
      return D.9372;
    }
  finally
    {
      event_handle = {CLOBBER};
    }
}


_wapi_handle_lock_handle (void * handle)
{
  int D.9394;
  <unnamed type> D.9397;
  <unnamed type> D.9399;
  <unnamed type> D.9401;
  <unnamed type> D.9403;
  unsigned int D.9404;
  struct _WapiHandleUnshared * D.9405;
  unsigned int D.9406;
  unsigned int D.9407;
  struct _WapiHandleUnshared * D.9408;
  union mono_mutex_t * D.9409;
  guint32 idx;

  idx = (guint32) handle;
  if (idx > 4194303) goto <D.9392>; else goto <D.9393>;
  <D.9392>:
  D.9394 = 0;
  return D.9394;
  <D.9393>:
  _wapi_handle_ref (handle);
  D.9397 = _wapi_handle_type (handle);
  if (D.9397 == 9) goto <D.9395>; else goto <D.9398>;
  <D.9398>:
  D.9399 = _wapi_handle_type (handle);
  if (D.9399 == 11) goto <D.9395>; else goto <D.9400>;
  <D.9400>:
  D.9401 = _wapi_handle_type (handle);
  if (D.9401 == 12) goto <D.9395>; else goto <D.9402>;
  <D.9402>:
  D.9403 = _wapi_handle_type (handle);
  if (D.9403 == 13) goto <D.9395>; else goto <D.9396>;
  <D.9395>:
  D.9394 = 0;
  return D.9394;
  <D.9396>:
  D.9404 = idx / 256;
  D.9405 = _wapi_private_handles[D.9404];
  D.9406 = idx & 255;
  D.9407 = D.9406 * 136;
  D.9408 = D.9405 + D.9407;
  D.9409 = &D.9408->signal_mutex;
  D.9394 = pthread_mutex_lock (D.9409);
  return D.9394;
}


_wapi_handle_unlock_handle (void * handle)
{
  int D.9413;
  <unnamed type> D.9416;
  <unnamed type> D.9418;
  <unnamed type> D.9420;
  <unnamed type> D.9422;
  unsigned int D.9423;
  struct _WapiHandleUnshared * D.9424;
  unsigned int D.9425;
  unsigned int D.9426;
  struct _WapiHandleUnshared * D.9427;
  union mono_mutex_t * D.9428;
  guint32 idx;
  int ret;

  idx = (guint32) handle;
  if (idx > 4194303) goto <D.9411>; else goto <D.9412>;
  <D.9411>:
  D.9413 = 0;
  return D.9413;
  <D.9412>:
  D.9416 = _wapi_handle_type (handle);
  if (D.9416 == 9) goto <D.9414>; else goto <D.9417>;
  <D.9417>:
  D.9418 = _wapi_handle_type (handle);
  if (D.9418 == 11) goto <D.9414>; else goto <D.9419>;
  <D.9419>:
  D.9420 = _wapi_handle_type (handle);
  if (D.9420 == 12) goto <D.9414>; else goto <D.9421>;
  <D.9421>:
  D.9422 = _wapi_handle_type (handle);
  if (D.9422 == 13) goto <D.9414>; else goto <D.9415>;
  <D.9414>:
  _wapi_handle_unref (handle);
  D.9413 = 0;
  return D.9413;
  <D.9415>:
  D.9423 = idx / 256;
  D.9424 = _wapi_private_handles[D.9423];
  D.9425 = idx & 255;
  D.9426 = D.9425 * 136;
  D.9427 = D.9424 + D.9426;
  D.9428 = &D.9427->signal_mutex;
  ret = pthread_mutex_unlock (D.9428);
  _wapi_handle_unref (handle);
  D.9413 = ret;
  return D.9413;
}


namedevent_create (struct WapiSecurityAttributes * security, gboolean manual, gboolean initial, const gunichar2 * name)
{
  _Bool D.9430;
  long int D.9431;
  long int D.9432;
  unsigned int D.9441;
  unsigned int offset.8;
  void * D.9459;
  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.9430 = thr_ret != 0;
      D.9431 = (long int) D.9430;
      D.9432 = __builtin_expect (D.9431, 0);
      if (D.9432 != 0) goto <D.9433>; else goto <D.9434>;
      <D.9433>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "events.c", 227, "thr_ret == 0");
      <D.9434>:
      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.9435>; else goto <D.9436>;
      <D.9435>:
      SetLastError (6);
      goto cleanup;
      <D.9436>:
      if (offset != 0) goto <D.9437>; else goto <D.9438>;
      <D.9437>:
      SetLastError (183);
      <D.9438>:
      if (offset == 0) goto <D.9439>; else goto <D.9440>;
      <D.9439>:
      D.9441 = strlen (utf8_name);
      if (D.9441 <= 259) goto <D.9442>; else goto <D.9443>;
      <D.9442>:
      namelen = strlen (utf8_name);
      goto <D.9444>;
      <D.9443>:
      namelen = 260;
      <D.9444>:
      memcpy (&namedevent_handle.sharedns.name, utf8_name, namelen);
      namedevent_handle.manual = manual;
      namedevent_handle.set_count = 0;
      if (initial == 1) goto <D.9445>; else goto <D.9446>;
      <D.9445>:
      if (manual == 0) goto <D.9447>; else goto <D.9448>;
      <D.9447>:
      namedevent_handle.set_count = 1;
      <D.9448>:
      <D.9446>:
      handle = _wapi_handle_new (13, &namedevent_handle);
      goto <D.9449>;
      <D.9440>:
      offset.8 = (unsigned int) offset;
      handle = _wapi_handle_new_from_offset (13, offset.8, 1);
      <D.9449>:
      if (handle == 4294967295B) goto <D.9451>; else goto <D.9452>;
      <D.9451>:
      monoeg_g_log (0B, 16, "%s: error creating event handle", &__func__);
      SetLastError (31);
      goto cleanup;
      <D.9452>:
      ret = handle;
      if (offset == 0) goto <D.9453>; else goto <D.9454>;
      <D.9453>:
      thr_ret = _wapi_handle_lock_shared_handles ();
      D.9430 = thr_ret != 0;
      D.9431 = (long int) D.9430;
      D.9432 = __builtin_expect (D.9431, 0);
      if (D.9432 != 0) goto <D.9455>; else goto <D.9456>;
      <D.9455>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "events.c", 299, "thr_ret == 0");
      <D.9456>:
      if (initial == 1) goto <D.9457>; else goto <D.9458>;
      <D.9457>:
      _wapi_shared_handle_set_signal_state (handle, 1);
      <D.9458>:
      _wapi_handle_unlock_shared_handles ();
      <D.9454>:
      cleanup:
      monoeg_g_free (utf8_name);
      _wapi_namespace_unlock (0B);
      D.9459 = ret;
      return D.9459;
    }
  finally
    {
      namedevent_handle = {CLOBBER};
    }
}


_wapi_namespace_lock ()
{
  int D.9462;

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


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

  D.9465 = __builtin_object_size (__dest, 0);
  D.9464 = __builtin___memcpy_chk (__dest, __src, __len, D.9465);
  return D.9464;
}


_wapi_handle_lock_shared_handles ()
{
  int D.9467;

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


_wapi_handle_unlock_shared_handles ()
{
  int D.9469;

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


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

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


PulseEvent (void * handle)
{
  gboolean D.9475;
  gboolean (*<T12cb>) (void *) D.9476;
  WapiHandleType type;

  if (handle == 0B) goto <D.9473>; else goto <D.9474>;
  <D.9473>:
  SetLastError (6);
  D.9475 = 0;
  return D.9475;
  <D.9474>:
  type = _wapi_handle_type (handle);
  D.9476 = event_ops[type].pulse;
  if (D.9476 == 0B) goto <D.9477>; else goto <D.9478>;
  <D.9477>:
  SetLastError (6);
  D.9475 = 0;
  return D.9475;
  <D.9478>:
  D.9476 = event_ops[type].pulse;
  D.9475 = D.9476 (handle);
  return D.9475;
}


namedevent_set (void * handle)
{
  gboolean D.9482;
  _Bool D.9483;
  long int D.9484;
  long int D.9485;
  struct _WapiHandle_namedevent * namedevent_handle.9;
  int D.9489;
  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.9480>; else goto <D.9481>;
      <D.9480>:
      monoeg_g_log (0B, 16, "%s: error looking up named event handle %p", &__func__, handle);
      D.9482 = 0;
      return D.9482;
      <D.9481>:
      thr_ret = _wapi_handle_lock_shared_handles ();
      D.9483 = thr_ret != 0;
      D.9484 = (long int) D.9483;
      D.9485 = __builtin_expect (D.9484, 0);
      if (D.9485 != 0) goto <D.9486>; else goto <D.9487>;
      <D.9486>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "events.c", 661, "thr_ret == 0");
      <D.9487>:
      namedevent_handle.9 = namedevent_handle;
      D.9489 = namedevent_handle.9->manual;
      if (D.9489 == 1) goto <D.9490>; else goto <D.9491>;
      <D.9490>:
      _wapi_shared_handle_set_signal_state (handle, 1);
      goto <D.9492>;
      <D.9491>:
      namedevent_handle.9 = namedevent_handle;
      namedevent_handle.9->set_count = 1;
      _wapi_shared_handle_set_signal_state (handle, 1);
      <D.9492>:
      _wapi_handle_unlock_shared_handles ();
      D.9482 = 1;
      return D.9482;
    }
  finally
    {
      namedevent_handle = {CLOBBER};
    }
}


namedevent_reset (void * handle)
{
  gboolean D.9497;
  _Bool D.9498;
  long int D.9499;
  long int D.9500;
  int D.9503;
  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.9495>; else goto <D.9496>;
      <D.9495>:
      monoeg_g_log (0B, 16, "%s: error looking up named event handle %p", &__func__, handle);
      D.9497 = 0;
      return D.9497;
      <D.9496>:
      thr_ret = _wapi_handle_lock_shared_handles ();
      D.9498 = thr_ret != 0;
      D.9499 = (long int) D.9498;
      D.9500 = __builtin_expect (D.9499, 0);
      if (D.9500 != 0) goto <D.9501>; else goto <D.9502>;
      <D.9501>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "events.c", 563, "thr_ret == 0");
      <D.9502>:
      D.9503 = _wapi_handle_issignalled (handle);
      if (D.9503 == 0) goto <D.9504>; else goto <D.9505>;
      <D.9504>:
      goto <D.9506>;
      <D.9505>:
      _wapi_shared_handle_set_signal_state (handle, 0);
      <D.9506>:
      namedevent_handle.10 = namedevent_handle;
      namedevent_handle.10->set_count = 0;
      _wapi_handle_unlock_shared_handles ();
      D.9497 = 1;
      return D.9497;
    }
  finally
    {
      namedevent_handle = {CLOBBER};
    }
}


_wapi_handle_issignalled (void * handle)
{
  gboolean D.9512;
  <unnamed type> D.9515;
  <unnamed type> D.9517;
  <unnamed type> D.9519;
  <unnamed type> D.9521;
  struct _WapiHandleSharedLayout * _wapi_shared_layout.11;
  unsigned int handle.12;
  unsigned int D.9524;
  struct _WapiHandleUnshared * D.9525;
  unsigned int D.9526;
  unsigned int D.9527;
  struct _WapiHandleUnshared * D.9528;
  unsigned int D.9529;
  unsigned int D.9530;
  struct _WapiHandleUnshared * D.9531;
  unsigned int D.9532;
  unsigned int D.9533;
  struct _WapiHandleUnshared * D.9534;
  guint32 idx;

  idx = (guint32) handle;
  if (idx > 4194303) goto <D.9510>; else goto <D.9511>;
  <D.9510>:
  D.9512 = 0;
  return D.9512;
  <D.9511>:
  D.9515 = _wapi_handle_type (handle);
  if (D.9515 == 9) goto <D.9513>; else goto <D.9516>;
  <D.9516>:
  D.9517 = _wapi_handle_type (handle);
  if (D.9517 == 11) goto <D.9513>; else goto <D.9518>;
  <D.9518>:
  D.9519 = _wapi_handle_type (handle);
  if (D.9519 == 12) goto <D.9513>; else goto <D.9520>;
  <D.9520>:
  D.9521 = _wapi_handle_type (handle);
  if (D.9521 == 13) goto <D.9513>; else goto <D.9514>;
  <D.9513>:
  _wapi_shared_layout.11 = _wapi_shared_layout;
  handle.12 = (unsigned int) handle;
  D.9524 = handle.12 / 256;
  D.9525 = _wapi_private_handles[D.9524];
  handle.12 = (unsigned int) handle;
  D.9526 = handle.12 & 255;
  D.9527 = D.9526 * 136;
  D.9528 = D.9525 + D.9527;
  D.9529 = D.9528->u.shared.offset;
  D.9512 = _wapi_shared_layout.11->handles[D.9529].signalled;
  return D.9512;
  <D.9514>:
  D.9530 = idx / 256;
  D.9531 = _wapi_private_handles[D.9530];
  D.9532 = idx & 255;
  D.9533 = D.9532 * 136;
  D.9534 = D.9531 + D.9533;
  D.9512 = D.9534->signalled;
  return D.9512;
}


namedevent_pulse (void * handle)
{
  gboolean D.9538;
  _Bool D.9539;
  long int D.9540;
  long int D.9541;
  struct _WapiHandle_namedevent * namedevent_handle.13;
  int D.9545;
  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.9536>; else goto <D.9537>;
      <D.9536>:
      monoeg_g_log (0B, 16, "%s: error looking up named event handle %p", &__func__, handle);
      D.9538 = 0;
      return D.9538;
      <D.9537>:
      thr_ret = _wapi_handle_lock_shared_handles ();
      D.9539 = thr_ret != 0;
      D.9540 = (long int) D.9539;
      D.9541 = __builtin_expect (D.9540, 0);
      if (D.9541 != 0) goto <D.9542>; else goto <D.9543>;
      <D.9542>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "events.c", 431, "thr_ret == 0");
      <D.9543>:
      namedevent_handle.13 = namedevent_handle;
      D.9545 = namedevent_handle.13->manual;
      if (D.9545 == 1) goto <D.9546>; else goto <D.9547>;
      <D.9546>:
      _wapi_shared_handle_set_signal_state (handle, 1);
      goto <D.9548>;
      <D.9547>:
      namedevent_handle.13 = namedevent_handle;
      namedevent_handle.13->set_count = 1;
      _wapi_shared_handle_set_signal_state (handle, 1);
      <D.9548>:
      _wapi_handle_unlock_shared_handles ();
      namedevent_handle.13 = namedevent_handle;
      D.9545 = namedevent_handle.13->manual;
      if (D.9545 == 1) goto <D.9549>; else goto <D.9550>;
      <D.9549>:
      _wapi_handle_spin (200);
      thr_ret = _wapi_handle_lock_shared_handles ();
      D.9539 = thr_ret != 0;
      D.9540 = (long int) D.9539;
      D.9541 = __builtin_expect (D.9540, 0);
      if (D.9541 != 0) goto <D.9551>; else goto <D.9552>;
      <D.9551>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "events.c", 461, "thr_ret == 0");
      <D.9552>:
      _wapi_shared_handle_set_signal_state (handle, 0);
      _wapi_handle_unlock_shared_handles ();
      <D.9550>:
      D.9538 = 1;
      return D.9538;
    }
  finally
    {
      namedevent_handle = {CLOBBER};
    }
}


_wapi_handle_spin (guint32 ms)
{
  _Bool D.9555;
  long int D.9556;
  long int D.9557;
  unsigned int D.9560;
  long int D.9561;
  struct timespec sleepytime;

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


event_set (void * handle)
{
  gboolean D.9564;
  long int D.9565;
  _Bool D.9568;
  long int D.9569;
  long int D.9570;
  struct _WapiHandle_event * event_handle.14;
  int D.9574;
  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.9562>; else goto <D.9563>;
      <D.9562>:
      monoeg_g_log (0B, 16, "%s: error looking up event handle %p", &__func__, handle);
      D.9564 = 0;
      return D.9564;
      <D.9563>:
      {
        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.9565 = __builtin_expect (__not_first_call, 0);
            if (D.9565 != 0) goto <D.9566>; else goto <D.9567>;
            <D.9566>:
            __cancel_routine (__cancel_arg);
            __pthread_unwind_next (&__cancel_buf);
            <D.9567>:
            __pthread_register_cancel (&__cancel_buf);
            thr_ret = _wapi_handle_lock_handle (handle);
            D.9568 = thr_ret != 0;
            D.9569 = (long int) D.9568;
            D.9570 = __builtin_expect (D.9569, 0);
            if (D.9570 != 0) goto <D.9571>; else goto <D.9572>;
            <D.9571>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "events.c", 627, "thr_ret == 0");
            <D.9572>:
            event_handle.14 = event_handle;
            D.9574 = event_handle.14->manual;
            if (D.9574 == 1) goto <D.9575>; else goto <D.9576>;
            <D.9575>:
            _wapi_handle_set_signal_state (handle, 1, 1);
            goto <D.9577>;
            <D.9576>:
            event_handle.14 = event_handle;
            event_handle.14->set_count = 1;
            _wapi_handle_set_signal_state (handle, 1, 0);
            <D.9577>:
            thr_ret = _wapi_handle_unlock_handle (handle);
            D.9568 = thr_ret != 0;
            D.9569 = (long int) D.9568;
            D.9570 = __builtin_expect (D.9569, 0);
            if (D.9570 != 0) goto <D.9578>; else goto <D.9579>;
            <D.9578>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "events.c", 639, "thr_ret == 0");
            <D.9579>:
            __pthread_unregister_cancel (&__cancel_buf);
            if (0 != 0) goto <D.9580>; else goto <D.9581>;
            <D.9580>:
            __cancel_routine (__cancel_arg);
            <D.9581>:
          }
        finally
          {
            __cancel_buf = {CLOBBER};
          }
      }
      D.9564 = 1;
      return D.9564;
    }
  finally
    {
      event_handle = {CLOBBER};
    }
}


event_reset (void * handle)
{
  gboolean D.9589;
  long int D.9590;
  _Bool D.9593;
  long int D.9594;
  long int D.9595;
  int D.9598;
  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.9587>; else goto <D.9588>;
      <D.9587>:
      monoeg_g_log (0B, 16, "%s: error looking up event handle %p", &__func__, handle);
      D.9589 = 0;
      return D.9589;
      <D.9588>:
      {
        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.9590 = __builtin_expect (__not_first_call, 0);
            if (D.9590 != 0) goto <D.9591>; else goto <D.9592>;
            <D.9591>:
            __cancel_routine (__cancel_arg);
            __pthread_unwind_next (&__cancel_buf);
            <D.9592>:
            __pthread_register_cancel (&__cancel_buf);
            thr_ret = _wapi_handle_lock_handle (handle);
            D.9593 = thr_ret != 0;
            D.9594 = (long int) D.9593;
            D.9595 = __builtin_expect (D.9594, 0);
            if (D.9595 != 0) goto <D.9596>; else goto <D.9597>;
            <D.9596>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "events.c", 524, "thr_ret == 0");
            <D.9597>:
            D.9598 = _wapi_handle_issignalled (handle);
            if (D.9598 == 0) goto <D.9599>; else goto <D.9600>;
            <D.9599>:
            goto <D.9601>;
            <D.9600>:
            _wapi_handle_set_signal_state (handle, 0, 0);
            <D.9601>:
            event_handle.15 = event_handle;
            event_handle.15->set_count = 0;
            thr_ret = _wapi_handle_unlock_handle (handle);
            D.9593 = thr_ret != 0;
            D.9594 = (long int) D.9593;
            D.9595 = __builtin_expect (D.9594, 0);
            if (D.9595 != 0) goto <D.9603>; else goto <D.9604>;
            <D.9603>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "events.c", 539, "thr_ret == 0");
            <D.9604>:
            __pthread_unregister_cancel (&__cancel_buf);
            if (0 != 0) goto <D.9605>; else goto <D.9606>;
            <D.9605>:
            __cancel_routine (__cancel_arg);
            <D.9606>:
          }
        finally
          {
            __cancel_buf = {CLOBBER};
          }
      }
      D.9589 = 1;
      return D.9589;
    }
  finally
    {
      event_handle = {CLOBBER};
    }
}


event_pulse (void * handle)
{
  gboolean D.9615;
  long int D.9616;
  _Bool D.9619;
  long int D.9620;
  long int D.9621;
  struct _WapiHandle_event * event_handle.16;
  int D.9625;
  long int D.9635;
  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.9613>; else goto <D.9614>;
      <D.9613>:
      monoeg_g_log (0B, 16, "%s: error looking up event handle %p", &__func__, handle);
      D.9615 = 0;
      return D.9615;
      <D.9614>:
      {
        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.9616 = __builtin_expect (__not_first_call, 0);
            if (D.9616 != 0) goto <D.9617>; else goto <D.9618>;
            <D.9617>:
            __cancel_routine (__cancel_arg);
            __pthread_unwind_next (&__cancel_buf);
            <D.9618>:
            __pthread_register_cancel (&__cancel_buf);
            thr_ret = _wapi_handle_lock_handle (handle);
            D.9619 = thr_ret != 0;
            D.9620 = (long int) D.9619;
            D.9621 = __builtin_expect (D.9620, 0);
            if (D.9621 != 0) goto <D.9622>; else goto <D.9623>;
            <D.9622>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "events.c", 370, "thr_ret == 0");
            <D.9623>:
            event_handle.16 = event_handle;
            D.9625 = event_handle.16->manual;
            if (D.9625 == 1) goto <D.9626>; else goto <D.9627>;
            <D.9626>:
            _wapi_handle_set_signal_state (handle, 1, 1);
            goto <D.9628>;
            <D.9627>:
            event_handle.16 = event_handle;
            event_handle.16->set_count = 1;
            _wapi_handle_set_signal_state (handle, 1, 0);
            <D.9628>:
            thr_ret = _wapi_handle_unlock_handle (handle);
            D.9619 = thr_ret != 0;
            D.9620 = (long int) D.9619;
            D.9621 = __builtin_expect (D.9620, 0);
            if (D.9621 != 0) goto <D.9629>; else goto <D.9630>;
            <D.9629>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "events.c", 382, "thr_ret == 0");
            <D.9630>:
            __pthread_unregister_cancel (&__cancel_buf);
            if (0 != 0) goto <D.9631>; else goto <D.9632>;
            <D.9631>:
            __cancel_routine (__cancel_arg);
            <D.9632>:
          }
        finally
          {
            __cancel_buf = {CLOBBER};
          }
      }
      event_handle.16 = event_handle;
      D.9625 = event_handle.16->manual;
      if (D.9625 == 1) goto <D.9633>; else goto <D.9634>;
      <D.9633>:
      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.9635 = __builtin_expect (__not_first_call, 0);
            if (D.9635 != 0) goto <D.9636>; else goto <D.9637>;
            <D.9636>:
            __cancel_routine (__cancel_arg);
            __pthread_unwind_next (&__cancel_buf);
            <D.9637>:
            __pthread_register_cancel (&__cancel_buf);
            thr_ret = _wapi_handle_lock_handle (handle);
            D.9619 = thr_ret != 0;
            D.9620 = (long int) D.9619;
            D.9621 = __builtin_expect (D.9620, 0);
            if (D.9621 != 0) goto <D.9638>; else goto <D.9639>;
            <D.9638>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "events.c", 404, "thr_ret == 0");
            <D.9639>:
            _wapi_handle_set_signal_state (handle, 0, 0);
            thr_ret = _wapi_handle_unlock_handle (handle);
            D.9619 = thr_ret != 0;
            D.9620 = (long int) D.9619;
            D.9621 = __builtin_expect (D.9620, 0);
            if (D.9621 != 0) goto <D.9640>; else goto <D.9641>;
            <D.9640>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "events.c", 409, "thr_ret == 0");
            <D.9641>:
            __pthread_unregister_cancel (&__cancel_buf);
            if (0 != 0) goto <D.9642>; else goto <D.9643>;
            <D.9642>:
            __cancel_routine (__cancel_arg);
            <D.9643>:
          }
        finally
          {
            __cancel_buf = {CLOBBER};
          }
      }
      <D.9634>:
      D.9615 = 1;
      return D.9615;
    }
  finally
    {
      event_handle = {CLOBBER};
    }
}


ResetEvent (void * handle)
{
  gboolean D.9653;
  gboolean (*<T12cb>) (void *) D.9654;
  WapiHandleType type;

  if (handle == 0B) goto <D.9651>; else goto <D.9652>;
  <D.9651>:
  SetLastError (6);
  D.9653 = 0;
  return D.9653;
  <D.9652>:
  type = _wapi_handle_type (handle);
  D.9654 = event_ops[type].reset;
  if (D.9654 == 0B) goto <D.9655>; else goto <D.9656>;
  <D.9655>:
  SetLastError (6);
  D.9653 = 0;
  return D.9653;
  <D.9656>:
  D.9654 = event_ops[type].reset;
  D.9653 = D.9654 (handle);
  return D.9653;
}


SetEvent (void * handle)
{
  gboolean D.9660;
  gboolean (*<T12cb>) (void *) D.9661;
  WapiHandleType type;

  if (handle == 0B) goto <D.9658>; else goto <D.9659>;
  <D.9658>:
  SetLastError (6);
  D.9660 = 0;
  return D.9660;
  <D.9659>:
  type = _wapi_handle_type (handle);
  D.9661 = event_ops[type].set;
  if (D.9661 == 0B) goto <D.9662>; else goto <D.9663>;
  <D.9662>:
  SetLastError (6);
  D.9660 = 0;
  return D.9660;
  <D.9663>:
  D.9661 = event_ops[type].set;
  D.9660 = D.9661 (handle);
  return D.9660;
}


OpenEvent (guint32 access, gboolean inherit, const gunichar2 * name)
{
  _Bool D.9665;
  long int D.9666;
  long int D.9667;
  unsigned int offset.17;
  void * D.9677;
  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.9665 = thr_ret != 0;
  D.9666 = (long int) D.9665;
  D.9667 = __builtin_expect (D.9666, 0);
  if (D.9667 != 0) goto <D.9668>; else goto <D.9669>;
  <D.9668>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "events.c", 724, "thr_ret == 0");
  <D.9669>:
  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.9670>; else goto <D.9671>;
  <D.9670>:
  SetLastError (6);
  goto cleanup;
  <D.9671>:
  if (offset == 0) goto <D.9672>; else goto <D.9673>;
  <D.9672>:
  SetLastError (2);
  goto cleanup;
  <D.9673>:
  offset.17 = (unsigned int) offset;
  handle = _wapi_handle_new_from_offset (13, offset.17, 1);
  if (handle == 4294967295B) goto <D.9675>; else goto <D.9676>;
  <D.9675>:
  monoeg_g_log (0B, 16, "%s: error opening named event handle", &__func__);
  SetLastError (31);
  goto cleanup;
  <D.9676>:
  ret = handle;
  cleanup:
  monoeg_g_free (utf8_name);
  _wapi_namespace_unlock (0B);
  D.9677 = ret;
  return D.9677;
}


