event_own (void * handle)
{
  gboolean D.9565;
  struct _WapiHandle_event * event_handle.0;
  int D.9567;
  unsigned int D.9570;
  _Bool D.9571;
  long int D.9572;
  long int D.9573;
  unsigned int D.9576;
  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.9563>; else goto <D.9564>;
      <D.9563>:
      monoeg_g_log (0B, 16, "%s: error looking up event handle %p", &__func__, handle);
      D.9565 = 0;
      return D.9565;
      <D.9564>:
      event_handle.0 = event_handle;
      D.9567 = event_handle.0->manual;
      if (D.9567 == 0) goto <D.9568>; else goto <D.9569>;
      <D.9568>:
      event_handle.0 = event_handle;
      D.9570 = event_handle.0->set_count;
      D.9571 = D.9570 == 0;
      D.9572 = (long int) D.9571;
      D.9573 = __builtin_expect (D.9572, 0);
      if (D.9573 != 0) goto <D.9574>; else goto <D.9575>;
      <D.9574>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "events.c", 121, "event_handle->set_count > 0");
      <D.9575>:
      event_handle.0 = event_handle;
      D.9570 = event_handle.0->set_count;
      D.9576 = D.9570 + 4294967295;
      event_handle.0->set_count = D.9576;
      D.9570 = event_handle.0->set_count;
      if (D.9570 == 0) goto <D.9577>; else goto <D.9578>;
      <D.9577>:
      _wapi_handle_set_signal_state (handle, 0, 0);
      <D.9578>:
      <D.9569>:
      D.9565 = 1;
      return D.9565;
    }
  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.9588;
  <unnamed type> D.9590;
  <unnamed type> D.9592;
  <unnamed type> D.9594;
  _Bool D.9595;
  long int D.9596;
  long int D.9597;
  unsigned int D.9600;
  struct _WapiHandleUnshared * D.9601;
  long unsigned int D.9602;
  long unsigned int D.9603;
  long unsigned int D.9604;
  long int D.9607;
  long int D.9608;
  union mono_mutex_t * _wapi_global_signal_mutex.3;
  _Bool D.9614;
  long int D.9615;
  long int D.9616;
  union pthread_cond_t * D.9621;
  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.9582>; else goto <D.9583>;
  <D.9582>:
  return;
  <D.9583>:
  D.9588 = _wapi_handle_type (handle);
  if (D.9588 == 9) goto <D.9585>; else goto <D.9589>;
  <D.9589>:
  D.9590 = _wapi_handle_type (handle);
  if (D.9590 == 11) goto <D.9585>; else goto <D.9591>;
  <D.9591>:
  D.9592 = _wapi_handle_type (handle);
  if (D.9592 == 12) goto <D.9585>; else goto <D.9593>;
  <D.9593>:
  D.9594 = _wapi_handle_type (handle);
  if (D.9594 == 13) goto <D.9585>; else goto <D.9586>;
  <D.9585>:
  iftmp.2 = 1;
  goto <D.9587>;
  <D.9586>:
  iftmp.2 = 0;
  <D.9587>:
  D.9595 = iftmp.2 != 0;
  D.9596 = (long int) D.9595;
  D.9597 = __builtin_expect (D.9596, 0);
  if (D.9597 != 0) goto <D.9598>; else goto <D.9599>;
  <D.9598>:
  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.9599>:
  D.9600 = idx / 256;
  D.9601 = _wapi_private_handles[D.9600];
  D.9602 = (long unsigned int) idx;
  D.9603 = D.9602 & 255;
  D.9604 = D.9603 * 200;
  handle_data = D.9601 + D.9604;
  if (state == 1) goto <D.9605>; else goto <D.9606>;
  <D.9605>:
  {
    struct __pthread_unwind_buf_t __cancel_buf;
    void (*<Tc2>) (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.9607 = (long int) __not_first_call;
        D.9608 = __builtin_expect (D.9607, 0);
        if (D.9608 != 0) goto <D.9609>; else goto <D.9610>;
        <D.9609>:
        __cancel_routine (__cancel_arg);
        __pthread_unwind_next (&__cancel_buf);
        <D.9610>:
        __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.9612>; else goto <D.9613>;
        <D.9612>:
        monoeg_g_log (0B, 16, "Bad call to mono_mutex_lock result %d for global signal mutex", thr_ret);
        <D.9613>:
        D.9614 = thr_ret != 0;
        D.9615 = (long int) D.9614;
        D.9616 = __builtin_expect (D.9615, 0);
        if (D.9616 != 0) goto <D.9617>; else goto <D.9618>;
        <D.9617>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "../../mono/io-layer/handles-private.h", 151, "thr_ret == 0");
        <D.9618>:
        handle_data->signalled = state;
        if (broadcast == 1) goto <D.9619>; else goto <D.9620>;
        <D.9619>:
        D.9621 = &handle_data->signal_cond;
        thr_ret = pthread_cond_broadcast (D.9621);
        if (thr_ret != 0) goto <D.9622>; else goto <D.9623>;
        <D.9622>:
        monoeg_g_log (0B, 16, "Bad call to pthread_cond_broadcast result %d for handle %p", thr_ret, handle);
        <D.9623>:
        D.9614 = thr_ret != 0;
        D.9615 = (long int) D.9614;
        D.9616 = __builtin_expect (D.9615, 0);
        if (D.9616 != 0) goto <D.9624>; else goto <D.9625>;
        <D.9624>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "../../mono/io-layer/handles-private.h", 162, "thr_ret == 0");
        <D.9625>:
        goto <D.9626>;
        <D.9620>:
        D.9621 = &handle_data->signal_cond;
        thr_ret = pthread_cond_signal (D.9621);
        if (thr_ret != 0) goto <D.9627>; else goto <D.9628>;
        <D.9627>:
        monoeg_g_log (0B, 16, "Bad call to pthread_cond_signal result %d for handle %p", thr_ret, handle);
        <D.9628>:
        D.9614 = thr_ret != 0;
        D.9615 = (long int) D.9614;
        D.9616 = __builtin_expect (D.9615, 0);
        if (D.9616 != 0) goto <D.9629>; else goto <D.9630>;
        <D.9629>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "../../mono/io-layer/handles-private.h", 167, "thr_ret == 0");
        <D.9630>:
        <D.9626>:
        _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.9632>; else goto <D.9633>;
        <D.9632>:
        monoeg_g_log (0B, 16, "Bad call to pthread_cond_broadcast result %d for handle %p", thr_ret, handle);
        <D.9633>:
        D.9614 = thr_ret != 0;
        D.9615 = (long int) D.9614;
        D.9616 = __builtin_expect (D.9615, 0);
        if (D.9616 != 0) goto <D.9634>; else goto <D.9635>;
        <D.9634>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "../../mono/io-layer/handles-private.h", 176, "thr_ret == 0");
        <D.9635>:
        _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.9636>; else goto <D.9637>;
        <D.9636>:
        monoeg_g_log (0B, 16, "Bad call to mono_mutex_unlock result %d for global signal mutex", thr_ret);
        <D.9637>:
        D.9614 = thr_ret != 0;
        D.9615 = (long int) D.9614;
        D.9616 = __builtin_expect (D.9615, 0);
        if (D.9616 != 0) goto <D.9638>; else goto <D.9639>;
        <D.9638>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "../../mono/io-layer/handles-private.h", 181, "thr_ret == 0");
        <D.9639>:
        __pthread_unregister_cancel (&__cancel_buf);
        if (0 != 0) goto <D.9640>; else goto <D.9641>;
        <D.9640>:
        __cancel_routine (__cancel_arg);
        <D.9641>:
      }
    finally
      {
        __cancel_buf = {CLOBBER};
      }
  }
  goto <D.9642>;
  <D.9606>:
  handle_data->signalled = state;
  <D.9642>:
}


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

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


_wapi_handle_type (void * handle)
{
  long int handle.5;
  unsigned int D.9659;
  struct _WapiHandleUnshared * D.9660;
  WapiHandleType D.9661;
  unsigned int D.9662;
  struct _WapiHandleUnshared * D.9663;
  long unsigned int D.9664;
  long unsigned int D.9665;
  long unsigned int D.9666;
  struct _WapiHandleUnshared * D.9667;
  guint32 idx;

  handle.5 = (long int) handle;
  idx = (guint32) handle.5;
  if (idx > 4194303) goto <D.9656>; else goto <D.9658>;
  <D.9658>:
  D.9659 = idx / 256;
  D.9660 = _wapi_private_handles[D.9659];
  if (D.9660 == 0B) goto <D.9656>; else goto <D.9657>;
  <D.9656>:
  D.9661 = 0;
  return D.9661;
  <D.9657>:
  D.9662 = idx / 256;
  D.9663 = _wapi_private_handles[D.9662];
  D.9664 = (long unsigned int) idx;
  D.9665 = D.9664 & 255;
  D.9666 = D.9665 * 200;
  D.9667 = D.9663 + D.9666;
  D.9661 = D.9667->type;
  return D.9661;
}


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


namedevent_own (void * handle)
{
  gboolean D.9671;
  struct _WapiHandle_namedevent * namedevent_handle.6;
  int D.9673;
  unsigned int D.9676;
  _Bool D.9677;
  long int D.9678;
  long int D.9679;
  unsigned int D.9682;
  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.9669>; else goto <D.9670>;
      <D.9669>:
      monoeg_g_log (0B, 16, "%s: error looking up named event handle %p", &__func__, handle);
      D.9671 = 0;
      return D.9671;
      <D.9670>:
      namedevent_handle.6 = namedevent_handle;
      D.9673 = namedevent_handle.6->manual;
      if (D.9673 == 0) goto <D.9674>; else goto <D.9675>;
      <D.9674>:
      namedevent_handle.6 = namedevent_handle;
      D.9676 = namedevent_handle.6->set_count;
      D.9677 = D.9676 == 0;
      D.9678 = (long int) D.9677;
      D.9679 = __builtin_expect (D.9678, 0);
      if (D.9679 != 0) goto <D.9680>; else goto <D.9681>;
      <D.9680>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "events.c", 153, "namedevent_handle->set_count > 0");
      <D.9681>:
      namedevent_handle.6 = namedevent_handle;
      D.9676 = namedevent_handle.6->set_count;
      D.9682 = D.9676 + 4294967295;
      namedevent_handle.6->set_count = D.9682;
      D.9676 = namedevent_handle.6->set_count;
      if (D.9676 == 0) goto <D.9683>; else goto <D.9684>;
      <D.9683>:
      _wapi_shared_handle_set_signal_state (handle, 0);
      <D.9684>:
      <D.9675>:
      D.9671 = 1;
      return D.9671;
    }
  finally
    {
      namedevent_handle = {CLOBBER};
    }
}


_wapi_shared_handle_set_signal_state (void * handle, gboolean state)
{
  long int handle.7;
  int iftmp.8;
  <unnamed type> D.9693;
  <unnamed type> D.9695;
  <unnamed type> D.9697;
  <unnamed type> D.9699;
  _Bool D.9701;
  long int D.9702;
  long int D.9703;
  unsigned int D.9706;
  struct _WapiHandleUnshared * D.9707;
  long unsigned int D.9708;
  long unsigned int D.9709;
  long unsigned int D.9710;
  struct _WapiHandleSharedLayout * _wapi_shared_layout.9;
  unsigned int D.9712;
  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.9688>; else goto <D.9689>;
  <D.9688>:
  return;
  <D.9689>:
  D.9693 = _wapi_handle_type (handle);
  if (D.9693 != 9) goto <D.9694>; else goto <D.9691>;
  <D.9694>:
  D.9695 = _wapi_handle_type (handle);
  if (D.9695 != 11) goto <D.9696>; else goto <D.9691>;
  <D.9696>:
  D.9697 = _wapi_handle_type (handle);
  if (D.9697 != 12) goto <D.9698>; else goto <D.9691>;
  <D.9698>:
  D.9699 = _wapi_handle_type (handle);
  if (D.9699 != 13) goto <D.9700>; else goto <D.9691>;
  <D.9700>:
  iftmp.8 = 1;
  goto <D.9692>;
  <D.9691>:
  iftmp.8 = 0;
  <D.9692>:
  D.9701 = iftmp.8 != 0;
  D.9702 = (long int) D.9701;
  D.9703 = __builtin_expect (D.9702, 0);
  if (D.9703 != 0) goto <D.9704>; else goto <D.9705>;
  <D.9704>:
  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.9705>:
  D.9706 = idx / 256;
  D.9707 = _wapi_private_handles[D.9706];
  D.9708 = (long unsigned int) idx;
  D.9709 = D.9708 & 255;
  D.9710 = D.9709 * 200;
  handle_data = D.9707 + D.9710;
  ref = &handle_data->u.shared;
  _wapi_shared_layout.9 = _wapi_shared_layout;
  D.9712 = ref->offset;
  shared_data = &_wapi_shared_layout.9->handles[D.9712];
  shared_data->signalled = state;
}


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


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

  event = handle_info;
  D.9715 = event->manual;
  if (D.9715 != 0) goto <D.9716>; else goto <D.9717>;
  <D.9716>:
  iftmp.10 = "TRUE";
  goto <D.9718>;
  <D.9717>:
  iftmp.10 = "FALSE";
  <D.9718>:
  monoeg_g_print ("manual: %s", iftmp.10);
}


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

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


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.9729;
  long int D.9730;
  long int D.9731;
  _Bool D.9734;
  long int D.9735;
  long int D.9736;
  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.9723>; else goto <D.9724>;
      <D.9723>:
      if (manual == 0) goto <D.9725>; else goto <D.9726>;
      <D.9725>:
      event_handle.set_count = 1;
      <D.9726>:
      <D.9724>:
      handle = _wapi_handle_new (6, &event_handle);
      if (handle == -1B) goto <D.9727>; else goto <D.9728>;
      <D.9727>:
      monoeg_g_log (0B, 16, "%s: error creating event handle", &__func__);
      SetLastError (31);
      D.9729 = 0B;
      return D.9729;
      <D.9728>:
      {
        struct __pthread_unwind_buf_t __cancel_buf;
        void (*<Tc2>) (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.9730 = (long int) __not_first_call;
            D.9731 = __builtin_expect (D.9730, 0);
            if (D.9731 != 0) goto <D.9732>; else goto <D.9733>;
            <D.9732>:
            __cancel_routine (__cancel_arg);
            __pthread_unwind_next (&__cancel_buf);
            <D.9733>:
            __pthread_register_cancel (&__cancel_buf);
            thr_ret = _wapi_handle_lock_handle (handle);
            D.9734 = thr_ret != 0;
            D.9735 = (long int) D.9734;
            D.9736 = __builtin_expect (D.9735, 0);
            if (D.9736 != 0) goto <D.9737>; else goto <D.9738>;
            <D.9737>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "events.c", 196, "thr_ret == 0");
            <D.9738>:
            if (initial == 1) goto <D.9739>; else goto <D.9740>;
            <D.9739>:
            _wapi_handle_set_signal_state (handle, 1, 0);
            <D.9740>:
            thr_ret = _wapi_handle_unlock_handle (handle);
            D.9734 = thr_ret != 0;
            D.9735 = (long int) D.9734;
            D.9736 = __builtin_expect (D.9735, 0);
            if (D.9736 != 0) goto <D.9741>; else goto <D.9742>;
            <D.9741>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "events.c", 205, "thr_ret == 0");
            <D.9742>:
            __pthread_unregister_cancel (&__cancel_buf);
            if (0 != 0) goto <D.9743>; else goto <D.9744>;
            <D.9743>:
            __cancel_routine (__cancel_arg);
            <D.9744>:
          }
        finally
          {
            __cancel_buf = {CLOBBER};
          }
      }
      D.9729 = handle;
      return D.9729;
    }
  finally
    {
      event_handle = {CLOBBER};
    }
}


