// File: /workspace/github_c_makefile_star2_O0/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
subq $0x60, %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 0x15b0
movl %eax, -0x14(%rbp)
movl -0x8(%rbp), %eax
subl -0x14(%rbp), %eax
cmpl $0x0, %eax
jne 0x1368
movq 0x6c8a(%rip), %rax      # 0x7fd8
movq (%rax), %rax
movq %rax, -0x20(%rbp)
movq 0x6c74(%rip), %rax      # 0x7fd0
movq (%rax), %rax
movq %rax, -0x28(%rbp)
jmp 0x1405
movl -0x8(%rbp), %eax
subl -0x14(%rbp), %eax
cmpl $0x1, %eax
jne 0x139f
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x42fa(%rip), %rsi      # 0x5680
callq 0x1190
movq %rax, -0x20(%rbp)
movq 0x6c3a(%rip), %rax      # 0x7fd0
movq (%rax), %rax
movq %rax, -0x28(%rbp)
jmp 0x1403
movl -0x8(%rbp), %eax
subl -0x14(%rbp), %eax
cmpl $0x2, %eax
jne 0x13e9
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x42c3(%rip), %rsi      # 0x5680
callq 0x1910
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movl -0x14(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x3c8f(%rip), %rsi      # 0x506d
callq 0x1910
movq %rax, -0x28(%rbp)
jmp 0x1401
leaq 0x3c7f(%rip), %rdi      # 0x506f
movb $0x0, %al
callq 0x1090
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x11d0
jmp 0x1403
jmp 0x1405
movq -0x20(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x2280
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
cmpl $0x1, (%rax)
je 0x142d
leaq 0x3c80(%rip), %rdi      # 0x50a6
movb $0x0, %al
callq 0x17c0
xorps %xmm0, %xmm0
ucomisd 0x6d18(%rip), %xmm0     # 0x8150
jb 0x144a
movq -0x30(%rbp), %rax
cvtsi2sdl 0xc(%rax), %xmm0
movsd %xmm0, -0x38(%rbp)
jmp 0x1464
movsd 0x6cfe(%rip), %xmm0     # 0x8150
movq -0x30(%rbp), %rax
cvtsi2sdl 0x4(%rax), %xmm1
mulsd %xmm1, %xmm0
movsd %xmm0, -0x38(%rbp)
movsd 0x6cbc(%rip), %xmm0     # 0x8128
movq -0x30(%rbp), %rax
cvtsi2sdl 0x4(%rax), %xmm1
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movl %eax, -0x3c(%rbp)
movq -0x30(%rbp), %rax
movl 0xc(%rax), %eax
movl %eax, -0x40(%rbp)
cvttsd2si -0x38(%rbp), %ecx
movq -0x30(%rbp), %rax
movl %ecx, 0xc(%rax)
movq -0x28(%rbp), %rdi
movq -0x30(%rbp), %rsi
leaq 0x3c26(%rip), %rdx      # 0x50cb
xorl %eax, %eax
movl %eax, %ecx
callq 0x3290
movl $0x0, -0x18(%rbp)
cvtsi2sdl -0x18(%rbp), %xmm1
movsd -0x38(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x158b
movl $0x0, -0x48(%rbp)
movsd 0x3b30(%rip), %xmm0     # 0x5008
movsd %xmm0, -0x50(%rbp)
movl $0x0, -0x44(%rbp)
movl -0x44(%rbp), %eax
movl %eax, -0x54(%rbp)
movl -0x18(%rbp), %eax
cltd
idivl -0x3c(%rbp)
movl %eax, %ecx
movl -0x54(%rbp), %eax
addl $0x1, %ecx
cmpl %ecx, %eax
jge 0x1568
movl -0x18(%rbp), %eax
movl -0x40(%rbp), %ecx
movl -0x44(%rbp), %edx
imull -0x3c(%rbp), %edx
addl %edx, %ecx
cmpl %ecx, %eax
jge 0x1548
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rax
movq (%rax), %rax
movl -0x18(%rbp), %ecx
movl -0x44(%rbp), %edx
imull -0x3c(%rbp), %edx
subl %edx, %ecx
movslq %ecx, %rcx
cvtsi2sdl (%rax,%rcx,4), %xmm0
movsd -0x50(%rbp), %xmm2
cvtsi2sdl -0x48(%rbp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movl %eax, -0x48(%rbp)
movsd 0x6be0(%rip), %xmm0     # 0x8130
mulsd -0x50(%rbp), %xmm0
movsd %xmm0, -0x50(%rbp)
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x14e4
movq -0x28(%rbp), %rdi
movl -0x48(%rbp), %edx
leaq 0x3d9f(%rip), %rsi      # 0x5315
movb $0x0, %al
callq 0x1110
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x14b5
movq -0x20(%rbp), %rdi
callq 0x1070
movq -0x28(%rbp), %rdi
callq 0x1070
xorl %eax, %eax
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)