decompiled_code:
__int64 __fastcall ringbuffer_get(__int64 a1)
{
int v1; // eax
unsigned __int8 v2; // dl

v1 = *(_DWORD *)(a1 + 20);
if ( *(_DWORD *)(a1 + 16) == v1 )
return 0xFFFFFFFFLL;
v2 = *(_BYTE *)(*(_QWORD *)a1 + (v1 & ((unsigned int)*(_QWORD *)(a1 + 8) - 1)));
*(_DWORD *)(a1 + 20) = v1 + 1;
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1)
{
int v1; // eax
unsigned __int8 v2; // dl

v1 = *(_DWORD *)(a1 + 20);
if ( *(_DWORD *)(a1 + 16) == v1 )
return 0xFFFFFFFFLL;
v2 = *(_BYTE *)(*(_QWORD *)a1 + (v1 & ((unsigned int)*(_QWORD *)(a1 + 8) - 1)));
*(_DWORD *)(a1 + 20) = v1 + 1;
return v2;
}

original_code:
int ringbuffer_get(ringbuffer_t *pRB) {
    unsigned char value;
    if (((pRB)->headOffset - (pRB)->tailOffset) == 0) {
        return ring_empty;
    }
    value = pRB->pBuffer[pRB->tailOffset & (pRB->size - 1)];
    pRB->tailOffset ++;
    return value;
}

canonical_original_code:
int ringbuffer_get(struct ringbuffer_t *pRB) {
    unsigned char value;
    if (((pRB)->headOffset - (pRB)->tailOffset) == 0) {
        return ring_empty;
    }
    value = pRB->pBuffer[pRB->tailOffset & (pRB->size - 1)];
    pRB->tailOffset ++;
    return value;
}

variable_types:
value
unsigned char


repo: cdoenges/misclib

decompiled_code:
__int64 __fastcall ringbuffer_peek(__int64 a1)
{
int v1; // eax
__int64 result; // rax

v1 = *(_DWORD *)(a1 + 20);
if ( *(_DWORD *)(a1 + 16) == v1 )
result = 0xFFFFFFFFLL;
else
result = *(unsigned __int8 *)(*(_QWORD *)a1 + (((unsigned int)*(_QWORD *)(a1 + 8) - 1) & v1));
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1)
{
int v1; // eax
__int64 result; // rax

v1 = *(_DWORD *)(a1 + 20);
if ( *(_DWORD *)(a1 + 16) == v1 )
result = 0xFFFFFFFFLL;
else
result = *(unsigned __int8 *)(*(_QWORD *)a1 + (((unsigned int)*(_QWORD *)(a1 + 8) - 1) & v1));
return result;
}

original_code:
int ringbuffer_peek(ringbuffer_t *pRB) {
    unsigned char value;
    if (((pRB)->headOffset - (pRB)->tailOffset) == 0) {
        return ring_empty;
    }
    value = pRB->pBuffer[pRB->tailOffset & (pRB->size - 1)];
    return value;
}

canonical_original_code:
int ringbuffer_peek(struct ringbuffer_t *pRB) {
    unsigned char value;
    if (((pRB)->headOffset - (pRB)->tailOffset) == 0) {
        return ring_empty;
    }
    value = pRB->pBuffer[pRB->tailOffset & (pRB->size - 1)];
    return value;
}

variable_types: struct ringbuffer_t { unsigned char *pBuffer; unsigned long size; unsigned int headOffset; unsigned int tailOffset; } *

return_type: int


decompiled_code:
int log_flushLogfile()
{
if ( !logFileHandle )
_assert_fail("NULL != logFileHandle", "src/logging.c", 0x8Eu, "log_flushLogfile");
return fflush(logFileHandle);
}

canonical_decompiled_code:
int func0()
{
if ( !logFileHandle )
_assert_fail("NULL != logFileHandle", "src/logging.c", 0x8Eu, "log_flushLogfile");
return fflush(logFileHandle);
}

original_code:
void log_flushLogfile(void) {
    ((void) sizeof ((((void *)0) != logFileHandle) ? 1 : 0), __extension__ ({ if (((void *)0) != logFileHandle) ; else __assert_fail ("NULL != logFileHandle", "src/logging.c", 142, __extension__ __PRETTY_FUNCTION__); }));
    fflush(logFileHandle);
}

canonical_original_code:
void log_flushLogfile() {
    ((void) sizeof ((((void *)0) != logFileHandle) ? 1 : 0), __extension__ ({ if (((void *)0) != logFileHandle) ; else __assert_fail ("NULL != logFileHandle", "src/logging.c", 142, __extension__ __PRETTY_FUNCTION__); }));
    fflush(logFileHandle);
}

return_type: void


decompiled_code:
void __fastcall log_setFileLevel(unsigned int a1)
{
if ( a1 > 8 )
_assert_fail("(level >= LOGLEVEL_NONE) && (level < LOGLEVEL_ALWAYS)", "src/logging.c", 0x96u, "log_setFileLevel");
logLevelFile = a1;
}

canonical_decompiled_code:
void __fastcall func1(unsigned int a1)
{
if ( a1 > 8 )
_assert_fail("(level >= LOGLEVEL_NONE) && (level < LOGLEVEL_ALWAYS)", "src/logging.c", 0x96u, "log_setFileLevel");
logLevelFile = a1;
}

original_code:
void log_setFileLevel(log_level_t level) {
    ((void) sizeof (((level >= LOGLEVEL_NONE) && (level < LOGLEVEL_ALWAYS)) ? 1 : 0), __extension__ ({ if ((level >= LOGLEVEL_NONE) && (level < LOGLEVEL_ALWAYS)) ; else __assert_fail ("(level >= LOGLEVEL_NONE) && (level < LOGLEVEL_ALWAYS)", "src/logging.c", 150, __extension__ __PRETTY_FUNCTION__); }));
    logLevelFile = level;
}

canonical_original_code:
void log_setFileLevel(enum log_level_t level) {
    ((void) sizeof (((level >= LOGLEVEL_NONE) && (level < LOGLEVEL_ALWAYS)) ? 1 : 0), __extension__ ({ if ((level >= LOGLEVEL_NONE) && (level < LOGLEVEL_ALWAYS)) ; else __assert_fail ("(level >= LOGLEVEL_NONE) && (level < LOGLEVEL_ALWAYS)", "src/logging.c", 150, __extension__ __PRETTY_FUNCTION__); }));
    logLevelFile = level;
}

variable_types: enum log_level_t { LOGLEVEL_NONE=0, LOGLEVEL_DEBUG3=1, LOGLEVEL_DEBUG2=2, LOGLEVEL_DEBUG1=3, LOGLEVEL_DEBUG=4, LOGLEVEL_INFO=5, LOGLEVEL_WARNING=6, LOGLEVEL_ERROR=7, LOGLEVEL_FATAL=8, LOGLEVEL_ALWAYS=9 }


decompiled_code:
void __fastcall log_setStderrLevel(unsigned int a1)
{
if ( a1 > 8 )
_assert_fail("(level >= LOGLEVEL_NONE) && (level < LOGLEVEL_ALWAYS)", "src/logging.c", 0x9Eu, "log_setStderrLevel");
logLevelStderr = a1;
}

canonical_decompiled_code:
void __fastcall func2(unsigned int a1)
{
if ( a1 > 8 )
_assert_fail("(level >= LOGLEVEL_NONE) && (level < LOGLEVEL_ALWAYS)", "src/logging.c", 0x9Eu, "log_setStderrLevel");
logLevelStderr = a1;
}

original_code:
void log_setStderrLevel(log_level_t level) {
    ((void) sizeof (((level >= LOGLEVEL_NONE) && (level < LOGLEVEL_ALWAYS)) ? 1 : 0), __extension__ ({ if ((level >= LOGLEVEL_NONE) && (level < LOGLEVEL_ALWAYS)) ; else __assert_fail ("(level >= LOGLEVEL_NONE) && (level < LOGLEVEL_ALWAYS)", "src/logging.c", 158, __extension__ __PRETTY_FUNCTION__); }));
    logLevelStderr = level;
}

canonical_original_code:
void log_setStderrLevel(enum log_level_t level) {
    ((void) sizeof (((level >= LOGLEVEL_NONE) && (level < LOGLEVEL_ALWAYS)) ? 1 : 0), __extension__ ({ if ((level >= LOGLEVEL_NONE) && (level < LOGLEVEL_ALWAYS)) ; else __assert_fail ("(level >= LOGLEVEL_NONE) && (level < LOGLEVEL_ALWAYS)", "src/logging.c", 158, __extension__ __PRETTY_FUNCTION__); }));
    logLevelStderr = level;
}

user_defined_types: enum log_level_t { LOGLEVEL_NONE=0, LOGLEVEL_DEBUG3=1, LOGLEVEL_DEBUG2=2, LOGLEVEL_DEBUG1=3, LOGLEVEL_DEBUG=4, LOGLEVEL_INFO=5, LOGLEVEL_WARNING=6, LOGLEVEL_ERROR=7, LOGLEVEL_FATAL=8, LOGLEVEL_ALWAYS=9 }


decompiled_code:
void __fastcall log_setStdoutLevel(unsigned int a1)
{
if ( a1 > 8 )
_assert_fail("(level >= LOGLEVEL_NONE) && (level < LOGLEVEL_ALWAYS)", "src/logging.c", 0xA6u, "log_setStdoutLevel");
logLevelStdout = a1;
}

canonical_decompiled_code:
void __fastcall func3(unsigned int a1)
{
if ( a1 > 8 )
_assert_fail("(level >= LOGLEVEL_NONE) && (level < LOGLEVEL_ALWAYS)", "src/logging.c", 0xA6u, "log_setStdoutLevel");
logLevelStdout = a1;
}

original_code:
void log_setStdoutLevel(log_level_t level) {
    ((void) sizeof (((level >= LOGLEVEL_NONE) && (level < LOGLEVEL_ALWAYS)) ? 1 : 0), __extension__ ({ if ((level >= LOGLEVEL_NONE) && (level < LOGLEVEL_ALWAYS)) ; else __assert_fail ("(level >= LOGLEVEL_NONE) && (level < LOGLEVEL_ALWAYS)", "src/logging.c", 166, __extension__ __PRETTY_FUNCTION__); }));
    logLevelStdout = level;
}

canonical_original_code:
void log_setStdoutLevel(enum log_level_t level) {
    ((void) sizeof (((level >= LOGLEVEL_NONE) && (level < LOGLEVEL_ALWAYS)) ? 1 : 0), __extension__ ({ if ((level >= LOGLEVEL_NONE) && (level < LOGLEVEL_ALWAYS)) ; else __assert_fail ("(level >= LOGLEVEL_NONE) && (level < LOGLEVEL_ALWAYS)", "src/logging.c", 166, __extension__ __PRETTY_FUNCTION__); }));
    logLevelStdout = level;
}


decompiled_code:
void __fastcall log_setStdoutSupression(char a1)
{
logSuppressStdout = a1;
}

canonical_decompiled_code:
void __fastcall func4(char a1)
{
logSuppressStdout = a1;
}

original_code:
void log_setStdoutSupression(_Bool suppress) {
    logSuppressStdout = suppress;
}


decompiled_code:
int __fastcall log_logVMessageContinue(unsigned int a1, const char *a2, void *a3)
{
int result; // eax

result = a1 - 1;
if ( a1 - 1 > 8 )
_assert_fail(
"(level > LOGLEVEL_NONE) && (level <= LOGLEVEL_ALWAYS)",
"src/logging.c",
0xB4u,
"log_logVMessageContinue");
if ( !a2 )
_assert_fail("NULL != format", "src/logging.c", 0xB5u, "log_logVMessageContinue");
if ( logLevelStderr <= a1 )
result = vfprintf(stderr, a2, a3);
if ( logLevelStdout <= a1 && (!logSuppressStdout || logLevelStderr > a1) )
result = vprintf(a2, a3);
if ( logLevelFile <= a1 )
{
if ( logFileHandle )
{
vfprintf(logFileHandle, a2, a3);
result = fflush(logFileHandle);
}
}
return result;
}

canonical_decompiled_code:
int __fastcall func5(unsigned int a1, const char *a2, void *a3)
{
int result; // eax

result = a1 - 1;
if ( a1 - 1 > 8 )
_assert_fail(
"(level > LOGLEVEL_NONE) && (level <= LOGLEVEL_ALWAYS)",
"src/logging.c",
0xB4u,
"log_logVMessageContinue");
if ( !a2 )
_assert_fail("NULL != format", "src/logging.c", 0xB5u, "log_logVMessageContinue");
if ( logLevelStderr <= a1 )
result = vfprintf(stderr, a2, a3);
if ( logLevelStdout <= a1 && (!logSuppressStdout || logLevelStderr > a1) )
result = vprintf(a2, a3);
if ( logLevelFile <= a1 )
{
if ( logFileHandle )
{
vfprintf(logFileHandle, a2, a3);
result = fflush(logFileHandle);
}
}
return result;
}

original_code:
void log_logVMessageContinue(log_level_t level, char const *format, va_list arglist) {
    ((void) sizeof (((level > LOGLEVEL_NONE) && (level <= LOGLEVEL_ALWAYS)) ? 1 : 0), __extension__ ({ if ((level > LOGLEVEL_NONE) && (level <= LOGLEVEL_ALWAYS)) ; else __assert_fail ("(level > LOGLEVEL_NONE) && (level <= LOGLEVEL_ALWAYS)", "src/logging.c", 180, __extension__ __PRETTY_FUNCTION__); }));
    ((void) sizeof ((((void *)0) != format) ? 1 : 0), __extension__ ({ if (((void *)0) != format) ; else __assert_fail ("NULL != format", "src/logging.c", 181, __extension__ __PRETTY_FUNCTION__); }));
    if (logLevelStderr <= level) {
        (void) vfprintf(stderr, format, arglist);
    }
    if (logLevelStdout <= level) {
        if (!logSuppressStdout || (logLevelStderr > level)) {
            (void) vprintf(format, arglist);
        }
    }
    if ((logLevelFile <= level) && (((void *)0) != logFileHandle)) {
        (void) vfprintf(logFileHandle, format, arglist);
        (void) fflush(logFileHandle);
    }
}

canonical_original_code:
void log_logVMessageContinue(enum log_level_t level, char *format, __builtin_va_list arglist) {
    ((void) sizeof (((level > LOGLEVEL_NONE) && (level <= LOGLEVEL_ALWAYS)) ? 1 : 0), __extension__ ({ if ((level > LOGLEVEL_NONE) && (level <= LOGLEVEL_ALWAYS)) ; else __assert_fail ("(level > LOGLEVEL_NONE) && (level <= LOGLEVEL_ALWAYS)", "src/logging.c", 180, __extension__ __PRETTY_FUNCTION__); }));
    ((void) sizeof ((((void *)0) != format) ? 1 : 0), __extension__ ({ if (((void *)0) != format) ; else __assert_fail ("NULL != format", "src/logging.c", 181, __extension__ __PRETTY_FUNCTION__); }));
    if (logLevelStderr <= level) {
        (void) vfprintf(stderr, format, arglist);
    }
    if (logLevelStdout <= level) {
        if (!logSuppressStdout || (logLevelStderr > level)) {
            (void) vprintf(format, arglist);
        }
    }
    if ((logLevelFile <= level) && (((void *)0) != logFileHandle)) {
        (void) vfprintf(logFileHandle, format, arglist);
        (void) fflush(logFileHandle);
    }
}

variable_types:
format
char *


decompiled_code:
int log_logMessageContinue_impl(unsigned int a1, const char *a2, ...)
{
gcc_va_list va; // [rsp+8h] [rbp-D0h] BYREF

va_start(va, a2);
return log_logVMessageContinue(a1, a2, va);
}

canonical_decompiled_code:
int func6(unsigned int a1, const char *a2, ...)
{
gcc_va_list va; // [rsp+8h] [rbp-D0h] BYREF

va_start(va, a2);
return func5(a1, a2, va);
}

original_code:
void log_logMessageContinue_impl(log_level_t level, char const *format, ...) {
    va_list args;
    __builtin_va_start(args,format);
    log_logVMessageContinue(level, format, args);
    __builtin_va_end(args);
}

canonical_original_code:
void log_logMessageContinue_impl(enum log_level_t level, char *format, ...) {
    __builtin_va_list args;
    __builtin_va_start(args,format);
    log_logVMessageContinue(level, format, args);
    __builtin_va_end(args);
}