_wapi_handle_lock_handle (void * handle)
{
  long int handle.11;
  int D.9753;
  <unnamed type> D.9756;
  <unnamed type> D.9758;
  <unnamed type> D.9760;
  <unnamed type> D.9762;
  unsigned int D.9763;
  struct _WapiHandleUnshared * D.9764;
  long unsigned int D.9765;
  long unsigned int D.9766;
  long unsigned int D.9767;
  struct _WapiHandleUnshared * D.9768;
  union mono_mutex_t * D.9769;
  guint32 idx;

  handle.11 = (long int) handle;
  idx = (guint32) handle.11;
  if (idx > 4194303) goto <D.9751>; else goto <D.9752>;
  <D.9751>:
  D.9753 = 0;
  return D.9753;
  <D.9752>:
  _wapi_handle_ref (handle);
  D.9756 = _wapi_handle_type (handle);
  if (D.9756 == 9) goto <D.9754>; else goto <D.9757>;
  <D.9757>:
  D.9758 = _wapi_handle_type (handle);
  if (D.9758 == 11) goto <D.9754>; else goto <D.9759>;
  <D.9759>:
  D.9760 = _wapi_handle_type (handle);
  if (D.9760 == 12) goto <D.9754>; else goto <D.9761>;
  <D.9761>:
  D.9762 = _wapi_handle_type (handle);
  if (D.9762 == 13) goto <D.9754>; else goto <D.9755>;
  <D.9754>:
  D.9753 = 0;
  return D.9753;
  <D.9755>:
  D.9763 = idx / 256;
  D.9764 = _wapi_private_handles[D.9763];
  D.9765 = (long unsigned int) idx;
  D.9766 = D.9765 & 255;
  D.9767 = D.9766 * 200;
  D.9768 = D.9764 + D.9767;
  D.9769 = &D.9768->signal_mutex;
  D.9753 = pthread_mutex_lock (D.9769);
  return D.9753;
}


_wapi_handle_unlock_handle (void * handle)
{
  long int handle.12;
  int D.9774;
  <unnamed type> D.9777;
  <unnamed type> D.9779;
  <unnamed type> D.9781;
  <unnamed type> D.9783;
  unsigned int D.9784;
  struct _WapiHandleUnshared * D.9785;
  long unsigned int D.9786;
  long unsigned int D.9787;
  long unsigned int D.9788;
  struct _WapiHandleUnshared * D.9789;
  union mono_mutex_t * D.9790;
  guint32 idx;
  int ret;

  handle.12 = (long int) handle;
  idx = (guint32) handle.12;
  if (idx > 4194303) goto <D.9772>; else goto <D.9773>;
  <D.9772>:
  D.9774 = 0;
  return D.9774;
  <D.9773>:
  D.9777 = _wapi_handle_type (handle);
  if (D.9777 == 9) goto <D.9775>; else goto <D.9778>;
  <D.9778>:
  D.9779 = _wapi_handle_type (handle);
  if (D.9779 == 11) goto <D.9775>; else goto <D.9780>;
  <D.9780>:
  D.9781 = _wapi_handle_type (handle);
  if (D.9781 == 12) goto <D.9775>; else goto <D.9782>;
  <D.9782>:
  D.9783 = _wapi_handle_type (handle);
  if (D.9783 == 13) goto <D.9775>; else goto <D.9776>;
  <D.9775>:
  _wapi_handle_unref (handle);
  D.9774 = 0;
  return D.9774;
  <D.9776>:
  D.9784 = idx / 256;
  D.9785 = _wapi_private_handles[D.9784];
  D.9786 = (long unsigned int) idx;
  D.9787 = D.9786 & 255;
  D.9788 = D.9787 * 200;
  D.9789 = D.9785 + D.9788;
  D.9790 = &D.9789->signal_mutex;
  ret = pthread_mutex_unlock (D.9790);
  _wapi_handle_unref (handle);
  D.9774 = ret;
  return D.9774;
}


namedevent_create (struct WapiSecurityAttributes * security, gboolean manual, gboolean initial, const gunichar2 * name)
{
  _Bool D.9792;
  long int D.9793;
  long int D.9794;
  long unsigned int D.9803;
  long unsigned int D.9806;
  long unsigned int D.9808;
  unsigned int offset.13;
  void * D.9823;
  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.9792 = thr_ret != 0;
      D.9793 = (long int) D.9792;
      D.9794 = __builtin_expect (D.9793, 0);
      if (D.9794 != 0) goto <D.9795>; else goto <D.9796>;
      <D.9795>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "events.c", 227, "thr_ret == 0");
      <D.9796>:
      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.9797>; else goto <D.9798>;
      <D.9797>:
      SetLastError (6);
      goto cleanup;
      <D.9798>:
      if (offset != 0) goto <D.9799>; else goto <D.9800>;
      <D.9799>:
      SetLastError (183);
      <D.9800>:
      if (offset == 0) goto <D.9801>; else goto <D.9802>;
      <D.9801>:
      D.9803 = strlen (utf8_name);
      if (D.9803 <= 259) goto <D.9804>; else goto <D.9805>;
      <D.9804>:
      D.9806 = strlen (utf8_name);
      namelen = (guint32) D.9806;
      goto <D.9807>;
      <D.9805>:
      namelen = 260;
      <D.9807>:
      D.9808 = (long unsigned int) namelen;
      memcpy (&namedevent_handle.sharedns.name, utf8_name, D.9808);
      namedevent_handle.manual = manual;
      namedevent_handle.set_count = 0;
      if (initial == 1) goto <D.9809>; else goto <D.9810>;
      <D.9809>:
      if (manual == 0) goto <D.9811>; else goto <D.9812>;
      <D.9811>:
      namedevent_handle.set_count = 1;
      <D.9812>:
      <D.9810>:
      handle = _wapi_handle_new (13, &namedevent_handle);
      goto <D.9813>;
      <D.9802>:
      offset.13 = (unsigned int) offset;
      handle = _wapi_handle_new_from_offset (13, offset.13, 1);
      <D.9813>:
      if (handle == -1B) goto <D.9815>; else goto <D.9816>;
      <D.9815>:
      monoeg_g_log (0B, 16, "%s: error creating event handle", &__func__);
      SetLastError (31);
      goto cleanup;
      <D.9816>:
      ret = handle;
      if (offset == 0) goto <D.9817>; else goto <D.9818>;
      <D.9817>:
      thr_ret = _wapi_handle_lock_shared_handles ();
      D.9792 = thr_ret != 0;
      D.9793 = (long int) D.9792;
      D.9794 = __builtin_expect (D.9793, 0);
      if (D.9794 != 0) goto <D.9819>; else goto <D.9820>;
      <D.9819>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "events.c", 299, "thr_ret == 0");
      <D.9820>:
      if (initial == 1) goto <D.9821>; else goto <D.9822>;
      <D.9821>:
      _wapi_shared_handle_set_signal_state (handle, 1);
      <D.9822>:
      _wapi_handle_unlock_shared_handles ();
      <D.9818>:
      cleanup:
      monoeg_g_free (utf8_name);
      _wapi_namespace_unlock (0B);
      D.9823 = ret;
      return D.9823;
    }
  finally
    {
      namedevent_handle = {CLOBBER};
    }
}


_wapi_namespace_lock ()
{
  int D.9826;

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


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

  D.9829 = __builtin_object_size (__dest, 0);
  D.9828 = __builtin___memcpy_chk (__dest, __src, __len, D.9829);
  return D.9828;
}


_wapi_handle_lock_shared_handles ()
{
  int D.9831;

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


_wapi_handle_unlock_shared_handles ()
{
  int D.9833;

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


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

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


PulseEvent (void * handle)
{
  gboolean D.9839;
  gboolean (*<T136a>) (void *) D.9840;
  WapiHandleType type;

  if (handle == 0B) goto <D.9837>; else goto <D.9838>;
  <D.9837>:
  SetLastError (6);
  D.9839 = 0;
  return D.9839;
  <D.9838>:
  type = _wapi_handle_type (handle);
  D.9840 = event_ops[type].pulse;
  if (D.9840 == 0B) goto <D.9841>; else goto <D.9842>;
  <D.9841>:
  SetLastError (6);
  D.9839 = 0;
  return D.9839;
  <D.9842>:
  D.9840 = event_ops[type].pulse;
  D.9839 = D.9840 (handle);
  return D.9839;
}


namedevent_set (void * handle)
{
  gboolean D.9846;
  _Bool D.9847;
  long int D.9848;
  long int D.9849;
  struct _WapiHandle_namedevent * namedevent_handle.14;
  int D.9853;
  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.9844>; else goto <D.9845>;
      <D.9844>:
      monoeg_g_log (0B, 16, "%s: error looking up named event handle %p", &__func__, handle);
      D.9846 = 0;
      return D.9846;
      <D.9845>:
      thr_ret = _wapi_handle_lock_shared_handles ();
      D.9847 = thr_ret != 0;
      D.9848 = (long int) D.9847;
      D.9849 = __builtin_expect (D.9848, 0);
      if (D.9849 != 0) goto <D.9850>; else goto <D.9851>;
      <D.9850>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "events.c", 661, "thr_ret == 0");
      <D.9851>:
      namedevent_handle.14 = namedevent_handle;
      D.9853 = namedevent_handle.14->manual;
      if (D.9853 == 1) goto <D.9854>; else goto <D.9855>;
      <D.9854>:
      _wapi_shared_handle_set_signal_state (handle, 1);
      goto <D.9856>;
      <D.9855>:
      namedevent_handle.14 = namedevent_handle;
      namedevent_handle.14->set_count = 1;
      _wapi_shared_handle_set_signal_state (handle, 1);
      <D.9856>:
      _wapi_handle_unlock_shared_handles ();
      D.9846 = 1;
      return D.9846;
    }
  finally
    {
      namedevent_handle = {CLOBBER};
    }
}


namedevent_reset (void * handle)
{
  gboolean D.9861;
  _Bool D.9862;
  long int D.9863;
  long int D.9864;
  int D.9867;
  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.9859>; else goto <D.9860>;
      <D.9859>:
      monoeg_g_log (0B, 16, "%s: error looking up named event handle %p", &__func__, handle);
      D.9861 = 0;
      return D.9861;
      <D.9860>:
      thr_ret = _wapi_handle_lock_shared_handles ();
      D.9862 = thr_ret != 0;
      D.9863 = (long int) D.9862;
      D.9864 = __builtin_expect (D.9863, 0);
      if (D.9864 != 0) goto <D.9865>; else goto <D.9866>;
      <D.9865>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "events.c", 563, "thr_ret == 0");
      <D.9866>:
      D.9867 = _wapi_handle_issignalled (handle);
      if (D.9867 == 0) goto <D.9868>; else goto <D.9869>;
      <D.9868>:
      goto <D.9870>;
      <D.9869>:
      _wapi_shared_handle_set_signal_state (handle, 0);
      <D.9870>:
      namedevent_handle.15 = namedevent_handle;
      namedevent_handle.15->set_count = 0;
      _wapi_handle_unlock_shared_handles ();
      D.9861 = 1;
      return D.9861;
    }
  finally
    {
      namedevent_handle = {CLOBBER};
    }
}


_wapi_handle_issignalled (void * handle)
{
  long int handle.16;
  gboolean D.9877;
  <unnamed type> D.9880;
  <unnamed type> D.9882;
  <unnamed type> D.9884;
  <unnamed type> D.9886;
  struct _WapiHandleSharedLayout * _wapi_shared_layout.17;
  unsigned int D.9888;
  unsigned int D.9889;
  struct _WapiHandleUnshared * D.9890;
  long unsigned int D.9891;
  long unsigned int D.9892;
  long unsigned int D.9893;
  struct _WapiHandleUnshared * D.9894;
  unsigned int D.9895;
  unsigned int D.9896;
  struct _WapiHandleUnshared * D.9897;
  long unsigned int D.9898;
  long unsigned int D.9899;
  long unsigned int D.9900;
  struct _WapiHandleUnshared * D.9901;
  guint32 idx;

  handle.16 = (long int) handle;
  idx = (guint32) handle.16;
  if (idx > 4194303) goto <D.9875>; else goto <D.9876>;
  <D.9875>:
  D.9877 = 0;
  return D.9877;
  <D.9876>:
  D.9880 = _wapi_handle_type (handle);
  if (D.9880 == 9) goto <D.9878>; else goto <D.9881>;
  <D.9881>:
  D.9882 = _wapi_handle_type (handle);
  if (D.9882 == 11) goto <D.9878>; else goto <D.9883>;
  <D.9883>:
  D.9884 = _wapi_handle_type (handle);
  if (D.9884 == 12) goto <D.9878>; else goto <D.9885>;
  <D.9885>:
  D.9886 = _wapi_handle_type (handle);
  if (D.9886 == 13) goto <D.9878>; else goto <D.9879>;
  <D.9878>:
  _wapi_shared_layout.17 = _wapi_shared_layout;
  handle.16 = (long int) handle;
  D.9888 = (unsigned int) handle.16;
  D.9889 = D.9888 / 256;
  D.9890 = _wapi_private_handles[D.9889];
  handle.16 = (long int) handle;
  D.9888 = (unsigned int) handle.16;
  D.9891 = (long unsigned int) D.9888;
  D.9892 = D.9891 & 255;
  D.9893 = D.9892 * 200;
  D.9894 = D.9890 + D.9893;
  D.9895 = D.9894->u.shared.offset;
  D.9877 = _wapi_shared_layout.17->handles[D.9895].signalled;
  return D.9877;
  <D.9879>:
  D.9896 = idx / 256;
  D.9897 = _wapi_private_handles[D.9896];
  D.9898 = (long unsigned int) idx;
  D.9899 = D.9898 & 255;
  D.9900 = D.9899 * 200;
  D.9901 = D.9897 + D.9900;
  D.9877 = D.9901->signalled;
  return D.9877;
}


namedevent_pulse (void * handle)
{
  gboolean D.9905;
  _Bool D.9906;
  long int D.9907;
  long int D.9908;
  struct _WapiHandle_namedevent * namedevent_handle.18;
  int D.9912;
  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.9903>; else goto <D.9904>;
      <D.9903>:
      monoeg_g_log (0B, 16, "%s: error looking up named event handle %p", &__func__, handle);
      D.9905 = 0;
      return D.9905;
      <D.9904>:
      thr_ret = _wapi_handle_lock_shared_handles ();
      D.9906 = thr_ret != 0;
      D.9907 = (long int) D.9906;
      D.9908 = __builtin_expect (D.9907, 0);
      if (D.9908 != 0) goto <D.9909>; else goto <D.9910>;
      <D.9909>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "events.c", 431, "thr_ret == 0");
      <D.9910>:
      namedevent_handle.18 = namedevent_handle;
      D.9912 = namedevent_handle.18->manual;
      if (D.9912 == 1) goto <D.9913>; else goto <D.9914>;
      <D.9913>:
      _wapi_shared_handle_set_signal_state (handle, 1);
      goto <D.9915>;
      <D.9914>:
      namedevent_handle.18 = namedevent_handle;
      namedevent_handle.18->set_count = 1;
      _wapi_shared_handle_set_signal_state (handle, 1);
      <D.9915>:
      _wapi_handle_unlock_shared_handles ();
      namedevent_handle.18 = namedevent_handle;
      D.9912 = namedevent_handle.18->manual;
      if (D.9912 == 1) goto <D.9916>; else goto <D.9917>;
      <D.9916>:
      _wapi_handle_spin (200);
      thr_ret = _wapi_handle_lock_shared_handles ();
      D.9906 = thr_ret != 0;
      D.9907 = (long int) D.9906;
      D.9908 = __builtin_expect (D.9907, 0);
      if (D.9908 != 0) goto <D.9918>; else goto <D.9919>;
      <D.9918>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "events.c", 461, "thr_ret == 0");
      <D.9919>:
      _wapi_shared_handle_set_signal_state (handle, 0);
      _wapi_handle_unlock_shared_handles ();
      <D.9917>:
      D.9905 = 1;
      return D.9905;
    }
  finally
    {
      namedevent_handle = {CLOBBER};
    }
}


