// File: /workspace/github_c_makefile_star2_O0/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
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
callq 0x1ec0
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rdi
movq -0x8(%rbp), %rsi
callq 0x23c0
callq 0x3540
movq %rax, -0x28(%rbp)
movq -0x20(%rbp), %rax
movl 0x38(%rax), %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0x4(%rax)
movq -0x20(%rbp), %rax
movl 0x78(%rax), %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0xc(%rax)
movq -0x20(%rbp), %rax
movl 0x44(%rax), %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0x8(%rax)
cmpl $-0x1, 0x7ac0(%rip)     # 0x9150
jne 0x16a1
movq -0x20(%rbp), %rax
movl 0x34(%rax), %ecx
movq -0x28(%rbp), %rax
movl %ecx, (%rax)
jmp 0x16ab
movq -0x28(%rbp), %rax
movl $0x1, (%rax)
movq -0x20(%rbp), %rcx
addq $0x50, %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x20(%rbp), %rax
movl 0x80(%rax), %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0x20(%rax)
movq -0x28(%rbp), %rax
cmpl $0x0, 0x4(%rax)
jne 0x16e1
movq -0x28(%rbp), %rax
movl $0xac44, 0x4(%rax)      # imm = 0xAC44
movq -0x10(%rbp), %rdi
movq -0x28(%rbp), %rsi
leaq 0x49e5(%rip), %rdx      # 0x60d5
xorl %eax, %eax
movl %eax, %ecx
callq 0x49e0
movl $0x0, -0x14(%rbp)
movq -0x8(%rbp), %rdi
callq 0x1140
cmpl $0x0, %eax
setne %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x171a
jmp 0x17a6
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rax
movl 0x8(%rax), %eax
movl $0x8, %ecx
cltd
idivl %ecx
movl %eax, %esi
callq 0x1960
movl %eax, -0x18(%rbp)
movl -0x18(%rbp), %eax
movq -0x20(%rbp), %rcx
cmpl 0x80(%rcx), %eax
jl 0x1757
movq -0x28(%rbp), %rax
imull $0xfffffffe, 0x20(%rax), %eax # imm = 0xFFFFFFFE
addl -0x18(%rbp), %eax
movl %eax, -0x18(%rbp)
cmpl $-0x1, 0x79f2(%rip)     # 0x9150
je 0x1773
movl -0x14(%rbp), %eax
movq -0x20(%rbp), %rcx
cltd
idivl 0x34(%rcx)
cmpl 0x79df(%rip), %edx      # 0x9150
jne 0x1796
movq -0x10(%rbp), %rdi
cvtsi2sdl -0x18(%rbp), %xmm0
mulsd 0x79d4(%rip), %xmm0     # 0x9158
cvttsd2si %xmm0, %edx
leaq 0x4b89(%rip), %rsi      # 0x6318
movb $0x0, %al
callq 0x1120
jmp 0x1798
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x1700
movl -0x14(%rbp), %eax
subl $0x1, %eax
movq -0x20(%rbp), %rcx
cltd
idivl 0x34(%rcx)
movq -0x28(%rbp), %rcx
cmpl 0xc(%rcx), %eax
je 0x17ef
movq 0x7834(%rip), %rax      # 0x8ff8
movq (%rax), %rdi
movq -0x28(%rbp), %rax
movl 0xc(%rax), %eax
movl %eax, -0x2c(%rbp)
movl -0x14(%rbp), %eax
movq -0x20(%rbp), %rcx
cltd
idivl 0x34(%rcx)
movl -0x2c(%rbp), %edx
movl %eax, %ecx
leaq 0x4901(%rip), %rsi      # 0x60e9
movb $0x0, %al
callq 0x1120
movq -0x8(%rbp), %rdi
callq 0x1080
movq -0x10(%rbp), %rdi
callq 0x1080
addq $0x30, %rsp
popq %rbp
retq
nopw (%rax,%rax)