// File: /workspace/github_c_makefile_star2_O0/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
subq $0x50, %rsp
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl $0x1, -0x14(%rbp)
movl -0x8(%rbp), %edi
movq -0x10(%rbp), %rsi
callq 0x1680
movl %eax, -0x14(%rbp)
movl -0x8(%rbp), %eax
subl -0x14(%rbp), %eax
cmpl $0x0, %eax
jne 0x1378
movq 0x6c7a(%rip), %rax      # 0x7fd8
movq (%rax), %rax
movq %rax, -0x30(%rbp)
movq 0x6c64(%rip), %rax      # 0x7fd0
movq (%rax), %rax
movq %rax, -0x38(%rbp)
jmp 0x141f
movl -0x8(%rbp), %eax
subl -0x14(%rbp), %eax
cmpl $0x1, %eax
jne 0x13af
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x42d2(%rip), %rsi      # 0x5668
callq 0x1d50
movq %rax, -0x30(%rbp)
movq 0x6c2a(%rip), %rax      # 0x7fd0
movq (%rax), %rax
movq %rax, -0x38(%rbp)
jmp 0x141d
movl -0x8(%rbp), %eax
subl -0x14(%rbp), %eax
cmpl $0x2, %eax
jne 0x13f9
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x429b(%rip), %rsi      # 0x5668
callq 0x1d50
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rax
movl -0x14(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x3c94(%rip), %rsi      # 0x5082
callq 0x1d50
movq %rax, -0x38(%rbp)
jmp 0x141b
movq 0x6bf8(%rip), %rax      # 0x7ff8
movq (%rax), %rdi
leaq 0x3c7a(%rip), %rsi      # 0x5084
movb $0x0, %al
callq 0x1120
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x11e0
jmp 0x141d
jmp 0x141f
movq 0x6d12(%rip), %rdi      # 0x8138
callq 0x1810
movq 0x6bc6(%rip), %rax      # 0x7ff8
movq (%rax), %rdi
movl 0x6d35(%rip), %edx      # 0x8170
leaq 0x3c9c(%rip), %rsi      # 0x50de
movb $0x0, %al
callq 0x1120
movq 0x6ba8(%rip), %rax      # 0x7ff8
movq (%rax), %rdi
movl 0x6d1b(%rip), %edx      # 0x8174
leaq 0x3c94(%rip), %rsi      # 0x50f4
movb $0x0, %al
callq 0x1120
movq 0x6b8a(%rip), %rax      # 0x7ff8
movq (%rax), %rdi
movsd 0x6cc7(%rip), %xmm0     # 0x8140
leaq 0x3c87(%rip), %rsi      # 0x5107
movb $0x1, %al
callq 0x1120
callq 0x2230
movq %rax, -0x40(%rbp)
movq -0x30(%rbp), %rdi
movq -0x40(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edx
callq 0x2730
movq -0x38(%rbp), %rdi
movq -0x40(%rbp), %rsi
leaq 0x3c71(%rip), %rdx      # 0x5121
xorl %eax, %eax
movl %eax, %ecx
callq 0x36d0
movq -0x40(%rbp), %rax
movl 0x8(%rax), %eax
subl $0x1, %eax
cvtsi2sd %eax, %xmm1
movsd 0x3b41(%rip), %xmm0     # 0x5010
callq 0x1070
movsd 0x3b2c(%rip), %xmm1     # 0x5008
subsd %xmm1, %xmm0
movsd %xmm0, -0x28(%rbp)
movq -0x40(%rbp), %rax
movslq (%rax), %rax
shlq $0x3, %rax
movl %eax, %edi
callq 0x1e50
movq %rax, 0x6c7a(%rip)      # 0x8178
movq -0x40(%rbp), %rax
movslq (%rax), %rax
shlq $0x3, %rax
movl %eax, %edi
callq 0x1e50
movq %rax, 0x6c69(%rip)      # 0x8180
movl $0x0, -0x18(%rbp)
movl -0x18(%rbp), %eax
movq -0x40(%rbp), %rcx
cmpl (%rcx), %eax
jge 0x157e
movq -0x40(%rbp), %rax
movslq 0xc(%rax), %rax
shlq $0x3, %rax
movl %eax, %edi
callq 0x1e50
movq %rax, %rdx
movq 0x6c32(%rip), %rax      # 0x8178
movslq -0x18(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movq -0x40(%rbp), %rax
movslq 0xc(%rax), %rax
shlq $0x3, %rax
movl %eax, %edi
callq 0x1e50
movq %rax, %rdx
movq 0x6c15(%rip), %rax      # 0x8180
movslq -0x18(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x151e
movl $0x0, -0x18(%rbp)
movl -0x18(%rbp), %eax
movq -0x40(%rbp), %rcx
cmpl 0xc(%rcx), %eax
jge 0x1666
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
movq -0x40(%rbp), %rcx
cmpl (%rcx), %eax
jge 0x1656
movq -0x30(%rbp), %rdi
movq -0x38(%rbp), %rsi
movq -0x40(%rbp), %rax
movl 0x8(%rax), %edx
leaq 0x254f(%rip), %rcx      # 0x3b10
callq 0x2e60
movl %eax, -0x44(%rbp)
cvtsi2sdl -0x44(%rbp), %xmm0
divsd -0x28(%rbp), %xmm0
divsd 0x6b55(%rip), %xmm0     # 0x8130
movq 0x6b96(%rip), %rax      # 0x8178
movslq -0x1c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x18(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0x1c(%rbp), %edi
movl -0x18(%rbp), %esi
callq 0x1a70
movq 0x6b7b(%rip), %rax      # 0x8180
movslq -0x1c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x18(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movq -0x38(%rbp), %rdi
movsd 0x6b1e(%rip), %xmm0     # 0x8140
movq 0x6b57(%rip), %rax      # 0x8180
movslq -0x1c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x18(%rbp), %rcx
mulsd (%rax,%rcx,8), %xmm0
leaq 0x3b52(%rip), %rsi      # 0x5193
movb $0x1, %al
callq 0x1120
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x159c
jmp 0x1658
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x1585
movq -0x30(%rbp), %rdi
callq 0x1080
movq -0x38(%rbp), %rdi
callq 0x1080
xorl %eax, %eax
addq $0x50, %rsp
popq %rbp
retq