__attribute__((visibility ("hidden")))
mini_wapi_hps (int argc, char * * argv)
{
  void * D.23073;
  struct _WapiHandleSharedLayout * _wapi_shared_layout.0;
  void * D.23077;
  struct _WapiFileShareLayout * _wapi_fileshare_layout.1;
  unsigned int D.23083;
  int D.23084;
  long int D.23085;
  <unnamed type> D.23086;
  unsigned int D.23089;
  const char * D.23090;
  unsigned int D.23091;
  unsigned int D.23092;
  const char * iftmp.2;
  int D.23094;
  const gchar * (*<T3cb0>) (struct _WapiHandleShared *) D.23098;
  const gchar * D.23099;
  unsigned int D.23100;
  unsigned int D.23101;
  long unsigned int D.23104;
  long long int D.23105;
  long unsigned int D.23106;
  long long int D.23107;
  int D.23108;
  unsigned int D.23109;
  unsigned int D.23110;
  guint32 i;
  guint32 now;

  D.23073 = _wapi_shm_attach (0);
  _wapi_shared_layout = D.23073;
  _wapi_shared_layout.0 = _wapi_shared_layout;
  if (_wapi_shared_layout.0 == 0B) goto <D.23075>; else goto <D.23076>;
  <D.23075>:
  monoeg_g_log (0B, 4, "Failed to attach shared memory!");
  <D.23008>:
  goto <D.23008>;
  exit (-1);
  <D.23076>:
  D.23077 = _wapi_shm_attach (1);
  _wapi_fileshare_layout = D.23077;
  _wapi_fileshare_layout.1 = _wapi_fileshare_layout;
  if (_wapi_fileshare_layout.1 == 0B) goto <D.23079>; else goto <D.23080>;
  <D.23079>:
  monoeg_g_log (0B, 4, "Failed to attach fileshare shared memory!");
  <D.23009>:
  goto <D.23009>;
  exit (-1);
  <D.23080>:
  if (argc > 1) goto <D.23081>; else goto <D.23082>;
  <D.23081>:
  _wapi_shm_semaphores_init ();
  _wapi_collection_init ();
  _wapi_handle_collect ();
  <D.23082>:
  _wapi_shared_layout.0 = _wapi_shared_layout;
  D.23083 = _wapi_shared_layout.0->collection_count;
  _wapi_shared_layout.0 = _wapi_shared_layout;
  D.23084 = _wapi_shared_layout.0->sem_key;
  monoeg_g_print ("collection: %d sem: 0x%x\n", D.23083, D.23084);
  D.23085 = time (0B);
  now = (guint32) D.23085;
  i = 0;
  goto <D.23012>;
  <D.23011>:
  {
    struct _WapiHandleShared * shared;

    _wapi_shared_layout.0 = _wapi_shared_layout;
    shared = &_wapi_shared_layout.0->handles[i];
    D.23086 = shared->type;
    if (D.23086 != 0) goto <D.23087>; else goto <D.23088>;
    <D.23087>:
    D.23089 = shared->handle_refs;
    D.23086 = shared->type;
    D.23090 = _wapi_handle_typename[D.23086];
    D.23091 = shared->timestamp;
    D.23092 = now - D.23091;
    D.23094 = shared->signalled;
    if (D.23094 != 0) goto <D.23095>; else goto <D.23096>;
    <D.23095>:
    iftmp.2 = "Sg";
    goto <D.23097>;
    <D.23096>:
    iftmp.2 = "Un";
    <D.23097>:
    D.23086 = shared->type;
    D.23098 = details[D.23086];
    D.23099 = D.23098 (shared);
    monoeg_g_print ("%3x (%3d) [%7s] %4u %s (%s)\n", i, D.23089, D.23090, D.23092, iftmp.2, D.23099);
    <D.23088>:
  }
  i = i + 1;
  <D.23012>:
  if (i <= 255) goto <D.23011>; else goto <D.23013>;
  <D.23013>:
  _wapi_fileshare_layout.1 = _wapi_fileshare_layout;
  D.23100 = _wapi_fileshare_layout.1->hwm;
  monoeg_g_print ("Fileshare hwm: %d\n", D.23100);
  i = 0;
  goto <D.23016>;
  <D.23015>:
  {
    struct _WapiFileShare * file_share;

    _wapi_fileshare_layout.1 = _wapi_fileshare_layout;
    file_share = &_wapi_fileshare_layout.1->share_info[i];
    D.23101 = file_share->handle_refs;
    if (D.23101 != 0) goto <D.23102>; else goto <D.23103>;
    <D.23102>:
    D.23104 = file_share->device;
    D.23105 = (long long int) D.23104;
    D.23106 = file_share->inode;
    D.23107 = (long long int) D.23106;
    D.23108 = file_share->opened_by_pid;
    D.23109 = file_share->sharemode;
    D.23110 = file_share->access;
    D.23101 = 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.23105, D.23107, D.23108, D.23109, D.23110, D.23101);
    <D.23103>:
  }
  i = i + 1;
  <D.23016>:
  _wapi_fileshare_layout.1 = _wapi_fileshare_layout;
  D.23100 = _wapi_fileshare_layout.1->hwm;
  if (D.23100 >= i) goto <D.23015>; else goto <D.23017>;
  <D.23017>:
  exit (0);
}


namedevent_details (struct _WapiHandleShared * handle)
{
  gchar * iftmp.3;
  const char * iftmp.4;
  int D.23116;
  unsigned int D.23120;
  const gchar * D.23121;
  static gchar buf[80];
  gchar * name;
  struct _WapiHandle_namedevent * event;

  event = &handle->u.namedevent;
  name = &event->sharedns.name;
  if (name != 0B) goto <D.23112>; else goto <D.23113>;
  <D.23112>:
  iftmp.3 = name;
  goto <D.23114>;
  <D.23113>:
  iftmp.3 = "";
  <D.23114>:
  D.23116 = event->manual;
  if (D.23116 != 0) goto <D.23117>; else goto <D.23118>;
  <D.23117>:
  iftmp.4 = "Manual";
  goto <D.23119>;
  <D.23118>:
  iftmp.4 = "Auto";
  <D.23119>:
  D.23120 = event->set_count;
  monoeg_g_snprintf (&buf, 80, "[%15s] %s count: %5u", iftmp.3, iftmp.4, D.23120);
  D.23121 = &buf;
  return D.23121;
}


namedsem_details (struct _WapiHandleShared * handle)
{
  gchar * iftmp.5;
  unsigned int D.23127;
  int D.23128;
  const gchar * D.23129;
  static gchar buf[80];
  gchar * name;
  struct _WapiHandle_namedsem * sem;

  sem = &handle->u.namedsem;
  name = &sem->sharedns.name;
  if (name != 0B) goto <D.23124>; else goto <D.23125>;
  <D.23124>:
  iftmp.5 = name;
  goto <D.23126>;
  <D.23125>:
  iftmp.5 = "";
  <D.23126>:
  D.23127 = sem->val;
  D.23128 = sem->max;
  monoeg_g_snprintf (&buf, 80, "[%15s] val: %5u, max: %5d", iftmp.5, D.23127, D.23128);
  D.23129 = &buf;
  return D.23129;
}


namedmutex_details (struct _WapiHandleShared * handle)
{
  gchar * iftmp.6;
  int D.23135;
  long unsigned int D.23136;
  unsigned int D.23137;
  const gchar * D.23138;
  static gchar buf[80];
  gchar * name;
  struct _WapiHandle_namedmutex * mut;

  mut = &handle->u.namedmutex;
  name = &mut->sharedns.name;
  if (name != 0B) goto <D.23132>; else goto <D.23133>;
  <D.23132>:
  iftmp.6 = name;
  goto <D.23134>;
  <D.23133>:
  iftmp.6 = "";
  <D.23134>:
  D.23135 = mut->pid;
  D.23136 = mut->tid;
  D.23137 = mut->recursion;
  monoeg_g_snprintf (&buf, 80, "[%15s] own: %5d:%5ld, count: %5u", iftmp.6, D.23135, D.23136, D.23137);
  D.23138 = &buf;
  return D.23138;
}


process_details (struct _WapiHandleShared * handle)
{
  gchar * iftmp.7;
  int D.23144;
  unsigned int D.23145;
  const gchar * D.23146;
  static gchar buf[80];
  gchar * name;
  struct _WapiHandle_process * proc;

  proc = &handle->u.process;
  name = &proc->proc_name;
  if (name != 0B) goto <D.23141>; else goto <D.23142>;
  <D.23141>:
  iftmp.7 = name;
  goto <D.23143>;
  <D.23142>:
  iftmp.7 = "";
  <D.23143>:
  D.23144 = proc->id;
  D.23145 = proc->exitstatus;
  monoeg_g_snprintf (&buf, 80, "[%25.25s] pid: %5u exit: %u", iftmp.7, D.23144, D.23145);
  D.23146 = &buf;
  return D.23146;
}


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

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


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

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


