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

    int i,j,k,spacing,oldSampleCount;
    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);
    oldSampleCount = h->samples;

    spacing = LengthFactor * h->samples;

    h->samples = Repeats * (h->samples + spacing);
    writeRRAHeader(out,h,"modifiedBy: repeat",0);

    for (i = 0; i < Repeats; ++i)
        {
        for (j = 0; j < oldSampleCount; ++j)
            {
            for (k = 0; k < h->channels; ++k)
                {
                fprintf(out,"%d\n",h->data[k][j]);
                }
            }
        for (j = 0; j < spacing; ++j)
            {
            for (k = 0; k < h->channels; ++k)
                {
                fprintf(out,"%d\n",0);
                }
            }
        }

    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 0x1679
movl $0x1, %r12d
movslq %r12d, %rax
movq (%r14,%rax,8), %rsi
cmpb $0x2d, (%rsi)
jne 0x1679
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 $0x72, %eax
jg 0x1623
jne 0x163a
callq 0x11f0
movl %eax, 0x5b27(%rip)      # 0x7148
jmp 0x1635
cmpl $0x73, %eax
jne 0x1644
callq 0x1080
movsd %xmm0, 0x5b1b(%rip)     # 0x7150
movb $0x1, %r15b
jmp 0x165e
cmpl $0x68, %eax
jne 0x164d
jmp 0x1813
cmpl $0x76, %eax
je 0x17f2
xorl %r15d, %r15d
leaq 0x2a4d(%rip), %rdi      # 0x40a4
xorl %eax, %eax
callq 0x18b4
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 0x168a
movq 0x5953(%rip), %rax      # 0x6fd8
movq (%rax), %r15
jmp 0x16ae
cmpl $0x2, %ebx
je 0x16ba
cmpl $0x1, %ebx
jne 0x189b
movslq %r12d, %rax
movq (%r14,%rax,8), %rdi
leaq 0x2f54(%rip), %rsi      # 0x45fa
callq 0x11c0
movq %rax, %r15
movq 0x591b(%rip), %rax      # 0x6fd0
movq (%rax), %r14
jmp 0x16e4
movslq %r12d, %rbx
movq (%r14,%rbx,8), %rdi
leaq 0x2f32(%rip), %rsi      # 0x45fa
callq 0x194e
movq %rax, %r15
movq 0x8(%r14,%rbx,8), %rdi
leaq 0x292d(%rip), %rsi      # 0x4009
callq 0x194e
movq %rax, %r14
movq %r15, -0x48(%rbp)
movq %r15, %rdi
xorl %esi, %esi
callq 0x1eb6
movq %rax, %r15
movl 0xc(%rax), %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
mulsd 0x5a49(%rip), %xmm0     # 0x7150
cvttsd2si %xmm0, %ecx
movq %rax, -0x40(%rbp)
movq %rcx, -0x38(%rbp)
addl %ecx, %eax
imull 0x5a2c(%rip), %eax      # 0x7148
movl %eax, 0xc(%r15)
leaq 0x28e4(%rip), %rdx      # 0x400b
movq %r14, %rdi
movq %r15, %rsi
xorl %ecx, %ecx
callq 0x2a80
cmpl $0x0, 0x5a0d(%rip)      # 0x7148
jle 0x17d0
leaq 0x2b55(%rip), %r12      # 0x429d
xorl %eax, %eax
movl %eax, -0x2c(%rbp)
cmpl $0x0, -0x40(%rbp)
jle 0x178c
movl (%r15), %eax
xorl %r13d, %r13d
testl %eax, %eax
jle 0x1783
xorl %ebx, %ebx
movq 0x18(%r15), %rax
movq (%rax,%rbx,8), %rax
movl (%rax,%r13,4), %edx
movq %r14, %rdi
movq %r12, %rsi
xorl %eax, %eax
callq 0x1140
incq %rbx
movslq (%r15), %rax
cmpq %rax, %rbx
jl 0x175f
incq %r13
cmpq -0x40(%rbp), %r13
jne 0x1759
cmpl $0x0, -0x38(%rbp)
jle 0x17bf
movl (%r15), %eax
xorl %r13d, %r13d
testl %eax, %eax
jle 0x17b6
xorl %ebx, %ebx
movq %r14, %rdi
movq %r12, %rsi
xorl %edx, %edx
xorl %eax, %eax
callq 0x1140
incl %ebx
movl (%r15), %eax
cmpl %eax, %ebx
jl 0x179e
incl %r13d
cmpl -0x38(%rbp), %r13d
jne 0x1798
movl -0x2c(%rbp), %eax
incl %eax
cmpl 0x597e(%rip), %eax      # 0x7148
jl 0x174a
movq -0x48(%rbp), %rdi
callq 0x1090
movq %r14, %rdi
callq 0x1090
xorl %eax, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x593f(%rip), %rsi      # 0x7138
movq 0x5940(%rip), %rdx      # 0x7140
leaq 0x2817(%rip), %rdi      # 0x401e
xorl %eax, %eax
callq 0x10b0
jmp 0x1894
movq 0x591e(%rip), %rsi      # 0x7138
leaq 0x280c(%rip), %rdi      # 0x402d
xorl %eax, %eax
callq 0x10b0
movq 0x5909(%rip), %rsi      # 0x7138
leaq 0x2802(%rip), %rdi      # 0x4038
xorl %eax, %eax
callq 0x10b0
movq 0x58f4(%rip), %rsi      # 0x7138
leaq 0x2810(%rip), %rdi      # 0x405b
xorl %eax, %eax
callq 0x10b0
leaq 0x289b(%rip), %rdi      # 0x40f4
callq 0x1070
movl 0x58e4(%rip), %esi      # 0x7148
leaq 0x27fd(%rip), %rdi      # 0x4068
xorl %eax, %eax
callq 0x10b0
leaq 0x28a7(%rip), %rdi      # 0x4120
callq 0x1070
movsd 0x58ca(%rip), %xmm0     # 0x7150
leaq 0x27f9(%rip), %rdi      # 0x4086
movb $0x1, %al
callq 0x10b0
xorl %edi, %edi
callq 0x1200
leaq 0x281c(%rip), %rdi      # 0x40be
callq 0x1070
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x1200
nopl (%rax)