event_own (void * handle)
{
  gboolean D.9738;
  struct _WapiHandle_event * event_handle.0;
  int D.9740;
  unsigned int D.9743;
  _Bool D.9744;
  long int D.9745;
  long int D.9746;
  unsigned int D.9749;
  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.9736>; else goto <D.9737>;
      <D.9736>:
      monoeg_g_log (0B, 16, "%s: error looking up event handle %p", &__func__, handle);
      D.9738 = 0;
      return D.9738;
      <D.9737>:
      event_handle.0 = event_handle;
      D.9740 = event_handle.0->manual;
      if (D.9740 == 0) goto <D.9741>; else goto <D.9742>;
      <D.9741>:
      event_handle.0 = event_handle;
      D.9743 = event_handle.0->set_count;
      D.9744 = D.9743 == 0;
      D.9745 = (long int) D.9744;
      D.9746 = __builtin_expect (D.9745, 0);
      if (D.9746 != 0) goto <D.9747>; else goto <D.9748>;
      <D.9747>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "events.c", 121, "event_handle->set_count > 0");
      <D.9748>:
      event_handle.0 = event_handle;
      D.9743 = event_handle.0->set_count;
      D.9749 = D.9743 + 4294967295;
      event_handle.0->set_count = D.9749;
      D.9743 = event_handle.0->set_count;
      if (D.9743 == 0) goto <D.9750>; else goto <D.9751>;
      <D.9750>:
      _wapi_handle_set_signal_state (handle, 0, 0);
      <D.9751>:
      <D.9742>:
      D.9738 = 1;
      return D.9738;
    }
  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.9761;
  <unnamed type> D.9763;
  <unnamed type> D.9765;
  <unnamed type> D.9767;
  _Bool D.9768;
  long int D.9769;
  long int D.9770;
  unsigned int D.9773;
  struct _WapiHandleUnshared * D.9774;
  long unsigned int D.9775;
  long unsigned int D.9776;
  long unsigned int D.9777;
  long int D.9780;
  long int D.9781;
  union mono_mutex_t * _wapi_global_signal_mutex.3;
  _Bool D.9787;
  long int D.9788;
  long int D.9789;
  union pthread_cond_t * D.9794;
  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.9755>; else goto <D.9756>;
  <D.9755>:
  return;
  <D.9756>:
  D.9761 = _wapi_handle_type (handle);
  if (D.9761 == 9) goto <D.9758>; else goto <D.9762>;
  <D.9762>:
  D.9763 = _wapi_handle_type (handle);
  if (D.9763 == 11) goto <D.9758>; else goto <D.9764>;
  <D.9764>:
  D.9765 = _wapi_handle_type (handle);
  if (D.9765 == 12) goto <D.9758>; else goto <D.9766>;
  <D.9766>:
  D.9767 = _wapi_handle_type (handle);
  if (D.9767 == 13) goto <D.9758>; else goto <D.9759>;
  <D.9758>:
  iftmp.2 = 1;
  goto <D.9760>;
  <D.9759>:
  iftmp.2 = 0;
  <D.9760>:
  D.9768 = iftmp.2 != 0;
  D.9769 = (long int) D.9768;
  D.9770 = __builtin_expect (D.9769, 0);
  if (D.9770 != 0) goto <D.9771>; else goto <D.9772>;
  <D.9771>:
  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.9772>:
  D.9773 = idx / 256;
  D.9774 = _wapi_private_handles[D.9773];
  D.9775 = (long unsigned int) idx;
  D.9776 = D.9775 & 255;
  D.9777 = D.9776 * 200;
  handle_data = D.9774 + D.9777;
  if (state == 1) goto <D.9778>; else goto <D.9779>;
  <D.9778>:
  {
    struct __pthread_unwind_buf_t __cancel_buf;
    void (*<Tc6>) (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.9780 = (long int) __not_first_call;
        D.9781 = __builtin_expect (D.9780, 0);
        if (D.9781 != 0) goto <D.9782>; else goto <D.9783>;
        <D.9782>:
        __cancel_routine (__cancel_arg);
        __pthread_unwind_next (&__cancel_buf);
        <D.9783>:
        __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.9785>; else goto <D.9786>;
        <D.9785>:
        monoeg_g_log (0B, 16, "Bad call to mono_mutex_lock result %d for global signal mutex", thr_ret);
        <D.9786>:
        D.9787 = thr_ret != 0;
        D.9788 = (long int) D.9787;
        D.9789 = __builtin_expect (D.9788, 0);
        if (D.9789 != 0) goto <D.9790>; else goto <D.9791>;
        <D.9790>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "../../mono/io-layer/handles-private.h", 151, "thr_ret == 0");
        <D.9791>:
        handle_data->signalled = state;
        if (broadcast == 1) goto <D.9792>; else goto <D.9793>;
        <D.9792>:
        D.9794 = &handle_data->signal_cond;
        thr_ret = pthread_cond_broadcast (D.9794);
        if (thr_ret != 0) goto <D.9795>; else goto <D.9796>;
        <D.9795>:
        monoeg_g_log (0B, 16, "Bad call to pthread_cond_broadcast result %d for handle %p", thr_ret, handle);
        <D.9796>:
        D.9787 = thr_ret != 0;
        D.9788 = (long int) D.9787;
        D.9789 = __builtin_expect (D.9788, 0);
        if (D.9789 != 0) goto <D.9797>; else goto <D.9798>;
        <D.9797>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "../../mono/io-layer/handles-private.h", 162, "thr_ret == 0");
        <D.9798>:
        goto <D.9799>;
        <D.9793>:
        D.9794 = &handle_data->signal_cond;
        thr_ret = pthread_cond_signal (D.9794);
        if (thr_ret != 0) goto <D.9800>; else goto <D.9801>;
        <D.9800>:
        monoeg_g_log (0B, 16, "Bad call to pthread_cond_signal result %d for handle %p", thr_ret, handle);
        <D.9801>:
        D.9787 = thr_ret != 0;
        D.9788 = (long int) D.9787;
        D.9789 = __builtin_expect (D.9788, 0);
        if (D.9789 != 0) goto <D.9802>; else goto <D.9803>;
        <D.9802>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "../../mono/io-layer/handles-private.h", 167, "thr_ret == 0");
        <D.9803>:
        <D.9799>:
        _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.9805>; else goto <D.9806>;
        <D.9805>:
        monoeg_g_log (0B, 16, "Bad call to pthread_cond_broadcast result %d for handle %p", thr_ret, handle);
        <D.9806>:
        D.9787 = thr_ret != 0;
        D.9788 = (long int) D.9787;
        D.9789 = __builtin_expect (D.9788, 0);
        if (D.9789 != 0) goto <D.9807>; else goto <D.9808>;
        <D.9807>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "../../mono/io-layer/handles-private.h", 176, "thr_ret == 0");
        <D.9808>:
        _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.9809>; else goto <D.9810>;
        <D.9809>:
        monoeg_g_log (0B, 16, "Bad call to mono_mutex_unlock result %d for global signal mutex", thr_ret);
        <D.9810>:
        D.9787 = thr_ret != 0;
        D.9788 = (long int) D.9787;
        D.9789 = __builtin_expect (D.9788, 0);
        if (D.9789 != 0) goto <D.9811>; else goto <D.9812>;
        <D.9811>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "../../mono/io-layer/handles-private.h", 181, "thr_ret == 0");
        <D.9812>:
        __pthread_unregister_cancel (&__cancel_buf);
        if (0 != 0) goto <D.9813>; else goto <D.9814>;
        <D.9813>:
        __cancel_routine (__cancel_arg);
        <D.9814>:
      }
    finally
      {
        __cancel_buf = {CLOBBER};
      }
  }
  goto <D.9815>;
  <D.9779>:
  handle_data->signalled = state;
  <D.9815>:
}


__attribute__((__unused__))
mono_mutex_unlock_in_cleanup (union mono_mutex_t * mutex)
{
  int D.9826;

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


_wapi_handle_type (void * handle)
{
  long int handle.5;
  unsigned int D.9833;
  struct _WapiHandleUnshared * D.9834;
  WapiHandleType D.9835;
  unsigned int D.9836;
  struct _WapiHandleUnshared * D.9837;
  long unsigned int D.9838;
  long unsigned int D.9839;
  long unsigned int D.9840;
  struct _WapiHandleUnshared * D.9841;
  guint32 idx;

  handle.5 = (long int) handle;
  idx = (guint32) handle.5;
  if (idx > 4194303) goto <D.9829>; else goto <D.9831>;
  <D.9831>:
  if (idx > 268435455) goto <D.9829>; else goto <D.9832>;
  <D.9832>:
  D.9833 = idx / 256;
  D.9834 = _wapi_private_handles[D.9833];
  if (D.9834 == 0B) goto <D.9829>; else goto <D.9830>;
  <D.9829>:
  D.9835 = 0;
  return D.9835;
  <D.9830>:
  D.9836 = idx / 256;
  D.9837 = _wapi_private_handles[D.9836];
  D.9838 = (long unsigned int) idx;
  D.9839 = D.9838 & 255;
  D.9840 = D.9839 * 200;
  D.9841 = D.9837 + D.9840;
  D.9835 = D.9841->type;
  return D.9835;
}


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


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


_wapi_shared_handle_set_signal_state (void * handle, gboolean state)
{
  long int handle.7;
  int iftmp.8;
  <unnamed type> D.9867;
  <unnamed type> D.9869;
  <unnamed type> D.9871;
  <unnamed type> D.9873;
  _Bool D.9875;
  long int D.9876;
  long int D.9877;
  unsigned int D.9880;
  struct _WapiHandleUnshared * D.9881;
  long unsigned int D.9882;
  long unsigned int D.9883;
  long unsigned int D.9884;
  struct _WapiHandleSharedLayout * _wapi_shared_layout.9;
  unsigned int D.9886;
  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.9862>; else goto <D.9863>;
  <D.9862>:
  return;
  <D.9863>:
  D.9867 = _wapi_handle_type (handle);
  if (D.9867 != 9) goto <D.9868>; else goto <D.9865>;
  <D.9868>:
  D.9869 = _wapi_handle_type (handle);
  if (D.9869 != 11) goto <D.9870>; else goto <D.9865>;
  <D.9870>:
  D.9871 = _wapi_handle_type (handle);
  if (D.9871 != 12) goto <D.9872>; else goto <D.9865>;
  <D.9872>:
  D.9873 = _wapi_handle_type (handle);
  if (D.9873 != 13) goto <D.9874>; else goto <D.9865>;
  <D.9874>:
  iftmp.8 = 1;
  goto <D.9866>;
  <D.9865>:
  iftmp.8 = 0;
  <D.9866>:
  D.9875 = iftmp.8 != 0;
  D.9876 = (long int) D.9875;
  D.9877 = __builtin_expect (D.9876, 0);
  if (D.9877 != 0) goto <D.9878>; else goto <D.9879>;
  <D.9878>:
  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.9879>:
  D.9880 = idx / 256;
  D.9881 = _wapi_private_handles[D.9880];
  D.9882 = (long unsigned int) idx;
  D.9883 = D.9882 & 255;
  D.9884 = D.9883 * 200;
  handle_data = D.9881 + D.9884;
  ref = &handle_data->u.shared;
  _wapi_shared_layout.9 = _wapi_shared_layout;
  D.9886 = ref->offset;
  shared_data = &_wapi_shared_layout.9->handles[D.9886];
  shared_data->signalled = state;
}


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


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

  event = handle_info;
  D.9889 = event->manual;
  if (D.9889 != 0) goto <D.9890>; else goto <D.9891>;
  <D.9890>:
  iftmp.10 = "TRUE";
  goto <D.9892>;
  <D.9891>:
  iftmp.10 = "FALSE";
  <D.9892>:
  monoeg_g_print ("manual: %s", iftmp.10);
}


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

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


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.9903;
  long int D.9904;
  long int D.9905;
  _Bool D.9908;
  long int D.9909;
  long int D.9910;
  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.9897>; else goto <D.9898>;
      <D.9897>:
      if (manual == 0) goto <D.9899>; else goto <D.9900>;
      <D.9899>:
      event_handle.set_count = 1;
      <D.9900>:
      <D.9898>:
      handle = _wapi_handle_new (6, &event_handle);
      if (handle == -1B) goto <D.9901>; else goto <D.9902>;
      <D.9901>:
      monoeg_g_log (0B, 16, "%s: error creating event handle", &__func__);
      SetLastError (31);
      D.9903 = 0B;
      return D.9903;
      <D.9902>:
      {
        struct __pthread_unwind_buf_t __cancel_buf;
        void (*<Tc6>) (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.9904 = (long int) __not_first_call;
            D.9905 = __builtin_expect (D.9904, 0);
            if (D.9905 != 0) goto <D.9906>; else goto <D.9907>;
            <D.9906>:
            __cancel_routine (__cancel_arg);
            __pthread_unwind_next (&__cancel_buf);
            <D.9907>:
            __pthread_register_cancel (&__cancel_buf);
            thr_ret = _wapi_handle_lock_handle (handle);
            D.9908 = thr_ret != 0;
            D.9909 = (long int) D.9908;
            D.9910 = __builtin_expect (D.9909, 0);
            if (D.9910 != 0) goto <D.9911>; else goto <D.9912>;
            <D.9911>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "events.c", 196, "thr_ret == 0");
            <D.9912>:
            if (initial == 1) goto <D.9913>; else goto <D.9914>;
            <D.9913>:
            _wapi_handle_set_signal_state (handle, 1, 0);
            <D.9914>:
            thr_ret = _wapi_handle_unlock_handle (handle);
            D.9908 = thr_ret != 0;
            D.9909 = (long int) D.9908;
            D.9910 = __builtin_expect (D.9909, 0);
            if (D.9910 != 0) goto <D.9915>; else goto <D.9916>;
            <D.9915>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "events.c", 205, "thr_ret == 0");
            <D.9916>:
            __pthread_unregister_cancel (&__cancel_buf);
            if (0 != 0) goto <D.9917>; else goto <D.9918>;
            <D.9917>:
            __cancel_routine (__cancel_arg);
            <D.9918>:
          }
        finally
          {
            __cancel_buf = {CLOBBER};
          }
      }
      D.9903 = handle;
      return D.9903;
    }
  finally
    {
      event_handle = {CLOBBER};
    }
}


