decompiled_code:
__int64 __fastcall ingame_level3_render(__int64 a1, __int64 a2)
{
int v2; // eax
double v3; // rbx
double v5; // [rsp+8h] [rbp-18h]

v2 = SDL_GetTicks(a1, a2);
v3 = fmod((double)v2 * 0.001 - *(double *)&time_offset, 0.96);
t = *(_QWORD *)&v3;
v5 = exp(v3 * -4.0);
*(double *)(a1 + 128) = (v5 + v5) * sin(v3 * 24.0);
audioplayer_getTime(*(_QWORD *)(a1 + 112));
return draw_sky_random_cubes((double *)a1);
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, __int64 a2)
{
int v2; // eax
double v3; // rbx
double v5; // [rsp+8h] [rbp-18h]

v2 = SDL_GetTicks(a1, a2);
v3 = fmod((double)v2 * 0.001 - *(double *)&time_offset, 0.96);
t = *(_QWORD *)&v3;
v5 = exp(v3 * -4.0);
*(double *)(a1 + 128) = (v5 + v5) * sin(v3 * 24.0);
audioplayer_getTime(*(_QWORD *)(a1 + 112));
return func2((double *)a1);
}

original_code:
void ingame_level3_render(Game* game){
 double time_=SDL_GetTicks()*0.001 - time_offset;
 double deltat=.960;
 t=fmod(time_,deltat);
 game->heart_beat=2*exp(-4*t)*sin(24*t);
 double music_time=audioplayer_getTime(game->audio);
 draw_sky_random_cubes(game);
}

canonical_original_code:
void ingame_level3_render(struct Game *game){
 double time_ = SDL_GetTicks()*0.001 - time_offset;
 double deltat = .960;
 t=fmod(time_,deltat);
 game->heart_beat=2*exp(-4*t)*sin(24*t);
 double music_time = audioplayer_getTime(game->audio);
 draw_sky_random_cubes(game);
}

variable_types: deltat double

user_defined_types: struct ogg_sync_state { unsigned char *data; int storage; int fill; int returned; int unsynced; int headerbytes; int bodybytes; }

user_defined_types: struct ogg_stream_state { unsigned char *body_data; long body_storage; long body_fill; long body_returned; int *lacing_vals; long *granule_vals; long lacing_storage; long lacing_fill; long lacing_packet; long lacing_returned; unsigned char header[282]; int header_fill; int e_o_s; int b_o_s; long serialno; long pageno; long packetno; long granulepos; }


decompiled_code:
__int64 __fastcall ingame_level3_setup(_QWORD *a1)
{
int v2[6]; // [rsp+0h] [rbp-20h] BYREF

audioplayer_set_next(a1[14], "music/Goto80_gopho_level3.ogg");
a1[19] = ingame_level3_update;
a1[20] = ingame_level3_render;
set_time_(0.0);
glEnable(2912LL);
glFogi(2917LL, 9729LL);
glFogf(2915LL, 0.0);
glFogf(2916LL, COERCE_DOUBLE((unsigned __int64)LC31));
v2[0] = 0;
v2[1] = 0;
v2[2] = 0;
v2[3] = 1065353216;
glFogfv(2918LL, v2);
glFogf(2914LL, COERCE_DOUBLE((unsigned __int64)LC33));
return glHint(3156LL, 4352LL);
}

canonical_decompiled_code:
__int64 __fastcall func4(_QWORD *a1)
{
int v2[6]; // [rsp+0h] [rbp-20h] BYREF

audioplayer_set_next(a1[14], "music/Goto80_gopho_level3.ogg");
a1[19] = ingame_level3_update;
a1[20] = ingame_level3_render;
set_time_(0.0);
glEnable(2912LL);
glFogi(2917LL, 9729LL);
glFogf(2915LL, 0.0);
glFogf(2916LL, COERCE_DOUBLE((unsigned __int64)LC31));
v2[0] = 0;
v2[1] = 0;
v2[2] = 0;
v2[3] = 1065353216;
glFogfv(2918LL, v2);
glFogf(2914LL, COERCE_DOUBLE((unsigned __int64)LC33));
return glHint(3156LL, 4352LL);
}

original_code:
void ingame_level3_setup(Game* game){
 audioplayer_set_next(game->audio,"music/Goto80_gopho_level3.ogg");
 game->update=ingame_level3_update;
 game->render=ingame_level3_render;
 set_time_(0);
 glEnable(0x0B60);
 glFogi(0x0B65, 0x2601);
 glFogf(0x0B63, 0);
 glFogf(0x0B64, 250);
 GLfloat fogColor[4]= {0,0, 0, 1};
 glFogfv(0x0B66, fogColor);
 glFogf(0x0B62, 0.35f);
 glHint(0x0C54, 0x1100);
}

canonical_original_code:
void ingame_level3_setup(struct Game *game){
 audioplayer_set_next(game->audio,"music/Goto80_gopho_level3.ogg");
 game->update=ingame_level3_update;
 game->render=ingame_level3_render;
 set_time_(0);
 glEnable(0x0B60);
 glFogi(0x0B65, 0x2601);
 glFogf(0x0B63, 0);
 glFogf(0x0B64, 250);
 float fogColor[4] = {0,0, 0, 1};
 glFogfv(0x0B66, fogColor);
 glFogf(0x0B62, 0.35f);
 glHint(0x0C54, 0x1100);
}

variable_types: struct Game { struct Camera { struct Game *game; double theta; double phi; double rho; double dtheta; double dphi; double drho; double ddtheta; double ddphi; double ddrho; double x; double y; double z; double fake_y; double fake_z; double dx; double dy; double dz; double ddx; double ddy; double ddz; double mConvergence; double mEyeSeparation; double mAspectRatio; double mFOV; double mNearClippingDistance; double mFarClippingDistance; int avance; double angle; double x_culling; double y_culling; } *player; struct Arrow { double x; double y; double z; double dx; double dy; double dz; struct Arrow *next; struct Arrow *prev; struct Arrow *next_update; double v; double dist; double alpha; double beta; } *arrows; struct Arrow *arrows_last; struct Arrow *arrows_to_update; struct Arrow *sorting_arrow; struct Arrow *sorting_next; int color_debug; int sorting; double world_x_size; double world_y_size; double speed_custom; struct Mechant { double x; double y; double z; double dx; double dy; double dz; double phi; double theta; double rho; double dphi; double dtheta; double drho; int type; struct Mechant *next; struct Mechant *prev; void (*update)(struct Mechant *mechant); double dist; } *mechants; struct Mechant *mechants_last; struct Particle { double x; double y; double z; double z_destination; double dx; double dy; double dz; int good; struct Particle *next; struct Particle *prev; struct Particle *next_update; struct Particle *prev_update; } *particles; struct Particle *particles_update; struct AudioPlayer { struct SoundSample { char *data; char *old_data; int size; int old_read_size; int read_size; int freq; int format; int bitStream; union soundFile { struct OggVorbis_File { void *datasource; int seekable; long offset; long end; struct ogg_sync_state { unsigned char *data; int storage; int fill; int returned; int unsynced; int headerbytes; int bodybytes; } oy; int links; long *offsets; long *dataoffsets; long *serialnos; long *pcmlengths; struct vorbis_info { int version; int channels; long rate; long bitrate_upper; long bitrate_nominal; long bitrate_lower; long bitrate_window; void *codec_setup; } *vi; struct vorbis_comment { char **user_comments; int *comment_lengths; int comments; char *vendor; } *vc; long pcm_offset; int ready_state; long current_serialno; int current_link; double bittrack; double samptrack; struct ogg_stream_state { unsigned char *body_data; long body_storage; long body_fill; long body_returned; int *lacing_vals; long *granule_vals; long lacing_storage; long lacing_fill; long lacing_packet; long lacing_returned; unsigned char header[282]; int header_fill; int e_o_s; int b_o_s; long serialno; long pageno; long packetno; long granulepos; } os; struct vorbis_dsp_state { int analysisp; struct vorbis_info *vi; float **pcm; float **pcmret; int pcm_storage; int pcm_current; int pcm_returned; int preextrapolate; int eofflag; long lW; long W; long nW; long centerW; long granulepos; long sequence; long glue_bits; long time_bits; long floor_bits; long res_bits; void *backend_state; } vd; struct vorbis_block { float **pcm; struct oggpack_buffer { long endbyte; int endbit; unsigned char *buffer; unsigned char *ptr; long storage; } opb; long lW; long W; long nW; int pcmend; int mode; int eofflag; long granulepos; long sequence; struct vorbis_dsp_state *vd; void *localstore; long localtop; long localalloc; long totaluse; struct alloc_chain { void *ptr; struct alloc_chain *next; } *reap; long glue_bits; long time_bits; long floor_bits; long res_bits; void *internal; } vb; struct ov_callbacks { unsigned long (*read_func)(void *ptr, unsigned long size, unsigned long nmemb, void *datasource); int (*seek_func)(void *datasource, long offset, int whence); int (*close_func)(void *datasource); long (*tell_func)(void *datasource); } callbacks; } oggFile; } s_file; } *s1; char *next_file_path; char *now_playing; double time_buffer_offset; unsigned int source_id; unsigned int buffer_id[2]; unsigned int sound_buffer; } *audio; double audio_amplitude; double heart_beat; double heart_beat_time; double heart_beat_time_normalized; void (*update)(struct Game *game, int dt); void (*render)(struct Game *game); void (*HUD_render)(struct Game *game); int (*mechant_regeneration_type)(); double fire_value; int fire_state; double trigger_value; int trigger_state; int FIRST_SHOT; int weapon; int stereo; void (*trigger)(struct Game *game, int state); void (*fire)(struct Game *game, int state); } *

variable_types:
fogColor
float [4]

return_type: void

user_defined_types: struct Game { struct Camera *player; struct Arrow *arrows; struct Arrow *arrows_last; struct Arrow *arrows_to_update; struct Arrow *sorting_arrow; struct Arrow *sorting_next; int color_debug; int sorting; double world_x_size; double world_y_size; double speed_custom; struct Mechant *mechants; struct Mechant *mechants_last; struct Particle *particles; struct Particle *particles_update; struct AudioPlayer *audio; double audio_amplitude; double heart_beat; double heart_beat_time; double heart_beat_time_normalized; void (*update)(struct Game *game, int dt); void (*render)(struct Game *game); void (*HUD_render)(struct Game *game); int (*mechant_regeneration_type)(); double fire_value; int fire_state; double trigger_value; int trigger_state; int FIRST_SHOT; int weapon; int stereo; void (*trigger)(struct Game *game, int state); void (*fire)(struct Game *game, int state); }

user_defined_types: struct AudioPlayer { struct SoundSample *s1; char *next_file_path; char *now_playing; double time_buffer_offset; unsigned int source_id; unsigned int buffer_id[2]; unsigned int sound_buffer; }

user_defined_types: struct SoundSample { char *data; char *old_data; int size; int old_read_size; int read_size; int freq; int format; int bitStream; union soundFile s_file; }

user_defined_types: union soundFile { struct OggVorbis_File oggFile; }

user_defined_types: struct OggVorbis_File { void *datasource; int seekable; long offset; long end; struct ogg_sync_state oy; int links; long *offsets; long *dataoffsets; long *serialnos; long *pcmlengths; struct vorbis_info *vi; struct vorbis_comment *vc; long pcm_offset; int ready_state; long current_serialno; int current_link; double bittrack; double samptrack; struct ogg_stream_state os; struct vorbis_dsp_state vd; struct vorbis_block vb; struct ov_callbacks callbacks; }

user_defined_types: struct vorbis_block { float **pcm; struct oggpack_buffer opb; long lW; long W; long nW; int pcmend; int mode; int eofflag; long granulepos; long sequence; struct vorbis_dsp_state *vd; void *localstore; long localtop; long localalloc; long totaluse; struct alloc_chain *reap; long glue_bits; long time_bits; long floor_bits; long res_bits; void *internal; }


decompiled_code:
double level3_get_time_offset()
{
return *(double *)&time_offset;
}

canonical_decompiled_code:
double func5()
{
return *(double *)&time_offset;
}

original_code:
double level3_get_time_offset(){
 return time_offset;
}

return_type: double


original_code:
static void draw_sky_random_cubes(Game* game){
 if(!skycubeinit){
  for(int i=0;i<30;i++){
   for(int j=0;j<30;j++){
    skycubes[i][j][0]=(i-30/2.)*600./30;
    skycubes[i][j][1]=(j-30/2.)*600./30;
    skycubes[i][j][2]=130;
   }
  }
  skycubeinit=1;
 }
 for(int i=0;i<30;i++){
  for(int j=0;j<30;j++){
   skycubes[i][j][2]=130;
  }
 }
 double music_time=audioplayer_getTime(game->audio);
 if(!strcmp(game->audio->now_playing,"music/Goto80_gopho_level3.ogg")){
  if(music_time>49.80){
   game->heart_beat=0;
   double xxx =(music_time-49.80)/2.;
   for (int j=0;j<30;j++){
    for (int i=0;i<30;i++){
     skycubes[i][j][2]+=150*xxx;
    }
   }
   change_bg_color(xxx,xxx,xxx);
  }
 }
 for (int j=0;j<30;j++){
  for (int i=0;i<30;i++){
   game_loop_coord(game,&skycubes[i][j][0], &skycubes[i][j][1]);
   double front_x=game->player->x_culling - game->player->x;
   double front_y=game->player->y_culling - game->player->y;
   front_x*=30;
   front_y*=30;
   front_x=front_x + game->player->x;
   front_y=front_y + game->player->y;
   double alpha = atan2((skycubes[i][j][1]+front_y),(skycubes[i][j][0]+front_x))*180./3.14159265359;
   alpha = alpha+game->player->phi;
   while(alpha<=0) alpha+=360;
   while(alpha>360) alpha-=360;
   if(alpha <90||alpha>360-90){
    double xx=skycubes[i][j][0]+game->player->x;
    double yy=skycubes[i][j][1]+game->player->y;
    xx*=xx;
    yy*=yy;
    double dist= sqrt (xx+yy) / 600.;
    double z_size=80.;
    skycubes[i][j][2]+=
     -20*cos(i*6*3.14159265359/30 +SDL_GetTicks()*0.001)
     -10*cos(i*12*3.14159265359/30 -SDL_GetTicks()*0.002)
     -20*cos(j*8*3.14159265359/30 +SDL_GetTicks()*0.001);
     -10*cos(j*10*3.14159265359/30 -SDL_GetTicks()*0.003);
    glPushMatrix();
     glTranslated(
      skycubes[i][j][0],
      skycubes[i][j][1],
      ( skycubes[i][j][2] - dist*200 + 20*cos(dist*2*3.14159265359 +.001*game->heart_beat)*game->heart_beat)
      +z_size/2.);
     glScaled(500./30,500./30,-z_size);
     simple_cube_color(.5-dist*.5,0,0,0,0,0);
    glPopMatrix();
    glPushMatrix();
     glTranslated(
      skycubes[i][j][0],
      skycubes[i][j][1],
      -skycubes[i][j][2] + dist*200 - 20*cos(dist*2*3.14159265359)*game->heart_beat
      -z_size/2.);
     glScaled(500./30,500./30,z_size);
     simple_cube_color(.2-dist*.2,0,0,0,0,0);
    glPopMatrix();
   }
  }
 }
}

canonical_original_code:
static void draw_sky_random_cubes(struct Game *game){
 if(!skycubeinit){
  for(int i = 0;i<30;i++){
   for(int j = 0;j<30;j++){
    skycubes[i][j][0]=(i-30/2.)*600./30;
    skycubes[i][j][1]=(j-30/2.)*600./30;
    skycubes[i][j][2]=130;
   }
  }
  skycubeinit=1;
 }
 for(int i = 0;i<30;i++){
  for(int j = 0;j<30;j++){
   skycubes[i][j][2]=130;
  }
 }
 double music_time = audioplayer_getTime(game->audio);
 if(!strcmp(game->audio->now_playing,"music/Goto80_gopho_level3.ogg")){
  if(music_time>49.80){
   game->heart_beat=0;
   double xxx = (music_time-49.80)/2.;
   for (int j = 0;j<30;j++){
    for (int i = 0;i<30;i++){
     skycubes[i][j][2]+=150*xxx;
    }
   }
   change_bg_color(xxx,xxx,xxx);
  }
 }
 for (int j = 0;j<30;j++){
  for (int i = 0;i<30;i++){
   game_loop_coord(game,&skycubes[i][j][0], &skycubes[i][j][1]);
   double front_x = game->player->x_culling - game->player->x;
   double front_y = game->player->y_culling - game->player->y;
   front_x*=30;
   front_y*=30;
   front_x=front_x + game->player->x;
   front_y=front_y + game->player->y;
   double alpha = atan2((skycubes[i][j][1]+front_y),(skycubes[i][j][0]+front_x))*180./3.14159265359;
   alpha = alpha+game->player->phi;
   while(alpha<=0) alpha+=360;
   while(alpha>360) alpha-=360;
   if(alpha <90||alpha>360-90){
    double xx = skycubes[i][j][0]+game->player->x;
    double yy = skycubes[i][j][1]+game->player->y;
    xx*=xx;
    yy*=yy;
    double dist = sqrt (xx+yy) / 600.;
    double z_size = 80.;
    skycubes[i][j][2]+=
     -20*cos(i*6*3.14159265359/30 +SDL_GetTicks()*0.001)
     -10*cos(i*12*3.14159265359/30 -SDL_GetTicks()*0.002)
     -20*cos(j*8*3.14159265359/30 +SDL_GetTicks()*0.001);
     -10*cos(j*10*3.14159265359/30 -SDL_GetTicks()*0.003);
    glPushMatrix();
     glTranslated(
      skycubes[i][j][0],
      skycubes[i][j][1],
      ( skycubes[i][j][2] - dist*200 + 20*cos(dist*2*3.14159265359 +.001*game->heart_beat)*game->heart_beat)
      +z_size/2.);
     glScaled(500./30,500./30,-z_size);
     simple_cube_color(.5-dist*.5,0,0,0,0,0);
    glPopMatrix();
    glPushMatrix();
     glTranslated(
      skycubes[i][j][0],
      skycubes[i][j][1],
      -skycubes[i][j][2] + dist*200 - 20*cos(dist*2*3.14159265359)*game->heart_beat
      -z_size/2.);
     glScaled(500./30,500./30,z_size);
     simple_cube_color(.2-dist*.2,0,0,0,0,0);
    glPopMatrix();
   }
  }
 }
}

variable_types: i int

variable_types: j int

variable_types: xxx double

variable_types: alpha double

variable_types: xx double

variable_types: yy double

variable_types: dist double

user_defined_types: struct Camera { struct Game *game; double theta; double phi; double rho; double dtheta; double dphi; double drho; double ddtheta; double ddphi; double ddrho; double x; double y; double z; double fake_y; double fake_z; double dx; double dy; double dz; double ddx; double ddy; double ddz; double mConvergence; double mEyeSeparation; double mAspectRatio; double mFOV; double mNearClippingDistance; double mFarClippingDistance; int avance; double angle; double x_culling; double y_culling; }

user_defined_types: struct Arrow { double x; double y; double z; double dx; double dy; double dz; struct Arrow *next; struct Arrow *prev; struct Arrow *next_update; double v; double dist; double alpha; double beta; }

user_defined_types: struct Mechant { double x; double y; double z; double dx; double dy; double dz; double phi; double theta; double rho; double dphi; double dtheta; double drho; int type; struct Mechant *next; struct Mechant *prev; void (*update)(struct Mechant *mechant); double dist; }

user_defined_types: struct Particle { double x; double y; double z; double z_destination; double dx; double dy; double dz; int good; struct Particle *next; struct Particle *prev; struct Particle *next_update; struct Particle *prev_update; }

user_defined_types: struct vorbis_dsp_state { int analysisp; struct vorbis_info *vi; float **pcm; float **pcmret; int pcm_storage; int pcm_current; int pcm_returned; int preextrapolate; int eofflag; long lW; long W; long nW; long centerW; long granulepos; long sequence; long glue_bits; long time_bits; long floor_bits; long res_bits; void *backend_state; }

user_defined_types: struct ov_callbacks { unsigned long (*read_func)(void *ptr, unsigned long size, unsigned long nmemb, void *datasource); int (*seek_func)(void *datasource, long offset, int whence); int (*close_func)(void *datasource); long (*tell_func)(void *datasource); }

user_defined_types: struct vorbis_info { int version; int channels; long rate; long bitrate_upper; long bitrate_nominal; long bitrate_lower; long bitrate_window; void *codec_setup; }

user_defined_types: struct vorbis_comment { char **user_comments; int *comment_lengths; int comments; char *vendor; }

user_defined_types: struct oggpack_buffer { long endbyte; int endbit; unsigned char *buffer; unsigned char *ptr; long storage; }

user_defined_types: struct alloc_chain { void *ptr; struct alloc_chain *next; }


decompiled_code:
_QWORD **new_audioplayer()
{
_QWORD **v0; // rbx
__int64 v1; // rax

v0 = (_QWORD **)malloc(0x30uLL);
alGenSources(1LL, v0 + 4);
alSourceStop(*((unsigned int *)v0 + 8));
alSource3f(*((unsigned int *)v0 + 8), 4100LL, 0.0, 0.0);
alGenBuffers(2LL, (char *)v0 + 36);
v0[1] = 0LL;
v0[3] = 0LL;
v1 = sound_loadSample("music/silence.ogg");
*v0 = (_QWORD *)v1;
v0[2] = "music/silence.ogg";
if ( v1 )
{
if ( (unsigned int)sound_nextSample(v1) )
{
alBufferData(
*((unsigned int *)v0 + 9),
*((unsigned int *)*v0 + 8),
**v0,
*((unsigned int *)*v0 + 6),
*((unsigned int *)*v0 + 7));
if ( !(unsigned int)sound_nextSample(*v0) )
{
sound_seekSample(*v0);
sound_nextSample(*v0);
}
alBufferData(
*((unsigned int *)v0 + 10),
*((unsigned int *)*v0 + 8),
**v0,
*((unsigned int *)*v0 + 6),
*((unsigned int *)*v0 + 7));
alSourceQueueBuffers(*((unsigned int *)v0 + 8), 2LL, (char *)v0 + 36);
alSourcePlay(*((unsigned int *)v0 + 8));
}
else
{
puts("FILE EMPTY, COULD NOT PLAY");
sound_closeSample(*v0);
v0 = 0LL;
}
}
else
{
printf(format, v0[1]);
v0 = 0LL;
}
return v0;
}

canonical_decompiled_code:
_QWORD **func2()
{
_QWORD **v0; // rbx
__int64 v1; // rax

v0 = (_QWORD **)malloc(0x30uLL);
alGenSources(1LL, v0 + 4);
alSourceStop(*((unsigned int *)v0 + 8));
alSource3f(*((unsigned int *)v0 + 8), 4100LL, 0.0, 0.0);
alGenBuffers(2LL, (char *)v0 + 36);
v0[1] = 0LL;
v0[3] = 0LL;
v1 = sound_loadSample("music/silence.ogg");
*v0 = (_QWORD *)v1;
v0[2] = "music/silence.ogg";
if ( v1 )
{
if ( (unsigned int)sound_nextSample(v1) )
{
alBufferData(
*((unsigned int *)v0 + 9),
*((unsigned int *)*v0 + 8),
**v0,
*((unsigned int *)*v0 + 6),
*((unsigned int *)*v0 + 7));
if ( !(unsigned int)sound_nextSample(*v0) )
{
sound_seekSample(*v0);
sound_nextSample(*v0);
}
alBufferData(
*((unsigned int *)v0 + 10),
*((unsigned int *)*v0 + 8),
**v0,
*((unsigned int *)*v0 + 6),
*((unsigned int *)*v0 + 7));
alSourceQueueBuffers(*((unsigned int *)v0 + 8), 2LL, (char *)v0 + 36);
alSourcePlay(*((unsigned int *)v0 + 8));
}
else
{
puts("FILE EMPTY, COULD NOT PLAY");
sound_closeSample(*v0);
v0 = 0LL;
}
}
else
{
printf(format, v0[1]);
v0 = 0LL;
}
return v0;
}

original_code:
AudioPlayer* new_audioplayer(){
 AudioPlayer* player;
 player = malloc (sizeof(AudioPlayer));
 alGenSources (1, &player->source_id);
 alSourceStop (player->source_id);
 alSource3f (player->source_id, 0x1004, 0.0, 0.0, 0.0);
 alGenBuffers (2, player->buffer_id);
 player->next_file_path=((void *)0);
 player->time_buffer_offset=0;
 player->s1 = sound_loadSample ("music/silence.ogg");
 player->now_playing="music/silence.ogg";
 if (player->s1 == ((void *)0)) {
  printf("ERROR : STUPID SILENT FILE MISSING X¬D NEED : \"%s\"\n",player->next_file_path);
  return ((void *)0);
 }
 if (!sound_nextSample (player->s1)) {
  printf("FILE EMPTY, COULD NOT PLAY\n");
  sound_closeSample (player->s1);
  return ((void *)0);
 }
 alBufferData (player->buffer_id[0], player->s1->format, player->s1->data, player->s1->read_size, player->s1->freq);
 if (sound_nextSample (player->s1)==0) {
  sound_seekSample (player->s1);
  sound_nextSample (player->s1);
 }
 alBufferData (player->buffer_id[1], player->s1->format, player->s1->data, player->s1->read_size, player->s1->freq);
 alSourceQueueBuffers (player->source_id, 2, player->buffer_id);
 alSourcePlay (player->source_id);
 return player;
}

canonical_original_code:
struct AudioPlayer *new_audioplayer(){
 struct AudioPlayer *player;
 player = malloc (sizeof(AudioPlayer));
 alGenSources (1, &player->source_id);
 alSourceStop (player->source_id);
 alSource3f (player->source_id, 0x1004, 0.0, 0.0, 0.0);
 alGenBuffers (2, player->buffer_id);
 player->next_file_path=((void *)0);
 player->time_buffer_offset=0;
 player->s1 = sound_loadSample ("music/silence.ogg");
 player->now_playing="music/silence.ogg";
 if (player->s1 == ((void *)0)) {
  printf("ERROR : STUPID SILENT FILE MISSING X¬D NEED : \"%s\"\n",player->next_file_path);
  return ((void *)0);
 }
 if (!sound_nextSample (player->s1)) {
  printf("FILE EMPTY, COULD NOT PLAY\n");
  sound_closeSample (player->s1);
  return ((void *)0);
 }
 alBufferData (player->buffer_id[0], player->s1->format, player->s1->data, player->s1->read_size, player->s1->freq);
 if (sound_nextSample (player->s1)==0) {
  sound_seekSample (player->s1);
  sound_nextSample (player->s1);
 }
 alBufferData (player->buffer_id[1], player->s1->format, player->s1->data, player->s1->read_size, player->s1->freq);
 alSourceQueueBuffers (player->source_id, 2, player->buffer_id);
 alSourcePlay (player->source_id);
 return player;
}

variable_types: struct AudioPlayer { struct SoundSample { char *data; char *old_data; int size; int old_read_size; int read_size; int freq; int format; int bitStream; union soundFile { struct OggVorbis_File { void *datasource; int seekable; long offset; long end; struct ogg_sync_state { unsigned char *data; int storage; int fill; int returned; int unsynced; int headerbytes; int bodybytes; } oy; int links; long *offsets; long *dataoffsets; long *serialnos; long *pcmlengths; struct vorbis_info { int version; int channels; long rate; long bitrate_upper; long bitrate_nominal; long bitrate_lower; long bitrate_window; void *codec_setup; } *vi; struct vorbis_comment { char **user_comments; int *comment_lengths; int comments; char *vendor; } *vc; long pcm_offset; int ready_state; long current_serialno; int current_link; double bittrack; double samptrack; struct ogg_stream_state { unsigned char *body_data; long body_storage; long body_fill; long body_returned; int *lacing_vals; long *granule_vals; long lacing_storage; long lacing_fill; long lacing_packet; long lacing_returned; unsigned char header[282]; int header_fill; int e_o_s; int b_o_s; long serialno; long pageno; long packetno; long granulepos; } os; struct vorbis_dsp_state { int analysisp; struct vorbis_info *vi; float **pcm; float **pcmret; int pcm_storage; int pcm_current; int pcm_returned; int preextrapolate; int eofflag; long lW; long W; long nW; long centerW; long granulepos; long sequence; long glue_bits; long time_bits; long floor_bits; long res_bits; void *backend_state; } vd; struct vorbis_block { float **pcm; struct oggpack_buffer { long endbyte; int endbit; unsigned char *buffer; unsigned char *ptr; long storage; } opb; long lW; long W; long nW; int pcmend; int mode; int eofflag; long granulepos; long sequence; struct vorbis_dsp_state *vd; void *localstore; long localtop; long localalloc; long totaluse; struct alloc_chain { void *ptr; struct alloc_chain *next; } *reap; long glue_bits; long time_bits; long floor_bits; long res_bits; void *internal; } vb; struct ov_callbacks { unsigned long (*read_func)(void *ptr, unsigned long size, unsigned long nmemb, void *datasource); int (*seek_func)(void *datasource, long offset, int whence); int (*close_func)(void *datasource); long (*tell_func)(void *datasource); } callbacks; } oggFile; } s_file; } *s1; char *next_file_path; char *now_playing; double time_buffer_offset; unsigned int source_id; unsigned int buffer_id[2]; unsigned int sound_buffer; } *


decompiled_code:
__int64 __fastcall audioplayer_play(__int64 a1)
{
return alSourcePlay(*(unsigned int *)(a1 + 32));
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1)
{
return alSourcePlay(*(unsigned int *)(a1 + 32));
}

original_code:
void audioplayer_play(AudioPlayer* player){
  alSourcePlay (player->source_id);
}

canonical_original_code:
void audioplayer_play(struct AudioPlayer *player){
  alSourcePlay (player->source_id);
}

user_defined_types: struct ogg_sync_state { unsigned char *data; int storage; int fill; int returned; int unsynced; int headerbytes; int bodybytes; }

user_defined_types: struct ogg_stream_state { unsigned char *body_data; long body_storage; long body_fill; long body_returned; int *lacing_vals; long *granule_vals; long lacing_storage; long lacing_fill; long lacing_packet; long lacing_returned; unsigned char header[282]; int header_fill; int e_o_s; int b_o_s; long serialno; long pageno; long packetno; long granulepos; }


decompiled_code:
__int64 __fastcall audioplayer_pause(__int64 a1)
{
return alSourcePause(*(unsigned int *)(a1 + 32));
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1)
{
return alSourcePause(*(unsigned int *)(a1 + 32));
}

original_code:
void audioplayer_pause(AudioPlayer* player){
  alSourcePause (player->source_id);
}

canonical_original_code:
void audioplayer_pause(struct AudioPlayer *player){
  alSourcePause (player->source_id);
}

user_defined_types: struct AudioPlayer { struct SoundSample *s1; char *next_file_path; char *now_playing; double time_buffer_offset; unsigned int source_id; unsigned int buffer_id[2]; unsigned int sound_buffer; }


decompiled_code:
void __fastcall audioplayer_set_next(__int64 a1, __int64 a2)
{
*(_QWORD *)(a1 + 8) = a2;
}

canonical_decompiled_code:
void __fastcall func5(__int64 a1, __int64 a2)
{
*(_QWORD *)(a1 + 8) = a2;
}

original_code:
void audioplayer_set_next(AudioPlayer* player, char * path){
 player->next_file_path=path;
}

canonical_original_code:
void audioplayer_set_next(struct AudioPlayer *player, char *path){
 player->next_file_path=path;
}

variable_types:
path
char *

user_defined_types: struct SoundSample { char *data; char *old_data; int size; int old_read_size; int read_size; int freq; int format; int bitStream; union soundFile s_file; }


decompiled_code:
double __fastcall audioplayer_getTime(__int64 a1)
{
float v2[3]; // [rsp+Ch] [rbp-14h] BYREF

alGetSourcef(*(unsigned int *)(a1 + 32), 4133LL, v2);
return (float)(v2[0] / (float)*(int *)(*(_QWORD *)a1 + 28LL)) + *(double *)(a1 + 24);
}

canonical_decompiled_code:
double __fastcall func6(__int64 a1)
{
float v2[3]; // [rsp+Ch] [rbp-14h] BYREF

alGetSourcef(*(unsigned int *)(a1 + 32), 4133LL, v2);
return (float)(v2[0] / (float)*(int *)(*(_QWORD *)a1 + 28LL)) + *(double *)(a1 + 24);
}

original_code:
double audioplayer_getTime(AudioPlayer* player){
 float time_position;
 alGetSourcef( player->source_id, 0x1025, &time_position );
 time_position/=player->s1->freq;
 return time_position + player->time_buffer_offset;
}

canonical_original_code:
double audioplayer_getTime(struct AudioPlayer *player){
 float time_position;
 alGetSourcef( player->source_id, 0x1025, &time_position );
 time_position/=player->s1->freq;
 return time_position + player->time_buffer_offset;
}

user_defined_types: union soundFile { struct OggVorbis_File oggFile; }


original_code:
double audioplayer_getAmplitude(AudioPlayer* player, int time_dt){
 float time_position;
 alGetSourcef( player->source_id, 0x1025, &time_position );
 int begin = (int)time_position*4;
 {
  int delta=time_dt*player->s1->freq*.001;
  int end =delta+begin;
  if(end>player->s1->old_read_size)
   end=player->s1->old_read_size;
  double ret=0;
  int i;
  for(i=begin+1;i<end;i+=4){
   ret+=pow(fabs(player->s1->old_data[i]/128.),4);
  }
  i-=begin;
  ret=ret/i*50;
  if(i==0)ret=0;
  return ret;
 }
}

canonical_original_code:
double audioplayer_getAmplitude(struct AudioPlayer *player, int time_dt){
 float time_position;
 alGetSourcef( player->source_id, 0x1025, &time_position );
 int begin = (int)time_position*4;
 {
  int delta = time_dt*player->s1->freq*.001;
  int end = delta+begin;
  if(end>player->s1->old_read_size)
   end=player->s1->old_read_size;
  double ret = 0;
  int i;
  for(i=begin+1;i<end;i+=4){
   ret+=pow(fabs(player->s1->old_data[i]/128.),4);
  }
  i-=begin;
  ret=ret/i*50;
  if(i==0)ret=0;
  return ret;
 }
}

variable_types: begin int

variable_types: delta int

variable_types: end int

variable_types: ret double

user_defined_types: struct OggVorbis_File { void *datasource; int seekable; long offset; long end; struct ogg_sync_state oy; int links; long *offsets; long *dataoffsets; long *serialnos; long *pcmlengths; struct vorbis_info *vi; struct vorbis_comment *vc; long pcm_offset; int ready_state; long current_serialno; int current_link; double bittrack; double samptrack; struct ogg_stream_state os; struct vorbis_dsp_state vd; struct vorbis_block vb; struct ov_callbacks callbacks; }


decompiled_code:
int __fastcall audioplayer_update(double *a1)
{
int result; // eax
int v2; // xmm0_4
int v3; // xmm0_4

alGetSourcei(*((unsigned int *)a1 + 8), 4118LL, &no_buf);
for ( result = no_buf--; result; result = no_buf-- )
{
alSourceUnqueueBuffers(*((unsigned int *)a1 + 8), 1LL, &buf);
a1[3] = *(float *)&buf_time + a1[3];
buf_time = buf_time_next;
if ( music_changed )
{
music_changed = 0;
a1[3] = 0.0;
*((_QWORD *)a1 + 2) = next_file_path;
}
if ( music_looped )
{
music_looped = 0;
a1[3] = 0.0;
}
if ( cache )
{
alBufferData(
(unsigned int)buf,
*(unsigned int *)(*(_QWORD *)a1 + 32LL),
**(_QWORD **)a1,
*(unsigned int *)(*(_QWORD *)a1 + 24LL),
*(unsigned int *)(*(_QWORD *)a1 + 28LL));
alSourceQueueBuffers(*((unsigned int *)a1 + 8), 1LL, &buf);
*(float *)&v2 = (double)*(int *)(*(_QWORD *)a1 + 24LL) / (double)*(int *)(*(_QWORD *)a1 + 28LL) * 0.25;
buf_time_next = v2;
}
else
{
if ( *((_QWORD *)a1 + 1) )
{
sound_closeSample(*(_QWORD *)a1);
*(_QWORD *)a1 = sound_loadSample(*((_QWORD *)a1 + 1));
next_file_path = *((_QWORD *)a1 + 1);
a1[1] = 0.0;
music_changed = 1;
}
else
{
if ( !*(_QWORD *)a1 )
return puts("ERROR : SOUND CRASHED");
music_looped = 1;
sound_seekSample(*(_QWORD *)a1);
}
sound_nextSample(*(_QWORD *)a1);
alBufferData(
(unsigned int)buf,
*(unsigned int *)(*(_QWORD *)a1 + 32LL),
**(_QWORD **)a1,
*(unsigned int *)(*(_QWORD *)a1 + 24LL),
*(unsigned int *)(*(_QWORD *)a1 + 28LL));
alSourceQueueBuffers(*((unsigned int *)a1 + 8), 1LL, &buf);
alSourcePlay(*((unsigned int *)a1 + 8));
*(float *)&v3 = (double)*(int *)(*(_QWORD *)a1 + 24LL) / (double)*(int *)(*(_QWORD *)a1 + 28LL) * 0.25;
buf_time_next = v3;
}
cache = sound_nextSample(*(_QWORD *)a1);
}
return result;
}

canonical_decompiled_code:
int __fastcall func8(double *a1)
{
int result; // eax
int v2; // xmm0_4
int v3; // xmm0_4

alGetSourcei(*((unsigned int *)a1 + 8), 4118LL, &no_buf);
for ( result = no_buf--; result; result = no_buf-- )
{
alSourceUnqueueBuffers(*((unsigned int *)a1 + 8), 1LL, &buf);
a1[3] = *(float *)&buf_time + a1[3];
buf_time = buf_time_next;
if ( music_changed )
{
music_changed = 0;
a1[3] = 0.0;
*((_QWORD *)a1 + 2) = next_file_path;
}
if ( music_looped )
{
music_looped = 0;
a1[3] = 0.0;
}
if ( cache )
{
alBufferData(
(unsigned int)buf,
*(unsigned int *)(*(_QWORD *)a1 + 32LL),
**(_QWORD **)a1,
*(unsigned int *)(*(_QWORD *)a1 + 24LL),
*(unsigned int *)(*(_QWORD *)a1 + 28LL));
alSourceQueueBuffers(*((unsigned int *)a1 + 8), 1LL, &buf);
*(float *)&v2 = (double)*(int *)(*(_QWORD *)a1 + 24LL) / (double)*(int *)(*(_QWORD *)a1 + 28LL) * 0.25;
buf_time_next = v2;
}
else
{
if ( *((_QWORD *)a1 + 1) )
{
sound_closeSample(*(_QWORD *)a1);
*(_QWORD *)a1 = sound_loadSample(*((_QWORD *)a1 + 1));
next_file_path = *((_QWORD *)a1 + 1);
a1[1] = 0.0;
music_changed = 1;
}
else
{
if ( !*(_QWORD *)a1 )
return puts("ERROR : SOUND CRASHED");
music_looped = 1;
sound_seekSample(*(_QWORD *)a1);
}
sound_nextSample(*(_QWORD *)a1);
alBufferData(
(unsigned int)buf,
*(unsigned int *)(*(_QWORD *)a1 + 32LL),
**(_QWORD **)a1,
*(unsigned int *)(*(_QWORD *)a1 + 24LL),
*(unsigned int *)(*(_QWORD *)a1 + 28LL));
alSourceQueueBuffers(*((unsigned int *)a1 + 8), 1LL, &buf);
alSourcePlay(*((unsigned int *)a1 + 8));
*(float *)&v3 = (double)*(int *)(*(_QWORD *)a1 + 24LL) / (double)*(int *)(*(_QWORD *)a1 + 28LL) * 0.25;
buf_time_next = v3;
}
cache = sound_nextSample(*(_QWORD *)a1);
}
return result;
}

original_code:
void audioplayer_update (AudioPlayer * player) {
   alGetSourcei (player->source_id, 0x1016, &no_buf);
   while(no_buf--){
    alSourceUnqueueBuffers (player->source_id, 1, &buf);
    player->time_buffer_offset+=buf_time;
    buf_time=buf_time_next;
    if(music_changed){
     music_changed=0;
     player->time_buffer_offset=0;
     player->now_playing=next_file_path;
    }
    if(music_looped){
     music_looped=0;
     player->time_buffer_offset=0;
    }
    if (cache) {
     alBufferData (buf, player->s1->format, player->s1->data, player->s1->read_size, player->s1->freq);
     alSourceQueueBuffers (player->source_id, 1, &buf);
     buf_time_next=player->s1->read_size/(double)player->s1->freq/4.;
    } else {
     if(player->next_file_path){
      sound_closeSample(player->s1);
      player->s1=sound_loadSample(player->next_file_path);
      next_file_path=player->next_file_path;
      player->next_file_path=((void *)0);
      music_changed=1;
     }
     else if(player->s1!=((void *)0)){
      music_looped=1;
      sound_seekSample (player->s1);
     }else{
      printf("ERROR : SOUND CRASHED\n");
      break;
     }
     sound_nextSample (player->s1);
     alBufferData (buf, player->s1->format, player->s1->data, player->s1->read_size, player->s1->freq);
     alSourceQueueBuffers (player->source_id, 1, &buf);
     alSourcePlay (player->source_id);
     buf_time_next=player->s1->read_size/(double)player->s1->freq/4.;
    }
     cache = sound_nextSample (player->s1);
   }
}

canonical_original_code:
void audioplayer_update(struct AudioPlayer *player) {
   alGetSourcei (player->source_id, 0x1016, &no_buf);
   while(no_buf--){
    alSourceUnqueueBuffers (player->source_id, 1, &buf);
    player->time_buffer_offset+=buf_time;
    buf_time=buf_time_next;
    if(music_changed){
     music_changed=0;
     player->time_buffer_offset=0;
     player->now_playing=next_file_path;
    }
    if(music_looped){
     music_looped=0;
     player->time_buffer_offset=0;
    }
    if (cache) {
     alBufferData (buf, player->s1->format, player->s1->data, player->s1->read_size, player->s1->freq);
     alSourceQueueBuffers (player->source_id, 1, &buf);
     buf_time_next=player->s1->read_size/(double)player->s1->freq/4.;
    } else {
     if(player->next_file_path){
      sound_closeSample(player->s1);
      player->s1=sound_loadSample(player->next_file_path);
      next_file_path=player->next_file_path;
      player->next_file_path=((void *)0);
      music_changed=1;
     }
     else if(player->s1!=((void *)0)){
      music_looped=1;
      sound_seekSample (player->s1);
     }else{
      printf("ERROR : SOUND CRASHED\n");
      break;
     }
     sound_nextSample (player->s1);
     alBufferData (buf, player->s1->format, player->s1->data, player->s1->read_size, player->s1->freq);
     alSourceQueueBuffers (player->source_id, 1, &buf);
     alSourcePlay (player->source_id);
     buf_time_next=player->s1->read_size/(double)player->s1->freq/4.;
    }
     cache = sound_nextSample (player->s1);
   }
}

user_defined_types: struct vorbis_block { float **pcm; struct oggpack_buffer opb; long lW; long W; long nW; int pcmend; int mode; int eofflag; long granulepos; long sequence; struct vorbis_dsp_state *vd; void *localstore; long localtop; long localalloc; long totaluse; struct alloc_chain *reap; long glue_bits; long time_bits; long floor_bits; long res_bits; void *internal; }


decompiled_code:
time_t random_init()
{
unsigned int v0; // eax
time_t result; // rax

v0 = time(0LL);
srand(v0);
result = time(0LL);
x = result;
return result;
}

canonical_decompiled_code:
time_t func0()
{
unsigned int v0; // eax
time_t result; // rax

v0 = time(0LL);
srand(v0);
result = time(0LL);
x = result;
return result;
}

original_code:
void random_init(){
 srand((unsigned)time(((void *)0)));
 x=(unsigned)time(((void *)0));
}

canonical_original_code:
void random_init(){
 srand((unsigned int)time(((void *)0)));
 x=(unsigned int)time(((void *)0));
}


original_code:
double random_simple(){
 x = 1103515245 * x + 12345;
 return x*invert_RAND_MAX;
}


random

decompiled_code:
double __fastcall random(double a1, double a2)
{
return (random_simple() - 0.5) * a2 + a1;
}

canonical_decompiled_code:
double __fastcall func2(double a1, double a2)
{
return (func1() - 0.5) * a2 + a1;
}

original_code:
double random(double around,double noise){
 return around+noise*((double)random_simple()-.5);
}

canonical_original_code:
double random(double around, double noise){
 return around+noise*((double)random_simple()-.5);
}

variable_types: around double

variable_types: noise double


decompiled_code:
void empty_HUD()
{
;
}

canonical_decompiled_code:
void func0()
{
;
}

original_code: void empty_HUD(Game* game){}

canonical_original_code: void empty_HUD(struct Game *game){}

variable_types: struct Game { struct Camera { struct Game *game; double theta; double phi; double rho; double dtheta; double dphi; double drho; double ddtheta; double ddphi; double ddrho; double x; double y; double z; double fake_y; double fake_z; double dx; double dy; double dz; double ddx; double ddy; double ddz; double mConvergence; double mEyeSeparation; double mAspectRatio; double mFOV; double mNearClippingDistance; double mFarClippingDistance; int avance; double angle; double x_culling; double y_culling; } *player; struct Arrow { double x; double y; double z; double dx; double dy; double dz; struct Arrow *next; struct Arrow *prev; struct Arrow *next_update; double v; double dist; double alpha; double beta; } *arrows; struct Arrow *arrows_last; struct Arrow *arrows_to_update; struct Arrow *sorting_arrow; struct Arrow *sorting_next; int color_debug; int sorting; double world_x_size; double world_y_size; double speed_custom; struct Mechant { double x; double y; double z; double dx; double dy; double dz; double phi; double theta; double rho; double dphi; double dtheta; double drho; int type; struct Mechant *next; struct Mechant *prev; void (*update)(struct Mechant *mechant); double dist; } *mechants; struct Mechant *mechants_last; struct Particle { double x; double y; double z; double z_destination; double dx; double dy; double dz; int good; struct Particle *next; struct Particle *prev; struct Particle *next_update; struct Particle *prev_update; } *particles; struct Particle *particles_update; struct AudioPlayer { struct SoundSample { char *data; char *old_data; int size; int old_read_size; int read_size; int freq; int format; int bitStream; union soundFile { struct OggVorbis_File { void *datasource; int seekable; long offset; long end; struct ogg_sync_state { unsigned char *data; int storage; int fill; int returned; int unsynced; int headerbytes; int bodybytes; } oy; int links; long *offsets; long *dataoffsets; long *serialnos; long *pcmlengths; struct vorbis_info { int version; int channels; long rate; long bitrate_upper; long bitrate_nominal; long bitrate_lower; long bitrate_window; void *codec_setup; } *vi; struct vorbis_comment { char **user_comments; int *comment_lengths; int comments; char *vendor; } *vc; long pcm_offset; int ready_state; long current_serialno; int current_link; double bittrack; double samptrack; struct ogg_stream_state { unsigned char *body_data; long body_storage; long body_fill; long body_returned; int *lacing_vals; long *granule_vals; long lacing_storage; long lacing_fill; long lacing_packet; long lacing_returned; unsigned char header[282]; int header_fill; int e_o_s; int b_o_s; long serialno; long pageno; long packetno; long granulepos; } os; struct vorbis_dsp_state { int analysisp; struct vorbis_info *vi; float **pcm; float **pcmret; int pcm_storage; int pcm_current; int pcm_returned; int preextrapolate; int eofflag; long lW; long W; long nW; long centerW; long granulepos; long sequence; long glue_bits; long time_bits; long floor_bits; long res_bits; void *backend_state; } vd; struct vorbis_block { float **pcm; struct oggpack_buffer { long endbyte; int endbit; unsigned char *buffer; unsigned char *ptr; long storage; } opb; long lW; long W; long nW; int pcmend; int mode; int eofflag; long granulepos; long sequence; struct vorbis_dsp_state *vd; void *localstore; long localtop; long localalloc; long totaluse; struct alloc_chain { void *ptr; struct alloc_chain *next; } *reap; long glue_bits; long time_bits; long floor_bits; long res_bits; void *internal; } vb; struct ov_callbacks { unsigned long (*read_func)(void *ptr, unsigned long size, unsigned long nmemb, void *datasource); int (*seek_func)(void *datasource, long offset, int whence); int (*close_func)(void *datasource); long (*tell_func)(void *datasource); } callbacks; } oggFile; } s_file; } *s1; char *next_file_path; char *now_playing; double time_buffer_offset; unsigned int source_id; unsigned int buffer_id[2]; unsigned int sound_buffer; } *audio; double audio_amplitude; double heart_beat; double heart_beat_time; double heart_beat_time_normalized; void (*update)(struct Game *game, int dt); void (*render)(struct Game *game); void (*HUD_render)(struct Game *game); int (*mechant_regeneration_type)(); double fire_value; int fire_state; double trigger_value; int trigger_state; int FIRST_SHOT; int weapon; int stereo; void (*trigger)(struct Game *game, int state); void (*fire)(struct Game *game, int state); } *

