issue

decompiled_code:
__int64 __fastcall issue(__int64 a1, __int64 a2, __int64 a3, __int64 a4, int a5)
{
__int64 v5; // rbx
int v6; // er12
__int64 v7; // rbp
const char *v8; // rdx
__int64 result; // rax
char *v10; // rdi
char *v11; // rdi
int v12; // eax

v6 = instr_proc;
v7 = iq + ((__int64)instr_proc << 6);
v8 = *(const char **)v7;
if ( !strcmp("ADD", *(const char **)v7) || !strcmp("SUB", *(const char **)v7) )
{
v5 = add_int_rs;
a5 = 4;
}
else if ( !strcmp("ADDD", *(const char **)v7) || !strcmp("SUBD", *(const char **)v7) )
{
v5 = mul_int_rs;
a5 = 4;
}
else if ( !strcmp("MUL", *(const char **)v7) || !strcmp("DIV", *(const char **)v7) )
{
v5 = add_fp_rs;
a5 = 2;
}
else if ( !strcmp("MULD", *(const char **)v7) || !strcmp("DIVD", *(const char **)v7) )
{
v5 = mul_fp_rs;
a5 = 2;
}
else
{
v12 = *(unsigned __int8 *)v8;
if ( v12 == 76 && v8[1] == 68 && !v8[2] )
{
v5 = ld_rs;
a5 = 2;
}
else if ( v12 == 83 && v8[1] == 68 && !v8[2] )
{
v5 = sd_rs;
a5 = 2;
}
}
result = v5 + 40LL * (unsigned int)(a5 - 1) + 40;
while ( *(_DWORD *)v5 != 1 )
{
v5 += 40LL;
if ( v5 == result )
return result;
}
v10 = *(char **)(v7 + 16);
*(_DWORD *)v5 = 2;
*(_QWORD *)(v5 + 8) = v7;
if ( v10 )
*(_QWORD *)(v5 + 16) = dep_lookup(v10);
v11 = *(char **)(v7 + 24);
if ( v11 )
*(_QWORD *)(v5 + 24) = dep_lookup(v11);
result = (unsigned int)cycles;
instr_proc = v6 + 1;
*(_DWORD *)(v7 + 48) = cycles;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1, __int64 a2, __int64 a3, __int64 a4, int a5)
{
__int64 v5; // rbx
int v6; // er12
__int64 v7; // rbp
const char *v8; // rdx
__int64 result; // rax
char *v10; // rdi
char *v11; // rdi
int v12; // eax

v6 = instr_proc;
v7 = iq + ((__int64)instr_proc << 6);
v8 = *(const char **)v7;
if ( !strcmp("ADD", *(const char **)v7) || !strcmp("SUB", *(const char **)v7) )
{
v5 = add_int_rs;
a5 = 4;
}
else if ( !strcmp("ADDD", *(const char **)v7) || !strcmp("SUBD", *(const char **)v7) )
{
v5 = mul_int_rs;
a5 = 4;
}
else if ( !strcmp("MUL", *(const char **)v7) || !strcmp("DIV", *(const char **)v7) )
{
v5 = add_fp_rs;
a5 = 2;
}
else if ( !strcmp("MULD", *(const char **)v7) || !strcmp("DIVD", *(const char **)v7) )
{
v5 = mul_fp_rs;
a5 = 2;
}
else
{
v12 = *(unsigned __int8 *)v8;
if ( v12 == 76 && v8[1] == 68 && !v8[2] )
{
v5 = ld_rs;
a5 = 2;
}
else if ( v12 == 83 && v8[1] == 68 && !v8[2] )
{
v5 = sd_rs;
a5 = 2;
}
}
result = v5 + 40LL * (unsigned int)(a5 - 1) + 40;
while ( *(_DWORD *)v5 != 1 )
{
v5 += 40LL;
if ( v5 == result )
return result;
}
v10 = *(char **)(v7 + 16);
*(_DWORD *)v5 = 2;
*(_QWORD *)(v5 + 8) = v7;
if ( v10 )
*(_QWORD *)(v5 + 16) = func3(v10);
v11 = *(char **)(v7 + 24);
if ( v11 )
*(_QWORD *)(v5 + 24) = func3(v11);
result = (unsigned int)cycles;
instr_proc = v6 + 1;
*(_DWORD *)(v7 + 48) = cycles;
return result;
}

original_code:
void issue () {
 int i, rs_count;
 Instruction *curr;
 RS *rs_type, *rs;
 curr = &iq[instr_proc];
 if (!(strcmp ("ADD", curr->opcd)) || !(strcmp ("SUB", curr->opcd))) {
  rs_count = 4; rs_type = add_int_rs;
 }
 else if (!(strcmp ("ADDD", curr->opcd)) || !(strcmp ("SUBD", curr->opcd))) {
  rs_count = 4; rs_type = mul_int_rs;
 }
 else if (!(strcmp ("MUL", curr->opcd)) || !(strcmp ("DIV", curr->opcd))) {
  rs_count = 2; rs_type = add_fp_rs;
 }
 else if (!(strcmp ("MULD", curr->opcd)) || !(strcmp ("DIVD", curr->opcd))) {
  rs_count = 2; rs_type = mul_fp_rs;
 }
 else if (!(strcmp ("LD", curr->opcd))) {
  rs_count = 2; rs_type = ld_rs;
 }
 else if (!(strcmp ("SD", curr->opcd))) {
  rs_count = 2; rs_type = sd_rs;
 }
 for (i = 0; i < rs_count; i++)
  if (rs_type[i].status == AVAILABLE)
   break;
 if (i >= rs_count) return;
 rs = &rs_type[i];
 rs->status = BUSY;
 rs->instr = curr;
 if (curr->src1)
  rs->qj = dep_lookup (curr->src1);
 if (curr->src2)
  rs->qk = dep_lookup (curr->src2);
 curr->issue_time = cycles;
 instr_proc++;
}

canonical_original_code:
void issue() {
 int i; int rs_count;
 struct Instruction *curr;
 struct resrv_stn *rs_type; struct resrv_stn *rs;
 curr = &iq[instr_proc];
 if (!(strcmp ("ADD", curr->opcd)) || !(strcmp ("SUB", curr->opcd))) {
  rs_count = 4; rs_type = add_int_rs;
 }
 else if (!(strcmp ("ADDD", curr->opcd)) || !(strcmp ("SUBD", curr->opcd))) {
  rs_count = 4; rs_type = mul_int_rs;
 }
 else if (!(strcmp ("MUL", curr->opcd)) || !(strcmp ("DIV", curr->opcd))) {
  rs_count = 2; rs_type = add_fp_rs;
 }
 else if (!(strcmp ("MULD", curr->opcd)) || !(strcmp ("DIVD", curr->opcd))) {
  rs_count = 2; rs_type = mul_fp_rs;
 }
 else if (!(strcmp ("LD", curr->opcd))) {
  rs_count = 2; rs_type = ld_rs;
 }
 else if (!(strcmp ("SD", curr->opcd))) {
  rs_count = 2; rs_type = sd_rs;
 }
 for (i = 0; i < rs_count; i++)
  if (rs_type[i].status == AVAILABLE)
   break;
 if (i >= rs_count) return;
 rs = &rs_type[i];
 rs->status = BUSY;
 rs->instr = curr;
 if (curr->src1)
  rs->qj = dep_lookup (curr->src1);
 if (curr->src2)
  rs->qk = dep_lookup (curr->src2);
 curr->issue_time = cycles;
 instr_proc++;
}

variable_types: struct Instruction { char *opcd; char *dest; char *src1; char *src2; int num_ops; int latency; struct resrv_stn { enum rs_status { UNKNOWN=0, AVAILABLE=1, BUSY=2, RESULT_READY=3 } status; struct Instruction *instr; struct resrv_stn *qj; struct resrv_stn *qk; int timer; } *cur; unsigned int issue_time; unsigned int exec_time; unsigned int write_time; } *

variable_types: struct resrv_stn { enum rs_status { UNKNOWN=0, AVAILABLE=1, BUSY=2, RESULT_READY=3 } status; struct Instruction { char *opcd; char *dest; char *src1; char *src2; int num_ops; int latency; struct resrv_stn *cur; unsigned int issue_time; unsigned int exec_time; unsigned int write_time; } *instr; struct resrv_stn *qj; struct resrv_stn *qk; int timer; } *


main

canonical_name: main

repo: harshasrisri/tomasulo

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int64 v3; // rdi
__int64 v4; // rdx
__int64 v5; // rcx
int v6; // er8

parse_args(argc, argv, envp);
parse_file(inst_defn_file, 100LL);
v3 = inst_trace_file;
parse_file(inst_trace_file, 116LL);
create_arch();
while ( instr_proc < instr_count )
{
++cycles;
issue(v3, 116LL, v4, v5, v6);
execute();
write_back();
}
finish();
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int64 v3; // rdi
__int64 v4; // rdx
__int64 v5; // rcx
int v6; // er8

parse_args(argc, argv, envp);
parse_file(inst_defn_file, 100LL);
v3 = inst_trace_file;
parse_file(inst_trace_file, 116LL);
func2();
while ( instr_proc < instr_count )
{
++cycles;
func6(v3, 116LL, v4, v5, v6);
func4();
func5();
}
finish();
return 0;
}

original_code:
int main (int argc, char **argv) {
 parse_args (argc, argv);
 parse_file (inst_defn_file, 'd');
 parse_file (inst_trace_file, 't');
 create_arch();
 while (instr_proc < instr_count) {
  cycles++;
  issue ();
  execute ();
  write_back();
 }
 finish ();
 return 0;
}

canonical_original_code:
int main(int argc, char **argv) {
 parse_args (argc, argv);
 parse_file (inst_defn_file, 'd');
 parse_file (inst_trace_file, 't');
 create_arch();
 while (instr_proc < instr_count) {
  cycles++;
  issue ();
  execute ();
  write_back();
 }
 finish ();
 return 0;
}

variable_types: argc int

variable_types:
argv
char **

return_type: int


decompiled_code:
int __fastcall create_operation(char *s)
{
char *v1; // rax
char **v2; // rbp
char *v3; // rax
int v4; // edx
char *v5; // rax
int v6; // edx
char v7; // al
__int64 v8; // r8
char *v9; // rax
int result; // eax
char v11[32]; // [rsp+0h] [rbp-58h] BYREF
__int64 v12; // [rsp+20h] [rbp-38h] BYREF
char v13[8]; // [rsp+28h] [rbp-30h] BYREF

if ( __ROR4__(-858993459 * op_count + 429496728, 1) <= 0x19999998u )
ops = realloc(ops, 0xF0uLL);
v1 = strtok(s, " \t,");
strcpy(v11, v1);
if ( !v11[0] )
{
fprintf(stderr, "[FATAL] (%s:%d) OP name not proper : %s\n", "parser.c", 13LL, s);
goto LABEL_14;
}
v2 = (char **)((char *)ops + 24 * op_count);
*v2 = strdup(v11);
v3 = strtok(0LL, " \t,");
v4 = atoi(v3);
if ( v4 < 0 )
{
fprintf(stderr, "[FATAL] (%s:%d) Operand count not proper : %s\n", "parser.c", 18LL, s);
goto LABEL_14;
}
*((_DWORD *)ops + 6 * op_count + 2) = v4;
v5 = strtok(0LL, " \t,");
v6 = atoi(v5);
if ( v6 <= 0 )
{
fprintf(stderr, "[FATAL] (%s:%d) Latency not proper : %s\n", "parser.c", 23LL, s);
goto LABEL_14;
}
*((_DWORD *)ops + 6 * op_count + 3) = v6;
v7 = *strtok(0LL, " \t,");
if ( v7 == 73 )
{
v12 = 0x72656765746E49LL;
v8 = op_count;
v9 = (char *)ops + 24 * op_count;
*((_DWORD *)v9 + 4) = 1;
goto LABEL_10;
}
if ( v7 == 70 )
{
v12 = 0x676E6974616F6C46LL;
v8 = op_count;
v9 = (char *)ops + 24 * op_count;
*((_DWORD *)v9 + 4) = 2;
strcpy(v13, " Point");
goto LABEL_10;
}
if ( v7 != 67 )
{
fprintf(stderr, "[FATAL] (%s:%d) Unknown instruction type : %s\n", "parser.c", 40LL, s);
LABEL_14:
exit(-1);
}
LODWORD(v12) = 1835888451;
BYTE6(v12) = 0;
v8 = op_count;
v9 = (char *)ops + 24 * op_count;
*((_DWORD *)v9 + 4) = 3;
WORD2(v12) = 28271;
LABEL_10:
result = fprintf(
stderr,
"[INFO] (%s:%d) %d : %s operation %s defined taking %d operands with latency %d\n",
"parser.c",
42LL,
v8,
(const char *)&v12,
*(const char **)v9,
*((unsigned int *)v9 + 2),
*((unsigned int *)v9 + 3));
++op_count;
return result;
}

canonical_decompiled_code:
int __fastcall func0(char *s)
{
char *v1; // rax
char **v2; // rbp
char *v3; // rax
int v4; // edx
char *v5; // rax
int v6; // edx
char v7; // al
__int64 v8; // r8
char *v9; // rax
int result; // eax
char v11[32]; // [rsp+0h] [rbp-58h] BYREF
__int64 v12; // [rsp+20h] [rbp-38h] BYREF
char v13[8]; // [rsp+28h] [rbp-30h] BYREF

if ( __ROR4__(-858993459 * op_count + 429496728, 1) <= 0x19999998u )
ops = realloc(ops, 0xF0uLL);
v1 = strtok(s, " \t,");
strcpy(v11, v1);
if ( !v11[0] )
{
fprintf(stderr, "[FATAL] (%s:%d) OP name not proper : %s\n", "parser.c", 13LL, s);
goto LABEL_14;
}
v2 = (char **)((char *)ops + 24 * op_count);
*v2 = strdup(v11);
v3 = strtok(0LL, " \t,");
v4 = atoi(v3);
if ( v4 < 0 )
{
fprintf(stderr, "[FATAL] (%s:%d) Operand count not proper : %s\n", "parser.c", 18LL, s);
goto LABEL_14;
}
*((_DWORD *)ops + 6 * op_count + 2) = v4;
v5 = strtok(0LL, " \t,");
v6 = atoi(v5);
if ( v6 <= 0 )
{
fprintf(stderr, "[FATAL] (%s:%d) Latency not proper : %s\n", "parser.c", 23LL, s);
goto LABEL_14;
}
*((_DWORD *)ops + 6 * op_count + 3) = v6;
v7 = *strtok(0LL, " \t,");
if ( v7 == 73 )
{
v12 = 0x72656765746E49LL;
v8 = op_count;
v9 = (char *)ops + 24 * op_count;
*((_DWORD *)v9 + 4) = 1;
goto LABEL_10;
}
if ( v7 == 70 )
{
v12 = 0x676E6974616F6C46LL;
v8 = op_count;
v9 = (char *)ops + 24 * op_count;
*((_DWORD *)v9 + 4) = 2;
strcpy(v13, " Point");
goto LABEL_10;
}
if ( v7 != 67 )
{
fprintf(stderr, "[FATAL] (%s:%d) Unknown instruction type : %s\n", "parser.c", 40LL, s);
LABEL_14:
exit(-1);
}
LODWORD(v12) = 1835888451;
BYTE6(v12) = 0;
v8 = op_count;
v9 = (char *)ops + 24 * op_count;
*((_DWORD *)v9 + 4) = 3;
WORD2(v12) = 28271;
LABEL_10:
result = fprintf(
stderr,
"[INFO] (%s:%d) %d : %s operation %s defined taking %d operands with latency %d\n",
"parser.c",
42LL,
v8,
(const char *)&v12,
*(const char **)v9,
*((unsigned int *)v9 + 2),
*((unsigned int *)v9 + 3));
++op_count;
return result;
}

original_code:
static void create_operation (char *line) {
 char name[20], typ[20];
 int num_ops, latency;
 char type;
 if (!(op_count % 10))
  ops = (Operation *) realloc (ops, sizeof(Operation) * 10);
 strcpy (name, strtok (line," \t,"));
 if (!name[0])
  do {fprintf(stderr, "[FATAL] (%s:%d) " "OP name not proper : %s\n", "parser.c", 13, line); exit(-1); } while (0);
 ops[op_count].name = strdup (name);
 num_ops = atoi (strtok (((void *)0), " \t,"));
 if (0 > num_ops)
  do {fprintf(stderr, "[FATAL] (%s:%d) " "Operand count not proper : %s\n", "parser.c", 18, line); exit(-1); } while (0);
 ops[op_count].num_ops = num_ops;
 latency = atoi (strtok (((void *)0), " \t,"));
 if (0 >= latency)
  do {fprintf(stderr, "[FATAL] (%s:%d) " "Latency not proper : %s\n", "parser.c", 23, line); exit(-1); } while (0);
 ops[op_count].latency = latency;
 type = (strtok (((void *)0), " \t,"))[0];
 if ('I' == type) {
  ops[op_count].type = INTEGER;
  strcpy (typ, "Integer");
 }
 else if ('F' == type) {
  ops[op_count].type = FLOAT;
  strcpy (typ, "Floating Point");
 }
 else if ('C' == type) {
  ops[op_count].type = COMMON;
  strcpy (typ, "Common");
 }
 else
  do {fprintf(stderr, "[FATAL] (%s:%d) " "Unknown instruction type : %s\n", "parser.c", 40, line); exit(-1); } while (0);
 do {fprintf(stderr, "[INFO] (%s:%d) " "%d : %s operation %s defined taking %d operands with latency %d\n", "parser.c", 42, op_count, typ, ops[op_count].name, ops[op_count].num_ops, ops[op_count].latency); } while (0);
 op_count++;
}

canonical_original_code:
static void create_operation(char *line) {
 char name[20]; char typ[20];
 int num_ops; int latency;
 char type;
 if (!(op_count % 10))
  ops = (struct Operation *) realloc (ops, sizeof(Operation) * 10);
 strcpy (name, strtok (line," \t,"));
 if (!name[0])
  do {fprintf(stderr, "[FATAL] (%s:%d) " "OP name not proper : %s\n", "parser.c", 13, line); exit(-1); } while (0);
 ops[op_count].name = strdup (name);
 num_ops = atoi (strtok (((void *)0), " \t,"));
 if (0 > num_ops)
  do {fprintf(stderr, "[FATAL] (%s:%d) " "Operand count not proper : %s\n", "parser.c", 18, line); exit(-1); } while (0);
 ops[op_count].num_ops = num_ops;
 latency = atoi (strtok (((void *)0), " \t,"));
 if (0 >= latency)
  do {fprintf(stderr, "[FATAL] (%s:%d) " "Latency not proper : %s\n", "parser.c", 23, line); exit(-1); } while (0);
 ops[op_count].latency = latency;
 type = (strtok (((void *)0), " \t,"))[0];
 if ('I' == type) {
  ops[op_count].type = INTEGER;
  strcpy (typ, "Integer");
 }
 else if ('F' == type) {
  ops[op_count].type = FLOAT;
  strcpy (typ, "Floating Point");
 }
 else if ('C' == type) {
  ops[op_count].type = COMMON;
  strcpy (typ, "Common");
 }
 else
  do {fprintf(stderr, "[FATAL] (%s:%d) " "Unknown instruction type : %s\n", "parser.c", 40, line); exit(-1); } while (0);
 do {fprintf(stderr, "[INFO] (%s:%d) " "%d : %s operation %s defined taking %d operands with latency %d\n", "parser.c", 42, op_count, typ, ops[op_count].name, ops[op_count].num_ops, ops[op_count].latency); } while (0);
 op_count++;
}

variable_types:
line
char *

variable_types:
name
char [20]

variable_types:
typ
char [20]

variable_types: latency int

variable_types: type char

return_type: void

user_defined_types: struct Operation { char *name; int num_ops; int latency; enum instr_type type; }

user_defined_types: enum instr_type { UNDEFINED=0, INTEGER=1, FLOAT=2, COMMON=3 }


decompiled_code:
__int64 __fastcall lookup_definition(char *s1, __m128i *a2)
{
const __m128i *v2; // rbx
const __m128i *v3; // r12

if ( op_count <= 0 )
return 0LL;
v2 = (const __m128i *)ops;
v3 = (const __m128i *)((char *)ops + 24 * (unsigned int)(op_count - 1) + 24);
do
{
if ( !strcmp(s1, (const char *)v2->m128i_i64[0]) )
{
*a2 = _mm_loadu_si128(v2);
a2[1].m128i_i64[0] = v2[1].m128i_i64[0];
return 1LL;
}
v2 = (const __m128i *)((char *)v2 + 24);
}
while ( v2 != v3 );
return 0LL;
}

original_code:
static int lookup_definition (char *opcode, Operation *instr_defn) {
 int i;
 for (i = 0; i < op_count; i++)
  if (!strcmp (opcode, ops[i].name)) {
   *instr_defn = ops[i];
   return 1;
  }
 return 0;
}

canonical_original_code:
static int lookup_definition(char *opcode, struct Operation *instr_defn) {
 int i;
 for (i = 0; i < op_count; i++)
  if (!strcmp (opcode, ops[i].name)) {
   *instr_defn = ops[i];
   return 1;
  }
 return 0;
}

variable_types:
opcode
char *

variable_types: struct Operation { char *name; int num_ops; int latency; enum instr_type { UNDEFINED=0, INTEGER=1, FLOAT=2, COMMON=3 } type; } *

variable_types: i int


original_code:
static void queue_instuction (char *line) {
 char opcode[20];
 Operation instr_defn;
 if (!(instr_count % 10))
  iq = (Instruction *) realloc (iq, sizeof(Instruction) * 10);
 iq[instr_count].dest = iq[instr_count].src1 = iq[instr_count].src2 = 0;
 iq[instr_count].issue_time = iq[instr_count].exec_time = iq[instr_count].write_time = 0;
 sscanf (line, "%s", opcode);
 if (!lookup_definition (opcode, &instr_defn))
  do {fprintf(stderr, "[FATAL] (%s:%d) " "Undefined instruction : %s\n", "parser.c", 72, line); exit(-1); } while (0);
 iq[instr_count].opcd = strdup (strtok (line, " \t,"));
 iq[instr_count].num_ops = instr_defn.num_ops;
 iq[instr_count].latency = instr_defn.latency;
 if (instr_defn.num_ops > 0)
  iq[instr_count].dest = strdup (strtok (((void *)0), " \t,"));
 if (instr_defn.num_ops > 1)
  iq[instr_count].src1 = strdup (strtok (((void *)0), " \t,"));
 if (instr_defn.num_ops > 2)
  iq[instr_count].src2 = strdup (strtok (((void *)0), " \t,"));
 do {fprintf(stderr, "[INFO] (%s:%d) " "Instruction %d : %s %s, %s, %s \n", "parser.c", 87, instr_count, iq[instr_count].opcd, iq[instr_count].dest, iq[instr_count].src1, iq[instr_count].src2); } while (0);
 instr_count++;
}

canonical_original_code:
static void queue_instuction(char *line) {
 char opcode[20];
 struct Operation instr_defn;
 if (!(instr_count % 10))
  iq = (struct Instruction *) realloc (iq, sizeof(Instruction) * 10);
 iq[instr_count].dest = iq[instr_count].src1 = iq[instr_count].src2 = 0;
 iq[instr_count].issue_time = iq[instr_count].exec_time = iq[instr_count].write_time = 0;
 sscanf (line, "%s", opcode);
 if (!lookup_definition (opcode, &instr_defn))
  do {fprintf(stderr, "[FATAL] (%s:%d) " "Undefined instruction : %s\n", "parser.c", 72, line); exit(-1); } while (0);
 iq[instr_count].opcd = strdup (strtok (line, " \t,"));
 iq[instr_count].num_ops = instr_defn.num_ops;
 iq[instr_count].latency = instr_defn.latency;
 if (instr_defn.num_ops > 0)
  iq[instr_count].dest = strdup (strtok (((void *)0), " \t,"));
 if (instr_defn.num_ops > 1)
  iq[instr_count].src1 = strdup (strtok (((void *)0), " \t,"));
 if (instr_defn.num_ops > 2)
  iq[instr_count].src2 = strdup (strtok (((void *)0), " \t,"));
 do {fprintf(stderr, "[INFO] (%s:%d) " "Instruction %d : %s %s, %s, %s \n", "parser.c", 87, instr_count, iq[instr_count].opcd, iq[instr_count].dest, iq[instr_count].src1, iq[instr_count].src2); } while (0);
 instr_count++;
}

variable_types:
opcode
char [20]

variable_types: struct Operation { char *name; int num_ops; int latency; enum instr_type { UNDEFINED=0, INTEGER=1, FLOAT=2, COMMON=3 } type; }

user_defined_types: struct Instruction { char *opcd; char *dest; char *src1; char *src2; int num_ops; int latency; struct resrv_stn *cur; unsigned int issue_time; unsigned int exec_time; unsigned int write_time; }

user_defined_types: struct resrv_stn { enum rs_status status; struct Instruction *instr; struct resrv_stn *qj; struct resrv_stn *qk; int timer; }

user_defined_types: enum rs_status { UNKNOWN=0, AVAILABLE=1, BUSY=2, RESULT_READY=3 }


decompiled_code:
unsigned int __fastcall parse_args(int argc, char **argv)
{
unsigned int result; // eax
FILE *v3; // rbp

while ( 1 )
{
result = getopt(argc, argv, "d:t:h");
if ( result == -1 )
break;
v3 = stderr;
switch ( result )
{
case 'h':
fprintf(stderr, "[WARN] (%s:%d) Help file to come here\n", "utils.c", 23LL);
break;
case 't':
inst_trace_file = strdup(optarg);
fprintf(
v3,
"[INFO] (%s:%d) Instruction trace File set to : %s\n",
"utils.c",
20LL,
(const char *)inst_trace_file);
break;
case 'd':
inst_defn_file = strdup(optarg);
fprintf(
v3,
"[INFO] (%s:%d) Instruction Definition File set to : %s\n",
"utils.c",
16LL,
(const char *)inst_defn_file);
break;
default:
fprintf(stderr, "[FATAL] (%s:%d) Invalid command line option : -%c\n", "utils.c", 27LL, result);
exit(-1);
}
}
if ( inst_defn_file )
{
if ( inst_trace_file )
return result;
LABEL_13:
inst_trace_file = strdup("trace");
return fprintf(
stderr,
"[INFO] (%s:%d) Using default instruction trace file : %s\n",
"utils.c",
34LL,
(const char *)inst_trace_file);
}
inst_defn_file = strdup("instr.def");
result = fprintf(
stderr,
"[INFO] (%s:%d) Using default instruction definition file : %s\n",
"utils.c",
31LL,
(const char *)inst_defn_file);
if ( !inst_trace_file )
goto LABEL_13;
return result;
}

canonical_decompiled_code:
unsigned int __fastcall func0(int argc, char **argv)
{
unsigned int result; // eax
FILE *v3; // rbp

while ( 1 )
{
result = getopt(argc, argv, "d:t:h");
if ( result == -1 )
break;
v3 = stderr;
switch ( result )
{
case 'h':
fprintf(stderr, "[WARN] (%s:%d) Help file to come here\n", "utils.c", 23LL);
break;
case 't':
inst_trace_file = strdup(optarg);
fprintf(
v3,
"[INFO] (%s:%d) Instruction trace File set to : %s\n",
"utils.c",
20LL,
(const char *)inst_trace_file);
break;
case 'd':
inst_defn_file = strdup(optarg);
fprintf(
v3,
"[INFO] (%s:%d) Instruction Definition File set to : %s\n",
"utils.c",
16LL,
(const char *)inst_defn_file);
break;
default:
fprintf(stderr, "[FATAL] (%s:%d) Invalid command line option : -%c\n", "utils.c", 27LL, result);
exit(-1);
}
}
if ( inst_defn_file )
{
if ( inst_trace_file )
return result;
LABEL_13:
inst_trace_file = strdup("trace");
return fprintf(
stderr,
"[INFO] (%s:%d) Using default instruction trace file : %s\n",
"utils.c",
34LL,
(const char *)inst_trace_file);
}
inst_defn_file = strdup("instr.def");
result = fprintf(
stderr,
"[INFO] (%s:%d) Using default instruction definition file : %s\n",
"utils.c",
31LL,
(const char *)inst_defn_file);
if ( !inst_trace_file )
goto LABEL_13;
return result;
}

original_code:
void parse_args (int argc, char **argv) {
 int c;
 while ((c = getopt (argc, argv, "d:t:h")) != -1)
  switch (c) {
   case 'd' :
    inst_defn_file = strdup (optarg);
    do {fprintf(stderr, "[INFO] (%s:%d) " "Instruction Definition File set to : %s\n", "utils.c", 16, inst_defn_file); } while (0);
    break;
   case 't' :
    inst_trace_file = strdup (optarg);
    do {fprintf(stderr, "[INFO] (%s:%d) " "Instruction trace File set to : %s\n", "utils.c", 20, inst_trace_file); } while (0);
    break;
   case 'h' :
    do {fprintf(stderr, "[WARN] (%s:%d) " "Help file to come here\n", "utils.c", 23); } while (0);
    break;
   default :
    do {fprintf(stderr, "[FATAL] (%s:%d) " "Invalid command line option : -%c\n", "utils.c", 27, c); exit(-1); } while (0);
  }
 if (!inst_defn_file)
  do {fprintf(stderr, "[INFO] (%s:%d) " "Using default instruction definition file : %s\n", "utils.c", 31, inst_defn_file = strdup ("instr.def")); } while (0);
 if (!inst_trace_file)
  do {fprintf(stderr, "[INFO] (%s:%d) " "Using default instruction trace file : %s\n", "utils.c", 34, inst_trace_file = strdup ("trace")); } while (0);
}

canonical_original_code:
void parse_args(int argc, char **argv) {
 int c;
 while ((c = getopt (argc, argv, "d:t:h")) != -1)
  switch (c) {
   case 'd' :
    inst_defn_file = strdup (optarg);
    do {fprintf(stderr, "[INFO] (%s:%d) " "Instruction Definition File set to : %s\n", "utils.c", 16, inst_defn_file); } while (0);
    break;
   case 't' :
    inst_trace_file = strdup (optarg);
    do {fprintf(stderr, "[INFO] (%s:%d) " "Instruction trace File set to : %s\n", "utils.c", 20, inst_trace_file); } while (0);
    break;
   case 'h' :
    do {fprintf(stderr, "[WARN] (%s:%d) " "Help file to come here\n", "utils.c", 23); } while (0);
    break;
   default :
    do {fprintf(stderr, "[FATAL] (%s:%d) " "Invalid command line option : -%c\n", "utils.c", 27, c); exit(-1); } while (0);
  }
 if (!inst_defn_file)
  do {fprintf(stderr, "[INFO] (%s:%d) " "Using default instruction definition file : %s\n", "utils.c", 31, inst_defn_file = strdup ("instr.def")); } while (0);
 if (!inst_trace_file)
  do {fprintf(stderr, "[INFO] (%s:%d) " "Using default instruction trace file : %s\n", "utils.c", 34, inst_trace_file = strdup ("trace")); } while (0);
}

variable_types: c int


finish

