decompiled_code:
__int64 __fastcall hexchar_to_bin(char *a1)
{
char *v1; // rsi
unsigned int v2; // edx
int v3; // eax
char v4; // al

v1 = a1 + 2;
v2 = 0;
do
{
v4 = *a1++;
if ( (unsigned __int8)(v4 - 48) > 9u )
{
if ( (unsigned __int8)(v4 - 97) > 5u )
{
if ( (unsigned __int8)(v4 - 65) > 5u )
{
printf(
"[ERROR @ %s] unable to convert %c%c to hex\n",
"hexchar_to_bin",
(unsigned int)*a1,
(unsigned int)a1[1]);
return 0LL;
}
v3 = v4 - 55;
}
else
{
v3 = v4 - 87;
}
}
else
{
v3 = v4 - 48;
}
v2 = v3 + 16 * v2;
}
while ( a1 != v1 );
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func0(char *a1)
{
char *v1; // rsi
unsigned int v2; // edx
int v3; // eax
char v4; // al

v1 = a1 + 2;
v2 = 0;
do
{
v4 = *a1++;
if ( (unsigned __int8)(v4 - 48) > 9u )
{
if ( (unsigned __int8)(v4 - 97) > 5u )
{
if ( (unsigned __int8)(v4 - 65) > 5u )
{
printf(
"[ERROR @ %s] unable to convert %c%c to hex\n",
"hexchar_to_bin",
(unsigned int)*a1,
(unsigned int)a1[1]);
return 0LL;
}
v3 = v4 - 55;
}
else
{
v3 = v4 - 87;
}
}
else
{
v3 = v4 - 48;
}
v2 = v3 + 16 * v2;
}
while ( a1 != v1 );
return v2;
}

original_code:
unsigned char hexchar_to_bin(const char *s)
{
    int ret = 0;
    int i;
    for(i = 0; i < 2; i++)
    {
        char c = *s++;
        int n = 0;
        if ('0' <= c && c <= '9')
            n = c - '0';
        else if ('a' <=c && c<='f')
            n = 10 + c - 'a';
        else if('A' <=c && c <= 'F')
            n = 10 + c - 'A';
        else
        {
            printf("[ERROR @ %s] unable to convert %c%c to hex\n", __func__, *(s), *(s+1));
            return 0;
        }
        ret = n + ret * 16;
    }
    return ret;
}

canonical_original_code:
unsigned char hexchar_to_bin(char *s)
{
    int ret = 0;
    int i;
    for(i = 0; i < 2; i++)
    {
        char c = *s++;
        int n = 0;
        if ('0' <= c && c <= '9')
            n = c - '0';
        else if ('a' <=c && c<='f')
            n = 10 + c - 'a';
        else if('A' <=c && c <= 'F')
            n = 10 + c - 'A';
        else
        {
            printf("[ERROR @ %s] unable to convert %c%c to hex\n", __func__, *(s), *(s+1));
            return 0;
        }
        ret = n + ret * 16;
    }
    return ret;
}

variable_types:
s
char *

variable_types: c char

variable_types: n int

return_type: unsigned char


decompiled_code:
__int64 __fastcall convert_hex_string_to_bin(void *src, _DWORD *a2)
{
unsigned int v2; // eax
unsigned int v3; // ebx
unsigned int v4; // er13
int v5; // ebx
char *v6; // rbp
unsigned int v7; // er13
int v8; // ebx
int v9; // eax
__int64 result; // rax
char v11; // [rsp+5h] [rbp-33h] BYREF
char dest[50]; // [rsp+6h] [rbp-32h] BYREF

v2 = strlen((const char *)src);
v3 = v2;
v4 = v2 - 3;
if ( v2 - 3 > 7 )
{
printf("[ERROR @ %s] input string length (%d) is not valid\n", "convert_hex_string_to_bin", v2);
result = 0xFFFFFFFFLL;
}
else if ( *(_BYTE *)src == 48 && (*((_BYTE *)src + 1) & 0xDF) == 88 )
{
memcpy(dest, src, (int)v2);
if ( (v3 & 1) != 0 )
dest[1] = 48;
*a2 = 0;
v5 = v3 - 1;
if ( v5 <= 1 )
{
result = 0LL;
}
else
{
v6 = &v11 + v5;
v7 = v4 & 0xFFFFFFFE;
v8 = 0;
do
{
*a2 |= (unsigned __int8)hexchar_to_bin(v6) << (8 * (v8 / 2));
v9 = v8;
v8 += 2;
v6 -= 2;
}
while ( v9 != v7 );
result = 0LL;
}
}
else
{
printf(
"[ERROR @ %s] hex string identifier (leading 0x) not found in string %s...\n",
"convert_hex_string_to_bin",
(const char *)src);
result = 0xFFFFFFFFLL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(void *src, _DWORD *a2)
{
unsigned int v2; // eax
unsigned int v3; // ebx
unsigned int v4; // er13
int v5; // ebx
char *v6; // rbp
unsigned int v7; // er13
int v8; // ebx
int v9; // eax
__int64 result; // rax
char v11; // [rsp+5h] [rbp-33h] BYREF
char dest[50]; // [rsp+6h] [rbp-32h] BYREF

v2 = strlen((const char *)src);
v3 = v2;
v4 = v2 - 3;
if ( v2 - 3 > 7 )
{
printf("[ERROR @ %s] input string length (%d) is not valid\n", "convert_hex_string_to_bin", v2);
result = 0xFFFFFFFFLL;
}
else if ( *(_BYTE *)src == 48 && (*((_BYTE *)src + 1) & 0xDF) == 88 )
{
memcpy(dest, src, (int)v2);
if ( (v3 & 1) != 0 )
dest[1] = 48;
*a2 = 0;
v5 = v3 - 1;
if ( v5 <= 1 )
{
result = 0LL;
}
else
{
v6 = &v11 + v5;
v7 = v4 & 0xFFFFFFFE;
v8 = 0;
do
{
*a2 |= (unsigned __int8)func0(v6) << (8 * (v8 / 2));
v9 = v8;
v8 += 2;
v6 -= 2;
}
while ( v9 != v7 );
result = 0LL;
}
}
else
{
printf(
"[ERROR @ %s] hex string identifier (leading 0x) not found in string %s...\n",
"convert_hex_string_to_bin",
(const char *)src);
result = 0xFFFFFFFFLL;
}
return result;
}

original_code:
int convert_hex_string_to_bin(const char *hex_string, int32_t* integer_value)
{
    const static unsigned int min_string_size_in_chars = 2 + (sizeof(int32_t) * 2) / 8;
    const static unsigned int max_string_size_in_chars = 2 + (sizeof(int32_t) * 2) / 1;
    int string_length = strlen(hex_string);
    if (string_length < min_string_size_in_chars || string_length > max_string_size_in_chars)
    {
        printf("[ERROR @ %s] input string length (%d) is not valid\n", __func__, string_length);
        return -1;
    }
    if (!(hex_string[0] == '0' && (hex_string[1] == 'x' || hex_string[1] == 'X')))
    {
        printf("[ERROR @ %s] hex string identifier (leading 0x) not found in string %s...\n", __func__, hex_string);
        return -1;
    }
    char my_string_buffer[max_string_size_in_chars];
    memcpy(my_string_buffer, hex_string, string_length);
    if (string_length % 2 != 0 )
    {
        my_string_buffer[1] = '0';
    }
    *integer_value = 0x00000000;
    int shift = 0;
    for (int i = string_length - 1; i > 1 ; i--)
    {
        i--;
        shift = (string_length - 2 - i) / 2 * 8;
        *integer_value |= hexchar_to_bin(&my_string_buffer[i]) << shift;
    }
    return 0;
}

canonical_original_code:
int convert_hex_string_to_bin(char *hex_string, int *integer_value)
{
    static unsigned int min_string_size_in_chars = 2 + (sizeof(int32_t) * 2) / 8;
    static unsigned int max_string_size_in_chars = 2 + (sizeof(int32_t) * 2) / 1;
    int string_length = strlen(hex_string);
    if (string_length < min_string_size_in_chars || string_length > max_string_size_in_chars)
    {
        printf("[ERROR @ %s] input string length (%d) is not valid\n", __func__, string_length);
        return -1;
    }
    if (!(hex_string[0] == '0' && (hex_string[1] == 'x' || hex_string[1] == 'X')))
    {
        printf("[ERROR @ %s] hex string identifier (leading 0x) not found in string %s...\n", __func__, hex_string);
        return -1;
    }
    char my_string_buffer[-1];
    memcpy(my_string_buffer, hex_string, string_length);
    if (string_length % 2 != 0 )
    {
        my_string_buffer[1] = '0';
    }
    *integer_value = 0x00000000;
    int shift = 0;
    for (int i = string_length - 1; i > 1 ; i--)
    {
        i--;
        shift = (string_length - 2 - i) / 2 * 8;
        *integer_value |= hexchar_to_bin(&my_string_buffer[i]) << shift;
    }
    return 0;
}

variable_types: shift int

variable_types: i int

return_type: int


decompiled_code:
int __fastcall print_n_spaces(int a1)
{
int i; // ebx
int result; // eax

if ( a1 > 0 )
{
for ( i = 0; i != a1; ++i )
result = putchar(32);
}
return result;
}

canonical_decompiled_code:
int __fastcall func2(int a1)
{
int i; // ebx
int result; // eax

if ( a1 > 0 )
{
for ( i = 0; i != a1; ++i )
result = putchar(32);
}
return result;
}

original_code:
void print_n_spaces(int n)
{
    for (int i = 0; i < n; i++)
    {
        printf(" ");
    }
}

return_type: void


decompiled_code:
int global_increment_module2()
{
int result; // eax

result = printf("[%s] increment global_value...\n", "global_increment_module2");
++global_value;
return result;
}

canonical_decompiled_code:
int func0()
{
int result; // eax

result = printf("[%s] increment global_value...\n", "global_increment_module2");
++global_value;
return result;
}

original_code:
void global_increment_module2(void)
{
    printf("[%s] increment global_value...\n", __func__);
    global_value++;
}

canonical_original_code:
void global_increment_module2()
{
    printf("[%s] increment global_value...\n", __func__);
    global_value++;
}


decompiled_code:
int global_print_address_module2()
{
return printf("[%s] global_value address: %p\n", "global_print_address_module2", &global_value);
}

canonical_decompiled_code:
int func1()
{
return printf("[%s] global_value address: %p\n", "global_print_address_module2", &global_value);
}

original_code:
void global_print_address_module2(void)
{
    printf("[%s] global_value address: %p\n", __func__, &global_value);
}

canonical_original_code:
void global_print_address_module2()
{
    printf("[%s] global_value address: %p\n", __func__, &global_value);
}


decompiled_code:
int global_print_module2()
{
return printf("[%s] global_value is %d\n", "global_print_module2", (unsigned int)global_value);
}

canonical_decompiled_code:
int func2()
{
return printf("[%s] global_value is %d\n", "global_print_module2", (unsigned int)global_value);
}

original_code:
void global_print_module2(void)
{
    printf("[%s] global_value is %d\n", __func__, global_value);
}

canonical_original_code:
void global_print_module2()
{
    printf("[%s] global_value is %d\n", __func__, global_value);
}


decompiled_code:
int global_increment_module1()
{
int result; // eax

result = printf("[%s] increment global_value...\n", "global_increment_module1");
++global_value;
return result;
}

canonical_decompiled_code:
int func0()
{
int result; // eax

result = printf("[%s] increment global_value...\n", "global_increment_module1");
++global_value;
return result;
}

original_code:
void global_increment_module1(void)
{
    printf("[%s] increment global_value...\n", __func__);
    global_value++;
}

canonical_original_code:
void global_increment_module1()
{
    printf("[%s] increment global_value...\n", __func__);
    global_value++;
}


decompiled_code:
int global_print_address_module1()
{
return printf("[%s] global_value address: %p\n", "global_print_address_module1", &global_value);
}

canonical_decompiled_code:
int func1()
{
return printf("[%s] global_value address: %p\n", "global_print_address_module1", &global_value);
}

original_code:
void global_print_address_module1(void)
{
    printf("[%s] global_value address: %p\n", __func__, &global_value);
}

canonical_original_code:
void global_print_address_module1()
{
    printf("[%s] global_value address: %p\n", __func__, &global_value);
}


decompiled_code:
int global_print_module1()
{
return printf("[%s] global_value is %d\n", "global_print_module1", (unsigned int)global_value);
}

canonical_decompiled_code:
int func2()
{
return printf("[%s] global_value is %d\n", "global_print_module1", (unsigned int)global_value);
}

original_code:
void global_print_module1(void)
{
    printf("[%s] global_value is %d\n", __func__, global_value);
}

canonical_original_code:
void global_print_module1()
{
    printf("[%s] global_value is %d\n", __func__, global_value);
}


original_code:
void this_row(direction_s d)
{
    printf( d.left ? "*..\n"
            : d.right ? "..*\n"
            : ".*.\n");
}

canonical_original_code:
void this_row(struct direction_s d)
{
    printf( d.left ? "*..\n"
            : d.right ? "..*\n"
            : ".*.\n");
}

variable_types: struct direction_s { char *name; int left; int right; int up; int down; }


original_code:
void draw_box(direction_s d)
{
    printf("%s:\n", (d.name ? d.name : "a box"));
    d.up ? this_row(d) : printf("...\n");
    (!d.up && !d.down) ? this_row(d) : printf("...\n");
    d.down ? this_row(d) : printf("...\n");
    printf("\n");
}

canonical_original_code:
void draw_box(struct direction_s d)
{
    printf("%s:\n", (d.name ? d.name : "a box"));
    d.up ? this_row(d) : printf("...\n");
    (!d.up && !d.down) ? this_row(d) : printf("...\n");
    d.down ? this_row(d) : printf("...\n");
    printf("\n");
}

user_defined_types: struct direction_s { char *name; int left; int right; int up; int down; }


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int64 v3; // rdx
__int64 v4; // rcx
__int64 v5; // r8
__int64 v6; // r9
__int64 v7; // rdx
__int64 v8; // rcx
__int64 v9; // r8
__int64 v10; // r9
__int64 v11; // rdx
__int64 v12; // rcx
__int64 v13; // r8
__int64 v14; // r9

printf("[%s] hello world\n", "main");
draw_box((__int64)"[%s] hello world\n", (__int64)"main", v3, v4, v5, v6, "left", 1LL, 0LL);
draw_box((__int64)"[%s] hello world\n", (__int64)"main", v7, v8, v9, v10, "upper right", 0x100000000LL, 1LL);
draw_box((__int64)"[%s] hello world\n", (__int64)"main", v11, v12, v13, v14, 0LL, 0LL, 0LL);
return 0;
}

original_code:
int main(void)
{
    printf("[%s] hello world\n", __func__);
    direction_s D = {.name = "left", .left = 1};
    draw_box(D);
    D = (direction_s){"upper right", .up = 1, .right = 1};
    draw_box(D);
    draw_box((direction_s){});
    return 0;
}

canonical_original_code:
int main()
{
    printf("[%s] hello world\n", __func__);
    struct direction_s D = {.name = "left", .left = 1};
    draw_box(D);
    D = (struct direction_s){"upper right", .up = 1, .right = 1};
    draw_box(D);
    draw_box((struct direction_s){});
    return 0;
}


decompiled_code:
int __fastcall set_struct_aerConfig_s_int_data(__int64 a1, const char *a2, int a3)
{
__int64 v4; // rbx
int result; // eax

v4 = 0LL;
while ( 1 )
{
result = strcmp((&m_struct_aerConfig_s_field_reflection)[2 * v4], a2);
if ( !result )
break;
if ( ++v4 == 9 )
{
printf("[ERROR @ %s] key not found in reflection, check configuration!\n", "set_struct_aerConfig_s_int_data");
return -1;
}
}
*(_DWORD *)&(&m_struct_aerConfig_s_field_reflection)[2 * (int)v4 + 1][a1] = a3;
return result;
}

canonical_decompiled_code:
int __fastcall func0(__int64 a1, const char *a2, int a3)
{
__int64 v4; // rbx
int result; // eax

v4 = 0LL;
while ( 1 )
{
result = strcmp((&m_struct_aerConfig_s_field_reflection)[2 * v4], a2);
if ( !result )
break;
if ( ++v4 == 9 )
{
printf("[ERROR @ %s] key not found in reflection, check configuration!\n", "set_struct_aerConfig_s_int_data");
return -1;
}
}
*(_DWORD *)&(&m_struct_aerConfig_s_field_reflection)[2 * (int)v4 + 1][a1] = a3;
return result;
}

original_code:
int set_struct_aerConfig_s_int_data(void* p_aerConfig, const char* key, int32_t value)
{
    int i;
    uint8_t found_flag = 0;
    for (i = 0; i < sizeof(m_struct_aerConfig_s_field_reflection) / sizeof(struct_field); i++)
    {
        if (strcmp(m_struct_aerConfig_s_field_reflection[i].field_name, key) == 0)
        {
            *(int *)(p_aerConfig + m_struct_aerConfig_s_field_reflection[i].field_offset) = value;
            found_flag = 1;
            break;
        }
        if (found_flag)
        {
            break;
        }
    }
    if (!found_flag)
    {
        printf("[ERROR @ %s] key not found in reflection, check configuration!\n", __func__);
        return -1;
    }
    return 0;
}

canonical_original_code:
int set_struct_aerConfig_s_int_data(void *p_aerConfig, char *key, int value)
{
    int i;
    unsigned char found_flag = 0;
    for (i = 0; i < sizeof(m_struct_aerConfig_s_field_reflection) / sizeof(struct_field); i++)
    {
        if (strcmp(m_struct_aerConfig_s_field_reflection[i].field_name, key) == 0)
        {
            *(int *)(p_aerConfig + m_struct_aerConfig_s_field_reflection[i].field_offset) = value;
            found_flag = 1;
            break;
        }
        if (found_flag)
        {
            break;
        }
    }
    if (!found_flag)
    {
        printf("[ERROR @ %s] key not found in reflection, check configuration!\n", __func__);
        return -1;
    }
    return 0;
}

variable_types:
key
char *

variable_types: value int


decompiled_code:
__int64 __fastcall print_struct_aerConfig_s(__int64 a1)
{
const char **v1; // rbx
unsigned int v2; // ebp
int v3; // eax

print_default_struct_header(a1, "aerConfig_s");
v1 = (const char **)&m_struct_aerConfig_s_field_reflection;
do
{
v2 = *(_DWORD *)&v1[1][a1];
printf("# * %s:", *v1);
v3 = strlen(*v1);
print_n_spaces((unsigned int)(32 - v3));
printf("0X%08X, %d\n", v2, v2);
v1 += 2;
}
while ( v1 != (const char **)(unsigned int)((_DWORD)&m_struct_aerConfig_s_field_reflection + 144) );
return print_default_struct_footer();
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1)
{
const char **v1; // rbx
unsigned int v2; // ebp
int v3; // eax

print_default_struct_header(a1, "aerConfig_s");
v1 = (const char **)&m_struct_aerConfig_s_field_reflection;
do
{
v2 = *(_DWORD *)&v1[1][a1];
printf("# * %s:", *v1);
v3 = strlen(*v1);
print_n_spaces((unsigned int)(32 - v3));
printf("0X%08X, %d\n", v2, v2);
v1 += 2;
}
while ( v1 != (const char **)(unsigned int)((_DWORD)&m_struct_aerConfig_s_field_reflection + 144) );
return print_default_struct_footer();
}

original_code:
void print_struct_aerConfig_s(struct aerConfig_s* p_aerConfig)
{
    print_default_struct_header(p_aerConfig, "aerConfig_s");
    void* struct_address = (void*) p_aerConfig;
    int32_t int_value;
    for (int i = 0; i < sizeof(m_struct_aerConfig_s_field_reflection) / sizeof(struct_field); i++)
    {
        int_value = *((int32_t *)(((uint8_t*) struct_address) + m_struct_aerConfig_s_field_reflection[i].field_offset));
        printf("# * %s:", m_struct_aerConfig_s_field_reflection[i].field_name);
        print_n_spaces(32 - strlen(m_struct_aerConfig_s_field_reflection[i].field_name));
        printf("0X%08X, %d\n", int_value, int_value);
    }
    print_default_struct_footer();
}

canonical_original_code:
void print_struct_aerConfig_s(struct aerConfig_s *p_aerConfig)
{
    print_default_struct_header(p_aerConfig, "aerConfig_s");
    void *struct_address = (void*) p_aerConfig;
    int int_value;
    for (int i = 0; i < sizeof(m_struct_aerConfig_s_field_reflection) / sizeof(struct_field); i++)
    {
        int_value = *((int *)(((unsigned char *) struct_address) + m_struct_aerConfig_s_field_reflection[i].field_offset));
        printf("# * %s:", m_struct_aerConfig_s_field_reflection[i].field_name);
        print_n_spaces(32 - strlen(m_struct_aerConfig_s_field_reflection[i].field_name));
        printf("0X%08X, %d\n", int_value, int_value);
    }
    print_default_struct_footer();
}

variable_types: struct aerConfig_s { unsigned int reset_bitfield; unsigned int valid_bitfield; int y2x_delay; unsigned int srate_bitfield; int tail_length; int delay_tx_ag_chg; int delay_rx_ag_chg; int num_samp_interp; int phone_mode; } *


decompiled_code:
int say_std_hello()
{
return printf("hello from %s\n", "say_std_hello");
}

canonical_decompiled_code:
int func0()
{
return printf("hello from %s\n", "say_std_hello");
}

original_code:
void say_std_hello(void)
{
    printf("hello from %s\n", __func__);
}

canonical_original_code:
void say_std_hello()
{
    printf("hello from %s\n", __func__);
}


removeUser

decompiled_code:
__int64 __fastcall removeUser(int a1)
{
return removeLine(usersFilename, a1);
}

canonical_decompiled_code:
__int64 __fastcall func4(int a1)
{
return func0(usersFilename, a1);
}

original_code:
int removeUser(int targetID) {
 return removeLine(usersFilename, targetID);
}

variable_types: targetID int


updateBalance

decompiled_code:
__int64 __fastcall updateBalance(int a1, unsigned int a2)
{
if ( !getUser(a1) )
return 0xFFFFFFFFLL;
removeUser(a1);
return (unsigned int)-((unsigned int)addUser(a1, a2) == -1);
}

canonical_decompiled_code:
__int64 __fastcall func6(int a1, unsigned int a2)
{
if ( !func3(a1) )
return 0xFFFFFFFFLL;
func4(a1);
return (unsigned int)-((unsigned int)func5(a1, a2) == -1);
}

original_code:
int updateBalance(int userid, int balance) {
 USER *user = getUser(userid);
 if(user == ((void *)0)) return -1;
 removeUser(userid);
 if(addUser(userid, balance) == -1) return -1;
 return 0;
}

canonical_original_code:
int updateBalance(int userid, int balance) {
 struct USER *user = getUser(userid);
 if(user == ((void *)0)) return -1;
 removeUser(userid);
 if(addUser(userid, balance) == -1) return -1;
 return 0;
}

variable_types: userid int

variable_types: balance int

variable_types:
user
struct USER { int id; int balance; } *


getBalance

decompiled_code:
__int64 __fastcall getBalance(int a1)
{
char *v1; // rax
__int64 result; // rax

v1 = getUser(a1);
if ( v1 )
result = *((unsigned int *)v1 + 1);
else
result = 0xFFFFFFFFLL;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func7(int a1)
{
char *v1; // rax
__int64 result; // rax

v1 = func3(a1);
if ( v1 )
result = *((unsigned int *)v1 + 1);
else
result = 0xFFFFFFFFLL;
return result;
}

original_code:
int getBalance(int id) {
 USER *user = getUser(id);
 if(user != ((void *)0)) return user->balance;
 return -1;
}

canonical_original_code:
int getBalance(int id) {
 struct USER *user = getUser(id);
 if(user != ((void *)0)) return user->balance;
 return -1;
}

variable_types: id int


initOpenSSL

decompiled_code:
__int64 initOpenSSL()
{
OPENSSL_init_ssl(2097154LL, 0LL);
ERR_load_BIO_strings();
return OPENSSL_init_crypto(12LL, 0LL);
}

canonical_decompiled_code:
__int64 func0()
{
OPENSSL_init_ssl(2097154LL, 0LL);
ERR_load_BIO_strings();
return OPENSSL_init_crypto(12LL, 0LL);
}

original_code:
void initOpenSSL() {
 OPENSSL_init_ssl(0x00200000L | 0x00000002L, ((void *)0));
 ERR_load_BIO_strings();
 OPENSSL_init_crypto(0x00000004L | 0x00000008L, ((void *)0));
 return;
}


buildHostString

decompiled_code:
char *__fastcall buildHostString(const char *a1, const char *a2)
{
const char *v2; // rbx
int v3; // ebp
size_t v4; // r12
char *v5; // rax
char *v6; // rbp

v2 = a1;
if ( !a1 )
v2 = "127.0.0.1";
v3 = strlen(v2);
v4 = (int)(v3 + strlen(a2) + 2);
v5 = (char *)malloc(v4);
if ( !v5 )
{
fwrite("malloc() failed in buildHostString()\n", 1uLL, 0x25uLL, stderr);
exit(1);
}
v6 = v5;
snprintf(v5, v4, "%s:%s", v2, a2);
return v6;
}

canonical_decompiled_code:
char *__fastcall func1(const char *a1, const char *a2)
{
const char *v2; // rbx
int v3; // ebp
size_t v4; // r12
char *v5; // rax
char *v6; // rbp

v2 = a1;
if ( !a1 )
v2 = "127.0.0.1";
v3 = strlen(v2);
v4 = (int)(v3 + strlen(a2) + 2);
v5 = (char *)malloc(v4);
if ( !v5 )
{
fwrite("malloc() failed in buildHostString()\n", 1uLL, 0x25uLL, stderr);
exit(1);
}
v6 = v5;
snprintf(v5, v4, "%s:%s", v2, a2);
return v6;
}

original_code:
char *buildHostString(char *hostname, char *port) {
 if(hostname == ((void *)0)) hostname = "127.0.0.1";
 int numChars = strlen(hostname) + strlen(port) + 2;
 char *hostString = malloc(numChars * sizeof(char));
 if(hostString == ((void *)0)) {
  fprintf(stderr, "malloc() failed in buildHostString()\n");
  exit(1);
 }
 snprintf(hostString, numChars, "%s:%s", hostname, port);
 return hostString;
}

variable_types:
hostname
char *

variable_types:
port
char *

variable_types: numChars int

variable_types:
hostString
char *

return_type: char *


sizeOfFile

decompiled_code:
__int64 __fastcall sizeOfFile(const char *a1)
{
unsigned int v1; // ebx
struct stat v3; // [rsp+0h] [rbp-98h] BYREF

if ( stat(a1, &v3) != -1 )
return LODWORD(v3.st_size);
v1 = -1;
perror("loadFile");
return v1;
}

canonical_decompiled_code:
__int64 __fastcall func2(const char *a1)
{
unsigned int v1; // ebx
struct stat v3; // [rsp+0h] [rbp-98h] BYREF

if ( stat(a1, &v3) != -1 )
return LODWORD(v3.st_size);
v1 = -1;
perror("loadFile");
return v1;
}

original_code:
int sizeOfFile(char *filename) {
 struct stat s;
 int status = stat(filename, &s);
 if(status == -1) {
  perror("loadFile");
  return -1;
 }
 return s.st_size;
}

variable_types:
filename
char *

variable_types: struct stat { unsigned long st_dev; unsigned long st_ino; unsigned long st_nlink; unsigned int st_mode; unsigned int st_uid; unsigned int st_gid; int __pad0; unsigned long st_rdev; long st_size; long st_blksize; long st_blocks; long st_atime; unsigned long st_atimensec; long st_mtime; unsigned long st_mtimensec; long st_ctime; unsigned long st_ctimensec; long __glibc_reserved[3]; }

variable_types: status int


original_code:
int my_line_len(int i, char *buff)
{
  int mem;
  mem = i;
  if (buff != ((void *)0) && buff[i] != '\0')
    while (buff[i] != '\0' && buff[i] != '\n')
      i = i + 1;
  return (i - mem);
}

variable_types: i int

variable_types:
buff
char *

variable_types: mem int


coregnl

decompiled_code:
void *__fastcall coregnl(int a1)
{
void *v1; // rbx
int v2; // eax
void *v3; // rax

if ( !i_1 )
read(a1, buffer_0, 0x1000uLL);
v1 = 0LL;
if ( buffer_0[i_1] )
{
v2 = my_line_len(i_1, (__int64)buffer_0);
v3 = malloc(v2 + 1);
v1 = v3;
if ( v3 )
{
put_in_line((__int64)v3, (__int64)buffer_0, &i_1);
if ( i_1 > 4095 )
i_1 = 0;
}
}
return v1;
}

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

if ( !i_1 )
read(a1, buffer_0, 0x1000uLL);
v1 = 0LL;
if ( buffer_0[i_1] )
{
v2 = func1(i_1, (__int64)buffer_0);
v3 = malloc(v2 + 1);
v1 = v3;
if ( v3 )
{
func0((__int64)v3, (__int64)buffer_0, &i_1);
if ( i_1 > 4095 )
i_1 = 0;
}
}
return v1;
}

original_code:
char *coregnl(const int fd)
{
  char *line;
  int size;
  static char buffer[(4096) + 1];
  static int i;
  if (((i == 0 && (size = read(fd, buffer, (4096))) == -1) && size == 0)
      || buffer[i] == '\0')
    return (((void *)0));
  if ((line = malloc((my_line_len(i, buffer) + 1) * sizeof(char))) == ((void *)0))
    return (((void *)0));
  put_in_line(line, buffer, &i);
  if (i >= (4096))
    i = 0;
  return (line);
}

canonical_original_code:
char *coregnl(int fd)
{
  char *line;
  int size;
  static char buffer[-1];
  static int i;
  if (((i == 0 && (size = read(fd, buffer, (4096))) == -1) && size == 0)
      || buffer[i] == '\0')
    return (((void *)0));
  if ((line = malloc((my_line_len(i, buffer) + 1) * sizeof(char))) == ((void *)0))
    return (((void *)0));
  put_in_line(line, buffer, &i);
  if (i >= (4096))
    i = 0;
  return (line);
}

variable_types: fd int

variable_types:
line
char *

variable_types: size int

variable_types:
buffer
char [-1]


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
void *v3; // rbx
const char *v4; // rax
const char *v5; // rax
const char *v6; // rax
const char *v7; // rax
const char *v8; // rax
const char *v9; // rax
int v11[3]; // [rsp+Ch] [rbp-Ch] BYREF

v11[0] = 0;
v3 = malloc(0x64uLL);
BUinitGPS(0LL, 100LL);
while ( 1 )
{
puts("1. Message ID");
puts("2. Time");
puts("3. Latitude");
puts("4. Longitude");
puts("5. Number of satellites");
puts("6. Date");
_isoc99_scanf("%d", v11);
switch ( v11[0] )
{
case 1:
v4 = (const char *)getMessageID(v3);
printf("Message ID: %s\n", v4);
break;
case 2:
v5 = (const char *)getUTCTime(v3);
printf("Time: %s\n", v5);
break;
case 3:
v6 = (const char *)getLatitude(v3);
printf("Latitude: %s\n", v6);
break;
case 4:
v7 = (const char *)getLongitude(v3);
printf("Longitude: %s\n", v7);
break;
case 5:
v8 = (const char *)getSatellitesUsed(v3);
printf("Number of satellites: %s\n", v8);
break;
case 6:
v9 = (const char *)getDate(v3);
printf("Date: %s\n", v9);
break;
default:
continue;
}
}
}

original_code:
int main()
{
 char *retval;
 int choise = 0;
 retval = malloc(100);
 BUinitGPS(0, 100);
 while(1){
  printf("1. Message ID\n");
  printf("2. Time\n");
  printf("3. Latitude\n");
  printf("4. Longitude\n");
  printf("5. Number of satellites\n");
  printf("6. Date\n");
  scanf("%d", &choise);
  switch ((int)choise){
   case 1:
    printf("Message ID: %s\n", getMessageID(retval));
    break;
   case 2:
    printf("Time: %s\n", getUTCTime(retval));
    break;
   case 3:
    printf("Latitude: %s\n", getLatitude(retval));
    break;
   case 4:
    printf("Longitude: %s\n", getLongitude(retval));
    break;
   case 5:
    printf("Number of satellites: %s\n", getSatellitesUsed(retval));
    break;
   case 6:
    printf("Date: %s\n", getDate(retval));
   default:
    break;
  }
 }
 return 0;
}

variable_types:
retval
char *

variable_types: choise int


getNext

original_code:
static char *getNext(char **line, char *dest)
{
 while(**line != ',' && **line != '*' && **line != '\r'){
  *dest = **line;
  dest++;
  (*line)++;
 }
 *dest='\0';
 (*line)++;
 return *line;
}

variable_types:
line
char **

variable_types:
dest
char *


parseGPGGA

original_code:
void parseGPGGA(GPGGA *in, char *strToParse)
{
 strToParse = getNext(&strToParse, in->MessageID );
 strToParse = getNext(&strToParse, in->UTCTime );
 strToParse = getNext(&strToParse, in->Latitude );
 strToParse = getNext(&strToParse, in->NSIndicator );
 strToParse = getNext(&strToParse, in->Longitude );
 strToParse = getNext(&strToParse, in->EWIndicator );
 strToParse = getNext(&strToParse, in->PositionFixIndicator );
 strToParse = getNext(&strToParse, in->SatellitesUsed );
 strToParse = getNext(&strToParse, in->HDOP );
 strToParse = getNext(&strToParse, in->MSLAltitude );
 strToParse = getNext(&strToParse, in->MSLUnits );
 strToParse = getNext(&strToParse, in->GeoidSeparation );
 strToParse = getNext(&strToParse, in->GeoidUnits );
 strToParse = getNext(&strToParse, in->AgeOfDiffCorr );
 strToParse = getNext(&strToParse, in->DiffRefStationID );
 getNext(&strToParse, in->Checksum );
}

canonical_original_code:
void parseGPGGA(struct GPGGA *in, char *strToParse)
{
 strToParse = getNext(&strToParse, in->MessageID );
 strToParse = getNext(&strToParse, in->UTCTime );
 strToParse = getNext(&strToParse, in->Latitude );
 strToParse = getNext(&strToParse, in->NSIndicator );
 strToParse = getNext(&strToParse, in->Longitude );
 strToParse = getNext(&strToParse, in->EWIndicator );
 strToParse = getNext(&strToParse, in->PositionFixIndicator );
 strToParse = getNext(&strToParse, in->SatellitesUsed );
 strToParse = getNext(&strToParse, in->HDOP );
 strToParse = getNext(&strToParse, in->MSLAltitude );
 strToParse = getNext(&strToParse, in->MSLUnits );
 strToParse = getNext(&strToParse, in->GeoidSeparation );
 strToParse = getNext(&strToParse, in->GeoidUnits );
 strToParse = getNext(&strToParse, in->AgeOfDiffCorr );
 strToParse = getNext(&strToParse, in->DiffRefStationID );
 getNext(&strToParse, in->Checksum );
}

variable_types: struct GPGGA { char MessageID[7]; char UTCTime[11]; char Latitude[11]; char NSIndicator[2]; char Longitude[11]; char EWIndicator[2]; char PositionFixIndicator[2]; char SatellitesUsed[3]; char HDOP[5]; char MSLAltitude[4]; char MSLUnits[2]; char GeoidSeparation[4]; char GeoidUnits[2]; char AgeOfDiffCorr[8]; char DiffRefStationID[5]; char Checksum[8]; } *

variable_types:
strToParse
char *


parseGPRMC

original_code:
void parseGPRMC(GPRMC *in, char *strToParse)
{
 strToParse = getNext(&strToParse, in->RMCMessageID );
 strToParse = getNext(&strToParse, in->UTCPosition );
 strToParse = getNext(&strToParse, in->Status );
 strToParse = getNext(&strToParse, in->RMCLatitude );
 strToParse = getNext(&strToParse, in->RMCNSIndicator );
 strToParse = getNext(&strToParse, in->RMCLongitude );
 strToParse = getNext(&strToParse, in->RMCEWIndicator );
 strToParse = getNext(&strToParse, in->SpeedOverGround );
 strToParse = getNext(&strToParse, in->CourseOverGround );
 strToParse = getNext(&strToParse, in->Date );
 strToParse = getNext(&strToParse, in->MagneticVariation );
 strToParse = getNext(&strToParse, in->RMCEWIndicator );
 getNext(&strToParse, in->Checksum );
}

canonical_original_code:
void parseGPRMC(struct GPRMC *in, char *strToParse)
{
 strToParse = getNext(&strToParse, in->RMCMessageID );
 strToParse = getNext(&strToParse, in->UTCPosition );
 strToParse = getNext(&strToParse, in->Status );
 strToParse = getNext(&strToParse, in->RMCLatitude );
 strToParse = getNext(&strToParse, in->RMCNSIndicator );
 strToParse = getNext(&strToParse, in->RMCLongitude );
 strToParse = getNext(&strToParse, in->RMCEWIndicator );
 strToParse = getNext(&strToParse, in->SpeedOverGround );
 strToParse = getNext(&strToParse, in->CourseOverGround );
 strToParse = getNext(&strToParse, in->Date );
 strToParse = getNext(&strToParse, in->MagneticVariation );
 strToParse = getNext(&strToParse, in->RMCEWIndicator );
 getNext(&strToParse, in->Checksum );
}

variable_types: struct GPRMC { char RMCMessageID[7]; char UTCPosition[11]; char Status[2]; char RMCLatitude[11]; char RMCNSIndicator[2]; char RMCLongitude[11]; char RMCEWIndicator[2]; char SpeedOverGround[8]; char CourseOverGround[6]; char Date[7]; char MagneticVariation[4]; char RMCEWIndicator2[2]; char Checksum[8]; } *


getGpgga

decompiled_code:
char *__fastcall getGpgga(char *dest, int a2)
{
char v3[112]; // [rsp+0h] [rbp-E8h] BYREF
char src[7]; // [rsp+70h] [rbp-78h] BYREF
char v5[11]; // [rsp+77h] [rbp-71h] BYREF
char v6[11]; // [rsp+82h] [rbp-66h] BYREF
char v7[2]; // [rsp+8Dh] [rbp-5Bh] BYREF
char v8[11]; // [rsp+8Fh] [rbp-59h] BYREF
char v9[2]; // [rsp+9Ah] [rbp-4Eh] BYREF
char v10[2]; // [rsp+9Ch] [rbp-4Ch] BYREF
char v11[3]; // [rsp+9Eh] [rbp-4Ah] BYREF
char v12[5]; // [rsp+A1h] [rbp-47h] BYREF
char v13[4]; // [rsp+A6h] [rbp-42h] BYREF
char v14[2]; // [rsp+AAh] [rbp-3Eh] BYREF
char v15[4]; // [rsp+ACh] [rbp-3Ch] BYREF
char v16[2]; // [rsp+B0h] [rbp-38h] BYREF
char v17[8]; // [rsp+B2h] [rbp-36h] BYREF
char v18[5]; // [rsp+BAh] [rbp-2Eh] BYREF
char v19[41]; // [rsp+BFh] [rbp-29h] BYREF

pthread_mutex_lock(&GPGGAMutex);
strcpy(v3, *(const char **)GPGGA_LIST);
pthread_mutex_unlock(&GPGGAMutex);
parseGPGGA(src, v3);
switch ( a2 )
{
case 0:
strcpy(dest, src);
break;
case 1:
strcpy(dest, v5);
break;
case 2:
strcpy(dest, v6);
break;
case 3:
strcpy(dest, v7);
break;
case 4:
strcpy(dest, v8);
break;
case 5:
strcpy(dest, v9);
break;
case 6:
strcpy(dest, v10);
break;
case 7:
strcpy(dest, v11);
break;
case 8:
strcpy(dest, v12);
break;
case 9:
strcpy(dest, v13);
break;
case 10:
strcpy(dest, v14);
break;
case 11:
strcpy(dest, v15);
break;
case 12:
strcpy(dest, v16);
break;
case 13:
strcpy(dest, v17);
break;
case 14:
strcpy(dest, v18);
break;
case 15:
strcpy(dest, v19);
break;
default:
return dest;
}
return dest;
}

canonical_decompiled_code:
char *__fastcall func0(char *dest, int a2)
{
char v3[112]; // [rsp+0h] [rbp-E8h] BYREF
char src[7]; // [rsp+70h] [rbp-78h] BYREF
char v5[11]; // [rsp+77h] [rbp-71h] BYREF
char v6[11]; // [rsp+82h] [rbp-66h] BYREF
char v7[2]; // [rsp+8Dh] [rbp-5Bh] BYREF
char v8[11]; // [rsp+8Fh] [rbp-59h] BYREF
char v9[2]; // [rsp+9Ah] [rbp-4Eh] BYREF
char v10[2]; // [rsp+9Ch] [rbp-4Ch] BYREF
char v11[3]; // [rsp+9Eh] [rbp-4Ah] BYREF
char v12[5]; // [rsp+A1h] [rbp-47h] BYREF
char v13[4]; // [rsp+A6h] [rbp-42h] BYREF
char v14[2]; // [rsp+AAh] [rbp-3Eh] BYREF
char v15[4]; // [rsp+ACh] [rbp-3Ch] BYREF
char v16[2]; // [rsp+B0h] [rbp-38h] BYREF
char v17[8]; // [rsp+B2h] [rbp-36h] BYREF
char v18[5]; // [rsp+BAh] [rbp-2Eh] BYREF
char v19[41]; // [rsp+BFh] [rbp-29h] BYREF

pthread_mutex_lock(&GPGGAMutex);
strcpy(v3, *(const char **)GPGGA_LIST);
pthread_mutex_unlock(&GPGGAMutex);
parseGPGGA(src, v3);
switch ( a2 )
{
case 0:
strcpy(dest, src);
break;
case 1:
strcpy(dest, v5);
break;
case 2:
strcpy(dest, v6);
break;
case 3:
strcpy(dest, v7);
break;
case 4:
strcpy(dest, v8);
break;
case 5:
strcpy(dest, v9);
break;
case 6:
strcpy(dest, v10);
break;
case 7:
strcpy(dest, v11);
break;
case 8:
strcpy(dest, v12);
break;
case 9:
strcpy(dest, v13);
break;
case 10:
strcpy(dest, v14);
break;
case 11:
strcpy(dest, v15);
break;
case 12:
strcpy(dest, v16);
break;
case 13:
strcpy(dest, v17);
break;
case 14:
strcpy(dest, v18);
break;
case 15:
strcpy(dest, v19);
break;
default:
return dest;
}
return dest;
}

original_code:
static char *getGpgga(char *retval, int i)
{
 GPGGA gpgga;
 char line[100];
 pthread_mutex_lock(&GPGGAMutex);
 strcpy(line, GPGGA_LIST->string);
 pthread_mutex_unlock(&GPGGAMutex);
 parseGPGGA(&gpgga, line);
 switch (i){
  case 0:
   strcpy(retval, gpgga.MessageID);
   break;
  case 1:
   strcpy(retval, gpgga.UTCTime);
   break;
  case 2:
   strcpy(retval, gpgga.Latitude);
   break;
  case 3:
   strcpy(retval, gpgga.NSIndicator);
   break;
  case 4:
   strcpy(retval, gpgga.Longitude);
   break;
  case 5:
   strcpy(retval, gpgga.EWIndicator);
   break;
  case 6:
   strcpy(retval, gpgga.PositionFixIndicator);
   break;
  case 7:
   strcpy(retval, gpgga.SatellitesUsed);
   break;
  case 8:
   strcpy(retval, gpgga.HDOP);
   break;
  case 9:
   strcpy(retval, gpgga.MSLAltitude);
   break;
  case 10:
   strcpy(retval, gpgga.MSLUnits);
   break;
  case 11:
   strcpy(retval, gpgga.GeoidSeparation);
   break;
  case 12:
   strcpy(retval, gpgga.GeoidUnits);
   break;
  case 13:
   strcpy(retval, gpgga.AgeOfDiffCorr);
   break;
  case 14:
   strcpy(retval, gpgga.DiffRefStationID);
   break;
  case 15:
   strcpy(retval, gpgga.Checksum);
   break;
 }
 return retval;
}

canonical_original_code:
static char *getGpgga(char *retval, int i)
{
 struct GPGGA gpgga;
 char line[100];
 pthread_mutex_lock(&GPGGAMutex);
 strcpy(line, GPGGA_LIST->string);
 pthread_mutex_unlock(&GPGGAMutex);
 parseGPGGA(&gpgga, line);
 switch (i){
  case 0:
   strcpy(retval, gpgga.MessageID);
   break;
  case 1:
   strcpy(retval, gpgga.UTCTime);
   break;
  case 2:
   strcpy(retval, gpgga.Latitude);
   break;
  case 3:
   strcpy(retval, gpgga.NSIndicator);
   break;
  case 4:
   strcpy(retval, gpgga.Longitude);
   break;
  case 5:
   strcpy(retval, gpgga.EWIndicator);
   break;
  case 6:
   strcpy(retval, gpgga.PositionFixIndicator);
   break;
  case 7:
   strcpy(retval, gpgga.SatellitesUsed);
   break;
  case 8:
   strcpy(retval, gpgga.HDOP);
   break;
  case 9:
   strcpy(retval, gpgga.MSLAltitude);
   break;
  case 10:
   strcpy(retval, gpgga.MSLUnits);
   break;
  case 11:
   strcpy(retval, gpgga.GeoidSeparation);
   break;
  case 12:
   strcpy(retval, gpgga.GeoidUnits);
   break;
  case 13:
   strcpy(retval, gpgga.AgeOfDiffCorr);
   break;
  case 14:
   strcpy(retval, gpgga.DiffRefStationID);
   break;
  case 15:
   strcpy(retval, gpgga.Checksum);
   break;
 }
 return retval;
}

variable_types: struct GPGGA { char MessageID[7]; char UTCTime[11]; char Latitude[11]; char NSIndicator[2]; char Longitude[11]; char EWIndicator[2]; char PositionFixIndicator[2]; char SatellitesUsed[3]; char HDOP[5]; char MSLAltitude[4]; char MSLUnits[2]; char GeoidSeparation[4]; char GeoidUnits[2]; char AgeOfDiffCorr[8]; char DiffRefStationID[5]; char Checksum[8]; }

variable_types:
line
char [100]


getGprmc

decompiled_code:
char *__fastcall getGprmc(char *dest, int a2)
{
char v3[112]; // [rsp+0h] [rbp-E8h] BYREF
char src[7]; // [rsp+70h] [rbp-78h] BYREF
char v5[11]; // [rsp+77h] [rbp-71h] BYREF
char v6[2]; // [rsp+82h] [rbp-66h] BYREF
char v7[11]; // [rsp+84h] [rbp-64h] BYREF
char v8[2]; // [rsp+8Fh] [rbp-59h] BYREF
char v9[11]; // [rsp+91h] [rbp-57h] BYREF
char v10[2]; // [rsp+9Ch] [rbp-4Ch] BYREF
char v11[8]; // [rsp+9Eh] [rbp-4Ah] BYREF
char v12[6]; // [rsp+A6h] [rbp-42h] BYREF
char v13[7]; // [rsp+ACh] [rbp-3Ch] BYREF
char v14[4]; // [rsp+B3h] [rbp-35h] BYREF
char v15[2]; // [rsp+B7h] [rbp-31h] BYREF
char v16[47]; // [rsp+B9h] [rbp-2Fh] BYREF

pthread_mutex_lock(&GPRMCMutex);
strcpy(v3, *(const char **)GPRMC_LIST);
pthread_mutex_unlock(&GPRMCMutex);
parseGPRMC(src, v3);
switch ( a2 )
{
case 1:
strcpy(dest, src);
break;
case 2:
strcpy(dest, v5);
break;
case 3:
strcpy(dest, v6);
break;
case 4:
strcpy(dest, v7);
break;
case 5:
strcpy(dest, v8);
break;
case 6:
strcpy(dest, v9);
break;
case 7:
strcpy(dest, v10);
break;
case 8:
strcpy(dest, v11);
break;
case 9:
strcpy(dest, v12);
break;
case 10:
strcpy(dest, v13);
break;
case 11:
strcpy(dest, v14);
break;
case 12:
strcpy(dest, v15);
break;
case 13:
strcpy(dest, v16);
break;
default:
return dest;
}
return dest;
}

canonical_decompiled_code:
char *__fastcall func1(char *dest, int a2)
{
char v3[112]; // [rsp+0h] [rbp-E8h] BYREF
char src[7]; // [rsp+70h] [rbp-78h] BYREF
char v5[11]; // [rsp+77h] [rbp-71h] BYREF
char v6[2]; // [rsp+82h] [rbp-66h] BYREF
char v7[11]; // [rsp+84h] [rbp-64h] BYREF
char v8[2]; // [rsp+8Fh] [rbp-59h] BYREF
char v9[11]; // [rsp+91h] [rbp-57h] BYREF
char v10[2]; // [rsp+9Ch] [rbp-4Ch] BYREF
char v11[8]; // [rsp+9Eh] [rbp-4Ah] BYREF
char v12[6]; // [rsp+A6h] [rbp-42h] BYREF
char v13[7]; // [rsp+ACh] [rbp-3Ch] BYREF
char v14[4]; // [rsp+B3h] [rbp-35h] BYREF
char v15[2]; // [rsp+B7h] [rbp-31h] BYREF
char v16[47]; // [rsp+B9h] [rbp-2Fh] BYREF

pthread_mutex_lock(&GPRMCMutex);
strcpy(v3, *(const char **)GPRMC_LIST);
pthread_mutex_unlock(&GPRMCMutex);
parseGPRMC(src, v3);
switch ( a2 )
{
case 1:
strcpy(dest, src);
break;
case 2:
strcpy(dest, v5);
break;
case 3:
strcpy(dest, v6);
break;
case 4:
strcpy(dest, v7);
break;
case 5:
strcpy(dest, v8);
break;
case 6:
strcpy(dest, v9);
break;
case 7:
strcpy(dest, v10);
break;
case 8:
strcpy(dest, v11);
break;
case 9:
strcpy(dest, v12);
break;
case 10:
strcpy(dest, v13);
break;
case 11:
strcpy(dest, v14);
break;
case 12:
strcpy(dest, v15);
break;
case 13:
strcpy(dest, v16);
break;
default:
return dest;
}
return dest;
}

original_code:
static char *getGprmc(char *retval, int i)
{
 GPRMC gprmc;
 char line[100];
 pthread_mutex_lock(&GPRMCMutex);
 strcpy(line, GPRMC_LIST->string);
 pthread_mutex_unlock(&GPRMCMutex);
 parseGPRMC(&gprmc, line);
 switch(i){
  case 1:
   strcpy(retval, gprmc.RMCMessageID);
   break;
  case 2:
   strcpy(retval, gprmc.UTCPosition);
   break;
  case 3:
   strcpy(retval, gprmc.Status );
   break;
  case 4:
   strcpy(retval, gprmc.RMCLatitude );
   break;
  case 5:
   strcpy(retval, gprmc.RMCNSIndicator );
   break;
  case 6:
   strcpy(retval, gprmc.RMCLongitude);
   break;
  case 7:
   strcpy(retval, gprmc.RMCEWIndicator);
   break;
  case 8:
   strcpy(retval, gprmc.SpeedOverGround);
   break;
  case 9:
   strcpy(retval, gprmc.CourseOverGround);
   break;
  case 10:
   strcpy(retval, gprmc.Date);
   break;
  case 11:
   strcpy(retval, gprmc.MagneticVariation);
   break;
  case 12:
   strcpy(retval, gprmc.RMCEWIndicator2);
   break;
  case 13:
   strcpy(retval, gprmc.Checksum);
   break;
 }
 return retval;
}

canonical_original_code:
static char *getGprmc(char *retval, int i)
{
 struct GPRMC gprmc;
 char line[100];
 pthread_mutex_lock(&GPRMCMutex);
 strcpy(line, GPRMC_LIST->string);
 pthread_mutex_unlock(&GPRMCMutex);
 parseGPRMC(&gprmc, line);
 switch(i){
  case 1:
   strcpy(retval, gprmc.RMCMessageID);
   break;
  case 2:
   strcpy(retval, gprmc.UTCPosition);
   break;
  case 3:
   strcpy(retval, gprmc.Status );
   break;
  case 4:
   strcpy(retval, gprmc.RMCLatitude );
   break;
  case 5:
   strcpy(retval, gprmc.RMCNSIndicator );
   break;
  case 6:
   strcpy(retval, gprmc.RMCLongitude);
   break;
  case 7:
   strcpy(retval, gprmc.RMCEWIndicator);
   break;
  case 8:
   strcpy(retval, gprmc.SpeedOverGround);
   break;
  case 9:
   strcpy(retval, gprmc.CourseOverGround);
   break;
  case 10:
   strcpy(retval, gprmc.Date);
   break;
  case 11:
   strcpy(retval, gprmc.MagneticVariation);
   break;
  case 12:
   strcpy(retval, gprmc.RMCEWIndicator2);
   break;
  case 13:
   strcpy(retval, gprmc.Checksum);
   break;
 }
 return retval;
}

variable_types: struct GPRMC { char RMCMessageID[7]; char UTCPosition[11]; char Status[2]; char RMCLatitude[11]; char RMCNSIndicator[2]; char RMCLongitude[11]; char RMCEWIndicator[2]; char SpeedOverGround[8]; char CourseOverGround[6]; char Date[7]; char MagneticVariation[4]; char RMCEWIndicator2[2]; char Checksum[8]; }


getMessageID

decompiled_code:
char *__fastcall getMessageID(char *a1)
{
return getGpgga(a1, 0);
}

canonical_decompiled_code:
char *__fastcall func2(char *a1)
{
return func0(a1, 0);
}

original_code: char *getMessageID(char *retval){return getGpgga(retval, 0);}


getUTCTime

decompiled_code:
char *__fastcall getUTCTime(char *a1)
{
return getGpgga(a1, 1);
}

canonical_decompiled_code:
char *__fastcall func3(char *a1)
{
return func0(a1, 1);
}

original_code: char *getUTCTime(char *retval){return getGpgga(retval, 1);}


getLatitude

decompiled_code:
char *__fastcall getLatitude(char *a1)
{
return getGpgga(a1, 2);
}

canonical_decompiled_code:
char *__fastcall func4(char *a1)
{
return func0(a1, 2);
}

original_code: char *getLatitude(char *retval){return getGpgga(retval, 2);}


getNSIndicator

decompiled_code:
char *__fastcall getNSIndicator(char *a1)
{
return getGpgga(a1, 3);
}

canonical_decompiled_code:
char *__fastcall func5(char *a1)
{
return func0(a1, 3);
}

original_code: char *getNSIndicator(char *retval){return getGpgga(retval, 3);}


getLongitude

decompiled_code:
char *__fastcall getLongitude(char *a1)
{
return getGpgga(a1, 4);
}

canonical_decompiled_code:
char *__fastcall func6(char *a1)
{
return func0(a1, 4);
}

original_code: char *getLongitude(char *retval){return getGpgga(retval, 4);}


getEWIndicator

decompiled_code:
char *__fastcall getEWIndicator(char *a1)
{
return getGpgga(a1, 5);
}

canonical_decompiled_code:
char *__fastcall func7(char *a1)
{
return func0(a1, 5);
}

original_code: char *getEWIndicator(char *retval){return getGpgga(retval, 5);}


getPositionFixIndicator

decompiled_code:
char *__fastcall getPositionFixIndicator(char *a1)
{
return getGpgga(a1, 6);
}

canonical_decompiled_code:
char *__fastcall func8(char *a1)
{
return func0(a1, 6);
}

original_code: char *getPositionFixIndicator(char *retval){return getGpgga(retval, 6);}


getSatellitesUsed

decompiled_code:
char *__fastcall getSatellitesUsed(char *a1)
{
return getGpgga(a1, 7);
}

canonical_decompiled_code:
char *__fastcall func9(char *a1)
{
return func0(a1, 7);
}

original_code: char *getSatellitesUsed(char *retval){return getGpgga(retval, 7);}


getHDOP

decompiled_code:
char *__fastcall getHDOP(char *a1)
{
return getGpgga(a1, 8);
}

canonical_decompiled_code:
char *__fastcall func10(char *a1)
{
return func0(a1, 8);
}

original_code: char *getHDOP(char *retval){return getGpgga(retval, 8);}


getMSLAltitude

decompiled_code:
char *__fastcall getMSLAltitude(char *a1)
{
return getGpgga(a1, 9);
}

canonical_decompiled_code:
char *__fastcall func11(char *a1)
{
return func0(a1, 9);
}

original_code: char *getMSLAltitude(char *retval){return getGpgga(retval, 9);}


getMSLUnits

decompiled_code:
char *__fastcall getMSLUnits(char *a1)
{
return getGpgga(a1, 10);
}

canonical_decompiled_code:
char *__fastcall func12(char *a1)
{
return func0(a1, 10);
}

original_code: char *getMSLUnits(char *retval){return getGpgga(retval, 10);}


getGeoidSeparation

decompiled_code:
char *__fastcall getGeoidSeparation(char *a1)
{
return getGpgga(a1, 11);
}

canonical_decompiled_code:
char *__fastcall func13(char *a1)
{
return func0(a1, 11);
}

original_code: char *getGeoidSeparation(char *retval){return getGpgga(retval, 11);}


getGeoidUnits

decompiled_code:
char *__fastcall getGeoidUnits(char *a1)
{
return getGpgga(a1, 12);
}

canonical_decompiled_code:
char *__fastcall func14(char *a1)
{
return func0(a1, 12);
}

original_code: char *getGeoidUnits(char *retval){return getGpgga(retval, 12);}


getAgeOfDiffCorr

decompiled_code:
char *__fastcall getAgeOfDiffCorr(char *a1)
{
return getGpgga(a1, 13);
}

canonical_decompiled_code:
char *__fastcall func15(char *a1)
{
return func0(a1, 13);
}

original_code: char *getAgeOfDiffCorr(char *retval){return getGpgga(retval, 13);}


getDiffRefStation

decompiled_code:
char *__fastcall getDiffRefStation(char *a1)
{
return getGpgga(a1, 14);
}

canonical_decompiled_code:
char *__fastcall func16(char *a1)
{
return func0(a1, 14);
}

original_code: char *getDiffRefStation(char *retval){return getGpgga(retval, 14);}


getChecksum

decompiled_code:
char *__fastcall getChecksum(char *a1)
{
return getGpgga(a1, 15);
}

canonical_decompiled_code:
char *__fastcall func17(char *a1)
{
return func0(a1, 15);
}

original_code: char *getChecksum(char *retval){return getGpgga(retval, 15);}


getRMCMessageID

decompiled_code:
char *__fastcall getRMCMessageID(char *a1)
{
return getGprmc(a1, 1);
}

canonical_decompiled_code:
char *__fastcall func18(char *a1)
{
return func1(a1, 1);
}

original_code: char *getRMCMessageID(char *retval){return getGprmc(retval, 1);}


getUTCPosition

decompiled_code:
char *__fastcall getUTCPosition(char *a1)
{
return getGprmc(a1, 2);
}

canonical_decompiled_code:
char *__fastcall func19(char *a1)
{
return func1(a1, 2);
}

original_code: char *getUTCPosition(char *retval){return getGprmc(retval, 2);}


getStatus

decompiled_code:
char *__fastcall getStatus(char *a1)
{
return getGprmc(a1, 3);
}

canonical_decompiled_code:
char *__fastcall func20(char *a1)
{
return func1(a1, 3);
}

original_code: char *getStatus(char *retval){return getGprmc(retval, 3);}


getRMCLatitude

decompiled_code:
char *__fastcall getRMCLatitude(char *a1)
{
return getGprmc(a1, 4);
}

canonical_decompiled_code:
char *__fastcall func21(char *a1)
{
return func1(a1, 4);
}

original_code: char *getRMCLatitude(char *retval){return getGprmc(retval, 4);}


getRMCNSIndicator

decompiled_code:
char *__fastcall getRMCNSIndicator(char *a1)
{
return getGprmc(a1, 5);
}

canonical_decompiled_code:
char *__fastcall func22(char *a1)
{
return func1(a1, 5);
}

original_code: char *getRMCNSIndicator(char *retval){return getGprmc(retval, 5);}


getRMCLongitude

decompiled_code:
char *__fastcall getRMCLongitude(char *a1)
{
return getGprmc(a1, 6);
}

canonical_decompiled_code:
char *__fastcall func23(char *a1)
{
return func1(a1, 6);
}

original_code: char *getRMCLongitude(char *retval){return getGprmc(retval, 6);}


getRMCEWIndicator

decompiled_code:
char *__fastcall getRMCEWIndicator(char *a1)
{
return getGprmc(a1, 7);
}

canonical_decompiled_code:
char *__fastcall func24(char *a1)
{
return func1(a1, 7);
}

original_code: char *getRMCEWIndicator(char *retval){return getGprmc(retval, 7);}


getSpeedOverGround

decompiled_code:
char *__fastcall getSpeedOverGround(char *a1)
{
return getGprmc(a1, 8);
}

canonical_decompiled_code:
char *__fastcall func25(char *a1)
{
return func1(a1, 8);
}

original_code: char *getSpeedOverGround(char *retval){return getGprmc(retval, 8);}


getCourseOverGround

decompiled_code:
char *__fastcall getCourseOverGround(char *a1)
{
return getGprmc(a1, 9);
}

canonical_decompiled_code:
char *__fastcall func26(char *a1)
{
return func1(a1, 9);
}

original_code: char *getCourseOverGround(char *retval){return getGprmc(retval, 9);}


getDate

decompiled_code:
char *__fastcall getDate(char *a1)
{
return getGprmc(a1, 10);
}

canonical_decompiled_code:
char *__fastcall func27(char *a1)
{
return func1(a1, 10);
}

original_code: char *getDate(char *retval){return getGprmc(retval, 10);}


getMagneticVariation

decompiled_code:
char *__fastcall getMagneticVariation(char *a1)
{
return getGprmc(a1, 11);
}

canonical_decompiled_code:
char *__fastcall func28(char *a1)
{
return func1(a1, 11);
}

original_code: char *getMagneticVariation(char *retval){return getGprmc(retval, 11);}


getRMCChecksum

decompiled_code:
char *__fastcall getRMCChecksum(char *a1)
{
return getGprmc(a1, 12);
}

canonical_decompiled_code:
char *__fastcall func29(char *a1)
{
return func1(a1, 12);
}

original_code: char *getRMCChecksum(char *retval){return getGprmc(retval, 12);}


BUinitGPS

decompiled_code:
__int64 BUinitGPS()
{
pthread_attr_t v1; // [rsp+0h] [rbp-48h] BYREF
pthread_t newthread[2]; // [rsp+38h] [rbp-10h] BYREF

pthread_mutex_init(&GPGSAMutex, 0LL);
pthread_mutex_init(&GPRMCMutex, 0LL);
pthread_mutex_init(&GPGGAMutex, 0LL);
pthread_mutex_init(&GPGSVMutex, 0LL);
pthread_attr_init(&v1);
if ( pthread_create(newthread, &v1, (void *(*)(void *))&readSerial, 0LL) )
{
puts("Error could not create thread!");
exit(-1);
}
return 0LL;
}

canonical_decompiled_code:
__int64 func30()
{
pthread_attr_t v1; // [rsp+0h] [rbp-48h] BYREF
pthread_t newthread[2]; // [rsp+38h] [rbp-10h] BYREF

pthread_mutex_init(&GPGSAMutex, 0LL);
pthread_mutex_init(&GPRMCMutex, 0LL);
pthread_mutex_init(&GPGGAMutex, 0LL);
pthread_mutex_init(&GPGSVMutex, 0LL);
pthread_attr_init(&v1);
if ( pthread_create(newthread, &v1, (void *(*)(void *))&readSerial, 0LL) )
{
puts("Error could not create thread!");
exit(-1);
}
return 0LL;
}

original_code:
int BUinitGPS(int flags, int numberOfObjects)
{
 int pt;
 pthread_mutex_init(&GPGSAMutex, ((void *)0));
 pthread_mutex_init(&GPRMCMutex, ((void *)0));
 pthread_mutex_init(&GPGGAMutex, ((void *)0));
 pthread_mutex_init(&GPGSVMutex, ((void *)0));
 pthread_t thread1;
 pthread_attr_t attr;
 pthread_attr_init(&attr);
 pt = pthread_create(&thread1, &attr, readSerial, ((void *)0));
 if (pt){
  printf("Error could not create thread!\n");
  exit(-1);
 }
 return pt;
}

canonical_original_code:
int BUinitGPS(int flags, int numberOfObjects)
{
 int pt;
 pthread_mutex_init(&GPGSAMutex, ((void *)0));
 pthread_mutex_init(&GPRMCMutex, ((void *)0));
 pthread_mutex_init(&GPGGAMutex, ((void *)0));
 pthread_mutex_init(&GPGSVMutex, ((void *)0));
 unsigned long thread1;
 union pthread_attr_t attr;
 pthread_attr_init(&attr);
 pt = pthread_create(&thread1, &attr, readSerial, ((void *)0));
 if (pt){
  printf("Error could not create thread!\n");
  exit(-1);
 }
 return pt;
}

variable_types: flags int

variable_types: numberOfObjects int

variable_types: pt int

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


original_code:
static int nmea_checksum(char *line)
{
 uint8_t checksum = 0;
 while (*line){
  if (*line == '$'){
   line++;
   continue;
  }
  if (*line == '*')
   break;
  checksum ^= *line++;
 }
 return (strtoul(line+1, ((void *)0), 16) == checksum);
}

canonical_original_code:
static int nmea_checksum(char *line)
{
 unsigned char checksum = 0;
 while (*line){
  if (*line == '$'){
   line++;
   continue;
  }
  if (*line == '*')
   break;
  checksum ^= *line++;
 }
 return (strtoul(line+1, ((void *)0), 16) == checksum);
}

variable_types:
line
char *

variable_types:
checksum
unsigned char


readSerial

decompiled_code:
void __noreturn readSerial()
{
int v0; // eax
int v1; // ebx
int *v2; // rax
struct termios v3; // [rsp+0h] [rbp-A8h] BYREF
char haystack[104]; // [rsp+40h] [rbp-68h] BYREF

v0 = open("/dev/ttyUSB0", 0);
if ( v0 != -1 )
{
v1 = v0;
v3.c_lflag = 2;
v3.c_iflag = 20480;
v3.c_cflag = -2147481412;
tcflush(v0, 0);
if ( tcsetattr(v1, 0, &v3) == -1 )
{
puts("Could not set attributes!");
exit(1);
}
while ( 1 )
{
do
haystack[(int)read(v1, haystack, 0x51uLL)] = 0;
while ( !nmea_checksum(haystack) );
if ( strstr(haystack, "$GPGGA") )
{
pthread_mutex_lock(&GPGGAMutex);
GPGGA_LIST = pushItem(GPGGA_LIST, haystack);
pthread_mutex_unlock(&GPGGAMutex);
}
if ( strstr(haystack, "$GPGSA") )
{
pthread_mutex_lock(&GPGSAMutex);
GPGSA_LIST = pushItem(GPGSA_LIST, haystack);
pthread_mutex_unlock(&GPGSAMutex);
}
if ( strstr(haystack, "$GPRMC") )
{
pthread_mutex_lock(&GPRMCMutex);
GPRMC_LIST = pushItem(GPRMC_LIST, haystack);
pthread_mutex_unlock(&GPRMCMutex);
}
if ( strstr(haystack, "$GPGSV") )
{
pthread_mutex_lock(&GPGSVMutex);
GPGSV_LIST = pushItem(GPGSV_LIST, haystack);
pthread_mutex_unlock(&GPGSVMutex);
}
}
}
v2 = _errno_location();
printf("Could not open %s, errno = %d", "/dev/ttyUSB0", (unsigned int)*v2);
exit(1);
}

canonical_decompiled_code:
void __noreturn func1()
{
int v0; // eax
int v1; // ebx
int *v2; // rax
struct termios v3; // [rsp+0h] [rbp-A8h] BYREF
char haystack[104]; // [rsp+40h] [rbp-68h] BYREF

v0 = open("/dev/ttyUSB0", 0);
if ( v0 != -1 )
{
v1 = v0;
v3.c_lflag = 2;
v3.c_iflag = 20480;
v3.c_cflag = -2147481412;
tcflush(v0, 0);
if ( tcsetattr(v1, 0, &v3) == -1 )
{
puts("Could not set attributes!");
exit(1);
}
while ( 1 )
{
do
haystack[(int)read(v1, haystack, 0x51uLL)] = 0;
while ( !func0(haystack) );
if ( strstr(haystack, "$GPGGA") )
{
pthread_mutex_lock(&GPGGAMutex);
GPGGA_LIST = pushItem(GPGGA_LIST, haystack);
pthread_mutex_unlock(&GPGGAMutex);
}
if ( strstr(haystack, "$GPGSA") )
{
pthread_mutex_lock(&GPGSAMutex);
GPGSA_LIST = pushItem(GPGSA_LIST, haystack);
pthread_mutex_unlock(&GPGSAMutex);
}
if ( strstr(haystack, "$GPRMC") )
{
pthread_mutex_lock(&GPRMCMutex);
GPRMC_LIST = pushItem(GPRMC_LIST, haystack);
pthread_mutex_unlock(&GPRMCMutex);
}
if ( strstr(haystack, "$GPGSV") )
{
pthread_mutex_lock(&GPGSVMutex);
GPGSV_LIST = pushItem(GPGSV_LIST, haystack);
pthread_mutex_unlock(&GPGSVMutex);
}
}
}
v2 = _errno_location();
printf("Could not open %s, errno = %d", "/dev/ttyUSB0", (unsigned int)*v2);
exit(1);
}

original_code:
void *readSerial()
{
 int STOP=0;
 int fd, res;
 char line[82];
 struct termios attrib;
 fd = open("/dev/ttyUSB0", 00);
 if(fd == -1){
  printf("Could not open %s, errno = %d", "/dev/ttyUSB0", (*__errno_location ()));
  exit(1);
 }
 attrib.c_lflag = 0000002;
 attrib.c_iflag = 0010000 | 0040000;
 attrib.c_cflag = 0000014 | 020000000000 | 0000060 | 0004000 | 0000200;
 tcflush(fd, 0);
 if(tcsetattr(fd, 0, &attrib) == -1){
  printf("Could not set attributes!\n");
  exit(1);
 }
 while (STOP==0){
  res = read( fd, line, 81);
  line[res]=0;
  if(nmea_checksum(line)){
   if(strstr(line, "$GPGGA")!=((void *)0)){
    pthread_mutex_lock(&GPGGAMutex);
    GPGGA_LIST = pushItem(GPGGA_LIST, line);
    pthread_mutex_unlock(&GPGGAMutex);
   }
   if(strstr(line, "$GPGSA")!=((void *)0)){
    pthread_mutex_lock(&GPGSAMutex);
    GPGSA_LIST = pushItem(GPGSA_LIST, line);
    pthread_mutex_unlock(&GPGSAMutex);
   }
   if(strstr(line, "$GPRMC")!=((void *)0)){
    pthread_mutex_lock(&GPRMCMutex);
    GPRMC_LIST = pushItem(GPRMC_LIST, line);
    pthread_mutex_unlock(&GPRMCMutex);
   }
   if(strstr(line, "$GPGSV")!=((void *)0)){
    pthread_mutex_lock(&GPGSVMutex);
    GPGSV_LIST = pushItem(GPGSV_LIST, line);
    pthread_mutex_unlock(&GPGSVMutex);
   }
  }
 }
  close(fd);
 return ((void *)0);
}

canonical_original_code:
void *readSerial()
{
 int STOP = 0;
 int fd; int res;
 char line[82];
 struct termios attrib;
 fd = open("/dev/ttyUSB0", 00);
 if(fd == -1){
  printf("Could not open %s, errno = %d", "/dev/ttyUSB0", (*__errno_location ()));
  exit(1);
 }
 attrib.c_lflag = 0000002;
 attrib.c_iflag = 0010000 | 0040000;
 attrib.c_cflag = 0000014 | 020000000000 | 0000060 | 0004000 | 0000200;
 tcflush(fd, 0);
 if(tcsetattr(fd, 0, &attrib) == -1){
  printf("Could not set attributes!\n");
  exit(1);
 }
 while (STOP==0){
  res = read( fd, line, 81);
  line[res]=0;
  if(nmea_checksum(line)){
   if(strstr(line, "$GPGGA")!=((void *)0)){
    pthread_mutex_lock(&GPGGAMutex);
    GPGGA_LIST = pushItem(GPGGA_LIST, line);
    pthread_mutex_unlock(&GPGGAMutex);
   }
   if(strstr(line, "$GPGSA")!=((void *)0)){
    pthread_mutex_lock(&GPGSAMutex);
    GPGSA_LIST = pushItem(GPGSA_LIST, line);
    pthread_mutex_unlock(&GPGSAMutex);
   }
   if(strstr(line, "$GPRMC")!=((void *)0)){
    pthread_mutex_lock(&GPRMCMutex);
    GPRMC_LIST = pushItem(GPRMC_LIST, line);
    pthread_mutex_unlock(&GPRMCMutex);
   }
   if(strstr(line, "$GPGSV")!=((void *)0)){
    pthread_mutex_lock(&GPGSVMutex);
    GPGSV_LIST = pushItem(GPGSV_LIST, line);
    pthread_mutex_unlock(&GPGSVMutex);
   }
  }
 }
  close(fd);
 return ((void *)0);
}

variable_types: STOP int

variable_types: fd int

variable_types: res int

variable_types:
line
char [82]

variable_types: struct termios { unsigned int c_iflag; unsigned int c_oflag; unsigned int c_cflag; unsigned int c_lflag; unsigned char c_line; unsigned char c_cc[32]; unsigned int c_ispeed; unsigned int c_ospeed; }

return_type: void *


printList

decompiled_code:
int __fastcall printList(__int64 a1)
{
__int64 v1; // rbx
unsigned int v2; // ebp
__int64 v3; // rsi
int result; // eax

if ( a1 )
{
v1 = a1;
v2 = 0;
do
{
v3 = v2++;
result = printf("%d: %s", v3, *(const char **)v1);
v1 = *(_QWORD *)(v1 + 8);
}
while ( v1 );
}
return result;
}

canonical_decompiled_code:
int __fastcall func0(__int64 a1)
{
__int64 v1; // rbx
unsigned int v2; // ebp
__int64 v3; // rsi
int result; // eax

if ( a1 )
{
v1 = a1;
v2 = 0;
do
{
v3 = v2++;
result = printf("%d: %s", v3, *(const char **)v1);
v1 = *(_QWORD *)(v1 + 8);
}
while ( v1 );
}
return result;
}

original_code:
void printList(Item *head)
{
 int i=0;
 while(head != ((void *)0)){
  printf("%d: %s", i++, head->string);
  head = head->next;
 }
}

canonical_original_code:
void printList(struct Item *head)
{
 int i = 0;
 while(head != ((void *)0)){
  printf("%d: %s", i++, head->string);
  head = head->next;
 }
}

variable_types: struct Item { char *string; struct Item *next; } *

variable_types: i int


noOfItems

decompiled_code:
__int64 __fastcall noOfItems(__int64 a1)
{
unsigned int v1; // edx
__int64 v2; // rax

v1 = 0;
if ( a1 )
{
v2 = *(_QWORD *)(a1 + 8);
if ( v2 )
{
do
{
++v1;
v2 = *(_QWORD *)(v2 + 8);
}
while ( v2 );
}
else
{
v1 = 0;
}
}
return v1;
}

original_code:
int noOfItems(Item *head)
{
 int i=0;
 if(head!=((void *)0))
 while(head->next != ((void *)0)){
  i++;
  head = head->next;
 }
 return i;
}

canonical_original_code:
int noOfItems(struct Item *head)
{
 int i = 0;
 if(head!=((void *)0))
 while(head->next != ((void *)0)){
  i++;
  head = head->next;
 }
 return i;
}

user_defined_types: struct Item { char *string; struct Item *next; }


deleteLast

decompiled_code:
void __fastcall deleteLast(_QWORD *a1)
{
_QWORD *v1; // rbx

do
{
v1 = a1;
a1 = (_QWORD *)a1[1];
}
while ( a1[1] );
free(a1);
v1[1] = 0LL;
}

canonical_decompiled_code:
void __fastcall func2(_QWORD *a1)
{
_QWORD *v1; // rbx

do
{
v1 = a1;
a1 = (_QWORD *)a1[1];
}
while ( a1[1] );
free(a1);
v1[1] = 0LL;
}

original_code:
void deleteLast(Item *head)
{
 while((head->next)->next!=((void *)0))
  head=head->next;
 free(head->next);
 head->next=((void *)0);
}

canonical_original_code:
void deleteLast(struct Item *head)
{
 while((head->next)->next!=((void *)0))
  head=head->next;
 free(head->next);
 head->next=((void *)0);
}


decompiled_code:
void *__fastcall assoc_array_init(_QWORD *a1, __int64 a2, __int64 a3, __int64 a4)
{
void *v4; // rax
void *result; // rax

*a1 = a2;
a1[5] = 8LL;
a1[6] = 0LL;
a1[3] = a3;
a1[4] = a4;
a1[7] = a1;
a1[8] = 0LL;
v4 = calloc(8uLL, 8uLL);
a1[1] = v4;
if ( !v4 )
{
perror("calloc()");
abort();
}
result = calloc(8uLL, 8uLL);
a1[2] = result;
if ( !result )
{
perror("calloc()");
abort();
}
return result;
}

canonical_decompiled_code:
void *__fastcall func6(_QWORD *a1, __int64 a2, __int64 a3, __int64 a4)
{
void *v4; // rax
void *result; // rax

*a1 = a2;
a1[5] = 8LL;
a1[6] = 0LL;
a1[3] = a3;
a1[4] = a4;
a1[7] = a1;
a1[8] = 0LL;
v4 = calloc(8uLL, 8uLL);
a1[1] = v4;
if ( !v4 )
{
perror("calloc()");
abort();
}
result = calloc(8uLL, 8uLL);
a1[2] = result;
if ( !result )
{
perror("calloc()");
abort();
}
return result;
}

original_code:
void
assoc_array_init(AssocArray *array, CompareFunc compare_keys, FreeFunc free_key, FreeFunc free_value)
{
 ((void) (0));
 ((void) (0));
 array->compare_keys = compare_keys;
 array->size = 8;
 array->count = 0;
 array->free_key = free_key;
 array->free_value = free_value;
 array->pair.array = array;
 array->pair.offset = 0;
 array->keys = (void **)calloc(array->size, sizeof(void *));
 if(!array->keys)
 {
  perror("calloc()");
  abort();
 }
 array->values = (void **)calloc(array->size, sizeof(void *));
 if(!array->values)
 {
  perror("calloc()");
  abort();
 }
}

canonical_original_code:
void assoc_array_init(struct _AssocArray *array, int (*compare_keys)(void *a, void *b), void (*free_key)(void *p), void (*free_value)(void *p))
{
 ((void) (0));
 ((void) (0));
 array->compare_keys = compare_keys;
 array->size = 8;
 array->count = 0;
 array->free_key = free_key;
 array->free_value = free_value;
 array->pair.array = array;
 array->pair.offset = 0;
 array->keys = (void **)calloc(array->size, sizeof(void *));
 if(!array->keys)
 {
  perror("calloc()");
  abort();
 }
 array->values = (void **)calloc(array->size, sizeof(void *));
 if(!array->values)
 {
  perror("calloc()");
  abort();
 }
}

variable_types: struct _AssocArray { int (*compare_keys)(void *a, void *b); void **keys; void **values; void (*free_key)(void *p); void (*free_value)(void *p); unsigned long size; unsigned long count; struct _AssocArrayPair { struct _AssocArray *array; long offset; } pair; } *

user_defined_types: struct _AssocArray { int (*compare_keys)(void *a, void *b); void **keys; void **values; void (*free_key)(void *p); void (*free_value)(void *p); unsigned long size; unsigned long count; struct _AssocArrayPair pair; }


decompiled_code:
void __fastcall assoc_array_free(__int64 a1)
{
assoc_array_free_memory((_QWORD *)a1);
free(*(void **)(a1 + 8));
free(*(void **)(a1 + 16));
}

canonical_decompiled_code:
void __fastcall func7(__int64 a1)
{
func1((_QWORD *)a1);
free(*(void **)(a1 + 8));
free(*(void **)(a1 + 16));
}

original_code:
void
assoc_array_free(AssocArray *array)
{
 ((void) (0));
 _assoc_array_free_memory(array);
 free(array->keys);
 free(array->values);
}

canonical_original_code:
void assoc_array_free(struct _AssocArray *array)
{
 ((void) (0));
 _assoc_array_free_memory(array);
 free(array->keys);
 free(array->values);
}

user_defined_types: struct _AssocArrayPair { struct _AssocArray *array; long offset; }


decompiled_code:
void __fastcall assoc_array_destroy(void *ptr)
{
assoc_array_free((__int64)ptr);
free(ptr);
}

canonical_decompiled_code:
void __fastcall func8(void *ptr)
{
func7((__int64)ptr);
free(ptr);
}

original_code:
void
assoc_array_destroy(AssocArray *array)
{
 ((void) (0));
 assoc_array_free(array);
 free(array);
}

canonical_original_code:
void assoc_array_destroy(struct _AssocArray *array)
{
 ((void) (0));
 assoc_array_free(array);
 free(array);
}


decompiled_code:
__int64 __fastcall assoc_array_set(_QWORD *a1, __int64 a2, __int64 a3, char a4)
{
__int64 v5; // rdx
int v7; // er14
__int64 result; // rax
__int64 v9[6]; // [rsp+8h] [rbp-30h] BYREF

v5 = a1[6];
if ( v5 )
{
v9[0] = 0LL;
v7 = assoc_array_binary_search((__int64 (__fastcall *)(__int64, _QWORD))*a1, (_QWORD *)a1[1], v5, a2, v9);
if ( v7 )
{
assoc_array_resize_if_necessary((__int64)a1);
if ( v7 < 0 )
assoc_array_insert_before_offset(a1, a2, a3, v9[0]);
else
assoc_array_insert_after_offset(a1, a2, a3, v9[0]);
++a1[6];
result = 0LL;
}
else
{
assoc_array_replace(a1, a2, a3, v9[0], a4);
result = 1LL;
}
}
else
{
assoc_array_insert_first((__int64)a1, a2, a3);
result = 0LL;
}
return result;
}

original_code:
AssocArrayInsertResult
assoc_array_set(AssocArray *array, void *key, void *value, _Bool overwrite_key)
{
 AssocArrayInsertResult result = ASSOCARRAY_INSERT_RESULT_FAILED;
 ((void) (0));
 ((void) (0));
 if(array->count)
 {
  ssize_t offset = 0;
  int cmp = _assoc_array_binary_search(array->compare_keys, array->keys, array->count, key, &offset);
  if(cmp)
  {
   result = ASSOCARRAY_INSERT_RESULT_NEW;
   _assoc_array_resize_if_necessary(array);
   if(cmp < 0)
   {
    _assoc_array_insert_before_offset(array, key, value, offset);
   }
   else
   {
    _assoc_array_insert_after_offset(array, key, value, offset);
   }
   ++array->count;
  }
  else
  {
   result = ASSOCARRAY_INSERT_RESULT_REPLACED;
   _assoc_array_replace(array, key, value, offset, overwrite_key);
  }
 }
 else
 {
  result = ASSOCARRAY_INSERT_RESULT_NEW;
  _assoc_array_insert_first(array, key, value);
 }
 return result;
}

canonical_original_code:
enum AssocArrayInsertResult assoc_array_set(struct _AssocArray *array, void *key, void *value, _Bool overwrite_key)
{
 enum AssocArrayInsertResult result = ASSOCARRAY_INSERT_RESULT_FAILED;
 ((void) (0));
 ((void) (0));
 if(array->count)
 {
  long offset = 0;
  int cmp = _assoc_array_binary_search(array->compare_keys, array->keys, array->count, key, &offset);
  if(cmp)
  {
   result = ASSOCARRAY_INSERT_RESULT_NEW;
   _assoc_array_resize_if_necessary(array);
   if(cmp < 0)
   {
    _assoc_array_insert_before_offset(array, key, value, offset);
   }
   else
   {
    _assoc_array_insert_after_offset(array, key, value, offset);
   }
   ++array->count;
  }
  else
  {
   result = ASSOCARRAY_INSERT_RESULT_REPLACED;
   _assoc_array_replace(array, key, value, offset, overwrite_key);
  }
 }
 else
 {
  result = ASSOCARRAY_INSERT_RESULT_NEW;
  _assoc_array_insert_first(array, key, value);
 }
 return result;
}

variable_types:
key
void *

variable_types:
value
void *

variable_types: enum AssocArrayInsertResult { ASSOCARRAY_INSERT_RESULT_NEW=0, ASSOCARRAY_INSERT_RESULT_REPLACED=1, ASSOCARRAY_INSERT_RESULT_FAILED=2 }

variable_types: offset long

variable_types: cmp int


original_code:
void
assoc_array_remove(AssocArray *array, const void *key)
{
 ((void) (0));
 ((void) (0));
 if(array->count)
 {
  ssize_t offset = 0;
  if(!_assoc_array_binary_search(array->compare_keys, array->keys, array->count, key, &offset))
  {
   if(array->free_key)
   {
    array->free_key(array->keys[offset]);
   }
   if(array->free_value && array->values[offset])
   {
    array->free_value(array->values[offset]);
   }
   if((size_t)offset < array->count - 1)
   {
    memmove(&array->keys[offset], &array->keys[offset + 1], (array->count - 1 - offset) * sizeof(void *));
    memmove(&array->values[offset], &array->values[offset + 1], (array->count - 1 - offset) * sizeof(void *));
   }
   --array->count;
  }
 }
}

canonical_original_code:
void assoc_array_remove(struct _AssocArray *array, void *key)
{
 ((void) (0));
 ((void) (0));
 if(array->count)
 {
  long offset = 0;
  if(!_assoc_array_binary_search(array->compare_keys, array->keys, array->count, key, &offset))
  {
   if(array->free_key)
   {
    array->free_key(array->keys[offset]);
   }
   if(array->free_value && array->values[offset])
   {
    array->free_value(array->values[offset]);
   }
   if((unsigned long)offset < array->count - 1)
   {
    memmove(&array->keys[offset], &array->keys[offset + 1], (array->count - 1 - offset) * sizeof(void *));
    memmove(&array->values[offset], &array->values[offset + 1], (array->count - 1 - offset) * sizeof(void *));
   }
   --array->count;
  }
 }
}


decompiled_code:
__int64 __fastcall assoc_array_lookup(__int64 a1, __int64 a2)
{
__int64 v2; // rdx
__int64 result; // rax
int v4; // edx
__int64 v5; // [rsp+0h] [rbp-10h] BYREF

v2 = *(_QWORD *)(a1 + 48);
result = 0LL;
if ( v2 )
{
v5 = 0LL;
v4 = assoc_array_binary_search(*(__int64 (__fastcall **)(__int64, _QWORD))a1, *(_QWORD **)(a1 + 8), v2, a2, &v5);
result = 0LL;
if ( !v4 )
{
*(_QWORD *)(a1 + 64) = v5;
result = a1 + 56;
}
}
return result;
}

original_code:
AssocArrayPair *
assoc_array_lookup(AssocArray *array, const void *key)
{
 ((void) (0));
 ((void) (0));
 if(array->count)
 {
  ssize_t offset = 0;
  if(!_assoc_array_binary_search(array->compare_keys, array->keys, array->count, key, &offset))
  {
   array->pair.offset = offset;
   return &array->pair;
  }
 }
 return ((void *)0);
}

canonical_original_code:
struct _AssocArrayPair *assoc_array_lookup(struct _AssocArray *array, void *key)
{
 ((void) (0));
 ((void) (0));
 if(array->count)
 {
  long offset = 0;
  if(!_assoc_array_binary_search(array->compare_keys, array->keys, array->count, key, &offset))
  {
   array->pair.offset = offset;
   return &array->pair;
  }
 }
 return ((void *)0);
}

variable_types:
array
struct _AssocArray *

return_type: struct _AssocArrayPair { struct _AssocArray { int (*compare_keys)(void *a, void *b); void **keys; void **values; void (*free_key)(void *p); void (*free_value)(void *p); unsigned long size; unsigned long count; struct _AssocArrayPair pair; } *array; long offset; } *


decompiled_code:
bool __fastcall assoc_array_key_exists(__int64 a1, __int64 a2)
{
__int64 v2; // rdx
bool result; // al
__int64 v4; // [rsp+0h] [rbp-10h] BYREF

v2 = *(_QWORD *)(a1 + 48);
result = 0;
if ( v2 )
{
v4 = 0LL;
result = (unsigned int)assoc_array_binary_search(
*(__int64 (__fastcall **)(__int64, _QWORD))a1,
*(_QWORD **)(a1 + 8),
v2,
a2,
&v4) == 0;
}
return result;
}

canonical_decompiled_code:
bool __fastcall func16(__int64 a1, __int64 a2)
{
__int64 v2; // rdx
bool result; // al
__int64 v4; // [rsp+0h] [rbp-10h] BYREF

v2 = *(_QWORD *)(a1 + 48);
result = 0;
if ( v2 )
{
v4 = 0LL;
result = (unsigned int)func0(
*(__int64 (__fastcall **)(__int64, _QWORD))a1,
*(_QWORD **)(a1 + 8),
v2,
a2,
&v4) == 0;
}
return result;
}

original_code:
_Bool
assoc_array_key_exists(const AssocArray *array, const void *key)
{
 ((void) (0));
 ((void) (0));
 if(array->count)
 {
  ssize_t offset = 0;
  return !_assoc_array_binary_search(array->compare_keys, array->keys, array->count, key, &offset);
 }
 return 0;
}

canonical_original_code:
_Bool assoc_array_key_exists(struct _AssocArray *array, void *key)
{
 ((void) (0));
 ((void) (0));
 if(array->count)
 {
  long offset = 0;
  return !_assoc_array_binary_search(array->compare_keys, array->keys, array->count, key, &offset);
 }
 return 0;
}


decompiled_code:
__int64 __fastcall assoc_array_count(__int64 a1)
{
return *(_QWORD *)(a1 + 48);
}

canonical_decompiled_code:
__int64 __fastcall func17(__int64 a1)
{
return *(_QWORD *)(a1 + 48);
}

original_code:
size_t
assoc_array_count(const AssocArray *array)
{
 ((void) (0));
 return array->count;
}

canonical_original_code:
unsigned long assoc_array_count(struct _AssocArray *array)
{
 ((void) (0));
 return array->count;
}

return_type: unsigned long


decompiled_code:
__int64 __fastcall assoc_array_size(__int64 a1)
{
return *(_QWORD *)(a1 + 40);
}

canonical_decompiled_code:
__int64 __fastcall func18(__int64 a1)
{
return *(_QWORD *)(a1 + 40);
}

original_code:
size_t
assoc_array_size(const AssocArray *array)
{
 ((void) (0));
 return array->size;
}

canonical_original_code:
unsigned long assoc_array_size(struct _AssocArray *array)
{
 ((void) (0));
 return array->size;
}


decompiled_code:
bool __fastcall assoc_array_iter_next(_QWORD *a1)
{
unsigned __int64 v1; // rax

v1 = a1[1] + 1LL;
a1[1] = v1;
return v1 < *(_QWORD *)(*a1 + 48LL);
}

canonical_decompiled_code:
bool __fastcall func20(_QWORD *a1)
{
unsigned __int64 v1; // rax

v1 = a1[1] + 1LL;
a1[1] = v1;
return v1 < *(_QWORD *)(*a1 + 48LL);
}

original_code:
_Bool
assoc_array_iter_next(AssocArrayIter *iter)
{
 ((void) (0));
 ++iter->offset;
 return (size_t)iter->offset < iter->array->count;
}

canonical_original_code:
_Bool assoc_array_iter_next(struct _AssocArrayPair *iter)
{
 ((void) (0));
 ++iter->offset;
 return (unsigned long)iter->offset < iter->array->count;
}

variable_types: struct _AssocArrayPair { struct _AssocArray { int (*compare_keys)(void *a, void *b); void **keys; void **values; void (*free_key)(void *p); void (*free_value)(void *p); unsigned long size; unsigned long count; struct _AssocArrayPair pair; } *array; long offset; } *


decompiled_code:
__int64 __fastcall assoc_array_iter_get_key(_QWORD *a1)
{
return *(_QWORD *)(*(_QWORD *)(*a1 + 8LL) + 8LL * a1[1]);
}

canonical_decompiled_code:
__int64 __fastcall func21(_QWORD *a1)
{
return *(_QWORD *)(*(_QWORD *)(*a1 + 8LL) + 8LL * a1[1]);
}

original_code:
void *
assoc_array_iter_get_key(const AssocArrayIter *iter)
{
 ((void) (0));
 return iter->array->keys[iter->offset];
}

canonical_original_code:
void *assoc_array_iter_get_key(struct _AssocArrayPair *iter)
{
 ((void) (0));
 return iter->array->keys[iter->offset];
}


decompiled_code:
__int64 __fastcall assoc_array_iter_get_value(_QWORD *a1)
{
return *(_QWORD *)(*(_QWORD *)(*a1 + 16LL) + 8LL * a1[1]);
}

canonical_decompiled_code:
__int64 __fastcall func22(_QWORD *a1)
{
return *(_QWORD *)(*(_QWORD *)(*a1 + 16LL) + 8LL * a1[1]);
}

original_code:
void *
assoc_array_iter_get_value(const AssocArrayIter *iter)
{
 ((void) (0));
 return iter->array->values[iter->offset];
}

canonical_original_code:
void *assoc_array_iter_get_value(struct _AssocArrayPair *iter)
{
 ((void) (0));
 return iter->array->values[iter->offset];
}


decompiled_code:
void __fastcall slist_free(_QWORD *a1)
{
_QWORD *v1; // rbx
_QWORD *v2; // rsi

v1 = (_QWORD *)*a1;
if ( *a1 )
{
do
{
v2 = v1;
v1 = (_QWORD *)v1[1];
slist_item_free((__int64)a1, v2);
}
while ( v1 );
}
}

canonical_decompiled_code:
void __fastcall func2(_QWORD *a1)
{
_QWORD *v1; // rbx
_QWORD *v2; // rsi

v1 = (_QWORD *)*a1;
if ( *a1 )
{
do
{
v2 = v1;
v1 = (_QWORD *)v1[1];
func0((__int64)a1, v2);
}
while ( v1 );
}
}

original_code:
void
slist_free(SList *list)
{
 ((void) (0));
 SListItem *iter = list->head;
 while(iter)
 {
  SListItem *item = iter;
  iter = iter->next;
  _slist_item_free(list, item);
 }
}

canonical_original_code:
void slist_free(struct _SList *list)
{
 ((void) (0));
 struct _SListItem *iter = list->head;
 while(iter)
 {
  struct _SListItem *item = iter;
  iter = iter->next;
  _slist_item_free(list, item);
 }
}

variable_types: struct _SList { struct _SListItem { void *data; struct _SListItem *next; } *head; struct _SListItem *tail; unsigned long count; int (*compare)(void *a, void *b); void (*free)(void *p); struct _Pool { void *(*alloc)(struct _Pool *pool); void (*free)(struct _Pool *pool, void *ptr); } *pool; } *

user_defined_types: struct _SList { struct _SListItem *head; struct _SListItem *tail; unsigned long count; int (*compare)(void *a, void *b); void (*free)(void *p); struct _Pool *pool; }


decompiled_code:
void __fastcall slist_destroy(void *ptr)
{
slist_free(ptr);
free(ptr);
}

canonical_decompiled_code:
void __fastcall func3(void *ptr)
{
func2(ptr);
free(ptr);
}

original_code:
void
slist_destroy(SList *list)
{
 ((void) (0));
 slist_free(list);
 free(list);
}

canonical_original_code:
void slist_destroy(struct _SList *list)
{
 ((void) (0));
 slist_free(list);
 free(list);
}

user_defined_types: struct _SListItem { void *data; struct _SListItem *next; }

user_defined_types: struct _Pool { void *(*alloc)(struct _Pool *pool); void (*free)(struct _Pool *pool, void *ptr); }


original_code:
void
slist_remove(SList *list, SListItem *item)
{
 ((void) (0));
 ((void) (0));
 ((void) (0));
 SListItem **ptr = &list->head;
 SListItem *tail = ((void *)0);
 _Bool found = 0;
 while(*ptr && !found)
 {
  if(*ptr == item)
  {
   found = 1;
   if(!item->next)
   {
    list->tail = tail;
   }
   *ptr = item->next;
   _slist_item_free(list, item);
   --list->count;
  }
  else
  {
   tail = *ptr;
   ptr = &(*ptr)->next;
  }
 }
}

canonical_original_code:
void slist_remove(struct _SList *list, struct _SListItem *item)
{
 ((void) (0));
 ((void) (0));
 ((void) (0));
 struct _SListItem **ptr = &list->head;
 struct _SListItem *tail = ((void *)0);
 _Bool found = 0;
 while(*ptr && !found)
 {
  if(*ptr == item)
  {
   found = 1;
   if(!item->next)
   {
    list->tail = tail;
   }
   *ptr = item->next;
   _slist_item_free(list, item);
   --list->count;
  }
  else
  {
   tail = *ptr;
   ptr = &(*ptr)->next;
  }
 }
}

variable_types:
item
struct _SListItem *

variable_types: struct _SListItem { void *data; struct _SListItem *next; } **


original_code:
void *
slist_pop(SList *list)
{
 ((void) (0));
 void *data = ((void *)0);
 SListItem *item = list->head;
 if(item)
 {
  list->head = item->next;
  if(!list->head)
  {
   list->tail = ((void *)0);
  }
  data = item->data;
  if(list->pool)
  {
   list->pool->free(list->pool, item);
  }
  else
  {
   free(item);
  }
  --list->count;
 }
 return data;
}

canonical_original_code:
void *slist_pop(struct _SList *list)
{
 ((void) (0));
 void *data = ((void *)0);
 struct _SListItem *item = list->head;
 if(item)
 {
  list->head = item->next;
  if(!list->head)
  {
   list->tail = ((void *)0);
  }
  data = item->data;
  if(list->pool)
  {
   list->pool->free(list->pool, item);
  }
  else
  {
   free(item);
  }
  --list->count;
 }
 return data;
}

variable_types:
data
void *

variable_types: struct _SListItem { void *data; struct _SListItem *next; } *


decompiled_code:
bool __fastcall slist_contains(__int64 a1, __int64 a2)
{
return slist_find(a1, 0LL, a2) != 0LL;
}

canonical_decompiled_code:
bool __fastcall func6(__int64 a1, __int64 a2)
{
return slist_find(a1, 0LL, a2) != 0LL;
}

original_code:
_Bool
slist_contains(const SList *list, const void *data)
{
 ((void) (0));
 ((void) (0));
 return _slist_find(list, ((void *)0), data) != ((void *)0);
}

canonical_original_code:
_Bool slist_contains(struct _SList *list, void *data)
{
 ((void) (0));
 ((void) (0));
 return _slist_find(list, ((void *)0), data) != ((void *)0);
}


decompiled_code:
__int64 __fastcall slist_count(__int64 a1)
{
return *(_QWORD *)(a1 + 16);
}

canonical_decompiled_code:
__int64 __fastcall func8(__int64 a1)
{
return *(_QWORD *)(a1 + 16);
}

original_code:
size_t
slist_count(const SList *list)
{
 ((void) (0));
 return list->count;
}

canonical_original_code:
unsigned long slist_count(struct _SList *list)
{
 ((void) (0));
 return list->count;
}


decompiled_code:
__int64 __fastcall slist_head(__int64 a1)
{
return *(_QWORD *)a1;
}

canonical_decompiled_code:
__int64 __fastcall func9(__int64 a1)
{
return *(_QWORD *)a1;
}

original_code:
SListItem *
slist_head(const SList *list)
{
 ((void) (0));
 return list->head;
}

canonical_original_code:
struct _SListItem *slist_head(struct _SList *list)
{
 ((void) (0));
 return list->head;
}

variable_types: struct _SList { struct _SListItem *head; struct _SListItem *tail; unsigned long count; int (*compare)(void *a, void *b); void (*free)(void *p); struct _Pool { void *(*alloc)(struct _Pool *pool); void (*free)(struct _Pool *pool, void *ptr); } *pool; } *

return_type: struct _SListItem { void *data; struct _SListItem *next; } *


decompiled_code:
bool __fastcall slist_empty(_QWORD *a1)
{
return *a1 == 0LL;
}

canonical_decompiled_code:
bool __fastcall func10(_QWORD *a1)
{
return *a1 == 0LL;
}

original_code:
_Bool
slist_empty(const SList *list)
{
 ((void) (0));
 return list->head == ((void *)0);
}

canonical_original_code:
_Bool slist_empty(struct _SList *list)
{
 ((void) (0));
 return list->head == ((void *)0);
}


decompiled_code:
void __fastcall list_free(_QWORD *a1)
{
_QWORD *v1; // rbx
_QWORD *v2; // rsi

v1 = (_QWORD *)*a1;
if ( *a1 )
{
do
{
v2 = v1;
v1 = (_QWORD *)v1[1];
list_item_free((__int64)a1, v2);
}
while ( v1 );
}
}

canonical_decompiled_code:
void __fastcall func3(_QWORD *a1)
{
_QWORD *v1; // rbx
_QWORD *v2; // rsi

v1 = (_QWORD *)*a1;
if ( *a1 )
{
do
{
v2 = v1;
v1 = (_QWORD *)v1[1];
func1((__int64)a1, v2);
}
while ( v1 );
}
}

original_code:
void
list_free(List *list)
{
 ((void) (0));
 ListItem *iter = list->head;
 while(iter)
 {
  ListItem *item = iter;
  iter = iter->next;
  _list_item_free(list, item);
 }
}

canonical_original_code:
void list_free(struct List *list)
{
 ((void) (0));
 struct _ListItem *iter = list->head;
 while(iter)
 {
  struct _ListItem *item = iter;
  iter = iter->next;
  _list_item_free(list, item);
 }
}

variable_types: struct List { struct _ListItem { void *data; struct _ListItem *next; struct _ListItem *prev; } *head; struct _ListItem *tail; unsigned long count; int (*compare)(void *a, void *b); void (*free)(void *p); struct _Pool { void *(*alloc)(struct _Pool *pool); void (*free)(struct _Pool *pool, void *ptr); } *pool; } *

user_defined_types: struct List { struct _ListItem *head; struct _ListItem *tail; unsigned long count; int (*compare)(void *a, void *b); void (*free)(void *p); struct _Pool *pool; }


decompiled_code:
void __fastcall list_destroy(void *ptr)
{
list_free(ptr);
free(ptr);
}

canonical_decompiled_code:
void __fastcall func4(void *ptr)
{
func3(ptr);
free(ptr);
}

original_code:
void
list_destroy(List *list)
{
 ((void) (0));
 list_free(list);
 free(list);
}

canonical_original_code:
void list_destroy(struct List *list)
{
 ((void) (0));
 list_free(list);
 free(list);
}

user_defined_types: struct _ListItem { void *data; struct _ListItem *next; struct _ListItem *prev; }


decompiled_code:
void __fastcall list_remove_by_data(__int64 a1, __int64 a2, char a3)
{
_QWORD *v4; // rbx
_QWORD *v5; // rbp
char v6; // r12

v4 = *(_QWORD **)a1;
if ( *(_QWORD *)a1 )
{
do
{
v5 = v4;
v4 = (_QWORD *)v4[1];
v6 = 0;
if ( !(*(unsigned int (__fastcall **)(_QWORD, __int64))(a1 + 24))(*v5, a2) )
{
v6 = a3 ^ 1;
list_remove((_QWORD *)a1, v5);
}
}
while ( v4 && v6 != 1 );
}
}

original_code:
void
list_remove_by_data(List *list, void *data, _Bool remove_all)
{
 ((void) (0));
 ((void) (0));
 ListItem *iter = list->head;
 _Bool completed = 0;
 while(iter && !completed)
 {
  ListItem *next = iter->next;
  if(!list->compare(iter->data, data))
  {
   completed = !remove_all;
   list_remove(list, iter);
  }
  iter = next;
 }
}

canonical_original_code:
void list_remove_by_data(struct List *list, void *data, _Bool remove_all)
{
 ((void) (0));
 ((void) (0));
 struct _ListItem *iter = list->head;
 _Bool completed = 0;
 while(iter && !completed)
 {
  struct _ListItem *next = iter->next;
  if(!list->compare(iter->data, data))
  {
   completed = !remove_all;
   list_remove(list, iter);
  }
  iter = next;
 }
}

variable_types: struct _ListItem { void *data; struct _ListItem *next; struct _ListItem *prev; } *


original_code:
void *
list_pop(List *list)
{
 ((void) (0));
 ListItem *item = list->head;
 void *data = ((void *)0);
 if(item)
 {
  list->head = item->next;
  if(list->head)
  {
   list->head->prev = ((void *)0);
  }
  else
  {
   list->tail = ((void *)0);
  }
  data = item->data;
  if(list->pool)
  {
   list->pool->free(list->pool, item);
  }
  else
  {
   free(item);
  }
  --list->count;
 }
 return data;
}

canonical_original_code:
void *list_pop(struct List *list)
{
 ((void) (0));
 struct _ListItem *item = list->head;
 void *data = ((void *)0);
 if(item)
 {
  list->head = item->next;
  if(list->head)
  {
   list->head->prev = ((void *)0);
  }
  else
  {
   list->tail = ((void *)0);
  }
  data = item->data;
  if(list->pool)
  {
   list->pool->free(list->pool, item);
  }
  else
  {
   free(item);
  }
  --list->count;
 }
 return data;
}


decompiled_code:
bool __fastcall list_contains(__int64 a1, __int64 a2)
{
return list_find(a1, 0LL, a2) != 0LL;
}

canonical_decompiled_code:
bool __fastcall func8(__int64 a1, __int64 a2)
{
return list_find(a1, 0LL, a2) != 0LL;
}

original_code:
_Bool
list_contains(const List *list, const void *data)
{
 ((void) (0));
 ((void) (0));
 return _list_find(list, ((void *)0), data) != ((void *)0);
}

canonical_original_code:
_Bool list_contains(struct List *list, void *data)
{
 ((void) (0));
 ((void) (0));
 return _list_find(list, ((void *)0), data) != ((void *)0);
}


decompiled_code:
__int64 __fastcall list_head(__int64 a1)
{
return *(_QWORD *)a1;
}

canonical_decompiled_code:
__int64 __fastcall func10(__int64 a1)
{
return *(_QWORD *)a1;
}

original_code:
ListItem *
list_head(const List *list)
{
 ((void) (0));
 return list->head;
}

canonical_original_code:
struct _ListItem *list_head(struct List *list)
{
 ((void) (0));
 return list->head;
}

variable_types: struct List { struct _ListItem *head; struct _ListItem *tail; unsigned long count; int (*compare)(void *a, void *b); void (*free)(void *p); struct _Pool { void *(*alloc)(struct _Pool *pool); void (*free)(struct _Pool *pool, void *ptr); } *pool; } *

return_type: struct _ListItem { void *data; struct _ListItem *next; struct _ListItem *prev; } *


decompiled_code:
__int64 __fastcall list_tail(__int64 a1)
{
return *(_QWORD *)(a1 + 8);
}

canonical_decompiled_code:
__int64 __fastcall func11(__int64 a1)
{
return *(_QWORD *)(a1 + 8);
}

original_code:
ListItem *
list_tail(const List *list)
{
 ((void) (0));
 return list->tail;
}

canonical_original_code:
struct _ListItem *list_tail(struct List *list)
{
 ((void) (0));
 return list->tail;
}


decompiled_code:
__int64 __fastcall list_count(__int64 a1)
{
return *(_QWORD *)(a1 + 16);
}

canonical_decompiled_code:
__int64 __fastcall func12(__int64 a1)
{
return *(_QWORD *)(a1 + 16);
}

original_code:
size_t
list_count(const List *list)
{
 ((void) (0));
 return list->count;
}

canonical_original_code:
unsigned long list_count(struct List *list)
{
 ((void) (0));
 return list->count;
}


decompiled_code:
bool __fastcall list_empty(_QWORD *a1)
{
return *a1 == 0LL;
}

canonical_decompiled_code:
bool __fastcall func13(_QWORD *a1)
{
return *a1 == 0LL;
}

original_code:
_Bool
list_empty(const List *list)
{
 ((void) (0));
 return list->head == ((void *)0);
}

canonical_original_code:
_Bool list_empty(struct List *list)
{
 ((void) (0));
 return list->head == ((void *)0);
}


decompiled_code:
__int64 __fastcall stack_pop(__int64 a1, __int64 *a2)
{
__int64 result; // rax
__int64 v3; // rdx

if ( slist_count() )
{
v3 = slist_pop(a1);
result = 1LL;
if ( a2 )
*a2 = v3;
}
else
{
result = 0LL;
if ( a2 )
*a2 = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 *a2)
{
__int64 result; // rax
__int64 v3; // rdx

if ( slist_count() )
{
v3 = slist_pop(a1);
result = 1LL;
if ( a2 )
*a2 = v3;
}
else
{
result = 0LL;
if ( a2 )
*a2 = 0LL;
}
return result;
}

original_code:
_Bool
stack_pop(Stack *stack, void **data)
{
 ((void) (0));
 ((void) (0));
 _Bool success = 0;
 if(slist_count(stack))
 {
  void *ptr = slist_pop(stack);
  if(data)
  {
   *data = ptr;
  }
  success = 1;
 }
 else if(data)
 {
  *data = ((void *)0);
 }
 return success;
}

canonical_original_code:
_Bool stack_pop(struct _SList *stack, void **data)
{
 ((void) (0));
 ((void) (0));
 _Bool success = 0;
 if(slist_count(stack))
 {
  void *ptr = slist_pop(stack);
  if(data)
  {
   *data = ptr;
  }
  success = 1;
 }
 else if(data)
 {
  *data = ((void *)0);
 }
 return success;
}

variable_types:
data
void **

variable_types:
ptr
void *


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

v2 = (_QWORD *)slist_head();
v3 = 0;
if ( v2 )
{
*a2 = *v2;
v3 = 1;
}
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, _QWORD *a2)
{
_QWORD *v2; // rax
unsigned int v3; // edx

v2 = (_QWORD *)slist_head();
v3 = 0;
if ( v2 )
{
*a2 = *v2;
v3 = 1;
}
return v3;
}

original_code:
_Bool
stack_head(const Stack *stack, void **data)
{
 ((void) (0));
 ((void) (0));
 SListItem *iter = slist_head(stack);
 _Bool success = 0;
 if(iter)
 {
  *data = iter->data;
  success = 1;
 }
 return success;
}

canonical_original_code:
_Bool stack_head(struct _SList *stack, void **data)
{
 ((void) (0));
 ((void) (0));
 struct _SListItem *iter = slist_head(stack);
 _Bool success = 0;
 if(iter)
 {
  *data = iter->data;
  success = 1;
 }
 return success;
}


original_code:
void
hashtable_init(HashTable *table, size_t size, HashFunc hash_func, EqualFunc compare_keys, FreeFunc free_key, FreeFunc free_value)
{
 ((void) (0));
 ((void) (0));
 ((void) (0));
 ((void) (0));
 size_t table_size = 257;
 if(size != 0)
 {
  table_size = size;
 }
 table->buckets = (struct _Bucket **)calloc(table_size, sizeof(struct _Bucket *));
 if(!table->buckets)
 {
  perror("calloc()");
  abort();
 }
 table->pool = (Pool *)memory_pool_new(sizeof(struct _Bucket), 128);
 table->compare_keys = compare_keys;
 table->free_key = free_key;
 table->free_value = free_value;
 table->size = table_size;
 if(size == 0)
 {
  table->grow = 1;
  table->sizeptr = PRIMES;
 }
 else
 {
  table->grow = 0;
  table->sizeptr = ((void *)0);
 }
 table->hash = hash_func;
 table->count = 0;
 table->pair.free_value = free_value;
 table->pair.bucket = ((void *)0);
}

canonical_original_code:
void hashtable_init(struct _HashTable *table, unsigned long size, unsigned int (*hash_func)(void *ptr), _Bool (*compare_keys)(void *a, void *b), void (*free_key)(void *p), void (*free_value)(void *p))
{
 ((void) (0));
 ((void) (0));
 ((void) (0));
 ((void) (0));
 unsigned long table_size = 257;
 if(size != 0)
 {
  table_size = size;
 }
 table->buckets = (struct _Bucket **)calloc(table_size, sizeof(struct _Bucket *));
 if(!table->buckets)
 {
  perror("calloc()");
  abort();
 }
 table->pool = (struct _Pool *)memory_pool_new(sizeof(struct _Bucket), 128);
 table->compare_keys = compare_keys;
 table->free_key = free_key;
 table->free_value = free_value;
 table->size = table_size;
 if(size == 0)
 {
  table->grow = 1;
  table->sizeptr = PRIMES;
 }
 else
 {
  table->grow = 0;
  table->sizeptr = ((void *)0);
 }
 table->hash = hash_func;
 table->count = 0;
 table->pair.free_value = free_value;
 table->pair.bucket = ((void *)0);
}

variable_types: struct _HashTable { _Bool (*compare_keys)(void *a, void *b); void (*free_key)(void *p); void (*free_value)(void *p); unsigned int (*hash)(void *ptr); unsigned long size; unsigned long *sizeptr; _Bool grow; struct _Bucket { void *key; void *data; struct _Bucket *next; } **buckets; unsigned long count; struct _Pool { void *(*alloc)(struct _Pool *pool); void (*free)(struct _Pool *pool, void *ptr); } *pool; struct _HashTablePair { void (*free_value)(void *p); struct _Bucket *bucket; } pair; } *

variable_types:
size
unsigned long

user_defined_types: struct _HashTable { _Bool (*compare_keys)(void *a, void *b); void (*free_key)(void *p); void (*free_value)(void *p); unsigned int (*hash)(void *ptr); unsigned long size; unsigned long *sizeptr; _Bool grow; struct _Bucket **buckets; unsigned long count; struct _Pool *pool; struct _HashTablePair pair; }


decompiled_code:
void __fastcall hashtable_free(__int64 a1)
{
hashtable_free_memory((_QWORD *)a1);
memory_pool_destroy(*(_QWORD *)(a1 + 72));
free(*(void **)(a1 + 56));
}

canonical_decompiled_code:
void __fastcall func5(__int64 a1)
{
func0((_QWORD *)a1);
memory_pool_destroy(*(_QWORD *)(a1 + 72));
free(*(void **)(a1 + 56));
}

original_code:
void
hashtable_free(HashTable *table)
{
 ((void) (0));
 _hashtable_free_memory(table);
 memory_pool_destroy((MemoryPool *)table->pool);
 free(table->buckets);
}

canonical_original_code:
void hashtable_free(struct _HashTable *table)
{
 ((void) (0));
 _hashtable_free_memory(table);
 memory_pool_destroy((struct MemoryPool *)table->pool);
 free(table->buckets);
}

user_defined_types: struct MemoryPool { struct _Pool padding; struct _MemoryBlock *block; struct _MemoryPtrBlock *free_block; unsigned long block_size; unsigned long item_size; }

user_defined_types: struct _HashTablePair { void (*free_value)(void *p); struct _Bucket *bucket; }

user_defined_types: struct _MemoryBlock { char *items; unsigned long offset; struct _MemoryBlock *next; }

user_defined_types: struct _MemoryPtrBlock { void **items; unsigned long offset; struct _MemoryPtrBlock *next; }

user_defined_types: struct _Bucket { void *key; void *data; struct _Bucket *next; }


decompiled_code:
void __fastcall hashtable_destroy(void *ptr)
{
hashtable_free((__int64)ptr);
free(ptr);
}

canonical_decompiled_code:
void __fastcall func6(void *ptr)
{
func5((__int64)ptr);
free(ptr);
}

original_code:
void
hashtable_destroy(HashTable *table)
{
 ((void) (0));
 hashtable_free(table);
 free(table);
}

canonical_original_code:
void hashtable_destroy(struct _HashTable *table)
{
 ((void) (0));
 hashtable_free(table);
 free(table);
}


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

*(_QWORD *)(a1 + 64) = 0LL;
hashtable_free_memory((_QWORD *)a1);
memset(*(void **)(a1 + 56), 0, 8LL * *(_QWORD *)(a1 + 32));
memory_pool_destroy(*(_QWORD *)(a1 + 72));
result = memory_pool_new(24LL, 128LL);
*(_QWORD *)(a1 + 72) = result;
return result;
}

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

*(_QWORD *)(a1 + 64) = 0LL;
func0((_QWORD *)a1);
memset(*(void **)(a1 + 56), 0, 8LL * *(_QWORD *)(a1 + 32));
memory_pool_destroy(*(_QWORD *)(a1 + 72));
result = memory_pool_new(24LL, 128LL);
*(_QWORD *)(a1 + 72) = result;
return result;
}

original_code:
void
hashtable_clear(HashTable *table)
{
 ((void) (0));
 table->count = 0;
 _hashtable_free_memory(table);
 memset(table->buckets, 0, sizeof(struct _Bucket *) * table->size);
 memory_pool_destroy((MemoryPool *)table->pool);
 table->pool = (Pool *)memory_pool_new(sizeof(struct _Bucket), 128);
}

canonical_original_code:
void hashtable_clear(struct _HashTable *table)
{
 ((void) (0));
 table->count = 0;
 _hashtable_free_memory(table);
 memset(table->buckets, 0, sizeof(struct _Bucket *) * table->size);
 memory_pool_destroy((struct MemoryPool *)table->pool);
 table->pool = (struct _Pool *)memory_pool_new(sizeof(struct _Bucket), 128);
}


original_code:
HashTableInsertResult
hashtable_set(HashTable *table, void *key, void *value, _Bool overwrite_key)
{
 HashTableInsertResult result = HASHTABLE_INSERT_RESULT_FAILED;
 ((void) (0));
 ((void) (0));
 if(table->grow && table->count > table->size)
 {
  _hashtable_resize(table);
 }
 size_t index = table->hash(key) % table->size;
 struct _Bucket *head = table->buckets[index];
 struct _Bucket *item = _hashtable_find_bucket(table, head, key);
 if(item)
 {
  result = HASHTABLE_INSERT_RESULT_REPLACED;
  if(overwrite_key)
  {
   if(table->free_key)
   {
    table->free_key(item->key);
   }
   item->key = key;
  }
  if(table->free_value && item->data)
  {
   table->free_value(item->data);
  }
  item->data = value;
 }
 else if(table->count < (18446744073709551615UL))
 {
  result = HASHTABLE_INSERT_RESULT_NEW;
  item = (struct _Bucket *)table->pool->alloc(table->pool);
  item->key = key;
  item->data = value;
  table->buckets[index] = item;
  item->next = head;
  ++table->count;
 }
 else
 {
  fprintf(stderr, "%s(): integer overflow.\n", __func__);
 }
 return result;
}

