dump

decompiled_code:
int __fastcall dump(int *a1, int a2)
{
int *v2; // rbx
int v3; // edi
unsigned int v5; // ebp
const char *v6; // rax
__int64 v7; // rbp

if ( !a1 )
return printf("()");
v2 = a1;
v3 = *a1;
if ( v3 == 356 )
{
printf("(REF %d ", (unsigned int)v2[2]);
dump(**((_QWORD **)v2 + 2), 0LL);
dump_list(*(_QWORD *)(*((_QWORD *)v2 + 2) + 8LL), (unsigned int)(a2 + 1));
return putchar(41);
}
if ( v3 <= 356 )
{
switch ( v3 )
{
case 308:
return printf("\"%s\"", *((const char **)v2 + 1));
case 348:
return printf(
"(NAME \"%s\" \"%s\")",
*(const char **)(*((_QWORD *)v2 + 1) + 8LL),
*(const char **)(*((_QWORD *)v2 + 2) + 8LL));
case 294:
return printf("(NUMBER %d \"%s\")", (unsigned int)v2[2], **((const char ***)v2 + 2));
}
LABEL_18:
v5 = v2[2];
v6 = (const char *)name_of_tag();
printf("(%s %d", v6, v5);
if ( v2[1] > 0 )
{
v7 = 0LL;
do
in_dump(*(_QWORD *)(*((_QWORD *)v2 + 2) + 8 * v7++), (unsigned int)(a2 + 1));
while ( v2[1] > (int)v7 );
}
return putchar(41);
}
if ( v3 == 358 )
{
printf("(SREF %d ", (unsigned int)v2[2]);
dump(**((_QWORD **)v2 + 2), 0LL);
putchar(32);
dump(*(_QWORD *)(*((_QWORD *)v2 + 2) + 8LL), 0LL);
dump_list(*(_QWORD *)(*((_QWORD *)v2 + 2) + 16LL), (unsigned int)(a2 + 1));
dump_list(*(_QWORD *)(*((_QWORD *)v2 + 2) + 24LL), (unsigned int)(a2 + 1));
return putchar(41);
}
if ( v3 != 363 )
goto LABEL_18;
printf("(LIST");
do
{
in_dump(**((_QWORD **)v2 + 2), (unsigned int)(a2 + 1));
v2 = *(int **)(*((_QWORD *)v2 + 2) + 8LL);
}
while ( v2 );
return putchar(41);
}

canonical_decompiled_code:
int __fastcall func0(int *a1, int a2)
{
int *v2; // rbx
int v3; // edi
unsigned int v5; // ebp
const char *v6; // rax
__int64 v7; // rbp

if ( !a1 )
return printf("()");
v2 = a1;
v3 = *a1;
if ( v3 == 356 )
{
printf("(REF %d ", (unsigned int)v2[2]);
func0(**((_QWORD **)v2 + 2), 0LL);
func2(*(_QWORD *)(*((_QWORD *)v2 + 2) + 8LL), (unsigned int)(a2 + 1));
return putchar(41);
}
if ( v3 <= 356 )
{
switch ( v3 )
{
case 308:
return printf("\"%s\"", *((const char **)v2 + 1));
case 348:
return printf(
"(NAME \"%s\" \"%s\")",
*(const char **)(*((_QWORD *)v2 + 1) + 8LL),
*(const char **)(*((_QWORD *)v2 + 2) + 8LL));
case 294:
return printf("(NUMBER %d \"%s\")", (unsigned int)v2[2], **((const char ***)v2 + 2));
}
LABEL_18:
v5 = v2[2];
v6 = (const char *)name_of_tag();
printf("(%s %d", v6, v5);
if ( v2[1] > 0 )
{
v7 = 0LL;
do
func1(*(_QWORD *)(*((_QWORD *)v2 + 2) + 8 * v7++), (unsigned int)(a2 + 1));
while ( v2[1] > (int)v7 );
}
return putchar(41);
}
if ( v3 == 358 )
{
printf("(SREF %d ", (unsigned int)v2[2]);
func0(**((_QWORD **)v2 + 2), 0LL);
putchar(32);
func0(*(_QWORD *)(*((_QWORD *)v2 + 2) + 8LL), 0LL);
func2(*(_QWORD *)(*((_QWORD *)v2 + 2) + 16LL), (unsigned int)(a2 + 1));
func2(*(_QWORD *)(*((_QWORD *)v2 + 2) + 24LL), (unsigned int)(a2 + 1));
return putchar(41);
}
if ( v3 != 363 )
goto LABEL_18;
printf("(LIST");
do
{
func1(**((_QWORD **)v2 + 2), (unsigned int)(a2 + 1));
v2 = *(int **)(*((_QWORD *)v2 + 2) + 8LL);
}
while ( v2 );
return putchar(41);
}

original_code:
static void dump(tree t, int indent)
{
     int i; tree u;
     if (t == ((tree) ((void *)0))) {
   printf("()");
   return;
     }
     switch (t->x_kind) {
     case 363:
   printf("(LIST");
   for (u = t; u != ((tree) ((void *)0)); u = (u)->x_slot[1])
        in_dump((u)->x_slot[0], indent+1);
   printf(")");
   break;
     case 308:
   printf("\"%s\"", ((tok) t)->l_chars);
   break;
     case 348:
   printf("(NAME \"%s\" \"%s\")",
   ((sym) t)->s_basename->l_chars,
   ((sym) t)->s_decor->l_chars);
   break;
     case 356:
   printf("(REF %d ", t->x_loc);
   dump(t->x_slot[0], 0);
   dump_list(t->x_slot[1], indent+1);
   printf(")");
   break;
     case 358:
   printf("(SREF %d ", t->x_loc);
   dump(t->x_slot[0], 0);
   printf(" ");
   dump(t->x_slot[1], 0);
   dump_list(t->x_slot[2], indent+1);
   dump_list(t->x_slot[3], indent+1);
   printf(")");
   break;
     case 294:
   printf("(NUMBER %d \"%s\")", t->x_loc, (char *) t->x_slot[0]);
   break;
     default:
   printf("(%s %d", name_of_tag(t->x_kind), t->x_loc);
   for (i = 0; i < t->x_arity; i++)
        in_dump(t->x_slot[i], indent+1);
   printf(")");
     }
}

canonical_original_code:
static void dump(struct blob *t, int indent)
{
     int i; struct blob *u;
     if (t == ((tree) ((void *)0))) {
   printf("()");
   return;
     }
     switch (t->x_kind) {
     case 363:
   printf("(LIST");
   for (u = t; u != ((tree) ((void *)0)); u = (u)->x_slot[1])
        in_dump((u)->x_slot[0], indent+1);
   printf(")");
   break;
     case 308:
   printf("\"%s\"", ((struct tok *) t)->l_chars);
   break;
     case 348:
   printf("(NAME \"%s\" \"%s\")",
   ((struct sym *) t)->s_basename->l_chars,
   ((struct sym *) t)->s_decor->l_chars);
   break;
     case 356:
   printf("(REF %d ", t->x_loc);
   dump(t->x_slot[0], 0);
   dump_list(t->x_slot[1], indent+1);
   printf(")");
   break;
     case 358:
   printf("(SREF %d ", t->x_loc);
   dump(t->x_slot[0], 0);
   printf(" ");
   dump(t->x_slot[1], 0);
   dump_list(t->x_slot[2], indent+1);
   dump_list(t->x_slot[3], indent+1);
   printf(")");
   break;
     case 294:
   printf("(NUMBER %d \"%s\")", t->x_loc, (char *) t->x_slot[0]);
   break;
     default:
   printf("(%s %d", name_of_tag(t->x_kind), t->x_loc);
   for (i = 0; i < t->x_arity; i++)
        in_dump(t->x_slot[i], indent+1);
   printf(")");
     }
}

variable_types: struct blob { int x_kind; int x_arity; int x_loc; struct blob **x_slot; } *

variable_types: indent int


repo: thedotcomchase/Hot-Fuzz

decompiled_code:
int __fastcall in_dump(int *a1, int a2)
{
printf("\n%*s", 2 * a2, (const char *)&unk_2BF);
return dump(a1, a2);
}

canonical_decompiled_code:
int __fastcall func1(int *a1, int a2)
{
printf("\n%*s", 2 * a2, (const char *)&unk_2BF);
return func0(a1, a2);
}

original_code:
static void in_dump(tree t, int indent)
{
     printf("\n%*s", 2*indent, "");
     dump(t, indent);
}

canonical_original_code:
static void in_dump(struct blob *t, int indent)
{
     printf("\n%*s", 2*indent, "");
     dump(t, indent);
}

return_type: void

user_defined_types: struct blob { int x_kind; int x_arity; int x_loc; struct blob **x_slot; }


decompiled_code:
int __fastcall dump_list(int *a1, int a2)
{
int result; // eax

if ( a1 )
result = in_dump(a1, a2);
else
result = printf(" ()");
return result;
}

canonical_decompiled_code:
int __fastcall func2(int *a1, int a2)
{
int result; // eax

if ( a1 )
result = func1(a1, a2);
else
result = printf(" ()");
return result;
}

original_code:
static void dump_list(tree t, int indent)
{
     if (t == ((tree) ((void *)0)))
   printf(" ()");
     else
   in_dump(t, indent);
}

canonical_original_code:
static void dump_list(struct blob *t, int indent)
{
     if (t == ((tree) ((void *)0)))
   printf(" ()");
     else
   in_dump(t, indent);
}


decompiled_code:
int __fastcall dump_tree(int *a1)
{
dump(a1, 0);
return putchar(10);
}

canonical_decompiled_code:
int __fastcall func3(int *a1)
{
func0(a1, 0);
return putchar(10);
}

original_code:
void dump_tree(tree t)
{
     dump(t, 0);
     printf("\n");
}

canonical_original_code:
void dump_tree(struct blob *t)
{
     dump(t, 0);
     printf("\n");
}


decompiled_code:
__int64 parse_record()
{
char *v0; // rax
bool v1; // zf
char v2; // bl
__int64 result; // rax
char *v4; // rax
_BYTE *v5; // rax

++cursor;
v0 = (char *)get_field(":(*+-!>}");
record = (__int64)lookup(v0);
if ( peek == 58 )
{
v4 = (char *)get_field("(*+-!>}");
*(&record + 1) = (__int64)lookup(v4);
}
else
{
*(&record + 1) = 0LL;
}
if ( peek == 40 )
{
*(&record + 2) = cursor;
do
{
do
v5 = (_BYTE *)cursor++;
while ( *v5 != 36 );
}
while ( v5[1] != 41 );
cursor = v5 + 2;
v5[1] = 0;
get_field("*+-!>}");
}
else
{
*(&record + 2) = 0LL;
}
v1 = peek == 42;
*((_DWORD *)&record + 12) = peek == 42;
if ( v1 )
get_field("+-!>}");
v2 = peek;
if ( strchr("+-!>", peek) )
{
*((_BYTE *)&record + 24) = v2;
*(&record + 4) = get_field("}");
}
else
{
*((_BYTE *)&record + 24) = 32;
}
++cursor;
result = get_field("}");
*(&record + 5) = result;
return result;
}

canonical_decompiled_code:
__int64 func3()
{
char *v0; // rax
bool v1; // zf
char v2; // bl
__int64 result; // rax
char *v4; // rax
_BYTE *v5; // rax

++cursor;
v0 = (char *)get_field(":(*+-!>}");
record = (__int64)func2(v0);
if ( peek == 58 )
{
v4 = (char *)get_field("(*+-!>}");
*(&record + 1) = (__int64)func2(v4);
}
else
{
*(&record + 1) = 0LL;
}
if ( peek == 40 )
{
*(&record + 2) = cursor;
do
{
do
v5 = (_BYTE *)cursor++;
while ( *v5 != 36 );
}
while ( v5[1] != 41 );
cursor = v5 + 2;
v5[1] = 0;
get_field("*+-!>}");
}
else
{
*(&record + 2) = 0LL;
}
v1 = peek == 42;
*((_DWORD *)&record + 12) = peek == 42;
if ( v1 )
get_field("+-!>}");
v2 = peek;
if ( strchr("+-!>", peek) )
{
*((_BYTE *)&record + 24) = v2;
*(&record + 4) = get_field("}");
}
else
{
*((_BYTE *)&record + 24) = 32;
}
++cursor;
result = get_field("}");
*(&record + 5) = result;
return result;
}

original_code:
void parse_record(void)
{
     cursor++;
     record.main = lookup(get_field(":(*+-!>}"));
     if (peek == ':')
   record.sub = lookup(get_field("(*+-!>}"));
     else
   record.sub = ((void *)0);
     if (peek != '(')
   record.symbol = ((void *)0);
     else {
   record.symbol = cursor;
   do
        cursor++;
   while (cursor[-1] != '$' || *cursor != ')');
   *cursor++ = '\0';
   get_field("*+-!>}");
     }
     record.star = (peek == '*');
     if (record.star)
   get_field("+-!>}");
     if (strchr("+-!>", peek)) {
   record.flag = peek;
   record.see_also = get_field("}");
     }
     else
   record.flag = ' ';
     cursor++;
     record.page = get_field("}");
}

canonical_original_code:
void parse_record()
{
     cursor++;
     record.main = lookup(get_field(":(*+-!>}"));
     if (peek == ':')
   record.sub = lookup(get_field("(*+-!>}"));
     else
   record.sub = ((void *)0);
     if (peek != '(')
   record.symbol = ((void *)0);
     else {
   record.symbol = cursor;
   do
        cursor++;
   while (cursor[-1] != '$' || *cursor != ')');
   *cursor++ = '\0';
   get_field("*+-!>}");
     }
     record.star = (peek == '*');
     if (record.star)
   get_field("+-!>}");
     if (strchr("+-!>", peek)) {
   record.flag = peek;
   record.see_also = get_field("}");
     }
     else
   record.flag = ' ';
     cursor++;
     record.page = get_field("}");
}


original_code:
void print_range(char *start, char *end)
{
     int j = 0;
     if (strlen(start) == strlen(end))
   while (start[j] == end[j]) j++;
     if (j > 0 && start[j+1] == '\0' && start[j-1] == '1') j--;
     if (strspn(&start[j], "0") == strlen(&start[j]))
   while (start[j] == '0') j--;
     printf(", %s--%s", start, &end[j]);
}

variable_types:
start
char *

variable_types:
end
char *

variable_types: j int


textout

decompiled_code:
int __fastcall textout(const char *a1, _BYTE *a2)
{
_BYTE *v2; // rbp
int result; // eax
char i; // di
_BYTE *v5; // rbx
char v6; // di
_BYTE *v7; // rbx

v2 = a2;
result = printf("%s ", a1);
for ( i = *a2; i; i = v7[1] )
{
if ( i == 124 )
{
printf("\\verb:");
v5 = v2 + 1;
v6 = v2[1];
if ( v6 && v6 != 124 )
{
do
{
putchar(v6);
v6 = *++v5;
}
while ( *v5 && v6 != 124 );
}
result = putchar(58);
v7 = &v5[-(*v5 == 0)];
}
else
{
result = putchar(i);
v7 = v2;
}
v2 = v7 + 1;
}
return result;
}

