decompiled_code:
__int64 context_sensitive_analysis()
{
do_numbering(0LL);
identification();
do_element_numbering();
infer_typing();
construct_lattices();
do_empty_classification();
flow_check();
return dump_grammar_typing();
}

canonical_decompiled_code:
__int64 func11()
{
do_numbering(0LL);
identification();
do_element_numbering();
infer_typing();
construct_lattices();
do_empty_classification();
flow_check();
return dump_grammar_typing();
}

original_code:
static void context_sensitive_analysis ()
 { do_numbering (0);
   identification ();
   do_element_numbering ();
   infer_typing ();
   construct_lattices ();
   do_empty_classification ();
   flow_check ();
   dump_grammar_typing ();
 }

canonical_original_code:
static void context_sensitive_analysis()
 { do_numbering (0);
   identification ();
   do_element_numbering ();
   infer_typing ();
   construct_lattices ();
   do_empty_classification ();
   flow_check ();
   dump_grammar_typing ();
 }


repo: tjordanchat/eag

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

propagate_constants();
check_lexicon();
reduce_grammar();
check_recursion();
if ( placeholderflag )
decide_placeholders();
if ( lookahead )
determine_lookahead_sets();
prepare_grammar();
prepare_lexicon(a1);
result = (unsigned int)editor;
if ( editor )
{
result = analyze_layout();
if ( editor )
result = generate_unparsing_rules(a1);
}
return result;
}

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

propagate_constants();
check_lexicon();
reduce_grammar();
check_recursion();
if ( placeholderflag )
decide_placeholders();
if ( lookahead )
determine_lookahead_sets();
prepare_grammar();
prepare_lexicon(a1);
result = (unsigned int)editor;
if ( editor )
{
result = analyze_layout();
if ( editor )
result = generate_unparsing_rules(a1);
}
return result;
}

original_code:
static void prepare_parser_generation (string basename)
 { propagate_constants ();
   check_lexicon ();
   reduce_grammar ();
   check_recursion ();
   if (placeholderflag) decide_placeholders ();
   if (lookahead) determine_lookahead_sets ();
   prepare_grammar ();
   prepare_lexicon (basename);
   if (editor) analyze_layout ();
   if (editor) generate_unparsing_rules (basename);
 }

canonical_original_code:
static void prepare_parser_generation(char *basename)
 { propagate_constants ();
   check_lexicon ();
   reduce_grammar ();
   check_recursion ();
   if (placeholderflag) decide_placeholders ();
   if (lookahead) determine_lookahead_sets ();
   prepare_grammar ();
   prepare_lexicon (basename);
   if (editor) analyze_layout ();
   if (editor) generate_unparsing_rules (basename);
 }

variable_types:
basename
char *

return_type: void


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

if ( topdown )
generate_topdown_parser(a1, predefs);
if ( leftcorner )
generate_leftcorner_parser(a1, predefs);
result = (unsigned int)lr;
if ( lr )
result = generate_lr_parser(a1, predefs);
return result;
}

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

if ( topdown )
generate_topdown_parser(a1, predefs);
if ( leftcorner )
generate_leftcorner_parser(a1, predefs);
result = (unsigned int)lr;
if ( lr )
result = generate_lr_parser(a1, predefs);
return result;
}

original_code:
static void generate_code (string basename)
 { if (topdown) generate_topdown_parser (basename, predefs);
   if (leftcorner) generate_leftcorner_parser (basename, predefs);
   if (lr) generate_lr_parser (basename, predefs);
 }

canonical_original_code:
static void generate_code(char *basename)
 { if (topdown) generate_topdown_parser (basename, predefs);
   if (leftcorner) generate_leftcorner_parser (basename, predefs);
   if (lr) generate_lr_parser (basename, predefs);
 }


decompiled_code:
void __fastcall parse_command_line(signed int a1, const char *a2)
{
int i; // eax
__int64 v4; // rdi
int v5[7]; // [rsp+Ch] [rbp-1Ch] BYREF

v5[0] = 1;
if ( a1 > 1 )
{
for ( i = 1; i < a1; v5[0] = i )
{
while ( 1 )
{
v4 = *(_QWORD *)&a2[8 * i];
if ( *(_BYTE *)v4 == 45 )
break;
add_grammar_to_inputs((char *)v4);
i = v5[0] + 1;
v5[0] = i;
if ( i >= a1 )
return;
}
scan_option((const char *)(v4 + 1), v5, a1, a2);
i = v5[0] + 1;
}
}
}

original_code:
static void parse_command_line (int argc, char **argv)
 { int ix;
   for (ix = 1; ix < argc; ix++)
      { char *arg = argv[ix];
        if (arg[0] == '-') scan_option (arg+1, &ix, argc, argv);
        else add_grammar_to_inputs (arg);
      };
 }

canonical_original_code:
static void parse_command_line(int argc, char **argv)
 { int ix;
   for (ix = 1; ix < argc; ix++)
      { char *arg = argv[ix];
        if (arg[0] == '-') scan_option (arg+1, &ix, argc, argv);
        else add_grammar_to_inputs (arg);
      };
 }

variable_types: argc int

variable_types:
argv
char **

variable_types: ix int

variable_types:
arg
char *


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int64 v4[4]; // [rsp+8h] [rbp-20h] BYREF

init_command_line_parsing(argc, argv, envp);
parse_command_line(argc, (const char *)argv);
report_version();
init_compiler();
context_free_analysis(v4);
context_sensitive_analysis();
prepare_parser_generation(v4[0]);
unparse_eag();
generate_code(v4[0]);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int64 v4[4]; // [rsp+8h] [rbp-20h] BYREF

func1(argc, argv, envp);
func15(argc, (const char *)argv);
func2();
func8();
func10(v4);
func11();
func12(v4[0]);
unparse_eag();
func13(v4[0]);
return 0;
}

original_code:
int main (int argc, char **argv)
 { string basename;
   init_command_line_parsing ();
   parse_command_line (argc, argv);
   report_version ();
   init_compiler ();
   context_free_analysis (&basename);
   context_sensitive_analysis ();
   prepare_parser_generation (basename);
   unparse_eag ();
   generate_code (basename);
   return (0);
 }

canonical_original_code:
int main(int argc, char **argv)
 { char *basename;
   init_command_line_parsing ();
   parse_command_line (argc, argv);
   report_version ();
   init_compiler ();
   context_free_analysis (&basename);
   context_sensitive_analysis ();
   prepare_parser_generation (basename);
   unparse_eag ();
   generate_code (basename);
   return (0);
 }

return_type: int


canonical_decompiled_code:
void func0()
{
showversion = 0;
topdown = 0;
leftcorner = 1;
interface_to_c = 0;
lr = 0;
editor = 0;
layoutflag = 0;
placeholderflag = 0;
indirect_templates = 0;
traceflag = 0;
matchflag = 0;
dumpflag = 0;
lookahead = 1;
lookahead_error_messages = 0;
qstackflag = 0;
ignore_lexicon = 0;
v1_compatibility = 0;
strstore_size = 100000;
}

original_code:
static void init_options ()
 { showversion = 0;
   topdown = 0;
   leftcorner = 1;
   interface_to_c = 0;
   lr = 0;
   editor = 0;
   layoutflag = 0;
   placeholderflag = 0;
   indirect_templates = 0;
   traceflag = 0;
   matchflag = 0;
   dumpflag = 0;
   lookahead = 1;
   lookahead_error_messages = 0;
   qstackflag = 0;
   ignore_lexicon = 0;
   v1_compatibility = 0;
   strstore_size = 100000;
 }

canonical_original_code:
static void init_options()
 { showversion = 0;
   topdown = 0;
   leftcorner = 1;
   interface_to_c = 0;
   lr = 0;
   editor = 0;
   layoutflag = 0;
   placeholderflag = 0;
   indirect_templates = 0;
   traceflag = 0;
   matchflag = 0;
   dumpflag = 0;
   lookahead = 1;
   lookahead_error_messages = 0;
   qstackflag = 0;
   ignore_lexicon = 0;
   v1_compatibility = 0;
   strstore_size = 100000;
 }


decompiled_code:
void __noreturn print_usage()
{
wlog("usage: eag-compile [flags] [filenames]");
wlog("-h: provide this help");
wlog("-V: show version");
wlog("-v: verbose");
wlog("-fv: full verbose");
wlog("-p [filename]: include filename as extra prelude");
wlog("-ic: generate interface to C");
wlog("-ed: generate editor");
wlog("-td: generate topdown parser");
wlog("-lc: generate leftcorner parser");
wlog("-lr: generate lr parser (not yet implemented)");
wlog("-gl: generate code to report error messages on lookahead failure");
wlog("-il: generate code without lexicon");
wlog("-nl: do not use lookahead");
wlog("-sl: shortcut rule(s) for layout");
wlog("-pp: generate code to parse placeholders");
wlog("-it: generate indirect templates");
wlog("-D: generate code to dump parse tree");
wlog("-M: generate code to count number of matches");
wlog("-T: generate code to enable tracing");
wlog("-qc: generate code to check the runtime qstack");
wlog("-v1: accept eag version 1.6 syntax and semantics");
wlog("-ss [size]: use size as string store size");
exit(4);
}

canonical_decompiled_code:
void __noreturn func3()
{
wlog("usage: eag-compile [flags] [filenames]");
wlog("-h: provide this help");
wlog("-V: show version");
wlog("-v: verbose");
wlog("-fv: full verbose");
wlog("-p [filename]: include filename as extra prelude");
wlog("-ic: generate interface to C");
wlog("-ed: generate editor");
wlog("-td: generate topdown parser");
wlog("-lc: generate leftcorner parser");
wlog("-lr: generate lr parser (not yet implemented)");
wlog("-gl: generate code to report error messages on lookahead failure");
wlog("-il: generate code without lexicon");
wlog("-nl: do not use lookahead");
wlog("-sl: shortcut rule(s) for layout");
wlog("-pp: generate code to parse placeholders");
wlog("-it: generate indirect templates");
wlog("-D: generate code to dump parse tree");
wlog("-M: generate code to count number of matches");
wlog("-T: generate code to enable tracing");
wlog("-qc: generate code to check the runtime qstack");
wlog("-v1: accept eag version 1.6 syntax and semantics");
wlog("-ss [size]: use size as string store size");
exit(4);
}

original_code:
static void print_usage ()
 { wlog ("usage: eag-compile [flags] [filenames]");
   wlog ("-h:  provide this help");
   wlog ("-V:  show version");
   wlog ("-v:  verbose");
   wlog ("-fv: full verbose");
   wlog ("-p [filename]: include filename as extra prelude");
   wlog ("-ic: generate interface to C");
   wlog ("-ed: generate editor");
   wlog ("-td: generate topdown parser");
   wlog ("-lc: generate leftcorner parser");
   wlog ("-lr: generate lr parser (not yet implemented)");
   wlog ("-gl: generate code to report error messages on lookahead failure");
   wlog ("-il: generate code without lexicon");
   wlog ("-nl: do not use lookahead");
   wlog ("-sl: shortcut rule(s) for layout");
   wlog ("-pp: generate code to parse placeholders");
   wlog ("-it: generate indirect templates");
   wlog ("-D:  generate code to dump parse tree");
   wlog ("-M:  generate code to count number of matches");
   wlog ("-T:  generate code to enable tracing");
   wlog ("-qc: generate code to check the runtime qstack");
   wlog ("-v1: accept eag version 1.6 syntax and semantics");
   wlog ("-ss [size]: use size as string store size");
   exit (4);
 }

canonical_original_code:
static void print_usage()
 { wlog ("usage: eag-compile [flags] [filenames]");
   wlog ("-h:  provide this help");
   wlog ("-V:  show version");
   wlog ("-v:  verbose");
   wlog ("-fv: full verbose");
   wlog ("-p [filename]: include filename as extra prelude");
   wlog ("-ic: generate interface to C");
   wlog ("-ed: generate editor");
   wlog ("-td: generate topdown parser");
   wlog ("-lc: generate leftcorner parser");
   wlog ("-lr: generate lr parser (not yet implemented)");
   wlog ("-gl: generate code to report error messages on lookahead failure");
   wlog ("-il: generate code without lexicon");
   wlog ("-nl: do not use lookahead");
   wlog ("-sl: shortcut rule(s) for layout");
   wlog ("-pp: generate code to parse placeholders");
   wlog ("-it: generate indirect templates");
   wlog ("-D:  generate code to dump parse tree");
   wlog ("-M:  generate code to count number of matches");
   wlog ("-T:  generate code to enable tracing");
   wlog ("-qc: generate code to check the runtime qstack");
   wlog ("-v1: accept eag version 1.6 syntax and semantics");
   wlog ("-ss [size]: use size as string store size");
   exit (4);
 }


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

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

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

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


decompiled_code:
int __fastcall scan_option(const char *a1, int *a2, unsigned int a3, const char *a4)
{
int result; // eax
const char *v6; // rdx

result = *(unsigned __int8 *)a1;
if ( result == 116 && a1[1] == 100 && !a1[2] )
{
topdown = 1;
leftcorner = 0;
lr = 0;
return result;
}
if ( result == 108 )
{
if ( a1[1] == 99 && !a1[2] )
{
topdown = 0;
leftcorner = 1;
lr = 0;
return result;
}
if ( a1[1] == 114 && !a1[2] )
{
topdown = 0;
leftcorner = 0;
lr = 1;
return result;
}
}
if ( result == 101 && a1[1] == 100 && !a1[2] )
{
editor = 1;
layoutflag = 1;
placeholderflag = 1;
interface_to_c = 0;
return result;
}
if ( result == 105 && a1[1] == 116 && !a1[2] )
{
indirect_templates = 1;
return result;
}
if ( result == 115 && a1[1] == 108 && !a1[2] )
{
layoutflag = 1;
return result;
}
if ( result == 105 )
{
if ( a1[1] == 108 && !a1[2] )
{
ignore_lexicon = 1;
return result;
}
if ( a1[1] == 99 && !a1[2] )
{
interface_to_c = 1;
editor = 0;
return result;
}
}
if ( result == 112 && a1[1] == 112 && !a1[2] )
{
layoutflag = 1;
placeholderflag = 1;
}
else
{
result = *(unsigned __int8 *)a1;
if ( result != 112 || a1[1] )
{
if ( result == 104 && !a1[1] )
print_usage();
if ( result != 86 || a1[1] )
{
result = strcmp(a1, "v");
if ( result )
{
result = strcmp(a1, "fv");
if ( result )
{
result = strcmp(a1, "T");
if ( result )
{
result = strcmp(a1, "M");
if ( result )
{
result = strcmp(a1, "D");
if ( result )
{
result = strcmp(a1, "nl");
if ( result )
{
result = strcmp(a1, "gl");
if ( result )
{
result = strcmp(a1, "qc");
if ( result )
{
result = strcmp(a1, "v1");
if ( result )
{
if ( strcmp(a1, "ss") )
syntax_error((int)"illegal option specified", (__int64)"ss", v6);
result = new_strstore_size(a2, a3, a4);
}
else
{
v1_compatibility = 1;
}
}
else
{
qstackflag = 1;
}
}
else
{
lookahead_error_messages = 1;
}
}
else
{
lookahead = 0;
}
}
else
{
dumpflag = 1;
}
}
else
{
matchflag = 1;
}
}
else
{
traceflag = 1;
}
}
else
{
showversion = 1;
verbose = 1;
full_verbose = 1;
}
}
else
{
showversion = 1;
verbose = 1;
}
}
else
{
showversion = 1;
}
}
else
{
result = new_prelude(a2, a3, a4);
}
}
return result;
}

canonical_decompiled_code:
int __fastcall func7(const char *a1, int *a2, unsigned int a3, const char *a4)
{
int result; // eax
const char *v6; // rdx

result = *(unsigned __int8 *)a1;
if ( result == 116 && a1[1] == 100 && !a1[2] )
{
topdown = 1;
leftcorner = 0;
lr = 0;
return result;
}
if ( result == 108 )
{
if ( a1[1] == 99 && !a1[2] )
{
topdown = 0;
leftcorner = 1;
lr = 0;
return result;
}
if ( a1[1] == 114 && !a1[2] )
{
topdown = 0;
leftcorner = 0;
lr = 1;
return result;
}
}
if ( result == 101 && a1[1] == 100 && !a1[2] )
{
editor = 1;
layoutflag = 1;
placeholderflag = 1;
interface_to_c = 0;
return result;
}
if ( result == 105 && a1[1] == 116 && !a1[2] )
{
indirect_templates = 1;
return result;
}
if ( result == 115 && a1[1] == 108 && !a1[2] )
{
layoutflag = 1;
return result;
}
if ( result == 105 )
{
if ( a1[1] == 108 && !a1[2] )
{
ignore_lexicon = 1;
return result;
}
if ( a1[1] == 99 && !a1[2] )
{
interface_to_c = 1;
editor = 0;
return result;
}
}
if ( result == 112 && a1[1] == 112 && !a1[2] )
{
layoutflag = 1;
placeholderflag = 1;
}
else
{
result = *(unsigned __int8 *)a1;
if ( result != 112 || a1[1] )
{
if ( result == 104 && !a1[1] )
func3();
if ( result != 86 || a1[1] )
{
result = strcmp(a1, "v");
if ( result )
{
result = strcmp(a1, "fv");
if ( result )
{
result = strcmp(a1, "T");
if ( result )
{
result = strcmp(a1, "M");
if ( result )
{
result = strcmp(a1, "D");
if ( result )
{
result = strcmp(a1, "nl");
if ( result )
{
result = strcmp(a1, "gl");
if ( result )
{
result = strcmp(a1, "qc");
if ( result )
{
result = strcmp(a1, "v1");
if ( result )
{
if ( strcmp(a1, "ss") )
func4((int)"illegal option specified", (__int64)"ss", v6);
result = func6(a2, a3, a4);
}
else
{
v1_compatibility = 1;
}
}
else
{
qstackflag = 1;
}
}
else
{
lookahead_error_messages = 1;
}
}
else
{
lookahead = 0;
}
}
else
{
dumpflag = 1;
}
}
else
{
matchflag = 1;
}
}
else
{
traceflag = 1;
}
}
else
{
showversion = 1;
verbose = 1;
full_verbose = 1;
}
}
else
{
showversion = 1;
verbose = 1;
}
}
else
{
showversion = 1;
}
}
else
{
result = func5(a2, a3, a4);
}
}
return result;
}

original_code:
static void scan_option (char *ptr, int *i, int argc, char **argv)
 { if (strcmp (ptr, "td") == 0) { topdown = 1; leftcorner = 0; lr = 0; }
   else if (strcmp (ptr, "lc") == 0) { topdown = 0; leftcorner = 1; lr = 0; }
   else if (strcmp (ptr, "lr") == 0) { topdown = 0; leftcorner = 0; lr = 1; }
   else if (strcmp (ptr, "ed") == 0)
             { editor = 1; layoutflag = 1; placeholderflag = 1; interface_to_c = 0; }
   else if (strcmp (ptr, "it") == 0) indirect_templates = 1;
   else if (strcmp (ptr, "sl") == 0) layoutflag = 1;
   else if (strcmp (ptr, "il") == 0) ignore_lexicon = 1;
   else if (strcmp (ptr, "ic") == 0) { interface_to_c = 1; editor = 0; }
   else if (strcmp (ptr, "pp") == 0) { layoutflag = 1; placeholderflag = 1; }
   else if (strcmp (ptr, "p") == 0) new_prelude (i, argc, argv);
   else if (strcmp (ptr, "h") == 0) print_usage ();
   else if (strcmp (ptr, "V") == 0) showversion = 1;
   else if (strcmp (ptr, "v") == 0) { showversion = 1; verbose = 1; }
   else if (strcmp (ptr, "fv") == 0) { showversion = 1; verbose = 1; full_verbose = 1; }
   else if (strcmp (ptr, "T") == 0) traceflag = 1;
   else if (strcmp (ptr, "M") == 0) matchflag = 1;
   else if (strcmp (ptr, "D") == 0) dumpflag = 1;
   else if (strcmp (ptr, "nl") == 0) lookahead = 0;
   else if (strcmp (ptr, "gl") == 0) lookahead_error_messages = 1;
   else if (strcmp (ptr, "qc") == 0) qstackflag = 1;
   else if (strcmp (ptr, "v1") == 0) v1_compatibility = 1;
   else if (strcmp (ptr, "ss") == 0) new_strstore_size (i, argc, argv);
   else syntax_error ("illegal option specified");
 }

