zalloc

decompiled_code:
// attributes: thunk
void *zalloc(size_t size)
{
return malloc(size);
}

canonical_decompiled_code:
void *func20(size_t size)
{
return malloc(size);
}

original_code:
void *zalloc(size_t size)
{
    void *p = malloc(size);
    ((void) (0));
    return p;
}

canonical_original_code:
void *zalloc(unsigned long size)
{
    void *p = malloc(size);
    ((void) (0));
    return p;
}

variable_types:
size
unsigned long


zfree

repo: lotabout/c-interfaces

decompiled_code:
// attributes: thunk
void zfree(void *ptr)
{
free(ptr);
}

canonical_decompiled_code:
void func21(void *ptr)
{
free(ptr);
}

original_code:
void zfree(void *ptr)
{
    ((void) (0));
    free(ptr);
}

variable_types:
ptr
void *

return_type: void


zcalloc

decompiled_code:
// attributes: thunk
void *zcalloc(size_t nmemb, size_t size)
{
return calloc(nmemb, size);
}

canonical_decompiled_code:
void *func22(size_t nmemb, size_t size)
{
return calloc(nmemb, size);
}

original_code:
void *zcalloc(size_t nmemb, size_t size)
{
    void *p = calloc(nmemb, size);
    ((void) (0));
    return p;
}

canonical_original_code:
void *zcalloc(unsigned long nmemb, unsigned long size)
{
    void *p = calloc(nmemb, size);
    ((void) (0));
    return p;
}

variable_types:
nmemb
unsigned long

variable_types:
p
void *

return_type: void *


main

canonical_name: main

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

fprintf(_bss_start, "[DEBUG] %s:%d: \n===== RUNNING: %s\n", "tests/array_tests.c", 111LL, *argv);
printf("====\nRUNNING: %s\n", *argv);
v3 = (const char *)all_tests();
v4 = v3;
if ( v3 )
printf("FAILED: %s\n", v3);
else
puts("ALL TESTS PASSED");
printf("Tests run: %d\n", (unsigned int)tests_run);
exit(v4 != 0LL);
}

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

fprintf(_bss_start, "[DEBUG] %s:%d: \n===== RUNNING: %s\n", "tests/array_tests.c", 111LL, *argv);
printf("====\nRUNNING: %s\n", *argv);
v3 = (const char *)func12();
v4 = v3;
if ( v3 )
printf("FAILED: %s\n", v3);
else
puts("ALL TESTS PASSED");
printf("Tests run: %d\n", (unsigned int)tests_run);
exit(v4 != 0LL);
}

original_code: int main(int argc, const char *argv[]) { (void)argc; fprintf(stderr, "[DEBUG] %s:%d: ""\n===== RUNNING: %s\n", "tests/array_tests.c", 111, argv[0]);; printf("====\nRUNNING: %s\n", argv[0]); char *result = all_tests(); if (result != 0) { printf("FAILED: %s\n", result); } else { printf("ALL TESTS PASSED\n"); } printf("Tests run: %d\n", tests_run); exit(result != 0); }

canonical_original_code: int main(int argc, char *argv[]) { (void)argc; fprintf(stderr, "[DEBUG] %s:%d: ""\n===== RUNNING: %s\n", "tests/array_tests.c", 111, argv[0]);; printf("====\nRUNNING: %s\n", argv[0]); char *result = all_tests(); if (result != 0) { printf("FAILED: %s\n", result); } else { printf("ALL TESTS PASSED\n"); } printf("Tests run: %d\n", tests_run); exit(result != 0); }

variable_types: argc int

variable_types:
argv
char *[]

variable_types:
result
char *

return_type: int


decompiled_code:
const char *test_new()
{
__int64 v0; // rax
__int64 v1; // rdx
__int64 v2; // rcx
int v3; // er8
const char *result; // rax

v0 = array_new(10LL, 4LL);
v2 = 11LL;
ary_a = v0;
if ( !v0 )
goto LABEL_6;
if ( (unsigned int)array_length(v0, 4LL, v1, 11LL) != 10 )
{
v2 = 12LL;
LABEL_6:
fprintf(_bss_start, "[ERROR] (%s:%d:) array_new error.\n", "tests/array_tests.c", v2);
return "array_new error.\n";
}
v3 = array_size(ary_a);
result = 0LL;
if ( v3 != 4 )
{
fprintf(_bss_start, "[ERROR] (%s:%d:) array_new error.\n", "tests/array_tests.c", 13LL);
result = "array_new error.\n";
}
return result;
}

canonical_decompiled_code:
const char *func7()
{
__int64 v0; // rax
__int64 v1; // rdx
__int64 v2; // rcx
int v3; // er8
const char *result; // rax

v0 = array_new(10LL, 4LL);
v2 = 11LL;
ary_a = v0;
if ( !v0 )
goto LABEL_6;
if ( (unsigned int)func17(v0, 4LL, v1, 11LL) != 10 )
{
v2 = 12LL;
LABEL_6:
fprintf(_bss_start, "[ERROR] (%s:%d:) array_new error.\n", "tests/array_tests.c", v2);
return "array_new error.\n";
}
v3 = func18(ary_a);
result = 0LL;
if ( v3 != 4 )
{
fprintf(_bss_start, "[ERROR] (%s:%d:) array_new error.\n", "tests/array_tests.c", 13LL);
result = "array_new error.\n";
}
return result;
}

original_code:
char *test_new()
{
    ary_a = array_new(10, sizeof(int));
    if (!(ary_a != ((void *)0))) { fprintf(stderr, "[ERROR] (%s:%d:) " "array_new error.\n", "tests/array_tests.c", 11);; return "array_new error.\n"; };
    if (!(array_length(ary_a) == 10)) { fprintf(stderr, "[ERROR] (%s:%d:) " "array_new error.\n", "tests/array_tests.c", 12);; return "array_new error.\n"; };
    if (!(array_size(ary_a) == sizeof(int))) { fprintf(stderr, "[ERROR] (%s:%d:) " "array_new error.\n", "tests/array_tests.c", 13);; return "array_new error.\n"; };
    return ((void *)0);
}

return_type: char *


decompiled_code:
const char *test_put_get()
{
void *v0; // rax
__int64 v1; // rcx
const char *result; // rax
void *v3; // rax
void *v4; // rax
void *v5; // rax
void *v6; // rax
void *v7; // rax
__int64 v8; // rdx
_DWORD *v9; // rax
__int64 v10; // rdx
__int64 v11; // rcx
_DWORD *v12; // rax
__int64 v13; // rdx
_DWORD *v14; // rax
__int64 v15; // rdx
_DWORD *v16; // rax
__int64 v17; // rdx
_DWORD *v18; // rax
__int64 v19; // rdx
__int64 v20; // rdx
__int64 v21; // rcx
_DWORD *v22; // r8

v0 = (void *)array_put(ary_a, 0LL, &int_vals);
v1 = 21LL;
if ( v0 != &int_vals )
goto LABEL_2;
if ( (_UNKNOWN *)array_put(ary_a, 1LL, &unk_404084) != &unk_404084 )
{
v1 = 23LL;
LABEL_2:
fprintf(_bss_start, "[ERROR] (%s:%d:) array_put error.\n", "tests/array_tests.c", v1);
return "array_put error.\n";
}
v3 = (void *)array_put(ary_a, 2LL, &unk_404088);
v1 = 25LL;
if ( v3 != &unk_404088 )
goto LABEL_2;
v4 = (void *)array_put(ary_a, 3LL, &unk_40408C);
v1 = 27LL;
if ( v4 != &unk_40408C )
goto LABEL_2;
v5 = (void *)array_put(ary_a, 4LL, &unk_404090);
v1 = 29LL;
if ( v5 != &unk_404090 )
goto LABEL_2;
v6 = (void *)array_put(ary_a, 5LL, &unk_404094);
v1 = 31LL;
if ( v6 != &unk_404094 )
goto LABEL_2;
v7 = (void *)array_put(ary_a, 6LL, &unk_404098);
v1 = 33LL;
if ( v7 != &unk_404098 )
goto LABEL_2;
v9 = (_DWORD *)array_get(ary_a, 0LL, v8, 33LL);
v11 = 36LL;
if ( *v9 )
goto LABEL_18;
v12 = (_DWORD *)array_get(ary_a, 1LL, v10, 36LL);
v11 = 38LL;
if ( *v12 != 1
|| (v14 = (_DWORD *)array_get(ary_a, 2LL, v13, 38LL), v11 = 40LL, *v14 != 2)
|| (v16 = (_DWORD *)array_get(ary_a, 3LL, v15, 40LL), v11 = 42LL, *v16 != 3)
|| (v18 = (_DWORD *)array_get(ary_a, 4LL, v17, 42LL), v11 = 44LL, *v18 != 4) )
{
LABEL_18:
fprintf(_bss_start, "[ERROR] (%s:%d:) array_get error.\n", "tests/array_tests.c", v11);
return "array_get error.\n";
}
if ( *(_DWORD *)array_get(ary_a, 5LL, v19, 44LL) != 5 )
{
v11 = 46LL;
goto LABEL_18;
}
v22 = (_DWORD *)array_get(ary_a, 6LL, v20, v21);
result = 0LL;
if ( *v22 != 6 )
{
fprintf(_bss_start, "[ERROR] (%s:%d:) array_get error.\n", "tests/array_tests.c", 48LL);
result = "array_get error.\n";
}
return result;
}

canonical_decompiled_code:
const char *func8()
{
void *v0; // rax
__int64 v1; // rcx
const char *result; // rax
void *v3; // rax
void *v4; // rax
void *v5; // rax
void *v6; // rax
void *v7; // rax
__int64 v8; // rdx
_DWORD *v9; // rax
__int64 v10; // rdx
__int64 v11; // rcx
_DWORD *v12; // rax
__int64 v13; // rdx
_DWORD *v14; // rax
__int64 v15; // rdx
_DWORD *v16; // rax
__int64 v17; // rdx
_DWORD *v18; // rax
__int64 v19; // rdx
__int64 v20; // rdx
__int64 v21; // rcx
_DWORD *v22; // r8

v0 = (void *)func16(ary_a, 0LL, &int_vals);
v1 = 21LL;
if ( v0 != &int_vals )
goto LABEL_2;
if ( (_UNKNOWN *)func16(ary_a, 1LL, &unk_404084) != &unk_404084 )
{
v1 = 23LL;
LABEL_2:
fprintf(_bss_start, "[ERROR] (%s:%d:) array_put error.\n", "tests/array_tests.c", v1);
return "array_put error.\n";
}
v3 = (void *)func16(ary_a, 2LL, &unk_404088);
v1 = 25LL;
if ( v3 != &unk_404088 )
goto LABEL_2;
v4 = (void *)func16(ary_a, 3LL, &unk_40408C);
v1 = 27LL;
if ( v4 != &unk_40408C )
goto LABEL_2;
v5 = (void *)func16(ary_a, 4LL, &unk_404090);
v1 = 29LL;
if ( v5 != &unk_404090 )
goto LABEL_2;
v6 = (void *)func16(ary_a, 5LL, &unk_404094);
v1 = 31LL;
if ( v6 != &unk_404094 )
goto LABEL_2;
v7 = (void *)func16(ary_a, 6LL, &unk_404098);
v1 = 33LL;
if ( v7 != &unk_404098 )
goto LABEL_2;
v9 = (_DWORD *)func15(ary_a, 0LL, v8, 33LL);
v11 = 36LL;
if ( *v9 )
goto LABEL_18;
v12 = (_DWORD *)func15(ary_a, 1LL, v10, 36LL);
v11 = 38LL;
if ( *v12 != 1
|| (v14 = (_DWORD *)func15(ary_a, 2LL, v13, 38LL), v11 = 40LL, *v14 != 2)
|| (v16 = (_DWORD *)func15(ary_a, 3LL, v15, 40LL), v11 = 42LL, *v16 != 3)
|| (v18 = (_DWORD *)func15(ary_a, 4LL, v17, 42LL), v11 = 44LL, *v18 != 4) )
{
LABEL_18:
fprintf(_bss_start, "[ERROR] (%s:%d:) array_get error.\n", "tests/array_tests.c", v11);
return "array_get error.\n";
}
if ( *(_DWORD *)func15(ary_a, 5LL, v19, 44LL) != 5 )
{
v11 = 46LL;
goto LABEL_18;
}
v22 = (_DWORD *)func15(ary_a, 6LL, v20, v21);
result = 0LL;
if ( *v22 != 6 )
{
fprintf(_bss_start, "[ERROR] (%s:%d:) array_get error.\n", "tests/array_tests.c", 48LL);
result = "array_get error.\n";
}
return result;
}