_wapi_handle_lock_handle (void * handle)
{
  long int handle.11;
  int D.9927;
  <unnamed type> D.9930;
  <unnamed type> D.9932;
  <unnamed type> D.9934;
  <unnamed type> D.9936;
  unsigned int D.9937;
  struct _WapiHandleUnshared * D.9938;
  long unsigned int D.9939;
  long unsigned int D.9940;
  long unsigned int D.9941;
  struct _WapiHandleUnshared * D.9942;
  union mono_mutex_t * D.9943;
  guint32 idx;

  handle.11 = (long int) handle;
  idx = (guint32) handle.11;
  if (idx > 4194303) goto <D.9925>; else goto <D.9926>;
  <D.9925>:
  D.9927 = 0;
  return D.9927;
  <D.9926>:
  _wapi_handle_ref (handle);
  D.9930 = _wapi_handle_type (handle);
  if (D.9930 == 9) goto <D.9928>; else goto <D.9931>;
  <D.9931>:
  D.9932 = _wapi_handle_type (handle);
  if (D.9932 == 11) goto <D.9928>; else goto <D.9933>;
  <D.9933>:
  D.9934 = _wapi_handle_type (handle);
  if (D.9934 == 12) goto <D.9928>; else goto <D.9935>;
  <D.9935>:
  D.9936 = _wapi_handle_type (handle);
  if (D.9936 == 13) goto <D.9928>; else goto <D.9929>;
  <D.9928>:
  D.9927 = 0;
  return D.9927;
  <D.9929>:
  D.9937 = idx / 256;
  D.9938 = _wapi_private_handles[D.9937];
  D.9939 = (long unsigned int) idx;
  D.9940 = D.9939 & 255;
  D.9941 = D.9940 * 200;
  D.9942 = D.9938 + D.9941;
  D.9943 = &D.9942->signal_mutex;
  D.9927 = pthread_mutex_lock (D.9943);
  return D.9927;
}


