mini_wapi_hps (int argc, char * * argv)
{
  void * _wapi_shared_layout.0;
  struct _WapiHandleSharedLayout * _wapi_shared_layout.1;
  void * _wapi_fileshare_layout.2;
  struct _WapiFileShareLayout * _wapi_fileshare_layout.3;
  int D.22730;
  unsigned int D.22731;
  long int D.22732;
  <unnamed type> D.22733;
  const gchar * (*<T3ab5>) (struct _WapiHandleShared *) D.22736;
  const gchar * D.22737;
  const char * iftmp.4;
  int D.22739;
  unsigned int D.22743;
  unsigned int D.22744;
  const char * D.22745;
  unsigned int D.22746;
  unsigned int D.22747;
  unsigned int D.22748;
  unsigned int D.22751;
  unsigned int D.22752;
  int D.22753;
  long long unsigned int D.22754;
  long long int D.22755;
  long long unsigned int D.22756;
  long long int D.22757;
  guint32 i;
  guint32 now;

  _wapi_shared_layout.0 = _wapi_shm_attach (0);
  _wapi_shared_layout = _wapi_shared_layout.0;
  _wapi_shared_layout.1 = _wapi_shared_layout;
  if (_wapi_shared_layout.1 == 0B) goto <D.22722>; else goto <D.22723>;
  <D.22722>:
  monoeg_g_log (0B, 4, "Failed to attach shared memory!");
  <D.22655>:
  goto <D.22655>;
  exit (-1);
  <D.22723>:
  _wapi_fileshare_layout.2 = _wapi_shm_attach (1);
  _wapi_fileshare_layout = _wapi_fileshare_layout.2;
  _wapi_fileshare_layout.3 = _wapi_fileshare_layout;
  if (_wapi_fileshare_layout.3 == 0B) goto <D.22726>; else goto <D.22727>;
  <D.22726>:
  monoeg_g_log (0B, 4, "Failed to attach fileshare shared memory!");
  <D.22656>:
  goto <D.22656>;
  exit (-1);
  <D.22727>:
  if (argc > 1) goto <D.22728>; else goto <D.22729>;
  <D.22728>:
  _wapi_shm_semaphores_init ();
  _wapi_collection_init ();
  _wapi_handle_collect ();
  <D.22729>:
  _wapi_shared_layout.1 = _wapi_shared_layout;
  D.22730 = _wapi_shared_layout.1->sem_key;
  _wapi_shared_layout.1 = _wapi_shared_layout;
  D.22731 = _wapi_shared_layout.1->collection_count;
  monoeg_g_print ("collection: %d sem: 0x%x\n", D.22731, D.22730);
  D.22732 = time (0B);
  now = (guint32) D.22732;
  i = 0;
  goto <D.22659>;
  <D.22658>:
  {
    struct _WapiHandleShared * shared;

    _wapi_shared_layout.1 = _wapi_shared_layout;
    shared = &_wapi_shared_layout.1->handles[i];
    D.22733 = shared->type;
    if (D.22733 != 0) goto <D.22734>; else goto <D.22735>;
    <D.22734>:
    D.22733 = shared->type;
    D.22736 = details[D.22733];
    D.22737 = D.22736 (shared);
    D.22739 = shared->signalled;
    if (D.22739 != 0) goto <D.22740>; else goto <D.22741>;
    <D.22740>:
    iftmp.4 = "Sg";
    goto <D.22742>;
    <D.22741>:
    iftmp.4 = "Un";
    <D.22742>:
    D.22743 = shared->timestamp;
    D.22744 = now - D.22743;
    D.22733 = shared->type;
    D.22745 = _wapi_handle_typename[D.22733];
    D.22746 = shared->handle_refs;
    monoeg_g_print ("%3x (%3d) [%7s] %4u %s (%s)\n", i, D.22746, D.22745, D.22744, iftmp.4, D.22737);
    <D.22735>:
  }
  i = i + 1;
  <D.22659>:
  if (i <= 255) goto <D.22658>; else goto <D.22660>;
  <D.22660>:
  _wapi_fileshare_layout.3 = _wapi_fileshare_layout;
  D.22747 = _wapi_fileshare_layout.3->hwm;
  monoeg_g_print ("Fileshare hwm: %d\n", D.22747);
  i = 0;
  goto <D.22663>;
  <D.22662>:
  {
    struct _WapiFileShare * file_share;

    _wapi_fileshare_layout.3 = _wapi_fileshare_layout;
    file_share = &_wapi_fileshare_layout.3->share_info[i];
    D.22748 = file_share->handle_refs;
    if (D.22748 != 0) goto <D.22749>; else goto <D.22750>;
    <D.22749>:
    D.22748 = file_share->handle_refs;
    D.22751 = file_share->access;
    D.22752 = file_share->sharemode;
    D.22753 = file_share->opened_by_pid;
    D.22754 = file_share->inode;
    D.22755 = (long long int) D.22754;
    D.22756 = file_share->device;
    D.22757 = (long long int) D.22756;
    monoeg_g_print ("dev: 0x%llx ino: %lld open pid: %d share: 0x%x access: 0x%x refs: %d\n", D.22757, D.22755, D.22753, D.22752, D.22751, D.22748);
    <D.22750>:
  }
  i = i + 1;
  <D.22663>:
  _wapi_fileshare_layout.3 = _wapi_fileshare_layout;
  D.22747 = _wapi_fileshare_layout.3->hwm;
  if (D.22747 >= i) goto <D.22662>; else goto <D.22664>;
  <D.22664>:
  exit (0);
}


