event_own (void * handle)
{
  gboolean D.9261;
  struct _WapiHandle_event * event_handle.0;
  int D.9263;
  unsigned int D.9266;
  _Bool D.9267;
  long int D.9268;
  long int D.9269;
  unsigned int D.9272;
  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.9259>; else goto <D.9260>;
      <D.9259>:
      monoeg_g_log (0B, 16, "%s: error looking up event handle %p", &__func__, handle);
      D.9261 = 0;
      return D.9261;
      <D.9260>:
      event_handle.0 = event_handle;
      D.9263 = event_handle.0->manual;
      if (D.9263 == 0) goto <D.9264>; else goto <D.9265>;
      <D.9264>:
      event_handle.0 = event_handle;
      D.9266 = event_handle.0->set_count;
      D.9267 = D.9266 == 0;
      D.9268 = (long int) D.9267;
      D.9269 = __builtin_expect (D.9268, 0);
      if (D.9269 != 0) goto <D.9270>; else goto <D.9271>;
      <D.9270>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "events.c", 121, "event_handle->set_count > 0");
      <D.9271>:
      event_handle.0 = event_handle;
      D.9266 = event_handle.0->set_count;
      D.9272 = D.9266 + 4294967295;
      event_handle.0->set_count = D.9272;
      D.9266 = event_handle.0->set_count;
      if (D.9266 == 0) goto <D.9273>; else goto <D.9274>;
      <D.9273>:
      _wapi_handle_set_signal_state (handle, 0, 0);
      <D.9274>:
      <D.9265>:
      D.9261 = 1;
      return D.9261;
    }
  finally
    {
      event_handle = {CLOBBER};
    }
}


_wapi_handle_set_signal_state (void * handle, gboolean state, gboolean broadcast)
{
  int iftmp.1;
  <unnamed type> D.9283;
  <unnamed type> D.9285;
  <unnamed type> D.9287;
  <unnamed type> D.9289;
  _Bool D.9290;
  long int D.9291;
  long int D.9292;
  unsigned int D.9295;
  struct _WapiHandleUnshared * D.9296;
  unsigned int D.9297;
  unsigned int D.9298;
  long int D.9301;
  union mono_mutex_t * _wapi_global_signal_mutex.2;
  _Bool D.9307;
  long int D.9308;
  long int D.9309;
  union pthread_cond_t * D.9314;
  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.9277>; else goto <D.9278>;
  <D.9277>:
  return;
  <D.9278>:
  D.9283 = _wapi_handle_type (handle);
  if (D.9283 == 9) goto <D.9280>; else goto <D.9284>;
  <D.9284>:
  D.9285 = _wapi_handle_type (handle);
  if (D.9285 == 11) goto <D.9280>; else goto <D.9286>;
  <D.9286>:
  D.9287 = _wapi_handle_type (handle);
  if (D.9287 == 12) goto <D.9280>; else goto <D.9288>;
  <D.9288>:
  D.9289 = _wapi_handle_type (handle);
  if (D.9289 == 13) goto <D.9280>; else goto <D.9281>;
  <D.9280>:
  iftmp.1 = 1;
  goto <D.9282>;
  <D.9281>:
  iftmp.1 = 0;
  <D.9282>:
  D.9290 = iftmp.1 != 0;
  D.9291 = (long int) D.9290;
  D.9292 = __builtin_expect (D.9291, 0);
  if (D.9292 != 0) goto <D.9293>; else goto <D.9294>;
  <D.9293>:
  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.9294>:
  D.9295 = idx / 256;
  D.9296 = _wapi_private_handles[D.9295];
  D.9297 = idx & 255;
  D.9298 = D.9297 * 144;
  handle_data = D.9296 + D.9298;
  if (state == 1) goto <D.9299>; else goto <D.9300>;
  <D.9299>:
  {
    struct __pthread_unwind_buf_t __cancel_buf;
    void (*<Tc3>) (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.9301 = __builtin_expect (__not_first_call, 0);
        if (D.9301 != 0) goto <D.9302>; else goto <D.9303>;
        <D.9302>:
        __cancel_routine (__cancel_arg);
        __pthread_unwind_next (&__cancel_buf);
        <D.9303>:
        __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.9305>; else goto <D.9306>;
        <D.9305>:
        monoeg_g_log (0B, 16, "Bad call to mono_mutex_lock result %d for global signal mutex", thr_ret);
        <D.9306>:
        D.9307 = thr_ret != 0;
        D.9308 = (long int) D.9307;
        D.9309 = __builtin_expect (D.9308, 0);
        if (D.9309 != 0) goto <D.9310>; else goto <D.9311>;
        <D.9310>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "../../mono/io-layer/handles-private.h", 151, "thr_ret == 0");
        <D.9311>:
        handle_data->signalled = state;
        if (broadcast == 1) goto <D.9312>; else goto <D.9313>;
        <D.9312>:
        D.9314 = &handle_data->signal_cond;
        thr_ret = pthread_cond_broadcast (D.9314);
        if (thr_ret != 0) goto <D.9315>; else goto <D.9316>;
        <D.9315>:
        monoeg_g_log (0B, 16, "Bad call to pthread_cond_broadcast result %d for handle %p", thr_ret, handle);
        <D.9316>:
        D.9307 = thr_ret != 0;
        D.9308 = (long int) D.9307;
        D.9309 = __builtin_expect (D.9308, 0);
        if (D.9309 != 0) goto <D.9317>; else goto <D.9318>;
        <D.9317>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "../../mono/io-layer/handles-private.h", 162, "thr_ret == 0");
        <D.9318>:
        goto <D.9319>;
        <D.9313>:
        D.9314 = &handle_data->signal_cond;
        thr_ret = pthread_cond_signal (D.9314);
        if (thr_ret != 0) goto <D.9320>; else goto <D.9321>;
        <D.9320>:
        monoeg_g_log (0B, 16, "Bad call to pthread_cond_signal result %d for handle %p", thr_ret, handle);
        <D.9321>:
        D.9307 = thr_ret != 0;
        D.9308 = (long int) D.9307;
        D.9309 = __builtin_expect (D.9308, 0);
        if (D.9309 != 0) goto <D.9322>; else goto <D.9323>;
        <D.9322>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "../../mono/io-layer/handles-private.h", 167, "thr_ret == 0");
        <D.9323>:
        <D.9319>:
        _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.9325>; else goto <D.9326>;
        <D.9325>:
        monoeg_g_log (0B, 16, "Bad call to pthread_cond_broadcast result %d for handle %p", thr_ret, handle);
        <D.9326>:
        D.9307 = thr_ret != 0;
        D.9308 = (long int) D.9307;
        D.9309 = __builtin_expect (D.9308, 0);
        if (D.9309 != 0) goto <D.9327>; else goto <D.9328>;
        <D.9327>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "../../mono/io-layer/handles-private.h", 176, "thr_ret == 0");
        <D.9328>:
        _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.9329>; else goto <D.9330>;
        <D.9329>:
        monoeg_g_log (0B, 16, "Bad call to mono_mutex_unlock result %d for global signal mutex", thr_ret);
        <D.9330>:
        D.9307 = thr_ret != 0;
        D.9308 = (long int) D.9307;
        D.9309 = __builtin_expect (D.9308, 0);
        if (D.9309 != 0) goto <D.9331>; else goto <D.9332>;
        <D.9331>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "../../mono/io-layer/handles-private.h", 181, "thr_ret == 0");
        <D.9332>:
        __pthread_unregister_cancel (&__cancel_buf);
        if (0 != 0) goto <D.9333>; else goto <D.9334>;
        <D.9333>:
        __cancel_routine (__cancel_arg);
        <D.9334>:
      }
    finally
      {
        __cancel_buf = {CLOBBER};
      }
  }
  goto <D.9335>;
  <D.9300>:
  handle_data->signalled = state;
  <D.9335>:
}


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

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


_wapi_handle_type (void * handle)
{
  unsigned int D.9352;
  struct _WapiHandleUnshared * D.9353;
  WapiHandleType D.9354;
  unsigned int D.9355;
  unsigned int D.9356;
  struct _WapiHandleUnshared * D.9357;
  guint32 idx;

  idx = (guint32) handle;
  if (idx > 4194303) goto <D.9348>; else goto <D.9350>;
  <D.9350>:
  if (idx > 268435455) goto <D.9348>; else goto <D.9351>;
  <D.9351>:
  D.9352 = idx / 256;
  D.9353 = _wapi_private_handles[D.9352];
  if (D.9353 == 0B) goto <D.9348>; else goto <D.9349>;
  <D.9348>:
  D.9354 = 0;
  return D.9354;
  <D.9349>:
  D.9352 = idx / 256;
  D.9353 = _wapi_private_handles[D.9352];
  D.9355 = idx & 255;
  D.9356 = D.9355 * 144;
  D.9357 = D.9353 + D.9356;
  D.9354 = D.9357->type;
  return D.9354;
}


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


namedevent_own (void * handle)
{
  gboolean D.9361;
  struct _WapiHandle_namedevent * namedevent_handle.4;
  int D.9363;
  unsigned int D.9366;
  _Bool D.9367;
  long int D.9368;
  long int D.9369;
  unsigned int D.9372;
  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.9359>; else goto <D.9360>;
      <D.9359>:
      monoeg_g_log (0B, 16, "%s: error looking up named event handle %p", &__func__, handle);
      D.9361 = 0;
      return D.9361;
      <D.9360>:
      namedevent_handle.4 = namedevent_handle;
      D.9363 = namedevent_handle.4->manual;
      if (D.9363 == 0) goto <D.9364>; else goto <D.9365>;
      <D.9364>:
      namedevent_handle.4 = namedevent_handle;
      D.9366 = namedevent_handle.4->set_count;
      D.9367 = D.9366 == 0;
      D.9368 = (long int) D.9367;
      D.9369 = __builtin_expect (D.9368, 0);
      if (D.9369 != 0) goto <D.9370>; else goto <D.9371>;
      <D.9370>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "events.c", 153, "namedevent_handle->set_count > 0");
      <D.9371>:
      namedevent_handle.4 = namedevent_handle;
      D.9366 = namedevent_handle.4->set_count;
      D.9372 = D.9366 + 4294967295;
      namedevent_handle.4->set_count = D.9372;
      D.9366 = namedevent_handle.4->set_count;
      if (D.9366 == 0) goto <D.9373>; else goto <D.9374>;
      <D.9373>:
      _wapi_shared_handle_set_signal_state (handle, 0);
      <D.9374>:
      <D.9365>:
      D.9361 = 1;
      return D.9361;
    }
  finally
    {
      namedevent_handle = {CLOBBER};
    }
}


_wapi_shared_handle_set_signal_state (void * handle, gboolean state)
{
  int iftmp.5;
  <unnamed type> D.9382;
  <unnamed type> D.9384;
  <unnamed type> D.9386;
  <unnamed type> D.9388;
  _Bool D.9390;
  long int D.9391;
  long int D.9392;
  unsigned int D.9395;
  struct _WapiHandleUnshared * D.9396;
  unsigned int D.9397;
  unsigned int D.9398;
  struct _WapiHandleSharedLayout * _wapi_shared_layout.6;
  unsigned int D.9400;
  guint32 idx;
  struct _WapiHandleUnshared * handle_data;
  struct _WapiHandle_shared_ref * ref;
  struct _WapiHandleShared * shared_data;

  idx = (guint32) handle;
  if (idx > 4194303) goto <D.9377>; else goto <D.9378>;
  <D.9377>:
  return;
  <D.9378>:
  D.9382 = _wapi_handle_type (handle);
  if (D.9382 != 9) goto <D.9383>; else goto <D.9380>;
  <D.9383>:
  D.9384 = _wapi_handle_type (handle);
  if (D.9384 != 11) goto <D.9385>; else goto <D.9380>;
  <D.9385>:
  D.9386 = _wapi_handle_type (handle);
  if (D.9386 != 12) goto <D.9387>; else goto <D.9380>;
  <D.9387>:
  D.9388 = _wapi_handle_type (handle);
  if (D.9388 != 13) goto <D.9389>; else goto <D.9380>;
  <D.9389>:
  iftmp.5 = 1;
  goto <D.9381>;
  <D.9380>:
  iftmp.5 = 0;
  <D.9381>:
  D.9390 = iftmp.5 != 0;
  D.9391 = (long int) D.9390;
  D.9392 = __builtin_expect (D.9391, 0);
  if (D.9392 != 0) goto <D.9393>; else goto <D.9394>;
  <D.9393>:
  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.9394>:
  D.9395 = idx / 256;
  D.9396 = _wapi_private_handles[D.9395];
  D.9397 = idx & 255;
  D.9398 = D.9397 * 144;
  handle_data = D.9396 + D.9398;
  ref = &handle_data->u.shared;
  _wapi_shared_layout.6 = _wapi_shared_layout;
  D.9400 = ref->offset;
  shared_data = &_wapi_shared_layout.6->handles[D.9400];
  shared_data->signalled = state;
}


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


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

  event = handle_info;
  D.9403 = event->manual;
  if (D.9403 != 0) goto <D.9404>; else goto <D.9405>;
  <D.9404>:
  iftmp.7 = "TRUE";
  goto <D.9406>;
  <D.9405>:
  iftmp.7 = "FALSE";
  <D.9406>:
  monoeg_g_print ("manual: %s", iftmp.7);
}


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

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


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.9417;
  long int D.9418;
  _Bool D.9421;
  long int D.9422;
  long int D.9423;
  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.9411>; else goto <D.9412>;
      <D.9411>:
      if (manual == 0) goto <D.9413>; else goto <D.9414>;
      <D.9413>:
      event_handle.set_count = 1;
      <D.9414>:
      <D.9412>:
      handle = _wapi_handle_new (6, &event_handle);
      if (handle == 4294967295B) goto <D.9415>; else goto <D.9416>;
      <D.9415>:
      monoeg_g_log (0B, 16, "%s: error creating event handle", &__func__);
      SetLastError (31);
      D.9417 = 0B;
      return D.9417;
      <D.9416>:
      {
        struct __pthread_unwind_buf_t __cancel_buf;
        void (*<Tc3>) (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.9418 = __builtin_expect (__not_first_call, 0);
            if (D.9418 != 0) goto <D.9419>; else goto <D.9420>;
            <D.9419>:
            __cancel_routine (__cancel_arg);
            __pthread_unwind_next (&__cancel_buf);
            <D.9420>:
            __pthread_register_cancel (&__cancel_buf);
            thr_ret = _wapi_handle_lock_handle (handle);
            D.9421 = thr_ret != 0;
            D.9422 = (long int) D.9421;
            D.9423 = __builtin_expect (D.9422, 0);
            if (D.9423 != 0) goto <D.9424>; else goto <D.9425>;
            <D.9424>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "events.c", 196, "thr_ret == 0");
            <D.9425>:
            if (initial == 1) goto <D.9426>; else goto <D.9427>;
            <D.9426>:
            _wapi_handle_set_signal_state (handle, 1, 0);
            <D.9427>:
            thr_ret = _wapi_handle_unlock_handle (handle);
            D.9421 = thr_ret != 0;
            D.9422 = (long int) D.9421;
            D.9423 = __builtin_expect (D.9422, 0);
            if (D.9423 != 0) goto <D.9428>; else goto <D.9429>;
            <D.9428>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "events.c", 205, "thr_ret == 0");
            <D.9429>:
            __pthread_unregister_cancel (&__cancel_buf);
            if (0 != 0) goto <D.9430>; else goto <D.9431>;
            <D.9430>:
            __cancel_routine (__cancel_arg);
            <D.9431>:
          }
        finally
          {
            __cancel_buf = {CLOBBER};
          }
      }
      D.9417 = handle;
      return D.9417;
    }
  finally
    {
      event_handle = {CLOBBER};
    }
}


_wapi_handle_lock_handle (void * handle)
{
  int D.9439;
  <unnamed type> D.9442;
  <unnamed type> D.9444;
  <unnamed type> D.9446;
  <unnamed type> D.9448;
  unsigned int D.9449;
  struct _WapiHandleUnshared * D.9450;
  unsigned int D.9451;
  unsigned int D.9452;
  struct _WapiHandleUnshared * D.9453;
  union mono_mutex_t * D.9454;
  guint32 idx;

  idx = (guint32) handle;
  if (idx > 4194303) goto <D.9437>; else goto <D.9438>;
  <D.9437>:
  D.9439 = 0;
  return D.9439;
  <D.9438>:
  _wapi_handle_ref (handle);
  D.9442 = _wapi_handle_type (handle);
  if (D.9442 == 9) goto <D.9440>; else goto <D.9443>;
  <D.9443>:
  D.9444 = _wapi_handle_type (handle);
  if (D.9444 == 11) goto <D.9440>; else goto <D.9445>;
  <D.9445>:
  D.9446 = _wapi_handle_type (handle);
  if (D.9446 == 12) goto <D.9440>; else goto <D.9447>;
  <D.9447>:
  D.9448 = _wapi_handle_type (handle);
  if (D.9448 == 13) goto <D.9440>; else goto <D.9441>;
  <D.9440>:
  D.9439 = 0;
  return D.9439;
  <D.9441>:
  D.9449 = idx / 256;
  D.9450 = _wapi_private_handles[D.9449];
  D.9451 = idx & 255;
  D.9452 = D.9451 * 144;
  D.9453 = D.9450 + D.9452;
  D.9454 = &D.9453->signal_mutex;
  D.9439 = pthread_mutex_lock (D.9454);
  return D.9439;
}


_wapi_handle_unlock_handle (void * handle)
{
  int D.9458;
  <unnamed type> D.9461;
  <unnamed type> D.9463;
  <unnamed type> D.9465;
  <unnamed type> D.9467;
  unsigned int D.9468;
  struct _WapiHandleUnshared * D.9469;
  unsigned int D.9470;
  unsigned int D.9471;
  struct _WapiHandleUnshared * D.9472;
  union mono_mutex_t * D.9473;
  guint32 idx;
  int ret;

  idx = (guint32) handle;
  if (idx > 4194303) goto <D.9456>; else goto <D.9457>;
  <D.9456>:
  D.9458 = 0;
  return D.9458;
  <D.9457>:
  D.9461 = _wapi_handle_type (handle);
  if (D.9461 == 9) goto <D.9459>; else goto <D.9462>;
  <D.9462>:
  D.9463 = _wapi_handle_type (handle);
  if (D.9463 == 11) goto <D.9459>; else goto <D.9464>;
  <D.9464>:
  D.9465 = _wapi_handle_type (handle);
  if (D.9465 == 12) goto <D.9459>; else goto <D.9466>;
  <D.9466>:
  D.9467 = _wapi_handle_type (handle);
  if (D.9467 == 13) goto <D.9459>; else goto <D.9460>;
  <D.9459>:
  _wapi_handle_unref (handle);
  D.9458 = 0;
  return D.9458;
  <D.9460>:
  D.9468 = idx / 256;
  D.9469 = _wapi_private_handles[D.9468];
  D.9470 = idx & 255;
  D.9471 = D.9470 * 144;
  D.9472 = D.9469 + D.9471;
  D.9473 = &D.9472->signal_mutex;
  ret = pthread_mutex_unlock (D.9473);
  _wapi_handle_unref (handle);
  D.9458 = ret;
  return D.9458;
}


namedevent_create (struct WapiSecurityAttributes * security, gboolean manual, gboolean initial, const gunichar2 * name)
{
  _Bool D.9475;
  long int D.9476;
  long int D.9477;
  unsigned int D.9486;
  unsigned int offset.8;
  void * D.9504;
  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.9475 = thr_ret != 0;
      D.9476 = (long int) D.9475;
      D.9477 = __builtin_expect (D.9476, 0);
      if (D.9477 != 0) goto <D.9478>; else goto <D.9479>;
      <D.9478>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "events.c", 227, "thr_ret == 0");
      <D.9479>:
      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.9480>; else goto <D.9481>;
      <D.9480>:
      SetLastError (6);
      goto cleanup;
      <D.9481>:
      if (offset != 0) goto <D.9482>; else goto <D.9483>;
      <D.9482>:
      SetLastError (183);
      <D.9483>:
      if (offset == 0) goto <D.9484>; else goto <D.9485>;
      <D.9484>:
      D.9486 = strlen (utf8_name);
      if (D.9486 <= 259) goto <D.9487>; else goto <D.9488>;
      <D.9487>:
      namelen = strlen (utf8_name);
      goto <D.9489>;
      <D.9488>:
      namelen = 260;
      <D.9489>:
      memcpy (&namedevent_handle.sharedns.name, utf8_name, namelen);
      namedevent_handle.manual = manual;
      namedevent_handle.set_count = 0;
      if (initial == 1) goto <D.9490>; else goto <D.9491>;
      <D.9490>:
      if (manual == 0) goto <D.9492>; else goto <D.9493>;
      <D.9492>:
      namedevent_handle.set_count = 1;
      <D.9493>:
      <D.9491>:
      handle = _wapi_handle_new (13, &namedevent_handle);
      goto <D.9494>;
      <D.9485>:
      offset.8 = (unsigned int) offset;
      handle = _wapi_handle_new_from_offset (13, offset.8, 1);
      <D.9494>:
      if (handle == 4294967295B) goto <D.9496>; else goto <D.9497>;
      <D.9496>:
      monoeg_g_log (0B, 16, "%s: error creating event handle", &__func__);
      SetLastError (31);
      goto cleanup;
      <D.9497>:
      ret = handle;
      if (offset == 0) goto <D.9498>; else goto <D.9499>;
      <D.9498>:
      thr_ret = _wapi_handle_lock_shared_handles ();
      D.9475 = thr_ret != 0;
      D.9476 = (long int) D.9475;
      D.9477 = __builtin_expect (D.9476, 0);
      if (D.9477 != 0) goto <D.9500>; else goto <D.9501>;
      <D.9500>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "events.c", 299, "thr_ret == 0");
      <D.9501>:
      if (initial == 1) goto <D.9502>; else goto <D.9503>;
      <D.9502>:
      _wapi_shared_handle_set_signal_state (handle, 1);
      <D.9503>:
      _wapi_handle_unlock_shared_handles ();
      <D.9499>:
      cleanup:
      monoeg_g_free (utf8_name);
      _wapi_namespace_unlock (0B);
      D.9504 = ret;
      return D.9504;
    }
  finally
    {
      namedevent_handle = {CLOBBER};
    }
}


_wapi_namespace_lock ()
{
  int D.9507;

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


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

  D.9510 = __builtin_object_size (__dest, 0);
  D.9509 = __builtin___memcpy_chk (__dest, __src, __len, D.9510);
  return D.9509;
}


_wapi_handle_lock_shared_handles ()
{
  int D.9512;

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


_wapi_handle_unlock_shared_handles ()
{
  int D.9514;

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


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

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


PulseEvent (void * handle)
{
  gboolean D.9520;
  gboolean (*<T12e4>) (void *) D.9521;
  WapiHandleType type;

  if (handle == 0B) goto <D.9518>; else goto <D.9519>;
  <D.9518>:
  SetLastError (6);
  D.9520 = 0;
  return D.9520;
  <D.9519>:
  type = _wapi_handle_type (handle);
  D.9521 = event_ops[type].pulse;
  if (D.9521 == 0B) goto <D.9522>; else goto <D.9523>;
  <D.9522>:
  SetLastError (6);
  D.9520 = 0;
  return D.9520;
  <D.9523>:
  D.9521 = event_ops[type].pulse;
  D.9520 = D.9521 (handle);
  return D.9520;
}


namedevent_set (void * handle)
{
  gboolean D.9527;
  _Bool D.9528;
  long int D.9529;
  long int D.9530;
  struct _WapiHandle_namedevent * namedevent_handle.9;
  int D.9534;
  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.9525>; else goto <D.9526>;
      <D.9525>:
      monoeg_g_log (0B, 16, "%s: error looking up named event handle %p", &__func__, handle);
      D.9527 = 0;
      return D.9527;
      <D.9526>:
      thr_ret = _wapi_handle_lock_shared_handles ();
      D.9528 = thr_ret != 0;
      D.9529 = (long int) D.9528;
      D.9530 = __builtin_expect (D.9529, 0);
      if (D.9530 != 0) goto <D.9531>; else goto <D.9532>;
      <D.9531>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "events.c", 661, "thr_ret == 0");
      <D.9532>:
      namedevent_handle.9 = namedevent_handle;
      D.9534 = namedevent_handle.9->manual;
      if (D.9534 == 1) goto <D.9535>; else goto <D.9536>;
      <D.9535>:
      _wapi_shared_handle_set_signal_state (handle, 1);
      goto <D.9537>;
      <D.9536>:
      namedevent_handle.9 = namedevent_handle;
      namedevent_handle.9->set_count = 1;
      _wapi_shared_handle_set_signal_state (handle, 1);
      <D.9537>:
      _wapi_handle_unlock_shared_handles ();
      D.9527 = 1;
      return D.9527;
    }
  finally
    {
      namedevent_handle = {CLOBBER};
    }
}


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


_wapi_handle_issignalled (void * handle)
{
  gboolean D.9557;
  <unnamed type> D.9560;
  <unnamed type> D.9562;
  <unnamed type> D.9564;
  <unnamed type> D.9566;
  struct _WapiHandleSharedLayout * _wapi_shared_layout.11;
  unsigned int handle.12;
  unsigned int D.9569;
  struct _WapiHandleUnshared * D.9570;
  unsigned int D.9571;
  unsigned int D.9572;
  struct _WapiHandleUnshared * D.9573;
  unsigned int D.9574;
  unsigned int D.9575;
  struct _WapiHandleUnshared * D.9576;
  unsigned int D.9577;
  unsigned int D.9578;
  struct _WapiHandleUnshared * D.9579;
  guint32 idx;

  idx = (guint32) handle;
  if (idx > 4194303) goto <D.9555>; else goto <D.9556>;
  <D.9555>:
  D.9557 = 0;
  return D.9557;
  <D.9556>:
  D.9560 = _wapi_handle_type (handle);
  if (D.9560 == 9) goto <D.9558>; else goto <D.9561>;
  <D.9561>:
  D.9562 = _wapi_handle_type (handle);
  if (D.9562 == 11) goto <D.9558>; else goto <D.9563>;
  <D.9563>:
  D.9564 = _wapi_handle_type (handle);
  if (D.9564 == 12) goto <D.9558>; else goto <D.9565>;
  <D.9565>:
  D.9566 = _wapi_handle_type (handle);
  if (D.9566 == 13) goto <D.9558>; else goto <D.9559>;
  <D.9558>:
  _wapi_shared_layout.11 = _wapi_shared_layout;
  handle.12 = (unsigned int) handle;
  D.9569 = handle.12 / 256;
  D.9570 = _wapi_private_handles[D.9569];
  handle.12 = (unsigned int) handle;
  D.9571 = handle.12 & 255;
  D.9572 = D.9571 * 144;
  D.9573 = D.9570 + D.9572;
  D.9574 = D.9573->u.shared.offset;
  D.9557 = _wapi_shared_layout.11->handles[D.9574].signalled;
  return D.9557;
  <D.9559>:
  D.9575 = idx / 256;
  D.9576 = _wapi_private_handles[D.9575];
  D.9577 = idx & 255;
  D.9578 = D.9577 * 144;
  D.9579 = D.9576 + D.9578;
  D.9557 = D.9579->signalled;
  return D.9557;
}


namedevent_pulse (void * handle)
{
  gboolean D.9583;
  _Bool D.9584;
  long int D.9585;
  long int D.9586;
  struct _WapiHandle_namedevent * namedevent_handle.13;
  int D.9590;
  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.9581>; else goto <D.9582>;
      <D.9581>:
      monoeg_g_log (0B, 16, "%s: error looking up named event handle %p", &__func__, handle);
      D.9583 = 0;
      return D.9583;
      <D.9582>:
      thr_ret = _wapi_handle_lock_shared_handles ();
      D.9584 = thr_ret != 0;
      D.9585 = (long int) D.9584;
      D.9586 = __builtin_expect (D.9585, 0);
      if (D.9586 != 0) goto <D.9587>; else goto <D.9588>;
      <D.9587>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "events.c", 431, "thr_ret == 0");
      <D.9588>:
      namedevent_handle.13 = namedevent_handle;
      D.9590 = namedevent_handle.13->manual;
      if (D.9590 == 1) goto <D.9591>; else goto <D.9592>;
      <D.9591>:
      _wapi_shared_handle_set_signal_state (handle, 1);
      goto <D.9593>;
      <D.9592>:
      namedevent_handle.13 = namedevent_handle;
      namedevent_handle.13->set_count = 1;
      _wapi_shared_handle_set_signal_state (handle, 1);
      <D.9593>:
      _wapi_handle_unlock_shared_handles ();
      namedevent_handle.13 = namedevent_handle;
      D.9590 = namedevent_handle.13->manual;
      if (D.9590 == 1) goto <D.9594>; else goto <D.9595>;
      <D.9594>:
      _wapi_handle_spin (200);
      thr_ret = _wapi_handle_lock_shared_handles ();
      D.9584 = thr_ret != 0;
      D.9585 = (long int) D.9584;
      D.9586 = __builtin_expect (D.9585, 0);
      if (D.9586 != 0) goto <D.9596>; else goto <D.9597>;
      <D.9596>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "events.c", 461, "thr_ret == 0");
      <D.9597>:
      _wapi_shared_handle_set_signal_state (handle, 0);
      _wapi_handle_unlock_shared_handles ();
      <D.9595>:
      D.9583 = 1;
      return D.9583;
    }
  finally
    {
      namedevent_handle = {CLOBBER};
    }
}


_wapi_handle_spin (guint32 ms)
{
  _Bool D.9600;
  long int D.9601;
  long int D.9602;
  unsigned int D.9605;
  long int D.9606;
  struct timespec sleepytime;

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


event_set (void * handle)
{
  gboolean D.9609;
  long int D.9610;
  _Bool D.9613;
  long int D.9614;
  long int D.9615;
  struct _WapiHandle_event * event_handle.14;
  int D.9619;
  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.9607>; else goto <D.9608>;
      <D.9607>:
      monoeg_g_log (0B, 16, "%s: error looking up event handle %p", &__func__, handle);
      D.9609 = 0;
      return D.9609;
      <D.9608>:
      {
        struct __pthread_unwind_buf_t __cancel_buf;
        void (*<Tc3>) (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.9610 = __builtin_expect (__not_first_call, 0);
            if (D.9610 != 0) goto <D.9611>; else goto <D.9612>;
            <D.9611>:
            __cancel_routine (__cancel_arg);
            __pthread_unwind_next (&__cancel_buf);
            <D.9612>:
            __pthread_register_cancel (&__cancel_buf);
            thr_ret = _wapi_handle_lock_handle (handle);
            D.9613 = thr_ret != 0;
            D.9614 = (long int) D.9613;
            D.9615 = __builtin_expect (D.9614, 0);
            if (D.9615 != 0) goto <D.9616>; else goto <D.9617>;
            <D.9616>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "events.c", 627, "thr_ret == 0");
            <D.9617>:
            event_handle.14 = event_handle;
            D.9619 = event_handle.14->manual;
            if (D.9619 == 1) goto <D.9620>; else goto <D.9621>;
            <D.9620>:
            _wapi_handle_set_signal_state (handle, 1, 1);
            goto <D.9622>;
            <D.9621>:
            event_handle.14 = event_handle;
            event_handle.14->set_count = 1;
            _wapi_handle_set_signal_state (handle, 1, 0);
            <D.9622>:
            thr_ret = _wapi_handle_unlock_handle (handle);
            D.9613 = thr_ret != 0;
            D.9614 = (long int) D.9613;
            D.9615 = __builtin_expect (D.9614, 0);
            if (D.9615 != 0) goto <D.9623>; else goto <D.9624>;
            <D.9623>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "events.c", 639, "thr_ret == 0");
            <D.9624>:
            __pthread_unregister_cancel (&__cancel_buf);
            if (0 != 0) goto <D.9625>; else goto <D.9626>;
            <D.9625>:
            __cancel_routine (__cancel_arg);
            <D.9626>:
          }
        finally
          {
            __cancel_buf = {CLOBBER};
          }
      }
      D.9609 = 1;
      return D.9609;
    }
  finally
    {
      event_handle = {CLOBBER};
    }
}


