_wapi_collection_init ()
{
  _Bool D.10900;
  long int D.10901;
  long int D.10902;
  const gchar * D.10920;
  union pthread_attr_t attr;
  int ret;
  int set_stacksize;
  void retry = <<< error >>>;
  static const char __func__[22] = "_wapi_collection_init";

  try
    {
      set_stacksize = 0;
      retry:
      ret = pthread_attr_init (&attr);
      D.10900 = ret != 0;
      D.10901 = (long int) D.10900;
      D.10902 = __builtin_expect (D.10901, 0);
      if (D.10902 != 0) goto <D.10903>; else goto <D.10904>;
      <D.10903>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "collection.c", 57, "ret == 0");
      <D.10904>:
      if (set_stacksize == 0) goto <D.10905>; else goto <D.10906>;
      <D.10905>:
      ret = pthread_attr_setstacksize (&attr, 65536);
      D.10900 = ret != 0;
      D.10901 = (long int) D.10900;
      D.10902 = __builtin_expect (D.10901, 0);
      if (D.10902 != 0) goto <D.10907>; else goto <D.10908>;
      <D.10907>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "collection.c", 62, "ret == 0");
      <D.10908>:
      goto <D.10909>;
      <D.10906>:
      if (set_stacksize == 1) goto <D.10910>; else goto <D.10911>;
      <D.10910>:
      ret = pthread_attr_setstacksize (&attr, 131072);
      D.10900 = ret != 0;
      D.10901 = (long int) D.10900;
      D.10902 = __builtin_expect (D.10901, 0);
      if (D.10902 != 0) goto <D.10912>; else goto <D.10913>;
      <D.10912>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "collection.c", 65, "ret == 0");
      <D.10913>:
      <D.10911>:
      <D.10909>:
      ret = pthread_create (&collection_thread_id, &attr, collection_thread, 0B);
      if (ret != 0) goto <D.10914>; else goto <D.10915>;
      <D.10914>:
      if (set_stacksize <= 1) goto <D.10916>; else goto <D.10917>;
      <D.10916>:
      set_stacksize = set_stacksize + 1;
      goto retry;
      <D.10917>:
      <D.10915>:
      if (ret != 0) goto <D.10918>; else goto <D.10919>;
      <D.10918>:
      D.10920 = monoeg_g_strerror (ret);
      monoeg_g_log (0B, 4, "%s: Couldn\'t create handle collection thread: %s", &__func__, D.10920);
      <D.10883>:
      goto <D.10883>;
      <D.10919>:
    }
  finally
    {
      attr = {CLOBBER};
    }
}


collection_thread (void * unused)
{
  int _wapi_has_shut_down.0;
  void * D.10922;
  struct timespec sleepytime;

  try
    {
      sleepytime.tv_sec = 10;
      sleepytime.tv_nsec = 0;
      goto <D.10873>;
      <D.10872>:
      nanosleep (&sleepytime, 0B);
      _wapi_handle_update_refs ();
      <D.10873>:
      _wapi_has_shut_down.0 = _wapi_has_shut_down;
      if (_wapi_has_shut_down.0 == 0) goto <D.10872>; else goto <D.10874>;
      <D.10874>:
      pthread_exit (0B);
      D.10922 = 0B;
      return D.10922;
    }
  finally
    {
      sleepytime = {CLOBBER};
    }
}


_wapi_handle_collect ()
{
  struct _WapiHandleSharedLayout * _wapi_shared_layout.1;
  int D.10926;
  _Bool D.10929;
  long int D.10930;
  long int D.10931;
  unsigned int D.10934;
  long int D.10937;
  unsigned int D.10938;
  unsigned int D.10939;
  struct _WapiHandleShared * D.10942;
  struct _WapiFileShareLayout * _wapi_fileshare_layout.2;
  unsigned int D.10944;
  unsigned int D.10947;
  unsigned int i.3;
  volatile guint32 * D.10949;
  guint32 count;
  int i;
  int thr_ret;

  _wapi_shared_layout.1 = _wapi_shared_layout;
  count = _wapi_shared_layout.1->collection_count;
  D.10926 = _wapi_shm_enabled ();
  if (D.10926 == 0) goto <D.10927>; else goto <D.10928>;
  <D.10927>:
  return;
  <D.10928>:
  thr_ret = _wapi_handle_lock_shared_handles ();
  D.10929 = thr_ret != 0;
  D.10930 = (long int) D.10929;
  D.10931 = __builtin_expect (D.10930, 0);
  if (D.10931 != 0) goto <D.10932>; else goto <D.10933>;
  <D.10932>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "collection.c", 93, "thr_ret == 0");
  <D.10933>:
  _wapi_shared_layout.1 = _wapi_shared_layout;
  D.10934 = _wapi_shared_layout.1->collection_count;
  if (D.10934 == count) goto <D.10935>; else goto <D.10936>;
  <D.10935>:
  {
    guint32 too_old;

    D.10937 = time (0B);
    D.10938 = (unsigned int) D.10937;
    too_old = D.10938 + 4294967236;
    i = 0;
    goto <D.10893>;
    <D.10892>:
    {
      struct _WapiHandleShared * data;

      _wapi_shared_layout.1 = _wapi_shared_layout;
      data = &_wapi_shared_layout.1->handles[i];
      D.10939 = data->timestamp;
      if (D.10939 < too_old) goto <D.10940>; else goto <D.10941>;
      <D.10940>:
      _wapi_shared_layout.1 = _wapi_shared_layout;
      D.10942 = &_wapi_shared_layout.1->handles[i];
      memset (D.10942, 0, 336);
      <D.10941>:
    }
    i = i + 1;
    <D.10893>:
    if (i <= 255) goto <D.10892>; else goto <D.10894>;
    <D.10894>:
    i = 0;
    goto <D.10897>;
    <D.10896>:
    {
      struct _WapiFileShare * file_share;

      _wapi_fileshare_layout.2 = _wapi_fileshare_layout;
      file_share = &_wapi_fileshare_layout.2->share_info[i];
      D.10944 = file_share->timestamp;
      if (D.10944 < too_old) goto <D.10945>; else goto <D.10946>;
      <D.10945>:
      memset (file_share, 0, 40);
      <D.10946>:
    }
    i = i + 1;
    <D.10897>:
    _wapi_fileshare_layout.2 = _wapi_fileshare_layout;
    D.10947 = _wapi_fileshare_layout.2->hwm;
    i.3 = (unsigned int) i;
    if (D.10947 > i.3) goto <D.10896>; else goto <D.10898>;
    <D.10898>:
    _wapi_shared_layout.1 = _wapi_shared_layout;
    D.10949 = &_wapi_shared_layout.1->collection_count;
    InterlockedIncrement (D.10949);
  }
  <D.10936>:
  _wapi_handle_unlock_shared_handles ();
}


_wapi_handle_lock_shared_handles ()
{
  int D.10951;

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


__attribute__((__artificial__, __gnu_inline__, __always_inline__, __nothrow__, __leaf__))
memset (void * __dest, int __ch, size_t __len)
{
  void * D.10953;
  long unsigned int D.10954;

  D.10954 = __builtin_object_size (__dest, 0);
  D.10953 = __builtin___memset_chk (__dest, __ch, __len, D.10954);
  return D.10953;
}


InterlockedIncrement (volatile gint32 * val)
{
  gint32 D.10956;
  unsigned int D.10957;

  D.10957 = __sync_add_and_fetch_4 (val, 1);
  D.10956 = (gint32) D.10957;
  return D.10956;
}


_wapi_handle_unlock_shared_handles ()
{
  int D.10959;

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


