decompiled_code:
__int64 __fastcall filename_to_utf8_nofail(__int64 a1)
{
__int64 result; // rax

result = g_filename_to_utf8(a1, -1LL, 0LL, 0LL, 0LL);
if ( !result )
result = g_strdup(a1);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func8(__int64 a1)
{
__int64 result; // rax

result = g_filename_to_utf8(a1, -1LL, 0LL, 0LL, 0LL);
if ( !result )
result = g_strdup(a1);
return result;
}

original_code:
gchar *filename_to_utf8_nofail( const gchar *path )
{
    gchar *file_path_utf8;
    file_path_utf8 = g_filename_to_utf8( path, -1, ((void *)0), ((void *)0), ((void *)0) );
    if( ! file_path_utf8 )
    {
        file_path_utf8 = g_strdup( path );
    }
    return file_path_utf8;
}

canonical_original_code:
char *filename_to_utf8_nofail(char *path)
{
    char *file_path_utf8;
    file_path_utf8 = g_filename_to_utf8( path, -1, ((void *)0), ((void *)0), ((void *)0) );
    if( ! file_path_utf8 )
    {
        file_path_utf8 = g_strdup( path );
    }
    return file_path_utf8;
}

variable_types:
path
char *


repo: Tblue/sessionchooser

decompiled_code:
__int64 __fastcall ptr_array_copy(__int64 a1)
{
__int64 v1; // rbx

v1 = g_ptr_array_new_full(*(unsigned int *)(a1 + 8));
g_ptr_array_foreach(a1, ptr_array_copy_cb, v1);
return v1;
}

canonical_decompiled_code:
__int64 __fastcall func9(__int64 a1)
{
__int64 v1; // rbx

v1 = g_ptr_array_new_full(*(unsigned int *)(a1 + 8));
g_ptr_array_foreach(a1, ptr_array_copy_cb, v1);
return v1;
}

original_code:
GPtrArray *ptr_array_copy( GPtrArray *src, GDestroyNotify free_func )
{
    GPtrArray *dest = g_ptr_array_new_full( src->len, free_func );
    g_ptr_array_foreach( src, _ptr_array_copy_cb, dest );
    return dest;
}

canonical_original_code:
struct _GPtrArray *ptr_array_copy(struct _GPtrArray *src, void (*free_func)(void *data))
{
    struct _GPtrArray *dest = g_ptr_array_new_full( src->len, free_func );
    g_ptr_array_foreach( src, _ptr_array_copy_cb, dest );
    return dest;
}

variable_types:
src
struct _GPtrArray *

variable_types: struct _GPtrArray { void **pdata; unsigned int len; } *


decompiled_code:
__int64 sess_desktopentry_error_quark()
{
return g_quark_from_static_string("sess-desktopentry-error-quark");
}

canonical_decompiled_code:
__int64 func0()
{
return g_quark_from_static_string("sess-desktopentry-error-quark");
}

original_code:
GQuark sess_desktopentry_error_quark( void )
{
    return g_quark_from_static_string( "sess-desktopentry-error-quark" );
}

canonical_original_code:
unsigned int sess_desktopentry_error_quark()
{
    return g_quark_from_static_string( "sess-desktopentry-error-quark" );
}

return_type: unsigned int


decompiled_code:
__int64 sess_cmdlineoption_error_quark()
{
return g_quark_from_static_string("sess-cmdlineoption-error-quark");
}

canonical_decompiled_code:
__int64 func1()
{
return g_quark_from_static_string("sess-cmdlineoption-error-quark");
}

original_code:
GQuark sess_cmdlineoption_error_quark( void )
{
    return g_quark_from_static_string( "sess-cmdlineoption-error-quark" );
}

canonical_original_code:
unsigned int sess_cmdlineoption_error_quark()
{
    return g_quark_from_static_string( "sess-cmdlineoption-error-quark" );
}


decompiled_code:
char *i18n_init()
{
char *result; // rax

setlocale(6, &locale);
result = textdomain("sessionchooser");
if ( !result )
{
g_log(0LL, 4LL, "Out of memory!");
while ( 1 )
;
}
return result;
}

canonical_decompiled_code:
char *func0()
{
char *result; // rax

setlocale(6, &locale);
result = textdomain("sessionchooser");
if ( !result )
{
g_log(0LL, 4LL, "Out of memory!");
while ( 1 )
;
}
return result;
}

original_code:
void i18n_init( void )
{
    setlocale( 6, "" );
    if( ! textdomain( "sessionchooser" ) )
    {
        do { g_log (((gchar*) 0), G_LOG_LEVEL_ERROR, "Out of memory!"); for (;;) ; } while (0);
    }
}

canonical_original_code:
void i18n_init()
{
    setlocale( 6, "" );
    if( ! textdomain( "sessionchooser" ) )
    {
        do { g_log (((char *) 0), G_LOG_LEVEL_ERROR, "Out of memory!"); for (;;) ; } while (0);
    }
}

return_type: void


decompiled_code:
__int64 __fastcall sess_locale_from_utf8(__int64 a1, __int64 a2)
{
__int64 result; // rax

result = g_locale_from_utf8(a1, a2, 0LL, 0LL, 0LL);
if ( !result )
result = g_strdup(a1);
return result;
}

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

result = g_locale_from_utf8(a1, a2, 0LL, 0LL, 0LL);
if ( !result )
result = g_strdup(a1);
return result;
}

original_code:
gchar *sess_locale_from_utf8( const gchar *utf8string, gssize len )
{
    gchar *converted = g_locale_from_utf8( utf8string, len, ((void *)0), ((void *)0), ((void *)0) );
    if( ! converted )
    {
        return g_strdup( utf8string );
    }
    return converted;
}

canonical_original_code:
char *sess_locale_from_utf8(char *utf8string, long len)
{
    char *converted = g_locale_from_utf8( utf8string, len, ((void *)0), ((void *)0), ((void *)0) );
    if( ! converted )
    {
        return g_strdup( utf8string );
    }
    return converted;
}

variable_types: len long

variable_types:
converted
char *

return_type: char *


decompiled_code:
__int64 __fastcall sess_session_free(_QWORD *a1)
{
g_free(*a1);
g_free(a1[1]);
g_free(a1[2]);
g_free(a1[3]);
g_free(a1[4]);
g_free(a1[5]);
g_free(a1[6]);
g_free(a1[7]);
return g_free(a1);
}

canonical_decompiled_code:
__int64 __fastcall func0(_QWORD *a1)
{
g_free(*a1);
g_free(a1[1]);
g_free(a1[2]);
g_free(a1[3]);
g_free(a1[4]);
g_free(a1[5]);
g_free(a1[6]);
g_free(a1[7]);
return g_free(a1);
}

original_code:
void sess_session_free( SessSession *sess )
{
    g_free( sess->name );
    g_free( sess->name_coll_key_case );
    g_free( sess->name_locale );
    g_free( sess->path );
    g_free( sess->path_normalized );
    g_free( sess->path_coll_key );
    g_free( sess->exec );
    g_free( sess->exec_locale );
    g_free( sess );
}

canonical_original_code:
void sess_session_free(struct SessSession *sess)
{
    g_free( sess->name );
    g_free( sess->name_coll_key_case );
    g_free( sess->name_locale );
    g_free( sess->path );
    g_free( sess->path_normalized );
    g_free( sess->path_coll_key );
    g_free( sess->exec );
    g_free( sess->exec_locale );
    g_free( sess );
}

variable_types: struct SessSession { char *name; char *name_coll_key_case; char *name_locale; char *path; char *path_normalized; char *path_coll_key; char *exec; char *exec_locale; int use_xinit; } *


decompiled_code:
__int64 sess_session_new()
{
return g_malloc0(72LL);
}

canonical_decompiled_code:
__int64 func1()
{
return g_malloc0(72LL);
}

original_code:
SessSession *sess_session_new( void )
{
    return ((SessSession *) g_malloc0_n ((1), sizeof (SessSession)));
}

canonical_original_code:
struct SessSession *sess_session_new()
{
    return ((struct SessSession *) g_malloc0_n ((1), sizeof (SessSession)));
}

return_type: struct SessSession { char *name; char *name_coll_key_case; char *name_locale; char *path; char *path_normalized; char *path_coll_key; char *exec; char *exec_locale; int use_xinit; } *


decompiled_code:
__int64 __fastcall sess_session_get_name_coll_key_case(_QWORD *a1)
{
__int64 v2; // rbp

if ( !a1[1] )
{
v2 = g_utf8_casefold(*a1, -1LL);
a1[1] = g_utf8_collate_key(v2, -1LL);
g_free(v2);
}
return a1[1];
}

canonical_decompiled_code:
__int64 __fastcall func2(_QWORD *a1)
{
__int64 v2; // rbp

if ( !a1[1] )
{
v2 = g_utf8_casefold(*a1, -1LL);
a1[1] = g_utf8_collate_key(v2, -1LL);
g_free(v2);
}
return a1[1];
}

original_code:
gchar *sess_session_get_name_coll_key_case( SessSession *sess )
{
    gchar *folded;
    if( ! sess->name_coll_key_case )
    {
        folded = g_utf8_casefold( sess->name, -1 );
        sess->name_coll_key_case = g_utf8_collate_key( folded, -1 );
        g_free( folded );
    }
    return sess->name_coll_key_case;
}

canonical_original_code:
char *sess_session_get_name_coll_key_case(struct SessSession *sess)
{
    char *folded;
    if( ! sess->name_coll_key_case )
    {
        folded = g_utf8_casefold( sess->name, -1 );
        sess->name_coll_key_case = g_utf8_collate_key( folded, -1 );
        g_free( folded );
    }
    return sess->name_coll_key_case;
}

variable_types:
folded
char *

user_defined_types: struct SessSession { char *name; char *name_coll_key_case; char *name_locale; char *path; char *path_normalized; char *path_coll_key; char *exec; char *exec_locale; int use_xinit; }


decompiled_code:
__int64 __fastcall sess_session_get_name_locale(_QWORD *a1)
{
if ( !a1[2] )
a1[2] = sess_locale_from_utf8(*a1, -1LL);
return a1[2];
}

canonical_decompiled_code:
__int64 __fastcall func4(_QWORD *a1)
{
if ( !a1[2] )
a1[2] = sess_locale_from_utf8(*a1, -1LL);
return a1[2];
}

original_code:
gchar *sess_session_get_name_locale( SessSession *sess )
{
    if( ! sess->name_locale )
    {
        sess->name_locale = sess_locale_from_utf8( sess->name, -1 );
    }
    return sess->name_locale;
}

canonical_original_code:
char *sess_session_get_name_locale(struct SessSession *sess)
{
    if( ! sess->name_locale )
    {
        sess->name_locale = sess_locale_from_utf8( sess->name, -1 );
    }
    return sess->name_locale;
}


decompiled_code:
__int64 __fastcall sess_session_get_path_normalized(__int64 a1)
{
__int64 v2; // rax

if ( !*(_QWORD *)(a1 + 32) )
{
v2 = g_utf8_normalize(*(_QWORD *)(a1 + 24), -1LL, 1LL);
if ( v2 )
*(_QWORD *)(a1 + 32) = v2;
else
*(_QWORD *)(a1 + 32) = g_strdup(*(_QWORD *)(a1 + 24));
}
return *(_QWORD *)(a1 + 32);
}

original_code:
gchar *sess_session_get_path_normalized( SessSession *sess )
{
    gchar *normalized;
    if( ! sess->path_normalized )
    {
        normalized = g_utf8_normalize( sess->path, -1, G_NORMALIZE_NFC );
        if( ! normalized )
        {
            sess->path_normalized = g_strdup( sess->path );
        }
        else
        {
            sess->path_normalized = normalized;
        }
    }
    return sess->path_normalized;
}

canonical_original_code:
char *sess_session_get_path_normalized(struct SessSession *sess)
{
    char *normalized;
    if( ! sess->path_normalized )
    {
        normalized = g_utf8_normalize( sess->path, -1, G_NORMALIZE_NFC );
        if( ! normalized )
        {
            sess->path_normalized = g_strdup( sess->path );
        }
        else
        {
            sess->path_normalized = normalized;
        }
    }
    return sess->path_normalized;
}

variable_types:
normalized
char *


decompiled_code:
__int64 __fastcall sess_session_get_path_coll_key(__int64 a1)
{
if ( !*(_QWORD *)(a1 + 40) )
*(_QWORD *)(a1 + 40) = g_utf8_collate_key(*(_QWORD *)(a1 + 24), -1LL);
return *(_QWORD *)(a1 + 40);
}

original_code:
gchar *sess_session_get_path_coll_key( SessSession *sess )
{
    if( ! sess->path_coll_key )
    {
        sess->path_coll_key = g_utf8_collate_key( sess->path, -1 );
    }
    return sess->path_coll_key;
}

canonical_original_code:
char *sess_session_get_path_coll_key(struct SessSession *sess)
{
    if( ! sess->path_coll_key )
    {
        sess->path_coll_key = g_utf8_collate_key( sess->path, -1 );
    }
    return sess->path_coll_key;
}


decompiled_code:
__int64 __fastcall sess_session_get_exec_locale(__int64 a1)
{
if ( !*(_QWORD *)(a1 + 56) )
*(_QWORD *)(a1 + 56) = sess_locale_from_utf8(*(_QWORD *)(a1 + 48), -1LL);
return *(_QWORD *)(a1 + 56);
}

original_code:
gchar *sess_session_get_exec_locale( SessSession *sess )
{
    if( ! sess->exec_locale )
    {
        sess->exec_locale = sess_locale_from_utf8( sess->exec, -1 );
    }
    return sess->exec_locale;
}

canonical_original_code:
char *sess_session_get_exec_locale(struct SessSession *sess)
{
    if( ! sess->exec_locale )
    {
        sess->exec_locale = sess_locale_from_utf8( sess->exec, -1 );
    }
    return sess->exec_locale;
}


decompiled_code:
_QWORD *sess_list_new()
{
_QWORD *v0; // rbx

v0 = (_QWORD *)g_malloc0(16LL);
*v0 = g_ptr_array_new_with_free_func(sess_session_free);
return v0;
}

canonical_decompiled_code:
_QWORD *func10()
{
_QWORD *v0; // rbx

v0 = (_QWORD *)g_malloc0(16LL);
*v0 = g_ptr_array_new_with_free_func(sess_session_free);
return v0;
}