canonical_original_code:
enum HashTableInsertResult hashtable_set(struct _HashTable *table, void *key, void *value, _Bool overwrite_key)
{
 enum HashTableInsertResult result = HASHTABLE_INSERT_RESULT_FAILED;
 ((void) (0));
 ((void) (0));
 if(table->grow && table->count > table->size)
 {
  _hashtable_resize(table);
 }
 unsigned long index = table->hash(key) % table->size;
 struct _Bucket *head = table->buckets[index];
 struct _Bucket *item = _hashtable_find_bucket(table, head, key);
 if(item)
 {
  result = HASHTABLE_INSERT_RESULT_REPLACED;
  if(overwrite_key)
  {
   if(table->free_key)
   {
    table->free_key(item->key);
   }
   item->key = key;
  }
  if(table->free_value && item->data)
  {
   table->free_value(item->data);
  }
  item->data = value;
 }
 else if(table->count < (18446744073709551615UL))
 {
  result = HASHTABLE_INSERT_RESULT_NEW;
  item = (struct _Bucket *)table->pool->alloc(table->pool);
  item->key = key;
  item->data = value;
  table->buckets[index] = item;
  item->next = head;
  ++table->count;
 }
 else
 {
  fprintf(stderr, "%s(): integer overflow.\n", __func__);
 }
 return result;
}

