memcmp

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

result = 0LL;
if ( a3 )
{
do
{
if ( *(_BYTE *)(a1 + result) != *(_BYTE *)(a2 + result) )
return 1LL;
++result;
}
while ( a3 != result );
result = 0LL;
}
return result;
}

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

result = 0LL;
if ( a3 )
{
do
{
if ( *(_BYTE *)(a1 + result) != *(_BYTE *)(a2 + result) )
return 1LL;
++result;
}
while ( a3 != result );
result = 0LL;
}
return result;
}

original_code:
uint64_t memcmp(const void* _m1, const void* _m2, uint64_t bytes)
{
        const char* m1 = _m1, * m2 = _m2;
        for(uint64_t i = 0; i < bytes; i++)
                if(m1[i] != m2[i]) {
                    return 1;
                }
        return 0;
}

canonical_original_code:
unsigned long long memcmp(void *_m1, void *_m2, unsigned long long bytes)
{
        char *m1 = _m1; char *m2 = _m2;
        for(unsigned long long i = 0; i < bytes; i++)
                if(m1[i] != m2[i]) {
                    return 1;
                }
        return 0;
}

variable_types:
bytes
unsigned long long

return_type: unsigned long long


strcmp

decompiled_code:
__int64 __fastcall strcmp(char *a1, _BYTE *a2)
{
char v2; // dl
__int64 v3; // rax

v2 = *a1;
if ( *a1 != *a2 )
return 1LL;
v3 = 0LL;
while ( v2 )
{
v2 = a1[++v3];
if ( v2 != a2[v3] )
return 1LL;
}
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func11(char *a1, _BYTE *a2)
{
char v2; // dl
__int64 v3; // rax

v2 = *a1;
if ( *a1 != *a2 )
return 1LL;
v3 = 0LL;
while ( v2 )
{
v2 = a1[++v3];
if ( v2 != a2[v3] )
return 1LL;
}
return 0LL;
}

original_code:
uint64_t strcmp(const char* str1, const char* str2)
{
        uint64_t i;
        for(i = 0; str1[i] == str2[i]; i++)
                if(str1[i] == '\0') {
                    return 0;
                }
        return 1;
}

canonical_original_code:
unsigned long long strcmp(char *str1, char *str2)
{
        unsigned long long i;
        for(i = 0; str1[i] == str2[i]; i++)
                if(str1[i] == '\0') {
                    return 0;
                }
        return 1;
}

variable_types:
i
unsigned long long


strncpy

decompiled_code:
__int64 __fastcall strncpy(_BYTE *a1, unsigned __int8 *a2, __int64 a3)
{
__int64 result; // rax
_BYTE *v4; // rdx

result = a3;
v4 = &a1[a3];
if ( result )
{
while ( 1 )
{
result = *a2;
if ( !(_BYTE)result )
break;
*a1++ = result;
++a2;
if ( a1 == v4 )
return result;
}
*a1 = 0;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func12(_BYTE *a1, unsigned __int8 *a2, __int64 a3)
{
__int64 result; // rax
_BYTE *v4; // rdx

result = a3;
v4 = &a1[a3];
if ( result )
{
while ( 1 )
{
result = *a2;
if ( !(_BYTE)result )
break;
*a1++ = result;
++a2;
if ( a1 == v4 )
return result;
}
*a1 = 0;
}
return result;
}

original_code:
void strncpy(char* dst, const char* src, uint64_t len)
{
        for(uint64_t i = 0; i < len; i++) {
                if(src[i] == '\0') {
                        dst[i] = '\0';
                        return;
                }
                dst[i] = src[i];
        }
}

canonical_original_code:
void strncpy(char *dst, char *src, unsigned long long len)
{
        for(unsigned long long i = 0; i < len; i++) {
                if(src[i] == '\0') {
                        dst[i] = '\0';
                        return;
                }
                dst[i] = src[i];
        }
}

variable_types:
dst
char *

variable_types:
src
char *

variable_types:
len
unsigned long long

return_type: void


abs

decompiled_code:
__m128d __fastcall abs(__m128d result)
{
if ( result.m128d_f64[0] < 0.0 )
result = _mm_xor_pd(result, (__m128d)LC1);
return result;
}

canonical_decompiled_code:
__m128d __fastcall func0(__m128d result)
{
if ( result.m128d_f64[0] < 0.0 )
result = _mm_xor_pd(result, (__m128d)LC1);
return result;
}

original_code:
static double abs(double a)
{
    return a < 0.0 ? -a : a;
}

variable_types: a double

return_type: double


decompiled_code:
__int64 sort_monocore()
{
return heapsort(367001600LL, MEMORY[0x200600]);
}

canonical_original_code:
void sort_monocore()
{
    heapsort(
        (unsigned int *) (0x1e00000 + 32 * 0xa00000),
        *((unsigned int *) 0x200600)
    );
}


wait

decompiled_code:
unsigned __int64 wait()
{
unsigned __int64 v0; // rsi
unsigned __int64 result; // rax

_mm_mfence();
v0 = __rdtsc();
start = v0;
do
{
_mm_mfence();
__rdtsc();
_mm_mfence();
__rdtsc();
_mm_mfence();
result = __rdtsc();
}
while ( result - v0 <= 0x13D18C1FFLL );
stop = result;
return result;
}

canonical_decompiled_code:
unsigned __int64 func2()
{
unsigned __int64 v0; // rsi
unsigned __int64 result; // rax

_mm_mfence();
v0 = __rdtsc();
start = v0;
do
{
_mm_mfence();
__rdtsc();
_mm_mfence();
__rdtsc();
_mm_mfence();
result = __rdtsc();
}
while ( result - v0 <= 0x13D18C1FFLL );
stop = result;
return result;
}

original_code:
void wait()
{
    uint64_t limit = 5320000000;
    { unsigned int start_high, start_low; __asm__ __volatile__ ( "mfence\n\t" "rdtsc\n\t" "mov %%edx, %0\n\t" "mov %%eax, %1\n\t" : "=r" (start_high), "=r" (start_low) : : "%eax" ); start = (((unsigned long long int) start_high) << 32) | (unsigned long long int) (start_low); };
    do {
        { { unsigned int end_high, end_low; __asm__ __volatile__ ( "mfence\n\t" "rdtsc\n\t" "mov %%edx, %0\n\t" "mov %%eax, %1\n\t" : "=r" (end_high), "=r" (end_low) : : "%eax" ); stop = (((unsigned long long int) end_high) << 32) | (unsigned long long int) (end_low); } { unsigned int end_high, end_low; __asm__ __volatile__ ( "mfence\n\t" "rdtsc\n\t" "mov %%edx, %0\n\t" "mov %%eax, %1\n\t" : "=r" (end_high), "=r" (end_low) : : "%eax" ); stop = (((unsigned long long int) end_high) << 32) | (unsigned long long int) (end_low); } { unsigned int end_high, end_low; __asm__ __volatile__ ( "mfence\n\t" "rdtsc\n\t" "mov %%edx, %0\n\t" "mov %%eax, %1\n\t" : "=r" (end_high), "=r" (end_low) : : "%eax" ); stop = (((unsigned long long int) end_high) << 32) | (unsigned long long int) (end_low); } };
    } while ((stop - start) < limit);
    return;
}

canonical_original_code:
void wait()
{
    unsigned long limit = 5320000000;
    { unsigned int start_high; unsigned int start_low; __asm__ __volatile__ ( "mfence\n\t" "rdtsc\n\t" "mov %%edx, %0\n\t" "mov %%eax, %1\n\t" : "=r" (start_high), "=r" (start_low) : : "%eax" ); start = (((unsigned long long) start_high) << 32) | (unsigned long long) (start_low); };
    do {
        { { unsigned int end_high; unsigned int end_low; __asm__ __volatile__ ( "mfence\n\t" "rdtsc\n\t" "mov %%edx, %0\n\t" "mov %%eax, %1\n\t" : "=r" (end_high), "=r" (end_low) : : "%eax" ); stop = (((unsigned long long) end_high) << 32) | (unsigned long long) (end_low); } { unsigned int end_high; unsigned int end_low; __asm__ __volatile__ ( "mfence\n\t" "rdtsc\n\t" "mov %%edx, %0\n\t" "mov %%eax, %1\n\t" : "=r" (end_high), "=r" (end_low) : : "%eax" ); stop = (((unsigned long long) end_high) << 32) | (unsigned long long) (end_low); } { unsigned int end_high; unsigned int end_low; __asm__ __volatile__ ( "mfence\n\t" "rdtsc\n\t" "mov %%edx, %0\n\t" "mov %%eax, %1\n\t" : "=r" (end_high), "=r" (end_low) : : "%eax" ); stop = (((unsigned long long) end_high) << 32) | (unsigned long long) (end_low); } };
    } while ((stop - start) < limit);
    return;
}

variable_types:
limit
unsigned long


rand

canonical_original_code:
unsigned int rand()
{
    unsigned long seed = *((uint64_t *) 0x200500);
    seed = seed * 1103515245 + 12345;
    *((unsigned long *) 0x200500) = seed;
    return (unsigned int) (seed / 65536) % 32768;
}

variable_types:
seed
unsigned long

return_type: unsigned int


decompiled_code:
__int64 verfiy_sort()
{
__int64 v0; // rax
unsigned int v1; // edx

if ( MEMORY[0x200600] <= 1u )
return 1LL;
v0 = 367001600LL;
while ( 1 )
{
v1 = *(_DWORD *)v0;
v0 += 4LL;
if ( v1 > *(_DWORD *)v0 )
break;
if ( v0 == 4LL * (unsigned int)(MEMORY[0x200600] - 2) + 367001604 )
return 1LL;
}
return 0LL;
}

canonical_decompiled_code:
__int64 func5()
{
__int64 v0; // rax
unsigned int v1; // edx

if ( MEMORY[0x200600] <= 1u )
return 1LL;
v0 = 367001600LL;
while ( 1 )
{
v1 = *(_DWORD *)v0;
v0 += 4LL;
if ( v1 > *(_DWORD *)v0 )
break;
if ( v0 == 4LL * (unsigned int)(MEMORY[0x200600] - 2) + 367001604 )
return 1LL;
}
return 0LL;
}

original_code:
_Bool verfiy_sort(uint32_t len)
{
    for (uint32_t i = 1; i < len; ++i) {
        if (array[i - 1] > array[i]) {
            return 0;
        }
    }
    return 1;
}

canonical_original_code:
_Bool verfiy_sort(unsigned int len)
{
    for (unsigned int i = 1; i < len; ++i) {
        if (array[i - 1] > array[i]) {
            return 0;
        }
    }
    return 1;
}

variable_types:
len
unsigned int

variable_types:
i
unsigned int


original_code:
void clean_array(uint32_t len)
{
    uint32_t *array = (uint32_t *) (0x1e00000 + 32 * 0xa00000);
    for (uint32_t i = 0; i < len; ++i) {
        array[i] = 0;
    }
}

canonical_original_code:
void clean_array(unsigned int len)
{
    unsigned int *array = (uint32_t *) (0x1e00000 + 32 * 0xa00000);
    for (unsigned int i = 0; i < len; ++i) {
        array[i] = 0;
    }
}

variable_types:
array
unsigned int *


decompiled_code:
__int64 __fastcall test_suite_sort(void (*a1)(void), unsigned __int8 a2, unsigned __int8 a3, __int64 a4)
{
unsigned int v4; // er12
unsigned __int8 v5; // bl
__int64 i; // rax
int v7; // er13
__int64 v8; // r14
__int64 v9; // rsi
__int64 v10; // rsi
double v11; // xmm0_8
unsigned __int64 v12; // rax
__int64 v13; // rcx
unsigned __int64 v14; // rsi
unsigned __int8 v15; // r14
__int64 j; // rbp
unsigned __int64 v17; // rdi
double v18; // xmm0_8
__int64 v19; // rsi

v4 = a2;
v5 = a3 + 1;
print_string(a4, a3, a2);
for ( i = 2100736LL; i != 2100920; i += 8LL )
*(_QWORD *)i = 0LL;
v7 = 5;
do
{
MEMORY[0x200600] = 2;
v8 = 2100736LL;
v9 = 2LL;
do
{
generate_global_array(13214LL, v9);
_mm_mfence();
start = __rdtsc();
a1();
_mm_mfence();
__rdtsc();
_mm_mfence();
v12 = __rdtsc();
v13 = (unsigned int)v12;
_mm_mfence();
v14 = __rdtsc();
stop = v14;
if ( (unsigned int)verfiy_sort(13214LL, v14, (unsigned int)v14, v13) )
{
v10 = v14 - start;
if ( v10 < 0 )
v11 = (double)(int)(v10 & 1 | ((unsigned __int64)v10 >> 1))
+ (double)(int)(v10 & 1 | ((unsigned __int64)v10 >> 1));
else
v11 = (double)(int)v10;
*(double *)v8 = v11 + *(double *)v8;
}
else
{
print_string("bad sort :(", v5++, v4);
}
v8 += 8LL;
v9 = (unsigned int)(2 * MEMORY[0x200600]);
MEMORY[0x200600] = v9;
}
while ( (unsigned int)v9 <= 0x7FFFFF );
--v7;
}
while ( v7 );
v15 = v5;
for ( j = 2100736LL; j != 2100920; j += 8LL )
{
v18 = *(double *)j / 5.0;
v19 = v15;
if ( v18 < 9.223372036854776e18 )
v17 = (unsigned int)(int)v18;
else
v17 = (unsigned int)(int)(v18 - 9.223372036854776e18) ^ 0x8000000000000000LL;
++v15;
print_number_u64(v17, v19, v4);
}
return print_string("Done! :D", (unsigned __int8)(v5 + 23), v4);
}

original_code:
void test_suite_sort(sort_test function, uint8_t col, uint8_t line, const char *header)
{
    uint32_t *len = (uint32_t *) 0x200600;
    print_string(header, line++, col);
    int iter;
    double *run_measures = (double *) 0x200e00;
    for (int i = 0; i < 23; ++i) {
        run_measures[i] = 0;
    }
    for (int run = 0; run < 5; ++run) {
        for (iter = 0, *len = 2; *len < (8*1024*1024); *len <<= 1, iter++) {
            uint32_t seed = 13214;
            generate_global_array(seed, *len);
            { unsigned int start_high, start_low; __asm__ __volatile__ ( "mfence\n\t" "rdtsc\n\t" "mov %%edx, %0\n\t" "mov %%eax, %1\n\t" : "=r" (start_high), "=r" (start_low) : : "%eax" ); start = (((unsigned long long int) start_high) << 32) | (unsigned long long int) (start_low); };
            function();
            { { unsigned int end_high, end_low; __asm__ __volatile__ ( "mfence\n\t" "rdtsc\n\t" "mov %%edx, %0\n\t" "mov %%eax, %1\n\t" : "=r" (end_high), "=r" (end_low) : : "%eax" ); stop = (((unsigned long long int) end_high) << 32) | (unsigned long long int) (end_low); } { unsigned int end_high, end_low; __asm__ __volatile__ ( "mfence\n\t" "rdtsc\n\t" "mov %%edx, %0\n\t" "mov %%eax, %1\n\t" : "=r" (end_high), "=r" (end_low) : : "%eax" ); stop = (((unsigned long long int) end_high) << 32) | (unsigned long long int) (end_low); } { unsigned int end_high, end_low; __asm__ __volatile__ ( "mfence\n\t" "rdtsc\n\t" "mov %%edx, %0\n\t" "mov %%eax, %1\n\t" : "=r" (end_high), "=r" (end_low) : : "%eax" ); stop = (((unsigned long long int) end_high) << 32) | (unsigned long long int) (end_low); } };
            if (verfiy_sort()) {
                run_measures[iter] += stop - start;
            } else {
                print_string("bad sort :(", line++, col);
            }
        }
    }
    for (int i = 0; i < 23; i++, line++) {
        uint64_t res = run_measures[i] / ((double) 5);
        print_number_u64(res, line, col);
    }
    print_string("Done! :D", line, col);
}

canonical_original_code:
void test_suite_sort(void (*function)(), unsigned char col, unsigned char line, char *header)
{
    unsigned int *len = (uint32_t *) 0x200600;
    print_string(header, line++, col);
    int iter;
    double *run_measures = (double *) 0x200e00;
    for (int i = 0; i < 23; ++i) {
        run_measures[i] = 0;
    }
    for (int run = 0; run < 5; ++run) {
        for (iter = 0, *len = 2; *len < (8*1024*1024); *len <<= 1, iter++) {
            unsigned int seed = 13214;
            generate_global_array(seed, *len);
            { unsigned int start_high; unsigned int start_low; __asm__ __volatile__ ( "mfence\n\t" "rdtsc\n\t" "mov %%edx, %0\n\t" "mov %%eax, %1\n\t" : "=r" (start_high), "=r" (start_low) : : "%eax" ); start = (((unsigned long long) start_high) << 32) | (unsigned long long) (start_low); };
            function();
            { { unsigned int end_high; unsigned int end_low; __asm__ __volatile__ ( "mfence\n\t" "rdtsc\n\t" "mov %%edx, %0\n\t" "mov %%eax, %1\n\t" : "=r" (end_high), "=r" (end_low) : : "%eax" ); stop = (((unsigned long long) end_high) << 32) | (unsigned long long) (end_low); } { unsigned int end_high; unsigned int end_low; __asm__ __volatile__ ( "mfence\n\t" "rdtsc\n\t" "mov %%edx, %0\n\t" "mov %%eax, %1\n\t" : "=r" (end_high), "=r" (end_low) : : "%eax" ); stop = (((unsigned long long) end_high) << 32) | (unsigned long long) (end_low); } { unsigned int end_high; unsigned int end_low; __asm__ __volatile__ ( "mfence\n\t" "rdtsc\n\t" "mov %%edx, %0\n\t" "mov %%eax, %1\n\t" : "=r" (end_high), "=r" (end_low) : : "%eax" ); stop = (((unsigned long long) end_high) << 32) | (unsigned long long) (end_low); } };
            if (verfiy_sort()) {
                run_measures[iter] += stop - start;
            } else {
                print_string("bad sort :(", line++, col);
            }
        }
    }
    for (int i = 0; i < 23; i++, line++) {
        unsigned long res = run_measures[i] / ((double) 5);
        print_number_u64(res, line, col);
    }
    print_string("Done! :D", line, col);
}

variable_types:
function
void (*)()

variable_types:
col
unsigned char

variable_types:
line
unsigned char

variable_types:
header
char *

variable_types:
len
unsigned int *

variable_types: iter int

variable_types: i int

variable_types: run int

variable_types:
seed
unsigned int

variable_types:
res
unsigned long


decompiled_code:
__int64 test_1_core()
{
clean_array(0x800000);
clear_screen();
return test_suite_sort((void (*)(void))sort_monocore, 0, 0, (__int64)"Test 1 core");
}

canonical_decompiled_code:
__int64 func8()
{
func6(0x800000);
clear_screen();
return func7((void (*)(void))sort_monocore, 0, 0, (__int64)"Test 1 core");
}

original_code:
void test_1_core()
{
    clean_array((8*1024*1024));
    clear_screen();
    test_suite_sort(sort_monocore, 0, 0, "Test 1 core");
}


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

result = test_suite_sort((void (*)(void))&sort_bsp, 0x1Eu, 0, (__int64)"Test 2 cores");
MEMORY[0x200200] = 1;
return result;
}

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

result = func7((void (*)(void))&sort_bsp, 0x1Eu, 0, (__int64)"Test 2 cores");
MEMORY[0x200200] = 1;
return result;
}

original_code:
void test_2_cores()
{
    test_suite_sort(sort_bsp, 30, 0, "Test 2 cores");
    *((uint8_t *) 0x200200) = 1;
}

canonical_original_code:
void test_2_cores()
{
    test_suite_sort(sort_bsp, 30, 0, "Test 2 cores");
    *((unsigned char *) 0x200200) = 1;
}


decompiled_code:
__int64 test_ipi_cores()
{
return test_suite_sort((void (*)(void))&sort_bsp_ipi, 0x3Cu, 0, (__int64)"Test Dual Ipis");
}

canonical_decompiled_code:
__int64 func10()
{
return func7((void (*)(void))&sort_bsp_ipi, 0x3Cu, 0, (__int64)"Test Dual Ipis");
}

original_code:
void test_ipi_cores()
{
    test_suite_sort(sort_bsp_ipi, 60, 0, "Test Dual Ipis");
}


decompiled_code:
__int64 test_sync_ipi_cores()
{
int v0; // ebx
__int64 v1; // rsi
__int64 v2; // rsi
unsigned __int8 v3; // r12
__int64 v4; // rdx
__int64 v5; // rcx
int *v6; // rbp
unsigned int v7; // ebx
__int64 v8; // rdx
__int64 result; // rax
int v10; // [rsp+Ah] [rbp-1Eh] BYREF
__int16 v11; // [rsp+Eh] [rbp-1Ah]
char v12; // [rsp+10h] [rbp-18h] BYREF

v0 = 1;
wait();
wait();
clear_screen();
v11 = 16692;
v10 = 656018688;
print_string("Test Dual Ipis", 0LL, 0LL);
print_string("Sync", 1LL, 13LL);
print_string("Sync", 1LL, 39LL);
print_string("Sync", 1LL, 65LL);
v1 = 2LL;
MEMORY[0x200600] = 2;
do
{
v3 = v0 + 1;
generate_global_array(13214LL, v1);
measure_sync_ipis();
if ( (unsigned int)verfiy_sort(13214LL, v1, v4, v5) )
{
print_number_u64(MEMORY[0x200D08], (unsigned __int8)++v0, BYTE1(v10));
print_number_u64(MEMORY[0x200D18], v3, HIBYTE(v10));
print_number_u64(MEMORY[0x200D28], v3, HIBYTE(v11));
}
else
{
v2 = (unsigned __int8)v0;
v0 += 2;
print_string("bad_sort :(", v2, BYTE1(v10));
print_string("bad_sort :(", v3, HIBYTE(v10));
}
v1 = (unsigned int)(2 * MEMORY[0x200600]);
MEMORY[0x200600] = v1;
}
while ( (unsigned int)v1 <= 0x7FFFFF );
v6 = &v10;
v7 = (unsigned __int8)(v0 + 1);
do
{
v8 = *((unsigned __int8 *)v6 + 1);
v6 = (int *)((char *)v6 + 2);
result = print_string("Done!", v7, v8);
}
while ( &v12 != (char *)v6 );
return result;
}

canonical_decompiled_code:
__int64 func12()
{
int v0; // ebx
__int64 v1; // rsi
__int64 v2; // rsi
unsigned __int8 v3; // r12
__int64 v4; // rdx
__int64 v5; // rcx
int *v6; // rbp
unsigned int v7; // ebx
__int64 v8; // rdx
__int64 result; // rax
int v10; // [rsp+Ah] [rbp-1Eh] BYREF
__int16 v11; // [rsp+Eh] [rbp-1Ah]
char v12; // [rsp+10h] [rbp-18h] BYREF

v0 = 1;
func2();
func2();
clear_screen();
v11 = 16692;
v10 = 656018688;
print_string("Test Dual Ipis", 0LL, 0LL);
print_string("Sync", 1LL, 13LL);
print_string("Sync", 1LL, 39LL);
print_string("Sync", 1LL, 65LL);
v1 = 2LL;
MEMORY[0x200600] = 2;
do
{
v3 = v0 + 1;
func4(13214LL, v1);
measure_sync_ipis();
if ( (unsigned int)func5(13214LL, v1, v4, v5) )
{
print_number_u64(MEMORY[0x200D08], (unsigned __int8)++v0, BYTE1(v10));
print_number_u64(MEMORY[0x200D18], v3, HIBYTE(v10));
print_number_u64(MEMORY[0x200D28], v3, HIBYTE(v11));
}
else
{
v2 = (unsigned __int8)v0;
v0 += 2;
print_string("bad_sort :(", v2, BYTE1(v10));
print_string("bad_sort :(", v3, HIBYTE(v10));
}
v1 = (unsigned int)(2 * MEMORY[0x200600]);
MEMORY[0x200600] = v1;
}
while ( (unsigned int)v1 <= 0x7FFFFF );
v6 = &v10;
v7 = (unsigned __int8)(v0 + 1);
do
{
v8 = *((unsigned __int8 *)v6 + 1);
v6 = (int *)((char *)v6 + 2);
result = print_string("Done!", v7, v8);
}
while ( &v12 != (char *)v6 );
return result;
}

original_code:
void test_sync_ipi_cores()
{
    wait();
    wait();
    clear_screen();
    uint32_t *len = (uint32_t *) 0x200600;
    uint64_t *time_measures = (uint64_t *) 0x200d00;
    uint8_t col[6] = {0, 13, 26, 39, 52, 65};
    uint8_t line = 0;
    print_string("Test Dual Ipis", line++, col[0]);
    print_string("Sync", line, col[1]);
    print_string("Sync", line, col[3]);
    print_string("Sync", line, col[5]);
    for (*len = 2; *len < (8*1024*1024); *len *= 2) {
        uint32_t seed = 13214;
        generate_global_array(seed, *len);
        measure_sync_ipis();
        if (verfiy_sort()) {
            line++;
            uint8_t i;
            for (i = 1; i < 6; i += 2) {
                print_number_u64(time_measures[i], line, col[i]);
            }
        } else {
            for (uint8_t i = 1; i < 5; i += 2) {
                print_string("bad_sort :(", line++, col[i]);
            }
        }
    }
    uint8_t i;
    line++;
    for (i = 1; i < 6; i += 2) {
        print_string("Done!", line, col[i]);
    }
}

canonical_original_code:
void test_sync_ipi_cores()
{
    wait();
    wait();
    clear_screen();
    unsigned int *len = (uint32_t *) 0x200600;
    unsigned long *time_measures = (uint64_t *) 0x200d00;
    unsigned char col[6] = {0, 13, 26, 39, 52, 65};
    unsigned char line = 0;
    print_string("Test Dual Ipis", line++, col[0]);
    print_string("Sync", line, col[1]);
    print_string("Sync", line, col[3]);
    print_string("Sync", line, col[5]);
    for (*len = 2; *len < (8*1024*1024); *len *= 2) {
        unsigned int seed = 13214;
        generate_global_array(seed, *len);
        measure_sync_ipis();
        if (verfiy_sort()) {
            line++;
            unsigned char i;
            for (i = 1; i < 6; i += 2) {
                print_number_u64(time_measures[i], line, col[i]);
            }
        } else {
            for (unsigned char i = 1; i < 5; i += 2) {
                print_string("bad_sort :(", line++, col[i]);
            }
        }
    }
    unsigned char i;
    line++;
    for (i = 1; i < 6; i += 2) {
        print_string("Done!", line, col[i]);
    }
}

variable_types:
col
unsigned char [6]

variable_types:
i
unsigned char


original_code:
void sum_vector(uint32_t len)
{
    uint32_t *array = (uint32_t *) (0x1e00000 + 32 * 0xa00000);
    for (uint32_t i = 0; i < len; ++i) {
        array[i]++;
    }
}

canonical_original_code:
void sum_vector(unsigned int len)
{
    unsigned int *array = (uint32_t *) (0x1e00000 + 32 * 0xa00000);
    for (unsigned int i = 0; i < len; ++i) {
        array[i]++;
    }
}


decompiled_code:
__int64 test_sum_vector1()
{
int v0; // ebx
unsigned int v1; // edi
__int64 v2; // rsi

v0 = 1;
print_string("sum 1 core", 0LL, 68LL);
v1 = 2;
MEMORY[0x200600] = 2;
do
{
_mm_mfence();
start = __rdtsc();
sum_vector(v1);
_mm_mfence();
__rdtsc();
_mm_mfence();
__rdtsc();
_mm_mfence();
v2 = (unsigned __int8)v0++;
stop = __rdtsc();
print_number_u64(stop - start, v2, 68LL);
v1 = 2 * MEMORY[0x200600];
MEMORY[0x200600] = v1;
}
while ( v1 <= 0x7FFFFF );
return print_string("Done! :D", (unsigned __int8)(v2 + 2), 68LL);
}

canonical_decompiled_code:
__int64 func14()
{
int v0; // ebx
unsigned int v1; // edi
__int64 v2; // rsi

v0 = 1;
print_string("sum 1 core", 0LL, 68LL);
v1 = 2;
MEMORY[0x200600] = 2;
do
{
_mm_mfence();
start = __rdtsc();
func13(v1);
_mm_mfence();
__rdtsc();
_mm_mfence();
__rdtsc();
_mm_mfence();
v2 = (unsigned __int8)v0++;
stop = __rdtsc();
print_number_u64(stop - start, v2, 68LL);
v1 = 2 * MEMORY[0x200600];
MEMORY[0x200600] = v1;
}
while ( v1 <= 0x7FFFFF );
return print_string("Done! :D", (unsigned __int8)(v2 + 2), 68LL);
}

original_code:
void test_sum_vector1()
{
    uint32_t *len = (uint32_t *) 0x200600;
    uint8_t col = 68;
    uint8_t line = 0;
    print_string("sum 1 core", line++, col);
    for (*len = 2; *len < (8*1024*1024); *len *= 2) {
        { unsigned int start_high, start_low; __asm__ __volatile__ ( "mfence\n\t" "rdtsc\n\t" "mov %%edx, %0\n\t" "mov %%eax, %1\n\t" : "=r" (start_high), "=r" (start_low) : : "%eax" ); start = (((unsigned long long int) start_high) << 32) | (unsigned long long int) (start_low); };
        sum_vector(*len);
        { { unsigned int end_high, end_low; __asm__ __volatile__ ( "mfence\n\t" "rdtsc\n\t" "mov %%edx, %0\n\t" "mov %%eax, %1\n\t" : "=r" (end_high), "=r" (end_low) : : "%eax" ); stop = (((unsigned long long int) end_high) << 32) | (unsigned long long int) (end_low); } { unsigned int end_high, end_low; __asm__ __volatile__ ( "mfence\n\t" "rdtsc\n\t" "mov %%edx, %0\n\t" "mov %%eax, %1\n\t" : "=r" (end_high), "=r" (end_low) : : "%eax" ); stop = (((unsigned long long int) end_high) << 32) | (unsigned long long int) (end_low); } { unsigned int end_high, end_low; __asm__ __volatile__ ( "mfence\n\t" "rdtsc\n\t" "mov %%edx, %0\n\t" "mov %%eax, %1\n\t" : "=r" (end_high), "=r" (end_low) : : "%eax" ); stop = (((unsigned long long int) end_high) << 32) | (unsigned long long int) (end_low); } };
        print_number_u64(stop - start, line++, col);
    }
    print_string("Done! :D", ++line, col);
}

canonical_original_code:
void test_sum_vector1()
{
    unsigned int *len = (uint32_t *) 0x200600;
    unsigned char col = 68;
    unsigned char line = 0;
    print_string("sum 1 core", line++, col);
    for (*len = 2; *len < (8*1024*1024); *len *= 2) {
        { unsigned int start_high; unsigned int start_low; __asm__ __volatile__ ( "mfence\n\t" "rdtsc\n\t" "mov %%edx, %0\n\t" "mov %%eax, %1\n\t" : "=r" (start_high), "=r" (start_low) : : "%eax" ); start = (((unsigned long long) start_high) << 32) | (unsigned long long) (start_low); };
        sum_vector(*len);
        { { unsigned int end_high; unsigned int end_low; __asm__ __volatile__ ( "mfence\n\t" "rdtsc\n\t" "mov %%edx, %0\n\t" "mov %%eax, %1\n\t" : "=r" (end_high), "=r" (end_low) : : "%eax" ); stop = (((unsigned long long) end_high) << 32) | (unsigned long long) (end_low); } { unsigned int end_high; unsigned int end_low; __asm__ __volatile__ ( "mfence\n\t" "rdtsc\n\t" "mov %%edx, %0\n\t" "mov %%eax, %1\n\t" : "=r" (end_high), "=r" (end_low) : : "%eax" ); stop = (((unsigned long long) end_high) << 32) | (unsigned long long) (end_low); } { unsigned int end_high; unsigned int end_low; __asm__ __volatile__ ( "mfence\n\t" "rdtsc\n\t" "mov %%edx, %0\n\t" "mov %%eax, %1\n\t" : "=r" (end_high), "=r" (end_low) : : "%eax" ); stop = (((unsigned long long) end_high) << 32) | (unsigned long long) (end_low); } };
        print_number_u64(stop - start, line++, col);
    }
    print_string("Done! :D", ++line, col);
}


decompiled_code:
__int64 test_sum_vector2()
{
int v0; // ebx
__int64 v1; // rsi
__int64 result; // rax

v0 = 1;
print_string("sum 2 cores", 0LL, 102LL);
MEMORY[0x200600] = 2;
do
{
_mm_mfence();
start = __rdtsc();
sum_vector_bsp();
_mm_mfence();
__rdtsc();
_mm_mfence();
__rdtsc();
_mm_mfence();
v1 = (unsigned __int8)v0++;
stop = __rdtsc();
print_number_u64(stop - start, v1, 102LL);
MEMORY[0x200600] *= 2;
}
while ( MEMORY[0x200600] <= 0x7FFFFFu );
result = print_string("Done! :D", (unsigned __int8)(v1 + 2), 102LL);
MEMORY[0x200200] = 1;
return result;
}

canonical_decompiled_code:
__int64 func15()
{
int v0; // ebx
__int64 v1; // rsi
__int64 result; // rax

v0 = 1;
print_string("sum 2 cores", 0LL, 102LL);
MEMORY[0x200600] = 2;
do
{
_mm_mfence();
start = __rdtsc();
sum_vector_bsp();
_mm_mfence();
__rdtsc();
_mm_mfence();
__rdtsc();
_mm_mfence();
v1 = (unsigned __int8)v0++;
stop = __rdtsc();
print_number_u64(stop - start, v1, 102LL);
MEMORY[0x200600] *= 2;
}
while ( MEMORY[0x200600] <= 0x7FFFFFu );
result = print_string("Done! :D", (unsigned __int8)(v1 + 2), 102LL);
MEMORY[0x200200] = 1;
return result;
}

original_code:
void test_sum_vector2()
{
    uint32_t *len = (uint32_t *) 0x200600;
    uint8_t *sleep = (uint8_t *) 0x200200;
    uint8_t col = 102;
    uint8_t line = 0;
    print_string("sum 2 cores", line++, col);
    for (*len = 2; *len < (8*1024*1024); *len *= 2) {
        { unsigned int start_high, start_low; __asm__ __volatile__ ( "mfence\n\t" "rdtsc\n\t" "mov %%edx, %0\n\t" "mov %%eax, %1\n\t" : "=r" (start_high), "=r" (start_low) : : "%eax" ); start = (((unsigned long long int) start_high) << 32) | (unsigned long long int) (start_low); };
        sum_vector_bsp();
        { { unsigned int end_high, end_low; __asm__ __volatile__ ( "mfence\n\t" "rdtsc\n\t" "mov %%edx, %0\n\t" "mov %%eax, %1\n\t" : "=r" (end_high), "=r" (end_low) : : "%eax" ); stop = (((unsigned long long int) end_high) << 32) | (unsigned long long int) (end_low); } { unsigned int end_high, end_low; __asm__ __volatile__ ( "mfence\n\t" "rdtsc\n\t" "mov %%edx, %0\n\t" "mov %%eax, %1\n\t" : "=r" (end_high), "=r" (end_low) : : "%eax" ); stop = (((unsigned long long int) end_high) << 32) | (unsigned long long int) (end_low); } { unsigned int end_high, end_low; __asm__ __volatile__ ( "mfence\n\t" "rdtsc\n\t" "mov %%edx, %0\n\t" "mov %%eax, %1\n\t" : "=r" (end_high), "=r" (end_low) : : "%eax" ); stop = (((unsigned long long int) end_high) << 32) | (unsigned long long int) (end_low); } };
        print_number_u64(stop - start, line++, col);
    }
    print_string("Done! :D", ++line, col);
    *sleep = 1;
}

canonical_original_code:
void test_sum_vector2()
{
    unsigned int *len = (uint32_t *) 0x200600;
    unsigned char *sleep = (uint8_t *) 0x200200;
    unsigned char col = 102;
    unsigned char line = 0;
    print_string("sum 2 cores", line++, col);
    for (*len = 2; *len < (8*1024*1024); *len *= 2) {
        { unsigned int start_high; unsigned int start_low; __asm__ __volatile__ ( "mfence\n\t" "rdtsc\n\t" "mov %%edx, %0\n\t" "mov %%eax, %1\n\t" : "=r" (start_high), "=r" (start_low) : : "%eax" ); start = (((unsigned long long) start_high) << 32) | (unsigned long long) (start_low); };
        sum_vector_bsp();
        { { unsigned int end_high; unsigned int end_low; __asm__ __volatile__ ( "mfence\n\t" "rdtsc\n\t" "mov %%edx, %0\n\t" "mov %%eax, %1\n\t" : "=r" (end_high), "=r" (end_low) : : "%eax" ); stop = (((unsigned long long) end_high) << 32) | (unsigned long long) (end_low); } { unsigned int end_high; unsigned int end_low; __asm__ __volatile__ ( "mfence\n\t" "rdtsc\n\t" "mov %%edx, %0\n\t" "mov %%eax, %1\n\t" : "=r" (end_high), "=r" (end_low) : : "%eax" ); stop = (((unsigned long long) end_high) << 32) | (unsigned long long) (end_low); } { unsigned int end_high; unsigned int end_low; __asm__ __volatile__ ( "mfence\n\t" "rdtsc\n\t" "mov %%edx, %0\n\t" "mov %%eax, %1\n\t" : "=r" (end_high), "=r" (end_low) : : "%eax" ); stop = (((unsigned long long) end_high) << 32) | (unsigned long long) (end_low); } };
        print_number_u64(stop - start, line++, col);
    }
    print_string("Done! :D", ++line, col);
    *sleep = 1;
}

variable_types:
sleep
unsigned char *


original_code:
void generate_fft_array(uint32_t N)
{
    Complex *array = (Complex *) (0x1e00000 + 32 * 0xa00000);
    for (uint32_t i = 0; i < N / 2; ++i) {
        array[i].m_re = 1.0;
        array[i].m_im = 0.0;
    }
    for (uint32_t i = N / 2; i < N; ++i) {
        array[i].m_re = 0.0;
        array[i].m_im = 0.0;
    }
}

canonical_original_code:
void generate_fft_array(unsigned int N)
{
    struct s_complex *array = (Complex *) (0x1e00000 + 32 * 0xa00000);
    for (unsigned int i = 0; i < N / 2; ++i) {
        array[i].m_re = 1.0;
        array[i].m_im = 0.0;
    }
    for (unsigned int i = N / 2; i < N; ++i) {
        array[i].m_re = 0.0;
        array[i].m_im = 0.0;
    }
}

variable_types:
N
unsigned int

variable_types: struct s_complex { double m_re; double m_im; } *


decompiled_code:
__int64 test_fft_mono()
{
return test_suite_fft(
(void (__fastcall *)(__int64, __int64, _QWORD, __int64))&Inverse_IO,
0,
0,
(__int64)"fft monocore");
}

canonical_decompiled_code:
__int64 func20()
{
return func19(
(void (__fastcall *)(__int64, __int64, _QWORD, __int64))&Inverse_IO,
0,
0,
(__int64)"fft monocore");
}

original_code:
void test_fft_mono()
{
    test_suite_fft(Inverse_IO, 0, 0, "fft monocore");
}


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

clear_screen();
result = test_suite_fft(
(void (__fastcall *)(__int64, __int64, _QWORD, __int64))&Inverse_IO_Dual,
0,
0x1Eu,
(__int64)"fft dualcore");
MEMORY[0x200200] = 1;
return result;
}

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

clear_screen();
result = func19(
(void (__fastcall *)(__int64, __int64, _QWORD, __int64))&Inverse_IO_Dual,
0,
0x1Eu,
(__int64)"fft dualcore");
MEMORY[0x200200] = 1;
return result;
}

original_code:
void test_fft_dual_mem()
{
    clear_screen();
    test_suite_fft(Inverse_IO_Dual, 0, 30, "fft dualcore");
    *((uint8_t *) 0x200200) = 1;
}

canonical_original_code:
void test_fft_dual_mem()
{
    clear_screen();
    test_suite_fft(Inverse_IO_Dual, 0, 30, "fft dualcore");
    *((unsigned char *) 0x200200) = 1;
}


decompiled_code:
__int64 test_fft_dual_ipi()
{
return test_suite_fft(
(void (__fastcall *)(__int64, __int64, _QWORD, __int64))&Inverse_IO_Ipi,
0,
0x3Cu,
(__int64)"fft dualcore ipis");
}

canonical_decompiled_code:
__int64 func22()
{
return func19(
(void (__fastcall *)(__int64, __int64, _QWORD, __int64))&Inverse_IO_Ipi,
0,
0x3Cu,
(__int64)"fft dualcore ipis");
}

original_code:
void test_fft_dual_ipi()
{
    test_suite_fft(Inverse_IO_Ipi, 0, 60, "fft dualcore ipis");
}