original_code:
char *test_put_get()
{
    int * x;
    x = (int *)array_put(ary_a, 0, &int_vals[0]);
    if (!(x == &int_vals[0])) { fprintf(stderr, "[ERROR] (%s:%d:) " "array_put error.\n", "tests/array_tests.c", 21);; return "array_put error.\n"; };
    x = (int *)array_put(ary_a, 1, &int_vals[1]);
    if (!(x == &int_vals[1])) { fprintf(stderr, "[ERROR] (%s:%d:) " "array_put error.\n", "tests/array_tests.c", 23);; return "array_put error.\n"; };
    x = (int *)array_put(ary_a, 2, &int_vals[2]);
    if (!(x == &int_vals[2])) { fprintf(stderr, "[ERROR] (%s:%d:) " "array_put error.\n", "tests/array_tests.c", 25);; return "array_put error.\n"; };
    x = (int *)array_put(ary_a, 3, &int_vals[3]);
    if (!(x == &int_vals[3])) { fprintf(stderr, "[ERROR] (%s:%d:) " "array_put error.\n", "tests/array_tests.c", 27);; return "array_put error.\n"; };
    x = (int *)array_put(ary_a, 4, &int_vals[4]);
    if (!(x == &int_vals[4])) { fprintf(stderr, "[ERROR] (%s:%d:) " "array_put error.\n", "tests/array_tests.c", 29);; return "array_put error.\n"; };
    x = (int *)array_put(ary_a, 5, &int_vals[5]);
    if (!(x == &int_vals[5])) { fprintf(stderr, "[ERROR] (%s:%d:) " "array_put error.\n", "tests/array_tests.c", 31);; return "array_put error.\n"; };
    x = (int *)array_put(ary_a, 6, &int_vals[6]);
    if (!(x == &int_vals[6])) { fprintf(stderr, "[ERROR] (%s:%d:) " "array_put error.\n", "tests/array_tests.c", 33);; return "array_put error.\n"; };
    x = (int *)array_get(ary_a, 0);
    if (!(*x == 0)) { fprintf(stderr, "[ERROR] (%s:%d:) " "array_get error.\n", "tests/array_tests.c", 36);; return "array_get error.\n"; }
    x = (int *)array_get(ary_a, 1);
    if (!(*x == 1)) { fprintf(stderr, "[ERROR] (%s:%d:) " "array_get error.\n", "tests/array_tests.c", 38);; return "array_get error.\n"; }
    x = (int *)array_get(ary_a, 2);
    if (!(*x == 2)) { fprintf(stderr, "[ERROR] (%s:%d:) " "array_get error.\n", "tests/array_tests.c", 40);; return "array_get error.\n"; }
    x = (int *)array_get(ary_a, 3);
    if (!(*x == 3)) { fprintf(stderr, "[ERROR] (%s:%d:) " "array_get error.\n", "tests/array_tests.c", 42);; return "array_get error.\n"; }
    x = (int *)array_get(ary_a, 4);
    if (!(*x == 4)) { fprintf(stderr, "[ERROR] (%s:%d:) " "array_get error.\n", "tests/array_tests.c", 44);; return "array_get error.\n"; }
    x = (int *)array_get(ary_a, 5);
    if (!(*x == 5)) { fprintf(stderr, "[ERROR] (%s:%d:) " "array_get error.\n", "tests/array_tests.c", 46);; return "array_get error.\n"; }
    x = (int *)array_get(ary_a, 6);
    if (!(*x == 6)) { fprintf(stderr, "[ERROR] (%s:%d:) " "array_get error.\n", "tests/array_tests.c", 48);; return "array_get error.\n"; }
    return ((void *)0);
}

canonical_original_code:
char *test_put_get()
{
    int *x;
    x = (int *)array_put(ary_a, 0, &int_vals[0]);
    if (!(x == &int_vals[0])) { fprintf(stderr, "[ERROR] (%s:%d:) " "array_put error.\n", "tests/array_tests.c", 21);; return "array_put error.\n"; };
    x = (int *)array_put(ary_a, 1, &int_vals[1]);
    if (!(x == &int_vals[1])) { fprintf(stderr, "[ERROR] (%s:%d:) " "array_put error.\n", "tests/array_tests.c", 23);; return "array_put error.\n"; };
    x = (int *)array_put(ary_a, 2, &int_vals[2]);
    if (!(x == &int_vals[2])) { fprintf(stderr, "[ERROR] (%s:%d:) " "array_put error.\n", "tests/array_tests.c", 25);; return "array_put error.\n"; };
    x = (int *)array_put(ary_a, 3, &int_vals[3]);
    if (!(x == &int_vals[3])) { fprintf(stderr, "[ERROR] (%s:%d:) " "array_put error.\n", "tests/array_tests.c", 27);; return "array_put error.\n"; };
    x = (int *)array_put(ary_a, 4, &int_vals[4]);
    if (!(x == &int_vals[4])) { fprintf(stderr, "[ERROR] (%s:%d:) " "array_put error.\n", "tests/array_tests.c", 29);; return "array_put error.\n"; };
    x = (int *)array_put(ary_a, 5, &int_vals[5]);
    if (!(x == &int_vals[5])) { fprintf(stderr, "[ERROR] (%s:%d:) " "array_put error.\n", "tests/array_tests.c", 31);; return "array_put error.\n"; };
    x = (int *)array_put(ary_a, 6, &int_vals[6]);
    if (!(x == &int_vals[6])) { fprintf(stderr, "[ERROR] (%s:%d:) " "array_put error.\n", "tests/array_tests.c", 33);; return "array_put error.\n"; };
    x = (int *)array_get(ary_a, 0);
    if (!(*x == 0)) { fprintf(stderr, "[ERROR] (%s:%d:) " "array_get error.\n", "tests/array_tests.c", 36);; return "array_get error.\n"; }
    x = (int *)array_get(ary_a, 1);
    if (!(*x == 1)) { fprintf(stderr, "[ERROR] (%s:%d:) " "array_get error.\n", "tests/array_tests.c", 38);; return "array_get error.\n"; }
    x = (int *)array_get(ary_a, 2);
    if (!(*x == 2)) { fprintf(stderr, "[ERROR] (%s:%d:) " "array_get error.\n", "tests/array_tests.c", 40);; return "array_get error.\n"; }
    x = (int *)array_get(ary_a, 3);
    if (!(*x == 3)) { fprintf(stderr, "[ERROR] (%s:%d:) " "array_get error.\n", "tests/array_tests.c", 42);; return "array_get error.\n"; }
    x = (int *)array_get(ary_a, 4);
    if (!(*x == 4)) { fprintf(stderr, "[ERROR] (%s:%d:) " "array_get error.\n", "tests/array_tests.c", 44);; return "array_get error.\n"; }
    x = (int *)array_get(ary_a, 5);
    if (!(*x == 5)) { fprintf(stderr, "[ERROR] (%s:%d:) " "array_get error.\n", "tests/array_tests.c", 46);; return "array_get error.\n"; }
    x = (int *)array_get(ary_a, 6);
    if (!(*x == 6)) { fprintf(stderr, "[ERROR] (%s:%d:) " "array_get error.\n", "tests/array_tests.c", 48);; return "array_get error.\n"; }
    return ((void *)0);
}

variable_types:
x
int *


decompiled_code:
const char *test_copy()
{
int v0; // eax
__int64 v1; // rdx
__int64 v2; // rcx
__int64 v3; // rdx
__int64 v4; // rcx
const char *result; // rax
_DWORD *v6; // rax
__int64 v7; // rdx
__int64 v8; // rcx
__int64 v9; // rdx
__int64 v10; // rcx
_DWORD *v11; // r8

ary_b = array_copy(ary_a, 3LL);
v0 = array_size(ary_b);
v2 = 76LL;
if ( v0 != 4 )
goto LABEL_4;
if ( (unsigned int)array_length(ary_b, 3LL, v1, 76LL) != 3 )
{
v2 = 77LL;
LABEL_4:
fprintf(_bss_start, "[ERROR] (%s:%d:) array_copy error.\n", "tests/array_tests.c", v2);
return "array_copy error.\n";
}
v6 = (_DWORD *)array_get(ary_a, 0LL, v3, v4);
v8 = 81LL;
if ( *v6 )
{
LABEL_9:
fprintf(_bss_start, "[ERROR] (%s:%d:) array_copy error", "tests/array_tests.c", v8);
return "array_copy error";
}
if ( *(_DWORD *)array_get(ary_a, 1LL, v7, 81LL) != 1 )
{
v8 = 83LL;
goto LABEL_9;
}
v11 = (_DWORD *)array_get(ary_a, 2LL, v9, v10);
result = 0LL;
if ( *v11 != 2 )
{
fprintf(_bss_start, "[ERROR] (%s:%d:) array_copy error", "tests/array_tests.c", 85LL);
result = "array_copy error";
}
return result;
}

canonical_decompiled_code:
const char *func10()
{
int v0; // eax
__int64 v1; // rdx
__int64 v2; // rcx
__int64 v3; // rdx
__int64 v4; // rcx
const char *result; // rax
_DWORD *v6; // rax
__int64 v7; // rdx
__int64 v8; // rcx
__int64 v9; // rdx
__int64 v10; // rcx
_DWORD *v11; // r8

ary_b = array_copy(ary_a, 3LL);
v0 = func18(ary_b);
v2 = 76LL;
if ( v0 != 4 )
goto LABEL_4;
if ( (unsigned int)func17(ary_b, 3LL, v1, 76LL) != 3 )
{
v2 = 77LL;
LABEL_4:
fprintf(_bss_start, "[ERROR] (%s:%d:) array_copy error.\n", "tests/array_tests.c", v2);
return "array_copy error.\n";
}
v6 = (_DWORD *)func15(ary_a, 0LL, v3, v4);
v8 = 81LL;
if ( *v6 )
{
LABEL_9:
fprintf(_bss_start, "[ERROR] (%s:%d:) array_copy error", "tests/array_tests.c", v8);
return "array_copy error";
}
if ( *(_DWORD *)func15(ary_a, 1LL, v7, 81LL) != 1 )
{
v8 = 83LL;
goto LABEL_9;
}
v11 = (_DWORD *)func15(ary_a, 2LL, v9, v10);
result = 0LL;
if ( *v11 != 2 )
{
fprintf(_bss_start, "[ERROR] (%s:%d:) array_copy error", "tests/array_tests.c", 85LL);
result = "array_copy error";
}
return result;
}

original_code:
char *test_copy()
{
    ary_b = array_copy(ary_a, 3);
    if (!(array_size(ary_b)==sizeof(int))) { fprintf(stderr, "[ERROR] (%s:%d:) " "array_copy error.\n", "tests/array_tests.c", 76);; return "array_copy error.\n"; };
    if (!(array_length(ary_b)==3)) { fprintf(stderr, "[ERROR] (%s:%d:) " "array_copy error.\n", "tests/array_tests.c", 77);; return "array_copy error.\n"; };
    int *x;
    x = (int *)array_get(ary_a, 0);
    if (!(*x == 0)) { fprintf(stderr, "[ERROR] (%s:%d:) " "array_copy error", "tests/array_tests.c", 81);; return "array_copy error"; }
    x = (int *)array_get(ary_a, 1);
    if (!(*x == 1)) { fprintf(stderr, "[ERROR] (%s:%d:) " "array_copy error", "tests/array_tests.c", 83);; return "array_copy error"; }
    x = (int *)array_get(ary_a, 2);
    if (!(*x == 2)) { fprintf(stderr, "[ERROR] (%s:%d:) " "array_copy error", "tests/array_tests.c", 85);; return "array_copy error"; }
    return ((void *)0);
}


decompiled_code:
const char *test_free()
{
__int64 v0; // rcx
const char *result; // rax

array_free(&ary_a);
v0 = 92LL;
if ( ary_a )
goto LABEL_2;
array_free(&ary_b);
result = (const char *)ary_b;
if ( ary_b )
{
v0 = 94LL;
LABEL_2:
fprintf(_bss_start, "[ERROR] (%s:%d:) array_free error.\n", "tests/array_tests.c", v0);
result = "array_free error.\n";
}
return result;
}

canonical_decompiled_code:
const char *func11()
{
__int64 v0; // rcx
const char *result; // rax

func14(&ary_a);
v0 = 92LL;
if ( ary_a )
goto LABEL_2;
func14(&ary_b);
result = (const char *)ary_b;
if ( ary_b )
{
v0 = 94LL;
LABEL_2:
fprintf(_bss_start, "[ERROR] (%s:%d:) array_free error.\n", "tests/array_tests.c", v0);
result = "array_free error.\n";
}
return result;
}

original_code:
char *test_free()
{
    array_free(&ary_a);
    if (!(ary_a == ((void *)0))) { fprintf(stderr, "[ERROR] (%s:%d:) " "array_free error.\n", "tests/array_tests.c", 92);; return "array_free error.\n"; };
    array_free(&ary_b);
    if (!(ary_b == ((void *)0))) { fprintf(stderr, "[ERROR] (%s:%d:) " "array_free error.\n", "tests/array_tests.c", 94);; return "array_free error.\n"; };
    return ((void *)0);
}


decompiled_code:
const char *all_tests()
{
const char *result; // rax

fprintf(_bss_start, "[DEBUG] %s:%d: \n------->%s\n", "tests/array_tests.c", 102LL, " test_new");
result = test_new();
++tests_run;
if ( !result )
{
fprintf(_bss_start, "[DEBUG] %s:%d: \n------->%s\n", "tests/array_tests.c", 103LL, " test_put_get");
result = test_put_get();
++tests_run;
if ( !result )
{
fprintf(_bss_start, "[DEBUG] %s:%d: \n------->%s\n", "tests/array_tests.c", 104LL, " test_resize");
result = test_resize();
++tests_run;
if ( !result )
{
fprintf(_bss_start, "[DEBUG] %s:%d: \n------->%s\n", "tests/array_tests.c", 105LL, " test_copy");
result = test_copy();
++tests_run;
if ( !result )
{
fprintf(_bss_start, "[DEBUG] %s:%d: \n------->%s\n", "tests/array_tests.c", 106LL, " test_free");
result = test_free();
++tests_run;
}
}
}
}
return result;
}

canonical_decompiled_code:
const char *func12()
{
const char *result; // rax

fprintf(_bss_start, "[DEBUG] %s:%d: \n------->%s\n", "tests/array_tests.c", 102LL, " test_new");
result = func7();
++tests_run;
if ( !result )
{
fprintf(_bss_start, "[DEBUG] %s:%d: \n------->%s\n", "tests/array_tests.c", 103LL, " test_put_get");
result = func8();
++tests_run;
if ( !result )
{
fprintf(_bss_start, "[DEBUG] %s:%d: \n------->%s\n", "tests/array_tests.c", 104LL, " test_resize");
result = func9();
++tests_run;
if ( !result )
{
fprintf(_bss_start, "[DEBUG] %s:%d: \n------->%s\n", "tests/array_tests.c", 105LL, " test_copy");
result = func10();
++tests_run;
if ( !result )
{
fprintf(_bss_start, "[DEBUG] %s:%d: \n------->%s\n", "tests/array_tests.c", 106LL, " test_free");
result = func11();
++tests_run;
}
}
}
}
return result;
}

