mono_path_canonicalize (const char * path)
{
  int D.5921;
  int pos.0;
  int lastpos.1;
  char D.5930;
  gchar * D.5936;
  char D.5937;
  int D.5946;
  unsigned int D.5947;
  sizetype len.2;
  sizetype D.5949;
  char * D.5952;
  unsigned int D.5955;
  int D.5956;
  unsigned int D.5957;
  sizetype len.3;
  gchar * D.5959;
  sizetype D.5960;
  gchar * D.5961;
  gchar * D.5962;
  gchar * abspath;
  gchar * pos;
  gchar * lastpos;
  gchar * dest;
  int backc;

  D.5921 = monoeg_g_path_is_absolute (path);
  if (D.5921 != 0) goto <D.5922>; else goto <D.5923>;
  <D.5922>:
  abspath = monoeg_strdup (path);
  goto <D.5924>;
  <D.5923>:
  {
    gchar * tmpdir;

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

    pos.0 = (int) pos;
    lastpos.1 = (int) lastpos;
    len = pos.0 - lastpos.1;
    if (len == 1) goto <D.5929>; else goto <D.5927>;
    <D.5929>:
    D.5930 = *lastpos;
    if (D.5930 == 46) goto <D.5931>; else goto <D.5927>;
    <D.5931>:
    goto <D.5928>;
    <D.5927>:
    if (len == 2) goto <D.5934>; else goto <D.5932>;
    <D.5934>:
    D.5930 = *lastpos;
    if (D.5930 == 46) goto <D.5935>; else goto <D.5932>;
    <D.5935>:
    D.5936 = lastpos + 1;
    D.5937 = *D.5936;
    if (D.5937 == 46) goto <D.5938>; else goto <D.5932>;
    <D.5938>:
    backc = backc + 1;
    goto <D.5933>;
    <D.5932>:
    if (len > 0) goto <D.5939>; else goto <D.5940>;
    <D.5939>:
    if (backc > 0) goto <D.5941>; else goto <D.5942>;
    <D.5941>:
    backc = backc + -1;
    goto <D.5943>;
    <D.5942>:
    if (dest != lastpos) goto <D.5944>; else goto <D.5945>;
    <D.5944>:
    D.5946 = len + 1;
    D.5947 = (unsigned int) D.5946;
    memmove (dest, lastpos, D.5947);
    <D.5945>:
    len.2 = (sizetype) len;
    D.5949 = len.2 + 1;
    dest = dest + D.5949;
    <D.5943>:
    <D.5940>:
    <D.5933>:
    <D.5928>:
    lastpos = pos + 1;
    pos = __builtin_strchr (lastpos, 47);
  }
  <D.5886>:
  if (pos != 0B) goto <D.5885>; else goto <D.5887>;
  <D.5887>:
  if (dest != lastpos) goto <D.5950>; else goto <D.5951>;
  <D.5950>:
  strcpy (dest, lastpos);
  <D.5951>:
  monoeg_g_strreverse (abspath);
  D.5952 = __builtin_strchr (abspath, 47);
  if (D.5952 == 0B) goto <D.5953>; else goto <D.5954>;
  <D.5953>:
  {
    int len;

    D.5955 = strlen (abspath);
    len = (int) D.5955;
    D.5956 = len + 2;
    D.5957 = (unsigned int) D.5956;
    abspath = monoeg_realloc (abspath, D.5957);
    len.3 = (sizetype) len;
    D.5959 = abspath + len.3;
    *D.5959 = 47;
    len.3 = (sizetype) len;
    D.5960 = len.3 + 1;
    D.5961 = abspath + D.5960;
    *D.5961 = 0;
  }
  <D.5954>:
  D.5962 = abspath;
  return D.5962;
}


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

  if (str != 0B) goto <D.5964>; else goto <D.5965>;
  <D.5964>:
  D.5966 = __strdup (str);
  return D.5966;
  <D.5965>:
  D.5966 = 0B;
  return D.5966;
}


memmove (void * __dest, const void * __src, size_t __len)
{
  void * D.5968;
  unsigned int D.5969;

  D.5969 = __builtin_object_size (__dest, 0);
  D.5968 = __builtin___memmove_chk (__dest, __src, __len, D.5969);
  return D.5968;
}


strcpy (char * restrict __dest, const char * restrict __src)
{
  char * D.5971;
  unsigned int D.5972;

  D.5972 = __builtin_object_size (__dest, 1);
  D.5971 = __builtin___strcpy_chk (__dest, __src, D.5972);
  return D.5971;
}


mono_path_resolve_symlinks (const char * path)
{
  int D.5916;
  int iftmp.4;
  int D.5915;
  unsigned int i.5;
  unsigned int D.5978;
  gchar * * D.5979;
  const char[1] * D.5980;
  unsigned char D.5981;
  int D.5982;
  unsigned char D.5983;
  int D.5984;
  const unsigned char * D.5989;
  unsigned char D.5990;
  int D.5991;
  const unsigned char * D.5992;
  unsigned char D.5993;
  int D.5994;
  const unsigned char * D.5999;
  unsigned char D.6000;
  int D.6001;
  const unsigned char * D.6002;
  unsigned char D.6003;
  int D.6004;
  const unsigned char * D.6009;
  unsigned char D.6010;
  int D.6011;
  const unsigned char * D.6012;
  unsigned char D.6013;
  int D.6014;
  gchar * D.6016;
  unsigned char D.6017;
  sizetype i.6;
  sizetype D.6021;
  sizetype D.6022;
  gchar * * D.6023;
  gchar * D.6024;
  gchar * D.6027;
  gchar * * split;
  gchar * p;
  int i;

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

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

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

        i.5 = (unsigned int) i;
        D.5978 = i.5 * 4;
        D.5979 = split + D.5978;
        __s2 = *D.5979;
        D.5980 = "";
        D.5981 = MEM[(const unsigned char *)D.5980];
        D.5982 = (int) D.5981;
        D.5983 = *__s2;
        D.5984 = (int) D.5983;
        __result = D.5982 - D.5984;
        {
          if (__s2_len != 0) goto <D.5985>; else goto <D.5986>;
          <D.5985>:
          if (__result == 0) goto <D.5987>; else goto <D.5988>;
          <D.5987>:
          D.5989 = &MEM[(void *)"" + 1B];
          D.5990 = *D.5989;
          D.5991 = (int) D.5990;
          D.5992 = __s2 + 1;
          D.5993 = *D.5992;
          D.5994 = (int) D.5993;
          __result = D.5991 - D.5994;
          if (__s2_len > 1) goto <D.5995>; else goto <D.5996>;
          <D.5995>:
          if (__result == 0) goto <D.5997>; else goto <D.5998>;
          <D.5997>:
          D.5999 = &MEM[(void *)"" + 2B];
          D.6000 = *D.5999;
          D.6001 = (int) D.6000;
          D.6002 = __s2 + 2;
          D.6003 = *D.6002;
          D.6004 = (int) D.6003;
          __result = D.6001 - D.6004;
          if (__s2_len > 2) goto <D.6005>; else goto <D.6006>;
          <D.6005>:
          if (__result == 0) goto <D.6007>; else goto <D.6008>;
          <D.6007>:
          D.6009 = &MEM[(void *)"" + 3B];
          D.6010 = *D.6009;
          D.6011 = (int) D.6010;
          D.6012 = __s2 + 3;
          D.6013 = *D.6012;
          D.6014 = (int) D.6013;
          __result = D.6011 - D.6014;
          <D.6008>:
          <D.6006>:
          <D.5998>:
          <D.5996>:
          <D.5988>:
          <D.5986>:
        }
        D.5915 = __result;
      }
      iftmp.4 = -D.5915;
      goto <D.6015>;
      <D.5976>:
      i.5 = (unsigned int) i;
      D.5978 = i.5 * 4;
      D.5979 = split + D.5978;
      D.6016 = *D.5979;
      D.6017 = MEM[(const unsigned char * {ref-all})D.6016];
      iftmp.4 = (int) D.6017;
      <D.6015>:
      D.5916 = iftmp.4;
    }
    if (D.5916 != 0) goto <D.6018>; else goto <D.6019>;
    <D.6018>:
    i.5 = (unsigned int) i;
    D.5978 = i.5 * 4;
    D.5979 = split + D.5978;
    D.6016 = *D.5979;
    tmp = monoeg_g_strdup_printf ("%s%s", p, D.6016);
    monoeg_g_free (p);
    p = resolve_symlink (tmp);
    monoeg_g_free (tmp);
    <D.6019>:
    i.6 = (sizetype) i;
    D.6021 = i.6 + 1;
    D.6022 = D.6021 * 4;
    D.6023 = split + D.6022;
    D.6024 = *D.6023;
    if (D.6024 != 0B) goto <D.6025>; else goto <D.6026>;
    <D.6025>:
    tmp = monoeg_g_strdup_printf ("%s%s", p, "/");
    monoeg_g_free (p);
    p = tmp;
    <D.6026>:
  }
  i = i + 1;
  <D.5918>:
  i.5 = (unsigned int) i;
  D.5978 = i.5 * 4;
  D.5979 = split + D.5978;
  D.6016 = *D.5979;
  if (D.6016 != 0B) goto <D.5917>; else goto <D.5919>;
  <D.5919>:
  monoeg_g_strfreev (split);
  D.6027 = p;
  return D.6027;
}