user_defined_types: struct Game { struct Camera *player; struct Arrow *arrows; struct Arrow *arrows_last; struct Arrow *arrows_to_update; struct Arrow *sorting_arrow; struct Arrow *sorting_next; int color_debug; int sorting; double world_x_size; double world_y_size; double speed_custom; struct Mechant *mechants; struct Mechant *mechants_last; struct Particle *particles; struct Particle *particles_update; struct AudioPlayer *audio; double audio_amplitude; double heart_beat; double heart_beat_time; double heart_beat_time_normalized; void (*update)(struct Game *game, int dt); void (*render)(struct Game *game); void (*HUD_render)(struct Game *game); int (*mechant_regeneration_type)(); double fire_value; int fire_state; double trigger_value; int trigger_state; int FIRST_SHOT; int weapon; int stereo; void (*trigger)(struct Game *game, int state); void (*fire)(struct Game *game, int state); }


decompiled_code:
void __fastcall fake_walk_update(__int64 a1, int a2)
{
double v2; // xmm0_8
double v3; // xmm0_8
int i; // ebx
int v5; // eax
int v6; // eax
int v7; // eax
double v8; // xmm0_8
double v9; // [rsp+8h] [rbp-28h]
double v10; // [rsp+8h] [rbp-28h]
double v11; // [rsp+8h] [rbp-28h]

v2 = *(double *)(*(_QWORD *)a1 + 136LL) * *(double *)(*(_QWORD *)a1 + 136LL)
+ *(double *)(*(_QWORD *)a1 + 120LL) * *(double *)(*(_QWORD *)a1 + 120LL)
+ *(double *)(*(_QWORD *)a1 + 128LL) * *(double *)(*(_QWORD *)a1 + 128LL);
fake_walking = *(_QWORD *)&v2;
if ( v2 < 0.0 )
v3 = sqrt(v2);
else
v3 = sqrt(v2);
*(double *)&fake_walking = v3 * 0.007;
if ( a2 > 0 )
{
for ( i = 0; i != a2; ++i )
{
v9 = *(double *)&fake_walking + *(double *)&fake_walking;
v5 = SDL_GetTicks();
v10 = cos((double)v5 * 0.008) * v9;
v6 = SDL_GetTicks();
v11 = cos((double)v6 * 0.008) * v10;
v7 = SDL_GetTicks();
v8 = cos((double)v7 * 0.008);
*(double *)&fake_drho = (v8 * v11 + *(double *)&fake_drho) * -0.013 + v8 * v11 + *(double *)&fake_drho;
*(double *)&fake_theta = *(double *)&fake_theta * -0.01 + *(double *)&fake_theta;
*(double *)&fake_rho = *(double *)&fake_drho * 0.001 - *(double *)&fake_rho * 0.03 + *(double *)&fake_rho;
*(double *)&fake_HUD_drho_compensation = *(double *)&fake_drho * 0.2 * 0.3
+ 0.8 * *(double *)&fake_HUD_drho_compensation;
*(double *)&HUD_drho_compensation = 0.02 * *(double *)(*(_QWORD *)a1 + 48LL) * 0.3
+ 0.98 * *(double *)&HUD_drho_compensation;
}
}
}

canonical_decompiled_code:
void __fastcall func1(__int64 a1, int a2)
{
double v2; // xmm0_8
double v3; // xmm0_8
int i; // ebx
int v5; // eax
int v6; // eax
int v7; // eax
double v8; // xmm0_8
double v9; // [rsp+8h] [rbp-28h]
double v10; // [rsp+8h] [rbp-28h]
double v11; // [rsp+8h] [rbp-28h]

v2 = *(double *)(*(_QWORD *)a1 + 136LL) * *(double *)(*(_QWORD *)a1 + 136LL)
+ *(double *)(*(_QWORD *)a1 + 120LL) * *(double *)(*(_QWORD *)a1 + 120LL)
+ *(double *)(*(_QWORD *)a1 + 128LL) * *(double *)(*(_QWORD *)a1 + 128LL);
fake_walking = *(_QWORD *)&v2;
if ( v2 < 0.0 )
v3 = sqrt(v2);
else
v3 = sqrt(v2);
*(double *)&fake_walking = v3 * 0.007;
if ( a2 > 0 )
{
for ( i = 0; i != a2; ++i )
{
v9 = *(double *)&fake_walking + *(double *)&fake_walking;
v5 = SDL_GetTicks();
v10 = cos((double)v5 * 0.008) * v9;
v6 = SDL_GetTicks();
v11 = cos((double)v6 * 0.008) * v10;
v7 = SDL_GetTicks();
v8 = cos((double)v7 * 0.008);
*(double *)&fake_drho = (v8 * v11 + *(double *)&fake_drho) * -0.013 + v8 * v11 + *(double *)&fake_drho;
*(double *)&fake_theta = *(double *)&fake_theta * -0.01 + *(double *)&fake_theta;
*(double *)&fake_rho = *(double *)&fake_drho * 0.001 - *(double *)&fake_rho * 0.03 + *(double *)&fake_rho;
*(double *)&fake_HUD_drho_compensation = *(double *)&fake_drho * 0.2 * 0.3
+ 0.8 * *(double *)&fake_HUD_drho_compensation;
*(double *)&HUD_drho_compensation = 0.02 * *(double *)(*(_QWORD *)a1 + 48LL) * 0.3
+ 0.98 * *(double *)&HUD_drho_compensation;
}
}
}

original_code:
void fake_walk_update(Game* game,int dt){
 fake_walking=
   game->player->dx*game->player->dx
  +game->player->dy*game->player->dy
  +game->player->dz*game->player->dz;
 fake_walking=sqrt(fake_walking);
 fake_walking*=0.007;
 for(int i=0;i<dt;i++){
  fake_drho+=fake_walking*2*cos(SDL_GetTicks()*.008)*cos(SDL_GetTicks()*.008)*cos(SDL_GetTicks()*.008);
  fake_drho+=-.013*fake_drho;
  fake_theta+= -.01*fake_theta;
  fake_rho +=.001*fake_drho -.03*fake_rho ;
  fake_HUD_drho_compensation=
       (.2)* fake_drho*(.3)
       + (1-.2)*fake_HUD_drho_compensation;
  HUD_drho_compensation= (.02)* game->player->drho*(.3)
       + (1-.02)*HUD_drho_compensation;
 }
}

canonical_original_code:
void fake_walk_update(struct Game *game, int dt){
 fake_walking=
   game->player->dx*game->player->dx
  +game->player->dy*game->player->dy
  +game->player->dz*game->player->dz;
 fake_walking=sqrt(fake_walking);
 fake_walking*=0.007;
 for(int i = 0;i<dt;i++){
  fake_drho+=fake_walking*2*cos(SDL_GetTicks()*.008)*cos(SDL_GetTicks()*.008)*cos(SDL_GetTicks()*.008);
  fake_drho+=-.013*fake_drho;
  fake_theta+= -.01*fake_theta;
  fake_rho +=.001*fake_drho -.03*fake_rho ;
  fake_HUD_drho_compensation=
       (.2)* fake_drho*(.3)
       + (1-.2)*fake_HUD_drho_compensation;
  HUD_drho_compensation= (.02)* game->player->drho*(.3)
       + (1-.02)*HUD_drho_compensation;
 }
}

variable_types: dt int

user_defined_types: struct Camera { struct Game *game; double theta; double phi; double rho; double dtheta; double dphi; double drho; double ddtheta; double ddphi; double ddrho; double x; double y; double z; double fake_y; double fake_z; double dx; double dy; double dz; double ddx; double ddy; double ddz; double mConvergence; double mEyeSeparation; double mAspectRatio; double mFOV; double mNearClippingDistance; double mFarClippingDistance; int avance; double angle; double x_culling; double y_culling; }

user_defined_types: struct Arrow { double x; double y; double z; double dx; double dy; double dz; struct Arrow *next; struct Arrow *prev; struct Arrow *next_update; double v; double dist; double alpha; double beta; }


viseur

original_code:
void viseur(Game * game){
 if(SDL_GetMouseState( ((void *)0), ((void *)0) )&(1 << ((1)-1))
  ||SDL_GetMouseState( ((void *)0), ((void *)0) )&(1 << ((3)-1))
  ||SDL_GetKeyState(((void *)0))[SDLK_LALT]
  ||SDL_GetKeyState(((void *)0))[SDLK_LCTRL]){
  precision=1;
 }else{
  precision=0;
 }
 glPushMatrix();
  glColor4d(1,0,0,1);
  glPointSize(2.);
  glRotated(game->player->rho*(-2),1,0,0);
  glRotated(game->player->theta*(.5-precision*.8), 0.0, 1.0, 0.0);
  glPointSize(6.);
  glBegin(0x0000);
   glVertex3d(.05,.003,0);
   glVertex3d(.05,-.003,0); glVertex3d(.05,0,0); glVertex3d(.05,0,.003);
   glVertex3d(.05,0,-.003);
  glEnd();
 glPopMatrix();
}

canonical_original_code:
void viseur(struct Game *game){
 if(SDL_GetMouseState( ((void *)0), ((void *)0) )&(1 << ((1)-1))
  ||SDL_GetMouseState( ((void *)0), ((void *)0) )&(1 << ((3)-1))
  ||SDL_GetKeyState(((void *)0))[SDLK_LALT]
  ||SDL_GetKeyState(((void *)0))[SDLK_LCTRL]){
  precision=1;
 }else{
  precision=0;
 }
 glPushMatrix();
  glColor4d(1,0,0,1);
  glPointSize(2.);
  glRotated(game->player->rho*(-2),1,0,0);
  glRotated(game->player->theta*(.5-precision*.8), 0.0, 1.0, 0.0);
  glPointSize(6.);
  glBegin(0x0000);
   glVertex3d(.05,.003,0);
   glVertex3d(.05,-.003,0); glVertex3d(.05,0,0); glVertex3d(.05,0,.003);
   glVertex3d(.05,0,-.003);
  glEnd();
 glPopMatrix();
}

user_defined_types: struct Mechant { double x; double y; double z; double dx; double dy; double dz; double phi; double theta; double rho; double dphi; double dtheta; double drho; int type; struct Mechant *next; struct Mechant *prev; void (*update)(struct Mechant *mechant); double dist; }

user_defined_types: struct Particle { double x; double y; double z; double z_destination; double dx; double dy; double dz; int good; struct Particle *next; struct Particle *prev; struct Particle *next_update; struct Particle *prev_update; }


decompiled_code:
__int64 __fastcall weapon_HUD_ARM(double *a1, int a2, double a3)
{
int v3; // eax
double v4; // r12
int v5; // eax
double v6; // r13
double v7; // r14
double v8; // r15
int v9; // eax
double v10; // xmm0_8
double v11; // xmm3_8
double v13; // [rsp+10h] [rbp-50h]
double v14; // [rsp+18h] [rbp-48h]
double v15; // [rsp+20h] [rbp-40h]
double v16; // [rsp+20h] [rbp-40h]
double v17; // [rsp+28h] [rbp-38h]
double v18; // [rsp+28h] [rbp-38h]

v17 = a3 + a1[25];
v3 = SDL_GetTicks();
v4 = sin((double)v3 * 0.001);
v5 = SDL_GetTicks();
v14 = v4 * 0.5 + sin((double)v5 * 0.00085) * 0.5;
glPushMatrix();
v15 = *(double *)(*(_QWORD *)a1 + 8LL) + *(double *)&fake_theta;
glRotated((*(double *)(*(_QWORD *)a1 + 24LL) + *(double *)&fake_rho) * -4.0, 1.0, 0.0);
glRotated(0.5 * v15, 0.0, 1.0);
v13 = *(double *)&HUD_drho_compensation + *(double *)&fake_HUD_drho_compensation;
glTranslated(
0.0,
0.0,
COERCE_DOUBLE(COERCE_UNSIGNED_INT64(*(double *)&HUD_drho_compensation + *(double *)&fake_HUD_drho_compensation) ^ LC22)
* (*(double *)&HUD_drho_compensation + *(double *)&fake_HUD_drho_compensation)
* 0.0007);
glTranslated(5.0, 0.0, -3.0);
glTranslated(v15 * 0.05, 0.0, 0.0);
glRotated(80.0, 0.0, 1.0);
glRotated(70.0, 1.0, 0.0);
glRotated(v15, 0.0, 0.0);
glRotated(v13, 0.0, 1.0);
glTranslated(0.0, 0.0, -1.0);
glLineWidth(3.0);
glPushMatrix();
v6 = v17 * 1.5;
v16 = v17 + v17;
glTranslated(0.0, v17 * 1.5, v17 + v17);
v7 = v17 * -65.0;
glRotated(v17 * -65.0, 0.0, 1.0);
v8 = v17 * -15.0;
glRotated(v17 * -15.0, 0.0, 0.0);
glRotated(v17 * 30.0 + 60.0, 0.0, 1.0);
glRotated(v17 * 30.0 + 60.0, 1.0, 0.0);
v9 = SDL_GetTicks();
v10 = sin((double)v9 * 0.0017);
glTranslated(v10 * 0.1 * (1.0 - v17) - 0.3 - v17 * 0.7, 1.0 - v17 * 0.8, (1.0 - v17) * v14 - 5.0 + v17 + v17);
glScaled(1.0, 1.0, v17 * 0.2 + 1.0);
draw_arrow_high_quality();
if ( !a2 )
{
glClear(256LL);
glPopMatrix();
glTranslated(0.0, v6, v16);
glRotated(v7, 0.0, 1.0);
v11 = *(double *)&LC12;
glRotated(v8, 0.0, 0.0);
if ( v17 == 0.0 )
{
v11 = v14 * 0.1;
v18 = v14 * 0.1;
draw_hand(0LL, v14 * 0.1 + 0.3, 0.0);
goto LABEL_4;
}
draw_hand(1LL, v17 * 0.3, v16);
goto LABEL_17;
}
glPushMatrix();
glTranslated(-1.7, 0.0, 1.5);
glRotated(10.0, 0.0, 1.0);
draw_arrow_high_quality();
glPopMatrix();
glPushMatrix();
glTranslated(1.7, 0.0, 0.75);
glRotated(-10.0, 0.0, 1.0);
draw_arrow_high_quality();
glPopMatrix();
if ( a2 != 2 )
{
glClear(256LL);
glPopMatrix();
glTranslated(0.0, v6, v16);
glRotated(v7, 0.0, 1.0);
v11 = *(double *)&LC12;
glRotated(v8, 0.0, 0.0);
if ( v17 == 0.0 )
{
v18 = v14 * 0.1;
draw_hand(0LL, v14 * 0.1 + 0.3, 0.0);
LABEL_4:
if ( a2 == 1 )
draw_bow_v2(0.2, v18 + 0.2, 0.0, v11);
else
draw_bow(0.2, v18 + 0.2, 0.0, v11);
return glPopMatrix();
}
draw_hand(1LL, v17 * 0.3, v16);
if ( a2 == 1 )
{
draw_bow_v2(0.2, v17 * 0.6 + 0.2, 0.0, 1.0);
return glPopMatrix();
}
LABEL_17:
draw_bow(0.2, v17 * 0.6 + 0.2, 0.0, v11);
return glPopMatrix();
}
glPushMatrix();
glTranslated(-3.2, 0.0, 3.0);
glRotated(20.0, 0.0, 1.0);
draw_arrow_high_quality();
glPopMatrix();
glPushMatrix();
glTranslated(3.2, 0.0, 1.5);
glRotated(-20.0, 0.0, 1.0);
draw_arrow_high_quality();
glPopMatrix();
glClear(256LL);
glPopMatrix();
glTranslated(0.0, v6, v16);
glRotated(v7, 0.0, 1.0);
glRotated(v8, 0.0, 0.0);
if ( v17 == 0.0 )
{
draw_hand(0LL, v14 * 0.1 + 0.3, 0.0);
draw_bow_v3(0.2, v14 * 0.1 + 0.2, 0.0, 1.0);
}
else
{
draw_hand(1LL, v17 * 0.3, v16);
draw_bow_v3(0.2, v17 * 0.6 + 0.2, 0.0, 1.0);
}
return glPopMatrix();
}

