// File: /workspace/github_c_makefile_star2_O3/pipde[P]deos-songlib/utils/filter/iir.c
// Function: main
int
main(int argc,char **argv)
    {
    int argIndex = 1;

    int i,j;
    double max;
    FILE *in,*out;
    RRA *h;

    argIndex = processOptions(argc,argv);

    if (argc-argIndex == 0)
        {
        in = stdin;
        out = stdout;
        }
    else if (argc-argIndex == 1)
        {
        in = OpenFile(argv[argIndex],"r");
        out = stdout;
        }
    else if (argc-argIndex == 2)
        {
        in = OpenFile(argv[argIndex],"r");
        out = OpenFile(argv[argIndex+1],"w");
        }
    else
        {
        fprintf(stderr,"usage: flanger -h -a<N.M> -w<N.M> -d<N.M> -l<N.M> "
            "[<input rra file> [<output rra file>]]\n");
        exit(-1);
        }

    readCoefficients(coefficientFile);
    fprintf(stderr,"feedforward taps: %d\n",feedforwardTaps);
    fprintf(stderr,"feedback taps: %d\n",feedbackTaps);
    fprintf(stderr,"filter attenuation is %f\n",attenuation);

    h = newRRAHeader();
    
    readRRAHeader(in,h,0);

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

    max = pow(2,h->bitsPerSample - 1) - 1;

    input = (double **) New(sizeof(double *) * h->channels);
    output = (double **) New(sizeof(double *) * h->channels);

    for (i = 0; i < h->channels; ++i)
        {
        input[i] = (double *) New(sizeof(double) * h->samples);
        output[i] = (double *) New(sizeof(double) * h->samples);
        }

    for ( i = 0; i < h->samples; ++i)
        for (j = 0; j < h->channels; ++j)
            {
            int amp = readRRAAmplitude(in,out,h->bitsPerSample,outputComment);
            input[j][i] = (amp / max) / gain;
            output[j][i] = iirFilter(j,i);
            //fprintf(out,"original: %d\n", amp);
            //fprintf(out,"original: %f\n", input[j][i]);
            fprintf(out,"%f\n", attenuation * output[j][i]);
            }

    fclose(in);
    fclose(out);

    return 0;
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rsi, %r14
movl %edi, %ebx
movl $0x1, %r12d
cmpl $0x2, %edi
jl 0x16a7
movl $0x1, %r12d
movslq %r12d, %rax
movq (%r14,%rax,8), %rsi
cmpb $0x2d, (%rsi)
jne 0x16a7
movb 0x2(%rsi), %r13b
testb %r13b, %r13b
je 0x1636
leaq 0x2(%rsi), %rdi
jmp 0x163b
movq 0x8(%r14,%rax,8), %rdi
movzbl 0x1(%rsi), %eax
cmpl $0x65, %eax
jle 0x1652
cmpl $0x66, %eax
jne 0x1669
movq %rdi, 0x5b08(%rip)      # 0x7158
jmp 0x1664
cmpl $0x61, %eax
jne 0x167b
callq 0x1090
movsd %xmm0, 0x5afc(%rip)     # 0x7160
movb $0x1, %r15b
jmp 0x168c
cmpl $0x68, %eax
je 0x1ba9
cmpl $0x76, %eax
je 0x1b8b
xorl %r15d, %r15d
leaq 0x2af0(%rip), %rdi      # 0x4175
xorl %eax, %eax
callq 0x1bd0
testb %r13b, %r13b
sete %al
andb %r15b, %al
movzbl %al, %eax
addl %eax, %r12d
incl %r12d
cmpl %ebx, %r12d
jl 0x1617
subl %r12d, %ebx
jne 0x16b8
movq 0x5925(%rip), %rax      # 0x6fd8
movq (%rax), %rax
jmp 0x16d9
cmpl $0x2, %ebx
je 0x16e9
cmpl $0x1, %ebx
jne 0x1bc8
movslq %r12d, %rax
movq (%r14,%rax,8), %rdi
leaq 0x2f56(%rip), %rsi      # 0x462a
callq 0x1c6a
movq %rax, -0x30(%rbp)
movq 0x58ec(%rip), %rax      # 0x6fd0
movq (%rax), %r14
jmp 0x1714
movslq %r12d, %rbx
movq (%r14,%rbx,8), %rdi
leaq 0x2f33(%rip), %rsi      # 0x462a
callq 0x1c6a
movq %rax, -0x30(%rbp)
movq 0x8(%r14,%rbx,8), %rdi
leaq 0x291e(%rip), %rsi      # 0x402a
callq 0x1c6a
movq %rax, %r14
movq 0x5a3d(%rip), %rbx      # 0x7158
movq 0x58d6(%rip), %rax      # 0x6ff8
movq (%rax), %rdi
leaq 0x29ad(%rip), %rsi      # 0x40d9
movq %rbx, %rdx
xorl %eax, %eax
callq 0x1150
leaq 0x2eed(%rip), %rsi      # 0x462a
movq %rbx, %rdi
callq 0x1c6a
movq %rax, %r15
movq $0x0, 0x9a5d(%rip) # 0xb1b0
movl $0x0, 0x5a33(%rip)      # 0x7190
leaq 0x298f(%rip), %rbx      # 0x40f3
leaq 0x59e5(%rip), %rdx      # 0x7150
movq %rax, %rdi
movq %rbx, %rsi
xorl %eax, %eax
callq 0x1070
leaq -0x38(%rbp), %rdx
movq %r15, %rdi
movq %rbx, %rsi
xorl %eax, %eax
callq 0x1070
movq %r15, %rdi
callq 0x1170
testl %eax, %eax
jne 0x183f
leaq 0x2953(%rip), %r13      # 0x40f3
leaq -0x38(%rbp), %r12
movl 0x59e6(%rip), %eax      # 0x7190
cmpl $0x400, %eax            # imm = 0x400
jl 0x17c5
leaq 0x2940(%rip), %rdi      # 0x40f8
xorl %eax, %eax
callq 0x1bd0
movl 0x59cb(%rip), %eax      # 0x7190
movsd -0x38(%rbp), %xmm0
cltq
leaq 0x59dd(%rip), %rcx      # 0x71b0
movsd %xmm0, (%rcx,%rax,8)
addsd 0x99d0(%rip), %xmm0     # 0xb1b0
movsd %xmm0, 0x99c8(%rip)     # 0xb1b0
incl %eax
movl %eax, 0x59a0(%rip)      # 0x7190
movq %r15, %rdi
callq 0x10f0
movl %eax, %ebx
testl %eax, %eax
je 0x1815
callq 0x1250
movq (%rax), %rax
movslq %ebx, %rcx
testb $0x20, 0x1(%rax,%rcx,2)
jne 0x17f0
cmpl $0x25, %ebx
je 0x183f
movl %ebx, %edi
movq %r15, %rsi
callq 0x11a0
movq %r15, %rdi
movq %r13, %rsi
movq %r12, %rdx
xorl %eax, %eax
callq 0x1070
movq %r15, %rdi
callq 0x1170
testl %eax, %eax
je 0x17a4
movq 0x57b2(%rip), %rax      # 0x6ff8
movq (%rax), %rdi
movsd 0x995f(%rip), %xmm0     # 0xb1b0
leaq 0x28bd(%rip), %rsi      # 0x4115
movb $0x1, %al
callq 0x1150
movq $0x0, 0x9946(%rip) # 0xb1b0
movl $0x0, 0x5920(%rip)      # 0x7194
leaq 0x2878(%rip), %rsi      # 0x40f3
leaq -0x38(%rbp), %rdx
movq %r15, %rdi
xorl %eax, %eax
callq 0x1070
movq %r15, %rdi
callq 0x1170
leaq 0x7918(%rip), %r12      # 0x91b0
testl %eax, %eax
jne 0x1909
leaq 0x2850(%rip), %r13      # 0x40f3
leaq -0x38(%rbp), %rbx
movl 0x58e7(%rip), %eax      # 0x7194
cmpl $0x400, %eax            # imm = 0x400
jl 0x18c8
leaq 0x283d(%rip), %rdi      # 0x40f8
xorl %eax, %eax
callq 0x1bd0
movl 0x58cc(%rip), %eax      # 0x7194
movsd -0x38(%rbp), %xmm0
cltq
movsd %xmm0, (%r12,%rax,8)
addsd 0x98d3(%rip), %xmm0     # 0xb1b0
movsd %xmm0, 0x98cb(%rip)     # 0xb1b0
incl %eax
movl %eax, 0x58a7(%rip)      # 0x7194
movq %r15, %rdi
movq %r13, %rsi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x1070
movq %r15, %rdi
callq 0x1170
testl %eax, %eax
je 0x18a7
movq 0x56e8(%rip), %rbx      # 0x6ff8
movq (%rbx), %rdi
movsd 0x9895(%rip), %xmm0     # 0xb1b0
leaq 0x281d(%rip), %rsi      # 0x413f
movb $0x1, %al
callq 0x1150
movq (%rbx), %rdi
movl 0x585e(%rip), %edx      # 0x7190
leaq 0x274d(%rip), %rsi      # 0x4086
xorl %eax, %eax
callq 0x1150
movq (%rbx), %rdi
movl 0x584b(%rip), %edx      # 0x7194
leaq 0x274c(%rip), %rsi      # 0x409c
xorl %eax, %eax
callq 0x1150
movq (%rbx), %rdi
movsd 0x57fe(%rip), %xmm0     # 0x7160
leaq 0x2746(%rip), %rsi      # 0x40af
movb $0x1, %al
callq 0x1150
callq 0x1edb
movq %rax, %rbx
movq -0x30(%rbp), %rdi
movq %rax, %rsi
xorl %edx, %edx
callq 0x2301
leaq 0x273c(%rip), %rdx      # 0x40c9
movq %r14, %rdi
movq %rbx, %rsi
xorl %ecx, %ecx
callq 0x2d9c
movl 0x8(%rbx), %edi
decl %edi
movsd 0x2661(%rip), %xmm0     # 0x4008
callq 0x1050
movsd %xmm0, -0x48(%rbp)
movl (%rbx), %edi
shll $0x3, %edi
callq 0x1cef
movq %rax, 0x57d6(%rip)      # 0x7198
movl (%rbx), %edi
shll $0x3, %edi
callq 0x1cef
movq %rbx, %rsi
movq %rax, 0x57ca(%rip)      # 0x71a0
movl (%rbx), %eax
testl %eax, %eax
movq %rbx, -0x58(%rbp)
jle 0x1a21
xorl %ebx, %ebx
movl 0xc(%rsi), %edi
shll $0x3, %edi
callq 0x1cef
movq 0x57a4(%rip), %rcx      # 0x7198
movq %rax, (%rcx,%rbx,8)
movq -0x58(%rbp), %rax
movl 0xc(%rax), %edi
shll $0x3, %edi
callq 0x1cef
movq -0x58(%rbp), %rsi
movq 0x578e(%rip), %rcx      # 0x71a0
movq %rax, (%rcx,%rbx,8)
incq %rbx
movslq (%rsi), %rax
cmpq %rax, %rbx
jl 0x19e2
movq %r14, -0x50(%rbp)
movl 0xc(%rsi), %ecx
testl %ecx, %ecx
jle 0x1b68
movsd -0x48(%rbp), %xmm0
addsd 0x25d3(%rip), %xmm0     # 0x4010
movsd %xmm0, -0x48(%rbp)
movl $0xffffffff, -0x3c(%rbp) # imm = 0xFFFFFFFF
xorl %r13d, %r13d
xorl %r14d, %r14d
testl %eax, %eax
jle 0x1b56
xorl %ebx, %ebx
movq -0x50(%rbp), %r15
movl 0x8(%rsi), %edx
movq -0x30(%rbp), %rdi
movq %r15, %rsi
leaq 0x15f9(%rip), %rcx      # 0x3067
callq 0x2804
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
divsd -0x48(%rbp), %xmm0
divsd 0x56c9(%rip), %xmm0     # 0x7150
movq 0x570a(%rip), %rax      # 0x7198
movq (%rax,%rbx,8), %rax
movsd %xmm0, (%rax,%r14,8)
movslq 0x56f1(%rip), %rcx      # 0x7190
testq %rcx, %rcx
jle 0x1ade
leaq 0x5705(%rip), %rdx      # 0x71b0
leaq (%rdx,%rcx,8), %rdx
addq $-0x8, %rdx
negq %rcx
xorpd %xmm0, %xmm0
xorl %esi, %esi
movsd (%rdx,%rsi,8), %xmm1
leal (%r14,%rsi), %edi
testl %edi, %edi
cmovlel %r13d, %edi
mulsd (%rax,%rdi,8), %xmm1
addsd %xmm1, %xmm0
decq %rsi
cmpq %rsi, %rcx
jne 0x1abc
jmp 0x1ae2
xorpd %xmm0, %xmm0
movslq 0x56ab(%rip), %rax      # 0x7194
movq 0x56b0(%rip), %rcx      # 0x71a0
movq (%rcx,%rbx,8), %rcx
movl -0x3c(%rbp), %edx
testq %rax, %rax
jle 0x1b1d
movsd -0x8(%r12,%rax,8), %xmm1
testl %edx, %edx
movl $0x0, %esi
cmovgl %edx, %esi
mulsd (%rcx,%rsi,8), %xmm1
addsd %xmm1, %xmm0
decl %edx
decq %rax
jne 0x1afc
movsd %xmm0, (%rcx,%r14,8)
mulsd 0x5635(%rip), %xmm0     # 0x7160
movq -0x50(%rbp), %r15
movq %r15, %rdi
leaq 0x2602(%rip), %rsi      # 0x413b
movb $0x1, %al
callq 0x1150
incq %rbx
movq -0x58(%rbp), %rsi
movslq (%rsi), %rax
cmpq %rax, %rbx
jl 0x1a5d
movl 0xc(%rsi), %ecx
incq %r14
movslq %ecx, %rdx
incl -0x3c(%rbp)
cmpq %rdx, %r14
jl 0x1a4f
movq -0x30(%rbp), %rdi
callq 0x10a0
movq -0x50(%rbp), %rdi
callq 0x10a0
xorl %eax, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x55ae(%rip), %rsi      # 0x7140
movq 0x55af(%rip), %rdx      # 0x7148
leaq 0x25c6(%rip), %rdi      # 0x4166
xorl %eax, %eax
callq 0x10c0
jmp 0x1bc1
leaq 0x25df(%rip), %rdi      # 0x418f
callq 0x1080
leaq 0x25e0(%rip), %rdi      # 0x419c
callq 0x1080
xorl %edi, %edi
callq 0x1210
callq 0x1270
nopl (%rax)