decompiled_code:
__int64 __fastcall string_toVec(char *nptr, float *a2, unsigned int a3)
{
float *v5; // r14
unsigned int v6; // er13
__int64 v7; // rbp
__int64 v8; // r12
float v9; // xmm0_4
unsigned __int64 v10; // rdx
unsigned __int64 v11; // rcx
unsigned __int64 v12; // rax

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

canonical_decompiled_code:
__int64 __fastcall func4(char *nptr, float *a2, unsigned int a3)
{
float *v5; // r14
unsigned int v6; // er13
__int64 v7; // rbp
__int64 v8; // r12
float v9; // xmm0_4
unsigned __int64 v10; // rdx
unsigned __int64 v11; // rcx
unsigned __int64 v12; // rax

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

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


decompiled_code:
__int64 __fastcall string_countWords(_BYTE *a1)
{
unsigned int v1; // er8
__int64 v2; // rcx
__int64 v3; // rsi
unsigned __int64 v5; // r9
unsigned __int64 v6; // r10
unsigned __int64 v7; // rax

v1 = 0;
v2 = 0x100002600LL;
v3 = 0x100002601LL;
while ( *a1 )
{
v7 = (unsigned __int8)*a1;
if ( (_BYTE)v7 )
{
while ( 1 )
{
if ( (unsigned __int8)v7 > 0x20u )
goto LABEL_3;
if ( !_bittest64(&v2, v7) )
break;
v7 = (unsigned __int8)*++a1;
if ( !(_BYTE)v7 )
goto LABEL_5;
}
if ( !_bittest64(&v3, (unsigned int)v7) )
{
LABEL_3:
++v1;
++a1;
goto LABEL_5;
}
}
LABEL_5:
v5 = (unsigned __int8)*a1;
if ( (unsigned __int8)v5 > 0x20u || !_bittest64(&v3, v5) )
{
do
{
do
v6 = (unsigned __int8)*++a1;
while ( (unsigned __int8)v6 > 0x20u );
}
while ( !_bittest64(&v3, v6) );
}
}
return v1;
}

canonical_decompiled_code:
__int64 __fastcall func5(_BYTE *a1)
{
unsigned int v1; // er8
__int64 v2; // rcx
__int64 v3; // rsi
unsigned __int64 v5; // r9
unsigned __int64 v6; // r10
unsigned __int64 v7; // rax

v1 = 0;
v2 = 0x100002600LL;
v3 = 0x100002601LL;
while ( *a1 )
{
v7 = (unsigned __int8)*a1;
if ( (_BYTE)v7 )
{
while ( 1 )
{
if ( (unsigned __int8)v7 > 0x20u )
goto LABEL_3;
if ( !_bittest64(&v2, v7) )
break;
v7 = (unsigned __int8)*++a1;
if ( !(_BYTE)v7 )
goto LABEL_5;
}
if ( !_bittest64(&v3, (unsigned int)v7) )
{
LABEL_3:
++v1;
++a1;
goto LABEL_5;
}
}
LABEL_5:
v5 = (unsigned __int8)*a1;
if ( (unsigned __int8)v5 > 0x20u || !_bittest64(&v3, v5) )
{
do
{
do
v6 = (unsigned __int8)*++a1;
while ( (unsigned __int8)v6 > 0x20u );
}
while ( !_bittest64(&v3, v6) );
}
}
return v1;
}

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:
i
unsigned int

variable_types:
mystr
char *

return_type: unsigned int


getHash

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

v1 = *a1;
if ( *a1 )
{
v2 = 0;
do
{
v2 = v1 + 31 * v2;
v1 = *++a1;
}
while ( *a1 );
}
else
{
v2 = 0;
}
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

return_type: int


getHashCI

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 v4; // ebp
_QWORD *v5; // rax
_QWORD *v6; // rbx

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

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: id int

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;
}

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


findByNameRINT

decompiled_code:
__int64 __fastcall findByNameRINT(char *a1, __int64 a2)
{
__int64 v2; // rbx
__int64 result; // rax

v2 = a2 + 24LL * (int)getHash(a1);
if ( !*(_QWORD *)v2 )
return 0LL;
while ( 1 )
{
result = string_testEqual(*(_QWORD *)v2, a1);
if ( (_DWORD)result )
break;
v2 = *(_QWORD *)(v2 + 16);
if ( !v2 )
return result;
}
return *(unsigned int *)(v2 + 8);
}

canonical_decompiled_code:
__int64 __fastcall func4(char *a1, __int64 a2)
{
__int64 v2; // rbx
__int64 result; // rax

v2 = a2 + 24LL * (int)func0(a1);
if ( !*(_QWORD *)v2 )
return 0LL;
while ( 1 )
{
result = string_testEqual(*(_QWORD *)v2, a1);
if ( (_DWORD)result )
break;
v2 = *(_QWORD *)(v2 + 16);
if ( !v2 )
return result;
}
return *(unsigned int *)(v2 + 8);
}

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(_DWORD **a1, int a2)
{
_DWORD *v3; // rbp
__int64 v4; // rsi
unsigned int v5; // eax
__int64 v7[22]; // [rsp+0h] [rbp-C8h] BYREF
__int64 v8; // [rsp+B0h] [rbp-18h] BYREF

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

canonical_decompiled_code:
__int64 __fastcall func0(_DWORD **a1, int a2)
{
_DWORD *v3; // rbp
__int64 v4; // rsi
unsigned int v5; // eax
__int64 v7[22]; // [rsp+0h] [rbp-C8h] BYREF
__int64 v8; // [rsp+B0h] [rbp-18h] BYREF

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

return_type: void

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
__int64 v3; // r14
int result; // eax
int v5; // er12
__int64 v6; // rbp
int v7; // eax
int v8; // er12
__int64 v9; // rbx
int v10; // ebp
int v11; // er12

if ( a2 > 1 )
{
v2 = a1;
v3 = (__int64)&a1[7 * a2];
while ( 1 )
{
while ( 1 )
{
v6 = *v2;
v7 = pushDataToVertCache(8LL, 24LL, &bboxpfaces, *v2 + 12LL, 0LL, 0LL, 0LL, 0LL, 0LL);
v8 = v7;
if ( v7 >= 0 )
break;
puts("BAAAD");
*(_DWORD *)(v6 + 8) = v8;
result = pushDataToUBOCache(184LL, v6 + 108);
v5 = result;
if ( result < 0 )
goto LABEL_4;
LABEL_5:
*(_DWORD *)(v6 + 4) = v5;
*((_DWORD *)v2 + 9) = 1;
v2 += 7;
if ( v2 == (_QWORD *)v3 )
return result;
}
*(_DWORD *)(v6 + 8) = v7;
result = pushDataToUBOCache(184LL, v6 + 108);
v5 = result;
if ( result < 0 )
{
LABEL_4:
result = puts("BAAAD");
goto LABEL_5;
}
*(_DWORD *)(v6 + 4) = result;
*((_DWORD *)v2 + 9) = 1;
v2 += 7;
if ( (_QWORD *)v3 == v2 )
return result;
}
}
if ( a2 != 1 )
return puts("fuckyou");
v9 = *a1;
v10 = pushDataToVertCache(8LL, 24LL, &bboxpfaces, *a1 + 12LL, 0LL, 0LL, 0LL, 0LL, 0LL);
if ( v10 < 0 )
puts("BAAAD");
*(_DWORD *)(v9 + 8) = v10;
result = pushDataToUBOCache(184LL, v9 + 108);
v11 = result;
if ( result < 0 )
result = puts("BAAAD");
*(_DWORD *)(v9 + 4) = v11;
return result;
}

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

if ( a2 > 1 )
{
v2 = a1;
v3 = (__int64)&a1[7 * a2];
while ( 1 )
{
while ( 1 )
{
v6 = *v2;
v7 = pushDataToVertCache(8LL, 24LL, &bboxpfaces, *v2 + 12LL, 0LL, 0LL, 0LL, 0LL, 0LL);
v8 = v7;
if ( v7 >= 0 )
break;
puts("BAAAD");
*(_DWORD *)(v6 + 8) = v8;
result = pushDataToUBOCache(184LL, v6 + 108);
v5 = result;
if ( result < 0 )
goto LABEL_4;
LABEL_5:
*(_DWORD *)(v6 + 4) = v5;
*((_DWORD *)v2 + 9) = 1;
v2 += 7;
if ( v2 == (_QWORD *)v3 )
return result;
}
*(_DWORD *)(v6 + 8) = v7;
result = pushDataToUBOCache(184LL, v6 + 108);
v5 = result;
if ( result < 0 )
{
LABEL_4:
result = puts("BAAAD");
goto LABEL_5;
}
*(_DWORD *)(v6 + 4) = result;
*((_DWORD *)v2 + 9) = 1;
v2 += 7;
if ( (_QWORD *)v3 == v2 )
return result;
}
}
if ( a2 != 1 )
return puts("fuckyou");
v9 = *a1;
v10 = pushDataToVertCache(8LL, 24LL, &bboxpfaces, *a1 + 12LL, 0LL, 0LL, 0LL, 0LL, 0LL);
if ( v10 < 0 )
puts("BAAAD");
*(_DWORD *)(v9 + 8) = v10;
result = pushDataToUBOCache(184LL, v9 + 108);
v11 = result;
if ( result < 0 )
result = puts("BAAAD");
*(_DWORD *)(v9 + 4) = v11;
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: 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()
{
drawbbshaderid = shader_createAndAddRINT("wireframe");
drawbb_ok = 1;
return 1LL;
}

canonical_decompiled_code:
__int64 func2()
{
drawbbshaderid = shader_createAndAddRINT("wireframe");
drawbb_ok = 1;
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, __m128i a3, __m128i a4, float a5)
{
__int64 v5; // rax
unsigned int v7; // [rsp+10h] [rbp-138h]
char v8[64]; // [rsp+7Ch] [rbp-CCh] BYREF
int v9; // [rsp+BCh] [rbp-8Ch]
int v10; // [rsp+C0h] [rbp-88h]
float v11; // [rsp+C4h] [rbp-84h]
__int64 v12; // [rsp+D8h] [rbp-70h]
__m128 v13; // [rsp+E0h] [rbp-68h]
__int64 v14; // [rsp+F0h] [rbp-58h]
__int64 v15; // [rsp+F8h] [rbp-50h]
__int64 v16; // [rsp+100h] [rbp-48h]

v12 = 0LL;
v13 = 0uLL;
v14 = 0LL;
v15 = 0LL;
v16 = 0LL;
v5 = shader_returnById((unsigned int)drawbbshaderid);
v7 = *(_DWORD *)(shader_addPermutationToProgram(v5, 0LL) + 8);
Matrix4x4_ToArrayFloatGL(a1 + 196, v8);
v9 = _mm_cvtsi128_si32(a3);
v10 = _mm_cvtsi128_si32(a4);
v11 = a5;
LOBYTE(v15) = v7 != 0;
BYTE1(v15) = v7 >> 8 != 0;
BYTE2(v15) = HIWORD(v7) != 0;
BYTE3(v15) = HIBYTE(v7) != 0;
v13 = _mm_loadh_ps((const double *)&LC5);
LODWORD(v12) = 184;
LOBYTE(v14) = 6;
addRenderlistitem(a2, HIWORD(v7), HIBYTE(v7), v7 >> 8);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, __int64 a2, __m128i a3, __m128i a4, float a5)
{
__int64 v5; // rax
unsigned int v7; // [rsp+10h] [rbp-138h]
char v8[64]; // [rsp+7Ch] [rbp-CCh] BYREF
int v9; // [rsp+BCh] [rbp-8Ch]
int v10; // [rsp+C0h] [rbp-88h]
float v11; // [rsp+C4h] [rbp-84h]
__int64 v12; // [rsp+D8h] [rbp-70h]
__m128 v13; // [rsp+E0h] [rbp-68h]
__int64 v14; // [rsp+F0h] [rbp-58h]
__int64 v15; // [rsp+F8h] [rbp-50h]
__int64 v16; // [rsp+100h] [rbp-48h]

v12 = 0LL;
v13 = 0uLL;
v14 = 0LL;
v15 = 0LL;
v16 = 0LL;
v5 = shader_returnById((unsigned int)drawbbshaderid);
v7 = *(_DWORD *)(shader_addPermutationToProgram(v5, 0LL) + 8);
Matrix4x4_ToArrayFloatGL(a1 + 196, v8);
v9 = _mm_cvtsi128_si32(a3);
v10 = _mm_cvtsi128_si32(a4);
v11 = a5;
LOBYTE(v15) = v7 != 0;
BYTE1(v15) = v7 >> 8 != 0;
BYTE2(v15) = HIWORD(v7) != 0;
BYTE3(v15) = HIBYTE(v7) != 0;
v13 = _mm_loadh_ps((const double *)&LC5);
LODWORD(v12) = 184;
LOBYTE(v14) = 6;
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 i; // ebp
int v5; // ebx
int v6; // ebx

if ( (unsigned int)sdlInit(1366LL, 768LL, 24LL, 1LL) && (unsigned int)glInit() )
{
for ( i = SDL_GetTicks(); ; i = v6 )
{
v5 = 1000;
do
{
sdlCheckEvent();
glRender();
--v5;
}
while ( v5 );
v6 = SDL_GetTicks();
printf("%f fps \n", (float)(1000000.0 / (float)(v6 - i)));
}
}
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)
{
unsigned int v8; // er15
size_t v9; // rbx
char *v10; // rax
char *v11; // rbx

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

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, int a2, int a3, int a4, int a5, char a6)
{
unsigned int v8; // er15
size_t v9; // rbx
char *v10; // rax
char *v11; // rbx

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

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; // rbx

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; // rbx

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;
}


findFrameBufferByName

decompiled_code:
__int64 __fastcall findFrameBufferByName(char *s1)
{
int v1; // er13
const char **v2; // rbx
unsigned int v3; // ebp

v1 = fbnumber;
if ( fbnumber <= 0 )
return 0;
v2 = (const char **)((char *)fblist + 8);
v3 = 0;
while ( strcmp(s1, *v2) )
{
++v3;
v2 += 5;
if ( v3 == v1 )
return 0;
}
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func2(char *s1)
{
int v1; // er13
const char **v2; // rbx
unsigned int v3; // ebp

v1 = fbnumber;
if ( fbnumber <= 0 )
return 0;
v2 = (const char **)((char *)fblist + 8);
v3 = 0;
while ( strcmp(s1, *v2) )
{
++v3;
v2 += 5;
if ( v3 == v1 )
return 0;
}
return v3;
}

original_code:
int findFrameBufferByName(char * name){
 int i;
 for(i = 0; i<fbnumber; i++){
  if(!strcmp(name, fblist[i].name)) return i;
 }
 return 0;
}

canonical_original_code:
int findFrameBufferByName(char *name){
 int i;
 for(i = 0; i<fbnumber; i++){
  if(!strcmp(name, fblist[i].name)) return i;
 }
 return 0;
}


resizeFrameBuffer

decompiled_code:
__int64 __fastcall resizeFrameBuffer(unsigned int a1, int a2, int a3)
{
__int64 v4; // rbx
char *v5; // rax

v4 = 40LL * a1;
glBindTexture(3553LL, *(unsigned int *)((char *)fblist + v4 + 32));
glTexImage2D(3553LL, 0LL, 6407LL, (unsigned int)a2, (unsigned int)a3, 0LL, 6407LL, 5121LL, 0LL);
glBindTexture(3553LL, 0LL);
v5 = (char *)fblist + v4;
*((_DWORD *)v5 + 4) = a2;
*((_DWORD *)v5 + 5) = a3;
*((float *)v5 + 6) = (float)a2 / (float)a3;
return a1;
}

canonical_decompiled_code:
__int64 __fastcall func3(unsigned int a1, int a2, int a3)
{
__int64 v4; // rbx
char *v5; // rax

v4 = 40LL * a1;
glBindTexture(3553LL, *(unsigned int *)((char *)fblist + v4 + 32));
glTexImage2D(3553LL, 0LL, 6407LL, (unsigned int)a2, (unsigned int)a3, 0LL, 6407LL, 5121LL, 0LL);
glBindTexture(3553LL, 0LL);
v5 = (char *)fblist + v4;
*((_DWORD *)v5 + 4) = a2;
*((_DWORD *)v5 + 5) = a3;
*((float *)v5 + 6) = (float)a2 / (float)a3;
return a1;
}

original_code:
int resizeFrameBuffer(GLuint id, GLuint width, GLuint height){
 glBindTexture(0x0DE1, fblist[id].texid);
  glTexImage2D(0x0DE1, 0 , 0x1907, width, height, 0, 0x1907, 0x1401, ((void *)0));
 glBindTexture(0x0DE1, 0);
 fblist[id].width = width;
 fblist[id].height = height;
 fblist[id].aspect = (float)width/(float)height;
 return id;
}

canonical_original_code:
int resizeFrameBuffer(unsigned int id, unsigned int width, unsigned int height){
 glBindTexture(0x0DE1, fblist[id].texid);
  glTexImage2D(0x0DE1, 0 , 0x1907, width, height, 0, 0x1907, 0x1401, ((void *)0));
 glBindTexture(0x0DE1, 0);
 fblist[id].width = width;
 fblist[id].height = height;
 fblist[id].aspect = (float)width/(float)height;
 return id;
}


createFrameBuffersAndTextures

decompiled_code:
__int64 __fastcall createFrameBuffersAndTextures(unsigned int a1, unsigned int a2)
{
__int64 result; // rax
int v3; // [rsp+0h] [rbp-28h] BYREF
int v4; // [rsp+4h] [rbp-24h] BYREF
unsigned int v5; // [rsp+8h] [rbp-20h] BYREF
unsigned int v6[7]; // [rsp+Ch] [rbp-1Ch] BYREF

if ( a1 && a2 )
{
glGenTextures(1LL, v6);
glGenTextures(1LL, &v5);
if ( v6[0] && v5 )
{
glBindTexture(3553LL, v5);
glTexImage2D(3553LL, 0LL, 6408LL, a1, a2, 0LL, 6408LL, 5126LL, 0LL);
glTexParameteri(3553LL, 10241LL, 9728LL);
glTexParameteri(3553LL, 10240LL, 9728LL);
glTexParameteri(3553LL, 10242LL, 33071LL);
glTexParameteri(3553LL, 10243LL, 33071LL);
glBindTexture(3553LL, v6[0]);
glTexImage2D(3553LL, 0LL, 6408LL, a1, a2, 0LL, 6408LL, 5126LL, 0LL);
glTexParameteri(3553LL, 10241LL, 9728LL);
glTexParameteri(3553LL, 10240LL, 9728LL);
glTexParameteri(3553LL, 10242LL, 33071LL);
glTexParameteri(3553LL, 10243LL, 33071LL);
glBindTexture(3553LL, 0LL);
_glewGenFramebuffers(1LL, &v4);
_glewGenFramebuffers(1LL, &v3);
if ( v4 && v3 )
{
_glewBindFramebuffer(36160LL);
_glewFramebufferTexture2D(36160LL, 36064LL, 3553LL, v5, 0LL);
glClear(16640LL);
_glewBindFramebuffer(36160LL);
_glewFramebufferTexture2D(36160LL, 36064LL, 3553LL, v6[0], 0LL);
glClear(16640LL);
_glewBindFramebuffer(36160LL);
addFrameBufferToList((__int64)"vel", v4, a1, a2, v6[0], 1);
addFrameBufferToList((__int64)"pos", v3, a1, a2, v5, 1);
result = 1LL;
}
else
{
printf("Error creating framebuffers");
result = 0LL;
}
}
else
{
printf("Error creating textures");
result = 0LL;
}
}
else
{
printf("Error, width and height have to be > 0");
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(unsigned int a1, unsigned int a2)
{
__int64 result; // rax
int v3; // [rsp+0h] [rbp-28h] BYREF
int v4; // [rsp+4h] [rbp-24h] BYREF
unsigned int v5; // [rsp+8h] [rbp-20h] BYREF
unsigned int v6[7]; // [rsp+Ch] [rbp-1Ch] BYREF

if ( a1 && a2 )
{
glGenTextures(1LL, v6);
glGenTextures(1LL, &v5);
if ( v6[0] && v5 )
{
glBindTexture(3553LL, v5);
glTexImage2D(3553LL, 0LL, 6408LL, a1, a2, 0LL, 6408LL, 5126LL, 0LL);
glTexParameteri(3553LL, 10241LL, 9728LL);
glTexParameteri(3553LL, 10240LL, 9728LL);
glTexParameteri(3553LL, 10242LL, 33071LL);
glTexParameteri(3553LL, 10243LL, 33071LL);
glBindTexture(3553LL, v6[0]);
glTexImage2D(3553LL, 0LL, 6408LL, a1, a2, 0LL, 6408LL, 5126LL, 0LL);
glTexParameteri(3553LL, 10241LL, 9728LL);
glTexParameteri(3553LL, 10240LL, 9728LL);
glTexParameteri(3553LL, 10242LL, 33071LL);
glTexParameteri(3553LL, 10243LL, 33071LL);
glBindTexture(3553LL, 0LL);
_glewGenFramebuffers(1LL, &v4);
_glewGenFramebuffers(1LL, &v3);
if ( v4 && v3 )
{
_glewBindFramebuffer(36160LL);
_glewFramebufferTexture2D(36160LL, 36064LL, 3553LL, v5, 0LL);
glClear(16640LL);
_glewBindFramebuffer(36160LL);
_glewFramebufferTexture2D(36160LL, 36064LL, 3553LL, v6[0], 0LL);
glClear(16640LL);
_glewBindFramebuffer(36160LL);
func0((__int64)"vel", v4, a1, a2, v6[0], 1);
func0((__int64)"pos", v3, a1, a2, v5, 1);
result = 1LL;
}
else
{
printf("Error creating framebuffers");
result = 0LL;
}
}
else
{
printf("Error creating textures");
result = 0LL;
}
}
else
{
printf("Error, width and height have to be > 0");
result = 0LL;
}
return result;
}

original_code:
int createFrameBuffersAndTextures(int width, int height){
 GLuint velTexid, posTexid ;
 GLuint velFBOid, posFBOid;
 if (!width||!height){
  printf("Error, width and height have to be > 0");
  return 0;
 }
 glGenTextures(1, &velTexid);
 glGenTextures(1, &posTexid);
 if (!velTexid||!posTexid){
  printf("Error creating textures");
  return 0;
 }
 glBindTexture(0x0DE1, posTexid);
  glTexImage2D(0x0DE1, 0 , 0x1908, width, height, 0 , 0x1908, 0x1406, ((void *)0));
  glTexParameteri(0x0DE1, 0x2801, 0x2600);
  glTexParameteri(0x0DE1, 0x2800, 0x2600);
  glTexParameteri(0x0DE1, 0x2802, 0x812F);
  glTexParameteri(0x0DE1, 0x2803, 0x812F);
 glBindTexture(0x0DE1, velTexid);
  glTexImage2D(0x0DE1, 0 , 0x1908, width, height, 0 , 0x1908, 0x1406, ((void *)0));
  glTexParameteri(0x0DE1, 0x2801, 0x2600);
  glTexParameteri(0x0DE1, 0x2800, 0x2600);
  glTexParameteri(0x0DE1, 0x2802, 0x812F);
  glTexParameteri(0x0DE1, 0x2803, 0x812F);
 glBindTexture(0x0DE1, 0);
 __glewGenFramebuffers(1, &velFBOid);
 __glewGenFramebuffers(1, &posFBOid);
 if (!velFBOid||!posFBOid){
  printf("Error creating framebuffers");
  return 0;
 }
 __glewBindFramebuffer(0x8D40, posFBOid);
  __glewFramebufferTexture2D(0x8D40, 0x8CE0,0x0DE1, posTexid, 0);
  glClear(0x00004000| 0x00000100);
 __glewBindFramebuffer(0x8D40, velFBOid);
  __glewFramebufferTexture2D(0x8D40, 0x8CE0,0x0DE1, velTexid, 0);
  glClear(0x00004000| 0x00000100);
 __glewBindFramebuffer(0x8D40, 0);
 addFrameBufferToList("vel", velFBOid, width, height, velTexid, (char)1);
 addFrameBufferToList("pos", posFBOid, width, height, posTexid, (char)1);
 return 1;
}

canonical_original_code:
int createFrameBuffersAndTextures(int width, int height){
 unsigned int velTexid; unsigned int posTexid;
 unsigned int velFBOid; unsigned int posFBOid;
 if (!width||!height){
  printf("Error, width and height have to be > 0");
  return 0;
 }
 glGenTextures(1, &velTexid);
 glGenTextures(1, &posTexid);
 if (!velTexid||!posTexid){
  printf("Error creating textures");
  return 0;
 }
 glBindTexture(0x0DE1, posTexid);
  glTexImage2D(0x0DE1, 0 , 0x1908, width, height, 0 , 0x1908, 0x1406, ((void *)0));
  glTexParameteri(0x0DE1, 0x2801, 0x2600);
  glTexParameteri(0x0DE1, 0x2800, 0x2600);
  glTexParameteri(0x0DE1, 0x2802, 0x812F);
  glTexParameteri(0x0DE1, 0x2803, 0x812F);
 glBindTexture(0x0DE1, velTexid);
  glTexImage2D(0x0DE1, 0 , 0x1908, width, height, 0 , 0x1908, 0x1406, ((void *)0));
  glTexParameteri(0x0DE1, 0x2801, 0x2600);
  glTexParameteri(0x0DE1, 0x2800, 0x2600);
  glTexParameteri(0x0DE1, 0x2802, 0x812F);
  glTexParameteri(0x0DE1, 0x2803, 0x812F);
 glBindTexture(0x0DE1, 0);
 __glewGenFramebuffers(1, &velFBOid);
 __glewGenFramebuffers(1, &posFBOid);
 if (!velFBOid||!posFBOid){
  printf("Error creating framebuffers");
  return 0;
 }
 __glewBindFramebuffer(0x8D40, posFBOid);
  __glewFramebufferTexture2D(0x8D40, 0x8CE0,0x0DE1, posTexid, 0);
  glClear(0x00004000| 0x00000100);
 __glewBindFramebuffer(0x8D40, velFBOid);
  __glewFramebufferTexture2D(0x8D40, 0x8CE0,0x0DE1, velTexid, 0);
  glClear(0x00004000| 0x00000100);
 __glewBindFramebuffer(0x8D40, 0);
 addFrameBufferToList("vel", velFBOid, width, height, velTexid, (char)1);
 addFrameBufferToList("pos", posFBOid, width, height, posTexid, (char)1);
 return 1;
}

variable_types: width int

variable_types: height int

variable_types:
velTexid
unsigned int

variable_types:
posTexid
unsigned int

variable_types:
velFBOid
unsigned int

variable_types:
posFBOid
unsigned int


gamecodeTick

decompiled_code:
__int64 gamecodeTick()
{
return 1LL;
}

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

original_code:
int gamecodeTick(void){
 return 1;
}

canonical_original_code:
int gamecodeTick(){
 return 1;
}


gamecodeHandleKeyPress

decompiled_code:
__int64 __fastcall gamecodeHandleKeyPress(__int64 a1, int a2)
{
unsigned int v2; // eax

v2 = *(_DWORD *)(a1 + 4);
if ( v2 > 0x77 )
{
if ( v2 == 303 )
{
if ( a2 )
controllkeys |= 0x32u;
else
controllkeys &= 0xCDu;
}
}
else if ( v2 <= 0x60 )
{
if ( v2 == 27 )
exit(1);
if ( v2 == 32 )
{
if ( a2 )
controllkeys |= 0x16u;
else
controllkeys &= 0xE9u;
}
}
else
{
switch ( v2 )
{
case 'a':
if ( a2 )
controllkeys |= 2u;
else
controllkeys &= 0xFDu;
break;
case 'd':
if ( a2 )
controllkeys |= 8u;
else
controllkeys &= 0xF7u;
break;
case 'e':
if ( a2 )
controllkeys |= 0x28u;
else
controllkeys &= 0xD7u;
break;
case 'q':
if ( a2 )
controllkeys |= 0x64u;
else
controllkeys &= 0x9Bu;
break;
case 's':
if ( a2 )
controllkeys |= 4u;
else
controllkeys &= 0xFBu;
break;
case 'w':
if ( a2 )
controllkeys |= 1u;
else
controllkeys &= 0xFEu;
break;
default:
return 1LL;
}
}
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, int a2)
{
unsigned int v2; // eax

v2 = *(_DWORD *)(a1 + 4);
if ( v2 > 0x77 )
{
if ( v2 == 303 )
{
if ( a2 )
controllkeys |= 0x32u;
else
controllkeys &= 0xCDu;
}
}
else if ( v2 <= 0x60 )
{
if ( v2 == 27 )
exit(1);
if ( v2 == 32 )
{
if ( a2 )
controllkeys |= 0x16u;
else
controllkeys &= 0xE9u;
}
}
else
{
switch ( v2 )
{
case 'a':
if ( a2 )
controllkeys |= 2u;
else
controllkeys &= 0xFDu;
break;
case 'd':
if ( a2 )
controllkeys |= 8u;
else
controllkeys &= 0xF7u;
break;
case 'e':
if ( a2 )
controllkeys |= 0x28u;
else
controllkeys &= 0xD7u;
break;
case 'q':
if ( a2 )
controllkeys |= 0x64u;
else
controllkeys &= 0x9Bu;
break;
case 's':
if ( a2 )
controllkeys |= 4u;
else
controllkeys &= 0xFBu;
break;
case 'w':
if ( a2 )
controllkeys |= 1u;
else
controllkeys &= 0xFEu;
break;
default:
return 1LL;
}
}
return 1LL;
}

original_code:
int gamecodeHandleKeyPress(SDL_keysym * keysym, int type){
 switch(keysym ->sym){
  case SDLK_ESCAPE:
   exit(1);
  break;
  case SDLK_w:
   if(type)controllkeys = controllkeys | 0x1;
   else controllkeys = controllkeys & (~0x1);
  break;
  case SDLK_a:
   if(type)controllkeys = controllkeys | 0x2;
   else controllkeys = controllkeys & (~0x2);
  break;
  case SDLK_s:
   if(type)controllkeys = controllkeys | 0x4;
   else controllkeys = controllkeys & (~0x4);
  break;
  case SDLK_d:
   if(type)controllkeys = controllkeys | 0x8;
   else controllkeys = controllkeys & (~0x8);
  break;
  case SDLK_SPACE:
   if(type)controllkeys = controllkeys | 0x16;
   else controllkeys = controllkeys & (~0x16);
  break;
  case SDLK_RSHIFT:
   if(type)controllkeys = controllkeys | 0x32;
   else controllkeys = controllkeys & (~0x32);
  break;
  case SDLK_q:
   if(type)controllkeys = controllkeys | 0x64;
   else controllkeys = controllkeys & (~0x64);
  break;
  case SDLK_e:
   if(type)controllkeys = controllkeys | 0x128;
   else controllkeys = controllkeys & (~0x128);
  break;
  default:
  break;
 }
 return 1;
}

canonical_original_code:
int gamecodeHandleKeyPress(struct SDL_keysym *keysym, int type){
 switch(keysym ->sym){
  case SDLK_ESCAPE:
   exit(1);
  break;
  case SDLK_w:
   if(type)controllkeys = controllkeys | 0x1;
   else controllkeys = controllkeys & (~0x1);
  break;
  case SDLK_a:
   if(type)controllkeys = controllkeys | 0x2;
   else controllkeys = controllkeys & (~0x2);
  break;
  case SDLK_s:
   if(type)controllkeys = controllkeys | 0x4;
   else controllkeys = controllkeys & (~0x4);
  break;
  case SDLK_d:
   if(type)controllkeys = controllkeys | 0x8;
   else controllkeys = controllkeys & (~0x8);
  break;
  case SDLK_SPACE:
   if(type)controllkeys = controllkeys | 0x16;
   else controllkeys = controllkeys & (~0x16);
  break;
  case SDLK_RSHIFT:
   if(type)controllkeys = controllkeys | 0x32;
   else controllkeys = controllkeys & (~0x32);
  break;
  case SDLK_q:
   if(type)controllkeys = controllkeys | 0x64;
   else controllkeys = controllkeys & (~0x64);
  break;
  case SDLK_e:
   if(type)controllkeys = controllkeys | 0x128;
   else controllkeys = controllkeys & (~0x128);
  break;
  default:
  break;
 }
 return 1;
}

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

variable_types: type int

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


gamecodeHandleMouseMove

decompiled_code:
__int64 __fastcall gamecodeHandleMouseMove(int a1, int a2)
{
double v2; // xmm2_8
double v3; // xmm0_8

campos[0] = LC0;
campos[1] = LC0;
campos[2] = LC0;
v2 = (double)a1 + camangle[2];
camangle[2] = v2;
v3 = (double)a2 + camangle[0];
camangle[0] = v3;
if ( v3 <= 90.0 )
{
if ( v3 < -90.0 )
*(_QWORD *)&camangle[0] = LC2;
}
else
{
*(_QWORD *)&camangle[0] = LC1;
}
camangle[2] = fmod(v2, 360.0);
updateCameraViewMatrix(campos, camangle);
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func2(int a1, int a2)
{
double v2; // xmm2_8
double v3; // xmm0_8

campos[0] = LC0;
campos[1] = LC0;
campos[2] = LC0;
v2 = (double)a1 + camangle[2];
camangle[2] = v2;
v3 = (double)a2 + camangle[0];
camangle[0] = v3;
if ( v3 <= 90.0 )
{
if ( v3 < -90.0 )
*(_QWORD *)&camangle[0] = LC2;
}
else
{
*(_QWORD *)&camangle[0] = LC1;
}
camangle[2] = fmod(v2, 360.0);
updateCameraViewMatrix(campos, camangle);
return 1LL;
}

original_code:
int gamecodeHandleMouseMove(int xrel, int yrel){
 campos[0] = 1.0;
 campos[1] = 1.0;
 campos[2] = 1.0;
 camangle[2] += xrel;
 camangle[0] += yrel;
 if(camangle[0] > 90) camangle[0] = 90.0;
 if(camangle[0] < -90) camangle[0] = -90.0;
 camangle[2] = fmod(camangle[2], 360.0);
 updateCameraViewMatrix(campos, camangle);
 return 1;
}

variable_types: xrel int

variable_types: yrel int


gamecodeHandleMousePress

decompiled_code:
__int64 gamecodeHandleMousePress()
{
return 1LL;
}

canonical_decompiled_code:
__int64 func3()
{
return 1LL;
}

original_code:
int gamecodeHandleMousePress(int button, int type){
 return 1;
}

variable_types: button int


resizeWindow

decompiled_code:
__int64 __fastcall resizeWindow(int a1, int a2, unsigned int a3, int a4)
{
unsigned int v4; // ebx
unsigned int v5; // ebp
__int64 result; // rax
const char *v8; // rax

v4 = a1;
v5 = a2;
if ( a4 )
printf("DEBUG -- SDL video resize to: %ix%i with %i bits per pixel \n", (unsigned int)a1, (unsigned int)a2, a3);
if ( a2 <= 0 )
v5 = 1;
if ( a1 <= 0 )
v4 = 1;
surface = SDL_SetVideoMode(v4, v5, a3, (unsigned int)videoFlags);
if ( surface )
{
updateScreenSize(v4, v5);
result = 1LL;
}
else
{
v8 = (const char *)SDL_GetError();
fprintf(stderr, "ERROR -- SDL video resize failed: %s \n", v8);
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(int a1, int a2, unsigned int a3, int a4)
{
unsigned int v4; // ebx
unsigned int v5; // ebp
__int64 result; // rax
const char *v8; // rax

v4 = a1;
v5 = a2;
if ( a4 )
printf("DEBUG -- SDL video resize to: %ix%i with %i bits per pixel \n", (unsigned int)a1, (unsigned int)a2, a3);
if ( a2 <= 0 )
v5 = 1;
if ( a1 <= 0 )
v4 = 1;
surface = SDL_SetVideoMode(v4, v5, a3, (unsigned int)videoFlags);
if ( surface )
{
updateScreenSize(v4, v5);
result = 1LL;
}
else
{
v8 = (const char *)SDL_GetError();
fprintf(stderr, "ERROR -- SDL video resize failed: %s \n", v8);
result = 0LL;
}
return result;
}

original_code:
int resizeWindow(int width, int height, int bpp, int debugmode){
 if(debugmode) printf("DEBUG -- SDL video resize to: %ix%i with %i bits per pixel \n", width, height, bpp);
 if(height<1) height = 1;
 if(width<1) width = 1;
 surface = SDL_SetVideoMode(width, height, bpp, videoFlags);
 if(!surface){
  fprintf(stderr, "ERROR -- SDL video resize failed: %s \n", SDL_GetError());
  return 0;
 }
 updateScreenSize(width, height);
 return 1;
}

variable_types: bpp int

variable_types: debugmode int


swapBuffers

decompiled_code:
__int64 swapBuffers()
{
return SDL_GL_SwapBuffers();
}

canonical_decompiled_code:
__int64 func1()
{
return SDL_GL_SwapBuffers();
}

original_code:
void swapBuffers(void){
 SDL_GL_SwapBuffers();
}

canonical_original_code:
void swapBuffers(){
 SDL_GL_SwapBuffers();
}


sdlInit

decompiled_code:
__int64 __fastcall sdlInit(int a1, int a2, unsigned int a3, int a4)
{
int v6; // eax
__int64 result; // rax
const char *v8; // rax

if ( a4 )
puts("DEBUG -- SDL window initializing ");
if ( (int)SDL_Init(32LL) < 0 )
{
v8 = (const char *)SDL_GetError();
fprintf(stderr, "ERROR -- SDL video init failed: %s \n", v8);
result = 0LL;
}
else
{
videoInfo = SDL_GetVideoInfo();
videoFlags = 536870935;
v6 = -((*(_BYTE *)(videoInfo + 1) & 2) == 0);
LOBYTE(v6) = 0;
videoFlags = v6 + 536871191;
SDL_GL_SetAttribute(5LL, 1LL);
SDL_GL_SetAttribute(13LL, 1LL);
SDL_GL_SetAttribute(14LL, 16LL);
result = resizeWindow(a1, a2, a3, a4);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(int a1, int a2, unsigned int a3, int a4)
{
int v6; // eax
__int64 result; // rax
const char *v8; // rax

if ( a4 )
puts("DEBUG -- SDL window initializing ");
if ( (int)SDL_Init(32LL) < 0 )
{
v8 = (const char *)SDL_GetError();
fprintf(stderr, "ERROR -- SDL video init failed: %s \n", v8);
result = 0LL;
}
else
{
videoInfo = SDL_GetVideoInfo();
videoFlags = 536870935;
v6 = -((*(_BYTE *)(videoInfo + 1) & 2) == 0);
LOBYTE(v6) = 0;
videoFlags = v6 + 536871191;
SDL_GL_SetAttribute(5LL, 1LL);
SDL_GL_SetAttribute(13LL, 1LL);
SDL_GL_SetAttribute(14LL, 16LL);
result = func0(a1, a2, a3, a4);
}
return result;
}

original_code:
int sdlInit(int width, int height, int bpp, int debugmode){
 if(debugmode) printf("DEBUG -- SDL window initializing \n");
 if(SDL_Init(0x00000020)<0){
  fprintf(stderr, "ERROR -- SDL video init failed: %s \n", SDL_GetError());
  return 0;
 }
 videoInfo = SDL_GetVideoInfo();
 videoFlags = 0x00000002;
 videoFlags |= SDL_GL_DOUBLEBUFFER;
 videoFlags |= 0x20000000;
 videoFlags |= 0x00000010;
 if(videoInfo->hw_available) videoFlags |= 0x00000001;
 else videoFlags |= 0x00000000;
 if(videoInfo->blit_hw) videoFlags |= 0x00000100;
 SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
  SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1);
  SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 16);
 return resizeWindow(width, height, bpp, debugmode);
}


sdlToggleMouseGrab

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

if ( (unsigned int)SDL_WM_GrabInput(0xFFFFFFFFLL) )
{
SDL_WM_GrabInput(0LL);
SDL_ShowCursor(1LL);
result = 0LL;
}
else
{
SDL_WM_GrabInput(1LL);
SDL_ShowCursor(0LL);
result = 1LL;
}
return result;
}

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

if ( (unsigned int)SDL_WM_GrabInput(0xFFFFFFFFLL) )
{
SDL_WM_GrabInput(0LL);
SDL_ShowCursor(1LL);
result = 0LL;
}
else
{
SDL_WM_GrabInput(1LL);
SDL_ShowCursor(0LL);
result = 1LL;
}
return result;
}

original_code:
int sdlToggleMouseGrab(void){
 if(SDL_WM_GrabInput(SDL_GRAB_QUERY) == SDL_GRAB_OFF){
  SDL_WM_GrabInput(SDL_GRAB_ON);
  SDL_ShowCursor(0);
  return 1;
 } else {
  SDL_WM_GrabInput(SDL_GRAB_OFF);
  SDL_ShowCursor(1);
  return 0;
 }
}

canonical_original_code:
int sdlToggleMouseGrab(){
 if(SDL_WM_GrabInput(SDL_GRAB_QUERY) == SDL_GRAB_OFF){
  SDL_WM_GrabInput(SDL_GRAB_ON);
  SDL_ShowCursor(0);
  return 1;
 } else {
  SDL_WM_GrabInput(SDL_GRAB_OFF);
  SDL_ShowCursor(1);
  return 0;
 }
}


sdlSetMouseGrab

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

if ( a1 )
{
SDL_WM_GrabInput(1LL);
result = SDL_ShowCursor(0LL);
}
else
{
SDL_WM_GrabInput(0LL);
result = SDL_ShowCursor(1LL);
}
return result;
}

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

if ( a1 )
{
SDL_WM_GrabInput(1LL);
result = SDL_ShowCursor(0LL);
}
else
{
SDL_WM_GrabInput(0LL);
result = SDL_ShowCursor(1LL);
}
return result;
}

original_code:
void sdlSetMouseGrab(int grab){
 if(grab){
  SDL_WM_GrabInput(SDL_GRAB_ON);
  SDL_ShowCursor(0);
 } else {
  SDL_WM_GrabInput(SDL_GRAB_OFF);
  SDL_ShowCursor(1);
 }
}

variable_types: grab int


glVBO

decompiled_code:
__int64 glVBO()
{
char *v0; // rbx
char *v1; // rsi
int i; // ecx
char *v3; // rax
int j; // edx

_glewGenVertexArrays(1LL, &vaoID);
_glewGenVertexArrays(1LL, &vaostarID);
_glewGenBuffers(1LL, &vboID);
_glewGenBuffers(1LL, &indicesID);
_glewGenBuffers(1LL, &starID);
_glewBindVertexArray((unsigned int)vaostarID);
v0 = (char *)malloc(0x140000uLL);
memset(v0, 0, 0x140000uLL);
v1 = v0;
for ( i = 0; i != 256; ++i )
{
v3 = v1;
for ( j = 0; j != 256; ++j )
{
*(_DWORD *)v3 = 0;
*((_DWORD *)v3 + 1) = 0;
*((_DWORD *)v3 + 2) = 0;
*((float *)v3 + 3) = (float)i * 0.00390625;
*((float *)v3 + 4) = (float)j * 0.00390625;
v3 += 20;
}
v1 += 5120;
}
_glewBindBuffer(34962LL, (unsigned int)starID);
_glewBufferData(34962LL, 1310720LL, v0, 35044LL);
glEnableClientState(32884LL);
glVertexPointer(3LL, 5126LL, 20LL, 0LL);
glEnableClientState(32888LL);
glTexCoordPointer(2LL, 5126LL, 20LL, 12LL);
free(v0);
_glewBindVertexArray((unsigned int)vaoID);
_glewBindBuffer(34962LL, (unsigned int)vboID);
_glewBufferData(34962LL, 64LL, &fsverts, 35044LL);
glEnableClientState(32884LL);
glVertexPointer(2LL, 5126LL, 16LL, 0LL);
glEnableClientState(32888LL);
glTexCoordPointer(2LL, 5126LL, 16LL, 8LL);
_glewBindBuffer(34963LL, (unsigned int)indicesID);
_glewBufferData(34963LL, 24LL, &fsindices, 35044LL);
return 1LL;
}

canonical_decompiled_code:
__int64 func0()
{
char *v0; // rbx
char *v1; // rsi
int i; // ecx
char *v3; // rax
int j; // edx

_glewGenVertexArrays(1LL, &vaoID);
_glewGenVertexArrays(1LL, &vaostarID);
_glewGenBuffers(1LL, &vboID);
_glewGenBuffers(1LL, &indicesID);
_glewGenBuffers(1LL, &starID);
_glewBindVertexArray((unsigned int)vaostarID);
v0 = (char *)malloc(0x140000uLL);
memset(v0, 0, 0x140000uLL);
v1 = v0;
for ( i = 0; i != 256; ++i )
{
v3 = v1;
for ( j = 0; j != 256; ++j )
{
*(_DWORD *)v3 = 0;
*((_DWORD *)v3 + 1) = 0;
*((_DWORD *)v3 + 2) = 0;
*((float *)v3 + 3) = (float)i * 0.00390625;
*((float *)v3 + 4) = (float)j * 0.00390625;
v3 += 20;
}
v1 += 5120;
}
_glewBindBuffer(34962LL, (unsigned int)starID);
_glewBufferData(34962LL, 1310720LL, v0, 35044LL);
glEnableClientState(32884LL);
glVertexPointer(3LL, 5126LL, 20LL, 0LL);
glEnableClientState(32888LL);
glTexCoordPointer(2LL, 5126LL, 20LL, 12LL);
free(v0);
_glewBindVertexArray((unsigned int)vaoID);
_glewBindBuffer(34962LL, (unsigned int)vboID);
_glewBufferData(34962LL, 64LL, &fsverts, 35044LL);
glEnableClientState(32884LL);
glVertexPointer(2LL, 5126LL, 16LL, 0LL);
glEnableClientState(32888LL);
glTexCoordPointer(2LL, 5126LL, 16LL, 8LL);
_glewBindBuffer(34963LL, (unsigned int)indicesID);
_glewBufferData(34963LL, 24LL, &fsindices, 35044LL);
return 1LL;
}

original_code:
int glVBO(void){
 __glewGenVertexArrays(1, &vaoID);
 __glewGenVertexArrays(1, &vaostarID);
 __glewGenBuffers(1, &vboID);
 __glewGenBuffers(1, &indicesID);
 __glewGenBuffers(1, &starID);
 __glewBindVertexArray(vaostarID);
 GLfloat *starverts;
 starverts = malloc(5*256*256*sizeof(GLfloat));
 memset(starverts, 0, 5*256*256*sizeof(GLfloat));
 int x, y, i;
 for(x = 0; x< 256; x++){
  for(y = 0; y< 256; y++){
   i = (x*256 + y)*5;
   starverts[i] = 0.0;
   starverts[i+1] = 0.0;
   starverts[i+2] = 0.0;
   starverts[i+3] = (float)x/(float)256;
   starverts[i+4] = (float)y/(float)256;
  }
 }
 __glewBindBuffer(0x8892, starID);
 __glewBufferData(0x8892, 5*256*256*sizeof(GLfloat), starverts, 0x88E4);
 glEnableClientState(0x8074);
 glVertexPointer(3, 0x1406, 5*sizeof(GLfloat), ((void *)0));
 glEnableClientState(0x8078);
 glTexCoordPointer(2, 0x1406, 5*sizeof(GLfloat), ((char*)((void *)0)) + 3*sizeof(GLfloat));
 free(starverts);
 __glewBindVertexArray(vaoID);
 __glewBindBuffer(0x8892, vboID);
 __glewBufferData(0x8892, sizeof(fsverts), fsverts, 0x88E4);
 glEnableClientState(0x8074);
 glVertexPointer(2, 0x1406, 4*sizeof(GLfloat), ((void *)0));
 glEnableClientState(0x8078);
 glTexCoordPointer(2, 0x1406, 4*sizeof(GLfloat), ((char*)((void *)0)) + 2*sizeof(GLfloat));
 __glewBindBuffer(0x8893, indicesID);
 __glewBufferData(0x8893, sizeof(fsindices), fsindices, 0x88E4);
 return 1;
}

canonical_original_code:
int glVBO(){
 __glewGenVertexArrays(1, &vaoID);
 __glewGenVertexArrays(1, &vaostarID);
 __glewGenBuffers(1, &vboID);
 __glewGenBuffers(1, &indicesID);
 __glewGenBuffers(1, &starID);
 __glewBindVertexArray(vaostarID);
 float *starverts;
 starverts = malloc(5*256*256*sizeof(GLfloat));
 memset(starverts, 0, 5*256*256*sizeof(GLfloat));
 int x; int y; int i;
 for(x = 0; x< 256; x++){
  for(y = 0; y< 256; y++){
   i = (x*256 + y)*5;
   starverts[i] = 0.0;
   starverts[i+1] = 0.0;
   starverts[i+2] = 0.0;
   starverts[i+3] = (float)x/(float)256;
   starverts[i+4] = (float)y/(float)256;
  }
 }
 __glewBindBuffer(0x8892, starID);
 __glewBufferData(0x8892, 5*256*256*sizeof(GLfloat), starverts, 0x88E4);
 glEnableClientState(0x8074);
 glVertexPointer(3, 0x1406, 5*sizeof(GLfloat), ((void *)0));
 glEnableClientState(0x8078);
 glTexCoordPointer(2, 0x1406, 5*sizeof(GLfloat), ((char *)((void *)0)) + 3*sizeof(GLfloat));
 free(starverts);
 __glewBindVertexArray(vaoID);
 __glewBindBuffer(0x8892, vboID);
 __glewBufferData(0x8892, sizeof(fsverts), fsverts, 0x88E4);
 glEnableClientState(0x8074);
 glVertexPointer(2, 0x1406, 4*sizeof(GLfloat), ((void *)0));
 glEnableClientState(0x8078);
 glTexCoordPointer(2, 0x1406, 4*sizeof(GLfloat), ((char *)((void *)0)) + 2*sizeof(GLfloat));
 __glewBindBuffer(0x8893, indicesID);
 __glewBufferData(0x8893, sizeof(fsindices), fsindices, 0x88E4);
 return 1;
}

variable_types:
starverts
float *

variable_types: x int

variable_types: y int

variable_types: i int


fillRandom

original_code:
int fillRandom(void){
 srand(time(((void *)0)));
 GLfloat * posarray = malloc(4*256*256*sizeof(GLfloat));
 GLfloat * velarray = malloc(4*256*256*sizeof(GLfloat));
 int x, y;
 for(x = 0; x< 256; x++){
  for(y = 0; y < 256; y++){
   int i = (x*256 +y)*4;
   posarray[i] = (float)x/(float)256;
   posarray[i+1] = (float)y/(float)256;
   posarray[i+2] = 0.0;
   posarray[i+2] = (((GLfloat)rand() / (GLfloat)2147483647)-0.5)*0.1;
   posarray[i+3] = 1.0;
   velarray[i] = 0.0;
   velarray[i+1] = 0.0;
   velarray[i+2] = 0.0;
   velarray[i+3] = 0.0;
  }
 }
 x = 0;
 y = 256 -1;
 for(x = 0; x < 256/2; x++){
  int i = (x*256 +y)*4;
  posarray[i+2] = 0.0;
  posarray[i+3] = 0.0;
 }
 x = 0;
 y = 0;
 for(y = 0; y < 256; y++){
  int i = (x*256 +y)*4;
  posarray[i+2] = 0.0;
  posarray[i+3] = 0.0;
 }
 glBindTexture(0x0DE1, posTexid);
 glTexImage2D(0x0DE1, 0, 0x8814, 256, 256, 0 , 0x1908, 0x1406, posarray);
 glBindTexture(0x0DE1, velTexid);
 glTexImage2D(0x0DE1, 0, 0x8814, 256, 256, 0 , 0x1908, 0x1406, velarray);
 if(posarray)free(posarray);
 if(velarray)free(velarray);
 return 1;
}

canonical_original_code:
int fillRandom(){
 srand(time(((void *)0)));
 float *posarray = malloc(4*256*256*sizeof(GLfloat));
 float *velarray = malloc(4*256*256*sizeof(GLfloat));
 int x; int y;
 for(x = 0; x< 256; x++){
  for(y = 0; y < 256; y++){
   int i = (x*256 +y)*4;
   posarray[i] = (float)x/(float)256;
   posarray[i+1] = (float)y/(float)256;
   posarray[i+2] = 0.0;
   posarray[i+2] = (((float)rand() / (float)2147483647)-0.5)*0.1;
   posarray[i+3] = 1.0;
   velarray[i] = 0.0;
   velarray[i+1] = 0.0;
   velarray[i+2] = 0.0;
   velarray[i+3] = 0.0;
  }
 }
 x = 0;
 y = 256 -1;
 for(x = 0; x < 256/2; x++){
  int i = (x*256 +y)*4;
  posarray[i+2] = 0.0;
  posarray[i+3] = 0.0;
 }
 x = 0;
 y = 0;
 for(y = 0; y < 256; y++){
  int i = (x*256 +y)*4;
  posarray[i+2] = 0.0;
  posarray[i+3] = 0.0;
 }
 glBindTexture(0x0DE1, posTexid);
 glTexImage2D(0x0DE1, 0, 0x8814, 256, 256, 0 , 0x1908, 0x1406, posarray);
 glBindTexture(0x0DE1, velTexid);
 glTexImage2D(0x0DE1, 0, 0x8814, 256, 256, 0 , 0x1908, 0x1406, velarray);
 if(posarray)free(posarray);
 if(velarray)free(velarray);
 return 1;
}

variable_types:
posarray
float *

variable_types:
velarray
float *


glSetupUniforms

decompiled_code:
__int64 glSetupUniforms()
{
void (__fastcall *v0)(_QWORD, __int64); // rbx
unsigned int v1; // eax
void (__fastcall *v2)(_QWORD, __int64); // rbx
unsigned int v3; // eax
void (__fastcall *v4)(_QWORD, __int64); // rbx
unsigned int v5; // eax
void (__fastcall *v6)(_QWORD, __int64); // rbx
unsigned int v7; // eax
void (__fastcall *v8)(_QWORD, __int64); // rbx
unsigned int v9; // eax
void (__fastcall *v10)(_QWORD, __int64); // rbx
unsigned int v11; // eax

_glewActiveTexture(33985LL);
glBindTexture(3553LL, (unsigned int)posTexid);
v0 = (void (__fastcall *)(_QWORD, __int64))_glewUniform1i;
v1 = _glewGetUniformLocation((unsigned int)velShader, "posTex");
v0(v1, 1LL);
v2 = (void (__fastcall *)(_QWORD, __int64))_glewUniform1i;
v3 = _glewGetUniformLocation((unsigned int)posShader, "posTex");
v2(v3, 1LL);
v4 = (void (__fastcall *)(_QWORD, __int64))_glewUniform1i;
v5 = _glewGetUniformLocation((unsigned int)starShader, "posTex");
v4(v5, 1LL);
_glewActiveTexture(33986LL);
glBindTexture(3553LL, (unsigned int)velTexid);
v6 = (void (__fastcall *)(_QWORD, __int64))_glewUniform1i;
v7 = _glewGetUniformLocation((unsigned int)posShader, "velTex");
v6(v7, 2LL);
v8 = (void (__fastcall *)(_QWORD, __int64))_glewUniform1i;
v9 = _glewGetUniformLocation((unsigned int)velShader, "velTex");
v8(v9, 2LL);
v10 = (void (__fastcall *)(_QWORD, __int64))_glewUniform1i;
v11 = _glewGetUniformLocation((unsigned int)starShader, "velTex");
v10(v11, 2LL);
_glewActiveTexture(33984LL);
return 1LL;
}

canonical_decompiled_code:
__int64 func2()
{
void (__fastcall *v0)(_QWORD, __int64); // rbx
unsigned int v1; // eax
void (__fastcall *v2)(_QWORD, __int64); // rbx
unsigned int v3; // eax
void (__fastcall *v4)(_QWORD, __int64); // rbx
unsigned int v5; // eax
void (__fastcall *v6)(_QWORD, __int64); // rbx
unsigned int v7; // eax
void (__fastcall *v8)(_QWORD, __int64); // rbx
unsigned int v9; // eax
void (__fastcall *v10)(_QWORD, __int64); // rbx
unsigned int v11; // eax

_glewActiveTexture(33985LL);
glBindTexture(3553LL, (unsigned int)posTexid);
v0 = (void (__fastcall *)(_QWORD, __int64))_glewUniform1i;
v1 = _glewGetUniformLocation((unsigned int)velShader, "posTex");
v0(v1, 1LL);
v2 = (void (__fastcall *)(_QWORD, __int64))_glewUniform1i;
v3 = _glewGetUniformLocation((unsigned int)posShader, "posTex");
v2(v3, 1LL);
v4 = (void (__fastcall *)(_QWORD, __int64))_glewUniform1i;
v5 = _glewGetUniformLocation((unsigned int)starShader, "posTex");
v4(v5, 1LL);
_glewActiveTexture(33986LL);
glBindTexture(3553LL, (unsigned int)velTexid);
v6 = (void (__fastcall *)(_QWORD, __int64))_glewUniform1i;
v7 = _glewGetUniformLocation((unsigned int)posShader, "velTex");
v6(v7, 2LL);
v8 = (void (__fastcall *)(_QWORD, __int64))_glewUniform1i;
v9 = _glewGetUniformLocation((unsigned int)velShader, "velTex");
v8(v9, 2LL);
v10 = (void (__fastcall *)(_QWORD, __int64))_glewUniform1i;
v11 = _glewGetUniformLocation((unsigned int)starShader, "velTex");
v10(v11, 2LL);
_glewActiveTexture(33984LL);
return 1LL;
}

original_code:
int glSetupUniforms(void){
 __glewActiveTexture(0x84C1);
 glBindTexture(0x0DE1, posTexid);
 __glewUniform1i(__glewGetUniformLocation(velShader, "posTex"), 1);
 __glewUniform1i(__glewGetUniformLocation(posShader, "posTex"), 1);
 __glewUniform1i(__glewGetUniformLocation(starShader, "posTex"), 1);
 __glewActiveTexture(0x84C2);
 glBindTexture(0x0DE1, velTexid);
 __glewUniform1i(__glewGetUniformLocation(posShader, "velTex"), 2);
 __glewUniform1i(__glewGetUniformLocation(velShader, "velTex"), 2);
 __glewUniform1i(__glewGetUniformLocation(starShader, "velTex"), 2);
 __glewActiveTexture(0x84C0);
 return 1;
}

canonical_original_code:
int glSetupUniforms(){
 __glewActiveTexture(0x84C1);
 glBindTexture(0x0DE1, posTexid);
 __glewUniform1i(__glewGetUniformLocation(velShader, "posTex"), 1);
 __glewUniform1i(__glewGetUniformLocation(posShader, "posTex"), 1);
 __glewUniform1i(__glewGetUniformLocation(starShader, "posTex"), 1);
 __glewActiveTexture(0x84C2);
 glBindTexture(0x0DE1, velTexid);
 __glewUniform1i(__glewGetUniformLocation(posShader, "velTex"), 2);
 __glewUniform1i(__glewGetUniformLocation(velShader, "velTex"), 2);
 __glewUniform1i(__glewGetUniformLocation(starShader, "velTex"), 2);
 __glewActiveTexture(0x84C0);
 return 1;
}


updateMatrix

decompiled_code:
__int64 updateMatrix()
{
_BYTE v1[64]; // [rsp+0h] [rbp-88h] BYREF
char v2[72]; // [rsp+40h] [rbp-48h] BYREF

_glewUseProgram((unsigned int)starShader);
Matrix4x4_Concat(v2, &viewmatrix, &projectionmatrix);
Matrix4x4_ToArrayFloatGL(v2, v1);
_glewUniformMatrix4fv((unsigned int)starviewprojpos, 1LL, 0LL, v1);
return 1LL;
}

canonical_decompiled_code:
__int64 func3()
{
_BYTE v1[64]; // [rsp+0h] [rbp-88h] BYREF
char v2[72]; // [rsp+40h] [rbp-48h] BYREF

_glewUseProgram((unsigned int)starShader);
Matrix4x4_Concat(v2, &viewmatrix, &projectionmatrix);
Matrix4x4_ToArrayFloatGL(v2, v1);
_glewUniformMatrix4fv((unsigned int)starviewprojpos, 1LL, 0LL, v1);
return 1LL;
}

original_code:
int updateMatrix(){
 matrix4x4_t viewprojectionmatrix;
 float out[16];
 __glewUseProgram(starShader);
 Matrix4x4_Concat(&viewprojectionmatrix, &viewmatrix, &projectionmatrix);
 Matrix4x4_ToArrayFloatGL(&viewprojectionmatrix, out);
 __glewUniformMatrix4fv(starviewprojpos,1, 0, out);
 return 1;
}

canonical_original_code:
int updateMatrix(){
 struct matrix4x4_s viewprojectionmatrix;
 float out[16];
 __glewUseProgram(starShader);
 Matrix4x4_Concat(&viewprojectionmatrix, &viewmatrix, &projectionmatrix);
 Matrix4x4_ToArrayFloatGL(&viewprojectionmatrix, out);
 __glewUniformMatrix4fv(starviewprojpos,1, 0, out);
 return 1;
}

variable_types:
viewprojectionmatrix
struct matrix4x4_s { float m[4][4]; }

variable_types:
out
float [16]


updateCameraViewMatrix

decompiled_code:
__int64 __fastcall updateCameraViewMatrix(double *a1, double *a2)
{
_BYTE v3[64]; // [rsp+0h] [rbp-C8h] BYREF
char v4[64]; // [rsp+40h] [rbp-88h] BYREF
char v5[72]; // [rsp+80h] [rbp-48h] BYREF

Matrix4x4_CreateFromQuakeEntity(&viewmatrix, *a1, a1[1], a1[2], *a2, a2[2], a2[1], 1.0);
Matrix4x4_Invert_Full(v4, &viewmatrix);
Matrix4x4_CreateRotate(v3, -90.0, 1.0, 0.0);
Matrix4x4_ConcatRotate(v3, 90.0, 0.0, 0.0, 1.0);
Matrix4x4_Concat(&viewmatrix, v3, v4);
_glewUseProgram((unsigned int)starShader);
Matrix4x4_ToArrayFloatGL(&viewmatrix, v5);
_glewUniformMatrix4fv((unsigned int)starviewpos, 1LL, 0LL, v5);
updateMatrix();
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func4(double *a1, double *a2)
{
_BYTE v3[64]; // [rsp+0h] [rbp-C8h] BYREF
char v4[64]; // [rsp+40h] [rbp-88h] BYREF
char v5[72]; // [rsp+80h] [rbp-48h] BYREF

Matrix4x4_CreateFromQuakeEntity(&viewmatrix, *a1, a1[1], a1[2], *a2, a2[2], a2[1], 1.0);
Matrix4x4_Invert_Full(v4, &viewmatrix);
Matrix4x4_CreateRotate(v3, -90.0, 1.0, 0.0);
Matrix4x4_ConcatRotate(v3, 90.0, 0.0, 0.0, 1.0);
Matrix4x4_Concat(&viewmatrix, v3, v4);
_glewUseProgram((unsigned int)starShader);
Matrix4x4_ToArrayFloatGL(&viewmatrix, v5);
_glewUniformMatrix4fv((unsigned int)starviewpos, 1LL, 0LL, v5);
func3();
return 1LL;
}

original_code:
int updateCameraViewMatrix(double campos[3], double camangle[3]){
 float out[16];
 matrix4x4_t tempmatrix;
 matrix4x4_t basematrix;
 Matrix4x4_CreateFromQuakeEntity(&viewmatrix, campos[0], campos[1], campos[2], camangle[0], camangle[2], camangle[1], 1.0);
        Matrix4x4_Invert_Full(&tempmatrix, &viewmatrix);
        Matrix4x4_CreateRotate(&basematrix, -90, 1, 0, 0);
        Matrix4x4_ConcatRotate(&basematrix, 90, 0, 0, 1);
        Matrix4x4_Concat(&viewmatrix, &basematrix, &tempmatrix);
 __glewUseProgram(starShader);
 Matrix4x4_ToArrayFloatGL(&viewmatrix, out);
 __glewUniformMatrix4fv(starviewpos,1, 0, out);
 updateMatrix();
 return 1;
}

canonical_original_code:
int updateCameraViewMatrix(double campos[3], double camangle[3]){
 float out[16];
 struct matrix4x4_s tempmatrix;
 struct matrix4x4_s basematrix;
 Matrix4x4_CreateFromQuakeEntity(&viewmatrix, campos[0], campos[1], campos[2], camangle[0], camangle[2], camangle[1], 1.0);
        Matrix4x4_Invert_Full(&tempmatrix, &viewmatrix);
        Matrix4x4_CreateRotate(&basematrix, -90, 1, 0, 0);
        Matrix4x4_ConcatRotate(&basematrix, 90, 0, 0, 1);
        Matrix4x4_Concat(&viewmatrix, &basematrix, &tempmatrix);
 __glewUseProgram(starShader);
 Matrix4x4_ToArrayFloatGL(&viewmatrix, out);
 __glewUniformMatrix4fv(starviewpos,1, 0, out);
 updateMatrix();
 return 1;
}

variable_types:
campos
double [3]

variable_types:
camangle
double [3]

variable_types:
tempmatrix
struct matrix4x4_s { float m[4][4]; }

variable_types:
basematrix
struct matrix4x4_s { float m[4][4]; }


updateCameraProjMatrix

decompiled_code:
__int64 updateCameraProjMatrix()
{
__int64 v0; // rdx
__int64 v2[5]; // [rsp+0h] [rbp-48h] BYREF
int v3; // [rsp+28h] [rbp-20h]
int v4; // [rsp+2Ch] [rbp-1Ch]
__int64 v5; // [rsp+30h] [rbp-18h]
__int64 v6; // [rsp+38h] [rbp-10h]

_glewUseProgram((unsigned int)starShader);
v0 = (unsigned int)(screenx >> 31);
LODWORD(v0) = screenx % screeny;
HIDWORD(v2[0]) = 0;
v2[1] = 0LL;
v2[2] = 0x3FAAAAAB00000000LL;
v2[3] = 0LL;
v2[4] = 0LL;
v5 = 0LL;
v6 = 3192704203LL;
*(float *)v2 = 1.0 / (float)((float)(screenx / screeny) * 0.75);
v3 = -1082130434;
v4 = -1082130432;
Matrix4x4_FromArrayFloatGL(&projectionmatrix, v2, v0);
_glewUniformMatrix4fv((unsigned int)starprojpos, 1LL, 0LL, v2);
updateMatrix();
return 1LL;
}

canonical_decompiled_code:
__int64 func5()
{
__int64 v0; // rdx
__int64 v2[5]; // [rsp+0h] [rbp-48h] BYREF
int v3; // [rsp+28h] [rbp-20h]
int v4; // [rsp+2Ch] [rbp-1Ch]
__int64 v5; // [rsp+30h] [rbp-18h]
__int64 v6; // [rsp+38h] [rbp-10h]

_glewUseProgram((unsigned int)starShader);
v0 = (unsigned int)(screenx >> 31);
LODWORD(v0) = screenx % screeny;
HIDWORD(v2[0]) = 0;
v2[1] = 0LL;
v2[2] = 0x3FAAAAAB00000000LL;
v2[3] = 0LL;
v2[4] = 0LL;
v5 = 0LL;
v6 = 3192704203LL;
*(float *)v2 = 1.0 / (float)((float)(screenx / screeny) * 0.75);
v3 = -1082130434;
v4 = -1082130432;
Matrix4x4_FromArrayFloatGL(&projectionmatrix, v2, v0);
_glewUniformMatrix4fv((unsigned int)starprojpos, 1LL, 0LL, v2);
func3();
return 1LL;
}

original_code:
int updateCameraProjMatrix( ){
 __glewUseProgram(starShader);
 float out[16];
 float nearclip = 0.1;
 float fov = 360/130*3.1415926;
 float aspect = screenx/screeny;
 const float nudge = 1.0 - 1.0 / (1<<23);
 float frustumy = 0.75;
 float frustumx = 0.75 * aspect;
 memset(out, 0, sizeof(out));
        out[ 0] = 1.0 / frustumx;
        out[ 5] = 1.0 / frustumy;
        out[10] = -nudge;
        out[11] = -1.0;
        out[14] = -2.0 * nearclip * nudge;
 Matrix4x4_FromArrayFloatGL(&projectionmatrix, out);
 __glewUniformMatrix4fv(starprojpos,1, 0, out);
 updateMatrix();
 return 1;
}

canonical_original_code:
int updateCameraProjMatrix(){
 __glewUseProgram(starShader);
 float out[16];
 float nearclip = 0.1;
 float fov = 360/130*3.1415926;
 float aspect = screenx/screeny;
 float nudge = 1.0 - 1.0 / (1<<23);
 float frustumy = 0.75;
 float frustumx = 0.75 * aspect;
 memset(out, 0, sizeof(out));
        out[ 0] = 1.0 / frustumx;
        out[ 5] = 1.0 / frustumy;
        out[10] = -nudge;
        out[11] = -1.0;
        out[14] = -2.0 * nearclip * nudge;
 Matrix4x4_FromArrayFloatGL(&projectionmatrix, out);
 __glewUniformMatrix4fv(starprojpos,1, 0, out);
 updateMatrix();
 return 1;
}

variable_types: nearclip float

variable_types: fov float

variable_types: aspect float

variable_types: nudge float

variable_types: frustumy float

variable_types: frustumx float


updateScreenSize

decompiled_code:
__int64 __fastcall updateScreenSize(int a1, int a2)
{
__int64 result; // rax

result = 1LL;
if ( a1 <= 0 )
a1 = 1;
screenx = a1;
if ( a2 <= 0 )
a2 = 1;
screeny = a2;
return result;
}

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

result = 1LL;
if ( a1 <= 0 )
a1 = 1;
screenx = a1;
if ( a2 <= 0 )
a2 = 1;
screeny = a2;
return result;
}

original_code:
int updateScreenSize(int x, int y){
 if(x < 1) x = 1;
 if(y < 1) y = 1;
 screenx = x;
 screeny = y;
 return 1;
}

variable_types: x int


initUniforms

decompiled_code:
__int64 initUniforms()
{
starprojpos = _glewGetUniformLocation((unsigned int)starShader, "proj");
starviewprojpos = _glewGetUniformLocation((unsigned int)starShader, "viewprojection");
starviewpos = _glewGetUniformLocation((unsigned int)starShader, "view");
forceunipos = _glewGetUniformLocation((unsigned int)velShader, "force");
return 1LL;
}

canonical_decompiled_code:
__int64 func7()
{
starprojpos = _glewGetUniformLocation((unsigned int)starShader, "proj");
starviewprojpos = _glewGetUniformLocation((unsigned int)starShader, "viewprojection");
starviewpos = _glewGetUniformLocation((unsigned int)starShader, "view");
forceunipos = _glewGetUniformLocation((unsigned int)velShader, "force");
return 1LL;
}

original_code:
int initUniforms(void){
 starprojpos = __glewGetUniformLocation(starShader, "proj");
 starviewprojpos = __glewGetUniformLocation(starShader, "viewprojection");
 starviewpos = __glewGetUniformLocation(starShader, "view");
 forceunipos = __glewGetUniformLocation(velShader, "force");
 return 1;
}

canonical_original_code:
int initUniforms(){
 starprojpos = __glewGetUniformLocation(starShader, "proj");
 starviewprojpos = __glewGetUniformLocation(starShader, "viewprojection");
 starviewpos = __glewGetUniformLocation(starShader, "view");
 forceunipos = __glewGetUniformLocation(velShader, "force");
 return 1;
}