__attribute__((visibility ("hidden")))
mini_wapi_semdel (int argc, char * * argv)
{
  void * D.23152;
  struct _WapiHandleSharedLayout * _wapi_shared_layout.8;
  int D.23157;
  int D.23158;
  int * D.23163;
  int D.23164;
  const gchar * D.23165;
  int sem_id;
  int ret;

  D.23152 = _wapi_shm_attach (0);
  _wapi_shared_layout = D.23152;
  _wapi_shared_layout.8 = _wapi_shared_layout;
  if (_wapi_shared_layout.8 == 0B) goto <D.23153>; else goto <D.23156>;
  <D.23156>:
  _wapi_shared_layout.8 = _wapi_shared_layout;
  D.23157 = _wapi_shared_layout.8->sem_key;
  if (D.23157 == 0) goto <D.23153>; else goto <D.23154>;
  <D.23153>:
  exit (0);
  <D.23154>:
  _wapi_shared_layout.8 = _wapi_shared_layout;
  D.23158 = _wapi_shared_layout.8->sem_key;
  sem_id = semget (D.23158, 8, 384);
  if (sem_id != -1) goto <D.23159>; else goto <D.23160>;
  <D.23159>:
  ret = semctl (sem_id, 0, 0);
  if (ret == -1) goto <D.23161>; else goto <D.23162>;
  <D.23161>:
  D.23163 = __errno_location ();
  D.23164 = *D.23163;
  D.23165 = monoeg_g_strerror (D.23164);
  monoeg_g_log (0B, 32, "Error deleting semaphore: %s", D.23165);
  <D.23162>:
  <D.23160>:
  exit (0);
}


__attribute__((visibility ("hidden")))
mini_wapi_seminfo (int argc, char * * argv)
{
  void * D.23166;
  struct _WapiHandleSharedLayout * _wapi_shared_layout.9;
  int D.23171;
  int D.23172;
  int D.23175;
  short unsigned int D.23178;
  int D.23179;
  int sem_id;
  int ret;
  typedef union semun unionunion semun;
  union semun arg;
  ushort vals[8];

  try
    {
      D.23166 = _wapi_shm_attach (0);
      _wapi_shared_layout = D.23166;
      _wapi_shared_layout.9 = _wapi_shared_layout;
      if (_wapi_shared_layout.9 == 0B) goto <D.23167>; else goto <D.23170>;
      <D.23170>:
      _wapi_shared_layout.9 = _wapi_shared_layout;
      D.23171 = _wapi_shared_layout.9->sem_key;
      if (D.23171 == 0) goto <D.23167>; else goto <D.23168>;
      <D.23167>:
      exit (0);
      <D.23168>:
      _wapi_shared_layout.9 = _wapi_shared_layout;
      D.23172 = _wapi_shared_layout.9->sem_key;
      sem_id = semget (D.23172, 8, 384);
      if (sem_id != -1) goto <D.23173>; else goto <D.23174>;
      <D.23173>:
      _wapi_shared_layout.9 = _wapi_shared_layout;
      D.23175 = _wapi_shared_layout.9->sem_key;
      monoeg_g_print ("Getting values for sem: 0x%x\n", D.23175);
      arg.array = &vals;
      ret = semctl (sem_id, 0, 13, arg);
      if (ret != -1) goto <D.23176>; else goto <D.23177>;
      <D.23176>:
      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.23178 = vals[7];
      D.23179 = (int) D.23178;
      monoeg_g_print ("Count: %d\n", D.23179);
      <D.23177>:
      <D.23174>:
      exit (0);
    }
  finally
    {
      arg = {CLOBBER};
      vals = {CLOBBER};
    }
}


sem_explain (int sem_id, ushort * vals, int which)
{
  long unsigned int D.23180;
  long unsigned int D.23181;
  ushort * D.23182;
  short unsigned int D.23183;
  int D.23184;
  pid_t pid;

  D.23180 = (long unsigned int) which;
  D.23181 = D.23180 * 2;
  D.23182 = vals + D.23181;
  D.23183 = *D.23182;
  D.23184 = (int) D.23183;
  monoeg_g_print ("%d ", D.23184);
  D.23180 = (long unsigned int) which;
  D.23181 = D.23180 * 2;
  D.23182 = vals + D.23181;
  D.23183 = *D.23182;
  if (D.23183 != 0) goto <D.23185>; else goto <D.23186>;
  <D.23185>:
  monoeg_g_print ("(Unlocked)");
  goto <D.23187>;
  <D.23186>:
  pid = semctl (sem_id, which, 11);
  monoeg_g_print ("(Locked by %d)", pid);
  <D.23187>:
  monoeg_g_print ("\n");
}


