// File: /workspace/github_c_makefile_star2_O0/pipde[P]deos-songlib/utils/fixpitch/fixpitch.c
// Function: advance
static void
advance(FILE *in,FILE *out,RRA *h)
    {
    int i;
    int start = SamplesWritten;
    int more = replace(in,out,h);
    int thresholdReached = 0;
    int peak = 0;

    //printf("advancing\n");
    while (more && !(thresholdReached && peek(0) == 0 && peek(1) > 0))
        {
        if (abs(peek(0)) > peak) peak = abs(peek(0));
        if (thresholdReached == 0 && peak > AbsoluteThreshold)
            thresholdReached = 1;
        //printf("while advancing, first amp is %d\n",peek(0));
        //printf("while advancing, second amp is %d\n",peek(1));
        //printf("while advancing, thresholdReached is %d\n",thresholdReached);
        more = replace(in,out,h);
        }

    //printf("after advance, first amp is %d\n",peek(0));
    //printf("after advance, second amp is %d\n",peek(1));
    //printf("more: %d\n",more);
    //printf("thresholdReached: %d\n",thresholdReached);

    if (!more)
        {
        //printf("dumping the window, stored = %d\n",SamplesStored);
        int count = SamplesStored;
        for (i = 0; i < count; ++i)
            replace(in,out,h);
        //printf("done dumping the window, stored = %d\n",SamplesStored);
        }

    if (Report)
        fprintf(ReportFP,"no repitching of cycle with length %d, peak was %d\n",
            SamplesWritten - start,peak);
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl 0x7aca(%rip), %eax      # 0xa954
movl %eax, -0x20(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
callq 0x3520
movl %eax, -0x24(%rbp)
movl $0x0, -0x28(%rbp)
movl $0x0, -0x2c(%rbp)
xorl %eax, %eax
cmpl $0x0, -0x24(%rbp)
movb %al, -0x31(%rbp)
je 0x2ef3
xorl %eax, %eax
cmpl $0x0, -0x28(%rbp)
movb %al, -0x32(%rbp)
je 0x2eeb
xorl %edi, %edi
callq 0x2fc0
movl %eax, %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x32(%rbp)
jne 0x2eeb
movl $0x1, %edi
callq 0x2fc0
cmpl $0x0, %eax
setg %al
movb %al, -0x32(%rbp)
movb -0x32(%rbp), %al
xorb $-0x1, %al
movb %al, -0x31(%rbp)
movb -0x31(%rbp), %al
testb $0x1, %al
jne 0x2efc
jmp 0x2f51
xorl %edi, %edi
callq 0x2fc0
movl %eax, %ecx
negl %ecx
cmovnsl %ecx, %eax
cmpl -0x2c(%rbp), %eax
jle 0x2f20
xorl %edi, %edi
callq 0x2fc0
movl %eax, %ecx
negl %ecx
cmovnsl %ecx, %eax
movl %eax, -0x2c(%rbp)
cmpl $0x0, -0x28(%rbp)
jne 0x2f38
movl -0x2c(%rbp), %eax
cmpl 0x7a0d(%rip), %eax      # 0xa93c
jle 0x2f38
movl $0x1, -0x28(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
callq 0x3520
movl %eax, -0x24(%rbp)
jmp 0x2eaf
cmpl $0x0, -0x24(%rbp)
jne 0x2f8d
movl 0x7a03(%rip), %eax      # 0xa960
movl %eax, -0x30(%rbp)
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
cmpl -0x30(%rbp), %eax
jge 0x2f8b
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
callq 0x3520
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x2f67
jmp 0x2f8d
cmpl $0x0, 0x7980(%rip)      # 0xa914
je 0x2fb7
movq 0x797b(%rip), %rdi      # 0xa918
movl 0x79b1(%rip), %edx      # 0xa954
subl -0x20(%rbp), %edx
movl -0x2c(%rbp), %ecx
leaq 0x4508(%rip), %rsi      # 0x74b8
movb $0x0, %al
callq 0x2130
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax)