// File: /workspace/github_c_makefile_star2_O1/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 0x1bac(%rip), %rsi      # 0x4502
callq 0x1140
testq %rax, %rax
je 0x2b9a
movq %rax, %r13
movl $0x1, %edi
movl $0x20, %esi
callq 0x10a0
movq %rax, %rbx
movq %r13, 0x8(%rax)
movl $0x1, 0x18(%rax)
leaq 0x1c0f(%rip), %rsi      # 0x459a
movq %rax, %rdi
callq 0x306d
leaq 0x7(%rsp), %rsi
movq %rbx, %rdi
movl $0x4, %edx
callq 0x30f5
leaq 0x1bf3(%rip), %rsi      # 0x459f
movq %rbx, %rdi
callq 0x306d
leaq 0x1be9(%rip), %rsi      # 0x45a4
movq %rbx, %rdi
callq 0x306d
leaq 0x7(%rsp), %rsi
movq %rbx, %rdi
movl $0x4, %edx
callq 0x30f5
xorl %ebp, %ebp
movl $0x4, %eax
movl %ebp, %ecx
shll $0x8, %ecx
movzbl 0x6(%rsp,%rax), %ebp
orl %ecx, %ebp
decq %rax
jne 0x29dc
movl %ebp, %eax
andl $-0x3, %eax
cmpl $0x10, %eax
jne 0x2bb9
leaq 0x7(%rsp), %rsi
movq %rbx, %rdi
movl $0x2, %edx
callq 0x30f5
xorl %edx, %edx
movl $0x2, %eax
movl %edx, %ecx
shll $0x8, %ecx
movzbl 0x6(%rsp,%rax), %edx
orl %ecx, %edx
decq %rax
jne 0x2a14
cmpl $0x1, %edx
jne 0x2bc0
leaq 0x7(%rsp), %rsi
movq %rbx, %rdi
movl $0x2, %edx
callq 0x30f5
xorl %eax, %eax
movl $0x2, %ecx
movl %eax, %edx
shll $0x8, %edx
movzbl 0x6(%rsp,%rcx), %eax
orl %edx, %eax
decq %rcx
jne 0x2a47
movl %eax, (%rbx)
leaq 0x7(%rsp), %rsi
movq %rbx, %rdi
movl $0x4, %edx
callq 0x30f5
xorl %eax, %eax
movl $0x4, %ecx
movl %eax, %edx
shll $0x8, %edx
movzbl 0x6(%rsp,%rcx), %eax
orl %edx, %eax
decq %rcx
jne 0x2a73
movl %eax, 0x4(%rbx)
leaq 0x7(%rsp), %rsi
movq %rbx, %rdi
movl $0x4, %edx
callq 0x30f5
leaq 0x7(%rsp), %rsi
movq %rbx, %rdi
movl $0x2, %edx
callq 0x30f5
leaq 0x7(%rsp), %rsi
movq %rbx, %rdi
movl $0x2, %edx
callq 0x30f5
xorl %eax, %eax
movl $0x2, %ecx
movl %eax, %edx
shll $0x8, %edx
movzbl 0x6(%rsp,%rcx), %eax
orl %edx, %eax
decq %rcx
jne 0x2ac4
cmpl $0x10, %eax
jne 0x2bda
movq %r14, 0x10(%rsp)
cmpl $0x12, %ebp
jne 0x2afa
leaq 0x7(%rsp), %rsi
movq %rbx, %rdi
movl $0x2, %edx
callq 0x30f5
leaq 0x7(%rsp), %r12
movb $0x0, 0x4(%r12)
leaq 0xc(%rsp), %r13
movl $0x61746164, %ebp       # imm = 0x61746164
movq %rbx, %rdi
movq %r12, %rsi
movl $0x4, %edx
callq 0x30f5
movq %rbx, %rdi
movq %r13, %rsi
movl $0x4, %edx
callq 0x30f5
xorl %esi, %esi
movl $0x4, %eax
shll $0x8, %esi
movzbl 0xb(%rsp,%rax), %ecx
movslq %esi, %rsi
orq %rcx, %rsi
decq %rax
jne 0x2b36
movl 0x7(%rsp), %eax
xorl %ebp, %eax
movzbl 0xb(%rsp), %ecx
orl %eax, %ecx
je 0x2b78
movq 0x8(%rbx), %rdi
movl $0x1, %edx
callq 0x1110
movb $0x1, %cl
testl %eax, %eax
je 0x2b80
callq 0x11b8
xorl %ecx, %ecx
xorl %r14d, %r14d
jmp 0x2b80
movl $0x1, %r14d
xorl %ecx, %ecx
testb %cl, %cl
jne 0x2b0f
testl %r14d, %r14d
je 0x2bdf
movl 0x4(%rbx), %eax
movl %eax, (%r15)
movl (%rbx), %eax
movq 0x10(%rsp), %rcx
movl %eax, (%rcx)
jmp 0x2be9
movq 0x4457(%rip), %rax      # 0x6ff8
movq (%rax), %rdi
leaq 0x195a(%rip), %rsi      # 0x4505
xorl %ebx, %ebx
movq %r12, %rdx
xorl %eax, %eax
callq 0x10c0
jmp 0x2be9
callq 0x1180
jmp 0x2bdf
movq 0x4431(%rip), %rax      # 0x6ff8
movq (%rax), %rdi
leaq 0x19fd(%rip), %rsi      # 0x45ce
xorl %eax, %eax
callq 0x10c0
jmp 0x2bdf
callq 0x119c
movq %rbx, %rdi
callq 0x2bfb
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq