// File: /workspace/github_c_makefile_star2_O2/floriangit[P]hdd_sound/disk.c
// Function: play
static int play(int mode) 
{
    int r = rand() % 2;
    static const pa_sample_spec ss = {
        .format = PA_SAMPLE_S16LE,
        .rate = 48000,
        .channels = 1
    };

    static pa_buffer_attr ba = {
	.maxlength = -1,
	.tlength = -1,
	.prebuf = -1,
	.minreq = -1,
	.fragsize = -1,
    };
 
    pa_simple *s = NULL;
    int ret = 1;
    int error;

    /* Create a new playback stream */
    if (!(s = pa_simple_new(NULL, "unused", PA_STREAM_PLAYBACK, NULL, "playback", &ss, NULL, &ba, &error))) {
        fprintf(stderr, __FILE__": pa_simple_new() failed: %s\n", pa_strerror(error));
        goto finish;
    }
 
    switch(mode) {
        int ret;
        case SHORT:
	    if(r) {
	        ret = pa_simple_write(s, (out_short_clean_wav + WAV_HEADER_LEN), out_short_clean_wav_len - WAV_HEADER_LEN, &error);
	    } else {
	        ret = pa_simple_write(s, (out2_short_clean_wav + WAV_HEADER_LEN), out2_short_clean_wav_len - WAV_HEADER_LEN, &error);
	    }
            break;
        case MEDIUM:
	    if(r) {
	        ret = pa_simple_write(s, (out_clean_wav + WAV_HEADER_LEN), out_clean_wav_len - WAV_HEADER_LEN, &error);
	    } else {
	        ret = pa_simple_write(s, (out_clean2_wav + WAV_HEADER_LEN), out_clean2_wav_len - WAV_HEADER_LEN, &error);
	    }
            break;
        default:
            break;
	if(ret < 0) {
            fprintf(stderr, __FILE__": pa_simple_write() failed: %s\n", pa_strerror(error));
            goto finish;
	}

    }
 
    /* Make sure that every single sample was played */
    if (pa_simple_drain(s, &error) < 0) {
        fprintf(stderr, __FILE__": pa_simple_drain() failed: %s\n", pa_strerror(error));
        goto finish;
    }
 
    ret = 0;
 
finish:
    if (s)
        pa_simple_free(s);
 
    return ret;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0x20, %rsp
movl %edi, %ebp
callq 0x10f0
movl %eax, %r14d
leaq 0x1c(%rsp), %rax
movq %rax, 0x10(%rsp)
andq $0x0, (%rsp)
leaq 0x2a05f(%rip), %rax     # 0x2b3b4
movq %rax, 0x8(%rsp)
leaq 0xcd6(%rip), %rsi       # 0x2037
leaq 0xcd6(%rip), %r8        # 0x203e
leaq 0xd25(%rip), %r9        # 0x2094
pushq $0x1
popq %rdx
xorl %edi, %edi
xorl %ecx, %ecx
callq 0x1050
testq %rax, %rax
je 0x1412
movq %rax, %rbx
testb $0x1, %r14b
leaq 0x884a(%rip), %rax      # 0x9bdc
leaq 0x2d33(%rip), %rcx      # 0x40cc
cmoveq %rax, %rcx
leaq 0x20da8(%rip), %rax     # 0x2214c
leaq 0xc891(%rip), %rsi      # 0xdc3c
cmoveq %rax, %rsi
leaq 0xc84a(%rip), %rax      # 0xdc00
leaq 0x87e3(%rip), %rdx      # 0x9ba0
cmoveq %rax, %rdx
leaq 0x29fe8(%rip), %rax     # 0x2b3b0
leaq 0x20d41(%rip), %rdi     # 0x22110
cmoveq %rax, %rdi
testl %ebp, %ebp
cmoveq %rcx, %rsi
cmoveq %rdx, %rdi
movl (%rdi), %edx
addl $-0x2c, %edx
leaq 0x1c(%rsp), %r14
movq %rbx, %rdi
movq %r14, %rcx
callq 0x10a0
movq %rbx, %rdi
movq %r14, %rsi
callq 0x10c0
testl %eax, %eax
js 0x143b
movq %rbx, %rdi
callq 0x1040
addq $0x20, %rsp
popq %rbx
popq %r14
popq %rbp
retq
movq 0x2bd7(%rip), %rax      # 0x3ff0
movq (%rax), %rbx
movl 0x1c(%rsp), %edi
callq 0x10d0
leaq 0xc1b(%rip), %rsi       # 0x2047
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x1100
jmp 0x1409
movq 0x2bae(%rip), %rax      # 0x3ff0
movq (%rax), %r14
movl 0x1c(%rsp), %edi
callq 0x10d0
leaq 0xc16(%rip), %rsi       # 0x206b
movq %r14, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x1100
jmp 0x1401