decompiled_code:
double __fastcall det_angle(double a1, double a2, double a3)
{
double v3; // xmm3_8
double v4; // xmm0_8

v3 = a1 * a1 + a2 * a2 - a3 * a3;
v4 = (a1 + a1) * a2;
if ( v4 == 0.0 )
__assert_fail("denominator != 0", "triangle.c", 0x5Bu, "det_angle");
return acos(v3 / v4);
}

canonical_decompiled_code:
double __fastcall func9(double a1, double a2, double a3)
{
double v3; // xmm3_8
double v4; // xmm0_8

v3 = a1 * a1 + a2 * a2 - a3 * a3;
v4 = (a1 + a1) * a2;
if ( v4 == 0.0 )
__assert_fail("denominator != 0", "triangle.c", 0x5Bu, "det_angle");
return acos(v3 / v4);
}

original_code:
double det_angle(double a, double b, double c)
{
 double numerator, denominator;
 numerator = pow(a, 2) + pow(b, 2) - pow(c, 2);
 denominator = 2 * a * b;
 ((void) sizeof ((denominator != 0) ? 1 : 0), __extension__ ({ if (denominator != 0) ; else __assert_fail ("denominator != 0", "triangle.c", 91, __extension__ __PRETTY_FUNCTION__); }));
 return acos(numerator/denominator);
}

canonical_original_code:
double det_angle(double a, double b, double c)
{
 double numerator; double denominator;
 numerator = pow(a, 2) + pow(b, 2) - pow(c, 2);
 denominator = 2 * a * b;
 ((void) sizeof ((denominator != 0) ? 1 : 0), __extension__ ({ if (denominator != 0) ; else __assert_fail ("denominator != 0", "triangle.c", 91, __extension__ __PRETTY_FUNCTION__); }));
 return acos(numerator/denominator);
}

variable_types: a double

variable_types: b double

variable_types: c double

variable_types: numerator double

variable_types: denominator double


original_code:
_Bool is_nat(struct Point p1, struct Point p2, struct Point p3)
{
 if((p1.x*(p2.y-p3.y) + p2.x*(p3.y-p1.y) + p3.x*(p1.y-p2.y)) == 0)
  return 1;
 else
  return 0;
}

variable_types: struct Point { long long x; long long y; }


original_code:
_Bool is_right(struct Point p1, struct Point p2, struct Point p3)
{
 _Bool r1, r2, r3;
 r1 = (sq_dist(p1, p2) + sq_dist(p2, p3) == sq_dist(p1, p3));
 r2 = (sq_dist(p2, p3) + sq_dist(p1, p3) == sq_dist(p1, p2));
 r3 = (sq_dist(p1, p2) + sq_dist(p1, p3) == sq_dist(p2, p3));
 return (r1 || r2 || r3);
}

canonical_original_code:
_Bool is_right(struct Point p1, struct Point p2, struct Point p3)
{
 _Bool r1; _Bool r2; _Bool r3;
 r1 = (sq_dist(p1, p2) + sq_dist(p2, p3) == sq_dist(p1, p3));
 r2 = (sq_dist(p2, p3) + sq_dist(p1, p3) == sq_dist(p1, p2));
 r3 = (sq_dist(p1, p2) + sq_dist(p1, p3) == sq_dist(p2, p3));
 return (r1 || r2 || r3);
}

user_defined_types: struct Point { long long x; long long y; }


main

canonical_name: main

original_code:
int main(int argc, char* argv[])
{
 struct Point p1, p2, p3;
 double ab, bc, ac;
 double AB, BC, AC;
 ((void) sizeof ((argc == 7) ? 1 : 0), __extension__ ({ if (argc == 7) ; else __assert_fail ("argc == 7", "triangle.c", 26, __extension__ __PRETTY_FUNCTION__); }));
 p1.x = atoi(argv[1]); p1.y = atoi(argv[2]);
 p2.x = atoi(argv[3]); p2.y = atoi(argv[4]);
 p3.x = atoi(argv[5]); p3.y = atoi(argv[6]);
 if(is_nat(p1, p2, p3))
 {
  printf("not a triangle\n");
  return 0;
 }
 ab = sqrt(sq_dist(p1, p2));
 bc = sqrt(sq_dist(p2, p3));
 ac = sqrt(sq_dist(p1, p3));
 AB = det_angle(ac, bc, ab);
 BC = det_angle(ab, ac, bc);
 AC = det_angle(ab, bc, ac);
 if(ab == bc || bc == ac || ab == ac)
  printf("isosceles");
 else
  printf("scalene");
 double right = 3.14159265358979323846/2;
 if(is_right(p1, p2, p3))
  printf(" right\n");
 else if(AB > right || BC > right || AC > right)
  printf(" obtuse\n");
 else
  printf(" acute\n");
 exit(0);
}

canonical_original_code:
int main(int argc, char *argv[])
{
 struct Point p1; struct Point p2; struct Point p3;
 double ab; double bc; double ac;
 double AB; double BC; double AC;
 ((void) sizeof ((argc == 7) ? 1 : 0), __extension__ ({ if (argc == 7) ; else __assert_fail ("argc == 7", "triangle.c", 26, __extension__ __PRETTY_FUNCTION__); }));
 p1.x = atoi(argv[1]); p1.y = atoi(argv[2]);
 p2.x = atoi(argv[3]); p2.y = atoi(argv[4]);
 p3.x = atoi(argv[5]); p3.y = atoi(argv[6]);
 if(is_nat(p1, p2, p3))
 {
  printf("not a triangle\n");
  return 0;
 }
 ab = sqrt(sq_dist(p1, p2));
 bc = sqrt(sq_dist(p2, p3));
 ac = sqrt(sq_dist(p1, p3));
 AB = det_angle(ac, bc, ab);
 BC = det_angle(ab, ac, bc);
 AC = det_angle(ab, bc, ac);
 if(ab == bc || bc == ac || ab == ac)
  printf("isosceles");
 else
  printf("scalene");
 double right = 3.14159265358979323846/2;
 if(is_right(p1, p2, p3))
  printf(" right\n");
 else if(AB > right || BC > right || AC > right)
  printf(" obtuse\n");
 else
  printf(" acute\n");
 exit(0);
}

variable_types: argc int

variable_types:
argv
char *[]

variable_types: ab double

variable_types: bc double

variable_types: ac double

variable_types: AB double

variable_types: BC double

variable_types: AC double

variable_types: right double

return_type: int


randint

decompiled_code:
__int64 __fastcall randint(int a1, int a2)
{
int v2; // ebx
int v3; // eax
int v4; // ecx

v2 = a2;
v3 = rand();
v4 = a1;
if ( a2 <= a1 )
v4 = a2;
if ( a2 < a1 )
v2 = a1;
return (unsigned int)(v3 % (v2 - v4) + v4);
}

canonical_decompiled_code:
__int64 __fastcall func7(int a1, int a2)
{
int v2; // ebx
int v3; // eax
int v4; // ecx

v2 = a2;
v3 = rand();
v4 = a1;
if ( a2 <= a1 )
v4 = a2;
if ( a2 < a1 )
v2 = a1;
return (unsigned int)(v3 % (v2 - v4) + v4);
}

original_code:
int randint(int a, int b) {
    return (rand() % ((a > b ? a : b) - (a < b ? a : b))) + (a < b ? a : b);
}

variable_types: a int

variable_types: b int


cfori

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

if ( (unsigned int)a1 > 0x20 )
__assert_fail("i >= 0 && i <= 32", "xprintf.c", 0x1Eu, "cfori");
result = (unsigned int)(a1 + 87);
if ( a1 <= 9 )
result = (unsigned int)(a1 + 48);
return result;
}

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

if ( (unsigned int)a1 > 0x20 )
__assert_fail("i >= 0 && i <= 32", "xprintf.c", 0x1Eu, "cfori");
result = (unsigned int)(a1 + 87);
if ( a1 <= 9 )
result = (unsigned int)(a1 + 48);
return result;
}

variable_types: i int

return_type: char


utos

decompiled_code:
__int64 __fastcall utos(unsigned int a1, __int64 a2, unsigned int a3)
{
unsigned int v3; // eax
__int64 v5; // rbx
int v6; // edx
unsigned int v7; // er12
int v8; // ebp

if ( a3 > 0x20 )
__assert_fail("radix >= 0 && radix <= 32", "xprintf.c", 0x23u, "utos");
v3 = a1;
v5 = 1LL;
v6 = 0;
if ( a3 < a1 )
{
do
{
v7 = v3 / a3;
*(_BYTE *)(a2 + v5 - 1) = cfori(v3 % a3);
v3 = v7;
v6 = v5++;
}
while ( a3 < v7 );
}
v8 = v6 + 1;
*(_BYTE *)(a2 + v6) = cfori(v3);
reverse(a2, v8);
*(_BYTE *)(a2 + v8) = 0;
return (unsigned int)v8;
}

canonical_decompiled_code:
__int64 __fastcall func11(unsigned int a1, __int64 a2, unsigned int a3)
{
unsigned int v3; // eax
__int64 v5; // rbx
int v6; // edx
unsigned int v7; // er12
int v8; // ebp

if ( a3 > 0x20 )
__assert_fail("radix >= 0 && radix <= 32", "xprintf.c", 0x23u, "utos");
v3 = a1;
v5 = 1LL;
v6 = 0;
if ( a3 < a1 )
{
do
{
v7 = v3 / a3;
*(_BYTE *)(a2 + v5 - 1) = func10(v3 % a3);
v3 = v7;
v6 = v5++;
}
while ( a3 < v7 );
}
v8 = v6 + 1;
*(_BYTE *)(a2 + v6) = func10(v3);
func9(a2, v8);
*(_BYTE *)(a2 + v8) = 0;
return (unsigned int)v8;
}

original_code:
int utos(unsigned int v, char * out, unsigned int radix) {
    ((void) sizeof ((radix >= 0 && radix <= 32) ? 1 : 0), __extension__ ({ if (radix >= 0 && radix <= 32) ; else __assert_fail ("radix >= 0 && radix <= 32", "xprintf.c", 35, __extension__ __PRETTY_FUNCTION__); }));
    int nchars = 0;
    for (; v > radix; v /= radix, nchars++) {
        out[nchars] = cfori(v % radix);
    }
    out[nchars++] = cfori(v);
    reverse(out, nchars);
    out[nchars] = '\0';
    return nchars;
}

canonical_original_code:
int utos(unsigned int v, char *out, unsigned int radix) {
    ((void) sizeof ((radix >= 0 && radix <= 32) ? 1 : 0), __extension__ ({ if (radix >= 0 && radix <= 32) ; else __assert_fail ("radix >= 0 && radix <= 32", "xprintf.c", 35, __extension__ __PRETTY_FUNCTION__); }));
    int nchars = 0;
    for (; v > radix; v /= radix, nchars++) {
        out[nchars] = cfori(v % radix);
    }
    out[nchars++] = cfori(v);
    reverse(out, nchars);
    out[nchars] = '\0';
    return nchars;
}

variable_types:
v
unsigned int

variable_types:
out
char *

variable_types:
radix
unsigned int

variable_types: nchars int


xabs

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

result = 0x80000000LL;
if ( a1 != 0x80000000 )
result = abs32(a1);
return result;
}

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

result = 0x80000000LL;
if ( a1 != 0x80000000 )
result = abs32(a1);
return result;
}

original_code:
unsigned int xabs(int i) {
    return i == (-0x7fffffff - 1)
        ? ((unsigned int) 0x7fffffff) + 1
        : (unsigned int) abs(i);
}

return_type: unsigned int


itos

decompiled_code:
__int64 __fastcall itos(int a1, _BYTE *a2)
{
unsigned int v2; // eax
__int64 result; // rax
unsigned int v4; // ebx

v2 = xabs(a1);
result = utos(v2, (__int64)a2, 0xAu);
if ( a1 < 0 )
{
v4 = result + 1;
memmove(a2 + 1, a2, (int)result);
*a2 = 45;
result = v4;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func13(int a1, _BYTE *a2)
{
unsigned int v2; // eax
__int64 result; // rax
unsigned int v4; // ebx

v2 = func12(a1);
result = func11(v2, (__int64)a2, 0xAu);
if ( a1 < 0 )
{
v4 = result + 1;
memmove(a2 + 1, a2, (int)result);
*a2 = 45;
result = v4;
}
return result;
}

original_code:
int itos(int v, char * out) {
    int nchars = utos(xabs(v), out, 10);
    if (v < 0) {
        memmove(out + 1, out, nchars++);
        out[0] = '-';
    }
    return nchars;
}

canonical_original_code:
int itos(int v, char *out) {
    int nchars = utos(xabs(v), out, 10);
    if (v < 0) {
        memmove(out + 1, out, nchars++);
        out[0] = '-';
    }
    return nchars;
}

variable_types: v int


decompiled_code:
__int64 __fastcall field_width(char **a1)
{
char *v1; // rbp
char v2; // bl
__int64 result; // rax
const unsigned __int16 *v4; // rcx

v1 = *a1;
v2 = **a1;
result = 0LL;
if ( v2 != 48 )
{
if ( v2 )
{
v4 = *__ctype_b_loc();
result = 0LL;
do
{
if ( (v4[v2] & 0x800) == 0 )
break;
result = (unsigned int)(v2 + 10 * result - 48);
v2 = *++v1;
}
while ( *v1 );
}
else
{
result = 0LL;
}
*a1 = v1;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func14(char **a1)
{
char *v1; // rbp
char v2; // bl
__int64 result; // rax
const unsigned __int16 *v4; // rcx

v1 = *a1;
v2 = **a1;
result = 0LL;
if ( v2 != 48 )
{
if ( v2 )
{
v4 = *__ctype_b_loc();
result = 0LL;
do
{
if ( (v4[v2] & 0x800) == 0 )
break;
result = (unsigned int)(v2 + 10 * result - 48);
v2 = *++v1;
}
while ( *v1 );
}
else
{
result = 0LL;
}
*a1 = v1;
}
return result;
}

original_code:
int field_width(const char ** fmt) {
    const char * format = *fmt;
    int fw = 0;
    if (*format && *format == '0') { return fw; }
    for (; *format && ((*__ctype_b_loc ())[(int) ((*format))] & (unsigned short int) _ISdigit); format++) {
        fw *= 10;
        fw += *format - '0';
    }
    *fmt = format;
    return fw;
}

canonical_original_code:
int field_width(char **fmt) {
    char *format = *fmt;
    int fw = 0;
    if (*format && *format == '0') { return fw; }
    for (; *format && ((*__ctype_b_loc ())[(int) ((*format))] & (unsigned short) _ISdigit); format++) {
        fw *= 10;
        fw += *format - '0';
    }
    *fmt = format;
    return fw;
}

variable_types:
fmt
char **

variable_types:
format
char *

variable_types: fw int


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v3; // edx
int v4; // ecx
int v5; // er8
int v6; // er9
int v7; // edx
int v8; // ecx
int v9; // er8
int v10; // er9
int v11; // edx
int v12; // ecx
int v13; // er8
int v14; // er9
int v15; // edx
int v16; // ecx
int v17; // er8
int v18; // er9
int v19; // edx
int v20; // ecx
int v21; // er8
int v22; // er9
int v23; // ecx
int v24; // er8
int v25; // er9
int v26; // edx
int v27; // ecx
int v28; // er8
int v29; // er9
int v30; // edx
int v31; // ecx
int v32; // er8
int v33; // er9
int v34; // ecx
int v35; // er8
int v36; // er9
int v37; // edx
int v38; // ecx
int v39; // er8
int v40; // er9
int v41; // ebp
__int64 v42; // rbx
int v43; // edx
int v44; // ecx
int v45; // er8
int v46; // er9
int v47; // edx
int v48; // ecx
int v49; // er8
int v50; // er9
int v51; // edx
int v52; // ecx
int v53; // er8
int v54; // er9
unsigned int v56; // [rsp+8h] [rbp-20h] BYREF
__int64 v57[3]; // [rsp+Ch] [rbp-1Ch] BYREF

srand(3u);
printf("libc: %%\n");
xprintf((unsigned int)" us: %%\n", (_DWORD)argv, v3, v4, v5, v6);
printf("libc: %015d\n", 4294967291LL);
xprintf((unsigned int)" us: %015d\n", -5, v7, v8, v9, v10);
printf("libc: %15d\n", 4294967219LL);
xprintf((unsigned int)" us: %15d\n", -77, v11, v12, v13, v14);
printf("libc: %015d\n", 3360274168LL);
xprintf((unsigned int)" us: %015d\n", -934693128, v15, v16, v17, v18);
printf("libc: %15d\n", 3394143814LL);
xprintf((unsigned int)" us: %15d\n", -900823482, v19, v20, v21, v22);
printf("libc: %0300d | %070d\n", 4160344168LL, 134623128LL);
xprintf((unsigned int)" us: %0300d | %070d\n", -134623128, 134623128, v23, v24, v25);
printf("libc: %3c\n", 98LL);
xprintf((unsigned int)" us: %3c\n", 98, v26, v27, v28, v29);
printf("libc: %04d\n", 13LL);
xprintf((unsigned int)" us: %04d\n", 13, v30, v31, v32, v33);
printf("libc: %s %20s.\n", "Hello", "World");
xprintf((unsigned int)" us: %s %20s.\n", (unsigned int)"Hello", (unsigned int)"World", v34, v35, v36);
LODWORD(v57[0]) = -1;
v56 = -1;
printf("abc%n (libc capturing %%n)\n", v57);
xprintf((unsigned int)"abc%n (us capturing %%n)\n", (unsigned int)&v56, v37, v38, v39, v40);
printf("libc: %d\n us: %d\n", LODWORD(v57[0]), v56);
v41 = 3;
do
{
v42 = (unsigned int)randint(0, 0x7FFFFFFF);
printf("libc: %15d\n", v42);
xprintf((unsigned int)" us: %15d\n", v42, v43, v44, v45, v46);
--v41;
}
while ( v41 );
printf("libc: %u\n", 324234224LL);
xprintf((unsigned int)" us: %u\n", 324234224, v47, v48, v49, v50);
printf("libc: %x\n", 1752281LL);
xprintf((unsigned int)" us: %x\n", 1752281, v51, v52, v53, v54);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v3; // edx
int v4; // ecx
int v5; // er8
int v6; // er9
int v7; // edx
int v8; // ecx
int v9; // er8
int v10; // er9
int v11; // edx
int v12; // ecx
int v13; // er8
int v14; // er9
int v15; // edx
int v16; // ecx
int v17; // er8
int v18; // er9
int v19; // edx
int v20; // ecx
int v21; // er8
int v22; // er9
int v23; // ecx
int v24; // er8
int v25; // er9
int v26; // edx
int v27; // ecx
int v28; // er8
int v29; // er9
int v30; // edx
int v31; // ecx
int v32; // er8
int v33; // er9
int v34; // ecx
int v35; // er8
int v36; // er9
int v37; // edx
int v38; // ecx
int v39; // er8
int v40; // er9
int v41; // ebp
__int64 v42; // rbx
int v43; // edx
int v44; // ecx
int v45; // er8
int v46; // er9
int v47; // edx
int v48; // ecx
int v49; // er8
int v50; // er9
int v51; // edx
int v52; // ecx
int v53; // er8
int v54; // er9
unsigned int v56; // [rsp+8h] [rbp-20h] BYREF
__int64 v57[3]; // [rsp+Ch] [rbp-1Ch] BYREF

srand(3u);
printf("libc: %%\n");
func17((unsigned int)" us: %%\n", (_DWORD)argv, v3, v4, v5, v6);
printf("libc: %015d\n", 4294967291LL);
func17((unsigned int)" us: %015d\n", -5, v7, v8, v9, v10);
printf("libc: %15d\n", 4294967219LL);
func17((unsigned int)" us: %15d\n", -77, v11, v12, v13, v14);
printf("libc: %015d\n", 3360274168LL);
func17((unsigned int)" us: %015d\n", -934693128, v15, v16, v17, v18);
printf("libc: %15d\n", 3394143814LL);
func17((unsigned int)" us: %15d\n", -900823482, v19, v20, v21, v22);
printf("libc: %0300d | %070d\n", 4160344168LL, 134623128LL);
func17((unsigned int)" us: %0300d | %070d\n", -134623128, 134623128, v23, v24, v25);
printf("libc: %3c\n", 98LL);
func17((unsigned int)" us: %3c\n", 98, v26, v27, v28, v29);
printf("libc: %04d\n", 13LL);
func17((unsigned int)" us: %04d\n", 13, v30, v31, v32, v33);
printf("libc: %s %20s.\n", "Hello", "World");
func17((unsigned int)" us: %s %20s.\n", (unsigned int)"Hello", (unsigned int)"World", v34, v35, v36);
LODWORD(v57[0]) = -1;
v56 = -1;
printf("abc%n (libc capturing %%n)\n", v57);
func17((unsigned int)"abc%n (us capturing %%n)\n", (unsigned int)&v56, v37, v38, v39, v40);
printf("libc: %d\n us: %d\n", LODWORD(v57[0]), v56);
v41 = 3;
do
{
v42 = (unsigned int)func7(0, 0x7FFFFFFF);
printf("libc: %15d\n", v42);
func17((unsigned int)" us: %15d\n", v42, v43, v44, v45, v46);
--v41;
}
while ( v41 );
printf("libc: %u\n", 324234224LL);
func17((unsigned int)" us: %u\n", 324234224, v47, v48, v49, v50);
printf("libc: %x\n", 1752281LL);
func17((unsigned int)" us: %x\n", 1752281, v51, v52, v53, v54);
return 0;
}

variable_types: libc int

variable_types: us int

variable_types: r int


swap

decompiled_code:
__int64 __fastcall swap(int a1, int a2, __int64 a3)
{
_BYTE *v3; // rdi
__int64 result; // rax
_BYTE *v5; // rdx

v3 = (_BYTE *)(a3 + a1);
result = (unsigned __int8)*v3;
v5 = (_BYTE *)(a2 + a3);
*v3 = *v5;
*v5 = result;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func8(int a1, int a2, __int64 a3)
{
_BYTE *v3; // rdi
__int64 result; // rax
_BYTE *v5; // rdx

v3 = (_BYTE *)(a3 + a1);
result = (unsigned __int8)*v3;
v5 = (_BYTE *)(a2 + a3);
*v3 = *v5;
*v5 = result;
return result;
}

original_code:
void swap(int what, int with, char * out) {
    char tmp = out[what];
    out[what] = out[with];
    out[with] = tmp;
}

canonical_original_code:
void swap(int what, int with, char *out) {
    char tmp = out[what];
    out[what] = out[with];
    out[with] = tmp;
}

variable_types: what int

variable_types: with int

variable_types: tmp char

return_type: void


reverse

decompiled_code:
__int64 __fastcall reverse(__int64 a1, int a2)
{
int v2; // ebx
__int64 result; // rax

if ( a2 < 0 )
__assert_fail("nchars >= 0", "xprintf.c", 0x17u, "reverse");
v2 = 0;
if ( a2 > 1 )
{
do
{
result = swap(v2, a2 - 1 - v2, a1);
++v2;
}
while ( v2 < a2 / 2 );
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func9(__int64 a1, int a2)
{
int v2; // ebx
__int64 result; // rax

if ( a2 < 0 )
__assert_fail("nchars >= 0", "xprintf.c", 0x17u, "reverse");
v2 = 0;
if ( a2 > 1 )
{
do
{
result = func8(v2, a2 - 1 - v2, a1);
++v2;
}
while ( v2 < a2 / 2 );
}
return result;
}

original_code:
void reverse(char * out, int nchars) {
    ((void) sizeof ((nchars >= 0) ? 1 : 0), __extension__ ({ if (nchars >= 0) ; else __assert_fail ("nchars >= 0", "xprintf.c", 23, __extension__ __PRETTY_FUNCTION__); }));
    for (int i = 0; i < (nchars / 2); i++) {
        swap(i, (nchars - 1) - i, out);
    }
}

canonical_original_code:
void reverse(char *out, int nchars) {
    ((void) sizeof ((nchars >= 0) ? 1 : 0), __extension__ ({ if (nchars >= 0) ; else __assert_fail ("nchars >= 0", "xprintf.c", 23, __extension__ __PRETTY_FUNCTION__); }));
    for (int i = 0; i < (nchars / 2); i++) {
        swap(i, (nchars - 1) - i, out);
    }
}


pad

decompiled_code:
const char *__fastcall pad(int c, int a2, char *a3, const char *a4)
{
const char *v5; // rbx
int v6; // er12

v5 = a4;
v6 = strlen(a4);
memset(a3, c, a2);
a3[a2] = 0;
if ( v6 < a2 )
{
memcpy(&a3[a2 - (__int64)v6], v5, v6);
v5 = a3;
}
return v5;
}

canonical_decompiled_code:
const char *__fastcall func15(int c, int a2, char *a3, const char *a4)
{
const char *v5; // rbx
int v6; // er12

v5 = a4;
v6 = strlen(a4);
memset(a3, c, a2);
a3[a2] = 0;
if ( v6 < a2 )
{
memcpy(&a3[a2 - (__int64)v6], v5, v6);
v5 = a3;
}
return v5;
}

original_code:
char * pad(int c, int fw, char * fwb, char * str) {
    int len = strlen(str);
    memset(fwb, c, fw);
    fwb[fw] = '\0';
    if (fw > len) {
        memcpy(&fwb[fw] - len, str, len);
        return fwb;
    } else {
        return str;
    }
}

canonical_original_code:
char *pad(int c, int fw, char *fwb, char *str) {
    int len = strlen(str);
    memset(fwb, c, fw);
    fwb[fw] = '\0';
    if (fw > len) {
        memcpy(&fwb[fw] - len, str, len);
        return fwb;
    } else {
        return str;
    }
}

variable_types: c int

variable_types:
fwb
char *

variable_types:
str
char *

variable_types: len int

return_type: char *


xprintf

decompiled_code:
__int64 __fastcall xprintf(char *a1)
{
return xvfprintf((FILE *)_bss_start, a1);
}

canonical_decompiled_code:
__int64 __fastcall func17(char *a1)
{
return func16((FILE *)_bss_start, a1);
}

original_code:
int xprintf(const char * format, ...) {
    va_list args;
    __builtin_va_start(args,format);
    int ret = xvfprintf(stdout, format, args);
    __builtin_va_end(args);
    return ret;
}

canonical_original_code:
int xprintf(char *format, ...) {
    __builtin_va_list args;
    __builtin_va_start(args,format);
    int ret = xvfprintf(stdout, format, args);
    __builtin_va_end(args);
    return ret;
}

variable_types: ret int


decompiled_code:
__int64 musl_snprintf(__int64 a1, __int64 a2, __int64 a3, ...)
{
__int64 result; // rax
gcc_va_list va; // [rsp+8h] [rbp-D0h] BYREF

va_start(va, a3);
++_gcov0_musl_snprintf;
result = musl_vsnprintf(a1, a2, a3, va);
++qword_198;
return result;
}

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

va_start(va, a3);
++_gcov0_musl_snprintf;
result = musl_vsnprintf(a1, a2, a3, va);
++qword_198;
return result;
}

original_code:
int musl_snprintf(char * s, size_t n, const char * fmt, ...)
{
 int ret;
 va_list ap;
 __builtin_va_start(ap,fmt);
 ret = musl_vsnprintf(s, n, fmt, ap);
 __builtin_va_end(ap);
 return ret;
}

canonical_original_code:
int musl_snprintf(char *s, unsigned long n, char *fmt, ...)
{
 int ret;
 __builtin_va_list ap;
 __builtin_va_start(ap,fmt);
 ret = musl_vsnprintf(s, n, fmt, ap);
 __builtin_va_end(ap);
 return ret;
}

variable_types:
s
char *

variable_types:
n
unsigned long

variable_types:
fmt
char *


decompiled_code:
__int64 __fastcall huff_error(int a1)
{
return ERROR_STRINGS[-a1];
}

canonical_decompiled_code:
__int64 __fastcall func0(int a1)
{
return ERROR_STRINGS[-a1];
}

original_code:
const char * huff_error(int code) {
    return ERROR_STRINGS[-code];
}

canonical_original_code:
char *huff_error(int code) {
    return ERROR_STRINGS[-code];
}

variable_types: code int


xmalloc

decompiled_code:
void *__fastcall xmalloc(size_t a1)
{
void *result; // rax

result = malloc(a1);
if ( !result )
{
fwrite("Out of memory.\n", 1uLL, 0xFuLL, stderr);
exit(255);
}
return result;
}

canonical_decompiled_code:
void *__fastcall func1(size_t a1)
{
void *result; // rax

result = malloc(a1);
if ( !result )
{
fwrite("Out of memory.\n", 1uLL, 0xFuLL, stderr);
exit(255);
}
return result;
}

original_code:
void * xmalloc(size_t size) {
    void * out = malloc(size);
    if (out == ((void *)0)) {
        fputs("Out of memory.\n", stderr);
        exit(255);
    }
    return out;
}

canonical_original_code:
void *xmalloc(unsigned long size) {
    void *out = malloc(size);
    if (out == ((void *)0)) {
        fputs("Out of memory.\n", stderr);
        exit(255);
    }
    return out;
}

variable_types:
size
unsigned long

variable_types:
out
void *

return_type: void *


xrealloc

decompiled_code:
void *__fastcall xrealloc(void *a1, size_t a2)
{
void *result; // rax

result = realloc(a1, a2);
if ( !result )
{
if ( a2 )
{
fwrite("Out of memory.\n", 1uLL, 0xFuLL, stderr);
exit(255);
}
}
return result;
}

canonical_decompiled_code:
void *__fastcall func2(void *a1, size_t a2)
{
void *result; // rax

result = realloc(a1, a2);
if ( !result )
{
if ( a2 )
{
fwrite("Out of memory.\n", 1uLL, 0xFuLL, stderr);
exit(255);
}
}
return result;
}

original_code:
void * xrealloc(void * ptr, size_t size) {
    void * out = realloc(ptr, size);
    if (out == ((void *)0) && size != 0) {
        fputs("Out of memory.\n", stderr);
        exit(255);
    }
    return out;
}

canonical_original_code:
void *xrealloc(void *ptr, unsigned long size) {
    void *out = realloc(ptr, size);
    if (out == ((void *)0) && size != 0) {
        fputs("Out of memory.\n", stderr);
        exit(255);
    }
    return out;
}

variable_types:
ptr
void *


getArgs

original_code:
int getArgs(int * width, char *p)
{
  *width += atoi(p);
  if(*width == 0)
    return 0;
  else
    return (int) floor(log10(abs(*width)));
}

canonical_original_code:
int getArgs(int *width, char *p)
{
  *width += atoi(p);
  if(*width == 0)
    return 0;
  else
    return (int) floor(log10(abs(*width)));
}

variable_types:
width
int *

variable_types:
p
char *


utoa

decompiled_code:
char *__fastcall utoa(unsigned int a1, char *a2)
{
sprintf(a2, "%u", a1);
return a2;
}

canonical_decompiled_code:
char *__fastcall func8(unsigned int a1, char *a2)
{
sprintf(a2, "%u", a1);
return a2;
}

original_code:
char *utoa(unsigned int toConvert, char* buf)
{
  sprintf(buf, "%u", toConvert);
  return buf;
}

canonical_original_code:
char *utoa(unsigned int toConvert, char *buf)
{
  sprintf(buf, "%u", toConvert);
  return buf;
}

variable_types:
toConvert
unsigned int

variable_types:
buf
char *


reverse

original_code:
void reverse(char str[], int length)
{
  int start = 0;
  int end = length -1;
  while (start < end)
    {
      char temp = *(str+start);
      *(str+start) = *(str+end);
      *(str+end) = temp;
      start++;
      end--;
    }
}

variable_types:
str
char []

variable_types: length int

variable_types: start int

variable_types: end int

variable_types: temp char


xprintf

decompiled_code:
char *xprintf(char *a1, ...)
{
char *result; // rax
char v3; // di
const char *v4; // rbx
gcc_va_list va; // [rsp+8h] [rbp-E0h] BYREF

va_start(va, a1);
result = (char *)va[0].reg_save_area;
v3 = *a1;
if ( v3 )
{
v4 = a1;
do
{
if ( v3 == 37 )
{
result = (char *)printSpecialCase((__int64)va, v4);
}
else
{
putchar(v3);
result = (char *)v4;
}
v4 = result + 1;
v3 = result[1];
}
while ( v3 );
}
return result;
}

canonical_decompiled_code:
char *func12(char *a1, ...)
{
char *result; // rax
char v3; // di
const char *v4; // rbx
gcc_va_list va; // [rsp+8h] [rbp-E0h] BYREF

va_start(va, a1);
result = (char *)va[0].reg_save_area;
v3 = *a1;
if ( v3 )
{
v4 = a1;
do
{
if ( v3 == 37 )
{
result = (char *)func11((__int64)va, v4);
}
else
{
putchar(v3);
result = (char *)v4;
}
v4 = result + 1;
v3 = result[1];
}
while ( v3 );
}
return result;
}

original_code:
void xprintf(const char *fmt, ...)
{
  char *p;
  va_list argp;
  __builtin_va_start(argp,fmt);
  for(p = fmt; *p != '\0'; p++)
    {
      if(*p != '%')
 {
   putchar(*p);
   continue;
 }
      p = printSpecialCase(argp, p, fmt);
    }
  __builtin_va_end(argp);
}

canonical_original_code:
void xprintf(char *fmt, ...)
{
  char *p;
  __builtin_va_list argp;
  __builtin_va_start(argp,fmt);
  for(p = fmt; *p != '\0'; p++)
    {
      if(*p != '%')
 {
   putchar(*p);
   continue;
 }
      p = printSpecialCase(argp, p, fmt);
    }
  __builtin_va_end(argp);
}


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned int *v3; // rbx

v3 = (unsigned int *)malloc(4uLL);
xprintf("this%n\n", v3);
xprintf("%d\n", *v3);
xprintf("%c\n", 98LL);
xprintf("%d\n", 5LL);
xprintf("%d\n", *v3);
xprintf("%s\n", "string test");
xprintf("%u\n", 3000000000LL);
xprintf("%x\n", 10LL);
free(v3);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned int *v3; // rbx

v3 = (unsigned int *)malloc(4uLL);
func12("this%n\n", v3);
func12("%d\n", *v3);
func12("%c\n", 98LL);
func12("%d\n", 5LL);
func12("%d\n", *v3);
func12("%s\n", "string test");
func12("%u\n", 3000000000LL);
func12("%x\n", 10LL);
free(v3);
return 0;
}

original_code:
int main (int argc, char** argv)
{
  int *chars = malloc(sizeof(int));
  xprintf("this%n\n", chars);
  xprintf("%d\n", *chars);
  xprintf("%c\n", 'b');
  xprintf("%d\n", 5);
  xprintf("%d\n", *chars);
  xprintf("%s\n", "string test");
  xprintf("%u\n", (unsigned int)3000000000);
  xprintf("%x\n", 10);
  free(chars);
  return 0;
}

canonical_original_code:
int main(int argc, char **argv)
{
  int *chars = malloc(sizeof(int));
  xprintf("this%n\n", chars);
  xprintf("%d\n", *chars);
  xprintf("%c\n", 'b');
  xprintf("%d\n", 5);
  xprintf("%d\n", *chars);
  xprintf("%s\n", "string test");
  xprintf("%u\n", (unsigned int)3000000000);
  xprintf("%x\n", 10);
  free(chars);
  return 0;
}

variable_types: argc int

variable_types:
argv
char **

variable_types:
chars
int *


decompiled_code:
__int64 __fastcall has_huff_ext(const char *a1)
{
size_t v1; // rax
unsigned int v2; // edx

v1 = strlen(a1);
v2 = 0;
if ( v1 > 4 )
LOBYTE(v2) = strcmp(&a1[v1 - 5], ".hurl") == 0;
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func0(const char *a1)
{
size_t v1; // rax
unsigned int v2; // edx

v1 = strlen(a1);
v2 = 0;
if ( v1 > 4 )
LOBYTE(v2) = strcmp(&a1[v1 - 5], ".hurl") == 0;
return v2;
}

original_code:
static _Bool has_huff_ext(const char * filename) {
    size_t name_length = strlen(filename);
    if (name_length < (sizeof(".hurl") - 1)) { return 0; }
    const char * ext_start = &filename[name_length - (sizeof(".hurl") - 1)];
    return strcmp(ext_start, ".hurl") == 0;
}

canonical_original_code:
static _Bool has_huff_ext(char *filename) {
    unsigned long name_length = strlen(filename);
    if (name_length < (sizeof(".hurl") - 1)) { return 0; }
    char *ext_start = &filename[name_length - (sizeof(".hurl") - 1)];
    return strcmp(ext_start, ".hurl") == 0;
}

variable_types:
filename
char *


decompiled_code:
__int64 __fastcall huff_free_hdrtable(__int64 a1)
{
void **v1; // rbx
__int64 result; // rax

v1 = (void **)(a1 + 8);
do
free(*v1++);
while ( v1 != (void **)(a1 + 2056) );
*(_QWORD *)(a1 + 8) = 0LL;
*(_QWORD *)(a1 + 2048) = 0LL;
result = 0LL;
memset(
(void *)((a1 + 16) & 0xFFFFFFFFFFFFFFF8LL),
0,
8LL * (((unsigned int)a1 - (((_DWORD)a1 + 16) & 0xFFFFFFF8) + 2056) >> 3));
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1)
{
void **v1; // rbx
__int64 result; // rax

v1 = (void **)(a1 + 8);
do
free(*v1++);
while ( v1 != (void **)(a1 + 2056) );
*(_QWORD *)(a1 + 8) = 0LL;
*(_QWORD *)(a1 + 2048) = 0LL;
result = 0LL;
memset(
(void *)((a1 + 16) & 0xFFFFFFFFFFFFFFF8LL),
0,
8LL * (((unsigned int)a1 - (((_DWORD)a1 + 16) & 0xFFFFFFF8) + 2056) >> 3));
return result;
}

original_code:
int huff_free_hdrtable(struct huff_header * header) {
    for (int i = 0; i < 256; i++) {
        free(header->table[i]);
    }
    memset(header->table, 0, 256 * sizeof(char *));
    return 0;
}

canonical_original_code:
int huff_free_hdrtable(struct huff_header *header) {
    for (int i = 0; i < 256; i++) {
        free(header->table[i]);
    }
    memset(header->table, 0, 256 * sizeof(char *));
    return 0;
}

variable_types: struct huff_header { unsigned long length; char *table[256]; } *

variable_types: i int


printType

decompiled_code:
int __fastcall printType(__int64 a1, __int64 a2, __int64 a3)
{
__int64 v3; // rax
__int64 v4; // rsi
__int64 v6; // [rsp+8h] [rbp-20h] BYREF
__int64 v7; // [rsp+10h] [rbp-18h] BYREF
__int64 v8; // [rsp+18h] [rbp-10h] BYREF

v8 = a1;
v7 = a2;
v6 = a3;
if ( a1 == a3 || a1 == a2 || a2 == a3 )
printf("isosceles ");
else
printf("scalene ");
v3 = v7;
v4 = v6;
if ( v8 >= v6 )
v4 = v8;
if ( v7 > v4 )
{
swap(&v6, &v7);
}
else
{
if ( v7 < v6 )
v3 = v6;
if ( v8 > v3 )
swap(&v6, &v8);
}
if ( v6 - v8 == v7 )
return puts("right");
if ( v6 - v8 >= v7 )
return puts("obtuse");
return puts("acute");
}

canonical_decompiled_code:
int __fastcall func9(__int64 a1, __int64 a2, __int64 a3)
{
__int64 v3; // rax
__int64 v4; // rsi
__int64 v6; // [rsp+8h] [rbp-20h] BYREF
__int64 v7; // [rsp+10h] [rbp-18h] BYREF
__int64 v8; // [rsp+18h] [rbp-10h] BYREF

v8 = a1;
v7 = a2;
v6 = a3;
if ( a1 == a3 || a1 == a2 || a2 == a3 )
printf("isosceles ");
else
printf("scalene ");
v3 = v7;
v4 = v6;
if ( v8 >= v6 )
v4 = v8;
if ( v7 > v4 )
{
func8(&v6, &v7);
}
else
{
if ( v7 < v6 )
v3 = v6;
if ( v8 > v3 )
func8(&v6, &v8);
}
if ( v6 - v8 == v7 )
return puts("right");
if ( v6 - v8 >= v7 )
return puts("obtuse");
return puts("acute");
}

original_code:
void printType(long long a, long long int b, long long int c)
{
  if(a == b || a == c || b == c)
    printf("isosceles ");
  else
    printf("scalene ");
  if(b > a && b > c)
    swap(&c, &b);
  else if(a > c && a > b)
    swap(&c, &a);
  if(c - a == b)
    printf("right\n");
  else if(c - a < b)
    printf("acute\n");
  else
    printf("obtuse\n");
}

canonical_original_code:
void printType(long long a, long long b, long long c)
{
  if(a == b || a == c || b == c)
    printf("isosceles ");
  else
    printf("scalene ");
  if(b > a && b > c)
    swap(&c, &b);
  else if(a > c && a > b)
    swap(&c, &a);
  if(c - a == b)
    printf("right\n");
  else if(c - a < b)
    printf("acute\n");
  else
    printf("obtuse\n");
}

variable_types:
a
long long

variable_types:
b
long long

variable_types:
c
long long


distanceSquared

original_code:
long long distanceSquared(struct Point a, struct Point b)
{
  return ((a.x - b.x)*(a.x - b.x)) + ((a.y - b.y)*(a.y - b.y));
}

variable_types: struct Point { long long x; long long y; }

variable_types:
b
struct Point

return_type: long long


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int64 v3; // r15
__int64 v4; // r14
__int64 v5; // rbp
__int64 v6; // rbx
__int64 v7; // r13
__int64 v8; // r12
__int64 v9; // r14
__int64 v10; // rax
__int64 v12; // [rsp+8h] [rbp-40h]

v3 = atoi(argv[1]);
v4 = atoi(argv[2]);
v5 = atoi(argv[3]);
v6 = atoi(argv[4]);
v7 = atoi(argv[5]);
v8 = atoi(argv[6]);
if ( (v7 - v5) * (v6 - v4) == (v5 - v3) * (v8 - v6) )
{
puts("not a triangle");
}
else
{
v12 = distanceSquared(v3, v4, v5, v6);
v9 = distanceSquared(v3, v4, v7, v8);
v10 = distanceSquared(v5, v6, v7, v8);
printType(v12, v9, v10);
}
return 0;
}

original_code:
int main(int argc, char* argv[])
{
  struct Point a, b, c;
  long long ab, ac, bc;
  a.x = atoi(argv[1]);
  a.y = atoi(argv[2]);
  b.x = atoi(argv[3]);
  b.y = atoi(argv[4]);
  c.x = atoi(argv[5]);
  c.y = atoi(argv[6]);
  if(((b.y - a.y) * (c.x - b.x)) == ((c.y - b.y) * (b.x - a.x)))
  {
    printf("not a triangle\n");
    return 0;
  }
  ab = distanceSquared(a, b);
  ac = distanceSquared(a, c);
  bc = distanceSquared(b, c);
  printType(ab, ac, bc);
  return 0;
}

canonical_original_code:
int main(int argc, char *argv[])
{
  struct Point a; struct Point b; struct Point c;
  long long ab; long long ac; long long bc;
  a.x = atoi(argv[1]);
  a.y = atoi(argv[2]);
  b.x = atoi(argv[3]);
  b.y = atoi(argv[4]);
  c.x = atoi(argv[5]);
  c.y = atoi(argv[6]);
  if(((b.y - a.y) * (c.x - b.x)) == ((c.y - b.y) * (b.x - a.x)))
  {
    printf("not a triangle\n");
    return 0;
  }
  ab = distanceSquared(a, b);
  ac = distanceSquared(a, c);
  bc = distanceSquared(b, c);
  printType(ab, ac, bc);
  return 0;
}

variable_types:
argv
char *[]

variable_types:
ab
long long

variable_types:
ac
long long

variable_types:
bc
long long


padZeros

decompiled_code:
__int64 __fastcall padZeros(int a1)
{
int i; // ebx
__int64 result; // rax

if ( a1 > 0 )
{
for ( i = 0; i != a1; ++i )
putchar(48);
}
result = 0LL;
if ( a1 >= 0 )
result = (unsigned int)a1;
return result;
}

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

if ( a1 > 0 )
{
for ( i = 0; i != a1; ++i )
putchar(48);
}
result = 0LL;
if ( a1 >= 0 )
result = (unsigned int)a1;
return result;
}

original_code:
int padZeros(int i)
{
  int j;
  for(j = 0; j < i; j++)
    putchar('0');
  if(i >= 0)
    return i;
  else
    return 0;
}

variable_types: j int


utoa

decompiled_code:
__int64 __fastcall utoa(int a1, __int64 a2)
{
do
{
*(_BYTE *)++a2 = a1 % 10;
a1 /= 10;
}
while ( a1 );
return a2;
}

original_code:
char* utoa( unsigned int val, char* result)
{
  int quotient = val;
  do {
    *++result = quotient % 10;
    quotient /= 10;
  } while ( quotient );
  return result;
}

canonical_original_code:
char *utoa(unsigned int val, char *result)
{
  int quotient = val;
  do {
    *++result = quotient % 10;
    quotient /= 10;
  } while ( quotient );
  return result;
}

variable_types:
val
unsigned int

variable_types:
result
char *

variable_types: quotient int


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
double v3; // xmm0_8
double v4; // xmm1_8
double v5; // xmm2_8
double v6; // xmm3_8
double v7; // xmm4_8
double v8; // xmm5_8
double v9; // xmm6_8
double v10; // xmm7_8

return xprintf("Hello World %n\n", v3, v4, v5, v6, v7, v8, v9, v10, argv, envp);
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
double v3; // xmm0_8
double v4; // xmm1_8
double v5; // xmm2_8
double v6; // xmm3_8
double v7; // xmm4_8
double v8; // xmm5_8
double v9; // xmm6_8
double v10; // xmm7_8

return func9("Hello World %n\n", v3, v4, v5, v6, v7, v8, v9, v10, argv, envp);
}

original_code:
void main()
{
  xprintf("Hello World %n\n");
}


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

v1 = strlen(src);
v2 = (char *)malloc(v1 + 6);
v3 = strcpy(v2, src);
strcat(v3, ".hurl");
return v3;
}

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

v1 = strlen(src);
v2 = (char *)malloc(v1 + 6);
v3 = strcpy(v2, src);
strcat(v3, ".hurl");
return v3;
}

