mono_path_canonicalize (const char * path)
{
  int D.6460;
  long int pos.0;
  long int lastpos.1;
  long int D.6466;
  char D.6470;
  gchar * D.6476;
  char D.6477;
  int D.6486;
  long unsigned int D.6487;
  sizetype D.6488;
  sizetype D.6489;
  char * D.6492;
  long unsigned int D.6495;
  int D.6496;
  long unsigned int D.6497;
  sizetype D.6498;
  gchar * D.6499;
  sizetype D.6500;
  gchar * D.6501;
  gchar * D.6502;
  gchar * abspath;
  gchar * pos;
  gchar * lastpos;
  gchar * dest;
  int backc;

  D.6460 = monoeg_g_path_is_absolute (path);
  if (D.6460 != 0) goto <D.6461>; else goto <D.6462>;
  <D.6461>:
  abspath = monoeg_strdup (path);
  goto <D.6463>;
  <D.6462>:
  {
    gchar * tmpdir;

    tmpdir = monoeg_g_get_current_dir ();
    abspath = monoeg_g_build_path ("/", tmpdir, path, 0B);
    monoeg_g_free (tmpdir);
  }
  <D.6463>:
  abspath = monoeg_g_strreverse (abspath);
  backc = 0;
  lastpos = abspath;
  dest = lastpos;
  pos = __builtin_strchr (lastpos, 47);
  goto <D.6434>;
  <D.6433>:
  {
    int len;

    pos.0 = (long int) pos;
    lastpos.1 = (long int) lastpos;
    D.6466 = pos.0 - lastpos.1;
    len = (int) D.6466;
    if (len == 1) goto <D.6469>; else goto <D.6467>;
    <D.6469>:
    D.6470 = *lastpos;
    if (D.6470 == 46) goto <D.6471>; else goto <D.6467>;
    <D.6471>:
    goto <D.6468>;
    <D.6467>:
    if (len == 2) goto <D.6474>; else goto <D.6472>;
    <D.6474>:
    D.6470 = *lastpos;
    if (D.6470 == 46) goto <D.6475>; else goto <D.6472>;
    <D.6475>:
    D.6476 = lastpos + 1;
    D.6477 = *D.6476;
    if (D.6477 == 46) goto <D.6478>; else goto <D.6472>;
    <D.6478>:
    backc = backc + 1;
    goto <D.6473>;
    <D.6472>:
    if (len > 0) goto <D.6479>; else goto <D.6480>;
    <D.6479>:
    if (backc > 0) goto <D.6481>; else goto <D.6482>;
    <D.6481>:
    backc = backc + -1;
    goto <D.6483>;
    <D.6482>:
    if (dest != lastpos) goto <D.6484>; else goto <D.6485>;
    <D.6484>:
    D.6486 = len + 1;
    D.6487 = (long unsigned int) D.6486;
    memmove (dest, lastpos, D.6487);
    <D.6485>:
    D.6488 = (sizetype) len;
    D.6489 = D.6488 + 1;
    dest = dest + D.6489;
    <D.6483>:
    <D.6480>:
    <D.6473>:
    <D.6468>:
    lastpos = pos + 1;
    pos = __builtin_strchr (lastpos, 47);
  }
  <D.6434>:
  if (pos != 0B) goto <D.6433>; else goto <D.6435>;
  <D.6435>:
  if (dest != lastpos) goto <D.6490>; else goto <D.6491>;
  <D.6490>:
  strcpy (dest, lastpos);
  <D.6491>:
  monoeg_g_strreverse (abspath);
  D.6492 = __builtin_strchr (abspath, 47);
  if (D.6492 == 0B) goto <D.6493>; else goto <D.6494>;
  <D.6493>:
  {
    int len;

    D.6495 = __strlen_g (abspath);
    len = (int) D.6495;
    D.6496 = len + 2;
    D.6497 = (long unsigned int) D.6496;
    abspath = monoeg_realloc (abspath, D.6497);
    D.6498 = (sizetype) len;
    D.6499 = abspath + D.6498;
    *D.6499 = 47;
    D.6498 = (sizetype) len;
    D.6500 = D.6498 + 1;
    D.6501 = abspath + D.6500;
    *D.6501 = 0;
  }
  <D.6494>:
  D.6502 = abspath;
  return D.6502;
}


monoeg_strdup (const gchar * str)
{
  gchar * D.6506;

  if (str != 0B) goto <D.6504>; else goto <D.6505>;
  <D.6504>:
  D.6506 = __strdup (str);
  return D.6506;
  <D.6505>:
  D.6506 = 0B;
  return D.6506;
}


__attribute__((__artificial__, __gnu_inline__, __always_inline__, __nothrow__, __leaf__))
memmove (void * __dest, const void * __src, size_t __len)
{
  void * D.6508;
  long unsigned int D.6509;

  D.6509 = __builtin_object_size (__dest, 0);
  D.6508 = __builtin___memmove_chk (__dest, __src, __len, D.6509);
  return D.6508;
}


__attribute__((__artificial__, __gnu_inline__, __always_inline__, __nothrow__, __leaf__))
strcpy (char * restrict __dest, const char * restrict __src)
{
  char * D.6511;
  long unsigned int D.6512;

  D.6512 = __builtin_object_size (__dest, 1);
  D.6511 = __builtin___strcpy_chk (__dest, __src, D.6512);
  return D.6511;
}