namedevent_details (struct _WapiHandleShared * handle)
{
  unsigned int D.22758;
  const char * iftmp.5;
  int D.22760;
  gchar * iftmp.6;
  const gchar * D.22768;
  static gchar buf[80];
  gchar * name;
  struct _WapiHandle_namedevent * event;

  event = &handle->u.namedevent;
  name = &event->sharedns.name;
  D.22758 = event->set_count;
  D.22760 = event->manual;
  if (D.22760 != 0) goto <D.22761>; else goto <D.22762>;
  <D.22761>:
  iftmp.5 = "Manual";
  goto <D.22763>;
  <D.22762>:
  iftmp.5 = "Auto";
  <D.22763>:
  if (name != 0B) goto <D.22765>; else goto <D.22766>;
  <D.22765>:
  iftmp.6 = name;
  goto <D.22767>;
  <D.22766>:
  iftmp.6 = "";
  <D.22767>:
  monoeg_g_snprintf (&buf, 80, "[%15s] %s count: %5u", iftmp.6, iftmp.5, D.22758);
  D.22768 = &buf;
  return D.22768;
}


namedsem_details (struct _WapiHandleShared * handle)
{
  int D.22770;
  unsigned int D.22771;
  gchar * iftmp.7;
  const gchar * D.22776;
  static gchar buf[80];
  gchar * name;
  struct _WapiHandle_namedsem * sem;

  sem = &handle->u.namedsem;
  name = &sem->sharedns.name;
  D.22770 = sem->max;
  D.22771 = sem->val;
  if (name != 0B) goto <D.22773>; else goto <D.22774>;
  <D.22773>:
  iftmp.7 = name;
  goto <D.22775>;
  <D.22774>:
  iftmp.7 = "";
  <D.22775>:
  monoeg_g_snprintf (&buf, 80, "[%15s] val: %5u, max: %5d", iftmp.7, D.22771, D.22770);
  D.22776 = &buf;
  return D.22776;
}


namedmutex_details (struct _WapiHandleShared * handle)
{
  unsigned int D.22778;
  long unsigned int D.22779;
  int D.22780;
  gchar * iftmp.8;
  const gchar * D.22785;
  static gchar buf[80];
  gchar * name;
  struct _WapiHandle_namedmutex * mut;

  mut = &handle->u.namedmutex;
  name = &mut->sharedns.name;
  D.22778 = mut->recursion;
  D.22779 = mut->tid;
  D.22780 = mut->pid;
  if (name != 0B) goto <D.22782>; else goto <D.22783>;
  <D.22782>:
  iftmp.8 = name;
  goto <D.22784>;
  <D.22783>:
  iftmp.8 = "";
  <D.22784>:
  monoeg_g_snprintf (&buf, 80, "[%15s] own: %5d:%5ld, count: %5u", iftmp.8, D.22780, D.22779, D.22778);
  D.22785 = &buf;
  return D.22785;
}


process_details (struct _WapiHandleShared * handle)
{
  unsigned int D.22787;
  int D.22788;
  gchar * iftmp.9;
  const gchar * D.22793;
  static gchar buf[80];
  gchar * name;
  struct _WapiHandle_process * proc;

  proc = &handle->u.process;
  name = &proc->proc_name;
  D.22787 = proc->exitstatus;
  D.22788 = proc->id;
  if (name != 0B) goto <D.22790>; else goto <D.22791>;
  <D.22790>:
  iftmp.9 = name;
  goto <D.22792>;
  <D.22791>:
  iftmp.9 = "";
  <D.22792>:
  monoeg_g_snprintf (&buf, 80, "[%25.25s] pid: %5u exit: %u", iftmp.9, D.22788, D.22787);
  D.22793 = &buf;
  return D.22793;
}


unshared_details (struct _WapiHandleShared * handle)
{
  const gchar * D.22795;

  D.22795 = "unshared details";
  return D.22795;
}


unused_details (struct _WapiHandleShared * handle)
{
  const gchar * D.22797;

  D.22797 = "unused details";
  return D.22797;
}


