// File: /workspace/github_c_makefile_star2_O1/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 0x1649
movl $0x1, %r12d
movslq %r12d, %rax
movq (%r14,%rax,8), %rsi
cmpb $0x2d, (%rsi)
jne 0x1649
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 $0x72, %eax
jg 0x15f3
jne 0x160a
callq 0x11f0
movl %eax, 0x5b57(%rip)      # 0x7148
jmp 0x1605
cmpl $0x73, %eax
jne 0x1614
callq 0x1080
movsd %xmm0, 0x5b4b(%rip)     # 0x7150
movb $0x1, %r15b
jmp 0x162e
cmpl $0x68, %eax
jne 0x161d
jmp 0x17db
cmpl $0x76, %eax
je 0x17ba
xorl %r15d, %r15d
leaq 0x2a7d(%rip), %rdi      # 0x40a4
xorl %eax, %eax
callq 0x187c
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 0x165a
movq 0x5983(%rip), %rax      # 0x6fd8
movq (%rax), %r15
jmp 0x167e
cmpl $0x2, %ebx
je 0x168a
cmpl $0x1, %ebx
jne 0x1863
movslq %r12d, %rax
movq (%r14,%rax,8), %rdi
leaq 0x2f87(%rip), %rsi      # 0x45fd
callq 0x11c0
movq %rax, %r15
movq 0x594b(%rip), %rax      # 0x6fd0
movq (%rax), %r14
jmp 0x16b4
movslq %r12d, %rbx
movq (%r14,%rbx,8), %rdi
leaq 0x2f65(%rip), %rsi      # 0x45fd
callq 0x1916
movq %rax, %r15
movq 0x8(%r14,%rbx,8), %rdi
leaq 0x295d(%rip), %rsi      # 0x4009
callq 0x1916
movq %rax, %r14
movq %r15, -0x48(%rbp)
movq %r15, %rdi
xorl %esi, %esi
callq 0x1e82
movq %rax, %r15
movl 0xc(%rax), %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
mulsd 0x5a79(%rip), %xmm0     # 0x7150
cvttsd2si %xmm0, %ecx
movq %rax, -0x40(%rbp)
movq %rcx, -0x38(%rbp)
addl %ecx, %eax
imull 0x5a5c(%rip), %eax      # 0x7148
movl %eax, 0xc(%r15)
leaq 0x2914(%rip), %rdx      # 0x400b
movq %r14, %rdi
movq %r15, %rsi
xorl %ecx, %ecx
callq 0x29f1
cmpl $0x0, 0x5a3d(%rip)      # 0x7148
jle 0x1798
leaq 0x2b85(%rip), %r12      # 0x429d
xorl %eax, %eax
movl %eax, -0x2c(%rbp)
cmpl $0x0, -0x40(%rbp)
jle 0x175b
xorl %r13d, %r13d
cmpl $0x0, (%r15)
jle 0x1752
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 0x172e
incq %r13
cmpq -0x40(%rbp), %r13
jne 0x1726
cmpl $0x0, -0x38(%rbp)
jle 0x178b
xorl %r13d, %r13d
cmpl $0x0, (%r15)
jle 0x1782
xorl %ebx, %ebx
movq %r14, %rdi
movq %r12, %rsi
xorl %edx, %edx
xorl %eax, %eax
callq 0x1140
incl %ebx
cmpl (%r15), %ebx
jl 0x176c
incl %r13d
cmpl -0x38(%rbp), %r13d
jne 0x1764
movl -0x2c(%rbp), %eax
incl %eax
cmpl 0x59b2(%rip), %eax      # 0x7148
jl 0x171a
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 0x5977(%rip), %rsi      # 0x7138
movq 0x5978(%rip), %rdx      # 0x7140
leaq 0x284f(%rip), %rdi      # 0x401e
xorl %eax, %eax
callq 0x10b0
jmp 0x185c
movq 0x5956(%rip), %rsi      # 0x7138
leaq 0x2844(%rip), %rdi      # 0x402d
xorl %eax, %eax
callq 0x10b0
movq 0x5941(%rip), %rsi      # 0x7138
leaq 0x283a(%rip), %rdi      # 0x4038
xorl %eax, %eax
callq 0x10b0
movq 0x592c(%rip), %rsi      # 0x7138
leaq 0x2848(%rip), %rdi      # 0x405b
xorl %eax, %eax
callq 0x10b0
leaq 0x28d3(%rip), %rdi      # 0x40f4
callq 0x1070
movl 0x591c(%rip), %esi      # 0x7148
leaq 0x2835(%rip), %rdi      # 0x4068
xorl %eax, %eax
callq 0x10b0
leaq 0x28df(%rip), %rdi      # 0x4120
callq 0x1070
movsd 0x5902(%rip), %xmm0     # 0x7150
leaq 0x2831(%rip), %rdi      # 0x4086
movb $0x1, %al
callq 0x10b0
xorl %edi, %edi
callq 0x1200
leaq 0x2854(%rip), %rdi      # 0x40be
callq 0x1070
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x1200
nopl (%rax)