decompiled_code:
void finish()
{
int v0; // eax
bool v1; // zf
__int64 i; // rax

v0 = instr_count;
if ( !instr_count )
goto LABEL_5;
do
{
free(*((void **)iq + 8 * (__int64)v0));
free(*((void **)iq + 8 * (__int64)instr_count + 1));
free(*((void **)iq + 8 * (__int64)instr_count + 2));
free(*((void **)iq + 8 * (__int64)instr_count + 3));
v1 = instr_count == 1;
v0 = --instr_count;
}
while ( !v1 );
for ( i = op_count; op_count; i = op_count )
{
op_count = i - 1;
free(*((void **)ops + 3 * i));
LABEL_5:
;
}
free(iq);
free(ops);
free(inst_trace_file);
free(inst_defn_file);
}

canonical_decompiled_code:
void func1()
{
int v0; // eax
bool v1; // zf
__int64 i; // rax

v0 = instr_count;
if ( !instr_count )
goto LABEL_5;
do
{
free(*((void **)iq + 8 * (__int64)v0));
free(*((void **)iq + 8 * (__int64)instr_count + 1));
free(*((void **)iq + 8 * (__int64)instr_count + 2));
free(*((void **)iq + 8 * (__int64)instr_count + 3));
v1 = instr_count == 1;
v0 = --instr_count;
}
while ( !v1 );
for ( i = op_count; op_count; i = op_count )
{
op_count = i - 1;
free(*((void **)ops + 3 * i));
LABEL_5:
;
}
free(iq);
free(ops);
free(inst_trace_file);
free(inst_defn_file);
}

original_code:
void finish (void) {
 while (instr_count) {
  free (iq[instr_count].opcd);
  free (iq[instr_count].dest);
  free (iq[instr_count].src1);
  free (iq[instr_count].src2);
  instr_count--;
 }
 while (op_count)
  free (ops[op_count--].name);
 free (iq);
 free (ops);
 free (inst_trace_file);
 free (inst_defn_file);
}

canonical_original_code:
void finish() {
 while (instr_count) {
  free (iq[instr_count].opcd);
  free (iq[instr_count].dest);
  free (iq[instr_count].src1);
  free (iq[instr_count].src2);
  instr_count--;
 }
 while (op_count)
  free (ops[op_count--].name);
 free (iq);
 free (ops);
 free (inst_trace_file);
 free (inst_defn_file);
}


main

repo: harto/realpath-osx

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int result; // eax
char v4[4104]; // [rsp+0h] [rbp-1008h] BYREF

if ( argc == 2 )
{
if ( realpath(argv[1], v4) )
{
puts(v4);
result = 0;
}
else
{
fprintf(stderr, "Bad path: %s\n", v4);
result = 2;
}
}
else
{
fwrite("Usage: realpath <path>\n", 1uLL, 0x17uLL, stderr);
result = 1;
}
return result;
}

original_code:
int main(int argc, char** argv) {
  if (argc != 2) {
    fprintf(stderr, "Usage: realpath <path>\n");
    return 1;
  }
  char* path = argv[1];
  char result[4096];
  if (realpath(path, result)) {
    printf("%s\n", result);
    return 0;
  } else {
    fprintf(stderr, "Bad path: %s\n", result);
    return 2;
  }
}

canonical_original_code:
int main(int argc, char **argv) {
  if (argc != 2) {
    fprintf(stderr, "Usage: realpath <path>\n");
    return 1;
  }
  char *path = argv[1];
  char result[4096];
  if (realpath(path, result)) {
    printf("%s\n", result);
    return 0;
  } else {
    fprintf(stderr, "Bad path: %s\n", result);
    return 2;
  }
}

variable_types:
path
char *

variable_types:
result
char [4096]


repo: hartwork/mysecureshell-issues

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
const char **v3; // rbx
const char *v4; // rbp
unsigned int v5; // er12
int v6; // ebp
int v7; // ebx
key_t v8; // edi
int v9; // edi
char *v10; // rax
char *v11; // rbp

v3 = argv;
if ( argc != 2 )
return usage_constprop_0_isra_0(*v3, argv, envp);
v4 = argv[1];
if ( !strcmp(v4, "block") )
{
v5 = 0;
}
else
{
if ( strcmp(v4, "unblock") )
{
argv = (const char **)"show";
if ( !strcmp(v4, "show") )
{
v5 = 2;
goto LABEL_7;
}
return usage_constprop_0_isra_0(*v3, argv, envp);
}
v5 = 1;
}
LABEL_7:
v6 = 0;
legend();
while ( 1 )
{
v7 = v6 + 1;
fprintf(stdout, "SEGMENT %d\n", (unsigned int)(v6 + 1));
v8 = ftok("/dev/null", v6 + 1927);
if ( !v8 )
__assert_fail("segment_key != 0", "local-dos.c", 0xC2u, "main");
v9 = shmget(v8, 0x16610uLL, 950);
if ( v9 == -1 )
__assert_fail("segment_id != -1", "local-dos.c", 0xC5u, "main");
v10 = (char *)shmat(v9, 0LL, 0);
v11 = v10;
if ( v10 == (char *)-1LL )
__assert_fail("segment_address != (void *)-1", "local-dos.c", 0xC8u, "main");
process(v10 + 16, v5);
if ( shmdt(v11) == -1 )
__assert_fail("detach_res != -1", "local-dos.c", 0xCEu, "main");
if ( v7 == 3 )
break;
v6 = v7;
fputc(10, stdout);
}
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
const char **v3; // rbx
const char *v4; // rbp
unsigned int v5; // er12
int v6; // ebp
int v7; // ebx
key_t v8; // edi
int v9; // edi
char *v10; // rax
char *v11; // rbp

v3 = argv;
if ( argc != 2 )
return func10(*v3, argv, envp);
v4 = argv[1];
if ( !strcmp(v4, "block") )
{
v5 = 0;
}
else
{
if ( strcmp(v4, "unblock") )
{
argv = (const char **)"show";
if ( !strcmp(v4, "show") )
{
v5 = 2;
goto LABEL_7;
}
return func10(*v3, argv, envp);
}
v5 = 1;
}
LABEL_7:
v6 = 0;
func9();
while ( 1 )
{
v7 = v6 + 1;
fprintf(stdout, "SEGMENT %d\n", (unsigned int)(v6 + 1));
v8 = ftok("/dev/null", v6 + 1927);
if ( !v8 )
__assert_fail("segment_key != 0", "local-dos.c", 0xC2u, "main");
v9 = shmget(v8, 0x16610uLL, 950);
if ( v9 == -1 )
__assert_fail("segment_id != -1", "local-dos.c", 0xC5u, "main");
v10 = (char *)shmat(v9, 0LL, 0);
v11 = v10;
if ( v10 == (char *)-1LL )
__assert_fail("segment_address != (void *)-1", "local-dos.c", 0xC8u, "main");
func8(v10 + 16, v5);
if ( shmdt(v11) == -1 )
__assert_fail("detach_res != -1", "local-dos.c", 0xCEu, "main");
if ( v7 == 3 )
break;
v6 = v7;
fputc(10, stdout);
}
return 0;
}

original_code:
int main(int argc, char ** argv) {
 if (argc != 2) {
  return usage(argc, argv);
 }
 ((argc == 2) ? (void) (0) : __assert_fail ("argc == 2", "local-dos.c", 176, __extension__ __PRETTY_FUNCTION__));
 task_t task = TASK_SHOW;
 if (strcmp(argv[1], "block") == 0) {
  task = TASK_BLOCK;
 } else if (strcmp(argv[1], "unblock") == 0) {
  task = TASK_UNBLOCK;
 } else if (strcmp(argv[1], "show") == 0) {
 } else {
  return usage(argc, argv);
 }
 legend();
 int project_id_offset = 0;
 for (; project_id_offset < 3; project_id_offset++) {
  fprintf(stdout, "SEGMENT %d\n", project_id_offset + 1);
  const key_t segment_key = ftok(_shmfile, _shmkey + project_id_offset);
  ((segment_key != 0) ? (void) (0) : __assert_fail ("segment_key != 0", "local-dos.c", 194, __extension__ __PRETTY_FUNCTION__));
  const int segment_id = shmget(segment_key, sizeof(t_shm), 01000 | 0666);
  ((segment_id != -1) ? (void) (0) : __assert_fail ("segment_id != -1", "local-dos.c", 197, __extension__ __PRETTY_FUNCTION__));
  void * const segment_address = shmat(segment_id, 0, 0);
  ((segment_address != (void *)-1) ? (void) (0) : __assert_fail ("segment_address != (void *)-1", "local-dos.c", 200, __extension__ __PRETTY_FUNCTION__));
  t_sftpwho * const who = ((t_shm *)segment_address)->who;
  process(who, task);
  const int detach_res = shmdt(segment_address);
  ((detach_res != -1) ? (void) (0) : __assert_fail ("detach_res != -1", "local-dos.c", 206, __extension__ __PRETTY_FUNCTION__));
  if (project_id_offset < 3 - 1) {
   fprintf(stdout, "\n");
  }
 }
 return 0;
}

canonical_original_code:
int main(int argc, char **argv) {
 if (argc != 2) {
  return usage(argc, argv);
 }
 ((argc == 2) ? (void) (0) : __assert_fail ("argc == 2", "local-dos.c", 176, __extension__ __PRETTY_FUNCTION__));
 enum _task_t task = TASK_SHOW;
 if (strcmp(argv[1], "block") == 0) {
  task = TASK_BLOCK;
 } else if (strcmp(argv[1], "unblock") == 0) {
  task = TASK_UNBLOCK;
 } else if (strcmp(argv[1], "show") == 0) {
 } else {
  return usage(argc, argv);
 }
 legend();
 int project_id_offset = 0;
 for (; project_id_offset < 3; project_id_offset++) {
  fprintf(stdout, "SEGMENT %d\n", project_id_offset + 1);
  int segment_key = ftok(_shmfile, _shmkey + project_id_offset);
  ((segment_key != 0) ? (void) (0) : __assert_fail ("segment_key != 0", "local-dos.c", 194, __extension__ __PRETTY_FUNCTION__));
  int segment_id = shmget(segment_key, sizeof(t_shm), 01000 | 0666);
  ((segment_id != -1) ? (void) (0) : __assert_fail ("segment_id != -1", "local-dos.c", 197, __extension__ __PRETTY_FUNCTION__));
  void *segment_address = shmat(segment_id, 0, 0);
  ((segment_address != (void *)-1) ? (void) (0) : __assert_fail ("segment_address != (void *)-1", "local-dos.c", 200, __extension__ __PRETTY_FUNCTION__));
  struct s_sftpwho *who = ((t_shm *)segment_address)->who;
  process(who, task);
  int detach_res = shmdt(segment_address);
  ((detach_res != -1) ? (void) (0) : __assert_fail ("detach_res != -1", "local-dos.c", 206, __extension__ __PRETTY_FUNCTION__));
  if (project_id_offset < 3 - 1) {
   fprintf(stdout, "\n");
  }
 }
 return 0;
}

variable_types: enum _task_t { TASK_BLOCK=0, TASK_UNBLOCK=1, TASK_SHOW=2 }

variable_types: struct s_sftpwho { char user[30]; char ip[30]; char path[200]; char file[200]; char home[196]; unsigned int status; unsigned int pid; unsigned int mode; unsigned int download_pos; unsigned int download_current; unsigned int download_total; unsigned int download_max; unsigned int upload_current; unsigned int upload_total; unsigned int upload_max; unsigned int time_maxidle; unsigned int time_maxlife; unsigned int time_idle; unsigned int time_total; unsigned int time_begin; unsigned int time_transf; } *


decompiled_code:
int __fastcall print_status(int a1, int a2)
{
int v2; // er8

v2 = 46;
if ( a1 )
{
v2 = 67;
if ( a1 == 3 && a2 == -1 )
v2 = 47;
}
return fputc(v2, stdout);
}

canonical_decompiled_code:
int __fastcall func7(int a1, int a2)
{
int v2; // er8

v2 = 46;
if ( a1 )
{
v2 = 67;
if ( a1 == 3 && a2 == -1 )
v2 = 47;
}
return fputc(v2, stdout);
}

original_code:
static void print_status(u_int32_t status, u_int32_t pid) {
 char char_to_print;
 switch (status) {
 case 0:
  char_to_print = '.';
  break;
 case 3:
  if (pid == ((u_int32_t)-1)) {
   char_to_print = '/';
  } else {
   char_to_print = 'C';
  }
  break;
 default:
  char_to_print = 'C';
  break;
 }
 fprintf(stdout, "%c", char_to_print);
}

canonical_original_code:
static void print_status(unsigned int status, unsigned int pid) {
 char char_to_print;
 switch (status) {
 case 0:
  char_to_print = '.';
  break;
 case 3:
  if (pid == ((u_int32_t)-1)) {
   char_to_print = '/';
  } else {
   char_to_print = 'C';
  }
  break;
 default:
  char_to_print = 'C';
  break;
 }
 fprintf(stdout, "%c", char_to_print);
}

variable_types:
status
unsigned int

variable_types:
pid
unsigned int


process

original_code:
static void process(t_sftpwho * who, task_t task) {
 size_t i = 0;
 for (; i < 128; i++) {
  if ((i > 0) && (i % 64 == 0)) {
   fprintf(stdout, "\n");
  }
  switch (task) {
  case TASK_BLOCK:
   if (who[i].status == 0) {
    who[i].status = 3;
    who[i].pid = ((u_int32_t)-1);
    who[i].time_begin = ((u_int32_t)-1) - 10;
    who[i].time_total = 0;
   }
   break;
  case TASK_UNBLOCK:
   if ((who[i].status == 3)
     && (who[i].pid == ((u_int32_t)-1))) {
    who[i].pid = 0;
    who[i].time_begin = 0;
    who[i].time_total = 0;
    who[i].status = 0;
   }
   break;
  default:
   break;
  }
  print_status(who[i].status, who[i].pid);
 }
 fprintf(stdout, "\n");
}

canonical_original_code:
static void process(struct s_sftpwho *who, enum _task_t task) {
 unsigned long i = 0;
 for (; i < 128; i++) {
  if ((i > 0) && (i % 64 == 0)) {
   fprintf(stdout, "\n");
  }
  switch (task) {
  case TASK_BLOCK:
   if (who[i].status == 0) {
    who[i].status = 3;
    who[i].pid = ((u_int32_t)-1);
    who[i].time_begin = ((u_int32_t)-1) - 10;
    who[i].time_total = 0;
   }
   break;
  case TASK_UNBLOCK:
   if ((who[i].status == 3)
     && (who[i].pid == ((u_int32_t)-1))) {
    who[i].pid = 0;
    who[i].time_begin = 0;
    who[i].time_total = 0;
    who[i].status = 0;
   }
   break;
  default:
   break;
  }
  print_status(who[i].status, who[i].pid);
 }
 fprintf(stdout, "\n");
}

variable_types:
i
unsigned long

user_defined_types: enum _task_t { TASK_BLOCK=0, TASK_UNBLOCK=1, TASK_SHOW=2 }

user_defined_types: struct s_sftpwho { char user[30]; char ip[30]; char path[200]; char file[200]; char home[196]; unsigned int status; unsigned int pid; unsigned int mode; unsigned int download_pos; unsigned int download_current; unsigned int download_total; unsigned int download_max; unsigned int upload_current; unsigned int upload_total; unsigned int upload_max; unsigned int time_maxidle; unsigned int time_maxlife; unsigned int time_idle; unsigned int time_total; unsigned int time_begin; unsigned int time_transf; }


legend

decompiled_code:
int legend()
{
fwrite("LEGEND\n", 1uLL, 7uLL, stdout);
fprintf(stdout, " %c = used by a client\n", 67LL);
fprintf(stdout, " %c = blocked\n", 47LL);
fprintf(stdout, " %c = unused\n", 46LL);
return fputc(10, stdout);
}

