decompiled_code:
_BOOL8 __fastcall test_consumer_thread(__int64 a1)
{
_DWORD *v1; // rbp
_BOOL8 result; // rax
__int64 v3[3]; // [rsp+8h] [rbp-18h] BYREF

v1 = *(_DWORD **)a1;
*(_QWORD *)(a1 + 24) = 0LL;
while ( !*(_DWORD *)(a1 + 32) )
{
if ( !(unsigned int)rte_ring_sc_dequeue(v1, v3) )
*(_QWORD *)(a1 + 24) += v3[0];
}
while ( 1 )
{
result = rte_ring_empty((__int64)v1);
if ( result )
break;
if ( !(unsigned int)rte_ring_sc_dequeue(v1, v3) )
*(_QWORD *)(a1 + 24) += v3[0];
}
*(_DWORD *)(a1 + 16) = 1;
return result;
}

canonical_decompiled_code:
_BOOL8 __fastcall func6(__int64 a1)
{
_DWORD *v1; // rbp
_BOOL8 result; // rax
__int64 v3[3]; // [rsp+8h] [rbp-18h] BYREF

v1 = *(_DWORD **)a1;
*(_QWORD *)(a1 + 24) = 0LL;
while ( !*(_DWORD *)(a1 + 32) )
{
if ( !(unsigned int)func5(v1, v3) )
*(_QWORD *)(a1 + 24) += v3[0];
}
while ( 1 )
{
result = func0((__int64)v1);
if ( result )
break;
if ( !(unsigned int)func5(v1, v3) )
*(_QWORD *)(a1 + 24) += v3[0];
}
*(_DWORD *)(a1 + 16) = 1;
return result;
}

original_code:
static void
test_consumer_thread(void *v)
{
    struct Test *test = (struct Test *)v;
    struct rte_ring *ring = test->ring;
    int err;
    test->total_count = 0;
    while (!test->not_active) {
        Element e;
        err = rte_ring_sc_dequeue(ring, (void**)&e);
        if (err == 0)
            test->total_count += e;
        else {
            ;
        }
    }
    while (!rte_ring_empty(ring)) {
        Element e;
        err = rte_ring_sc_dequeue(ring, (void**)&e);
        if (err == 0)
            test->total_count += e;
        else {
            ;
        }
    }
    test->consumer_done = 1;
}

canonical_original_code:
static void test_consumer_thread(void *v)
{
    struct Test *test = (struct Test *)v;
    struct rte_ring *ring = test->ring;
    int err;
    test->total_count = 0;
    while (!test->not_active) {
        unsigned long e;
        err = rte_ring_sc_dequeue(ring, (void **)&e);
        if (err == 0)
            test->total_count += e;
        else {
            ;
        }
    }
    while (!rte_ring_empty(ring)) {
        unsigned long e;
        err = rte_ring_sc_dequeue(ring, (void **)&e);
        if (err == 0)
            test->total_count += e;
        else {
            ;
        }
    }
    test->consumer_done = 1;
}

variable_types:
v
void *

variable_types: struct Test { struct rte_ring { int flags; struct prod { unsigned int watermark; unsigned int sp_enqueue; unsigned int size; unsigned int mask; unsigned int head; unsigned int tail; } prod; struct cons { unsigned int sc_dequeue; unsigned int size; unsigned int mask; unsigned int head; unsigned int tail; } cons; void *ring[1]; } *ring; unsigned int producer_started; unsigned int producer_done; unsigned int consumer_done; unsigned long long total_count; int not_active; unsigned int test_count; } *

variable_types: err int

variable_types:
e
unsigned long


repo: robertdavidgraham/masscan

decompiled_code:
__int64 __fastcall test_producer_thread(__int64 a1)
{
_DWORD *v1; // rbp
__int64 v2; // rbx
__int64 result; // rax

v1 = *(_DWORD **)a1;
_InterlockedAdd((volatile signed __int32 *)(a1 + 8), 1u);
v2 = 1000LL;
do
{
do
result = rte_ring_sp_enqueue(v1, v2);
while ( (_DWORD)result );
--v2;
}
while ( v2 );
_InterlockedAdd((volatile signed __int32 *)(a1 + 12), 1u);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func10(__int64 a1)
{
_DWORD *v1; // rbp
__int64 v2; // rbx
__int64 result; // rax

v1 = *(_DWORD **)a1;
_InterlockedAdd((volatile signed __int32 *)(a1 + 8), 1u);
v2 = 1000LL;
do
{
do
result = func9(v1, v2);
while ( (_DWORD)result );
--v2;
}
while ( v2 );
_InterlockedAdd((volatile signed __int32 *)(a1 + 12), 1u);
return result;
}

original_code:
static void
test_producer_thread(void *v)
{
    struct Test *test = (struct Test *)v;
    unsigned i = 1000;
    struct rte_ring *ring = test->ring;
    __sync_add_and_fetch((volatile int*)(&test->producer_started), (int)(1));;
    while (i) {
        int err;
        for (;;) {
            err = rte_ring_sp_enqueue(ring, (void*)(size_t)i);
            if (err == 0)
                break;
        }
        i--;
    }
    __sync_add_and_fetch((volatile int*)(&test->producer_done), (int)(1));;
}

canonical_original_code:
static void test_producer_thread(void *v)
{
    struct Test *test = (struct Test *)v;
    unsigned int i = 1000;
    struct rte_ring *ring = test->ring;
    __sync_add_and_fetch((int *)(&test->producer_started), (int)(1));;
    while (i) {
        int err;
        for (;;) {
            err = rte_ring_sp_enqueue(ring, (void *)(unsigned long)i);
            if (err == 0)
                break;
        }
        i--;
    }
    __sync_add_and_fetch((int *)(&test->producer_done), (int)(1));;
}

variable_types:
i
unsigned int

variable_types: struct rte_ring { int flags; struct prod { unsigned int watermark; unsigned int sp_enqueue; unsigned int size; unsigned int mask; unsigned int head; unsigned int tail; } prod; struct cons { unsigned int sc_dequeue; unsigned int size; unsigned int mask; unsigned int head; unsigned int tail; } cons; void *ring[1]; } *

return_type: void

user_defined_types: struct Test { struct rte_ring *ring; unsigned int producer_started; unsigned int producer_done; unsigned int consumer_done; unsigned long long total_count; int not_active; unsigned int test_count; }

user_defined_types: struct rte_ring { int flags; struct prod prod; struct cons cons; void *ring[1]; }


decompiled_code:
__int64 __fastcall run_test(__int64 a1)
{
*(_QWORD *)a1 = 0LL;
*(_QWORD *)(a1 + 8) = 0LL;
*(_QWORD *)(a1 + 16) = 0LL;
*(_QWORD *)(a1 + 24) = 0LL;
*(_QWORD *)(a1 + 32) = 0LL;
*(_QWORD *)a1 = rte_ring_create(0x10u, 3u);
pixie_begin_thread(test_producer_thread, 0LL, a1);
while ( !*(_DWORD *)(a1 + 8) )
pixie_usleep(10LL);
pixie_begin_thread(test_consumer_thread, 0LL, a1);
while ( !*(_DWORD *)(a1 + 12) )
pixie_usleep(10LL);
*(_DWORD *)(a1 + 32) = 1;
while ( !*(_DWORD *)(a1 + 16) )
pixie_usleep(10LL);
return *(_QWORD *)(a1 + 24);
}

canonical_decompiled_code:
__int64 __fastcall func11(__int64 a1)
{
*(_QWORD *)a1 = 0LL;
*(_QWORD *)(a1 + 8) = 0LL;
*(_QWORD *)(a1 + 16) = 0LL;
*(_QWORD *)(a1 + 24) = 0LL;
*(_QWORD *)(a1 + 32) = 0LL;
*(_QWORD *)a1 = rte_ring_create(0x10u, 3u);
pixie_begin_thread(test_producer_thread, 0LL, a1);
while ( !*(_DWORD *)(a1 + 8) )
pixie_usleep(10LL);
pixie_begin_thread(test_consumer_thread, 0LL, a1);
while ( !*(_DWORD *)(a1 + 12) )
pixie_usleep(10LL);
*(_DWORD *)(a1 + 32) = 1;
while ( !*(_DWORD *)(a1 + 16) )
pixie_usleep(10LL);
return *(_QWORD *)(a1 + 24);
}

original_code:
static uint64_t
run_test(struct Test *test)
{
    unsigned i;
    const unsigned THREADS = 1;
    memset(test, 0, sizeof(*test));
    test->ring = rte_ring_create(16, 0x0001|0x0002);
    for (i=0; i<THREADS; i++) {
        pixie_begin_thread(test_producer_thread, 0, test);
    }
    while (test->producer_started < THREADS)
        pixie_usleep(10);
    pixie_begin_thread(test_consumer_thread, 0, test);
    while (test->producer_done < THREADS)
        pixie_usleep(10);
    test->not_active = 1;
    while (!test->consumer_done)
        pixie_usleep(10);
    return test->total_count;
}

canonical_original_code:
static unsigned long run_test(struct Test *test)
{
    unsigned int i;
    unsigned int THREADS = 1;
    memset(test, 0, sizeof(*test));
    test->ring = rte_ring_create(16, 0x0001|0x0002);
    for (i=0; i<THREADS; i++) {
        pixie_begin_thread(test_producer_thread, 0, test);
    }
    while (test->producer_started < THREADS)
        pixie_usleep(10);
    pixie_begin_thread(test_consumer_thread, 0, test);
    while (test->producer_done < THREADS)
        pixie_usleep(10);
    test->not_active = 1;
    while (!test->consumer_done)
        pixie_usleep(10);
    return test->total_count;
}

variable_types:
THREADS
unsigned int

return_type: unsigned long

user_defined_types: struct prod { unsigned int watermark; unsigned int sp_enqueue; unsigned int size; unsigned int mask; unsigned int head; unsigned int tail; }

user_defined_types: struct cons { unsigned int sc_dequeue; unsigned int size; unsigned int mask; unsigned int head; unsigned int tail; }


REALLOCARRAY

decompiled_code:
void *__fastcall REALLOCARRAY(void *a1, unsigned __int64 a2, unsigned __int64 a3)
{
unsigned __int64 v3; // rbx
void *result; // rax

if ( (a3 > 0xFFFFFFFF || a2 > 0xFFFFFFFF) && a3 && 0xFFFFFFFFFFFFFFFFLL / a3 <= a2 )
{
fwrite("[-] alloc too large, aborting\n", 1uLL, 0x1EuLL, stderr);
abort();
}
v3 = a2 * a3;
result = realloc(a1, a2 * a3);
if ( v3 )
{
if ( !result )
{
fwrite("[-] out of memory, aborting\n", 1uLL, 0x1CuLL, stderr);
abort();
}
}
return result;
}

canonical_decompiled_code:
void *__fastcall func0(void *a1, unsigned __int64 a2, unsigned __int64 a3)
{
unsigned __int64 v3; // rbx
void *result; // rax

if ( (a3 > 0xFFFFFFFF || a2 > 0xFFFFFFFF) && a3 && 0xFFFFFFFFFFFFFFFFLL / a3 <= a2 )
{
fwrite("[-] alloc too large, aborting\n", 1uLL, 0x1EuLL, stderr);
abort();
}
v3 = a2 * a3;
result = realloc(a1, a2 * a3);
if ( v3 )
{
if ( !result )
{
fwrite("[-] out of memory, aborting\n", 1uLL, 0x1CuLL, stderr);
abort();
}
}
return result;
}

original_code:
void *
REALLOCARRAY(void *p, size_t count, size_t size)
{
    if (count >= ((size_t)1 << (sizeof(size_t)*4)) || size >= ((size_t)1 << (sizeof(size_t)*4))) {
        if (size != 0 && count >= (18446744073709551615UL)/size) {
            fprintf(stderr, "[-] alloc too large, aborting\n");
            abort();
        }
    }
    p = realloc(p, count * size);
    if (p == ((void *)0) && count * size != 0) {
        fprintf(stderr, "[-] out of memory, aborting\n");
        abort();
    }
    return p;
}

canonical_original_code:
void *REALLOCARRAY(void *p, unsigned long count, unsigned long size)
{
    if (count >= ((unsigned long)1 << (sizeof(unsigned long)*4)) || size >= ((unsigned long)1 << (sizeof(unsigned long)*4))) {
        if (size != 0 && count >= (18446744073709551615UL)/size) {
            fprintf(stderr, "[-] alloc too large, aborting\n");
            abort();
        }
    }
    p = realloc(p, count * size);
    if (p == ((void *)0) && count * size != 0) {
        fprintf(stderr, "[-] out of memory, aborting\n");
        abort();
    }
    return p;
}

variable_types:
p
void *

variable_types:
count
unsigned long

variable_types:
size
unsigned long

return_type: void *


CALLOC

decompiled_code:
void *__fastcall CALLOC(size_t nmemb, size_t size)
{
void *result; // rax

if ( (size > 0xFFFFFFFF || nmemb > 0xFFFFFFFF) && size && 0xFFFFFFFFFFFFFFFFLL / size <= nmemb )
{
fwrite("[-] alloc too large, aborting\n", 1uLL, 0x1EuLL, stderr);
abort();
}
result = calloc(nmemb, size);
if ( !result )
{
if ( nmemb * size )
{
fwrite("[-] out of memory, aborting\n", 1uLL, 0x1CuLL, stderr);
abort();
}
}
return result;
}

canonical_decompiled_code:
void *__fastcall func1(size_t nmemb, size_t size)
{
void *result; // rax

if ( (size > 0xFFFFFFFF || nmemb > 0xFFFFFFFF) && size && 0xFFFFFFFFFFFFFFFFLL / size <= nmemb )
{
fwrite("[-] alloc too large, aborting\n", 1uLL, 0x1EuLL, stderr);
abort();
}
result = calloc(nmemb, size);
if ( !result )
{
if ( nmemb * size )
{
fwrite("[-] out of memory, aborting\n", 1uLL, 0x1CuLL, stderr);
abort();
}
}
return result;
}

original_code:
void *
CALLOC(size_t count, size_t size)
{
    void *p;
    if (count >= ((size_t)1 << (sizeof(size_t)*4)) || size >= ((size_t)1 << (sizeof(size_t)*4))) {
        if (size != 0 && count >= (18446744073709551615UL)/size) {
            fprintf(stderr, "[-] alloc too large, aborting\n");
            abort();
        }
    }
    p = calloc(count, size);
    if (p == ((void *)0) && count * size != 0) {
        fprintf(stderr, "[-] out of memory, aborting\n");
        abort();
    }
    return p;
}

canonical_original_code:
void *CALLOC(unsigned long count, unsigned long size)
{
    void *p;
    if (count >= ((unsigned long)1 << (sizeof(unsigned long)*4)) || size >= ((unsigned long)1 << (sizeof(unsigned long)*4))) {
        if (size != 0 && count >= (18446744073709551615UL)/size) {
            fprintf(stderr, "[-] alloc too large, aborting\n");
            abort();
        }
    }
    p = calloc(count, size);
    if (p == ((void *)0) && count * size != 0) {
        fprintf(stderr, "[-] out of memory, aborting\n");
        abort();
    }
    return p;
}


MALLOC

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

if ( !a1 )
a1 = 1LL;
result = malloc(a1);
if ( !result )
{
fwrite("[-] out of memory, aborting\n", 1uLL, 0x1CuLL, stderr);
abort();
}
return result;
}

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

