// File: /workspace/github_c_makefile_star2_O3/waywardgeek[P]sonic/wave.c
// Function: openInputWaveFile
waveFile openInputWaveFile(const char* fileName, int* sampleRate, int* numChannels) {
  waveFile file;
  FILE* soundFile = fopen(fileName, "rb");

  if (soundFile == NULL) {
    fprintf(stderr, "Unable to open wave file %s for reading\n", fileName);
    return NULL;
  }
  file = (waveFile)calloc(1, sizeof(struct waveFileStruct));
  file->soundFile = soundFile;
  file->isInput = 1;
  if (!readHeader(file)) {
    closeFile(file);
    return NULL;
  }
  *sampleRate = file->sampleRate;
  *numChannels = file->numChannels;
  return file;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %r12
leaq 0xca8(%rip), %rsi       # 0x3532
callq 0x1140
testq %rax, %rax
je 0x2a80
movq %rax, %r13
movl $0x1, %edi
movl $0x20, %esi
callq 0x10a0
movq %rax, %rbx
movq %r13, 0x8(%rax)
movl $0x1, 0x18(%rax)
leaq 0xd0b(%rip), %rsi       # 0x35ca
movq %rax, %rdi
callq 0x2f18
leaq 0xe(%rsp), %rsi
movq %rbx, %rdi
movl $0x4, %edx
callq 0x2fa0
leaq 0xcef(%rip), %rsi       # 0x35cf
movq %rbx, %rdi
callq 0x2f18
leaq 0xce5(%rip), %rsi       # 0x35d4
movq %rbx, %rdi
callq 0x2f18
leaq 0xe(%rsp), %rsi
movq %rbx, %rdi
movl $0x4, %edx
callq 0x2fa0
xorl %ebp, %ebp
movl $0x4, %eax
movl %ebp, %ecx
shll $0x8, %ecx
movzbl 0xd(%rsp,%rax), %ebp
orl %ecx, %ebp
decq %rax
jne 0x2910
movl %ebp, %eax
andl $-0x3, %eax
cmpl $0x10, %eax
jne 0x2a9f
leaq 0xe(%rsp), %r12
movq %rbx, %rdi
movq %r12, %rsi
movl $0x2, %edx
callq 0x2fa0
movzwl (%r12), %edx
cmpl $0x1, %edx
jne 0x2aa6
leaq 0xe(%rsp), %r12
movq %rbx, %rdi
movq %r12, %rsi
movl $0x2, %edx
callq 0x2fa0
movzwl (%r12), %eax
movl %eax, (%rbx)
leaq 0xe(%rsp), %rsi
movq %rbx, %rdi
movl $0x4, %edx
callq 0x2fa0
xorl %eax, %eax
movl $0x4, %ecx
movl %eax, %edx
shll $0x8, %edx
movzbl 0xd(%rsp,%rcx), %eax
orl %edx, %eax
decq %rcx
jne 0x2987
movl %eax, 0x4(%rbx)
leaq 0xe(%rsp), %rsi
movq %rbx, %rdi
movl $0x4, %edx
callq 0x2fa0
leaq 0xe(%rsp), %rsi
movq %rbx, %rdi
movl $0x2, %edx
callq 0x2fa0
leaq 0xe(%rsp), %r12
movq %rbx, %rdi
movq %r12, %rsi
movl $0x2, %edx
callq 0x2fa0
cmpw $0x10, (%r12)
jne 0x2ac0
cmpl $0x12, %ebp
jne 0x29f7
leaq 0xe(%rsp), %rsi
movq %rbx, %rdi
movl $0x2, %edx
callq 0x2fa0
leaq 0xe(%rsp), %r12
movb $0x0, 0x4(%r12)
leaq 0x14(%rsp), %r13
movl $0x61746164, %ebp       # imm = 0x61746164
movq %rbx, %rdi
movq %r12, %rsi
movl $0x4, %edx
callq 0x2fa0
movq %rbx, %rdi
movq %r13, %rsi
movl $0x4, %edx
callq 0x2fa0
xorl %esi, %esi
movl $0x4, %eax
shll $0x8, %esi
movzbl 0x13(%rsp,%rax), %ecx
movslq %esi, %rsi
orq %rcx, %rsi
decq %rax
jne 0x2a33
movl 0xe(%rsp), %eax
xorl %ebp, %eax
movzbl 0x12(%rsp), %ecx
orl %eax, %ecx
je 0x2a73
movq 0x8(%rbx), %rdi
movl $0x1, %edx
callq 0x1110
testl %eax, %eax
je 0x2a0c
leaq 0xe(%rsp), %rdi
callq 0x11b8
jmp 0x2ac5
movl 0x4(%rbx), %eax
movl %eax, (%r15)
movl (%rbx), %eax
movl %eax, (%r14)
jmp 0x2acf
movq 0x3571(%rip), %rax      # 0x5ff8
movq (%rax), %rdi
leaq 0xaa4(%rip), %rsi       # 0x3535
xorl %ebx, %ebx
movq %r12, %rdx
xorl %eax, %eax
callq 0x10c0
jmp 0x2acf
callq 0x1180
jmp 0x2ac5
movq 0x354b(%rip), %rax      # 0x5ff8
movq (%rax), %rdi
leaq 0xb47(%rip), %rsi       # 0x35fe
xorl %eax, %eax
callq 0x10c0
jmp 0x2ac5
callq 0x119c
movq %rbx, %rdi
callq 0x2ae1
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq