original_code:
void eof_MIDI_add_track(EOF_SONG *sp, struct eof_MIDI_data_track *ptr)
{
 if(!sp || !ptr)
  return;
 if(sp->midi_data_head == ((void *)0))
 {
  sp->midi_data_head = ptr;
 }
 else if(sp->midi_data_tail != ((void *)0))
 {
  sp->midi_data_tail->next = ptr;
 }
 sp->midi_data_tail = ptr;
}

canonical_original_code:
void eof_MIDI_add_track(struct EOF_SONG *sp, struct eof_MIDI_data_track *ptr)
{
 if(!sp || !ptr)
  return;
 if(sp->midi_data_head == ((void *)0))
 {
  sp->midi_data_head = ptr;
 }
 else if(sp->midi_data_tail != ((void *)0))
 {
  sp->midi_data_tail->next = ptr;
 }
 sp->midi_data_tail = ptr;
}

variable_types: struct EOF_SONG { struct EOF_SONG_TAGS { char artist[256]; char title[256]; char frettist[256]; char album[256]; char year[32]; char loading_text[512]; char lyrics; char eighth_note_hopo; char eof_fret_hand_pos_1_pg; char eof_fret_hand_pos_1_pb; char tempo_map_locked; char double_bass_drum_disabled; char click_drag_disabled; char rs_chord_technique_export; char unshare_drum_phrasing; char highlight_unsnapped_notes; struct EOF_OGG_INFO { char filename[256]; long midi_offset; char modified; char description[-1]; } ogg[8]; short oggs; char ini_setting[64][512]; short ini_settings; unsigned long revision; unsigned long difficulty; } *tags; int resolution; struct EOF_TRACK_ENTRY { char track_format; char track_behavior; char track_type; unsigned long tracknum; char name[-1]; char altname[-1]; unsigned char difficulty; unsigned char numdiffs; unsigned long flags; } *track[-1]; unsigned long tracks; struct EOF_LEGACY_TRACK { unsigned char numlanes; struct EOF_TRACK_ENTRY *parent; struct EOF_NOTE { char name[-1]; unsigned char type; unsigned char note; unsigned long midi_pos; unsigned long midi_length; unsigned long pos; long length; unsigned long flags; unsigned char tflags; } *note[32768]; unsigned long notes; struct EOF_PHRASE_SECTION { unsigned long midi_start_pos; unsigned long midi_end_pos; unsigned long start_pos; unsigned long end_pos; unsigned long flags; char name[-1]; unsigned char difficulty; } solo[1000]; unsigned long solos; struct EOF_PHRASE_SECTION star_power_path[1000]; unsigned long star_power_paths; struct EOF_PHRASE_SECTION trill[1000]; unsigned long trills; struct EOF_PHRASE_SECTION tremolo[1000]; unsigned long tremolos; struct EOF_PHRASE_SECTION slider[1000]; unsigned long sliders; } *legacy_track[8]; unsigned long legacy_tracks; struct EOF_VOCAL_TRACK { unsigned char toneset; struct EOF_TRACK_ENTRY *parent; struct EOF_LYRIC { unsigned char type; unsigned char note; char text[-1]; unsigned long midi_pos; long midi_length; unsigned long pos; long length; unsigned long flags; unsigned char tflags; } *lyric[32768]; unsigned long lyrics; struct EOF_PHRASE_SECTION line[4096]; unsigned long lines; } *vocal_track[1]; unsigned long vocal_tracks; struct EOF_PRO_GUITAR_TRACK { unsigned char numfrets; unsigned char numstrings; unsigned char arrangement; unsigned char ignore_tuning; unsigned char capo; char tuning[6]; struct EOF_TRACK_ENTRY *parent; struct EOF_PRO_GUITAR_NOTE { char name[-1]; unsigned char type; unsigned char note; unsigned char ghost; unsigned char frets[8]; unsigned char finger[8]; unsigned char legacymask; unsigned long midi_pos; long midi_length; unsigned long pos; long length; unsigned long flags; unsigned long eflags; unsigned char bendstrength; unsigned char slideend; unsigned char unpitchend; unsigned char tflags; } **note; unsigned long notes; struct EOF_PRO_GUITAR_NOTE *pgnote[32768]; unsigned long pgnotes; struct EOF_PRO_GUITAR_NOTE *technote[32768]; unsigned long technotes; struct EOF_PHRASE_SECTION solo[1000]; unsigned long solos; struct EOF_PHRASE_SECTION star_power_path[1000]; unsigned long star_power_paths; struct EOF_PHRASE_SECTION arpeggio[1000]; unsigned long arpeggios; struct EOF_PHRASE_SECTION trill[1000]; unsigned long trills; struct EOF_PHRASE_SECTION tremolo[1000]; unsigned long tremolos; struct EOF_PHRASE_SECTION handposition[32768]; unsigned long handpositions; struct EOF_PHRASE_SECTION popupmessage[1000]; unsigned long popupmessages; struct EOF_PHRASE_SECTION tonechange[1000]; unsigned long tonechanges; char defaulttone[-1]; } *pro_guitar_track[4]; unsigned long pro_guitar_tracks; struct EOF_BEAT_MARKER { unsigned long ppqn; unsigned long midi_pos; unsigned long pos; unsigned long flags; char key; double fpos; unsigned long measurenum; int beat_within_measure; char contains_tempo_change; } *beat[32768]; unsigned long beats; struct EOF_TEXT_EVENT { char text[256]; unsigned long beat; unsigned long track; char is_temporary; unsigned char flags; unsigned long index; } *text_event[4096]; unsigned long text_events; struct eof_MIDI_data_track { char *trackname; char *description; struct eof_MIDI_data_event { double realtime; char *stringtime; unsigned long deltatime; unsigned int size; void *data; struct eof_MIDI_data_event *next; } *events; struct eof_MIDI_data_track *next; unsigned long timedivision; } *midi_data_head; unsigned long bookmark_pos[10]; struct EOF_CATALOG { struct EOF_CATALOG_ENTRY { unsigned long track; unsigned char type; unsigned long start_pos; unsigned long end_pos; char name[-1]; } entry[256]; unsigned long entries; } *catalog; char fpbeattimes; } *

variable_types:
ptr
struct eof_MIDI_data_track *

user_defined_types: struct EOF_SONG { struct EOF_SONG_TAGS *tags; int resolution; struct EOF_TRACK_ENTRY *track[-1]; unsigned long tracks; struct EOF_LEGACY_TRACK *legacy_track[8]; unsigned long legacy_tracks; struct EOF_VOCAL_TRACK *vocal_track[1]; unsigned long vocal_tracks; struct EOF_PRO_GUITAR_TRACK *pro_guitar_track[4]; unsigned long pro_guitar_tracks; struct EOF_BEAT_MARKER *beat[32768]; unsigned long beats; struct EOF_TEXT_EVENT *text_event[4096]; unsigned long text_events; struct eof_MIDI_data_track *midi_data_head; unsigned long bookmark_pos[10]; struct EOF_CATALOG *catalog; char fpbeattimes; }

user_defined_types: struct EOF_SONG_TAGS { char artist[256]; char title[256]; char frettist[256]; char album[256]; char year[32]; char loading_text[512]; char lyrics; char eighth_note_hopo; char eof_fret_hand_pos_1_pg; char eof_fret_hand_pos_1_pb; char tempo_map_locked; char double_bass_drum_disabled; char click_drag_disabled; char rs_chord_technique_export; char unshare_drum_phrasing; char highlight_unsnapped_notes; struct EOF_OGG_INFO ogg[8]; short oggs; char ini_setting[64][512]; short ini_settings; unsigned long revision; unsigned long difficulty; }

user_defined_types: struct EOF_CATALOG { struct EOF_CATALOG_ENTRY entry[256]; unsigned long entries; }

user_defined_types: struct EOF_LEGACY_TRACK { unsigned char numlanes; struct EOF_TRACK_ENTRY *parent; struct EOF_NOTE *note[32768]; unsigned long notes; struct EOF_PHRASE_SECTION solo[1000]; unsigned long solos; struct EOF_PHRASE_SECTION star_power_path[1000]; unsigned long star_power_paths; struct EOF_PHRASE_SECTION trill[1000]; unsigned long trills; struct EOF_PHRASE_SECTION tremolo[1000]; unsigned long tremolos; struct EOF_PHRASE_SECTION slider[1000]; unsigned long sliders; }

user_defined_types: struct EOF_VOCAL_TRACK { unsigned char toneset; struct EOF_TRACK_ENTRY *parent; struct EOF_LYRIC *lyric[32768]; unsigned long lyrics; struct EOF_PHRASE_SECTION line[4096]; unsigned long lines; }


repo: cincodenada/editor-on-fire