original_code:
char *get_new_name (char *filename)
{
 int length = strlen(filename);
 char *name = malloc(length + 6);
 name = strcpy(name, filename);
 if (name == ((void *)0)) {
  printf("Failed to get new name.\n");
  exit(255);
 }
 strcat(name, ".hurl");
 return name;
}

canonical_original_code:
char *get_new_name(char *filename)
{
 int length = strlen(filename);
 char *name = malloc(length + 6);
 name = strcpy(name, filename);
 if (name == ((void *)0)) {
  printf("Failed to get new name.\n");
  exit(255);
 }
 strcat(name, ".hurl");
 return name;
}

variable_types: length int

variable_types:
name
char *


unpackByte

decompiled_code:
__int64 __fastcall unpackByte(int a1, _DWORD *a2, int *a3)
{
__int64 result; // rax

result = (a1 >> 7) & 1;
*a2 = result;
*a3 = a1 & 0x7F;
return result;
}

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

result = (a1 >> 7) & 1;
*a2 = result;
*a3 = a1 & 0x7F;
return result;
}

original_code:
void unpackByte( int packed, int* symbol, int* number)
{
  short symbolMask = 0x80;
  short countMask = 0x7f;
  *symbol = (packed&symbolMask)>>7;
  *number = packed&countMask;
}

canonical_original_code:
void unpackByte(int packed, int *symbol, int *number)
{
  short symbolMask = 0x80;
  short countMask = 0x7f;
  *symbol = (packed&symbolMask)>>7;
  *number = packed&countMask;
}

variable_types: packed int

variable_types:
symbol
int *

variable_types:
number
int *

variable_types: symbolMask short

variable_types: countMask short


decompiled_code:
bool __fastcall is_huff_file(FILE *stream)
{
char *v1; // rbx
bool v2; // zf
bool result; // al
int v4; // [rsp+Bh] [rbp-1Dh] BYREF
char v5; // [rsp+Fh] [rbp-19h]
char v6; // [rsp+10h] [rbp-18h] BYREF

v4 = 0;
v5 = 0;
v1 = (char *)&v4;
do
*v1++ = fgetc(stream);
while ( v1 != &v6 );
v5 = 0;
v2 = strcmp((const char *)&v4, "HURL") == 0;
result = !v2;
if ( !v2 )
{
puts("not a hurl file");
exit(255);
}
return result;
}

canonical_decompiled_code:
bool __fastcall func0(FILE *stream)
{
char *v1; // rbx
bool v2; // zf
bool result; // al
int v4; // [rsp+Bh] [rbp-1Dh] BYREF
char v5; // [rsp+Fh] [rbp-19h]
char v6; // [rsp+10h] [rbp-18h] BYREF

v4 = 0;
v5 = 0;
v1 = (char *)&v4;
do
*v1++ = fgetc(stream);
while ( v1 != &v6 );
v5 = 0;
v2 = strcmp((const char *)&v4, "HURL") == 0;
result = !v2;
if ( !v2 )
{
puts("not a hurl file");
exit(255);
}
return result;
}

original_code:
_Bool is_huff_file(const char* filename){
    const char *dot = strrchr(filename, '.');
    if(!dot || dot == filename) return 0;
    return strcmp(".hurl", dot) == 0;
}

canonical_original_code:
_Bool is_huff_file(char *filename){
    char *dot = strrchr(filename, '.');
    if(!dot || dot == filename) return 0;
    return strcmp(".hurl", dot) == 0;
}

variable_types:
filename
char *

variable_types:
dot
char *


repo: regit/SuricataC

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

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

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

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

original_code:
pcap_file_t * add_entry(pcap_file_t *list, pcap_file_t *entry)
{
 if (list == ((void *)0)) {
  entry->next = ((void *)0);
  return entry;
 }
 entry->next = list;
 list = entry;
 return list;
}

canonical_original_code:
struct _pcap_file_t *add_entry(struct _pcap_file_t *list, struct _pcap_file_t *entry)
{
 if (list == ((void *)0)) {
  entry->next = ((void *)0);
  return entry;
 }
 entry->next = list;
 list = entry;
 return list;
}

variable_types:
list
struct _pcap_file_t *

variable_types:
entry
struct _pcap_file_t *

return_type: struct _pcap_file_t { char *filename; char *dirname; struct _pcap_file_t *next; } *


decompiled_code:
__int64 __fastcall validate_entry(const char **a1)
{
unsigned int v1; // ebp
int *v3; // rax
char *v4; // rax
int *v5; // rax
char *v6; // rax
struct stat v7; // [rsp+0h] [rbp-A8h] BYREF

if ( access(*a1, 4) )
{
v3 = __errno_location();
v4 = strerror(*v3);
printf("Unable to access file '%s': %s\n", *a1, v4);
v1 = 0;
}
else
{
v1 = stat((char *)a1[1], &v7);
if ( v1 )
{
v5 = __errno_location();
v6 = strerror(*v5);
printf("Unable to access dir '%s' stat: %s\n", a1[1], v6);
v1 = 0;
}
else if ( (v7.st_mode & 0xF000) == 0x4000 )
{
v1 = 1;
}
else
{
printf("File '%s' is not a directory.\n", a1[1]);
}
}
return v1;
}

canonical_decompiled_code:
__int64 __fastcall func8(const char **a1)
{
unsigned int v1; // ebp
int *v3; // rax
char *v4; // rax
int *v5; // rax
char *v6; // rax
struct stat v7; // [rsp+0h] [rbp-A8h] BYREF

if ( access(*a1, 4) )
{
v3 = __errno_location();
v4 = strerror(*v3);
printf("Unable to access file '%s': %s\n", *a1, v4);
v1 = 0;
}
else
{
v1 = func13((char *)a1[1], &v7);
if ( v1 )
{
v5 = __errno_location();
v6 = strerror(*v5);
printf("Unable to access dir '%s' stat: %s\n", a1[1], v6);
v1 = 0;
}
else if ( (v7.st_mode & 0xF000) == 0x4000 )
{
v1 = 1;
}
else
{
printf("File '%s' is not a directory.\n", a1[1]);
}
}
return v1;
}

original_code:
int validate_entry(pcap_file_t *entry)
{
 struct stat st;
 int ret = 0;
 ret = access(entry->filename, 4);
 if (ret != 0) {
  printf("Unable to access file '%s': %s\n",
    entry->filename,
    strerror((*__errno_location ())));
  return 0;
 }
 if (stat(entry->dirname, &st) != 0) {
  printf("Unable to access dir '%s' stat: %s\n",
    entry->dirname,
    strerror((*__errno_location ())));
  return 0;
 }
 if ((st.st_mode & 0170000) != 0040000) {
  printf("File '%s' is not a directory.\n", entry->dirname);
  return 0;
 }
 return 1;
}

canonical_original_code:
int validate_entry(struct _pcap_file_t *entry)
{
 struct stat st;
 int ret = 0;
 ret = access(entry->filename, 4);
 if (ret != 0) {
  printf("Unable to access file '%s': %s\n",
    entry->filename,
    strerror((*__errno_location ())));
  return 0;
 }
 if (stat(entry->dirname, &st) != 0) {
  printf("Unable to access dir '%s' stat: %s\n",
    entry->dirname,
    strerror((*__errno_location ())));
  return 0;
 }
 if ((st.st_mode & 0170000) != 0040000) {
  printf("File '%s' is not a directory.\n", entry->dirname);
  return 0;
 }
 return 1;
}

variable_types: struct _pcap_file_t { char *filename; char *dirname; struct _pcap_file_t *next; } *

variable_types: struct stat { unsigned long st_dev; unsigned long st_ino; unsigned long st_nlink; unsigned int st_mode; unsigned int st_uid; unsigned int st_gid; int __pad0; unsigned long st_rdev; long st_size; long st_blksize; long st_blocks; struct timespec { long tv_sec; long tv_nsec; } st_atim; struct timespec st_mtim; struct timespec st_ctim; long __glibc_reserved[3]; }

variable_types: ret int

user_defined_types: struct stat { unsigned long st_dev; unsigned long st_ino; unsigned long st_nlink; unsigned int st_mode; unsigned int st_uid; unsigned int st_gid; int __pad0; unsigned long st_rdev; long st_size; long st_blksize; long st_blocks; struct timespec st_atim; struct timespec st_mtim; struct timespec st_ctim; long __glibc_reserved[3]; }


decompiled_code:
__int64 __fastcall process_pcap_file(int fd, const char **a2)
{
int v2; // eax
int v3; // eax
__int64 result; // rax
int *v5; // rax
char *v6; // rax
int *v7; // rax
char *v8; // rax
int *v9; // rax
char *v10; // rax
char v11[520]; // [rsp+0h] [rbp-208h] BYREF

memset(v11, 0, 0x200uLL);
v2 = snprintf(
v11,
0x1FFuLL,
"{ \"command\": \"pcap-file\", \"arguments\": { \"filename\": \"%s\", \"output-dir\": \"%s\" } }",
*a2,
a2[1]);
if ( v2 < 0 )
{
v5 = __errno_location();
v6 = strerror(*v5);
printf("Can not create message: %s\n", v6);
result = 0LL;
}
else if ( v2 == 511 )
{
printf("Write buffer too small");
result = 0LL;
}
else
{
v3 = send(fd, v11, 0x200uLL, 0);
if ( v3 == -1 )
{
v7 = __errno_location();
v8 = strerror(*v7);
printf("Can not send info: %s\n", v8);
result = 0LL;
}
else if ( (unsigned __int64)v3 <= 0x13 )
{
puts("Unable to send all message");
result = 0LL;
}
else
{
usleep(0x186A0u);
memset(v11, 0, 0x200uLL);
if ( (unsigned int)read(fd, v11, 0x200uLL) == -1 )
{
v9 = __errno_location();
v10 = strerror(*v9);
printf("Can not read answer: %s\n", v10);
result = 0LL;
}
else
{
printf("Buffer: %s.\n", v11);
result = 1LL;
}
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func10(int fd, const char **a2)
{
int v2; // eax
int v3; // eax
__int64 result; // rax
int *v5; // rax
char *v6; // rax
int *v7; // rax
char *v8; // rax
int *v9; // rax
char *v10; // rax
char v11[520]; // [rsp+0h] [rbp-208h] BYREF

memset(v11, 0, 0x200uLL);
v2 = snprintf(
v11,
0x1FFuLL,
"{ \"command\": \"pcap-file\", \"arguments\": { \"filename\": \"%s\", \"output-dir\": \"%s\" } }",
*a2,
a2[1]);
if ( v2 < 0 )
{
v5 = __errno_location();
v6 = strerror(*v5);
printf("Can not create message: %s\n", v6);
result = 0LL;
}
else if ( v2 == 511 )
{
printf("Write buffer too small");
result = 0LL;
}
else
{
v3 = send(fd, v11, 0x200uLL, 0);
if ( v3 == -1 )
{
v7 = __errno_location();
v8 = strerror(*v7);
printf("Can not send info: %s\n", v8);
result = 0LL;
}
else if ( (unsigned __int64)v3 <= 0x13 )
{
puts("Unable to send all message");
result = 0LL;
}
else
{
usleep(0x186A0u);
memset(v11, 0, 0x200uLL);
if ( (unsigned int)read(fd, v11, 0x200uLL) == -1 )
{
v9 = __errno_location();
v10 = strerror(*v9);
printf("Can not read answer: %s\n", v10);
result = 0LL;
}
else
{
printf("Buffer: %s.\n", v11);
result = 1LL;
}
}
}
return result;
}

original_code:
int process_pcap_file(int sck, pcap_file_t *files)
{
 int ret;
 char buffer[512];
 memset(buffer, 0, sizeof(buffer));
 ret = snprintf(buffer, sizeof(buffer) - 1,
  "{ \"command\": \"pcap-file\", "
  "\"arguments\": { \"filename\": "
  "\"%s\", \"output-dir\": \"%s\" } }",
  files->filename,
  files->dirname);
 if (ret < 0) {
  printf("Can not create message: %s\n", strerror((*__errno_location ())));
  return 0;
 } else if (ret == sizeof(buffer) - 1) {
  printf("Write buffer too small");
  return 0;
 }
 ret = send(sck, buffer, sizeof(buffer), 0);
 if (ret == -1) {
  printf("Can not send info: %s\n", strerror((*__errno_location ())));
  return 0;
 } else if (ret < strlen("{ \"version\": \"0.1\" }")) {
  printf("Unable to send all message\n");
  return 0;
 }
 usleep(100 * 1000);
 memset(buffer, 0, sizeof(buffer));
 ret = read(sck, buffer, sizeof(buffer));
 if (ret == -1) {
  printf("Can not read answer: %s\n", strerror((*__errno_location ())));
  return 0;
 }
 printf("Buffer: %s.\n", buffer);
 return 1;
}

canonical_original_code:
int process_pcap_file(int sck, struct _pcap_file_t *files)
{
 int ret;
 char buffer[512];
 memset(buffer, 0, sizeof(buffer));
 ret = snprintf(buffer, sizeof(buffer) - 1,
  "{ \"command\": \"pcap-file\", "
  "\"arguments\": { \"filename\": "
  "\"%s\", \"output-dir\": \"%s\" } }",
  files->filename,
  files->dirname);
 if (ret < 0) {
  printf("Can not create message: %s\n", strerror((*__errno_location ())));
  return 0;
 } else if (ret == sizeof(buffer) - 1) {
  printf("Write buffer too small");
  return 0;
 }
 ret = send(sck, buffer, sizeof(buffer), 0);
 if (ret == -1) {
  printf("Can not send info: %s\n", strerror((*__errno_location ())));
  return 0;
 } else if (ret < strlen("{ \"version\": \"0.1\" }")) {
  printf("Unable to send all message\n");
  return 0;
 }
 usleep(100 * 1000);
 memset(buffer, 0, sizeof(buffer));
 ret = read(sck, buffer, sizeof(buffer));
 if (ret == -1) {
  printf("Can not read answer: %s\n", strerror((*__errno_location ())));
  return 0;
 }
 printf("Buffer: %s.\n", buffer);
 return 1;
}

variable_types: sck int

variable_types:
buffer
char [512]

user_defined_types: struct _pcap_file_t { char *filename; char *dirname; struct _pcap_file_t *next; }


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
char *i; // rbp
int v4; // eax
const char **v5; // rbp
const char **v6; // rbx
int v7; // ebx
int v8; // eax
int *v9; // rax
char *v10; // rax
int *v11; // rax
char *v12; // rax
int *v13; // rax
char *v14; // rax
int *v15; // rax
char *v16; // rax
char v18[512]; // [rsp+0h] [rbp-288h] BYREF
struct sockaddr addr; // [rsp+200h] [rbp-88h] BYREF
char v20; // [rsp+26Dh] [rbp-1Bh]

for ( i = 0LL; ; i = (char *)optarg )
{
v4 = getopt(argc, (char *const *)argv, "hf:");
if ( v4 == -1 )
break;
if ( v4 != 102 )
{
if ( v4 == 104 )
{
puts("Devine.");
exit(0);
}
puts("Option inconnue.");
exit(-1);
}
}
if ( i )
{
if ( _bss_start != argc )
{
puts("File and command entry are exclusive");
exit(-1);
}
v5 = (const char **)read_filelist(i);
}
else
{
if ( argc - _bss_start != 2 )
{
puts("Invalid number of arguments.");
exit(-1);
}
v5 = (const char **)create_entry(argv[_bss_start], argv[_bss_start + 1]);
}
if ( v5 )
{
v6 = v5;
do
{
if ( !(unsigned int)validate_entry(v6) )
exit(-1);
v6 = (const char **)v6[2];
}
while ( v6 );
}
v7 = socket(1, 1, 0);
if ( v7 == -1 )
{
v9 = __errno_location();
v10 = strerror(*v9);
printf("Can not create socket: %s\n", v10);
exit(-1);
}
addr.sa_family = 1;
strncpy(addr.sa_data, "/usr/local/var//run/suricata/suricata-command.socket", 0x6BuLL);
v20 = 0;
if ( connect(v7, &addr, 0x6Eu) == -1 )
{
v11 = __errno_location();
v12 = strerror(*v11);
printf("Can not connect: %s\n", v12);
exit(-1);
}
v8 = send(v7, "{ \"version\": \"0.1\" }", 0x14uLL, 0);
if ( v8 == -1 )
{
v13 = __errno_location();
v14 = strerror(*v13);
printf("Can not send info: %s\n", v14);
exit(-1);
}
if ( (unsigned __int64)v8 <= 0x13 )
{
puts("Unable to send all message");
exit(-1);
}
memset(v18, 0, sizeof(v18));
if ( (unsigned int)read(v7, v18, 0x200uLL) == -1 )
{
v15 = __errno_location();
v16 = strerror(*v15);
printf("Can not read answer: %s\n", v16);
exit(-1);
}
printf("Buffer: %s.\n", v18);
while ( v5 )
{
if ( !(unsigned int)process_pcap_file(v7, v5) )
printf("Unable to process '%s'", *v5);
v5 = (const char **)v5[2];
}
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
char *i; // rbp
int v4; // eax
const char **v5; // rbp
const char **v6; // rbx
int v7; // ebx
int v8; // eax
int *v9; // rax
char *v10; // rax
int *v11; // rax
char *v12; // rax
int *v13; // rax
char *v14; // rax
int *v15; // rax
char *v16; // rax
char v18[512]; // [rsp+0h] [rbp-288h] BYREF
struct sockaddr addr; // [rsp+200h] [rbp-88h] BYREF
char v20; // [rsp+26Dh] [rbp-1Bh]

for ( i = 0LL; ; i = (char *)optarg )
{
v4 = getopt(argc, (char *const *)argv, "hf:");
if ( v4 == -1 )
break;
if ( v4 != 102 )
{
if ( v4 == 104 )
{
puts("Devine.");
exit(0);
}
puts("Option inconnue.");
exit(-1);
}
}
if ( i )
{
if ( _bss_start != argc )
{
puts("File and command entry are exclusive");
exit(-1);
}
v5 = (const char **)func9(i);
}
else
{
if ( argc - _bss_start != 2 )
{
puts("Invalid number of arguments.");
exit(-1);
}
v5 = (const char **)create_entry(argv[_bss_start], argv[_bss_start + 1]);
}
if ( v5 )
{
v6 = v5;
do
{
if ( !(unsigned int)func8(v6) )
exit(-1);
v6 = (const char **)v6[2];
}
while ( v6 );
}
v7 = socket(1, 1, 0);
if ( v7 == -1 )
{
v9 = __errno_location();
v10 = strerror(*v9);
printf("Can not create socket: %s\n", v10);
exit(-1);
}
addr.sa_family = 1;
strncpy(addr.sa_data, "/usr/local/var//run/suricata/suricata-command.socket", 0x6BuLL);
v20 = 0;
if ( connect(v7, &addr, 0x6Eu) == -1 )
{
v11 = __errno_location();
v12 = strerror(*v11);
printf("Can not connect: %s\n", v12);
exit(-1);
}
v8 = send(v7, "{ \"version\": \"0.1\" }", 0x14uLL, 0);
if ( v8 == -1 )
{
v13 = __errno_location();
v14 = strerror(*v13);
printf("Can not send info: %s\n", v14);
exit(-1);
}
if ( (unsigned __int64)v8 <= 0x13 )
{
puts("Unable to send all message");
exit(-1);
}
memset(v18, 0, sizeof(v18));
if ( (unsigned int)read(v7, v18, 0x200uLL) == -1 )
{
v15 = __errno_location();
v16 = strerror(*v15);
printf("Can not read answer: %s\n", v16);
exit(-1);
}
printf("Buffer: %s.\n", v18);
while ( v5 )
{
if ( !(unsigned int)func10(v7, v5) )
printf("Unable to process '%s'", *v5);
v5 = (const char **)v5[2];
}
return 0;
}

original_code:
int main(int argc, char *argv[])
{
 int opt;
 int sck;
 struct sockaddr_un addr;
 char buffer[512];
 int ret;
 char* filelist = ((void *)0);
 pcap_file_t *pcap_list = ((void *)0);
 pcap_file_t *pp_list = ((void *)0);
 while ((opt = getopt(argc, argv, "hf:")) != -1) {
  switch (opt) {
   case 'h':
    printf("Devine.\n");
    exit(0);
   case 'f':
    filelist = optarg;
    break;
   default:
    printf("Option inconnue.\n");
    exit(-1);
  }
 }
 if (filelist == ((void *)0)) {
  char *filename = ((void *)0);
  char * dirname = ((void *)0);
  if (argc - optind != 2) {
   printf("Invalid number of arguments.\n");
   exit(-1);
  }
  filename = argv[optind];
  dirname = argv[optind + 1];
  pcap_list = create_entry(filename, dirname);
 } else {
  if (argc - optind != 0) {
   printf("File and command entry are exclusive\n");
   exit(-1);
  }
  pcap_list = read_filelist(filelist);
 }
 pp_list = pcap_list;
 while (pp_list != ((void *)0)) {
  if (validate_entry(pp_list) == 0) {
   exit(-1);
  }
  pp_list = pp_list->next;
 }
 sck = socket(1, SOCK_STREAM, 0);
 if (sck == -1) {
  printf("Can not create socket: %s\n", strerror((*__errno_location ())));
  exit(-1);
 }
 addr.sun_family = 1;
 strncpy(addr.sun_path, "/usr/local/var/" "/run/suricata/" "suricata-command.socket", sizeof(addr.sun_path));
 addr.sun_path[sizeof(addr.sun_path) - 1] = 0;
 ret = connect(sck, (struct sockaddr *) &addr, sizeof(addr));
 if (ret == -1) {
  printf("Can not connect: %s\n", strerror((*__errno_location ())));
  exit(-1);
 }
 ret = send(sck, "{ \"version\": \"0.1\" }", strlen("{ \"version\": \"0.1\" }"), 0);
 if (ret == -1) {
  printf("Can not send info: %s\n", strerror((*__errno_location ())));
  exit(-1);
 } else if (ret < strlen("{ \"version\": \"0.1\" }")) {
  printf("Unable to send all message\n");
  exit(-1);
 }
 memset(buffer, 0, sizeof(buffer));
 ret = read(sck, buffer, sizeof(buffer));
 if (ret == -1) {
  printf("Can not read answer: %s\n", strerror((*__errno_location ())));
  exit(-1);
 }
 printf("Buffer: %s.\n", buffer);
 pp_list = pcap_list;
 while (pp_list != ((void *)0)) {
  if (process_pcap_file(sck, pp_list) == 0) {
   printf("Unable to process '%s'", pp_list->filename);
  }
  pp_list = pp_list->next;
 }
 return 0;
}

canonical_original_code:
int main(int argc, char *argv[])
{
 int opt;
 int sck;
 struct sockaddr_un addr;
 char buffer[512];
 int ret;
 char *filelist = ((void *)0);
 struct _pcap_file_t *pcap_list = ((void *)0);
 struct _pcap_file_t *pp_list = ((void *)0);
 while ((opt = getopt(argc, argv, "hf:")) != -1) {
  switch (opt) {
   case 'h':
    printf("Devine.\n");
    exit(0);
   case 'f':
    filelist = optarg;
    break;
   default:
    printf("Option inconnue.\n");
    exit(-1);
  }
 }
 if (filelist == ((void *)0)) {
  char *filename = ((void *)0);
  char *dirname = ((void *)0);
  if (argc - optind != 2) {
   printf("Invalid number of arguments.\n");
   exit(-1);
  }
  filename = argv[optind];
  dirname = argv[optind + 1];
  pcap_list = create_entry(filename, dirname);
 } else {
  if (argc - optind != 0) {
   printf("File and command entry are exclusive\n");
   exit(-1);
  }
  pcap_list = read_filelist(filelist);
 }
 pp_list = pcap_list;
 while (pp_list != ((void *)0)) {
  if (validate_entry(pp_list) == 0) {
   exit(-1);
  }
  pp_list = pp_list->next;
 }
 sck = socket(1, SOCK_STREAM, 0);
 if (sck == -1) {
  printf("Can not create socket: %s\n", strerror((*__errno_location ())));
  exit(-1);
 }
 addr.sun_family = 1;
 strncpy(addr.sun_path, "/usr/local/var/" "/run/suricata/" "suricata-command.socket", sizeof(addr.sun_path));
 addr.sun_path[sizeof(addr.sun_path) - 1] = 0;
 ret = connect(sck, (struct sockaddr *) &addr, sizeof(addr));
 if (ret == -1) {
  printf("Can not connect: %s\n", strerror((*__errno_location ())));
  exit(-1);
 }
 ret = send(sck, "{ \"version\": \"0.1\" }", strlen("{ \"version\": \"0.1\" }"), 0);
 if (ret == -1) {
  printf("Can not send info: %s\n", strerror((*__errno_location ())));
  exit(-1);
 } else if (ret < strlen("{ \"version\": \"0.1\" }")) {
  printf("Unable to send all message\n");
  exit(-1);
 }
 memset(buffer, 0, sizeof(buffer));
 ret = read(sck, buffer, sizeof(buffer));
 if (ret == -1) {
  printf("Can not read answer: %s\n", strerror((*__errno_location ())));
  exit(-1);
 }
 printf("Buffer: %s.\n", buffer);
 pp_list = pcap_list;
 while (pp_list != ((void *)0)) {
  if (process_pcap_file(sck, pp_list) == 0) {
   printf("Unable to process '%s'", pp_list->filename);
  }
  pp_list = pp_list->next;
 }
 return 0;
}

variable_types: argc int

variable_types:
argv
char *[]

variable_types: opt int

variable_types: struct sockaddr_un { unsigned short sun_family; char sun_path[108]; }

variable_types:
filelist
char *

variable_types:
dirname
char *

user_defined_types: struct sockaddr { unsigned short sa_family; char sa_data[14]; }


repo: reklaklislaw/bookmaker

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
FILE *v3; // rbx
unsigned __int16 v4; // r12
unsigned __int16 v5; // r14
unsigned __int16 v6; // r13
unsigned __int16 v7; // r15
int v8; // eax
size_t v10; // rbp
FILE *stream; // [rsp+8h] [rbp-60h]
__int64 v12[2]; // [rsp+10h] [rbp-58h] BYREF
fpos_t pos; // [rsp+20h] [rbp-48h] BYREF

v3 = fopen(argv[1], "r+");
fgetpos(v3, &pos);
stream = fopen(argv[2], "w");
v4 = atoi(argv[3]);
v5 = atoi(argv[4]);
v6 = atoi(argv[5]);
v7 = atoi(argv[6]);
imageWidth = atoi(argv[7]);
imageHeight = atoi(argv[8]);
while ( 1 )
{
v8 = fgetc(v3);
if ( v8 == -1 )
break;
if ( v8 == 10 )
++numValues;
}
if ( numValues )
{
fsetpos(v3, &pos);
v10 = 2LL * (unsigned __int16)numValues;
v12[0] = (__int64)malloc(v10);
v12[1] = (__int64)malloc(v10);
filter((__int64)v3, v12, v4, v6, v5, v7);
updateFile(v3, v12);
calculateWindow(stream, v12);
}
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
FILE *v3; // rbx
unsigned __int16 v4; // r12
unsigned __int16 v5; // r14
unsigned __int16 v6; // r13
unsigned __int16 v7; // r15
int v8; // eax
size_t v10; // rbp
FILE *stream; // [rsp+8h] [rbp-60h]
__int64 v12[2]; // [rsp+10h] [rbp-58h] BYREF
fpos_t pos; // [rsp+20h] [rbp-48h] BYREF

v3 = fopen(argv[1], "r+");
fgetpos(v3, &pos);
stream = fopen(argv[2], "w");
v4 = atoi(argv[3]);
v5 = atoi(argv[4]);
v6 = atoi(argv[5]);
v7 = atoi(argv[6]);
imageWidth = atoi(argv[7]);
imageHeight = atoi(argv[8]);
while ( 1 )
{
v8 = fgetc(v3);
if ( v8 == -1 )
break;
if ( v8 == 10 )
++numValues;
}
if ( numValues )
{
fsetpos(v3, &pos);
v10 = 2LL * (unsigned __int16)numValues;
v12[0] = (__int64)malloc(v10);
v12[1] = (__int64)malloc(v10);
func7((__int64)v3, v12, v4, v6, v5, v7);
func8(v3, v12);
func9(stream, v12);
}
return 0;
}

original_code:
int main (int argc, char *argv[]) {
  if (argc==8) {
    char in_file[1000], out_file[1000];
    unsigned int window_width;
    unsigned int window_height;
    float skew_angle;
    unsigned int mx;
    unsigned int my;
    strcpy(in_file, argv[1]);
    strcpy(out_file, argv[2]);
    window_width = (unsigned int) atoi(argv[3]);
    window_height = (unsigned int) atoi(argv[4]);
    skew_angle = atof(argv[5]);
    mx = atoi(argv[6]);
    my = atoi(argv[7]);
    struct corners *corners = GetCornersFromFile(in_file,
       mx, my,
       skew_angle);
    UpdateCornerFile(corners, in_file);
    struct cluster **clusters = RunSlidingWindowClustering(corners,
          window_width,
          window_height);
    WriteClusters(out_file,
    clusters);
    free(corners->x);
    free(corners->y);
    free(corners);
    free(clusters);
  }
  return 0;
}

canonical_original_code:
int main(int argc, char *argv[]) {
  if (argc==8) {
    char in_file[1000]; char out_file[1000];
    unsigned int window_width;
    unsigned int window_height;
    float skew_angle;
    unsigned int mx;
    unsigned int my;
    strcpy(in_file, argv[1]);
    strcpy(out_file, argv[2]);
    window_width = (unsigned int) atoi(argv[3]);
    window_height = (unsigned int) atoi(argv[4]);
    skew_angle = atof(argv[5]);
    mx = atoi(argv[6]);
    my = atoi(argv[7]);
    struct corners *corners = GetCornersFromFile(in_file,
       mx, my,
       skew_angle);
    UpdateCornerFile(corners, in_file);
    struct cluster **clusters = RunSlidingWindowClustering(corners,
          window_width,
          window_height);
    WriteClusters(out_file,
    clusters);
    free(corners->x);
    free(corners->y);
    free(corners);
    free(clusters);
  }
  return 0;
}

variable_types:
mx
unsigned int

variable_types:
my
unsigned int

variable_types: struct corners { unsigned int *x; unsigned int *y; unsigned int num_corners; unsigned int mx; float skew_angle; } *

variable_types: struct cluster { unsigned int *corners; unsigned int size; unsigned int num; unsigned int num_clusters; struct dimensions { unsigned int l; } dimensions; } **

user_defined_types: struct cluster { unsigned int *corners; unsigned int size; unsigned int num; unsigned int num_clusters; struct dimensions dimensions; }


hash

decompiled_code:
__int64 __fastcall hash(char *a1)
{
char v1; // dl
__int64 result; // rax
int v3; // ecx
int v4; // esi

v1 = *a1;
result = 0LL;
v3 = 1;
if ( *a1 )
{
while ( 1 )
{
v4 = v3 + 1;
for ( result = (unsigned int)(v3 * v1 + result); (int)result > 2998; result = (unsigned int)(result - 2999) )
;
v1 = *++a1;
if ( !*a1 )
break;
if ( v4 >= 5 )
v4 = 1;
v3 = v4;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(char *a1)
{
char v1; // dl
__int64 result; // rax
int v3; // ecx
int v4; // esi

v1 = *a1;
result = 0LL;
v3 = 1;
if ( *a1 )
{
while ( 1 )
{
v4 = v3 + 1;
for ( result = (unsigned int)(v3 * v1 + result); (int)result > 2998; result = (unsigned int)(result - 2999) )
;
v1 = *++a1;
if ( !*a1 )
break;
if ( v4 >= 5 )
v4 = 1;
v3 = v4;
}
}
return result;
}

original_code:
static int hash(char name[])
{
  int val = 0, factor = 1;
  for(; *name; name++)
  {
    if(factor>4) factor = 1;
    val += *name * factor++;
    while(val>=2999) val -= 2999;
  }
  return val;
}

canonical_original_code:
static int hash(char name[])
{
  int val = 0; int factor = 1;
  for(; *name; name++)
  {
    if(factor>4) factor = 1;
    val += *name * factor++;
    while(val>=2999) val -= 2999;
  }
  return val;
}

variable_types:
name
char []

variable_types: val int

variable_types: factor int


comparefuncdef

decompiled_code:
int __fastcall comparefuncdef(const void *a1, const void *a2)
{
return strcmp(
*(const char **)(hashtable + 80LL * *(int *)a1 + 16),
*(const char **)(hashtable + 80LL * *(int *)a2 + 16));
}

canonical_decompiled_code:
int __fastcall func1(const void *a1, const void *a2)
{
return strcmp(
*(const char **)(hashtable + 80LL * *(int *)a1 + 16),
*(const char **)(hashtable + 80LL * *(int *)a2 + 16));
}

original_code:
static int comparefuncdef(const void *x, const void *y)
{
  return strcmp(hashtable[*(int *)x].name, hashtable[*(int *)y].name);
}

canonical_original_code:
static int comparefuncdef(void *x, void *y)
{
  return strcmp(hashtable[*(int *)x].name, hashtable[*(int *)y].name);
}

variable_types:
x
void *

variable_types:
y
void *


getfunctionnr

decompiled_code:
__int64 __fastcall getfunctionnr(char *s)
{
unsigned int v2; // ebp
__int64 v3; // rbx
const char *v4; // rdi
int v5; // er12
char *v6; // rax
int v8; // edx

v2 = hash(s);
v3 = hashtable + 80LL * (int)v2;
v4 = *(const char **)(v3 + 16);
v5 = 0;
if ( v4 )
{
while ( strcmp(v4, s) )
{
if ( v5 > 2999 )
systemerror(3LL);
v8 = v2 + 1;
v2 -= 2998;
if ( v8 <= 2998 )
v2 = v8;
v3 = hashtable + 80LL * (int)v2;
v4 = *(const char **)(v3 + 16);
++v5;
if ( !v4 )
goto LABEL_2;
}
}
else
{
LABEL_2:
v6 = strdup(s);
*(_QWORD *)(v3 + 16) = v6;
if ( !v6 )
systemerror(4LL);
if ( (unsigned __int8)(*s - 65) <= 0x19u )
{
*(_BYTE *)(v3 + 72) = 1;
*(_BYTE *)(*(_QWORD *)(v3 + 64) + 20LL) = 1;
}
}
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func2(char *s)
{
unsigned int v2; // ebp
__int64 v3; // rbx
const char *v4; // rdi
int v5; // er12
char *v6; // rax
int v8; // edx

v2 = func0(s);
v3 = hashtable + 80LL * (int)v2;
v4 = *(const char **)(v3 + 16);
v5 = 0;
if ( v4 )
{
while ( strcmp(v4, s) )
{
if ( v5 > 2999 )
systemerror(3LL);
v8 = v2 + 1;
v2 -= 2998;
if ( v8 <= 2998 )
v2 = v8;
v3 = hashtable + 80LL * (int)v2;
v4 = *(const char **)(v3 + 16);
++v5;
if ( !v4 )
goto LABEL_2;
}
}
else
{
LABEL_2:
v6 = strdup(s);
*(_QWORD *)(v3 + 16) = v6;
if ( !v6 )
systemerror(4LL);
if ( (unsigned __int8)(*s - 65) <= 0x19u )
{
*(_BYTE *)(v3 + 72) = 1;
*(_BYTE *)(*(_QWORD *)(v3 + 64) + 20LL) = 1;
}
}
return v2;
}

original_code:
static int getfunctionnr(char name[])
{
  int pos = hash(name), count = 0;
  while(hashtable[pos].name != ((void *)0) && strcmp(hashtable[pos].name, name) != 0)
  {
    if(count++>2999) systemerror(3);
    if(++pos>=2999) pos -= 2999;
  }
  if(hashtable[pos].name == ((void *)0))
  {
    FuncDef *temp = &hashtable[pos];
    temp->name = strdup(name);
    if(temp->name == ((void *)0)) systemerror(4);
    if('A' <= name[0] && name[0] <= 'Z')
    {
      temp->tag = TYPE;
      temp->template->tag = TYPE;
    }
  }
  return pos;
}

canonical_original_code:
static int getfunctionnr(char name[])
{
  int pos = hash(name); int count = 0;
  while(hashtable[pos].name != ((void *)0) && strcmp(hashtable[pos].name, name) != 0)
  {
    if(count++>2999) systemerror(3);
    if(++pos>=2999) pos -= 2999;
  }
  if(hashtable[pos].name == ((void *)0))
  {
    struct FuncDef *temp = &hashtable[pos];
    temp->name = strdup(name);
    if(temp->name == ((void *)0)) systemerror(4);
    if('A' <= name[0] && name[0] <= 'Z')
    {
      temp->tag = TYPE;
      temp->template->tag = TYPE;
    }
  }
  return pos;
}

variable_types: pos int

variable_types: count int

variable_types: struct FuncDef { void (*code)(); struct CELL { struct CELL *left; int value; unsigned char tag; } *def; char *name; int argcount; int sysfunc; int typechanged; int generic; struct CELL *typeexpr; struct CELL *abstype; int prio; enum Assoc { Left=0, Right=1 } assoc; struct CELL *template; unsigned char tag; } *

user_defined_types: struct FuncDef { void (*code)(); struct CELL *def; char *name; int argcount; int sysfunc; int typechanged; int generic; struct CELL *typeexpr; struct CELL *abstype; int prio; enum Assoc assoc; struct CELL *template; unsigned char tag; }


getdef

decompiled_code:
__int64 __fastcall getdef(char *a1)
{
__int64 v1; // rbx

v1 = hashtable;
return v1 + 80LL * (int)getfunctionnr(a1);
}

canonical_decompiled_code:
__int64 __fastcall func3(char *a1)
{
__int64 v1; // rbx

v1 = hashtable;
return v1 + 80LL * (int)func2(a1);
}

original_code:
static FuncDef *getdef(char name[])
{
  return hashtable+getfunctionnr(name);
}

canonical_original_code:
static struct FuncDef *getdef(char name[])
{
  return hashtable+getfunctionnr(name);
}

return_type: struct FuncDef { void (*code)(); struct CELL { struct CELL *left; int value; unsigned char tag; } *def; char *name; int argcount; int sysfunc; int typechanged; int generic; struct CELL *typeexpr; struct CELL *abstype; int prio; enum Assoc { Left=0, Right=1 } assoc; struct CELL *template; unsigned char tag; } *


gettemplate

decompiled_code:
__int64 __fastcall gettemplate(char *a1)
{
__int64 v1; // rbx

v1 = hashtable;
return *(_QWORD *)(v1 + 80LL * (int)getfunctionnr(a1) + 64);
}

canonical_decompiled_code:
__int64 __fastcall func4(char *a1)
{
__int64 v1; // rbx

v1 = hashtable;
return *(_QWORD *)(v1 + 80LL * (int)func2(a1) + 64);
}

original_code:
Cell *gettemplate(char name[])
{
  return hashtable[getfunctionnr(name)].template;
}

canonical_original_code:
struct CELL *gettemplate(char name[])
{
  return hashtable[getfunctionnr(name)].template;
}

return_type: struct CELL { struct CELL *left; int value; unsigned char tag; } *


insert

original_code:
bool insert(char name[], int argcount, TagType tag, Cell *def, void (*code)(void))
{
  FuncDef *fun = getdef(name);
  if(fun->code) return 0;
  if(fun->def == ((void *)0)) fun->argcount = argcount;
  else if(argcount != fun->argcount) return 0;
  fun->template->tag = fun->tag = tag;
  if(code)
    fun->code = code;
  else if(def)
  {
    Cell *temp = newcell(LIST);
    temp->left = def;
    temp->right = template_nil;
    if(fun->def == ((void *)0))
      fun->def = temp;
    else
    {
      Cell *list = fun->def;
      while(list->right->tag == LIST) list = list->right;
      list->right = temp;
    }
  }
  return 1;
}

canonical_original_code:
int insert(char name[], int argcount, unsigned char tag, struct CELL *def, void (*code)())
{
  struct FuncDef *fun = getdef(name);
  if(fun->code) return 0;
  if(fun->def == ((void *)0)) fun->argcount = argcount;
  else if(argcount != fun->argcount) return 0;
  fun->template->tag = fun->tag = tag;
  if(code)
    fun->code = code;
  else if(def)
  {
    struct CELL *temp = newcell(LIST);
    temp->left = def;
    temp->right = template_nil;
    if(fun->def == ((void *)0))
      fun->def = temp;
    else
    {
      struct CELL *list = fun->def;
      while(list->right->tag == LIST) list = list->right;
      list->right = temp;
    }
  }
  return 1;
}

variable_types: argcount int

variable_types:
tag
unsigned char

variable_types: struct CELL { struct CELL *left; int value; unsigned char tag; } *

variable_types:
code
void (*)()


storefunctionname

decompiled_code:
__int64 __fastcall storefunctionname(char *src)
{
__int64 v1; // rbx
__int64 result; // rax

strcpy(parsefunctionname, src);
v1 = newcell(13LL);
errorcell = v1;
result = getfunctionnr(parsefunctionname);
*(_DWORD *)(v1 + 16) = result;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func6(char *src)
{
__int64 v1; // rbx
__int64 result; // rax

strcpy(parsefunctionname, src);
v1 = newcell(13LL);
errorcell = v1;
result = func2(parsefunctionname);
*(_DWORD *)(v1 + 16) = result;
return result;
}

original_code:
void storefunctionname(char name[])
{
  strcpy(parsefunctionname, name);
  errorcell = newcell(ERROR);
  errorcell->value = getfunctionnr(parsefunctionname);
}


makeerror

decompiled_code:
__int64 makeerror()
{
return errorcell;
}

canonical_decompiled_code:
__int64 func7()
{
return errorcell;
}

original_code:
Cell *makeerror(void)
{
  return errorcell;
}

canonical_original_code:
struct CELL *makeerror()
{
  return errorcell;
}

user_defined_types: struct CELL { struct CELL *left; int value; unsigned char tag; }


printhashtable

decompiled_code:
__int64 printhashtable()
{
_QWORD *v0; // rax
int v1; // ebx
int i; // edx
__int64 result; // rax
int *v4; // rbp
int v5[3006]; // [rsp+0h] [rbp-2EF8h] BYREF

v0 = (_QWORD *)(hashtable + 16LL);
v1 = 0;
for ( i = 0; i != 2999; ++i )
{
if ( *v0 && *(_BYTE *)*v0 != 95 && (v0[3] || v0[4]) )
v5[v1++] = i;
v0 += 10;
}
qsort(v5, v1, 4uLL, comparefuncdef);
result = Write("\nFUNCTIONS:\n");
if ( v1 > 0 )
{
v4 = v5;
do
result = Write("%s ", *(const char **)(hashtable + 80LL * *v4++ + 16));
while ( v4 != &v5[v1 - 1 + 1] );
}
return result;
}

canonical_decompiled_code:
__int64 func8()
{
_QWORD *v0; // rax
int v1; // ebx
int i; // edx
__int64 result; // rax
int *v4; // rbp
int v5[3006]; // [rsp+0h] [rbp-2EF8h] BYREF

v0 = (_QWORD *)(hashtable + 16LL);
v1 = 0;
for ( i = 0; i != 2999; ++i )
{
if ( *v0 && *(_BYTE *)*v0 != 95 && (v0[3] || v0[4]) )
v5[v1++] = i;
v0 += 10;
}
qsort(v5, v1, 4uLL, comparefuncdef);
result = Write("\nFUNCTIONS:\n");
if ( v1 > 0 )
{
v4 = v5;
do
result = Write("%s ", *(const char **)(hashtable + 80LL * *v4++ + 16));
while ( v4 != &v5[v1 - 1 + 1] );
}
return result;
}

original_code:
void printhashtable(void)
{
  int k, index[2999], indexsize = 0;
  for(k=0; k<2999; k++)
  {
    FuncDef *fun = &(hashtable[k]);
    if(fun->name != ((void *)0)
    && fun->name[0] != '_'
    && (fun->typeexpr || fun->abstype)) index[indexsize++] = k;
  }
  qsort(index, indexsize, sizeof(int), comparefuncdef);
  Write("\nFUNCTIONS:\n");
  for(k=0; k<indexsize; k++) Write("%s ", hashtable[index[k]].name);
}

canonical_original_code:
void printhashtable()
{
  int k; int index[2999]; int indexsize = 0;
  for(k=0; k<2999; k++)
  {
    struct FuncDef *fun = &(hashtable[k]);
    if(fun->name != ((void *)0)
    && fun->name[0] != '_'
    && (fun->typeexpr || fun->abstype)) index[indexsize++] = k;
  }
  qsort(index, indexsize, sizeof(int), comparefuncdef);
  Write("\nFUNCTIONS:\n");
  for(k=0; k<indexsize; k++) Write("%s ", hashtable[index[k]].name);
}

variable_types: k int

variable_types:
index
int [2999]

variable_types: indexsize int


printusertypes

decompiled_code:
__int64 printusertypes()
{
_QWORD *v0; // rdx
int v1; // ebx
int i; // eax
__int64 result; // rax
int *v4; // rbp
int *v5; // r13
_QWORD *v6; // rbx
const char *v7; // rsi
int v8[3010]; // [rsp+0h] [rbp-2F08h] BYREF

v0 = (_QWORD *)(hashtable + 16LL);
v1 = 0;
for ( i = 0; i != 2999; ++i )
{
if ( *v0 )
v8[v1++] = i;
v0 += 10;
}
qsort(v8, v1, 4uLL, comparefuncdef);
result = Write("\nUSERDEFINED FUNCTIONS:\n");
if ( v1 > 0 )
{
v4 = v8;
v5 = &v8[v1 - 1 + 1];
do
{
result = *v4;
v6 = (_QWORD *)(hashtable + 80 * result);
if ( v6[1] )
{
v7 = (const char *)v6[2];
if ( *v7 != 95 )
{
if ( v6[6] )
{
Write(" %-15s <= ", v7);
if ( *(_BYTE *)(v6[5] + 20LL) == 33 )
WriteType(v6[6]);
else
Write("%s", *(const char **)(hashtable + 80LL * *(int *)(v6[6] + 16LL) + 16));
result = Write("\n");
}
if ( v6[5] )
{
Write(" %-15s :: ", (const char *)v6[2]);
WriteType(v6[5]);
result = Write("\n");
}
}
}
++v4;
}
while ( v4 != v5 );
}
return result;
}

canonical_decompiled_code:
__int64 func9()
{
_QWORD *v0; // rdx
int v1; // ebx
int i; // eax
__int64 result; // rax
int *v4; // rbp
int *v5; // r13
_QWORD *v6; // rbx
const char *v7; // rsi
int v8[3010]; // [rsp+0h] [rbp-2F08h] BYREF

v0 = (_QWORD *)(hashtable + 16LL);
v1 = 0;
for ( i = 0; i != 2999; ++i )
{
if ( *v0 )
v8[v1++] = i;
v0 += 10;
}
qsort(v8, v1, 4uLL, comparefuncdef);
result = Write("\nUSERDEFINED FUNCTIONS:\n");
if ( v1 > 0 )
{
v4 = v8;
v5 = &v8[v1 - 1 + 1];
do
{
result = *v4;
v6 = (_QWORD *)(hashtable + 80 * result);
if ( v6[1] )
{
v7 = (const char *)v6[2];
if ( *v7 != 95 )
{
if ( v6[6] )
{
Write(" %-15s <= ", v7);
if ( *(_BYTE *)(v6[5] + 20LL) == 33 )
WriteType(v6[6]);
else
Write("%s", *(const char **)(hashtable + 80LL * *(int *)(v6[6] + 16LL) + 16));
result = Write("\n");
}
if ( v6[5] )
{
Write(" %-15s :: ", (const char *)v6[2]);
WriteType(v6[5]);
result = Write("\n");
}
}
}
++v4;
}
while ( v4 != v5 );
}
return result;
}

original_code:
void printusertypes(void)
{
  int k, index[2999], indexsize = 0;
  for(k=0; k<2999; k++)
    if(hashtable[k].name != ((void *)0)) index[indexsize++] = k;
  qsort(index, indexsize, sizeof(int), comparefuncdef);
  Write("\nUSERDEFINED FUNCTIONS:\n");
  for(k=0; k<indexsize; k++)
  {
    FuncDef *fun = &(hashtable[index[k]]);
    if(fun->def && fun->name[0] != '_')
    {
      if(fun->abstype)
      {
        Write("   %-15s <= ", fun->name);
        if(fun->typeexpr->tag == TYPESYNONYM)
          WriteType(fun->abstype);
        else
          Write("%s", (hashtable+(fun->abstype->value))->name);
        Write("\n");
      }
      if(fun->typeexpr)
      {
        Write("   %-15s :: ", fun->name);
        WriteType(fun->typeexpr);
        Write("\n");
      }
    }
  }
}

canonical_original_code:
void printusertypes()
{
  int k; int index[2999]; int indexsize = 0;
  for(k=0; k<2999; k++)
    if(hashtable[k].name != ((void *)0)) index[indexsize++] = k;
  qsort(index, indexsize, sizeof(int), comparefuncdef);
  Write("\nUSERDEFINED FUNCTIONS:\n");
  for(k=0; k<indexsize; k++)
  {
    struct FuncDef *fun = &(hashtable[index[k]]);
    if(fun->def && fun->name[0] != '_')
    {
      if(fun->abstype)
      {
        Write("   %-15s <= ", fun->name);
        if(fun->typeexpr->tag == TYPESYNONYM)
          WriteType(fun->abstype);
        else
          Write("%s", (hashtable+(fun->abstype->value))->name);
        Write("\n");
      }
      if(fun->typeexpr)
      {
        Write("   %-15s :: ", fun->name);
        WriteType(fun->typeexpr);
        Write("\n");
      }
    }
  }
}


forallhashtable

decompiled_code:
__int64 __fastcall forallhashtable(__int64 (__fastcall *a1)(__int64))
{
__int64 i; // rbx
__int64 result; // rax

for ( i = 0LL; i != 239920; i += 80LL )
result = a1(hashtable + i);
return result;
}

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

for ( i = 0LL; i != 239920; i += 80LL )
result = a1(hashtable + i);
return result;
}

original_code:
void forallhashtable(void (*function)(FuncDef *))
{
  int k;
  for(k=0; k<2999; k++) (*function)(&hashtable[k]);
}

canonical_original_code:
void forallhashtable(void (*function)(struct FuncDef *))
{
  int k;
  for(k=0; k<2999; k++) (*function)(&hashtable[k]);
}

variable_types: void (*)(struct FuncDef { void (*code)(); struct CELL { struct CELL *left; int value; unsigned char tag; } *def; char *name; int argcount; int sysfunc; int typechanged; int generic; struct CELL *typeexpr; struct CELL *abstype; int prio; enum Assoc { Left=0, Right=1 } assoc; struct CELL *template; unsigned char tag; } *)


constantfunction

decompiled_code:
_BOOL8 __fastcall constantfunction(int a1)
{
__int64 v1; // rax
__int64 v2; // rcx
_BOOL4 v3; // edx

v1 = hashtable + 80LL * a1;
v2 = *(_QWORD *)(v1 + 8);
v3 = 0;
if ( v2 && !*(_DWORD *)(v1 + 24) )
v3 = *(_BYTE *)(v2 + 20) <= 7u;
return v3;
}

original_code:
bool constantfunction(int funnr)
{
  FuncDef *fun = &hashtable[funnr];
  return fun->def && fun->argcount == 0 && fun->def->tag < nonevaltag;
}

canonical_original_code:
int constantfunction(int funnr)
{
  struct FuncDef *fun = &hashtable[funnr];
  return fun->def && fun->argcount == 0 && fun->def->tag < nonevaltag;
}

variable_types: funnr int


restoretemplates

original_code:
void restoretemplates(void)
{
  int k;
  for(k=0; k<2999; k++)
  {
    FuncDef *fun = &(hashtable[k]);
    if(fun->name && strncmp(fun->name, "_nn_", 4) == 0)
    {
      free(fun->name);
      fun->tag = UNDEFINED;
      fun->def = ((void *)0);
      fun->argcount = 0;
      fun->name = ((void *)0);
      fun->typeexpr = ((void *)0);
      fun->abstype = ((void *)0);
      fun->code = ((void *)0);
      fun->prio = 1;
      fun->assoc = Left;
      fun->sysfunc = 0;
      fun->generic = 0;
      fun->template->tag = UNDEFINED;
      fun->template->value = k;
      fun->template->left = ((void *)0);
      fun->template->right = ((void *)0);
    }
    if(fun->def && fun->argcount == 0)
    {
      if(fun->def->tag < nonevaltag)
        *(fun->template) = *(fun->def);
      if(fun->abstype)
      {
        fun->template->tag = FUNC;
        fun->template->value = k;
        fun->template->left = ((void *)0);
        fun->template->right = ((void *)0);
      }
    }
  }
  (template_true = gettemplate("True"))->value = 1;
  (template_false = gettemplate("False"))->value = 0;
  template_nil = gettemplate("Nil");
  template_match = gettemplate("Match");
  sysvalue_fread = gettemplate("_fread")->value;
  (((RealCell *)(gettemplate("pi")))->value) = 3.14159;
}

canonical_original_code:
void restoretemplates()
{
  int k;
  for(k=0; k<2999; k++)
  {
    struct FuncDef *fun = &(hashtable[k]);
    if(fun->name && strncmp(fun->name, "_nn_", 4) == 0)
    {
      free(fun->name);
      fun->tag = UNDEFINED;
      fun->def = ((void *)0);
      fun->argcount = 0;
      fun->name = ((void *)0);
      fun->typeexpr = ((void *)0);
      fun->abstype = ((void *)0);
      fun->code = ((void *)0);
      fun->prio = 1;
      fun->assoc = Left;
      fun->sysfunc = 0;
      fun->generic = 0;
      fun->template->tag = UNDEFINED;
      fun->template->value = k;
      fun->template->left = ((void *)0);
      fun->template->right = ((void *)0);
    }
    if(fun->def && fun->argcount == 0)
    {
      if(fun->def->tag < nonevaltag)
        *(fun->template) = *(fun->def);
      if(fun->abstype)
      {
        fun->template->tag = FUNC;
        fun->template->value = k;
        fun->template->left = ((void *)0);
        fun->template->right = ((void *)0);
      }
    }
  }
  (template_true = gettemplate("True"))->value = 1;
  (template_false = gettemplate("False"))->value = 0;
  template_nil = gettemplate("Nil");
  template_match = gettemplate("Match");
  sysvalue_fread = gettemplate("_fread")->value;
  (((struct RealCell *)(gettemplate("pi")))->value) = 3.14159;
}


insertsys

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

result = getdef(a1);
*(_DWORD *)(result + 28) = 1;
return result;
}

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

result = func3(a1);
*(_DWORD *)(result + 28) = 1;
return result;
}

original_code:
void insertsys(char name[])
{
  FuncDef *fun = getdef(name);
  fun->sysfunc = 1;
}

canonical_original_code:
void insertsys(char name[])
{
  struct FuncDef *fun = getdef(name);
  fun->sysfunc = 1;
}

variable_types:
name
char []


insertoperator

decompiled_code:
__int64 __fastcall insertoperator(char *a1, int a2, int a3)
{
int v3; // ebx
__int64 result; // rax

v3 = a2;
result = getdef(a1);
if ( a2 > 7 )
v3 = 7;
if ( v3 <= 0 )
v3 = 1;
*(_DWORD *)(result + 56) = v3;
*(_DWORD *)(result + 60) = a3;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func14(char *a1, int a2, int a3)
{
int v3; // ebx
__int64 result; // rax

v3 = a2;
result = func3(a1);
if ( a2 > 7 )
v3 = 7;
if ( v3 <= 0 )
v3 = 1;
*(_DWORD *)(result + 56) = v3;
*(_DWORD *)(result + 60) = a3;
return result;
}

original_code:
void insertoperator(char name[], int prio, Assoc assoc)
{
  FuncDef *fun = getdef(name);
  if(prio < 1) prio = 1;
  if(prio > 7) prio = 7;
  fun->prio = prio;
  fun->assoc = assoc;
}

canonical_original_code:
void insertoperator(char name[], int prio, enum Assoc assoc)
{
  struct FuncDef *fun = getdef(name);
  if(prio < 1) prio = 1;
  if(prio > 7) prio = 7;
  fun->prio = prio;
  fun->assoc = assoc;
}

variable_types: prio int

variable_types:
assoc
enum Assoc { Left=0, Right=1 }


createhashtable

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

result = &hashtable;
if ( !hashtable )
{
result = malloc(0x3A930uLL);
hashtable = result;
if ( !result )
result = (_QWORD *)systemerror(4LL);
}
return result;
}

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

result = &hashtable;
if ( !hashtable )
{
result = malloc(0x3A930uLL);
hashtable = result;
if ( !result )
result = (_QWORD *)systemerror(4LL);
}
return result;
}

original_code:
void createhashtable(void)
{
  if(hashtable == ((void *)0)) hashtable = malloc(2999 * sizeof(FuncDef));
  if(hashtable == ((void *)0)) systemerror(4);
}

canonical_original_code:
void createhashtable()
{
  if(hashtable == ((void *)0)) hashtable = malloc(2999 * sizeof(FuncDef));
  if(hashtable == ((void *)0)) systemerror(4);
}


inithashtable

original_code:
void inithashtable(void)
{
  static bool initialised = 0;
  int k;
  for(k=0; k<2999; k++)
  {
    FuncDef *fun = &(hashtable[k]);
    if(initialised && fun->name) free(fun->name);
    fun->name = ((void *)0);
    fun->argcount = 0;
    fun->tag = UNDEFINED;
    fun->def = ((void *)0);
    if(!initialised) fun->template = newcell(UNDEFINED);
    fun->typeexpr = ((void *)0);
    fun->abstype = ((void *)0);
    fun->code = ((void *)0);
    fun->prio = 1;
    fun->assoc = Left;
    fun->sysfunc = 0;
    fun->generic = 0;
    fun->template->tag = UNDEFINED;
    fun->template->value = k;
    fun->template->left = ((void *)0);
    fun->template->right = ((void *)0);
  }
  restoretemplates();
  initialised = 1;
}

canonical_original_code:
void inithashtable()
{
  static int initialised = 0;
  int k;
  for(k=0; k<2999; k++)
  {
    struct FuncDef *fun = &(hashtable[k]);
    if(initialised && fun->name) free(fun->name);
    fun->name = ((void *)0);
    fun->argcount = 0;
    fun->tag = UNDEFINED;
    fun->def = ((void *)0);
    if(!initialised) fun->template = newcell(UNDEFINED);
    fun->typeexpr = ((void *)0);
    fun->abstype = ((void *)0);
    fun->code = ((void *)0);
    fun->prio = 1;
    fun->assoc = Left;
    fun->sysfunc = 0;
    fun->generic = 0;
    fun->template->tag = UNDEFINED;
    fun->template->value = k;
    fun->template->left = ((void *)0);
    fun->template->right = ((void *)0);
  }
  restoretemplates();
  initialised = 1;
}

variable_types: initialised int


anonymousfunction

decompiled_code:
__int64 __fastcall anonymousfunction(int a1, __int64 a2)
{
__int64 v2; // r8
__int64 v3; // rax
char v5[280]; // [rsp+0h] [rbp-118h] BYREF

do
{
do
{
v2 = (unsigned int)count_0++;
sprintf(v5, "%s%s%d", parsefunctionname, "_nn_", v2);
v3 = getdef(v5);
}
while ( *(_QWORD *)v3 );
}
while ( *(_QWORD *)(v3 + 8) );
*(_DWORD *)(v3 + 24) = a1;
*(_QWORD *)(v3 + 8) = a2;
*(_BYTE *)(v3 + 72) = 14;
*(_BYTE *)(*(_QWORD *)(v3 + 64) + 20LL) = 14;
return *(_QWORD *)(v3 + 64);
}

original_code:
Cell *anonymousfunction(int argcount, Cell *def)
{
  static int count = 0;
  char funname[256];
  FuncDef *fun;
  do
  {
    sprintf(funname, "%s%s%d", parsefunctionname, "_nn_", count++);
    fun = getdef(funname);
  }
  while(fun->code || fun->def);
  fun->argcount = argcount;
  fun->def = def;
  fun->template->tag = fun->tag = FUNC;
  return fun->template;
}

canonical_original_code:
struct CELL *anonymousfunction(int argcount, struct CELL *def)
{
  static int count = 0;
  char funname[256];
  struct FuncDef *fun;
  do
  {
    sprintf(funname, "%s%s%d", parsefunctionname, "_nn_", count++);
    fun = getdef(funname);
  }
  while(fun->code || fun->def);
  fun->argcount = argcount;
  fun->def = def;
  fun->template->tag = fun->tag = FUNC;
  return fun->template;
}

variable_types:
def
struct CELL *

variable_types:
funname
char [256]


inserttypeexpr

decompiled_code:
__int64 __fastcall inserttypeexpr(char *a1, __int64 a2)
{
__int64 v2; // rax
unsigned int v3; // edx

v2 = getdef(a1);
v3 = 0;
if ( !*(_QWORD *)(v2 + 40) )
{
*(_QWORD *)(v2 + 40) = a2;
v3 = 1;
}
return v3;
}

original_code:
bool inserttypeexpr(char name[], Cell *typeexpr)
{
  FuncDef *fun = getdef(name);
  if(fun->typeexpr) return 0;
  fun->typeexpr = typeexpr;
  return 1;
}

canonical_original_code:
int inserttypeexpr(char name[], struct CELL *typeexpr)
{
  struct FuncDef *fun = getdef(name);
  if(fun->typeexpr) return 0;
  fun->typeexpr = typeexpr;
  return 1;
}


inserttypestring

decompiled_code:
__int64 __fastcall inserttypestring(char *a1, __int64 a2)
{
parsetypeexpr(a2);
return inserttypeexpr(a1, *(_QWORD *)(stack + 8LL * --stackpointer));
}

canonical_decompiled_code:
__int64 __fastcall func19(char *a1, __int64 a2)
{
parsetypeexpr(a2);
return func18(a1, *(_QWORD *)(stack + 8LL * --stackpointer));
}

original_code:
bool inserttypestring(char name[], char typestring[])
{
  parsetypeexpr(typestring);
  return inserttypeexpr(name, stack[--stackpointer]);
}

canonical_original_code:
int inserttypestring(char name[], char typestring[])
{
  parsetypeexpr(typestring);
  return inserttypeexpr(name, stack[--stackpointer]);
}

variable_types:
typestring
char []


insertabstype

decompiled_code:
__int64 __fastcall insertabstype(char *a1, __int64 a2)
{
__int64 v2; // rax
unsigned int v3; // edx

v2 = getdef(a1);
v3 = 0;
if ( !*(_QWORD *)(v2 + 48) )
{
*(_QWORD *)(v2 + 48) = a2;
v3 = 1;
}
return v3;
}

original_code:
bool insertabstype(char name[], Cell *abstype)
{
  FuncDef *fun = getdef(name);
  if(fun->abstype) return 0;
  fun->abstype = abstype;
  return 1;
}

canonical_original_code:
int insertabstype(char name[], struct CELL *abstype)
{
  struct FuncDef *fun = getdef(name);
  if(fun->abstype) return 0;
  fun->abstype = abstype;
  return 1;
}

variable_types: struct FuncDef { void (*code)(); struct CELL { struct CELL *left; int value; unsigned char tag; } *def; char *name; int argcount; int sysfunc; int typechanged; int generic; struct CELL *typeexpr; struct CELL *abstype; int prio; enum Assoc { Left=0, Right=1 } assoc; struct CELL *template; unsigned char tag; } *


storeMessage

decompiled_code:
int *__fastcall storeMessage(const char *a1)
{
int *result; // rax
int v2; // ebx

result = messageStoreIndex;
v2 = messageStoreIndex[0];
if ( messageStoreIndex[0] <= 9999 )
{
if ( a1 )
{
stdoutMessages[v2] = strdup(a1);
result = messageStoreIndex;
messageStoreIndex[0] = v2 + 1;
}
}
return result;
}

canonical_decompiled_code:
int *__fastcall func1(const char *a1)
{
int *result; // rax
int v2; // ebx

result = messageStoreIndex;
v2 = messageStoreIndex[0];
if ( messageStoreIndex[0] <= 9999 )
{
if ( a1 )
{
stdoutMessages[v2] = strdup(a1);
result = messageStoreIndex;
messageStoreIndex[0] = v2 + 1;
}
}
return result;
}

original_code:
void storeMessage(char out[])
{
 if(messageStoreIndex < 10000 & out != ((void *)0))
 {
  stdoutMessages[messageStoreIndex] = strdup(out);
  messageStoreIndex++;
 }
}

variable_types:
out
char []


getMessages

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

result = 0LL;
if ( messageStoreIndex[0] > 0 )
{
result = stdoutMessages;
stdoutMessages[messageStoreIndex[0]] = &LC0;
messageStoreIndex[0] = 0;
}
return result;
}

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

result = 0LL;
if ( messageStoreIndex[0] > 0 )
{
result = stdoutMessages;
stdoutMessages[messageStoreIndex[0]] = &LC0;
messageStoreIndex[0] = 0;
}
return result;
}

