testDecode

decompiled_code:
int testDecode()
{
unsigned __int8 v0; // al

printf("\n=== %s ===\n", "testDecode");
v0 = decodeByte(22933LL);
return printf("Input: %04X\nShould: 0x28\nGet: %02X\n", 22933LL, v0);
}

canonical_decompiled_code:
int func4()
{
unsigned __int8 v0; // al

printf("\n=== %s ===\n", "testDecode");
v0 = decodeByte(22933LL);
return printf("Input: %04X\nShould: 0x28\nGet: %02X\n", 22933LL, v0);
}

original_code:
void testDecode()
{
    unsigned short int srcWord = 0x5995;
    unsigned char decByte;
    printf("\n=== %s ===\n", __FUNCTION__);
    decByte = decodeByte(srcWord);
    printf("Input: %04X\nShould: 0x28\nGet: %02X\n", srcWord, decByte);
}

canonical_original_code:
void testDecode()
{
    unsigned short srcWord = 0x5995;
    unsigned char decByte;
    printf("\n=== %s ===\n", __FUNCTION__);
    decByte = decodeByte(srcWord);
    printf("Input: %04X\nShould: 0x28\nGet: %02X\n", srcWord, decByte);
}

variable_types:
srcWord
unsigned short

variable_types:
decByte
unsigned char


testHomeEasyEncode

decompiled_code:
__int64 testHomeEasyEncode()
{
__int64 v0; // r12
__int64 v1; // rdx
__int64 v2; // rbp

printf("\n=== %s ===\n", "testHomeEasyEncode");
printf("Input: %08X\n", 673776026LL);
printf("Should: 59 95 59 95 55 56 96 99\nGet: ");
v0 = homeEasyEncode(673776026LL);
v2 = v1;
printfByteBuffer(v0, v1);
return destroyByteBuffer(v0, v2);
}

canonical_decompiled_code:
__int64 func5()
{
__int64 v0; // r12
__int64 v1; // rdx
__int64 v2; // rbp

printf("\n=== %s ===\n", "testHomeEasyEncode");
printf("Input: %08X\n", 673776026LL);
printf("Should: 59 95 59 95 55 56 96 99\nGet: ");
v0 = homeEasyEncode(673776026LL);
v2 = v1;
printfByteBuffer(v0, v1);
return destroyByteBuffer(v0, v2);
}

original_code:
void testHomeEasyEncode()
{
    BYTE_BUFFER source;
    BYTE_BUFFER encoded;
    unsigned long int frame = 0x2829019a;
    printf("\n=== %s ===\n", __FUNCTION__);
    printf("Input: %08X\n", frame);
    printf("Should: 59 95 59 95 55 56 96 99\nGet:    ");
    encoded = homeEasyEncode(frame);
    printfByteBuffer(encoded);
    destroyByteBuffer(encoded);
}

canonical_original_code:
void testHomeEasyEncode()
{
    struct BYTE_BUFFER source;
    struct BYTE_BUFFER encoded;
    unsigned long frame = 0x2829019a;
    printf("\n=== %s ===\n", __FUNCTION__);
    printf("Input: %08X\n", frame);
    printf("Should: 59 95 59 95 55 56 96 99\nGet:    ");
    encoded = homeEasyEncode(frame);
    printfByteBuffer(encoded);
    destroyByteBuffer(encoded);
}

variable_types: struct BYTE_BUFFER { char *data; unsigned long size; }

variable_types:
frame
unsigned long

return_type: void


testHomeEasyDecode

decompiled_code:
__int64 testHomeEasyDecode()
{
__int64 v0; // rax
__int64 v1; // rdx
__int64 v2; // rax
__int64 v4; // [rsp+8h] [rbp-20h] BYREF
__int64 v5; // [rsp+10h] [rbp-18h] BYREF
__int64 v6; // [rsp+18h] [rbp-10h]

v4 = 0x559A565596599559LL;
printf("\n=== %s ===\n", "testHomeEasyDecode");
v0 = createByteBuffer();
v6 = v1;
v5 = v0;
pushBytes(&v5, &v4, 8LL);
printf("Input: ");
printfByteBuffer(v5, v6);
v2 = homeEasyDecode(&v5);
printf("Should: 282901B0\nGet: %08X\n", v2);
return destroyByteBuffer(v5, v6);
}

canonical_decompiled_code:
__int64 func6()
{
__int64 v0; // rax
__int64 v1; // rdx
__int64 v2; // rax
__int64 v4; // [rsp+8h] [rbp-20h] BYREF
__int64 v5; // [rsp+10h] [rbp-18h] BYREF
__int64 v6; // [rsp+18h] [rbp-10h]

v4 = 0x559A565596599559LL;
printf("\n=== %s ===\n", "testHomeEasyDecode");
v0 = createByteBuffer();
v6 = v1;
v5 = v0;
pushBytes(&v5, &v4, 8LL);
printf("Input: ");
printfByteBuffer(v5, v6);
v2 = homeEasyDecode(&v5);
printf("Should: 282901B0\nGet: %08X\n", v2);
return destroyByteBuffer(v5, v6);
}

original_code:
void testHomeEasyDecode()
{
    BYTE_BUFFER source;
    unsigned long int decoded;
    unsigned char bytes[] = {0x59, 0x95, 0x59, 0x96, 0x55, 0x56, 0x9A, 0x55};
    printf("\n=== %s ===\n", __FUNCTION__);
    source = createByteBuffer();
    pushBytes(&source, bytes, 8);
    printf("Input: ");
    printfByteBuffer(source);
    printf("Should: 282901B0\nGet:    %08X\n", homeEasyDecode(&source));
    destroyByteBuffer(source);
}

canonical_original_code:
void testHomeEasyDecode()
{
    struct BYTE_BUFFER source;
    unsigned long decoded;
    unsigned char bytes[] = {0x59, 0x95, 0x59, 0x96, 0x55, 0x56, 0x9A, 0x55};
    printf("\n=== %s ===\n", __FUNCTION__);
    source = createByteBuffer();
    pushBytes(&source, bytes, 8);
    printf("Input: ");
    printfByteBuffer(source);
    printf("Should: 282901B0\nGet:    %08X\n", homeEasyDecode(&source));
    destroyByteBuffer(source);
}

variable_types:
decoded
unsigned long

variable_types:
bytes
unsigned char []

user_defined_types: struct BYTE_BUFFER { char *data; unsigned long size; }


testHomeEasyCommand

decompiled_code:
__int64 __fastcall testHomeEasyCommand(char a1, unsigned __int8 a2, unsigned __int8 a3)
{
__int64 v4; // r13
__int64 v5; // rbp
__int64 v6; // r12
__int64 v7; // rdx
__int64 v8; // rbp

v4 = getHomeEasyId(673776026LL);
printf("\n=== %s ===\n", "testHomeEasyCommand");
v5 = createHomeEasyCommand(v4, (unsigned int)a1, a2, a3);
printf("%08X\n", v5);
v6 = homeEasyEncode(v5);
v8 = v7;
printfByteBuffer(v6, v7);
return destroyByteBuffer(v6, v8);
}

canonical_decompiled_code:
__int64 __fastcall func7(char a1, unsigned __int8 a2, unsigned __int8 a3)
{
__int64 v4; // r13
__int64 v5; // rbp
__int64 v6; // r12
__int64 v7; // rdx
__int64 v8; // rbp

v4 = getHomeEasyId(673776026LL);
printf("\n=== %s ===\n", "testHomeEasyCommand");
v5 = createHomeEasyCommand(v4, (unsigned int)a1, a2, a3);
printf("%08X\n", v5);
v6 = homeEasyEncode(v5);
v8 = v7;
printfByteBuffer(v6, v7);
return destroyByteBuffer(v6, v8);
}

original_code:
void testHomeEasyCommand(char section, unsigned char num, unsigned char onOff)
{
    unsigned long int command;
    BYTE_BUFFER encoded;
    unsigned long int id = getHomeEasyId(0x2829019a);
    printf("\n=== %s ===\n", __FUNCTION__);
    command = createHomeEasyCommand(id, section, num, onOff);
    printf("%08X\n", command);
    encoded = homeEasyEncode(command);
    printfByteBuffer(encoded);
    destroyByteBuffer(encoded);
}

canonical_original_code:
void testHomeEasyCommand(char section, unsigned char num, unsigned char onOff)
{
    unsigned long command;
    struct BYTE_BUFFER encoded;
    unsigned long id = getHomeEasyId(0x2829019a);
    printf("\n=== %s ===\n", __FUNCTION__);
    command = createHomeEasyCommand(id, section, num, onOff);
    printf("%08X\n", command);
    encoded = homeEasyEncode(command);
    printfByteBuffer(encoded);
    destroyByteBuffer(encoded);
}

variable_types: section char

variable_types:
num
unsigned char

variable_types:
onOff
unsigned char

variable_types:
command
unsigned long

variable_types:
id
unsigned long


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
puts("Test");
testByteBuffer("Test", argv);
testPrintBits();
testGetId();
testEncode();
testDecode();
testHomeEasyEncode();
testHomeEasyDecode();
testHomeEasyCommand(68, 4u, 0);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
puts("Test");
func0("Test", argv);
func1();
func2();
func3();
func4();
func5();
func6();
func7(68, 4u, 0);
return 0;
}

original_code:
int main()
{
    printf("Test\n");
    testByteBuffer();
    testPrintBits();
    testGetId();
    testEncode();
    testDecode();
    testHomeEasyEncode();
    testHomeEasyDecode();
    testHomeEasyCommand('D', 4, 0);
    return 0;
}

return_type: int


createByteBuffer

decompiled_code:
void *createByteBuffer()
{
return malloc(1uLL);
}

canonical_decompiled_code:
void *func0()
{
return malloc(1uLL);
}

original_code:
BYTE_BUFFER createByteBuffer()
{
    BYTE_BUFFER buffer;
    buffer.size = 0;
    buffer.data = (char*) malloc(1);
    return buffer;
}

canonical_original_code:
struct BYTE_BUFFER createByteBuffer()
{
    struct BYTE_BUFFER buffer;
    buffer.size = 0;
    buffer.data = (char *) malloc(1);
    return buffer;
}

return_type: struct BYTE_BUFFER { char *data; unsigned long size; }


destroyByteBuffer

decompiled_code:
// attributes: thunk
void destroyByteBuffer(void *ptr)
{
free(ptr);
}

canonical_decompiled_code:
void func1(void *ptr)
{
free(ptr);
}

original_code:
void destroyByteBuffer(BYTE_BUFFER buffer)
{
    free(buffer.data);
}

canonical_original_code:
void destroyByteBuffer(struct BYTE_BUFFER buffer)
{
    free(buffer.data);
}


printfBit

decompiled_code:
int __fastcall printfBit(char a1)
{
int v1; // ebp
int v2; // ebx
_BOOL8 v3; // rdx
int result; // eax

v1 = 8;
v2 = 128;
do
{
v3 = (unsigned __int8)(v2 & a1) == v2;
v2 >>= 1;
result = fprintf(stdout, "%d", v3);
--v1;
}
while ( v1 );
return result;
}

canonical_decompiled_code:
int __fastcall func2(char a1)
{
int v1; // ebp
int v2; // ebx
_BOOL8 v3; // rdx
int result; // eax

v1 = 8;
v2 = 128;
do
{
v3 = (unsigned __int8)(v2 & a1) == v2;
v2 >>= 1;
result = fprintf(stdout, "%d", v3);
--v1;
}
while ( v1 );
return result;
}

original_code:
void printfBit(unsigned char byte)
{
    int i;
    for(i=0x80; i>0; i>>=1) {
        fprintf(stdout, "%d", ((byte & i) == i));
    }
}

variable_types:
byte
unsigned char

variable_types: i int


printfBitBuffer

decompiled_code:
int __fastcall printfBitBuffer(__int64 a1, unsigned __int64 a2)
{
__int64 v2; // rax
unsigned int v3; // ebx

LODWORD(v2) = printf("bytes: %lu\nbits: %lu\n", a2, 8 * a2);
if ( a2 )
{
v3 = 0;
v2 = 0LL;
do
{
printfBit(*(_BYTE *)(a1 + v2));
putchar(10);
v2 = ++v3;
}
while ( v3 < a2 );
}
return v2;
}

canonical_decompiled_code:
int __fastcall func3(__int64 a1, unsigned __int64 a2)
{
__int64 v2; // rax
unsigned int v3; // ebx

LODWORD(v2) = printf("bytes: %lu\nbits: %lu\n", a2, 8 * a2);
if ( a2 )
{
v3 = 0;
v2 = 0LL;
do
{
func2(*(_BYTE *)(a1 + v2));
putchar(10);
v2 = ++v3;
}
while ( v3 < a2 );
}
return v2;
}

original_code:
void printfBitBuffer(BYTE_BUFFER buffer)
{
    printf("bytes: %lu\nbits: %lu\n", buffer.size, buffer.size*8);
    unsigned int x;
    for(x=0; x<buffer.size ; x++) {
        printfBit(buffer.data[x]);
        printf("\n");
    }
}

canonical_original_code:
void printfBitBuffer(struct BYTE_BUFFER buffer)
{
    printf("bytes: %lu\nbits: %lu\n", buffer.size, buffer.size*8);
    unsigned int x;
    for(x=0; x<buffer.size ; x++) {
        printfBit(buffer.data[x]);
        printf("\n");
    }
}

variable_types:
x
unsigned int


printfByteBuffer

decompiled_code:
int __fastcall printfByteBuffer(__int64 a1, unsigned __int64 a2)
{
unsigned int v2; // ebx
__int64 v3; // rax

if ( a2 )
{
v2 = 0;
v3 = 0LL;
do
{
fprintf(stdout, "%02X ", *(unsigned __int8 *)(a1 + v3));
v3 = ++v2;
}
while ( v2 < a2 );
}
return fputc(10, stdout);
}

canonical_decompiled_code:
int __fastcall func4(__int64 a1, unsigned __int64 a2)
{
unsigned int v2; // ebx
__int64 v3; // rax

if ( a2 )
{
v2 = 0;
v3 = 0LL;
do
{
fprintf(stdout, "%02X ", *(unsigned __int8 *)(a1 + v3));
v3 = ++v2;
}
while ( v2 < a2 );
}
return fputc(10, stdout);
}

original_code:
void printfByteBuffer(BYTE_BUFFER buffer)
{
    unsigned int i;
    for(i=0; i<buffer.size; i++) {
        fprintf(stdout, "%02X ", (unsigned char)buffer.data[i]);
    }
    fprintf(stdout, "\n");
}

canonical_original_code:
void printfByteBuffer(struct BYTE_BUFFER buffer)
{
    unsigned int i;
    for(i=0; i<buffer.size; i++) {
        fprintf(stdout, "%02X ", (unsigned char)buffer.data[i]);
    }
    fprintf(stdout, "\n");
}

variable_types:
i
unsigned int


pushByte

decompiled_code:
char *__fastcall pushByte(__int64 a1, char a2)
{
size_t v3; // rsi
char *result; // rax
__int64 v5; // rdx

v3 = *(_QWORD *)(a1 + 8) + 1LL;
*(_QWORD *)(a1 + 8) = v3;
result = (char *)realloc(*(void **)a1, v3);
v5 = *(_QWORD *)(a1 + 8);
*(_QWORD *)a1 = result;
result[v5 - 1] = a2;
return result;
}

canonical_decompiled_code:
char *__fastcall func5(__int64 a1, char a2)
{
size_t v3; // rsi
char *result; // rax
__int64 v5; // rdx

v3 = *(_QWORD *)(a1 + 8) + 1LL;
*(_QWORD *)(a1 + 8) = v3;
result = (char *)realloc(*(void **)a1, v3);
v5 = *(_QWORD *)(a1 + 8);
*(_QWORD *)a1 = result;
result[v5 - 1] = a2;
return result;
}

original_code:
void pushByte(BYTE_BUFFER* buffer, unsigned char byte)
{
    buffer->size++;
    buffer->data = (char*)realloc(buffer->data, buffer->size);
    buffer->data[buffer->size-1] = byte;
}

canonical_original_code:
void pushByte(struct BYTE_BUFFER *buffer, unsigned char byte)
{
    buffer->size++;
    buffer->data = (char *)realloc(buffer->data, buffer->size);
    buffer->data[buffer->size-1] = byte;
}

variable_types: struct BYTE_BUFFER { char *data; unsigned long size; } *


pushWord

decompiled_code:
char *__fastcall pushWord(__int64 a1, __int16 a2)
{
pushByte(a1, SHIBYTE(a2));
return pushByte(a1, a2);
}

canonical_decompiled_code:
char *__fastcall func6(__int64 a1, __int16 a2)
{
func5(a1, SHIBYTE(a2));
return func5(a1, a2);
}

original_code:
void pushWord(BYTE_BUFFER* buffer, unsigned short int word)
{
    unsigned char* data = (unsigned char*)&word;
    pushByte(buffer, data[1]);
    pushByte(buffer, data[0]);
}

canonical_original_code:
void pushWord(struct BYTE_BUFFER *buffer, unsigned short word)
{
    unsigned char *data = (unsigned char*)&word;
    pushByte(buffer, data[1]);
    pushByte(buffer, data[0]);
}

variable_types:
word
unsigned short

variable_types:
data
unsigned char *


pushBytes

decompiled_code:
void *__fastcall pushBytes(__int64 a1, const void *a2, unsigned int a3)
{
size_t v3; // rbp
char *v4; // rax
void *result; // rax

v3 = a3;
v4 = (char *)realloc(*(void **)a1, a3 + *(_QWORD *)(a1 + 8));
*(_QWORD *)a1 = v4;
result = memcpy(&v4[*(_QWORD *)(a1 + 8)], a2, v3);
*(_QWORD *)(a1 + 8) += v3;
return result;
}

canonical_decompiled_code:
void *__fastcall func7(__int64 a1, const void *a2, unsigned int a3)
{
size_t v3; // rbp
char *v4; // rax
void *result; // rax

v3 = a3;
v4 = (char *)realloc(*(void **)a1, a3 + *(_QWORD *)(a1 + 8));
*(_QWORD *)a1 = v4;
result = memcpy(&v4[*(_QWORD *)(a1 + 8)], a2, v3);
*(_QWORD *)(a1 + 8) += v3;
return result;
}

original_code:
void pushBytes(BYTE_BUFFER* buffer, unsigned char *byte, unsigned int len)
{
    buffer->data = (char*)realloc(buffer->data, buffer->size+len);
    memcpy(&buffer->data[buffer->size], byte, len);
    buffer->size += len;
}

canonical_original_code:
void pushBytes(struct BYTE_BUFFER *buffer, unsigned char *byte, unsigned int len)
{
    buffer->data = (char *)realloc(buffer->data, buffer->size+len);
    memcpy(&buffer->data[buffer->size], byte, len);
    buffer->size += len;
}

variable_types:
byte
unsigned char *

variable_types:
len
unsigned int


bitAt

decompiled_code:
__int64 __fastcall bitAt(__int64 a1, __int64 a2, unsigned __int64 a3)
{
return *(_BYTE *)((a3 >> 3) + a1) & 1;
}

canonical_decompiled_code:
__int64 __fastcall func8(__int64 a1, __int64 a2, unsigned __int64 a3)
{
return *(_BYTE *)((a3 >> 3) + a1) & 1;
}

original_code:
unsigned int bitAt(BYTE_BUFFER buffer, unsigned long int n)
{
    unsigned char byte = buffer.data[n / 8];
    return (byte & (0x80 >> (n % 8)) != 0);
}

canonical_original_code:
unsigned int bitAt(struct BYTE_BUFFER buffer, unsigned long n)
{
    unsigned char byte = buffer.data[n / 8];
    return (byte & (0x80 >> (n % 8)) != 0);
}

variable_types: struct BYTE_BUFFER { char *data; unsigned long size; }

variable_types:
n
unsigned long

return_type: unsigned int


showTime

decompiled_code:
struct timeval *__fastcall showTime(_QWORD *a1)
{
struct timeval *v1; // r12
__suseconds_t v2; // rdx
__suseconds_t v3; // rax
__time_t v4; // r9
__suseconds_t v5; // rdi

v1 = (struct timeval *)malloc(0x10uLL);
gettimeofday(v1, 0LL);
if ( a1 )
{
v2 = v1->tv_usec;
v3 = a1[1];
v4 = v1->tv_sec - *a1;
v5 = v2 - v3;
if ( v3 > v2 )
{
--v4;
v5 = v2 + 1000000 - v3;
}
fprintf(stderr, format, v4, v5 / 1000, v4 % 1000);
}
return v1;
}

canonical_decompiled_code:
struct timeval *__fastcall func0(_QWORD *a1)
{
struct timeval *v1; // r12
__suseconds_t v2; // rdx
__suseconds_t v3; // rax
__time_t v4; // r9
__suseconds_t v5; // rdi

v1 = (struct timeval *)malloc(0x10uLL);
gettimeofday(v1, 0LL);
if ( a1 )
{
v2 = v1->tv_usec;
v3 = a1[1];
v4 = v1->tv_sec - *a1;
v5 = v2 - v3;
if ( v3 > v2 )
{
--v4;
v5 = v2 + 1000000 - v3;
}
fprintf(stderr, format, v4, v5 / 1000, v4 % 1000);
}
return v1;
}

original_code:
struct timeval* showTime(struct timeval* start)
{
    struct timeval* stop;
    long tv_sec;
    long tv_usec;
    stop = (struct timeval*)malloc(sizeof(struct timeval));
    gettimeofday(stop, 0);
    if (!start) return stop;
    tv_sec = (start->tv_usec > stop->tv_usec) ? stop->tv_sec - start->tv_sec - 1 : stop->tv_sec - start->tv_sec;
    tv_usec = (start->tv_usec > stop->tv_usec) ? 1000000 + stop->tv_usec - start->tv_usec : stop->tv_usec - start->tv_usec;
    fprintf(stderr, "%lus %lums %luµs\n", tv_sec, tv_usec/1000, tv_sec % 1000);
    return stop;
}

canonical_original_code:
struct timeval *showTime(struct timeval *start)
{
    struct timeval *stop;
    long tv_sec;
    long tv_usec;
    stop = (struct timeval *)malloc(sizeof(struct timeval));
    gettimeofday(stop, 0);
    if (!start) return stop;
    tv_sec = (start->tv_usec > stop->tv_usec) ? stop->tv_sec - start->tv_sec - 1 : stop->tv_sec - start->tv_sec;
    tv_usec = (start->tv_usec > stop->tv_usec) ? 1000000 + stop->tv_usec - start->tv_usec : stop->tv_usec - start->tv_usec;
    fprintf(stderr, "%lus %lums %luµs\n", tv_sec, tv_usec/1000, tv_sec % 1000);
    return stop;
}

variable_types:
start
struct timeval *

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


cpuMode

decompiled_code:
void __fastcall cpuMode(int a1)
{
struct sched_param param; // [rsp+Ch] [rbp-Ch] BYREF

if ( a1 )
{
param.__sched_priority = 0;
if ( sched_setscheduler(0, 0, &param) == -1 )
perror("Failed to switch to normal scheduler.");
}
else
{
param.__sched_priority = sched_get_priority_max(2);
if ( sched_setscheduler(0, 2, &param) == -1 )
perror("Failed to switch to realtime scheduler.");
}
}

canonical_decompiled_code:
void __fastcall func1(int a1)
{
struct sched_param param; // [rsp+Ch] [rbp-Ch] BYREF

if ( a1 )
{
param.__sched_priority = 0;
if ( sched_setscheduler(0, 0, &param) == -1 )
perror("Failed to switch to normal scheduler.");
}
else
{
param.__sched_priority = sched_get_priority_max(2);
if ( sched_setscheduler(0, 2, &param) == -1 )
perror("Failed to switch to realtime scheduler.");
}
}

original_code:
void cpuMode(int mode)
{
    struct sched_param p;
    switch (mode) {
        case 0:
            p.sched_priority = sched_get_priority_max(2);
            if( sched_setscheduler( 0, 2, &p ) == -1 ) {
                perror("Failed to switch to realtime scheduler.");
            }
            break;
        case 1:
        default:
            p.sched_priority = 0;
            if( sched_setscheduler( 0, 0, &p ) == -1 ) {
                perror("Failed to switch to normal scheduler.");
            }
            break;
    }
}

variable_types: mode int

variable_types: struct sched_param { int sched_priority; }


repo: lantus/ROTT

decompiled_code:
__int64 __fastcall PITCH_GetScale(int a1)
{
unsigned int v1; // eax
int v2; // edi
unsigned __int64 v3; // rax
__int64 v4; // rdx
__int64 result; // rax

if ( !a1 )
return PitchTable[0];
v1 = a1 % 1200 + (a1 % 1200 < 0 ? 0x4B0 : 0);
v2 = a1 - v1;
v3 = PitchTable[25 * (v1 / 0x64) + ((int)(v1 % 0x64) >> 2)];
v4 = v3 << (v2 / 1200);
result = v3 >> (v2 / -1200);
if ( v2 >= -1199 )
result = v4;
return result;
}

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

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

variable_types: pitchoffset int

variable_types:
scale
unsigned long

variable_types: octaveshift int

variable_types: noteshift int

variable_types: note int

variable_types: detune int

return_type: unsigned long


decompiled_code:
void PITCH_LockEnd()
{
;
}

canonical_decompiled_code:
void func1()
{
;
}

original_code:
static void PITCH_LockEnd
   (
   void
   )
   {
   }

canonical_original_code:
static void PITCH_LockEnd()
   {
   }


decompiled_code:
__int64 PITCH_UnlockMemory()
{
DPMI_UnlockMemoryRegion(PITCH_GetScale, PITCH_LockEnd);
return DPMI_UnlockMemory(PitchTable, 2400LL);
}

canonical_decompiled_code:
__int64 func2()
{
DPMI_UnlockMemoryRegion(PITCH_GetScale, PITCH_LockEnd);
return DPMI_UnlockMemory(PitchTable, 2400LL);
}

original_code:
void PITCH_UnlockMemory
   (
   void
   )
   {
   DPMI_UnlockMemoryRegion( PITCH_GetScale, PITCH_LockEnd );
   ( DPMI_UnlockMemory( (void *) &( PitchTable ), sizeof( PitchTable ) ) );
   }

canonical_original_code:
void PITCH_UnlockMemory()
   {
   DPMI_UnlockMemoryRegion( PITCH_GetScale, PITCH_LockEnd );
   ( DPMI_UnlockMemory( (void *) &( PitchTable ), sizeof( PitchTable ) ) );
   }


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

v0 = DPMI_LockMemoryRegion(PITCH_GetScale, PITCH_LockEnd);
result = v0 | (unsigned int)DPMI_LockMemory(PitchTable, 2400LL);
if ( (_DWORD)result )
{
PITCH_UnlockMemory();
result = 0xFFFFFFFFLL;
}
return result;
}

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

v0 = DPMI_LockMemoryRegion(PITCH_GetScale, PITCH_LockEnd);
result = v0 | (unsigned int)DPMI_LockMemory(PitchTable, 2400LL);
if ( (_DWORD)result )
{
func2();
result = 0xFFFFFFFFLL;
}
return result;
}

original_code:
int PITCH_LockMemory
   (
   void
   )
   {
   int status;
   status = DPMI_LockMemoryRegion( PITCH_GetScale, PITCH_LockEnd );
   status |= ( DPMI_LockMemory( (void *) &( PitchTable ), sizeof( PitchTable ) ) );
   if ( status != DPMI_Ok )
      {
      PITCH_UnlockMemory();
      return( PITCH_Error );
      }
   return( PITCH_Ok );
   }

canonical_original_code:
int PITCH_LockMemory()
   {
   int status;
   status = DPMI_LockMemoryRegion( PITCH_GetScale, PITCH_LockEnd );
   status |= ( DPMI_LockMemory( (void *) &( PitchTable ), sizeof( PitchTable ) ) );
   if ( status != DPMI_Ok )
      {
      PITCH_UnlockMemory();
      return( PITCH_Error );
      }
   return( PITCH_Ok );
   }

variable_types: status int


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