canonical_original_code:
static void scan_option(char *ptr, int *i, int argc, char **argv)
 { if (strcmp (ptr, "td") == 0) { topdown = 1; leftcorner = 0; lr = 0; }
   else if (strcmp (ptr, "lc") == 0) { topdown = 0; leftcorner = 1; lr = 0; }
   else if (strcmp (ptr, "lr") == 0) { topdown = 0; leftcorner = 0; lr = 1; }
   else if (strcmp (ptr, "ed") == 0)
             { editor = 1; layoutflag = 1; placeholderflag = 1; interface_to_c = 0; }
   else if (strcmp (ptr, "it") == 0) indirect_templates = 1;
   else if (strcmp (ptr, "sl") == 0) layoutflag = 1;
   else if (strcmp (ptr, "il") == 0) ignore_lexicon = 1;
   else if (strcmp (ptr, "ic") == 0) { interface_to_c = 1; editor = 0; }
   else if (strcmp (ptr, "pp") == 0) { layoutflag = 1; placeholderflag = 1; }
   else if (strcmp (ptr, "p") == 0) new_prelude (i, argc, argv);
   else if (strcmp (ptr, "h") == 0) print_usage ();
   else if (strcmp (ptr, "V") == 0) showversion = 1;
   else if (strcmp (ptr, "v") == 0) { showversion = 1; verbose = 1; }
   else if (strcmp (ptr, "fv") == 0) { showversion = 1; verbose = 1; full_verbose = 1; }
   else if (strcmp (ptr, "T") == 0) traceflag = 1;
   else if (strcmp (ptr, "M") == 0) matchflag = 1;
   else if (strcmp (ptr, "D") == 0) dumpflag = 1;
   else if (strcmp (ptr, "nl") == 0) lookahead = 0;
   else if (strcmp (ptr, "gl") == 0) lookahead_error_messages = 1;
   else if (strcmp (ptr, "qc") == 0) qstackflag = 1;
   else if (strcmp (ptr, "v1") == 0) v1_compatibility = 1;
   else if (strcmp (ptr, "ss") == 0) new_strstore_size (i, argc, argv);
   else syntax_error ("illegal option specified");
 }

variable_types:
ptr
char *

variable_types:
i
int *


decompiled_code:
int __fastcall add_grammar_to_inputs(char *s2)
{
__int64 v1; // r13
const char **v2; // rbx
__int64 v3; // r12
int result; // eax

v1 = inputs;
if ( *(int *)inputs <= 0 )
return app_string_list(v1, s2);
v2 = *(const char ***)(inputs + 8);
v3 = (__int64)&v2[(unsigned int)(*(_DWORD *)inputs - 1) + 1];
while ( 1 )
{
result = strcmp(*v2, s2);
if ( !result )
break;
if ( ++v2 == (const char **)v3 )
return app_string_list(v1, s2);
}
return result;
}

canonical_decompiled_code:
int __fastcall func14(char *s2)
{
__int64 v1; // r13
const char **v2; // rbx
__int64 v3; // r12
int result; // eax

v1 = inputs;
if ( *(int *)inputs <= 0 )
return app_string_list(v1, s2);
v2 = *(const char ***)(inputs + 8);
v3 = (__int64)&v2[(unsigned int)(*(_DWORD *)inputs - 1) + 1];
while ( 1 )
{
result = strcmp(*v2, s2);
if ( !result )
break;
if ( ++v2 == (const char **)v3 )
return app_string_list(v1, s2);
}
return result;
}

original_code:
void add_grammar_to_inputs (string gname)
 { int ix;
   for (ix = 0; ix < inputs -> size; ix++)
      if ((!strcmp(inputs -> array[ix],gname))) return;
   app_string_list (inputs, gname);
 }

canonical_original_code:
void add_grammar_to_inputs(char *gname)
 { int ix;
   for (ix = 0; ix < inputs -> size; ix++)
      if ((!strcmp(inputs -> array[ix],gname))) return;
   app_string_list (inputs, gname);
 }

variable_types:
gname
char *


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

debug = 0;
verbose = 0;
result = &full_verbose;
full_verbose = 0;
return result;
}

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

debug = 0;
verbose = 0;
result = &full_verbose;
full_verbose = 0;
return result;
}

original_code:
void init_error ()
{ debug = 0;
  verbose = 0;
  full_verbose = 0;
}

canonical_original_code:
void init_error()
{ debug = 0;
  verbose = 0;
  full_verbose = 0;
}


panic

decompiled_code:
void __noreturn panic(char *format, ...)
{
gcc_va_list arg; // [rsp+8h] [rbp-4D0h] BYREF
char s[1024]; // [rsp+20h] [rbp-4B8h] BYREF

va_start(arg, format);
vsprintf(s, format, arg);
fprintf(stderr, "%s\n", s);
exit(4);
}

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

va_start(arg, format);
vsprintf(s, format, arg);
fprintf(stderr, "%s\n", s);
exit(4);
}

original_code:
void panic (char *format, ...)
{ char buf[1024];
  va_list arg_ptr;
  __builtin_va_start(arg_ptr,format);
  vsprintf (buf, format, arg_ptr);
  __builtin_va_end(arg_ptr);
  fprintf (stderr, "%s\n", buf);
  exit (4);
}

canonical_original_code:
void panic(char *format, ...)
{ char buf[1024];
  __builtin_va_list arg_ptr;
  __builtin_va_start(arg_ptr,format);
  vsprintf (buf, format, arg_ptr);
  __builtin_va_end(arg_ptr);
  fprintf (stderr, "%s\n", buf);
  exit (4);
}

variable_types:
format
char *

variable_types:
buf
char [1024]


error

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

va_start(arg, format);
vsprintf(s, format, arg);
return fprintf(stderr, "%s\n", s);
}

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

va_start(arg, format);
vsprintf(s, format, arg);
return fprintf(stderr, "%s\n", s);
}

original_code:
void error (char *format, ...)
{ char buf[1024];
  va_list arg_ptr;
  __builtin_va_start(arg_ptr,format);
  vsprintf (buf, format, arg_ptr);
  __builtin_va_end(arg_ptr);
  fprintf (stderr, "%s\n", buf);
}

canonical_original_code:
void error(char *format, ...)
{ char buf[1024];
  __builtin_va_list arg_ptr;
  __builtin_va_start(arg_ptr,format);
  vsprintf (buf, format, arg_ptr);
  __builtin_va_end(arg_ptr);
  fprintf (stderr, "%s\n", buf);
}


wlog

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

va_start(arg, format);
vsprintf(s, format, arg);
return fprintf(stderr, "%s\n", s);
}

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

va_start(arg, format);
vsprintf(s, format, arg);
return fprintf(stderr, "%s\n", s);
}

original_code:
void wlog (char *format, ...)
{ char buf[1024];
  va_list arg_ptr;
  __builtin_va_start(arg_ptr,format);
  vsprintf (buf, format, arg_ptr);
  __builtin_va_end(arg_ptr);
  fprintf (stderr, "%s\n", buf);
}

canonical_original_code:
void wlog(char *format, ...)
{ char buf[1024];
  __builtin_va_list arg_ptr;
  __builtin_va_start(arg_ptr,format);
  vsprintf (buf, format, arg_ptr);
  __builtin_va_end(arg_ptr);
  fprintf (stderr, "%s\n", buf);
}


warning

decompiled_code:
int warning(char *format, ...)
{
int result; // eax
gcc_va_list arg; // [rsp+8h] [rbp-4D0h] BYREF
char s[1024]; // [rsp+20h] [rbp-4B8h] BYREF

va_start(arg, format);
vsprintf(s, format, arg);
result = verbose;
if ( verbose )
result = fprintf(stderr, "%s\n", s);
return result;
}

canonical_decompiled_code:
int func4(char *format, ...)
{
int result; // eax
gcc_va_list arg; // [rsp+8h] [rbp-4D0h] BYREF
char s[1024]; // [rsp+20h] [rbp-4B8h] BYREF

va_start(arg, format);
vsprintf(s, format, arg);
result = verbose;
if ( verbose )
result = fprintf(stderr, "%s\n", s);
return result;
}

original_code:
void warning (char *format, ...)
{ char buf[1024];
  va_list arg_ptr;
  __builtin_va_start(arg_ptr,format);
  vsprintf (buf, format, arg_ptr);
  __builtin_va_end(arg_ptr);
  if (verbose) fprintf (stderr, "%s\n", buf);
}

canonical_original_code:
void warning(char *format, ...)
{ char buf[1024];
  __builtin_va_list arg_ptr;
  __builtin_va_start(arg_ptr,format);
  vsprintf (buf, format, arg_ptr);
  __builtin_va_end(arg_ptr);
  if (verbose) fprintf (stderr, "%s\n", buf);
}


hint

decompiled_code:
int hint(char *format, ...)
{
int result; // eax
gcc_va_list arg; // [rsp+8h] [rbp-4D0h] BYREF
char s[1024]; // [rsp+20h] [rbp-4B8h] BYREF

va_start(arg, format);
vsprintf(s, format, arg);
result = full_verbose;
if ( full_verbose )
result = fprintf(stderr, "%s\n", s);
return result;
}

canonical_decompiled_code:
int func5(char *format, ...)
{
int result; // eax
gcc_va_list arg; // [rsp+8h] [rbp-4D0h] BYREF
char s[1024]; // [rsp+20h] [rbp-4B8h] BYREF

va_start(arg, format);
vsprintf(s, format, arg);
result = full_verbose;
if ( full_verbose )
result = fprintf(stderr, "%s\n", s);
return result;
}

original_code:
void hint (char *format, ...)
{ char buf[1024];
  va_list arg_ptr;
  __builtin_va_start(arg_ptr,format);
  vsprintf (buf, format, arg_ptr);
  __builtin_va_end(arg_ptr);
  if (full_verbose) fprintf (stderr, "%s\n", buf);
}

