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

result = is_an_invisible_member(a1);
if ( !(_DWORD)result )
{
result = *(unsigned int *)(a1 + 24);
if ( (_DWORD)result )
{
if ( (_DWORD)result == 1 )
result = output_unquoted_string(out, *(_QWORD *)(a1 + 32));
}
else
{
result = code_string("%s%s%s", "<|", *(const char **)(a1 + 32), "|>");
}
}
return result;
}

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

result = is_an_invisible_member(a1);
if ( !(_DWORD)result )
{
result = *(unsigned int *)(a1 + 24);
if ( (_DWORD)result )
{
if ( (_DWORD)result == 1 )
result = output_unquoted_string(out, *(_QWORD *)(a1 + 32));
}
else
{
result = code_string("%s%s%s", "<|", *(const char **)(a1 + 32), "|>");
}
}
return result;
}

original_code:
static void generate_template_member (member m)
 { if (is_an_invisible_member (m)) return;
   switch (m -> tag)
      { case 0:
    code_string ("%s%s%s", "<|",
          m -> u.call.nonterminal, "|>");
    break;
        case 1:
    output_unquoted_string (out, m -> u.terminal);
        default: break;
      };
 }

canonical_original_code:
static void generate_template_member(struct member_rec *m)
 { if (is_an_invisible_member (m)) return;
   switch (m -> tag)
      { case 0:
    code_string ("%s%s%s", "<|",
          m -> u.call.nonterminal, "|>");
    break;
        case 1:
    output_unquoted_string (out, m -> u.terminal);
        default: break;
      };
 }

variable_types: struct member_rec { int empty; int followlayout; char *first; int number; int sonnr; int tag; union { struct call_rec { char *nonterminal; 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; } *display; struct rule_rec { char *nonterminal; struct alt_list_rec { int size; int room; struct alt_rec { struct pos_list_rec *display; struct member_list_rec { int size; int room; struct member_rec **array; } *members; int number; int nodenr; int nrsons; struct affix_rec *locals; int empty; char *first; char *director; int rule_nr; } **array; } *alts; int kind; int empty; int lex; int ext; int number; int placeholder; int startswithlayout; int endsinlayout; char *first; char *follow; struct pos_list_rec *proto_display; int reachable; int has_sons; int goal; struct lextree_rec { char *remainder; struct lexend_list_rec { int size; int room; struct lexend_rec { int nodenr; struct int_list_rec *valuenrs; } **array; } *prods; struct lextree_list_rec { int size; int room; struct lextree_rec **array; } *tails; } *rev_tree; } *def; } call; char *terminal; struct semiterminal_rec { struct cset_rec *set; struct pos_list_rec *display; } semi; } u; } *

user_defined_types: struct call_rec { char *nonterminal; struct pos_list_rec *display; struct rule_rec *def; }

user_defined_types: struct rule_rec { char *nonterminal; struct alt_list_rec *alts; int kind; int empty; int lex; int ext; int number; int placeholder; int startswithlayout; int endsinlayout; char *first; char *follow; struct pos_list_rec *proto_display; int reachable; int has_sons; int goal; struct lextree_rec *rev_tree; }

user_defined_types: struct alt_list_rec { int size; int room; struct alt_rec **array; }

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

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


repo: tjordanchat/eag

decompiled_code:
int __fastcall generate_template_members(__int64 a1)
{
__int64 v1; // rbx
__int64 v2; // rbp
int result; // eax

if ( a1 && *(int *)a1 > 0 )
{
v1 = 0LL;
do
{
v2 = *(_QWORD *)(*(_QWORD *)(a1 + 8) + 8 * v1);
result = generate_template_member(v2);
if ( *(_DWORD *)(v2 + 4) )
result = fputc(32, out);
++v1;
}
while ( *(_DWORD *)a1 > (int)v1 );
}
return result;
}

canonical_decompiled_code:
int __fastcall func4(__int64 a1)
{
__int64 v1; // rbx
__int64 v2; // rbp
int result; // eax

if ( a1 && *(int *)a1 > 0 )
{
v1 = 0LL;
do
{
v2 = *(_QWORD *)(*(_QWORD *)(a1 + 8) + 8 * v1);
result = func3(v2);
if ( *(_DWORD *)(v2 + 4) )
result = fputc(32, out);
++v1;
}
while ( *(_DWORD *)a1 > (int)v1 );
}
return result;
}

original_code:
static void generate_template_members (member_list mems)
 { int ix;
   if (mems == ((member_list) ((void *)0))) return;
   for (ix = 0; ix < mems -> size; ix++)
      { member m = mems -> array[ix];
        generate_template_member (m);
        if (m -> followlayout) fputc (' ', out);
      };
 }

canonical_original_code:
static void generate_template_members(struct member_list_rec *mems)
 { int ix;
   if (mems == ((member_list) ((void *)0))) return;
   for (ix = 0; ix < mems -> size; ix++)
      { struct member_rec *m = mems -> array[ix];
        generate_template_member (m);
        if (m -> followlayout) fputc (' ', out);
      };
 }

variable_types: struct member_list_rec { int size; int room; struct member_rec { int empty; int followlayout; char *first; int number; int sonnr; int tag; union { struct call_rec { char *nonterminal; 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; } *display; struct rule_rec { char *nonterminal; struct alt_list_rec { int size; int room; struct alt_rec { struct pos_list_rec *display; struct member_list_rec *members; int number; int nodenr; int nrsons; struct affix_rec *locals; int empty; char *first; char *director; int rule_nr; } **array; } *alts; int kind; int empty; int lex; int ext; int number; int placeholder; int startswithlayout; int endsinlayout; char *first; char *follow; struct pos_list_rec *proto_display; int reachable; int has_sons; int goal; struct lextree_rec { char *remainder; struct lexend_list_rec { int size; int room; struct lexend_rec { int nodenr; struct int_list_rec *valuenrs; } **array; } *prods; struct lextree_list_rec { int size; int room; struct lextree_rec **array; } *tails; } *rev_tree; } *def; } call; char *terminal; struct semiterminal_rec { struct cset_rec *set; struct pos_list_rec *display; } semi; } u; } **array; } *

variable_types: ix int

return_type: void

user_defined_types: struct member_list_rec { int size; int room; struct member_rec **array; }

user_defined_types: struct member_rec { int empty; int followlayout; char *first; int number; int sonnr; int tag; union { struct call_rec call; char *terminal; struct semiterminal_rec semi; } u; }

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

user_defined_types: struct lextree_rec { char *remainder; struct lexend_list_rec *prods; struct lextree_list_rec *tails; }

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

user_defined_types: struct lexend_list_rec { int size; int room; struct lexend_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_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; }


decompiled_code:
size_t __fastcall generate_text_template(unsigned int a1, __int64 a2)
{
fprintf(out, "\t enter_template_in_list_text (%d, \"", a1);
generate_template_members(*(_QWORD *)(a2 + 8));
return fwrite("\");\n", 1uLL, 4uLL, out);
}

canonical_decompiled_code:
size_t __fastcall func5(unsigned int a1, __int64 a2)
{
fprintf(out, "\t enter_template_in_list_text (%d, \"", a1);
func4(*(_QWORD *)(a2 + 8));
return fwrite("\");\n", 1uLL, 4uLL, out);
}

original_code:
static void generate_text_template (int nodenr, alt a)
 { fprintf (out, "\t  enter_template_in_list_text (%d, \"", nodenr);
   generate_template_members (a -> members);
   fprintf (out, "\");\n");
 }

canonical_original_code:
static void generate_text_template(int nodenr, struct alt_rec *a)
 { fprintf (out, "\t  enter_template_in_list_text (%d, \"", nodenr);
   generate_template_members (a -> members);
   fprintf (out, "\");\n");
 }

variable_types: nodenr int

variable_types: struct alt_rec { 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; } *display; struct member_list_rec { int size; int room; struct member_rec { int empty; int followlayout; char *first; int number; int sonnr; int tag; union { struct call_rec { char *nonterminal; struct pos_list_rec *display; struct rule_rec { char *nonterminal; struct alt_list_rec { int size; int room; struct alt_rec **array; } *alts; int kind; int empty; int lex; int ext; int number; int placeholder; int startswithlayout; int endsinlayout; char *first; char *follow; struct pos_list_rec *proto_display; int reachable; int has_sons; int goal; struct lextree_rec { char *remainder; struct lexend_list_rec { int size; int room; struct lexend_rec { int nodenr; struct int_list_rec *valuenrs; } **array; } *prods; struct lextree_list_rec { int size; int room; struct lextree_rec **array; } *tails; } *rev_tree; } *def; } call; char *terminal; struct semiterminal_rec { struct cset_rec *set; struct pos_list_rec *display; } semi; } u; } **array; } *members; int number; int nodenr; int nrsons; struct affix_rec *locals; int empty; char *first; char *director; int rule_nr; } *

user_defined_types: struct alt_rec { struct pos_list_rec *display; struct member_list_rec *members; int number; int nodenr; int nrsons; struct affix_rec *locals; int empty; char *first; char *director; int rule_nr; }

user_defined_types: struct call_rec { char *nonterminal; struct pos_list_rec *display; struct rule_rec *def; }


decompiled_code:
__int64 __fastcall enter_templates_of_alt(unsigned int a1, __int64 a2)
{
__int64 result; // rax
__int64 v3[4]; // [rsp+8h] [rbp-20h] BYREF

result = alt_contains_semiterminals(a2);
if ( !(_DWORD)result )
{
if ( (unsigned int)alt_is_single_call(a2, v3) )
result = check_to_generate_indirect_templates(a1, v3[0]);
else
result = generate_text_template(a1, a2);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func6(unsigned int a1, __int64 a2)
{
__int64 result; // rax
__int64 v3[4]; // [rsp+8h] [rbp-20h] BYREF

result = func0(a2);
if ( !(_DWORD)result )
{
if ( (unsigned int)func2(a2, v3) )
result = func10(a1, v3[0]);
else
result = func5(a1, a2);
}
return result;
}

original_code:
static void enter_templates_of_alt (int nodenr, alt a)
 { rule def;
   if (alt_contains_semiterminals (a)) return;
   if (alt_is_single_call (a, &def))
      check_to_generate_indirect_templates (nodenr, def);
   else generate_text_template (nodenr, a);
 }

canonical_original_code:
static void enter_templates_of_alt(int nodenr, struct alt_rec *a)
 { struct rule_rec *def;
   if (alt_contains_semiterminals (a)) return;
   if (alt_is_single_call (a, &def))
      check_to_generate_indirect_templates (nodenr, def);
   else generate_text_template (nodenr, a);
 }

variable_types: struct rule_rec { char *nonterminal; struct alt_list_rec { int size; int room; struct alt_rec { 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; } *display; struct member_list_rec { int size; int room; struct member_rec { int empty; int followlayout; char *first; int number; int sonnr; int tag; union { struct call_rec { char *nonterminal; struct pos_list_rec *display; struct rule_rec *def; } call; char *terminal; struct semiterminal_rec { struct cset_rec *set; struct pos_list_rec *display; } semi; } u; } **array; } *members; int number; int nodenr; int nrsons; struct affix_rec *locals; int empty; char *first; char *director; int rule_nr; } **array; } *alts; int kind; int empty; int lex; int ext; int number; int placeholder; int startswithlayout; int endsinlayout; char *first; char *follow; struct pos_list_rec *proto_display; int reachable; int has_sons; int goal; struct lextree_rec { char *remainder; struct lexend_list_rec { int size; int room; struct lexend_rec { int nodenr; struct int_list_rec *valuenrs; } **array; } *prods; struct lextree_list_rec { int size; int room; struct lextree_rec **array; } *tails; } *rev_tree; } *

user_defined_types: struct rule_rec { char *nonterminal; struct alt_list_rec *alts; int kind; int empty; int lex; int ext; int number; int placeholder; int startswithlayout; int endsinlayout; char *first; char *follow; struct pos_list_rec *proto_display; int reachable; int has_sons; int goal; struct lextree_rec *rev_tree; }

user_defined_types: struct alt_list_rec { int size; int room; struct alt_rec **array; }


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

if ( *(_DWORD *)(a1 + 36) )
result = enter_templates_of_rule_with_nodenr(*(_DWORD *)(**(_QWORD **)(*(_QWORD *)(a1 + 8) + 8LL) + 20LL) - 1, a1);
return result;
}

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

if ( *(_DWORD *)(a1 + 36) )
result = func7(*(_DWORD *)(**(_QWORD **)(*(_QWORD *)(a1 + 8) + 8LL) + 20LL) - 1, a1);
return result;
}

original_code:
static void enter_templates_of_rule (rule srule)
 { int nodenr;
   if (!srule -> placeholder) return;
   nodenr = srule -> alts -> array[0] -> nodenr - 1;
   enter_templates_of_rule_with_nodenr (nodenr, srule, 0);
 }

canonical_original_code:
static void enter_templates_of_rule(struct rule_rec *srule)
 { int nodenr;
   if (!srule -> placeholder) return;
   nodenr = srule -> alts -> array[0] -> nodenr - 1;
   enter_templates_of_rule_with_nodenr (nodenr, srule, 0);
 }

user_defined_types: struct lextree_list_rec { int size; int room; struct lextree_rec **array; }

user_defined_types: struct lexend_rec { int nodenr; struct int_list_rec *valuenrs; }

user_defined_types: struct semiterminal_rec { struct cset_rec *set; struct pos_list_rec *display; }

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

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

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

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


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

if ( nr_of_rules > 0 )
{
v0 = 0LL;
do
result = enter_templates_of_rule(*(_QWORD *)(all_rules + 8 * v0++));
while ( nr_of_rules > (int)v0 );
}
return result;
}

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

if ( nr_of_rules > 0 )
{
v0 = 0LL;
do
result = func8(*(_QWORD *)(all_rules + 8 * v0++));
while ( nr_of_rules > (int)v0 );
}
return result;
}

original_code:
static void enter_templates_of_rules ()
 { int ix;
   for (ix = 0; ix < nr_of_rules; ix++)
      enter_templates_of_rule (all_rules[ix]);
 }

canonical_original_code:
static void enter_templates_of_rules()
 { int ix;
   for (ix = 0; ix < nr_of_rules; ix++)
      enter_templates_of_rule (all_rules[ix]);
 }


decompiled_code:
int __fastcall check_to_generate_indirect_templates(unsigned int a1, const char **a2)
{
if ( indirect_templates )
enter_templates_of_rule_with_nodenr(a1, (__int64)a2);
return fprintf(out, "\t enter_template_in_list_text (%d, \"<|%s|>\");\n", a1, *a2);
}

canonical_decompiled_code:
int __fastcall func10(unsigned int a1, const char **a2)
{
if ( indirect_templates )
func7(a1, (__int64)a2);
return fprintf(out, "\t enter_template_in_list_text (%d, \"<|%s|>\");\n", a1, *a2);
}

original_code:
static void check_to_generate_indirect_templates (int nodenr, rule def)
 { if (indirect_templates)
      enter_templates_of_rule_with_nodenr (nodenr, def, 1);
   fprintf (out, "\t  enter_template_in_list_text (%d, \"<|%s|>\");\n",
    nodenr, def -> nonterminal);
 }

canonical_original_code:
static void check_to_generate_indirect_templates(int nodenr, struct rule_rec *def)
 { if (indirect_templates)
      enter_templates_of_rule_with_nodenr (nodenr, def, 1);
   fprintf (out, "\t  enter_template_in_list_text (%d, \"<|%s|>\");\n",
    nodenr, def -> nonterminal);
 }

user_defined_types: struct lextree_rec { char *remainder; struct lexend_list_rec *prods; struct lextree_list_rec *tails; }

user_defined_types: struct lexend_list_rec { int size; int room; struct lexend_rec **array; }

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

user_defined_types: struct member_list_rec { int size; int room; struct member_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 member_rec { int empty; int followlayout; char *first; int number; int sonnr; int tag; union { struct call_rec call; char *terminal; struct semiterminal_rec semi; } u; }

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

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

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

user_defined_types: struct 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; }


decompiled_code:
size_t generate_enter_templates()
{
warning("coding templates table...");
fwrite("static void enter_templates ()\n", 1uLL, 0x1FuLL, out);
fwrite("\t{\n", 1uLL, 3uLL, out);
enter_templates_of_rules();
return fwrite("\t};\n\n", 1uLL, 5uLL, out);
}

canonical_decompiled_code:
size_t func11()
{
warning("coding templates table...");
fwrite("static void enter_templates ()\n", 1uLL, 0x1FuLL, out);
fwrite("\t{\n", 1uLL, 3uLL, out);
func9();
return fwrite("\t};\n\n", 1uLL, 5uLL, out);
}

original_code:
void generate_enter_templates ()
 { warning ("coding templates table...");
   fprintf (out, "static void enter_templates ()\n");
   fprintf (out, "\t{\n");
   enter_templates_of_rules ();
   fprintf (out, "\t};\n\n");
 }

canonical_original_code:
void generate_enter_templates()
 { warning ("coding templates table...");
   fprintf (out, "static void enter_templates ()\n");
   fprintf (out, "\t{\n");
   enter_templates_of_rules ();
   fprintf (out, "\t};\n\n");
 }


decompiled_code:
__int64 __fastcall generate_lr_parser(__int64 a1, __int64 a2)
{
full_verbose = 1;
verbose = 1;
warning("generating lr parser...");
open_output_file(a1, "lr", "c");
generate_std_includes(a2);
generate_meta_rules();
return close_output_file();
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 a2)
{
full_verbose = 1;
verbose = 1;
warning("generating lr parser...");
open_output_file(a1, "lr", "c");
generate_std_includes(a2);
generate_meta_rules();
return close_output_file();
}

original_code:
void generate_lr_parser (string fname, string_list predefs)
 { full_verbose = 1; verbose = 1;
   warning ("generating lr parser...");
   open_output_file (fname, "lr", "c");
   generate_std_includes (predefs);
   generate_meta_rules ();
   close_output_file ();
 }

canonical_original_code:
void generate_lr_parser(char *fname, struct string_list_rec *predefs)
 { full_verbose = 1; verbose = 1;
   warning ("generating lr parser...");
   open_output_file (fname, "lr", "c");
   generate_std_includes (predefs);
   generate_meta_rules ();
   close_output_file ();
 }

variable_types:
fname
char *

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


decompiled_code:
int __fastcall open_rule_file(const char *a1)
{
char v2[1032]; // [rsp+0h] [rbp-408h] BYREF

sprintf(v2, "%s.rules", a1);
rfile = fopen(v2, "w");
if ( !rfile )
panic("can't open rulefile %s", v2);
code_rule("number of rules: %d\n", max_nodenr);
return code_rule("number of tuples: %d\n", max_members_per_alt);
}

canonical_decompiled_code:
int __fastcall func2(const char *a1)
{
char v2[1032]; // [rsp+0h] [rbp-408h] BYREF

sprintf(v2, "%s.rules", a1);
rfile = fopen(v2, "w");
if ( !rfile )
panic("can't open rulefile %s", v2);
func1("number of rules: %d\n", max_nodenr);
return func1("number of tuples: %d\n", max_members_per_alt);
}

original_code:
static void open_rule_file (string gram)
 { char totalname[1024];
   sprintf (totalname, "%s.rules", gram);
   if (!(rfile = fopen (totalname, "w")))
      panic ("can't open rulefile %s", totalname);
   code_rule ("number of rules: %d\n", max_nodenr);
   code_rule ("number of tuples: %d\n", max_members_per_alt);
 }

canonical_original_code:
static void open_rule_file(char *gram)
 { char totalname[1024];
   sprintf (totalname, "%s.rules", gram);
   if (!(rfile = fopen (totalname, "w")))
      panic ("can't open rulefile %s", totalname);
   code_rule ("number of rules: %d\n", max_nodenr);
   code_rule ("number of tuples: %d\n", max_members_per_alt);
 }

variable_types:
gram
char *

variable_types:
totalname
char [1024]


decompiled_code:
int generate_unparsing_rule_for_startrule()
{
code_rule("type 0, 1\n");
code_rule("::\n");
return code_rule("%s%s%s\n", "<|", *(const char **)(start_rule + 32LL), "|>");
}

original_code:
static void generate_unparsing_rule_for_startrule ()
 { code_rule ("type 0, 1\n");
   code_rule ("::\n");
   code_rule ("%s%s%s\n", "<|",
       start_rule -> u.call.nonterminal, "|>");
 }

canonical_original_code:
static void generate_unparsing_rule_for_startrule()
 { code_rule ("type 0, 1\n");
   code_rule ("::\n");
   code_rule ("%s%s%s\n", "<|",
       start_rule -> u.call.nonterminal, "|>");
 }


decompiled_code:
int __fastcall generate_default_horizontal_rule(__int64 a1)
{
__int64 v1; // rbx
__int64 v2; // rax

if ( *(int *)a1 > 0 )
{
v1 = 0LL;
do
{
generate_member(*(_QWORD *)(*(_QWORD *)(a1 + 8) + 8 * v1));
v2 = *(_QWORD *)(*(_QWORD *)(a1 + 8) + 8 * v1);
if ( *(_DWORD *)(v2 + 4) )
LODWORD(v2) = code_rule(".");
++v1;
}
while ( *(_DWORD *)a1 > (int)v1 );
}
return v2;
}

original_code:
static void generate_default_horizontal_rule (member_list mems)
 { int ix;
   for (ix = 0; ix < mems -> size; ix++)
      { generate_member (mems -> array[ix]);
        if (mems -> array[ix] -> followlayout) code_rule (".");
      };
 }

canonical_original_code:
static void generate_default_horizontal_rule(struct member_list_rec *mems)
 { int ix;
   for (ix = 0; ix < mems -> size; ix++)
      { generate_member (mems -> array[ix]);
        if (mems -> array[ix] -> followlayout) code_rule (".");
      };
 }