variable_types:
key
void *

variable_types:
value
void *

variable_types: enum HashTableInsertResult { HASHTABLE_INSERT_RESULT_NEW=0, HASHTABLE_INSERT_RESULT_REPLACED=1, HASHTABLE_INSERT_RESULT_FAILED=2 }

variable_types:
index
unsigned long

variable_types: struct _Bucket { void *key; void *data; struct _Bucket *next; } *


decompiled_code:
__int64 __fastcall hashtable_pair_get_key(__int64 a1)
{
return **(_QWORD **)(a1 + 8);
}

canonical_decompiled_code:
__int64 __fastcall func10(__int64 a1)
{
return **(_QWORD **)(a1 + 8);
}

original_code:
void *
hashtable_pair_get_key(const HashTablePair *pair)
{
 ((void) (0));
 ((void) (0));
 ((void) (0));
 return pair->bucket->key;
}

canonical_original_code:
void *hashtable_pair_get_key(struct _HashTablePair *pair)
{
 ((void) (0));
 ((void) (0));
 ((void) (0));
 return pair->bucket->key;
}

variable_types: struct _HashTablePair { void (*free_value)(void *p); struct _Bucket { void *key; void *data; struct _Bucket *next; } *bucket; } *


decompiled_code:
__int64 __fastcall hashtable_pair_get_value(__int64 a1)
{
return *(_QWORD *)(*(_QWORD *)(a1 + 8) + 8LL);
}

canonical_decompiled_code:
__int64 __fastcall func11(__int64 a1)
{
return *(_QWORD *)(*(_QWORD *)(a1 + 8) + 8LL);
}

original_code:
void *
hashtable_pair_get_value(const HashTablePair *pair)
{
 ((void) (0));
 ((void) (0));
 ((void) (0));
 return pair->bucket->data;
}

canonical_original_code:
void *hashtable_pair_get_value(struct _HashTablePair *pair)
{
 ((void) (0));
 ((void) (0));
 ((void) (0));
 return pair->bucket->data;
}


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

if ( *(_QWORD *)a1 && *(_QWORD *)(*(_QWORD *)(a1 + 8) + 8LL) )
(*(void (**)(void))a1)();
result = *(_QWORD *)(a1 + 8);
*(_QWORD *)(result + 8) = a2;
return result;
}

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

if ( *(_QWORD *)a1 && *(_QWORD *)(*(_QWORD *)(a1 + 8) + 8LL) )
(*(void (**)(void))a1)();
result = *(_QWORD *)(a1 + 8);
*(_QWORD *)(result + 8) = a2;
return result;
}

original_code:
void
hashtable_pair_set_value(HashTablePair *pair, void *value)
{
 ((void) (0));
 ((void) (0));
 ((void) (0));
 if(pair->free_value && pair->bucket->data)
 {
  pair->free_value(pair->bucket->data);
 }
 pair->bucket->data = value;
}

canonical_original_code:
void hashtable_pair_set_value(struct _HashTablePair *pair, void *value)
{
 ((void) (0));
 ((void) (0));
 ((void) (0));
 if(pair->free_value && pair->bucket->data)
 {
  pair->free_value(pair->bucket->data);
 }
 pair->bucket->data = value;
}