mono_pagesize ()
{
  int saved_pagesize.0;
  int D.7513;
  int saved_pagesize.1;
  static int saved_pagesize = 0;

  saved_pagesize.0 = saved_pagesize;
  if (saved_pagesize.0 != 0) goto <D.7511>; else goto <D.7512>;
  <D.7511>:
  D.7513 = saved_pagesize;
  return D.7513;
  <D.7512>:
  saved_pagesize.1 = getpagesize ();
  saved_pagesize = saved_pagesize.1;
  D.7513 = saved_pagesize;
  return D.7513;
}


mono_valloc (void * addr, size_t length, int flags)
{
  int D.7516;
  int D.7519;
  void * D.7528;
  void * ptr;
  int mflags;
  int prot;

  mflags = 0;
  prot = prot_from_flags (flags);
  D.7516 = flags & 128;
  if (D.7516 != 0) goto <D.7517>; else goto <D.7518>;
  <D.7517>:
  mflags = mflags | 16;
  <D.7518>:
  D.7519 = flags & 256;
  if (D.7519 != 0) goto <D.7520>; else goto <D.7521>;
  <D.7520>:
  mflags = mflags;
  <D.7521>:
  mflags = mflags | 32;
  mflags = mflags | 2;
  ptr = mmap (addr, length, prot, mflags, -1, 0);
  if (ptr == -1B) goto <D.7522>; else goto <D.7523>;
  <D.7522>:
  {
    int fd;

    fd = open ("/dev/zero", 0);
    if (fd != -1) goto <D.7524>; else goto <D.7525>;
    <D.7524>:
    ptr = mmap (addr, length, prot, mflags, fd, 0);
    close (fd);
    <D.7525>:
    if (ptr == -1B) goto <D.7526>; else goto <D.7527>;
    <D.7526>:
    D.7528 = 0B;
    return D.7528;
    <D.7527>:
  }
  <D.7523>:
  D.7528 = ptr;
  return D.7528;
}


prot_from_flags (int flags)
{
  int D.7530;
  int D.7533;
  int D.7536;
  int D.7539;
  int prot;

  prot = 0;
  D.7530 = flags & 1;
  if (D.7530 != 0) goto <D.7531>; else goto <D.7532>;
  <D.7531>:
  prot = prot | 1;
  <D.7532>:
  D.7533 = flags & 2;
  if (D.7533 != 0) goto <D.7534>; else goto <D.7535>;
  <D.7534>:
  prot = prot | 2;
  <D.7535>:
  D.7536 = flags & 4;
  if (D.7536 != 0) goto <D.7537>; else goto <D.7538>;
  <D.7537>:
  prot = prot | 4;
  <D.7538>:
  D.7539 = prot;
  return D.7539;
}


open (const char * __path, int __oflag)
{
  int D.7541;
  int D.7544;
  int D.7549;
  int D.7551;
  int D.7552;
  int D.7555;
  int D.7556;

  D.7541 = __builtin_va_arg_pack_len ();
  if (D.7541 > 1) goto <D.7542>; else goto <D.7543>;
  <D.7542>:
  __open_too_many_args ();
  <D.7543>:
  D.7544 = __builtin_constant_p (__oflag);
  if (D.7544 != 0) goto <D.7545>; else goto <D.7546>;
  <D.7545>:
  D.7549 = __oflag & 64;
  if (D.7549 != 0) goto <D.7547>; else goto <D.7550>;
  <D.7550>:
  D.7551 = __oflag & 4259840;
  if (D.7551 == 4259840) goto <D.7547>; else goto <D.7548>;
  <D.7547>:
  D.7552 = __builtin_va_arg_pack_len ();
  if (D.7552 <= 0) goto <D.7553>; else goto <D.7554>;
  <D.7553>:
  __open_missing_mode ();
  D.7555 = __open_2 (__path, __oflag);
  return D.7555;
  <D.7554>:
  <D.7548>:
  D.7555 = __open_alias (__path, __oflag, __builtin_va_arg_pack ());
  return D.7555;
  <D.7546>:
  D.7556 = __builtin_va_arg_pack_len ();
  if (D.7556 <= 0) goto <D.7557>; else goto <D.7558>;
  <D.7557>:
  D.7555 = __open_2 (__path, __oflag);
  return D.7555;
  <D.7558>:
  D.7555 = __open_alias (__path, __oflag, __builtin_va_arg_pack ());
  return D.7555;
}


