main

original_code:
int main()
{
 int i;
 struct universal_bio_params *bio_params;
 bio_params = malloc(sizeof(*bio_params));
 bio_params->substance_count = 8;
 bio_params->init_concs = malloc(sizeof(*(bio_params->init_concs)) * bio_params->substance_count);
 bio_params->init_concs[0] = 0;
 bio_params->init_concs[1] = 0;
 bio_params->init_concs[2] = 40e-6;
 bio_params->init_concs[3] = 0;
 bio_params->init_concs[4] = 8e-6;
 bio_params->init_concs[5] = 0;
 bio_params->init_concs[6] = 4e-7;
 bio_params->init_concs[7] = 0;
 bio_params->reaction_count = 4;
 bio_params->reactions = malloc(sizeof(*(bio_params->reactions)) * bio_params->reaction_count);
 bio_params->reactions[0].k = 1.25e7;
 bio_params->reactions[0].reactant_count = 2;
 bio_params->reactions[0].reactants = malloc(sizeof(*(bio_params->reactions[0].reactants)) * bio_params->reactions[0].reactant_count);
 bio_params->reactions[0].reactants[0] = 0;
 bio_params->reactions[0].reactants[1] = 2;
 bio_params->reactions[0].react_stoichs = malloc(sizeof(*(bio_params->reactions[0].react_stoichs)) * bio_params->reactions[0].reactant_count);
 bio_params->reactions[0].react_stoichs[0] = 1;
 bio_params->reactions[0].react_stoichs[1] = 1;
 bio_params->reactions[0].react_orders = malloc(sizeof(*(bio_params->reactions[0].react_orders)) * bio_params->reactions[0].reactant_count);
 bio_params->reactions[0].react_orders[0] = 1;
 bio_params->reactions[0].react_orders[1] = 1;
 bio_params->reactions[0].product_count = 2;
 bio_params->reactions[0].products = malloc(sizeof(*(bio_params->reactions[0].products)) * bio_params->reactions[0].product_count);
 bio_params->reactions[0].products[0] = 1;
 bio_params->reactions[0].products[1] = 3;
 bio_params->reactions[0].prod_stoichs = malloc(sizeof(*(bio_params->reactions[0].prod_stoichs)) * bio_params->reactions[0].product_count);
 bio_params->reactions[0].prod_stoichs[0] = 1;
 bio_params->reactions[0].prod_stoichs[1] = 1;
 bio_params->reactions[1].k = 1.2e5;
 bio_params->reactions[1].reactant_count = 2;
 bio_params->reactions[1].reactants = malloc(sizeof(*(bio_params->reactions[1].reactants)) * bio_params->reactions[1].reactant_count);
 bio_params->reactions[1].reactants[0] = 1;
 bio_params->reactions[1].reactants[1] = 4;
 bio_params->reactions[1].react_stoichs = malloc(sizeof(*(bio_params->reactions[1].react_stoichs)) * bio_params->reactions[1].reactant_count);
 bio_params->reactions[1].react_stoichs[0] = 1;
 bio_params->reactions[1].react_stoichs[1] = 1;
 bio_params->reactions[1].react_orders = malloc(sizeof(*(bio_params->reactions[1].react_orders)) * bio_params->reactions[1].reactant_count);
 bio_params->reactions[1].react_orders[0] = 1;
 bio_params->reactions[1].react_orders[1] = 1;
 bio_params->reactions[1].product_count = 2;
 bio_params->reactions[1].products = malloc(sizeof(*(bio_params->reactions[1].products)) * bio_params->reactions[1].product_count);
 bio_params->reactions[1].products[0] = 0;
 bio_params->reactions[1].products[1] = 5;
 bio_params->reactions[1].prod_stoichs = malloc(sizeof(*(bio_params->reactions[1].prod_stoichs)) * bio_params->reactions[1].product_count);
 bio_params->reactions[1].prod_stoichs[0] = 1;
 bio_params->reactions[1].prod_stoichs[1] = 1;
 bio_params->reactions[2].k = 1.4e9;
 bio_params->reactions[2].reactant_count = 2;
 bio_params->reactions[2].reactants = malloc(sizeof(*(bio_params->reactions[2].reactants)) * bio_params->reactions[2].reactant_count);
 bio_params->reactions[2].reactants[0] = 1;
 bio_params->reactions[2].reactants[1] = 6;
 bio_params->reactions[2].react_stoichs = malloc(sizeof(*(bio_params->reactions[2].react_stoichs)) * bio_params->reactions[2].reactant_count);
 bio_params->reactions[2].react_stoichs[0] = 1;
 bio_params->reactions[2].react_stoichs[1] = 1;
 bio_params->reactions[2].react_orders = malloc(sizeof(*(bio_params->reactions[2].react_orders)) * bio_params->reactions[2].reactant_count);
 bio_params->reactions[2].react_orders[0] = 1;
 bio_params->reactions[2].react_orders[1] = 1;
 bio_params->reactions[2].product_count = 2;
 bio_params->reactions[2].products = malloc(sizeof(*(bio_params->reactions[2].products)) * bio_params->reactions[2].product_count);
 bio_params->reactions[2].products[0] = 0;
 bio_params->reactions[2].products[1] = 7;
 bio_params->reactions[2].prod_stoichs = malloc(sizeof(*(bio_params->reactions[2].prod_stoichs)) * bio_params->reactions[2].product_count);
 bio_params->reactions[2].prod_stoichs[0] = 1;
 bio_params->reactions[2].prod_stoichs[1] = 1;
 bio_params->reactions[3].k = 1.4e9;
 bio_params->reactions[3].reactant_count = 2;
 bio_params->reactions[3].reactants = malloc(sizeof(*(bio_params->reactions[3].reactants)) * bio_params->reactions[3].reactant_count);
 bio_params->reactions[3].reactants[0] = 4;
 bio_params->reactions[3].reactants[1] = 7;
 bio_params->reactions[3].react_stoichs = malloc(sizeof(*(bio_params->reactions[3].react_stoichs)) * bio_params->reactions[3].reactant_count);
 bio_params->reactions[3].react_stoichs[0] = 1;
 bio_params->reactions[3].react_stoichs[1] = 1;
 bio_params->reactions[3].react_orders = malloc(sizeof(*(bio_params->reactions[3].react_orders)) * bio_params->reactions[3].reactant_count);
 bio_params->reactions[3].react_orders[0] = 1;
 bio_params->reactions[3].react_orders[1] = 1;
 bio_params->reactions[3].product_count = 2;
 bio_params->reactions[3].products = malloc(sizeof(*(bio_params->reactions[3].products)) * bio_params->reactions[3].product_count);
 bio_params->reactions[3].products[0] = 5;
 bio_params->reactions[3].products[1] = 6;
 bio_params->reactions[3].prod_stoichs = malloc(sizeof(*(bio_params->reactions[3].prod_stoichs)) * bio_params->reactions[3].product_count);
 bio_params->reactions[3].prod_stoichs[0] = 1;
 bio_params->reactions[3].prod_stoichs[1] = 1;
 bio_params->electrochem_count = 2;
 bio_params->electrochems = malloc(sizeof(*(bio_params->electrochems)) * bio_params->electrochem_count);
 bio_params->electrochems[0].ne = 1;
 bio_params->electrochems[0].reactant_count = 1;
 bio_params->electrochems[0].reactants = malloc(sizeof(*(bio_params->electrochems[0].reactants)) * bio_params->electrochems[0].reactant_count);
 bio_params->electrochems[0].reactants[0] = 5;
 bio_params->electrochems[0].react_stoichs = malloc(sizeof(*(bio_params->electrochems[0].react_stoichs)) * bio_params->electrochems[0].reactant_count);
 bio_params->electrochems[0].react_stoichs[0] = 1;
 bio_params->electrochems[0].product_count = 1;
 bio_params->electrochems[0].products = malloc(sizeof(*(bio_params->electrochems[0].products)) * bio_params->electrochems[0].product_count);
 bio_params->electrochems[0].products[0] = 4;
 bio_params->electrochems[0].prod_stoichs = malloc(sizeof(*(bio_params->electrochems[0].prod_stoichs)) * bio_params->electrochems[0].product_count);
 bio_params->electrochems[0].prod_stoichs[0] = 1;
 bio_params->electrochems[1].ne = 1;
 bio_params->electrochems[1].reactant_count = 1;
 bio_params->electrochems[1].reactants = malloc(sizeof(*(bio_params->electrochems[1].reactants)) * bio_params->electrochems[1].reactant_count);
 bio_params->electrochems[1].reactants[0] = 7;
 bio_params->electrochems[1].react_stoichs = malloc(sizeof(*(bio_params->electrochems[1].react_stoichs)) * bio_params->electrochems[1].reactant_count);
 bio_params->electrochems[1].react_stoichs[0] = 1;
 bio_params->electrochems[1].product_count = 1;
 bio_params->electrochems[1].products = malloc(sizeof(*(bio_params->electrochems[1].products)) * bio_params->electrochems[1].product_count);
 bio_params->electrochems[1].products[0] = 6;
 bio_params->electrochems[1].prod_stoichs = malloc(sizeof(*(bio_params->electrochems[1].prod_stoichs)) * bio_params->electrochems[1].product_count);
 bio_params->electrochems[1].prod_stoichs[0] = 1;
 bio_params->layer_count = 3;
 bio_params->layers = malloc(sizeof(*(bio_params->layers)) * bio_params->layer_count);
 bio_params->layers[0].d = 23.3e-4;
 bio_params->layers[0].reaction_count = 4;
 bio_params->layers[0].reactions = malloc(sizeof(*(bio_params->layers[0].reactions)) * bio_params->layers[0].reaction_count);
 bio_params->layers[0].reactions[0] = 0;
 bio_params->layers[0].reactions[1] = 1;
 bio_params->layers[0].reactions[2] = 2;
 bio_params->layers[0].reactions[3] = 3;
 bio_params->layers[0].diff_coefs = malloc(sizeof(*(bio_params->layers[0].diff_coefs)) * bio_params->substance_count);
 bio_params->layers[0].diff_coefs[0] = 0;
 bio_params->layers[0].diff_coefs[1] = 0;
 bio_params->layers[0].diff_coefs[2] = 3.15e-6;
 bio_params->layers[0].diff_coefs[3] = 3.15e-6;
 bio_params->layers[0].diff_coefs[4] = 3.15e-6;
 bio_params->layers[0].diff_coefs[5] = 3.15e-6;
 bio_params->layers[0].diff_coefs[6] = 3.15e-6;
 bio_params->layers[0].diff_coefs[7] = 3.15e-6;
 bio_params->layers[0].init_concs = malloc(sizeof(*(bio_params->layers[0].init_concs)) * bio_params->substance_count);
 bio_params->layers[0].init_concs[0] = 4e-8;
 bio_params->layers[0].init_concs[1] = 0;
 bio_params->layers[0].init_concs[2] = 0;
 bio_params->layers[0].init_concs[3] = 0;
 bio_params->layers[0].init_concs[4] = 0;
 bio_params->layers[0].init_concs[5] = 0;
 bio_params->layers[0].init_concs[6] = 0;
 bio_params->layers[0].init_concs[7] = 0;
 bio_params->layers[1].d = 18.6e-4;
 bio_params->layers[1].reaction_count = 1;
 bio_params->layers[1].reactions = malloc(sizeof(*(bio_params->layers[1].reactions)) * bio_params->layers[1].reaction_count);
 bio_params->layers[1].reactions[0] = 3;
 bio_params->layers[1].diff_coefs = malloc(sizeof(*(bio_params->layers[1].diff_coefs)) * bio_params->substance_count);
 bio_params->layers[1].diff_coefs[0] = 0;
 bio_params->layers[1].diff_coefs[1] = 0;
 bio_params->layers[1].diff_coefs[2] = 4.2e-7;
 bio_params->layers[1].diff_coefs[3] = 4.2e-7;
 bio_params->layers[1].diff_coefs[4] = 4.2e-7;
 bio_params->layers[1].diff_coefs[5] = 4.2e-7;
 bio_params->layers[1].diff_coefs[6] = 4.2e-7;
 bio_params->layers[1].diff_coefs[7] = 4.2e-7;
 bio_params->layers[1].init_concs = malloc(sizeof(*(bio_params->layers[1].init_concs)) * bio_params->substance_count);
 bio_params->layers[1].init_concs[0] = 0;
 bio_params->layers[1].init_concs[1] = 0;
 bio_params->layers[1].init_concs[2] = 0;
 bio_params->layers[1].init_concs[3] = 0;
 bio_params->layers[1].init_concs[4] = 0;
 bio_params->layers[1].init_concs[5] = 0;
 bio_params->layers[1].init_concs[6] = 0;
 bio_params->layers[1].init_concs[7] = 0;
 bio_params->layers[2].d = 116.5e-4;
 bio_params->layers[2].reaction_count = 1;
 bio_params->layers[2].reactions = malloc(sizeof(*(bio_params->layers[2].reactions)) * bio_params->layers[2].reaction_count);
 bio_params->layers[2].reactions[0] = 3;
 bio_params->layers[2].diff_coefs = malloc(sizeof(*(bio_params->layers[2].diff_coefs)) * bio_params->substance_count);
 bio_params->layers[2].diff_coefs[0] = 0;
 bio_params->layers[2].diff_coefs[1] = 0;
 bio_params->layers[2].diff_coefs[2] = 6.3e-6;
 bio_params->layers[2].diff_coefs[3] = 6.3e-6;
 bio_params->layers[2].diff_coefs[4] = 6.3e-6;
 bio_params->layers[2].diff_coefs[5] = 6.3e-6;
 bio_params->layers[2].diff_coefs[6] = 6.3e-6;
 bio_params->layers[2].diff_coefs[7] = 6.3e-6;
 bio_params->layers[2].init_concs = malloc(sizeof(*(bio_params->layers[2].init_concs)) * bio_params->substance_count);
 bio_params->layers[2].init_concs[0] = 0;
 bio_params->layers[2].init_concs[1] = 0;
 bio_params->layers[2].init_concs[2] = 0;
 bio_params->layers[2].init_concs[3] = 0;
 bio_params->layers[2].init_concs[4] = 0;
 bio_params->layers[2].init_concs[5] = 0;
 bio_params->layers[2].init_concs[6] = 0;
 bio_params->layers[2].init_concs[7] = 0;
 bio_params->electrode_neutral_count = 1;
 bio_params->electrode_neutrals = malloc(sizeof(*(bio_params->electrode_neutrals)) * bio_params->electrode_neutral_count);
 bio_params->electrode_neutrals[0] = 2;
 bio_params->n = 200;
 double dt0 = pow(bio_params->layers[0].d / bio_params->n, 2) / (2 * bio_params->layers[0].diff_coefs[2]);
 double dt1 = pow(bio_params->layers[1].d / bio_params->n, 2) / (2 * bio_params->layers[1].diff_coefs[2]);
 double dt2 = pow(bio_params->layers[2].d / bio_params->n, 2) / (2 * bio_params->layers[2].diff_coefs[2]);
 bio_params->dt = 0.9 * fmin(dt0, fmin(dt1, dt2));
 bio_params->resp_t_meth = MIN_TIME;
 bio_params->min_t = 100;
 bio_params->resp_t = 0;
 bio_params->out_file_name = "output.dat";
 calculate(bio_params, ((void *)0), &callback_crunched);
 free(bio_params->electrode_neutrals);
 for (i = 0; i < bio_params->layer_count; i++) {
  free(bio_params->layers[i].reactions);
  free(bio_params->layers[i].diff_coefs);
  free(bio_params->layers[i].init_concs);
 }
 free(bio_params->layers);
 for (i = 0; i < bio_params->electrochem_count; i++) {
  free(bio_params->electrochems[i].reactants);
  free(bio_params->electrochems[i].react_stoichs);
  free(bio_params->electrochems[i].products);
  free(bio_params->electrochems[i].prod_stoichs);
 }
 free(bio_params->electrochems);
 for (i = 0; i < bio_params->reaction_count; i++) {
  free(bio_params->reactions[i].reactants);
  free(bio_params->reactions[i].react_stoichs);
  free(bio_params->reactions[i].react_orders);
  free(bio_params->reactions[i].products);
  free(bio_params->reactions[i].prod_stoichs);
 }
 free(bio_params->reactions);
 free(bio_params->init_concs);
 free(bio_params);
 return 0;
}