decompiled_code:
__int64 __fastcall eof_track_overridden_by_stored_MIDI_track(__int64 a1, unsigned __int64 a2)
{
__int64 result; // rax
_QWORD *v3; // rbx

if ( !a1 )
return 0LL;
result = 0LL;
if ( *(_QWORD *)(a1 + 128) > a2 )
{
v3 = *(_QWORD **)(a1 + 295192);
if ( v3 )
{
do
{
if ( *v3 && !(unsigned int)ustricmp(*v3, *(_QWORD *)(a1 + 8 * (a2 + 2)) + 16LL) )
return 1LL;
v3 = (_QWORD *)v3[3];
}
while ( v3 );
result = 0LL;
}
else
{
result = 0LL;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1, unsigned __int64 a2)
{
__int64 result; // rax
_QWORD *v3; // rbx

if ( !a1 )
return 0LL;
result = 0LL;
if ( *(_QWORD *)(a1 + 128) > a2 )
{
v3 = *(_QWORD **)(a1 + 295192);
if ( v3 )
{
do
{
if ( *v3 && !(unsigned int)ustricmp(*v3, *(_QWORD *)(a1 + 8 * (a2 + 2)) + 16LL) )
return 1LL;
v3 = (_QWORD *)v3[3];
}
while ( v3 );
result = 0LL;
}
else
{
result = 0LL;
}
}
return result;
}

original_code:
int eof_track_overridden_by_stored_MIDI_track(EOF_SONG *sp, unsigned long tracknum)
{
 struct eof_MIDI_data_track *trackptr;
 if(!sp || (tracknum >= sp->tracks))
  return 0;
 for(trackptr = sp->midi_data_head; trackptr != ((void *)0); trackptr = trackptr->next)
 {
  if(trackptr->trackname && !ustricmp(trackptr->trackname, sp->track[tracknum]->name))
  {
   return 1;
  }
 }
 return 0;
}

canonical_original_code:
int eof_track_overridden_by_stored_MIDI_track(struct EOF_SONG *sp, unsigned long tracknum)
{
 struct eof_MIDI_data_track *trackptr;
 if(!sp || (tracknum >= sp->tracks))
  return 0;
 for(trackptr = sp->midi_data_head; trackptr != ((void *)0); trackptr = trackptr->next)
 {
  if(trackptr->trackname && !ustricmp(trackptr->trackname, sp->track[tracknum]->name))
  {
   return 1;
  }
 }
 return 0;
}

variable_types:
tracknum
unsigned long

variable_types: struct eof_MIDI_data_track { char *trackname; char *description; struct eof_MIDI_data_event { double realtime; char *stringtime; unsigned long deltatime; unsigned int size; void *data; struct eof_MIDI_data_event *next; } *events; struct eof_MIDI_data_track *next; unsigned long timedivision; } *

return_type: int

user_defined_types: struct eof_MIDI_data_track { char *trackname; char *description; struct eof_MIDI_data_event *events; struct eof_MIDI_data_track *next; unsigned long timedivision; }

user_defined_types: struct EOF_TRACK_ENTRY { char track_format; char track_behavior; char track_type; unsigned long tracknum; char name[-1]; char altname[-1]; unsigned char difficulty; unsigned char numdiffs; unsigned long flags; }

user_defined_types: struct EOF_PRO_GUITAR_TRACK { unsigned char numfrets; unsigned char numstrings; unsigned char arrangement; unsigned char ignore_tuning; unsigned char capo; char tuning[6]; struct EOF_TRACK_ENTRY *parent; struct EOF_PRO_GUITAR_NOTE **note; unsigned long notes; struct EOF_PRO_GUITAR_NOTE *pgnote[32768]; unsigned long pgnotes; struct EOF_PRO_GUITAR_NOTE *technote[32768]; unsigned long technotes; struct EOF_PHRASE_SECTION solo[1000]; unsigned long solos; struct EOF_PHRASE_SECTION star_power_path[1000]; unsigned long star_power_paths; struct EOF_PHRASE_SECTION arpeggio[1000]; unsigned long arpeggios; struct EOF_PHRASE_SECTION trill[1000]; unsigned long trills; struct EOF_PHRASE_SECTION tremolo[1000]; unsigned long tremolos; struct EOF_PHRASE_SECTION handposition[32768]; unsigned long handpositions; struct EOF_PHRASE_SECTION popupmessage[1000]; unsigned long popupmessages; struct EOF_PHRASE_SECTION tonechange[1000]; unsigned long tonechanges; char defaulttone[-1]; }

user_defined_types: struct EOF_BEAT_MARKER { unsigned long ppqn; unsigned long midi_pos; unsigned long pos; unsigned long flags; char key; double fpos; unsigned long measurenum; int beat_within_measure; char contains_tempo_change; }

user_defined_types: struct EOF_TEXT_EVENT { char text[256]; unsigned long beat; unsigned long track; char is_temporary; unsigned char flags; unsigned long index; }

user_defined_types: struct EOF_OGG_INFO { char filename[256]; long midi_offset; char modified; char description[-1]; }

user_defined_types: struct EOF_CATALOG_ENTRY { unsigned long track; unsigned char type; unsigned long start_pos; unsigned long end_pos; char name[-1]; }

user_defined_types: struct EOF_PHRASE_SECTION { unsigned long midi_start_pos; unsigned long midi_end_pos; unsigned long start_pos; unsigned long end_pos; unsigned long flags; char name[-1]; unsigned char difficulty; }

user_defined_types: struct EOF_NOTE { char name[-1]; unsigned char type; unsigned char note; unsigned long midi_pos; unsigned long midi_length; unsigned long pos; long length; unsigned long flags; unsigned char tflags; }

user_defined_types: struct EOF_LYRIC { unsigned char type; unsigned char note; char text[-1]; unsigned long midi_pos; long midi_length; unsigned long pos; long length; unsigned long flags; unsigned char tflags; }

user_defined_types: struct EOF_PRO_GUITAR_NOTE { char name[-1]; unsigned char type; unsigned char note; unsigned char ghost; unsigned char frets[8]; unsigned char finger[8]; unsigned char legacymask; unsigned long midi_pos; long midi_length; unsigned long pos; long length; unsigned long flags; unsigned long eflags; unsigned char bendstrength; unsigned char slideend; unsigned char unpitchend; unsigned char tflags; }


decompiled_code:
__int64 __fastcall eof_events_overridden_by_stored_MIDI_track(__int64 a1)
{
_QWORD *v1; // rbx

if ( !a1 )
return 0LL;
v1 = *(_QWORD **)(a1 + 295192);
if ( !v1 )
return 0LL;
do
{
if ( *v1 && !(unsigned int)ustricmp(*v1, "EVENTS") )
return 1LL;
v1 = (_QWORD *)v1[3];
}
while ( v1 );
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1)
{
_QWORD *v1; // rbx

if ( !a1 )
return 0LL;
v1 = *(_QWORD **)(a1 + 295192);
if ( !v1 )
return 0LL;
do
{
if ( *v1 && !(unsigned int)ustricmp(*v1, "EVENTS") )
return 1LL;
v1 = (_QWORD *)v1[3];
}
while ( v1 );
return 0LL;
}

original_code:
int eof_events_overridden_by_stored_MIDI_track(EOF_SONG *sp)
{
 struct eof_MIDI_data_track *trackptr;
 if(!sp)
  return 0;
 for(trackptr = sp->midi_data_head; trackptr != ((void *)0); trackptr = trackptr->next)
 {
  if(trackptr->trackname && !ustricmp(trackptr->trackname, "EVENTS"))
  {
   return 1;
  }
 }
 return 0;
}

canonical_original_code:
int eof_events_overridden_by_stored_MIDI_track(struct EOF_SONG *sp)
{
 struct eof_MIDI_data_track *trackptr;
 if(!sp)
  return 0;
 for(trackptr = sp->midi_data_head; trackptr != ((void *)0); trackptr = trackptr->next)
 {
  if(trackptr->trackname && !ustricmp(trackptr->trackname, "EVENTS"))
  {
   return 1;
  }
 }
 return 0;
}

user_defined_types: struct eof_MIDI_data_event { double realtime; char *stringtime; unsigned long deltatime; unsigned int size; void *data; struct eof_MIDI_data_event *next; }


decompiled_code:
__int64 __fastcall eof_music_seek(int a1)
{
eof_log("eof_music_seek() entered", 1LL);
alogg_seek_abs_msecs_ogg(eof_music_track, (unsigned int)(eof_av_delay + a1));
eof_music_pos = eof_av_delay + a1;
eof_music_actual_pos = eof_av_delay + a1;
eof_mix_seek();
return eof_reset_lyric_preview_lines();
}

canonical_decompiled_code:
__int64 __fastcall func0(int a1)
{
eof_log("eof_music_seek() entered", 1LL);
alogg_seek_abs_msecs_ogg(eof_music_track, (unsigned int)(eof_av_delay + a1));
eof_music_pos = eof_av_delay + a1;
eof_music_actual_pos = eof_av_delay + a1;
eof_mix_seek();
return eof_reset_lyric_preview_lines();
}

original_code:
void eof_music_seek(unsigned long pos)
{
 eof_log("eof_music_seek() entered", 1);
 alogg_seek_abs_msecs_ogg(eof_music_track, pos + eof_av_delay);
 eof_music_pos = pos + eof_av_delay;
 eof_music_actual_pos = eof_music_pos;
 eof_mix_seek(eof_music_actual_pos);
 eof_reset_lyric_preview_lines();
}

variable_types:
pos
unsigned long

return_type: void


decompiled_code:
unsigned __int64 __fastcall eof_music_play(char a1)
{
unsigned __int64 result; // rax
int v2; // eax
int v3; // ebp
_BOOL8 v4; // r9
int v5; // er10
int v6; // er11
int v7; // eax
unsigned __int64 i; // rbx
int v9; // ebp
__int64 v10; // rbp

result = eof_log("eof_music_play() entered", 1LL);
if ( !eof_music_catalog_playback && !eof_silence_loaded )
{
v2 = 1 - eof_music_paused;
eof_music_paused = 1 - eof_music_paused;
v3 = 1000;
if ( !a1 )
{
if ( (eof_key_shifts & 2) != 0 )
{
v3 = 500;
if ( (eof_key_shifts & 1) != 0 )
{
eof_shift_used = 1;
v3 = 250;
}
}
else
{
v3 = eof_playback_speed;
if ( key[4] )
{
key[4] = 0;
v3 = 1000;
}
}
}
if ( v2 )
{
eof_log("\tStopping playback", 1LL);
eof_stop_midi();
alogg_stop_ogg(eof_music_track);
result = alogg_get_pos_msecs_ogg(eof_music_track);
eof_music_actual_pos = result;
if ( eof_play_selection )
{
result = eof_music_seek(eof_music_rewind_pos);
eof_music_pos = eof_music_rewind_pos;
}
else if ( !eof_smooth_pos )
{
eof_music_pos = result;
}
}
else
{
result = eof_music_pos - eof_av_delay;
if ( result < eof_music_length )
{
eof_log("\tStarting playback", 1LL);
if ( !a1 )
speed_0 = v3;
if ( key[19] && eof_count_selected_notes(0LL, 0LL) )
{
eof_music_end_pos = 0;
eof_music_rewind_pos = eof_chart_length;
for ( i = 0LL; eof_get_track_size(eof_song, eof_selected_track) > i; ++i )
{
if ( eof_selection[i + 40] )
{
v10 = eof_get_note_pos(eof_song, eof_selected_track, i);
if ( v10 + eof_get_note_length(eof_song, eof_selected_track, i) > (unsigned __int64)eof_music_end_pos )
{
v9 = eof_get_note_pos(eof_song, eof_selected_track, i);
eof_music_end_pos = eof_get_note_length(eof_song, eof_selected_track, i) + v9;
}
if ( eof_selection[i + 40]
&& eof_get_note_pos(eof_song, eof_selected_track, i) < (unsigned __int64)eof_music_rewind_pos )
{
eof_music_rewind_pos = eof_get_note_pos(eof_song, eof_selected_track, i);
}
}
}
eof_music_seek(eof_music_rewind_pos);
eof_play_selection = 1;
}
else
{
eof_play_selection = 0;
}
eof_music_rewind_pos = eof_music_pos;
alogg_seek_abs_msecs_ogg(eof_music_track, eof_music_pos);
eof_mix_find_claps();
while ( 1 )
{
eof_read_controller(eof_drums);
eof_read_controller(eof_guitar);
v4 = 1LL;
if ( !eof_drums[7] )
v4 = eof_guitar[25] != 0LL;
v5 = 1;
if ( !eof_drums[16] )
{
if ( eof_guitar[34] )
v4 = 1LL;
v5 = v4;
}
v6 = 1;
if ( !eof_drums[25] )
{
v6 = v5;
if ( eof_guitar[43] )
v6 = 1;
}
if ( !eof_drums[34] )
{
if ( eof_guitar[52] )
v6 = 1;
if ( !(eof_guitar[61] | eof_drums[43]) && !v6 )
break;
}
}
if ( eof_playback_time_stretch )
v7 = alogg_play_ogg_ts(eof_music_track, eof_buffer_size, 255LL, 128LL, (unsigned int)speed_0, v4);
else
v7 = alogg_play_ex_ogg(
eof_music_track,
eof_buffer_size,
255LL,
128LL,
(unsigned int)(eof_audio_fine_tune + speed_0),
0LL);
if ( v7 )
{
result = allegro_message("Can't play song!");
eof_music_paused = 1;
}
else
{
eof_mix_start((unsigned int)speed_0);
eof_entering_note_note = 0LL;
eof_entering_note_lyric = 0LL;
eof_entering_note = 0;
eof_snote = 0;
alogg_poll_ogg(eof_music_track);
result = alogg_get_pos_msecs_ogg(eof_music_track);
eof_music_actual_pos = result;
}
}
else
{
eof_music_paused = 1;
}
}
}
return result;
}

canonical_decompiled_code:
unsigned __int64 __fastcall func1(char a1)
{
unsigned __int64 result; // rax
int v2; // eax
int v3; // ebp
_BOOL8 v4; // r9
int v5; // er10
int v6; // er11
int v7; // eax
unsigned __int64 i; // rbx
int v9; // ebp
__int64 v10; // rbp

result = eof_log("eof_music_play() entered", 1LL);
if ( !eof_music_catalog_playback && !eof_silence_loaded )
{
v2 = 1 - eof_music_paused;
eof_music_paused = 1 - eof_music_paused;
v3 = 1000;
if ( !a1 )
{
if ( (eof_key_shifts & 2) != 0 )
{
v3 = 500;
if ( (eof_key_shifts & 1) != 0 )
{
eof_shift_used = 1;
v3 = 250;
}
}
else
{
v3 = eof_playback_speed;
if ( key[4] )
{
key[4] = 0;
v3 = 1000;
}
}
}
if ( v2 )
{
eof_log("\tStopping playback", 1LL);
eof_stop_midi();
alogg_stop_ogg(eof_music_track);
result = alogg_get_pos_msecs_ogg(eof_music_track);
eof_music_actual_pos = result;
if ( eof_play_selection )
{
result = func0(eof_music_rewind_pos);
eof_music_pos = eof_music_rewind_pos;
}
else if ( !eof_smooth_pos )
{
eof_music_pos = result;
}
}
else
{
result = eof_music_pos - eof_av_delay;
if ( result < eof_music_length )
{
eof_log("\tStarting playback", 1LL);
if ( !a1 )
speed_0 = v3;
if ( key[19] && eof_count_selected_notes(0LL, 0LL) )
{
eof_music_end_pos = 0;
eof_music_rewind_pos = eof_chart_length;
for ( i = 0LL; eof_get_track_size(eof_song, eof_selected_track) > i; ++i )
{
if ( eof_selection[i + 40] )
{
v10 = eof_get_note_pos(eof_song, eof_selected_track, i);
if ( v10 + eof_get_note_length(eof_song, eof_selected_track, i) > (unsigned __int64)eof_music_end_pos )
{
v9 = eof_get_note_pos(eof_song, eof_selected_track, i);
eof_music_end_pos = eof_get_note_length(eof_song, eof_selected_track, i) + v9;
}
if ( eof_selection[i + 40]
&& eof_get_note_pos(eof_song, eof_selected_track, i) < (unsigned __int64)eof_music_rewind_pos )
{
eof_music_rewind_pos = eof_get_note_pos(eof_song, eof_selected_track, i);
}
}
}
func0(eof_music_rewind_pos);
eof_play_selection = 1;
}
else
{
eof_play_selection = 0;
}
eof_music_rewind_pos = eof_music_pos;
alogg_seek_abs_msecs_ogg(eof_music_track, eof_music_pos);
eof_mix_find_claps();
while ( 1 )
{
eof_read_controller(eof_drums);
eof_read_controller(eof_guitar);
v4 = 1LL;
if ( !eof_drums[7] )
v4 = eof_guitar[25] != 0LL;
v5 = 1;
if ( !eof_drums[16] )
{
if ( eof_guitar[34] )
v4 = 1LL;
v5 = v4;
}
v6 = 1;
if ( !eof_drums[25] )
{
v6 = v5;
if ( eof_guitar[43] )
v6 = 1;
}
if ( !eof_drums[34] )
{
if ( eof_guitar[52] )
v6 = 1;
if ( !(eof_guitar[61] | eof_drums[43]) && !v6 )
break;
}
}
if ( eof_playback_time_stretch )
v7 = alogg_play_ogg_ts(eof_music_track, eof_buffer_size, 255LL, 128LL, (unsigned int)speed_0, v4);
else
v7 = alogg_play_ex_ogg(
eof_music_track,
eof_buffer_size,
255LL,
128LL,
(unsigned int)(eof_audio_fine_tune + speed_0),
0LL);
if ( v7 )
{
result = allegro_message("Can't play song!");
eof_music_paused = 1;
}
else
{
eof_mix_start((unsigned int)speed_0);
eof_entering_note_note = 0LL;
eof_entering_note_lyric = 0LL;
eof_entering_note = 0;
eof_snote = 0;
alogg_poll_ogg(eof_music_track);
result = alogg_get_pos_msecs_ogg(eof_music_track);
eof_music_actual_pos = result;
}
}
else
{
eof_music_paused = 1;
}
}
}
return result;
}

original_code:
void eof_music_play(char resumelastspeed)
{
 static int speed = 1000;
 unsigned long i;
 int ret, newspeed = 1000;
 eof_log("eof_music_play() entered", 1);
 if(eof_music_catalog_playback || eof_silence_loaded)
 {
  return;
 }
 eof_music_paused = 1 - eof_music_paused;
 if(!resumelastspeed)
 {
  newspeed = eof_playback_speed;
  if((eof_key_shifts & __allegro_KB_CTRL_FLAG))
  {
   if((eof_key_shifts & __allegro_KB_SHIFT_FLAG))
   {
    eof_shift_used = 1;
    newspeed = 250;
   }
   else
   {
    newspeed = 500;
   }
  }
  else if(key[__allegro_KEY_D])
  {
   newspeed = 1000;
   key[__allegro_KEY_D]=0;
  }
 }
 if(eof_music_paused)
 {
  eof_log("\tStopping playback", 1);
  eof_stop_midi();
  alogg_stop_ogg(eof_music_track);
  eof_music_actual_pos = alogg_get_pos_msecs_ogg(eof_music_track);
  if(eof_play_selection)
  {
   eof_music_seek(eof_music_rewind_pos);
   eof_music_pos = eof_music_rewind_pos;
  }
  else if(!eof_smooth_pos)
  {
   eof_music_pos = eof_music_actual_pos;
  }
 }
 else if(eof_music_pos - eof_av_delay < eof_music_length)
 {
  unsigned long x;
  int held;
  eof_log("\tStarting playback", 1);
  if(!resumelastspeed)
  {
   speed = newspeed;
  }
  if(key[__allegro_KEY_S] && (eof_count_selected_notes(((void *)0), 0) > 0))
  {
   eof_music_end_pos = 0;
   eof_music_rewind_pos = eof_chart_length;
   for(i = 0; i < eof_get_track_size(eof_song, eof_selected_track); i++)
   {
    if(eof_selection.multi[i] && (eof_get_note_pos(eof_song, eof_selected_track, i) + eof_get_note_length(eof_song, eof_selected_track, i) > eof_music_end_pos))
    {
     eof_music_end_pos = eof_get_note_pos(eof_song, eof_selected_track, i) + eof_get_note_length(eof_song, eof_selected_track, i);
    }
    if(eof_selection.multi[i] && (eof_get_note_pos(eof_song, eof_selected_track, i) < eof_music_rewind_pos))
    {
     eof_music_rewind_pos = eof_get_note_pos(eof_song, eof_selected_track, i);
    }
   }
   eof_music_seek(eof_music_rewind_pos);
   eof_play_selection = 1;
  }
  else
  {
   eof_play_selection = 0;
  }
  eof_music_rewind_pos = eof_music_pos;
   alogg_seek_abs_msecs_ogg(eof_music_track, eof_music_pos);
  eof_mix_find_claps();
  do{
   held = 0;
   eof_read_controller(&eof_drums);
   eof_read_controller(&eof_guitar);
   for(x = 0; x < 5; x++)
   {
    if((eof_drums.button[x].held) || (eof_guitar.button[x+2].held))
     held = 1;
   }
  }while(held);
  if(eof_playback_time_stretch)
  {
   ret = alogg_play_ogg_ts(eof_music_track, eof_buffer_size, 255, 128, speed);
  }
  else
  {
   ret = alogg_play_ex_ogg(eof_music_track, eof_buffer_size, 255, 128, speed + eof_audio_fine_tune, 0);
  }
  if(ret == 0)
  {
   eof_mix_start(speed);
   eof_entering_note_note = ((void *)0);
   eof_entering_note_lyric = ((void *)0);
   eof_entering_note = 0;
   eof_snote = 0;
   (void) alogg_poll_ogg(eof_music_track);
   eof_music_actual_pos = alogg_get_pos_msecs_ogg(eof_music_track);
  }
  else
  {
   allegro_message("Can't play song!");
   eof_music_paused = 1;
  }
 }
 else
 {
  eof_music_paused = 1;
 }
}

canonical_original_code:
void eof_music_play(char resumelastspeed)
{
 static int speed = 1000;
 unsigned long i;
 int ret; int newspeed = 1000;
 eof_log("eof_music_play() entered", 1);
 if(eof_music_catalog_playback || eof_silence_loaded)
 {
  return;
 }
 eof_music_paused = 1 - eof_music_paused;
 if(!resumelastspeed)
 {
  newspeed = eof_playback_speed;
  if((eof_key_shifts & __allegro_KB_CTRL_FLAG))
  {
   if((eof_key_shifts & __allegro_KB_SHIFT_FLAG))
   {
    eof_shift_used = 1;
    newspeed = 250;
   }
   else
   {
    newspeed = 500;
   }
  }
  else if(key[__allegro_KEY_D])
  {
   newspeed = 1000;
   key[__allegro_KEY_D]=0;
  }
 }
 if(eof_music_paused)
 {
  eof_log("\tStopping playback", 1);
  eof_stop_midi();
  alogg_stop_ogg(eof_music_track);
  eof_music_actual_pos = alogg_get_pos_msecs_ogg(eof_music_track);
  if(eof_play_selection)
  {
   eof_music_seek(eof_music_rewind_pos);
   eof_music_pos = eof_music_rewind_pos;
  }
  else if(!eof_smooth_pos)
  {
   eof_music_pos = eof_music_actual_pos;
  }
 }
 else if(eof_music_pos - eof_av_delay < eof_music_length)
 {
  unsigned long x;
  int held;
  eof_log("\tStarting playback", 1);
  if(!resumelastspeed)
  {
   speed = newspeed;
  }
  if(key[__allegro_KEY_S] && (eof_count_selected_notes(((void *)0), 0) > 0))
  {
   eof_music_end_pos = 0;
   eof_music_rewind_pos = eof_chart_length;
   for(i = 0; i < eof_get_track_size(eof_song, eof_selected_track); i++)
   {
    if(eof_selection.multi[i] && (eof_get_note_pos(eof_song, eof_selected_track, i) + eof_get_note_length(eof_song, eof_selected_track, i) > eof_music_end_pos))
    {
     eof_music_end_pos = eof_get_note_pos(eof_song, eof_selected_track, i) + eof_get_note_length(eof_song, eof_selected_track, i);
    }
    if(eof_selection.multi[i] && (eof_get_note_pos(eof_song, eof_selected_track, i) < eof_music_rewind_pos))
    {
     eof_music_rewind_pos = eof_get_note_pos(eof_song, eof_selected_track, i);
    }
   }
   eof_music_seek(eof_music_rewind_pos);
   eof_play_selection = 1;
  }
  else
  {
   eof_play_selection = 0;
  }
  eof_music_rewind_pos = eof_music_pos;
   alogg_seek_abs_msecs_ogg(eof_music_track, eof_music_pos);
  eof_mix_find_claps();
  do{
   held = 0;
   eof_read_controller(&eof_drums);
   eof_read_controller(&eof_guitar);
   for(x = 0; x < 5; x++)
   {
    if((eof_drums.button[x].held) || (eof_guitar.button[x+2].held))
     held = 1;
   }
  }while(held);
  if(eof_playback_time_stretch)
  {
   ret = alogg_play_ogg_ts(eof_music_track, eof_buffer_size, 255, 128, speed);
  }
  else
  {
   ret = alogg_play_ex_ogg(eof_music_track, eof_buffer_size, 255, 128, speed + eof_audio_fine_tune, 0);
  }
  if(ret == 0)
  {
   eof_mix_start(speed);
   eof_entering_note_note = ((void *)0);
   eof_entering_note_lyric = ((void *)0);
   eof_entering_note = 0;
   eof_snote = 0;
   (void) alogg_poll_ogg(eof_music_track);
   eof_music_actual_pos = alogg_get_pos_msecs_ogg(eof_music_track);
  }
  else
  {
   allegro_message("Can't play song!");
   eof_music_paused = 1;
  }
 }
 else
 {
  eof_music_paused = 1;
 }
}

variable_types: resumelastspeed char

variable_types: speed int

variable_types:
i
unsigned long

variable_types: ret int

variable_types: newspeed int

variable_types:
x
unsigned long

variable_types: held int


decompiled_code:
unsigned __int64 eof_catalog_play()
{
unsigned __int64 result; // rax
__int64 v1; // rsi

eof_log("eof_catalog_play() entered", 1LL);
result = eof_song;
v1 = *(_QWORD *)(eof_song + 295288LL);
if ( *(_QWORD *)(v1 + 0x4000) && !eof_silence_loaded )
{
if ( eof_music_paused )
{
if ( eof_music_catalog_playback )
{
eof_music_catalog_playback = 0;
eof_music_catalog_pos = *(_DWORD *)(v1 + (eof_selected_catalog_entry << 6) + 16) + eof_av_delay;
eof_stop_midi();
alogg_stop_ogg(eof_music_track);
result = alogg_seek_abs_msecs_ogg(eof_music_track, eof_music_pos);
}
else
{
alogg_seek_abs_msecs_ogg(eof_music_track, *(_QWORD *)(v1 + (eof_selected_catalog_entry << 6) + 16));
eof_music_catalog_pos = *(_DWORD *)(*(_QWORD *)(eof_song + 295288LL) + (eof_selected_catalog_entry << 6) + 16LL)
+ eof_av_delay;
eof_music_catalog_playback = 1;
if ( (unsigned int)alogg_play_ex_ogg(
eof_music_track,
eof_buffer_size,
255LL,
128LL,
(unsigned int)(eof_audio_fine_tune + 1000),
0LL) )
{
result = allegro_message("Can't play song!");
}
else
{
eof_music_actual_pos = alogg_get_pos_msecs_ogg(eof_music_track);
eof_mix_find_claps();
result = eof_mix_start(1000LL);
}
}
}
else
{
result = eof_music_play(0);
}
}
return result;
}

canonical_decompiled_code:
unsigned __int64 func2()
{
unsigned __int64 result; // rax
__int64 v1; // rsi

eof_log("eof_catalog_play() entered", 1LL);
result = eof_song;
v1 = *(_QWORD *)(eof_song + 295288LL);
if ( *(_QWORD *)(v1 + 0x4000) && !eof_silence_loaded )
{
if ( eof_music_paused )
{
if ( eof_music_catalog_playback )
{
eof_music_catalog_playback = 0;
eof_music_catalog_pos = *(_DWORD *)(v1 + (eof_selected_catalog_entry << 6) + 16) + eof_av_delay;
eof_stop_midi();
alogg_stop_ogg(eof_music_track);
result = alogg_seek_abs_msecs_ogg(eof_music_track, eof_music_pos);
}
else
{
alogg_seek_abs_msecs_ogg(eof_music_track, *(_QWORD *)(v1 + (eof_selected_catalog_entry << 6) + 16));
eof_music_catalog_pos = *(_DWORD *)(*(_QWORD *)(eof_song + 295288LL) + (eof_selected_catalog_entry << 6) + 16LL)
+ eof_av_delay;
eof_music_catalog_playback = 1;
if ( (unsigned int)alogg_play_ex_ogg(
eof_music_track,
eof_buffer_size,
255LL,
128LL,
(unsigned int)(eof_audio_fine_tune + 1000),
0LL) )
{
result = allegro_message("Can't play song!");
}
else
{
eof_music_actual_pos = alogg_get_pos_msecs_ogg(eof_music_track);
eof_mix_find_claps();
result = eof_mix_start(1000LL);
}
}
}
else
{
result = func1(0);
}
}
return result;
}

original_code:
void eof_catalog_play(void)
{
 eof_log("eof_catalog_play() entered", 1);
 if((eof_song->catalog->entries > 0) && !eof_silence_loaded)
 {
  if(!eof_music_paused)
  {
   eof_music_play(0);
  }
  else if(eof_music_catalog_playback)
  {
   eof_music_catalog_playback = 0;
   eof_music_catalog_pos = eof_song->catalog->entry[eof_selected_catalog_entry].start_pos + eof_av_delay;
   eof_stop_midi();
   alogg_stop_ogg(eof_music_track);
   alogg_seek_abs_msecs_ogg(eof_music_track, eof_music_pos);
  }
  else
  {
   alogg_seek_abs_msecs_ogg(eof_music_track, eof_song->catalog->entry[eof_selected_catalog_entry].start_pos);
   eof_music_catalog_pos = eof_song->catalog->entry[eof_selected_catalog_entry].start_pos + eof_av_delay;
   eof_music_catalog_playback = 1;
   if(alogg_play_ex_ogg(eof_music_track, eof_buffer_size, 255, 128, 1000 + eof_audio_fine_tune, 0) == 0)
   {
    eof_music_actual_pos = alogg_get_pos_msecs_ogg(eof_music_track);
    eof_mix_find_claps();
    eof_mix_start(1000);
   }
   else
   {
    allegro_message("Can't play song!");
   }
  }
 }
}

canonical_original_code:
void eof_catalog_play()
{
 eof_log("eof_catalog_play() entered", 1);
 if((eof_song->catalog->entries > 0) && !eof_silence_loaded)
 {
  if(!eof_music_paused)
  {
   eof_music_play(0);
  }
  else if(eof_music_catalog_playback)
  {
   eof_music_catalog_playback = 0;
   eof_music_catalog_pos = eof_song->catalog->entry[eof_selected_catalog_entry].start_pos + eof_av_delay;
   eof_stop_midi();
   alogg_stop_ogg(eof_music_track);
   alogg_seek_abs_msecs_ogg(eof_music_track, eof_music_pos);
  }
  else
  {
   alogg_seek_abs_msecs_ogg(eof_music_track, eof_song->catalog->entry[eof_selected_catalog_entry].start_pos);
   eof_music_catalog_pos = eof_song->catalog->entry[eof_selected_catalog_entry].start_pos + eof_av_delay;
   eof_music_catalog_playback = 1;
   if(alogg_play_ex_ogg(eof_music_track, eof_buffer_size, 255, 128, 1000 + eof_audio_fine_tune, 0) == 0)
   {
    eof_music_actual_pos = alogg_get_pos_msecs_ogg(eof_music_track);
    eof_mix_find_claps();
    eof_mix_start(1000);
   }
   else
   {
    allegro_message("Can't play song!");
   }
  }
 }
}


decompiled_code:
__int64 eof_music_rewind()
{
__int64 result; // rax
int v1; // eax

eof_log("eof_music_rewind() entered", 2LL);
result = eof_stop_midi();
if ( !eof_music_catalog_playback )
{
v1 = eof_key_shifts & 1;
if ( (eof_key_shifts & 1) != 0 )
{
eof_shift_used = 1;
if ( (eof_key_shifts & 2) == 0 )
v1 = 1000;
}
else
{
v1 = (eof_key_shifts & 2) == 0 ? 100 : 10;
}
if ( eof_music_pos - eof_av_delay >= v1 )
result = eof_set_seek_position((unsigned int)(eof_music_pos - v1));
else
result = eof_menu_song_seek_start();
}
return result;
}

canonical_decompiled_code:
__int64 func3()
{
__int64 result; // rax
int v1; // eax

eof_log("eof_music_rewind() entered", 2LL);
result = eof_stop_midi();
if ( !eof_music_catalog_playback )
{
v1 = eof_key_shifts & 1;
if ( (eof_key_shifts & 1) != 0 )
{
eof_shift_used = 1;
if ( (eof_key_shifts & 2) == 0 )
v1 = 1000;
}
else
{
v1 = (eof_key_shifts & 2) == 0 ? 100 : 10;
}
if ( eof_music_pos - eof_av_delay >= v1 )
result = eof_set_seek_position((unsigned int)(eof_music_pos - v1));
else
result = eof_menu_song_seek_start();
}
return result;
}

original_code:
void eof_music_rewind(void)
{
 int amount = 0;
 eof_log("eof_music_rewind() entered", 2);
 eof_stop_midi();
 if(!eof_music_catalog_playback)
 {
  if((eof_key_shifts & __allegro_KB_SHIFT_FLAG))
  {
   eof_shift_used = 1;
   if((eof_key_shifts & __allegro_KB_CTRL_FLAG))
   {
    amount = 1;
   }
   else
   {
    amount = 1000;
   }
  }
  else if((eof_key_shifts & __allegro_KB_CTRL_FLAG))
  {
   amount = 10;
  }
  else
  {
   amount = 100;
  }
  if(eof_music_pos - eof_av_delay < amount)
  {
   (void) eof_menu_song_seek_start();
  }
  else
  {
   eof_set_seek_position(eof_music_pos - amount);
  }
 }
}

canonical_original_code:
void eof_music_rewind()
{
 int amount = 0;
 eof_log("eof_music_rewind() entered", 2);
 eof_stop_midi();
 if(!eof_music_catalog_playback)
 {
  if((eof_key_shifts & __allegro_KB_SHIFT_FLAG))
  {
   eof_shift_used = 1;
   if((eof_key_shifts & __allegro_KB_CTRL_FLAG))
   {
    amount = 1;
   }
   else
   {
    amount = 1000;
   }
  }
  else if((eof_key_shifts & __allegro_KB_CTRL_FLAG))
  {
   amount = 10;
  }
  else
  {
   amount = 100;
  }
  if(eof_music_pos - eof_av_delay < amount)
  {
   (void) eof_menu_song_seek_start();
  }
  else
  {
   eof_set_seek_position(eof_music_pos - amount);
  }
 }
}

variable_types: amount int


decompiled_code:
__int64 eof_music_forward()
{
__int64 result; // rax
int v1; // edi
unsigned __int64 v2; // r8
__int64 v3; // rdi

eof_log("eof_music_forward() entered", 2LL);
result = eof_stop_midi();
if ( !eof_music_catalog_playback )
{
v1 = eof_key_shifts & 1;
if ( (eof_key_shifts & 1) != 0 )
{
eof_shift_used = 1;
if ( (eof_key_shifts & 2) == 0 )
v1 = 1000;
}
else
{
v1 = (eof_key_shifts & 2) == 0 ? 100 : 10;
}
v2 = eof_music_pos + v1;
v3 = (unsigned int)(eof_music_pos + v1);
if ( v2 > eof_chart_length )
v3 = eof_chart_length;
result = eof_set_seek_position(v3);
}
return result;
}

canonical_decompiled_code:
__int64 func4()
{
__int64 result; // rax
int v1; // edi
unsigned __int64 v2; // r8
__int64 v3; // rdi

eof_log("eof_music_forward() entered", 2LL);
result = eof_stop_midi();
if ( !eof_music_catalog_playback )
{
v1 = eof_key_shifts & 1;
if ( (eof_key_shifts & 1) != 0 )
{
eof_shift_used = 1;
if ( (eof_key_shifts & 2) == 0 )
v1 = 1000;
}
else
{
v1 = (eof_key_shifts & 2) == 0 ? 100 : 10;
}
v2 = eof_music_pos + v1;
v3 = (unsigned int)(eof_music_pos + v1);
if ( v2 > eof_chart_length )
v3 = eof_chart_length;
result = eof_set_seek_position(v3);
}
return result;
}

original_code:
void eof_music_forward(void)
{
 int amount = 0, target;
 eof_log("eof_music_forward() entered", 2);
 eof_stop_midi();
 if(!eof_music_catalog_playback)
 {
  if((eof_key_shifts & __allegro_KB_SHIFT_FLAG))
  {
   eof_shift_used = 1;
   if((eof_key_shifts & __allegro_KB_CTRL_FLAG))
   {
    amount = 1;
   }
   else
   {
    amount = 1000;
   }
  }
  else if((eof_key_shifts & __allegro_KB_CTRL_FLAG))
  {
   amount = 10;
  }
  else
  {
   amount = 100;
  }
  target = eof_music_pos + amount;
  if(target > eof_chart_length)
  {
   target = eof_chart_length;
  }
  eof_set_seek_position(target);
 }
}

canonical_original_code:
void eof_music_forward()
{
 int amount = 0; int target;
 eof_log("eof_music_forward() entered", 2);
 eof_stop_midi();
 if(!eof_music_catalog_playback)
 {
  if((eof_key_shifts & __allegro_KB_SHIFT_FLAG))
  {
   eof_shift_used = 1;
   if((eof_key_shifts & __allegro_KB_CTRL_FLAG))
   {
    amount = 1;
   }
   else
   {
    amount = 1000;
   }
  }
  else if((eof_key_shifts & __allegro_KB_CTRL_FLAG))
  {
   amount = 10;
  }
  else
  {
   amount = 100;
  }
  target = eof_music_pos + amount;
  if(target > eof_chart_length)
  {
   target = eof_chart_length;
  }
  eof_set_seek_position(target);
 }
}

variable_types: target int


ParseLongIntXML

original_code:
long int ParseLongIntXML(char *buffer,unsigned long linenum)
{
 char numberbuffer[11]={0};
 unsigned long index=0;
 unsigned long index2=0;
 char *tempstr=((void *)0);
 long num;
 assert_wrapper(buffer != ((void *)0));
 while(buffer[index] != '\0')
 {
  if(buffer[index] == '<')
   break;
  if(index2 >= 10)
   break;
  numberbuffer[index2++]=buffer[index++];
 }
 numberbuffer[index2]='\0';
 tempstr=RemoveLeadingZeroes(numberbuffer);
 if(tempstr[0] == '0')
 {
  num = 0;
 }
 else
 {
  num = atol(tempstr);
  if(!num)
  {
   printf("Error converting numerical string to numerical value.\nError occurs in line %lu of input file\nAborting\n",linenum);
   exit_wrapper(2);
  }
 }
 free(tempstr);
 return num;
}

canonical_original_code:
long ParseLongIntXML(char *buffer, unsigned long linenum)
{
 char numberbuffer[11] = {0};
 unsigned long index = 0;
 unsigned long index2 = 0;
 char *tempstr = ((void *)0);
 long num;
 assert_wrapper(buffer != ((void *)0));
 while(buffer[index] != '\0')
 {
  if(buffer[index] == '<')
   break;
  if(index2 >= 10)
   break;
  numberbuffer[index2++]=buffer[index++];
 }
 numberbuffer[index2]='\0';
 tempstr=RemoveLeadingZeroes(numberbuffer);
 if(tempstr[0] == '0')
 {
  num = 0;
 }
 else
 {
  num = atol(tempstr);
  if(!num)
  {
   printf("Error converting numerical string to numerical value.\nError occurs in line %lu of input file\nAborting\n",linenum);
   exit_wrapper(2);
  }
 }
 free(tempstr);
 return num;
}

variable_types:
buffer
char *

variable_types:
linenum
unsigned long

variable_types:
numberbuffer
char [11]

variable_types:
index
unsigned long

variable_types:
tempstr
char *

variable_types: num long

return_type: long


original_code:
double notefunc_note_to_freq(char* note)
{
 char notename;
 char octavestr[10];
 int octavenum;
 char accidental = 0;
 int adj = 0;
 size_t notenum = 0, numnotes = strlen(notelist);
 notename = note[0];
 if(strlen(note) == 2)
 {
  strncpy(octavestr, note + 1, sizeof(octavestr) - 1);
  accidental = 0;
 }
 else if(strlen(note) == 3)
 {
  strncpy(octavestr, note + 2, sizeof(octavestr) - 1);
  accidental = note[1];
 }
 else
 {
  return 440;
 }
 octavestr[9] = '\0';
 octavenum = atoi(octavestr);
 if(notename > 90)
 {
  notename -= 32;
 }
 for(notenum=0;notenum < numnotes;notenum++)
 {
  if(notelist[notenum] == notename)
   break;
 }
 if(notenum == numnotes)
 {
  return 440;
 }
 if(accidental)
 {
  if(accidental == '#')
  {
   adj = 1;
  }
  else if(accidental == 'b')
  {
   adj = -1;
  }
  notenum = (notenum + adj) % numnotes;
 }
 return round(16.3515978312874 * pow(2,(double)octavenum+(notenum/12.0)) *100)/100;
}

canonical_original_code:
double notefunc_note_to_freq(char *note)
{
 char notename;
 char octavestr[10];
 int octavenum;
 char accidental = 0;
 int adj = 0;
 unsigned long notenum = 0; unsigned long numnotes = strlen(notelist);
 notename = note[0];
 if(strlen(note) == 2)
 {
  strncpy(octavestr, note + 1, sizeof(octavestr) - 1);
  accidental = 0;
 }
 else if(strlen(note) == 3)
 {
  strncpy(octavestr, note + 2, sizeof(octavestr) - 1);
  accidental = note[1];
 }
 else
 {
  return 440;
 }
 octavestr[9] = '\0';
 octavenum = atoi(octavestr);
 if(notename > 90)
 {
  notename -= 32;
 }
 for(notenum=0;notenum < numnotes;notenum++)
 {
  if(notelist[notenum] == notename)
   break;
 }
 if(notenum == numnotes)
 {
  return 440;
 }
 if(accidental)
 {
  if(accidental == '#')
  {
   adj = 1;
  }
  else if(accidental == 'b')
  {
   adj = -1;
  }
  notenum = (notenum + adj) % numnotes;
 }
 return round(16.3515978312874 * pow(2,(double)octavenum+(notenum/12.0)) *100)/100;
}

variable_types:
note
char *

variable_types: notename char

variable_types:
octavestr
char [10]

variable_types: octavenum int

variable_types: accidental char

variable_types: adj int

variable_types:
notenum
unsigned long

variable_types:
numnotes
unsigned long

return_type: double


decompiled_code:
char *__fastcall notefunc_freq_to_note(double a1)
{
double v1; // xmm1_8
double v2; // xmm0_8
double v3; // xmm0_8
__int64 v4; // r8

v1 = COERCE_DOUBLE(COERCE_UNSIGNED_INT64(_log_finite(a1 * 0.06115610292754293) * 1.442695040888963) & LC4) * 100.0;
v2 = v1;
if ( COERCE_DOUBLE(*(_QWORD *)&v1 & LC4) < 4.503599627370496e15 )
*(_QWORD *)&v2 = COERCE_UNSIGNED_INT64((double)(int)(COERCE_DOUBLE(*(_QWORD *)&v1 & LC4) + 0.4999999999999999)) | ~LC4 & *(_QWORD *)&v1;
v3 = v2 * 0.01;
v4 = (unsigned int)(int)v3;
if ( (double)(int)v4 > v3 )
v4 = (unsigned int)(v4 - 1);
snprintf(
returnval,
9uLL,
"%s%d",
(const char *)notenames
+ 3
* (int)((v3 - (double)(int)v4) * 12.0
+ COERCE_DOUBLE(LC11 & COERCE_UNSIGNED_INT64((v3 - (double)(int)v4) * 12.0) | LC5)),
v4);
return returnval;
}

canonical_decompiled_code:
char *__fastcall func1(double a1)
{
double v1; // xmm1_8
double v2; // xmm0_8
double v3; // xmm0_8
__int64 v4; // r8

v1 = COERCE_DOUBLE(COERCE_UNSIGNED_INT64(_log_finite(a1 * 0.06115610292754293) * 1.442695040888963) & LC4) * 100.0;
v2 = v1;
if ( COERCE_DOUBLE(*(_QWORD *)&v1 & LC4) < 4.503599627370496e15 )
*(_QWORD *)&v2 = COERCE_UNSIGNED_INT64((double)(int)(COERCE_DOUBLE(*(_QWORD *)&v1 & LC4) + 0.4999999999999999)) | ~LC4 & *(_QWORD *)&v1;
v3 = v2 * 0.01;
v4 = (unsigned int)(int)v3;
if ( (double)(int)v4 > v3 )
v4 = (unsigned int)(v4 - 1);
snprintf(
returnval,
9uLL,
"%s%d",
(const char *)notenames
+ 3
* (int)((v3 - (double)(int)v4) * 12.0
+ COERCE_DOUBLE(LC11 & COERCE_UNSIGNED_INT64((v3 - (double)(int)v4) * 12.0) | LC5)),
v4);
return returnval;
}

original_code:
char* notefunc_freq_to_note(double freq)
{
 double logof2 = log(2.0);
 double midval = round(fabs(log(freq/16.3515978312874)/logof2) *100)/100;
 int octavenum = floor(midval);
 int notenum = round(12.0*(midval - octavenum));
 (void) snprintf(returnval, sizeof(returnval) - 1, "%s%d", notenames+notenum*3, octavenum);
 return returnval;
}

canonical_original_code:
char *notefunc_freq_to_note(double freq)
{
 double logof2 = log(2.0);
 double midval = round(fabs(log(freq/16.3515978312874)/logof2) *100)/100;
 int octavenum = floor(midval);
 int notenum = round(12.0*(midval - octavenum));
 (void) snprintf(returnval, sizeof(returnval) - 1, "%s%d", notenames+notenum*3, octavenum);
 return returnval;
}

variable_types: freq double

variable_types: midval double

variable_types: notenum int

return_type: char *


decompiled_code:
__int64 __fastcall eof_verified_edit_proc(__int64 a1, __int64 a2, int a3)
{
int v4; // eax
char *v5; // rdx
char v6; // r10
char *v7; // rdx

if ( (_DWORD)a1 != 7 )
return d_agup_edit_proc(a1, a2, (unsigned int)a3);
v4 = a3 >> 8;
if ( a3 >> 8 == 63 || v4 == 77 || v4 == 82 || v4 == 83 || v4 == 84 || v4 == 85 || v4 == 59 || v4 == 67 )
return d_agup_edit_proc(7LL, a2, (unsigned int)a3);
v5 = *(char **)(a2 + 56);
if ( !v5 )
return d_agup_edit_proc(a1, a2, (unsigned int)a3);
v6 = *v5;
if ( *v5 )
{
v7 = v5 + 1;
while ( v6 != (unsigned __int8)a3 )
{
v6 = *v7++;
if ( !v6 )
return 16LL;
}
return d_agup_edit_proc(a1, a2, (unsigned int)a3);
}
return 16LL;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 a2, int a3)
{
int v4; // eax
char *v5; // rdx
char v6; // r10
char *v7; // rdx

if ( (_DWORD)a1 != 7 )
return d_agup_edit_proc(a1, a2, (unsigned int)a3);
v4 = a3 >> 8;
if ( a3 >> 8 == 63 || v4 == 77 || v4 == 82 || v4 == 83 || v4 == 84 || v4 == 85 || v4 == 59 || v4 == 67 )
return d_agup_edit_proc(7LL, a2, (unsigned int)a3);
v5 = *(char **)(a2 + 56);
if ( !v5 )
return d_agup_edit_proc(a1, a2, (unsigned int)a3);
v6 = *v5;
if ( *v5 )
{
v7 = v5 + 1;
while ( v6 != (unsigned __int8)a3 )
{
v6 = *v7++;
if ( !v6 )
return 16LL;
}
return d_agup_edit_proc(a1, a2, (unsigned int)a3);
}
return 16LL;
}

original_code:
int eof_verified_edit_proc(int msg, DIALOG *d, int c)
{
 int i;
 char * string = ((void *)0);
 int key_list[32] = {__allegro_KEY_BACKSPACE, __allegro_KEY_DEL, __allegro_KEY_LEFT, __allegro_KEY_RIGHT, __allegro_KEY_UP, __allegro_KEY_DOWN, __allegro_KEY_ESC, __allegro_KEY_ENTER};
 int match = 0;
 if(msg == 7)
 {
  for(i = 0; i < 8; i++)
  {
   if(c >> 8 == key_list[i])
   {
    return d_agup_edit_proc(msg, d, c);
   }
  }
  string = (char *)(d->dp2);
  if(string == ((void *)0))
   match = 1;
  else
  {
   for(i = 0; string[i] != '\0'; i++)
   {
    if(string[i] == (c & 0xff))
    {
     match = 1;
     break;
    }
   }
  }
  if(!match)
   return 16;
 }
 return d_agup_edit_proc(msg, d, c);
}

canonical_original_code:
int eof_verified_edit_proc(int msg, struct DIALOG *d, int c)
{
 int i;
 char *string = ((void *)0);
 int key_list[32] = {__allegro_KEY_BACKSPACE, __allegro_KEY_DEL, __allegro_KEY_LEFT, __allegro_KEY_RIGHT, __allegro_KEY_UP, __allegro_KEY_DOWN, __allegro_KEY_ESC, __allegro_KEY_ENTER};
 int match = 0;
 if(msg == 7)
 {
  for(i = 0; i < 8; i++)
  {
   if(c >> 8 == key_list[i])
   {
    return d_agup_edit_proc(msg, d, c);
   }
  }
  string = (char *)(d->dp2);
  if(string == ((void *)0))
   match = 1;
  else
  {
   for(i = 0; string[i] != '\0'; i++)
   {
    if(string[i] == (c & 0xff))
    {
     match = 1;
     break;
    }
   }
  }
  if(!match)
   return 16;
 }
 return d_agup_edit_proc(msg, d, c);
}

variable_types: msg int

variable_types: struct DIALOG { int (*proc)(int msg, struct DIALOG *d, int c); int x; int fg; int key; int flags; int d1; void *dp; } *

variable_types: c int

variable_types: i int

variable_types:
string
char *

variable_types: match int


decompiled_code:
void eof_prepare_main_menu()
{
*((_DWORD *)&eof_main_menu + 46) = 32;
if ( eof_song && eof_song_loaded )
{
*((_DWORD *)&eof_main_menu + 16) = 0;
*((_DWORD *)&eof_main_menu + 26) = 0;
*((_DWORD *)&eof_main_menu + 36) = 0;
*((_DWORD *)&eof_main_menu + 56) = 0;
if ( eof_count_selected_notes(0LL, 1LL) || eof_input_mode == 6 && eof_seek_hover_note >= 0 )
*((_DWORD *)&eof_main_menu + 46) = 0;
}
else
{
*((_DWORD *)&eof_main_menu + 16) = 32;
*((_DWORD *)&eof_main_menu + 26) = 32;
*((_DWORD *)&eof_main_menu + 56) = 32;
}
}

canonical_decompiled_code:
void func0()
{
*((_DWORD *)&eof_main_menu + 46) = 32;
if ( eof_song && eof_song_loaded )
{
*((_DWORD *)&eof_main_menu + 16) = 0;
*((_DWORD *)&eof_main_menu + 26) = 0;
*((_DWORD *)&eof_main_menu + 36) = 0;
*((_DWORD *)&eof_main_menu + 56) = 0;
if ( eof_count_selected_notes(0LL, 1LL) || eof_input_mode == 6 && eof_seek_hover_note >= 0 )
*((_DWORD *)&eof_main_menu + 46) = 0;
}
else
{
*((_DWORD *)&eof_main_menu + 16) = 32;
*((_DWORD *)&eof_main_menu + 26) = 32;
*((_DWORD *)&eof_main_menu + 56) = 32;
}
}

original_code:
void eof_prepare_main_menu(void)
{
 eof_main_menu[4].flags = 32;
 if(eof_song && eof_song_loaded)
 {
  eof_main_menu[1].flags = 0;
  eof_main_menu[2].flags = 0;
  eof_main_menu[3].flags = 0;
  eof_main_menu[5].flags = 0;
  if(eof_count_selected_notes(((void *)0), 1) || ((eof_input_mode == 6) && (eof_seek_hover_note >= 0)))
  {
   eof_main_menu[4].flags = 0;
  }
 }
 else
 {
  eof_main_menu[1].flags = 32;
  eof_main_menu[2].flags = 32;
  eof_main_menu[5].flags = 32;
 }
}

canonical_original_code:
void eof_prepare_main_menu()
{
 eof_main_menu[4].flags = 32;
 if(eof_song && eof_song_loaded)
 {
  eof_main_menu[1].flags = 0;
  eof_main_menu[2].flags = 0;
  eof_main_menu[3].flags = 0;
  eof_main_menu[5].flags = 0;
  if(eof_count_selected_notes(((void *)0), 1) || ((eof_input_mode == 6) && (eof_seek_hover_note >= 0)))
  {
   eof_main_menu[4].flags = 0;
  }
 }
 else
 {
  eof_main_menu[1].flags = 32;
  eof_main_menu[2].flags = 32;
  eof_main_menu[5].flags = 32;
 }
}


decompiled_code:
void __fastcall eof_window_destroy(void *ptr)
{
eof_log("eof_window_destroy() entered", 1LL);
if ( ptr )
{
destroy_bitmap(*((_QWORD *)ptr + 2));
free(ptr);
}
}

canonical_decompiled_code:
void __fastcall func0(void *ptr)
{
eof_log("eof_window_destroy() entered", 1LL);
if ( ptr )
{
destroy_bitmap(*((_QWORD *)ptr + 2));
free(ptr);
}
}

original_code:
void eof_window_destroy(EOF_WINDOW * wp)
{
  eof_log("eof_window_destroy() entered", 1);
 if(wp)
 {
  destroy_bitmap(wp->screen);
  free(wp);
 }
}

canonical_original_code:
void eof_window_destroy(struct EOF_WINDOW *wp)
{
  eof_log("eof_window_destroy() entered", 1);
 if(wp)
 {
  destroy_bitmap(wp->screen);
  free(wp);
 }
}

variable_types: struct EOF_WINDOW { int x; int w; struct BITMAP { int w; int clip; int cl; struct GFX_VTABLE { int color_depth; int mask_color; void *unwrite_bank; void (*set_clip)(struct BITMAP *bmp); void (*acquire)(struct BITMAP *bmp); void (*release)(struct BITMAP *bmp); struct BITMAP *(*create_sub_bitmap)(struct BITMAP *parent, int x, int y, int width, int height); void (*created_sub_bitmap)(struct BITMAP *bmp, struct BITMAP *parent); int (*getpixel)(struct BITMAP *bmp, int x, int y); void (*putpixel)(struct BITMAP *bmp, int x, int y, int color); void (*vline)(struct BITMAP *bmp, int x, int y_1, int y2, int color); void (*hline)(struct BITMAP *bmp, int x1, int y, int x2, int color); void (*hfill)(struct BITMAP *bmp, int x1, int y, int x2, int color); void (*line)(struct BITMAP *bmp, int x1, int y_1, int x2, int y2, int color); void (*fastline)(struct BITMAP *bmp, int x1, int y_1, int x2, int y2, int color); void (*rectfill)(struct BITMAP *bmp, int x1, int y_1, int x2, int y2, int color); void (*triangle)(struct BITMAP *bmp, int x1, int y_1, int x2, int y2, int x3, int y3, int color); void (*draw_sprite)(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y); void (*draw_256_sprite)(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y); void (*draw_sprite_v_flip)(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y); void (*draw_sprite_h_flip)(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y); void (*draw_sprite_vh_flip)(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y); void (*draw_trans_sprite)(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y); void (*draw_trans_rgba_sprite)(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y); void (*draw_lit_sprite)(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y, int color); void (*draw_rle_sprite)(struct BITMAP *bmp, struct RLE_SPRITE { int w; int color_depth; int size; char dat[]; } *sprite, int x, int y); void (*draw_trans_rle_sprite)(struct BITMAP *bmp, struct RLE_SPRITE *sprite, int x, int y); void (*draw_trans_rgba_rle_sprite)(struct BITMAP *bmp, struct RLE_SPRITE *sprite, int x, int y); void (*draw_lit_rle_sprite)(struct BITMAP *bmp, struct RLE_SPRITE *sprite, int x, int y, int color); void (*draw_character)(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y, int color, int bg); void (*draw_glyph)(struct BITMAP *bmp, struct FONT_GLYPH { short w; unsigned char dat[]; } *glyph, int x, int y, int color, int bg); void (*blit_from_memory)(struct BITMAP *source, struct BITMAP *dest, int source_x, int source_y, int dest_x, int dest_y, int width, int height); void (*blit_to_memory)(struct BITMAP *source, struct BITMAP *dest, int source_x, int source_y, int dest_x, int dest_y, int width, int height); void (*blit_from_system)(struct BITMAP *source, struct BITMAP *dest, int source_x, int source_y, int dest_x, int dest_y, int width, int height); void (*blit_to_system)(struct BITMAP *source, struct BITMAP *dest, int source_x, int source_y, int dest_x, int dest_y, int width, int height); void (*blit_to_self)(struct BITMAP *source, struct BITMAP *dest, int source_x, int source_y, int dest_x, int dest_y, int width, int height); void (*blit_to_self_forward)(struct BITMAP *source, struct BITMAP *dest, int source_x, int source_y, int dest_x, int dest_y, int width, int height); void (*blit_to_self_backward)(struct BITMAP *source, struct BITMAP *dest, int source_x, int source_y, int dest_x, int dest_y, int width, int height); void (*blit_between_formats)(struct BITMAP *source, struct BITMAP *dest, int source_x, int source_y, int dest_x, int dest_y, int width, int height); void (*masked_blit)(struct BITMAP *source, struct BITMAP *dest, int source_x, int source_y, int dest_x, int dest_y, int width, int height); void (*clear_to_color)(struct BITMAP *bitmap, int color); void (*pivot_scaled_sprite_flip)(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y, int cx, int cy, int angle, int scale, int v_flip); void (*do_stretch_blit)(struct BITMAP *source, struct BITMAP *dest, int source_x, int source_y, int source_width, int source_height, int dest_x, int dest_y, int dest_width, int dest_height, int masked); void (*draw_gouraud_sprite)(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y, int c1, int c2, int c3, int c4); void (*draw_sprite_end)(); void (*blit_end)(); void (*polygon)(struct BITMAP *bmp, int vertices, int *points, int color); void (*rect)(struct BITMAP *bmp, int x1, int y_1, int x2, int y2, int color); void (*circle)(struct BITMAP *bmp, int x, int y, int radius, int color); void (*circlefill)(struct BITMAP *bmp, int x, int y, int radius, int color); void (*ellipse)(struct BITMAP *bmp, int x, int y, int rx, int ry, int color); void (*ellipsefill)(struct BITMAP *bmp, int x, int y, int rx, int ry, int color); void (*arc)(struct BITMAP *bmp, int x, int y, int ang1, int ang2, int r, int color); void (*spline)(struct BITMAP *bmp, int points[8], int color); void (*floodfill)(struct BITMAP *bmp, int x, int y, int color); void (*polygon3d)(struct BITMAP *bmp, int type, struct BITMAP *texture, int vc, struct V3D { int x; int u; int c; } *vtx[]); void (*polygon3d_f)(struct BITMAP *bmp, int type, struct BITMAP *texture, int vc, struct V3D_f { float x; float u; int c; } *vtx[]); void (*triangle3d)(struct BITMAP *bmp, int type, struct BITMAP *texture, struct V3D *v1, struct V3D *v2, struct V3D *v3); void (*triangle3d_f)(struct BITMAP *bmp, int type, struct BITMAP *texture, struct V3D_f *v1, struct V3D_f *v2, struct V3D_f *v3); void (*quad3d)(struct BITMAP *bmp, int type, struct BITMAP *texture, struct V3D *v1, struct V3D *v2, struct V3D *v3, struct V3D *v4); void (*quad3d_f)(struct BITMAP *bmp, int type, struct BITMAP *texture, struct V3D_f *v1, struct V3D_f *v2, struct V3D_f *v3, struct V3D_f *v4); void (*draw_sprite_ex)(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y, int mode, int flip); } *vtable; void *write_bank; void *read_bank; void *dat; unsigned long id; void *extra; int x_ofs; int y_ofs; int seg; unsigned char *line[]; } *screen; } *

user_defined_types: struct EOF_WINDOW { int x; int w; struct BITMAP *screen; }

user_defined_types: struct BITMAP { int w; int clip; int cl; struct GFX_VTABLE *vtable; void *write_bank; void *read_bank; void *dat; unsigned long id; void *extra; int x_ofs; int y_ofs; int seg; unsigned char *line[]; }

user_defined_types: struct GFX_VTABLE { int color_depth; int mask_color; void *unwrite_bank; void (*set_clip)(struct BITMAP *bmp); void (*acquire)(struct BITMAP *bmp); void (*release)(struct BITMAP *bmp); struct BITMAP *(*create_sub_bitmap)(struct BITMAP *parent, int x, int y, int width, int height); void (*created_sub_bitmap)(struct BITMAP *bmp, struct BITMAP *parent); int (*getpixel)(struct BITMAP *bmp, int x, int y); void (*putpixel)(struct BITMAP *bmp, int x, int y, int color); void (*vline)(struct BITMAP *bmp, int x, int y_1, int y2, int color); void (*hline)(struct BITMAP *bmp, int x1, int y, int x2, int color); void (*hfill)(struct BITMAP *bmp, int x1, int y, int x2, int color); void (*line)(struct BITMAP *bmp, int x1, int y_1, int x2, int y2, int color); void (*fastline)(struct BITMAP *bmp, int x1, int y_1, int x2, int y2, int color); void (*rectfill)(struct BITMAP *bmp, int x1, int y_1, int x2, int y2, int color); void (*triangle)(struct BITMAP *bmp, int x1, int y_1, int x2, int y2, int x3, int y3, int color); void (*draw_sprite)(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y); void (*draw_256_sprite)(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y); void (*draw_sprite_v_flip)(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y); void (*draw_sprite_h_flip)(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y); void (*draw_sprite_vh_flip)(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y); void (*draw_trans_sprite)(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y); void (*draw_trans_rgba_sprite)(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y); void (*draw_lit_sprite)(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y, int color); void (*draw_rle_sprite)(struct BITMAP *bmp, struct RLE_SPRITE *sprite, int x, int y); void (*draw_trans_rle_sprite)(struct BITMAP *bmp, struct RLE_SPRITE *sprite, int x, int y); void (*draw_trans_rgba_rle_sprite)(struct BITMAP *bmp, struct RLE_SPRITE *sprite, int x, int y); void (*draw_lit_rle_sprite)(struct BITMAP *bmp, struct RLE_SPRITE *sprite, int x, int y, int color); void (*draw_character)(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y, int color, int bg); void (*draw_glyph)(struct BITMAP *bmp, struct FONT_GLYPH *glyph, int x, int y, int color, int bg); void (*blit_from_memory)(struct BITMAP *source, struct BITMAP *dest, int source_x, int source_y, int dest_x, int dest_y, int width, int height); void (*blit_to_memory)(struct BITMAP *source, struct BITMAP *dest, int source_x, int source_y, int dest_x, int dest_y, int width, int height); void (*blit_from_system)(struct BITMAP *source, struct BITMAP *dest, int source_x, int source_y, int dest_x, int dest_y, int width, int height); void (*blit_to_system)(struct BITMAP *source, struct BITMAP *dest, int source_x, int source_y, int dest_x, int dest_y, int width, int height); void (*blit_to_self)(struct BITMAP *source, struct BITMAP *dest, int source_x, int source_y, int dest_x, int dest_y, int width, int height); void (*blit_to_self_forward)(struct BITMAP *source, struct BITMAP *dest, int source_x, int source_y, int dest_x, int dest_y, int width, int height); void (*blit_to_self_backward)(struct BITMAP *source, struct BITMAP *dest, int source_x, int source_y, int dest_x, int dest_y, int width, int height); void (*blit_between_formats)(struct BITMAP *source, struct BITMAP *dest, int source_x, int source_y, int dest_x, int dest_y, int width, int height); void (*masked_blit)(struct BITMAP *source, struct BITMAP *dest, int source_x, int source_y, int dest_x, int dest_y, int width, int height); void (*clear_to_color)(struct BITMAP *bitmap, int color); void (*pivot_scaled_sprite_flip)(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y, int cx, int cy, int angle, int scale, int v_flip); void (*do_stretch_blit)(struct BITMAP *source, struct BITMAP *dest, int source_x, int source_y, int source_width, int source_height, int dest_x, int dest_y, int dest_width, int dest_height, int masked); void (*draw_gouraud_sprite)(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y, int c1, int c2, int c3, int c4); void (*draw_sprite_end)(); void (*blit_end)(); void (*polygon)(struct BITMAP *bmp, int vertices, int *points, int color); void (*rect)(struct BITMAP *bmp, int x1, int y_1, int x2, int y2, int color); void (*circle)(struct BITMAP *bmp, int x, int y, int radius, int color); void (*circlefill)(struct BITMAP *bmp, int x, int y, int radius, int color); void (*ellipse)(struct BITMAP *bmp, int x, int y, int rx, int ry, int color); void (*ellipsefill)(struct BITMAP *bmp, int x, int y, int rx, int ry, int color); void (*arc)(struct BITMAP *bmp, int x, int y, int ang1, int ang2, int r, int color); void (*spline)(struct BITMAP *bmp, int points[8], int color); void (*floodfill)(struct BITMAP *bmp, int x, int y, int color); void (*polygon3d)(struct BITMAP *bmp, int type, struct BITMAP *texture, int vc, struct V3D *vtx[]); void (*polygon3d_f)(struct BITMAP *bmp, int type, struct BITMAP *texture, int vc, struct V3D_f *vtx[]); void (*triangle3d)(struct BITMAP *bmp, int type, struct BITMAP *texture, struct V3D *v1, struct V3D *v2, struct V3D *v3); void (*triangle3d_f)(struct BITMAP *bmp, int type, struct BITMAP *texture, struct V3D_f *v1, struct V3D_f *v2, struct V3D_f *v3); void (*quad3d)(struct BITMAP *bmp, int type, struct BITMAP *texture, struct V3D *v1, struct V3D *v2, struct V3D *v3, struct V3D *v4); void (*quad3d_f)(struct BITMAP *bmp, int type, struct BITMAP *texture, struct V3D_f *v1, struct V3D_f *v2, struct V3D_f *v3, struct V3D_f *v4); void (*draw_sprite_ex)(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y, int mode, int flip); }


decompiled_code:
__int64 eof_menu_help_keys()
{
void *v0; // rax

v0 = (void *)eof_buffer_file("keys.txt", 1LL);
eof_help_text = v0;
if ( v0 )
{
*(&eof_help_dialog + 24) = v0;
eof_cursor_visible = 0;
eof_pen_visible = 0;
eof_render();
eof_color_dialog(&eof_help_dialog, gui_fg_color, gui_bg_color);
centre_dialog(&eof_help_dialog);
eof_popup_dialog(&eof_help_dialog, 0LL);
eof_show_mouse(0LL);
eof_cursor_visible = 1;
eof_pen_visible = 1;
free(eof_help_text);
eof_help_text = 0LL;
}
else
{
allegro_message("Error reading keys.txt");
}
return 1LL;
}

canonical_decompiled_code:
__int64 func0()
{
void *v0; // rax

v0 = (void *)eof_buffer_file("keys.txt", 1LL);
eof_help_text = v0;
if ( v0 )
{
*(&eof_help_dialog + 24) = v0;
eof_cursor_visible = 0;
eof_pen_visible = 0;
eof_render();
eof_color_dialog(&eof_help_dialog, gui_fg_color, gui_bg_color);
centre_dialog(&eof_help_dialog);
eof_popup_dialog(&eof_help_dialog, 0LL);
eof_show_mouse(0LL);
eof_cursor_visible = 1;
eof_pen_visible = 1;
free(eof_help_text);
eof_help_text = 0LL;
}
else
{
allegro_message("Error reading keys.txt");
}
return 1LL;
}

original_code:
int eof_menu_help_keys(void)
{
 eof_help_text = eof_buffer_file("keys.txt", 1);
 if(eof_help_text == ((void *)0))
 {
  allegro_message("Error reading keys.txt");
  return 1;
 }
 eof_help_dialog[2].dp = eof_help_text;
 eof_cursor_visible = 0;
 eof_pen_visible = 0;
 eof_render();
 eof_color_dialog(eof_help_dialog, gui_fg_color, gui_bg_color);
 centre_dialog(eof_help_dialog);
 if(eof_popup_dialog(eof_help_dialog, 0) == 1)
 {
 }
 eof_show_mouse(((void *)0));
 eof_cursor_visible = 1;
 eof_pen_visible = 1;
 free(eof_help_text);
 eof_help_text = ((void *)0);
 return 1;
}

canonical_original_code:
int eof_menu_help_keys()
{
 eof_help_text = eof_buffer_file("keys.txt", 1);
 if(eof_help_text == ((void *)0))
 {
  allegro_message("Error reading keys.txt");
  return 1;
 }
 eof_help_dialog[2].dp = eof_help_text;
 eof_cursor_visible = 0;
 eof_pen_visible = 0;
 eof_render();
 eof_color_dialog(eof_help_dialog, gui_fg_color, gui_bg_color);
 centre_dialog(eof_help_dialog);
 if(eof_popup_dialog(eof_help_dialog, 0) == 1)
 {
 }
 eof_show_mouse(((void *)0));
 eof_cursor_visible = 1;
 eof_pen_visible = 1;
 free(eof_help_text);
 eof_help_text = ((void *)0);
 return 1;
}


decompiled_code:
__int64 eof_menu_help_manual()
{
eof_system("xdg-open manual/index.htm");
return 1LL;
}

canonical_decompiled_code:
__int64 func1()
{
eof_system("xdg-open manual/index.htm");
return 1LL;
}

original_code:
int eof_menu_help_manual(void)
{
   (void) eof_system("xdg-open manual/index.htm");
 return 1;
}

canonical_original_code:
int eof_menu_help_manual()
{
   (void) eof_system("xdg-open manual/index.htm");
 return 1;
}


decompiled_code:
__int64 eof_menu_help_tutorial()
{
eof_system("xdg-open tutorial/index.htm");
return 1LL;
}

canonical_decompiled_code:
__int64 func2()
{
eof_system("xdg-open tutorial/index.htm");
return 1LL;
}

original_code:
int eof_menu_help_tutorial(void)
{
   (void) eof_system("xdg-open tutorial/index.htm");
 return 1;
}

canonical_original_code:
int eof_menu_help_tutorial()
{
   (void) eof_system("xdg-open tutorial/index.htm");
 return 1;
}


decompiled_code:
__int64 eof_menu_help_vocals_tutorial()
{
eof_system("xdg-open vocaltutorial/index.htm");
return 1LL;
}

canonical_decompiled_code:
__int64 func3()
{
eof_system("xdg-open vocaltutorial/index.htm");
return 1LL;
}

original_code:
int eof_menu_help_vocals_tutorial(void)
{
   (void) eof_system("xdg-open vocaltutorial/index.htm");
 return 1;
}

canonical_original_code:
int eof_menu_help_vocals_tutorial()
{
   (void) eof_system("xdg-open vocaltutorial/index.htm");
 return 1;
}


decompiled_code:
__int64 eof_menu_help_pro_guitar_tutorial()
{
eof_system("xdg-open proguitartutorial/index.htm");
return 1LL;
}

canonical_decompiled_code:
__int64 func4()
{
eof_system("xdg-open proguitartutorial/index.htm");
return 1LL;
}

original_code:
int eof_menu_help_pro_guitar_tutorial(void)
{
   (void) eof_system("xdg-open proguitartutorial/index.htm");
 return 1;
}

canonical_original_code:
int eof_menu_help_pro_guitar_tutorial()
{
   (void) eof_system("xdg-open proguitartutorial/index.htm");
 return 1;
}


decompiled_code:
__int64 eof_menu_help_about()
{
eof_cursor_visible = 0;
eof_pen_visible = 0;
eof_render();
alert("EOF v1.8RC10", 0LL, "(c)2008-2010 T^3 Software.", "Okay", 0LL, 67LL, 0LL);
eof_clear_input();
eof_show_mouse(0LL);
eof_cursor_visible = 1;
eof_pen_visible = 1;
return 1LL;
}

canonical_decompiled_code:
__int64 func5()
{
eof_cursor_visible = 0;
eof_pen_visible = 0;
eof_render();
alert("EOF v1.8RC10", 0LL, "(c)2008-2010 T^3 Software.", "Okay", 0LL, 67LL, 0LL);
eof_clear_input();
eof_show_mouse(0LL);
eof_cursor_visible = 1;
eof_pen_visible = 1;
return 1LL;
}

original_code:
int eof_menu_help_about(void)
{
 eof_cursor_visible = 0;
 eof_pen_visible = 0;
 eof_render();
 (void) alert("EOF v1.8RC10", ((void *)0), "(c)2008-2010 T^3 Software.", "Okay", ((void *)0), __allegro_KEY_ENTER, 0);
 eof_clear_input();
 eof_show_mouse(((void *)0));
 eof_cursor_visible = 1;
 eof_pen_visible = 1;
 return 1;
}

canonical_original_code:
int eof_menu_help_about()
{
 eof_cursor_visible = 0;
 eof_pen_visible = 0;
 eof_render();
 (void) alert("EOF v1.8RC10", ((void *)0), "(c)2008-2010 T^3 Software.", "Okay", ((void *)0), __allegro_KEY_ENTER, 0);
 eof_clear_input();
 eof_show_mouse(((void *)0));
 eof_cursor_visible = 1;
 eof_pen_visible = 1;
 return 1;
}


decompiled_code:
void aalg_init()
{
gui_menu_draw_menu = 0LL;
gui_menu_draw_menu_item = 0LL;
qword_168 = (__int64)&gui_fg_color;
qword_170 = (__int64)&gui_bg_color;
qword_178 = (__int64)&gui_mg_color;
}

canonical_decompiled_code:
void func0()
{
gui_menu_draw_menu = 0LL;
gui_menu_draw_menu_item = 0LL;
qword_168 = (__int64)&gui_fg_color;
qword_170 = (__int64)&gui_bg_color;
qword_178 = (__int64)&gui_mg_color;
}

original_code:
void aalg_init(void)
{
    gui_menu_draw_menu = ((void *)0);
    gui_menu_draw_menu_item = ((void *)0);
    the_theme.fg_color = &gui_fg_color;
    the_theme.bg_color = &gui_bg_color;
    the_theme.mg_color = &gui_mg_color;
}

canonical_original_code:
void aalg_init()
{
    gui_menu_draw_menu = ((void *)0);
    gui_menu_draw_menu_item = ((void *)0);
    the_theme.fg_color = &gui_fg_color;
    the_theme.bg_color = &gui_bg_color;
    the_theme.mg_color = &gui_mg_color;
}


decompiled_code:
void aalg_shutdown()
{
;
}

canonical_decompiled_code:
void func1()
{
;
}

original_code:
void aalg_shutdown(void)
{
}

canonical_original_code:
void aalg_shutdown()
{
}


decompiled_code:
__int64 __fastcall d_aalg_window_proc(int a1, __int64 a2)
{
_DWORD *v3; // rbp
unsigned int v4; // er12
unsigned int v5; // er13
unsigned int v6; // er14
unsigned int v7; // er15

if ( a1 != 3 )
return 0LL;
d_shadow_box_proc();
if ( *(_QWORD *)(a2 + 48) )
{
v3 = (_DWORD *)gui_get_screen();
v4 = v3[3];
v5 = v3[5];
v6 = v3[4];
v7 = v3[6];
set_clip_rect(
v3,
*(unsigned int *)(a2 + 8),
*(unsigned int *)(a2 + 12),
(unsigned int)(*(_DWORD *)(a2 + 16) + *(_DWORD *)(a2 + 8) - 1),
(unsigned int)(*(_DWORD *)(a2 + 20) + *(_DWORD *)(a2 + 12) - 1));
textout_ex(
v3,
font,
*(_QWORD *)(a2 + 48),
(unsigned int)(*(_DWORD *)(a2 + 8) + 6),
(unsigned int)(*(_DWORD *)(a2 + 12) + 6),
gui_fg_color,
gui_bg_color);
set_clip_rect(v3, v4, v5, v6, v7);
}
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func3(int a1, __int64 a2)
{
_DWORD *v3; // rbp
unsigned int v4; // er12
unsigned int v5; // er13
unsigned int v6; // er14
unsigned int v7; // er15

if ( a1 != 3 )
return 0LL;
d_shadow_box_proc();
if ( *(_QWORD *)(a2 + 48) )
{
v3 = (_DWORD *)gui_get_screen();
v4 = v3[3];
v5 = v3[5];
v6 = v3[4];
v7 = v3[6];
set_clip_rect(
v3,
*(unsigned int *)(a2 + 8),
*(unsigned int *)(a2 + 12),
(unsigned int)(*(_DWORD *)(a2 + 16) + *(_DWORD *)(a2 + 8) - 1),
(unsigned int)(*(_DWORD *)(a2 + 20) + *(_DWORD *)(a2 + 12) - 1));
textout_ex(
v3,
font,
*(_QWORD *)(a2 + 48),
(unsigned int)(*(_DWORD *)(a2 + 8) + 6),
(unsigned int)(*(_DWORD *)(a2 + 12) + 6),
gui_fg_color,
gui_bg_color);
set_clip_rect(v3, v4, v5, v6, v7);
}
return 0LL;
}

original_code:
int d_aalg_window_proc(int msg, DIALOG *d, int c)
{
   (void)c;
   if (msg == 3) {
      d_shadow_box_proc(msg, d, c);
      if (d->dp) {
  BITMAP *bmp = gui_get_screen();
  int cl = bmp->cl, ct = bmp->ct, cr = bmp->cr, cb = bmp->cb;
  set_clip_rect(bmp, d->x, d->y, d->x+d->w-1, d->y+d->h-1);
  textout_ex(bmp, font, (char *)d->dp, d->x+6, d->y+6, gui_fg_color, gui_bg_color);
  set_clip_rect(bmp, cl, ct, cr, cb);
      }
   }
   return 0;
}

canonical_original_code:
int d_aalg_window_proc(int msg, struct DIALOG *d, int c)
{
   (void)c;
   if (msg == 3) {
      d_shadow_box_proc(msg, d, c);
      if (d->dp) {
  struct BITMAP *bmp = gui_get_screen();
  int cl = bmp->cl; int ct = bmp->ct; int cr = bmp->cr; int cb = bmp->cb;
  set_clip_rect(bmp, d->x, d->y, d->x+d->w-1, d->y+d->h-1);
  textout_ex(bmp, font, (char *)d->dp, d->x+6, d->y+6, gui_fg_color, gui_bg_color);
  set_clip_rect(bmp, cl, ct, cr, cb);
      }
   }
   return 0;
}

variable_types: struct BITMAP { int w; int clip; int cl; struct GFX_VTABLE { int color_depth; int mask_color; void *unwrite_bank; void (*set_clip)(struct BITMAP *bmp); void (*acquire)(struct BITMAP *bmp); void (*release)(struct BITMAP *bmp); struct BITMAP *(*create_sub_bitmap)(struct BITMAP *parent, int x, int y, int width, int height); void (*created_sub_bitmap)(struct BITMAP *bmp, struct BITMAP *parent); int (*getpixel)(struct BITMAP *bmp, int x, int y); void (*putpixel)(struct BITMAP *bmp, int x, int y, int color); void (*vline)(struct BITMAP *bmp, int x, int y_1, int y2, int color); void (*hline)(struct BITMAP *bmp, int x1, int y, int x2, int color); void (*hfill)(struct BITMAP *bmp, int x1, int y, int x2, int color); void (*line)(struct BITMAP *bmp, int x1, int y_1, int x2, int y2, int color); void (*fastline)(struct BITMAP *bmp, int x1, int y_1, int x2, int y2, int color); void (*rectfill)(struct BITMAP *bmp, int x1, int y_1, int x2, int y2, int color); void (*triangle)(struct BITMAP *bmp, int x1, int y_1, int x2, int y2, int x3, int y3, int color); void (*draw_sprite)(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y); void (*draw_256_sprite)(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y); void (*draw_sprite_v_flip)(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y); void (*draw_sprite_h_flip)(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y); void (*draw_sprite_vh_flip)(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y); void (*draw_trans_sprite)(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y); void (*draw_trans_rgba_sprite)(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y); void (*draw_lit_sprite)(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y, int color); void (*draw_rle_sprite)(struct BITMAP *bmp, struct RLE_SPRITE { int w; int color_depth; int size; char dat[]; } *sprite, int x, int y); void (*draw_trans_rle_sprite)(struct BITMAP *bmp, struct RLE_SPRITE *sprite, int x, int y); void (*draw_trans_rgba_rle_sprite)(struct BITMAP *bmp, struct RLE_SPRITE *sprite, int x, int y); void (*draw_lit_rle_sprite)(struct BITMAP *bmp, struct RLE_SPRITE *sprite, int x, int y, int color); void (*draw_character)(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y, int color, int bg); void (*draw_glyph)(struct BITMAP *bmp, struct FONT_GLYPH { short w; unsigned char dat[]; } *glyph, int x, int y, int color, int bg); void (*blit_from_memory)(struct BITMAP *source, struct BITMAP *dest, int source_x, int source_y, int dest_x, int dest_y, int width, int height); void (*blit_to_memory)(struct BITMAP *source, struct BITMAP *dest, int source_x, int source_y, int dest_x, int dest_y, int width, int height); void (*blit_from_system)(struct BITMAP *source, struct BITMAP *dest, int source_x, int source_y, int dest_x, int dest_y, int width, int height); void (*blit_to_system)(struct BITMAP *source, struct BITMAP *dest, int source_x, int source_y, int dest_x, int dest_y, int width, int height); void (*blit_to_self)(struct BITMAP *source, struct BITMAP *dest, int source_x, int source_y, int dest_x, int dest_y, int width, int height); void (*blit_to_self_forward)(struct BITMAP *source, struct BITMAP *dest, int source_x, int source_y, int dest_x, int dest_y, int width, int height); void (*blit_to_self_backward)(struct BITMAP *source, struct BITMAP *dest, int source_x, int source_y, int dest_x, int dest_y, int width, int height); void (*blit_between_formats)(struct BITMAP *source, struct BITMAP *dest, int source_x, int source_y, int dest_x, int dest_y, int width, int height); void (*masked_blit)(struct BITMAP *source, struct BITMAP *dest, int source_x, int source_y, int dest_x, int dest_y, int width, int height); void (*clear_to_color)(struct BITMAP *bitmap, int color); void (*pivot_scaled_sprite_flip)(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y, int cx, int cy, int angle, int scale, int v_flip); void (*do_stretch_blit)(struct BITMAP *source, struct BITMAP *dest, int source_x, int source_y, int source_width, int source_height, int dest_x, int dest_y, int dest_width, int dest_height, int masked); void (*draw_gouraud_sprite)(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y, int c1, int c2, int c3, int c4); void (*draw_sprite_end)(); void (*blit_end)(); void (*polygon)(struct BITMAP *bmp, int vertices, int *points, int color); void (*rect)(struct BITMAP *bmp, int x1, int y_1, int x2, int y2, int color); void (*circle)(struct BITMAP *bmp, int x, int y, int radius, int color); void (*circlefill)(struct BITMAP *bmp, int x, int y, int radius, int color); void (*ellipse)(struct BITMAP *bmp, int x, int y, int rx, int ry, int color); void (*ellipsefill)(struct BITMAP *bmp, int x, int y, int rx, int ry, int color); void (*arc)(struct BITMAP *bmp, int x, int y, int ang1, int ang2, int r, int color); void (*spline)(struct BITMAP *bmp, int points[8], int color); void (*floodfill)(struct BITMAP *bmp, int x, int y, int color); void (*polygon3d)(struct BITMAP *bmp, int type, struct BITMAP *texture, int vc, struct V3D { int x; int u; int c; } *vtx[]); void (*polygon3d_f)(struct BITMAP *bmp, int type, struct BITMAP *texture, int vc, struct V3D_f { float x; float u; int c; } *vtx[]); void (*triangle3d)(struct BITMAP *bmp, int type, struct BITMAP *texture, struct V3D *v1, struct V3D *v2, struct V3D *v3); void (*triangle3d_f)(struct BITMAP *bmp, int type, struct BITMAP *texture, struct V3D_f *v1, struct V3D_f *v2, struct V3D_f *v3); void (*quad3d)(struct BITMAP *bmp, int type, struct BITMAP *texture, struct V3D *v1, struct V3D *v2, struct V3D *v3, struct V3D *v4); void (*quad3d_f)(struct BITMAP *bmp, int type, struct BITMAP *texture, struct V3D_f *v1, struct V3D_f *v2, struct V3D_f *v3, struct V3D_f *v4); void (*draw_sprite_ex)(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y, int mode, int flip); } *vtable; void *write_bank; void *read_bank; void *dat; unsigned long id; void *extra; int x_ofs; int y_ofs; int seg; unsigned char *line[]; } *

variable_types: cl int

variable_types: ct int

variable_types: cr int

variable_types: cb int

user_defined_types: struct DIALOG { int (*proc)(int msg, struct DIALOG *d, int c); int x; int fg; int key; int flags; int d1; void *dp; }


decompiled_code:
__int64 eof_prepare_menus()
{
eof_log("eof_prepare_menus() entered", 2LL);
eof_prepare_main_menu();
eof_prepare_beat_menu();
eof_prepare_file_menu();
eof_prepare_edit_menu();
eof_prepare_song_menu();
eof_prepare_track_menu();
eof_prepare_note_menu();
return eof_prepare_context_menu();
}

canonical_decompiled_code:
__int64 func0()
{
eof_log("eof_prepare_menus() entered", 2LL);
eof_prepare_main_menu();
eof_prepare_beat_menu();
eof_prepare_file_menu();
eof_prepare_edit_menu();
eof_prepare_song_menu();
eof_prepare_track_menu();
eof_prepare_note_menu();
return eof_prepare_context_menu();
}

original_code:
void eof_prepare_menus(void)
{
 eof_log("eof_prepare_menus() entered", 2);
 eof_prepare_main_menu();
 eof_prepare_beat_menu();
 eof_prepare_file_menu();
 eof_prepare_edit_menu();
 eof_prepare_song_menu();
 eof_prepare_track_menu();
 eof_prepare_note_menu();
 eof_prepare_context_menu();
}

canonical_original_code:
void eof_prepare_menus()
{
 eof_log("eof_prepare_menus() entered", 2);
 eof_prepare_main_menu();
 eof_prepare_beat_menu();
 eof_prepare_file_menu();
 eof_prepare_edit_menu();
 eof_prepare_song_menu();
 eof_prepare_track_menu();
 eof_prepare_note_menu();
 eof_prepare_context_menu();
}


decompiled_code:
__int64 __fastcall eof_color_dialog(_QWORD *a1, int a2, int a3)
{
__int64 result; // rax
_QWORD *v5; // rdi

result = eof_log("eof_color_dialog() entered", 2LL);
if ( a1 && *a1 )
{
v5 = a1 + 9;
do
{
*((_DWORD *)v5 - 12) = a2;
*((_DWORD *)v5 - 11) = a3;
v5 += 9;
}
while ( *(v5 - 9) );
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(_QWORD *a1, int a2, int a3)
{
__int64 result; // rax
_QWORD *v5; // rdi

result = eof_log("eof_color_dialog() entered", 2LL);
if ( a1 && *a1 )
{
v5 = a1 + 9;
do
{
*((_DWORD *)v5 - 12) = a2;
*((_DWORD *)v5 - 11) = a3;
v5 += 9;
}
while ( *(v5 - 9) );
}
return result;
}

original_code:
void eof_color_dialog(DIALOG * dp, int fg, int bg)
{
 int i;
 eof_log("eof_color_dialog() entered", 2);
 if(dp == ((void *)0))
  return;
 for(i = 0; dp[i].proc != ((void *)0); i++)
 {
  dp[i].fg = fg;
  dp[i].bg = bg;
 }
}

canonical_original_code:
void eof_color_dialog(struct DIALOG *dp, int fg, int bg)
{
 int i;
 eof_log("eof_color_dialog() entered", 2);
 if(dp == ((void *)0))
  return;
 for(i = 0; dp[i].proc != ((void *)0); i++)
 {
  dp[i].fg = fg;
  dp[i].bg = bg;
 }
}

variable_types: fg int

variable_types: bg int


decompiled_code:
__int64 __fastcall eof_popup_dialog(void **a1, unsigned int a2)
{
__int64 v2; // rbp
int v3; // er13
int v4; // er12
__int64 v5; // r14
unsigned __int64 v6; // rax
unsigned int v7; // ebx

eof_log("eof_popup_dialog() entered", 2LL);
eof_prepare_menus();
v2 = init_dialog(a1, a2);
eof_show_mouse(screen);
clear_keybuf();
v3 = 0;
v4 = 0;
v5 = 397401LL;
while ( 1 )
{
eof_read_keyboard_input(0LL);
if ( eof_key_pressed )
{
if ( eof_key_code == 59 )
goto LABEL_25;
if ( eof_key_char )
{
simulate_ukeypress(eof_key_uchar);
}
else if ( eof_key_code )
{
simulate_ukeypress(0LL);
}
}
if ( !(unsigned int)update_dialog(v2) )
goto LABEL_25;
if ( *a1 == &d_agup_menu_proc )
break;
LABEL_5:
if ( a1 == eof_song_properties_dialog && (unsigned int)ustrlen(eof_song_properties_dialog[150]) != v4 )
{
object_message((unsigned int)((_DWORD)eof_song_properties_dialog + 1296), 3LL, 0LL);
v4 = ustrlen(eof_song_properties_dialog[168]);
}
if ( a1 == (void **)&eof_file_new_windows_dialog )
{
if ( (*((_BYTE *)&eof_file_new_windows_dialog + 252) & 2) != 0 && (int)ustrlen(&eof_etext4) <= 0 )
{
*((_DWORD *)&eof_file_new_windows_dialog + 99) = 32;
object_message((unsigned int)((_DWORD)&eof_file_new_windows_dialog + 360), 3LL, 0LL);
v3 = 1;
}
else
{
*((_DWORD *)&eof_file_new_windows_dialog + 99) = 1;
if ( v3 )
{
object_message((unsigned int)((_DWORD)&eof_file_new_windows_dialog + 360), 3LL, 0LL);
v3 = 0;
}
}
}
if ( eof_key_pressed )
eof_use_key();
Idle(10LL);
}
v6 = (unsigned int)(eof_key_char - 98);
if ( (unsigned int)v6 <= 0x12 && _bittest64(&v5, v6) )
{
eof_keyboard_shortcut = 1;
*(_DWORD *)(v2 + 8) = 0;
if ( (mouse_b & 1) == 0 )
goto LABEL_5;
}
else if ( (mouse_b & 1) == 0 )
{
if ( eof_keyboard_shortcut != 2 )
goto LABEL_23;
goto LABEL_19;
}
eof_keyboard_shortcut = 2;
LABEL_19:
if ( (mouse_b & 1) == 0 )
eof_keyboard_shortcut = 0;
LABEL_23:
if ( *(int *)(v2 + 8) >= 0 || eof_keyboard_shortcut | eof_key_shifts & 4 )
goto LABEL_5;
LABEL_25:
v7 = shutdown_dialog(v2);
eof_clear_input();
gametime_reset();
eof_show_mouse(0LL);
eof_keyboard_shortcut = 0;
return v7;
}

canonical_decompiled_code:
__int64 __fastcall func2(void **a1, unsigned int a2)
{
__int64 v2; // rbp
int v3; // er13
int v4; // er12
__int64 v5; // r14
unsigned __int64 v6; // rax
unsigned int v7; // ebx

eof_log("eof_popup_dialog() entered", 2LL);
func0();
v2 = init_dialog(a1, a2);
eof_show_mouse(screen);
clear_keybuf();
v3 = 0;
v4 = 0;
v5 = 397401LL;
while ( 1 )
{
eof_read_keyboard_input(0LL);
if ( eof_key_pressed )
{
if ( eof_key_code == 59 )
goto LABEL_25;
if ( eof_key_char )
{
simulate_ukeypress(eof_key_uchar);
}
else if ( eof_key_code )
{
simulate_ukeypress(0LL);
}
}
if ( !(unsigned int)update_dialog(v2) )
goto LABEL_25;
if ( *a1 == &d_agup_menu_proc )
break;
LABEL_5:
if ( a1 == eof_song_properties_dialog && (unsigned int)ustrlen(eof_song_properties_dialog[150]) != v4 )
{
object_message((unsigned int)((_DWORD)eof_song_properties_dialog + 1296), 3LL, 0LL);
v4 = ustrlen(eof_song_properties_dialog[168]);
}
if ( a1 == (void **)&eof_file_new_windows_dialog )
{
if ( (*((_BYTE *)&eof_file_new_windows_dialog + 252) & 2) != 0 && (int)ustrlen(&eof_etext4) <= 0 )
{
*((_DWORD *)&eof_file_new_windows_dialog + 99) = 32;
object_message((unsigned int)((_DWORD)&eof_file_new_windows_dialog + 360), 3LL, 0LL);
v3 = 1;
}
else
{
*((_DWORD *)&eof_file_new_windows_dialog + 99) = 1;
if ( v3 )
{
object_message((unsigned int)((_DWORD)&eof_file_new_windows_dialog + 360), 3LL, 0LL);
v3 = 0;
}
}
}
if ( eof_key_pressed )
eof_use_key();
Idle(10LL);
}
v6 = (unsigned int)(eof_key_char - 98);
if ( (unsigned int)v6 <= 0x12 && _bittest64(&v5, v6) )
{
eof_keyboard_shortcut = 1;
*(_DWORD *)(v2 + 8) = 0;
if ( (mouse_b & 1) == 0 )
goto LABEL_5;
}
else if ( (mouse_b & 1) == 0 )
{
if ( eof_keyboard_shortcut != 2 )
goto LABEL_23;
goto LABEL_19;
}
eof_keyboard_shortcut = 2;
LABEL_19:
if ( (mouse_b & 1) == 0 )
eof_keyboard_shortcut = 0;
LABEL_23:
if ( *(int *)(v2 + 8) >= 0 || eof_keyboard_shortcut | eof_key_shifts & 4 )
goto LABEL_5;
LABEL_25:
v7 = shutdown_dialog(v2);
eof_clear_input();
gametime_reset();
eof_show_mouse(0LL);
eof_keyboard_shortcut = 0;
return v7;
}

original_code:
int eof_popup_dialog(DIALOG * dp, int n)
{
 int ret;
 int oldlen = 0;
 int dflag = 0;
 DIALOG_PLAYER * player;
 eof_log("eof_popup_dialog() entered", 2);
 eof_prepare_menus();
 player = init_dialog(dp, n);
 eof_show_mouse(screen);
 clear_keybuf();
 while(1)
 {
  eof_read_keyboard_input(0);
  if(eof_key_pressed)
  {
   if(eof_key_code == __allegro_KEY_ESC)
   {
    break;
   }
   if(eof_key_char)
   {
    simulate_ukeypress(eof_key_uchar, eof_key_code);
   }
   else if(eof_key_code)
   {
    simulate_ukeypress(0, eof_key_code);
   }
  }
  if(!update_dialog(player))
  {
   break;
  }
  if(dp[0].proc == d_agup_menu_proc)
  {
   if(eof_key_char == 'f' || eof_key_char == 'e' || eof_key_char == 's' || eof_key_char == 't' || eof_key_char == 'n' || eof_key_char == 'b' || eof_key_char == 'h')
   {
    eof_keyboard_shortcut = 1;
    player->mouse_obj = 0;
   }
   if(mouse_b & 1)
   {
    eof_keyboard_shortcut = 2;
   }
   if((eof_keyboard_shortcut == 2) && !(mouse_b & 1))
   {
    eof_keyboard_shortcut = 0;
   }
   if(player->mouse_obj < 0)
   {
    if(!(eof_key_shifts & __allegro_KB_ALT_FLAG) && !eof_keyboard_shortcut)
    {
     break;
    }
   }
  }
  if(dp == eof_song_properties_dialog)
  {
   if(ustrlen(eof_song_properties_dialog[16].dp) != oldlen)
   {
    (void) object_message(&eof_song_properties_dialog[18], 3, 0);
    oldlen = ustrlen(eof_song_properties_dialog[18].dp);
   }
  }
  if(dp == eof_file_new_windows_dialog)
  {
   if((eof_file_new_windows_dialog[3].flags & 2) && (ustrlen(eof_etext4) <= 0))
   {
    eof_file_new_windows_dialog[5].flags = 32;
    (void) object_message(&eof_file_new_windows_dialog[5], 3, 0);
    dflag = 1;
   }
   else
   {
    eof_file_new_windows_dialog[5].flags = 1;
    if(dflag)
    {
     (void) object_message(&eof_file_new_windows_dialog[5], 3, 0);
     dflag = 0;
    }
   }
  }
  if(eof_key_pressed)
  {
   eof_use_key();
  }
  Idle(10);
 }
 ret = shutdown_dialog(player);
 eof_clear_input();
 gametime_reset();
 eof_show_mouse(((void *)0));
 eof_keyboard_shortcut = 0;
 return ret;
}

canonical_original_code:
int eof_popup_dialog(struct DIALOG *dp, int n)
{
 int ret;
 int oldlen = 0;
 int dflag = 0;
 struct DIALOG_PLAYER *player;
 eof_log("eof_popup_dialog() entered", 2);
 eof_prepare_menus();
 player = init_dialog(dp, n);
 eof_show_mouse(screen);
 clear_keybuf();
 while(1)
 {
  eof_read_keyboard_input(0);
  if(eof_key_pressed)
  {
   if(eof_key_code == __allegro_KEY_ESC)
   {
    break;
   }
   if(eof_key_char)
   {
    simulate_ukeypress(eof_key_uchar, eof_key_code);
   }
   else if(eof_key_code)
   {
    simulate_ukeypress(0, eof_key_code);
   }
  }
  if(!update_dialog(player))
  {
   break;
  }
  if(dp[0].proc == d_agup_menu_proc)
  {
   if(eof_key_char == 'f' || eof_key_char == 'e' || eof_key_char == 's' || eof_key_char == 't' || eof_key_char == 'n' || eof_key_char == 'b' || eof_key_char == 'h')
   {
    eof_keyboard_shortcut = 1;
    player->mouse_obj = 0;
   }
   if(mouse_b & 1)
   {
    eof_keyboard_shortcut = 2;
   }
   if((eof_keyboard_shortcut == 2) && !(mouse_b & 1))
   {
    eof_keyboard_shortcut = 0;
   }
   if(player->mouse_obj < 0)
   {
    if(!(eof_key_shifts & __allegro_KB_ALT_FLAG) && !eof_keyboard_shortcut)
    {
     break;
    }
   }
  }
  if(dp == eof_song_properties_dialog)
  {
   if(ustrlen(eof_song_properties_dialog[16].dp) != oldlen)
   {
    (void) object_message(&eof_song_properties_dialog[18], 3, 0);
    oldlen = ustrlen(eof_song_properties_dialog[18].dp);
   }
  }
  if(dp == eof_file_new_windows_dialog)
  {
   if((eof_file_new_windows_dialog[3].flags & 2) && (ustrlen(eof_etext4) <= 0))
   {
    eof_file_new_windows_dialog[5].flags = 32;
    (void) object_message(&eof_file_new_windows_dialog[5], 3, 0);
    dflag = 1;
   }
   else
   {
    eof_file_new_windows_dialog[5].flags = 1;
    if(dflag)
    {
     (void) object_message(&eof_file_new_windows_dialog[5], 3, 0);
     dflag = 0;
    }
   }
  }
  if(eof_key_pressed)
  {
   eof_use_key();
  }
  Idle(10);
 }
 ret = shutdown_dialog(player);
 eof_clear_input();
 gametime_reset();
 eof_show_mouse(((void *)0));
 eof_keyboard_shortcut = 0;
 return ret;
}

variable_types: n int

variable_types: ret int

variable_types: oldlen int

variable_types: dflag int

variable_types: struct DIALOG_PLAYER { int obj; int res; int mouse_obj; int focus_obj; int joy_on; int click_wait; int mouse_ox; int mouse_oz; int mouse_b; struct DIALOG { int (*proc)(int msg, struct DIALOG *d, int c); int x; int fg; int key; int flags; int d1; void *dp; } *dialog; } *

user_defined_types: struct DIALOG_PLAYER { int obj; int res; int mouse_obj; int focus_obj; int joy_on; int click_wait; int mouse_ox; int mouse_oz; int mouse_b; struct DIALOG *dialog; }