_wapi_collection_init ()
{
  _Bool D.10750;
  long int D.10751;
  long int D.10752;
  _Bool D.10764;
  _Bool D.10765;
  const gchar * D.10770;
  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.10750 = ret != 0;
      D.10751 = (long int) D.10750;
      D.10752 = __builtin_expect (D.10751, 0);
      if (D.10752 != 0) goto <D.10753>; else goto <D.10754>;
      <D.10753>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "collection.c", 57, "ret == 0");
      <D.10754>:
      if (set_stacksize == 0) goto <D.10755>; else goto <D.10756>;
      <D.10755>:
      ret = pthread_attr_setstacksize (&attr, 65536);
      D.10750 = ret != 0;
      D.10751 = (long int) D.10750;
      D.10752 = __builtin_expect (D.10751, 0);
      if (D.10752 != 0) goto <D.10757>; else goto <D.10758>;
      <D.10757>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "collection.c", 62, "ret == 0");
      <D.10758>:
      goto <D.10759>;
      <D.10756>:
      if (set_stacksize == 1) goto <D.10760>; else goto <D.10761>;
      <D.10760>:
      ret = pthread_attr_setstacksize (&attr, 131072);
      D.10750 = ret != 0;
      D.10751 = (long int) D.10750;
      D.10752 = __builtin_expect (D.10751, 0);
      if (D.10752 != 0) goto <D.10762>; else goto <D.10763>;
      <D.10762>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "collection.c", 65, "ret == 0");
      <D.10763>:
      <D.10761>:
      <D.10759>:
      ret = pthread_create (&collection_thread_id, &attr, collection_thread, 0B);
      D.10750 = ret != 0;
      D.10764 = set_stacksize <= 1;
      D.10765 = D.10750 & D.10764;
      if (D.10765 != 0) goto <D.10766>; else goto <D.10767>;
      <D.10766>:
      set_stacksize = set_stacksize + 1;
      goto retry;
      <D.10767>:
      if (ret != 0) goto <D.10768>; else goto <D.10769>;
      <D.10768>:
      D.10770 = monoeg_g_strerror (ret);
      monoeg_g_log (0B, 4, "%s: Couldn\'t create handle collection thread: %s", &__func__, D.10770);
      <D.10733>:
      goto <D.10733>;
      <D.10769>:
    }
  finally
    {
      attr = {CLOBBER};
    }
}


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

  try
    {
      sleepytime.tv_sec = 10;
      sleepytime.tv_nsec = 0;
      goto <D.10723>;
      <D.10722>:
      nanosleep (&sleepytime, 0B);
      _wapi_handle_update_refs ();
      <D.10723>:
      _wapi_has_shut_down.0 = _wapi_has_shut_down;
      if (_wapi_has_shut_down.0 == 0) goto <D.10722>; else goto <D.10724>;
      <D.10724>:
      pthread_exit (0B);
      D.10772 = 0B;
      return D.10772;
    }
  finally
    {
      sleepytime = {CLOBBER};
    }
}