decompiled_code:
int __fastcall log_logLevelStart(unsigned int a1)
{
int result; // eax

if ( a1 - 1 > 8 )
_assert_fail("(level > LOGLEVEL_NONE) && (level <= LOGLEVEL_ALWAYS)", "src/logging.c", 0xD6u, "log_logLevelStart");
switch ( a1 )
{
case 2u:
result = log_logMessageContinue_impl(a1, "DEBUG2: ");
break;
case 3u:
result = log_logMessageContinue_impl(a1, "DEBUG1: ");
break;
case 4u:
result = log_logMessageContinue_impl(a1, "DEBUG: ");
break;
case 5u:
result = log_logMessageContinue_impl(a1, "INFO: ");
break;
case 6u:
result = log_logMessageContinue_impl(a1, "WARNING: ");
break;
case 7u:
result = log_logMessageContinue_impl(a1, "ERROR: ");
break;
case 8u:
result = log_logMessageContinue_impl(a1, "FATAL ERROR: ");
break;
case 9u:
result = log_logMessageContinue_impl(a1, "ALWAYS: ");
break;
default:
result = log_logMessageContinue_impl(a1, "DEBUG3: ");
break;
}
return result;
}

canonical_decompiled_code:
int __fastcall func7(unsigned int a1)
{
int result; // eax

if ( a1 - 1 > 8 )
_assert_fail("(level > LOGLEVEL_NONE) && (level <= LOGLEVEL_ALWAYS)", "src/logging.c", 0xD6u, "log_logLevelStart");
switch ( a1 )
{
case 2u:
result = func6(a1, "DEBUG2: ");
break;
case 3u:
result = func6(a1, "DEBUG1: ");
break;
case 4u:
result = func6(a1, "DEBUG: ");
break;
case 5u:
result = func6(a1, "INFO: ");
break;
case 6u:
result = func6(a1, "WARNING: ");
break;
case 7u:
result = func6(a1, "ERROR: ");
break;
case 8u:
result = func6(a1, "FATAL ERROR: ");
break;
case 9u:
result = func6(a1, "ALWAYS: ");
break;
default:
result = func6(a1, "DEBUG3: ");
break;
}
return result;
}

original_code:
void log_logLevelStart(log_level_t level) {
    char const *prepend_string;
    ((void) sizeof (((level > LOGLEVEL_NONE) && (level <= LOGLEVEL_ALWAYS)) ? 1 : 0), __extension__ ({ if ((level > LOGLEVEL_NONE) && (level <= LOGLEVEL_ALWAYS)) ; else __assert_fail ("(level > LOGLEVEL_NONE) && (level <= LOGLEVEL_ALWAYS)", "src/logging.c", 214, __extension__ __PRETTY_FUNCTION__); }));
    switch (level) {
        case LOGLEVEL_DEBUG3:
            prepend_string = "DEBUG3: ";
            break;
        case LOGLEVEL_DEBUG2:
            prepend_string = "DEBUG2: ";
            break;
        case LOGLEVEL_DEBUG1:
            prepend_string = "DEBUG1: ";
            break;
        case LOGLEVEL_DEBUG:
            prepend_string = "DEBUG: ";
            break;
        case LOGLEVEL_INFO:
            prepend_string = "INFO: ";
            break;
        case LOGLEVEL_WARNING:
            prepend_string = "WARNING: ";
            break;
        case LOGLEVEL_ERROR:
            prepend_string = "ERROR: ";
            break;
        case LOGLEVEL_FATAL:
            prepend_string = "FATAL ERROR: ";
            break;
        case LOGLEVEL_ALWAYS:
            prepend_string = "ALWAYS: ";
            break;
        case LOGLEVEL_NONE:
        default:
            ((void) sizeof ((0) ? 1 : 0), __extension__ ({ if (0) ; else __assert_fail ("false", "src/logging.c", 251, __extension__ __PRETTY_FUNCTION__); }));
            return;
    }
    log_logMessageContinue_impl(level, prepend_string);
}

canonical_original_code:
void log_logLevelStart(enum log_level_t level) {
    char *prepend_string;
    ((void) sizeof (((level > LOGLEVEL_NONE) && (level <= LOGLEVEL_ALWAYS)) ? 1 : 0), __extension__ ({ if ((level > LOGLEVEL_NONE) && (level <= LOGLEVEL_ALWAYS)) ; else __assert_fail ("(level > LOGLEVEL_NONE) && (level <= LOGLEVEL_ALWAYS)", "src/logging.c", 214, __extension__ __PRETTY_FUNCTION__); }));
    switch (level) {
        case LOGLEVEL_DEBUG3:
            prepend_string = "DEBUG3: ";
            break;
        case LOGLEVEL_DEBUG2:
            prepend_string = "DEBUG2: ";
            break;
        case LOGLEVEL_DEBUG1:
            prepend_string = "DEBUG1: ";
            break;
        case LOGLEVEL_DEBUG:
            prepend_string = "DEBUG: ";
            break;
        case LOGLEVEL_INFO:
            prepend_string = "INFO: ";
            break;
        case LOGLEVEL_WARNING:
            prepend_string = "WARNING: ";
            break;
        case LOGLEVEL_ERROR:
            prepend_string = "ERROR: ";
            break;
        case LOGLEVEL_FATAL:
            prepend_string = "FATAL ERROR: ";
            break;
        case LOGLEVEL_ALWAYS:
            prepend_string = "ALWAYS: ";
            break;
        case LOGLEVEL_NONE:
        default:
            ((void) sizeof ((0) ? 1 : 0), __extension__ ({ if (0) ; else __assert_fail ("false", "src/logging.c", 251, __extension__ __PRETTY_FUNCTION__); }));
            return;
    }
    log_logMessageContinue_impl(level, prepend_string);
}


decompiled_code:
int __fastcall log_logVMessageStart(unsigned int a1, const char *a2, void *a3)
{
if ( a1 - 1 > 8 )
_assert_fail(
"(level > LOGLEVEL_NONE) && (level <= LOGLEVEL_ALWAYS)",
"src/logging.c",
0x103u,
"log_logVMessageStart");
if ( !a2 )
_assert_fail("NULL != format", "src/logging.c", 0x104u, "log_logVMessageStart");
log_logLevelStart(a1);
return log_logVMessageContinue(a1, a2, a3);
}

canonical_decompiled_code:
int __fastcall func8(unsigned int a1, const char *a2, void *a3)
{
if ( a1 - 1 > 8 )
_assert_fail(
"(level > LOGLEVEL_NONE) && (level <= LOGLEVEL_ALWAYS)",
"src/logging.c",
0x103u,
"log_logVMessageStart");
if ( !a2 )
_assert_fail("NULL != format", "src/logging.c", 0x104u, "log_logVMessageStart");
func7(a1);
return func5(a1, a2, a3);
}

original_code:
void log_logVMessageStart(log_level_t level, char const *format, va_list arglist) {
    ((void) sizeof (((level > LOGLEVEL_NONE) && (level <= LOGLEVEL_ALWAYS)) ? 1 : 0), __extension__ ({ if ((level > LOGLEVEL_NONE) && (level <= LOGLEVEL_ALWAYS)) ; else __assert_fail ("(level > LOGLEVEL_NONE) && (level <= LOGLEVEL_ALWAYS)", "src/logging.c", 259, __extension__ __PRETTY_FUNCTION__); }));
    ((void) sizeof ((((void *)0) != format) ? 1 : 0), __extension__ ({ if (((void *)0) != format) ; else __assert_fail ("NULL != format", "src/logging.c", 260, __extension__ __PRETTY_FUNCTION__); }));
    log_logLevelStart(level);
    log_logVMessageContinue(level, format, arglist);
}

canonical_original_code:
void log_logVMessageStart(enum log_level_t level, char *format, __builtin_va_list arglist) {
    ((void) sizeof (((level > LOGLEVEL_NONE) && (level <= LOGLEVEL_ALWAYS)) ? 1 : 0), __extension__ ({ if ((level > LOGLEVEL_NONE) && (level <= LOGLEVEL_ALWAYS)) ; else __assert_fail ("(level > LOGLEVEL_NONE) && (level <= LOGLEVEL_ALWAYS)", "src/logging.c", 259, __extension__ __PRETTY_FUNCTION__); }));
    ((void) sizeof ((((void *)0) != format) ? 1 : 0), __extension__ ({ if (((void *)0) != format) ; else __assert_fail ("NULL != format", "src/logging.c", 260, __extension__ __PRETTY_FUNCTION__); }));
    log_logLevelStart(level);
    log_logVMessageContinue(level, format, arglist);
}


decompiled_code:
int log_logMessageStart_impl(unsigned int a1, const char *a2, ...)
{
gcc_va_list va; // [rsp+8h] [rbp-D0h] BYREF

va_start(va, a2);
return log_logVMessageStart(a1, a2, va);
}

canonical_decompiled_code:
int func9(unsigned int a1, const char *a2, ...)
{
gcc_va_list va; // [rsp+8h] [rbp-D0h] BYREF

va_start(va, a2);
return func8(a1, a2, va);
}

original_code:
void log_logMessageStart_impl(log_level_t level, char const *format, ...) {
    va_list args;
    __builtin_va_start(args,format);
    log_logVMessageStart(level, format, args);
    __builtin_va_end(args);
}

canonical_original_code:
void log_logMessageStart_impl(enum log_level_t level, char *format, ...) {
    __builtin_va_list args;
    __builtin_va_start(args,format);
    log_logVMessageStart(level, format, args);
    __builtin_va_end(args);
}


decompiled_code:
int log_logMessage_impl(unsigned int a1, const char *a2, ...)
{
gcc_va_list va; // [rsp+8h] [rbp-D0h] BYREF

va_start(va, a2);
log_logVMessageStart(a1, a2, va);
return log_logMessageContinue_impl(a1, "\n");
}

canonical_decompiled_code:
int func10(unsigned int a1, const char *a2, ...)
{
gcc_va_list va; // [rsp+8h] [rbp-D0h] BYREF

va_start(va, a2);
func8(a1, a2, va);
return func6(a1, "\n");
}

original_code:
void log_logMessage_impl(log_level_t level, char const *format, ...) {
    va_list args;
    __builtin_va_start(args,format);
    log_logVMessageStart(level, format, args);
    __builtin_va_end(args);
    log_logMessageContinue_impl(level, "\n");
}

canonical_original_code:
void log_logMessage_impl(enum log_level_t level, char *format, ...) {
    __builtin_va_list args;
    __builtin_va_start(args,format);
    log_logVMessageStart(level, format, args);
    __builtin_va_end(args);
    log_logMessageContinue_impl(level, "\n");
}


decompiled_code:
__int64 log_closeLogfile()
{
int v0; // eax
int *v2; // rax
char *v3; // rax

if ( !logFileHandle )
_assert_fail("NULL != logFileHandle", "src/logging.c", 0x78u, "log_closeLogfile");
v0 = fclose(logFileHandle);
logFileHandle = 0LL;
if ( !v0 )
return 0LL;
v2 = _errno_location();
v3 = strerror(*v2);
log_logMessage_impl(7u, "Unable to close logfile: %s", v3);
return 1LL;
}

canonical_decompiled_code:
__int64 func11()
{
int v0; // eax
int *v2; // rax
char *v3; // rax

if ( !logFileHandle )
_assert_fail("NULL != logFileHandle", "src/logging.c", 0x78u, "log_closeLogfile");
v0 = fclose(logFileHandle);
logFileHandle = 0LL;
if ( !v0 )
return 0LL;
v2 = _errno_location();
v3 = strerror(*v2);
func10(7u, "Unable to close logfile: %s", v3);
return 1LL;
}

original_code:
_Bool log_closeLogfile(void) {
    ((void) sizeof ((((void *)0) != logFileHandle) ? 1 : 0), __extension__ ({ if (((void *)0) != logFileHandle) ; else __assert_fail ("NULL != logFileHandle", "src/logging.c", 120, __extension__ __PRETTY_FUNCTION__); }));
    if (fclose(logFileHandle) != 0) {
        logFileHandle = ((void *)0);
        log_logMessage_impl(LOGLEVEL_ERROR,
                       "Unable to close logfile: %s",
                       strerror((*__errno_location ())));
        return 1;
    }
    logFileHandle = ((void *)0);
    return 0;
}

canonical_original_code:
_Bool log_closeLogfile() {
    ((void) sizeof ((((void *)0) != logFileHandle) ? 1 : 0), __extension__ ({ if (((void *)0) != logFileHandle) ; else __assert_fail ("NULL != logFileHandle", "src/logging.c", 120, __extension__ __PRETTY_FUNCTION__); }));
    if (fclose(logFileHandle) != 0) {
        logFileHandle = ((void *)0);
        log_logMessage_impl(LOGLEVEL_ERROR,
                       "Unable to close logfile: %s",
                       strerror((*__errno_location ())));
        return 1;
    }
    logFileHandle = ((void *)0);
    return 0;
}