while ( 2 )
{
switch ( a1 )
{
case -2:
case -1:
a1 = FX_ErrorCode;
continue;
case 0:
result = "Fx ok.";
break;
case 1:
result = "Apogee Sound System Version 1.12 Programmed by Jim Dose\n"
"(c) Copyright 1995 James R. Dose. All Rights Reserved.\n";
break;
case 3:
result = (const char *)DSL_ErrorString(0xFFFFFFFFLL);
break;
case 4:
result = "Invalid Sound Fx device.";
break;
case 5:
result = (const char *)MV_ErrorString(0xFFFFFFFFLL);
break;
case 6:
result = "DPMI Error in FX_MAN.";
break;
default:
result = "Unknown Fx error code.";
break;
}
break;
}
return result;
}

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

while ( 2 )
{
switch ( a1 )
{
case -2:
case -1:
a1 = FX_ErrorCode;
continue;
case 0:
result = "Fx ok.";
break;
case 1:
result = "Apogee Sound System Version 1.12 Programmed by Jim Dose\n"
"(c) Copyright 1995 James R. Dose. All Rights Reserved.\n";
break;
case 3:
result = (const char *)DSL_ErrorString(0xFFFFFFFFLL);
break;
case 4:
result = "Invalid Sound Fx device.";
break;
case 5:
result = (const char *)MV_ErrorString(0xFFFFFFFFLL);
break;
case 6:
result = "DPMI Error in FX_MAN.";
break;
default:
result = "Unknown Fx error code.";
break;
}
break;
}
return result;
}

original_code:
char *FX_ErrorString
   (
   int ErrorNumber
   )
   {
   char *ErrorString;
   switch( ErrorNumber )
      {
      case FX_Warning :
      case FX_Error :
         ErrorString = FX_ErrorString( FX_ErrorCode );
         break;
      case FX_Ok :
         ErrorString = "Fx ok.";
         break;
      case FX_ASSVersion :
         ErrorString = "Apogee Sound System Version " "1.12" "  "
            "Programmed by Jim Dose\n"
            "(c) Copyright 1995 James R. Dose.  All Rights Reserved.\n";
         break;
      case FX_SoundCardError :
         ErrorString = DSL_ErrorString( DSL_Error );
         break;
      case FX_InvalidCard :
         ErrorString = "Invalid Sound Fx device.";
         break;
      case FX_MultiVocError :
         ErrorString = MV_ErrorString( MV_Error );
         break;
      case FX_DPMI_Error :
         ErrorString = "DPMI Error in FX_MAN.";
         break;
      default :
         ErrorString = "Unknown Fx error code.";
         break;
      }
   return( ErrorString );
   }

canonical_original_code:
char *FX_ErrorString(int ErrorNumber)
   {
   char *ErrorString;
   switch( ErrorNumber )
      {
      case FX_Warning :
      case FX_Error :
         ErrorString = FX_ErrorString( FX_ErrorCode );
         break;
      case FX_Ok :
         ErrorString = "Fx ok.";
         break;
      case FX_ASSVersion :
         ErrorString = "Apogee Sound System Version " "1.12" "  "
            "Programmed by Jim Dose\n"
            "(c) Copyright 1995 James R. Dose.  All Rights Reserved.\n";
         break;
      case FX_SoundCardError :
         ErrorString = DSL_ErrorString( DSL_Error );
         break;
      case FX_InvalidCard :
         ErrorString = "Invalid Sound Fx device.";
         break;
      case FX_MultiVocError :
         ErrorString = MV_ErrorString( MV_Error );
         break;
      case FX_DPMI_Error :
         ErrorString = "DPMI Error in FX_MAN.";
         break;
      default :
         ErrorString = "Unknown Fx error code.";
         break;
      }
   return( ErrorString );
   }

variable_types: ErrorNumber int

variable_types:
ErrorString
char *

return_type: char *


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

if ( (unsigned int)USER_CheckParameter("ASSVER") )
{
FX_ErrorCode = 1;
result = 0xFFFFFFFFLL;
}
else
{
FX_SoundDevice = a1;
FX_ErrorCode = 0;
result = DSL_Init();
if ( (_DWORD)result )
{
FX_ErrorCode = 3;
result = 0xFFFFFFFFLL;
}
else
{
*(_QWORD *)a2 = 32LL;
*(_DWORD *)(a2 + 8) = 0;
}
}
return result;
}

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

if ( (unsigned int)USER_CheckParameter("ASSVER") )
{
FX_ErrorCode = 1;
result = 0xFFFFFFFFLL;
}
else
{
FX_SoundDevice = a1;
FX_ErrorCode = 0;
result = DSL_Init();
if ( (_DWORD)result )
{
FX_ErrorCode = 3;
result = 0xFFFFFFFFLL;
}
else
{
*(_QWORD *)a2 = 32LL;
*(_DWORD *)(a2 + 8) = 0;
}
}
return result;
}

original_code:
int FX_SetupCard
   (
   int SoundCard,
   fx_device *device
   )
   {
   int status;
   int DeviceStatus;
   if ( USER_CheckParameter( "ASSVER" ) )
      {
      FX_ErrorCode = ( FX_ASSVersion );;
      return( FX_Error );
      }
   FX_SoundDevice = SoundCard;
   status = FX_Ok;
   FX_ErrorCode = ( FX_Ok );;
      DeviceStatus = DSL_Init();
      if ( DeviceStatus != DSL_Ok )
         {
         FX_ErrorCode = ( FX_SoundCardError );;
         status = FX_Error;
         }
         else
         {
         device->MaxVoices = 32;
         device->MaxSampleBits = 0;
         device->MaxChannels = 0;
         }
   return( status );
   }

canonical_original_code:
int FX_SetupCard(int SoundCard, struct fx_device *device)
   {
   int status;
   int DeviceStatus;
   if ( USER_CheckParameter( "ASSVER" ) )
      {
      FX_ErrorCode = ( FX_ASSVersion );;
      return( FX_Error );
      }
   FX_SoundDevice = SoundCard;
   status = FX_Ok;
   FX_ErrorCode = ( FX_Ok );;
      DeviceStatus = DSL_Init();
      if ( DeviceStatus != DSL_Ok )
         {
         FX_ErrorCode = ( FX_SoundCardError );;
         status = FX_Error;
         }
         else
         {
         device->MaxVoices = 32;
         device->MaxSampleBits = 0;
         device->MaxChannels = 0;
         }
   return( status );
   }

variable_types: SoundCard int

variable_types: struct fx_device { int MaxVoices; int MaxSampleBits; int MaxChannels; } *

variable_types: DeviceStatus int


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

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

original_code:
int FX_GetBlasterSettings
   (
   fx_blaster_config *blaster
   )
   {
   return( FX_Ok );
   }

canonical_original_code:
int FX_GetBlasterSettings(struct fx_blaster_config *blaster)
   {
   return( FX_Ok );
   }

variable_types: struct fx_blaster_config { unsigned long Address; unsigned long Type; unsigned long Interrupt; unsigned long Dma8; unsigned long Dma16; unsigned long Midi; unsigned long Emu; } *


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

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

original_code:
int FX_SetupSoundBlaster
   (
   fx_blaster_config blaster,
   int *MaxVoices,
   int *MaxSampleBits,
   int *MaxChannels
   )
   {
   return( FX_Ok );
   }

canonical_original_code:
int FX_SetupSoundBlaster(struct fx_blaster_config blaster, int *MaxVoices, int *MaxSampleBits, int *MaxChannels)
   {
   return( FX_Ok );
   }

variable_types: struct fx_blaster_config { unsigned long Address; unsigned long Type; unsigned long Interrupt; unsigned long Dma8; unsigned long Dma16; unsigned long Midi; unsigned long Emu; }

variable_types:
MaxVoices
int *

variable_types:
MaxSampleBits
int *

variable_types:
MaxChannels
int *


decompiled_code:
__int64 FX_Shutdown()
{
unsigned int v0; // er12
unsigned int v1; // er12

v0 = FX_Installed;
if ( !FX_Installed )
return v0;
if ( (unsigned int)FX_SoundDevice <= 0xB && ((1LL << FX_SoundDevice) & 0xF47) != 0 )
{
v1 = MV_Shutdown();
if ( v1 )
{
FX_ErrorCode = 5;
v0 = -1;
FX_Installed = 0;
LL_UnlockMemory();
return v0;
}
}
else
{
FX_ErrorCode = 4;
v1 = -1;
}
FX_Installed = 0;
LL_UnlockMemory();
return v1;
}

canonical_decompiled_code:
__int64 func4()
{
unsigned int v0; // er12
unsigned int v1; // er12

v0 = FX_Installed;
if ( !FX_Installed )
return v0;
if ( (unsigned int)FX_SoundDevice <= 0xB && ((1LL << FX_SoundDevice) & 0xF47) != 0 )
{
v1 = MV_Shutdown();
if ( v1 )
{
FX_ErrorCode = 5;
v0 = -1;
FX_Installed = 0;
LL_UnlockMemory();
return v0;
}
}
else
{
FX_ErrorCode = 4;
v1 = -1;
}
FX_Installed = 0;
LL_UnlockMemory();
return v1;
}

original_code:
int FX_Shutdown
   (
   void
   )
   {
   int status;
   if ( !FX_Installed )
      {
      return( FX_Ok );
      }
   status = FX_Ok;
   switch( FX_SoundDevice )
      {
      case SoundBlaster :
      case Awe32 :
      case ProAudioSpectrum :
      case SoundMan16 :
      case SoundScape :
      case SoundSource :
      case TandySoundSource :
      case UltraSound :
         status = MV_Shutdown();
         if ( status != MV_Ok )
            {
            FX_ErrorCode = ( FX_MultiVocError );;
            status = FX_Error;
            }
         break;
      default :
         FX_ErrorCode = ( FX_InvalidCard );;
         status = FX_Error;
      }
   FX_Installed = ( !( 1 == 1 ) );
   LL_UnlockMemory();
   return( status );
   }

canonical_original_code:
int FX_Shutdown()
   {
   int status;
   if ( !FX_Installed )
      {
      return( FX_Ok );
      }
   status = FX_Ok;
   switch( FX_SoundDevice )
      {
      case SoundBlaster :
      case Awe32 :
      case ProAudioSpectrum :
      case SoundMan16 :
      case SoundScape :
      case SoundSource :
      case TandySoundSource :
      case UltraSound :
         status = MV_Shutdown();
         if ( status != MV_Ok )
            {
            FX_ErrorCode = ( FX_MultiVocError );;
            status = FX_Error;
            }
         break;
      default :
         FX_ErrorCode = ( FX_InvalidCard );;
         status = FX_Error;
      }
   FX_Installed = ( !( 1 == 1 ) );
   LL_UnlockMemory();
   return( status );
   }


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

if ( FX_Installed )
FX_Shutdown();
if ( (unsigned int)USER_CheckParameter("ASSVER") )
{
FX_ErrorCode = 1;
result = 0xFFFFFFFFLL;
}
else if ( (unsigned int)LL_LockMemory() )
{
FX_ErrorCode = 6;
result = 0xFFFFFFFFLL;
}
else
{
FX_SoundDevice = a1;
if ( a1 <= 0xB && ((1LL << a1) & 0xF47) != 0 )
{
result = MV_Init(a1, a5, a2, a3, a4);
if ( !(_DWORD)result )
{
FX_Installed = 1;
return result;
}
FX_ErrorCode = 5;
}
else
{
FX_ErrorCode = 4;
}
LL_UnlockMemory();
result = 0xFFFFFFFFLL;
}
return result;
}

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

if ( FX_Installed )
func4();
if ( (unsigned int)USER_CheckParameter("ASSVER") )
{
FX_ErrorCode = 1;
result = 0xFFFFFFFFLL;
}
else if ( (unsigned int)LL_LockMemory() )
{
FX_ErrorCode = 6;
result = 0xFFFFFFFFLL;
}
else
{
FX_SoundDevice = a1;
if ( a1 <= 0xB && ((1LL << a1) & 0xF47) != 0 )
{
result = MV_Init(a1, a5, a2, a3, a4);
if ( !(_DWORD)result )
{
FX_Installed = 1;
return result;
}
FX_ErrorCode = 5;
}
else
{
FX_ErrorCode = 4;
}
LL_UnlockMemory();
result = 0xFFFFFFFFLL;
}
return result;
}

original_code:
int FX_Init
   (
   int SoundCard,
   int numvoices,
   int numchannels,
   int samplebits,
   unsigned mixrate
   )
   {
   int status;
   int devicestatus;
   if ( FX_Installed )
      {
      FX_Shutdown();
      }
   if ( USER_CheckParameter( "ASSVER" ) )
      {
      FX_ErrorCode = ( FX_ASSVersion );;
      return( FX_Error );
      }
   status = LL_LockMemory();
   if ( status != LL_Ok )
      {
      FX_ErrorCode = ( FX_DPMI_Error );;
      return( FX_Error );
      }
   FX_MixRate = mixrate;
   status = FX_Ok;
   FX_SoundDevice = SoundCard;
   switch( SoundCard )
      {
      case SoundBlaster :
      case Awe32 :
      case ProAudioSpectrum :
      case SoundMan16 :
      case SoundScape :
      case SoundSource :
      case TandySoundSource :
      case UltraSound :
         devicestatus = MV_Init( SoundCard, FX_MixRate, numvoices,
            numchannels, samplebits );
         if ( devicestatus != MV_Ok )
            {
            FX_ErrorCode = ( FX_MultiVocError );;
            status = FX_Error;
            }
         break;
      default :
         FX_ErrorCode = ( FX_InvalidCard );;
         status = FX_Error;
      }
   if ( status != FX_Ok )
      {
      LL_UnlockMemory();
      }
   else
      {
      FX_Installed = ( 1 == 1 );
      }
   return( status );
   }

canonical_original_code:
int FX_Init(int SoundCard, int numvoices, int numchannels, int samplebits, unsigned int mixrate)
   {
   int status;
   int devicestatus;
   if ( FX_Installed )
      {
      FX_Shutdown();
      }
   if ( USER_CheckParameter( "ASSVER" ) )
      {
      FX_ErrorCode = ( FX_ASSVersion );;
      return( FX_Error );
      }
   status = LL_LockMemory();
   if ( status != LL_Ok )
      {
      FX_ErrorCode = ( FX_DPMI_Error );;
      return( FX_Error );
      }
   FX_MixRate = mixrate;
   status = FX_Ok;
   FX_SoundDevice = SoundCard;
   switch( SoundCard )
      {
      case SoundBlaster :
      case Awe32 :
      case ProAudioSpectrum :
      case SoundMan16 :
      case SoundScape :
      case SoundSource :
      case TandySoundSource :
      case UltraSound :
         devicestatus = MV_Init( SoundCard, FX_MixRate, numvoices,
            numchannels, samplebits );
         if ( devicestatus != MV_Ok )
            {
            FX_ErrorCode = ( FX_MultiVocError );;
            status = FX_Error;
            }
         break;
      default :
         FX_ErrorCode = ( FX_InvalidCard );;
         status = FX_Error;
      }
   if ( status != FX_Ok )
      {
      LL_UnlockMemory();
      }
   else
      {
      FX_Installed = ( 1 == 1 );
      }
   return( status );
   }

