// File: /workspace/github_c_makefile_star2_O1/pipde[P]deos-songlib/utils/rra/wav2rra.c
// Function: filter
static void
filter(FILE *in,FILE *out)
    {
    int i,amp;
    WAVE *w;
    RRA *h;

    w = newWave();
    //printf("reading wave header...\n");
    readWaveHeader(w,in);
    //printf("wave header read.\n");

    h = newRRAHeader();

    h->sampleRate = w->SampleRate;
    h->samples = w->sampleCount;
    //fprintf(stderr,"%d samples in wav\n",w->sampleCount);
    h->bitsPerSample = w->BitsPerSample;
    if (Track == -1)
        h->channels = w->NumChannels;
    else
        h->channels = 1;
    h->data = w->channels;
    h->maxAmp = w->maxAmp;

    if (h->sampleRate == 0) h->sampleRate = 44100;

    writeRRAHeader(out,h,"modifiedBy: wav2rra",0);

    for (i = 0; !feof(in); ++i)
        {
        amp = readByteInt(in,h->bitsPerSample/8);
        if (amp >= w->maxAmp)
            amp = -2 * h->maxAmp + amp;

        if (Track == -1 || i % w->NumChannels == Track)
            fprintf(out,"%d\n",(int)(amp * Attenuation));
        }

    if ((i - 1) / w->NumChannels != h->samples)
        fprintf(stderr,"WARNING: %d samples expected, %d found\n",
            h->samples, i / w->NumChannels);

    fclose(in);
    fclose(out);
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, -0x38(%rbp)
movq %rdi, %r14
callq 0x230c
movq %rax, %r15
movq %rax, %rdi
movq %r14, %rsi
callq 0x25d5
callq 0x2f1f
movq %rax, %r12
movl 0x38(%r15), %eax
movl %eax, 0x4(%r12)
movl 0x78(%r15), %ecx
movl %ecx, 0xc(%r12)
movl 0x44(%r15), %ecx
movl %ecx, 0x8(%r12)
movl $0x1, %ecx
cmpl $-0x1, 0x621a(%rip)     # 0x8168
jne 0x1f54
movl 0x34(%r15), %ecx
movl %ecx, (%r12)
movq %r15, %rcx
addq $0x50, %rcx
movq %rcx, 0x18(%r12)
movl 0x80(%r15), %ecx
movl %ecx, 0x20(%r12)
testl %eax, %eax
jne 0x1f7d
movl $0xac44, 0x4(%r12)      # imm = 0xAC44
leaq 0x308c(%rip), %rdx      # 0x5010
xorl %r13d, %r13d
movq -0x38(%rbp), %rdi
movq %r12, %rsi
xorl %ecx, %ecx
callq 0x3d7d
movq %r14, %rdi
callq 0x1170
testl %eax, %eax
jne 0x203a
leaq -0x2c(%rbp), %rbx
xorl %r13d, %r13d
movl 0x8(%r12), %eax
leal 0x7(%rax), %ecx
testl %eax, %eax
cmovnsl %eax, %ecx
sarl $0x3, %ecx
movl $0x0, -0x2c(%rbp)
movslq %ecx, %rdx
movl $0x1, %esi
movq %rbx, %rdi
movq %r14, %rcx
callq 0x1080
movl -0x2c(%rbp), %ecx
cmpl 0x80(%r15), %ecx
jl 0x1feb
movl 0x20(%r12), %eax
addl %eax, %eax
subl %eax, %ecx
movl 0x6177(%rip), %esi      # 0x8168
cmpl $-0x1, %esi
je 0x2002
movl %r13d, %eax
cltd
idivl 0x34(%r15)
cmpl %esi, %edx
jne 0x2027
xorps %xmm0, %xmm0
cvtsi2sd %ecx, %xmm0
mulsd 0x615f(%rip), %xmm0     # 0x8170
cvttsd2si %xmm0, %edx
movq -0x38(%rbp), %rdi
leaq 0x3288(%rip), %rsi      # 0x52a8
xorl %eax, %eax
callq 0x1150
incl %r13d
movq %r14, %rdi
callq 0x1170
testl %eax, %eax
je 0x1fac
leal -0x1(%r13), %eax
movl 0x34(%r15), %esi
cltd
idivl %esi
movl 0xc(%r12), %ecx
cmpl %ecx, %eax
jne 0x206d
movq %r14, %rdi
callq 0x10a0
movq -0x38(%rbp), %rdi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x10a0
movq 0x5f84(%rip), %rax      # 0x7ff8
movq (%rax), %rdi
movl %r13d, %eax
cltd
idivl %esi
leaq 0x2fa0(%rip), %rsi      # 0x5024
movl %ecx, %edx
movl %eax, %ecx
xorl %eax, %eax
callq 0x1150
jmp 0x204e
nopl (%rax)