decompiled_code:
__int64 __fastcall initial_first_sets_in_terminal(__int64 a1)
{
__int64 result; // rax
char v2[10]; // [rsp+Eh] [rbp-Ah] BYREF

result = **(unsigned __int8 **)(a1 + 32);
if ( (_BYTE)result )
{
v2[0] = **(_BYTE **)(a1 + 32);
v2[1] = 0;
result = addto_names(v2);
*(_QWORD *)(a1 + 8) = result;
}
else
{
*(_QWORD *)(a1 + 8) = &unk_930;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1)
{
__int64 result; // rax
char v2[10]; // [rsp+Eh] [rbp-Ah] BYREF

result = **(unsigned __int8 **)(a1 + 32);
if ( (_BYTE)result )
{
v2[0] = **(_BYTE **)(a1 + 32);
v2[1] = 0;
result = addto_names(v2);
*(_QWORD *)(a1 + 8) = result;
}
else
{
*(_QWORD *)(a1 + 8) = &unk_930;
}
return result;
}

original_code:
static void initial_first_sets_in_terminal (member m)
 { char first[2];
   if (strlen (m -> u.terminal) != 0)
      { first[0] = m -> u.terminal[0];
        first[1] = '\0';
        m -> first = addto_names (first);
      }
   else m -> first = "";
 }

canonical_original_code:
static void initial_first_sets_in_terminal(struct member_rec *m)
 { char first[2];
   if (strlen (m -> u.terminal) != 0)
      { first[0] = m -> u.terminal[0];
        first[1] = '\0';
        m -> first = addto_names (first);
      }
   else m -> first = "";
 }

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

variable_types:
first
char [2]

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 call_rec { char *nonterminal; struct pos_list_rec *display; struct rule_rec *def; }

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

user_defined_types: struct meta_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:
__int64 __fastcall make_complementaryset(char *a1)
{
int i; // ebx
char vars0; // [rsp+0h] [rbp+0h] BYREF

for ( i = 1; i != 128; ++i )
{
if ( !(unsigned int)char_in_set(i, a1) )
vars0 = i;
}
vars0 = 0;
return addto_names(&vars0);
}

canonical_decompiled_code:
__int64 __fastcall func5(char *a1)
{
int i; // ebx
char vars0; // [rsp+0h] [rbp+0h] BYREF

for ( i = 1; i != 128; ++i )
{
if ( !(unsigned int)func0(i, a1) )
vars0 = i;
}
vars0 = 0;
return addto_names(&vars0);
}

original_code:
static char *make_complementaryset (char *s)
 { char buf[129];
   char *dptr = buf;
   int i;
   for (i=1; i <= 127; i++)
      if (!char_in_set (i, s))
  *dptr++ = i;
   *dptr = '\0';
   dptr = addto_names (buf);
   return (dptr);
 }

canonical_original_code:
static char *make_complementaryset(char *s)
 { char buf[129];
   char *dptr = buf;
   int i;
   for (i=1; i <= 127; i++)
      if (!char_in_set (i, s))
  *dptr++ = i;
   *dptr = '\0';
   dptr = addto_names (buf);
   return (dptr);
 }

variable_types:
s
char *

variable_types:
buf
char [129]

variable_types:
dptr
char *

variable_types: i int

return_type: char *


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

v1 = *(_QWORD *)(a1 + 32);
if ( (*(_BYTE *)v1 & 8) != 0 )
result = make_complementaryset(*(char **)(v1 + 8));
else
result = *(_QWORD *)(v1 + 8);
*(_QWORD *)(a1 + 8) = result;
return result;
}

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

v1 = *(_QWORD *)(a1 + 32);
if ( (*(_BYTE *)v1 & 8) != 0 )
result = func5(*(char **)(v1 + 8));
else
result = *(_QWORD *)(v1 + 8);
*(_QWORD *)(a1 + 8) = result;
return result;
}

original_code:
static void initial_first_sets_in_semi (member m)
 { cset set = m -> u.semi.set;
   if (set -> kind & 8)
      m -> first = make_complementaryset (set -> str);
   else m -> first = set -> str;
 }

canonical_original_code:
static void initial_first_sets_in_semi(struct member_rec *m)
 { struct cset_rec *set = m -> u.semi.set;
   if (set -> kind & 8)
      m -> first = make_complementaryset (set -> str);
   else m -> first = set -> str;
 }

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

