decompiled_code:
__int64 __fastcall camera_render(double *a1, __int64 a2)
{
glClear(16640LL);
SDL_GetTicks();
camera_look(a1);
glMatrixMode(5888LL);
glLoadIdentity();
gluLookAt(0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0);
glRotated(a1[3], 1.0, 0.0);
glRotated(a1[1], 0.0, 1.0);
glRotated(a1[2], 0.0, 0.0);
glTranslated(a1[10], a1[11] + a1[13], a1[12] + a1[14], 1.0);
game_render(*(_QWORD *)a1);
glClear(256LL);
return camera_HUD(a1, a2);
}

original_code:
void camera_render(Camera* c){
 glClear(0x00004000 | 0x00000100);
 double time_=SDL_GetTicks()*0.001;
 camera_look(c);
 glMatrixMode(0x1700);
 glLoadIdentity();
 gluLookAt(
 0,0,0,
 1,0,0,
 0,0,1);
 glRotated(c->rho,1,0,0);
 glRotated(c->theta, 0.0, 1.0, 0.0);
 glRotated(c->phi, 0.0, 0.0, 1.0);
 glTranslated(c->x, c->y + c->fake_y, c->z + c->fake_z);
 game_render(c->game);
 glClear(0x00000100);
 camera_HUD(c);
}

canonical_original_code:
void camera_render(struct Camera *c){
 glClear(0x00004000 | 0x00000100);
 double time_ = SDL_GetTicks()*0.001;
 camera_look(c);
 glMatrixMode(0x1700);
 glLoadIdentity();
 gluLookAt(
 0,0,0,
 1,0,0,
 0,0,1);
 glRotated(c->rho,1,0,0);
 glRotated(c->theta, 0.0, 1.0, 0.0);
 glRotated(c->phi, 0.0, 0.0, 1.0);
 glTranslated(c->x, c->y + c->fake_y, c->z + c->fake_z);
 game_render(c->game);
 glClear(0x00000100);
 camera_HUD(c);
}

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 camera_ApplyLeftFrustum(__int64 a1, double a2, double a3, double a4, double a5)
{
double v5; // xmm0_8

glTranslated(*(double *)(a1 + 168), 0.0, 0.0, a5);
v5 = atan(*(double *)(a1 + 176) / *(double *)(a1 + 168));
glRotated(v5 * -57.29577951307855, 0.0, 0.0);
return glTranslated(COERCE_DOUBLE(*(_QWORD *)(a1 + 168) ^ LC1), 0.0, 0.0, 1.0);
}

original_code:
void camera_ApplyLeftFrustum(Camera* c){
 glTranslated(c->mConvergence,0,0);
 glRotated( -180/3.14159265359*atan(c->mEyeSeparation/c->mConvergence),0,0,1);
 glTranslated(-c->mConvergence,0,0);
}

canonical_original_code:
void camera_ApplyLeftFrustum(struct Camera *c){
 glTranslated(c->mConvergence,0,0);
 glRotated( -180/3.14159265359*atan(c->mEyeSeparation/c->mConvergence),0,0,1);
 glTranslated(-c->mConvergence,0,0);
}

variable_types: struct Camera { struct Game { struct Camera *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); } *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; } *

return_type: void

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 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:
__int64 __fastcall camera_ApplyRightFrustum(__int64 a1, double a2, double a3, double a4, double a5)
{
double v5; // xmm0_8

glTranslated(*(double *)(a1 + 168), 0.0, 0.0, a5);
v5 = atan(*(double *)(a1 + 176) / *(double *)(a1 + 168));
glRotated(v5 * 57.29577951307855, 0.0, 0.0);
return glTranslated(COERCE_DOUBLE(*(_QWORD *)(a1 + 168) ^ LC1), 0.0, 0.0, 1.0);
}

original_code:
void camera_ApplyRightFrustum(Camera* c){
 glTranslated(c->mConvergence,0,0);
 glRotated( +180/3.14159265359*atan(c->mEyeSeparation/c->mConvergence),0,0,1);
 glTranslated(-c->mConvergence,0,0);
}

canonical_original_code:
void camera_ApplyRightFrustum(struct Camera *c){
 glTranslated(c->mConvergence,0,0);
 glRotated( +180/3.14159265359*atan(c->mEyeSeparation/c->mConvergence),0,0,1);
 glTranslated(-c->mConvergence,0,0);
}

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

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 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 camera_render_stereo(double *a1)
{
double v1; // xmm0_8
double v2; // xmm2_8
double v3; // xmm1_8
double v4; // xmm0_8
double v5; // xmm2_8
double v6; // xmm1_8

glClear(16640LL);
camera_look(a1);
glColorMask(1LL, 0LL, 0LL, 0LL);
glMatrixMode(5888LL);
((void (*)(void))glLoadIdentity)();
gluLookAt(0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0);
glRotated(a1[3], 1.0, 0.0);
glRotated(a1[1], 0.0, 1.0);
glRotated(a1[2], 0.0, 0.0);
v1 = a1[10];
v2 = a1[12];
v3 = a1[11];
glTranslated(v1, v3, v2, 1.0);
camera_ApplyLeftFrustum((__int64)a1, v1, v3, v2, 1.0);
game_render(*(_QWORD *)a1);
glClear(256LL);
camera_look(a1);
glColorMask(0LL, 1LL, 1LL, 0LL);
glMatrixMode(5888LL);
glLoadIdentity(5888LL);
gluLookAt(0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0);
glRotated(a1[3], 1.0, 0.0);
glRotated(a1[1], 0.0, 1.0);
glRotated(a1[2], 0.0, 0.0);
v4 = a1[10];
v5 = a1[12];
v6 = a1[11];
glTranslated(v4, v6, v5, 1.0);
camera_ApplyRightFrustum((__int64)a1, v4, v6, v5, 1.0);
game_render(*(_QWORD *)a1);
glColorMask(1LL, 1LL, 1LL, 1LL);
glClear(256LL);
return camera_HUD(a1, 1LL);
}

original_code:
void camera_render_stereo(Camera* c){
 glClear(0x00004000 | 0x00000100);
 camera_look(c);
 glColorMask(1, 0, 0, 0);
 glMatrixMode(0x1700);
 glLoadIdentity();
 gluLookAt(
 0,0,0,
 1,0,0,
 0,0,1);
 glRotated(c->rho,1,0,0);
 glRotated(c->theta, 0.0, 1.0, 0.0);
 glRotated(c->phi, 0.0, 0.0, 1.0);
 glTranslated(c->x, c->y, c->z);
 camera_ApplyLeftFrustum(c);
 game_render(c->game);
 glClear(0x00000100) ;
 camera_look(c);
 glColorMask(0, 1, 1, 0);
 glMatrixMode(0x1700);
 glLoadIdentity();
 gluLookAt(
 0,0,0,
 1,0,0,
 0,0,1);
 glRotated(c->rho,1,0,0);
 glRotated(c->theta, 0.0, 1.0, 0.0);
 glRotated(c->phi, 0.0, 0.0, 1.0);
 glTranslated(c->x, c->y, c->z);
 camera_ApplyRightFrustum(c);
 game_render(c->game);
 glColorMask(1, 1, 1, 1);
 glClear(0x00000100);
 camera_HUD(c);
}

canonical_original_code:
void camera_render_stereo(struct Camera *c){
 glClear(0x00004000 | 0x00000100);
 camera_look(c);
 glColorMask(1, 0, 0, 0);
 glMatrixMode(0x1700);
 glLoadIdentity();
 gluLookAt(
 0,0,0,
 1,0,0,
 0,0,1);
 glRotated(c->rho,1,0,0);
 glRotated(c->theta, 0.0, 1.0, 0.0);
 glRotated(c->phi, 0.0, 0.0, 1.0);
 glTranslated(c->x, c->y, c->z);
 camera_ApplyLeftFrustum(c);
 game_render(c->game);
 glClear(0x00000100) ;
 camera_look(c);
 glColorMask(0, 1, 1, 0);
 glMatrixMode(0x1700);
 glLoadIdentity();
 gluLookAt(
 0,0,0,
 1,0,0,
 0,0,1);
 glRotated(c->rho,1,0,0);
 glRotated(c->theta, 0.0, 1.0, 0.0);
 glRotated(c->phi, 0.0, 0.0, 1.0);
 glTranslated(c->x, c->y, c->z);
 camera_ApplyRightFrustum(c);
 game_render(c->game);
 glColorMask(1, 1, 1, 1);
 glClear(0x00000100);
 camera_HUD(c);
}

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


variable_types: dt int

variable_types: i 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 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); }


original_code:
int sound_nextSample (SoundSample * sample) {
 char array[4096];
 long bytes;
 if(sample->read_size!=0){
  memcpy (sample->old_data, sample->data, sample->read_size);
  sample->old_read_size = sample->read_size;
 }
 sample->read_size = 0;
 do {
  bytes = ov_read (&sample->s_file.oggFile, array, 4096, 0, 2, 1, &sample->bitStream);
  memcpy (&sample->data[sample->read_size], array, bytes);
  sample->read_size += bytes;
 }while ((sample->read_size + 4096) < sample->size && bytes != 0);
 return sample->read_size;
}

canonical_original_code:
int sound_nextSample(struct SoundSample *sample) {
 char array[4096];
 long bytes;
 if(sample->read_size!=0){
  memcpy (sample->old_data, sample->data, sample->read_size);
  sample->old_read_size = sample->read_size;
 }
 sample->read_size = 0;
 do {
  bytes = ov_read (&sample->s_file.oggFile, array, 4096, 0, 2, 1, &sample->bitStream);
  memcpy (&sample->data[sample->read_size], array, bytes);
  sample->read_size += bytes;
 }while ((sample->read_size + 4096) < sample->size && bytes != 0);
 return sample->read_size;
}

variable_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 { 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; } *

variable_types:
array
char [4096]

variable_types: bytes long

return_type: int

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:
__int64 __fastcall sound_seekSample(__int64 a1)
{
return ov_raw_seek(a1 + 40, 0LL);
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1)
{
return ov_raw_seek(a1 + 40, 0LL);
}

original_code:
void sound_seekSample (SoundSample * sample) {
 ov_raw_seek (&sample->s_file.oggFile, 0);
}

canonical_original_code:
void sound_seekSample(struct SoundSample *sample) {
 ov_raw_seek (&sample->s_file.oggFile, 0);
}

user_defined_types: union soundFile { struct OggVorbis_File oggFile; }


decompiled_code:
void __fastcall sound_closeSample(void *ptr)
{
free(*(void **)ptr);
free(*((void **)ptr + 1));
ov_clear((char *)ptr + 40);
free(ptr);
}

canonical_decompiled_code:
void __fastcall func3(void *ptr)
{
free(*(void **)ptr);
free(*((void **)ptr + 1));
ov_clear((char *)ptr + 40);
free(ptr);
}

original_code:
void sound_closeSample (SoundSample * sample) {
 free (sample->data);
 free (sample->old_data);
 ov_clear (&sample->s_file.oggFile);
 free (sample);
}

canonical_original_code:
void sound_closeSample(struct SoundSample *sample) {
 free (sample->data);
 free (sample->old_data);
 ov_clear (&sample->s_file.oggFile);
 free (sample);
}

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_level2_update(__int64 a1)
{
__int64 v1; // r8
const char *v2; // rax
bool v4; // dl
bool v5; // cf
bool v6; // zf
const char *v7; // rsi
const char *v8; // rdi
__int64 v9; // rcx
char result; // al

v1 = *(_QWORD *)(a1 + 112);
v2 = *(const char **)(v1 + 16);
v4 = strcmp(v2, "music/Goto80_gopho_level2.ogg") != 0;
v5 = 0;
v6 = !v4;
if ( !v4 )
{
audioplayer_set_next(v1, "music/Goto80_gopho_level3.ogg");
*(double *)&sky_1_x = *(double *)&sky_1_dx * 0.5 + *(double *)&sky_1_x;
*(double *)&sky_1_y = *(double *)&sky_1_dy * 0.5 + *(double *)&sky_1_y;
game_loop_coord(a1, &sky_1_x, &sky_1_y);
*(double *)&sky_2_x = *(double *)&sky_2_dx * 0.5 + *(double *)&sky_2_x;
*(double *)&sky_2_y = *(double *)&sky_2_dy * 0.5 + *(double *)&sky_2_y;
game_loop_coord(a1, &sky_2_x, &sky_2_y);
*(double *)&sky_3_x = *(double *)&sky_3_dx * 0.5 + *(double *)&sky_3_x;
*(double *)&sky_3_y = 0.5 * *(double *)&sky_3_dy + *(double *)&sky_3_y;
game_loop_coord(a1, &sky_3_x, &sky_3_y);
v2 = *(const char **)(*(_QWORD *)(a1 + 112) + 16LL);
}
v7 = v2;
v8 = "music/Goto80_gopho_level3.ogg";
v9 = 30LL;
do
{
if ( !v9 )
break;
v5 = *v7 < (unsigned int)*v8;
v6 = *v7++ == *v8++;
--v9;
}
while ( v6 );
result = (!v5 && !v6) - v5;
if ( !result )
{
change_bg_color(v8, v7, 0.0, 0.0);
*(_DWORD *)(a1 + 216) = 2;
result = ingame_level3_setup(a1);
}
return result;
}

