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

    if (in == 0) return 0;

    w = newWave();

    readWaveHeader(w,in);

    if (w->AudioFormat != 1)
        Fatal("PCM only (no compression)");

    fprintf(stderr,"allocating %d samples\n",w->sampleCount);

    w->channels[0] = (int *) newIntArray(w->sampleCount);

    for (i = 0; !feof(in) && i < w->sampleCount; ++i)
        {
        int total = 0;
        for (j = 0; j < w->NumChannels; ++j)
            {
            int amp;
            amp = readByteInt(in,w->sampleWidth);
            if (amp >= w->maxAmp)
                amp = -2 * w->maxAmp + amp;
            total += amp;
            }
        w->channels[0][i] = total;
        }

    if (i != w->sampleCount)
        setWaveSize(w,i);

    if (w->NumChannels != 1)
        {
        fprintf(stderr,"WAVE WARNING: converting to mono\n");
        w->NumChannels = 1;
        setWaveSize(w,w->sampleCount);
        }

    fclose(in);

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

    return w;
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x2e40
movq $0x0, -0x8(%rbp)
jmp 0x2fde
callq 0x21c0
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x26c0
movq -0x20(%rbp), %rax
cmpl $0x1, 0x30(%rax)
je 0x2e6e
leaq 0x1875(%rip), %rdi      # 0x46dc
movb $0x0, %al
callq 0x1ca0
movq 0x4183(%rip), %rax      # 0x6ff8
movq (%rax), %rdi
movq -0x20(%rbp), %rax
movl 0x78(%rax), %edx
leaq 0x1870(%rip), %rsi      # 0x46f6
movb $0x0, %al
callq 0x10d0
movq -0x20(%rbp), %rax
movl 0x78(%rax), %edi
callq 0x2d10
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x50(%rax)
movl $0x0, -0x14(%rbp)
movq -0x10(%rbp), %rdi
callq 0x10e0
movl %eax, %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x29(%rbp)
jne 0x2ed0
movl -0x14(%rbp), %eax
movq -0x20(%rbp), %rcx
cmpl 0x78(%rcx), %eax
setl %al
movb %al, -0x29(%rbp)
movb -0x29(%rbp), %al
testb $0x1, %al
jne 0x2edc
jmp 0x2f60
movl $0x0, -0x24(%rbp)
movl $0x0, -0x18(%rbp)
movl -0x18(%rbp), %eax
movq -0x20(%rbp), %rcx
cmpl 0x34(%rcx), %eax
jge 0x2f40
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rax
movl 0x7c(%rax), %esi
callq 0x2a10
movl %eax, -0x28(%rbp)
movl -0x28(%rbp), %eax
movq -0x20(%rbp), %rcx
cmpl 0x80(%rcx), %eax
jl 0x2f2c
movq -0x20(%rbp), %rax
imull $0xfffffffe, 0x80(%rax), %eax # imm = 0xFFFFFFFE
addl -0x28(%rbp), %eax
movl %eax, -0x28(%rbp)
movl -0x28(%rbp), %eax
addl -0x24(%rbp), %eax
movl %eax, -0x24(%rbp)
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x2eea
movl -0x24(%rbp), %edx
movq -0x20(%rbp), %rax
movq 0x50(%rax), %rax
movslq -0x14(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x2eab
movl -0x14(%rbp), %eax
movq -0x20(%rbp), %rcx
cmpl 0x78(%rcx), %eax
je 0x2f78
movq -0x20(%rbp), %rdi
movl -0x14(%rbp), %esi
callq 0x2d50
movq -0x20(%rbp), %rax
cmpl $0x1, 0x34(%rax)
je 0x2fb5
movq 0x406f(%rip), %rax      # 0x6ff8
movq (%rax), %rdi
leaq 0x177a(%rip), %rsi      # 0x470d
movb $0x0, %al
callq 0x10d0
movq -0x20(%rbp), %rax
movl $0x1, 0x34(%rax)
movq -0x20(%rbp), %rdi
movq -0x20(%rbp), %rax
movl 0x78(%rax), %esi
callq 0x2d50
movq -0x10(%rbp), %rdi
callq 0x1080
movq 0x4033(%rip), %rax      # 0x6ff8
movq (%rax), %rdi
leaq 0x1760(%rip), %rsi      # 0x472f
movb $0x0, %al
callq 0x10d0
movq -0x20(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax,%rax)