findFrameBufferByName

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

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

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

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

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)
{
char *v4; // rax

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

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

glBindTexture(3553LL, *((unsigned int *)fblist + 10 * a1 + 8));
glTexImage2D(3553LL, 0LL, 6407LL, (unsigned int)a2, (unsigned int)a3, 0LL, 6407LL, 5121LL, 0LL);
glBindTexture(3553LL, 0LL);
v4 = (char *)fblist + 40 * a1;
*((_DWORD *)v4 + 4) = a2;
*((_DWORD *)v4 + 5) = a3;
*((float *)v4 + 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;
}

variable_types:
id
unsigned int

variable_types:
width
unsigned int

variable_types:
height
unsigned int

return_type: int


createFrameBuffersAndTextures

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

if ( a1 && a2 )
{
glGenTextures(1LL, &v3);
glGenTextures(1LL, &v4);
if ( v3 && v4 )
{
glBindTexture(3553LL, v4);
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, v3);
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, &v5);
_glewGenFramebuffers(1LL, v6);
if ( v5 && v6[0] )
{
_glewBindFramebuffer(36160LL);
_glewFramebufferTexture2D(36160LL, 36064LL, 3553LL, v4, 0LL);
glClear(16640LL);
_glewBindFramebuffer(36160LL);
_glewFramebufferTexture2D(36160LL, 36064LL, 3553LL, v3, 0LL);
glClear(16640LL);
_glewBindFramebuffer(36160LL);
addFrameBufferToList((__int64)"vel", v5, a1, a2, v3, 1);
addFrameBufferToList((__int64)"pos", v6[0], a1, a2, v4, 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
unsigned int v3; // [rsp+0h] [rbp-28h] BYREF
unsigned int v4; // [rsp+4h] [rbp-24h] BYREF
int v5; // [rsp+8h] [rbp-20h] BYREF
int v6[7]; // [rsp+Ch] [rbp-1Ch] BYREF

if ( a1 && a2 )
{
glGenTextures(1LL, &v3);
glGenTextures(1LL, &v4);
if ( v3 && v4 )
{
glBindTexture(3553LL, v4);
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, v3);
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, &v5);
_glewGenFramebuffers(1LL, v6);
if ( v5 && v6[0] )
{
_glewBindFramebuffer(36160LL);
_glewFramebufferTexture2D(36160LL, 36064LL, 3553LL, v4, 0LL);
glClear(16640LL);
_glewBindFramebuffer(36160LL);
_glewFramebufferTexture2D(36160LL, 36064LL, 3553LL, v3, 0LL);
glClear(16640LL);
_glewBindFramebuffer(36160LL);
func0((__int64)"vel", v5, a1, a2, v3, 1);
func0((__int64)"pos", v6[0], a1, a2, v4, 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
char v3; // al
__int64 result; // rax
char v5; // al
char v6; // al
char v7; // al
char v8; // al
char v9; // al
char v10; // al
char v11; // al

v2 = *(_DWORD *)(a1 + 4);
if ( v2 <= 0x77 )
{
if ( v2 > 0x60 )
{
switch ( v2 )
{
case 'a':
v7 = controllkeys | 2;
if ( !a2 )
v7 = controllkeys & 0xFD;
controllkeys = v7;
result = 1LL;
break;
case 'd':
v8 = controllkeys | 8;
if ( !a2 )
v8 = controllkeys & 0xF7;
controllkeys = v8;
result = 1LL;
break;
case 'e':
v9 = controllkeys | 0x28;
if ( !a2 )
v9 = controllkeys & 0xD7;
controllkeys = v9;
result = 1LL;
break;
case 'q':
v10 = controllkeys | 0x64;
if ( !a2 )
v10 = controllkeys & 0x9B;
controllkeys = v10;
result = 1LL;
break;
case 's':
v11 = controllkeys | 4;
if ( !a2 )
v11 = controllkeys & 0xFB;
controllkeys = v11;
result = 1LL;
break;
case 'w':
v6 = controllkeys | 1;
if ( !a2 )
v6 = controllkeys & 0xFE;
controllkeys = v6;
result = 1LL;
break;
default:
return 1LL;
}
return result;
}
if ( v2 == 27 )
exit(1);
if ( v2 == 32 )
{
v3 = controllkeys | 0x16;
if ( !a2 )
v3 = controllkeys & 0xE9;
controllkeys = v3;
}
return 1LL;
}
if ( v2 != 303 )
return 1LL;
v5 = controllkeys | 0x32;
if ( !a2 )
v5 = controllkeys & 0xCD;
controllkeys = v5;
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, int a2)
{
unsigned int v2; // eax
char v3; // al
__int64 result; // rax
char v5; // al
char v6; // al
char v7; // al
char v8; // al
char v9; // al
char v10; // al
char v11; // al

v2 = *(_DWORD *)(a1 + 4);
if ( v2 <= 0x77 )
{
if ( v2 > 0x60 )
{
switch ( v2 )
{
case 'a':
v7 = controllkeys | 2;
if ( !a2 )
v7 = controllkeys & 0xFD;
controllkeys = v7;
result = 1LL;
break;
case 'd':
v8 = controllkeys | 8;
if ( !a2 )
v8 = controllkeys & 0xF7;
controllkeys = v8;
result = 1LL;
break;
case 'e':
v9 = controllkeys | 0x28;
if ( !a2 )
v9 = controllkeys & 0xD7;
controllkeys = v9;
result = 1LL;
break;
case 'q':
v10 = controllkeys | 0x64;
if ( !a2 )
v10 = controllkeys & 0x9B;
controllkeys = v10;
result = 1LL;
break;
case 's':
v11 = controllkeys | 4;
if ( !a2 )
v11 = controllkeys & 0xFB;
controllkeys = v11;
result = 1LL;
break;
case 'w':
v6 = controllkeys | 1;
if ( !a2 )
v6 = controllkeys & 0xFE;
controllkeys = v6;
result = 1LL;
break;
default:
return 1LL;
}
return result;
}
if ( v2 == 27 )
exit(1);
if ( v2 == 32 )
{
v3 = controllkeys | 0x16;
if ( !a2 )
v3 = controllkeys & 0xE9;
controllkeys = v3;
}
return 1LL;
}
if ( v2 != 303 )
return 1LL;
v5 = controllkeys | 0x32;
if ( !a2 )
v5 = controllkeys & 0xCD;
controllkeys = v5;
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; // xmm1_8
double v4; // xmm0_8

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

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

v2 = *(double *)&LC1;
v3 = (double)a2 + *(double *)&camangle;
campos[0] = LC0;
campos[1] = LC0;
campos[2] = LC0;
v4 = (double)a1 + *((double *)&camangle + 2);
*((double *)&camangle + 2) = v4;
if ( v3 <= 90.0 )
v2 = fmax(-90.0, v3);
camangle = *(_QWORD *)&v2;
*((double *)&camangle + 2) = fmod(v4, 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 v5; // er12
unsigned int v6; // ebp
__int64 result; // rax
const char *v8; // rax

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);
v6 = 1;
if ( a2 <= 0 )
v5 = 1;
if ( a1 > 0 )
v6 = a1;
surface = SDL_SetVideoMode(v6, v5, a3, (unsigned int)videoFlags);
if ( surface )
{
updateScreenSize(v6, 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 v5; // er12
unsigned int v6; // ebp
__int64 result; // rax
const char *v8; // rax

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);
v6 = 1;
if ( a2 <= 0 )
v5 = 1;
if ( a1 > 0 )
v6 = a1;
surface = SDL_SetVideoMode(v6, v5, a3, (unsigned int)videoFlags);
if ( surface )
{
updateScreenSize(v6, 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:
// attributes: thunk
__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();
}

return_type: void


sdlInit

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

if ( a4 )
{
puts("DEBUG -- SDL window initializing ");
if ( (int)SDL_Init(32LL) >= 0 )
goto LABEL_3;
}
else if ( (int)SDL_Init(32LL) >= 0 )
{
LABEL_3:
videoInfo = SDL_GetVideoInfo();
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);
return resizeWindow(a1, a2, a3, a4);
}
v8 = (const char *)SDL_GetError();
fprintf(stderr, "ERROR -- SDL video init failed: %s \n", v8);
return 0LL;
}

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

if ( a4 )
{
puts("DEBUG -- SDL window initializing ");
if ( (int)SDL_Init(32LL) >= 0 )
goto LABEL_3;
}
else if ( (int)SDL_Init(32LL) >= 0 )
{
LABEL_3:
videoInfo = SDL_GetVideoInfo();
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);
return func0(a1, a2, a3, a4);
}
v8 = (const char *)SDL_GetError();
fprintf(stderr, "ERROR -- SDL video init failed: %s \n", v8);
return 0LL;
}

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; // rax
int v1; // ecx
void *v2; // rbp
float *v3; // rsi
float *v4; // rax
int v5; // edx
float v6; // xmm0_4

_glewGenVertexArrays(1LL, &vaoID);
_glewGenVertexArrays(1LL, &vaostarID);
_glewGenBuffers(1LL, &vboID);
_glewGenBuffers(1LL, &indicesID);
_glewGenBuffers(1LL, &starID);
_glewBindVertexArray((unsigned int)vaostarID);
v0 = (char *)calloc(0x140000uLL, 1uLL);
v1 = 0;
v2 = v0;
v3 = (float *)v0;
do
{
v4 = v3;
v5 = 0;
do
{
v4[3] = (float)v1 * 0.00390625;
v4 += 5;
v6 = (float)v5++;
*(v4 - 5) = 0.0;
*(v4 - 4) = 0.0;
*(v4 - 3) = 0.0;
*(v4 - 1) = v6 * 0.00390625;
}
while ( v5 != 256 );
++v1;
v3 += 1280;
}
while ( v1 != 256 );
_glewBindBuffer(34962LL, (unsigned int)starID);
_glewBufferData(34962LL, 1310720LL, v2, 35044LL);
glEnableClientState(32884LL);
glVertexPointer(3LL, 5126LL, 20LL, 0LL);
glEnableClientState(32888LL);
glTexCoordPointer(2LL, 5126LL, 20LL, 12LL);
free(v2);
_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; // rax
int v1; // ecx
void *v2; // rbp
float *v3; // rsi
float *v4; // rax
int v5; // edx
float v6; // xmm0_4

_glewGenVertexArrays(1LL, &vaoID);
_glewGenVertexArrays(1LL, &vaostarID);
_glewGenBuffers(1LL, &vboID);
_glewGenBuffers(1LL, &indicesID);
_glewGenBuffers(1LL, &starID);
_glewBindVertexArray((unsigned int)vaostarID);
v0 = (char *)calloc(0x140000uLL, 1uLL);
v1 = 0;
v2 = v0;
v3 = (float *)v0;
do
{
v4 = v3;
v5 = 0;
do
{
v4[3] = (float)v1 * 0.00390625;
v4 += 5;
v6 = (float)v5++;
*(v4 - 5) = 0.0;
*(v4 - 4) = 0.0;
*(v4 - 3) = 0.0;
*(v4 - 1) = v6 * 0.00390625;
}
while ( v5 != 256 );
++v1;
v3 += 1280;
}
while ( v1 != 256 );
_glewBindBuffer(34962LL, (unsigned int)starID);
_glewBufferData(34962LL, 1310720LL, v2, 35044LL);
glEnableClientState(32884LL);
glVertexPointer(3LL, 5126LL, 20LL, 0LL);
glEnableClientState(32888LL);
glTexCoordPointer(2LL, 5126LL, 20LL, 12LL);
free(v2);
_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(v1, &viewmatrix, &projectionmatrix);
Matrix4x4_ToArrayFloatGL(v1, v2);
_glewUniformMatrix4fv((unsigned int)starviewprojpos, 1LL, 0LL, v2);
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(v1, &viewmatrix, &projectionmatrix);
Matrix4x4_ToArrayFloatGL(v1, v2);
_glewUniformMatrix4fv((unsigned int)starviewprojpos, 1LL, 0LL, v2);
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(v5, -90.0, 1.0, 0.0);
Matrix4x4_ConcatRotate(v5, 90.0, 0.0, 0.0, 1.0);
Matrix4x4_Concat(&viewmatrix, v5, v4);
_glewUseProgram((unsigned int)starShader);
Matrix4x4_ToArrayFloatGL(&viewmatrix, v3);
_glewUniformMatrix4fv((unsigned int)starviewpos, 1LL, 0LL, v3);
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(v5, -90.0, 1.0, 0.0);
Matrix4x4_ConcatRotate(v5, 90.0, 0.0, 0.0, 1.0);
Matrix4x4_Concat(&viewmatrix, v5, v4);
_glewUseProgram((unsigned int)starShader);
Matrix4x4_ToArrayFloatGL(&viewmatrix, v3);
_glewUniformMatrix4fv((unsigned int)starviewpos, 1LL, 0LL, v3);
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
__int128 v2; // [rsp+0h] [rbp-48h] BYREF
__int128 v3; // [rsp+10h] [rbp-38h]
__int128 v4; // [rsp+20h] [rbp-28h]
__int128 v5; // [rsp+30h] [rbp-18h]

_glewUseProgram((unsigned int)starShader);
v2 = 0LL;
v3 = 0LL;
v0 = (unsigned int)(screenx >> 31);
*(_QWORD *)&v4 = 0LL;
LODWORD(v0) = screenx % screeny;
v5 = 0LL;
DWORD1(v3) = 1068149419;
DWORD2(v5) = -1102263093;
*((_QWORD *)&v4 + 1) = 0xBF800000BF7FFFFELL;
*(float *)&v2 = 1.0 / (float)((float)(screenx / screeny) * 0.75);
Matrix4x4_FromArrayFloatGL(&projectionmatrix, &v2, v0);
_glewUniformMatrix4fv((unsigned int)starprojpos, 1LL, 0LL, &v2);
updateMatrix();
return 1LL;
}

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

_glewUseProgram((unsigned int)starShader);
v2 = 0LL;
v3 = 0LL;
v0 = (unsigned int)(screenx >> 31);
*(_QWORD *)&v4 = 0LL;
LODWORD(v0) = screenx % screeny;
v5 = 0LL;
DWORD1(v3) = 1068149419;
DWORD2(v5) = -1102263093;
*((_QWORD *)&v4 + 1) = 0xBF800000BF7FFFFELL;
*(float *)&v2 = 1.0 / (float)((float)(screenx / screeny) * 0.75);
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;
if ( a2 <= 0 )
a2 = 1;
screenx = a1;
screeny = a2;
return result;
}

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

result = 1LL;
if ( a1 <= 0 )
a1 = 1;
if ( a2 <= 0 )
a2 = 1;
screenx = a1;
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;
}