canonical_decompiled_code:
char __fastcall func0(__int64 a1)
{
__int64 v1; // r8
const char *v2; // rax
bool v4; // dl
bool v5; // cf
bool v6; // zf
const char *v7; // rsi
const char *v8; // rdi
__int64 v9; // rcx
char result; // al

v1 = *(_QWORD *)(a1 + 112);
v2 = *(const char **)(v1 + 16);
v4 = strcmp(v2, "music/Goto80_gopho_level2.ogg") != 0;
v5 = 0;
v6 = !v4;
if ( !v4 )
{
audioplayer_set_next(v1, "music/Goto80_gopho_level3.ogg");
*(double *)&sky_1_x = *(double *)&sky_1_dx * 0.5 + *(double *)&sky_1_x;
*(double *)&sky_1_y = *(double *)&sky_1_dy * 0.5 + *(double *)&sky_1_y;
game_loop_coord(a1, &sky_1_x, &sky_1_y);
*(double *)&sky_2_x = *(double *)&sky_2_dx * 0.5 + *(double *)&sky_2_x;
*(double *)&sky_2_y = *(double *)&sky_2_dy * 0.5 + *(double *)&sky_2_y;
game_loop_coord(a1, &sky_2_x, &sky_2_y);
*(double *)&sky_3_x = *(double *)&sky_3_dx * 0.5 + *(double *)&sky_3_x;
*(double *)&sky_3_y = 0.5 * *(double *)&sky_3_dy + *(double *)&sky_3_y;
game_loop_coord(a1, &sky_3_x, &sky_3_y);
v2 = *(const char **)(*(_QWORD *)(a1 + 112) + 16LL);
}
v7 = v2;
v8 = "music/Goto80_gopho_level3.ogg";
v9 = 30LL;
do
{
if ( !v9 )
break;
v5 = *v7 < (unsigned int)*v8;
v6 = *v7++ == *v8++;
--v9;
}
while ( v6 );
result = (!v5 && !v6) - v5;
if ( !result )
{
change_bg_color(v8, v7, 0.0, 0.0);
*(_DWORD *)(a1 + 216) = 2;
result = ingame_level3_setup(a1);
}
return result;
}

original_code:
void ingame_level2_update(Game* game,int dt){
 if(!strcmp(game->audio->now_playing,"music/Goto80_gopho_level2.ogg")){
  audioplayer_set_next(game->audio,"music/Goto80_gopho_level3.ogg");
  sky_1_x+=.5*sky_1_dx;
  sky_1_y+=.5*sky_1_dy;
  game_loop_coord(game,&sky_1_x,&sky_1_y);
  sky_2_x+=.5*sky_2_dx;
  sky_2_y+=.5*sky_2_dy;
  game_loop_coord(game,&sky_2_x,&sky_2_y);
  sky_3_x+=.5*sky_3_dx;
  sky_3_y+=.5*sky_3_dy;
  game_loop_coord(game,&sky_3_x,&sky_3_y);
 }
 if(!strcmp(game->audio->now_playing,"music/Goto80_gopho_level3.ogg")){
  change_bg_color(0,0,0);
  game->weapon=2;
  ingame_level3_setup(game);
 }
}

canonical_original_code:
void ingame_level2_update(struct Game *game, int dt){
 if(!strcmp(game->audio->now_playing,"music/Goto80_gopho_level2.ogg")){
  audioplayer_set_next(game->audio,"music/Goto80_gopho_level3.ogg");
  sky_1_x+=.5*sky_1_dx;
  sky_1_y+=.5*sky_1_dy;
  game_loop_coord(game,&sky_1_x,&sky_1_y);
  sky_2_x+=.5*sky_2_dx;
  sky_2_y+=.5*sky_2_dy;
  game_loop_coord(game,&sky_2_x,&sky_2_y);
  sky_3_x+=.5*sky_3_dx;
  sky_3_y+=.5*sky_3_dy;
  game_loop_coord(game,&sky_3_x,&sky_3_y);
 }
 if(!strcmp(game->audio->now_playing,"music/Goto80_gopho_level3.ogg")){
  change_bg_color(0,0,0);
  game->weapon=2;
  ingame_level3_setup(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 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 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:
__int64 __fastcall draw_stuff_in_sky(double a1, double a2, double a3, double a4, double a5, double a6, double a7, double a8)
{
int v8; // ebx
int v10; // er12
double v11; // xmm1_8
__int64 result; // rax
double v15; // [rsp+30h] [rbp-40h]
double v16; // [rsp+38h] [rbp-38h]

v8 = 0;
glLineWidth(5.0);
do
{
v10 = 0;
v15 = (0.5 - (double)v8 / 50.0) * 2000.0 + a1;
do
{
v11 = (double)v10++ / 50.0;
v16 = (0.5 - v11) * 2000.0 + a2;
glBegin(1LL);
glColor4d(0.0, 0.0, 0.0, 0.0);
glVertex3d(v15, v16, a3);
glColor4d(a6, a7, a8, *(double *)&sky_transparency);
glVertex3d(v15 + a4, v16 + a5, a3);
result = glEnd();
}
while ( v10 != 50 );
++v8;
}
while ( v8 != 50 );
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(double a1, double a2, double a3, double a4, double a5, double a6, double a7, double a8)
{
int v8; // ebx
int v10; // er12
double v11; // xmm1_8
__int64 result; // rax
double v15; // [rsp+30h] [rbp-40h]
double v16; // [rsp+38h] [rbp-38h]

v8 = 0;
glLineWidth(5.0);
do
{
v10 = 0;
v15 = (0.5 - (double)v8 / 50.0) * 2000.0 + a1;
do
{
v11 = (double)v10++ / 50.0;
v16 = (0.5 - v11) * 2000.0 + a2;
glBegin(1LL);
glColor4d(0.0, 0.0, 0.0, 0.0);
glVertex3d(v15, v16, a3);
glColor4d(a6, a7, a8, *(double *)&sky_transparency);
glVertex3d(v15 + a4, v16 + a5, a3);
result = glEnd();
}
while ( v10 != 50 );
++v8;
}
while ( v8 != 50 );
return result;
}

original_code:
void draw_stuff_in_sky(double x,double y,double z,double dx,double dy,double r,double g,double b){
 glLineWidth(5);
 for(int i=0;i<50;i++){
  for(int j=0;j<50;j++){
   double xx=.5-i/50.;
   double yy=.5-j/50.;
   xx*=2000;
   yy*=2000;
   xx+=x;
   yy+=y;
   glBegin(0x0001);
    glColor4d(0,0,0,0);
    glVertex3d(xx,yy,z);
    glColor4d(r,g,b,sky_transparency);
    glVertex3d(xx+dx,yy+dy,z);
   glEnd();
  }
 }
}

canonical_original_code:
void draw_stuff_in_sky(double x, double y, double z, double dx, double dy, double r, double g, double b){
 glLineWidth(5);
 for(int i = 0;i<50;i++){
  for(int j = 0;j<50;j++){
   double xx = .5-i/50.;
   double yy = .5-j/50.;
   xx*=2000;
   yy*=2000;
   xx+=x;
   yy+=y;
   glBegin(0x0001);
    glColor4d(0,0,0,0);
    glVertex3d(xx,yy,z);
    glColor4d(r,g,b,sky_transparency);
    glVertex3d(xx+dx,yy+dy,z);
   glEnd();
  }
 }
}

variable_types: x double

variable_types: y double

variable_types: z double

variable_types: dx double

variable_types: dy double

variable_types: r double

variable_types: g double

variable_types: b double

variable_types: j int

variable_types: xx double

variable_types: yy double


original_code:
void draw_aurore_boreale(Game * game,double * X, double *Y, double * Z,int partie){
 double time_=SDL_GetTicks()*0.001;
 glDisable( 0x0B10 );
 glPointSize(4);
 glBegin(0x0000);
 glColor4d(.5,0,0,1);
 glDepthFunc(0x0207);
 int i_max = 120;
 int j_max = 7;
 double inverse_i_max=1./i_max;
 double inverse_j_max=1./j_max;
 if(partie){
  while(*X-100+game->player->x+game->world_x_size*.5>0)
   *X-=game->world_x_size;
  while(*X-100+game->player->x+game->world_x_size*.5<0)
   *X+=game->world_x_size;
  while(*Y+game->player->y+game->world_y_size*.5>0)
   *Y-=game->world_y_size;
  while(*Y+game->player->y+game->world_y_size*.5<0)
   *Y+=game->world_y_size;
 }else{
  while(*X-200+game->player->x+game->world_x_size*.5>0)
   *X-=game->world_x_size;
  while(*X-200+game->player->x+game->world_x_size*.5<0)
   *X+=game->world_x_size;
  while(*Y+game->player->y+game->world_y_size*.5>0)
   *Y-=game->world_y_size;
  while(*Y+game->player->y+game->world_y_size*.5<0)
   *Y+=game->world_y_size;
 }
 int i_min=-i_max;
 if(partie){
  i_min=0;
 }else{
  i_max=0;
 }
 for(int i=i_min;i<i_max;i++){
  for(int j=-j_max;j<j_max;j++){
   double x=i*inverse_i_max + .1*random(-.5,1);
   double variation = 40*sin(2*x*(1)+.5*time_) + 10*sin(10*x+time_) + 10*sin(24*x-time_) + 3*sin(45*x-5*time_);
   variation=2*variation;
   double y=j*inverse_j_max + .1*random(-.5,1);
   double dist_factor=1-exp(-1-1*y);
   double super_z = exp(2*(-y+1))*(1+random(-.5,1));
   glColor4d(0,dist_factor*(.5+.5*sin(2*3.14159265359*x+2*3.14159265359*exp(-.1-.1*super_z)-time_)),dist_factor*(.5+.5*cos(2*3.14159265359*exp(-.1-.1*super_z)-time_)),.4);
   glVertex3d(
     *X+x*200 + variation * sin(15*x*(1)+time_)+ 20*random(-.5,1),
     *Y + variation + 20*random(-.5,1),
     *Z+64 + 5*super_z + 20*sin(20*x + time_)
    );
  }
 }
 glEnd();
 glDepthFunc(0x0201);
}

canonical_original_code:
void draw_aurore_boreale(struct Game *game, double *X, double *Y, double *Z, int partie){
 double time_ = SDL_GetTicks()*0.001;
 glDisable( 0x0B10 );
 glPointSize(4);
 glBegin(0x0000);
 glColor4d(.5,0,0,1);
 glDepthFunc(0x0207);
 int i_max = 120;
 int j_max = 7;
 double inverse_i_max = 1./i_max;
 double inverse_j_max = 1./j_max;
 if(partie){
  while(*X-100+game->player->x+game->world_x_size*.5>0)
   *X-=game->world_x_size;
  while(*X-100+game->player->x+game->world_x_size*.5<0)
   *X+=game->world_x_size;
  while(*Y+game->player->y+game->world_y_size*.5>0)
   *Y-=game->world_y_size;
  while(*Y+game->player->y+game->world_y_size*.5<0)
   *Y+=game->world_y_size;
 }else{
  while(*X-200+game->player->x+game->world_x_size*.5>0)
   *X-=game->world_x_size;
  while(*X-200+game->player->x+game->world_x_size*.5<0)
   *X+=game->world_x_size;
  while(*Y+game->player->y+game->world_y_size*.5>0)
   *Y-=game->world_y_size;
  while(*Y+game->player->y+game->world_y_size*.5<0)
   *Y+=game->world_y_size;
 }
 int i_min = -i_max;
 if(partie){
  i_min=0;
 }else{
  i_max=0;
 }
 for(int i = i_min;i<i_max;i++){
  for(int j = -j_max;j<j_max;j++){
   double x = i*inverse_i_max + .1*random(-.5,1);
   double variation = 40*sin(2*x*(1)+.5*time_) + 10*sin(10*x+time_) + 10*sin(24*x-time_) + 3*sin(45*x-5*time_);
   variation=2*variation;
   double y = j*inverse_j_max + .1*random(-.5,1);
   double dist_factor = 1-exp(-1-1*y);
   double super_z = exp(2*(-y+1))*(1+random(-.5,1));
   glColor4d(0,dist_factor*(.5+.5*sin(2*3.14159265359*x+2*3.14159265359*exp(-.1-.1*super_z)-time_)),dist_factor*(.5+.5*cos(2*3.14159265359*exp(-.1-.1*super_z)-time_)),.4);
   glVertex3d(
     *X+x*200 + variation * sin(15*x*(1)+time_)+ 20*random(-.5,1),
     *Y + variation + 20*random(-.5,1),
     *Z+64 + 5*super_z + 20*sin(20*x + time_)
    );
  }
 }
 glEnd();
 glDepthFunc(0x0201);
}

variable_types:
X
double *

variable_types:
Y
double *

variable_types:
Z
double *

variable_types: partie int

variable_types: variation double

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


original_code:
void ingame_level2_render(Game* game){
 double music_time=audioplayer_getTime(game->audio);
  if( 07.45<music_time && music_time<07.70){
   change_bg_color(.5,.2,.2);
  }else if(22.70<music_time && music_time<22.95){
   change_bg_color(.5,.2,.2);
  }else if(29.70<music_time && music_time<29.80){
   change_bg_color(1,1,1);
  }else if(29.80<music_time && music_time<30.05){
   change_bg_color(1,0,0);
  }else if(30.05<music_time && music_time<30.30){
   change_bg_color(0,0,0);
  }else if(30.30<music_time && music_time<30.50){
   change_bg_color(1,0,0);
  }else if(44.35<music_time && music_time<45.45){
   double x=(music_time-44.35)/(45.45-44.35);
   change_bg_color(x*.5,0,0);
  }else if(45.45<music_time && music_time<45.75){
   change_bg_color(1,0,0);
  }else{
   change_bg_color(0,0,0);
  }
  if(45.75<music_time){
   game->weapon=2;
  }
 if(music_time<45.75){
  draw_aurore_boreale(game,&X1,&Y1,&Z1,1);
  draw_aurore_boreale(game,&X1,&Y1,&Z1,0);
  draw_aurore_boreale(game,&X2,&Y2,&Z2,1);
  draw_aurore_boreale(game,&X2,&Y2,&Z2,0);
 }else{
  change_bg_color(0,0,0);
  game->weapon=2;
  ingame_level3_setup(game);
 }
 if(music_time+.1>sky_change_counter*(15.325)/64.){
  sky_change_counter++;
  double angle=random(0.,3.14159265359/4.);
  if(angle<0) angle-=3.14159265359/8.;
  else angle+=3.14159265359/8.;
  double newx=cos(angle)*sky_1_dx-sin(angle)*sky_1_dy;
  double newy=sin(angle)*sky_1_dx+cos(angle)*sky_1_dy;
  sky_1_dx=newx;
  sky_1_dy=newy;
  angle=random(0,3.14159265359/4.);
  if(angle<0) angle-=3.14159265359/8.;
  else angle+=3.14159265359/8.;
  newx=cos(angle)*sky_2_dx-sin(angle)*sky_2_dy;
  newy=sin(angle)*sky_2_dx+cos(angle)*sky_2_dy;
  sky_2_dx=newx;
  sky_2_dy=newy;
  angle=random(0,3.14159265359/4.);
  if(angle<0) angle-=3.14159265359/8.;
  else angle+=3.14159265359/8.;
  newx=cos(angle)*sky_3_dx-sin(angle)*sky_3_dy;
  newy=sin(angle)*sky_3_dx+cos(angle)*sky_3_dy;
  sky_3_dx=newx;
  sky_3_dy=newy;
 }
 if(15.50<music_time && music_time<29.65){
  draw_stuff_in_sky(sky_1_x,sky_1_y,sky_1_z,sky_1_dx,sky_1_dy,0,.3,0);
  draw_stuff_in_sky(sky_2_x,sky_2_y,sky_2_z,sky_2_dx,sky_2_dy,0,.3,0);
  draw_stuff_in_sky(sky_3_x,sky_3_y,sky_3_z,sky_3_dx,sky_3_dy,0,1.,0);
  draw_stuff_in_sky(sky_1_x,sky_1_y,-sky_1_z,sky_1_dx,sky_1_dy,0,.3,0);
  draw_stuff_in_sky(sky_2_x,sky_2_y,-sky_2_z,sky_2_dx,sky_2_dy,0,.3,0);
  draw_stuff_in_sky(sky_3_x,sky_3_y,-sky_3_z,sky_3_dx,sky_3_dy,0,1.,0);
  if(music_time<19.10){
   sky_transparency=(music_time-15.5)/(19.1-15.50);
  }else if(music_time<23.3){
   sky_transparency=1 - (music_time-19.1)/(23.3-19.1);
  }else if(music_time<26.7){
   sky_transparency=(music_time-23.3)/(26.7-23.3);
  }else{
   sky_transparency=1 - (music_time-26.7)/(29.65-26.7);
  }
 }
 if(30.50<music_time && music_time<44.65){
  draw_stuff_in_sky(sky_1_x,sky_1_y,sky_1_z,sky_1_dx,sky_1_dy,0,1,0);
  draw_stuff_in_sky(sky_2_x,sky_2_y,sky_2_z,sky_2_dx,sky_2_dy,0,1,0);
  draw_stuff_in_sky(sky_3_x,sky_3_y,sky_3_z,sky_3_dx,sky_3_dy,0,1,0);
  draw_stuff_in_sky(sky_1_x,sky_1_y,-sky_1_z,sky_1_dx,sky_1_dy,0,1,0);
  draw_stuff_in_sky(sky_2_x,sky_2_y,-sky_2_z,sky_2_dx,sky_2_dy,0,1,0);
  draw_stuff_in_sky(sky_3_x,sky_3_y,-sky_3_z,sky_3_dx,sky_3_dy,0,1,0);
  if(music_time<34.10){
   sky_transparency=(music_time-30.5)/(34.1-30.50);
  }else if(music_time<38.3){
   sky_transparency=1 - (music_time-34.1)/(38.3-34.1);
  }else if(music_time<41.7){
   sky_transparency=(music_time-38.3)/(41.7-38.3);
  }else{
   sky_transparency=1 - (music_time-41.7)/(44.65-41.7);
  }
 }
}

canonical_original_code:
void ingame_level2_render(struct Game *game){
 double music_time = audioplayer_getTime(game->audio);
  if( 07.45<music_time && music_time<07.70){
   change_bg_color(.5,.2,.2);
  }else if(22.70<music_time && music_time<22.95){
   change_bg_color(.5,.2,.2);
  }else if(29.70<music_time && music_time<29.80){
   change_bg_color(1,1,1);
  }else if(29.80<music_time && music_time<30.05){
   change_bg_color(1,0,0);
  }else if(30.05<music_time && music_time<30.30){
   change_bg_color(0,0,0);
  }else if(30.30<music_time && music_time<30.50){
   change_bg_color(1,0,0);
  }else if(44.35<music_time && music_time<45.45){
   double x = (music_time-44.35)/(45.45-44.35);
   change_bg_color(x*.5,0,0);
  }else if(45.45<music_time && music_time<45.75){
   change_bg_color(1,0,0);
  }else{
   change_bg_color(0,0,0);
  }
  if(45.75<music_time){
   game->weapon=2;
  }
 if(music_time<45.75){
  draw_aurore_boreale(game,&X1,&Y1,&Z1,1);
  draw_aurore_boreale(game,&X1,&Y1,&Z1,0);
  draw_aurore_boreale(game,&X2,&Y2,&Z2,1);
  draw_aurore_boreale(game,&X2,&Y2,&Z2,0);
 }else{
  change_bg_color(0,0,0);
  game->weapon=2;
  ingame_level3_setup(game);
 }
 if(music_time+.1>sky_change_counter*(15.325)/64.){
  sky_change_counter++;
  double angle = random(0.,3.14159265359/4.);
  if(angle<0) angle-=3.14159265359/8.;
  else angle+=3.14159265359/8.;
  double newx = cos(angle)*sky_1_dx-sin(angle)*sky_1_dy;
  double newy = sin(angle)*sky_1_dx+cos(angle)*sky_1_dy;
  sky_1_dx=newx;
  sky_1_dy=newy;
  angle=random(0,3.14159265359/4.);
  if(angle<0) angle-=3.14159265359/8.;
  else angle+=3.14159265359/8.;
  newx=cos(angle)*sky_2_dx-sin(angle)*sky_2_dy;
  newy=sin(angle)*sky_2_dx+cos(angle)*sky_2_dy;
  sky_2_dx=newx;
  sky_2_dy=newy;
  angle=random(0,3.14159265359/4.);
  if(angle<0) angle-=3.14159265359/8.;
  else angle+=3.14159265359/8.;
  newx=cos(angle)*sky_3_dx-sin(angle)*sky_3_dy;
  newy=sin(angle)*sky_3_dx+cos(angle)*sky_3_dy;
  sky_3_dx=newx;
  sky_3_dy=newy;
 }
 if(15.50<music_time && music_time<29.65){
  draw_stuff_in_sky(sky_1_x,sky_1_y,sky_1_z,sky_1_dx,sky_1_dy,0,.3,0);
  draw_stuff_in_sky(sky_2_x,sky_2_y,sky_2_z,sky_2_dx,sky_2_dy,0,.3,0);
  draw_stuff_in_sky(sky_3_x,sky_3_y,sky_3_z,sky_3_dx,sky_3_dy,0,1.,0);
  draw_stuff_in_sky(sky_1_x,sky_1_y,-sky_1_z,sky_1_dx,sky_1_dy,0,.3,0);
  draw_stuff_in_sky(sky_2_x,sky_2_y,-sky_2_z,sky_2_dx,sky_2_dy,0,.3,0);
  draw_stuff_in_sky(sky_3_x,sky_3_y,-sky_3_z,sky_3_dx,sky_3_dy,0,1.,0);
  if(music_time<19.10){
   sky_transparency=(music_time-15.5)/(19.1-15.50);
  }else if(music_time<23.3){
   sky_transparency=1 - (music_time-19.1)/(23.3-19.1);
  }else if(music_time<26.7){
   sky_transparency=(music_time-23.3)/(26.7-23.3);
  }else{
   sky_transparency=1 - (music_time-26.7)/(29.65-26.7);
  }
 }
 if(30.50<music_time && music_time<44.65){
  draw_stuff_in_sky(sky_1_x,sky_1_y,sky_1_z,sky_1_dx,sky_1_dy,0,1,0);
  draw_stuff_in_sky(sky_2_x,sky_2_y,sky_2_z,sky_2_dx,sky_2_dy,0,1,0);
  draw_stuff_in_sky(sky_3_x,sky_3_y,sky_3_z,sky_3_dx,sky_3_dy,0,1,0);
  draw_stuff_in_sky(sky_1_x,sky_1_y,-sky_1_z,sky_1_dx,sky_1_dy,0,1,0);
  draw_stuff_in_sky(sky_2_x,sky_2_y,-sky_2_z,sky_2_dx,sky_2_dy,0,1,0);
  draw_stuff_in_sky(sky_3_x,sky_3_y,-sky_3_z,sky_3_dx,sky_3_dy,0,1,0);
  if(music_time<34.10){
   sky_transparency=(music_time-30.5)/(34.1-30.50);
  }else if(music_time<38.3){
   sky_transparency=1 - (music_time-34.1)/(38.3-34.1);
  }else if(music_time<41.7){
   sky_transparency=(music_time-38.3)/(41.7-38.3);
  }else{
   sky_transparency=1 - (music_time-41.7)/(44.65-41.7);
  }
 }
}

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: angle double

variable_types: newx double

variable_types: newy double


decompiled_code:
char __fastcall ingame_level3_update(__int64 a1)
{
bool v1; // cf
bool v2; // zf
__int64 v3; // rcx
__int64 v4; // r8
const char *v5; // rax
const char *v7; // rsi
const char *v8; // rdi
char v9; // dl
bool v10; // cf
bool v11; // zf
const char *v12; // rsi
const char *v13; // rdi
__int64 v14; // rcx
char result; // al
int v16; // eax

v3 = 30LL;
v4 = *(_QWORD *)(a1 + 112);
v5 = *(const char **)(v4 + 16);
v7 = v5;
v8 = "music/Goto80_gopho_level3.ogg";
do
{
if ( !v3 )
break;
v1 = *v7 < (unsigned int)*v8;
v2 = *v7++ == *v8++;
--v3;
}
while ( v2 );
v9 = (!v1 && !v2) - v1;
v10 = 0;
v11 = v9 == 0;
if ( !v9 )
{
if ( !music_started )
{
*(_QWORD *)(a1 + 176) = mechant_regeneration_type_level3_0;
v16 = SDL_GetTicks(v8, v7);
v4 = *(_QWORD *)(a1 + 112);
music_started = 1;
*(double *)&time_offset = (double)v16 * 0.001 - 0.72;
}
audioplayer_set_next(v4, "music/Goto80_gopho_level4.ogg");
v5 = *(const char **)(*(_QWORD *)(a1 + 112) + 16LL);
}
v12 = v5;
v13 = "music/Goto80_gopho_level4.ogg";
v14 = 30LL;
do
{
if ( !v14 )
break;
v10 = *v12 < (unsigned int)*v13;
v11 = *v12++ == *v13++;
--v14;
}
while ( v11 );
result = (!v10 && !v11) - v10;
if ( !result )
result = ingame_level4_setup(a1, v12);
return result;
}

canonical_decompiled_code:
char __fastcall func0(__int64 a1)
{
bool v1; // cf
bool v2; // zf
__int64 v3; // rcx
__int64 v4; // r8
const char *v5; // rax
const char *v7; // rsi
const char *v8; // rdi
char v9; // dl
bool v10; // cf
bool v11; // zf
const char *v12; // rsi
const char *v13; // rdi
__int64 v14; // rcx
char result; // al
int v16; // eax

v3 = 30LL;
v4 = *(_QWORD *)(a1 + 112);
v5 = *(const char **)(v4 + 16);
v7 = v5;
v8 = "music/Goto80_gopho_level3.ogg";
do
{
if ( !v3 )
break;
v1 = *v7 < (unsigned int)*v8;
v2 = *v7++ == *v8++;
--v3;
}
while ( v2 );
v9 = (!v1 && !v2) - v1;
v10 = 0;
v11 = v9 == 0;
if ( !v9 )
{
if ( !music_started )
{
*(_QWORD *)(a1 + 176) = mechant_regeneration_type_level3_0;
v16 = SDL_GetTicks(v8, v7);
v4 = *(_QWORD *)(a1 + 112);
music_started = 1;
*(double *)&time_offset = (double)v16 * 0.001 - 0.72;
}
audioplayer_set_next(v4, "music/Goto80_gopho_level4.ogg");
v5 = *(const char **)(*(_QWORD *)(a1 + 112) + 16LL);
}
v12 = v5;
v13 = "music/Goto80_gopho_level4.ogg";
v14 = 30LL;
do
{
if ( !v14 )
break;
v10 = *v12 < (unsigned int)*v13;
v11 = *v12++ == *v13++;
--v14;
}
while ( v11 );
result = (!v10 && !v11) - v10;
if ( !result )
result = ingame_level4_setup(a1, v12);
return result;
}

original_code:
void ingame_level3_update(Game* game,int dt){
 if(!strcmp(game->audio->now_playing,"music/Goto80_gopho_level3.ogg")){
  if(!music_started){
   int mechant_regeneration_type_level3(){
    return rand()%2;
   }
   game->mechant_regeneration_type=mechant_regeneration_type_level3;
   time_offset=SDL_GetTicks()*0.001-.960*3./4.;
   music_started=1;
  }
  audioplayer_set_next(game->audio,"music/Goto80_gopho_level4.ogg");
 }
 if(!strcmp(game->audio->now_playing,"music/Goto80_gopho_level4.ogg")){
  ingame_level4_setup(game);
 }
}

canonical_original_code:
void ingame_level3_update(struct Game *game, int dt){
 if(!strcmp(game->audio->now_playing,"music/Goto80_gopho_level3.ogg")){
  if(!music_started){
   int mechant_regeneration_type_level3(){
    return rand()%2;
   }
   game->mechant_regeneration_type=mechant_regeneration_type_level3;
   time_offset=SDL_GetTicks()*0.001-.960*3./4.;
   music_started=1;
  }
  audioplayer_set_next(game->audio,"music/Goto80_gopho_level4.ogg");
 }
 if(!strcmp(game->audio->now_playing,"music/Goto80_gopho_level4.ogg")){
  ingame_level4_setup(game);
 }
}

variable_types: dt int

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 ogg_sync_state { unsigned char *data; int storage; int fill; int returned; int unsynced; int headerbytes; int bodybytes; }


decompiled_code:
double *__fastcall ingame_level3_render(__int64 a1, double *a2)
{
int v3; // eax
double v4; // xmm0_8
__int64 v5; // rdi
__int64 v6; // rdx
double v8; // [rsp+0h] [rbp-20h]
double v9; // [rsp+8h] [rbp-18h]

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

canonical_decompiled_code:
double *__fastcall func3(__int64 a1, double *a2)
{
int v3; // eax
double v4; // xmm0_8
__int64 v5; // rdi
__int64 v6; // rdx
double v8; // [rsp+0h] [rbp-20h]
double v9; // [rsp+8h] [rbp-18h]

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

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

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


decompiled_code:
__int64 __fastcall ingame_level3_setup(_QWORD *a1)
{
__int64 v2[3]; // [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[1] = 0x3F80000000000000LL;
v2[0] = 0LL;
glFogfv(2918LL, v2);
glFogf(2914LL, COERCE_DOUBLE((unsigned __int64)LC32));
return glHint(3156LL, 4352LL);
}

canonical_decompiled_code:
__int64 __fastcall func4(_QWORD *a1)
{
__int64 v2[3]; // [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[1] = 0x3F80000000000000LL;
v2[0] = 0LL;
glFogfv(2918LL, v2);
glFogf(2914LL, COERCE_DOUBLE((unsigned __int64)LC32));
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:
fogColor
float [4]

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 oggpack_buffer { long endbyte; int endbit; unsigned char *buffer; unsigned char *ptr; long storage; }


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: xxx double

variable_types: alpha double

variable_types: dist double

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 alloc_chain { void *ptr; struct alloc_chain *next; }


decompiled_code:
_QWORD **new_audioplayer()
{
_QWORD **v0; // r12
__int64 v1; // rax
_QWORD *v3; // rsi

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[2] = "music/silence.ogg";
*v0 = (_QWORD *)v1;
if ( !v1 )
{
v3 = v0[1];
v0 = 0LL;
printf(format, v3);
return v0;
}
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));
return v0;
}
puts("FILE EMPTY, COULD NOT PLAY");
sound_closeSample(*v0);
return 0LL;
}

canonical_decompiled_code:
_QWORD **func2()
{
_QWORD **v0; // r12
__int64 v1; // rax
_QWORD *v3; // rsi

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[2] = "music/silence.ogg";
*v0 = (_QWORD *)v1;
if ( !v1 )
{
v3 = v0[1];
v0 = 0LL;
printf(format, v3);
return v0;
}
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));
return v0;
}
puts("FILE EMPTY, COULD NOT PLAY");
sound_closeSample(*v0);
return 0LL;
}

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 vorbis_comment { char **user_comments; int *comment_lengths; int comments; char *vendor; }


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


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 *


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


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


decompiled_code:
int __fastcall audioplayer_update(__int64 *a1)
{
__int64 v2; // rax
__int64 v3; // rdi
__int64 v4; // rax
_QWORD *v5; // rdi
int v6; // xmm0_4
int result; // eax
int v8; // ecx
__int64 v9; // rax
__int64 v10; // rdi

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

canonical_decompiled_code:
int __fastcall func8(__int64 *a1)
{
__int64 v2; // rax
__int64 v3; // rdi
__int64 v4; // rax
_QWORD *v5; // rdi
int v6; // xmm0_4
int result; // eax
int v8; // ecx
__int64 v9; // rax
__int64 v10; // rdi

alGetSourcei(*((unsigned int *)a1 + 8), 4118LL, &no_buf);
while ( 1 )
{
result = no_buf--;
if ( !result )
break;
alSourceUnqueueBuffers(*((unsigned int *)a1 + 8), 1LL, &buf);
v8 = music_changed;
*((double *)a1 + 3) = *(float *)&buf_time + *((double *)a1 + 3);
buf_time = buf_time_next;
if ( v8 )
{
v9 = next_file_path;
a1[3] = 0LL;
music_changed = 0;
a1[2] = v9;
}
if ( music_looped )
{
music_looped = 0;
a1[3] = 0LL;
}
v10 = *a1;
if ( cache )
{
alBufferData(
(unsigned int)buf,
*(unsigned int *)(v10 + 32),
*(_QWORD *)v10,
*(unsigned int *)(v10 + 24),
*(unsigned int *)(v10 + 28));
alSourceQueueBuffers(*((unsigned int *)a1 + 8), 1LL, &buf);
}
else
{
if ( a1[1] )
{
sound_closeSample(v10);
v2 = sound_loadSample(a1[1]);
*a1 = v2;
v3 = v2;
v4 = a1[1];
music_changed = 1;
next_file_path = v4;
a1[1] = 0LL;
}
else
{
if ( !v10 )
return puts("ERROR : SOUND CRASHED");
music_looped = 1;
sound_seekSample(v10);
v3 = *a1;
}
sound_nextSample(v3);
alBufferData(
(unsigned int)buf,
*(unsigned int *)(*a1 + 32),
*(_QWORD *)*a1,
*(unsigned int *)(*a1 + 24),
*(unsigned int *)(*a1 + 28));
alSourceQueueBuffers(*((unsigned int *)a1 + 8), 1LL, &buf);
alSourcePlay(*((unsigned int *)a1 + 8));
}
v5 = (_QWORD *)*a1;
*(float *)&v6 = (double)*(int *)(*a1 + 24) / (double)*(int *)(*a1 + 28) * 0.25;
buf_time_next = v6;
cache = sound_nextSample(v5);
}
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);
   }
}


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; // xmm1_8
double v3; // xmm1_8
double v4; // xmm1_8
int v5; // er13
int v6; // eax
int v7; // eax
int v8; // eax
double v9; // xmm0_8
__int64 v10; // rax
double v11; // [rsp+8h] [rbp-28h]
double v12; // [rsp+8h] [rbp-28h]

