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

  saved_pagesize.0 = saved_pagesize;
  if (saved_pagesize.0 != 0) goto <D.6977>; else goto <D.6978>;
  <D.6977>:
  D.6979 = saved_pagesize;
  return D.6979;
  <D.6978>:
  saved_pagesize.1 = getpagesize ();
  saved_pagesize = saved_pagesize.1;
  D.6979 = saved_pagesize;
  return D.6979;
}


mono_valloc (void * addr, size_t length, int flags)
{
  int D.6982;
  int D.6985;
  void * D.6994;
  void * ptr;
  int mflags;
  int prot;

  mflags = 0;
  prot = prot_from_flags (flags);
  D.6982 = flags & 128;
  if (D.6982 != 0) goto <D.6983>; else goto <D.6984>;
  <D.6983>:
  mflags = mflags | 16;
  <D.6984>:
  D.6985 = flags & 256;
  if (D.6985 != 0) goto <D.6986>; else goto <D.6987>;
  <D.6986>:
  mflags = mflags | 64;
  <D.6987>:
  mflags = mflags | 32;
  mflags = mflags | 2;
  ptr = mmap (addr, length, prot, mflags, -1, 0);
  if (ptr == -1B) goto <D.6988>; else goto <D.6989>;
  <D.6988>:
  {
    int fd;

    fd = open ("/dev/zero", 0);
    if (fd != -1) goto <D.6990>; else goto <D.6991>;
    <D.6990>:
    ptr = mmap (addr, length, prot, mflags, fd, 0);
    close (fd);
    <D.6991>:
    if (ptr == -1B) goto <D.6992>; else goto <D.6993>;
    <D.6992>:
    D.6994 = 0B;
    return D.6994;
    <D.6993>:
  }
  <D.6989>:
  D.6994 = ptr;
  return D.6994;
}


prot_from_flags (int flags)
{
  int D.6996;
  int D.6999;
  int D.7002;
  int D.7005;
  int prot;

  prot = 0;
  D.6996 = flags & 1;
  if (D.6996 != 0) goto <D.6997>; else goto <D.6998>;
  <D.6997>:
  prot = prot | 1;
  <D.6998>:
  D.6999 = flags & 2;
  if (D.6999 != 0) goto <D.7000>; else goto <D.7001>;
  <D.7000>:
  prot = prot | 2;
  <D.7001>:
  D.7002 = flags & 4;
  if (D.7002 != 0) goto <D.7003>; else goto <D.7004>;
  <D.7003>:
  prot = prot | 4;
  <D.7004>:
  D.7005 = prot;
  return D.7005;
}


open (const char * __path, int __oflag)
{
  int D.7007;
  int D.7010;
  int D.7015;
  int D.7017;
  int D.7018;
  int D.7021;
  int D.7022;

  D.7007 = __builtin_va_arg_pack_len ();
  if (D.7007 > 1) goto <D.7008>; else goto <D.7009>;
  <D.7008>:
  __open_too_many_args ();
  <D.7009>:
  D.7010 = __builtin_constant_p (__oflag);
  if (D.7010 != 0) goto <D.7011>; else goto <D.7012>;
  <D.7011>:
  D.7015 = __oflag & 64;
  if (D.7015 != 0) goto <D.7013>; else goto <D.7016>;
  <D.7016>:
  D.7017 = __oflag & 4259840;
  if (D.7017 == 4259840) goto <D.7013>; else goto <D.7014>;
  <D.7013>:
  D.7018 = __builtin_va_arg_pack_len ();
  if (D.7018 <= 0) goto <D.7019>; else goto <D.7020>;
  <D.7019>:
  __open_missing_mode ();
  D.7021 = __open_2 (__path, __oflag);
  return D.7021;
  <D.7020>:
  <D.7014>:
  D.7021 = __open_alias (__path, __oflag, __builtin_va_arg_pack ());
  return D.7021;
  <D.7012>:
  D.7022 = __builtin_va_arg_pack_len ();
  if (D.7022 <= 0) goto <D.7023>; else goto <D.7024>;
  <D.7023>:
  D.7021 = __open_2 (__path, __oflag);
  return D.7021;
  <D.7024>:
  D.7021 = __open_alias (__path, __oflag, __builtin_va_arg_pack ());
  return D.7021;
}


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

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


