// File: /workspace/github_c_makefile_star2_O0/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
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movsd %xmm0, -0x10(%rbp)
movl $0x0, -0x14(%rbp)
movsd 0x113a8(%rip), %xmm0    # 0x143e8
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x3058
jp 0x3058
movsd -0x10(%rbp), %xmm0
movsd %xmm0, 0x11390(%rip)    # 0x143e8
movq 0xef99(%rip), %rax      # 0x11ff8
movq (%rax), %rdi
movsd 0x1137e(%rip), %xmm0    # 0x143e8
movsd -0x10(%rbp), %xmm1
leaq 0xa42d(%rip), %rsi      # 0xd4a3
movb $0x2, %al
callq 0x21a0
movsd 0x1136b(%rip), %xmm1    # 0x143f0
movl 0xf885(%rip), %eax      # 0x12910
subl $0x1, %eax
cvtsi2sd %eax, %xmm0
ucomisd %xmm1, %xmm0
jbe 0x31dd
movq -0x8(%rbp), %rax
movq %rax, -0x20(%rbp)
movq 0x1132d(%rip), %rdi     # 0x143d8
movl 0xf85f(%rip), %esi      # 0x12910
movsd 0x11337(%rip), %xmm0    # 0x143f0
callq 0x6f00
movq -0x20(%rbp), %rdi
movl %eax, %edx
leaq 0xa34b(%rip), %rsi      # 0xd416
movb $0x0, %al
callq 0x21a0
movl 0xfadc(%rip), %eax      # 0x12bb4
addl $-0x1, %eax
movl %eax, 0xfad3(%rip)      # 0x12bb4
movsd 0x112ff(%rip), %xmm0    # 0x143e8
addsd 0x112ff(%rip), %xmm0    # 0x143f0
movsd %xmm0, 0x112f7(%rip)    # 0x143f0
movsd 0x112e7(%rip), %xmm1    # 0x143e8
movsd -0x10(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x316e
movsd 0x9f6c(%rip), %xmm0     # 0xd080
mulsd 0x112cc(%rip), %xmm0    # 0x143e8
movsd %xmm0, 0x112c4(%rip)    # 0x143e8
movsd 0x112bc(%rip), %xmm0    # 0x143e8
ucomisd -0x10(%rbp), %xmm0
jb 0x316c
movsd -0x10(%rbp), %xmm0
movsd %xmm0, 0x112a8(%rip)    # 0x143e8
cmpl $0x0, -0x14(%rbp)
jne 0x316a
movq 0xeeab(%rip), %rax      # 0x11ff8
movq (%rax), %rdi
movsd -0x10(%rbp), %xmm0
leaq 0xa36b(%rip), %rsi      # 0xd4c7
movb $0x1, %al
callq 0x21a0
movl $0x1, -0x14(%rbp)
jmp 0x316c
jmp 0x31d8
movsd 0x11272(%rip), %xmm0    # 0x143e8
movsd 0x9f02(%rip), %xmm1     # 0xd080
divsd %xmm1, %xmm0
movsd %xmm0, 0x1125e(%rip)    # 0x143e8
movsd 0x11256(%rip), %xmm1    # 0x143e8
movsd -0x10(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jb 0x31d6
movsd -0x10(%rbp), %xmm0
movsd %xmm0, 0x1123e(%rip)    # 0x143e8
cmpl $0x0, -0x14(%rbp)
jne 0x31d4
movq 0xee41(%rip), %rax      # 0x11ff8
movq (%rax), %rdi
movsd -0x10(%rbp), %xmm0
leaq 0xa301(%rip), %rsi      # 0xd4c7
movb $0x1, %al
callq 0x21a0
movl $0x1, -0x14(%rbp)
jmp 0x31d6
jmp 0x31d8
jmp 0x307d
cmpl $0x0, -0x14(%rbp)
jne 0x3200
movq 0xee0e(%rip), %rax      # 0x11ff8
movq (%rax), %rdi
movsd -0x10(%rbp), %xmm0
leaq 0xa2e9(%rip), %rsi      # 0xd4e2
movb $0x1, %al
callq 0x21a0
cmpl $0x0, -0x14(%rbp)
jne 0x3226
movq 0xedeb(%rip), %rax      # 0x11ff8
movq (%rax), %rdi
movsd 0x111d0(%rip), %xmm0    # 0x143e8
leaq 0xa2e2(%rip), %rsi      # 0xd501
movb $0x1, %al
callq 0x21a0
movsd 0x111c2(%rip), %xmm0    # 0x143f0
cvttsd2si 0x111ba(%rip), %eax # 0x143f0
cvtsi2sd %eax, %xmm1
subsd %xmm1, %xmm0
movsd %xmm0, 0x111aa(%rip)    # 0x143f0
movq 0x1118b(%rip), %rax     # 0x143d8
movl 0xf6bd(%rip), %ecx      # 0x12910
subl $0x1, %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %ecx
movq 0x11175(%rip), %rax     # 0x143d8
movl %ecx, (%rax)
movl $0x1, 0x11171(%rip)     # 0x143e0
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)