v2 = *(double *)(*a1 + 136) * *(double *)(*a1 + 136)
+ *(double *)(*a1 + 120) * *(double *)(*a1 + 120)
+ *(double *)(*a1 + 128) * *(double *)(*a1 + 128);
fake_walking = *(_QWORD *)&v2;
if ( v2 < 0.0 )
v3 = sqrt(v2);
else
v3 = sqrt(v2);
v4 = v3 * 0.007;
fake_walking = *(_QWORD *)&v4;
if ( a2 > 0 )
{
v5 = 0;
while ( 1 )
{
++v5;
v6 = SDL_GetTicks();
v11 = (v4 + v4) * cos((double)v6 * 0.008);
v7 = SDL_GetTicks();
v12 = cos((double)v7 * 0.008) * v11;
v8 = SDL_GetTicks();
v9 = cos((double)v8 * 0.008);
v10 = *a1;
*(double *)&fake_drho = -0.013 * (*(double *)&fake_drho + v9 * v12) + *(double *)&fake_drho + v9 * v12;
*(double *)&fake_theta = -0.01 * *(double *)&fake_theta + *(double *)&fake_theta;
*(double *)&fake_rho = 0.001 * *(double *)&fake_drho - 0.03 * *(double *)&fake_rho + *(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 *)(v10 + 48) * 0.3 + 0.98 * *(double *)&HUD_drho_compensation;
if ( a2 == v5 )
break;
v4 = *(double *)&fake_walking;
}
}
}

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