variable_types: numvoices int

variable_types: numchannels int

variable_types: samplebits int

variable_types:
mixrate
unsigned int

variable_types: devicestatus int


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

if ( (unsigned int)FX_SoundDevice <= 0xB && ((1LL << FX_SoundDevice) & 0xF47) != 0 )
{
MV_SetCallBack();
result = 0LL;
}
else
{
FX_ErrorCode = 4;
result = 0xFFFFFFFFLL;
}
return result;
}

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

if ( (unsigned int)FX_SoundDevice <= 0xB && ((1LL << FX_SoundDevice) & 0xF47) != 0 )
{
MV_SetCallBack();
result = 0LL;
}
else
{
FX_ErrorCode = 4;
result = 0xFFFFFFFFLL;
}
return result;
}

original_code:
int FX_SetCallBack
   (
   void ( *function )( unsigned long )
   )
   {
   int status;
   status = FX_Ok;
   switch( FX_SoundDevice )
      {
      case SoundBlaster :
      case Awe32 :
      case ProAudioSpectrum :
      case SoundMan16 :
      case SoundScape :
      case SoundSource :
      case TandySoundSource :
      case UltraSound :
         MV_SetCallBack( function );
         break;
      default :
         FX_ErrorCode = ( FX_InvalidCard );;
         status = FX_Error;
      }
   return( status );
   }

canonical_original_code:
int FX_SetCallBack(void (*function)(unsigned long))
   {
   int status;
   status = FX_Ok;
   switch( FX_SoundDevice )
      {
      case SoundBlaster :
      case Awe32 :
      case ProAudioSpectrum :
      case SoundMan16 :
      case SoundScape :
      case SoundSource :
      case TandySoundSource :
      case UltraSound :
         MV_SetCallBack( function );
         break;
      default :
         FX_ErrorCode = ( FX_InvalidCard );;
         status = FX_Error;
      }
   return( status );
   }

variable_types:
function
void (*)(unsigned long)


decompiled_code:
// attributes: thunk
__int64 FX_SetVolume()
{
return MV_SetVolume();
}

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

original_code:
void FX_SetVolume
   (
   int volume
   )
   {
   int status;
   MV_SetVolume( volume );
   }

canonical_original_code:
void FX_SetVolume(int volume)
   {
   int status;
   MV_SetVolume( volume );
   }

variable_types: volume int

variable_types: status int


decompiled_code:
// attributes: thunk
__int64 FX_GetVolume()
{
return MV_GetVolume();
}

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

original_code:
int FX_GetVolume
   (
   void
   )
   {
   int volume;
   volume = MV_GetVolume();
   return( volume );
   }

canonical_original_code:
int FX_GetVolume()
   {
   int volume;
   volume = MV_GetVolume();
   return( volume );
   }


decompiled_code:
// attributes: thunk
__int64 FX_SetReverseStereo()
{
return MV_SetReverseStereo();
}

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

original_code:
void FX_SetReverseStereo
   (
   int setting
   )
   {
   MV_SetReverseStereo( setting );
   }

canonical_original_code:
void FX_SetReverseStereo(int setting)
   {
   MV_SetReverseStereo( setting );
   }

variable_types: setting int


decompiled_code:
// attributes: thunk
__int64 FX_GetReverseStereo()
{
return MV_GetReverseStereo();
}

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

original_code:
int FX_GetReverseStereo
   (
   void
   )
   {
   return MV_GetReverseStereo();
   }

canonical_original_code:
int FX_GetReverseStereo()
   {
   return MV_GetReverseStereo();
   }


decompiled_code:
// attributes: thunk
__int64 FX_SetReverb()
{
return MV_SetReverb();
}

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

original_code:
void FX_SetReverb
   (
   int reverb
   )
   {
   MV_SetReverb( reverb );
   }

canonical_original_code:
void FX_SetReverb(int reverb)
   {
   MV_SetReverb( reverb );
   }

variable_types: reverb int


decompiled_code:
// attributes: thunk
__int64 FX_SetFastReverb()
{
return MV_SetFastReverb();
}

canonical_decompiled_code:
__int64 func12()
{
return MV_SetFastReverb();
}

original_code:
void FX_SetFastReverb
   (
   int reverb
   )
   {
   MV_SetFastReverb( reverb );
   }

canonical_original_code:
void FX_SetFastReverb(int reverb)
   {
   MV_SetFastReverb( reverb );
   }


decompiled_code:
// attributes: thunk
__int64 FX_GetMaxReverbDelay()
{
return MV_GetMaxReverbDelay();
}

canonical_decompiled_code:
__int64 func13()
{
return MV_GetMaxReverbDelay();
}

original_code:
int FX_GetMaxReverbDelay
   (
   void
   )
   {
   return MV_GetMaxReverbDelay();
   }

canonical_original_code:
int FX_GetMaxReverbDelay()
   {
   return MV_GetMaxReverbDelay();
   }


decompiled_code:
// attributes: thunk
__int64 FX_GetReverbDelay()
{
return MV_GetReverbDelay();
}

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

original_code:
int FX_GetReverbDelay
   (
   void
   )
   {
   return MV_GetReverbDelay();
   }

canonical_original_code:
int FX_GetReverbDelay()
   {
   return MV_GetReverbDelay();
   }


decompiled_code:
// attributes: thunk
__int64 FX_SetReverbDelay()
{
return MV_SetReverbDelay();
}

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

original_code:
void FX_SetReverbDelay
   (
   int delay
   )
   {
   MV_SetReverbDelay( delay );
   }

canonical_original_code:
void FX_SetReverbDelay(int delay)
   {
   MV_SetReverbDelay( delay );
   }

variable_types: delay int


decompiled_code:
// attributes: thunk
__int64 FX_VoiceAvailable()
{
return MV_VoiceAvailable();
}

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

original_code:
int FX_VoiceAvailable
   (
   int priority
   )
   {
   return MV_VoiceAvailable( priority );
   }

canonical_original_code:
int FX_VoiceAvailable(int priority)
   {
   return MV_VoiceAvailable( priority );
   }

variable_types: priority int


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

result = MV_EndLooping();
if ( (_DWORD)result == -1 )
{
FX_ErrorCode = 5;
result = 4294967294LL;
}
return result;
}

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

result = MV_EndLooping();
if ( (_DWORD)result == -1 )
{
FX_ErrorCode = 5;
result = 4294967294LL;
}
return result;
}

original_code:
int FX_EndLooping
   (
   int handle
   )
   {
   int status;
   status = MV_EndLooping( handle );
   if ( status == MV_Error )
      {
      FX_ErrorCode = ( FX_MultiVocError );;
      status = FX_Warning;
      }
   return( status );
   }

canonical_original_code:
int FX_EndLooping(int handle)
   {
   int status;
   status = MV_EndLooping( handle );
   if ( status == MV_Error )
      {
      FX_ErrorCode = ( FX_MultiVocError );;
      status = FX_Warning;
      }
   return( status );
   }

variable_types: handle int


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

result = MV_SetPan();
if ( (_DWORD)result == -1 )
{
FX_ErrorCode = 5;
result = 4294967294LL;
}
return result;
}

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

result = MV_SetPan();
if ( (_DWORD)result == -1 )
{
FX_ErrorCode = 5;
result = 4294967294LL;
}
return result;
}

original_code:
int FX_SetPan
   (
   int handle,
   int vol,
   int left,
   int right
   )
   {
   int status;
   status = MV_SetPan( handle, vol, left, right );
   if ( status == MV_Error )
      {
      FX_ErrorCode = ( FX_MultiVocError );;
      status = FX_Warning;
      }
   return( status );
   }

canonical_original_code:
int FX_SetPan(int handle, int vol, int left, int right)
   {
   int status;
   status = MV_SetPan( handle, vol, left, right );
   if ( status == MV_Error )
      {
      FX_ErrorCode = ( FX_MultiVocError );;
      status = FX_Warning;
      }
   return( status );
   }

variable_types: vol int

variable_types: left int

variable_types: right int


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

result = MV_SetPitch();
if ( (_DWORD)result == -1 )
{
FX_ErrorCode = 5;
result = 4294967294LL;
}
return result;
}

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

result = MV_SetPitch();
if ( (_DWORD)result == -1 )
{
FX_ErrorCode = 5;
result = 4294967294LL;
}
return result;
}

original_code:
int FX_SetPitch
   (
   int handle,
   int pitchoffset
   )
   {
   int status;
   status = MV_SetPitch( handle, pitchoffset );
   if ( status == MV_Error )
      {
      FX_ErrorCode = ( FX_MultiVocError );;
      status = FX_Warning;
      }
   return( status );
   }

canonical_original_code:
int FX_SetPitch(int handle, int pitchoffset)
   {
   int status;
   status = MV_SetPitch( handle, pitchoffset );
   if ( status == MV_Error )
      {
      FX_ErrorCode = ( FX_MultiVocError );;
      status = FX_Warning;
      }
   return( status );
   }

variable_types: pitchoffset int


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

result = MV_SetFrequency();
if ( (_DWORD)result == -1 )
{
FX_ErrorCode = 5;
result = 4294967294LL;
}
return result;
}

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

result = MV_SetFrequency();
if ( (_DWORD)result == -1 )
{
FX_ErrorCode = 5;
result = 4294967294LL;
}
return result;
}

original_code:
int FX_SetFrequency
   (
   int handle,
   int frequency
   )
   {
   int status;
   status = MV_SetFrequency( handle, frequency );
   if ( status == MV_Error )
      {
      FX_ErrorCode = ( FX_MultiVocError );;
      status = FX_Warning;
      }
   return( status );
   }

canonical_original_code:
int FX_SetFrequency(int handle, int frequency)
   {
   int status;
   status = MV_SetFrequency( handle, frequency );
   if ( status == MV_Error )
      {
      FX_ErrorCode = ( FX_MultiVocError );;
      status = FX_Warning;
      }
   return( status );
   }

variable_types: frequency int


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

result = MV_PlayVOC(a1);
if ( (int)result < 0 )
{
FX_ErrorCode = 5;
result = 4294967294LL;
}
return result;
}

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

result = MV_PlayVOC(a1);
if ( (int)result < 0 )
{
FX_ErrorCode = 5;
result = 4294967294LL;
}
return result;
}

original_code:
int FX_PlayVOC
   (
   char *ptr,
   int pitchoffset,
   int vol,
   int left,
   int right,
   int priority,
   unsigned long callbackval
   )
   {
   int handle;
   handle = MV_PlayVOC( ptr, pitchoffset, vol, left, right,
      priority, callbackval );
   if ( handle < MV_Ok )
      {
      FX_ErrorCode = ( FX_MultiVocError );;
      handle = FX_Warning;
      }
   return( handle );
   }

canonical_original_code:
int FX_PlayVOC(char *ptr, int pitchoffset, int vol, int left, int right, int priority, unsigned long callbackval)
   {
   int handle;
   handle = MV_PlayVOC( ptr, pitchoffset, vol, left, right,
      priority, callbackval );
   if ( handle < MV_Ok )
      {
      FX_ErrorCode = ( FX_MultiVocError );;
      handle = FX_Warning;
      }
   return( handle );
   }

variable_types:
ptr
char *

variable_types:
callbackval
unsigned long


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

result = MV_PlayLoopedVOC(a1, a2, a3);
if ( (int)result < 0 )
{
FX_ErrorCode = 5;
result = 4294967294LL;
}
return result;
}

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

result = MV_PlayLoopedVOC(a1, a2, a3);
if ( (int)result < 0 )
{
FX_ErrorCode = 5;
result = 4294967294LL;
}
return result;
}

original_code:
int FX_PlayLoopedVOC
   (
   char *ptr,
   long loopstart,
   long loopend,
   int pitchoffset,
   int vol,
   int left,
   int right,
   int priority,
   unsigned long callbackval
   )
   {
   int handle;
   handle = MV_PlayLoopedVOC( ptr, loopstart, loopend, pitchoffset,
      vol, left, right, priority, callbackval );
   if ( handle < MV_Ok )
      {
      FX_ErrorCode = ( FX_MultiVocError );;
      handle = FX_Warning;
      }
   return( handle );
   }

canonical_original_code:
int FX_PlayLoopedVOC(char *ptr, long loopstart, long loopend, int pitchoffset, int vol, int left, int right, int priority, unsigned long callbackval)
   {
   int handle;
   handle = MV_PlayLoopedVOC( ptr, loopstart, loopend, pitchoffset,
      vol, left, right, priority, callbackval );
   if ( handle < MV_Ok )
      {
      FX_ErrorCode = ( FX_MultiVocError );;
      handle = FX_Warning;
      }
   return( handle );
   }

variable_types: loopstart long

variable_types: loopend long


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

result = MV_PlayWAV(a1);
if ( (int)result < 0 )
{
FX_ErrorCode = 5;
result = 4294967294LL;
}
return result;
}

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

result = MV_PlayWAV(a1);
if ( (int)result < 0 )
{
FX_ErrorCode = 5;
result = 4294967294LL;
}
return result;
}

original_code:
int FX_PlayWAV
   (
   char *ptr,
   int pitchoffset,
   int vol,
   int left,
   int right,
   int priority,
   unsigned long callbackval
   )
   {
   int handle;
   handle = MV_PlayWAV( ptr, pitchoffset, vol, left, right,
      priority, callbackval );
   if ( handle < MV_Ok )
      {
      FX_ErrorCode = ( FX_MultiVocError );;
      handle = FX_Warning;
      }
   return( handle );
   }

canonical_original_code:
int FX_PlayWAV(char *ptr, int pitchoffset, int vol, int left, int right, int priority, unsigned long callbackval)
   {
   int handle;
   handle = MV_PlayWAV( ptr, pitchoffset, vol, left, right,
      priority, callbackval );
   if ( handle < MV_Ok )
      {
      FX_ErrorCode = ( FX_MultiVocError );;
      handle = FX_Warning;
      }
   return( handle );
   }


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

result = MV_PlayLoopedWAV(a1, a2, a3);
if ( (int)result < 0 )
{
FX_ErrorCode = 5;
result = 4294967294LL;
}
return result;
}

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

result = MV_PlayLoopedWAV(a1, a2, a3);
if ( (int)result < 0 )
{
FX_ErrorCode = 5;
result = 4294967294LL;
}
return result;
}

original_code:
int FX_PlayLoopedWAV
   (
   char *ptr,
   long loopstart,
   long loopend,
   int pitchoffset,
   int vol,
   int left,
   int right,
   int priority,
   unsigned long callbackval
   )
   {
   int handle;
   handle = MV_PlayLoopedWAV( ptr, loopstart, loopend,
      pitchoffset, vol, left, right, priority, callbackval );
   if ( handle < MV_Ok )
      {
      FX_ErrorCode = ( FX_MultiVocError );;
      handle = FX_Warning;
      }
   return( handle );
   }

canonical_original_code:
int FX_PlayLoopedWAV(char *ptr, long loopstart, long loopend, int pitchoffset, int vol, int left, int right, int priority, unsigned long callbackval)
   {
   int handle;
   handle = MV_PlayLoopedWAV( ptr, loopstart, loopend,
      pitchoffset, vol, left, right, priority, callbackval );
   if ( handle < MV_Ok )
      {
      FX_ErrorCode = ( FX_MultiVocError );;
      handle = FX_Warning;
      }
   return( handle );
   }


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

result = MV_PlayVOC3D();
if ( (int)result < 0 )
{
FX_ErrorCode = 5;
result = 4294967294LL;
}
return result;
}

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

result = MV_PlayVOC3D();
if ( (int)result < 0 )
{
FX_ErrorCode = 5;
result = 4294967294LL;
}
return result;
}

original_code:
int FX_PlayVOC3D
   (
   char *ptr,
   int pitchoffset,
   int angle,
   int distance,
   int priority,
   unsigned long callbackval
   )
   {
   int handle;
   handle = MV_PlayVOC3D( ptr, pitchoffset, angle, distance,
      priority, callbackval );
   if ( handle < MV_Ok )
      {
      FX_ErrorCode = ( FX_MultiVocError );;
      handle = FX_Warning;
      }
   return( handle );
   }

canonical_original_code:
int FX_PlayVOC3D(char *ptr, int pitchoffset, int angle, int distance, int priority, unsigned long callbackval)
   {
   int handle;
   handle = MV_PlayVOC3D( ptr, pitchoffset, angle, distance,
      priority, callbackval );
   if ( handle < MV_Ok )
      {
      FX_ErrorCode = ( FX_MultiVocError );;
      handle = FX_Warning;
      }
   return( handle );
   }

variable_types: angle int

variable_types: distance int


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

result = MV_PlayWAV3D();
if ( (int)result < 0 )
{
FX_ErrorCode = 5;
result = 4294967294LL;
}
return result;
}

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

result = MV_PlayWAV3D();
if ( (int)result < 0 )
{
FX_ErrorCode = 5;
result = 4294967294LL;
}
return result;
}

original_code:
int FX_PlayWAV3D
   (
   char *ptr,
   int pitchoffset,
   int angle,
   int distance,
   int priority,
   unsigned long callbackval
   )
   {
   int handle;
   handle = MV_PlayWAV3D( ptr, pitchoffset, angle, distance,
      priority, callbackval );
   if ( handle < MV_Ok )
      {
      FX_ErrorCode = ( FX_MultiVocError );;
      handle = FX_Warning;
      }
   return( handle );
   }

canonical_original_code:
int FX_PlayWAV3D(char *ptr, int pitchoffset, int angle, int distance, int priority, unsigned long callbackval)
   {
   int handle;
   handle = MV_PlayWAV3D( ptr, pitchoffset, angle, distance,
      priority, callbackval );
   if ( handle < MV_Ok )
      {
      FX_ErrorCode = ( FX_MultiVocError );;
      handle = FX_Warning;
      }
   return( handle );
   }


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

result = MV_PlayRaw(a1, a2, a3);
if ( (int)result < 0 )
{
FX_ErrorCode = 5;
result = 4294967294LL;
}
return result;
}

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

result = MV_PlayRaw(a1, a2, a3);
if ( (int)result < 0 )
{
FX_ErrorCode = 5;
result = 4294967294LL;
}
return result;
}

original_code:
int FX_PlayRaw
   (
   char *ptr,
   unsigned long length,
   unsigned rate,
   int pitchoffset,
   int vol,
   int left,
   int right,
   int priority,
   unsigned long callbackval
   )
   {
   int handle;
   handle = MV_PlayRaw( ptr, length, rate, pitchoffset,
      vol, left, right, priority, callbackval );
   if ( handle < MV_Ok )
      {
      FX_ErrorCode = ( FX_MultiVocError );;
      handle = FX_Warning;
      }
   return( handle );
   }

canonical_original_code:
int FX_PlayRaw(char *ptr, unsigned long length, unsigned int rate, int pitchoffset, int vol, int left, int right, int priority, unsigned long callbackval)
   {
   int handle;
   handle = MV_PlayRaw( ptr, length, rate, pitchoffset,
      vol, left, right, priority, callbackval );
   if ( handle < MV_Ok )
      {
      FX_ErrorCode = ( FX_MultiVocError );;
      handle = FX_Warning;
      }
   return( handle );
   }

variable_types:
length
unsigned long

variable_types:
rate
unsigned int


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

result = MV_PlayLoopedRaw(a1, a2, a3, a4, a5);
if ( (int)result < 0 )
{
FX_ErrorCode = 5;
result = 4294967294LL;
}
return result;
}

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

result = MV_PlayLoopedRaw(a1, a2, a3, a4, a5);
if ( (int)result < 0 )
{
FX_ErrorCode = 5;
result = 4294967294LL;
}
return result;
}

original_code:
int FX_PlayLoopedRaw
   (
   char *ptr,
   unsigned long length,
   char *loopstart,
   char *loopend,
   unsigned rate,
   int pitchoffset,
   int vol,
   int left,
   int right,
   int priority,
   unsigned long callbackval
   )
   {
   int handle;
   handle = MV_PlayLoopedRaw( ptr, length, loopstart, loopend,
      rate, pitchoffset, vol, left, right, priority, callbackval );
   if ( handle < MV_Ok )
      {
      FX_ErrorCode = ( FX_MultiVocError );;
      handle = FX_Warning;
      }
   return( handle );
   }

canonical_original_code:
int FX_PlayLoopedRaw(char *ptr, unsigned long length, char *loopstart, char *loopend, unsigned int rate, int pitchoffset, int vol, int left, int right, int priority, unsigned long callbackval)
   {
   int handle;
   handle = MV_PlayLoopedRaw( ptr, length, loopstart, loopend,
      rate, pitchoffset, vol, left, right, priority, callbackval );
   if ( handle < MV_Ok )
      {
      FX_ErrorCode = ( FX_MultiVocError );;
      handle = FX_Warning;
      }
   return( handle );
   }

variable_types:
loopstart
char *

variable_types:
loopend
char *


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

result = MV_Pan3D();
if ( (_DWORD)result )
{
FX_ErrorCode = 5;
result = 4294967294LL;
}
return result;
}

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

result = MV_Pan3D();
if ( (_DWORD)result )
{
FX_ErrorCode = 5;
result = 4294967294LL;
}
return result;
}

original_code:
int FX_Pan3D
   (
   int handle,
   int angle,
   int distance
   )
   {
   int status;
   status = MV_Pan3D( handle, angle, distance );
   if ( status != MV_Ok )
      {
      FX_ErrorCode = ( FX_MultiVocError );;
      status = FX_Warning;
      }
   return( status );
   }

canonical_original_code:
int FX_Pan3D(int handle, int angle, int distance)
   {
   int status;
   status = MV_Pan3D( handle, angle, distance );
   if ( status != MV_Ok )
      {
      FX_ErrorCode = ( FX_MultiVocError );;
      status = FX_Warning;
      }
   return( status );
   }

variable_types: status int


decompiled_code:
// attributes: thunk
__int64 FX_SoundActive()
{
return MV_VoicePlaying();
}

canonical_decompiled_code:
__int64 func30()
{
return MV_VoicePlaying();
}

original_code:
int FX_SoundActive
   (
   int handle
   )
   {
   return( MV_VoicePlaying( handle ) );
   }

canonical_original_code:
int FX_SoundActive(int handle)
   {
   return( MV_VoicePlaying( handle ) );
   }

variable_types: handle int


decompiled_code:
// attributes: thunk
__int64 FX_SoundsPlaying()
{
return MV_VoicesPlaying();
}

canonical_decompiled_code:
__int64 func31()
{
return MV_VoicesPlaying();
}

original_code:
int FX_SoundsPlaying
   (
   void
   )
   {
   return( MV_VoicesPlaying() );
   }

canonical_original_code:
int FX_SoundsPlaying()
   {
   return( MV_VoicesPlaying() );
   }


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

result = MV_Kill();
if ( (_DWORD)result )
{
FX_ErrorCode = 5;
result = 4294967294LL;
}
return result;
}

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

result = MV_Kill();
if ( (_DWORD)result )
{
FX_ErrorCode = 5;
result = 4294967294LL;
}
return result;
}

original_code:
int FX_StopSound
   (
   int handle
   )
   {
   int status;
   status = MV_Kill( handle );
   if ( status != MV_Ok )
      {
      FX_ErrorCode = ( FX_MultiVocError );;
      return( FX_Warning );
      }
   return( FX_Ok );
   }

canonical_original_code:
int FX_StopSound(int handle)
   {
   int status;
   status = MV_Kill( handle );
   if ( status != MV_Ok )
      {
      FX_ErrorCode = ( FX_MultiVocError );;
      return( FX_Warning );
      }
   return( FX_Ok );
   }


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

result = MV_KillAllVoices();
if ( (_DWORD)result )
{
FX_ErrorCode = 5;
result = 4294967294LL;
}
return result;
}

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

result = MV_KillAllVoices();
if ( (_DWORD)result )
{
FX_ErrorCode = 5;
result = 4294967294LL;
}
return result;
}

original_code:
int FX_StopAllSounds
   (
   void
   )
   {
   int status;
   status = MV_KillAllVoices();
   if ( status != MV_Ok )
      {
      FX_ErrorCode = ( FX_MultiVocError );;
      return( FX_Warning );
      }
   return( FX_Ok );
   }

canonical_original_code:
int FX_StopAllSounds()
   {
   int status;
   status = MV_KillAllVoices();
   if ( status != MV_Ok )
      {
      FX_ErrorCode = ( FX_MultiVocError );;
      return( FX_Warning );
      }
   return( FX_Ok );
   }


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

result = MV_StartDemandFeedPlayback(a1, a2);
if ( (int)result < 0 )
{
FX_ErrorCode = 5;
result = 4294967294LL;
}
return result;
}

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

result = MV_StartDemandFeedPlayback(a1, a2);
if ( (int)result < 0 )
{
FX_ErrorCode = 5;
result = 4294967294LL;
}
return result;
}

original_code:
int FX_StartDemandFeedPlayback
   (
   void ( *function )( char **ptr, unsigned long *length ),
   int rate,
   int pitchoffset,
   int vol,
   int left,
   int right,
   int priority,
   unsigned long callbackval
   )
   {
   int handle;
   handle = MV_StartDemandFeedPlayback( function, rate,
      pitchoffset, vol, left, right, priority, callbackval );
   if ( handle < MV_Ok )
      {
      FX_ErrorCode = ( FX_MultiVocError );;
      handle = FX_Warning;
      }
   return( handle );
   }

canonical_original_code:
int FX_StartDemandFeedPlayback(void (*function)(char **ptr, unsigned long *length), int rate, int pitchoffset, int vol, int left, int right, int priority, unsigned long callbackval)
   {
   int handle;
   handle = MV_StartDemandFeedPlayback( function, rate,
      pitchoffset, vol, left, right, priority, callbackval );
   if ( handle < MV_Ok )
      {
      FX_ErrorCode = ( FX_MultiVocError );;
      handle = FX_Warning;
      }
   return( handle );
   }

variable_types: void (*)(char **ptr, unsigned long *length)

variable_types: rate int

variable_types: vol int

variable_types: priority int


decompiled_code:
__int64 FX_StartRecording()
{
FX_ErrorCode = 4;
return 4294967294LL;
}

canonical_decompiled_code:
__int64 func35()
{
FX_ErrorCode = 4;
return 4294967294LL;
}

original_code:
int FX_StartRecording
   (
   int MixRate,
   void ( *function )( char *ptr, int length )
   )
   {
   int status;
   FX_ErrorCode = ( FX_InvalidCard );;
   status = FX_Warning;
   return( status );
   }

canonical_original_code:
int FX_StartRecording(int MixRate, void (*function)(char *ptr, int length))
   {
   int status;
   FX_ErrorCode = ( FX_InvalidCard );;
   status = FX_Warning;
   return( status );
   }

variable_types: MixRate int

variable_types:
function
void (*)(char *ptr, int length)


decompiled_code:
void FX_StopRecord()
{
;
}

canonical_decompiled_code:
void func36()
{
;
}

original_code:
void FX_StopRecord
   (
   void
   )
   {
   }

canonical_original_code:
void FX_StopRecord()
   {
   }


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

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

original_code:
unsigned long DPMI_GetRealModeVector
   (
   int num
   )
   {
   return 0;
   }

canonical_original_code:
unsigned long DPMI_GetRealModeVector(int num)
   {
   return 0;
   }

variable_types: num int


decompiled_code:
void DPMI_SetRealModeVector()
{
;
}

canonical_decompiled_code:
void func2()
{
;
}

original_code:
void DPMI_SetRealModeVector
   (
   int num,
   unsigned long vector
   )
   {
   }

canonical_original_code:
void DPMI_SetRealModeVector(int num, unsigned long vector)
   {
   }