user_defined_types: struct call_rec { char *nonterminal; struct pos_list_rec *display; struct rule_rec *def; }

user_defined_types: struct semiterminal_rec { struct cset_rec *set; struct pos_list_rec *display; }

user_defined_types: struct rule_rec { char *nonterminal; struct alt_list_rec *alts; int kind; int empty; int lex; int ext; int number; int placeholder; int startswithlayout; int endsinlayout; char *first; char *follow; struct pos_list_rec *proto_display; int reachable; int has_sons; int goal; struct lextree_rec *rev_tree; }

user_defined_types: struct alt_list_rec { int size; int room; struct alt_rec **array; }

user_defined_types: struct lextree_list_rec { int size; int room; struct lextree_rec **array; }

user_defined_types: struct alt_rec { struct pos_list_rec *display; struct member_list_rec *members; int number; int nodenr; int nrsons; struct affix_rec *locals; int empty; char *first; char *director; int rule_nr; }

user_defined_types: struct lexend_rec { int nodenr; struct int_list_rec *valuenrs; }

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

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

user_defined_types: struct 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; }


decompiled_code:
int __fastcall generate_default_vertical_rule(__int64 a1)
{
__int64 v1; // rbx
__int64 v2; // rax

if ( *(int *)a1 > 0 )
{
v1 = 0LL;
do
{
generate_member(*(_QWORD *)(*(_QWORD *)(a1 + 8) + 8 * v1));
v2 = *(_QWORD *)(*(_QWORD *)(a1 + 8) + 8 * v1);
if ( *(_DWORD *)(v2 + 4) )
LODWORD(v2) = code_rule("\n");
++v1;
}
while ( *(_DWORD *)a1 > (int)v1 );
}
return v2;
}

original_code:
static void generate_default_vertical_rule (member_list mems)
 { int ix;
   for (ix = 0; ix < mems -> size; ix++)
      { generate_member (mems -> array[ix]);
        if (mems -> array[ix] -> followlayout) code_rule ("\n");
      };
 }

canonical_original_code:
static void generate_default_vertical_rule(struct member_list_rec *mems)
 { int ix;
   for (ix = 0; ix < mems -> size; ix++)
      { generate_member (mems -> array[ix]);
        if (mems -> array[ix] -> followlayout) code_rule ("\n");
      };
 }

user_defined_types: struct member_list_rec { int size; int room; struct member_rec **array; }

user_defined_types: struct member_rec { int empty; int followlayout; char *first; int number; int sonnr; int tag; union { struct call_rec call; char *terminal; struct semiterminal_rec semi; } u; }

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

user_defined_types: struct lextree_rec { char *remainder; struct lexend_list_rec *prods; struct lextree_list_rec *tails; }

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

user_defined_types: struct lexend_list_rec { int size; int room; struct lexend_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_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_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_rec { struct expr_rec *e; int number; }

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


original_code:
static int heuristic_horizontal_rule (member_list mems)
 { int ix;
   member m;
   for (ix = 0; ix < mems -> size; ix++)
      if (!is_an_invisible_member (mems -> array[ix])) break;
   m = mems -> array[ix];
   if (m -> tag != 1) return (0);
   if (strlen (m -> u.terminal) != 1) return (0);
   m -> followlayout = 0;
   for (ix++; ix < mems -> size; ix++)
      { int iy;
        if (mems -> array[ix] -> followlayout)
           for (iy = ix + 1; iy < mems -> size; iy++)
       { m = mems -> array[iy];
         if ((m -> tag == 1) &&
      (strlen (m -> u.terminal) == 1))
            mems -> array[ix] -> followlayout = 0;
         if (!is_an_invisible_member (m)) break;
       };
      };
   generate_default_horizontal_rule (mems);
   return (1);
 }

canonical_original_code:
static int heuristic_horizontal_rule(struct member_list_rec *mems)
 { int ix;
   struct member_rec *m;
   for (ix = 0; ix < mems -> size; ix++)
      if (!is_an_invisible_member (mems -> array[ix])) break;
   m = mems -> array[ix];
   if (m -> tag != 1) return (0);
   if (strlen (m -> u.terminal) != 1) return (0);
   m -> followlayout = 0;
   for (ix++; ix < mems -> size; ix++)
      { int iy;
        if (mems -> array[ix] -> followlayout)
           for (iy = ix + 1; iy < mems -> size; iy++)
       { m = mems -> array[iy];
         if ((m -> tag == 1) &&
      (strlen (m -> u.terminal) == 1))
            mems -> array[ix] -> followlayout = 0;
         if (!is_an_invisible_member (m)) break;
       };
      };
   generate_default_horizontal_rule (mems);
   return (1);
 }

variable_types: iy int

return_type: int

user_defined_types: struct call_rec { char *nonterminal; struct pos_list_rec *display; struct rule_rec *def; }

user_defined_types: struct semiterminal_rec { struct cset_rec *set; struct pos_list_rec *display; }

user_defined_types: struct rule_rec { char *nonterminal; struct alt_list_rec *alts; int kind; int empty; int lex; int ext; int number; int placeholder; int startswithlayout; int endsinlayout; char *first; char *follow; struct pos_list_rec *proto_display; int reachable; int has_sons; int goal; struct lextree_rec *rev_tree; }

user_defined_types: struct alt_list_rec { int size; int room; struct alt_rec **array; }

user_defined_types: struct lextree_list_rec { int size; int room; struct lextree_rec **array; }

user_defined_types: struct alt_rec { struct pos_list_rec *display; struct member_list_rec *members; int number; int nodenr; int nrsons; struct affix_rec *locals; int empty; char *first; char *director; int rule_nr; }

user_defined_types: struct lexend_rec { int nodenr; struct int_list_rec *valuenrs; }

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

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


decompiled_code:
__int64 __fastcall alt_has_brackets(__int64 a1)
{
int v1; // eax
__int64 v2; // rbp
unsigned int v3; // ebx
__int64 v4; // r12
__int64 v6; // rbp
unsigned __int64 v7; // r14
__int64 v8; // r12

v1 = *(_DWORD *)a1;
if ( *(int *)a1 <= 0 )
{
LABEL_8:
if ( v1 - 1 < 0 )
{
v3 = 0;
}
else
{
v6 = 8LL * (v1 - 1);
v7 = 8 * (v1 - (unsigned __int64)(unsigned int)(v1 - 1)) - 16;
while ( 1 )
{
v8 = *(_QWORD *)(*(_QWORD *)(a1 + 8) + v6);
v3 = *(_DWORD *)(v8 + 24);
if ( v3 == 1 && strlen(*(const char **)(v8 + 32)) > 1 )
break;
v3 = is_an_invisible_member(v8);
if ( !v3 )
break;
v6 -= 8LL;
if ( v6 == v7 )
return 0;
}
}
}
else
{
v2 = 0LL;
while ( 1 )
{
v4 = *(_QWORD *)(*(_QWORD *)(a1 + 8) + 8 * v2);
v3 = *(_DWORD *)(v4 + 24);
if ( v3 == 1 && strlen(*(const char **)(v4 + 32)) > 1 )
break;
v3 = is_an_invisible_member(v4);
if ( !v3 )
break;
v1 = *(_DWORD *)a1;
if ( *(_DWORD *)a1 <= (int)++v2 )
goto LABEL_8;
}
}
return v3;
}

original_code:
static int alt_has_brackets (member_list mems)
 { int ix;
   for (ix = 0; ix < mems -> size; ix++)
      { if ((((mems -> array[ix]) -> tag == 1) && (strlen ((mems -> array[ix]) -> u.terminal) > 1))) return (1);
        if (!is_an_invisible_member (mems -> array[ix])) return (0);
      };
   for (ix = mems -> size - 1; 0 <= ix; ix--)
      { if ((((mems -> array[ix]) -> tag == 1) && (strlen ((mems -> array[ix]) -> u.terminal) > 1))) return (1);
        if (!is_an_invisible_member (mems -> array[ix])) return (0);
      };
   return (0);
 }

canonical_original_code:
static int alt_has_brackets(struct member_list_rec *mems)
 { int ix;
   for (ix = 0; ix < mems -> size; ix++)
      { if ((((mems -> array[ix]) -> tag == 1) && (strlen ((mems -> array[ix]) -> u.terminal) > 1))) return (1);
        if (!is_an_invisible_member (mems -> array[ix])) return (0);
      };
   for (ix = mems -> size - 1; 0 <= ix; ix--)
      { if ((((mems -> array[ix]) -> tag == 1) && (strlen ((mems -> array[ix]) -> u.terminal) > 1))) return (1);
        if (!is_an_invisible_member (mems -> array[ix])) return (0);
      };
   return (0);
 }

user_defined_types: struct member_list_rec { int size; int room; struct member_rec **array; }

user_defined_types: struct member_rec { int empty; int followlayout; char *first; int number; int sonnr; int tag; union { struct call_rec call; char *terminal; struct semiterminal_rec semi; } u; }

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

user_defined_types: struct lextree_rec { char *remainder; struct lexend_list_rec *prods; struct lextree_list_rec *tails; }

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

user_defined_types: struct lexend_list_rec { int size; int room; struct lexend_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_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 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; }


decompiled_code:
__int64 __fastcall heuristic_vertical_rule(__int64 a1)
{
__int64 result; // rax
__int64 v2; // rbx
int v3; // er12
__int64 v4; // rbx
__int64 v5; // r14
int v6; // er12
__int64 v7; // rbx
__int64 v8; // rbp

result = alt_has_brackets(a1);
if ( (_DWORD)result )
{
if ( *(int *)a1 <= 0 )
{
v3 = 0;
}
else
{
v2 = 0LL;
do
{
v3 = v2;
if ( !(unsigned int)is_an_invisible_member(*(_QWORD *)(*(_QWORD *)(a1 + 8) + 8 * v2)) )
break;
v3 = ++v2;
}
while ( *(_DWORD *)a1 > (int)v2 );
}
v4 = 8LL * v3;
v5 = *(_QWORD *)(*(_QWORD *)(a1 + 8) + v4);
generate_member(v5);
v6 = v3 + 1;
if ( v6 >= *(_DWORD *)a1 )
{
result = 1LL;
}
else
{
v7 = v4 + 8;
do
{
v8 = *(_QWORD *)(*(_QWORD *)(a1 + 8) + v7);
if ( !(unsigned int)is_an_invisible_member(v8) )
{
if ( *(_DWORD *)(v5 + 4) )
{
if ( *(_DWORD *)(v8 + 24) || *(_DWORD *)(v5 + 24) != 1 )
code_rule("\n");
else
code_rule("\n. ");
}
generate_member(v8);
v5 = v8;
}
++v6;
v7 += 8LL;
}
while ( *(_DWORD *)a1 > v6 );
result = 1LL;
}
}
return result;
}

original_code:
static int heuristic_vertical_rule (member_list mems)
 { int ix;
   member prev;
   if (!alt_has_brackets (mems)) return (0);
   for (ix = 0; ix < mems -> size; ix++)
      if (!is_an_invisible_member (mems -> array[ix])) break;
   prev = mems -> array[ix];
   generate_member (prev);
   for (ix++; ix < mems -> size; ix++)
      { member cur = mems -> array[ix];
        if (!is_an_invisible_member (cur))
    { if (prev -> followlayout)
         { if ((cur -> tag == 0) &&
        (prev -> tag == 1))
       code_rule ("\n.  ");
           else code_rule ("\n");
         };
      generate_member (cur);
      prev = cur;
    };
      };
   return (1);
 }

canonical_original_code:
static int heuristic_vertical_rule(struct member_list_rec *mems)
 { int ix;
   struct member_rec *prev;
   if (!alt_has_brackets (mems)) return (0);
   for (ix = 0; ix < mems -> size; ix++)
      if (!is_an_invisible_member (mems -> array[ix])) break;
   prev = mems -> array[ix];
   generate_member (prev);
   for (ix++; ix < mems -> size; ix++)
      { struct member_rec *cur = mems -> array[ix];
        if (!is_an_invisible_member (cur))
    { if (prev -> followlayout)
         { if ((cur -> tag == 0) &&
        (prev -> tag == 1))
       code_rule ("\n.  ");
           else code_rule ("\n");
         };
      generate_member (cur);
      prev = cur;
    };
      };
   return (1);
 }

user_defined_types: struct call_rec { char *nonterminal; struct pos_list_rec *display; struct rule_rec *def; }

user_defined_types: struct semiterminal_rec { struct cset_rec *set; struct pos_list_rec *display; }

user_defined_types: struct rule_rec { char *nonterminal; struct alt_list_rec *alts; int kind; int empty; int lex; int ext; int number; int placeholder; int startswithlayout; int endsinlayout; char *first; char *follow; struct pos_list_rec *proto_display; int reachable; int has_sons; int goal; struct lextree_rec *rev_tree; }

user_defined_types: struct alt_list_rec { int size; int room; struct alt_rec **array; }

user_defined_types: struct lextree_list_rec { int size; int room; struct lextree_rec **array; }

user_defined_types: struct alt_rec { struct pos_list_rec *display; struct member_list_rec *members; int number; int nodenr; int nrsons; struct affix_rec *locals; int empty; char *first; char *director; int rule_nr; }

user_defined_types: struct lexend_rec { int nodenr; struct int_list_rec *valuenrs; }

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

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

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


decompiled_code:
int __fastcall generate_unparsing_rule_for_alt(__int64 a1)
{
generate_alt_type_and_sonnrs(a1);
if ( (unsigned int)rule_is_unoriented(a1) )
return generate_unoriented_rule(a1);
generate_horizontal_rule(a1);
return generate_vertical_rule(a1);
}

canonical_decompiled_code:
int __fastcall func14(__int64 a1)
{
func4(a1);
if ( (unsigned int)func0(a1) )
return func6(a1);
func10(a1);
return func13(a1);
}

original_code:
static void generate_unparsing_rule_for_alt (alt a)
 { generate_alt_type_and_sonnrs (a);
   if (rule_is_unoriented (a)) generate_unoriented_rule (a);
   else
      { generate_horizontal_rule (a);
        generate_vertical_rule (a);
      };
 }

canonical_original_code:
static void generate_unparsing_rule_for_alt(struct alt_rec *a)
 { generate_alt_type_and_sonnrs (a);
   if (rule_is_unoriented (a)) generate_unoriented_rule (a);
   else
      { generate_horizontal_rule (a);
        generate_vertical_rule (a);
      };
 }

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

user_defined_types: struct member_list_rec { int size; int room; struct member_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 member_rec { int empty; int followlayout; char *first; int number; int sonnr; int tag; union { struct call_rec call; char *terminal; struct semiterminal_rec semi; } u; }

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

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

user_defined_types: struct lextree_rec { char *remainder; struct lexend_list_rec *prods; struct lextree_list_rec *tails; }

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 lexend_list_rec { int size; int room; struct lexend_rec **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; }


decompiled_code:
void __fastcall generate_unparsing_rule_for_rule(__int64 a1)
{
__int64 v1; // rax
__int64 v2; // rbx

if ( *(_DWORD *)(a1 + 36) )
{
v1 = *(_QWORD *)(a1 + 8);
if ( *(int *)v1 > 0 )
{
v2 = 0LL;
do
{
generate_unparsing_rule_for_alt(*(_QWORD *)(*(_QWORD *)(v1 + 8) + 8 * v2));
v1 = *(_QWORD *)(a1 + 8);
++v2;
}
while ( *(_DWORD *)v1 > (int)v2 );
}
}
}

original_code:
static void generate_unparsing_rule_for_rule (rule srule)
 { int ix;
   if (!srule -> placeholder) return;
   for (ix = 0; ix < srule -> alts -> size; ix++)
      generate_unparsing_rule_for_alt (srule -> alts -> array[ix]);
 }

canonical_original_code:
static void generate_unparsing_rule_for_rule(struct rule_rec *srule)
 { int ix;
   if (!srule -> placeholder) return;
   for (ix = 0; ix < srule -> alts -> size; ix++)
      generate_unparsing_rule_for_alt (srule -> alts -> array[ix]);
 }

user_defined_types: struct rule_rec { char *nonterminal; struct alt_list_rec *alts; int kind; int empty; int lex; int ext; int number; int placeholder; int startswithlayout; int endsinlayout; char *first; char *follow; struct pos_list_rec *proto_display; int reachable; int has_sons; int goal; struct lextree_rec *rev_tree; }

user_defined_types: struct alt_list_rec { int size; int room; struct alt_rec **array; }

user_defined_types: struct lextree_list_rec { int size; int room; struct lextree_rec **array; }

user_defined_types: struct alt_rec { struct pos_list_rec *display; struct member_list_rec *members; int number; int nodenr; int nrsons; struct affix_rec *locals; int empty; char *first; char *director; int rule_nr; }

user_defined_types: struct lexend_rec { int nodenr; struct int_list_rec *valuenrs; }

user_defined_types: struct call_rec { char *nonterminal; struct pos_list_rec *display; struct rule_rec *def; }

user_defined_types: struct semiterminal_rec { struct cset_rec *set; struct pos_list_rec *display; }

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

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

user_defined_types: struct 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; }


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

if ( nr_of_rules > 0 )
{
v0 = 0LL;
do
generate_unparsing_rule_for_rule(*(_QWORD *)(all_rules + 8 * v0++));
while ( nr_of_rules > (int)v0 );
}
}

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

if ( nr_of_rules > 0 )
{
v0 = 0LL;
do
func15(*(_QWORD *)(all_rules + 8 * v0++));
while ( nr_of_rules > (int)v0 );
}
}

original_code:
static void generate_unparsing_rule_for_rules ()
 { int ix;
   for (ix = 0; ix < nr_of_rules; ix++)
      generate_unparsing_rule_for_rule (all_rules[ix]);
 }

canonical_original_code:
static void generate_unparsing_rule_for_rules()
 { int ix;
   for (ix = 0; ix < nr_of_rules; ix++)
      generate_unparsing_rule_for_rule (all_rules[ix]);
 }


decompiled_code:
int __fastcall generate_unparsing_rules(const char *a1)
{
warning("generating unparsing rules...");
open_rule_file(a1);
generate_unparsing_rule_for_startrule();
generate_unparsing_rule_for_rules();
return fclose(rfile);
}

canonical_decompiled_code:
int __fastcall func17(const char *a1)
{
warning("generating unparsing rules...");
func2(a1);
func3();
func16();
return fclose(rfile);
}

original_code:
void generate_unparsing_rules (string gram)
 { warning ("generating unparsing rules...");
   open_rule_file (gram);
   generate_unparsing_rule_for_startrule ();
   generate_unparsing_rule_for_rules ();
   fclose (rfile);
 }

canonical_original_code:
void generate_unparsing_rules(char *gram)
 { warning ("generating unparsing rules...");
   open_rule_file (gram);
   generate_unparsing_rule_for_startrule ();
   generate_unparsing_rule_for_rules ();
   fclose (rfile);
 }


decompiled_code:
int code_rule(char *format, ...)
{
gcc_va_list arg; // [rsp+8h] [rbp-10D0h] BYREF
char s[4096]; // [rsp+20h] [rbp-10B8h] BYREF

va_start(arg, format);
vsprintf(s, format, arg);
return fprintf(rfile, s);
}

canonical_decompiled_code:
int func1(char *format, ...)
{
gcc_va_list arg; // [rsp+8h] [rbp-10D0h] BYREF
char s[4096]; // [rsp+20h] [rbp-10B8h] BYREF

va_start(arg, format);
vsprintf(s, format, arg);
return fprintf(rfile, s);
}

original_code:
static void code_rule (char *format, ...)
 { char buf[4096];
   va_list arg_ptr;
   __builtin_va_start(arg_ptr,format);
   vsprintf (buf, format, arg_ptr);
   __builtin_va_end(arg_ptr);
   fprintf (rfile, buf);
 }

canonical_original_code:
static void code_rule(char *format, ...)
 { char buf[4096];
   __builtin_va_list arg_ptr;
   __builtin_va_start(arg_ptr,format);
   vsprintf (buf, format, arg_ptr);
   __builtin_va_end(arg_ptr);
   fprintf (rfile, buf);
 }

variable_types:
format
char *

variable_types:
buf
char [4096]


decompiled_code:
int __fastcall generate_member(__int64 a1)
{
int result; // eax

result = is_an_invisible_member(a1);
if ( !result )
{
result = *(_DWORD *)(a1 + 24);
switch ( result )
{
case 1:
result = output_string(rfile, *(_QWORD *)(a1 + 32));
break;
case 2:
result = code_rule("{}");
break;
case 0:
result = code_rule("%s%s%s", "<|", *(const char **)(a1 + 32), "|>");
break;
}
}
return result;
}

canonical_decompiled_code:
int __fastcall func5(__int64 a1)
{
int result; // eax

result = is_an_invisible_member(a1);
if ( !result )
{
result = *(_DWORD *)(a1 + 24);
switch ( result )
{
case 1:
result = output_string(rfile, *(_QWORD *)(a1 + 32));
break;
case 2:
result = func1("{}");
break;
case 0:
result = func1("%s%s%s", "<|", *(const char **)(a1 + 32), "|>");
break;
}
}
return result;
}

original_code:
static void generate_member (member m)
 { if (is_an_invisible_member (m)) return;
   switch (m -> tag)
      { case 0:
    code_rule ("%s%s%s", "<|",
        m -> u.call.nonterminal, "|>");
    break;
        case 1:
    output_string (rfile, m -> u.terminal);
    break;
        case 2: code_rule ("{}");
        default: break;
      };
 }

