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.23166;
  unsigned int D.23167;
  long int D.23168;
  <unnamed type> D.23169;
  const gchar * (*<T3b51>) (struct _WapiHandleShared *) D.23172;
  const gchar * D.23173;
  const char * iftmp.4;
  int D.23175;
  unsigned int D.23179;
  unsigned int D.23180;
  const char * D.23181;
  unsigned int D.23182;
  unsigned int D.23183;
  unsigned int D.23184;
  unsigned int D.23187;
  unsigned int D.23188;
  int D.23189;
  long unsigned int D.23190;
  long long int D.23191;
  long unsigned int D.23192;
  long long int D.23193;
  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.23158>; else goto <D.23159>;
  <D.23158>:
  monoeg_g_log (0B, 4, "Failed to attach shared memory!");
  <D.23091>:
  goto <D.23091>;
  exit (-1);
  <D.23159>:
  _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.23162>; else goto <D.23163>;
  <D.23162>:
  monoeg_g_log (0B, 4, "Failed to attach fileshare shared memory!");
  <D.23092>:
  goto <D.23092>;
  exit (-1);
  <D.23163>:
  if (argc > 1) goto <D.23164>; else goto <D.23165>;
  <D.23164>:
  _wapi_shm_semaphores_init ();
  _wapi_collection_init ();
  _wapi_handle_collect ();
  <D.23165>:
  _wapi_shared_layout.1 = _wapi_shared_layout;
  D.23166 = _wapi_shared_layout.1->sem_key;
  _wapi_shared_layout.1 = _wapi_shared_layout;
  D.23167 = _wapi_shared_layout.1->collection_count;
  monoeg_g_print ("collection: %d sem: 0x%x\n", D.23167, D.23166);
  D.23168 = time (0B);
  now = (guint32) D.23168;
  i = 0;
  goto <D.23095>;
  <D.23094>:
  {
    struct _WapiHandleShared * shared;

    _wapi_shared_layout.1 = _wapi_shared_layout;
    shared = &_wapi_shared_layout.1->handles[i];
    D.23169 = shared->type;
    if (D.23169 != 0) goto <D.23170>; else goto <D.23171>;
    <D.23170>:
    D.23169 = shared->type;
    D.23172 = details[D.23169];
    D.23173 = D.23172 (shared);
    D.23175 = shared->signalled;
    if (D.23175 != 0) goto <D.23176>; else goto <D.23177>;
    <D.23176>:
    iftmp.4 = "Sg";
    goto <D.23178>;
    <D.23177>:
    iftmp.4 = "Un";
    <D.23178>:
    D.23179 = shared->timestamp;
    D.23180 = now - D.23179;
    D.23169 = shared->type;
    D.23181 = _wapi_handle_typename[D.23169];
    D.23182 = shared->handle_refs;
    monoeg_g_print ("%3x (%3d) [%7s] %4u %s (%s)\n", i, D.23182, D.23181, D.23180, iftmp.4, D.23173);
    <D.23171>:
  }
  i = i + 1;
  <D.23095>:
  if (i <= 255) goto <D.23094>; else goto <D.23096>;
  <D.23096>:
  _wapi_fileshare_layout.3 = _wapi_fileshare_layout;
  D.23183 = _wapi_fileshare_layout.3->hwm;
  monoeg_g_print ("Fileshare hwm: %d\n", D.23183);
  i = 0;
  goto <D.23099>;
  <D.23098>:
  {
    struct _WapiFileShare * file_share;

    _wapi_fileshare_layout.3 = _wapi_fileshare_layout;
    file_share = &_wapi_fileshare_layout.3->share_info[i];
    D.23184 = file_share->handle_refs;
    if (D.23184 != 0) goto <D.23185>; else goto <D.23186>;
    <D.23185>:
    D.23184 = file_share->handle_refs;
    D.23187 = file_share->access;
    D.23188 = file_share->sharemode;
    D.23189 = file_share->opened_by_pid;
    D.23190 = file_share->inode;
    D.23191 = (long long int) D.23190;
    D.23192 = file_share->device;
    D.23193 = (long long int) D.23192;
    monoeg_g_print ("dev: 0x%llx ino: %lld open pid: %d share: 0x%x access: 0x%x refs: %d\n", D.23193, D.23191, D.23189, D.23188, D.23187, D.23184);
    <D.23186>:
  }
  i = i + 1;
  <D.23099>:
  _wapi_fileshare_layout.3 = _wapi_fileshare_layout;
  D.23183 = _wapi_fileshare_layout.3->hwm;
  if (D.23183 >= i) goto <D.23098>; else goto <D.23100>;
  <D.23100>:
  exit (0);
}


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

  event = &handle->u.namedevent;
  name = &event->sharedns.name;
  D.23194 = event->set_count;
  D.23196 = event->manual;
  if (D.23196 != 0) goto <D.23197>; else goto <D.23198>;
  <D.23197>:
  iftmp.5 = "Manual";
  goto <D.23199>;
  <D.23198>:
  iftmp.5 = "Auto";
  <D.23199>:
  if (name != 0B) goto <D.23201>; else goto <D.23202>;
  <D.23201>:
  iftmp.6 = name;
  goto <D.23203>;
  <D.23202>:
  iftmp.6 = "";
  <D.23203>:
  monoeg_g_snprintf (&buf, 80, "[%15s] %s count: %5u", iftmp.6, iftmp.5, D.23194);
  D.23204 = &buf;
  return D.23204;
}


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

  sem = &handle->u.namedsem;
  name = &sem->sharedns.name;
  D.23206 = sem->max;
  D.23207 = sem->val;
  if (name != 0B) goto <D.23209>; else goto <D.23210>;
  <D.23209>:
  iftmp.7 = name;
  goto <D.23211>;
  <D.23210>:
  iftmp.7 = "";
  <D.23211>:
  monoeg_g_snprintf (&buf, 80, "[%15s] val: %5u, max: %5d", iftmp.7, D.23207, D.23206);
  D.23212 = &buf;
  return D.23212;
}


namedmutex_details (struct _WapiHandleShared * handle)
{
  unsigned int D.23214;
  long unsigned int D.23215;
  int D.23216;
  gchar * iftmp.8;
  const gchar * D.23221;
  static gchar buf[80];
  gchar * name;
  struct _WapiHandle_namedmutex * mut;

  mut = &handle->u.namedmutex;
  name = &mut->sharedns.name;
  D.23214 = mut->recursion;
  D.23215 = mut->tid;
  D.23216 = mut->pid;
  if (name != 0B) goto <D.23218>; else goto <D.23219>;
  <D.23218>:
  iftmp.8 = name;
  goto <D.23220>;
  <D.23219>:
  iftmp.8 = "";
  <D.23220>:
  monoeg_g_snprintf (&buf, 80, "[%15s] own: %5d:%5ld, count: %5u", iftmp.8, D.23216, D.23215, D.23214);
  D.23221 = &buf;
  return D.23221;
}


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

  proc = &handle->u.process;
  name = &proc->proc_name;
  D.23223 = proc->exitstatus;
  D.23224 = proc->id;
  if (name != 0B) goto <D.23226>; else goto <D.23227>;
  <D.23226>:
  iftmp.9 = name;
  goto <D.23228>;
  <D.23227>:
  iftmp.9 = "";
  <D.23228>:
  monoeg_g_snprintf (&buf, 80, "[%25.25s] pid: %5u exit: %u", iftmp.9, D.23224, D.23223);
  D.23229 = &buf;
  return D.23229;
}


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

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


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

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


mini_wapi_semdel (int argc, char * * argv)
{
  void * _wapi_shared_layout.10;
  struct _WapiHandleSharedLayout * _wapi_shared_layout.11;
  int D.23240;
  int D.23241;
  int * D.23246;
  int D.23247;
  const gchar * D.23248;
  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.23236>; else goto <D.23239>;
  <D.23239>:
  _wapi_shared_layout.11 = _wapi_shared_layout;
  D.23240 = _wapi_shared_layout.11->sem_key;
  if (D.23240 == 0) goto <D.23236>; else goto <D.23237>;
  <D.23236>:
  exit (0);
  <D.23237>:
  _wapi_shared_layout.11 = _wapi_shared_layout;
  D.23241 = _wapi_shared_layout.11->sem_key;
  sem_id = semget (D.23241, 8, 384);
  if (sem_id != -1) goto <D.23242>; else goto <D.23243>;
  <D.23242>:
  ret = semctl (sem_id, 0, 0);
  if (ret == -1) goto <D.23244>; else goto <D.23245>;
  <D.23244>:
  D.23246 = __errno_location ();
  D.23247 = *D.23246;
  D.23248 = monoeg_g_strerror (D.23247);
  monoeg_g_log (0B, 32, "Error deleting semaphore: %s", D.23248);
  <D.23245>:
  <D.23243>:
  exit (0);
}


mini_wapi_seminfo (int argc, char * * argv)
{
  void * _wapi_shared_layout.12;
  struct _WapiHandleSharedLayout * _wapi_shared_layout.13;
  int D.23254;
  int D.23255;
  int D.23258;
  short unsigned int D.23261;
  int D.23262;
  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.23250>; else goto <D.23253>;
      <D.23253>:
      _wapi_shared_layout.13 = _wapi_shared_layout;
      D.23254 = _wapi_shared_layout.13->sem_key;
      if (D.23254 == 0) goto <D.23250>; else goto <D.23251>;
      <D.23250>:
      exit (0);
      <D.23251>:
      _wapi_shared_layout.13 = _wapi_shared_layout;
      D.23255 = _wapi_shared_layout.13->sem_key;
      sem_id = semget (D.23255, 8, 384);
      if (sem_id != -1) goto <D.23256>; else goto <D.23257>;
      <D.23256>:
      _wapi_shared_layout.13 = _wapi_shared_layout;
      D.23258 = _wapi_shared_layout.13->sem_key;
      monoeg_g_print ("Getting values for sem: 0x%x\n", D.23258);
      arg.array = &vals;
      ret = semctl (sem_id, 0, 13, arg);
      if (ret != -1) goto <D.23259>; else goto <D.23260>;
      <D.23259>:
      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.23261 = vals[7];
      D.23262 = (int) D.23261;
      monoeg_g_print ("Count: %d\n", D.23262);
      <D.23260>:
      <D.23257>:
      exit (0);
    }
  finally
    {
      arg = {CLOBBER};
      vals = {CLOBBER};
    }
}


sem_explain (int sem_id, ushort * vals, int which)
{
  long unsigned int D.23263;
  long unsigned int D.23264;
  ushort * D.23265;
  short unsigned int D.23266;
  int D.23267;
  pid_t pid;

  D.23263 = (long unsigned int) which;
  D.23264 = D.23263 * 2;
  D.23265 = vals + D.23264;
  D.23266 = *D.23265;
  D.23267 = (int) D.23266;
  monoeg_g_print ("%d ", D.23267);
  D.23263 = (long unsigned int) which;
  D.23264 = D.23263 * 2;
  D.23265 = vals + D.23264;
  D.23266 = *D.23265;
  if (D.23266 != 0) goto <D.23268>; else goto <D.23269>;
  <D.23268>:
  monoeg_g_print ("(Unlocked)");
  goto <D.23270>;
  <D.23269>:
  pid = semctl (sem_id, which, 11);
  monoeg_g_print ("(Locked by %d)", pid);
  <D.23270>:
  monoeg_g_print ("\n");
}