canonical_decompiled_code:
int __fastcall func8(const char *a1, _BYTE *a2)
{
_BYTE *v2; // rbp
int result; // eax
char i; // di
_BYTE *v5; // rbx
char v6; // di
_BYTE *v7; // rbx

v2 = a2;
result = printf("%s ", a1);
for ( i = *a2; i; i = v7[1] )
{
if ( i == 124 )
{
printf("\\verb:");
v5 = v2 + 1;
v6 = v2[1];
if ( v6 && v6 != 124 )
{
do
{
putchar(v6);
v6 = *++v5;
}
while ( *v5 && v6 != 124 );
}
result = putchar(58);
v7 = &v5[-(*v5 == 0)];
}
else
{
result = putchar(i);
v7 = v2;
}
v2 = v7 + 1;
}
return result;
}

original_code:
void textout(char *tag, char *txt)
{
     char *s;
     printf("%s ", tag);
     for (s = txt; *s != '\0'; s++) {
   if (*s != '|')
        putchar(*s);
   else {
        printf("\\verb:");
        for (s++; *s != '\0' && *s != '|'; s++)
      putchar(*s);
        putchar(':');
        if (*s == '\0') s--;
   }
     }
}

variable_types:
tag
char *

variable_types:
txt
char *

variable_types:
s
char *


initial

decompiled_code:
__int64 __fastcall initial(_BYTE *a1)
{
char v1; // bl
_BYTE *v2; // rbp
const unsigned __int16 *v3; // rdx
const unsigned __int16 *v4; // rdx
__int64 result; // rax

v1 = *a1;
if ( (*a1 & 0xDF) != 0 )
{
v2 = a1;
v3 = *_ctype_b_loc();
do
{
if ( (v3[v1] & 0x400) != 0 )
break;
v1 = *++v2;
}
while ( (*v2 & 0xDF) != 0 );
}
v4 = *_ctype_b_loc();
result = 33LL;
if ( (v4[v1] & 0x400) != 0 )
result = LOBYTE((*_ctype_tolower_loc())[v1]);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func11(_BYTE *a1)
{
char v1; // bl
_BYTE *v2; // rbp
const unsigned __int16 *v3; // rdx
const unsigned __int16 *v4; // rdx
__int64 result; // rax

v1 = *a1;
if ( (*a1 & 0xDF) != 0 )
{
v2 = a1;
v3 = *_ctype_b_loc();
do
{
if ( (v3[v1] & 0x400) != 0 )
break;
v1 = *++v2;
}
while ( (*v2 & 0xDF) != 0 );
}
v4 = *_ctype_b_loc();
result = 33LL;
if ( (v4[v1] & 0x400) != 0 )
result = LOBYTE((*_ctype_tolower_loc())[v1]);
return result;
}

original_code:
char initial(char *s)
{
     while (*s != '\0' && *s != ' ' && !((*__ctype_b_loc ())[(int) ((*s))] & (unsigned short int) _ISalpha)) s++;
     return (((*__ctype_b_loc ())[(int) ((*s))] & (unsigned short int) _ISalpha) ? tolower(*s) : '!');
}

canonical_original_code:
char initial(char *s)
{
     while (*s != '\0' && *s != ' ' && !((*__ctype_b_loc ())[(int) ((*s))] & (unsigned short) _ISalpha)) s++;
     return (((*__ctype_b_loc ())[(int) ((*s))] & (unsigned short) _ISalpha) ? tolower(*s) : '!');
}

return_type: char


decompiled_code:
int make_index()
{
char v0; // r12
__int64 i; // rbx
char v2; // al
char v3; // bp

puts("\\begin{theindex}");
if ( n_items > 0 )
{
v0 = initial(*(_BYTE **)item_table[0]);
for ( i = 1LL; ; ++i )
{
do_item(*(_QWORD *)(item_table[i - 1] + 8));
if ( n_items <= (int)i )
break;
v2 = initial(*(_BYTE **)item_table[i]);
v3 = v2;
if ( v2 != v0 && v0 != 38 )
printf("\\indexspace %% %c\n", (unsigned int)v2);
v0 = v3;
}
}
return puts("\\end{theindex}");
}

canonical_decompiled_code:
int func12()
{
char v0; // r12
__int64 i; // rbx
char v2; // al
char v3; // bp

puts("\\begin{theindex}");
if ( n_items > 0 )
{
v0 = func11(*(_BYTE **)item_table[0]);
for ( i = 1LL; ; ++i )
{
func10(*(_QWORD *)(item_table[i - 1] + 8));
if ( n_items <= (int)i )
break;
v2 = func11(*(_BYTE **)item_table[i]);
v3 = v2;
if ( v2 != v0 && v0 != 38 )
printf("\\indexspace %% %c\n", (unsigned int)v2);
v0 = v3;
}
}
return puts("\\end{theindex}");
}

original_code:
void make_index(void)
{
     int i;
     char init = '&', new_init;
     printf("\\begin{theindex}\n");
     for (i = 0; i < n_items; i++) {
   new_init = initial(item_table[i]->text);
   if (new_init != init && init != '&')
        printf("\\indexspace %% %c\n", new_init);
   init = new_init;
   do_item(item_table[i]->entry);
     }
     printf("\\end{theindex}\n");
}

canonical_original_code:
void make_index()
{
     int i;
     char init = '&'; char new_init;
     printf("\\begin{theindex}\n");
     for (i = 0; i < n_items; i++) {
   new_init = initial(item_table[i]->text);
   if (new_init != init && init != '&')
        printf("\\indexspace %% %c\n", new_init);
   init = new_init;
   do_item(item_table[i]->entry);
     }
     printf("\\end{theindex}\n");
}

variable_types: i int

variable_types: init char


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
setup_and_read(argc, argv, envp);
qsort(item_table, n_items, 8uLL, (__compar_fn_t)item_compare);
make_index();
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
setup_and_read(argc, argv, envp);
qsort(item_table, n_items, 8uLL, (__compar_fn_t)item_compare);
func12();
return 0;
}

original_code:
int main(int argc, char *argv[])
{
     setup_and_read(argc, argv);
     qsort(item_table, n_items, sizeof(token), (compare_fun) item_compare);
     make_index();
     return 0;
}

canonical_original_code:
int main(int argc, char *argv[])
{
     setup_and_read(argc, argv);
     qsort(item_table, n_items, sizeof(token), (int (*)(void *, void *)) item_compare);
     make_index();
     return 0;
}

variable_types: argc int

variable_types:
argv
char *[]

return_type: int


panic

decompiled_code:
void __noreturn panic(__int64 a1, ...)
{
gcc_va_list va; // [rsp+8h] [rbp-D0h] BYREF

va_start(va, a1);
grind(stderr, "\nPanic: ");
do_grind(stderr, a1, va);
grind(stderr, "\n");
fflush(stderr);
abort();
}

canonical_decompiled_code:
void __noreturn func0(__int64 a1, ...)
{
gcc_va_list va; // [rsp+8h] [rbp-D0h] BYREF

va_start(va, a1);
grind(stderr, "\nPanic: ");
do_grind(stderr, a1, va);
grind(stderr, "\n");
fflush(stderr);
abort();
}

original_code:
void panic(char *fmt, ...)
{
     va_list a;
     grind(stderr, "\nPanic: ");
     __builtin_va_start(a,fmt);
     do_grind(stderr, fmt, &a);
     __builtin_va_end(a);
     grind(stderr, "\n");
     fflush(stderr);
     abort();
}

canonical_original_code:
void panic(char *fmt, ...)
{
     __builtin_va_list a;
     grind(stderr, "\nPanic: ");
     __builtin_va_start(a,fmt);
     do_grind(stderr, fmt, &a);
     __builtin_va_end(a);
     grind(stderr, "\n");
     fflush(stderr);
     abort();
}

variable_types:
fmt
char *


decompiled_code:
int tc_e_etc(__int64 a1, ...)
{
gcc_va_list va; // [rsp+8h] [rbp-D0h] BYREF

if ( !in_error )
panic((__int64)"tc_e_etc");
grind(stderr, "> ");
va_start(va, a1);
do_grind(stderr, a1, va);
grind(stderr, "\n");
return fflush(stderr);
}

canonical_decompiled_code:
int func1(__int64 a1, ...)
{
gcc_va_list va; // [rsp+8h] [rbp-D0h] BYREF

if ( !in_error )
func0((__int64)"tc_e_etc");
grind(stderr, "> ");
va_start(va, a1);
do_grind(stderr, a1, va);
grind(stderr, "\n");
return fflush(stderr);
}

original_code:
void tc_e_etc(char *fmt, ...)
{
     va_list a;
     if (! in_error) panic("tc_e_etc");
     grind(stderr, "> ");
     __builtin_va_start(a,fmt);
     do_grind(stderr, fmt, &a);
     __builtin_va_end(a);
     grind(stderr, "\n");
     fflush(stderr);
}

canonical_original_code:
void tc_e_etc(char *fmt, ...)
{
     __builtin_va_list a;
     if (! in_error) panic("tc_e_etc");
     grind(stderr, "> ");
     __builtin_va_start(a,fmt);
     do_grind(stderr, fmt, &a);
     __builtin_va_end(a);
     grind(stderr, "\n");
     fflush(stderr);
}


decompiled_code:
int tc_e_end()
{
if ( !in_error )
panic((__int64)"tc_e_end");
in_error = 0;
grind(stderr, "\n");
return fflush(stderr);
}

canonical_decompiled_code:
int func2()
{
if ( !in_error )
func0((__int64)"tc_e_end");
in_error = 0;
grind(stderr, "\n");
return fflush(stderr);
}

original_code:
void tc_e_end(void)
{
     if (! in_error) panic("tc_e_end");
     in_error = 0;
     grind(stderr, "\n");
     fflush(stderr);
}

canonical_original_code:
void tc_e_end()
{
     if (! in_error) panic("tc_e_end");
     in_error = 0;
     grind(stderr, "\n");
     fflush(stderr);
}


decompiled_code:
__int64 __fastcall report_error(int a1, unsigned int a2, const char *a3, __int64 a4)
{
const unsigned __int16 **v5; // rax
__int64 v6; // r12
char v8[168]; // [rsp+0h] [rbp-A8h] BYREF

if ( in_error )
panic((__int64)"report_error");
in_error = 1;
if ( a1 != 3 )
{
++n_errors;
if ( n_errors > 99 )
{
fwrite("fuzz: too many errors - giving up\n", 1uLL, 0x22uLL, stderr);
fflush(stderr);
exit(1);
}
}
strcpy(v8, a3);
v5 = _ctype_b_loc();
v6 = v8[0];
if ( ((*v5)[v8[0]] & 0x200) != 0 )
v8[0] = (*_ctype_toupper_loc())[v6];
grind(stderr, "\"%s\", line %d: ", file_name, a2);
if ( a1 == 3 )
{
grind(stderr, "Warning - ");
do_grind(stderr, v8, a4);
}
else
{
do_grind(stderr, v8, a4);
if ( a1 == 1 )
{
if ( yychar )
{
if ( yychar == 292 )
{
grind(stderr, " at \"\\\\\" or \"\\also\"");
}
else if ( *yytext )
{
grind(stderr, " at symbol \"%s\"", yytext);
}
}
else
{
grind(stderr, " at end of file");
}
}
}
return grind(stderr, "\n");
}

canonical_decompiled_code:
__int64 __fastcall func3(int a1, unsigned int a2, const char *a3, __int64 a4)
{
const unsigned __int16 **v5; // rax
__int64 v6; // r12
char v8[168]; // [rsp+0h] [rbp-A8h] BYREF

if ( in_error )
func0((__int64)"report_error");
in_error = 1;
if ( a1 != 3 )
{
++n_errors;
if ( n_errors > 99 )
{
fwrite("fuzz: too many errors - giving up\n", 1uLL, 0x22uLL, stderr);
fflush(stderr);
exit(1);
}
}
strcpy(v8, a3);
v5 = _ctype_b_loc();
v6 = v8[0];
if ( ((*v5)[v8[0]] & 0x200) != 0 )
v8[0] = (*_ctype_toupper_loc())[v6];
grind(stderr, "\"%s\", line %d: ", file_name, a2);
if ( a1 == 3 )
{
grind(stderr, "Warning - ");
do_grind(stderr, v8, a4);
}
else
{
do_grind(stderr, v8, a4);
if ( a1 == 1 )
{
if ( yychar )
{
if ( yychar == 292 )
{
grind(stderr, " at \"\\\\\" or \"\\also\"");
}
else if ( *yytext )
{
grind(stderr, " at symbol \"%s\"", yytext);
}
}
else
{
grind(stderr, " at end of file");
}
}
}
return grind(stderr, "\n");
}

original_code:
static void report_error(int kind, int line, char *fmt, va_list *a)
{
     char buf[128];
     if (in_error) panic("report_error");
     in_error = 1;
     if (kind != 3 && ++n_errors >= 100) {
   fprintf(stderr, "fuzz: too many errors - giving up\n");
   fflush(stderr);
   exit(1);
     }
     strcpy(buf, fmt);
     if (((*__ctype_b_loc ())[(int) ((buf[0]))] & (unsigned short int) _ISlower))
   buf[0] = toupper(buf[0]);
     grind(stderr, "\"%s\", line %d: ", file_name, line);
     if (kind == 3)
          grind(stderr, "Warning - ");
     do_grind(stderr, buf, a);
     if (kind == 1) {
          if (yychar == 0)
               grind(stderr, " at end of file");
          else if (yychar == 292)
               grind(stderr, " at \"\\\\\" or \"\\also\"");
          else if (yytext[0] != '\0')
          grind(stderr, " at symbol \"%s\"", yytext);
     }
     grind(stderr, "\n");
}

canonical_original_code:
static void report_error(int kind, int line, char *fmt, __builtin_va_list *a)
{
     char buf[128];
     if (in_error) panic("report_error");
     in_error = 1;
     if (kind != 3 && ++n_errors >= 100) {
   fprintf(stderr, "fuzz: too many errors - giving up\n");
   fflush(stderr);
   exit(1);
     }
     strcpy(buf, fmt);
     if (((*__ctype_b_loc ())[(int) ((buf[0]))] & (unsigned short) _ISlower))
   buf[0] = toupper(buf[0]);
     grind(stderr, "\"%s\", line %d: ", file_name, line);
     if (kind == 3)
          grind(stderr, "Warning - ");
     do_grind(stderr, buf, a);
     if (kind == 1) {
          if (yychar == 0)
               grind(stderr, " at end of file");
          else if (yychar == 292)
               grind(stderr, " at \"\\\\\" or \"\\also\"");
          else if (yytext[0] != '\0')
          grind(stderr, " at symbol \"%s\"", yytext);
     }
     grind(stderr, "\n");
}

variable_types: kind int

variable_types: line int

variable_types:
a
__builtin_va_list *

variable_types:
buf
char [128]


yyerror

