monoeg_g_pattern_spec_new (const gchar * pattern)
{
  struct GPatternSpec * D.6000;
  struct GSList * D.6003;
  struct GPatternSpec * spec;

  if (pattern == 0B) goto <D.5998>; else goto <D.5999>;
  <D.5998>:
  monoeg_g_log (0B, 8, "%s:%d: assertion \'%s\' failed", "gpattern.c", 127, "pattern != NULL");
  D.6000 = 0B;
  return D.6000;
  <D.5999>:
  spec = monoeg_malloc0 (8);
  if (pattern != 0B) goto <D.6001>; else goto <D.6002>;
  <D.6001>:
  D.6003 = compile_pattern (pattern);
  spec->pattern = D.6003;
  <D.6002>:
  D.6000 = spec;
  return D.6000;
}


compile_pattern (const gchar * pattern)
{
  struct GSList * D.6007;
  const gchar * D.6008;
  long unsigned int D.6013;
  gchar * D.6016;
  MatchType iftmp.0;
  char * D.6031;
  struct GSList * list;
  size_t i;
  size_t len;
  struct PData * data;
  gchar c;
  MatchType last;
  struct GString * str;
  gboolean free_str;

  last = -1;
  if (pattern == 0B) goto <D.6005>; else goto <D.6006>;
  <D.6005>:
  D.6007 = 0B;
  return D.6007;
  <D.6006>:
  data = 0B;
  list = 0B;
  free_str = 1;
  str = monoeg_g_string_new ("");
  i = 0;
  len = strlen (pattern);
  goto <D.5956>;
  <D.5955>:
  D.6008 = pattern + i;
  c = *D.6008;
  if (c == 42) goto <D.6009>; else goto <D.6012>;
  <D.6012>:
  if (c == 63) goto <D.6009>; else goto <D.6010>;
  <D.6009>:
  D.6013 = str->len;
  if (D.6013 != 0) goto <D.6014>; else goto <D.6015>;
  <D.6014>:
  data = monoeg_malloc0 (16);
  data->type = 0;
  D.6016 = monoeg_g_string_free (str, 0);
  data->str = D.6016;
  list = monoeg_g_slist_append (list, data);
  str = monoeg_g_string_new ("");
  <D.6015>:
  if (last == 2) goto <D.6017>; else goto <D.6018>;
  <D.6017>:
  if (c == 42) goto <D.6019>; else goto <D.6020>;
  <D.6019>:
  // predicted unlikely by continue predictor.
  goto <D.5954>;
  <D.6020>:
  <D.6018>:
  data = monoeg_malloc0 (16);
  if (c == 42) goto <D.6022>; else goto <D.6023>;
  <D.6022>:
  iftmp.0 = 2;
  goto <D.6024>;
  <D.6023>:
  iftmp.0 = 1;
  <D.6024>:
  data->type = iftmp.0;
  list = monoeg_g_slist_append (list, data);
  last = data->type;
  goto <D.6011>;
  <D.6010>:
  monoeg_g_string_append_c (str, c);
  last = 0;
  <D.6011>:
  <D.5954>:
  i = i + 1;
  <D.5956>:
  if (i < len) goto <D.5955>; else goto <D.5957>;
  <D.5957>:
  if (last == 2) goto <D.6027>; else goto <D.6025>;
  <D.6027>:
  D.6013 = str->len;
  if (D.6013 == 0) goto <D.6028>; else goto <D.6025>;
  <D.6028>:
  data->type = 3;
  free_str = 1;
  goto <D.6026>;
  <D.6025>:
  D.6013 = str->len;
  if (D.6013 != 0) goto <D.6029>; else goto <D.6030>;
  <D.6029>:
  data = monoeg_malloc0 (16);
  data->type = 0;
  D.6031 = str->str;
  data->str = D.6031;
  free_str = 0;
  list = monoeg_g_slist_append (list, data);
  <D.6030>:
  <D.6026>:
  monoeg_g_string_free (str, free_str);
  D.6007 = list;
  return D.6007;
}


monoeg_g_pattern_spec_free (struct GPatternSpec * pspec)
{
  struct GSList * D.6035;

  if (pspec != 0B) goto <D.6033>; else goto <D.6034>;
  <D.6033>:
  D.6035 = pspec->pattern;
  monoeg_g_slist_foreach (D.6035, free_pdata, 0B);
  D.6035 = pspec->pattern;
  monoeg_g_slist_free (D.6035);
  pspec->pattern = 0B;
  <D.6034>:
  monoeg_g_free (pspec);
}