original_code:
char *all_tests()
{
    char *message = ((void *)0);
    fprintf(stderr, "[DEBUG] %s:%d: ""\n------->%s\n", "tests/array_tests.c", 102, " " "test_new");; message = (test_new)(); tests_run++; if (message) return message;;
    fprintf(stderr, "[DEBUG] %s:%d: ""\n------->%s\n", "tests/array_tests.c", 103, " " "test_put_get");; message = (test_put_get)(); tests_run++; if (message) return message;;
    fprintf(stderr, "[DEBUG] %s:%d: ""\n------->%s\n", "tests/array_tests.c", 104, " " "test_resize");; message = (test_resize)(); tests_run++; if (message) return message;;
    fprintf(stderr, "[DEBUG] %s:%d: ""\n------->%s\n", "tests/array_tests.c", 105, " " "test_copy");; message = (test_copy)(); tests_run++; if (message) return message;;
    fprintf(stderr, "[DEBUG] %s:%d: ""\n------->%s\n", "tests/array_tests.c", 106, " " "test_free");; message = (test_free)(); tests_run++; if (message) return message;;
    return ((void *)0);
}

variable_types:
message
char *


min

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

result = a1;
if ( (int)a2 <= (int)a1 )
result = a2;
return result;
}

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

result = a1;
if ( (int)a2 <= (int)a1 )
result = a2;
return result;
}

original_code:
static inline int min(int a, int b)
{
    return (a < b) ? a : b;
}

variable_types: a int

variable_types: b int


decompiled_code:
const char *test_string()
{
const char *v0; // r8
__int64 v2; // rax

atom_a = atom_string(a);
atom_b = atom_string(b);
if ( atom_b == atom_a )
{
v2 = atom_string(c);
v0 = 0LL;
atom_c = v2;
if ( v2 == atom_a )
{
fprintf(
stderr,
"[ERROR] (%s:%d:) atom_string returns the same atom with different contents.\n",
"tests/atom_tests.c",
33LL);
v0 = "atom_string returns the same atom with different contents.\n";
}
}
else
{
fprintf(stderr, "[ERROR] (%s:%d:) atom_string did not return the same atom.\n", "tests/atom_tests.c", 31LL);
v0 = "atom_string did not return the same atom.\n";
}
return v0;
}

canonical_decompiled_code:
const char *func8()
{
const char *v0; // r8
__int64 v2; // rax

atom_a = func13(a);
atom_b = func13(b);
if ( atom_b == atom_a )
{
v2 = func13(c);
v0 = 0LL;
atom_c = v2;
if ( v2 == atom_a )
{
fprintf(
stderr,
"[ERROR] (%s:%d:) atom_string returns the same atom with different contents.\n",
"tests/atom_tests.c",
33LL);
v0 = "atom_string returns the same atom with different contents.\n";
}
}
else
{
fprintf(stderr, "[ERROR] (%s:%d:) atom_string did not return the same atom.\n", "tests/atom_tests.c", 31LL);
v0 = "atom_string did not return the same atom.\n";
}
return v0;
}

original_code:
char *test_string()
{
    atom_a = atom_string(a);
    atom_b = atom_string(b);
    if (!(atom_a == atom_b)) { fprintf(stderr, "[ERROR] (%s:%d:) " "atom_string did not return the same atom.\n", "tests/atom_tests.c", 31);; return "atom_string did not return the same atom.\n"; };
    atom_c = atom_string(c);
    if (!(atom_a != atom_c)) { fprintf(stderr, "[ERROR] (%s:%d:) " "atom_string returns the same atom with different contents.\n", "tests/atom_tests.c", 33);; return "atom_string returns the same atom with different contents.\n"; }
    return ((void *)0);
}


decompiled_code:
const char *test_int()
{
__int64 v0; // r8
__int64 v2; // rax

atom_f = atom_int(123456LL);
atom_tmp = atom_int(123456LL);
if ( atom_tmp != atom_f )
{
fprintf(stderr, "[ERROR] (%s:%d:) atom_int did not return the same atom.\n", "tests/atom_tests.c", 42LL);
return "atom_int did not return the same atom.\n";
}
v2 = atom_string(e);
v0 = 0LL;
atom_e = v2;
if ( v2 == atom_f )
return (const char *)v0;
fprintf(stderr, "[ERROR] (%s:%d:) atom_int & atom_string did not return the same atom\n", "tests/atom_tests.c", 45LL);
return "atom_int & atom_string did not return the same atom\n";
}

canonical_decompiled_code:
const char *func9()
{
__int64 v0; // r8
__int64 v2; // rax

atom_f = func14(123456LL);
atom_tmp = func14(123456LL);
if ( atom_tmp != atom_f )
{
fprintf(stderr, "[ERROR] (%s:%d:) atom_int did not return the same atom.\n", "tests/atom_tests.c", 42LL);
return "atom_int did not return the same atom.\n";
}
v2 = func13(e);
v0 = 0LL;
atom_e = v2;
if ( v2 == atom_f )
return (const char *)v0;
fprintf(stderr, "[ERROR] (%s:%d:) atom_int & atom_string did not return the same atom\n", "tests/atom_tests.c", 45LL);
return "atom_int & atom_string did not return the same atom\n";
}

original_code:
char *test_int()
{
    atom_f = atom_int(123456);
    atom_tmp = atom_int(123456);
    if (!(atom_f == atom_tmp)) { fprintf(stderr, "[ERROR] (%s:%d:) " "atom_int did not return the same atom.\n", "tests/atom_tests.c", 42);; return "atom_int did not return the same atom.\n"; };
    atom_e = atom_string(e);
    if (!(atom_e == atom_f)) { fprintf(stderr, "[ERROR] (%s:%d:) " "atom_int & atom_string did not return the same atom\n", "tests/atom_tests.c", 45);; return "atom_int & atom_string did not return the same atom\n"; };
    return ((void *)0);
}


hash

original_code:
static inline unsigned long hash(const char *str, int len)
{
    unsigned long hash = 5381;
    int i;
    for (i = 0; i < len; i++) {
        hash = ((hash << 5) + hash) + str[i];
    }
    return hash;
}

canonical_original_code:
static inline unsigned long hash(char *str, int len)
{
    unsigned long hash = 5381;
    int i;
    for (i = 0; i < len; i++) {
        hash = ((hash << 5) + hash) + str[i];
    }
    return hash;
}

variable_types:
str
char *

variable_types: len int

variable_types:
hash
unsigned long

variable_types: i int

return_type: unsigned long


original_code:
const char *atom_new(const char *str, int len)
{
    unsigned long hash_val = 0;
    int i;
    struct atom_t *p;
    int nelts = (sizeof(buckets)/sizeof(buckets[0]));
    ((void) (0));
    ((void) (0));
    hash_val = hash(str, len);
    hash_val %= nelts;
    for (p = buckets[hash_val]; p; p = p->link) {
        if (len == p->len) {
            for (i=0; i<len && p->str[i] == str[i]; i++) {
            }
            if (i == len) {
                return p->str;
            }
        }
    }
    p = zalloc(sizeof(*p) + len + 1);
    p->len = len;
    p->str = (char *)(p+1);
    if (len > 0) {
        memcpy(p->str, str, len);
    }
    p->str[len] = '\0';
    p->link = buckets[hash_val];
    buckets[hash_val] = p;
    return p->str;
}

canonical_original_code:
char *atom_new(char *str, int len)
{
    unsigned long hash_val = 0;
    int i;
    struct atom_t *p;
    int nelts = (sizeof(buckets)/sizeof(buckets[0]));
    ((void) (0));
    ((void) (0));
    hash_val = hash(str, len);
    hash_val %= nelts;
    for (p = buckets[hash_val]; p; p = p->link) {
        if (len == p->len) {
            for (i=0; i<len && p->str[i] == str[i]; i++) {
            }
            if (i == len) {
                return p->str;
            }
        }
    }
    p = zalloc(sizeof(*p) + len + 1);
    p->len = len;
    p->str = (char *)(p+1);
    if (len > 0) {
        memcpy(p->str, str, len);
    }
    p->str[len] = '\0';
    p->link = buckets[hash_val];
    buckets[hash_val] = p;
    return p->str;
}

variable_types: struct atom_t { struct atom_t *link; int len; char *str; } *

variable_types: nelts int


decompiled_code:
__int64 __fastcall atom_string(void *src)
{
int v1; // eax

v1 = strlen((const char *)src);
return atom_new(src, v1);
}

canonical_decompiled_code:
__int64 __fastcall func13(void *src)
{
int v1; // eax

v1 = strlen((const char *)src);
return func12(src, v1);
}

original_code:
const char *atom_string(const char *str)
{
    ((void) (0));
    return atom_new(str, strlen(str));
}

canonical_original_code:
char *atom_string(char *str)
{
    ((void) (0));
    return atom_new(str, strlen(str));
}


original_code:
const char *atom_int(long n)
{
    char str[43];
    char *s = str + sizeof(str);
    unsigned long m;
    if (n == (-0x7fffffffffffffffL - 1L)) {
        m = 0x7fffffffffffffffL + 1UL;
    } else if (n < 0) {
        m = -n;
    } else {
        m = n;
    }
    do {
        *--s = m % 10 + '0';
    } while ((m /= 10) > 0);
    if (n < 0) {
        *--s = '-';
    }
    return atom_new(s, sizeof(str) - (s-str));
}

variable_types: n long

variable_types:
str
char [43]

variable_types:
s
char *

variable_types:
m
unsigned long


decompiled_code:
__int64 __fastcall atom_length(__int64 *a1)
{
__int64 ***v1; // rdx
__int64 **v2; // rax

v1 = (__int64 ***)buckets;
while ( 1 )
{
v2 = *v1;
if ( *v1 )
break;
LABEL_7:
if ( ++v1 == &buckets[2048] )
{
fprintf(stderr, "[ERROR] (%s:%d:) atom_length: *str* is not an existing atom\n", "lib/atom.c", 131LL);
return 0LL;
}
}
while ( v2[2] != a1 )
{
v2 = (__int64 **)*v2;
if ( !v2 )
goto LABEL_7;
}
return *((unsigned int *)v2 + 2);
}

canonical_decompiled_code:
__int64 __fastcall func15(__int64 *a1)
{
__int64 ***v1; // rdx
__int64 **v2; // rax

v1 = (__int64 ***)buckets;
while ( 1 )
{
v2 = *v1;
if ( *v1 )
break;
LABEL_7:
if ( ++v1 == &buckets[2048] )
{
fprintf(stderr, "[ERROR] (%s:%d:) atom_length: *str* is not an existing atom\n", "lib/atom.c", 131LL);
return 0LL;
}
}
while ( v2[2] != a1 )
{
v2 = (__int64 **)*v2;
if ( !v2 )
goto LABEL_7;
}
return *((unsigned int *)v2 + 2);
}

original_code:
int atom_length(const char *str)
{
    struct atom_t *p;
    int i;
    int nelts = (sizeof(buckets)/sizeof(buckets[0]));
    ((void) (0));
    for (i = 0; i < nelts; i++) {
        for (p = buckets[i]; p; p = p->link) {
            if (p->str == str) {
                return p->len;
            }
        }
    }
    fprintf(stderr, "[ERROR] (%s:%d:) " "atom_length: *str* is not an existing atom\n", "lib/atom.c", 131);;
    ((void) (0));
    return 0;
}

canonical_original_code:
int atom_length(char *str)
{
    struct atom_t *p;
    int i;
    int nelts = (sizeof(buckets)/sizeof(buckets[0]));
    ((void) (0));
    for (i = 0; i < nelts; i++) {
        for (p = buckets[i]; p; p = p->link) {
            if (p->str == str) {
                return p->len;
            }
        }
    }
    fprintf(stderr, "[ERROR] (%s:%d:) " "atom_length: *str* is not an existing atom\n", "lib/atom.c", 131);;
    ((void) (0));
    return 0;
}

user_defined_types: struct atom_t { struct atom_t *link; int len; char *str; }


decompiled_code:
_QWORD *print_atom_table()
{
__int64 i; // r14
_QWORD *result; // rax
__int64 **v2; // rbx
unsigned int v3; // ebp
__int64 v4; // r9
_QWORD *v5; // [rsp-10h] [rbp-48h]

for ( i = 0LL; i != 2048; ++i )
{
result = buckets;
v2 = (__int64 **)buckets[i];
if ( v2 )
{
v3 = 0;
do
{
v4 = v3++;
fprintf(
stderr,
"[INFO] (%s:%d:) buckets[%d][%d] = %s\n",
"lib/atom.c",
146LL,
(unsigned int)i,
v4,
(const char *)v2[2]);
v2 = (__int64 **)*v2;
result = v5;
}
while ( v2 );
}
}
return result;
}

canonical_decompiled_code:
_QWORD *func16()
{
__int64 i; // r14
_QWORD *result; // rax
__int64 **v2; // rbx
unsigned int v3; // ebp
__int64 v4; // r9
_QWORD *v5; // [rsp-10h] [rbp-48h]

for ( i = 0LL; i != 2048; ++i )
{
result = buckets;
v2 = (__int64 **)buckets[i];
if ( v2 )
{
v3 = 0;
do
{
v4 = v3++;
fprintf(
stderr,
"[INFO] (%s:%d:) buckets[%d][%d] = %s\n",
"lib/atom.c",
146LL,
(unsigned int)i,
v4,
(const char *)v2[2]);
v2 = (__int64 **)*v2;
result = v5;
}
while ( v2 );
}
}
return result;
}

