monoeg_g_build_path (const gchar * separator, const gchar * first_element)
{
  gchar * D.8164;
  unsigned int D.8165;
  sizetype D.8166;
  const char * D.8167;
  int D.8168;
  const char * D.8170;
  int endptr.0;
  int elem.1;
  int D.8175;
  void * D.8176;
  void * D.8177;
  int D.8179;
  char D.8180;
  _Bool D.8181;
  _Bool D.8182;
  _Bool D.8183;
  int slen.2;
  const char * elem;
  const char * next;
  const char * endptr;
  gboolean trimmed;
  struct GString * path;
  struct va_list args;
  size_t slen;

  try
    {
      if (separator == 0B) goto <D.8162>; else goto <D.8163>;
      <D.8162>:
      monoeg_g_log (0B, 8, "%s:%d: assertion \'%s\' failed", "gpath.c", 50, "separator != NULL");
      D.8164 = 0B;
      return D.8164;
      <D.8163>:
      path = monoeg_g_string_sized_new (48);
      slen = strlen (separator);
      __builtin_va_start (&args, 0);
      elem = first_element;
      goto <D.8123>;
      <D.8122>:
      D.8165 = strlen (elem);
      endptr = elem + D.8165;
      trimmed = 0;
      goto <D.8107>;
      <D.8106>:
      D.8166 = -slen;
      D.8167 = endptr + D.8166;
      D.8168 = strncmp (D.8167, separator, slen);
      if (D.8168 != 0) goto <D.8105>; else goto <D.8169>;
      <D.8169>:
      D.8166 = -slen;
      endptr = endptr + D.8166;
      trimmed = 1;
      <D.8107>:
      D.8170 = elem + slen;
      if (D.8170 <= endptr) goto <D.8106>; else goto <D.8105>;
      <D.8105>:
      if (endptr > elem) goto <D.8171>; else goto <D.8172>;
      <D.8171>:
      endptr.0 = (int) endptr;
      elem.1 = (int) elem;
      D.8175 = endptr.0 - elem.1;
      monoeg_g_string_append_len (path, elem, D.8175);
      <D.8172>:
      <D.8121>:
      D.8176 = args.__ap;
      D.8177 = D.8176 + 4;
      args.__ap = D.8177;
      next = MEM[(char * *)D.8176];
      if (next == 0B) goto <D.8108>; else goto <D.8178>;
      <D.8178>:
      goto <D.8119>;
      <D.8118>:
      next = next + slen;
      <D.8119>:
      D.8179 = strncmp (next, separator, slen);
      if (D.8179 == 0) goto <D.8118>; else goto <D.8120>;
      <D.8120>:
      D.8180 = *next;
      if (D.8180 == 0) goto <D.8121>; else goto <D.8108>;
      <D.8108>:
      D.8181 = next != 0B;
      D.8182 = trimmed != 0;
      D.8183 = D.8181 | D.8182;
      if (D.8183 != 0) goto <D.8184>; else goto <D.8185>;
      <D.8184>:
      slen.2 = (int) slen;
      monoeg_g_string_append_len (path, separator, slen.2);
      <D.8185>:
      elem = next;
      <D.8123>:
      if (elem != 0B) goto <D.8122>; else goto <D.8124>;
      <D.8124>:
      __builtin_va_end (&args);
      D.8164 = monoeg_g_string_free (path, 0);
      return D.8164;
    }
  finally
    {
      args = {CLOBBER};
    }
}


monoeg_g_path_get_dirname (const gchar * filename)
{
  gchar * D.8191;
  int p.3;
  int filename.4;
  int D.8198;
  unsigned int D.8199;
  char * D.8200;
  char * p;
  char * r;
  size_t count;

  if (filename == 0B) goto <D.8189>; else goto <D.8190>;
  <D.8189>:
  monoeg_g_log (0B, 8, "%s:%d: assertion \'%s\' failed", "gpath.c", 114, "filename != NULL");
  D.8191 = 0B;
  return D.8191;
  <D.8190>:
  p = strrchr_seperator (filename);
  if (p == 0B) goto <D.8192>; else goto <D.8193>;
  <D.8192>:
  D.8191 = monoeg_strdup (".");
  return D.8191;
  <D.8193>:
  if (p == filename) goto <D.8194>; else goto <D.8195>;
  <D.8194>:
  D.8191 = monoeg_strdup ("/");
  return D.8191;
  <D.8195>:
  p.3 = (int) p;
  filename.4 = (int) filename;
  D.8198 = p.3 - filename.4;
  count = (size_t) D.8198;
  D.8199 = count + 1;
  r = monoeg_malloc (D.8199);
  strncpy (r, filename, count);
  D.8200 = r + count;
  *D.8200 = 0;
  D.8191 = r;
  return D.8191;
}