free_pdata (void * data, void * user_data)
{
  gchar * D.6036;
  struct PData * d;

  d = data;
  D.6036 = d->str;
  if (D.6036 != 0B) goto <D.6037>; else goto <D.6038>;
  <D.6037>:
  D.6036 = d->str;
  monoeg_g_free (D.6036);
  <D.6038>:
  monoeg_g_free (d);
}


monoeg_g_pattern_match_string (struct GPatternSpec * pspec, const gchar * string)
{
  gboolean D.6041;
  struct GSList * D.6044;
  long unsigned int D.6047;

  if (pspec == 0B) goto <D.6039>; else goto <D.6040>;
  <D.6039>:
  monoeg_g_log (0B, 8, "%s:%d: assertion \'%s\' failed", "gpattern.c", 205, "pspec != NULL");
  D.6041 = 0;
  return D.6041;
  <D.6040>:
  if (string == 0B) goto <D.6042>; else goto <D.6043>;
  <D.6042>:
  monoeg_g_log (0B, 8, "%s:%d: assertion \'%s\' failed", "gpattern.c", 206, "string != NULL");
  D.6041 = 0;
  return D.6041;
  <D.6043>:
  D.6044 = pspec->pattern;
  if (D.6044 == 0B) goto <D.6045>; else goto <D.6046>;
  <D.6045>:
  D.6041 = 0;
  return D.6041;
  <D.6046>:
  D.6044 = pspec->pattern;
  D.6047 = strlen (string);
  D.6041 = match_string (D.6044, string, 0, D.6047);
  return D.6041;
}


match_string (struct GSList * list, const gchar * str, size_t idx, size_t max)
{
  <unnamed type> D.6049;
  gboolean D.6052;
  gchar * D.6055;
  const gchar * D.6056;
  int D.6057;
  struct GSList * D.6070;
  long unsigned int idx.1;
  int D.6072;
  int iftmp.2;
  size_t len;

  goto <D.5991>;
  <D.5990>:
  {
    struct PData * data;

    data = list->data;
    D.6049 = data->type;
    if (D.6049 == 3) goto <D.6050>; else goto <D.6051>;
    <D.6050>:
    D.6052 = 1;
    return D.6052;
    <D.6051>:
    D.6049 = data->type;
    if (D.6049 == 0) goto <D.6053>; else goto <D.6054>;
    <D.6053>:
    D.6055 = data->str;
    len = strlen (D.6055);
    D.6056 = str + idx;
    D.6055 = data->str;
    D.6057 = strncmp (D.6056, D.6055, len);
    if (D.6057 != 0) goto <D.6058>; else goto <D.6059>;
    <D.6058>:
    D.6052 = 0;
    return D.6052;
    <D.6059>:
    idx = idx + len;
    list = list->next;
    if (list != 0B) goto <D.6060>; else goto <D.6061>;
    <D.6060>:
    data = list->data;
    D.6049 = data->type;
    if (D.6049 == 3) goto <D.6062>; else goto <D.6063>;
    <D.6062>:
    D.6052 = 1;
    return D.6052;
    <D.6063>:
    <D.6061>:
    goto <D.6064>;
    <D.6054>:
    D.6049 = data->type;
    if (D.6049 == 1) goto <D.6065>; else goto <D.6066>;
    <D.6065>:
    idx = idx + 1;
    list = list->next;
    goto <D.6067>;
    <D.6066>:
    D.6049 = data->type;
    if (D.6049 == 2) goto <D.6068>; else goto <D.6069>;
    <D.6068>:
    goto <D.5988>;
    <D.5987>:
    D.6070 = list->next;
    idx.1 = idx;
    idx = idx.1 + 1;
    D.6072 = match_string (D.6070, str, idx.1, max);
    if (D.6072 != 0) goto <D.6073>; else goto <D.6074>;
    <D.6073>:
    D.6052 = 1;
    return D.6052;
    <D.6074>:
    <D.5988>:
    if (idx < max) goto <D.5987>; else goto <D.5989>;
    <D.5989>:
    D.6052 = 0;
    return D.6052;
    <D.6069>:
    monoeg_assertion_message ("* Assertion: should not be reached at %s:%d\n", "gpattern.c", 196);
    <D.6067>:
    <D.6064>:
  }
  <D.5991>:
  if (list != 0B) goto <D.6075>; else goto <D.5992>;
  <D.6075>:
  if (idx < max) goto <D.5990>; else goto <D.5992>;
  <D.5992>:
  if (list == 0B) goto <D.6079>; else goto <D.6077>;
  <D.6079>:
  if (idx >= max) goto <D.6080>; else goto <D.6077>;
  <D.6080>:
  iftmp.2 = 1;
  goto <D.6078>;
  <D.6077>:
  iftmp.2 = 0;
  <D.6078>:
  D.6052 = iftmp.2;
  return D.6052;
}


