// File: /workspace/github_c_makefile_star2_O0/waywardgeek[P]sonic/sonic.c
// Function: sonicIntFlushStream
int sonicFlushStream(sonicStream stream) {
  int maxRequired = stream->maxRequired;
  int remainingSamples = stream->numInputSamples;
  float speed = stream->speed / stream->pitch;
  float rate = stream->rate * stream->pitch;
  int expectedOutputSamples =
      stream->numOutputSamples +
      (int)((remainingSamples / speed + stream->numPitchSamples) / rate + 0.5f);

  /* Add enough silence to flush both input and pitch buffers. */
  if (!enlargeInputBufferIfNeeded(stream, remainingSamples + 2 * maxRequired)) {
    return 0;
  }
  memset(stream->inputBuffer + remainingSamples * stream->numChannels, 0,
         2 * maxRequired * sizeof(short) * stream->numChannels);
  stream->numInputSamples += 2 * maxRequired;
  if (!sonicWriteShortToStream(stream, NULL, 0)) {
    return 0;
  }
  /* Throw away any extra samples we generated due to the silence we added */
  if (stream->numOutputSamples > expectedOutputSamples) {
    stream->numOutputSamples = expectedOutputSamples;
  }
  /* Empty input and pitch buffers */
  stream->numInputSamples = 0;
  stream->inputPlayTime = 0.0f;
  stream->timeError = 0.0f;
  stream->numPitchSamples = 0;
  return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movl 0x74(%rax), %eax
movl %eax, -0x14(%rbp)
movq -0x10(%rbp), %rax
movl 0x60(%rax), %eax
movl %eax, -0x18(%rbp)
movq -0x10(%rbp), %rax
movss 0x28(%rax), %xmm0
movq -0x10(%rbp), %rax
divss 0x30(%rax), %xmm0
movss %xmm0, -0x1c(%rbp)
movq -0x10(%rbp), %rax
movss 0x34(%rax), %xmm0
movq -0x10(%rbp), %rax
mulss 0x30(%rax), %xmm0
movss %xmm0, -0x20(%rbp)
movq -0x10(%rbp), %rax
movl 0x64(%rax), %eax
cvtsi2ssl -0x18(%rbp), %xmm0
divss -0x1c(%rbp), %xmm0
movq -0x10(%rbp), %rcx
cvtsi2ssl 0x68(%rcx), %xmm1
addss %xmm1, %xmm0
divss -0x20(%rbp), %xmm0
movss 0x319f(%rip), %xmm1     # 0x5018
addss %xmm1, %xmm0
cvttss2si %xmm0, %ecx
addl %ecx, %eax
movl %eax, -0x24(%rbp)
movq -0x10(%rbp), %rdi
movl -0x18(%rbp), %esi
movl -0x14(%rbp), %eax
shll %eax
addl %eax, %esi
callq 0x1f70
cmpl $0x0, %eax
jne 0x1eaa
movl $0x0, -0x4(%rbp)
jmp 0x1f59
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movl -0x18(%rbp), %eax
movq -0x10(%rbp), %rcx
imull 0x50(%rcx), %eax
cltq
shlq %rax
addq %rax, %rdi
movl -0x14(%rbp), %eax
shll %eax
movslq %eax, %rdx
shlq %rdx
movq -0x10(%rbp), %rax
movslq 0x50(%rax), %rax
imulq %rax, %rdx
xorl %esi, %esi
callq 0x10b0
movl -0x14(%rbp), %ecx
shll %ecx
movq -0x10(%rbp), %rax
addl 0x60(%rax), %ecx
movl %ecx, 0x60(%rax)
movq -0x10(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
xorl %edx, %edx
callq 0x1110
cmpl $0x0, %eax
jne 0x1f0e
movl $0x0, -0x4(%rbp)
jmp 0x1f59
movq -0x10(%rbp), %rax
movl 0x64(%rax), %eax
cmpl -0x24(%rbp), %eax
jle 0x1f24
movl -0x24(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x64(%rax)
movq -0x10(%rbp), %rax
movl $0x0, 0x60(%rax)
movq -0x10(%rbp), %rax
xorps %xmm0, %xmm0
movss %xmm0, 0x3c(%rax)
movq -0x10(%rbp), %rax
xorps %xmm0, %xmm0
movss %xmm0, 0x40(%rax)
movq -0x10(%rbp), %rax
movl $0x0, 0x68(%rax)
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)