variable_types:
vector
unsigned long


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

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

original_code:
int DPMI_CallRealModeFunction
   (
   dpmi_regs *callregs
   )
   {
   return( DPMI_Ok );
   }

canonical_original_code:
int DPMI_CallRealModeFunction(struct dpmi_regs *callregs)
   {
   return( DPMI_Ok );
   }

variable_types: struct dpmi_regs { unsigned long EDI; unsigned long ESI; unsigned long EBP; unsigned long Reserved; unsigned long EBX; unsigned long EDX; unsigned long ECX; unsigned long EAX; unsigned short Flags; unsigned short ES; unsigned short DS; unsigned short FS; unsigned short GS; unsigned short IP; unsigned short CS; unsigned short SP; unsigned short SS; } *


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

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

original_code:
int DPMI_LockMemory
   (
   void *address,
   unsigned length
   )
   {
   return ( DPMI_Ok );
   }

canonical_original_code:
int DPMI_LockMemory(void *address, unsigned int length)
   {
   return ( DPMI_Ok );
   }

variable_types:
address
void *

variable_types:
length
unsigned int


decompiled_code:
// attributes: thunk
__int64 DPMI_LockMemoryRegion()
{
return DPMI_LockMemory_constprop_0();
}

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

original_code:
int DPMI_LockMemoryRegion
   (
   void *start,
   void *end
   )
   {
   int status;
   status = DPMI_LockMemory( start, ( char * )end - ( char * )start );
   return( status );
   }

canonical_original_code:
int DPMI_LockMemoryRegion(void *start, void *end)
   {
   int status;
   status = DPMI_LockMemory( start, ( char * )end - ( char * )start );
   return( status );
   }

variable_types:
start
void *

variable_types:
end
void *


decompiled_code:
// attributes: thunk
__int64 DPMI_UnlockMemory()
{
return DPMI_LockMemory_constprop_0();
}

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

original_code:
int DPMI_UnlockMemory
   (
   void *address,
   unsigned length
   )
   {
   return ( DPMI_Ok );
   }

canonical_original_code:
int DPMI_UnlockMemory(void *address, unsigned int length)
   {
   return ( DPMI_Ok );
   }


decompiled_code:
// attributes: thunk
__int64 DPMI_UnlockMemoryRegion()
{
return DPMI_LockMemoryRegion();
}

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

original_code:
int DPMI_UnlockMemoryRegion
   (
   void *start,
   void *end
   )
   {
   int status;
   status = DPMI_UnlockMemory( start, ( char * )end - ( char * )start );
   return( status );
   }

canonical_original_code:
int DPMI_UnlockMemoryRegion(void *start, void *end)
   {
   int status;
   status = DPMI_UnlockMemory( start, ( char * )end - ( char * )start );
   return( status );
   }