decompiled_code:
__int64 __fastcall log_openLogfile(char *filename, char a2)
{
unsigned int v2; // er8
FILE *v3; // rax
int *v5; // rax
char *v6; // rax

if ( !logFileHandle || (v2 = log_closeLogfile(), !(_BYTE)v2) )
{
if ( a2 )
v3 = fopen(filename, "wa");
else
v3 = fopen(filename, "w");
logFileHandle = v3;
v2 = 0;
if ( !v3 )
{
v5 = _errno_location();
v6 = strerror(*v5);
fprintf(stderr, "ERROR: Unable to open logfile '%s' for write: %s\n", filename, v6);
v2 = 1;
}
}
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func12(char *filename, char a2)
{
unsigned int v2; // er8
FILE *v3; // rax
int *v5; // rax
char *v6; // rax

if ( !logFileHandle || (v2 = func11(), !(_BYTE)v2) )
{
if ( a2 )
v3 = fopen(filename, "wa");
else
v3 = fopen(filename, "w");
logFileHandle = v3;
v2 = 0;
if ( !v3 )
{
v5 = _errno_location();
v6 = strerror(*v5);
fprintf(stderr, "ERROR: Unable to open logfile '%s' for write: %s\n", filename, v6);
v2 = 1;
}
}
return v2;
}

original_code:
_Bool log_openLogfile(char const *filename, _Bool append) {
    if (((void *)0) != logFileHandle) {
        if (log_closeLogfile()) {
            return 1;
        }
    }
    if (append) {
        logFileHandle = fopen(filename, "wa");
    } else {
        logFileHandle = fopen(filename, "w");
    }
    if (((void *)0) == logFileHandle) {
        fprintf(stderr, "ERROR: Unable to open logfile '%s' for write: %s\n", filename, strerror((*__errno_location ())));
        return 1;
    }
    return 0;
}

canonical_original_code:
_Bool log_openLogfile(char *filename, _Bool append) {
    if (((void *)0) != logFileHandle) {
        if (log_closeLogfile()) {
            return 1;
        }
    }
    if (append) {
        logFileHandle = fopen(filename, "wa");
    } else {
        logFileHandle = fopen(filename, "w");
    }
    if (((void *)0) == logFileHandle) {
        fprintf(stderr, "ERROR: Unable to open logfile '%s' for write: %s\n", filename, strerror((*__errno_location ())));
        return 1;
    }
    return 0;
}

variable_types:
filename
char *


decompiled_code:
int __fastcall log_logData(unsigned int a1, __int64 a2, unsigned __int64 a3, const char *a4, unsigned __int64 a5)
{
__int64 v5; // r14
unsigned __int64 v6; // rbp
char v7; // bl
int result; // eax
unsigned __int64 v9; // r12
int v10; // ebx
int v13; // [rsp+1Ch] [rbp-3Ch]

if ( a1 - 1 > 8 )
_assert_fail("(level > LOGLEVEL_NONE) && (level <= LOGLEVEL_ALWAYS)", "src/logging.c", 0x130u, "log_logData");
v5 = a2;
if ( !a2 )
_assert_fail("NULL != pData", "src/logging.c", 0x131u, "log_logData");
if ( !a4 )
_assert_fail("NULL != prefixStr", "src/logging.c", 0x132u, "log_logData");
if ( 3 * a5 + 3 > 0xFFF )
_assert_fail("hexWidth*3 + 3 < sizeof(debugBuffer)", "src/logging.c", 0x133u, "log_logData");
v6 = a3;
if ( !a3 )
return log_logMessage_impl(a1, "%s (None)", a4);
v7 = 1;
v13 = strlen(a4);
while ( 1 )
{
v9 = a5;
if ( a5 > v6 )
v9 = v6;
if ( !hexbuf2String(v5, v9, debugBuffer, 4096LL, 0LL, 0LL, (unsigned int)a5, 0LL, 0LL) )
break;
debugBuffer[strlen(debugBuffer) - 2] = 0;
if ( v7 )
{
v7 = 0;
v5 += v9;
result = log_logMessage_impl(a1, "%s %s", a4, debugBuffer);
v6 -= v9;
if ( !v6 )
return result;
}
else
{
log_logLevelStart(a1);
v10 = v13 + 1;
if ( v13 != -1 )
{
do
{
log_logMessageContinue_impl(a1, " ");
--v10;
}
while ( v10 );
}
v5 += v9;
log_logMessageContinue_impl(a1, debugBuffer);
v7 = 0;
result = log_logMessageContinue_impl(a1, "\n");
v6 -= v9;
if ( !v6 )
return result;
}
}
return log_logMessage_impl(7u, "tcp_log_data(): unable to hexify buffer");
}

canonical_decompiled_code:
int __fastcall func13(unsigned int a1, __int64 a2, unsigned __int64 a3, const char *a4, unsigned __int64 a5)
{
__int64 v5; // r14
unsigned __int64 v6; // rbp
char v7; // bl
int result; // eax
unsigned __int64 v9; // r12
int v10; // ebx
int v13; // [rsp+1Ch] [rbp-3Ch]

if ( a1 - 1 > 8 )
_assert_fail("(level > LOGLEVEL_NONE) && (level <= LOGLEVEL_ALWAYS)", "src/logging.c", 0x130u, "log_logData");
v5 = a2;
if ( !a2 )
_assert_fail("NULL != pData", "src/logging.c", 0x131u, "log_logData");
if ( !a4 )
_assert_fail("NULL != prefixStr", "src/logging.c", 0x132u, "log_logData");
if ( 3 * a5 + 3 > 0xFFF )
_assert_fail("hexWidth*3 + 3 < sizeof(debugBuffer)", "src/logging.c", 0x133u, "log_logData");
v6 = a3;
if ( !a3 )
return func10(a1, "%s (None)", a4);
v7 = 1;
v13 = strlen(a4);
while ( 1 )
{
v9 = a5;
if ( a5 > v6 )
v9 = v6;
if ( !hexbuf2String(v5, v9, debugBuffer, 4096LL, 0LL, 0LL, (unsigned int)a5, 0LL, 0LL) )
break;
debugBuffer[strlen(debugBuffer) - 2] = 0;
if ( v7 )
{
v7 = 0;
v5 += v9;
result = func10(a1, "%s %s", a4, debugBuffer);
v6 -= v9;
if ( !v6 )
return result;
}
else
{
func7(a1);
v10 = v13 + 1;
if ( v13 != -1 )
{
do
{
func6(a1, " ");
--v10;
}
while ( v10 );
}
v5 += v9;
func6(a1, debugBuffer);
v7 = 0;
result = func6(a1, "\n");
v6 -= v9;
if ( !v6 )
return result;
}
}
return func10(7u, "tcp_log_data(): unable to hexify buffer");
}

original_code:
void log_logData(log_level_t level,
                        char const *pData,
                        size_t nrOfBytes,
                        char const *prefixStr,
                        size_t hexWidth) {
    _Bool firstLine = 1;
    unsigned prefixLen, i;
    ((void) sizeof (((level > LOGLEVEL_NONE) && (level <= LOGLEVEL_ALWAYS)) ? 1 : 0), __extension__ ({ if ((level > LOGLEVEL_NONE) && (level <= LOGLEVEL_ALWAYS)) ; else __assert_fail ("(level > LOGLEVEL_NONE) && (level <= LOGLEVEL_ALWAYS)", "src/logging.c", 304, __extension__ __PRETTY_FUNCTION__); }));
    ((void) sizeof ((((void *)0) != pData) ? 1 : 0), __extension__ ({ if (((void *)0) != pData) ; else __assert_fail ("NULL != pData", "src/logging.c", 305, __extension__ __PRETTY_FUNCTION__); }));
    ((void) sizeof ((((void *)0) != prefixStr) ? 1 : 0), __extension__ ({ if (((void *)0) != prefixStr) ; else __assert_fail ("NULL != prefixStr", "src/logging.c", 306, __extension__ __PRETTY_FUNCTION__); }));
    ((void) sizeof ((hexWidth*3 + 3 < sizeof(debugBuffer)) ? 1 : 0), __extension__ ({ if (hexWidth*3 + 3 < sizeof(debugBuffer)) ; else __assert_fail ("hexWidth*3 + 3 < sizeof(debugBuffer)", "src/logging.c", 307, __extension__ __PRETTY_FUNCTION__); }));
    if (0 == nrOfBytes) {
        log_logMessage_impl(level, "%s (None)", prefixStr);
        return;
    }
    prefixLen = (unsigned) strlen(prefixStr);
    while (nrOfBytes > 0) {
        size_t chunkSize = hexWidth;
        if (nrOfBytes < chunkSize) {
            chunkSize = nrOfBytes;
        }
        if (hexbuf2String(pData, chunkSize,
                          debugBuffer, sizeof(debugBuffer),
                          0, 0,
                          (unsigned) hexWidth,
                          0, 0)
             == ((void *)0)) {
                log_logMessage_impl(LOGLEVEL_ERROR,
                       "tcp_log_data(): unable to hexify buffer");
                return;
        }
        debugBuffer[strlen(debugBuffer) - 2] = '\0';
        if (firstLine) {
            log_logMessage_impl(level, "%s %s", prefixStr, debugBuffer);
            firstLine = 0;
        } else {
            log_logLevelStart(level);
            for (i = prefixLen + 1;i > 0;i --) {
                log_logMessageContinue_impl(level, " ");
            }
            log_logMessageContinue_impl(level, debugBuffer);
            log_logMessageContinue_impl(level, "\n");
        }
        nrOfBytes = nrOfBytes - chunkSize;
        pData = pData + chunkSize;
    }
}

canonical_original_code:
void log_logData(enum log_level_t level, char *pData, unsigned long nrOfBytes, char *prefixStr, unsigned long hexWidth) {
    _Bool firstLine = 1;
    unsigned int prefixLen; unsigned int i;
    ((void) sizeof (((level > LOGLEVEL_NONE) && (level <= LOGLEVEL_ALWAYS)) ? 1 : 0), __extension__ ({ if ((level > LOGLEVEL_NONE) && (level <= LOGLEVEL_ALWAYS)) ; else __assert_fail ("(level > LOGLEVEL_NONE) && (level <= LOGLEVEL_ALWAYS)", "src/logging.c", 304, __extension__ __PRETTY_FUNCTION__); }));
    ((void) sizeof ((((void *)0) != pData) ? 1 : 0), __extension__ ({ if (((void *)0) != pData) ; else __assert_fail ("NULL != pData", "src/logging.c", 305, __extension__ __PRETTY_FUNCTION__); }));
    ((void) sizeof ((((void *)0) != prefixStr) ? 1 : 0), __extension__ ({ if (((void *)0) != prefixStr) ; else __assert_fail ("NULL != prefixStr", "src/logging.c", 306, __extension__ __PRETTY_FUNCTION__); }));
    ((void) sizeof ((hexWidth*3 + 3 < sizeof(debugBuffer)) ? 1 : 0), __extension__ ({ if (hexWidth*3 + 3 < sizeof(debugBuffer)) ; else __assert_fail ("hexWidth*3 + 3 < sizeof(debugBuffer)", "src/logging.c", 307, __extension__ __PRETTY_FUNCTION__); }));
    if (0 == nrOfBytes) {
        log_logMessage_impl(level, "%s (None)", prefixStr);
        return;
    }
    prefixLen = (unsigned int) strlen(prefixStr);
    while (nrOfBytes > 0) {
        unsigned long chunkSize = hexWidth;
        if (nrOfBytes < chunkSize) {
            chunkSize = nrOfBytes;
        }
        if (hexbuf2String(pData, chunkSize,
                          debugBuffer, sizeof(debugBuffer),
                          0, 0,
                          (unsigned int) hexWidth,
                          0, 0)
             == ((void *)0)) {
                log_logMessage_impl(LOGLEVEL_ERROR,
                       "tcp_log_data(): unable to hexify buffer");
                return;
        }
        debugBuffer[strlen(debugBuffer) - 2] = '\0';
        if (firstLine) {
            log_logMessage_impl(level, "%s %s", prefixStr, debugBuffer);
            firstLine = 0;
        } else {
            log_logLevelStart(level);
            for (i = prefixLen + 1;i > 0;i --) {
                log_logMessageContinue_impl(level, " ");
            }
            log_logMessageContinue_impl(level, debugBuffer);
            log_logMessageContinue_impl(level, "\n");
        }
        nrOfBytes = nrOfBytes - chunkSize;
        pData = pData + chunkSize;
    }
}

variable_types:
pData
char *

variable_types:
nrOfBytes
unsigned long

variable_types:
prefixStr
char *

variable_types:
hexWidth
unsigned long

variable_types:
prefixLen
unsigned int

variable_types:
i
unsigned int

variable_types:
chunkSize
unsigned long


decompiled_code:
__int64 prng_xorshift64star_next()
{
state ^= ((state ^ ((unsigned __int64)state >> 12)) << 25) ^ ((unsigned __int64)state >> 12) ^ ((((state ^ ((unsigned __int64)state >> 12)) << 25) ^ state ^ ((unsigned __int64)state >> 12)) >> 27);
return 0x2545F4914F6CDD1DLL * state;
}

canonical_decompiled_code:
__int64 func0()
{
state ^= ((state ^ ((unsigned __int64)state >> 12)) << 25) ^ ((unsigned __int64)state >> 12) ^ ((((state ^ ((unsigned __int64)state >> 12)) << 25) ^ state ^ ((unsigned __int64)state >> 12)) >> 27);
return 0x2545F4914F6CDD1DLL * state;
}

original_code:
uint64_t prng_xorshift64star_next(void) {
    state ^= state >> 12;
    state ^= state << 25;
    state ^= state >> 27;
    return state * 2685821657736338717UL;
}

canonical_original_code:
unsigned long prng_xorshift64star_next() {
    state ^= state >> 12;
    state ^= state << 25;
    state ^= state >> 27;
    return state * 2685821657736338717UL;
}

return_type: unsigned long


decompiled_code:
void prng_xorshift64star_jump()
{
;
}

canonical_decompiled_code:
void func1()
{
;
}

original_code:
void prng_xorshift64star_jump(void) {
}

canonical_original_code:
void prng_xorshift64star_jump() {
}


decompiled_code:
__int64 __fastcall hexToInt8(unsigned __int8 *a1)
{
int v1; // eax
int v2; // eax
int v3; // edx
int v4; // esi

if ( !a1 )
_assert_fail("NULL != pSrc", "src/hex.c", 0x6Bu, "hexToInt8");
v1 = *a1;
if ( (char)v1 <= 57 )
goto LABEL_3;
if ( (char)v1 > 70 )
{
v1 -= 87;
LABEL_3:
v2 = 16 * v1;
goto LABEL_4;
}
v2 = 16 * (v1 - 55);
LABEL_4:
v3 = a1[1];
if ( (char)v3 <= 57 )
return (unsigned int)(v3 - 48 + v2);
v4 = v3 - 55;
if ( (char)v3 > 70 )
v4 = v3 - 87;
return (unsigned int)(v4 + v2);
}

canonical_decompiled_code:
__int64 __fastcall func2(unsigned __int8 *a1)
{
int v1; // eax
int v2; // eax
int v3; // edx
int v4; // esi

if ( !a1 )
_assert_fail("NULL != pSrc", "src/hex.c", 0x6Bu, "hexToInt8");
v1 = *a1;
if ( (char)v1 <= 57 )
goto LABEL_3;
if ( (char)v1 > 70 )
{
v1 -= 87;
LABEL_3:
v2 = 16 * v1;
goto LABEL_4;
}
v2 = 16 * (v1 - 55);
LABEL_4:
v3 = a1[1];
if ( (char)v3 <= 57 )
return (unsigned int)(v3 - 48 + v2);
v4 = v3 - 55;
if ( (char)v3 > 70 )
v4 = v3 - 87;
return (unsigned int)(v4 + v2);
}

variable_types:
pSrc
char *

variable_types:
n
unsigned char

return_type: unsigned char


decompiled_code:
__int64 __fastcall hexToInt16(char *a1)
{
char *v1; // rbx
const unsigned __int16 **v2; // rax
__int64 v3; // r8
const unsigned __int16 *v4; // rcx
__int64 v5; // rdx
__int64 v6; // r8
__int64 v7; // rax

if ( !a1 )
_assert_fail("NULL != pSrc", "src/hex.c", 0x79u, "hexToInt16");
v1 = a1;
v2 = _ctype_b_loc();
v3 = 0LL;
v4 = *v2;
do
{
v5 = *v1;
if ( (v4[v5] & 0x1000) == 0 )
_assert_fail("isxdigit((int) *pSrc)", "src/hex.c", 0x7Cu, "hexToInt16");
v6 = 16 * v3;
if ( (char)v5 > 57 )
{
if ( (char)v5 > 70 )
v7 = (unsigned __int8)(v5 - 87);
else
v7 = (unsigned __int8)(v5 - 55);
}
else
{
v7 = (unsigned __int8)(v5 - 48);
}
++v1;
v3 = v7 + v6;
}
while ( v1 != a1 + 4 );
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func3(char *a1)
{
char *v1; // rbx
const unsigned __int16 **v2; // rax
__int64 v3; // r8
const unsigned __int16 *v4; // rcx
__int64 v5; // rdx
__int64 v6; // r8
__int64 v7; // rax

if ( !a1 )
_assert_fail("NULL != pSrc", "src/hex.c", 0x79u, "hexToInt16");
v1 = a1;
v2 = _ctype_b_loc();
v3 = 0LL;
v4 = *v2;
do
{
v5 = *v1;
if ( (v4[v5] & 0x1000) == 0 )
_assert_fail("isxdigit((int) *pSrc)", "src/hex.c", 0x7Cu, "hexToInt16");
v6 = 16 * v3;
if ( (char)v5 > 57 )
{
if ( (char)v5 > 70 )
v7 = (unsigned __int8)(v5 - 87);
else
v7 = (unsigned __int8)(v5 - 55);
}
else
{
v7 = (unsigned __int8)(v5 - 48);
}
++v1;
v3 = v7 + v6;
}
while ( v1 != a1 + 4 );
return v3;
}

original_code:
uint_fast16_t hexToInt16(char const *pSrc) {
    uint_fast16_t n = 0;
    int i;
    ((void) sizeof ((((void *)0) != pSrc) ? 1 : 0), __extension__ ({ if (((void *)0) != pSrc) ; else __assert_fail ("NULL != pSrc", "src/hex.c", 121, __extension__ __PRETTY_FUNCTION__); }));
    for (i = 0;i < 4;i ++, pSrc++) {
        ((void) sizeof ((((*__ctype_b_loc ())[(int) (((int) *pSrc))] & (unsigned short int) _ISxdigit)) ? 1 : 0), __extension__ ({ if (((*__ctype_b_loc ())[(int) (((int) *pSrc))] & (unsigned short int) _ISxdigit)) ; else __assert_fail ("isxdigit((int) *pSrc)", "src/hex.c", 124, __extension__ __PRETTY_FUNCTION__); }));
        n <<= 4;
        n += (uint_fast16_t) ((unsigned char) ((*pSrc) - '0' < 10 ? (*pSrc) - '0' : (*pSrc) - 'A' < 6 ? (((*pSrc) - 'A') + 10) : (((*pSrc) - 'a') + 10)));
    }
    return n;
}

canonical_original_code:
unsigned long hexToInt16(char *pSrc) {
    unsigned long n = 0;
    int i;
    ((void) sizeof ((((void *)0) != pSrc) ? 1 : 0), __extension__ ({ if (((void *)0) != pSrc) ; else __assert_fail ("NULL != pSrc", "src/hex.c", 121, __extension__ __PRETTY_FUNCTION__); }));
    for (i = 0;i < 4;i ++, pSrc++) {
        ((void) sizeof ((((*__ctype_b_loc ())[(int) (((int) *pSrc))] & (unsigned short) _ISxdigit)) ? 1 : 0), __extension__ ({ if (((*__ctype_b_loc ())[(int) (((int) *pSrc))] & (unsigned short) _ISxdigit)) ; else __assert_fail ("isxdigit((int) *pSrc)", "src/hex.c", 124, __extension__ __PRETTY_FUNCTION__); }));
        n <<= 4;
        n += (uint_fast16_t) ((unsigned char) ((*pSrc) - '0' < 10 ? (*pSrc) - '0' : (*pSrc) - 'A' < 6 ? (((*pSrc) - 'A') + 10) : (((*pSrc) - 'a') + 10)));
    }
    return n;
}

variable_types:
n
unsigned long

variable_types: i int


decompiled_code:
__int64 __fastcall hexToInt32(char *a1)
{
char *v1; // rbx
const unsigned __int16 **v2; // rax
char *v3; // rcx
__int64 v4; // r8
const unsigned __int16 *v5; // rsi
__int64 v6; // rax
__int64 v7; // rdx
__int64 v8; // r8

if ( !a1 )
_assert_fail("NULL != pSrc", "src/hex.c", 0x8Au, "hexToInt32");
v1 = a1;
v2 = _ctype_b_loc();
v3 = a1 + 8;
v4 = 0LL;
v5 = *v2;
do
{
while ( 1 )
{
v7 = *v1;
if ( (v5[v7] & 0x1000) == 0 )
_assert_fail("isxdigit((int) *pSrc)", "src/hex.c", 0x8Du, "hexToInt32");
v8 = 16 * v4;
if ( (char)v7 > 57 )
break;
v6 = (unsigned __int8)(v7 - 48);
LABEL_4:
++v1;
v4 = v6 + v8;
if ( v1 == v3 )
return v4;
}
if ( (char)v7 > 70 )
{
v6 = (unsigned __int8)(v7 - 87);
goto LABEL_4;
}
++v1;
v4 = (unsigned __int8)(v7 - 55) + v8;
}
while ( v1 != v3 );
return v4;
}

canonical_decompiled_code:
__int64 __fastcall func4(char *a1)
{
char *v1; // rbx
const unsigned __int16 **v2; // rax
char *v3; // rcx
__int64 v4; // r8
const unsigned __int16 *v5; // rsi
__int64 v6; // rax
__int64 v7; // rdx
__int64 v8; // r8

if ( !a1 )
_assert_fail("NULL != pSrc", "src/hex.c", 0x8Au, "hexToInt32");
v1 = a1;
v2 = _ctype_b_loc();
v3 = a1 + 8;
v4 = 0LL;
v5 = *v2;
do
{
while ( 1 )
{
v7 = *v1;
if ( (v5[v7] & 0x1000) == 0 )
_assert_fail("isxdigit((int) *pSrc)", "src/hex.c", 0x8Du, "hexToInt32");
v8 = 16 * v4;
if ( (char)v7 > 57 )
break;
v6 = (unsigned __int8)(v7 - 48);
LABEL_4:
++v1;
v4 = v6 + v8;
if ( v1 == v3 )
return v4;
}
if ( (char)v7 > 70 )
{
v6 = (unsigned __int8)(v7 - 87);
goto LABEL_4;
}
++v1;
v4 = (unsigned __int8)(v7 - 55) + v8;
}
while ( v1 != v3 );
return v4;
}

original_code:
uint_fast32_t hexToInt32(char const *pSrc) {
    uint_fast32_t n = 0;
    int i;
    ((void) sizeof ((((void *)0) != pSrc) ? 1 : 0), __extension__ ({ if (((void *)0) != pSrc) ; else __assert_fail ("NULL != pSrc", "src/hex.c", 138, __extension__ __PRETTY_FUNCTION__); }));
    for (i = 0;i < 8;i ++, pSrc++) {
        ((void) sizeof ((((*__ctype_b_loc ())[(int) (((int) *pSrc))] & (unsigned short int) _ISxdigit)) ? 1 : 0), __extension__ ({ if (((*__ctype_b_loc ())[(int) (((int) *pSrc))] & (unsigned short int) _ISxdigit)) ; else __assert_fail ("isxdigit((int) *pSrc)", "src/hex.c", 141, __extension__ __PRETTY_FUNCTION__); }));
        n <<= 4;
        n += (uint_fast16_t) ((unsigned char) ((*pSrc) - '0' < 10 ? (*pSrc) - '0' : (*pSrc) - 'A' < 6 ? (((*pSrc) - 'A') + 10) : (((*pSrc) - 'a') + 10)));
    }
    return n;
}

canonical_original_code:
unsigned long hexToInt32(char *pSrc) {
    unsigned long n = 0;
    int i;
    ((void) sizeof ((((void *)0) != pSrc) ? 1 : 0), __extension__ ({ if (((void *)0) != pSrc) ; else __assert_fail ("NULL != pSrc", "src/hex.c", 138, __extension__ __PRETTY_FUNCTION__); }));
    for (i = 0;i < 8;i ++, pSrc++) {
        ((void) sizeof ((((*__ctype_b_loc ())[(int) (((int) *pSrc))] & (unsigned short) _ISxdigit)) ? 1 : 0), __extension__ ({ if (((*__ctype_b_loc ())[(int) (((int) *pSrc))] & (unsigned short) _ISxdigit)) ; else __assert_fail ("isxdigit((int) *pSrc)", "src/hex.c", 141, __extension__ __PRETTY_FUNCTION__); }));
        n <<= 4;
        n += (uint_fast16_t) ((unsigned char) ((*pSrc) - '0' < 10 ? (*pSrc) - '0' : (*pSrc) - 'A' < 6 ? (((*pSrc) - 'A') + 10) : (((*pSrc) - 'a') + 10)));
    }
    return n;
}


decompiled_code:
__int64 __fastcall hexbuf2StringLength(__int64 a1, char a2, char a3, unsigned int a4, char a5)
{
__int64 result; // rax
unsigned __int64 v7; // rax
__int64 v8; // rdx
__int64 v9; // rcx

if ( !a4 )
_assert_fail("lineWidth > 0", "src/hex.c", 0x9Cu, "hexbuf2StringLength");
result = 0LL;
if ( a1 )
{
v7 = ((unsigned __int64)a4 + a1 - 1) / a4;
v8 = 3LL * a4 + 8LL * (a5 != 0);
v9 = a4 + v8 + 1;
if ( a3 )
v8 = v9;
result = v7 * (v8 - ((a2 == 0) - 2LL)) + 1;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1, char a2, char a3, unsigned int a4, char a5)
{
__int64 result; // rax
unsigned __int64 v7; // rax
__int64 v8; // rdx
__int64 v9; // rcx

if ( !a4 )
_assert_fail("lineWidth > 0", "src/hex.c", 0x9Cu, "hexbuf2StringLength");
result = 0LL;
if ( a1 )
{
v7 = ((unsigned __int64)a4 + a1 - 1) / a4;
v8 = 3LL * a4 + 8LL * (a5 != 0);
v9 = a4 + v8 + 1;
if ( a3 )
v8 = v9;
result = v7 * (v8 - ((a2 == 0) - 2LL)) + 1;
}
return result;
}

original_code:
size_t hexbuf2StringLength(size_t nrBytes,
                           _Bool useCRLF, _Bool showASCII, unsigned lineWidth,
                           _Bool showOffset) {
    size_t nrOfLines, bytesPerLine, totalBytes;
    ((void) sizeof ((lineWidth > 0) ? 1 : 0), __extension__ ({ if (lineWidth > 0) ; else __assert_fail ("lineWidth > 0", "src/hex.c", 156, __extension__ __PRETTY_FUNCTION__); }));
    if (0 == nrBytes) {
        return 0;
    }
    nrOfLines = (nrBytes + lineWidth - 1) / lineWidth;
    bytesPerLine = (showOffset ? 8 : 0) + 3 * (size_t) lineWidth
        + (showASCII ? (size_t) lineWidth + 1 : 0)
        + (useCRLF ? 2 : 1);
    totalBytes = bytesPerLine * nrOfLines + 1;
    return totalBytes;
}

canonical_original_code:
unsigned long hexbuf2StringLength(unsigned long nrBytes, _Bool useCRLF, _Bool showASCII, unsigned int lineWidth, _Bool showOffset) {
    unsigned long nrOfLines; unsigned long bytesPerLine; unsigned long totalBytes;
    ((void) sizeof ((lineWidth > 0) ? 1 : 0), __extension__ ({ if (lineWidth > 0) ; else __assert_fail ("lineWidth > 0", "src/hex.c", 156, __extension__ __PRETTY_FUNCTION__); }));
    if (0 == nrBytes) {
        return 0;
    }
    nrOfLines = (nrBytes + lineWidth - 1) / lineWidth;
    bytesPerLine = (showOffset ? 8 : 0) + 3 * (unsigned long) lineWidth
        + (showASCII ? (unsigned long) lineWidth + 1 : 0)
        + (useCRLF ? 2 : 1);
    totalBytes = bytesPerLine * nrOfLines + 1;
    return totalBytes;
}

variable_types:
nrBytes
unsigned long

variable_types:
lineWidth
unsigned int

variable_types:
nrOfLines
unsigned long

variable_types:
bytesPerLine
unsigned long

variable_types:
totalBytes
unsigned long


decompiled_code:
__int64 prng_xorshift1024star_next()
{
unsigned __int64 v0; // rdi
unsigned __int64 v1; // rcx
unsigned __int64 v2; // rax

v0 = state[state_word_index];
state_word_index = ((_BYTE)state_word_index + 1) & 0xF;
v1 = state[state_word_index] ^ (state[state_word_index] << 31);
v2 = (v1 >> 11) ^ v1 ^ v0 ^ (v0 >> 30);
state[state_word_index] = v2;
return 0x106689D45497FDB5LL * v2;
}

canonical_decompiled_code:
__int64 func0()
{
unsigned __int64 v0; // rdi
unsigned __int64 v1; // rcx
unsigned __int64 v2; // rax

v0 = state[state_word_index];
state_word_index = ((_BYTE)state_word_index + 1) & 0xF;
v1 = state[state_word_index] ^ (state[state_word_index] << 31);
v2 = (v1 >> 11) ^ v1 ^ v0 ^ (v0 >> 30);
state[state_word_index] = v2;
return 0x106689D45497FDB5LL * v2;
}

original_code:
uint64_t prng_xorshift1024star_next(void) {
 const uint64_t s0 = state[state_word_index];
 uint64_t s1;
 state_word_index = (state_word_index + 1) & (16 - 1);
 s1 = state[state_word_index];
 s1 ^= s1 << 31;
 state[state_word_index] = s1 ^ s0 ^ (s1 >> 11) ^ (s0 >> 30);
 return state[state_word_index] * 1181783497276652981UL;
}

canonical_original_code:
unsigned long prng_xorshift1024star_next() {
 unsigned long s0 = state[state_word_index];
 unsigned long s1;
 state_word_index = (state_word_index + 1) & (16 - 1);
 s1 = state[state_word_index];
 s1 ^= s1 << 31;
 state[state_word_index] = s1 ^ s0 ^ (s1 >> 11) ^ (s0 >> 30);
 return state[state_word_index] * 1181783497276652981UL;
}


decompiled_code:
__int64 __fastcall prng_xorshift1024star_jump(__int64 a1, char *a2)
{
unsigned __int64 v2; // rbp
__int64 v3; // rbx
char *v4; // r12
unsigned __int64 v5; // r13
__int64 v6; // rdx
char *j; // rax
char v8; // cl
__int64 result; // rax
char v10; // dl
unsigned __int64 *i; // [rsp+8h] [rbp-C0h]
__int64 v12[16]; // [rsp+10h] [rbp-B8h] BYREF
char v13[56]; // [rsp+90h] [rbp-38h] BYREF

v2 = 0x84242F96ECA9C41DLL;
v3 = 0LL;
v4 = (char *)v12;
memset(v12, 0, sizeof(v12));
for ( i = (unsigned __int64 *)&unk_1E8; ; ++i )
{
v5 = 0LL;
do
{
while ( !_bittest64((const __int64 *)&v2, v5) )
{
((void (*)(void))prng_xorshift1024star_next)();
v5 = (unsigned int)(v5 + 1);
if ( (_DWORD)v5 == 64 )
goto LABEL_9;
}
LODWORD(v6) = state_word_index;
for ( j = (char *)v12; ; v3 = *(_QWORD *)j )
{
v8 = v6;
j += 8;
v6 = (unsigned int)(v6 + 1);
*((_QWORD *)j - 1) = state[v8 & 0xF] ^ v3;
if ( j == v13 )
break;
}
v5 = (unsigned int)(v5 + 1);
v3 = v12[0];
prng_xorshift1024star_next(v13, a2, v6);
}
while ( (_DWORD)v5 != 64 );
LABEL_9:
a2 = (char *)&unk_25F + 1;
if ( i == (unsigned __int64 *)((char *)&unk_25F + 1) )
break;
v2 = *i;
}
LODWORD(result) = state_word_index;
while ( 1 )
{
v10 = result;
v4 += 8;
result = (unsigned int)(result + 1);
state[v10 & 0xF] = v3;
if ( v13 == v4 )
break;
v3 = *(_QWORD *)v4;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, char *a2)
{
unsigned __int64 v2; // rbp
__int64 v3; // rbx
char *v4; // r12
unsigned __int64 v5; // r13
__int64 v6; // rdx
char *j; // rax
char v8; // cl
__int64 result; // rax
char v10; // dl
unsigned __int64 *i; // [rsp+8h] [rbp-C0h]
__int64 v12[16]; // [rsp+10h] [rbp-B8h] BYREF
char v13[56]; // [rsp+90h] [rbp-38h] BYREF

v2 = 0x84242F96ECA9C41DLL;
v3 = 0LL;
v4 = (char *)v12;
memset(v12, 0, sizeof(v12));
for ( i = (unsigned __int64 *)&unk_1E8; ; ++i )
{
v5 = 0LL;
do
{
while ( !_bittest64((const __int64 *)&v2, v5) )
{
((void (*)(void))prng_xorshift1024star_next)();
v5 = (unsigned int)(v5 + 1);
if ( (_DWORD)v5 == 64 )
goto LABEL_9;
}
LODWORD(v6) = state_word_index;
for ( j = (char *)v12; ; v3 = *(_QWORD *)j )
{
v8 = v6;
j += 8;
v6 = (unsigned int)(v6 + 1);
*((_QWORD *)j - 1) = state[v8 & 0xF] ^ v3;
if ( j == v13 )
break;
}
v5 = (unsigned int)(v5 + 1);
v3 = v12[0];
func0(v13, a2, v6);
}
while ( (_DWORD)v5 != 64 );
LABEL_9:
a2 = (char *)&unk_25F + 1;
if ( i == (unsigned __int64 *)((char *)&unk_25F + 1) )
break;
v2 = *i;
}
LODWORD(result) = state_word_index;
while ( 1 )
{
v10 = result;
v4 += 8;
result = (unsigned int)(result + 1);
state[v10 & 0xF] = v3;
if ( v13 == v4 )
break;
v3 = *(_QWORD *)v4;
}
return result;
}

original_code:
void prng_xorshift1024star_jump(void) {
 static const uint64_t JUMP[] = {
  0x84242f96eca9c41dULL, 0xa3c65b8776f96855ULL, 0x5b34a39f070b5837ULL,
  0x4489affce4f31a1eULL, 0x2ffeeb0a48316f40ULL, 0xdc2d9891fe68c022ULL,
  0x3659132bb12fea70ULL, 0xaac17d8efa43cab8ULL, 0xc4cb815590989b13ULL,
  0x5ee975283d71c93bULL, 0x691548c86c1bd540ULL, 0x7910c41d10a1e6a5ULL,
  0x0b5fc64563b3e2a8ULL, 0x047f7684e9fc949dULL, 0xb99181f2d8f685caULL,
  0x284600e3f30e38c3ULL
 };
 uint64_t t[16] = { 0 };
 for (unsigned i = 0; i < sizeof JUMP / sizeof *JUMP; i++) {
  for (unsigned bit_index = 0; bit_index < 64; bit_index++) {
   if (JUMP[i] & 1ULL << bit_index) {
    for (unsigned j = 0; j < 16; j++) {
     t[j] ^= state[(j + state_word_index) & (16 - 1)];
    }
   }
            prng_xorshift1024star_next();
  }
 }
 for(unsigned j = 0;j < 16;j++) {
  state[(j + state_word_index) & (16 - 1)] = t[j];
 }
}

canonical_original_code:
void prng_xorshift1024star_jump() {
 static unsigned long JUMP[] = {
  0x84242f96eca9c41dULL, 0xa3c65b8776f96855ULL, 0x5b34a39f070b5837ULL,
  0x4489affce4f31a1eULL, 0x2ffeeb0a48316f40ULL, 0xdc2d9891fe68c022ULL,
  0x3659132bb12fea70ULL, 0xaac17d8efa43cab8ULL, 0xc4cb815590989b13ULL,
  0x5ee975283d71c93bULL, 0x691548c86c1bd540ULL, 0x7910c41d10a1e6a5ULL,
  0x0b5fc64563b3e2a8ULL, 0x047f7684e9fc949dULL, 0xb99181f2d8f685caULL,
  0x284600e3f30e38c3ULL
 };
 unsigned long t[16] = { 0 };
 for (unsigned int i = 0; i < sizeof JUMP / sizeof *JUMP; i++) {
  for (unsigned int bit_index = 0; bit_index < 64; bit_index++) {
   if (JUMP[i] & 1ULL << bit_index) {
    for (unsigned int j = 0; j < 16; j++) {
     t[j] ^= state[(j + state_word_index) & (16 - 1)];
    }
   }
            prng_xorshift1024star_next();
  }
 }
 for(unsigned int j = 0;j < 16;j++) {
  state[(j + state_word_index) & (16 - 1)] = t[j];
 }
}

variable_types:
JUMP
unsigned long []

variable_types:
t
unsigned long [16]

variable_types:
j
unsigned int


original_code:
unsigned char *base64_decode(unsigned char const *pInputString, size_t *pOutputLength) {
 unsigned char *pOutputData, *pOut;
 size_t inputLength, outputLength;
 if (((void *)0) == pInputString) {
  return ((void *)0);
 }
 inputLength = strlen((char const *) pInputString);
 if (0 == inputLength) {
  return ((void *)0);
 }
 pOutputData = (unsigned char *) calloc(inputLength * 3 / 4, sizeof(unsigned char));
 if (((void *)0) == pOutputData) {
  return ((void *)0);
 }
 pOut = pOutputData;
 outputLength = 0;
 while (inputLength > 0) {
  unsigned char inByte[4] = { 0, 0, 0, 0 };
  signed i = 0;
  while ((i < 4) && (inputLength > 0)) {
   signed inValue = s_base64DecodingTable[*pInputString++];
   inputLength --;
   if (-1 == inValue) {
    continue;
   } else if (inValue < 0) {
    free(pOut);
    return ((void *)0);
   }
   inByte[i++] = (unsigned char) inValue;
  }
  *pOutputData++ = (unsigned char) ((inByte[0] << 2) | (inByte[1] >> 4));
  *pOutputData++ = (unsigned char) ((inByte[1] << 4) | (inByte[2] >> 2));
  *pOutputData++ = (unsigned char) (((inByte[2] << 6) & 0xC0) | inByte[3]);
  switch (i) {
   case 4:
    outputLength += 3;
    break;
   case 3:
    outputLength += 2;
    break;
   case 2:
    outputLength += 1;
    break;
   case 1:
   case 0:
    break;
   default:
    free(pOut);
    return ((void *)0);
  }
 }
 *pOutputLength = outputLength;
 return pOut;
}

canonical_original_code:
unsigned char *base64_decode(unsigned char *pInputString, unsigned long *pOutputLength) {
 unsigned char *pOutputData; unsigned char *pOut;
 unsigned long inputLength; unsigned long outputLength;
 if (((void *)0) == pInputString) {
  return ((void *)0);
 }
 inputLength = strlen((char *) pInputString);
 if (0 == inputLength) {
  return ((void *)0);
 }
 pOutputData = (unsigned char *) calloc(inputLength * 3 / 4, sizeof(unsigned char));
 if (((void *)0) == pOutputData) {
  return ((void *)0);
 }
 pOut = pOutputData;
 outputLength = 0;
 while (inputLength > 0) {
  unsigned char inByte[4] = { 0, 0, 0, 0 };
  int i = 0;
  while ((i < 4) && (inputLength > 0)) {
   int inValue = s_base64DecodingTable[*pInputString++];
   inputLength --;
   if (-1 == inValue) {
    continue;
   } else if (inValue < 0) {
    free(pOut);
    return ((void *)0);
   }
   inByte[i++] = (unsigned char) inValue;
  }
  *pOutputData++ = (unsigned char) ((inByte[0] << 2) | (inByte[1] >> 4));
  *pOutputData++ = (unsigned char) ((inByte[1] << 4) | (inByte[2] >> 2));
  *pOutputData++ = (unsigned char) (((inByte[2] << 6) & 0xC0) | inByte[3]);
  switch (i) {
   case 4:
    outputLength += 3;
    break;
   case 3:
    outputLength += 2;
    break;
   case 2:
    outputLength += 1;
    break;
   case 1:
   case 0:
    break;
   default:
    free(pOut);
    return ((void *)0);
  }
 }
 *pOutputLength = outputLength;
 return pOut;
}

variable_types:
pInputString
unsigned char *

variable_types:
pOutputLength
unsigned long *

variable_types:
pOutputData
unsigned char *

variable_types:
pOut
unsigned char *

variable_types:
inputLength
unsigned long

variable_types:
outputLength
unsigned long

variable_types:
inByte
unsigned char [4]

variable_types: inValue int

return_type: unsigned char *


decompiled_code:
unsigned __int64 __fastcall beGetUint16(unsigned __int8 *a1)
{
if ( !a1 )
_assert_fail("NULL != pS", "src/begetset.c", 0x4Fu, "beGetUint16");
return a1[1] + ((unsigned __int64)*a1 << 8);
}

canonical_decompiled_code:
unsigned __int64 __fastcall func1(unsigned __int8 *a1)
{
if ( !a1 )
_assert_fail("NULL != pS", "src/begetset.c", 0x4Fu, "beGetUint16");
return a1[1] + ((unsigned __int64)*a1 << 8);
}

original_code:
uint_fast16_t beGetUint16(void const *pSrc) {
    unsigned char const *pS = (unsigned char const *) pSrc;
    uint_fast16_t u;
    ((void) sizeof ((((void *)0) != pS) ? 1 : 0), __extension__ ({ if (((void *)0) != pS) ; else __assert_fail ("NULL != pS", "src/begetset.c", 79, __extension__ __PRETTY_FUNCTION__); }));
    u = (uint_fast16_t) ((((uint_fast16_t) *pS) << 8) + *(pS + 1));
    return u;
}

canonical_original_code:
unsigned long beGetUint16(void *pSrc) {
    unsigned char *pS = (unsigned char const *) pSrc;
    unsigned long u;
    ((void) sizeof ((((void *)0) != pS) ? 1 : 0), __extension__ ({ if (((void *)0) != pS) ; else __assert_fail ("NULL != pS", "src/begetset.c", 79, __extension__ __PRETTY_FUNCTION__); }));
    u = (uint_fast16_t) ((((uint_fast16_t) *pS) << 8) + *(pS + 1));
    return u;
}

variable_types:
pSrc
void *

variable_types:
pS
unsigned char *

variable_types:
u
unsigned long


decompiled_code:
unsigned __int64 __fastcall beGetUint32(unsigned __int8 *a1)
{
if ( !a1 )
_assert_fail("NULL != pS", "src/begetset.c", 0x69u, "beGetUint32");
return ((unsigned __int64)*a1 << 24) + ((unsigned __int64)a1[1] << 16) + a1[3] + ((unsigned __int64)a1[2] << 8);
}

canonical_decompiled_code:
unsigned __int64 __fastcall func3(unsigned __int8 *a1)
{
if ( !a1 )
_assert_fail("NULL != pS", "src/begetset.c", 0x69u, "beGetUint32");
return ((unsigned __int64)*a1 << 24) + ((unsigned __int64)a1[1] << 16) + a1[3] + ((unsigned __int64)a1[2] << 8);
}

original_code:
uint_fast32_t beGetUint32(void const *pSrc) {
    unsigned char const *pS = (unsigned char const *) pSrc;
    uint_fast32_t u;
    ((void) sizeof ((((void *)0) != pS) ? 1 : 0), __extension__ ({ if (((void *)0) != pS) ; else __assert_fail ("NULL != pS", "src/begetset.c", 105, __extension__ __PRETTY_FUNCTION__); }));
    u = (((uint_fast32_t) *pS) << 24)
        + (((uint_fast32_t) *(pS + 1)) << 16)
        + (((uint_fast32_t) *(pS + 2)) << 8)
        + *(pS + 3);
    return u;
}

canonical_original_code:
unsigned long beGetUint32(void *pSrc) {
    unsigned char *pS = (unsigned char const *) pSrc;
    unsigned long u;
    ((void) sizeof ((((void *)0) != pS) ? 1 : 0), __extension__ ({ if (((void *)0) != pS) ; else __assert_fail ("NULL != pS", "src/begetset.c", 105, __extension__ __PRETTY_FUNCTION__); }));
    u = (((uint_fast32_t) *pS) << 24)
        + (((uint_fast32_t) *(pS + 1)) << 16)
        + (((uint_fast32_t) *(pS + 2)) << 8)
        + *(pS + 3);
    return u;
}


factorial

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

result = 0xFFFFFFFFLL;
if ( a1 <= 0xC )
result = m_factorials[a1];
return result;
}

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

result = 0xFFFFFFFFLL;
if ( a1 <= 0xC )
result = m_factorials[a1];
return result;
}

original_code:
unsigned factorial(unsigned n) {
    if (n > MAX_FACTORIAL_INPUT) {
        return (0x7fffffff * 2U + 1U);
    }
    return m_factorials[n];
}

canonical_original_code:
unsigned int factorial(unsigned int n) {
    if (n > MAX_FACTORIAL_INPUT) {
        return (0x7fffffff * 2U + 1U);
    }
    return m_factorials[n];
}

variable_types:
n
unsigned int

return_type: unsigned int


rstrip

original_code:
size_t rstrip(char *pStartOfString) {
    char *pEndOfString = pStartOfString + strlen(pStartOfString);
    while (--pEndOfString >= pStartOfString) {
        if (!((*__ctype_b_loc ())[(int) ((*pEndOfString))] & (unsigned short int) _ISspace)) {
            *(pEndOfString + 1) = '\0';
            break;
        }
    }
    if (pEndOfString == pStartOfString - 1) {
        *pStartOfString = '\0';
    }
    return (size_t) pEndOfString + 1 - (size_t) pStartOfString;
}

canonical_original_code:
unsigned long rstrip(char *pStartOfString) {
    char *pEndOfString = pStartOfString + strlen(pStartOfString);
    while (--pEndOfString >= pStartOfString) {
        if (!((*__ctype_b_loc ())[(int) ((*pEndOfString))] & (unsigned short) _ISspace)) {
            *(pEndOfString + 1) = '\0';
            break;
        }
    }
    if (pEndOfString == pStartOfString - 1) {
        *pStartOfString = '\0';
    }
    return (unsigned long) pEndOfString + 1 - (unsigned long) pStartOfString;
}

variable_types:
pStartOfString
char *

variable_types:
pEndOfString
char *


lstrip

decompiled_code:
size_t __fastcall lstrip(void *dest)
{
char *v1; // r12
char *v2; // rsi
const unsigned __int16 *v3; // rdx
size_t v4; // r12

v1 = (char *)dest + strlen((const char *)dest);
v2 = (char *)dest;
v3 = *_ctype_b_loc();
do
{
if ( (v3[*v2] & 0x2000) == 0 )
break;
++v2;
}
while ( v1 > v2 );
v4 = v1 - v2;
if ( v2 != dest )
{
memmove(dest, v2, v4);
*((_BYTE *)dest + v4) = 0;
}
return v4;
}

canonical_decompiled_code:
size_t __fastcall func0(void *dest)
{
char *v1; // r12
char *v2; // rsi
const unsigned __int16 *v3; // rdx
size_t v4; // r12

v1 = (char *)dest + strlen((const char *)dest);
v2 = (char *)dest;
v3 = *_ctype_b_loc();
do
{
if ( (v3[*v2] & 0x2000) == 0 )
break;
++v2;
}
while ( v1 > v2 );
v4 = v1 - v2;
if ( v2 != dest )
{
memmove(dest, v2, v4);
*((_BYTE *)dest + v4) = 0;
}
return v4;
}

original_code:
size_t lstrip(char *pStartOfString) {
    char *pFirstNonWhitespace = pStartOfString;
    char *pEndOfString = pStartOfString + strlen(pStartOfString);
    size_t newlength;
    do {
        if (!((*__ctype_b_loc ())[(int) ((*pFirstNonWhitespace))] & (unsigned short int) _ISspace)) {
            break;
        }
    } while (++pFirstNonWhitespace < pEndOfString);
    newlength = pEndOfString - pFirstNonWhitespace;
    if (pFirstNonWhitespace != pStartOfString) {
        memmove(pStartOfString, pFirstNonWhitespace, newlength);
        *(pStartOfString + newlength) = '\0';
    }
    return newlength;
}

canonical_original_code:
unsigned long lstrip(char *pStartOfString) {
    char *pFirstNonWhitespace = pStartOfString;
    char *pEndOfString = pStartOfString + strlen(pStartOfString);
    unsigned long newlength;
    do {
        if (!((*__ctype_b_loc ())[(int) ((*pFirstNonWhitespace))] & (unsigned short) _ISspace)) {
            break;
        }
    } while (++pFirstNonWhitespace < pEndOfString);
    newlength = pEndOfString - pFirstNonWhitespace;
    if (pFirstNonWhitespace != pStartOfString) {
        memmove(pStartOfString, pFirstNonWhitespace, newlength);
        *(pStartOfString + newlength) = '\0';
    }
    return newlength;
}

variable_types:
pFirstNonWhitespace
char *

variable_types:
newlength
unsigned long


decompiled_code:
__int64 __fastcall leGetUint16(unsigned __int8 *a1)
{
if ( !a1 )
_assert_fail("NULL != pS", "src/legetset.c", 0x50u, "leGetUint16");
return *a1 + (__int64)(a1[1] << 8);
}

canonical_decompiled_code:
__int64 __fastcall func1(unsigned __int8 *a1)
{
if ( !a1 )
_assert_fail("NULL != pS", "src/legetset.c", 0x50u, "leGetUint16");
return *a1 + (__int64)(a1[1] << 8);
}

original_code:
uint_fast16_t leGetUint16(void const *pSrc) {
    unsigned char const *pS = (unsigned char const *) pSrc;
    uint_fast16_t u;
    ((void) sizeof ((((void *)0) != pS) ? 1 : 0), __extension__ ({ if (((void *)0) != pS) ; else __assert_fail ("NULL != pS", "src/legetset.c", 80, __extension__ __PRETTY_FUNCTION__); }));
    u = (uint_fast16_t) (*(pS + 1) << 8) + *pS;
    return u;
}

canonical_original_code:
unsigned long leGetUint16(void *pSrc) {
    unsigned char *pS = (unsigned char const *) pSrc;
    unsigned long u;
    ((void) sizeof ((((void *)0) != pS) ? 1 : 0), __extension__ ({ if (((void *)0) != pS) ; else __assert_fail ("NULL != pS", "src/legetset.c", 80, __extension__ __PRETTY_FUNCTION__); }));
    u = (uint_fast16_t) (*(pS + 1) << 8) + *pS;
    return u;
}


decompiled_code:
unsigned __int64 __fastcall leGetUint32(unsigned __int8 *a1)
{
if ( !a1 )
_assert_fail("NULL != pS", "src/legetset.c", 0x6Au, "leGetUint32");
return ((unsigned __int64)a1[3] << 24) + ((unsigned __int64)a1[2] << 16) + *a1 + ((unsigned __int64)a1[1] << 8);
}

canonical_decompiled_code:
unsigned __int64 __fastcall func3(unsigned __int8 *a1)
{
if ( !a1 )
_assert_fail("NULL != pS", "src/legetset.c", 0x6Au, "leGetUint32");
return ((unsigned __int64)a1[3] << 24) + ((unsigned __int64)a1[2] << 16) + *a1 + ((unsigned __int64)a1[1] << 8);
}

original_code:
uint_fast32_t leGetUint32(void const *pSrc) {
    unsigned char const *pS = (unsigned char const *) pSrc;
    uint_fast32_t u;
    ((void) sizeof ((((void *)0) != pS) ? 1 : 0), __extension__ ({ if (((void *)0) != pS) ; else __assert_fail ("NULL != pS", "src/legetset.c", 106, __extension__ __PRETTY_FUNCTION__); }));
    u = (((uint_fast32_t) *(pS + 3)) << 24)
        + (((uint_fast32_t) *(pS + 2)) << 16)
        + (((uint_fast32_t) *(pS + 1)) << 8)
        + *pS;
    return u;
}

canonical_original_code:
unsigned long leGetUint32(void *pSrc) {
    unsigned char *pS = (unsigned char const *) pSrc;
    unsigned long u;
    ((void) sizeof ((((void *)0) != pS) ? 1 : 0), __extension__ ({ if (((void *)0) != pS) ; else __assert_fail ("NULL != pS", "src/legetset.c", 106, __extension__ __PRETTY_FUNCTION__); }));
    u = (((uint_fast32_t) *(pS + 3)) << 24)
        + (((uint_fast32_t) *(pS + 2)) << 16)
        + (((uint_fast32_t) *(pS + 1)) << 8)
        + *pS;
    return u;
}


ffactorial

decompiled_code:
__int64 __fastcall ffactorial(double a1)
{
__int64 result; // rax
unsigned int v2; // edx
double v3; // xmm0_8

if ( a1 < 21.0 )
return (unsigned int)(int)a1;
if ( a1 >= 4294967295.0 )
_assert_fail("n < UINT_MAX", "src/ffactorial.c", 0x65u, "ffactorial");
v2 = (int)a1;
v3 = *(double *)&LC0;
result = v2;
if ( v2 )
{
do
{
v3 = v3 * (double)(int)result;
result = (unsigned int)(result - 1);
}
while ( (_DWORD)result );
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(double a1)
{
__int64 result; // rax
unsigned int v2; // edx
double v3; // xmm0_8

if ( a1 < 21.0 )
return (unsigned int)(int)a1;
if ( a1 >= 4294967295.0 )
_assert_fail("n < UINT_MAX", "src/ffactorial.c", 0x65u, "ffactorial");
v2 = (int)a1;
v3 = *(double *)&LC0;
result = v2;
if ( v2 )
{
do
{
v3 = v3 * (double)(int)result;
result = (unsigned int)(result - 1);
}
while ( (_DWORD)result );
}
return result;
}

original_code:
double ffactorial(double n) {
    double f;
    if (n < sizeof(m_factorials) / sizeof(double)) {
        f = m_factorials[(unsigned) n];
    } else {
        unsigned i;
        ((void) sizeof ((n < (0x7fffffff * 2U + 1U)) ? 1 : 0), __extension__ ({ if (n < (0x7fffffff * 2U + 1U)) ; else __assert_fail ("n < UINT_MAX", "src/ffactorial.c", 101, __extension__ __PRETTY_FUNCTION__); }));
        f = 1.0;
        for (i = (unsigned) n;i > 0;i --) {
            f = f * i;
        }
    }
    return f;
}

canonical_original_code:
double ffactorial(double n) {
    double f;
    if (n < sizeof(m_factorials) / sizeof(double)) {
        f = m_factorials[(unsigned int) n];
    } else {
        unsigned int i;
        ((void) sizeof ((n < (0x7fffffff * 2U + 1U)) ? 1 : 0), __extension__ ({ if (n < (0x7fffffff * 2U + 1U)) ; else __assert_fail ("n < UINT_MAX", "src/ffactorial.c", 101, __extension__ __PRETTY_FUNCTION__); }));
        f = 1.0;
        for (i = (unsigned int) n;i > 0;i --) {
            f = f * i;
        }
    }
    return f;
}

variable_types: n double

variable_types: f double

variable_types:
i
unsigned int

return_type: double


checksum

decompiled_code:
__int64 __fastcall checksum(unsigned __int8 *a1, unsigned int a2)
{
unsigned int v3; // edx
unsigned int v4; // esi
unsigned int i; // ecx
int v6; // eax
unsigned int v7; // eax

v3 = 0;
v4 = a2 - 1;
if ( !v4 )
goto LABEL_8;
for ( i = 0; i < v4; i += 2 )
{
v6 = i;
v7 = v3 + *(unsigned __int16 *)&a1[2 * (v6 >> 1)];
v3 = HIWORD(v7) + (unsigned __int16)v7;
}
if ( a2 > ((a2 - 2) & 0xFFFFFFFE) + 2 )
LABEL_8:
v3 += *a1;
if ( HIWORD(v3) )
v3 = (unsigned __int16)v3 + 1;
return ~v3;
}

canonical_decompiled_code:
__int64 __fastcall func0(unsigned __int8 *a1, unsigned int a2)
{
unsigned int v3; // edx
unsigned int v4; // esi
unsigned int i; // ecx
int v6; // eax
unsigned int v7; // eax

v3 = 0;
v4 = a2 - 1;
if ( !v4 )
goto LABEL_8;
for ( i = 0; i < v4; i += 2 )
{
v6 = i;
v7 = v3 + *(unsigned __int16 *)&a1[2 * (v6 >> 1)];
v3 = HIWORD(v7) + (unsigned __int16)v7;
}
if ( a2 > ((a2 - 2) & 0xFFFFFFFE) + 2 )
LABEL_8:
v3 += *a1;
if ( HIWORD(v3) )
v3 = (unsigned __int16)v3 + 1;
return ~v3;
}

original_code:
uint16_t checksum(const uint8_t * addr, uint32_t count)
{
 int i = 0;
 uint32_t sum = 0, checksum = 0;
 while(i < (count - 1)) {
  sum += ((uint16_t *) addr)[i/2];
  sum = (sum & 0xFFFF) + (sum >> 16);
  i+=2;
 }
 if(i < count)
 {
  sum += *((uint8_t *) addr);
 }
 while (sum >> 16)
 {
  sum = (sum & 0xFFFF) + (sum >> 16);
 }
 checksum = ~sum;
 return checksum;
}

canonical_original_code:
unsigned short checksum(unsigned char *addr, unsigned int count)
{
 int i = 0;
 unsigned int sum = 0; unsigned int checksum = 0;
 while(i < (count - 1)) {
  sum += ((unsigned short *) addr)[i/2];
  sum = (sum & 0xFFFF) + (sum >> 16);
  i+=2;
 }
 if(i < count)
 {
  sum += *((unsigned char *) addr);
 }
 while (sum >> 16)
 {
  sum = (sum & 0xFFFF) + (sum >> 16);
 }
 checksum = ~sum;
 return checksum;
}

variable_types:
addr
unsigned char *

variable_types:
count
unsigned int

variable_types: i int

variable_types:
sum
unsigned int

variable_types:
checksum
unsigned int

return_type: unsigned short


getSeqNum

decompiled_code:
__int64 __fastcall getSeqNum(unsigned int *a1)
{
return *a1;
}

canonical_decompiled_code:
__int64 __fastcall func1(unsigned int *a1)
{
return *a1;
}

original_code:
uint32_t getSeqNum(const byte_t * pkt)
{
 return ((uint32_t *)pkt)[0>>5];
}

canonical_original_code:
unsigned int getSeqNum(unsigned char *pkt)
{
 return ((unsigned int *)pkt)[0>>5];
}

variable_types:
pkt
unsigned char *


getACKNum

decompiled_code:
__int64 __fastcall getACKNum(__int64 a1)
{
return *(unsigned int *)(a1 + 4);
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1)
{
return *(unsigned int *)(a1 + 4);
}

original_code:
uint32_t getACKNum(const byte_t * pkt)
{
 return ((uint32_t *)pkt)[32>>5];
}

canonical_original_code:
unsigned int getACKNum(unsigned char *pkt)
{
 return ((unsigned int *)pkt)[32>>5];
}


setACKNum

decompiled_code:
void __fastcall setACKNum(__int64 a1, int a2)
{
*(_DWORD *)(a1 + 4) = a2;
}

canonical_decompiled_code:
void __fastcall func4(__int64 a1, int a2)
{
*(_DWORD *)(a1 + 4) = a2;
}

original_code:
void setACKNum(byte_t * pkt, uint32_t ACKNum)
{
 int index = 32>>5;
 ((uint32_t *)pkt)[index] = ACKNum;
}

canonical_original_code:
void setACKNum(unsigned char *pkt, unsigned int ACKNum)
{
 int index = 32>>5;
 ((unsigned int *)pkt)[index] = ACKNum;
}

variable_types:
ACKNum
unsigned int

variable_types: index int


getACK

decompiled_code:
__int64 __fastcall getACK(__int64 a1)
{
return *(_DWORD *)(a1 + 8) >> 31;
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1)
{
return *(_DWORD *)(a1 + 8) >> 31;
}

original_code:
_Bool getACK(const byte_t * pkt)
{
 uint32_t temp = ((uint32_t *)pkt)[64>>5];
 temp = temp >> 31;
 temp = temp & 0x1;
 return temp;
}

canonical_original_code:
_Bool getACK(unsigned char *pkt)
{
 unsigned int temp = ((uint32_t *)pkt)[64>>5];
 temp = temp >> 31;
 temp = temp & 0x1;
 return temp;
}

variable_types:
temp
unsigned int


setACK

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

result = (a2 << 31) | *(_DWORD *)(a1 + 8) & 0x7FFFFFFFu;
*(_DWORD *)(a1 + 8) = result;
return result;
}

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

result = (a2 << 31) | *(_DWORD *)(a1 + 8) & 0x7FFFFFFFu;
*(_DWORD *)(a1 + 8) = result;
return result;
}

original_code:
void setACK(byte_t * pkt, _Bool ACK)
{
 uint32_t temp = ACK;
 temp = temp << 31;
 ((uint32_t *)pkt)[64>>5] = (((uint32_t *)pkt)[64>>5]&0x7FFFFFFF) | temp;
}

canonical_original_code:
void setACK(unsigned char *pkt, _Bool ACK)
{
 unsigned int temp = ACK;
 temp = temp << 31;
 ((unsigned int *)pkt)[64>>5] = (((unsigned int *)pkt)[64>>5]&0x7FFFFFFF) | temp;
}


getLast

decompiled_code:
__int64 __fastcall getLast(__int64 a1)
{
if ( a1 )
return (*(_DWORD *)(a1 + 8) >> 30) & 1;
puts("getLast: pkt is NULL");
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1)
{
if ( a1 )
return (*(_DWORD *)(a1 + 8) >> 30) & 1;
puts("getLast: pkt is NULL");
return 0LL;
}

original_code:
_Bool getLast(const byte_t * pkt)
{
 uint32_t temp = 0;
 if (pkt == ((void *)0))
 {
  printf("getLast: pkt is NULL\n");
  return 0;
 }
 temp = ((uint32_t *)pkt)[65>>5];
 temp = temp >> 30;
 temp = temp & 0x1;
 return temp;
}

canonical_original_code:
_Bool getLast(unsigned char *pkt)
{
 unsigned int temp = 0;
 if (pkt == ((void *)0))
 {
  printf("getLast: pkt is NULL\n");
  return 0;
 }
 temp = ((unsigned int *)pkt)[65>>5];
 temp = temp >> 30;
 temp = temp & 0x1;
 return temp;
}


setLast

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

result = (a2 << 30) | *(_DWORD *)(a1 + 8) & 0xBFFFFFFF;
*(_DWORD *)(a1 + 8) = result;
return result;
}

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

result = (a2 << 30) | *(_DWORD *)(a1 + 8) & 0xBFFFFFFF;
*(_DWORD *)(a1 + 8) = result;
return result;
}

original_code:
void setLast(byte_t * pkt, _Bool last)
{
 uint32_t temp = last;
 temp = temp << 30;
 ((uint32_t *)pkt)[65>>5] = (((uint32_t *)pkt)[65>>5]&0xBFFFFFFF) | temp;
}

canonical_original_code:
void setLast(unsigned char *pkt, _Bool last)
{
 unsigned int temp = last;
 temp = temp << 30;
 ((unsigned int *)pkt)[65>>5] = (((unsigned int *)pkt)[65>>5]&0xBFFFFFFF) | temp;
}


getClose

decompiled_code:
__int64 __fastcall getClose(__int64 a1)
{
return (*(_DWORD *)(a1 + 8) >> 29) & 1;
}

original_code:
_Bool getClose(const byte_t * pkt)
{
 uint32_t temp = ((uint32_t *)pkt)[66>>5];
 temp = temp >> 29;
 temp = temp & 0x1;
 return (temp != 0);
}

canonical_original_code:
_Bool getClose(unsigned char *pkt)
{
 unsigned int temp = ((uint32_t *)pkt)[66>>5];
 temp = temp >> 29;
 temp = temp & 0x1;
 return (temp != 0);
}


setClose

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

result = (a2 << 29) | *(_DWORD *)(a1 + 8) & 0xDFFFFFFF;
*(_DWORD *)(a1 + 8) = result;
return result;
}

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