mono_file_map (size_t length, int flags, int fd, guint64 offset, void * * ret_handle)
{
  int D.7028;
  int D.7031;
  int D.7034;
  int D.7037;
  long int offset.2;
  void * D.7043;
  void * length.3;
  void * ptr;
  int mflags;
  int prot;

  mflags = 0;
  prot = prot_from_flags (flags);
  D.7028 = flags & 16;
  if (D.7028 != 0) goto <D.7029>; else goto <D.7030>;
  <D.7029>:
  mflags = mflags | 2;
  <D.7030>:
  D.7031 = flags & 32;
  if (D.7031 != 0) goto <D.7032>; else goto <D.7033>;
  <D.7032>:
  mflags = mflags | 1;
  <D.7033>:
  D.7034 = flags & 128;
  if (D.7034 != 0) goto <D.7035>; else goto <D.7036>;
  <D.7035>:
  mflags = mflags | 16;
  <D.7036>:
  D.7037 = flags & 256;
  if (D.7037 != 0) goto <D.7038>; else goto <D.7039>;
  <D.7038>:
  mflags = mflags | 64;
  <D.7039>:
  offset.2 = (long int) offset;
  ptr = mmap (0B, length, prot, mflags, fd, offset.2);
  if (ptr == -1B) goto <D.7041>; else goto <D.7042>;
  <D.7041>:
  D.7043 = 0B;
  return D.7043;
  <D.7042>:
  length.3 = (void *) length;
  *ret_handle = length.3;
  D.7043 = ptr;
  return D.7043;
}


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

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


mono_mprotect (void * addr, size_t length, int flags)
{
  int D.7049;
  int D.7052;
  int D.7055;
  int prot;

  prot = prot_from_flags (flags);
  D.7049 = flags & 8;
  if (D.7049 != 0) goto <D.7050>; else goto <D.7051>;
  <D.7050>:
  D.7052 = madvise (addr, length, 4);
  if (D.7052 != 0) goto <D.7053>; else goto <D.7054>;
  <D.7053>:
  memset (addr, 0, length);
  <D.7054>:
  <D.7051>:
  D.7055 = mprotect (addr, length, prot);
  return D.7055;
}


memset (void * __dest, int __ch, size_t __len)
{
  int D.7059;
  int D.7064;
  void * D.7066;
  long unsigned int D.7067;

  D.7059 = __builtin_constant_p (__len);
  if (D.7059 != 0) goto <D.7060>; else goto <D.7061>;
  <D.7060>:
  if (__len == 0) goto <D.7062>; else goto <D.7063>;
  <D.7062>:
  D.7064 = __builtin_constant_p (__ch);
  if (D.7064 == 0) goto <D.7057>; else goto <D.7065>;
  <D.7065>:
  if (__ch != 0) goto <D.7057>; else goto <D.7058>;
  <D.7057>:
  __warn_memset_zero_len ();
  D.7066 = __dest;
  return D.7066;
  <D.7058>:
  <D.7063>:
  <D.7061>:
  D.7067 = __builtin_object_size (__dest, 0);
  D.7066 = __builtin___memset_chk (__dest, __ch, __len, D.7067);
  return D.7066;
}


mono_shared_area ()
{
  int D.7069;
  void * malloced_shared_area.5;
  void * malloced_shared_area.6;
  void * D.7076;
  int * D.7079;
  int D.7080;
  long int D.7085;
  int D.7086;
  long unsigned int D.7089;
  int fd;
  int pid;
  int size;
  char buf[128];
  void * res;
  struct SAreaHeader * header;

  try
    {
      pid = getpid ();
      size = mono_pagesize ();
      D.7069 = shared_area_disabled ();
      if (D.7069 != 0) goto <D.7070>; else goto <D.7071>;
      <D.7070>:
      malloced_shared_area.5 = malloced_shared_area;
      if (malloced_shared_area.5 == 0B) goto <D.7073>; else goto <D.7074>;
      <D.7073>:
      malloced_shared_area.6 = malloc_shared_area (0);
      malloced_shared_area = malloced_shared_area.6;
      <D.7074>:
      D.7076 = malloced_shared_area;
      return D.7076;
      <D.7071>:
      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.7077>; else goto <D.7078>;
      <D.7077>:
      D.7079 = __errno_location ();
      D.7080 = *D.7079;
      if (D.7080 == 17) goto <D.7081>; else goto <D.7082>;
      <D.7081>:
      shm_unlink (&buf);
      fd = shm_open (&buf, 194, 416);
      <D.7082>:
      <D.7078>:
      if (fd == -1) goto <D.7083>; else goto <D.7084>;
      <D.7083>:
      D.7076 = malloc_shared_area (pid);
      return D.7076;
      <D.7084>:
      D.7085 = (long int) size;
      D.7086 = ftruncate (fd, D.7085);
      if (D.7086 != 0) goto <D.7087>; else goto <D.7088>;
      <D.7087>:
      shm_unlink (&buf);
      close (fd);
      <D.7088>:
      D.7089 = (long unsigned int) size;
      res = mmap (0B, D.7089, 3, 1, fd, 0);
      if (res == -1B) goto <D.7090>; else goto <D.7091>;
      <D.7090>:
      shm_unlink (&buf);
      close (fd);
      D.7076 = malloc_shared_area (pid);
      return D.7076;
      <D.7091>:
      close (fd);
      header = res;
      header->size = size;
      header->pid = pid;
      header->stats_start = 16;
      header->stats_end = 16;
      atexit (mono_shared_area_remove);
      D.7076 = res;
      return D.7076;
    }
  finally
    {
      buf = {CLOBBER};
    }
}