v2 = *(double *)(*a1 + 136) * *(double *)(*a1 + 136)
+ *(double *)(*a1 + 120) * *(double *)(*a1 + 120)
+ *(double *)(*a1 + 128) * *(double *)(*a1 + 128);
fake_walking = *(_QWORD *)&v2;
if ( v2 < 0.0 )
v3 = sqrt(v2);
else
v3 = sqrt(v2);
v4 = v3 * 0.007;
fake_walking = *(_QWORD *)&v4;
if ( a2 > 0 )
{
v5 = 0;
while ( 1 )
{
++v5;
v6 = SDL_GetTicks();
v11 = (v4 + v4) * cos((double)v6 * 0.008);
v7 = SDL_GetTicks();
v12 = cos((double)v7 * 0.008) * v11;
v8 = SDL_GetTicks();
v9 = cos((double)v8 * 0.008);
v10 = *a1;
*(double *)&fake_drho = -0.013 * (*(double *)&fake_drho + v9 * v12) + *(double *)&fake_drho + v9 * v12;
*(double *)&fake_theta = -0.01 * *(double *)&fake_theta + *(double *)&fake_theta;
*(double *)&fake_rho = 0.001 * *(double *)&fake_drho - 0.03 * *(double *)&fake_rho + *(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 *)(v10 + 48) * 0.3 + 0.98 * *(double *)&HUD_drho_compensation;
if ( a2 == v5 )
break;
v4 = *(double *)&fake_walking;
}
}
}

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

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