canonical_original_code:
void hint(char *format, ...)
{ char buf[1024];
  __builtin_va_list arg_ptr;
  __builtin_va_start(arg_ptr,format);
  vsprintf (buf, format, arg_ptr);
  __builtin_va_end(arg_ptr);
  if (full_verbose) fprintf (stderr, "%s\n", buf);
}


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

va_start(arg, format);
vsprintf(s, format, arg);
return fputs(s, stderr);
}

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

va_start(arg, format);
vsprintf(s, format, arg);
return fputs(s, stderr);
}

original_code:
void eprint_log (char *format, ...)
{ char buf[1024];
  va_list arg_ptr;
  __builtin_va_start(arg_ptr,format);
  vsprintf (buf, format, arg_ptr);
  __builtin_va_end(arg_ptr);
  fprintf (stderr, "%s", buf);
}

canonical_original_code:
void eprint_log(char *format, ...)
{ char buf[1024];
  __builtin_va_list arg_ptr;
  __builtin_va_start(arg_ptr,format);
  vsprintf (buf, format, arg_ptr);
  __builtin_va_end(arg_ptr);
  fprintf (stderr, "%s", buf);
}


decompiled_code:
void __fastcall __noreturn bad_tag(unsigned int a1, const char *a2)
{
panic("bad tag %d occurred in routine %s", a1, a2);
}

canonical_decompiled_code:
void __fastcall __noreturn func7(unsigned int a1, const char *a2)
{
func1("bad tag %d occurred in routine %s", a1, a2);
}

original_code:
void bad_tag (int tag, char *routine)
{ panic ("bad tag %d occurred in routine %s", tag, routine);
}

canonical_original_code:
void bad_tag(int tag, char *routine)
{ panic ("bad tag %d occurred in routine %s", tag, routine);
}

variable_types: tag int

variable_types:
routine
char *


decompiled_code:
void __fastcall __noreturn internal_error(const char *a1)
{
panic("internal consistency check failed in routine %s", a1);
}

canonical_decompiled_code:
void __fastcall __noreturn func8(const char *a1)
{
func1("internal consistency check failed in routine %s", a1);
}

original_code:
void internal_error (char *routine)
{ panic ("internal consistency check failed in routine %s", routine);
}

canonical_original_code:
void internal_error(char *routine)
{ panic ("internal consistency check failed in routine %s", routine);
}


canonical_decompiled_code:
void func0()
{
lexicon_present = 0;
lexicon_errors = 0;
est_nr_lex_rules = 0;
}

original_code:
static void init_lexicon_check ()
 { lexicon_present = 0;
   lexicon_errors = 0;
   est_nr_lex_rules = 0;
 }

canonical_original_code:
static void init_lexicon_check()
 { lexicon_present = 0;
   lexicon_errors = 0;
   est_nr_lex_rules = 0;
 }


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

result = 0LL;
if ( !**(_BYTE **)a1 && !**(_DWORD **)(a1 + 8) )
result = **(_DWORD **)(a1 + 16) == 0;
return result;
}

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

result = 0LL;
if ( !**(_BYTE **)a1 && !**(_DWORD **)(a1 + 8) )
result = **(_DWORD **)(a1 + 16) == 0;
return result;
}

original_code:
static int is_initial_lextree (lextree curr_tree)
 { return ((strlen (curr_tree -> remainder) == 0) &&
    (curr_tree -> prods -> size == 0) &&
    (curr_tree -> tails -> size == 0));
 }

canonical_original_code:
static int is_initial_lextree(struct lextree_rec *curr_tree)
 { return ((strlen (curr_tree -> remainder) == 0) &&
    (curr_tree -> prods -> size == 0) &&
    (curr_tree -> tails -> size == 0));
 }

variable_types: struct lextree_rec { char *remainder; struct lexend_list_rec { int size; int room; struct lexend_rec { int nodenr; struct int_list_rec { int size; int room; int *array; } *valuenrs; } **array; } *prods; struct lextree_list_rec { int size; int room; struct lextree_rec **array; } *tails; } *

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 lexend_rec { int nodenr; struct int_list_rec *valuenrs; }


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

va_start(arg, format);
vsprintf(s, format, arg);
++lexicon_errors;
error((int)"lexicon error: %s", (int)s, v1);
}

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

va_start(arg, format);
vsprintf(s, format, arg);
++lexicon_errors;
error((int)"lexicon error: %s", (int)s, v1);
}

original_code:
static void lexicon_error (char *format, ...)
 { char buf[4096];
   va_list arg_ptr;
   __builtin_va_start(arg_ptr,format);
   vsprintf (buf, format, arg_ptr);
   __builtin_va_end(arg_ptr);
   lexicon_errors++;
   error ("lexicon error: %s", buf);
 }

canonical_original_code:
static void lexicon_error(char *format, ...)
 { char buf[4096];
   __builtin_va_list arg_ptr;
   __builtin_va_start(arg_ptr,format);
   vsprintf (buf, format, arg_ptr);
   __builtin_va_end(arg_ptr);
   lexicon_errors++;
   error ("lexicon error: %s", buf);
 }

variable_types:
buf
char [4096]


decompiled_code:
void __fastcall check_lexicon_lhs_expr(const char **a1, unsigned int a2, const char *a3, __int64 a4)
{
__int64 v4; // rax

if ( *(_DWORD *)a4 == 1 )
{
v4 = *(_QWORD *)(a4 + 8);
if ( !*(_QWORD *)(v4 + 24) )
lexicon_error("affix %s in lexicon rule %s, alt %d should have a static value", *(const char **)v4, a3, *a1);
}
else
{
lexicon_error("position %d in lexicon rule %s, alt %d does not have a static value", (unsigned int)a3, *a1, a2);
}
}

canonical_decompiled_code:
void __fastcall func3(const char **a1, unsigned int a2, const char *a3, __int64 a4)
{
__int64 v4; // rax

if ( *(_DWORD *)a4 == 1 )
{
v4 = *(_QWORD *)(a4 + 8);
if ( !*(_QWORD *)(v4 + 24) )
func2("affix %s in lexicon rule %s, alt %d should have a static value", *(const char **)v4, a3, *a1);
}
else
{
func2("position %d in lexicon rule %s, alt %d does not have a static value", (unsigned int)a3, *a1, a2);
}
}

original_code:
static void check_lexicon_lhs_expr (rule lrule, int altnr, int posnr, expr ex)
 { affix a;
   if (ex -> tag != 1)
      { lexicon_error ("position %d in lexicon rule %s, alt %d does not have a static value", posnr, lrule -> nonterminal, altnr);
        return;
      };
   a = ex -> u.single;
   if (a -> val == ((value) ((void *)0)))
      lexicon_error ("affix %s in lexicon rule %s, alt %d should have a static value", a -> name, posnr, lrule -> nonterminal);
 }

canonical_original_code:
static void check_lexicon_lhs_expr(struct rule_rec *lrule, int altnr, int posnr, struct expr_rec *ex)
 { struct affix_rec *a;
   if (ex -> tag != 1)
      { lexicon_error ("position %d in lexicon rule %s, alt %d does not have a static value", posnr, lrule -> nonterminal, altnr);
        return;
      };
   a = ex -> u.single;
   if (a -> val == ((value) ((void *)0)))
      lexicon_error ("affix %s in lexicon rule %s, alt %d should have a static value", a -> name, posnr, lrule -> nonterminal);
 }

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

variable_types: posnr int

variable_types:
ex
struct expr_rec *

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

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 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 alt_list_rec { int size; int room; struct alt_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 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 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 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 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 element_set_rec { int number; struct element_def_list_rec *defs; }

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


decompiled_code:
__int64 init_lexicon_preparation()
{
__int64 v0; // rbp
__int64 v1; // r12
__int64 v2; // rax
__int64 result; // rax

v0 = new_int_list();
v1 = new_value_list(nr_of_alts);
v2 = new_lextree_list((unsigned int)est_nr_lex_rules);
result = new_lexicon(v0, v1, v2);
value_root = 0LL;
the_lexicon = result;
return result;
}

canonical_decompiled_code:
__int64 func4()
{
__int64 v0; // rbp
__int64 v1; // r12
__int64 v2; // rax
__int64 result; // rax

v0 = new_int_list();
v1 = new_value_list(nr_of_alts);
v2 = new_lextree_list((unsigned int)est_nr_lex_rules);
result = new_lexicon(v0, v1, v2);
value_root = 0LL;
the_lexicon = result;
return result;
}

original_code:
static void init_lexicon_preparation ()
 { int_list lex_lnames = new_int_list ();
   value_list lex_vals = new_value_list (nr_of_alts);
   lextree_list lex_trees = new_lextree_list (est_nr_lex_rules);
   the_lexicon = new_lexicon (lex_lnames, lex_vals, lex_trees);
   value_root = ((value_tree) ((void *)0));
 }

canonical_original_code:
static void init_lexicon_preparation()
 { struct int_list_rec *lex_lnames = new_int_list ();
   struct value_list_rec *lex_vals = new_value_list (nr_of_alts);
   struct lextree_list_rec *lex_trees = new_lextree_list (est_nr_lex_rules);
   the_lexicon = new_lexicon (lex_lnames, lex_vals, lex_trees);
   value_root = ((value_tree) ((void *)0));
 }

variable_types: struct value_list_rec { int size; int room; 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 { int size; int room; int *array; } *elat; struct value_rec *free; } u; } **array; } *

variable_types: struct lextree_list_rec { int size; int room; struct lextree_rec { char *remainder; struct lexend_list_rec { int size; int room; struct lexend_rec { int nodenr; struct int_list_rec { int size; int room; int *array; } *valuenrs; } **array; } *prods; struct lextree_list_rec *tails; } **array; } *

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

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


decompiled_code:
__int64 __fastcall make_initial_lextree(unsigned int a1)
{
__int64 v1; // rbp
__int64 v2; // r12
__int64 v3; // rax

v1 = addto_names(&unk_A82);
v2 = new_lexend_list();
v3 = new_lextree_list(a1);
return new_lextree(v1, v2, v3);
}

canonical_decompiled_code:
__int64 __fastcall func5(unsigned int a1)
{
__int64 v1; // rbp
__int64 v2; // r12
__int64 v3; // rax

v1 = addto_names(&unk_A82);
v2 = new_lexend_list();
v3 = new_lextree_list(a1);
return new_lextree(v1, v2, v3);
}

