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.25244;
  int D.25245;
  long int D.25246;
  <unnamed type> D.25247;
  unsigned int D.25250;
  const char * D.25251;
  unsigned int D.25252;
  unsigned int D.25253;
  const char * iftmp.4;
  int D.25255;
  const gchar * (*<T455c>) (struct _WapiHandleShared *) D.25259;
  const gchar * D.25260;
  unsigned int D.25261;
  unsigned int D.25262;
  long long unsigned int D.25265;
  long long int D.25266;
  long long unsigned int D.25267;
  long long int D.25268;
  int D.25269;
  unsigned int D.25270;
  unsigned int D.25271;
  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.25236>; else goto <D.25237>;
  <D.25236>:
  monoeg_g_log (0B, 4, "Failed to attach shared memory!");
  <D.25167>:
  goto <D.25167>;
  exit (-1);
  <D.25237>:
  _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.25240>; else goto <D.25241>;
  <D.25240>:
  monoeg_g_log (0B, 4, "Failed to attach fileshare shared memory!");
  <D.25168>:
  goto <D.25168>;
  exit (-1);
  <D.25241>:
  if (argc > 1) goto <D.25242>; else goto <D.25243>;
  <D.25242>:
  _wapi_shm_semaphores_init ();
  _wapi_collection_init ();
  _wapi_handle_collect ();
  <D.25243>:
  _wapi_shared_layout.1 = _wapi_shared_layout;
  D.25244 = _wapi_shared_layout.1->collection_count;
  _wapi_shared_layout.1 = _wapi_shared_layout;
  D.25245 = _wapi_shared_layout.1->sem_key;
  monoeg_g_print ("collection: %d sem: 0x%x\n", D.25244, D.25245);
  D.25246 = time (0B);
  now = (guint32) D.25246;
  i = 0;
  goto <D.25171>;
  <D.25170>:
  {
    struct _WapiHandleShared * shared;

    _wapi_shared_layout.1 = _wapi_shared_layout;
    shared = &_wapi_shared_layout.1->handles[i];
    D.25247 = shared->type;
    if (D.25247 != 0) goto <D.25248>; else goto <D.25249>;
    <D.25248>:
    D.25250 = shared->handle_refs;
    D.25247 = shared->type;
    D.25251 = _wapi_handle_typename[D.25247];
    D.25252 = shared->timestamp;
    D.25253 = now - D.25252;
    D.25255 = shared->signalled;
    if (D.25255 != 0) goto <D.25256>; else goto <D.25257>;
    <D.25256>:
    iftmp.4 = "Sg";
    goto <D.25258>;
    <D.25257>:
    iftmp.4 = "Un";
    <D.25258>:
    D.25247 = shared->type;
    D.25259 = details[D.25247];
    D.25260 = D.25259 (shared);
    monoeg_g_print ("%3x (%3d) [%7s] %4u %s (%s)\n", i, D.25250, D.25251, D.25253, iftmp.4, D.25260);
    <D.25249>:
  }
  i = i + 1;
  <D.25171>:
  if (i <= 255) goto <D.25170>; else goto <D.25172>;
  <D.25172>:
  _wapi_fileshare_layout.3 = _wapi_fileshare_layout;
  D.25261 = _wapi_fileshare_layout.3->hwm;
  monoeg_g_print ("Fileshare hwm: %d\n", D.25261);
  i = 0;
  goto <D.25175>;
  <D.25174>:
  {
    struct _WapiFileShare * file_share;

    _wapi_fileshare_layout.3 = _wapi_fileshare_layout;
    file_share = &_wapi_fileshare_layout.3->share_info[i];
    D.25262 = file_share->handle_refs;
    if (D.25262 != 0) goto <D.25263>; else goto <D.25264>;
    <D.25263>:
    D.25265 = file_share->device;
    D.25266 = (long long int) D.25265;
    D.25267 = file_share->inode;
    D.25268 = (long long int) D.25267;
    D.25269 = file_share->opened_by_pid;
    D.25270 = file_share->sharemode;
    D.25271 = file_share->access;
    D.25262 = 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.25266, D.25268, D.25269, D.25270, D.25271, D.25262);
    <D.25264>:
  }
  i = i + 1;
  <D.25175>:
  _wapi_fileshare_layout.3 = _wapi_fileshare_layout;
  D.25261 = _wapi_fileshare_layout.3->hwm;
  if (D.25261 >= i) goto <D.25174>; else goto <D.25176>;
  <D.25176>:
  exit (0);
}


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

  event = &handle->u.namedevent;
  name = &event->sharedns.name;
  if (name != 0B) goto <D.25273>; else goto <D.25274>;
  <D.25273>:
  iftmp.5 = name;
  goto <D.25275>;
  <D.25274>:
  iftmp.5 = "";
  <D.25275>:
  D.25277 = event->manual;
  if (D.25277 != 0) goto <D.25278>; else goto <D.25279>;
  <D.25278>:
  iftmp.6 = "Manual";
  goto <D.25280>;
  <D.25279>:
  iftmp.6 = "Auto";
  <D.25280>:
  D.25281 = event->set_count;
  monoeg_g_snprintf (&buf, 80, "[%15s] %s count: %5u", iftmp.5, iftmp.6, D.25281);
  D.25282 = &buf;
  return D.25282;
}


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

  sem = &handle->u.namedsem;
  name = &sem->sharedns.name;
  if (name != 0B) goto <D.25285>; else goto <D.25286>;
  <D.25285>:
  iftmp.7 = name;
  goto <D.25287>;
  <D.25286>:
  iftmp.7 = "";
  <D.25287>:
  D.25288 = sem->val;
  D.25289 = sem->max;
  monoeg_g_snprintf (&buf, 80, "[%15s] val: %5u, max: %5d", iftmp.7, D.25288, D.25289);
  D.25290 = &buf;
  return D.25290;
}


namedmutex_details (struct _WapiHandleShared * handle)
{
  gchar * iftmp.8;
  int D.25296;
  long unsigned int D.25297;
  unsigned int D.25298;
  const gchar * D.25299;
  static gchar buf[80];
  gchar * name;
  struct _WapiHandle_namedmutex * mut;

  mut = &handle->u.namedmutex;
  name = &mut->sharedns.name;
  if (name != 0B) goto <D.25293>; else goto <D.25294>;
  <D.25293>:
  iftmp.8 = name;
  goto <D.25295>;
  <D.25294>:
  iftmp.8 = "";
  <D.25295>:
  D.25296 = mut->pid;
  D.25297 = mut->tid;
  D.25298 = mut->recursion;
  monoeg_g_snprintf (&buf, 80, "[%15s] own: %5d:%5ld, count: %5u", iftmp.8, D.25296, D.25297, D.25298);
  D.25299 = &buf;
  return D.25299;
}


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

  proc = &handle->u.process;
  name = &proc->proc_name;
  if (name != 0B) goto <D.25302>; else goto <D.25303>;
  <D.25302>:
  iftmp.9 = name;
  goto <D.25304>;
  <D.25303>:
  iftmp.9 = "";
  <D.25304>:
  D.25305 = proc->id;
  D.25306 = proc->exitstatus;
  monoeg_g_snprintf (&buf, 80, "[%25.25s] pid: %5u exit: %u", iftmp.9, D.25305, D.25306);
  D.25307 = &buf;
  return D.25307;
}


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

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


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

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


mini_wapi_semdel (int argc, char * * argv)
{
  void * _wapi_shared_layout.10;
  struct _WapiHandleSharedLayout * _wapi_shared_layout.11;
  int D.25318;
  int D.25319;
  int * D.25324;
  int D.25325;
  const gchar * D.25326;
  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.25314>; else goto <D.25317>;
  <D.25317>:
  _wapi_shared_layout.11 = _wapi_shared_layout;
  D.25318 = _wapi_shared_layout.11->sem_key;
  if (D.25318 == 0) goto <D.25314>; else goto <D.25315>;
  <D.25314>:
  exit (0);
  <D.25315>:
  _wapi_shared_layout.11 = _wapi_shared_layout;
  D.25319 = _wapi_shared_layout.11->sem_key;
  sem_id = semget (D.25319, 8, 384);
  if (sem_id != -1) goto <D.25320>; else goto <D.25321>;
  <D.25320>:
  ret = semctl (sem_id, 0, 0);
  if (ret == -1) goto <D.25322>; else goto <D.25323>;
  <D.25322>:
  D.25324 = __errno_location ();
  D.25325 = *D.25324;
  D.25326 = monoeg_g_strerror (D.25325);
  monoeg_g_log (0B, 32, "Error deleting semaphore: %s", D.25326);
  <D.25323>:
  <D.25321>:
  exit (0);
}


mini_wapi_seminfo (int argc, char * * argv)
{
  void * _wapi_shared_layout.12;
  struct _WapiHandleSharedLayout * _wapi_shared_layout.13;
  int D.25332;
  int D.25333;
  int D.25336;
  short unsigned int D.25339;
  int D.25340;
  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.25328>; else goto <D.25331>;
      <D.25331>:
      _wapi_shared_layout.13 = _wapi_shared_layout;
      D.25332 = _wapi_shared_layout.13->sem_key;
      if (D.25332 == 0) goto <D.25328>; else goto <D.25329>;
      <D.25328>:
      exit (0);
      <D.25329>:
      _wapi_shared_layout.13 = _wapi_shared_layout;
      D.25333 = _wapi_shared_layout.13->sem_key;
      sem_id = semget (D.25333, 8, 384);
      if (sem_id != -1) goto <D.25334>; else goto <D.25335>;
      <D.25334>:
      _wapi_shared_layout.13 = _wapi_shared_layout;
      D.25336 = _wapi_shared_layout.13->sem_key;
      monoeg_g_print ("Getting values for sem: 0x%x\n", D.25336);
      arg.array = &vals;
      ret = semctl (sem_id, 0, 13, arg);
      if (ret != -1) goto <D.25337>; else goto <D.25338>;
      <D.25337>:
      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.25339 = vals[7];
      D.25340 = (int) D.25339;
      monoeg_g_print ("Count: %d\n", D.25340);
      <D.25338>:
      <D.25335>:
      exit (0);
    }
  finally
    {
      arg = {CLOBBER};
      vals = {CLOBBER};
    }
}


sem_explain (int sem_id, ushort * vals, int which)
{
  unsigned int which.14;
  unsigned int D.25342;
  ushort * D.25343;
  short unsigned int D.25344;
  int D.25345;
  pid_t pid;

  which.14 = (unsigned int) which;
  D.25342 = which.14 * 2;
  D.25343 = vals + D.25342;
  D.25344 = *D.25343;
  D.25345 = (int) D.25344;
  monoeg_g_print ("%d ", D.25345);
  which.14 = (unsigned int) which;
  D.25342 = which.14 * 2;
  D.25343 = vals + D.25342;
  D.25344 = *D.25343;
  if (D.25344 != 0) goto <D.25346>; else goto <D.25347>;
  <D.25346>:
  monoeg_g_print ("(Unlocked)");
  goto <D.25348>;
  <D.25347>:
  pid = semctl (sem_id, which, 11);
  monoeg_g_print ("(Locked by %d)", pid);
  <D.25348>:
  monoeg_g_print ("\n");
}


