decompiled_code:
__int64 MUSIC_GetSongLength()
{
return MIDI_GetSongLength();
}

canonical_decompiled_code:
__int64 func20()
{
return MIDI_GetSongLength();
}

original_code:
void MUSIC_GetSongLength
   (
   songposition *pos
   )
   {
   MIDI_GetSongLength( pos );
   }

canonical_original_code:
void MUSIC_GetSongLength(struct songposition *pos)
   {
   MIDI_GetSongLength( pos );
   }

user_defined_types: struct songposition { unsigned long tickposition; unsigned long milliseconds; unsigned int measure; unsigned int beat; unsigned int tick; }


repo: TermiT/sw-redux

decompiled_code:
__int64 MUSIC_FadeVolume()
{
return 0LL;
}

canonical_decompiled_code:
__int64 func21()
{
return 0LL;
}

original_code:
int MUSIC_FadeVolume
   (
   int tovolume,
   int milliseconds
   )
   {
   return( MUSIC_Ok );
   }

canonical_original_code:
int MUSIC_FadeVolume(int tovolume, int milliseconds)
   {
   return( MUSIC_Ok );
   }

variable_types: tovolume int

variable_types: milliseconds int

return_type: int


decompiled_code:
__int64 MUSIC_FadeActive()
{
return 0LL;
}

canonical_decompiled_code:
__int64 func22()
{
return 0LL;
}

original_code:
int MUSIC_FadeActive
   (
   void
   )
   {
   return 0;
   }

canonical_original_code:
int MUSIC_FadeActive()
   {
   return 0;
   }


decompiled_code:
void MUSIC_StopFade()
{
;
}

canonical_decompiled_code:
void func23()
{
;
}

original_code:
void MUSIC_StopFade
   (
   void
   )
   {
   }

canonical_original_code:
void MUSIC_StopFade()
   {
   }

return_type: void


decompiled_code:
__int64 MUSIC_RerouteMidiChannel()
{
return MIDI_RerouteMidiChannel();
}

canonical_decompiled_code:
__int64 func24()
{
return MIDI_RerouteMidiChannel();
}

original_code:
void MUSIC_RerouteMidiChannel
   (
   int channel,
   int ( *function )( int event, int c1, int c2 )
   )
   {
   MIDI_RerouteMidiChannel( channel, function );
   }

canonical_original_code:
void MUSIC_RerouteMidiChannel(int channel, int (*function)(int event, int c1, int c2))
   {
   MIDI_RerouteMidiChannel( channel, function );
   }

variable_types: channel int

variable_types:
function
int (*)(int event, int c1, int c2)


decompiled_code:
void MUSIC_RegisterTimbreBank()
{
;
}

canonical_decompiled_code:
void func25()
{
;
}

original_code:
void MUSIC_RegisterTimbreBank
   (
   unsigned char *timbres
   )
   {
   }

canonical_original_code:
void MUSIC_RegisterTimbreBank(unsigned char *timbres)
   {
   }

variable_types:
timbres
unsigned char *


decompiled_code:
__int64 CD_GetError()
{
return (unsigned int)ErrorCode;
}

canonical_decompiled_code:
__int64 func0()
{
return (unsigned int)ErrorCode;
}

original_code:
int CD_GetError(void)
{
    return ErrorCode;
}

canonical_original_code:
int CD_GetError()
{
    return ErrorCode;
}


decompiled_code:
const char *__fastcall CD_ErrorString(int a1)
{
const char *result; // rax
unsigned int v2; // eax

if ( a1 == 1 )
return "Invalid or unsupported card.";
if ( a1 > 1 )
{
result = "Unknown error code.";
if ( a1 == 2 )
{
v2 = SoundDriver_CD_GetError();
result = (const char *)SoundDriver_CD_ErrorString(v2);
}
}
else if ( a1 == -1 )
{
result = (const char *)CD_ErrorString((unsigned int)ErrorCode);
}
else
{
result = "Unknown error code.";
if ( !a1 )
result = "No error.";
}
return result;
}

canonical_decompiled_code:
const char *__fastcall func1(int a1)
{
const char *result; // rax
unsigned int v2; // eax

if ( a1 == 1 )
return "Invalid or unsupported card.";
if ( a1 > 1 )
{
result = "Unknown error code.";
if ( a1 == 2 )
{
v2 = SoundDriver_CD_GetError();
result = (const char *)SoundDriver_CD_ErrorString(v2);
}
}
else if ( a1 == -1 )
{
result = (const char *)func1((unsigned int)ErrorCode);
}
else
{
result = "Unknown error code.";
if ( !a1 )
result = "No error.";
}
return result;
}

original_code:
const char * CD_ErrorString(int code)
{
    switch (code) {
        case CD_Error:
            return CD_ErrorString(ErrorCode);
        case CD_Ok:
            return "No error.";
        case CD_InvalidCard:
            return "Invalid or unsupported card.";
        case CD_DriverError:
            return SoundDriver_CD_ErrorString(SoundDriver_CD_GetError());
        default:
            return "Unknown error code.";
    }
}

canonical_original_code:
char *CD_ErrorString(int code)
{
    switch (code) {
        case CD_Error:
            return CD_ErrorString(ErrorCode);
        case CD_Ok:
            return "No error.";
        case CD_InvalidCard:
            return "Invalid or unsupported card.";
        case CD_DriverError:
            return SoundDriver_CD_ErrorString(SoundDriver_CD_GetError());
        default:
            return "Unknown error code.";
    }
}

variable_types: code int

return_type: char *


decompiled_code:
__int64 __fastcall CD_Init(unsigned int a1)
{
unsigned int v1; // ebx
__int64 result; // rax

if ( a1 == -2 )
{
v1 = 1;
}
else
{
v1 = a1;
if ( a1 > 6 )
{
ErrorCode = 1;
return 0xFFFFFFFFLL;
}
}
if ( !(unsigned int)SoundDriver_IsCDSupported(v1) )
v1 = 0;
ASS_CDSoundDriver = v1;
result = SoundDriver_CD_Init();
if ( (_DWORD)result )
{
ErrorCode = 2;
result = 0xFFFFFFFFLL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(unsigned int a1)
{
unsigned int v1; // ebx
__int64 result; // rax

if ( a1 == -2 )
{
v1 = 1;
}
else
{
v1 = a1;
if ( a1 > 6 )
{
ErrorCode = 1;
return 0xFFFFFFFFLL;
}
}
if ( !(unsigned int)SoundDriver_IsCDSupported(v1) )
v1 = 0;
ASS_CDSoundDriver = v1;
result = SoundDriver_CD_Init();
if ( (_DWORD)result )
{
ErrorCode = 2;
result = 0xFFFFFFFFLL;
}
return result;
}

original_code:
int CD_Init(int SoundCard)
{
    int err;
 if (SoundCard == ASS_AutoDetect) {
  SoundCard = ASS_SDL;
 }
 if (SoundCard < 0 || SoundCard >= ASS_NumSoundCards) {
  ErrorCode = CD_InvalidCard;
  return CD_Error;
 }
 if (SoundDriver_IsCDSupported(SoundCard) == 0) {
  SoundCard = ASS_NoSound;
 }
    ASS_CDSoundDriver = SoundCard;
    err = SoundDriver_CD_Init();
    if (err != CD_Ok) {
        ErrorCode = CD_DriverError;
        return CD_Error;
    }
    return CD_Ok;
}

variable_types: SoundCard int

variable_types: err int


decompiled_code:
__int64 CD_Shutdown()
{
return SoundDriver_CD_Shutdown();
}

canonical_decompiled_code:
__int64 func3()
{
return SoundDriver_CD_Shutdown();
}

original_code:
void CD_Shutdown(void)
{
    SoundDriver_CD_Shutdown();
}

canonical_original_code:
void CD_Shutdown()
{
    SoundDriver_CD_Shutdown();
}


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

result = SoundDriver_CD_Play();
if ( (_DWORD)result )
{
ErrorCode = result;
result = 0xFFFFFFFFLL;
}
return result;
}

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

result = SoundDriver_CD_Play();
if ( (_DWORD)result )
{
ErrorCode = result;
result = 0xFFFFFFFFLL;
}
return result;
}

original_code:
int CD_Play(int track, int loop)
{
    int err;
    err = SoundDriver_CD_Play(track, loop);
    if (err != CD_Ok) {
        ErrorCode = err;
        return CD_Error;
    }
    return CD_Ok;
}

variable_types: track int

variable_types: loop int


decompiled_code:
__int64 CD_Stop()
{
return SoundDriver_CD_Stop();
}

canonical_decompiled_code:
__int64 func5()
{
return SoundDriver_CD_Stop();
}

original_code:
void CD_Stop(void)
{
    SoundDriver_CD_Stop();
}

canonical_original_code:
void CD_Stop()
{
    SoundDriver_CD_Stop();
}


decompiled_code:
__int64 CD_Pause()
{
return SoundDriver_CD_Pause();
}

canonical_decompiled_code:
__int64 func6()
{
return SoundDriver_CD_Pause();
}

original_code:
void CD_Pause(int pauseon)
{
    SoundDriver_CD_Pause(pauseon);
}

variable_types: pauseon int


decompiled_code:
__int64 CD_IsPlaying()
{
return SoundDriver_CD_IsPlaying();
}

canonical_decompiled_code:
__int64 func7()
{
return SoundDriver_CD_IsPlaying();
}

original_code:
int CD_IsPlaying(void)
{
    return SoundDriver_CD_IsPlaying();
}

canonical_original_code:
int CD_IsPlaying()
{
    return SoundDriver_CD_IsPlaying();
}


decompiled_code:
__int64 CD_SetVolume()
{
return SoundDriver_CD_SetVolume();
}

canonical_decompiled_code:
__int64 func8()
{
return SoundDriver_CD_SetVolume();
}

original_code:
void CD_SetVolume(int volume)
{
    SoundDriver_CD_SetVolume(volume);
}

variable_types: volume int


decompiled_code:
__int64 NoSoundDrv_GetError()
{
return 0LL;
}

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

original_code:
int NoSoundDrv_GetError(void)
{
 return 0;
}

canonical_original_code:
int NoSoundDrv_GetError()
{
 return 0;
}


decompiled_code:
const char *NoSoundDrv_ErrorString()
{
return "No sound, Ok.";
}

canonical_decompiled_code:
const char *func1()
{
return "No sound, Ok.";
}

original_code:
const char *NoSoundDrv_ErrorString( int ErrorNumber )
{
 return "No sound, Ok.";
}

canonical_original_code:
char *NoSoundDrv_ErrorString(int ErrorNumber)
{
 return "No sound, Ok.";
}

variable_types: ErrorNumber int


decompiled_code:
__int64 NoSoundDrv_PCM_Init()
{
return 0LL;
}

canonical_decompiled_code:
__int64 func2()
{
return 0LL;
}

original_code:
int NoSoundDrv_PCM_Init(int * mixrate, int * numchannels, int * samplebits, void * initdata)
{
 return 0;
}

canonical_original_code:
int NoSoundDrv_PCM_Init(int *mixrate, int *numchannels, int *samplebits, void *initdata)
{
 return 0;
}

variable_types:
mixrate
int *

variable_types:
numchannels
int *

variable_types:
samplebits
int *

variable_types:
initdata
void *


decompiled_code:
void NoSoundDrv_PCM_Shutdown()
{
;
}

canonical_decompiled_code:
void func3()
{
;
}

original_code:
void NoSoundDrv_PCM_Shutdown(void)
{
}

canonical_original_code:
void NoSoundDrv_PCM_Shutdown()
{
}


decompiled_code:
__int64 NoSoundDrv_PCM_BeginPlayback()
{
return 0LL;
}

canonical_decompiled_code:
__int64 func4()
{
return 0LL;
}

original_code:
int NoSoundDrv_PCM_BeginPlayback(char *BufferStart, int BufferSize,
      int NumDivisions, void ( *CallBackFunc )( void ) )
{
 return 0;
}

canonical_original_code:
int NoSoundDrv_PCM_BeginPlayback(char *BufferStart, int BufferSize, int NumDivisions, void (*CallBackFunc)())
{
 return 0;
}

variable_types:
BufferStart
char *

variable_types: BufferSize int

variable_types: NumDivisions int

variable_types:
CallBackFunc
void (*)()


decompiled_code:
void NoSoundDrv_PCM_StopPlayback()
{
;
}

canonical_decompiled_code:
void func5()
{
;
}

original_code:
void NoSoundDrv_PCM_StopPlayback(void)
{
}

canonical_original_code:
void NoSoundDrv_PCM_StopPlayback()
{
}


decompiled_code:
void NoSoundDrv_PCM_Lock()
{
;
}

canonical_decompiled_code:
void func6()
{
;
}

original_code:
void NoSoundDrv_PCM_Lock(void)
{
}

canonical_original_code:
void NoSoundDrv_PCM_Lock()
{
}


decompiled_code:
void NoSoundDrv_PCM_Unlock()
{
;
}

canonical_decompiled_code:
void func7()
{
;
}

original_code:
void NoSoundDrv_PCM_Unlock(void)
{
}

canonical_original_code:
void NoSoundDrv_PCM_Unlock()
{
}


decompiled_code:
__int64 NoSoundDrv_CD_Init()
{
return 0LL;
}

canonical_decompiled_code:
__int64 func8()
{
return 0LL;
}

original_code:
int NoSoundDrv_CD_Init(void)
{
    return 0;
}

canonical_original_code:
int NoSoundDrv_CD_Init()
{
    return 0;
}


decompiled_code:
void NoSoundDrv_CD_Shutdown()
{
;
}

canonical_decompiled_code:
void func9()
{
;
}

original_code:
void NoSoundDrv_CD_Shutdown(void)
{
}

canonical_original_code:
void NoSoundDrv_CD_Shutdown()
{
}


decompiled_code:
__int64 NoSoundDrv_CD_Play()
{
return 0LL;
}

canonical_decompiled_code:
__int64 func10()
{
return 0LL;
}

original_code:
int NoSoundDrv_CD_Play(int track, int loop)
{
    return 0;
}


decompiled_code:
void NoSoundDrv_CD_Stop()
{
;
}

canonical_decompiled_code:
void func11()
{
;
}

original_code:
void NoSoundDrv_CD_Stop(void)
{
}

canonical_original_code:
void NoSoundDrv_CD_Stop()
{
}


decompiled_code:
void NoSoundDrv_CD_Pause()
{
;
}

canonical_decompiled_code:
void func12()
{
;
}

original_code:
void NoSoundDrv_CD_Pause(int pauseon)
{
}


decompiled_code:
__int64 NoSoundDrv_CD_IsPlaying()
{
return 0LL;
}

canonical_decompiled_code:
__int64 func13()
{
return 0LL;
}

original_code:
int NoSoundDrv_CD_IsPlaying(void)
{
    return 0;
}

canonical_original_code:
int NoSoundDrv_CD_IsPlaying()
{
    return 0;
}


decompiled_code:
void NoSoundDrv_CD_SetVolume()
{
;
}

canonical_decompiled_code:
void func14()
{
;
}

original_code:
void NoSoundDrv_CD_SetVolume(int volume)
{
}


decompiled_code:
__int64 __fastcall NoSoundDrv_MIDI_Init(_QWORD *a1)
{
__int64 result; // rax

*a1 = 0LL;
a1[11] = 0LL;
result = 0LL;
memset(
(void *)((unsigned __int64)(a1 + 1) & 0xFFFFFFFFFFFFFFF8LL),
0,
8LL * (((unsigned int)a1 - (((_DWORD)a1 + 8) & 0xFFFFFFF8) + 96) >> 3));
return result;
}

canonical_decompiled_code:
__int64 __fastcall func15(_QWORD *a1)
{
__int64 result; // rax

*a1 = 0LL;
a1[11] = 0LL;
result = 0LL;
memset(
(void *)((unsigned __int64)(a1 + 1) & 0xFFFFFFFFFFFFFFF8LL),
0,
8LL * (((unsigned int)a1 - (((_DWORD)a1 + 8) & 0xFFFFFFF8) + 96) >> 3));
return result;
}

original_code:
int NoSoundDrv_MIDI_Init(midifuncs *funcs)
{
    memset(funcs, 0, sizeof(midifuncs));
    return 0;
}

canonical_original_code:
int NoSoundDrv_MIDI_Init(struct midifuncs *funcs)
{
    memset(funcs, 0, sizeof(midifuncs));
    return 0;
}

variable_types: struct midifuncs { void (*NoteOff)(int channel, int key, int velocity); void (*NoteOn)(int channel, int key, int velocity); void (*PolyAftertouch)(int channel, int key, int pressure); void (*ControlChange)(int channel, int number, int value); void (*ProgramChange)(int channel, int program); void (*ChannelAftertouch)(int channel, int pressure); void (*PitchBend)(int channel, int lsb, int msb); void (*ReleasePatches)(); void (*LoadPatch)(int number); void (*SetVolume)(int volume); int (*GetVolume)(); void (*SysEx)(unsigned char *data, int length); } *


decompiled_code:
void NoSoundDrv_MIDI_Shutdown()
{
;
}

canonical_decompiled_code:
void func16()
{
;
}

original_code:
void NoSoundDrv_MIDI_Shutdown(void)
{
}

canonical_original_code:
void NoSoundDrv_MIDI_Shutdown()
{
}


decompiled_code:
__int64 NoSoundDrv_MIDI_StartPlayback()
{
return 0LL;
}

canonical_decompiled_code:
__int64 func17()
{
return 0LL;
}

original_code:
int NoSoundDrv_MIDI_StartPlayback(void (*service)(void))
{
    return 0;
}

canonical_original_code:
int NoSoundDrv_MIDI_StartPlayback(void (*service)())
{
    return 0;
}

variable_types:
service
void (*)()


decompiled_code:
void NoSoundDrv_MIDI_HaltPlayback()
{
;
}

canonical_decompiled_code:
void func18()
{
;
}

original_code:
void NoSoundDrv_MIDI_HaltPlayback(void)
{
}

canonical_original_code:
void NoSoundDrv_MIDI_HaltPlayback()
{
}


decompiled_code:
__int64 NoSoundDrv_MIDI_GetTick()
{
return 0LL;
}

canonical_decompiled_code:
__int64 func19()
{
return 0LL;
}

original_code:
unsigned int NoSoundDrv_MIDI_GetTick(void)
{
    return 0;
}

canonical_original_code:
unsigned int NoSoundDrv_MIDI_GetTick()
{
    return 0;
}

return_type: unsigned int


decompiled_code:
void NoSoundDrv_MIDI_SetTempo()
{
;
}

canonical_decompiled_code:
void func20()
{
;
}

original_code:
void NoSoundDrv_MIDI_SetTempo(int tempo, int division)
{
}

variable_types: tempo int

variable_types: division int


decompiled_code:
void NoSoundDrv_MIDI_Lock()
{
;
}

canonical_decompiled_code:
void func21()
{
;
}

original_code:
void NoSoundDrv_MIDI_Lock(void)
{
}

canonical_original_code:
void NoSoundDrv_MIDI_Lock()
{
}


decompiled_code:
void NoSoundDrv_MIDI_Unlock()
{
;
}

canonical_decompiled_code:
void func22()
{
;
}

original_code:
void NoSoundDrv_MIDI_Unlock(void)
{
}

canonical_original_code:
void NoSoundDrv_MIDI_Unlock()
{
}


decompiled_code:
__int64 ALSADrv_GetError()
{
return (unsigned int)ErrorCode;
}

canonical_decompiled_code:
__int64 func10()
{
return (unsigned int)ErrorCode;
}

original_code:
int ALSADrv_GetError(void)
{
 return ErrorCode;
}

canonical_original_code:
int ALSADrv_GetError()
{
 return ErrorCode;
}


decompiled_code:
const char *__fastcall ALSADrv_ErrorString(int a1)
{
const char *result; // rax

switch ( a1 )
{
case -2:
case -1:
result = (const char *)ALSADrv_ErrorString((unsigned int)ErrorCode);
break;
case 0:
result = "ALSA ok.";
break;
case 1:
result = "ALSA uninitialised.";
break;
case 2:
result = "ALSA error: failed in snd_seq_open.\n";
break;
case 3:
result = "ALSA error: failed in snd_seq_create_simple_port.\n";
break;
case 4:
result = "ALSA error: failed in snd_seq_alloc_queue.\n";
break;
case 5:
result = "ALSA error: failed in snd_seq_connect_to.\n";
break;
default:
result = "Unknown ALSA error.";
break;
}
return result;
}

canonical_decompiled_code:
const char *__fastcall func11(int a1)
{
const char *result; // rax

switch ( a1 )
{
case -2:
case -1:
result = (const char *)func11((unsigned int)ErrorCode);
break;
case 0:
result = "ALSA ok.";
break;
case 1:
result = "ALSA uninitialised.";
break;
case 2:
result = "ALSA error: failed in snd_seq_open.\n";
break;
case 3:
result = "ALSA error: failed in snd_seq_create_simple_port.\n";
break;
case 4:
result = "ALSA error: failed in snd_seq_alloc_queue.\n";
break;
case 5:
result = "ALSA error: failed in snd_seq_connect_to.\n";
break;
default:
result = "Unknown ALSA error.";
break;
}
return result;
}

original_code:
const char *ALSADrv_ErrorString( int ErrorNumber )
{
 const char *ErrorString;
    switch( ErrorNumber )
 {
        case ALSAErr_Warning :
        case ALSAErr_Error :
            ErrorString = ALSADrv_ErrorString( ErrorCode );
            break;
        case ALSAErr_Ok :
            ErrorString = "ALSA ok.";
            break;
  case ALSAErr_Uninitialised:
   ErrorString = "ALSA uninitialised.";
   break;
        case ALSAErr_SeqOpen:
            ErrorString = "ALSA error: failed in snd_seq_open.\n";
            break;
        case ALSAErr_CreateSimplePort:
            ErrorString = "ALSA error: failed in snd_seq_create_simple_port.\n";
            break;
        case ALSAErr_AllocQueue:
            ErrorString = "ALSA error: failed in snd_seq_alloc_queue.\n";
            break;
        case ALSAErr_ConnectTo:
            ErrorString = "ALSA error: failed in snd_seq_connect_to.\n";
            break;
        default:
            ErrorString = "Unknown ALSA error.";
            break;
    }
 return ErrorString;
}

canonical_original_code:
char *ALSADrv_ErrorString(int ErrorNumber)
{
 char *ErrorString;
    switch( ErrorNumber )
 {
        case ALSAErr_Warning :
        case ALSAErr_Error :
            ErrorString = ALSADrv_ErrorString( ErrorCode );
            break;
        case ALSAErr_Ok :
            ErrorString = "ALSA ok.";
            break;
  case ALSAErr_Uninitialised:
   ErrorString = "ALSA uninitialised.";
   break;
        case ALSAErr_SeqOpen:
            ErrorString = "ALSA error: failed in snd_seq_open.\n";
            break;
        case ALSAErr_CreateSimplePort:
            ErrorString = "ALSA error: failed in snd_seq_create_simple_port.\n";
            break;
        case ALSAErr_AllocQueue:
            ErrorString = "ALSA error: failed in snd_seq_alloc_queue.\n";
            break;
        case ALSAErr_ConnectTo:
            ErrorString = "ALSA error: failed in snd_seq_connect_to.\n";
            break;
        default:
            ErrorString = "Unknown ALSA error.";
            break;
    }
 return ErrorString;
}

variable_types:
ErrorString
char *


decompiled_code:
void ALSADrv_MIDI_HaltPlayback()
{
int v0; // eax
void *thread_return; // [rsp+0h] [rbp-10h] BYREF

if ( threadRunning )
{
threadQuit = 1;
if ( pthread_join(thread, &thread_return) )
fwrite("ALSA pthread_join returned error\n", 1uLL, 0x21uLL, stderr);
do
v0 = snd_seq_drain_output(seq);
while ( v0 > 0 );
if ( v0 < 0 )
fprintf(stderr, "ALSA could not drain output: err %d\n", (unsigned int)v0);
snd_seq_sync_output_queue(seq);
threadRunning = 0;
}
}

canonical_decompiled_code:
void func12()
{
int v0; // eax
void *thread_return; // [rsp+0h] [rbp-10h] BYREF

if ( threadRunning )
{
threadQuit = 1;
if ( pthread_join(thread, &thread_return) )
fwrite("ALSA pthread_join returned error\n", 1uLL, 0x21uLL, stderr);
do
v0 = snd_seq_drain_output(seq);
while ( v0 > 0 );
if ( v0 < 0 )
fprintf(stderr, "ALSA could not drain output: err %d\n", (unsigned int)v0);
snd_seq_sync_output_queue(seq);
threadRunning = 0;
}
}

original_code:
void ALSADrv_MIDI_HaltPlayback(void)
{
    int result;
    void * ret;
    if (!threadRunning) {
        return;
    }
    threadQuit = 1;
    if (pthread_join(thread, &ret)) {
        fprintf(stderr, "ALSA pthread_join returned error\n");
    }
    if (queueRunning) {
    }
    while ((result = snd_seq_drain_output(seq)) > 0) ;
    if (result < 0) {
        fprintf(stderr, "ALSA could not drain output: err %d\n", result);
    }
    snd_seq_sync_output_queue(seq);
    threadRunning = 0;
}

canonical_original_code:
void ALSADrv_MIDI_HaltPlayback()
{
    int result;
    void *ret;
    if (!threadRunning) {
        return;
    }
    threadQuit = 1;
    if (pthread_join(thread, &ret)) {
        fprintf(stderr, "ALSA pthread_join returned error\n");
    }
    if (queueRunning) {
    }
    while ((result = snd_seq_drain_output(seq)) > 0) ;
    if (result < 0) {
        fprintf(stderr, "ALSA could not drain output: err %d\n", result);
    }
    snd_seq_sync_output_queue(seq);
    threadRunning = 0;
}

variable_types: result int

variable_types:
ret
void *


decompiled_code:
void ALSADrv_MIDI_Shutdown()
{
ALSADrv_MIDI_HaltPlayback();
if ( seq_queue >= 0 )
snd_seq_free_queue(seq);
if ( seq_port >= 0 )
snd_seq_delete_simple_port(seq);
if ( seq )
snd_seq_close();
seq_queue = -1;
seq_port = -1;
seq = 0LL;
}

canonical_decompiled_code:
void func13()
{
func12();
if ( seq_queue >= 0 )
snd_seq_free_queue(seq);
if ( seq_port >= 0 )
snd_seq_delete_simple_port(seq);
if ( seq )
snd_seq_close();
seq_queue = -1;
seq_port = -1;
seq = 0LL;
}

original_code:
void ALSADrv_MIDI_Shutdown(void)
{
    ALSADrv_MIDI_HaltPlayback();
    if (seq_queue >= 0) {
        snd_seq_free_queue(seq, seq_queue);
    }
    if (seq_port >= 0) {
        snd_seq_delete_simple_port(seq, seq_port);
    }
    if (seq) {
        snd_seq_close(seq);
    }
    seq_queue = -1;
    seq_port = -1;
    seq = 0;
}

canonical_original_code:
void ALSADrv_MIDI_Shutdown()
{
    ALSADrv_MIDI_HaltPlayback();
    if (seq_queue >= 0) {
        snd_seq_free_queue(seq, seq_queue);
    }
    if (seq_port >= 0) {
        snd_seq_delete_simple_port(seq, seq_port);
    }
    if (seq) {
        snd_seq_close(seq);
    }
    seq_queue = -1;
    seq_port = -1;
    seq = 0;
}


decompiled_code:
__int64 __fastcall ALSADrv_MIDI_Init(int (__fastcall **a1)(unsigned __int8 a1, char a2, char a3))
{
int v1; // eax
int v2; // ebp
__int64 result; // rax

ALSADrv_MIDI_Shutdown();
*a1 = 0LL;
a1[11] = 0LL;
memset(
(void *)((unsigned __int64)(a1 + 1) & 0xFFFFFFFFFFFFFFF8LL),
0,
8LL * (((unsigned int)a1 - (((_DWORD)a1 + 8) & 0xFFFFFFF8) + 96) >> 3));
v1 = snd_seq_open(&seq, "default", 3LL);
if ( v1 < 0 )
{
fprintf(stderr, "ALSA snd_seq_open err %d\n", (unsigned int)v1);
ErrorCode = 2;
result = 0xFFFFFFFFLL;
}
else
{
seq_port = snd_seq_create_simple_port(seq, "output", 3LL, 0x100000LL);
if ( seq_port < 0 )
{
ALSADrv_MIDI_Shutdown();
fprintf(stderr, "ALSA snd_seq_create_simple_port err %d\n", (unsigned int)seq_port);
ErrorCode = 3;
result = 0xFFFFFFFFLL;
}
else
{
snd_seq_set_client_name(seq, "JFAudioLib application");
seq_queue = snd_seq_alloc_queue(seq);
if ( seq_queue < 0 )
{
ALSADrv_MIDI_Shutdown();
fprintf(stderr, "ALSA snd_seq_alloc_queue err %d\n", (unsigned int)seq_queue);
ErrorCode = 4;
result = 0xFFFFFFFFLL;
}
else
{
v2 = snd_seq_connect_to(seq, (unsigned int)seq_port, 128LL, 0LL);
if ( v2 < 0 )
{
ALSADrv_MIDI_Shutdown();
fprintf(stderr, "ALSA snd_seq_connect_to err %d\n", (unsigned int)v2);
ErrorCode = 5;
result = 0xFFFFFFFFLL;
}
else
{
*a1 = Func_NoteOff;
a1[1] = Func_NoteOn;
a1[2] = Func_PolyAftertouch;
a1[3] = (int (__fastcall *)(unsigned __int8, char, char))Func_ControlChange;
a1[4] = (int (__fastcall *)(unsigned __int8, char, char))Func_ProgramChange;
a1[5] = (int (__fastcall *)(unsigned __int8, char, char))Func_ChannelAftertouch;
a1[6] = (int (__fastcall *)(unsigned __int8, char, char))Func_PitchBend;
result = 0LL;
}
}
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func14(int (__fastcall **a1)(unsigned __int8 a1, char a2, char a3))
{
int v1; // eax
int v2; // ebp
__int64 result; // rax

func13();
*a1 = 0LL;
a1[11] = 0LL;
memset(
(void *)((unsigned __int64)(a1 + 1) & 0xFFFFFFFFFFFFFFF8LL),
0,
8LL * (((unsigned int)a1 - (((_DWORD)a1 + 8) & 0xFFFFFFF8) + 96) >> 3));
v1 = snd_seq_open(&seq, "default", 3LL);
if ( v1 < 0 )
{
fprintf(stderr, "ALSA snd_seq_open err %d\n", (unsigned int)v1);
ErrorCode = 2;
result = 0xFFFFFFFFLL;
}
else
{
seq_port = snd_seq_create_simple_port(seq, "output", 3LL, 0x100000LL);
if ( seq_port < 0 )
{
func13();
fprintf(stderr, "ALSA snd_seq_create_simple_port err %d\n", (unsigned int)seq_port);
ErrorCode = 3;
result = 0xFFFFFFFFLL;
}
else
{
snd_seq_set_client_name(seq, "JFAudioLib application");
seq_queue = snd_seq_alloc_queue(seq);
if ( seq_queue < 0 )
{
func13();
fprintf(stderr, "ALSA snd_seq_alloc_queue err %d\n", (unsigned int)seq_queue);
ErrorCode = 4;
result = 0xFFFFFFFFLL;
}
else
{
v2 = snd_seq_connect_to(seq, (unsigned int)seq_port, 128LL, 0LL);
if ( v2 < 0 )
{
func13();
fprintf(stderr, "ALSA snd_seq_connect_to err %d\n", (unsigned int)v2);
ErrorCode = 5;
result = 0xFFFFFFFFLL;
}
else
{
*a1 = Func_NoteOff;
a1[1] = Func_NoteOn;
a1[2] = Func_PolyAftertouch;
a1[3] = (int (__fastcall *)(unsigned __int8, char, char))Func_ControlChange;
a1[4] = (int (__fastcall *)(unsigned __int8, char, char))Func_ProgramChange;
a1[5] = (int (__fastcall *)(unsigned __int8, char, char))Func_ChannelAftertouch;
a1[6] = (int (__fastcall *)(unsigned __int8, char, char))Func_PitchBend;
result = 0LL;
}
}
}
}
return result;
}

original_code:
int ALSADrv_MIDI_Init(midifuncs *funcs)
{
    int result;
    ALSADrv_MIDI_Shutdown();
    memset(funcs, 0, sizeof(midifuncs));
    result = snd_seq_open(&seq, "default", (1|2), 0);
    if (result < 0) {
        fprintf(stderr, "ALSA snd_seq_open err %d\n", result);
        ErrorCode = ALSAErr_SeqOpen;
        return ALSAErr_Error;
    }
    seq_port = snd_seq_create_simple_port(seq, "output",
                  (1<<0) | (1<<1),
                  (1<<20));
    if (seq_port < 0) {
        ALSADrv_MIDI_Shutdown();
        fprintf(stderr, "ALSA snd_seq_create_simple_port err %d\n", seq_port);
        ErrorCode = ALSAErr_CreateSimplePort;
        return ALSAErr_Error;
    }
    snd_seq_set_client_name(seq, "JFAudioLib application");
    seq_queue = snd_seq_alloc_queue(seq);
    if (seq_queue < 0) {
        ALSADrv_MIDI_Shutdown();
        fprintf(stderr, "ALSA snd_seq_alloc_queue err %d\n", seq_queue);
        ErrorCode = ALSAErr_AllocQueue;
        return ALSAErr_Error;
    }
    result = snd_seq_connect_to(seq, seq_port, 128, 0);
    if (result < 0) {
        ALSADrv_MIDI_Shutdown();
        fprintf(stderr, "ALSA snd_seq_connect_to err %d\n", result);
        ErrorCode = ALSAErr_ConnectTo;
        return ALSAErr_Error;
    }
    funcs->NoteOff = Func_NoteOff;
    funcs->NoteOn = Func_NoteOn;
    funcs->PolyAftertouch = Func_PolyAftertouch;
    funcs->ControlChange = Func_ControlChange;
    funcs->ProgramChange = Func_ProgramChange;
    funcs->ChannelAftertouch = Func_ChannelAftertouch;
    funcs->PitchBend = Func_PitchBend;
    return ALSAErr_Ok;
}

canonical_original_code:
int ALSADrv_MIDI_Init(struct midifuncs *funcs)
{
    int result;
    ALSADrv_MIDI_Shutdown();
    memset(funcs, 0, sizeof(midifuncs));
    result = snd_seq_open(&seq, "default", (1|2), 0);
    if (result < 0) {
        fprintf(stderr, "ALSA snd_seq_open err %d\n", result);
        ErrorCode = ALSAErr_SeqOpen;
        return ALSAErr_Error;
    }
    seq_port = snd_seq_create_simple_port(seq, "output",
                  (1<<0) | (1<<1),
                  (1<<20));
    if (seq_port < 0) {
        ALSADrv_MIDI_Shutdown();
        fprintf(stderr, "ALSA snd_seq_create_simple_port err %d\n", seq_port);
        ErrorCode = ALSAErr_CreateSimplePort;
        return ALSAErr_Error;
    }
    snd_seq_set_client_name(seq, "JFAudioLib application");
    seq_queue = snd_seq_alloc_queue(seq);
    if (seq_queue < 0) {
        ALSADrv_MIDI_Shutdown();
        fprintf(stderr, "ALSA snd_seq_alloc_queue err %d\n", seq_queue);
        ErrorCode = ALSAErr_AllocQueue;
        return ALSAErr_Error;
    }
    result = snd_seq_connect_to(seq, seq_port, 128, 0);
    if (result < 0) {
        ALSADrv_MIDI_Shutdown();
        fprintf(stderr, "ALSA snd_seq_connect_to err %d\n", result);
        ErrorCode = ALSAErr_ConnectTo;
        return ALSAErr_Error;
    }
    funcs->NoteOff = Func_NoteOff;
    funcs->NoteOn = Func_NoteOn;
    funcs->PolyAftertouch = Func_PolyAftertouch;
    funcs->ControlChange = Func_ControlChange;
    funcs->ProgramChange = Func_ProgramChange;
    funcs->ChannelAftertouch = Func_ChannelAftertouch;
    funcs->PitchBend = Func_PitchBend;
    return ALSAErr_Ok;
}

user_defined_types: struct midifuncs { void (*NoteOff)(int channel, int key, int velocity); void (*NoteOn)(int channel, int key, int velocity); void (*PolyAftertouch)(int channel, int key, int pressure); void (*ControlChange)(int channel, int number, int value); void (*ProgramChange)(int channel, int program); void (*ChannelAftertouch)(int channel, int pressure); void (*PitchBend)(int channel, int lsb, int msb); void (*ReleasePatches)(); void (*LoadPatch)(int number); void (*SetVolume)(int volume); int (*GetVolume)(); void (*SysEx)(unsigned char *data, int length); }


decompiled_code:
int __fastcall ALSADrv_MIDI_StartPlayback(__int64 (*a1)(void))
{
int v1; // eax
int v2; // eax
int result; // eax
int v4; // eax

ALSADrv_MIDI_HaltPlayback();
threadService = a1;
threadQuit = 0;
if ( !queueRunning )
{
v1 = snd_seq_control_queue(seq, (unsigned int)seq_queue, 30LL, 0LL, 0LL);
if ( v1 < 0 )
{
fprintf(stderr, "ALSA snd_seq_start_queue err %d\n", (unsigned int)v1);
return 6;
}
do
v2 = snd_seq_drain_output(seq);
while ( v2 > 0 );
if ( v2 < 0 )
fprintf(stderr, "ALSA could not drain output: err %d\n", (unsigned int)v2);
}
queueRunning = 1;
result = pthread_create(&thread, 0LL, threadProc, 0LL);
if ( result )
{
fwrite("ALSA pthread_create returned error\n", 1uLL, 0x23uLL, stderr);
snd_seq_control_queue(seq, (unsigned int)seq_queue, 32LL, 0LL, 0LL);
do
v4 = snd_seq_drain_output(seq);
while ( v4 > 0 );
if ( v4 < 0 )
fprintf(stderr, "ALSA could not drain output: err %d\n", (unsigned int)v4);
queueRunning = 0;
result = 8;
}
else
{
threadRunning = 1;
}
return result;
}

canonical_decompiled_code:
int __fastcall func15(__int64 (*a1)(void))
{
int v1; // eax
int v2; // eax
int result; // eax
int v4; // eax

func12();
threadService = a1;
threadQuit = 0;
if ( !queueRunning )
{
v1 = snd_seq_control_queue(seq, (unsigned int)seq_queue, 30LL, 0LL, 0LL);
if ( v1 < 0 )
{
fprintf(stderr, "ALSA snd_seq_start_queue err %d\n", (unsigned int)v1);
return 6;
}
do
v2 = snd_seq_drain_output(seq);
while ( v2 > 0 );
if ( v2 < 0 )
fprintf(stderr, "ALSA could not drain output: err %d\n", (unsigned int)v2);
}
queueRunning = 1;
result = pthread_create(&thread, 0LL, threadProc, 0LL);
if ( result )
{
fwrite("ALSA pthread_create returned error\n", 1uLL, 0x23uLL, stderr);
snd_seq_control_queue(seq, (unsigned int)seq_queue, 32LL, 0LL, 0LL);
do
v4 = snd_seq_drain_output(seq);
while ( v4 > 0 );
if ( v4 < 0 )
fprintf(stderr, "ALSA could not drain output: err %d\n", (unsigned int)v4);
queueRunning = 0;
result = 8;
}
else
{
threadRunning = 1;
}
return result;
}

original_code:
int ALSADrv_MIDI_StartPlayback(void (*service)(void))
{
    int result;
    ALSADrv_MIDI_HaltPlayback();
    threadService = service;
    threadQuit = 0;
    if (!queueRunning) {
        result = snd_seq_control_queue(seq, seq_queue, SND_SEQ_EVENT_START, 0, ((void *)0));
        if (result < 0) {
            fprintf(stderr, "ALSA snd_seq_start_queue err %d\n", result);
            return ALSAErr_StartQueue;
        }
        while ((result = snd_seq_drain_output(seq)) > 0) ;
        if (result < 0) {
            fprintf(stderr, "ALSA could not drain output: err %d\n", result);
        }
    }
    queueRunning = 1;
    if (pthread_create(&thread, ((void *)0), threadProc, ((void *)0))) {
        fprintf(stderr, "ALSA pthread_create returned error\n");
        snd_seq_control_queue(seq, seq_queue, SND_SEQ_EVENT_STOP, 0, ((void *)0));
        while ((result = snd_seq_drain_output(seq)) > 0) ;
        if (result < 0) {
            fprintf(stderr, "ALSA could not drain output: err %d\n", result);
        }
        queueRunning = 0;
        return ALSAErr_PlayThread;
    }
    threadRunning = 1;
    return 0;
}

canonical_original_code:
int ALSADrv_MIDI_StartPlayback(void (*service)())
{
    int result;
    ALSADrv_MIDI_HaltPlayback();
    threadService = service;
    threadQuit = 0;
    if (!queueRunning) {
        result = snd_seq_control_queue(seq, seq_queue, SND_SEQ_EVENT_START, 0, ((void *)0));
        if (result < 0) {
            fprintf(stderr, "ALSA snd_seq_start_queue err %d\n", result);
            return ALSAErr_StartQueue;
        }
        while ((result = snd_seq_drain_output(seq)) > 0) ;
        if (result < 0) {
            fprintf(stderr, "ALSA could not drain output: err %d\n", result);
        }
    }
    queueRunning = 1;
    if (pthread_create(&thread, ((void *)0), threadProc, ((void *)0))) {
        fprintf(stderr, "ALSA pthread_create returned error\n");
        snd_seq_control_queue(seq, seq_queue, SND_SEQ_EVENT_STOP, 0, ((void *)0));
        while ((result = snd_seq_drain_output(seq)) > 0) ;
        if (result < 0) {
            fprintf(stderr, "ALSA could not drain output: err %d\n", result);
        }
        queueRunning = 0;
        return ALSAErr_PlayThread;
    }
    threadRunning = 1;
    return 0;
}


decompiled_code:
void ALSADrv_MIDI_Lock()
{
;
}

canonical_decompiled_code:
void func17()
{
;
}

original_code:
void ALSADrv_MIDI_Lock(void)
{
}

canonical_original_code:
void ALSADrv_MIDI_Lock()
{
}


decompiled_code:
void ALSADrv_MIDI_Unlock()
{
;
}

original_code:
void ALSADrv_MIDI_Unlock(void)
{
}

canonical_original_code:
void ALSADrv_MIDI_Unlock()
{
}


decompiled_code:
int __fastcall sequence_event(__int64 a1)
{
int v1; // eax
int result; // eax

*(_BYTE *)(a1 + 14) = -2;
*(_BYTE *)(a1 + 15) = -3;
*(_BYTE *)(a1 + 13) = seq_port;
*(_BYTE *)(a1 + 1) &= 0xFCu;
*(_DWORD *)(a1 + 4) = threadTimer;
*(_BYTE *)(a1 + 3) = seq_queue;
v1 = snd_seq_event_output(seq, a1);
if ( v1 < 0 )
return fprintf(stderr, "ALSA could not queue event: err %d\n", (unsigned int)v1);
do
result = snd_seq_drain_output(seq);
while ( result > 0 );
if ( result < 0 )
result = fprintf(stderr, "ALSA could not drain output: err %d\n", (unsigned int)result);
return result;
}

canonical_decompiled_code:
int __fastcall func0(__int64 a1)
{
int v1; // eax
int result; // eax

*(_BYTE *)(a1 + 14) = -2;
*(_BYTE *)(a1 + 15) = -3;
*(_BYTE *)(a1 + 13) = seq_port;
*(_BYTE *)(a1 + 1) &= 0xFCu;
*(_DWORD *)(a1 + 4) = threadTimer;
*(_BYTE *)(a1 + 3) = seq_queue;
v1 = snd_seq_event_output(seq, a1);
if ( v1 < 0 )
return fprintf(stderr, "ALSA could not queue event: err %d\n", (unsigned int)v1);
do
result = snd_seq_drain_output(seq);
while ( result > 0 );
if ( result < 0 )
result = fprintf(stderr, "ALSA could not drain output: err %d\n", (unsigned int)result);
return result;
}

original_code:
static inline void sequence_event(snd_seq_event_t * ev)
{
    int result = 0;
    ((ev)->dest.client = 254, (ev)->dest.port = 253);
    ((ev)->source.port = (seq_port));
    ((ev)->flags &= ~((1<<0) | (1<<1)), (ev)->flags |= (0<<0), (ev)->flags |= (0) ? (1<<1) : (0<<1), (ev)->time.tick = (threadTimer), (ev)->queue = (seq_queue));
    result = snd_seq_event_output(seq, ev);
    if (result < 0) {
        fprintf(stderr, "ALSA could not queue event: err %d\n", result);
    } else {
        while ((result = snd_seq_drain_output(seq)) > 0) ;
        if (result < 0) {
            fprintf(stderr, "ALSA could not drain output: err %d\n", result);
        }
    }
}

canonical_original_code:
static inline void sequence_event(struct snd_seq_event *ev)
{
    int result = 0;
    ((ev)->dest.client = 254, (ev)->dest.port = 253);
    ((ev)->source.port = (seq_port));
    ((ev)->flags &= ~((1<<0) | (1<<1)), (ev)->flags |= (0<<0), (ev)->flags |= (0) ? (1<<1) : (0<<1), (ev)->time.tick = (threadTimer), (ev)->queue = (seq_queue));
    result = snd_seq_event_output(seq, ev);
    if (result < 0) {
        fprintf(stderr, "ALSA could not queue event: err %d\n", result);
    } else {
        while ((result = snd_seq_drain_output(seq)) > 0) ;
        if (result < 0) {
            fprintf(stderr, "ALSA could not drain output: err %d\n", result);
        }
    }
}

variable_types: struct snd_seq_event { unsigned char type; unsigned char flags; unsigned char tag; unsigned char queue; union snd_seq_timestamp { unsigned int tick; struct snd_seq_real_time { unsigned int tv_sec; unsigned int tv_nsec; } time; } time; struct snd_seq_addr { unsigned char client; unsigned char port; } source; struct snd_seq_addr dest; union { struct snd_seq_ev_note { unsigned char channel; unsigned char note; unsigned char velocity; unsigned char off_velocity; unsigned int duration; } note; struct snd_seq_ev_ctrl { unsigned char channel; unsigned char unused[3]; unsigned int param; int value; } control; struct snd_seq_ev_raw8 { unsigned char d[12]; } raw8; struct snd_seq_ev_raw32 { unsigned int d[3]; } raw32; struct snd_seq_ev_ext { unsigned int len; void *ptr; } ext; struct snd_seq_ev_queue_control { unsigned char queue; unsigned char unused[3]; union { int value; union snd_seq_timestamp time; unsigned int position; struct snd_seq_queue_skew { unsigned int value; unsigned int base; } skew; unsigned int d32[2]; unsigned char d8[8]; } param; } queue; union snd_seq_timestamp time; struct snd_seq_addr addr; struct snd_seq_connect { struct snd_seq_addr sender; struct snd_seq_addr dest; } connect; struct snd_seq_result { int event; int result; } result; } data; } *

user_defined_types: struct snd_seq_event { unsigned char type; unsigned char flags; unsigned char tag; unsigned char queue; union snd_seq_timestamp time; struct snd_seq_addr source; struct snd_seq_addr dest; union { struct snd_seq_ev_note note; struct snd_seq_ev_ctrl control; struct snd_seq_ev_raw8 raw8; struct snd_seq_ev_raw32 raw32; struct snd_seq_ev_ext ext; struct snd_seq_ev_queue_control queue; union snd_seq_timestamp time; struct snd_seq_addr addr; struct snd_seq_connect connect; struct snd_seq_result result; } data; }

user_defined_types: union snd_seq_timestamp { unsigned int tick; struct snd_seq_real_time time; }

user_defined_types: struct snd_seq_ev_queue_control { unsigned char queue; unsigned char unused[3]; union { int value; union snd_seq_timestamp time; unsigned int position; struct snd_seq_queue_skew skew; unsigned int d32[2]; unsigned char d8[8]; } param; }


decompiled_code:
int __fastcall Func_PitchBend(unsigned __int8 a1, int a2, int a3)
{
__int64 v4[3]; // [rsp+0h] [rbp-28h] BYREF
int v5; // [rsp+18h] [rbp-10h]

v4[0] = 13LL;
v4[1] = 0LL;
v4[2] = a1;
v5 = (a2 | (a3 << 7)) - 0x2000;
return sequence_event((__int64)v4);
}

original_code:
static void Func_PitchBend( int channel, int lsb, int msb )
{
    snd_seq_event_t ev;
    memset(&ev, 0, sizeof(snd_seq_event_t));
    ((&ev)->type = SND_SEQ_EVENT_PITCHBEND, ((&ev)->flags &= ~(3<<2), (&ev)->flags |= (0<<2)), (&ev)->data.control.channel = (channel), (&ev)->data.control.value = ((lsb | (msb << 7)) - 8192));
    sequence_event(&ev);
}

canonical_original_code:
static void Func_PitchBend(int channel, int lsb, int msb)
{
    struct snd_seq_event ev;
    memset(&ev, 0, sizeof(snd_seq_event_t));
    ((&ev)->type = SND_SEQ_EVENT_PITCHBEND, ((&ev)->flags &= ~(3<<2), (&ev)->flags |= (0<<2)), (&ev)->data.control.channel = (channel), (&ev)->data.control.value = ((lsb | (msb << 7)) - 8192));
    sequence_event(&ev);
}

variable_types: channel int

variable_types: lsb int

variable_types: msb int

variable_types: struct snd_seq_event { unsigned char type; unsigned char flags; unsigned char tag; unsigned char queue; union snd_seq_timestamp { unsigned int tick; struct snd_seq_real_time { unsigned int tv_sec; unsigned int tv_nsec; } time; } time; struct snd_seq_addr { unsigned char client; unsigned char port; } source; struct snd_seq_addr dest; union { struct snd_seq_ev_note { unsigned char channel; unsigned char note; unsigned char velocity; unsigned char off_velocity; unsigned int duration; } note; struct snd_seq_ev_ctrl { unsigned char channel; unsigned char unused[3]; unsigned int param; int value; } control; struct snd_seq_ev_raw8 { unsigned char d[12]; } raw8; struct snd_seq_ev_raw32 { unsigned int d[3]; } raw32; struct snd_seq_ev_ext { unsigned int len; void *ptr; } ext; struct snd_seq_ev_queue_control { unsigned char queue; unsigned char unused[3]; union { int value; union snd_seq_timestamp time; unsigned int position; struct snd_seq_queue_skew { unsigned int value; unsigned int base; } skew; unsigned int d32[2]; unsigned char d8[8]; } param; } queue; union snd_seq_timestamp time; struct snd_seq_addr addr; struct snd_seq_connect { struct snd_seq_addr sender; struct snd_seq_addr dest; } connect; struct snd_seq_result { int event; int result; } result; } data; }


decompiled_code:
int __fastcall Func_ChannelAftertouch(unsigned __int8 a1, int a2)
{
__int64 v3[3]; // [rsp+0h] [rbp-28h] BYREF
int v4; // [rsp+18h] [rbp-10h]

v3[0] = 12LL;
v3[1] = 0LL;
v3[2] = a1;
v4 = a2;
return sequence_event((__int64)v3);
}

canonical_decompiled_code:
int __fastcall func2(unsigned __int8 a1, int a2)
{
__int64 v3[3]; // [rsp+0h] [rbp-28h] BYREF
int v4; // [rsp+18h] [rbp-10h]

v3[0] = 12LL;
v3[1] = 0LL;
v3[2] = a1;
v4 = a2;
return func0((__int64)v3);
}

original_code:
static void Func_ChannelAftertouch( int channel, int pressure )
{
    snd_seq_event_t ev;
    memset(&ev, 0, sizeof(snd_seq_event_t));
    ((&ev)->type = SND_SEQ_EVENT_CHANPRESS, ((&ev)->flags &= ~(3<<2), (&ev)->flags |= (0<<2)), (&ev)->data.control.channel = (channel), (&ev)->data.control.value = (pressure));
    sequence_event(&ev);
}

canonical_original_code:
static void Func_ChannelAftertouch(int channel, int pressure)
{
    struct snd_seq_event ev;
    memset(&ev, 0, sizeof(snd_seq_event_t));
    ((&ev)->type = SND_SEQ_EVENT_CHANPRESS, ((&ev)->flags &= ~(3<<2), (&ev)->flags |= (0<<2)), (&ev)->data.control.channel = (channel), (&ev)->data.control.value = (pressure));
    sequence_event(&ev);
}

variable_types: pressure int

user_defined_types: struct snd_seq_addr { unsigned char client; unsigned char port; }

user_defined_types: struct snd_seq_real_time { unsigned int tv_sec; unsigned int tv_nsec; }

user_defined_types: struct snd_seq_ev_note { unsigned char channel; unsigned char note; unsigned char velocity; unsigned char off_velocity; unsigned int duration; }

user_defined_types: struct snd_seq_ev_ctrl { unsigned char channel; unsigned char unused[3]; unsigned int param; int value; }

user_defined_types: struct snd_seq_ev_raw8 { unsigned char d[12]; }

user_defined_types: struct snd_seq_ev_raw32 { unsigned int d[3]; }

user_defined_types: struct snd_seq_ev_ext { unsigned int len; void *ptr; }

user_defined_types: struct snd_seq_connect { struct snd_seq_addr sender; struct snd_seq_addr dest; }

user_defined_types: struct snd_seq_result { int event; int result; }

user_defined_types: struct snd_seq_queue_skew { unsigned int value; unsigned int base; }


decompiled_code:
int __fastcall Func_ProgramChange(unsigned __int8 a1, int a2)
{
__int64 v3[3]; // [rsp+0h] [rbp-28h] BYREF
int v4; // [rsp+18h] [rbp-10h]

v3[0] = 11LL;
v3[1] = 0LL;
v3[2] = a1;
v4 = a2;
return sequence_event((__int64)v3);
}

canonical_decompiled_code:
int __fastcall func3(unsigned __int8 a1, int a2)
{
__int64 v3[3]; // [rsp+0h] [rbp-28h] BYREF
int v4; // [rsp+18h] [rbp-10h]

v3[0] = 11LL;
v3[1] = 0LL;
v3[2] = a1;
v4 = a2;
return func0((__int64)v3);
}

original_code:
static void Func_ProgramChange( int channel, int program )
{
    snd_seq_event_t ev;
    memset(&ev, 0, sizeof(snd_seq_event_t));
    ((&ev)->type = SND_SEQ_EVENT_PGMCHANGE, ((&ev)->flags &= ~(3<<2), (&ev)->flags |= (0<<2)), (&ev)->data.control.channel = (channel), (&ev)->data.control.value = (program));
    sequence_event(&ev);
}

canonical_original_code:
static void Func_ProgramChange(int channel, int program)
{
    struct snd_seq_event ev;
    memset(&ev, 0, sizeof(snd_seq_event_t));
    ((&ev)->type = SND_SEQ_EVENT_PGMCHANGE, ((&ev)->flags &= ~(3<<2), (&ev)->flags |= (0<<2)), (&ev)->data.control.channel = (channel), (&ev)->data.control.value = (program));
    sequence_event(&ev);
}

variable_types: program int


decompiled_code:
int __fastcall Func_ControlChange(unsigned __int8 a1, int a2, int a3)
{
__int64 v4[2]; // [rsp+0h] [rbp-28h] BYREF
int v5; // [rsp+10h] [rbp-18h]
int v6; // [rsp+14h] [rbp-14h]
int v7; // [rsp+18h] [rbp-10h]

v4[0] = 10LL;
v4[1] = 0LL;
v5 = a1;
v6 = a2;
v7 = a3;
return sequence_event((__int64)v4);
}

original_code:
static void Func_ControlChange( int channel, int number, int value )
{
    snd_seq_event_t ev;
    memset(&ev, 0, sizeof(snd_seq_event_t));
    ((&ev)->type = SND_SEQ_EVENT_CONTROLLER, ((&ev)->flags &= ~(3<<2), (&ev)->flags |= (0<<2)), (&ev)->data.control.channel = (channel), (&ev)->data.control.param = (number), (&ev)->data.control.value = (value));
    sequence_event(&ev);
}

canonical_original_code:
static void Func_ControlChange(int channel, int number, int value)
{
    struct snd_seq_event ev;
    memset(&ev, 0, sizeof(snd_seq_event_t));
    ((&ev)->type = SND_SEQ_EVENT_CONTROLLER, ((&ev)->flags &= ~(3<<2), (&ev)->flags |= (0<<2)), (&ev)->data.control.channel = (channel), (&ev)->data.control.param = (number), (&ev)->data.control.value = (value));
    sequence_event(&ev);
}

variable_types: number int

variable_types: value int


decompiled_code:
int __fastcall Func_PolyAftertouch(unsigned __int8 a1, char a2, char a3)
{
__int64 v4[2]; // [rsp+0h] [rbp-28h] BYREF
__int64 v5; // [rsp+10h] [rbp-18h]
int v6; // [rsp+18h] [rbp-10h]

v4[0] = 8LL;
v4[1] = 0LL;
v6 = 0;
v5 = a1;
BYTE1(v5) = a2;
BYTE2(v5) = a3;
return sequence_event((__int64)v4);
}

original_code:
static void Func_PolyAftertouch( int channel, int key, int pressure )
{
    snd_seq_event_t ev;
    memset(&ev, 0, sizeof(snd_seq_event_t));
    ((&ev)->type = SND_SEQ_EVENT_KEYPRESS, ((&ev)->flags &= ~(3<<2), (&ev)->flags |= (0<<2)), (&ev)->data.note.channel = (channel), (&ev)->data.note.note = (key), (&ev)->data.note.velocity = (pressure));
    sequence_event(&ev);
}

canonical_original_code:
static void Func_PolyAftertouch(int channel, int key, int pressure)
{
    struct snd_seq_event ev;
    memset(&ev, 0, sizeof(snd_seq_event_t));
    ((&ev)->type = SND_SEQ_EVENT_KEYPRESS, ((&ev)->flags &= ~(3<<2), (&ev)->flags |= (0<<2)), (&ev)->data.note.channel = (channel), (&ev)->data.note.note = (key), (&ev)->data.note.velocity = (pressure));
    sequence_event(&ev);
}

variable_types: key int


decompiled_code:
int __fastcall Func_NoteOn(unsigned __int8 a1, char a2, char a3)
{
__int64 v4[2]; // [rsp+0h] [rbp-28h] BYREF
__int64 v5; // [rsp+10h] [rbp-18h]
int v6; // [rsp+18h] [rbp-10h]

v4[0] = 6LL;
v4[1] = 0LL;
v6 = 0;
v5 = a1;
BYTE1(v5) = a2;
BYTE2(v5) = a3;
return sequence_event((__int64)v4);
}

original_code:
static void Func_NoteOn( int channel, int key, int velocity )
{
    snd_seq_event_t ev;
    memset(&ev, 0, sizeof(snd_seq_event_t));
    ((&ev)->type = SND_SEQ_EVENT_NOTEON, ((&ev)->flags &= ~(3<<2), (&ev)->flags |= (0<<2)), (&ev)->data.note.channel = (channel), (&ev)->data.note.note = (key), (&ev)->data.note.velocity = (velocity));
    sequence_event(&ev);
}

canonical_original_code:
static void Func_NoteOn(int channel, int key, int velocity)
{
    struct snd_seq_event ev;
    memset(&ev, 0, sizeof(snd_seq_event_t));
    ((&ev)->type = SND_SEQ_EVENT_NOTEON, ((&ev)->flags &= ~(3<<2), (&ev)->flags |= (0<<2)), (&ev)->data.note.channel = (channel), (&ev)->data.note.note = (key), (&ev)->data.note.velocity = (velocity));
    sequence_event(&ev);
}

variable_types: velocity int


decompiled_code:
int __fastcall Func_NoteOff(unsigned __int8 a1, char a2, char a3)
{
__int64 v4[2]; // [rsp+0h] [rbp-28h] BYREF
__int64 v5; // [rsp+10h] [rbp-18h]
int v6; // [rsp+18h] [rbp-10h]

v4[0] = 7LL;
v4[1] = 0LL;
v6 = 0;
v5 = a1;
BYTE1(v5) = a2;
BYTE2(v5) = a3;
return sequence_event((__int64)v4);
}

original_code:
static void Func_NoteOff( int channel, int key, int velocity )
{
    snd_seq_event_t ev;
    memset(&ev, 0, sizeof(snd_seq_event_t));
    ((&ev)->type = SND_SEQ_EVENT_NOTEOFF, ((&ev)->flags &= ~(3<<2), (&ev)->flags |= (0<<2)), (&ev)->data.note.channel = (channel), (&ev)->data.note.note = (key), (&ev)->data.note.velocity = (velocity));
    sequence_event(&ev);
}

canonical_original_code:
static void Func_NoteOff(int channel, int key, int velocity)
{
    struct snd_seq_event ev;
    memset(&ev, 0, sizeof(snd_seq_event_t));
    ((&ev)->type = SND_SEQ_EVENT_NOTEOFF, ((&ev)->flags &= ~(3<<2), (&ev)->flags |= (0<<2)), (&ev)->data.note.channel = (channel), (&ev)->data.note.note = (key), (&ev)->data.note.velocity = (velocity));
    sequence_event(&ev);
}


threadProc

decompiled_code:
void *__fastcall threadProc(void *a1)
{
unsigned int v1; // ecx
int v2; // eax
struct timeval v4; // [rsp+0h] [rbp-28h] BYREF

threadTimer = get_tick(a1);
for ( threadQueueTimer = threadQueueTicks + threadTimer; threadTimer < (unsigned int)threadQueueTimer; ++threadTimer )
{
if ( threadService )
threadService();
}
LABEL_2:
v1 = 50000;
while ( !threadQuit )
{
v4.tv_sec = 0LL;
v4.tv_usec = v1;
select(0, 0LL, 0LL, 0LL, &v4);
v2 = get_tick(0LL);
v1 = 25000;
if ( threadTimer - v2 <= threadQueueTicks )
{
for ( threadQueueTimer = threadQueueTicks + v2; threadTimer < (unsigned int)threadQueueTimer; ++threadTimer )
{
if ( threadService )
threadService();
}
goto LABEL_2;
}
}
return 0LL;
}

canonical_decompiled_code:
void *__fastcall func9(void *a1)
{
unsigned int v1; // ecx
int v2; // eax
struct timeval v4; // [rsp+0h] [rbp-28h] BYREF

threadTimer = func8(a1);
for ( threadQueueTimer = threadQueueTicks + threadTimer; threadTimer < (unsigned int)threadQueueTimer; ++threadTimer )
{
if ( threadService )
threadService();
}
LABEL_2:
v1 = 50000;
while ( !threadQuit )
{
v4.tv_sec = 0LL;
v4.tv_usec = v1;
select(0, 0LL, 0LL, 0LL, &v4);
v2 = func8(0LL);
v1 = 25000;
if ( threadTimer - v2 <= threadQueueTicks )
{
for ( threadQueueTimer = threadQueueTicks + v2; threadTimer < (unsigned int)threadQueueTimer; ++threadTimer )
{
if ( threadService )
threadService();
}
goto LABEL_2;
}
}
return 0LL;
}

original_code:
static void * threadProc(void * parm)
{
    struct timeval tv;
    int sleepAmount = 1000000 / 20;
    unsigned int sequenceTime;
    threadTimer = get_tick();
    threadQueueTimer = threadTimer + threadQueueTicks;
    while (threadTimer < threadQueueTimer) {
        if (threadService) {
            threadService();
        }
        threadTimer++;
    }
    while (!threadQuit) {
        tv.tv_sec = 0;
        tv.tv_usec = sleepAmount;
        select(0, ((void *)0), ((void *)0), ((void *)0), &tv);
        sequenceTime = get_tick();
        sleepAmount = 1000000 / 20;
        if ((int)(threadTimer - sequenceTime) > threadQueueTicks) {
            sleepAmount /= 2;
            continue;
        }
        threadQueueTimer = sequenceTime + threadQueueTicks;
        while (threadTimer < threadQueueTimer) {
            if (threadService) {
                threadService();
            }
            threadTimer++;
        }
    }
    return ((void *)0);
}

canonical_original_code:
static void *threadProc(void *parm)
{
    struct timeval tv;
    int sleepAmount = 1000000 / 20;
    unsigned int sequenceTime;
    threadTimer = get_tick();
    threadQueueTimer = threadTimer + threadQueueTicks;
    while (threadTimer < threadQueueTimer) {
        if (threadService) {
            threadService();
        }
        threadTimer++;
    }
    while (!threadQuit) {
        tv.tv_sec = 0;
        tv.tv_usec = sleepAmount;
        select(0, ((void *)0), ((void *)0), ((void *)0), &tv);
        sequenceTime = get_tick();
        sleepAmount = 1000000 / 20;
        if ((int)(threadTimer - sequenceTime) > threadQueueTicks) {
            sleepAmount /= 2;
            continue;
        }
        threadQueueTimer = sequenceTime + threadQueueTicks;
        while (threadTimer < threadQueueTimer) {
            if (threadService) {
                threadService();
            }
            threadTimer++;
        }
    }
    return ((void *)0);
}

variable_types:
parm
void *

variable_types: struct timeval { long tv_sec; long tv_usec; }

variable_types: sleepAmount int

variable_types:
sequenceTime
unsigned int

return_type: void *


decompiled_code:
__int64 FluidSynthDrv_GetError()
{
return (unsigned int)ErrorCode;
}

canonical_decompiled_code:
__int64 func9()
{
return (unsigned int)ErrorCode;
}

original_code:
int FluidSynthDrv_GetError(void)
{
 return ErrorCode;
}

canonical_original_code:
int FluidSynthDrv_GetError()
{
 return ErrorCode;
}


decompiled_code:
const char *__fastcall FluidSynthDrv_ErrorString(int a1)
{
const char *result; // rax

switch ( a1 )
{
case -2:
case -1:
result = (const char *)FluidSynthDrv_ErrorString((unsigned int)ErrorCode);
break;
case 0:
result = "FluidSynth ok.";
break;
case 1:
result = "FluidSynth uninitialised.";
break;
case 2:
result = "Failed creating new fluid settings.";
break;
case 3:
result = "Failed creating new fluid synth.";
break;
case 4:
result = "Failed creating new fluid audio driver.";
break;
case 5:
result = "Failed creating new fluid sequencer.";
break;
case 6:
result = "Failed registering fluid synth with sequencer.";
break;
case 7:
result = "Invalid or non-existent SoundFont.";
break;
case 8:
result = "Failed creating new fluid event.";
break;
case 9:
result = "Failed creating playback thread.";
break;
default:
result = "Unknown FluidSynth error.";
break;
}
return result;
}

canonical_decompiled_code:
const char *__fastcall func10(int a1)
{
const char *result; // rax

switch ( a1 )
{
case -2:
case -1:
result = (const char *)func10((unsigned int)ErrorCode);
break;
case 0:
result = "FluidSynth ok.";
break;
case 1:
result = "FluidSynth uninitialised.";
break;
case 2:
result = "Failed creating new fluid settings.";
break;
case 3:
result = "Failed creating new fluid synth.";
break;
case 4:
result = "Failed creating new fluid audio driver.";
break;
case 5:
result = "Failed creating new fluid sequencer.";
break;
case 6:
result = "Failed registering fluid synth with sequencer.";
break;
case 7:
result = "Invalid or non-existent SoundFont.";
break;
case 8:
result = "Failed creating new fluid event.";
break;
case 9:
result = "Failed creating playback thread.";
break;
default:
result = "Unknown FluidSynth error.";
break;
}
return result;
}

original_code:
const char *FluidSynthDrv_ErrorString( int ErrorNumber )
{
 const char *ErrorString;
    switch( ErrorNumber )
 {
        case FSynthErr_Warning :
        case FSynthErr_Error :
            ErrorString = FluidSynthDrv_ErrorString( ErrorCode );
            break;
        case FSynthErr_Ok :
            ErrorString = "FluidSynth ok.";
            break;
  case FSynthErr_Uninitialised:
   ErrorString = "FluidSynth uninitialised.";
   break;
        case FSynthErr_NewFluidSettings:
            ErrorString = "Failed creating new fluid settings.";
            break;
        case FSynthErr_NewFluidSynth:
            ErrorString = "Failed creating new fluid synth.";
            break;
        case FSynthErr_NewFluidAudioDriver:
            ErrorString = "Failed creating new fluid audio driver.";
            break;
        case FSynthErr_NewFluidSequencer:
            ErrorString = "Failed creating new fluid sequencer.";
            break;
        case FSynthErr_RegisterFluidSynth:
            ErrorString = "Failed registering fluid synth with sequencer.";
            break;
        case FSynthErr_BadSoundFont:
            ErrorString = "Invalid or non-existent SoundFont.";
            break;
        case FSynthErr_NewFluidEvent:
            ErrorString = "Failed creating new fluid event.";
            break;
        case FSynthErr_PlayThread:
            ErrorString = "Failed creating playback thread.";
            break;
        default:
            ErrorString = "Unknown FluidSynth error.";
            break;
    }
 return ErrorString;
}

canonical_original_code:
char *FluidSynthDrv_ErrorString(int ErrorNumber)
{
 char *ErrorString;
    switch( ErrorNumber )
 {
        case FSynthErr_Warning :
        case FSynthErr_Error :
            ErrorString = FluidSynthDrv_ErrorString( ErrorCode );
            break;
        case FSynthErr_Ok :
            ErrorString = "FluidSynth ok.";
            break;
  case FSynthErr_Uninitialised:
   ErrorString = "FluidSynth uninitialised.";
   break;
        case FSynthErr_NewFluidSettings:
            ErrorString = "Failed creating new fluid settings.";
            break;
        case FSynthErr_NewFluidSynth:
            ErrorString = "Failed creating new fluid synth.";
            break;
        case FSynthErr_NewFluidAudioDriver:
            ErrorString = "Failed creating new fluid audio driver.";
            break;
        case FSynthErr_NewFluidSequencer:
            ErrorString = "Failed creating new fluid sequencer.";
            break;
        case FSynthErr_RegisterFluidSynth:
            ErrorString = "Failed registering fluid synth with sequencer.";
            break;
        case FSynthErr_BadSoundFont:
            ErrorString = "Invalid or non-existent SoundFont.";
            break;
        case FSynthErr_NewFluidEvent:
            ErrorString = "Failed creating new fluid event.";
            break;
        case FSynthErr_PlayThread:
            ErrorString = "Failed creating playback thread.";
            break;
        default:
            ErrorString = "Unknown FluidSynth error.";
            break;
    }
 return ErrorString;
}

variable_types: ErrorNumber int

variable_types:
ErrorString
char *


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

if ( fluidevent )
result = delete_fluid_event();
if ( fluidsequencer )
result = delete_fluid_sequencer();
if ( fluidaudiodriver )
result = delete_fluid_audio_driver();
if ( fluidsynth )
result = delete_fluid_synth();
if ( fluidsettings )
result = delete_fluid_settings();
synthseqid = -1;
fluidevent = 0LL;
fluidsequencer = 0LL;
fluidaudiodriver = 0LL;
fluidsynth = 0LL;
fluidsettings = 0LL;
return result;
}

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

if ( fluidevent )
result = delete_fluid_event();
if ( fluidsequencer )
result = delete_fluid_sequencer();
if ( fluidaudiodriver )
result = delete_fluid_audio_driver();
if ( fluidsynth )
result = delete_fluid_synth();
if ( fluidsettings )
result = delete_fluid_settings();
synthseqid = -1;
fluidevent = 0LL;
fluidsequencer = 0LL;
fluidaudiodriver = 0LL;
fluidsynth = 0LL;
fluidsettings = 0LL;
return result;
}

original_code:
void FluidSynthDrv_MIDI_Shutdown(void)
{
    if (fluidevent) {
        delete_fluid_event(fluidevent);
    }
    if (fluidsequencer) {
        delete_fluid_sequencer(fluidsequencer);
    }
    if (fluidaudiodriver) {
        delete_fluid_audio_driver(fluidaudiodriver);
    }
    if (fluidsynth) {
        delete_fluid_synth(fluidsynth);
    }
    if (fluidsettings) {
        delete_fluid_settings(fluidsettings);
    }
    synthseqid = -1;
    fluidevent = 0;
    fluidsequencer = 0;
    fluidaudiodriver = 0;
    fluidsynth = 0;
    fluidsettings = 0;
}

canonical_original_code:
void FluidSynthDrv_MIDI_Shutdown()
{
    if (fluidevent) {
        delete_fluid_event(fluidevent);
    }
    if (fluidsequencer) {
        delete_fluid_sequencer(fluidsequencer);
    }
    if (fluidaudiodriver) {
        delete_fluid_audio_driver(fluidaudiodriver);
    }
    if (fluidsynth) {
        delete_fluid_synth(fluidsynth);
    }
    if (fluidsettings) {
        delete_fluid_settings(fluidsettings);
    }
    synthseqid = -1;
    fluidevent = 0;
    fluidsequencer = 0;
    fluidaudiodriver = 0;
    fluidsynth = 0;
    fluidsettings = 0;
}


decompiled_code:
__int64 __fastcall FluidSynthDrv_MIDI_Init(size_t (__fastcall **a1)(unsigned int a1, __int16 a2))
{
__int64 v2; // rax
__int64 v3; // rsi
__int64 v4; // rdi
__int64 v5; // rsi
__int64 v6; // rdi
__int64 v7; // rdi
__int64 result; // rax

((void (*)(void))FluidSynthDrv_MIDI_Shutdown)();
*a1 = 0LL;
a1[11] = 0LL;
memset(
(void *)((unsigned __int64)(a1 + 1) & 0xFFFFFFFFFFFFFFF8LL),
0,
8LL * (((unsigned int)a1 - (((_DWORD)a1 + 8) & 0xFFFFFFF8) + 96) >> 3));
v2 = new_fluid_settings();
fluidsettings = v2;
if ( v2 )
{
v3 = new_fluid_synth(v2);
fluidsynth = v3;
v4 = fluidsettings;
if ( fluidsettings )
{
fluidaudiodriver = new_fluid_audio_driver(fluidsettings, v3);
if ( fluidsettings )
{
fluidsequencer = new_fluid_sequencer();
if ( fluidsettings )
{
fluidevent = new_fluid_event();
if ( fluidevent )
{
v5 = fluidsynth;
v6 = fluidsequencer;
synthseqid = fluid_sequencer_register_fluidsynth(fluidsequencer, fluidsynth);
if ( synthseqid < 0 )
{
FluidSynthDrv_MIDI_Shutdown(v6, v5);
ErrorCode = 6;
result = 0xFFFFFFFFLL;
}
else
{
v7 = fluidsynth;
if ( (int)fluid_synth_sfload(fluidsynth, "/usr/share/sounds/sf2/SGM-V2.01.sf2", 1LL) < 0 )
{
FluidSynthDrv_MIDI_Shutdown(v7, "/usr/share/sounds/sf2/SGM-V2.01.sf2");
ErrorCode = 7;
result = 0xFFFFFFFFLL;
}
else
{
fluid_event_set_source(fluidevent, 0xFFFFFFFFLL);
fluid_event_set_dest(fluidevent, (unsigned int)synthseqid);
*a1 = Func_NoteOff;
a1[1] = (size_t (__fastcall *)(unsigned int, __int16))Func_NoteOn;
a1[2] = (size_t (__fastcall *)(unsigned int, __int16))Func_PolyAftertouch;
a1[3] = (size_t (__fastcall *)(unsigned int, __int16))Func_ControlChange;
a1[4] = Func_ProgramChange;
a1[5] = (size_t (__fastcall *)(unsigned int, __int16))Func_ChannelAftertouch;
a1[6] = (size_t (__fastcall *)(unsigned int, __int16))Func_PitchBend;
result = 0LL;
}
}
}
else
{
FluidSynthDrv_MIDI_Shutdown(v4, v3);
ErrorCode = 8;
result = 0xFFFFFFFFLL;
}
}
else
{
FluidSynthDrv_MIDI_Shutdown(v4, v3);
ErrorCode = 5;
result = 0xFFFFFFFFLL;
}
}
else
{
FluidSynthDrv_MIDI_Shutdown(v4, v3);
ErrorCode = 4;
result = 0xFFFFFFFFLL;
}
}
else
{
FluidSynthDrv_MIDI_Shutdown(fluidsettings, v3);
ErrorCode = 3;
result = 0xFFFFFFFFLL;
}
}
else
{
ErrorCode = 2;
result = 0xFFFFFFFFLL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func12(size_t (__fastcall **a1)(unsigned int a1, __int16 a2))
{
__int64 v2; // rax
__int64 v3; // rsi
__int64 v4; // rdi
__int64 v5; // rsi
__int64 v6; // rdi
__int64 v7; // rdi
__int64 result; // rax

((void (*)(void))FluidSynthDrv_MIDI_Shutdown)();
*a1 = 0LL;
a1[11] = 0LL;
memset(
(void *)((unsigned __int64)(a1 + 1) & 0xFFFFFFFFFFFFFFF8LL),
0,
8LL * (((unsigned int)a1 - (((_DWORD)a1 + 8) & 0xFFFFFFF8) + 96) >> 3));
v2 = new_fluid_settings();
fluidsettings = v2;
if ( v2 )
{
v3 = new_fluid_synth(v2);
fluidsynth = v3;
v4 = fluidsettings;
if ( fluidsettings )
{
fluidaudiodriver = new_fluid_audio_driver(fluidsettings, v3);
if ( fluidsettings )
{
fluidsequencer = new_fluid_sequencer();
if ( fluidsettings )
{
fluidevent = new_fluid_event();
if ( fluidevent )
{
v5 = fluidsynth;
v6 = fluidsequencer;
synthseqid = fluid_sequencer_register_fluidsynth(fluidsequencer, fluidsynth);
if ( synthseqid < 0 )
{
func11(v6, v5);
ErrorCode = 6;
result = 0xFFFFFFFFLL;
}
else
{
v7 = fluidsynth;
if ( (int)fluid_synth_sfload(fluidsynth, "/usr/share/sounds/sf2/SGM-V2.01.sf2", 1LL) < 0 )
{
func11(v7, "/usr/share/sounds/sf2/SGM-V2.01.sf2");
ErrorCode = 7;
result = 0xFFFFFFFFLL;
}
else
{
fluid_event_set_source(fluidevent, 0xFFFFFFFFLL);
fluid_event_set_dest(fluidevent, (unsigned int)synthseqid);
*a1 = Func_NoteOff;
a1[1] = (size_t (__fastcall *)(unsigned int, __int16))Func_NoteOn;
a1[2] = (size_t (__fastcall *)(unsigned int, __int16))Func_PolyAftertouch;
a1[3] = (size_t (__fastcall *)(unsigned int, __int16))Func_ControlChange;
a1[4] = Func_ProgramChange;
a1[5] = (size_t (__fastcall *)(unsigned int, __int16))Func_ChannelAftertouch;
a1[6] = (size_t (__fastcall *)(unsigned int, __int16))Func_PitchBend;
result = 0LL;
}
}
}
else
{
func11(v4, v3);
ErrorCode = 8;
result = 0xFFFFFFFFLL;
}
}
else
{
func11(v4, v3);
ErrorCode = 5;
result = 0xFFFFFFFFLL;
}
}
else
{
func11(v4, v3);
ErrorCode = 4;
result = 0xFFFFFFFFLL;
}
}
else
{
func11(fluidsettings, v3);
ErrorCode = 3;
result = 0xFFFFFFFFLL;
}
}
else
{
ErrorCode = 2;
result = 0xFFFFFFFFLL;
}
return result;
}

original_code:
int FluidSynthDrv_MIDI_Init(midifuncs *funcs)
{
    int result;
    FluidSynthDrv_MIDI_Shutdown();
    memset(funcs, 0, sizeof(midifuncs));
    fluidsettings = new_fluid_settings();
    if (!fluidsettings) {
        ErrorCode = FSynthErr_NewFluidSettings;
        return FSynthErr_Error;
    }
    fluidsynth = new_fluid_synth(fluidsettings);
    if (!fluidsettings) {
        FluidSynthDrv_MIDI_Shutdown();
        ErrorCode = FSynthErr_NewFluidSynth;
        return FSynthErr_Error;
    }
    fluidaudiodriver = new_fluid_audio_driver(fluidsettings, fluidsynth);
    if (!fluidsettings) {
        FluidSynthDrv_MIDI_Shutdown();
        ErrorCode = FSynthErr_NewFluidAudioDriver;
        return FSynthErr_Error;
    }
    fluidsequencer = new_fluid_sequencer();
    if (!fluidsettings) {
        FluidSynthDrv_MIDI_Shutdown();
        ErrorCode = FSynthErr_NewFluidSequencer;
        return FSynthErr_Error;
    }
    fluidevent = new_fluid_event();
    if (!fluidevent) {
        FluidSynthDrv_MIDI_Shutdown();
        ErrorCode = FSynthErr_NewFluidEvent;
        return FSynthErr_Error;
    }
    synthseqid = fluid_sequencer_register_fluidsynth(fluidsequencer, fluidsynth);
    if (synthseqid < 0) {
        FluidSynthDrv_MIDI_Shutdown();
        ErrorCode = FSynthErr_RegisterFluidSynth;
        return FSynthErr_Error;
    }
    result = fluid_synth_sfload(fluidsynth, soundFontName, 1);
    if (result < 0) {
        FluidSynthDrv_MIDI_Shutdown();
        ErrorCode = FSynthErr_BadSoundFont;
        return FSynthErr_Error;
    }
    fluid_event_set_source(fluidevent, -1);
    fluid_event_set_dest(fluidevent, synthseqid);
    funcs->NoteOff = Func_NoteOff;
    funcs->NoteOn = Func_NoteOn;
    funcs->PolyAftertouch = Func_PolyAftertouch;
    funcs->ControlChange = Func_ControlChange;
    funcs->ProgramChange = Func_ProgramChange;
    funcs->ChannelAftertouch = Func_ChannelAftertouch;
    funcs->PitchBend = Func_PitchBend;
    return FSynthErr_Ok;
}

canonical_original_code:
int FluidSynthDrv_MIDI_Init(struct midifuncs *funcs)
{
    int result;
    FluidSynthDrv_MIDI_Shutdown();
    memset(funcs, 0, sizeof(midifuncs));
    fluidsettings = new_fluid_settings();
    if (!fluidsettings) {
        ErrorCode = FSynthErr_NewFluidSettings;
        return FSynthErr_Error;
    }
    fluidsynth = new_fluid_synth(fluidsettings);
    if (!fluidsettings) {
        FluidSynthDrv_MIDI_Shutdown();
        ErrorCode = FSynthErr_NewFluidSynth;
        return FSynthErr_Error;
    }
    fluidaudiodriver = new_fluid_audio_driver(fluidsettings, fluidsynth);
    if (!fluidsettings) {
        FluidSynthDrv_MIDI_Shutdown();
        ErrorCode = FSynthErr_NewFluidAudioDriver;
        return FSynthErr_Error;
    }
    fluidsequencer = new_fluid_sequencer();
    if (!fluidsettings) {
        FluidSynthDrv_MIDI_Shutdown();
        ErrorCode = FSynthErr_NewFluidSequencer;
        return FSynthErr_Error;
    }
    fluidevent = new_fluid_event();
    if (!fluidevent) {
        FluidSynthDrv_MIDI_Shutdown();
        ErrorCode = FSynthErr_NewFluidEvent;
        return FSynthErr_Error;
    }
    synthseqid = fluid_sequencer_register_fluidsynth(fluidsequencer, fluidsynth);
    if (synthseqid < 0) {
        FluidSynthDrv_MIDI_Shutdown();
        ErrorCode = FSynthErr_RegisterFluidSynth;
        return FSynthErr_Error;
    }
    result = fluid_synth_sfload(fluidsynth, soundFontName, 1);
    if (result < 0) {
        FluidSynthDrv_MIDI_Shutdown();
        ErrorCode = FSynthErr_BadSoundFont;
        return FSynthErr_Error;
    }
    fluid_event_set_source(fluidevent, -1);
    fluid_event_set_dest(fluidevent, synthseqid);
    funcs->NoteOff = Func_NoteOff;
    funcs->NoteOn = Func_NoteOn;
    funcs->PolyAftertouch = Func_PolyAftertouch;
    funcs->ControlChange = Func_ControlChange;
    funcs->ProgramChange = Func_ProgramChange;
    funcs->ChannelAftertouch = Func_ChannelAftertouch;
    funcs->PitchBend = Func_PitchBend;
    return FSynthErr_Ok;
}

variable_types: struct midifuncs { void (*NoteOff)(int channel, int key, int velocity); void (*NoteOn)(int channel, int key, int velocity); void (*PolyAftertouch)(int channel, int key, int pressure); void (*ControlChange)(int channel, int number, int value); void (*ProgramChange)(int channel, int program); void (*ChannelAftertouch)(int channel, int pressure); void (*PitchBend)(int channel, int lsb, int msb); void (*ReleasePatches)(); void (*LoadPatch)(int number); void (*SetVolume)(int volume); int (*GetVolume)(); void (*SysEx)(unsigned char *data, int length); } *

variable_types: result int


decompiled_code:
void FluidSynthDrv_MIDI_HaltPlayback()
{
void *thread_return; // [rsp+0h] [rbp-10h] BYREF

if ( threadRunning )
{
threadQuit = 1;
if ( pthread_join(thread, &thread_return) )
fwrite("fluidsynth pthread_join returned error\n", 1uLL, 0x27uLL, stderr);
threadRunning = 0;
}
}

canonical_decompiled_code:
void func13()
{
void *thread_return; // [rsp+0h] [rbp-10h] BYREF

if ( threadRunning )
{
threadQuit = 1;
if ( pthread_join(thread, &thread_return) )
fwrite("fluidsynth pthread_join returned error\n", 1uLL, 0x27uLL, stderr);
threadRunning = 0;
}
}

original_code:
void FluidSynthDrv_MIDI_HaltPlayback(void)
{
    void * ret;
    if (!threadRunning) {
        return;
    }
    threadQuit = 1;
    if (pthread_join(thread, &ret)) {
        fprintf(stderr, "fluidsynth pthread_join returned error\n");
    }
    threadRunning = 0;
}

canonical_original_code:
void FluidSynthDrv_MIDI_HaltPlayback()
{
    void *ret;
    if (!threadRunning) {
        return;
    }
    threadQuit = 1;
    if (pthread_join(thread, &ret)) {
        fprintf(stderr, "fluidsynth pthread_join returned error\n");
    }
    threadRunning = 0;
}

variable_types:
ret
void *


decompiled_code:
int __fastcall FluidSynthDrv_MIDI_StartPlayback(__int64 (*a1)(void))
{
int result; // eax

FluidSynthDrv_MIDI_HaltPlayback();
threadService = a1;
threadQuit = 0;
result = pthread_create(&thread, 0LL, threadProc, 0LL);
if ( result )
{
fwrite("fluidsynth pthread_create returned error\n", 1uLL, 0x29uLL, stderr);
result = 9;
}
else
{
threadRunning = 1;
}
return result;
}

canonical_decompiled_code:
int __fastcall func14(__int64 (*a1)(void))
{
int result; // eax

func13();
threadService = a1;
threadQuit = 0;
result = pthread_create(&thread, 0LL, threadProc, 0LL);
if ( result )
{
fwrite("fluidsynth pthread_create returned error\n", 1uLL, 0x29uLL, stderr);
result = 9;
}
else
{
threadRunning = 1;
}
return result;
}

original_code:
int FluidSynthDrv_MIDI_StartPlayback(void (*service)(void))
{
    FluidSynthDrv_MIDI_HaltPlayback();
    threadService = service;
    threadQuit = 0;
    if (pthread_create(&thread, ((void *)0), threadProc, ((void *)0))) {
        fprintf(stderr, "fluidsynth pthread_create returned error\n");
        return FSynthErr_PlayThread;
    }
    threadRunning = 1;
    return 0;
}

canonical_original_code:
int FluidSynthDrv_MIDI_StartPlayback(void (*service)())
{
    FluidSynthDrv_MIDI_HaltPlayback();
    threadService = service;
    threadQuit = 0;
    if (pthread_create(&thread, ((void *)0), threadProc, ((void *)0))) {
        fprintf(stderr, "fluidsynth pthread_create returned error\n");
        return FSynthErr_PlayThread;
    }
    threadRunning = 1;
    return 0;
}

variable_types:
service
void (*)()


decompiled_code:
__int64 __fastcall FluidSynthDrv_MIDI_SetTempo(int a1, int a2)
{
double v2; // xmm0_8
__m128d v3; // xmm3
__m128d v4; // xmm1
__int64 result; // rax

fluid_sequencer_set_time_scale(fluidsequencer);
v2 = (double)a1 * (double)a2 / 60.0 / 20.0;
v3.m128d_f64[0] = v2;
if ( COERCE_DOUBLE(*(_QWORD *)&v2 & LC20) < 4.503599627370496e15 )
{
v4.m128d_f64[0] = (double)(int)v2;
*(_QWORD *)&v3.m128d_f64[0] = COERCE_UNSIGNED_INT64(COERCE_DOUBLE(*(_OWORD *)&_mm_cmpgt_sd(v3, v4) & LC21) + v4.m128d_f64[0]) | ~LC20 & *(_QWORD *)&v2;
}
result = (unsigned int)(int)v3.m128d_f64[0];
threadQueueTicks = (int)v3.m128d_f64[0];
return result;
}

canonical_decompiled_code:
__int64 __fastcall func15(int a1, int a2)
{
double v2; // xmm0_8
__m128d v3; // xmm3
__m128d v4; // xmm1
__int64 result; // rax

fluid_sequencer_set_time_scale(fluidsequencer);
v2 = (double)a1 * (double)a2 / 60.0 / 20.0;
v3.m128d_f64[0] = v2;
if ( COERCE_DOUBLE(*(_QWORD *)&v2 & LC20) < 4.503599627370496e15 )
{
v4.m128d_f64[0] = (double)(int)v2;
*(_QWORD *)&v3.m128d_f64[0] = COERCE_UNSIGNED_INT64(COERCE_DOUBLE(*(_OWORD *)&_mm_cmpgt_sd(v3, v4) & LC21) + v4.m128d_f64[0]) | ~LC20 & *(_QWORD *)&v2;
}
result = (unsigned int)(int)v3.m128d_f64[0];
threadQueueTicks = (int)v3.m128d_f64[0];
return result;
}

original_code:
void FluidSynthDrv_MIDI_SetTempo(int tempo, int division)
{
    double tps;
    tps = ( (double) tempo * (double) division ) / 60.0;
    fluid_sequencer_set_time_scale(fluidsequencer, tps);
    threadQueueTicks = (int) ceil(tps / (double) 20);
}

variable_types: tempo int

variable_types: division int

variable_types: tps double


decompiled_code:
void FluidSynthDrv_MIDI_Lock()
{
;
}

canonical_decompiled_code:
void func16()
{
;
}

original_code:
void FluidSynthDrv_MIDI_Lock(void)
{
}

canonical_original_code:
void FluidSynthDrv_MIDI_Lock()
{
}


decompiled_code:
void FluidSynthDrv_MIDI_Unlock()
{
;
}

original_code:
void FluidSynthDrv_MIDI_Unlock(void)
{
}

canonical_original_code:
void FluidSynthDrv_MIDI_Unlock()
{
}


decompiled_code:
size_t sequence_event()
{
size_t result; // rax

result = fluid_sequencer_send_at(fluidsequencer, fluidevent, (unsigned int)threadTimer, 1LL);
if ( (result & 0x80000000) != 0LL )
result = fwrite("fluidsynth could not queue event\n", 1uLL, 0x21uLL, stderr);
return result;
}

canonical_decompiled_code:
size_t func0()
{
size_t result; // rax

result = fluid_sequencer_send_at(fluidsequencer, fluidevent, (unsigned int)threadTimer, 1LL);
if ( (result & 0x80000000) != 0LL )
result = fwrite("fluidsynth could not queue event\n", 1uLL, 0x21uLL, stderr);
return result;
}

original_code:
static inline void sequence_event(void)
{
    int result = 0;
    result = fluid_sequencer_send_at(fluidsequencer, fluidevent, threadTimer, 1);
    if (result < 0) {
        fprintf(stderr, "fluidsynth could not queue event\n");
    }
}

canonical_original_code:
static inline void sequence_event()
{
    int result = 0;
    result = fluid_sequencer_send_at(fluidsequencer, fluidevent, threadTimer, 1);
    if (result < 0) {
        fprintf(stderr, "fluidsynth could not queue event\n");
    }
}


decompiled_code:
size_t __fastcall Func_PitchBend(unsigned int a1, int a2, int a3)
{
fluid_event_pitch_bend(fluidevent, a1, a2 | (unsigned int)(a3 << 7));
return sequence_event();
}

canonical_decompiled_code:
size_t __fastcall func1(unsigned int a1, int a2, int a3)
{
fluid_event_pitch_bend(fluidevent, a1, a2 | (unsigned int)(a3 << 7));
return func0();
}

original_code:
static void Func_PitchBend( int channel, int lsb, int msb )
{
    fluid_event_pitch_bend(fluidevent, channel, lsb | (msb << 7));
    sequence_event();
}

canonical_original_code:
static void Func_PitchBend(int channel, int lsb, int msb)
{
    fluid_event_pitch_bend(fluidevent, channel, lsb | (msb << 7));
    sequence_event();
}

variable_types: channel int

variable_types: lsb int

variable_types: msb int


decompiled_code:
int __fastcall Func_ChannelAftertouch(unsigned int a1)
{
return fprintf(stderr, "fluidsynth channel %d aftertouch\n", a1);
}

canonical_decompiled_code:
int __fastcall func2(unsigned int a1)
{
return fprintf(stderr, "fluidsynth channel %d aftertouch\n", a1);
}

original_code:
static void Func_ChannelAftertouch( int channel, int pressure )
{
    fprintf(stderr, "fluidsynth channel %d aftertouch\n", channel);
}

canonical_original_code:
static void Func_ChannelAftertouch(int channel, int pressure)
{
    fprintf(stderr, "fluidsynth channel %d aftertouch\n", channel);
}

variable_types: pressure int


decompiled_code:
int __fastcall Func_PolyAftertouch(unsigned int a1, unsigned int a2)
{
return fprintf(stderr, "fluidsynth key %d channel %d aftertouch\n", a2, a1);
}

canonical_decompiled_code:
int __fastcall func3(unsigned int a1, unsigned int a2)
{
return fprintf(stderr, "fluidsynth key %d channel %d aftertouch\n", a2, a1);
}

original_code:
static void Func_PolyAftertouch( int channel, int key, int pressure )
{
    fprintf(stderr, "fluidsynth key %d channel %d aftertouch\n", key, channel);
}

canonical_original_code:
static void Func_PolyAftertouch(int channel, int key, int pressure)
{
    fprintf(stderr, "fluidsynth key %d channel %d aftertouch\n", key, channel);
}

variable_types: key int


decompiled_code:
size_t __fastcall Func_ProgramChange(unsigned int a1, __int16 a2)
{
fluid_event_program_change(fluidevent, a1, (unsigned int)a2);
return sequence_event();
}

canonical_decompiled_code:
size_t __fastcall func4(unsigned int a1, __int16 a2)
{
fluid_event_program_change(fluidevent, a1, (unsigned int)a2);
return func0();
}

original_code:
static void Func_ProgramChange( int channel, int program )
{
    fluid_event_program_change(fluidevent, channel, program);
    sequence_event();
}

canonical_original_code:
static void Func_ProgramChange(int channel, int program)
{
    fluid_event_program_change(fluidevent, channel, program);
    sequence_event();
}

variable_types: program int


decompiled_code:
size_t __fastcall Func_ControlChange(unsigned int a1, __int16 a2, __int16 a3)
{
fluid_event_control_change(fluidevent, a1, (unsigned int)a2, (unsigned int)a3);
return sequence_event();
}

canonical_decompiled_code:
size_t __fastcall func5(unsigned int a1, __int16 a2, __int16 a3)
{
fluid_event_control_change(fluidevent, a1, (unsigned int)a2, (unsigned int)a3);
return func0();
}

original_code:
static void Func_ControlChange( int channel, int number, int value )
{
    fluid_event_control_change(fluidevent, channel, number, value);
    sequence_event();
}

canonical_original_code:
static void Func_ControlChange(int channel, int number, int value)
{
    fluid_event_control_change(fluidevent, channel, number, value);
    sequence_event();
}

variable_types: number int

variable_types: value int


decompiled_code:
size_t __fastcall Func_NoteOn(unsigned int a1, __int16 a2, __int16 a3)
{
fluid_event_noteon(fluidevent, a1, (unsigned int)a2, (unsigned int)a3);
return sequence_event();
}

canonical_decompiled_code:
size_t __fastcall func6(unsigned int a1, __int16 a2, __int16 a3)
{
fluid_event_noteon(fluidevent, a1, (unsigned int)a2, (unsigned int)a3);
return func0();
}

original_code:
static void Func_NoteOn( int channel, int key, int velocity )
{
    fluid_event_noteon(fluidevent, channel, key, velocity);
    sequence_event();
}

canonical_original_code:
static void Func_NoteOn(int channel, int key, int velocity)
{
    fluid_event_noteon(fluidevent, channel, key, velocity);
    sequence_event();
}

variable_types: velocity int


decompiled_code:
size_t __fastcall Func_NoteOff(unsigned int a1, __int16 a2)
{
fluid_event_noteoff(fluidevent, a1, (unsigned int)a2);
return sequence_event();
}

canonical_decompiled_code:
size_t __fastcall func7(unsigned int a1, __int16 a2)
{
fluid_event_noteoff(fluidevent, a1, (unsigned int)a2);
return func0();
}

original_code:
static void Func_NoteOff( int channel, int key, int velocity )
{
    fluid_event_noteoff(fluidevent, channel, key);
    sequence_event();
}

canonical_original_code:
static void Func_NoteOff(int channel, int key, int velocity)
{
    fluid_event_noteoff(fluidevent, channel, key);
    sequence_event();
}


decompiled_code:
void *__fastcall threadProc(void *a1)
{
unsigned int v1; // ecx
int v2; // eax
struct timeval v4; // [rsp+0h] [rbp-28h] BYREF

threadTimer = fluid_sequencer_get_tick(fluidsequencer);
for ( threadQueueTimer = threadQueueTicks + threadTimer; threadTimer < (unsigned int)threadQueueTimer; ++threadTimer )
{
if ( threadService )
threadService();
}
LABEL_2:
v1 = 50000;
while ( !threadQuit )
{
v4.tv_sec = 0LL;
v4.tv_usec = v1;
select(0, 0LL, 0LL, 0LL, &v4);
v2 = fluid_sequencer_get_tick(fluidsequencer);
v1 = 25000;
if ( threadTimer - v2 <= threadQueueTicks )
{
for ( threadQueueTimer = threadQueueTicks + v2; threadTimer < (unsigned int)threadQueueTimer; ++threadTimer )
{
if ( threadService )
threadService();
}
goto LABEL_2;
}
}
return 0LL;
}

canonical_decompiled_code:
void *__fastcall func8(void *a1)
{
unsigned int v1; // ecx
int v2; // eax
struct timeval v4; // [rsp+0h] [rbp-28h] BYREF

threadTimer = fluid_sequencer_get_tick(fluidsequencer);
for ( threadQueueTimer = threadQueueTicks + threadTimer; threadTimer < (unsigned int)threadQueueTimer; ++threadTimer )
{
if ( threadService )
threadService();
}
LABEL_2:
v1 = 50000;
while ( !threadQuit )
{
v4.tv_sec = 0LL;
v4.tv_usec = v1;
select(0, 0LL, 0LL, 0LL, &v4);
v2 = fluid_sequencer_get_tick(fluidsequencer);
v1 = 25000;
if ( threadTimer - v2 <= threadQueueTicks )
{
for ( threadQueueTimer = threadQueueTicks + v2; threadTimer < (unsigned int)threadQueueTimer; ++threadTimer )
{
if ( threadService )
threadService();
}
goto LABEL_2;
}
}
return 0LL;
}

original_code:
static void * threadProc(void * parm)
{
    struct timeval tv;
    int sleepAmount = 1000000 / 20;
    unsigned int sequenceTime;
    threadTimer = fluid_sequencer_get_tick(fluidsequencer);
    threadQueueTimer = threadTimer + threadQueueTicks;
    while (threadTimer < threadQueueTimer) {
        if (threadService) {
            threadService();
        }
        threadTimer++;
    }
    while (!threadQuit) {
        tv.tv_sec = 0;
        tv.tv_usec = sleepAmount;
        select(0, ((void *)0), ((void *)0), ((void *)0), &tv);
        sequenceTime = fluid_sequencer_get_tick(fluidsequencer);
        sleepAmount = 1000000 / 20;
        if ((int)(threadTimer - sequenceTime) > threadQueueTicks) {
            sleepAmount /= 2;
            continue;
        }
        threadQueueTimer = sequenceTime + threadQueueTicks;
        while (threadTimer < threadQueueTimer) {
            if (threadService) {
                threadService();
            }
            threadTimer++;
        }
    }
    return ((void *)0);
}

canonical_original_code:
static void *threadProc(void *parm)
{
    struct timeval tv;
    int sleepAmount = 1000000 / 20;
    unsigned int sequenceTime;
    threadTimer = fluid_sequencer_get_tick(fluidsequencer);
    threadQueueTimer = threadTimer + threadQueueTicks;
    while (threadTimer < threadQueueTimer) {
        if (threadService) {
            threadService();
        }
        threadTimer++;
    }
    while (!threadQuit) {
        tv.tv_sec = 0;
        tv.tv_usec = sleepAmount;
        select(0, ((void *)0), ((void *)0), ((void *)0), &tv);
        sequenceTime = fluid_sequencer_get_tick(fluidsequencer);
        sleepAmount = 1000000 / 20;
        if ((int)(threadTimer - sequenceTime) > threadQueueTicks) {
            sleepAmount /= 2;
            continue;
        }
        threadQueueTimer = sequenceTime + threadQueueTicks;
        while (threadTimer < threadQueueTimer) {
            if (threadService) {
                threadService();
            }
            threadTimer++;
        }
    }
    return ((void *)0);
}

variable_types:
parm
void *

variable_types: struct timeval { long tv_sec; long tv_usec; }

variable_types: sleepAmount int

variable_types:
sequenceTime
unsigned int


decompiled_code:
int __fastcall ASS_Sleep(int a1)
{
struct timeval v2; // [rsp+0h] [rbp-18h] BYREF

v2.tv_sec = a1 / 1000;
v2.tv_usec = 1000 * (a1 % 1000);
return select(0, 0LL, 0LL, 0LL, &v2);
}

canonical_decompiled_code:
int __fastcall func0(int a1)
{
struct timeval v2; // [rsp+0h] [rbp-18h] BYREF

v2.tv_sec = a1 / 1000;
v2.tv_usec = 1000 * (a1 % 1000);
return select(0, 0LL, 0LL, 0LL, &v2);
}

original_code:
void ASS_Sleep(int msec)
{
 struct timeval tv;
 tv.tv_sec = msec / 1000;
 tv.tv_usec = (msec % 1000) * 1000;
 select(0, ((void *)0), ((void *)0), ((void *)0), &tv);
}

variable_types: msec int

user_defined_types: struct timeval { long tv_sec; long tv_usec; }


original_code:
unsigned long PITCH_GetScale
   (
   int pitchoffset
   )
   {
   unsigned long scale;
   int octaveshift;
   int noteshift;
   int note;
   int detune;
   if ( pitchoffset == 0 )
      {
      return( PitchTable[ 0 ][ 0 ] );
      }
   noteshift = pitchoffset % 1200;
   if ( noteshift < 0 )
      {
      noteshift += 1200;
      }
   note = noteshift / 100;
   detune = ( noteshift % 100 ) / ( 100 / 25 );
   octaveshift = ( pitchoffset - noteshift ) / 1200;
   if ( detune < 0 )
      {
      detune += ( 100 / 25 );
      note--;
      if ( note < 0 )
         {
         note += 12;
         octaveshift--;
         }
      }
   scale = PitchTable[ note ][ detune ];
   if ( octaveshift < 0 )
      {
      scale >>= -octaveshift;
      }
   else
      {
      scale <<= octaveshift;
      }
   return( scale );
   }

canonical_original_code:
unsigned long PITCH_GetScale(int pitchoffset)
   {
   unsigned long scale;
   int octaveshift;
   int noteshift;
   int note;
   int detune;
   if ( pitchoffset == 0 )
      {
      return( PitchTable[ 0 ][ 0 ] );
      }
   noteshift = pitchoffset % 1200;
   if ( noteshift < 0 )
      {
      noteshift += 1200;
      }
   note = noteshift / 100;
   detune = ( noteshift % 100 ) / ( 100 / 25 );
   octaveshift = ( pitchoffset - noteshift ) / 1200;
   if ( detune < 0 )
      {
      detune += ( 100 / 25 );
      note--;
      if ( note < 0 )
         {
         note += 12;
         octaveshift--;
         }
      }
   scale = PitchTable[ note ][ detune ];
   if ( octaveshift < 0 )
      {
      scale >>= -octaveshift;
      }
   else
      {
      scale <<= octaveshift;
      }
   return( scale );
   }

variable_types: pitchoffset int

variable_types:
scale
unsigned long

variable_types: octaveshift int

variable_types: noteshift int

variable_types: note int

variable_types: detune int

return_type: unsigned long


findx

repo: Terminus-IMRC/DependOn

decompiled_code:
__int64 __fastcall findx(_BYTE *a1)
{
const unsigned __int16 *v2; // rcx
char v3; // dl
unsigned int v4; // esi

v2 = *__ctype_b_loc();
v3 = 0;
v4 = 0;
do
{
if ( (v2[(char)*a1] & 0x800) != 0 )
{
if ( !v3 )
{
++v4;
v3 = 1;
}
}
else
{
v3 = 0;
}
++a1;
}
while ( *a1 );
return v4;
}

canonical_decompiled_code:
__int64 __fastcall func7(_BYTE *a1)
{
const unsigned __int16 *v2; // rcx
char v3; // dl
unsigned int v4; // esi

v2 = *__ctype_b_loc();
v3 = 0;
v4 = 0;
do
{
if ( (v2[(char)*a1] & 0x800) != 0 )
{
if ( !v3 )
{
++v4;
v3 = 1;
}
}
else
{
v3 = 0;
}
++a1;
}
while ( *a1 );
return v4;
}

original_code:
int findx(char* str)
{
 int numcont=0;
 _Bool priortype=0;
 do{
  if(((*__ctype_b_loc ())[(int) (((int)*str))] & (unsigned short int) _ISdigit)){
   if(!priortype)
    numcont++;
   priortype=1;
  }else
   priortype=0;
 }while(*++str);
 return numcont;
}

canonical_original_code:
int findx(char *str)
{
 int numcont = 0;
 _Bool priortype = 0;
 do{
  if(((*__ctype_b_loc ())[(int) (((int)*str))] & (unsigned short) _ISdigit)){
   if(!priortype)
    numcont++;
   priortype=1;
  }else
   priortype=0;
 }while(*++str);
 return numcont;
}

variable_types:
str
char *

variable_types: numcont int


separ

decompiled_code:
void __fastcall separ(__int64 a1, char *a2)
{
__int64 v2; // rbx
char *nptr; // [rsp+8h] [rbp-20h] BYREF

nptr = a2;
if ( X > 0 )
{
v2 = 0LL;
do
*(_DWORD *)(a1 + 4 * v2++) = strtol(nptr, &nptr, 10);
while ( X > (int)v2 );
}
}

canonical_decompiled_code:
void __fastcall func8(__int64 a1, char *a2)
{
__int64 v2; // rbx
char *nptr; // [rsp+8h] [rbp-20h] BYREF

nptr = a2;
if ( X > 0 )
{
v2 = 0LL;
do
*(_DWORD *)(a1 + 4 * v2++) = strtol(nptr, &nptr, 10);
while ( X > (int)v2 );
}
}

original_code:
void separ(int* c, char* str)
{
 int i;
 for(i=0; i<X; i++)
  c[i]=(int)strtol(str, &str, 10);
 return;
}

canonical_original_code:
void separ(int *c, char *str)
{
 int i;
 for(i=0; i<X; i++)
  c[i]=(int)strtol(str, &str, 10);
 return;
}

variable_types:
c
int *

variable_types: i int


DependOn

original_code:
void DependOn(int* ar, int place, int_fast8_t* dned)
{
 int i, j;
 int cnt=0;
 int cabricnt=0;
 for(i=0; i<Ceilings; i++)
  dned[i]=0;
 for(i=0; i<X; i++)
  dned[ar[i+place*X]]=1;
 for(i=place+1; i<ple; i++){
  for(j=0; j<X; j++)
   if(dned[ar[j+i*X]])
    cabricnt++;
  if(cabricnt==X%2){
   cnt++;
   for(j=0; j<X; j++)
    fprintf(fp, "%3d", ar[j+i*X]);
   fputc('\n', fp);
  }
  cabricnt=0;
 }
 sum+=cnt;
 return;
}

canonical_original_code:
void DependOn(int *ar, int place, char *dned)
{
 int i; int j;
 int cnt = 0;
 int cabricnt = 0;
 for(i=0; i<Ceilings; i++)
  dned[i]=0;
 for(i=0; i<X; i++)
  dned[ar[i+place*X]]=1;
 for(i=place+1; i<ple; i++){
  for(j=0; j<X; j++)
   if(dned[ar[j+i*X]])
    cabricnt++;
  if(cabricnt==X%2){
   cnt++;
   for(j=0; j<X; j++)
    fprintf(fp, "%3d", ar[j+i*X]);
   fputc('\n', fp);
  }
  cabricnt=0;
 }
 sum+=cnt;
 return;
}

variable_types:
ar
int *

variable_types: place int

variable_types:
dned
char *

variable_types: j int

variable_types: cnt int

variable_types: cabricnt int


main

canonical_name: main

repo: Terminus-IMRC/detect-endian

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
_WORD v4[8]; // [rsp+0h] [rbp-108h] BYREF
char v5[232]; // [rsp+10h] [rbp-F8h] BYREF
int v6; // [rsp+F8h] [rbp-10h]
__int16 v7; // [rsp+FCh] [rbp-Ch]
char v8; // [rsp+FEh] [rbp-Ah]

v4[7] = 0;
memset(v5, 0, sizeof(v5));
v6 = 0;
v7 = 0;
v8 = 0;
strcpy((char *)v4, "Little endian");
puts((const char *)v4);
return 0;
}

original_code:
int main()
{
 char str[0xff]="";
 switch(1234){
  case 1234:
   strcpy(str, "Little endian");
   break;
  case 4321:
   strcpy(str, "Big endian");
   break;
  case 3412:
   strcpy(str, "PDP endian");
   break;
  default:
   strcpy(str, "Unknown endian");
   break;
 }
 printf("%s\n", str);
 return 0;
}

canonical_original_code:
int main()
{
 char str[255] = "";
 switch(1234){
  case 1234:
   strcpy(str, "Little endian");
   break;
  case 4321:
   strcpy(str, "Big endian");
   break;
  case 3412:
   strcpy(str, "PDP endian");
   break;
  default:
   strcpy(str, "Unknown endian");
   break;
 }
 printf("%s\n", str);
 return 0;
}

variable_types:
str
char [255]


repo: Terminus-IMRC/rotdash

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int result; // eax
int i; // ebx
int v5; // ebp
int v6; // er12
unsigned int v7; // ebx
int v8[11]; // [rsp+Ch] [rbp-2Ch]

v8[0] = 1546465148;
result = 1;
if ( argc == 2 )
{
chdir("/proc");
for ( i = 0; ; i = v6 )
{
v5 = access(argv[1], 0);
if ( v5 )
break;
v6 = i + 1;
v7 = *((char *)v8 + i);
printf("%c\b", v7);
if ( v6 == 4 )
{
printf(".%c\b", v7);
v6 = v5;
}
fflush(_bss_start);
usleep(0x186A0u);
}
puts(".");
result = 0;
}
return result;
}

original_code:
int main(int argc, char *argv[])
{
    const char arr[] = { '|', '/', '-', '\\' };
    if (argc != 2)
 return 1;
    chdir("/proc");
    argc = 0;
    while (!access(argv[1], 0)) {
 printf("%c\b", arr[argc++]);
 if (argc == sizeof(arr)) {
     printf(".%c\b", arr[argc - 1]);
     argc = 0;
 }
 fflush(stdout);
 usleep(100000);
    }
    puts(".");
    return 0;
}

canonical_original_code:
int main(int argc, char *argv[])
{
    char arr[] = { '|', '/', '-', '\\' };
    if (argc != 2)
 return 1;
    chdir("/proc");
    argc = 0;
    while (!access(argv[1], 0)) {
 printf("%c\b", arr[argc++]);
 if (argc == sizeof(arr)) {
     printf(".%c\b", arr[argc - 1]);
     argc = 0;
 }
 fflush(stdout);
 usleep(100000);
    }
    puts(".");
    return 0;
}

variable_types: argc int

variable_types:
argv
char *[]

variable_types:
arr
char []


repo: Terminus-IMRC/sc

decompiled_code:
int __fastcall sc_output(int a1, __int64 a2)
{
int i; // eax

printf("%d", (unsigned int)a1);
sc_i = 0;
if ( a1 > 0 )
{
for ( i = 0; i < a1; sc_i = i )
{
printf("%3d", *(unsigned int *)(a2 + 4LL * i));
i = sc_i + 1;
}
}
return putchar(10);
}

canonical_decompiled_code:
int __fastcall func7(int a1, __int64 a2)
{
int i; // eax

printf("%d", (unsigned int)a1);
sc_i = 0;
if ( a1 > 0 )
{
for ( i = 0; i < a1; sc_i = i )
{
printf("%3d", *(unsigned int *)(a2 + 4LL * i));
i = sc_i + 1;
}
}
return putchar(10);
}

original_code:
void sc_output(int sc_length, int *sc_path){
  printf("%d",sc_length);
  for(sc_i = 0; sc_i<sc_length; ++sc_i){printf("%3d",sc_path[sc_i]);
 }printf("\n");}


decompiled_code:
int reinit_all()
{
__int64 i; // rbx
char *v1; // rax
int result; // eax
char v3[40]; // [rsp+0h] [rbp-28h] BYREF

for ( i = 0LL; i != 20; ++i )
{
v1 = fgets(v3, 32, stdin);
result = atoi(v1);
q[i] = result;
step[i] = 0;
}
rcont = 0;
return result;
}

canonical_decompiled_code:
int func8()
{
__int64 i; // rbx
char *v1; // rax
int result; // eax
char v3[40]; // [rsp+0h] [rbp-28h] BYREF

for ( i = 0LL; i != 20; ++i )
{
v1 = fgets(v3, 32, stdin);
result = atoi(v1);
q[i] = result;
step[i] = 0;
}
rcont = 0;
return result;
}

original_code:
void reinit_all()
{
 int i;
 char str[32];
 for(i=0; i<20; i++){
  q[i]=atoi(fgets(str, 32, stdin));
  step[i]=0;
 }
 rcont=0;
 return;
}

variable_types:
str
char [32]


crosschannel

decompiled_code:
__int64 __fastcall crosschannel(int a1)
{
int v1; // eax
__int64 result; // rax

v1 = rcont++;
route[v1] = a1;
if ( a1 == 19 )
longjmp(jb, 1);
result = crosschannel_header_l2();
--rcont;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func9(int a1)
{
int v1; // eax
__int64 result; // rax

v1 = rcont++;
route[v1] = a1;
if ( a1 == 19 )
longjmp(jb, 1);
result = func10();
--rcont;
return result;
}

original_code:
void crosschannel(int m)
{
 route[rcont++]=m;
 if(m==20 -1)
  longjmp(jb, 1);
 crosschannel_header_l2(m);
 rcont--;
 return;
}

variable_types: m int


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v4; // [rsp+Ch] [rbp-Ch]

v4 = 5;
do
{
reinit_all();
if ( !_setjmp(jb) )
crosschannel(0);
sc_output(rcont, (__int64)route);
--v4;
}
while ( v4 );
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v4; // [rsp+Ch] [rbp-Ch]

v4 = 5;
do
{
func8();
if ( !_setjmp(jb) )
func9(0);
func7(rcont, (__int64)route);
--v4;
}
while ( v4 );
return 0;
}

original_code:
int main()
{
 int i;
 for(i=0; i<5; i++){
  reinit_all();
  if(!_setjmp (jb))
   crosschannel(0);
  sc_output(rcont, route);
 }
 return 0;
}


decompiled_code:
__int64 __fastcall crosschannel_header_l2(int a1)
{
int v2; // esi
int v3; // edi
int v4; // ebx
__int64 result; // rax

v2 = q[a1];
v3 = (v2 + a1) % 20;
v4 = (a1 - v2 + 20) % 20;
result = v3;
if ( !step[v3] )
{
step[v3] = 1;
crosschannel(v3);
step[v3] = 0;
result = v4;
if ( !step[v4] )
{
step[v4] = 1;
result = crosschannel(v4);
step[v4] = 0;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func10(int a1)
{
int v2; // esi
int v3; // edi
int v4; // ebx
__int64 result; // rax

v2 = q[a1];
v3 = (v2 + a1) % 20;
v4 = (a1 - v2 + 20) % 20;
result = v3;
if ( !step[v3] )
{
step[v3] = 1;
func9(v3);
step[v3] = 0;
result = v4;
if ( !step[v4] )
{
step[v4] = 1;
result = func9(v4);
step[v4] = 0;
}
}
return result;
}

original_code:
void crosschannel_header_l2(int m)
{
 int i;
 int ideal[2];
 ideal[0]=(m+q[m])%20;
 ideal[1]=(m-q[m]+20)%20;
 for(i=0; i<2; i++){
  if(step[ideal[i]])
   return;
  step[ideal[i]]=1;
  crosschannel(ideal[i]);
  step[ideal[i]]=0;
 }
 return;
}

variable_types:
ideal
int [2]


repo: Tesian/lock

decompiled_code:
_BOOL8 __fastcall my_manage_password(int a1, char a2, const char *a3)
{
_BOOL8 result; // rax
int v5; // eax
const char *v6; // rax

result = 1LL;
if ( c_2 != a2 )
{
if ( a1 == 27 )
{
my_memset(pass_enter_1, 63LL, 0LL);
i_0 = -1;
result = 1LL;
}
else if ( a1 == 8 )
{
result = 1LL;
if ( i_0 >= 0 )
--i_0;
}
else
{
c_2 = a2;
result = 1LL;
if ( a2 )
{
v5 = i_0;
if ( i_0 <= 61 )
{
++i_0;
pass_enter_1[v5 + 1] = a2;
}
result = 1LL;
if ( a1 == 13 )
{
pass_enter_1[i_0] = 0;
v6 = (const char *)my_crypt(pass_enter_1);
result = strcmp(a3, v6) != 0;
}
}
}
}
return result;
}

canonical_decompiled_code:
_BOOL8 __fastcall func0(int a1, char a2, const char *a3)
{
_BOOL8 result; // rax
int v5; // eax
const char *v6; // rax

result = 1LL;
if ( c_2 != a2 )
{
if ( a1 == 27 )
{
my_memset(pass_enter_1, 63LL, 0LL);
i_0 = -1;
result = 1LL;
}
else if ( a1 == 8 )
{
result = 1LL;
if ( i_0 >= 0 )
--i_0;
}
else
{
c_2 = a2;
result = 1LL;
if ( a2 )
{
v5 = i_0;
if ( i_0 <= 61 )
{
++i_0;
pass_enter_1[v5 + 1] = a2;
}
result = 1LL;
if ( a1 == 13 )
{
pass_enter_1[i_0] = 0;
v6 = (const char *)my_crypt(pass_enter_1);
result = strcmp(a3, v6) != 0;
}
}
}
}
return result;
}

original_code:
int my_manage_password(int key, unsigned char unicode, char *pass)
{
  static int i = -1;
  static char pass_enter[64];
  int ret = 1;
  static unsigned char c = 0;
  char *pass_enter_crypt;
  if (c == unicode)
    return (1);
  if (key == SDLK_ESCAPE)
    {
      my_memset(pass_enter, 63, '\0');
      i = -1;
      return (1);
    }
  if (key == SDLK_BACKSPACE)
    {
      if (i > -1)
 i--;
      return (1);
    }
  if ((c = unicode) != 0)
    {
      if (i < 62)
 pass_enter[++i] = c;
      if (key == SDLK_RETURN)
 {
   pass_enter[i] = '\0';
   pass_enter_crypt = my_crypt(pass_enter);
   if (strcmp(pass, pass_enter_crypt) == 0)
     ret = 0;
 }
    }
  return (ret);
}

variable_types: key int

variable_types:
unicode
unsigned char

variable_types:
pass
char *

variable_types: ret int

variable_types:
c
unsigned char


decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned int v3; // eax
char v4; // bp

v3 = time(0LL);
srand(v3);
v4 = my_pars_sort(argv);
if ( argc == 2 )
{
if ( !(unsigned int)my_strcmp(argv[1], "-h") )
{
my_putstr(&unk_370);
return 0;
}
}
else if ( argc == 3 && !(unsigned int)my_strcmp(argv[1], "-p") )
{
make_password(argv[2]);
return 0;
}
my_lock(argc, (__int64)argv, v4);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned int v3; // eax
char v4; // bp

v3 = time(0LL);
srand(v3);
v4 = my_pars_sort(argv);
if ( argc == 2 )
{
if ( !(unsigned int)my_strcmp(argv[1], "-h") )
{
my_putstr(&unk_370);
return 0;
}
}
else if ( argc == 3 && !(unsigned int)my_strcmp(argv[1], "-p") )
{
make_password(argv[2]);
return 0;
}
func2(argc, (__int64)argv, v4);
return 0;
}

original_code:
int main(int argc, char **argv)
{
  char sort;
  srand(time(((void *)0)));
  sort = my_pars_sort(argv);
  if (argc == 2 && my_strcmp(argv[1], "-h") == 0)
    my_putstr("\nHelp lock:\n     le password doit faire moins de 60 caractères, liste des caractères\n     autorisés : azertyuiopqsdfghjklmwxcvbnAZERTYUIOPQSDFGHJKLMWXCVBN\n     123456789&\"'(-_)=/*-+$%!:/;.,?~#{[|`\\@]}\nlock lance le lock avec les images contenues dans le dossier par default\n     (voir lock.h)\n-h   affiche ce récapitulatif.\n-p   \"password\" remplace le password courant par \"password\".\n     lock dir1 dir2 dir3 lance le lock avec les images contenues dans les 3\n     dossiers.\n\nOptions de tris des images :\n           tri par default \"vrai aléatoire\" une images peut se répéter\n           deux fois (chaque fois une images et choisi aux hasards dans \n           l'ensemble des images).\n-t.rand    random organisé une images ne peut pas se répéter deux fois (une \n           liste est fait au départ qui met les images dans le désordre).\n-t.alpha   tri alphaphabétiques.\n-t.numeric tri numérique.\n\n");
  else if (argc == 3 && my_strcmp(argv[1], "-p") == 0)
    make_password(argv[2]);
  else
    my_lock(argc, argv, sort);
  return (0);
}

variable_types:
argv
char **

variable_types: sort char