decompiled_code:
int yyerror(const char *a1, ...)
{
gcc_va_list va; // [rsp+8h] [rbp-D0h] BYREF

va_start(va, a1);
report_error(1, yylloc, a1, (__int64)va);
return tc_e_end();
}

canonical_decompiled_code:
int func4(const char *a1, ...)
{
gcc_va_list va; // [rsp+8h] [rbp-D0h] BYREF

va_start(va, a1);
func3(1, yylloc, a1, (__int64)va);
return func2();
}

original_code:
void yyerror(char *fmt, ...)
{
     va_list a;
     extern YYLTYPE yylloc;
     __builtin_va_start(a,fmt);
     report_error(1, yylloc.first_line, fmt, &a);
     __builtin_va_end(a);
     tc_e_end();
}

canonical_original_code:
void yyerror(char *fmt, ...)
{
     __builtin_va_list a;
     extern struct YYLTYPE yylloc;
     __builtin_va_start(a,fmt);
     report_error(1, yylloc.first_line, fmt, &a);
     __builtin_va_end(a);
     tc_e_end();
}

variable_types: struct YYLTYPE { int first_line; int first_column; int last_line; int last_column; }


decompiled_code:
__int64 tc_error(unsigned int a1, const char *a2, ...)
{
gcc_va_list va; // [rsp+8h] [rbp-D0h] BYREF

va_start(va, a2);
return report_error(2, a1, a2, (__int64)va);
}

canonical_decompiled_code:
__int64 func5(unsigned int a1, const char *a2, ...)
{
gcc_va_list va; // [rsp+8h] [rbp-D0h] BYREF

va_start(va, a2);
return func3(2, a1, a2, (__int64)va);
}

original_code:
void tc_error(int loc, char *fmt, ...)
{
     va_list a;
     __builtin_va_start(a,fmt);
     report_error(2, loc, fmt, &a);
     __builtin_va_end(a);
}

canonical_original_code:
void tc_error(int loc, char *fmt, ...)
{
     __builtin_va_list a;
     __builtin_va_start(a,fmt);
     report_error(2, loc, fmt, &a);
     __builtin_va_end(a);
}

variable_types: loc int


decompiled_code:
__int64 tc_warn(unsigned int a1, const char *a2, ...)
{
gcc_va_list va; // [rsp+8h] [rbp-D0h] BYREF

va_start(va, a2);
return report_error(3, a1, a2, (__int64)va);
}

canonical_decompiled_code:
__int64 func6(unsigned int a1, const char *a2, ...)
{
gcc_va_list va; // [rsp+8h] [rbp-D0h] BYREF

va_start(va, a2);
return func3(3, a1, a2, (__int64)va);
}

original_code:
void tc_warn(int loc, char *fmt, ...)
{
     va_list a;
     __builtin_va_start(a,fmt);
     report_error(3, loc, fmt, &a);
     __builtin_va_end(a);
}

canonical_original_code:
void tc_warn(int loc, char *fmt, ...)
{
     __builtin_va_list a;
     __builtin_va_start(a,fmt);
     report_error(3, loc, fmt, &a);
     __builtin_va_end(a);
}


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

canonical_decompiled_code:
void __fastcall __noreturn func7(const char *a1, __int64 a2)
{
func0((__int64)"bad tag %d in %s", a2, a1);
}

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

variable_types: v int


decompiled_code:
void __noreturn debug_help()
{
fprintf(stderr, "%s\n", "Debugging options: -D{adehpstuvy}");
fprintf(stderr, "%s\n", "Codes: Allocation, Dependencies, Expressions, Hash table,");
fprintf(stderr, "%s\n", " Lisp dump, Prelude, Scribble on freed storage,");
fprintf(stderr, "%s\n", " Type storage, Unification, Version, Yacc parser");
exit(2);
}

canonical_decompiled_code:
void __noreturn func0()
{
fprintf(stderr, "%s\n", "Debugging options: -D{adehpstuvy}");
fprintf(stderr, "%s\n", "Codes: Allocation, Dependencies, Expressions, Hash table,");
fprintf(stderr, "%s\n", " Lisp dump, Prelude, Scribble on freed storage,");
fprintf(stderr, "%s\n", " Type storage, Unification, Version, Yacc parser");
exit(2);
}

original_code:
static void debug_help(void)
{
     (void) fprintf(stderr, "%s\n", "Debugging options: -D{adehpstuvy}");
     (void) fprintf(stderr, "%s\n", "Codes: Allocation, Dependencies, Expressions, Hash table,");
     (void) fprintf(stderr, "%s\n", "       Lisp dump, Prelude, Scribble on freed storage,");
     (void) fprintf(stderr, "%s\n", "       Type storage, Unification, Version, Yacc parser");
     exit(2);
}

canonical_original_code:
static void debug_help()
{
     (void) fprintf(stderr, "%s\n", "Debugging options: -D{adehpstuvy}");
     (void) fprintf(stderr, "%s\n", "Codes: Allocation, Dependencies, Expressions, Hash table,");
     (void) fprintf(stderr, "%s\n", "       Lisp dump, Prelude, Scribble on freed storage,");
     (void) fprintf(stderr, "%s\n", "       Type storage, Unification, Version, Yacc parser");
     exit(2);
}


decompiled_code:
__int64 __fastcall do_flags(__int64 a1, __int64 a2)
{
__int64 result; // rax
_BYTE *v3; // rdx
int v4; // er12
__int64 v5; // r13
char v6; // r15
char v7; // r14
_BYTE *v8; // rbp
_BYTE *v9; // rbp
char v10; // bl
const unsigned __int16 **v11; // rcx

result = *(unsigned __int8 *)(a1 + 1);
if ( (_BYTE)result )
{
v3 = (_BYTE *)(a1 + 1);
v4 = argc;
v5 = argv;
v6 = 0;
v7 = 0;
do
{
switch ( (char)result )
{
case 'D':
v9 = v3 + 1;
v10 = v3[1];
if ( v10 )
{
v11 = _ctype_b_loc();
do
{
if ( ((*v11)[v10] & 0x200) == 0 )
{
if ( v7 )
argc = v4;
if ( v6 )
argv = v5;
debug_help();
}
++dcode[v10 - 97];
v10 = *++v9;
}
while ( *v9 );
}
v8 = v9 - 1;
break;
case 'a':
++aflag;
v8 = v3;
break;
case 'd':
++dflag;
v8 = v3;
break;
case 'i':
++iflag;
v8 = v3;
break;
case 'l':
++lflag;
v8 = v3;
break;
case 'p':
if ( !--v4 )
{
argc = 0;
if ( v6 )
argv = v5;
usage(a1, a2, v3);
}
++pflag;
prelude = *(char **)(v5 + 8);
v5 += 8LL;
v8 = v3;
v6 = 1;
v7 = 1;
break;
case 'q':
++qflag;
v8 = v3;
break;
case 's':
++sflag;
v8 = v3;
break;
case 't':
++tflag;
v8 = v3;
break;
case 'v':
++vflag;
v8 = v3;
break;
default:
if ( v7 )
argc = v4;
if ( v6 )
argv = v5;
usage(a1, a2, v3);
return result;
}
v3 = v8 + 1;
result = (unsigned __int8)v8[1];
}
while ( (_BYTE)result );
if ( v7 )
argc = v4;
if ( v6 )
argv = v5;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, __int64 a2)
{
__int64 result; // rax
_BYTE *v3; // rdx
int v4; // er12
__int64 v5; // r13
char v6; // r15
char v7; // r14
_BYTE *v8; // rbp
_BYTE *v9; // rbp
char v10; // bl
const unsigned __int16 **v11; // rcx

result = *(unsigned __int8 *)(a1 + 1);
if ( (_BYTE)result )
{
v3 = (_BYTE *)(a1 + 1);
v4 = argc;
v5 = argv;
v6 = 0;
v7 = 0;
do
{
switch ( (char)result )
{
case 'D':
v9 = v3 + 1;
v10 = v3[1];
if ( v10 )
{
v11 = _ctype_b_loc();
do
{
if ( ((*v11)[v10] & 0x200) == 0 )
{
if ( v7 )
argc = v4;
if ( v6 )
argv = v5;
func0();
}
++dcode[v10 - 97];
v10 = *++v9;
}
while ( *v9 );
}
v8 = v9 - 1;
break;
case 'a':
++aflag;
v8 = v3;
break;
case 'd':
++dflag;
v8 = v3;
break;
case 'i':
++iflag;
v8 = v3;
break;
case 'l':
++lflag;
v8 = v3;
break;
case 'p':
if ( !--v4 )
{
argc = 0;
if ( v6 )
argv = v5;
func1(a1, a2, v3);
}
++pflag;
prelude = *(char **)(v5 + 8);
v5 += 8LL;
v8 = v3;
v6 = 1;
v7 = 1;
break;
case 'q':
++qflag;
v8 = v3;
break;
case 's':
++sflag;
v8 = v3;
break;
case 't':
++tflag;
v8 = v3;
break;
case 'v':
++vflag;
v8 = v3;
break;
default:
if ( v7 )
argc = v4;
if ( v6 )
argv = v5;
func1(a1, a2, v3);
return result;
}
v3 = v8 + 1;
result = (unsigned __int8)v8[1];
}
while ( (_BYTE)result );
if ( v7 )
argc = v4;
if ( v6 )
argv = v5;
}
return result;
}

original_code:
static void do_flags(char *flags)
{
     char *s;
     for (s = flags+1; *s != '\0'; s++)
          switch (*s) {
          case 'a': aflag++; break;
   case 'd': dflag++; break;
   case 'l': lflag++; break;
          case 'q': qflag++; break;
          case 's': sflag++; break;
          case 't': tflag++; break;
          case 'v': vflag++; break;
          case 'i': iflag++; break;
          case 'p':
               if (--argc == 0) usage();
               pflag++;
               prelude = *++argv;
               break;
          case 'D':
               for (s++; *s != '\0'; s++)
                    if (((*__ctype_b_loc ())[(int) ((*s))] & (unsigned short int) _ISlower))
                         dcode[*s - 'a']++;
                    else
                         debug_help();
               s--;
               break;
          default: usage();
          }
}

canonical_original_code:
static void do_flags(char *flags)
{
     char *s;
     for (s = flags+1; *s != '\0'; s++)
          switch (*s) {
          case 'a': aflag++; break;
   case 'd': dflag++; break;
   case 'l': lflag++; break;
          case 'q': qflag++; break;
          case 's': sflag++; break;
          case 't': tflag++; break;
          case 'v': vflag++; break;
          case 'i': iflag++; break;
          case 'p':
               if (--argc == 0) usage();
               pflag++;
               prelude = *++argv;
               break;
          case 'D':
               for (s++; *s != '\0'; s++)
                    if (((*__ctype_b_loc ())[(int) ((*s))] & (unsigned short) _ISlower))
                         dcode[*s - 'a']++;
                    else
                         debug_help();
               s--;
               break;
          default: usage();
          }
}

variable_types:
flags
char *


decompiled_code:
char *__fastcall perm_copy(char *src)
{
int v1; // eax
char *v2; // rax

v1 = strlen(src);
v2 = (char *)perm_alloc((unsigned int)(v1 + 1));
return strcpy(v2, src);
}

canonical_decompiled_code:
char *__fastcall func3(char *src)
{
int v1; // eax
char *v2; // rax

v1 = strlen(src);
v2 = (char *)perm_alloc((unsigned int)(v1 + 1));
return strcpy(v2, src);
}

original_code:
static char *perm_copy(char *s)
{
     char *t = (char *) perm_alloc(strlen(s)+1);
     strcpy(t, s);
     return t;
}

variable_types:
t
char *

return_type: char *


decompiled_code:
char *open_prelude()
{
char *v0; // rbx
char *result; // rax

v0 = prelude;
if ( !pflag )
{
v0 = getenv(envname);
if ( v0 )
goto LABEL_3;
v0 = prelude;
}
if ( !v0 )
goto LABEL_7;
LABEL_3:
yyin = fopen(v0, "r");
if ( !yyin )
{
LABEL_7:
fprintf(stderr, "fuzz: can't read prelude file %s\n", v0);
exit(2);
}
result = perm_copy(v0);
file_name = (__int64)result;
return result;
}

canonical_decompiled_code:
char *func4()
{
char *v0; // rbx
char *result; // rax

v0 = prelude;
if ( !pflag )
{
v0 = getenv(envname);
if ( v0 )
goto LABEL_3;
v0 = prelude;
}
if ( !v0 )
goto LABEL_7;
LABEL_3:
yyin = fopen(v0, "r");
if ( !yyin )
{
LABEL_7:
fprintf(stderr, "fuzz: can't read prelude file %s\n", v0);
exit(2);
}
result = func3(v0);
file_name = (__int64)result;
return result;
}

original_code:
static void open_prelude(void)
{
     char *fn;
     extern char *envname;
     extern char *getenv();
     if (pflag)
   fn = prelude;
     else {
   fn = getenv(envname);
   if (fn == ((void *)0)) {
        fn = prelude;
   }
     }
     if (fn == ((void *)0) || (yyin = fopen(fn, "r")) == ((void *)0)) {
   (void) fprintf(stderr, "fuzz: can't read prelude file %s\n", fn);
   exit(2);
     }
     file_name = perm_copy(fn);
}

canonical_original_code:
static void open_prelude()
{
     char *fn;
     extern char *envname;
     extern char *getenv();
     if (pflag)
   fn = prelude;
     else {
   fn = getenv(envname);
   if (fn == ((void *)0)) {
        fn = prelude;
   }
     }
     if (fn == ((void *)0) || (yyin = fopen(fn, "r")) == ((void *)0)) {
   (void) fprintf(stderr, "fuzz: can't read prelude file %s\n", fn);
   exit(2);
     }
     file_name = perm_copy(fn);
}

variable_types:
fn
char *

variable_types:
envname
char *

variable_types:
getenv
char *()


decompiled_code:
__int64 read_a_file()
{
int v0; // eax

line_count = 1;
yylloc = 1;
v0 = debugging;
if ( debugging )
v0 = dcode[24] != 0;
yydebug = v0;
return yyparse();
}

canonical_decompiled_code:
__int64 func6()
{
int v0; // eax

line_count = 1;
yylloc = 1;
v0 = debugging;
if ( debugging )
v0 = dcode[24] != 0;
yydebug = v0;
return yyparse();
}

original_code:
static void read_a_file(void)
{
     yylloc = line_count = 1;
     yydebug = (debugging && dcode['y' - 'a']);
     yyparse();
}

canonical_original_code:
static void read_a_file()
{
     yylloc = line_count = 1;
     yydebug = (debugging && dcode['y' - 'a']);
     yyparse();
}


usage

decompiled_code:
void __noreturn usage()
{
fprintf(stderr, "%s\n", "Usage: fuzz [-aqstv] [-p file] file ...");
fprintf(stderr, "%s\n", "Flags: -a Don't use type abbreviations");
fprintf(stderr, "%s\n", " -d Allow use before definition");
fprintf(stderr, "%s\n", " -l Lisp-style echoing of input");
fprintf(stderr, "%s\n", " -p file Use <file> in place of standard prelude");
fprintf(stderr, "%s\n", " -q Assume quantifiers for undeclared variables");
fprintf(stderr, "%s\n", " -s Syntax check only");
fprintf(stderr, "%s\n", " -t Report types of global definitions");
fprintf(stderr, "%s\n", " -v Echo input as it is parsed");
exit(2);
}

canonical_decompiled_code:
void __noreturn func1()
{
fprintf(stderr, "%s\n", "Usage: fuzz [-aqstv] [-p file] file ...");
fprintf(stderr, "%s\n", "Flags: -a Don't use type abbreviations");
fprintf(stderr, "%s\n", " -d Allow use before definition");
fprintf(stderr, "%s\n", " -l Lisp-style echoing of input");
fprintf(stderr, "%s\n", " -p file Use <file> in place of standard prelude");
fprintf(stderr, "%s\n", " -q Assume quantifiers for undeclared variables");
fprintf(stderr, "%s\n", " -s Syntax check only");
fprintf(stderr, "%s\n", " -t Report types of global definitions");
fprintf(stderr, "%s\n", " -v Echo input as it is parsed");
exit(2);
}

original_code:
static void usage(void)
{
     (void) fprintf(stderr, "%s\n", "Usage: fuzz [-aqstv] [-p file] file ...");
     (void) fprintf(stderr, "%s\n", "Flags: -a       Don't use type abbreviations");
     (void) fprintf(stderr, "%s\n", "       -d       Allow use before definition");
     (void) fprintf(stderr, "%s\n", "       -l       Lisp-style echoing of input");
     (void) fprintf(stderr, "%s\n", "       -p file  Use <file> in place of standard prelude");
     (void) fprintf(stderr, "%s\n", "       -q       Assume quantifiers for undeclared variables");
     (void) fprintf(stderr, "%s\n", "       -s       Syntax check only");
     (void) fprintf(stderr, "%s\n", "       -t       Report types of global definitions");
     (void) fprintf(stderr, "%s\n", "       -v       Echo input as it is parsed");
     exit(2);
}

canonical_original_code:
static void usage()
{
     (void) fprintf(stderr, "%s\n", "Usage: fuzz [-aqstv] [-p file] file ...");
     (void) fprintf(stderr, "%s\n", "Flags: -a       Don't use type abbreviations");
     (void) fprintf(stderr, "%s\n", "       -d       Allow use before definition");
     (void) fprintf(stderr, "%s\n", "       -l       Lisp-style echoing of input");
     (void) fprintf(stderr, "%s\n", "       -p file  Use <file> in place of standard prelude");
     (void) fprintf(stderr, "%s\n", "       -q       Assume quantifiers for undeclared variables");
     (void) fprintf(stderr, "%s\n", "       -s       Syntax check only");
     (void) fprintf(stderr, "%s\n", "       -t       Report types of global definitions");
     (void) fprintf(stderr, "%s\n", "       -v       Echo input as it is parsed");
     exit(2);
}


main

decompiled_code:
// local variable allocation has failed, the output may be wrong!
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v3; // ebx
__int64 v4; // r12
char **v5; // rbp
__int64 v6; // rbx

::argv = (__int64)argv;
v3 = argc - 1;
for ( ::argc = argc - 1; v3 > 0; ::argc = v3 )
{
envp = (const char **)(::argv + 8);
::argv = (__int64)envp;
*(_QWORD *)&argc = *envp;
if ( **envp != 45 )
break;
do_flags(*(__int64 *)&argc, (__int64)argv);
v3 = ::argc - 1;
}
v4 = ::argv;
if ( dcode[21] )
{
argv = (const char **)"%s\n%s\n%s\n";
fprintf(stderr, "%s\n%s\n%s\n", fuzz_banner, fuzz_rcsid, fuzz_copyright);
*(_QWORD *)&argc = stderr;
fflush(stderr);
}
debugging = dcode[15];
init_sym(*(_QWORD *)&argc, argv, envp);
init_type();
init_dict();
open_prelude();
read_a_file();
if ( dflag )
{
check_file();
clear_temp(0LL);
}
debugging = 1;
if ( v3 )
{
if ( v3 > 0 )
{
v5 = (char **)v4;
v6 = v4 + 8LL * (unsigned int)(v3 - 1) + 8;
do
{
reopen_input(*v5);
yyrestart(yyin);
read_a_file();
++v5;
}
while ( v5 != (char **)v6 );
}
}
else
{
file_name = (__int64)"standard input";
yyrestart(stdin);
read_a_file();
}
if ( dflag )
{
check_file();
clear_temp(0LL);
}
if ( dcode[7] )
dump_hash();
return n_errors > 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v3; // ebx
__int64 v4; // r12
char **v5; // rbp
__int64 v6; // rbx

::argv = (__int64)argv;
v3 = argc - 1;
for ( ::argc = argc - 1; v3 > 0; ::argc = v3 )
{
envp = (const char **)(::argv + 8);
::argv = (__int64)envp;
*(_QWORD *)&argc = *envp;
if ( **envp != 45 )
break;
func2(*(__int64 *)&argc, (__int64)argv);
v3 = ::argc - 1;
}
v4 = ::argv;
if ( dcode[21] )
{
argv = (const char **)"%s\n%s\n%s\n";
fprintf(stderr, "%s\n%s\n%s\n", fuzz_banner, fuzz_rcsid, fuzz_copyright);
*(_QWORD *)&argc = stderr;
fflush(stderr);
}
debugging = dcode[15];
init_sym(*(_QWORD *)&argc, argv, envp);
init_type();
init_dict();
func4();
func6();
if ( dflag )
{
check_file();
clear_temp(0LL);
}
debugging = 1;
if ( v3 )
{
if ( v3 > 0 )
{
v5 = (char **)v4;
v6 = v4 + 8LL * (unsigned int)(v3 - 1) + 8;
do
{
func5(*v5);
yyrestart(yyin);
func6();
++v5;
}
while ( v5 != (char **)v6 );
}
}
else
{
file_name = (__int64)"standard input";
yyrestart(stdin);
func6();
}
if ( dflag )
{
check_file();
clear_temp(0LL);
}
if ( dcode[7] )
dump_hash();
return n_errors > 0;
}