mini_wapi_semdel (int argc, char * * argv)
{
  void * _wapi_shared_layout.10;
  struct _WapiHandleSharedLayout * _wapi_shared_layout.11;
  int D.22804;
  int D.22805;
  int * D.22810;
  int D.22811;
  const gchar * D.22812;
  int sem_id;
  int ret;

  _wapi_shared_layout.10 = _wapi_shm_attach (0);
  _wapi_shared_layout = _wapi_shared_layout.10;
  _wapi_shared_layout.11 = _wapi_shared_layout;
  if (_wapi_shared_layout.11 == 0B) goto <D.22800>; else goto <D.22803>;
  <D.22803>:
  _wapi_shared_layout.11 = _wapi_shared_layout;
  D.22804 = _wapi_shared_layout.11->sem_key;
  if (D.22804 == 0) goto <D.22800>; else goto <D.22801>;
  <D.22800>:
  exit (0);
  <D.22801>:
  _wapi_shared_layout.11 = _wapi_shared_layout;
  D.22805 = _wapi_shared_layout.11->sem_key;
  sem_id = semget (D.22805, 8, 384);
  if (sem_id != -1) goto <D.22806>; else goto <D.22807>;
  <D.22806>:
  ret = semctl (sem_id, 0, 0);
  if (ret == -1) goto <D.22808>; else goto <D.22809>;
  <D.22808>:
  D.22810 = __errno_location ();
  D.22811 = *D.22810;
  D.22812 = monoeg_g_strerror (D.22811);
  monoeg_g_log (0B, 32, "Error deleting semaphore: %s", D.22812);
  <D.22809>:
  <D.22807>:
  exit (0);
}


mini_wapi_seminfo (int argc, char * * argv)
{
  void * _wapi_shared_layout.12;
  struct _WapiHandleSharedLayout * _wapi_shared_layout.13;
  int D.22818;
  int D.22819;
  int D.22822;
  short unsigned int D.22825;
  int D.22826;
  int sem_id;
  int ret;
  typedef union semun unionunion semun;
  union semun arg;
  ushort vals[8];

  try
    {
      _wapi_shared_layout.12 = _wapi_shm_attach (0);
      _wapi_shared_layout = _wapi_shared_layout.12;
      _wapi_shared_layout.13 = _wapi_shared_layout;
      if (_wapi_shared_layout.13 == 0B) goto <D.22814>; else goto <D.22817>;
      <D.22817>:
      _wapi_shared_layout.13 = _wapi_shared_layout;
      D.22818 = _wapi_shared_layout.13->sem_key;
      if (D.22818 == 0) goto <D.22814>; else goto <D.22815>;
      <D.22814>:
      exit (0);
      <D.22815>:
      _wapi_shared_layout.13 = _wapi_shared_layout;
      D.22819 = _wapi_shared_layout.13->sem_key;
      sem_id = semget (D.22819, 8, 384);
      if (sem_id != -1) goto <D.22820>; else goto <D.22821>;
      <D.22820>:
      _wapi_shared_layout.13 = _wapi_shared_layout;
      D.22822 = _wapi_shared_layout.13->sem_key;
      monoeg_g_print ("Getting values for sem: 0x%x\n", D.22822);
      arg.array = &vals;
      ret = semctl (sem_id, 0, 13, arg);
      if (ret != -1) goto <D.22823>; else goto <D.22824>;
      <D.22823>:
      monoeg_g_print ("Namespace: ");
      sem_explain (sem_id, &vals, 0);
      monoeg_g_print ("Fileshare: ");
      sem_explain (sem_id, &vals, 2);
      monoeg_g_print ("Handles: ");
      sem_explain (sem_id, &vals, 3);
      monoeg_g_print ("Count lock: ");
      sem_explain (sem_id, &vals, 6);
      D.22825 = vals[7];
      D.22826 = (int) D.22825;
      monoeg_g_print ("Count: %d\n", D.22826);
      <D.22824>:
      <D.22821>:
      exit (0);
    }
  finally
    {
      arg = {CLOBBER};
      vals = {CLOBBER};
    }
}


sem_explain (int sem_id, ushort * vals, int which)
{
  unsigned int which.14;
  unsigned int D.22828;
  ushort * D.22829;
  short unsigned int D.22830;
  int D.22831;
  pid_t pid;

  which.14 = (unsigned int) which;
  D.22828 = which.14 * 2;
  D.22829 = vals + D.22828;
  D.22830 = *D.22829;
  D.22831 = (int) D.22830;
  monoeg_g_print ("%d ", D.22831);
  which.14 = (unsigned int) which;
  D.22828 = which.14 * 2;
  D.22829 = vals + D.22828;
  D.22830 = *D.22829;
  if (D.22830 != 0) goto <D.22832>; else goto <D.22833>;
  <D.22832>:
  monoeg_g_print ("(Unlocked)");
  goto <D.22834>;
  <D.22833>:
  pid = semctl (sem_id, which, 11);
  monoeg_g_print ("(Locked by %d)", pid);
  <D.22834>:
  monoeg_g_print ("\n");
}