original_code:
void print_atom_table()
{
    struct atom_t *p;
    int i;
    int nelts = (sizeof(buckets)/sizeof(buckets[0]));
    for (i = 0; i < nelts; i++) {
        int j = 0;
        for (p = buckets[i]; p; p = p->link, j++) {
            fprintf(stderr, "[INFO] (%s:%d:) " "buckets[%d][%d] = %s\n", "lib/atom.c", 146, i, j, p->str);;
        }
    }
}

variable_types: j int


zalloc

canonical_decompiled_code:
void *func17(size_t size)
{
return malloc(size);
}

original_code:
void *zalloc(size_t size)
{
    void *p = malloc(size);
    ((void) (0));
    return p;
}

variable_types:
size
unsigned long

variable_types:
p
void *


zfree

canonical_decompiled_code:
void func18(void *ptr)
{
free(ptr);
}

original_code:
void zfree(void *ptr)
{
    ((void) (0));
    free(ptr);
}

variable_types:
ptr
void *


zcalloc

canonical_decompiled_code:
void *func19(size_t nmemb, size_t size)
{
return calloc(nmemb, size);
}

original_code:
void *zcalloc(size_t nmemb, size_t size)
{
    void *p = calloc(nmemb, size);
    ((void) (0));
    return p;
}

variable_types:
nmemb
unsigned long


main

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

fprintf(stderr, "[DEBUG] %s:%d: \n===== RUNNING: %s\n", "tests/atom_tests.c", 61LL, *argv);
printf("====\nRUNNING: %s\n", *argv);
v3 = (const char *)all_tests();
v4 = v3;
if ( v3 )
printf("FAILED: %s\n", v3);
else
puts("ALL TESTS PASSED");
printf("Tests run: %d\n", (unsigned int)tests_run);
exit(v4 != 0LL);
}

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

fprintf(stderr, "[DEBUG] %s:%d: \n===== RUNNING: %s\n", "tests/atom_tests.c", 61LL, *argv);
printf("====\nRUNNING: %s\n", *argv);
v3 = (const char *)func10();
v4 = v3;
if ( v3 )
printf("FAILED: %s\n", v3);
else
puts("ALL TESTS PASSED");
printf("Tests run: %d\n", (unsigned int)tests_run);
exit(v4 != 0LL);
}

original_code: int main(int argc, const char *argv[]) { (void)argc; fprintf(stderr, "[DEBUG] %s:%d: ""\n===== RUNNING: %s\n", "tests/atom_tests.c", 61, argv[0]);; printf("====\nRUNNING: %s\n", argv[0]); char *result = all_tests(); if (result != 0) { printf("FAILED: %s\n", result); } else { printf("ALL TESTS PASSED\n"); } printf("Tests run: %d\n", tests_run); exit(result != 0); }

canonical_original_code: int main(int argc, char *argv[]) { (void)argc; fprintf(stderr, "[DEBUG] %s:%d: ""\n===== RUNNING: %s\n", "tests/atom_tests.c", 61, argv[0]);; printf("====\nRUNNING: %s\n", argv[0]); char *result = all_tests(); if (result != 0) { printf("FAILED: %s\n", result); } else { printf("ALL TESTS PASSED\n"); } printf("Tests run: %d\n", tests_run); exit(result != 0); }

variable_types: argc int

variable_types:
argv
char *[]

variable_types:
result
char *


decompiled_code:
const char *test_new()
{
__int64 v0; // rax
const char *v1; // r8

atom_d = atom_new(&d);
v0 = atom_new(&d);
v1 = 0LL;
atom_tmp = v0;
if ( v0 != atom_d )
{
fprintf(stderr, "[ERROR] (%s:%d:) atom_new did not return the same atom\n", "tests/atom_tests.c", 23LL);
v1 = "atom_new did not return the same atom\n";
}
return v1;
}

canonical_decompiled_code:
const char *func7()
{
__int64 v0; // rax
const char *v1; // r8

atom_d = func12(&d);
v0 = func12(&d);
v1 = 0LL;
atom_tmp = v0;
if ( v0 != atom_d )
{
fprintf(stderr, "[ERROR] (%s:%d:) atom_new did not return the same atom\n", "tests/atom_tests.c", 23LL);
v1 = "atom_new did not return the same atom\n";
}
return v1;
}

original_code:
char *test_new()
{
    atom_d = atom_new((char *)d, 6*sizeof(int));
    atom_tmp = atom_new((char *)d, 6*sizeof(int));
    if (!(atom_d == atom_tmp)) { fprintf(stderr, "[ERROR] (%s:%d:) " "atom_new did not return the same atom\n", "tests/atom_tests.c", 23);; return "atom_new did not return the same atom\n"; };
    return ((void *)0);
}


decompiled_code:
const char *all_tests()
{
const char *result; // rax

fprintf(stderr, "[DEBUG] %s:%d: \n------->%s\n", "tests/atom_tests.c", 54LL, " test_new");
result = test_new();
++tests_run;
if ( !result )
{
fprintf(stderr, "[DEBUG] %s:%d: \n------->%s\n", "tests/atom_tests.c", 55LL, " test_string");
result = test_string();
++tests_run;
if ( !result )
{
fprintf(stderr, "[DEBUG] %s:%d: \n------->%s\n", "tests/atom_tests.c", 56LL, " test_int");
result = test_int();
++tests_run;
}
}
return result;
}

canonical_decompiled_code:
const char *func10()
{
const char *result; // rax

fprintf(stderr, "[DEBUG] %s:%d: \n------->%s\n", "tests/atom_tests.c", 54LL, " test_new");
result = func7();
++tests_run;
if ( !result )
{
fprintf(stderr, "[DEBUG] %s:%d: \n------->%s\n", "tests/atom_tests.c", 55LL, " test_string");
result = func8();
++tests_run;
if ( !result )
{
fprintf(stderr, "[DEBUG] %s:%d: \n------->%s\n", "tests/atom_tests.c", 56LL, " test_int");
result = func9();
++tests_run;
}
}
return result;
}

original_code:
char *all_tests()
{
    char *message = ((void *)0);
    fprintf(stderr, "[DEBUG] %s:%d: ""\n------->%s\n", "tests/atom_tests.c", 54, " " "test_new");; message = (test_new)(); tests_run++; if (message) return message;;
    fprintf(stderr, "[DEBUG] %s:%d: ""\n------->%s\n", "tests/atom_tests.c", 55, " " "test_string");; message = (test_string)(); tests_run++; if (message) return message;;
    fprintf(stderr, "[DEBUG] %s:%d: ""\n------->%s\n", "tests/atom_tests.c", 56, " " "test_int");; message = (test_int)(); tests_run++; if (message) return message;;
    return ((void *)0);
}

variable_types:
message
char *


cmp

decompiled_code:
int __fastcall cmp(const void *a1, const void *a2)
{
return strcmp(*(const char **)a1, *(const char **)a2);
}

canonical_decompiled_code:
int __fastcall func2(const void *a1, const void *a2)
{
return strcmp(*(const char **)a1, *(const char **)a2);
}

original_code:
int cmp(const void *a, const void *b)
{
    return strcmp(*(char **)a, *(char **)b);
}

canonical_original_code:
int cmp(void *a, void *b)
{
    return strcmp(*(char **)a, *(char **)b);
}

variable_types:
a
void *

variable_types:
b
void *


vfree

decompiled_code:
__int64 __fastcall vfree(__int64 a1, __int64 a2)
{
return zfree(a2);
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, __int64 a2)
{
return zfree(a2);
}

original_code:
void vfree(const void *key, void *val)
{
    (void)key;
    zfree(val);
}

canonical_original_code:
void vfree(void *key, void *val)
{
    (void)key;
    zfree(val);
}

variable_types:
key
void *

variable_types:
val
void *


decompiled_code:
unsigned __int64 __fastcall default_hash(unsigned __int64 a1)
{
return a1 >> 2;
}

canonical_decompiled_code:
unsigned __int64 __fastcall func0(unsigned __int64 a1)
{
return a1 >> 2;
}

original_code:
static unsigned default_hash(const void *key)
{
    return (unsigned long)key >> 2;
}

canonical_original_code:
static unsigned int default_hash(void *key)
{
    return (unsigned long)key >> 2;
}

return_type: unsigned int


decompiled_code:
_BOOL8 __fastcall default_cmp(__int64 a1, __int64 a2)
{
return a2 != a1;
}

canonical_decompiled_code:
_BOOL8 __fastcall func1(__int64 a1, __int64 a2)
{
return a2 != a1;
}

original_code:
static int default_cmp(const void *a, const void *b)
{
    return a != b;
}

canonical_original_code:
static int default_cmp(void *a, void *b)
{
    return a != b;
}


original_code:
table_t table_new(int hint,
            int cmp(const void *a, const void *b),
            unsigned hash(const void *key))
{
    table_t table;
    int i;
    static int primes[] = {509, 509, 1021, 2053, 4093, 8191, 16381, 32771,
        65521, 0x7fffffff};
    ((void) (0));
    for (i=1; primes[i] < hint; i++) {
    }
    table = (table_t) zalloc(sizeof(*table) + primes[i-1]*sizeof(table->buckets[0]));
    table->size = primes[i-1];
    table->cmp = cmp ? cmp: default_cmp;
    table->hash = hash ? hash: default_hash;
    table->buckets = (struct binding **) (table+1);
    for (i = 0; i < table->size; i++) {
        table->buckets[i] = ((void *)0);
    }
    table->length = 0;
    table->timestamp = 0;
    return table;
}

canonical_original_code:
struct table_t *table_new(int hint, int cmp(void *a, void *b), unsigned int hash(void *key))
{
    struct table_t *table;
    int i;
    static int primes[] = {509, 509, 1021, 2053, 4093, 8191, 16381, 32771,
        65521, 0x7fffffff};
    ((void) (0));
    for (i=1; primes[i] < hint; i++) {
    }
    table = (struct table_t *) zalloc(sizeof(*table) + primes[i-1]*sizeof(table->buckets[0]));
    table->size = primes[i-1];
    table->cmp = cmp ? cmp: default_cmp;
    table->hash = hash ? hash: default_hash;
    table->buckets = (struct binding **) (table+1);
    for (i = 0; i < table->size; i++) {
        table->buckets[i] = ((void *)0);
    }
    table->length = 0;
    table->timestamp = 0;
    return table;
}

variable_types: hint int

variable_types:
cmp
int (void *a, void *b)

variable_types:
hash
unsigned int (void *key)

variable_types: struct table_t { struct binding { struct binding *link; void *key; void *value; } **buckets; int size; int length; unsigned int timestamp; int (*cmp)(void *a, void *b); unsigned int (*hash)(void *key); } *

variable_types: i int

variable_types:
primes
int []

user_defined_types: struct table_t { struct binding **buckets; int size; int length; unsigned int timestamp; int (*cmp)(void *a, void *b); unsigned int (*hash)(void *key); }


decompiled_code:
__int64 __fastcall table_get(__int64 a1, __int64 a2)
{
_QWORD *v2; // rbx

v2 = *(_QWORD **)(*(_QWORD *)a1
+ 8LL * (int)((*(unsigned int (__fastcall **)(__int64))(a1 + 32))(a2) % *(_DWORD *)(a1 + 8)));
if ( !v2 )
return 0LL;
while ( (*(unsigned int (__fastcall **)(__int64, _QWORD))(a1 + 24))(a2, v2[1]) )
{
v2 = (_QWORD *)*v2;
if ( !v2 )
return 0LL;
}
return v2[2];
}

original_code:
void *table_get(table_t table, const void *key)
{
    int hash_val;
    struct binding *p;
    ((void) (0));
    ((void) (0));
    hash_val = (*table->hash)(key) % table->size;
    for (p = table->buckets[hash_val]; p; p = p->link) {
        if ((*table->cmp)(key, p->key) == 0) {
            break;
        }
    }
    return p ? p->value: ((void *)0);
}

canonical_original_code:
void *table_get(struct table_t *table, void *key)
{
    int hash_val;
    struct binding *p;
    ((void) (0));
    ((void) (0));
    hash_val = (*table->hash)(key) % table->size;
    for (p = table->buckets[hash_val]; p; p = p->link) {
        if ((*table->cmp)(key, p->key) == 0) {
            break;
        }
    }
    return p ? p->value: ((void *)0);
}

variable_types: struct binding { struct binding *link; void *key; void *value; } *


original_code:
void *table_put(table_t table, const void *key, void *value)
{
    int hash_val;
    struct binding *p;
    void *prev;
    ((void) (0));
    ((void) (0));
    hash_val = (*table->hash)(key) % table->size;
    for (p = table->buckets[hash_val]; p; p = p->link) {
        if ((*table->cmp)(key, p->key) == 0) {
            break;
        }
    }
    if (p == ((void *)0)) {
        p = (struct binding *)zalloc(sizeof(*p));
        p->key = key;
        p->link = table->buckets[hash_val];
        table->buckets[hash_val] = p;
        table->length ++;
        prev = ((void *)0);
    } else {
        prev = p->value;
    }
    p->value = value;
    table->timestamp ++;
    return prev;
}

canonical_original_code:
void *table_put(struct table_t *table, void *key, void *value)
{
    int hash_val;
    struct binding *p;
    void *prev;
    ((void) (0));
    ((void) (0));
    hash_val = (*table->hash)(key) % table->size;
    for (p = table->buckets[hash_val]; p; p = p->link) {
        if ((*table->cmp)(key, p->key) == 0) {
            break;
        }
    }
    if (p == ((void *)0)) {
        p = (struct binding *)zalloc(sizeof(*p));
        p->key = key;
        p->link = table->buckets[hash_val];
        table->buckets[hash_val] = p;
        table->length ++;
        prev = ((void *)0);
    } else {
        prev = p->value;
    }
    p->value = value;
    table->timestamp ++;
    return prev;
}

