// File: /workspace/github_c_makefile_star2_O1/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 0x1687
movl $0x1, %r12d
movslq %r12d, %rax
movq (%r14,%rax,8), %rsi
cmpb $0x2d, (%rsi)
jne 0x1687
movb 0x2(%rsi), %r13b
testb %r13b, %r13b
je 0x1616
leaq 0x2(%rsi), %rdi
jmp 0x161b
movq 0x8(%r14,%rax,8), %rdi
movzbl 0x1(%rsi), %eax
cmpl $0x65, %eax
jle 0x1632
cmpl $0x66, %eax
jne 0x1649
movq %rdi, 0x5b28(%rip)      # 0x7158
jmp 0x1644
cmpl $0x61, %eax
jne 0x165b
callq 0x1090
movsd %xmm0, 0x5b1c(%rip)     # 0x7160
movb $0x1, %r15b
jmp 0x166c
cmpl $0x68, %eax
je 0x1b99
cmpl $0x76, %eax
je 0x1b7b
xorl %r15d, %r15d
leaq 0x2b10(%rip), %rdi      # 0x4175
xorl %eax, %eax
callq 0x1bc0
testb %r13b, %r13b
sete %al
andb %r15b, %al
movzbl %al, %eax
addl %eax, %r12d
incl %r12d
cmpl %ebx, %r12d
jl 0x15f7
subl %r12d, %ebx
jne 0x1698
movq 0x5945(%rip), %rax      # 0x6fd8
movq (%rax), %rax
jmp 0x16b9
cmpl $0x2, %ebx
je 0x16c9
cmpl $0x1, %ebx
jne 0x1bb8
movslq %r12d, %rax
movq (%r14,%rax,8), %rdi
leaq 0x2f79(%rip), %rsi      # 0x462d
callq 0x1c5a
movq %rax, -0x30(%rbp)
movq 0x590c(%rip), %rax      # 0x6fd0
movq (%rax), %r14
jmp 0x16f4
movslq %r12d, %rbx
movq (%r14,%rbx,8), %rdi
leaq 0x2f56(%rip), %rsi      # 0x462d
callq 0x1c5a
movq %rax, -0x30(%rbp)
movq 0x8(%r14,%rbx,8), %rdi
leaq 0x293e(%rip), %rsi      # 0x402a
callq 0x1c5a
movq %rax, %r14
movq 0x5a5d(%rip), %rbx      # 0x7158
movq 0x58f6(%rip), %rax      # 0x6ff8
movq (%rax), %rdi
leaq 0x29cd(%rip), %rsi      # 0x40d9
movq %rbx, %rdx
xorl %eax, %eax
callq 0x1150
leaq 0x2f10(%rip), %rsi      # 0x462d
movq %rbx, %rdi
callq 0x1c5a
movq %rax, %r15
movq $0x0, 0x9a7d(%rip) # 0xb1b0
movl $0x0, 0x5a53(%rip)      # 0x7190
leaq 0x29af(%rip), %rbx      # 0x40f3
leaq 0x5a05(%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 0x181d
leaq 0x2973(%rip), %r13      # 0x40f3
leaq -0x38(%rbp), %r12
cmpl $0x400, 0x5a02(%rip)    # imm = 0x400
jl 0x179e
leaq 0x2961(%rip), %rdi      # 0x40f8
xorl %eax, %eax
callq 0x1bc0
movsd -0x38(%rbp), %xmm0
movslq 0x59e6(%rip), %rax      # 0x7190
leaq 0x59ff(%rip), %rcx      # 0x71b0
movsd %xmm0, (%rcx,%rax,8)
addsd 0x99f2(%rip), %xmm0     # 0xb1b0
movsd %xmm0, 0x99ea(%rip)     # 0xb1b0
incl %eax
movl %eax, 0x59c2(%rip)      # 0x7190
movq %r15, %rdi
callq 0x10f0
movl %eax, %ebx
testl %eax, %eax
je 0x17f3
callq 0x1250
movq (%rax), %rax
movslq %ebx, %rcx
testb $0x20, 0x1(%rax,%rcx,2)
jne 0x17ce
cmpl $0x25, %ebx
je 0x181d
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 0x1784
movq 0x57d4(%rip), %rax      # 0x6ff8
movq (%rax), %rdi
movsd 0x9981(%rip), %xmm0     # 0xb1b0
leaq 0x28df(%rip), %rsi      # 0x4115
movb $0x1, %al
callq 0x1150
movq $0x0, 0x9968(%rip) # 0xb1b0
movl $0x0, 0x5942(%rip)      # 0x7194
leaq 0x289a(%rip), %rsi      # 0x40f3
leaq -0x38(%rbp), %rdx
movq %r15, %rdi
xorl %eax, %eax
callq 0x1070
movq %r15, %rdi
callq 0x1170
leaq 0x793a(%rip), %r12      # 0x91b0
testl %eax, %eax
jne 0x18e5
leaq 0x2872(%rip), %r13      # 0x40f3
leaq -0x38(%rbp), %rbx
cmpl $0x400, 0x5905(%rip)    # imm = 0x400
jl 0x189f
leaq 0x2860(%rip), %rdi      # 0x40f8
xorl %eax, %eax
callq 0x1bc0
movsd -0x38(%rbp), %xmm0
movslq 0x58e9(%rip), %rax      # 0x7194
movsd %xmm0, (%r12,%rax,8)
addsd 0x98f7(%rip), %xmm0     # 0xb1b0
movsd %xmm0, 0x98ef(%rip)     # 0xb1b0
incl %eax
movl %eax, 0x58cb(%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 0x1885
movq 0x570c(%rip), %rbx      # 0x6ff8
movq (%rbx), %rdi
movsd 0x98b9(%rip), %xmm0     # 0xb1b0
leaq 0x2841(%rip), %rsi      # 0x413f
movb $0x1, %al
callq 0x1150
movq (%rbx), %rdi
movl 0x5882(%rip), %edx      # 0x7190
leaq 0x2771(%rip), %rsi      # 0x4086
xorl %eax, %eax
callq 0x1150
movq (%rbx), %rdi
movl 0x586f(%rip), %edx      # 0x7194
leaq 0x2770(%rip), %rsi      # 0x409c
xorl %eax, %eax
callq 0x1150
movq (%rbx), %rdi
movsd 0x5822(%rip), %xmm0     # 0x7160
leaq 0x276a(%rip), %rsi      # 0x40af
movb $0x1, %al
callq 0x1150
callq 0x1ed7
movq %rax, %rbx
movq -0x30(%rbp), %rdi
movq %rax, %rsi
xorl %edx, %edx
callq 0x22e4
leaq 0x2760(%rip), %rdx      # 0x40c9
movq %r14, -0x50(%rbp)
movq %r14, %rdi
movq %rbx, %rsi
xorl %ecx, %ecx
callq 0x2d35
movl 0x8(%rbx), %edi
decl %edi
movsd 0x2681(%rip), %xmm0     # 0x4008
callq 0x1050
movsd %xmm0, -0x48(%rbp)
movl (%rbx), %edi
shll $0x3, %edi
callq 0x1ced
movq %rax, 0x57f6(%rip)      # 0x7198
movl (%rbx), %edi
shll $0x3, %edi
callq 0x1ced
movq %rbx, %rdx
movq %rax, 0x57ea(%rip)      # 0x71a0
cmpl $0x0, (%rbx)
movq %rbx, -0x58(%rbp)
jle 0x1a00
xorl %ebx, %ebx
movl 0xc(%rdx), %edi
shll $0x3, %edi
callq 0x1ced
movq 0x57c5(%rip), %rcx      # 0x7198
movq %rax, (%rcx,%rbx,8)
movq -0x58(%rbp), %rax
movl 0xc(%rax), %edi
shll $0x3, %edi
callq 0x1ced
movq -0x58(%rbp), %rdx
movq 0x57af(%rip), %rcx      # 0x71a0
movq %rax, (%rcx,%rbx,8)
incq %rbx
movslq (%rdx), %rax
cmpq %rax, %rbx
jl 0x19c1
cmpl $0x0, 0xc(%rdx)
jle 0x1b58
movsd -0x48(%rbp), %xmm0
addsd 0x25f9(%rip), %xmm0     # 0x4010
movsd %xmm0, -0x48(%rbp)
movl $0xffffffff, -0x3c(%rbp) # imm = 0xFFFFFFFF
xorl %r13d, %r13d
xorl %r14d, %r14d
cmpl $0x0, (%rdx)
movq -0x50(%rbp), %r15
jle 0x1b45
xorl %ebx, %ebx
movl 0x8(%rdx), %edx
movq -0x30(%rbp), %rdi
movq %r15, %rsi
leaq 0x15b8(%rip), %rcx      # 0x3001
callq 0x27d0
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
divsd -0x48(%rbp), %xmm0
divsd 0x56ee(%rip), %xmm0     # 0x7150
movq 0x572f(%rip), %rax      # 0x7198
movq (%rax,%rbx,8), %rax
movsd %xmm0, (%rax,%r14,8)
movslq 0x5716(%rip), %rax      # 0x7190
testq %rax, %rax
jle 0x1ac5
movq 0x5712(%rip), %rcx      # 0x7198
movq (%rcx,%rbx,8), %rcx
leaq 0x571f(%rip), %rdx      # 0x71b0
leaq (%rdx,%rax,8), %rdx
addq $-0x8, %rdx
negq %rax
xorpd %xmm0, %xmm0
xorl %esi, %esi
movsd (%rdx,%rsi,8), %xmm1
leaq (%r14,%rsi), %rdi
testq %rdi, %rdi
cmovleq %r13, %rdi
mulsd (%rcx,%rdi,8), %xmm1
addsd %xmm1, %xmm0
decq %rsi
cmpq %rsi, %rax
jne 0x1aa2
jmp 0x1ac9
xorpd %xmm0, %xmm0
movslq 0x56c4(%rip), %rax      # 0x7194
testq %rax, %rax
jle 0x1b04
movq 0x56c4(%rip), %rcx      # 0x71a0
movq (%rcx,%rbx,8), %rcx
movl -0x3c(%rbp), %edx
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 0x1ae3
movq 0x5695(%rip), %rax      # 0x71a0
movq (%rax,%rbx,8), %rax
movsd %xmm0, (%rax,%r14,8)
mulsd 0x5643(%rip), %xmm0     # 0x7160
movq -0x50(%rbp), %r15
movq %r15, %rdi
leaq 0x2610(%rip), %rsi      # 0x413b
movb $0x1, %al
callq 0x1150
incq %rbx
movq -0x58(%rbp), %rdx
movslq (%rdx), %rax
cmpq %rax, %rbx
jl 0x1a38
incq %r14
movslq 0xc(%rdx), %rax
incl -0x3c(%rbp)
cmpq %rax, %r14
jl 0x1a29
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 0x55be(%rip), %rsi      # 0x7140
movq 0x55bf(%rip), %rdx      # 0x7148
leaq 0x25d6(%rip), %rdi      # 0x4166
xorl %eax, %eax
callq 0x10c0
jmp 0x1bb1
leaq 0x25ef(%rip), %rdi      # 0x418f
callq 0x1080
leaq 0x25f0(%rip), %rdi      # 0x419c
callq 0x1080
xorl %edi, %edi
callq 0x1210
callq 0x1270
nopl (%rax)