_wapi_handle_spin (guint32 ms)
{
  _Bool D.9922;
  long int D.9923;
  long int D.9924;
  unsigned int D.9927;
  long int D.9928;
  struct timespec sleepytime;

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


event_set (void * handle)
{
  gboolean D.9931;
  long int D.9932;
  long int D.9933;
  _Bool D.9936;
  long int D.9937;
  long int D.9938;
  struct _WapiHandle_event * event_handle.19;
  int D.9942;
  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.9929>; else goto <D.9930>;
      <D.9929>:
      monoeg_g_log (0B, 16, "%s: error looking up event handle %p", &__func__, handle);
      D.9931 = 0;
      return D.9931;
      <D.9930>:
      {
        struct __pthread_unwind_buf_t __cancel_buf;
        void (*<Tc2>) (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.9932 = (long int) __not_first_call;
            D.9933 = __builtin_expect (D.9932, 0);
            if (D.9933 != 0) goto <D.9934>; else goto <D.9935>;
            <D.9934>:
            __cancel_routine (__cancel_arg);
            __pthread_unwind_next (&__cancel_buf);
            <D.9935>:
            __pthread_register_cancel (&__cancel_buf);
            thr_ret = _wapi_handle_lock_handle (handle);
            D.9936 = thr_ret != 0;
            D.9937 = (long int) D.9936;
            D.9938 = __builtin_expect (D.9937, 0);
            if (D.9938 != 0) goto <D.9939>; else goto <D.9940>;
            <D.9939>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "events.c", 627, "thr_ret == 0");
            <D.9940>:
            event_handle.19 = event_handle;
            D.9942 = event_handle.19->manual;
            if (D.9942 == 1) goto <D.9943>; else goto <D.9944>;
            <D.9943>:
            _wapi_handle_set_signal_state (handle, 1, 1);
            goto <D.9945>;
            <D.9944>:
            event_handle.19 = event_handle;
            event_handle.19->set_count = 1;
            _wapi_handle_set_signal_state (handle, 1, 0);
            <D.9945>:
            thr_ret = _wapi_handle_unlock_handle (handle);
            D.9936 = thr_ret != 0;
            D.9937 = (long int) D.9936;
            D.9938 = __builtin_expect (D.9937, 0);
            if (D.9938 != 0) goto <D.9946>; else goto <D.9947>;
            <D.9946>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "events.c", 639, "thr_ret == 0");
            <D.9947>:
            __pthread_unregister_cancel (&__cancel_buf);
            if (0 != 0) goto <D.9948>; else goto <D.9949>;
            <D.9948>:
            __cancel_routine (__cancel_arg);
            <D.9949>:
          }
        finally
          {
            __cancel_buf = {CLOBBER};
          }
      }
      D.9931 = 1;
      return D.9931;
    }
  finally
    {
      event_handle = {CLOBBER};
    }
}


event_reset (void * handle)
{
  gboolean D.9957;
  long int D.9958;
  long int D.9959;
  _Bool D.9962;
  long int D.9963;
  long int D.9964;
  int D.9967;
  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.9955>; else goto <D.9956>;
      <D.9955>:
      monoeg_g_log (0B, 16, "%s: error looking up event handle %p", &__func__, handle);
      D.9957 = 0;
      return D.9957;
      <D.9956>:
      {
        struct __pthread_unwind_buf_t __cancel_buf;
        void (*<Tc2>) (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.9958 = (long int) __not_first_call;
            D.9959 = __builtin_expect (D.9958, 0);
            if (D.9959 != 0) goto <D.9960>; else goto <D.9961>;
            <D.9960>:
            __cancel_routine (__cancel_arg);
            __pthread_unwind_next (&__cancel_buf);
            <D.9961>:
            __pthread_register_cancel (&__cancel_buf);
            thr_ret = _wapi_handle_lock_handle (handle);
            D.9962 = thr_ret != 0;
            D.9963 = (long int) D.9962;
            D.9964 = __builtin_expect (D.9963, 0);
            if (D.9964 != 0) goto <D.9965>; else goto <D.9966>;
            <D.9965>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "events.c", 524, "thr_ret == 0");
            <D.9966>:
            D.9967 = _wapi_handle_issignalled (handle);
            if (D.9967 == 0) goto <D.9968>; else goto <D.9969>;
            <D.9968>:
            goto <D.9970>;
            <D.9969>:
            _wapi_handle_set_signal_state (handle, 0, 0);
            <D.9970>:
            event_handle.20 = event_handle;
            event_handle.20->set_count = 0;
            thr_ret = _wapi_handle_unlock_handle (handle);
            D.9962 = thr_ret != 0;
            D.9963 = (long int) D.9962;
            D.9964 = __builtin_expect (D.9963, 0);
            if (D.9964 != 0) goto <D.9972>; else goto <D.9973>;
            <D.9972>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "events.c", 539, "thr_ret == 0");
            <D.9973>:
            __pthread_unregister_cancel (&__cancel_buf);
            if (0 != 0) goto <D.9974>; else goto <D.9975>;
            <D.9974>:
            __cancel_routine (__cancel_arg);
            <D.9975>:
          }
        finally
          {
            __cancel_buf = {CLOBBER};
          }
      }
      D.9957 = 1;
      return D.9957;
    }
  finally
    {
      event_handle = {CLOBBER};
    }
}