glInit

decompiled_code:
__int64 glInit()
{
unsigned int v0; // eax
unsigned int v1; // eax
unsigned int v2; // eax
unsigned int v3; // eax
unsigned int v4; // eax
unsigned int v5; // eax
__int64 result; // rax
const char *v7; // rax
int v8[8]; // [rsp+0h] [rbp-98h] BYREF
int v9[8]; // [rsp+20h] [rbp-78h] BYREF
int v10[8]; // [rsp+40h] [rbp-58h] BYREF
int v11[8]; // [rsp+60h] [rbp-38h] BYREF
unsigned int v12; // [rsp+80h] [rbp-18h]

v0 = glewInit();
if ( v0 )
{
v7 = (const char *)glewGetErrorString(v0);
printf("ERROR with the glew: %s\n", v7);
result = 0LL;
}
else
{
initShaderSystem();
initFrameBufferSystem();
v1 = createAndLoadShader("flagvel");
returnShader(v8, v1);
velShader = v8[0];
v2 = createAndLoadShader("flag");
returnShader(v9, v2);
starShader = v9[0];
v3 = createAndLoadShader("pos");
returnShader(v10, v3);
posShader = v10[0];
createFrameBuffersAndTextures(256LL, 256LL);
v4 = findFrameBufferByName("pos");
returnFrameBuffer(v11, v4);
posTexid = v12;
posFBid = v11[0];
v5 = findFrameBufferByName("vel");
returnFrameBuffer(v11, v5);
velFBid = v11[0];
velTexid = v12;
printf(
"velTexid: %d velFBid: %d velShader: %d posTexid: %d posFBid: %d posShader: %d \n",
v12,
(unsigned int)v11[0],
(unsigned int)velShader,
(unsigned int)posTexid,
(unsigned int)posFBid,
(unsigned int)posShader);
printf("star: %d\n", (unsigned int)starShader);
glVBO();
glDisable(2929LL);
glEnable(3042LL);
glEnable(32925LL);
glEnable(2832LL);
glEnable(34370LL);
glEnable(3553LL);
glBlendFunc(1LL, 1LL);
glColor3f(1.0, 1.0);
fillRandom();
initUniforms();
updateCameraProjMatrix();
result = 1LL;
}
return result;
}

canonical_decompiled_code:
__int64 func8()
{
unsigned int v0; // eax
unsigned int v1; // eax
unsigned int v2; // eax
unsigned int v3; // eax
unsigned int v4; // eax
unsigned int v5; // eax
__int64 result; // rax
const char *v7; // rax
int v8[8]; // [rsp+0h] [rbp-98h] BYREF
int v9[8]; // [rsp+20h] [rbp-78h] BYREF
int v10[8]; // [rsp+40h] [rbp-58h] BYREF
int v11[8]; // [rsp+60h] [rbp-38h] BYREF
unsigned int v12; // [rsp+80h] [rbp-18h]

v0 = glewInit();
if ( v0 )
{
v7 = (const char *)glewGetErrorString(v0);
printf("ERROR with the glew: %s\n", v7);
result = 0LL;
}
else
{
initShaderSystem();
initFrameBufferSystem();
v1 = createAndLoadShader("flagvel");
returnShader(v8, v1);
velShader = v8[0];
v2 = createAndLoadShader("flag");
returnShader(v9, v2);
starShader = v9[0];
v3 = createAndLoadShader("pos");
returnShader(v10, v3);
posShader = v10[0];
createFrameBuffersAndTextures(256LL, 256LL);
v4 = findFrameBufferByName("pos");
returnFrameBuffer(v11, v4);
posTexid = v12;
posFBid = v11[0];
v5 = findFrameBufferByName("vel");
returnFrameBuffer(v11, v5);
velFBid = v11[0];
velTexid = v12;
printf(
"velTexid: %d velFBid: %d velShader: %d posTexid: %d posFBid: %d posShader: %d \n",
v12,
(unsigned int)v11[0],
(unsigned int)velShader,
(unsigned int)posTexid,
(unsigned int)posFBid,
(unsigned int)posShader);
printf("star: %d\n", (unsigned int)starShader);
func0();
glDisable(2929LL);
glEnable(3042LL);
glEnable(32925LL);
glEnable(2832LL);
glEnable(34370LL);
glEnable(3553LL);
glBlendFunc(1LL, 1LL);
glColor3f(1.0, 1.0);
func1();
func7();
func5();
result = 1LL;
}
return result;
}

original_code:
int glInit(void){
 GLenum glewError = glewInit();
 if(glewError != 0){
  printf("ERROR with the glew: %s\n", glewGetErrorString(glewError));
  return 0;
 }
 initShaderSystem();
 initFrameBufferSystem();
  velShader = returnShader(createAndLoadShader("flagvel")).id;
  starShader = returnShader(createAndLoadShader("flag")).id;
 posShader = returnShader(createAndLoadShader("pos")).id;
 createFrameBuffersAndTextures(256, 256);
 framebuffer_t tf;
 tf = returnFrameBuffer(findFrameBufferByName("pos"));
 posTexid = tf.texid;
 posFBid = tf.id;
 tf = returnFrameBuffer(findFrameBufferByName("vel"));
 velTexid = tf.texid;
 velFBid = tf.id;
 printf("velTexid: %d velFBid: %d velShader: %d  posTexid: %d posFBid: %d posShader: %d \n", velTexid, velFBid, velShader, posTexid, posFBid, posShader);
 printf("star: %d\n", starShader);
 glVBO();
 glDisable(0x0B71);
 glEnable(0x0BE2);
 glEnable(0x809D);
 glEnable(0x0B10);
 glEnable(0x8642);
 glEnable(0x0DE1);
 glBlendFunc(1, 1);
 glColor3f(1.0f, 1.0f, 1.0f);
 fillRandom();
 initUniforms();
 updateCameraProjMatrix();
 return 1;
}

canonical_original_code:
int glInit(){
 unsigned int glewError = glewInit();
 if(glewError != 0){
  printf("ERROR with the glew: %s\n", glewGetErrorString(glewError));
  return 0;
 }
 initShaderSystem();
 initFrameBufferSystem();
  velShader = returnShader(createAndLoadShader("flagvel")).id;
  starShader = returnShader(createAndLoadShader("flag")).id;
 posShader = returnShader(createAndLoadShader("pos")).id;
 createFrameBuffersAndTextures(256, 256);
 struct framebuffer_s tf;
 tf = returnFrameBuffer(findFrameBufferByName("pos"));
 posTexid = tf.texid;
 posFBid = tf.id;
 tf = returnFrameBuffer(findFrameBufferByName("vel"));
 velTexid = tf.texid;
 velFBid = tf.id;
 printf("velTexid: %d velFBid: %d velShader: %d  posTexid: %d posFBid: %d posShader: %d \n", velTexid, velFBid, velShader, posTexid, posFBid, posShader);
 printf("star: %d\n", starShader);
 glVBO();
 glDisable(0x0B71);
 glEnable(0x0BE2);
 glEnable(0x809D);
 glEnable(0x0B10);
 glEnable(0x8642);
 glEnable(0x0DE1);
 glBlendFunc(1, 1);
 glColor3f(1.0f, 1.0f, 1.0f);
 fillRandom();
 initUniforms();
 updateCameraProjMatrix();
 return 1;
}

variable_types:
glewError
unsigned int

variable_types: struct framebuffer_s { unsigned int id; char *name; unsigned int width; unsigned int height; float aspect; unsigned int fov; unsigned int texid; char type; }


glRender

decompiled_code:
__int64 glRender()
{
int v0; // eax
unsigned int v1; // xmm2_4

_glewBindVertexArray((unsigned int)vaoID);
glViewport(0LL, 0LL, 256LL, 256LL);
_glewUseProgram((unsigned int)velShader);
v0 = clock();
*(float *)&v1 = sin((float)((float)v0 / 1000000.0)) * 0.01;
_glewUniform3f((unsigned int)forceunipos, COERCE_DOUBLE((unsigned __int64)v1), -0.02);
_glewBindFramebuffer(36160LL, (unsigned int)velFBid);
glBindTexture(3553LL, (unsigned int)posTexid);
glDrawElements(4LL, 6LL, 5125LL, 0LL);
glBlendFunc(774LL, 0LL);
glColor3f(0.40000001, 0.40000001);
_glewUseProgram(0LL);
glBindTexture(3553LL, 0LL);
glDrawElements(4LL, 6LL, 5125LL, 0LL);
glBlendFunc(1LL, 1LL);
glColor3f(1.0, 1.0);
_glewUseProgram((unsigned int)posShader);
_glewBindFramebuffer(36160LL, (unsigned int)posFBid);
glBindTexture(3553LL, (unsigned int)velTexid);
glDrawElements(4LL, 6LL, 5125LL, 0LL);
_glewBindVertexArray((unsigned int)vaostarID);
glViewport(0LL, 0LL, (unsigned int)screenx, (unsigned int)screeny);
_glewUseProgram((unsigned int)starShader);
_glewBindFramebuffer(36160LL, 0LL);
glBindTexture(3553LL, (unsigned int)posTexid);
glClear(16640LL);
glDrawArrays(0LL, 0LL, 0x10000LL);
swapBuffers();
return 1LL;
}

canonical_decompiled_code:
__int64 func9()
{
int v0; // eax
unsigned int v1; // xmm2_4

_glewBindVertexArray((unsigned int)vaoID);
glViewport(0LL, 0LL, 256LL, 256LL);
_glewUseProgram((unsigned int)velShader);
v0 = clock();
*(float *)&v1 = sin((float)((float)v0 / 1000000.0)) * 0.01;
_glewUniform3f((unsigned int)forceunipos, COERCE_DOUBLE((unsigned __int64)v1), -0.02);
_glewBindFramebuffer(36160LL, (unsigned int)velFBid);
glBindTexture(3553LL, (unsigned int)posTexid);
glDrawElements(4LL, 6LL, 5125LL, 0LL);
glBlendFunc(774LL, 0LL);
glColor3f(0.40000001, 0.40000001);
_glewUseProgram(0LL);
glBindTexture(3553LL, 0LL);
glDrawElements(4LL, 6LL, 5125LL, 0LL);
glBlendFunc(1LL, 1LL);
glColor3f(1.0, 1.0);
_glewUseProgram((unsigned int)posShader);
_glewBindFramebuffer(36160LL, (unsigned int)posFBid);
glBindTexture(3553LL, (unsigned int)velTexid);
glDrawElements(4LL, 6LL, 5125LL, 0LL);
_glewBindVertexArray((unsigned int)vaostarID);
glViewport(0LL, 0LL, (unsigned int)screenx, (unsigned int)screeny);
_glewUseProgram((unsigned int)starShader);
_glewBindFramebuffer(36160LL, 0LL);
glBindTexture(3553LL, (unsigned int)posTexid);
glClear(16640LL);
glDrawArrays(0LL, 0LL, 0x10000LL);
swapBuffers();
return 1LL;
}

original_code:
int glRender(void){
 __glewBindVertexArray(vaoID);
 glViewport(0,0, 256, 256);
 __glewUseProgram(velShader);
 float time = (float)clock() / ((__clock_t) 1000000);
 float dirz = sin(time) * 0.01;
 float dirx = sin(time) * 0.01;
 __glewUniform3f(forceunipos, dirx, -0.02, dirz);
 __glewBindFramebuffer(0x8D40, velFBid);
 glBindTexture(0x0DE1, posTexid);
 glDrawElements(0x0004, 6, 0x1405, 0);
 glBlendFunc(0x0306, 0);
 glColor3f(0.4, 0.4, 0.4);
 __glewUseProgram(0);
 glBindTexture(0x0DE1, 0);
 glDrawElements(0x0004, 6, 0x1405, 0);
 glBlendFunc(1, 1);
 glColor3f(1.0, 1.0, 1.0);
 __glewUseProgram(posShader);
 __glewBindFramebuffer(0x8D40, posFBid);
 glBindTexture(0x0DE1, velTexid);
 glDrawElements(0x0004, 6, 0x1405, 0);
 __glewBindVertexArray(vaostarID);
 glViewport(0,0,screenx,screeny);
 __glewUseProgram(starShader);
 __glewBindFramebuffer(0x8D40, 0);
 glBindTexture(0x0DE1, posTexid);
 glClear(0x00004000| 0x00000100);
 glDrawArrays(0x0000, 0, 256*256);
 swapBuffers();
 return 1;
}

canonical_original_code:
int glRender(){
 __glewBindVertexArray(vaoID);
 glViewport(0,0, 256, 256);
 __glewUseProgram(velShader);
 float time = (float)clock() / ((__clock_t) 1000000);
 float dirz = sin(time) * 0.01;
 float dirx = sin(time) * 0.01;
 __glewUniform3f(forceunipos, dirx, -0.02, dirz);
 __glewBindFramebuffer(0x8D40, velFBid);
 glBindTexture(0x0DE1, posTexid);
 glDrawElements(0x0004, 6, 0x1405, 0);
 glBlendFunc(0x0306, 0);
 glColor3f(0.4, 0.4, 0.4);
 __glewUseProgram(0);
 glBindTexture(0x0DE1, 0);
 glDrawElements(0x0004, 6, 0x1405, 0);
 glBlendFunc(1, 1);
 glColor3f(1.0, 1.0, 1.0);
 __glewUseProgram(posShader);
 __glewBindFramebuffer(0x8D40, posFBid);
 glBindTexture(0x0DE1, velTexid);
 glDrawElements(0x0004, 6, 0x1405, 0);
 __glewBindVertexArray(vaostarID);
 glViewport(0,0,screenx,screeny);
 __glewUseProgram(starShader);
 __glewBindFramebuffer(0x8D40, 0);
 glBindTexture(0x0DE1, posTexid);
 glClear(0x00004000| 0x00000100);
 glDrawArrays(0x0000, 0, 256*256);
 swapBuffers();
 return 1;
}

variable_types: time float

variable_types: dirz float

variable_types: dirx float


addProgramToList

decompiled_code:
__int64 __fastcall addProgramToList(__int64 a1, int a2, int a3, int a4)
{
unsigned int v6; // er15
size_t v7; // rbx
char *v8; // rax

v6 = programnumber++;
v7 = 24LL * programnumber;
programlist = realloc(programlist, v7);
v8 = (char *)programlist + v7 - 24;
*((_QWORD *)v8 + 1) = a1;
*(_DWORD *)v8 = a2;
*((_DWORD *)v8 + 4) = a3;
*((_DWORD *)v8 + 5) = a4;
return v6;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, int a2, int a3, int a4)
{
unsigned int v6; // er15
size_t v7; // rbx
char *v8; // rax

v6 = programnumber++;
v7 = 24LL * programnumber;
programlist = realloc(programlist, v7);
v8 = (char *)programlist + v7 - 24;
*((_QWORD *)v8 + 1) = a1;
*(_DWORD *)v8 = a2;
*((_DWORD *)v8 + 4) = a3;
*((_DWORD *)v8 + 5) = a4;
return v6;
}

original_code:
int addProgramToList(char *name, GLuint id, GLuint vertexid, GLuint fragmentid){
 int current = programnumber;
 programnumber++;
 programlist = realloc(programlist, (programnumber)*sizeof(shaderprogram_t));
 programlist[current].name = name;
 programlist[current].id = id;
 programlist[current].vertexid = vertexid;
 programlist[current].fragmentid = fragmentid;
 return current;
}

canonical_original_code:
int addProgramToList(char *name, unsigned int id, unsigned int vertexid, unsigned int fragmentid){
 int current = programnumber;
 programnumber++;
 programlist = realloc(programlist, (programnumber)*sizeof(shaderprogram_t));
 programlist[current].name = name;
 programlist[current].id = id;
 programlist[current].vertexid = vertexid;
 programlist[current].fragmentid = fragmentid;
 return current;
}

variable_types:
name
char *

variable_types:
id
unsigned int

variable_types:
vertexid
unsigned int

variable_types:
fragmentid
unsigned int

variable_types: current int


initShaderSystem

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

if ( programlist )
free(programlist);
v0 = 24LL * programnumber;
programlist = malloc(v0);
if ( !programlist )
memset(0LL, 0, v0);
addProgramToList((__int64)"default", 0, 0, 0);
return 1LL;
}

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

if ( programlist )
free(programlist);
v0 = 24LL * programnumber;
programlist = malloc(v0);
if ( !programlist )
memset(0LL, 0, v0);
func0((__int64)"default", 0, 0, 0);
return 1LL;
}

original_code:
int initShaderSystem(void){
 if(programlist) free(programlist);
 programlist = malloc(programnumber * sizeof(shaderprogram_t));
 if(!programlist) memset(programlist, 0 , programnumber * sizeof(shaderprogram_t));
 addProgramToList("default", 0, 0, 0);
 return 1;
}

canonical_original_code:
int initShaderSystem(){
 if(programlist) free(programlist);
 programlist = malloc(programnumber * sizeof(shaderprogram_t));
 if(!programlist) memset(programlist, 0 , programnumber * sizeof(shaderprogram_t));
 addProgramToList("default", 0, 0, 0);
 return 1;
}


findProgramByName

decompiled_code:
__int64 __fastcall findProgramByName(char *s1)
{
int v1; // er13
unsigned int v2; // er12
const char **i; // rbx

v1 = programnumber;
if ( programnumber <= 0 )
return 0LL;
v2 = 0;
for ( i = (const char **)((char *)programlist + 8); strcmp(s1, *i); i += 3 )
{
if ( ++v2 == v1 )
return 0LL;
}
return v2;
}

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

v1 = programnumber;
if ( programnumber <= 0 )
return 0LL;
v2 = 0;
for ( i = (const char **)((char *)programlist + 8); strcmp(s1, *i); i += 3 )
{
if ( ++v2 == v1 )
return 0LL;
}
return v2;
}

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

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

variable_types: i int


printProgramLogStatus

decompiled_code:
__int64 __fastcall printProgramLogStatus(__int64 a1)
{
unsigned int v1; // er12
__int64 result; // rax
char *v3; // r13
int v4[7]; // [rsp+Ch] [rbp-1Ch] BYREF

v4[0] = 0;
_glewGetProgramiv(a1, 35716LL, v4);
v1 = v4[0];
result = 1LL;
if ( v4[0] > 1 )
{
v3 = (char *)malloc(v4[0]);
_glewGetProgramInfoLog((unsigned int)a1, v1, 0LL, v3);
printf("program log: %s \n", v3);
free(v3);
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1)
{
unsigned int v1; // er12
__int64 result; // rax
char *v3; // r13
int v4[7]; // [rsp+Ch] [rbp-1Ch] BYREF

v4[0] = 0;
_glewGetProgramiv(a1, 35716LL, v4);
v1 = v4[0];
result = 1LL;
if ( v4[0] > 1 )
{
v3 = (char *)malloc(v4[0]);
_glewGetProgramInfoLog((unsigned int)a1, v1, 0LL, v3);
printf("program log: %s \n", v3);
free(v3);
result = 0LL;
}
return result;
}

original_code:
int printProgramLogStatus(int id){
 GLint blen = 0;
 __glewGetProgramiv(id, 0x8B84, &blen);
 if(blen > 1){
  GLchar *log = (GLchar *) malloc(blen);
  __glewGetProgramInfoLog(id, blen, 0, log);
  printf("program log: %s \n", log);
  free(log);
  return 0;
 }
 return 1;
}

canonical_original_code:
int printProgramLogStatus(int id){
 int blen = 0;
 __glewGetProgramiv(id, 0x8B84, &blen);
 if(blen > 1){
  char *log = (GLchar *) malloc(blen);
  __glewGetProgramInfoLog(id, blen, 0, log);
  printf("program log: %s \n", log);
  free(log);
  return 0;
 }
 return 1;
}

variable_types: id int

variable_types: blen int

variable_types:
log
char *


createAndLoadShader

decompiled_code:
__int64 __fastcall createAndLoadShader(void *src)
{
size_t v1; // rbx
void *v2; // rbp
size_t v3; // rbx
void *v4; // rbp
unsigned int v5; // er13
unsigned int v6; // er14
__int64 v7; // rbp
__int64 result; // rax
int v9; // [rsp+8h] [rbp-40h] BYREF
int v10; // [rsp+Ch] [rbp-3Ch] BYREF
void *ptr; // [rsp+10h] [rbp-38h] BYREF
void *v12[6]; // [rsp+18h] [rbp-30h] BYREF

v1 = strlen((const char *)src);
v2 = malloc(v1 + 5);
memcpy(v2, src, v1);
strcpy((char *)v2 + v1, ".vert");
loadFileString(v2, &ptr, &v9, 2LL);
free(v2);
if ( v9 )
{
v3 = strlen((const char *)src);
v4 = malloc(v3 + 5);
memcpy(v4, src, v3);
strcpy((char *)v4 + v3, ".frag");
loadFileString(v4, v12, &v10, 2LL);
free(v4);
if ( v10 )
{
v5 = _glewCreateShader(35633LL);
v6 = _glewCreateShader(35632LL);
_glewShaderSource(v5, 1LL, &ptr, &v9);
_glewShaderSource(v6, 1LL, v12, &v10);
free(ptr);
free(v12[0]);
_glewCompileShader(v5);
_glewCompileShader(v6);
v7 = (unsigned int)_glewCreateProgram();
_glewAttachShader(v7, v5);
_glewAttachShader((unsigned int)v7, v6);
_glewLinkProgram((unsigned int)v7);
printProgramLogStatus((unsigned int)v7);
result = (unsigned int)addProgramToList((__int64)src, v7, v5, v6);
}
else
{
free(v12[0]);
result = 0LL;
}
}
else
{
free(ptr);
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(void *src)
{
size_t v1; // rbx
void *v2; // rbp
size_t v3; // rbx
void *v4; // rbp
unsigned int v5; // er13
unsigned int v6; // er14
__int64 v7; // rbp
__int64 result; // rax
int v9; // [rsp+8h] [rbp-40h] BYREF
int v10; // [rsp+Ch] [rbp-3Ch] BYREF
void *ptr; // [rsp+10h] [rbp-38h] BYREF
void *v12[6]; // [rsp+18h] [rbp-30h] BYREF

v1 = strlen((const char *)src);
v2 = malloc(v1 + 5);
memcpy(v2, src, v1);
strcpy((char *)v2 + v1, ".vert");
loadFileString(v2, &ptr, &v9, 2LL);
free(v2);
if ( v9 )
{
v3 = strlen((const char *)src);
v4 = malloc(v3 + 5);
memcpy(v4, src, v3);
strcpy((char *)v4 + v3, ".frag");
loadFileString(v4, v12, &v10, 2LL);
free(v4);
if ( v10 )
{
v5 = _glewCreateShader(35633LL);
v6 = _glewCreateShader(35632LL);
_glewShaderSource(v5, 1LL, &ptr, &v9);
_glewShaderSource(v6, 1LL, v12, &v10);
free(ptr);
free(v12[0]);
_glewCompileShader(v5);
_glewCompileShader(v6);
v7 = (unsigned int)_glewCreateProgram();
_glewAttachShader(v7, v5);
_glewAttachShader((unsigned int)v7, v6);
_glewLinkProgram((unsigned int)v7);
func3((unsigned int)v7);
result = (unsigned int)func0((__int64)src, v7, v5, v6);
}
else
{
free(v12[0]);
result = 0LL;
}
}
else
{
free(ptr);
result = 0LL;
}
return result;
}

original_code:
int createAndLoadShader(char * name){
 char * vertname = malloc(strlen(name) + 5);
 strcpy(vertname, name);strcat(vertname, ".vert");
 char * vertstring;
 int vertlength;
 loadFileString(vertname, &vertstring, &vertlength, 2);
 free(vertname);
 if(vertlength == 0){
  free(vertstring);
  return 0;
 }
 char * fragname = malloc(strlen(name) + 5);
 strcpy(fragname,name); strcat(fragname, ".frag");
 char * fragstring;
 int fraglength;
 loadFileString(fragname, &fragstring, &fraglength, 2);
 free(fragname);
 if(fraglength == 0){
  free(fragstring);
  return 0;
 }
 GLuint vertid = __glewCreateShader(0x8B31);
 GLuint fragid = __glewCreateShader(0x8B30);
 __glewShaderSource(vertid, 1, (const GLchar**) &vertstring, &vertlength);
 __glewShaderSource(fragid, 1, (const GLchar**) &fragstring, &fraglength);
 free(vertstring); free(fragstring);
 __glewCompileShader(vertid);
 __glewCompileShader(fragid);
 GLuint programid = __glewCreateProgram();
 __glewAttachShader(programid, vertid);
 __glewAttachShader(programid, fragid);
 __glewLinkProgram(programid);
 printProgramLogStatus(programid);
 int id = addProgramToList(name, programid, vertid, fragid);
 return id;
}

canonical_original_code:
int createAndLoadShader(char *name){
 char *vertname = malloc(strlen(name) + 5);
 strcpy(vertname, name);strcat(vertname, ".vert");
 char *vertstring;
 int vertlength;
 loadFileString(vertname, &vertstring, &vertlength, 2);
 free(vertname);
 if(vertlength == 0){
  free(vertstring);
  return 0;
 }
 char *fragname = malloc(strlen(name) + 5);
 strcpy(fragname,name); strcat(fragname, ".frag");
 char *fragstring;
 int fraglength;
 loadFileString(fragname, &fragstring, &fraglength, 2);
 free(fragname);
 if(fraglength == 0){
  free(fragstring);
  return 0;
 }
 unsigned int vertid = __glewCreateShader(0x8B31);
 unsigned int fragid = __glewCreateShader(0x8B30);
 __glewShaderSource(vertid, 1, (char **) &vertstring, &vertlength);
 __glewShaderSource(fragid, 1, (char **) &fragstring, &fraglength);
 free(vertstring); free(fragstring);
 __glewCompileShader(vertid);
 __glewCompileShader(fragid);
 unsigned int programid = __glewCreateProgram();
 __glewAttachShader(programid, vertid);
 __glewAttachShader(programid, fragid);
 __glewLinkProgram(programid);
 printProgramLogStatus(programid);
 int id = addProgramToList(name, programid, vertid, fragid);
 return id;
}

variable_types:
vertname
char *

variable_types:
vertstring
char *

variable_types: vertlength int

variable_types:
fragname
char *

variable_types:
fragstring
char *

variable_types: fraglength int

variable_types:
vertid
unsigned int

variable_types:
fragid
unsigned int

variable_types:
programid
unsigned int


getProgramLogStatus

decompiled_code:
__int64 __fastcall getProgramLogStatus(__int64 a1, _QWORD *a2)
{
unsigned int v2; // er12
void *v3; // rax
int v5[7]; // [rsp+Ch] [rbp-1Ch] BYREF

v5[0] = 0;
_glewGetProgramiv(a1, 35716LL, v5);
v2 = v5[0];
if ( v5[0] > 1 )
{
v3 = malloc(v5[0]);
*a2 = v3;
_glewGetProgramInfoLog((unsigned int)a1, v2, 0LL, v3);
v2 = v5[0];
}
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1, _QWORD *a2)
{
unsigned int v2; // er12
void *v3; // rax
int v5[7]; // [rsp+Ch] [rbp-1Ch] BYREF

v5[0] = 0;
_glewGetProgramiv(a1, 35716LL, v5);
v2 = v5[0];
if ( v5[0] > 1 )
{
v3 = malloc(v5[0]);
*a2 = v3;
_glewGetProgramInfoLog((unsigned int)a1, v2, 0LL, v3);
v2 = v5[0];
}
return v2;
}

original_code:
int getProgramLogStatus(int id, char ** output){
 GLint length = 0;
 __glewGetProgramiv(id, 0x8B84, &length);
 if(length > 1){
  *output = malloc(length);
  __glewGetProgramInfoLog(id, length, 0, *output);
 }
 return length;
}

canonical_original_code:
int getProgramLogStatus(int id, char **output){
 int length = 0;
 __glewGetProgramiv(id, 0x8B84, &length);
 if(length > 1){
  *output = malloc(length);
  __glewGetProgramInfoLog(id, length, 0, *output);
 }
 return length;
}

variable_types:
output
char **

variable_types: length int


setupUniforms

decompiled_code:
__int64 setupUniforms()
{
void (__fastcall *v0)(_QWORD, float, float); // rbx
unsigned int v1; // eax
float v3; // [rsp+8h] [rbp-10h]
float v4; // [rsp+Ch] [rbp-Ch]

_glewUseProgram((unsigned int)programobject);
v0 = (void (__fastcall *)(_QWORD, float, float))_glewUniform2f;
v4 = 1.0 / (float)playheight;
v3 = 1.0 / (float)playwidth;
v1 = _glewGetUniformLocation((unsigned int)programobject, "offsetVec");
v0(v1, v3, v4);
_glewUseProgram(0LL);
return 1LL;
}

canonical_decompiled_code:
__int64 func0()
{
void (__fastcall *v0)(_QWORD, float, float); // rbx
unsigned int v1; // eax
float v3; // [rsp+8h] [rbp-10h]
float v4; // [rsp+Ch] [rbp-Ch]

_glewUseProgram((unsigned int)programobject);
v0 = (void (__fastcall *)(_QWORD, float, float))_glewUniform2f;
v4 = 1.0 / (float)playheight;
v3 = 1.0 / (float)playwidth;
v1 = _glewGetUniformLocation((unsigned int)programobject, "offsetVec");
v0(v1, v3, v4);
_glewUseProgram(0LL);
return 1LL;
}

original_code:
int setupUniforms(void){
 __glewUseProgram(programobject);
 __glewUniform2f(__glewGetUniformLocation(programobject, "offsetVec"), 1.0/(float)playwidth, 1.0/(float)playheight);
 __glewUseProgram(0);
 return 1;
}

canonical_original_code:
int setupUniforms(){
 __glewUseProgram(programobject);
 __glewUniform2f(__glewGetUniformLocation(programobject, "offsetVec"), 1.0/(float)playwidth, 1.0/(float)playheight);
 __glewUseProgram(0);
 return 1;
}


printShaderLogStatus

decompiled_code:
__int64 __fastcall printShaderLogStatus(__int64 a1)
{
unsigned int v1; // er12
__int64 result; // rax
char *v3; // r13
int v4[7]; // [rsp+Ch] [rbp-1Ch] BYREF

v4[0] = 0;
_glewGetShaderiv(a1, 35716LL, v4);
v1 = v4[0];
result = 1LL;
if ( v4[0] > 1 )
{
v3 = (char *)malloc(v4[0]);
_glewGetShaderInfoLog((unsigned int)a1, v1, 0LL, v3);
fprintf(stderr, "shader_log: %s \n", v3);
free(v3);
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1)
{
unsigned int v1; // er12
__int64 result; // rax
char *v3; // r13
int v4[7]; // [rsp+Ch] [rbp-1Ch] BYREF

v4[0] = 0;
_glewGetShaderiv(a1, 35716LL, v4);
v1 = v4[0];
result = 1LL;
if ( v4[0] > 1 )
{
v3 = (char *)malloc(v4[0]);
_glewGetShaderInfoLog((unsigned int)a1, v1, 0LL, v3);
fprintf(stderr, "shader_log: %s \n", v3);
free(v3);
result = 0LL;
}
return result;
}

original_code:
int printShaderLogStatus(int shader){
 GLint blen = 0;
 __glewGetShaderiv(shader, 0x8B84 , &blen);
 if (blen > 1){
  GLchar *log = (GLchar*)malloc(blen);
  __glewGetShaderInfoLog(shader, blen, 0, log);
  fprintf(stderr, "shader_log: %s \n", log);
  free(log);
  return 0;
 }
 return 1;
}

canonical_original_code:
int printShaderLogStatus(int shader){
 int blen = 0;
 __glewGetShaderiv(shader, 0x8B84 , &blen);
 if (blen > 1){
  char *log = (GLchar*)malloc(blen);
  __glewGetShaderInfoLog(shader, blen, 0, log);
  fprintf(stderr, "shader_log: %s \n", log);
  free(log);
  return 0;
 }
 return 1;
}

variable_types: shader int


printProgramLogStatus

decompiled_code:
__int64 __fastcall printProgramLogStatus(__int64 a1)
{
unsigned int v1; // er12
__int64 result; // rax
char *v3; // r13
int v4[7]; // [rsp+Ch] [rbp-1Ch] BYREF

v4[0] = 0;
_glewGetProgramiv(a1, 35716LL, v4);
v1 = v4[0];
result = 1LL;
if ( v4[0] > 1 )
{
v3 = (char *)malloc(v4[0]);
_glewGetProgramInfoLog((unsigned int)a1, v1, 0LL, v3);
fprintf(stderr, "program_log: %s \n", v3);
free(v3);
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1)
{
unsigned int v1; // er12
__int64 result; // rax
char *v3; // r13
int v4[7]; // [rsp+Ch] [rbp-1Ch] BYREF

v4[0] = 0;
_glewGetProgramiv(a1, 35716LL, v4);
v1 = v4[0];
result = 1LL;
if ( v4[0] > 1 )
{
v3 = (char *)malloc(v4[0]);
_glewGetProgramInfoLog((unsigned int)a1, v1, 0LL, v3);
fprintf(stderr, "program_log: %s \n", v3);
free(v3);
result = 0LL;
}
return result;
}

original_code:
int printProgramLogStatus(int program){
 GLint blen = 0;
 __glewGetProgramiv(program, 0x8B84 , &blen);
 if (blen > 1){
  GLchar *log = (GLchar*)malloc(blen);
  __glewGetProgramInfoLog(program, blen, 0, log);
  fprintf(stderr, "program_log: %s \n", log);
  free(log);
  return 0;
 }
 return 1;
}

canonical_original_code:
int printProgramLogStatus(int program){
 int blen = 0;
 __glewGetProgramiv(program, 0x8B84 , &blen);
 if (blen > 1){
  char *log = (GLchar*)malloc(blen);
  __glewGetProgramInfoLog(program, blen, 0, log);
  fprintf(stderr, "program_log: %s \n", log);
  free(log);
  return 0;
 }
 return 1;
}

variable_types: program int


initShader

decompiled_code:
__int64 initShader()
{
__int64 v0; // rdi
__int64 v1; // rdi
unsigned int v2; // er12
unsigned int v3; // eax
unsigned int v4; // ebp
unsigned int v6; // [rsp+0h] [rbp-38h] BYREF
unsigned int v7; // [rsp+4h] [rbp-34h] BYREF
int v8; // [rsp+8h] [rbp-30h] BYREF
int v9; // [rsp+Ch] [rbp-2Ch] BYREF
void *ptr; // [rsp+10h] [rbp-28h] BYREF
void *v11[4]; // [rsp+18h] [rbp-20h] BYREF

if ( !debugmode )
{
v0 = shadervertname;
if ( shadervertname )
goto LABEL_3;
LABEL_18:
fwrite("ERROR -- No vertex shader! \n", 1uLL, 0x1CuLL, stderr);
return 0LL;
}
puts("DEBUG -- Initializing Shaders");
v0 = shadervertname;
if ( !shadervertname )
goto LABEL_18;
LABEL_3:
loadfilestring(v0, &ptr, &v6);
if ( !debugmode )
{
v1 = shaderfragname;
if ( shaderfragname )
goto LABEL_5;
LABEL_20:
fwrite("ERROR -- No fragment shader! \n", 1uLL, 0x1EuLL, stderr);
return 0LL;
}
printf("DEBUG -- Vert shader loaded with size %i and contents: \n %s \n", v6, (const char *)ptr);
v1 = shaderfragname;
if ( !shaderfragname )
goto LABEL_20;
LABEL_5:
loadfilestring(v1, v11, &v7);
if ( debugmode )
printf("DEBUG -- Frag shader loaded with size %i and contents: \n %s \n", v7, (const char *)v11[0]);
v2 = _glewCreateShader(35633LL);
v3 = _glewCreateShader(35632LL);
v4 = v3;
if ( debugmode )
printf("DEBUG -- Shaders created at %i and %i\n", v2, v3);
_glewShaderSource(v2, 1LL, &ptr, &v6);
_glewShaderSource(v4, 1LL, v11, &v7);
free(ptr);
free(v11[0]);
_glewCompileShader(v2);
_glewCompileShader(v4);
_glewGetShaderiv(v2, 35713LL, &v9);
_glewGetShaderiv(v4, 35713LL, &v8);
if ( !v9 )
{
printShaderLogStatus(v2);
if ( v8 )
goto LABEL_11;
goto LABEL_14;
}
if ( !v8 )
LABEL_14:
printShaderLogStatus(v4);
LABEL_11:
programobject = _glewCreateProgram();
_glewAttachShader((unsigned int)programobject, v2);
_glewAttachShader((unsigned int)programobject, v4);
_glewLinkProgram((unsigned int)programobject);
printProgramLogStatus((unsigned int)programobject);
if ( debugmode )
puts("DEBUG -- Shader compiled and linked ");
setupUniforms();
return 1LL;
}

canonical_decompiled_code:
__int64 func3()
{
__int64 v0; // rdi
__int64 v1; // rdi
unsigned int v2; // er12
unsigned int v3; // eax
unsigned int v4; // ebp
unsigned int v6; // [rsp+0h] [rbp-38h] BYREF
unsigned int v7; // [rsp+4h] [rbp-34h] BYREF
int v8; // [rsp+8h] [rbp-30h] BYREF
int v9; // [rsp+Ch] [rbp-2Ch] BYREF
void *ptr; // [rsp+10h] [rbp-28h] BYREF
void *v11[4]; // [rsp+18h] [rbp-20h] BYREF

if ( !debugmode )
{
v0 = shadervertname;
if ( shadervertname )
goto LABEL_3;
LABEL_18:
fwrite("ERROR -- No vertex shader! \n", 1uLL, 0x1CuLL, stderr);
return 0LL;
}
puts("DEBUG -- Initializing Shaders");
v0 = shadervertname;
if ( !shadervertname )
goto LABEL_18;
LABEL_3:
loadfilestring(v0, &ptr, &v6);
if ( !debugmode )
{
v1 = shaderfragname;
if ( shaderfragname )
goto LABEL_5;
LABEL_20:
fwrite("ERROR -- No fragment shader! \n", 1uLL, 0x1EuLL, stderr);
return 0LL;
}
printf("DEBUG -- Vert shader loaded with size %i and contents: \n %s \n", v6, (const char *)ptr);
v1 = shaderfragname;
if ( !shaderfragname )
goto LABEL_20;
LABEL_5:
loadfilestring(v1, v11, &v7);
if ( debugmode )
printf("DEBUG -- Frag shader loaded with size %i and contents: \n %s \n", v7, (const char *)v11[0]);
v2 = _glewCreateShader(35633LL);
v3 = _glewCreateShader(35632LL);
v4 = v3;
if ( debugmode )
printf("DEBUG -- Shaders created at %i and %i\n", v2, v3);
_glewShaderSource(v2, 1LL, &ptr, &v6);
_glewShaderSource(v4, 1LL, v11, &v7);
free(ptr);
free(v11[0]);
_glewCompileShader(v2);
_glewCompileShader(v4);
_glewGetShaderiv(v2, 35713LL, &v9);
_glewGetShaderiv(v4, 35713LL, &v8);
if ( !v9 )
{
func1(v2);
if ( v8 )
goto LABEL_11;
goto LABEL_14;
}
if ( !v8 )
LABEL_14:
func1(v4);
LABEL_11:
programobject = _glewCreateProgram();
_glewAttachShader((unsigned int)programobject, v2);
_glewAttachShader((unsigned int)programobject, v4);
_glewLinkProgram((unsigned int)programobject);
func2((unsigned int)programobject);
if ( debugmode )
puts("DEBUG -- Shader compiled and linked ");
func0();
return 1LL;
}

original_code:
int initShader(void){
 if(debugmode) printf("DEBUG -- Initializing Shaders\n");
 char * shadervertstring;
 char * shaderfragstring;
 const int shadervertlength, shaderfraglength;
 if(shadervertname){
  loadfilestring(shadervertname, &shadervertstring, &shadervertlength);
  if(debugmode)printf("DEBUG -- Vert shader loaded with size %i and contents: \n %s \n", shadervertlength, shadervertstring);
 } else {
  fprintf(stderr, "ERROR -- No vertex shader! \n");
  return 0;
 }
 if(shaderfragname){
  loadfilestring(shaderfragname, &shaderfragstring, &shaderfraglength);
  if(debugmode)printf("DEBUG -- Frag shader loaded with size %i and contents: \n %s \n", shaderfraglength, shaderfragstring);
 } else {
  fprintf(stderr, "ERROR -- No fragment shader! \n");
  return 0;
 }
 GLuint vertshader = __glewCreateShader(0x8B31);
 GLuint fragshader = __glewCreateShader(0x8B30);
 if(debugmode) printf("DEBUG -- Shaders created at %i and %i\n", vertshader, fragshader);
 __glewShaderSource(vertshader, 1, (const GLchar **)&shadervertstring, &shadervertlength);
 __glewShaderSource(fragshader, 1, (const GLchar **)&shaderfragstring, &shaderfraglength);
 free(shadervertstring);
 free(shaderfragstring);
 __glewCompileShader(vertshader);
 __glewCompileShader(fragshader);
 GLint fragcompiled, vertcompiled ;
 __glewGetShaderiv(vertshader, 0x8B81, &vertcompiled);
 __glewGetShaderiv(fragshader, 0x8B81, &fragcompiled);
 if (!vertcompiled)printShaderLogStatus(vertshader);
 if (!fragcompiled)printShaderLogStatus(fragshader);
 programobject = __glewCreateProgram();
 __glewAttachShader(programobject, vertshader);
 __glewAttachShader(programobject, fragshader);
 __glewLinkProgram(programobject);
  printProgramLogStatus(programobject);
 if(debugmode) printf("DEBUG -- Shader compiled and linked \n");
 setupUniforms();
 return 1;
}

canonical_original_code:
int initShader(){
 if(debugmode) printf("DEBUG -- Initializing Shaders\n");
 char *shadervertstring;
 char *shaderfragstring;
 int shadervertlength; int shaderfraglength;
 if(shadervertname){
  loadfilestring(shadervertname, &shadervertstring, &shadervertlength);
  if(debugmode)printf("DEBUG -- Vert shader loaded with size %i and contents: \n %s \n", shadervertlength, shadervertstring);
 } else {
  fprintf(stderr, "ERROR -- No vertex shader! \n");
  return 0;
 }
 if(shaderfragname){
  loadfilestring(shaderfragname, &shaderfragstring, &shaderfraglength);
  if(debugmode)printf("DEBUG -- Frag shader loaded with size %i and contents: \n %s \n", shaderfraglength, shaderfragstring);
 } else {
  fprintf(stderr, "ERROR -- No fragment shader! \n");
  return 0;
 }
 unsigned int vertshader = __glewCreateShader(0x8B31);
 unsigned int fragshader = __glewCreateShader(0x8B30);
 if(debugmode) printf("DEBUG -- Shaders created at %i and %i\n", vertshader, fragshader);
 __glewShaderSource(vertshader, 1, (char **)&shadervertstring, &shadervertlength);
 __glewShaderSource(fragshader, 1, (char **)&shaderfragstring, &shaderfraglength);
 free(shadervertstring);
 free(shaderfragstring);
 __glewCompileShader(vertshader);
 __glewCompileShader(fragshader);
 int fragcompiled; int vertcompiled;
 __glewGetShaderiv(vertshader, 0x8B81, &vertcompiled);
 __glewGetShaderiv(fragshader, 0x8B81, &fragcompiled);
 if (!vertcompiled)printShaderLogStatus(vertshader);
 if (!fragcompiled)printShaderLogStatus(fragshader);
 programobject = __glewCreateProgram();
 __glewAttachShader(programobject, vertshader);
 __glewAttachShader(programobject, fragshader);
 __glewLinkProgram(programobject);
  printProgramLogStatus(programobject);
 if(debugmode) printf("DEBUG -- Shader compiled and linked \n");
 setupUniforms();
 return 1;
}

variable_types:
shadervertstring
char *

variable_types:
shaderfragstring
char *

variable_types: shadervertlength int

variable_types: shaderfraglength int

variable_types:
vertshader
unsigned int

variable_types:
fragshader
unsigned int

variable_types: fragcompiled int

variable_types: vertcompiled int


main

canonical_name: main

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

debugmode = 1;
active = 0;
slowness = 1;
skip = 0;
zoom = 1065353216;
shadervertname = (__int64)"./life.vert";
shaderfragname = (__int64)"./life.frag";
playwidth = 800;
playheight = 600;
if ( (unsigned int)sdlInit(1366LL, 768LL, 24LL) && (unsigned int)glInit() )
{
if ( argc <= 1 )
startsmall();
else
loadTexture(argv[1]);
v5 = SDL_GetTicks();
while ( 1 )
{
sdlCheckEvent();
if ( active )
break;
while ( 1 )
{
glDrawScreen(1LL);
LABEL_10:
if ( slowness <= 1 )
break;
SDL_Delay();
sdlCheckEvent();
if ( active )
goto LABEL_8;
}
}
LABEL_8:
glRender();
if ( ++v3 == 1000 )
{
v6 = SDL_GetTicks();
v7 = (float)(v6 - v5);
v5 = v6;
v3 = 0;
printf("%f fps\n", (float)(1000000.0 / v7));
}
goto LABEL_10;
}
return 0;
}

original_code:
int main(int argc, char *argv[]){
 debugmode = 1;
 active = 0;
 slowness = 1;
 skip = 0;
 zoom = 1.0f;
 int framecount, to, t;
 shadervertname = "./life.vert";
 shaderfragname = "./life.frag";
 playwidth = 800;
 playheight = 600;
 if(!sdlInit(1366, 768, 24) || !glInit()) return 0;
 if(argc >1)
  loadTexture(argv[1]);
 else startsmall();
 to = SDL_GetTicks();
 while(1){
  sdlCheckEvent();
  if(active){
   glRender();
   framecount++;
   if(framecount>999){
    t = SDL_GetTicks();
    printf("%f fps\n", 1000000.0f/(t-to));
    to = t;
    framecount = 0;
   }
  } else {
   glDrawScreen(1);
  }
 if(slowness > 1)
  SDL_Delay(slowness);
 }
 return 1;
}

canonical_original_code:
int main(int argc, char *argv[]){
 debugmode = 1;
 active = 0;
 slowness = 1;
 skip = 0;
 zoom = 1.0f;
 int framecount; int to; int t;
 shadervertname = "./life.vert";
 shaderfragname = "./life.frag";
 playwidth = 800;
 playheight = 600;
 if(!sdlInit(1366, 768, 24) || !glInit()) return 0;
 if(argc >1)
  loadTexture(argv[1]);
 else startsmall();
 to = SDL_GetTicks();
 while(1){
  sdlCheckEvent();
  if(active){
   glRender();
   framecount++;
   if(framecount>999){
    t = SDL_GetTicks();
    printf("%f fps\n", 1000000.0f/(t-to));
    to = t;
    framecount = 0;
   }
  } else {
   glDrawScreen(1);
  }
 if(slowness > 1)
  SDL_Delay(slowness);
 }
 return 1;
}

variable_types: argc int

variable_types:
argv
char *[]

variable_types: framecount int

variable_types: to int

variable_types: t int


initFB

decompiled_code:
__int64 initFB()
{
if ( !playwidth )
playwidth = 1;
if ( !playheight )
playheight = 1;
*(float *)&aspect = (float)screenWidth / (float)screenHeight;
glGenTextures(1LL, &texid1);
glBindTexture(3553LL, (unsigned int)texid1);
glTexParameteri(3553LL, 10241LL, 9729LL);
glTexParameteri(3553LL, 10240LL, 9728LL);
glTexImage2D(3553LL, 0LL, 6403LL, (unsigned int)playwidth, (unsigned int)playheight, 0LL, 6403LL, 5121LL, 0LL);
glBindTexture(3553LL, 0LL);
_glewGenFramebuffers(1LL, &fbid1);
_glewBindFramebuffer(36160LL, (unsigned int)fbid1);
_glewFramebufferTexture2D(36160LL, 36064LL, 3553LL, (unsigned int)texid1, 0LL);
glClear(16640LL);
_glewBindFramebuffer(36160LL, 0LL);
if ( debugmode )
printf("DEBUG -- Bound framebuffer1 to: %i and texture to : %i \n", (unsigned int)fbid1, (unsigned int)texid1);
glGenTextures(1LL, &texid2);
glBindTexture(3553LL, (unsigned int)texid2);
glTexParameteri(3553LL, 10241LL, 9729LL);
glTexParameteri(3553LL, 10240LL, 9728LL);
glTexImage2D(3553LL, 0LL, 6403LL, (unsigned int)playwidth, (unsigned int)playheight, 0LL, 6403LL, 5121LL, 0LL);
glBindTexture(3553LL, 0LL);
_glewGenFramebuffers(1LL, &fbid2);
_glewBindFramebuffer(36160LL, (unsigned int)fbid2);
_glewFramebufferTexture2D(36160LL, 36064LL, 3553LL, (unsigned int)texid2, 0LL);
glClear(16640LL);
_glewBindFramebuffer(36160LL, 0LL);
if ( debugmode )
printf("DEBUG -- Bound framebuffer2 to: %i and texture to : %i \n", (unsigned int)fbid2, (unsigned int)texid2);
return 1LL;
}

canonical_decompiled_code:
__int64 func0()
{
if ( !playwidth )
playwidth = 1;
if ( !playheight )
playheight = 1;
*(float *)&aspect = (float)screenWidth / (float)screenHeight;
glGenTextures(1LL, &texid1);
glBindTexture(3553LL, (unsigned int)texid1);
glTexParameteri(3553LL, 10241LL, 9729LL);
glTexParameteri(3553LL, 10240LL, 9728LL);
glTexImage2D(3553LL, 0LL, 6403LL, (unsigned int)playwidth, (unsigned int)playheight, 0LL, 6403LL, 5121LL, 0LL);
glBindTexture(3553LL, 0LL);
_glewGenFramebuffers(1LL, &fbid1);
_glewBindFramebuffer(36160LL, (unsigned int)fbid1);
_glewFramebufferTexture2D(36160LL, 36064LL, 3553LL, (unsigned int)texid1, 0LL);
glClear(16640LL);
_glewBindFramebuffer(36160LL, 0LL);
if ( debugmode )
printf("DEBUG -- Bound framebuffer1 to: %i and texture to : %i \n", (unsigned int)fbid1, (unsigned int)texid1);
glGenTextures(1LL, &texid2);
glBindTexture(3553LL, (unsigned int)texid2);
glTexParameteri(3553LL, 10241LL, 9729LL);
glTexParameteri(3553LL, 10240LL, 9728LL);
glTexImage2D(3553LL, 0LL, 6403LL, (unsigned int)playwidth, (unsigned int)playheight, 0LL, 6403LL, 5121LL, 0LL);
glBindTexture(3553LL, 0LL);
_glewGenFramebuffers(1LL, &fbid2);
_glewBindFramebuffer(36160LL, (unsigned int)fbid2);
_glewFramebufferTexture2D(36160LL, 36064LL, 3553LL, (unsigned int)texid2, 0LL);
glClear(16640LL);
_glewBindFramebuffer(36160LL, 0LL);
if ( debugmode )
printf("DEBUG -- Bound framebuffer2 to: %i and texture to : %i \n", (unsigned int)fbid2, (unsigned int)texid2);
return 1LL;
}

original_code:
int initFB(void){
 if(playwidth ==0) playwidth = 1;
 if(playheight ==0) playheight = 1;
 aspect = (float)screenWidth/(float)screenHeight;
 glGenTextures(1, &texid1);
 glBindTexture(0x0DE1, texid1);
  glTexParameteri(0x0DE1, 0x2801, 0x2601);
  glTexParameteri(0x0DE1, 0x2800, 0x2600);
  glTexImage2D(0x0DE1, 0, 0x1903, playwidth, playheight, 0, 0x1903, 0x1401, ((void *)0));
 glBindTexture(0x0DE1, 0);
 __glewGenFramebuffers(1, &fbid1);
 __glewBindFramebuffer(0x8D40, fbid1);
  __glewFramebufferTexture2D(0x8D40,0x8CE0,0x0DE1, texid1, 0);
  glClear(0x00004000 | 0x00000100);
 __glewBindFramebuffer(0x8D40, 0);
 if(debugmode) printf("DEBUG -- Bound framebuffer1 to: %i and texture to : %i \n", fbid1, texid1);
 glGenTextures(1, &texid2);
 glBindTexture(0x0DE1, texid2);
  glTexParameteri(0x0DE1, 0x2801, 0x2601);
  glTexParameteri(0x0DE1, 0x2800, 0x2600);
  glTexImage2D(0x0DE1, 0, 0x1903, playwidth, playheight, 0, 0x1903, 0x1401, ((void *)0));
 glBindTexture(0x0DE1, 0);
 __glewGenFramebuffers(1, &fbid2);
 __glewBindFramebuffer(0x8D40, fbid2);
  __glewFramebufferTexture2D(0x8D40,0x8CE0,0x0DE1, texid2, 0);
  glClear(0x00004000 | 0x00000100);
 __glewBindFramebuffer(0x8D40, 0);
 if(debugmode) printf("DEBUG -- Bound framebuffer2 to: %i and texture to : %i \n", fbid2, texid2);
 return 1;
}

canonical_original_code:
int initFB(){
 if(playwidth ==0) playwidth = 1;
 if(playheight ==0) playheight = 1;
 aspect = (float)screenWidth/(float)screenHeight;
 glGenTextures(1, &texid1);
 glBindTexture(0x0DE1, texid1);
  glTexParameteri(0x0DE1, 0x2801, 0x2601);
  glTexParameteri(0x0DE1, 0x2800, 0x2600);
  glTexImage2D(0x0DE1, 0, 0x1903, playwidth, playheight, 0, 0x1903, 0x1401, ((void *)0));
 glBindTexture(0x0DE1, 0);
 __glewGenFramebuffers(1, &fbid1);
 __glewBindFramebuffer(0x8D40, fbid1);
  __glewFramebufferTexture2D(0x8D40,0x8CE0,0x0DE1, texid1, 0);
  glClear(0x00004000 | 0x00000100);
 __glewBindFramebuffer(0x8D40, 0);
 if(debugmode) printf("DEBUG -- Bound framebuffer1 to: %i and texture to : %i \n", fbid1, texid1);
 glGenTextures(1, &texid2);
 glBindTexture(0x0DE1, texid2);
  glTexParameteri(0x0DE1, 0x2801, 0x2601);
  glTexParameteri(0x0DE1, 0x2800, 0x2600);
  glTexImage2D(0x0DE1, 0, 0x1903, playwidth, playheight, 0, 0x1903, 0x1401, ((void *)0));
 glBindTexture(0x0DE1, 0);
 __glewGenFramebuffers(1, &fbid2);
 __glewBindFramebuffer(0x8D40, fbid2);
  __glewFramebufferTexture2D(0x8D40,0x8CE0,0x0DE1, texid2, 0);
  glClear(0x00004000 | 0x00000100);
 __glewBindFramebuffer(0x8D40, 0);
 if(debugmode) printf("DEBUG -- Bound framebuffer2 to: %i and texture to : %i \n", fbid2, texid2);
 return 1;
}


initVBO

decompiled_code:
__int64 initVBO()
{
_glewGenVertexArrays(1LL, &fsvao);
_glewGenBuffers(1LL, &fsvbo);
_glewGenBuffers(1LL, &fsivbo);
_glewBindVertexArray((unsigned int)fsvao);
_glewBindBuffer(34962LL, (unsigned int)fsvbo);
_glewBufferData(34962LL, 64LL, &fsverts, 35044LL);
glEnableClientState(32884LL);
glVertexPointer(2LL, 5126LL, 16LL, 0LL);
glEnableClientState(32888LL);
glTexCoordPointer(2LL, 5126LL, 16LL, 8LL);
_glewBindBuffer(34963LL, (unsigned int)fsivbo);
_glewBufferData(34963LL, 24LL, &fsindices, 35044LL);
return 1LL;
}

canonical_decompiled_code:
__int64 func1()
{
_glewGenVertexArrays(1LL, &fsvao);
_glewGenBuffers(1LL, &fsvbo);
_glewGenBuffers(1LL, &fsivbo);
_glewBindVertexArray((unsigned int)fsvao);
_glewBindBuffer(34962LL, (unsigned int)fsvbo);
_glewBufferData(34962LL, 64LL, &fsverts, 35044LL);
glEnableClientState(32884LL);
glVertexPointer(2LL, 5126LL, 16LL, 0LL);
glEnableClientState(32888LL);
glTexCoordPointer(2LL, 5126LL, 16LL, 8LL);
_glewBindBuffer(34963LL, (unsigned int)fsivbo);
_glewBufferData(34963LL, 24LL, &fsindices, 35044LL);
return 1LL;
}

original_code:
int initVBO(void){
 __glewGenVertexArrays(1, &fsvao);
 __glewGenBuffers(1, &fsvbo);
 __glewGenBuffers(1, &fsivbo);
 __glewBindVertexArray(fsvao);
 __glewBindBuffer(0x8892, fsvbo);
 __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, fsivbo);
 __glewBufferData(0x8893, sizeof(fsindices),fsindices, 0x88E4);
 return 1;
}

canonical_original_code:
int initVBO(){
 __glewGenVertexArrays(1, &fsvao);
 __glewGenBuffers(1, &fsvbo);
 __glewGenBuffers(1, &fsivbo);
 __glewBindVertexArray(fsvao);
 __glewBindBuffer(0x8892, fsvbo);
 __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, fsivbo);
 __glewBufferData(0x8893, sizeof(fsindices),fsindices, 0x88E4);
 return 1;
}


glInit

decompiled_code:
__int64 __fastcall glInit(__int64 a1, __int64 a2)
{
unsigned int v2; // eax
__int64 result; // rax
const char *v4; // rax

if ( debugmode )
puts("DEBUG -- Initialising OpenGL ");
v2 = glewInit();
if ( v2 )
{
v4 = (const char *)glewGetErrorString(v2);
printf("Error initializing GLEW! %s\n", v4);
result = 0LL;
}
else
{
glDisable("i and texture to : %i \n", a2);
glClearColor(0.0, 0.0, 0.0, 0.5);
glEnable(3553LL);
glViewport(0LL, 0LL, (unsigned int)playwidth, (unsigned int)playheight);
glMatrixMode(5889LL);
glLoadIdentity();
glOrtho(-1.0, 1.0, -1.0, 1.0, 0.1000000014901161, 100.0);
glMatrixMode(5888LL);
glLoadIdentity();
glColor3f(1.0, 1.0);
if ( (unsigned int)initShader() && (unsigned int)initFB() )
{
initVBO();
result = 1LL;
}
else
{
result = 0LL;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, __int64 a2)
{
unsigned int v2; // eax
__int64 result; // rax
const char *v4; // rax

if ( debugmode )
puts("DEBUG -- Initialising OpenGL ");
v2 = glewInit();
if ( v2 )
{
v4 = (const char *)glewGetErrorString(v2);
printf("Error initializing GLEW! %s\n", v4);
result = 0LL;
}
else
{
glDisable("i and texture to : %i \n", a2);
glClearColor(0.0, 0.0, 0.0, 0.5);
glEnable(3553LL);
glViewport(0LL, 0LL, (unsigned int)playwidth, (unsigned int)playheight);
glMatrixMode(5889LL);
glLoadIdentity();
glOrtho(-1.0, 1.0, -1.0, 1.0, 0.1000000014901161, 100.0);
glMatrixMode(5888LL);
glLoadIdentity();
glColor3f(1.0, 1.0);
if ( (unsigned int)initShader() && (unsigned int)func0() )
{
func1();
result = 1LL;
}
else
{
result = 0LL;
}
}
return result;
}

original_code:
int glInit(void){
 if(debugmode) printf("DEBUG -- Initialising OpenGL \n");
 GLenum glewError = glewInit();
 if( glewError != 0 ){
  printf( "Error initializing GLEW! %s\n", glewGetErrorString( glewError ) );
  return 0;
 }
 glDisable(0x0B71);
 glClearColor(0.0f, 0.0f, 0.0f, 0.5f);
 glEnable(0x0DE1);
 glViewport(0, 0, playwidth, playheight);
 glMatrixMode(0x1701);
 glLoadIdentity();
 glOrtho(-1.0f, 1.0f, -1.0f, 1.0f, 0.1f, 100.0f);
 glMatrixMode(0x1700);
 glLoadIdentity();
 glColor3f(1.0f, 1.0f, 1.0f);
 if(!initShader()) return 0;
 if(!initFB()) return 0;
 initVBO();
 return 1;
}

canonical_original_code:
int glInit(){
 if(debugmode) printf("DEBUG -- Initialising OpenGL \n");
 unsigned int glewError = glewInit();
 if( glewError != 0 ){
  printf( "Error initializing GLEW! %s\n", glewGetErrorString( glewError ) );
  return 0;
 }
 glDisable(0x0B71);
 glClearColor(0.0f, 0.0f, 0.0f, 0.5f);
 glEnable(0x0DE1);
 glViewport(0, 0, playwidth, playheight);
 glMatrixMode(0x1701);
 glLoadIdentity();
 glOrtho(-1.0f, 1.0f, -1.0f, 1.0f, 0.1f, 100.0f);
 glMatrixMode(0x1700);
 glLoadIdentity();
 glColor3f(1.0f, 1.0f, 1.0f);
 if(!initShader()) return 0;
 if(!initFB()) return 0;
 initVBO();
 return 1;
}

variable_types:
glewError
unsigned int


drawfsquad

decompiled_code:
__int64 drawfsquad()
{
return glDrawElements(4LL, 6LL, 5125LL, 0LL);
}

canonical_decompiled_code:
__int64 func3()
{
return glDrawElements(4LL, 6LL, 5125LL, 0LL);
}

original_code:
void drawfsquad(void){
 glDrawElements(0x0004, 6, 0x1405, 0);
}

canonical_original_code:
void drawfsquad(){
 glDrawElements(0x0004, 6, 0x1405, 0);
}


drawsmallquad

decompiled_code:
__int64 __fastcall drawsmallquad(float a1, float a2)
{
double v2; // xmm1_8
double v3; // xmm0_8

glBegin(7LL);
glTexCoord2f(0.0);
*(_QWORD *)&v2 = LODWORD(a2) ^ (unsigned __int64)(unsigned int)LC11;
*(_QWORD *)&v3 = LODWORD(a1) ^ (unsigned __int64)(unsigned int)LC11;
glVertex3f(v3, v2, -0.5);
glTexCoord2f(COERCE_DOUBLE((unsigned __int64)LC10));
glVertex3f(COERCE_DOUBLE((unsigned __int64)LODWORD(a1)), COERCE_DOUBLE((unsigned __int64)LODWORD(v2)), -0.5);
glTexCoord2f(COERCE_DOUBLE((unsigned __int64)LC10));
glVertex3f(COERCE_DOUBLE((unsigned __int64)LODWORD(a1)), COERCE_DOUBLE((unsigned __int64)LODWORD(a2)), -0.5);
glTexCoord2f(0.0);
glVertex3f(COERCE_DOUBLE((unsigned __int64)LODWORD(v3)), COERCE_DOUBLE((unsigned __int64)LODWORD(a2)), -0.5);
return glEnd();
}

canonical_decompiled_code:
__int64 __fastcall func4(float a1, float a2)
{
double v2; // xmm1_8
double v3; // xmm0_8

glBegin(7LL);
glTexCoord2f(0.0);
*(_QWORD *)&v2 = LODWORD(a2) ^ (unsigned __int64)(unsigned int)LC11;
*(_QWORD *)&v3 = LODWORD(a1) ^ (unsigned __int64)(unsigned int)LC11;
glVertex3f(v3, v2, -0.5);
glTexCoord2f(COERCE_DOUBLE((unsigned __int64)LC10));
glVertex3f(COERCE_DOUBLE((unsigned __int64)LODWORD(a1)), COERCE_DOUBLE((unsigned __int64)LODWORD(v2)), -0.5);
glTexCoord2f(COERCE_DOUBLE((unsigned __int64)LC10));
glVertex3f(COERCE_DOUBLE((unsigned __int64)LODWORD(a1)), COERCE_DOUBLE((unsigned __int64)LODWORD(a2)), -0.5);
glTexCoord2f(0.0);
glVertex3f(COERCE_DOUBLE((unsigned __int64)LODWORD(v3)), COERCE_DOUBLE((unsigned __int64)LODWORD(a2)), -0.5);
return glEnd();
}

original_code:
void drawsmallquad(const float sizex, const float sizey){
 glBegin(0x0007);
  glTexCoord2f(0.0f, 0.0f);glVertex3f(-sizex,-sizey, -0.5f);
  glTexCoord2f(1.0f, 0.0f);glVertex3f( sizex,-sizey, -0.5f);
  glTexCoord2f(1.0f, 1.0f);glVertex3f( sizex, sizey, -0.5f);
  glTexCoord2f(0.0f, 1.0f);glVertex3f(-sizex, sizey, -0.5f);
 glEnd();
}

canonical_original_code:
void drawsmallquad(float sizex, float sizey){
 glBegin(0x0007);
  glTexCoord2f(0.0f, 0.0f);glVertex3f(-sizex,-sizey, -0.5f);
  glTexCoord2f(1.0f, 0.0f);glVertex3f( sizex,-sizey, -0.5f);
  glTexCoord2f(1.0f, 1.0f);glVertex3f( sizex, sizey, -0.5f);
  glTexCoord2f(0.0f, 1.0f);glVertex3f(-sizex, sizey, -0.5f);
 glEnd();
}

variable_types: sizex float

variable_types: sizey float