if ( !a1 )
a1 = 1LL;
result = malloc(a1);
if ( !result )
{
fwrite("[-] out of memory, aborting\n", 1uLL, 0x1CuLL, stderr);
abort();
}
return result;
}

original_code:
void *
MALLOC(size_t size)
{
    void *p;
    if (size == 0)
        size = 1;
    p = malloc(size);
    if (p == ((void *)0)) {
        fprintf(stderr, "[-] out of memory, aborting\n");
        abort();
    }
    return p;
}

canonical_original_code:
void *MALLOC(unsigned long size)
{
    void *p;
    if (size == 0)
        size = 1;
    p = malloc(size);
    if (p == ((void *)0)) {
        fprintf(stderr, "[-] out of memory, aborting\n");
        abort();
    }
    return p;
}


REALLOC

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

result = realloc(a1, a2);
if ( !result )
{
fwrite("[-] out of memory, aborting\n", 1uLL, 0x1CuLL, stderr);
abort();
}
return result;
}

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

result = realloc(a1, a2);
if ( !result )
{
fwrite("[-] out of memory, aborting\n", 1uLL, 0x1CuLL, stderr);
abort();
}
return result;
}

original_code:
void *
REALLOC(void *p, size_t size)
{
    p = realloc(p, size);
    if (p == ((void *)0)) {
        fprintf(stderr, "[-] out of memory, aborting\n");
        abort();
    }
    return p;
}

canonical_original_code:
void *REALLOC(void *p, unsigned long size)
{
    p = realloc(p, size);
    if (p == ((void *)0)) {
        fprintf(stderr, "[-] out of memory, aborting\n");
        abort();
    }
    return p;
}


STRDUP

decompiled_code:
char *__fastcall STRDUP(const char *a1)
{
char *result; // rax

result = strdup(a1);
if ( !result )
{
fwrite("[-] out of memory, aborting\n", 1uLL, 0x1CuLL, stderr);
abort();
}
return result;
}

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

result = strdup(a1);
if ( !result )
{
fwrite("[-] out of memory, aborting\n", 1uLL, 0x1CuLL, stderr);
abort();
}
return result;
}

original_code:
char *
STRDUP(const char *str)
{
    char *p = strdup(str);
    if (p == ((void *)0) && str != ((void *)0)) {
        fprintf(stderr, "[-] out of memory, aborting\n");
        abort();
    }
    return p;
}

canonical_original_code:
char *STRDUP(char *str)
{
    char *p = strdup(str);
    if (p == ((void *)0) && str != ((void *)0)) {
        fprintf(stderr, "[-] out of memory, aborting\n");
        abort();
    }
    return p;
}

variable_types:
str
char *

variable_types:
p
char *

return_type: char *


READ

decompiled_code:
unsigned __int64 __fastcall READ(char a1, __int64 a2, __int64 a3)
{
__int64 v3; // rsi
char v4; // cl

v3 = __ROL8__(a3, a1) ^ a2;
v4 = a3 ^ a1;
return ((unsigned __int64)(((unsigned __int8)sbox[(unsigned __int8)(a3 ^ a1 ^ HIBYTE(v3))] << 24) | ((unsigned __int8)sbox[(unsigned __int8)(a3 ^ a1 ^ BYTE6(v3))] << 16)) << 33) ^ ((unsigned __int8)sbox[(unsigned __int8)(a3 ^ a1 ^ v3)] | ((unsigned __int8)sbox[(unsigned __int8)(v4 ^ BYTE1(v3))] << 8)) ^ ((__int64)((unsigned __int8)sbox[(unsigned __int8)(v4 ^ BYTE4(v3))] | ((unsigned __int8)sbox[(unsigned __int8)(v4 ^ BYTE5(v3))] << 8)) << 23) ^ (((unsigned __int8)sbox[(unsigned __int8)(v4 ^ BYTE3(v3))] << 24) | ((unsigned __int8)sbox[(unsigned __int8)(v4 ^ BYTE2(v3))] << 16));
}

canonical_decompiled_code:
unsigned __int64 __fastcall func0(char a1, __int64 a2, __int64 a3)
{
__int64 v3; // rsi
char v4; // cl

v3 = __ROL8__(a3, a1) ^ a2;
v4 = a3 ^ a1;
return ((unsigned __int64)(((unsigned __int8)sbox[(unsigned __int8)(a3 ^ a1 ^ HIBYTE(v3))] << 24) | ((unsigned __int8)sbox[(unsigned __int8)(a3 ^ a1 ^ BYTE6(v3))] << 16)) << 33) ^ ((unsigned __int8)sbox[(unsigned __int8)(a3 ^ a1 ^ v3)] | ((unsigned __int8)sbox[(unsigned __int8)(v4 ^ BYTE1(v3))] << 8)) ^ ((__int64)((unsigned __int8)sbox[(unsigned __int8)(v4 ^ BYTE4(v3))] | ((unsigned __int8)sbox[(unsigned __int8)(v4 ^ BYTE5(v3))] << 8)) << 23) ^ (((unsigned __int8)sbox[(unsigned __int8)(v4 ^ BYTE3(v3))] << 24) | ((unsigned __int8)sbox[(unsigned __int8)(v4 ^ BYTE2(v3))] << 16));
}

canonical_original_code:
static inline unsigned long READ(unsigned long r, unsigned long R, unsigned long seed)
{
    unsigned long r0; unsigned long r1; unsigned long r2; unsigned long r3;
    R ^= (seed << r) ^ (seed >> (64 - r));
    r0 = sbox[((((R)>>(0*8))^seed^r)&0xFF)]<< 0 | sbox[((((R)>>(1*8))^seed^r)&0xFF)]<< 8;
    r1 = (sbox[((((R)>>(2*8))^seed^r)&0xFF)]<<16UL | sbox[((((R)>>(3*8))^seed^r)&0xFF)]<<24UL)&0x0ffffFFFFUL;
    r2 = sbox[((((R)>>(4*8))^seed^r)&0xFF)]<< 0 | sbox[((((R)>>(5*8))^seed^r)&0xFF)]<< 8;
    r3 = (sbox[((((R)>>(6*8))^seed^r)&0xFF)]<<16UL | sbox[((((R)>>(7*8))^seed^r)&0xFF)]<<24UL)&0x0ffffFFFFUL;
    R = r0 ^ r1 ^ r2<<23UL ^ r3<<33UL;
    return R;
}

variable_types:
r
unsigned long

variable_types:
R
unsigned long

variable_types:
seed
unsigned long


UNENCRYPT

original_code:
static inline uint64_t
UNENCRYPT(unsigned r, uint64_t a, uint64_t b, uint64_t m, uint64_t seed)
{
    uint64_t L, R;
    unsigned j;
    uint64_t tmp;
    if (r & 1) {
        R = m % a;
        L = m / a;
    } else {
        L = m % a;
        R = m / a;
    }
    for (j=r; j>=1; j--) {
        if (j & 1) {
            tmp = READ(j, L, seed);
            if (tmp > R) {
                tmp = (tmp - R);
                tmp = a - (tmp%a);
                if (tmp == a)
                    tmp = 0;
            } else {
                tmp = (R - tmp);
                tmp %= a;
            }
        } else {
            tmp = READ(j, L, seed);
            if (tmp > R) {
                tmp = (tmp - R);
                tmp = b - (tmp%b);
                if (tmp == b)
                    tmp = 0;
            } else {
                tmp = (R - tmp);
                tmp %= b;
            }
        }
        R = L;
        L = tmp;
    }
    return a * R + L;
}

canonical_original_code:
static inline unsigned long UNENCRYPT(unsigned int r, unsigned long a, unsigned long b, unsigned long m, unsigned long seed)
{
    unsigned long L; unsigned long R;
    unsigned int j;
    unsigned long tmp;
    if (r & 1) {
        R = m % a;
        L = m / a;
    } else {
        L = m % a;
        R = m / a;
    }
    for (j=r; j>=1; j--) {
        if (j & 1) {
            tmp = READ(j, L, seed);
            if (tmp > R) {
                tmp = (tmp - R);
                tmp = a - (tmp%a);
                if (tmp == a)
                    tmp = 0;
            } else {
                tmp = (R - tmp);
                tmp %= a;
            }
        } else {
            tmp = READ(j, L, seed);
            if (tmp > R) {
                tmp = (tmp - R);
                tmp = b - (tmp%b);
                if (tmp == b)
                    tmp = 0;
            } else {
                tmp = (R - tmp);
                tmp %= b;
            }
        }
        R = L;
        L = tmp;
    }
    return a * R + L;
}

variable_types:
r
unsigned int

variable_types:
a
unsigned long

variable_types:
b
unsigned long

variable_types:
m
unsigned long

variable_types:
L
unsigned long

variable_types:
j
unsigned int

variable_types:
tmp
unsigned long


original_code:
void
blackrock_init(struct BlackRock *br, uint64_t range, uint64_t seed, unsigned rounds)
{
    double foo = sqrt(range * 1.0);
    switch (range) {
        case 0:
            br->a = 0;
            br->b = 0;
            break;
        case 1:
            br->a = 1;
            br->b = 1;
            break;
        case 2:
            br->a = 1;
            br->b = 2;
            break;
        case 3:
            br->a = 2;
            br->b = 2;
            break;
        case 4:
        case 5:
        case 6:
            br->a = 2;
            br->b = 3;
            break;
        case 7:
        case 8:
            br->a = 3;
            br->b = 3;
            break;
        default:
            br->range = range;
            br->a = (uint64_t)(foo - 2);
            br->b = (uint64_t)(foo + 3);
            break;
    }
    while (br->a * br->b <= range)
        br->b++;
    br->rounds = rounds;
    br->seed = seed;
    br->range = range;
}

canonical_original_code:
void blackrock_init(struct BlackRock *br, unsigned long range, unsigned long seed, unsigned int rounds)
{
    double foo = sqrt(range * 1.0);
    switch (range) {
        case 0:
            br->a = 0;
            br->b = 0;
            break;
        case 1:
            br->a = 1;
            br->b = 1;
            break;
        case 2:
            br->a = 1;
            br->b = 2;
            break;
        case 3:
            br->a = 2;
            br->b = 2;
            break;
        case 4:
        case 5:
        case 6:
            br->a = 2;
            br->b = 3;
            break;
        case 7:
        case 8:
            br->a = 3;
            br->b = 3;
            break;
        default:
            br->range = range;
            br->a = (unsigned long)(foo - 2);
            br->b = (unsigned long)(foo + 3);
            break;
    }
    while (br->a * br->b <= range)
        br->b++;
    br->rounds = rounds;
    br->seed = seed;
    br->range = range;
}

variable_types: struct BlackRock { unsigned long range; unsigned long a; unsigned long b; unsigned long seed; unsigned int rounds; unsigned long a_bits; unsigned long a_mask; unsigned long b_bits; unsigned long b_mask; } *

variable_types:
range
unsigned long

variable_types:
rounds
unsigned int

variable_types: foo double


decompiled_code:
unsigned __int64 __fastcall blackrock_shuffle(__int64 a1, unsigned __int64 a2)
{
__int64 v2; // r14
unsigned __int64 v3; // r13
unsigned __int64 v4; // r12
unsigned int v5; // ebp
unsigned __int64 v6; // rcx
unsigned __int64 i; // rbx

v2 = *(_QWORD *)(a1 + 24);
v3 = *(_QWORD *)(a1 + 16);
v4 = *(_QWORD *)(a1 + 8);
v5 = *(_DWORD *)(a1 + 32);
v6 = ENCRYPT(v5, v4, v3, a2, v2);
for ( i = *(_QWORD *)a1; v6 >= i; v6 = ENCRYPT(v5, v4, v3, v6, v2) )
;
return v6;
}

canonical_decompiled_code:
unsigned __int64 __fastcall func4(__int64 a1, unsigned __int64 a2)
{
__int64 v2; // r14
unsigned __int64 v3; // r13
unsigned __int64 v4; // r12
unsigned int v5; // ebp
unsigned __int64 v6; // rcx
unsigned __int64 i; // rbx

v2 = *(_QWORD *)(a1 + 24);
v3 = *(_QWORD *)(a1 + 16);
v4 = *(_QWORD *)(a1 + 8);
v5 = *(_DWORD *)(a1 + 32);
v6 = func1(v5, v4, v3, a2, v2);
for ( i = *(_QWORD *)a1; v6 >= i; v6 = func1(v5, v4, v3, v6, v2) )
;
return v6;
}

original_code:
uint64_t
blackrock_shuffle(const struct BlackRock *br, uint64_t m)
{
    uint64_t c;
    c = ENCRYPT(br->rounds, br->a, br->b, m, br->seed);
    while (c >= br->range)
        c = ENCRYPT(br->rounds, br->a, br->b, c, br->seed);
    return c;
}

canonical_original_code:
unsigned long blackrock_shuffle(struct BlackRock *br, unsigned long m)
{
    unsigned long c;
    c = ENCRYPT(br->rounds, br->a, br->b, m, br->seed);
    while (c >= br->range)
        c = ENCRYPT(br->rounds, br->a, br->b, c, br->seed);
    return c;
}

variable_types:
c
unsigned long

user_defined_types: struct BlackRock { unsigned long range; unsigned long a; unsigned long b; unsigned long seed; unsigned int rounds; unsigned long a_bits; unsigned long a_mask; unsigned long b_bits; unsigned long b_mask; }


decompiled_code:
__int64 __fastcall blackrock_verify(unsigned __int64 *a1, unsigned __int64 a2)
{
unsigned __int64 v2; // r14
unsigned __int64 v3; // r13
_BYTE *v4; // rbp
unsigned __int64 i; // rbx
unsigned __int64 v6; // rax
_BYTE *v7; // rax
_BYTE *v8; // r13
unsigned int v9; // ebx

v2 = *a1;
v3 = a2;
if ( *a1 <= a2 )
v3 = *a1;
v4 = (_BYTE *)CALLOC(1LL, v3);
if ( v2 )
{
for ( i = 0LL; i != v2; ++i )
{
v6 = blackrock_shuffle((__int64)a1, i);
if ( a2 > v6 )
++v4[v6];
}
if ( v3 )
{
v7 = v4;
v8 = &v4[v3];
v9 = 1;
do
{
if ( *v7 != 1 )
v9 = 0;
++v7;
}
while ( v7 != v8 );
}
else
{
v9 = 1;
}
}
else
{
v9 = 1;
}
free(v4);
return v9;
}

canonical_decompiled_code:
__int64 __fastcall func5(unsigned __int64 *a1, unsigned __int64 a2)
{
unsigned __int64 v2; // r14
unsigned __int64 v3; // r13
_BYTE *v4; // rbp
unsigned __int64 i; // rbx
unsigned __int64 v6; // rax
_BYTE *v7; // rax
_BYTE *v8; // r13
unsigned int v9; // ebx

v2 = *a1;
v3 = a2;
if ( *a1 <= a2 )
v3 = *a1;
v4 = (_BYTE *)CALLOC(1LL, v3);
if ( v2 )
{
for ( i = 0LL; i != v2; ++i )
{
v6 = func4((__int64)a1, i);
if ( a2 > v6 )
++v4[v6];
}
if ( v3 )
{
v7 = v4;
v8 = &v4[v3];
v9 = 1;
do
{
if ( *v7 != 1 )
v9 = 0;
++v7;
}
while ( v7 != v8 );
}
else
{
v9 = 1;
}
}
else
{
v9 = 1;
}
free(v4);
return v9;
}

original_code:
static unsigned
blackrock_verify(struct BlackRock *br, uint64_t max)
{
    unsigned char *list;
    uint64_t i;
    unsigned is_success = 1;
    uint64_t range = br->range;
    list = CALLOC(1, (size_t)((range<max)?range:max));
    for (i=0; i<range; i++) {
        uint64_t x = blackrock_shuffle(br, i);
        if (x < max)
            list[x]++;
    }
    for (i=0; i<max && i<range; i++) {
        if (list[i] != 1)
            is_success = 0;
    }
    free(list);
    return is_success;
}

canonical_original_code:
static unsigned int blackrock_verify(struct BlackRock *br, unsigned long max)
{
    unsigned char *list;
    unsigned long i;
    unsigned int is_success = 1;
    unsigned long range = br->range;
    list = CALLOC(1, (unsigned long)((range<max)?range:max));
    for (i=0; i<range; i++) {
        unsigned long x = blackrock_shuffle(br, i);
        if (x < max)
            list[x]++;
    }
    for (i=0; i<max && i<range; i++) {
        if (list[i] != 1)
            is_success = 0;
    }
    free(list);
    return is_success;
}

variable_types:
max
unsigned long

variable_types:
list
unsigned char *

variable_types:
i
unsigned long

variable_types:
x
unsigned long

return_type: unsigned int


decompiled_code:
unsigned __int64 __fastcall blackrock_unshuffle(__int64 a1, unsigned __int64 a2)
{
__int64 v2; // r14
unsigned __int64 v3; // r13
unsigned __int64 v4; // r12
int v5; // ebp
unsigned __int64 v6; // rcx
unsigned __int64 i; // rbx

v2 = *(_QWORD *)(a1 + 24);
v3 = *(_QWORD *)(a1 + 16);
v4 = *(_QWORD *)(a1 + 8);
v5 = *(_DWORD *)(a1 + 32);
v6 = UNENCRYPT(v5, v4, v3, a2, v2);
for ( i = *(_QWORD *)a1; v6 >= i; v6 = UNENCRYPT(v5, v4, v3, v6, v2) )
;
return v6;
}

canonical_decompiled_code:
unsigned __int64 __fastcall func6(__int64 a1, unsigned __int64 a2)
{
__int64 v2; // r14
unsigned __int64 v3; // r13
unsigned __int64 v4; // r12
int v5; // ebp
unsigned __int64 v6; // rcx
unsigned __int64 i; // rbx

v2 = *(_QWORD *)(a1 + 24);
v3 = *(_QWORD *)(a1 + 16);
v4 = *(_QWORD *)(a1 + 8);
v5 = *(_DWORD *)(a1 + 32);
v6 = func2(v5, v4, v3, a2, v2);
for ( i = *(_QWORD *)a1; v6 >= i; v6 = func2(v5, v4, v3, v6, v2) )
;
return v6;
}

original_code:
uint64_t
blackrock_unshuffle(const struct BlackRock *br, uint64_t m)
{
    uint64_t c;
    c = UNENCRYPT(br->rounds, br->a, br->b, m, br->seed);
    while (c >= br->range)
        c = UNENCRYPT(br->rounds, br->a, br->b, c, br->seed);
    return c;
}

canonical_original_code:
unsigned long blackrock_unshuffle(struct BlackRock *br, unsigned long m)
{
    unsigned long c;
    c = UNENCRYPT(br->rounds, br->a, br->b, m, br->seed);
    while (c >= br->range)
        c = UNENCRYPT(br->rounds, br->a, br->b, c, br->seed);
    return c;
}


decompiled_code:
int __fastcall blackrock_benchmark(unsigned int a1)
{
__int64 v1; // r12
__int64 v2; // rbp
unsigned __int64 i; // rbx
__int64 v4; // rax
__int64 v6; // rax
double v7; // xmm1_8
_BYTE v8[104]; // [rsp+0h] [rbp-68h] BYREF

puts("-- blackrock-1 -- ");
printf("rounds = %u\n", a1);
blackrock_init((__int64)v8, 0x12356789123uLL, 1LL, a1);
v1 = pixie_nanotime();
v2 = 0LL;
for ( i = 0LL; i != 5000000; ++i )
v2 += blackrock_shuffle((__int64)v8, i);
v4 = pixie_nanotime();
if ( v2 )
{
v6 = v4 - v1;
if ( v6 < 0 )
v7 = (double)(int)(v6 & 1 | ((unsigned __int64)v6 >> 1)) + (double)(int)(v6 & 1 | ((unsigned __int64)v6 >> 1));
else
v7 = (double)(int)v6;
printf("iterations/second = %5.3f-million\n", 5000000.0 / (v7 / 1000000000.0) / 1000000.0);
}
return putchar(10);
}

canonical_decompiled_code:
int __fastcall func7(unsigned int a1)
{
__int64 v1; // r12
__int64 v2; // rbp
unsigned __int64 i; // rbx
__int64 v4; // rax
__int64 v6; // rax
double v7; // xmm1_8
_BYTE v8[104]; // [rsp+0h] [rbp-68h] BYREF

puts("-- blackrock-1 -- ");
printf("rounds = %u\n", a1);
func3((__int64)v8, 0x12356789123uLL, 1LL, a1);
v1 = pixie_nanotime();
v2 = 0LL;
for ( i = 0LL; i != 5000000; ++i )
v2 += func4((__int64)v8, i);
v4 = pixie_nanotime();
if ( v2 )
{
v6 = v4 - v1;
if ( v6 < 0 )
v7 = (double)(int)(v6 & 1 | ((unsigned __int64)v6 >> 1)) + (double)(int)(v6 & 1 | ((unsigned __int64)v6 >> 1));
else
v7 = (double)(int)v6;
printf("iterations/second = %5.3f-million\n", 5000000.0 / (v7 / 1000000000.0) / 1000000.0);
}
return putchar(10);
}

original_code:
void
blackrock_benchmark(unsigned rounds)
{
    struct BlackRock br;
    uint64_t range = 0x012356789123ULL;
    uint64_t i;
    uint64_t result = 0;
    uint64_t start, stop;
    static const uint64_t ITERATIONS = 5000000ULL;
    printf("-- blackrock-1 -- \n");
    printf("rounds = %u\n", rounds);
    blackrock_init(&br, range, 1, rounds);
    start = pixie_nanotime();
    for (i=0; i<ITERATIONS; i++) {
        result += blackrock_shuffle(&br, i);
    }
    stop = pixie_nanotime();
    if (result) {
        double elapsed = ((double)(stop - start))/(1000000000.0);
        double rate = ITERATIONS/elapsed;
        rate /= 1000000.0;
        printf("iterations/second = %5.3f-million\n", rate);
    }
    printf("\n");
}

canonical_original_code:
void blackrock_benchmark(unsigned int rounds)
{
    struct BlackRock br;
    unsigned long range = 0x012356789123ULL;
    unsigned long i;
    unsigned long result = 0;
    unsigned long start; unsigned long stop;
    static unsigned long ITERATIONS = 5000000ULL;
    printf("-- blackrock-1 -- \n");
    printf("rounds = %u\n", rounds);
    blackrock_init(&br, range, 1, rounds);
    start = pixie_nanotime();
    for (i=0; i<ITERATIONS; i++) {
        result += blackrock_shuffle(&br, i);
    }
    stop = pixie_nanotime();
    if (result) {
        double elapsed = ((double)(stop - start))/(1000000000.0);
        double rate = ITERATIONS/elapsed;
        rate /= 1000000.0;
        printf("iterations/second = %5.3f-million\n", rate);
    }
    printf("\n");
}

variable_types: struct BlackRock { unsigned long range; unsigned long a; unsigned long b; unsigned long seed; unsigned int rounds; unsigned long a_bits; unsigned long a_mask; unsigned long b_bits; unsigned long b_mask; }

variable_types:
result
unsigned long

variable_types:
start
unsigned long

variable_types:
stop
unsigned long

variable_types:
ITERATIONS
unsigned long

variable_types: elapsed double

variable_types: rate double


decompiled_code:
__int64 blackrock_selftest()
{
unsigned __int64 i; // rbx
unsigned __int64 v1; // rax
unsigned __int64 v2; // rbp
__int64 v3; // rax
unsigned __int64 v5[13]; // [rsp+0h] [rbp-68h] BYREF

blackrock_init((__int64)v5, 0x3E8uLL, 0LL, 4);
for ( i = 0LL; i != 10; ++i )
{
v1 = blackrock_shuffle((__int64)v5, i);
if ( blackrock_unshuffle((__int64)v5, v1) != i )
return 1LL;
}
v2 = 9045LL;
while ( 1 )
{
v2 = 2 * (i + v2);
v3 = time(0LL);
blackrock_init((__int64)v5, v2, v3, 4);
if ( !(unsigned int)blackrock_verify(v5, v2) )
break;
if ( ++i == 15 )
return 0LL;
}
fwrite("BLACKROCK: randomization failed\n", 1uLL, 0x20uLL, stderr);
return 1LL;
}

canonical_decompiled_code:
__int64 func8()
{
unsigned __int64 i; // rbx
unsigned __int64 v1; // rax
unsigned __int64 v2; // rbp
__int64 v3; // rax
unsigned __int64 v5[13]; // [rsp+0h] [rbp-68h] BYREF

func3((__int64)v5, 0x3E8uLL, 0LL, 4);
for ( i = 0LL; i != 10; ++i )
{
v1 = func4((__int64)v5, i);
if ( func6((__int64)v5, v1) != i )
return 1LL;
}
v2 = 9045LL;
while ( 1 )
{
v2 = 2 * (i + v2);
v3 = time(0LL);
func3((__int64)v5, v2, v3, 4);
if ( !(unsigned int)func5(v5, v2) )
break;
if ( ++i == 15 )
return 0LL;
}
fwrite("BLACKROCK: randomization failed\n", 1uLL, 0x20uLL, stderr);
return 1LL;
}

original_code:
int
blackrock_selftest(void)
{
    uint64_t i;
    uint64_t range;
    {
        struct BlackRock br;
        blackrock_init(&br, 1000, 0, 4);
        for (i=0; i<10; i++) {
            uint64_t result, result2;
            result = blackrock_shuffle(&br, i);
            result2 = blackrock_unshuffle(&br, result);
            if (i != result2)
                return 1;
        }
    }
    range = 3015 * 3;
    for (i=0; i<5; i++) {
        struct BlackRock br;
        int is_success;
        range += 10 + i;
        range *= 2;
        blackrock_init(&br, range, time(0), 4);
        is_success = blackrock_verify(&br, range);
        if (!is_success) {
            fprintf(stderr, "BLACKROCK: randomization failed\n");
            return 1;
        }
    }
    return 0;
}

canonical_original_code:
int blackrock_selftest()
{
    unsigned long i;
    unsigned long range;
    {
        struct BlackRock br;
        blackrock_init(&br, 1000, 0, 4);
        for (i=0; i<10; i++) {
            unsigned long result; unsigned long result2;
            result = blackrock_shuffle(&br, i);
            result2 = blackrock_unshuffle(&br, result);
            if (i != result2)
                return 1;
        }
    }
    range = 3015 * 3;
    for (i=0; i<5; i++) {
        struct BlackRock br;
        int is_success;
        range += 10 + i;
        range *= 2;
        blackrock_init(&br, range, time(0), 4);
        is_success = blackrock_verify(&br, range);
        if (!is_success) {
            fprintf(stderr, "BLACKROCK: randomization failed\n");
            return 1;
        }
    }
    return 0;
}

return_type: int


ENCRYPT

decompiled_code:
unsigned __int64 __fastcall ENCRYPT(unsigned int a1, unsigned __int64 a2, unsigned __int64 a3, unsigned __int64 a4, __int64 a5)
{
__int64 v7; // rbp
unsigned int v8; // ebx
unsigned __int64 v9; // rdx
unsigned __int64 v11; // [rsp+0h] [rbp-38h]

v11 = a4 % a2;
if ( a1 )
{
v7 = a4 / a2;
v8 = 1;
while ( 1 )
{
v9 = (v8 & 1) != 0 ? (v11 + READ(v8, v7, a5)) % a2 : (v11 + READ(v8, v7, a5)) % a3;
++v8;
v11 = v7;
if ( a1 < v8 )
break;
v7 = v9;
}
if ( (a1 & 1) != 0 )
return a2 * v7 + v9;
}
else
{
v9 = a4 / a2;
v7 = a4 % a2;
}
return a2 * v9 + v7;
}

canonical_decompiled_code:
unsigned __int64 __fastcall func1(unsigned int a1, unsigned __int64 a2, unsigned __int64 a3, unsigned __int64 a4, __int64 a5)
{
__int64 v7; // rbp
unsigned int v8; // ebx
unsigned __int64 v9; // rdx
unsigned __int64 v11; // [rsp+0h] [rbp-38h]

v11 = a4 % a2;
if ( a1 )
{
v7 = a4 / a2;
v8 = 1;
while ( 1 )
{
v9 = (v8 & 1) != 0 ? (v11 + func0(v8, v7, a5)) % a2 : (v11 + func0(v8, v7, a5)) % a3;
++v8;
v11 = v7;
if ( a1 < v8 )
break;
v7 = v9;
}
if ( (a1 & 1) != 0 )
return a2 * v7 + v9;
}
else
{
v9 = a4 / a2;
v7 = a4 % a2;
}
return a2 * v9 + v7;
}

original_code:
static inline uint64_t
ENCRYPT(unsigned r, uint64_t a, uint64_t b, uint64_t m, uint64_t seed)
{
    uint64_t L, R;
    unsigned j;
    uint64_t tmp;
    L = m % a;
    R = m / a;
    for (j=1; j<=r; j++) {
        if (j & 1) {
            tmp = (L + READ(j, R, seed)) % a;
        } else {
            tmp = (L + READ(j, R, seed)) % b;
        }
        L = R;
        R = tmp;
    }
    if (r & 1) {
        return a * L + R;
    } else {
        return a * R + L;
    }
}

canonical_original_code:
static inline unsigned long ENCRYPT(unsigned int r, unsigned long a, unsigned long b, unsigned long m, unsigned long seed)
{
    unsigned long L; unsigned long R;
    unsigned int j;
    unsigned long tmp;
    L = m % a;
    R = m / a;
    for (j=1; j<=r; j++) {
        if (j & 1) {
            tmp = (L + READ(j, R, seed)) % a;
        } else {
            tmp = (L + READ(j, R, seed)) % b;
        }
        L = R;
        R = tmp;
    }
    if (r & 1) {
        return a * L + R;
    } else {
        return a * R + L;
    }
}

variable_types:
r
unsigned int

variable_types:
a
unsigned long

variable_types:
b
unsigned long

variable_types:
m
unsigned long

variable_types:
seed
unsigned long

variable_types:
L
unsigned long

variable_types:
R
unsigned long

variable_types:
j
unsigned int

variable_types:
tmp
unsigned long


decompiled_code:
__int64 __fastcall r_rand(unsigned int *a1)
{
unsigned int v1; // eax

v1 = 214013 * *a1 + 2531011;
*a1 = v1;
return HIWORD(v1) & 0x7FFF;
}

canonical_decompiled_code:
__int64 __fastcall func0(unsigned int *a1)
{
unsigned int v1; // eax

v1 = 214013 * *a1 + 2531011;
*a1 = v1;
return HIWORD(v1) & 0x7FFF;
}

original_code:
static unsigned
r_rand(unsigned *seed)
{
    static const unsigned a = 214013;
    static const unsigned c = 2531011;
    *seed = (*seed) * a + c;
    return (*seed)>>16 & 0x7fff;
}

canonical_original_code:
static unsigned int r_rand(unsigned int *seed)
{
    static unsigned int a = 214013;
    static unsigned int c = 2531011;
    *seed = (*seed) * a + c;
    return (*seed)>>16 & 0x7fff;
}

variable_types:
seed
unsigned int *

variable_types:
a
unsigned int

variable_types:
c
unsigned int


original_code:
size_t
base64_encode(void *vdst, size_t sizeof_dst,
              const void *vsrc, size_t sizeof_src)
{
    static const char *b64 =
        "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
        "abcdefghijklmnopqrstuvwxyz"
        "0123456789"
        "+/";
    size_t i = 0;
    size_t d = 0;
    unsigned char *dst = (unsigned char *)vdst;
    const unsigned char *src = (const unsigned char *)vsrc;
    while (i + 3 <= sizeof_src) {
        unsigned n;
        if (d + 4 > sizeof_dst)
            return d;
        n = src[i]<<16 | src[i+1]<<8 | src[i+2];
        dst[d+0] = b64[ (n>>18) & 0x3F ];
        dst[d+1] = b64[ (n>>12) & 0x3F ];
        dst[d+2] = b64[ (n>> 6) & 0x3F ];
        dst[d+3] = b64[ (n>> 0) & 0x3F ];
        i += 3;
        d += 4;
    }
    if (i + 2 <= sizeof_src && d + 4 <= sizeof_dst) {
        unsigned n = src[i]<<16 | src[i+1]<<8;
        dst[d+0] = b64[ (n>>18) & 0x3F ];
        dst[d+1] = b64[ (n>>12) & 0x3F ];
        dst[d+2] = b64[ (n>> 6) & 0x3F ];
        dst[d+3] = '=';
        d += 4;
    } else if (i + 1 <= sizeof_src && d + 4 <= sizeof_dst) {
        unsigned n = src[i]<<16;
        dst[d+0] = b64[ (n>>18) & 0x3F ];
        dst[d+1] = b64[ (n>>12) & 0x3F ];
        dst[d+2] = '=';
        dst[d+3] = '=';
        d += 4;
    }
    return d;
}

canonical_original_code:
unsigned long base64_encode(void *vdst, unsigned long sizeof_dst, void *vsrc, unsigned long sizeof_src)
{
    static char *b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
        "abcdefghijklmnopqrstuvwxyz"
        "0123456789"
        "+/";
    unsigned long i = 0;
    unsigned long d = 0;
    unsigned char *dst = (unsigned char *)vdst;
    unsigned char *src = (const unsigned char *)vsrc;
    while (i + 3 <= sizeof_src) {
        unsigned int n;
        if (d + 4 > sizeof_dst)
            return d;
        n = src[i]<<16 | src[i+1]<<8 | src[i+2];
        dst[d+0] = b64[ (n>>18) & 0x3F ];
        dst[d+1] = b64[ (n>>12) & 0x3F ];
        dst[d+2] = b64[ (n>> 6) & 0x3F ];
        dst[d+3] = b64[ (n>> 0) & 0x3F ];
        i += 3;
        d += 4;
    }
    if (i + 2 <= sizeof_src && d + 4 <= sizeof_dst) {
        unsigned int n = src[i]<<16 | src[i+1]<<8;
        dst[d+0] = b64[ (n>>18) & 0x3F ];
        dst[d+1] = b64[ (n>>12) & 0x3F ];
        dst[d+2] = b64[ (n>> 6) & 0x3F ];
        dst[d+3] = '=';
        d += 4;
    } else if (i + 1 <= sizeof_src && d + 4 <= sizeof_dst) {
        unsigned int n = src[i]<<16;
        dst[d+0] = b64[ (n>>18) & 0x3F ];
        dst[d+1] = b64[ (n>>12) & 0x3F ];
        dst[d+2] = '=';
        dst[d+3] = '=';
        d += 4;
    }
    return d;
}

variable_types:
vdst
void *

variable_types:
vsrc
void *

variable_types:
i
unsigned long

variable_types:
d
unsigned long

variable_types:
dst
unsigned char *

variable_types:
src
unsigned char *

variable_types:
n
unsigned int


original_code:
size_t
base64_decode(void *vdst, size_t sizeof_dst,
              const void *vsrc, size_t sizeof_src)
{
 static const unsigned char rstr[] = {
  0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
        0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
  0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
        0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
  0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
        0xFF, 0xFF, 0xFF, 62, 0xFF, 0xFF, 0xFF, 63,
  52, 53, 54, 55, 56, 57, 58, 59,
        60, 61, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
  0xFF, 0, 1, 2, 3, 4, 5, 6,
        7, 8, 9, 10, 11, 12, 13, 14,
  15, 16, 17, 18, 19, 20, 21, 22,
        23, 24, 25, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
  0xFF, 26, 27, 28, 29, 30, 31, 32,
        33, 34, 35, 36, 37, 38, 39, 40,
  41, 42, 43, 44, 45, 46, 47, 48,
        49, 50, 51, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
  0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
        0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
  0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
        0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
  0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
        0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
  0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
        0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
  0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
        0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
  0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
        0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
  0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
        0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
  0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
        0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
 };
    size_t i = 0;
    size_t d = 0;
    unsigned char *dst = (unsigned char *)vdst;
    const unsigned char *src = (const unsigned char *)vsrc;
 while (i < sizeof_src) {
        unsigned b;
  unsigned c=0;
  while (i<sizeof_src && (c = rstr[src[i]]) > 64)
   i++;
  if (src[i] == '=' || i++ >= sizeof_src)
   break;
  b = (c << 2) & 0xfc;
  while (i<sizeof_src && (c = rstr[src[i]]) > 64)
   i++;
  if (src[i] == '=' || i++ >= sizeof_src)
   break;
  b |= (c>>4) & 0x03;
  if (d<sizeof_dst)
   dst[d++] = (unsigned char)b;
  if (i>=sizeof_src)
   break;
  b = (c<<4) & 0xF0;
  while (i<sizeof_src && src[i] != '=' && (c = rstr[src[i]]) > 64)
   ;
  if (src[i] == '=' || i++ >= sizeof_src)
   break;
  b |= (c>>2) & 0x0F;
  if (d<sizeof_dst)
   dst[d++] = (unsigned char)b;
  if (i>=sizeof_src)
   break;
  b = (c<<6) & 0xC0;
  while (i<sizeof_src && src[i] != '=' && (c = rstr[src[i]]) > 64)
   ;
  if (src[i] == '=' || i++ >= sizeof_src)
   break;
  b |= c;
  if (d<sizeof_dst)
   dst[d++] = (unsigned char)b;
  if (i>=sizeof_src)
   break;
 }
 if (d<sizeof_dst)
  dst[d] = '\0';
 return d;
}

canonical_original_code:
unsigned long base64_decode(void *vdst, unsigned long sizeof_dst, void *vsrc, unsigned long sizeof_src)
{
 static unsigned char rstr[] = {
  0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
        0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
  0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
        0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
  0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
        0xFF, 0xFF, 0xFF, 62, 0xFF, 0xFF, 0xFF, 63,
  52, 53, 54, 55, 56, 57, 58, 59,
        60, 61, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
  0xFF, 0, 1, 2, 3, 4, 5, 6,
        7, 8, 9, 10, 11, 12, 13, 14,
  15, 16, 17, 18, 19, 20, 21, 22,
        23, 24, 25, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
  0xFF, 26, 27, 28, 29, 30, 31, 32,
        33, 34, 35, 36, 37, 38, 39, 40,
  41, 42, 43, 44, 45, 46, 47, 48,
        49, 50, 51, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
  0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
        0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
  0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
        0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
  0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
        0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
  0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
        0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
  0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
        0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
  0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
        0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
  0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
        0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
  0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
        0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
 };
    unsigned long i = 0;
    unsigned long d = 0;
    unsigned char *dst = (unsigned char *)vdst;
    unsigned char *src = (const unsigned char *)vsrc;
 while (i < sizeof_src) {
        unsigned int b;
  unsigned int c = 0;
  while (i<sizeof_src && (c = rstr[src[i]]) > 64)
   i++;
  if (src[i] == '=' || i++ >= sizeof_src)
   break;
  b = (c << 2) & 0xfc;
  while (i<sizeof_src && (c = rstr[src[i]]) > 64)
   i++;
  if (src[i] == '=' || i++ >= sizeof_src)
   break;
  b |= (c>>4) & 0x03;
  if (d<sizeof_dst)
   dst[d++] = (unsigned char)b;
  if (i>=sizeof_src)
   break;
  b = (c<<4) & 0xF0;
  while (i<sizeof_src && src[i] != '=' && (c = rstr[src[i]]) > 64)
   ;
  if (src[i] == '=' || i++ >= sizeof_src)
   break;
  b |= (c>>2) & 0x0F;
  if (d<sizeof_dst)
   dst[d++] = (unsigned char)b;
  if (i>=sizeof_src)
   break;
  b = (c<<6) & 0xC0;
  while (i<sizeof_src && src[i] != '=' && (c = rstr[src[i]]) > 64)
   ;
  if (src[i] == '=' || i++ >= sizeof_src)
   break;
  b |= c;
  if (d<sizeof_dst)
   dst[d++] = (unsigned char)b;
  if (i>=sizeof_src)
   break;
 }
 if (d<sizeof_dst)
  dst[d] = '\0';
 return d;
}

variable_types:
rstr
unsigned char []

variable_types:
b
unsigned int


decompiled_code:
__int64 base64_selftest()
{
__int64 v0; // rax
int v1; // ebp
__int64 v3; // rax
unsigned int v4; // eax
unsigned __int64 v5; // r13
char *v6; // rbx
char *v7; // r12
__int64 v8; // rax
unsigned int v9; // [rsp+Ch] [rbp-17Ch] BYREF
char v10[112]; // [rsp+10h] [rbp-178h] BYREF
char s1[112]; // [rsp+80h] [rbp-108h] BYREF
char s2[152]; // [rsp+F0h] [rbp-98h] BYREF

v9 = time(0LL);
v0 = base64_encode((__int64)s2, 0x64uLL, (__int64)"hello", 5uLL);
if ( base64_decode(s1, 0x64uLL, (__int64)s2, v0) == 5 )
{
v1 = 100;
while ( 1 )
{
LABEL_8:
v4 = (unsigned int)r_rand(&v9) % 0x32;
v5 = v4;
if ( v4 )
{
v6 = s2;
v7 = &s2[v4];
do
*v6++ = r_rand(&v9);
while ( v6 != v7 );
v8 = base64_encode((__int64)s1, 0x64uLL, (__int64)s2, v5);
if ( v5 != base64_decode(v10, 0x64uLL, (__int64)s1, v8) && memcmp(v10, s2, v5) )
{
fwrite("base64: selftest failed\n", 1uLL, 0x18uLL, stderr);
return 1LL;
}
}
else
{
v3 = base64_encode((__int64)s1, 0x64uLL, (__int64)s2, 0LL);
base64_decode(v10, 0x64uLL, (__int64)s1, v3);
}
if ( !--v1 )
return 0LL;
}
}
v1 = 100;
if ( !memcmp(s1, "hello", 5uLL) )
goto LABEL_8;
fwrite("base64: selftest failed\n", 1uLL, 0x18uLL, stderr);
return 1LL;
}

canonical_decompiled_code:
__int64 func3()
{
__int64 v0; // rax
int v1; // ebp
__int64 v3; // rax
unsigned int v4; // eax
unsigned __int64 v5; // r13
char *v6; // rbx
char *v7; // r12
__int64 v8; // rax
unsigned int v9; // [rsp+Ch] [rbp-17Ch] BYREF
char v10[112]; // [rsp+10h] [rbp-178h] BYREF
char s1[112]; // [rsp+80h] [rbp-108h] BYREF
char s2[152]; // [rsp+F0h] [rbp-98h] BYREF

v9 = time(0LL);
v0 = func1((__int64)s2, 0x64uLL, (__int64)"hello", 5uLL);
if ( func2(s1, 0x64uLL, (__int64)s2, v0) == 5 )
{
v1 = 100;
while ( 1 )
{
LABEL_8:
v4 = (unsigned int)func0(&v9) % 0x32;
v5 = v4;
if ( v4 )
{
v6 = s2;
v7 = &s2[v4];
do
*v6++ = func0(&v9);
while ( v6 != v7 );
v8 = func1((__int64)s1, 0x64uLL, (__int64)s2, v5);
if ( v5 != func2(v10, 0x64uLL, (__int64)s1, v8) && memcmp(v10, s2, v5) )
{
fwrite("base64: selftest failed\n", 1uLL, 0x18uLL, stderr);
return 1LL;
}
}
else
{
v3 = func1((__int64)s1, 0x64uLL, (__int64)s2, 0LL);
func2(v10, 0x64uLL, (__int64)s1, v3);
}
if ( !--v1 )
return 0LL;
}
}
v1 = 100;
if ( !memcmp(s1, "hello", 5uLL) )
goto LABEL_8;
fwrite("base64: selftest failed\n", 1uLL, 0x18uLL, stderr);
return 1LL;
}

