// File: /workspace/github_c_makefile_star2_O3/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 0x2310
movq %rax, %r15
movq %rax, %rdi
movq %r14, %rsi
callq 0x2572
callq 0x2e9b
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, 0x620a(%rip)     # 0x8168
jne 0x1f64
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 0x1f8d
movl $0xac44, 0x4(%r12)      # imm = 0xAC44
leaq 0x307c(%rip), %rdx      # 0x5010
xorl %r13d, %r13d
movq -0x38(%rbp), %rdi
movq %r12, %rsi
xorl %ecx, %ecx
callq 0x3d5c
movq %r14, %rdi
callq 0x1170
testl %eax, %eax
jne 0x204a
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 0x1ffb
movl 0x20(%r12), %eax
addl %eax, %eax
subl %eax, %ecx
movl 0x6167(%rip), %esi      # 0x8168
cmpl $-0x1, %esi
je 0x2012
movl %r13d, %eax
cltd
idivl 0x34(%r15)
cmpl %esi, %edx
jne 0x2037
xorps %xmm0, %xmm0
cvtsi2sd %ecx, %xmm0
mulsd 0x614f(%rip), %xmm0     # 0x8170
cvttsd2si %xmm0, %edx
movq -0x38(%rbp), %rdi
leaq 0x3290(%rip), %rsi      # 0x52c0
xorl %eax, %eax
callq 0x1150
incl %r13d
movq %r14, %rdi
callq 0x1170
testl %eax, %eax
je 0x1fbc
leal -0x1(%r13), %eax
movl 0x34(%r15), %esi
cltd
idivl %esi
movl 0xc(%r12), %ecx
cmpl %ecx, %eax
jne 0x207d
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 0x5f74(%rip), %rax      # 0x7ff8
movq (%rax), %rdi
movl %r13d, %eax
cltd
idivl %esi
leaq 0x2f90(%rip), %rsi      # 0x5024
movl %ecx, %edx
movl %eax, %ecx
xorl %eax, %eax
callq 0x1150
jmp 0x205e
nopl (%rax)