decompiled_code:
__int64 __fastcall DPMI_GetDOSMemory(_QWORD *a1, _QWORD *a2, unsigned int a3)
{
void *v3; // rax

v3 = malloc(a3);
*a1 = v3;
*a2 = v3;
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func8(_QWORD *a1, _QWORD *a2, unsigned int a3)
{
void *v3; // rax

v3 = malloc(a3);
*a1 = v3;
*a2 = v3;
return 0LL;
}

original_code:
int DPMI_GetDOSMemory( void **ptr, long *descriptor, unsigned length )
{
 *ptr = (void *)malloc(length);
 *descriptor = (long) *ptr;
 return (descriptor == 0) ? DPMI_Error : DPMI_Ok;
}

canonical_original_code:
int DPMI_GetDOSMemory(void **ptr, long *descriptor, unsigned int length)
{
 *ptr = (void *)malloc(length);
 *descriptor = (long) *ptr;
 return (descriptor == 0) ? DPMI_Error : DPMI_Ok;
}

variable_types:
ptr
void **

variable_types:
descriptor
long *


decompiled_code:
__int64 __fastcall DPMI_FreeDOSMemory(void *a1)
{
free(a1);
return (unsigned int)-(a1 == 0LL);
}

canonical_decompiled_code:
__int64 __fastcall func9(void *a1)
{
free(a1);
return (unsigned int)-(a1 == 0LL);
}

original_code:
int DPMI_FreeDOSMemory( long descriptor )
{
 free((void *)descriptor);
 return (descriptor == 0) ? DPMI_Error : DPMI_Ok;
}

canonical_original_code:
int DPMI_FreeDOSMemory(long descriptor)
{
 free((void *)descriptor);
 return (descriptor == 0) ? DPMI_Error : DPMI_Ok;
}

variable_types: descriptor long


original_code:
void MV_16BitReverb( const char *src, char *dest, const VOLUME16 *volume, int count )
{
 int i;
 short *pdest = (short *)dest;
 for (i = 0; i < count; i++) {
  int sl = src[i*2+0];
  int sh = src[i*2+1] ^ 0x80;
  sl = (*volume)[sl] >> 8;
  sh = (*volume)[sh];
  pdest[i] = (short)(sl + sh + 0x80);
 }
}

canonical_original_code:
void MV_16BitReverb(char *src, char *dest, short (*volume)[256], int count)
{
 int i;
 short *pdest = (short *)dest;
 for (i = 0; i < count; i++) {
  int sl = src[i*2+0];
  int sh = src[i*2+1] ^ 0x80;
  sl = (*volume)[sl] >> 8;
  sh = (*volume)[sh];
  pdest[i] = (short)(sl + sh + 0x80);
 }
}

variable_types:
src
char *

variable_types:
dest
char *

variable_types:
volume
short (*)[256]

variable_types: count int

variable_types: i int

variable_types:
pdest
short *

variable_types: sl int

variable_types: sh int


original_code:
void MV_8BitReverb( const signed char *src, signed char *dest, const VOLUME16 *volume, int count )
{
 int i;
 for (i = 0; i < count; i++) {
  unsigned char s = (unsigned char) src[i];
  s = (*volume)[s] & 0xff;
  dest[i] = (char)(s + 0x80);
 }
}

canonical_original_code:
void MV_8BitReverb(char *src, char *dest, short (*volume)[256], int count)
{
 int i;
 for (i = 0; i < count; i++) {
  unsigned char s = (unsigned char) src[i];
  s = (*volume)[s] & 0xff;
  dest[i] = (char)(s + 0x80);
 }
}

variable_types:
s
unsigned char


original_code:
void MV_16BitReverbFast( const char *src, char *dest, int count, int shift )
{
 int i;
 short *pdest = (short *)dest;
 const short *psrc = (const short *)src;
 for (i = 0; i < count; i++) {
  pdest[i] = psrc[i] >> shift;
 }
}

canonical_original_code:
void MV_16BitReverbFast(char *src, char *dest, int count, int shift)
{
 int i;
 short *pdest = (short *)dest;
 short *psrc = (const short *)src;
 for (i = 0; i < count; i++) {
  pdest[i] = psrc[i] >> shift;
 }
}

variable_types: shift int

variable_types:
psrc
short *


decompiled_code:
__int64 __fastcall MV_8BitReverbFast(__int64 a1, __int64 a2, int a3, char a4)
{
__int64 result; // rax
int v7; // er10
__int64 v8; // rdi
__int64 i; // rsi
int v10; // edx

result = 128 >> a4;
v7 = -128 - result;
if ( a3 > 0 )
{
v8 = a3;
for ( i = 0LL; i != v8; ++i )
{
v10 = (int)*(unsigned __int8 *)(a1 + i) >> a4;
result = v10 + v7 + (unsigned int)!(*(_BYTE *)(a1 + i) >> 7);
*(_BYTE *)(a2 + i) = v10 + v7 + !(*(_BYTE *)(a1 + i) >> 7);
}
}
return result;
}

original_code:
void MV_8BitReverbFast( const signed char *src, signed char *dest, int count, int shift )
{
 int i;
 unsigned char sh = 0x80 - (0x80 >> shift);
 for (i = 0; i < count; i++) {
  unsigned char a = ((unsigned char) src[i]) >> shift;
  unsigned char c = (((unsigned char) src[i]) ^ 0x80) >> 7;
  dest[i] = (signed char) (a + sh + c);
 }
}

canonical_original_code:
void MV_8BitReverbFast(char *src, char *dest, int count, int shift)
{
 int i;
 unsigned char sh = 0x80 - (0x80 >> shift);
 for (i = 0; i < count; i++) {
  unsigned char a = ((unsigned char) src[i]) >> shift;
  unsigned char c = (((unsigned char) src[i]) ^ 0x80) >> 7;
  dest[i] = (char) (a + sh + c);
 }
}

variable_types:
sh
unsigned char

variable_types:
a
unsigned char

variable_types:
c
unsigned char


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

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

original_code:
int USER_CheckParameter
   (
   const char *parameter
   )
   {
   return ( !( 1 == 1 ) );
   }

canonical_original_code:
int USER_CheckParameter(char *parameter)
   {
   return ( !( 1 == 1 ) );
   }

variable_types:
parameter
char *


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

original_code:
char *USER_GetText
   (
   const char *parameter
   )
   {
   return ((void *)0);
   }

canonical_original_code:
char *USER_GetText(char *parameter)
   {
   return ((void *)0);
   }


decompiled_code:
__int64 __fastcall USRHOOKS_GetMem(_QWORD *a1, size_t a2)
{
void *v2; // rax

v2 = malloc(a2);
if ( !v2 )
return 0xFFFFFFFFLL;
*a1 = v2;
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func0(_QWORD *a1, size_t a2)
{
void *v2; // rax

v2 = malloc(a2);
if ( !v2 )
return 0xFFFFFFFFLL;
*a1 = v2;
return 0LL;
}

original_code:
int USRHOOKS_GetMem
   (
   void **ptr,
   unsigned long size
   )
   {
   void *memory;
   memory = malloc( size );
   if ( memory == ((void *)0) )
      {
      return( USRHOOKS_Error );
      }
   *ptr = memory;
   return( USRHOOKS_Ok );
   }

canonical_original_code:
int USRHOOKS_GetMem(void **ptr, unsigned long size)
   {
   void *memory;
   memory = malloc( size );
   if ( memory == ((void *)0) )
      {
      return( USRHOOKS_Error );
      }
   *ptr = memory;
   return( USRHOOKS_Ok );
   }

variable_types:
ptr
void **

variable_types:
size
unsigned long

variable_types:
memory
void *


decompiled_code:
__int64 __fastcall USRHOOKS_FreeMem(void *a1)
{
if ( !a1 )
return 0xFFFFFFFFLL;
free(a1);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func1(void *a1)
{
if ( !a1 )
return 0xFFFFFFFFLL;
free(a1);
return 0LL;
}

original_code:
int USRHOOKS_FreeMem
   (
   void *ptr
   )
   {
   if ( ptr == ((void *)0) )
      {
      return( USRHOOKS_Error );
      }
   free( ptr );
   return( USRHOOKS_Ok );
   }

canonical_original_code:
int USRHOOKS_FreeMem(void *ptr)
   {
   if ( ptr == ((void *)0) )
      {
      return( USRHOOKS_Error );
      }
   free( ptr );
   return( USRHOOKS_Ok );
   }

variable_types:
ptr
void *


decompiled_code:
void __fastcall lbs_arg_qopt_free_generic(void *ptr)
{
void *v2; // rdi
void **v3; // rbx

if ( ptr )
{
lbs_strv_unref_generic(*(_QWORD *)ptr);
lbs_array_unref_generic(*((_QWORD *)ptr + 1));
v2 = (void *)*((_QWORD *)ptr + 3);
if ( v2 )
{
v3 = (void **)((char *)ptr + 40);
do
{
free(v2);
v2 = *v3;
v3 += 2;
}
while ( v2 );
}
free(ptr);
}
}

canonical_decompiled_code:
void __fastcall func0(void *ptr)
{
void *v2; // rdi
void **v3; // rbx

if ( ptr )
{
lbs_strv_unref_generic(*(_QWORD *)ptr);
lbs_array_unref_generic(*((_QWORD *)ptr + 1));
v2 = (void *)*((_QWORD *)ptr + 3);
if ( v2 )
{
v3 = (void **)((char *)ptr + 40);
do
{
free(v2);
v2 = *v3;
v3 += 2;
}
while ( v2 );
}
free(ptr);
}
}

original_code:
void lbs_arg_qopt_free_generic (void* qopt_generic) {
    if (qopt_generic == ((void *)0)) {
        return;
    }
    LbsArgQopt* qopt = qopt_generic;
    (lbs_strv_unref_generic ((_Generic (((qopt->strv)), LbsStrv*: ((qopt->strv))))));
    (lbs_array_unref_generic ((_Generic (((qopt->detail)), LbsArray*: ((qopt->detail))))));
    for (int i = 0; qopt->opts[i].name != ((void *)0); i++) {
        free (qopt->opts[i].name);
    }
    free (qopt);
}

canonical_original_code:
void lbs_arg_qopt_free_generic(void *qopt_generic) {
    if (qopt_generic == ((void *)0)) {
        return;
    }
    struct LbsArgQoptStruct *qopt = qopt_generic;
    (lbs_strv_unref_generic ((_Generic (((qopt->strv)), struct LbsStrvStruct *: ((qopt->strv))))));
    (lbs_array_unref_generic ((_Generic (((qopt->detail)), struct LbsArrayStruct *: ((qopt->detail))))));
    for (int i = 0; qopt->opts[i].name != ((void *)0); i++) {
        free (qopt->opts[i].name);
    }
    free (qopt);
}

variable_types: struct LbsArgQoptStruct { struct LbsStrvStruct { struct LbsArrayStruct { void *data; void (*free_func)(void *data); unsigned long size; unsigned long len; unsigned long max; unsigned int ref_count; _Bool is_alloc; } array; unsigned int ref_count; _Bool is_alloc; } *strv; struct LbsArrayStruct *detail; unsigned long len; struct LbsArgQoptItemStruct { char *name; char *value; } opts[]; } *

user_defined_types: struct LbsArgQoptStruct { struct LbsStrvStruct *strv; struct LbsArrayStruct *detail; unsigned long len; struct LbsArgQoptItemStruct opts[]; }

user_defined_types: struct LbsStrvStruct { struct LbsArrayStruct array; unsigned int ref_count; _Bool is_alloc; }


decompiled_code:
char __fastcall lbs_str_has_prefix(char *a1, _BYTE *a2)
{
char v2; // dl
__int64 v3; // rax
char v4; // cl

v2 = *a1;
v3 = 0LL;
if ( !*a1 )
return *a2 == 0;
while ( 1 )
{
v4 = a2[v3];
if ( !v4 )
return 1;
if ( v4 != v2 )
break;
v2 = a1[++v3];
if ( !v2 )
{
a2 += v3;
return *a2 == 0;
}
}
return 0;
}

canonical_decompiled_code:
char __fastcall func0(char *a1, _BYTE *a2)
{
char v2; // dl
__int64 v3; // rax
char v4; // cl

v2 = *a1;
v3 = 0LL;
if ( !*a1 )
return *a2 == 0;
while ( 1 )
{
v4 = a2[v3];
if ( !v4 )
return 1;
if ( v4 != v2 )
break;
v2 = a1[++v3];
if ( !v2 )
{
a2 += v3;
return *a2 == 0;
}
}
return 0;
}

original_code:
_Bool lbs_str_has_prefix (const char* str, const char* prefix) {
    int i;
    for (i = 0; str[i] != '\0' && prefix[i] != '\0'; i++) {
        if (str[i] != prefix[i]) {
            return 0;
        }
    }
    if (str[i] == '\0' && prefix[i] == '\0') {
        return 1;
    }
    if (str[i] == '\0') {
        return 0;
    }
    return 1;
}

canonical_original_code:
_Bool lbs_str_has_prefix(char *str, char *prefix) {
    int i;
    for (i = 0; str[i] != '\0' && prefix[i] != '\0'; i++) {
        if (str[i] != prefix[i]) {
            return 0;
        }
    }
    if (str[i] == '\0' && prefix[i] == '\0') {
        return 1;
    }
    if (str[i] == '\0') {
        return 0;
    }
    return 1;
}

variable_types:
str
char *

variable_types:
prefix
char *


original_code:
_Bool lbs_str_has_suffix (const char* str, const char* suffix) {
    size_t len = strlen (str);
    size_t suflen = strlen (suffix);
    int i, j;
    for (i = len - 1, j = suflen - 1; i >= 0 && j >= 0; i--, j--) {
        if (str[i] != suffix[j]) {
            return 0;
        }
    }
    if (i < 0 && j >= 0) {
        return 0;
    }
    return 1;
}

canonical_original_code:
_Bool lbs_str_has_suffix(char *str, char *suffix) {
    unsigned long len = strlen (str);
    unsigned long suflen = strlen (suffix);
    int i; int j;
    for (i = len - 1, j = suflen - 1; i >= 0 && j >= 0; i--, j--) {
        if (str[i] != suffix[j]) {
            return 0;
        }
    }
    if (i < 0 && j >= 0) {
        return 0;
    }
    return 1;
}

variable_types:
suffix
char *

variable_types:
len
unsigned long

variable_types:
suflen
unsigned long

variable_types: i int

variable_types: j int


decompiled_code:
char *__fastcall lbs_str_vprintf(char *format, const __m128i *a2)
{
size_t v2; // rbp
char *v3; // r12
__int64 v4; // rax
__m128i v6; // [rsp+0h] [rbp-58h] BYREF
__int64 v7; // [rsp+10h] [rbp-48h]
__m128i arg; // [rsp+18h] [rbp-40h] BYREF
__int64 v9; // [rsp+28h] [rbp-30h]

v6 = _mm_loadu_si128(a2);
v7 = a2[1].m128i_i64[0];
v2 = vsnprintf(0LL, 0LL, format, &v6) + 1;
v3 = (char *)malloc(v2);
v4 = a2[1].m128i_i64[0];
arg = _mm_loadu_si128(a2);
v9 = v4;
vsnprintf(v3, v2, format, &arg);
return v3;
}

canonical_decompiled_code:
char *__fastcall func2(char *format, const __m128i *a2)
{
size_t v2; // rbp
char *v3; // r12
__int64 v4; // rax
__m128i v6; // [rsp+0h] [rbp-58h] BYREF
__int64 v7; // [rsp+10h] [rbp-48h]
__m128i arg; // [rsp+18h] [rbp-40h] BYREF
__int64 v9; // [rsp+28h] [rbp-30h]

v6 = _mm_loadu_si128(a2);
v7 = a2[1].m128i_i64[0];
v2 = vsnprintf(0LL, 0LL, format, &v6) + 1;
v3 = (char *)malloc(v2);
v4 = a2[1].m128i_i64[0];
arg = _mm_loadu_si128(a2);
v9 = v4;
vsnprintf(v3, v2, format, &arg);
return v3;
}

original_code:
char* lbs_str_vprintf (const char* format, va_list ap) {
    va_list ap1, ap2;
    char* newstr;
    int len;
    __builtin_va_copy(ap1,ap);
    len = vsnprintf (((void *)0), 0, format, ap1) + 1;
    __builtin_va_end(ap1);
    newstr = malloc (len);
    __builtin_va_copy(ap2,ap);
    vsnprintf (newstr, len, format, ap2);
    __builtin_va_end(ap2);
    return newstr;
}

canonical_original_code:
char *lbs_str_vprintf(char *format, __builtin_va_list ap) {
    __builtin_va_list ap1; __builtin_va_list ap2;
    char *newstr;
    int len;
    __builtin_va_copy(ap1,ap);
    len = vsnprintf (((void *)0), 0, format, ap1) + 1;
    __builtin_va_end(ap1);
    newstr = malloc (len);
    __builtin_va_copy(ap2,ap);
    vsnprintf (newstr, len, format, ap2);
    __builtin_va_end(ap2);
    return newstr;
}

variable_types:
format
char *

variable_types:
newstr
char *

variable_types: len int


decompiled_code:
char *lbs_str_printf(char *a1, ...)
{
gcc_va_list va; // [rsp+8h] [rbp-D0h] BYREF

va_start(va, a1);
return lbs_str_vprintf(a1, (const __m128i *)va);
}

canonical_decompiled_code:
char *func3(char *a1, ...)
{
gcc_va_list va; // [rsp+8h] [rbp-D0h] BYREF

va_start(va, a1);
return func2(a1, (const __m128i *)va);
}

original_code:
char* lbs_str_printf (const char* format, ...) {
    va_list ap;
    char* newstr;
    __builtin_va_start(ap,format);
    newstr = lbs_str_vprintf (format, ap);
    __builtin_va_end(ap);
    return newstr;
}

canonical_original_code:
char *lbs_str_printf(char *format, ...) {
    __builtin_va_list ap;
    char *newstr;
    __builtin_va_start(ap,format);
    newstr = lbs_str_vprintf (format, ap);
    __builtin_va_end(ap);
    return newstr;
}


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

if ( (int)lbs_array_init_with_max(a1, 48LL, a2) < 0 )
return 0xFFFFFFFFLL;
*(_DWORD *)(a1 + 48) = 1;
result = 0LL;
*(_BYTE *)(a1 + 52) = 0;
return result;
}

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

if ( (int)lbs_array_init_with_max(a1, 48LL, a2) < 0 )
return 0xFFFFFFFFLL;
*(_DWORD *)(a1 + 48) = 1;
result = 0LL;
*(_BYTE *)(a1 + 52) = 0;
return result;
}

original_code:
int lbs_strv_init_with_max (LbsStrv* strv, size_t max) {
    if (lbs_array_init_with_max (&strv->array, sizeof (LbsArray), max) < 0) {
        return -1;
    }
    strv->ref_count = 1;
    strv->is_alloc = 0;
    return 0;
}

canonical_original_code:
int lbs_strv_init_with_max(struct LbsStrvStruct *strv, unsigned long max) {
    if (lbs_array_init_with_max (&strv->array, sizeof (LbsArray), max) < 0) {
        return -1;
    }
    strv->ref_count = 1;
    strv->is_alloc = 0;
    return 0;
}

variable_types: struct LbsStrvStruct { struct LbsArrayStruct { void *data; void (*free_func)(void *data); unsigned long size; unsigned long len; unsigned long max; unsigned int ref_count; _Bool is_alloc; } array; unsigned int ref_count; _Bool is_alloc; } *

variable_types:
max
unsigned long


decompiled_code:
__int64 __fastcall lbs_strv_ref_generic(__int64 a1)
{
++*(_DWORD *)(a1 + 48);
return a1;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1)
{
++*(_DWORD *)(a1 + 48);
return a1;
}

original_code:
void* lbs_strv_ref_generic (void* strv_generic) {
    LbsStrv* strv = ((LbsStrv*)(strv_generic));
    strv->ref_count++;
    return strv;
}

canonical_original_code:
void *lbs_strv_ref_generic(void *strv_generic) {
    struct LbsStrvStruct *strv = ((LbsStrv*)(strv_generic));
    strv->ref_count++;
    return strv;
}

return_type: void *

user_defined_types: struct LbsArrayStruct { void *data; void (*free_func)(void *data); unsigned long size; unsigned long len; unsigned long max; unsigned int ref_count; _Bool is_alloc; }


decompiled_code:
void __fastcall lbs_strv_free_generic(void *ptr)
{
unsigned __int64 v2; // rbx
__int64 v3; // rdi

if ( ptr )
{
if ( *((_QWORD *)ptr + 3) )
{
v2 = 0LL;
do
{
v3 = 3 * v2++;
lbs_array_unref_generic(*(_QWORD *)ptr + 16 * v3);
}
while ( *((_QWORD *)ptr + 3) > v2 );
}
lbs_array_unref_generic(ptr);
if ( *((_BYTE *)ptr + 52) )
free(ptr);
}
}

canonical_decompiled_code:
void __fastcall func3(void *ptr)
{
unsigned __int64 v2; // rbx
__int64 v3; // rdi

if ( ptr )
{
if ( *((_QWORD *)ptr + 3) )
{
v2 = 0LL;
do
{
v3 = 3 * v2++;
lbs_array_unref_generic(*(_QWORD *)ptr + 16 * v3);
}
while ( *((_QWORD *)ptr + 3) > v2 );
}
lbs_array_unref_generic(ptr);
if ( *((_BYTE *)ptr + 52) )
free(ptr);
}
}

original_code:
void lbs_strv_free_generic (void* strv_generic) {
    if (strv_generic == ((void *)0)) {
        return;
    }
    LbsStrv* strv = ((LbsStrv*)(strv_generic));
    size_t i = 0;
    for (; i < (((_Generic (((&((_Generic (((strv)), LbsStrv*: ((strv))))->array))), LbsArray*: ((&((_Generic (((strv)), LbsStrv*: ((strv))))->array)))))->len)); i++) {
        LbsArray* str_wrapper = (&((*(((LbsArray*)((&((strv)->array))->data))+((i))))));
        (lbs_array_unref_generic ((_Generic (((str_wrapper)), LbsArray*: ((str_wrapper))))));
    }
    (lbs_array_unref_generic ((_Generic (((&strv->array)), LbsArray*: ((&strv->array))))));
    if (strv->is_alloc) {
        free (strv);
    }
}

canonical_original_code:
void lbs_strv_free_generic(void *strv_generic) {
    if (strv_generic == ((void *)0)) {
        return;
    }
    struct LbsStrvStruct *strv = ((LbsStrv*)(strv_generic));
    unsigned long i = 0;
    for (; i < (((_Generic (((&((_Generic (((strv)), struct LbsStrvStruct *: ((strv))))->array))), struct LbsArrayStruct *: ((&((_Generic (((strv)), struct LbsStrvStruct *: ((strv))))->array)))))->len)); i++) {
        struct LbsArrayStruct *str_wrapper = (&((*(((LbsArray*)((&((strv)->array))->data))+((i))))));
        (lbs_array_unref_generic ((_Generic (((str_wrapper)), struct LbsArrayStruct *: ((str_wrapper))))));
    }
    (lbs_array_unref_generic ((_Generic (((&strv->array)), struct LbsArrayStruct *: ((&strv->array))))));
    if (strv->is_alloc) {
        free (strv);
    }
}

variable_types:
i
unsigned long

variable_types: struct LbsArrayStruct { void *data; void (*free_func)(void *data); unsigned long size; unsigned long len; unsigned long max; unsigned int ref_count; _Bool is_alloc; } *


decompiled_code:
void __fastcall lbs_strv_unref_generic(void *ptr)
{
if ( ptr )
{
if ( (*((_DWORD *)ptr + 12))-- == 1 )
lbs_strv_free_generic(ptr);
}
}

canonical_decompiled_code:
void __fastcall func4(void *ptr)
{
if ( ptr )
{
if ( (*((_DWORD *)ptr + 12))-- == 1 )
func3(ptr);
}
}

original_code:
void lbs_strv_unref_generic (void* strv_generic) {
    if (strv_generic == ((void *)0)) {
        return;
    }
    LbsStrv* strv = ((LbsStrv*)(strv_generic));
    strv->ref_count--;
    if (strv->ref_count <= 0) {
        (lbs_strv_free_generic ((_Generic (((strv)), LbsStrv*: ((strv))))));
    }
}

canonical_original_code:
void lbs_strv_unref_generic(void *strv_generic) {
    if (strv_generic == ((void *)0)) {
        return;
    }
    struct LbsStrvStruct *strv = ((LbsStrv*)(strv_generic));
    strv->ref_count--;
    if (strv->ref_count <= 0) {
        (lbs_strv_free_generic ((_Generic (((strv)), struct LbsStrvStruct *: ((strv))))));
    }
}


decompiled_code:
char *__fastcall lbs_strv_dup_str(_QWORD *a1, __int64 a2)
{
__int64 v2; // rax
size_t v3; // rbx
const char *v4; // rbp
char *v5; // rax
char *result; // rax

v2 = *a1 + 48 * a2;
v3 = *(_QWORD *)(v2 + 24);
v4 = *(const char **)v2;
v5 = (char *)malloc(v3 + 1);
result = strncpy(v5, v4, v3);
result[v3] = 0;
return result;
}

canonical_decompiled_code:
char *__fastcall func5(_QWORD *a1, __int64 a2)
{
__int64 v2; // rax
size_t v3; // rbx
const char *v4; // rbp
char *v5; // rax
char *result; // rax

v2 = *a1 + 48 * a2;
v3 = *(_QWORD *)(v2 + 24);
v4 = *(const char **)v2;
v5 = (char *)malloc(v3 + 1);
result = strncpy(v5, v4, v3);
result[v3] = 0;
return result;
}

original_code:
char* lbs_strv_dup_str (LbsStrv* strv, size_t stri) {
    LbsArray* str_wrapper = (&((*(((LbsArray*)((&((strv)->array))->data))+((stri))))));
    size_t len = ((_Generic (((str_wrapper)), LbsArray*: ((str_wrapper))))->len);
    char* str = ((_Generic (((str_wrapper)), LbsArray*: ((str_wrapper))))->data);
    char* str_new = malloc (len + sizeof (char));
    strncpy (str_new, str, len);
    str_new[len] = '\0';
    return str_new;
}

canonical_original_code:
char *lbs_strv_dup_str(struct LbsStrvStruct *strv, unsigned long stri) {
    struct LbsArrayStruct *str_wrapper = (&((*(((LbsArray*)((&((strv)->array))->data))+((stri))))));
    unsigned long len = ((_Generic (((str_wrapper)), LbsArray*: ((str_wrapper))))->len);
    char *str = ((_Generic (((str_wrapper)), LbsArray*: ((str_wrapper))))->data);
    char *str_new = malloc (len + sizeof (char));
    strncpy (str_new, str, len);
    str_new[len] = '\0';
    return str_new;
}

variable_types:
stri
unsigned long


decompiled_code:
__int64 __fastcall lbs_strv_append_char(_QWORD *a1, unsigned __int64 a2, char a3)
{
unsigned __int64 v3; // rbp
char v5[4]; // [rsp+Ch] [rbp-4Ch] BYREF
char v6[72]; // [rsp+10h] [rbp-48h] BYREF

v5[0] = a3;
if ( a3 )
{
v3 = a1[3];
if ( v3 > a2 )
return lbs_array_append_data(*a1 + 48 * a2, v5);
if ( (int)lbs_array_init_with_max(v6, 1LL, 0LL) >= 0 )
{
if ( (int)lbs_array_append_data(a1, v6) >= 0 )
{
a2 = v3;
return lbs_array_append_data(*a1 + 48 * a2, v5);
}
lbs_array_unref_generic(v6);
}
}
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 __fastcall func6(_QWORD *a1, unsigned __int64 a2, char a3)
{
unsigned __int64 v3; // rbp
char v5[4]; // [rsp+Ch] [rbp-4Ch] BYREF
char v6[72]; // [rsp+10h] [rbp-48h] BYREF

v5[0] = a3;
if ( a3 )
{
v3 = a1[3];
if ( v3 > a2 )
return lbs_array_append_data(*a1 + 48 * a2, v5);
if ( (int)lbs_array_init_with_max(v6, 1LL, 0LL) >= 0 )
{
if ( (int)lbs_array_append_data(a1, v6) >= 0 )
{
a2 = v3;
return lbs_array_append_data(*a1 + 48 * a2, v5);
}
lbs_array_unref_generic(v6);
}
}
return 0xFFFFFFFFLL;
}

original_code:
int lbs_strv_append_char (LbsStrv* strv, size_t stri, char chr) {
    if (chr == '\0') {
        return -1;
    }
    if (stri >= (((_Generic (((&((_Generic (((strv)), LbsStrv*: ((strv))))->array))), LbsArray*: ((&((_Generic (((strv)), LbsStrv*: ((strv))))->array)))))->len))) {
        stri = (((_Generic (((&((_Generic (((strv)), LbsStrv*: ((strv))))->array))), LbsArray*: ((&((_Generic (((strv)), LbsStrv*: ((strv))))->array)))))->len));
        LbsArray str_struct;
        LbsArray* str = &str_struct;
        if ((lbs_array_init_with_max (str, sizeof (char), 0)) < 0) {
            return -1;
        }
        if (lbs_array_append_data (&strv->array, str) < 0) {
            (lbs_array_unref_generic ((_Generic (((str)), LbsArray*: ((str))))));
            return -1;
        }
    }
    LbsArray* str = (&((*(((LbsArray*)((&((strv)->array))->data))+((stri))))));
    return lbs_array_append_data (str, &chr);
}

canonical_original_code:
int lbs_strv_append_char(struct LbsStrvStruct *strv, unsigned long stri, char chr) {
    if (chr == '\0') {
        return -1;
    }
    if (stri >= (((_Generic (((&((_Generic (((strv)), struct LbsStrvStruct *: ((strv))))->array))), struct LbsArrayStruct *: ((&((_Generic (((strv)), struct LbsStrvStruct *: ((strv))))->array)))))->len))) {
        stri = (((_Generic (((&((_Generic (((strv)), struct LbsStrvStruct *: ((strv))))->array))), struct LbsArrayStruct *: ((&((_Generic (((strv)), struct LbsStrvStruct *: ((strv))))->array)))))->len));
        struct LbsArrayStruct str_struct;
        struct LbsArrayStruct *str = &str_struct;
        if ((lbs_array_init_with_max (str, sizeof (char), 0)) < 0) {
            return -1;
        }
        if (lbs_array_append_data (&strv->array, str) < 0) {
            (lbs_array_unref_generic ((_Generic (((str)), struct LbsArrayStruct *: ((str))))));
            return -1;
        }
    }
    struct LbsArrayStruct *str = (&((*(((LbsArray*)((&((strv)->array))->data))+((stri))))));
    return lbs_array_append_data (str, &chr);
}

variable_types: chr char

variable_types: struct LbsArrayStruct { void *data; void (*free_func)(void *data); unsigned long size; unsigned long len; unsigned long max; unsigned int ref_count; _Bool is_alloc; }


decompiled_code:
__int64 __fastcall lbs_strv_append_str_empty(__int64 a1)
{
_BYTE v2[56]; // [rsp+0h] [rbp-38h] BYREF

if ( (int)lbs_array_init_with_max(v2, 1LL, 0LL) < 0 )
return 0xFFFFFFFFLL;
if ( (int)lbs_array_append_data(a1, v2) >= 0 )
return 0LL;
lbs_array_unref_generic(v2);
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1)
{
_BYTE v2[56]; // [rsp+0h] [rbp-38h] BYREF

if ( (int)lbs_array_init_with_max(v2, 1LL, 0LL) < 0 )
return 0xFFFFFFFFLL;
if ( (int)lbs_array_append_data(a1, v2) >= 0 )
return 0LL;
lbs_array_unref_generic(v2);
return 0xFFFFFFFFLL;
}

original_code:
int lbs_strv_append_str_empty (LbsStrv* strv) {
    LbsArray str_struct, *str = &str_struct;
    if ((lbs_array_init_with_max (str, sizeof (char), 0)) < 0) {
        return -1;
    }
    if (lbs_array_append_data (&strv->array, &str_struct) < 0) {
        (lbs_array_unref_generic ((_Generic (((str)), LbsArray*: ((str))))));
        return -1;
    }
    return 0;
}

canonical_original_code:
int lbs_strv_append_str_empty(struct LbsStrvStruct *strv) {
    struct LbsArrayStruct str_struct; struct LbsArrayStruct *str = &str_struct;
    if ((lbs_array_init_with_max (str, sizeof (char), 0)) < 0) {
        return -1;
    }
    if (lbs_array_append_data (&strv->array, &str_struct) < 0) {
        (lbs_array_unref_generic ((_Generic (((str)), struct LbsArrayStruct *: ((str))))));
        return -1;
    }
    return 0;
}


decompiled_code:
__int64 __fastcall lbs_strv_append_str(__int64 a1, const char *a2)
{
size_t v2; // r12
char *v3; // rax
char *v4; // r13
_BYTE v6[88]; // [rsp-58h] [rbp-58h] BYREF

if ( !a2 )
return 0xFFFFFFFFLL;
v2 = strlen(a2);
v3 = (char *)malloc(v2);
v4 = v3;
if ( !v3 )
return 0xFFFFFFFFLL;
strncpy(v3, a2, v2);
if ( !lbs_array_make_struct(v6, 1LL, v2, v2, v4) )
{
LABEL_8:
free(v4);
return 0xFFFFFFFFLL;
}
if ( (int)lbs_array_append_data(a1, v6) < 0 )
{
lbs_array_unref_generic(v6);
goto LABEL_8;
}
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func8(__int64 a1, const char *a2)
{
size_t v2; // r12
char *v3; // rax
char *v4; // r13
_BYTE v6[88]; // [rsp-58h] [rbp-58h] BYREF

if ( !a2 )
return 0xFFFFFFFFLL;
v2 = strlen(a2);
v3 = (char *)malloc(v2);
v4 = v3;
if ( !v3 )
return 0xFFFFFFFFLL;
strncpy(v3, a2, v2);
if ( !lbs_array_make_struct(v6, 1LL, v2, v2, v4) )
{
LABEL_8:
free(v4);
return 0xFFFFFFFFLL;
}
if ( (int)lbs_array_append_data(a1, v6) < 0 )
{
lbs_array_unref_generic(v6);
goto LABEL_8;
}
return 0LL;
}

original_code:
int lbs_strv_append_str (LbsStrv* strv, const char* bstr) {
    if (bstr == ((void *)0)) {
        return -1;
    }
    size_t len = strlen (bstr);
    char* str_copy = malloc (sizeof (char) * len);
    if (str_copy == ((void *)0)) {
        return -1;
    }
    strncpy (str_copy, bstr, len);
    LbsArray str_struct, *str = &str_struct;
    if (lbs_array_make_struct (str, sizeof (char), len, len, str_copy) == ((void *)0))
    {
        free (str_copy);
        return -1;
    }
    if (lbs_array_append_data (&strv->array, &str_struct) < 0) {
        (lbs_array_unref_generic ((_Generic (((str)), LbsArray*: ((str))))));
        free (str_copy);
        return -1;
    }
    return 0;
}

canonical_original_code:
int lbs_strv_append_str(struct LbsStrvStruct *strv, char *bstr) {
    if (bstr == ((void *)0)) {
        return -1;
    }
    unsigned long len = strlen (bstr);
    char *str_copy = malloc (sizeof (char) * len);
    if (str_copy == ((void *)0)) {
        return -1;
    }
    strncpy (str_copy, bstr, len);
    struct LbsArrayStruct str_struct; struct LbsArrayStruct *str = &str_struct;
    if (lbs_array_make_struct (str, sizeof (char), len, len, str_copy) == ((void *)0))
    {
        free (str_copy);
        return -1;
    }
    if (lbs_array_append_data (&strv->array, &str_struct) < 0) {
        (lbs_array_unref_generic ((_Generic (((str)), struct LbsArrayStruct *: ((str))))));
        free (str_copy);
        return -1;
    }
    return 0;
}

variable_types:
bstr
char *


decompiled_code:
__int64 __fastcall lbs_strv_append_strv(__int64 a1, const char **a2)
{
const char **v2; // rbx
const char *v3; // rsi

if ( !a2 )
return 0xFFFFFFFFLL;
v2 = a2 + 1;
v3 = *a2;
if ( !v3 )
return 0LL;
while ( (int)lbs_strv_append_str(a1, v3) >= 0 )
{
v3 = *v2++;
if ( !v3 )
return 0LL;
}
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 __fastcall func9(__int64 a1, const char **a2)
{
const char **v2; // rbx
const char *v3; // rsi

if ( !a2 )
return 0xFFFFFFFFLL;
v2 = a2 + 1;
v3 = *a2;
if ( !v3 )
return 0LL;
while ( (int)func8(a1, v3) >= 0 )
{
v3 = *v2++;
if ( !v3 )
return 0LL;
}
return 0xFFFFFFFFLL;
}

original_code:
int lbs_strv_append_strv (LbsStrv* strv, const char* const* bstrv) {
    if (bstrv == ((void *)0)) {
        return -1;
    }
    int i;
    for (i = 0; bstrv[i] != ((void *)0); i++) {
        if (lbs_strv_append_str (strv, bstrv[i]) < 0) {
            return -1;
        }
    }
    return 0;
}

canonical_original_code:
int lbs_strv_append_strv(struct LbsStrvStruct *strv, char **bstrv) {
    if (bstrv == ((void *)0)) {
        return -1;
    }
    int i;
    for (i = 0; bstrv[i] != ((void *)0); i++) {
        if (lbs_strv_append_str (strv, bstrv[i]) < 0) {
            return -1;
        }
    }
    return 0;
}

variable_types:
bstrv
char **


decompiled_code:
__int64 __fastcall lbs_strv_remove_str(_QWORD *a1)
{
__int64 v1; // rax

v1 = a1[3];
if ( !v1 )
return 0xFFFFFFFFLL;
lbs_array_unref_generic(*a1 + 48 * v1 - 48);
return lbs_array_remove(a1);
}

canonical_decompiled_code:
__int64 __fastcall func10(_QWORD *a1)
{
__int64 v1; // rax

v1 = a1[3];
if ( !v1 )
return 0xFFFFFFFFLL;
lbs_array_unref_generic(*a1 + 48 * v1 - 48);
return lbs_array_remove(a1);
}

original_code:
int lbs_strv_remove_str (LbsStrv* strv) {
    size_t len = (((_Generic (((&((_Generic (((strv)), LbsStrv*: ((strv))))->array))), LbsArray*: ((&((_Generic (((strv)), LbsStrv*: ((strv))))->array)))))->len));
    if (len <= 0) {
        return -1;
    }
    (lbs_array_unref_generic ((_Generic ((((&((*(((LbsArray*)((&((strv)->array))->data))+((len - 1)))))))), LbsArray*: (((&((*(((LbsArray*)((&((strv)->array))->data))+((len - 1))))))))))));
    return lbs_array_remove (&strv->array);
}

canonical_original_code:
int lbs_strv_remove_str(struct LbsStrvStruct *strv) {
    unsigned long len = (((_Generic (((&((_Generic (((strv)), LbsStrv*: ((strv))))->array))), LbsArray*: ((&((_Generic (((strv)), LbsStrv*: ((strv))))->array)))))->len));
    if (len <= 0) {
        return -1;
    }
    (lbs_array_unref_generic ((_Generic ((((&((*(((struct LbsArrayStruct *)((&((strv)->array))->data))+((len - 1)))))))), struct LbsArrayStruct *: (((&((*(((struct LbsArrayStruct *)((&((strv)->array))->data))+((len - 1))))))))))));
    return lbs_array_remove (&strv->array);
}