mono_vfree (void * addr, size_t length)
{
  int D.7560;

  D.7560 = munmap (addr, length);
  return D.7560;
}


mono_file_map (size_t length, int flags, int fd, guint64 offset, void * * ret_handle)
{
  int D.7562;
  int D.7565;
  int D.7568;
  int D.7571;
  long int offset.2;
  void * D.7577;
  void * length.3;
  void * ptr;
  int mflags;
  int prot;

  mflags = 0;
  prot = prot_from_flags (flags);
  D.7562 = flags & 16;
  if (D.7562 != 0) goto <D.7563>; else goto <D.7564>;
  <D.7563>:
  mflags = mflags | 2;
  <D.7564>:
  D.7565 = flags & 32;
  if (D.7565 != 0) goto <D.7566>; else goto <D.7567>;
  <D.7566>:
  mflags = mflags | 1;
  <D.7567>:
  D.7568 = flags & 128;
  if (D.7568 != 0) goto <D.7569>; else goto <D.7570>;
  <D.7569>:
  mflags = mflags | 16;
  <D.7570>:
  D.7571 = flags & 256;
  if (D.7571 != 0) goto <D.7572>; else goto <D.7573>;
  <D.7572>:
  mflags = mflags;
  <D.7573>:
  offset.2 = (long int) offset;
  ptr = mmap (0B, length, prot, mflags, fd, offset.2);
  if (ptr == -1B) goto <D.7575>; else goto <D.7576>;
  <D.7575>:
  D.7577 = 0B;
  return D.7577;
  <D.7576>:
  length.3 = (void *) length;
  *ret_handle = length.3;
  D.7577 = ptr;
  return D.7577;
}


mono_file_unmap (void * addr, void * handle)
{
  int D.7580;
  long unsigned int handle.4;

  handle.4 = (long unsigned int) handle;
  D.7580 = munmap (addr, handle.4);
  return D.7580;
}


mono_mprotect (void * addr, size_t length, int flags)
{
  int D.7583;
  int D.7586;
  int D.7589;
  int prot;

  prot = prot_from_flags (flags);
  D.7583 = flags & 8;
  if (D.7583 != 0) goto <D.7584>; else goto <D.7585>;
  <D.7584>:
  D.7586 = madvise (addr, length, 4);
  if (D.7586 != 0) goto <D.7587>; else goto <D.7588>;
  <D.7587>:
  memset (addr, 0, length);
  <D.7588>:
  <D.7585>:
  D.7589 = mprotect (addr, length, prot);
  return D.7589;
}


memset (void * __dest, int __ch, size_t __len)
{
  int D.7593;
  int D.7598;
  void * D.7600;
  long unsigned int D.7601;

  D.7593 = __builtin_constant_p (__len);
  if (D.7593 != 0) goto <D.7594>; else goto <D.7595>;
  <D.7594>:
  if (__len == 0) goto <D.7596>; else goto <D.7597>;
  <D.7596>:
  D.7598 = __builtin_constant_p (__ch);
  if (D.7598 == 0) goto <D.7591>; else goto <D.7599>;
  <D.7599>:
  if (__ch != 0) goto <D.7591>; else goto <D.7592>;
  <D.7591>:
  __warn_memset_zero_len ();
  D.7600 = __dest;
  return D.7600;
  <D.7592>:
  <D.7597>:
  <D.7595>:
  D.7601 = __builtin_object_size (__dest, 0);
  D.7600 = __builtin___memset_chk (__dest, __ch, __len, D.7601);
  return D.7600;
}


