// File: /workspace/github_c_makefile_star2_O2/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
pushq $0x1
popq %r12
movslq %r12d, %r15
cmpl %r12d, %ebx
jle 0x1402
movq (%r14,%r15,8), %rsi
cmpb $0x2d, (%rsi)
jne 0x1402
movb 0x2(%rsi), %r13b
testb %r13b, %r13b
je 0x139a
leaq 0x2(%rsi), %rdi
jmp 0x139f
movq 0x8(%r14,%r15,8), %rdi
movzbl 0x1(%rsi), %eax
cmpl $0x61, %eax
je 0x13d2
cmpl $0x66, %eax
je 0x13e1
cmpl $0x68, %eax
je 0x188e
cmpl $0x76, %eax
je 0x18a8
xorl %r15d, %r15d
leaq 0x2dac(%rip), %rdi      # 0x4175
xorl %eax, %eax
callq 0x18f0
jmp 0x13eb
callq 0x1090
movsd %xmm0, 0x5d81(%rip)     # 0x7160
jmp 0x13e8
movq %rdi, 0x5d70(%rip)      # 0x7158
movb $0x1, %r15b
testb %r13b, %r13b
sete %al
andb %r15b, %al
movzbl %al, %eax
addl %eax, %r12d
incl %r12d
jmp 0x1376
subl %r12d, %ebx
jne 0x1413
movq 0x5bca(%rip), %rax      # 0x6fd8
movq (%rax), %rax
jmp 0x1431
cmpl $0x2, %ebx
je 0x1441
cmpl $0x1, %ebx
jne 0x18cb
movq (%r14,%r15,8), %rdi
leaq 0x31fe(%rip), %rsi      # 0x462a
callq 0x1a20
movq %rax, -0x38(%rbp)
movq 0x5b94(%rip), %rax      # 0x6fd0
movq (%rax), %rax
jmp 0x1466
movq (%r14,%r15,8), %rdi
leaq 0x31de(%rip), %rsi      # 0x462a
callq 0x1a20
movq %rax, -0x38(%rbp)
movq 0x8(%r14,%r15,8), %rdi
leaq 0x2bc9(%rip), %rsi      # 0x402a
callq 0x1a20
movq %rax, -0x30(%rbp)
movq 0x5ce7(%rip), %r15      # 0x7158
movq 0x5b80(%rip), %rax      # 0x6ff8
movq (%rax), %rdi
leaq 0x2c57(%rip), %rsi      # 0x40d9
movq %r15, %rdx
xorl %eax, %eax
callq 0x1150
leaq 0x3197(%rip), %rsi      # 0x462a
movq %r15, %rdi
callq 0x1a20
andq $0x0, 0x9d0d(%rip)      # 0xb1b0
movq %rax, %r15
andl $0x0, 0x5ce3(%rip)      # 0x7190
leaq 0x2c3f(%rip), %rsi      # 0x40f3
leaq 0x5c95(%rip), %rdx      # 0x7150
movq %rax, %rdi
movq %rsi, %r14
xorl %eax, %eax
callq 0x1070
leaq -0x50(%rbp), %r13
leaq 0x5cdd(%rip), %rbx      # 0x71b0
movq %r15, %rdi
movq %r14, %rsi
movq %r13, %rdx
xorl %eax, %eax
callq 0x1070
movq %r15, %rdi
callq 0x1170
testl %eax, %eax
jne 0x156b
movl 0x5c9b(%rip), %eax      # 0x7190
cmpl $0x400, %eax            # imm = 0x400
jl 0x1510
leaq 0x2bf5(%rip), %rdi      # 0x40f8
xorl %eax, %eax
callq 0x18f0
movl 0x5c80(%rip), %eax      # 0x7190
movsd -0x50(%rbp), %xmm0
cltq
movsd %xmm0, (%rbx,%rax,8)
addsd 0x9c8c(%rip), %xmm0     # 0xb1b0
movsd %xmm0, 0x9c84(%rip)     # 0xb1b0
incl %eax
movl %eax, 0x5c5c(%rip)      # 0x7190
movq %r15, %rdi
callq 0x10f0
movl %eax, %r12d
testl %eax, %eax
je 0x155b
callq 0x1250
movq (%rax), %rax
movslq %r12d, %rcx
testb $0x20, 0x1(%rax,%rcx,2)
jne 0x1534
cmpl $0x25, %r12d
je 0x156b
movl %r12d, %edi
movq %r15, %rsi
callq 0x11a0
jmp 0x14d3
movq 0x5a86(%rip), %rax      # 0x6ff8
movq (%rax), %rdi
movsd 0x9c33(%rip), %xmm0     # 0xb1b0
leaq 0x2b91(%rip), %rsi      # 0x4115
movb $0x1, %al
callq 0x1150
andq $0x0, 0x9c1d(%rip)      # 0xb1b0
leaq 0x2b59(%rip), %r14      # 0x40f3
leaq -0x50(%rbp), %r13
leaq 0x7c0b(%rip), %r12      # 0x91b0
xorl %eax, %eax
movl %eax, 0x5be7(%rip)      # 0x7194
movq %r15, %rdi
movq %r14, %rsi
movq %r13, %rdx
xorl %eax, %eax
callq 0x1070
movq %r15, %rdi
callq 0x1170
testl %eax, %eax
jne 0x160b
movl 0x5bc5(%rip), %eax      # 0x7194
cmpl $0x400, %eax            # imm = 0x400
jl 0x15ea
leaq 0x2b1b(%rip), %rdi      # 0x40f8
xorl %eax, %eax
callq 0x18f0
movl 0x5baa(%rip), %eax      # 0x7194
movsd -0x50(%rbp), %xmm0
cltq
movsd %xmm0, (%r12,%rax,8)
addsd 0x9bb1(%rip), %xmm0     # 0xb1b0
movsd %xmm0, 0x9ba9(%rip)     # 0xb1b0
incl %eax
jmp 0x15a7
movq 0x59e6(%rip), %r15      # 0x6ff8
movq (%r15), %rdi
movsd 0x9b93(%rip), %xmm0     # 0xb1b0
leaq 0x2b1b(%rip), %rsi      # 0x413f
movb $0x1, %al
callq 0x1150
movq (%r15), %rdi
movl 0x5b5c(%rip), %edx      # 0x7190
leaq 0x2a4b(%rip), %rsi      # 0x4086
xorl %r14d, %r14d
xorl %eax, %eax
callq 0x1150
movq (%r15), %rdi
movl 0x5b46(%rip), %edx      # 0x7194
leaq 0x2a47(%rip), %rsi      # 0x409c
xorl %eax, %eax
callq 0x1150
movq (%r15), %rdi
movsd 0x5af9(%rip), %xmm0     # 0x7160
leaq 0x2a41(%rip), %rsi      # 0x40af
movb $0x1, %al
callq 0x1150
callq 0x1c7c
movq %rax, %r15
movq -0x38(%rbp), %rdi
movq %rax, %rsi
xorl %edx, %edx
callq 0x1fe1
leaq 0x2a37(%rip), %rdx      # 0x40c9
movq -0x30(%rbp), %rdi
movq %r15, %rsi
xorl %ecx, %ecx
callq 0x29f0
movl 0x8(%r15), %edi
decl %edi
movsd 0x295a(%rip), %xmm0     # 0x4008
callq 0x1050
movsd %xmm0, -0x48(%rbp)
movl (%r15), %edi
shll $0x3, %edi
callq 0x1aa5
movq %rax, 0x5ace(%rip)      # 0x7198
movl (%r15), %edi
shll $0x3, %edi
callq 0x1aa5
movq %rax, 0x5ac4(%rip)      # 0x71a0
movslq (%r15), %rax
cmpq %rax, %r14
movq %r15, %rdx
jge 0x171c
movl 0xc(%rdx), %edi
shll $0x3, %edi
movq %rdx, %r15
callq 0x1aa5
movq 0x5a9c(%rip), %rcx      # 0x7198
movq %rax, (%rcx,%r14,8)
movl 0xc(%r15), %edi
shll $0x3, %edi
callq 0x1aa5
movq 0x5a8d(%rip), %rcx      # 0x71a0
movq %rax, (%rcx,%r14,8)
incq %r14
jmp 0x16dc
movsd -0x48(%rbp), %xmm0
addsd 0x28e7(%rip), %xmm0     # 0x4010
movsd %xmm0, -0x48(%rbp)
pushq $-0x1
popq %rcx
movl %ecx, -0x3c(%rbp)
xorl %r14d, %r14d
xorl %r13d, %r13d
movq %rdx, -0x58(%rbp)
movslq 0xc(%rdx), %rcx
cmpq %rcx, %r13
jge 0x186b
xorl %r15d, %r15d
movslq %eax, %rcx
cmpq %rcx, %r15
jge 0x1860
movl 0x8(%rdx), %edx
movq -0x38(%rbp), %rdi
movq -0x30(%rbp), %rsi
leaq 0x1511(%rip), %rcx      # 0x2c7d
callq 0x24b6
cvtsi2sd %eax, %xmm0
divsd -0x48(%rbp), %xmm0
divsd 0x59ce(%rip), %xmm0     # 0x7150
movq 0x5a0f(%rip), %rax      # 0x7198
movq (%rax,%r15,8), %rax
movsd %xmm0, (%rax,%r13,8)
movl 0x59f7(%rip), %eax      # 0x7190
movq 0x59f8(%rip), %rcx      # 0x7198
testl %eax, %eax
movl $0x0, %edx
cmovgl %eax, %edx
decl %eax
negq %rdx
xorpd %xmm0, %xmm0
xorl %esi, %esi
cmpq %rsi, %rdx
je 0x17e3
leal (%rax,%rsi), %edi
movslq %edi, %rdi
movsd (%rbx,%rdi,8), %xmm1
movq (%rcx,%r15,8), %rdi
leal (%rsi,%r13), %r8d
testl %r8d, %r8d
cmovlel %r14d, %r8d
mulsd (%rdi,%r8,8), %xmm1
addsd %xmm1, %xmm0
decq %rsi
jmp 0x17b5
movl 0x59ab(%rip), %ecx      # 0x7194
movq 0x59b0(%rip), %rax      # 0x71a0
testl %ecx, %ecx
movl $0x0, %edx
cmovgl %ecx, %edx
decl %ecx
movl -0x3c(%rbp), %esi
subq $0x1, %rdx
jb 0x182e
movslq %ecx, %rcx
movsd (%r12,%rcx,8), %xmm1
movq (%rax,%r15,8), %rdi
testl %esi, %esi
movl $0x0, %r8d
cmovgl %esi, %r8d
mulsd (%rdi,%r8,8), %xmm1
addsd %xmm1, %xmm0
decl %esi
decl %ecx
jmp 0x17ff
movq (%rax,%r15,8), %rax
movsd %xmm0, (%rax,%r13,8)
mulsd 0x5920(%rip), %xmm0     # 0x7160
movq -0x30(%rbp), %rdi
leaq 0x28f0(%rip), %rsi      # 0x413b
movb $0x1, %al
callq 0x1150
incq %r15
movq -0x58(%rbp), %rdx
movl (%rdx), %eax
jmp 0x174e
incq %r13
incl -0x3c(%rbp)
jmp 0x173e
movq -0x38(%rbp), %rdi
callq 0x10a0
movq -0x30(%rbp), %rdi
callq 0x10a0
xorl %eax, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x28fa(%rip), %rdi      # 0x418f
callq 0x1080
leaq 0x28fb(%rip), %rdi      # 0x419c
callq 0x1080
jmp 0x18c4
movq 0x5891(%rip), %rsi      # 0x7140
movq 0x5892(%rip), %rdx      # 0x7148
leaq 0x28a9(%rip), %rdi      # 0x4166
xorl %eax, %eax
callq 0x10c0
xorl %edi, %edi
callq 0x1210
movq 0x5726(%rip), %rax      # 0x6ff8
movq (%rax), %rcx
leaq 0x2750(%rip), %rdi      # 0x402c
pushq $0x59
popq %rsi
pushq $0x1
popq %rdx
callq 0x1220
pushq $-0x1
popq %rdi
callq 0x1210
nop