_wapi_handle_unlock_handle (void * handle)
{
  long int handle.12;
  int D.9948;
  <unnamed type> D.9951;
  <unnamed type> D.9953;
  <unnamed type> D.9955;
  <unnamed type> D.9957;
  unsigned int D.9958;
  struct _WapiHandleUnshared * D.9959;
  long unsigned int D.9960;
  long unsigned int D.9961;
  long unsigned int D.9962;
  struct _WapiHandleUnshared * D.9963;
  union mono_mutex_t * D.9964;
  guint32 idx;
  int ret;

  handle.12 = (long int) handle;
  idx = (guint32) handle.12;
  if (idx > 4194303) goto <D.9946>; else goto <D.9947>;
  <D.9946>:
  D.9948 = 0;
  return D.9948;
  <D.9947>:
  D.9951 = _wapi_handle_type (handle);
  if (D.9951 == 9) goto <D.9949>; else goto <D.9952>;
  <D.9952>:
  D.9953 = _wapi_handle_type (handle);
  if (D.9953 == 11) goto <D.9949>; else goto <D.9954>;
  <D.9954>:
  D.9955 = _wapi_handle_type (handle);
  if (D.9955 == 12) goto <D.9949>; else goto <D.9956>;
  <D.9956>:
  D.9957 = _wapi_handle_type (handle);
  if (D.9957 == 13) goto <D.9949>; else goto <D.9950>;
  <D.9949>:
  _wapi_handle_unref (handle);
  D.9948 = 0;
  return D.9948;
  <D.9950>:
  D.9958 = idx / 256;
  D.9959 = _wapi_private_handles[D.9958];
  D.9960 = (long unsigned int) idx;
  D.9961 = D.9960 & 255;
  D.9962 = D.9961 * 200;
  D.9963 = D.9959 + D.9962;
  D.9964 = &D.9963->signal_mutex;
  ret = pthread_mutex_unlock (D.9964);
  _wapi_handle_unref (handle);
  D.9948 = ret;
  return D.9948;
}


namedevent_create (struct WapiSecurityAttributes * security, gboolean manual, gboolean initial, const gunichar2 * name)
{
  _Bool D.9966;
  long int D.9967;
  long int D.9968;
  long unsigned int D.9977;
  long unsigned int D.9980;
  long unsigned int D.9982;
  unsigned int offset.13;
  void * D.9997;
  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.9966 = thr_ret != 0;
      D.9967 = (long int) D.9966;
      D.9968 = __builtin_expect (D.9967, 0);
      if (D.9968 != 0) goto <D.9969>; else goto <D.9970>;
      <D.9969>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "events.c", 227, "thr_ret == 0");
      <D.9970>:
      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.9971>; else goto <D.9972>;
      <D.9971>:
      SetLastError (6);
      goto cleanup;
      <D.9972>:
      if (offset != 0) goto <D.9973>; else goto <D.9974>;
      <D.9973>:
      SetLastError (183);
      <D.9974>:
      if (offset == 0) goto <D.9975>; else goto <D.9976>;
      <D.9975>:
      D.9977 = __strlen_g (utf8_name);
      if (D.9977 <= 259) goto <D.9978>; else goto <D.9979>;
      <D.9978>:
      D.9980 = __strlen_g (utf8_name);
      namelen = (guint32) D.9980;
      goto <D.9981>;
      <D.9979>:
      namelen = 260;
      <D.9981>:
      D.9982 = (long unsigned int) namelen;
      memcpy (&namedevent_handle.sharedns.name, utf8_name, D.9982);
      namedevent_handle.manual = manual;
      namedevent_handle.set_count = 0;
      if (initial == 1) goto <D.9983>; else goto <D.9984>;
      <D.9983>:
      if (manual == 0) goto <D.9985>; else goto <D.9986>;
      <D.9985>:
      namedevent_handle.set_count = 1;
      <D.9986>:
      <D.9984>:
      handle = _wapi_handle_new (13, &namedevent_handle);
      goto <D.9987>;
      <D.9976>:
      offset.13 = (unsigned int) offset;
      handle = _wapi_handle_new_from_offset (13, offset.13, 1);
      <D.9987>:
      if (handle == -1B) goto <D.9989>; else goto <D.9990>;
      <D.9989>:
      monoeg_g_log (0B, 16, "%s: error creating event handle", &__func__);
      SetLastError (31);
      goto cleanup;
      <D.9990>:
      ret = handle;
      if (offset == 0) goto <D.9991>; else goto <D.9992>;
      <D.9991>:
      thr_ret = _wapi_handle_lock_shared_handles ();
      D.9966 = thr_ret != 0;
      D.9967 = (long int) D.9966;
      D.9968 = __builtin_expect (D.9967, 0);
      if (D.9968 != 0) goto <D.9993>; else goto <D.9994>;
      <D.9993>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "events.c", 299, "thr_ret == 0");
      <D.9994>:
      if (initial == 1) goto <D.9995>; else goto <D.9996>;
      <D.9995>:
      _wapi_shared_handle_set_signal_state (handle, 1);
      <D.9996>:
      _wapi_handle_unlock_shared_handles ();
      <D.9992>:
      cleanup:
      monoeg_g_free (utf8_name);
      _wapi_namespace_unlock (0B);
      D.9997 = ret;
      return D.9997;
    }
  finally
    {
      namedevent_handle = {CLOBBER};
    }
}


