// File: /workspace/github_c_makefile_star2_O0/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
subq $0x40, %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 0x1560
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, -0x30(%rbp)
movq 0x6c74(%rip), %rax      # 0x7fd0
movq (%rax), %rax
movq %rax, -0x38(%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 0x4292(%rip), %rsi      # 0x5618
callq 0x1190
movq %rax, -0x30(%rbp)
movq 0x6c3a(%rip), %rax      # 0x7fd0
movq (%rax), %rax
movq %rax, -0x38(%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 0x425b(%rip), %rsi      # 0x5618
callq 0x18b0
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rax
movl -0x14(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x3c67(%rip), %rsi      # 0x5045
callq 0x18b0
movq %rax, -0x38(%rbp)
jmp 0x1401
leaq 0x3c57(%rip), %rdi      # 0x5047
movb $0x0, %al
callq 0x1090
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x11d0
jmp 0x1403
jmp 0x1405
movq -0x30(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x2220
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
movl 0xc(%rax), %eax
movl %eax, -0x28(%rbp)
movsd 0x6d08(%rip), %xmm0     # 0x8130
movq -0x40(%rbp), %rax
cvtsi2sdl 0xc(%rax), %xmm1
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movl %eax, -0x24(%rbp)
movl 0x6ce6(%rip), %ecx      # 0x8128
movq -0x40(%rbp), %rax
movl 0xc(%rax), %eax
addl -0x24(%rbp), %eax
imull %eax, %ecx
movq -0x40(%rbp), %rax
movl %ecx, 0xc(%rax)
movq -0x38(%rbp), %rdi
movq -0x40(%rbp), %rsi
leaq 0x3c19(%rip), %rdx      # 0x507e
xorl %eax, %eax
movl %eax, %ecx
callq 0x3230
movl $0x0, -0x18(%rbp)
movl -0x18(%rbp), %eax
cmpl 0x6caa(%rip), %eax      # 0x8128
jge 0x1543
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
cmpl -0x28(%rbp), %eax
jge 0x14e6
movl $0x0, -0x20(%rbp)
movl -0x20(%rbp), %eax
movq -0x40(%rbp), %rcx
cmpl (%rcx), %eax
jge 0x14d9
movq -0x38(%rbp), %rdi
movq -0x40(%rbp), %rax
movq 0x18(%rax), %rax
movslq -0x20(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x1c(%rbp), %rcx
movl (%rax,%rcx,4), %edx
leaq 0x3de6(%rip), %rsi      # 0x52ad
movb $0x0, %al
callq 0x1110
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x149a
jmp 0x14db
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x148b
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
cmpl -0x24(%rbp), %eax
jge 0x1533
movl $0x0, -0x20(%rbp)
movl -0x20(%rbp), %eax
movq -0x40(%rbp), %rcx
cmpl (%rcx), %eax
jge 0x1526
movq -0x38(%rbp), %rdi
leaq 0x3d9b(%rip), %rsi      # 0x52ad
xorl %edx, %edx
movb $0x0, %al
callq 0x1110
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x14fc
jmp 0x1528
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x14ed
jmp 0x1535
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x1475
movq -0x30(%rbp), %rdi
callq 0x1070
movq -0x38(%rbp), %rdi
callq 0x1070
xorl %eax, %eax
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax)