mono_path_canonicalize (const char * path)
{
  int D.6855;
  long int pos.0;
  long int lastpos.1;
  long int D.6861;
  char D.6865;
  gchar * D.6871;
  char D.6872;
  int D.6881;
  long unsigned int D.6882;
  sizetype D.6883;
  sizetype D.6884;
  char * D.6887;
  long unsigned int D.6890;
  int D.6891;
  long unsigned int D.6892;
  sizetype D.6893;
  gchar * D.6894;
  sizetype D.6895;
  gchar * D.6896;
  gchar * D.6897;
  gchar * abspath;
  gchar * pos;
  gchar * lastpos;
  gchar * dest;
  int backc;

  D.6855 = monoeg_g_path_is_absolute (path);
  if (D.6855 != 0) goto <D.6856>; else goto <D.6857>;
  <D.6856>:
  abspath = monoeg_strdup (path);
  goto <D.6858>;
  <D.6857>:
  {
    gchar * tmpdir;

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

    pos.0 = (long int) pos;
    lastpos.1 = (long int) lastpos;
    D.6861 = pos.0 - lastpos.1;
    len = (int) D.6861;
    if (len == 1) goto <D.6864>; else goto <D.6862>;
    <D.6864>:
    D.6865 = *lastpos;
    if (D.6865 == 46) goto <D.6866>; else goto <D.6862>;
    <D.6866>:
    goto <D.6863>;
    <D.6862>:
    if (len == 2) goto <D.6869>; else goto <D.6867>;
    <D.6869>:
    D.6865 = *lastpos;
    if (D.6865 == 46) goto <D.6870>; else goto <D.6867>;
    <D.6870>:
    D.6871 = lastpos + 1;
    D.6872 = *D.6871;
    if (D.6872 == 46) goto <D.6873>; else goto <D.6867>;
    <D.6873>:
    backc = backc + 1;
    goto <D.6868>;
    <D.6867>:
    if (len > 0) goto <D.6874>; else goto <D.6875>;
    <D.6874>:
    if (backc > 0) goto <D.6876>; else goto <D.6877>;
    <D.6876>:
    backc = backc + -1;
    goto <D.6878>;
    <D.6877>:
    if (dest != lastpos) goto <D.6879>; else goto <D.6880>;
    <D.6879>:
    D.6881 = len + 1;
    D.6882 = (long unsigned int) D.6881;
    memmove (dest, lastpos, D.6882);
    <D.6880>:
    D.6883 = (sizetype) len;
    D.6884 = D.6883 + 1;
    dest = dest + D.6884;
    <D.6878>:
    <D.6875>:
    <D.6868>:
    <D.6863>:
    lastpos = pos + 1;
    pos = __builtin_strchr (lastpos, 47);
  }
  <D.6820>:
  if (pos != 0B) goto <D.6819>; else goto <D.6821>;
  <D.6821>:
  if (dest != lastpos) goto <D.6885>; else goto <D.6886>;
  <D.6885>:
  strcpy (dest, lastpos);
  <D.6886>:
  monoeg_g_strreverse (abspath);
  D.6887 = __builtin_strchr (abspath, 47);
  if (D.6887 == 0B) goto <D.6888>; else goto <D.6889>;
  <D.6888>:
  {
    int len;

    D.6890 = strlen (abspath);
    len = (int) D.6890;
    D.6891 = len + 2;
    D.6892 = (long unsigned int) D.6891;
    abspath = monoeg_realloc (abspath, D.6892);
    D.6893 = (sizetype) len;
    D.6894 = abspath + D.6893;
    *D.6894 = 47;
    D.6893 = (sizetype) len;
    D.6895 = D.6893 + 1;
    D.6896 = abspath + D.6895;
    *D.6896 = 0;
  }
  <D.6889>:
  D.6897 = abspath;
  return D.6897;
}


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

  if (str != 0B) goto <D.6899>; else goto <D.6900>;
  <D.6899>:
  D.6901 = __strdup (str);
  return D.6901;
  <D.6900>:
  D.6901 = 0B;
  return D.6901;
}


memmove (void * __dest, const void * __src, size_t __len)
{
  void * D.6903;
  long unsigned int D.6904;

  D.6904 = __builtin_object_size (__dest, 0);
  D.6903 = __builtin___memmove_chk (__dest, __src, __len, D.6904);
  return D.6903;
}