canonical_decompiled_code:
int func9()
{
fwrite("LEGEND\n", 1uLL, 7uLL, stdout);
fprintf(stdout, " %c = used by a client\n", 67LL);
fprintf(stdout, " %c = blocked\n", 47LL);
fprintf(stdout, " %c = unused\n", 46LL);
return fputc(10, stdout);
}

original_code:
static void legend() {
 fprintf(stdout, "LEGEND\n");
 fprintf(stdout, "  %c = used by a client\n", 'C');
 fprintf(stdout, "  %c = blocked\n", '/');
 fprintf(stdout, "  %c = unused\n", '.');
 fprintf(stdout, "\n");
}


repo: hashmal/shirka

decompiled_code:
char *__fastcall symbol_id_from_string(char *src)
{
char *v1; // rbx
char *v2; // r12
char *result; // rax
char *v4; // r12

v1 = symbol_list;
if ( symbol_list )
{
v2 = symbol_list;
while ( strcmp(src, v2) )
{
v2 = (char *)*((_QWORD *)v2 + 32);
if ( !v2 )
goto LABEL_6;
}
result = v2;
}
else
{
LABEL_6:
v4 = (char *)malloc(0x108uLL);
strcpy(v4, src);
*((_QWORD *)v4 + 32) = v1;
result = v4;
symbol_list = v4;
}
return result;
}

canonical_decompiled_code:
char *__fastcall func0(char *src)
{
char *v1; // rbx
char *v2; // r12
char *result; // rax
char *v4; // r12

v1 = symbol_list;
if ( symbol_list )
{
v2 = symbol_list;
while ( strcmp(src, v2) )
{
v2 = (char *)*((_QWORD *)v2 + 32);
if ( !v2 )
goto LABEL_6;
}
result = v2;
}
else
{
LABEL_6:
v4 = (char *)malloc(0x108uLL);
strcpy(v4, src);
*((_QWORD *)v4 + 32) = v1;
result = v4;
symbol_list = v4;
}
return result;
}

original_code:
symbol *symbol_id_from_string (char *str)
{
 symbol *sym = symbol_list;
 while (sym) {
  if (strcmp(str, sym->name) == 0) {
   goto symbol_found;
  }
  sym = sym->next;
 }
 sym = malloc(sizeof(symbol));
 strcpy(sym->name, str);
 sym->next = symbol_list;
 symbol_list = sym;
symbol_found:
 return sym;
}

canonical_original_code:
struct symbol *symbol_id_from_string(char *str)
{
 struct symbol *sym = symbol_list;
 while (sym) {
  if (strcmp(str, sym->name) == 0) {
   goto symbol_found;
  }
  sym = sym->next;
 }
 sym = malloc(sizeof(symbol));
 strcpy(sym->name, str);
 sym->next = symbol_list;
 symbol_list = sym;
symbol_found:
 return sym;
}

variable_types:
str
char *

variable_types: struct symbol { char name[256]; struct symbol *next; } *


decompiled_code:
void __fastcall skO_free(__int64 a1)
{
unsigned int v2; // eax
_QWORD *v3; // rbx
_QWORD *v4; // rdi

v2 = *(_DWORD *)(a1 + 8);
if ( v2 > 4 )
{
if ( v2 != 5 )
{
fwrite("Internal type error.\n", 1uLL, 0x15uLL, stderr);
exit(1);
}
v3 = *(_QWORD **)(a1 + 16);
while ( v3 )
{
v4 = v3;
v3 = (_QWORD *)*v3;
skO_free(v4);
}
}
free((void *)a1);
}

canonical_decompiled_code:
void __fastcall func1(__int64 a1)
{
unsigned int v2; // eax
_QWORD *v3; // rbx
_QWORD *v4; // rdi

v2 = *(_DWORD *)(a1 + 8);
if ( v2 > 4 )
{
if ( v2 != 5 )
{
fwrite("Internal type error.\n", 1uLL, 0x15uLL, stderr);
exit(1);
}
v3 = *(_QWORD **)(a1 + 16);
while ( v3 )
{
v4 = v3;
v3 = (_QWORD *)*v3;
func1(v4);
}
}
free((void *)a1);
}

original_code:
void skO_free (skO *obj)
{
 skO *node;
 skO *next;
 switch (obj->tag) {
 case SKO_LIST:
  node = obj->data.list;
  while (node) {
   next = node->next;
   skO_free(node);
   node = next;
  }
 case SKO_SYMBOL:
 case SKO_QSYMBOL:
 case SKO_NUMBER:
 case SKO_BOOLEAN:
 case SKO_CHARACTER:
  free (obj);
  break;
 default:
  fprintf(stderr, "Internal type error.\n");
  exit(1);
  break;
 }
}

canonical_original_code:
void skO_free(struct skO *obj)
{
 struct skO *node;
 struct skO *next;
 switch (obj->tag) {
 case SKO_LIST:
  node = obj->data.list;
  while (node) {
   next = node->next;
   skO_free(node);
   node = next;
  }
 case SKO_SYMBOL:
 case SKO_QSYMBOL:
 case SKO_NUMBER:
 case SKO_BOOLEAN:
 case SKO_CHARACTER:
  free (obj);
  break;
 default:
  fprintf(stderr, "Internal type error.\n");
  exit(1);
  break;
 }
}

variable_types: struct skO { struct skO *next; enum skO_t { SKO_NUMBER=0, SKO_BOOLEAN=1, SKO_CHARACTER=2, SKO_QSYMBOL=3, SKO_SYMBOL=4, SKO_LIST=5 } tag; union { double number; int boolean; char character; struct symbol { char name[256]; struct symbol *next; } *sym; struct skO *list; } data; } *

user_defined_types: struct skO { struct skO *next; enum skO_t tag; union { double number; int boolean; char character; struct symbol *sym; struct skO *list; } data; }


decompiled_code:
double *__fastcall skO_number_new(double a1)
{
double *result; // rax

result = (double *)malloc(0x18uLL);
*result = 0.0;
*((_DWORD *)result + 2) = 0;
result[2] = a1;
return result;
}

canonical_decompiled_code:
double *__fastcall func2(double a1)
{
double *result; // rax

result = (double *)malloc(0x18uLL);
*result = 0.0;
*((_DWORD *)result + 2) = 0;
result[2] = a1;
return result;
}

original_code:
skO *skO_number_new (double d)
{
 skO *obj = malloc(sizeof(skO));
 obj->next = ((void *)0);
 obj->tag = SKO_NUMBER;
 obj->data.number = d;
 return obj;
}

canonical_original_code:
struct skO *skO_number_new(double d)
{
 struct skO *obj = malloc(sizeof(skO));
 obj->next = ((void *)0);
 obj->tag = SKO_NUMBER;
 obj->data.number = d;
 return obj;
}

variable_types: d double

return_type: struct skO { struct skO *next; enum skO_t { SKO_NUMBER=0, SKO_BOOLEAN=1, SKO_CHARACTER=2, SKO_QSYMBOL=3, SKO_SYMBOL=4, SKO_LIST=5 } tag; union { double number; int boolean; char character; struct symbol { char name[256]; struct symbol *next; } *sym; struct skO *list; } data; } *


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

result = malloc(0x18uLL);
*(_QWORD *)result = 0LL;
result[2] = 5;
*((_QWORD *)result + 2) = 0LL;
return result;
}

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

result = malloc(0x18uLL);
*(_QWORD *)result = 0LL;
result[2] = 5;
*((_QWORD *)result + 2) = 0LL;
return result;
}

original_code:
skO *skO_list_new (void)
{
 skO *obj = malloc(sizeof(skO));
 obj->next = ((void *)0);
 obj->tag = SKO_LIST;
 obj->data.list = ((void *)0);
 return obj;
}

canonical_original_code:
struct skO *skO_list_new()
{
 struct skO *obj = malloc(sizeof(skO));
 obj->next = ((void *)0);
 obj->tag = SKO_LIST;
 obj->data.list = ((void *)0);
 return obj;
}

user_defined_types: enum skO_t { SKO_NUMBER=0, SKO_BOOLEAN=1, SKO_CHARACTER=2, SKO_QSYMBOL=3, SKO_SYMBOL=4, SKO_LIST=5 }

user_defined_types: struct symbol { char name[256]; struct symbol *next; }


tystr

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

switch ( a1 )
{
case 0LL:
result = NUMBER_AS_STRING;
break;
case 1LL:
result = BOOLEAN_AS_STRING;
break;
case 2LL:
result = CHARACTER_AS_STRING;
break;
case 3LL:
result = QSYMBOL_AS_STRING;
break;
case 4LL:
result = SYMBOL_AS_STRING;
break;
case 5LL:
result = LIST_AS_STRING;
break;
default:
fwrite("Internal type error.\n", 1uLL, 0x15uLL, stderr);
exit(1);
}
return result;
}

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

switch ( a1 )
{
case 0LL:
result = NUMBER_AS_STRING;
break;
case 1LL:
result = BOOLEAN_AS_STRING;
break;
case 2LL:
result = CHARACTER_AS_STRING;
break;
case 3LL:
result = QSYMBOL_AS_STRING;
break;
case 4LL:
result = SYMBOL_AS_STRING;
break;
case 5LL:
result = LIST_AS_STRING;
break;
default:
fwrite("Internal type error.\n", 1uLL, 0x15uLL, stderr);
exit(1);
}
return result;
}

original_code:
const char *tystr (size_t i)
{
 switch (i) {
 case SKO_NUMBER: return NUMBER_AS_STRING;
 case SKO_BOOLEAN: return BOOLEAN_AS_STRING;
 case SKO_CHARACTER: return CHARACTER_AS_STRING;
 case SKO_QSYMBOL: return QSYMBOL_AS_STRING;
 case SKO_SYMBOL: return SYMBOL_AS_STRING;
 case SKO_LIST: return LIST_AS_STRING;
 default:
  fprintf(stderr, "Internal type error.\n");
  exit(1);
 }
}

canonical_original_code:
char *tystr(unsigned long i)
{
 switch (i) {
 case SKO_NUMBER: return NUMBER_AS_STRING;
 case SKO_BOOLEAN: return BOOLEAN_AS_STRING;
 case SKO_CHARACTER: return CHARACTER_AS_STRING;
 case SKO_QSYMBOL: return QSYMBOL_AS_STRING;
 case SKO_SYMBOL: return SYMBOL_AS_STRING;
 case SKO_LIST: return LIST_AS_STRING;
 default:
  fprintf(stderr, "Internal type error.\n");
  exit(1);
 }
}

return_type: char *