original_code:
static lextree make_initial_lextree (int room)
 { string empty_string = addto_names ("");
   lexend_list loc_prods = new_lexend_list ();
   lextree_list loc_tails = new_lextree_list (room);
   return (new_lextree (empty_string, loc_prods, loc_tails));
 }

canonical_original_code:
static struct lextree_rec *make_initial_lextree(int room)
 { char *empty_string = addto_names ("");
   struct lexend_list_rec *loc_prods = new_lexend_list ();
   struct lextree_list_rec *loc_tails = new_lextree_list (room);
   return (new_lextree (empty_string, loc_prods, loc_tails));
 }

variable_types: room int

return_type: struct lextree_rec { char *remainder; struct lexend_list_rec { int size; int room; struct lexend_rec { int nodenr; struct int_list_rec { int size; int room; int *array; } *valuenrs; } **array; } *prods; struct lextree_list_rec { int size; int room; struct lextree_rec **array; } *tails; } *

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


decompiled_code:
__int64 __fastcall addto_values(unsigned int *a1)
{
__int64 *v1; // rbx
_QWORD *v2; // rax
_QWORD *v3; // rbx
_QWORD *v4; // rbx
unsigned int v5; // er13
__int64 v6; // rax
_QWORD *v7; // r12
__int64 v8; // rax
__int64 v9; // rsi
_QWORD *v10; // rax
__int64 v11; // rax
__int64 result; // rax

v1 = &value_root;
v2 = (_QWORD *)value_root;
if ( value_root )
{
while ( 1 )
{
while ( (unsigned int)less_value(a1, *v2) )
{
v3 = (_QWORD *)*v1;
v2 = (_QWORD *)v3[2];
v1 = v3 + 2;
if ( !v2 )
goto LABEL_7;
}
if ( !(unsigned int)less_value(*(_QWORD *)*v1, a1) )
break;
v4 = (_QWORD *)*v1;
v2 = (_QWORD *)v4[3];
v1 = v4 + 3;
if ( !v2 )
goto LABEL_7;
}
result = *(unsigned int *)(*v1 + 8);
}
else
{
LABEL_7:
v5 = **(_DWORD **)(the_lexicon + 8);
v6 = ckmalloc(32LL);
*v1 = v6;
v7 = (_QWORD *)v6;
v8 = rdup_value(a1);
v9 = *a1;
*v7 = v8;
v10 = (_QWORD *)*v1;
*((_DWORD *)v10 + 2) = v5;
v10[2] = 0LL;
*(_QWORD *)(*v1 + 24) = 0LL;
app_int_list(*(_QWORD *)the_lexicon, v9);
v11 = rdup_value(a1);
app_value_list(*(_QWORD *)(the_lexicon + 8), v11);
result = v5;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func6(unsigned int *a1)
{
__int64 *v1; // rbx
_QWORD *v2; // rax
_QWORD *v3; // rbx
_QWORD *v4; // rbx
unsigned int v5; // er13
__int64 v6; // rax
_QWORD *v7; // r12
__int64 v8; // rax
__int64 v9; // rsi
_QWORD *v10; // rax
__int64 v11; // rax
__int64 result; // rax

v1 = &value_root;
v2 = (_QWORD *)value_root;
if ( value_root )
{
while ( 1 )
{
while ( (unsigned int)less_value(a1, *v2) )
{
v3 = (_QWORD *)*v1;
v2 = (_QWORD *)v3[2];
v1 = v3 + 2;
if ( !v2 )
goto LABEL_7;
}
if ( !(unsigned int)less_value(*(_QWORD *)*v1, a1) )
break;
v4 = (_QWORD *)*v1;
v2 = (_QWORD *)v4[3];
v1 = v4 + 3;
if ( !v2 )
goto LABEL_7;
}
result = *(unsigned int *)(*v1 + 8);
}
else
{
LABEL_7:
v5 = **(_DWORD **)(the_lexicon + 8);
v6 = ckmalloc(32LL);
*v1 = v6;
v7 = (_QWORD *)v6;
v8 = rdup_value(a1);
v9 = *a1;
*v7 = v8;
v10 = (_QWORD *)*v1;
*((_DWORD *)v10 + 2) = v5;
v10[2] = 0LL;
*(_QWORD *)(*v1 + 24) = 0LL;
app_int_list(*(_QWORD *)the_lexicon, v9);
v11 = rdup_value(a1);
app_value_list(*(_QWORD *)(the_lexicon + 8), v11);
result = v5;
}
return result;
}

original_code:
static int addto_values (value v)
 { value_tree *ptr = &value_root;
   while (1)
      { if (*ptr == ((value_tree) ((void *)0)))
           { int nr = the_lexicon -> lex_vals -> size;
      *ptr = (value_tree)
    ckmalloc (sizeof (struct value_tree_rec));
      (*ptr) -> val = rdup_value (v);
      (*ptr) -> nr = nr;
             (*ptr) -> left = ((value_tree) ((void *)0));
      (*ptr) -> right = ((value_tree) ((void *)0));
      app_int_list (the_lexicon -> lex_lnames, v -> admin_nr);
      app_value_list (the_lexicon -> lex_vals, rdup_value (v));
      return (nr);
    };
        if (less_value (v, (*ptr) -> val)) ptr = &((*ptr) -> left);
        else if (less_value ((*ptr) -> val, v))
    ptr = &((*ptr) -> right);
        else return ((*ptr) -> nr);
      };
 }

canonical_original_code:
static int addto_values(struct value_rec *v)
 { struct value_tree_rec **ptr = &value_root;
   while (1)
      { if (*ptr == ((value_tree) ((void *)0)))
           { int nr = the_lexicon -> lex_vals -> size;
      *ptr = (struct value_tree_rec *)
    ckmalloc (sizeof (struct value_tree_rec));
      (*ptr) -> val = rdup_value (v);
      (*ptr) -> nr = nr;
             (*ptr) -> left = ((value_tree) ((void *)0));
      (*ptr) -> right = ((value_tree) ((void *)0));
      app_int_list (the_lexicon -> lex_lnames, v -> admin_nr);
      app_value_list (the_lexicon -> lex_vals, rdup_value (v));
      return (nr);
    };
        if (less_value (v, (*ptr) -> val)) ptr = &((*ptr) -> left);
        else if (less_value ((*ptr) -> val, v))
    ptr = &((*ptr) -> right);
        else return ((*ptr) -> nr);
      };
 }

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

variable_types: nr int

user_defined_types: struct value_tree_rec { struct value_rec *val; int nr; struct value_tree_rec *left; struct value_tree_rec *right; }

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 make_deeper_lextree(char **a1)
{
__int64 v2; // rax
_BYTE *v3; // rdi
char *v4; // rbx
int v5; // er12
__int64 v6; // r13
__int64 v7; // rax
__int64 v8; // rax
int v9; // ebx
__int64 v10; // r13
__int64 v11; // rax

v2 = addto_names(&unk_A82);
v3 = *a1;
v4 = (char *)v2;
v5 = (char)*v3;
if ( !*v3 || *(_DWORD *)a1[2] )
{
internal_error("make_deeper_lextree");
v3 = *a1;
v5 = **a1;
}
v6 = addto_names(v3 + 1);
v7 = new_lextree_list(1LL);
v8 = new_lextree(v6, a1[1], v7);
*a1 = v4;
v9 = 0;
v10 = v8;
a1[1] = (char *)new_lexend_list();
if ( v5 > 0 )
{
do
{
++v9;
v11 = make_initial_lextree(1u);
app_lextree_list(a1[2], v11);
}
while ( v5 != v9 );
}
return app_lextree_list(a1[2], v10);
}

canonical_decompiled_code:
__int64 __fastcall func7(char **a1)
{
__int64 v2; // rax
_BYTE *v3; // rdi
char *v4; // rbx
int v5; // er12
__int64 v6; // r13
__int64 v7; // rax
__int64 v8; // rax
int v9; // ebx
__int64 v10; // r13
__int64 v11; // rax

v2 = addto_names(&unk_A82);
v3 = *a1;
v4 = (char *)v2;
v5 = (char)*v3;
if ( !*v3 || *(_DWORD *)a1[2] )
{
internal_error("make_deeper_lextree");
v3 = *a1;
v5 = **a1;
}
v6 = addto_names(v3 + 1);
v7 = new_lextree_list(1LL);
v8 = new_lextree(v6, a1[1], v7);
*a1 = v4;
v9 = 0;
v10 = v8;
a1[1] = (char *)new_lexend_list();
if ( v5 > 0 )
{
do
{
++v9;
v11 = func5(1u);
app_lextree_list(a1[2], v11);
}
while ( v5 != v9 );
}
return app_lextree_list(a1[2], v10);
}

original_code:
static void make_deeper_lextree (lextree curr_tree)
 { string empty_string = addto_names ("");
   string new_remainder;
   lextree_list new_tails;
   lextree new;
   int curr, ix;
   if (!strlen (curr_tree -> remainder) || curr_tree -> tails -> size)
      internal_error ("make_deeper_lextree");
   curr = curr_tree -> remainder[0];
   new_remainder = addto_names (curr_tree -> remainder + 1);
   new_tails = new_lextree_list (1);
   new = new_lextree (new_remainder, curr_tree -> prods, new_tails);
   curr_tree -> remainder = empty_string;
   curr_tree -> prods = new_lexend_list ();
   for (ix = 0; ix < curr; ix++)
      app_lextree_list (curr_tree -> tails, make_initial_lextree (1));
   app_lextree_list (curr_tree -> tails, new);
 }

canonical_original_code:
static void make_deeper_lextree(struct lextree_rec *curr_tree)
 { char *empty_string = addto_names ("");
   char *new_remainder;
   struct lextree_list_rec *new_tails;
   struct lextree_rec *new;
   int curr; int ix;
   if (!strlen (curr_tree -> remainder) || curr_tree -> tails -> size)
      internal_error ("make_deeper_lextree");
   curr = curr_tree -> remainder[0];
   new_remainder = addto_names (curr_tree -> remainder + 1);
   new_tails = new_lextree_list (1);
   new = new_lextree (new_remainder, curr_tree -> prods, new_tails);
   curr_tree -> remainder = empty_string;
   curr_tree -> prods = new_lexend_list ();
   for (ix = 0; ix < curr; ix++)
      app_lextree_list (curr_tree -> tails, make_initial_lextree (1));
   app_lextree_list (curr_tree -> tails, new);
 }

variable_types: curr int

variable_types: ix int

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


decompiled_code:
__int64 dump_lexicon_rules()
{
unsigned int *v0; // rbp
__int64 v1; // r12
__int64 result; // rax
__int64 v3; // rsi
const char *v4; // rdx
__int64 v5; // rsi
__int64 v6; // rbx
__int64 v7; // rdi

if ( full_verbose )
{
v0 = *(unsigned int **)(the_lexicon + 8);
v1 = *(_QWORD *)the_lexicon;
result = *(_QWORD *)(the_lexicon + 16);
v3 = *(unsigned int *)result;
if ( (_DWORD)v3 )
{
v4 = (const char *)&unk_A82;
if ( (_DWORD)v3 != 1 )
v4 = "s";
result = hint("compiled %d nonterminal%s into lexicon", v3, v4);
}
v5 = *v0;
if ( (_DWORD)v5 )
{
hint("collected %d different values in lexicon", v5);
result = *v0;
if ( (int)result > 0 )
{
v6 = 0LL;
do
{
eprint_log("value %d, lnr %d: ", (unsigned int)v6, *(unsigned int *)(*(_QWORD *)(v1 + 8) + 4 * v6));
v7 = *(_QWORD *)(*((_QWORD *)v0 + 1) + 8 * v6++);
dump_value(v7);
result = eprint_log("\n");
}
while ( (int)*v0 > (int)v6 );
}
}
}
return result;
}

canonical_decompiled_code:
__int64 func8()
{
unsigned int *v0; // rbp
__int64 v1; // r12
__int64 result; // rax
__int64 v3; // rsi
const char *v4; // rdx
__int64 v5; // rsi
__int64 v6; // rbx
__int64 v7; // rdi

if ( full_verbose )
{
v0 = *(unsigned int **)(the_lexicon + 8);
v1 = *(_QWORD *)the_lexicon;
result = *(_QWORD *)(the_lexicon + 16);
v3 = *(unsigned int *)result;
if ( (_DWORD)v3 )
{
v4 = (const char *)&unk_A82;
if ( (_DWORD)v3 != 1 )
v4 = "s";
result = hint("compiled %d nonterminal%s into lexicon", v3, v4);
}
v5 = *v0;
if ( (_DWORD)v5 )
{
hint("collected %d different values in lexicon", v5);
result = *v0;
if ( (int)result > 0 )
{
v6 = 0LL;
do
{
eprint_log("value %d, lnr %d: ", (unsigned int)v6, *(unsigned int *)(*(_QWORD *)(v1 + 8) + 4 * v6));
v7 = *(_QWORD *)(*((_QWORD *)v0 + 1) + 8 * v6++);
dump_value(v7);
result = eprint_log("\n");
}
while ( (int)*v0 > (int)v6 );
}
}
}
return result;
}

original_code:
static void dump_lexicon_rules ()
 { value_list lex_vals = the_lexicon -> lex_vals;
   int_list lex_lnames = the_lexicon -> lex_lnames;
   int lex_size = the_lexicon -> lex_trees -> size;
   int ix;
   if (!full_verbose) return;
   if (lex_size)
      hint ("compiled %d nonterminal%s into lexicon", lex_size,
     (lex_size == 1)?"":"s");
   if (!lex_vals -> size) return;
   hint ("collected %d different values in lexicon", lex_vals -> size);
   for (ix = 0; ix < lex_vals -> size; ix++)
      { eprint_log ("value %d, lnr %d: ", ix, lex_lnames -> array[ix]);
        dump_value (lex_vals -> array[ix]);
        eprint_log ("\n");
      };
 }

canonical_original_code:
static void dump_lexicon_rules()
 { struct value_list_rec *lex_vals = the_lexicon -> lex_vals;
   struct int_list_rec *lex_lnames = the_lexicon -> lex_lnames;
   int lex_size = the_lexicon -> lex_trees -> size;
   int ix;
   if (!full_verbose) return;
   if (lex_size)
      hint ("compiled %d nonterminal%s into lexicon", lex_size,
     (lex_size == 1)?"":"s");
   if (!lex_vals -> size) return;
   hint ("collected %d different values in lexicon", lex_vals -> size);
   for (ix = 0; ix < lex_vals -> size; ix++)
      { eprint_log ("value %d, lnr %d: ", ix, lex_lnames -> array[ix]);
        dump_value (lex_vals -> array[ix]);
        eprint_log ("\n");
      };
 }

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


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

sprintf(v2, "%s.clx", a1);
return csave_lexicon(v2, the_lexicon);
}

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

sprintf(v2, "%s.clx", a1);
return csave_lexicon(v2, the_lexicon);
}

