_wapi_glob (struct GDir * dir, const char * pattern, int flags, struct wapi_glob_t * pglob)
{
  int D.6827;
  int D.6830;
  const u_char * patnext.0;
  unsigned char D.6834;
  gchar * bufnext.1;
  char D.6838;
  gchar * bufnext.2;
  char D.6841;
  const u_char * patnext.3;
  unsigned char D.6844;
  int D.6845;
  int D.6846;
  int D.6847;
  const u_char * patnext;
  int c;
  gchar * bufnext;
  gchar * bufend;
  gchar patbuf[4096];

  try
    {
      patnext = pattern;
      D.6827 = flags & 1;
      if (D.6827 == 0) goto <D.6828>; else goto <D.6829>;
      <D.6828>:
      pglob->gl_pathc = 0;
      pglob->gl_pathv = 0B;
      pglob->gl_offs = 0;
      <D.6829>:
      D.6830 = flags & -257;
      pglob->gl_flags = D.6830;
      bufnext = &patbuf;
      bufend = bufnext + 4095;
      goto <D.6714>;
      <D.6713>:
      if (c == 92) goto <D.6831>; else goto <D.6832>;
      <D.6831>:
      patnext.0 = patnext;
      patnext = patnext.0 + 1;
      D.6834 = *patnext.0;
      c = (int) D.6834;
      if (c == 0) goto <D.6835>; else goto <D.6836>;
      <D.6835>:
      c = 92;
      patnext = patnext + 18446744073709551615;
      <D.6836>:
      bufnext.1 = bufnext;
      bufnext = bufnext.1 + 1;
      D.6838 = (char) c;
      *bufnext.1 = D.6838;
      goto <D.6839>;
      <D.6832>:
      bufnext.2 = bufnext;
      bufnext = bufnext.2 + 1;
      D.6841 = (char) c;
      *bufnext.2 = D.6841;
      <D.6839>:
      <D.6714>:
      if (bufnext < bufend) goto <D.6842>; else goto <D.6715>;
      <D.6842>:
      patnext.3 = patnext;
      patnext = patnext.3 + 1;
      D.6844 = *patnext.3;
      c = (int) D.6844;
      if (c != 0) goto <D.6713>; else goto <D.6715>;
      <D.6715>:
      *bufnext = 0;
      D.6846 = flags & 16384;
      D.6847 = flags & 64;
      D.6845 = glob0 (dir, &patbuf, pglob, D.6846, D.6847);
      return D.6845;
    }
  finally
    {
      patbuf = {CLOBBER};
    }
}


glob0 (struct GDir * dir, const gchar * pattern, struct wapi_glob_t * pglob, gboolean ignorecase, gboolean unique)
{
  int D.6850;
  int D.6851;
  gchar * bufnext.4;
  gchar * D.6856;
  char D.6857;
  gchar * bufnext.5;
  gchar * bufnext.6;
  char D.6860;
  const gchar * qpatnext.7;
  char D.6862;
  int D.6865;
  int D.6866;
  const gchar * qpatnext;
  int c;
  int err;
  int oldpathc;
  gchar * bufnext;
  gchar patbuf[4096];
  size_t limit;

  try
    {
      limit = 0;
      qpatnext = pattern;
      oldpathc = pglob->gl_pathc;
      bufnext = &patbuf;
      goto <D.6735>;
      <D.6734>:
      switch (c) <default: <D.6733>, case 42: <D.6732>, case 63: <D.6730>>
      <D.6730>:
      D.6850 = pglob->gl_flags;
      D.6851 = D.6850 | 256;
      pglob->gl_flags = D.6851;
      bufnext.4 = bufnext;
      bufnext = bufnext.4 + 1;
      *bufnext.4 = 63;
      goto <D.6731>;
      <D.6732>:
      D.6850 = pglob->gl_flags;
      D.6851 = D.6850 | 256;
      pglob->gl_flags = D.6851;
      if (&patbuf == bufnext) goto <D.6853>; else goto <D.6855>;
      <D.6855>:
      D.6856 = bufnext + 18446744073709551615;
      D.6857 = *D.6856;
      if (D.6857 != 42) goto <D.6853>; else goto <D.6854>;
      <D.6853>:
      bufnext.5 = bufnext;
      bufnext = bufnext.5 + 1;
      *bufnext.5 = 42;
      <D.6854>:
      goto <D.6731>;
      <D.6733>:
      bufnext.6 = bufnext;
      bufnext = bufnext.6 + 1;
      D.6860 = (char) c;
      *bufnext.6 = D.6860;
      goto <D.6731>;
      <D.6731>:
      <D.6735>:
      qpatnext.7 = qpatnext;
      qpatnext = qpatnext.7 + 1;
      D.6862 = *qpatnext.7;
      c = (int) D.6862;
      if (c != 0) goto <D.6734>; else goto <D.6736>;
      <D.6736>:
      *bufnext = 0;
      err = glob1 (dir, &patbuf, &MEM[(void *)&patbuf + 4095B], pglob, &limit, ignorecase, unique);
      if (err != 0) goto <D.6863>; else goto <D.6864>;
      <D.6863>:
      D.6865 = err;
      return D.6865;
      <D.6864>:
      D.6866 = pglob->gl_pathc;
      if (D.6866 == oldpathc) goto <D.6867>; else goto <D.6868>;
      <D.6867>:
      D.6865 = -3;
      return D.6865;
      <D.6868>:
      D.6865 = 0;
      return D.6865;
    }
  finally
    {
      patbuf = {CLOBBER};
      limit = {CLOBBER};
    }
}


glob1 (struct GDir * dir, gchar * pattern, gchar * pattern_last, struct wapi_glob_t * pglob, size_t * limitp, gboolean ignorecase, gboolean unique)
{
  char D.6871;
  int D.6874;

  D.6871 = *pattern;
  if (D.6871 == 0) goto <D.6872>; else goto <D.6873>;
  <D.6872>:
  D.6874 = 0;
  return D.6874;
  <D.6873>:
  D.6874 = glob3 (dir, pattern, pattern_last, pglob, limitp, ignorecase, unique);
  return D.6874;
}


glob3 (struct GDir * dir, gchar * pattern, gchar * pattern_last, struct wapi_glob_t * pglob, size_t * limitp, gboolean ignorecase, gboolean unique)
{
  long unsigned int D.6876;
  gchar * D.6877;
  int D.6878;
  int D.6884;
  int D.6885;
  const gchar * name;

  goto <D.6774>;
  <D.6775>:
  D.6876 = strlen (pattern);
  D.6877 = pattern + D.6876;
  D.6878 = match (name, pattern, D.6877, ignorecase);
  if (D.6878 == 0) goto <D.6879>; else goto <D.6880>;
  <D.6879>:
  // predicted unlikely by continue predictor.
  goto <D.6774>;
  <D.6880>:
  if (unique == 0) goto <D.6881>; else goto <D.6883>;
  <D.6883>:
  D.6884 = contains (pglob, name);
  if (D.6884 == 0) goto <D.6881>; else goto <D.6882>;
  <D.6881>:
  globextend (name, pglob, limitp);
  <D.6882>:
  <D.6774>:
  name = monoeg_g_dir_read_name (dir);
  if (name != 0B) goto <D.6775>; else goto <D.6776>;
  <D.6776>:
  D.6885 = 0;
  return D.6885;
}


match (const gchar * name, gchar * pat, gchar * patend, gboolean ignorecase)
{
  gchar * pat.8;
  int D.6888;
  int D.6891;
  int D.6892;
  const gchar * name.9;
  char D.6896;
  const gchar * name.10;
  char D.6898;
  const gchar * name.11;
  char D.6904;
  char D.6905;
  char D.6906;
  const gchar * name.12;
  char D.6911;
  char D.6914;
  _Bool D.6915;
  gchar c;

  goto <D.6808>;
  <D.6807>:
  pat.8 = pat;
  pat = pat.8 + 1;
  c = *pat.8;
  D.6888 = (int) c;
  switch (D.6888) <default: <D.6806>, case 42: <D.6801>, case 63: <D.6804>>
  <D.6801>:
  if (pat == patend) goto <D.6889>; else goto <D.6890>;
  <D.6889>:
  D.6891 = 1;
  return D.6891;
  <D.6890>:
  <D.6802>:
  D.6892 = match (name, pat, patend, ignorecase);
  if (D.6892 != 0) goto <D.6893>; else goto <D.6894>;
  <D.6893>:
  D.6891 = 1;
  return D.6891;
  <D.6894>:
  name.9 = name;
  name = name.9 + 1;
  D.6896 = *name.9;
  if (D.6896 != 0) goto <D.6802>; else goto <D.6803>;
  <D.6803>:
  D.6891 = 0;
  return D.6891;
  <D.6804>:
  name.10 = name;
  name = name.10 + 1;
  D.6898 = *name.10;
  if (D.6898 == 0) goto <D.6899>; else goto <D.6900>;
  <D.6899>:
  D.6891 = 0;
  return D.6891;
  <D.6900>:
  goto <D.6805>;
  <D.6806>:
  if (ignorecase != 0) goto <D.6901>; else goto <D.6902>;
  <D.6901>:
  name.11 = name;
  name = name.11 + 1;
  D.6904 = *name.11;
  D.6905 = monoeg_g_ascii_tolower (D.6904);
  D.6906 = monoeg_g_ascii_tolower (c);
  if (D.6905 != D.6906) goto <D.6907>; else goto <D.6908>;
  <D.6907>:
  D.6891 = 0;
  return D.6891;
  <D.6908>:
  goto <D.6909>;
  <D.6902>:
  name.12 = name;
  name = name.12 + 1;
  D.6911 = *name.12;
  if (D.6911 != c) goto <D.6912>; else goto <D.6913>;
  <D.6912>:
  D.6891 = 0;
  return D.6891;
  <D.6913>:
  <D.6909>:
  goto <D.6805>;
  <D.6805>:
  <D.6808>:
  if (pat < patend) goto <D.6807>; else goto <D.6809>;
  <D.6809>:
  D.6914 = *name;
  D.6915 = D.6914 == 0;
  D.6891 = (int) D.6915;
  return D.6891;
}