original_code:
SessList *sess_list_new( void )
{
    SessList *s = ((SessList *) g_malloc0_n ((1), sizeof (SessList)));
    s->list = g_ptr_array_new_with_free_func( (GDestroyNotify)sess_session_free );
    return s;
}

canonical_original_code:
struct SessList *sess_list_new()
{
    struct SessList *s = ((SessList *) g_malloc0_n ((1), sizeof (SessList)));
    s->list = g_ptr_array_new_with_free_func( (void (*)(void *data))sess_session_free );
    return s;
}

variable_types: struct SessList { struct _GPtrArray { void **pdata; unsigned int len; } *list; struct _GPtrArray *path_idx; } *

user_defined_types: struct SessList { struct _GPtrArray *list; struct _GPtrArray *path_idx; }


decompiled_code:
__int64 __fastcall sess_list_free(_QWORD *a1)
{
__int64 result; // rax
__int64 v2; // rdi

if ( a1 )
{
result = g_ptr_array_free(*a1, 1LL);
v2 = a1[1];
if ( v2 )
result = g_ptr_array_free(v2, 1LL);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func11(_QWORD *a1)
{
__int64 result; // rax
__int64 v2; // rdi

if ( a1 )
{
result = g_ptr_array_free(*a1, 1LL);
v2 = a1[1];
if ( v2 )
result = g_ptr_array_free(v2, 1LL);
}
return result;
}

original_code:
void sess_list_free( SessList *s )
{
    if( ! s )
    {
        return;
    }
    g_ptr_array_free( s->list, (!(0)) );
    if( s->path_idx )
    {
        g_ptr_array_free( s->path_idx, (!(0)) );
    }
}

canonical_original_code:
void sess_list_free(struct SessList *s)
{
    if( ! s )
    {
        return;
    }
    g_ptr_array_free( s->list, (!(0)) );
    if( s->path_idx )
    {
        g_ptr_array_free( s->path_idx, (!(0)) );
    }
}

user_defined_types: struct _GPtrArray { void **pdata; unsigned int len; }


decompiled_code:
__int64 __fastcall sess_list_sort(_QWORD *a1)
{
__int64 v2; // rdi
__int64 v3; // rax

g_ptr_array_sort(*a1, session_name_sort_func);
v2 = a1[1];
if ( v2 )
g_ptr_array_free(v2, 1LL);
v3 = ptr_array_copy(*a1, 0LL);
a1[1] = v3;
return g_ptr_array_sort(v3, session_path_sort_func);
}

canonical_decompiled_code:
__int64 __fastcall func12(_QWORD *a1)
{
__int64 v2; // rdi
__int64 v3; // rax

g_ptr_array_sort(*a1, session_name_sort_func);
v2 = a1[1];
if ( v2 )
g_ptr_array_free(v2, 1LL);
v3 = ptr_array_copy(*a1, 0LL);
a1[1] = v3;
return g_ptr_array_sort(v3, session_path_sort_func);
}

original_code:
void sess_list_sort( SessList *s )
{
    g_ptr_array_sort( s->list, _session_name_sort_func );
    if( s->path_idx )
    {
        g_ptr_array_free( s->path_idx, (!(0)) );
    }
    s->path_idx = ptr_array_copy( s->list, ((void *)0) );
    g_ptr_array_sort( s->path_idx, _session_path_sort_func );
}

canonical_original_code:
void sess_list_sort(struct SessList *s)
{
    g_ptr_array_sort( s->list, _session_name_sort_func );
    if( s->path_idx )
    {
        g_ptr_array_free( s->path_idx, (!(0)) );
    }
    s->path_idx = ptr_array_copy( s->list, ((void *)0) );
    g_ptr_array_sort( s->path_idx, _session_path_sort_func );
}


repo: TermiT/sw-redux

decompiled_code:
_BOOL8 __fastcall SoundDriver_IsPCMSupported(int a1)
{
return *(&off_4D0 + 22 * a1) != 0LL;
}

canonical_decompiled_code:
_BOOL8 __fastcall func0(int a1)
{
return *(&off_4D0 + 22 * a1) != 0LL;
}

original_code:
int SoundDriver_IsPCMSupported(int driver)
{
 return (SoundDrivers[driver].PCM_Init != 0);
}

variable_types: driver int

return_type: int


decompiled_code:
_BOOL8 __fastcall SoundDriver_IsCDSupported(int a1)
{
return *(&off_500 + 22 * a1) != 0LL;
}

canonical_decompiled_code:
_BOOL8 __fastcall func1(int a1)
{
return *(&off_500 + 22 * a1) != 0LL;
}

original_code:
int SoundDriver_IsCDSupported(int driver)
{
 return (SoundDrivers[driver].CD_Init != 0);
}


decompiled_code:
_BOOL8 __fastcall SoundDriver_IsMIDISupported(int a1)
{
return *(&off_538 + 22 * a1) != 0LL;
}

canonical_decompiled_code:
_BOOL8 __fastcall func2(int a1)
{
return *(&off_538 + 22 * a1) != 0LL;
}

original_code:
int SoundDriver_IsMIDISupported(int driver)
{
 return (SoundDrivers[driver].MIDI_Init != 0);
}


decompiled_code:
__int64 SoundDriver_PCM_GetError()
{
int v0; // ebx
__int64 result; // rax

v0 = ASS_PCMSoundDriver;
if ( SoundDriver_IsPCMSupported(ASS_PCMSoundDriver) )
result = ((__int64 (*)(void))*(&SoundDrivers + 22 * v0))();
else
result = 0xFFFFFFFFLL;
return result;
}

canonical_decompiled_code:
__int64 func3()
{
int v0; // ebx
__int64 result; // rax

v0 = ASS_PCMSoundDriver;
if ( func0(ASS_PCMSoundDriver) )
result = ((__int64 (*)(void))*(&SoundDrivers + 22 * v0))();
else
result = 0xFFFFFFFFLL;
return result;
}

original_code:
int SoundDriver_PCM_GetError(void)
{
 if (!SoundDriver_IsPCMSupported(ASS_PCMSoundDriver)) {
  return -1;
 }
 return SoundDrivers[ASS_PCMSoundDriver].GetError();
}

canonical_original_code:
int SoundDriver_PCM_GetError()
{
 if (!SoundDriver_IsPCMSupported(ASS_PCMSoundDriver)) {
  return -1;
 }
 return SoundDrivers[ASS_PCMSoundDriver].GetError();
}


decompiled_code:
const char *__fastcall SoundDriver_PCM_ErrorString(unsigned int a1)
{
int v1; // ebx
const char *result; // rax
_BOOL4 v3; // edx

v1 = ASS_PCMSoundDriver;
result = "No sound driver selected.";
if ( (unsigned int)ASS_PCMSoundDriver <= 6 )
{
v3 = SoundDriver_IsPCMSupported(ASS_PCMSoundDriver);
result = "Unsupported sound driver selected.";
if ( v3 )
result = (const char *)((__int64 (__fastcall *)(_QWORD))*(&off_4C8 + 22 * v1))(a1);
}
return result;
}

canonical_decompiled_code:
const char *__fastcall func4(unsigned int a1)
{
int v1; // ebx
const char *result; // rax
_BOOL4 v3; // edx

v1 = ASS_PCMSoundDriver;
result = "No sound driver selected.";
if ( (unsigned int)ASS_PCMSoundDriver <= 6 )
{
v3 = func0(ASS_PCMSoundDriver);
result = "Unsupported sound driver selected.";
if ( v3 )
result = (const char *)((__int64 (__fastcall *)(_QWORD))*(&off_4C8 + 22 * v1))(a1);
}
return result;
}

original_code:
const char * SoundDriver_PCM_ErrorString( int ErrorNumber )
{
 if (ASS_PCMSoundDriver < 0 || ASS_PCMSoundDriver >= ASS_NumSoundCards) {
  return "No sound driver selected.";
 }
 if (!SoundDriver_IsPCMSupported(ASS_PCMSoundDriver)) {
  return "Unsupported sound driver selected.";
 }
 return SoundDrivers[ASS_PCMSoundDriver].ErrorString(ErrorNumber);
}

canonical_original_code:
char *SoundDriver_PCM_ErrorString(int ErrorNumber)
{
 if (ASS_PCMSoundDriver < 0 || ASS_PCMSoundDriver >= ASS_NumSoundCards) {
  return "No sound driver selected.";
 }
 if (!SoundDriver_IsPCMSupported(ASS_PCMSoundDriver)) {
  return "Unsupported sound driver selected.";
 }
 return SoundDrivers[ASS_PCMSoundDriver].ErrorString(ErrorNumber);
}

variable_types: ErrorNumber int


decompiled_code:
__int64 SoundDriver_CD_GetError()
{
int v0; // ebx
__int64 result; // rax

v0 = ASS_CDSoundDriver;
if ( SoundDriver_IsCDSupported(ASS_CDSoundDriver) )
result = ((__int64 (*)(void))*(&SoundDrivers + 22 * v0))();
else
result = 0xFFFFFFFFLL;
return result;
}

canonical_decompiled_code:
__int64 func5()
{
int v0; // ebx
__int64 result; // rax

v0 = ASS_CDSoundDriver;
if ( func1(ASS_CDSoundDriver) )
result = ((__int64 (*)(void))*(&SoundDrivers + 22 * v0))();
else
result = 0xFFFFFFFFLL;
return result;
}

original_code:
int SoundDriver_CD_GetError(void)
{
 if (!SoundDriver_IsCDSupported(ASS_CDSoundDriver)) {
  return -1;
 }
 return SoundDrivers[ASS_CDSoundDriver].GetError();
}

canonical_original_code:
int SoundDriver_CD_GetError()
{
 if (!SoundDriver_IsCDSupported(ASS_CDSoundDriver)) {
  return -1;
 }
 return SoundDrivers[ASS_CDSoundDriver].GetError();
}


decompiled_code:
const char *__fastcall SoundDriver_CD_ErrorString(unsigned int a1)
{
int v1; // ebx
const char *result; // rax
_BOOL4 v3; // edx

v1 = ASS_CDSoundDriver;
result = "No sound driver selected.";
if ( (unsigned int)ASS_CDSoundDriver <= 6 )
{
v3 = SoundDriver_IsCDSupported(ASS_CDSoundDriver);
result = "Unsupported sound driver selected.";
if ( v3 )
result = (const char *)((__int64 (__fastcall *)(_QWORD))*(&off_4C8 + 22 * v1))(a1);
}
return result;
}

canonical_decompiled_code:
const char *__fastcall func6(unsigned int a1)
{
int v1; // ebx
const char *result; // rax
_BOOL4 v3; // edx

v1 = ASS_CDSoundDriver;
result = "No sound driver selected.";
if ( (unsigned int)ASS_CDSoundDriver <= 6 )
{
v3 = func1(ASS_CDSoundDriver);
result = "Unsupported sound driver selected.";
if ( v3 )
result = (const char *)((__int64 (__fastcall *)(_QWORD))*(&off_4C8 + 22 * v1))(a1);
}
return result;
}

original_code:
const char * SoundDriver_CD_ErrorString( int ErrorNumber )
{
 if (ASS_CDSoundDriver < 0 || ASS_CDSoundDriver >= ASS_NumSoundCards) {
  return "No sound driver selected.";
 }
 if (!SoundDriver_IsCDSupported(ASS_CDSoundDriver)) {
  return "Unsupported sound driver selected.";
 }
 return SoundDrivers[ASS_CDSoundDriver].ErrorString(ErrorNumber);
}

canonical_original_code:
char *SoundDriver_CD_ErrorString(int ErrorNumber)
{
 if (ASS_CDSoundDriver < 0 || ASS_CDSoundDriver >= ASS_NumSoundCards) {
  return "No sound driver selected.";
 }
 if (!SoundDriver_IsCDSupported(ASS_CDSoundDriver)) {
  return "Unsupported sound driver selected.";
 }
 return SoundDrivers[ASS_CDSoundDriver].ErrorString(ErrorNumber);
}


decompiled_code:
__int64 SoundDriver_MIDI_GetError()
{
int v0; // ebx
__int64 result; // rax

v0 = ASS_MIDISoundDriver;
if ( SoundDriver_IsMIDISupported(ASS_MIDISoundDriver) )
result = ((__int64 (*)(void))*(&SoundDrivers + 22 * v0))();
else
result = 0xFFFFFFFFLL;
return result;
}

canonical_decompiled_code:
__int64 func7()
{
int v0; // ebx
__int64 result; // rax

v0 = ASS_MIDISoundDriver;
if ( func2(ASS_MIDISoundDriver) )
result = ((__int64 (*)(void))*(&SoundDrivers + 22 * v0))();
else
result = 0xFFFFFFFFLL;
return result;
}

original_code:
int SoundDriver_MIDI_GetError(void)
{
 if (!SoundDriver_IsMIDISupported(ASS_MIDISoundDriver)) {
  return -1;
 }
 return SoundDrivers[ASS_MIDISoundDriver].GetError();
}

canonical_original_code:
int SoundDriver_MIDI_GetError()
{
 if (!SoundDriver_IsMIDISupported(ASS_MIDISoundDriver)) {
  return -1;
 }
 return SoundDrivers[ASS_MIDISoundDriver].GetError();
}


decompiled_code:
const char *__fastcall SoundDriver_MIDI_ErrorString(unsigned int a1)
{
int v1; // ebx
const char *result; // rax
_BOOL4 v3; // edx

v1 = ASS_MIDISoundDriver;
result = "No sound driver selected.";
if ( (unsigned int)ASS_MIDISoundDriver <= 6 )
{
v3 = SoundDriver_IsMIDISupported(ASS_MIDISoundDriver);
result = "Unsupported sound driver selected.";
if ( v3 )
result = (const char *)((__int64 (__fastcall *)(_QWORD))*(&off_4C8 + 22 * v1))(a1);
}
return result;
}

canonical_decompiled_code:
const char *__fastcall func8(unsigned int a1)
{
int v1; // ebx
const char *result; // rax
_BOOL4 v3; // edx

v1 = ASS_MIDISoundDriver;
result = "No sound driver selected.";
if ( (unsigned int)ASS_MIDISoundDriver <= 6 )
{
v3 = func2(ASS_MIDISoundDriver);
result = "Unsupported sound driver selected.";
if ( v3 )
result = (const char *)((__int64 (__fastcall *)(_QWORD))*(&off_4C8 + 22 * v1))(a1);
}
return result;
}

original_code:
const char * SoundDriver_MIDI_ErrorString( int ErrorNumber )
{
 if (ASS_MIDISoundDriver < 0 || ASS_MIDISoundDriver >= ASS_NumSoundCards) {
  return "No sound driver selected.";
 }
 if (!SoundDriver_IsMIDISupported(ASS_MIDISoundDriver)) {
  return "Unsupported sound driver selected.";
 }
 return SoundDrivers[ASS_MIDISoundDriver].ErrorString(ErrorNumber);
}

canonical_original_code:
char *SoundDriver_MIDI_ErrorString(int ErrorNumber)
{
 if (ASS_MIDISoundDriver < 0 || ASS_MIDISoundDriver >= ASS_NumSoundCards) {
  return "No sound driver selected.";
 }
 if (!SoundDriver_IsMIDISupported(ASS_MIDISoundDriver)) {
  return "Unsupported sound driver selected.";
 }
 return SoundDrivers[ASS_MIDISoundDriver].ErrorString(ErrorNumber);
}


decompiled_code:
__int64 SoundDriver_PCM_Init()
{
return ((__int64 (*)(void))*(&off_4D0 + 22 * ASS_PCMSoundDriver))();
}

canonical_decompiled_code:
__int64 func9()
{
return ((__int64 (*)(void))*(&off_4D0 + 22 * ASS_PCMSoundDriver))();
}

original_code:
int SoundDriver_PCM_Init(int * mixrate, int * numchannels, int * samplebits, void * initdata)
{
 return SoundDrivers[ASS_PCMSoundDriver].PCM_Init(mixrate, numchannels, samplebits, initdata);
}

canonical_original_code:
int SoundDriver_PCM_Init(int *mixrate, int *numchannels, int *samplebits, void *initdata)
{
 return SoundDrivers[ASS_PCMSoundDriver].PCM_Init(mixrate, numchannels, samplebits, initdata);
}

variable_types:
mixrate
int *

variable_types:
numchannels
int *

variable_types:
samplebits
int *

variable_types:
initdata
void *


decompiled_code:
__int64 SoundDriver_PCM_Shutdown()
{
return ((__int64 (*)(void))*(&off_4D8 + 22 * ASS_PCMSoundDriver))();
}

canonical_decompiled_code:
__int64 func10()
{
return ((__int64 (*)(void))*(&off_4D8 + 22 * ASS_PCMSoundDriver))();
}

original_code:
void SoundDriver_PCM_Shutdown(void)
{
 SoundDrivers[ASS_PCMSoundDriver].PCM_Shutdown();
}

canonical_original_code:
void SoundDriver_PCM_Shutdown()
{
 SoundDrivers[ASS_PCMSoundDriver].PCM_Shutdown();
}


decompiled_code:
__int64 SoundDriver_PCM_BeginPlayback()
{
return ((__int64 (*)(void))*(&off_4E0 + 22 * ASS_PCMSoundDriver))();
}

canonical_decompiled_code:
__int64 func11()
{
return ((__int64 (*)(void))*(&off_4E0 + 22 * ASS_PCMSoundDriver))();
}

original_code:
int SoundDriver_PCM_BeginPlayback(char *BufferStart, int BufferSize,
  int NumDivisions, void ( *CallBackFunc )( void ) )
{
 return SoundDrivers[ASS_PCMSoundDriver].PCM_BeginPlayback(BufferStart,
   BufferSize, NumDivisions, CallBackFunc);
}

canonical_original_code:
int SoundDriver_PCM_BeginPlayback(char *BufferStart, int BufferSize, int NumDivisions, void (*CallBackFunc)())
{
 return SoundDrivers[ASS_PCMSoundDriver].PCM_BeginPlayback(BufferStart,
   BufferSize, NumDivisions, CallBackFunc);
}

variable_types:
BufferStart
char *

variable_types: BufferSize int

variable_types: NumDivisions int

variable_types:
CallBackFunc
void (*)()


decompiled_code:
__int64 SoundDriver_PCM_StopPlayback()
{
return ((__int64 (*)(void))*(&off_4E8 + 22 * ASS_PCMSoundDriver))();
}

canonical_decompiled_code:
__int64 func12()
{
return ((__int64 (*)(void))*(&off_4E8 + 22 * ASS_PCMSoundDriver))();
}

original_code:
void SoundDriver_PCM_StopPlayback(void)
{
 SoundDrivers[ASS_PCMSoundDriver].PCM_StopPlayback();
}

canonical_original_code:
void SoundDriver_PCM_StopPlayback()
{
 SoundDrivers[ASS_PCMSoundDriver].PCM_StopPlayback();
}


decompiled_code:
__int64 SoundDriver_PCM_Lock()
{
return ((__int64 (*)(void))*(&off_4F0 + 22 * ASS_PCMSoundDriver))();
}

canonical_decompiled_code:
__int64 func13()
{
return ((__int64 (*)(void))*(&off_4F0 + 22 * ASS_PCMSoundDriver))();
}

original_code:
void SoundDriver_PCM_Lock(void)
{
 SoundDrivers[ASS_PCMSoundDriver].PCM_Lock();
}

canonical_original_code:
void SoundDriver_PCM_Lock()
{
 SoundDrivers[ASS_PCMSoundDriver].PCM_Lock();
}


decompiled_code:
__int64 SoundDriver_PCM_Unlock()
{
return ((__int64 (*)(void))*(&off_4F8 + 22 * ASS_PCMSoundDriver))();
}

canonical_decompiled_code:
__int64 func14()
{
return ((__int64 (*)(void))*(&off_4F8 + 22 * ASS_PCMSoundDriver))();
}

original_code:
void SoundDriver_PCM_Unlock(void)
{
 SoundDrivers[ASS_PCMSoundDriver].PCM_Unlock();
}

canonical_original_code:
void SoundDriver_PCM_Unlock()
{
 SoundDrivers[ASS_PCMSoundDriver].PCM_Unlock();
}


decompiled_code:
__int64 SoundDriver_CD_Init()
{
return ((__int64 (*)(void))*(&off_500 + 22 * ASS_CDSoundDriver))();
}

canonical_decompiled_code:
__int64 func15()
{
return ((__int64 (*)(void))*(&off_500 + 22 * ASS_CDSoundDriver))();
}

original_code:
int SoundDriver_CD_Init(void)
{
    return SoundDrivers[ASS_CDSoundDriver].CD_Init();
}

canonical_original_code:
int SoundDriver_CD_Init()
{
    return SoundDrivers[ASS_CDSoundDriver].CD_Init();
}


decompiled_code:
__int64 SoundDriver_CD_Shutdown()
{
return ((__int64 (*)(void))*(&off_508 + 22 * ASS_CDSoundDriver))();
}

canonical_decompiled_code:
__int64 func16()
{
return ((__int64 (*)(void))*(&off_508 + 22 * ASS_CDSoundDriver))();
}

original_code:
void SoundDriver_CD_Shutdown(void)
{
    SoundDrivers[ASS_CDSoundDriver].CD_Shutdown();
}

canonical_original_code:
void SoundDriver_CD_Shutdown()
{
    SoundDrivers[ASS_CDSoundDriver].CD_Shutdown();
}


decompiled_code:
__int64 SoundDriver_CD_Play()
{
return ((__int64 (*)(void))*(&off_510 + 22 * ASS_CDSoundDriver))();
}

canonical_decompiled_code:
__int64 func17()
{
return ((__int64 (*)(void))*(&off_510 + 22 * ASS_CDSoundDriver))();
}

original_code:
int SoundDriver_CD_Play(int track, int loop)
{
    return SoundDrivers[ASS_CDSoundDriver].CD_Play(track, loop);
}

variable_types: track int

variable_types: loop int


decompiled_code:
__int64 SoundDriver_CD_Stop()
{
return ((__int64 (*)(void))*(&off_518 + 22 * ASS_CDSoundDriver))();
}

canonical_decompiled_code:
__int64 func18()
{
return ((__int64 (*)(void))*(&off_518 + 22 * ASS_CDSoundDriver))();
}

original_code:
void SoundDriver_CD_Stop(void)
{
    SoundDrivers[ASS_CDSoundDriver].CD_Stop();
}

canonical_original_code:
void SoundDriver_CD_Stop()
{
    SoundDrivers[ASS_CDSoundDriver].CD_Stop();
}


decompiled_code:
__int64 SoundDriver_CD_Pause()
{
return ((__int64 (*)(void))*(&off_520 + 22 * ASS_CDSoundDriver))();
}

canonical_decompiled_code:
__int64 func19()
{
return ((__int64 (*)(void))*(&off_520 + 22 * ASS_CDSoundDriver))();
}

original_code:
void SoundDriver_CD_Pause(int pauseon)
{
    SoundDrivers[ASS_CDSoundDriver].CD_Pause(pauseon);
}

variable_types: pauseon int


decompiled_code:
__int64 SoundDriver_CD_IsPlaying()
{
return ((__int64 (*)(void))*(&off_528 + 22 * ASS_CDSoundDriver))();
}

canonical_decompiled_code:
__int64 func20()
{
return ((__int64 (*)(void))*(&off_528 + 22 * ASS_CDSoundDriver))();
}

original_code:
int SoundDriver_CD_IsPlaying(void)
{
    return SoundDrivers[ASS_CDSoundDriver].CD_IsPlaying();
}

canonical_original_code:
int SoundDriver_CD_IsPlaying()
{
    return SoundDrivers[ASS_CDSoundDriver].CD_IsPlaying();
}


decompiled_code:
__int64 SoundDriver_CD_SetVolume()
{
return ((__int64 (*)(void))*(&off_530 + 22 * ASS_CDSoundDriver))();
}

canonical_decompiled_code:
__int64 func21()
{
return ((__int64 (*)(void))*(&off_530 + 22 * ASS_CDSoundDriver))();
}

original_code:
void SoundDriver_CD_SetVolume(int volume)
{
    SoundDrivers[ASS_CDSoundDriver].CD_SetVolume(volume);
}

variable_types: volume int


decompiled_code:
__int64 SoundDriver_MIDI_Init()
{
return ((__int64 (*)(void))*(&off_538 + 22 * ASS_MIDISoundDriver))();
}

canonical_decompiled_code:
__int64 func22()
{
return ((__int64 (*)(void))*(&off_538 + 22 * ASS_MIDISoundDriver))();
}

original_code:
int SoundDriver_MIDI_Init(midifuncs *funcs)
{
    return SoundDrivers[ASS_MIDISoundDriver].MIDI_Init(funcs);
}

canonical_original_code:
int SoundDriver_MIDI_Init(struct midifuncs *funcs)
{
    return SoundDrivers[ASS_MIDISoundDriver].MIDI_Init(funcs);
}

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:
__int64 SoundDriver_MIDI_Shutdown()
{
return ((__int64 (*)(void))*(&off_540 + 22 * ASS_MIDISoundDriver))();
}

canonical_decompiled_code:
__int64 func23()
{
return ((__int64 (*)(void))*(&off_540 + 22 * ASS_MIDISoundDriver))();
}

original_code:
void SoundDriver_MIDI_Shutdown(void)
{
    SoundDrivers[ASS_MIDISoundDriver].MIDI_Shutdown();
}

canonical_original_code:
void SoundDriver_MIDI_Shutdown()
{
    SoundDrivers[ASS_MIDISoundDriver].MIDI_Shutdown();
}


decompiled_code:
__int64 SoundDriver_MIDI_StartPlayback()
{
return ((__int64 (*)(void))*(&off_548 + 22 * ASS_MIDISoundDriver))();
}

canonical_decompiled_code:
__int64 func24()
{
return ((__int64 (*)(void))*(&off_548 + 22 * ASS_MIDISoundDriver))();
}

original_code:
int SoundDriver_MIDI_StartPlayback(void (*service)(void))
{
    return SoundDrivers[ASS_MIDISoundDriver].MIDI_StartPlayback(service);
}

canonical_original_code:
int SoundDriver_MIDI_StartPlayback(void (*service)())
{
    return SoundDrivers[ASS_MIDISoundDriver].MIDI_StartPlayback(service);
}

variable_types:
service
void (*)()


decompiled_code:
__int64 SoundDriver_MIDI_HaltPlayback()
{
return ((__int64 (*)(void))*(&off_550 + 22 * ASS_MIDISoundDriver))();
}

canonical_decompiled_code:
__int64 func25()
{
return ((__int64 (*)(void))*(&off_550 + 22 * ASS_MIDISoundDriver))();
}

original_code:
void SoundDriver_MIDI_HaltPlayback(void)
{
    SoundDrivers[ASS_MIDISoundDriver].MIDI_HaltPlayback();
}

canonical_original_code:
void SoundDriver_MIDI_HaltPlayback()
{
    SoundDrivers[ASS_MIDISoundDriver].MIDI_HaltPlayback();
}


decompiled_code:
__int64 SoundDriver_MIDI_SetTempo()
{
return ((__int64 (*)(void))*(&off_558 + 22 * ASS_MIDISoundDriver))();
}

canonical_decompiled_code:
__int64 func26()
{
return ((__int64 (*)(void))*(&off_558 + 22 * ASS_MIDISoundDriver))();
}

original_code:
void SoundDriver_MIDI_SetTempo(int tempo, int division)
{
    SoundDrivers[ASS_MIDISoundDriver].MIDI_SetTempo(tempo, division);
}

variable_types: tempo int

variable_types: division int


decompiled_code:
__int64 SoundDriver_MIDI_Lock()
{
return ((__int64 (*)(void))*(&off_560 + 22 * ASS_MIDISoundDriver))();
}

canonical_decompiled_code:
__int64 func27()
{
return ((__int64 (*)(void))*(&off_560 + 22 * ASS_MIDISoundDriver))();
}

original_code:
void SoundDriver_MIDI_Lock(void)
{
 SoundDrivers[ASS_MIDISoundDriver].MIDI_Lock();
}

canonical_original_code:
void SoundDriver_MIDI_Lock()
{
 SoundDrivers[ASS_MIDISoundDriver].MIDI_Lock();
}


decompiled_code:
__int64 SoundDriver_MIDI_Unlock()
{
return ((__int64 (*)(void))*(&off_568 + 22 * ASS_MIDISoundDriver))();
}

canonical_decompiled_code:
__int64 func28()
{
return ((__int64 (*)(void))*(&off_568 + 22 * ASS_MIDISoundDriver))();
}

original_code:
void SoundDriver_MIDI_Unlock(void)
{
 SoundDrivers[ASS_MIDISoundDriver].MIDI_Unlock();
}

canonical_original_code:
void SoundDriver_MIDI_Unlock()
{
 SoundDrivers[ASS_MIDISoundDriver].MIDI_Unlock();
}


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

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

original_code:
int32_t SDLDrv_GetError(void)
{
    return ErrorCode;
}

canonical_original_code:
int SDLDrv_GetError()
{
    return ErrorCode;
}


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

switch ( a1 )
{
case -2:
case -1:
result = (const char *)SDLDrv_ErrorString((unsigned int)ErrorCode);
break;
case 0:
result = "SDL Audio ok.";
break;
case 1:
result = "SDL Audio uninitialised.";
break;
case 2:
result = "SDL Audio: error in Init or InitSubSystem.";
break;
case 3:
result = "SDL Audio: error in OpenAudio.";
break;
case 4:
result = "SDL Audio: error loading OGG file.";
break;
case 5:
result = "SDL Audio: error playing OGG file.";
break;
default:
result = "Unknown SDL Audio error code.";
break;
}
return result;
}

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

switch ( a1 )
{
case -2:
case -1:
result = (const char *)func2((unsigned int)ErrorCode);
break;
case 0:
result = "SDL Audio ok.";
break;
case 1:
result = "SDL Audio uninitialised.";
break;
case 2:
result = "SDL Audio: error in Init or InitSubSystem.";
break;
case 3:
result = "SDL Audio: error in OpenAudio.";
break;
case 4:
result = "SDL Audio: error loading OGG file.";
break;
case 5:
result = "SDL Audio: error playing OGG file.";
break;
default:
result = "Unknown SDL Audio error code.";
break;
}
return result;
}

