decompiled_code:
__int64 __fastcall cvar_register(__int64 a1)
{
int v1; // esi
int v3; // er12
char v4; // r10
__int64 *v5; // r11
int v6; // edx
__int64 *v7; // rax
int v8; // ebx
__int64 *v9; // rcx
int v10; // er8
char *v11; // rax
char v12; // bl
unsigned int v13; // er12
__int64 v14; // rdi
char v15; // al

v1 = cvar_arraysize;
v3 = ++cvar_count;
if ( cvar_arrayfirstopen >= cvar_arraysize )
{
if ( cvar_arrayfirstopen != cvar_arraysize )
{
v6 = cvar_arrayfirstopen;
v9 = (__int64 *)((char *)cvar_list + 8 * cvar_arrayfirstopen);
goto LABEL_32;
}
goto LABEL_31;
}
v4 = 0;
v5 = (__int64 *)((char *)cvar_list + 8 * cvar_arrayfirstopen);
v6 = cvar_arrayfirstopen;
v7 = v5;
v8 = ((_BYTE)cvar_arraysize - (_BYTE)cvar_arrayfirstopen) & 7;
if ( (((_BYTE)cvar_arraysize - (_BYTE)cvar_arrayfirstopen) & 7) == 0 )
goto LABEL_21;
switch ( v8 )
{
case 1:
LABEL_19:
v9 = v7;
if ( !*v7 )
goto LABEL_37;
++v6;
++v7;
v4 = 1;
if ( v6 != cvar_arraysize )
{
LABEL_21:
while ( 1 )
{
v9 = v7;
if ( !*v7 )
break;
v9 = v7 + 1;
v10 = v6 + 1;
v4 = 1;
++v6;
if ( !v7[1] )
goto LABEL_38;
++v6;
v9 = v7 + 2;
if ( !v7[2] )
goto LABEL_38;
v6 = v10 + 2;
v9 = v7 + 3;
if ( !v7[3] )
goto LABEL_38;
v6 = v10 + 3;
v9 = v7 + 4;
if ( !v7[4] )
goto LABEL_38;
v6 = v10 + 4;
v9 = v7 + 5;
if ( !v7[5] )
goto LABEL_38;
v6 = v10 + 5;
v9 = v7 + 6;
if ( !v7[6] )
goto LABEL_38;
v6 = v10 + 6;
v9 = v7 + 7;
if ( !v7[7] )
goto LABEL_38;
v6 = v10 + 7;
v7 += 8;
if ( v10 + 7 == cvar_arraysize )
goto LABEL_30;
}
LABEL_37:
if ( v4 )
{
LABEL_38:
cvar_arrayfirstopen = v6;
goto LABEL_32;
}
goto LABEL_42;
}
LABEL_30:
cvar_arrayfirstopen = cvar_arraysize;
LABEL_31:
++cvar_arraysize;
v11 = (char *)realloc(cvar_list, 88LL * (v1 + 1));
v3 = cvar_count;
cvar_list = v11;
v6 = cvar_arrayfirstopen;
v9 = (__int64 *)&v11[8 * cvar_arrayfirstopen];
goto LABEL_32;
case 2:
LABEL_17:
v9 = v7;
if ( !*v7 )
goto LABEL_37;
++v6;
++v7;
v4 = 1;
goto LABEL_19;
case 3:
LABEL_15:
v9 = v7;
if ( !*v7 )
goto LABEL_37;
++v6;
++v7;
v4 = 1;
goto LABEL_17;
case 4:
LABEL_13:
v9 = v7;
if ( !*v7 )
goto LABEL_37;
++v6;
++v7;
v4 = 1;
goto LABEL_15;
case 5:
LABEL_11:
v9 = v7;
if ( !*v7 )
goto LABEL_37;
++v6;
++v7;
v4 = 1;
goto LABEL_13;
}
if ( v8 == 6 || (v6 = cvar_arrayfirstopen + 1, v7 = v5 + 1, v4 = 1, *v5) )
{
v9 = v7;
if ( !*v7 )
goto LABEL_37;
++v6;
++v7;
v4 = 1;
goto LABEL_11;
}
LABEL_42:
v9 = (__int64 *)((char *)cvar_list + 8 * cvar_arrayfirstopen);
v6 = cvar_arrayfirstopen;
LABEL_32:
*v9 = a1;
v12 = *(_BYTE *)a1;
v13 = v6 | (v3 << 16);
v14 = *(_QWORD *)(a1 + 8);
v15 = *(_BYTE *)a1;
*(_DWORD *)(a1 + 76) = v13;
*(_BYTE *)a1 = v15 | 1;
addToHashTable(v14, v13, &cvarhashtable);
if ( cvar_arraylasttaken >= cvar_arrayfirstopen )
{
if ( (v12 & 8) != 0 )
return v13;
}
else
{
cvar_arraylasttaken = cvar_arrayfirstopen;
if ( (v12 & 8) != 0 )
return v13;
}
cvar_pset(a1, *(const char **)(a1 + 24));
return v13;
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1)
{
int v1; // esi
int v3; // er12
char v4; // r10
__int64 *v5; // r11
int v6; // edx
__int64 *v7; // rax
int v8; // ebx
__int64 *v9; // rcx
int v10; // er8
char *v11; // rax
char v12; // bl
unsigned int v13; // er12
__int64 v14; // rdi
char v15; // al

v1 = cvar_arraysize;
v3 = ++cvar_count;
if ( cvar_arrayfirstopen >= cvar_arraysize )
{
if ( cvar_arrayfirstopen != cvar_arraysize )
{
v6 = cvar_arrayfirstopen;
v9 = (__int64 *)((char *)cvar_list + 8 * cvar_arrayfirstopen);
goto LABEL_32;
}
goto LABEL_31;
}
v4 = 0;
v5 = (__int64 *)((char *)cvar_list + 8 * cvar_arrayfirstopen);
v6 = cvar_arrayfirstopen;
v7 = v5;
v8 = ((_BYTE)cvar_arraysize - (_BYTE)cvar_arrayfirstopen) & 7;
if ( (((_BYTE)cvar_arraysize - (_BYTE)cvar_arrayfirstopen) & 7) == 0 )
goto LABEL_21;
switch ( v8 )
{
case 1:
LABEL_19:
v9 = v7;
if ( !*v7 )
goto LABEL_37;
++v6;
++v7;
v4 = 1;
if ( v6 != cvar_arraysize )
{
LABEL_21:
while ( 1 )
{
v9 = v7;
if ( !*v7 )
break;
v9 = v7 + 1;
v10 = v6 + 1;
v4 = 1;
++v6;
if ( !v7[1] )
goto LABEL_38;
++v6;
v9 = v7 + 2;
if ( !v7[2] )
goto LABEL_38;
v6 = v10 + 2;
v9 = v7 + 3;
if ( !v7[3] )
goto LABEL_38;
v6 = v10 + 3;
v9 = v7 + 4;
if ( !v7[4] )
goto LABEL_38;
v6 = v10 + 4;
v9 = v7 + 5;
if ( !v7[5] )
goto LABEL_38;
v6 = v10 + 5;
v9 = v7 + 6;
if ( !v7[6] )
goto LABEL_38;
v6 = v10 + 6;
v9 = v7 + 7;
if ( !v7[7] )
goto LABEL_38;
v6 = v10 + 7;
v7 += 8;
if ( v10 + 7 == cvar_arraysize )
goto LABEL_30;
}
LABEL_37:
if ( v4 )
{
LABEL_38:
cvar_arrayfirstopen = v6;
goto LABEL_32;
}
goto LABEL_42;
}
LABEL_30:
cvar_arrayfirstopen = cvar_arraysize;
LABEL_31:
++cvar_arraysize;
v11 = (char *)realloc(cvar_list, 88LL * (v1 + 1));
v3 = cvar_count;
cvar_list = v11;
v6 = cvar_arrayfirstopen;
v9 = (__int64 *)&v11[8 * cvar_arrayfirstopen];
goto LABEL_32;
case 2:
LABEL_17:
v9 = v7;
if ( !*v7 )
goto LABEL_37;
++v6;
++v7;
v4 = 1;
goto LABEL_19;
case 3:
LABEL_15:
v9 = v7;
if ( !*v7 )
goto LABEL_37;
++v6;
++v7;
v4 = 1;
goto LABEL_17;
case 4:
LABEL_13:
v9 = v7;
if ( !*v7 )
goto LABEL_37;
++v6;
++v7;
v4 = 1;
goto LABEL_15;
case 5:
LABEL_11:
v9 = v7;
if ( !*v7 )
goto LABEL_37;
++v6;
++v7;
v4 = 1;
goto LABEL_13;
}
if ( v8 == 6 || (v6 = cvar_arrayfirstopen + 1, v7 = v5 + 1, v4 = 1, *v5) )
{
v9 = v7;
if ( !*v7 )
goto LABEL_37;
++v6;
++v7;
v4 = 1;
goto LABEL_11;
}
LABEL_42:
v9 = (__int64 *)((char *)cvar_list + 8 * cvar_arrayfirstopen);
v6 = cvar_arrayfirstopen;
LABEL_32:
*v9 = a1;
v12 = *(_BYTE *)a1;
v13 = v6 | (v3 << 16);
v14 = *(_QWORD *)(a1 + 8);
v15 = *(_BYTE *)a1;
*(_DWORD *)(a1 + 76) = v13;
*(_BYTE *)a1 = v15 | 1;
addToHashTable(v14, v13, &cvarhashtable);
if ( cvar_arraylasttaken >= cvar_arrayfirstopen )
{
if ( (v12 & 8) != 0 )
return v13;
}
else
{
cvar_arraylasttaken = cvar_arrayfirstopen;
if ( (v12 & 8) != 0 )
return v13;
}
func5(a1, *(const char **)(a1 + 24));
return v13;
}

original_code:
int cvar_register(cvar_t *c){
 cvar_count++;
 for(; cvar_arrayfirstopen < cvar_arraysize && cvar_list[cvar_arrayfirstopen]; cvar_arrayfirstopen++);
 if(cvar_arrayfirstopen == cvar_arraysize){
  cvar_arraysize++;
  cvar_list = realloc(cvar_list, cvar_arraysize * sizeof(cvar_t));
 }
 cvar_list[cvar_arrayfirstopen] = c;
 int returnid = (cvar_count << 16) | cvar_arrayfirstopen;
 c->myid = returnid;
 c->type = c->type | 1;
 char flags = c->type;
 addToHashTable(c->name, returnid, cvarhashtable);
 if(cvar_arraylasttaken < cvar_arrayfirstopen) cvar_arraylasttaken = cvar_arrayfirstopen;
 if(!(flags & 8)){
  cvar_pset(c, c->defaultstring);
 }
 return returnid;
}

canonical_original_code:
int cvar_register(struct cvar_s *c){
 cvar_count++;
 for(; cvar_arrayfirstopen < cvar_arraysize && cvar_list[cvar_arrayfirstopen]; cvar_arrayfirstopen++);
 if(cvar_arrayfirstopen == cvar_arraysize){
  cvar_arraysize++;
  cvar_list = realloc(cvar_list, cvar_arraysize * sizeof(cvar_t));
 }
 cvar_list[cvar_arrayfirstopen] = c;
 int returnid = (cvar_count << 16) | cvar_arrayfirstopen;
 c->myid = returnid;
 c->type = c->type | 1;
 char flags = c->type;
 addToHashTable(c->name, returnid, cvarhashtable);
 if(cvar_arraylasttaken < cvar_arrayfirstopen) cvar_arraylasttaken = cvar_arrayfirstopen;
 if(!(flags & 8)){
  cvar_pset(c, c->defaultstring);
 }
 return returnid;
}


decompiled_code:
void __fastcall cvar_idset(int a1, const char *a2)
{
__int64 v2; // rax

v2 = cvar_returnById(a1);
cvar_pset(v2, a2);
}

canonical_decompiled_code:
void __fastcall func7(int a1, const char *a2)
{
__int64 v2; // rax

v2 = func2(a1);
func5(v2, a2);
}

original_code:
void cvar_idset(const int id, const char *value){
 cvar_pset(cvar_returnById(id), value);
}

canonical_original_code:
void cvar_idset(int id, char *value){
 cvar_pset(cvar_returnById(id), value);
}

variable_types: id int

variable_types:
value
char *

return_type: void


decompiled_code:
void __fastcall cvar_nameset(__int64 a1, const char *a2)
{
__int64 v2; // rax

v2 = cvar_findByNameRPOINT(a1);
cvar_pset(v2, a2);
}

canonical_decompiled_code:
void __fastcall func8(__int64 a1, const char *a2)
{
__int64 v2; // rax

v2 = func3(a1);
func5(v2, a2);
}

original_code:
void cvar_nameset(char * name, const char *value){
 cvar_pset(cvar_findByNameRPOINT(name), value);
}

canonical_original_code:
void cvar_nameset(char *name, char *value){
 cvar_pset(cvar_findByNameRPOINT(name), value);
}

variable_types:
name
char *


checkBBoxPInBBox

original_code:
unsigned char checkBBoxPInBBox(const vec_t *bbox, const vec_t *bboxp){
 unsigned int j;
 for(j = 0; j < 24; j+=3){ if(bboxp[j] < bbox[0]) break;} if(j==24)return 0;
 for(j = 0; j < 24; j+=3){ if(bboxp[j] > bbox[1]) break;} if(j==24)return 0;
 for(j = 1; j < 24; j+=3){ if(bboxp[j] < bbox[2]) break;} if(j> 24)return 0;
 for(j = 1; j < 24; j+=3){ if(bboxp[j] > bbox[3]) break;} if(j> 24)return 0;
 for(j = 2; j < 24; j+=3){ if(bboxp[j] < bbox[4]) break;} if(j> 24)return 0;
 for(j = 2; j < 24; j+=3){ if(bboxp[j] > bbox[5]) break;} if(j> 24)return 0;
 return 1;
}

canonical_original_code:
unsigned char checkBBoxPInBBox(float *bbox, float *bboxp){
 unsigned int j;
 for(j = 0; j < 24; j+=3){ if(bboxp[j] < bbox[0]) break;} if(j==24)return 0;
 for(j = 0; j < 24; j+=3){ if(bboxp[j] > bbox[1]) break;} if(j==24)return 0;
 for(j = 1; j < 24; j+=3){ if(bboxp[j] < bbox[2]) break;} if(j> 24)return 0;
 for(j = 1; j < 24; j+=3){ if(bboxp[j] > bbox[3]) break;} if(j> 24)return 0;
 for(j = 2; j < 24; j+=3){ if(bboxp[j] < bbox[4]) break;} if(j> 24)return 0;
 for(j = 2; j < 24; j+=3){ if(bboxp[j] > bbox[5]) break;} if(j> 24)return 0;
 return 1;
}

variable_types:
bbox
float *

variable_types:
bboxp
float *

variable_types:
j
unsigned int

return_type: unsigned char


checkVertsInBBox

decompiled_code:
__int64 __fastcall checkVertsInBBox(float *a1, float *a2, int a3)
{
unsigned int v3; // eax
float *v5; // rdi
float *v6; // rdx
unsigned int v7; // ecx
unsigned int v8; // er9
unsigned int i; // er10
unsigned int v10; // ecx
unsigned int j; // esi
unsigned int k; // er10
unsigned int l; // er9

v3 = 3 * a3;
v5 = a2;
if ( 3 * a3 )
{
v6 = a2;
v7 = 0;
do
{
if ( *a1 > *v6 )
goto LABEL_5;
v7 += 3;
v6 += 3;
}
while ( v3 > v7 );
if ( v3 == v7 )
return 0LL;
LABEL_5:
v8 = 0;
do
{
if ( *a2 > a1[1] )
break;
v8 += 3;
a2 += 3;
}
while ( v3 > v8 );
if ( v3 != v8 )
{
if ( v3 > 1 )
{
for ( i = 1; i < v3; i += 3 )
{
if ( a1[2] > v5[i] )
break;
}
v10 = 0;
if ( i > v3 )
return v10;
for ( j = 1; j < v3; j += 3 )
{
if ( v5[j] > a1[3] )
break;
}
v10 = 0;
if ( v3 < j )
return v10;
}
if ( v3 <= 2 )
{
v10 = 0;
l = 2;
if ( v3 != 2 )
return v10;
}
else
{
for ( k = 2; k < v3; k += 3 )
{
if ( a1[4] > v5[k] )
break;
}
v10 = 0;
if ( k > v3 )
return v10;
for ( l = 2; l < v3; l += 3 )
{
v10 = l;
if ( v5[l] > a1[5] )
break;
}
}
LOBYTE(v10) = v3 >= l;
return v10;
}
}
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func2(float *a1, float *a2, int a3)
{
unsigned int v3; // eax
float *v5; // rdi
float *v6; // rdx
unsigned int v7; // ecx
unsigned int v8; // er9
unsigned int i; // er10
unsigned int v10; // ecx
unsigned int j; // esi
unsigned int k; // er10
unsigned int l; // er9

v3 = 3 * a3;
v5 = a2;
if ( 3 * a3 )
{
v6 = a2;
v7 = 0;
do
{
if ( *a1 > *v6 )
goto LABEL_5;
v7 += 3;
v6 += 3;
}
while ( v3 > v7 );
if ( v3 == v7 )
return 0LL;
LABEL_5:
v8 = 0;
do
{
if ( *a2 > a1[1] )
break;
v8 += 3;
a2 += 3;
}
while ( v3 > v8 );
if ( v3 != v8 )
{
if ( v3 > 1 )
{
for ( i = 1; i < v3; i += 3 )
{
if ( a1[2] > v5[i] )
break;
}
v10 = 0;
if ( i > v3 )
return v10;
for ( j = 1; j < v3; j += 3 )
{
if ( v5[j] > a1[3] )
break;
}
v10 = 0;
if ( v3 < j )
return v10;
}
if ( v3 <= 2 )
{
v10 = 0;
l = 2;
if ( v3 != 2 )
return v10;
}
else
{
for ( k = 2; k < v3; k += 3 )
{
if ( a1[4] > v5[k] )
break;
}
v10 = 0;
if ( k > v3 )
return v10;
for ( l = 2; l < v3; l += 3 )
{
v10 = l;
if ( v5[l] > a1[5] )
break;
}
}
LOBYTE(v10) = v3 >= l;
return v10;
}
}
return 0LL;
}

original_code:
unsigned char checkVertsInBBox(const vec_t *bbox, const vec_t *verts, const unsigned int count){
 unsigned int j;
 unsigned int max = count*3;
 for(j = 0; j < max; j+=3){ if(verts[j] < bbox[0]) break;} if(j==max)return 0;
 for(j = 0; j < max; j+=3){ if(verts[j] > bbox[1]) break;} if(j==max)return 0;
 for(j = 1; j < max; j+=3){ if(verts[j] < bbox[2]) break;} if(j> max)return 0;
 for(j = 1; j < max; j+=3){ if(verts[j] > bbox[3]) break;} if(j> max)return 0;
 for(j = 2; j < max; j+=3){ if(verts[j] < bbox[4]) break;} if(j> max)return 0;
 for(j = 2; j < max; j+=3){ if(verts[j] > bbox[5]) break;} if(j> max)return 0;
 return 1;
}

canonical_original_code:
unsigned char checkVertsInBBox(float *bbox, float *verts, unsigned int count){
 unsigned int j;
 unsigned int max = count*3;
 for(j = 0; j < max; j+=3){ if(verts[j] < bbox[0]) break;} if(j==max)return 0;
 for(j = 0; j < max; j+=3){ if(verts[j] > bbox[1]) break;} if(j==max)return 0;
 for(j = 1; j < max; j+=3){ if(verts[j] < bbox[2]) break;} if(j> max)return 0;
 for(j = 1; j < max; j+=3){ if(verts[j] > bbox[3]) break;} if(j> max)return 0;
 for(j = 2; j < max; j+=3){ if(verts[j] < bbox[4]) break;} if(j> max)return 0;
 for(j = 2; j < max; j+=3){ if(verts[j] > bbox[5]) break;} if(j> max)return 0;
 return 1;
}

variable_types:
verts
float *

variable_types:
count
unsigned int

variable_types:
max
unsigned int


variable_types:
b
float [3]

variable_types:
c
float [3]

variable_types:
math
float [3]

return_type: float


decompiled_code:
float __fastcall vec3distfastvec(float *a1, float *a2)
{
return (float)((float)((float)(*a1 - *a2) * (float)(*a1 - *a2))
+ (float)((float)(a1[1] - a2[1]) * (float)(a1[1] - a2[1])))
+ (float)((float)(a1[2] - a2[2]) * (float)(a1[2] - a2[2]));
}


variable_types:
b
float [4]

variable_types:
c
float [4]

variable_types:
math
float [4]


checkSphereInSphere

decompiled_code:
bool __fastcall checkSphereInSphere(float *a1, float *a2, float a3, float a4)
{
vec3distvec(a1, a2);
return (float)(a4 + a3) > a3;
}

canonical_decompiled_code:
bool __fastcall func10(float *a1, float *a2, float a3, float a4)
{
func3(a1, a2);
return (float)(a4 + a3) > a3;
}

original_code:
unsigned char checkSphereInSphere(const vec3_t sphere1, const vec_t size1, const vec3_t sphere2, const vec_t size2){
 vec_t tots = size1+size2;
 return(vec3distvec(sphere1, sphere2) < tots);
}

canonical_original_code:
unsigned char checkSphereInSphere(float sphere1[3], float size1, float sphere2[3], float size2){
 float tots = size1+size2;
 return(vec3distvec(sphere1, sphere2) < tots);
}

variable_types: tots float


decompiled_code:
void *__fastcall entity_findAllByNameRINT(__int64 a1)
{
unsigned int v1; // ebp
void *v2; // r12
int v3; // eax
__int64 v4; // rdx
__int64 *v5; // rbx
void *v7; // rax

v3 = getHash();
v4 = 0LL;
v5 = &entityhashtable[3 * v3];
if ( *v5 )
{
do
{
while ( !(unsigned int)string_testEqual(*v5, a1, v4) )
{
v5 = (__int64 *)v5[2];
if ( !v5 )
return v2;
}
v7 = realloc(v2, 4LL * (v1 + 1));
v4 = *((unsigned int *)v5 + 2);
v5 = (__int64 *)v5[2];
v2 = v7;
*((_DWORD *)v7 + v1++) = v4;
}
while ( v5 );
}
return v2;
}

canonical_decompiled_code:
void *__fastcall func0(__int64 a1)
{
unsigned int v1; // ebp
void *v2; // r12
int v3; // eax
__int64 v4; // rdx
__int64 *v5; // rbx
void *v7; // rax

v3 = getHash();
v4 = 0LL;
v5 = &entityhashtable[3 * v3];
if ( *v5 )
{
do
{
while ( !(unsigned int)string_testEqual(*v5, a1, v4) )
{
v5 = (__int64 *)v5[2];
if ( !v5 )
return v2;
}
v7 = realloc(v2, 4LL * (v1 + 1));
v4 = *((unsigned int *)v5 + 2);
v5 = (__int64 *)v5[2];
v2 = v7;
*((_DWORD *)v7 + v1++) = v4;
}
while ( v5 );
}
return v2;
}

original_code:
entitylistint_t entity_findAllByNameRINT(const char * name){
 entitylistint_t ret;
 int hash = getHash(name);
 hashbucket_t * hb = &entityhashtable[hash];
 if(!hb->name) return ret;
        for(; hb; hb = hb->next){
  if(string_testEqual(hb->name, name)){
   ret.count++;
   ret.list = realloc(ret.list, ret.count * sizeof(int));
   ret.list[ret.count-1] = hb->id;
  }
        }
 return ret;
}

canonical_original_code:
struct entitylistint_s entity_findAllByNameRINT(char *name){
 struct entitylistint_s ret;
 int hash = getHash(name);
 struct hashbucket_s *hb = &entityhashtable[hash];
 if(!hb->name) return ret;
        for(; hb; hb = hb->next){
  if(string_testEqual(hb->name, name)){
   ret.count++;
   ret.list = realloc(ret.list, ret.count * sizeof(int));
   ret.list[ret.count-1] = hb->id;
  }
        }
 return ret;
}

variable_types: struct entitylistint_s { int *list; unsigned int count; }

variable_types: hash int

variable_types: struct hashbucket_s { char *name; int id; struct hashbucket_s *next; } *


decompiled_code:
__int64 __fastcall entity_findByNameRINT(__int64 a1)
{
return findByNameRINT(a1, entityhashtable);
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1)
{
return findByNameRINT(a1, entityhashtable);
}

original_code:
int entity_findByNameRINT(const char * name){
 return findByNameRINT(name, entityhashtable);
}

canonical_original_code:
int entity_findByNameRINT(char *name){
 return findByNameRINT(name, entityhashtable);
}

variable_types:
name
char *

return_type: int


decompiled_code:
__int64 __fastcall entity_delete(unsigned int a1)
{
__int64 result; // rax
char *v2; // rbx
int v3; // ecx
char v4; // bp
char *v5; // r9
int v6; // er11
int v7; // ebx

result = 0LL;
v2 = (char *)entity_list + 416 * (unsigned __int16)a1;
if ( *((_DWORD *)v2 + 2) != a1 || !*(_QWORD *)v2 )
return result;
deleteFromHashTable(*(_QWORD *)v2, a1, entityhashtable);
free(*(void **)v2);
*(_QWORD *)v2 = 0LL;
*((_QWORD *)v2 + 51) = 0LL;
memset(
(void *)((unsigned __int64)(v2 + 8) & 0xFFFFFFFFFFFFFFF8LL),
0,
8LL * (((unsigned int)v2 - (((_DWORD)v2 + 8) & 0xFFFFFFF8) + 416) >> 3));
if ( entity_arrayfirstopen > (unsigned __int16)a1 )
entity_arrayfirstopen = (unsigned __int16)a1;
v3 = entity_arraylasttaken;
if ( entity_arraylasttaken <= 0 )
return 1LL;
v4 = 0;
v5 = (char *)entity_list + 416 * entity_arraylasttaken;
v6 = entity_arraylasttaken & 7;
if ( (entity_arraylasttaken & 7) == 0 )
goto LABEL_25;
if ( v6 != 1 )
{
switch ( v6 )
{
case 2:
LABEL_21:
if ( v5[12] )
goto LABEL_36;
--v3;
v5 -= 416;
v4 = 1;
goto LABEL_23;
case 3:
LABEL_19:
if ( v5[12] )
goto LABEL_36;
--v3;
v5 -= 416;
v4 = 1;
goto LABEL_21;
case 4:
LABEL_17:
if ( v5[12] )
goto LABEL_36;
--v3;
v5 -= 416;
v4 = 1;
goto LABEL_19;
case 5:
LABEL_15:
if ( v5[12] )
goto LABEL_36;
--v3;
v5 -= 416;
v4 = 1;
goto LABEL_17;
case 6:
LABEL_13:
if ( v5[12] )
goto LABEL_36;
--v3;
v5 -= 416;
v4 = 1;
goto LABEL_15;
}
if ( !v5[12] )
{
v3 = entity_arraylasttaken - 1;
v5 -= 416;
v4 = 1;
goto LABEL_13;
}
return 1LL;
}
LABEL_23:
if ( v5[12] )
goto LABEL_36;
v5 -= 416;
v4 = 1;
if ( --v3 )
{
LABEL_25:
while ( !v5[12] )
{
v7 = v3 - 1;
v4 = 1;
--v3;
if ( *(v5 - 404) )
goto LABEL_37;
--v3;
if ( *(v5 - 820) )
goto LABEL_37;
v3 = v7 - 2;
if ( *(v5 - 1236) )
goto LABEL_37;
v3 = v7 - 3;
if ( *(v5 - 1652) )
goto LABEL_37;
v3 = v7 - 4;
if ( *(v5 - 2068) )
goto LABEL_37;
v3 = v7 - 5;
if ( *(v5 - 2484) )
goto LABEL_37;
v3 = v7 - 6;
if ( *(v5 - 2900) )
goto LABEL_37;
v5 -= 3328;
v3 = v7 - 7;
if ( v7 == 7 )
goto LABEL_34;
}
LABEL_36:
if ( v4 )
LABEL_37:
entity_arraylasttaken = v3;
return 1LL;
}
LABEL_34:
entity_arraylasttaken = 0;
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func2(unsigned int a1)
{
__int64 result; // rax
char *v2; // rbx
int v3; // ecx
char v4; // bp
char *v5; // r9
int v6; // er11
int v7; // ebx

result = 0LL;
v2 = (char *)entity_list + 416 * (unsigned __int16)a1;
if ( *((_DWORD *)v2 + 2) != a1 || !*(_QWORD *)v2 )
return result;
deleteFromHashTable(*(_QWORD *)v2, a1, entityhashtable);
free(*(void **)v2);
*(_QWORD *)v2 = 0LL;
*((_QWORD *)v2 + 51) = 0LL;
memset(
(void *)((unsigned __int64)(v2 + 8) & 0xFFFFFFFFFFFFFFF8LL),
0,
8LL * (((unsigned int)v2 - (((_DWORD)v2 + 8) & 0xFFFFFFF8) + 416) >> 3));
if ( entity_arrayfirstopen > (unsigned __int16)a1 )
entity_arrayfirstopen = (unsigned __int16)a1;
v3 = entity_arraylasttaken;
if ( entity_arraylasttaken <= 0 )
return 1LL;
v4 = 0;
v5 = (char *)entity_list + 416 * entity_arraylasttaken;
v6 = entity_arraylasttaken & 7;
if ( (entity_arraylasttaken & 7) == 0 )
goto LABEL_25;
if ( v6 != 1 )
{
switch ( v6 )
{
case 2:
LABEL_21:
if ( v5[12] )
goto LABEL_36;
--v3;
v5 -= 416;
v4 = 1;
goto LABEL_23;
case 3:
LABEL_19:
if ( v5[12] )
goto LABEL_36;
--v3;
v5 -= 416;
v4 = 1;
goto LABEL_21;
case 4:
LABEL_17:
if ( v5[12] )
goto LABEL_36;
--v3;
v5 -= 416;
v4 = 1;
goto LABEL_19;
case 5:
LABEL_15:
if ( v5[12] )
goto LABEL_36;
--v3;
v5 -= 416;
v4 = 1;
goto LABEL_17;
case 6:
LABEL_13:
if ( v5[12] )
goto LABEL_36;
--v3;
v5 -= 416;
v4 = 1;
goto LABEL_15;
}
if ( !v5[12] )
{
v3 = entity_arraylasttaken - 1;
v5 -= 416;
v4 = 1;
goto LABEL_13;
}
return 1LL;
}
LABEL_23:
if ( v5[12] )
goto LABEL_36;
v5 -= 416;
v4 = 1;
if ( --v3 )
{
LABEL_25:
while ( !v5[12] )
{
v7 = v3 - 1;
v4 = 1;
--v3;
if ( *(v5 - 404) )
goto LABEL_37;
--v3;
if ( *(v5 - 820) )
goto LABEL_37;
v3 = v7 - 2;
if ( *(v5 - 1236) )
goto LABEL_37;
v3 = v7 - 3;
if ( *(v5 - 1652) )
goto LABEL_37;
v3 = v7 - 4;
if ( *(v5 - 2068) )
goto LABEL_37;
v3 = v7 - 5;
if ( *(v5 - 2484) )
goto LABEL_37;
v3 = v7 - 6;
if ( *(v5 - 2900) )
goto LABEL_37;
v5 -= 3328;
v3 = v7 - 7;
if ( v7 == 7 )
goto LABEL_34;
}
LABEL_36:
if ( v4 )
LABEL_37:
entity_arraylasttaken = v3;
return 1LL;
}
LABEL_34:
entity_arraylasttaken = 0;
return 1LL;
}

original_code:
int entity_delete(const int id){
 int entityindex = (id & 0xFFFF);
 entity_t * ent = &entity_list[entityindex];
 if(ent->myid != id) return 0;
 if(!ent->name) return 0;
 deleteFromHashTable(ent->name, id, entityhashtable);
 free(ent->name);
 memset(ent, 0, sizeof(entity_t));
 if(entityindex < entity_arrayfirstopen) entity_arrayfirstopen = entityindex;
 for(; entity_arraylasttaken > 0 && !entity_list[entity_arraylasttaken].type; entity_arraylasttaken--);
 return 1;
}

canonical_original_code:
int entity_delete(int id){
 int entityindex = (id & 0xFFFF);
 struct entity_s *ent = &entity_list[entityindex];
 if(ent->myid != id) return 0;
 if(!ent->name) return 0;
 deleteFromHashTable(ent->name, id, entityhashtable);
 free(ent->name);
 memset(ent, 0, sizeof(entity_t));
 if(entityindex < entity_arrayfirstopen) entity_arrayfirstopen = entityindex;
 for(; entity_arraylasttaken > 0 && !entity_list[entity_arraylasttaken].type; entity_arraylasttaken--);
 return 1;
}

variable_types: id int

variable_types: entityindex int

variable_types: struct entity_s { char *name; int myid; char type; char flags; unsigned char treedepth; float pos[3]; float angle[3]; float anglevel[3]; float vel[3]; float scale; int needsmatupdate; struct matrix4x4_s { float m[4][4]; } mat; double nextthink; void (*spawn)(struct entity_s *e); void (*remove)(struct entity_s *e); void (*think)(struct entity_s *e); void (*touch)(struct entity_s *e, int touchid); int parentid; int attachmentid; int shaderid; int shaderperm; int texturegroupid; int modelid; struct phystype_s { enum { STATIC=0, FLY=1, DYNAMIC=2, ODEFLY=3, ODEDYNAMIC=4 } movetype; enum { NONE=0, AABB=1, ODESPHERE=2, ODEBOX=3, ODECYLINDER=4, ODECAPSULE=5 } collidetype; float mass; void *gid; void *bid; } phys; int needsbboxupdate; float bboxp[24]; float bbox[6]; unsigned int leafpos; void *leaf; struct leaflinkitem_s { int self; char type; float bb[2]; int unext; char unextt; int uprev; char uprevt; int dnext; char dnextt; int dprev; char dprevt; } ll; } *

user_defined_types: struct entity_s { char *name; int myid; char type; char flags; unsigned char treedepth; float pos[3]; float angle[3]; float anglevel[3]; float vel[3]; float scale; int needsmatupdate; struct matrix4x4_s mat; double nextthink; void (*spawn)(struct entity_s *e); void (*remove)(struct entity_s *e); void (*think)(struct entity_s *e); void (*touch)(struct entity_s *e, int touchid); int parentid; int attachmentid; int shaderid; int shaderperm; int texturegroupid; int modelid; struct phystype_s phys; int needsbboxupdate; float bboxp[24]; float bbox[6]; unsigned int leafpos; void *leaf; struct leaflinkitem_s ll; }


decompiled_code:
char *__fastcall entity_returnById(int a1)
{
char *result; // rax

result = (char *)entity_list + 416 * (unsigned __int16)a1;
if ( !result[12] )
return 0LL;
if ( *((_DWORD *)result + 2) != a1 )
result = 0LL;
return result;
}

canonical_decompiled_code:
char *__fastcall func3(int a1)
{
char *result; // rax

result = (char *)entity_list + 416 * (unsigned __int16)a1;
if ( !result[12] )
return 0LL;
if ( *((_DWORD *)result + 2) != a1 )
result = 0LL;
return result;
}

original_code:
entity_t * entity_returnById(const int id){
 int entityindex = (id & 0xFFFF);
 entity_t * ent = &entity_list[entityindex];
 if(!ent->type) return 0;
 if(ent->myid == id) return ent;
 return 0;
}

canonical_original_code:
struct entity_s *entity_returnById(int id){
 int entityindex = (id & 0xFFFF);
 struct entity_s *ent = &entity_list[entityindex];
 if(!ent->type) return 0;
 if(ent->myid == id) return ent;
 return 0;
}

return_type: struct entity_s { char *name; int myid; char type; char flags; unsigned char treedepth; float pos[3]; float angle[3]; float anglevel[3]; float vel[3]; float scale; int needsmatupdate; struct matrix4x4_s { float m[4][4]; } mat; double nextthink; void (*spawn)(struct entity_s *e); void (*remove)(struct entity_s *e); void (*think)(struct entity_s *e); void (*touch)(struct entity_s *e, int touchid); int parentid; int attachmentid; int shaderid; int shaderperm; int texturegroupid; int modelid; struct phystype_s { enum { STATIC=0, FLY=1, DYNAMIC=2, ODEFLY=3, ODEDYNAMIC=4 } movetype; enum { NONE=0, AABB=1, ODESPHERE=2, ODEBOX=3, ODECYLINDER=4, ODECAPSULE=5 } collidetype; float mass; void *gid; void *bid; } phys; int needsbboxupdate; float bboxp[24]; float bbox[6]; unsigned int leafpos; void *leaf; struct leaflinkitem_s { int self; char type; float bb[2]; int unext; char unextt; int uprev; char uprevt; int dnext; char dnextt; int dprev; char dprevt; } ll; } *


decompiled_code:
char *__fastcall entity_findByNameRPOINT(__int64 a1)
{
int v1; // eax

v1 = findByNameRINT(a1, entityhashtable);
return entity_returnById(v1);
}

canonical_decompiled_code:
char *__fastcall func4(__int64 a1)
{
int v1; // eax

v1 = findByNameRINT(a1, entityhashtable);
return func3(v1);
}

original_code:
entity_t * entity_findByNameRPOINT(const char * name){
 return entity_returnById(findByNameRINT(name, entityhashtable));
}

canonical_original_code:
struct entity_s *entity_findByNameRPOINT(char *name){
 return entity_returnById(findByNameRINT(name, entityhashtable));
}

user_defined_types: struct phystype_s { enum { STATIC=0, FLY=1, DYNAMIC=2, ODEFLY=3, ODEDYNAMIC=4 } movetype; enum { NONE=0, AABB=1, ODESPHERE=2, ODEBOX=3, ODECYLINDER=4, ODECAPSULE=5 } collidetype; float mass; void *gid; void *bid; }

user_defined_types: struct leaflinkitem_s { int self; char type; float bb[2]; int unext; char unextt; int uprev; char uprevt; int dnext; char dnextt; int dprev; char dprevt; }


decompiled_code:
void *__fastcall entity_findAllByNameRPOINT(__int64 a1)
{
int v1; // ebp
void *v2; // r12
int v3; // eax
__int64 v4; // rdx
__int64 *v5; // rbx
char *v7; // rax
char **v8; // rsi
char *v9; // rax

v3 = getHash();
v4 = 0LL;
v5 = &entityhashtable[3 * v3];
if ( *v5 )
{
do
{
while ( !(unsigned int)string_testEqual(*v5, a1, v4) )
{
v5 = (__int64 *)v5[2];
if ( !v5 )
return v2;
}
v7 = (char *)realloc(v2, 8LL * (unsigned int)(v1 + 1));
v8 = (char **)&v7[8 * v1];
v2 = v7;
++v1;
v9 = entity_returnById(*((_DWORD *)v5 + 2));
v5 = (__int64 *)v5[2];
*v8 = v9;
}
while ( v5 );
}
return v2;
}

canonical_decompiled_code:
void *__fastcall func5(__int64 a1)
{
int v1; // ebp
void *v2; // r12
int v3; // eax
__int64 v4; // rdx
__int64 *v5; // rbx
char *v7; // rax
char **v8; // rsi
char *v9; // rax

v3 = getHash();
v4 = 0LL;
v5 = &entityhashtable[3 * v3];
if ( *v5 )
{
do
{
while ( !(unsigned int)string_testEqual(*v5, a1, v4) )
{
v5 = (__int64 *)v5[2];
if ( !v5 )
return v2;
}
v7 = (char *)realloc(v2, 8LL * (unsigned int)(v1 + 1));
v8 = (char **)&v7[8 * v1];
v2 = v7;
++v1;
v9 = func3(*((_DWORD *)v5 + 2));
v5 = (__int64 *)v5[2];
*v8 = v9;
}
while ( v5 );
}
return v2;
}

original_code:
entitylistpoint_t entity_findAllByNameRPOINT(const char * name){
 entitylistpoint_t ret;
 int hash = getHash(name);
 hashbucket_t * hb = &entityhashtable[hash];
 if(!hb->name) return ret;
        for(; hb; hb = hb->next){
  if(string_testEqual(hb->name, name)){
   ret.count++;
   ret.list = realloc(ret.list, ret.count * sizeof(entity_t *));
   ret.list[ret.count-1] = entity_returnById(hb->id);
  }
        }
 return ret;
}

canonical_original_code:
struct entitylistpoint_s entity_findAllByNameRPOINT(char *name){
 struct entitylistpoint_s ret;
 int hash = getHash(name);
 struct hashbucket_s *hb = &entityhashtable[hash];
 if(!hb->name) return ret;
        for(; hb; hb = hb->next){
  if(string_testEqual(hb->name, name)){
   ret.count++;
   ret.list = realloc(ret.list, ret.count * sizeof(struct entity_s *));
   ret.list[ret.count-1] = entity_returnById(hb->id);
  }
        }
 return ret;
}

variable_types: struct entitylistpoint_s { struct entity_s { char *name; int myid; char type; char flags; unsigned char treedepth; float pos[3]; float angle[3]; float anglevel[3]; float vel[3]; float scale; int needsmatupdate; struct matrix4x4_s { float m[4][4]; } mat; double nextthink; void (*spawn)(struct entity_s *e); void (*remove)(struct entity_s *e); void (*think)(struct entity_s *e); void (*touch)(struct entity_s *e, int touchid); int parentid; int attachmentid; int shaderid; int shaderperm; int texturegroupid; int modelid; struct phystype_s { enum { STATIC=0, FLY=1, DYNAMIC=2, ODEFLY=3, ODEDYNAMIC=4 } movetype; enum { NONE=0, AABB=1, ODESPHERE=2, ODEBOX=3, ODECYLINDER=4, ODECAPSULE=5 } collidetype; float mass; void *gid; void *bid; } phys; int needsbboxupdate; float bboxp[24]; float bbox[6]; unsigned int leafpos; void *leaf; struct leaflinkitem_s { int self; char type; float bb[2]; int unext; char unextt; int uprev; char uprevt; int dnext; char dnextt; int dprev; char dprevt; } ll; } **list; unsigned int count; }

user_defined_types: struct entitylistpoint_s { struct entity_s **list; unsigned int count; }

user_defined_types: struct hashbucket_s { char *name; int id; struct hashbucket_s *next; }


decompiled_code:
__int64 __fastcall entity_addRINT(const char *a1)
{
int v2; // eax
int v3; // ecx
char v4; // di
char *v5; // rbp
_BYTE *v6; // rbx
int v7; // er9
_BYTE *v8; // r11
int v9; // er10
bool v10; // zf
unsigned int v11; // er12
char *v12; // rbx
int v13; // edx
char *v15; // r8
__int64 v16[57]; // [rsp+0h] [rbp-1C8h] BYREF

v2 = entity_arrayfirstopen;
v3 = entity_arraysize;
++entity_count;
if ( entity_arrayfirstopen >= entity_arraysize )
{
if ( entity_arrayfirstopen != entity_arraysize )
{
v5 = (char *)entity_list + 416 * entity_arrayfirstopen;
goto LABEL_32;
}
goto LABEL_31;
}
v4 = 0;
v5 = (char *)entity_list + 416 * entity_arrayfirstopen;
v6 = v5;
v7 = ((_BYTE)entity_arraysize - (_BYTE)entity_arrayfirstopen) & 7;
if ( (((_BYTE)entity_arraysize - (_BYTE)entity_arrayfirstopen) & 7) == 0 )
goto LABEL_21;
switch ( v7 )
{
case 1:
LABEL_19:
if ( !v6[12] )
goto LABEL_35;
++v2;
v6 += 416;
v4 = 1;
if ( v2 != entity_arraysize )
{
LABEL_21:
while ( v6[12] )
{
v8 = v6 + 416;
v9 = v2 + 1;
v10 = v6[428] == 0;
v4 = 1;
++v2;
v6 += 416;
if ( v10 )
goto LABEL_36;
v6 += 416;
++v2;
if ( !v6[12] )
goto LABEL_36;
v2 = v9 + 2;
v6 = v8 + 832;
if ( !v8[844] )
goto LABEL_36;
v2 = v9 + 3;
v6 = v8 + 1248;
if ( !v8[1260] )
goto LABEL_36;
v2 = v9 + 4;
v6 = v8 + 1664;
if ( !v8[1676] )
goto LABEL_36;
v2 = v9 + 5;
v6 = v8 + 2080;
if ( !v8[2092] )
goto LABEL_36;
v2 = v9 + 6;
v6 = v8 + 2496;
if ( !v8[2508] )
goto LABEL_36;
v2 = v9 + 7;
v6 = v8 + 2912;
if ( v9 + 7 == entity_arraysize )
goto LABEL_30;
}
goto LABEL_35;
}
LABEL_30:
entity_arrayfirstopen = entity_arraysize;
LABEL_31:
++entity_arraysize;
entity_list = realloc(entity_list, 416LL * (v3 + 1));
v5 = (char *)entity_list + 416 * entity_arrayfirstopen;
goto LABEL_32;
case 2:
LABEL_17:
if ( !v6[12] )
goto LABEL_35;
++v2;
v6 += 416;
v4 = 1;
goto LABEL_19;
case 3:
LABEL_15:
if ( !v6[12] )
goto LABEL_35;
++v2;
v6 += 416;
v4 = 1;
goto LABEL_17;
case 4:
LABEL_13:
if ( !v6[12] )
goto LABEL_35;
++v2;
v6 += 416;
v4 = 1;
goto LABEL_15;
case 5:
LABEL_11:
if ( !v6[12] )
goto LABEL_35;
++v2;
v6 += 416;
v4 = 1;
goto LABEL_13;
}
if ( v7 != 6 )
{
v2 = entity_arrayfirstopen + 1;
v6 = v5 + 416;
v4 = 1;
if ( !v5[12] )
{
LABEL_32:
createEntity(v16, a1);
qmemcpy(v5, v16, 0x1A0uLL);
v11 = entity_arrayfirstopen | (entity_count << 16);
v12 = (char *)entity_list + 416 * entity_arrayfirstopen;
*((_DWORD *)v12 + 2) = v11;
addToHashTable(*(_QWORD *)v12, v11, entityhashtable);
v13 = entity_arrayfirstopen;
if ( entity_arraylasttaken < entity_arrayfirstopen )
goto LABEL_33;
LABEL_37:
if ( v11 )
return v11;
LABEL_38:
v11 = 0;
puts("yes, i can");
return v11;
}
}
if ( v6[12] )
{
++v2;
v6 += 416;
v4 = 1;
goto LABEL_11;
}
LABEL_35:
if ( !v4 )
goto LABEL_32;
LABEL_36:
entity_arrayfirstopen = v2;
createEntity(v16, a1);
qmemcpy(v6, v16, 0x1A0uLL);
v11 = entity_arrayfirstopen | (entity_count << 16);
v15 = (char *)entity_list + 416 * entity_arrayfirstopen;
*((_DWORD *)v15 + 2) = v11;
addToHashTable(*(_QWORD *)v15, v11, entityhashtable);
v13 = entity_arrayfirstopen;
if ( entity_arrayfirstopen <= entity_arraylasttaken )
goto LABEL_37;
LABEL_33:
entity_arraylasttaken = v13;
if ( !v11 )
goto LABEL_38;
return v11;
}

canonical_decompiled_code:
__int64 __fastcall func6(const char *a1)
{
int v2; // eax
int v3; // ecx
char v4; // di
char *v5; // rbp
_BYTE *v6; // rbx
int v7; // er9
_BYTE *v8; // r11
int v9; // er10
bool v10; // zf
unsigned int v11; // er12
char *v12; // rbx
int v13; // edx
char *v15; // r8
__int64 v16[57]; // [rsp+0h] [rbp-1C8h] BYREF

v2 = entity_arrayfirstopen;
v3 = entity_arraysize;
++entity_count;
if ( entity_arrayfirstopen >= entity_arraysize )
{
if ( entity_arrayfirstopen != entity_arraysize )
{
v5 = (char *)entity_list + 416 * entity_arrayfirstopen;
goto LABEL_32;
}
goto LABEL_31;
}
v4 = 0;
v5 = (char *)entity_list + 416 * entity_arrayfirstopen;
v6 = v5;
v7 = ((_BYTE)entity_arraysize - (_BYTE)entity_arrayfirstopen) & 7;
if ( (((_BYTE)entity_arraysize - (_BYTE)entity_arrayfirstopen) & 7) == 0 )
goto LABEL_21;
switch ( v7 )
{
case 1:
LABEL_19:
if ( !v6[12] )
goto LABEL_35;
++v2;
v6 += 416;
v4 = 1;
if ( v2 != entity_arraysize )
{
LABEL_21:
while ( v6[12] )
{
v8 = v6 + 416;
v9 = v2 + 1;
v10 = v6[428] == 0;
v4 = 1;
++v2;
v6 += 416;
if ( v10 )
goto LABEL_36;
v6 += 416;
++v2;
if ( !v6[12] )
goto LABEL_36;
v2 = v9 + 2;
v6 = v8 + 832;
if ( !v8[844] )
goto LABEL_36;
v2 = v9 + 3;
v6 = v8 + 1248;
if ( !v8[1260] )
goto LABEL_36;
v2 = v9 + 4;
v6 = v8 + 1664;
if ( !v8[1676] )
goto LABEL_36;
v2 = v9 + 5;
v6 = v8 + 2080;
if ( !v8[2092] )
goto LABEL_36;
v2 = v9 + 6;
v6 = v8 + 2496;
if ( !v8[2508] )
goto LABEL_36;
v2 = v9 + 7;
v6 = v8 + 2912;
if ( v9 + 7 == entity_arraysize )
goto LABEL_30;
}
goto LABEL_35;
}
LABEL_30:
entity_arrayfirstopen = entity_arraysize;
LABEL_31:
++entity_arraysize;
entity_list = realloc(entity_list, 416LL * (v3 + 1));
v5 = (char *)entity_list + 416 * entity_arrayfirstopen;
goto LABEL_32;
case 2:
LABEL_17:
if ( !v6[12] )
goto LABEL_35;
++v2;
v6 += 416;
v4 = 1;
goto LABEL_19;
case 3:
LABEL_15:
if ( !v6[12] )
goto LABEL_35;
++v2;
v6 += 416;
v4 = 1;
goto LABEL_17;
case 4:
LABEL_13:
if ( !v6[12] )
goto LABEL_35;
++v2;
v6 += 416;
v4 = 1;
goto LABEL_15;
case 5:
LABEL_11:
if ( !v6[12] )
goto LABEL_35;
++v2;
v6 += 416;
v4 = 1;
goto LABEL_13;
}
if ( v7 != 6 )
{
v2 = entity_arrayfirstopen + 1;
v6 = v5 + 416;
v4 = 1;
if ( !v5[12] )
{
LABEL_32:
createEntity(v16, a1);
qmemcpy(v5, v16, 0x1A0uLL);
v11 = entity_arrayfirstopen | (entity_count << 16);
v12 = (char *)entity_list + 416 * entity_arrayfirstopen;
*((_DWORD *)v12 + 2) = v11;
addToHashTable(*(_QWORD *)v12, v11, entityhashtable);
v13 = entity_arrayfirstopen;
if ( entity_arraylasttaken < entity_arrayfirstopen )
goto LABEL_33;
LABEL_37:
if ( v11 )
return v11;
LABEL_38:
v11 = 0;
puts("yes, i can");
return v11;
}
}
if ( v6[12] )
{
++v2;
v6 += 416;
v4 = 1;
goto LABEL_11;
}
LABEL_35:
if ( !v4 )
goto LABEL_32;
LABEL_36:
entity_arrayfirstopen = v2;
createEntity(v16, a1);
qmemcpy(v6, v16, 0x1A0uLL);
v11 = entity_arrayfirstopen | (entity_count << 16);
v15 = (char *)entity_list + 416 * entity_arrayfirstopen;
*((_DWORD *)v15 + 2) = v11;
addToHashTable(*(_QWORD *)v15, v11, entityhashtable);
v13 = entity_arrayfirstopen;
if ( entity_arrayfirstopen <= entity_arraylasttaken )
goto LABEL_37;
LABEL_33:
entity_arraylasttaken = v13;
if ( !v11 )
goto LABEL_38;
return v11;
}

original_code:
int entity_addRINT(const char * name){
 entity_count++;
 for(; entity_arrayfirstopen < entity_arraysize && entity_list[entity_arrayfirstopen].type; entity_arrayfirstopen++);
 if(entity_arrayfirstopen == entity_arraysize){
  entity_arraysize++;
  entity_list = realloc(entity_list, entity_arraysize * sizeof(entity_t));
 }
 entity_list[entity_arrayfirstopen] = createEntity(name);
 int returnid = (entity_count << 16) | entity_arrayfirstopen;
 entity_list[entity_arrayfirstopen].myid = returnid;
 addToHashTable(entity_list[entity_arrayfirstopen].name, returnid, entityhashtable);
 if(entity_arraylasttaken < entity_arrayfirstopen) entity_arraylasttaken = entity_arrayfirstopen;
 if(returnid == 0) printf("yes, i can\n");
 return returnid;
}

canonical_original_code:
int entity_addRINT(char *name){
 entity_count++;
 for(; entity_arrayfirstopen < entity_arraysize && entity_list[entity_arrayfirstopen].type; entity_arrayfirstopen++);
 if(entity_arrayfirstopen == entity_arraysize){
  entity_arraysize++;
  entity_list = realloc(entity_list, entity_arraysize * sizeof(entity_t));
 }
 entity_list[entity_arrayfirstopen] = createEntity(name);
 int returnid = (entity_count << 16) | entity_arrayfirstopen;
 entity_list[entity_arrayfirstopen].myid = returnid;
 addToHashTable(entity_list[entity_arrayfirstopen].name, returnid, entityhashtable);
 if(entity_arraylasttaken < entity_arrayfirstopen) entity_arraylasttaken = entity_arrayfirstopen;
 if(returnid == 0) printf("yes, i can\n");
 return returnid;
}

variable_types: returnid int


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

memset(entityhashtable, 0, sizeof(entityhashtable));
if ( entity_list )
{
free(entity_list);
entity_list = 0LL;
}
entity_addRINT("default");
result = 1LL;
entity_ok = 1;
return result;
}

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

memset(entityhashtable, 0, sizeof(entityhashtable));
if ( entity_list )
{
free(entity_list);
entity_list = 0LL;
}
func6("default");
result = 1LL;
entity_ok = 1;
return result;
}

original_code:
int entity_init(void){
 memset(entityhashtable, 0, 128 * sizeof(hashbucket_t));
 if(entity_list) free(entity_list);
 entity_list = 0;
 entity_addRINT("default");
 entity_ok = 1;
 return 1;
}

canonical_original_code:
int entity_init(){
 memset(entityhashtable, 0, 128 * sizeof(hashbucket_t));
 if(entity_list) free(entity_list);
 entity_list = 0;
 entity_addRINT("default");
 entity_ok = 1;
 return 1;
}


decompiled_code:
char *__fastcall entity_addRPOINT(const char *a1)
{
int v2; // eax
int v3; // ecx
char v4; // di
char *v5; // rbp
char *v6; // r13
int v7; // er9
char *v8; // r11
int v9; // er10
bool v10; // zf
char *v11; // rdi
__int64 v12; // rsi
char *v13; // r10
char *result; // rax
__int64 v15[57]; // [rsp+0h] [rbp-1C8h] BYREF

v2 = entity_arrayfirstopen;
v3 = entity_arraysize;
++entity_count;
if ( entity_arrayfirstopen >= entity_arraysize )
{
if ( entity_arrayfirstopen != entity_arraysize )
{
v5 = (char *)entity_list + 416 * entity_arrayfirstopen;
goto LABEL_32;
}
goto LABEL_31;
}
v4 = 0;
v5 = (char *)entity_list + 416 * entity_arrayfirstopen;
v6 = v5;
v7 = ((_BYTE)entity_arraysize - (_BYTE)entity_arrayfirstopen) & 7;
if ( (((_BYTE)entity_arraysize - (_BYTE)entity_arrayfirstopen) & 7) == 0 )
goto LABEL_21;
switch ( v7 )
{
case 1:
LABEL_19:
if ( !v6[12] )
goto LABEL_37;
++v2;
v6 += 416;
v4 = 1;
if ( v2 != entity_arraysize )
{
LABEL_21:
while ( v6[12] )
{
v8 = v6 + 416;
v9 = v2 + 1;
v10 = v6[428] == 0;
v4 = 1;
++v2;
v6 += 416;
if ( v10 )
goto LABEL_38;
v6 += 416;
++v2;
if ( !v6[12] )
goto LABEL_38;
v2 = v9 + 2;
v6 = v8 + 832;
if ( !v8[844] )
goto LABEL_38;
v2 = v9 + 3;
v6 = v8 + 1248;
if ( !v8[1260] )
goto LABEL_38;
v2 = v9 + 4;
v6 = v8 + 1664;
if ( !v8[1676] )
goto LABEL_38;
v2 = v9 + 5;
v6 = v8 + 2080;
if ( !v8[2092] )
goto LABEL_38;
v2 = v9 + 6;
v6 = v8 + 2496;
if ( !v8[2508] )
goto LABEL_38;
v2 = v9 + 7;
v6 = v8 + 2912;
if ( v9 + 7 == entity_arraysize )
goto LABEL_30;
}
goto LABEL_37;
}
LABEL_30:
entity_arrayfirstopen = entity_arraysize;
LABEL_31:
++entity_arraysize;
entity_list = realloc(entity_list, 416LL * (v3 + 1));
v5 = (char *)entity_list + 416 * entity_arrayfirstopen;
LABEL_32:
createEntity(v15, a1);
v11 = v5;
goto LABEL_33;
case 2:
LABEL_17:
if ( !v6[12] )
goto LABEL_37;
++v2;
v6 += 416;
v4 = 1;
goto LABEL_19;
case 3:
LABEL_15:
if ( !v6[12] )
goto LABEL_37;
++v2;
v6 += 416;
v4 = 1;
goto LABEL_17;
case 4:
LABEL_13:
if ( !v6[12] )
goto LABEL_37;
++v2;
v6 += 416;
v4 = 1;
goto LABEL_15;
case 5:
LABEL_11:
if ( !v6[12] )
goto LABEL_37;
++v2;
v6 += 416;
v4 = 1;
goto LABEL_13;
}
if ( v7 != 6 )
{
v2 = entity_arrayfirstopen + 1;
v6 = v5 + 416;
v4 = 1;
if ( !v5[12] )
goto LABEL_32;
}
if ( v6[12] )
{
++v2;
v6 += 416;
v4 = 1;
goto LABEL_11;
}
LABEL_37:
if ( !v4 )
goto LABEL_32;
LABEL_38:
entity_arrayfirstopen = v2;
createEntity(v15, a1);
v11 = v6;
LABEL_33:
qmemcpy(v11, v15, 0x1A0uLL);
v12 = entity_arrayfirstopen | (unsigned int)(entity_count << 16);
v13 = (char *)entity_list + 416 * entity_arrayfirstopen;
*((_DWORD *)v13 + 2) = v12;
addToHashTable(*(_QWORD *)v13, v12, entityhashtable);
if ( entity_arraylasttaken < entity_arrayfirstopen )
entity_arraylasttaken = entity_arrayfirstopen;
result = (char *)entity_list + 416 * entity_arrayfirstopen;
if ( !*((_DWORD *)result + 2) )
{
puts("yes, i can");
result = (char *)entity_list + 416 * entity_arrayfirstopen;
}
return result;
}

canonical_decompiled_code:
char *__fastcall func8(const char *a1)
{
int v2; // eax
int v3; // ecx
char v4; // di
char *v5; // rbp
char *v6; // r13
int v7; // er9
char *v8; // r11
int v9; // er10
bool v10; // zf
char *v11; // rdi
__int64 v12; // rsi
char *v13; // r10
char *result; // rax
__int64 v15[57]; // [rsp+0h] [rbp-1C8h] BYREF

v2 = entity_arrayfirstopen;
v3 = entity_arraysize;
++entity_count;
if ( entity_arrayfirstopen >= entity_arraysize )
{
if ( entity_arrayfirstopen != entity_arraysize )
{
v5 = (char *)entity_list + 416 * entity_arrayfirstopen;
goto LABEL_32;
}
goto LABEL_31;
}
v4 = 0;
v5 = (char *)entity_list + 416 * entity_arrayfirstopen;
v6 = v5;
v7 = ((_BYTE)entity_arraysize - (_BYTE)entity_arrayfirstopen) & 7;
if ( (((_BYTE)entity_arraysize - (_BYTE)entity_arrayfirstopen) & 7) == 0 )
goto LABEL_21;
switch ( v7 )
{
case 1:
LABEL_19:
if ( !v6[12] )
goto LABEL_37;
++v2;
v6 += 416;
v4 = 1;
if ( v2 != entity_arraysize )
{
LABEL_21:
while ( v6[12] )
{
v8 = v6 + 416;
v9 = v2 + 1;
v10 = v6[428] == 0;
v4 = 1;
++v2;
v6 += 416;
if ( v10 )
goto LABEL_38;
v6 += 416;
++v2;
if ( !v6[12] )
goto LABEL_38;
v2 = v9 + 2;
v6 = v8 + 832;
if ( !v8[844] )
goto LABEL_38;
v2 = v9 + 3;
v6 = v8 + 1248;
if ( !v8[1260] )
goto LABEL_38;
v2 = v9 + 4;
v6 = v8 + 1664;
if ( !v8[1676] )
goto LABEL_38;
v2 = v9 + 5;
v6 = v8 + 2080;
if ( !v8[2092] )
goto LABEL_38;
v2 = v9 + 6;
v6 = v8 + 2496;
if ( !v8[2508] )
goto LABEL_38;
v2 = v9 + 7;
v6 = v8 + 2912;
if ( v9 + 7 == entity_arraysize )
goto LABEL_30;
}
goto LABEL_37;
}
LABEL_30:
entity_arrayfirstopen = entity_arraysize;
LABEL_31:
++entity_arraysize;
entity_list = realloc(entity_list, 416LL * (v3 + 1));
v5 = (char *)entity_list + 416 * entity_arrayfirstopen;
LABEL_32:
createEntity(v15, a1);
v11 = v5;
goto LABEL_33;
case 2:
LABEL_17:
if ( !v6[12] )
goto LABEL_37;
++v2;
v6 += 416;
v4 = 1;
goto LABEL_19;
case 3:
LABEL_15:
if ( !v6[12] )
goto LABEL_37;
++v2;
v6 += 416;
v4 = 1;
goto LABEL_17;
case 4:
LABEL_13:
if ( !v6[12] )
goto LABEL_37;
++v2;
v6 += 416;
v4 = 1;
goto LABEL_15;
case 5:
LABEL_11:
if ( !v6[12] )
goto LABEL_37;
++v2;
v6 += 416;
v4 = 1;
goto LABEL_13;
}
if ( v7 != 6 )
{
v2 = entity_arrayfirstopen + 1;
v6 = v5 + 416;
v4 = 1;
if ( !v5[12] )
goto LABEL_32;
}
if ( v6[12] )
{
++v2;
v6 += 416;
v4 = 1;
goto LABEL_11;
}
LABEL_37:
if ( !v4 )
goto LABEL_32;
LABEL_38:
entity_arrayfirstopen = v2;
createEntity(v15, a1);
v11 = v6;
LABEL_33:
qmemcpy(v11, v15, 0x1A0uLL);
v12 = entity_arrayfirstopen | (unsigned int)(entity_count << 16);
v13 = (char *)entity_list + 416 * entity_arrayfirstopen;
*((_DWORD *)v13 + 2) = v12;
addToHashTable(*(_QWORD *)v13, v12, entityhashtable);
if ( entity_arraylasttaken < entity_arrayfirstopen )
entity_arraylasttaken = entity_arrayfirstopen;
result = (char *)entity_list + 416 * entity_arrayfirstopen;
if ( !*((_DWORD *)result + 2) )
{
puts("yes, i can");
result = (char *)entity_list + 416 * entity_arrayfirstopen;
}
return result;
}

original_code:
entity_t * entity_addRPOINT(const char * name){
 entity_count++;
 for(; entity_arrayfirstopen < entity_arraysize && entity_list[entity_arrayfirstopen].type; entity_arrayfirstopen++);
 if(entity_arrayfirstopen == entity_arraysize){
  entity_arraysize++;
  entity_list = realloc(entity_list, entity_arraysize * sizeof(entity_t));
 }
 entity_list[entity_arrayfirstopen] = createEntity(name);
 int returnid = (entity_count << 16) | entity_arrayfirstopen;
 entity_list[entity_arrayfirstopen].myid = returnid;
 addToHashTable(entity_list[entity_arrayfirstopen].name, returnid, entityhashtable);
 if(entity_arraylasttaken < entity_arrayfirstopen) entity_arraylasttaken = entity_arrayfirstopen;
 if(entity_list[entity_arrayfirstopen].myid == 0) printf("yes, i can\n");
 return &entity_list[entity_arrayfirstopen];
}

canonical_original_code:
struct entity_s *entity_addRPOINT(char *name){
 entity_count++;
 for(; entity_arrayfirstopen < entity_arraysize && entity_list[entity_arrayfirstopen].type; entity_arrayfirstopen++);
 if(entity_arrayfirstopen == entity_arraysize){
  entity_arraysize++;
  entity_list = realloc(entity_list, entity_arraysize * sizeof(entity_t));
 }
 entity_list[entity_arrayfirstopen] = createEntity(name);
 int returnid = (entity_count << 16) | entity_arrayfirstopen;
 entity_list[entity_arrayfirstopen].myid = returnid;
 addToHashTable(entity_list[entity_arrayfirstopen].name, returnid, entityhashtable);
 if(entity_arraylasttaken < entity_arrayfirstopen) entity_arraylasttaken = entity_arrayfirstopen;
 if(entity_list[entity_arrayfirstopen].myid == 0) printf("yes, i can\n");
 return &entity_list[entity_arrayfirstopen];
}


decompiled_code:
unsigned __int64 entity_pruneList()
{
unsigned __int64 result; // rax

result = (unsigned int)(entity_arraylasttaken + 1);
if ( (_DWORD)result != entity_arraysize )
{
entity_arraysize = entity_arraylasttaken + 1;
result = (unsigned __int64)realloc(entity_list, 416LL * (int)result);
entity_list = (void *)result;
}
return result;
}

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

result = (unsigned int)(entity_arraylasttaken + 1);
if ( (_DWORD)result != entity_arraysize )
{
entity_arraysize = entity_arraylasttaken + 1;
result = (unsigned __int64)realloc(entity_list, 416LL * (int)result);
entity_list = (void *)result;
}
return result;
}

original_code:
void entity_pruneList(void){
 if(entity_arraysize == entity_arraylasttaken+1) return;
 entity_arraysize = entity_arraylasttaken+1;
 entity_list = realloc(entity_list, entity_arraysize * sizeof(entity_t));
}

canonical_original_code:
void entity_pruneList(){
 if(entity_arraysize == entity_arraylasttaken+1) return;
 entity_arraysize = entity_arraylasttaken+1;
 entity_list = realloc(entity_list, entity_arraysize * sizeof(entity_t));
}


decompiled_code:
_BOOL8 __fastcall string_testEqual(__int64 a1, __int64 a2)
{
__int64 i; // rax
char v3; // dl
char v4; // cl

if ( !a1 || !a2 )
return 0LL;
for ( i = 0LL; ; ++i )
{
v3 = *(_BYTE *)(a1 + i);
v4 = *(_BYTE *)(a2 + i);
if ( !v3 )
break;
if ( v3 != v4 )
return 0LL;
}
return v4 == 0;
}

canonical_decompiled_code:
_BOOL8 __fastcall func0(__int64 a1, __int64 a2)
{
__int64 i; // rax
char v3; // dl
char v4; // cl

if ( !a1 || !a2 )
return 0LL;
for ( i = 0LL; ; ++i )
{
v3 = *(_BYTE *)(a1 + i);
v4 = *(_BYTE *)(a2 + i);
if ( !v3 )
break;
if ( v3 != v4 )
return 0LL;
}
return v4 == 0;
}

original_code:
int string_testEqual(const char * one, const char * two){
 if(!one || !two) return 0;
 char * m1 = (char *)one;
 char * m2 = (char *)two;
 while(*m1) if(*m1++ != *m2++) return 0;
 if(*m2) return 0;
 return 1;
}

canonical_original_code:
int string_testEqual(char *one, char *two){
 if(!one || !two) return 0;
 char *m1 = (char *)one;
 char *m2 = (char *)two;
 while(*m1) if(*m1++ != *m2++) return 0;
 if(*m2) return 0;
 return 1;
}

variable_types:
one
char *

variable_types:
two
char *


decompiled_code:
_BOOL8 __fastcall string_testEqualCI(_BYTE *a1, _BYTE *a2)
{
int v2; // er8
int v3; // eax

if ( !a1 || !a2 )
return 0LL;
while ( 1 )
{
v3 = (char)*a1;
if ( !*a1 )
return *a2 == 0;
if ( (unsigned __int8)(v3 - 65) <= 0x19u )
{
v2 = (char)*a2;
v3 = (char)(v3 + 32);
if ( (unsigned __int8)(*a2 - 65) <= 0x19u )
goto LABEL_5;
}
else
{
v2 = (char)*a2;
if ( (unsigned __int8)(*a2 - 65) <= 0x19u )
{
LABEL_5:
if ( (char)(v2 + 32) != v3 )
return 0LL;
goto LABEL_6;
}
}
if ( v2 != v3 )
return 0LL;
LABEL_6:
++a1;
++a2;
}
}

canonical_decompiled_code:
_BOOL8 __fastcall func1(_BYTE *a1, _BYTE *a2)
{
int v2; // er8
int v3; // eax

if ( !a1 || !a2 )
return 0LL;
while ( 1 )
{
v3 = (char)*a1;
if ( !*a1 )
return *a2 == 0;
if ( (unsigned __int8)(v3 - 65) <= 0x19u )
{
v2 = (char)*a2;
v3 = (char)(v3 + 32);
if ( (unsigned __int8)(*a2 - 65) <= 0x19u )
goto LABEL_5;
}
else
{
v2 = (char)*a2;
if ( (unsigned __int8)(*a2 - 65) <= 0x19u )
{
LABEL_5:
if ( (char)(v2 + 32) != v3 )
return 0LL;
goto LABEL_6;
}
}
if ( v2 != v3 )
return 0LL;
LABEL_6:
++a1;
++a2;
}
}


original_code:
int string_testEqualN(const char * one, const char * two, const unsigned int n){
 if(!one || !two) return 0;
 char * m1 = (char *)one;
 char * m2 = (char *)two;
 unsigned int i;
 for(i = 0; i < n && *m1; i++) if(*m1++ != *m2++) return 0;
 return 1;
}

canonical_original_code:
int string_testEqualN(char *one, char *two, unsigned int n){
 if(!one || !two) return 0;
 char *m1 = (char *)one;
 char *m2 = (char *)two;
 unsigned int i;
 for(i = 0; i < n && *m1; i++) if(*m1++ != *m2++) return 0;
 return 1;
}

variable_types:
n
unsigned int

variable_types:
i
unsigned int


decompiled_code:
__int64 __fastcall string_testEqualNCI(__int64 a1, __int64 a2, int a3)
{
__int64 i; // rcx
int v4; // er10
int v5; // eax

if ( !a1 || !a2 )
return 0LL;
if ( a3 )
{
for ( i = 0LL; a3 != i; ++i )
{
v5 = *(char *)(a1 + i);
if ( !*(_BYTE *)(a1 + i) )
return 1LL;
if ( (unsigned __int8)(v5 - 65) <= 0x19u )
{
v4 = *(char *)(a2 + i);
v5 = (char)(v5 + 32);
if ( (unsigned __int8)(*(_BYTE *)(a2 + i) - 65) <= 0x19u )
goto LABEL_6;
}
else
{
v4 = *(char *)(a2 + i);
if ( (unsigned __int8)(*(_BYTE *)(a2 + i) - 65) <= 0x19u )
{
LABEL_6:
if ( (char)(v4 + 32) != v5 )
return 0LL;
continue;
}
}
if ( v4 != v5 )
return 0LL;
}
}
return 1LL;
}

original_code:
int string_testEqualNCI(const char * one, const char * two, const unsigned int n){
 if(!one || !two) return 0;
 char * m1 = (char *)one;
 char * m2 = (char *)two;
 unsigned int i;
 for(i = 0; i < n && *m1; i++, m1++, m2++)if(( ( (((*m1)) >= 'A' && ((*m1)) <= 'Z') ) ? (*m1) + 32 : (*m1) ) != ( ( (((*m2)) >= 'A' && ((*m2)) <= 'Z') ) ? (*m2) + 32 : (*m2) )) return 0;
 return 1;
}