original_code:
int main(int ac, char **av)
{
     int i, n_files;
     char **files;
     argc = ac; argv = av;
     while (--argc > 0 && (*++argv)[0] == '-')
          do_flags(*argv);
     files = argv;
     n_files = argc;
     if (dcode['v' - 'a']) {
   fprintf(stderr, "%s\n%s\n%s\n",
    fuzz_banner, fuzz_rcsid, fuzz_copyright);
   fflush(stderr);
     }
     debugging = dcode['p' - 'a'];
     init_sym();
     init_type();
     init_dict();
     open_prelude();
     read_a_file();
     if (dflag) {
   check_file();
   clear_temp((univ) ((void *)0));
     }
     debugging = 1;
     if (n_files == 0) {
   file_name = "standard input";
   yyrestart(stdin);
   read_a_file();
     }
     else {
   for (i = 0; i < n_files; i++) {
        reopen_input(files[i]);
        yyrestart(yyin);
        read_a_file();
   }
     }
     if (dflag) {
   check_file();
   clear_temp((univ) ((void *)0));
     }
     if (dcode['h' - 'a'])
   dump_hash();
     return (n_errors > 0 ? 1 : 0);
}

canonical_original_code:
int main(int ac, char **av)
{
     int i; int n_files;
     char **files;
     argc = ac; argv = av;
     while (--argc > 0 && (*++argv)[0] == '-')
          do_flags(*argv);
     files = argv;
     n_files = argc;
     if (dcode['v' - 'a']) {
   fprintf(stderr, "%s\n%s\n%s\n",
    fuzz_banner, fuzz_rcsid, fuzz_copyright);
   fflush(stderr);
     }
     debugging = dcode['p' - 'a'];
     init_sym();
     init_type();
     init_dict();
     open_prelude();
     read_a_file();
     if (dflag) {
   check_file();
   clear_temp((univ) ((void *)0));
     }
     debugging = 1;
     if (n_files == 0) {
   file_name = "standard input";
   yyrestart(stdin);
   read_a_file();
     }
     else {
   for (i = 0; i < n_files; i++) {
        reopen_input(files[i]);
        yyrestart(yyin);
        read_a_file();
   }
     }
     if (dflag) {
   check_file();
   clear_temp((univ) ((void *)0));
     }
     if (dcode['h' - 'a'])
   dump_hash();
     return (n_errors > 0 ? 1 : 0);
}

variable_types: ac int

variable_types:
av
char **

variable_types: i int

variable_types:
files
char **


decompiled_code:
void check_current_addr()
{
;
}

canonical_decompiled_code:
void func1()
{
;
}

original_code:
void check_current_addr(uassembler* uasm)
{
}

canonical_original_code:
void check_current_addr(struct uassembler *uasm)
{
}

variable_types: struct uassembler { struct bin_table { struct bin_table_collumn_description { char *name; int width; int active_high; int index; } *collumn_descriptions; struct bin_table_cell { unsigned int value; unsigned int is_known; } *cells; int collumns; int rows; int print_on_error; int exit_on_error; } table; char *next_addr_collumn_name; char *nextsel_collumn_name; int rom_addr_with; int opcode_width; int addr_fetch; int addr_free; int addr_reset; struct addresses4_t { int addresses[4]; int len; } current_addresses; int current_at_op_entry; } *

user_defined_types: struct uassembler { struct bin_table table; char *next_addr_collumn_name; char *nextsel_collumn_name; int rom_addr_with; int opcode_width; int addr_fetch; int addr_free; int addr_reset; struct addresses4_t current_addresses; int current_at_op_entry; }

user_defined_types: struct bin_table { struct bin_table_collumn_description *collumn_descriptions; struct bin_table_cell *cells; int collumns; int rows; int print_on_error; int exit_on_error; }


decompiled_code:
__int64 __fastcall set_field(__int64 a1, __int64 a2, unsigned int a3)
{
__int64 result; // rax
unsigned int v5; // er12
__int64 v6; // rbp

result = bin_table_collumn_by_name();
if ( *(int *)(a1 + 84) > 0 )
{
v5 = result;
v6 = 0LL;
do
result = bin_table_set_cell_value(a1, v5, *(unsigned int *)(a1 + 4 * v6++ + 68), a3);
while ( *(_DWORD *)(a1 + 84) > (int)v6 );
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, __int64 a2, unsigned int a3)
{
__int64 result; // rax
unsigned int v5; // er12
__int64 v6; // rbp

result = bin_table_collumn_by_name();
if ( *(int *)(a1 + 84) > 0 )
{
v5 = result;
v6 = 0LL;
do
result = bin_table_set_cell_value(a1, v5, *(unsigned int *)(a1 + 4 * v6++ + 68), a3);
while ( *(_DWORD *)(a1 + 84) > (int)v6 );
}
return result;
}

original_code:
void set_field(uassembler* uasm, const char* field_name, int value)
{
 check_current_addr(uasm);
 int field_index = bin_table_collumn_by_name(&(uasm->table), field_name);
 int n = 0;
 for(n = 0; n < uasm->current_addresses.len; ++n)
 {
  bin_table_set_cell_value(&(uasm->table), field_index,
    uasm->current_addresses.addresses[n], value);
 }
}

canonical_original_code:
void set_field(struct uassembler *uasm, char *field_name, int value)
{
 check_current_addr(uasm);
 int field_index = bin_table_collumn_by_name(&(uasm->table), field_name);
 int n = 0;
 for(n = 0; n < uasm->current_addresses.len; ++n)
 {
  bin_table_set_cell_value(&(uasm->table), field_index,
    uasm->current_addresses.addresses[n], value);
 }
}

variable_types: value int

variable_types: n int

user_defined_types: struct addresses4_t { int addresses[4]; int len; }

user_defined_types: struct bin_table_collumn_description { char *name; int width; int active_high; int index; }

user_defined_types: struct bin_table_cell { unsigned int value; unsigned int is_known; }


decompiled_code:
__int64 __fastcall assert_signal(_QWORD *a1, __int64 a2)
{
__int64 v2; // rax

v2 = *a1 + 24LL * (int)bin_table_collumn_by_name();
if ( *(_DWORD *)(v2 + 8) != 1 )
{
fwrite("error: want to assert signal with width not equal to 1\n", 1uLL, 0x37uLL, stderr);
print_state((__int64)a1, stderr);
exit(1);
}
return set_field((__int64)a1, a2, *(_DWORD *)(v2 + 12) != 0);
}

canonical_decompiled_code:
__int64 __fastcall func3(_QWORD *a1, __int64 a2)
{
__int64 v2; // rax

v2 = *a1 + 24LL * (int)bin_table_collumn_by_name();
if ( *(_DWORD *)(v2 + 8) != 1 )
{
fwrite("error: want to assert signal with width not equal to 1\n", 1uLL, 0x37uLL, stderr);
func0((__int64)a1, stderr);
exit(1);
}
return func2((__int64)a1, a2, *(_DWORD *)(v2 + 12) != 0);
}

original_code:
void assert_signal(uassembler* uasm, const char* field_name)
{
 check_current_addr(uasm);
 int field_index = bin_table_collumn_by_name(&(uasm->table), field_name);
 if(uasm->table.collumn_descriptions[field_index].width != 1)
 {
  fprintf(stderr, "error: want to assert signal with width not equal to 1\n");
  print_state(uasm, stderr);
  exit(1);
 }
 int value = uasm->table.collumn_descriptions[field_index].active_high ? 1 : 0;
 set_field(uasm, field_name, value);
}

canonical_original_code:
void assert_signal(struct uassembler *uasm, char *field_name)
{
 check_current_addr(uasm);
 int field_index = bin_table_collumn_by_name(&(uasm->table), field_name);
 if(uasm->table.collumn_descriptions[field_index].width != 1)
 {
  fprintf(stderr, "error: want to assert signal with width not equal to 1\n");
  print_state(uasm, stderr);
  exit(1);
 }
 int value = uasm->table.collumn_descriptions[field_index].active_high ? 1 : 0;
 set_field(uasm, field_name, value);
}


original_code:
void set_default(uassembler* uasm)
{
 check_current_addr(uasm);
 int n;
 for(n = 0; n < uasm->table.collumns; n++)
 {
  if(uasm->table.collumn_descriptions[n].active_high)
  {
   set_field(uasm, uasm->table.collumn_descriptions[n].name ,0);
  }
  else
  {
   set_field(uasm, uasm->table.collumn_descriptions[n].name , (1 << uasm->table.collumn_descriptions[n].width) - 1);
  }
 }
}

canonical_original_code:
void set_default(struct uassembler *uasm)
{
 check_current_addr(uasm);
 int n;
 for(n = 0; n < uasm->table.collumns; n++)
 {
  if(uasm->table.collumn_descriptions[n].active_high)
  {
   set_field(uasm, uasm->table.collumn_descriptions[n].name ,0);
  }
  else
  {
   set_field(uasm, uasm->table.collumn_descriptions[n].name , (1 << uasm->table.collumn_descriptions[n].width) - 1);
  }
 }
}


decompiled_code:
__int64 __fastcall set_next_hardcoded(__int64 a1, unsigned int a2)
{
set_field(a1, *(_QWORD *)(a1 + 40), 0);
return set_field(a1, *(_QWORD *)(a1 + 32), a2);
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1, unsigned int a2)
{
func2(a1, *(_QWORD *)(a1 + 40), 0);
return func2(a1, *(_QWORD *)(a1 + 32), a2);
}

original_code:
void set_next_hardcoded(uassembler* uasm, int addr)
{
 set_field(uasm, uasm->nextsel_collumn_name, 0);
 set_field(uasm, uasm->next_addr_collumn_name, addr);
}

canonical_original_code:
void set_next_hardcoded(struct uassembler *uasm, int addr)
{
 set_field(uasm, uasm->nextsel_collumn_name, 0);
 set_field(uasm, uasm->next_addr_collumn_name, addr);
}

variable_types: addr int


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

if ( a2 == 2 )
return set_field(a1, *(_QWORD *)(a1 + 40), 1u);
if ( a2 > 2 )
{
if ( a2 != 3 )
{
fwrite("error: unkown next_sel\n", 1uLL, 0x17uLL, stderr);
print_state(a1, stderr);
exit(1);
}
if ( *(int *)(a1 + 84) > 0 )
result = set_next_hardcoded(a1, *(_DWORD *)(a1 + 68));
}
else if ( a2 )
{
result = set_next_hardcoded(a1, *(_DWORD *)(a1 + 60));
}
else
{
result = set_next_hardcoded(a1, *(_DWORD *)(a1 + 56));
}
return result;
}

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