decompiled_code:
void __fastcall __noreturn dummy_function(void *a1)
{
pthread_exit(0LL);
}

canonical_decompiled_code:
void __fastcall __noreturn func0(void *a1)
{
pthread_exit(0LL);
}

original_code:
void *dummy_function(void *p)
{
    pthread_exit(((void *)0));
}

variable_types:
p
void *

return_type: void *


decompiled_code:
void __fastcall __noreturn thread_sort(void *a1)
{
heapsort(&array[*(_DWORD *)a1 >> 1]);
pthread_exit(0LL);
}

canonical_decompiled_code:
void __fastcall __noreturn func1(void *a1)
{
heapsort(&array[*(_DWORD *)a1 >> 1]);
pthread_exit(0LL);
}

original_code:
void *thread_sort(void *v_len)
{
    uint32_t len = *((uint32_t *) v_len);
    heapsort(array + len / 2, len / 2);
    pthread_exit(((void *)0));
}

canonical_original_code:
void *thread_sort(void *v_len)
{
    unsigned int len = *((uint32_t *) v_len);
    heapsort(array + len / 2, len / 2);
    pthread_exit(((void *)0));
}

variable_types:
len
unsigned int


decompiled_code:
void __fastcall __noreturn thread_copy(void *a1)
{
copy(array, *(_DWORD *)a1 >> 1, &ap_temp, 0LL, *(_DWORD *)a1 >> 1);
pthread_exit(0LL);
}

canonical_decompiled_code:
void __fastcall __noreturn func2(void *a1)
{
copy(array, *(_DWORD *)a1 >> 1, &ap_temp, 0LL, *(_DWORD *)a1 >> 1);
pthread_exit(0LL);
}

original_code:
void *thread_copy(void *v_len)
{
    uint32_t len = *((uint32_t *) v_len);
    copy(array, len / 2, ap_temp, 0, len / 2);
    pthread_exit(((void *)0));
}

canonical_original_code:
void *thread_copy(void *v_len)
{
    unsigned int len = *((uint32_t *) v_len);
    copy(array, len / 2, ap_temp, 0, len / 2);
    pthread_exit(((void *)0));
}


decompiled_code:
void __fastcall __noreturn thread_merge(void *a1)
{
limit_merge_reverse(array, &ap_temp, 0LL, (unsigned int)((*(_DWORD *)a1 >> 1) - 1), (unsigned int)(*(_DWORD *)a1 - 1));
pthread_exit(0LL);
}

canonical_decompiled_code:
void __fastcall __noreturn func3(void *a1)
{
limit_merge_reverse(array, &ap_temp, 0LL, (unsigned int)((*(_DWORD *)a1 >> 1) - 1), (unsigned int)(*(_DWORD *)a1 - 1));
pthread_exit(0LL);
}

original_code:
void *thread_merge(void *v_len)
{
    uint32_t len = *((uint32_t *) v_len);
    limit_merge_reverse(array, ap_temp, 0, (len / 2) - 1, len - 1, len / 2);
    pthread_exit(((void *)0));
}

canonical_original_code:
void *thread_merge(void *v_len)
{
    unsigned int len = *((uint32_t *) v_len);
    limit_merge_reverse(array, ap_temp, 0, (len / 2) - 1, len - 1, len / 2);
    pthread_exit(((void *)0));
}


decompiled_code:
void __fastcall exit_if_error(unsigned int a1)
{
if ( a1 )
{
printf("ERROR; return code from create or join is %d\n", a1);
exit(-1);
}
}

canonical_decompiled_code:
void __fastcall func4(unsigned int a1)
{
if ( a1 )
{
printf("ERROR; return code from create or join is %d\n", a1);
exit(-1);
}
}

original_code:
void exit_if_error(int err_code)
{
    if (err_code) {
        printf("ERROR; return code from create or join is %d\n", err_code);
        exit(-1);
    }
}


decompiled_code:
int __fastcall do_sort_pthreads(unsigned int a1)
{
int v1; // eax
int v2; // eax
int v3; // eax
int v4; // eax
int v5; // eax
int v6; // eax
unsigned int arg; // [rsp+Ch] [rbp-6Ch] BYREF
void *thread_return; // [rsp+10h] [rbp-68h] BYREF
pthread_t newthread; // [rsp+18h] [rbp-60h] BYREF
pthread_t th; // [rsp+20h] [rbp-58h] BYREF
pthread_t v12; // [rsp+28h] [rbp-50h] BYREF
pthread_attr_t attr; // [rsp+30h] [rbp-48h] BYREF

arg = a1;
pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr, 0);
v1 = pthread_create(&newthread, &attr, (void *(*)(void *))thread_sort, &arg);
exit_if_error(v1);
heapsort(array);
v2 = pthread_join(newthread, &thread_return);
exit_if_error(v2);
v3 = pthread_create(&th, &attr, (void *(*)(void *))thread_merge, &arg);
exit_if_error(v3);
limit_merge(array, &bsp_temp, 0LL, (arg >> 1) - 1, arg - 1);
v4 = pthread_join(th, &thread_return);
exit_if_error(v4);
v5 = pthread_create(&v12, &attr, (void *(*)(void *))thread_copy, &arg);
exit_if_error(v5);
copy(array, 0LL, &bsp_temp, 0LL, arg >> 1);
v6 = pthread_join(v12, &thread_return);
exit_if_error(v6);
return pthread_attr_destroy(&attr);
}

canonical_decompiled_code:
int __fastcall func5(unsigned int a1)
{
int v1; // eax
int v2; // eax
int v3; // eax
int v4; // eax
int v5; // eax
int v6; // eax
unsigned int arg; // [rsp+Ch] [rbp-6Ch] BYREF
void *thread_return; // [rsp+10h] [rbp-68h] BYREF
pthread_t newthread; // [rsp+18h] [rbp-60h] BYREF
pthread_t th; // [rsp+20h] [rbp-58h] BYREF
pthread_t v12; // [rsp+28h] [rbp-50h] BYREF
pthread_attr_t attr; // [rsp+30h] [rbp-48h] BYREF

arg = a1;
pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr, 0);
v1 = pthread_create(&newthread, &attr, (void *(*)(void *))thread_sort, &arg);
func4(v1);
heapsort(array);
v2 = pthread_join(newthread, &thread_return);
func4(v2);
v3 = pthread_create(&th, &attr, (void *(*)(void *))thread_merge, &arg);
func4(v3);
limit_merge(array, &bsp_temp, 0LL, (arg >> 1) - 1, arg - 1);
v4 = pthread_join(th, &thread_return);
func4(v4);
v5 = pthread_create(&v12, &attr, (void *(*)(void *))thread_copy, &arg);
func4(v5);
copy(array, 0LL, &bsp_temp, 0LL, arg >> 1);
v6 = pthread_join(v12, &thread_return);
func4(v6);
return pthread_attr_destroy(&attr);
}