resolve_symlink (const char * path)
{
  gchar * D.6031;
  int D.6032;
  char * p;
  char * concat;
  char * dir;
  char buffer[4097];
  int n;
  int iterations;

  try
    {
      iterations = 0;
      p = monoeg_strdup (path);
      <D.5899>:
      iterations = iterations + 1;
      n = readlink (p, &buffer, 4096);
      if (n < 0) goto <D.6029>; else goto <D.6030>;
      <D.6029>:
      {
        char * copy;

        copy = p;
        p = mono_path_canonicalize (copy);
        monoeg_g_free (copy);
        D.6031 = p;
        return D.6031;
      }
      <D.6030>:
      buffer[n] = 0;
      D.6032 = monoeg_g_path_is_absolute (&buffer);
      if (D.6032 == 0) goto <D.6033>; else goto <D.6034>;
      <D.6033>:
      dir = monoeg_g_path_get_dirname (p);
      concat = monoeg_g_build_path ("/", dir, &buffer, 0B);
      monoeg_g_free (dir);
      goto <D.6035>;
      <D.6034>:
      concat = monoeg_strdup (&buffer);
      <D.6035>:
      monoeg_g_free (p);
      p = mono_path_canonicalize (concat);
      monoeg_g_free (concat);
      if (iterations <= 19) goto <D.5899>; else goto <D.5900>;
      <D.5900>:
      D.6031 = p;
      return D.6031;
    }
  finally
    {
      buffer = {CLOBBER};
    }
}


readlink (const char * restrict __path, char * restrict __buf, size_t __len)
{
  unsigned int D.6038;
  int D.6041;
  ssize_t D.6044;
  unsigned int D.6045;
  unsigned int D.6046;
  unsigned int D.6049;

  D.6038 = __builtin_object_size (__buf, 1);
  if (D.6038 != 4294967295) goto <D.6039>; else goto <D.6040>;
  <D.6039>:
  D.6041 = __builtin_constant_p (__len);
  if (D.6041 == 0) goto <D.6042>; else goto <D.6043>;
  <D.6042>:
  D.6045 = __builtin_object_size (__buf, 1);
  D.6044 = __readlink_chk (__path, __buf, __len, D.6045);
  return D.6044;
  <D.6043>:
  D.6046 = __builtin_object_size (__buf, 1);
  if (D.6046 < __len) goto <D.6047>; else goto <D.6048>;
  <D.6047>:
  D.6049 = __builtin_object_size (__buf, 1);
  D.6044 = __readlink_chk_warn (__path, __buf, __len, D.6049);
  return D.6044;
  <D.6048>:
  <D.6040>:
  D.6044 = __readlink_alias (__path, __buf, __len);
  return D.6044;
}


