// File: /workspace/github_c_makefile_star2_O0/pipde[P]deos-songlib/lib/wave.c
// Function: readWaveFP
WAVE *
readWaveFP(FILE *in)
    {
    int i,j;
    WAVE *w;

    w = newWave();

    readWaveHeader(w,in);

    if (w->AudioFormat != 1)
        fprintf(stderr,"WARNING: Audio format is not PCM");

    //fprintf(stderr,"allocating %d samples for each of %d channels\n",
            //w->sampleCount,w->NumChannels);

    for (j = 0; j < w->NumChannels; ++j)
        w->channels[j] = (int *) newIntArray(w->sampleCount);

    for (i = 0; !feof(in) && i < w->sampleCount; ++i)
        for (j = 0; j < w->NumChannels; ++j)
            {
            int amp;
            amp = readByteInt(in,w->sampleWidth);
            if (amp >= w->maxAmp)
                amp = -2 * w->maxAmp + amp;
            //if (i < 1000) printf("read sample %d: %d\n", i, amp);
            w->channels[j][i] = amp;
            }

    //fprintf(stderr,"i is %d\n",i);
    if (i != w->sampleCount)
        {
        fprintf(stderr,"sample count mismatch, setting sample count to %d\n",
            i);
        setWaveSize(w,i);
        }

    fclose(in);

    //fprintf(stderr,"samples allocated\n");

    return w;
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
callq 0x21c0
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rdi
movq -0x8(%rbp), %rsi
callq 0x26c0
movq -0x18(%rbp), %rax
cmpl $0x1, 0x30(%rax)
je 0x2bd4
movq 0x4435(%rip), %rax      # 0x6ff8
movq (%rax), %rdi
leaq 0x1abb(%rip), %rsi      # 0x4688
movb $0x0, %al
callq 0x10d0
movl $0x0, -0x10(%rbp)
movl -0x10(%rbp), %eax
movq -0x18(%rbp), %rcx
cmpl 0x34(%rcx), %eax
jge 0x2c0e
movq -0x18(%rbp), %rax
movl 0x78(%rax), %edi
callq 0x2d10
movq %rax, %rdx
movq -0x18(%rbp), %rax
movslq -0x10(%rbp), %rcx
movq %rdx, 0x50(%rax,%rcx,8)
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0x2bdb
movl $0x0, -0xc(%rbp)
movq -0x8(%rbp), %rdi
callq 0x10e0
movl %eax, %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x1d(%rbp)
jne 0x2c3a
movl -0xc(%rbp), %eax
movq -0x18(%rbp), %rcx
cmpl 0x78(%rcx), %eax
setl %al
movb %al, -0x1d(%rbp)
movb -0x1d(%rbp), %al
testb $0x1, %al
jne 0x2c43
jmp 0x2cbe
movl $0x0, -0x10(%rbp)
movl -0x10(%rbp), %eax
movq -0x18(%rbp), %rcx
cmpl 0x34(%rcx), %eax
jge 0x2cae
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rax
movl 0x7c(%rax), %esi
callq 0x2a10
movl %eax, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
movq -0x18(%rbp), %rcx
cmpl 0x80(%rcx), %eax
jl 0x2c8c
movq -0x18(%rbp), %rax
imull $0xfffffffe, 0x80(%rax), %eax # imm = 0xFFFFFFFE
addl -0x1c(%rbp), %eax
movl %eax, -0x1c(%rbp)
movl -0x1c(%rbp), %edx
movq -0x18(%rbp), %rax
movslq -0x10(%rbp), %rcx
movq 0x50(%rax,%rcx,8), %rax
movslq -0xc(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0x2c4a
jmp 0x2cb0
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x2c15
movl -0xc(%rbp), %eax
movq -0x18(%rbp), %rcx
cmpl 0x78(%rcx), %eax
je 0x2cf1
movq 0x4327(%rip), %rax      # 0x6ff8
movq (%rax), %rdi
movl -0xc(%rbp), %edx
leaq 0x19cb(%rip), %rsi      # 0x46a9
movb $0x0, %al
callq 0x10d0
movq -0x18(%rbp), %rdi
movl -0xc(%rbp), %esi
callq 0x2d50
movq -0x8(%rbp), %rdi
callq 0x1080
movq -0x18(%rbp), %rax
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)