strcpy (char * restrict __dest, const char * restrict __src)
{
  char * D.6906;
  long unsigned int D.6907;

  D.6907 = __builtin_object_size (__dest, 1);
  D.6906 = __builtin___strcpy_chk (__dest, __src, D.6907);
  return D.6906;
}


mono_path_resolve_symlinks (const char * path)
{
  int D.6850;
  int iftmp.2;
  int D.6849;
  long unsigned int D.6912;
  long unsigned int D.6913;
  gchar * * D.6914;
  const char[1] * D.6915;
  unsigned char D.6916;
  int D.6917;
  unsigned char D.6918;
  int D.6919;
  const unsigned char * D.6924;
  unsigned char D.6925;
  int D.6926;
  const unsigned char * D.6927;
  unsigned char D.6928;
  int D.6929;
  const unsigned char * D.6934;
  unsigned char D.6935;
  int D.6936;
  const unsigned char * D.6937;
  unsigned char D.6938;
  int D.6939;
  const unsigned char * D.6944;
  unsigned char D.6945;
  int D.6946;
  const unsigned char * D.6947;
  unsigned char D.6948;
  int D.6949;
  gchar * D.6951;
  unsigned char D.6952;
  sizetype D.6955;
  sizetype D.6956;
  sizetype D.6957;
  gchar * * D.6958;
  gchar * D.6959;
  gchar * D.6962;
  gchar * * split;
  gchar * p;
  int i;

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

    tmp = 0B;
    {
      size_t __s1_len;
      size_t __s2_len;

      __s2_len = 0;
      if (__s2_len <= 3) goto <D.6910>; else goto <D.6911>;
      <D.6910>:
      {
        const unsigned char * __s2;
        int __result;

        D.6912 = (long unsigned int) i;
        D.6913 = D.6912 * 8;
        D.6914 = split + D.6913;
        __s2 = *D.6914;
        D.6915 = "";
        D.6916 = MEM[(const unsigned char *)D.6915];
        D.6917 = (int) D.6916;
        D.6918 = *__s2;
        D.6919 = (int) D.6918;
        __result = D.6917 - D.6919;
        {
          if (__s2_len != 0) goto <D.6920>; else goto <D.6921>;
          <D.6920>:
          if (__result == 0) goto <D.6922>; else goto <D.6923>;
          <D.6922>:
          D.6924 = &MEM[(void *)"" + 1B];
          D.6925 = *D.6924;
          D.6926 = (int) D.6925;
          D.6927 = __s2 + 1;
          D.6928 = *D.6927;
          D.6929 = (int) D.6928;
          __result = D.6926 - D.6929;
          if (__s2_len > 1) goto <D.6930>; else goto <D.6931>;
          <D.6930>:
          if (__result == 0) goto <D.6932>; else goto <D.6933>;
          <D.6932>:
          D.6934 = &MEM[(void *)"" + 2B];
          D.6935 = *D.6934;
          D.6936 = (int) D.6935;
          D.6937 = __s2 + 2;
          D.6938 = *D.6937;
          D.6939 = (int) D.6938;
          __result = D.6936 - D.6939;
          if (__s2_len > 2) goto <D.6940>; else goto <D.6941>;
          <D.6940>:
          if (__result == 0) goto <D.6942>; else goto <D.6943>;
          <D.6942>:
          D.6944 = &MEM[(void *)"" + 3B];
          D.6945 = *D.6944;
          D.6946 = (int) D.6945;
          D.6947 = __s2 + 3;
          D.6948 = *D.6947;
          D.6949 = (int) D.6948;
          __result = D.6946 - D.6949;
          <D.6943>:
          <D.6941>:
          <D.6933>:
          <D.6931>:
          <D.6923>:
          <D.6921>:
        }
        D.6849 = __result;
      }
      iftmp.2 = -D.6849;
      goto <D.6950>;
      <D.6911>:
      D.6912 = (long unsigned int) i;
      D.6913 = D.6912 * 8;
      D.6914 = split + D.6913;
      D.6951 = *D.6914;
      D.6952 = MEM[(const unsigned char * {ref-all})D.6951];
      iftmp.2 = (int) D.6952;
      <D.6950>:
      D.6850 = iftmp.2;
    }
    if (D.6850 != 0) goto <D.6953>; else goto <D.6954>;
    <D.6953>:
    D.6912 = (long unsigned int) i;
    D.6913 = D.6912 * 8;
    D.6914 = split + D.6913;
    D.6951 = *D.6914;
    tmp = monoeg_g_strdup_printf ("%s%s", p, D.6951);
    monoeg_g_free (p);
    p = resolve_symlink (tmp);
    monoeg_g_free (tmp);
    <D.6954>:
    D.6955 = (sizetype) i;
    D.6956 = D.6955 + 1;
    D.6957 = D.6956 * 8;
    D.6958 = split + D.6957;
    D.6959 = *D.6958;
    if (D.6959 != 0B) goto <D.6960>; else goto <D.6961>;
    <D.6960>:
    tmp = monoeg_g_strdup_printf ("%s%s", p, "/");
    monoeg_g_free (p);
    p = tmp;
    <D.6961>:
  }
  i = i + 1;
  <D.6852>:
  D.6912 = (long unsigned int) i;
  D.6913 = D.6912 * 8;
  D.6914 = split + D.6913;
  D.6951 = *D.6914;
  if (D.6951 != 0B) goto <D.6851>; else goto <D.6853>;
  <D.6853>:
  monoeg_g_strfreev (split);
  D.6962 = p;
  return D.6962;
}