if ( a2 == 2 )
return func2(a1, *(_QWORD *)(a1 + 40), 1u);
if ( a2 > 2 )
{
if ( a2 != 3 )
{
fwrite("error: unkown next_sel\n", 1uLL, 0x17uLL, stderr);
func0(a1, stderr);
exit(1);
}
if ( *(int *)(a1 + 84) > 0 )
result = func5(a1, *(_DWORD *)(a1 + 68));
}
else if ( a2 )
{
result = func5(a1, *(_DWORD *)(a1 + 60));
}
else
{
result = func5(a1, *(_DWORD *)(a1 + 56));
}
return result;
}

original_code:
void set_next(uassembler* uasm, next_sel nxt)
{
 check_current_addr(uasm);
 switch(nxt)
 {
  case next_sel_fetch:
   set_next_hardcoded(uasm, uasm->addr_fetch);
  break;
  case next_sel_next_free:
   set_next_hardcoded(uasm, uasm->addr_free);
  break;
  case next_sel_op_entry:
   set_field(uasm, uasm->nextsel_collumn_name, 1);
  break;
  case next_sel_current: {
   if(uasm->current_addresses.len > 0) {
    set_next_hardcoded(uasm, uasm->current_addresses.addresses[0]);
   }
  }
  break;
  default:
   fprintf(stderr, "error: unkown next_sel\n");
   print_state(uasm, stderr);
   exit(1);
  break;
 }
}

canonical_original_code:
void set_next(struct uassembler *uasm, enum next_sel nxt)
{
 check_current_addr(uasm);
 switch(nxt)
 {
  case next_sel_fetch:
   set_next_hardcoded(uasm, uasm->addr_fetch);
  break;
  case next_sel_next_free:
   set_next_hardcoded(uasm, uasm->addr_free);
  break;
  case next_sel_op_entry:
   set_field(uasm, uasm->nextsel_collumn_name, 1);
  break;
  case next_sel_current: {
   if(uasm->current_addresses.len > 0) {
    set_next_hardcoded(uasm, uasm->current_addresses.addresses[0]);
   }
  }
  break;
  default:
   fprintf(stderr, "error: unkown next_sel\n");
   print_state(uasm, stderr);
   exit(1);
  break;
 }
}

variable_types: enum next_sel { next_sel_fetch=0, next_sel_next_free=1, next_sel_op_entry=2, next_sel_current=3 }


decompiled_code:
void __fastcall goto_address(__int64 a1, int a2)
{
*(_DWORD *)(a1 + 84) = 1;
*(_DWORD *)(a1 + 68) = a2;
set_default(a1);
}

original_code:
void goto_address(uassembler* uasm, int address)
{
 uasm->current_addresses.len = 1;
 uasm->current_addresses.addresses[0] = address;
 set_default(uasm);
}

canonical_original_code:
void goto_address(struct uassembler *uasm, int address)
{
 uasm->current_addresses.len = 1;
 uasm->current_addresses.addresses[0] = address;
 set_default(uasm);
}

variable_types: address int


decompiled_code:
void __fastcall goto_reset(__int64 a1)
{
*(_DWORD *)(a1 + 88) = 0;
goto_address(a1, *(_DWORD *)(a1 + 64));
}

original_code:
void goto_reset(uassembler* uasm)
{
 uasm->current_at_op_entry = 0;
 goto_address(uasm, uasm->addr_reset);
}

canonical_original_code:
void goto_reset(struct uassembler *uasm)
{
 uasm->current_at_op_entry = 0;
 goto_address(uasm, uasm->addr_reset);
}


decompiled_code:
void __fastcall goto_fetch(__int64 a1)
{
*(_DWORD *)(a1 + 88) = 0;
goto_address(a1, *(_DWORD *)(a1 + 56));
}

original_code:
void goto_fetch(uassembler* uasm)
{
 uasm->current_at_op_entry = 0;
 goto_address(uasm, uasm->addr_fetch);
}

canonical_original_code:
void goto_fetch(struct uassembler *uasm)
{
 uasm->current_at_op_entry = 0;
 goto_address(uasm, uasm->addr_fetch);
}


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

*(_DWORD *)(a1 + 88) = 0;
goto_address(a1, *(_DWORD *)(a1 + 60));
result = *(unsigned int *)(a1 + 60);
*(_DWORD *)(a1 + 60) = result + 1;
return result;
}

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

*(_DWORD *)(a1 + 88) = 0;
func7(a1, *(_DWORD *)(a1 + 60));
result = *(unsigned int *)(a1 + 60);
*(_DWORD *)(a1 + 60) = result + 1;
return result;
}

original_code:
int goto_next_free(uassembler* uasm)
{
 uasm->current_at_op_entry = 0;
 goto_address(uasm, uasm->addr_free);
 int result = uasm->addr_free;
 uasm->addr_free++;
 return result;
}

canonical_original_code:
int goto_next_free(struct uassembler *uasm)
{
 uasm->current_at_op_entry = 0;
 goto_address(uasm, uasm->addr_free);
 int result = uasm->addr_free;
 uasm->addr_free++;
 return result;
}

variable_types: result int


decompiled_code:
void __fastcall goto_op_entry(__int64 a1, int a2, char a3)
{
__m128i v3; // [rsp+0h] [rbp-28h] BYREF
int v4; // [rsp+10h] [rbp-18h]

if ( 1 << *(_DWORD *)(a1 + 52) <= a2 )
{
fprintf(stderr, "error: opcode %d does not fit in opcode field\n", (unsigned int)a2);
print_state(a1, stderr);
exit(1);
}
get_jmptable_addresses(&v3, a1, a2, a3, 0);
*(__m128i *)(a1 + 68) = _mm_loadu_si128(&v3);
*(_DWORD *)(a1 + 84) = v4;
set_default(a1);
}

canonical_decompiled_code:
void __fastcall func11(__int64 a1, int a2, char a3)
{
__m128i v3; // [rsp+0h] [rbp-28h] BYREF
int v4; // [rsp+10h] [rbp-18h]

if ( 1 << *(_DWORD *)(a1 + 52) <= a2 )
{
fprintf(stderr, "error: opcode %d does not fit in opcode field\n", (unsigned int)a2);
func0(a1, stderr);
exit(1);
}
get_jmptable_addresses(&v3, a1, a2, a3, 0);
*(__m128i *)(a1 + 68) = _mm_loadu_si128(&v3);
*(_DWORD *)(a1 + 84) = v4;
func4(a1);
}

original_code:
void goto_op_entry(uassembler* uasm, int opcode, int carry_zero_flags)
{
 if(opcode >= (1 << uasm->opcode_width))
 {
  fprintf(stderr, "error: opcode %d does not fit in opcode field\n", opcode);
  print_state(uasm, stderr);
  exit(1);
 }
 uasm->current_addresses = get_jmptable_addresses(uasm, opcode, carry_zero_flags, 0);
 set_default(uasm);
}

canonical_original_code:
void goto_op_entry(struct uassembler *uasm, int opcode, int carry_zero_flags)
{
 if(opcode >= (1 << uasm->opcode_width))
 {
  fprintf(stderr, "error: opcode %d does not fit in opcode field\n", opcode);
  print_state(uasm, stderr);
  exit(1);
 }
 uasm->current_addresses = get_jmptable_addresses(uasm, opcode, carry_zero_flags, 0);
 set_default(uasm);
}

variable_types: opcode int


decompiled_code:
void __fastcall goto_inspect_cpu_entry(__int64 a1, int a2, char a3)
{
__m128i v3; // [rsp+0h] [rbp-28h] BYREF
int v4; // [rsp+10h] [rbp-18h]

if ( 1 << *(_DWORD *)(a1 + 52) <= a2 )
{
fprintf(stderr, "error: opcode %d does not fit in opcode field\n", (unsigned int)a2);
print_state(a1, stderr);
exit(1);
}
get_jmptable_addresses(&v3, a1, a2, a3, 1);
*(__m128i *)(a1 + 68) = _mm_loadu_si128(&v3);
*(_DWORD *)(a1 + 84) = v4;
set_default(a1);
}

canonical_decompiled_code:
void __fastcall func12(__int64 a1, int a2, char a3)
{
__m128i v3; // [rsp+0h] [rbp-28h] BYREF
int v4; // [rsp+10h] [rbp-18h]

if ( 1 << *(_DWORD *)(a1 + 52) <= a2 )
{
fprintf(stderr, "error: opcode %d does not fit in opcode field\n", (unsigned int)a2);
func0(a1, stderr);
exit(1);
}
get_jmptable_addresses(&v3, a1, a2, a3, 1);
*(__m128i *)(a1 + 68) = _mm_loadu_si128(&v3);
*(_DWORD *)(a1 + 84) = v4;
func4(a1);
}

original_code:
void goto_inspect_cpu_entry(uassembler* uasm, int opcode, int carry_zero_flags)
{
 if(opcode >= (1 << uasm->opcode_width))
 {
  fprintf(stderr, "error: opcode %d does not fit in opcode field\n", opcode);
  print_state(uasm, stderr);
  exit(1);
 }
 uasm->current_addresses = get_jmptable_addresses(uasm, opcode, carry_zero_flags, 1);
 set_default(uasm);
}

canonical_original_code:
void goto_inspect_cpu_entry(struct uassembler *uasm, int opcode, int carry_zero_flags)
{
 if(opcode >= (1 << uasm->opcode_width))
 {
  fprintf(stderr, "error: opcode %d does not fit in opcode field\n", opcode);
  print_state(uasm, stderr);
  exit(1);
 }
 uasm->current_addresses = get_jmptable_addresses(uasm, opcode, carry_zero_flags, 1);
 set_default(uasm);
}