canonical_original_code:
static void generate_member(struct member_rec *m)
 { if (is_an_invisible_member (m)) return;
   switch (m -> tag)
      { case 0:
    code_rule ("%s%s%s", "<|",
        m -> u.call.nonterminal, "|>");
    break;
        case 1:
    output_string (rfile, m -> u.terminal);
    break;
        case 2: code_rule ("{}");
        default: break;
      };
 }

user_defined_types: struct member_rec { int empty; int followlayout; char *first; int number; int sonnr; int tag; union { struct call_rec call; char *terminal; struct semiterminal_rec semi; } u; }

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

user_defined_types: struct lextree_rec { char *remainder; struct lexend_list_rec *prods; struct lextree_list_rec *tails; }

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

user_defined_types: struct member_list_rec { int size; int room; struct member_rec **array; }

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

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


cut

decompiled_code:
__int64 cut()
{
__int64 v0; // rbx
__int64 v1; // rdx
__int64 v2; // rax
__int64 result; // rax

qptr -= 8LL;
v0 = *qptr;
*(_DWORD *)*qptr = 1;
v1 = qptr;
qptr -= 8LL;
(*(void (**)(void))(v1 - 8))();
*qptr = v0;
v2 = qptr;
*(_QWORD *)(qptr + 8LL) = cut;
result = v2 + 16;
qptr = result;
return result;
}

canonical_decompiled_code:
__int64 func0()
{
__int64 v0; // rbx
__int64 v1; // rdx
__int64 v2; // rax
__int64 result; // rax

qptr -= 8LL;
v0 = *qptr;
*(_DWORD *)*qptr = 1;
v1 = qptr;
qptr -= 8LL;
(*(void (**)(void))(v1 - 8))();
*qptr = v0;
v2 = qptr;
*(_QWORD *)(qptr + 8LL) = cut;
result = v2 + 16;
qptr = result;
return result;
}

original_code:
void cut ()
 { int *p = ((--qptr) -> ip);
   *p = 1;
   (--qptr) -> q();
   qptr -> ip = p; qptr++;
   qptr -> q = cut; qptr++;
 }

canonical_original_code:
void cut()
 { int *p = ((--qptr) -> ip);
   *p = 1;
   (--qptr) -> q();
   qptr -> ip = p; qptr++;
   qptr -> q = cut; qptr++;
 }

variable_types:
p
int *


decompiled_code:
__int64 make_empty_strstore()
{
char v0; // bl
__int64 v1; // rdx
__int64 result; // rax

v0 = *strstore;
*strstore = 0;
v1 = qptr;
qptr -= 8LL;
(*(void (**)(void))(v1 - 8))();
*strstore = v0;
result = qptr;
*qptr = make_empty_strstore;
qptr += 8LL;
return result;
}

canonical_decompiled_code:
__int64 func1()
{
char v0; // bl
__int64 v1; // rdx
__int64 result; // rax

v0 = *strstore;
*strstore = 0;
v1 = qptr;
qptr -= 8LL;
(*(void (**)(void))(v1 - 8))();
*strstore = v0;
result = qptr;
*qptr = make_empty_strstore;
qptr += 8LL;
return result;
}

original_code:
void make_empty_strstore ()
 { char c = strstore[0];
   strstore[0] = '\0';
   (--qptr) -> q();
   strstore[0] = c;
   qptr -> q = make_empty_strstore; qptr++;
 }

canonical_original_code:
void make_empty_strstore()
 { char c = strstore[0];
   strstore[0] = '\0';
   (--qptr) -> q();
   strstore[0] = c;
   qptr -> q = make_empty_strstore; qptr++;
 }

variable_types: c char


decompiled_code:
__int64 dummy_continuation()
{
__int64 result; // rax

result = qptr;
*qptr = dummy_continuation;
qptr += 8LL;
return result;
}

canonical_decompiled_code:
__int64 func2()
{
__int64 result; // rax

result = qptr;
*qptr = dummy_continuation;
qptr += 8LL;
return result;
}

original_code:
void dummy_continuation ()
 { qptr -> q = dummy_continuation; qptr++;
 }

canonical_original_code:
void dummy_continuation()
 { qptr -> q = dummy_continuation; qptr++;
 }


decompiled_code:
__int64 output_affix()
{
__int64 v0; // rbx
__int64 v1; // rdx
__int64 v2; // rax
__int64 result; // rax

qptr -= 8LL;
v0 = *qptr;
output_value(stdout, *(_QWORD *)(*qptr + 8LL));
v1 = qptr;
qptr -= 8LL;
(*(void (**)(void))(v1 - 8))();
*qptr = v0;
v2 = qptr;
*(_QWORD *)(qptr + 8LL) = output_affix;
result = v2 + 16;
qptr = result;
return result;
}

canonical_decompiled_code:
__int64 func3()
{
__int64 v0; // rbx
__int64 v1; // rdx
__int64 v2; // rax
__int64 result; // rax

qptr -= 8LL;
v0 = *qptr;
output_value(stdout, *(_QWORD *)(*qptr + 8LL));
v1 = qptr;
qptr -= 8LL;
(*(void (**)(void))(v1 - 8))();
*qptr = v0;
v2 = qptr;
*(_QWORD *)(qptr + 8LL) = output_affix;
result = v2 + 16;
qptr = result;
return result;
}

original_code:
void output_affix ()
 { affix_node affx = ((--qptr) -> a);
   output_value (stdout, affx -> val);
   (--qptr) -> q();
   qptr -> a = affx; qptr++;
   qptr -> q = output_affix; qptr++;
 }

canonical_original_code:
void output_affix()
 { struct affix_rec *affx = ((--qptr) -> a);
   output_value (stdout, affx -> val);
   (--qptr) -> q();
   qptr -> a = affx; qptr++;
   qptr -> q = output_affix; qptr++;
 }

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 affix_rec { char *name; struct value_rec *val; void (*mfunc)(); struct link_rec *links; }

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

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


decompiled_code:
__int64 new_tree_node()
{
__int64 result; // rax

result = free_tree_node_list;
if ( free_tree_node_list )
free_tree_node_list = *(_QWORD *)free_tree_node_list;
else
result = ckmalloc(48LL);
*(_QWORD *)result = &LC0;
*(_DWORD *)(result + 8) = 0;
*(_DWORD *)(result + 12) = 0;
*(_DWORD *)(result + 16) = 0;
*(_DWORD *)(result + 32) = 0;
return result;
}

canonical_decompiled_code:
__int64 func0()
{
__int64 result; // rax

result = free_tree_node_list;
if ( free_tree_node_list )
free_tree_node_list = *(_QWORD *)free_tree_node_list;
else
result = ckmalloc(48LL);
*(_QWORD *)result = &LC0;
*(_DWORD *)(result + 8) = 0;
*(_DWORD *)(result + 12) = 0;
*(_DWORD *)(result + 16) = 0;
*(_DWORD *)(result + 32) = 0;
return result;
}

original_code:
tree_node new_tree_node ()
 { tree_node new;
   if (free_tree_node_list == ((tree_node) ((void *)0)))
      new = (tree_node) ckmalloc (sizeof (struct tree_rec));
   else
      { new = free_tree_node_list;
        free_tree_node_list = (tree_node) free_tree_node_list -> name;
      };
   new -> name = "";
   new -> type = 0;
   new -> nodenr = 0;
   new -> nrsons = 0;
   new -> nraffs = 0;
   return (new);
 }

canonical_original_code:
struct tree_rec *new_tree_node()
 { struct tree_rec *new;
   if (free_tree_node_list == ((tree_node) ((void *)0)))
      new = (struct tree_rec *) ckmalloc (sizeof (struct tree_rec));
   else
      { new = free_tree_node_list;
        free_tree_node_list = (struct tree_rec *) free_tree_node_list -> name;
      };
   new -> name = "";
   new -> type = 0;
   new -> nodenr = 0;
   new -> nrsons = 0;
   new -> nraffs = 0;
   return (new);
 }

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

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

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


decompiled_code:
void __fastcall free_son_space(int a1, _QWORD *a2)
{
int v2; // edi

if ( a1 )
{
if ( a1 > 64 )
{
free(a2);
}
else
{
v2 = a1 - 1;
*a2 = free_son_list[v2];
free_son_list[v2] = a2;
}
}
}

canonical_decompiled_code:
void __fastcall func2(int a1, _QWORD *a2)
{
int v2; // edi

if ( a1 )
{
if ( a1 > 64 )
{
free(a2);
}
else
{
v2 = a1 - 1;
*a2 = free_son_list[v2];
free_son_list[v2] = a2;
}
}
}

original_code:
void free_son_space (int nrsons, tree_node *old)
 { if (nrsons == 0) return;
   if (nrsons > 64) free ((char *) old);
   else
      { old[0] = (tree_node) free_son_list[nrsons-1];
        free_son_list[nrsons-1] = old;
      };
 }

canonical_original_code:
void free_son_space(int nrsons, struct tree_rec **old)
 { if (nrsons == 0) return;
   if (nrsons > 64) free ((char *) old);
   else
      { old[0] = (struct tree_rec *) free_son_list[nrsons-1];
        free_son_list[nrsons-1] = old;
      };
 }

variable_types: nrsons int

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


decompiled_code:
__int64 new_pos_node()
{
__int64 result; // rax

result = free_pos_node_list;
if ( free_pos_node_list )
free_pos_node_list = *(_QWORD *)free_pos_node_list;
else
result = ckmalloc(80LL);
*(_QWORD *)result = 0LL;
*(_DWORD *)(result + 12) = 0;
*(_DWORD *)(result + 36) = 0;
*(_DWORD *)(result + 56) = 0;
*(_QWORD *)(result + 64) = 0LL;
*(_QWORD *)(result + 72) = 0LL;
return result;
}

canonical_decompiled_code:
__int64 func3()
{
__int64 result; // rax

result = free_pos_node_list;
if ( free_pos_node_list )
free_pos_node_list = *(_QWORD *)free_pos_node_list;
else
result = ckmalloc(80LL);
*(_QWORD *)result = 0LL;
*(_DWORD *)(result + 12) = 0;
*(_DWORD *)(result + 36) = 0;
*(_DWORD *)(result + 56) = 0;
*(_QWORD *)(result + 64) = 0LL;
*(_QWORD *)(result + 72) = 0LL;
return result;
}

original_code:
pos_node new_pos_node ()
 { pos_node new;
   if (free_pos_node_list == ((pos_node) ((void *)0)))
      { new = (pos_node) ckmalloc (sizeof (struct pos_rec));
      }
   else
      { new = free_pos_node_list;
        free_pos_node_list = (pos_node) free_pos_node_list -> node;
      };
   new -> node = ((tree_node) ((void *)0));
   new -> sides[0].tag = 0;
   new -> sides[1].tag = 0;
   new -> delayed = 0;
   new -> args = ((pos_node *) ((void *)0));
   new -> dfunc = ((void *)0);
   return (new);
 }