result = (a2 << 29) | *(_DWORD *)(a1 + 8) & 0xDFFFFFFF;
*(_DWORD *)(a1 + 8) = result;
return result;
}

original_code:
void setClose(byte_t * pkt, _Bool last)
{
 uint32_t temp = last;
 temp = temp << 29;
 ((uint32_t *)pkt)[66>>5] = (((uint32_t *)pkt)[66>>5]&0xDFFFFFFF) | temp;
}

canonical_original_code:
void setClose(unsigned char *pkt, _Bool last)
{
 unsigned int temp = last;
 temp = temp << 29;
 ((unsigned int *)pkt)[66>>5] = (((unsigned int *)pkt)[66>>5]&0xDFFFFFFF) | temp;
}


getSize

decompiled_code:
__int64 __fastcall getSize(__int64 a1)
{
return *(_WORD *)(a1 + 10) & 0x3FF;
}

canonical_decompiled_code:
__int64 __fastcall func11(__int64 a1)
{
return *(_WORD *)(a1 + 10) & 0x3FF;
}

original_code:
uint16_t getSize(const byte_t * pkt)
{
 uint32_t temp = ((uint32_t *)pkt)[70>>5];
 temp = temp >> 16;
 temp = temp & 0x3FF;
 return (uint16_t)temp;
}