decompiled_code:
__int64 __fastcall uassembler_init(__int64 a1, __int64 a2, __int64 a3, int a4, __int64 a5, __int64 a6, int a7, unsigned int a8)
{
char v11; // cl
__int64 result; // rax

bin_table_new(a1, a2, a3, (unsigned int)(1 << a4), a8, 1LL, 1LL);
*(_QWORD *)(a1 + 32) = a5;
*(_QWORD *)(a1 + 40) = a6;
*(_DWORD *)(a1 + 52) = a7;
v11 = a7 + 3;
if ( a7 + 3 >= a4 )
{
fwrite("error: uassembler initialized with a too small address width", 1uLL, 0x3CuLL, stderr);
exit(1);
}
*(_DWORD *)(a1 + 48) = a4;
*(_DWORD *)(a1 + 56) = 1 << v11;
*(_DWORD *)(a1 + 84) = 0;
*(_DWORD *)(a1 + 64) = 0;
result = (unsigned int)((1 << v11) + 1);
*(_DWORD *)(a1 + 60) = result;
*(_DWORD *)(a1 + 88) = 0;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func13(__int64 a1, __int64 a2, __int64 a3, int a4, __int64 a5, __int64 a6, int a7, unsigned int a8)
{
char v11; // cl
__int64 result; // rax

bin_table_new(a1, a2, a3, (unsigned int)(1 << a4), a8, 1LL, 1LL);
*(_QWORD *)(a1 + 32) = a5;
*(_QWORD *)(a1 + 40) = a6;
*(_DWORD *)(a1 + 52) = a7;
v11 = a7 + 3;
if ( a7 + 3 >= a4 )
{
fwrite("error: uassembler initialized with a too small address width", 1uLL, 0x3CuLL, stderr);
exit(1);
}
*(_DWORD *)(a1 + 48) = a4;
*(_DWORD *)(a1 + 56) = 1 << v11;
*(_DWORD *)(a1 + 84) = 0;
*(_DWORD *)(a1 + 64) = 0;
result = (unsigned int)((1 << v11) + 1);
*(_DWORD *)(a1 + 60) = result;
*(_DWORD *)(a1 + 88) = 0;
return result;
}

original_code:
void uassembler_init(uassembler* uasm, bin_table_collumn_description* field_descriptions, int number_of_fields,
  int rom_addr_with, char* next_addr_collumn_name, char* nextsel_addr_collumn_name,
  int opcode_width, int urom_width)
{
 bin_table_new(&(uasm->table), field_descriptions, number_of_fields, 1 << rom_addr_with, urom_width, 1, 1);
 uasm->next_addr_collumn_name = next_addr_collumn_name;
 uasm->nextsel_collumn_name = nextsel_addr_collumn_name;
 uasm->opcode_width = opcode_width;
 if(rom_addr_with <= opcode_width + 3)
 {
  fprintf(stderr, "error: uassembler initialized with a too small address width");
  exit(1);
 }
 uasm->rom_addr_with = rom_addr_with;
 uasm->addr_fetch = 1 << (opcode_width + 3);
 uasm->current_addresses.len = 0;
 uasm->addr_reset = 0;
 uasm->addr_free = uasm->addr_fetch + 1;
 uasm->current_at_op_entry = 0;
}

canonical_original_code:
void uassembler_init(struct uassembler *uasm, struct bin_table_collumn_description *field_descriptions, int number_of_fields, int rom_addr_with, char *next_addr_collumn_name, char *nextsel_addr_collumn_name, int opcode_width, int urom_width)
{
 bin_table_new(&(uasm->table), field_descriptions, number_of_fields, 1 << rom_addr_with, urom_width, 1, 1);
 uasm->next_addr_collumn_name = next_addr_collumn_name;
 uasm->nextsel_collumn_name = nextsel_addr_collumn_name;
 uasm->opcode_width = opcode_width;
 if(rom_addr_with <= opcode_width + 3)
 {
  fprintf(stderr, "error: uassembler initialized with a too small address width");
  exit(1);
 }
 uasm->rom_addr_with = rom_addr_with;
 uasm->addr_fetch = 1 << (opcode_width + 3);
 uasm->current_addresses.len = 0;
 uasm->addr_reset = 0;
 uasm->addr_free = uasm->addr_fetch + 1;
 uasm->current_at_op_entry = 0;
}


decompiled_code:
__int64 __fastcall print_verilog(__int64 a1, unsigned int a2)
{
return bin_table_print_binverilog(a1, stdout, a2);
}

canonical_decompiled_code:
__int64 __fastcall func14(__int64 a1, unsigned int a2)
{
return bin_table_print_binverilog(a1, stdout, a2);
}

original_code:
void print_verilog(uassembler* uasm, int comments)
{
 bin_table_print_binverilog(&uasm->table, stdout, comments);
}

canonical_original_code:
void print_verilog(struct uassembler *uasm, int comments)
{
 bin_table_print_binverilog(&uasm->table, stdout, comments);
}

variable_types: comments int


decompiled_code:
int __fastcall print_str(const char *a1)
{
return fputs(a1, _bss_start);
}

canonical_decompiled_code:
int __fastcall func7(const char *a1)
{
return fputs(a1, _bss_start);
}

original_code:
void print_str(const char* str)
{
 fputs(str, stdout);
}

canonical_original_code:
void print_str(char *str)
{
 fputs(str, stdout);
}

variable_types:
str
char *


decompiled_code:
int __fastcall print_char(unsigned __int16 a1)
{
return putchar(a1);
}

canonical_decompiled_code:
int __fastcall func8(unsigned __int16 a1)
{
return putchar(a1);
}

original_code:
void print_char(uint16_t ch)
{
 putchar(ch);
}

canonical_original_code:
void print_char(unsigned short ch)
{
 putchar(ch);
}

variable_types:
ch
unsigned short


decompiled_code:
int __fastcall print_hex8(unsigned __int16 a1)
{
return printf("%02X", a1);
}

canonical_decompiled_code:
int __fastcall func9(unsigned __int16 a1)
{
return printf("%02X", a1);
}

original_code:
void print_hex8(uint16_t x)
{
 printf("%02X", x);
}

canonical_original_code:
void print_hex8(unsigned short x)
{
 printf("%02X", x);
}

variable_types:
x
unsigned short


decompiled_code:
int __fastcall print_hex16(unsigned __int16 a1)
{
return printf("%04X", a1);
}

canonical_decompiled_code:
int __fastcall func10(unsigned __int16 a1)
{
return printf("%04X", a1);
}

original_code:
void print_hex16(uint16_t x)
{
 printf("%04X", x);
}

canonical_original_code:
void print_hex16(unsigned short x)
{
 printf("%04X", x);
}


decompiled_code:
__int64 __fastcall bin_table_new(__int64 a1, const void *a2, int a3, int a4, int a5, int a6, int a7)
{
__int64 result; // rax
__int64 v13; // r15
size_t v14; // r15
void *v15; // rax
int *v16; // rcx
int v17; // esi
int v18; // edi
int v19; // edx
int v20; // eax
__int64 n; // [rsp+10h] [rbp-48h]
int *v22; // [rsp+18h] [rbp-40h]

*(_DWORD *)(a1 + 24) = a6;
*(_DWORD *)(a1 + 28) = a7;
if ( a4 <= 0 || a3 <= 0 )
{
if ( a6 )
fwrite("ERROR: bin_table: rows or collumns is less than 1\n", 1uLL, 0x32uLL, stderr);
result = *(unsigned int *)(a1 + 28);
if ( (_DWORD)result )
exit(1);
return result;
}
*(_DWORD *)(a1 + 20) = a4;
*(_DWORD *)(a1 + 16) = a3;
v13 = a3;
n = 24LL * a3;
v22 = (int *)malloc(n);
*(_QWORD *)a1 = v22;
memcpy(v22, a2, n);
v14 = 8 * a4 * v13;
v15 = malloc(v14);
*(_QWORD *)(a1 + 8) = v15;
if ( v15 )
{
if ( a5 >= 0 )
{
v16 = v22 + 2;
v17 = 0;
v18 = -1;
v19 = 0;
while ( 1 )
{
v20 = *v16;
if ( *v16 == -1 )
{
if ( v18 != -1 )
{
if ( a6 )
fwrite("ERROR: bin_table: table can only have one padding collumn\n", 1uLL, 0x3AuLL, stderr);
result = *(unsigned int *)(a1 + 28);
if ( (_DWORD)result )
exit(1);
return result;
}
if ( !a5 )
{
if ( a6 )
fwrite(
"ERROR: bin_table: table has padding collumn but no max total width is specified\n",
1uLL,
0x50uLL,
stderr);
result = *(unsigned int *)(a1 + 28);
if ( (_DWORD)result )
exit(1);
return result;
}
v18 = v19;
}
else
{
if ( v20 <= 0 )
{
if ( a6 )
fwrite("ERROR: bin_table: width of collumn can only be -1 of greater than zero\n", 1uLL, 0x47uLL, stderr);
result = *(unsigned int *)(a1 + 28);
if ( (_DWORD)result )
exit(1);
return result;
}
v17 += v20;
}
if ( v17 > a5 )
{
if ( a6 )
fwrite(
"ERROR: bin_table: total width of collumns is greater than the maximum total width\n",
1uLL,
0x52uLL,
stderr);
result = *(unsigned int *)(a1 + 28);
if ( (_DWORD)result )
exit(1);
return result;
}
++v19;
v16 += 6;
if ( a3 <= v19 )
{
if ( v18 != -1 )
v22[6 * v18 + 2] = a5 - v17;
initialize_table(a1);
return 1LL;
}
}
}
if ( a6 )
fwrite(
"ERROR: bin_table: max_total_width can not be less than zero. zero means no maximum.\n",
1uLL,
0x54uLL,
stderr);
result = *(unsigned int *)(a1 + 28);
if ( (_DWORD)result )
exit(1);
}
else
{
if ( a6 )
fprintf(stderr, "ERROR: bin_table: could not allocate %zu bytes for table\n", v14);
result = *(unsigned int *)(a1 + 28);
if ( (_DWORD)result )
exit(1);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, const void *a2, int a3, int a4, int a5, int a6, int a7)
{
__int64 result; // rax
__int64 v13; // r15
size_t v14; // r15
void *v15; // rax
int *v16; // rcx
int v17; // esi
int v18; // edi
int v19; // edx
int v20; // eax
__int64 n; // [rsp+10h] [rbp-48h]
int *v22; // [rsp+18h] [rbp-40h]

*(_DWORD *)(a1 + 24) = a6;
*(_DWORD *)(a1 + 28) = a7;
if ( a4 <= 0 || a3 <= 0 )
{
if ( a6 )
fwrite("ERROR: bin_table: rows or collumns is less than 1\n", 1uLL, 0x32uLL, stderr);
result = *(unsigned int *)(a1 + 28);
if ( (_DWORD)result )
exit(1);
return result;
}
*(_DWORD *)(a1 + 20) = a4;
*(_DWORD *)(a1 + 16) = a3;
v13 = a3;
n = 24LL * a3;
v22 = (int *)malloc(n);
*(_QWORD *)a1 = v22;
memcpy(v22, a2, n);
v14 = 8 * a4 * v13;
v15 = malloc(v14);
*(_QWORD *)(a1 + 8) = v15;
if ( v15 )
{
if ( a5 >= 0 )
{
v16 = v22 + 2;
v17 = 0;
v18 = -1;
v19 = 0;
while ( 1 )
{
v20 = *v16;
if ( *v16 == -1 )
{
if ( v18 != -1 )
{
if ( a6 )
fwrite("ERROR: bin_table: table can only have one padding collumn\n", 1uLL, 0x3AuLL, stderr);
result = *(unsigned int *)(a1 + 28);
if ( (_DWORD)result )
exit(1);
return result;
}
if ( !a5 )
{
if ( a6 )
fwrite(
"ERROR: bin_table: table has padding collumn but no max total width is specified\n",
1uLL,
0x50uLL,
stderr);
result = *(unsigned int *)(a1 + 28);
if ( (_DWORD)result )
exit(1);
return result;
}
v18 = v19;
}
else
{
if ( v20 <= 0 )
{
if ( a6 )
fwrite("ERROR: bin_table: width of collumn can only be -1 of greater than zero\n", 1uLL, 0x47uLL, stderr);
result = *(unsigned int *)(a1 + 28);
if ( (_DWORD)result )
exit(1);
return result;
}
v17 += v20;
}
if ( v17 > a5 )
{
if ( a6 )
fwrite(
"ERROR: bin_table: total width of collumns is greater than the maximum total width\n",
1uLL,
0x52uLL,
stderr);
result = *(unsigned int *)(a1 + 28);
if ( (_DWORD)result )
exit(1);
return result;
}
++v19;
v16 += 6;
if ( a3 <= v19 )
{
if ( v18 != -1 )
v22[6 * v18 + 2] = a5 - v17;
func0(a1);
return 1LL;
}
}
}
if ( a6 )
fwrite(
"ERROR: bin_table: max_total_width can not be less than zero. zero means no maximum.\n",
1uLL,
0x54uLL,
stderr);
result = *(unsigned int *)(a1 + 28);
if ( (_DWORD)result )
exit(1);
}
else
{
if ( a6 )
fprintf(stderr, "ERROR: bin_table: could not allocate %zu bytes for table\n", v14);
result = *(unsigned int *)(a1 + 28);
if ( (_DWORD)result )
exit(1);
}
return result;
}

original_code:
int bin_table_new(bin_table* table, bin_table_collumn_description* collumn_descriptions, int collumns, int rows, int max_total_width, int print_on_error, int exit_on_error)
{
 table->print_on_error = print_on_error;
 table->exit_on_error = exit_on_error;
 if(rows < 1 || collumns < 1)
 {
  do { if(table->print_on_error) { fprintf(stderr, "ERROR: bin_table: ""rows or collumns is less than 1""\n"); } if(table->exit_on_error) { exit(1); } } while(0);
  return 0;
 }
 table->rows = rows;
 table->collumns = collumns;
 size_t col_descrs_size = collumns*sizeof(bin_table_collumn_description);
 table->collumn_descriptions = malloc(col_descrs_size);
 memcpy(table->collumn_descriptions, collumn_descriptions, col_descrs_size);
 size_t cells_size = sizeof(bin_table_cell)*collumns*rows;
 table->cells = malloc(cells_size);
 if(table->cells == ((void *)0))
 {
  do { if(table->print_on_error) { fprintf(stderr, "ERROR: bin_table: ""could not allocate %zu bytes for table""\n", cells_size); } if(table->exit_on_error) { exit(1); } } while(0); return 0;
 }
 if(max_total_width < 0)
 {
  do { if(table->print_on_error) { fprintf(stderr, "ERROR: bin_table: ""max_total_width can not be less than zero. zero means no maximum.""\n"); } if(table->exit_on_error) { exit(1); } } while(0); return 0;
 }
 int n;
 int padding_collumn = -1;
 int total_width = 0;
 for(n = 0; n < collumns; ++n)
 {
  if(table->collumn_descriptions[n].width == -1)
  {
   if(padding_collumn == -1)
   {
    if(max_total_width != 0)
    {
     padding_collumn = n;
    }
    else
    {
     do { if(table->print_on_error) { fprintf(stderr, "ERROR: bin_table: ""table has padding collumn but no max total width is specified""\n"); } if(table->exit_on_error) { exit(1); } } while(0); return 0;
    }
   }
   else
   {
    do { if(table->print_on_error) { fprintf(stderr, "ERROR: bin_table: ""table can only have one padding collumn""\n"); } if(table->exit_on_error) { exit(1); } } while(0); return 0;
   }
  }
  else if(table->collumn_descriptions[n].width <= 0)
  {
   do { if(table->print_on_error) { fprintf(stderr, "ERROR: bin_table: ""width of collumn can only be -1 of greater than zero""\n"); } if(table->exit_on_error) { exit(1); } } while(0); return 0;
  }
  else
  {
   total_width += table->collumn_descriptions[n].width;
  }
  if(total_width > max_total_width)
  {
   do { if(table->print_on_error) { fprintf(stderr, "ERROR: bin_table: ""total width of collumns is greater than the maximum total width""\n"); } if(table->exit_on_error) { exit(1); } } while(0); return 0;
  }
 }
 if(padding_collumn != -1)
 {
  table->collumn_descriptions[padding_collumn].width = max_total_width - total_width;
 }
 initialize_table(table);
 return 1;
}

canonical_original_code:
int bin_table_new(struct bin_table *table, struct bin_table_collumn_description *collumn_descriptions, int collumns, int rows, int max_total_width, int print_on_error, int exit_on_error)
{
 table->print_on_error = print_on_error;
 table->exit_on_error = exit_on_error;
 if(rows < 1 || collumns < 1)
 {
  do { if(table->print_on_error) { fprintf(stderr, "ERROR: bin_table: ""rows or collumns is less than 1""\n"); } if(table->exit_on_error) { exit(1); } } while(0);
  return 0;
 }
 table->rows = rows;
 table->collumns = collumns;
 unsigned long col_descrs_size = collumns*sizeof(bin_table_collumn_description);
 table->collumn_descriptions = malloc(col_descrs_size);
 memcpy(table->collumn_descriptions, collumn_descriptions, col_descrs_size);
 unsigned long cells_size = sizeof(bin_table_cell)*collumns*rows;
 table->cells = malloc(cells_size);
 if(table->cells == ((void *)0))
 {
  do { if(table->print_on_error) { fprintf(stderr, "ERROR: bin_table: ""could not allocate %zu bytes for table""\n", cells_size); } if(table->exit_on_error) { exit(1); } } while(0); return 0;
 }
 if(max_total_width < 0)
 {
  do { if(table->print_on_error) { fprintf(stderr, "ERROR: bin_table: ""max_total_width can not be less than zero. zero means no maximum.""\n"); } if(table->exit_on_error) { exit(1); } } while(0); return 0;
 }
 int n;
 int padding_collumn = -1;
 int total_width = 0;
 for(n = 0; n < collumns; ++n)
 {
  if(table->collumn_descriptions[n].width == -1)
  {
   if(padding_collumn == -1)
   {
    if(max_total_width != 0)
    {
     padding_collumn = n;
    }
    else
    {
     do { if(table->print_on_error) { fprintf(stderr, "ERROR: bin_table: ""table has padding collumn but no max total width is specified""\n"); } if(table->exit_on_error) { exit(1); } } while(0); return 0;
    }
   }
   else
   {
    do { if(table->print_on_error) { fprintf(stderr, "ERROR: bin_table: ""table can only have one padding collumn""\n"); } if(table->exit_on_error) { exit(1); } } while(0); return 0;
   }
  }
  else if(table->collumn_descriptions[n].width <= 0)
  {
   do { if(table->print_on_error) { fprintf(stderr, "ERROR: bin_table: ""width of collumn can only be -1 of greater than zero""\n"); } if(table->exit_on_error) { exit(1); } } while(0); return 0;
  }
  else
  {
   total_width += table->collumn_descriptions[n].width;
  }
  if(total_width > max_total_width)
  {
   do { if(table->print_on_error) { fprintf(stderr, "ERROR: bin_table: ""total width of collumns is greater than the maximum total width""\n"); } if(table->exit_on_error) { exit(1); } } while(0); return 0;
  }
 }
 if(padding_collumn != -1)
 {
  table->collumn_descriptions[padding_collumn].width = max_total_width - total_width;
 }
 initialize_table(table);
 return 1;
}

variable_types: struct bin_table { struct bin_table_collumn_description { char *name; int width; int active_high; int index; } *collumn_descriptions; struct bin_table_cell { unsigned int value; unsigned int is_known; } *cells; int collumns; int rows; int print_on_error; int exit_on_error; } *

variable_types: collumns int

variable_types: rows int


decompiled_code:
void __fastcall bin_table_free(void **a1)
{
free(a1[1]);
free(*a1);
}

canonical_decompiled_code:
void __fastcall func2(void **a1)
{
free(a1[1]);
free(*a1);
}

original_code:
void bin_table_free(bin_table* table)
{
 free(table->cells);
 free(table->collumn_descriptions);
}

canonical_original_code:
void bin_table_free(struct bin_table *table)
{
 free(table->cells);
 free(table->collumn_descriptions);
}


decompiled_code:
__int64 __fastcall bin_table_set_cell_value(__int64 a1, int a2, int a3, int a4)
{
__int64 result; // rax
int v7; // edi
__int64 v8; // r10
unsigned int v9; // ecx
int *v10; // rdx

if ( *(_DWORD *)(a1 + 20) > a3 )
{
v7 = *(_DWORD *)(a1 + 16);
if ( v7 > a2 )
{
v8 = *(_QWORD *)a1 + 24LL * a2;
v9 = *(_DWORD *)(v8 + 8);
if ( 1 << v9 > a4 )
{
v10 = (int *)(*(_QWORD *)(a1 + 8) + 8LL * (v7 * a3 + a2));
*v10 = a4;
v10[1] = 1;
result = 1LL;
}
else
{
if ( *(_DWORD *)(a1 + 24) )
fprintf(
stderr,
"ERROR: bin_table: value %d does not fit in collumn %s with width %d\n",
(unsigned int)a4,
*(const char **)v8,
v9);
result = *(unsigned int *)(a1 + 28);
if ( (_DWORD)result )
exit(1);
}
}
else
{
if ( *(_DWORD *)(a1 + 24) )
fwrite("ERROR: bin_table: collumn_index > number of collumns in table\n", 1uLL, 0x3EuLL, stderr);
result = *(unsigned int *)(a1 + 28);
if ( (_DWORD)result )
exit(1);
}
}
else
{
if ( *(_DWORD *)(a1 + 24) )
fwrite("ERROR: bin_table: row > number of rows in table\n", 1uLL, 0x30uLL, stderr);
result = *(unsigned int *)(a1 + 28);
if ( (_DWORD)result )
exit(1);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, int a2, int a3, int a4)
{
__int64 result; // rax
int v7; // edi
__int64 v8; // r10
unsigned int v9; // ecx
int *v10; // rdx

if ( *(_DWORD *)(a1 + 20) > a3 )
{
v7 = *(_DWORD *)(a1 + 16);
if ( v7 > a2 )
{
v8 = *(_QWORD *)a1 + 24LL * a2;
v9 = *(_DWORD *)(v8 + 8);
if ( 1 << v9 > a4 )
{
v10 = (int *)(*(_QWORD *)(a1 + 8) + 8LL * (v7 * a3 + a2));
*v10 = a4;
v10[1] = 1;
result = 1LL;
}
else
{
if ( *(_DWORD *)(a1 + 24) )
fprintf(
stderr,
"ERROR: bin_table: value %d does not fit in collumn %s with width %d\n",
(unsigned int)a4,
*(const char **)v8,
v9);
result = *(unsigned int *)(a1 + 28);
if ( (_DWORD)result )
exit(1);
}
}
else
{
if ( *(_DWORD *)(a1 + 24) )
fwrite("ERROR: bin_table: collumn_index > number of collumns in table\n", 1uLL, 0x3EuLL, stderr);
result = *(unsigned int *)(a1 + 28);
if ( (_DWORD)result )
exit(1);
}
}
else
{
if ( *(_DWORD *)(a1 + 24) )
fwrite("ERROR: bin_table: row > number of rows in table\n", 1uLL, 0x30uLL, stderr);
result = *(unsigned int *)(a1 + 28);
if ( (_DWORD)result )
exit(1);
}
return result;
}

original_code:
int bin_table_set_cell_value(bin_table* table, int collumn_index, int row, int value)
{
 if(row >= table->rows)
 {
  do { if(table->print_on_error) { fprintf(stderr, "ERROR: bin_table: ""row > number of rows in table""\n"); } if(table->exit_on_error) { exit(1); } } while(0); return 0;
 }
 if(collumn_index >= table->collumns)
 {
  do { if(table->print_on_error) { fprintf(stderr, "ERROR: bin_table: ""collumn_index > number of collumns in table""\n"); } if(table->exit_on_error) { exit(1); } } while(0); return 0;
 }
 if(value >= (1 << table->collumn_descriptions[collumn_index].width))
 {
  do { if(table->print_on_error) { fprintf(stderr, "ERROR: bin_table: ""value %d does not fit in collumn %s with width %d""\n", value, table->collumn_descriptions[collumn_index].name, table->collumn_descriptions[collumn_index].width); } if(table->exit_on_error) { exit(1); } } while(0);
  return 0;
 }
 table->cells[row*table->collumns + collumn_index] = (bin_table_cell){.value = value, .is_known = 1};
 return 1;
}

canonical_original_code:
int bin_table_set_cell_value(struct bin_table *table, int collumn_index, int row, int value)
{
 if(row >= table->rows)
 {
  do { if(table->print_on_error) { fprintf(stderr, "ERROR: bin_table: ""row > number of rows in table""\n"); } if(table->exit_on_error) { exit(1); } } while(0); return 0;
 }
 if(collumn_index >= table->collumns)
 {
  do { if(table->print_on_error) { fprintf(stderr, "ERROR: bin_table: ""collumn_index > number of collumns in table""\n"); } if(table->exit_on_error) { exit(1); } } while(0); return 0;
 }
 if(value >= (1 << table->collumn_descriptions[collumn_index].width))
 {
  do { if(table->print_on_error) { fprintf(stderr, "ERROR: bin_table: ""value %d does not fit in collumn %s with width %d""\n", value, table->collumn_descriptions[collumn_index].name, table->collumn_descriptions[collumn_index].width); } if(table->exit_on_error) { exit(1); } } while(0);
  return 0;
 }
 table->cells[row*table->collumns + collumn_index] = (struct bin_table_cell){.value = value, .is_known = 1};
 return 1;
}

variable_types: row int


decompiled_code:
__int64 __fastcall bin_table_set_row_inactive(__int64 a1, int a2)
{
__int64 v2; // rbx
__int64 result; // rax
__int64 v4; // rax

if ( *(int *)(a1 + 16) <= 0 )
return 1LL;
v2 = 0LL;
do
{
v4 = *(_QWORD *)a1 + 24 * v2;
if ( *(_DWORD *)(v4 + 12) )
{
result = bin_table_set_cell_value(a1, v2, a2, 0);
if ( !(_DWORD)result )
return result;
}
else
{
result = bin_table_set_cell_value(a1, v2, a2, (1 << *(_DWORD *)(v4 + 8)) - 1);
if ( !(_DWORD)result )
return result;
}
++v2;
}
while ( *(_DWORD *)(a1 + 16) > (int)v2 );
return 1LL;
}

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

if ( *(int *)(a1 + 16) <= 0 )
return 1LL;
v2 = 0LL;
do
{
v4 = *(_QWORD *)a1 + 24 * v2;
if ( *(_DWORD *)(v4 + 12) )
{
result = func3(a1, v2, a2, 0);
if ( !(_DWORD)result )
return result;
}
else
{
result = func3(a1, v2, a2, (1 << *(_DWORD *)(v4 + 8)) - 1);
if ( !(_DWORD)result )
return result;
}
++v2;
}
while ( *(_DWORD *)(a1 + 16) > (int)v2 );
return 1LL;
}

original_code:
int bin_table_set_row_inactive(bin_table* table, int row)
{
 int n;
 for(n = 0; n < table->collumns; ++n)
 {
  if(table->collumn_descriptions[n].active_high)
  {
   if(!bin_table_set_cell_value(table, n, row, 0))
    return 0;
  }
  else
  {
   if(!bin_table_set_cell_value(table, n, row, (1 << table->collumn_descriptions[n].width) - 1))
    return 0;
  }
 }
 return 1;
}

canonical_original_code:
int bin_table_set_row_inactive(struct bin_table *table, int row)
{
 int n;
 for(n = 0; n < table->collumns; ++n)
 {
  if(table->collumn_descriptions[n].active_high)
  {
   if(!bin_table_set_cell_value(table, n, row, 0))
    return 0;
  }
  else
  {
   if(!bin_table_set_cell_value(table, n, row, (1 << table->collumn_descriptions[n].width) - 1))
    return 0;
  }
 }
 return 1;
}


decompiled_code:
__int64 __fastcall bin_table_get_cell_value(__int64 a1, int a2, int a3, _DWORD *a4)
{
__int64 result; // rax
int v5; // eax
_DWORD *v6; // rdx

if ( *(_DWORD *)(a1 + 20) > a3 )
{
v5 = *(_DWORD *)(a1 + 16);
if ( v5 > a2 )
{
v6 = (_DWORD *)(*(_QWORD *)(a1 + 8) + 8LL * (v5 * a3 + a2));
result = 0LL;
if ( v6[1] )
{
*a4 = *v6;
result = 1LL;
}
}
else
{
if ( *(_DWORD *)(a1 + 24) )
fwrite("ERROR: bin_table: collumn_index > number of collumns in table\n", 1uLL, 0x3EuLL, stderr);
result = *(unsigned int *)(a1 + 28);
if ( (_DWORD)result )
exit(1);
}
}
else
{
if ( *(_DWORD *)(a1 + 24) )
fwrite("ERROR: bin_table: row > number of rows in table\n", 1uLL, 0x30uLL, stderr);
result = *(unsigned int *)(a1 + 28);
if ( (_DWORD)result )
exit(1);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1, int a2, int a3, _DWORD *a4)
{
__int64 result; // rax
int v5; // eax
_DWORD *v6; // rdx

if ( *(_DWORD *)(a1 + 20) > a3 )
{
v5 = *(_DWORD *)(a1 + 16);
if ( v5 > a2 )
{
v6 = (_DWORD *)(*(_QWORD *)(a1 + 8) + 8LL * (v5 * a3 + a2));
result = 0LL;
if ( v6[1] )
{
*a4 = *v6;
result = 1LL;
}
}
else
{
if ( *(_DWORD *)(a1 + 24) )
fwrite("ERROR: bin_table: collumn_index > number of collumns in table\n", 1uLL, 0x3EuLL, stderr);
result = *(unsigned int *)(a1 + 28);
if ( (_DWORD)result )
exit(1);
}
}
else
{
if ( *(_DWORD *)(a1 + 24) )
fwrite("ERROR: bin_table: row > number of rows in table\n", 1uLL, 0x30uLL, stderr);
result = *(unsigned int *)(a1 + 28);
if ( (_DWORD)result )
exit(1);
}
return result;
}

original_code:
int bin_table_get_cell_value(bin_table* table, int collumn_index, int row, int* out_val)
{
 if(row >= table->rows)
 {
  do { if(table->print_on_error) { fprintf(stderr, "ERROR: bin_table: ""row > number of rows in table""\n"); } if(table->exit_on_error) { exit(1); } } while(0); return 0;
 }
 if(collumn_index >= table->collumns)
 {
  do { if(table->print_on_error) { fprintf(stderr, "ERROR: bin_table: ""collumn_index > number of collumns in table""\n"); } if(table->exit_on_error) { exit(1); } } while(0); return 0;
 }
 if(!table->cells[row*table->collumns + collumn_index].is_known)
  return 0;
 *out_val = table->cells[row*table->collumns + collumn_index].value;
 return 1;
}

canonical_original_code:
int bin_table_get_cell_value(struct bin_table *table, int collumn_index, int row, int *out_val)
{
 if(row >= table->rows)
 {
  do { if(table->print_on_error) { fprintf(stderr, "ERROR: bin_table: ""row > number of rows in table""\n"); } if(table->exit_on_error) { exit(1); } } while(0); return 0;
 }
 if(collumn_index >= table->collumns)
 {
  do { if(table->print_on_error) { fprintf(stderr, "ERROR: bin_table: ""collumn_index > number of collumns in table""\n"); } if(table->exit_on_error) { exit(1); } } while(0); return 0;
 }
 if(!table->cells[row*table->collumns + collumn_index].is_known)
  return 0;
 *out_val = table->cells[row*table->collumns + collumn_index].value;
 return 1;
}


decompiled_code:
__int64 __fastcall bin_table_copy_row(__int64 a1, int a2, int a3)
{
int v3; // eax
__int64 result; // rax

v3 = *(_DWORD *)(a1 + 20);
if ( v3 > a2 )
{
if ( v3 > a3 )
{
memcpy(
(void *)(*(_QWORD *)(a1 + 8) + 8LL * *(_DWORD *)(a1 + 16) * a2),
(const void *)(*(_QWORD *)(a1 + 8) + 8LL * *(_DWORD *)(a1 + 16) * a3),
8LL * *(int *)(a1 + 16));
result = 1LL;
}
else
{
if ( *(_DWORD *)(a1 + 24) )
fwrite("ERROR: bin_table: src row > number of rows\n", 1uLL, 0x2BuLL, stderr);
result = *(unsigned int *)(a1 + 28);
if ( (_DWORD)result )
exit(1);
}
}
else
{
if ( *(_DWORD *)(a1 + 24) )
fwrite("ERROR: bin_table: dest row > number of rows\n", 1uLL, 0x2CuLL, stderr);
result = *(unsigned int *)(a1 + 28);
if ( (_DWORD)result )
exit(1);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1, int a2, int a3)
{
int v3; // eax
__int64 result; // rax

v3 = *(_DWORD *)(a1 + 20);
if ( v3 > a2 )
{
if ( v3 > a3 )
{
memcpy(
(void *)(*(_QWORD *)(a1 + 8) + 8LL * *(_DWORD *)(a1 + 16) * a2),
(const void *)(*(_QWORD *)(a1 + 8) + 8LL * *(_DWORD *)(a1 + 16) * a3),
8LL * *(int *)(a1 + 16));
result = 1LL;
}
else
{
if ( *(_DWORD *)(a1 + 24) )
fwrite("ERROR: bin_table: src row > number of rows\n", 1uLL, 0x2BuLL, stderr);
result = *(unsigned int *)(a1 + 28);
if ( (_DWORD)result )
exit(1);
}
}
else
{
if ( *(_DWORD *)(a1 + 24) )
fwrite("ERROR: bin_table: dest row > number of rows\n", 1uLL, 0x2CuLL, stderr);
result = *(unsigned int *)(a1 + 28);
if ( (_DWORD)result )
exit(1);
}
return result;
}

original_code:
int bin_table_copy_row(bin_table* table, int dest, int src)
{
 if(dest >= table->rows)
 {
  do { if(table->print_on_error) { fprintf(stderr, "ERROR: bin_table: ""dest row > number of rows""\n"); } if(table->exit_on_error) { exit(1); } } while(0); return 0;
 }
 if(src >= table->rows)
 {
  do { if(table->print_on_error) { fprintf(stderr, "ERROR: bin_table: ""src row > number of rows""\n"); } if(table->exit_on_error) { exit(1); } } while(0); return 0;
 }
 memcpy(&table->cells[dest*table->collumns], &table->cells[src*table->collumns], sizeof(bin_table_cell) * table->collumns);
 return 1;
}

canonical_original_code:
int bin_table_copy_row(struct bin_table *table, int dest, int src)
{
 if(dest >= table->rows)
 {
  do { if(table->print_on_error) { fprintf(stderr, "ERROR: bin_table: ""dest row > number of rows""\n"); } if(table->exit_on_error) { exit(1); } } while(0); return 0;
 }
 if(src >= table->rows)
 {
  do { if(table->print_on_error) { fprintf(stderr, "ERROR: bin_table: ""src row > number of rows""\n"); } if(table->exit_on_error) { exit(1); } } while(0); return 0;
 }
 memcpy(&table->cells[dest*table->collumns], &table->cells[src*table->collumns], sizeof(bin_table_cell) * table->collumns);
 return 1;
}

variable_types: dest int

variable_types: src int


decompiled_code:
__int64 __fastcall bin_table_collumn_by_name(__int64 a1, const char *a2)
{
int v2; // er14
const char **v3; // rbp
unsigned int v4; // ebx

v2 = *(_DWORD *)(a1 + 16);
if ( v2 <= 0 )
{
LABEL_5:
if ( *(_DWORD *)(a1 + 24) )
fprintf(stderr, "ERROR: bin_table: unkown collumn name %s.\n", a2);
if ( *(_DWORD *)(a1 + 28) )
exit(1);
v4 = -1;
}
else
{
v3 = *(const char ***)a1;
v4 = 0;
while ( strcmp(a2, *v3) )
{
++v4;
v3 += 3;
if ( v4 == v2 )
goto LABEL_5;
}
}
return v4;
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1, const char *a2)
{
int v2; // er14
const char **v3; // rbp
unsigned int v4; // ebx

v2 = *(_DWORD *)(a1 + 16);
if ( v2 <= 0 )
{
LABEL_5:
if ( *(_DWORD *)(a1 + 24) )
fprintf(stderr, "ERROR: bin_table: unkown collumn name %s.\n", a2);
if ( *(_DWORD *)(a1 + 28) )
exit(1);
v4 = -1;
}
else
{
v3 = *(const char ***)a1;
v4 = 0;
while ( strcmp(a2, *v3) )
{
++v4;
v3 += 3;
if ( v4 == v2 )
goto LABEL_5;
}
}
return v4;
}

original_code:
int bin_table_collumn_by_name(bin_table* table, const char* name)
{
 int i;
 for(i = 0; i < table->collumns; i++)
 {
  if(!strcmp(name, table->collumn_descriptions[i].name))
   return i;
 }
 do { if(table->print_on_error) { fprintf(stderr, "ERROR: bin_table: ""unkown collumn name %s.""\n", name); } if(table->exit_on_error) { exit(1); } } while(0);
 return -1;
}

canonical_original_code:
int bin_table_collumn_by_name(struct bin_table *table, char *name)
{
 int i;
 for(i = 0; i < table->collumns; i++)
 {
  if(!strcmp(name, table->collumn_descriptions[i].name))
   return i;
 }
 do { if(table->print_on_error) { fprintf(stderr, "ERROR: bin_table: ""unkown collumn name %s.""\n", name); } if(table->exit_on_error) { exit(1); } } while(0);
 return -1;
}

variable_types:
name
char *

variable_types: i int


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

if ( a2 == 7 )
{
*(_DWORD *)(a1 + 32) |= 0x20u;
return 1LL;
}
if ( a2 > 7 )
{
if ( a2 == 8 )
{
*(_DWORD *)(a1 + 32) |= 0x30u;
return 1LL;
}
}
else
{
if ( a2 == 5 )
return 1LL;
if ( a2 == 6 )
{
*(_DWORD *)(a1 + 32) |= 0x10u;
return 1LL;
}
}
if ( *(_DWORD *)(a1 + 20) )
fprintf(stderr, "ERROR: device %s: unsupported character size: %d\n", *(const char **)(a1 + 8), (unsigned int)a2);
result = *(unsigned int *)(a1 + 16);
if ( (_DWORD)result )
exit(1);
return result;
}

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

if ( a2 == 7 )
{
*(_DWORD *)(a1 + 32) |= 0x20u;
return 1LL;
}
if ( a2 > 7 )
{
if ( a2 == 8 )
{
*(_DWORD *)(a1 + 32) |= 0x30u;
return 1LL;
}
}
else
{
if ( a2 == 5 )
return 1LL;
if ( a2 == 6 )
{
*(_DWORD *)(a1 + 32) |= 0x10u;
return 1LL;
}
}
if ( *(_DWORD *)(a1 + 20) )
fprintf(stderr, "ERROR: device %s: unsupported character size: %d\n", *(const char **)(a1 + 8), (unsigned int)a2);
result = *(unsigned int *)(a1 + 16);
if ( (_DWORD)result )
exit(1);
return result;
}

original_code:
int serial_set_character_size(serial_device* const dev, int char_size)
{
 switch(char_size)
 {
  case 5: dev->tios.c_cflag |= 0000000; break;
  case 6: dev->tios.c_cflag |= 0000020; break;
  case 7: dev->tios.c_cflag |= 0000040; break;
  case 8: dev->tios.c_cflag |= 0000060; break;
  default: do { if(dev->print_on_error) { fprintf(stderr, "ERROR: device %s: ""unsupported character size: %d""\n", dev->path, char_size); } if(dev->exit_on_error) { exit(1); } } while(0); return 0;
 }
 return 1;
}

canonical_original_code:
int serial_set_character_size(struct serial_device *dev, int char_size)
{
 switch(char_size)
 {
  case 5: dev->tios.c_cflag |= 0000000; break;
  case 6: dev->tios.c_cflag |= 0000020; break;
  case 7: dev->tios.c_cflag |= 0000040; break;
  case 8: dev->tios.c_cflag |= 0000060; break;
  default: do { if(dev->print_on_error) { fprintf(stderr, "ERROR: device %s: ""unsupported character size: %d""\n", dev->path, char_size); } if(dev->exit_on_error) { exit(1); } } while(0); return 0;
 }
 return 1;
}

variable_types: struct serial_device { int fd; char *path; int exit_on_error; int print_on_error; struct termios { unsigned int c_iflag; unsigned int c_oflag; unsigned int c_cflag; unsigned int c_lflag; unsigned char c_line; unsigned char c_cc[32]; unsigned int c_ispeed; unsigned int c_ospeed; } tios; } *

user_defined_types: struct serial_device { int fd; char *path; int exit_on_error; int print_on_error; struct termios tios; }


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

if ( a2 == 600 )
{
cfsetispeed((struct termios *)(a1 + 24), 8u);
return 1LL;
}
if ( a2 > 600 )
{
if ( a2 == 4800 )
{
cfsetispeed((struct termios *)(a1 + 24), 0xCu);
return 1LL;
}
if ( a2 <= 4800 )
{
switch ( a2 )
{
case 1800:
cfsetispeed((struct termios *)(a1 + 24), 0xAu);
return 1LL;
case 2400:
cfsetispeed((struct termios *)(a1 + 24), 0xBu);
return 1LL;
case 1200:
cfsetispeed((struct termios *)(a1 + 24), 9u);
return 1LL;
}
}
else
{
switch ( a2 )
{
case 19200:
cfsetispeed((struct termios *)(a1 + 24), 0xEu);
return 1LL;
case 38400:
cfsetispeed((struct termios *)(a1 + 24), 0xFu);
return 1LL;
case 9600:
cfsetispeed((struct termios *)(a1 + 24), 0xDu);
return 1LL;
}
}
}
else
{
if ( a2 == 134 )
{
cfsetispeed((struct termios *)(a1 + 24), 4u);
return 1LL;
}
if ( a2 <= 134 )
{
switch ( a2 )
{
case 'K':
cfsetispeed((struct termios *)(a1 + 24), 2u);
return 1LL;
case 'n':
cfsetispeed((struct termios *)(a1 + 24), 3u);
return 1LL;
case '2':
cfsetispeed((struct termios *)(a1 + 24), 1u);
return 1LL;
}
}
else
{
switch ( a2 )
{
case 200:
cfsetispeed((struct termios *)(a1 + 24), 6u);
return 1LL;
case 300:
cfsetispeed((struct termios *)(a1 + 24), 7u);
return 1LL;
case 150:
cfsetispeed((struct termios *)(a1 + 24), 5u);
return 1LL;
}
}
}
if ( *(_DWORD *)(a1 + 20) )
fprintf(stderr, "ERROR: device %s: unsupported input baudrate: %d\n", *(const char **)(a1 + 8), (unsigned int)a2);
result = *(unsigned int *)(a1 + 16);
if ( (_DWORD)result )
exit(1);
return result;
}

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

if ( a2 == 600 )
{
cfsetispeed((struct termios *)(a1 + 24), 8u);
return 1LL;
}
if ( a2 > 600 )
{
if ( a2 == 4800 )
{
cfsetispeed((struct termios *)(a1 + 24), 0xCu);
return 1LL;
}
if ( a2 <= 4800 )
{
switch ( a2 )
{
case 1800:
cfsetispeed((struct termios *)(a1 + 24), 0xAu);
return 1LL;
case 2400:
cfsetispeed((struct termios *)(a1 + 24), 0xBu);
return 1LL;
case 1200:
cfsetispeed((struct termios *)(a1 + 24), 9u);
return 1LL;
}
}
else
{
switch ( a2 )
{
case 19200:
cfsetispeed((struct termios *)(a1 + 24), 0xEu);
return 1LL;
case 38400:
cfsetispeed((struct termios *)(a1 + 24), 0xFu);
return 1LL;
case 9600:
cfsetispeed((struct termios *)(a1 + 24), 0xDu);
return 1LL;
}
}
}
else
{
if ( a2 == 134 )
{
cfsetispeed((struct termios *)(a1 + 24), 4u);
return 1LL;
}
if ( a2 <= 134 )
{
switch ( a2 )
{
case 'K':
cfsetispeed((struct termios *)(a1 + 24), 2u);
return 1LL;
case 'n':
cfsetispeed((struct termios *)(a1 + 24), 3u);
return 1LL;
case '2':
cfsetispeed((struct termios *)(a1 + 24), 1u);
return 1LL;
}
}
else
{
switch ( a2 )
{
case 200:
cfsetispeed((struct termios *)(a1 + 24), 6u);
return 1LL;
case 300:
cfsetispeed((struct termios *)(a1 + 24), 7u);
return 1LL;
case 150:
cfsetispeed((struct termios *)(a1 + 24), 5u);
return 1LL;
}
}
}
if ( *(_DWORD *)(a1 + 20) )
fprintf(stderr, "ERROR: device %s: unsupported input baudrate: %d\n", *(const char **)(a1 + 8), (unsigned int)a2);
result = *(unsigned int *)(a1 + 16);
if ( (_DWORD)result )
exit(1);
return result;
}