decompiled_code:
__int64 __fastcall skO_checkType(__int64 a1, unsigned int a2)
{
__int64 result; // rax
char *v3; // r12
char *v4; // rax

result = *(unsigned int *)(a1 + 8);
if ( (_DWORD)result != a2 )
{
v3 = tystr((unsigned int)result);
v4 = tystr(a2);
fprintf(stderr, "INTERPRETER ERROR! Expected `%s' but got `%s'.\n", v4, v3);
exit(1);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1, unsigned int a2)
{
__int64 result; // rax
char *v3; // r12
char *v4; // rax

result = *(unsigned int *)(a1 + 8);
if ( (_DWORD)result != a2 )
{
v3 = func4((unsigned int)result);
v4 = func4(a2);
fprintf(stderr, "INTERPRETER ERROR! Expected `%s' but got `%s'.\n", v4, v3);
exit(1);
}
return result;
}

original_code:
void skO_checkType(skO *obj, skO_t type)
{
 if (obj->tag == type)
  return;
 fprintf(stderr, "INTERPRETER ERROR! Expected `%s' but got `%s'.\n",
  tystr(type), tystr(obj->tag));
 exit(1);
}

canonical_original_code:
void skO_checkType(struct skO *obj, enum skO_t type)
{
 if (obj->tag == type)
  return;
 fprintf(stderr, "INTERPRETER ERROR! Expected `%s' but got `%s'.\n",
  tystr(type), tystr(obj->tag));
 exit(1);
}

variable_types: enum skO_t { SKO_NUMBER=0, SKO_BOOLEAN=1, SKO_CHARACTER=2, SKO_QSYMBOL=3, SKO_SYMBOL=4, SKO_LIST=5 }


original_code:
void consume_leading (char **next)
{
 char *c = *next;
 while (*c != 0) {
  if (((*__ctype_b_loc ())[(int) ((*c))] & (unsigned short int) _ISspace)) {
   c++;
  } else if (c[0] == '-' && c[1] == '-') {
   while (*c != '\n' && *c != 0)
    c++;
  } else {
   break;
  }
 }
 *next = c;
}

canonical_original_code:
void consume_leading(char **next)
{
 char *c = *next;
 while (*c != 0) {
  if (((*__ctype_b_loc ())[(int) ((*c))] & (unsigned short) _ISspace)) {
   c++;
  } else if (c[0] == '-' && c[1] == '-') {
   while (*c != '\n' && *c != 0)
    c++;
  } else {
   break;
  }
 }
 *next = c;
}

variable_types:
next
char **

variable_types:
c
char *


original_code:
skO *parse_number (char **next)
{
 char *c = *next;
 char buffer[256];
 short i = 0;
 if (*c == '-' && c[1] >= '0' && c[1] <= '9') {
  buffer[i] = *c;
  i++;
  c++;
 }
 if (*c == '.')
  return ((void *)0);
 while (1) {
  if (!((*__ctype_b_loc ())[(int) ((*c))] & (unsigned short int) _ISdigit))
   break;
  buffer[i] = *c;
  i++;
  c++;
 }
 if (*c == '.') {
  buffer[i] = *c;
  i++;
  c++;
  while (1) {
   if (!((*__ctype_b_loc ())[(int) ((*c))] & (unsigned short int) _ISdigit))
    break;
   buffer[i] = *c;
   i++;
   c++;
  }
 }
 buffer[i] = 0;
 if ((((*__ctype_b_loc ())[(int) ((*c))] & (unsigned short int) _ISspace) || *c == '[' || *c == ']' || *c == '(' || *c == ')' || *c == 0) && i) {
  char **dummy = ((void *)0);
  *next = c;
  return skO_number_new(strtod(buffer, dummy));
 } else {
  return ((void *)0);
 }
}

canonical_original_code:
struct skO *parse_number(char **next)
{
 char *c = *next;
 char buffer[256];
 short i = 0;
 if (*c == '-' && c[1] >= '0' && c[1] <= '9') {
  buffer[i] = *c;
  i++;
  c++;
 }
 if (*c == '.')
  return ((void *)0);
 while (1) {
  if (!((*__ctype_b_loc ())[(int) ((*c))] & (unsigned short) _ISdigit))
   break;
  buffer[i] = *c;
  i++;
  c++;
 }
 if (*c == '.') {
  buffer[i] = *c;
  i++;
  c++;
  while (1) {
   if (!((*__ctype_b_loc ())[(int) ((*c))] & (unsigned short) _ISdigit))
    break;
   buffer[i] = *c;
   i++;
   c++;
  }
 }
 buffer[i] = 0;
 if ((((*__ctype_b_loc ())[(int) ((*c))] & (unsigned short) _ISspace) || *c == '[' || *c == ']' || *c == '(' || *c == ')' || *c == 0) && i) {
  char **dummy = ((void *)0);
  *next = c;
  return skO_number_new(strtod(buffer, dummy));
 } else {
  return ((void *)0);
 }
}

variable_types:
buffer
char [256]

variable_types: i short

variable_types:
dummy
char **


decompiled_code:
__int64 __fastcall parse_character(char **a1)
{
char *v1; // rcx
char v2; // dl
char *v3; // rax
char v4; // cl
unsigned int v5; // er8

v1 = *a1;
v2 = **a1;
if ( v2 == 92 )
{
v3 = v1 + 1;
v4 = v1[1];
if ( v4 == 34 )
{
v5 = 34;
}
else
{
switch ( v4 )
{
case '\\':
v5 = 92;
break;
case 'a':
v5 = 7;
break;
case 'b':
v5 = 8;
break;
case 'f':
v5 = 12;
break;
case 'n':
v5 = 10;
break;
case 'r':
v5 = 13;
break;
case 's':
v5 = 32;
break;
case 't':
v5 = 9;
break;
case 'v':
v5 = 11;
break;
default:
fprintf(stderr, "PANIC! Unknown escape sequence \\%c.\n", (unsigned int)v4);
exit(1);
}
}
}
else
{
v5 = v2;
v3 = *a1;
}
*a1 = v3 + 1;
return skO_character_new(v5);
}

canonical_decompiled_code:
__int64 __fastcall func2(char **a1)
{
char *v1; // rcx
char v2; // dl
char *v3; // rax
char v4; // cl
unsigned int v5; // er8

v1 = *a1;
v2 = **a1;
if ( v2 == 92 )
{
v3 = v1 + 1;
v4 = v1[1];
if ( v4 == 34 )
{
v5 = 34;
}
else
{
switch ( v4 )
{
case '\\':
v5 = 92;
break;
case 'a':
v5 = 7;
break;
case 'b':
v5 = 8;
break;
case 'f':
v5 = 12;
break;
case 'n':
v5 = 10;
break;
case 'r':
v5 = 13;
break;
case 's':
v5 = 32;
break;
case 't':
v5 = 9;
break;
case 'v':
v5 = 11;
break;
default:
fprintf(stderr, "PANIC! Unknown escape sequence \\%c.\n", (unsigned int)v4);
exit(1);
}
}
}
else
{
v5 = v2;
v3 = *a1;
}
*a1 = v3 + 1;
return skO_character_new(v5);
}

original_code:
skO *parse_character (char **next, jmp_buf jmp)
{
 char *c = *next;
 char result = 0;
 if (*c == '\\') {
  c++;
  switch (*c) {
  case '\\':
   result = '\\';
   break;
  case '"':
   result = '"';
   break;
  case 'a':
   result = '\a';
   break;
  case 'b':
   result = '\b';
   break;
  case 'f':
   result = '\f';
   break;
  case 'n':
   result = '\n';
   break;
  case 'r':
   result = '\r';
   break;
  case 's':
   result = ' ';
   break;
  case 't':
   result = '\t';
   break;
  case 'v':
   result = '\v';
   break;
  default:
   do { fprintf (stderr, "PANIC! Unknown escape sequence \\%c.\n", *c); exit(1); } while (0);
   longjmp(jmp, 1);
  }
 } else {
  result = *c;
 }
 c++;
 *next = c;
 return skO_character_new(result);
}

canonical_original_code:
struct skO *parse_character(char **next, struct __jmp_buf_tag jmp[1])
{
 char *c = *next;
 char result = 0;
 if (*c == '\\') {
  c++;
  switch (*c) {
  case '\\':
   result = '\\';
   break;
  case '"':
   result = '"';
   break;
  case 'a':
   result = '\a';
   break;
  case 'b':
   result = '\b';
   break;
  case 'f':
   result = '\f';
   break;
  case 'n':
   result = '\n';
   break;
  case 'r':
   result = '\r';
   break;
  case 's':
   result = ' ';
   break;
  case 't':
   result = '\t';
   break;
  case 'v':
   result = '\v';
   break;
  default:
   do { fprintf (stderr, "PANIC! Unknown escape sequence \\%c.\n", *c); exit(1); } while (0);
   longjmp(jmp, 1);
  }
 } else {
  result = *c;
 }
 c++;
 *next = c;
 return skO_character_new(result);
}

variable_types: struct __jmp_buf_tag { long __jmpbuf[8]; int __mask_was_saved; struct __sigset_t { unsigned long __val[-1]; } __saved_mask; } [1]

variable_types: result char

user_defined_types: struct __jmp_buf_tag { long __jmpbuf[8]; int __mask_was_saved; struct __sigset_t __saved_mask; }


decompiled_code:
__int64 __fastcall parse_character_literal(char **a1)
{
if ( **a1 != 39 )
return 0LL;
++*a1;
return parse_character(a1);
}

canonical_decompiled_code:
__int64 __fastcall func3(char **a1)
{
if ( **a1 != 39 )
return 0LL;
++*a1;
return func2(a1);
}

original_code:
skO *parse_character_literal (char **next, jmp_buf jmp)
{
 if (**next != '\'')
  return ((void *)0);
 ++*next;
 return parse_character(next, jmp);
}

canonical_original_code:
struct skO *parse_character_literal(char **next, struct __jmp_buf_tag jmp[1])
{
 if (**next != '\'')
  return ((void *)0);
 ++*next;
 return parse_character(next, jmp);
}

user_defined_types: struct __sigset_t { unsigned long __val[-1]; }


decompiled_code:
__int64 __fastcall parse_op_def(char **a1)
{
__int64 v1; // r8
char *v2; // rax
__int64 result; // rax
char *v4[2]; // [rsp+8h] [rbp-10h] BYREF

v1 = 0LL;
v2 = *a1;
v4[0] = v2;
if ( *v2 != 61 )
return v1;
if ( v2[1] != 62 )
return v1;
v4[0] = v2 + 2;
consume_leading(v4);
result = parse_identifier(v4);
v1 = result;
if ( !result )
return v1;
*a1 = v4[0];
*(_DWORD *)(result + 8) = 3;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func6(char **a1)
{
__int64 v1; // r8
char *v2; // rax
__int64 result; // rax
char *v4[2]; // [rsp+8h] [rbp-10h] BYREF

v1 = 0LL;
v2 = *a1;
v4[0] = v2;
if ( *v2 != 61 )
return v1;
if ( v2[1] != 62 )
return v1;
v4[0] = v2 + 2;
func0(v4);
result = func5(v4);
v1 = result;
if ( !result )
return v1;
*a1 = v4[0];
*(_DWORD *)(result + 8) = 3;
return result;
}

original_code:
skO *parse_op_def (char **next)
{
 char *src = *next;
 skO *sym;
 if (src[0] == '=' && src[1] == '>') {
  src++;
  src++;
  consume_leading(&src);
  sym = parse_identifier(&src);
  if (sym) {
   *next = src;
   sym->tag = SKO_QSYMBOL;
   return(sym);
  }
 }
 return ((void *)0);
}

canonical_original_code:
struct skO *parse_op_def(char **next)
{
 char *src = *next;
 struct skO *sym;
 if (src[0] == '=' && src[1] == '>') {
  src++;
  src++;
  consume_leading(&src);
  sym = parse_identifier(&src);
  if (sym) {
   *next = src;
   sym->tag = SKO_QSYMBOL;
   return(sym);
  }
 }
 return ((void *)0);
}

variable_types:
src
char *


decompiled_code:
__int64 __fastcall parse_obj_reserve(char **a1)
{
__int64 v1; // r8
char *v2; // rax
__int64 result; // rax
char *v4[2]; // [rsp+8h] [rbp-10h] BYREF

v1 = 0LL;
v2 = *a1;
v4[0] = v2;
if ( *v2 != 45 )
return v1;
if ( v2[1] != 62 )
return v1;
v4[0] = v2 + 2;
consume_leading(v4);
result = parse_identifier(v4);
v1 = result;
if ( !result )
return v1;
*a1 = v4[0];
*(_DWORD *)(result + 8) = 3;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func7(char **a1)
{
__int64 v1; // r8
char *v2; // rax
__int64 result; // rax
char *v4[2]; // [rsp+8h] [rbp-10h] BYREF

v1 = 0LL;
v2 = *a1;
v4[0] = v2;
if ( *v2 != 45 )
return v1;
if ( v2[1] != 62 )
return v1;
v4[0] = v2 + 2;
func0(v4);
result = func5(v4);
v1 = result;
if ( !result )
return v1;
*a1 = v4[0];
*(_DWORD *)(result + 8) = 3;
return result;
}

original_code:
skO *parse_obj_reserve (char **next)
{
 char *src = *next;
 skO *sym;
 if (src[0] == '-' && src[1] == '>') {
  src++;
  src++;
  consume_leading(&src);
  sym = parse_identifier(&src);
  if (sym) {
   *next = src;
   sym->tag = SKO_QSYMBOL;
   return(sym);
  }
 }
 return ((void *)0);
}

canonical_original_code:
struct skO *parse_obj_reserve(char **next)
{
 char *src = *next;
 struct skO *sym;
 if (src[0] == '-' && src[1] == '>') {
  src++;
  src++;
  consume_leading(&src);
  sym = parse_identifier(&src);
  if (sym) {
   *next = src;
   sym->tag = SKO_QSYMBOL;
   return(sym);
  }
 }
 return ((void *)0);
}


decompiled_code:
__int64 __fastcall parse_obj_restore(char **a1)
{
__int64 v1; // r8
char *v2; // rax
__int64 result; // rax
char *v4[2]; // [rsp+8h] [rbp-10h] BYREF

v1 = 0LL;
v2 = *a1;
v4[0] = v2;
if ( *v2 != 60 )
return v1;
if ( v2[1] != 45 )
return v1;
v4[0] = v2 + 2;
consume_leading(v4);
result = parse_identifier(v4);
v1 = result;
if ( !result )
return v1;
*a1 = v4[0];
*(_DWORD *)(result + 8) = 3;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func8(char **a1)
{
__int64 v1; // r8
char *v2; // rax
__int64 result; // rax
char *v4[2]; // [rsp+8h] [rbp-10h] BYREF

v1 = 0LL;
v2 = *a1;
v4[0] = v2;
if ( *v2 != 60 )
return v1;
if ( v2[1] != 45 )
return v1;
v4[0] = v2 + 2;
func0(v4);
result = func5(v4);
v1 = result;
if ( !result )
return v1;
*a1 = v4[0];
*(_DWORD *)(result + 8) = 3;
return result;
}

original_code:
skO *parse_obj_restore (char **next)
{
 char *src = *next;
 skO *sym;
 if (src[0] == '<' && src[1] == '-') {
  src++;
  src++;
  consume_leading(&src);
  sym = parse_identifier(&src);
  if (sym) {
   *next = src;
   sym->tag = SKO_QSYMBOL;
   return(sym);
  }
 }
 return ((void *)0);
}

canonical_original_code:
struct skO *parse_obj_restore(char **next)
{
 char *src = *next;
 struct skO *sym;
 if (src[0] == '<' && src[1] == '-') {
  src++;
  src++;
  consume_leading(&src);
  sym = parse_identifier(&src);
  if (sym) {
   *next = src;
   sym->tag = SKO_QSYMBOL;
   return(sym);
  }
 }
 return ((void *)0);
}


decompiled_code:
__int64 __fastcall parse_string_literal(char **a1)
{
__int64 v1; // r12
char *i; // rax
__int64 v3; // rax

v1 = 0LL;
if ( **a1 == 34 )
{
++*a1;
v1 = skO_list_new();
for ( i = *a1; **a1 != 34; i = *a1 )
{
v3 = parse_character(a1);
sk_list_append(v1, v3);
}
*a1 = i + 1;
}
return v1;
}

original_code:
skO *parse_string_literal (char **next, jmp_buf jmp)
{
 skO *list;
 if (**next != '"')
  return ((void *)0);
 ++*next;
 list = skO_list_new();
 while (**next != '"')
  sk_list_append(list, parse_character(next, jmp));
 ++*next;
 return list;
}

canonical_original_code:
struct skO *parse_string_literal(char **next, struct __jmp_buf_tag jmp[1])
{
 struct skO *list;
 if (**next != '"')
  return ((void *)0);
 ++*next;
 list = skO_list_new();
 while (**next != '"')
  sk_list_append(list, parse_character(next, jmp));
 ++*next;
 return list;
}


decompiled_code:
__int64 __fastcall skO_parse(char **a1, struct __jmp_buf_tag *a2, _BYTE *a3)
{
char v3; // dl
__int64 v4; // rsi
char *v5; // rdx
_QWORD *v6; // rbp
__int64 v7; // rsi
__int64 v8; // rsi
__int64 v9; // rax
__int64 v11; // rsi
__int64 v12; // [rsp+0h] [rbp-108h]
char *v15; // [rsp+28h] [rbp-E0h] BYREF
jmp_buf env; // [rsp+30h] [rbp-D8h] BYREF

v12 = skO_list_new();
v15 = *a1;
consume_leading(&v15);
if ( setjmp(env) )
{
skO_free(v12);
puts("parse jmp");
}
v3 = *v15;
if ( !a3 )
{
if ( !v3 )
exit(1);
while ( 1 )
{
while ( 1 )
{
LABEL_8:
consume_leading(&v15);
v5 = v15;
if ( !*v15 )
{
LABEL_21:
*a1 = v5;
return v12;
}
if ( a3 && *v15 == a3[1] )
{
v5 = v15 + 1;
goto LABEL_21;
}
v6 = (_QWORD *)skO_parse(&v15, env, "()");
if ( v6 )
consume_leading(&v15);
v7 = parse_op_def(&v15);
if ( !v7 )
break;
sk_list_append(v12, v7);
v4 = skO_symbol_new("$=>");
LABEL_7:
sk_list_append(v12, v4);
if ( v6 )
goto LABEL_16;
}
v8 = parse_obj_reserve(&v15);
if ( !v8 )
{
v11 = parse_obj_restore(&v15);
if ( v11 )
{
sk_list_append(v12, v11);
v4 = skO_symbol_new("$<-");
}
else
{
v4 = parse_string_literal(&v15);
if ( !v4 )
{
v4 = parse_number(&v15);
if ( !v4 )
{
v4 = parse_qidentifier(&v15);
if ( !v4 )
{
v4 = parse_identifier(&v15);
if ( !v4 )
{
v4 = parse_character_literal(&v15);
if ( !v4 )
{
v4 = skO_parse(&v15, env, "[]");
if ( !v4 )
{
fprintf(stderr, "PANIC! Parsing error: %s\n", v15);
longjmp(a2, 1);
}
}
}
}
}
}
}
goto LABEL_7;
}
sk_list_append(v12, v8);
v9 = skO_symbol_new("$->");
sk_list_append(v12, v9);
if ( v6 )
{
LABEL_16:
sk_list_append(v12, v6[2]);
free(v6);
}
}
}
if ( *a3 == v3 )
{
++v15;
consume_leading(&v15);
goto LABEL_8;
}
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func10(char **a1, struct __jmp_buf_tag *a2, _BYTE *a3)
{
char v3; // dl
__int64 v4; // rsi
char *v5; // rdx
_QWORD *v6; // rbp
__int64 v7; // rsi
__int64 v8; // rsi
__int64 v9; // rax
__int64 v11; // rsi
__int64 v12; // [rsp+0h] [rbp-108h]
char *v15; // [rsp+28h] [rbp-E0h] BYREF
jmp_buf env; // [rsp+30h] [rbp-D8h] BYREF

v12 = skO_list_new();
v15 = *a1;
func0(&v15);
if ( setjmp(env) )
{
skO_free(v12);
puts("parse jmp");
}
v3 = *v15;
if ( !a3 )
{
if ( !v3 )
exit(1);
while ( 1 )
{
while ( 1 )
{
LABEL_8:
func0(&v15);
v5 = v15;
if ( !*v15 )
{
LABEL_21:
*a1 = v5;
return v12;
}
if ( a3 && *v15 == a3[1] )
{
v5 = v15 + 1;
goto LABEL_21;
}
v6 = (_QWORD *)func10(&v15, env, "()");
if ( v6 )
func0(&v15);
v7 = func6(&v15);
if ( !v7 )
break;
sk_list_append(v12, v7);
v4 = skO_symbol_new("$=>");
LABEL_7:
sk_list_append(v12, v4);
if ( v6 )
goto LABEL_16;
}
v8 = func7(&v15);
if ( !v8 )
{
v11 = func8(&v15);
if ( v11 )
{
sk_list_append(v12, v11);
v4 = skO_symbol_new("$<-");
}
else
{
v4 = func9(&v15);
if ( !v4 )
{
v4 = func1(&v15);
if ( !v4 )
{
v4 = func4(&v15);
if ( !v4 )
{
v4 = func5(&v15);
if ( !v4 )
{
v4 = func3(&v15);
if ( !v4 )
{
v4 = func10(&v15, env, "[]");
if ( !v4 )
{
fprintf(stderr, "PANIC! Parsing error: %s\n", v15);
longjmp(a2, 1);
}
}
}
}
}
}
}
goto LABEL_7;
}
sk_list_append(v12, v8);
v9 = skO_symbol_new("$->");
sk_list_append(v12, v9);
if ( v6 )
{
LABEL_16:
sk_list_append(v12, v6[2]);
free(v6);
}
}
}
if ( *a3 == v3 )
{
++v15;
func0(&v15);
goto LABEL_8;
}
return 0LL;
}

original_code:
skO *skO_parse (char **next, jmp_buf jmp, char *delim)
{
 skO *obj;
 skO *list = skO_list_new();
 skO *prefixed = ((void *)0);
 char *src = *next;
 jmp_buf pe;
 int ended = 0;
 consume_leading(&src);
 if (_setjmp (pe)) {
  if (prefixed)
   free(prefixed);
  skO_free(list);
  printf("parse jmp\n");
 }
 if (delim) {
  if (*src != delim[0])
   return ((void *)0);
  src++;
  consume_leading(&src);
 } else if (*src == 0) {
  ended = 1;
  exit(1);
 }
 while (!ended) {
  consume_leading(&src);
  if (*src == 0) {
   ended = 1;
   *next = src;
   break;
  }
  if (delim) {
   if (*src == delim[1]) {
    src++;
    *next = src;
    return list;
   }
  }
  prefixed = skO_parse(&src, pe, "()");
  if (prefixed)
   consume_leading(&src);
  obj = parse_op_def(&src);
  if (obj) {
   sk_list_append(list, obj);
   obj = skO_symbol_new("$=>");
   goto matched;
  }
  obj = parse_obj_reserve(&src);
  if (obj) {
   sk_list_append(list, obj);
   obj = skO_symbol_new("$->");
   goto matched;
  }
  obj = parse_obj_restore(&src);
  if (obj) {
   sk_list_append(list, obj);
   obj = skO_symbol_new("$<-");
   goto matched;
  }
  if ((obj = parse_string_literal(&src, pe))
   || (obj = parse_number(&src))
   || (obj = parse_qidentifier(&src))
   || (obj = parse_identifier(&src))
   || (obj = parse_character_literal(&src, pe))
   || (obj = skO_parse(&src, pe, "[]")))
   goto matched;
  fprintf(stderr, "PANIC! Parsing error: %s\n", src);
  longjmp(jmp, 1);
 matched:
  sk_list_append(list, obj);
  if (prefixed) {
   sk_list_append(list, prefixed->data.list);
   free(prefixed);
   prefixed = ((void *)0);
  }
 }
 *next = src;
 return list;
}

canonical_original_code:
struct skO *skO_parse(char **next, struct __jmp_buf_tag jmp[1], char *delim)
{
 struct skO *obj;
 struct skO *list = skO_list_new();
 struct skO *prefixed = ((void *)0);
 char *src = *next;
 struct __jmp_buf_tag pe[1];
 int ended = 0;
 consume_leading(&src);
 if (_setjmp (pe)) {
  if (prefixed)
   free(prefixed);
  skO_free(list);
  printf("parse jmp\n");
 }
 if (delim) {
  if (*src != delim[0])
   return ((void *)0);
  src++;
  consume_leading(&src);
 } else if (*src == 0) {
  ended = 1;
  exit(1);
 }
 while (!ended) {
  consume_leading(&src);
  if (*src == 0) {
   ended = 1;
   *next = src;
   break;
  }
  if (delim) {
   if (*src == delim[1]) {
    src++;
    *next = src;
    return list;
   }
  }
  prefixed = skO_parse(&src, pe, "()");
  if (prefixed)
   consume_leading(&src);
  obj = parse_op_def(&src);
  if (obj) {
   sk_list_append(list, obj);
   obj = skO_symbol_new("$=>");
   goto matched;
  }
  obj = parse_obj_reserve(&src);
  if (obj) {
   sk_list_append(list, obj);
   obj = skO_symbol_new("$->");
   goto matched;
  }
  obj = parse_obj_restore(&src);
  if (obj) {
   sk_list_append(list, obj);
   obj = skO_symbol_new("$<-");
   goto matched;
  }
  if ((obj = parse_string_literal(&src, pe))
   || (obj = parse_number(&src))
   || (obj = parse_qidentifier(&src))
   || (obj = parse_identifier(&src))
   || (obj = parse_character_literal(&src, pe))
   || (obj = skO_parse(&src, pe, "[]")))
   goto matched;
  fprintf(stderr, "PANIC! Parsing error: %s\n", src);
  longjmp(jmp, 1);
 matched:
  sk_list_append(list, obj);
  if (prefixed) {
   sk_list_append(list, prefixed->data.list);
   free(prefixed);
   prefixed = ((void *)0);
  }
 }
 *next = src;
 return list;
}

variable_types:
delim
char *

variable_types: ended int


main

repo: hatsuseno/bigextract

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
void *v3; // rax
void *v4; // r12
const char *v5; // rax
int result; // eax
int v7[7]; // [rsp+Ch] [rbp-1Ch] BYREF

v3 = malloc(0x1000uLL);
v7[0] = 0;
if ( argc > 2 )
{
v4 = v3;
v5 = argv[1];
if ( *v5 == 45 )
{
switch ( v5[1] )
{
case 'd':
findFiles((char *)argv[3]);
outputMatrix(argv[2], v4, v7);
return 0;
case 'e':
case 'f':
findFiles((char *)argv[2]);
return 0;
case 'n':
findFiles((char *)argv[3]);
extractFiles((char *)argv[3]);
return 0;
case 'x':
findFiles((char *)argv[2]);
extractFiles((char *)argv[2]);
return 0;
default:
break;
}
}
}
printHelp(*argv);
return result;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
void *v3; // rax
void *v4; // r12
const char *v5; // rax
int result; // eax
int v7[7]; // [rsp+Ch] [rbp-1Ch] BYREF

v3 = malloc(0x1000uLL);
v7[0] = 0;
if ( argc > 2 )
{
v4 = v3;
v5 = argv[1];
if ( *v5 == 45 )
{
switch ( v5[1] )
{
case 'd':
func10((char *)argv[3]);
func8(argv[2], v4, v7);
return 0;
case 'e':
case 'f':
func10((char *)argv[2]);
return 0;
case 'n':
func10((char *)argv[3]);
func11((char *)argv[3]);
return 0;
case 'x':
func10((char *)argv[2]);
func11((char *)argv[2]);
return 0;
default:
break;
}
}
}
func9(*argv);
return result;
}

original_code:
int main(int argc, char **argv) {
  int *matrix = malloc(1024*sizeof(int)), fc=0;
  if(argc < 3) { printHelp(argv[0]); }
  if(argv[1][0] == '-') {
    switch(argv[1][1]) {
      case 'f': findFiles(argv[2], matrix, &fc); break;
      case 'x': findFiles(argv[2], matrix, &fc); extractFiles(argv[2], argv[2], matrix, &fc); break;
      case 'n': findFiles(argv[3], matrix, &fc); extractFiles(argv[3], argv[2], matrix, &fc); break;
      case 'd': findFiles(argv[3], matrix, &fc); outputMatrix(argv[2], matrix, &fc); break;
      case 'e': findFiles(argv[2], matrix, &fc); break;
      case 'h': printHelp(argv[0]); break;
      default : printHelp(argv[0]);
    }
  }else {
    printHelp(argv[0]);
  }
  return 0;
}

canonical_original_code:
int main(int argc, char **argv) {
  int *matrix = malloc(1024*sizeof(int)); int fc = 0;
  if(argc < 3) { printHelp(argv[0]); }
  if(argv[1][0] == '-') {
    switch(argv[1][1]) {
      case 'f': findFiles(argv[2], matrix, &fc); break;
      case 'x': findFiles(argv[2], matrix, &fc); extractFiles(argv[2], argv[2], matrix, &fc); break;
      case 'n': findFiles(argv[3], matrix, &fc); extractFiles(argv[3], argv[2], matrix, &fc); break;
      case 'd': findFiles(argv[3], matrix, &fc); outputMatrix(argv[2], matrix, &fc); break;
      case 'e': findFiles(argv[2], matrix, &fc); break;
      case 'h': printHelp(argv[0]); break;
      default : printHelp(argv[0]);
    }
  }else {
    printHelp(argv[0]);
  }
  return 0;
}

variable_types: argc int

variable_types:
argv
char **

variable_types:
matrix
int *

variable_types: fc int


printError

decompiled_code:
void __fastcall __noreturn printError(const char *a1)
{
printf("BigExtract: %s\nBigExtract: calling it a day...", a1);
exit(1);
}

canonical_decompiled_code:
void __fastcall __noreturn func7(const char *a1)
{
printf("BigExtract: %s\nBigExtract: calling it a day...", a1);
exit(1);
}

original_code:
void printError(char *emsg) {
  printf("BigExtract: %s\nBigExtract: calling it a day...", emsg);
  exit(1);
}

variable_types:
emsg
char *


printHelp

decompiled_code:
void __fastcall __noreturn printHelp(const char *a1)
{
printf("BigExtract v%s help\n", version);
puts("Released in public domain, as is");
puts("Rudolf Leermakers <rudolf@hatsuseno.org>\n");
printf(" Usage : %s <options> [filename]\n\n", a1);
puts(" -f do a normal search, if possible by index");
puts(" -x extract files");
puts(" -n name extract files to name@adress");
puts(" -d name output matrix of found files to file");
puts(" -h display this message\n");
exit(1);
}

canonical_decompiled_code:
void __fastcall __noreturn func9(const char *a1)
{
printf("BigExtract v%s help\n", version);
puts("Released in public domain, as is");
puts("Rudolf Leermakers <rudolf@hatsuseno.org>\n");
printf(" Usage : %s <options> [filename]\n\n", a1);
puts(" -f do a normal search, if possible by index");
puts(" -x extract files");
puts(" -n name extract files to name@adress");
puts(" -d name output matrix of found files to file");
puts(" -h display this message\n");
exit(1);
}

original_code:
void printHelp(char *filename) {
  printf("BigExtract v%s help\n", version);
  printf("Released in public domain, as is\n");
  printf("Rudolf Leermakers <rudolf@hatsuseno.org>\n\n");
  printf(" Usage : %s <options> [filename]\n\n", filename);
 printf(" -f        do a normal search, if possible by index\n");
  printf(" -x        extract files\n");
 printf(" -n name   extract files to name@adress\n");
 printf(" -d name   output matrix of found files to file\n");
 printf(" -h        display this message\n\n");
 exit(1);
}

variable_types:
filename
char *


checkLU

repo: haulisson/denseLinearAlgebraHybrid

decompiled_code:
__int64 checkLU()
{
unsigned int v0; // er12
char *v1; // rbp
__int64 v2; // rdx
__int64 v3; // rdx
__int64 v4; // rdx
__int64 v5; // rdx
double i; // r14
unsigned int v7; // ebx
double v8; // xmm0_8
double v10; // [rsp+8h] [rbp-90h]
double v11; // [rsp+8h] [rbp-90h]
__int64 v12; // [rsp+10h] [rbp-88h] BYREF
__int64 v13; // [rsp+18h] [rbp-80h]
__int64 v14; // [rsp+20h] [rbp-78h] BYREF
__int64 v15; // [rsp+28h] [rbp-70h]
__int64 v16; // [rsp+30h] [rbp-68h] BYREF
__int64 v17; // [rsp+38h] [rbp-60h]
__int64 v18; // [rsp+40h] [rbp-58h] BYREF
__int64 v19; // [rsp+48h] [rbp-50h]
char v20; // [rsp+50h] [rbp-48h] BYREF
__int64 v21; // [rsp+58h] [rbp-40h]
__int64 v22; // [rsp+60h] [rbp-38h]
char v23; // [rsp+68h] [rbp-30h] BYREF

v0 = 1;
v1 = &v20;
v21 = LC1;
v22 = LC2;
v12 = allocAndInitRandomizedMatrix(100LL, 100LL);
v13 = v2;
v14 = allocAndInitZeroMatrix(100LL, 100LL);
v15 = v3;
v16 = allocAndInitZeroMatrix(100LL, 100LL);
v17 = v4;
v18 = allocAndInitZeroMatrix(100LL, 100LL);
v19 = v5;
for ( i = *(double *)&LC0; ; i = *(double *)v1 )
{
v7 = 0;
printf("Tests for cond = %e :\n\n", i);
do
{
getCondNumberMatrix(&v12, v7, i);
v10 = read_timer();
LUFactorize(v12, v13, &v14, &v16);
v8 = read_timer();
printf("Elapsed time = %f seconds.\n", v8 - v10);
matrixMatrixMultiply(v14, v15, v16, v17, &v18);
v11 = maxDiffMatrix(v18, v19, v12, v13);
printf("maxDiff = %e\n", v11);
if ( v11 >= 1.0e-10 )
{
v0 = 0;
printf("LU factorization test failed on matrix of type %d.\n\n", v7);
}
else
{
printf("LU factorization test passed on matrix of type %d.\n\n", v7);
}
++v7;
}
while ( v7 != 5 );
v1 += 8;
if ( v1 == &v23 )
break;
}
if ( (_BYTE)v0 )
puts("LU factorization test passed.\n");
else
puts("LU factorization test failed.\n");
freeMatrix(v12, v13);
freeMatrix(v14, v15);
freeMatrix(v16, v17);
freeMatrix(v18, v19);
return v0;
}

canonical_decompiled_code:
__int64 func0()
{
unsigned int v0; // er12
char *v1; // rbp
__int64 v2; // rdx
__int64 v3; // rdx
__int64 v4; // rdx
__int64 v5; // rdx
double i; // r14
unsigned int v7; // ebx
double v8; // xmm0_8
double v10; // [rsp+8h] [rbp-90h]
double v11; // [rsp+8h] [rbp-90h]
__int64 v12; // [rsp+10h] [rbp-88h] BYREF
__int64 v13; // [rsp+18h] [rbp-80h]
__int64 v14; // [rsp+20h] [rbp-78h] BYREF
__int64 v15; // [rsp+28h] [rbp-70h]
__int64 v16; // [rsp+30h] [rbp-68h] BYREF
__int64 v17; // [rsp+38h] [rbp-60h]
__int64 v18; // [rsp+40h] [rbp-58h] BYREF
__int64 v19; // [rsp+48h] [rbp-50h]
char v20; // [rsp+50h] [rbp-48h] BYREF
__int64 v21; // [rsp+58h] [rbp-40h]
__int64 v22; // [rsp+60h] [rbp-38h]
char v23; // [rsp+68h] [rbp-30h] BYREF

v0 = 1;
v1 = &v20;
v21 = LC1;
v22 = LC2;
v12 = allocAndInitRandomizedMatrix(100LL, 100LL);
v13 = v2;
v14 = allocAndInitZeroMatrix(100LL, 100LL);
v15 = v3;
v16 = allocAndInitZeroMatrix(100LL, 100LL);
v17 = v4;
v18 = allocAndInitZeroMatrix(100LL, 100LL);
v19 = v5;
for ( i = *(double *)&LC0; ; i = *(double *)v1 )
{
v7 = 0;
printf("Tests for cond = %e :\n\n", i);
do
{
getCondNumberMatrix(&v12, v7, i);
v10 = read_timer();
LUFactorize(v12, v13, &v14, &v16);
v8 = read_timer();
printf("Elapsed time = %f seconds.\n", v8 - v10);
matrixMatrixMultiply(v14, v15, v16, v17, &v18);
v11 = maxDiffMatrix(v18, v19, v12, v13);
printf("maxDiff = %e\n", v11);
if ( v11 >= 1.0e-10 )
{
v0 = 0;
printf("LU factorization test failed on matrix of type %d.\n\n", v7);
}
else
{
printf("LU factorization test passed on matrix of type %d.\n\n", v7);
}
++v7;
}
while ( v7 != 5 );
v1 += 8;
if ( v1 == &v23 )
break;
}
if ( (_BYTE)v0 )
puts("LU factorization test passed.\n");
else
puts("LU factorization test failed.\n");
freeMatrix(v12, v13);
freeMatrix(v14, v15);
freeMatrix(v16, v17);
freeMatrix(v18, v19);
return v0;
}

original_code:
char checkLU(){
 int j;
 int n = 100 ;
 double tolMax = 1e-10 ;
 char pass = 1;
 double cond[3] = {10.0, 1.0 / sqrt(1e-14), 1.0 / 1e-14} ;
 int numConds = 3;
 int type = 4;
 double startTime, endTime;
 matrix A = allocAndInitRandomizedMatrix(n,n) ;
 matrix L = allocAndInitZeroMatrix(n, n) ;
 matrix U = allocAndInitZeroMatrix(n, n) ;
 matrix product = allocAndInitZeroMatrix(n,n) ;
 for(j=0; j<numConds; j++){
  printf("Tests for cond = %e :\n\n", cond[j]) ;
  for(type = 0; type < 5; type++){
   getCondNumberMatrix(&A, cond[j], type) ;
   startTime = read_timer();
   LUFactorize(A, &L, &U) ;
   endTime = read_timer();
   printf("Elapsed time = %f seconds.\n", endTime - startTime);
   matrixMatrixMultiply(L, U, &product) ;
   char output = 0;
   if(output){
    printf("Input matrix:\n");
    printMatrix(A);
    printf("U = \n") ;
    printMatrix(U);
    printf("L = \n") ;
    printMatrix(L);
    printMatrix(product) ;
   }
   double maxDiff = maxDiffMatrix(product, A) ;
   printf("maxDiff = %e\n", maxDiff) ;
   if(maxDiff < tolMax){
    printf("LU factorization test passed on matrix of type %d.\n\n", type) ;
   }
   else{
    printf("LU factorization test failed on matrix of type %d.\n\n", type) ;
    pass = 0;
   }
  }
 }
 if(pass)
  printf("LU factorization test passed.\n\n") ;
 else
  printf("LU factorization test failed.\n\n") ;
 freeMatrix(A) ;
 freeMatrix(L) ;
 freeMatrix(U) ;
 freeMatrix(product) ;
 return pass;
}

canonical_original_code:
char checkLU(){
 int j;
 int n = 100;
 double tolMax = 1e-10;
 char pass = 1;
 double cond[3] = {10.0, 1.0 / sqrt(1e-14), 1.0 / 1e-14};
 int numConds = 3;
 int type = 4;
 double startTime; double endTime;
 struct matrix A = allocAndInitRandomizedMatrix(n,n);
 struct matrix L = allocAndInitZeroMatrix(n, n);
 struct matrix U = allocAndInitZeroMatrix(n, n);
 struct matrix product = allocAndInitZeroMatrix(n,n);
 for(j=0; j<numConds; j++){
  printf("Tests for cond = %e :\n\n", cond[j]) ;
  for(type = 0; type < 5; type++){
   getCondNumberMatrix(&A, cond[j], type) ;
   startTime = read_timer();
   LUFactorize(A, &L, &U) ;
   endTime = read_timer();
   printf("Elapsed time = %f seconds.\n", endTime - startTime);
   matrixMatrixMultiply(L, U, &product) ;
   char output = 0;
   if(output){
    printf("Input matrix:\n");
    printMatrix(A);
    printf("U = \n") ;
    printMatrix(U);
    printf("L = \n") ;
    printMatrix(L);
    printMatrix(product) ;
   }
   double maxDiff = maxDiffMatrix(product, A);
   printf("maxDiff = %e\n", maxDiff) ;
   if(maxDiff < tolMax){
    printf("LU factorization test passed on matrix of type %d.\n\n", type) ;
   }
   else{
    printf("LU factorization test failed on matrix of type %d.\n\n", type) ;
    pass = 0;
   }
  }
 }
 if(pass)
  printf("LU factorization test passed.\n\n") ;
 else
  printf("LU factorization test failed.\n\n") ;
 freeMatrix(A) ;
 freeMatrix(L) ;
 freeMatrix(U) ;
 freeMatrix(product) ;
 return pass;
}

variable_types: j int

variable_types: n int

variable_types: tolMax double

variable_types: pass char

variable_types:
cond
double [3]

variable_types: numConds int

variable_types: type int

variable_types: startTime double

variable_types: endTime double

variable_types: struct matrix { double **values; int m; int n; }

variable_types: output char

variable_types: maxDiff double

return_type: char


checkQR

decompiled_code:
__int64 checkQR()
{
unsigned int v0; // er13
unsigned int v1; // ebx
void *v2; // r12
__int64 v3; // rdx
void *v4; // rbp
double v5; // xmm0_8
__int64 v6; // rsi
double v8; // [rsp+8h] [rbp-40h]
double v9; // [rsp+8h] [rbp-40h]
__int64 v10; // [rsp+10h] [rbp-38h] BYREF
__int64 v11; // [rsp+18h] [rbp-30h]

v0 = 1;
v1 = 0;
v2 = malloc(0x320uLL);
v10 = allocAndInitZeroMatrix(100LL, 100LL);
v11 = v3;
do
{
while ( 1 )
{
getEigenvalueTestMatrix(100LL, v1, &v10, v2);
qsort(v2, 0x64uLL, 8uLL, (__compar_fn_t)&compareDoubles);
v8 = read_timer();
v4 = (void *)symmetricQR(v10, v11);
v5 = read_timer();
printf("Elapsed time = %f seconds.\n", v5 - v8);
v9 = maxDiffVector(v4, v2, 100LL);
printf("maxDiff = %e\n", v9);
v6 = v1;
if ( v9 >= 1.0e-12 )
break;
++v1;
printf("QR factorization for eigenvalues test passed on matrix of type %d.\n\n", v6);
if ( v1 == 9 )
goto LABEL_5;
}
++v1;
v0 = 0;
printf("QR factorization for eigenvalues test failed on matrix of type %d.\n\n", v6);
}
while ( v1 != 9 );
LABEL_5:
if ( (_BYTE)v0 )
puts("QR factorization for eigenvalues test passed.\n");
else
puts("QR factorization for eigenvalues test failed.\n");
free(v4);
free(v2);
freeMatrix(v10, v11);
return v0;
}

canonical_decompiled_code:
__int64 func1()
{
unsigned int v0; // er13
unsigned int v1; // ebx
void *v2; // r12
__int64 v3; // rdx
void *v4; // rbp
double v5; // xmm0_8
__int64 v6; // rsi
double v8; // [rsp+8h] [rbp-40h]
double v9; // [rsp+8h] [rbp-40h]
__int64 v10; // [rsp+10h] [rbp-38h] BYREF
__int64 v11; // [rsp+18h] [rbp-30h]

v0 = 1;
v1 = 0;
v2 = malloc(0x320uLL);
v10 = allocAndInitZeroMatrix(100LL, 100LL);
v11 = v3;
do
{
while ( 1 )
{
getEigenvalueTestMatrix(100LL, v1, &v10, v2);
qsort(v2, 0x64uLL, 8uLL, (__compar_fn_t)&compareDoubles);
v8 = read_timer();
v4 = (void *)symmetricQR(v10, v11);
v5 = read_timer();
printf("Elapsed time = %f seconds.\n", v5 - v8);
v9 = maxDiffVector(v4, v2, 100LL);
printf("maxDiff = %e\n", v9);
v6 = v1;
if ( v9 >= 1.0e-12 )
break;
++v1;
printf("QR factorization for eigenvalues test passed on matrix of type %d.\n\n", v6);
if ( v1 == 9 )
goto LABEL_5;
}
++v1;
v0 = 0;
printf("QR factorization for eigenvalues test failed on matrix of type %d.\n\n", v6);
}
while ( v1 != 9 );
LABEL_5:
if ( (_BYTE)v0 )
puts("QR factorization for eigenvalues test passed.\n");
else
puts("QR factorization for eigenvalues test failed.\n");
free(v4);
free(v2);
freeMatrix(v10, v11);
return v0;
}

original_code:
char checkQR(){
 int n = 100;
 int type ;
 double tolMax = 1e-12 ;
 char pass = 1;
 int numTypes = 9 ;
 double maxDiff ;
 char output = 0;
 double startTime, endTime;
 double *eigsOriginal = (double *) malloc(n * sizeof(double)) ;
 matrix A = allocAndInitZeroMatrix(n,n);
 double *eigs ;
 for(type=0; type < numTypes; type++){
  getEigenvalueTestMatrix(n, type, &A, eigsOriginal) ;
  qsort(eigsOriginal, n, sizeof(double), compareDoubles) ;
  if(output){
   printf("Input matrix:\n") ;
   printMatrix(A) ;
  }
  startTime = read_timer();
  eigs = symmetricQR(A) ;
  endTime = read_timer();
  printf("Elapsed time = %f seconds.\n", endTime - startTime);
  if(output){
   printf("Known eigenvalues = \n") ;
   printVector(eigsOriginal, n) ;
   printf("Computed eigenvalues = \n") ;
   printVector(eigs, n) ;
  }
  maxDiff = maxDiffVector(eigs, eigsOriginal, n) ;
  printf("maxDiff = %e\n", maxDiff);
  if (maxDiff < tolMax) {
   printf("QR factorization for eigenvalues test passed on matrix of type %d.\n\n", type);
  } else {
   printf("QR factorization for eigenvalues test failed on matrix of type %d.\n\n", type);
   pass = 0;
  }
 }
 if(pass)
  printf("QR factorization for eigenvalues test passed.\n\n") ;
 else
  printf("QR factorization for eigenvalues test failed.\n\n") ;
 free(eigs) ;
 free(eigsOriginal) ;
 freeMatrix(A) ;
 return pass;
}

canonical_original_code:
char checkQR(){
 int n = 100;
 int type;
 double tolMax = 1e-12;
 char pass = 1;
 int numTypes = 9;
 double maxDiff;
 char output = 0;
 double startTime; double endTime;
 double *eigsOriginal = (double *) malloc(n * sizeof(double));
 struct matrix A = allocAndInitZeroMatrix(n,n);
 double *eigs;
 for(type=0; type < numTypes; type++){
  getEigenvalueTestMatrix(n, type, &A, eigsOriginal) ;
  qsort(eigsOriginal, n, sizeof(double), compareDoubles) ;
  if(output){
   printf("Input matrix:\n") ;
   printMatrix(A) ;
  }
  startTime = read_timer();
  eigs = symmetricQR(A) ;
  endTime = read_timer();
  printf("Elapsed time = %f seconds.\n", endTime - startTime);
  if(output){
   printf("Known eigenvalues = \n") ;
   printVector(eigsOriginal, n) ;
   printf("Computed eigenvalues = \n") ;
   printVector(eigs, n) ;
  }
  maxDiff = maxDiffVector(eigs, eigsOriginal, n) ;
  printf("maxDiff = %e\n", maxDiff);
  if (maxDiff < tolMax) {
   printf("QR factorization for eigenvalues test passed on matrix of type %d.\n\n", type);
  } else {
   printf("QR factorization for eigenvalues test failed on matrix of type %d.\n\n", type);
   pass = 0;
  }
 }
 if(pass)
  printf("QR factorization for eigenvalues test passed.\n\n") ;
 else
  printf("QR factorization for eigenvalues test failed.\n\n") ;
 free(eigs) ;
 free(eigsOriginal) ;
 freeMatrix(A) ;
 return pass;
}

variable_types: numTypes int

variable_types:
eigsOriginal
double *

variable_types:
eigs
double *

user_defined_types: struct matrix { double **values; int m; int n; }


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
_BYTE *v3; // rbp
char v4; // al
char v5; // bl
char v6; // al
char v7; // r12
double v8; // xmm0_8
char v9; // bl
double v11; // [rsp+8h] [rbp-20h]

puts("Dense Linear Algebra Tests.");
v3 = malloc(2uLL);
v11 = read_timer(2LL, argv);
v4 = checkLU();
*v3 = v4;
v5 = v4;
v6 = checkQR();
v3[1] = v6;
v7 = v6;
v8 = read_timer(2LL, argv);
printf("Total time for all tests = %f seconds.\n\n", v8 - v11);
if ( v5 )
{
printf("Test %d passed.\n", 0LL);
if ( v7 )
{
v9 = 1;
printf("Test %d passed.\n", 1LL);
puts("\nAll tests passed.\n");
goto LABEL_5;
}
}
else
{
fprintf(stderr, "Test %d failed.\n", 0LL);
if ( v7 )
{
printf("Test %d passed.\n", 1LL);
goto LABEL_4;
}
}
fprintf(stderr, "Test %d failed.\n", 1LL);
LABEL_4:
v9 = 0;
fwrite("\nTests failed!\n", 1uLL, 0xFuLL, stderr);
LABEL_5:
free(v3);
return v9;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
_BYTE *v3; // rbp
char v4; // al
char v5; // bl
char v6; // al
char v7; // r12
double v8; // xmm0_8
char v9; // bl
double v11; // [rsp+8h] [rbp-20h]

puts("Dense Linear Algebra Tests.");
v3 = malloc(2uLL);
v11 = read_timer(2LL, argv);
v4 = func0();
*v3 = v4;
v5 = v4;
v6 = func1();
v3[1] = v6;
v7 = v6;
v8 = read_timer(2LL, argv);
printf("Total time for all tests = %f seconds.\n\n", v8 - v11);
if ( v5 )
{
printf("Test %d passed.\n", 0LL);
if ( v7 )
{
v9 = 1;
printf("Test %d passed.\n", 1LL);
puts("\nAll tests passed.\n");
goto LABEL_5;
}
}
else
{
fprintf(stderr, "Test %d failed.\n", 0LL);
if ( v7 )
{
printf("Test %d passed.\n", 1LL);
goto LABEL_4;
}
}
fprintf(stderr, "Test %d failed.\n", 1LL);
LABEL_4:
v9 = 0;
fwrite("\nTests failed!\n", 1uLL, 0xFuLL, stderr);
LABEL_5:
free(v3);
return v9;
}

original_code:
int main(){
 printf("Dense Linear Algebra Tests.\n") ;
 int i;
 int numTests = 2;
 char *pass = (char *) malloc(numTests * sizeof(char));
 char allPass = 1;
 double startTime, endTime;
 startTime = read_timer();
 pass[0] = checkLU() ;
 pass[1] = checkQR() ;
 endTime = read_timer();
 printf("Total time for all tests = %f seconds.\n\n", endTime - startTime);
 for(i=0; i<numTests; i++){
  if(pass[i]){
   printf("Test %d passed.\n", i) ;
   allPass &= 1;
  }
  else{
   fprintf(stderr, "Test %d failed.\n", i) ;
   allPass = 0;
  }
 }
 if( allPass )
  printf("\nAll tests passed.\n\n") ;
 else
  fprintf(stderr, "\nTests failed!\n") ;
 free(pass) ;
 return allPass;
}

canonical_original_code:
int main(){
 printf("Dense Linear Algebra Tests.\n") ;
 int i;
 int numTests = 2;
 char *pass = (char *) malloc(numTests * sizeof(char));
 char allPass = 1;
 double startTime; double endTime;
 startTime = read_timer();
 pass[0] = checkLU() ;
 pass[1] = checkQR() ;
 endTime = read_timer();
 printf("Total time for all tests = %f seconds.\n\n", endTime - startTime);
 for(i=0; i<numTests; i++){
  if(pass[i]){
   printf("Test %d passed.\n", i) ;
   allPass &= 1;
  }
  else{
   fprintf(stderr, "Test %d failed.\n", i) ;
   allPass = 0;
  }
 }
 if( allPass )
  printf("\nAll tests passed.\n\n") ;
 else
  fprintf(stderr, "\nTests failed!\n") ;
 free(pass) ;
 return allPass;
}

variable_types: i int

variable_types: numTests int

variable_types:
pass
char *

variable_types: allPass char


repo: hauspie/minunit

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned int v4; // [rsp+8h] [rbp-10h] BYREF
int v5[3]; // [rsp+Ch] [rbp-Ch] BYREF

v4 = 0;
v5[0] = 0;
mu_run_test_suite(sampleTest_setup, sampleTest_tear_down, &sampleTest_tests_array, &v4, v5);
mu_report_test_suite_report("sampleTest", &sampleTest_tests_array, v4, (unsigned int)v5[0]);
v4 = 0;
v5[0] = 0;
mu_run_test_suite(test_half_setup, test_half_tear_down, &test_half_tests_array, &v4, v5);
mu_report_test_suite_report("test_half", &test_half_tests_array, v4, (unsigned int)v5[0]);
v4 = 0;
v5[0] = 0;
mu_run_test_suite(test_assertions_setup, test_assertions_tear_down, &test_assertions_tests_array, &v4, v5);
mu_report_test_suite_report("test_assertions", &test_assertions_tests_array, v4, (unsigned int)v5[0]);
puts("The next suite will fail on purpose");
v4 = 0;
v5[0] = 0;
mu_run_test_suite(half_success_setup, half_success_tear_down, &half_success_tests_array, &v4, v5);
mu_report_test_suite_report("half_success", &half_success_tests_array, v4, (unsigned int)v5[0]);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned int v4; // [rsp+8h] [rbp-10h] BYREF
int v5[3]; // [rsp+Ch] [rbp-Ch] BYREF

v4 = 0;
v5[0] = 0;
func7(sampleTest_setup, sampleTest_tear_down, &sampleTest_tests_array, &v4, v5);
func21("sampleTest", &sampleTest_tests_array, v4, (unsigned int)v5[0]);
v4 = 0;
v5[0] = 0;
func7(test_half_setup, test_half_tear_down, &test_half_tests_array, &v4, v5);
func21("test_half", &test_half_tests_array, v4, (unsigned int)v5[0]);
v4 = 0;
v5[0] = 0;
func7(test_assertions_setup, test_assertions_tear_down, &test_assertions_tests_array, &v4, v5);
func21("test_assertions", &test_assertions_tests_array, v4, (unsigned int)v5[0]);
puts("The next suite will fail on purpose");
v4 = 0;
v5[0] = 0;
func7(half_success_setup, half_success_tear_down, &half_success_tests_array, &v4, v5);
func21("half_success", &half_success_tests_array, v4, (unsigned int)v5[0]);
return 0;
}

original_code:
int main(void)
{
    do { int success = 0; int total = 0; mu_run_test_suite(sampleTest_setup, sampleTest_tear_down, sampleTest_tests_array, (&success), (&total)); mu_report_test_suite_report("sampleTest", sampleTest_tests_array, success, total); } while(0);
    do { int success = 0; int total = 0; mu_run_test_suite(test_half_setup, test_half_tear_down, test_half_tests_array, (&success), (&total)); mu_report_test_suite_report("test_half", test_half_tests_array, success, total); } while(0);
    do { int success = 0; int total = 0; mu_run_test_suite(test_assertions_setup, test_assertions_tear_down, test_assertions_tests_array, (&success), (&total)); mu_report_test_suite_report("test_assertions", test_assertions_tests_array, success, total); } while(0);
    printf("%s", ("The next suite will fail on purpose\n"));
    do { int success = 0; int total = 0; mu_run_test_suite(half_success_setup, half_success_tear_down, half_success_tests_array, (&success), (&total)); mu_report_test_suite_report("half_success", half_success_tests_array, success, total); } while(0);
    return 0;
}

canonical_original_code:
int main()
{
    do { int success = 0; int total = 0; mu_run_test_suite(sampleTest_setup, sampleTest_tear_down, sampleTest_tests_array, (&success), (&total)); mu_report_test_suite_report("sampleTest", sampleTest_tests_array, success, total); } while(0);
    do { int success = 0; int total = 0; mu_run_test_suite(test_half_setup, test_half_tear_down, test_half_tests_array, (&success), (&total)); mu_report_test_suite_report("test_half", test_half_tests_array, success, total); } while(0);
    do { int success = 0; int total = 0; mu_run_test_suite(test_assertions_setup, test_assertions_tear_down, test_assertions_tests_array, (&success), (&total)); mu_report_test_suite_report("test_assertions", test_assertions_tests_array, success, total); } while(0);
    printf("%s", ("The next suite will fail on purpose\n"));
    do { int success = 0; int total = 0; mu_run_test_suite(half_success_setup, half_success_tear_down, half_success_tests_array, (&success), (&total)); mu_report_test_suite_report("half_success", half_success_tests_array, success, total); } while(0);
    return 0;
}

variable_types: success int

variable_types: total int


decompiled_code:
__int64 __fastcall mu_run_test_suite(void (__fastcall *a1)(_QWORD *), void (__fastcall *a2)(_QWORD *), _QWORD *a3, _DWORD *a4, _DWORD *a5)
{
_QWORD *v6; // rbx
int v7; // er13
int v8; // er14
int v9; // eax
__int64 result; // rax

if ( *a3 )
{
v6 = a3;
v7 = 0;
v8 = 0;
do
{
*((_DWORD *)v6 + 5) = 0;
*((_DWORD *)v6 + 4) = 0;
a1(v6);
((void (__fastcall *)(_QWORD *))*v6)(v6);
a2(v6);
v9 = *((_DWORD *)v6 + 5);
if ( v9 )
v7 += v9 == *((_DWORD *)v6 + 4);
v6 += 3;
++v8;
}
while ( *v6 );
result = (unsigned int)-(v7 != v8);
}
else
{
result = 0LL;
v7 = 0;
v8 = 0;
}
*a5 = v8;
*a4 = v7;
return result;
}

original_code:
static __inline__ int mu_run_test_suite(mu_test_func setup, mu_test_func tear_down, struct mu_test_desc *tests_array, int *out_success, int *out_total)
    {
 int i;
 int success = 0;
 for (i = 0 ; tests_array[i].test != ((void *)0) ; ++i)
 {
     struct mu_test_desc *desc = &tests_array[i];
     desc->success = desc->performed = 0;
     setup(desc);
     desc->test(desc);
     tear_down(desc);
     if (((desc)->performed != 0 && ((desc)->success == (desc)->performed)))
  success++;
 }
 if (out_total)
     *out_total = i;
 if (out_success)
     *out_success = success;
 if (i == success) return 0;
 return -1;
    }

canonical_original_code:
static __inline__ int mu_run_test_suite(void (*setup)(struct mu_test_desc *desc), void (*tear_down)(struct mu_test_desc *desc), struct mu_test_desc *tests_array, int *out_success, int *out_total)
    {
 int i;
 int success = 0;
 for (i = 0 ; tests_array[i].test != ((void *)0) ; ++i)
 {
     struct mu_test_desc *desc = &tests_array[i];
     desc->success = desc->performed = 0;
     setup(desc);
     desc->test(desc);
     tear_down(desc);
     if (((desc)->performed != 0 && ((desc)->success == (desc)->performed)))
  success++;
 }
 if (out_total)
     *out_total = i;
 if (out_success)
     *out_success = success;
 if (i == success) return 0;
 return -1;
    }

variable_types: void (*)(struct mu_test_desc { void (*test)(struct mu_test_desc *desc); char *test_name; int success; int performed; } *desc)


decompiled_code:
void sampleTest_setup()
{
value = 0;
}

canonical_decompiled_code:
void func8()
{
value = 0;
}

original_code:
void sampleTest_setup(struct mu_test_desc *desc)
{
    value = 0;
}

variable_types: struct mu_test_desc { void (*test)(struct mu_test_desc *desc); char *test_name; int success; int performed; } *


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

result = (unsigned int)value;
if ( value )
++*(_DWORD *)(a1 + 16);
++*(_DWORD *)(a1 + 20);
return result;
}

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

result = (unsigned int)value;
if ( value )
++*(_DWORD *)(a1 + 16);
++*(_DWORD *)(a1 + 20);
return result;
}