contains (struct wapi_glob_t * pglob, const gchar * name)
{
  char * * D.6917;
  int D.6920;
  long unsigned int D.6921;
  long unsigned int D.6922;
  char * D.6923;
  int D.6760;
  gboolean D.6928;
  int i.13;
  int i;
  char * * pp;

  D.6917 = pglob->gl_pathv;
  if (D.6917 != 0B) goto <D.6918>; else goto <D.6919>;
  <D.6918>:
  D.6917 = pglob->gl_pathv;
  D.6920 = pglob->gl_offs;
  D.6921 = (long unsigned int) D.6920;
  D.6922 = D.6921 * 8;
  pp = D.6917 + D.6922;
  i = pglob->gl_pathc;
  goto <D.6762>;
  <D.6761>:
  D.6923 = *pp;
  if (D.6923 != 0B) goto <D.6924>; else goto <D.6925>;
  <D.6924>:
  {
    size_t __s1_len;
    size_t __s2_len;

    D.6923 = *pp;
    D.6760 = __builtin_strcmp (D.6923, name);
  }
  if (D.6760 == 0) goto <D.6926>; else goto <D.6927>;
  <D.6926>:
  D.6928 = 1;
  return D.6928;
  <D.6927>:
  <D.6925>:
  pp = pp + 8;
  <D.6762>:
  i.13 = i;
  i = i.13 + -1;
  if (i.13 != 0) goto <D.6761>; else goto <D.6763>;
  <D.6763>:
  <D.6919>:
  D.6928 = 0;
  return D.6928;
}