mono_shared_area ()
{
  int D.7603;
  void * malloced_shared_area.5;
  void * malloced_shared_area.6;
  void * D.7610;
  int * D.7613;
  int D.7614;
  long int D.7619;
  int D.7620;
  long unsigned int D.7623;
  int fd;
  int pid;
  int size;
  char buf[128];
  void * res;
  struct SAreaHeader * header;

  try
    {
      pid = getpid ();
      size = mono_pagesize ();
      D.7603 = shared_area_disabled ();
      if (D.7603 != 0) goto <D.7604>; else goto <D.7605>;
      <D.7604>:
      malloced_shared_area.5 = malloced_shared_area;
      if (malloced_shared_area.5 == 0B) goto <D.7607>; else goto <D.7608>;
      <D.7607>:
      malloced_shared_area.6 = malloc_shared_area (0);
      malloced_shared_area = malloced_shared_area.6;
      <D.7608>:
      D.7610 = malloced_shared_area;
      return D.7610;
      <D.7605>:
      mono_shared_area_instances_helper (0B, 0, 1);
      monoeg_g_snprintf (&buf, 128, "/mono.%d", pid);
      fd = shm_open (&buf, 194, 416);
      if (fd == -1) goto <D.7611>; else goto <D.7612>;
      <D.7611>:
      D.7613 = __errno_location ();
      D.7614 = *D.7613;
      if (D.7614 == 17) goto <D.7615>; else goto <D.7616>;
      <D.7615>:
      shm_unlink (&buf);
      fd = shm_open (&buf, 194, 416);
      <D.7616>:
      <D.7612>:
      if (fd == -1) goto <D.7617>; else goto <D.7618>;
      <D.7617>:
      D.7610 = malloc_shared_area (pid);
      return D.7610;
      <D.7618>:
      D.7619 = (long int) size;
      D.7620 = ftruncate (fd, D.7619);
      if (D.7620 != 0) goto <D.7621>; else goto <D.7622>;
      <D.7621>:
      shm_unlink (&buf);
      close (fd);
      <D.7622>:
      D.7623 = (long unsigned int) size;
      res = mmap (0B, D.7623, 3, 1, fd, 0);
      if (res == -1B) goto <D.7624>; else goto <D.7625>;
      <D.7624>:
      shm_unlink (&buf);
      close (fd);
      D.7610 = malloc_shared_area (pid);
      return D.7610;
      <D.7625>:
      close (fd);
      header = res;
      header->size = size;
      header->pid = pid;
      header->stats_start = 16;
      header->stats_end = 16;
      atexit (mono_shared_area_remove);
      D.7610 = res;
      return D.7610;
    }
  finally
    {
      buf = {CLOBBER};
    }
}


shared_area_disabled ()
{
  int use_shared_area.7;
  const gchar * D.7631;
  gboolean D.7635;
  _Bool D.7636;

  use_shared_area.7 = use_shared_area;
  if (use_shared_area.7 == 0) goto <D.7629>; else goto <D.7630>;
  <D.7629>:
  D.7631 = monoeg_g_getenv ("MONO_DISABLE_SHARED_AREA");
  if (D.7631 != 0B) goto <D.7632>; else goto <D.7633>;
  <D.7632>:
  use_shared_area = -1;
  goto <D.7634>;
  <D.7633>:
  use_shared_area = 1;
  <D.7634>:
  <D.7630>:
  use_shared_area.7 = use_shared_area;
  D.7636 = use_shared_area.7 == -1;
  D.7635 = (gboolean) D.7636;
  return D.7635;
}