return_type: void

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

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

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_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 lextree_list_rec { int size; int room; struct lextree_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 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_list_rec { int size; int room; struct member_rec **array; }

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 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 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 __fastcall determine_director_sets_in_alt(__int64 a1, __int64 a2)
{
__int64 result; // rax
unsigned __int8 v3[280]; // [rsp+0h] [rbp-118h] BYREF

v3[0] = 0;
addto_set(v3, *(unsigned __int8 **)(a2 + 48));
if ( *(_DWORD *)(a2 + 40) == 1 )
addto_set(v3, *(unsigned __int8 **)(a1 + 56));
result = addto_names(v3);
*(_QWORD *)(a2 + 56) = result;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1, __int64 a2)
{
__int64 result; // rax
unsigned __int8 v3[280]; // [rsp+0h] [rbp-118h] BYREF

v3[0] = 0;
func2(v3, *(unsigned __int8 **)(a2 + 48));
if ( *(_DWORD *)(a2 + 40) == 1 )
func2(v3, *(unsigned __int8 **)(a1 + 56));
result = addto_names(v3);
*(_QWORD *)(a2 + 56) = result;
return result;
}

original_code:
static void determine_director_sets_in_alt (rule srule, alt a)
 { char fset[256];
   fset [0] = '\0';
   addto_set (fset, a -> first);
   if (a -> empty == 1)
      addto_set (fset, srule -> follow);
   a -> director = addto_names (fset);
 }

canonical_original_code:
static void determine_director_sets_in_alt(struct rule_rec *srule, struct alt_rec *a)
 { char fset[256];
   fset [0] = '\0';
   addto_set (fset, a -> first);
   if (a -> empty == 1)
      addto_set (fset, srule -> follow);
   a -> director = addto_names (fset);
 }

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

variable_types:
a
struct alt_rec *

variable_types:
fset
char [256]

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_rec { char *remainder; struct lexend_list_rec *prods; struct lextree_list_rec *tails; }

user_defined_types: struct pos_list_rec { int size; int room; struct pos_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 affix_rec { char *name; int type; struct affix_rec *next; struct value_rec *val; int ref_count; int reachable; int tag; union { struct variable_rec var; char *str; int inum; double rnum; struct cset_rec *semi; struct element_rec elt; struct expr_rec *cexpr; } u; }

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


original_code:
static void determine_director_set (rule srule)
 { int ix;
   if ((srule -> kind & 2) ||
       (srule -> kind & 4)) return;
   for (ix = 0; ix < srule -> alts -> size; ix++)
      determine_director_sets_in_alt (srule, srule -> alts -> array[ix]);
 }

canonical_original_code:
static void determine_director_set(struct rule_rec *srule)
 { int ix;
   if ((srule -> kind & 2) ||
       (srule -> kind & 4)) return;
   for (ix = 0; ix < srule -> alts -> size; ix++)
      determine_director_sets_in_alt (srule, srule -> alts -> array[ix]);
 }

variable_types: ix int

user_defined_types: struct lexend_list_rec { int size; int room; struct lexend_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 member_list_rec { int size; int room; struct member_rec **array; }

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

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 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 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 cset_rec { int kind; char *str; }


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

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

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

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

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

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


decompiled_code:
__int64 __fastcall initial_first_sets_in_member(__int64 a1)
{
__int64 result; // rax
__int64 v2; // rdi

result = a1;
v2 = *(unsigned int *)(a1 + 24);
if ( (_DWORD)v2 == 2 )
return initial_first_sets_in_semi(result);
if ( (int)v2 > 2 )
{
if ( (_DWORD)v2 == 3 )
{
*(_QWORD *)(result + 8) = &unk_930;
return result;
}
return bad_tag(v2, "initial_first_sets_in_member");
}
if ( !(_DWORD)v2 )
return result;
if ( (_DWORD)v2 != 1 )
return bad_tag(v2, "initial_first_sets_in_member");
return initial_first_sets_in_terminal(result);
}

canonical_decompiled_code:
__int64 __fastcall func10(__int64 a1)
{
__int64 result; // rax
__int64 v2; // rdi

result = a1;
v2 = *(unsigned int *)(a1 + 24);
if ( (_DWORD)v2 == 2 )
return func6(result);
if ( (int)v2 > 2 )
{
if ( (_DWORD)v2 == 3 )
{
*(_QWORD *)(result + 8) = &unk_930;
return result;
}
return bad_tag(v2, "initial_first_sets_in_member");
}
if ( !(_DWORD)v2 )
return result;
if ( (_DWORD)v2 != 1 )
return bad_tag(v2, "initial_first_sets_in_member");
return func4(result);
}

original_code:
static void initial_first_sets_in_member (member m)
 { switch (m -> tag)
      { case 0: break;
        case 1: initial_first_sets_in_terminal (m); break;
        case 2: initial_first_sets_in_semi (m); break;
        case 3: m -> first = ""; break;
        default: bad_tag (m -> tag, "initial_first_sets_in_member");
      }
 }

canonical_original_code:
static void initial_first_sets_in_member(struct member_rec *m)
 { switch (m -> tag)
      { case 0: break;
        case 1: initial_first_sets_in_terminal (m); break;
        case 2: initial_first_sets_in_semi (m); break;
        case 3: m -> first = ""; break;
        default: bad_tag (m -> tag, "initial_first_sets_in_member");
      }
 }

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 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_rec { char *remainder; struct lexend_list_rec *prods; struct lextree_list_rec *tails; }

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 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 __fastcall initial_first_sets_in_members(__int64 a1)
{
__int64 v1; // rbx
__int64 result; // rax

if ( a1 && *(int *)a1 > 0 )
{
v1 = 0LL;
do
result = initial_first_sets_in_member(*(_QWORD *)(*(_QWORD *)(a1 + 8) + 8 * v1++));
while ( *(_DWORD *)a1 > (int)v1 );
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func11(__int64 a1)
{
__int64 v1; // rbx
__int64 result; // rax

if ( a1 && *(int *)a1 > 0 )
{
v1 = 0LL;
do
result = func10(*(_QWORD *)(*(_QWORD *)(a1 + 8) + 8 * v1++));
while ( *(_DWORD *)a1 > (int)v1 );
}
return result;
}

original_code:
static void initial_first_sets_in_members (member_list mems)
 { int ix;
   if (mems == ((member_list) ((void *)0))) return;
   for (ix = 0; ix < mems -> size; ix++)
      initial_first_sets_in_member (mems -> array[ix]);
 }

canonical_original_code:
static void initial_first_sets_in_members(struct member_list_rec *mems)
 { int ix;
   if (mems == ((member_list) ((void *)0))) return;
   for (ix = 0; ix < mems -> size; ix++)
      initial_first_sets_in_member (mems -> array[ix]);
 }

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

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

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

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 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 initial_first_sets_in_alts(__int64 a1)
{
__int64 v1; // rbx
__int64 result; // rax

if ( *(int *)a1 > 0 )
{
v1 = 0LL;
do
result = initial_first_sets_in_members(*(_QWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 8) + 8 * v1++) + 8LL));
while ( *(_DWORD *)a1 > (int)v1 );
}
return result;
}

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

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

original_code:
static void initial_first_sets_in_alts (alt_list alts)
 { int ix;
   for (ix = 0; ix < alts -> size; ix++)
      initial_first_sets_in_members (alts -> array[ix] -> members);
 }

canonical_original_code:
static void initial_first_sets_in_alts(struct alt_list_rec *alts)
 { int ix;
   for (ix = 0; ix < alts -> size; ix++)
      initial_first_sets_in_members (alts -> array[ix] -> members);
 }

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

user_defined_types: struct alt_list_rec { int size; int room; struct alt_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 pos_list_rec { int size; int room; struct pos_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 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 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; }


original_code:
static void initial_first_sets_in_rule (rule srule)
 { char buf[3];
   if (srule -> ext) return;
   if (srule -> kind & 2) return;
   if (srule -> kind & 4) return;
   initial_first_sets_in_alts (srule -> alts);
   if (!srule -> placeholder) return;
   buf[0] = "<|>"[0];
   if ("<|"[0] != "<|>"[0])
      { buf[1] = "<|"[0];
        buf[2] = '\0';
      }
   else buf[1] = '\0';
   srule -> first = addto_names (buf);
 }

canonical_original_code:
static void initial_first_sets_in_rule(struct rule_rec *srule)
 { char buf[3];
   if (srule -> ext) return;
   if (srule -> kind & 2) return;
   if (srule -> kind & 4) return;
   initial_first_sets_in_alts (srule -> alts);
   if (!srule -> placeholder) return;
   buf[0] = "<|>"[0];
   if ("<|"[0] != "<|>"[0])
      { buf[1] = "<|"[0];
        buf[2] = '\0';
      }
   else buf[1] = '\0';
   srule -> first = addto_names (buf);
 }

variable_types:
buf
char [3]

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:
void initial_first_sets_in_rules()
{
__int64 v0; // rbx

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

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

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

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

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


decompiled_code:
unsigned __int8 *__fastcall add_first_sets_for_member(unsigned __int8 *a1, __int64 a2)
{
unsigned __int8 *result; // rax
__int64 v3; // rdi

result = a1;
v3 = *(unsigned int *)(a2 + 24);
if ( (int)v3 <= 2 )
{
if ( (int)v3 > 0 )
return (unsigned __int8 *)addto_set(result, *(unsigned __int8 **)(a2 + 8));
if ( !(_DWORD)v3 )
return (unsigned __int8 *)add_first_sets_for_call(result, a2);
return (unsigned __int8 *)bad_tag(v3, "add_first_sets_for_member");
}
if ( (_DWORD)v3 != 3 )
return (unsigned __int8 *)bad_tag(v3, "add_first_sets_for_member");
return result;
}

canonical_decompiled_code:
unsigned __int8 *__fastcall func15(unsigned __int8 *a1, __int64 a2)
{
unsigned __int8 *result; // rax
__int64 v3; // rdi

result = a1;
v3 = *(unsigned int *)(a2 + 24);
if ( (int)v3 <= 2 )
{
if ( (int)v3 > 0 )
return (unsigned __int8 *)func2(result, *(unsigned __int8 **)(a2 + 8));
if ( !(_DWORD)v3 )
return (unsigned __int8 *)func3(result, a2);
return (unsigned __int8 *)bad_tag(v3, "add_first_sets_for_member");
}
if ( (_DWORD)v3 != 3 )
return (unsigned __int8 *)bad_tag(v3, "add_first_sets_for_member");
return result;
}

original_code:
static void add_first_sets_for_member (char *dst, member m)
 { switch (m -> tag)
      { case 0: add_first_sets_for_call (dst, m); break;
        case 1:
        case 2: addto_set (dst, m -> first);
        case 3: break;
        default: bad_tag (m -> tag, "add_first_sets_for_member");
      };
 }

canonical_original_code:
static void add_first_sets_for_member(char *dst, struct member_rec *m)
 { switch (m -> tag)
      { case 0: add_first_sets_for_call (dst, m); break;
        case 1:
        case 2: addto_set (dst, m -> first);
        case 3: break;
        default: bad_tag (m -> tag, "add_first_sets_for_member");
      };
 }

variable_types:
dst
char *

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

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

user_defined_types: struct alt_list_rec { int size; int room; struct alt_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 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 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_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 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 add_first_of_member_to_follow_set(__int64 a1, unsigned __int8 *a2)
{
__int64 result; // rax
__int64 v3; // rdi

result = a1;
v3 = *(unsigned int *)(a1 + 24);
if ( (int)v3 <= 2 )
{
if ( (int)v3 > 0 )
return addto_set(a2, *(unsigned __int8 **)(result + 8));
if ( !(_DWORD)v3 )
return addto_set(a2, *(unsigned __int8 **)(*(_QWORD *)(result + 48) + 48LL));
return bad_tag(v3, "add_first_of_member_to_follow_set");
}
if ( (_DWORD)v3 != 3 )
return bad_tag(v3, "add_first_of_member_to_follow_set");
return result;
}

canonical_decompiled_code:
__int64 __fastcall func16(__int64 a1, unsigned __int8 *a2)
{
__int64 result; // rax
__int64 v3; // rdi

result = a1;
v3 = *(unsigned int *)(a1 + 24);
if ( (int)v3 <= 2 )
{
if ( (int)v3 > 0 )
return func2(a2, *(unsigned __int8 **)(result + 8));
if ( !(_DWORD)v3 )
return func2(a2, *(unsigned __int8 **)(*(_QWORD *)(result + 48) + 48LL));
return bad_tag(v3, "add_first_of_member_to_follow_set");
}
if ( (_DWORD)v3 != 3 )
return bad_tag(v3, "add_first_of_member_to_follow_set");
return result;
}

original_code:
static void add_first_of_member_to_follow_set (member m, char *s)
 { switch (m -> tag)
      { case 0:
    addto_set (s, m -> u.call.def -> first); break;
        case 1:
        case 2: addto_set (s, m -> first);
        case 3: break;
        default: bad_tag (m -> tag, "add_first_of_member_to_follow_set");
      };
 }

canonical_original_code:
static void add_first_of_member_to_follow_set(struct member_rec *m, char *s)
 { switch (m -> tag)
      { case 0:
    addto_set (s, m -> u.call.def -> first); break;
        case 1:
        case 2: addto_set (s, m -> first);
        case 3: break;
        default: bad_tag (m -> tag, "add_first_of_member_to_follow_set");
      };
 }

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 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 lextree_rec { char *remainder; struct lexend_list_rec *prods; struct lextree_list_rec *tails; }

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 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 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 add_first_sets_for_alt(unsigned __int8 *a1, __int64 a2)
{
const char *v3; // rdi
unsigned __int8 v5[280]; // [rsp+0h] [rbp-118h] BYREF

v5[0] = 0;
addto_set(v5, *(unsigned __int8 **)(a2 + 48));
add_first_sets_for_members(v5, *(_QWORD *)(a2 + 8));
v3 = *(const char **)(a2 + 48);
if ( !v3 || strcmp(v3, (const char *)v5) )
{
*(_QWORD *)(a2 + 48) = addto_names(v5);
change = 1;
}
return addto_set(a1, *(unsigned __int8 **)(a2 + 48));
}

canonical_decompiled_code:
__int64 __fastcall func17(unsigned __int8 *a1, __int64 a2)
{
const char *v3; // rdi
unsigned __int8 v5[280]; // [rsp+0h] [rbp-118h] BYREF

v5[0] = 0;
func2(v5, *(unsigned __int8 **)(a2 + 48));
add_first_sets_for_members(v5, *(_QWORD *)(a2 + 8));
v3 = *(const char **)(a2 + 48);
if ( !v3 || strcmp(v3, (const char *)v5) )
{
*(_QWORD *)(a2 + 48) = addto_names(v5);
change = 1;
}
return func2(a1, *(unsigned __int8 **)(a2 + 48));
}

original_code:
static void add_first_sets_for_alt (char *dst, alt a)
 { char altset[256];
   altset[0] = '\0';
   addto_set (altset, a -> first);
   add_first_sets_for_members (altset, a -> members);
   if ((a -> first == ((string) ((void *)0))) ||
       (strcmp (a -> first, altset) != 0))
      { a -> first = addto_names (altset);
        change = 1;
      };
   addto_set (dst, a -> first);
 }

canonical_original_code:
static void add_first_sets_for_alt(char *dst, struct alt_rec *a)
 { char altset[256];
   altset[0] = '\0';
   addto_set (altset, a -> first);
   add_first_sets_for_members (altset, a -> members);
   if ((a -> first == ((string) ((void *)0))) ||
       (strcmp (a -> first, altset) != 0))
      { a -> first = addto_names (altset);
        change = 1;
      };
   addto_set (dst, a -> first);
 }

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

variable_types:
altset
char [256]

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 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 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 call_rec { char *nonterminal; struct pos_list_rec *display; struct rule_rec *def; }

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


original_code:
static void find_first_sets_for_rule (rule srule)
 { char ruleset[256];
   int ix;
   if (srule -> ext) return;
   if (srule -> kind & 2) return;
   if (srule -> kind & 4) return;
   ruleset[0] = '\0';
   addto_set (ruleset, srule -> first);
   for (ix = 0; ix < srule -> alts -> size; ix++)
      add_first_sets_for_alt (ruleset, srule -> alts -> array[ix]);
   if ((srule -> first == ((string) ((void *)0))) ||
       (strcmp (srule -> first, ruleset) != 0))
      { srule -> first = addto_names (ruleset);
        change = 1;
      };
 }

canonical_original_code:
static void find_first_sets_for_rule(struct rule_rec *srule)
 { char ruleset[256];
   int ix;
   if (srule -> ext) return;
   if (srule -> kind & 2) return;
   if (srule -> kind & 4) return;
   ruleset[0] = '\0';
   addto_set (ruleset, srule -> first);
   for (ix = 0; ix < srule -> alts -> size; ix++)
      add_first_sets_for_alt (ruleset, srule -> alts -> array[ix]);
   if ((srule -> first == ((string) ((void *)0))) ||
       (strcmp (srule -> first, ruleset) != 0))
      { srule -> first = addto_names (ruleset);
        change = 1;
      };
 }

variable_types:
ruleset
char [256]

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 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 semiterminal_rec { struct cset_rec *set; struct pos_list_rec *display; }

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

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

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

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

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


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

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

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

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

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

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


decompiled_code:
__int64 determine_first_sets()
{
unsigned int v0; // ebx

warning("determining first sets...");
initial_first_sets_in_rules();
v0 = 0;
do
{
change = 0;
++v0;
find_first_sets_for_rules();
}
while ( change );
return hint("used %d passes for first sets", v0);
}

canonical_decompiled_code:
__int64 func20()
{
unsigned int v0; // ebx

warning("determining first sets...");
func14();
v0 = 0;
do
{
change = 0;
++v0;
func19();
}
while ( change );
return hint("used %d passes for first sets", v0);
}

original_code:
static void determine_first_sets ()
 { int nrpasses = 0;
   warning ("determining first sets...");
   initial_first_sets_in_rules ();
   do
      { change = 0;
        nrpasses++;
        find_first_sets_for_rules ();
      }
   while (change);
   hint ("used %d passes for first sets", nrpasses);
 }

canonical_original_code:
static void determine_first_sets()
 { int nrpasses = 0;
   warning ("determining first sets...");
   initial_first_sets_in_rules ();
   do
      { change = 0;
        nrpasses++;
        find_first_sets_for_rules ();
      }
   while (change);
   hint ("used %d passes for first sets", nrpasses);
 }

variable_types: nrpasses int


decompiled_code:
void __fastcall try_update_follow_set(__int64 a1, int *a2, int a3, __int64 a4)
{
unsigned __int8 v6[296]; // [rsp+0h] [rbp-128h] BYREF

v6[0] = 0;
if ( (*(_BYTE *)(a4 + 16) & 6) == 0 )
{
addto_set(v6, *(unsigned __int8 **)(a4 + 56));
add_first_of_members_to_follow_set((__int64)a2, a3, v6);
try_add_rule_set_to_follow_set(a1, a2, a3, v6);
if ( strcmp(*(const char **)(a4 + 56), (const char *)v6) )
{
*(_QWORD *)(a4 + 56) = addto_names(v6);
change = 1;
}
}
}

canonical_decompiled_code:
void __fastcall func21(__int64 a1, int *a2, int a3, __int64 a4)
{
unsigned __int8 v6[296]; // [rsp+0h] [rbp-128h] BYREF

v6[0] = 0;
if ( (*(_BYTE *)(a4 + 16) & 6) == 0 )
{
func2(v6, *(unsigned __int8 **)(a4 + 56));
add_first_of_members_to_follow_set((__int64)a2, a3, v6);
try_add_rule_set_to_follow_set(a1, a2, a3, v6);
if ( strcmp(*(const char **)(a4 + 56), (const char *)v6) )
{
*(_QWORD *)(a4 + 56) = addto_names(v6);
change = 1;
}
}
}

original_code:
static void try_update_follow_set (rule srule, member_list mems,
        int from, rule target)
 { char fset[256];
   fset[0] = '\0';
   if ((target -> kind & 2) ||
       (target -> kind & 4)) return;
   addto_set (fset, target -> follow);
   add_first_of_members_to_follow_set (mems, from, fset);
   try_add_rule_set_to_follow_set (srule, mems, from, fset);
   if (strcmp (target -> follow, fset) != 0)
      { target -> follow = addto_names (fset);
        change = 1;
      };
 }

canonical_original_code:
static void try_update_follow_set(struct rule_rec *srule, struct member_list_rec *mems, int from, struct rule_rec *target)
 { char fset[256];
   fset[0] = '\0';
   if ((target -> kind & 2) ||
       (target -> kind & 4)) return;
   addto_set (fset, target -> follow);
   add_first_of_members_to_follow_set (mems, from, fset);
   try_add_rule_set_to_follow_set (srule, mems, from, fset);
   if (strcmp (target -> follow, fset) != 0)
      { target -> follow = addto_names (fset);
        change = 1;
      };
 }

variable_types:
mems
struct member_list_rec *

variable_types: from int

variable_types:
target
struct rule_rec *

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

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 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 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 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 __fastcall determine_follow_sets_in_members(__int64 a1, __int64 a2)
{
__int64 v2; // rbx
__int64 v3; // rax

if ( a2 && *(int *)a2 > 0 )
{
v2 = 0LL;
do
{
v3 = *(_QWORD *)(*(_QWORD *)(a2 + 8) + 8 * v2);
if ( !*(_DWORD *)(v3 + 24) )
try_update_follow_set(a1, (int *)a2, v2 + 1, *(_QWORD *)(v3 + 48));
++v2;
}
while ( *(_DWORD *)a2 > (int)v2 );
}
}

original_code:
static void determine_follow_sets_in_members (rule srule, member_list mems)
 { int ix;
   if (mems == ((member_list) ((void *)0))) return;
   for (ix = 0; ix < mems -> size; ix++)
      if (mems -> array[ix] -> tag == 0)
         try_update_follow_set (srule, mems, ix + 1,
   mems -> array[ix] -> u.call.def);
 }

canonical_original_code:
static void determine_follow_sets_in_members(struct rule_rec *srule, struct member_list_rec *mems)
 { int ix;
   if (mems == ((member_list) ((void *)0))) return;
   for (ix = 0; ix < mems -> size; ix++)
      if (mems -> array[ix] -> tag == 0)
         try_update_follow_set (srule, mems, ix + 1,
   mems -> array[ix] -> u.call.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 lexend_list_rec { int size; int room; struct lexend_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 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_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_list_rec { int size; int room; struct meta_alt_rec **array; }


decompiled_code:
void __fastcall determine_follow_sets_in_alts(__int64 a1, __int64 a2)
{
__int64 v2; // rbx

if ( *(int *)a2 > 0 )
{
v2 = 0LL;
do
determine_follow_sets_in_members(a1, *(_QWORD *)(*(_QWORD *)(*(_QWORD *)(a2 + 8) + 8 * v2++) + 8LL));
while ( *(_DWORD *)a2 > (int)v2 );
}
}

original_code:
static void determine_follow_sets_in_alts (rule srule, alt_list alts)
 { int ix;
   for (ix = 0; ix < alts -> size; ix++)
      determine_follow_sets_in_members (srule,
            alts -> array[ix] -> members);
 }

canonical_original_code:
static void determine_follow_sets_in_alts(struct rule_rec *srule, struct alt_list_rec *alts)
 { int ix;
   for (ix = 0; ix < alts -> size; ix++)
      determine_follow_sets_in_members (srule,
            alts -> array[ix] -> members);
 }

variable_types:
alts
struct alt_list_rec *

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

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

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

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

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


decompiled_code:
void __fastcall determine_follow_sets_in_rule(__int64 a1)
{
if ( (*(_BYTE *)(a1 + 16) & 6) == 0 )
determine_follow_sets_in_alts(a1, *(_QWORD *)(a1 + 8));
}

original_code:
static void determine_follow_sets_in_rule (rule srule)
 { if ((srule -> kind & 2) ||
       (srule -> kind & 4)) return;
   determine_follow_sets_in_alts (srule, srule -> alts);
 }

canonical_original_code:
static void determine_follow_sets_in_rule(struct rule_rec *srule)
 { if ((srule -> kind & 2) ||
       (srule -> kind & 4)) return;
   determine_follow_sets_in_alts (srule, srule -> alts);
 }

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 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 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 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 determine_follow_sets_in_rules()
{
__int64 v0; // rbx

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

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

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

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

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


decompiled_code:
__int64 initiate_follow_sets()
{
__int64 v0; // rbx
__int64 result; // rax
__int64 v2; // rbx
char v3; // [rsp+Eh] [rbp-Ah] BYREF
char v4; // [rsp+Fh] [rbp-9h]

v3 = -124;
v4 = 0;
v0 = *(_QWORD *)(start_rule + 48LL);
result = addto_names(&v3);
*(_QWORD *)(v0 + 56) = result;
if ( placeholderflag )
{
v3 = 60;
v4 = 0;
v2 = lookup_syntax_rule("layout");
result = addto_names(&v3);
*(_QWORD *)(v2 + 56) = result;
}
return result;
}

canonical_decompiled_code:
__int64 func26()
{
__int64 v0; // rbx
__int64 result; // rax
__int64 v2; // rbx
char v3; // [rsp+Eh] [rbp-Ah] BYREF
char v4; // [rsp+Fh] [rbp-9h]

v3 = -124;
v4 = 0;
v0 = *(_QWORD *)(start_rule + 48LL);
result = addto_names(&v3);
*(_QWORD *)(v0 + 56) = result;
if ( placeholderflag )
{
v3 = 60;
v4 = 0;
v2 = lookup_syntax_rule("layout");
result = addto_names(&v3);
*(_QWORD *)(v2 + 56) = result;
}
return result;
}

original_code:
static void initiate_follow_sets ()
 { char buf[2];
   buf[0] = '\204';
   buf[1] = '\0';
   start_rule -> u.call.def -> follow = addto_names (buf);
   if (!placeholderflag) return;
   buf[0] = "<|>"[0];
   if ("<|"[0] != buf[0])
      { buf[1] = "<|"[0];
        buf[2] = '\0';
      }
   else buf[1] = '\0';
   lookup_syntax_rule ("layout") -> follow = addto_names (buf);
 }

canonical_original_code:
static void initiate_follow_sets()
 { char buf[2];
   buf[0] = '\204';
   buf[1] = '\0';
   start_rule -> u.call.def -> follow = addto_names (buf);
   if (!placeholderflag) return;
   buf[0] = "<|>"[0];
   if ("<|"[0] != buf[0])
      { buf[1] = "<|"[0];
        buf[2] = '\0';
      }
   else buf[1] = '\0';
   lookup_syntax_rule ("layout") -> follow = addto_names (buf);
 }

variable_types:
buf
char [2]


decompiled_code:
__int64 determine_follow_sets()
{
unsigned int v0; // ebx

warning("determining follow sets...");
initiate_follow_sets();
v0 = 0;
do
{
change = 0;
++v0;
determine_follow_sets_in_rules();
}
while ( change );
return hint("used %d passes for follow sets", v0);
}

canonical_decompiled_code:
__int64 func27()
{
unsigned int v0; // ebx

warning("determining follow sets...");
func26();
v0 = 0;
do
{
change = 0;
++v0;
func25();
}
while ( change );
return hint("used %d passes for follow sets", v0);
}

original_code:
static void determine_follow_sets ()
 { int nrpasses = 0;
   warning ("determining follow sets...");
   initiate_follow_sets ();
   nrpasses = 0;
   do
      { change = 0;
        nrpasses++;
        determine_follow_sets_in_rules ();
      }
   while (change);
   hint ("used %d passes for follow sets", nrpasses);
 }

canonical_original_code:
static void determine_follow_sets()
 { int nrpasses = 0;
   warning ("determining follow sets...");
   initiate_follow_sets ();
   nrpasses = 0;
   do
      { change = 0;
        nrpasses++;
        determine_follow_sets_in_rules ();
      }
   while (change);
   hint ("used %d passes for follow sets", nrpasses);
 }


decompiled_code:
const char *__fastcall report_director_set(const char **a1)
{
const char *result; // rax
__int64 v2; // rbx

wlog("first (%s) = %s", *a1, a1[6]);
wlog("follow (%s) = %s", *a1, a1[7]);
result = a1[1];
if ( *(int *)result > 0 )
{
v2 = 0LL;
do
{
wlog(
"direct_alt (%d) = %s",
(unsigned int)(v2 + 1),
*(const char **)(*(_QWORD *)(*((_QWORD *)result + 1) + 8 * v2) + 56LL));
result = a1[1];
++v2;
}
while ( *(_DWORD *)result > (int)v2 );
}
return result;
}

canonical_decompiled_code:
const char *__fastcall func28(const char **a1)
{
const char *result; // rax
__int64 v2; // rbx

wlog("first (%s) = %s", *a1, a1[6]);
wlog("follow (%s) = %s", *a1, a1[7]);
result = a1[1];
if ( *(int *)result > 0 )
{
v2 = 0LL;
do
{
wlog(
"direct_alt (%d) = %s",
(unsigned int)(v2 + 1),
*(const char **)(*(_QWORD *)(*((_QWORD *)result + 1) + 8 * v2) + 56LL));
result = a1[1];
++v2;
}
while ( *(_DWORD *)result > (int)v2 );
}
return result;
}

original_code:
static void report_director_set (rule srule)
 { int ix;
   wlog ("first (%s) = %s", srule -> nonterminal, srule -> first);
   wlog ("follow (%s) = %s", srule -> nonterminal, srule -> follow);
   for (ix = 0; ix < srule -> alts -> size; ix++)
      wlog ("direct_alt (%d) = %s", ix + 1,
     srule -> alts -> array[ix] -> director);
 }

canonical_original_code:
static void report_director_set(struct rule_rec *srule)
 { int ix;
   wlog ("first (%s) = %s", srule -> nonterminal, srule -> first);
   wlog ("follow (%s) = %s", srule -> nonterminal, srule -> follow);
   for (ix = 0; ix < srule -> alts -> size; ix++)
      wlog ("direct_alt (%d) = %s", ix + 1,
     srule -> alts -> array[ix] -> director);
 }

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 lextree_rec { char *remainder; struct lexend_list_rec *prods; struct lextree_list_rec *tails; }

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


decompiled_code:
const char *report_director_sets()
{
__int64 v0; // rbx
const char *result; // rax

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

canonical_decompiled_code:
const char *func29()
{
__int64 v0; // rbx
const char *result; // rax

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

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

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


decompiled_code:
void determine_lookahead_sets()
{
determine_first_sets();
determine_follow_sets();
determine_director_sets();
if ( full_verbose )
report_director_sets();
}

canonical_decompiled_code:
void func30()
{
func20();
func27();
func9();
if ( full_verbose )
func29();
}

original_code:
void determine_lookahead_sets ()
 { determine_first_sets ();
   determine_follow_sets ();
   determine_director_sets ();
   if (full_verbose) report_director_sets ();
 }

canonical_original_code:
void determine_lookahead_sets()
 { determine_first_sets ();
   determine_follow_sets ();
   determine_director_sets ();
   if (full_verbose) report_director_sets ();
 }


decompiled_code:
__int64 __fastcall gather_lcin_director_set(__int64 a1, int *a2, int a3)
{
int v3; // ebp
unsigned __int8 v5[280]; // [rsp+0h] [rbp-118h] BYREF

v5[0] = 0;
v3 = a3 + 1;
add_first_of_members_to_follow_set((__int64)a2, a3 + 1, v5);
try_add_rule_set_to_follow_set(a1, a2, v3, v5);
return addto_names(v5);
}

canonical_decompiled_code:
__int64 __fastcall func31(__int64 a1, int *a2, int a3)
{
int v3; // ebp
unsigned __int8 v5[280]; // [rsp+0h] [rbp-118h] BYREF

v5[0] = 0;
v3 = a3 + 1;
add_first_of_members_to_follow_set((__int64)a2, a3 + 1, v5);
try_add_rule_set_to_follow_set(a1, a2, v3, v5);
return addto_names(v5);
}

original_code:
char *gather_lcin_director_set (rule srule, member_list mems, int j)
 { char fset[256];
   fset[0] = '\0';
   add_first_of_members_to_follow_set (mems, j + 1, fset);
   try_add_rule_set_to_follow_set (srule, mems, j + 1, fset);
   return (addto_names (fset));
 }

canonical_original_code:
char *gather_lcin_director_set(struct rule_rec *srule, struct member_list_rec *mems, int j)
 { char fset[256];
   fset[0] = '\0';
   add_first_of_members_to_follow_set (mems, j + 1, fset);
   try_add_rule_set_to_follow_set (srule, mems, j + 1, fset);
   return (addto_names (fset));
 }

variable_types: j int

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

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

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

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


decompiled_code:
__int64 __fastcall enter_meta_rule(const char **a1)
{
const char ***v1; // rbx
const char *v2; // r12
__int64 *v3; // rbp
const char ***v4; // rax
int v6; // eax

v1 = (const char ***)meta_root;
if ( meta_root )
{
v2 = *a1;
while ( 1 )
{
v6 = strcmp(v2, **v1);
v3 = (__int64 *)(v1 + 1);
if ( v6 >= 0 )
{
if ( v6 <= 0 )
return 0LL;
v3 = (__int64 *)(v1 + 2);
}
v1 = (const char ***)*v3;
if ( !*v3 )
goto LABEL_4;
}
}
v3 = &meta_root;
LABEL_4:
v4 = (const char ***)ckmalloc(24LL);
*v3 = (__int64)v4;
*v4 = a1;
*(_QWORD *)(*v3 + 8) = 0LL;
*(_QWORD *)(*v3 + 16) = 0LL;
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func0(const char **a1)
{
const char ***v1; // rbx
const char *v2; // r12
__int64 *v3; // rbp
const char ***v4; // rax
int v6; // eax

v1 = (const char ***)meta_root;
if ( meta_root )
{
v2 = *a1;
while ( 1 )
{
v6 = strcmp(v2, **v1);
v3 = (__int64 *)(v1 + 1);
if ( v6 >= 0 )
{
if ( v6 <= 0 )
return 0LL;
v3 = (__int64 *)(v1 + 2);
}
v1 = (const char ***)*v3;
if ( !*v3 )
goto LABEL_4;
}
}
v3 = &meta_root;
LABEL_4:
v4 = (const char ***)ckmalloc(24LL);
*v3 = (__int64)v4;
*v4 = a1;
*(_QWORD *)(*v3 + 8) = 0LL;
*(_QWORD *)(*v3 + 16) = 0LL;
return 1LL;
}

original_code:
int enter_meta_rule (meta_rule node)
 { meta_tree *ptr = &meta_root;
   while (1)
      { int cond;
        if (*ptr == ((meta_tree) ((void *)0)))
    { *ptr = (meta_tree) ckmalloc (sizeof (struct meta_tree_rec));
      (*ptr) -> node = node;
      (*ptr) -> left = ((meta_tree) ((void *)0));
      (*ptr) -> right = ((meta_tree) ((void *)0));
      return (1);
    };
        cond = strcmp (node -> nonterminal,
         (*ptr) -> node -> nonterminal);
        if (cond < 0) ptr = &((*ptr) -> left);
        else if (cond > 0) ptr = &((*ptr) -> right);
        else return (0);
      }
 }

canonical_original_code:
int enter_meta_rule(struct meta_rule_rec *node)
 { struct meta_tree_rec **ptr = &meta_root;
   while (1)
      { int cond;
        if (*ptr == ((meta_tree) ((void *)0)))
    { *ptr = (struct meta_tree_rec *) ckmalloc (sizeof (struct meta_tree_rec));
      (*ptr) -> node = node;
      (*ptr) -> left = ((meta_tree) ((void *)0));
      (*ptr) -> right = ((meta_tree) ((void *)0));
      return (1);
    };
        cond = strcmp (node -> nonterminal,
         (*ptr) -> node -> nonterminal);
        if (cond < 0) ptr = &((*ptr) -> left);
        else if (cond > 0) ptr = &((*ptr) -> right);
        else return (0);
      }
 }

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

variable_types: cond int

return_type: int

user_defined_types: struct meta_tree_rec { struct meta_rule_rec *node; struct meta_tree_rec *left; struct meta_tree_rec *right; }

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 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 element_rec { char *eltnm; struct element_def_rec *def; }


decompiled_code:
const char **__fastcall lookup_meta_rule(char *s1)
{
__int64 v1; // rbx
const char **v2; // rbp
int v3; // eax

v1 = meta_root;
while ( v1 )
{
v2 = *(const char ***)v1;
v3 = strcmp(s1, **(const char ***)v1);
if ( v3 < 0 )
{
v1 = *(_QWORD *)(v1 + 8);
}
else
{
if ( v3 <= 0 )
return v2;
v1 = *(_QWORD *)(v1 + 16);
}
}
return (const char **)v1;
}

canonical_decompiled_code:
const char **__fastcall func1(char *s1)
{
__int64 v1; // rbx
const char **v2; // rbp
int v3; // eax

v1 = meta_root;
while ( v1 )
{
v2 = *(const char ***)v1;
v3 = strcmp(s1, **(const char ***)v1);
if ( v3 < 0 )
{
v1 = *(_QWORD *)(v1 + 8);
}
else
{
if ( v3 <= 0 )
return v2;
v1 = *(_QWORD *)(v1 + 16);
}
}
return (const char **)v1;
}

original_code:
meta_rule lookup_meta_rule (string nont)
 { meta_tree ptr = meta_root;
   while (1)
      { int cond;
        if (ptr == ((meta_tree) ((void *)0))) return (((meta_rule) ((void *)0)));
        cond = strcmp (nont, ptr -> node -> nonterminal);
        if (cond < 0) ptr = ptr -> left;
        else if (cond > 0) ptr = ptr -> right;
        else return (ptr -> node);
      };
 }

canonical_original_code:
struct meta_rule_rec *lookup_meta_rule(char *nont)
 { struct meta_tree_rec *ptr = meta_root;
   while (1)
      { int cond;
        if (ptr == ((meta_tree) ((void *)0))) return (((meta_rule) ((void *)0)));
        cond = strcmp (nont, ptr -> node -> nonterminal);
        if (cond < 0) ptr = ptr -> left;
        else if (cond > 0) ptr = ptr -> right;
        else return (ptr -> node);
      };
 }

variable_types:
nont
char *

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

user_defined_types: struct meta_alt_list_rec { int size; int room; struct meta_alt_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; }


decompiled_code:
__int64 __fastcall enter_syntax_rule(const char **a1)
{
const char ***v1; // rbx
const char *v2; // r12
__int64 *v3; // rbp
const char ***v4; // rax
int v6; // eax

v1 = (const char ***)rule_root;
if ( rule_root )
{
v2 = *a1;
while ( 1 )
{
v6 = strcmp(v2, **v1);
v3 = (__int64 *)(v1 + 1);
if ( v6 >= 0 )
{
if ( v6 <= 0 )
return 0LL;
v3 = (__int64 *)(v1 + 2);
}
v1 = (const char ***)*v3;
if ( !*v3 )
goto LABEL_4;
}
}
v3 = &rule_root;
LABEL_4:
v4 = (const char ***)ckmalloc(24LL);
*v3 = (__int64)v4;
*v4 = a1;
*(_QWORD *)(*v3 + 8) = 0LL;
*(_QWORD *)(*v3 + 16) = 0LL;
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func2(const char **a1)
{
const char ***v1; // rbx
const char *v2; // r12
__int64 *v3; // rbp
const char ***v4; // rax
int v6; // eax

v1 = (const char ***)rule_root;
if ( rule_root )
{
v2 = *a1;
while ( 1 )
{
v6 = strcmp(v2, **v1);
v3 = (__int64 *)(v1 + 1);
if ( v6 >= 0 )
{
if ( v6 <= 0 )
return 0LL;
v3 = (__int64 *)(v1 + 2);
}
v1 = (const char ***)*v3;
if ( !*v3 )
goto LABEL_4;
}
}
v3 = &rule_root;
LABEL_4:
v4 = (const char ***)ckmalloc(24LL);
*v3 = (__int64)v4;
*v4 = a1;
*(_QWORD *)(*v3 + 8) = 0LL;
*(_QWORD *)(*v3 + 16) = 0LL;
return 1LL;
}

original_code:
int enter_syntax_rule (rule node)
 { rule_tree *ptr = &rule_root;
   while (1)
      { int cond;
        if (*ptr == ((rule_tree) ((void *)0)))
    { *ptr = (rule_tree) ckmalloc (sizeof (struct rule_tree_rec));
      (*ptr) -> node = node;
      (*ptr) -> left = ((rule_tree) ((void *)0));
      (*ptr) -> right = ((rule_tree) ((void *)0));
      return (1);
    };
        cond = strcmp (node -> nonterminal,
         (*ptr) -> node -> nonterminal);
        if (cond < 0) ptr = &((*ptr) -> left);
        else if (cond > 0) ptr = &((*ptr) -> right);
        else return (0);
      }
 }

canonical_original_code:
int enter_syntax_rule(struct rule_rec *node)
 { struct rule_tree_rec **ptr = &rule_root;
   while (1)
      { int cond;
        if (*ptr == ((rule_tree) ((void *)0)))
    { *ptr = (struct rule_tree_rec *) ckmalloc (sizeof (struct rule_tree_rec));
      (*ptr) -> node = node;
      (*ptr) -> left = ((rule_tree) ((void *)0));
      (*ptr) -> right = ((rule_tree) ((void *)0));
      return (1);
    };
        cond = strcmp (node -> nonterminal,
         (*ptr) -> node -> nonterminal);
        if (cond < 0) ptr = &((*ptr) -> left);
        else if (cond > 0) ptr = &((*ptr) -> right);
        else return (0);
      }
 }

variable_types: struct rule_tree_rec { 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; } *node; struct rule_tree_rec *left; struct rule_tree_rec *right; } **

user_defined_types: struct rule_tree_rec { struct rule_rec *node; struct rule_tree_rec *left; struct rule_tree_rec *right; }

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


decompiled_code:
const char **__fastcall lookup_syntax_rule(char *s1)
{
__int64 v1; // rbx
const char **v2; // rbp
int v3; // eax

v1 = rule_root;
while ( v1 )
{
v2 = *(const char ***)v1;
v3 = strcmp(s1, **(const char ***)v1);
if ( v3 < 0 )
{
v1 = *(_QWORD *)(v1 + 8);
}
else
{
if ( v3 <= 0 )
return v2;
v1 = *(_QWORD *)(v1 + 16);
}
}
return (const char **)v1;
}

canonical_decompiled_code:
const char **__fastcall func3(char *s1)
{
__int64 v1; // rbx
const char **v2; // rbp
int v3; // eax

v1 = rule_root;
while ( v1 )
{
v2 = *(const char ***)v1;
v3 = strcmp(s1, **(const char ***)v1);
if ( v3 < 0 )
{
v1 = *(_QWORD *)(v1 + 8);
}
else
{
if ( v3 <= 0 )
return v2;
v1 = *(_QWORD *)(v1 + 16);
}
}
return (const char **)v1;
}

original_code:
rule lookup_syntax_rule (string nont)
 { rule_tree ptr = rule_root;
   while (1)
      { int cond;
        if (ptr == ((rule_tree) ((void *)0))) return (((rule) ((void *)0)));
        cond = strcmp (nont, ptr -> node -> nonterminal);
        if (cond < 0) ptr = ptr -> left;
        else if (cond > 0) ptr = ptr -> right;
        else return (ptr -> node);
      };
 }

canonical_original_code:
struct rule_rec *lookup_syntax_rule(char *nont)
 { struct rule_tree_rec *ptr = rule_root;
   while (1)
      { int cond;
        if (ptr == ((rule_tree) ((void *)0))) return (((rule) ((void *)0)));
        cond = strcmp (nont, ptr -> node -> nonterminal);
        if (cond < 0) ptr = ptr -> left;
        else if (cond > 0) ptr = ptr -> right;
        else return (ptr -> node);
      };
 }

variable_types: struct rule_tree_rec { 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; } *node; struct rule_tree_rec *left; struct rule_tree_rec *right; } *

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 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 enter_element(const char **a1)
{
const char ***v1; // rbx
const char *v2; // r12
__int64 *v3; // rbp
const char ***v4; // rax
int v6; // eax

v1 = (const char ***)element_root;
if ( element_root )
{
v2 = *a1;
while ( 1 )
{
v6 = strcmp(v2, **v1);
v3 = (__int64 *)(v1 + 1);
if ( v6 >= 0 )
{
if ( v6 <= 0 )
return 0LL;
v3 = (__int64 *)(v1 + 2);
}
v1 = (const char ***)*v3;
if ( !*v3 )
goto LABEL_4;
}
}
v3 = &element_root;
LABEL_4:
v4 = (const char ***)ckmalloc(24LL);
*v3 = (__int64)v4;
*v4 = a1;
*(_QWORD *)(*v3 + 8) = 0LL;
*(_QWORD *)(*v3 + 16) = 0LL;
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func4(const char **a1)
{
const char ***v1; // rbx
const char *v2; // r12
__int64 *v3; // rbp
const char ***v4; // rax
int v6; // eax

v1 = (const char ***)element_root;
if ( element_root )
{
v2 = *a1;
while ( 1 )
{
v6 = strcmp(v2, **v1);
v3 = (__int64 *)(v1 + 1);
if ( v6 >= 0 )
{
if ( v6 <= 0 )
return 0LL;
v3 = (__int64 *)(v1 + 2);
}
v1 = (const char ***)*v3;
if ( !*v3 )
goto LABEL_4;
}
}
v3 = &element_root;
LABEL_4:
v4 = (const char ***)ckmalloc(24LL);
*v3 = (__int64)v4;
*v4 = a1;
*(_QWORD *)(*v3 + 8) = 0LL;
*(_QWORD *)(*v3 + 16) = 0LL;
return 1LL;
}

original_code:
int enter_element (element_def node)
 { element_tree *ptr = &element_root;
   while (1)
      { int cond;
        if (*ptr == ((element_tree) ((void *)0)))
    { *ptr = (element_tree) ckmalloc
     (sizeof (struct element_tree_rec));
      (*ptr) -> node = node;
      (*ptr) -> left = ((element_tree) ((void *)0));
      (*ptr) -> right = ((element_tree) ((void *)0));
      return (1);
    };
        cond = strcmp (node -> eltnm, (*ptr) -> node -> eltnm);
        if (cond < 0) ptr = &((*ptr) -> left);
        else if (cond > 0) ptr = &((*ptr) -> right);
        else return (0);
      }
 }

canonical_original_code:
int enter_element(struct element_def_rec *node)
 { struct element_tree_rec **ptr = &element_root;
   while (1)
      { int cond;
        if (*ptr == ((element_tree) ((void *)0)))
    { *ptr = (struct element_tree_rec *) ckmalloc
     (sizeof (struct element_tree_rec));
      (*ptr) -> node = node;
      (*ptr) -> left = ((element_tree) ((void *)0));
      (*ptr) -> right = ((element_tree) ((void *)0));
      return (1);
    };
        cond = strcmp (node -> eltnm, (*ptr) -> node -> eltnm);
        if (cond < 0) ptr = &((*ptr) -> left);
        else if (cond > 0) ptr = &((*ptr) -> right);
        else return (0);
      }
 }

variable_types: struct element_tree_rec { 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; } *node; struct element_tree_rec *left; struct element_tree_rec *right; } **

user_defined_types: struct element_tree_rec { struct element_def_rec *node; struct element_tree_rec *left; struct element_tree_rec *right; }


decompiled_code:
const char **__fastcall lookup_element(char *s1)
{
__int64 v1; // rbx
const char **v2; // rbp
int v3; // eax

v1 = element_root;
while ( v1 )
{
v2 = *(const char ***)v1;
v3 = strcmp(s1, **(const char ***)v1);
if ( v3 < 0 )
{
v1 = *(_QWORD *)(v1 + 8);
}
else
{
if ( v3 <= 0 )
return v2;
v1 = *(_QWORD *)(v1 + 16);
}
}
return (const char **)v1;
}

canonical_decompiled_code:
const char **__fastcall func5(char *s1)
{
__int64 v1; // rbx
const char **v2; // rbp
int v3; // eax

v1 = element_root;
while ( v1 )
{
v2 = *(const char ***)v1;
v3 = strcmp(s1, **(const char ***)v1);
if ( v3 < 0 )
{
v1 = *(_QWORD *)(v1 + 8);
}
else
{
if ( v3 <= 0 )
return v2;
v1 = *(_QWORD *)(v1 + 16);
}
}
return (const char **)v1;
}

original_code:
element_def lookup_element (string eltnm)
 { element_tree ptr = element_root;
   while (1)
      { int cond;
        if (ptr == ((element_tree) ((void *)0))) return (((element_def) ((void *)0)));
        cond = strcmp (eltnm, ptr -> node -> eltnm);
        if (cond < 0) ptr = ptr -> left;
        else if (cond > 0) ptr = ptr -> right;
        else return (ptr -> node);
      };
 }

canonical_original_code:
struct element_def_rec *lookup_element(char *eltnm)
 { struct element_tree_rec *ptr = element_root;
   while (1)
      { int cond;
        if (ptr == ((element_tree) ((void *)0))) return (((element_def) ((void *)0)));
        cond = strcmp (eltnm, ptr -> node -> eltnm);
        if (cond < 0) ptr = ptr -> left;
        else if (cond > 0) ptr = ptr -> right;
        else return (ptr -> node);
      };
 }

variable_types:
eltnm
char *

variable_types: struct element_tree_rec { 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; } *node; struct element_tree_rec *left; struct element_tree_rec *right; } *