variable_types:
value
void *

variable_types:
prev
void *

user_defined_types: struct binding { struct binding *link; void *key; void *value; }


decompiled_code:
__int64 __fastcall table_length(__int64 a1)
{
return *(unsigned int *)(a1 + 12);
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1)
{
return *(unsigned int *)(a1 + 12);
}

original_code:
int table_length(table_t table)
{
    ((void) (0));
    return table->length;
}

canonical_original_code:
int table_length(struct table_t *table)
{
    ((void) (0));
    return table->length;
}


decompiled_code:
__int64 __fastcall table_map(__int64 a1, __int64 (__fastcall *a2)(_QWORD, _QWORD *, __int64), __int64 a3)
{
__int64 result; // rax
__int64 v4; // r13
_QWORD *i; // rbx

result = *(unsigned int *)(a1 + 8);
if ( (int)result > 0 )
{
v4 = 0LL;
do
{
result = *(_QWORD *)a1;
for ( i = *(_QWORD **)(*(_QWORD *)a1 + 8 * v4); i; i = (_QWORD *)*i )
result = a2(i[1], i + 2, a3);
++v4;
}
while ( *(_DWORD *)(a1 + 8) > (int)v4 );
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1, __int64 (__fastcall *a2)(_QWORD, _QWORD *, __int64), __int64 a3)
{
__int64 result; // rax
__int64 v4; // r13
_QWORD *i; // rbx

result = *(unsigned int *)(a1 + 8);
if ( (int)result > 0 )
{
v4 = 0LL;
do
{
result = *(_QWORD *)a1;
for ( i = *(_QWORD **)(*(_QWORD *)a1 + 8 * v4); i; i = (_QWORD *)*i )
result = a2(i[1], i + 2, a3);
++v4;
}
while ( *(_DWORD *)(a1 + 8) > (int)v4 );
}
return result;
}

original_code:
void table_map(table_t table,
               void apply(const void *key, void **value, void *cl),
               void *cl)
{
    int i;
    unsigned timestamp;
    struct binding *p;
    ((void) (0));
    ((void) (0));
    timestamp = table->timestamp;
    for (i = 0; i < table->size; i++) {
        for (p=table->buckets[i]; p; p = p->link) {
            ((void) (0));
            apply(p->key, &p->value, cl);
        }
    }
}

canonical_original_code:
void table_map(struct table_t *table, void apply(void *key, void **value, void *cl), void *cl)
{
    int i;
    unsigned int timestamp;
    struct binding *p;
    ((void) (0));
    ((void) (0));
    timestamp = table->timestamp;
    for (i = 0; i < table->size; i++) {
        for (p=table->buckets[i]; p; p = p->link) {
            ((void) (0));
            apply(p->key, &p->value, cl);
        }
    }
}

variable_types: void (void *key, void **value, void *cl)

variable_types:
cl
void *

variable_types:
timestamp
unsigned int


decompiled_code:
int __fastcall print_table(__int64 *a1)
{
__int64 v1; // rax
__int64 v2; // r12
__int64 **v3; // rbx

LODWORD(v1) = *((_DWORD *)a1 + 2);
if ( (int)v1 > 0 )
{
v2 = 0LL;
do
{
while ( 1 )
{
v1 = *a1;
v3 = *(__int64 ***)(*a1 + 8 * v2);
if ( v3 )
break;
if ( *((_DWORD *)a1 + 2) <= (int)++v2 )
return v1;
}
fprintf(stderr, "[INFO] (%s:%d:) table[%d] contains: \n", "lib/table.c", 223LL, (unsigned int)v2);
do
{
LODWORD(v1) = fprintf(
stderr,
"[INFO] (%s:%d:) \t(key = '%p', \tval= '%p'\n",
"lib/table.c",
225LL,
v3[1],
v3[2]);
v3 = (__int64 **)*v3;
}
while ( v3 );
++v2;
}
while ( *((_DWORD *)a1 + 2) > (int)v2 );
}
return v1;
}

original_code:
extern void print_table(table_t table)
{
    ((void) (0));
    int i;
    struct binding *p;
    for (i = 0; i < table->size; i++) {
        p = table->buckets[i];
        if (p == ((void *)0)) {
            continue;
        }
        fprintf(stderr, "[INFO] (%s:%d:) " "table[%d] contains: \n", "lib/table.c", 223, i);;
        for (; p; p=p->link) {
            fprintf(stderr, "[INFO] (%s:%d:) " "\t(key = '%p', \tval= '%p'\n", "lib/table.c", 225, p->key, p->value);;
        }
    }
}

canonical_original_code:
extern void print_table(struct table_t *table)
{
    ((void) (0));
    int i;
    struct binding *p;
    for (i = 0; i < table->size; i++) {
        p = table->buckets[i];
        if (p == ((void *)0)) {
            continue;
        }
        fprintf(stderr, "[INFO] (%s:%d:) " "table[%d] contains: \n", "lib/table.c", 223, i);;
        for (; p; p=p->link) {
            fprintf(stderr, "[INFO] (%s:%d:) " "\t(key = '%p', \tval= '%p'\n", "lib/table.c", 225, p->key, p->value);;
        }
    }
}


original_code:
list_t *list_copy(list_t *list)
{
    list_t *head;
    list_t **p = &head;
    for (; list; list = list->rest) {
        *p = (list_t *)zalloc(sizeof(**p));
        (*p)->first = list->first;
        p = &(*p)->rest;
    }
    *p = ((void *)0);
    return head;
}

canonical_original_code:
struct list_t *list_copy(struct list_t *list)
{
    struct list_t *head;
    struct list_t **p = &head;
    for (; list; list = list->rest) {
        *p = (struct list_t *)zalloc(sizeof(**p));
        (*p)->first = list->first;
        p = &(*p)->rest;
    }
    *p = ((void *)0);
    return head;
}

variable_types:
list
struct list_t *

variable_types: struct list_t { struct list_t *rest; void *first; } **


decompiled_code:
__int64 __fastcall list_length(_QWORD *a1)
{
__int64 result; // rax

for ( result = 0LL; a1; result = (unsigned int)(result + 1) )
a1 = (_QWORD *)*a1;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(_QWORD *a1)
{
__int64 result; // rax

for ( result = 0LL; a1; result = (unsigned int)(result + 1) )
a1 = (_QWORD *)*a1;
return result;
}

original_code:
int list_length(list_t *list)
{
    int n;
    for (n=0; list; list = list->rest) {
        n ++;
    }
    return n;
}

canonical_original_code:
int list_length(struct list_t *list)
{
    int n;
    for (n=0; list; list = list->rest) {
        n ++;
    }
    return n;
}

variable_types: struct list_t { struct list_t *rest; void *first; } *

variable_types: n int


main

repo: lotabout/compiler-design-in-c

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
statements(argc, argv, envp);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
func15(argc, argv, envp);
return 0;
}

original_code:
int main(int argc, const char *argv[])
{
    statements();
    return 0;
}

canonical_original_code:
int main(int argc, char *argv[])
{
    statements();
    return 0;
}

variable_types: argc int

variable_types:
argv
char *[]


lex

decompiled_code:
__int64 lex()
{
char *v0; // rbx
__int64 v1; // rax
char v2; // bp
const unsigned __int16 *v3; // rax
__int64 result; // rax
const unsigned __int16 *v5; // rcx
char *v6; // rdx
__int64 v7; // rcx

v0 = (char *)yytext + yyleng;
LOBYTE(v1) = *v0;
while ( !(_BYTE)v1 )
{
LABEL_7:
result = gets();
if ( !(_DWORD)result )
{
input_buffer_0 = 0;
return result;
}
++yylineno;
v0 = &input_buffer_0;
v5 = *__ctype_b_loc();
while ( 1 )
{
v1 = *v0;
if ( (v5[v1] & 0x2000) == 0 )
break;
++v0;
}
}
while ( 2 )
{
yytext = v0;
yyleng = 1;
v2 = *v0;
switch ( *v0 )
{
case -1:
return 0LL;
case 9:
case 10:
case 32:
goto LABEL_6;
case 40:
return 4LL;
case 41:
return 5LL;
case 42:
return 3LL;
case 43:
return 2LL;
case 59:
return 1LL;
default:
v3 = *__ctype_b_loc();
if ( (v3[v2] & 8) == 0 )
{
fprintf(_bss_start, "Ignoring illegal input <%c>\n", (unsigned int)v2);
LABEL_6:
if ( !*++v0 )
goto LABEL_7;
continue;
}
v6 = v0;
do
v7 = *++v6;
while ( (v3[v7] & 8) != 0 );
result = 6LL;
yyleng = (_DWORD)v6 - (_DWORD)v0;
return result;
}
}
}

canonical_decompiled_code:
__int64 func7()
{
char *v0; // rbx
__int64 v1; // rax
char v2; // bp
const unsigned __int16 *v3; // rax
__int64 result; // rax
const unsigned __int16 *v5; // rcx
char *v6; // rdx
__int64 v7; // rcx

v0 = (char *)yytext + yyleng;
LOBYTE(v1) = *v0;
while ( !(_BYTE)v1 )
{
LABEL_7:
result = gets();
if ( !(_DWORD)result )
{
input_buffer_0 = 0;
return result;
}
++yylineno;
v0 = &input_buffer_0;
v5 = *__ctype_b_loc();
while ( 1 )
{
v1 = *v0;
if ( (v5[v1] & 0x2000) == 0 )
break;
++v0;
}
}
while ( 2 )
{
yytext = v0;
yyleng = 1;
v2 = *v0;
switch ( *v0 )
{
case -1:
return 0LL;
case 9:
case 10:
case 32:
goto LABEL_6;
case 40:
return 4LL;
case 41:
return 5LL;
case 42:
return 3LL;
case 43:
return 2LL;
case 59:
return 1LL;
default:
v3 = *__ctype_b_loc();
if ( (v3[v2] & 8) == 0 )
{
fprintf(_bss_start, "Ignoring illegal input <%c>\n", (unsigned int)v2);
LABEL_6:
if ( !*++v0 )
goto LABEL_7;
continue;
}
v6 = v0;
do
v7 = *++v6;
while ( (v3[v7] & 8) != 0 );
result = 6LL;
yyleng = (_DWORD)v6 - (_DWORD)v0;
return result;
}
}
}

original_code:
token_t lex(void)
{
    static char input_buffer[128];
    char *current;
    current = yytext + yyleng;
    while (1) {
        while (*current == '\0') {
            current = input_buffer;
            if (!gets(input_buffer)) {
                *current = '\0';
                return EOI;
            }
            ++yylineno;
            while (((*__ctype_b_loc ())[(int) ((*current))] & (unsigned short int) _ISspace)) {
                ++current;
            }
        }
        for (; *current; ++current) {
            yytext = current;
            yyleng = 1;
            switch (*current) {
                case (-1):
                    return EOI;
                    break;
                case ';':
                    return SEMI;
                    break;
                case '+':
                    return PLUS;
                    break;
                case '*':
                    return TIMES;
                    break;
                case '(':
                    return LP;
                    break;
                case ')':
                    return RP;
                    break;
                case '\n':
                case '\t':
                case ' ':
                    break;
                default:
                    if (! ((*__ctype_b_loc ())[(int) ((*current))] & (unsigned short int) _ISalnum)) {
                        fprintf(stderr, "Ignoring illegal input <%c>\n",
                                *current);
                    } else {
                        while (((*__ctype_b_loc ())[(int) ((*current))] & (unsigned short int) _ISalnum)) {
                            ++current;
                        }
                        yyleng = current - yytext;
                        return NUM_OR_ID;
                    }
                    break;
            }
        }
    }
}

canonical_original_code:
enum token_t lex()
{
    static char input_buffer[128];
    char *current;
    current = yytext + yyleng;
    while (1) {
        while (*current == '\0') {
            current = input_buffer;
            if (!gets(input_buffer)) {
                *current = '\0';
                return EOI;
            }
            ++yylineno;
            while (((*__ctype_b_loc ())[(int) ((*current))] & (unsigned short) _ISspace)) {
                ++current;
            }
        }
        for (; *current; ++current) {
            yytext = current;
            yyleng = 1;
            switch (*current) {
                case (-1):
                    return EOI;
                    break;
                case ';':
                    return SEMI;
                    break;
                case '+':
                    return PLUS;
                    break;
                case '*':
                    return TIMES;
                    break;
                case '(':
                    return LP;
                    break;
                case ')':
                    return RP;
                    break;
                case '\n':
                case '\t':
                case ' ':
                    break;
                default:
                    if (! ((*__ctype_b_loc ())[(int) ((*current))] & (unsigned short) _ISalnum)) {
                        fprintf(stderr, "Ignoring illegal input <%c>\n",
                                *current);
                    } else {
                        while (((*__ctype_b_loc ())[(int) ((*current))] & (unsigned short) _ISalnum)) {
                            ++current;
                        }
                        yyleng = current - yytext;
                        return NUM_OR_ID;
                    }
                    break;
            }
        }
    }
}

variable_types:
current
char *

return_type: enum token_t { EOI=0, SEMI=1, PLUS=2, TIMES=3, LP=4, RP=5, NUM_OR_ID=6, UNKNOWN=7 }


match

decompiled_code:
bool __fastcall match(int a1)
{
if ( Lookahead == 7 )
Lookahead = lex();
return a1 == Lookahead;
}

canonical_decompiled_code:
bool __fastcall func8(int a1)
{
if ( Lookahead == 7 )
Lookahead = func7();
return a1 == Lookahead;
}

original_code:
_Bool match(token_t token)
{
    if (Lookahead == UNKNOWN) {
        Lookahead = lex();
    }
    return token == Lookahead;
}

canonical_original_code:
_Bool match(enum token_t token)
{
    if (Lookahead == UNKNOWN) {
        Lookahead = lex();
    }
    return token == Lookahead;
}

variable_types: enum token_t { EOI=0, SEMI=1, PLUS=2, TIMES=3, LP=4, RP=5, NUM_OR_ID=6, UNKNOWN=7 }


advance

decompiled_code:
__int64 advance()
{
__int64 result; // rax

result = lex();
Lookahead = result;
return result;
}

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

result = func7();
Lookahead = result;
return result;
}

