decompiled_code:
void *__fastcall module_dump_c(char *a1)
{
__int64 v1; // r14
__int64 v2; // rbp
char v3; // al
__int64 v4; // r13
__int64 v5; // r12
__int64 v6; // rbp
__int64 v7; // r14
unsigned __int8 *v8; // rax
int v9; // er13
unsigned __int16 *v10; // rax
__int64 v11; // rbp
unsigned int v12; // er13
__int64 v13; // rax
_QWORD *v14; // rax
unsigned __int16 *v15; // rax
__int64 v16; // rbp
unsigned int v17; // eax
__int64 v18; // r12
char *v19; // r12
int i; // ebp
unsigned __int8 *v21; // r12
int j; // ebp
unsigned __int8 *v23; // r12
int k; // ebp
unsigned __int8 *v25; // rbx
int l; // ebp
void *result; // rax
__int64 v28; // [rsp+0h] [rbp-68h]
__int64 v29[2]; // [rsp+10h] [rbp-58h] BYREF
int v30; // [rsp+20h] [rbp-48h]

v30 = 0;
v29[1] = 0LL;
v29[0] = 0LL;
puts("#ifndef _CONSTMOD_H\n#define _CONSTMOD_H\n\n#include \"module.h\"");
if ( *((_WORD *)a1 + 55) )
{
v1 = 0LL;
do
{
printf("const int8_t sample_data_%02i[] = {", (unsigned int)v1);
v4 = 80 * v1;
if ( *(_DWORD *)(*((_QWORD *)a1 + 47) + 80 * v1 + 32) )
{
v2 = 0LL;
do
{
if ( (v2 & 0xF) == 0 )
putchar(10);
v3 = sample_to_s8(*(_WORD *)(*(_QWORD *)(*((_QWORD *)a1 + 47) + v4 + 72) + 2 * v2));
printf("%6i", (unsigned int)v3);
if ( *(_DWORD *)(*((_QWORD *)a1 + 47) + v4 + 32) > (unsigned int)(v2 + 1) )
printf(", ");
++v2;
}
while ( *(_DWORD *)(*((_QWORD *)a1 + 47) + v4 + 32) > (unsigned int)v2 );
}
puts("};\n");
++v1;
}
while ( *((unsigned __int16 *)a1 + 55) > (int)v1 );
}
printf("const module_sample_t samples[] = { ");
if ( *((_WORD *)a1 + 55) )
{
v5 = 0LL;
do
{
puts("\t{ ");
printf("\t\t.header.length = %u,\n", *(unsigned int *)(*((_QWORD *)a1 + 47) + 80 * v5 + 32));
printf("\t\t.header.finetune = %i,\n", (unsigned int)*(char *)(*((_QWORD *)a1 + 47) + 80 * v5 + 36));
printf("\t\t.header.c2spd = %u,\n", *(unsigned __int16 *)(*((_QWORD *)a1 + 47) + 80 * v5 + 38));
printf("\t\t.header.volume = %u,\n", *(unsigned __int8 *)(*((_QWORD *)a1 + 47) + 80 * v5 + 40));
printf("\t\t.header.loop_enabled = %u,\n", *(unsigned __int8 *)(*((_QWORD *)a1 + 47) + 80 * v5 + 41));
printf("\t\t.header.loop_start = %u,\n", *(unsigned int *)(*((_QWORD *)a1 + 47) + 80 * v5 + 44));
printf("\t\t.header.loop_length = %u,\n", *(unsigned int *)(*((_QWORD *)a1 + 47) + 80 * v5 + 48));
printf("\t\t.header.loop_end = %u,\n", *(unsigned int *)(*((_QWORD *)a1 + 47) + 80 * v5 + 52));
printf("\t\t.data = sample_data_%02i\n", (unsigned int)v5);
puts("\t},");
++v5;
}
while ( *((unsigned __int16 *)a1 + 55) > (int)v5 );
}
puts("};");
v28 = 0LL;
if ( *((_WORD *)a1 + 57) )
{
do
{
v18 = 16 * v28;
v10 = (unsigned __int16 *)(*((_QWORD *)a1 + 49) + 16 * v28);
v11 = 0LL;
if ( *v10 )
{
do
{
v12 = MurmurHash2A(
*(_QWORD *)(*((_QWORD *)v10 + 1) + 8 * v11),
12 * (unsigned int)*((unsigned __int16 *)a1 + 54),
3735928559LL);
v13 = v29[0];
if ( v29[0] )
{
while ( *(_DWORD *)(v13 + 16) != (unsigned __int64)v12 )
{
v13 = *(_QWORD *)v13;
if ( !v13 )
goto LABEL_24;
}
}
else
{
LABEL_24:
v14 = malloc(0x18uLL);
v14[1] = 0LL;
*v14 = 0LL;
v14[2] = v12;
dllist_push(v29);
printf("const module_pattern_data_t pattern_data_%08x[] = {", v12);
v7 = 0LL;
v9 = 0;
if ( *((_WORD *)a1 + 54) )
{
do
{
v8 = (unsigned __int8 *)(*(_QWORD *)(*(_QWORD *)(*((_QWORD *)a1 + 49) + v18 + 8) + 8 * v11) + v7);
printf(
"{.sample_num=%3u, .period_index=%6i, .volume=%4i, .effect_num=%3u, .effect_value=%3u }",
*v8,
*((unsigned int *)v8 + 1),
(unsigned int)(char)v8[8],
v8[9],
v8[10]);
if ( ++v9 >= *((unsigned __int16 *)a1 + 54) )
break;
printf(", ");
v7 += 12LL;
}
while ( v9 < *((unsigned __int16 *)a1 + 54) );
}
puts("};");
}
v10 = (unsigned __int16 *)(*((_QWORD *)a1 + 49) + v18);
++v11;
}
while ( *v10 > (int)v11 );
}
printf("const module_pattern_row_t pattern_rows_%02i[] = {\n", (unsigned int)v28);
v15 = (unsigned __int16 *)(*((_QWORD *)a1 + 49) + v18);
if ( *v15 )
{
v16 = 0LL;
do
{
v17 = MurmurHash2A(
*(_QWORD *)(*((_QWORD *)v15 + 1) + 8 * v16),
12 * (unsigned int)*((unsigned __int16 *)a1 + 54),
3735928559LL);
printf("{ .data = pattern_data_%08x }", v17);
if ( *(unsigned __int16 *)(*((_QWORD *)a1 + 49) + 16 * v28) <= (int)v16 + 1 )
break;
printf(", ");
v15 = (unsigned __int16 *)(*((_QWORD *)a1 + 49) + v18);
++v16;
}
while ( *v15 > (int)v16 );
}
puts("\n};\n");
++v28;
}
while ( *((unsigned __int16 *)a1 + 57) > (int)v28 );
}
puts("const module_pattern_t patterns[] = {");
if ( *((_WORD *)a1 + 57) )
{
v6 = 0LL;
do
{
printf(
"{ .num_rows = %03u, .rows = pattern_rows_%02i }",
*(unsigned __int16 *)(*((_QWORD *)a1 + 49) + 16 * v6),
(unsigned int)v6);
if ( (int)v6 + 1 >= *((unsigned __int16 *)a1 + 57) )
break;
printf(", ");
++v6;
}
while ( *((unsigned __int16 *)a1 + 57) > (int)v6 );
}
puts("};");
puts("const module_t static_module = {");
printf("\t.song_title = { ");
v19 = a1;
for ( i = 1; ; ++i )
{
printf(" %3i", (unsigned int)*v19);
if ( i - 1 > 19 )
break;
printf(", ");
LABEL_40:
++v19;
}
if ( i <= 20 )
goto LABEL_40;
puts("},");
printf("\t.module_type = %i,\n", *((unsigned int *)a1 + 26));
printf("\t.num_channels = %u,\n", *((unsigned __int16 *)a1 + 54));
printf("\t.num_samples = %u,\n", *((unsigned __int16 *)a1 + 55));
printf("\t.num_instruments = %u,\n", *((unsigned __int16 *)a1 + 56));
printf("\t.num_patterns = %u,\n", *((unsigned __int16 *)a1 + 57));
printf("\t.num_orders = %u,\n", *((unsigned __int16 *)a1 + 58));
printf("\t.orders = { ");
v21 = (unsigned __int8 *)(a1 + 118);
for ( j = 1; ; ++j )
{
printf(" %3u", *v21);
if ( j - 1 <= 254 )
{
printf(", ");
goto LABEL_39;
}
if ( j > 255 )
break;
LABEL_39:
++v21;
}
puts("},");
puts("\t.samples = samples,");
puts("\t.patterns = patterns,");
printf("\t.initial_speed = %u,\n", (unsigned __int8)a1[400]);
printf("\t.initial_bpm = %u,\n", (unsigned __int8)a1[401]);
printf("\t.initial_master_volume = %u,\n", (unsigned __int8)a1[402]);
printf("\t.mix_volume = %u,\n", (unsigned __int8)a1[403]);
printf("\t.initial_panning = { ");
v23 = (unsigned __int8 *)(a1 + 404);
for ( k = 1; ; ++k )
{
printf(" %3u", *v23);
if ( k - 1 > 62 )
break;
printf(", ");
LABEL_47:
++v23;
}
if ( k <= 63 )
goto LABEL_47;
puts("},");
printf("\t.channel_volume = { ");
v25 = (unsigned __int8 *)(a1 + 468);
for ( l = 1; ; ++l )
{
printf(" %3u", *v25);
if ( l - 1 > 62 )
break;
printf(", ");
LABEL_52:
++v25;
}
if ( l <= 63 )
goto LABEL_52;
puts("}");
puts("};");
printf("#endif");
while ( 1 )
{
result = (void *)dllist_pop(v29);
if ( !result )
break;
free(result);
}
return result;
}

canonical_decompiled_code:
void *__fastcall func1(char *a1)
{
__int64 v1; // r14
__int64 v2; // rbp
char v3; // al
__int64 v4; // r13
__int64 v5; // r12
__int64 v6; // rbp
__int64 v7; // r14
unsigned __int8 *v8; // rax
int v9; // er13
unsigned __int16 *v10; // rax
__int64 v11; // rbp
unsigned int v12; // er13
__int64 v13; // rax
_QWORD *v14; // rax
unsigned __int16 *v15; // rax
__int64 v16; // rbp
unsigned int v17; // eax
__int64 v18; // r12
char *v19; // r12
int i; // ebp
unsigned __int8 *v21; // r12
int j; // ebp
unsigned __int8 *v23; // r12
int k; // ebp
unsigned __int8 *v25; // rbx
int l; // ebp
void *result; // rax
__int64 v28; // [rsp+0h] [rbp-68h]
__int64 v29[2]; // [rsp+10h] [rbp-58h] BYREF
int v30; // [rsp+20h] [rbp-48h]

v30 = 0;
v29[1] = 0LL;
v29[0] = 0LL;
puts("#ifndef _CONSTMOD_H\n#define _CONSTMOD_H\n\n#include \"module.h\"");
if ( *((_WORD *)a1 + 55) )
{
v1 = 0LL;
do
{
printf("const int8_t sample_data_%02i[] = {", (unsigned int)v1);
v4 = 80 * v1;
if ( *(_DWORD *)(*((_QWORD *)a1 + 47) + 80 * v1 + 32) )
{
v2 = 0LL;
do
{
if ( (v2 & 0xF) == 0 )
putchar(10);
v3 = func0(*(_WORD *)(*(_QWORD *)(*((_QWORD *)a1 + 47) + v4 + 72) + 2 * v2));
printf("%6i", (unsigned int)v3);
if ( *(_DWORD *)(*((_QWORD *)a1 + 47) + v4 + 32) > (unsigned int)(v2 + 1) )
printf(", ");
++v2;
}
while ( *(_DWORD *)(*((_QWORD *)a1 + 47) + v4 + 32) > (unsigned int)v2 );
}
puts("};\n");
++v1;
}
while ( *((unsigned __int16 *)a1 + 55) > (int)v1 );
}
printf("const module_sample_t samples[] = { ");
if ( *((_WORD *)a1 + 55) )
{
v5 = 0LL;
do
{
puts("\t{ ");
printf("\t\t.header.length = %u,\n", *(unsigned int *)(*((_QWORD *)a1 + 47) + 80 * v5 + 32));
printf("\t\t.header.finetune = %i,\n", (unsigned int)*(char *)(*((_QWORD *)a1 + 47) + 80 * v5 + 36));
printf("\t\t.header.c2spd = %u,\n", *(unsigned __int16 *)(*((_QWORD *)a1 + 47) + 80 * v5 + 38));
printf("\t\t.header.volume = %u,\n", *(unsigned __int8 *)(*((_QWORD *)a1 + 47) + 80 * v5 + 40));
printf("\t\t.header.loop_enabled = %u,\n", *(unsigned __int8 *)(*((_QWORD *)a1 + 47) + 80 * v5 + 41));
printf("\t\t.header.loop_start = %u,\n", *(unsigned int *)(*((_QWORD *)a1 + 47) + 80 * v5 + 44));
printf("\t\t.header.loop_length = %u,\n", *(unsigned int *)(*((_QWORD *)a1 + 47) + 80 * v5 + 48));
printf("\t\t.header.loop_end = %u,\n", *(unsigned int *)(*((_QWORD *)a1 + 47) + 80 * v5 + 52));
printf("\t\t.data = sample_data_%02i\n", (unsigned int)v5);
puts("\t},");
++v5;
}
while ( *((unsigned __int16 *)a1 + 55) > (int)v5 );
}
puts("};");
v28 = 0LL;
if ( *((_WORD *)a1 + 57) )
{
do
{
v18 = 16 * v28;
v10 = (unsigned __int16 *)(*((_QWORD *)a1 + 49) + 16 * v28);
v11 = 0LL;
if ( *v10 )
{
do
{
v12 = MurmurHash2A(
*(_QWORD *)(*((_QWORD *)v10 + 1) + 8 * v11),
12 * (unsigned int)*((unsigned __int16 *)a1 + 54),
3735928559LL);
v13 = v29[0];
if ( v29[0] )
{
while ( *(_DWORD *)(v13 + 16) != (unsigned __int64)v12 )
{
v13 = *(_QWORD *)v13;
if ( !v13 )
goto LABEL_24;
}
}
else
{
LABEL_24:
v14 = malloc(0x18uLL);
v14[1] = 0LL;
*v14 = 0LL;
v14[2] = v12;
dllist_push(v29);
printf("const module_pattern_data_t pattern_data_%08x[] = {", v12);
v7 = 0LL;
v9 = 0;
if ( *((_WORD *)a1 + 54) )
{
do
{
v8 = (unsigned __int8 *)(*(_QWORD *)(*(_QWORD *)(*((_QWORD *)a1 + 49) + v18 + 8) + 8 * v11) + v7);
printf(
"{.sample_num=%3u, .period_index=%6i, .volume=%4i, .effect_num=%3u, .effect_value=%3u }",
*v8,
*((unsigned int *)v8 + 1),
(unsigned int)(char)v8[8],
v8[9],
v8[10]);
if ( ++v9 >= *((unsigned __int16 *)a1 + 54) )
break;
printf(", ");
v7 += 12LL;
}
while ( v9 < *((unsigned __int16 *)a1 + 54) );
}
puts("};");
}
v10 = (unsigned __int16 *)(*((_QWORD *)a1 + 49) + v18);
++v11;
}
while ( *v10 > (int)v11 );
}
printf("const module_pattern_row_t pattern_rows_%02i[] = {\n", (unsigned int)v28);
v15 = (unsigned __int16 *)(*((_QWORD *)a1 + 49) + v18);
if ( *v15 )
{
v16 = 0LL;
do
{
v17 = MurmurHash2A(
*(_QWORD *)(*((_QWORD *)v15 + 1) + 8 * v16),
12 * (unsigned int)*((unsigned __int16 *)a1 + 54),
3735928559LL);
printf("{ .data = pattern_data_%08x }", v17);
if ( *(unsigned __int16 *)(*((_QWORD *)a1 + 49) + 16 * v28) <= (int)v16 + 1 )
break;
printf(", ");
v15 = (unsigned __int16 *)(*((_QWORD *)a1 + 49) + v18);
++v16;
}
while ( *v15 > (int)v16 );
}
puts("\n};\n");
++v28;
}
while ( *((unsigned __int16 *)a1 + 57) > (int)v28 );
}
puts("const module_pattern_t patterns[] = {");
if ( *((_WORD *)a1 + 57) )
{
v6 = 0LL;
do
{
printf(
"{ .num_rows = %03u, .rows = pattern_rows_%02i }",
*(unsigned __int16 *)(*((_QWORD *)a1 + 49) + 16 * v6),
(unsigned int)v6);
if ( (int)v6 + 1 >= *((unsigned __int16 *)a1 + 57) )
break;
printf(", ");
++v6;
}
while ( *((unsigned __int16 *)a1 + 57) > (int)v6 );
}
puts("};");
puts("const module_t static_module = {");
printf("\t.song_title = { ");
v19 = a1;
for ( i = 1; ; ++i )
{
printf(" %3i", (unsigned int)*v19);
if ( i - 1 > 19 )
break;
printf(", ");
LABEL_40:
++v19;
}
if ( i <= 20 )
goto LABEL_40;
puts("},");
printf("\t.module_type = %i,\n", *((unsigned int *)a1 + 26));
printf("\t.num_channels = %u,\n", *((unsigned __int16 *)a1 + 54));
printf("\t.num_samples = %u,\n", *((unsigned __int16 *)a1 + 55));
printf("\t.num_instruments = %u,\n", *((unsigned __int16 *)a1 + 56));
printf("\t.num_patterns = %u,\n", *((unsigned __int16 *)a1 + 57));
printf("\t.num_orders = %u,\n", *((unsigned __int16 *)a1 + 58));
printf("\t.orders = { ");
v21 = (unsigned __int8 *)(a1 + 118);
for ( j = 1; ; ++j )
{
printf(" %3u", *v21);
if ( j - 1 <= 254 )
{
printf(", ");
goto LABEL_39;
}
if ( j > 255 )
break;
LABEL_39:
++v21;
}
puts("},");
puts("\t.samples = samples,");
puts("\t.patterns = patterns,");
printf("\t.initial_speed = %u,\n", (unsigned __int8)a1[400]);
printf("\t.initial_bpm = %u,\n", (unsigned __int8)a1[401]);
printf("\t.initial_master_volume = %u,\n", (unsigned __int8)a1[402]);
printf("\t.mix_volume = %u,\n", (unsigned __int8)a1[403]);
printf("\t.initial_panning = { ");
v23 = (unsigned __int8 *)(a1 + 404);
for ( k = 1; ; ++k )
{
printf(" %3u", *v23);
if ( k - 1 > 62 )
break;
printf(", ");
LABEL_47:
++v23;
}
if ( k <= 63 )
goto LABEL_47;
puts("},");
printf("\t.channel_volume = { ");
v25 = (unsigned __int8 *)(a1 + 468);
for ( l = 1; ; ++l )
{
printf(" %3u", *v25);
if ( l - 1 > 62 )
break;
printf(", ");
LABEL_52:
++v25;
}
if ( l <= 63 )
goto LABEL_52;
puts("}");
puts("};");
printf("#endif");
while ( 1 )
{
result = (void *)dllist_pop(v29);
if ( !result )
break;
free(result);
}
return result;
}

original_code:
void module_dump_c(module_t * module)
{
    int i, j, k;
    uint32_t hash;
    dllist_t list;
    dllist_element_t * tmp_elem;
    list.first=list.last=list.count = 0;
    printf("#ifndef _CONSTMOD_H\n#define _CONSTMOD_H\n\n#include \"module.h\"\n");
    for (i = 0; i < module->num_samples; i++) {
        printf ("const int8_t sample_data_%02i[] = {", i);
        for (j = 0; j < module->samples[i].header.length; j++) {
            if (!(j % 16))
                printf("\n");
            printf("%6i", sample_to_s8(module->samples[i].data[j]));
            if (j+1 < module->samples[i].header.length)
                printf(", ");
        }
        printf("};\n\n");
    }
    printf ("const module_sample_t samples[] = { ");
    for (i = 0; i < module->num_samples; i++) {
        printf("\t{ \n");
        printf("\t\t.header.length = %u,\n", module->samples[i].header.length);
        printf("\t\t.header.finetune = %i,\n", module->samples[i].header.finetune);
        printf("\t\t.header.c2spd = %u,\n", module->samples[i].header.c2spd);
        printf("\t\t.header.volume = %u,\n", module->samples[i].header.volume);
        printf("\t\t.header.loop_enabled = %u,\n", module->samples[i].header.loop_enabled);
        printf("\t\t.header.loop_start = %u,\n", module->samples[i].header.loop_start);
        printf("\t\t.header.loop_length = %u,\n", module->samples[i].header.loop_length);
        printf("\t\t.header.loop_end = %u,\n", module->samples[i].header.loop_end);
        printf("\t\t.data = sample_data_%02i\n", i);
        printf("\t},\n");
    }
    printf("};\n");
    for (i = 0; i < module->num_patterns; i++) {
        for (j = 0; j < module->patterns[i].num_rows; j++) {
            hash = MurmurHash2A(module->patterns[i].rows[j].data, (sizeof(module_pattern_data_t) * module->num_channels), 0xdeadbeef);
            for (tmp_elem = list.first; tmp_elem; tmp_elem = tmp_elem->next) {
                if (!tmp_elem)
                    break;
                if ((uint32_t)(tmp_elem->data) == (void *)hash)
                    break;
            }
            if (!tmp_elem) {
                tmp_elem = malloc(sizeof(dllist_element_t));
                tmp_elem->next = tmp_elem->prev = 0;
                tmp_elem->data = hash;
                dllist_push(&list, tmp_elem);
                printf("const module_pattern_data_t pattern_data_%08x[] = {", hash);
                for (k = 0; k < module->num_channels; k++) {
                    module_pattern_data_t * data = &(module->patterns[i].rows[j].data[k]);
                    printf("{.sample_num=%3u, .period_index=%6i, .volume=%4i, .effect_num=%3u, .effect_value=%3u }", data->sample_num, data->period_index, data->volume, data->effect_num, data->effect_value);
                    if (k+1 < module->num_channels)
                        printf(", ");
                }
                printf("};\n");
            }
        }
        printf("const module_pattern_row_t pattern_rows_%02i[] = {\n", i);
        for (j = 0; j < module->patterns[i].num_rows; j++) {
            hash = MurmurHash2A(module->patterns[i].rows[j].data, (sizeof(module_pattern_data_t) * module->num_channels), 0xdeadbeef);
            printf("{ .data = pattern_data_%08x }", hash);
            if (j+1 < module->patterns[i].num_rows)
                printf(", ");
        }
        printf("\n};\n\n");
    }
    printf("const module_pattern_t patterns[] = {\n");
    for (i = 0; i < module->num_patterns; i++) {
        printf("{ .num_rows = %03u, .rows = pattern_rows_%02i }", module->patterns[i].num_rows, i);
        if (i+1 < module->num_patterns)
            printf(", ");
    }
    printf("};\n");
    printf("const module_t static_module = {\n");
    printf("\t.song_title = { ");
    for (i = 0; i < 21; i++) {
        printf(" %3i", module->song_title[i]);
        if (i < 20)
            printf(", ");
    }
    printf("},\n");
    printf("\t.module_type = %i,\n", module->module_type);
    printf("\t.num_channels = %u,\n", module->num_channels);
    printf("\t.num_samples = %u,\n", module->num_samples);
    printf("\t.num_instruments = %u,\n", module->num_instruments);
    printf("\t.num_patterns = %u,\n", module->num_patterns);
    printf("\t.num_orders = %u,\n", module->num_orders);
    printf("\t.orders = { ");
    for (i = 0; i < 256; i++) {
        printf(" %3u", module->orders[i]);
        if (i < 255)
            printf(", ");
    }
    printf("},\n");
    printf("\t.samples = samples,\n");
    printf("\t.patterns = patterns,\n");
    printf("\t.initial_speed = %u,\n", module->initial_speed);
    printf("\t.initial_bpm = %u,\n", module->initial_bpm);
    printf("\t.initial_master_volume = %u,\n", module->initial_master_volume);
    printf("\t.mix_volume = %u,\n", module->mix_volume);
    printf("\t.initial_panning = { ");
    for (i = 0; i < 64; i++) {
        printf(" %3u", module->initial_panning[i]);
        if (i < 63)
            printf(", ");
    }
    printf("},\n");
    printf("\t.channel_volume = { ");
    for (i = 0; i < 64; i++) {
        printf(" %3u", module->channel_volume[i]);
        if (i < 63)
            printf(", ");
    }
    printf("}\n");
    printf("};\n");
    printf("#endif");
    while ((tmp_elem = dllist_pop(&list)) != 0)
        free(tmp_elem);
}

canonical_original_code:
void module_dump_c(struct module_t *module)
{
    int i; int j; int k;
    unsigned int hash;
    struct dllist_t list;
    struct dllist_element_s *tmp_elem;
    list.first=list.last=list.count = 0;
    printf("#ifndef _CONSTMOD_H\n#define _CONSTMOD_H\n\n#include \"module.h\"\n");
    for (i = 0; i < module->num_samples; i++) {
        printf ("const int8_t sample_data_%02i[] = {", i);
        for (j = 0; j < module->samples[i].header.length; j++) {
            if (!(j % 16))
                printf("\n");
            printf("%6i", sample_to_s8(module->samples[i].data[j]));
            if (j+1 < module->samples[i].header.length)
                printf(", ");
        }
        printf("};\n\n");
    }
    printf ("const module_sample_t samples[] = { ");
    for (i = 0; i < module->num_samples; i++) {
        printf("\t{ \n");
        printf("\t\t.header.length = %u,\n", module->samples[i].header.length);
        printf("\t\t.header.finetune = %i,\n", module->samples[i].header.finetune);
        printf("\t\t.header.c2spd = %u,\n", module->samples[i].header.c2spd);
        printf("\t\t.header.volume = %u,\n", module->samples[i].header.volume);
        printf("\t\t.header.loop_enabled = %u,\n", module->samples[i].header.loop_enabled);
        printf("\t\t.header.loop_start = %u,\n", module->samples[i].header.loop_start);
        printf("\t\t.header.loop_length = %u,\n", module->samples[i].header.loop_length);
        printf("\t\t.header.loop_end = %u,\n", module->samples[i].header.loop_end);
        printf("\t\t.data = sample_data_%02i\n", i);
        printf("\t},\n");
    }
    printf("};\n");
    for (i = 0; i < module->num_patterns; i++) {
        for (j = 0; j < module->patterns[i].num_rows; j++) {
            hash = MurmurHash2A(module->patterns[i].rows[j].data, (sizeof(module_pattern_data_t) * module->num_channels), 0xdeadbeef);
            for (tmp_elem = list.first; tmp_elem; tmp_elem = tmp_elem->next) {
                if (!tmp_elem)
                    break;
                if ((unsigned int)(tmp_elem->data) == (void *)hash)
                    break;
            }
            if (!tmp_elem) {
                tmp_elem = malloc(sizeof(dllist_element_t));
                tmp_elem->next = tmp_elem->prev = 0;
                tmp_elem->data = hash;
                dllist_push(&list, tmp_elem);
                printf("const module_pattern_data_t pattern_data_%08x[] = {", hash);
                for (k = 0; k < module->num_channels; k++) {
                    struct module_pattern_data_t *data = &(module->patterns[i].rows[j].data[k]);
                    printf("{.sample_num=%3u, .period_index=%6i, .volume=%4i, .effect_num=%3u, .effect_value=%3u }", data->sample_num, data->period_index, data->volume, data->effect_num, data->effect_value);
                    if (k+1 < module->num_channels)
                        printf(", ");
                }
                printf("};\n");
            }
        }
        printf("const module_pattern_row_t pattern_rows_%02i[] = {\n", i);
        for (j = 0; j < module->patterns[i].num_rows; j++) {
            hash = MurmurHash2A(module->patterns[i].rows[j].data, (sizeof(module_pattern_data_t) * module->num_channels), 0xdeadbeef);
            printf("{ .data = pattern_data_%08x }", hash);
            if (j+1 < module->patterns[i].num_rows)
                printf(", ");
        }
        printf("\n};\n\n");
    }
    printf("const module_pattern_t patterns[] = {\n");
    for (i = 0; i < module->num_patterns; i++) {
        printf("{ .num_rows = %03u, .rows = pattern_rows_%02i }", module->patterns[i].num_rows, i);
        if (i+1 < module->num_patterns)
            printf(", ");
    }
    printf("};\n");
    printf("const module_t static_module = {\n");
    printf("\t.song_title = { ");
    for (i = 0; i < 21; i++) {
        printf(" %3i", module->song_title[i]);
        if (i < 20)
            printf(", ");
    }
    printf("},\n");
    printf("\t.module_type = %i,\n", module->module_type);
    printf("\t.num_channels = %u,\n", module->num_channels);
    printf("\t.num_samples = %u,\n", module->num_samples);
    printf("\t.num_instruments = %u,\n", module->num_instruments);
    printf("\t.num_patterns = %u,\n", module->num_patterns);
    printf("\t.num_orders = %u,\n", module->num_orders);
    printf("\t.orders = { ");
    for (i = 0; i < 256; i++) {
        printf(" %3u", module->orders[i]);
        if (i < 255)
            printf(", ");
    }
    printf("},\n");
    printf("\t.samples = samples,\n");
    printf("\t.patterns = patterns,\n");
    printf("\t.initial_speed = %u,\n", module->initial_speed);
    printf("\t.initial_bpm = %u,\n", module->initial_bpm);
    printf("\t.initial_master_volume = %u,\n", module->initial_master_volume);
    printf("\t.mix_volume = %u,\n", module->mix_volume);
    printf("\t.initial_panning = { ");
    for (i = 0; i < 64; i++) {
        printf(" %3u", module->initial_panning[i]);
        if (i < 63)
            printf(", ");
    }
    printf("},\n");
    printf("\t.channel_volume = { ");
    for (i = 0; i < 64; i++) {
        printf(" %3u", module->channel_volume[i]);
        if (i < 63)
            printf(", ");
    }
    printf("}\n");
    printf("};\n");
    printf("#endif");
    while ((tmp_elem = dllist_pop(&list)) != 0)
        free(tmp_elem);
}

variable_types:
hash
unsigned int

variable_types: struct dllist_t { struct dllist_element_s { struct dllist_element_s *next; struct dllist_element_s *prev; void *data; } *first; struct dllist_element_s *last; int count; }

user_defined_types: struct dllist_t { struct dllist_element_s *first; struct dllist_element_s *last; int count; }


getHighScoreList

repo: FrostTree-Games/PrinceProtect

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

*a1 = scores[0];
a1[1] = scores[1];
result = scores[2];
a1[2] = result;
return result;
}

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

*a1 = scores[0];
a1[1] = scores[1];
result = scores[2];
a1[2] = result;
return result;
}

original_code:
void getHighScoreList(HighScore* scoreList)
{
 int i;
 for (i = 0; i < 3; i++)
 {
  scoreList[i] = scores[i];
 }
}

canonical_original_code:
void getHighScoreList(struct HighScore *scoreList)
{
 int i;
 for (i = 0; i < 3; i++)
 {
  scoreList[i] = scores[i];
 }
}

variable_types: struct HighScore { char playerCount; char name[3]; int score; } *

variable_types: i int

return_type: void


isHighScore

decompiled_code:
_BOOL8 __fastcall isHighScore(int a1)
{
return SHIDWORD(scores[2]) <= a1;
}

canonical_decompiled_code:
_BOOL8 __fastcall func1(int a1)
{
return SHIDWORD(scores[2]) <= a1;
}

original_code:
int isHighScore(int score)
{
 if (scores[3 - 1].score > score)
 {
  return 0;
 }
 else
 {
  return 1;
 }
}

variable_types: score int

return_type: int


pushHighScore

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

result = isHighScore(SHIDWORD(a1));
if ( (_DWORD)result )
{
if ( SHIDWORD(a1) > SHIDWORD(scores[0]) )
{
LODWORD(result) = 0;
}
else
{
if ( SHIDWORD(a1) <= SHIDWORD(scores[1]) )
{
if ( SHIDWORD(scores[2]) >= SHIDWORD(a1) )
return result;
LODWORD(result) = 2;
LABEL_10:
result = (int)result;
scores[(int)result] = a1;
return result;
}
LODWORD(result) = 1;
}
scores[2] = scores[1];
if ( (int)result <= 0 )
scores[1] = scores[0];
goto LABEL_10;
}
return result;
}

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

result = func1(SHIDWORD(a1));
if ( (_DWORD)result )
{
if ( SHIDWORD(a1) > SHIDWORD(scores[0]) )
{
LODWORD(result) = 0;
}
else
{
if ( SHIDWORD(a1) <= SHIDWORD(scores[1]) )
{
if ( SHIDWORD(scores[2]) >= SHIDWORD(a1) )
return result;
LODWORD(result) = 2;
LABEL_10:
result = (int)result;
scores[(int)result] = a1;
return result;
}
LODWORD(result) = 1;
}
scores[2] = scores[1];
if ( (int)result <= 0 )
scores[1] = scores[0];
goto LABEL_10;
}
return result;
}

original_code:
void pushHighScore(HighScore h)
{
 int i,j;
 if (!isHighScore(h.score))
 {
  return;
 }
 for (i = 0; i < 3; i++)
 {
  if (h.score > scores[i].score)
  {
   for (j = 3 - 1; j > i; j--)
   {
    scores[j] = scores[j - 1];
   }
   scores[i] = h;
   break;
  }
 }
}