viseur

decompiled_code:
__int64 __fastcall viseur(__int64 a1)
{
__int64 v1; // xmm4_8
__int64 v2; // xmm0_8
double v4; // [rsp+8h] [rbp-18h]

if ( (SDL_GetMouseState(0LL, 0LL) & 1) != 0
|| (SDL_GetMouseState(0LL, 0LL) & 4) != 0
|| *(_BYTE *)(SDL_GetKeyState(0LL) + 308)
|| *(_BYTE *)(SDL_GetKeyState(0LL) + 306) )
{
v1 = LC12;
v2 = LC12;
}
else
{
v1 = LC12;
v2 = 0LL;
}
v4 = *(double *)&v1;
precision = v2;
glPushMatrix();
glColor4d(v4, 0.0, 0.0, v4);
glPointSize(2.0);
glRotated(-2.0 * *(double *)(*(_QWORD *)a1 + 24LL), v4, 0.0);
glRotated((0.5 - 0.8 * *(double *)&precision) * *(double *)(*(_QWORD *)a1 + 8LL), 0.0, v4);
glPointSize(6.0);
glBegin(0LL);
glVertex3d(0.05, 0.003, 0.0);
glVertex3d(0.05, -0.003, 0.0);
glVertex3d(0.05, 0.0, 0.0);
glVertex3d(0.05, 0.0, 0.003);
glVertex3d(0.05, 0.0, -0.003);
glEnd();
return glPopMatrix();
}

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