SiguienteTurno

decompiled_code:
__int64 SiguienteTurno()
{
int v0; // er13
int v1; // ebx
__int64 v2; // r12
int v3; // ebp
__int64 result; // rax

v0 = fichasxturno[modo];
v1 = turno;
v2 = 7LL * modo;
while ( 1 )
{
v1 += v0;
turno = v1;
if ( !turnos[v2 + v1] )
{
turno = 0;
v1 = 0;
}
v3 = TotalFichasTurno(v1);
if ( v3 )
{
result = TotalFichasEnBase(v1);
if ( (_DWORD)result != v3 )
break;
}
}
return result;
}

canonical_decompiled_code:
__int64 func12()
{
int v0; // er13
int v1; // ebx
__int64 v2; // r12
int v3; // ebp
__int64 result; // rax

v0 = fichasxturno[modo];
v1 = turno;
v2 = 7LL * modo;
while ( 1 )
{
v1 += v0;
turno = v1;
if ( !turnos[v2 + v1] )
{
turno = 0;
v1 = 0;
}
v3 = func4(v1);
if ( v3 )
{
result = func8(v1);
if ( (_DWORD)result != v3 )
break;
}
}
return result;
}

original_code:
void SiguienteTurno()
{
 int totalfichasturno = 0;
 do
 {
  if (turnos[modo][turno+=fichasxturno[modo]] == 0){turno = 0;}
  totalfichasturno = TotalFichasTurno(turno);
 }
 while((totalfichasturno==0)||(totalfichasturno==TotalFichasEnBase(turno)));
}

variable_types: totalfichasturno int


PintarTablero

repo: joseprous/damas-chinas

decompiled_code:
int *__fastcall PintarTablero(int a1)
{
__int64 v2; // rdi
int *result; // rax
char *v4; // rdi
__int64 v5; // rcx
__int64 v6; // rsi

v2 = 80LL * (a1 - 2);
result = (int *)((char *)&iniciales + v2);
v4 = (char *)&iniciales + v2 + 80;
do
{
v5 = *result;
v6 = result[1];
result += 2;
tablero[13 * v5 + v6] = a1;
}
while ( result != (int *)v4 );
return result;
}

canonical_decompiled_code:
int *__fastcall func13(int a1)
{
__int64 v2; // rdi
int *result; // rax
char *v4; // rdi
__int64 v5; // rcx
__int64 v6; // rsi

v2 = 80LL * (a1 - 2);
result = (int *)((char *)&iniciales + v2);
v4 = (char *)&iniciales + v2 + 80;
do
{
v5 = *result;
v6 = result[1];
result += 2;
tablero[13 * v5 + v6] = a1;
}
while ( result != (int *)v4 );
return result;
}

original_code:
void PintarTablero(int ficha)
{
 int i,j;
 i = (ficha-2);
 for (j=0;j<(10*2);j+=2)
 {
  tablero[iniciales[i][j]][iniciales[i][j+1]] = ficha;
 }
}

canonical_original_code:
void PintarTablero(int ficha)
{
 int i; int j;
 i = (ficha-2);
 for (j=0;j<(10*2);j+=2)
 {
  tablero[iniciales[i][j]][iniciales[i][j+1]] = ficha;
 }
}

variable_types: ficha int

variable_types: i int

variable_types: j int

return_type: void


InicializarTablero

decompiled_code:
__int64 InicializarTablero()
{
__int64 result; // rax
int i; // edi
int v2; // er9

result = 7LL * modo;
for ( i = turnos[7 * modo]; i; i = turnos[result] )
{
PintarTablero(i);
result = v2 + 1 + 8LL * modo - modo;
}
return result;
}

canonical_decompiled_code:
__int64 func14()
{
__int64 result; // rax
int i; // edi
int v2; // er9

result = 7LL * modo;
for ( i = turnos[7 * modo]; i; i = turnos[result] )
{
func13(i);
result = v2 + 1 + 8LL * modo - modo;
}
return result;
}

original_code:
void InicializarTablero()
{
 int i = 0;
 while(turnos[modo][i]!=0)
 {
  PintarTablero(turnos[modo][i]);
  i++;
 }
}


CreateGrid

repo: joseprous/kianagy

decompiled_code:
int __fastcall CreateGrid(__int64 a1, unsigned int a2)
{
__int64 v4; // rsi
unsigned int v5; // ecx
int v6; // eax
__int64 v7; // rdi
__int64 v8; // rsi
__int64 v9; // rbx
unsigned int i; // ebp
unsigned int v11; // er12

v4 = *((unsigned int *)&size + 2);
v5 = (int)*(double *)(a1 + 16);
LODWORD(start) = (int)*(double *)a1;
v6 = (int)*(double *)(a1 + 8);
v7 = size;
*((_DWORD *)&start + 2) = v5;
HIDWORD(start) = v6;
object = CreateWorldObject(v7, v4, start, v5);
v8 = object;
v9 = *(_QWORD *)(*(_QWORD *)(a1 + 24) + 8LL);
if ( v9 )
{
for ( i = 0; ; ++i )
{
v11 = i + 1;
BrushToGrid(*(_QWORD *)(v9 + 16), v8, a2);
v9 = *(_QWORD *)(v9 + 24);
printf("%d...\n", i);
if ( !v9 )
break;
v8 = object;
}
}
else
{
v11 = 0;
}
return printf("Brushes = %d\n", v11);
}

canonical_decompiled_code:
int __fastcall func0(__int64 a1, unsigned int a2)
{
__int64 v4; // rsi
unsigned int v5; // ecx
int v6; // eax
__int64 v7; // rdi
__int64 v8; // rsi
__int64 v9; // rbx
unsigned int i; // ebp
unsigned int v11; // er12

v4 = *((unsigned int *)&size + 2);
v5 = (int)*(double *)(a1 + 16);
LODWORD(start) = (int)*(double *)a1;
v6 = (int)*(double *)(a1 + 8);
v7 = size;
*((_DWORD *)&start + 2) = v5;
HIDWORD(start) = v6;
object = CreateWorldObject(v7, v4, start, v5);
v8 = object;
v9 = *(_QWORD *)(*(_QWORD *)(a1 + 24) + 8LL);
if ( v9 )
{
for ( i = 0; ; ++i )
{
v11 = i + 1;
BrushToGrid(*(_QWORD *)(v9 + 16), v8, a2);
v9 = *(_QWORD *)(v9 + 24);
printf("%d...\n", i);
if ( !v9 )
break;
v8 = object;
}
}
else
{
v11 = 0;
}
return printf("Brushes = %d\n", v11);
}

original_code:
void CreateGrid(struct map *m,int mode)
{
 int i;
 struct brushlist *bl;
 start.x = m->start.x;
 start.y = m->start.y;
 start.z = m->start.z;
 object = CreateWorldObject(size,start);
 i=0;
 bl=m->entities->ent.brushes;
 while(bl)
 {
  BrushToGrid(bl->bsh,object,mode);
  bl=bl->next;
  printf("%d...\n",i++);
 }
 printf("Brushes = %d\n",i);
}

canonical_original_code:
void CreateGrid(struct map *m, int mode)
{
 int i;
 struct brushlist *bl;
 start.x = m->start.x;
 start.y = m->start.y;
 start.z = m->start.z;
 object = CreateWorldObject(size,start);
 i=0;
 bl=m->entities->ent.brushes;
 while(bl)
 {
  BrushToGrid(bl->bsh,object,mode);
  bl=bl->next;
  printf("%d...\n",i++);
 }
 printf("Brushes = %d\n",i);
}

variable_types: struct map { struct vector { double x; } start; struct entitylist { struct entity { struct headerlist { char *str1; struct headerlist *next; } *header; struct brushlist { int used; struct rawbrush { int num; struct points { struct vector p[3]; } *planes; struct texture { char *name; } *textures; } *rbsh; struct brush { unsigned long draw; int num; struct poly { int num; struct vector *vertexes; struct vector center; struct vector normal; struct texture tex; } *polys; } *bsh; struct brushlist *next; } *brushes; } ent; struct entitylist *next; } *entities; } *

variable_types: mode int

variable_types: struct brushlist { int used; struct rawbrush { int num; struct points { struct vector { double x; } p[3]; } *planes; struct texture { char *name; } *textures; } *rbsh; struct brush { unsigned long draw; int num; struct poly { int num; struct vector *vertexes; struct vector center; struct vector normal; struct texture tex; } *polys; } *bsh; struct brushlist *next; } *

user_defined_types: struct map { struct vector start; struct entitylist *entities; }

user_defined_types: struct brushlist { int used; struct rawbrush *rbsh; struct brush *bsh; struct brushlist *next; }

user_defined_types: struct entitylist { struct entity ent; struct entitylist *next; }

user_defined_types: struct rawbrush { int num; struct points *planes; struct texture *textures; }

user_defined_types: struct brush { unsigned long draw; int num; struct poly *polys; }

user_defined_types: struct entity { struct headerlist *header; struct brushlist *brushes; }


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v4; // eax
const char *v5; // rdi
int v6; // eax
const char *v7; // rdi
int v8; // eax
const char *v9; // rdi
unsigned int v10; // eax
int v11; // eax

if ( argc == 7 )
{
v4 = atoi(argv[3]);
v5 = argv[4];
LODWORD(size) = v4;
v6 = atoi(v5);
v7 = argv[5];
HIDWORD(size) = v6;
v8 = atoi(v7);
v9 = argv[1];
*((_DWORD *)&size + 2) = v8;
if ( (unsigned int)parsemap(v9) )
{
v10 = atoi(argv[6]);
printf(
"Map has been parsed, size = (%d,%d,%d) on %d mode.\n",
(unsigned int)size,
HIDWORD(size),
*((unsigned int *)&size + 2),
v10);
v11 = atoi(argv[6]);
CreateGrid(currentmap, v11);
ObjectToFile(object, argv[2]);
DestroyWorldObject(object);
}
}
else
{
puts("usage: test <input.map:file> <output.bcf:file> <x:integer> <y:integer> <z:integer> <mode:bin>");
}
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v4; // eax
const char *v5; // rdi
int v6; // eax
const char *v7; // rdi
int v8; // eax
const char *v9; // rdi
unsigned int v10; // eax
int v11; // eax

if ( argc == 7 )
{
v4 = atoi(argv[3]);
v5 = argv[4];
LODWORD(size) = v4;
v6 = atoi(v5);
v7 = argv[5];
HIDWORD(size) = v6;
v8 = atoi(v7);
v9 = argv[1];
*((_DWORD *)&size + 2) = v8;
if ( (unsigned int)parsemap(v9) )
{
v10 = atoi(argv[6]);
printf(
"Map has been parsed, size = (%d,%d,%d) on %d mode.\n",
(unsigned int)size,
HIDWORD(size),
*((unsigned int *)&size + 2),
v10);
v11 = atoi(argv[6]);
func0(currentmap, v11);
ObjectToFile(object, argv[2]);
DestroyWorldObject(object);
}
}
else
{
puts("usage: test <input.map:file> <output.bcf:file> <x:integer> <y:integer> <z:integer> <mode:bin>");
}
return 0;
}

original_code:
int main(int argc, char** argv)
{
 if(argc!=7){
  printf("usage: test <input.map:file> <output.bcf:file> <x:integer> <y:integer> <z:integer> <mode:bin>\n");
  return 0;
 }
 size.x = atoi(argv[3]);
 size.y = atoi(argv[4]);
 size.z = atoi(argv[5]);
 if(!parsemap(argv[1]))return 0;
 printf("Map has been parsed, size = (%d,%d,%d) on %d mode.\n",size.x,size.y,size.z,atoi(argv[6]));
 CreateGrid(currentmap,atoi(argv[6]));
 ObjectToFile(object,argv[2]);
 DestroyWorldObject(object);
   return 0;
}

canonical_original_code:
int main(int argc, char **argv)
{
 if(argc!=7){
  printf("usage: test <input.map:file> <output.bcf:file> <x:integer> <y:integer> <z:integer> <mode:bin>\n");
  return 0;
 }
 size.x = atoi(argv[3]);
 size.y = atoi(argv[4]);
 size.z = atoi(argv[5]);
 if(!parsemap(argv[1]))return 0;
 printf("Map has been parsed, size = (%d,%d,%d) on %d mode.\n",size.x,size.y,size.z,atoi(argv[6]));
 CreateGrid(currentmap,atoi(argv[6]));
 ObjectToFile(object,argv[2]);
 DestroyWorldObject(object);
   return 0;
}

variable_types: argc int

variable_types:
argv
char **

return_type: int


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

if ( !(unsigned int)ReadMD2Model("models/pknight/w_sshotgun.md2", &weapons)
|| !(unsigned int)ReadMD2Model("models/pknight/w_rlauncher.md2", (unsigned int)((_DWORD)&weapons + 120))
|| !(unsigned int)ReadMD2Model("models/pknight/a_grenades.md2", (unsigned int)((_DWORD)&weapons + 240))
|| !(unsigned int)ReadMD2Model("models/pknight/w_bfg.md2", (unsigned int)((_DWORD)&weapons + 360))
|| !(unsigned int)ReadMD2Model("models/pknight/w_chaingun.md2", (unsigned int)((_DWORD)&weapons + 480))
|| !(unsigned int)ReadMD2Model("models/pknight/w_glauncher.md2", (unsigned int)((_DWORD)&weapons + 600))
|| !(unsigned int)ReadMD2Model("models/pknight/w_hyperblaster.md2", (unsigned int)((_DWORD)&weapons + 720))
|| !(unsigned int)ReadMD2Model("models/pknight/w_railgun.md2", (unsigned int)((_DWORD)&weapons + 840))
|| !(unsigned int)ReadMD2Model("models/pknight/w_shotgun.md2", (unsigned int)((_DWORD)&weapons + 960))
|| !(unsigned int)ReadMD2Model("models/pknight/w_blaster.md2", (unsigned int)((_DWORD)&weapons + 1080))
|| !(unsigned int)ReadMD2Model("models/pknight/w_grapple.md2", (unsigned int)((_DWORD)&weapons + 1200))
|| (result = ReadMD2Model("models/pknight/w_machinegun.md2", (unsigned int)((_DWORD)&weapons + 1320)),
!(_DWORD)result) )
{
exit(1);
}
return result;
}

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

if ( !(unsigned int)ReadMD2Model("models/pknight/w_sshotgun.md2", &weapons)
|| !(unsigned int)ReadMD2Model("models/pknight/w_rlauncher.md2", (unsigned int)((_DWORD)&weapons + 120))
|| !(unsigned int)ReadMD2Model("models/pknight/a_grenades.md2", (unsigned int)((_DWORD)&weapons + 240))
|| !(unsigned int)ReadMD2Model("models/pknight/w_bfg.md2", (unsigned int)((_DWORD)&weapons + 360))
|| !(unsigned int)ReadMD2Model("models/pknight/w_chaingun.md2", (unsigned int)((_DWORD)&weapons + 480))
|| !(unsigned int)ReadMD2Model("models/pknight/w_glauncher.md2", (unsigned int)((_DWORD)&weapons + 600))
|| !(unsigned int)ReadMD2Model("models/pknight/w_hyperblaster.md2", (unsigned int)((_DWORD)&weapons + 720))
|| !(unsigned int)ReadMD2Model("models/pknight/w_railgun.md2", (unsigned int)((_DWORD)&weapons + 840))
|| !(unsigned int)ReadMD2Model("models/pknight/w_shotgun.md2", (unsigned int)((_DWORD)&weapons + 960))
|| !(unsigned int)ReadMD2Model("models/pknight/w_blaster.md2", (unsigned int)((_DWORD)&weapons + 1080))
|| !(unsigned int)ReadMD2Model("models/pknight/w_grapple.md2", (unsigned int)((_DWORD)&weapons + 1200))
|| (result = ReadMD2Model("models/pknight/w_machinegun.md2", (unsigned int)((_DWORD)&weapons + 1320)),
!(_DWORD)result) )
{
exit(1);
}
return result;
}

original_code:
void load_weapons()
{
 if (!ReadMD2Model ("models/pknight/w_sshotgun.md2", &weapons[0])) exit (1);
 if (!ReadMD2Model ("models/pknight/w_rlauncher.md2", &weapons[1])) exit (1);
 if (!ReadMD2Model ("models/pknight/a_grenades.md2", &weapons[2])) exit (1);
 if (!ReadMD2Model ("models/pknight/w_bfg.md2", &weapons[3])) exit (1);
 if (!ReadMD2Model ("models/pknight/w_chaingun.md2", &weapons[4])) exit (1);
 if (!ReadMD2Model ("models/pknight/w_glauncher.md2", &weapons[5])) exit (1);
 if (!ReadMD2Model ("models/pknight/w_hyperblaster.md2", &weapons[6])) exit (1);
 if (!ReadMD2Model ("models/pknight/w_railgun.md2", &weapons[7])) exit (1);
 if (!ReadMD2Model ("models/pknight/w_shotgun.md2", &weapons[8])) exit (1);
 if (!ReadMD2Model ("models/pknight/w_blaster.md2", &weapons[9])) exit (1);
 if (!ReadMD2Model ("models/pknight/w_grapple.md2", &weapons[10])) exit (1);
 if (!ReadMD2Model ("models/pknight/w_machinegun.md2", &weapons[11])) exit (1);
}


original_code:
void load_models()
{
 if (!ReadMD2Model ("models/Ogros.md2", &models[0].md2file)) exit (1);
 models[0].fps=10;
 models[0].iniframes[360]=40;
 models[0].endframes[360]=45;
 models[0].iniframes[90]=40;
 models[0].endframes[90]=45;
 models[0].iniframes[270]=40;
 models[0].endframes[270]=45;
 models[0].iniframes[180]=40;
 models[0].endframes[180]=45;
 models[0].iniframes[1]=0;
 models[0].endframes[1]=39;
 models[0].iniframes[12]=0;
 models[0].endframes[12]=39;
 models[0].hasweapon=0;
 if (!ReadMD2Model ("models/pknight/tris.md2", &models[2].md2file)) exit (1);
 models[2].fps=10;
 models[2].iniframes[360]=40;
 models[2].endframes[360]=45;
 models[2].iniframes[90]=40;
 models[2].endframes[90]=45;
 models[2].iniframes[270]=40;
 models[2].endframes[270]=45;
 models[2].iniframes[180]=40;
 models[2].endframes[180]=45;
 models[2].iniframes[1]=0;
 models[2].endframes[1]=39;
 models[2].iniframes[12]=46;
 models[2].endframes[12]=53;
 models[2].hasweapon=1;
 if (!ReadMD2Model ("models/Gargoyle.md2", &models[1].md2file)) exit (1);
 models[1].fps=30;
 models[1].iniframes[8]=20;
 models[1].endframes[8]=34;
 models[1].hasweapon=0;
 load_weapons();
}


drawplayer

decompiled_code:
__int64 __fastcall drawplayer(__int64 a1)
{
__int64 v2; // rax
double v3; // xmm1_8
__int64 v4; // rax
__int64 v5; // rsi
__int64 v6; // rdi
float v7; // xmm0_4

glPushMatrix();
glTranslatef(*(float *)(a1 + 20), *(float *)(a1 + 28), *(float *)(a1 + 24));
glPushMatrix();
glRotatef(*(float *)(a1 + 32), 0.0, 0.0, 1.0);
if ( *(_DWORD *)a1 )
{
glCallList(transport_list);
glPopMatrix();
if ( *(_DWORD *)a1 )
return glPopMatrix();
goto LABEL_7;
}
glTranslatef(0.0, 0.0, 8.0);
glFrontFace(2304LL);
v2 = *(int *)(a1 + 8);
v3 = (double)models[754 * v2 + 31];
v4 = *(int *)(a1 + 40) + 754 * v2;
v5 = (unsigned int)models[v4 + 393];
v6 = (unsigned int)models[v4 + 32];
v7 = (curent_time - last_time) * v3 + *(float *)(a1 + 332);
*(float *)(a1 + 332) = v7;
Animate(v6, v5, a1 + 328, a1 + 332);
RenderFrameItpWithGLCmds(
*(unsigned int *)(a1 + 328),
&models[754 * *(int *)(a1 + 8)],
*(float *)(a1 + 332),
*(float *)(a1 + 32));
if ( models[754 * *(int *)(a1 + 8) + 30] )
RenderFrameItpWithGLCmds(
*(unsigned int *)(a1 + 328),
(char *)&weapons + 120 * *(int *)(a1 + 12),
*(float *)(a1 + 332),
*(float *)(a1 + 32));
glPopMatrix();
if ( !*(_DWORD *)a1 )
{
LABEL_7:
glColor3f(0.0, 0.0);
glPushMatrix();
glDisable(2912LL);
glRasterPos3f(0.0, 0.0, 40.0);
glPrint("(%d) %s", *(unsigned int *)(a1 + 16), (const char *)(a1 + 301));
if ( (unsigned int)SDL_GetTicks() <= *(_DWORD *)(a1 + 320) + 10000 )
{
glRasterPos3f(0.0, 0.0, 50.0);
glPrint("%s", (const char *)(a1 + 44));
}
glEnable(2912LL);
glPopMatrix();
}
return glPopMatrix();
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1)
{
__int64 v2; // rax
double v3; // xmm1_8
__int64 v4; // rax
__int64 v5; // rsi
__int64 v6; // rdi
float v7; // xmm0_4

glPushMatrix();
glTranslatef(*(float *)(a1 + 20), *(float *)(a1 + 28), *(float *)(a1 + 24));
glPushMatrix();
glRotatef(*(float *)(a1 + 32), 0.0, 0.0, 1.0);
if ( *(_DWORD *)a1 )
{
glCallList(transport_list);
glPopMatrix();
if ( *(_DWORD *)a1 )
return glPopMatrix();
goto LABEL_7;
}
glTranslatef(0.0, 0.0, 8.0);
glFrontFace(2304LL);
v2 = *(int *)(a1 + 8);
v3 = (double)models[754 * v2 + 31];
v4 = *(int *)(a1 + 40) + 754 * v2;
v5 = (unsigned int)models[v4 + 393];
v6 = (unsigned int)models[v4 + 32];
v7 = (curent_time - last_time) * v3 + *(float *)(a1 + 332);
*(float *)(a1 + 332) = v7;
Animate(v6, v5, a1 + 328, a1 + 332);
RenderFrameItpWithGLCmds(
*(unsigned int *)(a1 + 328),
&models[754 * *(int *)(a1 + 8)],
*(float *)(a1 + 332),
*(float *)(a1 + 32));
if ( models[754 * *(int *)(a1 + 8) + 30] )
RenderFrameItpWithGLCmds(
*(unsigned int *)(a1 + 328),
(char *)&weapons + 120 * *(int *)(a1 + 12),
*(float *)(a1 + 332),
*(float *)(a1 + 32));
glPopMatrix();
if ( !*(_DWORD *)a1 )
{
LABEL_7:
glColor3f(0.0, 0.0);
glPushMatrix();
glDisable(2912LL);
glRasterPos3f(0.0, 0.0, 40.0);
glPrint("(%d) %s", *(unsigned int *)(a1 + 16), (const char *)(a1 + 301));
if ( (unsigned int)SDL_GetTicks() <= *(_DWORD *)(a1 + 320) + 10000 )
{
glRasterPos3f(0.0, 0.0, 50.0);
glPrint("%s", (const char *)(a1 + 44));
}
glEnable(2912LL);
glPopMatrix();
}
return glPopMatrix();
}

original_code:
void drawplayer(struct player *p)
{
 glPushMatrix();
  glTranslatef(p->x,p->y,p->z);
  glPushMatrix();
   glRotatef(p->dir,0,0,1);
   if(p->tipo==0){
    glTranslatef(0,0,8);
    glFrontFace(0x0900);
    p->interp+=models[p->model].fps * (curent_time - last_time);
    Animate (models[p->model].iniframes[p->acc], models[p->model].endframes[p->acc], &p->n, &p->interp);
    RenderFrameItpWithGLCmds (p->n, p->interp, &models[p->model].md2file,p->dir);
    if(models[p->model].hasweapon){
     RenderFrameItpWithGLCmds (p->n, p->interp, &weapons[p->weapon],p->dir);
    }
   }else{
    glCallList(transport_list);
   }
  glPopMatrix();
  if(p->tipo==0){
   glColor3f(0,0,0);
   glPushMatrix();
    glDisable(0x0B60);
    glRasterPos3f( 0,0, 40 );
    glPrint( "(%d) %s",p->hp,p->name);
    if(SDL_GetTicks()<=p->txt_ini_time+10000){
     glRasterPos3f( 0,0,50);
     glPrint( "%s",p->txt);
    }
    glEnable(0x0B60);
   glPopMatrix();
  }
 glPopMatrix();
}

variable_types: struct player { int tipo; int id; int model; int weapon; int hp; float x; float dir; float vel; int acc; char txt[-1]; char name[-1]; int txt_ini_time; int alive; int n; float interp; struct player *next; } *


drawpj

decompiled_code:
__int64 drawpj()
{
__int64 v0; // rdx
__int64 v1; // rax
__int64 v2; // r8
__int64 v3; // rcx
float v4; // xmm0_4
__int64 v5; // rax

glPushMatrix();
glTranslatef(*(float *)(pj + 20LL), *(float *)(pj + 28LL), *(float *)(pj + 24LL));
glPushMatrix();
glRotatef(COERCE_FLOAT(pj_ang ^ LC22), 0.0, 0.0, 1.0);
glTranslatef(0.0, 0.0, 8.0);
glFrontFace(2304LL);
v0 = pj;
v1 = *(int *)(pj + 8LL);
v2 = pj + 328LL;
v3 = pj + 332LL;
v4 = (curent_time - last_time) * (double)models[754 * v1 + 31] + *(float *)(pj + 332LL);
*(float *)(pj + 332LL) = v4;
v5 = *(int *)(v0 + 40) + 754 * v1;
Animate((unsigned int)models[v5 + 32], (unsigned int)models[v5 + 393], v2, v3);
RenderFrameItpWithGLCmds(
*(unsigned int *)(pj + 328LL),
&models[754 * *(int *)(pj + 8LL)],
*(float *)(pj + 332LL),
COERCE_FLOAT(pj_ang ^ LC22));
if ( models[754 * *(int *)(pj + 8LL) + 30] )
RenderFrameItpWithGLCmds(
*(unsigned int *)(pj + 328LL),
(char *)&weapons + 120 * *(int *)(pj + 12LL),
*(float *)(pj + 332LL),
COERCE_FLOAT(pj_ang ^ LC22));
glPopMatrix();
glColor3f(0.0, 0.0);
glPushMatrix();
glRasterPos3f(0.0, 0.0, 40.0);
glPrint("(%d) %s", *(unsigned int *)(pj + 16LL), (const char *)(pj + 301LL));
if ( (unsigned int)SDL_GetTicks() <= *(_DWORD *)(pj + 320LL) + 10000 )
{
glRasterPos3f(0.0, 0.0, 50.0);
glPrint("%s", (const char *)(pj + 44LL));
}
glPopMatrix();
return glPopMatrix();
}

canonical_decompiled_code:
__int64 func3()
{
__int64 v0; // rdx
__int64 v1; // rax
__int64 v2; // r8
__int64 v3; // rcx
float v4; // xmm0_4
__int64 v5; // rax

glPushMatrix();
glTranslatef(*(float *)(pj + 20LL), *(float *)(pj + 28LL), *(float *)(pj + 24LL));
glPushMatrix();
glRotatef(COERCE_FLOAT(pj_ang ^ LC22), 0.0, 0.0, 1.0);
glTranslatef(0.0, 0.0, 8.0);
glFrontFace(2304LL);
v0 = pj;
v1 = *(int *)(pj + 8LL);
v2 = pj + 328LL;
v3 = pj + 332LL;
v4 = (curent_time - last_time) * (double)models[754 * v1 + 31] + *(float *)(pj + 332LL);
*(float *)(pj + 332LL) = v4;
v5 = *(int *)(v0 + 40) + 754 * v1;
Animate((unsigned int)models[v5 + 32], (unsigned int)models[v5 + 393], v2, v3);
RenderFrameItpWithGLCmds(
*(unsigned int *)(pj + 328LL),
&models[754 * *(int *)(pj + 8LL)],
*(float *)(pj + 332LL),
COERCE_FLOAT(pj_ang ^ LC22));
if ( models[754 * *(int *)(pj + 8LL) + 30] )
RenderFrameItpWithGLCmds(
*(unsigned int *)(pj + 328LL),
(char *)&weapons + 120 * *(int *)(pj + 12LL),
*(float *)(pj + 332LL),
COERCE_FLOAT(pj_ang ^ LC22));
glPopMatrix();
glColor3f(0.0, 0.0);
glPushMatrix();
glRasterPos3f(0.0, 0.0, 40.0);
glPrint("(%d) %s", *(unsigned int *)(pj + 16LL), (const char *)(pj + 301LL));
if ( (unsigned int)SDL_GetTicks() <= *(_DWORD *)(pj + 320LL) + 10000 )
{
glRasterPos3f(0.0, 0.0, 50.0);
glPrint("%s", (const char *)(pj + 44LL));
}
glPopMatrix();
return glPopMatrix();
}

original_code:
void drawpj()
{
  glPushMatrix();
   glTranslatef(pj->x,pj->y,pj->z);
   glPushMatrix();
    glRotatef(-pj_ang,0,0,1);
    glTranslatef(0,0,8);
    glFrontFace(0x0900);
    pj->interp+=models[pj->model].fps * (curent_time - last_time);
    Animate (models[pj->model].iniframes[pj->acc], models[pj->model].endframes[pj->acc], &pj->n, &pj->interp);
    RenderFrameItpWithGLCmds (pj->n, pj->interp, &models[pj->model].md2file,-pj_ang);
    if(models[pj->model].hasweapon){
     RenderFrameItpWithGLCmds (pj->n, pj->interp, &weapons[pj->weapon],-pj_ang);
    }
   glPopMatrix();
   glColor3f(0,0,0);
   glPushMatrix();
    glRasterPos3f( 0,0, 40);
    glPrint( "(%d) %s",pj->hp,pj->name);
    if(SDL_GetTicks()<=pj->txt_ini_time+10000){
     glRasterPos3f( 0,0, 50 );
     glPrint( "%s",pj->txt);
    }
   glPopMatrix();
  glPopMatrix();
}


salir

decompiled_code:
void __noreturn salir()
{
send_msg(3LL);
exit(0);
}

canonical_decompiled_code:
void __noreturn func0()
{
send_msg(3LL);
exit(0);
}

original_code:
void salir()
{
 send_msg(3);
 exit (0);
}

canonical_original_code:
void salir()
{
 send_msg(3);
 exit (0);
}


otherkeys

decompiled_code:
__int64 otherkeys()
{
_BYTE *v0; // rax
unsigned int v1; // er8
__int64 result; // rax

v0 = (_BYTE *)SDL_GetKeyState(0LL);
if ( v0[100] )
{
send_msg(270LL);
result = 1LL;
}
else if ( v0[97] )
{
send_msg(90LL);
result = 1LL;
}
else if ( v0[119] )
{
send_msg(360LL);
result = 1LL;
}
else
{
if ( !v0[115] )
{
if ( v0[113] )
{
if ( !fly )
{
LABEL_7:
v1 = 0;
if ( v0[32] )
{
send_msg(5LL);
v1 = 1;
}
return v1;
}
send_msg(9LL);
v1 = 1;
}
else
{
if ( !v0[101] || !fly )
goto LABEL_7;
send_msg(10LL);
v1 = 1;
}
return v1;
}
send_msg(180LL);
result = 1LL;
}
return result;
}

canonical_decompiled_code:
__int64 func1()
{
_BYTE *v0; // rax
unsigned int v1; // er8
__int64 result; // rax

v0 = (_BYTE *)SDL_GetKeyState(0LL);
if ( v0[100] )
{
send_msg(270LL);
result = 1LL;
}
else if ( v0[97] )
{
send_msg(90LL);
result = 1LL;
}
else if ( v0[119] )
{
send_msg(360LL);
result = 1LL;
}
else
{
if ( !v0[115] )
{
if ( v0[113] )
{
if ( !fly )
{
LABEL_7:
v1 = 0;
if ( v0[32] )
{
send_msg(5LL);
v1 = 1;
}
return v1;
}
send_msg(9LL);
v1 = 1;
}
else
{
if ( !v0[101] || !fly )
goto LABEL_7;
send_msg(10LL);
v1 = 1;
}
return v1;
}
send_msg(180LL);
result = 1LL;
}
return result;
}

original_code:
int otherkeys()
{
 Uint8 * keystate;
 keystate = SDL_GetKeyState(((void *)0));
 if(keystate[SDLK_d]){
  send_msg(270);
  return 1;
 }
 if(keystate[SDLK_a]){
  send_msg(90);
  return 1;
 }
 if(keystate[SDLK_w]){
  send_msg(360);
  return 1;
 }
 if(keystate[SDLK_s]){
  send_msg(180);
  return 1;
 }
 if(keystate[SDLK_q]){
  if(fly){
   send_msg(9);
   return 1;
  }
 }
 if(keystate[SDLK_e]){
  if(fly){
   send_msg(10);
   return 1;
  }
 }
 if(keystate[SDLK_SPACE]){
  send_msg(5);
  return 1;
 }
 return 0;
}

canonical_original_code:
int otherkeys()
{
 unsigned char *keystate;
 keystate = SDL_GetKeyState(((void *)0));
 if(keystate[SDLK_d]){
  send_msg(270);
  return 1;
 }
 if(keystate[SDLK_a]){
  send_msg(90);
  return 1;
 }
 if(keystate[SDLK_w]){
  send_msg(360);
  return 1;
 }
 if(keystate[SDLK_s]){
  send_msg(180);
  return 1;
 }
 if(keystate[SDLK_q]){
  if(fly){
   send_msg(9);
   return 1;
  }
 }
 if(keystate[SDLK_e]){
  if(fly){
   send_msg(10);
   return 1;
  }
 }
 if(keystate[SDLK_SPACE]){
  send_msg(5);
  return 1;
 }
 return 0;
}

variable_types:
keystate
unsigned char *


decompiled_code:
__int64 handle_events()
{
__int64 result; // rax
char v1; // al
char v2; // al
int v3; // eax
double v4; // xmm1_8
unsigned int v5; // eax
__int16 v6; // bx
int v7; // eax
double v8; // xmm1_8
unsigned int v9; // ebx

while ( 2 )
{
result = SDL_PollEvent(&event);
if ( (_DWORD)result )
{
LABEL_2:
switch ( event )
{
case 2:
v5 = *((_DWORD *)&event + 2);
if ( escribiendo )
{
switch ( v5 )
{
case 0xDu:
escribiendo = 0;
send_txt();
pj_txtbuf = 0;
SDL_EnableUNICODE(0LL);
break;
case 0x1Bu:
pj_txtbuf = 0;
escribiendo = 0;
SDL_EnableUNICODE(0LL);
break;
case 8u:
*(&pj_txtbuf + (int)(strlen(&pj_txtbuf) - 1)) = 0;
break;
default:
v6 = *((_WORD *)&event + 8);
if ( (v6 & 0xFF80) == 0 && v6 )
{
v7 = strlen(&pj_txtbuf);
if ( v6 == 59 )
LOBYTE(v6) = 44;
*(&pj_txtbuf + v7) = v6;
*(&pj_txtbuf + v7 + 1) = 0;
}
break;
}
}
else if ( v5 > 0x77 )
{
if ( v5 == 275 )
{
rotcam(-10.0, 0.0);
}
else if ( v5 == 276 )
{
rotcam(10.0, 0.0);
}
}
else if ( v5 > 0x1A )
{
switch ( v5 )
{
case 0x1Bu:
goto LABEL_59;
case 0x20u:
send_msg(5LL);
continue;
case 0x31u:
send_msg2(12LL, &unk_63C);
continue;
case 0x32u:
send_msg2(12LL, &unk_63E);
continue;
case 0x61u:
send_msg(90LL);
continue;
case 0x63u:
banvf = 0;
continue;
case 0x64u:
send_msg(270LL);
continue;
case 0x65u:
if ( fly )
send_msg(10LL);
continue;
case 0x66u:
if ( fly )
{
send_msg(11LL);
fly = 0;
}
else
{
send_msg(8LL);
fly = 1;
}
continue;
case 0x71u:
if ( fly )
send_msg(9LL);
continue;
case 0x73u:
send_msg(180LL);
continue;
case 0x74u:
pj_txtbuf = 0;
escribiendo = 1;
SDL_EnableUNICODE(1LL);
continue;
case 0x77u:
send_msg(360LL);
continue;
default:
continue;
}
}
continue;
case 3:
if ( !(unsigned int)otherkeys() )
{
*(_DWORD *)(pj + 36LL) = 0;
send_msg(1LL);
}
continue;
case 4:
v3 = mover;
if ( mover == 2 )
{
HIDWORD(v8) = 0;
*(float *)&v8 = (float)*((__int16 *)&event + 5);
rotcam((float)*((__int16 *)&event + 4), v8);
pj_ang = cam_ang;
v9 = lastmsg + 25;
if ( v9 < (unsigned int)SDL_GetTicks() )
otherkeys();
v3 = mover;
}
if ( v3 == 1 )
{
HIDWORD(v4) = 0;
*(float *)&v4 = (float)*((__int16 *)&event + 5);
rotcam((float)*((__int16 *)&event + 4), v4);
}
continue;
case 5:
v2 = *(&event + 2);
if ( v2 == 1 )
{
mover = 1;
}
else if ( v2 == 3 )
{
mover = 2;
cam_ang = pj_ang;
rotcam(0.0, 0.0);
}
continue;
case 6:
v1 = *(&event + 2);
if ( (v1 & 0xFD) != 1 )
{
if ( v1 != 5 )
goto LABEL_5;
LABEL_35:
cam_dist = cam_dist + 10.0;
rotcam(0.0, 0.0);
v1 = *(&event + 2);
goto LABEL_5;
}
mover = 0;
if ( !(unsigned int)otherkeys() )
send_msg(1LL);
v1 = *(&event + 2);
if ( v1 == 5 )
goto LABEL_35;
LABEL_5:
if ( v1 != 4 )
continue;
cam_dist = fmaxf(10.0, cam_dist - 10.0);
rotcam(0.0, 0.0);
result = SDL_PollEvent(&event);
if ( !(_DWORD)result )
return result;
goto LABEL_2;
case 12:
LABEL_59:
salir();
return result;
default:
continue;
}
}
return result;
}
}

canonical_decompiled_code:
__int64 func2()
{
__int64 result; // rax
char v1; // al
char v2; // al
int v3; // eax
double v4; // xmm1_8
unsigned int v5; // eax
__int16 v6; // bx
int v7; // eax
double v8; // xmm1_8
unsigned int v9; // ebx

while ( 2 )
{
result = SDL_PollEvent(&event);
if ( (_DWORD)result )
{
LABEL_2:
switch ( event )
{
case 2:
v5 = *((_DWORD *)&event + 2);
if ( escribiendo )
{
switch ( v5 )
{
case 0xDu:
escribiendo = 0;
send_txt();
pj_txtbuf = 0;
SDL_EnableUNICODE(0LL);
break;
case 0x1Bu:
pj_txtbuf = 0;
escribiendo = 0;
SDL_EnableUNICODE(0LL);
break;
case 8u:
*(&pj_txtbuf + (int)(strlen(&pj_txtbuf) - 1)) = 0;
break;
default:
v6 = *((_WORD *)&event + 8);
if ( (v6 & 0xFF80) == 0 && v6 )
{
v7 = strlen(&pj_txtbuf);
if ( v6 == 59 )
LOBYTE(v6) = 44;
*(&pj_txtbuf + v7) = v6;
*(&pj_txtbuf + v7 + 1) = 0;
}
break;
}
}
else if ( v5 > 0x77 )
{
if ( v5 == 275 )
{
rotcam(-10.0, 0.0);
}
else if ( v5 == 276 )
{
rotcam(10.0, 0.0);
}
}
else if ( v5 > 0x1A )
{
switch ( v5 )
{
case 0x1Bu:
goto LABEL_59;
case 0x20u:
send_msg(5LL);
continue;
case 0x31u:
send_msg2(12LL, &unk_63C);
continue;
case 0x32u:
send_msg2(12LL, &unk_63E);
continue;
case 0x61u:
send_msg(90LL);
continue;
case 0x63u:
banvf = 0;
continue;
case 0x64u:
send_msg(270LL);
continue;
case 0x65u:
if ( fly )
send_msg(10LL);
continue;
case 0x66u:
if ( fly )
{
send_msg(11LL);
fly = 0;
}
else
{
send_msg(8LL);
fly = 1;
}
continue;
case 0x71u:
if ( fly )
send_msg(9LL);
continue;
case 0x73u:
send_msg(180LL);
continue;
case 0x74u:
pj_txtbuf = 0;
escribiendo = 1;
SDL_EnableUNICODE(1LL);
continue;
case 0x77u:
send_msg(360LL);
continue;
default:
continue;
}
}
continue;
case 3:
if ( !(unsigned int)func1() )
{
*(_DWORD *)(pj + 36LL) = 0;
send_msg(1LL);
}
continue;
case 4:
v3 = mover;
if ( mover == 2 )
{
HIDWORD(v8) = 0;
*(float *)&v8 = (float)*((__int16 *)&event + 5);
rotcam((float)*((__int16 *)&event + 4), v8);
pj_ang = cam_ang;
v9 = lastmsg + 25;
if ( v9 < (unsigned int)SDL_GetTicks() )
func1();
v3 = mover;
}
if ( v3 == 1 )
{
HIDWORD(v4) = 0;
*(float *)&v4 = (float)*((__int16 *)&event + 5);
rotcam((float)*((__int16 *)&event + 4), v4);
}
continue;
case 5:
v2 = *(&event + 2);
if ( v2 == 1 )
{
mover = 1;
}
else if ( v2 == 3 )
{
mover = 2;
cam_ang = pj_ang;
rotcam(0.0, 0.0);
}
continue;
case 6:
v1 = *(&event + 2);
if ( (v1 & 0xFD) != 1 )
{
if ( v1 != 5 )
goto LABEL_5;
LABEL_35:
cam_dist = cam_dist + 10.0;
rotcam(0.0, 0.0);
v1 = *(&event + 2);
goto LABEL_5;
}
mover = 0;
if ( !(unsigned int)func1() )
send_msg(1LL);
v1 = *(&event + 2);
if ( v1 == 5 )
goto LABEL_35;
LABEL_5:
if ( v1 != 4 )
continue;
cam_dist = fmaxf(10.0, cam_dist - 10.0);
rotcam(0.0, 0.0);
result = SDL_PollEvent(&event);
if ( !(_DWORD)result )
return result;
goto LABEL_2;
case 12:
LABEL_59:
func0();
return result;
default:
continue;
}
}
return result;
}
}

original_code:
int handle_events()
{
 while (SDL_PollEvent(&event)){
  SDL_keysym keysym;
  switch (event.type){
   case SDL_KEYDOWN:
    keysym = event.key.keysym;
    if(escribiendo){
     int len;
     switch (keysym.sym) {
      case SDLK_RETURN:
       escribiendo=0;
       send_txt();
       pj_txtbuf[0]=0;
       SDL_EnableUNICODE(0);
       break;
      case SDLK_BACKSPACE:
       len=strlen(pj_txtbuf);
       pj_txtbuf[len-1]=0;
       break;
      case SDLK_ESCAPE:
       escribiendo=0;
       pj_txtbuf[0]=0;
       SDL_EnableUNICODE(0);
       break;
      default:
       if ( (keysym.unicode & 0xFF80) == 0 ) {
        char ch;
        ch = keysym.unicode & 0x7F;
        if(ch){
         len=strlen(pj_txtbuf);
         if(ch==';'){
          pj_txtbuf[len]=',';
         }else{
          pj_txtbuf[len]=ch;
         }
         pj_txtbuf[len+1]=0;
        }
       }else {
       }
       break;
     }
    }else{
     switch (keysym.sym) {
             case SDLK_c:
        banvf=0;
        break;
      case SDLK_d:
       send_msg(270);
       break;
      case SDLK_a:
       send_msg(90);
       break;
      case SDLK_w:
       send_msg(360);
       break;
      case SDLK_s:
       send_msg(180);
       break;
      case SDLK_SPACE:
       send_msg(5);
       break;
      case SDLK_LEFT:
       rotcam(10,0);
       break;
      case SDLK_RIGHT:
       rotcam(-10,0);
       break;
      case SDLK_UP:
       break;
      case SDLK_DOWN:
       break;
      case SDLK_t:
       escribiendo=1;
       pj_txtbuf[0]=0;
       SDL_EnableUNICODE(1);
       break;
      case SDLK_q:
       if(fly) send_msg(9);
       break;
      case SDLK_e:
       if(fly) send_msg(10);
       break;
      case SDLK_1:
       send_msg2(12,"0");
       break;
      case SDLK_2:
       send_msg2(12,"1");
       break;
      case SDLK_f:
       if(fly){
        send_msg(11);
        fly=0;
       }else{
        send_msg(8);
        fly=1;
       }
       break;
      case SDLK_ESCAPE:
       salir();
       break;
     }
    }
    break;
   case SDL_KEYUP:
    if(!otherkeys()){
     pj->vel=0;
     send_msg(1);
    }
    break;
   case SDL_MOUSEBUTTONDOWN:
    if(event.button.button == 1){
     mover=1;
    }
    if(event.button.button == 3){
     mover=2;
     cam_ang=pj_ang;
     rotcam(0,0);
    }
    break;
   case SDL_MOUSEBUTTONUP:
    if(event.button.button == 1 || event.button.button == 3){
     mover=0;
     if(!otherkeys())send_msg(1);
    }
    if(event.button.button == 5){
     cam_dist+=10;
     rotcam(0,0);
    }
    if(event.button.button == 4){
     cam_dist-=10;
     if(cam_dist<10)cam_dist=10;
     rotcam(0,0);
    }
    break;
   case SDL_MOUSEMOTION:
    if(mover==2){
     rotcam(event.motion.xrel,event.motion.yrel);
     pj_ang=cam_ang;
     if(lastmsg+25<SDL_GetTicks()){
      otherkeys();
     }
    }
    if(mover==1){
     rotcam(event.motion.xrel,event.motion.yrel);
    }
    break;
   case SDL_QUIT:
    salir();
    break;
  }
 }
 return 0;
}

canonical_original_code:
int handle_events()
{
 while (SDL_PollEvent(&event)){
  struct SDL_keysym keysym;
  switch (event.type){
   case SDL_KEYDOWN:
    keysym = event.key.keysym;
    if(escribiendo){
     int len;
     switch (keysym.sym) {
      case SDLK_RETURN:
       escribiendo=0;
       send_txt();
       pj_txtbuf[0]=0;
       SDL_EnableUNICODE(0);
       break;
      case SDLK_BACKSPACE:
       len=strlen(pj_txtbuf);
       pj_txtbuf[len-1]=0;
       break;
      case SDLK_ESCAPE:
       escribiendo=0;
       pj_txtbuf[0]=0;
       SDL_EnableUNICODE(0);
       break;
      default:
       if ( (keysym.unicode & 0xFF80) == 0 ) {
        char ch;
        ch = keysym.unicode & 0x7F;
        if(ch){
         len=strlen(pj_txtbuf);
         if(ch==';'){
          pj_txtbuf[len]=',';
         }else{
          pj_txtbuf[len]=ch;
         }
         pj_txtbuf[len+1]=0;
        }
       }else {
       }
       break;
     }
    }else{
     switch (keysym.sym) {
             case SDLK_c:
        banvf=0;
        break;
      case SDLK_d:
       send_msg(270);
       break;
      case SDLK_a:
       send_msg(90);
       break;
      case SDLK_w:
       send_msg(360);
       break;
      case SDLK_s:
       send_msg(180);
       break;
      case SDLK_SPACE:
       send_msg(5);
       break;
      case SDLK_LEFT:
       rotcam(10,0);
       break;
      case SDLK_RIGHT:
       rotcam(-10,0);
       break;
      case SDLK_UP:
       break;
      case SDLK_DOWN:
       break;
      case SDLK_t:
       escribiendo=1;
       pj_txtbuf[0]=0;
       SDL_EnableUNICODE(1);
       break;
      case SDLK_q:
       if(fly) send_msg(9);
       break;
      case SDLK_e:
       if(fly) send_msg(10);
       break;
      case SDLK_1:
       send_msg2(12,"0");
       break;
      case SDLK_2:
       send_msg2(12,"1");
       break;
      case SDLK_f:
       if(fly){
        send_msg(11);
        fly=0;
       }else{
        send_msg(8);
        fly=1;
       }
       break;
      case SDLK_ESCAPE:
       salir();
       break;
     }
    }
    break;
   case SDL_KEYUP:
    if(!otherkeys()){
     pj->vel=0;
     send_msg(1);
    }
    break;
   case SDL_MOUSEBUTTONDOWN:
    if(event.button.button == 1){
     mover=1;
    }
    if(event.button.button == 3){
     mover=2;
     cam_ang=pj_ang;
     rotcam(0,0);
    }
    break;
   case SDL_MOUSEBUTTONUP:
    if(event.button.button == 1 || event.button.button == 3){
     mover=0;
     if(!otherkeys())send_msg(1);
    }
    if(event.button.button == 5){
     cam_dist+=10;
     rotcam(0,0);
    }
    if(event.button.button == 4){
     cam_dist-=10;
     if(cam_dist<10)cam_dist=10;
     rotcam(0,0);
    }
    break;
   case SDL_MOUSEMOTION:
    if(mover==2){
     rotcam(event.motion.xrel,event.motion.yrel);
     pj_ang=cam_ang;
     if(lastmsg+25<SDL_GetTicks()){
      otherkeys();
     }
    }
    if(mover==1){
     rotcam(event.motion.xrel,event.motion.yrel);
    }
    break;
   case SDL_QUIT:
    salir();
    break;
  }
 }
 return 0;
}

variable_types: struct SDL_keysym { unsigned char scancode; enum SDLKey { SDLK_UNKNOWN=0, SDLK_FIRST=0, SDLK_BACKSPACE=8, SDLK_TAB=9, SDLK_CLEAR=12, SDLK_RETURN=13, SDLK_PAUSE=19, SDLK_ESCAPE=27, SDLK_SPACE=32, SDLK_EXCLAIM=33, SDLK_QUOTEDBL=34, SDLK_HASH=35, SDLK_DOLLAR=36, SDLK_AMPERSAND=38, SDLK_QUOTE=39, SDLK_LEFTPAREN=40, SDLK_RIGHTPAREN=41, SDLK_ASTERISK=42, SDLK_PLUS=43, SDLK_COMMA=44, SDLK_MINUS=45, SDLK_PERIOD=46, SDLK_SLASH=47, SDLK_0=48, SDLK_1=49, SDLK_2=50, SDLK_3=51, SDLK_4=52, SDLK_5=53, SDLK_6=54, SDLK_7=55, SDLK_8=56, SDLK_9=57, SDLK_COLON=58, SDLK_SEMICOLON=59, SDLK_LESS=60, SDLK_EQUALS=61, SDLK_GREATER=62, SDLK_QUESTION=63, SDLK_AT=64, SDLK_LEFTBRACKET=91, SDLK_BACKSLASH=92, SDLK_RIGHTBRACKET=93, SDLK_CARET=94, SDLK_UNDERSCORE=95, SDLK_BACKQUOTE=96, SDLK_a=97, SDLK_b=98, SDLK_c=99, SDLK_d=100, SDLK_e=101, SDLK_f=102, SDLK_g=103, SDLK_h=104, SDLK_i=105, SDLK_j=106, SDLK_k=107, SDLK_l=108, SDLK_m=109, SDLK_n=110, SDLK_o=111, SDLK_p=112, SDLK_q=113, SDLK_r=114, SDLK_s=115, SDLK_t=116, SDLK_u=117, SDLK_v=118, SDLK_w=119, SDLK_x=120, SDLK_y=121, SDLK_z=122, SDLK_DELETE=127, SDLK_WORLD_0=160, SDLK_WORLD_1=161, SDLK_WORLD_2=162, SDLK_WORLD_3=163, SDLK_WORLD_4=164, SDLK_WORLD_5=165, SDLK_WORLD_6=166, SDLK_WORLD_7=167, SDLK_WORLD_8=168, SDLK_WORLD_9=169, SDLK_WORLD_10=170, SDLK_WORLD_11=171, SDLK_WORLD_12=172, SDLK_WORLD_13=173, SDLK_WORLD_14=174, SDLK_WORLD_15=175, SDLK_WORLD_16=176, SDLK_WORLD_17=177, SDLK_WORLD_18=178, SDLK_WORLD_19=179, SDLK_WORLD_20=180, SDLK_WORLD_21=181, SDLK_WORLD_22=182, SDLK_WORLD_23=183, SDLK_WORLD_24=184, SDLK_WORLD_25=185, SDLK_WORLD_26=186, SDLK_WORLD_27=187, SDLK_WORLD_28=188, SDLK_WORLD_29=189, SDLK_WORLD_30=190, SDLK_WORLD_31=191, SDLK_WORLD_32=192, SDLK_WORLD_33=193, SDLK_WORLD_34=194, SDLK_WORLD_35=195, SDLK_WORLD_36=196, SDLK_WORLD_37=197, SDLK_WORLD_38=198, SDLK_WORLD_39=199, SDLK_WORLD_40=200, SDLK_WORLD_41=201, SDLK_WORLD_42=202, SDLK_WORLD_43=203, SDLK_WORLD_44=204, SDLK_WORLD_45=205, SDLK_WORLD_46=206, SDLK_WORLD_47=207, SDLK_WORLD_48=208, SDLK_WORLD_49=209, SDLK_WORLD_50=210, SDLK_WORLD_51=211, SDLK_WORLD_52=212, SDLK_WORLD_53=213, SDLK_WORLD_54=214, SDLK_WORLD_55=215, SDLK_WORLD_56=216, SDLK_WORLD_57=217, SDLK_WORLD_58=218, SDLK_WORLD_59=219, SDLK_WORLD_60=220, SDLK_WORLD_61=221, SDLK_WORLD_62=222, SDLK_WORLD_63=223, SDLK_WORLD_64=224, SDLK_WORLD_65=225, SDLK_WORLD_66=226, SDLK_WORLD_67=227, SDLK_WORLD_68=228, SDLK_WORLD_69=229, SDLK_WORLD_70=230, SDLK_WORLD_71=231, SDLK_WORLD_72=232, SDLK_WORLD_73=233, SDLK_WORLD_74=234, SDLK_WORLD_75=235, SDLK_WORLD_76=236, SDLK_WORLD_77=237, SDLK_WORLD_78=238, SDLK_WORLD_79=239, SDLK_WORLD_80=240, SDLK_WORLD_81=241, SDLK_WORLD_82=242, SDLK_WORLD_83=243, SDLK_WORLD_84=244, SDLK_WORLD_85=245, SDLK_WORLD_86=246, SDLK_WORLD_87=247, SDLK_WORLD_88=248, SDLK_WORLD_89=249, SDLK_WORLD_90=250, SDLK_WORLD_91=251, SDLK_WORLD_92=252, SDLK_WORLD_93=253, SDLK_WORLD_94=254, SDLK_WORLD_95=255, SDLK_KP0=256, SDLK_KP1=257, SDLK_KP2=258, SDLK_KP3=259, SDLK_KP4=260, SDLK_KP5=261, SDLK_KP6=262, SDLK_KP7=263, SDLK_KP8=264, SDLK_KP9=265, SDLK_KP_PERIOD=266, SDLK_KP_DIVIDE=267, SDLK_KP_MULTIPLY=268, SDLK_KP_MINUS=269, SDLK_KP_PLUS=270, SDLK_KP_ENTER=271, SDLK_KP_EQUALS=272, SDLK_UP=273, SDLK_DOWN=274, SDLK_RIGHT=275, SDLK_LEFT=276, SDLK_INSERT=277, SDLK_HOME=278, SDLK_END=279, SDLK_PAGEUP=280, SDLK_PAGEDOWN=281, SDLK_F1=282, SDLK_F2=283, SDLK_F3=284, SDLK_F4=285, SDLK_F5=286, SDLK_F6=287, SDLK_F7=288, SDLK_F8=289, SDLK_F9=290, SDLK_F10=291, SDLK_F11=292, SDLK_F12=293, SDLK_F13=294, SDLK_F14=295, SDLK_F15=296, SDLK_NUMLOCK=300, SDLK_CAPSLOCK=301, SDLK_SCROLLOCK=302, SDLK_RSHIFT=303, SDLK_LSHIFT=304, SDLK_RCTRL=305, SDLK_LCTRL=306, SDLK_RALT=307, SDLK_LALT=308, SDLK_RMETA=309, SDLK_LMETA=310, SDLK_LSUPER=311, SDLK_RSUPER=312, SDLK_MODE=313, SDLK_COMPOSE=314, SDLK_HELP=315, SDLK_PRINT=316, SDLK_SYSREQ=317, SDLK_BREAK=318, SDLK_MENU=319, SDLK_POWER=320, SDLK_EURO=321, SDLK_UNDO=322, SDLK_LAST=323 } sym; enum SDLMod { KMOD_NONE=0, KMOD_LSHIFT=1, KMOD_RSHIFT=2, KMOD_LCTRL=64, KMOD_RCTRL=128, KMOD_LALT=256, KMOD_RALT=512, KMOD_LMETA=1024, KMOD_RMETA=2048, KMOD_NUM=4096, KMOD_CAPS=8192, KMOD_MODE=16384, KMOD_RESERVED=32768 } mod; unsigned short unicode; }

variable_types: len int

variable_types: ch char

user_defined_types: struct SDL_keysym { unsigned char scancode; enum SDLKey sym; enum SDLMod mod; unsigned short unicode; }


decompiled_code:
__int64 __fastcall send_msg(unsigned int a1)
{
unsigned int v1; // eax
size_t v2; // rax
__int64 result; // rax
char v4[40]; // [rsp+0h] [rbp-28h] BYREF

v1 = SDL_GetTicks();
if ( lastmsg + 25 >= v1 )
SDL_Delay(v1 - lastmsg + 25);
sprintf(v4, "%d %f ", a1, (float)(360.0 - pj_ang));
v2 = strlen(v4);
if ( send(sockfd, v4, v2, 0) == -1 )
perror("send");
result = SDL_GetTicks();
lastmsg = result;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(unsigned int a1)
{
unsigned int v1; // eax
size_t v2; // rax
__int64 result; // rax
char v4[40]; // [rsp+0h] [rbp-28h] BYREF

v1 = SDL_GetTicks();
if ( lastmsg + 25 >= v1 )
SDL_Delay(v1 - lastmsg + 25);
sprintf(v4, "%d %f ", a1, (float)(360.0 - pj_ang));
v2 = strlen(v4);
if ( send(sockfd, v4, v2, 0) == -1 )
perror("send");
result = SDL_GetTicks();
lastmsg = result;
return result;
}

original_code:
void send_msg(int code)
{
 char msg[20];
 Uint32 t=SDL_GetTicks();
 if(lastmsg+25>=t){
  SDL_Delay(t-lastmsg+25);
 }
 sprintf(msg,"%d %f ",code,360-pj_ang);
 if (send(sockfd, msg, strlen(msg), 0) == -1) perror("send");
 lastmsg=SDL_GetTicks();
}

canonical_original_code:
void send_msg(int code)
{
 char msg[20];
 unsigned int t = SDL_GetTicks();
 if(lastmsg+25>=t){
  SDL_Delay(t-lastmsg+25);
 }
 sprintf(msg,"%d %f ",code,360-pj_ang);
 if (send(sockfd, msg, strlen(msg), 0) == -1) perror("send");
 lastmsg=SDL_GetTicks();
}

variable_types: code int

variable_types:
msg
char [20]

variable_types:
t
unsigned int


decompiled_code:
__int64 __fastcall send_msg2(unsigned int a1, const char *a2)
{
unsigned int v2; // eax
size_t v3; // rax
__int64 result; // rax
char v5[56]; // [rsp+0h] [rbp-38h] BYREF

v2 = SDL_GetTicks();
if ( lastmsg + 25 >= v2 )
SDL_Delay(v2 - lastmsg + 25);
sprintf(v5, "%d %f %s..", a1, (float)(360.0 - pj_ang), a2);
v3 = strlen(v5);
if ( send(sockfd, v5, v3, 0) == -1 )
perror("send");
result = SDL_GetTicks();
lastmsg = result;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(unsigned int a1, const char *a2)
{
unsigned int v2; // eax
size_t v3; // rax
__int64 result; // rax
char v5[56]; // [rsp+0h] [rbp-38h] BYREF

v2 = SDL_GetTicks();
if ( lastmsg + 25 >= v2 )
SDL_Delay(v2 - lastmsg + 25);
sprintf(v5, "%d %f %s..", a1, (float)(360.0 - pj_ang), a2);
v3 = strlen(v5);
if ( send(sockfd, v5, v3, 0) == -1 )
perror("send");
result = SDL_GetTicks();
lastmsg = result;
return result;
}

original_code:
void send_msg2(int code,char *txt)
{
 char msg[20];
 Uint32 t=SDL_GetTicks();
 if(lastmsg+25>=t){
  SDL_Delay(t-lastmsg+25);
 }
 sprintf(msg,"%d %f %s..",code,360-pj_ang,txt);
 if (send(sockfd, msg, strlen(msg), 0) == -1) perror("send");
 lastmsg=SDL_GetTicks();
}

canonical_original_code:
void send_msg2(int code, char *txt)
{
 char msg[20];
 unsigned int t = SDL_GetTicks();
 if(lastmsg+25>=t){
  SDL_Delay(t-lastmsg+25);
 }
 sprintf(msg,"%d %f %s..",code,360-pj_ang,txt);
 if (send(sockfd, msg, strlen(msg), 0) == -1) perror("send");
 lastmsg=SDL_GetTicks();
}

variable_types:
txt
char *


decompiled_code:
void send_txt()
{
size_t v0; // rax
char v1[264]; // [rsp+0h] [rbp-108h] BYREF

sprintf(v1, "%d %f %s..", 6LL, pj_ang, (const char *)&pj_txtbuf);
printf("msg:%s\n", v1);
v0 = strlen(v1);
if ( send(sockfd, v1, v0, 0) == -1 )
perror("send");
}

canonical_decompiled_code:
void func3()
{
size_t v0; // rax
char v1[264]; // [rsp+0h] [rbp-108h] BYREF

sprintf(v1, "%d %f %s..", 6LL, pj_ang, (const char *)&pj_txtbuf);
printf("msg:%s\n", v1);
v0 = strlen(v1);
if ( send(sockfd, v1, v0, 0) == -1 )
perror("send");
}

original_code:
void send_txt()
{
 char msg[256];
 sprintf(msg,"%d %f %s..",6,pj_ang,pj_txtbuf);
 printf("msg:%s\n",msg);
 if (send(sockfd, msg, strlen(msg), 0) == -1) perror("send");
}

variable_types:
msg
char [256]


decompiled_code:
void send_name()
{
size_t v0; // rax
char v1[216]; // [rsp+0h] [rbp-D8h] BYREF

sprintf(v1, "%d 0 %s..", 7LL, (const char *)&myname);
v0 = strlen(v1);
if ( send(sockfd, v1, v0, 0) == -1 )
perror("send");
}

canonical_decompiled_code:
void func4()
{
size_t v0; // rax
char v1[216]; // [rsp+0h] [rbp-D8h] BYREF

sprintf(v1, "%d 0 %s..", 7LL, (const char *)&myname);
v0 = strlen(v1);
if ( send(sockfd, v1, v0, 0) == -1 )
perror("send");
}

original_code:
void send_name()
{
 char msg[200];
 sprintf(msg,"%d 0 %s..",7,myname);
 if (send(sockfd, msg, strlen(msg), 0) == -1) perror("send");
}

variable_types:
msg
char [200]


count

decompiled_code:
__int64 __fastcall count(__int64 a1)
{
int v1; // eax
unsigned int i; // er8

v1 = 1;
for ( i = 0; a1; ++v1 )
{
a1 = *(_QWORD *)(a1 + 336);
i = v1;
}
return i;
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1)
{
int v1; // eax
unsigned int i; // er8

v1 = 1;
for ( i = 0; a1; ++v1 )
{
a1 = *(_QWORD *)(a1 + 336);
i = v1;
}
return i;
}

original_code:
int count(struct player *p)
{
 if(p==0)return 0;
 return 1+count(p->next);
}

user_defined_types: struct player { int tipo; int id; int model; int weapon; int hp; float x; float dir; float vel; int acc; char txt[-1]; char name[-1]; int txt_ini_time; int alive; int n; float interp; struct player *next; }


original_code:
int buscar_player(int tipo,int id,char *name,int hp,float x,float y,float z,int acc,float ang,char *txt)
{
 struct player *aux;
 aux=players;
 while(aux!=((void *)0)){
  if(aux->id==id){
   SDL_mutexP (mutex);
    aux->tipo=tipo;
    strcpy(aux->name,name);
    aux->hp=hp;
    aux->x=x;
    aux->y=y;
    aux->z=z;
    aux->acc=acc;
    if(acc==8){
     aux->model=1;
    }else{
     aux->model=2;
    }
    aux->dir=ang;
    aux->vel=0;
    if(txt[0]){
     strcpy(aux->txt,txt);
     aux->txt_ini_time=SDL_GetTicks();
    }
    aux->alive=1;
   SDL_mutexV (mutex);
   return 1;
  }
  aux=aux->next;
 }
 return 0;
}

canonical_original_code:
int buscar_player(int tipo, int id, char *name, int hp, float x, float y, float z, int acc, float ang, char *txt)
{
 struct player *aux;
 aux=players;
 while(aux!=((void *)0)){
  if(aux->id==id){
   SDL_mutexP (mutex);
    aux->tipo=tipo;
    strcpy(aux->name,name);
    aux->hp=hp;
    aux->x=x;
    aux->y=y;
    aux->z=z;
    aux->acc=acc;
    if(acc==8){
     aux->model=1;
    }else{
     aux->model=2;
    }
    aux->dir=ang;
    aux->vel=0;
    if(txt[0]){
     strcpy(aux->txt,txt);
     aux->txt_ini_time=SDL_GetTicks();
    }
    aux->alive=1;
   SDL_mutexV (mutex);
   return 1;
  }
  aux=aux->next;
 }
 return 0;
}

variable_types: tipo int

variable_types: id int

variable_types:
name
char *

variable_types: hp int

variable_types: x float

variable_types: y float

variable_types: z float

variable_types: acc int

variable_types: ang float


network

original_code:
int network(void *data)
{
 char buf[1024],buf2[1024],txt[256],gname[16];
 char curbuf[1024]="";
 struct player *aux,*aux2;
 char *pbuf;
 int i,j,k,c,i2;
 static int c1=0;
 int numbytes;
 int gid,gacc,gtipo=3;
 float gx,gy,gz,gang;
 int ghp;
 while(1){
  if ((numbytes=recv(sockfd, buf, 1024-1, 0)) == -1) {
   perror("recv");
   exit(1);
  }
  buf[numbytes] = '\0';
  if(!numbytes)continue;
  for(i2=0;i2<numbytes;i2++){
   if(buf[i2]!='\n'){
    curbuf[c1]=buf[i2];
    c1++;
   }else{
    curbuf[c1]=0;
    if(curbuf[0]=='<' && curbuf[1]=='0' && curbuf[2]=='>' ){
     j=0;
     for(i=3;i<c1;i++){
      if(curbuf[i]!=';'){
       buf2[j]=curbuf[i];
       j++;
      }else{
       buf2[j]=0;
       pbuf=buf2;
       sscanf(pbuf,"%d,",&gtipo);
       while(pbuf[0]!=',')pbuf++;
       pbuf++;
       sscanf(pbuf,"%d,",&gid);
       while(pbuf[0]!=',')pbuf++;
       pbuf++;
       k=0;
       while(pbuf[0]!=','){
        gname[k]=pbuf[0];
        pbuf++;
        k++;
       }
       gname[k]=0;
       pbuf++;
       sscanf(pbuf,"%d,%f,%f,%f,%d,%f",&ghp,&gx,&gy,&gz,&gacc,&gang);
       c=0;
       for(k=0;k<6;k++){
        while(pbuf[c]!=',')c++;
        c++;
       }
       strcpy(txt,pbuf+c);
       if(!buscar_player(gtipo,gid,gname,ghp,gx,gy,gz,gacc,gang,txt)){
        aux=players;
        while(aux->next!=((void *)0)){
         aux=aux->next;
        }
        SDL_mutexP (mutex);
         aux->next=malloc(sizeof(struct player));
         aux->next->tipo=gtipo;
         aux->next->id=gid;
         aux->next->hp=ghp;
         aux->next->x=gx;
         aux->next->y=gy;
         aux->next->z=gz;
         aux->next->acc=gacc;
         if(gacc==8){
          aux->next->model=1;
         }else{
          aux->next->model=2;
         }
         aux->next->weapon=rand()%12;
         if(txt[0]){
          strcpy(aux->txt,txt);
          aux->txt_ini_time=SDL_GetTicks();
         }else{
          aux->next->txt[0]=0;
          aux->next->txt_ini_time=0;
         }
         strcpy(aux->name,gname);
         aux->next->dir=gang;
         aux->next->vel=0;
         aux->next->next=0;
         aux->next->alive=1;
         aux->interp=0;
        SDL_mutexV (mutex);
       }
       j=0;
      }
     }
     aux=players;
     while(aux->next!=((void *)0)){
      if(!aux->next->alive){
       aux2=aux->next->next;
       free(aux->next);
       aux->next=aux2;
      }else{
       aux->next->alive=0;
       aux=aux->next;
      }
     }
    }else{
     printf("Error %s\n",curbuf);
    }
    c1=0;
   }
  }
 }
}

canonical_original_code:
int network(void *data)
{
 char buf[1024]; char buf2[1024]; char txt[256]; char gname[16];
 char curbuf[1024] = "";
 struct player *aux; struct player *aux2;
 char *pbuf;
 int i; int j; int k; int c; int i2;
 static int c1 = 0;
 int numbytes;
 int gid; int gacc; int gtipo = 3;
 float gx; float gy; float gz; float gang;
 int ghp;
 while(1){
  if ((numbytes=recv(sockfd, buf, 1024-1, 0)) == -1) {
   perror("recv");
   exit(1);
  }
  buf[numbytes] = '\0';
  if(!numbytes)continue;
  for(i2=0;i2<numbytes;i2++){
   if(buf[i2]!='\n'){
    curbuf[c1]=buf[i2];
    c1++;
   }else{
    curbuf[c1]=0;
    if(curbuf[0]=='<' && curbuf[1]=='0' && curbuf[2]=='>' ){
     j=0;
     for(i=3;i<c1;i++){
      if(curbuf[i]!=';'){
       buf2[j]=curbuf[i];
       j++;
      }else{
       buf2[j]=0;
       pbuf=buf2;
       sscanf(pbuf,"%d,",&gtipo);
       while(pbuf[0]!=',')pbuf++;
       pbuf++;
       sscanf(pbuf,"%d,",&gid);
       while(pbuf[0]!=',')pbuf++;
       pbuf++;
       k=0;
       while(pbuf[0]!=','){
        gname[k]=pbuf[0];
        pbuf++;
        k++;
       }
       gname[k]=0;
       pbuf++;
       sscanf(pbuf,"%d,%f,%f,%f,%d,%f",&ghp,&gx,&gy,&gz,&gacc,&gang);
       c=0;
       for(k=0;k<6;k++){
        while(pbuf[c]!=',')c++;
        c++;
       }
       strcpy(txt,pbuf+c);
       if(!buscar_player(gtipo,gid,gname,ghp,gx,gy,gz,gacc,gang,txt)){
        aux=players;
        while(aux->next!=((void *)0)){
         aux=aux->next;
        }
        SDL_mutexP (mutex);
         aux->next=malloc(sizeof(struct player));
         aux->next->tipo=gtipo;
         aux->next->id=gid;
         aux->next->hp=ghp;
         aux->next->x=gx;
         aux->next->y=gy;
         aux->next->z=gz;
         aux->next->acc=gacc;
         if(gacc==8){
          aux->next->model=1;
         }else{
          aux->next->model=2;
         }
         aux->next->weapon=rand()%12;
         if(txt[0]){
          strcpy(aux->txt,txt);
          aux->txt_ini_time=SDL_GetTicks();
         }else{
          aux->next->txt[0]=0;
          aux->next->txt_ini_time=0;
         }
         strcpy(aux->name,gname);
         aux->next->dir=gang;
         aux->next->vel=0;
         aux->next->next=0;
         aux->next->alive=1;
         aux->interp=0;
        SDL_mutexV (mutex);
       }
       j=0;
      }
     }
     aux=players;
     while(aux->next!=((void *)0)){
      if(!aux->next->alive){
       aux2=aux->next->next;
       free(aux->next);
       aux->next=aux2;
      }else{
       aux->next->alive=0;
       aux=aux->next;
      }
     }
    }else{
     printf("Error %s\n",curbuf);
    }
    c1=0;
   }
  }
 }
}

variable_types:
data
void *

variable_types:
buf
char [1024]

variable_types:
txt
char [256]

variable_types:
gname
char [16]

variable_types:
curbuf
char [1024]

variable_types: struct player { int tipo; int id; int model; int weapon; int hp; float x; float dir; float vel; int acc; char txt[-1]; char name[-1]; int txt_ini_time; int alive; int n; float interp; struct player *next; } *

variable_types:
pbuf
char *

variable_types: i int

variable_types: j int

variable_types: k int

variable_types: c int

variable_types: numbytes int

variable_types: gid int

variable_types: gacc int

variable_types: gtipo int

variable_types: gx float

variable_types: gy float

variable_types: gz float

variable_types: gang float

variable_types: ghp int


decompiled_code:
int end_network()
{
return close(sockfd);
}

canonical_decompiled_code:
int func9()
{
return close(sockfd);
}

original_code:
void end_network()
{
 close(sockfd);
}

canonical_original_code:
void end_network()
{
 close(sockfd);
}


comb

decompiled_code:
__int64 __fastcall comb(unsigned int a1, unsigned int a2)
{
__int64 result; // rax
unsigned int v3; // ecx
unsigned int v4; // edi

result = 0LL;
if ( a2 <= a1 )
{
if ( a2 )
{
v3 = 1;
LODWORD(result) = 1;
v4 = a1 + 1;
do
{
result = (v4 - v3) * (unsigned int)result / v3;
++v3;
}
while ( a2 >= v3 );
}
else
{
result = 1LL;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(unsigned int a1, unsigned int a2)
{
__int64 result; // rax
unsigned int v3; // ecx
unsigned int v4; // edi

result = 0LL;
if ( a2 <= a1 )
{
if ( a2 )
{
v3 = 1;
LODWORD(result) = 1;
v4 = a1 + 1;
do
{
result = (v4 - v3) * (unsigned int)result / v3;
++v3;
}
while ( a2 >= v3 );
}
else
{
result = 1LL;
}
}
return result;
}

original_code:
unsigned int comb(unsigned int m, unsigned int n) {
  unsigned r = 1;
  unsigned d;
  if (n > m) return 0;
  for (d=1; d <= n; d++) {
    r *= m--;
    r /= d;
  }
  return r;
}

canonical_original_code:
unsigned int comb(unsigned int m, unsigned int n) {
  unsigned int r = 1;
  unsigned int d;
  if (n > m) return 0;
  for (d=1; d <= n; d++) {
    r *= m--;
    r /= d;
  }
  return r;
}

variable_types:
m
unsigned int

variable_types:
n
unsigned int

variable_types:
r
unsigned int

variable_types:
d
unsigned int

return_type: unsigned int


printvector

decompiled_code:
int __fastcall printvector(double a1, double a2, double a3, double a4, double a5, double a6, double a7, double a8, double a9, double a10, double a11)
{
return printf("<%lf %lf %lf> ", a9, a10, a11);
}

canonical_decompiled_code:
int __fastcall func1(double a1, double a2, double a3, double a4, double a5, double a6, double a7, double a8, double a9, double a10, double a11)
{
return printf("<%lf %lf %lf> ", a9, a10, a11);
}

original_code:
void printvector(struct vector v)
{
 printf("<%lf %lf %lf> ",v.x,v.y,v.z);
}

variable_types:
v
struct vector { double x; }


pointinpoly

decompiled_code:
__int64 __fastcall pointinpoly(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6, __int64 a7, __int64 a8, __int64 a9, int a10, __int64 a11)
{
__int64 v11; // rbx

if ( a10 <= 0 )
return 0LL;
v11 = a11;
while ( !(unsigned int)comppoints(a1, a2, a3, a4, a5, a6) )
{
v11 += 24LL;
if ( v11 == a11 + 24LL * (unsigned int)(a10 - 1) + 24 )
return 0LL;
}
return 1LL;
}

original_code:
int pointinpoly(struct vector point,struct poly p)
{
 int i;
 for(i=0;i<p.num;i++){
  if(comppoints(point,p.vertexes[i]))return 1;
 }
 return 0;
}

canonical_original_code:
int pointinpoly(struct vector point, struct poly p)
{
 int i;
 for(i=0;i<p.num;i++){
  if(comppoints(point,p.vertexes[i]))return 1;
 }
 return 0;
}

variable_types:
point
struct vector { double x; }

variable_types: struct poly { int num; struct vector *vertexes; struct vector center; struct vector normal; struct texture { char *name; } tex; }

variable_types: i int

user_defined_types: struct poly { int num; struct vector *vertexes; struct vector center; struct vector normal; struct texture tex; }


glPrint

decompiled_code:
void glPrint(char *format, ...)
{
size_t v1; // rax
gcc_va_list arg; // [rsp+8h] [rbp-1D0h] BYREF
char s[256]; // [rsp+20h] [rbp-1B8h] BYREF

if ( format )
{
va_start(arg, format);
vsprintf(s, format, arg);
glPushAttrib(0x20000LL);
glListBase((unsigned int)(base - 32));
v1 = strlen(s);
glCallLists(v1, 5121LL, s);
glPopAttrib();
}
}

canonical_decompiled_code:
void func1(char *format, ...)
{
size_t v1; // rax
gcc_va_list arg; // [rsp+8h] [rbp-1D0h] BYREF
char s[256]; // [rsp+20h] [rbp-1B8h] BYREF

if ( format )
{
va_start(arg, format);
vsprintf(s, format, arg);
glPushAttrib(0x20000LL);
glListBase((unsigned int)(base - 32));
v1 = strlen(s);
glCallLists(v1, 5121LL, s);
glPopAttrib();
}
}

original_code:
GLvoid glPrint( const char *fmt, ... )
{
    char text[256];
    va_list ap;
    if ( fmt == ((void *)0) )
 return;
    __builtin_va_start(ap,fmt);
      vsprintf( text, fmt, ap );
    __builtin_va_end(ap);
    glPushAttrib( 0x00020000 );
    glListBase( base - 32 );
    glCallLists( strlen( text ), 0x1401, text );
    glPopAttrib( );
}

canonical_original_code:
void glPrint(char *fmt, ...)
{
    char text[256];
    __builtin_va_list ap;
    if ( fmt == ((void *)0) )
 return;
    __builtin_va_start(ap,fmt);
      vsprintf( text, fmt, ap );
    __builtin_va_end(ap);
    glPushAttrib( 0x00020000 );
    glListBase( base - 32 );
    glCallLists( strlen( text ), 0x1401, text );
    glPopAttrib( );
}

variable_types:
fmt
char *

variable_types:
text
char [256]


validate

repo: joshi-prahlad/CPrograms

original_code:
void validate(int* output, int num_elements) {
    int i = 0;
    ((void) sizeof ((output != ((void *)0)) ? 1 : 0), __extension__ ({ if (output != ((void *)0)) ; else __assert_fail ("output != NULL", "validate.c", 8, __extension__ __PRETTY_FUNCTION__); }));
    for(i = 0; i < num_elements - 1; i++) {
        if (output[i] > output[i+1]) {
            printf("************* NOT sorted *************\n");
            return;
        }
    }
    printf("============= SORTED ===========\n");
}

canonical_original_code:
void validate(int *output, int num_elements) {
    int i = 0;
    ((void) sizeof ((output != ((void *)0)) ? 1 : 0), __extension__ ({ if (output != ((void *)0)) ; else __assert_fail ("output != NULL", "validate.c", 8, __extension__ __PRETTY_FUNCTION__); }));
    for(i = 0; i < num_elements - 1; i++) {
        if (output[i] > output[i+1]) {
            printf("************* NOT sorted *************\n");
            return;
        }
    }
    printf("============= SORTED ===========\n");
}

variable_types:
output
int *


repo: joshsh/archive

decompiled_code:
void __fastcall array__delete(void *ptr)
{
free(*((void **)ptr + 3));
free(ptr);
}

canonical_decompiled_code:
void __fastcall func1(void *ptr)
{
free(*((void **)ptr + 3));
free(ptr);
}

original_code:
void array__delete(struct JS_array *a)
{
  free(a->buffer);
  free(a);
}

variable_types: struct JS_array { int head; double expansion; void **buffer; } *


original_code:
void array__minimize(struct JS_array *a)
{
  int i;
  void **buffer0;
  if (a->size < a->buffer_size) {
    if (!a->size) {
      buffer0 = (void **) malloc(sizeof(void *));
      a->buffer_size = 1;
    } else {
      buffer0 = (void **) malloc(a->size * sizeof(void *));
      for (i=0; i<a->size; i++)
        buffer0[i] = a->buffer[(a->head+i)%a->buffer_size];
      a->buffer_size = a->size;
    }
    free(a->buffer);
    a->buffer = buffer0;
    a->head = 0;
  }
}

user_defined_types: struct JS_array { int head; double expansion; void **buffer; }


original_code:
void *array__get(struct JS_array *a, int index)
{
  if ((index >=0)&&(index < a->size))
    return a->buffer[(index+a->head)%a->buffer_size];
  else
    return ((void *)0);
}

variable_types: index int

return_type: void *


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

result = 0LL;
if ( a1[1] )
result = *(_QWORD *)(*((_QWORD *)a1 + 3) + 8LL * *a1);
return result;
}

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

result = 0LL;
if ( a1[1] )
result = *(_QWORD *)(*((_QWORD *)a1 + 3) + 8LL * *a1);
return result;
}

original_code:
void *array__peek(struct JS_array *a)
{
  if (a->size)
    return a->buffer[a->head];
  else
    return ((void *)0);
}


original_code:
void array__push(struct JS_array *a, void *p)
{
  if (a->size >= a->buffer_size)
    array__expand(a);
  a->head = ((a->head-1)+a->buffer_size)%a->buffer_size;
  a->buffer[a->head] = p;
  a->size++;
}

variable_types:
p
void *


original_code:
void *array__pop(struct JS_array *a)
{
  void *p;
  if (a->size) {
    p = a->buffer[a->head];
    a->head = (a->head+1)%a->buffer_size;
    a->size--;
    return p;
  } else
    return ((void *)0);
}


original_code:
void array__enqueue(struct JS_array *a, void *p)
{
  if (a->size >= a->buffer_size)
    array__expand(a);
  a->buffer[(a->head+a->size)%a->buffer_size] = p;
  a->size++;
}


original_code:
void *array__dequeue(struct JS_array *a)
{
  if (a->size) {
    a->size--;
    return a->buffer[(a->head+a->size)%a->buffer_size];
  } else
    return ((void *)0);
}


original_code:
void array__insert_before(struct JS_array *a, int index, void *p)
{
  int i;
  if ((index >= 0)&&(index < a->size)) {
    if (a->size >= a->buffer_size)
      array__expand(a);
    for (i=a->size; i>index; i--)
      a->buffer[(a->head+i)%a->buffer_size]
        = a->buffer[(a->head+i-1)%a->buffer_size];
    a->buffer[(a->head+index)%a->buffer_size] = p;
    a->size++;
  }
}


original_code:
void array__insert_after(struct JS_array *a, int index, void *p)
{
  int i;
  if ((index >= 0)&&(index < a->size)) {
    if (a->size >= a->buffer_size)
      array__expand(a);
    for (i=a->size; i>(index+1); i--)
      a->buffer[(a->head+i)%a->buffer_size]
        = a->buffer[(a->head+i-1)%a->buffer_size];
    a->buffer[(a->head+index+1)%a->buffer_size] = p;
    a->size++;
  }
}


original_code:
void array__remove(struct JS_array *a, int index)
{
  int i;
  if ((index >= 0)&&(index < a->size)) {
    for (i=index; i<(a->size-1); i++)
      a->buffer[(a->head+i)%a->buffer_size]
        = a->buffer[(a->head+i+1)%a->buffer_size];
    a->size--;
  }
}


original_code:
void array__simple_remove(struct JS_array *a, int index)
{
  if ((index >= 0)&&(index < a->size)) {
    a->buffer[(a->head+index)%a->buffer_size]
      = a->buffer[(a->head+a->size-1)%a->buffer_size];
    a->size--;
  }
}


original_code:
void array__merge_(int lo, int m, int hi)
{
 int i, j, k;
    i=0; j=lo;
    while (j<=m)
        aux_[i++]=buffer_[j++];
    i=0; k=lo;
    while (k<j && j<=hi)
        if (compare_(aux_[i],buffer_[j]) <= 0)
            buffer_[k++]=aux_[i++];
        else
            buffer_[k++]=buffer_[j++];
    while (k<j)
        buffer_[k++]=aux_[i++];
}

canonical_original_code:
void array__merge_(int lo, int m, int hi)
{
 int i; int j; int k;
    i=0; j=lo;
    while (j<=m)
        aux_[i++]=buffer_[j++];
    i=0; k=lo;
    while (k<j && j<=hi)
        if (compare_(aux_[i],buffer_[j]) <= 0)
            buffer_[k++]=aux_[i++];
        else
            buffer_[k++]=buffer_[j++];
    while (k<j)
        buffer_[k++]=aux_[i++];
}

variable_types: lo int

variable_types: m int

variable_types: hi int

variable_types: j int

variable_types: k int


decompiled_code:
void __fastcall array__mergesort_(__int64 a1, int a2)
{
unsigned int v2; // er13

if ( (int)a1 < a2 )
{
v2 = ((int)a1 + a2) / 2;
array__mergesort_(a1, v2);
array__mergesort_(v2 + 1, (unsigned int)a2);
array__merge_(a1, v2, a2);
}
}

canonical_decompiled_code:
void __fastcall func16(__int64 a1, int a2)
{
unsigned int v2; // er13

if ( (int)a1 < a2 )
{
v2 = ((int)a1 + a2) / 2;
func16(a1, v2);
func16(v2 + 1, (unsigned int)a2);
func15(a1, v2, a2);
}
}

original_code:
void array__mergesort_(int lo, int hi)
{
 int m;
    if (lo<hi)
    {
        m=(lo+hi)/2;
        array__mergesort_(lo, m);
        array__mergesort_(m+1, hi);
        array__merge_(lo, m, hi);
    }
}


original_code:
void array__mergesort(struct JS_array *a, int (*compare) (void *, void *))
{
 int i;
 int size = a->size, buffer_size = a->buffer_size, head = a->head;
 void **buffer = a->buffer;
 buffer_ = (void **) malloc(sizeof(void*)*a->size);
    for (i=0; i<size; i++)
  buffer_[i] = buffer[(head+i)%buffer_size];
    a->head = 0;
    a->buffer = buffer_;
    free(buffer);
 aux_ = (void **) malloc(sizeof(void*)*a->size);
 compare_ = compare;
 array__mergesort_(0, size - 1);
 free(aux_);
}

canonical_original_code:
void array__mergesort(struct JS_array *a, int (*compare)(void *, void *))
{
 int i;
 int size = a->size; int buffer_size = a->buffer_size; int head = a->head;
 void **buffer = a->buffer;
 buffer_ = (void **) malloc(sizeof(void *)*a->size);
    for (i=0; i<size; i++)
  buffer_[i] = buffer[(head+i)%buffer_size];
    a->head = 0;
    a->buffer = buffer_;
    free(buffer);
 aux_ = (void **) malloc(sizeof(void *)*a->size);
 compare_ = compare;
 array__mergesort_(0, size - 1);
 free(aux_);
}

variable_types:
compare
int (*)(void *, void *)

variable_types: size int

variable_types: head int

variable_types:
buffer
void **


decompiled_code:
__int64 __fastcall array__forall(__int64 a1, __int64 (__fastcall *a2)(_QWORD))
{
__int64 result; // rax
int v3; // ebp
int v4; // eax

result = *(unsigned int *)(a1 + 4);
if ( (int)result > 0 )
{
v3 = 0;
do
{
v4 = v3 + *(_DWORD *)a1;
++v3;
result = a2(*(_QWORD *)(*(_QWORD *)(a1 + 24) + 8LL * (v4 % *(_DWORD *)(a1 + 8))));
}
while ( *(_DWORD *)(a1 + 4) > v3 );
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func19(__int64 a1, __int64 (__fastcall *a2)(_QWORD))
{
__int64 result; // rax
int v3; // ebp
int v4; // eax

result = *(unsigned int *)(a1 + 4);
if ( (int)result > 0 )
{
v3 = 0;
do
{
v4 = v3 + *(_DWORD *)a1;
++v3;
result = a2(*(_QWORD *)(*(_QWORD *)(a1 + 24) + 8LL * (v4 % *(_DWORD *)(a1 + 8))));
}
while ( *(_DWORD *)(a1 + 4) > v3 );
}
return result;
}

original_code:
void array__forall(struct JS_array *a, void (*func) (void *))
{
  int i;
  for (i=0; i<a->size; i++)
    func(a->buffer[(a->head+i)%a->buffer_size]);
}

canonical_original_code:
void array__forall(struct JS_array *a, void (*func)(void *))
{
  int i;
  for (i=0; i<a->size; i++)
    func(a->buffer[(a->head+i)%a->buffer_size]);
}

variable_types:
func
void (*)(void *)


decompiled_code:
int __fastcall view_bytes(char *a1, int a2)
{
char *v2; // rbx
char *v3; // rbp
__int64 v4; // rsi

v2 = a1;
printf("%d bytes beginning at %d:", (unsigned int)a2, (unsigned int)a1);
if ( a2 > 0 )
{
v3 = &a1[a2];
do
{
v4 = (unsigned int)*v2++;
printf(" %d", v4);
}
while ( v2 != v3 );
}
return putchar(10);
}

canonical_decompiled_code:
int __fastcall func0(char *a1, int a2)
{
char *v2; // rbx
char *v3; // rbp
__int64 v4; // rsi

v2 = a1;
printf("%d bytes beginning at %d:", (unsigned int)a2, (unsigned int)a1);
if ( a2 > 0 )
{
v3 = &a1[a2];
do
{
v4 = (unsigned int)*v2++;
printf(" %d", v4);
}
while ( v2 != v3 );
}
return putchar(10);
}

original_code:
void view_bytes(void *start_address, int n)
{
  int i;
  char *s = (char *) start_address;
  printf("%d bytes beginning at %d:", n, (int) start_address);
  for (i=0; i<n; i++) {
    printf(" %d", (int) *s);
    s++;
  }
  printf("\n");
}

variable_types: n int

variable_types: i int

variable_types:
s
char *


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

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

original_code:
void jstring_destructor(struct jstring *j)
{
  free(j->s);
  free(j);
}

variable_types: struct jstring { char *s; int length; } *


decompiled_code:
int __fastcall jstring_view(__int64 a1)
{
printf("jstring of length %d: ", *(unsigned int *)(a1 + 8));
return view_bytes(*(char **)a1, *(_DWORD *)(a1 + 8));
}

canonical_decompiled_code:
int __fastcall func2(__int64 a1)
{
printf("jstring of length %d: ", *(unsigned int *)(a1 + 8));
return func0(*(char **)a1, *(_DWORD *)(a1 + 8));
}

original_code:
void jstring_view(struct jstring *j)
{
 printf("jstring of length %d: ", j->length);
 view_bytes(j->s, j->length);
}


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

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

original_code:
void expression_destructor(struct expression *e)
{
  jstring_destructor(e->jval);
  free(e);
}

variable_types: struct expression { struct jstring { char *s; int length; } *jval; int topvar; } *

user_defined_types: struct expression { struct jstring *jval; int topvar; }


decompiled_code:
__int64 __fastcall evaluate_term(__int64 a1)
{
_QWORD *v1; // rbp
__int64 v2; // r12

v1 = parenthesize(*(_QWORD *)a1);
v2 = SParse_interpret_expression(*v1, *((unsigned int *)v1 + 2), (unsigned int)(*(_DWORD *)(a1 + 8) + 1));
jstring_destructor(v1);
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1)
{
_QWORD *v1; // rbp
__int64 v2; // r12

v1 = parenthesize(*(_QWORD *)a1);
v2 = SParse_interpret_expression(*v1, *((unsigned int *)v1 + 2), (unsigned int)(*(_DWORD *)(a1 + 8) + 1));
func1(v1);
return v2;
}

original_code:
void *evaluate_term(struct expression *e)
{
  void *p;
  struct jstring *j = parenthesize(e->jval);
  p = SParse_interpret_expression(
    j->s, j->length, e->topvar+1);
  jstring_destructor(j);
  return p;
}


output

decompiled_code:
int __fastcall output(__int64 a1)
{
printf("\n\t>> ");
SParse_print(a1);
return puts(" <<\n");
}

canonical_decompiled_code:
int __fastcall func7(__int64 a1)
{
printf("\n\t>> ");
SParse_print(a1);
return puts(" <<\n");
}

original_code:
void output(void *p)
{
    printf("\n\t>> ");
    SParse_print(p);
    printf(" <<\n\n");
}


original_code:
int find_next_prime(int i)
{
  int j;
  if (i<3)
    i=3;
  else if (!(i%2))
    i++;
  while (1) {
    for (j=3; j<i; j+=2)
      if (!(i%j))
        j=i+1;
    if (j>i)
      i+=2;
    else
      return i;
  }
}


decompiled_code:
void __fastcall hash_table__delete(void *ptr)
{
free(*((void **)ptr + 4));
free(ptr);
}

canonical_decompiled_code:
void __fastcall func5(void *ptr)
{
free(*((void **)ptr + 4));
free(ptr);
}

original_code:
void hash_table__delete(struct JS_hash_table *h)
{
  free(h->buffer);
  free(h);
}

variable_types: struct JS_hash_table { int size; double expansion; void **buffer; int (*hashing_function)(void *key); int (*compare_to)(void *key1, void *key2); } *


original_code:
void *hash_table__lookup(struct JS_hash_table *h, void *key)
{
  int int_key, actual_size;
  void **p;
  if (key == ((void *)0))
    return ((void *)0);
  int_key = h->hashing_function(key);
  if (int_key < 0)
    int_key *= -1;
  p = h->buffer + (2*(int_key%h->buffer_size));
  actual_size = 2*h->buffer_size;
  while (1) {
    if ((*p == ((void *)0))||(!h->compare_to(*p, key)))
      break;
    p = h->buffer + ((p + 2 - h->buffer)%actual_size);
  }
  p++;
  return *p;
}

canonical_original_code:
void *hash_table__lookup(struct JS_hash_table *h, void *key)
{
  int int_key; int actual_size;
  void **p;
  if (key == ((void *)0))
    return ((void *)0);
  int_key = h->hashing_function(key);
  if (int_key < 0)
    int_key *= -1;
  p = h->buffer + (2*(int_key%h->buffer_size));
  actual_size = 2*h->buffer_size;
  while (1) {
    if ((*p == ((void *)0))||(!h->compare_to(*p, key)))
      break;
    p = h->buffer + ((p + 2 - h->buffer)%actual_size);
  }
  p++;
  return *p;
}

variable_types:
key
void *

variable_types:
p
void **

user_defined_types: struct JS_hash_table { int size; double expansion; void **buffer; int (*hashing_function)(void *key); int (*compare_to)(void *key1, void *key2); }


repo: joshthecoder/libhttp

decompiled_code:
void __fastcall http_session_close(void *ptr)
{
close(*(_DWORD *)ptr);
free(ptr);
}

canonical_decompiled_code:
void __fastcall func0(void *ptr)
{
close(*(_DWORD *)ptr);
free(ptr);
}

original_code:
void http_session_close(http_session* session) {
  close(session->sockfd);
  free(session);
}

canonical_original_code:
void http_session_close(struct http_session_s *session) {
  close(session->sockfd);
  free(session);
}

variable_types:
session
struct http_session_s { int sockfd; } *


main

repo: joshuaday/rook

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

Rng(&v4, 0LL, envp);
if ( (unsigned int)Term() )
Game();
return 0;
}

original_code:
int main (int argc, char *argv[]) {
 rng state = Rng.seed(0);
 if (Term.init()) {
  Game.loop();
 }
 return 0;
}

canonical_original_code:
int main(int argc, char *argv[]) {
 struct rng state = Rng.seed(0);
 if (Term.init()) {
  Game.loop();
 }
 return 0;
}

variable_types: argc int

variable_types:
argv
char *[]

variable_types: struct rng { unsigned int seed; unsigned int a; }


getkey

decompiled_code:
int getkey()
{
WINDOW *v0; // rdi
int v1; // eax
int result; // eax

v0 = stdscr;
while ( 1 )
{
result = wgetch(v0);
if ( result != 410 )
break;
v0 = stdscr;
if ( stdscr )
{
*((_DWORD *)&Term + 13) = stdscr->_maxy + 1;
v1 = v0->_maxx + 1;
}
else
{
*((_DWORD *)&Term + 13) = -1;
v1 = -1;
}
*((_DWORD *)&Term + 12) = v1;
}
return result;
}

canonical_decompiled_code:
int func0()
{
WINDOW *v0; // rdi
int v1; // eax
int result; // eax

v0 = stdscr;
while ( 1 )
{
result = wgetch(v0);
if ( result != 410 )
break;
v0 = stdscr;
if ( stdscr )
{
*((_DWORD *)&Term + 13) = stdscr->_maxy + 1;
v1 = v0->_maxx + 1;
}
else
{
*((_DWORD *)&Term + 13) = -1;
v1 = -1;
}
*((_DWORD *)&Term + 12) = v1;
}
return result;
}

original_code:
static int getkey( ) {
 while (1) {
  int got = wgetch(stdscr);
  if (got == 0632) {
   (Term.height = ((0 != (const void *)((stdscr))) ? ((stdscr)->_maxy + 1) : (-1)), Term.width = ((0 != (const void *)((stdscr))) ? ((stdscr)->_maxx + 1) : (-1)));
  } else {
   return got;
  }
 }
}

canonical_original_code:
static int getkey() {
 while (1) {
  int got = wgetch(stdscr);
  if (got == 0632) {
   (Term.height = ((0 != (void *)((stdscr))) ? ((stdscr)->_maxy + 1) : (-1)), Term.width = ((0 != (void *)((stdscr))) ? ((stdscr)->_maxx + 1) : (-1)));
  } else {
   return got;
  }
 }
}

variable_types: got int


decompiled_code:
int term_clear()
{
return wclear(stdscr);
}

canonical_decompiled_code:
int func1()
{
return wclear(stdscr);
}

original_code:
static void term_clear( ) {
 wclear(stdscr);
}

canonical_original_code:
static void term_clear() {
 wclear(stdscr);
}


plot

decompiled_code:
int __fastcall plot(int a1, int a2, int a3, unsigned int a4)
{
int result; // eax

wattrset(stdscr, (a3 << 18) & 0x200000 | (((a3 & 7) + ((a3 >> 1) & 0x38) + 1) << 8));
result = wmove(stdscr, a2, a1);
if ( result != -1 )
result = waddch(stdscr, a4);
return result;
}

canonical_decompiled_code:
int __fastcall func2(int a1, int a2, int a3, unsigned int a4)
{
int result; // eax

wattrset(stdscr, (a3 << 18) & 0x200000 | (((a3 & 7) + ((a3 >> 1) & 0x38) + 1) << 8));
result = wmove(stdscr, a2, a1);
if ( result != -1 )
result = waddch(stdscr, a4);
return result;
}

variable_types: x int

variable_types: y int

variable_types: color int

variable_types: ch int


print

decompiled_code:
int __fastcall print(int a1, int a2, int a3, char *a4)
{
_BYTE *v4; // rbx
unsigned int v5; // ecx
int v7; // er13
int v8; // edi
int result; // eax

v4 = a4;
v5 = *a4;
if ( (_BYTE)v5 )
{
v7 = a1 - (_DWORD)v4;
do
{
v8 = v7 + (_DWORD)v4++;
result = plot(v8, a2, a3, v5);
v5 = (char)*v4;
}
while ( *v4 );
}
return result;
}

canonical_decompiled_code:
int __fastcall func3(int a1, int a2, int a3, char *a4)
{
_BYTE *v4; // rbx
unsigned int v5; // ecx
int v7; // er13
int v8; // edi
int result; // eax

v4 = a4;
v5 = *a4;
if ( (_BYTE)v5 )
{
v7 = a1 - (_DWORD)v4;
do
{
v8 = v7 + (_DWORD)v4++;
result = func2(v8, a2, a3, v5);
v5 = (char)*v4;
}
while ( *v4 );
}
return result;
}

original_code:
static void print(int x, int y, int color, const char *ch) {
 while (*ch) {
  plot(x, y, color, *ch);
  x++;
  ch++;
 }
}

canonical_original_code:
static void print(int x, int y, int color, char *ch) {
 while (*ch) {
  plot(x, y, color, *ch);
  x++;
  ch++;
 }
}

variable_types:
ch
char *


cleanup

decompiled_code:
void cleanup(void)
{
if ( videomode )
{
wclear(stdscr);
wrefresh(stdscr);
endwin();
}
}

canonical_decompiled_code:
void func4(void)
{
if ( videomode )
{
wclear(stdscr);
wrefresh(stdscr);
endwin();
}
}

original_code:
static void cleanup( ) {
 if (videomode.curses) {
  wclear(stdscr);
  wrefresh(stdscr);
  endwin();
 }
}

canonical_original_code:
static void cleanup() {
 if (videomode.curses) {
  wclear(stdscr);
  wrefresh(stdscr);
  endwin();
 }
}


preparecolor

decompiled_code:
int preparecolor()
{
__int64 v0; // r13
int v1; // ebx
__int64 v2; // r14
int v3; // esi
int v4; // edi
char v5; // al
int result; // eax

v0 = 0LL;
LOWORD(v1) = 0;
while ( 1 )
{
v2 = 0LL;
LOWORD(v3) = 0;
while ( 1 )
{
v4 = v2 | (1 * v0);
v5 = v2++ | (1 * v0);
result = init_pair((v5 & 7 | (v4 >> 1) & 0x38) + 1, v3, v1);
if ( v2 == 8 )
break;
v3 = pairParts_0[v2];
}
if ( ++v0 == 8 )
break;
v1 = pairParts_0[v0];
}
return result;
}

canonical_decompiled_code:
int func5()
{
__int64 v0; // r13
int v1; // ebx
__int64 v2; // r14
int v3; // esi
int v4; // edi
char v5; // al
int result; // eax

v0 = 0LL;
LOWORD(v1) = 0;
while ( 1 )
{
v2 = 0LL;
LOWORD(v3) = 0;
while ( 1 )
{
v4 = v2 | (1 * v0);
v5 = v2++ | (1 * v0);
result = init_pair((v5 & 7 | (v4 >> 1) & 0x38) + 1, v3, v1);
if ( v2 == 8 )
break;
v3 = pairParts_0[v2];
}
if ( ++v0 == 8 )
break;
v1 = pairParts_0[v0];
}
return result;
}

variable_types:
pairParts
int [8]

variable_types: fg int

variable_types: bg int


decompiled_code:
__int64 curses_init()
{
__int64 result; // rax
int v1; // eax

result = 0LL;
if ( !videomode )
{
initscr();
if ( has_colors() )
{
start_color();
wclear(stdscr);
curs_set(0);
wrefresh(stdscr);
leaveok(stdscr, 1);
preparecolor();
cbreak();
noecho();
meta(stdscr, 1);
keypad(stdscr, 1);
mousemask(0x10000003uLL, 0LL);
mouseinterval(0);
videomode = 1;
if ( stdscr )
{
v1 = stdscr->_maxx + 1;
*((_DWORD *)&Term + 13) = stdscr->_maxy + 1;
}
else
{
*((_DWORD *)&Term + 13) = -1;
v1 = -1;
}
*((_DWORD *)&Term + 12) = v1;
atexit(cleanup);
result = 1LL;
}
else
{
endwin();
fwrite("Your terminal has no color support.\n", 1uLL, 0x24uLL, stderr);
result = 1LL;
}
}
return result;
}

canonical_decompiled_code:
__int64 func6()
{
__int64 result; // rax
int v1; // eax

result = 0LL;
if ( !videomode )
{
initscr();
if ( has_colors() )
{
start_color();
wclear(stdscr);
curs_set(0);
wrefresh(stdscr);
leaveok(stdscr, 1);
func5();
cbreak();
noecho();
meta(stdscr, 1);
keypad(stdscr, 1);
mousemask(0x10000003uLL, 0LL);
mouseinterval(0);
videomode = 1;
if ( stdscr )
{
v1 = stdscr->_maxx + 1;
*((_DWORD *)&Term + 13) = stdscr->_maxy + 1;
}
else
{
*((_DWORD *)&Term + 13) = -1;
v1 = -1;
}
*((_DWORD *)&Term + 12) = v1;
atexit(cleanup);
result = 1LL;
}
else
{
endwin();
fwrite("Your terminal has no color support.\n", 1uLL, 0x24uLL, stderr);
result = 1LL;
}
}
return result;
}

original_code:
static int curses_init( ) {
 if (videomode.curses) return 0;
 initscr( );
 if (!has_colors( )) {
  endwin( );
  fprintf (stderr, "Your terminal has no color support.\n");
  return 1;
 }
 start_color( );
 wclear(stdscr);
 curs_set( 0 );
 wrefresh(stdscr);
 leaveok(stdscr, 1);
 preparecolor( );
 cbreak( );
 noecho( );
 meta(stdscr, 1);
 keypad(stdscr, 1);
 mousemask(((002L) << (((1) - 1) * 5)) | ((001L) << (((1) - 1) * 5)) | ((0010L) << (((6) - 1) * 5)), ((void *)0));
 mouseinterval(0);
 videomode.curses = 1;
 (Term.height = ((0 != (const void *)((stdscr))) ? ((stdscr)->_maxy + 1) : (-1)), Term.width = ((0 != (const void *)((stdscr))) ? ((stdscr)->_maxx + 1) : (-1)));
 atexit(cleanup);
 return 1;
}

canonical_original_code:
static int curses_init() {
 if (videomode.curses) return 0;
 initscr( );
 if (!has_colors( )) {
  endwin( );
  fprintf (stderr, "Your terminal has no color support.\n");
  return 1;
 }
 start_color( );
 wclear(stdscr);
 curs_set( 0 );
 wrefresh(stdscr);
 leaveok(stdscr, 1);
 preparecolor( );
 cbreak( );
 noecho( );
 meta(stdscr, 1);
 keypad(stdscr, 1);
 mousemask(((002L) << (((1) - 1) * 5)) | ((001L) << (((1) - 1) * 5)) | ((0010L) << (((6) - 1) * 5)), ((void *)0));
 mouseinterval(0);
 videomode.curses = 1;
 (Term.height = ((0 != (void *)((stdscr))) ? ((stdscr)->_maxy + 1) : (-1)), Term.width = ((0 != (void *)((stdscr))) ? ((stdscr)->_maxx + 1) : (-1)));
 atexit(cleanup);
 return 1;
}


read

decompiled_code:
void *read()
{
*(_BYTE *)writer = 0;
return &buffer;
}

canonical_decompiled_code:
void *func0()
{
*(_BYTE *)writer = 0;
return &buffer;
}

original_code:
static char *read( ) {
 if ((1)) {
  *writer = '\0';
  return buffer;
 } else {
  return "Error in string builder.";
 }
}

canonical_original_code:
static char *read() {
 if ((1)) {
  *writer = '\0';
  return buffer;
 } else {
  return "Error in string builder.";
 }
}

return_type: char *


publish

decompiled_code:
__int64 __fastcall publish(__int64 a1)
{
__int64 result; // rax
void *v2; // rax
__int64 (__fastcall *v3)(__int64, void *); // rdx

result = (unsigned int)enabled;
if ( enabled )
{
v2 = read();
result = v3(a1, v2);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1)
{
__int64 result; // rax
void *v2; // rax
__int64 (__fastcall *v3)(__int64, void *); // rdx

result = (unsigned int)enabled;
if ( enabled )
{
v2 = func0();
result = v3(a1, v2);
}
return result;
}

original_code:
static void publish(chronicle *chron) {
 if (enabled) {
  Chronicle.post(chron, read( ));
 }
}

canonical_original_code:
static void publish(struct chronicle *chron) {
 if (enabled) {
  Chronicle.post(chron, read( ));
 }
}

variable_types: struct chronicle { struct message { int turn_number; char *text; int length; struct message *prev; int fork_count; } *last; int turn_number; } *

user_defined_types: struct chronicle { struct message *last; int turn_number; }


enable

decompiled_code:
void __fastcall enable(int a1)
{
enabled = a1;
}

canonical_decompiled_code:
void __fastcall func2(int a1)
{
enabled = a1;
}

original_code:
static void enable (int on) {
 enabled = on;
}

canonical_original_code:
static void enable(int on) {
 enabled = on;
}

variable_types: on int


original_code:
void layer_fill(layer *layer, int value) {
 int i, length = layer->width * layer->height;
 for (i = 0; i < length; i++) {
  layer->buffer[i] = value;
 }
}

canonical_original_code:
void layer_fill(struct layer *layer, int value) {
 int i; int length = layer->width * layer->height;
 for (i = 0; i < length; i++) {
  layer->buffer[i] = value;
 }
}

variable_types: struct layer { int width; int x1; int oob; int buffer[]; } *

variable_types: value int

variable_types: i int

variable_types: length int


decompiled_code:
__int64 __fastcall layer_set(_DWORD *a1, int a2, int a3, int a4)
{
__int64 result; // rax
int v5; // er8

result = (unsigned int)a1[2];
if ( (int)result <= a2 )
{
v5 = a1[3];
if ( v5 <= a3 && a1[4] >= a2 && a1[5] >= a3 )
{
result = *a1 * (a3 - v5) + a2 - (int)result;
a1[result + 7] = a4;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(_DWORD *a1, int a2, int a3, int a4)
{
__int64 result; // rax
int v5; // er8

result = (unsigned int)a1[2];
if ( (int)result <= a2 )
{
v5 = a1[3];
if ( v5 <= a3 && a1[4] >= a2 && a1[5] >= a3 )
{
result = *a1 * (a3 - v5) + a2 - (int)result;
a1[result + 7] = a4;
}
}
return result;
}

original_code:
void layer_set(layer *layer, int x, int y, int value) {
 if (x < layer->x1 || y < layer->y1 || x > layer->x2 || y > layer->y2) {
  return;
 } else {
  int index = (x - layer->x1) + (y - layer->y1) * layer->width;
  layer->buffer[index] = value;
 }
}

canonical_original_code:
void layer_set(struct layer *layer, int x, int y, int value) {
 if (x < layer->x1 || y < layer->y1 || x > layer->x2 || y > layer->y2) {
  return;
 } else {
  int index = (x - layer->x1) + (y - layer->y1) * layer->width;
  layer->buffer[index] = value;
 }
}

variable_types: index int

user_defined_types: struct layer { int width; int x1; int oob; int buffer[]; }


decompiled_code:
__int64 __fastcall layer_get(_DWORD *a1, int a2, int a3)
{
int v3; // eax
int v4; // ecx
__int64 result; // rax

v3 = a1[2];
if ( v3 <= a2 && (v4 = a1[3], v4 <= a3) && a1[4] >= a2 && a1[5] >= a3 )
result = (unsigned int)a1[*a1 * (a3 - v4) + 7 + a2 - v3];
else
result = (unsigned int)a1[6];
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(_DWORD *a1, int a2, int a3)
{
int v3; // eax
int v4; // ecx
__int64 result; // rax

v3 = a1[2];
if ( v3 <= a2 && (v4 = a1[3], v4 <= a3) && a1[4] >= a2 && a1[5] >= a3 )
result = (unsigned int)a1[*a1 * (a3 - v4) + 7 + a2 - v3];
else
result = (unsigned int)a1[6];
return result;
}

original_code:
int layer_get(layer *layer, int x, int y) {
 if (x < layer->x1 || y < layer->y1 || x > layer->x2 || y > layer->y2) {
  return layer->oob;
 } else {
  int index = (x - layer->x1) + (y - layer->y1) * layer->width;
  return layer->buffer[index];
 }
}

canonical_original_code:
int layer_get(struct layer *layer, int x, int y) {
 if (x < layer->x1 || y < layer->y1 || x > layer->x2 || y > layer->y2) {
  return layer->oob;
 } else {
  int index = (x - layer->x1) + (y - layer->y1) * layer->width;
  return layer->buffer[index];
 }
}


original_code:
void chronicle_post (chronicle *chron, const char *text) {
 if (chron == ((void *)0) || text == ((void *)0)) return;
 message *msg = malloc(sizeof(message));
 int length = strlen(text);
 msg->length = length;
 msg->text = malloc(length + 1);
 msg->turn_number = chron->turn_number;
 msg->fork_count = 0;
 msg->prev = chron->last;
 chron->last = msg;
 chron->count++;
 memcpy(msg->text, text, length + 1);
}

canonical_original_code:
void chronicle_post(struct chronicle *chron, char *text) {
 if (chron == ((void *)0) || text == ((void *)0)) return;
 struct message *msg = malloc(sizeof(message));
 int length = strlen(text);
 msg->length = length;
 msg->text = malloc(length + 1);
 msg->turn_number = chron->turn_number;
 msg->fork_count = 0;
 msg->prev = chron->last;
 chron->last = msg;
 chron->count++;
 memcpy(msg->text, text, length + 1);
}

variable_types:
text
char *

variable_types: struct message { int turn_number; char *text; int length; struct message *prev; int fork_count; } *


original_code:
void chronicle_free (chronicle *chron) {
 message *msg = chron->last;
 free(chron);
 while (msg != ((void *)0) && !msg->fork_count) {
  message *prev = msg->prev;
  free(msg);
  msg = prev;
 }
 if (msg != ((void *)0)) {
  msg->fork_count--;
 }
}

canonical_original_code:
void chronicle_free(struct chronicle *chron) {
 struct message *msg = chron->last;
 free(chron);
 while (msg != ((void *)0) && !msg->fork_count) {
  struct message *prev = msg->prev;
  free(msg);
  msg = prev;
 }
 if (msg != ((void *)0)) {
  msg->fork_count--;
 }
}

user_defined_types: struct message { int turn_number; char *text; int length; struct message *prev; int fork_count; }


decompiled_code:
__int64 __fastcall check_apply_effect(__int64 a1, __int64 a2)
{
_BYTE *v2; // rax
char v3; // al
__int64 result; // rax

v2 = *(_BYTE **)(*(_QWORD *)a2 + 104LL);
if ( *v2 == 119 && ((v3 = v2[1], v3 == 45) || v3 == 113) )
result = 1LL;
else
result = 2LL;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 a2)
{
_BYTE *v2; // rax
char v3; // al
__int64 result; // rax

v2 = *(_BYTE **)(*(_QWORD *)a2 + 104LL);
if ( *v2 == 119 && ((v3 = v2[1], v3 == 45) || v3 == 113) )
result = 1LL;
else
result = 2LL;
return result;
}

original_code:
static enum effects check_apply_effect(worldstate *state, agent *item, int itemnumber) {
 int magictype = item->def->asitem.magic[0];
 if (magictype == 'w') {
  char hacktype = item->def->asitem.magic[1];
  if (hacktype == '-') return outcome_like_waiting;
  if (hacktype == 'q') return outcome_like_waiting;
  else return outcome_needs_forking;
 } else {
  return outcome_needs_forking;
 }
}

canonical_original_code:
static enum effects check_apply_effect(struct worldstate *state, struct agent *item, int itemnumber) {
 int magictype = item->def->asitem.magic[0];
 if (magictype == 'w') {
  char hacktype = item->def->asitem.magic[1];
  if (hacktype == '-') return outcome_like_waiting;
  if (hacktype == 'q') return outcome_like_waiting;
  else return outcome_needs_forking;
 } else {
  return outcome_needs_forking;
 }
}

variable_types: struct worldstate { int locked; int donotfree; int isvalid; int turk_active; int totaltime; struct rng { unsigned int seed; unsigned int a; } randomness; struct agentlist { struct agent { struct mondef { struct forms_t { char *tag; char *name; char *desc; } forms; struct asabout_t { int glyph; } about; struct ascell_t { int flags; char *promotion; } ascell; struct asmob_t { int hp; char *stab; char *stumble; char *speed; } asmob; struct asitem_t { char *magic; char *stab; } asitem; } *def; int x; int hp; int time; } *buffer; int max; } agents; struct agent *player; struct layout { int left; int shiftx; int lastItem; } *layout; struct gameboard { int width; struct mondef **cells; int fork_count; } *board; struct chronicle { struct message { int turn_number; char *text; int length; struct message *prev; int fork_count; } *last; int turn_number; } *chron; struct layer { int width; int x1; int oob; int buffer[]; } *player_fov; struct agent inventory[-1]; } *

variable_types:
item
struct agent *

variable_types: itemnumber int

variable_types: magictype int

variable_types: hacktype char

return_type: enum effects { outcome_invalid=0, outcome_like_waiting=1, outcome_needs_forking=2 }

user_defined_types: struct worldstate { int locked; int donotfree; int isvalid; int turk_active; int totaltime; struct rng randomness; struct agentlist agents; struct agent *player; struct layout *layout; struct gameboard *board; struct chronicle *chron; struct layer *player_fov; struct agent inventory[-1]; }

user_defined_types: struct agentlist { struct agent *buffer; int max; }

user_defined_types: struct agent { struct mondef *def; int x; int hp; int time; }

user_defined_types: struct mondef { struct forms_t forms; struct asabout_t about; struct ascell_t ascell; struct asmob_t asmob; struct asitem_t asitem; }


decompiled_code:
__int64 __fastcall check_fire_effect(__int64 a1, __int64 a2, int a3, int a4)
{
__int64 v5; // r11
int v6; // edx
__int64 result; // rax
int v8; // [rsp+0h] [rbp-18h] BYREF
int v9; // [rsp+4h] [rbp-14h] BYREF
__int64 v10[2]; // [rsp+8h] [rbp-10h] BYREF

v5 = *(_QWORD *)(a1 + 80);
v6 = *(char *)(*(_QWORD *)(*(_QWORD *)a2 + 104LL) + 2LL);
if ( v6 == 98 )
{
v9 = -1;
LODWORD(v10[0]) = -1;
trace_shot_constprop_0(a1, v5, a3, a4, 32, &v9, v10, 0LL);
result = 2 * (unsigned int)(v9 != -1);
}
else
{
result = 1LL;
if ( v6 == 100 )
{
v10[0] = 0LL;
v8 = -1;
v9 = -1;
trace_shot_constprop_0(a1, v5, a3, a4, 64, &v8, &v9, v10);
result = 2 * (unsigned int)(v8 != -1);
}
}
return result;
}

original_code:
static enum effects check_fire_effect(worldstate *state, agent *item, int dx, int dy) {
 agent *player = state->player;
 int stafftype = item->def->asitem.magic[2];
 if (stafftype == 'b') {
  int x = -1, y = -1;
  trace_shot(state, player, dx, dy, 8, ' ', &x, &y, ((void *)0));
  if (x == -1) return outcome_invalid;
  else return outcome_needs_forking;
 }
 if (stafftype == 'd') {
  agent *mob = ((void *)0);
  int x = -1, y = -1;
  trace_shot(state, player, dx, dy, 8, '@', &x, &y, &mob);
  if (x == -1) return outcome_invalid;
  else return outcome_needs_forking;
 }
 return outcome_like_waiting;
}

canonical_original_code:
static enum effects check_fire_effect(struct worldstate *state, struct agent *item, int dx, int dy) {
 struct agent *player = state->player;
 int stafftype = item->def->asitem.magic[2];
 if (stafftype == 'b') {
  int x = -1; int y = -1;
  trace_shot(state, player, dx, dy, 8, ' ', &x, &y, ((void *)0));
  if (x == -1) return outcome_invalid;
  else return outcome_needs_forking;
 }
 if (stafftype == 'd') {
  struct agent *mob = ((void *)0);
  int x = -1; int y = -1;
  trace_shot(state, player, dx, dy, 8, '@', &x, &y, &mob);
  if (x == -1) return outcome_invalid;
  else return outcome_needs_forking;
 }
 return outcome_like_waiting;
}

variable_types: dx int

variable_types: dy int

variable_types: struct agent { struct mondef { struct forms_t { char *tag; char *name; char *desc; } forms; struct asabout_t { int glyph; } about; struct ascell_t { int flags; char *promotion; } ascell; struct asmob_t { int hp; char *stab; char *stumble; char *speed; } asmob; struct asitem_t { char *magic; char *stab; } asitem; } *def; int x; int hp; int time; } *

variable_types: stafftype int

variable_types: x int

variable_types: y int

user_defined_types: enum effects { outcome_invalid=0, outcome_like_waiting=1, outcome_needs_forking=2 }

user_defined_types: struct rng { unsigned int seed; unsigned int a; }

user_defined_types: struct layout { int left; int shiftx; int lastItem; }

user_defined_types: struct gameboard { int width; struct mondef **cells; int fork_count; }


original_code:
static enum effects do_fire_effect(worldstate *state, agent *item, int dx, int dy) {
 agent *player = state->player;
 int stafftype = item->def->asitem.magic[2];
 if (stafftype == 'b') {
  int x = -1, y = -1;
  trace_shot(state, player, dx, dy, 8, ' ', &x, &y, ((void *)0));
  if (x == -1) return outcome_invalid;
  else {
   Chronicle.post(state->chron, "You blink!");
   player->x = x;
   player->y = y;
  }
 }
 if (stafftype == 'd') {
  agent *mob = ((void *)0);
  int x = -1, y = -1;
  trace_shot(state, player, dx, dy, 8, '@', &x, &y, &mob);
  if (x == -1) return outcome_invalid;
  else {
   mob->hp = 0;
   Chronicle.post(state->chron, "Bam!  Dead.");
   return outcome_needs_forking;
  }
 }
 return outcome_like_waiting;
}

canonical_original_code:
static enum effects do_fire_effect(struct worldstate *state, struct agent *item, int dx, int dy) {
 struct agent *player = state->player;
 int stafftype = item->def->asitem.magic[2];
 if (stafftype == 'b') {
  int x = -1; int y = -1;
  trace_shot(state, player, dx, dy, 8, ' ', &x, &y, ((void *)0));
  if (x == -1) return outcome_invalid;
  else {
   Chronicle.post(state->chron, "You blink!");
   player->x = x;
   player->y = y;
  }
 }
 if (stafftype == 'd') {
  struct agent *mob = ((void *)0);
  int x = -1; int y = -1;
  trace_shot(state, player, dx, dy, 8, '@', &x, &y, &mob);
  if (x == -1) return outcome_invalid;
  else {
   mob->hp = 0;
   Chronicle.post(state->chron, "Bam!  Dead.");
   return outcome_needs_forking;
  }
 }
 return outcome_like_waiting;
}

user_defined_types: struct forms_t { char *tag; char *name; char *desc; }

user_defined_types: struct ascell_t { int flags; char *promotion; }

user_defined_types: struct asmob_t { int hp; char *stab; char *stumble; char *speed; }

user_defined_types: struct asitem_t { char *magic; char *stab; }


lookup

decompiled_code:
char **__fastcall lookup(int a1, const char *a2)
{
bool v2; // zf
const char *v3; // rdi
char **v4; // rax
char **v5; // r12

if ( a1 == 1 )
{
v3 = "* turk";
v4 = itemdefs;
}
else
{
v2 = a1 == 2;
v3 = "rogue";
if ( v2 )
v3 = "blank";
v4 = &mondefs;
if ( v2 )
v4 = &celldefs;
}
while ( 1 )
{
v5 = v4;
if ( !strcmp(v3, a2) )
return v5;
v4 = v5 + 15;
if ( !*((_DWORD *)v5 + 38) )
break;
v3 = v5[15];
}
return 0LL;
}

canonical_decompiled_code:
char **__fastcall func0(int a1, const char *a2)
{
bool v2; // zf
const char *v3; // rdi
char **v4; // rax
char **v5; // r12

if ( a1 == 1 )
{
v3 = "* turk";
v4 = itemdefs;
}
else
{
v2 = a1 == 2;
v3 = "rogue";
if ( v2 )
v3 = "blank";
v4 = &mondefs;
if ( v2 )
v4 = &celldefs;
}
while ( 1 )
{
v5 = v4;
if ( !strcmp(v3, a2) )
return v5;
v4 = v5 + 15;
if ( !*((_DWORD *)v5 + 38) )
break;
v3 = v5[15];
}
return 0LL;
}

original_code:
static const mondef *lookup(int whichlist, const char *tag) {
 int i;
 const mondef *list = mondefs;
 if (whichlist == 1) list = itemdefs;
 if (whichlist == 2) list = celldefs;
 for (i = 0; list[i].about.glyph != '\0'; i++) {
  if (strcmp(list[i].forms.tag, tag) == 0) {
   return list + i;
  }
 }
 return 0;
}

canonical_original_code:
static struct mondef *lookup(int whichlist, char *tag) {
 int i;
 struct mondef *list = mondefs;
 if (whichlist == 1) list = itemdefs;
 if (whichlist == 2) list = celldefs;
 for (i = 0; list[i].about.glyph != '\0'; i++) {
  if (strcmp(list[i].forms.tag, tag) == 0) {
   return list + i;
  }
 }
 return 0;
}

variable_types: whichlist int

variable_types:
tag
char *

variable_types: struct mondef { struct forms_t { char *tag; char *name; char *desc; } forms; struct asabout_t { int glyph; } about; struct ascell_t { int flags; char *promotion; } ascell; struct asmob_t { int hp; char *stab; char *stumble; char *speed; } asmob; struct asitem_t { char *magic; char *stab; } asitem; } *


main

repo: josmardias/linkedlist

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int64 v3; // rbp
__int64 v4; // rax
__int64 v5; // rax
__int64 v6; // rax
__int64 v7; // rax
__int64 v8; // rbp

v3 = Person_newlist(argc, argv, envp);
v4 = Person_new(10LL);
List_add(v3, v4);
v5 = Person_new(1LL);
List_add(v3, v5);
v6 = Person_new(9LL);
List_add(v3, v6);
v7 = Person_new(8LL);
List_add(v3, v7);
puts("All people:");
List_print(v3);
puts("Inverse:");
List_print_inverse(v3);
v8 = List_findOne(v3, 3LL);
printf("\nPerson with id %llu:\n", 3LL);
Person_print(v8);
return 0;
}

original_code:
int main() {
    List *l = Person_newlist();
    List_add(l, Person_new(10));
    List_add(l, Person_new(1));
    List_add(l, Person_new(9));
    List_add(l, Person_new(8));
    puts("All people:");
    List_print(l);
    puts("Inverse:");
    List_print_inverse(l);
    unsigned long long id = 3;
    Person * p = List_findOne(l, (void *)id);
    printf("\nPerson with id %llu:\n", id);
    Person_print(p);
    return 0;
}

canonical_original_code:
int main() {
    struct List *l = Person_newlist();
    List_add(l, Person_new(10));
    List_add(l, Person_new(1));
    List_add(l, Person_new(9));
    List_add(l, Person_new(8));
    puts("All people:");
    List_print(l);
    puts("Inverse:");
    List_print_inverse(l);
    unsigned long long id = 3;
    struct Person *p = List_findOne(l, (void *)id);
    printf("\nPerson with id %llu:\n", id);
    Person_print(p);
    return 0;
}

variable_types: struct List { int length; struct node { void *info; struct node *next; } *head; int (*cmp)(void *, void *); void (*print)(void *); _Bool (*query)(void *, void *); } *

variable_types:
id
unsigned long long

variable_types:
p
struct Person { int id; int age; } *

user_defined_types: struct List { int length; struct node *head; int (*cmp)(void *, void *); void (*print)(void *); _Bool (*query)(void *, void *); }