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

    int i;
    FILE *in,*out;
    RRA *h;

    argIndex = processOptions(argc,argv);

    if (argc-argIndex == 0)
        {
        in = stdin;
        out = stdout;
        }
    else if (argc-argIndex == 1)
        {
        in = fopen(argv[argIndex],"r");
        out = stdout;
        }
    else if (argc-argIndex == 2)
        {
        in = OpenFile(argv[argIndex],"r");
        out = OpenFile(argv[argIndex+1],"w");
        }
    else
        {
        printf("usage: rraecho [<input rra file> [<output rra file>]]\n");
        exit(-1);
        }

    h = readRRA(in,0);

    if (h->channels != 1) Fatal("rraecho only works on mono rra files");

    double slength;
    if (Length <= 0)
        slength = h->samples;
    else
        slength = Length * h->sampleRate;

    int sdelay = Delay * h->sampleRate;
    int olength = h->samples;

    h->samples = slength;
    writeRRAHeader(out,h,"modifiedBy: rraecho",0);

    for (i = 0; i < slength; ++i)
        {
        int j;
        int total = 0;
        double factor = 1;
        //printf("total is %d\n",total);
        for (j = 0; j < i / sdelay + 1; ++j)
            {
            if (i < olength + j * sdelay)
                total += h->data[0][i - j * sdelay] * factor;
            factor *= Attenuation;
            //printf("total now is %d\n",total);
            }
        fprintf(out,"%d\n",total);
        //if (i / sdelay > 1)
            //getchar();
        }

    fclose(in);
    fclose(out);

    return 0;
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rsi, %r14
movl %edi, %ebx
movl $0x1, %r12d
cmpl $0x2, %edi
jl 0x1691
movl $0x1, %r12d
movslq %r12d, %rax
movq (%r14,%rax,8), %rsi
cmpb $0x2d, (%rsi)
jne 0x1691
movb 0x2(%rsi), %r13b
testb %r13b, %r13b
je 0x1606
leaq 0x2(%rsi), %rdi
jmp 0x160b
movq 0x8(%r14,%rax,8), %rdi
movzbl 0x1(%rsi), %eax
cmpl $0x67, %eax
jg 0x162d
cmpl $0x61, %eax
je 0x1641
cmpl $0x64, %eax
jne 0x1665
callq 0x1080
movsd %xmm0, 0x5b1d(%rip)     # 0x7148
jmp 0x164e
cmpl $0x6c, %eax
jne 0x1653
callq 0x1080
movsd %xmm0, 0x5b31(%rip)     # 0x7170
jmp 0x164e
callq 0x1080
movsd %xmm0, 0x5b02(%rip)     # 0x7150
movb $0x1, %r15b
jmp 0x1676
cmpl $0x68, %eax
je 0x188d
cmpl $0x76, %eax
je 0x186f
xorl %r15d, %r15d
leaq 0x2a34(%rip), %rdi      # 0x40a3
xorl %eax, %eax
callq 0x1914
testb %r13b, %r13b
sete %al
andb %r15b, %al
movzbl %al, %eax
addl %eax, %r12d
incl %r12d
cmpl %ebx, %r12d
jl 0x15e7
subl %r12d, %ebx
jne 0x16a2
movq 0x593b(%rip), %rax      # 0x6fd8
movq (%rax), %r12
jmp 0x16c6
cmpl $0x2, %ebx
je 0x16d2
cmpl $0x1, %ebx
jne 0x18fc
movslq %r12d, %rax
movq (%r14,%rax,8), %rdi
leaq 0x2f84(%rip), %rsi      # 0x4642
callq 0x11c0
movq %rax, %r12
movq 0x5903(%rip), %rax      # 0x6fd0
movq (%rax), %rax
jmp 0x16f9
movslq %r12d, %rbx
movq (%r14,%rbx,8), %rdi
leaq 0x2f62(%rip), %rsi      # 0x4642
callq 0x19ae
movq %rax, %r12
movq 0x8(%r14,%rbx,8), %rdi
leaq 0x2921(%rip), %rsi      # 0x4015
callq 0x19ae
movq %rax, -0x30(%rbp)
movq %r12, %rdi
xorl %esi, %esi
callq 0x1f16
movq %rax, %r15
cmpl $0x1, (%rax)
je 0x171d
leaq 0x2901(%rip), %rdi      # 0x4017
xorl %eax, %eax
callq 0x1914
movsd 0x5a4b(%rip), %xmm1     # 0x7170
xorpd %xmm0, %xmm0
ucomisd %xmm1, %xmm0
movq %r12, -0x48(%rbp)
jae 0x1746
xorps %xmm0, %xmm0
cvtsi2sdl 0x4(%r15), %xmm0
mulsd %xmm0, %xmm1
movl 0xc(%r15), %ebx
jmp 0x175a
movl 0xc(%r15), %ebx
xorps %xmm1, %xmm1
cvtsi2sd %ebx, %xmm1
xorps %xmm0, %xmm0
cvtsi2sdl 0x4(%r15), %xmm0
movsd %xmm1, -0x40(%rbp)
mulsd 0x59e1(%rip), %xmm0     # 0x7148
movsd %xmm0, -0x38(%rbp)
cvttsd2si %xmm1, %eax
movl %eax, 0xc(%r15)
leaq 0x28c1(%rip), %rdx      # 0x403c
movq -0x30(%rbp), %rdi
movq %r15, %rsi
xorl %ecx, %ecx
callq 0x2ae0
xorpd %xmm0, %xmm0
movsd -0x40(%rbp), %xmm1
ucomisd %xmm0, %xmm1
jbe 0x184c
cvttsd2si -0x38(%rbp), %eax
movl %eax, -0x38(%rbp)
movslq %eax, %r12
movslq %ebx, %rax
movq %rax, -0x50(%rbp)
leaq (,%r12,4), %r14
xorl %ebx, %ebx
xorl %r13d, %r13d
movl %r13d, %eax
cltd
idivl -0x38(%rbp)
movl $0x0, %edx
testl %eax, %eax
js 0x181c
movsd 0x597d(%rip), %xmm0     # 0x7150
incl %eax
xorl %edx, %edx
movq -0x50(%rbp), %rcx
movq %rbx, %rsi
movsd 0x2822(%rip), %xmm1     # 0x4008
cmpq %rcx, %r13
jge 0x180d
movq 0x18(%r15), %rdi
movq (%rdi), %rdi
xorps %xmm2, %xmm2
cvtsi2sdl (%rdi,%rsi), %xmm2
xorps %xmm3, %xmm3
cvtsi2sd %edx, %xmm3
mulsd %xmm1, %xmm2
addsd %xmm3, %xmm2
cvttsd2si %xmm2, %edx
mulsd %xmm0, %xmm1
subq %r14, %rsi
addq %r12, %rcx
decq %rax
jne 0x17e6
movq -0x30(%rbp), %rdi
leaq 0x2abe(%rip), %rsi      # 0x42e5
xorl %eax, %eax
callq 0x1140
incq %r13
xorps %xmm0, %xmm0
cvtsi2sd %r13d, %xmm0
addq $0x4, %rbx
movsd -0x40(%rbp), %xmm1
ucomisd %xmm0, %xmm1
ja 0x17bb
movq -0x48(%rbp), %rdi
callq 0x1090
movq -0x30(%rbp), %rdi
callq 0x1090
xorl %eax, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x58c2(%rip), %rsi      # 0x7138
movq 0x58c3(%rip), %rdx      # 0x7140
leaq 0x27cc(%rip), %rdi      # 0x4050
xorl %eax, %eax
callq 0x10b0
jmp 0x18f5
leaq 0x285f(%rip), %rdi      # 0x40f3
callq 0x1070
leaq 0x2861(%rip), %rdi      # 0x4101
callq 0x1070
movsd 0x58a3(%rip), %xmm0     # 0x7150
leaq 0x27ab(%rip), %rdi      # 0x405f
movb $0x1, %al
callq 0x10b0
leaq 0x2869(%rip), %rdi      # 0x412b
callq 0x1070
movsd 0x5879(%rip), %xmm0     # 0x7148
leaq 0x27a7(%rip), %rdi      # 0x407d
movb $0x1, %al
callq 0x10b0
leaq 0x2870(%rip), %rdi      # 0x4154
callq 0x1070
leaq 0x2898(%rip), %rdi      # 0x4188
callq 0x1070
xorl %edi, %edi
callq 0x1200
leaq 0x27ba(%rip), %rdi      # 0x40bd
callq 0x1070
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x1200
nop