shared_area_disabled ()
{
  int use_shared_area.7;
  const gchar * D.7097;
  gboolean D.7101;
  _Bool D.7102;

  use_shared_area.7 = use_shared_area;
  if (use_shared_area.7 == 0) goto <D.7095>; else goto <D.7096>;
  <D.7095>:
  D.7097 = monoeg_g_getenv ("MONO_DISABLE_SHARED_AREA");
  if (D.7097 != 0B) goto <D.7098>; else goto <D.7099>;
  <D.7098>:
  use_shared_area = -1;
  goto <D.7100>;
  <D.7099>:
  use_shared_area = 1;
  <D.7100>:
  <D.7096>:
  use_shared_area.7 = use_shared_area;
  D.7102 = use_shared_area.7 == -1;
  D.7101 = (gboolean) D.7102;
  return D.7101;
}


mono_shared_area_instances_helper (void * * array, int count, gboolean cleanup)
{
  int D.7106;
  int D.7107;
  const char * D.7110;
  long int D.7111;
  char * nend.8;
  char D.7117;
  int i.9;
  long unsigned int D.7122;
  long unsigned int D.7123;
  void * * D.7124;
  long int D.7125;
  void * D.7126;
  int D.7129;
  int * D.7132;
  int D.7133;
  _Bool D.7134;
  _Bool D.7135;
  _Bool D.7136;
  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.7104>; else goto <D.7105>;
  <D.7104>:
  D.7106 = mono_shared_area_instances_slow (array, count, cleanup);
  return D.7106;
  <D.7105>:
  goto <D.6937>;
  <D.6940>:
  {
    int pid;
    char * nend;

    try
      {
        D.7107 = strncmp (name, "mono.", 5);
        if (D.7107 != 0) goto <D.7108>; else goto <D.7109>;
        <D.7108>:
        // predicted unlikely by continue predictor.
        goto <D.6937>;
        <D.7109>:
        D.7110 = name + 5;
        D.7111 = strtol (D.7110, &nend, 10);
        pid = (int) D.7111;
        if (pid <= 0) goto <D.7112>; else goto <D.7114>;
        <D.7114>:
        D.7110 = name + 5;
        nend.8 = nend;
        if (D.7110 == nend.8) goto <D.7112>; else goto <D.7116>;
        <D.7116>:
        nend.8 = nend;
        D.7117 = *nend.8;
        if (D.7117 != 0) goto <D.7112>; else goto <D.7113>;
        <D.7112>:
        // predicted unlikely by continue predictor.
        goto <D.6937>;
        <D.7113>:
        if (cleanup == 0) goto <D.7118>; else goto <D.7119>;
        <D.7118>:
        if (i < count) goto <D.7120>; else goto <D.6938>;
        <D.7120>:
        i.9 = i;
        i = i.9 + 1;
        D.7122 = (long unsigned int) i.9;
        D.7123 = D.7122 * 8;
        D.7124 = array + D.7123;
        D.7125 = (long int) pid;
        D.7126 = (void *) D.7125;
        *D.7124 = D.7126;
        <D.7119>:
        if (curpid != pid) goto <D.7127>; else goto <D.7128>;
        <D.7127>:
        D.7129 = kill (pid, 0);
        if (D.7129 == -1) goto <D.7130>; else goto <D.7131>;
        <D.7130>:
        D.7132 = __errno_location ();
        D.7133 = *D.7132;
        D.7134 = D.7133 == 3;
        D.7135 = D.7133 == 12;
        D.7136 = D.7134 | D.7135;
        if (D.7136 != 0) goto <D.7137>; else goto <D.7138>;
        <D.7137>:
        {
          char buf[128];

          try
            {
              monoeg_g_snprintf (&buf, 128, "/mono.%d", pid);
              shm_unlink (&buf);
            }
          finally
            {
              buf = {CLOBBER};
            }
        }
        <D.7138>:
        <D.7131>:
        <D.7128>:
      }
    finally
      {
        nend = {CLOBBER};
      }
  }
  <D.6937>:
  name = monoeg_g_dir_read_name (dir);
  if (name != 0B) goto <D.6940>; else goto <D.6938>;
  <D.6938>:
  monoeg_g_dir_close (dir);
  D.7106 = i;
  return D.7106;
}


mono_shared_area_instances_slow (void * * array, int count, gboolean cleanup)
{
  long unsigned int D.7143;
  long unsigned int D.7144;
  void * * D.7145;
  void * D.7146;
  int j.10;
  long unsigned int D.7153;
  long unsigned int D.7154;
  void * * D.7155;
  int num.11;
  int D.7157;
  int i;
  int j;
  int num;
  void * data;
  void * * processes;

  try
    {
      j = 0;
      processes = mono_process_list (&num);
      i = 0;
      goto <D.6916>;
      <D.6915>:
      D.7143 = (long unsigned int) i;
      D.7144 = D.7143 * 8;
      D.7145 = processes + D.7144;
      D.7146 = *D.7145;
      data = mono_shared_area_for_pid (D.7146);
      if (data == 0B) goto <D.7147>; else goto <D.7148>;
      <D.7147>:
      // predicted unlikely by continue predictor.
      goto <D.6913>;
      <D.7148>:
      mono_shared_area_unload (data);
      if (cleanup == 0) goto <D.7149>; else goto <D.7150>;
      <D.7149>:
      if (j < count) goto <D.7151>; else goto <D.6914>;
      <D.7151>:
      j.10 = j;
      j = j.10 + 1;
      D.7153 = (long unsigned int) j.10;
      D.7154 = D.7153 * 8;
      D.7155 = array + D.7154;
      D.7143 = (long unsigned int) i;
      D.7144 = D.7143 * 8;
      D.7145 = processes + D.7144;
      D.7146 = *D.7145;
      *D.7155 = D.7146;
      <D.7150>:
      <D.6913>:
      i = i + 1;
      <D.6916>:
      num.11 = num;
      if (i < num.11) goto <D.6915>; else goto <D.6914>;
      <D.6914>:
      monoeg_g_free (processes);
      D.7157 = j;
      return D.7157;
    }
  finally
    {
      num = {CLOBBER};
    }
}


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

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


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

  try
    {
      D.7163 = shared_area_disabled ();
      if (D.7163 != 0) goto <D.7164>; else goto <D.7165>;
      <D.7164>:
      malloced_shared_area.12 = malloced_shared_area;
      if (malloced_shared_area.12 != 0B) goto <D.7167>; else goto <D.7168>;
      <D.7167>:
      malloced_shared_area.12 = malloced_shared_area;
      monoeg_g_free (malloced_shared_area.12);
      <D.7168>:
      return;
      <D.7165>:
      D.7169 = getpid ();
      monoeg_g_snprintf (&buf, 128, "/mono.%d", D.7169);
      shm_unlink (&buf);
      malloced_shared_area.12 = malloced_shared_area;
      if (malloced_shared_area.12 != 0B) goto <D.7170>; else goto <D.7171>;
      <D.7170>:
      malloced_shared_area.12 = malloced_shared_area;
      monoeg_g_free (malloced_shared_area.12);
      <D.7171>:
    }
  finally
    {
      buf = {CLOBBER};
    }
}


mono_shared_area_for_pid (void * pid)
{
  int D.7175;
  void * D.7178;
  long int pid.13;
  int D.7180;
  long unsigned int D.7183;
  int fd;
  int size;
  char buf[128];
  void * res;

  try
    {
      size = mono_pagesize ();
      D.7175 = shared_area_disabled ();
      if (D.7175 != 0) goto <D.7176>; else goto <D.7177>;
      <D.7176>:
      D.7178 = 0B;
      return D.7178;
      <D.7177>:
      pid.13 = (long int) pid;
      D.7180 = (int) pid.13;
      monoeg_g_snprintf (&buf, 128, "/mono.%d", D.7180);
      fd = shm_open (&buf, 0, 288);
      if (fd == -1) goto <D.7181>; else goto <D.7182>;
      <D.7181>:
      D.7178 = 0B;
      return D.7178;
      <D.7182>:
      D.7183 = (long unsigned int) size;
      res = mmap (0B, D.7183, 1, 1, fd, 0);
      if (res == -1B) goto <D.7184>; else goto <D.7185>;
      <D.7184>:
      close (fd);
      D.7178 = 0B;
      return D.7178;
      <D.7185>:
      close (fd);
      D.7178 = res;
      return D.7178;
    }
  finally
    {
      buf = {CLOBBER};
    }
}


mono_shared_area_unload (void * area)
{
  int D.7188;
  long unsigned int D.7189;

  D.7188 = mono_pagesize ();
  D.7189 = (long unsigned int) D.7188;
  munmap (area, D.7189);
}


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

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


mono_valloc_aligned (size_t size, size_t alignment, int flags)
{
  long unsigned int D.7192;
  void * D.7195;
  long int aligned.14;
  long int mem.15;
  long int D.7200;
  long unsigned int D.7201;
  char * D.7202;
  sizetype D.7203;
  char * D.7204;
  long int mem.16;
  long int aligned.17;
  long int D.7209;
  long int D.7210;
  long int size.18;
  long int D.7212;
  long int D.7213;
  long unsigned int D.7214;
  void * D.7215;
  char * mem;
  char * aligned;

  D.7192 = size + alignment;
  mem = mono_valloc (0B, D.7192, flags);
  if (mem == 0B) goto <D.7193>; else goto <D.7194>;
  <D.7193>:
  D.7195 = 0B;
  return D.7195;
  <D.7194>:
  aligned = aligned_address (mem, size, alignment);
  if (aligned > mem) goto <D.7196>; else goto <D.7197>;
  <D.7196>:
  aligned.14 = (long int) aligned;
  mem.15 = (long int) mem;
  D.7200 = aligned.14 - mem.15;
  D.7201 = (long unsigned int) D.7200;
  mono_vfree (mem, D.7201);
  <D.7197>:
  D.7202 = aligned + size;
  D.7203 = size + alignment;
  D.7204 = mem + D.7203;
  if (D.7202 < D.7204) goto <D.7205>; else goto <D.7206>;
  <D.7205>:
  mem.16 = (long int) mem;
  aligned.17 = (long int) aligned;
  D.7209 = mem.16 - aligned.17;
  D.7203 = size + alignment;
  D.7210 = (long int) D.7203;
  size.18 = (long int) size;
  D.7212 = D.7210 - size.18;
  D.7213 = D.7209 + D.7212;
  D.7214 = (long unsigned int) D.7213;
  D.7215 = aligned + size;
  mono_vfree (D.7215, D.7214);
  <D.7206>:
  D.7195 = aligned;
  return D.7195;
}


aligned_address (char * mem, size_t size, size_t alignment)
{
  sizetype D.7217;
  char * D.7218;
  long unsigned int D.7219;
  long unsigned int D.7220;
  long unsigned int D.7221;
  int iftmp.19;
  char * D.7227;
  sizetype D.7228;
  char * D.7229;
  long unsigned int D.7231;
  long unsigned int aligned.20;
  long unsigned int D.7233;
  _Bool D.7234;
  long int D.7235;
  long int D.7236;
  char * D.7239;
  char * aligned;

  D.7217 = alignment + 18446744073709551615;
  D.7218 = mem + D.7217;
  D.7219 = (long unsigned int) D.7218;
  D.7220 = -alignment;
  D.7221 = D.7219 & D.7220;
  aligned = (char *) D.7221;
  if (aligned < mem) goto <D.7223>; else goto <D.7226>;
  <D.7226>:
  D.7227 = aligned + size;
  D.7228 = size + alignment;
  D.7229 = mem + D.7228;
  if (D.7227 > D.7229) goto <D.7223>; else goto <D.7230>;
  <D.7230>:
  D.7231 = alignment + 18446744073709551615;
  aligned.20 = (long unsigned int) aligned;
  D.7233 = D.7231 & aligned.20;
  if (D.7233 != 0) goto <D.7223>; else goto <D.7224>;
  <D.7223>:
  iftmp.19 = 1;
  goto <D.7225>;
  <D.7224>:
  iftmp.19 = 0;
  <D.7225>:
  D.7234 = iftmp.19 != 0;
  D.7235 = (long int) D.7234;
  D.7236 = __builtin_expect (D.7235, 0);
  if (D.7236 != 0) goto <D.7237>; else goto <D.7238>;
  <D.7237>:
  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.7238>:
  D.7239 = aligned;
  return D.7239;
}


