mono_path_canonicalize (const char * path)
{
  int D.5969;
  int pos.0;
  int lastpos.1;
  char D.5978;
  gchar * D.5984;
  char D.5985;
  int D.5994;
  unsigned int D.5995;
  sizetype len.2;
  sizetype D.5997;
  char * D.6000;
  unsigned int D.6003;
  int D.6004;
  unsigned int D.6005;
  sizetype len.3;
  gchar * D.6007;
  sizetype D.6008;
  gchar * D.6009;
  gchar * D.6010;
  gchar * abspath;
  gchar * pos;
  gchar * lastpos;
  gchar * dest;
  int backc;

  D.5969 = monoeg_g_path_is_absolute (path);
  if (D.5969 != 0) goto <D.5970>; else goto <D.5971>;
  <D.5970>:
  abspath = monoeg_strdup (path);
  goto <D.5972>;
  <D.5971>:
  {
    gchar * tmpdir;

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

    pos.0 = (int) pos;
    lastpos.1 = (int) lastpos;
    len = pos.0 - lastpos.1;
    if (len == 1) goto <D.5977>; else goto <D.5975>;
    <D.5977>:
    D.5978 = *lastpos;
    if (D.5978 == 46) goto <D.5979>; else goto <D.5975>;
    <D.5979>:
    goto <D.5976>;
    <D.5975>:
    if (len == 2) goto <D.5982>; else goto <D.5980>;
    <D.5982>:
    D.5978 = *lastpos;
    if (D.5978 == 46) goto <D.5983>; else goto <D.5980>;
    <D.5983>:
    D.5984 = lastpos + 1;
    D.5985 = *D.5984;
    if (D.5985 == 46) goto <D.5986>; else goto <D.5980>;
    <D.5986>:
    backc = backc + 1;
    goto <D.5981>;
    <D.5980>:
    if (len > 0) goto <D.5987>; else goto <D.5988>;
    <D.5987>:
    if (backc > 0) goto <D.5989>; else goto <D.5990>;
    <D.5989>:
    backc = backc + -1;
    goto <D.5991>;
    <D.5990>:
    if (dest != lastpos) goto <D.5992>; else goto <D.5993>;
    <D.5992>:
    D.5994 = len + 1;
    D.5995 = (unsigned int) D.5994;
    memmove (dest, lastpos, D.5995);
    <D.5993>:
    len.2 = (sizetype) len;
    D.5997 = len.2 + 1;
    dest = dest + D.5997;
    <D.5991>:
    <D.5988>:
    <D.5981>:
    <D.5976>:
    lastpos = pos + 1;
    pos = __builtin_strchr (lastpos, 47);
  }
  <D.5934>:
  if (pos != 0B) goto <D.5933>; else goto <D.5935>;
  <D.5935>:
  if (dest != lastpos) goto <D.5998>; else goto <D.5999>;
  <D.5998>:
  strcpy (dest, lastpos);
  <D.5999>:
  monoeg_g_strreverse (abspath);
  D.6000 = __builtin_strchr (abspath, 47);
  if (D.6000 == 0B) goto <D.6001>; else goto <D.6002>;
  <D.6001>:
  {
    int len;

    D.6003 = strlen (abspath);
    len = (int) D.6003;
    D.6004 = len + 2;
    D.6005 = (unsigned int) D.6004;
    abspath = monoeg_realloc (abspath, D.6005);
    len.3 = (sizetype) len;
    D.6007 = abspath + len.3;
    *D.6007 = 47;
    len.3 = (sizetype) len;
    D.6008 = len.3 + 1;
    D.6009 = abspath + D.6008;
    *D.6009 = 0;
  }
  <D.6002>:
  D.6010 = abspath;
  return D.6010;
}


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

  if (str != 0B) goto <D.6012>; else goto <D.6013>;
  <D.6012>:
  D.6014 = __strdup (str);
  return D.6014;
  <D.6013>:
  D.6014 = 0B;
  return D.6014;
}


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

  D.6017 = __builtin_object_size (__dest, 0);
  D.6016 = __builtin___memmove_chk (__dest, __src, __len, D.6017);
  return D.6016;
}


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

  D.6020 = __builtin_object_size (__dest, 1);
  D.6019 = __builtin___strcpy_chk (__dest, __src, D.6020);
  return D.6019;
}


mono_path_resolve_symlinks (const char * path)
{
  int D.5964;
  int iftmp.4;
  int D.5963;
  unsigned int i.5;
  unsigned int D.6026;
  gchar * * D.6027;
  const char[1] * D.6028;
  unsigned char D.6029;
  int D.6030;
  unsigned char D.6031;
  int D.6032;
  _Bool D.6033;
  _Bool D.6034;
  _Bool D.6035;
  const unsigned char * D.6038;
  unsigned char D.6039;
  int D.6040;
  const unsigned char * D.6041;
  unsigned char D.6042;
  int D.6043;
  _Bool D.6044;
  _Bool D.6045;
  const unsigned char * D.6048;
  unsigned char D.6049;
  int D.6050;
  const unsigned char * D.6051;
  unsigned char D.6052;
  int D.6053;
  _Bool D.6054;
  _Bool D.6055;
  const unsigned char * D.6058;
  unsigned char D.6059;
  int D.6060;
  const unsigned char * D.6061;
  unsigned char D.6062;
  int D.6063;
  gchar * D.6065;
  unsigned char D.6066;
  sizetype i.6;
  sizetype D.6070;
  sizetype D.6071;
  gchar * * D.6072;
  gchar * D.6073;
  gchar * D.6076;
  gchar * * split;
  gchar * p;
  int i;

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

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

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

        i.5 = (unsigned int) i;
        D.6026 = i.5 * 4;
        D.6027 = split + D.6026;
        __s2 = *D.6027;
        D.6028 = "";
        D.6029 = MEM[(const unsigned char *)D.6028];
        D.6030 = (int) D.6029;
        D.6031 = *__s2;
        D.6032 = (int) D.6031;
        __result = D.6030 - D.6032;
        {
          D.6033 = __s2_len != 0;
          D.6034 = __result == 0;
          D.6035 = D.6033 & D.6034;
          if (D.6035 != 0) goto <D.6036>; else goto <D.6037>;
          <D.6036>:
          D.6038 = &MEM[(void *)"" + 1B];
          D.6039 = *D.6038;
          D.6040 = (int) D.6039;
          D.6041 = __s2 + 1;
          D.6042 = *D.6041;
          D.6043 = (int) D.6042;
          __result = D.6040 - D.6043;
          D.6044 = __s2_len > 1;
          D.6034 = __result == 0;
          D.6045 = D.6044 & D.6034;
          if (D.6045 != 0) goto <D.6046>; else goto <D.6047>;
          <D.6046>:
          D.6048 = &MEM[(void *)"" + 2B];
          D.6049 = *D.6048;
          D.6050 = (int) D.6049;
          D.6051 = __s2 + 2;
          D.6052 = *D.6051;
          D.6053 = (int) D.6052;
          __result = D.6050 - D.6053;
          D.6054 = __s2_len > 2;
          D.6034 = __result == 0;
          D.6055 = D.6054 & D.6034;
          if (D.6055 != 0) goto <D.6056>; else goto <D.6057>;
          <D.6056>:
          D.6058 = &MEM[(void *)"" + 3B];
          D.6059 = *D.6058;
          D.6060 = (int) D.6059;
          D.6061 = __s2 + 3;
          D.6062 = *D.6061;
          D.6063 = (int) D.6062;
          __result = D.6060 - D.6063;
          <D.6057>:
          <D.6047>:
          <D.6037>:
        }
        D.5963 = __result;
      }
      iftmp.4 = -D.5963;
      goto <D.6064>;
      <D.6024>:
      i.5 = (unsigned int) i;
      D.6026 = i.5 * 4;
      D.6027 = split + D.6026;
      D.6065 = *D.6027;
      D.6066 = MEM[(const unsigned char * {ref-all})D.6065];
      iftmp.4 = (int) D.6066;
      <D.6064>:
      D.5964 = iftmp.4;
    }
    if (D.5964 != 0) goto <D.6067>; else goto <D.6068>;
    <D.6067>:
    i.5 = (unsigned int) i;
    D.6026 = i.5 * 4;
    D.6027 = split + D.6026;
    D.6065 = *D.6027;
    tmp = monoeg_g_strdup_printf ("%s%s", p, D.6065);
    monoeg_g_free (p);
    p = resolve_symlink (tmp);
    monoeg_g_free (tmp);
    <D.6068>:
    i.6 = (sizetype) i;
    D.6070 = i.6 + 1;
    D.6071 = D.6070 * 4;
    D.6072 = split + D.6071;
    D.6073 = *D.6072;
    if (D.6073 != 0B) goto <D.6074>; else goto <D.6075>;
    <D.6074>:
    tmp = monoeg_g_strdup_printf ("%s%s", p, "/");
    monoeg_g_free (p);
    p = tmp;
    <D.6075>:
  }
  i = i + 1;
  <D.5966>:
  i.5 = (unsigned int) i;
  D.6026 = i.5 * 4;
  D.6027 = split + D.6026;
  D.6065 = *D.6027;
  if (D.6065 != 0B) goto <D.5965>; else goto <D.5967>;
  <D.5967>:
  monoeg_g_strfreev (split);
  D.6076 = p;
  return D.6076;
}


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

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

        copy = p;
        p = mono_path_canonicalize (copy);
        monoeg_g_free (copy);
        D.6080 = p;
        return D.6080;
      }
      <D.6079>:
      buffer[n] = 0;
      D.6081 = monoeg_g_path_is_absolute (&buffer);
      if (D.6081 == 0) goto <D.6082>; else goto <D.6083>;
      <D.6082>:
      dir = monoeg_g_path_get_dirname (p);
      concat = monoeg_g_build_path ("/", dir, &buffer, 0B);
      monoeg_g_free (dir);
      goto <D.6084>;
      <D.6083>:
      concat = monoeg_strdup (&buffer);
      <D.6084>:
      monoeg_g_free (p);
      p = mono_path_canonicalize (concat);
      monoeg_g_free (concat);
      if (iterations <= 19) goto <D.5947>; else goto <D.5948>;
      <D.5948>:
      D.6080 = p;
      return D.6080;
    }
  finally
    {
      buffer = {CLOBBER};
    }
}


readlink (const char * restrict __path, char * restrict __buf, size_t __len)
{
  unsigned int D.6087;
  int D.6090;
  ssize_t D.6093;
  unsigned int D.6094;
  unsigned int D.6095;
  unsigned int D.6098;

  D.6087 = __builtin_object_size (__buf, 1);
  if (D.6087 != 4294967295) goto <D.6088>; else goto <D.6089>;
  <D.6088>:
  D.6090 = __builtin_constant_p (__len);
  if (D.6090 == 0) goto <D.6091>; else goto <D.6092>;
  <D.6091>:
  D.6094 = __builtin_object_size (__buf, 1);
  D.6093 = __readlink_chk (__path, __buf, __len, D.6094);
  return D.6093;
  <D.6092>:
  D.6095 = __builtin_object_size (__buf, 1);
  if (D.6095 < __len) goto <D.6096>; else goto <D.6097>;
  <D.6096>:
  D.6098 = __builtin_object_size (__buf, 1);
  D.6093 = __readlink_chk_warn (__path, __buf, __len, D.6098);
  return D.6093;
  <D.6097>:
  <D.6089>:
  D.6093 = __readlink_alias (__path, __buf, __len);
  return D.6093;
}