original_code:
void sampleTest_tear_down(struct mu_test_desc *desc)
{
    do { if ( (((value) != (0))) ) desc->success++; else { do {} while(0) ; } desc->performed++; } while (0);
}

user_defined_types: struct mu_test_desc { void (*test)(struct mu_test_desc *desc); char *test_name; int success; int performed; }


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

result = (unsigned int)value;
if ( !value )
++*(_DWORD *)(a1 + 16);
++*(_DWORD *)(a1 + 20);
value = 1;
return result;
}

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

result = (unsigned int)value;
if ( !value )
++*(_DWORD *)(a1 + 16);
++*(_DWORD *)(a1 + 20);
value = 1;
return result;
}

original_code:
void sampleTest_test1(struct mu_test_desc *desc)
{
    do { if ( (((value) == (0))) ) desc->success++; else { do {} while(0) ; } desc->performed++; } while (0);
    value = 1;
}


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

result = (unsigned int)value;
if ( !value )
++*(_DWORD *)(a1 + 16);
++*(_DWORD *)(a1 + 20);
value = 2;
return result;
}

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

result = (unsigned int)value;
if ( !value )
++*(_DWORD *)(a1 + 16);
++*(_DWORD *)(a1 + 20);
value = 2;
return result;
}

original_code:
void sampleTest_test2(struct mu_test_desc *desc)
{
    do { if ( (((value) == (0))) ) desc->success++; else { do {} while(0) ; } desc->performed++; } while (0);
    value = 2;
}


decompiled_code:
void half_success_setup()
{
;
}

canonical_decompiled_code:
void func12()
{
;
}

original_code: void half_success_setup(struct mu_test_desc *desc) {}


decompiled_code:
void __fastcall half_success_success1(__int64 a1)
{
++*(_DWORD *)(a1 + 16);
++*(_DWORD *)(a1 + 20);
}

original_code: void half_success_success1(struct mu_test_desc *desc) { do { if ( (((0) == (0))) ) desc->success++; else { do {} while(0) ; } desc->performed++; } while (0);}


decompiled_code:
// attributes: thunk
void __fastcall half_success_success2(__int64 a1)
{
half_success_success1(a1);
}

canonical_decompiled_code:
void __fastcall func14(__int64 a1)
{
func13(a1);
}

original_code: void half_success_success2(struct mu_test_desc *desc) { do { if ( (((1) != (0))) ) desc->success++; else { do {} while(0) ; } desc->performed++; } while (0); }


decompiled_code:
void __fastcall half_success_fail1(__int64 a1)
{
++*(_DWORD *)(a1 + 20);
}

original_code: void half_success_fail1(struct mu_test_desc *desc) { do { if ( (((0) == (1))) ) desc->success++; else { do {} while(0) ; } desc->performed++; } while (0); }


decompiled_code:
// attributes: thunk
void __fastcall half_success_fail2(__int64 a1)
{
half_success_fail1(a1);
}

canonical_decompiled_code:
void __fastcall func16(__int64 a1)
{
func15(a1);
}

original_code: void half_success_fail2(struct mu_test_desc *desc) { do { if ( (((0) != (0))) ) desc->success++; else { do {} while(0) ; } desc->performed++; } while (0); }


decompiled_code:
__int64 __fastcall test_half_run(__int64 a1)
{
int v1; // eax
__int64 result; // rax
int v3; // [rsp+8h] [rbp-10h] BYREF
int v4[3]; // [rsp+Ch] [rbp-Ch] BYREF

if ( (unsigned int)mu_run_test_suite(
(void (__fastcall *)(_QWORD *))half_success_setup,
(void (__fastcall *)(_QWORD *))half_success_tear_down,
&half_success_tests_array,
&v3,
v4) == -1 )
++*(_DWORD *)(a1 + 16);
v1 = *(_DWORD *)(a1 + 20);
if ( v3 == 2 )
++*(_DWORD *)(a1 + 16);
if ( v4[0] == 4 )
++*(_DWORD *)(a1 + 16);
result = (unsigned int)(v1 + 3);
*(_DWORD *)(a1 + 20) = result;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func17(__int64 a1)
{
int v1; // eax
__int64 result; // rax
int v3; // [rsp+8h] [rbp-10h] BYREF
int v4[3]; // [rsp+Ch] [rbp-Ch] BYREF

if ( (unsigned int)func7(
(void (__fastcall *)(_QWORD *))half_success_setup,
(void (__fastcall *)(_QWORD *))half_success_tear_down,
&half_success_tests_array,
&v3,
v4) == -1 )
++*(_DWORD *)(a1 + 16);
v1 = *(_DWORD *)(a1 + 20);
if ( v3 == 2 )
++*(_DWORD *)(a1 + 16);
if ( v4[0] == 4 )
++*(_DWORD *)(a1 + 16);
result = (unsigned int)(v1 + 3);
*(_DWORD *)(a1 + 20) = result;
return result;
}

original_code:
void test_half_run(struct mu_test_desc *desc) {
    int success, total;
    do { if ( (((mu_run_test_suite(half_success_setup, half_success_tear_down, half_success_tests_array, (&success), (&total))) == (-1))) ) desc->success++; else { do {} while(0) ; } desc->performed++; } while (0);
    do { if ( (((success) == (2))) ) desc->success++; else { do {} while(0) ; } desc->performed++; } while (0);
    do { if ( (((total) == (4))) ) desc->success++; else { do {} while(0) ; } desc->performed++; } while (0);
}

canonical_original_code:
void test_half_run(struct mu_test_desc *desc) {
    int success; int total;
    do { if ( (((mu_run_test_suite(half_success_setup, half_success_tear_down, half_success_tests_array, (&success), (&total))) == (-1))) ) desc->success++; else { do {} while(0) ; } desc->performed++; } while (0);
    do { if ( (((success) == (2))) ) desc->success++; else { do {} while(0) ; } desc->performed++; } while (0);
    do { if ( (((total) == (4))) ) desc->success++; else { do {} while(0) ; } desc->performed++; } while (0);
}


decompiled_code:
// attributes: thunk
void __fastcall test_assertions_assert(__int64 a1)
{
half_success_success1(a1);
}

canonical_decompiled_code:
void __fastcall func18(__int64 a1)
{
func13(a1);
}

original_code:
void test_assertions_assert(struct mu_test_desc *desc) {
    do { if ( ((0 == 0)) ) desc->success++; else { do {} while(0) ; } desc->performed++; } while (0);
}


decompiled_code:
// attributes: thunk
void __fastcall test_assertions_equal(__int64 a1)
{
half_success_success1(a1);
}

canonical_decompiled_code:
void __fastcall func19(__int64 a1)
{
func13(a1);
}

original_code:
void test_assertions_equal(struct mu_test_desc *desc) {
    do { if ( (((0) == (0))) ) desc->success++; else { do {} while(0) ; } desc->performed++; } while (0);
}


decompiled_code:
// attributes: thunk
void __fastcall test_assertions_notequal(__int64 a1)
{
half_success_success1(a1);
}

canonical_decompiled_code:
void __fastcall func20(__int64 a1)
{
func13(a1);
}

original_code:
void test_assertions_notequal(struct mu_test_desc *desc) {
    do { if ( (((0) != (1))) ) desc->success++; else { do {} while(0) ; } desc->performed++; } while (0);
}