event_pulse (void * handle)
{
  gboolean D.9984;
  long int D.9985;
  long int D.9986;
  _Bool D.9989;
  long int D.9990;
  long int D.9991;
  struct _WapiHandle_event * event_handle.21;
  int D.9995;
  long int D.10005;
  long int D.10006;
  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.9982>; else goto <D.9983>;
      <D.9982>:
      monoeg_g_log (0B, 16, "%s: error looking up event handle %p", &__func__, handle);
      D.9984 = 0;
      return D.9984;
      <D.9983>:
      {
        struct __pthread_unwind_buf_t __cancel_buf;
        void (*<Tc2>) (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.9985 = (long int) __not_first_call;
            D.9986 = __builtin_expect (D.9985, 0);
            if (D.9986 != 0) goto <D.9987>; else goto <D.9988>;
            <D.9987>:
            __cancel_routine (__cancel_arg);
            __pthread_unwind_next (&__cancel_buf);
            <D.9988>:
            __pthread_register_cancel (&__cancel_buf);
            thr_ret = _wapi_handle_lock_handle (handle);
            D.9989 = thr_ret != 0;
            D.9990 = (long int) D.9989;
            D.9991 = __builtin_expect (D.9990, 0);
            if (D.9991 != 0) goto <D.9992>; else goto <D.9993>;
            <D.9992>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "events.c", 370, "thr_ret == 0");
            <D.9993>:
            event_handle.21 = event_handle;
            D.9995 = event_handle.21->manual;
            if (D.9995 == 1) goto <D.9996>; else goto <D.9997>;
            <D.9996>:
            _wapi_handle_set_signal_state (handle, 1, 1);
            goto <D.9998>;
            <D.9997>:
            event_handle.21 = event_handle;
            event_handle.21->set_count = 1;
            _wapi_handle_set_signal_state (handle, 1, 0);
            <D.9998>:
            thr_ret = _wapi_handle_unlock_handle (handle);
            D.9989 = thr_ret != 0;
            D.9990 = (long int) D.9989;
            D.9991 = __builtin_expect (D.9990, 0);
            if (D.9991 != 0) goto <D.9999>; else goto <D.10000>;
            <D.9999>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "events.c", 382, "thr_ret == 0");
            <D.10000>:
            __pthread_unregister_cancel (&__cancel_buf);
            if (0 != 0) goto <D.10001>; else goto <D.10002>;
            <D.10001>:
            __cancel_routine (__cancel_arg);
            <D.10002>:
          }
        finally
          {
            __cancel_buf = {CLOBBER};
          }
      }
      event_handle.21 = event_handle;
      D.9995 = event_handle.21->manual;
      if (D.9995 == 1) goto <D.10003>; else goto <D.10004>;
      <D.10003>:
      sched_yield ();
      {
        struct __pthread_unwind_buf_t __cancel_buf;
        void (*<Tc2>) (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.10005 = (long int) __not_first_call;
            D.10006 = __builtin_expect (D.10005, 0);
            if (D.10006 != 0) goto <D.10007>; else goto <D.10008>;
            <D.10007>:
            __cancel_routine (__cancel_arg);
            __pthread_unwind_next (&__cancel_buf);
            <D.10008>:
            __pthread_register_cancel (&__cancel_buf);
            thr_ret = _wapi_handle_lock_handle (handle);
            D.9989 = thr_ret != 0;
            D.9990 = (long int) D.9989;
            D.9991 = __builtin_expect (D.9990, 0);
            if (D.9991 != 0) goto <D.10009>; else goto <D.10010>;
            <D.10009>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "events.c", 404, "thr_ret == 0");
            <D.10010>:
            _wapi_handle_set_signal_state (handle, 0, 0);
            thr_ret = _wapi_handle_unlock_handle (handle);
            D.9989 = thr_ret != 0;
            D.9990 = (long int) D.9989;
            D.9991 = __builtin_expect (D.9990, 0);
            if (D.9991 != 0) goto <D.10011>; else goto <D.10012>;
            <D.10011>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "events.c", 409, "thr_ret == 0");
            <D.10012>:
            __pthread_unregister_cancel (&__cancel_buf);
            if (0 != 0) goto <D.10013>; else goto <D.10014>;
            <D.10013>:
            __cancel_routine (__cancel_arg);
            <D.10014>:
          }
        finally
          {
            __cancel_buf = {CLOBBER};
          }
      }
      <D.10004>:
      D.9984 = 1;
      return D.9984;
    }
  finally
    {
      event_handle = {CLOBBER};
    }
}


ResetEvent (void * handle)
{
  gboolean D.10024;
  gboolean (*<T136a>) (void *) D.10025;
  WapiHandleType type;

  if (handle == 0B) goto <D.10022>; else goto <D.10023>;
  <D.10022>:
  SetLastError (6);
  D.10024 = 0;
  return D.10024;
  <D.10023>:
  type = _wapi_handle_type (handle);
  D.10025 = event_ops[type].reset;
  if (D.10025 == 0B) goto <D.10026>; else goto <D.10027>;
  <D.10026>:
  SetLastError (6);
  D.10024 = 0;
  return D.10024;
  <D.10027>:
  D.10025 = event_ops[type].reset;
  D.10024 = D.10025 (handle);
  return D.10024;
}


SetEvent (void * handle)
{
  gboolean D.10031;
  gboolean (*<T136a>) (void *) D.10032;
  WapiHandleType type;

  if (handle == 0B) goto <D.10029>; else goto <D.10030>;
  <D.10029>:
  SetLastError (6);
  D.10031 = 0;
  return D.10031;
  <D.10030>:
  type = _wapi_handle_type (handle);
  D.10032 = event_ops[type].set;
  if (D.10032 == 0B) goto <D.10033>; else goto <D.10034>;
  <D.10033>:
  SetLastError (6);
  D.10031 = 0;
  return D.10031;
  <D.10034>:
  D.10032 = event_ops[type].set;
  D.10031 = D.10032 (handle);
  return D.10031;
}


OpenEvent (guint32 access, gboolean inherit, const gunichar2 * name)
{
  _Bool D.10036;
  long int D.10037;
  long int D.10038;
  unsigned int offset.22;
  void * D.10048;
  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.10036 = thr_ret != 0;
  D.10037 = (long int) D.10036;
  D.10038 = __builtin_expect (D.10037, 0);
  if (D.10038 != 0) goto <D.10039>; else goto <D.10040>;
  <D.10039>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "events.c", 724, "thr_ret == 0");
  <D.10040>:
  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.10041>; else goto <D.10042>;
  <D.10041>:
  SetLastError (6);
  goto cleanup;
  <D.10042>:
  if (offset == 0) goto <D.10043>; else goto <D.10044>;
  <D.10043>:
  SetLastError (2);
  goto cleanup;
  <D.10044>:
  offset.22 = (unsigned int) offset;
  handle = _wapi_handle_new_from_offset (13, offset.22, 1);
  if (handle == -1B) goto <D.10046>; else goto <D.10047>;
  <D.10046>:
  monoeg_g_log (0B, 16, "%s: error opening named event handle", &__func__);
  SetLastError (31);
  goto cleanup;
  <D.10047>:
  ret = handle;
  cleanup:
  monoeg_g_free (utf8_name);
  _wapi_namespace_unlock (0B);
  D.10048 = ret;
  return D.10048;
}