_wapi_namespace_lock ()
{
  int D.10000;

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


__attribute__((__gnu_inline__))
__strlen_g (const char * __str)
{
  size_t D.10002;
  long int __ptr.14;
  long int __str.15;
  long int D.10005;
  char * __ptr;
  char * __tmp;

  __ptr = 0B;
  __tmp = __str;
  __asm__ __volatile__("   la    0,0
0: srst  %0,%1
   jo    0b
" : "=&a" __ptr, "=&a" __tmp : "0" __ptr, "1" __tmp : "0", "memory", "cc");
  __ptr.14 = (long int) __ptr;
  __str.15 = (long int) __str;
  D.10005 = __ptr.14 - __str.15;
  D.10002 = (size_t) D.10005;
  return D.10002;
}


__attribute__((__artificial__, __gnu_inline__, __always_inline__, __nothrow__, __leaf__))
memcpy (void * restrict __dest, const void * restrict __src, size_t __len)
{
  void * D.10007;
  long unsigned int D.10008;

  D.10008 = __builtin_object_size (__dest, 0);
  D.10007 = __builtin___memcpy_chk (__dest, __src, __len, D.10008);
  return D.10007;
}


_wapi_handle_lock_shared_handles ()
{
  int D.10010;

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


_wapi_handle_unlock_shared_handles ()
{
  int D.10012;

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


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

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


PulseEvent (void * handle)
{
  gboolean D.10018;
  gboolean (*<T147a>) (void *) D.10019;
  WapiHandleType type;

  if (handle == 0B) goto <D.10016>; else goto <D.10017>;
  <D.10016>:
  SetLastError (6);
  D.10018 = 0;
  return D.10018;
  <D.10017>:
  type = _wapi_handle_type (handle);
  D.10019 = event_ops[type].pulse;
  if (D.10019 == 0B) goto <D.10020>; else goto <D.10021>;
  <D.10020>:
  SetLastError (6);
  D.10018 = 0;
  return D.10018;
  <D.10021>:
  D.10019 = event_ops[type].pulse;
  D.10018 = D.10019 (handle);
  return D.10018;
}


namedevent_set (void * handle)
{
  gboolean D.10025;
  _Bool D.10026;
  long int D.10027;
  long int D.10028;
  struct _WapiHandle_namedevent * namedevent_handle.16;
  int D.10032;
  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.10023>; else goto <D.10024>;
      <D.10023>:
      monoeg_g_log (0B, 16, "%s: error looking up named event handle %p", &__func__, handle);
      D.10025 = 0;
      return D.10025;
      <D.10024>:
      thr_ret = _wapi_handle_lock_shared_handles ();
      D.10026 = thr_ret != 0;
      D.10027 = (long int) D.10026;
      D.10028 = __builtin_expect (D.10027, 0);
      if (D.10028 != 0) goto <D.10029>; else goto <D.10030>;
      <D.10029>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "events.c", 661, "thr_ret == 0");
      <D.10030>:
      namedevent_handle.16 = namedevent_handle;
      D.10032 = namedevent_handle.16->manual;
      if (D.10032 == 1) goto <D.10033>; else goto <D.10034>;
      <D.10033>:
      _wapi_shared_handle_set_signal_state (handle, 1);
      goto <D.10035>;
      <D.10034>:
      namedevent_handle.16 = namedevent_handle;
      namedevent_handle.16->set_count = 1;
      _wapi_shared_handle_set_signal_state (handle, 1);
      <D.10035>:
      _wapi_handle_unlock_shared_handles ();
      D.10025 = 1;
      return D.10025;
    }
  finally
    {
      namedevent_handle = {CLOBBER};
    }
}


namedevent_reset (void * handle)
{
  gboolean D.10040;
  _Bool D.10041;
  long int D.10042;
  long int D.10043;
  int D.10046;
  struct _WapiHandle_namedevent * namedevent_handle.17;
  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.10038>; else goto <D.10039>;
      <D.10038>:
      monoeg_g_log (0B, 16, "%s: error looking up named event handle %p", &__func__, handle);
      D.10040 = 0;
      return D.10040;
      <D.10039>:
      thr_ret = _wapi_handle_lock_shared_handles ();
      D.10041 = thr_ret != 0;
      D.10042 = (long int) D.10041;
      D.10043 = __builtin_expect (D.10042, 0);
      if (D.10043 != 0) goto <D.10044>; else goto <D.10045>;
      <D.10044>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "events.c", 563, "thr_ret == 0");
      <D.10045>:
      D.10046 = _wapi_handle_issignalled (handle);
      if (D.10046 == 0) goto <D.10047>; else goto <D.10048>;
      <D.10047>:
      goto <D.10049>;
      <D.10048>:
      _wapi_shared_handle_set_signal_state (handle, 0);
      <D.10049>:
      namedevent_handle.17 = namedevent_handle;
      namedevent_handle.17->set_count = 0;
      _wapi_handle_unlock_shared_handles ();
      D.10040 = 1;
      return D.10040;
    }
  finally
    {
      namedevent_handle = {CLOBBER};
    }
}