original_code:
static void save_lexicon_rules (string basename)
 { char fname[1024];
   sprintf (fname, "%s.clx", basename);
   csave_lexicon (fname, the_lexicon);
 }

canonical_original_code:
static void save_lexicon_rules(char *basename)
 { char fname[1024];
   sprintf (fname, "%s.clx", basename);
   csave_lexicon (fname, the_lexicon);
 }

variable_types:
basename
char *

variable_types:
fname
char [1024]


decompiled_code:
__int64 __fastcall enter_terminal(__int64 a1, __int64 a2, const char *a3)
{
const char *v5; // rbp
__int64 v6; // rsi
const char *v7; // r12

if ( *a3 )
{
v5 = a3;
while ( !is_initial_lextree(a1) )
{
v7 = *(const char **)a1;
if ( !strcmp(*(const char **)a1, v5) )
return app_lexend_list(*(_QWORD *)(a1 + 8), a2);
if ( *v7 )
make_deeper_lextree((char **)a1);
v6 = *v5++;
make_wider_lextree_isra_0(*(int **)(a1 + 16), v6);
a1 = *(_QWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 16) + 8LL) + 8 * v6);
if ( !*v5 )
goto LABEL_10;
}
*(_QWORD *)a1 = addto_names(v5);
}
else
{
LABEL_10:
if ( **(_BYTE **)a1 )
make_deeper_lextree((char **)a1);
}
return app_lexend_list(*(_QWORD *)(a1 + 8), a2);
}

canonical_decompiled_code:
__int64 __fastcall func11(__int64 a1, __int64 a2, const char *a3)
{
const char *v5; // rbp
__int64 v6; // rsi
const char *v7; // r12

if ( *a3 )
{
v5 = a3;
while ( !func1(a1) )
{
v7 = *(const char **)a1;
if ( !strcmp(*(const char **)a1, v5) )
return app_lexend_list(*(_QWORD *)(a1 + 8), a2);
if ( *v7 )
func7((char **)a1);
v6 = *v5++;
func10(*(int **)(a1 + 16), v6);
a1 = *(_QWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 16) + 8LL) + 8 * v6);
if ( !*v5 )
goto LABEL_10;
}
*(_QWORD *)a1 = addto_names(v5);
}
else
{
LABEL_10:
if ( **(_BYTE **)a1 )
func7((char **)a1);
}
return app_lexend_list(*(_QWORD *)(a1 + 8), a2);
}

original_code:
static void enter_terminal (lextree rev_tree, lexend le, string terminal)
 { lextree curr_tree = rev_tree;
   string tptr = terminal;
   while (*tptr)
      { int curr;
        if (is_initial_lextree (curr_tree))
    {
      curr_tree -> remainder = addto_names (tptr);
      app_lexend_list (curr_tree -> prods, le);
      return;
    };
        if ((!strcmp(curr_tree -> remainder,tptr)))
    {
      app_lexend_list (curr_tree -> prods, le);
      return;
    };
        if (strlen (curr_tree -> remainder))
    make_deeper_lextree (curr_tree);
        curr = *tptr++;
        make_wider_lextree (curr_tree, curr);
        curr_tree = curr_tree -> tails -> array[curr];
      };
   if (strlen (curr_tree -> remainder))
      make_deeper_lextree (curr_tree);
   app_lexend_list (curr_tree -> prods, le);
 }

canonical_original_code:
static void enter_terminal(struct lextree_rec *rev_tree, struct lexend_rec *le, char *terminal)
 { struct lextree_rec *curr_tree = rev_tree;
   char *tptr = terminal;
   while (*tptr)
      { int curr;
        if (is_initial_lextree (curr_tree))
    {
      curr_tree -> remainder = addto_names (tptr);
      app_lexend_list (curr_tree -> prods, le);
      return;
    };
        if ((!strcmp(curr_tree -> remainder,tptr)))
    {
      app_lexend_list (curr_tree -> prods, le);
      return;
    };
        if (strlen (curr_tree -> remainder))
    make_deeper_lextree (curr_tree);
        curr = *tptr++;
        make_wider_lextree (curr_tree, curr);
        curr_tree = curr_tree -> tails -> array[curr];
      };
   if (strlen (curr_tree -> remainder))
      make_deeper_lextree (curr_tree);
   app_lexend_list (curr_tree -> prods, le);
 }

variable_types: struct lextree_rec { char *remainder; struct lexend_list_rec { int size; int room; struct lexend_rec { int nodenr; struct int_list_rec { int size; int room; int *array; } *valuenrs; } **array; } *prods; struct lextree_list_rec { int size; int room; struct lextree_rec **array; } *tails; } *

variable_types:
le
struct lexend_rec *

variable_types:
terminal
char *

variable_types:
tptr
char *


