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;
  unsigned int D.23263;
  int D.23264;
  long int D.23265;
  <unnamed type> D.23266;
  unsigned int D.23269;
  const char * D.23270;
  unsigned int D.23271;
  unsigned int D.23272;
  const char * iftmp.4;
  int D.23274;
  const gchar * (*<T3bb8>) (struct _WapiHandleShared *) D.23278;
  const gchar * D.23279;
  unsigned int D.23280;
  unsigned int D.23281;
  long unsigned int D.23284;
  long long int D.23285;
  long unsigned int D.23286;
  long long int D.23287;
  int D.23288;
  unsigned int D.23289;
  unsigned int D.23290;
  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.23255>; else goto <D.23256>;
  <D.23255>:
  monoeg_g_log (0B, 4, "Failed to attach shared memory!");
  <D.23188>:
  goto <D.23188>;
  exit (-1);
  <D.23256>:
  _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.23259>; else goto <D.23260>;
  <D.23259>:
  monoeg_g_log (0B, 4, "Failed to attach fileshare shared memory!");
  <D.23189>:
  goto <D.23189>;
  exit (-1);
  <D.23260>:
  if (argc > 1) goto <D.23261>; else goto <D.23262>;
  <D.23261>:
  _wapi_shm_semaphores_init ();
  _wapi_collection_init ();
  _wapi_handle_collect ();
  <D.23262>:
  _wapi_shared_layout.1 = _wapi_shared_layout;
  D.23263 = _wapi_shared_layout.1->collection_count;
  _wapi_shared_layout.1 = _wapi_shared_layout;
  D.23264 = _wapi_shared_layout.1->sem_key;
  monoeg_g_print ("collection: %d sem: 0x%x\n", D.23263, D.23264);
  D.23265 = time (0B);
  now = (guint32) D.23265;
  i = 0;
  goto <D.23192>;
  <D.23191>:
  {
    struct _WapiHandleShared * shared;

    _wapi_shared_layout.1 = _wapi_shared_layout;
    shared = &_wapi_shared_layout.1->handles[i];
    D.23266 = shared->type;
    if (D.23266 != 0) goto <D.23267>; else goto <D.23268>;
    <D.23267>:
    D.23269 = shared->handle_refs;
    D.23266 = shared->type;
    D.23270 = _wapi_handle_typename[D.23266];
    D.23271 = shared->timestamp;
    D.23272 = now - D.23271;
    D.23274 = shared->signalled;
    if (D.23274 != 0) goto <D.23275>; else goto <D.23276>;
    <D.23275>:
    iftmp.4 = "Sg";
    goto <D.23277>;
    <D.23276>:
    iftmp.4 = "Un";
    <D.23277>:
    D.23266 = shared->type;
    D.23278 = details[D.23266];
    D.23279 = D.23278 (shared);
    monoeg_g_print ("%3x (%3d) [%7s] %4u %s (%s)\n", i, D.23269, D.23270, D.23272, iftmp.4, D.23279);
    <D.23268>:
  }
  i = i + 1;
  <D.23192>:
  if (i <= 255) goto <D.23191>; else goto <D.23193>;
  <D.23193>:
  _wapi_fileshare_layout.3 = _wapi_fileshare_layout;
  D.23280 = _wapi_fileshare_layout.3->hwm;
  monoeg_g_print ("Fileshare hwm: %d\n", D.23280);
  i = 0;
  goto <D.23196>;
  <D.23195>:
  {
    struct _WapiFileShare * file_share;

    _wapi_fileshare_layout.3 = _wapi_fileshare_layout;
    file_share = &_wapi_fileshare_layout.3->share_info[i];
    D.23281 = file_share->handle_refs;
    if (D.23281 != 0) goto <D.23282>; else goto <D.23283>;
    <D.23282>:
    D.23284 = file_share->device;
    D.23285 = (long long int) D.23284;
    D.23286 = file_share->inode;
    D.23287 = (long long int) D.23286;
    D.23288 = file_share->opened_by_pid;
    D.23289 = file_share->sharemode;
    D.23290 = file_share->access;
    D.23281 = file_share->handle_refs;
    monoeg_g_print ("dev: 0x%llx ino: %lld open pid: %d share: 0x%x access: 0x%x refs: %d\n", D.23285, D.23287, D.23288, D.23289, D.23290, D.23281);
    <D.23283>:
  }
  i = i + 1;
  <D.23196>:
  _wapi_fileshare_layout.3 = _wapi_fileshare_layout;
  D.23280 = _wapi_fileshare_layout.3->hwm;
  if (D.23280 >= i) goto <D.23195>; else goto <D.23197>;
  <D.23197>:
  exit (0);
}


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

  event = &handle->u.namedevent;
  name = &event->sharedns.name;
  if (name != 0B) goto <D.23292>; else goto <D.23293>;
  <D.23292>:
  iftmp.5 = name;
  goto <D.23294>;
  <D.23293>:
  iftmp.5 = "";
  <D.23294>:
  D.23296 = event->manual;
  if (D.23296 != 0) goto <D.23297>; else goto <D.23298>;
  <D.23297>:
  iftmp.6 = "Manual";
  goto <D.23299>;
  <D.23298>:
  iftmp.6 = "Auto";
  <D.23299>:
  D.23300 = event->set_count;
  monoeg_g_snprintf (&buf, 80, "[%15s] %s count: %5u", iftmp.5, iftmp.6, D.23300);
  D.23301 = &buf;
  return D.23301;
}


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

  sem = &handle->u.namedsem;
  name = &sem->sharedns.name;
  if (name != 0B) goto <D.23304>; else goto <D.23305>;
  <D.23304>:
  iftmp.7 = name;
  goto <D.23306>;
  <D.23305>:
  iftmp.7 = "";
  <D.23306>:
  D.23307 = sem->val;
  D.23308 = sem->max;
  monoeg_g_snprintf (&buf, 80, "[%15s] val: %5u, max: %5d", iftmp.7, D.23307, D.23308);
  D.23309 = &buf;
  return D.23309;
}