_wapi_handle_issignalled (void * handle)
{
  long int handle.18;
  gboolean D.10056;
  <unnamed type> D.10059;
  <unnamed type> D.10061;
  <unnamed type> D.10063;
  <unnamed type> D.10065;
  struct _WapiHandleSharedLayout * _wapi_shared_layout.19;
  unsigned int D.10067;
  unsigned int D.10068;
  struct _WapiHandleUnshared * D.10069;
  long unsigned int D.10070;
  long unsigned int D.10071;
  long unsigned int D.10072;
  struct _WapiHandleUnshared * D.10073;
  unsigned int D.10074;
  unsigned int D.10075;
  struct _WapiHandleUnshared * D.10076;
  long unsigned int D.10077;
  long unsigned int D.10078;
  long unsigned int D.10079;
  struct _WapiHandleUnshared * D.10080;
  guint32 idx;

  handle.18 = (long int) handle;
  idx = (guint32) handle.18;
  if (idx > 4194303) goto <D.10054>; else goto <D.10055>;
  <D.10054>:
  D.10056 = 0;
  return D.10056;
  <D.10055>:
  D.10059 = _wapi_handle_type (handle);
  if (D.10059 == 9) goto <D.10057>; else goto <D.10060>;
  <D.10060>:
  D.10061 = _wapi_handle_type (handle);
  if (D.10061 == 11) goto <D.10057>; else goto <D.10062>;
  <D.10062>:
  D.10063 = _wapi_handle_type (handle);
  if (D.10063 == 12) goto <D.10057>; else goto <D.10064>;
  <D.10064>:
  D.10065 = _wapi_handle_type (handle);
  if (D.10065 == 13) goto <D.10057>; else goto <D.10058>;
  <D.10057>:
  _wapi_shared_layout.19 = _wapi_shared_layout;
  handle.18 = (long int) handle;
  D.10067 = (unsigned int) handle.18;
  D.10068 = D.10067 / 256;
  D.10069 = _wapi_private_handles[D.10068];
  handle.18 = (long int) handle;
  D.10067 = (unsigned int) handle.18;
  D.10070 = (long unsigned int) D.10067;
  D.10071 = D.10070 & 255;
  D.10072 = D.10071 * 200;
  D.10073 = D.10069 + D.10072;
  D.10074 = D.10073->u.shared.offset;
  D.10056 = _wapi_shared_layout.19->handles[D.10074].signalled;
  return D.10056;
  <D.10058>:
  D.10075 = idx / 256;
  D.10076 = _wapi_private_handles[D.10075];
  D.10077 = (long unsigned int) idx;
  D.10078 = D.10077 & 255;
  D.10079 = D.10078 * 200;
  D.10080 = D.10076 + D.10079;
  D.10056 = D.10080->signalled;
  return D.10056;
}


namedevent_pulse (void * handle)
{
  gboolean D.10084;
  _Bool D.10085;
  long int D.10086;
  long int D.10087;
  struct _WapiHandle_namedevent * namedevent_handle.20;
  int D.10091;
  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.10082>; else goto <D.10083>;
      <D.10082>:
      monoeg_g_log (0B, 16, "%s: error looking up named event handle %p", &__func__, handle);
      D.10084 = 0;
      return D.10084;
      <D.10083>:
      thr_ret = _wapi_handle_lock_shared_handles ();
      D.10085 = thr_ret != 0;
      D.10086 = (long int) D.10085;
      D.10087 = __builtin_expect (D.10086, 0);
      if (D.10087 != 0) goto <D.10088>; else goto <D.10089>;
      <D.10088>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "events.c", 431, "thr_ret == 0");
      <D.10089>:
      namedevent_handle.20 = namedevent_handle;
      D.10091 = namedevent_handle.20->manual;
      if (D.10091 == 1) goto <D.10092>; else goto <D.10093>;
      <D.10092>:
      _wapi_shared_handle_set_signal_state (handle, 1);
      goto <D.10094>;
      <D.10093>:
      namedevent_handle.20 = namedevent_handle;
      namedevent_handle.20->set_count = 1;
      _wapi_shared_handle_set_signal_state (handle, 1);
      <D.10094>:
      _wapi_handle_unlock_shared_handles ();
      namedevent_handle.20 = namedevent_handle;
      D.10091 = namedevent_handle.20->manual;
      if (D.10091 == 1) goto <D.10095>; else goto <D.10096>;
      <D.10095>:
      _wapi_handle_spin (200);
      thr_ret = _wapi_handle_lock_shared_handles ();
      D.10085 = thr_ret != 0;
      D.10086 = (long int) D.10085;
      D.10087 = __builtin_expect (D.10086, 0);
      if (D.10087 != 0) goto <D.10097>; else goto <D.10098>;
      <D.10097>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "events.c", 461, "thr_ret == 0");
      <D.10098>:
      _wapi_shared_handle_set_signal_state (handle, 0);
      _wapi_handle_unlock_shared_handles ();
      <D.10096>:
      D.10084 = 1;
      return D.10084;
    }
  finally
    {
      namedevent_handle = {CLOBBER};
    }
}


_wapi_handle_spin (guint32 ms)
{
  _Bool D.10101;
  long int D.10102;
  long int D.10103;
  unsigned int D.10106;
  long int D.10107;
  struct timespec sleepytime;

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


event_set (void * handle)
{
  gboolean D.10110;
  long int D.10111;
  long int D.10112;
  _Bool D.10115;
  long int D.10116;
  long int D.10117;
  struct _WapiHandle_event * event_handle.21;
  int D.10121;
  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.10108>; else goto <D.10109>;
      <D.10108>:
      monoeg_g_log (0B, 16, "%s: error looking up event handle %p", &__func__, handle);
      D.10110 = 0;
      return D.10110;
      <D.10109>:
      {
        struct __pthread_unwind_buf_t __cancel_buf;
        void (*<Tc6>) (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.10111 = (long int) __not_first_call;
            D.10112 = __builtin_expect (D.10111, 0);
            if (D.10112 != 0) goto <D.10113>; else goto <D.10114>;
            <D.10113>:
            __cancel_routine (__cancel_arg);
            __pthread_unwind_next (&__cancel_buf);
            <D.10114>:
            __pthread_register_cancel (&__cancel_buf);
            thr_ret = _wapi_handle_lock_handle (handle);
            D.10115 = thr_ret != 0;
            D.10116 = (long int) D.10115;
            D.10117 = __builtin_expect (D.10116, 0);
            if (D.10117 != 0) goto <D.10118>; else goto <D.10119>;
            <D.10118>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "events.c", 627, "thr_ret == 0");
            <D.10119>:
            event_handle.21 = event_handle;
            D.10121 = event_handle.21->manual;
            if (D.10121 == 1) goto <D.10122>; else goto <D.10123>;
            <D.10122>:
            _wapi_handle_set_signal_state (handle, 1, 1);
            goto <D.10124>;
            <D.10123>:
            event_handle.21 = event_handle;
            event_handle.21->set_count = 1;
            _wapi_handle_set_signal_state (handle, 1, 0);
            <D.10124>:
            thr_ret = _wapi_handle_unlock_handle (handle);
            D.10115 = thr_ret != 0;
            D.10116 = (long int) D.10115;
            D.10117 = __builtin_expect (D.10116, 0);
            if (D.10117 != 0) goto <D.10125>; else goto <D.10126>;
            <D.10125>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "events.c", 639, "thr_ret == 0");
            <D.10126>:
            __pthread_unregister_cancel (&__cancel_buf);
            if (0 != 0) goto <D.10127>; else goto <D.10128>;
            <D.10127>:
            __cancel_routine (__cancel_arg);
            <D.10128>:
          }
        finally
          {
            __cancel_buf = {CLOBBER};
          }
      }
      D.10110 = 1;
      return D.10110;
    }
  finally
    {
      event_handle = {CLOBBER};
    }
}