_wapi_handle_collect ()
{
  struct _WapiHandleSharedLayout * _wapi_shared_layout.1;
  int D.10776;
  _Bool D.10779;
  long int D.10780;
  long int D.10781;
  unsigned int D.10784;
  long int D.10787;
  unsigned int D.10788;
  unsigned int D.10789;
  struct _WapiHandleShared * D.10792;
  struct _WapiFileShareLayout * _wapi_fileshare_layout.2;
  unsigned int D.10794;
  unsigned int i.3;
  unsigned int D.10798;
  volatile guint32 * D.10799;
  guint32 count;
  int i;
  int thr_ret;

  _wapi_shared_layout.1 = _wapi_shared_layout;
  count = _wapi_shared_layout.1->collection_count;
  D.10776 = _wapi_shm_enabled ();
  if (D.10776 == 0) goto <D.10777>; else goto <D.10778>;
  <D.10777>:
  return;
  <D.10778>:
  thr_ret = _wapi_handle_lock_shared_handles ();
  D.10779 = thr_ret != 0;
  D.10780 = (long int) D.10779;
  D.10781 = __builtin_expect (D.10780, 0);
  if (D.10781 != 0) goto <D.10782>; else goto <D.10783>;
  <D.10782>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "collection.c", 93, "thr_ret == 0");
  <D.10783>:
  _wapi_shared_layout.1 = _wapi_shared_layout;
  D.10784 = _wapi_shared_layout.1->collection_count;
  if (D.10784 == count) goto <D.10785>; else goto <D.10786>;
  <D.10785>:
  {
    guint32 too_old;

    D.10787 = time (0B);
    D.10788 = (unsigned int) D.10787;
    too_old = D.10788 + 4294967236;
    i = 0;
    goto <D.10743>;
    <D.10742>:
    {
      struct _WapiHandleShared * data;

      _wapi_shared_layout.1 = _wapi_shared_layout;
      data = &_wapi_shared_layout.1->handles[i];
      D.10789 = data->timestamp;
      if (D.10789 < too_old) goto <D.10790>; else goto <D.10791>;
      <D.10790>:
      _wapi_shared_layout.1 = _wapi_shared_layout;
      D.10792 = &_wapi_shared_layout.1->handles[i];
      memset (D.10792, 0, 336);
      <D.10791>:
    }
    i = i + 1;
    <D.10743>:
    if (i <= 255) goto <D.10742>; else goto <D.10744>;
    <D.10744>:
    i = 0;
    goto <D.10747>;
    <D.10746>:
    {
      struct _WapiFileShare * file_share;

      _wapi_fileshare_layout.2 = _wapi_fileshare_layout;
      file_share = &_wapi_fileshare_layout.2->share_info[i];
      D.10794 = file_share->timestamp;
      if (D.10794 < too_old) goto <D.10795>; else goto <D.10796>;
      <D.10795>:
      memset (file_share, 0, 40);
      <D.10796>:
    }
    i = i + 1;
    <D.10747>:
    i.3 = (unsigned int) i;
    _wapi_fileshare_layout.2 = _wapi_fileshare_layout;
    D.10798 = _wapi_fileshare_layout.2->hwm;
    if (i.3 < D.10798) goto <D.10746>; else goto <D.10748>;
    <D.10748>:
    _wapi_shared_layout.1 = _wapi_shared_layout;
    D.10799 = &_wapi_shared_layout.1->collection_count;
    InterlockedIncrement (D.10799);
  }
  <D.10786>:
  _wapi_handle_unlock_shared_handles ();
}


_wapi_handle_lock_shared_handles ()
{
  int D.10801;

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


memset (void * __dest, int __ch, size_t __len)
{
  int D.10805;
  int D.10810;
  void * D.10812;
  long unsigned int D.10813;

  D.10805 = __builtin_constant_p (__len);
  if (D.10805 != 0) goto <D.10806>; else goto <D.10807>;
  <D.10806>:
  if (__len == 0) goto <D.10808>; else goto <D.10809>;
  <D.10808>:
  D.10810 = __builtin_constant_p (__ch);
  if (D.10810 == 0) goto <D.10803>; else goto <D.10811>;
  <D.10811>:
  if (__ch != 0) goto <D.10803>; else goto <D.10804>;
  <D.10803>:
  __warn_memset_zero_len ();
  D.10812 = __dest;
  return D.10812;
  <D.10804>:
  <D.10809>:
  <D.10807>:
  D.10813 = __builtin_object_size (__dest, 0);
  D.10812 = __builtin___memset_chk (__dest, __ch, __len, D.10813);
  return D.10812;
}


InterlockedIncrement (volatile gint32 * val)
{
  gint32 D.10815;
  unsigned int D.10816;

  D.10816 = __sync_add_and_fetch_4 (val, 1);
  D.10815 = (gint32) D.10816;
  return D.10815;
}


_wapi_handle_unlock_shared_handles ()
{
  int D.10818;

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