original_code:
int serial_set_in_baudrate(serial_device* const dev, int in_baudrate)
{
 switch(in_baudrate)
 {
  case 50: cfsetispeed(&(dev->tios), 0000001); break;
  case 75: cfsetispeed(&(dev->tios), 0000002); break;
  case 110: cfsetispeed(&(dev->tios), 0000003); break;
  case 134: cfsetispeed(&(dev->tios), 0000004); break;
  case 150: cfsetispeed(&(dev->tios), 0000005); break;
  case 200: cfsetispeed(&(dev->tios), 0000006); break;
  case 300: cfsetispeed(&(dev->tios), 0000007); break;
  case 600: cfsetispeed(&(dev->tios), 0000010); break;
  case 1200: cfsetispeed(&(dev->tios), 0000011); break;
  case 1800: cfsetispeed(&(dev->tios), 0000012); break;
  case 2400: cfsetispeed(&(dev->tios), 0000013); break;
  case 4800: cfsetispeed(&(dev->tios), 0000014); break;
  case 9600: cfsetispeed(&(dev->tios), 0000015); break;
  case 19200: cfsetispeed(&(dev->tios), 0000016); break;
  case 38400: cfsetispeed(&(dev->tios), 0000017); break;
  default: do { if(dev->print_on_error) { fprintf(stderr, "ERROR: device %s: ""unsupported input baudrate: %d""\n", dev->path, in_baudrate); } if(dev->exit_on_error) { exit(1); } } while(0); return 0;
 }
 return 1;
}