event_reset (void * handle)
{
  gboolean D.10136;
  long int D.10137;
  long int D.10138;
  _Bool D.10141;
  long int D.10142;
  long int D.10143;
  int D.10146;
  struct _WapiHandle_event * event_handle.22;
  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.10134>; else goto <D.10135>;
      <D.10134>:
      monoeg_g_log (0B, 16, "%s: error looking up event handle %p", &__func__, handle);
      D.10136 = 0;
      return D.10136;
      <D.10135>:
      {
        struct __pthread_unwind_buf_t __cancel_buf;
        void (*<Tc6>) (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.10137 = (long int) __not_first_call;
            D.10138 = __builtin_expect (D.10137, 0);
            if (D.10138 != 0) goto <D.10139>; else goto <D.10140>;
            <D.10139>:
            __cancel_routine (__cancel_arg);
            __pthread_unwind_next (&__cancel_buf);
            <D.10140>:
            __pthread_register_cancel (&__cancel_buf);
            thr_ret = _wapi_handle_lock_handle (handle);
            D.10141 = thr_ret != 0;
            D.10142 = (long int) D.10141;
            D.10143 = __builtin_expect (D.10142, 0);
            if (D.10143 != 0) goto <D.10144>; else goto <D.10145>;
            <D.10144>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "events.c", 524, "thr_ret == 0");
            <D.10145>:
            D.10146 = _wapi_handle_issignalled (handle);
            if (D.10146 == 0) goto <D.10147>; else goto <D.10148>;
            <D.10147>:
            goto <D.10149>;
            <D.10148>:
            _wapi_handle_set_signal_state (handle, 0, 0);
            <D.10149>:
            event_handle.22 = event_handle;
            event_handle.22->set_count = 0;
            thr_ret = _wapi_handle_unlock_handle (handle);
            D.10141 = thr_ret != 0;
            D.10142 = (long int) D.10141;
            D.10143 = __builtin_expect (D.10142, 0);
            if (D.10143 != 0) goto <D.10151>; else goto <D.10152>;
            <D.10151>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "events.c", 539, "thr_ret == 0");
            <D.10152>:
            __pthread_unregister_cancel (&__cancel_buf);
            if (0 != 0) goto <D.10153>; else goto <D.10154>;
            <D.10153>:
            __cancel_routine (__cancel_arg);
            <D.10154>:
          }
        finally
          {
            __cancel_buf = {CLOBBER};
          }
      }
      D.10136 = 1;
      return D.10136;
    }
  finally
    {
      event_handle = {CLOBBER};
    }
}


