// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x50, %rsp
movl %edi, -0x4(%rbp)
callq 0x1100
movl $0x2, %ecx
cltd
idivl %ecx
movl %edx, -0x8(%rbp)
movq $0x0, -0x10(%rbp)
movl $0x1, -0x14(%rbp)
xorl %eax, %eax
movl %eax, %ecx
leaq 0xbd2(%rip), %rsi       # 0x2037
movl $0x1, %edx
leaq 0xbcd(%rip), %r8        # 0x203e
leaq 0xc1c(%rip), %r9        # 0x2094
leaq 0x29f45(%rip), %r10     # 0x2b3c4
leaq -0x18(%rbp), %rax
movq %rcx, %rdi
movq $0x0, (%rsp)
movq %r10, 0x8(%rsp)
movq %rax, 0x10(%rsp)
callq 0x1050
movq %rax, -0x10(%rbp)
cmpq $0x0, %rax
jne 0x14d7
movq 0x2b42(%rip), %rax      # 0x3ff0
movq (%rax), %rax
movq %rax, -0x28(%rbp)
movl -0x18(%rbp), %edi
callq 0x10e0
movq -0x28(%rbp), %rdi
movq %rax, %rdx
leaq 0xb7c(%rip), %rsi       # 0x2047
movb $0x0, %al
callq 0x1110
jmp 0x15ec
movl -0x4(%rbp), %eax
movl %eax, -0x2c(%rbp)
testl %eax, %eax
je 0x14f0
jmp 0x14e3
movl -0x2c(%rbp), %eax
subl $0x1, %eax
je 0x154a
jmp 0x15a4
cmpl $0x0, -0x8(%rbp)
je 0x1520
movq -0x10(%rbp), %rdi
movl 0x86b0(%rip), %eax      # 0x9bb0
subl $0x2c, %eax
movl %eax, %eax
movl %eax, %edx
leaq 0x2ba2(%rip), %rsi      # 0x40b0
addq $0x2c, %rsi
leaq -0x18(%rbp), %rcx
callq 0x10a0
movl %eax, -0x1c(%rbp)
jmp 0x1548
movq -0x10(%rbp), %rdi
movl 0xc6e6(%rip), %eax      # 0xdc10
subl $0x2c, %eax
movl %eax, %eax
movl %eax, %edx
leaq 0x8688(%rip), %rsi      # 0x9bc0
addq $0x2c, %rsi
leaq -0x18(%rbp), %rcx
callq 0x10a0
movl %eax, -0x1c(%rbp)
jmp 0x15a6
cmpl $0x0, -0x8(%rbp)
je 0x157a
movq -0x10(%rbp), %rdi
movl 0x20bc6(%rip), %eax     # 0x22120
subl $0x2c, %eax
movl %eax, %eax
movl %eax, %edx
leaq 0xc6b8(%rip), %rsi      # 0xdc20
addq $0x2c, %rsi
leaq -0x18(%rbp), %rcx
callq 0x10a0
movl %eax, -0x1c(%rbp)
jmp 0x15a2
movq -0x10(%rbp), %rdi
movl 0x29e3c(%rip), %eax     # 0x2b3c0
subl $0x2c, %eax
movl %eax, %eax
movl %eax, %edx
leaq 0x20b9e(%rip), %rsi     # 0x22130
addq $0x2c, %rsi
leaq -0x18(%rbp), %rcx
callq 0x10a0
movl %eax, -0x1c(%rbp)
jmp 0x15a6
jmp 0x15a6
movq -0x10(%rbp), %rdi
leaq -0x18(%rbp), %rsi
callq 0x10d0
cmpl $0x0, %eax
jge 0x15e5
movq 0x2a31(%rip), %rax      # 0x3ff0
movq (%rax), %rax
movq %rax, -0x38(%rbp)
movl -0x18(%rbp), %edi
callq 0x10e0
movq -0x38(%rbp), %rdi
movq %rax, %rdx
leaq 0xa8f(%rip), %rsi       # 0x206b
movb $0x0, %al
callq 0x1110
jmp 0x15ec
movl $0x0, -0x14(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x15fc
movq -0x10(%rbp), %rdi
callq 0x1040
movl -0x14(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq