mono_path_canonicalize (const char * path)
{
  int D.6325;
  long int pos.0;
  long int lastpos.1;
  long int D.6331;
  char D.6335;
  gchar * D.6341;
  char D.6342;
  int D.6351;
  long unsigned int D.6352;
  sizetype D.6353;
  sizetype D.6354;
  char * D.6357;
  long unsigned int D.6360;
  int D.6361;
  long unsigned int D.6362;
  sizetype D.6363;
  gchar * D.6364;
  sizetype D.6365;
  gchar * D.6366;
  gchar * D.6367;
  gchar * abspath;
  gchar * pos;
  gchar * lastpos;
  gchar * dest;
  int backc;

  D.6325 = monoeg_g_path_is_absolute (path);
  if (D.6325 != 0) goto <D.6326>; else goto <D.6327>;
  <D.6326>:
  abspath = monoeg_strdup (path);
  goto <D.6328>;
  <D.6327>:
  {
    gchar * tmpdir;

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

    pos.0 = (long int) pos;
    lastpos.1 = (long int) lastpos;
    D.6331 = pos.0 - lastpos.1;
    len = (int) D.6331;
    if (len == 1) goto <D.6334>; else goto <D.6332>;
    <D.6334>:
    D.6335 = *lastpos;
    if (D.6335 == 46) goto <D.6336>; else goto <D.6332>;
    <D.6336>:
    goto <D.6333>;
    <D.6332>:
    if (len == 2) goto <D.6339>; else goto <D.6337>;
    <D.6339>:
    D.6335 = *lastpos;
    if (D.6335 == 46) goto <D.6340>; else goto <D.6337>;
    <D.6340>:
    D.6341 = lastpos + 1;
    D.6342 = *D.6341;
    if (D.6342 == 46) goto <D.6343>; else goto <D.6337>;
    <D.6343>:
    backc = backc + 1;
    goto <D.6338>;
    <D.6337>:
    if (len > 0) goto <D.6344>; else goto <D.6345>;
    <D.6344>:
    if (backc > 0) goto <D.6346>; else goto <D.6347>;
    <D.6346>:
    backc = backc + -1;
    goto <D.6348>;
    <D.6347>:
    if (dest != lastpos) goto <D.6349>; else goto <D.6350>;
    <D.6349>:
    D.6351 = len + 1;
    D.6352 = (long unsigned int) D.6351;
    memmove (dest, lastpos, D.6352);
    <D.6350>:
    D.6353 = (sizetype) len;
    D.6354 = D.6353 + 1;
    dest = dest + D.6354;
    <D.6348>:
    <D.6345>:
    <D.6338>:
    <D.6333>:
    lastpos = pos + 1;
    pos = __builtin_strchr (lastpos, 47);
  }
  <D.6290>:
  if (pos != 0B) goto <D.6289>; else goto <D.6291>;
  <D.6291>:
  if (dest != lastpos) goto <D.6355>; else goto <D.6356>;
  <D.6355>:
  strcpy (dest, lastpos);
  <D.6356>:
  monoeg_g_strreverse (abspath);
  D.6357 = __builtin_strchr (abspath, 47);
  if (D.6357 == 0B) goto <D.6358>; else goto <D.6359>;
  <D.6358>:
  {
    int len;

    D.6360 = strlen (abspath);
    len = (int) D.6360;
    D.6361 = len + 2;
    D.6362 = (long unsigned int) D.6361;
    abspath = monoeg_realloc (abspath, D.6362);
    D.6363 = (sizetype) len;
    D.6364 = abspath + D.6363;
    *D.6364 = 47;
    D.6363 = (sizetype) len;
    D.6365 = D.6363 + 1;
    D.6366 = abspath + D.6365;
    *D.6366 = 0;
  }
  <D.6359>:
  D.6367 = abspath;
  return D.6367;
}


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

  if (str != 0B) goto <D.6369>; else goto <D.6370>;
  <D.6369>:
  D.6371 = __strdup (str);
  return D.6371;
  <D.6370>:
  D.6371 = 0B;
  return D.6371;
}


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

  D.6374 = __builtin_object_size (__dest, 0);
  D.6373 = __builtin___memmove_chk (__dest, __src, __len, D.6374);
  return D.6373;
}


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

  D.6377 = __builtin_object_size (__dest, 1);
  D.6376 = __builtin___strcpy_chk (__dest, __src, D.6377);
  return D.6376;
}


mono_path_resolve_symlinks (const char * path)
{
  int D.6320;
  int iftmp.2;
  int D.6319;
  long unsigned int D.6382;
  long unsigned int D.6383;
  gchar * * D.6384;
  const char[1] * D.6385;
  unsigned char D.6386;
  int D.6387;
  unsigned char D.6388;
  int D.6389;
  _Bool D.6390;
  _Bool D.6391;
  _Bool D.6392;
  const unsigned char * D.6395;
  unsigned char D.6396;
  int D.6397;
  const unsigned char * D.6398;
  unsigned char D.6399;
  int D.6400;
  _Bool D.6401;
  _Bool D.6402;
  const unsigned char * D.6405;
  unsigned char D.6406;
  int D.6407;
  const unsigned char * D.6408;
  unsigned char D.6409;
  int D.6410;
  _Bool D.6411;
  _Bool D.6412;
  const unsigned char * D.6415;
  unsigned char D.6416;
  int D.6417;
  const unsigned char * D.6418;
  unsigned char D.6419;
  int D.6420;
  gchar * D.6422;
  unsigned char D.6423;
  sizetype D.6426;
  sizetype D.6427;
  sizetype D.6428;
  gchar * * D.6429;
  gchar * D.6430;
  gchar * D.6433;
  gchar * * split;
  gchar * p;
  int i;

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

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

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

        D.6382 = (long unsigned int) i;
        D.6383 = D.6382 * 8;
        D.6384 = split + D.6383;
        __s2 = *D.6384;
        D.6385 = "";
        D.6386 = MEM[(const unsigned char *)D.6385];
        D.6387 = (int) D.6386;
        D.6388 = *__s2;
        D.6389 = (int) D.6388;
        __result = D.6387 - D.6389;
        {
          D.6390 = __s2_len != 0;
          D.6391 = __result == 0;
          D.6392 = D.6390 & D.6391;
          if (D.6392 != 0) goto <D.6393>; else goto <D.6394>;
          <D.6393>:
          D.6395 = &MEM[(void *)"" + 1B];
          D.6396 = *D.6395;
          D.6397 = (int) D.6396;
          D.6398 = __s2 + 1;
          D.6399 = *D.6398;
          D.6400 = (int) D.6399;
          __result = D.6397 - D.6400;
          D.6401 = __s2_len > 1;
          D.6391 = __result == 0;
          D.6402 = D.6401 & D.6391;
          if (D.6402 != 0) goto <D.6403>; else goto <D.6404>;
          <D.6403>:
          D.6405 = &MEM[(void *)"" + 2B];
          D.6406 = *D.6405;
          D.6407 = (int) D.6406;
          D.6408 = __s2 + 2;
          D.6409 = *D.6408;
          D.6410 = (int) D.6409;
          __result = D.6407 - D.6410;
          D.6411 = __s2_len > 2;
          D.6391 = __result == 0;
          D.6412 = D.6411 & D.6391;
          if (D.6412 != 0) goto <D.6413>; else goto <D.6414>;
          <D.6413>:
          D.6415 = &MEM[(void *)"" + 3B];
          D.6416 = *D.6415;
          D.6417 = (int) D.6416;
          D.6418 = __s2 + 3;
          D.6419 = *D.6418;
          D.6420 = (int) D.6419;
          __result = D.6417 - D.6420;
          <D.6414>:
          <D.6404>:
          <D.6394>:
        }
        D.6319 = __result;
      }
      iftmp.2 = -D.6319;
      goto <D.6421>;
      <D.6381>:
      D.6382 = (long unsigned int) i;
      D.6383 = D.6382 * 8;
      D.6384 = split + D.6383;
      D.6422 = *D.6384;
      D.6423 = MEM[(const unsigned char * {ref-all})D.6422];
      iftmp.2 = (int) D.6423;
      <D.6421>:
      D.6320 = iftmp.2;
    }
    if (D.6320 != 0) goto <D.6424>; else goto <D.6425>;
    <D.6424>:
    D.6382 = (long unsigned int) i;
    D.6383 = D.6382 * 8;
    D.6384 = split + D.6383;
    D.6422 = *D.6384;
    tmp = monoeg_g_strdup_printf ("%s%s", p, D.6422);
    monoeg_g_free (p);
    p = resolve_symlink (tmp);
    monoeg_g_free (tmp);
    <D.6425>:
    D.6426 = (sizetype) i;
    D.6427 = D.6426 + 1;
    D.6428 = D.6427 * 8;
    D.6429 = split + D.6428;
    D.6430 = *D.6429;
    if (D.6430 != 0B) goto <D.6431>; else goto <D.6432>;
    <D.6431>:
    tmp = monoeg_g_strdup_printf ("%s%s", p, "/");
    monoeg_g_free (p);
    p = tmp;
    <D.6432>:
  }
  i = i + 1;
  <D.6322>:
  D.6382 = (long unsigned int) i;
  D.6383 = D.6382 * 8;
  D.6384 = split + D.6383;
  D.6422 = *D.6384;
  if (D.6422 != 0B) goto <D.6321>; else goto <D.6323>;
  <D.6323>:
  monoeg_g_strfreev (split);
  D.6433 = p;
  return D.6433;
}


resolve_symlink (const char * path)
{
  long int D.6435;
  gchar * D.6438;
  int D.6439;
  char * p;
  char * concat;
  char * dir;
  char buffer[4097];
  int n;
  int iterations;

  try
    {
      iterations = 0;
      p = monoeg_strdup (path);
      <D.6303>:
      iterations = iterations + 1;
      D.6435 = readlink (p, &buffer, 4096);
      n = (int) D.6435;
      if (n < 0) goto <D.6436>; else goto <D.6437>;
      <D.6436>:
      {
        char * copy;

        copy = p;
        p = mono_path_canonicalize (copy);
        monoeg_g_free (copy);
        D.6438 = p;
        return D.6438;
      }
      <D.6437>:
      buffer[n] = 0;
      D.6439 = monoeg_g_path_is_absolute (&buffer);
      if (D.6439 == 0) goto <D.6440>; else goto <D.6441>;
      <D.6440>:
      dir = monoeg_g_path_get_dirname (p);
      concat = monoeg_g_build_path ("/", dir, &buffer, 0B);
      monoeg_g_free (dir);
      goto <D.6442>;
      <D.6441>:
      concat = monoeg_strdup (&buffer);
      <D.6442>:
      monoeg_g_free (p);
      p = mono_path_canonicalize (concat);
      monoeg_g_free (concat);
      if (iterations <= 19) goto <D.6303>; else goto <D.6304>;
      <D.6304>:
      D.6438 = p;
      return D.6438;
    }
  finally
    {
      buffer = {CLOBBER};
    }
}


readlink (const char * restrict __path, char * restrict __buf, size_t __len)
{
  long unsigned int D.6445;
  int D.6448;
  ssize_t D.6451;
  long unsigned int D.6452;
  long unsigned int D.6453;
  long unsigned int D.6456;

  D.6445 = __builtin_object_size (__buf, 1);
  if (D.6445 != 18446744073709551615) goto <D.6446>; else goto <D.6447>;
  <D.6446>:
  D.6448 = __builtin_constant_p (__len);
  if (D.6448 == 0) goto <D.6449>; else goto <D.6450>;
  <D.6449>:
  D.6452 = __builtin_object_size (__buf, 1);
  D.6451 = __readlink_chk (__path, __buf, __len, D.6452);
  return D.6451;
  <D.6450>:
  D.6453 = __builtin_object_size (__buf, 1);
  if (D.6453 < __len) goto <D.6454>; else goto <D.6455>;
  <D.6454>:
  D.6456 = __builtin_object_size (__buf, 1);
  D.6451 = __readlink_chk_warn (__path, __buf, __len, D.6456);
  return D.6451;
  <D.6455>:
  <D.6447>:
  D.6451 = __readlink_alias (__path, __buf, __len);
  return D.6451;
}