original_code:
const char *SDLDrv_ErrorString( int32_t ErrorNumber )
{
    const char *ErrorString;
    switch( ErrorNumber ) {
        case SDLErr_Warning :
        case SDLErr_Error :
            ErrorString = SDLDrv_ErrorString( ErrorCode );
            break;
        case SDLErr_Ok :
            ErrorString = "SDL Audio ok.";
            break;
        case SDLErr_Uninitialised:
            ErrorString = "SDL Audio uninitialised.";
            break;
        case SDLErr_InitSubSystem:
            ErrorString = "SDL Audio: error in Init or InitSubSystem.";
            break;
        case SDLErr_OpenAudio:
            ErrorString = "SDL Audio: error in OpenAudio.";
            break;
        case SDLErr_OpenOGG:
            ErrorString = "SDL Audio: error loading OGG file.";
            break;
        case SDLErr_PlayOGG:
            ErrorString = "SDL Audio: error playing OGG file.";
            break;
        default:
            ErrorString = "Unknown SDL Audio error code.";
            break;
    }
    return ErrorString;
}

canonical_original_code:
char *SDLDrv_ErrorString(int ErrorNumber)
{
    char *ErrorString;
    switch( ErrorNumber ) {
        case SDLErr_Warning :
        case SDLErr_Error :
            ErrorString = SDLDrv_ErrorString( ErrorCode );
            break;
        case SDLErr_Ok :
            ErrorString = "SDL Audio ok.";
            break;
        case SDLErr_Uninitialised:
            ErrorString = "SDL Audio uninitialised.";
            break;
        case SDLErr_InitSubSystem:
            ErrorString = "SDL Audio: error in Init or InitSubSystem.";
            break;
        case SDLErr_OpenAudio:
            ErrorString = "SDL Audio: error in OpenAudio.";
            break;
        case SDLErr_OpenOGG:
            ErrorString = "SDL Audio: error loading OGG file.";
            break;
        case SDLErr_PlayOGG:
            ErrorString = "SDL Audio: error playing OGG file.";
            break;
        default:
            ErrorString = "Unknown SDL Audio error code.";
            break;
    }
    return ErrorString;
}

variable_types: ErrorNumber int

variable_types:
ErrorString
char *


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

if ( Initialised )
{
Mix_HaltChannel(0xFFFFFFFFLL);
if ( DummyChunk )
{
Mix_FreeChunk();
DummyChunk = 0LL;
}
if ( DummyBuffer )
{
free(DummyBuffer);
DummyBuffer = 0LL;
}
Mix_CloseAudio();
result = SDL_DestroyMutex(EffectFence);
Initialised = 0;
}
return result;
}

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

if ( Initialised )
{
Mix_HaltChannel(0xFFFFFFFFLL);
if ( DummyChunk )
{
Mix_FreeChunk();
DummyChunk = 0LL;
}
if ( DummyBuffer )
{
free(DummyBuffer);
DummyBuffer = 0LL;
}
Mix_CloseAudio();
result = SDL_DestroyMutex(EffectFence);
Initialised = 0;
}
return result;
}

original_code:
void SDLDrv_PCM_Shutdown(void)
{
    if (!Initialised)
        return;
    else Mix_HaltChannel(-1);
    if (DummyChunk != ((void *)0))
    {
        Mix_FreeChunk(DummyChunk);
        DummyChunk = ((void *)0);
    }
    if (DummyBuffer != ((void *)0))
    {
        free(DummyBuffer);
        DummyBuffer = ((void *)0);
    }
    Mix_CloseAudio();
    SDL_DestroyMutex(EffectFence);
    Initialised = 0;
}

canonical_original_code:
void SDLDrv_PCM_Shutdown()
{
    if (!Initialised)
        return;
    else Mix_HaltChannel(-1);
    if (DummyChunk != ((void *)0))
    {
        Mix_FreeChunk(DummyChunk);
        DummyChunk = ((void *)0);
    }
    if (DummyBuffer != ((void *)0))
    {
        free(DummyBuffer);
        DummyBuffer = ((void *)0);
    }
    Mix_CloseAudio();
    SDL_DestroyMutex(EffectFence);
    Initialised = 0;
}


decompiled_code:
__int64 __fastcall SDLDrv_PCM_Init(unsigned int *a1, unsigned int *a2, _DWORD *a3)
{
__int64 v6; // rdi
unsigned int v7; // ebx
__int64 v8; // rdx
__int64 v9; // rsi
char *v10; // rdx
__int64 result; // rax
__int16 v12[21]; // [rsp+Eh] [rbp-2Ah] BYREF

if ( Initialised )
SDLDrv_PCM_Shutdown();
v6 = *a1;
v7 = 512;
if ( (int)v6 > 15999 )
{
v7 = 2048;
if ( (int)v6 <= 31999 )
v7 = 1024;
}
v8 = *a2;
v9 = (unsigned int)*a3;
if ( (_DWORD)v9 != 8 )
v9 = 32784LL;
if ( (int)Mix_OpenAudio(v6, v9, v8, v7) < 0 )
{
ErrorCode = 3;
result = 0xFFFFFFFFLL;
}
else
{
if ( (unsigned int)Mix_QuerySpec(a1, v12, a2) )
*a3 = 8 * ((v12[0] & 0x7FFF) != 8) + 8;
EffectFence = SDL_CreateMutex();
Mix_RegisterEffect(2LL, fillData, 0LL, 0LL);
v10 = (char *)malloc((int)v7);
DummyBuffer = v10;
*(_QWORD *)&v10[v7 - 8] = 0LL;
memset(v10, 0, 8LL * ((v7 - 1) >> 3));
DummyChunk = Mix_QuickLoad_RAW(v10, v7);
Mix_PlayChannelTimed(2LL, DummyChunk, 0xFFFFFFFFLL, 0xFFFFFFFFLL);
Initialised = 1;
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(unsigned int *a1, unsigned int *a2, _DWORD *a3)
{
__int64 v6; // rdi
unsigned int v7; // ebx
__int64 v8; // rdx
__int64 v9; // rsi
char *v10; // rdx
__int64 result; // rax
__int16 v12[21]; // [rsp+Eh] [rbp-2Ah] BYREF

if ( Initialised )
func3();
v6 = *a1;
v7 = 512;
if ( (int)v6 > 15999 )
{
v7 = 2048;
if ( (int)v6 <= 31999 )
v7 = 1024;
}
v8 = *a2;
v9 = (unsigned int)*a3;
if ( (_DWORD)v9 != 8 )
v9 = 32784LL;
if ( (int)Mix_OpenAudio(v6, v9, v8, v7) < 0 )
{
ErrorCode = 3;
result = 0xFFFFFFFFLL;
}
else
{
if ( (unsigned int)Mix_QuerySpec(a1, v12, a2) )
*a3 = 8 * ((v12[0] & 0x7FFF) != 8) + 8;
EffectFence = SDL_CreateMutex();
Mix_RegisterEffect(2LL, fillData, 0LL, 0LL);
v10 = (char *)malloc((int)v7);
DummyBuffer = v10;
*(_QWORD *)&v10[v7 - 8] = 0LL;
memset(v10, 0, 8LL * ((v7 - 1) >> 3));
DummyChunk = Mix_QuickLoad_RAW(v10, v7);
Mix_PlayChannelTimed(2LL, DummyChunk, 0xFFFFFFFFLL, 0xFFFFFFFFLL);
Initialised = 1;
result = 0LL;
}
return result;
}

original_code:
int32_t SDLDrv_PCM_Init(int32_t *mixrate, int32_t *numchannels, int32_t *samplebits, void * initdata)
{
    int32_t err = 0;
    int32_t chunksize;
    uint16_t fmt;
    numchannels=numchannels;
    initdata=initdata;
    if (Initialised) {
        SDLDrv_PCM_Shutdown();
    }
    chunksize = 512;
    if (*mixrate >= 16000) chunksize *= 2;
    if (*mixrate >= 32000) chunksize *= 2;
    err = Mix_OpenAudio(*mixrate, (*samplebits == 8) ? 0x0008 : 0x8010, *numchannels, chunksize);
    if (err < 0) {
        ErrorCode = SDLErr_OpenAudio;
        return SDLErr_Error;
    }
    if (Mix_QuerySpec(mixrate, &fmt, numchannels))
    {
        if (fmt == 0x0008 || fmt == 0x8008) *samplebits = 8;
        else *samplebits = 16;
    }
    EffectFence = SDL_CreateMutex();
    Mix_RegisterEffect(2, fillData, ((void *)0), ((void *)0));
    DummyBuffer = (uint8_t *) malloc(chunksize);
    memset(DummyBuffer, 0, chunksize);
    DummyChunk = Mix_QuickLoad_RAW(DummyBuffer, chunksize);
    Mix_PlayChannelTimed(2,DummyChunk,-1,-1);
    Initialised = 1;
    return SDLErr_Ok;
}

canonical_original_code:
int SDLDrv_PCM_Init(int *mixrate, int *numchannels, int *samplebits, void *initdata)
{
    int err = 0;
    int chunksize;
    unsigned short fmt;
    numchannels=numchannels;
    initdata=initdata;
    if (Initialised) {
        SDLDrv_PCM_Shutdown();
    }
    chunksize = 512;
    if (*mixrate >= 16000) chunksize *= 2;
    if (*mixrate >= 32000) chunksize *= 2;
    err = Mix_OpenAudio(*mixrate, (*samplebits == 8) ? 0x0008 : 0x8010, *numchannels, chunksize);
    if (err < 0) {
        ErrorCode = SDLErr_OpenAudio;
        return SDLErr_Error;
    }
    if (Mix_QuerySpec(mixrate, &fmt, numchannels))
    {
        if (fmt == 0x0008 || fmt == 0x8008) *samplebits = 8;
        else *samplebits = 16;
    }
    EffectFence = SDL_CreateMutex();
    Mix_RegisterEffect(2, fillData, ((void *)0), ((void *)0));
    DummyBuffer = (unsigned char *) malloc(chunksize);
    memset(DummyBuffer, 0, chunksize);
    DummyChunk = Mix_QuickLoad_RAW(DummyBuffer, chunksize);
    Mix_PlayChannelTimed(2,DummyChunk,-1,-1);
    Initialised = 1;
    return SDLErr_Ok;
}

variable_types:
mixrate
int *

variable_types:
numchannels
int *

variable_types: err int

variable_types: chunksize int

variable_types:
fmt
unsigned short


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

if ( Initialised )
{
if ( Playing )
{
result = Mix_Pause(0xFFFFFFFFLL);
Playing = 0;
}
}
return result;
}

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

if ( Initialised )
{
if ( Playing )
{
result = Mix_Pause(0xFFFFFFFFLL);
Playing = 0;
}
}
return result;
}

original_code:
void SDLDrv_PCM_StopPlayback(void)
{
    if (!Initialised || !Playing) {
        return;
    }
    Mix_Pause(-1);
    Playing = 0;
}

canonical_original_code:
void SDLDrv_PCM_StopPlayback()
{
    if (!Initialised || !Playing) {
        return;
    }
    Mix_Pause(-1);
    Playing = 0;
}


decompiled_code:
__int64 __fastcall SDLDrv_PCM_BeginPlayback(__int64 a1, int a2, int a3, __int64 (*a4)(void))
{
__int64 result; // rax

if ( Initialised )
{
if ( Playing )
SDLDrv_PCM_StopPlayback();
MixBuffer = a1;
MixBufferSize = a2;
MixBufferCount = a3;
MixBufferCurrent = 0;
MixBufferUsed = 0;
MixCallBack = a4;
a4();
Mix_Resume(0xFFFFFFFFLL);
Playing = 1;
result = 0LL;
}
else
{
ErrorCode = 1;
result = 0xFFFFFFFFLL;
}
return result;
}

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

if ( Initialised )
{
if ( Playing )
func5();
MixBuffer = a1;
MixBufferSize = a2;
MixBufferCount = a3;
MixBufferCurrent = 0;
MixBufferUsed = 0;
MixCallBack = a4;
a4();
Mix_Resume(0xFFFFFFFFLL);
Playing = 1;
result = 0LL;
}
else
{
ErrorCode = 1;
result = 0xFFFFFFFFLL;
}
return result;
}

original_code:
int32_t SDLDrv_PCM_BeginPlayback(char *BufferStart, int32_t BufferSize,
                        int32_t NumDivisions, void ( *CallBackFunc )( void ) )
{
    if (!Initialised) {
        ErrorCode = SDLErr_Uninitialised;
        return SDLErr_Error;
    }
    if (Playing) {
        SDLDrv_PCM_StopPlayback();
    }
    MixBuffer = BufferStart;
    MixBufferSize = BufferSize;
    MixBufferCount = NumDivisions;
    MixBufferCurrent = 0;
    MixBufferUsed = 0;
    MixCallBack = CallBackFunc;
    MixCallBack();
    Mix_Resume(-1);
    Playing = 1;
    return SDLErr_Ok;
}

canonical_original_code:
int SDLDrv_PCM_BeginPlayback(char *BufferStart, int BufferSize, int NumDivisions, void (*CallBackFunc)())
{
    if (!Initialised) {
        ErrorCode = SDLErr_Uninitialised;
        return SDLErr_Error;
    }
    if (Playing) {
        SDLDrv_PCM_StopPlayback();
    }
    MixBuffer = BufferStart;
    MixBufferSize = BufferSize;
    MixBufferCount = NumDivisions;
    MixBufferCurrent = 0;
    MixBufferUsed = 0;
    MixCallBack = CallBackFunc;
    MixCallBack();
    Mix_Resume(-1);
    Playing = 1;
    return SDLErr_Ok;
}

variable_types:
BufferStart
char *

variable_types: BufferSize int

variable_types: NumDivisions int


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

result = (unsigned int)InterruptsDisabled++;
if ( !(_DWORD)result )
result = SDL_mutexP(EffectFence);
return result;
}

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

result = (unsigned int)InterruptsDisabled++;
if ( !(_DWORD)result )
result = SDL_mutexP(EffectFence);
return result;
}

original_code:
void SDLDrv_PCM_Lock(void)
{
        if (InterruptsDisabled++)
            return;
        SDL_mutexP(EffectFence);
}

canonical_original_code:
void SDLDrv_PCM_Lock()
{
        if (InterruptsDisabled++)
            return;
        SDL_mutexP(EffectFence);
}


decompiled_code:
__int64 SDLDrv_PCM_Unlock()
{
bool v0; // zf
__int64 result; // rax

v0 = InterruptsDisabled == 1;
result = (unsigned int)--InterruptsDisabled;
if ( v0 )
result = SDL_mutexV(EffectFence);
return result;
}

canonical_decompiled_code:
__int64 func8()
{
bool v0; // zf
__int64 result; // rax

v0 = InterruptsDisabled == 1;
result = (unsigned int)--InterruptsDisabled;
if ( v0 )
result = SDL_mutexV(EffectFence);
return result;
}

original_code:
void SDLDrv_PCM_Unlock(void)
{
        if (--InterruptsDisabled)
            return;
        SDL_mutexV(EffectFence);
}

canonical_original_code:
void SDLDrv_PCM_Unlock()
{
        if (--InterruptsDisabled)
            return;
        SDL_mutexV(EffectFence);
}


decompiled_code:
__int64 SDLDrv_CD_Init()
{
music = 0LL;
return 0LL;
}

canonical_decompiled_code:
__int64 func9()
{
music = 0LL;
return 0LL;
}

original_code:
int SDLDrv_CD_Init(void) {
    music = ((void *)0);
    return SDLErr_Ok;
}

canonical_original_code:
int SDLDrv_CD_Init() {
    music = ((void *)0);
    return SDLErr_Ok;
}


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

result = Mix_HaltMusic();
music = 0LL;
return result;
}

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

result = Mix_HaltMusic();
music = 0LL;
return result;
}

original_code:
void SDLDrv_CD_Stop(void) {
         Mix_HaltMusic();
         music = ((void *)0);
}

canonical_original_code:
void SDLDrv_CD_Stop() {
         Mix_HaltMusic();
         music = ((void *)0);
}


decompiled_code:
__int64 SDLDrv_CD_Shutdown()
{
return SDLDrv_CD_Stop();
}

canonical_decompiled_code:
__int64 func11()
{
return func10();
}

original_code:
void SDLDrv_CD_Shutdown(void) {
    SDLDrv_CD_Stop();
}

canonical_original_code:
void SDLDrv_CD_Shutdown() {
    SDLDrv_CD_Stop();
}


