// File: /workspace/github_c_makefile_star2_O2/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
pushq $0x1
popq %r12
movslq %r12d, %r15
cmpl %r12d, %ebx
jle 0x1410
movq (%r14,%r15,8), %rsi
cmpb $0x2d, (%rsi)
jne 0x1410
movb 0x2(%rsi), %r13b
testb %r13b, %r13b
je 0x138e
leaq 0x2(%rsi), %rdi
jmp 0x1393
movq 0x8(%r14,%r15,8), %rdi
movzbl 0x1(%rsi), %eax
cmpl $0x61, %eax
je 0x13da
cmpl $0x64, %eax
je 0x13cb
cmpl $0x6c, %eax
je 0x13e9
cmpl $0x68, %eax
je 0x15c0
cmpl $0x76, %eax
je 0x162a
xorl %r15d, %r15d
leaq 0x1ce1(%rip), %rdi      # 0x30a3
xorl %eax, %eax
callq 0x1664
jmp 0x13f9
callq 0x1080
movsd %xmm0, 0x4d70(%rip)     # 0x6148
jmp 0x13f6
callq 0x1080
movsd %xmm0, 0x4d69(%rip)     # 0x6150
jmp 0x13f6
callq 0x1080
movsd %xmm0, 0x4d7a(%rip)     # 0x6170
movb $0x1, %r15b
testb %r13b, %r13b
sete %al
andb %r15b, %al
movzbl %al, %eax
addl %eax, %r12d
incl %r12d
jmp 0x1366
subl %r12d, %ebx
jne 0x1421
movq 0x4bbc(%rip), %rax      # 0x5fd8
movq (%rax), %rbx
jmp 0x1442
cmpl $0x2, %ebx
je 0x144e
cmpl $0x1, %ebx
jne 0x164d
movq (%r14,%r15,8), %rdi
leaq 0x2208(%rip), %rsi      # 0x3642
callq 0x11c0
movq %rax, %rbx
movq 0x4b87(%rip), %rax      # 0x5fd0
movq (%rax), %rax
jmp 0x1472
movq (%r14,%r15,8), %rdi
leaq 0x21e9(%rip), %rsi      # 0x3642
callq 0x1794
movq %rax, %rbx
movq 0x8(%r14,%r15,8), %rdi
leaq 0x1ba8(%rip), %rsi      # 0x3015
callq 0x1794
movq %rax, -0x30(%rbp)
movq %rbx, %rdi
xorl %esi, %esi
callq 0x1c61
movq %rax, %r15
cmpl $0x1, (%rax)
je 0x1496
leaq 0x1b88(%rip), %rdi      # 0x3017
xorl %eax, %eax
callq 0x1664
movq %rbx, -0x40(%rbp)
movsd 0x4cce(%rip), %xmm1     # 0x6170
xorpd %xmm0, %xmm0
ucomisd %xmm1, %xmm0
jae 0x14bc
cvtsi2sdl 0x4(%r15), %xmm0
mulsd %xmm0, %xmm1
movl 0xc(%r15), %ebx
jmp 0x14ca
movl 0xc(%r15), %ebx
cvtsi2sd %ebx, %xmm1
cvtsi2sdl 0x4(%r15), %xmm0
mulsd 0x4c76(%rip), %xmm0     # 0x6148
cvttsd2si %xmm0, %r14d
movsd %xmm1, -0x50(%rbp)
cvttsd2si %xmm1, %eax
movl %eax, 0xc(%r15)
leaq 0x1b51(%rip), %rdx      # 0x303c
movq -0x30(%rbp), %rdi
movq %r15, %rsi
xorl %ecx, %ecx
callq 0x2764
movl %r14d, -0x34(%rbp)
movslq %r14d, %r12
movslq %ebx, %rax
movq %rax, -0x48(%rbp)
leaq (,%r12,4), %rbx
xorl %r14d, %r14d
xorl %r13d, %r13d
cvtsi2sd %r13d, %xmm0
movsd -0x50(%rbp), %xmm1
ucomisd %xmm0, %xmm1
jbe 0x159d
movl %r13d, %eax
cltd
idivl -0x34(%rbp)
movsd 0x4c1c(%rip), %xmm0     # 0x6150
cltq
xorl %ecx, %ecx
movq -0x48(%rbp), %rsi
movq %r14, %rdi
xorl %edx, %edx
movsd 0x1abf(%rip), %xmm1     # 0x3008
cmpq %rax, %rcx
jg 0x157f
cmpq %rsi, %r13
jge 0x1570
movq 0x18(%r15), %r8
movq (%r8), %r8
cvtsi2sdl (%r8,%rdi), %xmm2
cvtsi2sd %edx, %xmm3
mulsd %xmm1, %xmm2
addsd %xmm3, %xmm2
cvttsd2si %xmm2, %edx
mulsd %xmm0, %xmm1
incq %rcx
subq %rbx, %rdi
addq %r12, %rsi
jmp 0x1549
movq -0x30(%rbp), %rdi
leaq 0x1d5b(%rip), %rsi      # 0x32e5
xorl %eax, %eax
callq 0x1140
incq %r13
addq $0x4, %r14
jmp 0x1515
movq -0x40(%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
leaq 0x1b2c(%rip), %rdi      # 0x30f3
callq 0x1070
leaq 0x1b2e(%rip), %rdi      # 0x3101
callq 0x1070
movsd 0x4b70(%rip), %xmm0     # 0x6150
leaq 0x1a78(%rip), %rdi      # 0x305f
movb $0x1, %al
callq 0x10b0
leaq 0x1b36(%rip), %rdi      # 0x312b
callq 0x1070
movsd 0x4b46(%rip), %xmm0     # 0x6148
leaq 0x1a74(%rip), %rdi      # 0x307d
movb $0x1, %al
callq 0x10b0
leaq 0x1b3d(%rip), %rdi      # 0x3154
callq 0x1070
leaq 0x1b65(%rip), %rdi      # 0x3188
callq 0x1070
jmp 0x1646
movq 0x4b07(%rip), %rsi      # 0x6138
movq 0x4b08(%rip), %rdx      # 0x6140
leaq 0x1a11(%rip), %rdi      # 0x3050
xorl %eax, %eax
callq 0x10b0
xorl %edi, %edi
callq 0x1200
leaq 0x1a69(%rip), %rdi      # 0x30bd
callq 0x1070
pushq $-0x1
popq %rdi
callq 0x1200
nopl (%rax)