event_reset (void * handle)
{
  gboolean D.9634;
  long int D.9635;
  _Bool D.9638;
  long int D.9639;
  long int D.9640;
  int D.9643;
  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.9632>; else goto <D.9633>;
      <D.9632>:
      monoeg_g_log (0B, 16, "%s: error looking up event handle %p", &__func__, handle);
      D.9634 = 0;
      return D.9634;
      <D.9633>:
      {
        struct __pthread_unwind_buf_t __cancel_buf;
        void (*<Tc3>) (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.9638 = thr_ret != 0;
            D.9639 = (long int) D.9638;
            D.9640 = __builtin_expect (D.9639, 0);
            if (D.9640 != 0) goto <D.9641>; else goto <D.9642>;
            <D.9641>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "events.c", 524, "thr_ret == 0");
            <D.9642>:
            D.9643 = _wapi_handle_issignalled (handle);
            if (D.9643 == 0) goto <D.9644>; else goto <D.9645>;
            <D.9644>:
            goto <D.9646>;
            <D.9645>:
            _wapi_handle_set_signal_state (handle, 0, 0);
            <D.9646>:
            event_handle.15 = event_handle;
            event_handle.15->set_count = 0;
            thr_ret = _wapi_handle_unlock_handle (handle);
            D.9638 = thr_ret != 0;
            D.9639 = (long int) D.9638;
            D.9640 = __builtin_expect (D.9639, 0);
            if (D.9640 != 0) goto <D.9648>; else goto <D.9649>;
            <D.9648>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "events.c", 539, "thr_ret == 0");
            <D.9649>:
            __pthread_unregister_cancel (&__cancel_buf);
            if (0 != 0) goto <D.9650>; else goto <D.9651>;
            <D.9650>:
            __cancel_routine (__cancel_arg);
            <D.9651>:
          }
        finally
          {
            __cancel_buf = {CLOBBER};
          }
      }
      D.9634 = 1;
      return D.9634;
    }
  finally
    {
      event_handle = {CLOBBER};
    }
}


event_pulse (void * handle)
{
  gboolean D.9660;
  long int D.9661;
  _Bool D.9664;
  long int D.9665;
  long int D.9666;
  struct _WapiHandle_event * event_handle.16;
  int D.9670;
  long int D.9680;
  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.9658>; else goto <D.9659>;
      <D.9658>:
      monoeg_g_log (0B, 16, "%s: error looking up event handle %p", &__func__, handle);
      D.9660 = 0;
      return D.9660;
      <D.9659>:
      {
        struct __pthread_unwind_buf_t __cancel_buf;
        void (*<Tc3>) (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.9661 = __builtin_expect (__not_first_call, 0);
            if (D.9661 != 0) goto <D.9662>; else goto <D.9663>;
            <D.9662>:
            __cancel_routine (__cancel_arg);
            __pthread_unwind_next (&__cancel_buf);
            <D.9663>:
            __pthread_register_cancel (&__cancel_buf);
            thr_ret = _wapi_handle_lock_handle (handle);
            D.9664 = thr_ret != 0;
            D.9665 = (long int) D.9664;
            D.9666 = __builtin_expect (D.9665, 0);
            if (D.9666 != 0) goto <D.9667>; else goto <D.9668>;
            <D.9667>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "events.c", 370, "thr_ret == 0");
            <D.9668>:
            event_handle.16 = event_handle;
            D.9670 = event_handle.16->manual;
            if (D.9670 == 1) goto <D.9671>; else goto <D.9672>;
            <D.9671>:
            _wapi_handle_set_signal_state (handle, 1, 1);
            goto <D.9673>;
            <D.9672>:
            event_handle.16 = event_handle;
            event_handle.16->set_count = 1;
            _wapi_handle_set_signal_state (handle, 1, 0);
            <D.9673>:
            thr_ret = _wapi_handle_unlock_handle (handle);
            D.9664 = thr_ret != 0;
            D.9665 = (long int) D.9664;
            D.9666 = __builtin_expect (D.9665, 0);
            if (D.9666 != 0) goto <D.9674>; else goto <D.9675>;
            <D.9674>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "events.c", 382, "thr_ret == 0");
            <D.9675>:
            __pthread_unregister_cancel (&__cancel_buf);
            if (0 != 0) goto <D.9676>; else goto <D.9677>;
            <D.9676>:
            __cancel_routine (__cancel_arg);
            <D.9677>:
          }
        finally
          {
            __cancel_buf = {CLOBBER};
          }
      }
      event_handle.16 = event_handle;
      D.9670 = event_handle.16->manual;
      if (D.9670 == 1) goto <D.9678>; else goto <D.9679>;
      <D.9678>:
      sched_yield ();
      {
        struct __pthread_unwind_buf_t __cancel_buf;
        void (*<Tc3>) (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.9680 = __builtin_expect (__not_first_call, 0);
            if (D.9680 != 0) goto <D.9681>; else goto <D.9682>;
            <D.9681>:
            __cancel_routine (__cancel_arg);
            __pthread_unwind_next (&__cancel_buf);
            <D.9682>:
            __pthread_register_cancel (&__cancel_buf);
            thr_ret = _wapi_handle_lock_handle (handle);
            D.9664 = thr_ret != 0;
            D.9665 = (long int) D.9664;
            D.9666 = __builtin_expect (D.9665, 0);
            if (D.9666 != 0) goto <D.9683>; else goto <D.9684>;
            <D.9683>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "events.c", 404, "thr_ret == 0");
            <D.9684>:
            _wapi_handle_set_signal_state (handle, 0, 0);
            thr_ret = _wapi_handle_unlock_handle (handle);
            D.9664 = thr_ret != 0;
            D.9665 = (long int) D.9664;
            D.9666 = __builtin_expect (D.9665, 0);
            if (D.9666 != 0) goto <D.9685>; else goto <D.9686>;
            <D.9685>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "events.c", 409, "thr_ret == 0");
            <D.9686>:
            __pthread_unregister_cancel (&__cancel_buf);
            if (0 != 0) goto <D.9687>; else goto <D.9688>;
            <D.9687>:
            __cancel_routine (__cancel_arg);
            <D.9688>:
          }
        finally
          {
            __cancel_buf = {CLOBBER};
          }
      }
      <D.9679>:
      D.9660 = 1;
      return D.9660;
    }
  finally
    {
      event_handle = {CLOBBER};
    }
}


ResetEvent (void * handle)
{
  gboolean D.9698;
  gboolean (*<T12e4>) (void *) D.9699;
  WapiHandleType type;

  if (handle == 0B) goto <D.9696>; else goto <D.9697>;
  <D.9696>:
  SetLastError (6);
  D.9698 = 0;
  return D.9698;
  <D.9697>:
  type = _wapi_handle_type (handle);
  D.9699 = event_ops[type].reset;
  if (D.9699 == 0B) goto <D.9700>; else goto <D.9701>;
  <D.9700>:
  SetLastError (6);
  D.9698 = 0;
  return D.9698;
  <D.9701>:
  D.9699 = event_ops[type].reset;
  D.9698 = D.9699 (handle);
  return D.9698;
}


SetEvent (void * handle)
{
  gboolean D.9705;
  gboolean (*<T12e4>) (void *) D.9706;
  WapiHandleType type;

  if (handle == 0B) goto <D.9703>; else goto <D.9704>;
  <D.9703>:
  SetLastError (6);
  D.9705 = 0;
  return D.9705;
  <D.9704>:
  type = _wapi_handle_type (handle);
  D.9706 = event_ops[type].set;
  if (D.9706 == 0B) goto <D.9707>; else goto <D.9708>;
  <D.9707>:
  SetLastError (6);
  D.9705 = 0;
  return D.9705;
  <D.9708>:
  D.9706 = event_ops[type].set;
  D.9705 = D.9706 (handle);
  return D.9705;
}


OpenEvent (guint32 access, gboolean inherit, const gunichar2 * name)
{
  _Bool D.9710;
  long int D.9711;
  long int D.9712;
  unsigned int offset.17;
  void * D.9722;
  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.9710 = thr_ret != 0;
  D.9711 = (long int) D.9710;
  D.9712 = __builtin_expect (D.9711, 0);
  if (D.9712 != 0) goto <D.9713>; else goto <D.9714>;
  <D.9713>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "events.c", 724, "thr_ret == 0");
  <D.9714>:
  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.9715>; else goto <D.9716>;
  <D.9715>:
  SetLastError (6);
  goto cleanup;
  <D.9716>:
  if (offset == 0) goto <D.9717>; else goto <D.9718>;
  <D.9717>:
  SetLastError (2);
  goto cleanup;
  <D.9718>:
  offset.17 = (unsigned int) offset;
  handle = _wapi_handle_new_from_offset (13, offset.17, 1);
  if (handle == 4294967295B) goto <D.9720>; else goto <D.9721>;
  <D.9720>:
  monoeg_g_log (0B, 16, "%s: error opening named event handle", &__func__);
  SetLastError (31);
  goto cleanup;
  <D.9721>:
  ret = handle;
  cleanup:
  monoeg_g_free (utf8_name);
  _wapi_namespace_unlock (0B);
  D.9722 = ret;
  return D.9722;
}