canonical_original_code:
struct pos_rec *new_pos_node()
 { struct pos_rec *new;
   if (free_pos_node_list == ((pos_node) ((void *)0)))
      { new = (struct pos_rec *) ckmalloc (sizeof (struct pos_rec));
      }
   else
      { new = free_pos_node_list;
        free_pos_node_list = (struct pos_rec *) free_pos_node_list -> node;
      };
   new -> node = ((tree_node) ((void *)0));
   new -> sides[0].tag = 0;
   new -> sides[1].tag = 0;
   new -> delayed = 0;
   new -> args = ((struct pos_rec **) ((void *)0));
   new -> dfunc = ((void *)0);
   return (new);
 }

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


decompiled_code:
void __fastcall free_pos_space(int a1, _QWORD *a2)
{
int v2; // edi

if ( a1 )
{
if ( a1 > 64 )
{
free(a2);
}
else
{
v2 = a1 - 1;
*a2 = free_pos_space_list[v2];
free_pos_space_list[v2] = a2;
}
}
}

canonical_decompiled_code:
void __fastcall func5(int a1, _QWORD *a2)
{
int v2; // edi

if ( a1 )
{
if ( a1 > 64 )
{
free(a2);
}
else
{
v2 = a1 - 1;
*a2 = free_pos_space_list[v2];
free_pos_space_list[v2] = a2;
}
}
}

original_code:
void free_pos_space (int nrofps, pos_node *old)
 { if (nrofps == 0) return;
   if (nrofps > 64) free ((char *) old);
   else
      { old[0] = (pos_node) free_pos_space_list[nrofps-1];
        free_pos_space_list[nrofps-1] = old;
      };
 }

canonical_original_code:
void free_pos_space(int nrofps, struct pos_rec **old)
 { if (nrofps == 0) return;
   if (nrofps > 64) free ((char *) old);
   else
      { old[0] = (struct pos_rec *) free_pos_space_list[nrofps-1];
        free_pos_space_list[nrofps-1] = old;
      };
 }

variable_types: nrofps int

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


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

result = free_affix_node_list;
*(_QWORD *)(a1 + 24) = free_affix_node_list;
free_affix_node_list = a1;
return result;
}

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

result = free_affix_node_list;
*(_QWORD *)(a1 + 24) = free_affix_node_list;
free_affix_node_list = a1;
return result;
}

original_code:
void free_affix_node (affix_node old)
 { old -> links = (link_node) free_affix_node_list;
   free_affix_node_list = old;
 }

canonical_original_code:
void free_affix_node(struct affix_rec *old)
 { old -> links = (struct link_rec *) free_affix_node_list;
   free_affix_node_list = old;
 }


decompiled_code:
void __fastcall free_affix_space(int a1, _QWORD *a2)
{
int v2; // edi

if ( a1 )
{
if ( a1 > 64 )
{
free(a2);
}
else
{
v2 = a1 - 1;
*a2 = free_affix_space_list[v2];
free_affix_space_list[v2] = a2;
}
}
}

canonical_decompiled_code:
void __fastcall func7(int a1, _QWORD *a2)
{
int v2; // edi

if ( a1 )
{
if ( a1 > 64 )
{
free(a2);
}
else
{
v2 = a1 - 1;
*a2 = free_affix_space_list[v2];
free_affix_space_list[v2] = a2;
}
}
}

original_code:
void free_affix_space (int nraffs, affix_node *old)
 { if (nraffs == 0) return;
   if (nraffs > 64) free ((char *) old);
   else
      { old[0] = (affix_node) free_affix_space_list[nraffs-1];
        free_affix_space_list[nraffs-1] = old;
      };
 }

canonical_original_code:
void free_affix_space(int nraffs, struct affix_rec **old)
 { if (nraffs == 0) return;
   if (nraffs > 64) free ((char *) old);
   else
      { old[0] = (struct affix_rec *) free_affix_space_list[nraffs-1];
        free_affix_space_list[nraffs-1] = old;
      };
 }

variable_types: nraffs int

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


decompiled_code:
__int64 new_link_node()
{
__int64 result; // rax

result = free_link_node_list;
if ( free_link_node_list )
free_link_node_list = *(_QWORD *)(free_link_node_list + 16);
else
result = ckmalloc(24LL);
*(_QWORD *)result = 0LL;
*(_DWORD *)(result + 8) = 0;
*(_QWORD *)(result + 16) = 0LL;
return result;
}

canonical_decompiled_code:
__int64 func8()
{
__int64 result; // rax

result = free_link_node_list;
if ( free_link_node_list )
free_link_node_list = *(_QWORD *)(free_link_node_list + 16);
else
result = ckmalloc(24LL);
*(_QWORD *)result = 0LL;
*(_DWORD *)(result + 8) = 0;
*(_QWORD *)(result + 16) = 0LL;
return result;
}

original_code:
link_node new_link_node ()
 { link_node new;
   if (free_link_node_list == ((link_node) ((void *)0)))
      new = (link_node) ckmalloc (sizeof (struct link_rec));
   else
      { new = free_link_node_list;
        free_link_node_list = free_link_node_list -> next;
      };
   new -> pos = ((pos_node) ((void *)0));
   new -> side = 0;
   new -> next = ((link_node) ((void *)0));
   return (new);
 }

canonical_original_code:
struct link_rec *new_link_node()
 { struct link_rec *new;
   if (free_link_node_list == ((link_node) ((void *)0)))
      new = (struct link_rec *) ckmalloc (sizeof (struct link_rec));
   else
      { new = free_link_node_list;
        free_link_node_list = free_link_node_list -> next;
      };
   new -> pos = ((pos_node) ((void *)0));
   new -> side = 0;
   new -> next = ((link_node) ((void *)0));
   return (new);
 }

variable_types: 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 { 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 *links; } *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; } *


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

result = free_link_node_list;
*(_QWORD *)(a1 + 16) = free_link_node_list;
free_link_node_list = a1;
return result;
}

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

result = free_link_node_list;
*(_QWORD *)(a1 + 16) = free_link_node_list;
free_link_node_list = a1;
return result;
}

original_code:
void free_link_node (link_node old)
 { old -> next = free_link_node_list;
   free_link_node_list = old;
 }

canonical_original_code:
void free_link_node(struct link_rec *old)
 { old -> next = free_link_node_list;
   free_link_node_list = old;
 }


decompiled_code:
_QWORD *reinit_ds()
{
_QWORD *result; // rax

tptr = tstack;
result = &qptr;
qptr = qstack;
return result;
}

canonical_decompiled_code:
_QWORD *func10()
{
_QWORD *result; // rax

tptr = tstack;
result = &qptr;
qptr = qstack;
return result;
}

original_code:
void reinit_ds ()
 { tptr = tstack;
   qptr = qstack;
 }

canonical_original_code:
void reinit_ds()
 { tptr = tstack;
   qptr = qstack;
 }


decompiled_code:
__int64 assign_input_affix()
{
__int64 v0; // rax
int v1; // ebp
__int64 v2; // rbx
__int64 v3; // r12
__int64 v4; // rdx
__int64 v5; // rax
__int64 result; // rax
__int64 v7; // rax
void (*v8)(void); // rdx
__int64 v9; // rdx

v0 = qptr;
qptr -= 8LL;
v1 = *qptr;
qptr = v0 - 16;
v2 = *(_QWORD *)(v0 - 16);
v3 = *(_QWORD *)(my_ivals + 8LL * v1);
if ( *(_QWORD *)(v2 + 8) )
{
if ( (unsigned int)equal_value(*(_QWORD *)(my_ivals + 8LL * v1)) )
{
v4 = qptr;
qptr -= 8LL;
(*(void (**)(void))(v4 - 8))();
}
}
else
{
*(_QWORD *)(v2 + 8) = rdup_value(*(_QWORD *)(my_ivals + 8LL * v1));
if ( *(_QWORD *)(v2 + 16) )
{
*qptr = v3;
v7 = qptr;
v8 = *(void (**)(void))(v2 + 16);
*(_QWORD *)(qptr + 8LL) = v8;
qptr = v7 + 8;
v8();
qptr -= 16LL;
}
else
{
v9 = qptr;
qptr -= 8LL;
(*(void (**)(void))(v9 - 8))();
}
rfre_value(v3);
*(_QWORD *)(v2 + 8) = 0LL;
}
*qptr = v2;
v5 = qptr;
*(_DWORD *)(qptr + 8LL) = v1;
*(_QWORD *)(v5 + 16) = assign_input_affix;
result = v5 + 24;
qptr = result;
return result;
}

canonical_decompiled_code:
__int64 func0()
{
__int64 v0; // rax
int v1; // ebp
__int64 v2; // rbx
__int64 v3; // r12
__int64 v4; // rdx
__int64 v5; // rax
__int64 result; // rax
__int64 v7; // rax
void (*v8)(void); // rdx
__int64 v9; // rdx

v0 = qptr;
qptr -= 8LL;
v1 = *qptr;
qptr = v0 - 16;
v2 = *(_QWORD *)(v0 - 16);
v3 = *(_QWORD *)(my_ivals + 8LL * v1);
if ( *(_QWORD *)(v2 + 8) )
{
if ( (unsigned int)equal_value(*(_QWORD *)(my_ivals + 8LL * v1)) )
{
v4 = qptr;
qptr -= 8LL;
(*(void (**)(void))(v4 - 8))();
}
}
else
{
*(_QWORD *)(v2 + 8) = rdup_value(*(_QWORD *)(my_ivals + 8LL * v1));
if ( *(_QWORD *)(v2 + 16) )
{
*qptr = v3;
v7 = qptr;
v8 = *(void (**)(void))(v2 + 16);
*(_QWORD *)(qptr + 8LL) = v8;
qptr = v7 + 8;
v8();
qptr -= 16LL;
}
else
{
v9 = qptr;
qptr -= 8LL;
(*(void (**)(void))(v9 - 8))();
}
rfre_value(v3);
*(_QWORD *)(v2 + 8) = 0LL;
}
*qptr = v2;
v5 = qptr;
*(_DWORD *)(qptr + 8LL) = v1;
*(_QWORD *)(v5 + 16) = assign_input_affix;
result = v5 + 24;
qptr = result;
return result;
}

original_code:
void assign_input_affix ()
 { int nr = ((--qptr) -> i);
   affix_node affx = ((--qptr) -> a);
   value new_val = my_ivals[nr];
   if (affx -> val != ((value) ((void *)0)))
      { if (equal_value (new_val, affx -> val)) (--qptr) -> q();
      }
   else
      { affx -> val = rdup_value (new_val);
        if (affx -> mfunc != ((void *)0))
    {
      qptr -> v = new_val; qptr++;
      qptr -> q = affx -> mfunc; qptr++;
      (--qptr) -> q();
      qptr -= 2;
    }
        else (--qptr) -> q();
        rfre_value (new_val);
        affx -> val = ((value) ((void *)0));
      };
   qptr -> a = affx; qptr++;
   qptr -> i = nr; qptr++;
   qptr -> q = assign_input_affix; qptr++;
 }