canonical_decompiled_code:
__int64 __fastcall func3(double *a1, int a2, double a3)
{
int v3; // eax
double v4; // r12
int v5; // eax
double v6; // r13
double v7; // r14
double v8; // r15
int v9; // eax
double v10; // xmm0_8
double v11; // xmm3_8
double v13; // [rsp+10h] [rbp-50h]
double v14; // [rsp+18h] [rbp-48h]
double v15; // [rsp+20h] [rbp-40h]
double v16; // [rsp+20h] [rbp-40h]
double v17; // [rsp+28h] [rbp-38h]
double v18; // [rsp+28h] [rbp-38h]

v17 = a3 + a1[25];
v3 = SDL_GetTicks();
v4 = sin((double)v3 * 0.001);
v5 = SDL_GetTicks();
v14 = v4 * 0.5 + sin((double)v5 * 0.00085) * 0.5;
glPushMatrix();
v15 = *(double *)(*(_QWORD *)a1 + 8LL) + *(double *)&fake_theta;
glRotated((*(double *)(*(_QWORD *)a1 + 24LL) + *(double *)&fake_rho) * -4.0, 1.0, 0.0);
glRotated(0.5 * v15, 0.0, 1.0);
v13 = *(double *)&HUD_drho_compensation + *(double *)&fake_HUD_drho_compensation;
glTranslated(
0.0,
0.0,
COERCE_DOUBLE(COERCE_UNSIGNED_INT64(*(double *)&HUD_drho_compensation + *(double *)&fake_HUD_drho_compensation) ^ LC22)
* (*(double *)&HUD_drho_compensation + *(double *)&fake_HUD_drho_compensation)
* 0.0007);
glTranslated(5.0, 0.0, -3.0);
glTranslated(v15 * 0.05, 0.0, 0.0);
glRotated(80.0, 0.0, 1.0);
glRotated(70.0, 1.0, 0.0);
glRotated(v15, 0.0, 0.0);
glRotated(v13, 0.0, 1.0);
glTranslated(0.0, 0.0, -1.0);
glLineWidth(3.0);
glPushMatrix();
v6 = v17 * 1.5;
v16 = v17 + v17;
glTranslated(0.0, v17 * 1.5, v17 + v17);
v7 = v17 * -65.0;
glRotated(v17 * -65.0, 0.0, 1.0);
v8 = v17 * -15.0;
glRotated(v17 * -15.0, 0.0, 0.0);
glRotated(v17 * 30.0 + 60.0, 0.0, 1.0);
glRotated(v17 * 30.0 + 60.0, 1.0, 0.0);
v9 = SDL_GetTicks();
v10 = sin((double)v9 * 0.0017);
glTranslated(v10 * 0.1 * (1.0 - v17) - 0.3 - v17 * 0.7, 1.0 - v17 * 0.8, (1.0 - v17) * v14 - 5.0 + v17 + v17);
glScaled(1.0, 1.0, v17 * 0.2 + 1.0);
draw_arrow_high_quality();
if ( !a2 )
{
glClear(256LL);
glPopMatrix();
glTranslated(0.0, v6, v16);
glRotated(v7, 0.0, 1.0);
v11 = *(double *)&LC12;
glRotated(v8, 0.0, 0.0);
if ( v17 == 0.0 )
{
v11 = v14 * 0.1;
v18 = v14 * 0.1;
draw_hand(0LL, v14 * 0.1 + 0.3, 0.0);
goto LABEL_4;
}
draw_hand(1LL, v17 * 0.3, v16);
goto LABEL_17;
}
glPushMatrix();
glTranslated(-1.7, 0.0, 1.5);
glRotated(10.0, 0.0, 1.0);
draw_arrow_high_quality();
glPopMatrix();
glPushMatrix();
glTranslated(1.7, 0.0, 0.75);
glRotated(-10.0, 0.0, 1.0);
draw_arrow_high_quality();
glPopMatrix();
if ( a2 != 2 )
{
glClear(256LL);
glPopMatrix();
glTranslated(0.0, v6, v16);
glRotated(v7, 0.0, 1.0);
v11 = *(double *)&LC12;
glRotated(v8, 0.0, 0.0);
if ( v17 == 0.0 )
{
v18 = v14 * 0.1;
draw_hand(0LL, v14 * 0.1 + 0.3, 0.0);
LABEL_4:
if ( a2 == 1 )
draw_bow_v2(0.2, v18 + 0.2, 0.0, v11);
else
draw_bow(0.2, v18 + 0.2, 0.0, v11);
return glPopMatrix();
}
draw_hand(1LL, v17 * 0.3, v16);
if ( a2 == 1 )
{
draw_bow_v2(0.2, v17 * 0.6 + 0.2, 0.0, 1.0);
return glPopMatrix();
}
LABEL_17:
draw_bow(0.2, v17 * 0.6 + 0.2, 0.0, v11);
return glPopMatrix();
}
glPushMatrix();
glTranslated(-3.2, 0.0, 3.0);
glRotated(20.0, 0.0, 1.0);
draw_arrow_high_quality();
glPopMatrix();
glPushMatrix();
glTranslated(3.2, 0.0, 1.5);
glRotated(-20.0, 0.0, 1.0);
draw_arrow_high_quality();
glPopMatrix();
glClear(256LL);
glPopMatrix();
glTranslated(0.0, v6, v16);
glRotated(v7, 0.0, 1.0);
glRotated(v8, 0.0, 0.0);
if ( v17 == 0.0 )
{
draw_hand(0LL, v14 * 0.1 + 0.3, 0.0);
draw_bow_v3(0.2, v14 * 0.1 + 0.2, 0.0, 1.0);
}
else
{
draw_hand(1LL, v17 * 0.3, v16);
draw_bow_v3(0.2, v17 * 0.6 + 0.2, 0.0, 1.0);
}
return glPopMatrix();
}

original_code:
void weapon_HUD_ARM(Game* game,int mode,double time_offset){
 double time_pos=game->trigger_value+time_offset;
 double oscill_force=.5*sin(SDL_GetTicks()*.001)+.5*sin(SDL_GetTicks()*.00085);
 glPushMatrix();
 double real_rho=game->player->rho +fake_rho; double real_theta=game->player->theta+fake_theta; glRotated(real_rho*(-4),1,0,0); glRotated(real_theta*.5, 0.0, 1.0, 0.0); double real_HUD_drho_compensation=HUD_drho_compensation+fake_HUD_drho_compensation; glTranslated(0,0,-real_HUD_drho_compensation*real_HUD_drho_compensation*0.0007); glTranslated(5,0,-3); glTranslated(real_theta*(.05),0,0); glRotated(80, 0, 1, 0); glRotated(70, 1, 0, 0); glRotated(real_theta*(1),0,0,1); glRotated(real_HUD_drho_compensation,0,1,0); glTranslated(0,0,-1); glLineWidth(3.0);
   glPushMatrix();
    glTranslated(0, 1.5*time_pos, 2*time_pos); glRotated(-130*.5*time_pos, 0, 1, 0); glRotated(-30*.5*time_pos, 0, 0, 1);;
    glRotated(60+30*time_pos, 0, 1, 0);
    glRotated(60+30*time_pos, 1, 0, 0);
    glTranslated(
     -.3+.1*sin(SDL_GetTicks()*.0017)*(1-time_pos)-.7*time_pos,
     1-.8*time_pos,
     -5+1*oscill_force*(1-time_pos)+2*time_pos
     );
    glScaled(1,1,1+.2*time_pos);
    draw_arrow_high_quality();
    if(mode){
     glPushMatrix();
      glTranslated(-1.7,0,1.5);
      glRotated(10,0,1,0);
      draw_arrow_high_quality();
     glPopMatrix();
     glPushMatrix();
      glTranslated(1.7,0,0.75);
      glRotated(-10,0,1,0);
      draw_arrow_high_quality();
     glPopMatrix();
    }if(mode==2){
     glPushMatrix();
      glTranslated(-3.2,0,3);
      glRotated(20,0,1,0);
      draw_arrow_high_quality();
     glPopMatrix();
     glPushMatrix();
      glTranslated(3.2,0,1.5);
      glRotated(-20,0,1,0);
      draw_arrow_high_quality();
     glPopMatrix();
    }
    glClear(0x00000100);
   glPopMatrix();
   glTranslated(0, 1.5*time_pos, 2*time_pos); glRotated(-130*.5*time_pos, 0, 1, 0); glRotated(-30*.5*time_pos, 0, 0, 1);;
   if(time_pos){
    draw_hand(.3*time_pos,2*time_pos,1);
    if(mode==2){
     draw_bow_v3(.2,.2+.6*time_pos);
    }else if(mode==1){
     draw_bow_v2(.2,.2+.6*time_pos);
    }else{
     draw_bow(.2,.2+.6*time_pos);
    }
   }else{
    draw_hand( .3+.1*oscill_force,0,0);
    if(mode==2){
     draw_bow_v3(.2,.2+.1*oscill_force);
    }else if(mode==1){
     draw_bow_v2(.2,.2+.1*oscill_force);
    }else{
     draw_bow(.2,.2+.1*oscill_force);
    }
   }
 glPopMatrix();
}

canonical_original_code:
void weapon_HUD_ARM(struct Game *game, int mode, double time_offset){
 double time_pos = game->trigger_value+time_offset;
 double oscill_force = .5*sin(SDL_GetTicks()*.001)+.5*sin(SDL_GetTicks()*.00085);
 glPushMatrix();
 double real_rho = game->player->rho +fake_rho; double real_theta = game->player->theta+fake_theta; glRotated(real_rho*(-4),1,0,0); glRotated(real_theta*.5, 0.0, 1.0, 0.0); double real_HUD_drho_compensation = HUD_drho_compensation+fake_HUD_drho_compensation; glTranslated(0,0,-real_HUD_drho_compensation*real_HUD_drho_compensation*0.0007); glTranslated(5,0,-3); glTranslated(real_theta*(.05),0,0); glRotated(80, 0, 1, 0); glRotated(70, 1, 0, 0); glRotated(real_theta*(1),0,0,1); glRotated(real_HUD_drho_compensation,0,1,0); glTranslated(0,0,-1); glLineWidth(3.0);
   glPushMatrix();
    glTranslated(0, 1.5*time_pos, 2*time_pos); glRotated(-130*.5*time_pos, 0, 1, 0); glRotated(-30*.5*time_pos, 0, 0, 1);;
    glRotated(60+30*time_pos, 0, 1, 0);
    glRotated(60+30*time_pos, 1, 0, 0);
    glTranslated(
     -.3+.1*sin(SDL_GetTicks()*.0017)*(1-time_pos)-.7*time_pos,
     1-.8*time_pos,
     -5+1*oscill_force*(1-time_pos)+2*time_pos
     );
    glScaled(1,1,1+.2*time_pos);
    draw_arrow_high_quality();
    if(mode){
     glPushMatrix();
      glTranslated(-1.7,0,1.5);
      glRotated(10,0,1,0);
      draw_arrow_high_quality();
     glPopMatrix();
     glPushMatrix();
      glTranslated(1.7,0,0.75);
      glRotated(-10,0,1,0);
      draw_arrow_high_quality();
     glPopMatrix();
    }if(mode==2){
     glPushMatrix();
      glTranslated(-3.2,0,3);
      glRotated(20,0,1,0);
      draw_arrow_high_quality();
     glPopMatrix();
     glPushMatrix();
      glTranslated(3.2,0,1.5);
      glRotated(-20,0,1,0);
      draw_arrow_high_quality();
     glPopMatrix();
    }
    glClear(0x00000100);
   glPopMatrix();
   glTranslated(0, 1.5*time_pos, 2*time_pos); glRotated(-130*.5*time_pos, 0, 1, 0); glRotated(-30*.5*time_pos, 0, 0, 1);;
   if(time_pos){
    draw_hand(.3*time_pos,2*time_pos,1);
    if(mode==2){
     draw_bow_v3(.2,.2+.6*time_pos);
    }else if(mode==1){
     draw_bow_v2(.2,.2+.6*time_pos);
    }else{
     draw_bow(.2,.2+.6*time_pos);
    }
   }else{
    draw_hand( .3+.1*oscill_force,0,0);
    if(mode==2){
     draw_bow_v3(.2,.2+.1*oscill_force);
    }else if(mode==1){
     draw_bow_v2(.2,.2+.1*oscill_force);
    }else{
     draw_bow(.2,.2+.1*oscill_force);
    }
   }
 glPopMatrix();
}

variable_types: mode int

user_defined_types: struct vorbis_dsp_state { int analysisp; struct vorbis_info *vi; float **pcm; float **pcmret; int pcm_storage; int pcm_current; int pcm_returned; int preextrapolate; int eofflag; long lW; long W; long nW; long centerW; long granulepos; long sequence; long glue_bits; long time_bits; long floor_bits; long res_bits; void *backend_state; }

user_defined_types: struct ov_callbacks { unsigned long (*read_func)(void *ptr, unsigned long size, unsigned long nmemb, void *datasource); int (*seek_func)(void *datasource, long offset, int whence); int (*close_func)(void *datasource); long (*tell_func)(void *datasource); }


decompiled_code:
__int64 __fastcall weapon_HUD_FIRE(double *a1, int a2, double a3)
{
double v3; // xmm6_8
double v4; // xmm2_8
double v5; // xmm2_8
double v6; // rbx
double v8; // rbx
int v9; // eax
double v10; // rbx
int v11; // eax
double v12; // rbx
int v13; // eax
double v14; // xmm0_8
double v15; // xmm2_8
double v16; // [rsp+0h] [rbp-30h]
double v17; // [rsp+8h] [rbp-28h]
double v18; // [rsp+8h] [rbp-28h]
double v19; // [rsp+8h] [rbp-28h]
double v20; // [rsp+8h] [rbp-28h]
double v21; // [rsp+8h] [rbp-28h]

((void (*)(void))glPushMatrix)();
v17 = *(double *)(*(_QWORD *)a1 + 8LL) + *(double *)&fake_theta;
glRotated((*(double *)(*(_QWORD *)a1 + 24LL) + *(double *)&fake_rho) * -4.0, 1.0, 0.0);
glRotated(v17 * 0.5, 0.0, 1.0);
v16 = *(double *)&HUD_drho_compensation + *(double *)&fake_HUD_drho_compensation;
glTranslated(
0.0,
0.0,
COERCE_DOUBLE(COERCE_UNSIGNED_INT64(*(double *)&HUD_drho_compensation + *(double *)&fake_HUD_drho_compensation) ^ LC22)
* (*(double *)&HUD_drho_compensation + *(double *)&fake_HUD_drho_compensation)
* 0.0007);
glTranslated(5.0, 0.0, -3.0);
glTranslated(v17 * 0.05, 0.0, 0.0);
glRotated(80.0, 0.0, 1.0);
glRotated(70.0, 1.0, 0.0);
glRotated(v17, 0.0, 0.0);
glRotated(v16, 0.0, 1.0);
glTranslated(0.0, 0.0, -1.0);
glLineWidth(3.0);
v3 = 1.0 - a1[23] + a3;
if ( v3 < 0.1 )
{
v19 = (exp(1.0 - v3 / 0.1) - 1.0) / 1.718281828459045;
glTranslated(v19, v19 + 0.5, 2.5);
glRotated(-65.0, 0.0, 1.0);
glRotated(-15.0, 0.0, 0.0);
glRotated(10.0, 0.0, 1.0);
((void (*)(void))glPushMatrix)();
glRotated(90.0, 0.0, 1.0);
glRotated(90.0, 1.0, 0.0);
glRotated(3.0, 1.0, 0.0);
glTranslated(0.0, 0.3, v19 * 5.0 - 8.0);
*(_QWORD *)&v5 = COERCE_UNSIGNED_INT64(1.0 - v19) ^ LC22;
glTranslated(0.0, 0.0, v5);
draw_arrow_high_quality();
glPopMatrix();
v6 = 0.5 * v19;
draw_hand(1LL, 0.5 * v19, 4.0 - (v19 + v19));
if ( a2 == 2 )
{
draw_bow_v3(0.2, v6, v5, 0.0);
}
else if ( a2 == 1 )
{
draw_bow_v2(0.2, v6, v5, 0.0);
}
else
{
draw_bow(0.2, v6, v5, 0.0);
}
}
else
{
if ( v3 < 0.3 )
{
v8 = (v3 - 0.1) / 0.2;
glTranslated(0.0, 0.5, 2.5);
glRotated(-65.0, 0.0, 1.0);
glRotated(-15.0, 0.0, 0.0);
glRotated(10.0, 0.0, 1.0);
glRotated(v8 * -40.0, 1.0, 0.0);
v4 = v8 * -3.0;
glTranslated(0.0, 0.0, v8 * -3.0);
draw_hand(1LL, 0.0, 4.0);
if ( a2 == 2 )
{
draw_bow_v3(0.2, 0.0, v4, 0.0);
return glPopMatrix();
}
if ( a2 == 1 )
{
draw_bow_v2(0.2, 0.0, v4, 0.0);
return glPopMatrix();
}
goto LABEL_6;
}
if ( v3 < 0.6 )
{
v18 = (v3 - 0.3) / 0.3;
glTranslated(0.0, 0.5, 2.5);
glRotated(-65.0, 0.0, 1.0);
glRotated(-15.0, 0.0, 0.0);
glRotated(10.0, 0.0, 1.0);
glRotated(-40.0, 1.0, 0.0);
glTranslated(0.0, 0.0, -3.0 * v18);
glRotated(v18 * 20.0, 0.0, 1.0);
glRotated(v18 * 20.0, 1.0, 1.0);
v4 = *(double *)&LC24;
glTranslated(0.0, 0.0, -3.0);
draw_hand(1LL, 0.0, 4.0 - (v18 + v18));
if ( a2 == 2 )
{
draw_bow_v3(0.2, 0.0, -3.0, 0.0);
return glPopMatrix();
}
if ( a2 == 1 )
{
draw_bow_v2(0.2, 0.0, -3.0, 0.0);
return glPopMatrix();
}
LABEL_6:
draw_bow(0.2, 0.0, v4, 0.0);
return glPopMatrix();
}
v9 = SDL_GetTicks();
v10 = sin((double)v9 * 0.001);
v11 = SDL_GetTicks();
v12 = v10 * 0.5 + sin((double)v11 * 0.00085) * 0.5;
v20 = 1.0 - (v3 - 0.6) / 0.4;
glTranslated(v20 + v20, 0.0, 0.0);
glRotated(v20 * 30.0, 0.0, 1.0);
glRotated(0.0, 0.0, 0.0);
glPushMatrix(0.0, 0.0, 0.0, 1.0);
glRotated(60.0, 0.0, 1.0);
glRotated(60.0, 1.0, 0.0);
v13 = SDL_GetTicks();
v14 = sin((double)v13 * 0.0017);
glTranslated(v14 * 0.1 - 0.3, 1.0, v12 - 5.0);
glTranslated(5.0 * v20, 5.0 * v20, 0.0);
glTranslated(v20 * -10.0, 0.0, 0.0);
glRotated(v20 * -40.0, 1.0, 0.0);
glTranslated(v20 * 10.0, 0.0, 0.0);
glTranslated(0.0, v20 + v20, v20 + v20);
v15 = 0.0;
glTranslated(v20 * -3.0, 0.0, 0.0);
draw_arrow_high_quality();
if ( a2 )
{
glPushMatrix(v20 * -3.0, 0.0, 0.0, 0.0);
glTranslated(-1.3, 0.0, 1.7);
glRotated(10.0, 0.0, 1.0);
draw_arrow_high_quality();
glPopMatrix();
glPushMatrix(10.0, 0.0, 1.0, 0.0);
glTranslated(1.3, 0.0, 1.0);
v15 = *(double *)&LC12;
glRotated(-10.0, 0.0, 1.0);
draw_arrow_high_quality();
glPopMatrix();
glPopMatrix();
v21 = v12 * 0.1;
draw_hand(0LL, v12 * 0.1 + 0.3, 0.0);
if ( a2 == 2 )
{
draw_bow_v3(0.2, v21 + 0.2, 1.0, 0.0);
return glPopMatrix();
}
if ( a2 == 1 )
{
draw_bow_v2(0.2, v21 + 0.2, 1.0, 0.0);
return glPopMatrix();
}
}
else
{
glPopMatrix();
v21 = v12 * 0.1;
draw_hand(0LL, v12 * 0.1 + 0.3, 0.0);
}
draw_bow(0.2, v21 + 0.2, v15, 0.0);
}
return glPopMatrix();
}

canonical_decompiled_code:
__int64 __fastcall func4(double *a1, int a2, double a3)
{
double v3; // xmm6_8
double v4; // xmm2_8
double v5; // xmm2_8
double v6; // rbx
double v8; // rbx
int v9; // eax
double v10; // rbx
int v11; // eax
double v12; // rbx
int v13; // eax
double v14; // xmm0_8
double v15; // xmm2_8
double v16; // [rsp+0h] [rbp-30h]
double v17; // [rsp+8h] [rbp-28h]
double v18; // [rsp+8h] [rbp-28h]
double v19; // [rsp+8h] [rbp-28h]
double v20; // [rsp+8h] [rbp-28h]
double v21; // [rsp+8h] [rbp-28h]

((void (*)(void))glPushMatrix)();
v17 = *(double *)(*(_QWORD *)a1 + 8LL) + *(double *)&fake_theta;
glRotated((*(double *)(*(_QWORD *)a1 + 24LL) + *(double *)&fake_rho) * -4.0, 1.0, 0.0);
glRotated(v17 * 0.5, 0.0, 1.0);
v16 = *(double *)&HUD_drho_compensation + *(double *)&fake_HUD_drho_compensation;
glTranslated(
0.0,
0.0,
COERCE_DOUBLE(COERCE_UNSIGNED_INT64(*(double *)&HUD_drho_compensation + *(double *)&fake_HUD_drho_compensation) ^ LC22)
* (*(double *)&HUD_drho_compensation + *(double *)&fake_HUD_drho_compensation)
* 0.0007);
glTranslated(5.0, 0.0, -3.0);
glTranslated(v17 * 0.05, 0.0, 0.0);
glRotated(80.0, 0.0, 1.0);
glRotated(70.0, 1.0, 0.0);
glRotated(v17, 0.0, 0.0);
glRotated(v16, 0.0, 1.0);
glTranslated(0.0, 0.0, -1.0);
glLineWidth(3.0);
v3 = 1.0 - a1[23] + a3;
if ( v3 < 0.1 )
{
v19 = (exp(1.0 - v3 / 0.1) - 1.0) / 1.718281828459045;
glTranslated(v19, v19 + 0.5, 2.5);
glRotated(-65.0, 0.0, 1.0);
glRotated(-15.0, 0.0, 0.0);
glRotated(10.0, 0.0, 1.0);
((void (*)(void))glPushMatrix)();
glRotated(90.0, 0.0, 1.0);
glRotated(90.0, 1.0, 0.0);
glRotated(3.0, 1.0, 0.0);
glTranslated(0.0, 0.3, v19 * 5.0 - 8.0);
*(_QWORD *)&v5 = COERCE_UNSIGNED_INT64(1.0 - v19) ^ LC22;
glTranslated(0.0, 0.0, v5);
draw_arrow_high_quality();
glPopMatrix();
v6 = 0.5 * v19;
draw_hand(1LL, 0.5 * v19, 4.0 - (v19 + v19));
if ( a2 == 2 )
{
draw_bow_v3(0.2, v6, v5, 0.0);
}
else if ( a2 == 1 )
{
draw_bow_v2(0.2, v6, v5, 0.0);
}
else
{
draw_bow(0.2, v6, v5, 0.0);
}
}
else
{
if ( v3 < 0.3 )
{
v8 = (v3 - 0.1) / 0.2;
glTranslated(0.0, 0.5, 2.5);
glRotated(-65.0, 0.0, 1.0);
glRotated(-15.0, 0.0, 0.0);
glRotated(10.0, 0.0, 1.0);
glRotated(v8 * -40.0, 1.0, 0.0);
v4 = v8 * -3.0;
glTranslated(0.0, 0.0, v8 * -3.0);
draw_hand(1LL, 0.0, 4.0);
if ( a2 == 2 )
{
draw_bow_v3(0.2, 0.0, v4, 0.0);
return glPopMatrix();
}
if ( a2 == 1 )
{
draw_bow_v2(0.2, 0.0, v4, 0.0);
return glPopMatrix();
}
goto LABEL_6;
}
if ( v3 < 0.6 )
{
v18 = (v3 - 0.3) / 0.3;
glTranslated(0.0, 0.5, 2.5);
glRotated(-65.0, 0.0, 1.0);
glRotated(-15.0, 0.0, 0.0);
glRotated(10.0, 0.0, 1.0);
glRotated(-40.0, 1.0, 0.0);
glTranslated(0.0, 0.0, -3.0 * v18);
glRotated(v18 * 20.0, 0.0, 1.0);
glRotated(v18 * 20.0, 1.0, 1.0);
v4 = *(double *)&LC24;
glTranslated(0.0, 0.0, -3.0);
draw_hand(1LL, 0.0, 4.0 - (v18 + v18));
if ( a2 == 2 )
{
draw_bow_v3(0.2, 0.0, -3.0, 0.0);
return glPopMatrix();
}
if ( a2 == 1 )
{
draw_bow_v2(0.2, 0.0, -3.0, 0.0);
return glPopMatrix();
}
LABEL_6:
draw_bow(0.2, 0.0, v4, 0.0);
return glPopMatrix();
}
v9 = SDL_GetTicks();
v10 = sin((double)v9 * 0.001);
v11 = SDL_GetTicks();
v12 = v10 * 0.5 + sin((double)v11 * 0.00085) * 0.5;
v20 = 1.0 - (v3 - 0.6) / 0.4;
glTranslated(v20 + v20, 0.0, 0.0);
glRotated(v20 * 30.0, 0.0, 1.0);
glRotated(0.0, 0.0, 0.0);
glPushMatrix(0.0, 0.0, 0.0, 1.0);
glRotated(60.0, 0.0, 1.0);
glRotated(60.0, 1.0, 0.0);
v13 = SDL_GetTicks();
v14 = sin((double)v13 * 0.0017);
glTranslated(v14 * 0.1 - 0.3, 1.0, v12 - 5.0);
glTranslated(5.0 * v20, 5.0 * v20, 0.0);
glTranslated(v20 * -10.0, 0.0, 0.0);
glRotated(v20 * -40.0, 1.0, 0.0);
glTranslated(v20 * 10.0, 0.0, 0.0);
glTranslated(0.0, v20 + v20, v20 + v20);
v15 = 0.0;
glTranslated(v20 * -3.0, 0.0, 0.0);
draw_arrow_high_quality();
if ( a2 )
{
glPushMatrix(v20 * -3.0, 0.0, 0.0, 0.0);
glTranslated(-1.3, 0.0, 1.7);
glRotated(10.0, 0.0, 1.0);
draw_arrow_high_quality();
glPopMatrix();
glPushMatrix(10.0, 0.0, 1.0, 0.0);
glTranslated(1.3, 0.0, 1.0);
v15 = *(double *)&LC12;
glRotated(-10.0, 0.0, 1.0);
draw_arrow_high_quality();
glPopMatrix();
glPopMatrix();
v21 = v12 * 0.1;
draw_hand(0LL, v12 * 0.1 + 0.3, 0.0);
if ( a2 == 2 )
{
draw_bow_v3(0.2, v21 + 0.2, 1.0, 0.0);
return glPopMatrix();
}
if ( a2 == 1 )
{
draw_bow_v2(0.2, v21 + 0.2, 1.0, 0.0);
return glPopMatrix();
}
}
else
{
glPopMatrix();
v21 = v12 * 0.1;
draw_hand(0LL, v12 * 0.1 + 0.3, 0.0);
}
draw_bow(0.2, v21 + 0.2, v15, 0.0);
}
return glPopMatrix();
}

original_code:
void weapon_HUD_FIRE(Game* game, int mode,double time_offset){
 glPushMatrix();
 double real_rho=game->player->rho +fake_rho; double real_theta=game->player->theta+fake_theta; glRotated(real_rho*(-4),1,0,0); glRotated(real_theta*.5, 0.0, 1.0, 0.0); double real_HUD_drho_compensation=HUD_drho_compensation+fake_HUD_drho_compensation; glTranslated(0,0,-real_HUD_drho_compensation*real_HUD_drho_compensation*0.0007); glTranslated(5,0,-3); glTranslated(real_theta*(.05),0,0); glRotated(80, 0, 1, 0); glRotated(70, 1, 0, 0); glRotated(real_theta*(1),0,0,1); glRotated(real_HUD_drho_compensation,0,1,0); glTranslated(0,0,-1); glLineWidth(3.0);
 double time_pos=game->fire_value;
 time_pos=1-time_pos + time_offset;
 if(time_pos<.1){
  time_pos=(time_pos)/.1;
  time_pos=(exp( 1-time_pos )-1)/(exp(1)-1);
  glTranslated(1*time_pos, 1.5-1+1*time_pos, 2.5);
  glRotated(-130*.5, 0, 1, 0);
  glRotated(-30*.5, 0, 0, 1);
  glRotated(10, 0, 1, 0);
  glPushMatrix();
   glRotated(90, 0, 1, 0);
   glRotated(90, 1, 0, 0);
   glRotated(3, 1, 0, 0);
   glTranslated(0,.3,-8+5*time_pos);
   glTranslated(0,0,-1*(1-time_pos));
   draw_arrow_high_quality();
  glPopMatrix();
  draw_hand(.5*time_pos,2.+2-2*time_pos,1);
  if(mode==2){
   draw_bow_v3(.2,.5*time_pos);
  }else if(mode==1){
   draw_bow_v2(.2,.5*time_pos);
  }else{
   draw_bow(.2,.5*time_pos);
  }
 }else if(time_pos<.3){
  time_pos=(time_pos-.1)/.2;
  glTranslated(0, 1.5-1, 2.5);
  glRotated(-130*.5, 0, 1, 0);
  glRotated(-30*.5, 0, 0, 1);
  glRotated(10, 0, 1, 0);
  glRotated(-40*time_pos, 1, 0, 0);
  glTranslated(0, 0, -3*time_pos);
  draw_hand(0,2.+2,1);
  if (mode==2){
   draw_bow_v3(.2,0);
  }else if(mode==1){
   draw_bow_v2(.2,0);
  }else{
   draw_bow(.2,0);
  }
 }else if(time_pos<.6){
  time_pos=(time_pos-.3)/.3;
  glTranslated(0, 1.5-1, 2.5);
  glRotated(-130*.5, 0, 1, 0);
  glRotated(-30*.5, 0, 0, 1);
  glRotated(10, 0, 1, 0);
  glRotated(-40, 1, 0, 0);
  glTranslated(0, 0, -3*time_pos);
  glRotated(20*time_pos, 0, 1, 0);
  glRotated(20*time_pos, 1, 1, 0);
  glTranslated(0, 0, -3);
  draw_hand(0,2.+2-2*time_pos,1);
  if (mode==2){
   draw_bow_v3(.2,0);
  }else if(mode==1){
   draw_bow_v2(.2,0);
  }else{
   draw_bow(.2,0);
  }
 }else{
  double oscill_force=.5*sin(SDL_GetTicks()*.001)+.5*sin(SDL_GetTicks()*.00085);
  time_pos=(time_pos-.6)/.4;
  time_pos=1-time_pos;
  glTranslated(2*time_pos, 0, 0);
  glRotated(30*(time_pos), 0, 1, 0);
  glRotated(-0, 0, 0, 1);
  glPushMatrix();
   glRotated(60, 0, 1, 0);
   glRotated(60, 1, 0, 0);
   glTranslated(
    -.3+.1*sin(SDL_GetTicks()*.0017),
    1,
    -5+1*oscill_force
    );
   glTranslated(5*time_pos,5*time_pos,0);
   glTranslated(-10*time_pos,0,0);
   glRotated(-40*time_pos, 1,0,0);
   glTranslated(10*time_pos,0,0);
   glTranslated(0,2*time_pos,2*time_pos);
   glTranslated(-3*time_pos,0,0);
   draw_arrow_high_quality();
    if(mode){
     glPushMatrix();
      glTranslated(-1.3,0,1.7);
      glRotated(10,0,1,0);
      draw_arrow_high_quality();
     glPopMatrix();
     glPushMatrix();
      glTranslated(1.3,0,1);
      glRotated(-10,0,1,0);
      draw_arrow_high_quality();
     glPopMatrix();
    }
  glPopMatrix();
  draw_hand( .3+.1*oscill_force,0,0);
  if(mode==2){
   draw_bow_v3(.2,.2+.1*oscill_force);
  }else if(mode==1){
   draw_bow_v2(.2,.2+.1*oscill_force);
  }else{
   draw_bow(.2,.2+.1*oscill_force);
  }
 }
 glPopMatrix();
}