resolve_symlink (const char * path)
{
  long int D.6964;
  gchar * D.6967;
  int D.6968;
  char * p;
  char * concat;
  char * dir;
  char buffer[4097];
  int n;
  int iterations;

  try
    {
      iterations = 0;
      p = monoeg_strdup (path);
      <D.6833>:
      iterations = iterations + 1;
      D.6964 = readlink (p, &buffer, 4096);
      n = (int) D.6964;
      if (n < 0) goto <D.6965>; else goto <D.6966>;
      <D.6965>:
      {
        char * copy;

        copy = p;
        p = mono_path_canonicalize (copy);
        monoeg_g_free (copy);
        D.6967 = p;
        return D.6967;
      }
      <D.6966>:
      buffer[n] = 0;
      D.6968 = monoeg_g_path_is_absolute (&buffer);
      if (D.6968 == 0) goto <D.6969>; else goto <D.6970>;
      <D.6969>:
      dir = monoeg_g_path_get_dirname (p);
      concat = monoeg_g_build_path ("/", dir, &buffer, 0B);
      monoeg_g_free (dir);
      goto <D.6971>;
      <D.6970>:
      concat = monoeg_strdup (&buffer);
      <D.6971>:
      monoeg_g_free (p);
      p = mono_path_canonicalize (concat);
      monoeg_g_free (concat);
      if (iterations <= 19) goto <D.6833>; else goto <D.6834>;
      <D.6834>:
      D.6967 = p;
      return D.6967;
    }
  finally
    {
      buffer = {CLOBBER};
    }
}


readlink (const char * restrict __path, char * restrict __buf, size_t __len)
{
  long unsigned int D.6974;
  int D.6977;
  ssize_t D.6980;
  long unsigned int D.6981;
  long unsigned int D.6982;
  long unsigned int D.6985;

  D.6974 = __builtin_object_size (__buf, 1);
  if (D.6974 != 18446744073709551615) goto <D.6975>; else goto <D.6976>;
  <D.6975>:
  D.6977 = __builtin_constant_p (__len);
  if (D.6977 == 0) goto <D.6978>; else goto <D.6979>;
  <D.6978>:
  D.6981 = __builtin_object_size (__buf, 1);
  D.6980 = __readlink_chk (__path, __buf, __len, D.6981);
  return D.6980;
  <D.6979>:
  D.6982 = __builtin_object_size (__buf, 1);
  if (D.6982 < __len) goto <D.6983>; else goto <D.6984>;
  <D.6983>:
  D.6985 = __builtin_object_size (__buf, 1);
  D.6980 = __readlink_chk_warn (__path, __buf, __len, D.6985);
  return D.6980;
  <D.6984>:
  <D.6976>:
  D.6980 = __readlink_alias (__path, __buf, __len);
  return D.6980;
}