original_code:
void do_sort_pthreads(uint32_t len)
{
    void *status;
    pthread_t ap_heap_sort, ap_merge, ap_copy;
    pthread_attr_t join_attr;
    pthread_attr_init(&join_attr);
    pthread_attr_setdetachstate(&join_attr, PTHREAD_CREATE_JOINABLE);
    exit_if_error(
        pthread_create(&ap_heap_sort, &join_attr, thread_sort, (void *) &len)
    );
    heapsort(array, len / 2);
    exit_if_error(
        pthread_join(ap_heap_sort, &status)
    );
    exit_if_error(
        pthread_create(&ap_merge, &join_attr, thread_merge, (void *) &len)
    );
    limit_merge(array, bsp_temp, 0, (len / 2) - 1, len - 1, len / 2);
    exit_if_error(
        pthread_join(ap_merge, &status)
    );
    exit_if_error(
        pthread_create(&ap_copy, &join_attr, thread_copy, (void *) &len)
    );
    copy(array, 0, bsp_temp, 0, len / 2);
    exit_if_error(
        pthread_join(ap_copy, &status)
    );
    pthread_attr_destroy(&join_attr);
}

canonical_original_code:
void do_sort_pthreads(unsigned int len)
{
    void *status;
    unsigned long ap_heap_sort; unsigned long ap_merge; unsigned long ap_copy;
    union pthread_attr_t join_attr;
    pthread_attr_init(&join_attr);
    pthread_attr_setdetachstate(&join_attr, PTHREAD_CREATE_JOINABLE);
    exit_if_error(
        pthread_create(&ap_heap_sort, &join_attr, thread_sort, (void *) &len)
    );
    heapsort(array, len / 2);
    exit_if_error(
        pthread_join(ap_heap_sort, &status)
    );
    exit_if_error(
        pthread_create(&ap_merge, &join_attr, thread_merge, (void *) &len)
    );
    limit_merge(array, bsp_temp, 0, (len / 2) - 1, len - 1, len / 2);
    exit_if_error(
        pthread_join(ap_merge, &status)
    );
    exit_if_error(
        pthread_create(&ap_copy, &join_attr, thread_copy, (void *) &len)
    );
    copy(array, 0, bsp_temp, 0, len / 2);
    exit_if_error(
        pthread_join(ap_copy, &status)
    );
    pthread_attr_destroy(&join_attr);
}

variable_types:
status
void *

variable_types: union pthread_attr_t { char __size[56]; long __align; }


decompiled_code:
unsigned __int64 custom_rand()
{
global_seed = 1103515245 * global_seed + 12345;
return ((unsigned __int64)global_seed >> 16) & 0x7FFF;
}

canonical_decompiled_code:
unsigned __int64 func6()
{
global_seed = 1103515245 * global_seed + 12345;
return ((unsigned __int64)global_seed >> 16) & 0x7FFF;
}

original_code:
uint32_t custom_rand()
{
    global_seed = global_seed * 1103515245 + 12345;
    return (uint32_t) (global_seed / 65536) % 32768;
}

canonical_original_code:
unsigned int custom_rand()
{
    global_seed = global_seed * 1103515245 + 12345;
    return (unsigned int) (global_seed / 65536) % 32768;
}


decompiled_code:
__int64 __fastcall verfiy_sort(unsigned int a1)
{
__int64 v1; // rax

if ( a1 <= 1 )
return 1LL;
v1 = 0LL;
while ( array[v1] <= array[v1 + 1] )
{
if ( ++v1 == a1 - 1 )
return 1LL;
}
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func8(unsigned int a1)
{
__int64 v1; // rax

if ( a1 <= 1 )
return 1LL;
v1 = 0LL;
while ( array[v1] <= array[v1 + 1] )
{
if ( ++v1 == a1 - 1 )
return 1LL;
}
return 0LL;
}

original_code:
_Bool verfiy_sort(uint32_t len)
{
    for (uint32_t i = 1; i < len; ++i) {
        if (array[i - 1] > array[i]) {
            return 0;
        }
    }
    return 1;
}

variable_types:
i
unsigned int


decompiled_code:
int test_pthreads_sync()
{
int v0; // ebp
unsigned int v1; // ebx
__int64 v2; // rsi

v0 = 22;
v1 = 2;
puts("\nTesting pthreads sync");
puts("Elementos\tCiclos\t\tCiclos\t\tCiclos");
do
{
while ( 1 )
{
generate_global_array(13214LL, v1);
sort_measure_sync(v1);
if ( !(unsigned __int8)verfiy_sort(v1) )
break;
v2 = v1;
v1 *= 2;
printf("%u\t\t%lu\t\t%lu\t\t%lu\n", v2, sync_times[0], sync_times[1], sync_times[2]);
if ( !--v0 )
return puts("Done! :D");
}
v1 *= 2;
puts("Bad sort! :(");
--v0;
}
while ( v0 );
return puts("Done! :D");
}

canonical_decompiled_code:
int func9()
{
int v0; // ebp
unsigned int v1; // ebx
__int64 v2; // rsi

v0 = 22;
v1 = 2;
puts("\nTesting pthreads sync");
puts("Elementos\tCiclos\t\tCiclos\t\tCiclos");
do
{
while ( 1 )
{
func7(13214LL, v1);
sort_measure_sync(v1);
if ( !(unsigned __int8)func8(v1) )
break;
v2 = v1;
v1 *= 2;
printf("%u\t\t%lu\t\t%lu\t\t%lu\n", v2, sync_times[0], sync_times[1], sync_times[2]);
if ( !--v0 )
return puts("Done! :D");
}
v1 *= 2;
puts("Bad sort! :(");
--v0;
}
while ( v0 );
return puts("Done! :D");
}

original_code:
void test_pthreads_sync()
{
    printf("\nTesting pthreads sync\n");
    printf("Elementos\tCiclos\t\tCiclos\t\tCiclos\n");
    for (uint32_t len = 2; len < (8*1024*1024); len *= 2) {
        uint32_t seed = 13214;
        generate_global_array(seed, len);
        sort_measure_sync(len);
        if (verfiy_sort(len)) {
            printf("%u\t\t%lu\t\t%lu\t\t%lu\n", len, sync_times[0], sync_times[1], sync_times[2]);
        } else {
            printf("Bad sort! :(\n");
        }
    }
    printf("Done! :D\n");
}

canonical_original_code:
void test_pthreads_sync()
{
    printf("\nTesting pthreads sync\n");
    printf("Elementos\tCiclos\t\tCiclos\t\tCiclos\n");
    for (unsigned int len = 2; len < (8*1024*1024); len *= 2) {
        unsigned int seed = 13214;
        generate_global_array(seed, len);
        sort_measure_sync(len);
        if (verfiy_sort(len)) {
            printf("%u\t\t%lu\t\t%lu\t\t%lu\n", len, sync_times[0], sync_times[1], sync_times[2]);
        } else {
            printf("Bad sort! :(\n");
        }
    }
    printf("Done! :D\n");
}


main

canonical_name: main

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

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

original_code:
int main()
{
    test_pthreads();
    test_pthreads_sync();
    return 0;
}

return_type: int


decompiled_code:
void __fastcall generate_global_array(__int64 a1, int a2)
{
int v2; // eax
__int64 v3; // rdx

global_seed = a1;
if ( a2 )
{
do
{
v2 = custom_rand();
array[v3] = v2;
}
while ( v3 + 1 != a2 );
}
}

canonical_decompiled_code:
void __fastcall func7(__int64 a1, int a2)
{
int v2; // eax
__int64 v3; // rdx

global_seed = a1;
if ( a2 )
{
do
{
v2 = func6();
array[v3] = v2;
}
while ( v3 + 1 != a2 );
}
}

original_code:
void generate_global_array(uint64_t seed, uint32_t len)
{
    global_seed = seed;
    for (uint32_t i = 0; i < len; ++i) {
        array[i] = custom_rand();
    }
}

canonical_original_code:
void generate_global_array(unsigned long seed, unsigned int len)
{
    global_seed = seed;
    for (unsigned int i = 0; i < len; ++i) {
        array[i] = custom_rand();
    }
}

variable_types:
seed
unsigned long


original_code:
void sort_ap()
{
    uint64_t *start = (uint64_t *) 0x200000;
    uint64_t *start_merge = (uint64_t *) 0x200100;
    uint64_t *done = (uint64_t *) 0x200700;
    uint64_t *finish_copy = (uint64_t *) 0x200800;
    uint64_t *sleep = (uint64_t *) 0x200200;
    uint64_t *start_copy = (uint64_t *) 0x200300;
    *sleep = 0;
    while(!(*sleep)) {
        while(!(*start)) {
            if (*sleep) {
                return;
            }
        }
        uint32_t *len = (uint32_t *) 0x200600;
        uint32_t *array = (uint32_t *) (0x1e00000 + 32 * 0xa00000);
        uint32_t *ap_temp = (uint32_t *) (0x1e00000 + 0xa00000);
        *start = 0;
        heapsort(array + *len / 2, *len / 2);
        *done = 1;
        while(!(*start_merge));
        limit_merge_reverse(array, ap_temp, 0, (*len / 2) - 1, *len - 1, *len / 2);
        *done = 1;
        while(!(*start_copy));
        copy(array, *len / 2, ap_temp, 0, *len / 2);
        *finish_copy = 1;
    }
    *sleep = 0;
}

canonical_original_code:
void sort_ap()
{
    unsigned long *start = (uint64_t *) 0x200000;
    unsigned long *start_merge = (uint64_t *) 0x200100;
    unsigned long *done = (uint64_t *) 0x200700;
    unsigned long *finish_copy = (uint64_t *) 0x200800;
    unsigned long *sleep = (uint64_t *) 0x200200;
    unsigned long *start_copy = (uint64_t *) 0x200300;
    *sleep = 0;
    while(!(*sleep)) {
        while(!(*start)) {
            if (*sleep) {
                return;
            }
        }
        unsigned int *len = (uint32_t *) 0x200600;
        unsigned int *array = (uint32_t *) (0x1e00000 + 32 * 0xa00000);
        unsigned int *ap_temp = (uint32_t *) (0x1e00000 + 0xa00000);
        *start = 0;
        heapsort(array + *len / 2, *len / 2);
        *done = 1;
        while(!(*start_merge));
        limit_merge_reverse(array, ap_temp, 0, (*len / 2) - 1, *len - 1, *len / 2);
        *done = 1;
        while(!(*start_copy));
        copy(array, *len / 2, ap_temp, 0, *len / 2);
        *finish_copy = 1;
    }
    *sleep = 0;
}

variable_types:
start
unsigned long *

variable_types:
done
unsigned long *

variable_types:
sleep
unsigned long *

variable_types:
len
unsigned int *

variable_types:
array
unsigned int *


decompiled_code:
void __noreturn ap_sync()
{
MEMORY[0x200200] = 0LL;
MEMORY[0x200000] = 0LL;
while ( 1 )
;
}

canonical_decompiled_code:
void __noreturn func1()
{
MEMORY[0x200200] = 0LL;
MEMORY[0x200000] = 0LL;
while ( 1 )
;
}

original_code:
void ap_sync()
{
    uint64_t *start = (uint64_t *) 0x200000;
    uint64_t *done = (uint64_t *) 0x200700;
    uint64_t *sleep = (uint64_t *) 0x200200;
    *sleep = 0;
    *start = 0;
    while(!(*sleep)) {
        while(!(*start)) {
            if (*sleep) {
                return;
            }
        }
        *start = 0;
        *done = 1;
    }
}

canonical_original_code:
void ap_sync()
{
    unsigned long *start = (uint64_t *) 0x200000;
    unsigned long *done = (uint64_t *) 0x200700;
    unsigned long *sleep = (uint64_t *) 0x200200;
    *sleep = 0;
    *start = 0;
    while(!(*sleep)) {
        while(!(*start)) {
            if (*sleep) {
                return;
            }
        }
        *start = 0;
        *done = 1;
    }
}


canonical_original_code:
void sum_vector_ap()
{
    unsigned long *start = (uint64_t *) 0x200000;
    unsigned int *array = (uint32_t *) (0x1e00000 + 32 * 0xa00000);
    unsigned int *len = (uint32_t *) 0x200600;
    unsigned long *sleep = (uint64_t *) 0x200200;
    while(!(*start)) {
        if (*sleep) {
            return;
        }
    }
    for (unsigned int i = *len / 2; i < *len; ++i) {
        array[i]++;
    }
    *((unsigned long *) 0x200800) = 1;
}


decompiled_code:
__int64 sort_ap_int()
{
heapsort(4LL * (MEMORY[0x200600] >> 1) + 367001600);
return signal_finished();
}

canonical_decompiled_code:
__int64 func3()
{
heapsort(4LL * (MEMORY[0x200600] >> 1) + 367001600);
return signal_finished();
}

original_code:
void sort_ap_int()
{
    uint32_t *len = (uint32_t *) 0x200600;
    uint32_t *array = (uint32_t *) (0x1e00000 + 32 * 0xa00000);
    heapsort(array + *len / 2, *len / 2);
    signal_finished();
}

canonical_original_code:
void sort_ap_int()
{
    unsigned int *len = (uint32_t *) 0x200600;
    unsigned int *array = (uint32_t *) (0x1e00000 + 32 * 0xa00000);
    heapsort(array + *len / 2, *len / 2);
    signal_finished();
}


decompiled_code:
__int64 merge_ap_int()
{
limit_merge_reverse(
367001600LL,
41943040LL,
0LL,
(unsigned int)((MEMORY[0x200600] >> 1) - 1),
(unsigned int)(MEMORY[0x200600] - 1));
return signal_finished();
}

canonical_decompiled_code:
__int64 func4()
{
limit_merge_reverse(
367001600LL,
41943040LL,
0LL,
(unsigned int)((MEMORY[0x200600] >> 1) - 1),
(unsigned int)(MEMORY[0x200600] - 1));
return signal_finished();
}

original_code:
void merge_ap_int()
{
    uint32_t *len = (uint32_t *) 0x200600;
    uint32_t *array = (uint32_t *) (0x1e00000 + 32 * 0xa00000);
    uint32_t *ap_temp = (uint32_t *) (0x1e00000 + 0xa00000);
    limit_merge_reverse(array, ap_temp, 0, (*len / 2) - 1, *len - 1, *len / 2);
    signal_finished();
}

canonical_original_code:
void merge_ap_int()
{
    unsigned int *len = (uint32_t *) 0x200600;
    unsigned int *array = (uint32_t *) (0x1e00000 + 32 * 0xa00000);
    unsigned int *ap_temp = (uint32_t *) (0x1e00000 + 0xa00000);
    limit_merge_reverse(array, ap_temp, 0, (*len / 2) - 1, *len - 1, *len / 2);
    signal_finished();
}


canonical_original_code:
void copy_ap_int()
{
    unsigned int *len = (uint32_t *) 0x200600;
    unsigned int *array = (uint32_t *) (0x1e00000 + 32 * 0xa00000);
    unsigned int *ap_temp = (uint32_t *) (0x1e00000 + 0xa00000);
    copy(array, *len / 2, ap_temp, 0, *len / 2);
    signal_finished();
}


decompiled_code:
__int64 ap_jump()
{
return signal_finished();
}

canonical_decompiled_code:
__int64 func6()
{
return signal_finished();
}

original_code:
void ap_jump()
{
    signal_finished();
}

canonical_original_code:
void ap_jump()
{
    signal_finished();
}


decompiled_code:
void startKernel64_BSPMODE()
{
;
}

canonical_decompiled_code:
void func0()
{
;
}

original_code:
void startKernel64_BSPMODE(){
}

canonical_original_code:
void startKernel64_BSPMODE(){
}


decompiled_code:
void startKernel64_APMODE()
{
;
}

canonical_decompiled_code:
void func1()
{
;
}

original_code:
void startKernel64_APMODE(){
}

canonical_original_code:
void startKernel64_APMODE(){
}


canonical_original_code:
static void clean_flags()
{
    *((unsigned long *) 0x200000) = 0;
    *((unsigned long *) 0x200100) = 0;
    *((unsigned long *) 0x200700) = 0;
    *((unsigned long *) 0x200800) = 0;
    *((unsigned long *) 0x200300) = 0;
}


original_code:
void sort_bsp()
{
    uint64_t *start = (uint64_t *) 0x200000;
    uint64_t *start_merge = (uint64_t *) 0x200100;
    uint64_t *done = (uint64_t *) 0x200700;
    uint64_t *finish_copy = (uint64_t *) 0x200800;
    uint64_t *start_copy = (uint64_t *) 0x200300;
    uint32_t *len = (uint32_t *) 0x200600;
    uint32_t *array = (uint32_t *) (0x1e00000 + 32 * 0xa00000);
    uint32_t *bsp_temp = (uint32_t *) 0x1e00000;
    clean_flags();
    *start = 1;
    heapsort(array, *len / 2);
    while(!(*done));
    *done = 0;
    *start_merge = 1;
    limit_merge(array, bsp_temp, 0, (*len / 2) - 1, *len - 1, *len / 2);
    while(!(*done));
    *done = 0;
    *start_copy = 1;
    copy(array, 0, bsp_temp, 0, *len / 2);
    while(!(*finish_copy));
    clean_flags();
}

canonical_original_code:
void sort_bsp()
{
    unsigned long *start = (uint64_t *) 0x200000;
    unsigned long *start_merge = (uint64_t *) 0x200100;
    unsigned long *done = (uint64_t *) 0x200700;
    unsigned long *finish_copy = (uint64_t *) 0x200800;
    unsigned long *start_copy = (uint64_t *) 0x200300;
    unsigned int *len = (uint32_t *) 0x200600;
    unsigned int *array = (uint32_t *) (0x1e00000 + 32 * 0xa00000);
    unsigned int *bsp_temp = (uint32_t *) 0x1e00000;
    clean_flags();
    *start = 1;
    heapsort(array, *len / 2);
    while(!(*done));
    *done = 0;
    *start_merge = 1;
    limit_merge(array, bsp_temp, 0, (*len / 2) - 1, *len - 1, *len / 2);
    while(!(*done));
    *done = 0;
    *start_copy = 1;
    copy(array, 0, bsp_temp, 0, *len / 2);
    while(!(*finish_copy));
    clean_flags();
}


original_code:
void sort_bsp_ipi()
{
    uint32_t *len = (uint32_t *) 0x200600;
    uint32_t *array = (uint32_t *) (0x1e00000 + 32 * 0xa00000);
    uint32_t *bsp_temp = (uint32_t *) 0x1e00000;
    send_ipi_ap(40);
    heapsort(array, *len / 2);
    check_rax();
    send_ipi_ap(41);
    limit_merge(array, bsp_temp, 0, (*len / 2) - 1, *len - 1, *len / 2);
    check_rax();
    send_ipi_ap(42);
    copy(array, 0, bsp_temp, 0, *len / 2);
    check_rax();
}

canonical_original_code:
void sort_bsp_ipi()
{
    unsigned int *len = (uint32_t *) 0x200600;
    unsigned int *array = (uint32_t *) (0x1e00000 + 32 * 0xa00000);
    unsigned int *bsp_temp = (uint32_t *) 0x1e00000;
    send_ipi_ap(40);
    heapsort(array, *len / 2);
    check_rax();
    send_ipi_ap(41);
    limit_merge(array, bsp_temp, 0, (*len / 2) - 1, *len - 1, *len / 2);
    check_rax();
    send_ipi_ap(42);
    copy(array, 0, bsp_temp, 0, *len / 2);
    check_rax();
}


canonical_decompiled_code:
unsigned __int64 func3()
{
global_seed = 1103515245 * global_seed + 12345;
return ((unsigned __int64)global_seed >> 16) & 0x7FFF;
}


decompiled_code:
void __fastcall generate_random_array(__int64 a1, __int64 a2, int a3)
{
__int64 v3; // rdx

global_seed = a2;
if ( a3 )
{
do
{
a1 += 4LL;
*(_DWORD *)(a1 - 4) = custom_rand();
}
while ( a1 != v3 );
}
}

canonical_decompiled_code:
void __fastcall func4(__int64 a1, __int64 a2, int a3)
{
__int64 v3; // rdx

global_seed = a2;
if ( a3 )
{
do
{
a1 += 4LL;
*(_DWORD *)(a1 - 4) = func3();
}
while ( a1 != v3 );
}
}

original_code:
void generate_random_array(int *array, uint64_t seed, uint32_t len)
{
    global_seed = seed;
    for (uint32_t i = 0; i < len; ++i) {
        array[i] = custom_rand();
    }
}

canonical_original_code:
void generate_random_array(int *array, unsigned long seed, unsigned int len)
{
    global_seed = seed;
    for (unsigned int i = 0; i < len; ++i) {
        array[i] = custom_rand();
    }
}

variable_types:
array
int *


original_code:
void bubble_sort(int *array, uint32_t len)
{
    for (int j = 0; j < len; ++j) {
        for (int i = 0; i < len - 1 - j; ++i) {
            if (array[i] > array[i + 1]) {
                int aux = array[i];
                array[i] = array[i + 1];
                array[i + 1] = aux;
            }
        }
    }
}

canonical_original_code:
void bubble_sort(int *array, unsigned int len)
{
    for (int j = 0; j < len; ++j) {
        for (int i = 0; i < len - 1 - j; ++i) {
            if (array[i] > array[i + 1]) {
                int aux = array[i];
                array[i] = array[i + 1];
                array[i + 1] = aux;
            }
        }
    }
}

variable_types: j int

variable_types: i int

variable_types: aux int


decompiled_code:
unsigned __int64 measure_sync_mem()
{
int v0; // er10
int v1; // er11
unsigned __int64 v2; // rcx
unsigned __int64 result; // rax
int v4[12]; // [rsp+0h] [rbp-30h] BYREF

MEMORY[0x200000] = 1LL;
if ( MEMORY[0x200600] )
{
do
{
generate_random_array((__int64)v4, 13214LL, 10);
bubble_sort(v4, 10);
}
while ( v0 != v1 );
}
_mm_mfence();
v2 = __rdtsc();
init = v2;
if ( !MEMORY[0x200700] )
{
while ( 1 )
;
}
_mm_mfence();
__rdtsc();
_mm_mfence();
__rdtsc();
_mm_mfence();
stop = __rdtsc();
result = stop - v2;
MEMORY[0x200D00] = stop - v2;
return result;
}

canonical_decompiled_code:
unsigned __int64 func6()
{
int v0; // er10
int v1; // er11
unsigned __int64 v2; // rcx
unsigned __int64 result; // rax
int v4[12]; // [rsp+0h] [rbp-30h] BYREF

MEMORY[0x200000] = 1LL;
if ( MEMORY[0x200600] )
{
do
{
func4((__int64)v4, 13214LL, 10);
func5(v4, 10);
}
while ( v0 != v1 );
}
_mm_mfence();
v2 = __rdtsc();
init = v2;
if ( !MEMORY[0x200700] )
{
while ( 1 )
;
}
_mm_mfence();
__rdtsc();
_mm_mfence();
__rdtsc();
_mm_mfence();
stop = __rdtsc();
result = stop - v2;
MEMORY[0x200D00] = stop - v2;
return result;
}

original_code:
void measure_sync_mem()
{
    int my_len = 10;
    int my_array[my_len];
    uint64_t *start = (uint64_t *) 0x200000;
    uint64_t *done = (uint64_t *) 0x200700;
    uint32_t len = *((uint32_t *) 0x200600);
    uint64_t *time_measures = (uint64_t *) 0x200d00;
    *start = 1;
    for (int i = 0; i < len; ++i) {
        generate_random_array(my_array, 13214, my_len);
        bubble_sort(my_array, my_len);
        for (int j = 1; j < my_len ; ++j) {
            if (my_array[j - 1] > my_array[j]) {
                break;
            }
        }
    }
    { unsigned int start_high, start_low; __asm__ __volatile__ ( "mfence\n\t" "rdtsc\n\t" "mov %%edx, %0\n\t" "mov %%eax, %1\n\t" : "=r" (start_high), "=r" (start_low) : : "%eax" ); init = (((unsigned long long int) start_high) << 32) | (unsigned long long int) (start_low); };
    while(!(*done));
    { { unsigned int end_high, end_low; __asm__ __volatile__ ( "mfence\n\t" "rdtsc\n\t" "mov %%edx, %0\n\t" "mov %%eax, %1\n\t" : "=r" (end_high), "=r" (end_low) : : "%eax" ); stop = (((unsigned long long int) end_high) << 32) | (unsigned long long int) (end_low); } { unsigned int end_high, end_low; __asm__ __volatile__ ( "mfence\n\t" "rdtsc\n\t" "mov %%edx, %0\n\t" "mov %%eax, %1\n\t" : "=r" (end_high), "=r" (end_low) : : "%eax" ); stop = (((unsigned long long int) end_high) << 32) | (unsigned long long int) (end_low); } { unsigned int end_high, end_low; __asm__ __volatile__ ( "mfence\n\t" "rdtsc\n\t" "mov %%edx, %0\n\t" "mov %%eax, %1\n\t" : "=r" (end_high), "=r" (end_low) : : "%eax" ); stop = (((unsigned long long int) end_high) << 32) | (unsigned long long int) (end_low); } };
    time_measures[0] = stop - init;
}

canonical_original_code:
void measure_sync_mem()
{
    int my_len = 10;
    int my_array[-1];
    unsigned long *start = (uint64_t *) 0x200000;
    unsigned long *done = (uint64_t *) 0x200700;
    unsigned int len = *((uint32_t *) 0x200600);
    unsigned long *time_measures = (uint64_t *) 0x200d00;
    *start = 1;
    for (int i = 0; i < len; ++i) {
        generate_random_array(my_array, 13214, my_len);
        bubble_sort(my_array, my_len);
        for (int j = 1; j < my_len ; ++j) {
            if (my_array[j - 1] > my_array[j]) {
                break;
            }
        }
    }
    { unsigned int start_high; unsigned int start_low; __asm__ __volatile__ ( "mfence\n\t" "rdtsc\n\t" "mov %%edx, %0\n\t" "mov %%eax, %1\n\t" : "=r" (start_high), "=r" (start_low) : : "%eax" ); init = (((unsigned long long) start_high) << 32) | (unsigned long long) (start_low); };
    while(!(*done));
    { { unsigned int end_high; unsigned int end_low; __asm__ __volatile__ ( "mfence\n\t" "rdtsc\n\t" "mov %%edx, %0\n\t" "mov %%eax, %1\n\t" : "=r" (end_high), "=r" (end_low) : : "%eax" ); stop = (((unsigned long long) end_high) << 32) | (unsigned long long) (end_low); } { unsigned int end_high; unsigned int end_low; __asm__ __volatile__ ( "mfence\n\t" "rdtsc\n\t" "mov %%edx, %0\n\t" "mov %%eax, %1\n\t" : "=r" (end_high), "=r" (end_low) : : "%eax" ); stop = (((unsigned long long) end_high) << 32) | (unsigned long long) (end_low); } { unsigned int end_high; unsigned int end_low; __asm__ __volatile__ ( "mfence\n\t" "rdtsc\n\t" "mov %%edx, %0\n\t" "mov %%eax, %1\n\t" : "=r" (end_high), "=r" (end_low) : : "%eax" ); stop = (((unsigned long long) end_high) << 32) | (unsigned long long) (end_low); } };
    time_measures[0] = stop - init;
}


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

send_ipi_ap(39LL);
heapsort(367001600LL, MEMORY[0x200600] >> 1);
heapsort(4LL * (MEMORY[0x200600] >> 1) + 367001600, MEMORY[0x200600] >> 1);
_mm_mfence();
init = __rdtsc();
check_rax();
_mm_mfence();
__rdtsc();
_mm_mfence();
__rdtsc();
_mm_mfence();
stop = __rdtsc();
MEMORY[0x200D08] = stop - init;
send_ipi_ap(39LL);
limit_merge(
367001600LL,
31457280LL,
0LL,
(unsigned int)((MEMORY[0x200600] >> 1) - 1),
(unsigned int)(MEMORY[0x200600] - 1));
limit_merge_reverse(
367001600LL,
41943040LL,
0LL,
(unsigned int)((MEMORY[0x200600] >> 1) - 1),
(unsigned int)(MEMORY[0x200600] - 1));
_mm_mfence();
init = __rdtsc();
check_rax();
_mm_mfence();
__rdtsc();
_mm_mfence();
__rdtsc();
_mm_mfence();
stop = __rdtsc();
MEMORY[0x200D18] = stop - init;
send_ipi_ap(39LL);
copy(367001600LL, 0LL, 31457280LL, 0LL, MEMORY[0x200600] >> 1);
copy(367001600LL, MEMORY[0x200600] >> 1, 41943040LL, 0LL, MEMORY[0x200600] >> 1);
_mm_mfence();
init = __rdtsc();
check_rax();
_mm_mfence();
__rdtsc();
_mm_mfence();
__rdtsc();
_mm_mfence();
stop = __rdtsc();
result = stop - init;
MEMORY[0x200D28] = stop - init;
return result;
}

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

send_ipi_ap(39LL);
heapsort(367001600LL, MEMORY[0x200600] >> 1);
heapsort(4LL * (MEMORY[0x200600] >> 1) + 367001600, MEMORY[0x200600] >> 1);
_mm_mfence();
init = __rdtsc();
check_rax();
_mm_mfence();
__rdtsc();
_mm_mfence();
__rdtsc();
_mm_mfence();
stop = __rdtsc();
MEMORY[0x200D08] = stop - init;
send_ipi_ap(39LL);
limit_merge(
367001600LL,
31457280LL,
0LL,
(unsigned int)((MEMORY[0x200600] >> 1) - 1),
(unsigned int)(MEMORY[0x200600] - 1));
limit_merge_reverse(
367001600LL,
41943040LL,
0LL,
(unsigned int)((MEMORY[0x200600] >> 1) - 1),
(unsigned int)(MEMORY[0x200600] - 1));
_mm_mfence();
init = __rdtsc();
check_rax();
_mm_mfence();
__rdtsc();
_mm_mfence();
__rdtsc();
_mm_mfence();
stop = __rdtsc();
MEMORY[0x200D18] = stop - init;
send_ipi_ap(39LL);
copy(367001600LL, 0LL, 31457280LL, 0LL, MEMORY[0x200600] >> 1);
copy(367001600LL, MEMORY[0x200600] >> 1, 41943040LL, 0LL, MEMORY[0x200600] >> 1);
_mm_mfence();
init = __rdtsc();
check_rax();
_mm_mfence();
__rdtsc();
_mm_mfence();
__rdtsc();
_mm_mfence();
stop = __rdtsc();
result = stop - init;
MEMORY[0x200D28] = stop - init;
return result;
}

original_code:
void measure_sync_ipis()
{
    uint32_t *len = (uint32_t *) 0x200600;
    uint32_t *array = (uint32_t *) (0x1e00000 + 32 * 0xa00000);
    uint32_t *bsp_temp = (uint32_t *) 0x1e00000;
    uint64_t *time_measures = (uint64_t *) 0x200d00;
    uint32_t *ap_temp = (uint32_t *) (0x1e00000 + 0xa00000);
    send_ipi_ap(39);
    heapsort(array, *len / 2);
    heapsort(array + *len / 2, *len / 2);
    { unsigned int start_high, start_low; __asm__ __volatile__ ( "mfence\n\t" "rdtsc\n\t" "mov %%edx, %0\n\t" "mov %%eax, %1\n\t" : "=r" (start_high), "=r" (start_low) : : "%eax" ); init = (((unsigned long long int) start_high) << 32) | (unsigned long long int) (start_low); };
    check_rax();
    { { unsigned int end_high, end_low; __asm__ __volatile__ ( "mfence\n\t" "rdtsc\n\t" "mov %%edx, %0\n\t" "mov %%eax, %1\n\t" : "=r" (end_high), "=r" (end_low) : : "%eax" ); stop = (((unsigned long long int) end_high) << 32) | (unsigned long long int) (end_low); } { unsigned int end_high, end_low; __asm__ __volatile__ ( "mfence\n\t" "rdtsc\n\t" "mov %%edx, %0\n\t" "mov %%eax, %1\n\t" : "=r" (end_high), "=r" (end_low) : : "%eax" ); stop = (((unsigned long long int) end_high) << 32) | (unsigned long long int) (end_low); } { unsigned int end_high, end_low; __asm__ __volatile__ ( "mfence\n\t" "rdtsc\n\t" "mov %%edx, %0\n\t" "mov %%eax, %1\n\t" : "=r" (end_high), "=r" (end_low) : : "%eax" ); stop = (((unsigned long long int) end_high) << 32) | (unsigned long long int) (end_low); } };
    time_measures[1] = stop - init;
    send_ipi_ap(39);
    limit_merge(array, bsp_temp, 0, (*len / 2) - 1, *len - 1, *len / 2);
    limit_merge_reverse(array, ap_temp, 0, (*len / 2) - 1, *len - 1, *len / 2);
    { unsigned int start_high, start_low; __asm__ __volatile__ ( "mfence\n\t" "rdtsc\n\t" "mov %%edx, %0\n\t" "mov %%eax, %1\n\t" : "=r" (start_high), "=r" (start_low) : : "%eax" ); init = (((unsigned long long int) start_high) << 32) | (unsigned long long int) (start_low); };
    check_rax();
    { { unsigned int end_high, end_low; __asm__ __volatile__ ( "mfence\n\t" "rdtsc\n\t" "mov %%edx, %0\n\t" "mov %%eax, %1\n\t" : "=r" (end_high), "=r" (end_low) : : "%eax" ); stop = (((unsigned long long int) end_high) << 32) | (unsigned long long int) (end_low); } { unsigned int end_high, end_low; __asm__ __volatile__ ( "mfence\n\t" "rdtsc\n\t" "mov %%edx, %0\n\t" "mov %%eax, %1\n\t" : "=r" (end_high), "=r" (end_low) : : "%eax" ); stop = (((unsigned long long int) end_high) << 32) | (unsigned long long int) (end_low); } { unsigned int end_high, end_low; __asm__ __volatile__ ( "mfence\n\t" "rdtsc\n\t" "mov %%edx, %0\n\t" "mov %%eax, %1\n\t" : "=r" (end_high), "=r" (end_low) : : "%eax" ); stop = (((unsigned long long int) end_high) << 32) | (unsigned long long int) (end_low); } };
    time_measures[3] = stop - init;
    send_ipi_ap(39);
    copy(array, 0, bsp_temp, 0, *len / 2);
    copy(array, *len / 2, ap_temp, 0, *len / 2);
    { unsigned int start_high, start_low; __asm__ __volatile__ ( "mfence\n\t" "rdtsc\n\t" "mov %%edx, %0\n\t" "mov %%eax, %1\n\t" : "=r" (start_high), "=r" (start_low) : : "%eax" ); init = (((unsigned long long int) start_high) << 32) | (unsigned long long int) (start_low); };
    check_rax();
    { { unsigned int end_high, end_low; __asm__ __volatile__ ( "mfence\n\t" "rdtsc\n\t" "mov %%edx, %0\n\t" "mov %%eax, %1\n\t" : "=r" (end_high), "=r" (end_low) : : "%eax" ); stop = (((unsigned long long int) end_high) << 32) | (unsigned long long int) (end_low); } { unsigned int end_high, end_low; __asm__ __volatile__ ( "mfence\n\t" "rdtsc\n\t" "mov %%edx, %0\n\t" "mov %%eax, %1\n\t" : "=r" (end_high), "=r" (end_low) : : "%eax" ); stop = (((unsigned long long int) end_high) << 32) | (unsigned long long int) (end_low); } { unsigned int end_high, end_low; __asm__ __volatile__ ( "mfence\n\t" "rdtsc\n\t" "mov %%edx, %0\n\t" "mov %%eax, %1\n\t" : "=r" (end_high), "=r" (end_low) : : "%eax" ); stop = (((unsigned long long int) end_high) << 32) | (unsigned long long int) (end_low); } };
    time_measures[5] = stop - init;
}

canonical_original_code:
void measure_sync_ipis()
{
    unsigned int *len = (uint32_t *) 0x200600;
    unsigned int *array = (uint32_t *) (0x1e00000 + 32 * 0xa00000);
    unsigned int *bsp_temp = (uint32_t *) 0x1e00000;
    unsigned long *time_measures = (uint64_t *) 0x200d00;
    unsigned int *ap_temp = (uint32_t *) (0x1e00000 + 0xa00000);
    send_ipi_ap(39);
    heapsort(array, *len / 2);
    heapsort(array + *len / 2, *len / 2);
    { unsigned int start_high; unsigned int start_low; __asm__ __volatile__ ( "mfence\n\t" "rdtsc\n\t" "mov %%edx, %0\n\t" "mov %%eax, %1\n\t" : "=r" (start_high), "=r" (start_low) : : "%eax" ); init = (((unsigned long long) start_high) << 32) | (unsigned long long) (start_low); };
    check_rax();
    { { unsigned int end_high; unsigned int end_low; __asm__ __volatile__ ( "mfence\n\t" "rdtsc\n\t" "mov %%edx, %0\n\t" "mov %%eax, %1\n\t" : "=r" (end_high), "=r" (end_low) : : "%eax" ); stop = (((unsigned long long) end_high) << 32) | (unsigned long long) (end_low); } { unsigned int end_high; unsigned int end_low; __asm__ __volatile__ ( "mfence\n\t" "rdtsc\n\t" "mov %%edx, %0\n\t" "mov %%eax, %1\n\t" : "=r" (end_high), "=r" (end_low) : : "%eax" ); stop = (((unsigned long long) end_high) << 32) | (unsigned long long) (end_low); } { unsigned int end_high; unsigned int end_low; __asm__ __volatile__ ( "mfence\n\t" "rdtsc\n\t" "mov %%edx, %0\n\t" "mov %%eax, %1\n\t" : "=r" (end_high), "=r" (end_low) : : "%eax" ); stop = (((unsigned long long) end_high) << 32) | (unsigned long long) (end_low); } };
    time_measures[1] = stop - init;
    send_ipi_ap(39);
    limit_merge(array, bsp_temp, 0, (*len / 2) - 1, *len - 1, *len / 2);
    limit_merge_reverse(array, ap_temp, 0, (*len / 2) - 1, *len - 1, *len / 2);
    { unsigned int start_high; unsigned int start_low; __asm__ __volatile__ ( "mfence\n\t" "rdtsc\n\t" "mov %%edx, %0\n\t" "mov %%eax, %1\n\t" : "=r" (start_high), "=r" (start_low) : : "%eax" ); init = (((unsigned long long) start_high) << 32) | (unsigned long long) (start_low); };
    check_rax();
    { { unsigned int end_high; unsigned int end_low; __asm__ __volatile__ ( "mfence\n\t" "rdtsc\n\t" "mov %%edx, %0\n\t" "mov %%eax, %1\n\t" : "=r" (end_high), "=r" (end_low) : : "%eax" ); stop = (((unsigned long long) end_high) << 32) | (unsigned long long) (end_low); } { unsigned int end_high; unsigned int end_low; __asm__ __volatile__ ( "mfence\n\t" "rdtsc\n\t" "mov %%edx, %0\n\t" "mov %%eax, %1\n\t" : "=r" (end_high), "=r" (end_low) : : "%eax" ); stop = (((unsigned long long) end_high) << 32) | (unsigned long long) (end_low); } { unsigned int end_high; unsigned int end_low; __asm__ __volatile__ ( "mfence\n\t" "rdtsc\n\t" "mov %%edx, %0\n\t" "mov %%eax, %1\n\t" : "=r" (end_high), "=r" (end_low) : : "%eax" ); stop = (((unsigned long long) end_high) << 32) | (unsigned long long) (end_low); } };
    time_measures[3] = stop - init;
    send_ipi_ap(39);
    copy(array, 0, bsp_temp, 0, *len / 2);
    copy(array, *len / 2, ap_temp, 0, *len / 2);
    { unsigned int start_high; unsigned int start_low; __asm__ __volatile__ ( "mfence\n\t" "rdtsc\n\t" "mov %%edx, %0\n\t" "mov %%eax, %1\n\t" : "=r" (start_high), "=r" (start_low) : : "%eax" ); init = (((unsigned long long) start_high) << 32) | (unsigned long long) (start_low); };
    check_rax();
    { { unsigned int end_high; unsigned int end_low; __asm__ __volatile__ ( "mfence\n\t" "rdtsc\n\t" "mov %%edx, %0\n\t" "mov %%eax, %1\n\t" : "=r" (end_high), "=r" (end_low) : : "%eax" ); stop = (((unsigned long long) end_high) << 32) | (unsigned long long) (end_low); } { unsigned int end_high; unsigned int end_low; __asm__ __volatile__ ( "mfence\n\t" "rdtsc\n\t" "mov %%edx, %0\n\t" "mov %%eax, %1\n\t" : "=r" (end_high), "=r" (end_low) : : "%eax" ); stop = (((unsigned long long) end_high) << 32) | (unsigned long long) (end_low); } { unsigned int end_high; unsigned int end_low; __asm__ __volatile__ ( "mfence\n\t" "rdtsc\n\t" "mov %%edx, %0\n\t" "mov %%eax, %1\n\t" : "=r" (end_high), "=r" (end_low) : : "%eax" ); stop = (((unsigned long long) end_high) << 32) | (unsigned long long) (end_low); } };
    time_measures[5] = stop - init;
}


original_code:
void sum_vector_bsp()
{
    uint64_t *start = (uint64_t *) 0x200000;
    uint32_t *array = (uint32_t *) (0x1e00000 + 32 * 0xa00000);
    uint32_t *len = (uint32_t *) 0x200600;
    uint64_t *finish = (uint64_t *) 0x200800;
    clean_flags();
    *start = 1;
    for (uint32_t i = 0; i < *len / 2; ++i) {
        array[i]++;
    }
    while(!(*finish));
    clean_flags();
}

canonical_original_code:
void sum_vector_bsp()
{
    unsigned long *start = (uint64_t *) 0x200000;
    unsigned int *array = (uint32_t *) (0x1e00000 + 32 * 0xa00000);
    unsigned int *len = (uint32_t *) 0x200600;
    unsigned long *finish = (uint64_t *) 0x200800;
    clean_flags();
    *start = 1;
    for (unsigned int i = 0; i < *len / 2; ++i) {
        array[i]++;
    }
    while(!(*finish));
    clean_flags();
}

variable_types:
finish
unsigned long *


decompiled_code:
__int64 make_ap_jump()
{
char v1[2]; // [rsp+8h] [rbp-10h] BYREF
char v2; // [rsp+Ah] [rbp-Eh]

initialize_ipi_options(v1, 0LL, 39LL, 1LL);
v2 |= 0xCu;
send_ipi(v1);
wait_for_ipi_reception();
return print_string("Jumpeo?", 1LL, 0LL);
}

canonical_decompiled_code:
__int64 func9()
{
char v1[2]; // [rsp+8h] [rbp-10h] BYREF
char v2; // [rsp+Ah] [rbp-Eh]

initialize_ipi_options(v1, 0LL, 39LL, 1LL);
v2 |= 0xCu;
send_ipi(v1);
wait_for_ipi_reception();
return print_string("Jumpeo?", 1LL, 0LL);
}

original_code:
void make_ap_jump()
{
    intr_command_register icr;
    initialize_ipi_options(&icr, FIXED, 39, 1);
    icr.destination_shorthand = 3;
    send_ipi(&icr);
    wait_for_ipi_reception();
    print_string("Jumpeo?", 1, 0);
}

canonical_original_code:
void make_ap_jump()
{
    struct intr_command_register icr;
    initialize_ipi_options(&icr, FIXED, 39, 1);
    icr.destination_shorthand = 3;
    send_ipi(&icr);
    wait_for_ipi_reception();
    print_string("Jumpeo?", 1, 0);
}

variable_types: struct intr_command_register { unsigned char vector; unsigned char delivery_mode; unsigned char destination_mode; unsigned char delivery_status; unsigned char __reserved1; unsigned char level; unsigned char trigger_mode; unsigned char __reserved2; unsigned char destination_shorthand; unsigned char __reserved3; unsigned char __reserved4[4]; unsigned char destination_field; }


repo: JAChapmanII/bprime

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int64 v4; // rsi
int v5; // eax
__int64 v6; // rbp
unsigned __int64 v7; // r8
__int64 v8; // rdi

v4 = 512LL;
if ( argc > 1 )
{
v5 = atoi(argv[1]);
v4 = v5;
if ( !v5 )
v4 = 512LL;
}
PRIME_COUNT = v4 * v4;
MEM_REQUIREMENT = (((unsigned __int64)(v4 * v4 + 7) >> 3) + 1) >> 1;
printf("Prime count: %ld, bytes needed: %ld\n", v4 * v4, MEM_REQUIREMENT);
v6 = generatePrimes();
puts("Generated initial prime set...");
printf("%ld out of %ld numbers were prime\n", v6, PRIME_COUNT);
v7 = PRIME_COUNT - 1;
if ( (unsigned __int64)(PRIME_COUNT - 1) > 2 )
{
v8 = prime;
do
{
if ( isPrime(v8, v7) )
break;
v7 -= 2LL;
}
while ( v7 > 2 );
}
printf("Biggest prime: %ld\n", v7);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int64 v4; // rsi
int v5; // eax
__int64 v6; // rbp
unsigned __int64 v7; // r8
__int64 v8; // rdi

v4 = 512LL;
if ( argc > 1 )
{
v5 = atoi(argv[1]);
v4 = v5;
if ( !v5 )
v4 = 512LL;
}
PRIME_COUNT = v4 * v4;
MEM_REQUIREMENT = (((unsigned __int64)(v4 * v4 + 7) >> 3) + 1) >> 1;
printf("Prime count: %ld, bytes needed: %ld\n", v4 * v4, MEM_REQUIREMENT);
v6 = func11();
puts("Generated initial prime set...");
printf("%ld out of %ld numbers were prime\n", v6, PRIME_COUNT);
v7 = PRIME_COUNT - 1;
if ( (unsigned __int64)(PRIME_COUNT - 1) > 2 )
{
v8 = prime;
do
{
if ( func7(v8, v7) )
break;
v7 -= 2LL;
}
while ( v7 > 2 );
}
printf("Biggest prime: %ld\n", v7);
return 0;
}

original_code:
int main(int argc, char **argv) {
 size_t pCount, count = 512, i;
 if(argc > 1) {
  count = atoi(argv[1]);
  if(count <= 0)
   count = 512;
 }
 PRIME_COUNT = count * count;
 MEM_REQUIREMENT = (((PRIME_COUNT + 7) >> 3) + 1) >> 1;
 printf("Prime count: %ld, bytes needed: %ld\n",
   PRIME_COUNT, MEM_REQUIREMENT);
 pCount = generatePrimes();
 printf("Generated initial prime set...\n");
 printf("%ld out of %ld numbers were prime\n", pCount, PRIME_COUNT);
 for(i = PRIME_COUNT - 1; i > 2; i -= 2)
  if(isPrime(prime, i))
   break;
 printf("Biggest prime: %ld\n", i);
 return 0;
}

canonical_original_code:
int main(int argc, char **argv) {
 unsigned long pCount; unsigned long count = 512; unsigned long i;
 if(argc > 1) {
  count = atoi(argv[1]);
  if(count <= 0)
   count = 512;
 }
 PRIME_COUNT = count * count;
 MEM_REQUIREMENT = (((PRIME_COUNT + 7) >> 3) + 1) >> 1;
 printf("Prime count: %ld, bytes needed: %ld\n",
   PRIME_COUNT, MEM_REQUIREMENT);
 pCount = generatePrimes();
 printf("Generated initial prime set...\n");
 printf("%ld out of %ld numbers were prime\n", pCount, PRIME_COUNT);
 for(i = PRIME_COUNT - 1; i > 2; i -= 2)
  if(isPrime(prime, i))
   break;
 printf("Biggest prime: %ld\n", i);
 return 0;
}

variable_types: argc int

variable_types:
argv
char **

variable_types:
pCount
unsigned long

variable_types:
count
unsigned long

variable_types:
i
unsigned long


isPrime

original_code:
size_t isPrime(char *p, size_t x) {
 x = (x >> 1) - 1;
 return p[x >> 3] & (0x1 << (x % 8));
}

canonical_original_code:
unsigned long isPrime(char *p, unsigned long x) {
 x = (x >> 1) - 1;
 return p[x >> 3] & (0x1 << (x % 8));
}

variable_types:
p
char *

variable_types:
x
unsigned long

return_type: unsigned long


crossOut

decompiled_code:
void *__fastcall crossOut(void *a1)
{
unsigned __int64 v1; // rsi
__int64 v2; // rcx
unsigned __int64 v4; // r9

v1 = *(_QWORD *)a1;
v2 = i;
if ( *(_QWORD *)a1 )
{
v4 = i * (v1 / i);
if ( v1 > v4 )
v4 += i;
}
else
{
v4 = i * i;
}
if ( v4 <= i )
v4 += i;
for ( ; *((_QWORD *)a1 + 1) > v4; v4 += v2 )
{
if ( (v4 & 1) != 0 )
{
setNotPrime(prime, v4);
v2 = i;
}
}
return 0LL;
}

original_code:
void *crossOut(void *args) {
 size_t j;
 if(((size_t *)args)[0] == 0) {
  j = i * i;
 } else {
  j = (((size_t *)args)[0] / i) * i;
  if(j < ((size_t *)args)[0])
   j += i;
 }
 if(j <= i)
  j += i;
 if(((size_t *)args)[1] < j)
  return ((void *)0);
 for(; j < ((size_t *)args)[1]; j += i)
  if(j % 2)
   setNotPrime(prime, j);
 return ((void *)0);
}

canonical_original_code:
void *crossOut(void *args) {
 unsigned long j;
 if(((unsigned long *)args)[0] == 0) {
  j = i * i;
 } else {
  j = (((unsigned long *)args)[0] / i) * i;
  if(j < ((unsigned long *)args)[0])
   j += i;
 }
 if(j <= i)
  j += i;
 if(((unsigned long *)args)[1] < j)
  return ((void *)0);
 for(; j < ((unsigned long *)args)[1]; j += i)
  if(j % 2)
   setNotPrime(prime, j);
 return ((void *)0);
}

variable_types:
args
void *

variable_types:
j
unsigned long


generatePrimes

decompiled_code:
__int64 generatePrimes()
{
double v0; // xmm0_8
double v1; // r14
__int64 v2; // r9
size_t v4; // r12
__int64 v5; // rbx
__int64 v6; // rbp
__int64 *v7; // r12
unsigned __int64 v8; // r13
__int64 v9; // rdx
__int64 v10; // rsi
double v11; // xmm0_8
unsigned __int64 v12; // rbp
unsigned __int64 i; // rsi
pthread_t *v14; // rbx
__int64 v15; // r12
__int64 v16; // r12
unsigned __int64 v17; // r10
unsigned __int64 v18; // rsi
__int64 v19; // r11
__int64 v20; // rcx
unsigned __int64 v21; // rax
__int64 v22; // r8
__int64 v23; // r9
unsigned __int64 v24; // r8
__int64 v25; // rdi
__int64 v26; // rax
__int64 v27; // r9
__int64 v28; // r8
unsigned __int64 v29; // r10
pthread_t th[16]; // [rsp+0h] [rbp-1A8h] BYREF
_QWORD v31[31]; // [rsp+80h] [rbp-128h] BYREF
__int64 v32; // [rsp+178h] [rbp-30h]

if ( PRIME_COUNT < 0 )
v0 = (double)(int)(PRIME_COUNT & 1 | ((unsigned __int64)PRIME_COUNT >> 1))
+ (double)(int)(PRIME_COUNT & 1 | ((unsigned __int64)PRIME_COUNT >> 1));
else
v0 = (double)(int)PRIME_COUNT;
if ( v0 < 0.0 )
v1 = sqrt(v0);
else
v1 = sqrt(v0);
v2 = -2LL;
if ( !prime )
{
v4 = MEM_REQUIREMENT;
prime = (__int64)malloc(MEM_REQUIREMENT);
if ( !prime )
{
fwrite("Could not allocate enough memory\n", 1uLL, 0x21uLL, _bss_start);
exit(1);
}
v5 = 0LL;
v6 = 0LL;
memset((void *)prime, 255, v4);
v7 = v31;
v8 = (((unsigned __int64)PRIME_COUNT >> 4) + 7) & 0xFFFFFFFFFFFFFFF8LL;
do
{
*v7 = v5;
v9 = v5;
v5 += v8;
v10 = v6;
v7[1] = v5;
++v6;
v7 += 2;
printf("t%ld: [%ld, %ld]\n", v10, v9, v5);
}
while ( v6 != 16 );
v11 = v1 + 1.0;
if ( v1 + 1.0 >= 9.223372036854776e18 )
v12 = (unsigned int)(int)(v11 - 9.223372036854776e18) ^ 0x8000000000000000LL;
else
v12 = (unsigned int)(int)v11;
v31[0] = 0LL;
v32 = PRIME_COUNT;
printf("m: %ld\n", v12);
::i = 3LL;
if ( v12 > 3 )
{
for ( i = 3LL; i < v12; ::i = i )
{
if ( isPrime(prime, i) )
{
v14 = th;
v15 = 0LL;
while ( !pthread_create(v14, 0LL, crossOut, &v31[2 * v15]) )
{
++v15;
++v14;
if ( v15 == 16 )
{
v16 = 0LL;
while ( !pthread_join(th[v16], 0LL) )
{
if ( ++v16 == 16 )
goto LABEL_14;
}
fprintf(_bss_start, "thread %ld join failed\n", v16);
LABEL_23:
exit(1);
}
}
fprintf(_bss_start, "thread creation %ld failed!\n", v15);
goto LABEL_23;
}
LABEL_14:
i = ::i + 2;
}
}
v17 = PRIME_COUNT;
::i = 0LL;
v18 = (unsigned __int64)(PRIME_COUNT - 2) >> 7;
if ( v18 )
{
v19 = prime;
v20 = 0LL;
do
{
v21 = countSet(*(_QWORD *)(v19 + 8 * v20));
::i = v20;
v2 = v21 + v23;
}
while ( v18 != v20 );
v24 = (v22 & 0xFFFFFFFFFFFFFF80LL) + 3;
}
else
{
v2 = 1LL;
v24 = 3LL;
}
::i = v24;
if ( v24 < v17 )
{
v25 = prime;
do
{
v26 = isPrime(v25, v24);
v2 = v27 - ((v26 == 0) - 1LL);
v24 = v28 + 2;
::i = v24;
}
while ( v24 < v29 );
}
}
return v2;
}

canonical_decompiled_code:
__int64 func11()
{
double v0; // xmm0_8
double v1; // r14
__int64 v2; // r9
size_t v4; // r12
__int64 v5; // rbx
__int64 v6; // rbp
__int64 *v7; // r12
unsigned __int64 v8; // r13
__int64 v9; // rdx
__int64 v10; // rsi
double v11; // xmm0_8
unsigned __int64 v12; // rbp
unsigned __int64 i; // rsi
pthread_t *v14; // rbx
__int64 v15; // r12
__int64 v16; // r12
unsigned __int64 v17; // r10
unsigned __int64 v18; // rsi
__int64 v19; // r11
__int64 v20; // rcx
unsigned __int64 v21; // rax
__int64 v22; // r8
__int64 v23; // r9
unsigned __int64 v24; // r8
__int64 v25; // rdi
__int64 v26; // rax
__int64 v27; // r9
__int64 v28; // r8
unsigned __int64 v29; // r10
pthread_t th[16]; // [rsp+0h] [rbp-1A8h] BYREF
_QWORD v31[31]; // [rsp+80h] [rbp-128h] BYREF
__int64 v32; // [rsp+178h] [rbp-30h]

if ( PRIME_COUNT < 0 )
v0 = (double)(int)(PRIME_COUNT & 1 | ((unsigned __int64)PRIME_COUNT >> 1))
+ (double)(int)(PRIME_COUNT & 1 | ((unsigned __int64)PRIME_COUNT >> 1));
else
v0 = (double)(int)PRIME_COUNT;
if ( v0 < 0.0 )
v1 = sqrt(v0);
else
v1 = sqrt(v0);
v2 = -2LL;
if ( !prime )
{
v4 = MEM_REQUIREMENT;
prime = (__int64)malloc(MEM_REQUIREMENT);
if ( !prime )
{
fwrite("Could not allocate enough memory\n", 1uLL, 0x21uLL, _bss_start);
exit(1);
}
v5 = 0LL;
v6 = 0LL;
memset((void *)prime, 255, v4);
v7 = v31;
v8 = (((unsigned __int64)PRIME_COUNT >> 4) + 7) & 0xFFFFFFFFFFFFFFF8LL;
do
{
*v7 = v5;
v9 = v5;
v5 += v8;
v10 = v6;
v7[1] = v5;
++v6;
v7 += 2;
printf("t%ld: [%ld, %ld]\n", v10, v9, v5);
}
while ( v6 != 16 );
v11 = v1 + 1.0;
if ( v1 + 1.0 >= 9.223372036854776e18 )
v12 = (unsigned int)(int)(v11 - 9.223372036854776e18) ^ 0x8000000000000000LL;
else
v12 = (unsigned int)(int)v11;
v31[0] = 0LL;
v32 = PRIME_COUNT;
printf("m: %ld\n", v12);
::i = 3LL;
if ( v12 > 3 )
{
for ( i = 3LL; i < v12; ::i = i )
{
if ( func7(prime, i) )
{
v14 = th;
v15 = 0LL;
while ( !pthread_create(v14, 0LL, crossOut, &v31[2 * v15]) )
{
++v15;
++v14;
if ( v15 == 16 )
{
v16 = 0LL;
while ( !pthread_join(th[v16], 0LL) )
{
if ( ++v16 == 16 )
goto LABEL_14;
}
fprintf(_bss_start, "thread %ld join failed\n", v16);
LABEL_23:
exit(1);
}
}
fprintf(_bss_start, "thread creation %ld failed!\n", v15);
goto LABEL_23;
}
LABEL_14:
i = ::i + 2;
}
}
v17 = PRIME_COUNT;
::i = 0LL;
v18 = (unsigned __int64)(PRIME_COUNT - 2) >> 7;
if ( v18 )
{
v19 = prime;
v20 = 0LL;
do
{
v21 = func10(*(_QWORD *)(v19 + 8 * v20));
::i = v20;
v2 = v21 + v23;
}
while ( v18 != v20 );
v24 = (v22 & 0xFFFFFFFFFFFFFF80LL) + 3;
}
else
{
v2 = 1LL;
v24 = 3LL;
}
::i = v24;
if ( v24 < v17 )
{
v25 = prime;
do
{
v26 = func7(v25, v24);
v2 = v27 - ((v26 == 0) - 1LL);
v24 = v28 + 2;
::i = v24;
}
while ( v24 < v29 );
}
}
return v2;
}

original_code:
size_t generatePrimes() {
 size_t pCount = 1, args[16 << 1], m = sqrt(PRIME_COUNT) + 1, j, s;
 pthread_t threads[16];
 if(prime != ((void *)0))
  return -2;
 prime = malloc(MEM_REQUIREMENT);
 if(!prime) {
  fprintf(stderr, "Could not allocate enough memory\n");
  exit(1);
 }
 memset(prime, 0xff, MEM_REQUIREMENT);
 s = (((PRIME_COUNT / 16 + 7) >> 3) << 3);
 for(j = 0; j < 16; ++j) {
  args[(j << 1) + 0] = j * s;
  args[(j << 1) + 1] = j * s + s;
  printf("t%ld: [%ld, %ld]\n", j, args[(j << 1)], args[(j << 1) + 1]);
 }
 args[0] = 0;
 args[(16 << 1) - 1] = PRIME_COUNT;
 printf("m: %ld\n", m);
 for(i = 3; i < m; i += 2) {
  if(!isPrime(prime, i))
   continue;
  for(j = 0; j < 16; ++j)
   if(pthread_create(&threads[j], ((void *)0),
      crossOut, (void *)(&args[j << 1]))) {
    fprintf(stderr, "thread creation %ld failed!\n", j);
    exit(1);
   }
  for(j = 0; j < 16; ++j)
   if(pthread_join(threads[j], ((void *)0))) {
    fprintf(stderr, "thread %ld join failed\n", j);
    exit(1);
   }
 }
 for(i = 0; i < ((PRIME_COUNT - 2) >> 7); ++i)
  pCount += countSet(((uint64_t *)prime)[i]);
 if(!i)
  i = 3;
 else
  i <<= 7, i += 3;
 for(; i < PRIME_COUNT; i += 2)
  if(isPrime(prime, i))
   pCount++;
 return pCount;
}

canonical_original_code:
unsigned long generatePrimes() {
 unsigned long pCount = 1; unsigned long args[-1]; unsigned long m = sqrt(PRIME_COUNT) + 1; unsigned long j; unsigned long s;
 unsigned long threads[16];
 if(prime != ((void *)0))
  return -2;
 prime = malloc(MEM_REQUIREMENT);
 if(!prime) {
  fprintf(stderr, "Could not allocate enough memory\n");
  exit(1);
 }
 memset(prime, 0xff, MEM_REQUIREMENT);
 s = (((PRIME_COUNT / 16 + 7) >> 3) << 3);
 for(j = 0; j < 16; ++j) {
  args[(j << 1) + 0] = j * s;
  args[(j << 1) + 1] = j * s + s;
  printf("t%ld: [%ld, %ld]\n", j, args[(j << 1)], args[(j << 1) + 1]);
 }
 args[0] = 0;
 args[(16 << 1) - 1] = PRIME_COUNT;
 printf("m: %ld\n", m);
 for(i = 3; i < m; i += 2) {
  if(!isPrime(prime, i))
   continue;
  for(j = 0; j < 16; ++j)
   if(pthread_create(&threads[j], ((void *)0),
      crossOut, (void *)(&args[j << 1]))) {
    fprintf(stderr, "thread creation %ld failed!\n", j);
    exit(1);
   }
  for(j = 0; j < 16; ++j)
   if(pthread_join(threads[j], ((void *)0))) {
    fprintf(stderr, "thread %ld join failed\n", j);
    exit(1);
   }
 }
 for(i = 0; i < ((PRIME_COUNT - 2) >> 7); ++i)
  pCount += countSet(((unsigned long *)prime)[i]);
 if(!i)
  i = 3;
 else
  i <<= 7, i += 3;
 for(; i < PRIME_COUNT; i += 2)
  if(isPrime(prime, i))
   pCount++;
 return pCount;
}

variable_types:
args
unsigned long [-1]

variable_types:
m
unsigned long

variable_types:
s
unsigned long

variable_types:
threads
unsigned long [16]


decompiled_code:
int __fastcall TestSlaveB_heartbeatError(__int64 a1, unsigned __int8 a2)
{
return printf("TestSlaveB_heartbeatError %d\n", a2);
}

canonical_decompiled_code:
int __fastcall func0(__int64 a1, unsigned __int8 a2)
{
return printf("TestSlaveB_heartbeatError %d\n", a2);
}

original_code:
void TestSlaveB_heartbeatError(CO_Data* d, unsigned char heartbeatID)
{
 printf ("TestSlaveB_heartbeatError %d\n", heartbeatID);
}

canonical_original_code:
void TestSlaveB_heartbeatError(struct struct_CO_Data *d, unsigned char heartbeatID)
{
 printf ("TestSlaveB_heartbeatError %d\n", heartbeatID);
}

variable_types: struct struct_CO_Data { unsigned char *bDeviceNodeId; struct td_indextable { struct td_subindex { unsigned char bAccessType; unsigned char bDataType; unsigned long size; void *pObject; } *pSubindex; unsigned char bSubCount; unsigned short index; } *objdict; struct struct_s_PDO_status { unsigned char transmit_type_parameter; short event_timer; short inhibit_timer; struct Message { unsigned short cob_id; unsigned char rtr; unsigned char len; unsigned char data[8]; } last_message; } *PDO_status; short *RxPDO_EventTimers; void (*RxPDO_EventTimers_Handler)(struct struct_CO_Data *, unsigned long); struct s_quick_index { unsigned short SDO_SVR; unsigned short SDO_CLT; unsigned short PDO_RCV; unsigned short PDO_RCV_MAP; unsigned short PDO_TRS; unsigned short PDO_TRS_MAP; } *firstIndex; struct s_quick_index *lastIndex; unsigned short *ObjdictSize; unsigned char *iam_a_slave; unsigned long (*valueRangeTest)(unsigned char typeValue, void *Value); struct struct_s_transfer { unsigned char CliServNbr; unsigned char whoami; unsigned char state; unsigned char toggle; unsigned long abortCode; unsigned short index; unsigned char subIndex; unsigned long count; unsigned long offset; unsigned char data[32]; unsigned char peerCRCsupport; unsigned char blksize; unsigned char ackseq; unsigned long objsize; unsigned char lastblockoffset; unsigned char seqno; unsigned char endfield; enum rxStep_t { RXSTEP_INIT=0, RXSTEP_STARTED=1, RXSTEP_END=2 } rxstep; unsigned char tmpData[8]; unsigned char dataType; short timer; void (*Callback)(struct struct_CO_Data *d, unsigned char nodeId); } transfers[4]; enum enum_nodeState { Initialisation=0, Disconnected=1, Connecting=2, Preparing=2, Stopped=4, Operational=5, Pre_operational=127, Unknown_state=15 } nodeState; struct s_state_communication { char csBoot_Up; char csSDO; char csEmergency; char csSYNC; char csLifeGuard; char csPDO; char csLSS; } CurrentCommunicationState; void (*initialisation)(struct struct_CO_Data *); void (*preOperational)(struct struct_CO_Data *); void (*operational)(struct struct_CO_Data *); void (*stopped)(struct struct_CO_Data *); void (*NMT_Slave_Node_Reset_Callback)(struct struct_CO_Data *); void (*NMT_Slave_Communications_Reset_Callback)(struct struct_CO_Data *); unsigned char *ConsumerHeartbeatCount; unsigned long *ConsumerHeartbeatEntries; short *ConsumerHeartBeatTimers; unsigned short *ProducerHeartBeatTime; short ProducerHeartBeatTimer; void (*heartbeatError)(struct struct_CO_Data *, unsigned char); enum enum_nodeState { Initialisation=0, Disconnected=1, Connecting=2, Preparing=2, Stopped=4, Operational=5, Pre_operational=127, Unknown_state=15 } NMTable[128]; short GuardTimeTimer; short LifeTimeTimer; void (*nodeguardError)(struct struct_CO_Data *, unsigned char); unsigned short *GuardTime; unsigned char *LifeTimeFactor; unsigned char nodeGuardStatus[128]; short syncTimer; unsigned long *COB_ID_Sync; unsigned long *Sync_Cycle_Period; void (*post_sync)(struct struct_CO_Data *); void (*post_TPDO)(struct struct_CO_Data *); void (*post_SlaveBootup)(struct struct_CO_Data *, unsigned char); void (*post_SlaveStateChange)(struct struct_CO_Data *, unsigned char, enum enum_nodeState { Initialisation=0, Disconnected=1, Connecting=2, Preparing=2, Stopped=4, Operational=5, Pre_operational=127, Unknown_state=15 }); unsigned char toggle; void *canHandle; struct td_indextable *(*scanIndexOD)(unsigned short wIndex, unsigned long *errorCode, unsigned long (***Callback)(struct struct_CO_Data *d, struct td_indextable *, unsigned char bSubindex)); void (*storeODSubIndex)(struct struct_CO_Data *d, unsigned short wIndex, unsigned char bSubindex); struct td_indextable *dcf_odentry; unsigned char *dcf_cursor; unsigned long dcf_entries_count; unsigned char dcf_status; unsigned long dcf_size; unsigned char *dcf_data; enum enum_errorState { Error_free=0, Error_occurred=1 } error_state; unsigned char error_history_size; unsigned char *error_number; unsigned long *error_first_element; unsigned char *error_register; unsigned long *error_cobid; struct s_errors { unsigned short errCode; unsigned char errRegMask; unsigned char active; } error_data[8]; void (*post_emcy)(struct struct_CO_Data *d, unsigned char nodeID, unsigned short errCode, unsigned char errReg); } *

variable_types:
heartbeatID
unsigned char

user_defined_types: struct struct_CO_Data { unsigned char *bDeviceNodeId; struct td_indextable *objdict; struct struct_s_PDO_status *PDO_status; short *RxPDO_EventTimers; void (*RxPDO_EventTimers_Handler)(struct struct_CO_Data *, unsigned long); struct s_quick_index *firstIndex; struct s_quick_index *lastIndex; unsigned short *ObjdictSize; unsigned char *iam_a_slave; unsigned long (*valueRangeTest)(unsigned char typeValue, void *Value); struct struct_s_transfer transfers[4]; enum enum_nodeState nodeState; struct s_state_communication CurrentCommunicationState; void (*initialisation)(struct struct_CO_Data *); void (*preOperational)(struct struct_CO_Data *); void (*operational)(struct struct_CO_Data *); void (*stopped)(struct struct_CO_Data *); void (*NMT_Slave_Node_Reset_Callback)(struct struct_CO_Data *); void (*NMT_Slave_Communications_Reset_Callback)(struct struct_CO_Data *); unsigned char *ConsumerHeartbeatCount; unsigned long *ConsumerHeartbeatEntries; short *ConsumerHeartBeatTimers; unsigned short *ProducerHeartBeatTime; short ProducerHeartBeatTimer; void (*heartbeatError)(struct struct_CO_Data *, unsigned char); enum enum_nodeState NMTable[128]; short GuardTimeTimer; short LifeTimeTimer; void (*nodeguardError)(struct struct_CO_Data *, unsigned char); unsigned short *GuardTime; unsigned char *LifeTimeFactor; unsigned char nodeGuardStatus[128]; short syncTimer; unsigned long *COB_ID_Sync; unsigned long *Sync_Cycle_Period; void (*post_sync)(struct struct_CO_Data *); void (*post_TPDO)(struct struct_CO_Data *); void (*post_SlaveBootup)(struct struct_CO_Data *, unsigned char); void (*post_SlaveStateChange)(struct struct_CO_Data *, unsigned char, enum enum_nodeState); unsigned char toggle; void *canHandle; struct td_indextable *(*scanIndexOD)(unsigned short wIndex, unsigned long *errorCode, unsigned long (***Callback)(struct struct_CO_Data *d, struct td_indextable *, unsigned char bSubindex)); void (*storeODSubIndex)(struct struct_CO_Data *d, unsigned short wIndex, unsigned char bSubindex); struct td_indextable *dcf_odentry; unsigned char *dcf_cursor; unsigned long dcf_entries_count; unsigned char dcf_status; unsigned long dcf_size; unsigned char *dcf_data; enum enum_errorState error_state; unsigned char error_history_size; unsigned char *error_number; unsigned long *error_first_element; unsigned char *error_register; unsigned long *error_cobid; struct s_errors error_data[8]; void (*post_emcy)(struct struct_CO_Data *d, unsigned char nodeID, unsigned short errCode, unsigned char errReg); }

user_defined_types: struct td_indextable { struct td_subindex *pSubindex; unsigned char bSubCount; unsigned short index; }

user_defined_types: struct struct_s_PDO_status { unsigned char transmit_type_parameter; short event_timer; short inhibit_timer; struct Message last_message; }

user_defined_types: struct struct_s_transfer { unsigned char CliServNbr; unsigned char whoami; unsigned char state; unsigned char toggle; unsigned long abortCode; unsigned short index; unsigned char subIndex; unsigned long count; unsigned long offset; unsigned char data[32]; unsigned char peerCRCsupport; unsigned char blksize; unsigned char ackseq; unsigned long objsize; unsigned char lastblockoffset; unsigned char seqno; unsigned char endfield; enum rxStep_t rxstep; unsigned char tmpData[8]; unsigned char dataType; short timer; void (*Callback)(struct struct_CO_Data *d, unsigned char nodeId); }


decompiled_code:
int TestSlaveB_initialisation()
{
return puts("TestSlaveB_initialisation");
}

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

original_code:
void TestSlaveB_initialisation(CO_Data* d)
{
 printf ("TestSlaveB_initialisation\n");
}

canonical_original_code:
void TestSlaveB_initialisation(struct struct_CO_Data *d)
{
 printf ("TestSlaveB_initialisation\n");
}

user_defined_types: enum enum_nodeState { Initialisation=0, Disconnected=1, Connecting=2, Preparing=2, Stopped=4, Operational=5, Pre_operational=127, Unknown_state=15 }

user_defined_types: struct s_state_communication { char csBoot_Up; char csSDO; char csEmergency; char csSYNC; char csLifeGuard; char csPDO; char csLSS; }

user_defined_types: enum enum_errorState { Error_free=0, Error_occurred=1 }

user_defined_types: struct s_quick_index { unsigned short SDO_SVR; unsigned short SDO_CLT; unsigned short PDO_RCV; unsigned short PDO_RCV_MAP; unsigned short PDO_TRS; unsigned short PDO_TRS_MAP; }

user_defined_types: struct s_errors { unsigned short errCode; unsigned char errRegMask; unsigned char active; }

user_defined_types: struct Message { unsigned short cob_id; unsigned char rtr; unsigned char len; unsigned char data[8]; }

user_defined_types: enum rxStep_t { RXSTEP_INIT=0, RXSTEP_STARTED=1, RXSTEP_END=2 }

user_defined_types: struct td_subindex { unsigned char bAccessType; unsigned char bDataType; unsigned long size; void *pObject; }


decompiled_code:
int TestSlaveB_preOperational()
{
return puts("TestSlaveB_preOperational");
}

canonical_decompiled_code:
int func2()
{
return puts("TestSlaveB_preOperational");
}

original_code:
void TestSlaveB_preOperational(CO_Data* d)
{
 printf ("TestSlaveB_preOperational\n");
}

canonical_original_code:
void TestSlaveB_preOperational(struct struct_CO_Data *d)
{
 printf ("TestSlaveB_preOperational\n");
}


decompiled_code:
int TestSlaveB_operational()
{
return puts("TestSlaveB_operational");
}

canonical_decompiled_code:
int func3()
{
return puts("TestSlaveB_operational");
}

original_code:
void TestSlaveB_operational(CO_Data* d)
{
 printf ("TestSlaveB_operational\n");
}

canonical_original_code:
void TestSlaveB_operational(struct struct_CO_Data *d)
{
 printf ("TestSlaveB_operational\n");
}


decompiled_code:
int TestSlaveB_stopped()
{
return puts("TestSlaveB_stopped");
}

canonical_decompiled_code:
int func4()
{
return puts("TestSlaveB_stopped");
}

original_code:
void TestSlaveB_stopped(CO_Data* d)
{
 printf ("TestSlaveB_stopped\n");
}

canonical_original_code:
void TestSlaveB_stopped(struct struct_CO_Data *d)
{
 printf ("TestSlaveB_stopped\n");
}


decompiled_code:
int TestSlaveB_post_sync()
{
return puts("TestSlaveB_post_sync");
}

canonical_decompiled_code:
int func5()
{
return puts("TestSlaveB_post_sync");
}

original_code:
void TestSlaveB_post_sync(CO_Data* d)
{
      printf ("TestSlaveB_post_sync\n");
}

canonical_original_code:
void TestSlaveB_post_sync(struct struct_CO_Data *d)
{
      printf ("TestSlaveB_post_sync\n");
}


decompiled_code:
_WORD *TestSlaveB_post_TPDO()
{
_WORD *result; // rax

puts("TestSlaveB_post_TPDO");
result = &SlaveBMap1;
SlaveBMap1 += 16;
return result;
}

canonical_decompiled_code:
_WORD *func6()
{
_WORD *result; // rax

puts("TestSlaveB_post_TPDO");
result = &SlaveBMap1;
SlaveBMap1 += 16;
return result;
}

original_code:
void TestSlaveB_post_TPDO(CO_Data* d)
{
 printf ("TestSlaveB_post_TPDO\n");
 SlaveBMap1+=16;
}

canonical_original_code:
void TestSlaveB_post_TPDO(struct struct_CO_Data *d)
{
 printf ("TestSlaveB_post_TPDO\n");
 SlaveBMap1+=16;
}


decompiled_code:
int __fastcall TestSlaveB_storeODSubIndex(__int64 a1, unsigned __int16 a2, unsigned __int8 a3)
{
return printf("TestSlaveB_storeODSubIndex : %4.4x %2.2x\n", a2, a3);
}

canonical_decompiled_code:
int __fastcall func7(__int64 a1, unsigned __int16 a2, unsigned __int8 a3)
{
return printf("TestSlaveB_storeODSubIndex : %4.4x %2.2x\n", a2, a3);
}

original_code:
void TestSlaveB_storeODSubIndex(CO_Data* d, unsigned short wIndex, unsigned char bSubindex)
{
 printf ("TestSlaveB_storeODSubIndex : %4.4x %2.2x\n", wIndex, bSubindex);
}

canonical_original_code:
void TestSlaveB_storeODSubIndex(struct struct_CO_Data *d, unsigned short wIndex, unsigned char bSubindex)
{
 printf ("TestSlaveB_storeODSubIndex : %4.4x %2.2x\n", wIndex, bSubindex);
}

variable_types:
wIndex
unsigned short

variable_types:
bSubindex
unsigned char


decompiled_code:
int __fastcall TestSlaveB_post_emcy(__int64 a1, unsigned __int8 a2, unsigned __int16 a3, unsigned __int8 a4)
{
return printf("SlaveB received EMCY message. Node: %2.2x ErrorCode: %4.4x ErrorRegister: %2.2x\n", a2, a3, a4);
}

canonical_decompiled_code:
int __fastcall func8(__int64 a1, unsigned __int8 a2, unsigned __int16 a3, unsigned __int8 a4)
{
return printf("SlaveB received EMCY message. Node: %2.2x ErrorCode: %4.4x ErrorRegister: %2.2x\n", a2, a3, a4);
}

original_code:
void TestSlaveB_post_emcy(CO_Data* d, unsigned char nodeID, unsigned short errCode, unsigned char errReg)
{
 printf ("SlaveB received EMCY message. Node: %2.2x  ErrorCode: %4.4x  ErrorRegister: %2.2x\n", nodeID, errCode, errReg);
}

canonical_original_code:
void TestSlaveB_post_emcy(struct struct_CO_Data *d, unsigned char nodeID, unsigned short errCode, unsigned char errReg)
{
 printf ("SlaveB received EMCY message. Node: %2.2x  ErrorCode: %4.4x  ErrorRegister: %2.2x\n", nodeID, errCode, errReg);
}

variable_types:
nodeID
unsigned char

variable_types:
errCode
unsigned short

variable_types:
errReg
unsigned char