generateXORTexture

decompiled_code:
__int64 generateXORTexture()
{
__int64 v0; // r8
__int64 v1; // rcx
__int64 v2; // rdx
int i; // eax
char v5[196616]; // [rsp+0h] [rbp-30008h] BYREF

LODWORD(v0) = 0;
LODWORD(v1) = 0;
do
{
LODWORD(v2) = v0;
for ( i = 0; i != 257; ++i )
{
v5[(unsigned int)v2] = i ^ v1;
v5[(unsigned int)(v2 + 1)] = i & v1;
v5[(unsigned int)(v2 + 2)] = i;
v2 = (unsigned int)(v2 + 3);
}
v1 = (unsigned int)(v1 + 1);
v0 = (unsigned int)(v0 + 768);
}
while ( (_DWORD)v1 != 256 );
glGenTextures(1LL, &xor_texture, v2, v1, v0);
glBindTexture(3553LL, (unsigned int)xor_texture);
return glTexImage2D(3553LL, 0LL, 3LL, 256LL, 256LL, 0LL, 6407LL, 5121LL, v5);
}

canonical_decompiled_code:
__int64 func6()
{
__int64 v0; // r8
__int64 v1; // rcx
__int64 v2; // rdx
int i; // eax
char v5[196616]; // [rsp+0h] [rbp-30008h] BYREF

LODWORD(v0) = 0;
LODWORD(v1) = 0;
do
{
LODWORD(v2) = v0;
for ( i = 0; i != 257; ++i )
{
v5[(unsigned int)v2] = i ^ v1;
v5[(unsigned int)(v2 + 1)] = i & v1;
v5[(unsigned int)(v2 + 2)] = i;
v2 = (unsigned int)(v2 + 3);
}
v1 = (unsigned int)(v1 + 1);
v0 = (unsigned int)(v0 + 768);
}
while ( (_DWORD)v1 != 256 );
glGenTextures(1LL, &xor_texture, v2, v1, v0);
glBindTexture(3553LL, (unsigned int)xor_texture);
return glTexImage2D(3553LL, 0LL, 3LL, 256LL, 256LL, 0LL, 6407LL, 5121LL, v5);
}

original_code:
void generateXORTexture()
{
  uint8_t pixels[256*256*3];
  unsigned int x,y;
  for(y=0;y<256;y++)
    {
      for(x=0;x<=256;x++)
 {
   pixels[x*3+256*y*3+0] = (uint8_t)(x^y);
   pixels[x*3+256*y*3+1] = (uint8_t)(x & y);
   pixels[x*3+256*y*3+2] = (uint8_t)x;
 }
    }
  glGenTextures(1, &xor_texture);
  glBindTexture(0x0DE1, xor_texture);
  glTexImage2D(0x0DE1, 0, 3, 256, 256, 0, 0x1907, 0x1401, pixels);
}

canonical_original_code:
void generateXORTexture()
{
  unsigned char pixels[-1];
  unsigned int x; unsigned int y;
  for(y=0;y<256;y++)
    {
      for(x=0;x<=256;x++)
 {
   pixels[x*3+256*y*3+0] = (unsigned char)(x^y);
   pixels[x*3+256*y*3+1] = (unsigned char)(x & y);
   pixels[x*3+256*y*3+2] = (unsigned char)x;
 }
    }
  glGenTextures(1, &xor_texture);
  glBindTexture(0x0DE1, xor_texture);
  glTexImage2D(0x0DE1, 0, 3, 256, 256, 0, 0x1907, 0x1401, pixels);
}

variable_types:
pixels
unsigned char [-1]

variable_types:
x
unsigned int

variable_types:
y
unsigned int


glxSetup

repo: Spekkio/GTK-with-GLX

decompiled_code:
__int64 glxSetup()
{
__int64 v0; // rax
__int64 v1; // rbx
__int64 v2; // rax
XFontStruct *v3; // rbx
__int64 v4; // rdx
__int64 v5; // rcx
__int64 v6; // r8
char v8[136]; // [rsp+0h] [rbp-88h] BYREF

TimeCounter = 0;
v0 = glXCreateContext(disp, vi, 0LL, 1LL);
glc = v0;
if ( !v0 )
{
puts("\n\tCannot create gl context");
exit(0);
}
v1 = v0;
v2 = gdk_x11_drawable_get_xid(*(_QWORD *)(window + 80LL));
glXMakeCurrent(disp, v2, v1);
glEnable(2929LL);
glDepthFunc(515LL);
glHint(3152LL, 4354LL);
glClearColor(0.0, 0.0, 0.40000001, 1.0);
strcpy(v8, "-monotype-*-medium-r-normal--*-*-*-*-*-*-iso8859-1");
v3 = XLoadQueryFont(disp, v8);
if ( v3 )
{
printf("found font: %s\n", v8);
glXUseXFont(v3->fid, 32LL, 192LL, 32LL);
}
glMatrixMode(5888LL);
glLoadIdentity();
glGetFloatv(2982LL, &rotation_matrix);
glGenTextures(1LL, &texture, v4, v5, v6);
glBindTexture(3553LL, (unsigned int)texture);
glTexImage2D(3553LL, 0LL, 3LL, box1, *((unsigned int *)&box1 + 2), 0LL, 6408LL, 5121LL, *((_QWORD *)&box1 + 6));
generateXORTexture();
glTexParameteri(3553LL, 10241LL, 9729LL);
glTexParameteri(3553LL, 10240LL, 9729LL);
return calcSphere();
}

canonical_decompiled_code:
__int64 func7()
{
__int64 v0; // rax
__int64 v1; // rbx
__int64 v2; // rax
XFontStruct *v3; // rbx
__int64 v4; // rdx
__int64 v5; // rcx
__int64 v6; // r8
char v8[136]; // [rsp+0h] [rbp-88h] BYREF

TimeCounter = 0;
v0 = glXCreateContext(disp, vi, 0LL, 1LL);
glc = v0;
if ( !v0 )
{
puts("\n\tCannot create gl context");
exit(0);
}
v1 = v0;
v2 = gdk_x11_drawable_get_xid(*(_QWORD *)(window + 80LL));
glXMakeCurrent(disp, v2, v1);
glEnable(2929LL);
glDepthFunc(515LL);
glHint(3152LL, 4354LL);
glClearColor(0.0, 0.0, 0.40000001, 1.0);
strcpy(v8, "-monotype-*-medium-r-normal--*-*-*-*-*-*-iso8859-1");
v3 = XLoadQueryFont(disp, v8);
if ( v3 )
{
printf("found font: %s\n", v8);
glXUseXFont(v3->fid, 32LL, 192LL, 32LL);
}
glMatrixMode(5888LL);
glLoadIdentity();
glGetFloatv(2982LL, &rotation_matrix);
glGenTextures(1LL, &texture, v4, v5, v6);
glBindTexture(3553LL, (unsigned int)texture);
glTexImage2D(3553LL, 0LL, 3LL, box1, *((unsigned int *)&box1 + 2), 0LL, 6408LL, 5121LL, *((_QWORD *)&box1 + 6));
func6();
glTexParameteri(3553LL, 10241LL, 9729LL);
glTexParameteri(3553LL, 10240LL, 9729LL);
return func2();
}

original_code:
void glxSetup()
{
  char font_string[128];
  XFontStruct *font_struct;
  TimeCounter = 0;
  glc = glXCreateContext(disp, vi, ((void *)0), 1);
  if(glc == ((void *)0))
    {
      printf("\n\tCannot create gl context\n");
      exit(0);
    }
  glXMakeCurrent(disp, (gdk_x11_drawable_get_xid (window->window)), glc);
  glEnable(0x0B71);
  glDepthFunc(0x0203);
  glHint(0x0C50, 0x1102);
  glClearColor(0.00, 0.00, 0.40, 1.00);
  sprintf(font_string, "-monotype-*-medium-r-normal--*-*-*-*-*-*-iso8859-1");
  font_struct = XLoadQueryFont(disp, font_string);
  if(font_struct != ((void *)0))
    {
      printf("found font: %s\n",font_string);
      glXUseXFont(font_struct->fid, 32, 192, 32);
    }
  glMatrixMode(0x1700);
  glLoadIdentity();
  glGetFloatv(0x0BA6, rotation_matrix);
  glGenTextures(1, &texture[0]);
  glBindTexture(0x0DE1, texture[0]);
  glTexImage2D(0x0DE1, 0, 3, box1.width, box1.height, 0, 0x1908, 0x1401, box1.glxRawTexture);
  generateXORTexture();
  glTexParameteri(0x0DE1,0x2801,0x2601);
  glTexParameteri(0x0DE1,0x2800,0x2601);
  calcSphere();
}

canonical_original_code:
void glxSetup()
{
  char font_string[128];
  struct XFontStruct *font_struct;
  TimeCounter = 0;
  glc = glXCreateContext(disp, vi, ((void *)0), 1);
  if(glc == ((void *)0))
    {
      printf("\n\tCannot create gl context\n");
      exit(0);
    }
  glXMakeCurrent(disp, (gdk_x11_drawable_get_xid (window->window)), glc);
  glEnable(0x0B71);
  glDepthFunc(0x0203);
  glHint(0x0C50, 0x1102);
  glClearColor(0.00, 0.00, 0.40, 1.00);
  sprintf(font_string, "-monotype-*-medium-r-normal--*-*-*-*-*-*-iso8859-1");
  font_struct = XLoadQueryFont(disp, font_string);
  if(font_struct != ((void *)0))
    {
      printf("found font: %s\n",font_string);
      glXUseXFont(font_struct->fid, 32, 192, 32);
    }
  glMatrixMode(0x1700);
  glLoadIdentity();
  glGetFloatv(0x0BA6, rotation_matrix);
  glGenTextures(1, &texture[0]);
  glBindTexture(0x0DE1, texture[0]);
  glTexImage2D(0x0DE1, 0, 3, box1.width, box1.height, 0, 0x1908, 0x1401, box1.glxRawTexture);
  generateXORTexture();
  glTexParameteri(0x0DE1,0x2801,0x2601);
  glTexParameteri(0x0DE1,0x2800,0x2601);
  calcSphere();
}

variable_types: struct XFontStruct { struct _XExtData { int number; struct _XExtData *next; int (*free_private)(struct _XExtData *extension); char *private_data; } *ext_data; unsigned long fid; unsigned int direction; unsigned int min_char_or_byte2; unsigned int max_char_or_byte2; unsigned int min_byte1; unsigned int max_byte1; int all_chars_exist; unsigned int default_char; int n_properties; struct XFontProp { unsigned long name; unsigned long card32; } *properties; struct XCharStruct { short lbearing; short rbearing; short width; short ascent; short descent; unsigned short attributes; } min_bounds; struct XCharStruct max_bounds; struct XCharStruct *per_char; int ascent; int descent; } *

return_type: void

user_defined_types: struct XFontStruct { struct _XExtData *ext_data; unsigned long fid; unsigned int direction; unsigned int min_char_or_byte2; unsigned int max_char_or_byte2; unsigned int min_byte1; unsigned int max_byte1; int all_chars_exist; unsigned int default_char; int n_properties; struct XFontProp *properties; struct XCharStruct min_bounds; struct XCharStruct max_bounds; struct XCharStruct *per_char; int ascent; int descent; }


decompiled_code:
__int64 __fastcall init_rc_filter(double *a1, double a2, double a3, double a4)
{
__int64 result; // rax

result = init_convolution(a1 + 2, a4);
*a1 = a2;
a1[1] = a3;
a1[3] = a2 * a3 * 4.0 * a4 / (a2 * a3 * (a2 * a3) * 4.0 - a4 * a4);
a1[4] = 4.0 / (a4 / (a2 * a3) + 2.0) - 1.0;
return result;
}

original_code:
void init_rc_filter(struct filter_rc_t * n, const double R, const double C, const double T, double * last_val, const unsigned long int size)
{
  init_convolution(&n->consts, T, last_val, size);
  n->R = R;
  n->C = C;
  n->consts.a = (4*C*R*T)/(4*(C*R)*(C*R)-T*T);
  n->consts.b = (-1 + (4)/(2+T/(C*R)));
}

canonical_original_code:
void init_rc_filter(struct filter_rc_t *n, double R, double C, double T, double *last_val, unsigned long size)
{
  init_convolution(&n->consts, T, last_val, size);
  n->R = R;
  n->C = C;
  n->consts.a = (4*C*R*T)/(4*(C*R)*(C*R)-T*T);
  n->consts.b = (-1 + (4)/(2+T/(C*R)));
}

variable_types: struct filter_rc_t { double R; struct const_t { double T; double a; double b; double *last_value; unsigned long n; } consts; } *

variable_types: R double

variable_types: C double

variable_types: T double

variable_types:
size
unsigned long

user_defined_types: struct filter_rc_t { double R; struct const_t consts; }


decompiled_code:
__int64 __fastcall init_cr_filter(double *a1, double a2, double a3, double a4)
{
__int64 result; // rax

result = init_convolution(a1 + 2, a4);
*a1 = a2;
a1[1] = a3;
a1[3] = a2 * a3 * 4.0 * a4 / (a4 * a4 - a2 * a3 * (a2 * a3) * 4.0);
a1[4] = 4.0 / (a4 / (a2 * a3) + 2.0) - 1.0;
return result;
}

original_code:
void init_cr_filter(struct filter_rc_t * n, const double R, const double C, const double T, double * last_val, const unsigned long int size)
{
  init_convolution(&n->consts, T, last_val, size);
  n->R = R;
  n->C = C;
  n->consts.a = -(4*C*R*T)/(4*(C*R)*(C*R)-T*T);
  n->consts.b = (-1 + (4)/(2+T/(C*R)));
}

canonical_original_code:
void init_cr_filter(struct filter_rc_t *n, double R, double C, double T, double *last_val, unsigned long size)
{
  init_convolution(&n->consts, T, last_val, size);
  n->R = R;
  n->C = C;
  n->consts.a = -(4*C*R*T)/(4*(C*R)*(C*R)-T*T);
  n->consts.b = (-1 + (4)/(2+T/(C*R)));
}

user_defined_types: struct const_t { double T; double a; double b; double *last_value; unsigned long n; }


decompiled_code:
__int64 __fastcall init_lr_filter(double *a1, double a2, double a3, double a4)
{
__int64 result; // rax

result = init_convolution(a1 + 2, a4);
*a1 = a2;
a1[1] = a3;
a1[3] = a3 * 4.0 * (a2 * a4) / (a3 * a3 * 4.0 - a2 * a4 * (a2 * a4));
a1[4] = 4.0 / (a2 * a4 / a3 + 2.0) - 1.0;
return result;
}

original_code:
void init_lr_filter(struct filter_rl_t * n, const double R, const double L, const double T, double * last_val, const unsigned long int size)
{
  init_convolution(&n->consts, T, last_val, size);
  n->R = R;
  n->L = L;
  n->consts.a = (4*L*R*T)/(4*L*L-R*R*T*T);
  n->consts.b = (-1 + 4/(2+((R*T)/L)));
}

canonical_original_code:
void init_lr_filter(struct filter_rl_t *n, double R, double L, double T, double *last_val, unsigned long size)
{
  init_convolution(&n->consts, T, last_val, size);
  n->R = R;
  n->L = L;
  n->consts.a = (4*L*R*T)/(4*L*L-R*R*T*T);
  n->consts.b = (-1 + 4/(2+((R*T)/L)));
}