canonical_original_code:
void pushHighScore(struct HighScore h)
{
 int i; int j;
 if (!isHighScore(h.score))
 {
  return;
 }
 for (i = 0; i < 3; i++)
 {
  if (h.score > scores[i].score)
  {
   for (j = 3 - 1; j > i; j--)
   {
    scores[j] = scores[j - 1];
   }
   scores[i] = h;
   break;
  }
 }
}

variable_types: struct HighScore { char playerCount; char name[3]; int score; }

variable_types: j int


updatePushMessages

decompiled_code:
void updatePushMessages()
{
int v0; // ecx
int *v1; // rax

if ( queueRear >= 0 && (unsigned int)getTimeSingleton() - messageQueue[0] > 0x9C4 )
{
v0 = queueRear;
if ( queueRear <= 0 )
{
--queueRear;
}
else
{
v1 = messageQueue;
do
{
*(__m128i *)v1 = _mm_loadu_si128((const __m128i *)(v1 + 9));
*((__m128i *)v1 + 1) = _mm_loadu_si128((const __m128i *)(v1 + 13));
v1[8] = v1[17];
v1 += 9;
}
while ( v1 != &messageQueue[9 * (v0 - 1) + 9] );
queueRear = v0 - 1;
messageQueue[0] = getTimeSingleton();
}
}
}

canonical_decompiled_code:
void func0()
{
int v0; // ecx
int *v1; // rax

if ( queueRear >= 0 && (unsigned int)getTimeSingleton() - messageQueue[0] > 0x9C4 )
{
v0 = queueRear;
if ( queueRear <= 0 )
{
--queueRear;
}
else
{
v1 = messageQueue;
do
{
*(__m128i *)v1 = _mm_loadu_si128((const __m128i *)(v1 + 9));
*((__m128i *)v1 + 1) = _mm_loadu_si128((const __m128i *)(v1 + 13));
v1[8] = v1[17];
v1 += 9;
}
while ( v1 != &messageQueue[9 * (v0 - 1) + 9] );
queueRear = v0 - 1;
messageQueue[0] = getTimeSingleton();
}
}
}

original_code:
void updatePushMessages()
{
 int i;
 if (queueRear < 0)
 {
  return;
 }
 if (getTimeSingleton() - messageQueue[0].startTime > 2500)
 {
  for (i = 0; i < queueRear; i++)
  {
   messageQueue[i] = messageQueue[i+1];
  }
  queueRear--;
  if (queueRear > -1)
  {
   messageQueue[0].startTime = getTimeSingleton();
  }
 }
}


pushNewMessage