event_pulse (void * handle)
{
  gboolean D.10163;
  long int D.10164;
  long int D.10165;
  _Bool D.10168;
  long int D.10169;
  long int D.10170;
  struct _WapiHandle_event * event_handle.23;
  int D.10174;
  long int D.10184;
  long int D.10185;
  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.10161>; else goto <D.10162>;
      <D.10161>:
      monoeg_g_log (0B, 16, "%s: error looking up event handle %p", &__func__, handle);
      D.10163 = 0;
      return D.10163;
      <D.10162>:
      {
        struct __pthread_unwind_buf_t __cancel_buf;
        void (*<Tc6>) (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.10164 = (long int) __not_first_call;
            D.10165 = __builtin_expect (D.10164, 0);
            if (D.10165 != 0) goto <D.10166>; else goto <D.10167>;
            <D.10166>:
            __cancel_routine (__cancel_arg);
            __pthread_unwind_next (&__cancel_buf);
            <D.10167>:
            __pthread_register_cancel (&__cancel_buf);
            thr_ret = _wapi_handle_lock_handle (handle);
            D.10168 = thr_ret != 0;
            D.10169 = (long int) D.10168;
            D.10170 = __builtin_expect (D.10169, 0);
            if (D.10170 != 0) goto <D.10171>; else goto <D.10172>;
            <D.10171>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "events.c", 370, "thr_ret == 0");
            <D.10172>:
            event_handle.23 = event_handle;
            D.10174 = event_handle.23->manual;
            if (D.10174 == 1) goto <D.10175>; else goto <D.10176>;
            <D.10175>:
            _wapi_handle_set_signal_state (handle, 1, 1);
            goto <D.10177>;
            <D.10176>:
            event_handle.23 = event_handle;
            event_handle.23->set_count = 1;
            _wapi_handle_set_signal_state (handle, 1, 0);
            <D.10177>:
            thr_ret = _wapi_handle_unlock_handle (handle);
            D.10168 = thr_ret != 0;
            D.10169 = (long int) D.10168;
            D.10170 = __builtin_expect (D.10169, 0);
            if (D.10170 != 0) goto <D.10178>; else goto <D.10179>;
            <D.10178>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "events.c", 382, "thr_ret == 0");
            <D.10179>:
            __pthread_unregister_cancel (&__cancel_buf);
            if (0 != 0) goto <D.10180>; else goto <D.10181>;
            <D.10180>:
            __cancel_routine (__cancel_arg);
            <D.10181>:
          }
        finally
          {
            __cancel_buf = {CLOBBER};
          }
      }
      event_handle.23 = event_handle;
      D.10174 = event_handle.23->manual;
      if (D.10174 == 1) goto <D.10182>; else goto <D.10183>;
      <D.10182>:
      sched_yield ();
      {
        struct __pthread_unwind_buf_t __cancel_buf;
        void (*<Tc6>) (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.10184 = (long int) __not_first_call;
            D.10185 = __builtin_expect (D.10184, 0);
            if (D.10185 != 0) goto <D.10186>; else goto <D.10187>;
            <D.10186>:
            __cancel_routine (__cancel_arg);
            __pthread_unwind_next (&__cancel_buf);
            <D.10187>:
            __pthread_register_cancel (&__cancel_buf);
            thr_ret = _wapi_handle_lock_handle (handle);
            D.10168 = thr_ret != 0;
            D.10169 = (long int) D.10168;
            D.10170 = __builtin_expect (D.10169, 0);
            if (D.10170 != 0) goto <D.10188>; else goto <D.10189>;
            <D.10188>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "events.c", 404, "thr_ret == 0");
            <D.10189>:
            _wapi_handle_set_signal_state (handle, 0, 0);
            thr_ret = _wapi_handle_unlock_handle (handle);
            D.10168 = thr_ret != 0;
            D.10169 = (long int) D.10168;
            D.10170 = __builtin_expect (D.10169, 0);
            if (D.10170 != 0) goto <D.10190>; else goto <D.10191>;
            <D.10190>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "events.c", 409, "thr_ret == 0");
            <D.10191>:
            __pthread_unregister_cancel (&__cancel_buf);
            if (0 != 0) goto <D.10192>; else goto <D.10193>;
            <D.10192>:
            __cancel_routine (__cancel_arg);
            <D.10193>:
          }
        finally
          {
            __cancel_buf = {CLOBBER};
          }
      }
      <D.10183>:
      D.10163 = 1;
      return D.10163;
    }
  finally
    {
      event_handle = {CLOBBER};
    }
}


ResetEvent (void * handle)
{
  gboolean D.10203;
  gboolean (*<T147a>) (void *) D.10204;
  WapiHandleType type;

  if (handle == 0B) goto <D.10201>; else goto <D.10202>;
  <D.10201>:
  SetLastError (6);
  D.10203 = 0;
  return D.10203;
  <D.10202>:
  type = _wapi_handle_type (handle);
  D.10204 = event_ops[type].reset;
  if (D.10204 == 0B) goto <D.10205>; else goto <D.10206>;
  <D.10205>:
  SetLastError (6);
  D.10203 = 0;
  return D.10203;
  <D.10206>:
  D.10204 = event_ops[type].reset;
  D.10203 = D.10204 (handle);
  return D.10203;
}


SetEvent (void * handle)
{
  gboolean D.10210;
  gboolean (*<T147a>) (void *) D.10211;
  WapiHandleType type;

  if (handle == 0B) goto <D.10208>; else goto <D.10209>;
  <D.10208>:
  SetLastError (6);
  D.10210 = 0;
  return D.10210;
  <D.10209>:
  type = _wapi_handle_type (handle);
  D.10211 = event_ops[type].set;
  if (D.10211 == 0B) goto <D.10212>; else goto <D.10213>;
  <D.10212>:
  SetLastError (6);
  D.10210 = 0;
  return D.10210;
  <D.10213>:
  D.10211 = event_ops[type].set;
  D.10210 = D.10211 (handle);
  return D.10210;
}


OpenEvent (guint32 access, gboolean inherit, const gunichar2 * name)
{
  _Bool D.10215;
  long int D.10216;
  long int D.10217;
  unsigned int offset.24;
  void * D.10227;
  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.10215 = thr_ret != 0;
  D.10216 = (long int) D.10215;
  D.10217 = __builtin_expect (D.10216, 0);
  if (D.10217 != 0) goto <D.10218>; else goto <D.10219>;
  <D.10218>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "events.c", 724, "thr_ret == 0");
  <D.10219>:
  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.10220>; else goto <D.10221>;
  <D.10220>:
  SetLastError (6);
  goto cleanup;
  <D.10221>:
  if (offset == 0) goto <D.10222>; else goto <D.10223>;
  <D.10222>:
  SetLastError (2);
  goto cleanup;
  <D.10223>:
  offset.24 = (unsigned int) offset;
  handle = _wapi_handle_new_from_offset (13, offset.24, 1);
  if (handle == -1B) goto <D.10225>; else goto <D.10226>;
  <D.10225>:
  monoeg_g_log (0B, 16, "%s: error opening named event handle", &__func__);
  SetLastError (31);
  goto cleanup;
  <D.10226>:
  ret = handle;
  cleanup:
  monoeg_g_free (utf8_name);
  _wapi_namespace_unlock (0B);
  D.10227 = ret;
  return D.10227;
}