namedmutex_details (struct _WapiHandleShared * handle)
{
  gchar * iftmp.8;
  int D.23315;
  long unsigned int D.23316;
  unsigned int D.23317;
  const gchar * D.23318;
  static gchar buf[80];
  gchar * name;
  struct _WapiHandle_namedmutex * mut;

  mut = &handle->u.namedmutex;
  name = &mut->sharedns.name;
  if (name != 0B) goto <D.23312>; else goto <D.23313>;
  <D.23312>:
  iftmp.8 = name;
  goto <D.23314>;
  <D.23313>:
  iftmp.8 = "";
  <D.23314>:
  D.23315 = mut->pid;
  D.23316 = mut->tid;
  D.23317 = mut->recursion;
  monoeg_g_snprintf (&buf, 80, "[%15s] own: %5d:%5ld, count: %5u", iftmp.8, D.23315, D.23316, D.23317);
  D.23318 = &buf;
  return D.23318;
}


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

  proc = &handle->u.process;
  name = &proc->proc_name;
  if (name != 0B) goto <D.23321>; else goto <D.23322>;
  <D.23321>:
  iftmp.9 = name;
  goto <D.23323>;
  <D.23322>:
  iftmp.9 = "";
  <D.23323>:
  D.23324 = proc->id;
  D.23325 = proc->exitstatus;
  monoeg_g_snprintf (&buf, 80, "[%25.25s] pid: %5u exit: %u", iftmp.9, D.23324, D.23325);
  D.23326 = &buf;
  return D.23326;
}


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

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


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

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


mini_wapi_semdel (int argc, char * * argv)
{
  void * _wapi_shared_layout.10;
  struct _WapiHandleSharedLayout * _wapi_shared_layout.11;
  int D.23337;
  int D.23338;
  int * D.23343;
  int D.23344;
  const gchar * D.23345;
  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.23333>; else goto <D.23336>;
  <D.23336>:
  _wapi_shared_layout.11 = _wapi_shared_layout;
  D.23337 = _wapi_shared_layout.11->sem_key;
  if (D.23337 == 0) goto <D.23333>; else goto <D.23334>;
  <D.23333>:
  exit (0);
  <D.23334>:
  _wapi_shared_layout.11 = _wapi_shared_layout;
  D.23338 = _wapi_shared_layout.11->sem_key;
  sem_id = semget (D.23338, 8, 384);
  if (sem_id != -1) goto <D.23339>; else goto <D.23340>;
  <D.23339>:
  ret = semctl (sem_id, 0, 0);
  if (ret == -1) goto <D.23341>; else goto <D.23342>;
  <D.23341>:
  D.23343 = __errno_location ();
  D.23344 = *D.23343;
  D.23345 = monoeg_g_strerror (D.23344);
  monoeg_g_log (0B, 32, "Error deleting semaphore: %s", D.23345);
  <D.23342>:
  <D.23340>:
  exit (0);
}


mini_wapi_seminfo (int argc, char * * argv)
{
  void * _wapi_shared_layout.12;
  struct _WapiHandleSharedLayout * _wapi_shared_layout.13;
  int D.23351;
  int D.23352;
  int D.23355;
  short unsigned int D.23358;
  int D.23359;
  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.23347>; else goto <D.23350>;
      <D.23350>:
      _wapi_shared_layout.13 = _wapi_shared_layout;
      D.23351 = _wapi_shared_layout.13->sem_key;
      if (D.23351 == 0) goto <D.23347>; else goto <D.23348>;
      <D.23347>:
      exit (0);
      <D.23348>:
      _wapi_shared_layout.13 = _wapi_shared_layout;
      D.23352 = _wapi_shared_layout.13->sem_key;
      sem_id = semget (D.23352, 8, 384);
      if (sem_id != -1) goto <D.23353>; else goto <D.23354>;
      <D.23353>:
      _wapi_shared_layout.13 = _wapi_shared_layout;
      D.23355 = _wapi_shared_layout.13->sem_key;
      monoeg_g_print ("Getting values for sem: 0x%x\n", D.23355);
      arg.array = &vals;
      ret = semctl (sem_id, 0, 13, arg);
      if (ret != -1) goto <D.23356>; else goto <D.23357>;
      <D.23356>:
      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.23358 = vals[7];
      D.23359 = (int) D.23358;
      monoeg_g_print ("Count: %d\n", D.23359);
      <D.23357>:
      <D.23354>:
      exit (0);
    }
  finally
    {
      arg = {CLOBBER};
      vals = {CLOBBER};
    }
}


sem_explain (int sem_id, ushort * vals, int which)
{
  long unsigned int D.23360;
  long unsigned int D.23361;
  ushort * D.23362;
  short unsigned int D.23363;
  int D.23364;
  pid_t pid;

  D.23360 = (long unsigned int) which;
  D.23361 = D.23360 * 2;
  D.23362 = vals + D.23361;
  D.23363 = *D.23362;
  D.23364 = (int) D.23363;
  monoeg_g_print ("%d ", D.23364);
  D.23360 = (long unsigned int) which;
  D.23361 = D.23360 * 2;
  D.23362 = vals + D.23361;
  D.23363 = *D.23362;
  if (D.23363 != 0) goto <D.23365>; else goto <D.23366>;
  <D.23365>:
  monoeg_g_print ("(Unlocked)");
  goto <D.23367>;
  <D.23366>:
  pid = semctl (sem_id, which, 11);
  monoeg_g_print ("(Locked by %d)", pid);
  <D.23367>:
  monoeg_g_print ("\n");
}