decompiled_code:
__int64 __fastcall CD_PlayFile(__int64 a1, int a2)
{
__int64 v2; // rdi
unsigned int v3; // ebx
const char *v5; // rax
const char *v6; // rax

if ( music )
SDLDrv_CD_Stop();
v2 = Mix_LoadMUS(a1);
music = v2;
if ( v2 )
{
v3 = Mix_PlayMusic(v2, (unsigned int)-(a2 != 0));
if ( v3 == -1 )
{
v6 = (const char *)SDL_GetError();
printf("Unable to playback OGG file: %s\n", v6);
ErrorCode = 5;
}
else
{
v3 = 0;
}
}
else
{
v5 = (const char *)SDL_GetError();
printf("Unable to load OGG file: %s\n", v5);
ErrorCode = 4;
v3 = -1;
}
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func12(__int64 a1, int a2)
{
__int64 v2; // rdi
unsigned int v3; // ebx
const char *v5; // rax
const char *v6; // rax

if ( music )
func10();
v2 = Mix_LoadMUS(a1);
music = v2;
if ( v2 )
{
v3 = Mix_PlayMusic(v2, (unsigned int)-(a2 != 0));
if ( v3 == -1 )
{
v6 = (const char *)SDL_GetError();
printf("Unable to playback OGG file: %s\n", v6);
ErrorCode = 5;
}
else
{
v3 = 0;
}
}
else
{
v5 = (const char *)SDL_GetError();
printf("Unable to load OGG file: %s\n", v5);
ErrorCode = 4;
v3 = -1;
}
return v3;
}

original_code:
int CD_PlayFile(const char * filename, int loop) {
    if (music != ((void *)0)) {
        SDLDrv_CD_Stop();
    }
    music = Mix_LoadMUS(filename);
    if(music == ((void *)0)) {
        printf("Unable to load OGG file: %s\n", SDL_GetError());
        ErrorCode = SDLErr_OpenOGG;
        return SDLErr_Error;
    }
    if(Mix_PlayMusic(music, loop ? -1 : 0) == -1) {
        printf("Unable to playback OGG file: %s\n", SDL_GetError());
        ErrorCode = SDLErr_PlayOGG;
        return SDLErr_Error;
    }
    return SDLErr_Ok;
}

canonical_original_code:
int CD_PlayFile(char *filename, int loop) {
    if (music != ((void *)0)) {
        SDLDrv_CD_Stop();
    }
    music = Mix_LoadMUS(filename);
    if(music == ((void *)0)) {
        printf("Unable to load OGG file: %s\n", SDL_GetError());
        ErrorCode = SDLErr_OpenOGG;
        return SDLErr_Error;
    }
    if(Mix_PlayMusic(music, loop ? -1 : 0) == -1) {
        printf("Unable to playback OGG file: %s\n", SDL_GetError());
        ErrorCode = SDLErr_PlayOGG;
        return SDLErr_Error;
    }
    return SDLErr_Ok;
}

variable_types:
filename
char *

variable_types: loop int


decompiled_code:
__int64 __fastcall CD_PlayByName(const char *a1, const char *a2, int a3)
{
char v5[216]; // [rsp+0h] [rbp-D8h] BYREF

sprintf(v5, "%s/%s", a2, a1);
return CD_PlayFile((__int64)v5, a3);
}

canonical_decompiled_code:
__int64 __fastcall func13(const char *a1, const char *a2, int a3)
{
char v5[216]; // [rsp+0h] [rbp-D8h] BYREF

sprintf(v5, "%s/%s", a2, a1);
return func12((__int64)v5, a3);
}

original_code:
int CD_PlayByName(const char *songname, const char *folder, int loop) {
    char filename[200];
    sprintf(filename, "%s/%s", folder, songname);
    return CD_PlayFile(filename, loop);
}

canonical_original_code:
int CD_PlayByName(char *songname, char *folder, int loop) {
    char filename[200];
    sprintf(filename, "%s/%s", folder, songname);
    return CD_PlayFile(filename, loop);
}

variable_types:
songname
char *

variable_types:
folder
char *

variable_types:
filename
char [200]


decompiled_code:
__int64 __fastcall SDLDrv_CD_Play(unsigned int a1, int a2)
{
char v3[216]; // [rsp+0h] [rbp-D8h] BYREF

sprintf(v3, "classic/MUSIC/Track%02d.ogg", a1);
return CD_PlayFile((__int64)v3, a2);
}

canonical_decompiled_code:
__int64 __fastcall func14(unsigned int a1, int a2)
{
char v3[216]; // [rsp+0h] [rbp-D8h] BYREF

sprintf(v3, "classic/MUSIC/Track%02d.ogg", a1);
return func12((__int64)v3, a2);
}

original_code:
int SDLDrv_CD_Play(int track, int loop) {
    char filename[200];
    sprintf(filename, "classic/MUSIC/Track%02d.ogg", track);
    return CD_PlayFile(filename, loop);
}

variable_types: track int


decompiled_code:
void SDLDrv_CD_Pause()
{
;
}

canonical_decompiled_code:
void func15()
{
;
}

original_code:
void SDLDrv_CD_Pause(int pauseon) {
}

canonical_original_code:
void SDLDrv_CD_Pause(int pauseon) {
}

variable_types: pauseon int


decompiled_code:
_BOOL8 SDLDrv_CD_IsPlaying()
{
return music != 0;
}

canonical_decompiled_code:
_BOOL8 func16()
{
return music != 0;
}

original_code:
int SDLDrv_CD_IsPlaying(void) {
    return music != ((void *)0);
}

canonical_original_code:
int SDLDrv_CD_IsPlaying() {
    return music != ((void *)0);
}


decompiled_code:
__int64 __fastcall SDLDrv_CD_SetVolume(int a1)
{
return Mix_VolumeMusic((unsigned int)(a1 / 2));
}

canonical_decompiled_code:
__int64 __fastcall func17(int a1)
{
return Mix_VolumeMusic((unsigned int)(a1 / 2));
}

original_code:
void SDLDrv_CD_SetVolume(int volume){
    Mix_VolumeMusic(volume/2);
}

variable_types: volume int


decompiled_code:
unsigned __int64 __fastcall seek_vorbis(__int64 a1, __int64 a2, int a3)
{
unsigned __int64 result; // rax

if ( a3 )
{
if ( a3 == 2 )
*(_QWORD *)(a1 + 16) = *(_QWORD *)(a1 + 8);
}
else
{
*(_QWORD *)(a1 + 16) = 0LL;
}
result = *(_QWORD *)(a1 + 16) + a2;
if ( result > *(_QWORD *)(a1 + 8) )
result = *(_QWORD *)(a1 + 8);
*(_QWORD *)(a1 + 16) = result;
return result;
}

canonical_decompiled_code:
unsigned __int64 __fastcall func0(__int64 a1, __int64 a2, int a3)
{
unsigned __int64 result; // rax

if ( a3 )
{
if ( a3 == 2 )
*(_QWORD *)(a1 + 16) = *(_QWORD *)(a1 + 8);
}
else
{
*(_QWORD *)(a1 + 16) = 0LL;
}
result = *(_QWORD *)(a1 + 16) + a2;
if ( result > *(_QWORD *)(a1 + 8) )
result = *(_QWORD *)(a1 + 8);
*(_QWORD *)(a1 + 16) = result;
return result;
}

original_code:
static int seek_vorbis(void * datasource, ogg_int64_t offset, int whence)
{
   vorbis_data * vorb = (vorbis_data *) datasource;
   switch (whence) {
      case 0: vorb->pos = 0; break;
      case 1: break;
      case 2: vorb->pos = vorb->length; break;
   }
   vorb->pos += offset;
   if (vorb->pos < 0) {
      vorb->pos = 0;
   } else if (vorb->pos > vorb->length) {
      vorb->pos = vorb->length;
   }
   return vorb->pos;
}

canonical_original_code:
static int seek_vorbis(void *datasource, long offset, int whence)
{
   struct vorbis_data *vorb = (vorbis_data *) datasource;
   switch (whence) {
      case 0: vorb->pos = 0; break;
      case 1: break;
      case 2: vorb->pos = vorb->length; break;
   }
   vorb->pos += offset;
   if (vorb->pos < 0) {
      vorb->pos = 0;
   } else if (vorb->pos > vorb->length) {
      vorb->pos = vorb->length;
   }
   return vorb->pos;
}

variable_types:
datasource
void *

variable_types: offset long

variable_types: whence int

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

user_defined_types: struct vorbis_data { void *ptr; unsigned long length; unsigned long pos; struct OggVorbis_File vf; char block[32768]; int lastbitstream; }

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

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


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

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

original_code:
static int close_vorbis(void * datasource)
{
   return 0;
}

canonical_original_code:
static int close_vorbis(void *datasource)
{
   return 0;
}


decompiled_code:
__int64 __fastcall tell_vorbis(__int64 a1)
{
return *(_QWORD *)(a1 + 16);
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1)
{
return *(_QWORD *)(a1 + 16);
}

original_code:
static long tell_vorbis(void * datasource)
{
   vorbis_data * vorb = (vorbis_data *) datasource;
   return vorb->pos;
}

canonical_original_code:
static long tell_vorbis(void *datasource)
{
   struct vorbis_data *vorb = (vorbis_data *) datasource;
   return vorb->pos;
}

return_type: long

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

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

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

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

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

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

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

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


decompiled_code:
__int64 __fastcall MV_GetNextVorbisBlock(__int64 a1)
{
__int64 v1; // r15
signed int v2; // ebp
__int64 v3; // r14
unsigned int v4; // eax
unsigned int v5; // ebx
__int64 v6; // rdx
unsigned int v7; // eax
__int64 result; // rax
int v9; // ecx
int v10; // edx
__int64 v11; // rax
int v12[15]; // [rsp+Ch] [rbp-3Ch] BYREF

v1 = *(_QWORD *)(a1 + 136);
v12[0] = 0;
*(_DWORD *)(a1 + 112) = 1;
v2 = 0;
v3 = v1 + 968;
while ( 1 )
{
v4 = ov_read(v1 + 24, v3 + v2, (unsigned int)(0x8000 - v2), 0LL, 2LL, 1LL, v12);
v5 = v4;
v6 = v4;
if ( v4 == -3 )
goto LABEL_4;
if ( !v4 )
break;
if ( (v4 & 0x80000000) != 0 )
{
fprintf(stderr, "MV_GetNextVorbisBlock ov_read: err %d\n", v4);
*(_DWORD *)(a1 + 112) = 0;
return 0LL;
}
LABEL_3:
v2 += v5;
LABEL_4:
if ( (unsigned int)v2 > 0x7FFF )
goto LABEL_13;
}
if ( *(_QWORD *)(a1 + 48) )
{
v7 = ov_pcm_seek_page(v1 + 24, 0LL, v4);
if ( !v7 )
goto LABEL_4;
fprintf(stderr, "MV_GetNextVorbisBlock ov_pcm_seek_page_lap: err %d\n", v7);
goto LABEL_3;
}
if ( !v2 )
{
*(_DWORD *)(a1 + 112) = 0;
return 0LL;
}
LABEL_13:
if ( *(_DWORD *)(v1 + 33736) == v12[0] )
{
LABEL_14:
*(_DWORD *)(v1 + 33736) = v12[0];
v9 = 2 * *(char *)(a1 + 21);
*(_DWORD *)(a1 + 108) = 0;
*(_QWORD *)(a1 + 88) = v3;
*(_DWORD *)(a1 + 72) = 0;
*(_DWORD *)(a1 + 96) = (v2 / v9) << 16;
result = 1LL;
}
else
{
result = ov_info(v1 + 24, 0xFFFFFFFFLL, v6);
if ( result )
{
v10 = *(_DWORD *)(result + 4);
if ( (unsigned int)(v10 - 1) <= 1 )
{
*(_BYTE *)(a1 + 21) = v10;
v11 = *(_QWORD *)(result + 8);
*(_DWORD *)(a1 + 100) = v11;
LODWORD(v11) = (unsigned int)(*(_DWORD *)(a1 + 76) * v11) / MV_MixRate;
*(_DWORD *)(a1 + 104) = v11;
*(_DWORD *)(a1 + 80) = 255 * v11;
MV_SetVoiceMixMode(a1);
goto LABEL_14;
}
*(_DWORD *)(a1 + 112) = 0;
result = 0LL;
}
else
{
*(_DWORD *)(a1 + 112) = 0;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1)
{
__int64 v1; // r15
signed int v2; // ebp
__int64 v3; // r14
unsigned int v4; // eax
unsigned int v5; // ebx
__int64 v6; // rdx
unsigned int v7; // eax
__int64 result; // rax
int v9; // ecx
int v10; // edx
__int64 v11; // rax
int v12[15]; // [rsp+Ch] [rbp-3Ch] BYREF

v1 = *(_QWORD *)(a1 + 136);
v12[0] = 0;
*(_DWORD *)(a1 + 112) = 1;
v2 = 0;
v3 = v1 + 968;
while ( 1 )
{
v4 = ov_read(v1 + 24, v3 + v2, (unsigned int)(0x8000 - v2), 0LL, 2LL, 1LL, v12);
v5 = v4;
v6 = v4;
if ( v4 == -3 )
goto LABEL_4;
if ( !v4 )
break;
if ( (v4 & 0x80000000) != 0 )
{
fprintf(stderr, "MV_GetNextVorbisBlock ov_read: err %d\n", v4);
*(_DWORD *)(a1 + 112) = 0;
return 0LL;
}
LABEL_3:
v2 += v5;
LABEL_4:
if ( (unsigned int)v2 > 0x7FFF )
goto LABEL_13;
}
if ( *(_QWORD *)(a1 + 48) )
{
v7 = ov_pcm_seek_page(v1 + 24, 0LL, v4);
if ( !v7 )
goto LABEL_4;
fprintf(stderr, "MV_GetNextVorbisBlock ov_pcm_seek_page_lap: err %d\n", v7);
goto LABEL_3;
}
if ( !v2 )
{
*(_DWORD *)(a1 + 112) = 0;
return 0LL;
}
LABEL_13:
if ( *(_DWORD *)(v1 + 33736) == v12[0] )
{
LABEL_14:
*(_DWORD *)(v1 + 33736) = v12[0];
v9 = 2 * *(char *)(a1 + 21);
*(_DWORD *)(a1 + 108) = 0;
*(_QWORD *)(a1 + 88) = v3;
*(_DWORD *)(a1 + 72) = 0;
*(_DWORD *)(a1 + 96) = (v2 / v9) << 16;
result = 1LL;
}
else
{
result = ov_info(v1 + 24, 0xFFFFFFFFLL, v6);
if ( result )
{
v10 = *(_DWORD *)(result + 4);
if ( (unsigned int)(v10 - 1) <= 1 )
{
*(_BYTE *)(a1 + 21) = v10;
v11 = *(_QWORD *)(result + 8);
*(_DWORD *)(a1 + 100) = v11;
LODWORD(v11) = (unsigned int)(*(_DWORD *)(a1 + 76) * v11) / MV_MixRate;
*(_DWORD *)(a1 + 104) = v11;
*(_DWORD *)(a1 + 80) = 255 * v11;
MV_SetVoiceMixMode(a1);
goto LABEL_14;
}
*(_DWORD *)(a1 + 112) = 0;
result = 0LL;
}
else
{
*(_DWORD *)(a1 + 112) = 0;
}
}
return result;
}

original_code:
static playbackstatus MV_GetNextVorbisBlock
(
 VoiceNode *voice
 )
{
   vorbis_data * vd = (vorbis_data *) voice->extra;
   int bytes = 0, bytesread = 0;
   int bitstream = 0, err = 0;
   voice->Playing = ( 1 == 1 );
   bytesread = 0;
   do {
      bytes = ov_read(&vd->vf, vd->block + bytesread, sizeof(vd->block) - bytesread, 0, 2, 1, &bitstream);
      if (bytes == -3) continue;
      if (bytes == 0) {
         if (voice->LoopStart) {
            err = ov_pcm_seek_page(&vd->vf, 0);
            if (err != 0) {
               fprintf(stderr, "MV_GetNextVorbisBlock ov_pcm_seek_page_lap: err %d\n", err);
            } else {
               continue;
            }
         } else {
           break;
         }
      } else if (bytes < 0) {
         fprintf(stderr, "MV_GetNextVorbisBlock ov_read: err %d\n", bytes);
         voice->Playing = ( !( 1 == 1 ) );
         return NoMoreData;
      }
      bytesread += bytes;
   } while (bytesread < sizeof(vd->block));
   if (bytesread == 0) {
      voice->Playing = ( !( 1 == 1 ) );
      return NoMoreData;
   }
   if (bitstream != vd->lastbitstream) {
      vorbis_info * vi = 0;
      vi = ov_info(&vd->vf, -1);
      if (!vi) {
         voice->Playing = ( !( 1 == 1 ) );
         return NoMoreData;
      }
      if (vi->channels != 1 && vi->channels != 2) {
         voice->Playing = ( !( 1 == 1 ) );
         return NoMoreData;
      }
      voice->channels = vi->channels;
      voice->SamplingRate = vi->rate;
      voice->RateScale = ( voice->SamplingRate * voice->PitchScale ) / MV_MixRate;
      voice->FixedPointBufferSize = ( voice->RateScale * 256 ) -
         voice->RateScale;
      MV_SetVoiceMixMode( voice );
   }
   vd->lastbitstream = bitstream;
   bytesread /= 2 * voice->channels;
   voice->position = 0;
   voice->sound = vd->block;
   voice->BlockLength = 0;
   voice->length = bytesread << 16;
   return( KeepPlaying );
}

canonical_original_code:
static enum playbackstatus MV_GetNextVorbisBlock(struct VoiceNode *voice)
{
   struct vorbis_data *vd = (vorbis_data *) voice->extra;
   int bytes = 0; int bytesread = 0;
   int bitstream = 0; int err = 0;
   voice->Playing = ( 1 == 1 );
   bytesread = 0;
   do {
      bytes = ov_read(&vd->vf, vd->block + bytesread, sizeof(vd->block) - bytesread, 0, 2, 1, &bitstream);
      if (bytes == -3) continue;
      if (bytes == 0) {
         if (voice->LoopStart) {
            err = ov_pcm_seek_page(&vd->vf, 0);
            if (err != 0) {
               fprintf(stderr, "MV_GetNextVorbisBlock ov_pcm_seek_page_lap: err %d\n", err);
            } else {
               continue;
            }
         } else {
           break;
         }
      } else if (bytes < 0) {
         fprintf(stderr, "MV_GetNextVorbisBlock ov_read: err %d\n", bytes);
         voice->Playing = ( !( 1 == 1 ) );
         return NoMoreData;
      }
      bytesread += bytes;
   } while (bytesread < sizeof(vd->block));
   if (bytesread == 0) {
      voice->Playing = ( !( 1 == 1 ) );
      return NoMoreData;
   }
   if (bitstream != vd->lastbitstream) {
      struct vorbis_info *vi = 0;
      vi = ov_info(&vd->vf, -1);
      if (!vi) {
         voice->Playing = ( !( 1 == 1 ) );
         return NoMoreData;
      }
      if (vi->channels != 1 && vi->channels != 2) {
         voice->Playing = ( !( 1 == 1 ) );
         return NoMoreData;
      }
      voice->channels = vi->channels;
      voice->SamplingRate = vi->rate;
      voice->RateScale = ( voice->SamplingRate * voice->PitchScale ) / MV_MixRate;
      voice->FixedPointBufferSize = ( voice->RateScale * 256 ) -
         voice->RateScale;
      MV_SetVoiceMixMode( voice );
   }
   vd->lastbitstream = bitstream;
   bytesread /= 2 * voice->channels;
   voice->position = 0;
   voice->sound = vd->block;
   voice->BlockLength = 0;
   voice->length = bytesread << 16;
   return( KeepPlaying );
}

variable_types: struct VoiceNode { struct VoiceNode *next; struct VoiceNode *prev; enum wavedata { Raw=0, VOC=1, DemandFeed=2, WAV=3, Vorbis=4 } wavetype; char bits; char channels; enum playbackstatus { NoMoreData=0, KeepPlaying=1 } (*GetSound)(struct VoiceNode *voice); void (*mix)(unsigned int position, unsigned int rate, char *start, unsigned int length); char *NextBlock; char *LoopStart; char *LoopEnd; unsigned int LoopCount; unsigned int LoopSize; unsigned int BlockLength; unsigned int PitchScale; unsigned int FixedPointBufferSize; char *sound; unsigned int length; unsigned int SamplingRate; unsigned int RateScale; unsigned int position; int Playing; int Paused; int handle; int priority; void (*DemandFeed)(char **ptr, unsigned int *length); void *extra; short *LeftVolume; short *RightVolume; unsigned int callbackval; } *

variable_types: bytes int

variable_types: bytesread int

variable_types: bitstream int

variable_types: err int

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

user_defined_types: struct VoiceNode { struct VoiceNode *next; struct VoiceNode *prev; enum wavedata wavetype; char bits; char channels; enum playbackstatus (*GetSound)(struct VoiceNode *voice); void (*mix)(unsigned int position, unsigned int rate, char *start, unsigned int length); char *NextBlock; char *LoopStart; char *LoopEnd; unsigned int LoopCount; unsigned int LoopSize; unsigned int BlockLength; unsigned int PitchScale; unsigned int FixedPointBufferSize; char *sound; unsigned int length; unsigned int SamplingRate; unsigned int RateScale; unsigned int position; int Playing; int Paused; int handle; int priority; void (*DemandFeed)(char **ptr, unsigned int *length); void *extra; short *LeftVolume; short *RightVolume; unsigned int callbackval; }


original_code:
static size_t read_vorbis(void * ptr, size_t size, size_t nmemb, void * datasource)
{
   vorbis_data * vorb = (vorbis_data *) datasource;
   size_t nread = 0;
   size_t bytes;
   (*__errno_location ()) = 0;
   if (vorb->length == vorb->pos) {
      return 0;
   }
   for (; nmemb > 0; nmemb--, nread++) {
      bytes = vorb->length - vorb->pos;
      if (size < bytes) {
         bytes = size;
      }
      memcpy(ptr, vorb->ptr + vorb->pos, bytes);
      vorb->pos += bytes;
      ptr += bytes;
      if (vorb->length == vorb->pos) {
         nread++;
         break;
      }
   }
   return nread;
}

canonical_original_code:
static unsigned long read_vorbis(void *ptr, unsigned long size, unsigned long nmemb, void *datasource)
{
   struct vorbis_data *vorb = (vorbis_data *) datasource;
   unsigned long nread = 0;
   unsigned long bytes;
   (*__errno_location ()) = 0;
   if (vorb->length == vorb->pos) {
      return 0;
   }
   for (; nmemb > 0; nmemb--, nread++) {
      bytes = vorb->length - vorb->pos;
      if (size < bytes) {
         bytes = size;
      }
      memcpy(ptr, vorb->ptr + vorb->pos, bytes);
      vorb->pos += bytes;
      ptr += bytes;
      if (vorb->length == vorb->pos) {
         nread++;
         break;
      }
   }
   return nread;
}

variable_types:
ptr
void *

variable_types:
size
unsigned long

variable_types:
nmemb
unsigned long

variable_types:
nread
unsigned long

variable_types:
bytes
unsigned long

return_type: unsigned long


original_code:
int MV_PlayLoopedVorbis
(
 char *ptr,
 unsigned int ptrlength,
 int loopstart,
 int loopend,
 int pitchoffset,
 int vol,
 int left,
 int right,
 int priority,
 unsigned int callbackval
 )
{
   VoiceNode *voice;
   int status;
   vorbis_data * vd = 0;
   vorbis_info * vi = 0;
   if ( !MV_Installed )
   {
      MV_ErrorCode = ( MV_NotInstalled );;
      return( MV_Error );
   }
   vd = (vorbis_data *) malloc( sizeof(vorbis_data) );
   if (!vd) {
      MV_ErrorCode = ( MV_InvalidVorbisFile );;
      return MV_Error;
   }
   memset(vd, 0, sizeof(vorbis_data));
   vd->ptr = ptr;
   vd->pos = 0;
   vd->length = ptrlength;
   vd->lastbitstream = -1;
   status = ov_open_callbacks((void *) vd, &vd->vf, 0, 0, vorbis_callbacks);
   if (status < 0) {
      fprintf(stderr, "MV_PlayLoopedVorbis: err %d\n", status);
      MV_ErrorCode = ( MV_InvalidVorbisFile );;
      return MV_Error;
   }
   vi = ov_info(&vd->vf, 0);
   if (!vi) {
      ov_clear(&vd->vf);
      free(vd);
      MV_ErrorCode = ( MV_InvalidVorbisFile );;
      return MV_Error;
   }
   if (vi->channels != 1 && vi->channels != 2) {
      ov_clear(&vd->vf);
      free(vd);
      MV_ErrorCode = ( MV_InvalidVorbisFile );;
      return MV_Error;
   }
   voice = MV_AllocVoice( priority );
   if ( voice == ((void *)0) )
   {
      ov_clear(&vd->vf);
      free(vd);
      MV_ErrorCode = ( MV_NoVoices );;
      return( MV_Error );
   }
   voice->wavetype = Vorbis;
   voice->bits = 16;
   voice->channels = vi->channels;
   voice->extra = (void *) vd;
   voice->GetSound = MV_GetNextVorbisBlock;
   voice->NextBlock = vd->block;
   voice->DemandFeed = ((void *)0);
   voice->LoopCount = 0;
   voice->BlockLength = 0;
   voice->PitchScale = PITCH_GetScale( pitchoffset );
   voice->length = 0;
   voice->next = ((void *)0);
   voice->prev = ((void *)0);
   voice->priority = priority;
   voice->callbackval = callbackval;
   voice->LoopStart = (char *) (loopstart >= 0 ? ( 1 == 1 ) : ( !( 1 == 1 ) ));
   voice->LoopEnd = 0;
   voice->LoopSize = 0;
   voice->Playing = ( 1 == 1 );
   voice->Paused = ( !( 1 == 1 ) );
   voice->SamplingRate = vi->rate;
   voice->RateScale = ( voice->SamplingRate * voice->PitchScale ) / MV_MixRate;
   voice->FixedPointBufferSize = ( voice->RateScale * 256 ) -
      voice->RateScale;
   MV_SetVoiceMixMode( voice );
   MV_SetVoiceVolume( voice, vol, left, right );
   MV_PlayVoice( voice );
   return( voice->handle );
}

canonical_original_code:
int MV_PlayLoopedVorbis(char *ptr, unsigned int ptrlength, int loopstart, int loopend, int pitchoffset, int vol, int left, int right, int priority, unsigned int callbackval)
{
   struct VoiceNode *voice;
   int status;
   struct vorbis_data *vd = 0;
   struct vorbis_info *vi = 0;
   if ( !MV_Installed )
   {
      MV_ErrorCode = ( MV_NotInstalled );;
      return( MV_Error );
   }
   vd = (struct vorbis_data *) malloc( sizeof(vorbis_data) );
   if (!vd) {
      MV_ErrorCode = ( MV_InvalidVorbisFile );;
      return MV_Error;
   }
   memset(vd, 0, sizeof(vorbis_data));
   vd->ptr = ptr;
   vd->pos = 0;
   vd->length = ptrlength;
   vd->lastbitstream = -1;
   status = ov_open_callbacks((void *) vd, &vd->vf, 0, 0, vorbis_callbacks);
   if (status < 0) {
      fprintf(stderr, "MV_PlayLoopedVorbis: err %d\n", status);
      MV_ErrorCode = ( MV_InvalidVorbisFile );;
      return MV_Error;
   }
   vi = ov_info(&vd->vf, 0);
   if (!vi) {
      ov_clear(&vd->vf);
      free(vd);
      MV_ErrorCode = ( MV_InvalidVorbisFile );;
      return MV_Error;
   }
   if (vi->channels != 1 && vi->channels != 2) {
      ov_clear(&vd->vf);
      free(vd);
      MV_ErrorCode = ( MV_InvalidVorbisFile );;
      return MV_Error;
   }
   voice = MV_AllocVoice( priority );
   if ( voice == ((void *)0) )
   {
      ov_clear(&vd->vf);
      free(vd);
      MV_ErrorCode = ( MV_NoVoices );;
      return( MV_Error );
   }
   voice->wavetype = Vorbis;
   voice->bits = 16;
   voice->channels = vi->channels;
   voice->extra = (void *) vd;
   voice->GetSound = MV_GetNextVorbisBlock;
   voice->NextBlock = vd->block;
   voice->DemandFeed = ((void *)0);
   voice->LoopCount = 0;
   voice->BlockLength = 0;
   voice->PitchScale = PITCH_GetScale( pitchoffset );
   voice->length = 0;
   voice->next = ((void *)0);
   voice->prev = ((void *)0);
   voice->priority = priority;
   voice->callbackval = callbackval;
   voice->LoopStart = (char *) (loopstart >= 0 ? ( 1 == 1 ) : ( !( 1 == 1 ) ));
   voice->LoopEnd = 0;
   voice->LoopSize = 0;
   voice->Playing = ( 1 == 1 );
   voice->Paused = ( !( 1 == 1 ) );
   voice->SamplingRate = vi->rate;
   voice->RateScale = ( voice->SamplingRate * voice->PitchScale ) / MV_MixRate;
   voice->FixedPointBufferSize = ( voice->RateScale * 256 ) -
      voice->RateScale;
   MV_SetVoiceMixMode( voice );
   MV_SetVoiceVolume( voice, vol, left, right );
   MV_PlayVoice( voice );
   return( voice->handle );
}

variable_types:
ptr
char *

variable_types:
ptrlength
unsigned int

variable_types: loopstart int

variable_types: loopend int

variable_types: pitchoffset int

variable_types: vol int

variable_types: left int

variable_types: right int

variable_types: priority int

variable_types:
callbackval
unsigned int

variable_types: status int

user_defined_types: enum wavedata { Raw=0, VOC=1, DemandFeed=2, WAV=3, Vorbis=4 }

user_defined_types: enum playbackstatus { NoMoreData=0, KeepPlaying=1 }


decompiled_code:
__int64 __fastcall MV_PlayVorbis(__int64 a1, unsigned int a2, unsigned int a3, unsigned int a4, unsigned int a5, unsigned int a6, unsigned int a7, int a8)
{
return MV_PlayLoopedVorbis(a1, a2, -1, 0xFFFFFFFFLL, a3, a4, a5, a6, a7, a8);
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1, unsigned int a2, unsigned int a3, unsigned int a4, unsigned int a5, unsigned int a6, unsigned int a7, int a8)
{
return func5(a1, a2, -1, 0xFFFFFFFFLL, a3, a4, a5, a6, a7, a8);
}

original_code:
int MV_PlayVorbis
(
 char *ptr,
 unsigned int ptrlength,
 int pitchoffset,
 int vol,
 int left,
 int right,
 int priority,
 unsigned int callbackval
 )
{
   int status;
   status = MV_PlayLoopedVorbis( ptr, ptrlength, -1, -1, pitchoffset, vol, left, right,
                                 priority, callbackval );
   return( status );
}

canonical_original_code:
int MV_PlayVorbis(char *ptr, unsigned int ptrlength, int pitchoffset, int vol, int left, int right, int priority, unsigned int callbackval)
{
   int status;
   status = MV_PlayLoopedVorbis( ptr, ptrlength, -1, -1, pitchoffset, vol, left, right,
                                 priority, callbackval );
   return( status );
}


decompiled_code:
__int64 __fastcall MV_PlayVorbis3D(__int64 a1, unsigned int a2, unsigned int a3, char a4, int a5, unsigned int a6, int a7)
{
int v7; // ebx
unsigned __int64 v8; // rax
unsigned int v9; // ecx
__int64 result; // rax

if ( MV_Installed )
{
if ( a5 < 0 )
{
a5 = -a5;
a4 += 16;
}
v7 = 255;
if ( a5 <= 255 )
v7 = a5;
if ( v7 < 0 )
v7 = 0;
v8 = ((unsigned __int64)(a4 & 0x1F) << 6) + ((v7 * (MV_MaxVolume + 1)) >> 8);
v9 = 255 - a5;
if ( 255 - a5 < 0 )
v9 = 0;
result = MV_PlayVorbis(a1, a2, a3, v9, MV_PanTable[2 * v8], MV_PanTable[2 * v8 + 1], a6, a7);
}
else
{
MV_ErrorCode = 2;
result = 0xFFFFFFFFLL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1, unsigned int a2, unsigned int a3, char a4, int a5, unsigned int a6, int a7)
{
int v7; // ebx
unsigned __int64 v8; // rax
unsigned int v9; // ecx
__int64 result; // rax

if ( MV_Installed )
{
if ( a5 < 0 )
{
a5 = -a5;
a4 += 16;
}
v7 = 255;
if ( a5 <= 255 )
v7 = a5;
if ( v7 < 0 )
v7 = 0;
v8 = ((unsigned __int64)(a4 & 0x1F) << 6) + ((v7 * (MV_MaxVolume + 1)) >> 8);
v9 = 255 - a5;
if ( 255 - a5 < 0 )
v9 = 0;
result = func6(a1, a2, a3, v9, MV_PanTable[2 * v8], MV_PanTable[2 * v8 + 1], a6, a7);
}
else
{
MV_ErrorCode = 2;
result = 0xFFFFFFFFLL;
}
return result;
}

original_code:
int MV_PlayVorbis3D
(
 char *ptr,
 unsigned int ptrlength,
 int pitchoffset,
 int angle,
 int distance,
 int priority,
 unsigned int callbackval
 )
{
   int left;
   int right;
   int mid;
   int volume;
   int status;
   if ( !MV_Installed )
   {
      MV_ErrorCode = ( MV_NotInstalled );;
      return( MV_Error );
   }
   if ( distance < 0 )
   {
      distance = -distance;
      angle += ( 31 + 1 ) / 2;
   }
   volume = ( ( ((0) > (((( distance )) < (255) ? (( distance )) : (255))) ? (0) : (((( distance )) < (255) ? (( distance )) : (255)))) * ( MV_MaxVolume + 1 ) ) >> 8 );
   angle &= 31;
   left = MV_PanTable[ angle ][ volume ].left;
   right = MV_PanTable[ angle ][ volume ].right;
   mid = ((0) > (255 - distance) ? (0) : (255 - distance));
   status = MV_PlayVorbis( ptr, ptrlength, pitchoffset, mid, left, right, priority,
                           callbackval );
   return( status );
}

canonical_original_code:
int MV_PlayVorbis3D(char *ptr, unsigned int ptrlength, int pitchoffset, int angle, int distance, int priority, unsigned int callbackval)
{
   int left;
   int right;
   int mid;
   int volume;
   int status;
   if ( !MV_Installed )
   {
      MV_ErrorCode = ( MV_NotInstalled );;
      return( MV_Error );
   }
   if ( distance < 0 )
   {
      distance = -distance;
      angle += ( 31 + 1 ) / 2;
   }
   volume = ( ( ((0) > (((( distance )) < (255) ? (( distance )) : (255))) ? (0) : (((( distance )) < (255) ? (( distance )) : (255)))) * ( MV_MaxVolume + 1 ) ) >> 8 );
   angle &= 31;
   left = MV_PanTable[ angle ][ volume ].left;
   right = MV_PanTable[ angle ][ volume ].right;
   mid = ((0) > (255 - distance) ? (0) : (255 - distance));
   status = MV_PlayVorbis( ptr, ptrlength, pitchoffset, mid, left, right, priority,
                           callbackval );
   return( status );
}

variable_types: angle int

variable_types: distance int

variable_types: mid int

variable_types: volume int


decompiled_code:
void __fastcall MV_ReleaseVorbisVoice(__int64 a1)
{
char *v1; // rbp

if ( *(_DWORD *)(a1 + 16) == 4 )
{
v1 = *(char **)(a1 + 136);
ov_clear(v1 + 24);
free(v1);
*(_QWORD *)(a1 + 136) = 0LL;
}
}

original_code:
void MV_ReleaseVorbisVoice( VoiceNode * voice )
{
   vorbis_data * vd = (vorbis_data *) voice->extra;
   if (voice->wavetype != Vorbis) {
      return;
   }
   ov_clear(&vd->vf);
   free(vd);
   voice->extra = 0;
}

canonical_original_code:
void MV_ReleaseVorbisVoice(struct VoiceNode *voice)
{
   struct vorbis_data *vd = (vorbis_data *) voice->extra;
   if (voice->wavetype != Vorbis) {
      return;
   }
   ov_clear(&vd->vf);
   free(vd);
   voice->extra = 0;
}

variable_types: struct VoiceNode { struct VoiceNode *next; struct VoiceNode *prev; enum wavedata { Raw=0, VOC=1, DemandFeed=2, WAV=3, Vorbis=4 } wavetype; char bits; char channels; enum playbackstatus { NoMoreData=0, KeepPlaying=1 } (*GetSound)(struct VoiceNode *voice); void (*mix)(unsigned int position, unsigned int rate, char *start, unsigned int length); char *NextBlock; char *LoopStart; char *LoopEnd; unsigned int LoopCount; unsigned int LoopSize; unsigned int BlockLength; unsigned int PitchScale; unsigned int FixedPointBufferSize; char *sound; unsigned int length; unsigned int SamplingRate; unsigned int RateScale; unsigned int position; int Playing; int Paused; int handle; int priority; void (*DemandFeed)(char **ptr, unsigned int *length); void *extra; short *LeftVolume; short *RightVolume; unsigned int callbackval; } *

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


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

switch ( a1 )
{
case -2:
case -1:
result = (const char *)MUSIC_ErrorString((unsigned int)MUSIC_ErrorCode);
break;
case 0:
result = "Music ok.";
break;
case 1:
v2 = SoundDriver_MIDI_GetError();
result = (const char *)SoundDriver_MIDI_ErrorString(v2);
break;
case 2:
result = "Invalid Music device.";
break;
case 3:
result = "Error playing MIDI file.";
break;
default:
result = "Unknown Music error code.";
break;
}
return result;
}

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

switch ( a1 )
{
case -2:
case -1:
result = (const char *)func0((unsigned int)MUSIC_ErrorCode);
break;
case 0:
result = "Music ok.";
break;
case 1:
v2 = SoundDriver_MIDI_GetError();
result = (const char *)SoundDriver_MIDI_ErrorString(v2);
break;
case 2:
result = "Invalid Music device.";
break;
case 3:
result = "Error playing MIDI file.";
break;
default:
result = "Unknown Music error code.";
break;
}
return result;
}

original_code:
const char *MUSIC_ErrorString
   (
   int ErrorNumber
   )
   {
   const char *ErrorString;
   switch( ErrorNumber )
      {
      case MUSIC_Warning :
      case MUSIC_Error :
         ErrorString = MUSIC_ErrorString( MUSIC_ErrorCode );
         break;
      case MUSIC_Ok :
         ErrorString = "Music ok.";
         break;
      case MUSIC_DriverError :
         ErrorString = SoundDriver_MIDI_ErrorString(SoundDriver_MIDI_GetError());
         break;
      case MUSIC_InvalidCard :
         ErrorString = "Invalid Music device.";
         break;
      case MUSIC_MidiError :
         ErrorString = "Error playing MIDI file.";
         break;
      default :
         ErrorString = "Unknown Music error code.";
         break;
      }
   return( ErrorString );
   }

canonical_original_code:
char *MUSIC_ErrorString(int ErrorNumber)
   {
   char *ErrorString;
   switch( ErrorNumber )
      {
      case MUSIC_Warning :
      case MUSIC_Error :
         ErrorString = MUSIC_ErrorString( MUSIC_ErrorCode );
         break;
      case MUSIC_Ok :
         ErrorString = "Music ok.";
         break;
      case MUSIC_DriverError :
         ErrorString = SoundDriver_MIDI_ErrorString(SoundDriver_MIDI_GetError());
         break;
      case MUSIC_InvalidCard :
         ErrorString = "Invalid Music device.";
         break;
      case MUSIC_MidiError :
         ErrorString = "Error playing MIDI file.";
         break;
      default :
         ErrorString = "Unknown Music error code.";
         break;
      }
   return( ErrorString );
   }

variable_types: ErrorNumber int

variable_types:
ErrorString
char *


decompiled_code:
__int64 __fastcall MUSIC_Init(unsigned int a1)
{
unsigned int v1; // ebx
__int64 i; // rax
unsigned int v3; // ebx

v1 = a1;
for ( i = 0LL; i != 128; ++i )
*((_BYTE *)&MIDI_PatchMap + i) = i;
if ( a1 == -2 )
{
v1 = 6;
}
else if ( a1 > 6 )
{
MUSIC_ErrorCode = 2;
return (unsigned int)-1;
}
if ( (unsigned int)SoundDriver_IsMIDISupported(v1) )
{
ASS_MIDISoundDriver = v1;
v3 = SoundDriver_MIDI_Init(&MUSIC_MidiFunctions);
if ( v3 )
{
MUSIC_ErrorCode = 1;
v3 = -1;
}
else
{
MIDI_SetMidiFuncs(&MUSIC_MidiFunctions);
}
}
else
{
MUSIC_ErrorCode = 2;
v3 = -1;
}
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func1(unsigned int a1)
{
unsigned int v1; // ebx
__int64 i; // rax
unsigned int v3; // ebx

v1 = a1;
for ( i = 0LL; i != 128; ++i )
*((_BYTE *)&MIDI_PatchMap + i) = i;
if ( a1 == -2 )
{
v1 = 6;
}
else if ( a1 > 6 )
{
MUSIC_ErrorCode = 2;
return (unsigned int)-1;
}
if ( (unsigned int)SoundDriver_IsMIDISupported(v1) )
{
ASS_MIDISoundDriver = v1;
v3 = SoundDriver_MIDI_Init(&MUSIC_MidiFunctions);
if ( v3 )
{
MUSIC_ErrorCode = 1;
v3 = -1;
}
else
{
MIDI_SetMidiFuncs(&MUSIC_MidiFunctions);
}
}
else
{
MUSIC_ErrorCode = 2;
v3 = -1;
}
return v3;
}

original_code:
int MUSIC_Init
   (
   int SoundCard,
   int Address
   )
   {
   int i;
   int status;
   for( i = 0; i < 128; i++ )
      {
      MIDI_PatchMap[ i ] = i;
      }
 if (SoundCard == ASS_AutoDetect) {
        SoundCard = ASS_ALSA;
 }
 if (SoundCard < 0 || SoundCard >= ASS_NumSoundCards) {
  MUSIC_ErrorCode = MUSIC_InvalidCard;
  return MUSIC_Error;
 }
    if (!SoundDriver_IsMIDISupported(SoundCard))
      {
      MUSIC_ErrorCode = MUSIC_InvalidCard;
      return MUSIC_Error;
      }
   ASS_MIDISoundDriver = SoundCard;
   status = SoundDriver_MIDI_Init(&MUSIC_MidiFunctions);
   if (status != MUSIC_Ok)
      {
      MUSIC_ErrorCode = MUSIC_DriverError;
      return MUSIC_Error;
      }
   MIDI_SetMidiFuncs( &MUSIC_MidiFunctions );
   return MUSIC_Ok;
   }

canonical_original_code:
int MUSIC_Init(int SoundCard, int Address)
   {
   int i;
   int status;
   for( i = 0; i < 128; i++ )
      {
      MIDI_PatchMap[ i ] = i;
      }
 if (SoundCard == ASS_AutoDetect) {
        SoundCard = ASS_ALSA;
 }
 if (SoundCard < 0 || SoundCard >= ASS_NumSoundCards) {
  MUSIC_ErrorCode = MUSIC_InvalidCard;
  return MUSIC_Error;
 }
    if (!SoundDriver_IsMIDISupported(SoundCard))
      {
      MUSIC_ErrorCode = MUSIC_InvalidCard;
      return MUSIC_Error;
      }
   ASS_MIDISoundDriver = SoundCard;
   status = SoundDriver_MIDI_Init(&MUSIC_MidiFunctions);
   if (status != MUSIC_Ok)
      {
      MUSIC_ErrorCode = MUSIC_DriverError;
      return MUSIC_Error;
      }
   MIDI_SetMidiFuncs( &MUSIC_MidiFunctions );
   return MUSIC_Ok;
   }

variable_types: SoundCard int

variable_types: Address int

variable_types: i int


decompiled_code:
__int64 MUSIC_Shutdown()
{
MIDI_StopSong();
SoundDriver_MIDI_Shutdown();
return 0LL;
}

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

original_code:
int MUSIC_Shutdown
   (
   void
   )
   {
   MIDI_StopSong();
   SoundDriver_MIDI_Shutdown();
   return MUSIC_Ok;
   }

canonical_original_code:
int MUSIC_Shutdown()
   {
   MIDI_StopSong();
   SoundDriver_MIDI_Shutdown();
   return MUSIC_Ok;
   }


decompiled_code:
void MUSIC_SetMaxFMMidiChannel()
{
;
}

canonical_decompiled_code:
void func3()
{
;
}

original_code:
void MUSIC_SetMaxFMMidiChannel
   (
   int channel
   )
   {
   }

canonical_original_code:
void MUSIC_SetMaxFMMidiChannel(int channel)
   {
   }

variable_types: channel int


decompiled_code:
void MUSIC_SetVolume()
{
;
}

canonical_decompiled_code:
void func4()
{
;
}

original_code:
void MUSIC_SetVolume
   (
   int volume
   )
   {
   volume = ((0) > (volume) ? (0) : (volume));
   volume = ((volume) < (255) ? (volume) : (255));
   }

canonical_original_code:
void MUSIC_SetVolume(int volume)
   {
   volume = ((0) > (volume) ? (0) : (volume));
   volume = ((volume) < (255) ? (volume) : (255));
   }


decompiled_code:
__int64 MUSIC_SetMidiChannelVolume()
{
return MIDI_SetUserChannelVolume();
}

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

original_code:
void MUSIC_SetMidiChannelVolume
   (
   int channel,
   int volume
   )
   {
   MIDI_SetUserChannelVolume( channel, volume );
   }

canonical_original_code:
void MUSIC_SetMidiChannelVolume(int channel, int volume)
   {
   MIDI_SetUserChannelVolume( channel, volume );
   }


decompiled_code:
__int64 MUSIC_ResetMidiChannelVolumes()
{
return MIDI_ResetUserChannelVolume();
}

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

original_code:
void MUSIC_ResetMidiChannelVolumes
   (
   void
   )
   {
   MIDI_ResetUserChannelVolume();
   }

canonical_original_code:
void MUSIC_ResetMidiChannelVolumes()
   {
   MIDI_ResetUserChannelVolume();
   }


decompiled_code:
__int64 MUSIC_GetVolume()
{
return MIDI_GetVolume();
}

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

original_code:
int MUSIC_GetVolume
   (
   void
   )
   {
   return( MIDI_GetVolume() );
   }

canonical_original_code:
int MUSIC_GetVolume()
   {
   return( MIDI_GetVolume() );
   }


decompiled_code:
__int64 MUSIC_SetLoopFlag()
{
return MIDI_SetLoopFlag();
}

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

original_code:
void MUSIC_SetLoopFlag
   (
   int loopflag
   )
   {
   MIDI_SetLoopFlag( loopflag );
   }

canonical_original_code:
void MUSIC_SetLoopFlag(int loopflag)
   {
   MIDI_SetLoopFlag( loopflag );
   }

variable_types: loopflag int


decompiled_code:
__int64 MUSIC_SongPlaying()
{
return MIDI_SongPlaying();
}

canonical_decompiled_code:
__int64 func9()
{
return MIDI_SongPlaying();
}

original_code:
int MUSIC_SongPlaying
   (
   void
   )
   {
   return( MIDI_SongPlaying() );
   }

canonical_original_code:
int MUSIC_SongPlaying()
   {
   return( MIDI_SongPlaying() );
   }


decompiled_code:
__int64 MUSIC_Continue()
{
return MIDI_ContinueSong();
}

canonical_decompiled_code:
__int64 func10()
{
return MIDI_ContinueSong();
}

original_code:
void MUSIC_Continue
   (
   void
   )
   {
   MIDI_ContinueSong();
   }

canonical_original_code:
void MUSIC_Continue()
   {
   MIDI_ContinueSong();
   }


decompiled_code:
__int64 MUSIC_Pause()
{
return MIDI_PauseSong();
}

canonical_decompiled_code:
__int64 func11()
{
return MIDI_PauseSong();
}

original_code:
void MUSIC_Pause
   (
   void
   )
   {
   MIDI_PauseSong();
   }

canonical_original_code:
void MUSIC_Pause()
   {
   MIDI_PauseSong();
   }


decompiled_code:
__int64 MUSIC_StopSong()
{
MIDI_StopSong();
MUSIC_ErrorCode = 0;
return 0LL;
}

canonical_decompiled_code:
__int64 func12()
{
MIDI_StopSong();
MUSIC_ErrorCode = 0;
return 0LL;
}

original_code:
int MUSIC_StopSong
   (
   void
   )
   {
   MUSIC_StopFade();
   MIDI_StopSong();
   MUSIC_ErrorCode = ( MUSIC_Ok );;
   return( MUSIC_Ok );
   }

canonical_original_code:
int MUSIC_StopSong()
   {
   MUSIC_StopFade();
   MIDI_StopSong();
   MUSIC_ErrorCode = ( MUSIC_Ok );;
   return( MUSIC_Ok );
   }


decompiled_code:
__int64 __fastcall MUSIC_PlaySong(__int64 a1, __int64 a2, unsigned int a3)
{
__int64 result; // rax

MIDI_StopSong();
result = MIDI_PlaySong(a1, a3);
if ( (_DWORD)result )
{
MUSIC_ErrorCode = 3;
result = 4294967294LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func13(__int64 a1, __int64 a2, unsigned int a3)
{
__int64 result; // rax

MIDI_StopSong();
result = MIDI_PlaySong(a1, a3);
if ( (_DWORD)result )
{
MUSIC_ErrorCode = 3;
result = 4294967294LL;
}
return result;
}

original_code:
int MUSIC_PlaySong
   (
   unsigned char *song,
   unsigned int length,
   int loopflag
   )
   {
   int status;
   MIDI_StopSong();
   status = MIDI_PlaySong( song, loopflag );
   if ( status != MIDI_Ok )
      {
      MUSIC_ErrorCode = ( MUSIC_MidiError );;
      return( MUSIC_Warning );
      }
   return( MUSIC_Ok );
   }

canonical_original_code:
int MUSIC_PlaySong(unsigned char *song, unsigned int length, int loopflag)
   {
   int status;
   MIDI_StopSong();
   status = MIDI_PlaySong( song, loopflag );
   if ( status != MIDI_Ok )
      {
      MUSIC_ErrorCode = ( MUSIC_MidiError );;
      return( MUSIC_Warning );
      }
   return( MUSIC_Ok );
   }

variable_types:
song
unsigned char *

variable_types:
length
unsigned int


decompiled_code:
__int64 MUSIC_SetContext()
{
return MIDI_SetContext();
}

canonical_decompiled_code:
__int64 func14()
{
return MIDI_SetContext();
}

original_code:
void MUSIC_SetContext
   (
   int context
   )
   {
   MIDI_SetContext( context );
   }

canonical_original_code:
void MUSIC_SetContext(int context)
   {
   MIDI_SetContext( context );
   }

variable_types: context int


decompiled_code:
__int64 MUSIC_GetContext()
{
return MIDI_GetContext();
}

canonical_decompiled_code:
__int64 func15()
{
return MIDI_GetContext();
}

original_code:
int MUSIC_GetContext
   (
   void
   )
   {
   return MIDI_GetContext();
   }

canonical_original_code:
int MUSIC_GetContext()
   {
   return MIDI_GetContext();
   }


decompiled_code:
__int64 MUSIC_SetSongTick()
{
return MIDI_SetSongTick();
}

canonical_decompiled_code:
__int64 func16()
{
return MIDI_SetSongTick();
}

original_code:
void MUSIC_SetSongTick
   (
   unsigned long PositionInTicks
   )
   {
   MIDI_SetSongTick( PositionInTicks );
   }

canonical_original_code:
void MUSIC_SetSongTick(unsigned long PositionInTicks)
   {
   MIDI_SetSongTick( PositionInTicks );
   }

variable_types:
PositionInTicks
unsigned long


decompiled_code:
__int64 MUSIC_SetSongTime()
{
return MIDI_SetSongTime();
}

canonical_decompiled_code:
__int64 func17()
{
return MIDI_SetSongTime();
}

original_code:
void MUSIC_SetSongTime
   (
   unsigned long milliseconds
   )
   {
   MIDI_SetSongTime( milliseconds );
   }

canonical_original_code:
void MUSIC_SetSongTime(unsigned long milliseconds)
   {
   MIDI_SetSongTime( milliseconds );
   }

variable_types:
milliseconds
unsigned long


decompiled_code:
__int64 MUSIC_SetSongPosition()
{
return MIDI_SetSongPosition();
}

canonical_decompiled_code:
__int64 func18()
{
return MIDI_SetSongPosition();
}

original_code:
void MUSIC_SetSongPosition
   (
   int measure,
   int beat,
   int tick
   )
   {
   MIDI_SetSongPosition( measure, beat, tick );
   }

canonical_original_code:
void MUSIC_SetSongPosition(int measure, int beat, int tick)
   {
   MIDI_SetSongPosition( measure, beat, tick );
   }

variable_types: measure int

variable_types: beat int

variable_types: tick int


decompiled_code:
__int64 MUSIC_GetSongPosition()
{
return MIDI_GetSongPosition();
}

canonical_decompiled_code:
__int64 func19()
{
return MIDI_GetSongPosition();
}

original_code:
void MUSIC_GetSongPosition
   (
   songposition *pos
   )
   {
   MIDI_GetSongPosition( pos );
   }

canonical_original_code:
void MUSIC_GetSongPosition(struct songposition *pos)
   {
   MIDI_GetSongPosition( pos );
   }

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