original_code:
int
base64_selftest(void)
{
    char buf[100];
    char buf2[100];
    char buf3[100];
    size_t buf_len;
    size_t buf2_len;
    unsigned i;
    unsigned seed = (unsigned)time(0);
    buf_len = base64_encode(buf, sizeof(buf), "hello", 5);
    buf2_len = base64_decode(buf2, sizeof(buf2), buf, buf_len);
    if (buf2_len != 5 && memcmp(buf2, "hello", 5) != 0) {
        fprintf(stderr, "base64: selftest failed\n");
        return 1;
    }
    for (i=0; i<100; i++) {
        unsigned j;
        size_t buf3_len;
        buf_len = r_rand(&seed) % 50;
        for (j=0; j<buf_len; j++) {
            buf[j] = (char)r_rand(&seed);
        }
        buf2_len = base64_encode(buf2, sizeof(buf2), buf, buf_len);
        buf3_len = base64_decode(buf3, sizeof(buf3), buf2, buf2_len);
        if (buf3_len != buf_len && memcmp(buf3, buf, buf_len) != 0) {
            fprintf(stderr, "base64: selftest failed\n");
            return 1;
        }
    }
    return 0;
}

canonical_original_code:
int base64_selftest()
{
    char buf[100];
    char buf2[100];
    char buf3[100];
    unsigned long buf_len;
    unsigned long buf2_len;
    unsigned int i;
    unsigned int seed = (unsigned)time(0);
    buf_len = base64_encode(buf, sizeof(buf), "hello", 5);
    buf2_len = base64_decode(buf2, sizeof(buf2), buf, buf_len);
    if (buf2_len != 5 && memcmp(buf2, "hello", 5) != 0) {
        fprintf(stderr, "base64: selftest failed\n");
        return 1;
    }
    for (i=0; i<100; i++) {
        unsigned int j;
        unsigned long buf3_len;
        buf_len = r_rand(&seed) % 50;
        for (j=0; j<buf_len; j++) {
            buf[j] = (char)r_rand(&seed);
        }
        buf2_len = base64_encode(buf2, sizeof(buf2), buf, buf_len);
        buf3_len = base64_decode(buf3, sizeof(buf3), buf2, buf2_len);
        if (buf3_len != buf_len && memcmp(buf3, buf, buf_len) != 0) {
            fprintf(stderr, "base64: selftest failed\n");
            return 1;
        }
    }
    return 0;
}

variable_types:
buf
char [100]

variable_types:
i
unsigned int

variable_types:
seed
unsigned int


decompiled_code:
__int64 __fastcall tcp_transmit_alloc(__int64 a1, __int64 a2)
{
return MALLOC(a2);
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 a2)
{
return MALLOC(a2);
}

original_code:
unsigned char *
tcp_transmit_alloc(struct InteractiveData *more, size_t length)
{
    (void) more;
    return MALLOC(length);
}

canonical_original_code:
unsigned char *tcp_transmit_alloc(struct InteractiveData *more, unsigned long length)
{
    (void) more;
    return MALLOC(length);
}

variable_types: struct InteractiveData { void *m_payload; unsigned int m_length; unsigned int is_payload_dynamic; unsigned int is_closing; } *

variable_types:
length
unsigned long

return_type: unsigned char *


decompiled_code:
void __fastcall tcp_close(__int64 a1)
{
if ( a1 )
*(_BYTE *)(a1 + 12) |= 2u;
}

original_code:
void
tcp_close(struct InteractiveData *more)
{
    if (more == ((void *)0))
        return;
    more->is_closing = 1;
}

user_defined_types: struct InteractiveData { void *m_payload; unsigned int m_length; unsigned int is_payload_dynamic; unsigned int is_closing; }


original_code:
void
tcp_transmit(struct InteractiveData *more, const void *payload, size_t length, unsigned flags)
{
    more->m_payload = payload;
    more->m_length = (unsigned)length;
    if (flags & TCPTRAN_DYNAMIC)
        more->is_payload_dynamic = 1;
}

canonical_original_code:
void tcp_transmit(struct InteractiveData *more, void *payload, unsigned long length, unsigned int flags)
{
    more->m_payload = payload;
    more->m_length = (unsigned int)length;
    if (flags & TCPTRAN_DYNAMIC)
        more->is_payload_dynamic = 1;
}

variable_types:
payload
void *

variable_types:
flags
unsigned int


memcasecmp

decompiled_code:
__int64 __fastcall memcasecmp(__int64 a1, __int64 a2, int a3)
{
const __int32_t *v4; // rdx
__int64 v5; // rax

if ( a3 <= 0 )
return 0LL;
v4 = *_ctype_tolower_loc();
v5 = 0LL;
while ( v4[*(char *)(a2 + v5)] == v4[*(char *)(a1 + v5)] )
{
if ( ++v5 == a3 )
return 0LL;
}
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, __int64 a2, int a3)
{
const __int32_t *v4; // rdx
__int64 v5; // rax

if ( a3 <= 0 )
return 0LL;
v4 = *_ctype_tolower_loc();
v5 = 0LL;
while ( v4[*(char *)(a2 + v5)] == v4[*(char *)(a1 + v5)] )
{
if ( ++v5 == a3 )
return 0LL;
}
return 0xFFFFFFFFLL;
}

original_code:
int
memcasecmp(const void *lhs, const void *rhs, int length)
{
    int i;
    for (i=0; i<length; i++) {
        if (tolower(((char*)lhs)[i]) != tolower(((char*)rhs)[i]))
            return -1;
    }
    return 0;
}

canonical_original_code:
int memcasecmp(void *lhs, void *rhs, int length)
{
    int i;
    for (i=0; i<length; i++) {
        if (tolower(((char *)lhs)[i]) != tolower(((char *)rhs)[i]))
            return -1;
    }
    return 0;
}

variable_types:
lhs
void *

variable_types:
rhs
void *

variable_types: length int

variable_types: i int


decompiled_code:
__int64 __fastcall strcpy_s(_BYTE *a1, unsigned __int64 a2, char *a3)
{
__int64 result; // rax
char v5; // dl
unsigned __int64 v6; // rax

result = 34LL;
if ( a2 )
{
if ( a1 )
{
if ( a3 )
{
v5 = *a3;
v6 = 0LL;
if ( !v5 )
goto LABEL_10;
while ( 1 )
{
a1[v6++] = v5;
v5 = a3[v6];
if ( !v5 )
break;
if ( a2 == v6 )
{
*a1 = 0;
return 34LL;
}
}
if ( a2 <= v6 )
{
*a1 = 0;
result = 34LL;
}
else
{
LABEL_10:
a1[v6] = 0;
result = 0LL;
}
}
else
{
*a1 = 0;
result = 22LL;
}
}
else
{
result = 22LL;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(_BYTE *a1, unsigned __int64 a2, char *a3)
{
__int64 result; // rax
char v5; // dl
unsigned __int64 v6; // rax

result = 34LL;
if ( a2 )
{
if ( a1 )
{
if ( a3 )
{
v5 = *a3;
v6 = 0LL;
if ( !v5 )
goto LABEL_10;
while ( 1 )
{
a1[v6++] = v5;
v5 = a3[v6];
if ( !v5 )
break;
if ( a2 == v6 )
{
*a1 = 0;
return 34LL;
}
}
if ( a2 <= v6 )
{
*a1 = 0;
result = 34LL;
}
else
{
LABEL_10:
a1[v6] = 0;
result = 0LL;
}
}
else
{
*a1 = 0;
result = 22LL;
}
}
else
{
result = 22LL;
}
}
return result;
}

original_code:
errno_t strcpy_s(char *dst, size_t sizeof_dst, const char *src)
{
    size_t i;
    if (sizeof_dst == 0)
        return 34;
    if (dst == ((void *)0))
        return 22;
    if (src == ((void *)0)) {
        dst[0] = 0;
        return 22;
    }
    for (i=0; src[i]; i++) {
        if (i >= sizeof_dst) {
            dst[0] = 0;
            return 34;
        } else
            dst[i] = src[i];
    }
    if (i >= sizeof_dst) {
        dst[0] = 0;
        return 34;
    } else
        dst[i] = src[i];
    return 0;
}

canonical_original_code:
int strcpy_s(char *dst, unsigned long sizeof_dst, char *src)
{
    unsigned long i;
    if (sizeof_dst == 0)
        return 34;
    if (dst == ((void *)0))
        return 22;
    if (src == ((void *)0)) {
        dst[0] = 0;
        return 22;
    }
    for (i=0; src[i]; i++) {
        if (i >= sizeof_dst) {
            dst[0] = 0;
            return 34;
        } else
            dst[i] = src[i];
    }
    if (i >= sizeof_dst) {
        dst[0] = 0;
        return 34;
    } else
        dst[i] = src[i];
    return 0;
}

variable_types:
dst
char *

variable_types:
src
char *

variable_types:
i
unsigned long


original_code:
errno_t localtime_s(struct tm* _tm, const time_t *time)
{
    struct tm *x;
    x = localtime(time);
    if (x == ((void *)0)) {
        memset(_tm, 0, sizeof(*_tm));
        return -1;
    }
    memcpy(_tm, x, sizeof(*_tm));
    return 0;
}

canonical_original_code:
int localtime_s(struct tm *_tm, long *time)
{
    struct tm *x;
    x = localtime(time);
    if (x == ((void *)0)) {
        memset(_tm, 0, sizeof(*_tm));
        return -1;
    }
    memcpy(_tm, x, sizeof(*_tm));
    return 0;
}

variable_types: struct tm { int tm_sec; int tm_min; int tm_hour; int tm_mday; int tm_mon; int tm_year; int tm_wday; int tm_yday; int tm_isdst; long tm_gmtoff; char *tm_zone; } *

variable_types:
time
long *


original_code:
errno_t gmtime_s(struct tm* _tm, const time_t *time)
{
    struct tm *x;
    x = gmtime(time);
    if (x == ((void *)0)) {
        memset(_tm, 0, sizeof(*_tm));
        return -1;
    }
    memcpy(_tm, x, sizeof(*_tm));
    return 0;
}

canonical_original_code:
int gmtime_s(struct tm *_tm, long *time)
{
    struct tm *x;
    x = gmtime(time);
    if (x == ((void *)0)) {
        memset(_tm, 0, sizeof(*_tm));
        return -1;
    }
    memcpy(_tm, x, sizeof(*_tm));
    return 0;
}

user_defined_types: struct tm { int tm_sec; int tm_min; int tm_hour; int tm_mday; int tm_mon; int tm_year; int tm_wday; int tm_yday; int tm_isdst; long tm_gmtoff; char *tm_zone; }


decompiled_code:
char *__fastcall strerror_x(int a1)
{
return strerror(a1);
}

canonical_decompiled_code:
char *__fastcall func5(int a1)
{
return strerror(a1);
}

original_code:
const char *strerror_x(int x)
{
    return strerror(x);
}

variable_types: x int


decompiled_code:
__int64 PFRING_init()
{
void *v0; // rax
void *v1; // rbx
int v2; // ebp
void *v3; // rax
void *v4; // rax
void *v5; // rax
void *v6; // rax
void *v7; // rax
void *v8; // rax
void *v9; // rax
void *v10; // rax
int *v12; // rax
const char *v13; // rax
int *v14; // rax
const char *v15; // rax
int *v16; // rax
const char *v17; // rax
int *v18; // rax
const char *v19; // rax
int *v20; // rax
const char *v21; // rax
int *v22; // rax
const char *v23; // rax
int *v24; // rax
const char *v25; // rax
int *v26; // rax
const char *v27; // rax
int *v28; // rax
const char *v29; // rax
void *v30; // rax
int *v31; // rax
const char *v32; // rax

LOG(6LL, "pfring: initializing subsystem\n");
LOG(6LL, "pfring: looking for 'libpfring.so'\n");
v0 = dlopen("libpfring.so", 1);
if ( !v0 )
{
v12 = _errno_location();
v13 = (const char *)strerror_x((unsigned int)*v12);
LOG(2LL, "pfring: error: dlopen('libpfring.so'): %s\n", v13);
return 0LL;
}
v1 = v0;
LOG(2LL, "pfring: found 'libpfring.so'!\n");
PFRING[0] = (__int64)dlsym(v1, "pfring_open");
v2 = 0;
if ( !PFRING[0] )
{
v14 = _errno_location();
v15 = (const char *)strerror_x((unsigned int)*v14);
LOG(2LL, "pfring_%s: not found in 'libpfring.so': %s\n", "open", v15);
v2 = 1;
}
v3 = dlsym(v1, "pfring_close");
PFRING[1] = (__int64)v3;
if ( !v3 )
{
v16 = _errno_location();
v17 = (const char *)strerror_x((unsigned int)*v16);
LOG(2LL, "pfring_%s: not found in 'libpfring.so': %s\n", "close", v17);
v2 = 1;
}
v4 = dlsym(v1, "pfring_enable_ring");
PFRING[2] = (__int64)v4;
if ( !v4 )
{
v18 = _errno_location();
v19 = (const char *)strerror_x((unsigned int)*v18);
LOG(2LL, "pfring_%s: not found in 'libpfring.so': %s\n", "enable_ring", v19);
v2 = 1;
}
v5 = dlsym(v1, "pfring_send");
PFRING[3] = (__int64)v5;
if ( !v5 )
{
v20 = _errno_location();
v21 = (const char *)strerror_x((unsigned int)*v20);
LOG(2LL, "pfring_%s: not found in 'libpfring.so': %s\n", "send", v21);
v2 = 1;
}
v6 = dlsym(v1, "pfring_recv");
PFRING[4] = (__int64)v6;
if ( !v6 )
{
v22 = _errno_location();
v23 = (const char *)strerror_x((unsigned int)*v22);
LOG(2LL, "pfring_%s: not found in 'libpfring.so': %s\n", "recv", v23);
v2 = 1;
}
v7 = dlsym(v1, "pfring_poll");
PFRING[5] = (__int64)v7;
if ( !v7 )
{
v24 = _errno_location();
v25 = (const char *)strerror_x((unsigned int)*v24);
LOG(2LL, "pfring_%s: not found in 'libpfring.so': %s\n", "poll", v25);
v2 = 1;
}
v8 = dlsym(v1, "pfring_version");
PFRING[6] = (__int64)v8;
if ( !v8 )
{
v26 = _errno_location();
v27 = (const char *)strerror_x((unsigned int)*v26);
LOG(2LL, "pfring_%s: not found in 'libpfring.so': %s\n", "version", v27);
v2 = 1;
}
v9 = dlsym(v1, "pfring_set_direction");
PFRING[7] = (__int64)v9;
if ( !v9 )
{
v28 = _errno_location();
v29 = (const char *)strerror_x((unsigned int)*v28);
LOG(2LL, "pfring_%s: not found in 'libpfring.so': %s\n", "set_direction", v29);
v30 = dlsym(v1, "pfring_set_application_name");
PFRING[8] = (__int64)v30;
if ( v30 )
goto LABEL_19;
LABEL_23:
v31 = _errno_location();
v32 = (const char *)strerror_x((unsigned int)*v31);
LOG(2LL, "pfring_%s: not found in 'libpfring.so': %s\n", "set_application_name", v32);
goto LABEL_19;
}
v10 = dlsym(v1, "pfring_set_application_name");
PFRING[8] = (__int64)v10;
if ( !v10 )
goto LABEL_23;
if ( v2 )
{
LABEL_19:
PFRING[0] = 0LL;
PFRING[1] = 0LL;
PFRING[2] = 0LL;
PFRING[3] = 0LL;
PFRING[4] = 0LL;
PFRING[5] = 0LL;
PFRING[6] = 0LL;
PFRING[7] = 0LL;
PFRING[8] = 0LL;
PFRING[9] = 0LL;
LOG(2LL, "pfring: failed to load\n");
return 0LL;
}
LOG(2LL, "pfring: successfully loaded PF_RING API\n");
if ( (unsigned int)PFRING_is_installed() )
LOG(2LL, "pfring: found 'pf_ring' driver module\n");
else
LOG(0LL, "pfring: ERROR: 'pf_ring' driver module not found!!!!!\n");
return 0LL;
}

canonical_decompiled_code:
__int64 func1()
{
void *v0; // rax
void *v1; // rbx
int v2; // ebp
void *v3; // rax
void *v4; // rax
void *v5; // rax
void *v6; // rax
void *v7; // rax
void *v8; // rax
void *v9; // rax
void *v10; // rax
int *v12; // rax
const char *v13; // rax
int *v14; // rax
const char *v15; // rax
int *v16; // rax
const char *v17; // rax
int *v18; // rax
const char *v19; // rax
int *v20; // rax
const char *v21; // rax
int *v22; // rax
const char *v23; // rax
int *v24; // rax
const char *v25; // rax
int *v26; // rax
const char *v27; // rax
int *v28; // rax
const char *v29; // rax
void *v30; // rax
int *v31; // rax
const char *v32; // rax

LOG(6LL, "pfring: initializing subsystem\n");
LOG(6LL, "pfring: looking for 'libpfring.so'\n");
v0 = dlopen("libpfring.so", 1);
if ( !v0 )
{
v12 = _errno_location();
v13 = (const char *)strerror_x((unsigned int)*v12);
LOG(2LL, "pfring: error: dlopen('libpfring.so'): %s\n", v13);
return 0LL;
}
v1 = v0;
LOG(2LL, "pfring: found 'libpfring.so'!\n");
PFRING[0] = (__int64)dlsym(v1, "pfring_open");
v2 = 0;
if ( !PFRING[0] )
{
v14 = _errno_location();
v15 = (const char *)strerror_x((unsigned int)*v14);
LOG(2LL, "pfring_%s: not found in 'libpfring.so': %s\n", "open", v15);
v2 = 1;
}
v3 = dlsym(v1, "pfring_close");
PFRING[1] = (__int64)v3;
if ( !v3 )
{
v16 = _errno_location();
v17 = (const char *)strerror_x((unsigned int)*v16);
LOG(2LL, "pfring_%s: not found in 'libpfring.so': %s\n", "close", v17);
v2 = 1;
}
v4 = dlsym(v1, "pfring_enable_ring");
PFRING[2] = (__int64)v4;
if ( !v4 )
{
v18 = _errno_location();
v19 = (const char *)strerror_x((unsigned int)*v18);
LOG(2LL, "pfring_%s: not found in 'libpfring.so': %s\n", "enable_ring", v19);
v2 = 1;
}
v5 = dlsym(v1, "pfring_send");
PFRING[3] = (__int64)v5;
if ( !v5 )
{
v20 = _errno_location();
v21 = (const char *)strerror_x((unsigned int)*v20);
LOG(2LL, "pfring_%s: not found in 'libpfring.so': %s\n", "send", v21);
v2 = 1;
}
v6 = dlsym(v1, "pfring_recv");
PFRING[4] = (__int64)v6;
if ( !v6 )
{
v22 = _errno_location();
v23 = (const char *)strerror_x((unsigned int)*v22);
LOG(2LL, "pfring_%s: not found in 'libpfring.so': %s\n", "recv", v23);
v2 = 1;
}
v7 = dlsym(v1, "pfring_poll");
PFRING[5] = (__int64)v7;
if ( !v7 )
{
v24 = _errno_location();
v25 = (const char *)strerror_x((unsigned int)*v24);
LOG(2LL, "pfring_%s: not found in 'libpfring.so': %s\n", "poll", v25);
v2 = 1;
}
v8 = dlsym(v1, "pfring_version");
PFRING[6] = (__int64)v8;
if ( !v8 )
{
v26 = _errno_location();
v27 = (const char *)strerror_x((unsigned int)*v26);
LOG(2LL, "pfring_%s: not found in 'libpfring.so': %s\n", "version", v27);
v2 = 1;
}
v9 = dlsym(v1, "pfring_set_direction");
PFRING[7] = (__int64)v9;
if ( !v9 )
{
v28 = _errno_location();
v29 = (const char *)strerror_x((unsigned int)*v28);
LOG(2LL, "pfring_%s: not found in 'libpfring.so': %s\n", "set_direction", v29);
v30 = dlsym(v1, "pfring_set_application_name");
PFRING[8] = (__int64)v30;
if ( v30 )
goto LABEL_19;
LABEL_23:
v31 = _errno_location();
v32 = (const char *)strerror_x((unsigned int)*v31);
LOG(2LL, "pfring_%s: not found in 'libpfring.so': %s\n", "set_application_name", v32);
goto LABEL_19;
}
v10 = dlsym(v1, "pfring_set_application_name");
PFRING[8] = (__int64)v10;
if ( !v10 )
goto LABEL_23;
if ( v2 )
{
LABEL_19:
PFRING[0] = 0LL;
PFRING[1] = 0LL;
PFRING[2] = 0LL;
PFRING[3] = 0LL;
PFRING[4] = 0LL;
PFRING[5] = 0LL;
PFRING[6] = 0LL;
PFRING[7] = 0LL;
PFRING[8] = 0LL;
PFRING[9] = 0LL;
LOG(2LL, "pfring: failed to load\n");
return 0LL;
}
LOG(2LL, "pfring: successfully loaded PF_RING API\n");
if ( (unsigned int)func0() )
LOG(2LL, "pfring: found 'pf_ring' driver module\n");
else
LOG(0LL, "pfring: ERROR: 'pf_ring' driver module not found!!!!!\n");
return 0LL;
}

original_code:
int
PFRING_init(void)
{
    void *h;
    int err = 0;
    LOG(6, "pfring: initializing subsystem\n");
    LOG(6, "pfring: looking for 'libpfring.so'\n");
    h = dlopen("libpfring.so", 0x00001);
    if (h == ((void *)0)) {
        LOG(2, "pfring: error: dlopen('libpfring.so'): %s\n", strerror_x((*__errno_location ())));
        return 0;
    } else
        LOG(2, "pfring: found 'libpfring.so'!\n");
    if ((PFRING.open = dlsym(h, "pfring_""open")) == 0) {LOG(2, "pfring_%s: not found in 'libpfring.so': %s\n", "open", strerror_x((*__errno_location ())));err=1;};
    if ((PFRING.close = dlsym(h, "pfring_""close")) == 0) {LOG(2, "pfring_%s: not found in 'libpfring.so': %s\n", "close", strerror_x((*__errno_location ())));err=1;};
    if ((PFRING.enable_ring = dlsym(h, "pfring_""enable_ring")) == 0) {LOG(2, "pfring_%s: not found in 'libpfring.so': %s\n", "enable_ring", strerror_x((*__errno_location ())));err=1;};
    if ((PFRING.send = dlsym(h, "pfring_""send")) == 0) {LOG(2, "pfring_%s: not found in 'libpfring.so': %s\n", "send", strerror_x((*__errno_location ())));err=1;};
    if ((PFRING.recv = dlsym(h, "pfring_""recv")) == 0) {LOG(2, "pfring_%s: not found in 'libpfring.so': %s\n", "recv", strerror_x((*__errno_location ())));err=1;};
    if ((PFRING.poll = dlsym(h, "pfring_""poll")) == 0) {LOG(2, "pfring_%s: not found in 'libpfring.so': %s\n", "poll", strerror_x((*__errno_location ())));err=1;};
    if ((PFRING.version = dlsym(h, "pfring_""version")) == 0) {LOG(2, "pfring_%s: not found in 'libpfring.so': %s\n", "version", strerror_x((*__errno_location ())));err=1;};
    if ((PFRING.set_direction = dlsym(h, "pfring_""set_direction")) == 0) {LOG(2, "pfring_%s: not found in 'libpfring.so': %s\n", "set_direction", strerror_x((*__errno_location ())));err=1;};
    if ((PFRING.set_application_name = dlsym(h, "pfring_""set_application_name")) == 0) {LOG(2, "pfring_%s: not found in 'libpfring.so': %s\n", "set_application_name", strerror_x((*__errno_location ())));err=1;};
    if (err) {
        memset(&PFRING, 0, sizeof(PFRING));
        LOG(2, "pfring: failed to load\n");
    } else {
        LOG(2, "pfring: successfully loaded PF_RING API\n");
        if (!PFRING_is_installed()) {
            LOG(0, "pfring: ERROR: 'pf_ring' driver module not found!!!!!\n");
        } else
            LOG(2, "pfring: found 'pf_ring' driver module\n");
    }
    return 0;
}

canonical_original_code:
int PFRING_init()
{
    void *h;
    int err = 0;
    LOG(6, "pfring: initializing subsystem\n");
    LOG(6, "pfring: looking for 'libpfring.so'\n");
    h = dlopen("libpfring.so", 0x00001);
    if (h == ((void *)0)) {
        LOG(2, "pfring: error: dlopen('libpfring.so'): %s\n", strerror_x((*__errno_location ())));
        return 0;
    } else
        LOG(2, "pfring: found 'libpfring.so'!\n");
    if ((PFRING.open = dlsym(h, "pfring_""open")) == 0) {LOG(2, "pfring_%s: not found in 'libpfring.so': %s\n", "open", strerror_x((*__errno_location ())));err=1;};
    if ((PFRING.close = dlsym(h, "pfring_""close")) == 0) {LOG(2, "pfring_%s: not found in 'libpfring.so': %s\n", "close", strerror_x((*__errno_location ())));err=1;};
    if ((PFRING.enable_ring = dlsym(h, "pfring_""enable_ring")) == 0) {LOG(2, "pfring_%s: not found in 'libpfring.so': %s\n", "enable_ring", strerror_x((*__errno_location ())));err=1;};
    if ((PFRING.send = dlsym(h, "pfring_""send")) == 0) {LOG(2, "pfring_%s: not found in 'libpfring.so': %s\n", "send", strerror_x((*__errno_location ())));err=1;};
    if ((PFRING.recv = dlsym(h, "pfring_""recv")) == 0) {LOG(2, "pfring_%s: not found in 'libpfring.so': %s\n", "recv", strerror_x((*__errno_location ())));err=1;};
    if ((PFRING.poll = dlsym(h, "pfring_""poll")) == 0) {LOG(2, "pfring_%s: not found in 'libpfring.so': %s\n", "poll", strerror_x((*__errno_location ())));err=1;};
    if ((PFRING.version = dlsym(h, "pfring_""version")) == 0) {LOG(2, "pfring_%s: not found in 'libpfring.so': %s\n", "version", strerror_x((*__errno_location ())));err=1;};
    if ((PFRING.set_direction = dlsym(h, "pfring_""set_direction")) == 0) {LOG(2, "pfring_%s: not found in 'libpfring.so': %s\n", "set_direction", strerror_x((*__errno_location ())));err=1;};
    if ((PFRING.set_application_name = dlsym(h, "pfring_""set_application_name")) == 0) {LOG(2, "pfring_%s: not found in 'libpfring.so': %s\n", "set_application_name", strerror_x((*__errno_location ())));err=1;};
    if (err) {
        memset(&PFRING, 0, sizeof(PFRING));
        LOG(2, "pfring: failed to load\n");
    } else {
        LOG(2, "pfring: successfully loaded PF_RING API\n");
        if (!PFRING_is_installed()) {
            LOG(0, "pfring: ERROR: 'pf_ring' driver module not found!!!!!\n");
        } else
            LOG(2, "pfring: found 'pf_ring' driver module\n");
    }
    return 0;
}

variable_types:
h
void *

variable_types: err int


decompiled_code:
__int64 __fastcall val2string_lookup(__int64 a1, int a2)
{
__int64 v2; // rcx
__int64 v3; // rax
int v4; // edx

v2 = *(_QWORD *)(a1 + 8);
if ( v2 )
{
v3 = a1;
v4 = 0;
do
{
if ( *(_DWORD *)v3 == a2 )
break;
v3 = a1 + 16LL * (unsigned int)++v4;
v2 = *(_QWORD *)(v3 + 8);
}
while ( v2 );
}
return v2;
}

original_code:
static const char *
val2string_lookup(const struct Val2String *list, unsigned val)
{
    unsigned i;
    for (i=0; list[i].string; i++) {
        if (list[i].value == val)
            return list[i].string;
    }
    return 0;
}

canonical_original_code:
static char *val2string_lookup(struct Val2String *list, unsigned int val)
{
    unsigned int i;
    for (i=0; list[i].string; i++) {
        if (list[i].value == val)
            return list[i].string;
    }
    return 0;
}

variable_types: struct Val2String { unsigned int value; char *string; } *

variable_types:
val
unsigned int

variable_types:
i
unsigned int


decompiled_code:
__int64 ntp_set_cookie()
{
return 0LL;
}

canonical_decompiled_code:
__int64 func4()
{
return 0LL;
}

original_code:
unsigned
ntp_set_cookie(unsigned char *px, size_t length, uint64_t seqno)
{
    (void) px;
    (void) length;
    (void) seqno;
    return 0;
}

canonical_original_code:
unsigned int ntp_set_cookie(unsigned char *px, unsigned long length, unsigned long seqno)
{
    (void) px;
    (void) length;
    (void) seqno;
    return 0;
}

variable_types:
px
unsigned char *

variable_types:
length
unsigned long

variable_types:
seqno
unsigned long


decompiled_code:
__int64 ntp_selftest()
{
return 0LL;
}

canonical_decompiled_code:
__int64 func6()
{
return 0LL;
}

original_code:
int
ntp_selftest(void)
{
    return 0;
}

canonical_original_code:
int ntp_selftest()
{
    return 0;
}


decompiled_code:
int __fastcall pixie_usleep(unsigned __int64 a1)
{
int *v1; // rax
struct timespec v3; // [rsp+0h] [rbp-28h] BYREF
struct timespec requested_time; // [rsp+10h] [rbp-18h] BYREF

requested_time.tv_sec = a1 / 0xF4240;
requested_time.tv_nsec = 1000 * (a1 % 0xF4240);
while ( 1 )
{
LODWORD(v1) = nanosleep(&requested_time, &v3);
if ( (_DWORD)v1 != -1 )
break;
v1 = _errno_location();
if ( *v1 != 4 )
break;
requested_time = (struct timespec)_mm_loadu_si128((const __m128i *)&v3);
}
return (int)v1;
}

canonical_decompiled_code:
int __fastcall func0(unsigned __int64 a1)
{
int *v1; // rax
struct timespec v3; // [rsp+0h] [rbp-28h] BYREF
struct timespec requested_time; // [rsp+10h] [rbp-18h] BYREF

requested_time.tv_sec = a1 / 0xF4240;
requested_time.tv_nsec = 1000 * (a1 % 0xF4240);
while ( 1 )
{
LODWORD(v1) = nanosleep(&requested_time, &v3);
if ( (_DWORD)v1 != -1 )
break;
v1 = _errno_location();
if ( *v1 != 4 )
break;
requested_time = (struct timespec)_mm_loadu_si128((const __m128i *)&v3);
}
return (int)v1;
}

original_code:
void
pixie_usleep(uint64_t microseconds)
{
    struct timespec ts;
    struct timespec remaining;
    int err;
    ts.tv_sec = microseconds/1000000;
    ts.tv_nsec = (microseconds%1000000) * 1000;
again:
    err = nanosleep(&ts, &remaining);
    if (err == -1 && (*__errno_location ()) == 4) {
        memcpy(&ts, &remaining, sizeof(ts));
        goto again;
    }
}

canonical_original_code:
void pixie_usleep(unsigned long microseconds)
{
    struct timespec ts;
    struct timespec remaining;
    int err;
    ts.tv_sec = microseconds/1000000;
    ts.tv_nsec = (microseconds%1000000) * 1000;
again:
    err = nanosleep(&ts, &remaining);
    if (err == -1 && (*__errno_location ()) == 4) {
        memcpy(&ts, &remaining, sizeof(ts));
        goto again;
    }
}

variable_types:
microseconds
unsigned long

variable_types: struct timespec { long tv_sec; long tv_nsec; }


decompiled_code:
int __fastcall pixie_mssleep(unsigned int a1)
{
return pixie_usleep(1000LL * a1);
}

canonical_decompiled_code:
int __fastcall func1(unsigned int a1)
{
return func0(1000LL * a1);
}

original_code:
void
pixie_mssleep(unsigned milliseconds)
{
    pixie_usleep(milliseconds * 1000ULL);
}

canonical_original_code:
void pixie_mssleep(unsigned int milliseconds)
{
    pixie_usleep(milliseconds * 1000ULL);
}

variable_types:
milliseconds
unsigned int


decompiled_code:
__time_t pixie_gettime()
{
int *v1; // rax
struct timespec v2; // [rsp+0h] [rbp-18h] BYREF

if ( clock_gettime(1, &v2) )
{
v1 = _errno_location();
printf("clock_gettime() err %d\n", (unsigned int)*v1);
}
return 1000000 * v2.tv_sec + v2.tv_nsec / 1000;
}

canonical_decompiled_code:
__time_t func2()
{
int *v1; // rax
struct timespec v2; // [rsp+0h] [rbp-18h] BYREF

if ( clock_gettime(1, &v2) )
{
v1 = _errno_location();
printf("clock_gettime() err %d\n", (unsigned int)*v1);
}
return 1000000 * v2.tv_sec + v2.tv_nsec / 1000;
}

original_code:
uint64_t
pixie_gettime(void)
{
    int x;
    struct timespec tv;
    x = clock_gettime(1, &tv);
    if (x != 0) {
        printf("clock_gettime() err %d\n", (*__errno_location ()));
    }
    return tv.tv_sec * 1000000 + tv.tv_nsec/1000;
}

canonical_original_code:
unsigned long pixie_gettime()
{
    int x;
    struct timespec tv;
    x = clock_gettime(1, &tv);
    if (x != 0) {
        printf("clock_gettime() err %d\n", (*__errno_location ()));
    }
    return tv.tv_sec * 1000000 + tv.tv_nsec/1000;
}

user_defined_types: struct timespec { long tv_sec; long tv_nsec; }


decompiled_code:
__syscall_slong_t pixie_nanotime()
{
int *v1; // rax
struct timespec v2; // [rsp+0h] [rbp-18h] BYREF

if ( clock_gettime(4, &v2) )
{
v1 = _errno_location();
printf("clock_gettime() err %d\n", (unsigned int)*v1);
}
return v2.tv_nsec + 1000000000 * v2.tv_sec;
}

canonical_decompiled_code:
__syscall_slong_t func3()
{
int *v1; // rax
struct timespec v2; // [rsp+0h] [rbp-18h] BYREF

if ( clock_gettime(4, &v2) )
{
v1 = _errno_location();
printf("clock_gettime() err %d\n", (unsigned int)*v1);
}
return v2.tv_nsec + 1000000000 * v2.tv_sec;
}

original_code:
uint64_t
pixie_nanotime(void)
{
    int x;
    struct timespec tv;
    x = clock_gettime(4, &tv);
    if (x != 0) {
        printf("clock_gettime() err %d\n", (*__errno_location ()));
    }
    return tv.tv_sec * 1000000000 + tv.tv_nsec;
}

canonical_original_code:
unsigned long pixie_nanotime()
{
    int x;
    struct timespec tv;
    x = clock_gettime(4, &tv);
    if (x != 0) {
        printf("clock_gettime() err %d\n", (*__errno_location ()));
    }
    return tv.tv_sec * 1000000000 + tv.tv_nsec;
}


decompiled_code:
__int64 pixie_time_selftest()
{
__time_t v0; // rbx
__int64 v1; // rax
double v2; // xmm0_8
__int64 result; // rax

v0 = pixie_gettime();
pixie_usleep(0x6F855uLL);
v1 = pixie_gettime() - v0;
if ( v1 < 0 )
v2 = (double)(int)(v1 & 1 | ((unsigned __int64)v1 >> 1)) + (double)(int)(v1 & 1 | ((unsigned __int64)v1 >> 1));
else
v2 = (double)(int)v1;
if ( v2 < 411110.1 )
{
fwrite("timing error, long delay\n", 1uLL, 0x19uLL, stderr);
result = 1LL;
}
else
{
result = 0LL;
if ( v2 > 548146.7999999999 )
{
fprintf(stderr, "timing error, long delay %5.0f%%\n", v2 * 100.0 / 456789.0);
result = 1LL;
}
}
return result;
}

canonical_decompiled_code:
__int64 func4()
{
__time_t v0; // rbx
__int64 v1; // rax
double v2; // xmm0_8
__int64 result; // rax

v0 = func2();
func0(0x6F855uLL);
v1 = func2() - v0;
if ( v1 < 0 )
v2 = (double)(int)(v1 & 1 | ((unsigned __int64)v1 >> 1)) + (double)(int)(v1 & 1 | ((unsigned __int64)v1 >> 1));
else
v2 = (double)(int)v1;
if ( v2 < 411110.1 )
{
fwrite("timing error, long delay\n", 1uLL, 0x19uLL, stderr);
result = 1LL;
}
else
{
result = 0LL;
if ( v2 > 548146.7999999999 )
{
fprintf(stderr, "timing error, long delay %5.0f%%\n", v2 * 100.0 / 456789.0);
result = 1LL;
}
}
return result;
}

original_code:
int pixie_time_selftest(void)
{
    static const uint64_t duration = 456789;
    uint64_t start, stop, elapsed;
    start = pixie_gettime();
    pixie_usleep(duration);
    stop = pixie_gettime();
    elapsed = stop - start;
    if (elapsed < 0.9 * duration) {
        fprintf(stderr, "timing error, long delay\n");
        return 1;
    }
    if (1.2 * duration < elapsed) {
        fprintf(stderr, "timing error, long delay %5.0f%%\n", elapsed*100.0/duration);
        return 1;
    }
    return 0;
}

canonical_original_code:
int pixie_time_selftest()
{
    static unsigned long duration = 456789;
    unsigned long start; unsigned long stop; unsigned long elapsed;
    start = pixie_gettime();
    pixie_usleep(duration);
    stop = pixie_gettime();
    elapsed = stop - start;
    if (elapsed < 0.9 * duration) {
        fprintf(stderr, "timing error, long delay\n");
        return 1;
    }
    if (1.2 * duration < elapsed) {
        fprintf(stderr, "timing error, long delay %5.0f%%\n", elapsed*100.0/duration);
        return 1;
    }
    return 0;
}

variable_types:
duration
unsigned long

variable_types:
start
unsigned long

variable_types:
stop
unsigned long

variable_types:
elapsed
unsigned long


original_code:
static void
proto_arp_parse(struct ARP_IncomingRequest *arp,
                const unsigned char px[], unsigned offset, unsigned max)
{
    if (offset+(8) > max) return;;
    arp->is_valid = 0;
    arp->hardware_type = px[offset]<<8 | px[offset+1];
    arp->protocol_type = px[offset+2]<<8 | px[offset+3];
    arp->hardware_length = px[offset+4];
    arp->protocol_length = px[offset+5];
    arp->opcode = px[offset+6]<<8 | px[offset+7];
    offset += 8;
    if (arp->protocol_length != 4 && arp->hardware_length != 6)
        return;
    if (arp->protocol_type != 0x0800)
        return;
    if (arp->hardware_type != 1 && arp->hardware_type != 6)
        return;
    if (offset+(2 * arp->hardware_length + 2 * arp->protocol_length) > max) return;;
    arp->mac_src = px+offset;
    offset += arp->hardware_length;
    arp->ip_src = px[offset+0]<<24 | px[offset+1]<<16 | px[offset+2]<<8 | px[offset+3];
    offset += arp->protocol_length;
    arp->mac_dst = px+offset;
    offset += arp->hardware_length;
    arp->ip_dst = px[offset+0]<<24 | px[offset+1]<<16 | px[offset+2]<<8 | px[offset+3];
    arp->is_valid = 1;
}

canonical_original_code:
static void proto_arp_parse(struct ARP_IncomingRequest *arp, unsigned char px[], unsigned int offset, unsigned int max)
{
    if (offset+(8) > max) return;;
    arp->is_valid = 0;
    arp->hardware_type = px[offset]<<8 | px[offset+1];
    arp->protocol_type = px[offset+2]<<8 | px[offset+3];
    arp->hardware_length = px[offset+4];
    arp->protocol_length = px[offset+5];
    arp->opcode = px[offset+6]<<8 | px[offset+7];
    offset += 8;
    if (arp->protocol_length != 4 && arp->hardware_length != 6)
        return;
    if (arp->protocol_type != 0x0800)
        return;
    if (arp->hardware_type != 1 && arp->hardware_type != 6)
        return;
    if (offset+(2 * arp->hardware_length + 2 * arp->protocol_length) > max) return;;
    arp->mac_src = px+offset;
    offset += arp->hardware_length;
    arp->ip_src = px[offset+0]<<24 | px[offset+1]<<16 | px[offset+2]<<8 | px[offset+3];
    offset += arp->protocol_length;
    arp->mac_dst = px+offset;
    offset += arp->hardware_length;
    arp->ip_dst = px[offset+0]<<24 | px[offset+1]<<16 | px[offset+2]<<8 | px[offset+3];
    arp->is_valid = 1;
}

variable_types: struct ARP_IncomingRequest { unsigned int is_valid; unsigned int opcode; unsigned int hardware_type; unsigned int protocol_type; unsigned int hardware_length; unsigned int protocol_length; unsigned int ip_src; unsigned int ip_dst; unsigned char *mac_src; unsigned char *mac_dst; } *

variable_types:
px
unsigned char []

variable_types:
offset
unsigned int

variable_types:
max
unsigned int


original_code:
int
stack_arp_incoming_request( struct stack_t *stack,
    ipv4address_t my_ip, macaddress_t my_mac,
    const unsigned char *px, unsigned length)
{
    struct PacketBuffer *response = 0;
    struct ARP_IncomingRequest request;
    memset(&request, 0, sizeof(request));
    response = stack_get_packetbuffer(stack);
    if (response == ((void *)0))
        return -1;
    response->length = 60;
    memset(response->px, 0, response->length);
    proto_arp_parse(&request, px, 14, length);
    if (!request.is_valid) {
        LOG(2, "arp: etype=0x%04x, not ARP\n", px[12]*256 + px[13]);
        return -1;
    }
    if (request.opcode != 1) {
        LOG(2, "arp: opcode=%u, not request(1)\n", request.opcode);
        return -1;
    }
    if (request.ip_dst != my_ip) {
        LOG(2, "arp: dst=%08x, not my ip 0x%08x\n", request.ip_dst, my_ip);
        return -1;
    }
    memcpy(response->px + 0, request.mac_src, 6);
    memcpy(response->px + 6, my_mac.addr, 6);
    memcpy(response->px + 12, "\x08\x06", 2);
    memcpy(response->px + 14,
            "\x00\x01"
            "\x08\x00"
            "\x06\x04"
            "\x00\x02"
            , 8);
    memcpy(response->px + 22, my_mac.addr, 6);
    response->px[28] = (unsigned char)(my_ip >> 24);
    response->px[29] = (unsigned char)(my_ip >> 16);
    response->px[30] = (unsigned char)(my_ip >> 8);
    response->px[31] = (unsigned char)(my_ip >> 0);
    memcpy(response->px + 32, request.mac_src, 6);
    response->px[38] = (unsigned char)(request.ip_src >> 24);
    response->px[39] = (unsigned char)(request.ip_src >> 16);
    response->px[40] = (unsigned char)(request.ip_src >> 8);
    response->px[41] = (unsigned char)(request.ip_src >> 0);
    stack_transmit_packetbuffer(stack, response);
    return 0;
}

canonical_original_code:
int stack_arp_incoming_request(struct stack_t *stack, unsigned int my_ip, struct macaddress_t my_mac, unsigned char *px, unsigned int length)
{
    struct PacketBuffer *response = 0;
    struct ARP_IncomingRequest request;
    memset(&request, 0, sizeof(request));
    response = stack_get_packetbuffer(stack);
    if (response == ((void *)0))
        return -1;
    response->length = 60;
    memset(response->px, 0, response->length);
    proto_arp_parse(&request, px, 14, length);
    if (!request.is_valid) {
        LOG(2, "arp: etype=0x%04x, not ARP\n", px[12]*256 + px[13]);
        return -1;
    }
    if (request.opcode != 1) {
        LOG(2, "arp: opcode=%u, not request(1)\n", request.opcode);
        return -1;
    }
    if (request.ip_dst != my_ip) {
        LOG(2, "arp: dst=%08x, not my ip 0x%08x\n", request.ip_dst, my_ip);
        return -1;
    }
    memcpy(response->px + 0, request.mac_src, 6);
    memcpy(response->px + 6, my_mac.addr, 6);
    memcpy(response->px + 12, "\x08\x06", 2);
    memcpy(response->px + 14,
            "\x00\x01"
            "\x08\x00"
            "\x06\x04"
            "\x00\x02"
            , 8);
    memcpy(response->px + 22, my_mac.addr, 6);
    response->px[28] = (unsigned char)(my_ip >> 24);
    response->px[29] = (unsigned char)(my_ip >> 16);
    response->px[30] = (unsigned char)(my_ip >> 8);
    response->px[31] = (unsigned char)(my_ip >> 0);
    memcpy(response->px + 32, request.mac_src, 6);
    response->px[38] = (unsigned char)(request.ip_src >> 24);
    response->px[39] = (unsigned char)(request.ip_src >> 16);
    response->px[40] = (unsigned char)(request.ip_src >> 8);
    response->px[41] = (unsigned char)(request.ip_src >> 0);
    stack_transmit_packetbuffer(stack, response);
    return 0;
}

variable_types: struct stack_t { struct rte_ring { int flags; struct prod { unsigned int watermark; unsigned int sp_enqueue; unsigned int size; unsigned int mask; unsigned int head; unsigned int tail; } prod; struct cons { unsigned int sc_dequeue; unsigned int size; unsigned int mask; unsigned int head; unsigned int tail; } cons; void *ring[1]; } *packet_buffers; struct rte_ring *transmit_queue; struct macaddress_t { unsigned char addr[6]; } source_mac; struct stack_src_t { struct { unsigned int first; unsigned int last; unsigned int range; } ipv4; struct { unsigned int first; unsigned int last; unsigned int range; } port; struct { struct ipv6address { unsigned long hi; unsigned long lo; } first; struct ipv6address last; unsigned int range; } ipv6; } *src; } *

variable_types:
length
unsigned int

variable_types: struct PacketBuffer { unsigned long length; unsigned char px[2040]; } *

variable_types: struct ARP_IncomingRequest { unsigned int is_valid; unsigned int opcode; unsigned int hardware_type; unsigned int protocol_type; unsigned int hardware_length; unsigned int protocol_length; unsigned int ip_src; unsigned int ip_dst; unsigned char *mac_src; unsigned char *mac_dst; }

user_defined_types: struct stack_t { struct rte_ring *packet_buffers; struct rte_ring *transmit_queue; struct macaddress_t source_mac; struct stack_src_t *src; }

user_defined_types: struct stack_src_t { struct { unsigned int first; unsigned int last; unsigned int range; } ipv4; struct { unsigned int first; unsigned int last; unsigned int range; } port; struct { struct ipv6address first; struct ipv6address last; unsigned int range; } ipv6; }


decompiled_code:
__int64 __fastcall massip_apply_excludes(__int64 a1, __int64 a2)
{
((void (*)(void))rangelist_exclude)();
range6list_exclude(a1 + 32, a2 + 32);
return rangelist_exclude(a1 + 72, a2 + 72);
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 a2)
{
((void (*)(void))rangelist_exclude)();
range6list_exclude(a1 + 32, a2 + 32);
return rangelist_exclude(a1 + 72, a2 + 72);
}

original_code:
void massip_apply_excludes(struct MassIP *targets, struct MassIP *exclude)
{
    rangelist_exclude(&targets->ipv4, &exclude->ipv4);
    range6list_exclude(&targets->ipv6, &exclude->ipv6);
    rangelist_exclude(&targets->ports, &exclude->ports);
}

variable_types: struct MassIP { struct RangeList { struct Range { unsigned int begin; unsigned int end; } *list; unsigned int count; unsigned int max; unsigned int *picker; unsigned int is_sorted; } ipv4; struct Range6List { struct Range6 { struct ipv6address { unsigned long hi; unsigned long lo; } begin; struct ipv6address end; } *list; unsigned long count; unsigned long max; unsigned long *picker; unsigned int is_sorted; } ipv6; struct RangeList ports; unsigned long ipv4_index_threshold; unsigned long count_ports; unsigned long count_ipv4s; unsigned long count_ipv6s; } *

variable_types:
exclude
struct MassIP *

user_defined_types: struct MassIP { struct RangeList ipv4; struct Range6List ipv6; struct RangeList ports; unsigned long ipv4_index_threshold; unsigned long count_ports; unsigned long count_ipv4s; unsigned long count_ipv6s; }

user_defined_types: struct RangeList { struct Range *list; unsigned int count; unsigned int max; unsigned int *picker; unsigned int is_sorted; }

user_defined_types: struct Range6List { struct Range6 *list; unsigned long count; unsigned long max; unsigned long *picker; unsigned int is_sorted; }

user_defined_types: struct Range6 { struct ipv6address begin; struct ipv6address end; }


original_code:
int massip_pick(const struct MassIP *massip, uint64_t index, ipaddress *addr, unsigned *port)
{
    if (index < massip->ipv4_index_threshold) {
        addr->version = 4;
        addr->ipv4 = rangelist_pick(&massip->ipv4, index % massip->count_ipv4s);
        *port = rangelist_pick(&massip->ports, index / massip->count_ipv4s);
    } else {
        addr->version = 6;
        index -= massip->ipv4_index_threshold;
        addr->ipv6 = range6list_pick(&massip->ipv6, index % massip->count_ipv6s);
        *port = rangelist_pick(&massip->ports, index / massip->count_ipv6s);
    }
    return 0;
}

canonical_original_code:
int massip_pick(struct MassIP *massip, unsigned long index, struct ipaddress *addr, unsigned int *port)
{
    if (index < massip->ipv4_index_threshold) {
        addr->version = 4;
        addr->ipv4 = rangelist_pick(&massip->ipv4, index % massip->count_ipv4s);
        *port = rangelist_pick(&massip->ports, index / massip->count_ipv4s);
    } else {
        addr->version = 6;
        index -= massip->ipv4_index_threshold;
        addr->ipv6 = range6list_pick(&massip->ipv6, index % massip->count_ipv6s);
        *port = rangelist_pick(&massip->ports, index / massip->count_ipv6s);
    }
    return 0;
}

variable_types:
index
unsigned long

variable_types: struct ipaddress { union { unsigned int ipv4; struct ipv6address ipv6; }; unsigned char version; } *

variable_types:
port
unsigned int *

user_defined_types: struct Range { unsigned int begin; unsigned int end; }

user_defined_types: struct ipv6address { unsigned long hi; unsigned long lo; }


decompiled_code:
__int64 __fastcall massip_has_ip(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6, __int64 a7, __int64 a8, char a9)
{
__int64 result; // rax

if ( a9 == 6 )
result = range6list_is_contains(a1 + 32, a7, a8);
else
result = rangelist_is_contains(a1, (unsigned int)a7);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6, __int64 a7, __int64 a8, char a9)
{
__int64 result; // rax

if ( a9 == 6 )
result = range6list_is_contains(a1 + 32, a7, a8);
else
result = rangelist_is_contains(a1, (unsigned int)a7);
return result;
}

original_code:
int massip_has_ip(const struct MassIP *massip, ipaddress ip)
{
    if (ip.version == 6)
        return range6list_is_contains(&massip->ipv6, ip.ipv6);
    else
        return rangelist_is_contains(&massip->ipv4, ip.ipv4);
}

canonical_original_code:
int massip_has_ip(struct MassIP *massip, struct ipaddress ip)
{
    if (ip.version == 6)
        return range6list_is_contains(&massip->ipv6, ip.ipv6);
    else
        return rangelist_is_contains(&massip->ipv4, ip.ipv4);
}

variable_types: struct ipaddress { union { unsigned int ipv4; struct ipv6address ipv6; }; unsigned char version; }


decompiled_code:
__int64 __fastcall massip_has_port(__int64 a1, __int64 a2)
{
return rangelist_is_contains(a1 + 72, a2);
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1, __int64 a2)
{
return rangelist_is_contains(a1 + 72, a2);
}

original_code:
int massip_has_port(const struct MassIP *massip, unsigned port)
{
    return rangelist_is_contains(&massip->ports, port);
}

canonical_original_code:
int massip_has_port(struct MassIP *massip, unsigned int port)
{
    return rangelist_is_contains(&massip->ports, port);
}

variable_types:
port
unsigned int


decompiled_code:
_BOOL8 __fastcall massip_has_ipv4_targets(__int64 a1)
{
return *(_DWORD *)(a1 + 8) != 0;
}

canonical_decompiled_code:
_BOOL8 __fastcall func5(__int64 a1)
{
return *(_DWORD *)(a1 + 8) != 0;
}

original_code:
int massip_has_ipv4_targets(const struct MassIP *massip)
{
    return massip->ipv4.count != 0;
}

canonical_original_code:
int massip_has_ipv4_targets(struct MassIP *massip)
{
    return massip->ipv4.count != 0;
}


decompiled_code:
_BOOL8 __fastcall massip_has_target_ports(__int64 a1)
{
return *(_DWORD *)(a1 + 80) != 0;
}

canonical_decompiled_code:
_BOOL8 __fastcall func6(__int64 a1)
{
return *(_DWORD *)(a1 + 80) != 0;
}

original_code:
int massip_has_target_ports(const struct MassIP *massip)
{
    return massip->ports.count != 0;
}

canonical_original_code:
int massip_has_target_ports(struct MassIP *massip)
{
    return massip->ports.count != 0;
}


decompiled_code:
_BOOL8 __fastcall massip_has_ipv6_targets(__int64 a1)
{
return *(_QWORD *)(a1 + 40) != 0LL;
}

canonical_decompiled_code:
_BOOL8 __fastcall func7(__int64 a1)
{
return *(_QWORD *)(a1 + 40) != 0LL;
}

original_code:
int massip_has_ipv6_targets(const struct MassIP *massip)
{
    return massip->ipv6.count != 0;
}

canonical_original_code:
int massip_has_ipv6_targets(struct MassIP *massip)
{
    return massip->ipv6.count != 0;
}


decompiled_code:
__int64 __fastcall massip_add_target_string(__int64 a1, const char *a2)
{
size_t v2; // rbp
unsigned __int64 v4; // rbx
const unsigned __int16 *v5; // rcx
unsigned __int8 v6; // al
int v7; // eax
int v8[2]; // [rsp+8h] [rbp-60h] BYREF
__int64 v9[5]; // [rsp+10h] [rbp-58h] BYREF
unsigned __int64 v10[6]; // [rsp+38h] [rbp-30h] BYREF

v10[0] = 0LL;
v2 = strlen(a2);
if ( !v2 )
return 0LL;
do
{
v7 = massip_parse_range(a2, v10, v2, v8, v9);
if ( v7 == 4 )
{
rangelist_add_range(a1, (unsigned int)v8[0], (unsigned int)v8[1]);
}
else
{
if ( v7 != 6 )
return 1LL;
range6list_add_range(a1 + 32, v9[0], v9[1], v9[2], v9[3]);
}
v4 = v10[0];
if ( v2 > v10[0] )
{
v5 = *_ctype_b_loc();
do
{
v6 = a2[v4];
if ( (v5[v6] & 0x2000) == 0 && v6 != 44 )
break;
v10[0] = ++v4;
}
while ( v4 != v2 );
}
}
while ( v10[0] < v2 );
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func8(__int64 a1, const char *a2)
{
size_t v2; // rbp
unsigned __int64 v4; // rbx
const unsigned __int16 *v5; // rcx
unsigned __int8 v6; // al
int v7; // eax
int v8[2]; // [rsp+8h] [rbp-60h] BYREF
__int64 v9[5]; // [rsp+10h] [rbp-58h] BYREF
unsigned __int64 v10[6]; // [rsp+38h] [rbp-30h] BYREF

v10[0] = 0LL;
v2 = strlen(a2);
if ( !v2 )
return 0LL;
do
{
v7 = massip_parse_range(a2, v10, v2, v8, v9);
if ( v7 == 4 )
{
rangelist_add_range(a1, (unsigned int)v8[0], (unsigned int)v8[1]);
}
else
{
if ( v7 != 6 )
return 1LL;
range6list_add_range(a1 + 32, v9[0], v9[1], v9[2], v9[3]);
}
v4 = v10[0];
if ( v2 > v10[0] )
{
v5 = *_ctype_b_loc();
do
{
v6 = a2[v4];
if ( (v5[v6] & 0x2000) == 0 && v6 != 44 )
break;
v10[0] = ++v4;
}
while ( v4 != v2 );
}
}
while ( v10[0] < v2 );
return 0LL;
}

original_code:
int massip_add_target_string(struct MassIP *massip, const char *string)
{
    const char *ranges = string;
    size_t offset = 0;
    size_t max_offset = strlen(ranges);
    while (offset < max_offset) {
        struct Range range;
        struct Range6 range6;
        int err;
        err = massip_parse_range(ranges, &offset, max_offset, &range, &range6);
        switch (err) {
        case Ipv4_Address:
            rangelist_add_range(&massip->ipv4, range.begin, range.end);
            break;
        case Ipv6_Address:
            range6list_add_range(&massip->ipv6, range6.begin, range6.end);
            break;
        default:
            offset = max_offset;
            return 1;
        }
        while (offset < max_offset && (((*__ctype_b_loc ())[(int) ((ranges[offset]&0xFF))] & (unsigned short int) _ISspace) || ranges[offset] == ','))
            offset++;
    }
    return 0;
}

canonical_original_code:
int massip_add_target_string(struct MassIP *massip, char *string)
{
    char *ranges = string;
    unsigned long offset = 0;
    unsigned long max_offset = strlen(ranges);
    while (offset < max_offset) {
        struct Range range;
        struct Range6 range6;
        int err;
        err = massip_parse_range(ranges, &offset, max_offset, &range, &range6);
        switch (err) {
        case Ipv4_Address:
            rangelist_add_range(&massip->ipv4, range.begin, range.end);
            break;
        case Ipv6_Address:
            range6list_add_range(&massip->ipv6, range6.begin, range6.end);
            break;
        default:
            offset = max_offset;
            return 1;
        }
        while (offset < max_offset && (((*__ctype_b_loc ())[(int) ((ranges[offset]&0xFF))] & (unsigned short) _ISspace) || ranges[offset] == ','))
            offset++;
    }
    return 0;
}

variable_types:
string
char *

variable_types:
ranges
char *

variable_types:
offset
unsigned long

variable_types: struct Range { unsigned int begin; unsigned int end; }

variable_types: struct Range6 { struct ipv6address { unsigned long hi; unsigned long lo; } begin; struct ipv6address end; }

variable_types: err int


decompiled_code:
_BOOL8 __fastcall massip_add_port_string(__int64 a1, __int64 a2, unsigned int a3)
{
int v4[3]; // [rsp+Ch] [rbp-Ch] BYREF

v4[0] = 0;
rangelist_parse_ports(a1 + 72, a2, v4, a3);
return v4[0] != 0;
}

canonical_decompiled_code:
_BOOL8 __fastcall func9(__int64 a1, __int64 a2, unsigned int a3)
{
int v4[3]; // [rsp+Ch] [rbp-Ch] BYREF

v4[0] = 0;
rangelist_parse_ports(a1 + 72, a2, v4, a3);
return v4[0] != 0;
}

original_code:
int massip_add_port_string(struct MassIP *targets, const char *string, unsigned defaultrange)
{
    unsigned is_error = 0;
    rangelist_parse_ports(&targets->ports, string, &is_error, defaultrange);
    if (is_error)
        return 1;
    else
        return 0;
}

canonical_original_code:
int massip_add_port_string(struct MassIP *targets, char *string, unsigned int defaultrange)
{
    unsigned int is_error = 0;
    rangelist_parse_ports(&targets->ports, string, &is_error, defaultrange);
    if (is_error)
        return 1;
    else
        return 0;
}

variable_types:
defaultrange
unsigned int