original_code:
void advance()
{
    Lookahead = lex();
}

canonical_original_code:
void advance()
{
    Lookahead = lex();
}


newname

decompiled_code:
__int64 newname()
{
if ( Namep >= (char **)&_bss_start )
{
fprintf(_bss_start, "%d: Expression too complex\n", (unsigned int)yylineno);
exit(1);
}
return (__int64)*Namep++;
}

canonical_decompiled_code:
__int64 func10()
{
if ( Namep >= (char **)&_bss_start )
{
fprintf(_bss_start, "%d: Expression too complex\n", (unsigned int)yylineno);
exit(1);
}
return (__int64)*Namep++;
}

original_code:
char *newname(void)
{
    if (Namep >= &Names[sizeof(Names)/sizeof(*Names)]) {
        fprintf(stderr, "%d: Expression too complex\n", yylineno);
        exit(1);
    }
    return (*Namep++);
}

canonical_original_code:
char *newname()
{
    if (Namep >= &Names[sizeof(Names)/sizeof(*Names)]) {
        fprintf(stderr, "%d: Expression too complex\n", yylineno);
        exit(1);
    }
    return (*Namep++);
}


freename

decompiled_code:
int __fastcall freename(char *a1)
{
char **v1; // rax

v1 = Namep;
if ( Namep <= &Names )
{
LODWORD(v1) = fprintf(_bss_start, "%d: (Internal error) Name stack underflow\n", (unsigned int)yylineno);
}
else
{
--Namep;
*(v1 - 1) = a1;
}
return (int)v1;
}

canonical_decompiled_code:
int __fastcall func11(char *a1)
{
char **v1; // rax

v1 = Namep;
if ( Namep <= &Names )
{
LODWORD(v1) = fprintf(_bss_start, "%d: (Internal error) Name stack underflow\n", (unsigned int)yylineno);
}
else
{
--Namep;
*(v1 - 1) = a1;
}
return (int)v1;
}

original_code:
void freename(char *s)
{
    if (Namep > Names) {
        *--Namep = s;
    } else {
        fprintf(stderr, "%d: (Internal error) Name stack underflow\n", yylineno);
    }
}

variable_types:
s
char *


decompiled_code:
__int64 __fastcall legal_lookahead(int a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6, char a7)
{
unsigned int v7; // er12
__int64 v8; // rsi
char *v9; // rdi
char *i; // rbp
__int64 v11; // rax
char *v12; // rax
int j; // er14
__int64 v14; // rdi
int v15; // eax
int *k; // rbx
int v17; // eax
int v19; // eax
int v20; // [rsp+20h] [rbp-98h] BYREF
char v21; // [rsp+24h] [rbp-94h] BYREF
char v22[8]; // [rsp+60h] [rbp-58h] BYREF
__int64 v23; // [rsp+68h] [rbp-50h]
__int64 v24; // [rsp+70h] [rbp-48h]
__int64 v25; // [rsp+78h] [rbp-40h]
__int64 v26; // [rsp+80h] [rbp-38h]
__int64 v27; // [rsp+88h] [rbp-30h]

v23 = a2;
v24 = a3;
v25 = a4;
v26 = a5;
v27 = a6;
if ( a1 )
{
v20 = a1;
v8 = 8LL;
v9 = &a7;
for ( i = &v21; ; i += 4 )
{
if ( (unsigned int)v8 <= 0x2F )
{
v11 = (unsigned int)v8;
v8 = (unsigned int)(v8 + 8);
v12 = &v22[v11];
}
else
{
v12 = v9;
v9 += 8;
}
LOBYTE(a3) = *(_DWORD *)v12 != 0 && i < v22;
v7 = a3;
if ( !(_BYTE)a3 )
break;
*((_DWORD *)i + 1) = *(_DWORD *)v12;
}
for ( j = 0; ; j = 1 )
{
v14 = 1LL;
LOBYTE(v15) = match(1);
if ( v15 )
break;
for ( k = &v20; i > (char *)k; ++k )
{
v14 = (unsigned int)*k;
LOBYTE(v17) = match(v14);
if ( v17 )
return 1;
}
if ( !j )
{
v14 = (__int64)_bss_start;
v8 = (__int64)"Line %d: Syntax error\n";
fprintf(_bss_start, "Line %d: Syntax error\n", (unsigned int)yylineno);
}
advance(v14, v8);
}
}
else
{
LOBYTE(v19) = match(-1);
LOBYTE(v7) = v19 != 0;
}
return v7;
}

canonical_decompiled_code:
__int64 __fastcall func16(int a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6, char a7)
{
unsigned int v7; // er12
__int64 v8; // rsi
char *v9; // rdi
char *i; // rbp
__int64 v11; // rax
char *v12; // rax
int j; // er14
__int64 v14; // rdi
int v15; // eax
int *k; // rbx
int v17; // eax
int v19; // eax
int v20; // [rsp+20h] [rbp-98h] BYREF
char v21; // [rsp+24h] [rbp-94h] BYREF
char v22[8]; // [rsp+60h] [rbp-58h] BYREF
__int64 v23; // [rsp+68h] [rbp-50h]
__int64 v24; // [rsp+70h] [rbp-48h]
__int64 v25; // [rsp+78h] [rbp-40h]
__int64 v26; // [rsp+80h] [rbp-38h]
__int64 v27; // [rsp+88h] [rbp-30h]

v23 = a2;
v24 = a3;
v25 = a4;
v26 = a5;
v27 = a6;
if ( a1 )
{
v20 = a1;
v8 = 8LL;
v9 = &a7;
for ( i = &v21; ; i += 4 )
{
if ( (unsigned int)v8 <= 0x2F )
{
v11 = (unsigned int)v8;
v8 = (unsigned int)(v8 + 8);
v12 = &v22[v11];
}
else
{
v12 = v9;
v9 += 8;
}
LOBYTE(a3) = *(_DWORD *)v12 != 0 && i < v22;
v7 = a3;
if ( !(_BYTE)a3 )
break;
*((_DWORD *)i + 1) = *(_DWORD *)v12;
}
for ( j = 0; ; j = 1 )
{
v14 = 1LL;
LOBYTE(v15) = func8(1);
if ( v15 )
break;
for ( k = &v20; i > (char *)k; ++k )
{
v14 = (unsigned int)*k;
LOBYTE(v17) = func8(v14);
if ( v17 )
return 1;
}
if ( !j )
{
v14 = (__int64)_bss_start;
v8 = (__int64)"Line %d: Syntax error\n";
fprintf(_bss_start, "Line %d: Syntax error\n", (unsigned int)yylineno);
}
func9(v14, v8);
}
}
else
{
LOBYTE(v19) = func8(-1);
LOBYTE(v7) = v19 != 0;
}
return v7;
}

original_code:
_Bool legal_lookahead(token_t first_arg,...)
{
    va_list args;
    token_t tok;
    token_t lookaheads[16], *p = lookaheads, *current;
    int error_printed = 0;
    int ret_val = 0;
    __builtin_va_start(args,first_arg);
    if (! first_arg) {
        if (match((-1))) {
            ret_val = 1;
        }
    } else {
        *p++ = first_arg;
        while ((tok = __builtin_va_arg(args,token_t)) && p < &lookaheads[16]) {
            *++p = tok;
        }
        while (!match(SEMI)) {
            for(current = lookaheads; current < p; ++current) {
                if (match(*current)) {
                    ret_val = 1;
                    goto exit;
                }
            }
            if (! error_printed) {
                fprintf(stderr, "Line %d: Syntax error\n", yylineno);
                error_printed = 1;
            }
            advance();
        }
    }
exit:
    __builtin_va_end(args);
    return ret_val;
}

canonical_original_code:
_Bool legal_lookahead(enum token_t first_arg, ...)
{
    __builtin_va_list args;
    enum token_t tok;
    enum token_t lookaheads[16]; enum token_t *p = lookaheads; enum token_t *current;
    int error_printed = 0;
    int ret_val = 0;
    __builtin_va_start(args,first_arg);
    if (! first_arg) {
        if (match((-1))) {
            ret_val = 1;
        }
    } else {
        *p++ = first_arg;
        while ((tok = __builtin_va_arg(args,token_t)) && p < &lookaheads[16]) {
            *++p = tok;
        }
        while (!match(SEMI)) {
            for(current = lookaheads; current < p; ++current) {
                if (match(*current)) {
                    ret_val = 1;
                    goto exit;
                }
            }
            if (! error_printed) {
                fprintf(stderr, "Line %d: Syntax error\n", yylineno);
                error_printed = 1;
            }
            advance();
        }
    }
exit:
    __builtin_va_end(args);
    return ret_val;
}

variable_types: enum token_t { EOI=0, SEMI=1, PLUS=2, TIMES=3, LP=4, RP=5, NUM_OR_ID=6, UNKNOWN=7 } [16]

variable_types: enum token_t { EOI=0, SEMI=1, PLUS=2, TIMES=3, LP=4, RP=5, NUM_OR_ID=6, UNKNOWN=7 } *


main

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
func17(argc, argv, envp);
return 0;
}


lex

user_defined_types: enum token_t { EOI=0, SEMI=1, PLUS=2, TIMES=3, LP=4, RP=5, NUM_OR_ID=6, UNKNOWN=7 }


freename

canonical_original_code:
void freename(char *s)
{
    if (Namep > Names) {
        *--Namep = s;
    } else {
        fprintf(stderr, "%d: (Internal error) Name stack underflow\n", yylineno);
    }
}


decompiled_code:
char term_prime()
{
int v0; // eax

while ( 1 )
{
LOBYTE(v0) = match(3);
if ( !v0 )
break;
advance();
factor();
}
return v0;
}

canonical_decompiled_code:
char func13()
{
int v0; // eax

while ( 1 )
{
LOBYTE(v0) = func8(3);
if ( !v0 )
break;
func9();
func12();
}
return v0;
}

original_code:
void term_prime(void)
{
    if (match(TIMES)) {
        advance();
        factor();
        term_prime();
    }
}

canonical_original_code:
void term_prime()
{
    if (match(TIMES)) {
        advance();
        factor();
        term_prime();
    }
}


decompiled_code:
char expr_prime()
{
int v0; // eax

while ( 1 )
{
LOBYTE(v0) = match(2);
if ( !v0 )
break;
advance();
term();
}
return v0;
}

canonical_decompiled_code:
char func15()
{
int v0; // eax

while ( 1 )
{
LOBYTE(v0) = func8(2);
if ( !v0 )
break;
func9();
func14();
}
return v0;
}

original_code:
void expr_prime(void)
{
    if (match(PLUS)) {
        advance();
        term();
        expr_prime();
    }
}

canonical_original_code:
void expr_prime()
{
    if (match(PLUS)) {
        advance();
        term();
        expr_prime();
    }
}


factor

decompiled_code:
int factor()
{
int v0; // eax
int v1; // eax
int v2; // eax

LOBYTE(v0) = match(6);
if ( v0 )
return advance();
LOBYTE(v1) = match(4);
if ( !v1 )
return fprintf(_bss_start, "%d Number or identifier expected\n", (unsigned int)yylineno);
advance();
expression();
LOBYTE(v2) = match(5);
if ( v2 )
return advance();
return fprintf(_bss_start, "%d: Mismatched parenthesis\n", (unsigned int)yylineno);
}

canonical_decompiled_code:
int func12()
{
int v0; // eax
int v1; // eax
int v2; // eax

LOBYTE(v0) = func8(6);
if ( v0 )
return func9();
LOBYTE(v1) = func8(4);
if ( !v1 )
return fprintf(_bss_start, "%d Number or identifier expected\n", (unsigned int)yylineno);
func9();
func16();
LOBYTE(v2) = func8(5);
if ( v2 )
return func9();
return fprintf(_bss_start, "%d: Mismatched parenthesis\n", (unsigned int)yylineno);
}

original_code:
void factor(void)
{
    if (match(NUM_OR_ID)) {
        advance();
    } else if (match(LP)) {
        advance();
        expression();
        if (match (RP)) {
            advance();
        } else {
            fprintf(stderr, "%d: Mismatched parenthesis\n", yylineno);
        }
    } else {
        fprintf(stderr, "%d Number or identifier expected\n", yylineno);
    }
}

canonical_original_code:
void factor()
{
    if (match(NUM_OR_ID)) {
        advance();
    } else if (match(LP)) {
        advance();
        expression();
        if (match (RP)) {
            advance();
        } else {
            fprintf(stderr, "%d: Mismatched parenthesis\n", yylineno);
        }
    } else {
        fprintf(stderr, "%d Number or identifier expected\n", yylineno);
    }
}


term

decompiled_code:
char term()
{
factor();
return term_prime();
}

canonical_decompiled_code:
char func14()
{
func12();
return func13();
}

original_code:
void term(void)
{
    factor();
    term_prime();
}

canonical_original_code:
void term()
{
    factor();
    term_prime();
}


expression

decompiled_code:
char expression()
{
term();
return expr_prime();
}

canonical_decompiled_code:
char func16()
{
func14();
return func15();
}

original_code:
void expression(void)
{
    term();
    expr_prime();
}

canonical_original_code:
void expression()
{
    term();
    expr_prime();
}


statements

decompiled_code:
char statements()
{
int v0; // eax
int v1; // eax

do
{
while ( 1 )
{
expression();
LOBYTE(v1) = match(1);
if ( !v1 )
break;
advance();
LOBYTE(v0) = match(0);
if ( v0 )
return v0;
}
fprintf(_bss_start, "%d: Inserting missing semicolon\n", (unsigned int)yylineno);
LOBYTE(v0) = match(0);
}
while ( !v0 );
return v0;
}

canonical_decompiled_code:
char func17()
{
int v0; // eax
int v1; // eax

do
{
while ( 1 )
{
func16();
LOBYTE(v1) = func8(1);
if ( !v1 )
break;
func9();
LOBYTE(v0) = func8(0);
if ( v0 )
return v0;
}
fprintf(_bss_start, "%d: Inserting missing semicolon\n", (unsigned int)yylineno);
LOBYTE(v0) = func8(0);
}
while ( !v0 );
return v0;
}

original_code:
void statements(void)
{
    expression();
    if (match(SEMI)) {
        advance();
    } else {
        fprintf(stderr, "%d: Inserting missing semicolon\n", yylineno);
    }
    if (! match(EOI)) {
        statements();
    }
}

canonical_original_code:
void statements()
{
    expression();
    if (match(SEMI)) {
        advance();
    } else {
        fprintf(stderr, "%d: Inserting missing semicolon\n", yylineno);
    }
    if (! match(EOI)) {
        statements();
    }
}


help

repo: louiswins/RB-Tree

decompiled_code:
int help()
{
return printf(
"Commands:\n"
"\tC - Create empty tree\n"
"\tR - Read tree from %s\n"
"\tW - Write tree to screen in preorder format\n"
"\tI n - Insert node with key `n' into tree\n"
"\tD n - Delete node with key `n' from tree\n"
"\tP - draw Picture in %s\n"
"\tH - Help\n"
"\tS - Stop\n",
"RBinput.txt",
"RBdrawing.svg");
}

canonical_decompiled_code:
int func0()
{
return printf(
"Commands:\n"
"\tC - Create empty tree\n"
"\tR - Read tree from %s\n"
"\tW - Write tree to screen in preorder format\n"
"\tI n - Insert node with key `n' into tree\n"
"\tD n - Delete node with key `n' from tree\n"
"\tP - draw Picture in %s\n"
"\tH - Help\n"
"\tS - Stop\n",
"RBinput.txt",
"RBdrawing.svg");
}

original_code:
void help() {
 printf(
"Commands:\n"
"\tC   - Create empty tree\n"
"\tR   - Read tree from %s\n"
"\tW   - Write tree to screen in preorder format\n"
"\tI n - Insert node with key `n' into tree\n"
"\tD n - Delete node with key `n' from tree\n"
"\tP   - draw Picture in %s\n"
"\tH   - Help\n"
"\tS   - Stop\n",
"RBinput.txt", "RBdrawing.svg");
}


parse

decompiled_code:
__int64 __fastcall parse(const char **a1, __int64 a2, _DWORD *a3)
{
const char *v3; // rax
const char **v4; // rbx
unsigned int v6; // er12
const char *v7; // rdx
int v8; // edx
unsigned int v9; // ebp

v3 = *a1;
if ( !*a1 )
return 0;
v4 = a1;
v6 = 0;
do
{
v8 = *(unsigned __int8 *)v3;
v9 = v6++;
if ( v8 != 38 || v3[1] )
{
if ( v8 != 62 || v3[1] )
{
if ( v8 != 60 || v3[1] )
{
if ( v8 == 124 && !v3[1] )
{
*a3 = 4;
puts("running in Pipeline Mode");
}
}
else
{
*a3 = 3;
puts("running in Input Redirect Mode");
}
}
else
{
*a3 = 2;
puts("running in Output Redirect Mode");
}
}
else
{
*a3 = 1;
puts("running in Background Mode");
}
v7 = *v4++;
printf("Argument %d: %s\n", v9, v7);
v3 = *v4;
}
while ( *v4 );
return v6;
}

canonical_decompiled_code:
__int64 __fastcall func0(const char **a1, __int64 a2, _DWORD *a3)
{
const char *v3; // rax
const char **v4; // rbx
unsigned int v6; // er12
const char *v7; // rdx
int v8; // edx
unsigned int v9; // ebp

v3 = *a1;
if ( !*a1 )
return 0;
v4 = a1;
v6 = 0;
do
{
v8 = *(unsigned __int8 *)v3;
v9 = v6++;
if ( v8 != 38 || v3[1] )
{
if ( v8 != 62 || v3[1] )
{
if ( v8 != 60 || v3[1] )
{
if ( v8 == 124 && !v3[1] )
{
*a3 = 4;
puts("running in Pipeline Mode");
}
}
else
{
*a3 = 3;
puts("running in Input Redirect Mode");
}
}
else
{
*a3 = 2;
puts("running in Output Redirect Mode");
}
}
else
{
*a3 = 1;
puts("running in Background Mode");
}
v7 = *v4++;
printf("Argument %d: %s\n", v9, v7);
v3 = *v4;
}
while ( *v4 );
return v6;
}

original_code:
int parse(char **input, char **suppPtr, int *modePtr) {
 int i, commandArgc = 0;
 for(i = 0; input[i] != ((void *)0); i++) {
  commandArgc++;
  if (strcmp(input[i], "&") == 0) {
   *modePtr = 1;
   printf("running in Background Mode\n");
  } else if (strcmp(input[i], ">") == 0) {
   *modePtr = 2;
   printf("running in Output Redirect Mode\n");
  } else if (strcmp(input[i], "<") == 0) {
   *modePtr = 3;
   printf("running in Input Redirect Mode\n");
  } else if (strcmp(input[i], "|") == 0) {
   *modePtr = 4;
   printf("running in Pipeline Mode\n");
  }
  printf("Argument %d: %s\n", i, input[i]);
 }
 return commandArgc;
}

canonical_original_code:
int parse(char **input, char **suppPtr, int *modePtr) {
 int i; int commandArgc = 0;
 for(i = 0; input[i] != ((void *)0); i++) {
  commandArgc++;
  if (strcmp(input[i], "&") == 0) {
   *modePtr = 1;
   printf("running in Background Mode\n");
  } else if (strcmp(input[i], ">") == 0) {
   *modePtr = 2;
   printf("running in Output Redirect Mode\n");
  } else if (strcmp(input[i], "<") == 0) {
   *modePtr = 3;
   printf("running in Input Redirect Mode\n");
  } else if (strcmp(input[i], "|") == 0) {
   *modePtr = 4;
   printf("running in Pipeline Mode\n");
  }
  printf("Argument %d: %s\n", i, input[i]);
 }
 return commandArgc;
}

variable_types:
input
char **

variable_types:
suppPtr
char **

variable_types:
modePtr
int *

variable_types: i int

variable_types: commandArgc int


execute

decompiled_code:
int execute()
{
return puts("executing");
}

canonical_decompiled_code:
int func1()
{
return puts("executing");
}

original_code:
void execute(char **command, int mode, char **suppPtr) {
   printf("executing\n");
}

variable_types:
command
char **

variable_types: mode int


main

decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
const char **v3; // rax
const char **v4; // rbp
unsigned int v5; // er12
const char *v6; // rax
int v7; // [rsp+4h] [rbp-24h] BYREF
__int64 v8[4]; // [rsp+8h] [rbp-20h] BYREF

v7 = 0;
v8[0] = 0LL;
while ( 1 )
{
printf("myShell>");
v3 = (const char **)get_line("myShell>", argv);
v4 = v3;
if ( !strcmp(*v3, "exit") )
break;
v5 = parse(v3, (__int64)v8, &v7);
v6 = *v4;
if ( **v4 == 99 && v6[1] == 100 && !v6[2] )
chdir(v4[1]);
else
execute();
argv = (const char **)v5;
printf("command arg count: %d\n", v5);
}
exit(0);
}

canonical_decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
const char **v3; // rax
const char **v4; // rbp
unsigned int v5; // er12
const char *v6; // rax
int v7; // [rsp+4h] [rbp-24h] BYREF
__int64 v8[4]; // [rsp+8h] [rbp-20h] BYREF

v7 = 0;
v8[0] = 0LL;
while ( 1 )
{
printf("myShell>");
v3 = (const char **)get_line("myShell>", argv);
v4 = v3;
if ( !strcmp(*v3, "exit") )
break;
v5 = func0(v3, (__int64)v8, &v7);
v6 = *v4;
if ( **v4 == 99 && v6[1] == 100 && !v6[2] )
chdir(v4[1]);
else
func1();
argv = (const char **)v5;
printf("command arg count: %d\n", v5);
}
exit(0);
}

original_code:
int main(int argc, char *argv[]) {
 int mode = 0;
 int commandArgc;
 char *supp = ((void *)0);
 char **args;
 while(1) {
  printf("myShell>");
  args = get_line();
  if(strcmp(args[0], "exit") == 0) exit(0);
  commandArgc = parse(args, &supp, &mode);
  if(strcmp(args[0], "cd") == 0) chdir(args[1]);
  else execute(args, mode, &supp);
  printf("command arg count: %d\n", commandArgc);
 }
 return 0;
}

variable_types:
supp
char *

variable_types:
args
char **


decompiled_code:
__int64 __fastcall xfs_bmbt_get_all(__int64 a1)
{
return _xfs_bmbt_get_all(*(_QWORD *)a1, *(_QWORD *)(a1 + 8));
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1)
{
return func2(*(_QWORD *)a1, *(_QWORD *)(a1 + 8));
}

original_code:
void
xfs_bmbt_get_all(
 xfs_bmbt_rec_host_t *r,
 xfs_bmbt_irec_t *s)
{
 __xfs_bmbt_get_all(r->l0, r->l1, s);
}

canonical_original_code:
void xfs_bmbt_get_all(struct xfs_bmbt_rec_host *r, struct xfs_bmbt_irec *s)
{
 __xfs_bmbt_get_all(r->l0, r->l1, s);
}

variable_types: struct xfs_bmbt_rec_host { unsigned long long l0; } *

variable_types: struct xfs_bmbt_irec { unsigned long long br_startoff; unsigned long long br_startblock; unsigned long long br_blockcount; enum xfs_exntst_t { XFS_EXT_NORM=0, XFS_EXT_UNWRITTEN=1, XFS_EXT_DMAPI_OFFLINE=2, XFS_EXT_INVALID=3 } br_state; } *

user_defined_types: struct xfs_bmbt_irec { unsigned long long br_startoff; unsigned long long br_startblock; unsigned long long br_blockcount; enum xfs_exntst_t br_state; }


decompiled_code:
__int64 xfs_bmbt_get_blockcount()
{
__int64 v0; // rax
__int64 v1; // rdx

v0 = xfs_mask64lo(21);
return *(_QWORD *)(v1 + 8) & v0;
}

original_code:
xfs_filblks_t
xfs_bmbt_get_blockcount(
 xfs_bmbt_rec_host_t *r)
{
 return (xfs_filblks_t)(r->l1 & xfs_mask64lo(21));
}

canonical_original_code:
unsigned long long xfs_bmbt_get_blockcount(struct xfs_bmbt_rec_host *r)
{
 return (xfs_filblks_t)(r->l1 & xfs_mask64lo(21));
}

return_type: unsigned long long

user_defined_types: struct xfs_bmbt_rec_host { unsigned long long l0; }


decompiled_code:
__int64 xfs_bmbt_get_startblock()
{
__int64 v0; // rax
_QWORD *v1; // rdx

v0 = xfs_mask64lo(9);
return (v1[1] >> 21) | ((*v1 & v0) << 43);
}

original_code:
xfs_fsblock_t
xfs_bmbt_get_startblock(
 xfs_bmbt_rec_host_t *r)
{
 return (((xfs_fsblock_t)r->l0 & xfs_mask64lo(9)) << 43) |
        (((xfs_fsblock_t)r->l1) >> 21);
}

canonical_original_code:
unsigned long long xfs_bmbt_get_startblock(struct xfs_bmbt_rec_host *r)
{
 return (((unsigned long long)r->l0 & xfs_mask64lo(9)) << 43) |
        (((unsigned long long)r->l1) >> 21);
}


decompiled_code:
unsigned __int64 xfs_bmbt_get_startoff()
{
__int64 v0; // rax
_QWORD *v1; // rdx

v0 = xfs_mask64lo(63);
return (*v1 & (unsigned __int64)v0) >> 9;
}

canonical_decompiled_code:
unsigned __int64 func7()
{
__int64 v0; // rax
_QWORD *v1; // rdx

v0 = func1(63);
return (*v1 & (unsigned __int64)v0) >> 9;
}

original_code:
xfs_fileoff_t
xfs_bmbt_get_startoff(
 xfs_bmbt_rec_host_t *r)
{
 return ((xfs_fileoff_t)r->l0 &
   xfs_mask64lo(64 - 1)) >> 9;
}

canonical_original_code:
unsigned long long xfs_bmbt_get_startoff(struct xfs_bmbt_rec_host *r)
{
 return ((unsigned long long)r->l0 &
   xfs_mask64lo(64 - 1)) >> 9;
}


decompiled_code:
__int64 __fastcall xfs_bmbt_get_state(_QWORD *a1)
{
return xfs_extent_state_constprop_0(*a1 >> 63);
}

canonical_decompiled_code:
__int64 __fastcall func8(_QWORD *a1)
{
return func3(*a1 >> 63);
}

original_code:
xfs_exntst_t
xfs_bmbt_get_state(
 xfs_bmbt_rec_host_t *r)
{
 int ext_flag;
 ext_flag = (int)((r->l0) >> (64 - 1));
 return xfs_extent_state(xfs_bmbt_get_blockcount(r),
    ext_flag);
}

canonical_original_code:
enum xfs_exntst_t xfs_bmbt_get_state(struct xfs_bmbt_rec_host *r)
{
 int ext_flag;
 ext_flag = (int)((r->l0) >> (64 - 1));
 return xfs_extent_state(xfs_bmbt_get_blockcount(r),
    ext_flag);
}

return_type: enum xfs_exntst_t { XFS_EXT_NORM=0, XFS_EXT_UNWRITTEN=1, XFS_EXT_DMAPI_OFFLINE=2, XFS_EXT_INVALID=3 }


decompiled_code:
unsigned __int64 xfs_bmbt_disk_get_blockcount()
{
__int64 v0; // rax
unsigned __int64 v1; // rdx

v0 = xfs_mask64lo(21);
return _byteswap_uint64(v1) & v0;
}

canonical_decompiled_code:
unsigned __int64 func9()
{
__int64 v0; // rax
unsigned __int64 v1; // rdx

v0 = func1(21);
return _byteswap_uint64(v1) & v0;
}

variable_types: struct xfs_bmbt_rec { unsigned long long l0; } *


decompiled_code:
unsigned __int64 xfs_bmbt_disk_get_startoff()
{
__int64 v0; // rax
unsigned __int64 v1; // rdx

v0 = xfs_mask64lo(63);
return (_byteswap_uint64(v1) & v0) >> 9;
}

canonical_decompiled_code:
unsigned __int64 func10()
{
__int64 v0; // rax
unsigned __int64 v1; // rdx

v0 = func1(63);
return (_byteswap_uint64(v1) & v0) >> 9;
}

user_defined_types: struct xfs_bmbt_rec { unsigned long long l0; }


decompiled_code:
__int64 __fastcall xfs_bmbt_disk_set_allf(_QWORD *a1, __int64 a2, unsigned __int64 a3, __int64 a4, int a5)
{
__int64 v5; // rax
__int64 v6; // r10
__int64 result; // rax
__int64 v8; // rdx
__int64 v9; // r9

*a1 = _byteswap_uint64(((unsigned __int64)(a5 != 0) << 63) | (a3 >> 43) | (a2 << 9));
v5 = xfs_mask64lo(21);
result = v6 & v5;
*(_QWORD *)(v9 + 8) = _byteswap_uint64(result | v8);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func13(_QWORD *a1, __int64 a2, unsigned __int64 a3, __int64 a4, int a5)
{
__int64 v5; // rax
__int64 v6; // r10
__int64 result; // rax
__int64 v8; // rdx
__int64 v9; // r9

*a1 = _byteswap_uint64(((unsigned __int64)(a5 != 0) << 63) | (a3 >> 43) | (a2 << 9));
v5 = func1(21);
result = v6 & v5;
*(_QWORD *)(v9 + 8) = _byteswap_uint64(result | v8);
return result;
}

original_code:
void
xfs_bmbt_disk_set_allf(
 xfs_bmbt_rec_t *r,
 xfs_fileoff_t startoff,
 xfs_fsblock_t startblock,
 xfs_filblks_t blockcount,
 xfs_exntst_t state)
{
 int extent_flag = (state == XFS_EXT_NORM) ? 0 : 1;
 (state == XFS_EXT_NORM || state == XFS_EXT_UNWRITTEN);
 ((startoff & xfs_mask64hi(64-54)) == 0);
 ((blockcount & xfs_mask64hi(64-21)) == 0);
 ((startblock & xfs_mask64hi(64-52)) == 0);
 r->l0 = ((__u64)( (((__u64)(((xfs_bmbt_rec_base_t)extent_flag << 63) | ((xfs_bmbt_rec_base_t)startoff << 9) | ((xfs_bmbt_rec_base_t)startblock >> 43)) & ( __u64)0x00000000000000ffUL) << 56) | (((__u64)(((xfs_bmbt_rec_base_t)extent_flag << 63) | ((xfs_bmbt_rec_base_t)startoff << 9) | ((xfs_bmbt_rec_base_t)startblock >> 43)) & ( __u64)0x000000000000ff00UL) << 40) | (((__u64)(((xfs_bmbt_rec_base_t)extent_flag << 63) | ((xfs_bmbt_rec_base_t)startoff << 9) | ((xfs_bmbt_rec_base_t)startblock >> 43)) & ( __u64)0x0000000000ff0000UL) << 24) | (((__u64)(((xfs_bmbt_rec_base_t)extent_flag << 63) | ((xfs_bmbt_rec_base_t)startoff << 9) | ((xfs_bmbt_rec_base_t)startblock >> 43)) & ( __u64)0x00000000ff000000UL) << 8) | (((__u64)(((xfs_bmbt_rec_base_t)extent_flag << 63) | ((xfs_bmbt_rec_base_t)startoff << 9) | ((xfs_bmbt_rec_base_t)startblock >> 43)) & ( __u64)0x000000ff00000000UL) >> 8) | (((__u64)(((xfs_bmbt_rec_base_t)extent_flag << 63) | ((xfs_bmbt_rec_base_t)startoff << 9) | ((xfs_bmbt_rec_base_t)startblock >> 43)) & ( __u64)0x0000ff0000000000UL) >> 24) | (((__u64)(((xfs_bmbt_rec_base_t)extent_flag << 63) | ((xfs_bmbt_rec_base_t)startoff << 9) | ((xfs_bmbt_rec_base_t)startblock >> 43)) & ( __u64)0x00ff000000000000UL) >> 40) | (((__u64)(((xfs_bmbt_rec_base_t)extent_flag << 63) | ((xfs_bmbt_rec_base_t)startoff << 9) | ((xfs_bmbt_rec_base_t)startblock >> 43)) & ( __u64)0xff00000000000000UL) >> 56)));
 r->l1 = ((__u64)( (((__u64)(((xfs_bmbt_rec_base_t)startblock << 21) | ((xfs_bmbt_rec_base_t)blockcount & (xfs_bmbt_rec_base_t)xfs_mask64lo(21))) & ( __u64)0x00000000000000ffUL) << 56) | (((__u64)(((xfs_bmbt_rec_base_t)startblock << 21) | ((xfs_bmbt_rec_base_t)blockcount & (xfs_bmbt_rec_base_t)xfs_mask64lo(21))) & ( __u64)0x000000000000ff00UL) << 40) | (((__u64)(((xfs_bmbt_rec_base_t)startblock << 21) | ((xfs_bmbt_rec_base_t)blockcount & (xfs_bmbt_rec_base_t)xfs_mask64lo(21))) & ( __u64)0x0000000000ff0000UL) << 24) | (((__u64)(((xfs_bmbt_rec_base_t)startblock << 21) | ((xfs_bmbt_rec_base_t)blockcount & (xfs_bmbt_rec_base_t)xfs_mask64lo(21))) & ( __u64)0x00000000ff000000UL) << 8) | (((__u64)(((xfs_bmbt_rec_base_t)startblock << 21) | ((xfs_bmbt_rec_base_t)blockcount & (xfs_bmbt_rec_base_t)xfs_mask64lo(21))) & ( __u64)0x000000ff00000000UL) >> 8) | (((__u64)(((xfs_bmbt_rec_base_t)startblock << 21) | ((xfs_bmbt_rec_base_t)blockcount & (xfs_bmbt_rec_base_t)xfs_mask64lo(21))) & ( __u64)0x0000ff0000000000UL) >> 24) | (((__u64)(((xfs_bmbt_rec_base_t)startblock << 21) | ((xfs_bmbt_rec_base_t)blockcount & (xfs_bmbt_rec_base_t)xfs_mask64lo(21))) & ( __u64)0x00ff000000000000UL) >> 40) | (((__u64)(((xfs_bmbt_rec_base_t)startblock << 21) | ((xfs_bmbt_rec_base_t)blockcount & (xfs_bmbt_rec_base_t)xfs_mask64lo(21))) & ( __u64)0xff00000000000000UL) >> 56)));
}

canonical_original_code:
void xfs_bmbt_disk_set_allf(struct xfs_bmbt_rec *r, unsigned long long startoff, unsigned long long startblock, unsigned long long blockcount, enum xfs_exntst_t state)
{
 int extent_flag = (state == XFS_EXT_NORM) ? 0 : 1;
 (state == XFS_EXT_NORM || state == XFS_EXT_UNWRITTEN);
 ((startoff & xfs_mask64hi(64-54)) == 0);
 ((blockcount & xfs_mask64hi(64-21)) == 0);
 ((startblock & xfs_mask64hi(64-52)) == 0);
 r->l0 = ((__u64)( (((__u64)(((unsigned long long)extent_flag << 63) | ((unsigned long long)startoff << 9) | ((unsigned long long)startblock >> 43)) & ( unsigned long long)0x00000000000000ffUL) << 56) | (((__u64)(((unsigned long long)extent_flag << 63) | ((unsigned long long)startoff << 9) | ((unsigned long long)startblock >> 43)) & ( unsigned long long)0x000000000000ff00UL) << 40) | (((__u64)(((unsigned long long)extent_flag << 63) | ((unsigned long long)startoff << 9) | ((unsigned long long)startblock >> 43)) & ( unsigned long long)0x0000000000ff0000UL) << 24) | (((__u64)(((unsigned long long)extent_flag << 63) | ((unsigned long long)startoff << 9) | ((unsigned long long)startblock >> 43)) & ( unsigned long long)0x00000000ff000000UL) << 8) | (((__u64)(((unsigned long long)extent_flag << 63) | ((unsigned long long)startoff << 9) | ((unsigned long long)startblock >> 43)) & ( unsigned long long)0x000000ff00000000UL) >> 8) | (((__u64)(((unsigned long long)extent_flag << 63) | ((unsigned long long)startoff << 9) | ((unsigned long long)startblock >> 43)) & ( unsigned long long)0x0000ff0000000000UL) >> 24) | (((__u64)(((unsigned long long)extent_flag << 63) | ((unsigned long long)startoff << 9) | ((unsigned long long)startblock >> 43)) & ( unsigned long long)0x00ff000000000000UL) >> 40) | (((__u64)(((unsigned long long)extent_flag << 63) | ((unsigned long long)startoff << 9) | ((unsigned long long)startblock >> 43)) & ( unsigned long long)0xff00000000000000UL) >> 56)));
 r->l1 = ((__u64)( (((__u64)(((unsigned long long)startblock << 21) | ((unsigned long long)blockcount & (unsigned long long)xfs_mask64lo(21))) & ( unsigned long long)0x00000000000000ffUL) << 56) | (((__u64)(((unsigned long long)startblock << 21) | ((unsigned long long)blockcount & (unsigned long long)xfs_mask64lo(21))) & ( unsigned long long)0x000000000000ff00UL) << 40) | (((__u64)(((unsigned long long)startblock << 21) | ((unsigned long long)blockcount & (unsigned long long)xfs_mask64lo(21))) & ( unsigned long long)0x0000000000ff0000UL) << 24) | (((__u64)(((unsigned long long)startblock << 21) | ((unsigned long long)blockcount & (unsigned long long)xfs_mask64lo(21))) & ( unsigned long long)0x00000000ff000000UL) << 8) | (((__u64)(((unsigned long long)startblock << 21) | ((unsigned long long)blockcount & (unsigned long long)xfs_mask64lo(21))) & ( unsigned long long)0x000000ff00000000UL) >> 8) | (((__u64)(((unsigned long long)startblock << 21) | ((unsigned long long)blockcount & (unsigned long long)xfs_mask64lo(21))) & ( unsigned long long)0x0000ff0000000000UL) >> 24) | (((__u64)(((unsigned long long)startblock << 21) | ((unsigned long long)blockcount & (unsigned long long)xfs_mask64lo(21))) & ( unsigned long long)0x00ff000000000000UL) >> 40) | (((__u64)(((unsigned long long)startblock << 21) | ((unsigned long long)blockcount & (unsigned long long)xfs_mask64lo(21))) & ( unsigned long long)0xff00000000000000UL) >> 56)));
}

variable_types:
startoff
unsigned long long

variable_types:
startblock
unsigned long long

variable_types:
blockcount
unsigned long long

variable_types: enum xfs_exntst_t { XFS_EXT_NORM=0, XFS_EXT_UNWRITTEN=1, XFS_EXT_DMAPI_OFFLINE=2, XFS_EXT_INVALID=3 }


decompiled_code:
__int64 xfs_bmbt_set_blockcount()
{
__int64 v0; // rax
__int64 v1; // rdx
__int64 v2; // rsi
__int64 v3; // rax
__int64 v4; // r8
__int64 result; // rax
__int64 v6; // rdx

v0 = xfs_mask64hi(43);
v2 = *(_QWORD *)(v1 + 8) & v0;
v3 = xfs_mask64lo(21);
result = v2 | v4 & v3;
*(_QWORD *)(v6 + 8) = result;
return result;
}

original_code:
void
xfs_bmbt_set_blockcount(
 xfs_bmbt_rec_host_t *r,
 xfs_filblks_t v)
{
 ((v & xfs_mask64hi(43)) == 0);
 r->l1 = (r->l1 & (xfs_bmbt_rec_base_t)xfs_mask64hi(43)) |
    (xfs_bmbt_rec_base_t)(v & xfs_mask64lo(21));
}

canonical_original_code:
void xfs_bmbt_set_blockcount(struct xfs_bmbt_rec_host *r, unsigned long long v)
{
 ((v & xfs_mask64hi(43)) == 0);
 r->l1 = (r->l1 & (unsigned long long)xfs_mask64hi(43)) |
    (xfs_bmbt_rec_base_t)(v & xfs_mask64lo(21));
}

variable_types:
v
unsigned long long