// File: /workspace/github_c_makefile_star2_O0/waywardgeek[P]sonic/sonic.c
// Function: adjustRate
static int adjustRate(sonicStream stream, float rate,
                      int originalNumOutputSamples) {
  int newSampleRate = stream->sampleRate / rate;
  int oldSampleRate = stream->sampleRate;
  int numChannels = stream->numChannels;
  int position;
  short *in, *out;
  int i;
  int N = SINC_FILTER_POINTS;

  /* Set these values to help with the integer math */
  while (newSampleRate > (1 << 14) || oldSampleRate > (1 << 14)) {
    newSampleRate >>= 1;
    oldSampleRate >>= 1;
  }
  if (stream->numOutputSamples == originalNumOutputSamples) {
    return 1;
  }
  if (!moveNewSamplesToPitchBuffer(stream, originalNumOutputSamples)) {
    return 0;
  }
  /* Leave at least N pitch sample in the buffer */
  for (position = 0; position < stream->numPitchSamples - N; position++) {
    while ((stream->oldRatePosition + 1) * newSampleRate >
           stream->newRatePosition * oldSampleRate) {
      if (!enlargeOutputBufferIfNeeded(stream, 1)) {
        return 0;
      }
      out = stream->outputBuffer + stream->numOutputSamples * numChannels;
      in = stream->pitchBuffer + position * numChannels;
      for (i = 0; i < numChannels; i++) {
        *out++ = interpolate(stream, in, oldSampleRate, newSampleRate);
        in++;
      }
      stream->newRatePosition++;
      stream->numOutputSamples++;
    }
    stream->oldRatePosition++;
    if (stream->oldRatePosition == oldSampleRate) {
      stream->oldRatePosition = 0;
      stream->newRatePosition = 0;
    }
  }
  removePitchSamples(stream, position);
  return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movss %xmm0, -0x14(%rbp)
movl %esi, -0x18(%rbp)
movq -0x10(%rbp), %rax
cvtsi2ssl 0x7c(%rax), %xmm0
divss -0x14(%rbp), %xmm0
cvttss2si %xmm0, %eax
movl %eax, -0x1c(%rbp)
movq -0x10(%rbp), %rax
movl 0x7c(%rax), %eax
movl %eax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movl 0x50(%rax), %eax
movl %eax, -0x24(%rbp)
movl $0xc, -0x40(%rbp)
movb $0x1, %al
cmpl $0x4000, -0x1c(%rbp)    # imm = 0x4000
movb %al, -0x41(%rbp)
jg 0x2a8f
cmpl $0x4000, -0x20(%rbp)    # imm = 0x4000
setg %al
movb %al, -0x41(%rbp)
movb -0x41(%rbp), %al
testb $0x1, %al
jne 0x2a98
jmp 0x2aaa
movl -0x1c(%rbp), %eax
sarl %eax
movl %eax, -0x1c(%rbp)
movl -0x20(%rbp), %eax
sarl %eax
movl %eax, -0x20(%rbp)
jmp 0x2a74
movq -0x10(%rbp), %rax
movl 0x64(%rax), %eax
cmpl -0x18(%rbp), %eax
jne 0x2ac2
movl $0x1, -0x4(%rbp)
jmp 0x2c38
movq -0x10(%rbp), %rdi
movl -0x18(%rbp), %esi
callq 0x3760
cmpl $0x0, %eax
jne 0x2adf
movl $0x0, -0x4(%rbp)
jmp 0x2c38
movl $0x0, -0x28(%rbp)
movl -0x28(%rbp), %eax
movq -0x10(%rbp), %rcx
movl 0x68(%rcx), %ecx
subl -0x40(%rbp), %ecx
cmpl %ecx, %eax
jge 0x2c25
jmp 0x2afd
movq -0x10(%rbp), %rax
movl 0x44(%rax), %eax
addl $0x1, %eax
imull -0x1c(%rbp), %eax
movq -0x10(%rbp), %rcx
movl 0x48(%rcx), %ecx
imull -0x20(%rbp), %ecx
cmpl %ecx, %eax
jle 0x2be6
movq -0x10(%rbp), %rdi
movl $0x1, %esi
callq 0x3300
cmpl $0x0, %eax
jne 0x2b3d
movl $0x0, -0x4(%rbp)
jmp 0x2c38
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x10(%rbp), %rcx
movl 0x64(%rcx), %ecx
imull -0x24(%rbp), %ecx
movslq %ecx, %rcx
shlq %rcx
addq %rcx, %rax
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x28(%rbp), %ecx
imull -0x24(%rbp), %ecx
movslq %ecx, %rcx
shlq %rcx
addq %rcx, %rax
movq %rax, -0x30(%rbp)
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
cmpl -0x24(%rbp), %eax
jge 0x2bc7
movq -0x10(%rbp), %rdi
movq -0x30(%rbp), %rsi
movl -0x20(%rbp), %edx
movl -0x1c(%rbp), %ecx
callq 0x3850
movw %ax, %cx
movq -0x38(%rbp), %rax
movq %rax, %rdx
addq $0x2, %rdx
movq %rdx, -0x38(%rbp)
movw %cx, (%rax)
movq -0x30(%rbp), %rax
addq $0x2, %rax
movq %rax, -0x30(%rbp)
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x2b80
movq -0x10(%rbp), %rax
movl 0x48(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x48(%rax)
movq -0x10(%rbp), %rax
movl 0x64(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x64(%rax)
jmp 0x2afd
movq -0x10(%rbp), %rax
movl 0x44(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x44(%rax)
movq -0x10(%rbp), %rax
movl 0x44(%rax), %eax
cmpl -0x20(%rbp), %eax
jne 0x2c15
movq -0x10(%rbp), %rax
movl $0x0, 0x44(%rax)
movq -0x10(%rbp), %rax
movl $0x0, 0x48(%rax)
jmp 0x2c17
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x2ae6
movq -0x10(%rbp), %rdi
movl -0x28(%rbp), %esi
callq 0x3980
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)