strrchr_seperator (const gchar * filename)
{
  gchar * D.8202;
  char * p;

  p = strrchr (filename, 47);
  D.8202 = p;
  return D.8202;
}


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

  if (str != 0B) goto <D.8204>; else goto <D.8205>;
  <D.8204>:
  D.8206 = __strdup (str);
  return D.8206;
  <D.8205>:
  D.8206 = 0B;
  return D.8206;
}


strncpy (char * restrict __dest, const char * restrict __src, size_t __len)
{
  char * D.8208;
  unsigned int D.8209;

  D.8209 = __builtin_object_size (__dest, 1);
  D.8208 = __builtin___strncpy_chk (__dest, __src, __len, D.8209);
  return D.8208;
}


monoeg_g_path_get_basename (const char * filename)
{
  gchar * D.8213;
  char D.8214;
  char * D.8219;
  char D.8220;
  int r.5;
  int filename.6;
  int D.8225;
  sizetype D.8226;
  char * D.8227;
  const gchar * D.8230;
  char * r;

  if (filename == 0B) goto <D.8211>; else goto <D.8212>;
  <D.8211>:
  monoeg_g_log (0B, 8, "%s:%d: assertion \'%s\' failed", "gpath.c", 133, "filename != NULL");
  D.8213 = 0B;
  return D.8213;
  <D.8212>:
  D.8214 = *filename;
  if (D.8214 == 0) goto <D.8215>; else goto <D.8216>;
  <D.8215>:
  D.8213 = monoeg_strdup (".");
  return D.8213;
  <D.8216>:
  r = strrchr_seperator (filename);
  if (r == 0B) goto <D.8217>; else goto <D.8218>;
  <D.8217>:
  D.8213 = monoeg_strdup (filename);
  return D.8213;
  <D.8218>:
  D.8219 = r + 1;
  D.8220 = *D.8219;
  if (D.8220 == 0) goto <D.8221>; else goto <D.8222>;
  <D.8221>:
  {
    char * copy;

    copy = monoeg_strdup (filename);
    r.5 = (int) r;
    filename.6 = (int) filename;
    D.8225 = r.5 - filename.6;
    D.8226 = (sizetype) D.8225;
    D.8227 = copy + D.8226;
    *D.8227 = 0;
    r = strrchr_seperator (copy);
    if (r == 0B) goto <D.8228>; else goto <D.8229>;
    <D.8228>:
    monoeg_g_free (copy);
    D.8213 = monoeg_strdup ("/");
    return D.8213;
    <D.8229>:
    D.8230 = r + 1;
    r = monoeg_strdup (D.8230);
    monoeg_g_free (copy);
    D.8213 = r;
    return D.8213;
  }
  <D.8222>:
  D.8230 = r + 1;
  D.8213 = monoeg_strdup (D.8230);
  return D.8213;
}


monoeg_g_find_program_in_path (const gchar * program)
{
  const gchar * D.8232;
  gchar * D.8235;
  char D.8239;
  int D.8240;
  char * p;
  char * x;
  char * l;
  gchar * curdir;
  char * save;

  try
    {
      D.8232 = monoeg_g_getenv ("PATH");
      p = monoeg_strdup (D.8232);
      x = p;
      curdir = 0B;
      save = 0B;
      if (program == 0B) goto <D.8233>; else goto <D.8234>;
      <D.8233>:
      monoeg_g_log (0B, 8, "%s:%d: assertion \'%s\' failed", "gpath.c", 230, "program != NULL");
      D.8235 = 0B;
      return D.8235;
      <D.8234>:
      if (x == 0B) goto <D.8236>; else goto <D.8238>;
      <D.8238>:
      D.8239 = *x;
      if (D.8239 == 0) goto <D.8236>; else goto <D.8237>;
      <D.8236>:
      curdir = monoeg_g_get_current_dir ();
      x = curdir;
      <D.8237>:
      goto <D.8150>;
      <D.8149>:
      {
        char * probe_path;

        x = 0B;
        probe_path = monoeg_g_build_path ("/", l, program, 0B);
        D.8240 = access (probe_path, 1);
        if (D.8240 == 0) goto <D.8241>; else goto <D.8242>;
        <D.8241>:
        monoeg_g_free (curdir);
        monoeg_g_free (p);
        D.8235 = probe_path;
        return D.8235;
        <D.8242>:
        monoeg_g_free (probe_path);
      }
      <D.8150>:
      l = strtok_r (x, ":", &save);
      if (l != 0B) goto <D.8149>; else goto <D.8151>;
      <D.8151>:
      monoeg_g_free (curdir);
      monoeg_g_free (p);
      D.8235 = 0B;
      return D.8235;
    }
  finally
    {
      save = {CLOBBER};
    }
}


monoeg_g_set_prgname (const gchar * prgname)
{
  gchar * name.7;

  name.7 = monoeg_strdup (prgname);
  name = name.7;
}


monoeg_g_get_prgname ()
{
  gchar * D.8246;

  D.8246 = name;
  return D.8246;
}


