decompiled_code:
void *__fastcall td_add(__int64 a1, const void *a2, const void *a3)
{
__int64 v5; // rsi
_QWORD *v6; // rax
unsigned int v7; // er13
_QWORD *v8; // r14
size_t v9; // r15
void *v10; // rax
char *v11; // rax
size_t v12; // r12
char *v13; // rbx
void *v14; // rax

v5 = (unsigned int)(*(_DWORD *)(a1 + 16) + 1);
*(_DWORD *)(a1 + 16) = v5;
v6 = realloc(*(void **)a1, 8 * v5);
*(_QWORD *)a1 = v6;
if ( !v6 )
return (void *)fwrite("Error: could not allocate memory for train data input values\n", 1uLL, 0x3DuLL, stderr);
v7 = *(_DWORD *)(a1 + 16);
v8 = v6;
v9 = 4LL * *(unsigned int *)(a1 + 20);
v10 = malloc(v9);
v8[v7 - 1] = v10;
memcpy(v10, a2, v9);
v11 = (char *)realloc(*(void **)(a1 + 8), 8LL * v7);
*(_QWORD *)(a1 + 8) = v11;
if ( !v11 )
return (void *)fwrite("Error: could not allocate memory for train data output values\n", 1uLL, 0x3EuLL, stderr);
v12 = 4LL * *(unsigned int *)(a1 + 24);
v13 = &v11[8 * (*(_DWORD *)(a1 + 16) - 1)];
v14 = malloc(v12);
*(_QWORD *)v13 = v14;
return memcpy(v14, a3, v12);
}

canonical_decompiled_code:
void *__fastcall func4(__int64 a1, const void *a2, const void *a3)
{
__int64 v5; // rsi
_QWORD *v6; // rax
unsigned int v7; // er13
_QWORD *v8; // r14
size_t v9; // r15
void *v10; // rax
char *v11; // rax
size_t v12; // r12
char *v13; // rbx
void *v14; // rax

v5 = (unsigned int)(*(_DWORD *)(a1 + 16) + 1);
*(_DWORD *)(a1 + 16) = v5;
v6 = realloc(*(void **)a1, 8 * v5);
*(_QWORD *)a1 = v6;
if ( !v6 )
return (void *)fwrite("Error: could not allocate memory for train data input values\n", 1uLL, 0x3DuLL, stderr);
v7 = *(_DWORD *)(a1 + 16);
v8 = v6;
v9 = 4LL * *(unsigned int *)(a1 + 20);
v10 = malloc(v9);
v8[v7 - 1] = v10;
memcpy(v10, a2, v9);
v11 = (char *)realloc(*(void **)(a1 + 8), 8LL * v7);
*(_QWORD *)(a1 + 8) = v11;
if ( !v11 )
return (void *)fwrite("Error: could not allocate memory for train data output values\n", 1uLL, 0x3EuLL, stderr);
v12 = 4LL * *(unsigned int *)(a1 + 24);
v13 = &v11[8 * (*(_DWORD *)(a1 + 16) - 1)];
v14 = malloc(v12);
*(_QWORD *)v13 = v14;
return memcpy(v14, a3, v12);
}

original_code:
void td_add(TD *data, float *input, float *output) {
    ;
    ;
    ;
    data->data_count++;
    data->input = (float **)realloc(data->input, sizeof(float *) * data->data_count);
    if (data->input == ((void *)0)) {
        fprintf(stderr, "Error: could not allocate memory for train data input values\n");
        return;
    }
    data->input[data->data_count - 1] = (float *)malloc(sizeof(float) * data->input_count);
    memcpy(data->input[data->data_count - 1], input, sizeof(float) * data->input_count);
    data->output = (float **)realloc(data->output, sizeof(float *) * data->data_count);
    if (data->output == ((void *)0)) {
        fprintf(stderr, "Error: could not allocate memory for train data output values\n");
        return;
    }
    data->output[data->data_count - 1] = (float *)malloc(sizeof(float) * data->output_count);
    memcpy(data->output[data->data_count - 1], output, sizeof(float) * data->output_count);
}

canonical_original_code:
void td_add(struct TD *data, float *input, float *output) {
    ;
    ;
    ;
    data->data_count++;
    data->input = (float **)realloc(data->input, sizeof(float *) * data->data_count);
    if (data->input == ((void *)0)) {
        fprintf(stderr, "Error: could not allocate memory for train data input values\n");
        return;
    }
    data->input[data->data_count - 1] = (float *)malloc(sizeof(float) * data->input_count);
    memcpy(data->input[data->data_count - 1], input, sizeof(float) * data->input_count);
    data->output = (float **)realloc(data->output, sizeof(float *) * data->data_count);
    if (data->output == ((void *)0)) {
        fprintf(stderr, "Error: could not allocate memory for train data output values\n");
        return;
    }
    data->output[data->data_count - 1] = (float *)malloc(sizeof(float) * data->output_count);
    memcpy(data->output[data->data_count - 1], output, sizeof(float) * data->output_count);
}

variable_types:
input
float *

variable_types:
output
float *


sigmoid

decompiled_code:
float __fastcall sigmoid(float a1)
{
return tanh(a1);
}

canonical_decompiled_code:
float __fastcall func0(float a1)
{
return tanh(a1);
}

original_code:
float sigmoid(float value) {
    return tanh(value);
}

variable_types: value float

return_type: float


dsigmoid

decompiled_code:
float __fastcall dsigmoid(float a1)
{
return 1.0 - a1 * a1;
}

canonical_decompiled_code:
float __fastcall func1(float a1)
{
return 1.0 - a1 * a1;
}

original_code:
float dsigmoid(float value) {
    return 1.0 - pow(value, 2);
}


original_code:
void neuron_destroy(Neuron *neuron) {
    ;
    free(neuron->inputs);
    neuron->inputs = ((void *)0);
    free(neuron->outputs);
    neuron->outputs = ((void *)0);
}

canonical_original_code:
void neuron_destroy(struct Neuron *neuron) {
    ;
    free(neuron->inputs);
    neuron->inputs = ((void *)0);
    free(neuron->outputs);
    neuron->outputs = ((void *)0);
}

variable_types: struct Neuron { float bias; float input; float output; struct Synapse { struct Neuron *input; struct Neuron *output; float weight; float change; float momentum; float learn_rate; } **inputs; struct Synapse **outputs; unsigned int input_count; unsigned int output_count; float (*sigmoid_function)(float); float (*dsigmoid_function)(float); } *

return_type: void

user_defined_types: struct Neuron { float bias; float input; float output; struct Synapse **inputs; struct Synapse **outputs; unsigned int input_count; unsigned int output_count; float (*sigmoid_function)(float); float (*dsigmoid_function)(float); }


decompiled_code:
__int64 __fastcall neuron_sigmoid(__int64 a1)
{
return (*(__int64 (__fastcall **)(float))(a1 + 40))(*(float *)(a1 + 4));
}

original_code:
float neuron_sigmoid(Neuron *neuron) {
    ;
    ;
    return neuron->sigmoid_function(neuron->input);
}

canonical_original_code:
float neuron_sigmoid(struct Neuron *neuron) {
    ;
    ;
    return neuron->sigmoid_function(neuron->input);
}

user_defined_types: struct Synapse { struct Neuron *input; struct Neuron *output; float weight; float change; float momentum; float learn_rate; }


decompiled_code:
__int64 __fastcall neuron_fire(unsigned int *a1)
{
__int64 result; // rax
unsigned int v2; // xmm0_4

result = a1[8];
if ( (_DWORD)result )
{
v2 = neuron_value(a1);
a1[1] = v2;
result = neuron_sigmoid((__int64)a1);
a1[2] = v2;
}
else
{
a1[2] = a1[1];
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func6(unsigned int *a1)
{
__int64 result; // rax
unsigned int v2; // xmm0_4

result = a1[8];
if ( (_DWORD)result )
{
v2 = neuron_value(a1);
a1[1] = v2;
result = func5((__int64)a1);
a1[2] = v2;
}
else
{
a1[2] = a1[1];
}
return result;
}

original_code:
void neuron_fire(Neuron *neuron) {
    ;
    if (neuron->input_count == 0) {
        neuron->output = neuron->input;
    }
    else {
        neuron->input = neuron_value(neuron);
        neuron->output = neuron_sigmoid(neuron);
    }
}

canonical_original_code:
void neuron_fire(struct Neuron *neuron) {
    ;
    if (neuron->input_count == 0) {
        neuron->output = neuron->input;
    }
    else {
        neuron->input = neuron_value(neuron);
        neuron->output = neuron_sigmoid(neuron);
    }
}


decompiled_code:
__int64 __fastcall neuron_dsigmoid(__int64 a1)
{
return (*(__int64 (__fastcall **)(float))(a1 + 48))(*(float *)(a1 + 8));
}

original_code:
float neuron_dsigmoid(Neuron *neuron) {
    ;
    ;
    return neuron->dsigmoid_function(neuron->output);
}

canonical_original_code:
float neuron_dsigmoid(struct Neuron *neuron) {
    ;
    ;
    return neuron->dsigmoid_function(neuron->output);
}


original_code:
TD *generate_train_data(void) {
    unsigned int inputs = 2;
    unsigned int outputs = 2;
    TD *data = td_create(inputs, outputs);
    float input[inputs];
    float output[outputs];
    input[0] = 0.75;
    input[1] = 0.25;
    output[0] = -0.25;
    output[1] = 0.75;
    td_add(data, input, output);
    input[0] = 0.25;
    input[1] = 0.75;
    output[0] = 1.0;
    output[1] = 0.0;
    td_add(data, input, output);
    return data;
}

canonical_original_code:
struct TD *generate_train_data() {
    unsigned int inputs = 2;
    unsigned int outputs = 2;
    struct TD *data = td_create(inputs, outputs);
    float input[-1];
    float output[-1];
    input[0] = 0.75;
    input[1] = 0.25;
    output[0] = -0.25;
    output[1] = 0.75;
    td_add(data, input, output);
    input[0] = 0.25;
    input[1] = 0.75;
    output[0] = 1.0;
    output[1] = 0.0;
    td_add(data, input, output);
    return data;
}

variable_types:
inputs
unsigned int

variable_types:
outputs
unsigned int

variable_types: struct TD { float **input; float **output; unsigned int data_count; unsigned int input_count; unsigned int output_count; } *

variable_types:
input
float [-1]

variable_types:
output
float [-1]


original_code:
void show_results(NN *network, TD* train_data) {
    nn_set_input(network, 0, train_data->input[0][0]);
    nn_set_input(network, 1, train_data->input[0][1]);
    nn_calculate(network);
    printf("\ninput  1:   %.2f \t%.2f\n", train_data->input[0][0], train_data->input[0][1]);
    printf("output 1:   %.2f \t%.2f\n", train_data->output[0][0], train_data->output[0][1]);
    printf("real   1:   %.2f \t%.2f\n\n", nn_read_output(network, 0), nn_read_output(network, 1));
    nn_set_input(network, 0, train_data->input[1][0]);
    nn_set_input(network, 1, train_data->input[1][1]);
    nn_calculate(network);
    printf("input  2:   %.2f \t%.2f\n", train_data->input[1][0], train_data->input[1][1]);
    printf("output 2:   %.2f \t%.2f\n", train_data->output[1][0], train_data->output[1][1]);
    printf("real   2:   %.2f \t%.2f\n\n", nn_read_output(network, 0), nn_read_output(network, 1));
}

canonical_original_code:
void show_results(struct NN *network, struct TD *train_data) {
    nn_set_input(network, 0, train_data->input[0][0]);
    nn_set_input(network, 1, train_data->input[0][1]);
    nn_calculate(network);
    printf("\ninput  1:   %.2f \t%.2f\n", train_data->input[0][0], train_data->input[0][1]);
    printf("output 1:   %.2f \t%.2f\n", train_data->output[0][0], train_data->output[0][1]);
    printf("real   1:   %.2f \t%.2f\n\n", nn_read_output(network, 0), nn_read_output(network, 1));
    nn_set_input(network, 0, train_data->input[1][0]);
    nn_set_input(network, 1, train_data->input[1][1]);
    nn_calculate(network);
    printf("input  2:   %.2f \t%.2f\n", train_data->input[1][0], train_data->input[1][1]);
    printf("output 2:   %.2f \t%.2f\n", train_data->output[1][0], train_data->output[1][1]);
    printf("real   2:   %.2f \t%.2f\n\n", nn_read_output(network, 0), nn_read_output(network, 1));
}

variable_types: struct NN { struct Neuron { float bias; float input; float output; struct Synapse { struct Neuron *input; struct Neuron *output; float weight; float change; float momentum; float learn_rate; } **inputs; struct Synapse **outputs; unsigned int input_count; unsigned int output_count; float (*sigmoid_function)(float); float (*dsigmoid_function)(float); } **layers; struct Synapse **synapses; unsigned int layer_count; unsigned int *neuron_count; unsigned int synapse_count; } *

user_defined_types: struct NN { struct Neuron **layers; struct Synapse **synapses; unsigned int layer_count; unsigned int *neuron_count; unsigned int synapse_count; }

user_defined_types: struct TD { float **input; float **output; unsigned int data_count; unsigned int input_count; unsigned int output_count; }


repo: Ricordel/parallel-programming-odes

decompiled_code:
int print_help()
{
puts("Usage: prog-name [args]\n");
puts("Available arguments:");
puts("\t-h --help print this message and exit");
puts("\t-n --n-iterations n number of iterations");
puts("\t-o --output-prefix pref Prefix to the output files. They'll be pref1.dat, pref2.dat, ...");
return puts("\t-s --n-steps num Number of steps in the discretization");
}

canonical_decompiled_code:
int func0()
{
puts("Usage: prog-name [args]\n");
puts("Available arguments:");
puts("\t-h --help print this message and exit");
puts("\t-n --n-iterations n number of iterations");
puts("\t-o --output-prefix pref Prefix to the output files. They'll be pref1.dat, pref2.dat, ...");
return puts("\t-s --n-steps num Number of steps in the discretization");
}

original_code:
static void print_help()
{
        puts("Usage: prog-name [args]\n");
        puts("Available arguments:");
        puts("\t-h --help                 print this message and exit");
        puts("\t-n --n-iterations n       number of iterations");
        puts("\t-o --output-prefix pref   Prefix to the output files. They'll be pref1.dat, pref2.dat, ...");
        puts("\t-s --n-steps num          Number of steps in the discretization");
}


decompiled_code:
__int64 __fastcall parse_options(_QWORD *a1, int a2, char *const *a3)
{
int i; // eax
char *v5; // r14
size_t v6; // rax
char *v7; // rax
int *v9; // rax
char *v10; // r8
int *v11; // rbx
size_t v12; // rdx
FILE *v13; // rcx
const char *v14; // rdi
int *v15; // rax
char *v16; // r8
int *v17; // rax
char *v18; // r8
__int64 v19; // rcx
int *v20; // rax
int *v21; // rax
char *v22; // r8

a1[1] = "output";
*a1 = 0x3E8000F4240LL;
for ( i = getopt_long(a2, a3, "hn:o:s:", &longOpts, 0LL); i != -1; i = getopt_long(a2, a3, "hn:o:s:", &longOpts, 0LL) )
{
if ( i == 110 )
{
if ( (int)_isoc99_sscanf(optarg, "%u", a1) < 0 )
{
v15 = _errno_location();
v16 = "None";
v11 = v15;
if ( *v15 )
v16 = strerror(*v15);
fprintf(stderr, "[ERROR] (%s%d: errno: %s) ", "src/option_parser.c", 56LL, v16);
v12 = 40LL;
v13 = stderr;
v14 = "Failed to parse the number of iterations";
LABEL_17:
fwrite(v14, 1uLL, v12, v13);
fputc(10, stderr);
*v11 = 0;
abort();
}
}
else
{
if ( i <= 110 )
{
if ( i )
{
if ( i == 104 )
{
print_help();
exit(0);
}
LABEL_22:
v17 = _errno_location();
v18 = "None";
if ( *v17 )
v18 = strerror(*v17);
v19 = 77LL;
}
else
{
v20 = _errno_location();
v18 = "None";
if ( *v20 )
v18 = strerror(*v20);
v19 = 73LL;
}
fprintf(stderr, "[ERROR] (%s%d: errno: %s) ", "src/option_parser.c", v19, v18);
fprintf(stderr, "Unknown argument %s\n", a3[optind]);
fputc(10, stderr);
exit(1);
}
if ( i == 111 )
{
v5 = optarg;
v6 = strlen(optarg);
v7 = (char *)malloc(v6 + 1);
a1[1] = v7;
if ( !v7 )
{
v21 = _errno_location();
v22 = "None";
v11 = v21;
if ( *v21 )
v22 = strerror(*v21);
fprintf(stderr, "[ERROR] (%s%d: errno: %s) ", "src/option_parser.c", 60LL, v22);
v12 = 14LL;
v13 = stderr;
v14 = "Out of memory.";
goto LABEL_17;
}
strcpy(v7, v5);
}
else
{
if ( i != 115 )
goto LABEL_22;
if ( (int)_isoc99_sscanf(optarg, "%u", (char *)a1 + 4) < 0 )
{
v9 = _errno_location();
v10 = "None";
v11 = v9;
if ( *v9 )
v10 = strerror(*v9);
fprintf(stderr, "[ERROR] (%s%d: errno: %s) ", "src/option_parser.c", 66LL, v10);
v12 = 35LL;
v13 = stderr;
v14 = "Failed to parse the number of steps";
goto LABEL_17;
}
}
}
}
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func1(_QWORD *a1, int a2, char *const *a3)
{
int i; // eax
char *v5; // r14
size_t v6; // rax
char *v7; // rax
int *v9; // rax
char *v10; // r8
int *v11; // rbx
size_t v12; // rdx
FILE *v13; // rcx
const char *v14; // rdi
int *v15; // rax
char *v16; // r8
int *v17; // rax
char *v18; // r8
__int64 v19; // rcx
int *v20; // rax
int *v21; // rax
char *v22; // r8

a1[1] = "output";
*a1 = 0x3E8000F4240LL;
for ( i = getopt_long(a2, a3, "hn:o:s:", &longOpts, 0LL); i != -1; i = getopt_long(a2, a3, "hn:o:s:", &longOpts, 0LL) )
{
if ( i == 110 )
{
if ( (int)_isoc99_sscanf(optarg, "%u", a1) < 0 )
{
v15 = _errno_location();
v16 = "None";
v11 = v15;
if ( *v15 )
v16 = strerror(*v15);
fprintf(stderr, "[ERROR] (%s%d: errno: %s) ", "src/option_parser.c", 56LL, v16);
v12 = 40LL;
v13 = stderr;
v14 = "Failed to parse the number of iterations";
LABEL_17:
fwrite(v14, 1uLL, v12, v13);
fputc(10, stderr);
*v11 = 0;
abort();
}
}
else
{
if ( i <= 110 )
{
if ( i )
{
if ( i == 104 )
{
func0();
exit(0);
}
LABEL_22:
v17 = _errno_location();
v18 = "None";
if ( *v17 )
v18 = strerror(*v17);
v19 = 77LL;
}
else
{
v20 = _errno_location();
v18 = "None";
if ( *v20 )
v18 = strerror(*v20);
v19 = 73LL;
}
fprintf(stderr, "[ERROR] (%s%d: errno: %s) ", "src/option_parser.c", v19, v18);
fprintf(stderr, "Unknown argument %s\n", a3[optind]);
fputc(10, stderr);
exit(1);
}
if ( i == 111 )
{
v5 = optarg;
v6 = strlen(optarg);
v7 = (char *)malloc(v6 + 1);
a1[1] = v7;
if ( !v7 )
{
v21 = _errno_location();
v22 = "None";
v11 = v21;
if ( *v21 )
v22 = strerror(*v21);
fprintf(stderr, "[ERROR] (%s%d: errno: %s) ", "src/option_parser.c", 60LL, v22);
v12 = 14LL;
v13 = stderr;
v14 = "Out of memory.";
goto LABEL_17;
}
strcpy(v7, v5);
}
else
{
if ( i != 115 )
goto LABEL_22;
if ( (int)_isoc99_sscanf(optarg, "%u", (char *)a1 + 4) < 0 )
{
v9 = _errno_location();
v10 = "None";
v11 = v9;
if ( *v9 )
v10 = strerror(*v9);
fprintf(stderr, "[ERROR] (%s%d: errno: %s) ", "src/option_parser.c", 66LL, v10);
v12 = 35LL;
v13 = stderr;
v14 = "Failed to parse the number of steps";
goto LABEL_17;
}
}
}
}
return 0LL;
}

original_code:
int parse_options(struct prog_options *pProgOptions, int argc, char **argv)
{
        pProgOptions->nIterations = 1000000;
        pProgOptions->outFilePrefix = "output";
        pProgOptions->nSteps = 1000;
        int ret = 0;
        int opt = getopt_long(argc, argv, shortOpts, longOpts, ((void *)0));
        while (opt != -1) {
                switch (opt) {
                        case 'n':
                                ret = sscanf(optarg, "%u", &pProgOptions->nIterations);
                                if(!(ret >= 0)) { fprintf(stderr, "[ERROR] (%s%d: errno: %s) ", "src/option_parser.c", 56, ((*__errno_location ()) == 0 ? "None" : strerror((*__errno_location ())))); fprintf(stderr, "Failed to parse the number of iterations"); fprintf(stderr, "\n"); (*__errno_location ())=0; abort(); };
                                break;
                        case 'o':
                                pProgOptions->outFilePrefix = malloc(strlen(optarg) + 1);
                                if(!((pProgOptions->outFilePrefix))) { fprintf(stderr, "[ERROR] (%s%d: errno: %s) ", "src/option_parser.c", 60, ((*__errno_location ()) == 0 ? "None" : strerror((*__errno_location ())))); fprintf(stderr, "Out of memory."); fprintf(stderr, "\n"); (*__errno_location ())=0; abort(); };
                                strcpy(pProgOptions->outFilePrefix, optarg);
                                if(!(ret >= 0)) { fprintf(stderr, "[ERROR] (%s%d: errno: %s) ", "src/option_parser.c", 62, ((*__errno_location ()) == 0 ? "None" : strerror((*__errno_location ())))); fprintf(stderr, "Failed to copy outfile prefix"); fprintf(stderr, "\n"); (*__errno_location ())=0; abort(); };
                                break;
                        case 's':
                                ret = sscanf(optarg, "%u", &pProgOptions->nSteps);
                                if(!(ret >= 0)) { fprintf(stderr, "[ERROR] (%s%d: errno: %s) ", "src/option_parser.c", 66, ((*__errno_location ()) == 0 ? "None" : strerror((*__errno_location ())))); fprintf(stderr, "Failed to parse the number of steps"); fprintf(stderr, "\n"); (*__errno_location ())=0; abort(); };
                                break;
                        case 'h':
                                print_help();
                                exit(0);
                                break;
                        case 0:
                                fprintf(stderr, "[ERROR] (%s%d: errno: %s) ", "src/option_parser.c", 73, ((*__errno_location ()) == 0 ? "None" : strerror((*__errno_location ())))); fprintf(stderr, "Unknown argument %s\n", argv[optind]); fprintf(stderr, "\n");
                                exit(1);
                                break;
                        default:
                                fprintf(stderr, "[ERROR] (%s%d: errno: %s) ", "src/option_parser.c", 77, ((*__errno_location ()) == 0 ? "None" : strerror((*__errno_location ())))); fprintf(stderr, "Unknown argument %s\n", argv[optind]); fprintf(stderr, "\n");
                                exit(1);
                                break;
                }
                opt = getopt_long(argc, argv, shortOpts, longOpts, ((void *)0));
        }
        ;
        return 0;
}

variable_types: struct prog_options { unsigned int nIterations; unsigned int nSteps; char *outFilePrefix; } *

variable_types: argc int

variable_types:
argv
char **

variable_types: ret int

variable_types: opt int

return_type: int


printfDbg

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

va_start(arg, a1);
return vprintf(a1, arg);
}

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

va_start(arg, a1);
return vprintf(a1, arg);
}

original_code:
void printfDbg(const char *format, ...) {
 va_list args;
 __builtin_va_start(args,format);
 if (1) {
  vprintf(format, args);
 }
 __builtin_va_end(args);
}

canonical_original_code:
void printfDbg(char *format, ...) {
 __builtin_va_list args;
 __builtin_va_start(args,format);
 if (1) {
  vprintf(format, args);
 }
 __builtin_va_end(args);
}

variable_types:
format
char *


isPathSelf

decompiled_code:
_BOOL8 __fastcall isPathSelf(unsigned __int8 *a1)
{
int v1; // eax

v1 = *a1 - 46;
if ( *a1 == 46 )
v1 = a1[1];
return v1 == 0;
}

canonical_decompiled_code:
_BOOL8 __fastcall func1(unsigned __int8 *a1)
{
int v1; // eax

v1 = *a1 - 46;
if ( *a1 == 46 )
v1 = a1[1];
return v1 == 0;
}

original_code:
int isPathSelf(const char *path) {
 if (strcmp(path, ".") == 0) {
  return 1;
 }
 return 0;
}

canonical_original_code:
int isPathSelf(char *path) {
 if (strcmp(path, ".") == 0) {
  return 1;
 }
 return 0;
}

variable_types:
path
char *


buildBakPath

decompiled_code:
char *__fastcall buildBakPath(char *src, int a2)
{
const char *v2; // r14
size_t v3; // r13
int v4; // er12
const char *v5; // r15
int v6; // eax
char *v7; // r12
size_t v8; // rax
size_t v10; // rax
size_t v11; // rax

v2 = bakDir;
v3 = strlen(bakDir);
v4 = v3 + 1;
if ( !isPathSelf((unsigned __int8 *)src) )
v4 = v3 + strlen(src) + 2;
if ( a2 )
{
v7 = (char *)calloc(v4, 1uLL);
strncpy(v7, v2, v3);
if ( !isPathSelf((unsigned __int8 *)src) )
{
v7[strlen(v2)] = 47;
v10 = strlen(src);
strncat(v7, src, v10);
}
}
else
{
v5 = suffix;
v6 = strlen(suffix);
v7 = (char *)calloc(v4 + v6, 1uLL);
strncpy(v7, v2, v3);
if ( !isPathSelf((unsigned __int8 *)src) )
{
v7[strlen(v2)] = 47;
v11 = strlen(src);
strncat(v7, src, v11);
v5 = suffix;
}
v8 = strlen(v5);
strncat(v7, v5, v8);
}
return v7;
}

canonical_decompiled_code:
char *__fastcall func2(char *src, int a2)
{
const char *v2; // r14
size_t v3; // r13
int v4; // er12
const char *v5; // r15
int v6; // eax
char *v7; // r12
size_t v8; // rax
size_t v10; // rax
size_t v11; // rax

v2 = bakDir;
v3 = strlen(bakDir);
v4 = v3 + 1;
if ( !func1((unsigned __int8 *)src) )
v4 = v3 + strlen(src) + 2;
if ( a2 )
{
v7 = (char *)calloc(v4, 1uLL);
strncpy(v7, v2, v3);
if ( !func1((unsigned __int8 *)src) )
{
v7[strlen(v2)] = 47;
v10 = strlen(src);
strncat(v7, src, v10);
}
}
else
{
v5 = suffix;
v6 = strlen(suffix);
v7 = (char *)calloc(v4 + v6, 1uLL);
strncpy(v7, v2, v3);
if ( !func1((unsigned __int8 *)src) )
{
v7[strlen(v2)] = 47;
v11 = strlen(src);
strncat(v7, src, v11);
v5 = suffix;
}
v8 = strlen(v5);
strncat(v7, v5, v8);
}
return v7;
}

original_code:
char *buildBakPath(const char *path, int dir) {
 int bakPathLen = strlen(bakDir) + 1;
 if (!isPathSelf(path)) {
  bakPathLen += strlen(path) + 1;
 }
 if (!dir) {
  bakPathLen += strlen(suffix);
 }
 char *bakPath = malloc(bakPathLen);
 memset(bakPath, '\0', bakPathLen);
 strncpy(bakPath, bakDir, strlen(bakDir));
 if (!isPathSelf(path)) {
  bakPath[strlen(bakDir)] = '/';
  strncat(bakPath, path, strlen(path));
 }
 if (!dir) {
  strncat(bakPath, suffix, strlen(suffix));
 }
 return bakPath;
}

canonical_original_code:
char *buildBakPath(char *path, int dir) {
 int bakPathLen = strlen(bakDir) + 1;
 if (!isPathSelf(path)) {
  bakPathLen += strlen(path) + 1;
 }
 if (!dir) {
  bakPathLen += strlen(suffix);
 }
 char *bakPath = malloc(bakPathLen);
 memset(bakPath, '\0', bakPathLen);
 strncpy(bakPath, bakDir, strlen(bakDir));
 if (!isPathSelf(path)) {
  bakPath[strlen(bakDir)] = '/';
  strncat(bakPath, path, strlen(path));
 }
 if (!dir) {
  strncat(bakPath, suffix, strlen(suffix));
 }
 return bakPath;
}

variable_types: dir int

variable_types: bakPathLen int

variable_types:
bakPath
char *

return_type: char *


buildEntryPath

decompiled_code:
char *__fastcall buildEntryPath(char *src, char *a2)
{
size_t v2; // r15
size_t v3; // r13
char *v4; // r12

v2 = strlen(src);
v3 = strlen(a2);
v4 = (char *)calloc((int)v2 + (int)v3 + 2, 1uLL);
strncpy(v4, src, v2);
*(_WORD *)&v4[strlen(v4)] = 47;
return strncat(v4, a2, v3);
}

canonical_decompiled_code:
char *__fastcall func4(char *src, char *a2)
{
size_t v2; // r15
size_t v3; // r13
char *v4; // r12

v2 = strlen(src);
v3 = strlen(a2);
v4 = (char *)calloc((int)v2 + (int)v3 + 2, 1uLL);
strncpy(v4, src, v2);
*(_WORD *)&v4[strlen(v4)] = 47;
return strncat(v4, a2, v3);
}

original_code:
char *buildEntryPath(const char *path, const char *entry_name) {
 int entryPathLen = strlen(path) + strlen(entry_name) + 2;
 char *entryPath = malloc(entryPathLen);
 memset(entryPath, '\0', entryPathLen);
 strncpy(entryPath, path, strlen(path));
 strncat(entryPath, "/", strlen("/"));
 strncat(entryPath, entry_name, strlen(entry_name));
 return entryPath;
}

canonical_original_code:
char *buildEntryPath(char *path, char *entry_name) {
 int entryPathLen = strlen(path) + strlen(entry_name) + 2;
 char *entryPath = malloc(entryPathLen);
 memset(entryPath, '\0', entryPathLen);
 strncpy(entryPath, path, strlen(path));
 strncat(entryPath, "/", strlen("/"));
 strncat(entryPath, entry_name, strlen(entry_name));
 return entryPath;
}

variable_types: entryPathLen int

variable_types:
entryPath
char *


isValidEntry

original_code:
int isValidEntry(const struct dirent *entry) {
 const char *name = entry->d_name;
 if (!strcmp(name, ".") || !strcmp(name, "..") || !strcmp(name, bakDir)) {
  return 0;
 }
 return 1;
}

canonical_original_code:
int isValidEntry(struct dirent *entry) {
 char *name = entry->d_name;
 if (!strcmp(name, ".") || !strcmp(name, "..") || !strcmp(name, bakDir)) {
  return 0;
 }
 return 1;
}

variable_types: struct dirent { unsigned long d_ino; long d_off; unsigned short d_reclen; unsigned char d_type; char d_name[256]; } *

variable_types:
name
char *


backup

decompiled_code:
void __fastcall backup(void *a1)
{
char *v1; // r12

v1 = buildBakPath((char *)a1, 0);
copyFile((char *)a1, v1, 0);
free(v1);
free(a1);
}

canonical_decompiled_code:
void __fastcall func8(void *a1)
{
char *v1; // r12

v1 = func2((char *)a1, 0);
func7((char *)a1, v1, 0);
free(v1);
free(a1);
}

original_code:
void backup(char *path) {
 char *destPath = buildBakPath(path, 0);
 copyFile(path, destPath, M_BACKUP);
 free(destPath);
 free(path);
}

variable_types:
destPath
char *


restore

decompiled_code:
void __fastcall restore(void *a1)
{
char *v1; // r12

v1 = buildResPath((const char *)a1, 0);
copyFile((char *)a1, v1, 1);
free(v1);
free(a1);
}

canonical_decompiled_code:
void __fastcall func9(void *a1)
{
char *v1; // r12

v1 = func3((const char *)a1, 0);
func7((char *)a1, v1, 1);
free(v1);
free(a1);
}

original_code:
void restore(char *path) {
 char *destPath = buildResPath(path, 0);
 copyFile(path, destPath, M_RESTORE);
 free(destPath);
 free(path);
}


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
const char *v3; // rax

v3 = argv[argc - 1];
if ( *(_WORD *)v3 != 29229 || v3[2] )
copyDir(".", 0);
else
copyDir(bakDir, 1u);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
const char *v3; // rax

v3 = argv[argc - 1];
if ( *(_WORD *)v3 != 29229 || v3[2] )
func10(".", 0);
else
func10(bakDir, 1u);
return 0;
}

original_code:
int main(int argc, char *argv[]) {
 if (strcmp(argv[argc - 1], "-r") == 0) {
  copyDir(bakDir, M_RESTORE);
 } else {
  copyDir(".", M_BACKUP);
 }
 return 0;
}

variable_types:
argv
char *[]


LireChaine

decompiled_code:
size_t __fastcall LireChaine(char *s)
{
size_t result; // rax

fgets(s, 50, stdin);
result = strlen(s);
s[result - 1] = 0;
return result;
}

canonical_decompiled_code:
size_t __fastcall func1(char *s)
{
size_t result; // rax

fgets(s, 50, stdin);
result = strlen(s);
s[result - 1] = 0;
return result;
}

original_code:
void LireChaine(char chaine[])
{
    fgets(chaine, 50, stdin);
    chaine[strlen(chaine) - 1] = '\0';
}

variable_types:
chaine
char []


Argument

original_code:
void Argument(char chaine1[],char chaine2[],int choix)
{
 int i=0, i2=0;
 char chainetmp[50];
 if(choix == 1)
 {
  while((i<50)&&(chaine1[i] != ':'))
  {
   if(chaine1[i] != ' ')
   {
    chainetmp[i]=chaine1[i];
   }
   i++;
  }
  chainetmp[i-1]='\0';
 }
 if(choix == 0)
 {
  while((i<50)&&(chaine1[i] != ':'))
  {
   i++;
  }
  i+=2;
  while((i<50)&&(chaine1[i] != '('))
  {
   if(chaine1[i] != ' ')
   {
    chainetmp[i2]=chaine1[i];
   }
   i++;
   i2++;
  }
  chainetmp[i-1]='\0';
 }
 strcpy(chaine2,chainetmp);
}

canonical_original_code:
void Argument(char chaine1[], char chaine2[], int choix)
{
 int i = 0; int i2 = 0;
 char chainetmp[50];
 if(choix == 1)
 {
  while((i<50)&&(chaine1[i] != ':'))
  {
   if(chaine1[i] != ' ')
   {
    chainetmp[i]=chaine1[i];
   }
   i++;
  }
  chainetmp[i-1]='\0';
 }
 if(choix == 0)
 {
  while((i<50)&&(chaine1[i] != ':'))
  {
   i++;
  }
  i+=2;
  while((i<50)&&(chaine1[i] != '('))
  {
   if(chaine1[i] != ' ')
   {
    chainetmp[i2]=chaine1[i];
   }
   i++;
   i2++;
  }
  chainetmp[i-1]='\0';
 }
 strcpy(chaine2,chainetmp);
}

variable_types: choix int

variable_types: i int

variable_types:
chainetmp
char [50]


NbLigne

decompiled_code:
__int64 __fastcall NbLigne(char *a1)
{
char v1; // al
_BYTE *v2; // rdi
unsigned int v3; // er8

v1 = *a1;
if ( !*a1 )
return 0LL;
v2 = a1 + 1;
v3 = 0;
do
{
++v2;
v3 += v1 == 91;
v1 = *(v2 - 1);
}
while ( v1 );
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func4(char *a1)
{
char v1; // al
_BYTE *v2; // rdi
unsigned int v3; // er8

v1 = *a1;
if ( !*a1 )
return 0LL;
v2 = a1 + 1;
v3 = 0;
do
{
++v2;
v3 += v1 == 91;
v1 = *(v2 - 1);
}
while ( v1 );
return v3;
}

original_code:
int NbLigne(char chaine[])
{
 int i=0, rows=0;
 while(chaine[i] != '\0')
 {
  if(chaine[i] == '[')
  {
   rows++;
  }
  i++;
 }
  return rows;
}

canonical_original_code:
int NbLigne(char chaine[])
{
 int i = 0; int rows = 0;
 while(chaine[i] != '\0')
 {
  if(chaine[i] == '[')
  {
   rows++;
  }
  i++;
 }
  return rows;
}

variable_types: rows int


NbColonne

original_code:
int NbColonne(char chaine[])
{
 int i=0, col=0;
 while((chaine[i] != '\0')&&(chaine[i] != ']'))
 {
  if(chaine[i] == ',')
  {
   col++;
  }
  i++;
 }
 return col;
}

canonical_original_code:
int NbColonne(char chaine[])
{
 int i = 0; int col = 0;
 while((chaine[i] != '\0')&&(chaine[i] != ']'))
 {
  if(chaine[i] == ',')
  {
   col++;
  }
  i++;
 }
 return col;
}

variable_types: col int


addition

original_code:
Matrix addition(Matrix m1, Matrix m2)
{
 Matrix m = newMatrix(m1->nrows, m1->ncols);
 int i, l = (m->nrows)*(m->ncols);
 for(i = 0; i < l; i++)
 {
  m->mat[i] = m1->mat[i] + m2->mat[i];
 }
 return m;
}

canonical_original_code:
struct matrix *addition(struct matrix *m1, struct matrix *m2)
{
 struct matrix *m = newMatrix(m1->nrows, m1->ncols);
 int i; int l = (m->nrows)*(m->ncols);
 for(i = 0; i < l; i++)
 {
  m->mat[i] = m1->mat[i] + m2->mat[i];
 }
 return m;
}

variable_types: struct matrix { float *mat; int nrows; } *

variable_types: l int


soustraction

original_code:
Matrix soustraction(Matrix m1,Matrix m2)
{
 Matrix m = newMatrix(m1->nrows, m1->ncols);
 int i, l = (m->nrows)*(m->ncols);
 for(i = 0; i < l; i++)
 {
  m->mat[i] = m1->mat[i] - m2->mat[i];
 }
 return m;
}

canonical_original_code:
struct matrix *soustraction(struct matrix *m1, struct matrix *m2)
{
 struct matrix *m = newMatrix(m1->nrows, m1->ncols);
 int i; int l = (m->nrows)*(m->ncols);
 for(i = 0; i < l; i++)
 {
  m->mat[i] = m1->mat[i] - m2->mat[i];
 }
 return m;
}

return_type: struct matrix { float *mat; int nrows; } *


multiplication

decompiled_code:
__int64 __fastcall multiplication(__int64 a1, __int64 a2)
{
unsigned int v2; // er13
__int64 v3; // r15
unsigned int i; // er12
double v5; // xmm1_8
unsigned int j; // ebx
float v8; // [rsp+8h] [rbp-40h]

v2 = 0;
v3 = newMatrix(*(unsigned int *)(a1 + 8), *(unsigned int *)(a2 + 12));
while ( *(_DWORD *)(a2 + 12) > (signed int)v2 )
{
++v2;
for ( i = 0; *(_DWORD *)(a1 + 8) > (signed int)i; setElt(v3, i, v2, v5) )
{
++i;
v5 = 0.0;
for ( j = 0; (signed int)j < *(_DWORD *)(a1 + 12); *(float *)&v5 = *(float *)&v5 + (float)(getElt(a2, j, v2) * v8) )
{
v8 = getElt(a1, i, ++j);
*(_QWORD *)&v5 = LODWORD(v5);
}
}
}
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, __int64 a2)
{
unsigned int v2; // er13
__int64 v3; // r15
unsigned int i; // er12
double v5; // xmm1_8
unsigned int j; // ebx
float v8; // [rsp+8h] [rbp-40h]

v2 = 0;
v3 = newMatrix(*(unsigned int *)(a1 + 8), *(unsigned int *)(a2 + 12));
while ( *(_DWORD *)(a2 + 12) > (signed int)v2 )
{
++v2;
for ( i = 0; *(_DWORD *)(a1 + 8) > (signed int)i; setElt(v3, i, v2, v5) )
{
++i;
v5 = 0.0;
for ( j = 0; (signed int)j < *(_DWORD *)(a1 + 12); *(float *)&v5 = *(float *)&v5 + (float)(getElt(a2, j, v2) * v8) )
{
v8 = getElt(a1, i, ++j);
*(_QWORD *)&v5 = LODWORD(v5);
}
}
}
return v3;
}

original_code:
Matrix multiplication(Matrix m1, Matrix m2)
{
 Matrix m = newMatrix(m1->nrows, m2->ncols);
 int i, j, k;
 float s = 0;
 for(k = 0; k < m2->ncols; k++)
 {
  for(j = 0; j < m1->nrows; j++)
  {
   for(i = 0; i < m1->ncols; i++)
   {
    s += getElt(m1, j+1, i+1)*getElt(m2, i+1, k+1);
   }
   setElt(m, j+1, k+1, s);
   s = 0;
  }
 }
 return m;
}

canonical_original_code:
struct matrix *multiplication(struct matrix *m1, struct matrix *m2)
{
 struct matrix *m = newMatrix(m1->nrows, m2->ncols);
 int i; int j; int k;
 float s = 0;
 for(k = 0; k < m2->ncols; k++)
 {
  for(j = 0; j < m1->nrows; j++)
  {
   for(i = 0; i < m1->ncols; i++)
   {
    s += getElt(m1, j+1, i+1)*getElt(m2, i+1, k+1);
   }
   setElt(m, j+1, k+1, s);
   s = 0;
  }
 }
 return m;
}

variable_types: j int

variable_types: k int

variable_types: s float

user_defined_types: struct matrix { float *mat; int nrows; }


transpose

decompiled_code:
__int64 __fastcall transpose(__int64 a1, double a2)
{
unsigned int v2; // ebp
__int64 v3; // r12
unsigned int i; // ebx

v2 = 0;
v3 = newMatrix(*(unsigned int *)(a1 + 12), *(unsigned int *)(a1 + 8));
if ( *(int *)(v3 + 8) > 0 )
{
do
{
++v2;
for ( i = 0; (signed int)i < *(_DWORD *)(v3 + 12); setElt(v3, v2, i, a2) )
*(float *)&a2 = getElt(a1, ++i, v2);
}
while ( *(_DWORD *)(v3 + 8) > (signed int)v2 );
}
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, double a2)
{
unsigned int v2; // ebp
__int64 v3; // r12
unsigned int i; // ebx

v2 = 0;
v3 = newMatrix(*(unsigned int *)(a1 + 12), *(unsigned int *)(a1 + 8));
if ( *(int *)(v3 + 8) > 0 )
{
do
{
++v2;
for ( i = 0; (signed int)i < *(_DWORD *)(v3 + 12); setElt(v3, v2, i, a2) )
*(float *)&a2 = getElt(a1, ++i, v2);
}
while ( *(_DWORD *)(v3 + 8) > (signed int)v2 );
}
return v3;
}

original_code:
Matrix transpose(Matrix m)
{
    Matrix mt = newMatrix(m->ncols, m->nrows);
    int i, j;
    for(j = 0 ; j < mt->nrows ; j++)
    {
        for(i = 0 ; i < mt->ncols ; i++)
        {
            setElt(mt, j+1, i+1, getElt(m, i+1, j+1));
        }
    }
    return mt;
}

canonical_original_code:
struct matrix *transpose(struct matrix *m)
{
    struct matrix *mt = newMatrix(m->ncols, m->nrows);
    int i; int j;
    for(j = 0 ; j < mt->nrows ; j++)
    {
        for(i = 0 ; i < mt->ncols ; i++)
        {
            setElt(mt, j+1, i+1, getElt(m, i+1, j+1));
        }
    }
    return mt;
}

variable_types:
m
struct matrix *


commande

decompiled_code:
__int64 __fastcall commande(char *a1, __int64 a2, __int64 a3)
{
char v4; // al
__int64 v6; // r13
struct timeval v7; // [rsp+0h] [rbp-48h] BYREF
struct timeval tv; // [rsp+10h] [rbp-38h] BYREF

printf("%c\n", (unsigned int)*a1);
v4 = *a1;
if ( *a1 == 109 )
{
gettimeofday(&v7, 0LL);
multiplication(a2, a3);
LABEL_6:
gettimeofday(&tv, 0LL);
return (unsigned int)(int)COERCE_DOUBLE(COERCE_UNSIGNED_INT64((double)(LODWORD(tv.tv_usec) - LODWORD(v7.tv_usec))) & LC13);
}
if ( v4 == 115 )
{
gettimeofday(&v7, 0LL);
soustraction(a2, a3);
goto LABEL_6;
}
if ( v4 != 97 )
return 0LL;
gettimeofday(&v7, 0LL);
addition(a2, a3);
gettimeofday(&tv, 0LL);
v6 = (unsigned int)(int)COERCE_DOUBLE(COERCE_UNSIGNED_INT64((double)(LODWORD(tv.tv_usec) - LODWORD(v7.tv_usec))) & LC13);
printf("temps : %d\n", v6);
return (unsigned int)v6;
}

canonical_decompiled_code:
__int64 __fastcall func2(char *a1, __int64 a2, __int64 a3)
{
char v4; // al
__int64 v6; // r13
struct timeval v7; // [rsp+0h] [rbp-48h] BYREF
struct timeval tv; // [rsp+10h] [rbp-38h] BYREF

printf("%c\n", (unsigned int)*a1);
v4 = *a1;
if ( *a1 == 109 )
{
gettimeofday(&v7, 0LL);
multiplication(a2, a3);
LABEL_6:
gettimeofday(&tv, 0LL);
return (unsigned int)(int)COERCE_DOUBLE(COERCE_UNSIGNED_INT64((double)(LODWORD(tv.tv_usec) - LODWORD(v7.tv_usec))) & LC13);
}
if ( v4 == 115 )
{
gettimeofday(&v7, 0LL);
soustraction(a2, a3);
goto LABEL_6;
}
if ( v4 != 97 )
return 0LL;
gettimeofday(&v7, 0LL);
addition(a2, a3);
gettimeofday(&tv, 0LL);
v6 = (unsigned int)(int)COERCE_DOUBLE(COERCE_UNSIGNED_INT64((double)(LODWORD(tv.tv_usec) - LODWORD(v7.tv_usec))) & LC13);
printf("temps : %d\n", v6);
return (unsigned int)v6;
}

original_code:
int commande(char* cmd,Matrix a, Matrix b)
{
 struct timeval start, end;
 int temps=0;
 Matrix m;
 printf("%c\n",cmd[0]);
 switch(cmd[0])
 {
  case 'a':
      gettimeofday(&start, ((void *)0));
      m=addition(a,b);
      gettimeofday(&end, ((void *)0));
      temps =fabs(end.tv_usec - start.tv_usec);
      printf("temps : %d\n",temps);
      break;
  case 'm':
      gettimeofday(&start, ((void *)0));
      m=multiplication(a,b);
      gettimeofday(&end, ((void *)0));
      temps =fabs(end.tv_usec - start.tv_usec);
      break;
  case 's':
      gettimeofday(&start, ((void *)0));
      m=soustraction(a,b);
      gettimeofday(&end, ((void *)0));
      temps =fabs(end.tv_usec - start.tv_usec);
      break;
  default:
     break;
 }
 return temps;
}

canonical_original_code:
int commande(char *cmd, struct matrix *a, struct matrix *b)
{
 struct timeval start; struct timeval end;
 int temps = 0;
 struct matrix *m;
 printf("%c\n",cmd[0]);
 switch(cmd[0])
 {
  case 'a':
      gettimeofday(&start, ((void *)0));
      m=addition(a,b);
      gettimeofday(&end, ((void *)0));
      temps =fabs(end.tv_usec - start.tv_usec);
      printf("temps : %d\n",temps);
      break;
  case 'm':
      gettimeofday(&start, ((void *)0));
      m=multiplication(a,b);
      gettimeofday(&end, ((void *)0));
      temps =fabs(end.tv_usec - start.tv_usec);
      break;
  case 's':
      gettimeofday(&start, ((void *)0));
      m=soustraction(a,b);
      gettimeofday(&end, ((void *)0));
      temps =fabs(end.tv_usec - start.tv_usec);
      break;
  default:
     break;
 }
 return temps;
}

variable_types:
cmd
char *

variable_types:
b
struct matrix *

variable_types: struct timeval { long tv_sec; long tv_usec; }

variable_types: temps int


speedTest

decompiled_code:
int __fastcall speedTest(char *a1, signed int a2, signed int a3, int a4, int a5)
{
unsigned int v6; // ebx
__int64 v9; // rbp
__int64 v10; // r12
unsigned int v11; // edi
signed int v12; // esi

if ( a2 > a3 )
{
v9 = 0LL;
v10 = 0LL;
}
else
{
v6 = a2;
v9 = 0LL;
v10 = 0LL;
do
{
v10 = aleatoire(v10, v6, v6, 0LL, 50LL);
v9 = aleatoire(v9, v6, v6, 0LL, 50LL);
v12 = commande(a1, v10, v9);
if ( v12 / 1000 > a5 )
{
printf(aLeTempsDeCalcu, (unsigned int)a5);
exit(0);
}
v11 = v6;
v6 += a4;
ecritureFichier(v11, v12, "speedTest.data");
}
while ( a3 >= (int)v6 );
}
deleteMatrix(v10);
deleteMatrix(v9);
return fichierCmde("speedTest.data");
}

canonical_decompiled_code:
int __fastcall func3(char *a1, signed int a2, signed int a3, int a4, int a5)
{
unsigned int v6; // ebx
__int64 v9; // rbp
__int64 v10; // r12
unsigned int v11; // edi
signed int v12; // esi

if ( a2 > a3 )
{
v9 = 0LL;
v10 = 0LL;
}
else
{
v6 = a2;
v9 = 0LL;
v10 = 0LL;
do
{
v10 = aleatoire(v10, v6, v6, 0LL, 50LL);
v9 = aleatoire(v9, v6, v6, 0LL, 50LL);
v12 = func2(a1, v10, v9);
if ( v12 / 1000 > a5 )
{
printf(aLeTempsDeCalcu, (unsigned int)a5);
exit(0);
}
v11 = v6;
v6 += a4;
func0(v11, v12, "speedTest.data");
}
while ( a3 >= (int)v6 );
}
deleteMatrix(v10);
deleteMatrix(v9);
return func1("speedTest.data");
}

original_code:
void speedTest(char* cmd,int tailleMin,int tailleMax,int pas, int nbSec) {
 int i;
 int temps=0;
 Matrix a=((void *)0),b=((void *)0);
 for(i=tailleMin;i<=tailleMax;i+=pas)
 {
  a=aleatoire(a,i,i,0,50);
  b=aleatoire(b,i,i,0,50);
  temps=commande(cmd,a,b);
  if(temps/1000>nbSec)
  {
   printf("le temps de calcul est supérieur à %ds\n",nbSec);
   exit(0);
  }
  else
  {
   ecritureFichier(i,temps,"speedTest.data");
  }
 }
 deleteMatrix(a);
 deleteMatrix(b);
 fichierCmde("speedTest.data");
}

canonical_original_code:
void speedTest(char *cmd, int tailleMin, int tailleMax, int pas, int nbSec) {
 int i;
 int temps = 0;
 struct matrix *a = ((void *)0); struct matrix *b = ((void *)0);
 for(i=tailleMin;i<=tailleMax;i+=pas)
 {
  a=aleatoire(a,i,i,0,50);
  b=aleatoire(b,i,i,0,50);
  temps=commande(cmd,a,b);
  if(temps/1000>nbSec)
  {
   printf("le temps de calcul est supérieur à %ds\n",nbSec);
   exit(0);
  }
  else
  {
   ecritureFichier(i,temps,"speedTest.data");
  }
 }
 deleteMatrix(a);
 deleteMatrix(b);
 fichierCmde("speedTest.data");
}

variable_types: tailleMin int

variable_types: tailleMax int

variable_types: pas int

variable_types: nbSec int


getElt

decompiled_code:
float __fastcall getElt(__int64 a1, int a2, int a3)
{
return *(float *)(*(_QWORD *)a1 + 4LL * (*(_DWORD *)(a1 + 12) * (a2 - 1) + a3 - 1));
}

canonical_decompiled_code:
float __fastcall func0(__int64 a1, int a2, int a3)
{
return *(float *)(*(_QWORD *)a1 + 4LL * (*(_DWORD *)(a1 + 12) * (a2 - 1) + a3 - 1));
}

original_code:
float getElt(Matrix m, int row, int column)
{
 return m->mat[(row-1)*m->ncols + (column-1)];
}

canonical_original_code:
float getElt(struct matrix *m, int row, int column)
{
 return m->mat[(row-1)*m->ncols + (column-1)];
}

variable_types: row int

variable_types: column int


setElt

decompiled_code:
__int64 __fastcall setElt(__int64 a1, int a2, int a3, float a4)
{
__int64 result; // rax

result = *(_DWORD *)(a1 + 12) * (a2 - 1) + a3 - 1;
*(float *)(*(_QWORD *)a1 + 4LL * (int)result) = a4;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, int a2, int a3, float a4)
{
__int64 result; // rax

result = *(_DWORD *)(a1 + 12) * (a2 - 1) + a3 - 1;
*(float *)(*(_QWORD *)a1 + 4LL * (int)result) = a4;
return result;
}

original_code:
void setElt(Matrix m, int row, int column, float val)
{
 m->mat[(row-1)*m->ncols + (column-1)] = val;
}

canonical_original_code:
void setElt(struct matrix *m, int row, int column, float val)
{
 m->mat[(row-1)*m->ncols + (column-1)] = val;
}

variable_types: val float


deleteMatrix

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

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

original_code:
void deleteMatrix(Matrix m)
{
 free(m->mat);
 free(m);
}

canonical_original_code:
void deleteMatrix(struct matrix *m)
{
 free(m->mat);
 free(m);
}

variable_types: struct matrix { float *mat; int nrows; } *


displayMatrix

decompiled_code:
int __fastcall displayMatrix(__int64 a1, __int64 a2)
{
int v2; // ebp
__int64 v3; // rbx
int v4; // er12
__int64 v5; // rax

v2 = *(_DWORD *)(a1 + 12) * *(_DWORD *)(a1 + 8);
if ( v2 > 0 )
{
v3 = 0LL;
v4 = 0;
do
{
while ( 1 )
{
printf("%d ", (unsigned int)(int)*(float *)(*(_QWORD *)a1 + 4 * v3));
if ( !(((int)v3 + 1) % *(_DWORD *)(a1 + 12)) )
break;
if ( ++v3 == v2 )
return putchar(10);
}
v5 = v4;
++v3;
++v4;
printf(asc_27E, (unsigned int)(int)*(float *)(a2 + 4 * v5));
}
while ( v3 != v2 );
}
return putchar(10);
}

original_code:
void displayMatrix(Matrix m, float *B)
{
 int i, l = (m->nrows)*(m->ncols), j = 0;
 int displaym, displayB;
 for(i = 0; i < l; i++)
 {
  displaym = (int)m->mat[i];
  printf("%d ", displaym);
  if((i+1)%(m->ncols) == 0) {
   displayB = (int)B[j];
   printf("| %d\n", displayB);
   j++;
  }
 }
 printf("\n");
}

canonical_original_code:
void displayMatrix(struct matrix *m, float *B)
{
 int i; int l = (m->nrows)*(m->ncols); int j = 0;
 int displaym; int displayB;
 for(i = 0; i < l; i++)
 {
  displaym = (int)m->mat[i];
  printf("%d ", displaym);
  if((i+1)%(m->ncols) == 0) {
   displayB = (int)B[j];
   printf("| %d\n", displayB);
   j++;
  }
 }
 printf("\n");
}

variable_types:
B
float *

variable_types: i int

variable_types: l int

variable_types: displaym int

variable_types: displayB int


Sommet

decompiled_code:
int __fastcall Sommet(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6, int a7, int a8, int a9, int a10)
{
int result; // eax

if ( a10 )
result = *(&a7 + a10 - 1);
else
result = printf("ici pd");
return result;
}

canonical_decompiled_code:
int __fastcall func0(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6, int a7, int a8, int a9, int a10)
{
int result; // eax

if ( a10 )
result = *(&a7 + a10 - 1);
else
result = printf("ici pd");
return result;
}

original_code:
Bool Sommet(Pile pPile)
{
 if(pPile.tete !=0)
 {
  return pPile.v[pPile.tete-1];
 }
 else
 {
  printf("ici pd");
  return;
 }
}

canonical_original_code:
int Sommet(struct Pile pPile)
{
 if(pPile.tete !=0)
 {
  return pPile.v[pPile.tete-1];
 }
 else
 {
  printf("ici pd");
  return;
 }
}

variable_types:
pPile
struct Pile { int v[6]; int tete; }


Hauteur

decompiled_code:
__int64 __fastcall Hauteur(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6, int a7, int a8, int a9, unsigned int a10)
{
return a10;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6, int a7, int a8, int a9, unsigned int a10)
{
return a10;
}

original_code:
Nat Hauteur (Pile pPile)
{
 return pPile.tete;
}

canonical_original_code:
int Hauteur(struct Pile pPile)
{
 return pPile.tete;
}


vide

decompiled_code:
_BOOL8 __fastcall vide(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6, int a7, int a8, int a9, int a10)
{
return a10 == 0;
}

canonical_decompiled_code:
_BOOL8 __fastcall func2(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6, int a7, int a8, int a9, int a10)
{
return a10 == 0;
}

original_code:
Bool vide (Pile pPile)
{
 return pPile.tete==0;
}

canonical_original_code:
int vide(struct Pile pPile)
{
 return pPile.tete==0;
}


ieme

decompiled_code:
int __fastcall ieme(unsigned int a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6, int a7)
{
int result; // eax

if ( a1 > 5 )
result = puts(" \n IEME >>>>> Indice faux boulz <<<<< ");
else
result = *(&a7 + (int)a1);
return result;
}

canonical_decompiled_code:
int __fastcall func3(unsigned int a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6, int a7)
{
int result; // eax

if ( a1 > 5 )
result = puts(" \n IEME >>>>> Indice faux boulz <<<<< ");
else
result = *(&a7 + (int)a1);
return result;
}

original_code:
Bool ieme(Pile p,int i)
{
 if((i<6)&&(i>=0))
 {
  return p.v[i];
 }
 else
 {
  printf(" \n IEME >>>>> Indice faux boulz <<<<< \n");
 }
}

canonical_original_code:
int ieme(struct Pile p, int i)
{
 if((i<6)&&(i>=0))
 {
  return p.v[i];
 }
 else
 {
  printf(" \n IEME >>>>> Indice faux boulz <<<<< \n");
 }
}

variable_types:
p
struct Pile { int v[6]; int tete; }


decompiled_code:
__int64 __fastcall Max1(_DWORD *a1)
{
_DWORD *v1; // rcx
__int64 result; // rax

v1 = a1 + 7;
result = 0LL;
do
{
if ( (int)result < *a1 )
result = (unsigned int)*a1;
++a1;
}
while ( a1 != v1 );
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(_DWORD *a1)
{
_DWORD *v1; // rcx
__int64 result; // rax

v1 = a1 + 7;
result = 0LL;
do
{
if ( (int)result < *a1 )
result = (unsigned int)*a1;
++a1;
}
while ( a1 != v1 );
return result;
}

original_code:
int Max1(int* p)
{
 int iCpt=0,i=0;
 for(iCpt=0;iCpt<7;iCpt++)
 {
  if(p[iCpt]>i)
  {
   i=p[iCpt];
  }
 }
 return i;
}

canonical_original_code:
int Max1(int *p)
{
 int iCpt = 0; int i = 0;
 for(iCpt=0;iCpt<7;iCpt++)
 {
  if(p[iCpt]>i)
  {
   i=p[iCpt];
  }
 }
 return i;
}

variable_types:
p
int *

variable_types: iCpt int


original_code:
int Max2(int* p)
{
 int iCpt=0,i=0,v=1;
 for(iCpt=0;iCpt<7;iCpt++)
 {
  if(p[iCpt]>i)
  {
   i=p[iCpt];
   v=iCpt+1;
  }
 }
 return v;
}

canonical_original_code:
int Max2(int *p)
{
 int iCpt = 0; int i = 0; int v = 1;
 for(iCpt=0;iCpt<7;iCpt++)
 {
  if(p[iCpt]>i)
  {
   i=p[iCpt];
   v=iCpt+1;
  }
 }
 return v;
}

variable_types: v int


randIA

decompiled_code:
__int64 randIA()
{
return (unsigned int)(rand() % 6 + 1);
}

canonical_decompiled_code:
__int64 func0()
{
return (unsigned int)(rand() % 6 + 1);
}

original_code:
int randIA(){
    return rand()%(7-1) +1;
}

canonical_original_code:
int randIA(){
    return rand()%(7-1) +1;
}


recuperCol

decompiled_code:
__int64 recuperCol()
{
__int64 result; // rax
unsigned int v1[3]; // [rsp+Ch] [rbp-Ch] BYREF

while ( 1 )
{
_isoc99_scanf("%d", v1);
result = v1[0];
if ( v1[0] - 1 <= 6 )
break;
puts("\nVeuillez entrer un nombre entre 1 et 7");
}
return result;
}

canonical_decompiled_code:
__int64 func1()
{
__int64 result; // rax
unsigned int v1[3]; // [rsp+Ch] [rbp-Ch] BYREF

while ( 1 )
{
_isoc99_scanf("%d", v1);
result = v1[0];
if ( v1[0] - 1 <= 6 )
break;
puts("\nVeuillez entrer un nombre entre 1 et 7");
}
return result;
}

original_code:
int recuperCol()
{
 int iCol=0,iOK=0;
 int c;
 while(iOK==0)
 {
  scanf("%d",&c);
  switch(c)
  {
   case 1: iCol=1;
      iOK=1;
      break;
   case 2: iCol=2;
      iOK=1;
      break;
   case 3: iCol=3;
      iOK=1;
      break;
   case 4: iCol=4;
      iOK=1;
      break;
   case 5: iCol=5;
      iOK=1;
      break;
   case 6: iCol=6;
      iOK=1;
      break;
   case 7: iCol=7;
      iOK=1;
      break;
   default : printf("\nVeuillez entrer un nombre entre 1 et 7\n");
  }
 }
 return iCol;
}

canonical_original_code:
int recuperCol()
{
 int iCol = 0; int iOK = 0;
 int c;
 while(iOK==0)
 {
  scanf("%d",&c);
  switch(c)
  {
   case 1: iCol=1;
      iOK=1;
      break;
   case 2: iCol=2;
      iOK=1;
      break;
   case 3: iCol=3;
      iOK=1;
      break;
   case 4: iCol=4;
      iOK=1;
      break;
   case 5: iCol=5;
      iOK=1;
      break;
   case 6: iCol=6;
      iOK=1;
      break;
   case 7: iCol=7;
      iOK=1;
      break;
   default : printf("\nVeuillez entrer un nombre entre 1 et 7\n");
  }
 }
 return iCol;
}

variable_types: iCol int

variable_types: iOK int

variable_types: c int


printUsage

repo: RoaldFre/ManyParticlesMC

decompiled_code:
int printUsage()
{
puts("Usage: main <num particles> <packing density> [flags]");
putchar(10);
puts("Flags:");
puts(" -2 2D instead of 3D");
puts(" -d <flt> Delta to use in Monte Carlo algorithm");
printf(" default: %f\n", *(double *)&qword_3E8);
puts(" -I <num> sample Interval");
puts(" default: don't sample");
puts(" -P <num> measurement Period");
puts(" default: sample indefinitely");
puts(" -D <path> Data file for the measurement");
printf(" default: %s\n", "data");
puts(" -B <num> number of Bins for the pair correlation");
printf(" default: %d\n", (unsigned int)pairCorrelationBins);
puts(" -b <num> number of Boxes per dimension");
puts(" -r Render");
puts(" -f <flt> desired Framerate when rendering.");
printf(" default: %f)\n", *(double *)&LC17);
return putchar(10);
}

canonical_decompiled_code:
int func0()
{
puts("Usage: main <num particles> <packing density> [flags]");
putchar(10);
puts("Flags:");
puts(" -2 2D instead of 3D");
puts(" -d <flt> Delta to use in Monte Carlo algorithm");
printf(" default: %f\n", *(double *)&qword_3E8);
puts(" -I <num> sample Interval");
puts(" default: don't sample");
puts(" -P <num> measurement Period");
puts(" default: sample indefinitely");
puts(" -D <path> Data file for the measurement");
printf(" default: %s\n", "data");
puts(" -B <num> number of Bins for the pair correlation");
printf(" default: %d\n", (unsigned int)pairCorrelationBins);
puts(" -b <num> number of Boxes per dimension");
puts(" -r Render");
puts(" -f <flt> desired Framerate when rendering.");
printf(" default: %f)\n", *(double *)&LC17);
return putchar(10);
}

original_code:
static void printUsage(void)
{
 printf("Usage: main <num particles> <packing density> [flags]\n");
 printf("\n");
 printf("Flags:\n");
 printf(" -2        2D instead of 3D\n");
 printf(" -d <flt>  Delta to use in Monte Carlo algorithm\n");
 printf("             default: %f\n", monteCarloConfig.delta);
 printf(" -I <num>  sample Interval\n");
 printf("             default: don't sample\n");
 printf(" -P <num>  measurement Period\n");
 printf("             default: sample indefinitely\n");
 printf(" -D <path> Data file for the measurement\n");
 printf("             default: %s\n", "data");
 printf(" -B <num>  number of Bins for the pair correlation\n");
 printf("             default: %d\n", pairCorrelationBins);
 printf(" -b <num>  number of Boxes per dimension\n");
 printf(" -r        Render\n");
 printf(" -f <flt>  desired Framerate when rendering.\n");
 printf("             default: %f)\n", 30.0);
 printf("\n");
}

canonical_original_code:
static void printUsage()
{
 printf("Usage: main <num particles> <packing density> [flags]\n");
 printf("\n");
 printf("Flags:\n");
 printf(" -2        2D instead of 3D\n");
 printf(" -d <flt>  Delta to use in Monte Carlo algorithm\n");
 printf("             default: %f\n", monteCarloConfig.delta);
 printf(" -I <num>  sample Interval\n");
 printf("             default: don't sample\n");
 printf(" -P <num>  measurement Period\n");
 printf("             default: sample indefinitely\n");
 printf(" -D <path> Data file for the measurement\n");
 printf("             default: %s\n", "data");
 printf(" -B <num>  number of Bins for the pair correlation\n");
 printf("             default: %d\n", pairCorrelationBins);
 printf(" -b <num>  number of Boxes per dimension\n");
 printf(" -r        Render\n");
 printf(" -f <flt>  desired Framerate when rendering.\n");
 printf("             default: %f)\n", 30.0);
 printf("\n");
}


parseArguments

decompiled_code:
__int64 __fastcall parseArguments(int argc, char **argv)
{
int v2; // eax
char *v3; // r12
char *v4; // r12
char *v5; // r12
char *v6; // r12
int v7; // eax
char *v8; // r12
int v9; // ebx
char **v10; // r13
int *v11; // rax
const char *v12; // rdi
int *v13; // r12
int v14; // eax
const char *v15; // rdi
int v16; // ebp
double v17; // xmm0_8
bool v18; // al
__int64 v20; // [rsp+0h] [rbp-28h]

while ( 1 )
{
v2 = getopt(argc, argv, ":2d:I:P:D:rf:B:b:");
if ( v2 == -1 )
break;
switch ( v2 )
{
case '2':
twoDimensional = 1;
break;
case ':':
printUsage();
die("Option -%c requires an argument\n", (unsigned int)optopt);
break;
case '?':
printUsage();
die("Option -%c not recognized\n", (unsigned int)optopt);
break;
case 'B':
v8 = optarg;
pairCorrelationBins = atoi(optarg);
if ( pairCorrelationBins <= 0 )
die("Invalid number of pair correlation bins %s\n", v8);
break;
case 'D':
off_3B8 = optarg;
break;
case 'I':
v6 = optarg;
v7 = atoi(optarg);
*((_QWORD *)&measConf + 1) = v7;
if ( v7 <= 0 )
die("Invalid measurement interval %s\n", v6);
break;
case 'P':
v5 = optarg;
*(_QWORD *)&measConf = atoi(optarg);
if ( (__int64)measConf < 0 )
die("Invalid measurement time %s\n", v5);
break;
case 'b':
numBoxes = atoi(optarg);
break;
case 'd':
v4 = optarg;
qword_3E8 = atof(optarg);
if ( *(double *)&qword_3E8 <= 0.0 )
die("Invalid Monte Carlo delta %s\n", v4);
break;
case 'f':
v3 = optarg;
renderConf = (int)atof(optarg);
if ( renderConf < 0 )
die("Invalid framerate %s\n", v3);
break;
case 'h':
printUsage();
exit(0);
case 'r':
render = 1;
break;
default:
die("Error parsing options!");
break;
}
}
v9 = argc - optind;
v10 = &argv[optind];
if ( argc - optind <= 1 )
{
printUsage();
die("\nNot enough required arguments!\n");
}
v11 = _errno_location();
v12 = *v10;
*v11 = 0;
v13 = v11;
v14 = strtol(v12, 0LL, 10);
v15 = v10[1];
v16 = v14;
numParticles = v14;
v17 = strtod(v15, 0LL);
v18 = *v13 != 0;
packingDensity = *(_QWORD *)&v17;
if ( v16 < 0 || v18 || v17 < 0.0 )
{
printUsage();
die("\nError parsing the required options, or they don't make sense!\n");
}
if ( v9 <= 2 )
return v20;
printUsage();
return die("\nFound unrecognised garbage at the command line!\n");
}

canonical_decompiled_code:
__int64 __fastcall func1(int argc, char **argv)
{
int v2; // eax
char *v3; // r12
char *v4; // r12
char *v5; // r12
char *v6; // r12
int v7; // eax
char *v8; // r12
int v9; // ebx
char **v10; // r13
int *v11; // rax
const char *v12; // rdi
int *v13; // r12
int v14; // eax
const char *v15; // rdi
int v16; // ebp
double v17; // xmm0_8
bool v18; // al
__int64 v20; // [rsp+0h] [rbp-28h]

while ( 1 )
{
v2 = getopt(argc, argv, ":2d:I:P:D:rf:B:b:");
if ( v2 == -1 )
break;
switch ( v2 )
{
case '2':
twoDimensional = 1;
break;
case ':':
func0();
die("Option -%c requires an argument\n", (unsigned int)optopt);
break;
case '?':
func0();
die("Option -%c not recognized\n", (unsigned int)optopt);
break;
case 'B':
v8 = optarg;
pairCorrelationBins = atoi(optarg);
if ( pairCorrelationBins <= 0 )
die("Invalid number of pair correlation bins %s\n", v8);
break;
case 'D':
off_3B8 = optarg;
break;
case 'I':
v6 = optarg;
v7 = atoi(optarg);
*((_QWORD *)&measConf + 1) = v7;
if ( v7 <= 0 )
die("Invalid measurement interval %s\n", v6);
break;
case 'P':
v5 = optarg;
*(_QWORD *)&measConf = atoi(optarg);
if ( (__int64)measConf < 0 )
die("Invalid measurement time %s\n", v5);
break;
case 'b':
numBoxes = atoi(optarg);
break;
case 'd':
v4 = optarg;
qword_3E8 = atof(optarg);
if ( *(double *)&qword_3E8 <= 0.0 )
die("Invalid Monte Carlo delta %s\n", v4);
break;
case 'f':
v3 = optarg;
renderConf = (int)atof(optarg);
if ( renderConf < 0 )
die("Invalid framerate %s\n", v3);
break;
case 'h':
func0();
exit(0);
case 'r':
render = 1;
break;
default:
die("Error parsing options!");
break;
}
}
v9 = argc - optind;
v10 = &argv[optind];
if ( argc - optind <= 1 )
{
func0();
die("\nNot enough required arguments!\n");
}
v11 = _errno_location();
v12 = *v10;
*v11 = 0;
v13 = v11;
v14 = strtol(v12, 0LL, 10);
v15 = v10[1];
v16 = v14;
numParticles = v14;
v17 = strtod(v15, 0LL);
v18 = *v13 != 0;
packingDensity = *(_QWORD *)&v17;
if ( v16 < 0 || v18 || v17 < 0.0 )
{
func0();
die("\nError parsing the required options, or they don't make sense!\n");
}
if ( v9 <= 2 )
return v20;
func0();
return die("\nFound unrecognised garbage at the command line!\n");
}

original_code:
static void parseArguments(int argc, char **argv)
{
 int c;
 while ((c = getopt(argc, argv, ":2d:I:P:D:rf:B:b:")) != -1)
 {
  switch (c)
  {
  case '2':
   twoDimensional = 1;
   break;
  case 'd':
   monteCarloConfig.delta = atof(optarg);
   if (monteCarloConfig.delta <= 0)
    die("Invalid Monte Carlo delta %s\n", optarg);
   break;
  case 'I':
   measConf.measureInterval = atoi(optarg);
   if (measConf.measureInterval <= 0)
    die("Invalid measurement interval %s\n", optarg);
   break;
  case 'P':
   measConf.measureTime = atoi(optarg);
   if (measConf.measureTime < 0)
    die("Invalid measurement time %s\n", optarg);
   break;
  case 'D':
   measConf.measureFile = optarg;
   break;
  case 'f':
   renderConf.framerate = atof(optarg);
   if (renderConf.framerate < 0)
    die("Invalid framerate %s\n", optarg);
   break;
  case 'r':
   render = 1;
   break;
  case 'B':
   pairCorrelationBins = atoi(optarg);
   if (pairCorrelationBins <= 0)
    die("Invalid number of pair correlation bins %s\n", optarg);
   break;
  case 'b':
   numBoxes = atoi(optarg);
   break;
  case 'h':
   printUsage();
   exit(0);
   break;
  case ':':
   printUsage();
   die("Option -%c requires an argument\n", optopt);
   break;
  case '?':
   printUsage();
   die("Option -%c not recognized\n", optopt);
   break;
  default:
   die("Error parsing options!");
   break;
  }
 }
 argc -= optind;
 argv += optind;
 if (argc < 2) {
  printUsage();
  die("\nNot enough required arguments!\n");
 }
 (*__errno_location ()) = 0;
 numParticles = strtol(argv[0], ((void *)0), 10);
 packingDensity = strtod(argv[1], ((void *)0));
 if ((*__errno_location ()) != 0 || numParticles < 0 || packingDensity < 0) {
  printUsage();
  die("\nError parsing the required options, or they don't "
    "make sense!\n");
 }
 if (argc > 2) {
  printUsage();
  die("\nFound unrecognised garbage at the command line!\n");
 }
}

variable_types: argc int

variable_types:
argv
char **


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
double v3; // xmm2_8
double v4; // xmm0_8
char *v5; // rbx
double v6; // xmm1_8
__m128i v7; // xmm7
__m128i v9; // [rsp+10h] [rbp-168h] BYREF
__m128i v10; // [rsp+20h] [rbp-158h] BYREF
__int64 v11; // [rsp+30h] [rbp-148h]
int v12; // [rsp+40h] [rbp-138h] BYREF
double v13; // [rsp+48h] [rbp-130h]
double v14; // [rsp+50h] [rbp-128h]
__int64 v15[4]; // [rsp+60h] [rbp-118h] BYREF
char v16[32]; // [rsp+80h] [rbp-F8h] BYREF
char v17[32]; // [rsp+A0h] [rbp-D8h] BYREF
char v18[32]; // [rsp+C0h] [rbp-B8h] BYREF
char v19[32]; // [rsp+E0h] [rbp-98h] BYREF
__int128 v20[3]; // [rsp+100h] [rbp-78h] BYREF
__int64 v21; // [rsp+130h] [rbp-48h]
__m128i v22; // [rsp+138h] [rbp-40h]
__m128i v23; // [rsp+148h] [rbp-30h]
__int64 v24; // [rsp+158h] [rbp-20h]

seedRandom(argc, argv, envp);
parseArguments(argc, (char **)argv);
if ( twoDimensional )
v3 = sqrt((double)numParticles * 0.7853981633974483 / *(double *)&packingDensity);
else
v3 = cbrt((double)numParticles * 0.5235987755982988 / *(double *)&packingDensity);
if ( numBoxes > 0 )
{
v4 = v3 / (double)numBoxes;
*(double *)&monteCarloConfig = v4;
if ( v4 < 1.0 )
die("Resulting boxsize %f less than particle dameter %f!\n", v4, *(double *)&LC34);
}
v5 = v16;
allocWorld((unsigned int)numParticles, (unsigned __int8)twoDimensional, v3);
makeRenderTask(v16, &renderConf);
makeMonteCarloTask(v17, &monteCarloConfig);
v6 = v3 * v3;
v12 = pairCorrelationBins;
v13 = 0.5 * v3;
if ( !twoDimensional )
v6 = v6 * v3;
v20[0] = (__int128)_mm_load_si128((const __m128i *)&measConf);
v20[1] = (__int128)_mm_load_si128((const __m128i *)&unk_3B0);
v20[2] = (__int128)_mm_load_si128((const __m128i *)&xmmword_3C0);
v21 = qword_3D0;
v14 = (double)numParticles / v6;
pairCorrelationSampler(&v9, &v12);
v7 = _mm_loadu_si128(&v10);
v22 = _mm_loadu_si128(&v9);
v23 = v7;
v24 = v11;
measurementTask(v18, v20);
if ( !render )
v5 = 0LL;
v15[1] = (__int64)v17;
v15[2] = (__int64)v18;
v15[0] = (__int64)v5;
sequence(v19, v15, 3LL);
return (unsigned __int8)run(v19) ^ 1;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
double v3; // xmm2_8
double v4; // xmm0_8
char *v5; // rbx
double v6; // xmm1_8
__m128i v7; // xmm7
__m128i v9; // [rsp+10h] [rbp-168h] BYREF
__m128i v10; // [rsp+20h] [rbp-158h] BYREF
__int64 v11; // [rsp+30h] [rbp-148h]
int v12; // [rsp+40h] [rbp-138h] BYREF
double v13; // [rsp+48h] [rbp-130h]
double v14; // [rsp+50h] [rbp-128h]
__int64 v15[4]; // [rsp+60h] [rbp-118h] BYREF
char v16[32]; // [rsp+80h] [rbp-F8h] BYREF
char v17[32]; // [rsp+A0h] [rbp-D8h] BYREF
char v18[32]; // [rsp+C0h] [rbp-B8h] BYREF
char v19[32]; // [rsp+E0h] [rbp-98h] BYREF
__int128 v20[3]; // [rsp+100h] [rbp-78h] BYREF
__int64 v21; // [rsp+130h] [rbp-48h]
__m128i v22; // [rsp+138h] [rbp-40h]
__m128i v23; // [rsp+148h] [rbp-30h]
__int64 v24; // [rsp+158h] [rbp-20h]

seedRandom(argc, argv, envp);
func1(argc, (char **)argv);
if ( twoDimensional )
v3 = sqrt((double)numParticles * 0.7853981633974483 / *(double *)&packingDensity);
else
v3 = cbrt((double)numParticles * 0.5235987755982988 / *(double *)&packingDensity);
if ( numBoxes > 0 )
{
v4 = v3 / (double)numBoxes;
*(double *)&monteCarloConfig = v4;
if ( v4 < 1.0 )
die("Resulting boxsize %f less than particle dameter %f!\n", v4, *(double *)&LC34);
}
v5 = v16;
allocWorld((unsigned int)numParticles, (unsigned __int8)twoDimensional, v3);
makeRenderTask(v16, &renderConf);
makeMonteCarloTask(v17, &monteCarloConfig);
v6 = v3 * v3;
v12 = pairCorrelationBins;
v13 = 0.5 * v3;
if ( !twoDimensional )
v6 = v6 * v3;
v20[0] = (__int128)_mm_load_si128((const __m128i *)&measConf);
v20[1] = (__int128)_mm_load_si128((const __m128i *)&unk_3B0);
v20[2] = (__int128)_mm_load_si128((const __m128i *)&xmmword_3C0);
v21 = qword_3D0;
v14 = (double)numParticles / v6;
pairCorrelationSampler(&v9, &v12);
v7 = _mm_loadu_si128(&v10);
v22 = _mm_loadu_si128(&v9);
v23 = v7;
v24 = v11;
measurementTask(v18, v20);
if ( !render )
v5 = 0LL;
v15[1] = (__int64)v17;
v15[2] = (__int64)v18;
v15[0] = (__int64)v5;
sequence(v19, v15, 3LL);
return (unsigned __int8)run(v19) ^ 1;
}

original_code:
int main(int argc, char **argv)
{
 seedRandom();
 parseArguments(argc, argv);
 double worldSize;
 if (twoDimensional) {
  double area = numParticles * (3.14159265358979323846 * ((0.5) * (0.5))) / packingDensity;
  worldSize = sqrt(area);
 } else {
  double volume = numParticles * (4.0/3.0*3.14159265358979323846 * ((0.5) * (0.5) * (0.5))) / packingDensity;
  worldSize = cbrt(volume);
 }
 if (numBoxes > 0) {
  monteCarloConfig.boxSize = worldSize / numBoxes;
  if (monteCarloConfig.boxSize < 2*0.5)
   die("Resulting boxsize %f less than particle "
     "dameter %f!\n",
     monteCarloConfig.boxSize, 2*0.5);
 }
 allocWorld(numParticles, worldSize, twoDimensional);
 Task renderTask = makeRenderTask(&renderConf);
 Task monteCarloTask = makeMonteCarloTask(&monteCarloConfig);
 PairCorrelationConfig pairCorrelationConf = {
  .numBins = pairCorrelationBins,
  .maxR = worldSize / 2,
  .rho = numParticles / (twoDimensional ? ((worldSize) * (worldSize))
                                        : ((worldSize) * (worldSize) * (worldSize))),
 };
 Measurement measurement;
 measurement.measConf = measConf;
 measurement.sampler = pairCorrelationSampler(&pairCorrelationConf);
 Task measTask = measurementTask(&measurement);
 Task *tasks[3];
 tasks[0] = (render ? &renderTask : ((void *)0));
 tasks[1] = &monteCarloTask;
 tasks[2] = &measTask;
 Task task = sequence(tasks, 3);
 _Bool everythingOK = run(&task);
 if (!everythingOK)
  return 1;
 return 0;
}

canonical_original_code:
int main(int argc, char **argv)
{
 seedRandom();
 parseArguments(argc, argv);
 double worldSize;
 if (twoDimensional) {
  double area = numParticles * (3.14159265358979323846 * ((0.5) * (0.5))) / packingDensity;
  worldSize = sqrt(area);
 } else {
  double volume = numParticles * (4.0/3.0*3.14159265358979323846 * ((0.5) * (0.5) * (0.5))) / packingDensity;
  worldSize = cbrt(volume);
 }
 if (numBoxes > 0) {
  monteCarloConfig.boxSize = worldSize / numBoxes;
  if (monteCarloConfig.boxSize < 2*0.5)
   die("Resulting boxsize %f less than particle "
     "dameter %f!\n",
     monteCarloConfig.boxSize, 2*0.5);
 }
 allocWorld(numParticles, worldSize, twoDimensional);
 struct Task renderTask = makeRenderTask(&renderConf);
 struct Task monteCarloTask = makeMonteCarloTask(&monteCarloConfig);
 struct PairCorrelationConfig pairCorrelationConf = {
  .numBins = pairCorrelationBins,
  .maxR = worldSize / 2,
  .rho = numParticles / (twoDimensional ? ((worldSize) * (worldSize))
                                        : ((worldSize) * (worldSize) * (worldSize))),
 };
 struct Measurement measurement;
 measurement.measConf = measConf;
 measurement.sampler = pairCorrelationSampler(&pairCorrelationConf);
 struct Task measTask = measurementTask(&measurement);
 struct Task *tasks[3];
 tasks[0] = (render ? &renderTask : ((void *)0));
 tasks[1] = &monteCarloTask;
 tasks[2] = &measTask;
 struct Task task = sequence(tasks, 3);
 _Bool everythingOK = run(&task);
 if (!everythingOK)
  return 1;
 return 0;
}

variable_types: worldSize double

variable_types: area double

variable_types: volume double

variable_types: struct PairCorrelationConfig { int numBins; double maxR; double rho; }

variable_types: struct Measurement { struct MeasurementConf { long measureTime; long measureInterval; long measureWait; char *measureFile; _Bool verbose; int renderStrBufSize; int renderStrX; char *measureHeader; } measConf; struct Sampler { void *samplerConf; void *(*start)(struct SamplerData { long sample; char *string; int strBufSize; double sampleInterval; } *sd, void *samplerConf); enum SamplerSignal { SAMPLER_OK=0, SAMPLER_STOP=1, SAMPLER_ERROR=2 } (*sample)(struct SamplerData *sd, void *state); void (*stop)(struct SamplerData *sd, void *state); char *header; } sampler; }

variable_types: struct Task { void *initialData; void *(*start)(void *initialData); enum TaskSignal { TASK_OK=0, TASK_STOP=1, TASK_ERROR=2 } (*tick)(void *state); void (*stop)(void *state); } *[3]

user_defined_types: struct Task { void *initialData; void *(*start)(void *initialData); enum TaskSignal (*tick)(void *state); void (*stop)(void *state); }

user_defined_types: struct Measurement { struct MeasurementConf measConf; struct Sampler sampler; }

user_defined_types: struct Sampler { void *samplerConf; void *(*start)(struct SamplerData *sd, void *samplerConf); enum SamplerSignal (*sample)(struct SamplerData *sd, void *state); void (*stop)(struct SamplerData *sd, void *state); char *header; }


repo: RobertCNelson/imx-bootlets

decompiled_code:
__int64 HW_DRAM_CTL10_RD()
{
return MEMORY[0x800E0028];
}

canonical_decompiled_code:
__int64 func0()
{
return MEMORY[0x800E0028];
}

original_code: static inline u32 HW_DRAM_CTL10_RD(void) { return (*(volatile u32*)((0x80000000 + 0x000e0000) + 0x28)); }

canonical_original_code: static inline unsigned int HW_DRAM_CTL10_RD() { return (*(unsigned int *)((0x80000000 + 0x000e0000) + 0x28)); }

return_type: unsigned int


decompiled_code:
__int64 HW_DRAM_CTL11_RD()
{
return MEMORY[0x800E002C];
}

canonical_decompiled_code:
__int64 func1()
{
return MEMORY[0x800E002C];
}

original_code: static inline u32 HW_DRAM_CTL11_RD(void) { return (*(volatile u32*)((0x80000000 + 0x000e0000) + 0x2c)); }

canonical_original_code: static inline unsigned int HW_DRAM_CTL11_RD() { return (*(unsigned int *)((0x80000000 + 0x000e0000) + 0x2c)); }


decompiled_code:
__int64 HW_DRAM_CTL14_RD()
{
return MEMORY[0x800E0038];
}

canonical_decompiled_code:
__int64 func2()
{
return MEMORY[0x800E0038];
}

original_code: static inline u32 HW_DRAM_CTL14_RD(void) { return (*(volatile u32*)((0x80000000 + 0x000e0000) + 0x38)); }

canonical_original_code: static inline unsigned int HW_DRAM_CTL14_RD() { return (*(unsigned int *)((0x80000000 + 0x000e0000) + 0x38)); }


decompiled_code:
char *find_command_lines()
{
char *result; // rax
__int64 v1; // rcx
char *i; // rdi
__int64 v3; // rsi
bool v4; // di

result = (char *)&cmdlines_start;
if ( &cmdlines_start >= &cmdlines_end )
{
LODWORD(v3) = 0;
LABEL_12:
v3 = (int)v3;
do
cmdlines[v3++] = (__int64)&cmdline_def;
while ( (int)v3 <= 3 );
return result;
}
v1 = 1LL;
for ( i = (char *)&cmdlines_start; ; i = result )
{
LODWORD(v3) = v1 - 1;
result = i;
do
++result;
while ( *(result - 1) && result < (char *)&cmdlines_end );
if ( result == (char *)&cmdlines_end )
break;
*(_QWORD *)(8 * v1 + 0x538) = i;
LODWORD(v3) = v1;
v4 = (int)v1++ <= 3;
if ( result >= (char *)&cmdlines_end || !v4 )
goto LABEL_11;
}
if ( !*((_BYTE *)&cmdlines_end - 1) )
{
cmdlines[(int)v3] = (__int64)i;
LODWORD(v3) = v1;
}
LABEL_11:
if ( (_DWORD)v3 != 4 )
goto LABEL_12;
return result;
}

canonical_decompiled_code:
char *func4()
{
char *result; // rax
__int64 v1; // rcx
char *i; // rdi
__int64 v3; // rsi
bool v4; // di

result = (char *)&cmdlines_start;
if ( &cmdlines_start >= &cmdlines_end )
{
LODWORD(v3) = 0;
LABEL_12:
v3 = (int)v3;
do
cmdlines[v3++] = (__int64)&cmdline_def;
while ( (int)v3 <= 3 );
return result;
}
v1 = 1LL;
for ( i = (char *)&cmdlines_start; ; i = result )
{
LODWORD(v3) = v1 - 1;
result = i;
do
++result;
while ( *(result - 1) && result < (char *)&cmdlines_end );
if ( result == (char *)&cmdlines_end )
break;
*(_QWORD *)(8 * v1 + 0x538) = i;
LODWORD(v3) = v1;
v4 = (int)v1++ <= 3;
if ( result >= (char *)&cmdlines_end || !v4 )
goto LABEL_11;
}
if ( !*((_BYTE *)&cmdlines_end - 1) )
{
cmdlines[(int)v3] = (__int64)i;
LODWORD(v3) = v1;
}
LABEL_11:
if ( (_DWORD)v3 != 4 )
goto LABEL_12;
return result;
}

original_code:
static void find_command_lines (void)
{
 char *start = &cmdlines_start[0];
 char *end = &cmdlines_end[0];
 char *head, *cur;
 int l;
 head = cur = start;
 for (l = 0; l < MAGIC_KEY_NR && cur < end; l++) {
  while (cur < end && *cur++ != '\0') ;
  if (cur == end && *(cur-1) != '\0')
   break;
  cmdlines[l] = head;
  head = cur;
 }
 while (l < MAGIC_KEY_NR)
  cmdlines[l++] = cmdline_def;
}

canonical_original_code:
static void find_command_lines()
{
 char *start = &cmdlines_start[0];
 char *end = &cmdlines_end[0];
 char *head; char *cur;
 int l;
 head = cur = start;
 for (l = 0; l < MAGIC_KEY_NR && cur < end; l++) {
  while (cur < end && *cur++ != '\0') ;
  if (cur == end && *(cur-1) != '\0')
   break;
  cmdlines[l] = head;
  head = cur;
 }
 while (l < MAGIC_KEY_NR)
  cmdlines[l++] = cmdline_def;
}

variable_types:
start
char *

variable_types:
end
char *

variable_types:
head
char *

variable_types:
cur
char *

variable_types: l int


decompiled_code:
__int64 __fastcall get_sdram_size(__int64 a1, __int64 a2)
{
unsigned int v2; // eax
__int64 v3; // rdi
__int64 result; // rax
char v5; // cl
int v6; // esi

v2 = HW_DRAM_CTL10_RD();
v3 = 12 - (((unsigned int)HW_DRAM_CTL11_RD(12LL, a2, 12LL, 13 - (HIWORD(v2) & 7)) >> 8) & 7);
result = HW_DRAM_CTL14_RD(v3) & 0xF;
if ( (_DWORD)result )
{
v6 = 0;
do
{
++v6;
LODWORD(result) = (result - 1) & result;
}
while ( (_DWORD)result );
result = (unsigned int)(2 * ((4 * v6) << v5 << v3));
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1, __int64 a2)
{
unsigned int v2; // eax
__int64 v3; // rdi
__int64 result; // rax
char v5; // cl
int v6; // esi

v2 = func0();
v3 = 12 - (((unsigned int)func1(12LL, a2, 12LL, 13 - (HIWORD(v2) & 7)) >> 8) & 7);
result = func2(v3) & 0xF;
if ( (_DWORD)result )
{
v6 = 0;
do
{
++v6;
LODWORD(result) = (result - 1) & result;
}
while ( (_DWORD)result );
result = (unsigned int)(2 * ((4 * v6) << v5 << v3));
}
return result;
}

original_code:
static u32 get_sdram_size (void)
{
 u32 row, column, csmap, size;
 u32 cs = 0;
 row = 13 -
       ((HW_DRAM_CTL10_RD() & 0x00070000) >> 16);
 column = 12 -
   ((HW_DRAM_CTL11_RD() & 0x00000700) >> 8);
 csmap = HW_DRAM_CTL14_RD() & 0x0000000f;
 while (csmap) {
  csmap &= (csmap - 1);
  cs++;
 }
 size = cs * 4 * (1 << row) * (1 << column) * 2;
 return size;
}

canonical_original_code:
static unsigned int get_sdram_size()
{
 unsigned int row; unsigned int column; unsigned int csmap; unsigned int size;
 unsigned int cs = 0;
 row = 13 -
       ((HW_DRAM_CTL10_RD() & 0x00070000) >> 16);
 column = 12 -
   ((HW_DRAM_CTL11_RD() & 0x00000700) >> 8);
 csmap = HW_DRAM_CTL14_RD() & 0x0000000f;
 while (csmap) {
  csmap &= (csmap - 1);
  cs++;
 }
 size = cs * 4 * (1 << row) * (1 << column) * 2;
 return size;
}

variable_types:
row
unsigned int

variable_types:
column
unsigned int

variable_types:
csmap
unsigned int

variable_types:
size
unsigned int

variable_types:
cs
unsigned int


original_code:
static void setup_start_tag (void)
{
 params = (struct tag*)(0x40000000 + 0x100);
 params->hdr.tag = 0x54410001;
 params->hdr.size = ((sizeof(struct tag_header) + sizeof(struct tag_core)) >> 2);
 params->u.core.flags = 0;
 params->u.core.pagesize = 0;
 params->u.core.rootdev = 0;
 params = ((struct tag *)((u32 *)(params) + (params)->hdr.size));
}

canonical_original_code:
static void setup_start_tag()
{
 params = (struct tag *)(0x40000000 + 0x100);
 params->hdr.tag = 0x54410001;
 params->hdr.size = ((sizeof(struct tag_header) + sizeof(struct tag_core)) >> 2);
 params->u.core.flags = 0;
 params->u.core.pagesize = 0;
 params->u.core.rootdev = 0;
 params = ((struct tag *)((unsigned int *)(params) + (params)->hdr.size));
}

user_defined_types: struct tag_header { unsigned int size; unsigned int tag; }

user_defined_types: struct tag_core { unsigned int flags; unsigned int pagesize; unsigned int rootdev; }

user_defined_types: struct tag { struct tag_header hdr; union { struct tag_core core; struct tag_mem32 mem; struct tag_videotext videotext; struct tag_ramdisk ramdisk; struct tag_initrd initrd; struct tag_serialnr serialnr; struct tag_revision revision; struct tag_videolfb videolfb; struct tag_cmdline cmdline; struct tag_acorn acorn; struct tag_memclk memclk; } u; }

user_defined_types: struct tag_mem32 { unsigned int size; unsigned int start; }

user_defined_types: struct tag_videotext { unsigned char x; unsigned char y; unsigned short video_page; unsigned char video_mode; unsigned char video_cols; unsigned short video_ega_bx; unsigned char video_lines; unsigned char video_isvga; unsigned short video_points; }

user_defined_types: struct tag_ramdisk { unsigned int flags; unsigned int size; unsigned int start; }

user_defined_types: struct tag_initrd { unsigned int start; unsigned int size; }

user_defined_types: struct tag_serialnr { unsigned int low; unsigned int high; }

user_defined_types: struct tag_revision { unsigned int rev; }

user_defined_types: struct tag_videolfb { unsigned short lfb_width; unsigned short lfb_height; unsigned short lfb_depth; unsigned short lfb_linelength; unsigned int lfb_base; unsigned int lfb_size; unsigned char red_size; unsigned char red_pos; unsigned char green_size; unsigned char green_pos; unsigned char blue_size; unsigned char blue_pos; unsigned char rsvd_size; unsigned char rsvd_pos; }

user_defined_types: struct tag_acorn { unsigned int memc_control_reg; unsigned int vram_pages; unsigned char sounddefault; unsigned char adfsdrives; }

user_defined_types: struct tag_memclk { unsigned int fmemclk; }


decompiled_code:
__int64 __fastcall setup_mem_tag(__int64 a1, __int64 a2)
{
__int64 v2; // r8
unsigned int v3; // eax
unsigned int *v4; // r8
__int64 result; // rax

v2 = params;
*(_QWORD *)params = 0x5441000200000004LL;
*(_DWORD *)(v2 + 12) = 0x40000000;
v3 = get_sdram_size(a1, a2);
v4[2] = v3;
result = (__int64)&v4[*v4];
params = result;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1, __int64 a2)
{
__int64 v2; // r8
unsigned int v3; // eax
unsigned int *v4; // r8
__int64 result; // rax

v2 = params;
*(_QWORD *)params = 0x5441000200000004LL;
*(_DWORD *)(v2 + 12) = 0x40000000;
v3 = func5(a1, a2);
v4[2] = v3;
result = (__int64)&v4[*v4];
params = result;
return result;
}

original_code:
static void setup_mem_tag (void)
{
 params->hdr.tag = 0x54410002;
 params->hdr.size = ((sizeof(struct tag_header) + sizeof(struct tag_mem32)) >> 2);
 params->u.mem.start = 0x40000000;
 params->u.mem.size = get_sdram_size();
 params = ((struct tag *)((u32 *)(params) + (params)->hdr.size));
}

canonical_original_code:
static void setup_mem_tag()
{
 params->hdr.tag = 0x54410002;
 params->hdr.size = ((sizeof(struct tag_header) + sizeof(struct tag_mem32)) >> 2);
 params->u.mem.start = 0x40000000;
 params->u.mem.size = get_sdram_size();
 params = ((struct tag *)((unsigned int *)(params) + (params)->hdr.size));
}


decompiled_code:
__int64 setup_initrd_tag()
{
__int64 v0; // rax
__int64 result; // rax

v0 = params;
*(_QWORD *)params = 0x5442000500000004LL;
result = v0 + 16;
*(_QWORD *)(result - 8) = 0x40000040400000LL;
params = result;
return result;
}

canonical_decompiled_code:
__int64 func8()
{
__int64 v0; // rax
__int64 result; // rax

v0 = params;
*(_QWORD *)params = 0x5442000500000004LL;
result = v0 + 16;
*(_QWORD *)(result - 8) = 0x40000040400000LL;
params = result;
return result;
}

original_code:
static void setup_initrd_tag(void)
{
 params->hdr.tag = 0x54420005 ;
 params->hdr.size = ((sizeof(struct tag_header) + sizeof(struct tag_initrd)) >> 2);
 params->u.initrd.start = 0x40400000;
 params->u.initrd.size = 0x00400000;
 params = ((struct tag *)((u32 *)(params) + (params)->hdr.size));
}

canonical_original_code:
static void setup_initrd_tag()
{
 params->hdr.tag = 0x54420005 ;
 params->hdr.size = ((sizeof(struct tag_header) + sizeof(struct tag_initrd)) >> 2);
 params->u.initrd.start = 0x40400000;
 params->u.initrd.size = 0x00400000;
 params = ((struct tag *)((unsigned int *)(params) + (params)->hdr.size));
}


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

result = params;
*(_QWORD *)params = 0LL;
return result;
}

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

result = params;
*(_QWORD *)params = 0LL;
return result;
}

original_code:
static void setup_end_tag (void)
{
 params->hdr.tag = 0x00000000;
 params->hdr.size = 0;
}

canonical_original_code:
static void setup_end_tag()
{
 params->hdr.tag = 0x00000000;
 params->hdr.size = 0;
}


decompiled_code:
__int64 get_magic_key()
{
int v0; // eax

v0 = get_pressed_keys();
if ( v0 == magic_keys[1] )
return 1LL;
if ( v0 == magic_keys[2] )
return 2LL;
return 3 * (unsigned int)(v0 == magic_keys[3]);
}

canonical_decompiled_code:
__int64 func10()
{
int v0; // eax

v0 = get_pressed_keys();
if ( v0 == magic_keys[1] )
return 1LL;
if ( v0 == magic_keys[2] )
return 2LL;
return 3 * (unsigned int)(v0 == magic_keys[3]);
}

original_code:
static enum magic_key get_magic_key (void)
{
 u32 keys;
 int magic;
 keys = get_pressed_keys();
 for (magic = MAGIC_KEY1; magic < MAGIC_KEY_NR; magic++)
  if (magic_keys[magic] == keys)
   return magic;
 return NO_MAGIC_KEY;
}

canonical_original_code:
static enum magic_key get_magic_key()
{
 unsigned int keys;
 int magic;
 keys = get_pressed_keys();
 for (magic = MAGIC_KEY1; magic < MAGIC_KEY_NR; magic++)
  if (magic_keys[magic] == keys)
   return magic;
 return NO_MAGIC_KEY;
}

variable_types:
keys
unsigned int

variable_types: magic int

return_type: enum magic_key { NO_MAGIC_KEY=0, MAGIC_KEY1=1, MAGIC_KEY2=2, MAGIC_KEY3=3, MAGIC_KEY_NR=4 }


original_code:
static void setup_cmdline_tag (char *cmdline)
{
 u32 len;
 const char *mtdprefix[] = { "root=/dev/mtdblock", "root=ubi0:rootfs"};
 char *o, *m, *s, *rest;
 int nr, i, j, p, digits;
 unsigned int val;
 for (p = 0; p < sizeof(mtdprefix)/sizeof(mtdprefix[0]); p++) {
  m = strstr(cmdline, mtdprefix[p]);
  if (m)
   break;
 }
 if (!m)
  goto normal_copy;
 ((*(volatile reg32_t *) ((0x80000000 + 0x0005C000) + 0x00000008)) = (0x80000000 | 0x40000000));
 while (((*(volatile hw_rtc_stat_t *) ((0x80000000 + 0x0005C000) + 0x00000010)).U) & (((0x1 << 1) << 16) & 0x00FF0000))
  ;
 val = ((*(volatile hw_rtc_persistent1_t *) ((0x80000000 + 0x0005C000) + 0x00000070)).U);
 if ((val & 0x00000002) == 0)
  goto normal_copy;
 o = params->u.cmdline.cmdline;
 m += strlen(mtdprefix[p]);
 memcpy(o, cmdline, m - cmdline);
 o += m - cmdline;
 s = m;
 while (*s && *s >= '0' && *s <= '9')
  s++;
 rest = s;
 s--;
 nr = 0;
 while (s >= m) {
  nr = nr * 10 + (*s - '0');
  s--;
 }
 nr++;
 digits = 0;
 i = nr;
 while (i > 0) {
  digits++;
  i /= 10;
 }
 i = nr;
 j = digits;
 while (j > 0) {
  o[j - 1] = '0' + (i % 10);
  i /= 10;
  j--;
 }
 o += digits;
 strcpy(o, rest);
 goto done_copy;
normal_copy:
 strcpy(params->u.cmdline.cmdline, cmdline);
done_copy:
 len = strlen(params->u.cmdline.cmdline) + 1;
 params->hdr.tag = 0x54410009;
 params->hdr.size = (sizeof(struct tag_header) + len + 4) >> 2;
 params = ((struct tag *)((u32 *)(params) + (params)->hdr.size));
}

canonical_original_code:
static void setup_cmdline_tag(char *cmdline)
{
 unsigned int len;
 char *mtdprefix[] = { "root=/dev/mtdblock", "root=ubi0:rootfs"};
 char *o; char *m; char *s; char *rest;
 int nr; int i; int j; int p; int digits;
 unsigned int val;
 for (p = 0; p < sizeof(mtdprefix)/sizeof(mtdprefix[0]); p++) {
  m = strstr(cmdline, mtdprefix[p]);
  if (m)
   break;
 }
 if (!m)
  goto normal_copy;
 ((*(unsigned int *) ((0x80000000 + 0x0005C000) + 0x00000008)) = (0x80000000 | 0x40000000));
 while (((*(union hw_rtc_stat_t *) ((0x80000000 + 0x0005C000) + 0x00000010)).U) & (((0x1 << 1) << 16) & 0x00FF0000))
  ;
 val = ((*(union hw_rtc_persistent1_t *) ((0x80000000 + 0x0005C000) + 0x00000070)).U);
 if ((val & 0x00000002) == 0)
  goto normal_copy;
 o = params->u.cmdline.cmdline;
 m += strlen(mtdprefix[p]);
 memcpy(o, cmdline, m - cmdline);
 o += m - cmdline;
 s = m;
 while (*s && *s >= '0' && *s <= '9')
  s++;
 rest = s;
 s--;
 nr = 0;
 while (s >= m) {
  nr = nr * 10 + (*s - '0');
  s--;
 }
 nr++;
 digits = 0;
 i = nr;
 while (i > 0) {
  digits++;
  i /= 10;
 }
 i = nr;
 j = digits;
 while (j > 0) {
  o[j - 1] = '0' + (i % 10);
  i /= 10;
  j--;
 }
 o += digits;
 strcpy(o, rest);
 goto done_copy;
normal_copy:
 strcpy(params->u.cmdline.cmdline, cmdline);
done_copy:
 len = strlen(params->u.cmdline.cmdline) + 1;
 params->hdr.tag = 0x54410009;
 params->hdr.size = (sizeof(struct tag_header) + len + 4) >> 2;
 params = ((struct tag *)((unsigned int *)(params) + (params)->hdr.size));
}

variable_types:
cmdline
char *

variable_types:
len
unsigned int

variable_types:
mtdprefix
char *[]

variable_types:
o
char *

variable_types:
m
char *

variable_types:
s
char *

variable_types:
rest
char *

variable_types: nr int

variable_types: i int

variable_types: j int

variable_types: p int

variable_types: digits int

variable_types:
val
unsigned int

user_defined_types: union hw_rtc_stat_t { unsigned int U; struct { unsigned char RSVD0; unsigned char NEW_REGS; unsigned char STALE_REGS; unsigned int RSVD1; unsigned int XTAL32768_PRESENT; unsigned int XTAL32000_PRESENT; unsigned int WATCHDOG_PRESENT; unsigned int ALARM_PRESENT; unsigned int RTC_PRESENT; } B; }

user_defined_types: union hw_rtc_persistent1_t { unsigned int U; struct { unsigned int GENERAL; } B; }


decompiled_code:
__int64 __fastcall setup_tags(__int64 a1, __int64 a2)
{
__int64 v2; // r9

get_magic_key();
find_command_lines();
setup_start_tag();
setup_mem_tag(a1, a2);
setup_initrd_tag();
setup_cmdline_tag((_BYTE *)cmdlines[v2]);
setup_end_tag();
return 1073742080LL;
}

original_code:
u32 setup_tags (void)
{
 enum magic_key magic_key;
 magic_key = get_magic_key();
 find_command_lines();
 setup_start_tag();
 setup_mem_tag();
 setup_initrd_tag();
 setup_cmdline_tag(cmdlines[magic_key]);
 setup_end_tag();
 return (u32)(0x40000000 + 0x100);
}

canonical_original_code:
unsigned int setup_tags()
{
 enum magic_key magic_key;
 magic_key = get_magic_key();
 find_command_lines();
 setup_start_tag();
 setup_mem_tag();
 setup_initrd_tag();
 setup_cmdline_tag(cmdlines[magic_key]);
 setup_end_tag();
 return (u32)(0x40000000 + 0x100);
}

variable_types: enum magic_key { NO_MAGIC_KEY=0, MAGIC_KEY1=1, MAGIC_KEY2=2, MAGIC_KEY3=3, MAGIC_KEY_NR=4 }


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

result = a1;
MEMORY[0x80050004] = a1;
return result;
}

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

result = a1;
MEMORY[0x80050004] = a1;
return result;
}

canonical_original_code: static inline void HW_LRADC_CTRL0_SET(unsigned int v) { ((*(unsigned int *)((0x80000000 + 0x00050000) + 0x00000000 + 0x04)) = (v)); }

variable_types:
v
unsigned int


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

result = a1;
MEMORY[0x80050008] = a1;
return result;
}

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

result = a1;
MEMORY[0x80050008] = a1;
return result;
}

canonical_original_code: static inline void HW_LRADC_CTRL0_CLR(unsigned int v) { ((*(unsigned int *)((0x80000000 + 0x00050000) + 0x00000000 + 0x08)) = (v)); }


decompiled_code:
__int64 HW_LRADC_CTRL1_RD()
{
return MEMORY[0x80050010];
}

canonical_original_code: static inline unsigned int HW_LRADC_CTRL1_RD() { return (*(unsigned int *)((0x80000000 + 0x00050000) + 0x00000010)); }


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

result = a1;
MEMORY[0x80050018] = a1;
return result;
}

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

result = a1;
MEMORY[0x80050018] = a1;
return result;
}

canonical_original_code: static inline void HW_LRADC_CTRL1_CLR(unsigned int v) { ((*(unsigned int *)((0x80000000 + 0x00050000) + 0x00000010 + 0x08)) = (v)); }


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

result = a1;
MEMORY[0x80050024] = a1;
return result;
}

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

result = a1;
MEMORY[0x80050024] = a1;
return result;
}

canonical_original_code: static inline void HW_LRADC_CTRL2_SET(unsigned int v) { ((*(unsigned int *)((0x80000000 + 0x00050000) + 0x00000020 + 0x04)) = (v)); }


decompiled_code:
__int64 __fastcall HW_LRADC_CHn_RD(int a1)
{
return *(unsigned int *)(unsigned int)(16 * a1 - 2147155888);
}

canonical_decompiled_code:
__int64 __fastcall func5(int a1)
{
return *(unsigned int *)(unsigned int)(16 * a1 - 2147155888);
}

canonical_original_code: static inline unsigned int HW_LRADC_CHn_RD(int n) { return (*(unsigned int *)((0x80000000 + 0x00050000) + 0x00000050 + n * 0x10)); }

variable_types: n int


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

result = a1;
MEMORY[0x80050144] = a1;
return result;
}

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

result = a1;
MEMORY[0x80050144] = a1;
return result;
}

canonical_original_code: static inline void HW_LRADC_CTRL4_SET(unsigned int v) { ((*(unsigned int *)((0x80000000 + 0x00050000) + 0x00000140 + 0x04)) = (v)); }


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

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

original_code:
static u32 get_no_keys (void)
{
 return 0;
}

canonical_original_code:
static unsigned int get_no_keys()
{
 return 0;
}


decompiled_code:
__int64 get_pressed_keys()
{
int v0; // ebx

v0 = (*((__int64 (**)(void))keys_drivers + 1))();
return v0 | (*((unsigned int (**)(void))off_48 + 1))();
}

original_code:
u32 get_pressed_keys(void)
{
 int drv;
 u32 keys = 0;
 for (drv = KEYS_DRV_LRADC; drv < KEYS_DRV_NR; drv++)
  keys |= keys_drivers[drv]->get_keys();
 return keys;
}

canonical_original_code:
unsigned int get_pressed_keys()
{
 int drv;
 unsigned int keys = 0;
 for (drv = KEYS_DRV_LRADC; drv < KEYS_DRV_NR; drv++)
  keys |= keys_drivers[drv]->get_keys();
 return keys;
}

variable_types: drv int

variable_types:
keys
unsigned int


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

result = *a1;
*(&keys_drivers + result) = a1;
return result;
}

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

result = *a1;
*(&keys_drivers + result) = a1;
return result;
}

original_code:
void set_keys_driver (struct keys_driver *driver)
{
 keys_drivers[driver->id] = driver;
}

canonical_original_code:
void set_keys_driver(struct keys_driver *driver)
{
 keys_drivers[driver->id] = driver;
}

variable_types: struct keys_driver { enum keys_driver_id { KEYS_DRV_LRADC=0, KEYS_DRV_GPIO=1, KEYS_DRV_NR=2, KEYS_DRV_DEFAULT=3 } id; unsigned int (*get_keys)(); } *

user_defined_types: struct keys_driver { enum keys_driver_id id; unsigned int (*get_keys)(); }


repo: RobertGBryan/TinyMTCPP

original_code:
void tinymt32_init(tinymt32_t * random, uint32_t seed) {
    random->status[0] = seed;
    random->status[1] = random->mat1;
    random->status[2] = random->mat2;
    random->status[3] = random->tmat;
    for (int i = 1; i < 8; i++) {
 random->status[i & 3] ^= i + 1812433253U
     * (random->status[(i - 1) & 3]
        ^ (random->status[(i - 1) & 3] >> 30));
    }
    period_certification(random);
    for (int i = 0; i < 8; i++) {
 tinymt32_next_state(random);
    }
}

canonical_original_code:
void tinymt32_init(struct TINYMT32_T *random, unsigned int seed) {
    random->status[0] = seed;
    random->status[1] = random->mat1;
    random->status[2] = random->mat2;
    random->status[3] = random->tmat;
    for (int i = 1; i < 8; i++) {
 random->status[i & 3] ^= i + 1812433253U
     * (random->status[(i - 1) & 3]
        ^ (random->status[(i - 1) & 3] >> 30));
    }
    period_certification(random);
    for (int i = 0; i < 8; i++) {
 tinymt32_next_state(random);
    }
}

variable_types: struct TINYMT32_T { unsigned int status[4]; unsigned int mat1; unsigned int mat2; unsigned int tmat; } *

variable_types:
seed
unsigned int


original_code:
void tinymt32_init_by_array(tinymt32_t * random, uint32_t init_key[],
       int key_length) {
    const int lag = 1;
    const int mid = 1;
    const int size = 4;
    int i, j;
    int count;
    uint32_t r;
    uint32_t * st = &random->status[0];
    st[0] = 0;
    st[1] = random->mat1;
    st[2] = random->mat2;
    st[3] = random->tmat;
    if (key_length + 1 > 8) {
 count = key_length + 1;
    } else {
 count = 8;
    }
    r = ini_func1(st[0] ^ st[mid % size]
    ^ st[(size - 1) % size]);
    st[mid % size] += r;
    r += key_length;
    st[(mid + lag) % size] += r;
    st[0] = r;
    count--;
    for (i = 1, j = 0; (j < count) && (j < key_length); j++) {
 r = ini_func1(st[i] ^ st[(i + mid) % size] ^ st[(i + size - 1) % size]);
 st[(i + mid) % size] += r;
 r += init_key[j] + i;
 st[(i + mid + lag) % size] += r;
 st[i] = r;
 i = (i + 1) % size;
    }
    for (; j < count; j++) {
 r = ini_func1(st[i] ^ st[(i + mid) % size] ^ st[(i + size - 1) % size]);
 st[(i + mid) % size] += r;
 r += i;
 st[(i + mid + lag) % size] += r;
 st[i] = r;
 i = (i + 1) % size;
    }
    for (j = 0; j < size; j++) {
 r = ini_func2(st[i] + st[(i + mid) % size] + st[(i + size - 1) % size]);
 st[(i + mid) % size] ^= r;
 r -= i;
 st[(i + mid + lag) % size] ^= r;
 st[i] = r;
 i = (i + 1) % size;
    }
    period_certification(random);
    for (i = 0; i < 8; i++) {
 tinymt32_next_state(random);
    }
}

canonical_original_code:
void tinymt32_init_by_array(struct TINYMT32_T *random, unsigned int init_key[], int key_length) {
    int lag = 1;
    int mid = 1;
    int size = 4;
    int i; int j;
    int count;
    unsigned int r;
    unsigned int *st = &random->status[0];
    st[0] = 0;
    st[1] = random->mat1;
    st[2] = random->mat2;
    st[3] = random->tmat;
    if (key_length + 1 > 8) {
 count = key_length + 1;
    } else {
 count = 8;
    }
    r = ini_func1(st[0] ^ st[mid % size]
    ^ st[(size - 1) % size]);
    st[mid % size] += r;
    r += key_length;
    st[(mid + lag) % size] += r;
    st[0] = r;
    count--;
    for (i = 1, j = 0; (j < count) && (j < key_length); j++) {
 r = ini_func1(st[i] ^ st[(i + mid) % size] ^ st[(i + size - 1) % size]);
 st[(i + mid) % size] += r;
 r += init_key[j] + i;
 st[(i + mid + lag) % size] += r;
 st[i] = r;
 i = (i + 1) % size;
    }
    for (; j < count; j++) {
 r = ini_func1(st[i] ^ st[(i + mid) % size] ^ st[(i + size - 1) % size]);
 st[(i + mid) % size] += r;
 r += i;
 st[(i + mid + lag) % size] += r;
 st[i] = r;
 i = (i + 1) % size;
    }
    for (j = 0; j < size; j++) {
 r = ini_func2(st[i] + st[(i + mid) % size] + st[(i + size - 1) % size]);
 st[(i + mid) % size] ^= r;
 r -= i;
 st[(i + mid + lag) % size] ^= r;
 st[i] = r;
 i = (i + 1) % size;
    }
    period_certification(random);
    for (i = 0; i < 8; i++) {
 tinymt32_next_state(random);
    }
}

variable_types: lag int

variable_types: mid int

variable_types: size int

variable_types: count int

variable_types:
r
unsigned int

variable_types:
st
unsigned int *

user_defined_types: struct TINYMT32_T { unsigned int status[4]; unsigned int mat1; unsigned int mat2; unsigned int tmat; }


decompiled_code:
__int64 __fastcall ini_func1(unsigned int a1)
{
return 1664525 * (a1 ^ (a1 >> 27));
}

canonical_decompiled_code:
__int64 __fastcall func1(unsigned int a1)
{
return 1664525 * (a1 ^ (a1 >> 27));
}

original_code:
static uint32_t ini_func1(uint32_t x) {
    return (x ^ (x >> 27)) * (uint32_t)1664525UL;
}

canonical_original_code:
static unsigned int ini_func1(unsigned int x) {
    return (x ^ (x >> 27)) * (unsigned int)1664525UL;
}

variable_types:
x
unsigned int


decompiled_code:
__int64 __fastcall ini_func2(unsigned int a1)
{
return 1566083941 * (a1 ^ (a1 >> 27));
}

canonical_decompiled_code:
__int64 __fastcall func2(unsigned int a1)
{
return 1566083941 * (a1 ^ (a1 >> 27));
}

original_code:
static uint32_t ini_func2(uint32_t x) {
    return (x ^ (x >> 27)) * (uint32_t)1566083941UL;
}

canonical_original_code:
static unsigned int ini_func2(unsigned int x) {
    return (x ^ (x >> 27)) * (unsigned int)1566083941UL;
}


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

if ( (*(_DWORD *)a1 & 0x7FFFFFFF) == 0 && !*(_DWORD *)(a1 + 4) && !*(_DWORD *)(a1 + 8) )
{
result = *(unsigned int *)(a1 + 12);
if ( !(_DWORD)result )
{
*(_QWORD *)a1 = 0x4900000054LL;
result = 0x590000004ELL;
*(_QWORD *)(a1 + 8) = 0x590000004ELL;
}
}
return result;
}

original_code:
static void period_certification(tinymt32_t * random) {
    if ((random->status[0] & 0x7fffffffU) == 0 &&
 random->status[1] == 0 &&
 random->status[2] == 0 &&
 random->status[3] == 0) {
 random->status[0] = 'T';
 random->status[1] = 'I';
 random->status[2] = 'N';
 random->status[3] = 'Y';
    }
}

canonical_original_code:
static void period_certification(struct TINYMT32_T *random) {
    if ((random->status[0] & 0x7fffffffU) == 0 &&
 random->status[1] == 0 &&
 random->status[2] == 0 &&
 random->status[3] == 0) {
 random->status[0] = 'T';
 random->status[1] = 'I';
 random->status[2] = 'N';
 random->status[3] = 'Y';
    }
}


original_code:
void tinymt64_init(tinymt64_t * random, uint64_t seed) {
    random->status[0] = seed ^ ((uint64_t)random->mat1 << 32);
    random->status[1] = random->mat2 ^ random->tmat;
    for (int i = 1; i < 8; i++) {
 random->status[i & 1] ^= i + 6364136223846793005UL
     * (random->status[(i - 1) & 1]
        ^ (random->status[(i - 1) & 1] >> 62));
    }
    period_certification(random);
}

canonical_original_code:
void tinymt64_init(struct TINYMT64_T *random, unsigned long seed) {
    random->status[0] = seed ^ ((unsigned long)random->mat1 << 32);
    random->status[1] = random->mat2 ^ random->tmat;
    for (int i = 1; i < 8; i++) {
 random->status[i & 1] ^= i + 6364136223846793005UL
     * (random->status[(i - 1) & 1]
        ^ (random->status[(i - 1) & 1] >> 62));
    }
    period_certification(random);
}

variable_types: struct TINYMT64_T { unsigned long status[2]; unsigned int mat1; unsigned int mat2; unsigned long tmat; } *

variable_types:
seed
unsigned long

variable_types: i int