globextend (const gchar * path, struct wapi_glob_t * pglob, size_t * limitp)
{
  int D.6931;
  int D.6932;
  int D.6933;
  int D.6934;
  long unsigned int D.6935;
  unsigned int D.6936;
  void * iftmp.14;
  char * * D.6938;
  long unsigned int D.6941;
  int D.6947;
  long unsigned int D.6952;
  long unsigned int D.6953;
  const gchar * p.15;
  char D.6955;
  long int p.16;
  long int path.17;
  long int D.6958;
  long unsigned int D.6959;
  long unsigned int D.6960;
  long unsigned int D.6961;
  int D.6964;
  int D.6967;
  int D.6968;
  int D.6969;
  long unsigned int D.6970;
  long unsigned int D.6971;
  char * * D.6972;
  int D.6973;
  long unsigned int D.6974;
  long unsigned int D.6975;
  char * * D.6976;
  int iftmp.18;
  char * * pathv;
  int i;
  u_int newsize;
  u_int len;
  char * copy;
  const gchar * p;

  D.6931 = pglob->gl_pathc;
  D.6932 = D.6931 + 2;
  D.6933 = pglob->gl_offs;
  D.6934 = D.6932 + D.6933;
  D.6935 = (long unsigned int) D.6934;
  D.6936 = (unsigned int) D.6935;
  newsize = D.6936 * 8;
  D.6938 = pglob->gl_pathv;
  if (D.6938 != 0B) goto <D.6939>; else goto <D.6940>;
  <D.6939>:
  D.6938 = pglob->gl_pathv;
  D.6941 = (long unsigned int) newsize;
  iftmp.14 = realloc (D.6938, D.6941);
  goto <D.6942>;
  <D.6940>:
  D.6941 = (long unsigned int) newsize;
  iftmp.14 = malloc (D.6941);
  <D.6942>:
  pathv = iftmp.14;
  if (pathv == 0B) goto <D.6943>; else goto <D.6944>;
  <D.6943>:
  D.6938 = pglob->gl_pathv;
  if (D.6938 != 0B) goto <D.6945>; else goto <D.6946>;
  <D.6945>:
  D.6938 = pglob->gl_pathv;
  free (D.6938);
  pglob->gl_pathv = 0B;
  <D.6946>:
  D.6947 = -1;
  return D.6947;
  <D.6944>:
  D.6938 = pglob->gl_pathv;
  if (D.6938 == 0B) goto <D.6948>; else goto <D.6949>;
  <D.6948>:
  D.6933 = pglob->gl_offs;
  if (D.6933 > 0) goto <D.6950>; else goto <D.6951>;
  <D.6950>:
  D.6933 = pglob->gl_offs;
  D.6952 = (long unsigned int) D.6933;
  D.6953 = D.6952 * 8;
  pathv = pathv + D.6953;
  i = pglob->gl_offs;
  goto <D.6789>;
  <D.6788>:
  pathv = pathv + 18446744073709551608;
  *pathv = 0B;
  <D.6789>:
  i = i + -1;
  if (i >= 0) goto <D.6788>; else goto <D.6790>;
  <D.6790>:
  <D.6951>:
  <D.6949>:
  pglob->gl_pathv = pathv;
  p = path;
  goto <D.6792>;
  <D.6791>:
  <D.6792>:
  p.15 = p;
  p = p.15 + 1;
  D.6955 = *p.15;
  if (D.6955 != 0) goto <D.6791>; else goto <D.6793>;
  <D.6793>:
  p.16 = (long int) p;
  path.17 = (long int) path;
  D.6958 = p.16 - path.17;
  len = (u_int) D.6958;
  D.6959 = *limitp;
  D.6960 = (long unsigned int) len;
  D.6961 = D.6959 + D.6960;
  *limitp = D.6961;
  D.6960 = (long unsigned int) len;
  copy = malloc (D.6960);
  if (copy != 0B) goto <D.6962>; else goto <D.6963>;
  <D.6962>:
  D.6964 = g_Ctoc (path, copy, len);
  if (D.6964 != 0) goto <D.6965>; else goto <D.6966>;
  <D.6965>:
  free (copy);
  D.6947 = -1;
  return D.6947;
  <D.6966>:
  D.6933 = pglob->gl_offs;
  D.6931 = pglob->gl_pathc;
  D.6967 = D.6931;
  D.6968 = D.6967 + 1;
  pglob->gl_pathc = D.6968;
  D.6969 = D.6933 + D.6967;
  D.6970 = (long unsigned int) D.6969;
  D.6971 = D.6970 * 8;
  D.6972 = pathv + D.6971;
  *D.6972 = copy;
  <D.6963>:
  D.6933 = pglob->gl_offs;
  D.6931 = pglob->gl_pathc;
  D.6973 = D.6933 + D.6931;
  D.6974 = (long unsigned int) D.6973;
  D.6975 = D.6974 * 8;
  D.6976 = pathv + D.6975;
  *D.6976 = 0B;
  if (copy == 0B) goto <D.6978>; else goto <D.6979>;
  <D.6978>:
  iftmp.18 = -1;
  goto <D.6980>;
  <D.6979>:
  iftmp.18 = 0;
  <D.6980>:
  D.6947 = iftmp.18;
  return D.6947;
}


g_Ctoc (const gchar * str, char * buf, u_int len)
{
  char * buf.19;
  const gchar * str.20;
  char D.6984;
  char D.6985;
  int D.6988;
  unsigned int len.21;

  goto <D.6824>;
  <D.6823>:
  buf.19 = buf;
  buf = buf.19 + 1;
  str.20 = str;
  str = str.20 + 1;
  D.6984 = *str.20;
  *buf.19 = D.6984;
  D.6985 = *buf.19;
  if (D.6985 == 0) goto <D.6986>; else goto <D.6987>;
  <D.6986>:
  D.6988 = 0;
  return D.6988;
  <D.6987>:
  <D.6824>:
  len.21 = len;
  len = len.21 + 4294967295;
  if (len.21 != 0) goto <D.6823>; else goto <D.6825>;
  <D.6825>:
  D.6988 = 1;
  return D.6988;
}


_wapi_globfree (struct wapi_glob_t * pglob)
{
  char * * D.6991;
  int D.6994;
  long unsigned int D.6995;
  long unsigned int D.6996;
  char * D.6997;
  int i.22;
  int i;
  char * * pp;

  D.6991 = pglob->gl_pathv;
  if (D.6991 != 0B) goto <D.6992>; else goto <D.6993>;
  <D.6992>:
  D.6991 = pglob->gl_pathv;
  D.6994 = pglob->gl_offs;
  D.6995 = (long unsigned int) D.6994;
  D.6996 = D.6995 * 8;
  pp = D.6991 + D.6996;
  i = pglob->gl_pathc;
  goto <D.6816>;
  <D.6815>:
  D.6997 = *pp;
  if (D.6997 != 0B) goto <D.6998>; else goto <D.6999>;
  <D.6998>:
  D.6997 = *pp;
  free (D.6997);
  <D.6999>:
  pp = pp + 8;
  <D.6816>:
  i.22 = i;
  i = i.22 + -1;
  if (i.22 != 0) goto <D.6815>; else goto <D.6817>;
  <D.6817>:
  D.6991 = pglob->gl_pathv;
  free (D.6991);
  pglob->gl_pathv = 0B;
  <D.6993>:
}