__attribute__((__gnu_inline__))
__strlen_g (const char * __str)
{
  size_t D.6514;
  long int __ptr.2;
  long int __str.3;
  long int D.6517;
  char * __ptr;
  char * __tmp;

  __ptr = 0B;
  __tmp = __str;
  __asm__ __volatile__("   la    0,0
0: srst  %0,%1
   jo    0b
" : "=&a" __ptr, "=&a" __tmp : "0" __ptr, "1" __tmp : "0", "memory", "cc");
  __ptr.2 = (long int) __ptr;
  __str.3 = (long int) __str;
  D.6517 = __ptr.2 - __str.3;
  D.6514 = (size_t) D.6517;
  return D.6514;
}


mono_path_resolve_symlinks (const char * path)
{
  long unsigned int D.6519;
  long unsigned int D.6520;
  gchar * * D.6521;
  gchar * D.6522;
  unsigned char D.6523;
  sizetype D.6526;
  sizetype D.6527;
  sizetype D.6528;
  gchar * * D.6529;
  gchar * D.6530;
  gchar * D.6533;
  gchar * * split;
  gchar * p;
  int i;

  split = monoeg_g_strsplit (path, "/", -1);
  p = monoeg_strdup ("");
  i = 0;
  goto <D.6457>;
  <D.6456>:
  {
    gchar * tmp;

    tmp = 0B;
    D.6519 = (long unsigned int) i;
    D.6520 = D.6519 * 8;
    D.6521 = split + D.6520;
    D.6522 = *D.6521;
    D.6523 = MEM[(const unsigned char * {ref-all})D.6522];
    if (D.6523 != 0) goto <D.6524>; else goto <D.6525>;
    <D.6524>:
    D.6519 = (long unsigned int) i;
    D.6520 = D.6519 * 8;
    D.6521 = split + D.6520;
    D.6522 = *D.6521;
    tmp = monoeg_g_strdup_printf ("%s%s", p, D.6522);
    monoeg_g_free (p);
    p = resolve_symlink (tmp);
    monoeg_g_free (tmp);
    <D.6525>:
    D.6526 = (sizetype) i;
    D.6527 = D.6526 + 1;
    D.6528 = D.6527 * 8;
    D.6529 = split + D.6528;
    D.6530 = *D.6529;
    if (D.6530 != 0B) goto <D.6531>; else goto <D.6532>;
    <D.6531>:
    tmp = monoeg_g_strdup_printf ("%s%s", p, "/");
    monoeg_g_free (p);
    p = tmp;
    <D.6532>:
  }
  i = i + 1;
  <D.6457>:
  D.6519 = (long unsigned int) i;
  D.6520 = D.6519 * 8;
  D.6521 = split + D.6520;
  D.6522 = *D.6521;
  if (D.6522 != 0B) goto <D.6456>; else goto <D.6458>;
  <D.6458>:
  monoeg_g_strfreev (split);
  D.6533 = p;
  return D.6533;
}


resolve_symlink (const char * path)
{
  long int D.6535;
  gchar * D.6538;
  int D.6539;
  char * p;
  char * concat;
  char * dir;
  char buffer[4097];
  int n;
  int iterations;

  try
    {
      iterations = 0;
      p = monoeg_strdup (path);
      <D.6447>:
      iterations = iterations + 1;
      D.6535 = readlink (p, &buffer, 4096);
      n = (int) D.6535;
      if (n < 0) goto <D.6536>; else goto <D.6537>;
      <D.6536>:
      {
        char * copy;

        copy = p;
        p = mono_path_canonicalize (copy);
        monoeg_g_free (copy);
        D.6538 = p;
        return D.6538;
      }
      <D.6537>:
      buffer[n] = 0;
      D.6539 = monoeg_g_path_is_absolute (&buffer);
      if (D.6539 == 0) goto <D.6540>; else goto <D.6541>;
      <D.6540>:
      dir = monoeg_g_path_get_dirname (p);
      concat = monoeg_g_build_path ("/", dir, &buffer, 0B);
      monoeg_g_free (dir);
      goto <D.6542>;
      <D.6541>:
      concat = monoeg_strdup (&buffer);
      <D.6542>:
      monoeg_g_free (p);
      p = mono_path_canonicalize (concat);
      monoeg_g_free (concat);
      if (iterations <= 19) goto <D.6447>; else goto <D.6448>;
      <D.6448>:
      D.6538 = p;
      return D.6538;
    }
  finally
    {
      buffer = {CLOBBER};
    }
}


__attribute__((__artificial__, __gnu_inline__, __always_inline__, __leaf__, __nothrow__))
readlink (const char * restrict __path, char * restrict __buf, size_t __len)
{
  long unsigned int D.6545;
  int D.6548;
  ssize_t D.6551;
  long unsigned int D.6552;
  long unsigned int D.6553;
  long unsigned int D.6556;

  D.6545 = __builtin_object_size (__buf, 1);
  if (D.6545 != 18446744073709551615) goto <D.6546>; else goto <D.6547>;
  <D.6546>:
  D.6548 = __builtin_constant_p (__len);
  if (D.6548 == 0) goto <D.6549>; else goto <D.6550>;
  <D.6549>:
  D.6552 = __builtin_object_size (__buf, 1);
  D.6551 = __readlink_chk (__path, __buf, __len, D.6552);
  return D.6551;
  <D.6550>:
  D.6553 = __builtin_object_size (__buf, 1);
  if (D.6553 < __len) goto <D.6554>; else goto <D.6555>;
  <D.6554>:
  D.6556 = __builtin_object_size (__buf, 1);
  D.6551 = __readlink_chk_warn (__path, __buf, __len, D.6556);
  return D.6551;
  <D.6555>:
  <D.6547>:
  D.6551 = __readlink_alias (__path, __buf, __len);
  return D.6551;
}