variable_types: i int

variable_types: struct universal_bio_params { int substance_count; int reaction_count; struct reaction { int reactant_count; int *reactants; int *react_stoichs; double *react_orders; int product_count; int *products; int *prod_stoichs; double k; } *reactions; int electrochem_count; struct electrochem { int ne; int reactant_count; int *reactants; int *react_stoichs; int product_count; int *products; int *prod_stoichs; } *electrochems; int layer_count; struct layer { double *diff_coefs; double *init_concs; int reaction_count; int *reactions; double d; } *layers; int electrode_neutral_count; int *electrode_neutrals; double *init_concs; double dt; int n; enum resp_method { DEFAULT_TIME=0, MIN_TIME=1, FIXED_TIME=2 } resp_t_meth; double min_t; double resp_t; char *out_file_name; } *

user_defined_types: struct universal_bio_params { int substance_count; int reaction_count; struct reaction *reactions; int electrochem_count; struct electrochem *electrochems; int layer_count; struct layer *layers; int electrode_neutral_count; int *electrode_neutrals; double *init_concs; double dt; int n; enum resp_method resp_t_meth; double min_t; double resp_t; char *out_file_name; }


canonical_name: main

repo: dakk/mandelbrot-fractal

original_code:
int main(int argc, char **argv)
{
 int x,y;
 request_t req;
 req.dx = 640;
 req.dy = 480;
 req.cl_start = -1431749881;
 req.cl_end = 0x00FFFF00;
 req.levels = 90;
 req.reg_x0 = -2;
 req.reg_x1 = 2;
 req.reg_y0 = -2;
 req.reg_y1 = 2;
 req.data = (int *) malloc(sizeof(int) * req.dx * req.dy);
 zoom(0.1, &req);
 for(x = 0; x < req.dx; x++)
  for(y = 0; y < req.dy; y++)
   req.data[y * req.dx + x] = 0;
 sdlrender(req);
 return 0;
}

canonical_original_code:
int main(int argc, char **argv)
{
 int x; int y;
 struct request_t req;
 req.dx = 640;
 req.dy = 480;
 req.cl_start = -1431749881;
 req.cl_end = 0x00FFFF00;
 req.levels = 90;
 req.reg_x0 = -2;
 req.reg_x1 = 2;
 req.reg_y0 = -2;
 req.reg_y1 = 2;
 req.data = (int *) malloc(sizeof(int) * req.dx * req.dy);
 zoom(0.1, &req);
 for(x = 0; x < req.dx; x++)
  for(y = 0; y < req.dy; y++)
   req.data[y * req.dx + x] = 0;
 sdlrender(req);
 return 0;
}

variable_types: argc int

variable_types:
argv
char **

variable_types: x int

variable_types: y int

variable_types: struct request_t { int algorithm; int *data; int dx; int dy; unsigned int cl_start; int cl_end; int levels; double reg_x0; double reg_x1; double reg_y0; double reg_y1; }

return_type: int


decompiled_code:
double __fastcall render_big(const char *a1, unsigned int a2, unsigned int a3, double a4)
{
double v4; // r12
double v5; // rbx
unsigned int v6; // ebp
unsigned int v7; // er13
double result; // xmm0_8
double v9; // [rsp+8h] [rbp-4B0h]
double v10; // [rsp+10h] [rbp-4A8h]
double v13; // [rsp+28h] [rbp-490h]
char s[1080]; // [rsp+80h] [rbp-438h] BYREF

v13 = a4 - 2.0;
v10 = a4 - 2.0;
v4 = a4 - 2.0;
v9 = *(double *)&LC0;
v5 = *(double *)&LC0;
v6 = 0;
v7 = 0;
do
{
sprintf(s, "%s_%d_%d.bmp", a1, v7, v6);
fract2bmp(s, a2, a3);
printf("writed %s\n", s);
v5 = v5 + a4;
if ( v5 >= 2.0 )
{
++v7;
v9 = v9 + a4;
v10 = v10 + a4;
v4 = v13;
v5 = *(double *)&LC0;
v6 = 0;
}
else
{
v4 = v4 + a4;
++v6;
}
result = *(double *)&LC1;
}
while ( v9 < 2.0 );
return result;
}

canonical_decompiled_code:
double __fastcall func0(const char *a1, unsigned int a2, unsigned int a3, double a4)
{
double v4; // r12
double v5; // rbx
unsigned int v6; // ebp
unsigned int v7; // er13
double result; // xmm0_8
double v9; // [rsp+8h] [rbp-4B0h]
double v10; // [rsp+10h] [rbp-4A8h]
double v13; // [rsp+28h] [rbp-490h]
char s[1080]; // [rsp+80h] [rbp-438h] BYREF

v13 = a4 - 2.0;
v10 = a4 - 2.0;
v4 = a4 - 2.0;
v9 = *(double *)&LC0;
v5 = *(double *)&LC0;
v6 = 0;
v7 = 0;
do
{
sprintf(s, "%s_%d_%d.bmp", a1, v7, v6);
fract2bmp(s, a2, a3);
printf("writed %s\n", s);
v5 = v5 + a4;
if ( v5 >= 2.0 )
{
++v7;
v9 = v9 + a4;
v10 = v10 + a4;
v4 = v13;
v5 = *(double *)&LC0;
v6 = 0;
}
else
{
v4 = v4 + a4;
++v6;
}
result = *(double *)&LC1;
}
while ( v9 < 2.0 );
return result;
}

original_code:
void render_big(char *name, int x, int y, double step, request_t req)
{
 char nf[1024];
 request_t current = req;
 current.reg_x0 = -2;
 current.reg_y0 = -2;
 current.reg_x1 = -2 + step;
 current.reg_y1 = -2 + step;
 int l = 0;
 int c = 0;
 while(current.reg_y0 < 2)
 {
  sprintf(nf, "%s_%d_%d.bmp", name, l, c);
  fract2bmp(nf, current, x, y);
  printf("writed %s\n", nf);
  current.reg_x0 += step;
  current.reg_x1 += step;
  c++;
  if(current.reg_x0 >= 2)
  {
   l++; c = 0;
   current.reg_x0 = -2;
   current.reg_x1 = -2 + step;
   current.reg_y0 += step;
   current.reg_y1 += step;
  }
 }
}

canonical_original_code:
void render_big(char *name, int x, int y, double step, struct request_t req)
{
 char nf[1024];
 struct request_t current = req;
 current.reg_x0 = -2;
 current.reg_y0 = -2;
 current.reg_x1 = -2 + step;
 current.reg_y1 = -2 + step;
 int l = 0;
 int c = 0;
 while(current.reg_y0 < 2)
 {
  sprintf(nf, "%s_%d_%d.bmp", name, l, c);
  fract2bmp(nf, current, x, y);
  printf("writed %s\n", nf);
  current.reg_x0 += step;
  current.reg_x1 += step;
  c++;
  if(current.reg_x0 >= 2)
  {
   l++; c = 0;
   current.reg_x0 = -2;
   current.reg_x1 = -2 + step;
   current.reg_y0 += step;
   current.reg_y1 += step;
  }
 }
}

variable_types:
name
char *

variable_types: step double

variable_types:
nf
char [1024]

variable_types: l int

variable_types: c int

return_type: void

user_defined_types: struct request_t { int algorithm; int *data; int dx; int dy; unsigned int cl_start; int cl_end; int levels; double reg_x0; double reg_x1; double reg_y0; double reg_y1; }


clear

decompiled_code:
__int64 __fastcall clear(__int64 a1)
{
int i; // esi
__int64 result; // rax
int j; // edx

for ( i = 0; *(_DWORD *)(a1 + 16) > i; ++i )
{
for ( j = 0; *(_DWORD *)(a1 + 20) > j; ++j )
{
result = i + *(_DWORD *)(a1 + 16) * j;
*(_DWORD *)(*(_QWORD *)(a1 + 8) + 4 * result) = 0;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1)
{
int i; // esi
__int64 result; // rax
int j; // edx

for ( i = 0; *(_DWORD *)(a1 + 16) > i; ++i )
{
for ( j = 0; *(_DWORD *)(a1 + 20) > j; ++j )
{
result = i + *(_DWORD *)(a1 + 16) * j;
*(_DWORD *)(*(_QWORD *)(a1 + 8) + 4 * result) = 0;
}
}
return result;
}

original_code:
void clear(request_t *req)
{
 int x,y;
 for(x = 0; x < req->dx; x++)
  for(y = 0; y < req->dy; y++)
   req->data[y * req->dx + x] = 0;
}

canonical_original_code:
void clear(struct request_t *req)
{
 int x; int y;
 for(x = 0; x < req->dx; x++)
  for(y = 0; y < req->dy; y++)
   req->data[y * req->dx + x] = 0;
}

variable_types: struct request_t { int algorithm; int *data; int dx; int dy; unsigned int cl_start; int cl_end; int levels; double reg_x0; double reg_x1; double reg_y0; double reg_y1; } *


zoom

original_code:
void zoom(double value, request_t *req)
{
 double v = value;
  req->reg_x0 = req->reg_x0 + v;
  req->reg_y0 = req->reg_y0 + v;
  req->reg_x1 = req->reg_x1 - v;
  req->reg_y1 = req->reg_y1 - v;
}

canonical_original_code:
void zoom(double value, struct request_t *req)
{
 double v = value;
  req->reg_x0 = req->reg_x0 + v;
  req->reg_y0 = req->reg_y0 + v;
  req->reg_x1 = req->reg_x1 - v;
  req->reg_y1 = req->reg_y1 - v;
}

variable_types: value double

variable_types: v double


move

original_code:
void move(double x, double y, request_t *req)
{
 req->reg_x0 = req->reg_x0 + x;
 req->reg_y0 = req->reg_y0 + y;
 req->reg_x1 = req->reg_x1 + x;
 req->reg_y1 = req->reg_y1 + y;
}

canonical_original_code:
void move(double x, double y, struct request_t *req)
{
 req->reg_x0 = req->reg_x0 + x;
 req->reg_y0 = req->reg_y0 + y;
 req->reg_x1 = req->reg_x1 + x;
 req->reg_y1 = req->reg_y1 + y;
}

variable_types: x double

variable_types: y double


setpos

original_code:
void setpos(int x, int y, request_t *req)
{
 double dif = req->reg_x1 - req->reg_x0;
 double newx = x * 4 / req->dx - dif / 2;
 double newy = y * 4 / req->dy - dif / 2;
 req->reg_x0 = newx;
 req->reg_y0 = newy;
 req->reg_x1 = newx + dif;
 req->reg_y1 = newy + dif;
}

canonical_original_code:
void setpos(int x, int y, struct request_t *req)
{
 double dif = req->reg_x1 - req->reg_x0;
 double newx = x * 4 / req->dx - dif / 2;
 double newy = y * 4 / req->dy - dif / 2;
 req->reg_x0 = newx;
 req->reg_y0 = newy;
 req->reg_x1 = newx + dif;
 req->reg_y1 = newy + dif;
}

variable_types: dif double

variable_types: newx double

variable_types: newy double


original_code:
void mandelbrot_fract_algorithm(request_t req)
{
 clear(&req);
    long x,y,d,i;
    double real_x,real_y;
    complex_t z,c,temp;
 double agg_temp;
    agg_temp=req.reg_y1;
    req.reg_y1=req.reg_y0*(-1);
    req.reg_y0=agg_temp*(-1);
    for(x=0; x < req.dx; x++)
    {
        real_x = ((req.reg_x1-req.reg_x0)/req.dx)*x+req.reg_x0;
        for(y=0;y<req.dy;y++)
        {
            real_y = ((req.reg_y1 - req.reg_y0) / req.dy) * y + req.reg_y0;
            c.real = real_x;
            c.imaginary = real_y;
            z.real = 0;
            z.imaginary = 0;
            d = 0;
            for(i=0;i<req.levels;i++)
            {
                if((z.real*z.real)+(z.imaginary*z.imaginary) > 4)
                {
                    d = i;
                    break;
                }
                temp.real = z.real;
                temp.imaginary = z.imaginary;
                z.real = (temp.real*temp.real) - (temp.imaginary*temp.imaginary) + c.real;
                z.imaginary = (temp.real*temp.imaginary)*2 + c.imaginary;
            }
            if(d == 0) req.data[y * req.dx + x] = 0;
            else req.data[y * req.dx + x] = req.cl_start + (char) d * 0x100 + (char) d * 0x10000+ (char) d * 0x1000000;
        }
    }
}

canonical_original_code:
void mandelbrot_fract_algorithm(struct request_t req)
{
 clear(&req);
    long x; long y; long d; long i;
    double real_x; double real_y;
    struct complex_t z; struct complex_t c; struct complex_t temp;
 double agg_temp;
    agg_temp=req.reg_y1;
    req.reg_y1=req.reg_y0*(-1);
    req.reg_y0=agg_temp*(-1);
    for(x=0; x < req.dx; x++)
    {
        real_x = ((req.reg_x1-req.reg_x0)/req.dx)*x+req.reg_x0;
        for(y=0;y<req.dy;y++)
        {
            real_y = ((req.reg_y1 - req.reg_y0) / req.dy) * y + req.reg_y0;
            c.real = real_x;
            c.imaginary = real_y;
            z.real = 0;
            z.imaginary = 0;
            d = 0;
            for(i=0;i<req.levels;i++)
            {
                if((z.real*z.real)+(z.imaginary*z.imaginary) > 4)
                {
                    d = i;
                    break;
                }
                temp.real = z.real;
                temp.imaginary = z.imaginary;
                z.real = (temp.real*temp.real) - (temp.imaginary*temp.imaginary) + c.real;
                z.imaginary = (temp.real*temp.imaginary)*2 + c.imaginary;
            }
            if(d == 0) req.data[y * req.dx + x] = 0;
            else req.data[y * req.dx + x] = req.cl_start + (char) d * 0x100 + (char) d * 0x10000+ (char) d * 0x1000000;
        }
    }
}

variable_types: x long

variable_types: y long

variable_types: d long

variable_types: i long

variable_types: struct complex_t { double real; double imaginary; }


repo: dakk/sirbonville

original_code:
void sv_recompact(Porcile *p)
{
 int i, k;
 int n_mai = 0;
 for(i = 0; i < 10; i++)
 {
  if(p->maiali[i].eta < 0)
  {
   for(k = i + 1; k < 10; k++)
   {
    if(p->maiali[k].eta >= 0)
    {
     p->maiali[i] = p->maiali[k];
     p->maiali[k].eta = -1;
     k = 10;
    }
   }
  }
 }
}

canonical_original_code:
void sv_recompact(struct Porcile *p)
{
 int i; int k;
 int n_mai = 0;
 for(i = 0; i < 10; i++)
 {
  if(p->maiali[i].eta < 0)
  {
   for(k = i + 1; k < 10; k++)
   {
    if(p->maiali[k].eta >= 0)
    {
     p->maiali[i] = p->maiali[k];
     p->maiali[k].eta = -1;
     k = 10;
    }
   }
  }
 }
}

variable_types: struct Porcile { unsigned int letame; unsigned int monete; unsigned int cibo; unsigned int tempo; unsigned int n_maiali; struct maiale_t { int eta; int peso; int salute; unsigned int fame; unsigned int bisogni; } maiali[10]; unsigned int sec4unit; } *

variable_types: i int

variable_types: k int

user_defined_types: struct Porcile { unsigned int letame; unsigned int monete; unsigned int cibo; unsigned int tempo; unsigned int n_maiali; struct maiale_t maiali[10]; unsigned int sec4unit; }


original_code:
int sv_update(Porcile *p)
{
 int morti = 0;
 int i;
 int nmai = p->n_maiali;
 p->tempo++;
 for(i = 0; i < nmai; i++)
 {
  if((p->tempo % 4) == 0)
   p->maiali[i].fame = (p->maiali[i].fame + 1) % 100;
  if((p->tempo % 5) == 0)
   p->maiali[i].bisogni++;
  if(p->maiali[i].fame == 100)
   p->maiali[i].salute -= 2;
  if(p->maiali[i].peso > 200)
   p->maiali[i].salute -= 1;
  if(p->letame > 300)
   p->maiali[i].salute -= 1;
  if(p->maiali[i].fame >= 60)
   p->maiali[i].peso -= 1;
  if(p->maiali[i].bisogni == 100)
  {
   p->letame += ((p->maiali[i].peso / 10));
   p->maiali[i].bisogni = 0;
  }
  p->maiali[i].eta += 1;
  if( ((p->maiali[i].eta < 2 * 500 / 3) && (p->maiali[i].salute <= 30)) ||
   ((p->maiali[i].eta >= 2 * 500 / 3) && (p->maiali[i].salute < 60)) ||
   (p->maiali[i].eta >= 500) || (p->maiali[i].peso <= 0))
  {
   p->maiali[i].eta = -1;
   p->n_maiali--;
   morti++;
  }
 }
 sv_recompact(p);
 if((p->tempo % 150) == 0)
 {
  int nascite = (rand() % (p->n_maiali / 2)) + 1;
  if(nascite > 0)
  {
   for(i = 0; (i < nascite) && ((i + p->n_maiali) < 10); i++)
    sv_new_default_maial(p, i + p->n_maiali);
   p->n_maiali += i;
   p->monete += (nascite - i) * 50;
   sv_recompact(p);
  }
 }
 return morti;
}

canonical_original_code:
int sv_update(struct Porcile *p)
{
 int morti = 0;
 int i;
 int nmai = p->n_maiali;
 p->tempo++;
 for(i = 0; i < nmai; i++)
 {
  if((p->tempo % 4) == 0)
   p->maiali[i].fame = (p->maiali[i].fame + 1) % 100;
  if((p->tempo % 5) == 0)
   p->maiali[i].bisogni++;
  if(p->maiali[i].fame == 100)
   p->maiali[i].salute -= 2;
  if(p->maiali[i].peso > 200)
   p->maiali[i].salute -= 1;
  if(p->letame > 300)
   p->maiali[i].salute -= 1;
  if(p->maiali[i].fame >= 60)
   p->maiali[i].peso -= 1;
  if(p->maiali[i].bisogni == 100)
  {
   p->letame += ((p->maiali[i].peso / 10));
   p->maiali[i].bisogni = 0;
  }
  p->maiali[i].eta += 1;
  if( ((p->maiali[i].eta < 2 * 500 / 3) && (p->maiali[i].salute <= 30)) ||
   ((p->maiali[i].eta >= 2 * 500 / 3) && (p->maiali[i].salute < 60)) ||
   (p->maiali[i].eta >= 500) || (p->maiali[i].peso <= 0))
  {
   p->maiali[i].eta = -1;
   p->n_maiali--;
   morti++;
  }
 }
 sv_recompact(p);
 if((p->tempo % 150) == 0)
 {
  int nascite = (rand() % (p->n_maiali / 2)) + 1;
  if(nascite > 0)
  {
   for(i = 0; (i < nascite) && ((i + p->n_maiali) < 10); i++)
    sv_new_default_maial(p, i + p->n_maiali);
   p->n_maiali += i;
   p->monete += (nascite - i) * 50;
   sv_recompact(p);
  }
 }
 return morti;
}

variable_types: morti int

variable_types: nmai int

variable_types: nascite int

user_defined_types: struct maiale_t { int eta; int peso; int salute; unsigned int fame; unsigned int bisogni; }


decompiled_code:
__int64 __fastcall sv_feed(__int64 a1, unsigned int a2, unsigned int a3)
{
unsigned int v3; // ecx
__int64 result; // rax
unsigned int v5; // er9
unsigned int v6; // eax
__int64 v7; // r10

if ( *(_DWORD *)(a1 + 16) < a3 || !a2 )
return 0LL;
v3 = *(_DWORD *)(a1 + 8);
result = 0LL;
if ( v3 )
{
if ( v3 < a2 )
a2 = *(_DWORD *)(a1 + 8);
v5 = *(_DWORD *)(a1 + 20LL * (int)a3 + 32);
v6 = 0;
if ( v5 < a2 )
{
v6 = a2 - v5;
a2 = *(_DWORD *)(a1 + 20LL * (int)a3 + 32);
}
v7 = 5LL * (int)a3;
*(_DWORD *)(a1 + 4 * v7 + 32) = v5 - a2;
*(_DWORD *)(a1 + 4 * v7 + 24) = *(_DWORD *)(a1 + 20LL * (int)a3 + 24) + v6;
result = a2 + v6;
*(_DWORD *)(a1 + 8) = v3 - result;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1, unsigned int a2, unsigned int a3)
{
unsigned int v3; // ecx
__int64 result; // rax
unsigned int v5; // er9
unsigned int v6; // eax
__int64 v7; // r10

if ( *(_DWORD *)(a1 + 16) < a3 || !a2 )
return 0LL;
v3 = *(_DWORD *)(a1 + 8);
result = 0LL;
if ( v3 )
{
if ( v3 < a2 )
a2 = *(_DWORD *)(a1 + 8);
v5 = *(_DWORD *)(a1 + 20LL * (int)a3 + 32);
v6 = 0;
if ( v5 < a2 )
{
v6 = a2 - v5;
a2 = *(_DWORD *)(a1 + 20LL * (int)a3 + 32);
}
v7 = 5LL * (int)a3;
*(_DWORD *)(a1 + 4 * v7 + 32) = v5 - a2;
*(_DWORD *)(a1 + 4 * v7 + 24) = *(_DWORD *)(a1 + 20LL * (int)a3 + 24) + v6;
result = a2 + v6;
*(_DWORD *)(a1 + 8) = v3 - result;
}
return result;
}

original_code:
int sv_feed(Porcile *p, int quant, int who)
{
 unsigned peso = 0;
 if((who > p->n_maiali) || (quant == 0) || (p->cibo == 0))
  return 0;
 if(quant > p->cibo)
  quant = p->cibo;
 if(quant > p->maiali[who].fame)
 {
  peso = quant - p->maiali[who].fame;
  quant = p->maiali[who].fame;
 }
 p->maiali[who].fame -= quant;
 p->maiali[who].peso += peso;
 p->cibo -= (quant + peso);
 return (quant + peso);
}

canonical_original_code:
int sv_feed(struct Porcile *p, int quant, int who)
{
 unsigned int peso = 0;
 if((who > p->n_maiali) || (quant == 0) || (p->cibo == 0))
  return 0;
 if(quant > p->cibo)
  quant = p->cibo;
 if(quant > p->maiali[who].fame)
 {
  peso = quant - p->maiali[who].fame;
  quant = p->maiali[who].fame;
 }
 p->maiali[who].fame -= quant;
 p->maiali[who].peso += peso;
 p->cibo -= (quant + peso);
 return (quant + peso);
}

variable_types: quant int

variable_types: who int

variable_types:
peso
unsigned int


decompiled_code:
__int64 __fastcall sv_feed_all(__int64 a1, unsigned int a2)
{
unsigned int v2; // er12
unsigned int v3; // ebx

if ( !*(_DWORD *)(a1 + 16) )
return 0;
v2 = 0;
v3 = 0;
do
v2 += sv_feed(a1, a2, v3++);
while ( *(_DWORD *)(a1 + 16) > v3 );
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1, unsigned int a2)
{
unsigned int v2; // er12
unsigned int v3; // ebx

if ( !*(_DWORD *)(a1 + 16) )
return 0;
v2 = 0;
v3 = 0;
do
v2 += func6(a1, a2, v3++);
while ( *(_DWORD *)(a1 + 16) > v3 );
return v2;
}

original_code:
int sv_feed_all(Porcile *p, int quant)
{
 int i;
 int kg = 0;
 for(i = 0; i < p->n_maiali; i++)
  kg += sv_feed(p, quant, i);
 return kg;
}

canonical_original_code:
int sv_feed_all(struct Porcile *p, int quant)
{
 int i;
 int kg = 0;
 for(i = 0; i < p->n_maiali; i++)
  kg += sv_feed(p, quant, i);
 return kg;
}

variable_types: kg int


original_code:
int sv_sell(Porcile *p, int who)
{
 int money;
 if(who > p->n_maiali)
  return 0;
 p->maiali[who].eta = -1;
 money = p->maiali[who].salute * p->maiali[who].peso / 100;
 p->monete += money;
 p->n_maiali--;
 sv_recompact(p);
 return money;
}

canonical_original_code:
int sv_sell(struct Porcile *p, int who)
{
 int money;
 if(who > p->n_maiali)
  return 0;
 p->maiali[who].eta = -1;
 money = p->maiali[who].salute * p->maiali[who].peso / 100;
 p->monete += money;
 p->n_maiali--;
 sv_recompact(p);
 return money;
}

variable_types: money int


decompiled_code:
__int64 __fastcall sv_clear(unsigned int *a1, unsigned int a2)
{
__int64 result; // rax
unsigned int v3; // ecx
unsigned int v4; // edx

result = a2;
v3 = *a1;
if ( *a1 < a2 )
result = v3;
v4 = a1[1];
if ( v4 < (unsigned int)result )
result = v4;
*a1 = v3 - result;
a1[1] = v4 - result;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func9(unsigned int *a1, unsigned int a2)
{
__int64 result; // rax
unsigned int v3; // ecx
unsigned int v4; // edx

result = a2;
v3 = *a1;
if ( *a1 < a2 )
result = v3;
v4 = a1[1];
if ( v4 < (unsigned int)result )
result = v4;
*a1 = v3 - result;
a1[1] = v4 - result;
return result;
}

original_code:
int sv_clear(Porcile *p, int quant)
{
 if(quant > p->letame)
  quant = p->letame;
 if((quant * 1) > p->monete)
  quant = p->monete / 1;
 p->letame -= quant;
 p->monete -= quant * 1;
 return (quant * 1);
}

canonical_original_code:
int sv_clear(struct Porcile *p, int quant)
{
 if(quant > p->letame)
  quant = p->letame;
 if((quant * 1) > p->monete)
  quant = p->monete / 1;
 p->letame -= quant;
 p->monete -= quant * 1;
 return (quant * 1);
}


decompiled_code:
__int64 __fastcall sv_buy_food(__int64 a1, unsigned int a2)
{
unsigned int v2; // edx
__int64 result; // rax

v2 = *(_DWORD *)(a1 + 4);
result = a2;
if ( a2 > v2 )
result = v2;
*(_DWORD *)(a1 + 4) = v2 - result;
*(_DWORD *)(a1 + 8) += result;
return result;
}

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

v2 = *(_DWORD *)(a1 + 4);
result = a2;
if ( a2 > v2 )
result = v2;
*(_DWORD *)(a1 + 4) = v2 - result;
*(_DWORD *)(a1 + 8) += result;
return result;
}

original_code:
int sv_buy_food(Porcile *p, int quant)
{
 quant = quant > p->monete ? p->monete : quant;
 p->monete -= quant;
 p->cibo += quant * 1;
 return quant;
}

canonical_original_code:
int sv_buy_food(struct Porcile *p, int quant)
{
 quant = quant > p->monete ? p->monete : quant;
 p->monete -= quant;
 p->cibo += quant * 1;
 return quant;
}


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned int v3; // eax
const char **v5; // [rsp+0h] [rbp-F8h] BYREF
int v6; // [rsp+Ch] [rbp-ECh] BYREF
char v7[232]; // [rsp+10h] [rbp-E8h] BYREF

v6 = argc;
v5 = argv;
v3 = time(0LL);
srand(v3);
puts("SirbonVille 1.0");
if ( argc == 2 )
{
if ( (unsigned int)sv_load(v7, v5[1]) )
printf("Stato del gioco caricato dal file %s\n", v5[1]);
else
printf("Impossibile caricare lo stato del gioco dal file %s.\n", v5[1]);
}
gtk_init(&v6, &v5);
if ( (unsigned int)gui_create(v7) )
gtk_main();
else
printf("Errore durante il caricamento della gui. Uscita");
return 0;
}

original_code:
int main(int argc, char **argv)
{
 Porcile porcile;
 srand(time(((void *)0)));
 printf("%s\n", "SirbonVille " "1.0");
 if(argc == 2)
 {
  if(!sv_load(&porcile, argv[1]))
  {
   printf("Impossibile caricare lo stato del gioco dal file %s.\n", argv[1]);
  }
  else
   printf("Stato del gioco caricato dal file %s\n", argv[1]);
 }
 gtk_init (&argc, &argv);
 if(!gui_create(&porcile))
 {
  printf("Errore durante il caricamento della gui. Uscita");
  return 0;
 }
 gtk_main();
 return 0;
}

canonical_original_code:
int main(int argc, char **argv)
{
 struct Porcile porcile;
 srand(time(((void *)0)));
 printf("%s\n", "SirbonVille " "1.0");
 if(argc == 2)
 {
  if(!sv_load(&porcile, argv[1]))
  {
   printf("Impossibile caricare lo stato del gioco dal file %s.\n", argv[1]);
  }
  else
   printf("Stato del gioco caricato dal file %s\n", argv[1]);
 }
 gtk_init (&argc, &argv);
 if(!gui_create(&porcile))
 {
  printf("Errore durante il caricamento della gui. Uscita");
  return 0;
 }
 gtk_main();
 return 0;
}

variable_types: argc int

variable_types:
argv
char **

variable_types: struct Porcile { unsigned int letame; unsigned int monete; unsigned int cibo; unsigned int tempo; unsigned int n_maiali; struct maiale_t { int eta; int peso; int salute; unsigned int fame; unsigned int bisogni; } maiali[10]; unsigned int sec4unit; }


repo: dakk/spiderpig-os

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

debug_puts("network_iface_add()\n");
result = 1LL;
if ( a1 )
{
*(_QWORD *)(a1 + 88) = network_ifaces;
*(_BYTE *)(a1 + 50) = 0;
*(_DWORD *)(a1 + 56) = 0;
*(_DWORD *)(a1 + 60) = 0;
network_ifaces = (char *)a1;
result = 0LL;
}
return result;
}

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

debug_puts("network_iface_add()\n");
result = 1LL;
if ( a1 )
{
*(_QWORD *)(a1 + 88) = network_ifaces;
*(_BYTE *)(a1 + 50) = 0;
*(_DWORD *)(a1 + 56) = 0;
*(_DWORD *)(a1 + 60) = 0;
network_ifaces = (char *)a1;
result = 0LL;
}
return result;
}

original_code:
uint32_t network_iface_add(network_iface_t *iface)
{
 debug_puts("network_iface_add()\n");
 if(iface != 0)
 {
  iface->next = network_ifaces;
  iface->if_up = 0;
  iface->tx_bytes = 0;
  iface->rx_bytes = 0;
  network_ifaces = iface;
  return 0;
 }
 return 1;
}

canonical_original_code:
unsigned int network_iface_add(struct network_iface_p *iface)
{
 debug_puts("network_iface_add()\n");
 if(iface != 0)
 {
  iface->next = network_ifaces;
  iface->if_up = 0;
  iface->tx_bytes = 0;
  iface->rx_bytes = 0;
  network_ifaces = iface;
  return 0;
 }
 return 1;
}

variable_types: struct network_iface_p { char name[32]; char addr[4]; char mask[4]; char bcast[4]; char mac[6]; unsigned char if_up; unsigned char if_mac; unsigned char if_bcast; unsigned char type; unsigned int tx_bytes; unsigned int rx_bytes; struct driver_p { char name[32]; char desc[128]; char author[128]; unsigned char type; struct driver_fs_t { unsigned int (*mount)(char *, unsigned int, struct inode_p { char name[255]; unsigned int inode_n; unsigned char type; unsigned char ow; void *fs_node; void *fs_driver; struct inode_p *link; struct inode_p *next; struct inode_p *prev; struct inode_p *parent; struct inode_p *childs; } *); unsigned int (*umount)(struct inode_p *); unsigned int (*mkdir)(struct inode_p *, char *); unsigned int (*readdir)(struct inode_p *, unsigned int, struct dirent { char name[255]; unsigned int inode; } *); unsigned int (*get_node)(struct inode_p *, unsigned int, struct inode_p **); unsigned int (*delete_node)(struct inode_p *, char *); unsigned int (*create_node)(struct inode_p *, char *, unsigned int); unsigned int (*write_stat)(struct inode_p *, struct stat { unsigned int st_dev; unsigned int st_ino; int st_uid; int st_gid; unsigned long long st_blksize; unsigned long long st_blocks; } *, unsigned int); unsigned int (*read_stat)(struct inode_p *, struct stat *); unsigned int (*open)(struct inode_p *, char *); unsigned int (*close)(struct inode_p *); unsigned int (*read)(struct inode_p *, char *, unsigned int, unsigned long long); unsigned int (*write)(struct inode_p *, char *, unsigned int, unsigned long long); unsigned int (*link)(struct inode_p *, char *, struct inode_p *, char *); unsigned int (*unlink)(struct inode_p *, char *); unsigned char ifdev; } fs; struct driver_video_t { char *buffer; void (*put_pixel)(unsigned int, unsigned int, unsigned int); unsigned int (*get_pixel)(unsigned int, unsigned int); unsigned int (*set_mode)(unsigned int, unsigned int, unsigned int); } video; unsigned char loaded; unsigned int (*init)(); unsigned int (*free)(); unsigned int (*probe)(struct device_p { unsigned int io_base; char vendor[32]; char vendor_full[32]; char device[32]; char device_desc[32]; char class[32]; char class_desc[32]; char class_prog_desc[32]; unsigned char bus_type; void *pci_dev; unsigned char interrupt; unsigned int base_addresses[6]; char file[32]; struct device_p *next; } *); unsigned int (*read)(struct device_p *, char *, unsigned int, unsigned long long); unsigned int (*write)(struct device_p *, char *, unsigned int, unsigned long long); unsigned int (*ioctl)(struct device_p *, unsigned int, unsigned int, unsigned int); struct driver_p *next; } *drv; struct device_p *dev; void *link_protocol; struct network_iface_p *next; } *

return_type: unsigned int

user_defined_types: struct network_iface_p { char name[32]; char addr[4]; char mask[4]; char bcast[4]; char mac[6]; unsigned char if_up; unsigned char if_mac; unsigned char if_bcast; unsigned char type; unsigned int tx_bytes; unsigned int rx_bytes; struct driver_p *drv; struct device_p *dev; void *link_protocol; struct network_iface_p *next; }

user_defined_types: struct driver_p { char name[32]; char desc[128]; char author[128]; unsigned char type; struct driver_fs_t fs; struct driver_video_t video; unsigned char loaded; unsigned int (*init)(); unsigned int (*free)(); unsigned int (*probe)(struct device_p *); unsigned int (*read)(struct device_p *, char *, unsigned int, unsigned long long); unsigned int (*write)(struct device_p *, char *, unsigned int, unsigned long long); unsigned int (*ioctl)(struct device_p *, unsigned int, unsigned int, unsigned int); struct driver_p *next; }

user_defined_types: struct driver_fs_t { unsigned int (*mount)(char *, unsigned int, struct inode_p *); unsigned int (*umount)(struct inode_p *); unsigned int (*mkdir)(struct inode_p *, char *); unsigned int (*readdir)(struct inode_p *, unsigned int, struct dirent *); unsigned int (*get_node)(struct inode_p *, unsigned int, struct inode_p **); unsigned int (*delete_node)(struct inode_p *, char *); unsigned int (*create_node)(struct inode_p *, char *, unsigned int); unsigned int (*write_stat)(struct inode_p *, struct stat *, unsigned int); unsigned int (*read_stat)(struct inode_p *, struct stat *); unsigned int (*open)(struct inode_p *, char *); unsigned int (*close)(struct inode_p *); unsigned int (*read)(struct inode_p *, char *, unsigned int, unsigned long long); unsigned int (*write)(struct inode_p *, char *, unsigned int, unsigned long long); unsigned int (*link)(struct inode_p *, char *, struct inode_p *, char *); unsigned int (*unlink)(struct inode_p *, char *); unsigned char ifdev; }


decompiled_code:
__int64 __fastcall network_iface_iget(int a1, char **a2)
{
char *v2; // rax
int v3; // edx
__int64 result; // rax

v2 = network_ifaces;
*a2 = 0LL;
if ( !v2 )
return 1LL;
if ( a1 )
{
v3 = 0;
while ( 1 )
{
++v3;
v2 = (char *)*((_QWORD *)v2 + 11);
if ( !v2 )
break;
if ( a1 == v3 )
goto LABEL_6;
}
result = 1LL;
}
else
{
LABEL_6:
*a2 = v2;
result = 0LL;
}
return result;
}

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

v2 = network_ifaces;
*a2 = 0LL;
if ( !v2 )
return 1LL;
if ( a1 )
{
v3 = 0;
while ( 1 )
{
++v3;
v2 = (char *)*((_QWORD *)v2 + 11);
if ( !v2 )
break;
if ( a1 == v3 )
goto LABEL_6;
}
result = 1LL;
}
else
{
LABEL_6:
*a2 = v2;
result = 0LL;
}
return result;
}

original_code:
uint32_t network_iface_iget(uint32_t x, network_iface_t **iface)
{
 network_iface_t *cf = network_ifaces;
 uint32_t i = 0;
 *iface = 0;
 while(cf != 0)
 {
  if(i == x)
  {
   *iface = cf;
   return 0;
  }
  i++;
  cf = cf->next;
 }
 return 1;
}

canonical_original_code:
unsigned int network_iface_iget(unsigned int x, struct network_iface_p **iface)
{
 struct network_iface_p *cf = network_ifaces;
 unsigned int i = 0;
 *iface = 0;
 while(cf != 0)
 {
  if(i == x)
  {
   *iface = cf;
   return 0;
  }
  i++;
  cf = cf->next;
 }
 return 1;
}

variable_types:
x
unsigned int

variable_types: struct network_iface_p { char name[32]; char addr[4]; char mask[4]; char bcast[4]; char mac[6]; unsigned char if_up; unsigned char if_mac; unsigned char if_bcast; unsigned char type; unsigned int tx_bytes; unsigned int rx_bytes; struct driver_p { char name[32]; char desc[128]; char author[128]; unsigned char type; struct driver_fs_t { unsigned int (*mount)(char *, unsigned int, struct inode_p { char name[255]; unsigned int inode_n; unsigned char type; unsigned char ow; void *fs_node; void *fs_driver; struct inode_p *link; struct inode_p *next; struct inode_p *prev; struct inode_p *parent; struct inode_p *childs; } *); unsigned int (*umount)(struct inode_p *); unsigned int (*mkdir)(struct inode_p *, char *); unsigned int (*readdir)(struct inode_p *, unsigned int, struct dirent { char name[255]; unsigned int inode; } *); unsigned int (*get_node)(struct inode_p *, unsigned int, struct inode_p **); unsigned int (*delete_node)(struct inode_p *, char *); unsigned int (*create_node)(struct inode_p *, char *, unsigned int); unsigned int (*write_stat)(struct inode_p *, struct stat { unsigned int st_dev; unsigned int st_ino; int st_uid; int st_gid; unsigned long long st_blksize; unsigned long long st_blocks; } *, unsigned int); unsigned int (*read_stat)(struct inode_p *, struct stat *); unsigned int (*open)(struct inode_p *, char *); unsigned int (*close)(struct inode_p *); unsigned int (*read)(struct inode_p *, char *, unsigned int, unsigned long long); unsigned int (*write)(struct inode_p *, char *, unsigned int, unsigned long long); unsigned int (*link)(struct inode_p *, char *, struct inode_p *, char *); unsigned int (*unlink)(struct inode_p *, char *); unsigned char ifdev; } fs; struct driver_video_t { char *buffer; void (*put_pixel)(unsigned int, unsigned int, unsigned int); unsigned int (*get_pixel)(unsigned int, unsigned int); unsigned int (*set_mode)(unsigned int, unsigned int, unsigned int); } video; unsigned char loaded; unsigned int (*init)(); unsigned int (*free)(); unsigned int (*probe)(struct device_p { unsigned int io_base; char vendor[32]; char vendor_full[32]; char device[32]; char device_desc[32]; char class[32]; char class_desc[32]; char class_prog_desc[32]; unsigned char bus_type; void *pci_dev; unsigned char interrupt; unsigned int base_addresses[6]; char file[32]; struct device_p *next; } *); unsigned int (*read)(struct device_p *, char *, unsigned int, unsigned long long); unsigned int (*write)(struct device_p *, char *, unsigned int, unsigned long long); unsigned int (*ioctl)(struct device_p *, unsigned int, unsigned int, unsigned int); struct driver_p *next; } *drv; struct device_p *dev; void *link_protocol; struct network_iface_p *next; } **

variable_types:
i
unsigned int


decompiled_code:
int __fastcall network_iface_get(char *s1, char **a2)
{
char *v2; // rbx
int result; // eax

v2 = network_ifaces;
*a2 = 0LL;
if ( !v2 )
return 1;
while ( 1 )
{
result = strcmp(s1, v2);
if ( !result )
break;
v2 = (char *)*((_QWORD *)v2 + 11);
if ( !v2 )
return 1;
}
*a2 = v2;
return result;
}

canonical_decompiled_code:
int __fastcall func2(char *s1, char **a2)
{
char *v2; // rbx
int result; // eax

v2 = network_ifaces;
*a2 = 0LL;
if ( !v2 )
return 1;
while ( 1 )
{
result = strcmp(s1, v2);
if ( !result )
break;
v2 = (char *)*((_QWORD *)v2 + 11);
if ( !v2 )
return 1;
}
*a2 = v2;
return result;
}

original_code:
uint32_t network_iface_get(char *name, network_iface_t **iface)
{
 network_iface_t *cf = network_ifaces;
 *iface = 0;
 while(cf != 0)
 {
  if(strcmp(name, cf->name) == 0)
  {
   *iface = cf;
   return 0;
  }
  cf = cf->next;
 }
 return 1;
}

canonical_original_code:
unsigned int network_iface_get(char *name, struct network_iface_p **iface)
{
 struct network_iface_p *cf = network_ifaces;
 *iface = 0;
 while(cf != 0)
 {
  if(strcmp(name, cf->name) == 0)
  {
   *iface = cf;
   return 0;
  }
  cf = cf->next;
 }
 return 1;
}

variable_types:
name
char *

user_defined_types: struct driver_video_t { char *buffer; void (*put_pixel)(unsigned int, unsigned int, unsigned int); unsigned int (*get_pixel)(unsigned int, unsigned int); unsigned int (*set_mode)(unsigned int, unsigned int, unsigned int); }

user_defined_types: struct device_p { unsigned int io_base; char vendor[32]; char vendor_full[32]; char device[32]; char device_desc[32]; char class[32]; char class_desc[32]; char class_prog_desc[32]; unsigned char bus_type; void *pci_dev; unsigned char interrupt; unsigned int base_addresses[6]; char file[32]; struct device_p *next; }

user_defined_types: struct inode_p { char name[255]; unsigned int inode_n; unsigned char type; unsigned char ow; void *fs_node; void *fs_driver; struct inode_p *link; struct inode_p *next; struct inode_p *prev; struct inode_p *parent; struct inode_p *childs; }

user_defined_types: struct dirent { char name[255]; unsigned int inode; }

user_defined_types: struct stat { unsigned int st_dev; unsigned int st_ino; int st_uid; int st_gid; unsigned long long st_blksize; unsigned long long st_blocks; }


decompiled_code:
__int64 __fastcall network_iface_down(char *s1)
{
__int64 result; // rax
char *v2; // [rsp+8h] [rbp-10h] BYREF

debug_puts("network_iface_down()\n");
network_iface_get(s1, &v2);
result = 1LL;
if ( v2 )
{
v2[50] = 0;
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(char *s1)
{
__int64 result; // rax
char *v2; // [rsp+8h] [rbp-10h] BYREF

debug_puts("network_iface_down()\n");
func2(s1, &v2);
result = 1LL;
if ( v2 )
{
v2[50] = 0;
result = 0LL;
}
return result;
}

original_code:
uint32_t network_iface_down(char *ifname)
{
 debug_puts("network_iface_down()\n");
 network_iface_t *ci;
 network_iface_get(ifname, &ci);
 if(ci != 0)
 {
  ci->if_up = 0;
  return 0;
 }
 return 1;
}

canonical_original_code:
unsigned int network_iface_down(char *ifname)
{
 debug_puts("network_iface_down()\n");
 struct network_iface_p *ci;
 network_iface_get(ifname, &ci);
 if(ci != 0)
 {
  ci->if_up = 0;
  return 0;
 }
 return 1;
}

variable_types:
ifname
char *


decompiled_code:
__int64 __fastcall network_iface_up(char *s1)
{
char *v1; // rax
unsigned int v2; // edx
char *v4[2]; // [rsp+8h] [rbp-10h] BYREF

debug_puts("network_iface_up()\n");
network_iface_get(s1, v4);
v1 = v4[0];
v2 = 1;
if ( v4[0] )
{
*((_DWORD *)v4[0] + 14) = 0;
*((_DWORD *)v1 + 15) = 0;
v1[50] = 1;
driver_initd(*((_QWORD *)v1 + 8), v4, 1LL);
v2 = 0;
}
return v2;
}

original_code:
uint32_t network_iface_up(char *ifname)
{
 debug_puts("network_iface_up()\n");
 network_iface_t *ci;
 network_iface_get(ifname, &ci);
 if(ci != 0)
 {
  ci->tx_bytes = 0;
  ci->rx_bytes = 0;
  ci->if_up = 1;
  driver_initd((ci->drv)->name);
  return 0;
 }
 return 1;
}

canonical_original_code:
unsigned int network_iface_up(char *ifname)
{
 debug_puts("network_iface_up()\n");
 struct network_iface_p *ci;
 network_iface_get(ifname, &ci);
 if(ci != 0)
 {
  ci->tx_bytes = 0;
  ci->rx_bytes = 0;
  ci->if_up = 1;
  driver_initd((ci->drv)->name);
  return 0;
 }
 return 1;
}


decompiled_code:
char *__fastcall network_addrtoa(unsigned __int8 *a1, char *a2)
{
const char *v2; // rax
const char *v3; // rax
const char *v4; // rax
const char *v5; // rax

v2 = (const char *)itoa(*a1);
strcpy(a2, v2);
strcat(a2, src);
v3 = (const char *)itoa(a1[1]);
strcat(a2, v3);
strcat(a2, src);
v4 = (const char *)itoa(a1[2]);
strcat(a2, v4);
strcat(a2, src);
v5 = (const char *)itoa(a1[3]);
strcat(a2, v5);
strcat(a2, byte_1016E90);
return a2;
}

canonical_decompiled_code:
char *__fastcall func5(unsigned __int8 *a1, char *a2)
{
const char *v2; // rax
const char *v3; // rax
const char *v4; // rax
const char *v5; // rax

v2 = (const char *)itoa(*a1);
strcpy(a2, v2);
strcat(a2, src);
v3 = (const char *)itoa(a1[1]);
strcat(a2, v3);
strcat(a2, src);
v4 = (const char *)itoa(a1[2]);
strcat(a2, v4);
strcat(a2, src);
v5 = (const char *)itoa(a1[3]);
strcat(a2, v5);
strcat(a2, byte_1016E90);
return a2;
}

original_code:
char *network_addrtoa(ip_t addr, char *str)
{
 strcpy(str, itoa((uint8_t) addr[0]));
 strcat(str, ".");
 strcat(str, itoa((uint8_t) addr[1]));
 strcat(str, ".");
 strcat(str, itoa((uint8_t) addr[2]));
 strcat(str, ".");
 strcat(str, itoa((uint8_t) addr[3]));
 strcat(str, "\0");
 return str;
}

canonical_original_code:
char *network_addrtoa(char addr[4], char *str)
{
 strcpy(str, itoa((unsigned char) addr[0]));
 strcat(str, ".");
 strcat(str, itoa((unsigned char) addr[1]));
 strcat(str, ".");
 strcat(str, itoa((unsigned char) addr[2]));
 strcat(str, ".");
 strcat(str, itoa((unsigned char) addr[3]));
 strcat(str, "\0");
 return str;
}

variable_types:
addr
char [4]

variable_types:
str
char *

return_type: char *


decompiled_code:
char *__fastcall network_macrtoa(unsigned __int8 *a1, char *a2)
{
const char *v2; // rax
const char *v3; // rax
const char *v4; // rax
const char *v5; // rax
const char *v6; // rax
const char *v7; // rax

v2 = (const char *)itox(*a1);
strcpy(a2, v2);
strcat(a2, &src[2]);
v3 = (const char *)itox(a1[1]);
strcat(a2, v3);
strcat(a2, &src[2]);
v4 = (const char *)itox(a1[2]);
strcat(a2, v4);
strcat(a2, &src[2]);
v5 = (const char *)itox(a1[3]);
strcat(a2, v5);
strcat(a2, &src[2]);
v6 = (const char *)itox(a1[4]);
strcat(a2, v6);
strcat(a2, &src[2]);
v7 = (const char *)itox(a1[5]);
strcat(a2, v7);
strcat(a2, byte_1016E90);
return a2;
}

canonical_decompiled_code:
char *__fastcall func6(unsigned __int8 *a1, char *a2)
{
const char *v2; // rax
const char *v3; // rax
const char *v4; // rax
const char *v5; // rax
const char *v6; // rax
const char *v7; // rax

v2 = (const char *)itox(*a1);
strcpy(a2, v2);
strcat(a2, &src[2]);
v3 = (const char *)itox(a1[1]);
strcat(a2, v3);
strcat(a2, &src[2]);
v4 = (const char *)itox(a1[2]);
strcat(a2, v4);
strcat(a2, &src[2]);
v5 = (const char *)itox(a1[3]);
strcat(a2, v5);
strcat(a2, &src[2]);
v6 = (const char *)itox(a1[4]);
strcat(a2, v6);
strcat(a2, &src[2]);
v7 = (const char *)itox(a1[5]);
strcat(a2, v7);
strcat(a2, byte_1016E90);
return a2;
}

original_code:
char *network_macrtoa(mac_t addr, char *str)
{
 strcpy(str, itox((uint8_t) addr[0]));
 strcat(str, ":");
 strcat(str, itox((uint8_t) addr[1]));
 strcat(str, ":");
 strcat(str, itox((uint8_t) addr[2]));
 strcat(str, ":");
 strcat(str, itox((uint8_t) addr[3]));
 strcat(str, ":");
 strcat(str, itox((uint8_t) addr[4]));
 strcat(str, ":");
 strcat(str, itox((uint8_t) addr[5]));
 strcat(str, "\0");
 return str;
}

canonical_original_code:
char *network_macrtoa(char addr[6], char *str)
{
 strcpy(str, itox((unsigned char) addr[0]));
 strcat(str, ":");
 strcat(str, itox((unsigned char) addr[1]));
 strcat(str, ":");
 strcat(str, itox((unsigned char) addr[2]));
 strcat(str, ":");
 strcat(str, itox((unsigned char) addr[3]));
 strcat(str, ":");
 strcat(str, itox((unsigned char) addr[4]));
 strcat(str, ":");
 strcat(str, itox((unsigned char) addr[5]));
 strcat(str, "\0");
 return str;
}

variable_types:
addr
char [6]


decompiled_code:
void __fastcall network_toaddr(_BYTE *a1, char a2, char a3, char a4, char a5)
{
*a1 = a2;
a1[1] = a3;
a1[2] = a4;
a1[3] = a5;
}

canonical_decompiled_code:
void __fastcall func7(_BYTE *a1, char a2, char a3, char a4, char a5)
{
*a1 = a2;
a1[1] = a3;
a1[2] = a4;
a1[3] = a5;
}

original_code:
void network_toaddr(ip_t buf, uint8_t a, uint8_t b, uint8_t c, uint8_t d)
{
 buf[0] = a;
 buf[1] = b;
 buf[2] = c;
 buf[3] = d;
}

canonical_original_code:
void network_toaddr(char buf[4], unsigned char a, unsigned char b, unsigned char c, unsigned char d)
{
 buf[0] = a;
 buf[1] = b;
 buf[2] = c;
 buf[3] = d;
}

variable_types:
buf
char [4]

variable_types:
a
unsigned char

variable_types:
b
unsigned char

variable_types:
c
unsigned char

variable_types:
d
unsigned char


decompiled_code:
__int64 __fastcall network_iface_create(int a1, __int64 a2, __int64 a3)
{
__int64 v4; // rbx
signed int v5; // eax

if ( a3 != 0 && a2 != 0 || (v4 = 0LL, a1 == 1) )
{
v5 = (unsigned int)malloc(0x60uLL);
v4 = v5;
*(_DWORD *)((char *)&loc_35 + v5 + 3) = 0;
*(_DWORD *)((char *)&loc_3C + v5) = 0;
*(_QWORD *)((char *)&loc_3C + v5 + 4) = a2;
*(_QWORD *)((char *)network_iface_iget + v5 + 5) = a3;
*((_BYTE *)&loc_35 + v5) = a1;
*((_BYTE *)&loc_2E + v5 + 4) = 0;
switch ( a1 )
{
case 1:
strcpy((char *)v5, "lo");
network_toaddr((_BYTE *)(v4 + 32), 127, 0, 0, 1);
network_toaddr((_BYTE *)(v4 + 36), 255, 0, 0, 0);
network_toaddr((_BYTE *)(v4 + 40), 0, 0, 0, 0);
*(_BYTE *)(v4 + 51) = 0;
*(_QWORD *)(v4 + 80) = &lo_linkproto;
break;
case 2:
strcpy((char *)v5, off_1016E6B);
*(_QWORD *)(v4 + 80) = &eth_linkproto;
break;
case 3:
strcpy((char *)v5, off_1016E72);
*(_QWORD *)(v4 + 80) = &ppp_linkproto;
break;
case 6:
strcpy((char *)v5, "wifi");
*(_QWORD *)(v4 + 80) = &wifi_linkproto;
break;
case 7:
strcpy((char *)v5, "bt");
*(_QWORD *)(v4 + 80) = &bt_linkproto;
break;
default:
free((void *)v5);
v4 = 0LL;
break;
}
}
return v4;
}

canonical_decompiled_code:
__int64 __fastcall func8(int a1, __int64 a2, __int64 a3)
{
__int64 v4; // rbx
signed int v5; // eax

if ( a3 != 0 && a2 != 0 || (v4 = 0LL, a1 == 1) )
{
v5 = (unsigned int)malloc(0x60uLL);
v4 = v5;
*(_DWORD *)((char *)&loc_35 + v5 + 3) = 0;
*(_DWORD *)((char *)&loc_3C + v5) = 0;
*(_QWORD *)((char *)&loc_3C + v5 + 4) = a2;
*(_QWORD *)((char *)network_iface_iget + v5 + 5) = a3;
*((_BYTE *)&loc_35 + v5) = a1;
*((_BYTE *)&loc_2E + v5 + 4) = 0;
switch ( a1 )
{
case 1:
strcpy((char *)v5, "lo");
func7((_BYTE *)(v4 + 32), 127, 0, 0, 1);
func7((_BYTE *)(v4 + 36), 255, 0, 0, 0);
func7((_BYTE *)(v4 + 40), 0, 0, 0, 0);
*(_BYTE *)(v4 + 51) = 0;
*(_QWORD *)(v4 + 80) = &lo_linkproto;
break;
case 2:
strcpy((char *)v5, off_1016E6B);
*(_QWORD *)(v4 + 80) = &eth_linkproto;
break;
case 3:
strcpy((char *)v5, off_1016E72);
*(_QWORD *)(v4 + 80) = &ppp_linkproto;
break;
case 6:
strcpy((char *)v5, "wifi");
*(_QWORD *)(v4 + 80) = &wifi_linkproto;
break;
case 7:
strcpy((char *)v5, "bt");
*(_QWORD *)(v4 + 80) = &bt_linkproto;
break;
default:
free((void *)v5);
v4 = 0LL;
break;
}
}
return v4;
}

original_code:
network_iface_t *network_iface_create(uint32_t type, driver_t *driver, device_t *device)
{
 if(((driver == 0) || (device == 0)) && type != 1)
  return 0;
 network_iface_t *iface = (network_iface_t *) malloc(sizeof(network_iface_t));
 iface->tx_bytes = 0;
 iface->rx_bytes = 0;
 iface->drv = driver;
 iface->dev = device;
 iface->type = type;
 iface->if_up = 0;
 switch(type)
 {
  case 2:
   strcpy(iface->name, "eth");
   iface->link_protocol = (void *) &eth_linkproto;
   break;
  case 1:
   strcpy(iface->name, "lo");
   network_toaddr(iface->addr, 127, 0, 0, 1);
   network_toaddr(iface->mask, 255, 0, 0, 0);
   network_toaddr(iface->bcast, 0, 0, 0, 0);
   iface->if_mac = 0;
   iface->link_protocol = (void *) &lo_linkproto;
   break;
  case 3:
   strcpy(iface->name, "ppp");
   iface->link_protocol = (void *) &ppp_linkproto;
   break;
  case 7:
   strcpy(iface->name, "bt");
   iface->link_protocol = (void *) &bt_linkproto;
   break;
  case 6:
   strcpy(iface->name, "wifi");
   iface->link_protocol = (void *) &wifi_linkproto;
   break;
  default:
   free(iface);
   return 0;
 }
 return iface;
}

canonical_original_code:
struct network_iface_p *network_iface_create(unsigned int type, struct driver_p *driver, struct device_p *device)
{
 if(((driver == 0) || (device == 0)) && type != 1)
  return 0;
 struct network_iface_p *iface = (network_iface_t *) malloc(sizeof(network_iface_t));
 iface->tx_bytes = 0;
 iface->rx_bytes = 0;
 iface->drv = driver;
 iface->dev = device;
 iface->type = type;
 iface->if_up = 0;
 switch(type)
 {
  case 2:
   strcpy(iface->name, "eth");
   iface->link_protocol = (void *) &eth_linkproto;
   break;
  case 1:
   strcpy(iface->name, "lo");
   network_toaddr(iface->addr, 127, 0, 0, 1);
   network_toaddr(iface->mask, 255, 0, 0, 0);
   network_toaddr(iface->bcast, 0, 0, 0, 0);
   iface->if_mac = 0;
   iface->link_protocol = (void *) &lo_linkproto;
   break;
  case 3:
   strcpy(iface->name, "ppp");
   iface->link_protocol = (void *) &ppp_linkproto;
   break;
  case 7:
   strcpy(iface->name, "bt");
   iface->link_protocol = (void *) &bt_linkproto;
   break;
  case 6:
   strcpy(iface->name, "wifi");
   iface->link_protocol = (void *) &wifi_linkproto;
   break;
  default:
   free(iface);
   return 0;
 }
 return iface;
}

variable_types:
type
unsigned int

variable_types:
driver
struct driver_p *

variable_types:
device
struct device_p *

return_type: struct network_iface_p { char name[32]; char addr[4]; char mask[4]; char bcast[4]; char mac[6]; unsigned char if_up; unsigned char if_mac; unsigned char if_bcast; unsigned char type; unsigned int tx_bytes; unsigned int rx_bytes; struct driver_p { char name[32]; char desc[128]; char author[128]; unsigned char type; struct driver_fs_t { unsigned int (*mount)(char *, unsigned int, struct inode_p { char name[255]; unsigned int inode_n; unsigned char type; unsigned char ow; void *fs_node; void *fs_driver; struct inode_p *link; struct inode_p *next; struct inode_p *prev; struct inode_p *parent; struct inode_p *childs; } *); unsigned int (*umount)(struct inode_p *); unsigned int (*mkdir)(struct inode_p *, char *); unsigned int (*readdir)(struct inode_p *, unsigned int, struct dirent { char name[255]; unsigned int inode; } *); unsigned int (*get_node)(struct inode_p *, unsigned int, struct inode_p **); unsigned int (*delete_node)(struct inode_p *, char *); unsigned int (*create_node)(struct inode_p *, char *, unsigned int); unsigned int (*write_stat)(struct inode_p *, struct stat { unsigned int st_dev; unsigned int st_ino; int st_uid; int st_gid; unsigned long long st_blksize; unsigned long long st_blocks; } *, unsigned int); unsigned int (*read_stat)(struct inode_p *, struct stat *); unsigned int (*open)(struct inode_p *, char *); unsigned int (*close)(struct inode_p *); unsigned int (*read)(struct inode_p *, char *, unsigned int, unsigned long long); unsigned int (*write)(struct inode_p *, char *, unsigned int, unsigned long long); unsigned int (*link)(struct inode_p *, char *, struct inode_p *, char *); unsigned int (*unlink)(struct inode_p *, char *); unsigned char ifdev; } fs; struct driver_video_t { char *buffer; void (*put_pixel)(unsigned int, unsigned int, unsigned int); unsigned int (*get_pixel)(unsigned int, unsigned int); unsigned int (*set_mode)(unsigned int, unsigned int, unsigned int); } video; unsigned char loaded; unsigned int (*init)(); unsigned int (*free)(); unsigned int (*probe)(struct device_p { unsigned int io_base; char vendor[32]; char vendor_full[32]; char device[32]; char device_desc[32]; char class[32]; char class_desc[32]; char class_prog_desc[32]; unsigned char bus_type; void *pci_dev; unsigned char interrupt; unsigned int base_addresses[6]; char file[32]; struct device_p *next; } *); unsigned int (*read)(struct device_p *, char *, unsigned int, unsigned long long); unsigned int (*write)(struct device_p *, char *, unsigned int, unsigned long long); unsigned int (*ioctl)(struct device_p *, unsigned int, unsigned int, unsigned int); struct driver_p *next; } *drv; struct device_p *dev; void *link_protocol; struct network_iface_p *next; } *


decompiled_code:
__int64 __fastcall network_iface_add2(char *s1, __int64 a2, __int64 a3, const void *a4, const void *a5)
{
__int64 v7; // r13
__int64 result; // rax
int v9; // edx
int v10; // edx

if ( !strcmp(s1, "lo") )
{
v7 = network_iface_create(1, 0LL, 0LL);
result = 0LL;
if ( v7 )
{
network_iface_add(v7);
network_iface_up(s1);
memcpy((void *)(v7 + 32), a4, 4uLL);
memcpy((void *)(v7 + 36), a5, 4uLL);
result = 1LL;
}
}
else
{
v9 = strcmp(s1, off_1016E6B);
result = 0LL;
if ( v9 )
{
v10 = strcmp(s1, off_1016E72);
result = 0LL;
if ( v10 )
{
strcmp(s1, "wifi");
result = 0LL;
}
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func9(char *s1, __int64 a2, __int64 a3, const void *a4, const void *a5)
{
__int64 v7; // r13
__int64 result; // rax
int v9; // edx
int v10; // edx

if ( !strcmp(s1, "lo") )
{
v7 = func8(1, 0LL, 0LL);
result = 0LL;
if ( v7 )
{
func0(v7);
func4(s1);
memcpy((void *)(v7 + 32), a4, 4uLL);
memcpy((void *)(v7 + 36), a5, 4uLL);
result = 1LL;
}
}
else
{
v9 = strcmp(s1, off_1016E6B);
result = 0LL;
if ( v9 )
{
v10 = strcmp(s1, off_1016E72);
result = 0LL;
if ( v10 )
{
strcmp(s1, "wifi");
result = 0LL;
}
}
}
return result;
}

original_code:
uint32_t network_iface_add2(char *type, char *driver, char *device, char *adr, char *mask)
{
 network_iface_t *nt = 0;
 if(strcmp(type, "lo") == 0)
  nt = network_iface_create(1, 0, 0);
 else if(strcmp(type, "eth") == 0)
  nt = 0;
 else if(strcmp(type, "ppp") == 0)
  nt = 0;
 else if(strcmp(type, "wifi") == 0)
  nt = 0;
 if(nt != 0)
 {
  network_iface_add(nt);
  network_iface_up(type);
  memcpy(nt->addr, adr, 4);
  memcpy(nt->mask, mask, 4);
  return 1;
 }
 return 0;
}

canonical_original_code:
unsigned int network_iface_add2(char *type, char *driver, char *device, char *adr, char *mask)
{
 struct network_iface_p *nt = 0;
 if(strcmp(type, "lo") == 0)
  nt = network_iface_create(1, 0, 0);
 else if(strcmp(type, "eth") == 0)
  nt = 0;
 else if(strcmp(type, "ppp") == 0)
  nt = 0;
 else if(strcmp(type, "wifi") == 0)
  nt = 0;
 if(nt != 0)
 {
  network_iface_add(nt);
  network_iface_up(type);
  memcpy(nt->addr, adr, 4);
  memcpy(nt->mask, mask, 4);
  return 1;
 }
 return 0;
}

variable_types:
type
char *

variable_types:
driver
char *

variable_types:
device
char *

variable_types:
adr
char *

variable_types:
mask
char *

variable_types: struct network_iface_p { char name[32]; char addr[4]; char mask[4]; char bcast[4]; char mac[6]; unsigned char if_up; unsigned char if_mac; unsigned char if_bcast; unsigned char type; unsigned int tx_bytes; unsigned int rx_bytes; struct driver_p { char name[32]; char desc[128]; char author[128]; unsigned char type; struct driver_fs_t { unsigned int (*mount)(char *, unsigned int, struct inode_p { char name[255]; unsigned int inode_n; unsigned char type; unsigned char ow; void *fs_node; void *fs_driver; struct inode_p *link; struct inode_p *next; struct inode_p *prev; struct inode_p *parent; struct inode_p *childs; } *); unsigned int (*umount)(struct inode_p *); unsigned int (*mkdir)(struct inode_p *, char *); unsigned int (*readdir)(struct inode_p *, unsigned int, struct dirent { char name[255]; unsigned int inode; } *); unsigned int (*get_node)(struct inode_p *, unsigned int, struct inode_p **); unsigned int (*delete_node)(struct inode_p *, char *); unsigned int (*create_node)(struct inode_p *, char *, unsigned int); unsigned int (*write_stat)(struct inode_p *, struct stat { unsigned int st_dev; unsigned int st_ino; int st_uid; int st_gid; unsigned long long st_blksize; unsigned long long st_blocks; } *, unsigned int); unsigned int (*read_stat)(struct inode_p *, struct stat *); unsigned int (*open)(struct inode_p *, char *); unsigned int (*close)(struct inode_p *); unsigned int (*read)(struct inode_p *, char *, unsigned int, unsigned long long); unsigned int (*write)(struct inode_p *, char *, unsigned int, unsigned long long); unsigned int (*link)(struct inode_p *, char *, struct inode_p *, char *); unsigned int (*unlink)(struct inode_p *, char *); unsigned char ifdev; } fs; struct driver_video_t { char *buffer; void (*put_pixel)(unsigned int, unsigned int, unsigned int); unsigned int (*get_pixel)(unsigned int, unsigned int); unsigned int (*set_mode)(unsigned int, unsigned int, unsigned int); } video; unsigned char loaded; unsigned int (*init)(); unsigned int (*free)(); unsigned int (*probe)(struct device_p { unsigned int io_base; char vendor[32]; char vendor_full[32]; char device[32]; char device_desc[32]; char class[32]; char class_desc[32]; char class_prog_desc[32]; unsigned char bus_type; void *pci_dev; unsigned char interrupt; unsigned int base_addresses[6]; char file[32]; struct device_p *next; } *); unsigned int (*read)(struct device_p *, char *, unsigned int, unsigned long long); unsigned int (*write)(struct device_p *, char *, unsigned int, unsigned long long); unsigned int (*ioctl)(struct device_p *, unsigned int, unsigned int, unsigned int); struct driver_p *next; } *drv; struct device_p *dev; void *link_protocol; struct network_iface_p *next; } *


variable_types:
dest
char [4]

variable_types:
gw
char [4]

variable_types:
genmask
char [4]

variable_types: i int

variable_types: struct packet_t { unsigned int size; char *data; } *


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

task_switch();
result = 100 * (++pit_tick / 0x64u);
if ( pit_tick == (_DWORD)result )
{
result = (unsigned int)(unsigned __int8)*(&clock_data + 2) + 1;
if ( (unsigned __int8)(*(&clock_data + 2) + 1) > 0x3Bu )
{
*(&clock_data + 2) = 0;
++*(&clock_data + 1);
}
else
{
++*(&clock_data + 2);
}
if ( (unsigned __int8)*(&clock_data + 1) > 0x3Bu )
{
*(&clock_data + 1) = 0;
++clock_data;
}
if ( (unsigned __int8)clock_data > 0x16u )
{
clock_data = 0;
++*(&clock_data + 4);
}
if ( (unsigned __int8)*(&clock_data + 4) > 0x1Du )
{
*(&clock_data + 4) = 0;
++*(&clock_data + 3);
}
if ( (unsigned __int8)*(&clock_data + 3) > 0xBu )
{
*(&clock_data + 3) = 0;
++*(&clock_data + 5);
}
}
return result;
}

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

task_switch();
result = 100 * (++pit_tick / 0x64u);
if ( pit_tick == (_DWORD)result )
{
result = (unsigned int)(unsigned __int8)*(&clock_data + 2) + 1;
if ( (unsigned __int8)(*(&clock_data + 2) + 1) > 0x3Bu )
{
*(&clock_data + 2) = 0;
++*(&clock_data + 1);
}
else
{
++*(&clock_data + 2);
}
if ( (unsigned __int8)*(&clock_data + 1) > 0x3Bu )
{
*(&clock_data + 1) = 0;
++clock_data;
}
if ( (unsigned __int8)clock_data > 0x16u )
{
clock_data = 0;
++*(&clock_data + 4);
}
if ( (unsigned __int8)*(&clock_data + 4) > 0x1Du )
{
*(&clock_data + 4) = 0;
++*(&clock_data + 3);
}
if ( (unsigned __int8)*(&clock_data + 3) > 0xBu )
{
*(&clock_data + 3) = 0;
++*(&clock_data + 5);
}
}
return result;
}

original_code:
static void timer_callback(regs_t *regs)
{
 task_switch(regs);
 pit_tick++;
 if(pit_tick%100 == 0)
 {
  clock_data.seconds++;
  if(clock_data.seconds >= 60)
  {
   clock_data.seconds = 0;
   clock_data.minutes++;
  }
  if(clock_data.minutes >= 60)
  {
   clock_data.minutes = 0;
   clock_data.hours++;
  }
  if(clock_data.hours >= 23)
  {
   clock_data.hours = 0;
   clock_data.day++;
  }
  if(clock_data.day >= 30)
  {
   clock_data.day = 0;
   clock_data.month++;
  }
  if(clock_data.month >= 12)
  {
   clock_data.month = 0;
   clock_data.year++;
  }
 }
}

canonical_original_code:
static void timer_callback(struct regs_t *regs)
{
 task_switch(regs);
 pit_tick++;
 if(pit_tick%100 == 0)
 {
  clock_data.seconds++;
  if(clock_data.seconds >= 60)
  {
   clock_data.seconds = 0;
   clock_data.minutes++;
  }
  if(clock_data.minutes >= 60)
  {
   clock_data.minutes = 0;
   clock_data.hours++;
  }
  if(clock_data.hours >= 23)
  {
   clock_data.hours = 0;
   clock_data.day++;
  }
  if(clock_data.day >= 30)
  {
   clock_data.day = 0;
   clock_data.month++;
  }
  if(clock_data.month >= 12)
  {
   clock_data.month = 0;
   clock_data.year++;
  }
 }
}

variable_types: struct regs_t { unsigned int edi; unsigned int ds; unsigned int which_int; unsigned int eip; } *


decompiled_code:
void __fastcall arch_sleep(int a1)
{
int i; // eax

if ( a1 )
{
for ( i = 0; i != a1; ++i )
;
}
}

canonical_decompiled_code:
void __fastcall func1(int a1)
{
int i; // eax

if ( a1 )
{
for ( i = 0; i != a1; ++i )
;
}
}

original_code:
void arch_sleep(uint32_t ms)
{
 uint32_t i;
 for(i = 0; i < ms; i++)
 {
  uint32_t end = pit_tick + (1 / 10);
  for(pit_tick;pit_tick < end;);
 }
}

canonical_original_code:
void arch_sleep(unsigned int ms)
{
 unsigned int i;
 for(i = 0; i < ms; i++)
 {
  unsigned int end = pit_tick + (1 / 10);
  for(pit_tick;pit_tick < end;);
 }
}

variable_types:
ms
unsigned int

variable_types:
i
unsigned int

variable_types:
end
unsigned int


decompiled_code:
__int64 timer_init()
{
handler_reg(0LL, timer_callback);
io_outb(67LL, 54LL);
io_outb(64LL, 155LL);
return io_outb(64LL, 46LL);
}

canonical_decompiled_code:
__int64 func2()
{
handler_reg(0LL, timer_callback);
io_outb(67LL, 54LL);
io_outb(64LL, 155LL);
return io_outb(64LL, 46LL);
}

original_code:
void timer_init()
{
 uint32_t divisor;
 uint8_t l;
 uint8_t h;
 uint32_t freq = 100;
 handler_reg(0, &timer_callback);
 divisor = 1193180 / freq;
 io_outb(0x43, 0x36);
 l = (uint8_t)(divisor & 0xFF);
 h = (uint8_t)((divisor>>8) & 0xFF );
 io_outb(0x40, l);
 io_outb(0x40, h);
}

canonical_original_code:
void timer_init()
{
 unsigned int divisor;
 unsigned char l;
 unsigned char h;
 unsigned int freq = 100;
 handler_reg(0, &timer_callback);
 divisor = 1193180 / freq;
 io_outb(0x43, 0x36);
 l = (unsigned char)(divisor & 0xFF);
 h = (unsigned char)((divisor>>8) & 0xFF );
 io_outb(0x40, l);
 io_outb(0x40, h);
}

variable_types:
divisor
unsigned int

variable_types:
l
unsigned char

variable_types:
h
unsigned char

variable_types:
freq
unsigned int


decompiled_code:
__int64 arch_get_tick()
{
return (unsigned int)pit_tick;
}

canonical_decompiled_code:
__int64 func3()
{
return (unsigned int)pit_tick;
}

original_code:
uint32_t arch_get_tick()
{
 return pit_tick;
}

canonical_original_code:
unsigned int arch_get_tick()
{
 return pit_tick;
}


decompiled_code:
__int64 __fastcall fs_get_mount_point(char *s2, char *dest)
{
char *v2; // rbx
unsigned int v3; // er14
unsigned int v4; // eax

v2 = fs_mountpoints;
v3 = 0;
do
{
v4 = strlen(v2);
if ( !strncmp(v2, s2, v4) && v2[1560] == 1 )
{
strcpy(dest, v2);
v3 = strlen(dest);
}
v2 += 1568;
}
while ( v2 != (char *)(unsigned int)((_DWORD)fs_mountpoints + 25088) );
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func0(char *s2, char *dest)
{
char *v2; // rbx
unsigned int v3; // er14
unsigned int v4; // eax

v2 = fs_mountpoints;
v3 = 0;
do
{
v4 = strlen(v2);
if ( !strncmp(v2, s2, v4) && v2[1560] == 1 )
{
strcpy(dest, v2);
v3 = strlen(dest);
}
v2 += 1568;
}
while ( v2 != (char *)(unsigned int)((_DWORD)fs_mountpoints + 25088) );
return v3;
}

original_code:
uint32_t fs_get_mount_point(char *path, char *mpstr)
{
 unsigned i;
 unsigned t = 0;
 for(i = 0; i < 16; i++)
 {
  if((strncmp(fs_mountpoints[i].path, path, strlen(fs_mountpoints[i].path)) == 0) && (fs_mountpoints[i].used == 1))
  {
   strcpy(mpstr, fs_mountpoints[i].path);
   t = strlen(mpstr);
  }
 }
 return t;
}

canonical_original_code:
unsigned int fs_get_mount_point(char *path, char *mpstr)
{
 unsigned int i;
 unsigned int t = 0;
 for(i = 0; i < 16; i++)
 {
  if((strncmp(fs_mountpoints[i].path, path, strlen(fs_mountpoints[i].path)) == 0) && (fs_mountpoints[i].used == 1))
  {
   strcpy(mpstr, fs_mountpoints[i].path);
   t = strlen(mpstr);
  }
 }
 return t;
}

variable_types:
path
char *

variable_types:
mpstr
char *

variable_types:
t
unsigned int


decompiled_code:
size_t __fastcall fs_get_mount_point_fs(char *s2, char *dest)
{
const char *v2; // rbp
int v3; // ebx
const char *v5; // rbx

v2 = fs_mountpoints;
v3 = 0;
while ( strcmp(v2, s2) )
{
++v3;
v2 += 1568;
if ( v3 == 16 )
return 0LL;
}
v5 = &fs_mountpoints[1568 * v3 + 1024];
strcpy(dest, v5);
return strlen(v5);
}

canonical_decompiled_code:
size_t __fastcall func1(char *s2, char *dest)
{
const char *v2; // rbp
int v3; // ebx
const char *v5; // rbx

v2 = fs_mountpoints;
v3 = 0;
while ( strcmp(v2, s2) )
{
++v3;
v2 += 1568;
if ( v3 == 16 )
return 0LL;
}
v5 = &fs_mountpoints[1568 * v3 + 1024];
strcpy(dest, v5);
return strlen(v5);
}

original_code:
uint32_t fs_get_mount_point_fs(char *path, char *mpstr)
{
 unsigned i;
 for(i = 0; i < 16; i++)
 {
  if(strcmp(fs_mountpoints[i].path, path) == 0)
  {
   strcpy(mpstr, fs_mountpoints[i].fs);
   return strlen(fs_mountpoints[i].fs);
  }
 }
 return 0;
}

canonical_original_code:
unsigned int fs_get_mount_point_fs(char *path, char *mpstr)
{
 unsigned int i;
 for(i = 0; i < 16; i++)
 {
  if(strcmp(fs_mountpoints[i].path, path) == 0)
  {
   strcpy(mpstr, fs_mountpoints[i].fs);
   return strlen(fs_mountpoints[i].fs);
  }
 }
 return 0;
}


decompiled_code:
__int64 __fastcall fs_iget_mount_point(unsigned int a1, _QWORD *a2)
{
__int64 result; // rax
__int64 v3; // rdx

*a2 = 0LL;
result = 1LL;
if ( a1 <= 0xF )
{
v3 = 1568LL * a1;
if ( *(_QWORD *)&fs_mountpoints[v3 + 1544] )
{
*a2 = &fs_mountpoints[v3];
result = 0LL;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(unsigned int a1, _QWORD *a2)
{
__int64 result; // rax
__int64 v3; // rdx

*a2 = 0LL;
result = 1LL;
if ( a1 <= 0xF )
{
v3 = 1568LL * a1;
if ( *(_QWORD *)&fs_mountpoints[v3 + 1544] )
{
*a2 = &fs_mountpoints[v3];
result = 0LL;
}
}
return result;
}

original_code:
uint32_t fs_iget_mount_point(uint32_t x, mount_point_t **fs)
{
 *fs = 0;
 if((x < 16) && (fs_mountpoints[x].root != 0))
 {
  *fs = &fs_mountpoints[x];
  return 0;
 }
 return 1;
}

canonical_original_code:
unsigned int fs_iget_mount_point(unsigned int x, struct mount_point_p **fs)
{
 *fs = 0;
 if((x < 16) && (fs_mountpoints[x].root != 0))
 {
  *fs = &fs_mountpoints[x];
  return 0;
 }
 return 1;
}

variable_types:
x
unsigned int

variable_types: struct mount_point_p { char path[512]; char dev[512]; char fs[512]; void *fs_struct; struct inode_p { char name[255]; unsigned int inode_n; unsigned char type; unsigned char ow; void *fs_node; void *fs_driver; struct inode_p *link; struct inode_p *next; struct inode_p *prev; struct inode_p *parent; struct inode_p *childs; } *root; struct inode_p *childs; unsigned char used; } **

user_defined_types: struct mount_point_p { char path[512]; char dev[512]; char fs[512]; void *fs_struct; struct inode_p *root; struct inode_p *childs; unsigned char used; }


decompiled_code:
const char *__fastcall fs_get_mount_point_struct(char *a1)
{
const char *v1; // rbx
const char *v2; // rbp
char v4[152]; // [rsp+0h] [rbp-98h] BYREF

fs_get_mount_point(a1, v4);
v1 = fs_mountpoints;
do
{
v2 = v1;
if ( !strcmp(v1, v4) )
break;
v1 += 1568;
}
while ( v1 != (const char *)(unsigned int)((_DWORD)fs_mountpoints + 25088) );
return v2;
}

canonical_decompiled_code:
const char *__fastcall func3(char *a1)
{
const char *v1; // rbx
const char *v2; // rbp
char v4[152]; // [rsp+0h] [rbp-98h] BYREF

func0(a1, v4);
v1 = fs_mountpoints;
do
{
v2 = v1;
if ( !strcmp(v1, v4) )
break;
v1 += 1568;
}
while ( v1 != (const char *)(unsigned int)((_DWORD)fs_mountpoints + 25088) );
return v2;
}

original_code:
mount_point_t *fs_get_mount_point_struct(char *path)
{
 uint32_t i;
 char mpname[128];
 fs_get_mount_point(path, mpname);
 for(i = 0; i < 16; i++)
 {
  if(strcmp(fs_mountpoints[i].path, mpname) == 0)
   return &fs_mountpoints[i];
 }
}

canonical_original_code:
struct mount_point_p *fs_get_mount_point_struct(char *path)
{
 unsigned int i;
 char mpname[128];
 fs_get_mount_point(path, mpname);
 for(i = 0; i < 16; i++)
 {
  if(strcmp(fs_mountpoints[i].path, mpname) == 0)
   return &fs_mountpoints[i];
 }
}

variable_types:
mpname
char [128]

return_type: struct mount_point_p { char path[512]; char dev[512]; char fs[512]; void *fs_struct; struct inode_p { char name[255]; unsigned int inode_n; unsigned char type; unsigned char ow; void *fs_node; void *fs_driver; struct inode_p *link; struct inode_p *next; struct inode_p *prev; struct inode_p *parent; struct inode_p *childs; } *root; struct inode_p *childs; unsigned char used; } *


decompiled_code:
__int64 __fastcall fs_mount(char *src, char *s1, char *a3)
{
char *v4; // rbp
const char *v5; // rbx
unsigned int v6; // ebp
unsigned __int64 v7; // rdx
unsigned int v8; // eax
__int64 v9; // rbx
char *v10; // rbx
__int64 v12[8]; // [rsp+8h] [rbp-40h] BYREF

debug_puts("fs_mount()\n");
v4 = driver_list;
v5 = fs_mountpoints;
do
{
if ( !strcmp(s1, v5) )
return 6;
v5 += 1568;
}
while ( v5 != (const char *)(unsigned int)((_DWORD)fs_mountpoints + 25088) );
if ( !v4 )
return 4;
while ( strcmp(a3, v4) )
{
v4 = (char *)*((_QWORD *)v4 + 64);
if ( !v4 )
return 4;
}
v4[288] = 5;
if ( v4[416] == 1 && (!*src || *src == 45) )
return 3;
fs_get_node(s1, v12);
if ( !v12[0] )
return 2;
v6 = (*((__int64 (__fastcall **)(_QWORD, _QWORD))v4 + 37))(0LL, 0LL);
if ( v6 != 1 )
return 5;
v7 = (unsigned int)((_DWORD)fs_mountpoints + 1560);
v8 = 0;
while ( *(_BYTE *)v7 )
{
++v8;
v7 += 1568LL;
if ( v8 == 16 )
return 5;
}
v9 = 1568LL * v8;
fs_mountpoints[v9 + 1560] = 1;
*(_QWORD *)&fs_mountpoints[v9 + 1544] = v12[0];
strcpy(&fs_mountpoints[v9], s1);
strcat(&fs_mountpoints[v9], ::src);
strcpy(&fs_mountpoints[v9 + 512], src);
strcat(&fs_mountpoints[v9 + 512], ::src);
v10 = &fs_mountpoints[v9 + 1024];
strcpy(v10, a3);
strcat(v10, ::src);
return v6;
}

canonical_decompiled_code:
__int64 __fastcall func4(char *src, char *s1, char *a3)
{
char *v4; // rbp
const char *v5; // rbx
unsigned int v6; // ebp
unsigned __int64 v7; // rdx
unsigned int v8; // eax
__int64 v9; // rbx
char *v10; // rbx
__int64 v12[8]; // [rsp+8h] [rbp-40h] BYREF

debug_puts("fs_mount()\n");
v4 = driver_list;
v5 = fs_mountpoints;
do
{
if ( !strcmp(s1, v5) )
return 6;
v5 += 1568;
}
while ( v5 != (const char *)(unsigned int)((_DWORD)fs_mountpoints + 25088) );
if ( !v4 )
return 4;
while ( strcmp(a3, v4) )
{
v4 = (char *)*((_QWORD *)v4 + 64);
if ( !v4 )
return 4;
}
v4[288] = 5;
if ( v4[416] == 1 && (!*src || *src == 45) )
return 3;
fs_get_node(s1, v12);
if ( !v12[0] )
return 2;
v6 = (*((__int64 (__fastcall **)(_QWORD, _QWORD))v4 + 37))(0LL, 0LL);
if ( v6 != 1 )
return 5;
v7 = (unsigned int)((_DWORD)fs_mountpoints + 1560);
v8 = 0;
while ( *(_BYTE *)v7 )
{
++v8;
v7 += 1568LL;
if ( v8 == 16 )
return 5;
}
v9 = 1568LL * v8;
fs_mountpoints[v9 + 1560] = 1;
*(_QWORD *)&fs_mountpoints[v9 + 1544] = v12[0];
strcpy(&fs_mountpoints[v9], s1);
strcat(&fs_mountpoints[v9], ::src);
strcpy(&fs_mountpoints[v9 + 512], src);
strcat(&fs_mountpoints[v9 + 512], ::src);
v10 = &fs_mountpoints[v9 + 1024];
strcpy(v10, a3);
strcat(v10, ::src);
return v6;
}

original_code:
uint32_t fs_mount(char *device, char *path, char *fs, uint32_t flags)
{
 debug_puts("fs_mount()\n");
 driver_t *cf = driver_list;
 inode_t *node;
 unsigned i;
 for(i = 0; i < 16; i++)
 {
  if((strcmp(path, fs_mountpoints[i].path) == 0))
   return 6;
 }
 while(cf != 0)
 {
  if((strcmp(fs, cf->name) == 0) && (cf->type = 5))
   break;
  cf = cf->next;
 }
 if(cf != 0)
 {
  if((cf->fs).ifdev == 1 && (device[0] == '\0' || device[0] == '-'))
   return 3;
  fs_get_node(path, &node);
  if(node == 0)
   return 2;
  if((cf->fs).mount(0, 0, node) != 1)
   return 5;
  mount_point_t *mp = 0;
  for(i = 0; i < 16; i++)
  {
   if(fs_mountpoints[i].used == 0)
   {
    mp = &fs_mountpoints[i];
    break;
   }
  }
  if(mp == 0)
   return 5;
  mp->used = 1;
  mp->root = node;
  strcpy(mp->path, path);
  strcat(mp->path, "\0");
  strcpy(mp->dev, device);
  strcat(mp->dev, "\0");
  strcpy(mp->fs, fs);
  strcat(mp->fs, "\0");
  return 1;
 }
 return 4;
}

canonical_original_code:
unsigned int fs_mount(char *device, char *path, char *fs, unsigned int flags)
{
 debug_puts("fs_mount()\n");
 struct driver_p *cf = driver_list;
 struct inode_p *node;
 unsigned int i;
 for(i = 0; i < 16; i++)
 {
  if((strcmp(path, fs_mountpoints[i].path) == 0))
   return 6;
 }
 while(cf != 0)
 {
  if((strcmp(fs, cf->name) == 0) && (cf->type = 5))
   break;
  cf = cf->next;
 }
 if(cf != 0)
 {
  if((cf->fs).ifdev == 1 && (device[0] == '\0' || device[0] == '-'))
   return 3;
  fs_get_node(path, &node);
  if(node == 0)
   return 2;
  if((cf->fs).mount(0, 0, node) != 1)
   return 5;
  struct mount_point_p *mp = 0;
  for(i = 0; i < 16; i++)
  {
   if(fs_mountpoints[i].used == 0)
   {
    mp = &fs_mountpoints[i];
    break;
   }
  }
  if(mp == 0)
   return 5;
  mp->used = 1;
  mp->root = node;
  strcpy(mp->path, path);
  strcat(mp->path, "\0");
  strcpy(mp->dev, device);
  strcat(mp->dev, "\0");
  strcpy(mp->fs, fs);
  strcat(mp->fs, "\0");
  return 1;
 }
 return 4;
}

variable_types:
device
char *

variable_types:
fs
char *

variable_types:
flags
unsigned int

variable_types: struct driver_p { char name[32]; char desc[128]; char author[128]; unsigned char type; struct driver_fs_t { unsigned int (*mount)(char *, unsigned int, struct inode_p { char name[255]; unsigned int inode_n; unsigned char type; unsigned char ow; void *fs_node; void *fs_driver; struct inode_p *link; struct inode_p *next; struct inode_p *prev; struct inode_p *parent; struct inode_p *childs; } *); unsigned int (*umount)(struct inode_p *); unsigned int (*mkdir)(struct inode_p *, char *); unsigned int (*readdir)(struct inode_p *, unsigned int, struct dirent { char name[255]; unsigned int inode; } *); unsigned int (*get_node)(struct inode_p *, unsigned int, struct inode_p **); unsigned int (*delete_node)(struct inode_p *, char *); unsigned int (*create_node)(struct inode_p *, char *, unsigned int); unsigned int (*write_stat)(struct inode_p *, struct stat { unsigned int st_dev; unsigned int st_ino; int st_uid; int st_gid; unsigned long long st_blksize; unsigned long long st_blocks; } *, unsigned int); unsigned int (*read_stat)(struct inode_p *, struct stat *); unsigned int (*open)(struct inode_p *, char *); unsigned int (*close)(struct inode_p *); unsigned int (*read)(struct inode_p *, char *, unsigned int, unsigned long long); unsigned int (*write)(struct inode_p *, char *, unsigned int, unsigned long long); unsigned int (*link)(struct inode_p *, char *, struct inode_p *, char *); unsigned int (*unlink)(struct inode_p *, char *); unsigned char ifdev; } fs; struct driver_video_t { char *buffer; void (*put_pixel)(unsigned int, unsigned int, unsigned int); unsigned int (*get_pixel)(unsigned int, unsigned int); unsigned int (*set_mode)(unsigned int, unsigned int, unsigned int); } video; unsigned char loaded; unsigned int (*init)(); unsigned int (*free)(); unsigned int (*probe)(struct device_p { unsigned int io_base; char vendor[32]; char vendor_full[32]; char device[32]; char device_desc[32]; char class[32]; char class_desc[32]; char class_prog_desc[32]; unsigned char bus_type; void *pci_dev; unsigned char interrupt; unsigned int base_addresses[6]; char file[32]; struct device_p *next; } *); unsigned int (*read)(struct device_p *, char *, unsigned int, unsigned long long); unsigned int (*write)(struct device_p *, char *, unsigned int, unsigned long long); unsigned int (*ioctl)(struct device_p *, unsigned int, unsigned int, unsigned int); struct driver_p *next; } *

variable_types: struct mount_point_p { char path[512]; char dev[512]; char fs[512]; void *fs_struct; struct inode_p { char name[255]; unsigned int inode_n; unsigned char type; unsigned char ow; void *fs_node; void *fs_driver; struct inode_p *link; struct inode_p *next; struct inode_p *prev; struct inode_p *parent; struct inode_p *childs; } *root; struct inode_p *childs; unsigned char used; } *


decompiled_code:
__int64 fs_umount()
{
debug_puts("fs_umount()\n");
return 2LL;
}

canonical_decompiled_code:
__int64 func5()
{
debug_puts("fs_umount()\n");
return 2LL;
}

original_code:
uint32_t fs_umount(char *path)
{
 debug_puts("fs_umount()\n");
 return 2;
}

canonical_original_code:
unsigned int fs_umount(char *path)
{
 debug_puts("fs_umount()\n");
 return 2;
}


decompiled_code:
void ppp_up()
{
;
}

canonical_decompiled_code:
void func0()
{
;
}

original_code:
uint32_t ppp_up(network_iface_t *iface)
{
}

canonical_original_code:
unsigned int ppp_up(struct network_iface_p *iface)
{
}

variable_types: struct network_iface_p { char name[32]; char addr[4]; char mask[4]; char bcast[4]; char mac[6]; unsigned char if_up; unsigned char if_mac; unsigned char if_bcast; unsigned char type; unsigned int tx_bytes; unsigned int rx_bytes; struct driver_p { char name[32]; char desc[128]; char author[128]; unsigned char type; struct driver_fs_t { unsigned int (*mount)(char *, unsigned int, struct inode_p { char name[255]; unsigned int inode_n; unsigned char type; unsigned char ow; void *fs_node; void *fs_driver; struct inode_p *link; struct inode_p *next; struct inode_p *prev; struct inode_p *parent; struct inode_p *childs; } *); unsigned int (*umount)(struct inode_p *); unsigned int (*mkdir)(struct inode_p *, char *); unsigned int (*readdir)(struct inode_p *, unsigned int, struct dirent { char name[255]; unsigned int inode; } *); unsigned int (*get_node)(struct inode_p *, unsigned int, struct inode_p **); unsigned int (*delete_node)(struct inode_p *, char *); unsigned int (*create_node)(struct inode_p *, char *, unsigned int); unsigned int (*write_stat)(struct inode_p *, struct stat { unsigned int st_dev; unsigned int st_ino; int st_uid; int st_gid; unsigned long long st_blksize; unsigned long long st_blocks; } *, unsigned int); unsigned int (*read_stat)(struct inode_p *, struct stat *); unsigned int (*open)(struct inode_p *, char *); unsigned int (*close)(struct inode_p *); unsigned int (*read)(struct inode_p *, char *, unsigned int, unsigned long long); unsigned int (*write)(struct inode_p *, char *, unsigned int, unsigned long long); unsigned int (*link)(struct inode_p *, char *, struct inode_p *, char *); unsigned int (*unlink)(struct inode_p *, char *); unsigned char ifdev; } fs; struct driver_video_t { char *buffer; void (*put_pixel)(unsigned int, unsigned int, unsigned int); unsigned int (*get_pixel)(unsigned int, unsigned int); unsigned int (*set_mode)(unsigned int, unsigned int, unsigned int); } video; unsigned char loaded; unsigned int (*init)(); unsigned int (*free)(); unsigned int (*probe)(struct device_p { unsigned int io_base; char vendor[32]; char vendor_full[32]; char device[32]; char device_desc[32]; char class[32]; char class_desc[32]; char class_prog_desc[32]; unsigned char bus_type; void *pci_dev; unsigned char interrupt; unsigned int base_addresses[6]; char file[32]; struct device_p *next; } *); unsigned int (*read)(struct device_p *, char *, unsigned int, unsigned long long); unsigned int (*write)(struct device_p *, char *, unsigned int, unsigned long long); unsigned int (*ioctl)(struct device_p *, unsigned int, unsigned int, unsigned int); struct driver_p *next; } *drv; struct device_p *dev; void *link_protocol; struct network_iface_p *next; } *


decompiled_code:
void ppp_down()
{
;
}

canonical_decompiled_code:
void func1()
{
;
}

original_code:
uint32_t ppp_down(network_iface_t *iface)
{
}

canonical_original_code:
unsigned int ppp_down(struct network_iface_p *iface)
{
}


decompiled_code:
__int64 __fastcall ppp_handle_frame(__int64 a1, unsigned int *a2)
{
unsigned __int16 v2; // r12

v2 = *(_WORD *)(*((_QWORD *)a2 + 1) + 4LL);
packet_del_header(a2, 6LL);
if ( (unsigned int)video_getx() )
printf("\n");
printf("ppp: received packet (sizeof %d) of protocol %x\n", *a2, v2);
if ( v2 == 33 )
ip_handle_packet(a1, a2);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, unsigned int *a2)
{
unsigned __int16 v2; // r12

v2 = *(_WORD *)(*((_QWORD *)a2 + 1) + 4LL);
packet_del_header(a2, 6LL);
if ( (unsigned int)video_getx() )
printf("\n");
printf("ppp: received packet (sizeof %d) of protocol %x\n", *a2, v2);
if ( v2 == 33 )
ip_handle_packet(a1, a2);
return 0LL;
}

original_code:
uint32_t ppp_handle_frame(network_iface_t *iface, packet_t *p)
{
 uint16_t protocol;
 ppp_header_t *ppphead = (ppp_header_t *) p->data;
 protocol = ppphead->protocol;
 packet_del_header(p, sizeof(ppp_header_t));
 if(video_getx() != 0)
  printf("\n");
 printf("ppp: received packet (sizeof %d) of protocol %x\n", p->size, protocol);
 switch(protocol)
 {
  case 0x0021:
   ip_handle_packet(iface, p);
   break;
 }
 return 0;
}

canonical_original_code:
unsigned int ppp_handle_frame(struct network_iface_p *iface, struct packet_t *p)
{
 unsigned short protocol;
 struct ppp_header_t *ppphead = (ppp_header_t *) p->data;
 protocol = ppphead->protocol;
 packet_del_header(p, sizeof(ppp_header_t));
 if(video_getx() != 0)
  printf("\n");
 printf("ppp: received packet (sizeof %d) of protocol %x\n", p->size, protocol);
 switch(protocol)
 {
  case 0x0021:
   ip_handle_packet(iface, p);
   break;
 }
 return 0;
}

variable_types: struct packet_t { unsigned int size; char *data; } *

variable_types:
protocol
unsigned short

variable_types: struct ppp_header_t { unsigned char flag; unsigned char address; unsigned char control; unsigned short protocol; } *


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

packet_add_header(a2, 6LL);
v2 = *((_QWORD *)a2 + 1);
*(_BYTE *)v2 = 126;
*(_BYTE *)(v2 + 1) = -1;
*(_BYTE *)(v2 + 2) = 3;
*(_WORD *)(v2 + 4) = 33;
v3 = *(__int64 (__fastcall **)(_QWORD, _QWORD, _QWORD, _QWORD))(*(_QWORD *)(a1 + 64) + 496LL);
if ( !v3 )
return 0LL;
result = v3(*(_QWORD *)(a1 + 72), *((_QWORD *)a2 + 1), *a2, 0LL);
*(_DWORD *)(a1 + 56) += result;
return result;
}

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

packet_add_header(a2, 6LL);
v2 = *((_QWORD *)a2 + 1);
*(_BYTE *)v2 = 126;
*(_BYTE *)(v2 + 1) = -1;
*(_BYTE *)(v2 + 2) = 3;
*(_WORD *)(v2 + 4) = 33;
v3 = *(__int64 (__fastcall **)(_QWORD, _QWORD, _QWORD, _QWORD))(*(_QWORD *)(a1 + 64) + 496LL);
if ( !v3 )
return 0LL;
result = v3(*(_QWORD *)(a1 + 72), *((_QWORD *)a2 + 1), *a2, 0LL);
*(_DWORD *)(a1 + 56) += result;
return result;
}

original_code:
uint32_t ppp_send_frame(network_iface_t *iface, packet_t *p)
{
 packet_add_header(p, sizeof(ppp_header_t));
 ppp_header_t *ppphead = (ppp_header_t *) p->data;
 ppphead->flag = 0x7E;
 ppphead->address = 0xFF;
 ppphead->control = 0x03;
 ppphead->protocol = 0x0021;
 uint32_t sended_b;
 if((iface->drv)->write != 0)
  sended_b = (iface->drv)->write(iface->dev, p->data, p->size, 0);
 else
  return 0;
 iface->tx_bytes = iface->tx_bytes + sended_b;
 return sended_b;
}

canonical_original_code:
unsigned int ppp_send_frame(struct network_iface_p *iface, struct packet_t *p)
{
 packet_add_header(p, sizeof(ppp_header_t));
 struct ppp_header_t *ppphead = (ppp_header_t *) p->data;
 ppphead->flag = 0x7E;
 ppphead->address = 0xFF;
 ppphead->control = 0x03;
 ppphead->protocol = 0x0021;
 unsigned int sended_b;
 if((iface->drv)->write != 0)
  sended_b = (iface->drv)->write(iface->dev, p->data, p->size, 0);
 else
  return 0;
 iface->tx_bytes = iface->tx_bytes + sended_b;
 return sended_b;
}

user_defined_types: struct packet_t { unsigned int size; char *data; }

user_defined_types: struct ppp_header_t { unsigned char flag; unsigned char address; unsigned char control; unsigned short protocol; }


decompiled_code:
__int64 __fastcall load_raw_bitmap(__int64 a1, __int64 a2, int a3, int a4)
{
__int64 v6; // rbp
__int64 result; // rax

v6 = fs_open(a1, &unk_1DCF18);
result = 0LL;
if ( v6 )
{
fs_read(v6, a2, (unsigned int)(4 * a4 * a3));
fs_close(v6);
result = 1LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 a2, int a3, int a4)
{
__int64 v6; // rbp
__int64 result; // rax

v6 = fs_open(a1, &unk_1DCF18);
result = 0LL;
if ( v6 )
{
fs_read(v6, a2, (unsigned int)(4 * a4 * a3));
fs_close(v6);
result = 1LL;
}
return result;
}

original_code:
uint32_t load_raw_bitmap(char *path, char *data, uint32_t x, uint32_t y)
{
 file_t *f = fs_open(path, "r");
 char *pixel_data = data;
 if(f != 0)
  fs_read(f, pixel_data, x * y * 4);
 else
  return 0;
 fs_close(f);
 return 1;
}

canonical_original_code:
unsigned int load_raw_bitmap(char *path, char *data, unsigned int x, unsigned int y)
{
 struct file_p *f = fs_open(path, "r");
 char *pixel_data = data;
 if(f != 0)
  fs_read(f, pixel_data, x * y * 4);
 else
  return 0;
 fs_close(f);
 return 1;
}

variable_types:
data
char *

variable_types:
y
unsigned int

variable_types: struct file_p { unsigned int id; unsigned long long seek_p; unsigned long long size; struct inode_p { char name[255]; unsigned int inode_n; unsigned char type; unsigned char ow; void *fs_node; void *fs_driver; struct inode_p *link; struct inode_p *next; struct inode_p *prev; struct inode_p *parent; struct inode_p *childs; } *node; void *drv; struct file_p *next; } *

user_defined_types: struct file_p { unsigned int id; unsigned long long seek_p; unsigned long long size; struct inode_p *node; void *drv; struct file_p *next; }


decompiled_code:
__int64 __fastcall render_get_pixel(unsigned int a1, unsigned int a2)
{
__int64 result; // rax
int v3; // ebx
__int64 v4; // rcx

result = *(unsigned __int16 *)(vesa_get_mode_info() + 18);
if ( (unsigned int)result >= a1 )
{
result = *(unsigned __int16 *)(vesa_get_mode_info() + 20);
if ( (unsigned int)result >= a2 )
{
v3 = (*(_BYTE *)(vesa_get_mode_info() + 25) >> 3) * a1;
v4 = a2 * *(unsigned __int16 *)(vesa_get_mode_info() + 16) + v3;
result = (unsigned int)((render_buffer[v4 + 1] << 8) + render_buffer[v4] + (render_buffer[v4 + 2] << 16));
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(unsigned int a1, unsigned int a2)
{
__int64 result; // rax
int v3; // ebx
__int64 v4; // rcx

result = *(unsigned __int16 *)(vesa_get_mode_info() + 18);
if ( (unsigned int)result >= a1 )
{
result = *(unsigned __int16 *)(vesa_get_mode_info() + 20);
if ( (unsigned int)result >= a2 )
{
v3 = (*(_BYTE *)(vesa_get_mode_info() + 25) >> 3) * a1;
v4 = a2 * *(unsigned __int16 *)(vesa_get_mode_info() + 16) + v3;
result = (unsigned int)((render_buffer[v4 + 1] << 8) + render_buffer[v4] + (render_buffer[v4 + 2] << 16));
}
}
return result;
}

original_code:
uint32_t render_get_pixel(uint32_t x, uint32_t y)
{
 if (x<0 || x > vesa_get_mode_info()->width || y<0 || y>vesa_get_mode_info()->height) return;
 x = (x*(vesa_get_mode_info()->bits_per_pixel>>3));
 y = (y*vesa_get_mode_info()->bytes_per_scan_line);
 register char * cTemp;
 cTemp = &render_buffer[x+y];
 return (cTemp[0] + (cTemp[1]<<8) + (cTemp[2]<<16));
}

canonical_original_code:
unsigned int render_get_pixel(unsigned int x, unsigned int y)
{
 if (x<0 || x > vesa_get_mode_info()->width || y<0 || y>vesa_get_mode_info()->height) return;
 x = (x*(vesa_get_mode_info()->bits_per_pixel>>3));
 y = (y*vesa_get_mode_info()->bytes_per_scan_line);
 register char *cTemp;
 cTemp = &render_buffer[x+y];
 return (cTemp[0] + (cTemp[1]<<8) + (cTemp[2]<<16));
}

variable_types:
cTemp
char *


decompiled_code:
__int64 __fastcall render_draw_pixel(unsigned int a1, unsigned int a2, int a3)
{
__int64 result; // rax
int v5; // ebx

result = *(unsigned __int16 *)(vesa_get_mode_info() + 18);
if ( (unsigned int)result >= a1 )
{
result = *(unsigned __int16 *)(vesa_get_mode_info() + 20);
if ( (unsigned int)result >= a2 )
{
v5 = (*(_BYTE *)(vesa_get_mode_info() + 25) >> 3) * a1;
result = a2 * *(unsigned __int16 *)(vesa_get_mode_info() + 16) + v5;
*(_WORD *)&render_buffer[result] = a3;
render_buffer[result + 2] = BYTE2(a3);
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(unsigned int a1, unsigned int a2, int a3)
{
__int64 result; // rax
int v5; // ebx

result = *(unsigned __int16 *)(vesa_get_mode_info() + 18);
if ( (unsigned int)result >= a1 )
{
result = *(unsigned __int16 *)(vesa_get_mode_info() + 20);
if ( (unsigned int)result >= a2 )
{
v5 = (*(_BYTE *)(vesa_get_mode_info() + 25) >> 3) * a1;
result = a2 * *(unsigned __int16 *)(vesa_get_mode_info() + 16) + v5;
*(_WORD *)&render_buffer[result] = a3;
render_buffer[result + 2] = BYTE2(a3);
}
}
return result;
}

original_code:
void render_draw_pixel(uint32_t x, uint32_t y, uint32_t cl)
{
 if (x<0 || x > vesa_get_mode_info()->width || y<0 || y>vesa_get_mode_info()->height) return;
 x = (x*(vesa_get_mode_info()->bits_per_pixel>>3));
 y = (y*vesa_get_mode_info()->bytes_per_scan_line);
 register char * cTemp;
 cTemp = &render_buffer[x+y];
 cTemp[0] = cl & 0xff;
 cTemp[1] = (cl>>8) & 0xff;
 cTemp[2] = (cl>>16) & 0xff;
}

canonical_original_code:
void render_draw_pixel(unsigned int x, unsigned int y, unsigned int cl)
{
 if (x<0 || x > vesa_get_mode_info()->width || y<0 || y>vesa_get_mode_info()->height) return;
 x = (x*(vesa_get_mode_info()->bits_per_pixel>>3));
 y = (y*vesa_get_mode_info()->bytes_per_scan_line);
 register char *cTemp;
 cTemp = &render_buffer[x+y];
 cTemp[0] = cl & 0xff;
 cTemp[1] = (cl>>8) & 0xff;
 cTemp[2] = (cl>>16) & 0xff;
}

variable_types:
cl
unsigned int