canonical_original_code:
void weapon_HUD_FIRE(struct Game *game, int mode, double time_offset){
 glPushMatrix();
 double real_rho = game->player->rho +fake_rho; double real_theta = game->player->theta+fake_theta; glRotated(real_rho*(-4),1,0,0); glRotated(real_theta*.5, 0.0, 1.0, 0.0); double real_HUD_drho_compensation = HUD_drho_compensation+fake_HUD_drho_compensation; glTranslated(0,0,-real_HUD_drho_compensation*real_HUD_drho_compensation*0.0007); glTranslated(5,0,-3); glTranslated(real_theta*(.05),0,0); glRotated(80, 0, 1, 0); glRotated(70, 1, 0, 0); glRotated(real_theta*(1),0,0,1); glRotated(real_HUD_drho_compensation,0,1,0); glTranslated(0,0,-1); glLineWidth(3.0);
 double time_pos = game->fire_value;
 time_pos=1-time_pos + time_offset;
 if(time_pos<.1){
  time_pos=(time_pos)/.1;
  time_pos=(exp( 1-time_pos )-1)/(exp(1)-1);
  glTranslated(1*time_pos, 1.5-1+1*time_pos, 2.5);
  glRotated(-130*.5, 0, 1, 0);
  glRotated(-30*.5, 0, 0, 1);
  glRotated(10, 0, 1, 0);
  glPushMatrix();
   glRotated(90, 0, 1, 0);
   glRotated(90, 1, 0, 0);
   glRotated(3, 1, 0, 0);
   glTranslated(0,.3,-8+5*time_pos);
   glTranslated(0,0,-1*(1-time_pos));
   draw_arrow_high_quality();
  glPopMatrix();
  draw_hand(.5*time_pos,2.+2-2*time_pos,1);
  if(mode==2){
   draw_bow_v3(.2,.5*time_pos);
  }else if(mode==1){
   draw_bow_v2(.2,.5*time_pos);
  }else{
   draw_bow(.2,.5*time_pos);
  }
 }else if(time_pos<.3){
  time_pos=(time_pos-.1)/.2;
  glTranslated(0, 1.5-1, 2.5);
  glRotated(-130*.5, 0, 1, 0);
  glRotated(-30*.5, 0, 0, 1);
  glRotated(10, 0, 1, 0);
  glRotated(-40*time_pos, 1, 0, 0);
  glTranslated(0, 0, -3*time_pos);
  draw_hand(0,2.+2,1);
  if (mode==2){
   draw_bow_v3(.2,0);
  }else if(mode==1){
   draw_bow_v2(.2,0);
  }else{
   draw_bow(.2,0);
  }
 }else if(time_pos<.6){
  time_pos=(time_pos-.3)/.3;
  glTranslated(0, 1.5-1, 2.5);
  glRotated(-130*.5, 0, 1, 0);
  glRotated(-30*.5, 0, 0, 1);
  glRotated(10, 0, 1, 0);
  glRotated(-40, 1, 0, 0);
  glTranslated(0, 0, -3*time_pos);
  glRotated(20*time_pos, 0, 1, 0);
  glRotated(20*time_pos, 1, 1, 0);
  glTranslated(0, 0, -3);
  draw_hand(0,2.+2-2*time_pos,1);
  if (mode==2){
   draw_bow_v3(.2,0);
  }else if(mode==1){
   draw_bow_v2(.2,0);
  }else{
   draw_bow(.2,0);
  }
 }else{
  double oscill_force = .5*sin(SDL_GetTicks()*.001)+.5*sin(SDL_GetTicks()*.00085);
  time_pos=(time_pos-.6)/.4;
  time_pos=1-time_pos;
  glTranslated(2*time_pos, 0, 0);
  glRotated(30*(time_pos), 0, 1, 0);
  glRotated(-0, 0, 0, 1);
  glPushMatrix();
   glRotated(60, 0, 1, 0);
   glRotated(60, 1, 0, 0);
   glTranslated(
    -.3+.1*sin(SDL_GetTicks()*.0017),
    1,
    -5+1*oscill_force
    );
   glTranslated(5*time_pos,5*time_pos,0);
   glTranslated(-10*time_pos,0,0);
   glRotated(-40*time_pos, 1,0,0);
   glTranslated(10*time_pos,0,0);
   glTranslated(0,2*time_pos,2*time_pos);
   glTranslated(-3*time_pos,0,0);
   draw_arrow_high_quality();
    if(mode){
     glPushMatrix();
      glTranslated(-1.3,0,1.7);
      glRotated(10,0,1,0);
      draw_arrow_high_quality();
     glPopMatrix();
     glPushMatrix();
      glTranslated(1.3,0,1);
      glRotated(-10,0,1,0);
      draw_arrow_high_quality();
     glPopMatrix();
    }
  glPopMatrix();
  draw_hand( .3+.1*oscill_force,0,0);
  if(mode==2){
   draw_bow_v3(.2,.2+.1*oscill_force);
  }else if(mode==1){
   draw_bow_v2(.2,.2+.1*oscill_force);
  }else{
   draw_bow(.2,.2+.1*oscill_force);
  }
 }
 glPopMatrix();
}

user_defined_types: struct vorbis_info { int version; int channels; long rate; long bitrate_upper; long bitrate_nominal; long bitrate_lower; long bitrate_window; void *codec_setup; }

user_defined_types: struct vorbis_comment { char **user_comments; int *comment_lengths; int comments; char *vendor; }


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

if ( a1[23] <= 0.0 )
result = weapon_HUD_ARM(a1, a2, a3);
else
result = weapon_HUD_FIRE(a1, a2, a3);
return result;
}

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

if ( a1[23] <= 0.0 )
result = func3(a1, a2, a3);
else
result = func4(a1, a2, a3);
return result;
}

original_code:
void bow_HUD(Game* game, int mode,double time_offset){
 if(game->fire_value<=0){
  weapon_HUD_ARM(game,mode,time_offset);
 }else{
  weapon_HUD_FIRE(game,mode,time_offset);
 }
}

canonical_original_code:
void bow_HUD(struct Game *game, int mode, double time_offset){
 if(game->fire_value<=0){
  weapon_HUD_ARM(game,mode,time_offset);
 }else{
  weapon_HUD_FIRE(game,mode,time_offset);
 }
}

user_defined_types: struct oggpack_buffer { long endbyte; int endbit; unsigned char *buffer; unsigned char *ptr; long storage; }

user_defined_types: struct alloc_chain { void *ptr; struct alloc_chain *next; }