original_code:
char** getMessages()
{
 if(messageStoreIndex > 0)
 {
  stdoutMessages[messageStoreIndex] = "\n\n\n";
  messageStoreIndex = 0;
  return stdoutMessages;
 }
 return 0;
}

canonical_original_code:
char **getMessages()
{
 if(messageStoreIndex > 0)
 {
  stdoutMessages[messageStoreIndex] = "\n\n\n";
  messageStoreIndex = 0;
  return stdoutMessages;
 }
 return 0;
}

return_type: char **


SetOutputCallback

decompiled_code:
__int64 __fastcall SetOutputCallback(__int64 a1)
{
writeStringCallback = a1;
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1)
{
writeStringCallback = a1;
return 1LL;
}

original_code:
bool SetOutputCallback(long pointerToWriteStringCallbackMethod)
{
 writeStringCallback = (WriteStringCallback)pointerToWriteStringCallbackMethod;
 return 1;
}

canonical_original_code:
int SetOutputCallback(long pointerToWriteStringCallbackMethod)
{
 writeStringCallback = (void (*)(char output[]))pointerToWriteStringCallbackMethod;
 return 1;
}

variable_types: pointerToWriteStringCallbackMethod long


getstring

decompiled_code:
char *__fastcall getstring(__int64 a1, char *a2)
{
char *result; // rax

WriteString();
result = fgets(a2, 256, stdin);
if ( !result )
exit(0);
return result;
}

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

WriteString();
result = fgets(a2, 256, stdin);
if ( !result )
exit(0);
return result;
}

original_code:
static void getstring(char prompt[], char string[])
{
    WriteString(prompt);
    if(fgets(string, 256, stdin) == ((void *)0)) exit(0);
}

variable_types:
prompt
char []

variable_types:
string
char []


amaproc

original_code:
static void amaproc(char path[])
{
  InitOptions(0, path);
  CreateInterpreter();
  for(;;)
  {
    char expr[256] = "";
    getstring(">> ", expr);
    WriteString("\n<\n");
    Interpret(expr);
    WriteString("\n>\n");
  }
}

variable_types:
path
char []

variable_types:
expr
char [256]


amaobj

decompiled_code:
char __fastcall amaobj(__int64 a1, __int64 a2)
{
int v2; // eax
int v3; // er13
unsigned int v4; // er12
__int64 v5; // rcx
const char *v6; // rsi
const char *v7; // rdi
bool v8; // cf
bool v9; // zf
char *v10; // rbp
char *v11; // rbx
int v12; // eax
int v13; // ebx
const char *v15; // [rsp+0h] [rbp-A38h] BYREF
__int64 v16; // [rsp+8h] [rbp-A30h]
char v17[2032]; // [rsp+10h] [rbp-A28h] BYREF
char v18[256]; // [rsp+800h] [rbp-238h] BYREF
char v19[312]; // [rsp+900h] [rbp-138h] BYREF

InitOptions(0LL, a1);
CreateInterpreter();
v2 = Load(a2);
if ( v2 )
{
v2 = InitRemote();
if ( v2 )
{
getstring((__int64)&LC1, v19);
v3 = 0;
v4 = -1;
while ( 1 )
{
WriteString();
v12 = FindWords(v19, (__int64)&v15, 256);
v13 = v12;
v8 = (unsigned int)v12 < 2;
v9 = v12 == 2;
if ( v12 == 2 )
{
v5 = 7LL;
v6 = v15;
v7 = "object";
do
{
if ( !v5 )
break;
v8 = *v6 < (unsigned int)*v7;
v9 = *v6++ == *v7++;
--v5;
}
while ( v9 );
if ( (!v8 && !v9) == v8 )
{
DropRemote(v4, v6);
v4 = CreateRemote(v16);
goto LABEL_19;
}
}
else if ( v12 <= 1 )
{
if ( v12 == 1 )
{
if ( !strcmp(v15, "echo") )
{
v3 ^= 1u;
goto LABEL_19;
}
if ( !strcmp(v15, "time") )
{
timing = timing == 0;
goto LABEL_19;
}
v9 = strcmp(v15, "exit") == 0;
LOBYTE(v2) = !v9;
if ( v9 )
return v2;
}
LABEL_18:
WriteString();
goto LABEL_19;
}
if ( strcmp(v15, "call") || (v4 & 0x80000000) != 0 )
goto LABEL_18;
starttiming();
if ( v13 > 2 )
{
v10 = v17;
v11 = &v17[8 * (v13 - 3) + 8];
do
{
PutRemote(v4, *(_QWORD *)v10);
v10 += 8;
}
while ( v10 != v11 );
}
CallRemote(v4, v16);
WriteString();
while ( (unsigned int)GetRemote(v4, v18, 256LL) )
{
WriteString();
WriteString();
}
WriteString();
stoptiming(">\n");
LABEL_19:
WriteString();
getstring((__int64)&LC1, v19);
if ( v3 )
WriteString();
}
}
}
return v2;
}

canonical_decompiled_code:
char __fastcall func6(__int64 a1, __int64 a2)
{
int v2; // eax
int v3; // er13
unsigned int v4; // er12
__int64 v5; // rcx
const char *v6; // rsi
const char *v7; // rdi
bool v8; // cf
bool v9; // zf
char *v10; // rbp
char *v11; // rbx
int v12; // eax
int v13; // ebx
const char *v15; // [rsp+0h] [rbp-A38h] BYREF
__int64 v16; // [rsp+8h] [rbp-A30h]
char v17[2032]; // [rsp+10h] [rbp-A28h] BYREF
char v18[256]; // [rsp+800h] [rbp-238h] BYREF
char v19[312]; // [rsp+900h] [rbp-138h] BYREF

InitOptions(0LL, a1);
CreateInterpreter();
v2 = Load(a2);
if ( v2 )
{
v2 = InitRemote();
if ( v2 )
{
func4((__int64)&LC1, v19);
v3 = 0;
v4 = -1;
while ( 1 )
{
WriteString();
v12 = func0(v19, (__int64)&v15, 256);
v13 = v12;
v8 = (unsigned int)v12 < 2;
v9 = v12 == 2;
if ( v12 == 2 )
{
v5 = 7LL;
v6 = v15;
v7 = "object";
do
{
if ( !v5 )
break;
v8 = *v6 < (unsigned int)*v7;
v9 = *v6++ == *v7++;
--v5;
}
while ( v9 );
if ( (!v8 && !v9) == v8 )
{
DropRemote(v4, v6);
v4 = CreateRemote(v16);
goto LABEL_19;
}
}
else if ( v12 <= 1 )
{
if ( v12 == 1 )
{
if ( !strcmp(v15, "echo") )
{
v3 ^= 1u;
goto LABEL_19;
}
if ( !strcmp(v15, "time") )
{
timing = timing == 0;
goto LABEL_19;
}
v9 = strcmp(v15, "exit") == 0;
LOBYTE(v2) = !v9;
if ( v9 )
return v2;
}
LABEL_18:
WriteString();
goto LABEL_19;
}
if ( strcmp(v15, "call") || (v4 & 0x80000000) != 0 )
goto LABEL_18;
starttiming();
if ( v13 > 2 )
{
v10 = v17;
v11 = &v17[8 * (v13 - 3) + 8];
do
{
PutRemote(v4, *(_QWORD *)v10);
v10 += 8;
}
while ( v10 != v11 );
}
CallRemote(v4, v16);
WriteString();
while ( (unsigned int)GetRemote(v4, v18, 256LL) )
{
WriteString();
WriteString();
}
WriteString();
stoptiming(">\n");
LABEL_19:
WriteString();
func4((__int64)&LC1, v19);
if ( v3 )
WriteString();
}
}
}
return v2;
}

original_code:
static void amaobj(char path[], char filename[])
{
  char command[256], s[256], *words[256];
  int k, handle = -1, count;
  bool echo = 0;
  InitOptions(0, path);
  CreateInterpreter();
  if(!Load(filename) || !InitRemote()) return;
  for(;;)
  {
    getstring(">> ", command);
    if(echo) WriteString(command);
    WriteString("\n");
    count = FindWords(command, words, 256);
    if(count == 2 && strcmp(words[0], "object") == 0)
    {
      DropRemote(handle);
      handle = CreateRemote(words[1]);
    }
    else if(count >= 2 && strcmp(words[0], "call") == 0)
    {
      if(handle < 0)
        WriteString("No object selected");
      else
      {
        starttiming();
        for(k=2; k < count; k++) PutRemote(handle, words[k]);
        CallRemote(handle, words[1]);
        WriteString("<\n");
        while(GetRemote(handle, s, 256))
        {
          WriteString(s);
          WriteString("\n");
        }
        WriteString(">\n");
        stoptiming();
      }
    }
    else if(count == 1 && strcmp(words[0], "echo") == 0)
      echo = !echo;
    else if(count == 1 && strcmp(words[0], "time") == 0)
      timing = !timing;
    else if(count == 1 && strcmp(words[0], "exit") == 0)
      break;
    else
      WriteString("???\n");
    WriteString("\n");
  }
}

canonical_original_code:
static void amaobj(char path[], char filename[])
{
  char command[256]; char s[256]; char *words[256];
  int k; int handle = -1; int count;
  int echo = 0;
  InitOptions(0, path);
  CreateInterpreter();
  if(!Load(filename) || !InitRemote()) return;
  for(;;)
  {
    getstring(">> ", command);
    if(echo) WriteString(command);
    WriteString("\n");
    count = FindWords(command, words, 256);
    if(count == 2 && strcmp(words[0], "object") == 0)
    {
      DropRemote(handle);
      handle = CreateRemote(words[1]);
    }
    else if(count >= 2 && strcmp(words[0], "call") == 0)
    {
      if(handle < 0)
        WriteString("No object selected");
      else
      {
        starttiming();
        for(k=2; k < count; k++) PutRemote(handle, words[k]);
        CallRemote(handle, words[1]);
        WriteString("<\n");
        while(GetRemote(handle, s, 256))
        {
          WriteString(s);
          WriteString("\n");
        }
        WriteString(">\n");
        stoptiming();
      }
    }
    else if(count == 1 && strcmp(words[0], "echo") == 0)
      echo = !echo;
    else if(count == 1 && strcmp(words[0], "time") == 0)
      timing = !timing;
    else if(count == 1 && strcmp(words[0], "exit") == 0)
      break;
    else
      WriteString("???\n");
    WriteString("\n");
  }
}

variable_types:
filename
char []

variable_types:
command
char [256]

variable_types:
s
char [256]

variable_types:
words
char *[256]

variable_types: k int

variable_types: handle int

variable_types: count int

variable_types: echo int


CheckIO

decompiled_code:
void CheckIO()
{
;
}

canonical_decompiled_code:
void func7()
{
;
}

original_code:
void CheckIO(void)
{
}

canonical_original_code:
void CheckIO()
{
}


GraphDisplay

decompiled_code:
void GraphDisplay()
{
;
}

canonical_decompiled_code:
void func8()
{
;
}

original_code:
void GraphDisplay(char string[])
{
}

canonical_original_code:
void GraphDisplay(char string[])
{
}