decompiled_code:
__int64 __fastcall pushNewMessage(char *src)
{
__int64 result; // rax
int v2; // ebx

if ( !src )
return 2LL;
result = 1LL;
if ( queueRear <= 3 )
{
v2 = ++queueRear;
if ( strlen(src) <= 0x1F )
{
strcpy((char *)&messageQueue[9 * v2 + 1], src);
}
else
{
strncpy((char *)&messageQueue[9 * v2 + 1], src, 0x1FuLL);
HIBYTE(messageQueue[9 * v2 + 8]) = 0;
}
messageQueue[9 * v2] = getTimeSingleton();
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(char *src)
{
__int64 result; // rax
int v2; // ebx

if ( !src )
return 2LL;
result = 1LL;
if ( queueRear <= 3 )
{
v2 = ++queueRear;
if ( strlen(src) <= 0x1F )
{
strcpy((char *)&messageQueue[9 * v2 + 1], src);
}
else
{
strncpy((char *)&messageQueue[9 * v2 + 1], src, 0x1FuLL);
HIBYTE(messageQueue[9 * v2 + 8]) = 0;
}
messageQueue[9 * v2] = getTimeSingleton();
result = 0LL;
}
return result;
}

original_code:
int pushNewMessage(char* text)
{
 if (text == ((void *)0))
 {
  return 2;
 }
 if (queueRear > 3)
 {
  return 1;
 }
 queueRear++;
 if (strlen(text) > 31)
 {
  strncpy(messageQueue[queueRear].message, text, 31);
  (messageQueue[queueRear].message)[31] = '\0';
 }
 else
 {
  strcpy(messageQueue[queueRear].message, text);
 }
 messageQueue[queueRear].startTime = getTimeSingleton();
 return 0;
}

canonical_original_code:
int pushNewMessage(char *text)
{
 if (text == ((void *)0))
 {
  return 2;
 }
 if (queueRear > 3)
 {
  return 1;
 }
 queueRear++;
 if (strlen(text) > 31)
 {
  strncpy(messageQueue[queueRear].message, text, 31);
  (messageQueue[queueRear].message)[31] = '\0';
 }
 else
 {
  strcpy(messageQueue[queueRear].message, text);
 }
 messageQueue[queueRear].startTime = getTimeSingleton();
 return 0;
}

variable_types:
text
char *


getCurrentMessage

decompiled_code:
int *getCurrentMessage()
{
int *result; // rax

result = messageQueue;
if ( queueRear < 0 )
result = 0LL;
return result;
}

canonical_decompiled_code:
int *func2()
{
int *result; // rax

result = messageQueue;
if ( queueRear < 0 )
result = 0LL;
return result;
}

original_code:
PushMessage* getCurrentMessage()
{
 if (queueRear < 0)
 {
  return ((void *)0);
 }
 else
 {
  return messageQueue;
 }
}

canonical_original_code:
struct PushMessage *getCurrentMessage()
{
 if (queueRear < 0)
 {
  return ((void *)0);
 }
 else
 {
  return messageQueue;
 }
}

return_type: struct PushMessage { unsigned int startTime; char message[32]; } *


initalizeParticleList

decompiled_code:
_BOOL8 initalizeParticleList()
{
_BOOL8 result; // rax

result = 1LL;
if ( !particleList )
{
particleList = calloc(0x64uLL, 0x18uLL);
result = particleList != 0LL;
}
return result;
}

canonical_decompiled_code:
_BOOL8 func0()
{
_BOOL8 result; // rax

result = 1LL;
if ( !particleList )
{
particleList = calloc(0x64uLL, 0x18uLL);
result = particleList != 0LL;
}
return result;
}

original_code:
int initalizeParticleList()
{
 if (particleList != ((void *)0))
 {
  return 1;
 }
 particleList = (Particle*)calloc(100, sizeof(Particle));
 if (particleList == ((void *)0))
 {
  return 0;
 }
 return 1;
}

canonical_original_code:
int initalizeParticleList()
{
 if (particleList != ((void *)0))
 {
  return 1;
 }
 particleList = (struct Particle *)calloc(100, sizeof(Particle));
 if (particleList == ((void *)0))
 {
  return 0;
 }
 return 1;
}

user_defined_types: struct Particle { enum ParticleType type; float x; float xVelo; unsigned int startTime; }

user_defined_types: enum ParticleType { NONE=0, ICE=1, MUD=2, BLOOD=3, SWEAT=4, HEALTHSPARK=5, TELESPARK=6, FIRE=7, LIFETEXT=8 }


freeParticleList

decompiled_code:
void freeParticleList()
{
free(particleList);
particleList = 0LL;
}

canonical_decompiled_code:
void func1()
{
free(particleList);
particleList = 0LL;
}

original_code:
void freeParticleList()
{
 free(particleList);
 particleList = ((void *)0);
}


updateParticles

decompiled_code:
float *updateParticles()
{
__int64 i; // rbx
float *result; // rax
int v2; // edx
float v3; // xmm0_4
float v4; // xmm0_4
int v5; // eax
float *v6; // rbp
float v7; // xmm0_4
unsigned int v8; // kr00_4
double v9; // rbp
float v10; // xmm0_4
double v11; // [rsp+8h] [rbp-20h]

for ( i = 0LL; i != 2400; i += 24LL )
{
result = (float *)((char *)particleList + i);
v2 = *(_DWORD *)((char *)particleList + i);
if ( v2 )
{
v3 = result[1];
if ( v3 > 317.0 || v3 < 1.0 || (v4 = result[2], v4 > 237.0) || v4 < 3.0 )
{
*result = 0.0;
}
else
{
if ( v2 == 7 )
{
v5 = getTimeSingleton();
v6 = (float *)((char *)particleList + i);
v7 = sin((double)(v5 - *(_DWORD *)((char *)particleList + i + 20))) * 3.0;
v6[3] = v7;
}
if ( *(_DWORD *)((char *)particleList + i) == 6 )
{
v8 = getTimeSingleton() - *(_DWORD *)((char *)particleList + i + 20);
*(float *)((char *)particleList + i + 4) = *(float *)((char *)particleList + i + 4)
+ *(float *)((char *)particleList + i + 12);
v11 = (double)(v8 / 0x64);
v9 = exp(v11 * 0.2);
v10 = (sin(v11 * 10.0) * v9 + v11) * *(float *)((char *)particleList + i + 16) * 0.5
+ *(float *)((char *)particleList + i + 8);
*(float *)((char *)particleList + i + 8) = v10;
}
else
{
*(float *)((char *)particleList + i + 4) = *(float *)((char *)particleList + i + 4)
+ *(float *)((char *)particleList + i + 12);
*(float *)((char *)particleList + i + 8) = *(float *)((char *)particleList + i + 8)
+ *(float *)((char *)particleList + i + 16);
}
result = (float *)((char *)particleList + i);
switch ( *(_DWORD *)((char *)particleList + i) )
{
case 1:
case 6:
result = (float *)((unsigned int)getTimeSingleton() - *(_DWORD *)((char *)particleList + i + 20));
if ( (unsigned int)result > 0xFA )
*(_DWORD *)((char *)particleList + i) = 0;
break;
case 2:
case 5:
result = (float *)((unsigned int)getTimeSingleton() - *(_DWORD *)((char *)particleList + i + 20));
if ( (unsigned int)result > 0x64 )
*(_DWORD *)((char *)particleList + i) = 0;
break;
case 3:
case 4:
result[4] = result[4] + 0.40000001;
result = (float *)((unsigned int)getTimeSingleton() - *(_DWORD *)((char *)particleList + i + 20));
if ( (unsigned int)result > 0xC8 )
*(_DWORD *)((char *)particleList + i) = 0;
break;
case 7:
result = (float *)((unsigned int)getTimeSingleton() - *(_DWORD *)((char *)particleList + i + 20));
if ( (unsigned int)result > 0x15E )
*(_DWORD *)((char *)particleList + i) = 0;
break;
case 8:
result = (float *)((unsigned int)getTimeSingleton() - *(_DWORD *)((char *)particleList + i + 20));
if ( (unsigned int)result > 0xAF )
*(_DWORD *)((char *)particleList + i) = 0;
break;
default:
continue;
}
}
}
}
return result;
}

canonical_decompiled_code:
float *func2()
{
__int64 i; // rbx
float *result; // rax
int v2; // edx
float v3; // xmm0_4
float v4; // xmm0_4
int v5; // eax
float *v6; // rbp
float v7; // xmm0_4
unsigned int v8; // kr00_4
double v9; // rbp
float v10; // xmm0_4
double v11; // [rsp+8h] [rbp-20h]

for ( i = 0LL; i != 2400; i += 24LL )
{
result = (float *)((char *)particleList + i);
v2 = *(_DWORD *)((char *)particleList + i);
if ( v2 )
{
v3 = result[1];
if ( v3 > 317.0 || v3 < 1.0 || (v4 = result[2], v4 > 237.0) || v4 < 3.0 )
{
*result = 0.0;
}
else
{
if ( v2 == 7 )
{
v5 = getTimeSingleton();
v6 = (float *)((char *)particleList + i);
v7 = sin((double)(v5 - *(_DWORD *)((char *)particleList + i + 20))) * 3.0;
v6[3] = v7;
}
if ( *(_DWORD *)((char *)particleList + i) == 6 )
{
v8 = getTimeSingleton() - *(_DWORD *)((char *)particleList + i + 20);
*(float *)((char *)particleList + i + 4) = *(float *)((char *)particleList + i + 4)
+ *(float *)((char *)particleList + i + 12);
v11 = (double)(v8 / 0x64);
v9 = exp(v11 * 0.2);
v10 = (sin(v11 * 10.0) * v9 + v11) * *(float *)((char *)particleList + i + 16) * 0.5
+ *(float *)((char *)particleList + i + 8);
*(float *)((char *)particleList + i + 8) = v10;
}
else
{
*(float *)((char *)particleList + i + 4) = *(float *)((char *)particleList + i + 4)
+ *(float *)((char *)particleList + i + 12);
*(float *)((char *)particleList + i + 8) = *(float *)((char *)particleList + i + 8)
+ *(float *)((char *)particleList + i + 16);
}
result = (float *)((char *)particleList + i);
switch ( *(_DWORD *)((char *)particleList + i) )
{
case 1:
case 6:
result = (float *)((unsigned int)getTimeSingleton() - *(_DWORD *)((char *)particleList + i + 20));
if ( (unsigned int)result > 0xFA )
*(_DWORD *)((char *)particleList + i) = 0;
break;
case 2:
case 5:
result = (float *)((unsigned int)getTimeSingleton() - *(_DWORD *)((char *)particleList + i + 20));
if ( (unsigned int)result > 0x64 )
*(_DWORD *)((char *)particleList + i) = 0;
break;
case 3:
case 4:
result[4] = result[4] + 0.40000001;
result = (float *)((unsigned int)getTimeSingleton() - *(_DWORD *)((char *)particleList + i + 20));
if ( (unsigned int)result > 0xC8 )
*(_DWORD *)((char *)particleList + i) = 0;
break;
case 7:
result = (float *)((unsigned int)getTimeSingleton() - *(_DWORD *)((char *)particleList + i + 20));
if ( (unsigned int)result > 0x15E )
*(_DWORD *)((char *)particleList + i) = 0;
break;
case 8:
result = (float *)((unsigned int)getTimeSingleton() - *(_DWORD *)((char *)particleList + i + 20));
if ( (unsigned int)result > 0xAF )
*(_DWORD *)((char *)particleList + i) = 0;
break;
default:
continue;
}
}
}
}
return result;
}

original_code:
void updateParticles()
{
 int i;
 for (i = 0; i < 100; i++)
 {
  if (particleList[i].type == NONE)
  {
   continue;
  }
  if (particleList[i].x > 320 - 3 || particleList[i].x < 1 || particleList[i].y > 240 - 3 || particleList[i].y < 3)
  {
   particleList[i].type = NONE;
   continue;
  }
  if (particleList[i].type == FIRE)
  {
   Uint32 delta = (getTimeSingleton() - particleList[i].startTime);
   particleList[i].xVelo = (float)(3*sin(delta));
  }
  if (particleList[i].type == TELESPARK)
  {
   Uint32 delta = (getTimeSingleton() - particleList[i].startTime)/100;
   particleList[i].x += particleList[i].xVelo;
   particleList[i].y += (delta + exp(0.20 * delta) * sin(10.0 * delta)) * particleList[i].yVelo/2.0f;
  }
  else
  {
   particleList[i].x += particleList[i].xVelo;
   particleList[i].y += particleList[i].yVelo;
  }
  switch(particleList[i].type)
  {
   case TELESPARK:
   case ICE:
   if (getTimeSingleton() - particleList[i].startTime > 250)
   {
    particleList[i].type = NONE;
   }
   break;
   case BLOOD:
   case SWEAT:
   particleList[i].yVelo += 0.4f;
   if (getTimeSingleton() - particleList[i].startTime > 200)
   {
    particleList[i].type = NONE;
   }
   break;
   case HEALTHSPARK:
   case MUD:
   if (getTimeSingleton() - particleList[i].startTime > 100)
   {
    particleList[i].type = NONE;
   }
   break;
   case LIFETEXT:
   if (getTimeSingleton() - particleList[i].startTime > 175)
   {
    particleList[i].type = NONE;
   }
   break;
   case FIRE:
   if (getTimeSingleton() - particleList[i].startTime > 350)
   {
    particleList[i].type = NONE;
   }
   break;
   default:
   break;
  }
 }
}

canonical_original_code:
void updateParticles()
{
 int i;
 for (i = 0; i < 100; i++)
 {
  if (particleList[i].type == NONE)
  {
   continue;
  }
  if (particleList[i].x > 320 - 3 || particleList[i].x < 1 || particleList[i].y > 240 - 3 || particleList[i].y < 3)
  {
   particleList[i].type = NONE;
   continue;
  }
  if (particleList[i].type == FIRE)
  {
   unsigned int delta = (getTimeSingleton() - particleList[i].startTime);
   particleList[i].xVelo = (float)(3*sin(delta));
  }
  if (particleList[i].type == TELESPARK)
  {
   unsigned int delta = (getTimeSingleton() - particleList[i].startTime)/100;
   particleList[i].x += particleList[i].xVelo;
   particleList[i].y += (delta + exp(0.20 * delta) * sin(10.0 * delta)) * particleList[i].yVelo/2.0f;
  }
  else
  {
   particleList[i].x += particleList[i].xVelo;
   particleList[i].y += particleList[i].yVelo;
  }
  switch(particleList[i].type)
  {
   case TELESPARK:
   case ICE:
   if (getTimeSingleton() - particleList[i].startTime > 250)
   {
    particleList[i].type = NONE;
   }
   break;
   case BLOOD:
   case SWEAT:
   particleList[i].yVelo += 0.4f;
   if (getTimeSingleton() - particleList[i].startTime > 200)
   {
    particleList[i].type = NONE;
   }
   break;
   case HEALTHSPARK:
   case MUD:
   if (getTimeSingleton() - particleList[i].startTime > 100)
   {
    particleList[i].type = NONE;
   }
   break;
   case LIFETEXT:
   if (getTimeSingleton() - particleList[i].startTime > 175)
   {
    particleList[i].type = NONE;
   }
   break;
   case FIRE:
   if (getTimeSingleton() - particleList[i].startTime > 350)
   {
    particleList[i].type = NONE;
   }
   break;
   default:
   break;
  }
 }
}

variable_types:
delta
unsigned int


pushParticle

decompiled_code:
__int64 __fastcall pushParticle(int a1, float a2, float a3, float a4, float a5)
{
__int64 v5; // rax
float *v7; // rbx

v5 = 0LL;
while ( *(_DWORD *)((char *)particleList + v5) )
{
v5 += 24LL;
if ( v5 == 2400 )
return 0LL;
}
*(_DWORD *)((char *)particleList + v5) = a1;
*(float *)((char *)particleList + v5 + 4) = a2;
v7 = (float *)((char *)particleList + v5);
v7[2] = a3;
v7[3] = a4;
v7[4] = a5;
*((_DWORD *)v7 + 5) = getTimeSingleton();
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func3(int a1, float a2, float a3, float a4, float a5)
{
__int64 v5; // rax
float *v7; // rbx

v5 = 0LL;
while ( *(_DWORD *)((char *)particleList + v5) )
{
v5 += 24LL;
if ( v5 == 2400 )
return 0LL;
}
*(_DWORD *)((char *)particleList + v5) = a1;
*(float *)((char *)particleList + v5 + 4) = a2;
v7 = (float *)((char *)particleList + v5);
v7[2] = a3;
v7[3] = a4;
v7[4] = a5;
*((_DWORD *)v7 + 5) = getTimeSingleton();
return 1LL;
}

original_code:
int pushParticle(ParticleType p, float newX, float newY, float newXSpeed, float newYSpeed)
{
 int i;
 for (i = 0; i < 100; i++)
 {
  if (particleList[i].type != NONE)
  {
   continue;
  }
  else
  {
   particleList[i].type = p;
   particleList[i].x = newX;
                        particleList[i].y = newY;
                        particleList[i].xVelo = newXSpeed;
                        particleList[i].yVelo = newYSpeed;
                        particleList[i].startTime = getTimeSingleton();
                        return 1;
  }
 }
 return 0;
}

canonical_original_code:
int pushParticle(enum ParticleType p, float newX, float newY, float newXSpeed, float newYSpeed)
{
 int i;
 for (i = 0; i < 100; i++)
 {
  if (particleList[i].type != NONE)
  {
   continue;
  }
  else
  {
   particleList[i].type = p;
   particleList[i].x = newX;
                        particleList[i].y = newY;
                        particleList[i].xVelo = newXSpeed;
                        particleList[i].yVelo = newYSpeed;
                        particleList[i].startTime = getTimeSingleton();
                        return 1;
  }
 }
 return 0;
}

variable_types: enum ParticleType { NONE=0, ICE=1, MUD=2, BLOOD=3, SWEAT=4, HEALTHSPARK=5, TELESPARK=6, FIRE=7, LIFETEXT=8 }

variable_types: newX float

variable_types: newY float

variable_types: newXSpeed float

variable_types: newYSpeed float


getParticleList

decompiled_code:
void *getParticleList()
{
return particleList;
}

canonical_decompiled_code:
void *func4()
{
return particleList;
}

original_code:
Particle* getParticleList()
{
 return particleList;
}

canonical_original_code:
struct Particle *getParticleList()
{
 return particleList;
}

return_type: struct Particle { enum ParticleType { NONE=0, ICE=1, MUD=2, BLOOD=3, SWEAT=4, HEALTHSPARK=5, TELESPARK=6, FIRE=7, LIFETEXT=8 } type; float x; float xVelo; unsigned int startTime; } *


loadSFXFiles

decompiled_code:
__int64 loadSFXFiles()
{
__int64 v0; // rax
__int64 v1; // rax
__int64 v2; // rax
__int64 v3; // rax
__int64 v4; // rax
__int64 v5; // rax
__int64 v6; // rax
__int64 v7; // rax
__int64 v8; // rax
__int64 v9; // rax
__int64 v10; // rax
__int64 v11; // rax
__int64 v12; // rax
__int64 v13; // rax
__int64 v14; // rax
__int64 v15; // rax
__int64 v16; // rax
__int64 v17; // rax
__int64 v18; // rax
__int64 v19; // rax
__int64 v20; // rax
__int64 v21; // rax

v0 = SDL_RWFromFile("aud/sfx/open.wav", &unk_F3C);
wipe_open = Mix_LoadWAV_RW(v0, 1LL);
if ( !wipe_open )
fwrite("Error loading wipe 1 sound effect. Check for aud/sfx/open.wav\n", 1uLL, 0x3EuLL, stderr);
v1 = SDL_RWFromFile("aud/sfx/close.wav", &unk_F3C);
wipe_close = Mix_LoadWAV_RW(v1, 1LL);
if ( !wipe_close )
fwrite("Error loading wipe 2 sound effect. Check for aud/sfx/close.wav\n", 1uLL, 0x3FuLL, stderr);
v2 = SDL_RWFromFile("aud/sfx/die.wav", &unk_F3C);
player_die = Mix_LoadWAV_RW(v2, 1LL);
if ( !player_die )
fwrite("Error loading knockout sound effect. Check for aud/sfx/die.wav\n", 1uLL, 0x3FuLL, stderr);
v3 = SDL_RWFromFile("aud/sfx/crash.wav", &unk_F3C);
crash = Mix_LoadWAV_RW(v3, 1LL);
if ( !crash )
fwrite("Error loading knockout crash effect. Check for aud/sfx/crash.wav\n", 1uLL, 0x41uLL, stderr);
v4 = SDL_RWFromFile("aud/sfx/menu.wav", &unk_F3C);
menuClick = Mix_LoadWAV_RW(v4, 1LL);
if ( !menuClick )
fwrite("Error loading menu sound effect. Check for aud/sfx/menu.wav\n", 1uLL, 0x3CuLL, stderr);
v5 = SDL_RWFromFile("aud/sfx/explosion.wav", &unk_F3C);
explosion = Mix_LoadWAV_RW(v5, 1LL);
if ( !explosion )
fwrite("Error loading explosion sound effect. Check for aud/sfx/explosion.wav\n", 1uLL, 0x46uLL, stderr);
v6 = SDL_RWFromFile("aud/sfx/hurt.wav", &unk_F3C);
player_hurt = Mix_LoadWAV_RW(v6, 1LL);
if ( !player_hurt )
fwrite("Error loading player damage sound effect. Check for aud/sfx/hurt.wav\n", 1uLL, 0x45uLL, stderr);
v7 = SDL_RWFromFile("aud/sfx/ice.wav", &unk_F3C);
ice = Mix_LoadWAV_RW(v7, 1LL);
if ( !ice )
fwrite("Error loading ice sound effect. Check for aud/sfx/ice.wav\n", 1uLL, 0x3AuLL, stderr);
v8 = SDL_RWFromFile("aud/sfx/laser.wav", &unk_F3C);
laser = Mix_LoadWAV_RW(v8, 1LL);
if ( !laser )
fwrite("Error loading shiruken sound effect. Check for aud/sfx/laser.wav\n", 1uLL, 0x41uLL, stderr);
v9 = SDL_RWFromFile("aud/sfx/laser_alt.wav", &unk_F3C);
laser_alt = Mix_LoadWAV_RW(v9, 1LL);
if ( !laser_alt )
fwrite("Error loading second shiruken sound effect. Check for aud/sfx/laser_alt.wav\n", 1uLL, 0x4CuLL, stderr);
v10 = SDL_RWFromFile("aud/sfx/mud.wav", &unk_F3C);
mudSplat = Mix_LoadWAV_RW(v10, 1LL);
if ( !mudSplat )
fwrite("Error loading poof sound effect. Check for aud/sfx/mud.wav\n", 1uLL, 0x3BuLL, stderr);
v11 = SDL_RWFromFile("aud/sfx/mud2.wav", &unk_F3C);
mudSplat2 = Mix_LoadWAV_RW(v11, 1LL);
if ( !mudSplat2 )
fwrite("Error loading glue sound effect. Check for aud/sfx/mud2.wav\n", 1uLL, 0x3CuLL, stderr);
v12 = SDL_RWFromFile("aud/sfx/sword.wav", &unk_F3C);
swordStrike = Mix_LoadWAV_RW(v12, 1LL);
if ( !swordStrike )
fwrite("Error loading sword sound effect. Check for aud/sfx/sword.wav\n", 1uLL, 0x3EuLL, stderr);
v13 = SDL_RWFromFile("aud/sfx/teleport.wav", &unk_F3C);
teleport = Mix_LoadWAV_RW(v13, 1LL);
if ( !teleport )
fwrite("Error loading teleport sound effect. Check for aud/sfx/teleport.wav\n", 1uLL, 0x44uLL, stderr);
v14 = SDL_RWFromFile("aud/sfx/princess.wav", &unk_F3C);
princessYell = Mix_LoadWAV_RW(v14, 1LL);
if ( !princessYell )
fwrite("Error loading prince yelling sound effect. Check for aud/sfx/princess.wav\n", 1uLL, 0x4AuLL, stderr);
v15 = SDL_RWFromFile("aud/sfx/enemyKill.wav", &unk_F3C);
enemy_die = Mix_LoadWAV_RW(v15, 1LL);
if ( !enemy_die )
fwrite("Error loading enemy death sound effect. Check for aud/sfx/enemyKill.wav\n", 1uLL, 0x48uLL, stderr);
v16 = SDL_RWFromFile("aud/sfx/enemyHurt.wav", &unk_F3C);
enemy_hurt = Mix_LoadWAV_RW(v16, 1LL);
if ( !enemy_hurt )
fwrite("Error loading enemy damage sound effect. Check for aud/sfx/enemyHurt.wav\n", 1uLL, 0x49uLL, stderr);
v17 = SDL_RWFromFile("aud/sfx/getHammer.wav", &unk_F3C);
get_hammer = Mix_LoadWAV_RW(v17, 1LL);
if ( !get_hammer )
fwrite("Error loading hammer sound effect. Check for aud/sfx/getHammer.wav\n", 1uLL, 0x43uLL, stderr);
v18 = SDL_RWFromFile("aud/sfx/ready.wav", &unk_F3C);
readyJingle = Mix_LoadWAV_RW(v18, 1LL);
if ( !readyJingle )
fwrite("Error loading ready Jingle effect. Check for aud/sfx/ready.wav\n", 1uLL, 0x3FuLL, stderr);
v19 = SDL_RWFromFile("aud/sfx/losePrincess.wav", &unk_F3C);
losePrincess = Mix_LoadWAV_RW(v19, 1LL);
if ( !losePrincess )
fwrite("Error loading prince escape effect. Check for aud/sfx/losePrincess.wav\n", 1uLL, 0x47uLL, stderr);
v20 = SDL_RWFromFile("aud/sfx/decoy.wav", &unk_F3C);
decoyYell = Mix_LoadWAV_RW(v20, 1LL);
if ( !decoyYell )
fwrite("Error loading decoy prince effect. Check for aud/sfx/decoy.wav\n", 1uLL, 0x3FuLL, stderr);
v21 = SDL_RWFromFile("aud/sfx/heart.wav", &unk_F3C);
heartSound = Mix_LoadWAV_RW(v21, 1LL);
if ( !heartSound )
fwrite("Error loading heart sound effect. Check for aud/sfx/heart.wav\n", 1uLL, 0x3EuLL, stderr);
return 0LL;
}

canonical_decompiled_code:
__int64 func0()
{
__int64 v0; // rax
__int64 v1; // rax
__int64 v2; // rax
__int64 v3; // rax
__int64 v4; // rax
__int64 v5; // rax
__int64 v6; // rax
__int64 v7; // rax
__int64 v8; // rax
__int64 v9; // rax
__int64 v10; // rax
__int64 v11; // rax
__int64 v12; // rax
__int64 v13; // rax
__int64 v14; // rax
__int64 v15; // rax
__int64 v16; // rax
__int64 v17; // rax
__int64 v18; // rax
__int64 v19; // rax
__int64 v20; // rax
__int64 v21; // rax

v0 = SDL_RWFromFile("aud/sfx/open.wav", &unk_F3C);
wipe_open = Mix_LoadWAV_RW(v0, 1LL);
if ( !wipe_open )
fwrite("Error loading wipe 1 sound effect. Check for aud/sfx/open.wav\n", 1uLL, 0x3EuLL, stderr);
v1 = SDL_RWFromFile("aud/sfx/close.wav", &unk_F3C);
wipe_close = Mix_LoadWAV_RW(v1, 1LL);
if ( !wipe_close )
fwrite("Error loading wipe 2 sound effect. Check for aud/sfx/close.wav\n", 1uLL, 0x3FuLL, stderr);
v2 = SDL_RWFromFile("aud/sfx/die.wav", &unk_F3C);
player_die = Mix_LoadWAV_RW(v2, 1LL);
if ( !player_die )
fwrite("Error loading knockout sound effect. Check for aud/sfx/die.wav\n", 1uLL, 0x3FuLL, stderr);
v3 = SDL_RWFromFile("aud/sfx/crash.wav", &unk_F3C);
crash = Mix_LoadWAV_RW(v3, 1LL);
if ( !crash )
fwrite("Error loading knockout crash effect. Check for aud/sfx/crash.wav\n", 1uLL, 0x41uLL, stderr);
v4 = SDL_RWFromFile("aud/sfx/menu.wav", &unk_F3C);
menuClick = Mix_LoadWAV_RW(v4, 1LL);
if ( !menuClick )
fwrite("Error loading menu sound effect. Check for aud/sfx/menu.wav\n", 1uLL, 0x3CuLL, stderr);
v5 = SDL_RWFromFile("aud/sfx/explosion.wav", &unk_F3C);
explosion = Mix_LoadWAV_RW(v5, 1LL);
if ( !explosion )
fwrite("Error loading explosion sound effect. Check for aud/sfx/explosion.wav\n", 1uLL, 0x46uLL, stderr);
v6 = SDL_RWFromFile("aud/sfx/hurt.wav", &unk_F3C);
player_hurt = Mix_LoadWAV_RW(v6, 1LL);
if ( !player_hurt )
fwrite("Error loading player damage sound effect. Check for aud/sfx/hurt.wav\n", 1uLL, 0x45uLL, stderr);
v7 = SDL_RWFromFile("aud/sfx/ice.wav", &unk_F3C);
ice = Mix_LoadWAV_RW(v7, 1LL);
if ( !ice )
fwrite("Error loading ice sound effect. Check for aud/sfx/ice.wav\n", 1uLL, 0x3AuLL, stderr);
v8 = SDL_RWFromFile("aud/sfx/laser.wav", &unk_F3C);
laser = Mix_LoadWAV_RW(v8, 1LL);
if ( !laser )
fwrite("Error loading shiruken sound effect. Check for aud/sfx/laser.wav\n", 1uLL, 0x41uLL, stderr);
v9 = SDL_RWFromFile("aud/sfx/laser_alt.wav", &unk_F3C);
laser_alt = Mix_LoadWAV_RW(v9, 1LL);
if ( !laser_alt )
fwrite("Error loading second shiruken sound effect. Check for aud/sfx/laser_alt.wav\n", 1uLL, 0x4CuLL, stderr);
v10 = SDL_RWFromFile("aud/sfx/mud.wav", &unk_F3C);
mudSplat = Mix_LoadWAV_RW(v10, 1LL);
if ( !mudSplat )
fwrite("Error loading poof sound effect. Check for aud/sfx/mud.wav\n", 1uLL, 0x3BuLL, stderr);
v11 = SDL_RWFromFile("aud/sfx/mud2.wav", &unk_F3C);
mudSplat2 = Mix_LoadWAV_RW(v11, 1LL);
if ( !mudSplat2 )
fwrite("Error loading glue sound effect. Check for aud/sfx/mud2.wav\n", 1uLL, 0x3CuLL, stderr);
v12 = SDL_RWFromFile("aud/sfx/sword.wav", &unk_F3C);
swordStrike = Mix_LoadWAV_RW(v12, 1LL);
if ( !swordStrike )
fwrite("Error loading sword sound effect. Check for aud/sfx/sword.wav\n", 1uLL, 0x3EuLL, stderr);
v13 = SDL_RWFromFile("aud/sfx/teleport.wav", &unk_F3C);
teleport = Mix_LoadWAV_RW(v13, 1LL);
if ( !teleport )
fwrite("Error loading teleport sound effect. Check for aud/sfx/teleport.wav\n", 1uLL, 0x44uLL, stderr);
v14 = SDL_RWFromFile("aud/sfx/princess.wav", &unk_F3C);
princessYell = Mix_LoadWAV_RW(v14, 1LL);
if ( !princessYell )
fwrite("Error loading prince yelling sound effect. Check for aud/sfx/princess.wav\n", 1uLL, 0x4AuLL, stderr);
v15 = SDL_RWFromFile("aud/sfx/enemyKill.wav", &unk_F3C);
enemy_die = Mix_LoadWAV_RW(v15, 1LL);
if ( !enemy_die )
fwrite("Error loading enemy death sound effect. Check for aud/sfx/enemyKill.wav\n", 1uLL, 0x48uLL, stderr);
v16 = SDL_RWFromFile("aud/sfx/enemyHurt.wav", &unk_F3C);
enemy_hurt = Mix_LoadWAV_RW(v16, 1LL);
if ( !enemy_hurt )
fwrite("Error loading enemy damage sound effect. Check for aud/sfx/enemyHurt.wav\n", 1uLL, 0x49uLL, stderr);
v17 = SDL_RWFromFile("aud/sfx/getHammer.wav", &unk_F3C);
get_hammer = Mix_LoadWAV_RW(v17, 1LL);
if ( !get_hammer )
fwrite("Error loading hammer sound effect. Check for aud/sfx/getHammer.wav\n", 1uLL, 0x43uLL, stderr);
v18 = SDL_RWFromFile("aud/sfx/ready.wav", &unk_F3C);
readyJingle = Mix_LoadWAV_RW(v18, 1LL);
if ( !readyJingle )
fwrite("Error loading ready Jingle effect. Check for aud/sfx/ready.wav\n", 1uLL, 0x3FuLL, stderr);
v19 = SDL_RWFromFile("aud/sfx/losePrincess.wav", &unk_F3C);
losePrincess = Mix_LoadWAV_RW(v19, 1LL);
if ( !losePrincess )
fwrite("Error loading prince escape effect. Check for aud/sfx/losePrincess.wav\n", 1uLL, 0x47uLL, stderr);
v20 = SDL_RWFromFile("aud/sfx/decoy.wav", &unk_F3C);
decoyYell = Mix_LoadWAV_RW(v20, 1LL);
if ( !decoyYell )
fwrite("Error loading decoy prince effect. Check for aud/sfx/decoy.wav\n", 1uLL, 0x3FuLL, stderr);
v21 = SDL_RWFromFile("aud/sfx/heart.wav", &unk_F3C);
heartSound = Mix_LoadWAV_RW(v21, 1LL);
if ( !heartSound )
fwrite("Error loading heart sound effect. Check for aud/sfx/heart.wav\n", 1uLL, 0x3EuLL, stderr);
return 0LL;
}

original_code:
int loadSFXFiles()
{
 if ( (wipe_open = Mix_LoadWAV_RW(SDL_RWFromFile("aud/sfx/open.wav", "rb"), 1)) == ((void *)0))
 {
  fprintf(stderr, "Error loading wipe 1 sound effect. Check for aud/sfx/open.wav\n");
 }
 if ( (wipe_close = Mix_LoadWAV_RW(SDL_RWFromFile("aud/sfx/close.wav", "rb"), 1)) == ((void *)0))
 {
  fprintf(stderr, "Error loading wipe 2 sound effect. Check for aud/sfx/close.wav\n");
 }
 if ( (player_die = Mix_LoadWAV_RW(SDL_RWFromFile("aud/sfx/die.wav", "rb"), 1)) == ((void *)0))
 {
  fprintf(stderr, "Error loading knockout sound effect. Check for aud/sfx/die.wav\n");
 }
 if ( (crash = Mix_LoadWAV_RW(SDL_RWFromFile("aud/sfx/crash.wav", "rb"), 1)) == ((void *)0))
 {
  fprintf(stderr, "Error loading knockout crash effect. Check for aud/sfx/crash.wav\n");
 }
 if ( (menuClick = Mix_LoadWAV_RW(SDL_RWFromFile("aud/sfx/menu.wav", "rb"), 1)) == ((void *)0))
 {
  fprintf(stderr, "Error loading menu sound effect. Check for aud/sfx/menu.wav\n");
 }
 if ( (explosion = Mix_LoadWAV_RW(SDL_RWFromFile("aud/sfx/explosion.wav", "rb"), 1)) == ((void *)0))
 {
  fprintf(stderr, "Error loading explosion sound effect. Check for aud/sfx/explosion.wav\n");
 }
 if ( (player_hurt = Mix_LoadWAV_RW(SDL_RWFromFile("aud/sfx/hurt.wav", "rb"), 1)) == ((void *)0))
 {
  fprintf(stderr, "Error loading player damage sound effect. Check for aud/sfx/hurt.wav\n");
 }
 if ( (ice = Mix_LoadWAV_RW(SDL_RWFromFile("aud/sfx/ice.wav", "rb"), 1)) == ((void *)0))
 {
  fprintf(stderr, "Error loading ice sound effect. Check for aud/sfx/ice.wav\n");
 }
 if ( (laser = Mix_LoadWAV_RW(SDL_RWFromFile("aud/sfx/laser.wav", "rb"), 1)) == ((void *)0))
 {
  fprintf(stderr, "Error loading shiruken sound effect. Check for aud/sfx/laser.wav\n");
 }
 if ( (laser_alt = Mix_LoadWAV_RW(SDL_RWFromFile("aud/sfx/laser_alt.wav", "rb"), 1)) == ((void *)0))
 {
  fprintf(stderr, "Error loading second shiruken sound effect. Check for aud/sfx/laser_alt.wav\n");
 }
 if ( (mudSplat = Mix_LoadWAV_RW(SDL_RWFromFile("aud/sfx/mud.wav", "rb"), 1)) == ((void *)0))
 {
  fprintf(stderr, "Error loading poof sound effect. Check for aud/sfx/mud.wav\n");
 }
 if ( (mudSplat2 = Mix_LoadWAV_RW(SDL_RWFromFile("aud/sfx/mud2.wav", "rb"), 1)) == ((void *)0))
 {
  fprintf(stderr, "Error loading glue sound effect. Check for aud/sfx/mud2.wav\n");
 }
 if ( (swordStrike = Mix_LoadWAV_RW(SDL_RWFromFile("aud/sfx/sword.wav", "rb"), 1)) == ((void *)0))
 {
  fprintf(stderr, "Error loading sword sound effect. Check for aud/sfx/sword.wav\n");
 }
 if ( (teleport = Mix_LoadWAV_RW(SDL_RWFromFile("aud/sfx/teleport.wav", "rb"), 1)) == ((void *)0))
 {
  fprintf(stderr, "Error loading teleport sound effect. Check for aud/sfx/teleport.wav\n");
 }
 if ( (princessYell = Mix_LoadWAV_RW(SDL_RWFromFile("aud/sfx/princess.wav", "rb"), 1)) == ((void *)0))
 {
  fprintf(stderr, "Error loading prince yelling sound effect. Check for aud/sfx/princess.wav\n");
 }
 if ( (enemy_die = Mix_LoadWAV_RW(SDL_RWFromFile("aud/sfx/enemyKill.wav", "rb"), 1)) == ((void *)0))
 {
  fprintf(stderr, "Error loading enemy death sound effect. Check for aud/sfx/enemyKill.wav\n");
 }
 if ( (enemy_hurt = Mix_LoadWAV_RW(SDL_RWFromFile("aud/sfx/enemyHurt.wav", "rb"), 1)) == ((void *)0))
 {
  fprintf(stderr, "Error loading enemy damage sound effect. Check for aud/sfx/enemyHurt.wav\n");
 }
 if ( (get_hammer = Mix_LoadWAV_RW(SDL_RWFromFile("aud/sfx/getHammer.wav", "rb"), 1)) == ((void *)0))
 {
  fprintf(stderr, "Error loading hammer sound effect. Check for aud/sfx/getHammer.wav\n");
 }
 if ( (readyJingle = Mix_LoadWAV_RW(SDL_RWFromFile("aud/sfx/ready.wav", "rb"), 1)) == ((void *)0))
 {
  fprintf(stderr, "Error loading ready Jingle effect. Check for aud/sfx/ready.wav\n");
 }
 if ( (losePrincess = Mix_LoadWAV_RW(SDL_RWFromFile("aud/sfx/losePrincess.wav", "rb"), 1)) == ((void *)0))
 {
  fprintf(stderr, "Error loading prince escape effect. Check for aud/sfx/losePrincess.wav\n");
 }
 if ( (decoyYell = Mix_LoadWAV_RW(SDL_RWFromFile("aud/sfx/decoy.wav", "rb"), 1)) == ((void *)0))
 {
  fprintf(stderr, "Error loading decoy prince effect. Check for aud/sfx/decoy.wav\n");
 }
 if ( (heartSound = Mix_LoadWAV_RW(SDL_RWFromFile("aud/sfx/heart.wav", "rb"), 1)) == ((void *)0))
 {
  fprintf(stderr, "Error loading heart sound effect. Check for aud/sfx/heart.wav\n");
 }
 return 0;
}


loadBGMFiles

decompiled_code:
__int64 loadBGMFiles()
{
bgm1 = Mix_LoadMUS("aud/bgm/artifical_turf.it");
if ( !bgm1 )
fwrite("Error loading background music 1. Check for aud/sfx/artifical_turf.it\n", 1uLL, 0x46uLL, stderr);
bgm2 = Mix_LoadMUS("aud/bgm/pretty_weeds.it");
if ( !bgm2 )
fwrite("Error loading background music 2. Check for aud/sfx/pretty_weeds.it\n", 1uLL, 0x44uLL, stderr);
bgm3 = Mix_LoadMUS("aud/bgm/real_grass.it");
if ( !bgm3 )
fwrite("Error loading background music 2. Check for aud/sfx/real_grass.it\n", 1uLL, 0x42uLL, stderr);
titleSong = Mix_LoadMUS("aud/bgm/title.ogg");
if ( !titleSong )
fwrite("Error loading title screen music! Oh no! Check for aud/sfx/title.ogg\n", 1uLL, 0x45uLL, stderr);
keyConfig = Mix_LoadMUS("aud/bgm/keyConfig.wav");
if ( !keyConfig )
fwrite("Error loading key config music. Check for aud/sfx/keyConfig.wav\n", 1uLL, 0x40uLL, stderr);
return 0LL;
}

canonical_decompiled_code:
__int64 func1()
{
bgm1 = Mix_LoadMUS("aud/bgm/artifical_turf.it");
if ( !bgm1 )
fwrite("Error loading background music 1. Check for aud/sfx/artifical_turf.it\n", 1uLL, 0x46uLL, stderr);
bgm2 = Mix_LoadMUS("aud/bgm/pretty_weeds.it");
if ( !bgm2 )
fwrite("Error loading background music 2. Check for aud/sfx/pretty_weeds.it\n", 1uLL, 0x44uLL, stderr);
bgm3 = Mix_LoadMUS("aud/bgm/real_grass.it");
if ( !bgm3 )
fwrite("Error loading background music 2. Check for aud/sfx/real_grass.it\n", 1uLL, 0x42uLL, stderr);
titleSong = Mix_LoadMUS("aud/bgm/title.ogg");
if ( !titleSong )
fwrite("Error loading title screen music! Oh no! Check for aud/sfx/title.ogg\n", 1uLL, 0x45uLL, stderr);
keyConfig = Mix_LoadMUS("aud/bgm/keyConfig.wav");
if ( !keyConfig )
fwrite("Error loading key config music. Check for aud/sfx/keyConfig.wav\n", 1uLL, 0x40uLL, stderr);
return 0LL;
}

original_code:
int loadBGMFiles()
{
 if ( (bgm1 = Mix_LoadMUS("aud/bgm/artifical_turf.it")) == ((void *)0))
 {
  fprintf(stderr, "Error loading background music 1. Check for aud/sfx/artifical_turf.it\n");
 }
 if ( (bgm2 = Mix_LoadMUS("aud/bgm/pretty_weeds.it")) == ((void *)0))
 {
  fprintf(stderr, "Error loading background music 2. Check for aud/sfx/pretty_weeds.it\n");
 }
 if ( (bgm3 = Mix_LoadMUS("aud/bgm/real_grass.it")) == ((void *)0))
 {
  fprintf(stderr, "Error loading background music 2. Check for aud/sfx/real_grass.it\n");
 }
 if ( (titleSong = Mix_LoadMUS("aud/bgm/title.ogg")) == ((void *)0))
 {
  fprintf(stderr, "Error loading title screen music! Oh no! Check for aud/sfx/title.ogg\n");
 }
 if ( (keyConfig = Mix_LoadMUS("aud/bgm/keyConfig.wav")) == ((void *)0))
 {
  fprintf(stderr, "Error loading key config music. Check for aud/sfx/keyConfig.wav\n");
 }
 return 0;
}


setupAudio

decompiled_code:
__int64 setupAudio()
{
__int64 result; // rax
const char *v1; // rax
const char *v2; // rax

if ( (Mix_Init(10LL) & 0xA) != 10 )
{
fwrite("Mix_Init: Failed to init required ogg support!\n", 1uLL, 0x2FuLL, stderr);
v1 = (const char *)SDL_GetError();
fprintf(stderr, "Mix_Init: %s\n", v1);
}
if ( (unsigned int)Mix_OpenAudio(22050LL, 32784LL, 2LL, 4096LL) == -1 )
{
fwrite("Error initalizing SDL_mixer. Check various libs.\n", 1uLL, 0x31uLL, stderr);
v2 = (const char *)SDL_GetError();
fprintf(stderr, "Mix_OpenAudio: %s\n", v2);
result = 1LL;
}
else
{
result = loadSFXFiles();
if ( (_DWORD)result != 1 )
{
result = loadBGMFiles();
if ( (_DWORD)result != 1 )
{
audioInitalized = 1;
result = 0LL;
}
}
}
return result;
}

canonical_decompiled_code:
__int64 func2()
{
__int64 result; // rax
const char *v1; // rax
const char *v2; // rax

if ( (Mix_Init(10LL) & 0xA) != 10 )
{
fwrite("Mix_Init: Failed to init required ogg support!\n", 1uLL, 0x2FuLL, stderr);
v1 = (const char *)SDL_GetError();
fprintf(stderr, "Mix_Init: %s\n", v1);
}
if ( (unsigned int)Mix_OpenAudio(22050LL, 32784LL, 2LL, 4096LL) == -1 )
{
fwrite("Error initalizing SDL_mixer. Check various libs.\n", 1uLL, 0x31uLL, stderr);
v2 = (const char *)SDL_GetError();
fprintf(stderr, "Mix_OpenAudio: %s\n", v2);
result = 1LL;
}
else
{
result = func0();
if ( (_DWORD)result != 1 )
{
result = func1();
if ( (_DWORD)result != 1 )
{
audioInitalized = 1;
result = 0LL;
}
}
}
return result;
}

original_code:
int setupAudio()
{
 int flags=MIX_INIT_OGG | MIX_INIT_MOD;
 int initted=Mix_Init(flags);
 if((initted & flags) != flags)
 {
  fprintf(stderr, "Mix_Init: Failed to init required ogg support!\n");
  fprintf(stderr, "Mix_Init: %s\n", SDL_GetError());
 }
 if (Mix_OpenAudio(22050, 0x8010, 2, 4096) == -1)
 {
  fprintf(stderr, "Error initalizing SDL_mixer. Check various libs.\n");
  fprintf(stderr, "Mix_OpenAudio: %s\n", SDL_GetError());
  return 1;
 }
 if (loadSFXFiles() == 1)
 {
  return 1;
 }
 if (loadBGMFiles() == 1)
 {
  return 1;
 }
 audioInitalized = 1;
 return 0;
}

canonical_original_code:
int setupAudio()
{
 int flags = MIX_INIT_OGG | MIX_INIT_MOD;
 int initted = Mix_Init(flags);
 if((initted & flags) != flags)
 {
  fprintf(stderr, "Mix_Init: Failed to init required ogg support!\n");
  fprintf(stderr, "Mix_Init: %s\n", SDL_GetError());
 }
 if (Mix_OpenAudio(22050, 0x8010, 2, 4096) == -1)
 {
  fprintf(stderr, "Error initalizing SDL_mixer. Check various libs.\n");
  fprintf(stderr, "Mix_OpenAudio: %s\n", SDL_GetError());
  return 1;
 }
 if (loadSFXFiles() == 1)
 {
  return 1;
 }
 if (loadBGMFiles() == 1)
 {
  return 1;
 }
 audioInitalized = 1;
 return 0;
}

variable_types: flags int

variable_types: initted int


clearAudio

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

Mix_FreeChunk(explosion);
Mix_FreeChunk(player_hurt);
Mix_FreeChunk(ice);
Mix_FreeChunk(laser);
Mix_FreeChunk(laser_alt);
Mix_FreeChunk(mudSplat);
Mix_FreeChunk(mudSplat2);
Mix_FreeChunk(swordStrike);
Mix_FreeChunk(teleport);
Mix_FreeChunk(princessYell);
Mix_FreeChunk(crash);
Mix_FreeChunk(wipe_open);
Mix_FreeChunk(wipe_close);
Mix_FreeChunk(enemy_die);
Mix_FreeChunk(enemy_hurt);
Mix_FreeChunk(get_hammer);
Mix_FreeChunk(readyJingle);
Mix_FreeChunk(losePrincess);
Mix_FreeChunk(decoyYell);
Mix_FreeChunk(heartSound);
Mix_FreeMusic(bgm1);
Mix_FreeMusic(bgm2);
Mix_FreeMusic(bgm3);
Mix_FreeMusic(titleSong);
Mix_FreeMusic(keyConfig);
result = Mix_CloseAudio();
audioInitalized = 0;
return result;
}

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

Mix_FreeChunk(explosion);
Mix_FreeChunk(player_hurt);
Mix_FreeChunk(ice);
Mix_FreeChunk(laser);
Mix_FreeChunk(laser_alt);
Mix_FreeChunk(mudSplat);
Mix_FreeChunk(mudSplat2);
Mix_FreeChunk(swordStrike);
Mix_FreeChunk(teleport);
Mix_FreeChunk(princessYell);
Mix_FreeChunk(crash);
Mix_FreeChunk(wipe_open);
Mix_FreeChunk(wipe_close);
Mix_FreeChunk(enemy_die);
Mix_FreeChunk(enemy_hurt);
Mix_FreeChunk(get_hammer);
Mix_FreeChunk(readyJingle);
Mix_FreeChunk(losePrincess);
Mix_FreeChunk(decoyYell);
Mix_FreeChunk(heartSound);
Mix_FreeMusic(bgm1);
Mix_FreeMusic(bgm2);
Mix_FreeMusic(bgm3);
Mix_FreeMusic(titleSong);
Mix_FreeMusic(keyConfig);
result = Mix_CloseAudio();
audioInitalized = 0;
return result;
}

original_code:
void clearAudio()
{
 Mix_FreeChunk(explosion);
 Mix_FreeChunk(player_hurt);
 Mix_FreeChunk(ice);
 Mix_FreeChunk(laser);
 Mix_FreeChunk(laser_alt);
 Mix_FreeChunk(mudSplat);
 Mix_FreeChunk(mudSplat2);
 Mix_FreeChunk(swordStrike);
 Mix_FreeChunk(teleport);
 Mix_FreeChunk(princessYell);
 Mix_FreeChunk(crash);
 Mix_FreeChunk(wipe_open);
 Mix_FreeChunk(wipe_close);
 Mix_FreeChunk(enemy_die);
 Mix_FreeChunk(enemy_hurt);
 Mix_FreeChunk(get_hammer);
 Mix_FreeChunk(readyJingle);
 Mix_FreeChunk(losePrincess);
 Mix_FreeChunk(decoyYell);
 Mix_FreeChunk(heartSound);
 Mix_FreeMusic(bgm1);
 Mix_FreeMusic(bgm2);
 Mix_FreeMusic(bgm3);
 Mix_FreeMusic(titleSong);
 Mix_FreeMusic(keyConfig);
 Mix_CloseAudio();
 audioInitalized = 0;
 return;
}


playSFX

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

if ( muteSFX != 1 && a1 )
{
switch ( a1 )
{
case 1:
result = Mix_PlayChannelTimed(0xFFFFFFFFLL, explosion, 0LL, 0xFFFFFFFFLL);
break;
case 3:
result = Mix_PlayChannelTimed(0xFFFFFFFFLL, player_hurt, 0LL, 0xFFFFFFFFLL);
LABEL_7:
if ( a1 == 5 )
{
result = Mix_PlayChannelTimed(0xFFFFFFFFLL, laser, 0LL, 0xFFFFFFFFLL);
LABEL_10:
if ( a1 == 8 )
{
result = Mix_PlayChannelTimed(0xFFFFFFFFLL, mudSplat, 0LL, 0xFFFFFFFFLL);
LABEL_13:
if ( a1 == 11 )
{
result = Mix_PlayChannelTimed(0xFFFFFFFFLL, teleport, 0LL, 0xFFFFFFFFLL);
LABEL_16:
if ( a1 == 15 )
{
result = Mix_PlayChannelTimed(0xFFFFFFFFLL, wipe_open, 0LL, 0xFFFFFFFFLL);
LABEL_19:
if ( a1 == 18 )
{
result = Mix_PlayChannelTimed(0xFFFFFFFFLL, enemy_hurt, 0LL, 0xFFFFFFFFLL);
LABEL_22:
if ( a1 == 21 )
return Mix_PlayChannelTimed(0xFFFFFFFFLL, losePrincess, 0LL, 0xFFFFFFFFLL);
LABEL_23:
if ( a1 == 13 )
return Mix_PlayChannelTimed(0xFFFFFFFFLL, decoyYell, 0LL, 0xFFFFFFFFLL);
goto LABEL_24;
}
goto LABEL_20;
}
goto LABEL_17;
}
goto LABEL_14;
}
goto LABEL_11;
}
goto LABEL_8;
case 14:
result = Mix_PlayChannelTimed(0xFFFFFFFFLL, player_die, 0LL, 0xFFFFFFFFLL);
LABEL_8:
if ( a1 == 6 )
{
result = Mix_PlayChannelTimed(0xFFFFFFFFLL, laser_alt, 0LL, 0xFFFFFFFFLL);
LABEL_11:
if ( a1 == 9 )
{
result = Mix_PlayChannelTimed(0xFFFFFFFFLL, mudSplat2, 0LL, 0xFFFFFFFFLL);
LABEL_14:
if ( a1 == 12 )
{
result = Mix_PlayChannelTimed(0xFFFFFFFFLL, princessYell, 0LL, 0xFFFFFFFFLL);
LABEL_17:
if ( a1 == 16 )
{
result = Mix_PlayChannelTimed(0xFFFFFFFFLL, wipe_close, 0LL, 0xFFFFFFFFLL);
LABEL_20:
if ( a1 == 19 )
{
result = Mix_PlayChannelTimed(0xFFFFFFFFLL, get_hammer, 0LL, 0xFFFFFFFFLL);
goto LABEL_23;
}
goto LABEL_21;
}
goto LABEL_18;
}
goto LABEL_15;
}
goto LABEL_12;
}
goto LABEL_9;
case 4:
result = Mix_PlayChannelTimed(0xFFFFFFFFLL, ice, 0LL, 0xFFFFFFFFLL);
LABEL_9:
if ( a1 == 7 )
{
result = Mix_PlayChannelTimed(0xFFFFFFFFLL, menuClick, 0LL, 0xFFFFFFFFLL);
LABEL_12:
if ( a1 == 10 )
{
result = Mix_PlayChannelTimed(0xFFFFFFFFLL, swordStrike, 0LL, 0xFFFFFFFFLL);
LABEL_15:
if ( a1 == 2 )
{
result = Mix_PlayChannelTimed(0xFFFFFFFFLL, crash, 0LL, 0xFFFFFFFFLL);
LABEL_18:
if ( a1 == 17 )
{
result = Mix_PlayChannelTimed(0xFFFFFFFFLL, enemy_die, 0LL, 0xFFFFFFFFLL);
LABEL_21:
if ( a1 == 20 )
{
result = Mix_PlayChannelTimed(0xFFFFFFFFLL, readyJingle, 0LL, 0xFFFFFFFFLL);
LABEL_24:
if ( a1 == 22 )
result = Mix_PlayChannelTimed(0xFFFFFFFFLL, heartSound, 0LL, 0xFFFFFFFFLL);
return result;
}
goto LABEL_22;
}
goto LABEL_19;
}
goto LABEL_16;
}
goto LABEL_13;
}
goto LABEL_10;
}
goto LABEL_7;
}
return result;
}

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

if ( muteSFX != 1 && a1 )
{
switch ( a1 )
{
case 1:
result = Mix_PlayChannelTimed(0xFFFFFFFFLL, explosion, 0LL, 0xFFFFFFFFLL);
break;
case 3:
result = Mix_PlayChannelTimed(0xFFFFFFFFLL, player_hurt, 0LL, 0xFFFFFFFFLL);
LABEL_7:
if ( a1 == 5 )
{
result = Mix_PlayChannelTimed(0xFFFFFFFFLL, laser, 0LL, 0xFFFFFFFFLL);
LABEL_10:
if ( a1 == 8 )
{
result = Mix_PlayChannelTimed(0xFFFFFFFFLL, mudSplat, 0LL, 0xFFFFFFFFLL);
LABEL_13:
if ( a1 == 11 )
{
result = Mix_PlayChannelTimed(0xFFFFFFFFLL, teleport, 0LL, 0xFFFFFFFFLL);
LABEL_16:
if ( a1 == 15 )
{
result = Mix_PlayChannelTimed(0xFFFFFFFFLL, wipe_open, 0LL, 0xFFFFFFFFLL);
LABEL_19:
if ( a1 == 18 )
{
result = Mix_PlayChannelTimed(0xFFFFFFFFLL, enemy_hurt, 0LL, 0xFFFFFFFFLL);
LABEL_22:
if ( a1 == 21 )
return Mix_PlayChannelTimed(0xFFFFFFFFLL, losePrincess, 0LL, 0xFFFFFFFFLL);
LABEL_23:
if ( a1 == 13 )
return Mix_PlayChannelTimed(0xFFFFFFFFLL, decoyYell, 0LL, 0xFFFFFFFFLL);
goto LABEL_24;
}
goto LABEL_20;
}
goto LABEL_17;
}
goto LABEL_14;
}
goto LABEL_11;
}
goto LABEL_8;
case 14:
result = Mix_PlayChannelTimed(0xFFFFFFFFLL, player_die, 0LL, 0xFFFFFFFFLL);
LABEL_8:
if ( a1 == 6 )
{
result = Mix_PlayChannelTimed(0xFFFFFFFFLL, laser_alt, 0LL, 0xFFFFFFFFLL);
LABEL_11:
if ( a1 == 9 )
{
result = Mix_PlayChannelTimed(0xFFFFFFFFLL, mudSplat2, 0LL, 0xFFFFFFFFLL);
LABEL_14:
if ( a1 == 12 )
{
result = Mix_PlayChannelTimed(0xFFFFFFFFLL, princessYell, 0LL, 0xFFFFFFFFLL);
LABEL_17:
if ( a1 == 16 )
{
result = Mix_PlayChannelTimed(0xFFFFFFFFLL, wipe_close, 0LL, 0xFFFFFFFFLL);
LABEL_20:
if ( a1 == 19 )
{
result = Mix_PlayChannelTimed(0xFFFFFFFFLL, get_hammer, 0LL, 0xFFFFFFFFLL);
goto LABEL_23;
}
goto LABEL_21;
}
goto LABEL_18;
}
goto LABEL_15;
}
goto LABEL_12;
}
goto LABEL_9;
case 4:
result = Mix_PlayChannelTimed(0xFFFFFFFFLL, ice, 0LL, 0xFFFFFFFFLL);
LABEL_9:
if ( a1 == 7 )
{
result = Mix_PlayChannelTimed(0xFFFFFFFFLL, menuClick, 0LL, 0xFFFFFFFFLL);
LABEL_12:
if ( a1 == 10 )
{
result = Mix_PlayChannelTimed(0xFFFFFFFFLL, swordStrike, 0LL, 0xFFFFFFFFLL);
LABEL_15:
if ( a1 == 2 )
{
result = Mix_PlayChannelTimed(0xFFFFFFFFLL, crash, 0LL, 0xFFFFFFFFLL);
LABEL_18:
if ( a1 == 17 )
{
result = Mix_PlayChannelTimed(0xFFFFFFFFLL, enemy_die, 0LL, 0xFFFFFFFFLL);
LABEL_21:
if ( a1 == 20 )
{
result = Mix_PlayChannelTimed(0xFFFFFFFFLL, readyJingle, 0LL, 0xFFFFFFFFLL);
LABEL_24:
if ( a1 == 22 )
result = Mix_PlayChannelTimed(0xFFFFFFFFLL, heartSound, 0LL, 0xFFFFFFFFLL);
return result;
}
goto LABEL_22;
}
goto LABEL_19;
}
goto LABEL_16;
}
goto LABEL_13;
}
goto LABEL_10;
}
goto LABEL_7;
}
return result;
}

original_code:
void playSFX(SFXType fx)
{
 if (muteSFX == 1)
 {
  return;
 }
 if (fx == SFX_NONE)
 {
  return;
 }
 if (fx == SFX_EXPLOSION)
 {
  Mix_PlayChannelTimed(-1,explosion,0,-1);
 }
 if (fx == SFX_PLAYER_HURT)
 {
  Mix_PlayChannelTimed(-1,player_hurt,0,-1);
 }
 if (fx == SFX_PLAYER_DEATH)
 {
  Mix_PlayChannelTimed(-1,player_die,0,-1);
 }
 if (fx == SFX_ICE_TINK)
 {
  Mix_PlayChannelTimed(-1,ice,0,-1);
 }
 if (fx == SFX_LASER_1)
 {
  Mix_PlayChannelTimed(-1,laser,0,-1);
 }
 if (fx == SFX_LASER_2)
 {
  Mix_PlayChannelTimed(-1,laser_alt,0,-1);
 }
 if (fx == SFX_MENU)
 {
  Mix_PlayChannelTimed(-1,menuClick,0,-1);
 }
 if (fx == SFX_MUD)
 {
  Mix_PlayChannelTimed(-1,mudSplat,0,-1);
 }
 if (fx == SFX_MUD2)
 {
  Mix_PlayChannelTimed(-1,mudSplat2,0,-1);
 }
 if (fx == SFX_SWORD)
 {
  Mix_PlayChannelTimed(-1,swordStrike,0,-1);
 }
 if (fx == SFX_TELEPORT)
 {
  Mix_PlayChannelTimed(-1,teleport,0,-1);
 }
 if (fx == SFX_PRINCESS_YELL)
 {
  Mix_PlayChannelTimed(-1,princessYell,0,-1);
 }
 if (fx == SFX_CRASH)
 {
  Mix_PlayChannelTimed(-1,crash,0,-1);
 }
 if (fx == SFX_WIPE_OPEN)
 {
  Mix_PlayChannelTimed(-1,wipe_open,0,-1);
 }
 if (fx == SFX_WIPE_CLOSE)
 {
  Mix_PlayChannelTimed(-1,wipe_close,0,-1);
 }
 if (fx == SFX_ENEMY_DIE)
 {
  Mix_PlayChannelTimed(-1,enemy_die,0,-1);
 }
 if (fx == SFX_ENEMY_HURT)
 {
  Mix_PlayChannelTimed(-1,enemy_hurt,0,-1);
 }
 if (fx == SFX_GET_HAMMER)
 {
  Mix_PlayChannelTimed(-1,get_hammer,0,-1);
 }
 if (fx == SFX_READY_JINGLE)
 {
  Mix_PlayChannelTimed(-1,readyJingle,0,-1);
 }
 if (fx == SFX_LOSE_PRINCESS)
 {
  Mix_PlayChannelTimed(-1,losePrincess,0,-1);
 }
 if (fx == SFX_DECOY_YELL)
 {
  Mix_PlayChannelTimed(-1,decoyYell,0,-1);
 }
 if (fx == SFX_LIFEUP)
 {
  Mix_PlayChannelTimed(-1,heartSound,0,-1);
 }
}

canonical_original_code:
void playSFX(enum SFXType fx)
{
 if (muteSFX == 1)
 {
  return;
 }
 if (fx == SFX_NONE)
 {
  return;
 }
 if (fx == SFX_EXPLOSION)
 {
  Mix_PlayChannelTimed(-1,explosion,0,-1);
 }
 if (fx == SFX_PLAYER_HURT)
 {
  Mix_PlayChannelTimed(-1,player_hurt,0,-1);
 }
 if (fx == SFX_PLAYER_DEATH)
 {
  Mix_PlayChannelTimed(-1,player_die,0,-1);
 }
 if (fx == SFX_ICE_TINK)
 {
  Mix_PlayChannelTimed(-1,ice,0,-1);
 }
 if (fx == SFX_LASER_1)
 {
  Mix_PlayChannelTimed(-1,laser,0,-1);
 }
 if (fx == SFX_LASER_2)
 {
  Mix_PlayChannelTimed(-1,laser_alt,0,-1);
 }
 if (fx == SFX_MENU)
 {
  Mix_PlayChannelTimed(-1,menuClick,0,-1);
 }
 if (fx == SFX_MUD)
 {
  Mix_PlayChannelTimed(-1,mudSplat,0,-1);
 }
 if (fx == SFX_MUD2)
 {
  Mix_PlayChannelTimed(-1,mudSplat2,0,-1);
 }
 if (fx == SFX_SWORD)
 {
  Mix_PlayChannelTimed(-1,swordStrike,0,-1);
 }
 if (fx == SFX_TELEPORT)
 {
  Mix_PlayChannelTimed(-1,teleport,0,-1);
 }
 if (fx == SFX_PRINCESS_YELL)
 {
  Mix_PlayChannelTimed(-1,princessYell,0,-1);
 }
 if (fx == SFX_CRASH)
 {
  Mix_PlayChannelTimed(-1,crash,0,-1);
 }
 if (fx == SFX_WIPE_OPEN)
 {
  Mix_PlayChannelTimed(-1,wipe_open,0,-1);
 }
 if (fx == SFX_WIPE_CLOSE)
 {
  Mix_PlayChannelTimed(-1,wipe_close,0,-1);
 }
 if (fx == SFX_ENEMY_DIE)
 {
  Mix_PlayChannelTimed(-1,enemy_die,0,-1);
 }
 if (fx == SFX_ENEMY_HURT)
 {
  Mix_PlayChannelTimed(-1,enemy_hurt,0,-1);
 }
 if (fx == SFX_GET_HAMMER)
 {
  Mix_PlayChannelTimed(-1,get_hammer,0,-1);
 }
 if (fx == SFX_READY_JINGLE)
 {
  Mix_PlayChannelTimed(-1,readyJingle,0,-1);
 }
 if (fx == SFX_LOSE_PRINCESS)
 {
  Mix_PlayChannelTimed(-1,losePrincess,0,-1);
 }
 if (fx == SFX_DECOY_YELL)
 {
  Mix_PlayChannelTimed(-1,decoyYell,0,-1);
 }
 if (fx == SFX_LIFEUP)
 {
  Mix_PlayChannelTimed(-1,heartSound,0,-1);
 }
}

variable_types: enum SFXType { SFX_NONE=0, SFX_EXPLOSION=1, SFX_CRASH=2, SFX_PLAYER_HURT=3, SFX_ICE_TINK=4, SFX_LASER_1=5, SFX_LASER_2=6, SFX_MENU=7, SFX_MUD=8, SFX_MUD2=9, SFX_SWORD=10, SFX_TELEPORT=11, SFX_PRINCESS_YELL=12, SFX_DECOY_YELL=13, SFX_PLAYER_DEATH=14, SFX_WIPE_OPEN=15, SFX_WIPE_CLOSE=16, SFX_ENEMY_DIE=17, SFX_ENEMY_HURT=18, SFX_GET_HAMMER=19, SFX_READY_JINGLE=20, SFX_LOSE_PRINCESS=21, SFX_LIFEUP=22 }


stopAllSFX

decompiled_code:
__int64 stopAllSFX()
{
return Mix_HaltChannel(0xFFFFFFFFLL);
}

canonical_decompiled_code:
__int64 func5()
{
return Mix_HaltChannel(0xFFFFFFFFLL);
}

original_code:
void stopAllSFX()
{
 Mix_HaltChannel(-1);
}


playBGM

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

if ( muteBGM != 1 )
{
result = Mix_HaltMusic();
switch ( a1 )
{
case 2:
result = Mix_PlayMusic(bgm1, 0xFFFFFFFFLL);
break;
case 3:
result = Mix_PlayMusic(bgm2, 0xFFFFFFFFLL);
break;
case 4:
result = Mix_PlayMusic(bgm3, 0xFFFFFFFFLL);
break;
case 5:
result = Mix_PlayMusic(titleSong, 0LL);
break;
case 6:
result = Mix_PlayMusic(keyConfig, 0xFFFFFFFFLL);
break;
default:
return result;
}
}
return result;
}

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

if ( muteBGM != 1 )
{
result = Mix_HaltMusic();
switch ( a1 )
{
case 2:
result = Mix_PlayMusic(bgm1, 0xFFFFFFFFLL);
break;
case 3:
result = Mix_PlayMusic(bgm2, 0xFFFFFFFFLL);
break;
case 4:
result = Mix_PlayMusic(bgm3, 0xFFFFFFFFLL);
break;
case 5:
result = Mix_PlayMusic(titleSong, 0LL);
break;
case 6:
result = Mix_PlayMusic(keyConfig, 0xFFFFFFFFLL);
break;
default:
return result;
}
}
return result;
}

original_code:
void playBGM(BGMType bg)
{
 if (muteBGM == 1)
 {
  return;
 }
 Mix_HaltMusic();
 switch (bg)
 {
  case BGM_1:
  Mix_PlayMusic(bgm1, -1);
  break;
  case BGM_2:
  Mix_PlayMusic(bgm2, -1);
  break;
  case BGM_3:
  Mix_PlayMusic(bgm3, -1);
  break;
  case BGM_TITLE:
  Mix_PlayMusic(titleSong, 0);
  break;
  case BGM_KEYCONFIG:
  Mix_PlayMusic(keyConfig, -1);
  break;
  default:
  break;
 }
}

canonical_original_code:
void playBGM(enum BGMType bg)
{
 if (muteBGM == 1)
 {
  return;
 }
 Mix_HaltMusic();
 switch (bg)
 {
  case BGM_1:
  Mix_PlayMusic(bgm1, -1);
  break;
  case BGM_2:
  Mix_PlayMusic(bgm2, -1);
  break;
  case BGM_3:
  Mix_PlayMusic(bgm3, -1);
  break;
  case BGM_TITLE:
  Mix_PlayMusic(titleSong, 0);
  break;
  case BGM_KEYCONFIG:
  Mix_PlayMusic(keyConfig, -1);
  break;
  default:
  break;
 }
}

variable_types: enum BGMType { BGM_NONE=0, BGM_ANGSTY=1, BGM_1=2, BGM_2=3, BGM_3=4, BGM_TITLE=5, BGM_KEYCONFIG=6 }


stopBGM

decompiled_code:
__int64 stopBGM()
{
return Mix_HaltMusic();
}

canonical_decompiled_code:
__int64 func7()
{
return Mix_HaltMusic();
}

original_code:
void stopBGM()
{
 Mix_HaltMusic();
}

canonical_original_code:
void stopBGM()
{
 Mix_HaltMusic();
}


fadeBGM

decompiled_code:
__int64 fadeBGM()
{
return Mix_FadeOutMusic(2000LL);
}

canonical_decompiled_code:
__int64 func8()
{
return Mix_FadeOutMusic(2000LL);
}

original_code:
void fadeBGM()
{
 Mix_FadeOutMusic(2000);
}


toggleBGM

decompiled_code:
_BOOL8 __fastcall toggleBGM(int a1)
{
_BOOL8 result; // rax

result = a1 == 0;
muteBGM = a1 == 0;
return result;
}

canonical_decompiled_code:
_BOOL8 __fastcall func9(int a1)
{
_BOOL8 result; // rax

result = a1 == 0;
muteBGM = a1 == 0;
return result;
}

original_code:
void toggleBGM(int aud)
{
 if (aud == 0)
 {
  muteBGM = 1;
 }
 else
 {
  muteBGM = 0;
 }
}

variable_types: aud int


toggleSFX

decompiled_code:
_BOOL8 __fastcall toggleSFX(int a1)
{
_BOOL8 result; // rax

result = a1 == 0;
muteSFX = a1 == 0;
return result;
}

canonical_decompiled_code:
_BOOL8 __fastcall func10(int a1)
{
_BOOL8 result; // rax

result = a1 == 0;
muteSFX = a1 == 0;
return result;
}

original_code:
void toggleSFX(int aud)
{
 if (aud == 0)
 {
  muteSFX = 1;
 }
 else
 {
  muteSFX = 0;
 }
}


repo: FunkyCat/crypt-bruteforce

decompiled_code:
__int64 __fastcall parse_args(int argc, char **argv, __int64 a3)
{
int v4; // eax
int v5; // eax
int v6; // eax
int v7; // eax
int v8; // eax
int v9; // eax
char *v11; // rax
char *v12; // rax

while ( 1 )
{
v4 = getopt(argc, argv, "smctlbpahxye");
if ( v4 == -1 )
break;
switch ( v4 )
{
case 'a':
v7 = optind++;
*(_DWORD *)(a3 + 188) = inet_addr(argv[v7]);
break;
case 'b':
v6 = optind++;
*(_DWORD *)(a3 + 176) = atoi(argv[v6]);
break;
case 'c':
*(_DWORD *)(a3 + 180) = 2;
break;
case 'e':
*(_DWORD *)(a3 + 180) = 6;
break;
case 'h':
v9 = optind++;
*(_QWORD *)(a3 + 16) = argv[v9];
break;
case 'l':
v5 = optind++;
*(_DWORD *)(a3 + 8) = atoi(argv[v5]);
break;
case 'm':
*(_DWORD *)(a3 + 180) = 1;
break;
case 'p':
v8 = optind++;
*(_WORD *)(a3 + 184) = atoi(argv[v8]);
break;
case 's':
*(_DWORD *)(a3 + 180) = 0;
break;
case 't':
*(_DWORD *)(a3 + 180) = 3;
break;
case 'x':
*(_DWORD *)(a3 + 180) = 5;
break;
case 'y':
*(_DWORD *)(a3 + 180) = 4;
break;
default:
fprintf(stderr, "Usage: %s [-smctlbaph]\n", *argv);
exit(1);
}
}
if ( *(int *)(a3 + 176) < 0 )
{
fwrite("Block size parameter can't be less then 0\n", 1uLL, 0x2AuLL, stderr);
exit(1);
}
if ( *(int *)(a3 + 8) <= 0 )
{
fwrite("Max length parameter can't be less then 1\n", 1uLL, 0x2AuLL, stderr);
exit(1);
}
if ( *(__int16 *)(a3 + 184) <= 0 )
{
fwrite("Port value should be between 1 and 65535\n", 1uLL, 0x29uLL, stderr);
exit(1);
}
if ( !*(_QWORD *)(a3 + 16) && ((*(_DWORD *)(a3 + 180) - 2) & 0xFFFFFFFD) != 0 )
{
fwrite("error: hash not defined\n", 1uLL, 0x18uLL, stderr);
exit(1);
}
switch ( *(_DWORD *)(a3 + 180) )
{
case 0:
puts("run_mode = RM_SINGLE");
printf("hash = %s\n", *(const char **)(a3 + 16));
break;
case 1:
puts("run_mode = RM_MULTI");
printf("hash = %s\n", *(const char **)(a3 + 16));
break;
case 2:
puts("run_mode = RM_CLIENT");
printf("port = %d\n", (unsigned int)*(__int16 *)(a3 + 184));
v11 = inet_ntoa(*(struct in_addr *)(a3 + 188));
printf("addr = %s\n", v11);
break;
case 3:
puts("run_mode = RM_SERVER");
printf("port = %d\n", (unsigned int)*(__int16 *)(a3 + 184));
break;
case 4:
puts("run_mode = RM_CLIENT_ASYNC");
printf("port = %d\n", (unsigned int)*(__int16 *)(a3 + 184));
v12 = inet_ntoa(*(struct in_addr *)(a3 + 188));
printf("addr = %s\n", v12);
break;
case 5:
puts("run_mode = RM_SERVER_ASYNC");
printf("port = %d\n", (unsigned int)*(__int16 *)(a3 + 184));
break;
case 6:
puts("run_mode = RM_SERVER_EPOLL");
printf("port = %d\n", (unsigned int)*(__int16 *)(a3 + 184));
break;
default:
break;
}
printf("max_length = %d\n", *(unsigned int *)(a3 + 8));
printf("block_size = %d\n", *(unsigned int *)(a3 + 176));
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func0(int argc, char **argv, __int64 a3)
{
int v4; // eax
int v5; // eax
int v6; // eax
int v7; // eax
int v8; // eax
int v9; // eax
char *v11; // rax
char *v12; // rax

while ( 1 )
{
v4 = getopt(argc, argv, "smctlbpahxye");
if ( v4 == -1 )
break;
switch ( v4 )
{
case 'a':
v7 = optind++;
*(_DWORD *)(a3 + 188) = inet_addr(argv[v7]);
break;
case 'b':
v6 = optind++;
*(_DWORD *)(a3 + 176) = atoi(argv[v6]);
break;
case 'c':
*(_DWORD *)(a3 + 180) = 2;
break;
case 'e':
*(_DWORD *)(a3 + 180) = 6;
break;
case 'h':
v9 = optind++;
*(_QWORD *)(a3 + 16) = argv[v9];
break;
case 'l':
v5 = optind++;
*(_DWORD *)(a3 + 8) = atoi(argv[v5]);
break;
case 'm':
*(_DWORD *)(a3 + 180) = 1;
break;
case 'p':
v8 = optind++;
*(_WORD *)(a3 + 184) = atoi(argv[v8]);
break;
case 's':
*(_DWORD *)(a3 + 180) = 0;
break;
case 't':
*(_DWORD *)(a3 + 180) = 3;
break;
case 'x':
*(_DWORD *)(a3 + 180) = 5;
break;
case 'y':
*(_DWORD *)(a3 + 180) = 4;
break;
default:
fprintf(stderr, "Usage: %s [-smctlbaph]\n", *argv);
exit(1);
}
}
if ( *(int *)(a3 + 176) < 0 )
{
fwrite("Block size parameter can't be less then 0\n", 1uLL, 0x2AuLL, stderr);
exit(1);
}
if ( *(int *)(a3 + 8) <= 0 )
{
fwrite("Max length parameter can't be less then 1\n", 1uLL, 0x2AuLL, stderr);
exit(1);
}
if ( *(__int16 *)(a3 + 184) <= 0 )
{
fwrite("Port value should be between 1 and 65535\n", 1uLL, 0x29uLL, stderr);
exit(1);
}
if ( !*(_QWORD *)(a3 + 16) && ((*(_DWORD *)(a3 + 180) - 2) & 0xFFFFFFFD) != 0 )
{
fwrite("error: hash not defined\n", 1uLL, 0x18uLL, stderr);
exit(1);
}
switch ( *(_DWORD *)(a3 + 180) )
{
case 0:
puts("run_mode = RM_SINGLE");
printf("hash = %s\n", *(const char **)(a3 + 16));
break;
case 1:
puts("run_mode = RM_MULTI");
printf("hash = %s\n", *(const char **)(a3 + 16));
break;
case 2:
puts("run_mode = RM_CLIENT");
printf("port = %d\n", (unsigned int)*(__int16 *)(a3 + 184));
v11 = inet_ntoa(*(struct in_addr *)(a3 + 188));
printf("addr = %s\n", v11);
break;
case 3:
puts("run_mode = RM_SERVER");
printf("port = %d\n", (unsigned int)*(__int16 *)(a3 + 184));
break;
case 4:
puts("run_mode = RM_CLIENT_ASYNC");
printf("port = %d\n", (unsigned int)*(__int16 *)(a3 + 184));
v12 = inet_ntoa(*(struct in_addr *)(a3 + 188));
printf("addr = %s\n", v12);
break;
case 5:
puts("run_mode = RM_SERVER_ASYNC");
printf("port = %d\n", (unsigned int)*(__int16 *)(a3 + 184));
break;
case 6:
puts("run_mode = RM_SERVER_EPOLL");
printf("port = %d\n", (unsigned int)*(__int16 *)(a3 + 184));
break;
default:
break;
}
printf("max_length = %d\n", *(unsigned int *)(a3 + 8));
printf("block_size = %d\n", *(unsigned int *)(a3 + 176));
return 0LL;
}

original_code:
int parse_args (int argc, char * argv[], context_t * context)
{
  int opt;
  while ((opt = getopt (argc, argv, "smctlbpahxye")) != -1)
    {
      switch (opt)
 {
 case 's':
   context->run_mode = RM_SINGLE;
   break;
 case 'm':
   context->run_mode = RM_MULTI;
   break;
 case 'c':
   context->run_mode = RM_CLIENT;
   break;
 case 't':
   context->run_mode = RM_SERVER;
   break;
 case 'x':
   context->run_mode = RM_SERVER_ASYNC;
   break;
 case 'y':
   context->run_mode = RM_CLIENT_ASYNC;
   break;
 case 'e':
   context->run_mode = RM_SERVER_EPOLL;
   break;
 case 'l':
   context->max_length = atoi (argv[optind++]);
   break;
 case 'b':
   context->block_size = atoi (argv[optind++]);
   break;
 case 'a':
   context->addr.s_addr = inet_addr (argv[optind++]);
   break;
 case 'p':
   context->port = atoi (argv[optind++]);
   break;
 case 'h':
   context->hash = argv[optind++];
   break;
 default:
   fprintf (stderr, "Usage: %s [-smctlbaph]\n", argv[0]);
   exit (1);
 }
    }
  if (context->block_size < 0)
    {
      fprintf (stderr, "Block size parameter can't be less then 0\n");
      exit (1);
    }
  if (context->max_length < 1)
    {
      fprintf (stderr, "Max length parameter can't be less then 1\n");
      exit (1);
    }
  if (context->port < 1 || context->port > 65535)
    {
      fprintf (stderr, "Port value should be between 1 and 65535\n");
      exit (1);
    }
  if ((context->hash == ((void *)0)) && (context->run_mode != RM_CLIENT) && (context->run_mode != RM_CLIENT_ASYNC))
    {
      fprintf (stderr, "error: hash not defined\n");
      exit (1);
    }
  switch (context->run_mode)
    {
    case RM_SINGLE:
      printf ("run_mode = RM_SINGLE\n");
      printf ("hash = %s\n", context->hash);
      break;
    case RM_MULTI:
      printf ("run_mode = RM_MULTI\n");
      printf ("hash = %s\n", context->hash);
      break;
    case RM_CLIENT:
      printf ("run_mode = RM_CLIENT\n");
      printf ("port = %d\n", context->port);
      printf ("addr = %s\n", inet_ntoa (context->addr));
      break;
    case RM_SERVER:
      printf ("run_mode = RM_SERVER\n");
      printf ("port = %d\n", context->port);
      break;
    case RM_CLIENT_ASYNC:
      printf ("run_mode = RM_CLIENT_ASYNC\n");
      printf ("port = %d\n", context->port);
      printf ("addr = %s\n", inet_ntoa (context->addr));
      break;
    case RM_SERVER_ASYNC:
      printf ("run_mode = RM_SERVER_ASYNC\n");
      printf ("port = %d\n", context->port);
      break;
    case RM_SERVER_EPOLL:
      printf ("run_mode = RM_SERVER_EPOLL\n");
      printf ("port = %d\n", context->port);
      break;
    }
  printf ("max_length = %d\n", context->max_length);
  printf ("block_size = %d\n", context->block_size);
  return 0;
}

canonical_original_code:
int parse_args(int argc, char *argv[], struct context_s *context)
{
  int opt;
  while ((opt = getopt (argc, argv, "smctlbpahxye")) != -1)
    {
      switch (opt)
 {
 case 's':
   context->run_mode = RM_SINGLE;
   break;
 case 'm':
   context->run_mode = RM_MULTI;
   break;
 case 'c':
   context->run_mode = RM_CLIENT;
   break;
 case 't':
   context->run_mode = RM_SERVER;
   break;
 case 'x':
   context->run_mode = RM_SERVER_ASYNC;
   break;
 case 'y':
   context->run_mode = RM_CLIENT_ASYNC;
   break;
 case 'e':
   context->run_mode = RM_SERVER_EPOLL;
   break;
 case 'l':
   context->max_length = atoi (argv[optind++]);
   break;
 case 'b':
   context->block_size = atoi (argv[optind++]);
   break;
 case 'a':
   context->addr.s_addr = inet_addr (argv[optind++]);
   break;
 case 'p':
   context->port = atoi (argv[optind++]);
   break;
 case 'h':
   context->hash = argv[optind++];
   break;
 default:
   fprintf (stderr, "Usage: %s [-smctlbaph]\n", argv[0]);
   exit (1);
 }
    }
  if (context->block_size < 0)
    {
      fprintf (stderr, "Block size parameter can't be less then 0\n");
      exit (1);
    }
  if (context->max_length < 1)
    {
      fprintf (stderr, "Max length parameter can't be less then 1\n");
      exit (1);
    }
  if (context->port < 1 || context->port > 65535)
    {
      fprintf (stderr, "Port value should be between 1 and 65535\n");
      exit (1);
    }
  if ((context->hash == ((void *)0)) && (context->run_mode != RM_CLIENT) && (context->run_mode != RM_CLIENT_ASYNC))
    {
      fprintf (stderr, "error: hash not defined\n");
      exit (1);
    }
  switch (context->run_mode)
    {
    case RM_SINGLE:
      printf ("run_mode = RM_SINGLE\n");
      printf ("hash = %s\n", context->hash);
      break;
    case RM_MULTI:
      printf ("run_mode = RM_MULTI\n");
      printf ("hash = %s\n", context->hash);
      break;
    case RM_CLIENT:
      printf ("run_mode = RM_CLIENT\n");
      printf ("port = %d\n", context->port);
      printf ("addr = %s\n", inet_ntoa (context->addr));
      break;
    case RM_SERVER:
      printf ("run_mode = RM_SERVER\n");
      printf ("port = %d\n", context->port);
      break;
    case RM_CLIENT_ASYNC:
      printf ("run_mode = RM_CLIENT_ASYNC\n");
      printf ("port = %d\n", context->port);
      printf ("addr = %s\n", inet_ntoa (context->addr));
      break;
    case RM_SERVER_ASYNC:
      printf ("run_mode = RM_SERVER_ASYNC\n");
      printf ("port = %d\n", context->port);
      break;
    case RM_SERVER_EPOLL:
      printf ("run_mode = RM_SERVER_EPOLL\n");
      printf ("port = %d\n", context->port);
      break;
    }
  printf ("max_length = %d\n", context->max_length);
  printf ("block_size = %d\n", context->block_size);
  return 0;
}

variable_types: argc int

variable_types:
argv
char *[]

variable_types: struct context_s { char *alph; int max_length; char *hash; struct brute_result_s { union pthread_mutex_t { struct __pthread_mutex_s { int __lock; unsigned int __count; int __owner; unsigned int __nusers; int __kind; short __spins; short __elision; struct __pthread_internal_list { struct __pthread_internal_list *__prev; struct __pthread_internal_list *__next; } __list; } __data; char __size[40]; long __align; } found_mutex; char password[-1]; int found; } result; int block_size; enum run_mode_t { RM_SINGLE=0, RM_MULTI=1, RM_CLIENT=2, RM_SERVER=3, RM_CLIENT_ASYNC=4, RM_SERVER_ASYNC=5, RM_SERVER_EPOLL=6 } run_mode; short port; struct in_addr { unsigned int s_addr; } addr; int n_cpus; int listener_socket; struct queue_s { struct task_s { char password[-1]; int left; int right; int final; int id; int idx; struct crypt_data { char keysched[-1]; char sb0[32768]; char sb1[32768]; char sb2[32768]; char sb3[32768]; char crypt_3_buf[14]; char current_salt[2]; long current_saltbits; int direction; } *cd; } queue[-1]; union sem_t { char __size[32]; long __align; } full; union sem_t empty; int head; int tail; union pthread_mutex_t head_mutex; union pthread_mutex_t tail_mutex; } queue; int tasks_in_process; union pthread_mutex_t tasks_in_process_mutex; union pthread_cond_t { struct __pthread_cond_s { union { unsigned long long __wseq; struct { unsigned int __low; unsigned int __high; } __wseq32; }; union { unsigned long long __g1_start; struct { unsigned int __low; unsigned int __high; } __g1_start32; }; unsigned int __g_refs[2]; unsigned int __g_size[2]; unsigned int __g1_orig_size; unsigned int __wrefs; unsigned int __g_signals[2]; } __data; char __size[48]; long long __align; } tasks_in_process_sem; int threads; union pthread_mutex_t threads_mutex; union pthread_cond_t threads_sem; int continue_execute; union pthread_mutex_t continue_execute_mutex; union pthread_cond_t continue_execute_sem; int id; void *(*srv_client_thread)(struct context_s *, int); struct result_queue_s { struct result_s { struct brute_result_s result; int id; int idx; int final; } queue[-1]; union sem_t full; union sem_t empty; int head; int tail; union pthread_mutex_t head_mutex; union pthread_mutex_t tail_mutex; } result_queue; } *

variable_types: opt int

user_defined_types: struct context_s { char *alph; int max_length; char *hash; struct brute_result_s result; int block_size; enum run_mode_t run_mode; short port; struct in_addr addr; int n_cpus; int listener_socket; struct queue_s queue; int tasks_in_process; union pthread_mutex_t tasks_in_process_mutex; union pthread_cond_t tasks_in_process_sem; int threads; union pthread_mutex_t threads_mutex; union pthread_cond_t threads_sem; int continue_execute; union pthread_mutex_t continue_execute_mutex; union pthread_cond_t continue_execute_sem; int id; void *(*srv_client_thread)(struct context_s *, int); struct result_queue_s result_queue; }

user_defined_types: struct brute_result_s { union pthread_mutex_t found_mutex; char password[-1]; int found; }

user_defined_types: struct queue_s { struct task_s queue[-1]; union sem_t full; union sem_t empty; int head; int tail; union pthread_mutex_t head_mutex; union pthread_mutex_t tail_mutex; }

user_defined_types: union pthread_cond_t { struct __pthread_cond_s __data; char __size[48]; long long __align; }

user_defined_types: struct result_queue_s { struct result_s queue[-1]; union sem_t full; union sem_t empty; int head; int tail; union pthread_mutex_t head_mutex; union pthread_mutex_t tail_mutex; }

user_defined_types: union pthread_mutex_t { struct __pthread_mutex_s __data; char __size[40]; long __align; }

user_defined_types: struct __pthread_mutex_s { int __lock; unsigned int __count; int __owner; unsigned int __nusers; int __kind; short __spins; short __elision; struct __pthread_internal_list __list; }

user_defined_types: struct task_s { char password[-1]; int left; int right; int final; int id; int idx; struct crypt_data *cd; }


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int64 v4[407]; // [rsp+0h] [rbp-CB8h] BYREF

memset(v4, 0, 0xCA8uLL);
v4[0] = (__int64)"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
LODWORD(v4[1]) = 6;
v4[22] = 0x100000001LL;
LOWORD(v4[23]) = 3456;
v4[24] = 0xFFFFFFFF00000001LL;
parse_args(argc, (char **)argv, (__int64)v4);
switch ( HIDWORD(v4[22]) )
{
case 0:
single_mode(v4);
break;
case 1:
multi_mode(v4);
break;
case 2:
client_mode(v4);
break;
case 3:
server_mode(v4);
break;
case 4:
client_async_mode(v4);
break;
case 5:
server_async_mode(v4);
break;
case 6:
server_epoll_mode(v4);
break;
default:
break;
}
if ( ((HIDWORD(v4[22]) - 2) & 0xFFFFFFFD) != 0 )
{
if ( LODWORD(v4[21]) )
printf("Found! Password: %s\n", (const char *)&v4[8]);
else
puts("Not found");
}
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int64 v4[407]; // [rsp+0h] [rbp-CB8h] BYREF

memset(v4, 0, 0xCA8uLL);
v4[0] = (__int64)"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
LODWORD(v4[1]) = 6;
v4[22] = 0x100000001LL;
LOWORD(v4[23]) = 3456;
v4[24] = 0xFFFFFFFF00000001LL;
func0(argc, (char **)argv, (__int64)v4);
switch ( HIDWORD(v4[22]) )
{
case 0:
single_mode(v4);
break;
case 1:
multi_mode(v4);
break;
case 2:
client_mode(v4);
break;
case 3:
server_mode(v4);
break;
case 4:
client_async_mode(v4);
break;
case 5:
server_async_mode(v4);
break;
case 6:
server_epoll_mode(v4);
break;
default:
break;
}
if ( ((HIDWORD(v4[22]) - 2) & 0xFFFFFFFD) != 0 )
{
if ( LODWORD(v4[21]) )
printf("Found! Password: %s\n", (const char *)&v4[8]);
else
puts("Not found");
}
return 0;
}

original_code:
int main (int argc, char* argv[])
{
  context_t context = {
    .alph = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890",
    .max_length = 6,
    .result = {
      .found = 0,
      .password[0] = 0,
    },
    .block_size = 1,
    .run_mode = RM_MULTI,
    .port = 3456,
    .addr.s_addr = ((in_addr_t) 0x00000000),
    .n_cpus = 1,
    .hash = ((void *)0),
    .listener_socket = -1,
    .id = 0,
  };
  parse_args (argc, argv, &context);
  switch (context.run_mode)
    {
    case RM_SINGLE:
      single_mode (&context);
      break;
    case RM_MULTI:
      multi_mode (&context);
      break;
    case RM_CLIENT:
      client_mode (&context);
      break;
    case RM_SERVER:
      server_mode (&context);
      break;
    case RM_CLIENT_ASYNC:
      client_async_mode (&context);
      break;
    case RM_SERVER_ASYNC:
      server_async_mode (&context);
      break;
    case RM_SERVER_EPOLL:
      server_epoll_mode (&context);
      break;
    }
  if (context.run_mode != RM_CLIENT && context.run_mode != RM_CLIENT_ASYNC)
    {
      if (context.result.found)
 {
   printf ("Found! Password: %s\n", context.result.password);
 }
      else
 {
   printf ("Not found\n");
 }
    }
  return (0);
}

canonical_original_code:
int main(int argc, char *argv[])
{
  struct context_s context = {
    .alph = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890",
    .max_length = 6,
    .result = {
      .found = 0,
      .password[0] = 0,
    },
    .block_size = 1,
    .run_mode = RM_MULTI,
    .port = 3456,
    .addr.s_addr = ((in_addr_t) 0x00000000),
    .n_cpus = 1,
    .hash = ((void *)0),
    .listener_socket = -1,
    .id = 0,
  };
  parse_args (argc, argv, &context);
  switch (context.run_mode)
    {
    case RM_SINGLE:
      single_mode (&context);
      break;
    case RM_MULTI:
      multi_mode (&context);
      break;
    case RM_CLIENT:
      client_mode (&context);
      break;
    case RM_SERVER:
      server_mode (&context);
      break;
    case RM_CLIENT_ASYNC:
      client_async_mode (&context);
      break;
    case RM_SERVER_ASYNC:
      server_async_mode (&context);
      break;
    case RM_SERVER_EPOLL:
      server_epoll_mode (&context);
      break;
    }
  if (context.run_mode != RM_CLIENT && context.run_mode != RM_CLIENT_ASYNC)
    {
      if (context.result.found)
 {
   printf ("Found! Password: %s\n", context.result.password);
 }
      else
 {
   printf ("Not found\n");
 }
    }
  return (0);
}

variable_types: struct context_s { char *alph; int max_length; char *hash; struct brute_result_s { union pthread_mutex_t { struct __pthread_mutex_s { int __lock; unsigned int __count; int __owner; unsigned int __nusers; int __kind; short __spins; short __elision; struct __pthread_internal_list { struct __pthread_internal_list *__prev; struct __pthread_internal_list *__next; } __list; } __data; char __size[40]; long __align; } found_mutex; char password[-1]; int found; } result; int block_size; enum run_mode_t { RM_SINGLE=0, RM_MULTI=1, RM_CLIENT=2, RM_SERVER=3, RM_CLIENT_ASYNC=4, RM_SERVER_ASYNC=5, RM_SERVER_EPOLL=6 } run_mode; short port; struct in_addr { unsigned int s_addr; } addr; int n_cpus; int listener_socket; struct queue_s { struct task_s { char password[-1]; int left; int right; int final; int id; int idx; struct crypt_data { char keysched[-1]; char sb0[32768]; char sb1[32768]; char sb2[32768]; char sb3[32768]; char crypt_3_buf[14]; char current_salt[2]; long current_saltbits; int direction; } *cd; } queue[-1]; union sem_t { char __size[32]; long __align; } full; union sem_t empty; int head; int tail; union pthread_mutex_t head_mutex; union pthread_mutex_t tail_mutex; } queue; int tasks_in_process; union pthread_mutex_t tasks_in_process_mutex; union pthread_cond_t { struct __pthread_cond_s { union { unsigned long long __wseq; struct { unsigned int __low; unsigned int __high; } __wseq32; }; union { unsigned long long __g1_start; struct { unsigned int __low; unsigned int __high; } __g1_start32; }; unsigned int __g_refs[2]; unsigned int __g_size[2]; unsigned int __g1_orig_size; unsigned int __wrefs; unsigned int __g_signals[2]; } __data; char __size[48]; long long __align; } tasks_in_process_sem; int threads; union pthread_mutex_t threads_mutex; union pthread_cond_t threads_sem; int continue_execute; union pthread_mutex_t continue_execute_mutex; union pthread_cond_t continue_execute_sem; int id; void *(*srv_client_thread)(struct context_s *, int); struct result_queue_s { struct result_s { struct brute_result_s result; int id; int idx; int final; } queue[-1]; union sem_t full; union sem_t empty; int head; int tail; union pthread_mutex_t head_mutex; union pthread_mutex_t tail_mutex; } result_queue; }