// File: /workspace/github_c_makefile_star2_O2/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
pushq $0x1
popq %r12
movslq %r12d, %r15
cmpl %r12d, %ebx
jle 0x13f6
movq (%r14,%r15,8), %rsi
cmpb $0x2d, (%rsi)
jne 0x13f6
movb 0x2(%rsi), %r13b
testb %r13b, %r13b
je 0x138a
leaq 0x2(%rsi), %rdi
jmp 0x138f
movq 0x8(%r14,%r15,8), %rdi
movzbl 0x1(%rsi), %eax
cmpl $0x72, %eax
je 0x13c2
cmpl $0x73, %eax
je 0x13cf
cmpl $0x68, %eax
je 0x1559
cmpl $0x76, %eax
je 0x15dc
xorl %r15d, %r15d
leaq 0x1ceb(%rip), %rdi      # 0x30a4
xorl %eax, %eax
callq 0x1614
jmp 0x13df
callq 0x11f0
movl %eax, 0x4d7b(%rip)      # 0x6148
jmp 0x13dc
callq 0x1080
movsd %xmm0, 0x4d74(%rip)     # 0x6150
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 0x1407
movq 0x4bd6(%rip), %rax      # 0x5fd8
movq (%rax), %rcx
jmp 0x1428
cmpl $0x2, %ebx
je 0x1434
cmpl $0x1, %ebx
jne 0x15ff
movq (%r14,%r15,8), %rdi
leaq 0x21da(%rip), %rsi      # 0x35fa
callq 0x11c0
movq %rax, %rcx
movq 0x4ba1(%rip), %rax      # 0x5fd0
movq (%rax), %r14
jmp 0x145e
movq (%r14,%r15,8), %rdi
leaq 0x21bb(%rip), %rsi      # 0x35fa
callq 0x1744
movq %rax, %rbx
movq 0x8(%r14,%r15,8), %rdi
leaq 0x1bb6(%rip), %rsi      # 0x3009
callq 0x1744
movq %rbx, %rcx
movq %rax, %r14
xorl %r12d, %r12d
movq %rcx, -0x38(%rbp)
movq %rcx, %rdi
xorl %esi, %esi
callq 0x1c11
movq %rax, %r15
movl 0xc(%rax), %ebx
cvtsi2sd %ebx, %xmm0
mulsd 0x4ccf(%rip), %xmm0     # 0x6150
cvttsd2si %xmm0, %r13d
leal (%rbx,%r13), %eax
imull 0x4cb7(%rip), %eax      # 0x6148
movl %eax, 0xc(%r15)
leaq 0x1b6f(%rip), %rdx      # 0x300b
movq %r14, %rdi
movq %r15, %rsi
xorl %ecx, %ecx
callq 0x2714
testl %ebx, %ebx
cmovlel %r12d, %ebx
movq %rbx, -0x48(%rbp)
testl %r13d, %r13d
cmovlel %r12d, %r13d
movq %r13, -0x40(%rbp)
leaq 0x1dd8(%rip), %r12      # 0x329d
xorl %eax, %eax
cmpl 0x4c7b(%rip), %eax      # 0x6148
jge 0x1537
movl %eax, -0x2c(%rbp)
xorl %r13d, %r13d
cmpq -0x48(%rbp), %r13
je 0x1508
xorl %ebx, %ebx
movslq (%r15), %rax
cmpq %rax, %rbx
jge 0x1503
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
jmp 0x14dd
incq %r13
jmp 0x14d5
xorl %r13d, %r13d
cmpl -0x40(%rbp), %r13d
je 0x1530
xorl %ebx, %ebx
cmpl (%r15), %ebx
jge 0x152b
movq %r14, %rdi
movq %r12, %rsi
xorl %edx, %edx
xorl %eax, %eax
callq 0x1140
incl %ebx
jmp 0x1513
incl %r13d
jmp 0x150b
movl -0x2c(%rbp), %eax
incl %eax
jmp 0x14c7
movq -0x38(%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 0x4bd8(%rip), %rsi      # 0x6138
leaq 0x1ac6(%rip), %rdi      # 0x302d
xorl %eax, %eax
callq 0x10b0
movq 0x4bc3(%rip), %rsi      # 0x6138
leaq 0x1abc(%rip), %rdi      # 0x3038
xorl %eax, %eax
callq 0x10b0
movq 0x4bae(%rip), %rsi      # 0x6138
leaq 0x1aca(%rip), %rdi      # 0x305b
xorl %eax, %eax
callq 0x10b0
leaq 0x1b55(%rip), %rdi      # 0x30f4
callq 0x1070
movl 0x4b9e(%rip), %esi      # 0x6148
leaq 0x1ab7(%rip), %rdi      # 0x3068
xorl %eax, %eax
callq 0x10b0
leaq 0x1b61(%rip), %rdi      # 0x3120
callq 0x1070
movsd 0x4b84(%rip), %xmm0     # 0x6150
leaq 0x1ab3(%rip), %rdi      # 0x3086
movb $0x1, %al
callq 0x10b0
jmp 0x15f8
movq 0x4b55(%rip), %rsi      # 0x6138
movq 0x4b56(%rip), %rdx      # 0x6140
leaq 0x1a2d(%rip), %rdi      # 0x301e
xorl %eax, %eax
callq 0x10b0
xorl %edi, %edi
callq 0x1200
leaq 0x1ab8(%rip), %rdi      # 0x30be
callq 0x1070
pushq $-0x1
popq %rdi
callq 0x1200
nop