decompiled_code:
__int64 __fastcall sulfateuse_HUD(double *a1, unsigned int a2, double a3, double a4, double a5, double a6)
{
int v6; // eax
double v7; // rbx
int v8; // eax
__int64 v9; // xmm2_8
double v10; // r14
double v11; // xmm0_8
int v12; // eax
int v13; // ebx
double v14; // xmm0_8
float v15; // xmm0_4
__int64 result; // rax
double v17; // [rsp+8h] [rbp-38h]
double v18; // [rsp+10h] [rbp-30h]
double v19; // [rsp+18h] [rbp-28h]

v6 = SDL_GetTicks();
v7 = sin((double)v6 * 0.001);
v8 = SDL_GetTicks();
v9 = LC15;
v10 = v7 * 0.5 + sin((double)v8 * 0.00085) * 0.5;
if ( n == 1 )
v11 = 16.0 * a1[25] + *(double *)∠
else
v11 = 10.0 * a1[25] + *(double *)∠
angle = *(_QWORD *)&v11;
glGetError();
v12 = n;
if ( n > 0 )
{
v13 = 0;
do
{
v14 = (double)v13 / (double)v12;
v18 = 1.0 - v14;
glPushMatrix(v14, (double)v12, *(double *)&v9, a6);
v19 = *(double *)(*(_QWORD *)a1 + 8LL) + *(double *)&fake_theta;
glRotated((*(double *)(*(_QWORD *)a1 + 24LL) + *(double *)&fake_rho) * -4.0, 1.0, 0.0);
glRotated(v19 * 0.5, 0.0, 1.0);
v17 = *(double *)&HUD_drho_compensation + *(double *)&fake_HUD_drho_compensation;
glTranslated(
v19 * 0.05 + 5.0,
0.0,
COERCE_DOUBLE(COERCE_UNSIGNED_INT64(*(double *)&HUD_drho_compensation + *(double *)&fake_HUD_drho_compensation) ^ LC22)
* (*(double *)&HUD_drho_compensation + *(double *)&fake_HUD_drho_compensation)
* 0.0007
- 3.0);
glRotated(80.0, 0.0, 1.0);
glRotated(70.0, 1.0, 0.0);
glRotated(v19, 0.0, 0.0);
a6 = 0.0;
glRotated(v17, 0.0, 1.0);
v9 = LC28;
glTranslated(0.0, 0.0, -1.0);
if ( (1.0 - v14) * a1[25] != 0.0 )
{
glTranslated(0.0, COERCE_DOUBLE(*(_QWORD *)&v18 ^ LC22) * a1[23], 0.0);
a6 = *(double *)&LC12;
v9 = 0LL;
glRotated(v18 * -2.0 * a1[23], 0.0, 0.0);
}
glLineWidth(3.0);
draw_hand(0LL, v10 * 0.1 + 0.3, 0.0);
draw_sulfateuse(a2, 0.0, *(double *)&angle - (double)(4 * v13) * a1[25], *(double *)&v9, a6);
glPopMatrix();
v15 = 1.0 / (double)n;
if ( v13 )
glAccum(256LL, v15);
else
glAccum(257LL, v15);
++v13;
v12 = n;
}
while ( n > v13 );
}
glAccum(258LL, 1.0);
result = glGetError();
if ( (result & 0x502) != 0 )
n = 1;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func6(double *a1, unsigned int a2, double a3, double a4, double a5, double a6)
{
int v6; // eax
double v7; // rbx
int v8; // eax
__int64 v9; // xmm2_8
double v10; // r14
double v11; // xmm0_8
int v12; // eax
int v13; // ebx
double v14; // xmm0_8
float v15; // xmm0_4
__int64 result; // rax
double v17; // [rsp+8h] [rbp-38h]
double v18; // [rsp+10h] [rbp-30h]
double v19; // [rsp+18h] [rbp-28h]

v6 = SDL_GetTicks();
v7 = sin((double)v6 * 0.001);
v8 = SDL_GetTicks();
v9 = LC15;
v10 = v7 * 0.5 + sin((double)v8 * 0.00085) * 0.5;
if ( n == 1 )
v11 = 16.0 * a1[25] + *(double *)∠
else
v11 = 10.0 * a1[25] + *(double *)∠
angle = *(_QWORD *)&v11;
glGetError();
v12 = n;
if ( n > 0 )
{
v13 = 0;
do
{
v14 = (double)v13 / (double)v12;
v18 = 1.0 - v14;
glPushMatrix(v14, (double)v12, *(double *)&v9, a6);
v19 = *(double *)(*(_QWORD *)a1 + 8LL) + *(double *)&fake_theta;
glRotated((*(double *)(*(_QWORD *)a1 + 24LL) + *(double *)&fake_rho) * -4.0, 1.0, 0.0);
glRotated(v19 * 0.5, 0.0, 1.0);
v17 = *(double *)&HUD_drho_compensation + *(double *)&fake_HUD_drho_compensation;
glTranslated(
v19 * 0.05 + 5.0,
0.0,
COERCE_DOUBLE(COERCE_UNSIGNED_INT64(*(double *)&HUD_drho_compensation + *(double *)&fake_HUD_drho_compensation) ^ LC22)
* (*(double *)&HUD_drho_compensation + *(double *)&fake_HUD_drho_compensation)
* 0.0007
- 3.0);
glRotated(80.0, 0.0, 1.0);
glRotated(70.0, 1.0, 0.0);
glRotated(v19, 0.0, 0.0);
a6 = 0.0;
glRotated(v17, 0.0, 1.0);
v9 = LC28;
glTranslated(0.0, 0.0, -1.0);
if ( (1.0 - v14) * a1[25] != 0.0 )
{
glTranslated(0.0, COERCE_DOUBLE(*(_QWORD *)&v18 ^ LC22) * a1[23], 0.0);
a6 = *(double *)&LC12;
v9 = 0LL;
glRotated(v18 * -2.0 * a1[23], 0.0, 0.0);
}
glLineWidth(3.0);
draw_hand(0LL, v10 * 0.1 + 0.3, 0.0);
draw_sulfateuse(a2, 0.0, *(double *)&angle - (double)(4 * v13) * a1[25], *(double *)&v9, a6);
glPopMatrix();
v15 = 1.0 / (double)n;
if ( v13 )
glAccum(256LL, v15);
else
glAccum(257LL, v15);
++v13;
v12 = n;
}
while ( n > v13 );
}
glAccum(258LL, 1.0);
result = glGetError();
if ( (result & 0x502) != 0 )
n = 1;
return result;
}

original_code:
void sulfateuse_HUD(Game* game, int color,double time_offset){
 double oscill_force=.5*sin(SDL_GetTicks()*.001)+.5*sin(SDL_GetTicks()*.00085);
 if(n==1){
  angle+=game->trigger_value*16.;
 }else{
  angle+=game->trigger_value*10.;
 }
 glGetError();
 for(int i=0;i<n;i++){
  double x=1-i*1./n;
  glPushMatrix();
    double real_rho=game->player->rho +fake_rho;
    double real_theta=game->player->theta+fake_theta;
    glRotated(real_rho*(-4),1,0,0);
    glRotated(real_theta*.5, 0, 1, 0);
    double real_HUD_drho_compensation=HUD_drho_compensation+fake_HUD_drho_compensation;
    glTranslated(real_theta*(.05)+5,0,-real_HUD_drho_compensation*real_HUD_drho_compensation*0.0007-3);
    glRotated(80, 0, 1, 0);
    glRotated(70, 1, 0, 0);
    glRotated(real_theta*(1),0,0,1);
    glRotated(real_HUD_drho_compensation,0,1,0);
     glTranslated(0,0,-1);
    if(x*game->trigger_value){
     glTranslated(0,-x*game->fire_value,0);
     glRotated(-2*x*game->fire_value,0,0,1);
    }
    glLineWidth(3.0);
    draw_hand( .3+.1*oscill_force,0,0);
    draw_sulfateuse(0,angle-4*i*game->trigger_value,color);
  glPopMatrix();
  if(i == 0)
   glAccum(0x0101, 1.0 / n);
  else
   glAccum(0x0100, 1.0 / n);
 }
 glAccum(0x0102, 1.0);
 if(glGetError()&0x0502) {
  n=1;
 }
}

canonical_original_code:
void sulfateuse_HUD(struct Game *game, int color, double time_offset){
 double oscill_force = .5*sin(SDL_GetTicks()*.001)+.5*sin(SDL_GetTicks()*.00085);
 if(n==1){
  angle+=game->trigger_value*16.;
 }else{
  angle+=game->trigger_value*10.;
 }
 glGetError();
 for(int i = 0;i<n;i++){
  double x = 1-i*1./n;
  glPushMatrix();
    double real_rho = game->player->rho +fake_rho;
    double real_theta = game->player->theta+fake_theta;
    glRotated(real_rho*(-4),1,0,0);
    glRotated(real_theta*.5, 0, 1, 0);
    double real_HUD_drho_compensation = HUD_drho_compensation+fake_HUD_drho_compensation;
    glTranslated(real_theta*(.05)+5,0,-real_HUD_drho_compensation*real_HUD_drho_compensation*0.0007-3);
    glRotated(80, 0, 1, 0);
    glRotated(70, 1, 0, 0);
    glRotated(real_theta*(1),0,0,1);
    glRotated(real_HUD_drho_compensation,0,1,0);
     glTranslated(0,0,-1);
    if(x*game->trigger_value){
     glTranslated(0,-x*game->fire_value,0);
     glRotated(-2*x*game->fire_value,0,0,1);
    }
    glLineWidth(3.0);
    draw_hand( .3+.1*oscill_force,0,0);
    draw_sulfateuse(0,angle-4*i*game->trigger_value,color);
  glPopMatrix();
  if(i == 0)
   glAccum(0x0101, 1.0 / n);
  else
   glAccum(0x0100, 1.0 / n);
 }
 glAccum(0x0102, 1.0);
 if(glGetError()&0x0502) {
  n=1;
 }
}

variable_types: color int

variable_types: i int

variable_types: x double

user_defined_types: struct ogg_sync_state { unsigned char *data; int storage; int fill; int returned; int unsynced; int headerbytes; int bodybytes; }

user_defined_types: struct ogg_stream_state { unsigned char *body_data; long body_storage; long body_fill; long body_returned; int *lacing_vals; long *granule_vals; long lacing_storage; long lacing_fill; long lacing_packet; long lacing_returned; unsigned char header[282]; int header_fill; int e_o_s; int b_o_s; long serialno; long pageno; long packetno; long granulepos; }


HUD

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

result = *(unsigned int *)(a1 + 216);
if ( (_DWORD)result )
{
switch ( (_DWORD)result )
{
case 1:
result = bow_HUD((double *)a1, 0, 0.0);
break;
case 2:
result = sulfateuse_HUD((double *)a1, 0, 0.0, a3, a4, a5);
break;
case 3:
result = sulfateuse_HUD((double *)a1, 1u, 0.0, a3, a4, a5);
break;
case 4:
result = bow_HUD((double *)a1, 1, 0.0);
break;
case 5:
result = bow_HUD((double *)a1, 2, 0.0);
break;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1, double a2, double a3, double a4, double a5)
{
__int64 result; // rax

result = *(unsigned int *)(a1 + 216);
if ( (_DWORD)result )
{
switch ( (_DWORD)result )
{
case 1:
result = func5((double *)a1, 0, 0.0);
break;
case 2:
result = func6((double *)a1, 0, 0.0, a3, a4, a5);
break;
case 3:
result = func6((double *)a1, 1u, 0.0, a3, a4, a5);
break;
case 4:
result = func5((double *)a1, 1, 0.0);
break;
case 5:
result = func5((double *)a1, 2, 0.0);
break;
}
}
return result;
}

original_code:
void HUD(Game* game){
  double time_offset=0;
    if(game->weapon==0){
    }
    else if(game->weapon==1){
     bow_HUD(game,0,time_offset);
    }
    else if(game->weapon==2){
     sulfateuse_HUD(game,0,time_offset);
    }else if(game->weapon==3){
     sulfateuse_HUD(game,1,time_offset);
    }else if(game->weapon==4){
     bow_HUD(game,1,time_offset);
    }else if(game->weapon==5){
     bow_HUD(game,2,time_offset);
    }
}

canonical_original_code:
void HUD(struct Game *game){
  double time_offset = 0;
    if(game->weapon==0){
    }
    else if(game->weapon==1){
     bow_HUD(game,0,time_offset);
    }
    else if(game->weapon==2){
     sulfateuse_HUD(game,0,time_offset);
    }else if(game->weapon==3){
     sulfateuse_HUD(game,1,time_offset);
    }else if(game->weapon==4){
     bow_HUD(game,1,time_offset);
    }else if(game->weapon==5){
     bow_HUD(game,2,time_offset);
    }
}

user_defined_types: struct AudioPlayer { struct SoundSample *s1; char *next_file_path; char *now_playing; double time_buffer_offset; unsigned int source_id; unsigned int buffer_id[2]; unsigned int sound_buffer; }

user_defined_types: struct SoundSample { char *data; char *old_data; int size; int old_read_size; int read_size; int freq; int format; int bitStream; union soundFile s_file; }


decompiled_code:
void __fastcall ingame_level4_update(__int64 a1)
{
__int64 v1; // rdx
int v2; // er12
double v3; // xmm0_8
char v4; // al
double v5; // r12
double v6; // [rsp+8h] [rbp-18h]
double v7; // [rsp+8h] [rbp-18h]

*(_QWORD *)(a1 + 176) = mechant_regeneration_type_level4_0;
v1 = *(_QWORD *)(a1 + 112);
if ( !strcmp(*(const char **)(v1 + 16), "music/Goto80_gopho_level4.ogg") )
{
audioplayer_set_next(v1, "music/silence.ogg");
v6 = audioplayer_getTime(*(_QWORD *)(a1 + 112));
v2 = SDL_GetTicks();
v3 = level3_get_time_offset();
t = fmod((double)v2 * 0.001 - v3, 0.96);
if ( v6 > 69.0 && v6 < 76.0 )
{
change_bg_color((v6 - 69.0) / 7.0, 0.0);
}
else if ( v6 > 76.0 && v6 < 83.0 )
{
if ( !ending_cleared )
{
clear_arrow(a1);
clear_particles(a1);
clear_mechant(a1);
ending_cleared = 1;
}
change_bg_color(1.0 - (v6 - 76.0) / 7.0, 0.0);
}
if ( v6 < 14.85 )
change_bg_color(1.0, 1.0);
if ( v6 > 14.85 && v6 < 15.3 )
{
v4 = mega_sulfateuse_transition;
if ( v6 > (double)mega_sulfateuse_transition * 0.4500000000000011 / 7.0 + 14.85 )
{
++mega_sulfateuse_transition;
if ( ((v4 + 1) & 1) != 0 )
{
change_bg_color(1.0, 0.0);
*(_DWORD *)(a1 + 216) = 3;
}
else
{
change_bg_color(0.5, 0.0);
*(_DWORD *)(a1 + 216) = 2;
}
}
}
if ( v6 > 15.3 && v6 < 76.0 )
{
if ( mega_sulfateuse_transition )
{
change_bg_color(0.0, 0.0);
*(_DWORD *)(a1 + 216) = 3;
mega_sulfateuse_transition = 0;
}
v5 = *(double *)&t;
*(_QWORD *)(a1 + 136) = t;
*(double *)(a1 + 144) = v5 / 0.96;
v7 = exp(v5 * -4.0);
*(double *)(a1 + 128) = (v7 + v7) * sin(v5 * 24.0);
}
}
}

canonical_decompiled_code:
void __fastcall func0(__int64 a1)
{
__int64 v1; // rdx
int v2; // er12
double v3; // xmm0_8
char v4; // al
double v5; // r12
double v6; // [rsp+8h] [rbp-18h]
double v7; // [rsp+8h] [rbp-18h]

*(_QWORD *)(a1 + 176) = mechant_regeneration_type_level4_0;
v1 = *(_QWORD *)(a1 + 112);
if ( !strcmp(*(const char **)(v1 + 16), "music/Goto80_gopho_level4.ogg") )
{
audioplayer_set_next(v1, "music/silence.ogg");
v6 = audioplayer_getTime(*(_QWORD *)(a1 + 112));
v2 = SDL_GetTicks();
v3 = level3_get_time_offset();
t = fmod((double)v2 * 0.001 - v3, 0.96);
if ( v6 > 69.0 && v6 < 76.0 )
{
change_bg_color((v6 - 69.0) / 7.0, 0.0);
}
else if ( v6 > 76.0 && v6 < 83.0 )
{
if ( !ending_cleared )
{
clear_arrow(a1);
clear_particles(a1);
clear_mechant(a1);
ending_cleared = 1;
}
change_bg_color(1.0 - (v6 - 76.0) / 7.0, 0.0);
}
if ( v6 < 14.85 )
change_bg_color(1.0, 1.0);
if ( v6 > 14.85 && v6 < 15.3 )
{
v4 = mega_sulfateuse_transition;
if ( v6 > (double)mega_sulfateuse_transition * 0.4500000000000011 / 7.0 + 14.85 )
{
++mega_sulfateuse_transition;
if ( ((v4 + 1) & 1) != 0 )
{
change_bg_color(1.0, 0.0);
*(_DWORD *)(a1 + 216) = 3;
}
else
{
change_bg_color(0.5, 0.0);
*(_DWORD *)(a1 + 216) = 2;
}
}
}
if ( v6 > 15.3 && v6 < 76.0 )
{
if ( mega_sulfateuse_transition )
{
change_bg_color(0.0, 0.0);
*(_DWORD *)(a1 + 216) = 3;
mega_sulfateuse_transition = 0;
}
v5 = *(double *)&t;
*(_QWORD *)(a1 + 136) = t;
*(double *)(a1 + 144) = v5 / 0.96;
v7 = exp(v5 * -4.0);
*(double *)(a1 + 128) = (v7 + v7) * sin(v5 * 24.0);
}
}
}

original_code:
void ingame_level4_update(Game* game,int dt){
 int mechant_regeneration_type_level4(){
  return rand()%3;
 }
 game->mechant_regeneration_type=mechant_regeneration_type_level4;
 if(!strcmp(game->audio->now_playing,"music/Goto80_gopho_level4.ogg")){
  audioplayer_set_next(game->audio,"music/silence.ogg");
  double music_time=audioplayer_getTime(game->audio);
  double time_=SDL_GetTicks()*0.001-level3_get_time_offset();
  t=fmod(time_,deltat);
  if(music_time>69 && music_time<69+7){
   double xxx =(music_time-69.)/7.;
   change_bg_color(xxx,0.,0.);
  }else if(music_time>76 && music_time<83){
   if(!ending_cleared){
    clear_arrow(game);
    clear_particles(game);
    clear_mechant(game);
    ending_cleared=1;
   }
   double xxx=(music_time-76)/(83.-76.);
   change_bg_color(1.-xxx,0.,0.);
  }
  if(music_time<14.85){
   change_bg_color(1,1,1);
  }
  if(music_time>14.85 && music_time<15.30 ){
   if(music_time>14.85+mega_sulfateuse_transition*(15.30-14.85)/7.){
    mega_sulfateuse_transition++;
    if(mega_sulfateuse_transition%2==0){
     change_bg_color(.5,0,0);
     game->weapon=2;
    }else{
     change_bg_color(1,0,0);
     game->weapon=3;
    }
   }
  }
  if(music_time>15.30 && music_time<69+7 ){
   if(mega_sulfateuse_transition){
    change_bg_color(0,0,0);
    game->weapon=3;
    mega_sulfateuse_transition=0;
   }
   game->heart_beat_time=t;
   game->heart_beat_time_normalized=t/deltat;
   game->heart_beat=2*exp(-4*t)*sin(24*t);
  }
 }
}

canonical_original_code:
void ingame_level4_update(struct Game *game, int dt){
 int mechant_regeneration_type_level4(){
  return rand()%3;
 }
 game->mechant_regeneration_type=mechant_regeneration_type_level4;
 if(!strcmp(game->audio->now_playing,"music/Goto80_gopho_level4.ogg")){
  audioplayer_set_next(game->audio,"music/silence.ogg");
  double music_time = audioplayer_getTime(game->audio);
  double time_ = SDL_GetTicks()*0.001-level3_get_time_offset();
  t=fmod(time_,deltat);
  if(music_time>69 && music_time<69+7){
   double xxx = (music_time-69.)/7.;
   change_bg_color(xxx,0.,0.);
  }else if(music_time>76 && music_time<83){
   if(!ending_cleared){
    clear_arrow(game);
    clear_particles(game);
    clear_mechant(game);
    ending_cleared=1;
   }
   double xxx = (music_time-76)/(83.-76.);
   change_bg_color(1.-xxx,0.,0.);
  }
  if(music_time<14.85){
   change_bg_color(1,1,1);
  }
  if(music_time>14.85 && music_time<15.30 ){
   if(music_time>14.85+mega_sulfateuse_transition*(15.30-14.85)/7.){
    mega_sulfateuse_transition++;
    if(mega_sulfateuse_transition%2==0){
     change_bg_color(.5,0,0);
     game->weapon=2;
    }else{
     change_bg_color(1,0,0);
     game->weapon=3;
    }
   }
  }
  if(music_time>15.30 && music_time<69+7 ){
   if(mega_sulfateuse_transition){
    change_bg_color(0,0,0);
    game->weapon=3;
    mega_sulfateuse_transition=0;
   }
   game->heart_beat_time=t;
   game->heart_beat_time_normalized=t/deltat;
   game->heart_beat=2*exp(-4*t)*sin(24*t);
  }
 }
}

variable_types: xxx double

user_defined_types: union soundFile { struct OggVorbis_File oggFile; }

user_defined_types: struct OggVorbis_File { void *datasource; int seekable; long offset; long end; struct ogg_sync_state oy; int links; long *offsets; long *dataoffsets; long *serialnos; long *pcmlengths; struct vorbis_info *vi; struct vorbis_comment *vc; long pcm_offset; int ready_state; long current_serialno; int current_link; double bittrack; double samptrack; struct ogg_stream_state os; struct vorbis_dsp_state vd; struct vorbis_block vb; struct ov_callbacks callbacks; }


decompiled_code:
char __fastcall ingame_level4_render(__int64 a1)
{
double v1; // xmm0_8
bool v2; // zf
char result; // al

v1 = audioplayer_getTime(*(_QWORD *)(a1 + 112));
v2 = strcmp(*(const char **)(*(_QWORD *)(a1 + 112) + 16LL), "music/Goto80_gopho_level4.ogg") == 0;
result = !v2;
if ( v2 )
{
if ( v1 > 15.3 && v1 < 69.0 )
result = draw_sky_random_cubes((double *)a1, 1.0);
if ( v1 > 69.0 && v1 < 76.0 )
result = draw_sky_random_cubes((double *)a1, 1.0 - (v1 - 69.0) / 7.0);
}
return result;
}

canonical_decompiled_code:
char __fastcall func3(__int64 a1)
{
double v1; // xmm0_8
bool v2; // zf
char result; // al

v1 = audioplayer_getTime(*(_QWORD *)(a1 + 112));
v2 = strcmp(*(const char **)(*(_QWORD *)(a1 + 112) + 16LL), "music/Goto80_gopho_level4.ogg") == 0;
result = !v2;
if ( v2 )
{
if ( v1 > 15.3 && v1 < 69.0 )
result = func2((double *)a1, 1.0);
if ( v1 > 69.0 && v1 < 76.0 )
result = func2((double *)a1, 1.0 - (v1 - 69.0) / 7.0);
}
return result;
}

original_code:
void ingame_level4_render(Game* game){
 double music_time=audioplayer_getTime(game->audio);
 if(!strcmp(game->audio->now_playing,"music/Goto80_gopho_level4.ogg")){
  if(music_time>15.30 && music_time<69 ){
   draw_sky_random_cubes(game,1);
  }if(music_time>69 && music_time<69+7){
   double k=(music_time-69)/7.;
   draw_sky_random_cubes(game,1-k);
  }
 }
}

canonical_original_code:
void ingame_level4_render(struct Game *game){
 double music_time = audioplayer_getTime(game->audio);
 if(!strcmp(game->audio->now_playing,"music/Goto80_gopho_level4.ogg")){
  if(music_time>15.30 && music_time<69 ){
   draw_sky_random_cubes(game,1);
  }if(music_time>69 && music_time<69+7){
   double k = (music_time-69)/7.;
   draw_sky_random_cubes(game,1-k);
  }
 }
}

variable_types: k double

user_defined_types: struct Game { struct Camera *player; struct Arrow *arrows; struct Arrow *arrows_last; struct Arrow *arrows_to_update; struct Arrow *sorting_arrow; struct Arrow *sorting_next; int color_debug; int sorting; double world_x_size; double world_y_size; double speed_custom; struct Mechant *mechants; struct Mechant *mechants_last; struct Particle *particles; struct Particle *particles_update; struct AudioPlayer *audio; double audio_amplitude; double heart_beat; double heart_beat_time; double heart_beat_time_normalized; void (*update)(struct Game *game, int dt); void (*render)(struct Game *game); void (*HUD_render)(struct Game *game); int (*mechant_regeneration_type)(); double fire_value; int fire_state; double trigger_value; int trigger_state; int FIRST_SHOT; int weapon; int stereo; void (*trigger)(struct Game *game, int state); void (*fire)(struct Game *game, int state); }

user_defined_types: struct vorbis_block { float **pcm; struct oggpack_buffer opb; long lW; long W; long nW; int pcmend; int mode; int eofflag; long granulepos; long sequence; struct vorbis_dsp_state *vd; void *localstore; long localtop; long localalloc; long totaluse; struct alloc_chain *reap; long glue_bits; long time_bits; long floor_bits; long res_bits; void *internal; }