decompiled_code:
__int64 __fastcall prepare_lexicon_rhs(__int64 a1, __int64 a2, unsigned int *a3)
{
unsigned int v3; // er8
__int64 result; // rax

v3 = *a3;
if ( *a3 )
{
if ( v3 == 1 )
result = enter_terminal(a1, a2, *(const char **)(**((_QWORD **)a3 + 1) + 32LL));
else
result = bad_tag(v3, "enter_alt_rhs");
}
else
{
if ( **(_BYTE **)a1 )
make_deeper_lextree((char **)a1);
result = app_lexend_list(*(_QWORD *)(a1 + 8), a2);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func12(__int64 a1, __int64 a2, unsigned int *a3)
{
unsigned int v3; // er8
__int64 result; // rax

v3 = *a3;
if ( *a3 )
{
if ( v3 == 1 )
result = func11(a1, a2, *(const char **)(**((_QWORD **)a3 + 1) + 32LL));
else
result = bad_tag(v3, "enter_alt_rhs");
}
else
{
if ( **(_BYTE **)a1 )
func7((char **)a1);
result = app_lexend_list(*(_QWORD *)(a1 + 8), a2);
}
return result;
}

original_code:
static void prepare_lexicon_rhs (lextree rev_tree, lexend le,
      member_list members)
 { switch (members -> size)
      { case 1:
    enter_terminal (rev_tree, le,
      members -> array[0] -> u.terminal);
    break;
        case 0:
    { if (strlen (rev_tree -> remainder))
         make_deeper_lextree (rev_tree);
      app_lexend_list (rev_tree -> prods, le);
    }; break;
        default: bad_tag (members -> size, "enter_alt_rhs");
      };
 }

canonical_original_code:
static void prepare_lexicon_rhs(struct lextree_rec *rev_tree, struct lexend_rec *le, struct member_list_rec *members)
 { switch (members -> size)
      { case 1:
    enter_terminal (rev_tree, le,
      members -> array[0] -> u.terminal);
    break;
        case 0:
    { if (strlen (rev_tree -> remainder))
         make_deeper_lextree (rev_tree);
      app_lexend_list (rev_tree -> prods, le);
    }; break;
        default: bad_tag (members -> size, "enter_alt_rhs");
      };
 }

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

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

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

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

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

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


decompiled_code:
__int64 __fastcall prepare_lexicon_lhs(__int64 a1)
{
__int64 v1; // rax
int *v2; // rbp
__int64 v3; // r12
__int64 v4; // rbx
__int64 v5; // rax
unsigned int v6; // eax

v1 = new_int_list();
v2 = *(int **)a1;
v3 = v1;
if ( **(int **)a1 > 0 )
{
v4 = 0LL;
do
{
v5 = *(_QWORD *)(*((_QWORD *)v2 + 1) + 8 * v4++);
v6 = prepare_lexicon_expr_isra_0(*(_QWORD *)(*(_QWORD *)(v5 + 8) + 8LL));
app_int_list(v3, v6);
}
while ( *v2 > (int)v4 );
}
return new_lexend(*(unsigned int *)(a1 + 20), v3);
}

original_code:
static lexend prepare_lexicon_lhs (alt a)
 { int_list valuenrs = new_int_list ();
   pos_list dpy = a -> display;
   int ix;
   for (ix = 0; ix < dpy -> size; ix++)
      { expr ex = dpy -> array[ix] -> ex;
        app_int_list (valuenrs, prepare_lexicon_expr (ex));
      };
   return (new_lexend (a -> nodenr, valuenrs));
 }

canonical_original_code:
static struct lexend_rec *prepare_lexicon_lhs(struct alt_rec *a)
 { struct int_list_rec *valuenrs = new_int_list ();
   struct pos_list_rec *dpy = a -> display;
   int ix;
   for (ix = 0; ix < dpy -> size; ix++)
      { struct expr_rec *ex = dpy -> array[ix] -> ex;
        app_int_list (valuenrs, prepare_lexicon_expr (ex));
      };
   return (new_lexend (a -> nodenr, valuenrs));
 }

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

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

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 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 prepare_lexicon_alt(__int64 a1, __int64 a2)
{
__int64 v2; // rax

v2 = prepare_lexicon_lhs(a2);
return prepare_lexicon_rhs(a1, v2, *(unsigned int **)(a2 + 8));
}

canonical_decompiled_code:
__int64 __fastcall func15(__int64 a1, __int64 a2)
{
__int64 v2; // rax

v2 = func14(a2);
return func12(a1, v2, *(unsigned int **)(a2 + 8));
}

original_code:
static void prepare_lexicon_alt (lextree rev_tree, alt a)
 { lexend le = prepare_lexicon_lhs (a);
   prepare_lexicon_rhs (rev_tree, le, a -> members);
 }

canonical_original_code:
static void prepare_lexicon_alt(struct lextree_rec *rev_tree, struct alt_rec *a)
 { struct lexend_rec *le = prepare_lexicon_lhs (a);
   prepare_lexicon_rhs (rev_tree, le, a -> members);
 }

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 *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 *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: struct lexend_rec { int nodenr; struct int_list_rec { int size; int room; int *array; } *valuenrs; } *

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

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

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


decompiled_code:
__int64 __fastcall prepare_lexicon_rule(__int64 a1)
{
__int64 v1; // rax
unsigned int *v2; // rbp
__int64 v3; // r12
__int64 result; // rax
__int64 v5; // rbx
__int64 v6; // rsi

v1 = make_initial_lextree(0x80u);
v2 = *(unsigned int **)(a1 + 8);
v3 = v1;
app_lextree_list(*(_QWORD *)(the_lexicon + 16), v1);
*(_DWORD *)(a1 + 24) = **(_DWORD **)(the_lexicon + 16);
result = *v2;
if ( (int)result > 0 )
{
v5 = 0LL;
do
{
v6 = *(_QWORD *)(*((_QWORD *)v2 + 1) + 8 * v5++);
result = prepare_lexicon_alt(v3, v6);
}
while ( (int)*v2 > (int)v5 );
}
lexicon_present = 1;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func16(__int64 a1)
{
__int64 v1; // rax
unsigned int *v2; // rbp
__int64 v3; // r12
__int64 result; // rax
__int64 v5; // rbx
__int64 v6; // rsi

v1 = func5(0x80u);
v2 = *(unsigned int **)(a1 + 8);
v3 = v1;
app_lextree_list(*(_QWORD *)(the_lexicon + 16), v1);
*(_DWORD *)(a1 + 24) = **(_DWORD **)(the_lexicon + 16);
result = *v2;
if ( (int)result > 0 )
{
v5 = 0LL;
do
{
v6 = *(_QWORD *)(*((_QWORD *)v2 + 1) + 8 * v5++);
result = func15(v3, v6);
}
while ( (int)*v2 > (int)v5 );
}
lexicon_present = 1;
return result;
}

original_code:
static void prepare_lexicon_rule (rule lrule)
 { lextree rev_tree = make_initial_lextree (128);
   alt_list alts = lrule -> alts;
   int ix;
   app_lextree_list (the_lexicon -> lex_trees, rev_tree);
   lrule -> lex = the_lexicon -> lex_trees -> size;
   for (ix = 0; ix < alts -> size; ix++)
      prepare_lexicon_alt (rev_tree, alts -> array[ix]);
   lexicon_present = 1;
 }

canonical_original_code:
static void prepare_lexicon_rule(struct rule_rec *lrule)
 { struct lextree_rec *rev_tree = make_initial_lextree (128);
   struct alt_list_rec *alts = lrule -> alts;
   int ix;
   app_lextree_list (the_lexicon -> lex_trees, rev_tree);
   lrule -> lex = the_lexicon -> lex_trees -> size;
   for (ix = 0; ix < alts -> size; ix++)
      prepare_lexicon_alt (rev_tree, alts -> array[ix]);
   lexicon_present = 1;
 }

variable_types: struct rule_rec { char *nonterminal; struct alt_list_rec { int size; int room; struct alt_rec { struct pos_list_rec { int size; int room; struct pos_rec { int kind; struct expr_rec { int tag; union { struct affix_rec { char *name; int type; struct affix_rec *next; struct value_rec { int admin_nr; int ref_count; void *dptr; int tag; union { char *str; int inum; double rnum; struct value_list_rec { int size; int room; struct value_rec **array; } *tuple; int slat; struct int_list_rec { int size; int room; int *array; } *elat; struct value_rec *free; } u; } *val; int ref_count; int reachable; int tag; union { struct variable_rec { char *nonterminal; char *suffix; struct meta_rule_rec { char *nonterminal; struct meta_alt_list_rec { int size; int room; struct meta_alt_rec { struct expr_rec *e; int number; } **array; } *alts; int ext; int type; int kind; int empty; int number; struct value_rec *mvalue; int reachable; struct element_def_rec { char *eltnm; int number; int eltnr; struct element_set_rec { int number; struct element_def_list_rec { int size; int room; struct element_def_rec **array; } *defs; } *set; } *lat_repr; int needs_rec; int needs_recbup; } *def; } var; char *str; int inum; double rnum; struct cset_rec { int kind; char *str; } *semi; struct element_rec { char *eltnm; struct element_def_rec *def; } elt; struct expr_rec *cexpr; } u; } *single; struct affix_list_rec { int size; int room; struct affix_rec **array; } *compos; struct affix_list_rec *concat; struct affix_list_rec *uni; } u; } *ex; int type; struct element_def_rec *lat_repr; } **array; } *display; struct member_list_rec { int size; int room; struct member_rec { int empty; int followlayout; char *first; int number; int sonnr; int tag; union { struct call_rec { char *nonterminal; struct pos_list_rec *display; struct rule_rec *def; } call; char *terminal; struct semiterminal_rec { struct cset_rec *set; struct pos_list_rec *display; } semi; } u; } **array; } *members; int number; int nodenr; int nrsons; struct affix_rec *locals; int empty; char *first; char *director; int rule_nr; } **array; } *alts; int kind; int empty; int lex; int ext; int number; int placeholder; int startswithlayout; int endsinlayout; char *first; char *follow; struct pos_list_rec *proto_display; int reachable; int has_sons; int goal; struct lextree_rec { char *remainder; struct lexend_list_rec { int size; int room; struct lexend_rec { int nodenr; struct int_list_rec *valuenrs; } **array; } *prods; struct lextree_list_rec { int size; int room; struct lextree_rec **array; } *tails; } *rev_tree; } *

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 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 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 prepare_lexicon_rules()
{
__int64 v0; // rbx
__int64 result; // rax
unsigned int *v2; // rdi

if ( nr_of_rules > 0 )
{
v0 = 0LL;
do
{
while ( 1 )
{
result = all_rules;
v2 = *(unsigned int **)(all_rules + 8 * v0);
if ( !v2[7] )
{
if ( v2[18] )
{
result = v2[6];
if ( (_DWORD)result )
break;
}
}
if ( nr_of_rules <= (int)++v0 )
return result;
}
result = prepare_lexicon_rule((__int64)v2);
++v0;
}
while ( nr_of_rules > (int)v0 );
}
return result;
}

canonical_decompiled_code:
__int64 func17()
{
__int64 v0; // rbx
__int64 result; // rax
unsigned int *v2; // rdi

if ( nr_of_rules > 0 )
{
v0 = 0LL;
do
{
while ( 1 )
{
result = all_rules;
v2 = *(unsigned int **)(all_rules + 8 * v0);
if ( !v2[7] )
{
if ( v2[18] )
{
result = v2[6];
if ( (_DWORD)result )
break;
}
}
if ( nr_of_rules <= (int)++v0 )
return result;
}
result = func16((__int64)v2);
++v0;
}
while ( nr_of_rules > (int)v0 );
}
return result;
}

original_code:
static void prepare_lexicon_rules ()
 { int ix;
   for (ix = 0; ix < nr_of_rules; ix++)
      { rule srule = all_rules[ix];
        if (srule -> ext || !srule -> reachable) continue;
        if (srule -> lex) prepare_lexicon_rule (srule);
      };
 }

canonical_original_code:
static void prepare_lexicon_rules()
 { int ix;
   for (ix = 0; ix < nr_of_rules; ix++)
      { struct rule_rec *srule = all_rules[ix];
        if (srule -> ext || !srule -> reachable) continue;
        if (srule -> lex) prepare_lexicon_rule (srule);
      };
 }

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 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 __fastcall check_lexicon_alt(const char **a1, unsigned int a2, __int64 *a3)
{
check_lexicon_lhs_isra_0(a1, a2, *a3);
check_lexicon_member_isra_0(a1, a2, a3[1]);
}

canonical_decompiled_code:
void __fastcall func20(const char **a1, unsigned int a2, __int64 *a3)
{
func19(a1, a2, *a3);
func18(a1, a2, a3[1]);
}

original_code:
static void check_lexicon_alt (rule lrule, int altnr, alt a)
 { check_lexicon_lhs (lrule, altnr, a);
   check_lexicon_member (lrule, altnr, a);
 }

canonical_original_code:
static void check_lexicon_alt(struct rule_rec *lrule, int altnr, struct alt_rec *a)
 { check_lexicon_lhs (lrule, altnr, a);
   check_lexicon_member (lrule, altnr, a);
 }

variable_types: altnr int

variable_types:
a
struct alt_rec *

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

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

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


decompiled_code:
void __fastcall check_lexicon_rule(__int64 a1)
{
__int64 v1; // rbp
__int64 v2; // rbx
__int64 *v3; // rdx

v1 = *(_QWORD *)(a1 + 8);
++est_nr_lex_rules;
if ( *(int *)v1 > 0 )
{
v2 = 0LL;
do
{
v3 = *(__int64 **)(*(_QWORD *)(v1 + 8) + 8 * v2++);
check_lexicon_alt((const char **)a1, v2, v3);
}
while ( *(_DWORD *)v1 > (int)v2 );
}
}

original_code:
static void check_lexicon_rule (rule lrule)
 { alt_list alts = lrule -> alts;
   int ix;
   est_nr_lex_rules++;
   for (ix = 0; ix < alts -> size; ix++)
      check_lexicon_alt (lrule, ix + 1, alts -> array[ix]);
 }

canonical_original_code:
static void check_lexicon_rule(struct rule_rec *lrule)
 { struct alt_list_rec *alts = lrule -> alts;
   int ix;
   est_nr_lex_rules++;
   for (ix = 0; ix < alts -> size; ix++)
      check_lexicon_alt (lrule, ix + 1, alts -> array[ix]);
 }

variable_types: ix 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 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 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 check_lexicon_rules()
{
__int64 v0; // rbx
__int64 result; // rax
__int64 v2; // rbp

if ( nr_of_rules > 0 )
{
v0 = 0LL;
do
{
v2 = *(_QWORD *)(all_rules + 8 * v0);
if ( *(_DWORD *)(v2 + 24) )
check_lexicon_rule(*(_QWORD *)(all_rules + 8 * v0));
result = ignore_lexicon;
if ( ignore_lexicon )
*(_DWORD *)(v2 + 24) = 0;
++v0;
}
while ( nr_of_rules > (int)v0 );
}
return result;
}

canonical_decompiled_code:
__int64 func22()
{
__int64 v0; // rbx
__int64 result; // rax
__int64 v2; // rbp

if ( nr_of_rules > 0 )
{
v0 = 0LL;
do
{
v2 = *(_QWORD *)(all_rules + 8 * v0);
if ( *(_DWORD *)(v2 + 24) )
func21(*(_QWORD *)(all_rules + 8 * v0));
result = ignore_lexicon;
if ( ignore_lexicon )
*(_DWORD *)(v2 + 24) = 0;
++v0;
}
while ( nr_of_rules > (int)v0 );
}
return result;
}

original_code:
static void check_lexicon_rules ()
 { int ix;
   for (ix = 0; ix < nr_of_rules; ix++)
      { rule srule = all_rules[ix];
        if (srule -> lex) check_lexicon_rule (srule);
        if (ignore_lexicon) srule -> lex = 0;
      };
 }

canonical_original_code:
static void check_lexicon_rules()
 { int ix;
   for (ix = 0; ix < nr_of_rules; ix++)
      { struct rule_rec *srule = all_rules[ix];
        if (srule -> lex) check_lexicon_rule (srule);
        if (ignore_lexicon) srule -> lex = 0;
      };
 }

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 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 pos_rec { int kind; struct expr_rec *ex; int type; struct element_def_rec *lat_repr; }

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 check_lexicon()
{
const char *v0; // rcx
const char *v1; // rdx
const char *v2; // rdx

warning("checking lexicon rules...");
init_lexicon_check();
check_lexicon_rules();
if ( lexicon_errors )
{
v0 = "as";
v1 = (const char *)&unk_A82;
if ( lexicon_errors != 1 )
v0 = "ere";
if ( lexicon_errors != 1 )
v1 = "s";
panic("%d error%s w%s found in lexicon rules", (unsigned int)lexicon_errors, v1, v0);
}
v2 = (const char *)&unk_A82;
if ( est_nr_lex_rules != 1 )
v2 = "s";
return hint("found %d rule%s in lexicon", (unsigned int)est_nr_lex_rules, v2);
}

canonical_decompiled_code:
__int64 func23()
{
const char *v0; // rcx
const char *v1; // rdx
const char *v2; // rdx

warning("checking lexicon rules...");
func0();
func22();
if ( lexicon_errors )
{
v0 = "as";
v1 = (const char *)&unk_A82;
if ( lexicon_errors != 1 )
v0 = "ere";
if ( lexicon_errors != 1 )
v1 = "s";
panic("%d error%s w%s found in lexicon rules", (unsigned int)lexicon_errors, v1, v0);
}
v2 = (const char *)&unk_A82;
if ( est_nr_lex_rules != 1 )
v2 = "s";
return hint("found %d rule%s in lexicon", (unsigned int)est_nr_lex_rules, v2);
}

original_code:
void check_lexicon ()
 { warning ("checking lexicon rules...");
   init_lexicon_check ();
   check_lexicon_rules ();
   if (lexicon_errors)
      panic ("%d error%s w%s found in lexicon rules", lexicon_errors,
      (lexicon_errors == 1)?"":"s",
      (lexicon_errors == 1)?"as":"ere");
   hint ("found %d rule%s in lexicon", est_nr_lex_rules,
  (est_nr_lex_rules == 1)?"":"s");
 }

canonical_original_code:
void check_lexicon()
 { warning ("checking lexicon rules...");
   init_lexicon_check ();
   check_lexicon_rules ();
   if (lexicon_errors)
      panic ("%d error%s w%s found in lexicon rules", lexicon_errors,
      (lexicon_errors == 1)?"":"s",
      (lexicon_errors == 1)?"as":"ere");
   hint ("found %d rule%s in lexicon", est_nr_lex_rules,
  (est_nr_lex_rules == 1)?"":"s");
 }


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

if ( !ignore_lexicon && est_nr_lex_rules )
{
warning("preparing lexicon rules...");
init_lexicon_preparation();
prepare_lexicon_rules();
dump_lexicon_rules();
result = (unsigned int)lexicon_present;
if ( lexicon_present )
result = save_lexicon_rules(a1);
}
return result;
}

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

if ( !ignore_lexicon && est_nr_lex_rules )
{
warning("preparing lexicon rules...");
func4();
func17();
func8();
result = (unsigned int)lexicon_present;
if ( lexicon_present )
result = func9(a1);
}
return result;
}

original_code:
void prepare_lexicon (string basename)
 { if (ignore_lexicon) return;
   if (!est_nr_lex_rules) return;
   warning ("preparing lexicon rules...");
   init_lexicon_preparation ();
   prepare_lexicon_rules ();
   dump_lexicon_rules ();
   if (lexicon_present)
      save_lexicon_rules (basename);
 }

canonical_original_code:
void prepare_lexicon(char *basename)
 { if (ignore_lexicon) return;
   if (!est_nr_lex_rules) return;
   warning ("preparing lexicon rules...");
   init_lexicon_preparation ();
   prepare_lexicon_rules ();
   dump_lexicon_rules ();
   if (lexicon_present)
      save_lexicon_rules (basename);
 }


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

result = "rule";
if ( (a1 & 1) == 0 )
{
result = "predicate";
if ( (a1 & 2) == 0 )
{
result = "error kind";
if ( (a1 & 4) != 0 )
result = "semipredicate";
}
}
return result;
}

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

result = "rule";
if ( (a1 & 1) == 0 )
{
result = "predicate";
if ( (a1 & 2) == 0 )
{
result = "error kind";
if ( (a1 & 4) != 0 )
result = "semipredicate";
}
}
return result;
}

original_code:
static string string_from_rule_kind (int k)
 { if (k & 1) return ("rule");
   if (k & 2) return ("predicate");
   if (k & 4) return ("semipredicate");
   return ("error kind");
 }

canonical_original_code:
static char *string_from_rule_kind(int k)
 { if (k & 1) return ("rule");
   if (k & 2) return ("predicate");
   if (k & 4) return ("semipredicate");
   return ("error kind");
 }

variable_types: k int

return_type: char *