mono_shared_area_instances_helper (void * * array, int count, gboolean cleanup)
{
  int D.7640;
  int D.7641;
  const char * D.7644;
  long int D.7645;
  char * nend.8;
  char D.7651;
  int i.9;
  long unsigned int D.7656;
  long unsigned int D.7657;
  void * * D.7658;
  long int D.7659;
  void * D.7660;
  int D.7665;
  int * D.7668;
  int D.7669;
  const char * name;
  int i;
  int curpid;
  struct GDir * dir;

  i = 0;
  curpid = getpid ();
  dir = monoeg_g_dir_open ("/dev/shm/", 0, 0B);
  if (dir == 0B) goto <D.7638>; else goto <D.7639>;
  <D.7638>:
  D.7640 = mono_shared_area_instances_slow (array, count, cleanup);
  return D.7640;
  <D.7639>:
  goto <D.7471>;
  <D.7474>:
  {
    int pid;
    char * nend;

    try
      {
        D.7641 = strncmp (name, "mono.", 5);
        if (D.7641 != 0) goto <D.7642>; else goto <D.7643>;
        <D.7642>:
        // predicted unlikely by continue predictor.
        goto <D.7471>;
        <D.7643>:
        D.7644 = name + 5;
        D.7645 = strtol (D.7644, &nend, 10);
        pid = (int) D.7645;
        if (pid <= 0) goto <D.7646>; else goto <D.7648>;
        <D.7648>:
        D.7644 = name + 5;
        nend.8 = nend;
        if (D.7644 == nend.8) goto <D.7646>; else goto <D.7650>;
        <D.7650>:
        nend.8 = nend;
        D.7651 = *nend.8;
        if (D.7651 != 0) goto <D.7646>; else goto <D.7647>;
        <D.7646>:
        // predicted unlikely by continue predictor.
        goto <D.7471>;
        <D.7647>:
        if (cleanup == 0) goto <D.7652>; else goto <D.7653>;
        <D.7652>:
        if (i < count) goto <D.7654>; else goto <D.7472>;
        <D.7654>:
        i.9 = i;
        i = i.9 + 1;
        D.7656 = (long unsigned int) i.9;
        D.7657 = D.7656 * 8;
        D.7658 = array + D.7657;
        D.7659 = (long int) pid;
        D.7660 = (void *) D.7659;
        *D.7658 = D.7660;
        <D.7653>:
        if (curpid != pid) goto <D.7663>; else goto <D.7664>;
        <D.7663>:
        D.7665 = kill (pid, 0);
        if (D.7665 == -1) goto <D.7666>; else goto <D.7667>;
        <D.7666>:
        D.7668 = __errno_location ();
        D.7669 = *D.7668;
        if (D.7669 == 3) goto <D.7661>; else goto <D.7670>;
        <D.7670>:
        D.7668 = __errno_location ();
        D.7669 = *D.7668;
        if (D.7669 == 12) goto <D.7661>; else goto <D.7662>;
        <D.7661>:
        {
          char buf[128];

          try
            {
              monoeg_g_snprintf (&buf, 128, "/mono.%d", pid);
              shm_unlink (&buf);
            }
          finally
            {
              buf = {CLOBBER};
            }
        }
        <D.7662>:
        <D.7667>:
        <D.7664>:
      }
    finally
      {
        nend = {CLOBBER};
      }
  }
  <D.7471>:
  name = monoeg_g_dir_read_name (dir);
  if (name != 0B) goto <D.7474>; else goto <D.7472>;
  <D.7472>:
  monoeg_g_dir_close (dir);
  D.7640 = i;
  return D.7640;
}


mono_shared_area_instances_slow (void * * array, int count, gboolean cleanup)
{
  long unsigned int D.7675;
  long unsigned int D.7676;
  void * * D.7677;
  void * D.7678;
  int j.10;
  long unsigned int D.7685;
  long unsigned int D.7686;
  void * * D.7687;
  int num.11;
  int D.7689;
  int i;
  int j;
  int num;
  void * data;
  void * * processes;

  try
    {
      j = 0;
      processes = mono_process_list (&num);
      i = 0;
      goto <D.7450>;
      <D.7449>:
      D.7675 = (long unsigned int) i;
      D.7676 = D.7675 * 8;
      D.7677 = processes + D.7676;
      D.7678 = *D.7677;
      data = mono_shared_area_for_pid (D.7678);
      if (data == 0B) goto <D.7679>; else goto <D.7680>;
      <D.7679>:
      // predicted unlikely by continue predictor.
      goto <D.7447>;
      <D.7680>:
      mono_shared_area_unload (data);
      if (cleanup == 0) goto <D.7681>; else goto <D.7682>;
      <D.7681>:
      if (j < count) goto <D.7683>; else goto <D.7448>;
      <D.7683>:
      j.10 = j;
      j = j.10 + 1;
      D.7685 = (long unsigned int) j.10;
      D.7686 = D.7685 * 8;
      D.7687 = array + D.7686;
      D.7675 = (long unsigned int) i;
      D.7676 = D.7675 * 8;
      D.7677 = processes + D.7676;
      D.7678 = *D.7677;
      *D.7687 = D.7678;
      <D.7682>:
      <D.7447>:
      i = i + 1;
      <D.7450>:
      num.11 = num;
      if (i < num.11) goto <D.7449>; else goto <D.7448>;
      <D.7448>:
      monoeg_g_free (processes);
      D.7689 = j;
      return D.7689;
    }
  finally
    {
      num = {CLOBBER};
    }
}


malloc_shared_area (int pid)
{
  long unsigned int D.7692;
  void * D.7693;
  int size;
  struct SAreaHeader * sarea;

  size = mono_pagesize ();
  D.7692 = (long unsigned int) size;
  sarea = monoeg_malloc0 (D.7692);
  sarea->size = size;
  sarea->pid = pid;
  sarea->stats_start = 16;
  sarea->stats_end = 16;
  D.7693 = sarea;
  return D.7693;
}


mono_shared_area_remove ()
{
  int D.7695;
  void * malloced_shared_area.12;
  int D.7701;
  char buf[128];

  try
    {
      D.7695 = shared_area_disabled ();
      if (D.7695 != 0) goto <D.7696>; else goto <D.7697>;
      <D.7696>:
      malloced_shared_area.12 = malloced_shared_area;
      if (malloced_shared_area.12 != 0B) goto <D.7699>; else goto <D.7700>;
      <D.7699>:
      malloced_shared_area.12 = malloced_shared_area;
      monoeg_g_free (malloced_shared_area.12);
      <D.7700>:
      return;
      <D.7697>:
      D.7701 = getpid ();
      monoeg_g_snprintf (&buf, 128, "/mono.%d", D.7701);
      shm_unlink (&buf);
      malloced_shared_area.12 = malloced_shared_area;
      if (malloced_shared_area.12 != 0B) goto <D.7702>; else goto <D.7703>;
      <D.7702>:
      malloced_shared_area.12 = malloced_shared_area;
      monoeg_g_free (malloced_shared_area.12);
      <D.7703>:
    }
  finally
    {
      buf = {CLOBBER};
    }
}


mono_shared_area_for_pid (void * pid)
{
  int D.7707;
  void * D.7710;
  long int pid.13;
  int D.7712;
  long unsigned int D.7715;
  int fd;
  int size;
  char buf[128];
  void * res;

  try
    {
      size = mono_pagesize ();
      D.7707 = shared_area_disabled ();
      if (D.7707 != 0) goto <D.7708>; else goto <D.7709>;
      <D.7708>:
      D.7710 = 0B;
      return D.7710;
      <D.7709>:
      pid.13 = (long int) pid;
      D.7712 = (int) pid.13;
      monoeg_g_snprintf (&buf, 128, "/mono.%d", D.7712);
      fd = shm_open (&buf, 0, 288);
      if (fd == -1) goto <D.7713>; else goto <D.7714>;
      <D.7713>:
      D.7710 = 0B;
      return D.7710;
      <D.7714>:
      D.7715 = (long unsigned int) size;
      res = mmap (0B, D.7715, 1, 1, fd, 0);
      if (res == -1B) goto <D.7716>; else goto <D.7717>;
      <D.7716>:
      close (fd);
      D.7710 = 0B;
      return D.7710;
      <D.7717>:
      close (fd);
      D.7710 = res;
      return D.7710;
    }
  finally
    {
      buf = {CLOBBER};
    }
}


mono_shared_area_unload (void * area)
{
  int D.7720;
  long unsigned int D.7721;

  D.7720 = mono_pagesize ();
  D.7721 = (long unsigned int) D.7720;
  munmap (area, D.7721);
}


mono_shared_area_instances (void * * array, int count)
{
  int D.7722;

  D.7722 = mono_shared_area_instances_helper (array, count, 0);
  return D.7722;
}


mono_valloc_aligned (size_t size, size_t alignment, int flags)
{
  long unsigned int D.7724;
  void * D.7727;
  long int aligned.14;
  long int mem.15;
  long int D.7732;
  long unsigned int D.7733;
  char * D.7734;
  sizetype D.7735;
  char * D.7736;
  void * D.7739;
  long int mem.16;
  long int aligned.17;
  long int D.7742;
  long int D.7743;
  long int size.18;
  long int D.7745;
  long int D.7746;
  long unsigned int D.7747;
  char * mem;
  char * aligned;

  D.7724 = size + alignment;
  mem = mono_valloc (0B, D.7724, flags);
  if (mem == 0B) goto <D.7725>; else goto <D.7726>;
  <D.7725>:
  D.7727 = 0B;
  return D.7727;
  <D.7726>:
  aligned = aligned_address (mem, size, alignment);
  if (aligned > mem) goto <D.7728>; else goto <D.7729>;
  <D.7728>:
  aligned.14 = (long int) aligned;
  mem.15 = (long int) mem;
  D.7732 = aligned.14 - mem.15;
  D.7733 = (long unsigned int) D.7732;
  mono_vfree (mem, D.7733);
  <D.7729>:
  D.7734 = aligned + size;
  D.7735 = size + alignment;
  D.7736 = mem + D.7735;
  if (D.7734 < D.7736) goto <D.7737>; else goto <D.7738>;
  <D.7737>:
  D.7739 = aligned + size;
  mem.16 = (long int) mem;
  aligned.17 = (long int) aligned;
  D.7742 = mem.16 - aligned.17;
  D.7735 = size + alignment;
  D.7743 = (long int) D.7735;
  size.18 = (long int) size;
  D.7745 = D.7743 - size.18;
  D.7746 = D.7742 + D.7745;
  D.7747 = (long unsigned int) D.7746;
  mono_vfree (D.7739, D.7747);
  <D.7738>:
  D.7727 = aligned;
  return D.7727;
}


aligned_address (char * mem, size_t size, size_t alignment)
{
  sizetype D.7749;
  char * D.7750;
  long unsigned int D.7751;
  long unsigned int D.7752;
  long unsigned int D.7753;
  int iftmp.19;
  char * D.7759;
  sizetype D.7760;
  char * D.7761;
  long unsigned int D.7763;
  long unsigned int aligned.20;
  long unsigned int D.7765;
  _Bool D.7766;
  long int D.7767;
  long int D.7768;
  char * D.7771;
  char * aligned;

  D.7749 = alignment + 18446744073709551615;
  D.7750 = mem + D.7749;
  D.7751 = (long unsigned int) D.7750;
  D.7752 = -alignment;
  D.7753 = D.7751 & D.7752;
  aligned = (char *) D.7753;
  if (aligned < mem) goto <D.7755>; else goto <D.7758>;
  <D.7758>:
  D.7759 = aligned + size;
  D.7760 = size + alignment;
  D.7761 = mem + D.7760;
  if (D.7759 > D.7761) goto <D.7755>; else goto <D.7762>;
  <D.7762>:
  D.7763 = alignment + 18446744073709551615;
  aligned.20 = (long unsigned int) aligned;
  D.7765 = D.7763 & aligned.20;
  if (D.7765 != 0) goto <D.7755>; else goto <D.7756>;
  <D.7755>:
  iftmp.19 = 1;
  goto <D.7757>;
  <D.7756>:
  iftmp.19 = 0;
  <D.7757>:
  D.7766 = iftmp.19 != 0;
  D.7767 = (long int) D.7766;
  D.7768 = __builtin_expect (D.7767, 0);
  if (D.7768 != 0) goto <D.7769>; else goto <D.7770>;
  <D.7769>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "mono-mmap.c", 69, "aligned >= mem && aligned + size <= mem + size + alignment && !((gulong)aligned & (alignment - 1))");
  <D.7770>:
  D.7771 = aligned;
  return D.7771;
}


