// File: /workspace/github_c_makefile_star2_O1/pipde[P]deos-songlib/utils/correct/correct.c
// Function: repitch
static void
repitch(FILE *out,double rfactor)
    {
    int reached = 0;

    if (Factor == 0) Factor = rfactor;

    fprintf(stderr,"old factor is %f, new factor is %f\n",Factor,rfactor);
    //getchar();

    //if (rfactor == 1.0)
    //    Factor = rfactor;
    //else
    //    Factor = (Factor + rfactor) / 2;
    //Factor = (2 * Factor + rfactor) / 3.0;
    while (WindowSpot < WindowSize - 1)
        {
        //printf("Spot is %f, Factor is %f\n",WindowSpot,Factor);
        //getchar();
        fprintf(out,"%d\n",(int) interp3(Window,WindowSize,WindowSpot));
        --ExtraSamples;

        WindowSpot += Factor; 
        if (Factor < rfactor)
            {
            Factor *= GAIN;
            if (Factor >= rfactor)
                {
                Factor = rfactor;
                if (!reached)
                    {
                    fprintf(stderr,"repitch factor %f reached\n",rfactor);
                    reached = 1;
                    }
                }
            }
        else
            {
            Factor /= GAIN;
            if (Factor <= rfactor)
                {
                Factor = rfactor;
                if (!reached)
                    {
                    fprintf(stderr,"repitch factor %f reached\n",rfactor);
                    reached = 1;
                    }
                }
            }
        }

    if (!reached) fprintf(stderr,"repitch factor %f NOT reached\n",rfactor);
    if (!reached) fprintf(stderr,"current factor is %f\n",Factor);
    WindowSpot = WindowSpot - (int) WindowSpot;
    Window[0] = Window[WindowSize - 1];
    WindowStart = 1;
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movaps %xmm0, %xmm2
movq %rdi, %rbx
movsd 0xe0bc(%rip), %xmm0     # 0x11418
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x3370
jp 0x3370
movsd %xmm2, 0xe0a8(%rip)     # 0x11418
movq 0xbc81(%rip), %r12      # 0xeff8
movq (%r12), %rdi
movsd 0xe095(%rip), %xmm0     # 0x11418
leaq 0x70c3(%rip), %rsi      # 0xa44d
movsd %xmm2, -0x30(%rbp)
movaps %xmm2, %xmm1
movb $0x2, %al
callq 0x31e0
movsd 0xe07f(%rip), %xmm0     # 0x11420
movl 0xc599(%rip), %esi      # 0xf940
leal -0x1(%rsi), %eax
cvtsi2sd %eax, %xmm1
ucomisd %xmm0, %xmm1
jbe 0x34d4
leaq 0x7001(%rip), %r14      # 0xa3c0
pushq $0x1
popq %r15
xorl %r13d, %r13d
movq 0xe03b(%rip), %rdi      # 0x11408
callq 0x7025
movq %rbx, %rdi
movq %r14, %rsi
movl %eax, %edx
xorl %eax, %eax
callq 0x31e0
decl 0xc7fd(%rip)            # 0xfbe4
movsd 0xe029(%rip), %xmm0     # 0x11418
movsd 0xe029(%rip), %xmm1     # 0x11420
addsd %xmm0, %xmm1
movsd %xmm1, 0xe01d(%rip)     # 0x11420
movsd -0x30(%rbp), %xmm1
ucomisd %xmm0, %xmm1
jbe 0x3426
mulsd 0x6c0a(%rip), %xmm0     # 0xa020
movsd %xmm0, 0xdffa(%rip)     # 0x11418
ucomisd %xmm1, %xmm0
jae 0x343c
jmp 0x344c
divsd 0x6bf2(%rip), %xmm0     # 0xa020
movsd %xmm0, 0xdfe2(%rip)     # 0x11418
ucomisd %xmm0, %xmm1
jb 0x344c
movsd %xmm1, 0xdfd4(%rip)     # 0x11418
testl %r13d, %r13d
movl %r15d, %r13d
je 0x346d
movsd 0xdfcc(%rip), %xmm0     # 0x11420
movl 0xc4e6(%rip), %esi      # 0xf940
leal -0x1(%rsi), %eax
cvtsi2sd %eax, %xmm1
ucomisd %xmm0, %xmm1
ja 0x33c6
jmp 0x3489
movq (%r12), %rdi
leaq 0x6ff9(%rip), %rsi      # 0xa471
movsd -0x30(%rbp), %xmm0
movb $0x1, %al
callq 0x31e0
movl %r15d, %r13d
jmp 0x344c
testl %r13d, %r13d
je 0x34d4
movsd 0xdf8a(%rip), %xmm0     # 0x11420
cvttpd2dq %xmm0, %xmm1
cvtdq2pd %xmm1, %xmm1
subsd %xmm1, %xmm0
movsd %xmm0, 0xdf76(%rip)     # 0x11420
movq 0xdf57(%rip), %rax      # 0x11408
movslq 0xc488(%rip), %rcx      # 0xf940
movl -0x4(%rax,%rcx,4), %ecx
movl %ecx, (%rax)
movb $0x1, 0xdf4b(%rip)      # 0x11410
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq (%r12), %rdi
leaq 0x6fad(%rip), %rsi      # 0xa48c
movsd -0x30(%rbp), %xmm0
movb $0x1, %al
callq 0x31e0
movq (%r12), %rdi
movsd 0xdf21(%rip), %xmm0     # 0x11418
leaq 0x6fad(%rip), %rsi      # 0xa4ab
movb $0x1, %al
callq 0x31e0
jmp 0x348e