variable_types: struct filter_rl_t { double R; struct const_t { double T; double a; double b; double *last_value; unsigned long n; } consts; } *

variable_types: L double

user_defined_types: struct filter_rl_t { double R; struct const_t consts; }


decompiled_code:
__int64 __fastcall init_rl_filter(double *a1, double a2, double a3, double a4)
{
__int64 result; // rax

result = init_convolution(a1 + 2, a4);
*a1 = a2;
a1[1] = a3;
a1[3] = a3 * 4.0 * (a2 * a4) / (a2 * a4 * (a2 * a4) - a3 * a3 * 4.0);
a1[4] = 4.0 / (a2 * a4 / a3 + 2.0) - 1.0;
return result;
}

original_code:
void init_rl_filter(struct filter_rl_t * n, const double R, const double L, const double T, double * last_val, const unsigned long int size)
{
  init_convolution(&n->consts, T, last_val, size);
  n->R = R;
  n->L = L;
  n->consts.a = -(4*L*R*T)/(4*L*L-R*R*T*T);
  n->consts.b = (-1 + 4/(2+(R*T/L)));
}

canonical_original_code:
void init_rl_filter(struct filter_rl_t *n, double R, double L, double T, double *last_val, unsigned long size)
{
  init_convolution(&n->consts, T, last_val, size);
  n->R = R;
  n->L = L;
  n->consts.a = -(4*L*R*T)/(4*L*L-R*R*T*T);
  n->consts.b = (-1 + 4/(2+(R*T/L)));
}


decompiled_code:
double convolution_integral()
{
return 0.0;
}

canonical_decompiled_code:
double func0()
{
return 0.0;
}

original_code:
double convolution_integral(void)
{
  return 0.0;
}

return_type: double


original_code:
double discrete_convolution(struct const_t * f, const double new_sample)
{
  double ret;
  unsigned long int i;
  ret = new_sample;
  f->last_value[f->n] = new_sample;
  if(f->n < 0xFFFFFF)
    {
      if(((f->last_value[0]) <= 1.17549435082228750796873653722224568e-38F) &&
  ((f->last_value[0]) >= -1.17549435082228750796873653722224568e-38F) &&
  (f->n >= 1))
 {
   for(i=1;i<(f->n);i++)
     {
       f->last_value[i] *= f->b;
       f->last_value[i-1] = f->last_value[i];
       ret+=f->last_value[i];
     }
   f->last_value[i-1] = f->last_value[i];
 } else
 {
   for(i=0;i<(f->n);i++)
     {
       f->last_value[i] *= f->b;
       ret+=f->last_value[i];
     }
   f->n++;
 }
    }
  return ret*f->a;
}

canonical_original_code:
double discrete_convolution(struct const_t *f, double new_sample)
{
  double ret;
  unsigned long i;
  ret = new_sample;
  f->last_value[f->n] = new_sample;
  if(f->n < 0xFFFFFF)
    {
      if(((f->last_value[0]) <= 1.17549435082228750796873653722224568e-38F) &&
  ((f->last_value[0]) >= -1.17549435082228750796873653722224568e-38F) &&
  (f->n >= 1))
 {
   for(i=1;i<(f->n);i++)
     {
       f->last_value[i] *= f->b;
       f->last_value[i-1] = f->last_value[i];
       ret+=f->last_value[i];
     }
   f->last_value[i-1] = f->last_value[i];
 } else
 {
   for(i=0;i<(f->n);i++)
     {
       f->last_value[i] *= f->b;
       ret+=f->last_value[i];
     }
   f->n++;
 }
    }
  return ret*f->a;
}

variable_types: struct const_t { double T; double a; double b; double *last_value; unsigned long n; } *

variable_types: ret double

variable_types:
i
unsigned long


original_code:
void init_convolution(struct const_t * n, const double T, double * last_val, const unsigned long int size)
{
  unsigned long int i;
  n->T = T;
  n->n = 0;
  n->last_value = last_val;
  for(i=0;i<size;i++)
    {
      n->last_value[i] = 0;
    }
}

canonical_original_code:
void init_convolution(struct const_t *n, double T, double *last_val, unsigned long size)
{
  unsigned long i;
  n->T = T;
  n->n = 0;
  n->last_value = last_val;
  for(i=0;i<size;i++)
    {
      n->last_value[i] = 0;
    }
}


decompiled_code:
float *__fastcall i_add(float *a1, double a2, double a3)
{
*a1 = *(float *)&a2 + *(float *)&a3;
a1[1] = *((float *)&a2 + 1) + *((float *)&a3 + 1);
return a1;
}

canonical_decompiled_code:
float *__fastcall func0(float *a1, double a2, double a3)
{
*a1 = *(float *)&a2 + *(float *)&a3;
a1[1] = *((float *)&a2 + 1) + *((float *)&a3 + 1);
return a1;
}

original_code:
complex * i_add(complex * r, const complex a, const complex b)
{
  r->real = a.real + b.real;
  r->imag = a.imag + b.imag;
  return r;
}

canonical_original_code:
struct complex *i_add(struct complex *r, struct complex a, struct complex b)
{
  r->real = a.real + b.real;
  r->imag = a.imag + b.imag;
  return r;
}

variable_types:
r
struct complex *

variable_types:
a
struct complex

variable_types:
b
struct complex

return_type: struct complex { float real; } *


decompiled_code:
float *__fastcall i_sub(float *a1, double a2, double a3)
{
*a1 = *(float *)&a2 - *(float *)&a3;
a1[1] = *((float *)&a2 + 1) - *((float *)&a3 + 1);
return a1;
}

canonical_decompiled_code:
float *__fastcall func2(float *a1, double a2, double a3)
{
*a1 = *(float *)&a2 - *(float *)&a3;
a1[1] = *((float *)&a2 + 1) - *((float *)&a3 + 1);
return a1;
}

original_code:
complex * i_sub(complex * r, const complex a, const complex b)
{
  r->real = a.real - b.real;
  r->imag = a.imag - b.imag;
  return r;
}

canonical_original_code:
struct complex *i_sub(struct complex *r, struct complex a, struct complex b)
{
  r->real = a.real - b.real;
  r->imag = a.imag - b.imag;
  return r;
}


decompiled_code:
float *__fastcall i_mul(float *a1, double a2, double a3)
{
*a1 = (float)(*(float *)&a2 * *(float *)&a3) - (float)(*((float *)&a2 + 1) * *((float *)&a3 + 1));
a1[1] = (float)(*((float *)&a2 + 1) * *(float *)&a3) + (float)(*(float *)&a2 * *((float *)&a3 + 1));
return a1;
}

canonical_decompiled_code:
float *__fastcall func4(float *a1, double a2, double a3)
{
*a1 = (float)(*(float *)&a2 * *(float *)&a3) - (float)(*((float *)&a2 + 1) * *((float *)&a3 + 1));
a1[1] = (float)(*((float *)&a2 + 1) * *(float *)&a3) + (float)(*(float *)&a2 * *((float *)&a3 + 1));
return a1;
}

original_code:
complex * i_mul(complex * r, const complex a, const complex b)
{
  complex temp;
  temp.real = a.real*b.real - a.imag*b.imag;
  temp.imag = a.real*b.imag + a.imag*b.real;
  r->real = temp.real;
  r->imag = temp.imag;
  return r;
}

canonical_original_code:
struct complex *i_mul(struct complex *r, struct complex a, struct complex b)
{
  struct complex temp;
  temp.real = a.real*b.real - a.imag*b.imag;
  temp.imag = a.real*b.imag + a.imag*b.real;
  r->real = temp.real;
  r->imag = temp.imag;
  return r;
}

variable_types:
temp
struct complex { float real; }


decompiled_code:
float *__fastcall i_exp(float *a1, __m128i a2)
{
float *result; // rax
long double v3; // fst7
long double v5; // fst7

result = a1;
v3 = 1.442695040888963387 * COERCE_FLOAT(_mm_cvtsi128_si32(a2));
_FST6 = v3;
__asm { frndint }
v5 = __F2XM1__(v3 - _FST6) + 1.0;
*a1 = cos(*(float *)&a2.m128i_i32[1]) * v5;
a1[1] = v5 * sin(*(float *)&a2.m128i_i32[1]);
return result;
}

canonical_decompiled_code:
float *__fastcall func5(float *a1, __m128i a2)
{
float *result; // rax
long double v3; // fst7
long double v5; // fst7

result = a1;
v3 = 1.442695040888963387 * COERCE_FLOAT(_mm_cvtsi128_si32(a2));
_FST6 = v3;
__asm { frndint }
v5 = __F2XM1__(v3 - _FST6) + 1.0;
*a1 = cos(*(float *)&a2.m128i_i32[1]) * v5;
a1[1] = v5 * sin(*(float *)&a2.m128i_i32[1]);
return result;
}

original_code:
complex * i_exp(complex * r, const complex a)
{
  complex temp;
  temp.real = exp(a.real) * cos(a.imag);
  temp.imag = exp(a.real) * sin(a.imag);
  r->real = temp.real;
  r->imag = temp.imag;
  return r;
}

canonical_original_code:
struct complex *i_exp(struct complex *r, struct complex a)
{
  struct complex temp;
  temp.real = exp(a.real) * cos(a.imag);
  temp.imag = exp(a.real) * sin(a.imag);
  r->real = temp.real;
  r->imag = temp.imag;
  return r;
}


decompiled_code:
float *__fastcall i_sqrt(float *a1, double a2)
{
double v2; // xmm1_8
float v3; // xmm4_4
float v4; // xmm5_4

v2 = sqrt((float)((float)(*((float *)&a2 + 1) * *((float *)&a2 + 1)) + (float)(*(float *)&a2 * *(float *)&a2)));
v3 = sqrt((*(float *)&a2 + v2) * 0.5);
*a1 = v3;
v4 = sqrt((COERCE_FLOAT(LODWORD(a2) ^ LC4) + v2) * 0.5);
a1[1] = v4;
return a1;
}

canonical_decompiled_code:
float *__fastcall func6(float *a1, double a2)
{
double v2; // xmm1_8
float v3; // xmm4_4
float v4; // xmm5_4

v2 = sqrt((float)((float)(*((float *)&a2 + 1) * *((float *)&a2 + 1)) + (float)(*(float *)&a2 * *(float *)&a2)));
v3 = sqrt((*(float *)&a2 + v2) * 0.5);
*a1 = v3;
v4 = sqrt((COERCE_FLOAT(LODWORD(a2) ^ LC4) + v2) * 0.5);
a1[1] = v4;
return a1;
}

original_code:
complex * i_sqrt(complex * r, const complex a)
{
  complex temp;
  temp.real = sqrt((a.real + sqrt(a.real*a.real + a.imag*a.imag))/2);
  temp.imag = sqrt((-a.real+sqrt(a.real*a.real + a.imag*a.imag))/2);
  r->real = temp.real;
  r->imag = temp.imag;
  return r;
}

canonical_original_code:
struct complex *i_sqrt(struct complex *r, struct complex a)
{
  struct complex temp;
  temp.real = sqrt((a.real + sqrt(a.real*a.real + a.imag*a.imag))/2);
  temp.imag = sqrt((-a.real+sqrt(a.real*a.real + a.imag*a.imag))/2);
  r->real = temp.real;
  r->imag = temp.imag;
  return r;
}


decompiled_code:
float __fastcall i_abs(double a1)
{
return fsqrt((float)(*((float *)&a1 + 1) * *((float *)&a1 + 1)) + (float)(*(float *)&a1 * *(float *)&a1));
}

canonical_decompiled_code:
float __fastcall func7(double a1)
{
return fsqrt((float)(*((float *)&a1 + 1) * *((float *)&a1 + 1)) + (float)(*(float *)&a1 * *(float *)&a1));
}

original_code:
float i_abs(const complex a)
{
  return sqrt(a.real*a.real + a.imag*a.imag);
}

canonical_original_code:
float i_abs(struct complex a)
{
  return sqrt(a.real*a.real + a.imag*a.imag);
}

variable_types:
a
struct complex { float real; }

return_type: float


original_code:
float i_absv(const c_vector a)
{
  return sqrt(a.f[0]*a.f[0] + a.f[1]*a.f[1]);
}

canonical_original_code:
float i_absv(union c_vector a)
{
  return sqrt(a.f[0]*a.f[0] + a.f[1]*a.f[1]);
}

variable_types:
a
union c_vector { float v; float f[2]; }


original_code:
float square_w(const float V, const float F, const unsigned int N, const float t)
{
  union float4v nv,in_sin,tv,out;
  union float4v Fv,Vv,PIv,two,minus_one,one,half;
  unsigned int n;
  two.f[0] = (const float)2;
  two.f[1] = (const float)2;
  two.f[2] = (const float)2;
  two.f[3] = (const float)2;
  out.f[0] = (const float)0.0;
  out.f[1] = (const float)0.0;
  out.f[2] = (const float)0.0;
  out.f[3] = (const float)0.0;
  half.f[0] = (const float)0.5;
  half.f[1] = (const float)0.0;
  half.f[2] = (const float)0.0;
  half.f[3] = (const float)0.0;
  minus_one.f[0] = (const float)-1.0;
  minus_one.f[1] = (const float)-1.0;
  minus_one.f[2] = (const float)-1.0;
  minus_one.f[3] = (const float)-1.0;
  one.f[0] = (const float)4.0;
  one.f[1] = (const float)4.0;
  one.f[2] = (const float)4.0;
  one.f[3] = (const float)4.0;
  Fv.f[0] = (const float)F;
  Fv.f[1] = (const float)F;
  Fv.f[2] = (const float)F;
  Fv.f[3] = (const float)F;
  PIv.f[0] = (const float)Pi;
  PIv.f[1] = (const float)Pi;
  PIv.f[2] = (const float)Pi;
  PIv.f[3] = (const float)Pi;
  Vv.f[0] = (const float)V;
  Vv.f[1] = (const float)V;
  Vv.f[2] = (const float)V;
  Vv.f[3] = (const float)V;
  tv.f[0] = t;
  tv.f[1] = t;
  tv.f[2] = t;
  tv.f[3] = t;
  nv.f[0] = (float)(1);
  nv.f[1] = (float)(2);
  nv.f[2] = (float)(3);
  nv.f[3] = (float)(4);
  for(n=0;n<N;n++)
    {
      in_sin.v = two.v*Fv.v*(minus_one.v + two.v*nv.v)*PIv.v*tv.v;
      in_sin.f[0] = sin(in_sin.f[0]);
      in_sin.f[1] = sin(in_sin.f[1]);
      in_sin.f[2] = sin(in_sin.f[2]);
      in_sin.f[3] = sin(in_sin.f[3]);
      in_sin.v /= ((minus_one.v + two.v*nv.v)*PIv.v);
      in_sin.v *= two.v;
      out.v += in_sin.v;
      nv.v = nv.v + one.v;
    }
  out.v += half.v;
  out.v *= Vv.v;
  return out.f[0] + out.f[1]+ out.f[2]+ out.f[3];
}

canonical_original_code:
float square_w(float V, float F, unsigned int N, float t)
{
  union float4v nv; union float4v in_sin; union float4v tv; union float4v out;
  union float4v Fv; union float4v Vv; union float4v PIv; union float4v two; union float4v minus_one; union float4v one; union float4v half;
  unsigned int n;
  two.f[0] = (float)2;
  two.f[1] = (float)2;
  two.f[2] = (float)2;
  two.f[3] = (float)2;
  out.f[0] = (float)0.0;
  out.f[1] = (float)0.0;
  out.f[2] = (float)0.0;
  out.f[3] = (float)0.0;
  half.f[0] = (float)0.5;
  half.f[1] = (float)0.0;
  half.f[2] = (float)0.0;
  half.f[3] = (float)0.0;
  minus_one.f[0] = (float)-1.0;
  minus_one.f[1] = (float)-1.0;
  minus_one.f[2] = (float)-1.0;
  minus_one.f[3] = (float)-1.0;
  one.f[0] = (float)4.0;
  one.f[1] = (float)4.0;
  one.f[2] = (float)4.0;
  one.f[3] = (float)4.0;
  Fv.f[0] = (float)F;
  Fv.f[1] = (float)F;
  Fv.f[2] = (float)F;
  Fv.f[3] = (float)F;
  PIv.f[0] = (float)Pi;
  PIv.f[1] = (float)Pi;
  PIv.f[2] = (float)Pi;
  PIv.f[3] = (float)Pi;
  Vv.f[0] = (float)V;
  Vv.f[1] = (float)V;
  Vv.f[2] = (float)V;
  Vv.f[3] = (float)V;
  tv.f[0] = t;
  tv.f[1] = t;
  tv.f[2] = t;
  tv.f[3] = t;
  nv.f[0] = (float)(1);
  nv.f[1] = (float)(2);
  nv.f[2] = (float)(3);
  nv.f[3] = (float)(4);
  for(n=0;n<N;n++)
    {
      in_sin.v = two.v*Fv.v*(minus_one.v + two.v*nv.v)*PIv.v*tv.v;
      in_sin.f[0] = sin(in_sin.f[0]);
      in_sin.f[1] = sin(in_sin.f[1]);
      in_sin.f[2] = sin(in_sin.f[2]);
      in_sin.f[3] = sin(in_sin.f[3]);
      in_sin.v /= ((minus_one.v + two.v*nv.v)*PIv.v);
      in_sin.v *= two.v;
      out.v += in_sin.v;
      nv.v = nv.v + one.v;
    }
  out.v += half.v;
  out.v *= Vv.v;
  return out.f[0] + out.f[1]+ out.f[2]+ out.f[3];
}

variable_types: V float

variable_types: F float

variable_types:
N
unsigned int

variable_types: t float

variable_types:
nv
union float4v { float v; float f[4]; }

variable_types:
tv
union float4v { float v; float f[4]; }

variable_types:
out
union float4v { float v; float f[4]; }

variable_types:
Fv
union float4v { float v; float f[4]; }

variable_types:
Vv
union float4v { float v; float f[4]; }

variable_types:
PIv
union float4v { float v; float f[4]; }

variable_types:
two
union float4v { float v; float f[4]; }

variable_types:
one
union float4v { float v; float f[4]; }

variable_types:
half
union float4v { float v; float f[4]; }

variable_types:
n
unsigned int


fft

original_code:
complex * fft(complex * r, const complex * x, const unsigned long int N, const unsigned long int k)
{
  unsigned long int n;
  complex f,ret;
  ret.real = 0;
  ret.imag = 0;
  for(n=0;n<=(N-1);n++)
    {
      f.real = 0;
      f.imag = -2*3.14159265358979323846*((k*n)/((float)N));
      i_exp(&f,f);
      i_mul(&f,x[n],f);
      i_add(&ret,ret,f);
    }
  r->real = ret.real;
  r->imag = ret.imag;
  return r;
}

canonical_original_code:
struct complex *fft(struct complex *r, struct complex *x, unsigned long N, unsigned long k)
{
  unsigned long n;
  struct complex f; struct complex ret;
  ret.real = 0;
  ret.imag = 0;
  for(n=0;n<=(N-1);n++)
    {
      f.real = 0;
      f.imag = -2*3.14159265358979323846*((k*n)/((float)N));
      i_exp(&f,f);
      i_mul(&f,x[n],f);
      i_add(&ret,ret,f);
    }
  r->real = ret.real;
  r->imag = ret.imag;
  return r;
}

variable_types:
r
struct complex *

variable_types:
x
struct complex *

variable_types:
N
unsigned long

variable_types:
k
unsigned long

variable_types:
n
unsigned long

variable_types:
f
struct complex { float real; }

variable_types:
ret
struct complex { float real; }


ifft

original_code:
complex * ifft(complex * r, const complex * x, const unsigned long int N, const unsigned long int k)
{
  unsigned long int n;
  complex f,ret;
  ret.real = 0;
  ret.imag = 0;
  for(n=0;n<=(N-1);n++)
    {
      f.real = 0;
      f.imag = 2*3.14159265358979323846*((k*n)/((float)N));
      i_exp(&f,f);
      i_mul(&f,x[n],f);
      i_add(&ret,ret,f);
    }
  r->real = (1.0/N)*ret.real;
  r->imag = (1.0/N)*ret.imag;
  return r;
}

canonical_original_code:
struct complex *ifft(struct complex *r, struct complex *x, unsigned long N, unsigned long k)
{
  unsigned long n;
  struct complex f; struct complex ret;
  ret.real = 0;
  ret.imag = 0;
  for(n=0;n<=(N-1);n++)
    {
      f.real = 0;
      f.imag = 2*3.14159265358979323846*((k*n)/((float)N));
      i_exp(&f,f);
      i_mul(&f,x[n],f);
      i_add(&ret,ret,f);
    }
  r->real = (1.0/N)*ret.real;
  r->imag = (1.0/N)*ret.imag;
  return r;
}


rotate

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

buffer = byte_4042A5;
byte_4042A5 = byte_4042A6;
result = (unsigned __int8)byte_4042A7;
byte_4042A6 = byte_4042A7;
byte_4042A7 = a1;
return result;
}

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

buffer = byte_4042A5;
byte_4042A5 = byte_4042A6;
result = (unsigned __int8)byte_4042A7;
byte_4042A6 = byte_4042A7;
byte_4042A7 = a1;
return result;
}

original_code:
void rotate(const char n)
{
    buffer[0] = buffer[1];
    buffer[1] = buffer[2];
    buffer[2] = buffer[3];
    buffer[3] = n;
}

canonical_original_code:
void rotate(char n)
{
    buffer[0] = buffer[1];
    buffer[1] = buffer[2];
    buffer[2] = buffer[3];
    buffer[3] = n;
}

variable_types: n char


isEmpty

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

result = 0LL;
if ( buffer == 95 && byte_4042A5 == 95 && byte_4042A6 == 95 )
{
byte_4042A7 = 95;
result = 1LL;
}
return result;
}

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

result = 0LL;
if ( buffer == 95 && byte_4042A5 == 95 && byte_4042A6 == 95 )
{
byte_4042A7 = 95;
result = 1LL;
}
return result;
}

return_type: int


isCon

decompiled_code:
__int64 __fastcall isCon(char a1)
{
_BYTE *v1; // rax

v1 = &con;
while ( *v1 != a1 )
{
if ( ++v1 == (_BYTE *)&_GNU_EH_FRAME_HDR )
return 0LL;
}
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func10(char a1)
{
_BYTE *v1; // rax

v1 = &con;
while ( *v1 != a1 )
{
if ( ++v1 == (_BYTE *)&_GNU_EH_FRAME_HDR )
return 0LL;
}
return 1LL;
}

original_code:
int isCon(const char c)
{
  int i;
  i=0;
  while(i<20) {
    if(c == con[i]) return 1;
    i++;
  }
  return 0;
}

canonical_original_code:
int isCon(char c)
{
  int i;
  i=0;
  while(i<20) {
    if(c == con[i]) return 1;
    i++;
  }
  return 0;
}

variable_types: c char

variable_types: i int


isVoc

decompiled_code:
_BOOL8 __fastcall isVoc(char a1)
{
switch ( a1 )
{
case 'A':
return 1LL;
case 'E':
return 1LL;
case 'I':
return 1LL;
case 'O':
return 1LL;
case 'U':
return 1LL;
}
return a1 == 89;
}

canonical_decompiled_code:
_BOOL8 __fastcall func11(char a1)
{
switch ( a1 )
{
case 'A':
return 1LL;
case 'E':
return 1LL;
case 'I':
return 1LL;
case 'O':
return 1LL;
case 'U':
return 1LL;
}
return a1 == 89;
}

original_code:
int isVoc(const char c)
{
  int i;
  i=0;
  while(i<6) {
    if(c == voc[i]) return 1;
    i++;
  }
  return 0;
}

canonical_original_code:
int isVoc(char c)
{
  int i;
  i=0;
  while(i<6) {
    if(c == voc[i]) return 1;
    i++;
  }
  return 0;
}


analyze

original_code:
void analyze(const char * in,const int len)
{
  int i,c;
  char anaz[255], temp[255], last;
  convert(anaz,in,len);
  i=0;
  c=0;
  last='S';
  while(i<len)
    {
      switch(anaz[i])
 {
 case 'C':
   switch(last)
     {
     case 'V':
       temp[c++] = '\0';
       printf("%s\t%u\n",temp,i-c+1);
       c=0;
     case 'S':
     case 'C':
       temp[c++] = in[i];
       last = anaz[i];
       break;
     default: break;
     }
   break;
 case 'V':
   switch(last)
     {
     case 'C':
       temp[c++] = '\0';
       printf("%s\t%u\n",temp,i-c+1);
       c=0;
     case 'S':
     case 'V':
       temp[c++] = in[i];
       last = anaz[i];
       break;
     default: break;
     }
   break;
 default:
   break;
 }
      i++;
    }
  temp[c++] = '\0';
  printf("%s\t%u\n",temp,i-c+1);
  temp[0]=temp[0];
}

canonical_original_code:
void analyze(char *in, int len)
{
  int i; int c;
  char anaz[255]; char temp[255]; char last;
  convert(anaz,in,len);
  i=0;
  c=0;
  last='S';
  while(i<len)
    {
      switch(anaz[i])
 {
 case 'C':
   switch(last)
     {
     case 'V':
       temp[c++] = '\0';
       printf("%s\t%u\n",temp,i-c+1);
       c=0;
     case 'S':
     case 'C':
       temp[c++] = in[i];
       last = anaz[i];
       break;
     default: break;
     }
   break;
 case 'V':
   switch(last)
     {
     case 'C':
       temp[c++] = '\0';
       printf("%s\t%u\n",temp,i-c+1);
       c=0;
     case 'S':
     case 'V':
       temp[c++] = in[i];
       last = anaz[i];
       break;
     default: break;
     }
   break;
 default:
   break;
 }
      i++;
    }
  temp[c++] = '\0';
  printf("%s\t%u\n",temp,i-c+1);
  temp[0]=temp[0];
}

variable_types:
in
char *

variable_types: len int

variable_types: c int

variable_types:
anaz
char [255]

variable_types:
temp
char [255]

variable_types: last char


params

decompiled_code:
bool __fastcall params(int a1, const void **a2)
{
const void **v2; // rdx
__int64 v3; // r9
bool v4; // zf
bool result; // al

if ( a1 > 0 )
{
v2 = a2;
v3 = (__int64)&a2[(unsigned int)(a1 - 1) + 1];
do
{
if ( !memcmp(*v2, "--help", 6uLL) )
{
puts(" -a\tanalyze vocals and consonants");
puts(" -l\tanalyze letters according to voc/con");
exit(0);
}
v4 = memcmp(*v2, "-a", 2uLL) == 0;
result = !v4;
if ( v4 )
{
flags = 1;
}
else
{
v4 = memcmp(*v2, "-l", 2uLL) == 0;
result = !v4;
if ( v4 )
flags = 2;
}
++v2;
}
while ( v2 != (const void **)v3 );
}
return result;
}

canonical_decompiled_code:
bool __fastcall func14(int a1, const void **a2)
{
const void **v2; // rdx
__int64 v3; // r9
bool v4; // zf
bool result; // al

if ( a1 > 0 )
{
v2 = a2;
v3 = (__int64)&a2[(unsigned int)(a1 - 1) + 1];
do
{
if ( !memcmp(*v2, "--help", 6uLL) )
{
puts(" -a\tanalyze vocals and consonants");
puts(" -l\tanalyze letters according to voc/con");
exit(0);
}
v4 = memcmp(*v2, "-a", 2uLL) == 0;
result = !v4;
if ( v4 )
{
flags = 1;
}
else
{
v4 = memcmp(*v2, "-l", 2uLL) == 0;
result = !v4;
if ( v4 )
flags = 2;
}
++v2;
}
while ( v2 != (const void **)v3 );
}
return result;
}

original_code:
void params(int argc, char **argv)
{
  int i=0;
  while(i<argc)
    {
      if(strncmp(argv[i],"--help",6)==0)
 {
   printf(" -a\tanalyze vocals and consonants\n");
   printf(" -l\tanalyze letters according to voc/con\n");
   exit(0);
 }
      else if(strncmp(argv[i],"-a",2)==0)
 {
   flags=0;
   flags|=1;
 }
      else if(strncmp(argv[i],"-l",2)==0)
 {
   flags=0;
   flags|=2;
 }
      i++;
    }
}

canonical_original_code:
void params(int argc, char **argv)
{
  int i = 0;
  while(i<argc)
    {
      if(strncmp(argv[i],"--help",6)==0)
 {
   printf(" -a\tanalyze vocals and consonants\n");
   printf(" -l\tanalyze letters according to voc/con\n");
   exit(0);
 }
      else if(strncmp(argv[i],"-a",2)==0)
 {
   flags=0;
   flags|=1;
 }
      else if(strncmp(argv[i],"-l",2)==0)
 {
   flags=0;
   flags|=2;
 }
      i++;
    }
}

variable_types: argc int

variable_types:
argv
char **


setupNodes

decompiled_code:
_DWORD *setupNodes()
{
_DWORD *result; // rax
char *v1; // rcx
__int64 v2; // rdx
__int64 v3; // rsi

result = &nodes;
v1 = (char *)&unk_404108;
v2 = 1LL;
do
{
*result = 0;
result[1] = 0;
result[2] = 0;
result[3] = 0;
result[4] = 0;
result[5] = 0;
*((_QWORD *)result + 3) = v2;
v3 = v2 + 2;
*((_QWORD *)result + 4) = v2 + 1;
v2 += 3LL;
*((_QWORD *)result + 5) = v3;
*((_QWORD *)result + 6) = v1;
*((_QWORD *)result + 7) = v1 + 72;
*((_QWORD *)result + 8) = v1 + 144;
result += 18;
v1 += 216;
}
while ( v2 != 2391484 );
return result;
}

original_code:
void setupNodes(void)
{
  unsigned long int i,c;
  c=0;i=1;
  while(c<797161) {
    nodes[c].p[0] = 0.0;
    nodes[c].p[1] = 0.0;
    nodes[c].p[2] = 0.0;
    nodes[c].count[0] = 0;
    nodes[c].count[1] = 0;
    nodes[c].count[2] = 0;
    nodes[c].index[0] = i++;
    nodes[c].index[1] = i++;
    nodes[c].index[2] = i++;
    nodes[c].tree_node[0] = &nodes[nodes[c].index[0]];
    nodes[c].tree_node[1] = &nodes[nodes[c].index[1]];
    nodes[c].tree_node[2] = &nodes[nodes[c].index[2]];
    c++;
  }
}

canonical_original_code:
void setupNodes()
{
  unsigned long i; unsigned long c;
  c=0;i=1;
  while(c<797161) {
    nodes[c].p[0] = 0.0;
    nodes[c].p[1] = 0.0;
    nodes[c].p[2] = 0.0;
    nodes[c].count[0] = 0;
    nodes[c].count[1] = 0;
    nodes[c].count[2] = 0;
    nodes[c].index[0] = i++;
    nodes[c].index[1] = i++;
    nodes[c].index[2] = i++;
    nodes[c].tree_node[0] = &nodes[nodes[c].index[0]];
    nodes[c].tree_node[1] = &nodes[nodes[c].index[1]];
    nodes[c].tree_node[2] = &nodes[nodes[c].index[2]];
    c++;
  }
}

variable_types:
i
unsigned long

variable_types:
c
unsigned long


params

decompiled_code:
bool __fastcall params(int a1, const void **a2)
{
const void **v2; // rdx
__int64 v3; // r9
bool v4; // zf
bool result; // al

if ( a1 > 0 )
{
v2 = a2;
v3 = (__int64)&a2[(unsigned int)(a1 - 1) + 1];
do
{
if ( !memcmp(*v2, "--help", 6uLL) )
{
puts(" --g\tgenerate a list with random names");
puts(" --p\tgenerate a probability tree");
exit(0);
}
v4 = memcmp(*v2, &off_40200B, 3uLL) == 0;
result = !v4;
if ( v4 )
{
flags = 1;
}
else
{
v4 = memcmp(*v2, &off_40200F, 3uLL) == 0;
result = !v4;
if ( v4 )
flags = 2;
}
++v2;
}
while ( v2 != (const void **)v3 );
}
return result;
}

canonical_decompiled_code:
bool __fastcall func8(int a1, const void **a2)
{
const void **v2; // rdx
__int64 v3; // r9
bool v4; // zf
bool result; // al

if ( a1 > 0 )
{
v2 = a2;
v3 = (__int64)&a2[(unsigned int)(a1 - 1) + 1];
do
{
if ( !memcmp(*v2, "--help", 6uLL) )
{
puts(" --g\tgenerate a list with random names");
puts(" --p\tgenerate a probability tree");
exit(0);
}
v4 = memcmp(*v2, &off_40200B, 3uLL) == 0;
result = !v4;
if ( v4 )
{
flags = 1;
}
else
{
v4 = memcmp(*v2, &off_40200F, 3uLL) == 0;
result = !v4;
if ( v4 )
flags = 2;
}
++v2;
}
while ( v2 != (const void **)v3 );
}
return result;
}

original_code:
void params(int argc, char **argv)
{
  int i=0;
  while(i<argc)
    {
      if(strncmp(argv[i],"--help",6)==0)
 {
   printf(" --g\tgenerate a list with random names\n");
   printf(" --p\tgenerate a probability tree\n");
   exit(0);
 }
      else if(strncmp(argv[i],"--g",3)==0)
 {
   flags=0;
   flags|=1;
 }
      else if(strncmp(argv[i],"--p",3)==0)
 {
   flags=0;
   flags|=2;
 }
      i++;
    }
}

canonical_original_code:
void params(int argc, char **argv)
{
  int i = 0;
  while(i<argc)
    {
      if(strncmp(argv[i],"--help",6)==0)
 {
   printf(" --g\tgenerate a list with random names\n");
   printf(" --p\tgenerate a probability tree\n");
   exit(0);
 }
      else if(strncmp(argv[i],"--g",3)==0)
 {
   flags=0;
   flags|=1;
 }
      else if(strncmp(argv[i],"--p",3)==0)
 {
   flags=0;
   flags|=2;
 }
      i++;
    }
}


original_code:
int setup_global_regex(void)
{
  int ret;
  char errbuf[100];
  ret = regcomp(&symbol_list, symbol_regstr, 0);
  if(ret!=0)
    {
      regerror(ret, &symbol_list, errbuf, 100);
      fprintf(stderr,"Error in Symbol Regex: %s\n",errbuf);
    }
  ret = regcomp(&arg_list, arg_regstr, 0);
  if(ret!=0)
    {
      regerror(ret, &arg_list, errbuf, 100);
      fprintf(stderr,"Error in Argument Regex: %s\n",errbuf);
    }
  ret = regcomp(&instr_list, instr_regstr, 0);
  if(ret!=0)
    {
      regerror(ret, &instr_list, errbuf, 100);
      fprintf(stderr,"Error in instruction Regex: %s\n",errbuf);
    }
  return 1;
}

canonical_original_code:
int setup_global_regex()
{
  int ret;
  char errbuf[100];
  ret = regcomp(&symbol_list, symbol_regstr, 0);
  if(ret!=0)
    {
      regerror(ret, &symbol_list, errbuf, 100);
      fprintf(stderr,"Error in Symbol Regex: %s\n",errbuf);
    }
  ret = regcomp(&arg_list, arg_regstr, 0);
  if(ret!=0)
    {
      regerror(ret, &arg_list, errbuf, 100);
      fprintf(stderr,"Error in Argument Regex: %s\n",errbuf);
    }
  ret = regcomp(&instr_list, instr_regstr, 0);
  if(ret!=0)
    {
      regerror(ret, &instr_list, errbuf, 100);
      fprintf(stderr,"Error in instruction Regex: %s\n",errbuf);
    }
  return 1;
}

variable_types: ret int

variable_types:
errbuf
char [100]


decompiled_code:
void free_global_regex()
{
regfree(&symbol_list);
regfree(&instr_list);
regfree(&arg_list);
}

canonical_decompiled_code:
void func1()
{
regfree(&symbol_list);
regfree(&instr_list);
regfree(&arg_list);
}

original_code:
void free_global_regex(void)
{
  regfree(&symbol_list);
  regfree(&instr_list);
  regfree(&arg_list);
}


repo: SpenceSellers/CRenderer

decompiled_code:
__int64 __fastcall Point3D_add(__int64 a1, __int64 a2, __int64 a3)
{
__int64 v4; // [rsp+0h] [rbp-14h]

LODWORD(v4) = a1 + a3;
HIDWORD(v4) = HIDWORD(a3) + HIDWORD(a1);
return v4;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 a2, __int64 a3)
{
__int64 v4; // [rsp+0h] [rbp-14h]

LODWORD(v4) = a1 + a3;
HIDWORD(v4) = HIDWORD(a3) + HIDWORD(a1);
return v4;
}

original_code:
Point3D Point3D_add(Point3D p1, Point3D p2){
    Point3D result;
    result.x = p1.x + p2.x;
    result.y = p1.y + p2.y;
    result.z = p1.z + p2.z;
    return result;
}

canonical_original_code:
struct Point3D Point3D_add(struct Point3D p1, struct Point3D p2){
    struct Point3D result;
    result.x = p1.x + p2.x;
    result.y = p1.y + p2.y;
    result.z = p1.z + p2.z;
    return result;
}

variable_types:
result
struct Point3D { int x; int y; int z; }

return_type: struct Point3D { int x; int y; int z; }


decompiled_code:
__int64 __fastcall Point3D_subtract(__int64 a1, __int64 a2, __int64 a3)
{
__int64 v4; // [rsp+0h] [rbp-14h]

LODWORD(v4) = a1 - a3;
HIDWORD(v4) = HIDWORD(a1) - HIDWORD(a3);
return v4;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, __int64 a2, __int64 a3)
{
__int64 v4; // [rsp+0h] [rbp-14h]

LODWORD(v4) = a1 - a3;
HIDWORD(v4) = HIDWORD(a1) - HIDWORD(a3);
return v4;
}

original_code:
Point3D Point3D_subtract(Point3D p1, Point3D p2){
    Point3D result;
    result.x = p1.x - p2.x;
    result.y = p1.y - p2.y;
    result.z = p1.z - p2.z;
    return result;
}

canonical_original_code:
struct Point3D Point3D_subtract(struct Point3D p1, struct Point3D p2){
    struct Point3D result;
    result.x = p1.x - p2.x;
    result.y = p1.y - p2.y;
    result.z = p1.z - p2.z;
    return result;
}


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

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

original_code:
Point3D Point3D_multiply(Point3D p, double scale){
    p.x *= scale;
    p.y *= scale;
    p.z *= scale;
}

canonical_original_code:
struct Point3D Point3D_multiply(struct Point3D p, double scale){
    p.x *= scale;
    p.y *= scale;
    p.z *= scale;
}

variable_types:
p
struct Point3D

variable_types: scale double


decompiled_code:
double __fastcall Point3D_distance(__int64 a1, int a2, __int64 a3, int a4)
{
double v4; // xmm0_8
double result; // xmm0_8

v4 = (double)((int)a3 - (int)a1) * (double)((int)a3 - (int)a1)
+ (double)(HIDWORD(a3) - HIDWORD(a1)) * (double)(HIDWORD(a3) - HIDWORD(a1))
+ (double)(a4 - a2) * (double)(a4 - a2);
if ( v4 < 0.0 )
result = sqrt(v4);
else
result = sqrt(v4);
return result;
}

canonical_decompiled_code:
double __fastcall func3(__int64 a1, int a2, __int64 a3, int a4)
{
double v4; // xmm0_8
double result; // xmm0_8

v4 = (double)((int)a3 - (int)a1) * (double)((int)a3 - (int)a1)
+ (double)(HIDWORD(a3) - HIDWORD(a1)) * (double)(HIDWORD(a3) - HIDWORD(a1))
+ (double)(a4 - a2) * (double)(a4 - a2);
if ( v4 < 0.0 )
result = sqrt(v4);
else
result = sqrt(v4);
return result;
}

original_code:
double Point3D_distance(Point3D p1, Point3D p2){
    return sqrt(
         pow(p2.x - p1.x, 2) +
  pow(p2.y - p1.y, 2) +
  pow(p2.z - p1.z, 2));
}

canonical_original_code:
double Point3D_distance(struct Point3D p1, struct Point3D p2){
    return sqrt(
         pow(p2.x - p1.x, 2) +
  pow(p2.y - p1.y, 2) +
  pow(p2.z - p1.z, 2));
}


decompiled_code:
unsigned __int64 __fastcall Point3D_rotZ(unsigned __int64 a1, int a2, double a3)
{
int v3; // er12
unsigned __int64 v4; // rdi
double cosx; // [rsp+10h] [rbp-48h] BYREF
double sinx[3]; // [rsp+18h] [rbp-40h] BYREF
unsigned __int64 v8; // [rsp+34h] [rbp-24h]
int v9; // [rsp+3Ch] [rbp-1Ch]

v3 = a1;
v4 = HIDWORD(a1);
if ( a3 == 0.0 )
{
v8 = __PAIR64__(v4, v3);
}
else
{
sincos(a3, sinx, &cosx);
LODWORD(v8) = (int)((double)v3 * cosx - (double)(int)v4 * sinx[0]);
HIDWORD(v8) = (int)((double)v3 * sinx[0] + cosx * (double)(int)v4);
}
v9 = a2;
return v8;
}

canonical_decompiled_code:
unsigned __int64 __fastcall func4(unsigned __int64 a1, int a2, double a3)
{
int v3; // er12
unsigned __int64 v4; // rdi
double cosx; // [rsp+10h] [rbp-48h] BYREF
double sinx[3]; // [rsp+18h] [rbp-40h] BYREF
unsigned __int64 v8; // [rsp+34h] [rbp-24h]
int v9; // [rsp+3Ch] [rbp-1Ch]

v3 = a1;
v4 = HIDWORD(a1);
if ( a3 == 0.0 )
{
v8 = __PAIR64__(v4, v3);
}
else
{
sincos(a3, sinx, &cosx);
LODWORD(v8) = (int)((double)v3 * cosx - (double)(int)v4 * sinx[0]);
HIDWORD(v8) = (int)((double)v3 * sinx[0] + cosx * (double)(int)v4);
}
v9 = a2;
return v8;
}

original_code:
Point3D Point3D_rotZ(Point3D p, double angle){
    if (angle == 0.0) return p;
    int x = p.x * cos(angle) - p.y * sin(angle);
    int y = p.x * sin(angle) + p.y * cos(angle);
    int z = p.z;
    Point3D result = {x,y,z};
    return result;
}

canonical_original_code:
struct Point3D Point3D_rotZ(struct Point3D p, double angle){
    if (angle == 0.0) return p;
    int x = p.x * cos(angle) - p.y * sin(angle);
    int y = p.x * sin(angle) + p.y * cos(angle);
    int z = p.z;
    struct Point3D result = {x,y,z};
    return result;
}

variable_types: angle double

variable_types: x int

variable_types: y int

variable_types: z int


decompiled_code:
unsigned __int64 __fastcall Point3D_rotX(unsigned __int64 a1, int a2, double a3)
{
unsigned int v3; // er12
unsigned __int64 v4; // rdi
double cosx; // [rsp+10h] [rbp-48h] BYREF
double sinx[3]; // [rsp+18h] [rbp-40h] BYREF
unsigned __int64 v8; // [rsp+34h] [rbp-24h]
int v9; // [rsp+3Ch] [rbp-1Ch]

v3 = a1;
v4 = HIDWORD(a1);
if ( a3 == 0.0 )
{
v8 = __PAIR64__(v4, v3);
v9 = a2;
}
else
{
sincos(a3, sinx, &cosx);
LODWORD(v8) = v3;
HIDWORD(v8) = (int)((double)(int)v4 * cosx - (double)a2 * sinx[0]);
v9 = (int)((double)(int)v4 * sinx[0] + cosx * (double)a2);
}
return v8;
}

canonical_decompiled_code:
unsigned __int64 __fastcall func5(unsigned __int64 a1, int a2, double a3)
{
unsigned int v3; // er12
unsigned __int64 v4; // rdi
double cosx; // [rsp+10h] [rbp-48h] BYREF
double sinx[3]; // [rsp+18h] [rbp-40h] BYREF
unsigned __int64 v8; // [rsp+34h] [rbp-24h]
int v9; // [rsp+3Ch] [rbp-1Ch]

v3 = a1;
v4 = HIDWORD(a1);
if ( a3 == 0.0 )
{
v8 = __PAIR64__(v4, v3);
v9 = a2;
}
else
{
sincos(a3, sinx, &cosx);
LODWORD(v8) = v3;
HIDWORD(v8) = (int)((double)(int)v4 * cosx - (double)a2 * sinx[0]);
v9 = (int)((double)(int)v4 * sinx[0] + cosx * (double)a2);
}
return v8;
}

original_code:
Point3D Point3D_rotX(Point3D p, double angle){
    if (angle == 0.0) return p;
    int y = p.y * cos(angle) - p.z * sin(angle);
    int z = p.y * sin(angle) + p.z * cos(angle);
    int x = p.x;
    Point3D result = {x,y,z};
    return result;
}

canonical_original_code:
struct Point3D Point3D_rotX(struct Point3D p, double angle){
    if (angle == 0.0) return p;
    int y = p.y * cos(angle) - p.z * sin(angle);
    int z = p.y * sin(angle) + p.z * cos(angle);
    int x = p.x;
    struct Point3D result = {x,y,z};
    return result;
}


decompiled_code:
unsigned __int64 __fastcall Point3D_rotY(unsigned __int64 a1, int a2, double a3)
{
int v3; // er12
unsigned __int64 v4; // rdi
double cosx; // [rsp+10h] [rbp-48h] BYREF
double sinx[3]; // [rsp+18h] [rbp-40h] BYREF
unsigned __int64 v8; // [rsp+34h] [rbp-24h]
int v9; // [rsp+3Ch] [rbp-1Ch]

v3 = a1;
v4 = HIDWORD(a1);
if ( a3 == 0.0 )
{
v8 = __PAIR64__(v4, v3);
v9 = a2;
}
else
{
sincos(a3, sinx, &cosx);
LODWORD(v8) = (int)((double)a2 * sinx[0] + cosx * (double)v3);
HIDWORD(v8) = v4;
v9 = (int)((double)a2 * cosx - (double)v3 * sinx[0]);
}
return v8;
}

canonical_decompiled_code:
unsigned __int64 __fastcall func6(unsigned __int64 a1, int a2, double a3)
{
int v3; // er12
unsigned __int64 v4; // rdi
double cosx; // [rsp+10h] [rbp-48h] BYREF
double sinx[3]; // [rsp+18h] [rbp-40h] BYREF
unsigned __int64 v8; // [rsp+34h] [rbp-24h]
int v9; // [rsp+3Ch] [rbp-1Ch]

v3 = a1;
v4 = HIDWORD(a1);
if ( a3 == 0.0 )
{
v8 = __PAIR64__(v4, v3);
v9 = a2;
}
else
{
sincos(a3, sinx, &cosx);
LODWORD(v8) = (int)((double)a2 * sinx[0] + cosx * (double)v3);
HIDWORD(v8) = v4;
v9 = (int)((double)a2 * cosx - (double)v3 * sinx[0]);
}
return v8;
}

original_code:
Point3D Point3D_rotY(Point3D p, double angle){
    if (angle == 0.0) return p;
    int z = p.z * cos(angle) - p.x * sin(angle);
    int x = p.z * sin(angle) + p.x * cos(angle);
    int y = p.y;
    Point3D result = {x,y,z};
    return result;
}

canonical_original_code:
struct Point3D Point3D_rotY(struct Point3D p, double angle){
    if (angle == 0.0) return p;
    int z = p.z * cos(angle) - p.x * sin(angle);
    int x = p.z * sin(angle) + p.x * cos(angle);
    int y = p.y;
    struct Point3D result = {x,y,z};
    return result;
}


decompiled_code:
unsigned __int64 __fastcall Point3D_rotate(unsigned __int64 a1, int a2, double a3, double a4, double a5, double a6, double a7, double a8, double a9, double a10, double a11, double a12, double a13)
{
unsigned __int64 v9; // rax
int v10; // edx
unsigned __int64 v11; // rax
int v12; // edx

v9 = Point3D_rotY(a1, a2, a12);
v11 = Point3D_rotX(v9, v10, a11);
return Point3D_rotZ(v11, v12, a13);
}

canonical_decompiled_code:
unsigned __int64 __fastcall func7(unsigned __int64 a1, int a2, double a3, double a4, double a5, double a6, double a7, double a8, double a9, double a10, double a11, double a12, double a13)
{
unsigned __int64 v9; // rax
int v10; // edx
unsigned __int64 v11; // rax
int v12; // edx

v9 = func6(a1, a2, a12);
v11 = func5(v9, v10, a11);
return func4(v11, v12, a13);
}

original_code:
Point3D Point3D_rotate(Point3D p, RotationVector rotation){
    p = Point3D_rotY(p, rotation.rotY);
    p = Point3D_rotX(p, rotation.rotX);
    p = Point3D_rotZ(p, rotation.rotZ);
    return p;
}

canonical_original_code:
struct Point3D Point3D_rotate(struct Point3D p, struct RotationVector rotation){
    p = Point3D_rotY(p, rotation.rotY);
    p = Point3D_rotX(p, rotation.rotX);
    p = Point3D_rotZ(p, rotation.rotZ);
    return p;
}

variable_types: struct RotationVector { double rotX; double rotY; double rotZ; }


decompiled_code:
__int64 __fastcall Point3D_rotate_around_point(__int64 a1, __int64 a2, __int64 a3, double a4, double a5, double a6, double a7, double a8, double a9, double a10, double a11, double a12, double a13, double a14)
{
__int64 v18; // rax
int v19; // edx
double v20; // xmm4_8
double v21; // xmm5_8
__int64 v22; // rax
__int64 v23; // rdx

v18 = Point3D_subtract(a1, a2, a3);
v22 = Point3D_rotate(v18, v19, a4, a5, a6, a7, v20, v21, a10, a11, a12, a13, a14);
return Point3D_add(v22, v23, a3);
}

canonical_decompiled_code:
__int64 __fastcall func8(__int64 a1, __int64 a2, __int64 a3, double a4, double a5, double a6, double a7, double a8, double a9, double a10, double a11, double a12, double a13, double a14)
{
__int64 v18; // rax
int v19; // edx
double v20; // xmm4_8
double v21; // xmm5_8
__int64 v22; // rax
__int64 v23; // rdx

v18 = func1(a1, a2, a3);
v22 = func7(v18, v19, a4, a5, a6, a7, v20, v21, a10, a11, a12, a13, a14);
return func0(v22, v23, a3);
}

original_code:
Point3D Point3D_rotate_around_point(Point3D p, RotationVector rotation, Point3D center){
    return Point3D_add(
 Point3D_rotate(Point3D_subtract(p, center),rotation),
 center);
}

canonical_original_code:
struct Point3D Point3D_rotate_around_point(struct Point3D p, struct RotationVector rotation, struct Point3D center){
    return Point3D_add(
 Point3D_rotate(Point3D_subtract(p, center),rotation),
 center);
}

variable_types:
center
struct Point3D

user_defined_types: struct RotationVector { double rotX; double rotY; double rotZ; }


decompiled_code:
__int64 __fastcall Line3D_scale(int *a1, double a2)
{
__int64 result; // rax

*a1 = (int)((double)*a1 * a2);
a1[1] = (int)((double)a1[1] * a2);
a1[2] = (int)((double)a1[2] * a2);
a1[3] = (int)((double)a1[3] * a2);
a1[4] = (int)((double)a1[4] * a2);
result = (unsigned int)(int)(a2 * (double)a1[5]);
a1[5] = result;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func9(int *a1, double a2)
{
__int64 result; // rax

*a1 = (int)((double)*a1 * a2);
a1[1] = (int)((double)a1[1] * a2);
a1[2] = (int)((double)a1[2] * a2);
a1[3] = (int)((double)a1[3] * a2);
a1[4] = (int)((double)a1[4] * a2);
result = (unsigned int)(int)(a2 * (double)a1[5]);
a1[5] = result;
return result;
}

original_code:
void Line3D_scale(Line3D *line, double factor){
    line->p1.x = (int) line->p1.x * factor;
    line->p1.y = (int) line->p1.y * factor;
    line->p1.z = (int) line->p1.z * factor;
    line->p2.x = (int) line->p2.x * factor;
    line->p2.y = (int) line->p2.y * factor;
    line->p2.z = (int) line->p2.z * factor;
}

canonical_original_code:
void Line3D_scale(struct Line3D *line, double factor){
    line->p1.x = (int) line->p1.x * factor;
    line->p1.y = (int) line->p1.y * factor;
    line->p1.z = (int) line->p1.z * factor;
    line->p2.x = (int) line->p2.x * factor;
    line->p2.y = (int) line->p2.y * factor;
    line->p2.z = (int) line->p2.z * factor;
}

variable_types: struct Line3D { struct Point3D { int x; int y; int z; } p1; struct Point3D p2; } *

variable_types: factor double

user_defined_types: struct Line3D { struct Point3D p1; struct Point3D p2; }


decompiled_code:
__int64 __fastcall Line3D_vectorize(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6, __int64 a7, __int64 a8, int a9)
{
__int64 v10; // [rsp+0h] [rbp-14h]

LODWORD(v10) = HIDWORD(a8) - a7;
HIDWORD(v10) = a9 - HIDWORD(a7);
return v10;
}

canonical_decompiled_code:
__int64 __fastcall func10(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6, __int64 a7, __int64 a8, int a9)
{
__int64 v10; // [rsp+0h] [rbp-14h]

LODWORD(v10) = HIDWORD(a8) - a7;
HIDWORD(v10) = a9 - HIDWORD(a7);
return v10;
}

original_code:
Point3D Line3D_vectorize(Line3D line){
    Point3D p;
    p.x = line.p2.x - line.p1.x;
    p.y = line.p2.y - line.p1.y;
    p.z = line.p2.z - line.p1.z;
    return p;
}

canonical_original_code:
struct Point3D Line3D_vectorize(struct Line3D line){
    struct Point3D p;
    p.x = line.p2.x - line.p1.x;
    p.y = line.p2.y - line.p1.y;
    p.z = line.p2.z - line.p1.z;
    return p;
}

variable_types: struct Line3D { struct Point3D p1; struct Point3D p2; }

variable_types:
p
struct Point3D { int x; int y; int z; }


decompiled_code:
double __fastcall Line3D_length(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6, __int64 a7, __int128 a8)
{
return Point3D_distance(a7, a8, *(__int64 *)((char *)&a8 + 4), SHIDWORD(a8));
}

original_code:
double Line3D_length(Line3D line){
    return Point3D_distance(line.p1, line.p2);
}

canonical_original_code:
double Line3D_length(struct Line3D line){
    return Point3D_distance(line.p1, line.p2);
}

variable_types: struct Line3D { struct Point3D { int x; int y; int z; } p1; struct Point3D p2; }


decompiled_code:
__int64 __fastcall Line3D_midpoint(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6, __int64 a7, __int128 a8)
{
__int64 v8; // rax
__int64 v9; // rdx

v8 = Point3D_add(a7, (unsigned int)a8, *(__int64 *)((char *)&a8 + 4));
return Point3D_multiply(v8, v9, 0.5);
}

original_code:
Point3D Line3D_midpoint(Line3D line){
    Point3D sum = Point3D_add(line.p1, line.p2);
    return Point3D_multiply(sum, 0.5);
}

canonical_original_code:
struct Point3D Line3D_midpoint(struct Line3D line){
    struct Point3D sum = Point3D_add(line.p1, line.p2);
    return Point3D_multiply(sum, 0.5);
}

variable_types:
sum
struct Point3D { int x; int y; int z; }


decompiled_code:
__int64 __fastcall Point3D_dot_product(__int64 a1, int a2, __int64 a3, int a4)
{
return (unsigned int)(HIDWORD(a3) * HIDWORD(a1) + a1 * a3 + a4 * a2);
}

canonical_decompiled_code:
__int64 __fastcall func13(__int64 a1, int a2, __int64 a3, int a4)
{
return (unsigned int)(HIDWORD(a3) * HIDWORD(a1) + a1 * a3 + a4 * a2);
}

original_code:
int Point3D_dot_product(Point3D a, Point3D b){
    return a.x*b.x + a.y*b.y + a.z*b.z;
}

canonical_original_code:
int Point3D_dot_product(struct Point3D a, struct Point3D b){
    return a.x*b.x + a.y*b.y + a.z*b.z;
}

variable_types:
a
struct Point3D { int x; int y; int z; }

variable_types:
b
struct Point3D


decompiled_code:
__int64 __fastcall Point3D_cross_product(__int64 a1, int a2, __int64 a3, int a4)
{
__int64 v5; // [rsp+0h] [rbp-14h]

LODWORD(v5) = a4 * HIDWORD(a1) - HIDWORD(a3) * a2;
HIDWORD(v5) = a3 * a2 - a1 * a4;
return v5;
}

canonical_decompiled_code:
__int64 __fastcall func14(__int64 a1, int a2, __int64 a3, int a4)
{
__int64 v5; // [rsp+0h] [rbp-14h]

LODWORD(v5) = a4 * HIDWORD(a1) - HIDWORD(a3) * a2;
HIDWORD(v5) = a3 * a2 - a1 * a4;
return v5;
}

original_code:
Point3D Point3D_cross_product(Point3D a, Point3D b){
    Point3D result;
    result.x = a.y * b.z - a.z * b.y;
    result.y = a.z * b.x - a.x * b.z;
    result.z = a.x * b.y - a.y * b.x;
    return result;
}

canonical_original_code:
struct Point3D Point3D_cross_product(struct Point3D a, struct Point3D b){
    struct Point3D result;
    result.x = a.y * b.z - a.z * b.y;
    result.y = a.z * b.x - a.x * b.z;
    result.z = a.x * b.y - a.y * b.x;
    return result;
}

variable_types:
a
struct Point3D

variable_types:
result
struct Point3D { int x; int y; int z; }


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

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

original_code:
unsigned char get_red(Uint32 color){
    Uint32 mask = 255 << 0;
    return (color & mask) >> 0;
}

canonical_original_code:
unsigned char get_red(unsigned int color){
    unsigned int mask = 255 << 0;
    return (color & mask) >> 0;
}

variable_types:
color
unsigned int

variable_types:
mask
unsigned int

return_type: unsigned char


decompiled_code:
__int64 __fastcall get_green(unsigned int a1)
{
return a1 >> 8;
}

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

original_code:
unsigned char get_green(Uint32 color){
    Uint32 mask = 255 << 8;
    return (color & mask) >> 8;
}

canonical_original_code:
unsigned char get_green(unsigned int color){
    unsigned int mask = 255 << 8;
    return (color & mask) >> 8;
}


decompiled_code:
__int64 __fastcall get_blue(unsigned int a1)
{
return HIWORD(a1);
}

canonical_decompiled_code:
__int64 __fastcall func2(unsigned int a1)
{
return HIWORD(a1);
}

original_code:
unsigned char get_blue(Uint32 color){
    Uint32 mask = 255 << 16;
    return (color & mask) >> 16;
}

canonical_original_code:
unsigned char get_blue(unsigned int color){
    unsigned int mask = 255 << 16;
    return (color & mask) >> 16;
}


decompiled_code:
__int64 __fastcall set_red(int a1, unsigned __int8 a2)
{
LOBYTE(a1) = 0;
return a1 | (unsigned int)a2;
}

canonical_decompiled_code:
__int64 __fastcall func3(int a1, unsigned __int8 a2)
{
LOBYTE(a1) = 0;
return a1 | (unsigned int)a2;
}

original_code:
Uint32 set_red(Uint32 color, unsigned char red){
    Uint32 mask = 255 << 0;
    color &= ~mask;
    color |= red << 0;
    return color;
}

canonical_original_code:
unsigned int set_red(unsigned int color, unsigned char red){
    unsigned int mask = 255 << 0;
    color &= ~mask;
    color |= red << 0;
    return color;
}

variable_types:
red
unsigned char

return_type: unsigned int


decompiled_code:
__int64 __fastcall set_green(int a1, unsigned __int8 a2)
{
return a1 & 0xFFFF00FF | (a2 << 8);
}

canonical_decompiled_code:
__int64 __fastcall func4(int a1, unsigned __int8 a2)
{
return a1 & 0xFFFF00FF | (a2 << 8);
}

original_code:
Uint32 set_green(Uint32 color, unsigned char red){
    Uint32 mask = 255 << 8;
    color &= ~mask;
    color |= red << 8;
    return color;
}

canonical_original_code:
unsigned int set_green(unsigned int color, unsigned char red){
    unsigned int mask = 255 << 8;
    color &= ~mask;
    color |= red << 8;
    return color;
}


decompiled_code:
__int64 __fastcall set_blue(int a1, unsigned __int8 a2)
{
return a1 & 0xFF00FFFF | (a2 << 16);
}

canonical_decompiled_code:
__int64 __fastcall func5(int a1, unsigned __int8 a2)
{
return a1 & 0xFF00FFFF | (a2 << 16);
}

original_code:
Uint32 set_blue(Uint32 color, unsigned char red){
    Uint32 mask = 255 << 16;
    color &= ~mask;
    color |= red << 16;
    return color;
}

canonical_original_code:
unsigned int set_blue(unsigned int color, unsigned char red){
    unsigned int mask = 255 << 16;
    color &= ~mask;
    color |= red << 16;
    return color;
}


decompiled_code:
__int64 __fastcall set_opacity(int a1, int a2)
{
return (a2 << 24) | a1 & 0xFFFFFFu;
}

canonical_decompiled_code:
__int64 __fastcall func6(int a1, int a2)
{
return (a2 << 24) | a1 & 0xFFFFFFu;
}

original_code:
Uint32 set_opacity(Uint32 color, unsigned char opacity){
    Uint32 mask = 255 << 24;
    color = color & (~mask);
    color = color | (opacity << 24);
    return color;
}

canonical_original_code:
unsigned int set_opacity(unsigned int color, unsigned char opacity){
    unsigned int mask = 255 << 24;
    color = color & (~mask);
    color = color | (opacity << 24);
    return color;
}

variable_types:
opacity
unsigned char


decompiled_code:
__int64 __fastcall scale_color(unsigned int a1, float a2)
{
unsigned __int8 v2; // r12
unsigned __int8 v3; // bp
int v4; // eax
int v5; // eax
float v7; // [rsp+4h] [rbp-1Ch]

v2 = get_red(a1);
v3 = get_green(a1);
v7 = (float)(unsigned __int8)get_blue(a1) * a2;
v4 = set_red(a1, (int)(float)((float)v2 * a2));
v5 = set_green(v4, (int)(float)((float)v3 * a2));
return set_blue(v5, (int)v7);
}

canonical_decompiled_code:
__int64 __fastcall func7(unsigned int a1, float a2)
{
unsigned __int8 v2; // r12
unsigned __int8 v3; // bp
int v4; // eax
int v5; // eax
float v7; // [rsp+4h] [rbp-1Ch]

v2 = func0(a1);
v3 = func1(a1);
v7 = (float)(unsigned __int8)func2(a1) * a2;
v4 = func3(a1, (int)(float)((float)v2 * a2));
v5 = func4(v4, (int)(float)((float)v3 * a2));
return func5(v5, (int)v7);
}

original_code:
Uint32 scale_color(Uint32 color, float multiplier){
    unsigned char red = get_red(color);
    unsigned char green = get_green(color);
    unsigned char blue = get_blue(color);
    red *= multiplier;
    green *= multiplier;
    blue *= multiplier;
    color = set_red(color, red);
    color = set_green(color, green);
    color = set_blue(color, blue);
    return color;
}

canonical_original_code:
unsigned int scale_color(unsigned int color, float multiplier){
    unsigned char red = get_red(color);
    unsigned char green = get_green(color);
    unsigned char blue = get_blue(color);
    red *= multiplier;
    green *= multiplier;
    blue *= multiplier;
    color = set_red(color, red);
    color = set_green(color, green);
    color = set_blue(color, blue);
    return color;
}

variable_types: multiplier float

variable_types:
green
unsigned char

variable_types:
blue
unsigned char


canonical_original_code:
void AI_indicator(struct Object *obj, struct Scene *scene){
    obj->rotation.rotY += 3.14159265358979323846/100;
    obj->pos.y += 1*(((scene->time/100)%2)*2 - 1);
}

variable_types: struct Object { struct Point3D { int x; int y; int z; } pos; struct Model { struct Line3D { struct Point3D p1; struct Point3D p2; } line; struct Model *next; } *model; unsigned int color; struct RotationVector { double rotX; double rotY; double rotZ; } rotation; void (*ai)(struct Object *, struct Scene { struct SceneList { struct Object *obj; struct SceneList *next; } *objects; int time; } *); void *ai_data; void (*ai_data_free)(struct Object *); } *

variable_types:
scene
struct Scene *

user_defined_types: struct Object { struct Point3D pos; struct Model *model; unsigned int color; struct RotationVector rotation; void (*ai)(struct Object *, struct Scene *); void *ai_data; void (*ai_data_free)(struct Object *); }

user_defined_types: struct Model { struct Line3D line; struct Model *next; }

user_defined_types: struct Scene { struct SceneList *objects; int time; }


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

if ( a2 <= 0 )
result = 0LL;
else
result = ((unsigned __int64)(unsigned int)(HIDWORD(a1) * a3 / a2 + 400) << 32) | (unsigned int)((int)a1 * a3 / a2
+ 400);
return result;
}

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

if ( a2 <= 0 )
result = 0LL;
else
result = ((unsigned __int64)(unsigned int)(HIDWORD(a1) * a3 / a2 + 400) << 32) | (unsigned int)((int)a1 * a3 / a2
+ 400);
return result;
}

original_code:
Point2D project_point(Point3D point, int eye_distance){
    Point2D s;
    if (point.z <= 0){
 s.x = 0;
 s.y = 0;
 return s;
    }
    s.x = ((point.x * eye_distance) / (point.z)) + 800/2;
    s.y = ((point.y * eye_distance) / (point.z)) + 800/2;
    return s;
}

canonical_original_code:
struct Point2D project_point(struct Point3D point, int eye_distance){
    struct Point2D s;
    if (point.z <= 0){
 s.x = 0;
 s.y = 0;
 return s;
    }
    s.x = ((point.x * eye_distance) / (point.z)) + 800/2;
    s.y = ((point.y * eye_distance) / (point.z)) + 800/2;
    return s;
}

variable_types:
point
struct Point3D { int x; int y; int z; }

variable_types:
s
struct Point2D { int x; int y; }

return_type: struct Point2D { int x; int y; }

user_defined_types:
struct Point3D { int x; int y; int z; }
struct Point2D { int x; int y; }


decompiled_code:
__int64 gen_newcube()
{
__int64 v0; // rax
__int64 v1; // rax

v0 = Model_add(0LL);
v1 = Model_extrude(v0, 0x6400000000LL, 0LL, 1LL);
return Model_extrude(v1, 100LL, 0LL, 1LL);
}

canonical_decompiled_code:
__int64 func9()
{
__int64 v0; // rax
__int64 v1; // rax

v0 = Model_add(0LL);
v1 = Model_extrude(v0, 0x6400000000LL, 0LL, 1LL);
return Model_extrude(v1, 100LL, 0LL, 1LL);
}

original_code:
Model * gen_newcube(){
    Model *model;
    model = Model_add(((void *)0), (Line3D) {0,0,0,0,0,100});
    model = Model_extrude(model, (Point3D) {0,100,0},1);
    model = Model_extrude(model, (Point3D) {100, 0, 0},1);
    return model;
}

canonical_original_code:
struct Model *gen_newcube(){
    struct Model *model;
    model = Model_add(((void *)0), (struct Line3D) {0,0,0,0,0,100});
    model = Model_extrude(model, (struct Point3D) {0,100,0},1);
    model = Model_extrude(model, (struct Point3D) {100, 0, 0},1);
    return model;
}

variable_types: struct Model { struct Line3D { struct Point3D { int x; int y; int z; } p1; struct Point3D p2; } line; struct Model *next; } *


decompiled_code:
__int64 gen_arrow()
{
__int64 v0; // rax
__int64 v1; // rax
__int64 v2; // rax
__int64 v3; // rax
__int64 v4; // rax
__int64 v5; // rax
__int64 v6; // rax
__int64 v7; // rbx

v0 = Model_add(0LL);
v1 = Model_add(v0);
v2 = Model_add(v1);
v3 = Model_add(v2);
v4 = Model_add(v3);
v5 = Model_add(v4);
v6 = Model_add(v5);
v7 = Model_extrude(v6, 50LL, 0LL, 1LL);
Model_centerize(v7);
return v7;
}

canonical_decompiled_code:
__int64 func10()
{
__int64 v0; // rax
__int64 v1; // rax
__int64 v2; // rax
__int64 v3; // rax
__int64 v4; // rax
__int64 v5; // rax
__int64 v6; // rax
__int64 v7; // rbx

v0 = Model_add(0LL);
v1 = Model_add(v0);
v2 = Model_add(v1);
v3 = Model_add(v2);
v4 = Model_add(v3);
v5 = Model_add(v4);
v6 = Model_add(v5);
v7 = Model_extrude(v6, 50LL, 0LL, 1LL);
Model_centerize(v7);
return v7;
}

original_code:
Model * gen_arrow(){
    Model *model;
    model = Model_add(((void *)0), (Line3D) {0,0,0,0,0,50});
    model = Model_add(model, (Line3D) {0,50,0,0,0,0});
    model = Model_add(model, (Line3D) {0,50,50,0,0,50});
    model = Model_add(model, (Line3D) {0,50,-50,0,50,0});
    model = Model_add(model, (Line3D) {0,50,50,0,50,100});
    model = Model_add(model, (Line3D) {0,100,25,0,50,-50});
    model = Model_add(model, (Line3D) {0,100,25,0,50,100});
    model = Model_extrude(model, (Point3D) {50,0,0},1);
    Model_centerize(model);
    return model;
}

canonical_original_code:
struct Model *gen_arrow(){
    struct Model *model;
    model = Model_add(((void *)0), (struct Line3D) {0,0,0,0,0,50});
    model = Model_add(model, (struct Line3D) {0,50,0,0,0,0});
    model = Model_add(model, (struct Line3D) {0,50,50,0,0,50});
    model = Model_add(model, (struct Line3D) {0,50,-50,0,50,0});
    model = Model_add(model, (struct Line3D) {0,50,50,0,50,100});
    model = Model_add(model, (struct Line3D) {0,100,25,0,50,-50});
    model = Model_add(model, (struct Line3D) {0,100,25,0,50,100});
    model = Model_extrude(model, (struct Point3D) {50,0,0},1);
    Model_centerize(model);
    return model;
}

return_type: struct Model { struct Line3D { struct Point3D { int x; int y; int z; } p1; struct Point3D p2; } line; struct Model *next; } *


decompiled_code:
__int64 __fastcall Model_scale(__int64 a1, double a2)
{
__int64 i; // rbx
__int64 result; // rax

for ( i = a1; i; i = *(_QWORD *)(i + 24) )
result = Line3D_scale(i, a2);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, double a2)
{
__int64 i; // rbx
__int64 result; // rax

for ( i = a1; i; i = *(_QWORD *)(i + 24) )
result = Line3D_scale(i, a2);
return result;
}

original_code:
void Model_scale(Model *model, double factor){
    Model *current;
    for (current = model; current != ((void *)0); current= current->next){
        Line3D_scale(&current->line, factor);
    }
}

canonical_original_code:
void Model_scale(struct Model *model, double factor){
    struct Model *current;
    for (current = model; current != ((void *)0); current= current->next){
        Line3D_scale(&current->line, factor);
    }
}

variable_types: factor double


decompiled_code:
int __fastcall Model_print(unsigned int *a1)
{
unsigned int *v1; // rbx

v1 = a1;
puts("Model: {");
if ( a1 )
{
do
{
printf("Line: %d %d %d -> %d %d %d\n", *v1, v1[1], v1[2], v1[3], v1[4], v1[5]);
v1 = (unsigned int *)*((_QWORD *)v1 + 3);
}
while ( v1 );
}
return puts("} ");
}

canonical_decompiled_code:
int __fastcall func1(unsigned int *a1)
{
unsigned int *v1; // rbx

v1 = a1;
puts("Model: {");
if ( a1 )
{
do
{
printf("Line: %d %d %d -> %d %d %d\n", *v1, v1[1], v1[2], v1[3], v1[4], v1[5]);
v1 = (unsigned int *)*((_QWORD *)v1 + 3);
}
while ( v1 );
}
return puts("} ");
}

original_code:
void Model_print(Model *model){
    printf("Model: {\n");
    Model *current;
    for (current = model; current != ((void *)0); current = current->next){
 Line3D line = current->line;
 printf("Line: %d %d %d -> %d %d %d\n",
        line.p1.x, line.p1.y, line.p1.z,
        line.p2.x, line.p2.y, line.p2.z);
    }
    printf("} \n");
}

canonical_original_code:
void Model_print(struct Model *model){
    printf("Model: {\n");
    struct Model *current;
    for (current = model; current != ((void *)0); current = current->next){
 struct Line3D line = current->line;
 printf("Line: %d %d %d -> %d %d %d\n",
        line.p1.x, line.p1.y, line.p1.z,
        line.p2.x, line.p2.y, line.p2.z);
    }
    printf("} \n");
}

variable_types: struct Line3D { struct Point3D { int x; int y; int z; } p1; struct Point3D p2; }


decompiled_code:
void __fastcall Object_rotate(double *a1, float a2, float a3, float a4)
{
a1[4] = a2 + a1[4];
a1[5] = a3 + a1[5];
a1[6] = a4 + a1[6];
}

original_code:
void Object_rotate(Object *obj, float rotX, float rotY, float rotZ){
    obj->rotation.rotX += rotX;
    obj->rotation.rotY += rotY;
    obj->rotation.rotZ += rotZ;
}

canonical_original_code:
void Object_rotate(struct Object *obj, float rotX, float rotY, float rotZ){
    obj->rotation.rotX += rotX;
    obj->rotation.rotY += rotY;
    obj->rotation.rotZ += rotZ;
}

variable_types: rotX float

variable_types: rotY float

variable_types: rotZ float

user_defined_types: struct SceneList { struct Object *obj; struct SceneList *next; }


decompiled_code:
void __fastcall Model_shift(__int64 a1, __int64 a2, unsigned int a3)
{
__int64 i; // rbx
int v4; // edx
int v5; // edx

for ( i = a1; i; i = *(_QWORD *)(i + 24) )
{
*(_QWORD *)i = Point3D_add(*(_QWORD *)i, *(unsigned int *)(i + 8), a2, a3);
*(_DWORD *)(i + 8) = v4;
*(_QWORD *)(i + 12) = Point3D_add(*(_QWORD *)(i + 12), *(unsigned int *)(i + 20), a2, a3);
*(_DWORD *)(i + 20) = v5;
}
}

canonical_decompiled_code:
void __fastcall func3(__int64 a1, __int64 a2, unsigned int a3)
{
__int64 i; // rbx
int v4; // edx
int v5; // edx

for ( i = a1; i; i = *(_QWORD *)(i + 24) )
{
*(_QWORD *)i = Point3D_add(*(_QWORD *)i, *(unsigned int *)(i + 8), a2, a3);
*(_DWORD *)(i + 8) = v4;
*(_QWORD *)(i + 12) = Point3D_add(*(_QWORD *)(i + 12), *(unsigned int *)(i + 20), a2, a3);
*(_DWORD *)(i + 20) = v5;
}
}

original_code:
void Model_shift(Model *model, Point3D delta){
    Model *cur;
    for (cur = model; cur != ((void *)0);cur=cur->next){
 cur->line.p1 = Point3D_add(cur->line.p1, delta);
 cur->line.p2 = Point3D_add(cur->line.p2, delta);
    }
}

canonical_original_code:
void Model_shift(struct Model *model, struct Point3D delta){
    struct Model *cur;
    for (cur = model; cur != ((void *)0);cur=cur->next){
 cur->line.p1 = Point3D_add(cur->line.p1, delta);
 cur->line.p2 = Point3D_add(cur->line.p2, delta);
    }
}

variable_types:
delta
struct Point3D


original_code:
Model * Model_combine(Model *m1, Model *m2){
    Model *cur;
    for (cur=m1; cur->next != ((void *)0); cur=cur->next);
    cur->next = m2;
    return m1;
}

canonical_original_code:
struct Model *Model_combine(struct Model *m1, struct Model *m2){
    struct Model *cur;
    for (cur=m1; cur->next != ((void *)0); cur=cur->next);
    cur->next = m2;
    return m1;
}


decompiled_code:
__int64 __fastcall Model_duplicate_and_shift(__m128i *a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6)
{
__m128i *v6; // rbp
unsigned int v8; // [rsp+8h] [rbp-20h]

v8 = a3;
v6 = Model_duplicate(a1, a2, a3, a4, a5, a6);
Model_shift((__int64)v6, a2, v8);
return Model_combine((__int64)a1, (__int64)v6);
}

original_code:
Model * Model_duplicate_and_shift(Model *model, Point3D delta){
    Model *newlines = Model_duplicate(model);
    Model_shift(newlines, delta);
    return Model_combine(model, newlines);
}

canonical_original_code:
struct Model *Model_duplicate_and_shift(struct Model *model, struct Point3D delta){
    struct Model *newlines = Model_duplicate(model);
    Model_shift(newlines, delta);
    return Model_combine(model, newlines);
}

variable_types:
model
struct Model *


decompiled_code:
__int64 __fastcall Model_average_point(__int64 a1)
{
__int64 v1; // rbx
__int64 v2; // rsi
unsigned __int64 v3; // rcx
signed int v4; // edx
int v5; // ebp
__int64 v6; // rax
__int64 v7; // rdx
unsigned __int64 v8; // rax
__int64 v9; // rdx
__int64 v11; // [rsp+24h] [rbp-24h]

if ( a1 )
{
v1 = a1;
v2 = 0LL;
LODWORD(v3) = 0;
v4 = 0;
v5 = 0;
do
{
v6 = Point3D_add(__PAIR64__(v3, v4), v2, *(_QWORD *)v1, *(unsigned int *)(v1 + 8));
v8 = Point3D_add(v6, v7, *(_QWORD *)(v1 + 12), *(unsigned int *)(v1 + 20));
v2 = v9;
v4 = v8;
v3 = HIDWORD(v8);
v5 += 2;
v1 = *(_QWORD *)(v1 + 24);
}
while ( v1 );
}
else
{
LODWORD(v3) = 0;
v4 = 0;
v5 = 0;
}
LODWORD(v11) = v4 / v5;
HIDWORD(v11) = (int)v3 / v5;
return v11;
}

original_code:
Point3D Model_average_point(Model *model){
    Point3D sum = {0,0,0};
    int count = 0;
    Model *cur;
    for (cur=model; cur != ((void *)0); cur=cur->next){
 sum = Point3D_add(sum, cur->line.p1);
 sum = Point3D_add(sum, cur->line.p2);
 count += 2;
    }
    sum.x /= count;
    sum.y /= count;
    sum.z /= count;
    return sum;
}

canonical_original_code:
struct Point3D Model_average_point(struct Model *model){
    struct Point3D sum = {0,0,0};
    int count = 0;
    struct Model *cur;
    for (cur=model; cur != ((void *)0); cur=cur->next){
 sum = Point3D_add(sum, cur->line.p1);
 sum = Point3D_add(sum, cur->line.p2);
 count += 2;
    }
    sum.x /= count;
    sum.y /= count;
    sum.z /= count;
    return sum;
}

variable_types: struct Model { struct Line3D { struct Point3D p1; struct Point3D p2; } line; struct Model *next; } *

variable_types:
sum
struct Point3D { int x; int y; int z; }

variable_types: count int


decompiled_code:
void __fastcall Model_centerize(__int64 a1)
{
__int64 v1; // rax
unsigned int v2; // edx
__int64 v3; // rax
unsigned int v4; // edx

v1 = Model_average_point(a1);
v3 = Point3D_subtract(0LL, 0LL, v1, v2);
Model_shift(a1, v3, v4);
}

canonical_decompiled_code:
void __fastcall func7(__int64 a1)
{
__int64 v1; // rax
unsigned int v2; // edx
__int64 v3; // rax
unsigned int v4; // edx

v1 = func6(a1);
v3 = Point3D_subtract(0LL, 0LL, v1, v2);
func3(a1, v3, v4);
}

original_code:
void Model_centerize(Model *model){
    Point3D center = Model_average_point(model);
    Point3D origin = {0,0,0};
    Point3D delta = Point3D_subtract(origin, center);
    Model_shift(model, delta);
}

canonical_original_code:
void Model_centerize(struct Model *model){
    struct Point3D center = Model_average_point(model);
    struct Point3D origin = {0,0,0};
    struct Point3D delta = Point3D_subtract(origin, center);
    Model_shift(model, delta);
}

variable_types:
center
struct Point3D { int x; int y; int z; }

variable_types:
origin
struct Point3D { int x; int y; int z; }

variable_types:
delta
struct Point3D { int x; int y; int z; }


original_code:
Model * Model_extrude(Model *model, Point3D delta, int bothsides){
    Model *new_lines = ((void *)0);
    Model *cur;
    for (cur = model; cur != ((void *)0); cur = cur->next){
 Line3D shifted;
 shifted.p1 = Point3D_add(cur->line.p1, delta);
 shifted.p2 = Point3D_add(cur->line.p2, delta);
 Line3D l;
 l.p1 = cur->line.p1;
 l.p2 = shifted.p1;
 new_lines = Model_add(new_lines, shifted);
 new_lines = Model_add(new_lines, l);
 if (bothsides){
     l.p1 = cur->line.p2;
     l.p2 = shifted.p2;
     new_lines = Model_add(new_lines, l);
 }
    }
    model = Model_combine(new_lines, model);
    return model;
}

canonical_original_code:
struct Model *Model_extrude(struct Model *model, struct Point3D delta, int bothsides){
    struct Model *new_lines = ((void *)0);
    struct Model *cur;
    for (cur = model; cur != ((void *)0); cur = cur->next){
 struct Line3D shifted;
 shifted.p1 = Point3D_add(cur->line.p1, delta);
 shifted.p2 = Point3D_add(cur->line.p2, delta);
 struct Line3D l;
 l.p1 = cur->line.p1;
 l.p2 = shifted.p1;
 new_lines = Model_add(new_lines, shifted);
 new_lines = Model_add(new_lines, l);
 if (bothsides){
     l.p1 = cur->line.p2;
     l.p2 = shifted.p2;
     new_lines = Model_add(new_lines, l);
 }
    }
    model = Model_combine(new_lines, model);
    return model;
}

variable_types: bothsides int


decompiled_code:
void Scene_new()
{
;
}

canonical_decompiled_code:
void func0()
{
;
}

original_code:
Scene * Scene_new(){
    Scene *scene = malloc(sizeof(Scene));
    scene->objects = ((void *)0);
    scene->time = 0;
}

canonical_original_code:
struct Scene *Scene_new(){
    struct Scene *scene = malloc(sizeof(Scene));
    scene->objects = ((void *)0);
    scene->time = 0;
}

variable_types: struct Scene { struct SceneList { struct Object { struct Point3D { int x; int y; int z; } pos; struct Model { struct Line3D { struct Point3D p1; struct Point3D p2; } line; struct Model *next; } *model; unsigned int color; struct RotationVector { double rotX; double rotY; double rotZ; } rotation; void (*ai)(struct Object *, struct Scene *); void *ai_data; void (*ai_data_free)(struct Object *); } *obj; struct SceneList *next; } *objects; int time; } *


repo: SpenceSellers/microMC

decompiled_code:
size_t __fastcall encoded_MCString_len(const char *a1)
{
return 2 * strlen(a1) + 2;
}

canonical_decompiled_code:
size_t __fastcall func2(const char *a1)
{
return 2 * strlen(a1) + 2;
}

original_code:
size_t encoded_MCString_len(char *string){
    size_t slen = strlen(string);
    return 2 + (slen * 2);
}

canonical_original_code:
unsigned long encoded_MCString_len(char *string){
    unsigned long slen = strlen(string);
    return 2 + (slen * 2);
}

variable_types:
string
char *

variable_types:
slen
unsigned long

return_type: unsigned long


decompiled_code:
__int64 __fastcall write_int(unsigned int a1, _DWORD *a2)
{
*a2 = _bswap_32(a1);
return 4LL;
}

canonical_decompiled_code:
__int64 __fastcall func3(unsigned int a1, _DWORD *a2)
{
*a2 = func1(a1);
return 4LL;
}

original_code:
size_t write_int(int i, char *place){
    int bige_int = htonl(i);
    *(int*) place = bige_int;
    return 4;
}

canonical_original_code:
unsigned long write_int(int i, char *place){
    int bige_int = htonl(i);
    *(int *) place = bige_int;
    return 4;
}

variable_types: i int

variable_types:
place
char *


decompiled_code:
__int64 __fastcall write_short(__int16 a1, __int16 *a2)
{
*a2 = _bswap_16(a1);
return 2LL;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int16 a1, __int16 *a2)
{
*a2 = func0(a1);
return 2LL;
}

original_code:
size_t write_short(short s, char *place){
    short flipped = htons(s);
    *(short*) place = flipped;
    return 2;
}

canonical_original_code:
unsigned long write_short(short s, char *place){
    short flipped = htons(s);
    *(short *) place = flipped;
    return 2;
}

variable_types: s short

variable_types: flipped short


decompiled_code:
__int64 __fastcall write_char(char a1, _BYTE *a2)
{
*a2 = a1;
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func5(char a1, _BYTE *a2)
{
*a2 = a1;
return 1LL;
}

original_code:
size_t write_char(char c, char *place){
    *place = c;
    return 1;
}

canonical_original_code:
unsigned long write_char(char c, char *place){
    *place = c;
    return 1;
}

variable_types: c char


decompiled_code:
__int64 __fastcall write_compressed(__int64 a1, __int64 a2, __int64 a3, __int64 a4)
{
__int64 v5; // [rsp+8h] [rbp-10h] BYREF

v5 = a4;
if ( (unsigned int)compress(a3, &v5, a1, a2) == -4 )
logmsg(0LL, "Not enough memory given to compress data!");
return v5;
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1, __int64 a2, __int64 a3, __int64 a4)
{
__int64 v5; // [rsp+8h] [rbp-10h] BYREF

v5 = a4;
if ( (unsigned int)compress(a3, &v5, a1, a2) == -4 )
logmsg(0LL, "Not enough memory given to compress data!");
return v5;
}

original_code:
size_t write_compressed(char *data, size_t len, char *place, size_t maxlen){
    size_t written = maxlen;
    int e = compress((unsigned char *) place, &written,(Bytef *) data, len);
    if (e == (-4)){
 logmsg(0, "Not enough memory given to compress data!");
    }
    return written;
}

canonical_original_code:
unsigned long write_compressed(char *data, unsigned long len, char *place, unsigned long maxlen){
    unsigned long written = maxlen;
    int e = compress((unsigned char *) place, &written,(Bytef *) data, len);
    if (e == (-4)){
 logmsg(0, "Not enough memory given to compress data!");
    }
    return written;
}

variable_types:
data
char *

variable_types:
len
unsigned long

variable_types:
maxlen
unsigned long

variable_types:
written
unsigned long

variable_types: e int


decompiled_code:
__int64 __fastcall read_int(unsigned int *a1, _QWORD *a2)
{
if ( a2 )
*a2 += 4LL;
return _bswap_32(*a1);
}

canonical_decompiled_code:
__int64 __fastcall func7(unsigned int *a1, _QWORD *a2)
{
if ( a2 )
*a2 += 4LL;
return func1(*a1);
}

original_code:
int read_int(char *place, size_t *read){
    if (read) *read += 4;
    return ntohl(*( (int*) place));
}

canonical_original_code:
int read_int(char *place, unsigned long *read){
    if (read) *read += 4;
    return ntohl(*( (int *) place));
}

variable_types:
read
unsigned long *


decompiled_code:
__int16 __fastcall read_short(__int16 *a1, _QWORD *a2)
{
if ( a2 )
*a2 += 2LL;
return _bswap_16(*a1);
}

canonical_decompiled_code:
__int16 __fastcall func8(__int16 *a1, _QWORD *a2)
{
if ( a2 )
*a2 += 2LL;
return func0(*a1);
}

original_code:
short read_short(char *place, size_t *read){
    if (read) *read += 2;
    return ntohs(*( (short*) place));
}

canonical_original_code:
short read_short(char *place, unsigned long *read){
    if (read) *read += 2;
    return ntohs(*( (short *) place));
}

return_type: short


decompiled_code:
__int64 __fastcall read_char(unsigned __int8 *a1, _QWORD *a2)
{
if ( a2 )
++*a2;
return *a1;
}

canonical_decompiled_code:
__int64 __fastcall func9(unsigned __int8 *a1, _QWORD *a2)
{
if ( a2 )
++*a2;
return *a1;
}

original_code:
char read_char(char *place, size_t *read){
    if (read) *read += 1;
    return *place;
}

canonical_original_code:
char read_char(char *place, unsigned long *read){
    if (read) *read += 1;
    return *place;
}

return_type: char


decompiled_code:
float __fastcall swap_float_endian(__m128i a1)
{
__int16 v1; // ax
float v3; // [rsp+0h] [rbp-4h]

v1 = _mm_cvtsi128_si32(a1);
LOBYTE(v3) = (unsigned int)_mm_cvtsi128_si32(a1) >> 24;
BYTE1(v3) = (unsigned int)(_mm_cvtsi128_si32(a1) << 8) >> 24;
BYTE2(v3) = HIBYTE(v1);
HIBYTE(v3) = v1;
return v3;
}

canonical_decompiled_code:
float __fastcall func10(__m128i a1)
{
__int16 v1; // ax
float v3; // [rsp+0h] [rbp-4h]

v1 = _mm_cvtsi128_si32(a1);
LOBYTE(v3) = (unsigned int)_mm_cvtsi128_si32(a1) >> 24;
BYTE1(v3) = (unsigned int)(_mm_cvtsi128_si32(a1) << 8) >> 24;
BYTE2(v3) = HIBYTE(v1);
HIBYTE(v3) = v1;
return v3;
}

original_code:
float swap_float_endian(float f){
    float result;
    char *fchars = (char*) &f;
    char *rchars = (char*) &result;
    rchars[0] = fchars[3];
    rchars[1] = fchars[2];
    rchars[2] = fchars[1];
    rchars[3] = fchars[0];
    return result;
}

variable_types: f float

variable_types: result float

variable_types:
fchars
char *

variable_types:
rchars
char *


decompiled_code:
__int64 __fastcall write_float(float *a1, __m128i a2)
{
*a1 = swap_float_endian(a2);
return 4LL;
}

canonical_decompiled_code:
__int64 __fastcall func11(float *a1, __m128i a2)
{
*a1 = func10(a2);
return 4LL;
}

original_code:
size_t write_float(float f, char *place){
    float flipped = swap_float_endian(f);
    *(float*) place = flipped;
    return 4;
}

canonical_original_code:
unsigned long write_float(float f, char *place){
    float flipped = swap_float_endian(f);
    *(float *) place = flipped;
    return 4;
}

variable_types: flipped float


decompiled_code:
float __fastcall read_float(unsigned int *a1, _QWORD *a2)
{
__m128i v2; // xmm0

v2 = (__m128i)*a1;
if ( a2 )
*a2 += 4LL;
return swap_float_endian(v2);
}

canonical_decompiled_code:
float __fastcall func12(unsigned int *a1, _QWORD *a2)
{
__m128i v2; // xmm0

v2 = (__m128i)*a1;
if ( a2 )
*a2 += 4LL;
return func10(v2);
}

original_code:
float read_float(char *place, size_t *read){
    float f = *(float*) place;
    if (read) *read += 4;
    return swap_float_endian(f);
}

canonical_original_code:
float read_float(char *place, unsigned long *read){
    float f = *(float*) place;
    if (read) *read += 4;
    return swap_float_endian(f);
}


original_code:
double swap_double_endian(double f){
    double result;
    char *fchars = (char*) &f;
    char *rchars = (char*) &result;
    rchars[0] = fchars[7];
    rchars[1] = fchars[6];
    rchars[2] = fchars[5];
    rchars[3] = fchars[4];
    rchars[4] = fchars[3];
    rchars[5] = fchars[2];
    rchars[6] = fchars[1];
    rchars[7] = fchars[0];
    return result;
}

variable_types: f double

variable_types: result double


decompiled_code:
__int64 __fastcall write_double(double *a1, __m128i a2)
{
*a1 = swap_double_endian(a2);
return 8LL;
}

canonical_decompiled_code:
__int64 __fastcall func14(double *a1, __m128i a2)
{
*a1 = func13(a2);
return 8LL;
}

original_code:
size_t write_double(double d, char *place){
    double flipped = swap_double_endian(d);
    *(double*) place = flipped;
    return 8;
}

canonical_original_code:
unsigned long write_double(double d, char *place){
    double flipped = swap_double_endian(d);
    *(double *) place = flipped;
    return 8;
}

variable_types: d double

variable_types:
place
char *

variable_types: flipped double


decompiled_code:
double __fastcall read_double(unsigned __int64 *a1, _QWORD *a2)
{
__m128i v2; // xmm0

v2 = (__m128i)*a1;
if ( a2 )
*a2 += 8LL;
return swap_double_endian(v2);
}

canonical_decompiled_code:
double __fastcall func15(unsigned __int64 *a1, _QWORD *a2)
{
__m128i v2; // xmm0

v2 = (__m128i)*a1;
if ( a2 )
*a2 += 8LL;
return func13(v2);
}

original_code:
double read_double(char *place, size_t *read){
    double d = *(double*) place;
    if (read) *read += 8;
    return swap_double_endian(d);
}

canonical_original_code:
double read_double(char *place, unsigned long *read){
    double d = *(double*) place;
    if (read) *read += 8;
    return swap_double_endian(d);
}


decompiled_code:
__int64 __fastcall pack_halfchars(int a1, int a2)
{
return a2 & (unsigned int)(16 * a1);
}

canonical_decompiled_code:
__int64 __fastcall func16(int a1, int a2)
{
return a2 & (unsigned int)(16 * a1);
}

original_code:
char pack_halfchars(char a, char b){
    return (a << 4) & b;
}

variable_types: a char

variable_types: b char


decompiled_code:
char *__fastcall fake_json_chat(char *src)
{
size_t v1; // rax
char *v2; // rbx

v1 = strlen(src);
v2 = (char *)malloc(v1 + 12);
*v2 = 0;
strcat(v2, "{\"text\":\"");
strcat(v2, src);
strcat(v2, "\"}");
return v2;
}

canonical_decompiled_code:
char *__fastcall func17(char *src)
{
size_t v1; // rax
char *v2; // rbx

v1 = strlen(src);
v2 = (char *)malloc(v1 + 12);
*v2 = 0;
strcat(v2, "{\"text\":\"");
strcat(v2, src);
strcat(v2, "\"}");
return v2;
}

original_code:
char * fake_json_chat(char *str){
    char *before = "{\"text\":\"";
    char *after = "\"}";
    char *fake_json = malloc(sizeof(char) * (strlen(before) + strlen(after) + strlen(str) + 1));
    fake_json[0] = 0;
    strcat(fake_json, before);
    strcat(fake_json, str);
    strcat(fake_json, after);
    return fake_json;
}

canonical_original_code:
char *fake_json_chat(char *str){
    char *before = "{\"text\":\"";
    char *after = "\"}";
    char *fake_json = malloc(sizeof(char) * (strlen(before) + strlen(after) + strlen(str) + 1));
    fake_json[0] = 0;
    strcat(fake_json, before);
    strcat(fake_json, str);
    strcat(fake_json, after);
    return fake_json;
}

variable_types:
str
char *

variable_types:
before
char *

variable_types:
after
char *

return_type: char *


decompiled_code:
__int64 __fastcall to_fixed_point(double a1)
{
return (unsigned int)(int)(a1 * 32.0);
}

canonical_decompiled_code:
__int64 __fastcall func18(double a1)
{
return (unsigned int)(int)(a1 * 32.0);
}

original_code:
int to_fixed_point(double d){
    return (int) (d*32);
}


decompiled_code:
double __fastcall from_fixed_point(int a1)
{
return (double)a1 * 0.03125;
}

canonical_decompiled_code:
double __fastcall func19(int a1)
{
return (double)a1 * 0.03125;
}

original_code:
double from_fixed_point(int i){
    return ((double) i)/32;
}

variable_types: i int


decompiled_code:
int __fastcall debug_list_players(__int64 a1)
{
int result; // eax
__int64 v2; // rbx
__int64 v3; // rax

result = printf("%d players logged in.\n", *(unsigned int *)(a1 + 152));
if ( *(int *)(a1 + 152) > 0 )
{
v2 = 0LL;
do
{
v3 = *(_QWORD *)(*(_QWORD *)(a1 + 160) + 8 * v2);
result = printf(
"Index %d, Player: %s, eid: %d, socket %d \n",
(unsigned int)v2++,
*(const char **)(v3 + 56),
*(unsigned int *)(v3 + 64),
*(unsigned int *)(v3 + 68));
}
while ( *(_DWORD *)(a1 + 152) > (int)v2 );
}
return result;
}

canonical_decompiled_code:
int __fastcall func0(__int64 a1)
{
int result; // eax
__int64 v2; // rbx
__int64 v3; // rax

result = printf("%d players logged in.\n", *(unsigned int *)(a1 + 152));
if ( *(int *)(a1 + 152) > 0 )
{
v2 = 0LL;
do
{
v3 = *(_QWORD *)(*(_QWORD *)(a1 + 160) + 8 * v2);
result = printf(
"Index %d, Player: %s, eid: %d, socket %d \n",
(unsigned int)v2++,
*(const char **)(v3 + 56),
*(unsigned int *)(v3 + 64),
*(unsigned int *)(v3 + 68));
}
while ( *(_DWORD *)(a1 + 152) > (int)v2 );
}
return result;
}

original_code:
void debug_list_players(Server *server){
    int i;
    printf("%d players logged in.\n", server->num_players);
    for (i=0; i < server->num_players; i++){
 Player *p = server->players[i];
 printf("Index %d, Player: %s, eid: %d, socket %d \n",
        i, p->username, p->entity_id, p->socket);
    }
}

canonical_original_code:
void debug_list_players(struct Server *server){
    int i;
    printf("%d players logged in.\n", server->num_players);
    for (i=0; i < server->num_players; i++){
 struct Player *p = server->players[i];
 printf("Index %d, Player: %s, eid: %d, socket %d \n",
        i, p->username, p->entity_id, p->socket);
    }
}

variable_types: struct Server { union pthread_rwlock_t { struct __pthread_rwlock_arch_t { unsigned int __readers; unsigned int __writers; unsigned int __wrphase_futex; unsigned int __writers_futex; unsigned int __pad3; unsigned int __pad4; int __cur_writer; int __shared; char __rwelision; unsigned char __pad1[7]; unsigned long __pad2; unsigned int __flags; } __data; char __size[56]; long __align; } state_lock; char is_running; long time; int last_entity_id; int spawnx; int spawny; int spawnz; unsigned long max_players; union pthread_rwlock_t players_lock; int num_players; struct Player { union pthread_rwlock_t lock; char *username; int entity_id; int socket; struct Inventory { unsigned long size; struct Slot { short id; char count; short damage; short nbt_len; char *nbt; } **slots; } *inventory; int held_slot_num; double x; double y; double z; float yaw; float pitch; double last_x; double last_y; double last_z; } **players; union pthread_rwlock_t map_lock; struct Map { unsigned long xchunks; unsigned long zchunks; struct Chunk { struct Block { unsigned char id; unsigned char metadata; } blocks[-1]; char biome_data[-1]; } **chunks; } *map; char *filename; unsigned long distributor_thread; int distributor_socket; } *

variable_types: struct Player { union pthread_rwlock_t { struct __pthread_rwlock_arch_t { unsigned int __readers; unsigned int __writers; unsigned int __wrphase_futex; unsigned int __writers_futex; unsigned int __pad3; unsigned int __pad4; int __cur_writer; int __shared; char __rwelision; unsigned char __pad1[7]; unsigned long __pad2; unsigned int __flags; } __data; char __size[56]; long __align; } lock; char *username; int entity_id; int socket; struct Inventory { unsigned long size; struct Slot { short id; char count; short damage; short nbt_len; char *nbt; } **slots; } *inventory; int held_slot_num; double x; double y; double z; float yaw; float pitch; double last_x; double last_y; double last_z; } *

user_defined_types: struct Server { union pthread_rwlock_t state_lock; char is_running; long time; int last_entity_id; int spawnx; int spawny; int spawnz; unsigned long max_players; union pthread_rwlock_t players_lock; int num_players; struct Player **players; union pthread_rwlock_t map_lock; struct Map *map; char *filename; unsigned long distributor_thread; int distributor_socket; }

user_defined_types: struct Player { union pthread_rwlock_t lock; char *username; int entity_id; int socket; struct Inventory *inventory; int held_slot_num; double x; double y; double z; float yaw; float pitch; double last_x; double last_y; double last_z; }

user_defined_types: union pthread_rwlock_t { struct __pthread_rwlock_arch_t __data; char __size[56]; long __align; }

user_defined_types: struct Map { unsigned long xchunks; unsigned long zchunks; struct Chunk **chunks; }

user_defined_types: struct Inventory { unsigned long size; struct Slot **slots; }

user_defined_types: struct Chunk { struct Block blocks[-1]; char biome_data[-1]; }


decompiled_code:
bool __fastcall Server_is_full(__int64 a1)
{
return (unsigned __int64)*(int *)(a1 + 152) >= *(_QWORD *)(a1 + 88);
}

canonical_decompiled_code:
bool __fastcall func2(__int64 a1)
{
return (unsigned __int64)*(int *)(a1 + 152) >= *(_QWORD *)(a1 + 88);
}

original_code:
char Server_is_full(Server *server){
    if (server->num_players >= server->max_players) return 1;
    else return 0;
}

canonical_original_code:
char Server_is_full(struct Server *server){
    if (server->num_players >= server->max_players) return 1;
    else return 0;
}

user_defined_types: struct __pthread_rwlock_arch_t { unsigned int __readers; unsigned int __writers; unsigned int __wrphase_futex; unsigned int __writers_futex; unsigned int __pad3; unsigned int __pad4; int __cur_writer; int __shared; char __rwelision; unsigned char __pad1[7]; unsigned long __pad2; unsigned int __flags; }

user_defined_types: struct Block { unsigned char id; unsigned char metadata; }

user_defined_types: struct Slot { short id; char count; short damage; short nbt_len; char *nbt; }


decompiled_code:
__int64 __fastcall get_index_of_player(__int64 a1, __int64 a2)
{
int v2; // edx
__int64 v3; // rdi
__int64 v4; // rax
unsigned int v5; // ecx

v2 = *(_DWORD *)(a1 + 152);
if ( v2 <= 0 )
return (unsigned int)-1;
v3 = *(_QWORD *)(a1 + 160);
v4 = 0LL;
while ( 1 )
{
v5 = v4;
if ( *(_QWORD *)(v3 + 8 * v4) == a2 )
break;
if ( ++v4 == v2 )
return (unsigned int)-1;
}
return v5;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, __int64 a2)
{
int v2; // edx
__int64 v3; // rdi
__int64 v4; // rax
unsigned int v5; // ecx

v2 = *(_DWORD *)(a1 + 152);
if ( v2 <= 0 )
return (unsigned int)-1;
v3 = *(_QWORD *)(a1 + 160);
v4 = 0LL;
while ( 1 )
{
v5 = v4;
if ( *(_QWORD *)(v3 + 8 * v4) == a2 )
break;
if ( ++v4 == v2 )
return (unsigned int)-1;
}
return v5;
}

original_code:
int get_index_of_player(Server *server, Player *player){
    int i;
    for (i=0; i < server->num_players; i++){
 if (server->players[i] == player){
     return i;
 }
    }
    return -1;
}

canonical_original_code:
int get_index_of_player(struct Server *server, struct Player *player){
    int i;
    for (i=0; i < server->num_players; i++){
 if (server->players[i] == player){
     return i;
 }
    }
    return -1;
}

variable_types:
player
struct Player *


decompiled_code:
__int64 __fastcall send_player_positions(__int64 a1)
{
__int64 i; // r13
__int64 result; // rax
__int64 j; // rbx

for ( i = 0LL; *(_DWORD *)(a1 + 152) > (int)i; ++i )
{
for ( j = 0LL; *(_DWORD *)(a1 + 152) > (int)j; ++j )
{
result = *(_QWORD *)(a1 + 160);
if ( *(_QWORD *)(result + 8 * i) != *(_QWORD *)(result + 8 * j) )
result = Player_send_player_position();
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1)
{
__int64 i; // r13
__int64 result; // rax
__int64 j; // rbx

for ( i = 0LL; *(_DWORD *)(a1 + 152) > (int)i; ++i )
{
for ( j = 0LL; *(_DWORD *)(a1 + 152) > (int)j; ++j )
{
result = *(_QWORD *)(a1 + 160);
if ( *(_QWORD *)(result + 8 * i) != *(_QWORD *)(result + 8 * j) )
result = Player_send_player_position();
}
}
return result;
}

original_code:
void send_player_positions(Server *server){
    int i;
    int j;
    for (i=0; i < server->num_players; i++){
 for(j=0; j < server->num_players; j++){
     if (server->players[i] == server->players[j]) continue;
     Player_send_player_position(server->players[i], server->players[j]);
 }
    }
}

canonical_original_code:
void send_player_positions(struct Server *server){
    int i;
    int j;
    for (i=0; i < server->num_players; i++){
 for(j=0; j < server->num_players; j++){
     if (server->players[i] == server->players[j]) continue;
     Player_send_player_position(server->players[i], server->players[j]);
 }
    }
}

variable_types: j int


original_code:
void Server_tick(Server *server){
    server->time++;
    if (server->time % 20 == 0) {
 int i;
 for(i=0; i < server->num_players; i++){
     Player_send_keep_alive(server->players[i]);
 }
    }
    send_player_positions(server);
    int i;
    for(i=0; i < server->num_players; i++){
 Player_tick_lastlocation(server->players[i]);
    }
}

canonical_original_code:
void Server_tick(struct Server *server){
    server->time++;
    if (server->time % 20 == 0) {
 int i;
 for(i=0; i < server->num_players; i++){
     Player_send_keep_alive(server->players[i]);
 }
    }
    send_player_positions(server);
    int i;
    for(i=0; i < server->num_players; i++){
 Player_tick_lastlocation(server->players[i]);
    }
}