// File: /workspace/github_c_makefile_star2_O0/pipde[P]deos-songlib/utils/fixpitch/fixpitch.c
// Function: repitch
static void
repitch(FILE *out,int cycle,double factor,int note)
    {
    int i;
    int steps;
    double step,spot;

    //if (LastNote >= 0) fprintf(ReportFP,"last note was %s\n",notes[LastNote]);
    //fprintf(ReportFP,"factor was %f\n",factor);
    if (LastNote == 0)
        {
        LastNote = note;
        LastNoteCount = Lag;
        }
    else if (note == LastNote && LastNoteCount > 0)
        {
        factor = 1;
        --LastNoteCount;
        }
    else if (note != LastNote)
        {
        LastNote = note;
        LastNoteCount = Lag;
        factor = 1;
        }
    //fprintf(ReportFP,"factor now is %f\n",factor);

    steps =(int) (cycle / factor + 0.5);
    step = cycle / (double) steps;

    if (Report)
        fprintf(ReportFP,"repitching to %3s, from %d samples to %d samples, "
            "factor is %f\n",notes[note],cycle,steps,factor);

    fprintf(out,"%d\n",0);
    ++SamplesWritten;

    spot = step;
    for (i = 1; i < steps; ++i)
        {
        fprintf(out,"%d\n",(int) interpolate(spot));
        ++SamplesWritten;
        spot += step;
        }

    if (factor != 1.000)
        SamplesRepitched += cycle;
    SampleDelta += (cycle - steps);
    assert((int)(spot+0.5) == cycle);
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movsd %xmm0, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
cmpl $0x0, 0x76ce(%rip)      # 0xa8dc
jne 0x3227
movl -0x1c(%rbp), %eax
movl %eax, 0x76c3(%rip)      # 0xa8dc
movl 0x76c9(%rip), %eax      # 0xa8e8
movl %eax, 0x7f4b(%rip)      # 0xb170
jmp 0x328a
movl -0x1c(%rbp), %eax
cmpl 0x76ac(%rip), %eax      # 0xa8dc
jne 0x3259
cmpl $0x0, 0x7f37(%rip)      # 0xb170
jle 0x3259
movsd 0x3dc5(%rip), %xmm0     # 0x7008
movsd %xmm0, -0x18(%rbp)
movl 0x7f22(%rip), %eax      # 0xb170
addl $-0x1, %eax
movl %eax, 0x7f19(%rip)      # 0xb170
jmp 0x3288
movl -0x1c(%rbp), %eax
cmpl 0x767a(%rip), %eax      # 0xa8dc
je 0x3286
movl -0x1c(%rbp), %eax
movl %eax, 0x766f(%rip)      # 0xa8dc
movl 0x7675(%rip), %eax      # 0xa8e8
movl %eax, 0x7ef7(%rip)      # 0xb170
movsd 0x3d87(%rip), %xmm0     # 0x7008
movsd %xmm0, -0x18(%rbp)
jmp 0x3288
jmp 0x328a
cvtsi2sdl -0xc(%rbp), %xmm0
divsd -0x18(%rbp), %xmm0
movsd 0x3da4(%rip), %xmm1     # 0x7040
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movl %eax, -0x24(%rbp)
cvtsi2sdl -0xc(%rbp), %xmm0
cvtsi2sdl -0x24(%rbp), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0x30(%rbp)
cmpl $0x0, 0x7653(%rip)      # 0xa914
je 0x32f3
movq 0x764e(%rip), %rdi      # 0xa918
movslq -0x1c(%rbp), %rcx
leaq 0x71cb(%rip), %rax      # 0xa4a0
movq (%rax,%rcx,8), %rdx
movl -0xc(%rbp), %ecx
movl -0x24(%rbp), %r8d
movsd -0x18(%rbp), %xmm0
leaq 0x4351(%rip), %rsi      # 0x763d
movb $0x1, %al
callq 0x2130
movq -0x8(%rbp), %rdi
leaq 0x4927(%rip), %rsi      # 0x7c25
xorl %edx, %edx
movb $0x0, %al
callq 0x2130
movl 0x7647(%rip), %eax      # 0xa954
addl $0x1, %eax
movl %eax, 0x763e(%rip)      # 0xa954
movsd -0x30(%rbp), %xmm0
movsd %xmm0, -0x38(%rbp)
movl $0x1, -0x20(%rbp)
movl -0x20(%rbp), %eax
cmpl -0x24(%rbp), %eax
jge 0x337e
movq -0x8(%rbp), %rax
movq %rax, -0x40(%rbp)
movsd -0x38(%rbp), %xmm0
callq 0x3ad0
movq -0x40(%rbp), %rdi
movl %eax, %edx
leaq 0x48d7(%rip), %rsi      # 0x7c25
movb $0x0, %al
callq 0x2130
movl 0x75f9(%rip), %eax      # 0xa954
addl $0x1, %eax
movl %eax, 0x75f0(%rip)      # 0xa954
movsd -0x30(%rbp), %xmm0
addsd -0x38(%rbp), %xmm0
movsd %xmm0, -0x38(%rbp)
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x3327
movsd -0x18(%rbp), %xmm0
movsd 0x3c7d(%rip), %xmm1     # 0x7008
ucomisd %xmm1, %xmm0
jne 0x3395
jp 0x3395
jmp 0x33a4
movl -0xc(%rbp), %eax
addl 0x75ba(%rip), %eax      # 0xa958
movl %eax, 0x75b4(%rip)      # 0xa958
movl -0xc(%rbp), %eax
subl -0x24(%rbp), %eax
addl 0x75ac(%rip), %eax      # 0xa95c
movl %eax, 0x75a6(%rip)      # 0xa95c
movsd 0x3c82(%rip), %xmm0     # 0x7040
addsd -0x38(%rbp), %xmm0
cvttsd2si %xmm0, %eax
cmpl -0xc(%rbp), %eax
jne 0x33ce
jmp 0x33ed
leaq 0x42a8(%rip), %rdi      # 0x767d
leaq 0x3ff9(%rip), %rsi      # 0x73d5
movl $0x2aa, %edx            # imm = 0x2AA
leaq 0x42ae(%rip), %rcx      # 0x7696
callq 0x20c0
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)