canonical_original_code:
unsigned short getSize(unsigned char *pkt)
{
 unsigned int temp = ((uint32_t *)pkt)[70>>5];
 temp = temp >> 16;
 temp = temp & 0x3FF;
 return (unsigned short)temp;
}


setSize

decompiled_code:
__int64 __fastcall setSize(__int64 a1, int a2)
{
unsigned int v2; // er8
int v3; // esi
__int64 result; // rax

if ( (unsigned __int16)a2 > 0x3F4u )
{
v3 = 66322432;
v2 = 1012;
}
else
{
v2 = (unsigned __int16)a2;
v3 = a2 << 16;
}
result = v2;
*(_DWORD *)(a1 + 8) = *(_DWORD *)(a1 + 8) & 0xFC00FFFF | v3;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func12(__int64 a1, int a2)
{
unsigned int v2; // er8
int v3; // esi
__int64 result; // rax

if ( (unsigned __int16)a2 > 0x3F4u )
{
v3 = 66322432;
v2 = 1012;
}
else
{
v2 = (unsigned __int16)a2;
v3 = a2 << 16;
}
result = v2;
*(_DWORD *)(a1 + 8) = *(_DWORD *)(a1 + 8) & 0xFC00FFFF | v3;
return result;
}

original_code:
int setSize(byte_t * pkt, uint16_t size)
{
 uint32_t temp = size;
 int ret = size;
 if(size > 1012){
  temp = 1012;
  ret = 1012;
 }
 temp = temp << 16;
 ((uint32_t *)pkt)[70>>5] = (((uint32_t *)pkt)[70>>5]&0xFC00FFFF) | temp;
 return ret;
}

canonical_original_code:
int setSize(unsigned char *pkt, unsigned short size)
{
 unsigned int temp = size;
 int ret = size;
 if(size > 1012){
  temp = 1012;
  ret = 1012;
 }
 temp = temp << 16;
 ((unsigned int *)pkt)[70>>5] = (((unsigned int *)pkt)[70>>5]&0xFC00FFFF) | temp;
 return ret;
}

variable_types:
size
unsigned short

variable_types: ret int


getChecksum

decompiled_code:
__int64 __fastcall getChecksum(__int64 a1)
{
return *(unsigned int *)(a1 + 8);
}

canonical_decompiled_code:
__int64 __fastcall func13(__int64 a1)
{
return *(unsigned int *)(a1 + 8);
}

original_code:
uint16_t getChecksum(const byte_t *pkt)
{
 uint32_t temp = ((uint32_t *)pkt)[80>>5];
 temp = temp & 0xFFFF;
 return (uint16_t)temp;
}

canonical_original_code:
unsigned short getChecksum(unsigned char *pkt)
{
 unsigned int temp = ((uint32_t *)pkt)[80>>5];
 temp = temp & 0xFFFF;
 return (unsigned short)temp;
}


setChecksum

decompiled_code:
void __fastcall setChecksum(__int64 a1, __int16 a2)
{
*(_WORD *)(a1 + 8) = a2;
}

original_code:
void setChecksum(byte_t * pkt, uint16_t checksum)
{
 uint32_t temp = checksum & 0x0000FFFF;
 ((uint32_t *)pkt)[80>>5] = (((uint32_t *)pkt)[80>>5]&0xFFFF0000) | temp;
}

canonical_original_code:
void setChecksum(unsigned char *pkt, unsigned short checksum)
{
 unsigned int temp = checksum & 0x0000FFFF;
 ((unsigned int *)pkt)[80>>5] = (((unsigned int *)pkt)[80>>5]&0xFFFF0000) | temp;
}

variable_types:
checksum
unsigned short


getBody

decompiled_code:
char *__fastcall getBody(__int64 a1)
{
return strdup((const char *)(a1 + 12));
}

canonical_decompiled_code:
char *__fastcall func15(__int64 a1)
{
return strdup((const char *)(a1 + 12));
}

original_code:
byte_t * getBody(const byte_t * pkt)
{
 return strdup(&(pkt[96>>3]));
}

canonical_original_code:
unsigned char *getBody(unsigned char *pkt)
{
 return strdup(&(pkt[96>>3]));
}


setBody

decompiled_code:
__int64 __fastcall setBody(__int64 a1, _QWORD *a2)
{
unsigned __int16 v2; // ax
int v3; // edx
int v4; // ebp
__int64 result; // rax
__int64 v6; // rdx

if ( !a1 )
return 0xFFFFFFFFLL;
if ( !a2 )
return 0xFFFFFFFFLL;
v2 = getSize(a1);
v4 = v3;
if ( v2 != v3 )
puts("setData: remember packet size parameter and data byte count must ==");
result = 1012LL;
v6 = a1 + 12;
if ( v4 <= 1012 )
result = (unsigned int)v4;
if ( (unsigned __int64)(int)result >= 8 )
{
*(_QWORD *)(a1 + 12) = *a2;
*(_QWORD *)(v6 + (int)result - 8) = *(_QWORD *)((char *)a2 + (int)result - 8);
qmemcpy(
(void *)((a1 + 20) & 0xFFFFFFFFFFFFFFF8LL),
(char *)a2 - (v6 - ((a1 + 20) & 0xFFFFFFFFFFFFFFF8LL)),
8 * ((v6 - ((a1 + 20) & 0xFFFFFFFFFFFFFFF8LL) + (int)result) >> 3));
}
else if ( (result & 4) != 0 )
{
*(_DWORD *)(a1 + 12) = *(_DWORD *)a2;
*(_DWORD *)(v6 + (int)result - 4) = *(_DWORD *)((char *)a2 + (int)result - 4);
}
else if ( (_DWORD)result )
{
*(_BYTE *)(a1 + 12) = *(_BYTE *)a2;
if ( (result & 2) != 0 )
*(_WORD *)(v6 + (int)result - 2) = *(_WORD *)((char *)a2 + (int)result - 2);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func16(__int64 a1, _QWORD *a2)
{
unsigned __int16 v2; // ax
int v3; // edx
int v4; // ebp
__int64 result; // rax
__int64 v6; // rdx

if ( !a1 )
return 0xFFFFFFFFLL;
if ( !a2 )
return 0xFFFFFFFFLL;
v2 = func11(a1);
v4 = v3;
if ( v2 != v3 )
puts("setData: remember packet size parameter and data byte count must ==");
result = 1012LL;
v6 = a1 + 12;
if ( v4 <= 1012 )
result = (unsigned int)v4;
if ( (unsigned __int64)(int)result >= 8 )
{
*(_QWORD *)(a1 + 12) = *a2;
*(_QWORD *)(v6 + (int)result - 8) = *(_QWORD *)((char *)a2 + (int)result - 8);
qmemcpy(
(void *)((a1 + 20) & 0xFFFFFFFFFFFFFFF8LL),
(char *)a2 - (v6 - ((a1 + 20) & 0xFFFFFFFFFFFFFFF8LL)),
8 * ((v6 - ((a1 + 20) & 0xFFFFFFFFFFFFFFF8LL) + (int)result) >> 3));
}
else if ( (result & 4) != 0 )
{
*(_DWORD *)(a1 + 12) = *(_DWORD *)a2;
*(_DWORD *)(v6 + (int)result - 4) = *(_DWORD *)((char *)a2 + (int)result - 4);
}
else if ( (_DWORD)result )
{
*(_BYTE *)(a1 + 12) = *(_BYTE *)a2;
if ( (result & 2) != 0 )
*(_WORD *)(v6 + (int)result - 2) = *(_WORD *)((char *)a2 + (int)result - 2);
}
return result;
}

original_code:
int setBody(byte_t * pkt, byte_t * buff, size_t count)
{
 int i = 0;
 int copied = count;
 if(pkt == ((void *)0) || buff == ((void *)0)) return -1;
 if(getSize(pkt) != copied){
  printf("setData: remember packet size parameter and data byte count must ==\n");
 }
 if(copied > 1012) {
  copied = 1012;
 }
 memcpy(&(pkt[96>>3]), buff, copied);
 return copied;
}

canonical_original_code:
int setBody(unsigned char *pkt, unsigned char *buff, unsigned long count)
{
 int i = 0;
 int copied = count;
 if(pkt == ((void *)0) || buff == ((void *)0)) return -1;
 if(getSize(pkt) != copied){
  printf("setData: remember packet size parameter and data byte count must ==\n");
 }
 if(copied > 1012) {
  copied = 1012;
 }
 memcpy(&(pkt[96>>3]), buff, copied);
 return copied;
}

variable_types:
buff
unsigned char *

variable_types:
count
unsigned long

variable_types: copied int


printPacket

decompiled_code:
void __fastcall printPacket(unsigned __int8 *a1)
{
__int64 v1; // rbp
unsigned int *v2; // rbx
char *v3; // r12
unsigned __int16 v4; // r14
unsigned __int16 v5; // r13
__int64 v6; // rcx
__int64 v7; // rdx
__int64 v8; // r8
__int64 v9; // rsi
__int64 v10; // rbx
unsigned int v11; // eax
unsigned int v12; // eax
unsigned __int8 v13; // al
unsigned __int8 v14; // al
unsigned __int8 v15; // al
unsigned __int16 v16; // ax
int v17; // edi

if ( a1 )
{
v1 = (__int64)a1;
v2 = (unsigned int *)a1;
v3 = getBody((__int64)a1);
v4 = getChecksum((__int64)a1);
v5 = checksum(a1, 0x400u);
puts("printPacket:");
puts("\tpkt bits");
do
{
v6 = v2[2];
v7 = v2[1];
v8 = v2[3];
v9 = *v2;
v2 += 8;
printf("%08x %08x %08x %08x ", v9, v7, v6, v8);
printf("%08x %08x %08x %08x\n", *(v2 - 4), *(v2 - 3), *(v2 - 2), *(v2 - 1));
}
while ( a1 + 128 != (unsigned __int8 *)v2 );
v10 = 0LL;
v11 = getSeqNum((unsigned int *)a1);
printf("\tseq_num=%x\n", v11);
v12 = getACKNum((__int64)a1);
printf("\tack_num=%x\n", v12);
v13 = getACK((__int64)a1);
printf("\tack=%d\n", v13);
v14 = getLast((__int64)a1);
printf("\tlast=%d\n", v14);
v15 = getClose((__int64)a1);
printf("\tclose=%d\n", v15);
v16 = getSize((__int64)a1);
printf("\tsize=%d\n", v16);
puts("\tchecksum:");
printf("\t\tcs_msg=%x\n", v4);
printf("\t\tcs_valid==0?=%x\n", v5);
printf("\tbody=\n\t:");
while ( (unsigned __int16)getSize(v1) > (int)v10 )
{
v17 = (unsigned __int8)v3[v10++];
putchar(v17);
}
putchar(10);
puts("printPacket: END");
free(v3);
}
else
{
puts("printPacket: was not given a valid string");
}
}

canonical_decompiled_code:
void __fastcall func18(unsigned __int8 *a1)
{
__int64 v1; // rbp
unsigned int *v2; // rbx
char *v3; // r12
unsigned __int16 v4; // r14
unsigned __int16 v5; // r13
__int64 v6; // rcx
__int64 v7; // rdx
__int64 v8; // r8
__int64 v9; // rsi
__int64 v10; // rbx
unsigned int v11; // eax
unsigned int v12; // eax
unsigned __int8 v13; // al
unsigned __int8 v14; // al
unsigned __int8 v15; // al
unsigned __int16 v16; // ax
int v17; // edi

if ( a1 )
{
v1 = (__int64)a1;
v2 = (unsigned int *)a1;
v3 = func15((__int64)a1);
v4 = func13((__int64)a1);
v5 = func0(a1, 0x400u);
puts("printPacket:");
puts("\tpkt bits");
do
{
v6 = v2[2];
v7 = v2[1];
v8 = v2[3];
v9 = *v2;
v2 += 8;
printf("%08x %08x %08x %08x ", v9, v7, v6, v8);
printf("%08x %08x %08x %08x\n", *(v2 - 4), *(v2 - 3), *(v2 - 2), *(v2 - 1));
}
while ( a1 + 128 != (unsigned __int8 *)v2 );
v10 = 0LL;
v11 = func1((unsigned int *)a1);
printf("\tseq_num=%x\n", v11);
v12 = func3((__int64)a1);
printf("\tack_num=%x\n", v12);
v13 = func5((__int64)a1);
printf("\tack=%d\n", v13);
v14 = func7((__int64)a1);
printf("\tlast=%d\n", v14);
v15 = func9((__int64)a1);
printf("\tclose=%d\n", v15);
v16 = func11((__int64)a1);
printf("\tsize=%d\n", v16);
puts("\tchecksum:");
printf("\t\tcs_msg=%x\n", v4);
printf("\t\tcs_valid==0?=%x\n", v5);
printf("\tbody=\n\t:");
while ( (unsigned __int16)func11(v1) > (int)v10 )
{
v17 = (unsigned __int8)v3[v10++];
putchar(v17);
}
putchar(10);
puts("printPacket: END");
free(v3);
}
else
{
puts("printPacket: was not given a valid string");
}
}

original_code:
void printPacket(byte_t * pkt)
{
 if(pkt == ((void *)0)){
  printf("printPacket: was not given a valid string\n");
 }
 else{
  int i = 0;
  byte_t * body = getBody(pkt);
  uint16_t cs_msg = getChecksum(pkt);
  uint16_t cs_valid = checksum(pkt,1024);
  printf("printPacket:\n");
  printf("\tpkt bits\n");
      for(i = 0; i < 1024/32; i+=8)
      {
            printf("%08x %08x %08x %08x ",((uint32_t *)pkt)[i], ((uint32_t *)pkt)[i+1], ((uint32_t *)pkt)[i+2], ((uint32_t *)pkt)[i+3]);
         printf("%08x %08x %08x %08x\n",((uint32_t *)pkt)[i+4], ((uint32_t *)pkt)[i+5], ((uint32_t *)pkt)[i+6], ((uint32_t *)pkt)[i+7]);
      }
  printf("\tseq_num=%x\n", getSeqNum(pkt));
  printf("\tack_num=%x\n", getACKNum(pkt));
  printf("\tack=%d\n", getACK(pkt));
  printf("\tlast=%d\n",getLast(pkt));
  printf("\tclose=%d\n",getClose(pkt));
  printf("\tsize=%d\n",getSize(pkt));
  printf("\tchecksum:\n");
  printf("\t\tcs_msg=%x\n",cs_msg);
  printf("\t\tcs_valid==0?=%x\n", cs_valid);
  printf("\tbody=\n\t:");
  for(i = 0; i < getSize(pkt); i++)
  {
   printf("%c",body[i]);
  }
  printf("\n");
  printf("printPacket: END\n");
  free(body);
 }
}

canonical_original_code:
void printPacket(unsigned char *pkt)
{
 if(pkt == ((void *)0)){
  printf("printPacket: was not given a valid string\n");
 }
 else{
  int i = 0;
  unsigned char *body = getBody(pkt);
  unsigned short cs_msg = getChecksum(pkt);
  unsigned short cs_valid = checksum(pkt,1024);
  printf("printPacket:\n");
  printf("\tpkt bits\n");
      for(i = 0; i < 1024/32; i+=8)
      {
            printf("%08x %08x %08x %08x ",((unsigned int *)pkt)[i], ((unsigned int *)pkt)[i+1], ((unsigned int *)pkt)[i+2], ((unsigned int *)pkt)[i+3]);
         printf("%08x %08x %08x %08x\n",((unsigned int *)pkt)[i+4], ((unsigned int *)pkt)[i+5], ((unsigned int *)pkt)[i+6], ((unsigned int *)pkt)[i+7]);
      }
  printf("\tseq_num=%x\n", getSeqNum(pkt));
  printf("\tack_num=%x\n", getACKNum(pkt));
  printf("\tack=%d\n", getACK(pkt));
  printf("\tlast=%d\n",getLast(pkt));
  printf("\tclose=%d\n",getClose(pkt));
  printf("\tsize=%d\n",getSize(pkt));
  printf("\tchecksum:\n");
  printf("\t\tcs_msg=%x\n",cs_msg);
  printf("\t\tcs_valid==0?=%x\n", cs_valid);
  printf("\tbody=\n\t:");
  for(i = 0; i < getSize(pkt); i++)
  {
   printf("%c",body[i]);
  }
  printf("\n");
  printf("printPacket: END\n");
  free(body);
 }
}

variable_types:
body
unsigned char *


freePacket

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

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

original_code:
void freePacket(byte_t * pkt)
{
 free(pkt);
 pkt = ((void *)0);
}

canonical_original_code:
void freePacket(unsigned char *pkt)
{
 free(pkt);
 pkt = ((void *)0);
}


freePackets

decompiled_code:
void __fastcall freePackets(void *ptr)
{
void *v2; // rdi
void **v3; // rbx

v2 = *(void **)ptr;
if ( v2 )
{
v3 = (void **)((char *)ptr + 8);
do
{
freePacket(v2);
v2 = *v3++;
}
while ( v2 );
}
free(ptr);
}

canonical_decompiled_code:
void __fastcall func20(void *ptr)
{
void *v2; // rdi
void **v3; // rbx

v2 = *(void **)ptr;
if ( v2 )
{
v3 = (void **)((char *)ptr + 8);
do
{
func19(v2);
v2 = *v3++;
}
while ( v2 );
}
free(ptr);
}

original_code:
void freePackets(byte_t **pkts)
{
 int i = 0;
 for(i = 0; pkts[i] != 0; i++)
 {
  freePacket(pkts[i]);
 }
 free(pkts);
}

canonical_original_code:
void freePackets(unsigned char **pkts)
{
 int i = 0;
 for(i = 0; pkts[i] != 0; i++)
 {
  freePacket(pkts[i]);
 }
 free(pkts);
}

variable_types:
pkts
unsigned char **


bufToPackets

decompiled_code:
char *__fastcall bufToPackets(_QWORD *a1, unsigned int a2, int a3)
{
unsigned int v3; // ebp
unsigned int v4; // er13
char *v5; // rax
char *v6; // r14
char *v7; // r12
char *v8; // r15
_QWORD *v9; // r15
__int64 v10; // rbx
unsigned __int8 *v11; // rdi
unsigned int v12; // er12
unsigned __int8 *v13; // rdi
_QWORD *v15; // [rsp-10h] [rbp-58h]
_QWORD *v16; // [rsp-10h] [rbp-58h]
unsigned int v18; // [rsp+Ch] [rbp-3Ch]

if ( !a1 )
return 0LL;
v3 = a2;
v4 = (a2 + 1011) / 0x3F4;
v5 = (char *)calloc(8LL * (int)(v4 + 1), 1uLL);
v6 = v5;
if ( a2 + 1011 > 0x3F3 )
{
v7 = v5;
v8 = &v5[8 * v4];
do
{
v7 += 8;
*((_QWORD *)v7 - 1) = calloc(0x400uLL, 1uLL);
}
while ( v7 != v8 );
v9 = a1;
v10 = 0LL;
v18 = 2 * a3;
do
{
while ( 1 )
{
v12 = ((_DWORD)v10 << 10) % v18;
printf("bufToPackets: seqNum=%d\n", v12);
if ( v3 > 0x3F3 )
break;
v11 = *(unsigned __int8 **)&v6[8 * v10];
v15 = v9;
++v10;
v3 = 0;
v9 = (_QWORD *)((char *)v9 + 1012);
generatePacket(v11, v12, v12, 0LL, 1LL, 0LL, v15);
if ( v10 == v4 )
return v6;
}
v13 = *(unsigned __int8 **)&v6[8 * v10];
v16 = v9;
++v10;
v3 -= 1012;
v9 = (_QWORD *)((char *)v9 + 1012);
generatePacket(v13, v12, v12, 0LL, 0LL, 0LL, v16);
}
while ( v10 != v4 );
}
return v6;
}

original_code:
byte_t** bufToPackets(byte_t * buf, uint32_t nbytes, uint32_t c_wnd)
{
 int numPackets = 0;
 int i = 0;
 byte_t **packetArray = ((void *)0);
 if(buf == ((void *)0)){
  return ((void *)0);
 }
 numPackets = (nbytes+(1012 -1))/1012;
 packetArray = (byte_t**)malloc(sizeof(byte_t*) * (numPackets+1));
 memset(packetArray, 0, sizeof(byte_t*)*(numPackets+1));
 for(i = 0; i < numPackets; i++){
  packetArray[i] = (byte_t*)malloc(sizeof(byte_t) * (1024));
  memset(packetArray[i], '\0', sizeof(byte_t)*(1024));
 }
 for(i = 0; i < numPackets; i++){
  int pieceLen = 1012;
  int seqNum = (i*1024)%(2*c_wnd);
  printf("bufToPackets: seqNum=%d\n", seqNum);
  if(nbytes < 1012)
  {
   pieceLen = nbytes;
   nbytes = 0;
   generatePacket(packetArray[i], seqNum,seqNum,0,1,0,&(buf[i*1012]), pieceLen);
  }
  else{
   nbytes -= 1012;
   generatePacket(packetArray[i], seqNum,seqNum,0,0,0,&(buf[i*1012]), pieceLen);
  }
 }
 return packetArray;
}

canonical_original_code:
unsigned char **bufToPackets(unsigned char *buf, unsigned int nbytes, unsigned int c_wnd)
{
 int numPackets = 0;
 int i = 0;
 unsigned char **packetArray = ((void *)0);
 if(buf == ((void *)0)){
  return ((void *)0);
 }
 numPackets = (nbytes+(1012 -1))/1012;
 packetArray = (unsigned char **)malloc(sizeof(unsigned char *) * (numPackets+1));
 memset(packetArray, 0, sizeof(unsigned char *)*(numPackets+1));
 for(i = 0; i < numPackets; i++){
  packetArray[i] = (unsigned char *)malloc(sizeof(byte_t) * (1024));
  memset(packetArray[i], '\0', sizeof(byte_t)*(1024));
 }
 for(i = 0; i < numPackets; i++){
  int pieceLen = 1012;
  int seqNum = (i*1024)%(2*c_wnd);
  printf("bufToPackets: seqNum=%d\n", seqNum);
  if(nbytes < 1012)
  {
   pieceLen = nbytes;
   nbytes = 0;
   generatePacket(packetArray[i], seqNum,seqNum,0,1,0,&(buf[i*1012]), pieceLen);
  }
  else{
   nbytes -= 1012;
   generatePacket(packetArray[i], seqNum,seqNum,0,0,0,&(buf[i*1012]), pieceLen);
  }
 }
 return packetArray;
}

variable_types:
buf
unsigned char *

variable_types:
nbytes
unsigned int

variable_types: numPackets int

variable_types:
packetArray
unsigned char **

variable_types: pieceLen int

variable_types: seqNum int

return_type: unsigned char **


seed

decompiled_code:
void seed()
{
unsigned int v0; // eax

v0 = time(0LL);
srand(v0);
}

canonical_decompiled_code:
void func0()
{
unsigned int v0; // eax

v0 = time(0LL);
srand(v0);
}

original_code:
void seed(){
 srand(time(((void *)0)));
}


decompiled_code:
bool __fastcall p_check(double a1)
{
if ( a1 < 0.0 || a1 > 1.0 )
_assert_fail("probability >= 0 && probability <= 1", "probability.c", 0x12u, "p_check");
return (double)rand() / 2147483647.0 <= a1;
}

canonical_decompiled_code:
bool __fastcall func1(double a1)
{
if ( a1 < 0.0 || a1 > 1.0 )
_assert_fail("probability >= 0 && probability <= 1", "probability.c", 0x12u, "p_check");
return (double)rand() / 2147483647.0 <= a1;
}

original_code:
_Bool p_check(double probability) {
 double p_val;
 ((void) sizeof ((probability >= 0 && probability <= 1) ? 1 : 0), __extension__ ({ if (probability >= 0 && probability <= 1) ; else __assert_fail ("probability >= 0 && probability <= 1", "probability.c", 18, __extension__ __PRETTY_FUNCTION__); }));
 p_val = rand()/(double)2147483647;
 if(p_val > probability){
  return 0;
 }
 else
  return 1;
}

variable_types: probability double


error

decompiled_code:
void __fastcall __noreturn error(const char *a1)
{
perror(a1);
exit(1);
}

canonical_decompiled_code:
void __fastcall __noreturn func2(const char *a1)
{
perror(a1);
exit(1);
}

original_code:
void error(char *msg)
{
    perror(msg);
    exit(1);
}

variable_types:
msg
char *


decompiled_code:
int __fastcall print_user_prompt(const char *a1)
{
printf("%s", a1);
return fflush(_bss_start);
}

canonical_decompiled_code:
int __fastcall func7(const char *a1)
{
printf("%s", a1);
return fflush(_bss_start);
}

original_code:
void print_user_prompt(char * prompt) {
  printf( "%s", prompt );
  fflush( stdout );
}

canonical_original_code:
void print_user_prompt(char *prompt) {
  printf( "%s", prompt );
  fflush( stdout );
}

variable_types:
prompt
char *


repo: centaurean/density

original_code:
inline __attribute__((always_inline)) void density_lion_form_model_init(density_lion_form_data *const data) {
    density_lion_form_node *rank_0 = &data->formsPool[0];
    rank_0->form = DENSITY_LION_FORM_PLAIN;
    rank_0->rank = 0;
    rank_0->previousForm = ((void *)0);
    data->formsIndex[DENSITY_LION_FORM_PLAIN] = rank_0;
    density_lion_form_node *rank_1 = &data->formsPool[1];
    rank_1->form = DENSITY_LION_FORM_DICTIONARY_A;
    rank_1->rank = 1;
    rank_1->previousForm = rank_0;
    data->formsIndex[DENSITY_LION_FORM_DICTIONARY_A] = rank_1;
    density_lion_form_node *rank_2 = &data->formsPool[2];
    rank_2->form = DENSITY_LION_FORM_DICTIONARY_B;
    rank_2->rank = 2;
    rank_2->previousForm = rank_1;
    data->formsIndex[DENSITY_LION_FORM_DICTIONARY_B] = rank_2;
    density_lion_form_node *rank_3 = &data->formsPool[3];
    rank_3->form = DENSITY_LION_FORM_PREDICTIONS_A;
    rank_3->rank = 3;
    rank_3->previousForm = rank_2;
    data->formsIndex[DENSITY_LION_FORM_PREDICTIONS_A] = rank_3;
    density_lion_form_node *rank_4 = &data->formsPool[4];
    rank_4->form = DENSITY_LION_FORM_PREDICTIONS_B;
    rank_4->rank = 4;
    rank_4->previousForm = rank_3;
    data->formsIndex[DENSITY_LION_FORM_PREDICTIONS_B] = rank_4;
    density_lion_form_node *rank_5 = &data->formsPool[5];
    rank_5->form = DENSITY_LION_FORM_DICTIONARY_C;
    rank_5->rank = 5;
    rank_5->previousForm = rank_4;
    data->formsIndex[DENSITY_LION_FORM_DICTIONARY_C] = rank_5;
    density_lion_form_node *rank_6 = &data->formsPool[6];
    rank_6->form = DENSITY_LION_FORM_PREDICTIONS_C;
    rank_6->rank = 6;
    rank_6->previousForm = rank_5;
    data->formsIndex[DENSITY_LION_FORM_PREDICTIONS_C] = rank_6;
    density_lion_form_node *rank_7 = &data->formsPool[7];
    rank_7->form = DENSITY_LION_FORM_DICTIONARY_D;
    rank_7->rank = 7;
    rank_7->previousForm = rank_6;
    data->formsIndex[DENSITY_LION_FORM_DICTIONARY_D] = rank_7;
    data->usages.usages_as_uint64_t = 0;
}

canonical_original_code:
inline void density_lion_form_model_init(struct density_lion_form_data *data) {
    struct density_lion_form_node *rank_0 = &data->formsPool[0];
    rank_0->form = DENSITY_LION_FORM_PLAIN;
    rank_0->rank = 0;
    rank_0->previousForm = ((void *)0);
    data->formsIndex[DENSITY_LION_FORM_PLAIN] = rank_0;
    struct density_lion_form_node *rank_1 = &data->formsPool[1];
    rank_1->form = DENSITY_LION_FORM_DICTIONARY_A;
    rank_1->rank = 1;
    rank_1->previousForm = rank_0;
    data->formsIndex[DENSITY_LION_FORM_DICTIONARY_A] = rank_1;
    struct density_lion_form_node *rank_2 = &data->formsPool[2];
    rank_2->form = DENSITY_LION_FORM_DICTIONARY_B;
    rank_2->rank = 2;
    rank_2->previousForm = rank_1;
    data->formsIndex[DENSITY_LION_FORM_DICTIONARY_B] = rank_2;
    struct density_lion_form_node *rank_3 = &data->formsPool[3];
    rank_3->form = DENSITY_LION_FORM_PREDICTIONS_A;
    rank_3->rank = 3;
    rank_3->previousForm = rank_2;
    data->formsIndex[DENSITY_LION_FORM_PREDICTIONS_A] = rank_3;
    struct density_lion_form_node *rank_4 = &data->formsPool[4];
    rank_4->form = DENSITY_LION_FORM_PREDICTIONS_B;
    rank_4->rank = 4;
    rank_4->previousForm = rank_3;
    data->formsIndex[DENSITY_LION_FORM_PREDICTIONS_B] = rank_4;
    struct density_lion_form_node *rank_5 = &data->formsPool[5];
    rank_5->form = DENSITY_LION_FORM_DICTIONARY_C;
    rank_5->rank = 5;
    rank_5->previousForm = rank_4;
    data->formsIndex[DENSITY_LION_FORM_DICTIONARY_C] = rank_5;
    struct density_lion_form_node *rank_6 = &data->formsPool[6];
    rank_6->form = DENSITY_LION_FORM_PREDICTIONS_C;
    rank_6->rank = 6;
    rank_6->previousForm = rank_5;
    data->formsIndex[DENSITY_LION_FORM_PREDICTIONS_C] = rank_6;
    struct density_lion_form_node *rank_7 = &data->formsPool[7];
    rank_7->form = DENSITY_LION_FORM_DICTIONARY_D;
    rank_7->rank = 7;
    rank_7->previousForm = rank_6;
    data->formsIndex[DENSITY_LION_FORM_DICTIONARY_D] = rank_7;
    data->usages.usages_as_uint64_t = 0;
}

variable_types: struct density_lion_form_data { union { unsigned char usages_as_uint8_t[8]; unsigned long usages_as_uint64_t; } usages; void (*attachments[8])(unsigned char **, unsigned char **, unsigned long *, void *, unsigned short *, unsigned int *); struct density_lion_form_node { void *previousForm; enum DENSITY_LION_FORM { DENSITY_LION_FORM_PREDICTIONS_A=0, DENSITY_LION_FORM_PREDICTIONS_B=1, DENSITY_LION_FORM_PREDICTIONS_C=2, DENSITY_LION_FORM_DICTIONARY_A=3, DENSITY_LION_FORM_DICTIONARY_B=4, DENSITY_LION_FORM_DICTIONARY_C=5, DENSITY_LION_FORM_DICTIONARY_D=6, DENSITY_LION_FORM_PLAIN=7 } form; unsigned char rank; } formsPool[8]; struct density_lion_form_node *formsIndex[8]; unsigned char nextAvailableForm; } *

variable_types: struct density_lion_form_node { void *previousForm; enum DENSITY_LION_FORM { DENSITY_LION_FORM_PREDICTIONS_A=0, DENSITY_LION_FORM_PREDICTIONS_B=1, DENSITY_LION_FORM_PREDICTIONS_C=2, DENSITY_LION_FORM_DICTIONARY_A=3, DENSITY_LION_FORM_DICTIONARY_B=4, DENSITY_LION_FORM_DICTIONARY_C=5, DENSITY_LION_FORM_DICTIONARY_D=6, DENSITY_LION_FORM_PLAIN=7 } form; unsigned char rank; } *

user_defined_types: struct density_lion_form_data { union { unsigned char usages_as_uint8_t[8]; unsigned long usages_as_uint64_t; } usages; void (*attachments[8])(unsigned char **, unsigned char **, unsigned long *, void *, unsigned short *, unsigned int *); struct density_lion_form_node formsPool[8]; struct density_lion_form_node *formsIndex[8]; unsigned char nextAvailableForm; }

user_defined_types: struct density_lion_form_node { void *previousForm; enum DENSITY_LION_FORM form; unsigned char rank; }


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

for ( result = 0LL; result != 64; result += 8LL )
*(_QWORD *)(a1 + result + 8) = *(_QWORD *)(a2 + result);
return result;
}

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

for ( result = 0LL; result != 64; result += 8LL )
*(_QWORD *)(a1 + result + 8) = *(_QWORD *)(a2 + result);
return result;
}

original_code:
inline __attribute__((always_inline)) void density_lion_form_model_attach(density_lion_form_data *const data, void (*attachments[8])(const uint8_t **, uint8_t **, uint_fast16_t *, void *const, uint16_t *const, uint32_t *const)) {
    for(uint_fast8_t count = 0; count < 8; count ++)
        data->attachments[count] = attachments[count];
}

canonical_original_code:
inline void density_lion_form_model_attach(struct density_lion_form_data *data, void (*attachments[8])(unsigned char **, unsigned char **, unsigned long *, void *, unsigned short *, unsigned int *)) {
    for(unsigned char count = 0; count < 8; count ++)
        data->attachments[count] = attachments[count];
}

variable_types: void (*[8])(unsigned char **, unsigned char **, unsigned long *, void *, unsigned short *, unsigned int *)

variable_types:
count
unsigned char

user_defined_types: enum DENSITY_LION_FORM { DENSITY_LION_FORM_PREDICTIONS_A=0, DENSITY_LION_FORM_PREDICTIONS_B=1, DENSITY_LION_FORM_PREDICTIONS_C=2, DENSITY_LION_FORM_DICTIONARY_A=3, DENSITY_LION_FORM_DICTIONARY_B=4, DENSITY_LION_FORM_DICTIONARY_C=5, DENSITY_LION_FORM_DICTIONARY_D=6, DENSITY_LION_FORM_PLAIN=7 }