canonical_original_code:
void assign_input_affix()
 { int nr = ((--qptr) -> i);
   struct affix_rec *affx = ((--qptr) -> a);
   struct value_rec *new_val = my_ivals[nr];
   if (affx -> val != ((value) ((void *)0)))
      { if (equal_value (new_val, affx -> val)) (--qptr) -> q();
      }
   else
      { affx -> val = rdup_value (new_val);
        if (affx -> mfunc != ((void *)0))
    {
      qptr -> v = new_val; qptr++;
      qptr -> q = affx -> mfunc; qptr++;
      (--qptr) -> q();
      qptr -= 2;
    }
        else (--qptr) -> q();
        rfre_value (new_val);
        affx -> val = ((value) ((void *)0));
      };
   qptr -> a = affx; qptr++;
   qptr -> i = nr; qptr++;
   qptr -> q = assign_input_affix; qptr++;
 }

variable_types: nr int

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


decompiled_code:
__int64 reserve_collection_space()
{
__int64 v0; // rdx
__int64 v1; // rax
__int64 result; // rax

qptr -= 8LL;
my_nrps = *qptr;
my_cvals = (void *)ckcalloc(1LL, 8LL);
room = 1;
allocated = 0;
v0 = qptr;
qptr -= 8LL;
(*(void (**)(void))(v0 - 8))();
*qptr = my_nrps;
v1 = qptr;
*(_QWORD *)(qptr + 8LL) = reserve_collection_space;
result = v1 + 16;
qptr = result;
return result;
}

canonical_decompiled_code:
__int64 func1()
{
__int64 v0; // rdx
__int64 v1; // rax
__int64 result; // rax

qptr -= 8LL;
my_nrps = *qptr;
my_cvals = (void *)ckcalloc(1LL, 8LL);
room = 1;
allocated = 0;
v0 = qptr;
qptr -= 8LL;
(*(void (**)(void))(v0 - 8))();
*qptr = my_nrps;
v1 = qptr;
*(_QWORD *)(qptr + 8LL) = reserve_collection_space;
result = v1 + 16;
qptr = result;
return result;
}

original_code:
void reserve_collection_space ()
 { my_nrps = ((--qptr) -> i);
   my_cvals = (value **) ckcalloc (1, sizeof (value *));
   room = 1;
   allocated = 0;
   (--qptr) -> q();
   qptr -> i = my_nrps; qptr++;
   qptr -> q = reserve_collection_space; qptr++;
 }

canonical_original_code:
void reserve_collection_space()
 { my_nrps = ((--qptr) -> i);
   my_cvals = (struct value_rec ***) ckcalloc (1, sizeof (struct value_rec **));
   room = 1;
   allocated = 0;
   (--qptr) -> q();
   qptr -> i = my_nrps; qptr++;
   qptr -> q = reserve_collection_space; qptr++;
 }


decompiled_code:
__int64 check_for_space()
{
__int64 result; // rax
__int64 *v1; // rbx
_QWORD *v2; // rbx
void *v3; // rcx
int v4; // edi
__int64 v5; // rax
__int64 v6; // rdx

result = (unsigned int)allocated;
if ( nrofparses >= allocated )
{
if ( allocated == room )
{
v2 = my_cvals;
v3 = (void *)ckcalloc((unsigned int)(2 * room), 8LL);
my_cvals = v3;
v4 = room;
if ( room > 1 )
{
v5 = 0LL;
do
{
*((_QWORD *)v3 + v5) = v2[v5];
v6 = v5++;
}
while ( v6 != v4 - 2 );
}
room = 2 * v4;
free(v2);
}
v1 = (__int64 *)((char *)my_cvals + 8 * allocated);
result = ckcalloc((unsigned int)my_nrps, 8LL);
*v1 = result;
++allocated;
}
return result;
}

canonical_decompiled_code:
__int64 func2()
{
__int64 result; // rax
__int64 *v1; // rbx
_QWORD *v2; // rbx
void *v3; // rcx
int v4; // edi
__int64 v5; // rax
__int64 v6; // rdx

result = (unsigned int)allocated;
if ( nrofparses >= allocated )
{
if ( allocated == room )
{
v2 = my_cvals;
v3 = (void *)ckcalloc((unsigned int)(2 * room), 8LL);
my_cvals = v3;
v4 = room;
if ( room > 1 )
{
v5 = 0LL;
do
{
*((_QWORD *)v3 + v5) = v2[v5];
v6 = v5++;
}
while ( v6 != v4 - 2 );
}
room = 2 * v4;
free(v2);
}
v1 = (__int64 *)((char *)my_cvals + 8 * allocated);
result = ckcalloc((unsigned int)my_nrps, 8LL);
*v1 = result;
++allocated;
}
return result;
}

original_code:
static void check_for_space ()
 { if (nrofparses < allocated) return;
   if (allocated == room)
      { int i;
        value **ocvals = my_cvals;
        my_cvals = (value **) ckcalloc (room * 2, sizeof (value *));
        for (i=0; i < room - 1; i++) my_cvals[i] = ocvals[i];
        room *= 2;
        free((char *) ocvals);
      };
   my_cvals[allocated] = (value *) ckcalloc (my_nrps, sizeof (value));
   allocated++;
 }

canonical_original_code:
static void check_for_space()
 { if (nrofparses < allocated) return;
   if (allocated == room)
      { int i;
        struct value_rec ***ocvals = my_cvals;
        my_cvals = (struct value_rec ***) ckcalloc (room * 2, sizeof (struct value_rec **));
        for (i=0; i < room - 1; i++) my_cvals[i] = ocvals[i];
        room *= 2;
        free((char *) ocvals);
      };
   my_cvals[allocated] = (struct value_rec **) ckcalloc (my_nrps, sizeof (value));
   allocated++;
 }

variable_types: i int

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


decompiled_code:
__int64 collect_output_affix()
{
__int64 v0; // rax
int v1; // ebx
__int64 v2; // rbp
__int64 v3; // r13
_QWORD *v4; // r12
__int64 v5; // rdx
__int64 v6; // rax
__int64 result; // rax

v0 = qptr;
qptr -= 8LL;
v1 = *qptr;
qptr = v0 - 16;
v2 = *(_QWORD *)(v0 - 16);
v3 = *(_QWORD *)(v2 + 8);
check_for_space();
v4 = (_QWORD *)(*((_QWORD *)my_cvals + nrofparses) + 8LL * v1);
*v4 = rdup_value(v3);
v5 = qptr;
qptr -= 8LL;
(*(void (**)(void))(v5 - 8))();
*qptr = v2;
v6 = qptr;
*(_DWORD *)(qptr + 8LL) = v1;
*(_QWORD *)(v6 + 16) = collect_output_affix;
result = v6 + 24;
qptr = result;
return result;
}

canonical_decompiled_code:
__int64 func3()
{
__int64 v0; // rax
int v1; // ebx
__int64 v2; // rbp
__int64 v3; // r13
_QWORD *v4; // r12
__int64 v5; // rdx
__int64 v6; // rax
__int64 result; // rax

v0 = qptr;
qptr -= 8LL;
v1 = *qptr;
qptr = v0 - 16;
v2 = *(_QWORD *)(v0 - 16);
v3 = *(_QWORD *)(v2 + 8);
func2();
v4 = (_QWORD *)(*((_QWORD *)my_cvals + nrofparses) + 8LL * v1);
*v4 = rdup_value(v3);
v5 = qptr;
qptr -= 8LL;
(*(void (**)(void))(v5 - 8))();
*qptr = v2;
v6 = qptr;
*(_DWORD *)(qptr + 8LL) = v1;
*(_QWORD *)(v6 + 16) = collect_output_affix;
result = v6 + 24;
qptr = result;
return result;
}

original_code:
void collect_output_affix ()
 { int nr = ((--qptr) -> i);
   affix_node affx = ((--qptr) -> a);
   value new_val = affx -> val;
   check_for_space ();
   my_cvals[nrofparses][nr] = rdup_value (new_val);
   (--qptr) -> q();
   qptr -> a = affx; qptr++;
   qptr -> i = nr; qptr++;
   qptr -> q = collect_output_affix; qptr++;
 }

canonical_original_code:
void collect_output_affix()
 { int nr = ((--qptr) -> i);
   struct affix_rec *affx = ((--qptr) -> a);
   struct value_rec *new_val = affx -> val;
   check_for_space ();
   my_cvals[nrofparses][nr] = rdup_value (new_val);
   (--qptr) -> q();
   qptr -> a = affx; qptr++;
   qptr -> i = nr; qptr++;
   qptr -> q = collect_output_affix; qptr++;
 }


decompiled_code:
__int64 init_C_interface()
{
init_textstorage(100000LL);
init_ds(10000LL, 100000LL);
return init_textparsing(100000LL, 0xFFFFFFFFLL);
}

canonical_decompiled_code:
__int64 func4()
{
init_textstorage(100000LL);
init_ds(10000LL, 100000LL);
return init_textparsing(100000LL, 0xFFFFFFFFLL);
}

original_code:
void init_C_interface ()
 { init_textstorage (100000);
   init_ds (10000, 100000);
   init_textparsing (100000, -1);
 }

canonical_original_code:
void init_C_interface()
 { init_textstorage (100000);
   init_ds (10000, 100000);
   init_textparsing (100000, -1);
 }


decompiled_code:
__int64 __fastcall parse_this_buffer(const char *a1, __int64 a2, _QWORD *a3)
{
size_t v4; // rax

my_ivals = a2;
v4 = strlen(a1);
copy_into_parsebuffer(a1, v4, 0LL);
reinit_ds();
reinit_textparsing();
transduce();
if ( nrofparses && a3 )
*a3 = my_cvals;
return nrofparses;
}

canonical_decompiled_code:
__int64 __fastcall func5(const char *a1, __int64 a2, _QWORD *a3)
{
size_t v4; // rax

my_ivals = a2;
v4 = strlen(a1);
copy_into_parsebuffer(a1, v4, 0LL);
reinit_ds();
reinit_textparsing();
transduce();
if ( nrofparses && a3 )
*a3 = my_cvals;
return nrofparses;
}

original_code:
int parse_this_buffer (char *buffer, value *ivals, value ***cvals)
 { my_ivals = ivals;
   copy_into_parsebuffer (buffer, strlen (buffer), 0);
   reinit_ds ();
   reinit_textparsing ();
   transduce ();
   if (nrofparses && cvals) *cvals = my_cvals;
   return (nrofparses);
 }

canonical_original_code:
int parse_this_buffer(char *buffer, struct value_rec **ivals, struct value_rec ****cvals)
 { my_ivals = ivals;
   copy_into_parsebuffer (buffer, strlen (buffer), 0);
   reinit_ds ();
   reinit_textparsing ();
   transduce ();
   if (nrofparses && cvals) *cvals = my_cvals;
   return (nrofparses);
 }

variable_types:
buffer
char *

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

variable_types:
cvals
struct value_rec ****


