// File: /workspace/github_c_makefile_star2_O1/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 0x1661
movl $0x1, %r12d
movslq %r12d, %rax
movq (%r14,%rax,8), %rsi
cmpb $0x2d, (%rsi)
jne 0x1661
movb 0x2(%rsi), %r13b
testb %r13b, %r13b
je 0x15d6
leaq 0x2(%rsi), %rdi
jmp 0x15db
movq 0x8(%r14,%rax,8), %rdi
movzbl 0x1(%rsi), %eax
cmpl $0x67, %eax
jg 0x15fd
cmpl $0x61, %eax
je 0x1611
cmpl $0x64, %eax
jne 0x1635
callq 0x1080
movsd %xmm0, 0x5b4d(%rip)     # 0x7148
jmp 0x161e
cmpl $0x6c, %eax
jne 0x1623
callq 0x1080
movsd %xmm0, 0x5b61(%rip)     # 0x7170
jmp 0x161e
callq 0x1080
movsd %xmm0, 0x5b32(%rip)     # 0x7150
movb $0x1, %r15b
jmp 0x1646
cmpl $0x68, %eax
je 0x1859
cmpl $0x76, %eax
je 0x183b
xorl %r15d, %r15d
leaq 0x2a64(%rip), %rdi      # 0x40a3
xorl %eax, %eax
callq 0x18e0
testb %r13b, %r13b
sete %al
andb %r15b, %al
movzbl %al, %eax
addl %eax, %r12d
incl %r12d
cmpl %ebx, %r12d
jl 0x15b7
subl %r12d, %ebx
jne 0x1672
movq 0x596b(%rip), %rax      # 0x6fd8
movq (%rax), %r12
jmp 0x1696
cmpl $0x2, %ebx
je 0x16a2
cmpl $0x1, %ebx
jne 0x18c8
movslq %r12d, %rax
movq (%r14,%rax,8), %rdi
leaq 0x2fb7(%rip), %rsi      # 0x4645
callq 0x11c0
movq %rax, %r12
movq 0x5933(%rip), %rax      # 0x6fd0
movq (%rax), %rax
jmp 0x16c9
movslq %r12d, %rbx
movq (%r14,%rbx,8), %rdi
leaq 0x2f95(%rip), %rsi      # 0x4645
callq 0x197a
movq %rax, %r12
movq 0x8(%r14,%rbx,8), %rdi
leaq 0x2951(%rip), %rsi      # 0x4015
callq 0x197a
movq %rax, -0x30(%rbp)
movq %r12, %rdi
xorl %esi, %esi
callq 0x1ee6
movq %rax, %r15
cmpl $0x1, (%rax)
je 0x16ed
leaq 0x2931(%rip), %rdi      # 0x4017
xorl %eax, %eax
callq 0x18e0
movsd 0x5a7b(%rip), %xmm1     # 0x7170
xorpd %xmm0, %xmm0
ucomisd %xmm1, %xmm0
movq %r12, -0x48(%rbp)
jae 0x1712
xorps %xmm0, %xmm0
cvtsi2sdl 0x4(%r15), %xmm0
mulsd %xmm0, %xmm1
jmp 0x171b
xorps %xmm1, %xmm1
cvtsi2sdl 0xc(%r15), %xmm1
movsd %xmm1, -0x40(%rbp)
xorps %xmm0, %xmm0
cvtsi2sdl 0x4(%r15), %xmm0
mulsd 0x5a17(%rip), %xmm0     # 0x7148
movsd %xmm0, -0x38(%rbp)
movslq 0xc(%r15), %rax
movq %rax, -0x50(%rbp)
cvttsd2si %xmm1, %eax
movl %eax, 0xc(%r15)
leaq 0x28ef(%rip), %rdx      # 0x403c
movq -0x30(%rbp), %rdi
movq %r15, %rsi
xorl %ecx, %ecx
callq 0x2a55
xorpd %xmm0, %xmm0
movsd -0x40(%rbp), %xmm1
ucomisd %xmm0, %xmm1
jbe 0x1818
cvttsd2si -0x38(%rbp), %eax
movl %eax, -0x38(%rbp)
movslq %eax, %rbx
leaq (,%rbx,4), %r14
xorl %r12d, %r12d
xorl %r13d, %r13d
movl %r13d, %eax
cltd
idivl -0x38(%rbp)
movl $0x0, %edx
testl %eax, %eax
js 0x17e8
movsd 0x59b1(%rip), %xmm0     # 0x7150
incl %eax
xorl %edx, %edx
movq -0x50(%rbp), %rcx
movq %r12, %rsi
movsd 0x2856(%rip), %xmm1     # 0x4008
cmpq %rcx, %r13
jge 0x17d9
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 %rbx, %rcx
decq %rax
jne 0x17b2
movq -0x30(%rbp), %rdi
leaq 0x2af2(%rip), %rsi      # 0x42e5
xorl %eax, %eax
callq 0x1140
incq %r13
xorps %xmm0, %xmm0
cvtsi2sd %r13d, %xmm0
addq $0x4, %r12
movsd -0x40(%rbp), %xmm1
ucomisd %xmm0, %xmm1
ja 0x1787
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 0x58f6(%rip), %rsi      # 0x7138
movq 0x58f7(%rip), %rdx      # 0x7140
leaq 0x2800(%rip), %rdi      # 0x4050
xorl %eax, %eax
callq 0x10b0
jmp 0x18c1
leaq 0x2893(%rip), %rdi      # 0x40f3
callq 0x1070
leaq 0x2895(%rip), %rdi      # 0x4101
callq 0x1070
movsd 0x58d7(%rip), %xmm0     # 0x7150
leaq 0x27df(%rip), %rdi      # 0x405f
movb $0x1, %al
callq 0x10b0
leaq 0x289d(%rip), %rdi      # 0x412b
callq 0x1070
movsd 0x58ad(%rip), %xmm0     # 0x7148
leaq 0x27db(%rip), %rdi      # 0x407d
movb $0x1, %al
callq 0x10b0
leaq 0x28a4(%rip), %rdi      # 0x4154
callq 0x1070
leaq 0x28cc(%rip), %rdi      # 0x4188
callq 0x1070
xorl %edi, %edi
callq 0x1200
leaq 0x27ee(%rip), %rdi      # 0x40bd
callq 0x1070
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x1200
nop