// File: /workspace/github_c_makefile_star2_O0/jonof[P]jfaudiolib/src/test.c
// Function: main
int main(int argc, char ** argv)
{
    int status = 0;
    int FXDevice = ASS_AutoDetect;
    int MusicDevice = ASS_AutoDetect;
    int NumVoices = 8;
    int NumChannels = 2;
    int NumBits = 16;
    int MixRate = 32000;
    int arg = 0;
    int loopstart = -1, loopend = -1;
    void * initdata = 0;
    const char * musicinit = 0;
    const char * song = "samples/test.wav";

    for (arg = 1; arg < argc; arg++) {
        if (argv[arg][0] == '-') {
            if (argv[arg][1] == 'h') {
                puts("test [options] [song]");
                puts("");
                puts("-h     This text.");
                puts("-l     List drivers.");
                puts("-fn    Set specific FX device (n = device number)");
                puts("-cn    Set 'n' FX output channels (1 or 2)");
                puts("-bn    Set 'n' FX output bits-per-sample (8 or 16)");
                puts("-sx    Set 'n' FX sample rate (8000 to 48000)");
                puts("-mn    Set specific Music device (n = device number)");
                puts("-M...  Specify music device parameter string");
                puts("-rx,y  Loop FX from samples x to y (0,-1 loops fully)");
                return 0;
            } else if (argv[arg][1] == 'l') {
                listdevs();
                return 0;
            } else if (argv[arg][1] == 'f') {
                FXDevice = atoi(argv[arg] + 2);
            } else if (argv[arg][1] == 'c') {
                NumChannels = atoi(argv[arg] + 2);
            } else if (argv[arg][1] == 'b') {
                NumBits = atoi(argv[arg] + 2);
            } else if (argv[arg][1] == 's') {
                MixRate = atoi(argv[arg] + 2);
            } else if (argv[arg][1] == 'm') {
                MusicDevice = atoi(argv[arg] + 2);
            } else if (argv[arg][1] == 'M') {
                musicinit = argv[arg] + 2;
            } else if (argv[arg][1] == 'r') {
                char *comma = NULL;
                loopstart = (int)strtol(argv[arg] + 2, &comma, 10);
                if (comma > argv[arg] + 2 && *comma == ',')
                    loopend = (int)strtol(comma + 1, NULL, 10);
                else
                    loopstart = -1;
            }
        } else {
            song = argv[arg];
        }
    }

    NumChannels = bound(1, NumChannels, 2);
    NumBits = bound(1, (NumBits >> 3), 2) << 3;
    MixRate = bound(8000, MixRate, 48000);

#ifdef _WIN32
    initdata = win_gethwnd();
#endif

    status = FX_Init( FXDevice, NumVoices, &NumChannels, &NumBits, &MixRate, initdata );
    if (status != FX_Ok) {
        fprintf(stderr, "FX_Init error %s\n", FX_ErrorString(status));
        return 1;
    }
    
    status = MUSIC_Init(MusicDevice, musicinit);
    if (status != MUSIC_Ok) {
        fprintf(stderr, "MUSIC_Init error %s\n", MUSIC_ErrorString(status));
        FX_Shutdown();
        return 1;
    }

    fprintf(stdout, "FX driver is %s\n", FX_GetCurrentDriverName());
    fprintf(stdout, "Music driver is %s\n", MUSIC_GetCurrentDriverName());
    fprintf(stdout, "Format is %dHz %d-bit %d-channel\n", MixRate, NumBits, NumChannels);

    playsong(song, loopstart, loopend);

    MUSIC_Shutdown();
    FX_Shutdown();

    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl $0x0, -0x14(%rbp)
movl $0xfffffffe, -0x18(%rbp) # imm = 0xFFFFFFFE
movl $0xfffffffe, -0x1c(%rbp) # imm = 0xFFFFFFFE
movl $0x8, -0x20(%rbp)
movl $0x2, -0x24(%rbp)
movl $0x10, -0x28(%rbp)
movl $0x7d00, -0x2c(%rbp)    # imm = 0x7D00
movl $0x0, -0x30(%rbp)
movl $0xffffffff, -0x34(%rbp) # imm = 0xFFFFFFFF
movl $0xffffffff, -0x38(%rbp) # imm = 0xFFFFFFFF
movq $0x0, -0x40(%rbp)
movq $0x0, -0x48(%rbp)
leaq 0xcabe(%rip), %rax      # 0xf004
movq %rax, -0x50(%rbp)
movl $0x1, -0x30(%rbp)
movl -0x30(%rbp), %eax
cmpl -0x8(%rbp), %eax
jge 0x2825
movq -0x10(%rbp), %rax
movslq -0x30(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbl (%rax), %eax
cmpl $0x2d, %eax
jne 0x2805
movq -0x10(%rbp), %rax
movslq -0x30(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbl 0x1(%rax), %eax
cmpl $0x68, %eax
jne 0x261e
leaq 0xca80(%rip), %rdi      # 0xf015
callq 0x2330
leaq 0xcd06(%rip), %rdi      # 0xf2a7
callq 0x2330
leaq 0xca7e(%rip), %rdi      # 0xf02b
callq 0x2330
leaq 0xca84(%rip), %rdi      # 0xf03d
callq 0x2330
leaq 0xca8d(%rip), %rdi      # 0xf052
callq 0x2330
leaq 0xcab3(%rip), %rdi      # 0xf084
callq 0x2330
leaq 0xcad2(%rip), %rdi      # 0xf0af
callq 0x2330
leaq 0xcaf9(%rip), %rdi      # 0xf0e2
callq 0x2330
leaq 0xcb1b(%rip), %rdi      # 0xf110
callq 0x2330
leaq 0xcb44(%rip), %rdi      # 0xf145
callq 0x2330
leaq 0xcb65(%rip), %rdi      # 0xf172
callq 0x2330
movl $0x0, -0x4(%rbp)
jmp 0x2a1b
movq -0x10(%rbp), %rax
movslq -0x30(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbl 0x1(%rax), %eax
cmpl $0x6c, %eax
jne 0x2644
callq 0x2a30
movl $0x0, -0x4(%rbp)
jmp 0x2a1b
movq -0x10(%rbp), %rax
movslq -0x30(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbl 0x1(%rax), %eax
cmpl $0x66, %eax
jne 0x2676
movq -0x10(%rbp), %rax
movslq -0x30(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
addq $0x2, %rdi
callq 0x2340
movl %eax, -0x18(%rbp)
jmp 0x27ff
movq -0x10(%rbp), %rax
movslq -0x30(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbl 0x1(%rax), %eax
cmpl $0x63, %eax
jne 0x26a8
movq -0x10(%rbp), %rax
movslq -0x30(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
addq $0x2, %rdi
callq 0x2340
movl %eax, -0x24(%rbp)
jmp 0x27fd
movq -0x10(%rbp), %rax
movslq -0x30(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbl 0x1(%rax), %eax
cmpl $0x62, %eax
jne 0x26da
movq -0x10(%rbp), %rax
movslq -0x30(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
addq $0x2, %rdi
callq 0x2340
movl %eax, -0x28(%rbp)
jmp 0x27fb
movq -0x10(%rbp), %rax
movslq -0x30(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbl 0x1(%rax), %eax
cmpl $0x73, %eax
jne 0x270c
movq -0x10(%rbp), %rax
movslq -0x30(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
addq $0x2, %rdi
callq 0x2340
movl %eax, -0x2c(%rbp)
jmp 0x27f9
movq -0x10(%rbp), %rax
movslq -0x30(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbl 0x1(%rax), %eax
cmpl $0x6d, %eax
jne 0x273e
movq -0x10(%rbp), %rax
movslq -0x30(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
addq $0x2, %rdi
callq 0x2340
movl %eax, -0x1c(%rbp)
jmp 0x27f7
movq -0x10(%rbp), %rax
movslq -0x30(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbl 0x1(%rax), %eax
cmpl $0x4d, %eax
jne 0x276c
movq -0x10(%rbp), %rax
movslq -0x30(%rbp), %rcx
movq (%rax,%rcx,8), %rax
addq $0x2, %rax
movq %rax, -0x48(%rbp)
jmp 0x27f5
movq -0x10(%rbp), %rax
movslq -0x30(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbl 0x1(%rax), %eax
cmpl $0x72, %eax
jne 0x27f3
movq $0x0, -0x58(%rbp)
movq -0x10(%rbp), %rax
movslq -0x30(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
addq $0x2, %rdi
leaq -0x58(%rbp), %rsi
movl $0xa, %edx
callq 0x22b0
movl %eax, -0x34(%rbp)
movq -0x58(%rbp), %rax
movq -0x10(%rbp), %rcx
movslq -0x30(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
addq $0x2, %rcx
cmpq %rcx, %rax
jbe 0x27ea
movq -0x58(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x2c, %eax
jne 0x27ea
movq -0x58(%rbp), %rdi
addq $0x1, %rdi
xorl %eax, %eax
movl %eax, %esi
movl $0xa, %edx
callq 0x22b0
movl %eax, -0x38(%rbp)
jmp 0x27f1
movl $0xffffffff, -0x34(%rbp) # imm = 0xFFFFFFFF
jmp 0x27f3
jmp 0x27f5
jmp 0x27f7
jmp 0x27f9
jmp 0x27fb
jmp 0x27fd
jmp 0x27ff
jmp 0x2801
jmp 0x2803
jmp 0x2815
movq -0x10(%rbp), %rax
movslq -0x30(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x50(%rbp)
jmp 0x2817
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x2551
cmpl $0x1, -0x24(%rbp)
jge 0x2835
movl $0x1, %eax
movl %eax, -0x5c(%rbp)
jmp 0x2851
cmpl $0x2, -0x24(%rbp)
jle 0x2845
movl $0x2, %eax
movl %eax, -0x60(%rbp)
jmp 0x284b
movl -0x24(%rbp), %eax
movl %eax, -0x60(%rbp)
movl -0x60(%rbp), %eax
movl %eax, -0x5c(%rbp)
movl -0x5c(%rbp), %eax
movl %eax, -0x24(%rbp)
movl -0x28(%rbp), %eax
sarl $0x3, %eax
cmpl $0x1, %eax
jge 0x286c
movl $0x1, %eax
movl %eax, -0x64(%rbp)
jmp 0x2890
movl -0x28(%rbp), %eax
sarl $0x3, %eax
cmpl $0x2, %eax
jle 0x2881
movl $0x2, %eax
movl %eax, -0x68(%rbp)
jmp 0x288a
movl -0x28(%rbp), %eax
sarl $0x3, %eax
movl %eax, -0x68(%rbp)
movl -0x68(%rbp), %eax
movl %eax, -0x64(%rbp)
movl -0x64(%rbp), %eax
shll $0x3, %eax
movl %eax, -0x28(%rbp)
cmpl $0x1f40, -0x2c(%rbp)    # imm = 0x1F40
jge 0x28ac
movl $0x1f40, %eax           # imm = 0x1F40
movl %eax, -0x6c(%rbp)
jmp 0x28cb
cmpl $0xbb80, -0x2c(%rbp)    # imm = 0xBB80
jle 0x28bf
movl $0xbb80, %eax           # imm = 0xBB80
movl %eax, -0x70(%rbp)
jmp 0x28c5
movl -0x2c(%rbp), %eax
movl %eax, -0x70(%rbp)
movl -0x70(%rbp), %eax
movl %eax, -0x6c(%rbp)
movl -0x6c(%rbp), %eax
movl %eax, -0x2c(%rbp)
movl -0x18(%rbp), %edi
movl -0x20(%rbp), %esi
movq -0x40(%rbp), %r9
leaq -0x24(%rbp), %rdx
leaq -0x28(%rbp), %rcx
leaq -0x2c(%rbp), %r8
callq 0x35a0
movl %eax, -0x14(%rbp)
cmpl $0x0, -0x14(%rbp)
je 0x292c
movq 0x126e4(%rip), %rax     # 0x14fe0
movq (%rax), %rax
movq %rax, -0x78(%rbp)
movl -0x14(%rbp), %edi
callq 0x3500
movq -0x78(%rbp), %rdi
movq %rax, %rdx
leaq 0xc88f(%rip), %rsi      # 0xf1a8
movb $0x0, %al
callq 0x22d0
movl $0x1, -0x4(%rbp)
jmp 0x2a1b
movl -0x1c(%rbp), %edi
movq -0x48(%rbp), %rsi
callq 0xa580
movl %eax, -0x14(%rbp)
cmpl $0x0, -0x14(%rbp)
je 0x297d
movq 0x12698(%rip), %rax     # 0x14fe0
movq (%rax), %rax
movq %rax, -0x80(%rbp)
movl -0x14(%rbp), %edi
callq 0xa4f0
movq -0x80(%rbp), %rdi
movq %rax, %rdx
leaq 0xc855(%rip), %rsi      # 0xf1ba
movb $0x0, %al
callq 0x22d0
callq 0x3700
movl $0x1, -0x4(%rbp)
jmp 0x2a1b
movq 0x12644(%rip), %rax     # 0x14fc8
movq (%rax), %rax
movq %rax, -0x90(%rbp)
callq 0x3770
movq -0x90(%rbp), %rdi
movq %rax, %rdx
leaq 0xc82b(%rip), %rsi      # 0xf1cf
movb $0x0, %al
callq 0x22d0
movq 0x12616(%rip), %rax     # 0x14fc8
movq (%rax), %rax
movq %rax, -0x88(%rbp)
callq 0xa700
movq -0x88(%rbp), %rdi
movq %rax, %rdx
leaq 0xc80e(%rip), %rsi      # 0xf1e0
movb $0x0, %al
callq 0x22d0
movq 0x125e8(%rip), %rax     # 0x14fc8
movq (%rax), %rdi
movl -0x2c(%rbp), %edx
movl -0x28(%rbp), %ecx
movl -0x24(%rbp), %r8d
leaq 0xc800(%rip), %rsi      # 0xf1f4
movb $0x0, %al
callq 0x22d0
movq -0x50(%rbp), %rdi
movl -0x34(%rbp), %esi
movl -0x38(%rbp), %edx
callq 0x2b00
callq 0xa6d0
callq 0x3700
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x90, %rsp
popq %rbp
retq
nopw (%rax,%rax)