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

code_line("\t\tpushv (%s);", a2);
v5 = *(unsigned int *)(a1 + 40);
switch ( (int)v5 )
{
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");
v7 = **(_DWORD **)(a1 + 48);
if ( (v7 & 4) != 0 )
{
code_string("_star");
v7 = **(_DWORD **)(a1 + 48);
}
if ( (v7 & 2) != 0 )
{
code_string("_plus");
v7 = **(_DWORD **)(a1 + 48);
}
if ( (v7 & 1) != 0 )
code_string("_strict");
result = code_line(");");
*a3 += 3;
break;
case 5:
case 6:
internal_error("generate_rec_affix");
v5 = *(unsigned int *)(a1 + 40);
goto LABEL_3;
default:
LABEL_3:
result = bad_tag(v5, "generate_rec_affix");
break;
}
return result;
}

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

code_line("\t\tpushv (%s);", a2);
v5 = *(unsigned int *)(a1 + 40);
switch ( (int)v5 )
{
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");
v7 = **(_DWORD **)(a1 + 48);
if ( (v7 & 4) != 0 )
{
code_string("_star");
v7 = **(_DWORD **)(a1 + 48);
}
if ( (v7 & 2) != 0 )
{
code_string("_plus");
v7 = **(_DWORD **)(a1 + 48);
}
if ( (v7 & 1) != 0 )
code_string("_strict");
result = code_line(");");
*a3 += 3;
break;
case 5:
case 6:
internal_error("generate_rec_affix");
v5 = *(unsigned int *)(a1 + 40);
goto LABEL_3;
default:
LABEL_3:
result = bad_tag(v5, "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 *


repo: tjordanchat/eag

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

return_type: void

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 variable_rec { char *nonterminal; char *suffix; struct meta_rule_rec *def; }

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

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

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 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 meta_alt_list_rec { int size; int room; struct meta_alt_rec **array; }

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; }

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

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

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_list_rec { int size; int room; struct affix_rec **array; }


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

v3 = *(unsigned int *)(a1 + 40);
switch ( (int)v3 )
{
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:
v5 = *(double *)(a1 + 48);
code_line("\t\tpushr (%d);\n", a2);
result = code_line("\t\tpushq (recbup_parse_real);\n", v5);
*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");
v6 = **(_DWORD **)(a1 + 48);
if ( (v6 & 4) != 0 )
{
code_string("_star");
v6 = **(_DWORD **)(a1 + 48);
}
if ( (v6 & 2) != 0 )
{
code_string("_plus");
v6 = **(_DWORD **)(a1 + 48);
}
if ( (v6 & 1) != 0 )
code_string("_strict");
result = code_line(");\n");
*a2 += 2;
break;
case 5:
case 6:
internal_error("generate_recbup_affix");
v3 = *(unsigned int *)(a1 + 40);
goto LABEL_3;
default:
LABEL_3:
result = bad_tag(v3, "generate_recbup_affix");
break;
}
return result;
}

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

v3 = *(unsigned int *)(a1 + 40);
switch ( (int)v3 )
{
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:
v5 = *(double *)(a1 + 48);
code_line("\t\tpushr (%d);\n", a2);
result = code_line("\t\tpushq (recbup_parse_real);\n", v5);
*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");
v6 = **(_DWORD **)(a1 + 48);
if ( (v6 & 4) != 0 )
{
code_string("_star");
v6 = **(_DWORD **)(a1 + 48);
}
if ( (v6 & 2) != 0 )
{
code_string("_plus");
v6 = **(_DWORD **)(a1 + 48);
}
if ( (v6 & 1) != 0 )
code_string("_strict");
result = code_line(");\n");
*a2 += 2;
break;
case 5:
case 6:
internal_error("generate_recbup_affix");
v3 = *(unsigned int *)(a1 + 40);
goto LABEL_3;
default:
LABEL_3:
result = bad_tag(v3, "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");
      };
 }

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; } *


decompiled_code:
__int64 __fastcall generate_recbup_concat(int *a1, _DWORD *a2)
{
__int64 result; // rax
int v3; // edx
__int64 v5; // rbx
__int64 v6; // r13
__int64 v7; // rdi

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

canonical_decompiled_code:
__int64 __fastcall func8(int *a1, _DWORD *a2)
{
__int64 result; // rax
int v3; // edx
__int64 v5; // rbx
__int64 v6; // r13
__int64 v7; // rdi

result = *a1;
v3 = *a1 - 1;
if ( v3 >= 0 )
{
v5 = 8LL * v3;
v6 = 8 * (result - (unsigned int)v3) - 16;
do
{
v7 = *(_QWORD *)(*((_QWORD *)a1 + 1) + v5);
v5 -= 8LL;
result = func7(v7, a2);
}
while ( v5 != v6 );
}
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; } *

variable_types: ix int


decompiled_code:
__int64 __fastcall generate_parser_expr(int **a1, _DWORD *a2)
{
__int64 v3; // rdi
__int64 result; // rax

if ( a1 )
{
v3 = *(unsigned int *)a1;
if ( (_DWORD)v3 == 3 )
{
result = generate_recbup_concat(a1[1], a2);
}
else
{
if ( (int)v3 > 3 )
{
if ( (_DWORD)v3 == 4 )
goto LABEL_6;
return bad_tag(v3, "generate_parser_expr");
}
if ( (_DWORD)v3 != 1 )
{
if ( (_DWORD)v3 == 2 )
{
LABEL_6:
internal_error("generate_parser_expr");
v3 = *(unsigned int *)a1;
}
return bad_tag(v3, "generate_parser_expr");
}
result = generate_recbup_affix((__int64)a1[1], a2);
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func9(int **a1, _DWORD *a2)
{
__int64 v3; // rdi
__int64 result; // rax

if ( a1 )
{
v3 = *(unsigned int *)a1;
if ( (_DWORD)v3 == 3 )
{
result = func8(a1[1], a2);
}
else
{
if ( (int)v3 > 3 )
{
if ( (_DWORD)v3 == 4 )
goto LABEL_6;
return bad_tag(v3, "generate_parser_expr");
}
if ( (_DWORD)v3 != 1 )
{
if ( (_DWORD)v3 == 2 )
{
LABEL_6:
internal_error("generate_parser_expr");
v3 = *(unsigned int *)a1;
}
return bad_tag(v3, "generate_parser_expr");
}
result = func7((__int64)a1[1], a2);
}
}
return result;
}

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, 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 func10(const char **a1, int a2, 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 {");
func9(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: i int

variable_types:
e
struct expr_rec *


decompiled_code:
__int64 __fastcall generate_parser_alts(__int64 a1)
{
unsigned int *v1; // rbp
__int64 result; // rax
__int64 v3; // rbx
int v4; // esi
int ***v5; // rax

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

canonical_decompiled_code:
__int64 __fastcall func11(__int64 a1)
{
unsigned int *v1; // rbp
__int64 result; // rax
__int64 v3; // rbx
int v4; // esi
int ***v5; // rax

v1 = *(unsigned int **)(a1 + 8);
result = *v1;
if ( (int)result > 0 )
{
v3 = 0LL;
do
{
v4 = v3;
v5 = *(int ****)(*((_QWORD *)v1 + 1) + 8 * v3++);
result = func10((const char **)a1, v4, *v5);
}
while ( (int)*v1 > (int)v3 );
}
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) )
{
result = *((unsigned int *)a1 + 17);
if ( (_DWORD)result )
{
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 func12(const char **a1)
{
__int64 result; // rax

if ( !*((_DWORD *)a1 + 4) && *((_DWORD *)a1 + 12) )
{
result = *((unsigned int *)a1 + 17);
if ( (_DWORD)result )
{
code_line("static void recbup_%s_value ()", *a1);
code_line("\t{");
func11((__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 result; // rax
__int64 v1; // rbx
const char **v2; // rdi

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

canonical_decompiled_code:
__int64 func13()
{
__int64 result; // rax
__int64 v1; // rbx
const char **v2; // rdi

result = nr_of_meta_rules;
if ( nr_of_meta_rules > 0 )
{
v1 = 0LL;
do
{
v2 = *(const char ***)(all_meta_rules + 8 * v1++);
result = func12(v2);
}
while ( nr_of_meta_rules > (int)v1 );
}
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)
{
__int64 v2; // rsi
int v3; // ebx
__int64 v4; // rbp
__int64 v5; // rdi
unsigned int v7; // [rsp+Ch] [rbp-4Ch] BYREF
char s[72]; // [rsp+10h] [rbp-48h] BYREF

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

canonical_decompiled_code:
__int64 __fastcall func14(unsigned int *a1)
{
__int64 v2; // rsi
int v3; // ebx
__int64 v4; // rbp
__int64 v5; // rdi
unsigned int v7; // [rsp+Ch] [rbp-4Ch] BYREF
char s[72]; // [rsp+10h] [rbp-48h] BYREF

v2 = *a1;
v7 = 0;
code_line("\t\tif (v -> u.tuple -> size == %d)", v2);
code_line("\t\t {");
v3 = *a1 - 1;
if ( v3 >= 0 )
{
v4 = 8LL * v3;
do
{
sprintf(s, "v -> u.tuple -> array[%d]", (unsigned int)v3--);
v5 = *(_QWORD *)(*((_QWORD *)a1 + 1) + v4);
v4 -= 8LL;
func5(v5, s, &v7);
}
while ( v3 != -1 );
}
code_line("\t\t callq ();");
code_line("\t\t pop (%d);", v7);
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(__int64 a1, int a2, int **a3)
{
__int64 v5; // rdi

if ( qstackflag )
{
code_line("\t { cont *lqptr = qptr;");
if ( a3 )
goto LABEL_3;
LABEL_15:
code_line("\t\tpushv (v);");
code_line("\t\tpushq (rec_empty_value);");
code_line("\t\tcallq ();");
code_line("\t\tpop (2);");
goto LABEL_8;
}
code_line("\t {");
if ( !a3 )
goto LABEL_15;
LABEL_3:
v5 = *(unsigned int *)a3;
if ( (_DWORD)v5 == 3 )
{
generate_rec_concat_isra_0(*(_DWORD *)(a1 + 20), a3[1]);
}
else
{
if ( (int)v5 > 3 )
{
if ( (_DWORD)v5 == 4 )
{
internal_error("generate_rec_expr");
v5 = *(unsigned int *)a3;
}
goto LABEL_12;
}
if ( (_DWORD)v5 != 1 )
{
if ( (_DWORD)v5 == 2 )
{
generate_rec_compos((unsigned int *)a3[1]);
goto LABEL_8;
}
LABEL_12:
bad_tag(v5, "generate_rec_expr");
if ( !qstackflag )
return code_line("\t };");
goto LABEL_13;
}
generate_rec_single((__int64)a3[1]);
}
LABEL_8:
if ( !qstackflag )
return code_line("\t };");
LABEL_13:
generate_qstack_mcheck((const char **)a1, a2, 0);
return code_line("\t };");
}

canonical_decompiled_code:
__int64 __fastcall func16(__int64 a1, int a2, int **a3)
{
__int64 v5; // rdi

if ( qstackflag )
{
code_line("\t { cont *lqptr = qptr;");
if ( a3 )
goto LABEL_3;
LABEL_15:
code_line("\t\tpushv (v);");
code_line("\t\tpushq (rec_empty_value);");
code_line("\t\tcallq ();");
code_line("\t\tpop (2);");
goto LABEL_8;
}
code_line("\t {");
if ( !a3 )
goto LABEL_15;
LABEL_3:
v5 = *(unsigned int *)a3;
if ( (_DWORD)v5 == 3 )
{
func15(*(_DWORD *)(a1 + 20), a3[1]);
}
else
{
if ( (int)v5 > 3 )
{
if ( (_DWORD)v5 == 4 )
{
internal_error("generate_rec_expr");
v5 = *(unsigned int *)a3;
}
goto LABEL_12;
}
if ( (_DWORD)v5 != 1 )
{
if ( (_DWORD)v5 == 2 )
{
func14((unsigned int *)a3[1]);
goto LABEL_8;
}
LABEL_12:
bad_tag(v5, "generate_rec_expr");
if ( !qstackflag )
return code_line("\t };");
goto LABEL_13;
}
func6((__int64)a3[1]);
}
LABEL_8:
if ( !qstackflag )
return code_line("\t };");
LABEL_13:
func2((const char **)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
int v3; // esi
int ***v4; // rax

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

canonical_decompiled_code:
__int64 __fastcall func17(__int64 a1)
{
__int64 result; // rax
__int64 v2; // rbx
int v3; // esi
int ***v4; // rax

result = *(_QWORD *)(a1 + 8);
if ( *(int *)result > 0 )
{
v2 = 0LL;
do
{
v3 = v2;
v4 = *(int ****)(*(_QWORD *)(result + 8) + 8 * v2++);
func16(a1, v3, *v4);
result = *(_QWORD *)(a1 + 8);
}
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
__int64 result; // rax

v1 = *(_QWORD *)(a1 + 40);
if ( !v1 )
goto LABEL_4;
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 ();");
result = code_line("\t };");
}
else
{
if ( v2 != 2 )
{
LABEL_4:
code_line("\t {");
generate_rec_alts(a1);
return code_line("\t };");
}
code_line("\t { if (v -> u.inum == %d) callq ();", *(unsigned int *)(v1 + 24));
result = code_line("\t };");
}
return result;
}

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

v1 = *(_QWORD *)(a1 + 40);
if ( !v1 )
goto LABEL_4;
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 ();");
result = code_line("\t };");
}
else
{
if ( v2 != 2 )
{
LABEL_4:
code_line("\t {");
func17(a1);
return code_line("\t };");
}
code_line("\t { if (v -> u.inum == %d) callq ();", *(unsigned int *)(v1 + 24));
result = code_line("\t };");
}
return result;
}

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
const char **v1; // rdi

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

canonical_decompiled_code:
void func20()
{
__int64 v0; // rbx
const char **v1; // rdi

if ( nr_of_meta_rules > 0 )
{
v0 = 0LL;
do
{
v1 = *(const char ***)(all_meta_rules + 8 * v0++);
func19(v1);
}
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 func13();
}

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:
_QWORD *new_int_list()
{
_QWORD *v0; // r12

v0 = (_QWORD *)ckmalloc(16LL);
*v0 = 0x200000000LL;
v0[1] = ckcalloc(2LL, 4LL);
return v0;
}

canonical_decompiled_code:
_QWORD *func1()
{
_QWORD *v0; // r12

v0 = (_QWORD *)ckmalloc(16LL);
*v0 = 0x200000000LL;
v0[1] = 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 func2(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(int *a1, int a2)
{
__int64 v3; // rsi
__int64 result; // rax

v3 = *a1;
if ( (_DWORD)v3 == a1[1] )
{
room_int_list((__int64)a1, (unsigned int)(2 * v3));
v3 = *a1;
}
result = *((_QWORD *)a1 + 1);
*(_DWORD *)(result + 4 * v3) = a2;
++*a1;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(int *a1, int a2)
{
__int64 v3; // rsi
__int64 result; // rax

v3 = *a1;
if ( (_DWORD)v3 == a1[1] )
{
func0((__int64)a1, (unsigned int)(2 * v3));
v3 = *a1;
}
result = *((_QWORD *)a1 + 1);
*(_DWORD *)(result + 4 * v3) = a2;
++*a1;
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(int *a1, __int64 a2)
{
__int64 v2; // rdx
__int64 v3; // rdi
__int64 v4; // rcx
__int64 v5; // rax
int v6; // esi

if ( !a1 || !a2 )
return 0LL;
v2 = *a1;
if ( (_DWORD)v2 != *(_DWORD *)a2 )
return (int)v2 < *(_DWORD *)a2;
if ( (int)v2 <= 0 )
return 0LL;
v3 = *((_QWORD *)a1 + 1);
v4 = *(_QWORD *)(a2 + 8);
v5 = 0LL;
while ( 1 )
{
v6 = *(_DWORD *)(v4 + 4 * v5);
if ( *(_DWORD *)(v3 + 4 * v5) < v6 )
break;
if ( *(_DWORD *)(v3 + 4 * v5) <= v6 && ++v5 != v2 )
continue;
return 0LL;
}
return 1LL;
}

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(int *a1, __int64 a2)
{
__int64 v2; // rdx
__int64 result; // rax
__int64 v4; // rdi
__int64 v5; // rax

if ( a1 && a2 )
{
v2 = *a1;
result = 0LL;
if ( (_DWORD)v2 != *(_DWORD *)a2 )
return result;
if ( (int)v2 <= 0 )
return 1LL;
v4 = *((_QWORD *)a1 + 1);
v5 = 0LL;
while ( *(_DWORD *)(v4 + 4 * v5) == *(_DWORD *)(*(_QWORD *)(a2 + 8) + 4 * v5) )
{
if ( ++v5 == v2 )
return 1LL;
}
}
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func5(int *a1, __int64 a2)
{
__int64 v2; // rdx
__int64 result; // rax
__int64 v4; // rdi
__int64 v5; // rax

if ( a1 && a2 )
{
v2 = *a1;
result = 0LL;
if ( (_DWORD)v2 != *(_DWORD *)a2 )
return result;
if ( (int)v2 <= 0 )
return 1LL;
v4 = *((_QWORD *)a1 + 1);
v5 = 0LL;
while ( *(_DWORD *)(v4 + 4 * v5) == *(_DWORD *)(*(_QWORD *)(a2 + 8) + 4 * v5) )
{
if ( ++v5 == v2 )
return 1LL;
}
}
return 0LL;
}

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);
}


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:
_QWORD *new_string_list()
{
_QWORD *v0; // r12

v0 = (_QWORD *)ckmalloc(16LL);
*v0 = 0x200000000LL;
v0[1] = ckcalloc(2LL, 8LL);
return v0;
}

canonical_decompiled_code:
_QWORD *func9()
{
_QWORD *v0; // r12

v0 = (_QWORD *)ckmalloc(16LL);
*v0 = 0x200000000LL;
v0[1] = 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 func10(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)
{
int v3; // esi
__int64 result; // rax

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

canonical_decompiled_code:
__int64 __fastcall func11(__int64 a1, __int64 a2)
{
int v3; // esi
__int64 result; // rax

v3 = *(_DWORD *)a1;
if ( *(_DWORD *)a1 == *(_DWORD *)(a1 + 4) )
{
func8(a1, (unsigned int)(2 * v3));
v3 = *(_DWORD *)a1;
}
result = *(_QWORD *)(a1 + 8);
*(_QWORD *)(result + 8LL * v3) = a2;
*(_DWORD *)a1 = v3 + 1;
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:
int __fastcall less_string_list(int *a1, __int64 a2)
{
__int64 v2; // rbp
__int64 v3; // r13
__int64 v4; // r12
__int64 v5; // rbx
int result; // eax

if ( !a1 || !a2 )
return 0;
v2 = *a1;
if ( (_DWORD)v2 != *(_DWORD *)a2 )
return (int)v2 < *(_DWORD *)a2;
if ( (int)v2 <= 0 )
return 0;
v3 = *(_QWORD *)(a2 + 8);
v4 = *((_QWORD *)a1 + 1);
v5 = 0LL;
while ( 1 )
{
result = strcmp(*(const char **)(v4 + 8 * v5), *(const char **)(v3 + 8 * v5));
if ( result < 0 )
break;
if ( result )
return 0;
if ( v2 == ++v5 )
return result;
}
return 1;
}

canonical_decompiled_code:
int __fastcall func12(int *a1, __int64 a2)
{
__int64 v2; // rbp
__int64 v3; // r13
__int64 v4; // r12
__int64 v5; // rbx
int result; // eax

if ( !a1 || !a2 )
return 0;
v2 = *a1;
if ( (_DWORD)v2 != *(_DWORD *)a2 )
return (int)v2 < *(_DWORD *)a2;
if ( (int)v2 <= 0 )
return 0;
v3 = *(_QWORD *)(a2 + 8);
v4 = *((_QWORD *)a1 + 1);
v5 = 0LL;
while ( 1 )
{
result = strcmp(*(const char **)(v4 + 8 * v5), *(const char **)(v3 + 8 * v5));
if ( result < 0 )
break;
if ( result )
return 0;
if ( v2 == ++v5 )
return result;
}
return 1;
}

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: stat int


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

if ( !a1 || !a2 )
return 0LL;
result = 0LL;
v3 = *a1;
if ( (_DWORD)v3 == *(_DWORD *)a2 )
{
if ( (int)v3 <= 0 )
{
LABEL_11:
result = 1LL;
}
else
{
v4 = *(_QWORD *)(a2 + 8);
v5 = *((_QWORD *)a1 + 1);
v6 = 0LL;
while ( !strcmp(*(const char **)(v5 + 8 * v6), *(const char **)(v4 + 8 * v6)) )
{
if ( v3 == ++v6 )
goto LABEL_11;
}
result = 0LL;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func13(int *a1, __int64 a2)
{
__int64 result; // rax
__int64 v3; // rbp
__int64 v4; // r13
__int64 v5; // r12
__int64 v6; // rbx

if ( !a1 || !a2 )
return 0LL;
result = 0LL;
v3 = *a1;
if ( (_DWORD)v3 == *(_DWORD *)a2 )
{
if ( (int)v3 <= 0 )
{
LABEL_11:
result = 1LL;
}
else
{
v4 = *(_QWORD *)(a2 + 8);
v5 = *((_QWORD *)a1 + 1);
v6 = 0LL;
while ( !strcmp(*(const char **)(v5 + 8 * v6), *(const char **)(v4 + 8 * v6)) )
{
if ( v3 == ++v6 )
goto LABEL_11;
}
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 func16(__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)
{
__int64 v2; // rdx
__int64 result; // rax

v2 = *(int *)(a2 + 32);
if ( (int)v2 <= 0 )
return 0xFFFFFFFFLL;
result = 0LL;
while ( *(_QWORD *)(*(_QWORD *)(a2 + 40) + 8 * result) != a1 )
{
if ( ++result == v2 )
return 0xFFFFFFFFLL;
}
return (unsigned int)result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 a2)
{
__int64 v2; // rdx
__int64 result; // rax

v2 = *(int *)(a2 + 32);
if ( (int)v2 <= 0 )
return 0xFFFFFFFFLL;
result = 0LL;
while ( *(_QWORD *)(*(_QWORD *)(a2 + 40) + 8 * result) != a1 )
{
if ( ++result == v2 )
return 0xFFFFFFFFLL;
}
return (unsigned int)result;
}

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

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

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

result = &tracing;
indent = 0;
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 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 link_rec { struct pos_rec *pos; int side; struct link_rec *next; }


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: 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; // ebx
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; // ebx
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; // ebx
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; // ebx
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++;
 }


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);
 }

variable_types: i int


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:
s
char *

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:
void dump_lattices()
{
void *v0; // rcx
void *v1; // rdx
__int64 v2; // rsi
__int64 v3; // rax
__int64 v4; // r15
__int64 v5; // r12
__int64 v6; // rbp
unsigned int v7; // ebx
const char *v8; // rsi
const char *v9; // rdx

if ( full_verbose )
{
v0 = &unk_7F4;
v1 = &unk_7F9;
v2 = *(unsigned int *)all_element_sets;
if ( (_DWORD)v2 != 1 )
v1 = &unk_7F7;
if ( (_DWORD)v2 == 1 )
v0 = &unk_7F7;
wlog("%d (super) lattice%s ha%s been found:", v2, v1, v0);
v3 = all_element_sets;
if ( *(int *)all_element_sets > 0 )
{
v4 = 0LL;
do
{
v5 = *(_QWORD *)(*(_QWORD *)(*(_QWORD *)(v3 + 8) + 8 * v4) + 8LL);
eprint_log("{ ");
if ( *(int *)v5 > 0 )
{
v6 = 8LL;
v7 = 0;
v8 = (const char *)&unk_7F9;
v9 = ***(const char ****)(v5 + 8);
while ( 1 )
{
eprint_log("%s%s (%d)", v8, v9, v7++);
if ( *(_DWORD *)v5 <= (signed int)v7 )
break;
v8 = ", ";
v9 = **(const char ***)(*(_QWORD *)(v5 + 8) + v6);
if ( -858993459 * v7 < 0x33333334 )
v8 = ",\n ";
v6 += 8LL;
}
}
++v4;
eprint_log(" }\n");
v3 = all_element_sets;
}
while ( *(_DWORD *)all_element_sets > (int)v4 );
}
}
}

canonical_decompiled_code:
void func1()
{
void *v0; // rcx
void *v1; // rdx
__int64 v2; // rsi
__int64 v3; // rax
__int64 v4; // r15
__int64 v5; // r12
__int64 v6; // rbp
unsigned int v7; // ebx
const char *v8; // rsi
const char *v9; // rdx

if ( full_verbose )
{
v0 = &unk_7F4;
v1 = &unk_7F9;
v2 = *(unsigned int *)all_element_sets;
if ( (_DWORD)v2 != 1 )
v1 = &unk_7F7;
if ( (_DWORD)v2 == 1 )
v0 = &unk_7F7;
wlog("%d (super) lattice%s ha%s been found:", v2, v1, v0);
v3 = all_element_sets;
if ( *(int *)all_element_sets > 0 )
{
v4 = 0LL;
do
{
v5 = *(_QWORD *)(*(_QWORD *)(*(_QWORD *)(v3 + 8) + 8 * v4) + 8LL);
eprint_log("{ ");
if ( *(int *)v5 > 0 )
{
v6 = 8LL;
v7 = 0;
v8 = (const char *)&unk_7F9;
v9 = ***(const char ****)(v5 + 8);
while ( 1 )
{
eprint_log("%s%s (%d)", v8, v9, v7++);
if ( *(_DWORD *)v5 <= (signed int)v7 )
break;
v8 = ", ";
v9 = **(const char ***)(*(_QWORD *)(v5 + 8) + v6);
if ( -858993459 * v7 < 0x33333334 )
v8 = ",\n ";
v6 += 8LL;
}
}
++v4;
eprint_log(" }\n");
v3 = all_element_sets;
}
while ( *(_DWORD *)all_element_sets > (int)v4 );
}
}
}

original_code:
static void dump_lattices ()
 { int ix;
   if (!full_verbose) return;
   wlog ("%d (super) lattice%s ha%s been found:",
  all_element_sets -> size,
  (all_element_sets -> size == 1)?"":"s",
  (all_element_sets -> size == 1)?"s":"ve");
   for (ix = 0; ix < all_element_sets -> size; ix++)
      { element_def_list defs = all_element_sets -> array[ix] -> defs;
        int iy;
        eprint_log ("{ ");
        for (iy = 0; iy < defs -> size; iy++)
    eprint_log ("%s%s (%d)", ((!iy)?"":(!(iy % 5))?",\n  ":", "),
        defs -> array[iy] -> eltnm, iy);
        eprint_log (" }\n");
      };
 }

canonical_original_code:
static void dump_lattices()
 { int ix;
   if (!full_verbose) return;
   wlog ("%d (super) lattice%s ha%s been found:",
  all_element_sets -> size,
  (all_element_sets -> size == 1)?"":"s",
  (all_element_sets -> size == 1)?"s":"ve");
   for (ix = 0; ix < all_element_sets -> size; ix++)
      { struct element_def_list_rec *defs = all_element_sets -> array[ix] -> defs;
        int iy;
        eprint_log ("{ ");
        for (iy = 0; iy < defs -> size; iy++)
    eprint_log ("%s%s (%d)", ((!iy)?"":(!(iy % 5))?",\n  ":", "),
        defs -> array[iy] -> eltnm, iy);
        eprint_log (" }\n");
      };
 }

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


decompiled_code:
void assign_element_numbers()
{
__int64 v0; // rbx
__int64 v1; // rax

all_element_sets = new_element_set_list();
if ( nr_of_elements > 0 )
{
v0 = 0LL;
do
{
v1 = *(_QWORD *)(all_elements + 8 * v0++);
assign_numbers_to_group_isra_0(*(_DWORD *)(v1 + 12), *(_QWORD *)(v1 + 16));
}
while ( nr_of_elements > (int)v0 );
}
}

canonical_decompiled_code:
void func3()
{
__int64 v0; // rbx
__int64 v1; // rax

all_element_sets = new_element_set_list();
if ( nr_of_elements > 0 )
{
v0 = 0LL;
do
{
v1 = *(_QWORD *)(all_elements + 8 * v0++);
func2(*(_DWORD *)(v1 + 12), *(_QWORD *)(v1 + 16));
}
while ( nr_of_elements > (int)v0 );
}
}

original_code:
static void assign_element_numbers ()
 { int ix;
   all_element_sets = new_element_set_list ();
   for (ix = 0; ix < nr_of_elements; ix++)
      assign_numbers_to_group (all_elements[ix]);
 }

canonical_original_code:
static void assign_element_numbers()
 { int ix;
   all_element_sets = new_element_set_list ();
   for (ix = 0; ix < nr_of_elements; ix++)
      assign_numbers_to_group (all_elements[ix]);
 }


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

v2 = *(_DWORD *)(a1 + 40);
if ( !v2 )
return construct_lattice_from_variable_isra_0(*(_QWORD *)a1, *(_QWORD *)(a1 + 64), a2);
if ( v2 == 5 )
return construct_lattice_from_element_isra_0(*(_QWORD *)(a1 + 56), a2);
bad_tag(v2, "construct_lattice_in_affix");
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1, __int64 a2)
{
unsigned int v2; // er8

v2 = *(_DWORD *)(a1 + 40);
if ( !v2 )
return func5(*(_QWORD *)a1, *(_QWORD *)(a1 + 64), a2);
if ( v2 == 5 )
return func4(*(_QWORD *)(a1 + 56), a2);
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 variable_rec { char *nonterminal; char *suffix; struct meta_rule_rec *def; }

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; }


decompiled_code:
__int64 __fastcall construct_lattices_in_affixes(__int64 a1, __int64 a2)
{
__int64 v3; // rbx
__int64 v4; // rdi
__int64 result; // rax

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

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1, __int64 a2)
{
__int64 v3; // rbx
__int64 v4; // rdi
__int64 result; // rax

if ( *(int *)a1 <= 0 )
return a2;
v3 = 0LL;
do
{
v4 = *(_QWORD *)(*(_QWORD *)(a1 + 8) + 8 * v3++);
result = func6(v4, a2);
a2 = result;
}
while ( *(_DWORD *)a1 > (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 meta_alt_list_rec { int size; int room; struct meta_alt_rec **array; }


decompiled_code:
__int64 __fastcall construct_lattices_in_expr(unsigned int *a1, __int64 a2)
{
__int64 v3; // rdi

if ( !a1 )
internal_error("construct_lattices_in_expr");
v3 = *a1;
if ( (_DWORD)v3 == 1 )
return construct_lattice_in_affix(*((_QWORD *)a1 + 1), a2);
if ( (_DWORD)v3 == 4 )
return construct_lattices_in_affixes(*((_QWORD *)a1 + 1), a2);
bad_tag(v3, "construct_lattices_in_expr");
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func8(unsigned int *a1, __int64 a2)
{
__int64 v3; // rdi

if ( !a1 )
internal_error("construct_lattices_in_expr");
v3 = *a1;
if ( (_DWORD)v3 == 1 )
return func6(*((_QWORD *)a1 + 1), a2);
if ( (_DWORD)v3 == 4 )
return func7(*((_QWORD *)a1 + 1), a2);
bad_tag(v3, "construct_lattices_in_expr");
return 0LL;
}

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 element_def_rec { char *eltnm; int number; int eltnr; struct element_set_rec *set; }


decompiled_code:
__int64 __fastcall construct_lattices_in_meta_alts(__int64 a1, __int64 a2)
{
__int64 v2; // rbx
unsigned int **v3; // rax
__int64 result; // rax

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

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

if ( *(int *)a1 <= 0 )
return a2;
v2 = 0LL;
do
{
v3 = *(unsigned int ***)(*(_QWORD *)(a1 + 8) + 8 * v2++);
result = func8(*v3, a2);
a2 = result;
}
while ( *(_DWORD *)a1 > (int)v2 );
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_set_rec { int number; struct element_def_list_rec *defs; }


decompiled_code:
__int64 __fastcall construct_lattices_in_meta_rule(__int64 a1)
{
__int64 result; // rax
__int64 v2; // rbp

result = *(unsigned int *)(a1 + 16);
if ( *(_QWORD *)(a1 + 16) == 0x1000000000LL )
{
v2 = *(_QWORD *)(a1 + 56);
if ( v2 )
v2 = *(_QWORD *)(v2 + 16);
result = construct_lattices_in_meta_alts(*(_QWORD *)(a1 + 8), v2);
if ( v2 != result )
{
change = 1;
result = **(_QWORD **)(*(_QWORD *)(result + 8) + 8LL);
*(_QWORD *)(a1 + 56) = result;
}
}
return result;
}

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 meta_alt_rec { struct expr_rec *e; int number; }

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


decompiled_code:
__int64 construct_lattices_in_meta_rules()
{
__int64 result; // rax
__int64 v1; // rbx
__int64 v2; // rdi

result = nr_of_meta_rules;
if ( nr_of_meta_rules > 0 )
{
v1 = 0LL;
do
{
v2 = *(_QWORD *)(all_meta_rules + 8 * v1++);
result = construct_lattices_in_meta_rule(v2);
}
while ( nr_of_meta_rules > (int)v1 );
}
return result;
}

canonical_decompiled_code:
__int64 func11()
{
__int64 result; // rax
__int64 v1; // rbx
__int64 v2; // rdi

result = nr_of_meta_rules;
if ( nr_of_meta_rules > 0 )
{
v1 = 0LL;
do
{
v2 = *(_QWORD *)(all_meta_rules + 8 * v1++);
result = func10(v2);
}
while ( nr_of_meta_rules > (int)v1 );
}
return result;
}

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

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


decompiled_code:
__int64 __fastcall construct_lattices_in_display(__int64 a1, unsigned int *a2)
{
__int64 result; // rax
__int64 v4; // rbx
__int64 v5; // rdi
__int64 v6; // rax

result = *a2;
if ( (int)result > 0 )
{
v4 = 0LL;
do
{
while ( 1 )
{
result = *(_QWORD *)(a1 + 8);
v5 = *(_QWORD *)(result + 8 * v4);
if ( (*(_BYTE *)(v5 + 16) & 0x10) != 0 )
break;
if ( (int)*a2 <= (int)++v4 )
return result;
}
v6 = *(_QWORD *)(*((_QWORD *)a2 + 1) + 8 * v4++);
result = construct_lattices_in_position_isra_0(v5, *(unsigned int **)(v6 + 8));
}
while ( (int)*a2 > (int)v4 );
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func13(__int64 a1, unsigned int *a2)
{
__int64 result; // rax
__int64 v4; // rbx
__int64 v5; // rdi
__int64 v6; // rax

result = *a2;
if ( (int)result > 0 )
{
v4 = 0LL;
do
{
while ( 1 )
{
result = *(_QWORD *)(a1 + 8);
v5 = *(_QWORD *)(result + 8 * v4);
if ( (*(_BYTE *)(v5 + 16) & 0x10) != 0 )
break;
if ( (int)*a2 <= (int)++v4 )
return result;
}
v6 = *(_QWORD *)(*((_QWORD *)a2 + 1) + 8 * v4++);
result = func12(v5, *(unsigned int **)(v6 + 8));
}
while ( (int)*a2 > (int)v4 );
}
return result;
}

original_code:
static void construct_lattices_in_display (pos_list protodpy, pos_list dpy)
 { int ix;
   for (ix = 0; ix < dpy -> size; ix++)
      { pos protopos = protodpy -> array[ix];
        if (protopos -> type & 16)
    construct_lattices_in_position (protopos, dpy -> array[ix]);
      };
 }

canonical_original_code:
static void construct_lattices_in_display(struct pos_list_rec *protodpy, struct pos_list_rec *dpy)
 { int ix;
   for (ix = 0; ix < dpy -> size; ix++)
      { struct pos_rec *protopos = protodpy -> array[ix];
        if (protopos -> type & 16)
    construct_lattices_in_position (protopos, dpy -> array[ix]);
      };
 }

variable_types: struct pos_list_rec { int size; int room; struct pos_rec { int kind; 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; } *ex; int type; struct element_def_rec *lat_repr; } **array; } *

variable_types:
dpy
struct pos_list_rec *

user_defined_types: struct pos_list_rec { int size; int room; struct pos_rec **array; }

user_defined_types: struct pos_rec { int kind; struct expr_rec *ex; int type; struct element_def_rec *lat_repr; }

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; }