decompiled_code:
__int64 __fastcall string_toVec(char *nptr, float *a2, unsigned int a3)
{
unsigned int v3; // er12
float *v5; // r13
__int64 v6; // r14
__int64 v7; // rbp
__int64 v8; // r15
unsigned __int64 v9; // rax
float v10; // xmm0_4
unsigned __int64 v11; // rdx

v3 = a3;
if ( a3 )
{
v5 = a2;
v6 = 0LL;
v7 = 0x100002600LL;
v8 = 0x100002601LL;
while ( 1 )
{
v9 = (unsigned __int8)*nptr;
if ( !(_BYTE)v9 )
goto LABEL_12;
while ( (unsigned __int8)v9 <= 0x20u && _bittest64(&v7, v9) )
{
v9 = (unsigned __int8)*++nptr;
if ( !(_BYTE)v9 )
{
LABEL_12:
if ( v3 <= (unsigned int)v6 )
return (unsigned int)v6;
memset(&a2[v6], 0, 4LL * (v3 - 1 - (unsigned int)v6) + 4);
return v3;
}
}
v10 = atof(nptr);
*v5 = v10;
v11 = (unsigned __int8)*nptr;
if ( (unsigned __int8)v11 > 0x20u )
break;
LABEL_7:
if ( !_bittest64(&v8, v11) )
goto LABEL_6;
v6 = (unsigned int)(v6 + 1);
++v5;
if ( v3 == (_DWORD)v6 )
return v3;
}
do
LABEL_6:
v11 = (unsigned __int8)*++nptr;
while ( (unsigned __int8)v11 > 0x20u );
goto LABEL_7;
}
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func4(char *nptr, float *a2, unsigned int a3)
{
unsigned int v3; // er12
float *v5; // r13
__int64 v6; // r14
__int64 v7; // rbp
__int64 v8; // r15
unsigned __int64 v9; // rax
float v10; // xmm0_4
unsigned __int64 v11; // rdx

v3 = a3;
if ( a3 )
{
v5 = a2;
v6 = 0LL;
v7 = 0x100002600LL;
v8 = 0x100002601LL;
while ( 1 )
{
v9 = (unsigned __int8)*nptr;
if ( !(_BYTE)v9 )
goto LABEL_12;
while ( (unsigned __int8)v9 <= 0x20u && _bittest64(&v7, v9) )
{
v9 = (unsigned __int8)*++nptr;
if ( !(_BYTE)v9 )
{
LABEL_12:
if ( v3 <= (unsigned int)v6 )
return (unsigned int)v6;
memset(&a2[v6], 0, 4LL * (v3 - 1 - (unsigned int)v6) + 4);
return v3;
}
}
v10 = atof(nptr);
*v5 = v10;
v11 = (unsigned __int8)*nptr;
if ( (unsigned __int8)v11 > 0x20u )
break;
LABEL_7:
if ( !_bittest64(&v8, v11) )
goto LABEL_6;
v6 = (unsigned int)(v6 + 1);
++v5;
if ( v3 == (_DWORD)v6 )
return v3;
}
do
LABEL_6:
v11 = (unsigned __int8)*++nptr;
while ( (unsigned __int8)v11 > 0x20u );
goto LABEL_7;
}
return v3;
}

original_code:
unsigned int string_toVec(const char *s, vec_t *v, const unsigned int maxdem){
 unsigned int i;
 for(i = 0; i < maxdem; i++){
  while(*s && (!(*s)||(*s)==' '||(*s)=='\r'||(*s)=='\n'||(*s) =='\t')) s++;
  if(!*s) break;
  v[i] = atof(s);
  while(!(!(*s)||(*s)==' '||(*s)=='\r'||(*s)=='\n'||(*s) =='\t')) s++;
 }
 unsigned int j;
 for(j = i; j < maxdem; j++) v[j] = 0.0;
 return j;
}

variable_types:
s
char *

variable_types:
v
float *

variable_types:
maxdem
unsigned int

variable_types:
j
unsigned int

return_type: unsigned int


decompiled_code:
__int64 __fastcall string_countWords(unsigned __int8 *a1)
{
__int64 v1; // rsi
unsigned __int64 v2; // rax
unsigned int v3; // er8
__int64 v4; // rcx
unsigned __int64 v5; // rdx

v1 = 0x100002601LL;
LODWORD(v2) = *a1;
v3 = 0;
v4 = 0x100002600LL;
LABEL_2:
if ( !(_BYTE)v2 )
return v3;
do
{
v5 = (unsigned int)v2;
v2 = *++a1;
if ( (unsigned __int8)v5 > 0x20u || !_bittest64(&v4, v5) )
{
++v3;
if ( (unsigned __int8)v2 > 0x20u )
goto LABEL_6;
while ( 1 )
{
if ( _bittest64(&v1, v2) )
goto LABEL_2;
do
LABEL_6:
v2 = *++a1;
while ( (unsigned __int8)v2 > 0x20u );
}
}
}
while ( (_BYTE)v2 );
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func5(unsigned __int8 *a1)
{
__int64 v1; // rsi
unsigned __int64 v2; // rax
unsigned int v3; // er8
__int64 v4; // rcx
unsigned __int64 v5; // rdx

v1 = 0x100002601LL;
LODWORD(v2) = *a1;
v3 = 0;
v4 = 0x100002600LL;
LABEL_2:
if ( !(_BYTE)v2 )
return v3;
do
{
v5 = (unsigned int)v2;
v2 = *++a1;
if ( (unsigned __int8)v5 > 0x20u || !_bittest64(&v4, v5) )
{
++v3;
if ( (unsigned __int8)v2 > 0x20u )
goto LABEL_6;
while ( 1 )
{
if ( _bittest64(&v1, v2) )
goto LABEL_2;
do
LABEL_6:
v2 = *++a1;
while ( (unsigned __int8)v2 > 0x20u );
}
}
}
while ( (_BYTE)v2 );
return v3;
}

original_code:
unsigned int string_countWords(const char *s){
 unsigned int i = 0;
 char * mystr = (char *) s;
 while(*mystr){
  while(*mystr && (!(*mystr)||(*mystr)==' '||(*mystr)=='\r'||(*mystr)=='\n'||(*mystr) =='\t')) mystr++;
  if(*mystr && !(!(*mystr)||(*mystr)==' '||(*mystr)=='\r'||(*mystr)=='\n'||(*mystr) =='\t')) i++, mystr++;
  while(*mystr && !(!(*mystr)||(*mystr)==' '||(*mystr)=='\r'||(*mystr)=='\n'||(*mystr) =='\t')) mystr++;
 }
 return i;
}

canonical_original_code:
unsigned int string_countWords(char *s){
 unsigned int i = 0;
 char *mystr = (char *) s;
 while(*mystr){
  while(*mystr && (!(*mystr)||(*mystr)==' '||(*mystr)=='\r'||(*mystr)=='\n'||(*mystr) =='\t')) mystr++;
  if(*mystr && !(!(*mystr)||(*mystr)==' '||(*mystr)=='\r'||(*mystr)=='\n'||(*mystr) =='\t')) i++, mystr++;
  while(*mystr && !(!(*mystr)||(*mystr)==' '||(*mystr)=='\r'||(*mystr)=='\n'||(*mystr) =='\t')) mystr++;
 }
 return i;
}

variable_types:
mystr
char *


getHash

decompiled_code:
__int64 __fastcall getHash(char *a1)
{
char v1; // al
char v2; // cl

v1 = *a1;
if ( !*a1 )
return 0LL;
v2 = 0;
do
{
++a1;
v2 = v1 + 31 * v2;
v1 = *a1;
}
while ( *a1 );
return v2 & 0x7F;
}

canonical_decompiled_code:
__int64 __fastcall func0(char *a1)
{
char v1; // al
char v2; // cl

v1 = *a1;
if ( !*a1 )
return 0LL;
v2 = 0;
do
{
++a1;
v2 = v1 + 31 * v2;
v1 = *a1;
}
while ( *a1 );
return v2 & 0x7F;
}

original_code:
int getHash(const char * string){
 unsigned long rethash = 0;
 while(*string){
  rethash = rethash * 31 + *string;
  string++;
 }
 return rethash%128;
}

canonical_original_code:
int getHash(char *string){
 unsigned long rethash = 0;
 while(*string){
  rethash = rethash * 31 + *string;
  string++;
 }
 return rethash%128;
}

variable_types:
string
char *

variable_types:
rethash
unsigned long


getHashCI

decompiled_code:
__int64 __fastcall getHashCI(char *a1)
{
char v1; // al
char v2; // si

v1 = *a1;
v2 = 0;
if ( !*a1 )
return 0LL;
do
{
if ( (unsigned __int8)(v1 - 65) <= 0x19u )
v1 += 32;
++a1;
v2 = v1 + 31 * v2;
v1 = *a1;
}
while ( *a1 );
return v2 & 0x7F;
}

original_code:
int getHashCI(const char * string){
 unsigned long rethash = 0;
 while(*string){
  rethash = rethash * 31 + ( ( (((*string)) >= 'A' && ((*string)) <= 'Z') ) ? (*string) + 32 : (*string) );
  string++;
 }
 return rethash%128;
}

canonical_original_code:
int getHashCI(char *string){
 unsigned long rethash = 0;
 while(*string){
  rethash = rethash * 31 + ( ( (((*string)) >= 'A' && ((*string)) <= 'Z') ) ? (*string) + 32 : (*string) );
  string++;
 }
 return rethash%128;
}


addToHashTable

decompiled_code:
__int64 __fastcall addToHashTable(char *a1, int a2, __int64 a3)
{
unsigned int v5; // er12
_QWORD *v6; // rax
_QWORD *v8; // rbx

v5 = getHash(a1);
v6 = (_QWORD *)(a3 + 24LL * (int)v5);
if ( *((_DWORD *)v6 + 2) )
{
do
{
v8 = v6;
v6 = (_QWORD *)v6[2];
}
while ( v6 );
v6 = malloc(0x18uLL);
v8[2] = v6;
}
*v6 = a1;
*((_DWORD *)v6 + 2) = a2;
v6[2] = 0LL;
return v5;
}

original_code:
int addToHashTable(const char * name, int id, hashbucket_t * ht){
 int hash = getHash(name);
 hashbucket_t * hb = &ht[hash];
 if(hb->id){
  for(; hb->next; hb = hb->next);
  hb->next = malloc(sizeof(hashbucket_t));
  hb = hb->next;
 }
 hb->name = (char *)name;
 hb->id = id;
 hb->next = 0;
 return hash;
}

canonical_original_code:
int addToHashTable(char *name, int id, struct hashbucket_s *ht){
 int hash = getHash(name);
 struct hashbucket_s *hb = &ht[hash];
 if(hb->id){
  for(; hb->next; hb = hb->next);
  hb->next = malloc(sizeof(hashbucket_t));
  hb = hb->next;
 }
 hb->name = (char *)name;
 hb->id = id;
 hb->next = 0;
 return hash;
}

variable_types:
name
char *

variable_types: struct hashbucket_s { char *name; int id; struct hashbucket_s *next; } *

variable_types: hash int


deleteFromHashTable

original_code:
int deleteFromHashTable(const char * name, int id, hashbucket_t *ht){
 int hash = getHash(name);
 hashbucket_t * hb = &ht[hash];
 if(hb->id == id){
  if(hb->next){
   *hb = *hb->next;
   free(hb->next);
  }
  hb->id = 0;
  hb->name = 0;
  return 1;
 }
 hashbucket_t * oldb = hb;
        for(hb = hb->next; hb; oldb = hb, hb = hb->next){
  if(hb->id == id){
   oldb->next = hb->next;
   free(hb);
   return 1;
  }
        }
 return 0;
}

canonical_original_code:
int deleteFromHashTable(char *name, int id, struct hashbucket_s *ht){
 int hash = getHash(name);
 struct hashbucket_s *hb = &ht[hash];
 if(hb->id == id){
  if(hb->next){
   *hb = *hb->next;
   free(hb->next);
  }
  hb->id = 0;
  hb->name = 0;
  return 1;
 }
 struct hashbucket_s *oldb = hb;
        for(hb = hb->next; hb; oldb = hb, hb = hb->next){
  if(hb->id == id){
   oldb->next = hb->next;
   free(hb);
   return 1;
  }
        }
 return 0;
}

variable_types: id int


findByNameRINT

decompiled_code:
__int64 __fastcall findByNameRINT(char *a1, __int64 a2)
{
__int64 *v3; // rbx
__int64 v4; // rdi

v3 = (__int64 *)(a2 + 24LL * (int)getHash(a1));
v4 = *v3;
if ( !*v3 )
return 0LL;
while ( !(unsigned int)string_testEqual(v4, a1) )
{
v3 = (__int64 *)v3[2];
if ( !v3 )
return 0LL;
v4 = *v3;
}
return *((unsigned int *)v3 + 2);
}

canonical_decompiled_code:
__int64 __fastcall func4(char *a1, __int64 a2)
{
__int64 *v3; // rbx
__int64 v4; // rdi

v3 = (__int64 *)(a2 + 24LL * (int)func0(a1));
v4 = *v3;
if ( !*v3 )
return 0LL;
while ( !(unsigned int)string_testEqual(v4, a1) )
{
v3 = (__int64 *)v3[2];
if ( !v3 )
return 0LL;
v4 = *v3;
}
return *((unsigned int *)v3 + 2);
}

original_code:
int findByNameRINT(const char * name, hashbucket_t *ht){
 int hash = getHash(name);
 hashbucket_t * hb = &ht[hash];
 if(!hb->name) return 0;
        for(; hb; hb = hb->next){
  if(string_testEqual(hb->name, name)){
   return hb->id;
  }
        }
 return 0;
}

canonical_original_code:
int findByNameRINT(char *name, struct hashbucket_s *ht){
 int hash = getHash(name);
 struct hashbucket_s *hb = &ht[hash];
 if(!hb->name) return 0;
        for(; hb; hb = hb->next){
  if(string_testEqual(hb->name, name)){
   return hb->id;
  }
        }
 return 0;
}


decompiled_code:
__int64 __fastcall drawbb_drawCallback(unsigned int **a1, int a2)
{
unsigned int *v2; // rbp
__int64 v3; // rdx
__int64 v4; // r8
__int64 v5; // r10
unsigned int v6; // eax
__int64 v8[22]; // [rsp+0h] [rbp-C8h] BYREF
__int64 v9; // [rsp+B0h] [rbp-18h] BYREF

v2 = *a1;
v3 = renderqueuevbo[2];
memset(v8, 0, sizeof(v8));
v4 = *v2;
v5 = v2[1];
*(__m128i *)((char *)v8 + 4) = _mm_load_si128((const __m128i *)&LC0);
LODWORD(v8[4]) = v3;
LODWORD(v8[8]) = v4;
LODWORD(v8[17]) = renderqueueuboid;
v8[18] = v5;
v8[20] = (unsigned int)(76 * a2);
LOBYTE(v8[0]) = 7;
LODWORD(v8[3]) = 513;
states_setState(
&v9,
v8[20],
v3,
0LL,
v4,
(unsigned int)renderqueueuboid,
v8[0],
*(_OWORD *)((char *)v8 + 4) >> 32,
v8[2],
v8[3],
v8[4],
v8[5],
v8[6],
v8[7],
v8[8],
v8[9],
v8[10],
v8[11],
v8[12],
v8[13],
v8[14],
v8[15]);
v6 = glGetError();
if ( v6 )
GL_PrintError(v6, "drawbb.c", 62LL);
return glDrawElements(1LL, (unsigned int)(24 * a2), 5125LL, 4LL * v2[2]);
}

original_code:
void drawbb_drawCallback(renderlistitem_t *ilist, unsigned int count){
 renderBBCallbackData_t *d = ilist->data;
 unsigned int mysize = count * sizeof(wireframeUBOStruct_t);
 glstate_t s = {1|4|2, 1, 1, 0x0201, 0x0405, 0, 0x0201, 0.0, renderqueuevbo.vaoid, 0, 0, 0, 0, 0, d->shaderprogram, 0, {0}, {0}, {renderqueueuboid, 0}, {d->ubodataoffset, 0}, {mysize, 0}};
 states_setState(s);
 {if (1){if (0) console_printf("CHECKGLERROR at %s:%d\n", "drawbb.c", 62);int checkglerror_errornumber = glGetError();if (checkglerror_errornumber) GL_PrintError(checkglerror_errornumber, "drawbb.c", 62);}}
 glDrawElements(0x0001, 24 * count, 0x1405, (const void *) (d->startf * sizeof(GLuint)));
}

canonical_original_code:
void drawbb_drawCallback(struct renderlistitem_s *ilist, unsigned int count){
 struct renderBBCallbackData_s *d = ilist->data;
 unsigned int mysize = count * sizeof(wireframeUBOStruct_t);
 struct glstate_s s = {1|4|2, 1, 1, 0x0201, 0x0405, 0, 0x0201, 0.0, renderqueuevbo.vaoid, 0, 0, 0, 0, 0, d->shaderprogram, 0, {0}, {0}, {renderqueueuboid, 0}, {d->ubodataoffset, 0}, {mysize, 0}};
 states_setState(s);
 {if (1){if (0) console_printf("CHECKGLERROR at %s:%d\n", "drawbb.c", 62);int checkglerror_errornumber = glGetError();if (checkglerror_errornumber) GL_PrintError(checkglerror_errornumber, "drawbb.c", 62);}}
 glDrawElements(0x0001, 24 * count, 0x1405, (void *) (d->startf * sizeof(GLuint)));
}

variable_types: struct renderlistitem_s { void *data; unsigned int datasize; unsigned int dataoffset; void (*setup)(struct renderlistitem_s *ilist, unsigned int count); void (*draw)(struct renderlistitem_s *ilist, unsigned int count); unsigned char flags; unsigned int counter; unsigned char sort[10]; } *

variable_types:
count
unsigned int

variable_types: struct renderBBCallbackData_s { unsigned int shaderprogram; unsigned int ubodataoffset; unsigned int startf; float bboxp[24]; struct wireframeUBOStruct_s { float mvp[16]; float color[3]; } ubo; } *

variable_types:
mysize
unsigned int

variable_types: struct glstate_s { char enabledstates; unsigned int blendsource; unsigned int blenddest; unsigned int depthfunc; unsigned int cullface; unsigned char depthmask; unsigned int alphafunc; float alpharef; unsigned int vaoid; unsigned int vboid; unsigned int vbotype; unsigned int vborangei; long vborangeo; long vboranges; unsigned int shaderid; unsigned char activetexture; unsigned int textureunitid[8]; unsigned int textureunittarget[8]; unsigned int uboblockid[2]; long uboblockrangeo[2]; long uboblockranges[2]; }

user_defined_types: struct renderBBCallbackData_s { unsigned int shaderprogram; unsigned int ubodataoffset; unsigned int startf; float bboxp[24]; struct wireframeUBOStruct_s ubo; }


decompiled_code:
int __fastcall drawbb_setupCallback(_QWORD *a1, unsigned int a2)
{
_QWORD *v2; // rbx
int result; // eax
int v4; // er12
__int64 v5; // rbp
int v6; // er12
__int64 v7; // rbx
int v8; // ebp
int v9; // er12

if ( a2 <= 1 )
{
if ( a2 == 1 )
{
v7 = *a1;
v8 = pushDataToVertCache(8LL, 24LL, &bboxpfaces, *a1 + 12LL, 0LL, 0LL, 0LL, 0LL, 0LL);
if ( v8 < 0 )
puts("BAAAD");
*(_DWORD *)(v7 + 8) = v8;
result = pushDataToUBOCache(184LL, v7 + 108);
v9 = result;
if ( result < 0 )
result = puts("BAAAD");
*(_DWORD *)(v7 + 4) = v9;
}
else
{
result = puts("fuckyou");
}
}
else
{
v2 = a1;
do
{
v5 = *v2;
v6 = pushDataToVertCache(8LL, 24LL, &bboxpfaces, *v2 + 12LL, 0LL, 0LL, 0LL, 0LL, 0LL);
if ( v6 < 0 )
puts("BAAAD");
*(_DWORD *)(v5 + 8) = v6;
result = pushDataToUBOCache(184LL, v5 + 108);
v4 = result;
if ( result < 0 )
result = puts("BAAAD");
*(_DWORD *)(v5 + 4) = v4;
v2 += 7;
*((_DWORD *)v2 - 5) = 1;
}
while ( &a1[7 * a2] != v2 );
}
return result;
}

canonical_decompiled_code:
int __fastcall func1(_QWORD *a1, unsigned int a2)
{
_QWORD *v2; // rbx
int result; // eax
int v4; // er12
__int64 v5; // rbp
int v6; // er12
__int64 v7; // rbx
int v8; // ebp
int v9; // er12

if ( a2 <= 1 )
{
if ( a2 == 1 )
{
v7 = *a1;
v8 = pushDataToVertCache(8LL, 24LL, &bboxpfaces, *a1 + 12LL, 0LL, 0LL, 0LL, 0LL, 0LL);
if ( v8 < 0 )
puts("BAAAD");
*(_DWORD *)(v7 + 8) = v8;
result = pushDataToUBOCache(184LL, v7 + 108);
v9 = result;
if ( result < 0 )
result = puts("BAAAD");
*(_DWORD *)(v7 + 4) = v9;
}
else
{
result = puts("fuckyou");
}
}
else
{
v2 = a1;
do
{
v5 = *v2;
v6 = pushDataToVertCache(8LL, 24LL, &bboxpfaces, *v2 + 12LL, 0LL, 0LL, 0LL, 0LL, 0LL);
if ( v6 < 0 )
puts("BAAAD");
*(_DWORD *)(v5 + 8) = v6;
result = pushDataToUBOCache(184LL, v5 + 108);
v4 = result;
if ( result < 0 )
result = puts("BAAAD");
*(_DWORD *)(v5 + 4) = v4;
v2 += 7;
*((_DWORD *)v2 - 5) = 1;
}
while ( &a1[7 * a2] != v2 );
}
return result;
}

original_code:
void drawbb_setupCallback(renderlistitem_t *ilist, unsigned int count){
 if(count > 1){
  unsigned int i = 0;
  while(i < count){
   renderBBCallbackData_t * d = ilist[i].data;
   int t = pushDataToVertCache(8, 24, bboxpfaces, d->bboxp, 0, 0, 0, 0, 0);
   if(t < 0) printf("BAAAD\n");
   d->startf = t;
   t = pushDataToUBOCache(sizeof(renderBBCallbackData_t), &d->ubo);
   if(t < 0) printf("BAAAD\n");
   d->ubodataoffset = t;
   ilist[i].counter = 1;
   i+= 1;
  }
 } else if (count == 1){
  renderBBCallbackData_t * d = ilist->data;
  int t = pushDataToVertCache(8, 24, bboxpfaces, d->bboxp, 0, 0, 0, 0, 0);
  if(t < 0) printf("BAAAD\n");
  d->startf = t;
  t = pushDataToUBOCache(sizeof(renderBBCallbackData_t), &d->ubo);
  if(t < 0) printf("BAAAD\n");
  d->ubodataoffset = t;
 } else {
  printf("fuckyou\n");
 }
}

canonical_original_code:
void drawbb_setupCallback(struct renderlistitem_s *ilist, unsigned int count){
 if(count > 1){
  unsigned int i = 0;
  while(i < count){
   struct renderBBCallbackData_s *d = ilist[i].data;
   int t = pushDataToVertCache(8, 24, bboxpfaces, d->bboxp, 0, 0, 0, 0, 0);
   if(t < 0) printf("BAAAD\n");
   d->startf = t;
   t = pushDataToUBOCache(sizeof(renderBBCallbackData_t), &d->ubo);
   if(t < 0) printf("BAAAD\n");
   d->ubodataoffset = t;
   ilist[i].counter = 1;
   i+= 1;
  }
 } else if (count == 1){
  struct renderBBCallbackData_s *d = ilist->data;
  int t = pushDataToVertCache(8, 24, bboxpfaces, d->bboxp, 0, 0, 0, 0, 0);
  if(t < 0) printf("BAAAD\n");
  d->startf = t;
  t = pushDataToUBOCache(sizeof(renderBBCallbackData_t), &d->ubo);
  if(t < 0) printf("BAAAD\n");
  d->ubodataoffset = t;
 } else {
  printf("fuckyou\n");
 }
}

variable_types:
i
unsigned int

variable_types: t int

user_defined_types: struct renderlistitem_s { void *data; unsigned int datasize; unsigned int dataoffset; void (*setup)(struct renderlistitem_s *ilist, unsigned int count); void (*draw)(struct renderlistitem_s *ilist, unsigned int count); unsigned char flags; unsigned int counter; unsigned char sort[10]; }

user_defined_types: struct wireframeUBOStruct_s { float mvp[16]; float color[3]; }


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

v0 = shader_createAndAddRINT("wireframe");
drawbb_ok = 1;
drawbbshaderid = v0;
return 1LL;
}

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

v0 = shader_createAndAddRINT("wireframe");
drawbb_ok = 1;
drawbbshaderid = v0;
return 1LL;
}

original_code:
int drawbb_init(void){
 drawbbshaderid = shader_createAndAddRINT("wireframe");
 drawbb_ok = 1;
 return 1;
}

canonical_original_code:
int drawbb_init(){
 drawbbshaderid = shader_createAndAddRINT("wireframe");
 drawbb_ok = 1;
 return 1;
}


decompiled_code:
__int64 __fastcall drawbb_addToRenderQueue(__int64 a1, __int64 a2, float a3, float a4, float a5)
{
__int64 v5; // rax
unsigned int v7; // [rsp+4Ch] [rbp-E8h]
char v8[64]; // [rsp+B8h] [rbp-7Ch] BYREF
float v9; // [rsp+F8h] [rbp-3Ch]
float v10; // [rsp+FCh] [rbp-38h]
float v11; // [rsp+100h] [rbp-34h]

v5 = shader_returnById((unsigned int)drawbbshaderid);
v7 = *(_DWORD *)(shader_addPermutationToProgram(v5, 0LL) + 8);
Matrix4x4_ToArrayFloatGL(a1 + 196, v8);
v9 = a3;
v10 = a4;
v11 = a5;
addRenderlistitem(a2, HIWORD(v7), HIBYTE(v7), v7 >> 8);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, __int64 a2, float a3, float a4, float a5)
{
__int64 v5; // rax
unsigned int v7; // [rsp+4Ch] [rbp-E8h]
char v8[64]; // [rsp+B8h] [rbp-7Ch] BYREF
float v9; // [rsp+F8h] [rbp-3Ch]
float v10; // [rsp+FCh] [rbp-38h]
float v11; // [rsp+100h] [rbp-34h]

v5 = shader_returnById((unsigned int)drawbbshaderid);
v7 = *(_DWORD *)(shader_addPermutationToProgram(v5, 0LL) + 8);
Matrix4x4_ToArrayFloatGL(a1 + 196, v8);
v9 = a3;
v10 = a4;
v11 = a5;
addRenderlistitem(a2, HIWORD(v7), HIBYTE(v7), v7 >> 8);
return 0LL;
}

original_code:
unsigned int drawbb_addToRenderQueue(viewport_t *v, renderqueue_t *q, const vec_t *bboxp, float colr, float colg, float colb){
 renderlistitem_t r ={0};
 renderBBCallbackData_t d;
 shaderprogram_t *s = shader_returnById(drawbbshaderid);
 shaderpermutation_t *sp = shader_addPermutationToProgram(s, 0);
 d.shaderprogram = sp->id;
 d.ubodataoffset = 0;
 Matrix4x4_ToArrayFloatGL(&v->viewproj, d.ubo.mvp);
 d.ubo.color[0] = colr;
 d.ubo.color[1] = colg;
 d.ubo.color[2] = colb;
 memcpy(d.bboxp, bboxp, 24 * sizeof(vec_t));
 r.sort[0] = (d.shaderprogram >> 0) && 0xFF;
 r.sort[1] = (d.shaderprogram >> 8) && 0xFF;
 r.sort[2] = (d.shaderprogram >> 16) && 0xFF;
 r.sort[3] = (d.shaderprogram >> 24) && 0xFF;
 r.setup = drawbb_setupCallback;
 r.draw = drawbb_drawCallback;
 r.datasize = sizeof(renderBBCallbackData_t);
 r.flags = 2 | 4;
 r.data = &d;
 addRenderlistitem(q, r);
 return 0;
}

canonical_original_code:
unsigned int drawbb_addToRenderQueue(struct viewport_s *v, struct renderqueue_s *q, float *bboxp, float colr, float colg, float colb){
 struct renderlistitem_s r = {0};
 struct renderBBCallbackData_s d;
 struct shaderprogram_s *s = shader_returnById(drawbbshaderid);
 struct shaderpermutation_s *sp = shader_addPermutationToProgram(s, 0);
 d.shaderprogram = sp->id;
 d.ubodataoffset = 0;
 Matrix4x4_ToArrayFloatGL(&v->viewproj, d.ubo.mvp);
 d.ubo.color[0] = colr;
 d.ubo.color[1] = colg;
 d.ubo.color[2] = colb;
 memcpy(d.bboxp, bboxp, 24 * sizeof(vec_t));
 r.sort[0] = (d.shaderprogram >> 0) && 0xFF;
 r.sort[1] = (d.shaderprogram >> 8) && 0xFF;
 r.sort[2] = (d.shaderprogram >> 16) && 0xFF;
 r.sort[3] = (d.shaderprogram >> 24) && 0xFF;
 r.setup = drawbb_setupCallback;
 r.draw = drawbb_drawCallback;
 r.datasize = sizeof(renderBBCallbackData_t);
 r.flags = 2 | 4;
 r.data = &d;
 addRenderlistitem(q, r);
 return 0;
}

variable_types: struct viewport_s { char *name; char type; int myid; float aspect; float fov; float near; float far; int viewchanged; int outfbid; int dfbid; float pos[3]; float angle[3]; struct matrix4x4_s { float m[4][4]; } projection; struct matrix4x4_s view; struct matrix4x4_s viewproj; struct matrix4x4_s cam; struct plane_s { float norm[3]; float d; } frustum[6]; float bboxp[24]; float v_forward[3]; float v_up[3]; float v_right[3]; char dir[4]; } *

variable_types: struct renderqueue_s { unsigned int size; unsigned int place; struct renderlistitem_s { void *data; unsigned int datasize; unsigned int dataoffset; void (*setup)(struct renderlistitem_s *ilist, unsigned int count); void (*draw)(struct renderlistitem_s *ilist, unsigned int count); unsigned char flags; unsigned int counter; unsigned char sort[10]; } *list; unsigned int datasize; unsigned int dataplace; unsigned char *data; } *

variable_types:
bboxp
float *

variable_types: colr float

variable_types: colg float

variable_types: colb float

variable_types: struct renderBBCallbackData_s { unsigned int shaderprogram; unsigned int ubodataoffset; unsigned int startf; float bboxp[24]; struct wireframeUBOStruct_s { float mvp[16]; float color[3]; } ubo; }

variable_types: struct shaderprogram_s { char *name; char type; char sysflagssupport; int numdefines; char **defines; int myid; char *fragstring; int fraglength; char *vertstring; int vertlength; char *geomstring; int geomlength; struct shaderpermutation_s { struct shaderpermutation_s *next; unsigned int id; char compiled; unsigned int permutation; int unimat40; int unimat41; int univec40; int univec30; int univec20; int univec21; int uniscreensizefix; int uniscreentodepth; int uniint0; int unifloat0; int uniblock0; int uniblock1; int texturespos[16]; } permhashtable[256]; } *

variable_types: struct shaderpermutation_s { struct shaderpermutation_s *next; unsigned int id; char compiled; unsigned int permutation; int unimat40; int unimat41; int univec40; int univec30; int univec20; int univec21; int uniscreensizefix; int uniscreentodepth; int uniint0; int unifloat0; int uniblock0; int uniblock1; int texturespos[16]; } *

user_defined_types: struct viewport_s { char *name; char type; int myid; float aspect; float fov; float near; float far; int viewchanged; int outfbid; int dfbid; float pos[3]; float angle[3]; struct matrix4x4_s projection; struct matrix4x4_s view; struct matrix4x4_s viewproj; struct matrix4x4_s cam; struct plane_s frustum[6]; float bboxp[24]; float v_forward[3]; float v_up[3]; float v_right[3]; char dir[4]; }

user_defined_types: struct renderqueue_s { unsigned int size; unsigned int place; struct renderlistitem_s *list; unsigned int datasize; unsigned int dataplace; unsigned char *data; }

user_defined_types: struct shaderprogram_s { char *name; char type; char sysflagssupport; int numdefines; char **defines; int myid; char *fragstring; int fraglength; char *vertstring; int vertlength; char *geomstring; int geomlength; struct shaderpermutation_s permhashtable[256]; }


initgame

original_code:
int initgame(void){
 entity_t * entcampointer = ec->entity_addRPOINT("campointer");
  entcampointer->type = 2;
  entcampointer->modelid = ec->model_createAndAddRINT("coil");
  entcampointer->shaderid = ec->shader_createAndAddRINT("deferredmodel");
  entcampointer->texturegroupid = ec->texture_createAndAddGroupRINT("coil");
  entcampointer->shaderperm = 7;
  entcampointer->flags = 1;
  entcampointer->angle[0] = 30;
  entcampointer->scale = 1.0;
  entcampointer->needsmatupdate = 1;
 entity_t * enthat = ec->entity_addRPOINT("hat");
  enthat->type = 2;
  enthat->pos[1] = 8.7;
  enthat->pos[0] = -2.5;
  enthat->scale = .5;
  enthat->angle[1] = -45.0;
  enthat->anglevel[0] = 45.0;
  enthat->needsmatupdate = 1;
  enthat->modelid = ec->model_createAndAddRINT("teapot");
  enthat->shaderid = ec->shader_createAndAddRINT("deferredmodel");
  enthat->texturegroupid = 0;
  enthat->flags = 1;
 entity_t * entcoil = ec->entity_addRPOINT("coil");
  entcoil->type = 2;
  entcoil->pos[2] = 10.0;
  entcoil->anglevel[2] = 360.0;
  entcoil->needsmatupdate = 1;
  entcoil->shaderid = ec->shader_createAndAddRINT("deferredmodel");
  entcoil->modelid = ec->model_createAndAddRINT("bunny");
  entcoil->flags = 2;
  entcoil->modelid = ec->model_createAndAddRINT("coil");
  entcoil->texturegroupid = ec->texture_createAndAddGroupRINT("coil");
  entcoil->attachmentid = ec->entity_findByNameRINT("hat");
  entcoil->shaderperm = 1;
 int tempid = entcoil->myid;
 entity_t * entlightoffset = ec->entity_addRPOINT("lightoffset");
  entlightoffset->pos[2] = 3.0f;
  entlightoffset->pos[1] = 3.0f;
  entlightoffset->needsmatupdate = 1;
  entlightoffset->type = 1;
  entlightoffset->attachmentid = tempid;
 tempid = entlightoffset->myid;
 light_t * splight = ec->light_addRPOINT("spot");
  splight->type = 2;
  splight->attachmentid = tempid;
  splight->needsupdate = 3;
  splight->scale = 20.0f;
  splight->fovx = 60;
  splight->fovy = 60;
  splight->near = 0.1;
  splight->angle[0] = 45.0;
 light_t * light = ec->light_addRPOINT("light");
  light->type = 1;
  light->attachmentid = tempid;
  light->needsupdate = 1;
  light->scale = 20.0f;
 entity_t * enttinydragon = ec->entity_addRPOINT("tinydragon");
  enttinydragon->type = 2;
  enttinydragon->pos[1] = 3.0f;
  enttinydragon->scale = 0.2f;
  enttinydragon->needsmatupdate = 1;
  enttinydragon->modelid = ec->model_createAndAddRINT("dragon");
  enttinydragon->shaderid = ec->shader_createAndAddRINT("deferredmodel");
  enttinydragon->texturegroupid = 0;
  enttinydragon->attachmentid = ec->entity_findByNameRINT("coil");
 enttinydragon = ec->entity_addRPOINT("tinydragon");
  enttinydragon->flags = 1;
  enttinydragon->type = 2;
  enttinydragon->pos[1] = -3.0f;
  enttinydragon->angle[2] = 180.0f;
  enttinydragon->scale = 0.2f;
  enttinydragon->needsmatupdate = 1;
  enttinydragon->shaderid = ec->shader_createAndAddRINT("deferredmodel");
  enttinydragon->modelid = ec->model_createAndAddRINT("dragon");
  enttinydragon->texturegroupid = 0;
  enttinydragon->attachmentid = ec->entity_findByNameRINT("coil");
  enttinydragon->texturegroupid = 1;
 enttinydragon = ec->entity_addRPOINT("tinydragon");
  enttinydragon->flags = 1;
  enttinydragon->type = 2;
  enttinydragon->pos[2] = 3.0f;
  enttinydragon->angle[2] = 90.0f;
  enttinydragon->scale = 0.2f;
  enttinydragon->needsmatupdate = 1;
  enttinydragon->shaderid = ec->shader_createAndAddRINT("deferredmodel");
  enttinydragon->modelid = ec->model_createAndAddRINT("dragon");
  enttinydragon->texturegroupid = 0;
  enttinydragon->attachmentid = ec->entity_findByNameRINT("coil");
  enttinydragon->shaderperm = 0;
 enttinydragon = ec->entity_addRPOINT("tinydragon");
  enttinydragon->flags = 1;
  enttinydragon->type = 2;
  enttinydragon->pos[2] = -3.0f;
  enttinydragon->angle[2] = -90.0f;
  enttinydragon->scale = 0.2f;
  enttinydragon->needsmatupdate = 1;
  enttinydragon->modelid = ec->model_createAndAddRINT("dragon");
  enttinydragon->shaderid = ec->shader_createAndAddRINT("deferredmodel");
  enttinydragon->texturegroupid = 0;
  enttinydragon->attachmentid = ec->entity_findByNameRINT("coil");
  enttinydragon->shaderperm = 0;
 int i;
 tempid = 0;
 for(i = 0; i < 100; i++){
  enttinydragon = ec->entity_addRPOINT("bunny");
   enttinydragon->flags = 1;
   enttinydragon->type = 2;
   enttinydragon->pos[0] = 5.0f;
   enttinydragon->pos[2] = -2.0f;
   enttinydragon->anglevel[1] = 20.0f;
   enttinydragon->scale = 1.0f;
   enttinydragon->needsmatupdate = 1;
   enttinydragon->modelid = ec->model_createAndAddRINT("cube2");
   enttinydragon->shaderid = ec->shader_createAndAddRINT("deferredmodel");
   enttinydragon->texturegroupid = ec->texture_createAndAddGroupRINT("bunny");
   enttinydragon->shaderperm = 1;
   enttinydragon->attachmentid = tempid;
   tempid = enttinydragon->myid;
 light_t * light = ec->light_addRPOINT("light");
  light->type = 1;
  light->attachmentid = enttinydragon->myid;
  light->needsupdate = 1;
  light->scale = 5.0f;
 }
 light_t * slight = ec->light_addRPOINT("spot");
  slight->type = 2;
  slight->needsupdate = 3;
  slight->scale = 20.0f;
  slight->fovx = 90;
  slight->fovy = 90;
  slight->near = 0.1;
  slight->far = 20.0;
  slight->pos[2] = -10.0;
 return 1;
}

canonical_original_code:
int initgame(){
 struct entity_s *entcampointer = ec->entity_addRPOINT("campointer");
  entcampointer->type = 2;
  entcampointer->modelid = ec->model_createAndAddRINT("coil");
  entcampointer->shaderid = ec->shader_createAndAddRINT("deferredmodel");
  entcampointer->texturegroupid = ec->texture_createAndAddGroupRINT("coil");
  entcampointer->shaderperm = 7;
  entcampointer->flags = 1;
  entcampointer->angle[0] = 30;
  entcampointer->scale = 1.0;
  entcampointer->needsmatupdate = 1;
 struct entity_s *enthat = ec->entity_addRPOINT("hat");
  enthat->type = 2;
  enthat->pos[1] = 8.7;
  enthat->pos[0] = -2.5;
  enthat->scale = .5;
  enthat->angle[1] = -45.0;
  enthat->anglevel[0] = 45.0;
  enthat->needsmatupdate = 1;
  enthat->modelid = ec->model_createAndAddRINT("teapot");
  enthat->shaderid = ec->shader_createAndAddRINT("deferredmodel");
  enthat->texturegroupid = 0;
  enthat->flags = 1;
 struct entity_s *entcoil = ec->entity_addRPOINT("coil");
  entcoil->type = 2;
  entcoil->pos[2] = 10.0;
  entcoil->anglevel[2] = 360.0;
  entcoil->needsmatupdate = 1;
  entcoil->shaderid = ec->shader_createAndAddRINT("deferredmodel");
  entcoil->modelid = ec->model_createAndAddRINT("bunny");
  entcoil->flags = 2;
  entcoil->modelid = ec->model_createAndAddRINT("coil");
  entcoil->texturegroupid = ec->texture_createAndAddGroupRINT("coil");
  entcoil->attachmentid = ec->entity_findByNameRINT("hat");
  entcoil->shaderperm = 1;
 int tempid = entcoil->myid;
 struct entity_s *entlightoffset = ec->entity_addRPOINT("lightoffset");
  entlightoffset->pos[2] = 3.0f;
  entlightoffset->pos[1] = 3.0f;
  entlightoffset->needsmatupdate = 1;
  entlightoffset->type = 1;
  entlightoffset->attachmentid = tempid;
 tempid = entlightoffset->myid;
 struct light_s *splight = ec->light_addRPOINT("spot");
  splight->type = 2;
  splight->attachmentid = tempid;
  splight->needsupdate = 3;
  splight->scale = 20.0f;
  splight->fovx = 60;
  splight->fovy = 60;
  splight->near = 0.1;
  splight->angle[0] = 45.0;
 struct light_s *light = ec->light_addRPOINT("light");
  light->type = 1;
  light->attachmentid = tempid;
  light->needsupdate = 1;
  light->scale = 20.0f;
 struct entity_s *enttinydragon = ec->entity_addRPOINT("tinydragon");
  enttinydragon->type = 2;
  enttinydragon->pos[1] = 3.0f;
  enttinydragon->scale = 0.2f;
  enttinydragon->needsmatupdate = 1;
  enttinydragon->modelid = ec->model_createAndAddRINT("dragon");
  enttinydragon->shaderid = ec->shader_createAndAddRINT("deferredmodel");
  enttinydragon->texturegroupid = 0;
  enttinydragon->attachmentid = ec->entity_findByNameRINT("coil");
 enttinydragon = ec->entity_addRPOINT("tinydragon");
  enttinydragon->flags = 1;
  enttinydragon->type = 2;
  enttinydragon->pos[1] = -3.0f;
  enttinydragon->angle[2] = 180.0f;
  enttinydragon->scale = 0.2f;
  enttinydragon->needsmatupdate = 1;
  enttinydragon->shaderid = ec->shader_createAndAddRINT("deferredmodel");
  enttinydragon->modelid = ec->model_createAndAddRINT("dragon");
  enttinydragon->texturegroupid = 0;
  enttinydragon->attachmentid = ec->entity_findByNameRINT("coil");
  enttinydragon->texturegroupid = 1;
 enttinydragon = ec->entity_addRPOINT("tinydragon");
  enttinydragon->flags = 1;
  enttinydragon->type = 2;
  enttinydragon->pos[2] = 3.0f;
  enttinydragon->angle[2] = 90.0f;
  enttinydragon->scale = 0.2f;
  enttinydragon->needsmatupdate = 1;
  enttinydragon->shaderid = ec->shader_createAndAddRINT("deferredmodel");
  enttinydragon->modelid = ec->model_createAndAddRINT("dragon");
  enttinydragon->texturegroupid = 0;
  enttinydragon->attachmentid = ec->entity_findByNameRINT("coil");
  enttinydragon->shaderperm = 0;
 enttinydragon = ec->entity_addRPOINT("tinydragon");
  enttinydragon->flags = 1;
  enttinydragon->type = 2;
  enttinydragon->pos[2] = -3.0f;
  enttinydragon->angle[2] = -90.0f;
  enttinydragon->scale = 0.2f;
  enttinydragon->needsmatupdate = 1;
  enttinydragon->modelid = ec->model_createAndAddRINT("dragon");
  enttinydragon->shaderid = ec->shader_createAndAddRINT("deferredmodel");
  enttinydragon->texturegroupid = 0;
  enttinydragon->attachmentid = ec->entity_findByNameRINT("coil");
  enttinydragon->shaderperm = 0;
 int i;
 tempid = 0;
 for(i = 0; i < 100; i++){
  enttinydragon = ec->entity_addRPOINT("bunny");
   enttinydragon->flags = 1;
   enttinydragon->type = 2;
   enttinydragon->pos[0] = 5.0f;
   enttinydragon->pos[2] = -2.0f;
   enttinydragon->anglevel[1] = 20.0f;
   enttinydragon->scale = 1.0f;
   enttinydragon->needsmatupdate = 1;
   enttinydragon->modelid = ec->model_createAndAddRINT("cube2");
   enttinydragon->shaderid = ec->shader_createAndAddRINT("deferredmodel");
   enttinydragon->texturegroupid = ec->texture_createAndAddGroupRINT("bunny");
   enttinydragon->shaderperm = 1;
   enttinydragon->attachmentid = tempid;
   tempid = enttinydragon->myid;
 struct light_s *light = ec->light_addRPOINT("light");
  light->type = 1;
  light->attachmentid = enttinydragon->myid;
  light->needsupdate = 1;
  light->scale = 5.0f;
 }
 struct light_s *slight = ec->light_addRPOINT("spot");
  slight->type = 2;
  slight->needsupdate = 3;
  slight->scale = 20.0f;
  slight->fovx = 90;
  slight->fovy = 90;
  slight->near = 0.1;
  slight->far = 20.0;
  slight->pos[2] = -10.0;
 return 1;
}

variable_types: struct entity_s { char *name; int myid; char type; float pos[3]; float angle[3]; float anglevel[3]; float vel[3]; float scale; int needsmatupdate; struct matrix4x4_s { float m[4][4]; } mat; double nextthink; void (*spawn)(struct entity_s *e); void (*remove)(struct entity_s *e); void (*think)(struct entity_s *e); void (*touch)(struct entity_s *e, int touchid); int parentid; int attachmentid; int shaderid; int shaderperm; int texturegroupid; int modelid; struct phystype_s { enum { STATIC=0, FLY=1, DYNAMIC=2, ODEFLY=3, ODEDYNAMIC=4 } movetype; enum { NONE=0, AABB=1, ODESPHERE=2, ODEBOX=3, ODECYLINDER=4, ODECAPSULE=5 } collidetype; float mass; void *gid; void *bid; } phys; int needsbboxupdate; float bboxp[24]; float bbox[6]; char flags; unsigned char treedepth; unsigned int leafpos; void *leaf; int leafitemupnext; char leaftypeupnext; int leafitemupprev; char leaftypeupprev; int leafitemdownnext; char leaftypedownnext; int leafitemdownprev; char leaftypedownprev; } *

variable_types: tempid int

variable_types: struct light_s { char *name; int myid; char type; float pos[3]; float angle[3]; float scale; float difbright; float specbright; float color[3]; int attachmentid; int needsupdate; float bboxp[24]; float bbox[6]; unsigned char treedepth; unsigned int leafpos; void *leaf; float fovx; float fovy; float near; float far; struct plane_s { float norm[3]; float d; } frustum[6]; struct matrix4x4_s { float m[4][4]; } projection; struct matrix4x4_s view; struct matrix4x4_s viewproj; struct matrix4x4_s cam; struct matrix4x4_s fixproj; struct matrix4x4_s camproj; struct matrix4x4_s samplemat; unsigned int shadowid; unsigned int shadowsize; struct leaflinkitem_s { int self; char type; float bb[2]; int unext; char unextt; int uprev; char uprevt; int dnext; char dnextt; int dprev; char dprevt; } ll; } *

variable_types: i int

user_defined_types: struct entity_s { char *name; int myid; char type; float pos[3]; float angle[3]; float anglevel[3]; float vel[3]; float scale; int needsmatupdate; struct matrix4x4_s mat; double nextthink; void (*spawn)(struct entity_s *e); void (*remove)(struct entity_s *e); void (*think)(struct entity_s *e); void (*touch)(struct entity_s *e, int touchid); int parentid; int attachmentid; int shaderid; int shaderperm; int texturegroupid; int modelid; struct phystype_s phys; int needsbboxupdate; float bboxp[24]; float bbox[6]; char flags; unsigned char treedepth; unsigned int leafpos; void *leaf; int leafitemupnext; char leaftypeupnext; int leafitemupprev; char leaftypeupprev; int leafitemdownnext; char leaftypedownnext; int leafitemdownprev; char leaftypedownprev; }

user_defined_types: struct light_s { char *name; int myid; char type; float pos[3]; float angle[3]; float scale; float difbright; float specbright; float color[3]; int attachmentid; int needsupdate; float bboxp[24]; float bbox[6]; unsigned char treedepth; unsigned int leafpos; void *leaf; float fovx; float fovy; float near; float far; struct plane_s frustum[6]; struct matrix4x4_s projection; struct matrix4x4_s view; struct matrix4x4_s viewproj; struct matrix4x4_s cam; struct matrix4x4_s fixproj; struct matrix4x4_s camproj; struct matrix4x4_s samplemat; unsigned int shadowid; unsigned int shadowsize; struct leaflinkitem_s ll; }


setupGameCodeCallbacks

decompiled_code:
void *__fastcall setupGameCodeCallbacks(__int64 a1)
{
void *result; // rax

ec = a1;
if ( !a1 )
return 0LL;
result = &gc;
gc = 1;
*((_QWORD *)&gc + 1) = initgame;
return result;
}

canonical_decompiled_code:
void *__fastcall func1(__int64 a1)
{
void *result; // rax

ec = a1;
if ( !a1 )
return 0LL;
result = &gc;
gc = 1;
*((_QWORD *)&gc + 1) = initgame;
return result;
}

original_code:
gcallheader_t* setupGameCodeCallbacks(ecallheader_t *myec){
 ec = myec;
 if(!ec) return 0;
 gc.apiver = 1;
 gc.initgame = initgame;
 return &gc;
}

canonical_original_code:
struct gcallheader_s *setupGameCodeCallbacks(struct ecallheader_s *myec){
 ec = myec;
 if(!ec) return 0;
 gc.apiver = 1;
 gc.initgame = initgame;
 return &gc;
}

variable_types: struct ecallheader_s { int (*console_printf)(char *fmt, ...); int (*console_nprintf)(unsigned long size, char *fmt, ...); int (*cvar_register)(struct cvar_s { char type; char *name; char *helptext; char *defaultstring; void (*onchange)(struct cvar_s *c); int valueint; float valuefloat; float valuevector[3]; char *valuestring; unsigned int valuestringlength; int myid; char notdefault; } *c); int (*cvar_unregister)(int id); int (*cvar_findByNameRINT)(char *name); void (*cvar_nameset)(char *name, char *value); void (*cvar_pset)(struct cvar_s *c, char *value); void (*cvar_idset)(int id, char *value); struct cvar_s *(*cvar_returnById)(int id); struct cvar_s *(*cvar_findByNameRPOINT)(char *name); struct entity_s { char *name; int myid; char type; float pos[3]; float angle[3]; float anglevel[3]; float vel[3]; float scale; int needsmatupdate; struct matrix4x4_s { float m[4][4]; } mat; double nextthink; void (*spawn)(struct entity_s *e); void (*remove)(struct entity_s *e); void (*think)(struct entity_s *e); void (*touch)(struct entity_s *e, int touchid); int parentid; int attachmentid; int shaderid; int shaderperm; int texturegroupid; int modelid; struct phystype_s { enum { STATIC=0, FLY=1, DYNAMIC=2, ODEFLY=3, ODEDYNAMIC=4 } movetype; enum { NONE=0, AABB=1, ODESPHERE=2, ODEBOX=3, ODECYLINDER=4, ODECAPSULE=5 } collidetype; float mass; void *gid; void *bid; } phys; int needsbboxupdate; float bboxp[24]; float bbox[6]; char flags; unsigned char treedepth; unsigned int leafpos; void *leaf; int leafitemupnext; char leaftypeupnext; int leafitemupprev; char leaftypeupprev; int leafitemdownnext; char leaftypedownnext; int leafitemdownprev; char leaftypedownprev; } *(*entity_findByNameRPOINT)(char *name); struct entitylistpoint_s { struct entity_s **list; unsigned int count; } (*entity_findAllByNameRPOINT)(char *name); struct entitylistint_s { int *list; unsigned int count; } (*entity_findAllByNameRINT)(char *name); struct entity_s *(*entity_returnById)(int id); struct entity_s *(*entity_addRPOINT)(char *name); int (*entity_findByNameRINT)(char *name); int (*entity_addRINT)(char *name); int (*entity_delete)(int id); int (*file_loadString)(char *filename, char **output, int *length, int debugmode); int (*file_loadStringNoLength)(char *filename, char **output, int debugmode); int (*light_addRINT)(char *name); struct light_s { char *name; int myid; char type; float pos[3]; float angle[3]; float scale; float difbright; float specbright; float color[3]; int attachmentid; int needsupdate; float bboxp[24]; float bbox[6]; unsigned char treedepth; unsigned int leafpos; void *leaf; float fovx; float fovy; float near; float far; struct plane_s { float norm[3]; float d; } frustum[6]; struct matrix4x4_s projection; struct matrix4x4_s view; struct matrix4x4_s viewproj; struct matrix4x4_s cam; struct matrix4x4_s fixproj; struct matrix4x4_s camproj; struct matrix4x4_s samplemat; unsigned int shadowid; unsigned int shadowsize; struct leaflinkitem_s { int self; char type; float bb[2]; int unext; char unextt; int uprev; char uprevt; int dnext; char dnextt; int dprev; char dprevt; } ll; } *(*light_addRPOINT)(char *name); int (*shader_createAndAddRINT)(char *name); unsigned int (*string_toVec)(char *s, float *c, unsigned int maxdem); int (*texture_createAndAddGroupRINT)(char *name); int (*model_createAndAddRINT)(char *name); } *

return_type: struct gcallheader_s { unsigned int apiver; int (*initgame)(); } *

user_defined_types: struct ecallheader_s { int (*console_printf)(char *fmt, ...); int (*console_nprintf)(unsigned long size, char *fmt, ...); int (*cvar_register)(struct cvar_s *c); int (*cvar_unregister)(int id); int (*cvar_findByNameRINT)(char *name); void (*cvar_nameset)(char *name, char *value); void (*cvar_pset)(struct cvar_s *c, char *value); void (*cvar_idset)(int id, char *value); struct cvar_s *(*cvar_returnById)(int id); struct cvar_s *(*cvar_findByNameRPOINT)(char *name); struct entity_s *(*entity_findByNameRPOINT)(char *name); struct entitylistpoint_s (*entity_findAllByNameRPOINT)(char *name); struct entitylistint_s (*entity_findAllByNameRINT)(char *name); struct entity_s *(*entity_returnById)(int id); struct entity_s *(*entity_addRPOINT)(char *name); int (*entity_findByNameRINT)(char *name); int (*entity_addRINT)(char *name); int (*entity_delete)(int id); int (*file_loadString)(char *filename, char **output, int *length, int debugmode); int (*file_loadStringNoLength)(char *filename, char **output, int debugmode); int (*light_addRINT)(char *name); struct light_s *(*light_addRPOINT)(char *name); int (*shader_createAndAddRINT)(char *name); unsigned int (*string_toVec)(char *s, float *c, unsigned int maxdem); int (*texture_createAndAddGroupRINT)(char *name); int (*model_createAndAddRINT)(char *name); }


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v4; // ebp
int v5; // ebx
int v6; // eax
float v7; // xmm1_4

if ( (unsigned int)sdlInit(1366LL, 768LL, 24LL, 1LL) && (unsigned int)glInit() )
{
v4 = SDL_GetTicks();
while ( 1 )
{
v5 = 1000;
do
{
sdlCheckEvent();
glRender();
--v5;
}
while ( v5 );
v6 = SDL_GetTicks();
v7 = (float)(v6 - v4);
v4 = v6;
printf("%f fps \n", (float)(1000000.0 / v7));
}
}
return 0;
}

original_code:
int main(int argc, char *argv[]){
unsigned int to, t;
unsigned int framecount = 0;
 if(!sdlInit(1366, 768, 24, 1) || !glInit()) return 0;
 to = SDL_GetTicks();
 while(1){
  sdlCheckEvent();
  glRender();
  framecount++;
  if(framecount == 1000){
   t = SDL_GetTicks();
   printf("%f fps \n", 1000000.0f/(t-to));
   to = t;
   framecount = 0;
  }
 }
 return 1;
}

canonical_original_code:
int main(int argc, char *argv[]){
unsigned int to; unsigned int t;
unsigned int framecount = 0;
 if(!sdlInit(1366, 768, 24, 1) || !glInit()) return 0;
 to = SDL_GetTicks();
 while(1){
  sdlCheckEvent();
  glRender();
  framecount++;
  if(framecount == 1000){
   t = SDL_GetTicks();
   printf("%f fps \n", 1000000.0f/(t-to));
   to = t;
   framecount = 0;
  }
 }
 return 1;
}

variable_types: argc int

variable_types:
argv
char *[]

variable_types:
to
unsigned int

variable_types:
t
unsigned int

variable_types:
framecount
unsigned int


addFrameBufferToList

decompiled_code:
__int64 __fastcall addFrameBufferToList(__int64 a1, int a2, int a3, int a4, int a5, char a6)
{
char *v10; // rax
size_t v12; // [rsp+0h] [rbp-48h]
unsigned int v13; // [rsp+Ch] [rbp-3Ch]

v13 = fbnumber++;
v12 = 40LL * fbnumber;
fblist = realloc(fblist, v12);
v10 = (char *)fblist + v12 - 40;
*((_QWORD *)v10 + 1) = a1;
*(_DWORD *)v10 = a2;
*((_DWORD *)v10 + 4) = a3;
*((_DWORD *)v10 + 5) = a4;
*((_DWORD *)v10 + 8) = a5;
v10[36] = a6;
*((float *)v10 + 6) = (float)a3 / (float)a4;
return v13;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, int a2, int a3, int a4, int a5, char a6)
{
char *v10; // rax
size_t v12; // [rsp+0h] [rbp-48h]
unsigned int v13; // [rsp+Ch] [rbp-3Ch]

v13 = fbnumber++;
v12 = 40LL * fbnumber;
fblist = realloc(fblist, v12);
v10 = (char *)fblist + v12 - 40;
*((_QWORD *)v10 + 1) = a1;
*(_DWORD *)v10 = a2;
*((_DWORD *)v10 + 4) = a3;
*((_DWORD *)v10 + 5) = a4;
*((_DWORD *)v10 + 8) = a5;
v10[36] = a6;
*((float *)v10 + 6) = (float)a3 / (float)a4;
return v13;
}

original_code:
int addFrameBufferToList(char *name, GLuint id, GLuint width, GLuint height, GLuint texid, char type){
 int current = fbnumber;
 fbnumber++;
 fblist = realloc(fblist, (fbnumber)*sizeof(framebuffer_t));
 fblist[current].name = name;
 fblist[current].id = id;
 fblist[current].width = width;
 fblist[current].height = height;
 fblist[current].aspect = (float)width/(float)height;
 fblist[current].texid = texid;
 fblist[current].type = type;
 return current;
}

canonical_original_code:
int addFrameBufferToList(char *name, unsigned int id, unsigned int width, unsigned int height, unsigned int texid, char type){
 int current = fbnumber;
 fbnumber++;
 fblist = realloc(fblist, (fbnumber)*sizeof(framebuffer_t));
 fblist[current].name = name;
 fblist[current].id = id;
 fblist[current].width = width;
 fblist[current].height = height;
 fblist[current].aspect = (float)width/(float)height;
 fblist[current].texid = texid;
 fblist[current].type = type;
 return current;
}

variable_types:
name
char *

variable_types:
id
unsigned int

variable_types:
width
unsigned int

variable_types:
height
unsigned int

variable_types:
texid
unsigned int

variable_types: type char

variable_types: current int


initFrameBufferSystem

decompiled_code:
__int64 initFrameBufferSystem()
{
size_t v0; // r12

if ( fblist )
free(fblist);
v0 = 40LL * fbnumber;
fblist = malloc(v0);
if ( !fblist )
memset(0LL, 0, v0);
addFrameBufferToList((__int64)"default", 0, 0, 0, 0, 0);
return 1LL;
}

canonical_decompiled_code:
__int64 func1()
{
size_t v0; // r12

if ( fblist )
free(fblist);
v0 = 40LL * fbnumber;
fblist = malloc(v0);
if ( !fblist )
memset(0LL, 0, v0);
func0((__int64)"default", 0, 0, 0, 0, 0);
return 1LL;
}

original_code:
int initFrameBufferSystem(void){
 if(fblist) free(fblist);
 fblist = malloc(fbnumber * sizeof(framebuffer_t));
 if(!fblist) memset(fblist, 0 , fbnumber * sizeof(framebuffer_t));
 addFrameBufferToList("default", 0,0,0,0, (char)0);
 return 1;
}

canonical_original_code:
int initFrameBufferSystem(){
 if(fblist) free(fblist);
 fblist = malloc(fbnumber * sizeof(framebuffer_t));
 if(!fblist) memset(fblist, 0 , fbnumber * sizeof(framebuffer_t));
 addFrameBufferToList("default", 0,0,0,0, (char)0);
 return 1;
}