decompiled_code:
void init_tree()
{
rule_root = 0LL;
meta_root = 0LL;
element_root = 0LL;
}

canonical_decompiled_code:
void func6()
{
rule_root = 0LL;
meta_root = 0LL;
element_root = 0LL;
}

original_code:
void init_tree ()
 { rule_root = ((rule_tree) ((void *)0));
   meta_root = ((meta_tree) ((void *)0));
   element_root = ((element_tree) ((void *)0));
 }

canonical_original_code:
void init_tree()
 { rule_root = ((rule_tree) ((void *)0));
   meta_root = ((meta_tree) ((void *)0));
   element_root = ((element_tree) ((void *)0));
 }


repo: tjordanchat/eag

decompiled_code:
__int64 __fastcall generate_meta_rule_declaration(const char **a1)
{
__int64 result; // rax

if ( *((_DWORD *)a1 + 12) )
{
if ( *((_DWORD *)a1 + 4) )
{
code_line("affix_node make_%s_affix ();", *a1);
result = code_line("void rec_%s_value ();", *a1);
}
else
{
result = code_line("static affix_node make_%s_affix ();", *a1);
if ( *((_DWORD *)a1 + 16) )
result = code_line("static void rec_%s_value ();", *a1);
if ( *((_DWORD *)a1 + 17) )
result = code_line("static void recbup_%s_value ();", *a1);
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(const char **a1)
{
__int64 result; // rax

if ( *((_DWORD *)a1 + 12) )
{
if ( *((_DWORD *)a1 + 4) )
{
code_line("affix_node make_%s_affix ();", *a1);
result = code_line("void rec_%s_value ();", *a1);
}
else
{
result = code_line("static affix_node make_%s_affix ();", *a1);
if ( *((_DWORD *)a1 + 16) )
result = code_line("static void rec_%s_value ();", *a1);
if ( *((_DWORD *)a1 + 17) )
result = code_line("static void recbup_%s_value ();", *a1);
}
}
return result;
}

original_code:
static void generate_meta_rule_declaration (meta_rule mrule)
 { if (!mrule -> reachable) return;
   if (mrule -> ext)
      { code_line ("affix_node make_%s_affix ();", mrule -> nonterminal);
        code_line ("void rec_%s_value ();", mrule -> nonterminal);
        return;
      };
          code_line ("static affix_node make_%s_affix ();", mrule -> nonterminal);
   if (mrule -> needs_rec)
      code_line ("static void rec_%s_value ();", mrule -> nonterminal);
   if (mrule -> needs_recbup)
      code_line ("static void recbup_%s_value ();", mrule -> nonterminal);
 }

canonical_original_code:
static void generate_meta_rule_declaration(struct meta_rule_rec *mrule)
 { if (!mrule -> reachable) return;
   if (mrule -> ext)
      { code_line ("affix_node make_%s_affix ();", mrule -> nonterminal);
        code_line ("void rec_%s_value ();", mrule -> nonterminal);
        return;
      };
          code_line ("static affix_node make_%s_affix ();", mrule -> nonterminal);
   if (mrule -> needs_rec)
      code_line ("static void rec_%s_value ();", mrule -> nonterminal);
   if (mrule -> needs_recbup)
      code_line ("static void recbup_%s_value ();", mrule -> nonterminal);
 }

variable_types: struct meta_rule_rec { char *nonterminal; struct meta_alt_list_rec { int size; int room; struct meta_alt_rec { struct expr_rec { int tag; union { struct affix_rec { char *name; int type; struct affix_rec *next; struct value_rec { int admin_nr; int ref_count; void *dptr; int tag; union { char *str; int inum; double rnum; struct value_list_rec { int size; int room; struct value_rec **array; } *tuple; int slat; struct int_list_rec { int size; int room; int *array; } *elat; struct value_rec *free; } u; } *val; int ref_count; int reachable; int tag; union { struct variable_rec { char *nonterminal; char *suffix; struct meta_rule_rec *def; } var; char *str; int inum; double rnum; struct cset_rec { int kind; char *str; } *semi; struct element_rec { char *eltnm; struct element_def_rec { char *eltnm; int number; int eltnr; struct element_set_rec { int number; struct element_def_list_rec { int size; int room; struct element_def_rec **array; } *defs; } *set; } *def; } elt; struct expr_rec *cexpr; } u; } *single; struct affix_list_rec { int size; int room; struct affix_rec **array; } *compos; struct affix_list_rec *concat; struct affix_list_rec *uni; } u; } *e; int number; } **array; } *alts; int ext; int type; int kind; int empty; int number; struct value_rec *mvalue; int reachable; struct element_def_rec *lat_repr; int needs_rec; int needs_recbup; } *

return_type: void

user_defined_types: struct meta_rule_rec { char *nonterminal; struct meta_alt_list_rec *alts; int ext; int type; int kind; int empty; int number; struct value_rec *mvalue; int reachable; struct element_def_rec *lat_repr; int needs_rec; int needs_recbup; }

user_defined_types: struct meta_alt_list_rec { int size; int room; struct meta_alt_rec **array; }

user_defined_types: struct meta_alt_rec { struct expr_rec *e; int number; }

user_defined_types: struct expr_rec { int tag; union { struct affix_rec *single; struct affix_list_rec *compos; struct affix_list_rec *concat; struct affix_list_rec *uni; } u; }

user_defined_types: struct affix_rec { char *name; int type; struct affix_rec *next; struct value_rec *val; int ref_count; int reachable; int tag; union { struct variable_rec var; char *str; int inum; double rnum; struct cset_rec *semi; struct element_rec elt; struct expr_rec *cexpr; } u; }

user_defined_types: struct value_rec { int admin_nr; int ref_count; void *dptr; int tag; union { char *str; int inum; double rnum; struct value_list_rec *tuple; int slat; struct int_list_rec *elat; struct value_rec *free; } u; }

user_defined_types: struct element_rec { char *eltnm; struct element_def_rec *def; }

user_defined_types: struct element_def_rec { char *eltnm; int number; int eltnr; struct element_set_rec *set; }

user_defined_types: struct element_set_rec { int number; struct element_def_list_rec *defs; }


decompiled_code:
__int64 generate_meta_rule_declarations()
{
__int64 v0; // rbx

code_line("/* forward declare meta rule routines */");
if ( nr_of_meta_rules > 0 )
{
v0 = 0LL;
do
generate_meta_rule_declaration(*(const char ***)(all_meta_rules + 8 * v0++));
while ( nr_of_meta_rules > (int)v0 );
}
return code_line((const char *)&unk_CE3);
}

canonical_decompiled_code:
__int64 func1()
{
__int64 v0; // rbx

code_line("/* forward declare meta rule routines */");
if ( nr_of_meta_rules > 0 )
{
v0 = 0LL;
do
func0(*(const char ***)(all_meta_rules + 8 * v0++));
while ( nr_of_meta_rules > (int)v0 );
}
return code_line((const char *)&unk_CE3);
}

original_code:
static void generate_meta_rule_declarations ()
 { int ix;
   code_line ("/* forward declare meta rule routines */");
   for (ix = 0; ix < nr_of_meta_rules; ix++)
      generate_meta_rule_declaration (all_meta_rules[ix]);
   code_line ("");
 }

canonical_original_code:
static void generate_meta_rule_declarations()
 { int ix;
   code_line ("/* forward declare meta rule routines */");
   for (ix = 0; ix < nr_of_meta_rules; ix++)
      generate_meta_rule_declaration (all_meta_rules[ix]);
   code_line ("");
 }

variable_types: ix int


decompiled_code:
__int64 __fastcall generate_qstack_mcheck(const char **a1, int a2, int a3)
{
const char *v4; // rsi
const char *v5; // r8

if ( a3 )
{
code_line("\t %sif (lqptr != qptr)", (const char *)&unk_CE3);
v4 = (const char *)&unk_CE3;
v5 = "body";
}
else
{
code_line("\t %sif (lqptr != qptr)", " ");
v4 = " ";
v5 = (const char *)&unk_CE3;
}
return code_line(
"\t %s panic (\"qstack inconsistency detected in metarule %s, alt %d, rec%s\");",
v4,
*a1,
(unsigned int)(a2 + 1),
v5);
}

canonical_decompiled_code:
__int64 __fastcall func2(const char **a1, int a2, int a3)
{
const char *v4; // rsi
const char *v5; // r8

if ( a3 )
{
code_line("\t %sif (lqptr != qptr)", (const char *)&unk_CE3);
v4 = (const char *)&unk_CE3;
v5 = "body";
}
else
{
code_line("\t %sif (lqptr != qptr)", " ");
v4 = " ";
v5 = (const char *)&unk_CE3;
}
return code_line(
"\t %s panic (\"qstack inconsistency detected in metarule %s, alt %d, rec%s\");",
v4,
*a1,
(unsigned int)(a2 + 1),
v5);
}

original_code:
static void generate_qstack_mcheck (meta_rule mrule, int i, int body)
 { char *indent = (body)?"":"     ";
   code_line ("\t   %sif (lqptr != qptr)", indent);
   code_line ("\t   %s   panic (\"qstack inconsistency detected in metarule %s, alt %d, rec%s\");",
  indent, mrule -> nonterminal, i+1, (body)?"body":"");
 }

canonical_original_code:
static void generate_qstack_mcheck(struct meta_rule_rec *mrule, int i, int body)
 { char *indent = (body)?"":"     ";
   code_line ("\t   %sif (lqptr != qptr)", indent);
   code_line ("\t   %s   panic (\"qstack inconsistency detected in metarule %s, alt %d, rec%s\");",
  indent, mrule -> nonterminal, i+1, (body)?"body":"");
 }

variable_types: i int

variable_types: body int

variable_types:
indent
char *

user_defined_types: struct affix_list_rec { int size; int room; struct affix_rec **array; }

user_defined_types: struct variable_rec { char *nonterminal; char *suffix; struct meta_rule_rec *def; }

user_defined_types: struct cset_rec { int kind; char *str; }

user_defined_types: struct value_list_rec { int size; int room; struct value_rec **array; }

user_defined_types: struct int_list_rec { int size; int room; int *array; }

user_defined_types: struct element_def_list_rec { int size; int room; struct element_def_rec **array; }


decompiled_code:
void __fastcall generate_creator_rule(const char **a1)
{
unsigned int v1; // eax

if ( !*((_DWORD *)a1 + 4) && *((_DWORD *)a1 + 12) )
{
reset_temporaries();
code_line("static affix_node make_%s_affix ()", *a1);
if ( a1[5] )
{
code_line("\t{");
v1 = generate_temp_value(a1[5], 0LL);
code_line("\t return (value_to_affix (\"meta_%s\", v%d));", *a1, v1);
}
else
{
code_line("\t{ affix_node new = new_affix_node (\"meta_%s\");", *a1);
code_line("\t new -> mfunc = rec_%s_value;", *a1);
code_line("\t return (new);");
}
code_line("\t};\n");
}
}

canonical_decompiled_code:
void __fastcall func3(const char **a1)
{
unsigned int v1; // eax

if ( !*((_DWORD *)a1 + 4) && *((_DWORD *)a1 + 12) )
{
reset_temporaries();
code_line("static affix_node make_%s_affix ()", *a1);
if ( a1[5] )
{
code_line("\t{");
v1 = generate_temp_value(a1[5], 0LL);
code_line("\t return (value_to_affix (\"meta_%s\", v%d));", *a1, v1);
}
else
{
code_line("\t{ affix_node new = new_affix_node (\"meta_%s\");", *a1);
code_line("\t new -> mfunc = rec_%s_value;", *a1);
code_line("\t return (new);");
}
code_line("\t};\n");
}
}

original_code:
static void generate_creator_rule (meta_rule mrule)
 { if (mrule -> ext) return;
   if (!mrule -> reachable) return;
   reset_temporaries ();
   code_line ("static affix_node make_%s_affix ()", mrule -> nonterminal);
   if (mrule -> mvalue != ((value) ((void *)0)))
      { int valnr;
        code_line ("\t{");
        valnr = generate_temp_value (mrule -> mvalue, 0);
        code_line ("\t  return (value_to_affix (\"meta_%s\", v%d));",
     mrule -> nonterminal, valnr);
        code_line ("\t};\n");
        return;
      };
   code_line ("\t{ affix_node new = new_affix_node (\"meta_%s\");",
     mrule -> nonterminal);
   code_line ("\t  new -> mfunc = rec_%s_value;", mrule -> nonterminal);
   code_line ("\t  return (new);");
   code_line ("\t};\n");
 }

canonical_original_code:
static void generate_creator_rule(struct meta_rule_rec *mrule)
 { if (mrule -> ext) return;
   if (!mrule -> reachable) return;
   reset_temporaries ();
   code_line ("static affix_node make_%s_affix ()", mrule -> nonterminal);
   if (mrule -> mvalue != ((value) ((void *)0)))
      { int valnr;
        code_line ("\t{");
        valnr = generate_temp_value (mrule -> mvalue, 0);
        code_line ("\t  return (value_to_affix (\"meta_%s\", v%d));",
     mrule -> nonterminal, valnr);
        code_line ("\t};\n");
        return;
      };
   code_line ("\t{ affix_node new = new_affix_node (\"meta_%s\");",
     mrule -> nonterminal);
   code_line ("\t  new -> mfunc = rec_%s_value;", mrule -> nonterminal);
   code_line ("\t  return (new);");
   code_line ("\t};\n");
 }

variable_types: valnr int


decompiled_code:
void generate_creator_rules()
{
__int64 v0; // rbx

if ( nr_of_meta_rules > 0 )
{
v0 = 0LL;
do
generate_creator_rule(*(const char ***)(all_meta_rules + 8 * v0++));
while ( nr_of_meta_rules > (int)v0 );
}
}

canonical_decompiled_code:
void func4()
{
__int64 v0; // rbx

if ( nr_of_meta_rules > 0 )
{
v0 = 0LL;
do
func3(*(const char ***)(all_meta_rules + 8 * v0++));
while ( nr_of_meta_rules > (int)v0 );
}
}

original_code:
static void generate_creator_rules ()
 { int ix;
   for (ix = 0; ix < nr_of_meta_rules; ix++)
      generate_creator_rule (all_meta_rules[ix]);
 }

canonical_original_code:
static void generate_creator_rules()
 { int ix;
   for (ix = 0; ix < nr_of_meta_rules; ix++)
      generate_creator_rule (all_meta_rules[ix]);
 }


decompiled_code:
__int64 __fastcall generate_rec_affix(__int64 a1, const char *a2, _DWORD *a3)
{
__int64 result; // rax

code_line("\t\tpushv (%s);", a2);
switch ( *(_DWORD *)(a1 + 40) )
{
case 0:
result = code_line("\t\tpushq (rec_%s_value);", **(const char ***)(a1 + 64));
*a3 += 2;
break;
case 1:
code_string("\t\tpushs (");
output_string(out, *(_QWORD *)(a1 + 48));
code_line(");");
result = code_line("\t\tpushq (rec_parse_terminal);");
*a3 += 3;
break;
case 2:
code_line("\t\tpushi (%d);", *(unsigned int *)(a1 + 48));
result = code_line("\t\tpushq (rec_parse_number);");
*a3 += 3;
break;
case 3:
code_line("\t\tpushr (%g);", *(double *)(a1 + 48));
result = code_line("\t\tpushq (rec_parse_real);");
*a3 += 3;
break;
case 4:
code_string("\t\tpushs (");
output_string(out, *(_QWORD *)(*(_QWORD *)(a1 + 48) + 8LL));
code_line(");");
code_string("\t\tpushq (rec_parse");
if ( (**(_BYTE **)(a1 + 48) & 8) != 0 )
code_string("_non");
code_string("_set");
if ( (**(_BYTE **)(a1 + 48) & 4) != 0 )
code_string("_star");
if ( (**(_BYTE **)(a1 + 48) & 2) != 0 )
code_string("_plus");
if ( (**(_BYTE **)(a1 + 48) & 1) != 0 )
code_string("_strict");
result = code_line(");");
*a3 += 3;
break;
case 5:
case 6:
internal_error("generate_rec_affix");
goto LABEL_16;
default:
LABEL_16:
result = bad_tag(*(unsigned int *)(a1 + 40), "generate_rec_affix");
break;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1, const char *a2, _DWORD *a3)
{
__int64 result; // rax

code_line("\t\tpushv (%s);", a2);
switch ( *(_DWORD *)(a1 + 40) )
{
case 0:
result = code_line("\t\tpushq (rec_%s_value);", **(const char ***)(a1 + 64));
*a3 += 2;
break;
case 1:
code_string("\t\tpushs (");
output_string(out, *(_QWORD *)(a1 + 48));
code_line(");");
result = code_line("\t\tpushq (rec_parse_terminal);");
*a3 += 3;
break;
case 2:
code_line("\t\tpushi (%d);", *(unsigned int *)(a1 + 48));
result = code_line("\t\tpushq (rec_parse_number);");
*a3 += 3;
break;
case 3:
code_line("\t\tpushr (%g);", *(double *)(a1 + 48));
result = code_line("\t\tpushq (rec_parse_real);");
*a3 += 3;
break;
case 4:
code_string("\t\tpushs (");
output_string(out, *(_QWORD *)(*(_QWORD *)(a1 + 48) + 8LL));
code_line(");");
code_string("\t\tpushq (rec_parse");
if ( (**(_BYTE **)(a1 + 48) & 8) != 0 )
code_string("_non");
code_string("_set");
if ( (**(_BYTE **)(a1 + 48) & 4) != 0 )
code_string("_star");
if ( (**(_BYTE **)(a1 + 48) & 2) != 0 )
code_string("_plus");
if ( (**(_BYTE **)(a1 + 48) & 1) != 0 )
code_string("_strict");
result = code_line(");");
*a3 += 3;
break;
case 5:
case 6:
internal_error("generate_rec_affix");
goto LABEL_16;
default:
LABEL_16:
result = bad_tag(*(unsigned int *)(a1 + 40), "generate_rec_affix");
break;
}
return result;
}

original_code:
static void generate_rec_affix (affix a, char *name, int *nrpushes)
 { code_line ("\t\tpushv (%s);", name);
   switch (a -> tag)
      { case 0:
    { meta_rule def = a -> u.var.def;
      code_line ("\t\tpushq (rec_%s_value);", def -> nonterminal);
      *nrpushes += 2;
    };
    break;
        case 1:
    { code_string ("\t\tpushs (");
      output_string (out, a -> u.str);
      code_line (");");
      code_line ("\t\tpushq (rec_parse_terminal);");
      *nrpushes += 3;
    };
    break;
        case 2:
    { code_line ("\t\tpushi (%d);", a -> u.inum);
      code_line ("\t\tpushq (rec_parse_number);");
      *nrpushes += 3;
    };
    break;
        case 3:
    { code_line ("\t\tpushr (%g);", a -> u.rnum);
      code_line ("\t\tpushq (rec_parse_real);");
      *nrpushes += 3;
    };
    break;
        case 4:
    { code_string ("\t\tpushs (");
      output_string (out, a -> u.semi -> str);
      code_line (");");
      code_string ("\t\tpushq (rec_parse");
      if (a -> u.semi -> kind & 8) code_string ("_non");
      code_string ("_set");
      if (a -> u.semi -> kind & 4) code_string ("_star");
      if (a -> u.semi -> kind & 2) code_string ("_plus");
      if (a -> u.semi -> kind & 1) code_string ("_strict");
      code_line (");");
      *nrpushes += 3;
    }; break;
        case 5:
        case 6:
    internal_error ("generate_rec_affix");
        default: bad_tag (a -> tag, "generate_rec_affix");
      };
 }

canonical_original_code:
static void generate_rec_affix(struct affix_rec *a, char *name, int *nrpushes)
 { code_line ("\t\tpushv (%s);", name);
   switch (a -> tag)
      { case 0:
    { struct meta_rule_rec *def = a -> u.var.def;
      code_line ("\t\tpushq (rec_%s_value);", def -> nonterminal);
      *nrpushes += 2;
    };
    break;
        case 1:
    { code_string ("\t\tpushs (");
      output_string (out, a -> u.str);
      code_line (");");
      code_line ("\t\tpushq (rec_parse_terminal);");
      *nrpushes += 3;
    };
    break;
        case 2:
    { code_line ("\t\tpushi (%d);", a -> u.inum);
      code_line ("\t\tpushq (rec_parse_number);");
      *nrpushes += 3;
    };
    break;
        case 3:
    { code_line ("\t\tpushr (%g);", a -> u.rnum);
      code_line ("\t\tpushq (rec_parse_real);");
      *nrpushes += 3;
    };
    break;
        case 4:
    { code_string ("\t\tpushs (");
      output_string (out, a -> u.semi -> str);
      code_line (");");
      code_string ("\t\tpushq (rec_parse");
      if (a -> u.semi -> kind & 8) code_string ("_non");
      code_string ("_set");
      if (a -> u.semi -> kind & 4) code_string ("_star");
      if (a -> u.semi -> kind & 2) code_string ("_plus");
      if (a -> u.semi -> kind & 1) code_string ("_strict");
      code_line (");");
      *nrpushes += 3;
    }; break;
        case 5:
        case 6:
    internal_error ("generate_rec_affix");
        default: bad_tag (a -> tag, "generate_rec_affix");
      };
 }

variable_types: struct affix_rec { char *name; int type; struct affix_rec *next; struct value_rec { int admin_nr; int ref_count; void *dptr; int tag; union { char *str; int inum; double rnum; struct value_list_rec { int size; int room; struct value_rec **array; } *tuple; int slat; struct int_list_rec { int size; int room; int *array; } *elat; struct value_rec *free; } u; } *val; int ref_count; int reachable; int tag; union { struct variable_rec { char *nonterminal; char *suffix; struct meta_rule_rec { char *nonterminal; struct meta_alt_list_rec { int size; int room; struct meta_alt_rec { struct expr_rec { int tag; union { struct affix_rec *single; struct affix_list_rec { int size; int room; struct affix_rec **array; } *compos; struct affix_list_rec *concat; struct affix_list_rec *uni; } u; } *e; int number; } **array; } *alts; int ext; int type; int kind; int empty; int number; struct value_rec *mvalue; int reachable; struct element_def_rec { char *eltnm; int number; int eltnr; struct element_set_rec { int number; struct element_def_list_rec { int size; int room; struct element_def_rec **array; } *defs; } *set; } *lat_repr; int needs_rec; int needs_recbup; } *def; } var; char *str; int inum; double rnum; struct cset_rec { int kind; char *str; } *semi; struct element_rec { char *eltnm; struct element_def_rec *def; } elt; struct expr_rec *cexpr; } u; } *

variable_types:
name
char *

variable_types:
nrpushes
int *


decompiled_code:
__int64 __fastcall generate_rec_single(__int64 a1)
{
unsigned int v2[3]; // [rsp+Ch] [rbp-Ch] BYREF

v2[0] = 0;
generate_rec_affix(a1, "v", v2);
code_line("\t\tcallq ();");
return code_line("\t\tpop (%d);", v2[0]);
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1)
{
unsigned int v2[3]; // [rsp+Ch] [rbp-Ch] BYREF

v2[0] = 0;
func5(a1, "v", v2);
code_line("\t\tcallq ();");
return code_line("\t\tpop (%d);", v2[0]);
}

original_code:
static void generate_rec_single (affix a)
 { int nrpushes = 0;
   generate_rec_affix (a, "v", &nrpushes);
   code_line ("\t\tcallq ();");
   code_line ("\t\tpop (%d);", nrpushes);
 }

canonical_original_code:
static void generate_rec_single(struct affix_rec *a)
 { int nrpushes = 0;
   generate_rec_affix (a, "v", &nrpushes);
   code_line ("\t\tcallq ();");
   code_line ("\t\tpop (%d);", nrpushes);
 }

variable_types: nrpushes int


decompiled_code:
__int64 __fastcall generate_recbup_affix(__int64 a1, _DWORD *a2)
{
__int64 result; // rax
double v3; // xmm0_8

switch ( *(_DWORD *)(a1 + 40) )
{
case 0:
result = code_line("\t\tpushq (recbup_%s_value);", **(const char ***)(a1 + 64));
++*a2;
break;
case 1:
code_string("\t\tpushs (");
output_string(out, *(_QWORD *)(a1 + 48));
code_line(");");
result = code_line("\t\tpushq (recbup_parse_terminal);");
*a2 += 2;
break;
case 2:
code_line("\t\tpushi (%d);\n", *(unsigned int *)(a1 + 48));
result = code_line("\t\tpushq (recbup_parse_integer);\n");
*a2 += 2;
break;
case 3:
v3 = *(double *)(a1 + 48);
code_line("\t\tpushr (%d);\n", a2);
result = code_line("\t\tpushq (recbup_parse_real);\n", v3);
*a2 += 2;
break;
case 4:
code_string("\t\tpushs (");
output_string(out, *(_QWORD *)(*(_QWORD *)(a1 + 48) + 8LL));
code_line(");");
code_string("\t\tpushq (recbup_parse");
if ( (**(_BYTE **)(a1 + 48) & 8) != 0 )
code_string("_non");
code_string("_set");
if ( (**(_BYTE **)(a1 + 48) & 4) != 0 )
code_string("_star");
if ( (**(_BYTE **)(a1 + 48) & 2) != 0 )
code_string("_plus");
if ( (**(_BYTE **)(a1 + 48) & 1) != 0 )
code_string("_strict");
result = code_line(");\n");
*a2 += 2;
break;
case 5:
case 6:
internal_error("generate_recbup_affix");
goto LABEL_16;
default:
LABEL_16:
result = bad_tag(*(unsigned int *)(a1 + 40), "generate_recbup_affix");
break;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1, _DWORD *a2)
{
__int64 result; // rax
double v3; // xmm0_8

switch ( *(_DWORD *)(a1 + 40) )
{
case 0:
result = code_line("\t\tpushq (recbup_%s_value);", **(const char ***)(a1 + 64));
++*a2;
break;
case 1:
code_string("\t\tpushs (");
output_string(out, *(_QWORD *)(a1 + 48));
code_line(");");
result = code_line("\t\tpushq (recbup_parse_terminal);");
*a2 += 2;
break;
case 2:
code_line("\t\tpushi (%d);\n", *(unsigned int *)(a1 + 48));
result = code_line("\t\tpushq (recbup_parse_integer);\n");
*a2 += 2;
break;
case 3:
v3 = *(double *)(a1 + 48);
code_line("\t\tpushr (%d);\n", a2);
result = code_line("\t\tpushq (recbup_parse_real);\n", v3);
*a2 += 2;
break;
case 4:
code_string("\t\tpushs (");
output_string(out, *(_QWORD *)(*(_QWORD *)(a1 + 48) + 8LL));
code_line(");");
code_string("\t\tpushq (recbup_parse");
if ( (**(_BYTE **)(a1 + 48) & 8) != 0 )
code_string("_non");
code_string("_set");
if ( (**(_BYTE **)(a1 + 48) & 4) != 0 )
code_string("_star");
if ( (**(_BYTE **)(a1 + 48) & 2) != 0 )
code_string("_plus");
if ( (**(_BYTE **)(a1 + 48) & 1) != 0 )
code_string("_strict");
result = code_line(");\n");
*a2 += 2;
break;
case 5:
case 6:
internal_error("generate_recbup_affix");
goto LABEL_16;
default:
LABEL_16:
result = bad_tag(*(unsigned int *)(a1 + 40), "generate_recbup_affix");
break;
}
return result;
}

original_code:
static void generate_recbup_affix (affix a, int *nrpushes)
 { switch (a -> tag)
      { case 0:
    { meta_rule def = a -> u.var.def;
      code_line ("\t\tpushq (recbup_%s_value);",
          def -> nonterminal);
      *nrpushes += 1;
    };
    break;
        case 1:
    { code_string ("\t\tpushs (");
      output_string (out, a -> u.str);
      code_line (");");
      code_line ("\t\tpushq (recbup_parse_terminal);");
      *nrpushes += 2;
    };
    break;
        case 2:
    { code_line ("\t\tpushi (%d);\n", a -> u.inum);
      code_line ("\t\tpushq (recbup_parse_integer);\n");
      *nrpushes += 2;
    };
    break;
        case 3:
    { code_line ("\t\tpushr (%d);\n", a -> u.rnum);
      code_line ("\t\tpushq (recbup_parse_real);\n");
      *nrpushes += 2;
    };
    break;
        case 4:
    { code_string ("\t\tpushs (");
      output_string (out, a -> u.semi -> str);
      code_line (");");
      code_string ("\t\tpushq (recbup_parse");
      if (a -> u.semi -> kind & 8) code_string ("_non");
      code_string ("_set");
      if (a -> u.semi -> kind & 4) code_string ("_star");
      if (a -> u.semi -> kind & 2) code_string ("_plus");
      if (a -> u.semi -> kind & 1) code_string ("_strict");
      code_line (");\n");
      *nrpushes += 2;
    };
    break;
        case 5:
        case 6:
    internal_error ("generate_recbup_affix");
        default: bad_tag (a -> tag, "generate_recbup_affix");
      };
 }

canonical_original_code:
static void generate_recbup_affix(struct affix_rec *a, int *nrpushes)
 { switch (a -> tag)
      { case 0:
    { struct meta_rule_rec *def = a -> u.var.def;
      code_line ("\t\tpushq (recbup_%s_value);",
          def -> nonterminal);
      *nrpushes += 1;
    };
    break;
        case 1:
    { code_string ("\t\tpushs (");
      output_string (out, a -> u.str);
      code_line (");");
      code_line ("\t\tpushq (recbup_parse_terminal);");
      *nrpushes += 2;
    };
    break;
        case 2:
    { code_line ("\t\tpushi (%d);\n", a -> u.inum);
      code_line ("\t\tpushq (recbup_parse_integer);\n");
      *nrpushes += 2;
    };
    break;
        case 3:
    { code_line ("\t\tpushr (%d);\n", a -> u.rnum);
      code_line ("\t\tpushq (recbup_parse_real);\n");
      *nrpushes += 2;
    };
    break;
        case 4:
    { code_string ("\t\tpushs (");
      output_string (out, a -> u.semi -> str);
      code_line (");");
      code_string ("\t\tpushq (recbup_parse");
      if (a -> u.semi -> kind & 8) code_string ("_non");
      code_string ("_set");
      if (a -> u.semi -> kind & 4) code_string ("_star");
      if (a -> u.semi -> kind & 2) code_string ("_plus");
      if (a -> u.semi -> kind & 1) code_string ("_strict");
      code_line (");\n");
      *nrpushes += 2;
    };
    break;
        case 5:
        case 6:
    internal_error ("generate_recbup_affix");
        default: bad_tag (a -> tag, "generate_recbup_affix");
      };
 }


decompiled_code:
__int64 __fastcall generate_recbup_concat(unsigned int *a1, _DWORD *a2)
{
__int64 result; // rax
__int64 v3; // rbx
unsigned __int64 v4; // r13

result = *a1;
if ( (int)(*a1 - 1) >= 0 )
{
v3 = 8LL * (int)(*a1 - 1);
v4 = 8 * ((int)result - (unsigned __int64)(unsigned int)(result - 1)) - 16;
do
{
result = generate_recbup_affix(*(_QWORD *)(*((_QWORD *)a1 + 1) + v3), a2);
v3 -= 8LL;
}
while ( v3 != v4 );
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func9(unsigned int *a1, _DWORD *a2)
{
__int64 result; // rax
__int64 v3; // rbx
unsigned __int64 v4; // r13

result = *a1;
if ( (int)(*a1 - 1) >= 0 )
{
v3 = 8LL * (int)(*a1 - 1);
v4 = 8 * ((int)result - (unsigned __int64)(unsigned int)(result - 1)) - 16;
do
{
result = func7(*(_QWORD *)(*((_QWORD *)a1 + 1) + v3), a2);
v3 -= 8LL;
}
while ( v3 != v4 );
}
return result;
}

original_code:
static void generate_recbup_concat (affix_list affs, int *nrpushes)
 { int ix;
   for (ix = affs -> size - 1; 0 <= ix; ix--)
      generate_recbup_affix (affs -> array[ix], nrpushes);
 }

canonical_original_code:
static void generate_recbup_concat(struct affix_list_rec *affs, int *nrpushes)
 { int ix;
   for (ix = affs -> size - 1; 0 <= ix; ix--)
      generate_recbup_affix (affs -> array[ix], nrpushes);
 }

variable_types: struct affix_list_rec { int size; int room; struct affix_rec { char *name; int type; struct affix_rec *next; struct value_rec { int admin_nr; int ref_count; void *dptr; int tag; union { char *str; int inum; double rnum; struct value_list_rec { int size; int room; struct value_rec **array; } *tuple; int slat; struct int_list_rec { int size; int room; int *array; } *elat; struct value_rec *free; } u; } *val; int ref_count; int reachable; int tag; union { struct variable_rec { char *nonterminal; char *suffix; struct meta_rule_rec { char *nonterminal; struct meta_alt_list_rec { int size; int room; struct meta_alt_rec { struct expr_rec { int tag; union { struct affix_rec *single; struct affix_list_rec *compos; struct affix_list_rec *concat; struct affix_list_rec *uni; } u; } *e; int number; } **array; } *alts; int ext; int type; int kind; int empty; int number; struct value_rec *mvalue; int reachable; struct element_def_rec { char *eltnm; int number; int eltnr; struct element_set_rec { int number; struct element_def_list_rec { int size; int room; struct element_def_rec **array; } *defs; } *set; } *lat_repr; int needs_rec; int needs_recbup; } *def; } var; char *str; int inum; double rnum; struct cset_rec { int kind; char *str; } *semi; struct element_rec { char *eltnm; struct element_def_rec *def; } elt; struct expr_rec *cexpr; } u; } **array; } *


decompiled_code:
void __fastcall generate_parser_expr(unsigned int *a1, _DWORD *a2)
{
int v2; // eax

if ( a1 )
{
v2 = *a1;
if ( *a1 == 3 )
{
generate_recbup_concat(*((unsigned int **)a1 + 1), a2);
}
else
{
if ( v2 > 3 )
{
if ( v2 != 4 )
goto LABEL_8;
goto LABEL_6;
}
if ( v2 != 1 )
{
if ( v2 != 2 )
{
LABEL_8:
bad_tag(*a1, "generate_parser_expr");
return;
}
LABEL_6:
internal_error("generate_parser_expr");
goto LABEL_8;
}
generate_recbup_affix(*((_QWORD *)a1 + 1), a2);
}
}
}

canonical_decompiled_code:
void __fastcall func10(unsigned int *a1, _DWORD *a2)
{
int v2; // eax

if ( a1 )
{
v2 = *a1;
if ( *a1 == 3 )
{
func9(*((unsigned int **)a1 + 1), a2);
}
else
{
if ( v2 > 3 )
{
if ( v2 != 4 )
goto LABEL_8;
goto LABEL_6;
}
if ( v2 != 1 )
{
if ( v2 != 2 )
{
LABEL_8:
bad_tag(*a1, "generate_parser_expr");
return;
}
LABEL_6:
internal_error("generate_parser_expr");
goto LABEL_8;
}
func7(*((_QWORD *)a1 + 1), a2);
}
}
}

original_code:
static void generate_parser_expr (expr e, int *nrpushes)
 { if (e == ((expr) ((void *)0))) return;
   switch (e -> tag)
      { case 1:
    generate_recbup_affix (e -> u.single, nrpushes);
    break;
        case 3:
    generate_recbup_concat (e -> u.concat, nrpushes);
    break;
        case 2:
        case 4: internal_error ("generate_parser_expr");
        default: bad_tag (e -> tag, "generate_parser_expr");
      };
 }

canonical_original_code:
static void generate_parser_expr(struct expr_rec *e, int *nrpushes)
 { if (e == ((expr) ((void *)0))) return;
   switch (e -> tag)
      { case 1:
    generate_recbup_affix (e -> u.single, nrpushes);
    break;
        case 3:
    generate_recbup_concat (e -> u.concat, nrpushes);
    break;
        case 2:
        case 4: internal_error ("generate_parser_expr");
        default: bad_tag (e -> tag, "generate_parser_expr");
      };
 }

variable_types: struct expr_rec { int tag; union { struct affix_rec { char *name; int type; struct affix_rec *next; struct value_rec { int admin_nr; int ref_count; void *dptr; int tag; union { char *str; int inum; double rnum; struct value_list_rec { int size; int room; struct value_rec **array; } *tuple; int slat; struct int_list_rec { int size; int room; int *array; } *elat; struct value_rec *free; } u; } *val; int ref_count; int reachable; int tag; union { struct variable_rec { char *nonterminal; char *suffix; struct meta_rule_rec { char *nonterminal; struct meta_alt_list_rec { int size; int room; struct meta_alt_rec { struct expr_rec *e; int number; } **array; } *alts; int ext; int type; int kind; int empty; int number; struct value_rec *mvalue; int reachable; struct element_def_rec { char *eltnm; int number; int eltnr; struct element_set_rec { int number; struct element_def_list_rec { int size; int room; struct element_def_rec **array; } *defs; } *set; } *lat_repr; int needs_rec; int needs_recbup; } *def; } var; char *str; int inum; double rnum; struct cset_rec { int kind; char *str; } *semi; struct element_rec { char *eltnm; struct element_def_rec *def; } elt; struct expr_rec *cexpr; } u; } *single; struct affix_list_rec { int size; int room; struct affix_rec **array; } *compos; struct affix_list_rec *concat; struct affix_list_rec *uni; } u; } *


decompiled_code:
__int64 __fastcall generate_parser_alt(const char **a1, int a2, unsigned int *a3)
{
unsigned int v5[7]; // [rsp+Ch] [rbp-1Ch] BYREF

v5[0] = 0;
if ( qstackflag )
code_line("\t { cont *lqptr = qptr;");
else
code_line("\t {");
generate_parser_expr(a3, v5);
code_line("\t callq ();");
code_line("\t pop (%d);", v5[0]);
if ( qstackflag )
generate_qstack_mcheck(a1, a2, 1);
return code_line("\t };");
}

canonical_decompiled_code:
__int64 __fastcall func11(const char **a1, int a2, unsigned int *a3)
{
unsigned int v5[7]; // [rsp+Ch] [rbp-1Ch] BYREF

v5[0] = 0;
if ( qstackflag )
code_line("\t { cont *lqptr = qptr;");
else
code_line("\t {");
func10(a3, v5);
code_line("\t callq ();");
code_line("\t pop (%d);", v5[0]);
if ( qstackflag )
func2(a1, a2, 1);
return code_line("\t };");
}

original_code:
static void generate_parser_alt (meta_rule mrule, int i, expr e)
 { int nrpushes = 0;
   if (qstackflag) code_line ("\t { cont *lqptr = qptr;");
   else code_line ("\t {");
   generate_parser_expr (e, &nrpushes);
   code_line ("\t   callq ();");
   code_line ("\t   pop (%d);", nrpushes);
   if (qstackflag) generate_qstack_mcheck (mrule, i, 1);
   code_line ("\t };");
 }

canonical_original_code:
static void generate_parser_alt(struct meta_rule_rec *mrule, int i, struct expr_rec *e)
 { int nrpushes = 0;
   if (qstackflag) code_line ("\t { cont *lqptr = qptr;");
   else code_line ("\t {");
   generate_parser_expr (e, &nrpushes);
   code_line ("\t   callq ();");
   code_line ("\t   pop (%d);", nrpushes);
   if (qstackflag) generate_qstack_mcheck (mrule, i, 1);
   code_line ("\t };");
 }

variable_types:
e
struct expr_rec *


decompiled_code:
__int64 __fastcall generate_parser_alts(__int64 a1)
{
__int64 v1; // rbp
__int64 v2; // rbx
__int64 result; // rax

v1 = *(_QWORD *)(a1 + 8);
if ( *(int *)v1 > 0 )
{
v2 = 0LL;
do
{
result = generate_parser_alt((const char **)a1, v2, **(unsigned int ***)(*(_QWORD *)(v1 + 8) + 8 * v2));
++v2;
}
while ( *(_DWORD *)v1 > (int)v2 );
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func12(__int64 a1)
{
__int64 v1; // rbp
__int64 v2; // rbx
__int64 result; // rax

v1 = *(_QWORD *)(a1 + 8);
if ( *(int *)v1 > 0 )
{
v2 = 0LL;
do
{
result = func11((const char **)a1, v2, **(unsigned int ***)(*(_QWORD *)(v1 + 8) + 8 * v2));
++v2;
}
while ( *(_DWORD *)v1 > (int)v2 );
}
return result;
}

original_code:
static void generate_parser_alts (meta_rule mrule)
 { int ix;
   meta_alt_list alts = mrule -> alts;
   for (ix = 0; ix < alts -> size; ix++)
      generate_parser_alt (mrule, ix, alts -> array[ix] -> e);
 }

canonical_original_code:
static void generate_parser_alts(struct meta_rule_rec *mrule)
 { int ix;
   struct meta_alt_list_rec *alts = mrule -> alts;
   for (ix = 0; ix < alts -> size; ix++)
      generate_parser_alt (mrule, ix, alts -> array[ix] -> e);
 }

variable_types: struct meta_alt_list_rec { int size; int room; struct meta_alt_rec { struct expr_rec { int tag; union { struct affix_rec { char *name; int type; struct affix_rec *next; struct value_rec { int admin_nr; int ref_count; void *dptr; int tag; union { char *str; int inum; double rnum; struct value_list_rec { int size; int room; struct value_rec **array; } *tuple; int slat; struct int_list_rec { int size; int room; int *array; } *elat; struct value_rec *free; } u; } *val; int ref_count; int reachable; int tag; union { struct variable_rec { char *nonterminal; char *suffix; struct meta_rule_rec { char *nonterminal; struct meta_alt_list_rec *alts; int ext; int type; int kind; int empty; int number; struct value_rec *mvalue; int reachable; struct element_def_rec { char *eltnm; int number; int eltnr; struct element_set_rec { int number; struct element_def_list_rec { int size; int room; struct element_def_rec **array; } *defs; } *set; } *lat_repr; int needs_rec; int needs_recbup; } *def; } var; char *str; int inum; double rnum; struct cset_rec { int kind; char *str; } *semi; struct element_rec { char *eltnm; struct element_def_rec *def; } elt; struct expr_rec *cexpr; } u; } *single; struct affix_list_rec { int size; int room; struct affix_rec **array; } *compos; struct affix_list_rec *concat; struct affix_list_rec *uni; } u; } *e; int number; } **array; } *


decompiled_code:
__int64 __fastcall generate_parser_rule(const char **a1)
{
__int64 result; // rax

if ( !*((_DWORD *)a1 + 4) && *((_DWORD *)a1 + 12) )
{
if ( *((_DWORD *)a1 + 17) )
{
code_line("static void recbup_%s_value ()", *a1);
code_line("\t{");
generate_parser_alts((__int64)a1);
code_line("\t pushq (recbup_%s_value);", *a1);
result = code_line("\t};\n");
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func13(const char **a1)
{
__int64 result; // rax

if ( !*((_DWORD *)a1 + 4) && *((_DWORD *)a1 + 12) )
{
if ( *((_DWORD *)a1 + 17) )
{
code_line("static void recbup_%s_value ()", *a1);
code_line("\t{");
func12((__int64)a1);
code_line("\t pushq (recbup_%s_value);", *a1);
result = code_line("\t};\n");
}
}
return result;
}

original_code:
static void generate_parser_rule (meta_rule mrule)
 { if (mrule -> ext) return;
   if (!mrule -> reachable) return;
   if (!mrule -> needs_recbup) return;
   code_line ("static void recbup_%s_value ()", mrule -> nonterminal);
   code_line ("\t{");
   generate_parser_alts (mrule);
   code_line ("\t  pushq (recbup_%s_value);", mrule -> nonterminal);
   code_line ("\t};\n");
 }

canonical_original_code:
static void generate_parser_rule(struct meta_rule_rec *mrule)
 { if (mrule -> ext) return;
   if (!mrule -> reachable) return;
   if (!mrule -> needs_recbup) return;
   code_line ("static void recbup_%s_value ()", mrule -> nonterminal);
   code_line ("\t{");
   generate_parser_alts (mrule);
   code_line ("\t  pushq (recbup_%s_value);", mrule -> nonterminal);
   code_line ("\t};\n");
 }


decompiled_code:
__int64 generate_parser_rules()
{
__int64 v0; // rbx
__int64 result; // rax

if ( nr_of_meta_rules > 0 )
{
v0 = 0LL;
do
result = generate_parser_rule(*(const char ***)(all_meta_rules + 8 * v0++));
while ( nr_of_meta_rules > (int)v0 );
}
return result;
}

canonical_decompiled_code:
__int64 func14()
{
__int64 v0; // rbx
__int64 result; // rax

if ( nr_of_meta_rules > 0 )
{
v0 = 0LL;
do
result = func13(*(const char ***)(all_meta_rules + 8 * v0++));
while ( nr_of_meta_rules > (int)v0 );
}
return result;
}

original_code:
static void generate_parser_rules ()
 { int ix;
   for (ix = 0; ix < nr_of_meta_rules; ix++)
      generate_parser_rule (all_meta_rules[ix]);
 }

canonical_original_code:
static void generate_parser_rules()
 { int ix;
   for (ix = 0; ix < nr_of_meta_rules; ix++)
      generate_parser_rule (all_meta_rules[ix]);
 }


decompiled_code:
__int64 __fastcall generate_rec_compos(unsigned int *a1)
{
int v1; // ebx
__int64 v2; // rbp
unsigned int v4; // [rsp+Ch] [rbp-4Ch] BYREF
char s[72]; // [rsp+10h] [rbp-48h] BYREF

v4 = 0;
code_line("\t\tif (v -> u.tuple -> size == %d)", *a1);
code_line("\t\t {");
v1 = *a1 - 1;
if ( v1 >= 0 )
{
v2 = 8LL * v1;
do
{
sprintf(s, "v -> u.tuple -> array[%d]", (unsigned int)v1);
generate_rec_affix(*(_QWORD *)(*((_QWORD *)a1 + 1) + v2), s, &v4);
--v1;
v2 -= 8LL;
}
while ( v1 != -1 );
}
code_line("\t\t callq ();");
code_line("\t\t pop (%d);", v4);
return code_line("\t\t };");
}

canonical_decompiled_code:
__int64 __fastcall func15(unsigned int *a1)
{
int v1; // ebx
__int64 v2; // rbp
unsigned int v4; // [rsp+Ch] [rbp-4Ch] BYREF
char s[72]; // [rsp+10h] [rbp-48h] BYREF

v4 = 0;
code_line("\t\tif (v -> u.tuple -> size == %d)", *a1);
code_line("\t\t {");
v1 = *a1 - 1;
if ( v1 >= 0 )
{
v2 = 8LL * v1;
do
{
sprintf(s, "v -> u.tuple -> array[%d]", (unsigned int)v1);
func5(*(_QWORD *)(*((_QWORD *)a1 + 1) + v2), s, &v4);
--v1;
v2 -= 8LL;
}
while ( v1 != -1 );
}
code_line("\t\t callq ();");
code_line("\t\t pop (%d);", v4);
return code_line("\t\t };");
}

original_code:
static void generate_rec_compos (affix_list affs)
 { char buffer[40];
   int ix;
   int nrpushes = 0;
   code_line ("\t\tif (v -> u.tuple -> size == %d)", affs -> size);
   code_line ("\t\t   {");
   for (ix = affs -> size - 1; 0 <= ix; ix--)
      { sprintf (buffer, "v -> u.tuple -> array[%d]", ix);
        generate_rec_affix (affs -> array[ix], buffer, &nrpushes);
      };
   code_line ("\t\t     callq ();");
   code_line ("\t\t     pop (%d);", nrpushes);
   code_line ("\t\t   };");
 }

canonical_original_code:
static void generate_rec_compos(struct affix_list_rec *affs)
 { char buffer[40];
   int ix;
   int nrpushes = 0;
   code_line ("\t\tif (v -> u.tuple -> size == %d)", affs -> size);
   code_line ("\t\t   {");
   for (ix = affs -> size - 1; 0 <= ix; ix--)
      { sprintf (buffer, "v -> u.tuple -> array[%d]", ix);
        generate_rec_affix (affs -> array[ix], buffer, &nrpushes);
      };
   code_line ("\t\t     callq ();");
   code_line ("\t\t     pop (%d);", nrpushes);
   code_line ("\t\t   };");
 }

variable_types:
buffer
char [40]


decompiled_code:
__int64 __fastcall generate_rec_expr(const char **a1, int a2, unsigned int *a3)
{
int v4; // eax

if ( qstackflag )
code_line("\t { cont *lqptr = qptr;");
else
code_line("\t {");
if ( !a3 )
{
code_line("\t\tpushv (v);");
code_line("\t\tpushq (rec_empty_value);");
code_line("\t\tcallq ();");
code_line("\t\tpop (2);");
goto LABEL_14;
}
v4 = *a3;
if ( *a3 == 3 )
{
generate_rec_concat((__int64)a1, *((int **)a3 + 1));
}
else
{
if ( v4 > 3 )
{
if ( v4 == 4 )
internal_error("generate_rec_expr");
LABEL_13:
bad_tag(*a3, "generate_rec_expr");
goto LABEL_14;
}
if ( v4 != 1 )
{
if ( v4 == 2 )
{
generate_rec_compos(*((unsigned int **)a3 + 1));
goto LABEL_14;
}
goto LABEL_13;
}
generate_rec_single(*((_QWORD *)a3 + 1));
}
LABEL_14:
if ( qstackflag )
generate_qstack_mcheck(a1, a2, 0);
return code_line("\t };");
}

canonical_decompiled_code:
__int64 __fastcall func16(const char **a1, int a2, unsigned int *a3)
{
int v4; // eax

if ( qstackflag )
code_line("\t { cont *lqptr = qptr;");
else
code_line("\t {");
if ( !a3 )
{
code_line("\t\tpushv (v);");
code_line("\t\tpushq (rec_empty_value);");
code_line("\t\tcallq ();");
code_line("\t\tpop (2);");
goto LABEL_14;
}
v4 = *a3;
if ( *a3 == 3 )
{
func8((__int64)a1, *((int **)a3 + 1));
}
else
{
if ( v4 > 3 )
{
if ( v4 == 4 )
internal_error("generate_rec_expr");
LABEL_13:
bad_tag(*a3, "generate_rec_expr");
goto LABEL_14;
}
if ( v4 != 1 )
{
if ( v4 == 2 )
{
func15(*((unsigned int **)a3 + 1));
goto LABEL_14;
}
goto LABEL_13;
}
func6(*((_QWORD *)a3 + 1));
}
LABEL_14:
if ( qstackflag )
func2(a1, a2, 0);
return code_line("\t };");
}

original_code:
static void generate_rec_expr (meta_rule mrule, int i, expr e)
 { if (qstackflag) code_line ("\t      { cont *lqptr = qptr;");
   else code_line ("\t      {");
   if (e == ((expr) ((void *)0)))
      { code_line ("\t\tpushv (v);");
        code_line ("\t\tpushq (rec_empty_value);");
        code_line ("\t\tcallq ();");
        code_line ("\t\tpop (2);");
      }
   else
      switch (e -> tag)
         { case 1: generate_rec_single (e -> u.single); break;
           case 2: generate_rec_compos (e -> u.compos); break;
           case 3: generate_rec_concat (mrule, e -> u.concat);
       break;
    case 4: internal_error ("generate_rec_expr");
    default: bad_tag (e -> tag, "generate_rec_expr");
         };
   if (qstackflag) generate_qstack_mcheck (mrule, i, 0);
   code_line ("\t      };");
 }

canonical_original_code:
static void generate_rec_expr(struct meta_rule_rec *mrule, int i, struct expr_rec *e)
 { if (qstackflag) code_line ("\t      { cont *lqptr = qptr;");
   else code_line ("\t      {");
   if (e == ((expr) ((void *)0)))
      { code_line ("\t\tpushv (v);");
        code_line ("\t\tpushq (rec_empty_value);");
        code_line ("\t\tcallq ();");
        code_line ("\t\tpop (2);");
      }
   else
      switch (e -> tag)
         { case 1: generate_rec_single (e -> u.single); break;
           case 2: generate_rec_compos (e -> u.compos); break;
           case 3: generate_rec_concat (mrule, e -> u.concat);
       break;
    case 4: internal_error ("generate_rec_expr");
    default: bad_tag (e -> tag, "generate_rec_expr");
         };
   if (qstackflag) generate_qstack_mcheck (mrule, i, 0);
   code_line ("\t      };");
 }


decompiled_code:
__int64 __fastcall generate_rec_alts(__int64 a1)
{
__int64 result; // rax
__int64 v2; // rbx

result = *(_QWORD *)(a1 + 8);
if ( *(int *)result > 0 )
{
v2 = 0LL;
do
{
generate_rec_expr((const char **)a1, v2, **(unsigned int ***)(*(_QWORD *)(result + 8) + 8 * v2));
result = *(_QWORD *)(a1 + 8);
++v2;
}
while ( *(_DWORD *)result > (int)v2 );
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func17(__int64 a1)
{
__int64 result; // rax
__int64 v2; // rbx

result = *(_QWORD *)(a1 + 8);
if ( *(int *)result > 0 )
{
v2 = 0LL;
do
{
func16((const char **)a1, v2, **(unsigned int ***)(*(_QWORD *)(result + 8) + 8 * v2));
result = *(_QWORD *)(a1 + 8);
++v2;
}
while ( *(_DWORD *)result > (int)v2 );
}
return result;
}

original_code:
static void generate_rec_alts (meta_rule mrule)
 { int ix;
   for (ix = 0; ix < mrule -> alts -> size; ix++)
      generate_rec_expr (mrule, ix, mrule -> alts -> array[ix] -> e);
 }

canonical_original_code:
static void generate_rec_alts(struct meta_rule_rec *mrule)
 { int ix;
   for (ix = 0; ix < mrule -> alts -> size; ix++)
      generate_rec_expr (mrule, ix, mrule -> alts -> array[ix] -> e);
 }


decompiled_code:
__int64 __fastcall generate_recognizer_body(__int64 a1)
{
__int64 v1; // rax
int v2; // edx

v1 = *(_QWORD *)(a1 + 40);
if ( v1 )
{
v2 = *(_DWORD *)(v1 + 16);
if ( v2 == 1 )
{
code_string("\t { if (strcmp (v -> u.str, ");
output_string(out, *(_QWORD *)(*(_QWORD *)(a1 + 40) + 24LL));
code_line(") == 0) callq ();");
return code_line("\t };");
}
if ( v2 == 2 )
{
code_line("\t { if (v -> u.inum == %d) callq ();", *(unsigned int *)(v1 + 24));
return code_line("\t };");
}
}
code_line("\t {");
generate_rec_alts(a1);
return code_line("\t };");
}

canonical_decompiled_code:
__int64 __fastcall func18(__int64 a1)
{
__int64 v1; // rax
int v2; // edx

v1 = *(_QWORD *)(a1 + 40);
if ( v1 )
{
v2 = *(_DWORD *)(v1 + 16);
if ( v2 == 1 )
{
code_string("\t { if (strcmp (v -> u.str, ");
output_string(out, *(_QWORD *)(*(_QWORD *)(a1 + 40) + 24LL));
code_line(") == 0) callq ();");
return code_line("\t };");
}
if ( v2 == 2 )
{
code_line("\t { if (v -> u.inum == %d) callq ();", *(unsigned int *)(v1 + 24));
return code_line("\t };");
}
}
code_line("\t {");
func17(a1);
return code_line("\t };");
}

original_code:
static void generate_recognizer_body (meta_rule mrule)
 { if ((mrule -> mvalue != ((value) ((void *)0))) && (mrule -> mvalue -> tag == 1))
      { code_string ("\t     { if (strcmp (v -> u.str, ");
        output_string (out, mrule -> mvalue -> u.str);
        code_line (") == 0) callq ();");
      }
   else if ((mrule -> mvalue != ((value) ((void *)0))) && (mrule -> mvalue -> tag == 2))
      code_line ("\t     { if (v -> u.inum == %d) callq ();", mrule -> mvalue -> u.inum);
   else
      { code_line ("\t     {");
        generate_rec_alts (mrule);
      };
   code_line ("\t     };");
 }

canonical_original_code:
static void generate_recognizer_body(struct meta_rule_rec *mrule)
 { if ((mrule -> mvalue != ((value) ((void *)0))) && (mrule -> mvalue -> tag == 1))
      { code_string ("\t     { if (strcmp (v -> u.str, ");
        output_string (out, mrule -> mvalue -> u.str);
        code_line (") == 0) callq ();");
      }
   else if ((mrule -> mvalue != ((value) ((void *)0))) && (mrule -> mvalue -> tag == 2))
      code_line ("\t     { if (v -> u.inum == %d) callq ();", mrule -> mvalue -> u.inum);
   else
      { code_line ("\t     {");
        generate_rec_alts (mrule);
      };
   code_line ("\t     };");
 }


decompiled_code:
void __fastcall generate_recognizer_rule(const char **a1)
{
const char *v1; // rax

if ( !*((_DWORD *)a1 + 4) && *((_DWORD *)a1 + 12) && *((_DWORD *)a1 + 16) )
{
code_line("static void rec_%s_value ()", *a1);
code_line("\t{ value v = popv ();");
code_line("\t if (v -> tag == undefined_value) callq ();");
if ( (*((_DWORD *)a1 + 5) & 1) != 0 )
{
code_line("\t else if (v -> tag == integer_value)");
}
else
{
v1 = (const char *)string_from_type();
code_line("\t else if (v -> tag == %s_value)", v1);
}
generate_recognizer_body((__int64)a1);
code_line("\t pushv (v);");
code_line("\t pushq (rec_%s_value);", *a1);
code_line("\t};\n");
}
}

canonical_decompiled_code:
void __fastcall func19(const char **a1)
{
const char *v1; // rax

if ( !*((_DWORD *)a1 + 4) && *((_DWORD *)a1 + 12) && *((_DWORD *)a1 + 16) )
{
code_line("static void rec_%s_value ()", *a1);
code_line("\t{ value v = popv ();");
code_line("\t if (v -> tag == undefined_value) callq ();");
if ( (*((_DWORD *)a1 + 5) & 1) != 0 )
{
code_line("\t else if (v -> tag == integer_value)");
}
else
{
v1 = (const char *)string_from_type();
code_line("\t else if (v -> tag == %s_value)", v1);
}
func18((__int64)a1);
code_line("\t pushv (v);");
code_line("\t pushq (rec_%s_value);", *a1);
code_line("\t};\n");
}
}

original_code:
static void generate_recognizer_rule (meta_rule mrule)
 { if (mrule -> ext) return;
   if (!mrule -> reachable) return;
   if (!mrule -> needs_rec) return;
   code_line ("static void rec_%s_value ()", mrule -> nonterminal);
   code_line ("\t{ value v = popv ();");
   code_line ("\t  if (v -> tag == undefined_value) callq ();");
   if ((mrule -> type & 1) == 1)
        code_line ("\t  else if (v -> tag == integer_value)");
   else code_line ("\t  else if (v -> tag == %s_value)", string_from_type (mrule -> type));
   generate_recognizer_body (mrule);
   code_line ("\t  pushv (v);");
   code_line ("\t  pushq (rec_%s_value);", mrule -> nonterminal);
   code_line ("\t};\n");
 }

canonical_original_code:
static void generate_recognizer_rule(struct meta_rule_rec *mrule)
 { if (mrule -> ext) return;
   if (!mrule -> reachable) return;
   if (!mrule -> needs_rec) return;
   code_line ("static void rec_%s_value ()", mrule -> nonterminal);
   code_line ("\t{ value v = popv ();");
   code_line ("\t  if (v -> tag == undefined_value) callq ();");
   if ((mrule -> type & 1) == 1)
        code_line ("\t  else if (v -> tag == integer_value)");
   else code_line ("\t  else if (v -> tag == %s_value)", string_from_type (mrule -> type));
   generate_recognizer_body (mrule);
   code_line ("\t  pushv (v);");
   code_line ("\t  pushq (rec_%s_value);", mrule -> nonterminal);
   code_line ("\t};\n");
 }


decompiled_code:
void generate_recognizer_rules()
{
__int64 v0; // rbx

if ( nr_of_meta_rules > 0 )
{
v0 = 0LL;
do
generate_recognizer_rule(*(const char ***)(all_meta_rules + 8 * v0++));
while ( nr_of_meta_rules > (int)v0 );
}
}

canonical_decompiled_code:
void func20()
{
__int64 v0; // rbx

if ( nr_of_meta_rules > 0 )
{
v0 = 0LL;
do
func19(*(const char ***)(all_meta_rules + 8 * v0++));
while ( nr_of_meta_rules > (int)v0 );
}
}

original_code:
static void generate_recognizer_rules ()
 { int ix;
   for (ix = 0; ix < nr_of_meta_rules; ix++)
      generate_recognizer_rule (all_meta_rules[ix]);
 }

canonical_original_code:
static void generate_recognizer_rules()
 { int ix;
   for (ix = 0; ix < nr_of_meta_rules; ix++)
      generate_recognizer_rule (all_meta_rules[ix]);
 }


decompiled_code:
__int64 generate_meta_rules()
{
warning("coding meta rules...");
generate_meta_rule_declarations();
generate_creator_rules();
generate_recognizer_rules();
return generate_parser_rules();
}

canonical_decompiled_code:
__int64 func21()
{
warning("coding meta rules...");
func1();
func4();
func20();
return func14();
}

original_code:
void generate_meta_rules ()
 { warning ("coding meta rules...");
   generate_meta_rule_declarations ();
   generate_creator_rules ();
   generate_recognizer_rules ();
   generate_parser_rules ();
 }

canonical_original_code:
void generate_meta_rules()
 { warning ("coding meta rules...");
   generate_meta_rule_declarations ();
   generate_creator_rules ();
   generate_recognizer_rules ();
   generate_parser_rules ();
 }


original_code:
void room_int_list (int_list il, int room)
{ if (room <= il -> room) return;
  il -> array = (int *) ckrecalloc (il -> array, room, sizeof (int));
  il -> room = room;
}

canonical_original_code:
void room_int_list(struct int_list_rec *il, int room)
{ if (room <= il -> room) return;
  il -> array = (int *) ckrecalloc (il -> array, room, sizeof (int));
  il -> room = room;
}

variable_types: struct int_list_rec { int size; int room; int *array; } *

variable_types: room int


decompiled_code:
__int64 new_int_list()
{
__int64 v0; // rbx

v0 = ckmalloc(16LL);
*(_DWORD *)v0 = 0;
*(_DWORD *)(v0 + 4) = 2;
*(_QWORD *)(v0 + 8) = ckcalloc(2LL, 4LL);
return v0;
}

original_code:
int_list new_int_list ()
{ int_list nl = (int_list) ckmalloc (sizeof (struct int_list_rec));
  nl -> size = 0;
  nl -> room = 2;
  nl -> array = (int *) ckcalloc (2, sizeof (int));
  return (nl);
}

canonical_original_code:
struct int_list_rec *new_int_list()
{ struct int_list_rec *nl = (int_list) ckmalloc (sizeof (struct int_list_rec));
  nl -> size = 0;
  nl -> room = 2;
  nl -> array = (int *) ckcalloc (2, sizeof (int));
  return (nl);
}

return_type: struct int_list_rec { int size; int room; int *array; } *


decompiled_code:
void __fastcall rfre_int_list(void *ptr)
{
free(*((void **)ptr + 1));
free(ptr);
}

canonical_decompiled_code:
void __fastcall func3(void *ptr)
{
free(*((void **)ptr + 1));
free(ptr);
}

original_code:
void rfre_int_list (int_list old)
{ free (old -> array);
  free (old);
}

canonical_original_code:
void rfre_int_list(struct int_list_rec *old)
{ free (old -> array);
  free (old);
}


decompiled_code:
__int64 __fastcall app_int_list(__int64 a1, int a2)
{
__int64 result; // rax

if ( *(_DWORD *)a1 == *(_DWORD *)(a1 + 4) )
room_int_list(a1, (unsigned int)(2 * *(_DWORD *)a1));
result = *(_QWORD *)(a1 + 8);
*(_DWORD *)(result + 4LL * (int)(*(_DWORD *)a1)++) = a2;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1, int a2)
{
__int64 result; // rax

if ( *(_DWORD *)a1 == *(_DWORD *)(a1 + 4) )
func0(a1, (unsigned int)(2 * *(_DWORD *)a1));
result = *(_QWORD *)(a1 + 8);
*(_DWORD *)(result + 4LL * (int)(*(_DWORD *)a1)++) = a2;
return result;
}

original_code:
void app_int_list (int_list il, int i)
{ if (il -> size == il -> room) room_int_list (il, il -> size << 1);
  il -> array [il -> size] = i;
  il -> size++;
}

canonical_original_code:
void app_int_list(struct int_list_rec *il, int i)
{ if (il -> size == il -> room) room_int_list (il, il -> size << 1);
  il -> array [il -> size] = i;
  il -> size++;
}


decompiled_code:
_BOOL8 __fastcall less_int_list(__int64 a1, __int64 a2)
{
int v2; // eax
__int64 v3; // rdi
__int64 v4; // rsi
__int64 v5; // r8
__int64 i; // rax
int v8; // ecx
int v9; // edx

if ( !a2 || !a1 )
return 0LL;
v2 = *(_DWORD *)a1;
if ( *(_DWORD *)a1 != *(_DWORD *)a2 )
return v2 < *(_DWORD *)a2;
if ( v2 <= 0 )
return 0LL;
v3 = *(_QWORD *)(a1 + 8);
v4 = *(_QWORD *)(a2 + 8);
v5 = (unsigned int)(v2 - 1);
for ( i = 0LL; ; ++i )
{
v8 = *(_DWORD *)(v3 + 4 * i);
v9 = *(_DWORD *)(v4 + 4 * i);
if ( v8 < v9 )
return 1LL;
if ( v8 > v9 )
break;
if ( i == v5 )
return 0LL;
}
return 0LL;
}

canonical_decompiled_code:
_BOOL8 __fastcall func5(__int64 a1, __int64 a2)
{
int v2; // eax
__int64 v3; // rdi
__int64 v4; // rsi
__int64 v5; // r8
__int64 i; // rax
int v8; // ecx
int v9; // edx

if ( !a2 || !a1 )
return 0LL;
v2 = *(_DWORD *)a1;
if ( *(_DWORD *)a1 != *(_DWORD *)a2 )
return v2 < *(_DWORD *)a2;
if ( v2 <= 0 )
return 0LL;
v3 = *(_QWORD *)(a1 + 8);
v4 = *(_QWORD *)(a2 + 8);
v5 = (unsigned int)(v2 - 1);
for ( i = 0LL; ; ++i )
{
v8 = *(_DWORD *)(v3 + 4 * i);
v9 = *(_DWORD *)(v4 + 4 * i);
if ( v8 < v9 )
return 1LL;
if ( v8 > v9 )
break;
if ( i == v5 )
return 0LL;
}
return 0LL;
}

original_code:
int less_int_list (int_list il1, int_list il2)
{ int ix;
  if (il1 == ((int_list) ((void *)0))) return (0);
  if (il2 == ((int_list) ((void *)0))) return (0);
  if (il1 -> size != il2 -> size) return (il1 -> size < il2 -> size);
  for (ix = 0; ix < il1 -> size; ix++)
    if (il1 -> array[ix] < il2 -> array[ix]) return (1);
    else if (il1 -> array[ix] > il2 -> array[ix]) return (0);
  return (0);
}

canonical_original_code:
int less_int_list(struct int_list_rec *il1, struct int_list_rec *il2)
{ int ix;
  if (il1 == ((int_list) ((void *)0))) return (0);
  if (il2 == ((int_list) ((void *)0))) return (0);
  if (il1 -> size != il2 -> size) return (il1 -> size < il2 -> size);
  for (ix = 0; ix < il1 -> size; ix++)
    if (il1 -> array[ix] < il2 -> array[ix]) return (1);
    else if (il1 -> array[ix] > il2 -> array[ix]) return (0);
  return (0);
}

return_type: int


decompiled_code:
__int64 __fastcall equal_int_list(__int64 a1, __int64 a2)
{
int v2; // edx
__int64 result; // rax
__int64 v4; // rdi
__int64 i; // rax

if ( !a2 || !a1 )
return 0LL;
v2 = *(_DWORD *)a1;
result = 0LL;
if ( *(_DWORD *)a1 == *(_DWORD *)a2 )
{
if ( v2 <= 0 )
{
result = 1LL;
}
else
{
v4 = *(_QWORD *)(a1 + 8);
for ( i = 0LL; *(_DWORD *)(v4 + 4 * i) == *(_DWORD *)(*(_QWORD *)(a2 + 8) + 4 * i); ++i )
{
if ( i == v2 - 1 )
return 1LL;
}
result = 0LL;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1, __int64 a2)
{
int v2; // edx
__int64 result; // rax
__int64 v4; // rdi
__int64 i; // rax

if ( !a2 || !a1 )
return 0LL;
v2 = *(_DWORD *)a1;
result = 0LL;
if ( *(_DWORD *)a1 == *(_DWORD *)a2 )
{
if ( v2 <= 0 )
{
result = 1LL;
}
else
{
v4 = *(_QWORD *)(a1 + 8);
for ( i = 0LL; *(_DWORD *)(v4 + 4 * i) == *(_DWORD *)(*(_QWORD *)(a2 + 8) + 4 * i); ++i )
{
if ( i == v2 - 1 )
return 1LL;
}
result = 0LL;
}
}
return result;
}

original_code:
int equal_int_list (int_list il1, int_list il2)
{ int ix;
  if (il1 == ((int_list) ((void *)0))) return (0);
  if (il2 == ((int_list) ((void *)0))) return (0);
  if (il1 -> size != il2 -> size) return (0);
  for (ix = 0; ix < il1 -> size; ix++)
    if (il1 -> array[ix] != il2 -> array[ix])
      return (0);
  return (1);
}

canonical_original_code:
int equal_int_list(struct int_list_rec *il1, struct int_list_rec *il2)
{ int ix;
  if (il1 == ((int_list) ((void *)0))) return (0);
  if (il2 == ((int_list) ((void *)0))) return (0);
  if (il1 -> size != il2 -> size) return (0);
  for (ix = 0; ix < il1 -> size; ix++)
    if (il1 -> array[ix] != il2 -> array[ix])
      return (0);
  return (1);
}


decompiled_code:
void __fastcall room_string_list(__int64 a1, __int64 a2)
{
if ( *(_DWORD *)(a1 + 4) < (int)a2 )
{
*(_QWORD *)(a1 + 8) = ckrecalloc(*(_QWORD *)(a1 + 8), a2, 8LL);
*(_DWORD *)(a1 + 4) = a2;
}
}

original_code:
void room_string_list (string_list sl, int room)
{ if (room <= sl -> room) return;
  sl -> array = (string *) ckrecalloc (sl -> array, room, sizeof (string));
  sl -> room = room;
}

canonical_original_code:
void room_string_list(struct string_list_rec *sl, int room)
{ if (room <= sl -> room) return;
  sl -> array = (char **) ckrecalloc (sl -> array, room, sizeof (string));
  sl -> room = room;
}

variable_types: struct string_list_rec { int size; int room; char **array; } *


decompiled_code:
__int64 new_string_list()
{
__int64 v0; // rbx

v0 = ckmalloc(16LL);
*(_DWORD *)v0 = 0;
*(_DWORD *)(v0 + 4) = 2;
*(_QWORD *)(v0 + 8) = ckcalloc(2LL, 8LL);
return v0;
}

original_code:
string_list new_string_list ()
{ string_list nsl = (string_list) ckmalloc (sizeof (struct string_list_rec));
  nsl -> size = 0;
  nsl -> room = 2;
  nsl -> array = (string *) ckcalloc (2, sizeof (string));
  return (nsl);
}

canonical_original_code:
struct string_list_rec *new_string_list()
{ struct string_list_rec *nsl = (string_list) ckmalloc (sizeof (struct string_list_rec));
  nsl -> size = 0;
  nsl -> room = 2;
  nsl -> array = (char **) ckcalloc (2, sizeof (string));
  return (nsl);
}

return_type: struct string_list_rec { int size; int room; char **array; } *


decompiled_code:
void __fastcall rfre_string_list(void *ptr)
{
free(*((void **)ptr + 1));
free(ptr);
}

canonical_decompiled_code:
void __fastcall func12(void *ptr)
{
free(*((void **)ptr + 1));
free(ptr);
}

original_code:
void rfre_string_list (string_list old)
{ free (old -> array);
  free (old);
}

canonical_original_code:
void rfre_string_list(struct string_list_rec *old)
{ free (old -> array);
  free (old);
}

user_defined_types: struct string_list_rec { int size; int room; char **array; }


decompiled_code:
__int64 __fastcall app_string_list(__int64 a1, __int64 a2)
{
__int64 result; // rax

if ( *(_DWORD *)a1 == *(_DWORD *)(a1 + 4) )
room_string_list(a1, (unsigned int)(2 * *(_DWORD *)a1));
result = *(_QWORD *)(a1 + 8);
*(_QWORD *)(result + 8LL * (int)(*(_DWORD *)a1)++) = a2;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func13(__int64 a1, __int64 a2)
{
__int64 result; // rax

if ( *(_DWORD *)a1 == *(_DWORD *)(a1 + 4) )
func9(a1, (unsigned int)(2 * *(_DWORD *)a1));
result = *(_QWORD *)(a1 + 8);
*(_QWORD *)(result + 8LL * (int)(*(_DWORD *)a1)++) = a2;
return result;
}

original_code:
void app_string_list (string_list sl, string s)
{ if (sl -> size == sl -> room) room_string_list (sl, sl -> size << 1);
  sl -> array [sl -> size] = s;
  sl -> size++;
}

canonical_original_code:
void app_string_list(struct string_list_rec *sl, char *s)
{ if (sl -> size == sl -> room) room_string_list (sl, sl -> size << 1);
  sl -> array [sl -> size] = s;
  sl -> size++;
}

variable_types:
s
char *


decompiled_code:
_BOOL8 __fastcall less_string_list(__int64 a1, __int64 a2)
{
int v2; // eax
__int64 v3; // r12
__int64 v4; // rbp
__int64 v5; // r13
__int64 i; // rbx
int v8; // eax

if ( !a2 || !a1 )
return 0LL;
v2 = *(_DWORD *)a1;
if ( *(_DWORD *)a1 != *(_DWORD *)a2 )
return v2 < *(_DWORD *)a2;
if ( v2 <= 0 )
return 0LL;
v3 = *(_QWORD *)(a2 + 8);
v4 = *(_QWORD *)(a1 + 8);
v5 = (unsigned int)(v2 - 1);
for ( i = 0LL; ; ++i )
{
v8 = strcmp(*(const char **)(v4 + 8 * i), *(const char **)(v3 + 8 * i));
if ( v8 < 0 )
return 1LL;
if ( v8 > 0 )
break;
if ( i == v5 )
return 0LL;
}
return 0LL;
}

canonical_decompiled_code:
_BOOL8 __fastcall func14(__int64 a1, __int64 a2)
{
int v2; // eax
__int64 v3; // r12
__int64 v4; // rbp
__int64 v5; // r13
__int64 i; // rbx
int v8; // eax

if ( !a2 || !a1 )
return 0LL;
v2 = *(_DWORD *)a1;
if ( *(_DWORD *)a1 != *(_DWORD *)a2 )
return v2 < *(_DWORD *)a2;
if ( v2 <= 0 )
return 0LL;
v3 = *(_QWORD *)(a2 + 8);
v4 = *(_QWORD *)(a1 + 8);
v5 = (unsigned int)(v2 - 1);
for ( i = 0LL; ; ++i )
{
v8 = strcmp(*(const char **)(v4 + 8 * i), *(const char **)(v3 + 8 * i));
if ( v8 < 0 )
return 1LL;
if ( v8 > 0 )
break;
if ( i == v5 )
return 0LL;
}
return 0LL;
}

original_code:
int less_string_list (string_list sl1, string_list sl2)
{ int ix;
  if (sl1 == ((string_list) ((void *)0))) return (0);
  if (sl2 == ((string_list) ((void *)0))) return (0);
  if (sl1 -> size != sl2 -> size) return (sl1 -> size < sl2 -> size);
  for (ix = 0; ix < sl1 -> size; ix++)
    { int stat = strcmp (sl1 -> array[ix], sl2 -> array[ix]);
      if (stat < 0) return (1);
      else if (stat > 0) return (0);
    };
  return (0);
}

canonical_original_code:
int less_string_list(struct string_list_rec *sl1, struct string_list_rec *sl2)
{ int ix;
  if (sl1 == ((string_list) ((void *)0))) return (0);
  if (sl2 == ((string_list) ((void *)0))) return (0);
  if (sl1 -> size != sl2 -> size) return (sl1 -> size < sl2 -> size);
  for (ix = 0; ix < sl1 -> size; ix++)
    { int stat = strcmp (sl1 -> array[ix], sl2 -> array[ix]);
      if (stat < 0) return (1);
      else if (stat > 0) return (0);
    };
  return (0);
}

variable_types: ix int

variable_types: stat int


decompiled_code:
__int64 __fastcall equal_string_list(__int64 a1, __int64 a2)
{
int v2; // edx
__int64 result; // rax
__int64 v4; // r12
__int64 v5; // rbp
__int64 v6; // r13
__int64 i; // rbx

if ( !a2 || !a1 )
return 0LL;
v2 = *(_DWORD *)a1;
result = 0LL;
if ( *(_DWORD *)a1 == *(_DWORD *)a2 )
{
if ( v2 <= 0 )
{
result = 1LL;
}
else
{
v4 = *(_QWORD *)(a2 + 8);
v5 = *(_QWORD *)(a1 + 8);
v6 = (unsigned int)(v2 - 1);
for ( i = 0LL; !strcmp(*(const char **)(v5 + 8 * i), *(const char **)(v4 + 8 * i)); ++i )
{
if ( i == v6 )
return 1LL;
}
result = 0LL;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func15(__int64 a1, __int64 a2)
{
int v2; // edx
__int64 result; // rax
__int64 v4; // r12
__int64 v5; // rbp
__int64 v6; // r13
__int64 i; // rbx

if ( !a2 || !a1 )
return 0LL;
v2 = *(_DWORD *)a1;
result = 0LL;
if ( *(_DWORD *)a1 == *(_DWORD *)a2 )
{
if ( v2 <= 0 )
{
result = 1LL;
}
else
{
v4 = *(_QWORD *)(a2 + 8);
v5 = *(_QWORD *)(a1 + 8);
v6 = (unsigned int)(v2 - 1);
for ( i = 0LL; !strcmp(*(const char **)(v5 + 8 * i), *(const char **)(v4 + 8 * i)); ++i )
{
if ( i == v6 )
return 1LL;
}
result = 0LL;
}
}
return result;
}

original_code:
int equal_string_list (string_list sl1, string_list sl2)
{ int ix;
  if (sl1 == ((string_list) ((void *)0))) return (0);
  if (sl2 == ((string_list) ((void *)0))) return (0);
  if (sl1 -> size != sl2 -> size) return (0);
  for (ix = 0; ix < sl1 -> size; ix++)
    if (strcmp (sl1 -> array[ix], sl2 -> array[ix]))
      return (0);
  return (1);
}

canonical_original_code:
int equal_string_list(struct string_list_rec *sl1, struct string_list_rec *sl2)
{ int ix;
  if (sl1 == ((string_list) ((void *)0))) return (0);
  if (sl2 == ((string_list) ((void *)0))) return (0);
  if (sl1 -> size != sl2 -> size) return (0);
  for (ix = 0; ix < sl1 -> size; ix++)
    if (strcmp (sl1 -> array[ix], sl2 -> array[ix]))
      return (0);
  return (1);
}


decompiled_code:
__int64 __fastcall concatenate_strings(__int64 a1)
{
_BYTE *v1; // rcx
__int64 v2; // rsi
char *v3; // rdx
char i; // al

v1 = (_BYTE *)strstore;
if ( *(int *)a1 > 0 )
{
v2 = 0LL;
do
{
v3 = *(char **)(*(_QWORD *)(a1 + 8) + 8 * v2);
for ( i = *v3; *v3; i = *v3 )
{
++v3;
*v1++ = i;
}
++v2;
}
while ( *(_DWORD *)a1 > (int)v2 );
}
*v1 = 0;
return addto_names(strstore);
}

canonical_decompiled_code:
__int64 __fastcall func18(__int64 a1)
{
_BYTE *v1; // rcx
__int64 v2; // rsi
char *v3; // rdx
char i; // al

v1 = (_BYTE *)strstore;
if ( *(int *)a1 > 0 )
{
v2 = 0LL;
do
{
v3 = *(char **)(*(_QWORD *)(a1 + 8) + 8 * v2);
for ( i = *v3; *v3; i = *v3 )
{
++v3;
*v1++ = i;
}
++v2;
}
while ( *(_DWORD *)a1 > (int)v2 );
}
*v1 = 0;
return addto_names(strstore);
}

original_code:
string concatenate_strings (string_list sl)
{ register char *dptr = strstore;
  int ix;
  for (ix = 0; ix < sl -> size; ix++)
    { register char *sptr = sl -> array[ix];
      while (*sptr) *dptr++ = *sptr++;
    };
  *dptr = '\0';
  return (addto_names (strstore));
}

canonical_original_code:
char *concatenate_strings(struct string_list_rec *sl)
{ register char *dptr = strstore;
  int ix;
  for (ix = 0; ix < sl -> size; ix++)
    { register char *sptr = sl -> array[ix];
      while (*sptr) *dptr++ = *sptr++;
    };
  *dptr = '\0';
  return (addto_names (strstore));
}

variable_types:
dptr
char *

variable_types:
sptr
char *

return_type: char *


decompiled_code:
__int64 __fastcall find_position_nr(__int64 a1, __int64 a2)
{
int v2; // edx
__int64 v3; // rsi
__int64 v4; // rax
unsigned int v5; // ecx

v2 = *(_DWORD *)(a2 + 32);
if ( v2 <= 0 )
return (unsigned int)-1;
v3 = *(_QWORD *)(a2 + 40);
v4 = 0LL;
while ( 1 )
{
v5 = v4;
if ( *(_QWORD *)(v3 + 8 * v4) == a1 )
break;
if ( ++v4 == v2 )
return (unsigned int)-1;
}
return v5;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 a2)
{
int v2; // edx
__int64 v3; // rsi
__int64 v4; // rax
unsigned int v5; // ecx

v2 = *(_DWORD *)(a2 + 32);
if ( v2 <= 0 )
return (unsigned int)-1;
v3 = *(_QWORD *)(a2 + 40);
v4 = 0LL;
while ( 1 )
{
v5 = v4;
if ( *(_QWORD *)(v3 + 8 * v4) == a1 )
break;
if ( ++v4 == v2 )
return (unsigned int)-1;
}
return v5;
}

original_code:
static int find_position_nr (pos_node p, tree_node node)
 { int ix;
   for (ix = 0; ix < node -> nraffs; ix++)
      if (node -> affs[ix] == p) return (ix);
   return (-1);
 }

canonical_original_code:
static int find_position_nr(struct pos_rec *p, struct tree_rec *node)
 { int ix;
   for (ix = 0; ix < node -> nraffs; ix++)
      if (node -> affs[ix] == p) return (ix);
   return (-1);
 }

variable_types: struct pos_rec { struct tree_rec { char *name; int type; int nodenr; int nrsons; struct tree_rec **sons; int nraffs; struct pos_rec **affs; } *node; struct pos_side_rec { int sill; int tag; union { struct affix_rec { char *name; struct value_rec { int admin_nr; int ref_count; void *dptr; int tag; union { char *str; int inum; double rnum; struct value_list_rec { int size; int room; struct value_rec **array; } *tuple; int slat; struct int_list_rec { int size; int room; int *array; } *elat; struct value_rec *free; } u; } *val; void (*mfunc)(); struct link_rec { struct pos_rec *pos; int side; struct link_rec *next; } *links; } *affx; struct { int nr; struct affix_rec **affs; } co; } a; } sides[2]; int delayed; struct pos_rec **args; void (*dfunc)(); } *

variable_types:
node
struct tree_rec *

user_defined_types: struct pos_rec { struct tree_rec *node; struct pos_side_rec sides[2]; int delayed; struct pos_rec **args; void (*dfunc)(); }

user_defined_types: struct pos_side_rec { int sill; int tag; union { struct affix_rec *affx; struct { int nr; struct affix_rec **affs; } co; } a; }

user_defined_types: struct affix_rec { char *name; struct value_rec *val; void (*mfunc)(); struct link_rec *links; }


decompiled_code:
__int64 __fastcall trace_char(char a1)
{
switch ( a1 )
{
case 9:
return eprint_log(&LC0);
case 10:
return eprint_log(&LC1);
case -124:
return eprint_log(&LC2);
}
if ( a1 > 31 )
return eprint_log(&LC4);
return eprint_log(&LC3);
}

canonical_decompiled_code:
__int64 __fastcall func1(char a1)
{
switch ( a1 )
{
case 9:
return eprint_log(&LC0);
case 10:
return eprint_log(&LC1);
case -124:
return eprint_log(&LC2);
}
if ( a1 > 31 )
return eprint_log(&LC4);
return eprint_log(&LC3);
}

original_code:
static void trace_char (char c)
 { if (c == '\t') eprint_log ("\\t");
   else if (c == '\n') eprint_log ("\\n");
   else if (c == '\204') eprint_log ("\\e");
   else if (c < ' ') eprint_log ("\\%o", c);
   else eprint_log ("%c", c);
 }

canonical_original_code:
static void trace_char(char c)
 { if (c == '\t') eprint_log ("\\t");
   else if (c == '\n') eprint_log ("\\n");
   else if (c == '\204') eprint_log ("\\e");
   else if (c < ' ') eprint_log ("\\%o", c);
   else eprint_log ("%c", c);
 }

variable_types: c char


decompiled_code:
__int64 output_indent()
{
eprint_log("%d '", (unsigned int)indent);
trace_char(*iptr);
return eprint_log("': ");
}

canonical_decompiled_code:
__int64 func2()
{
eprint_log("%d '", (unsigned int)indent);
func1(*iptr);
return eprint_log("': ");
}

original_code:
static void output_indent ()
 { eprint_log ("%d '", indent);
   trace_char (*iptr);
   eprint_log ("': ");
 }

canonical_original_code:
static void output_indent()
 { eprint_log ("%d '", indent);
   trace_char (*iptr);
   eprint_log ("': ");
 }


decompiled_code:
_DWORD *init_trace()
{
_DWORD *result; // rax

indent = 0;
result = &tracing;
tracing = 1;
return result;
}

canonical_decompiled_code:
_DWORD *func3()
{
_DWORD *result; // rax

indent = 0;
result = &tracing;
tracing = 1;
return result;
}

original_code:
void init_trace ()
 { indent = 0;
   tracing = 1;
 }

canonical_original_code:
void init_trace()
 { indent = 0;
   tracing = 1;
 }


decompiled_code:
__int64 __fastcall trace_affix(__int64 a1)
{
__int64 result; // rax

result = eprint_log("%s", *(const char **)a1);
if ( *(_QWORD *)(a1 + 8) )
{
eprint_log("[");
dump_value(*(_QWORD *)(a1 + 8));
result = eprint_log("]");
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1)
{
__int64 result; // rax

result = eprint_log("%s", *(const char **)a1);
if ( *(_QWORD *)(a1 + 8) )
{
eprint_log("[");
dump_value(*(_QWORD *)(a1 + 8));
result = eprint_log("]");
}
return result;
}

original_code:
void trace_affix (affix_node a)
 { eprint_log ("%s", a -> name);
   if (a -> val != ((value) ((void *)0)))
      { eprint_log ("[");
        dump_value (a -> val);
        eprint_log ("]");
      };
 }

canonical_original_code:
void trace_affix(struct affix_rec *a)
 { eprint_log ("%s", a -> name);
   if (a -> val != ((value) ((void *)0)))
      { eprint_log ("[");
        dump_value (a -> val);
        eprint_log ("]");
      };
 }

variable_types: struct affix_rec { char *name; struct value_rec { int admin_nr; int ref_count; void *dptr; int tag; union { char *str; int inum; double rnum; struct value_list_rec { int size; int room; struct value_rec **array; } *tuple; int slat; struct int_list_rec { int size; int room; int *array; } *elat; struct value_rec *free; } u; } *val; void (*mfunc)(); struct link_rec { struct pos_rec { struct tree_rec { char *name; int type; int nodenr; int nrsons; struct tree_rec **sons; int nraffs; struct pos_rec **affs; } *node; struct pos_side_rec { int sill; int tag; union { struct affix_rec *affx; struct { int nr; struct affix_rec **affs; } co; } a; } sides[2]; int delayed; struct pos_rec **args; void (*dfunc)(); } *pos; int side; struct link_rec *next; } *links; } *

user_defined_types: struct link_rec { struct pos_rec *pos; int side; struct link_rec *next; }


decompiled_code:
__int64 __fastcall trace_pos_side(__int64 a1, int a2)
{
__int64 v3; // rbp
int v4; // ebx
const char *v5; // rsi
int v7; // er12
char v8; // r14
__int64 v9; // r13
__int64 v10; // rbx
int v11; // er12

v3 = a1 + 24LL * a2;
v4 = *(_DWORD *)(v3 + 12);
output_indent();
v5 = "lo";
if ( a2 )
v5 = "hi";
eprint_log("%s = (", v5);
eprint_log("sill = %d, ", *(unsigned int *)(v3 + 8));
if ( v4 == 1 )
{
trace_affix(*(_QWORD *)(v3 + 16));
}
else if ( v4 > 1 )
{
if ( (unsigned int)(v4 - 2) <= 2 )
{
v7 = *(_DWORD *)(v3 + 16);
v8 = LC14[v4];
if ( v7 > 0 )
{
v9 = (unsigned int)v7;
v10 = 0LL;
v11 = v7 - 1;
do
{
trace_affix(*(_QWORD *)(*(_QWORD *)(v3 + 24) + 8 * v10));
if ( v11 != (_DWORD)v10 )
eprint_log(" %c ", (unsigned int)v8);
++v10;
}
while ( v10 != v9 );
}
}
}
else if ( !v4 )
{
eprint_log("_");
}
return eprint_log(")\n");
}

original_code:
void trace_pos_side (pos_node p, int i)
 { int tag = p -> sides[i].tag;
   output_indent ();
   eprint_log ("%s = (", (i == 0)?"lo":"hi");
   eprint_log ("sill = %d, ", p -> sides[i].sill);
   switch (tag)
      { case 0: eprint_log ("_"); break;
        case 1: trace_affix (p -> sides[i].a.affx); break;
        case 2:
        case 3:
        case 4:
    { int iy;
      int nr = p -> sides[i].a.co.nr;
      string seps = "*+|";
      char sep = seps[tag - 2];
      for (iy = 0; iy < nr; iy++)
         { trace_affix (p -> sides[i].a.co.affs[iy]);
    if (iy != nr - 1) eprint_log (" %c ", sep);
         };
    };
      };
   eprint_log (")\n");
 }

canonical_original_code:
void trace_pos_side(struct pos_rec *p, int i)
 { int tag = p -> sides[i].tag;
   output_indent ();
   eprint_log ("%s = (", (i == 0)?"lo":"hi");
   eprint_log ("sill = %d, ", p -> sides[i].sill);
   switch (tag)
      { case 0: eprint_log ("_"); break;
        case 1: trace_affix (p -> sides[i].a.affx); break;
        case 2:
        case 3:
        case 4:
    { int iy;
      int nr = p -> sides[i].a.co.nr;
      char *seps = "*+|";
      char sep = seps[tag - 2];
      for (iy = 0; iy < nr; iy++)
         { trace_affix (p -> sides[i].a.co.affs[iy]);
    if (iy != nr - 1) eprint_log (" %c ", sep);
         };
    };
      };
   eprint_log (")\n");
 }

variable_types: i int

variable_types: tag int

variable_types: iy int

variable_types: nr int

variable_types:
seps
char *

variable_types: sep char

user_defined_types: struct tree_rec { char *name; int type; int nodenr; int nrsons; struct tree_rec **sons; int nraffs; struct pos_rec **affs; }


decompiled_code:
__int64 __fastcall trace_pos(__int64 *a1)
{
const char **v1; // r12
unsigned int v2; // er13
int v3; // ebp
const char *v4; // rax

v1 = (const char **)*a1;
v2 = *(_DWORD *)(*a1 + 12);
v3 = find_position_nr((__int64)a1, *a1);
output_indent();
v4 = (const char *)module_name_from_nodenr(v2);
eprint_log("tracing position %d of %s in module %s\n", (unsigned int)(v3 + 1), *v1, v4);
trace_pos_side((__int64)a1, 0);
return trace_pos_side((__int64)a1, 1);
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 *a1)
{
const char **v1; // r12
unsigned int v2; // er13
int v3; // ebp
const char *v4; // rax

v1 = (const char **)*a1;
v2 = *(_DWORD *)(*a1 + 12);
v3 = func0((__int64)a1, *a1);
func2();
v4 = (const char *)module_name_from_nodenr(v2);
eprint_log("tracing position %d of %s in module %s\n", (unsigned int)(v3 + 1), *v1, v4);
func5((__int64)a1, 0);
return func5((__int64)a1, 1);
}

original_code:
void trace_pos (pos_node p)
 { tree_node node = p -> node;
   int nodenr = node -> nodenr;
   int pos_nr = find_position_nr (p, node);
   output_indent ();
   eprint_log ("tracing position %d of %s in module %s\n",
        pos_nr + 1, node -> name,
        module_name_from_nodenr (nodenr));
   trace_pos_side (p, 0);
   trace_pos_side (p, 1);
 }

canonical_original_code:
void trace_pos(struct pos_rec *p)
 { struct tree_rec *node = p -> node;
   int nodenr = node -> nodenr;
   int pos_nr = find_position_nr (p, node);
   output_indent ();
   eprint_log ("tracing position %d of %s in module %s\n",
        pos_nr + 1, node -> name,
        module_name_from_nodenr (nodenr));
   trace_pos_side (p, 0);
   trace_pos_side (p, 1);
 }

variable_types: struct tree_rec { char *name; int type; int nodenr; int nrsons; struct tree_rec **sons; int nraffs; struct pos_rec { struct tree_rec *node; struct pos_side_rec { int sill; int tag; union { struct affix_rec { char *name; struct value_rec { int admin_nr; int ref_count; void *dptr; int tag; union { char *str; int inum; double rnum; struct value_list_rec { int size; int room; struct value_rec **array; } *tuple; int slat; struct int_list_rec { int size; int room; int *array; } *elat; struct value_rec *free; } u; } *val; void (*mfunc)(); struct link_rec { struct pos_rec *pos; int side; struct link_rec *next; } *links; } *affx; struct { int nr; struct affix_rec **affs; } co; } a; } sides[2]; int delayed; struct pos_rec **args; void (*dfunc)(); } **affs; } *

variable_types: nodenr int


decompiled_code:
__int64 __fastcall trace_restrict_pos(__int64 *a1, __int64 a2)
{
const char **v2; // r13
unsigned int v3; // er14
int v4; // ebp
const char *v5; // rax

v2 = (const char **)*a1;
v3 = *(_DWORD *)(*a1 + 12);
v4 = find_position_nr((__int64)a1, *a1);
output_indent();
v5 = (const char *)module_name_from_nodenr(v3);
eprint_log("restricting position %d of %s in module %s\n", (unsigned int)(v4 + 1), *v2, v5);
output_indent();
eprint_log("with value: ");
dump_value(a2);
eprint_log("\n");
trace_pos_side((__int64)a1, 0);
return trace_pos_side((__int64)a1, 1);
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 *a1, __int64 a2)
{
const char **v2; // r13
unsigned int v3; // er14
int v4; // ebp
const char *v5; // rax

v2 = (const char **)*a1;
v3 = *(_DWORD *)(*a1 + 12);
v4 = func0((__int64)a1, *a1);
func2();
v5 = (const char *)module_name_from_nodenr(v3);
eprint_log("restricting position %d of %s in module %s\n", (unsigned int)(v4 + 1), *v2, v5);
func2();
eprint_log("with value: ");
dump_value(a2);
eprint_log("\n");
func5((__int64)a1, 0);
return func5((__int64)a1, 1);
}

original_code:
void trace_restrict_pos (pos_node p, value mval)
 { tree_node node = p -> node;
   int nodenr = node -> nodenr;
   int pos_nr = find_position_nr (p, node);
   output_indent ();
   eprint_log ("restricting position %d of %s in module %s\n",
        pos_nr + 1, node -> name,
        module_name_from_nodenr (nodenr));
   output_indent ();
   eprint_log ("with value: ");
   dump_value (mval);
   eprint_log ("\n");
   trace_pos_side (p, 0);
   trace_pos_side (p, 1);
 }

canonical_original_code:
void trace_restrict_pos(struct pos_rec *p, struct value_rec *mval)
 { struct tree_rec *node = p -> node;
   int nodenr = node -> nodenr;
   int pos_nr = find_position_nr (p, node);
   output_indent ();
   eprint_log ("restricting position %d of %s in module %s\n",
        pos_nr + 1, node -> name,
        module_name_from_nodenr (nodenr));
   output_indent ();
   eprint_log ("with value: ");
   dump_value (mval);
   eprint_log ("\n");
   trace_pos_side (p, 0);
   trace_pos_side (p, 1);
 }

variable_types:
mval
struct value_rec *


decompiled_code:
__int64 __fastcall trace_enter(const char *a1)
{
__int64 result; // rax

output_indent();
result = eprint_log(">%s\n", a1);
++indent;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func8(const char *a1)
{
__int64 result; // rax

func2();
result = eprint_log(">%s\n", a1);
++indent;
return result;
}

original_code:
void trace_enter (char *s)
 { output_indent ();
   eprint_log (">%s\n", s);
   indent++;
 }

canonical_original_code:
void trace_enter(char *s)
 { output_indent ();
   eprint_log (">%s\n", s);
   indent++;
 }

variable_types:
s
char *


decompiled_code:
__int64 __fastcall trace_alternative(const char *a1, unsigned int a2)
{
output_indent();
return eprint_log("-%s, alt %d\n", a1, a2);
}

canonical_decompiled_code:
__int64 __fastcall func9(const char *a1, unsigned int a2)
{
func2();
return eprint_log("-%s, alt %d\n", a1, a2);
}

original_code:
void trace_alternative (char *s, int i)
 { output_indent ();
   eprint_log ("-%s, alt %d\n", s, i);
 }

canonical_original_code:
void trace_alternative(char *s, int i)
 { output_indent ();
   eprint_log ("-%s, alt %d\n", s, i);
 }


decompiled_code:
__int64 __fastcall trace_placeholder_alternative(const char *a1, int a2)
{
const char *v2; // rdx

output_indent();
v2 = "un";
if ( !a2 )
v2 = (const char *)&LC25;
return eprint_log("-%s, %styped placeholder alt\n", a1, v2);
}

canonical_decompiled_code:
__int64 __fastcall func10(const char *a1, int a2)
{
const char *v2; // rdx

func2();
v2 = "un";
if ( !a2 )
v2 = (const char *)&LC25;
return eprint_log("-%s, %styped placeholder alt\n", a1, v2);
}

original_code:
void trace_placeholder_alternative (char *s, int untyped)
 { output_indent ();
   eprint_log ("-%s, %styped placeholder alt\n", s, (untyped)?"un":"");
 }

canonical_original_code:
void trace_placeholder_alternative(char *s, int untyped)
 { output_indent ();
   eprint_log ("-%s, %styped placeholder alt\n", s, (untyped)?"un":"");
 }

variable_types: untyped int


decompiled_code:
__int64 __fastcall trace_leave(const char *a1)
{
--indent;
output_indent();
return eprint_log("<%s\n", a1);
}

canonical_decompiled_code:
__int64 __fastcall func11(const char *a1)
{
--indent;
func2();
return eprint_log("<%s\n", a1);
}

original_code:
void trace_leave (char *s)
 { indent--;
   output_indent ();
   eprint_log ("<%s\n", s);
 }

canonical_original_code:
void trace_leave(char *s)
 { indent--;
   output_indent ();
   eprint_log ("<%s\n", s);
 }


original_code:
static element_set merge_lattices (element_set left, element_set right)
 { int ix;
   if (left == ((element_set) ((void *)0))) return (right);
   if (right == ((element_set) ((void *)0))) return (left);
   if (left == right) return (left);
   for (ix = 0; ix < right -> defs -> size; ix++)
      { element_def relt = right -> defs -> array[ix];
        app_element_def_list (left -> defs, relt);
        relt -> set = left;
      };
   change = 1;
   return (left);
 }

canonical_original_code:
static struct element_set_rec *merge_lattices(struct element_set_rec *left, struct element_set_rec *right)
 { int ix;
   if (left == ((element_set) ((void *)0))) return (right);
   if (right == ((element_set) ((void *)0))) return (left);
   if (left == right) return (left);
   for (ix = 0; ix < right -> defs -> size; ix++)
      { struct element_def_rec *relt = right -> defs -> array[ix];
        app_element_def_list (left -> defs, relt);
        relt -> set = left;
      };
   change = 1;
   return (left);
 }

variable_types:
left
struct element_set_rec *

variable_types:
right
struct element_set_rec *

variable_types: ix int

variable_types: struct element_def_rec { char *eltnm; int number; int eltnr; struct element_set_rec { int number; struct element_def_list_rec { int size; int room; struct element_def_rec **array; } *defs; } *set; } *

return_type: struct element_set_rec { int number; struct element_def_list_rec { int size; int room; struct element_def_rec { char *eltnm; int number; int eltnr; struct element_set_rec *set; } **array; } *defs; } *


decompiled_code:
__int64 __fastcall construct_lattice_in_affix(__int128 a1, __int64 a2)
{
unsigned int v2; // eax

v2 = *(_DWORD *)(a1 + 40);
if ( !v2 )
return construct_lattice_from_variable((_QWORD *)a1, *((__int64 *)&a1 + 1), a2);
if ( v2 == 5 )
return construct_lattice_from_element(a1);
bad_tag(v2, "construct_lattice_in_affix");
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int128 a1, __int64 a2)
{
unsigned int v2; // eax

v2 = *(_DWORD *)(a1 + 40);
if ( !v2 )
return func1((_QWORD *)a1, *((__int64 *)&a1 + 1), a2);
if ( v2 == 5 )
return func2(a1);
bad_tag(v2, "construct_lattice_in_affix");
return 0LL;
}

original_code:
static element_set construct_lattice_in_affix (affix a, element_set mset)
 { switch (a -> tag)
      { case 0:
    return (construct_lattice_from_variable (a, mset));
        case 5:
    return (construct_lattice_from_element (a, mset));
        default: bad_tag (a -> tag, "construct_lattice_in_affix");
      };
   return (((element_set) ((void *)0)));
 }

canonical_original_code:
static struct element_set_rec *construct_lattice_in_affix(struct affix_rec *a, struct element_set_rec *mset)
 { switch (a -> tag)
      { case 0:
    return (construct_lattice_from_variable (a, mset));
        case 5:
    return (construct_lattice_from_element (a, mset));
        default: bad_tag (a -> tag, "construct_lattice_in_affix");
      };
   return (((element_set) ((void *)0)));
 }

variable_types: struct affix_rec { char *name; int type; struct affix_rec *next; struct value_rec { int admin_nr; int ref_count; void *dptr; int tag; union { char *str; int inum; double rnum; struct value_list_rec { int size; int room; struct value_rec **array; } *tuple; int slat; struct int_list_rec { int size; int room; int *array; } *elat; struct value_rec *free; } u; } *val; int ref_count; int reachable; int tag; union { struct variable_rec { char *nonterminal; char *suffix; struct meta_rule_rec { char *nonterminal; struct meta_alt_list_rec { int size; int room; struct meta_alt_rec { struct expr_rec { int tag; union { struct affix_rec *single; struct affix_list_rec { int size; int room; struct affix_rec **array; } *compos; struct affix_list_rec *concat; struct affix_list_rec *uni; } u; } *e; int number; } **array; } *alts; int ext; int type; int kind; int empty; int number; struct value_rec *mvalue; int reachable; struct element_def_rec *lat_repr; int needs_rec; int needs_recbup; } *def; } var; char *str; int inum; double rnum; struct cset_rec { int kind; char *str; } *semi; struct element_rec { char *eltnm; struct element_def_rec *def; } elt; struct expr_rec *cexpr; } u; } *

variable_types:
mset
struct element_set_rec *

user_defined_types: struct affix_rec { char *name; int type; struct affix_rec *next; struct value_rec *val; int ref_count; int reachable; int tag; union { struct variable_rec var; char *str; int inum; double rnum; struct cset_rec *semi; struct element_rec elt; struct expr_rec *cexpr; } u; }

user_defined_types: struct meta_rule_rec { char *nonterminal; struct meta_alt_list_rec *alts; int ext; int type; int kind; int empty; int number; struct value_rec *mvalue; int reachable; struct element_def_rec *lat_repr; int needs_rec; int needs_recbup; }

user_defined_types: struct meta_alt_list_rec { int size; int room; struct meta_alt_rec **array; }

user_defined_types: struct meta_alt_rec { struct expr_rec *e; int number; }

user_defined_types: struct expr_rec { int tag; union { struct affix_rec *single; struct affix_list_rec *compos; struct affix_list_rec *concat; struct affix_list_rec *uni; } u; }


decompiled_code:
__int64 __fastcall construct_lattices_in_affixes(__int128 a1, __int64 a2)
{
__int64 v2; // rbp
__int64 v3; // rbx
__int64 result; // rax

if ( *(int *)a1 <= 0 )
return *((_QWORD *)&a1 + 1);
v2 = a1;
v3 = 0LL;
do
{
*(_QWORD *)&a1 = *(_QWORD *)(*(_QWORD *)(v2 + 8) + 8 * v3);
result = construct_lattice_in_affix(a1, a2);
*((_QWORD *)&a1 + 1) = result;
++v3;
}
while ( *(_DWORD *)v2 > (int)v3 );
return result;
}

original_code:
static element_set construct_lattices_in_affixes (affix_list affs,
         element_set mset)
 { element_set rset = mset;
   int ix;
   for (ix = 0; ix < affs -> size; ix++)
      rset = construct_lattice_in_affix (affs -> array[ix], rset);
   return (rset);
 }

canonical_original_code:
static struct element_set_rec *construct_lattices_in_affixes(struct affix_list_rec *affs, struct element_set_rec *mset)
 { struct element_set_rec *rset = mset;
   int ix;
   for (ix = 0; ix < affs -> size; ix++)
      rset = construct_lattice_in_affix (affs -> array[ix], rset);
   return (rset);
 }

variable_types: struct affix_list_rec { int size; int room; struct affix_rec { char *name; int type; struct affix_rec *next; struct value_rec { int admin_nr; int ref_count; void *dptr; int tag; union { char *str; int inum; double rnum; struct value_list_rec { int size; int room; struct value_rec **array; } *tuple; int slat; struct int_list_rec { int size; int room; int *array; } *elat; struct value_rec *free; } u; } *val; int ref_count; int reachable; int tag; union { struct variable_rec { char *nonterminal; char *suffix; struct meta_rule_rec { char *nonterminal; struct meta_alt_list_rec { int size; int room; struct meta_alt_rec { struct expr_rec { int tag; union { struct affix_rec *single; struct affix_list_rec *compos; struct affix_list_rec *concat; struct affix_list_rec *uni; } u; } *e; int number; } **array; } *alts; int ext; int type; int kind; int empty; int number; struct value_rec *mvalue; int reachable; struct element_def_rec *lat_repr; int needs_rec; int needs_recbup; } *def; } var; char *str; int inum; double rnum; struct cset_rec { int kind; char *str; } *semi; struct element_rec { char *eltnm; struct element_def_rec *def; } elt; struct expr_rec *cexpr; } u; } **array; } *

variable_types: struct element_set_rec { int number; struct element_def_list_rec { int size; int room; struct element_def_rec { char *eltnm; int number; int eltnr; struct element_set_rec *set; } **array; } *defs; } *

user_defined_types: struct affix_list_rec { int size; int room; struct affix_rec **array; }

user_defined_types: struct element_set_rec { int number; struct element_def_list_rec *defs; }

user_defined_types: struct value_rec { int admin_nr; int ref_count; void *dptr; int tag; union { char *str; int inum; double rnum; struct value_list_rec *tuple; int slat; struct int_list_rec *elat; struct value_rec *free; } u; }


decompiled_code:
__int64 __fastcall construct_lattices_in_expr(__int128 a1, __int64 a2)
{
__int64 v2; // rbx
__int64 v3; // rdi
__int64 result; // rax

v2 = a1;
if ( !(_QWORD)a1 )
internal_error("construct_lattices_in_expr");
v3 = *(unsigned int *)a1;
if ( (_DWORD)v3 == 1 )
{
*(_QWORD *)&a1 = *(_QWORD *)(v2 + 8);
result = construct_lattice_in_affix(a1, a2);
}
else if ( (_DWORD)v3 == 4 )
{
*(_QWORD *)&a1 = *(_QWORD *)(v2 + 8);
result = construct_lattices_in_affixes(a1, a2);
}
else
{
bad_tag(v3, "construct_lattices_in_expr");
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(__int128 a1, __int64 a2)
{
__int64 v2; // rbx
__int64 v3; // rdi
__int64 result; // rax

v2 = a1;
if ( !(_QWORD)a1 )
internal_error("construct_lattices_in_expr");
v3 = *(unsigned int *)a1;
if ( (_DWORD)v3 == 1 )
{
*(_QWORD *)&a1 = *(_QWORD *)(v2 + 8);
result = func3(a1, a2);
}
else if ( (_DWORD)v3 == 4 )
{
*(_QWORD *)&a1 = *(_QWORD *)(v2 + 8);
result = func4(a1, a2);
}
else
{
bad_tag(v3, "construct_lattices_in_expr");
result = 0LL;
}
return result;
}

original_code:
static element_set construct_lattices_in_expr (expr e, element_set mset)
 { if (e == ((expr) ((void *)0)))
      internal_error ("construct_lattices_in_expr");
   switch (e -> tag)
      { case 1:
    return (construct_lattice_in_affix (e -> u.single, mset));
        case 4:
    return (construct_lattices_in_affixes (e -> u.uni, mset));
        default: bad_tag (e -> tag, "construct_lattices_in_expr");
      };
   return (((element_set) ((void *)0)));
 }

canonical_original_code:
static struct element_set_rec *construct_lattices_in_expr(struct expr_rec *e, struct element_set_rec *mset)
 { if (e == ((expr) ((void *)0)))
      internal_error ("construct_lattices_in_expr");
   switch (e -> tag)
      { case 1:
    return (construct_lattice_in_affix (e -> u.single, mset));
        case 4:
    return (construct_lattices_in_affixes (e -> u.uni, mset));
        default: bad_tag (e -> tag, "construct_lattices_in_expr");
      };
   return (((element_set) ((void *)0)));
 }

variable_types: struct expr_rec { int tag; union { struct affix_rec { char *name; int type; struct affix_rec *next; struct value_rec { int admin_nr; int ref_count; void *dptr; int tag; union { char *str; int inum; double rnum; struct value_list_rec { int size; int room; struct value_rec **array; } *tuple; int slat; struct int_list_rec { int size; int room; int *array; } *elat; struct value_rec *free; } u; } *val; int ref_count; int reachable; int tag; union { struct variable_rec { char *nonterminal; char *suffix; struct meta_rule_rec { char *nonterminal; struct meta_alt_list_rec { int size; int room; struct meta_alt_rec { struct expr_rec *e; int number; } **array; } *alts; int ext; int type; int kind; int empty; int number; struct value_rec *mvalue; int reachable; struct element_def_rec *lat_repr; int needs_rec; int needs_recbup; } *def; } var; char *str; int inum; double rnum; struct cset_rec { int kind; char *str; } *semi; struct element_rec { char *eltnm; struct element_def_rec *def; } elt; struct expr_rec *cexpr; } u; } *single; struct affix_list_rec { int size; int room; struct affix_rec **array; } *compos; struct affix_list_rec *concat; struct affix_list_rec *uni; } u; } *

user_defined_types: struct variable_rec { char *nonterminal; char *suffix; struct meta_rule_rec *def; }

user_defined_types: struct element_def_rec { char *eltnm; int number; int eltnr; struct element_set_rec *set; }


decompiled_code:
__int64 __fastcall construct_lattices_in_meta_alts(__int128 a1, __int64 a2)
{
__int64 v2; // rbp
__int64 v3; // rbx
__int64 result; // rax

if ( *(int *)a1 <= 0 )
return *((_QWORD *)&a1 + 1);
v2 = a1;
v3 = 0LL;
do
{
*(_QWORD *)&a1 = **(_QWORD **)(*(_QWORD *)(v2 + 8) + 8 * v3);
result = construct_lattices_in_expr(a1, a2);
*((_QWORD *)&a1 + 1) = result;
++v3;
}
while ( *(_DWORD *)v2 > (int)v3 );
return result;
}

original_code:
static element_set construct_lattices_in_meta_alts (meta_alt_list alts,
           element_set mset)
 { int ix;
   element_set rset = mset;
   for (ix = 0; ix < alts -> size; ix++)
      rset = construct_lattices_in_expr (alts -> array[ix] -> e, rset);
   return (rset);
 }

canonical_original_code:
static struct element_set_rec *construct_lattices_in_meta_alts(struct meta_alt_list_rec *alts, struct element_set_rec *mset)
 { int ix;
   struct element_set_rec *rset = mset;
   for (ix = 0; ix < alts -> size; ix++)
      rset = construct_lattices_in_expr (alts -> array[ix] -> e, rset);
   return (rset);
 }

variable_types: struct meta_alt_list_rec { int size; int room; struct meta_alt_rec { struct expr_rec { int tag; union { struct affix_rec { char *name; int type; struct affix_rec *next; struct value_rec { int admin_nr; int ref_count; void *dptr; int tag; union { char *str; int inum; double rnum; struct value_list_rec { int size; int room; struct value_rec **array; } *tuple; int slat; struct int_list_rec { int size; int room; int *array; } *elat; struct value_rec *free; } u; } *val; int ref_count; int reachable; int tag; union { struct variable_rec { char *nonterminal; char *suffix; struct meta_rule_rec { char *nonterminal; struct meta_alt_list_rec *alts; int ext; int type; int kind; int empty; int number; struct value_rec *mvalue; int reachable; struct element_def_rec *lat_repr; int needs_rec; int needs_recbup; } *def; } var; char *str; int inum; double rnum; struct cset_rec { int kind; char *str; } *semi; struct element_rec { char *eltnm; struct element_def_rec *def; } elt; struct expr_rec *cexpr; } u; } *single; struct affix_list_rec { int size; int room; struct affix_rec **array; } *compos; struct affix_list_rec *concat; struct affix_list_rec *uni; } u; } *e; int number; } **array; } *

user_defined_types: struct element_def_list_rec { int size; int room; struct element_def_rec **array; }


original_code:
static void construct_lattices_in_meta_rule (meta_rule mrule)
 { element_set rset, mset;
   if (mrule -> ext) return;
   if (mrule -> type != 16) return;
   if (mrule -> lat_repr == ((element_def) ((void *)0))) mset = ((element_set) ((void *)0));
   else mset = mrule -> lat_repr -> set;
   rset = construct_lattices_in_meta_alts (mrule -> alts, mset);
   if (rset != mset)
      { mrule -> lat_repr = rset -> defs -> array[0];
        change = 1;
      };
 }

canonical_original_code:
static void construct_lattices_in_meta_rule(struct meta_rule_rec *mrule)
 { struct element_set_rec *rset; struct element_set_rec *mset;
   if (mrule -> ext) return;
   if (mrule -> type != 16) return;
   if (mrule -> lat_repr == ((element_def) ((void *)0))) mset = ((element_set) ((void *)0));
   else mset = mrule -> lat_repr -> set;
   rset = construct_lattices_in_meta_alts (mrule -> alts, mset);
   if (rset != mset)
      { mrule -> lat_repr = rset -> defs -> array[0];
        change = 1;
      };
 }

variable_types: struct meta_rule_rec { char *nonterminal; struct meta_alt_list_rec { int size; int room; struct meta_alt_rec { struct expr_rec { int tag; union { struct affix_rec { char *name; int type; struct affix_rec *next; struct value_rec { int admin_nr; int ref_count; void *dptr; int tag; union { char *str; int inum; double rnum; struct value_list_rec { int size; int room; struct value_rec **array; } *tuple; int slat; struct int_list_rec { int size; int room; int *array; } *elat; struct value_rec *free; } u; } *val; int ref_count; int reachable; int tag; union { struct variable_rec { char *nonterminal; char *suffix; struct meta_rule_rec *def; } var; char *str; int inum; double rnum; struct cset_rec { int kind; char *str; } *semi; struct element_rec { char *eltnm; struct element_def_rec { char *eltnm; int number; int eltnr; struct element_set_rec { int number; struct element_def_list_rec { int size; int room; struct element_def_rec **array; } *defs; } *set; } *def; } elt; struct expr_rec *cexpr; } u; } *single; struct affix_list_rec { int size; int room; struct affix_rec **array; } *compos; struct affix_list_rec *concat; struct affix_list_rec *uni; } u; } *e; int number; } **array; } *alts; int ext; int type; int kind; int empty; int number; struct value_rec *mvalue; int reachable; struct element_def_rec *lat_repr; int needs_rec; int needs_recbup; } *

user_defined_types: struct element_rec { char *eltnm; struct element_def_rec *def; }