original_code:
static void decide_placeholder_rule (rule srule)
 { if (srule -> ext) return;
   if (srule -> kind & 2) return;
   if (srule -> kind & 4) return;
   if (srule == layout_rule) return;
   if (!srule -> reachable) return;
   srule -> placeholder = 1;
 }

canonical_original_code:
static void decide_placeholder_rule(struct rule_rec *srule)
 { if (srule -> ext) return;
   if (srule -> kind & 2) return;
   if (srule -> kind & 4) return;
   if (srule == layout_rule) return;
   if (!srule -> reachable) return;
   srule -> placeholder = 1;
 }

variable_types: struct rule_rec { char *nonterminal; struct alt_list_rec { int size; int room; struct alt_rec { 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; } *display; struct member_list_rec { int size; int room; struct member_rec { int empty; int followlayout; char *first; int number; int sonnr; int tag; union { struct call_rec { char *nonterminal; struct pos_list_rec *display; struct rule_rec *def; } call; char *terminal; struct semiterminal_rec { struct cset_rec *set; struct pos_list_rec *display; } semi; } u; } **array; } *members; int number; int nodenr; int nrsons; struct affix_rec *locals; int empty; char *first; char *director; int rule_nr; } **array; } *alts; int kind; int empty; int lex; int ext; int number; int placeholder; int startswithlayout; int endsinlayout; char *first; char *follow; struct pos_list_rec *proto_display; int reachable; int has_sons; int goal; struct lextree_rec { char *remainder; struct lexend_list_rec { int size; int room; struct lexend_rec { int nodenr; struct int_list_rec *valuenrs; } **array; } *prods; struct lextree_list_rec { int size; int room; struct lextree_rec **array; } *tails; } *rev_tree; } *

user_defined_types: struct rule_rec { char *nonterminal; struct alt_list_rec *alts; int kind; int empty; int lex; int ext; int number; int placeholder; int startswithlayout; int endsinlayout; char *first; char *follow; struct pos_list_rec *proto_display; int reachable; int has_sons; int goal; struct lextree_rec *rev_tree; }

user_defined_types: struct alt_list_rec { int size; int room; struct alt_rec **array; }

user_defined_types: struct lexend_list_rec { int size; int room; struct lexend_rec **array; }

user_defined_types: struct alt_rec { struct pos_list_rec *display; struct member_list_rec *members; int number; int nodenr; int nrsons; struct affix_rec *locals; int empty; char *first; char *director; int rule_nr; }

user_defined_types: struct member_rec { int empty; int followlayout; char *first; int number; int sonnr; int tag; union { struct call_rec call; char *terminal; struct semiterminal_rec semi; } 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; }

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


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

if ( nr_of_rules > 0 )
{
v0 = 0LL;
do
decide_placeholder_rule(*(_QWORD *)(all_rules + 8 * v0++));
while ( nr_of_rules > (int)v0 );
}
}

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

if ( nr_of_rules > 0 )
{
v0 = 0LL;
do
func0(*(_QWORD *)(all_rules + 8 * v0++));
while ( nr_of_rules > (int)v0 );
}
}

original_code:
void decide_placeholders ()
 { int ix;
   for (ix = 0; ix < nr_of_rules; ix++)
      decide_placeholder_rule (all_rules[ix]);
 }

canonical_original_code:
void decide_placeholders()
 { int ix;
   for (ix = 0; ix < nr_of_rules; ix++)
      decide_placeholder_rule (all_rules[ix]);
 }

variable_types: ix int


decompiled_code:
__int64 __fastcall scan_integer_value(int *a1, __int64 a2, const char *a3, int *a4)
{
int v4; // eax
__int64 result; // rax
const char *v7; // rdx

v4 = *a1 + 1;
*a1 = v4;
if ( v4 == (_DWORD)a2 )
syntax_error((int)"missing integer argument", a2, a3);
result = strtol(*(const char **)&a3[8 * v4], 0LL, 0);
if ( (int)result <= 0 )
syntax_error((int)"illegal value", 0LL, v7);
if ( *a4 < 0 )
{
*a4 = result;
}
else if ( *a4 >= (int)result )
{
result = warning("specified value < default value, no effect");
}
else
{
*a4 = result;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(int *a1, __int64 a2, const char *a3, int *a4)
{
int v4; // eax
__int64 result; // rax
const char *v7; // rdx

v4 = *a1 + 1;
*a1 = v4;
if ( v4 == (_DWORD)a2 )
func2((int)"missing integer argument", a2, a3);
result = strtol(*(const char **)&a3[8 * v4], 0LL, 0);
if ( (int)result <= 0 )
func2((int)"illegal value", 0LL, v7);
if ( *a4 < 0 )
{
*a4 = result;
}
else if ( *a4 >= (int)result )
{
result = warning("specified value < default value, no effect");
}
else
{
*a4 = result;
}
return result;
}

original_code:
static void scan_integer_value (int *i, int argc, char **argv, int *trgt)
 { int value;
   *i += 1;
   if (*i == argc) syntax_error ("missing integer argument");
   value = strtol (argv[*i], (char **)((void *)0), 0);
   if (value <= 0) syntax_error ("illegal value");
   if (*trgt < 0) *trgt = value;
   else if (value > *trgt) *trgt = value;
   else warning ("specified value < default value, no effect");
 }

canonical_original_code:
static void scan_integer_value(int *i, int argc, char **argv, int *trgt)
 { int value;
   *i += 1;
   if (*i == argc) syntax_error ("missing integer argument");
   value = strtol (argv[*i], (char **)((void *)0), 0);
   if (value <= 0) syntax_error ("illegal value");
   if (*trgt < 0) *trgt = value;
   else if (value > *trgt) *trgt = value;
   else warning ("specified value < default value, no effect");
 }

variable_types:
i
int *

variable_types: argc int

variable_types:
argv
char **

variable_types:
trgt
int *

variable_types: value int


canonical_decompiled_code:
void func0()
{
strstore_size = 100000;
tstack_size = 10000;
qstack_size = 100000;
pbuffer_size = 100000;
ubuffer_size = 100000;
max_nr_parses = -1;
}

original_code:
static void init_options ()
 { strstore_size = 100000;
   tstack_size = 10000;
   qstack_size = 100000;
   pbuffer_size = 100000;
   ubuffer_size = 100000;
   max_nr_parses = -1;
 }

canonical_original_code:
static void init_options()
 { strstore_size = 100000;
   tstack_size = 10000;
   qstack_size = 100000;
   pbuffer_size = 100000;
   ubuffer_size = 100000;
   max_nr_parses = -1;
 }


decompiled_code:
void __noreturn print_usage()
{
wlog("usage: transducer [flags] [filename]");
wlog("or: editor [flags] [Xtoolkitoptions] [filename]");
wlog("-h: provide this help");
wlog("-v: verbose");
wlog("-db: enable debugging");
wlog("-fv: full verbose");
wlog("-ps [size]: use size as parse buffer size");
wlog("-qs [size]: use size as continuation stack size");
wlog("-ss [size]: use size as string store size");
wlog("-ts [size]: use size as tree stack size");
wlog("-us [size]: use size as unparse buffer size (editor only)");
wlog("-P number: maximum number of parses");
exit(4);
}

canonical_decompiled_code:
void __noreturn func1()
{
wlog("usage: transducer [flags] [filename]");
wlog("or: editor [flags] [Xtoolkitoptions] [filename]");
wlog("-h: provide this help");
wlog("-v: verbose");
wlog("-db: enable debugging");
wlog("-fv: full verbose");
wlog("-ps [size]: use size as parse buffer size");
wlog("-qs [size]: use size as continuation stack size");
wlog("-ss [size]: use size as string store size");
wlog("-ts [size]: use size as tree stack size");
wlog("-us [size]: use size as unparse buffer size (editor only)");
wlog("-P number: maximum number of parses");
exit(4);
}

original_code:
static void print_usage ()
 { wlog ("usage: transducer [flags] [filename]");
   wlog ("or:    editor [flags] [Xtoolkitoptions] [filename]");
   wlog ("-h:  provide this help");
   wlog ("-v:  verbose");
   wlog ("-db: enable debugging");
   wlog ("-fv: full verbose");
   wlog ("-ps [size]: use size as parse buffer size");
   wlog ("-qs [size]: use size as continuation stack size");
   wlog ("-ss [size]: use size as string store size");
   wlog ("-ts [size]: use size as tree stack size");
   wlog ("-us [size]: use size as unparse buffer size (editor only)");
   wlog ("-P number:  maximum number of parses");
   exit (4);
 }

canonical_original_code:
static void print_usage()
 { wlog ("usage: transducer [flags] [filename]");
   wlog ("or:    editor [flags] [Xtoolkitoptions] [filename]");
   wlog ("-h:  provide this help");
   wlog ("-v:  verbose");
   wlog ("-db: enable debugging");
   wlog ("-fv: full verbose");
   wlog ("-ps [size]: use size as parse buffer size");
   wlog ("-qs [size]: use size as continuation stack size");
   wlog ("-ss [size]: use size as string store size");
   wlog ("-ts [size]: use size as tree stack size");
   wlog ("-us [size]: use size as unparse buffer size (editor only)");
   wlog ("-P number:  maximum number of parses");
   exit (4);
 }


decompiled_code:
void __fastcall __noreturn syntax_error(int errnum, __int64 a2, const char *a3)
{
error((int)"error on command line: %s", errnum, a3);
print_usage();
}

canonical_decompiled_code:
void __fastcall __noreturn func2(int errnum, __int64 a2, const char *a3)
{
error((int)"error on command line: %s", errnum, a3);
func1();
}

original_code:
static void syntax_error (string error_string)
 { error ("error on command line: %s", error_string);
   print_usage ();
 }

canonical_original_code:
static void syntax_error(char *error_string)
 { error ("error on command line: %s", error_string);
   print_usage ();
 }


warshall

original_code:
char *warshall (int n, char *rel)
 { char *result = (char *) ckcalloc (n*n, sizeof (char));
   int i,j,k;
   for (i=0; i<n; i++)
      for (j=0; j<n; j++) result[i * n + j] = rel[i * n + j];
   for (k=0; k<n; k++)
      for (i=0; i<n; i++)
  for (j=0; j<n; j++)
     result[i * n + j] = result[i * n + j] ||
   (result[i * n + k] && result [k * n + j]);
   return (result);
 }

canonical_original_code:
char *warshall(int n, char *rel)
 { char *result = (char *) ckcalloc (n*n, sizeof (char));
   int i; int j; int k;
   for (i=0; i<n; i++)
      for (j=0; j<n; j++) result[i * n + j] = rel[i * n + j];
   for (k=0; k<n; k++)
      for (i=0; i<n; i++)
  for (j=0; j<n; j++)
     result[i * n + j] = result[i * n + j] ||
   (result[i * n + k] && result [k * n + j]);
   return (result);
 }

variable_types: n int

variable_types:
rel
char *

variable_types:
result
char *

variable_types: j int

variable_types: k int

return_type: char *