canonical_original_code:
int serial_set_in_baudrate(struct serial_device *dev, int in_baudrate)
{
 switch(in_baudrate)
 {
  case 50: cfsetispeed(&(dev->tios), 0000001); break;
  case 75: cfsetispeed(&(dev->tios), 0000002); break;
  case 110: cfsetispeed(&(dev->tios), 0000003); break;
  case 134: cfsetispeed(&(dev->tios), 0000004); break;
  case 150: cfsetispeed(&(dev->tios), 0000005); break;
  case 200: cfsetispeed(&(dev->tios), 0000006); break;
  case 300: cfsetispeed(&(dev->tios), 0000007); break;
  case 600: cfsetispeed(&(dev->tios), 0000010); break;
  case 1200: cfsetispeed(&(dev->tios), 0000011); break;
  case 1800: cfsetispeed(&(dev->tios), 0000012); break;
  case 2400: cfsetispeed(&(dev->tios), 0000013); break;
  case 4800: cfsetispeed(&(dev->tios), 0000014); break;
  case 9600: cfsetispeed(&(dev->tios), 0000015); break;
  case 19200: cfsetispeed(&(dev->tios), 0000016); break;
  case 38400: cfsetispeed(&(dev->tios), 0000017); break;
  default: do { if(dev->print_on_error) { fprintf(stderr, "ERROR: device %s: ""unsupported input baudrate: %d""\n", dev->path, in_baudrate); } if(dev->exit_on_error) { exit(1); } } while(0); return 0;
 }
 return 1;
}

user_defined_types: struct termios { unsigned int c_iflag; unsigned int c_oflag; unsigned int c_cflag; unsigned int c_lflag; unsigned char c_line; unsigned char c_cc[32]; unsigned int c_ispeed; unsigned int c_ospeed; }