// File: /workspace/github_c_makefile_star2_O2/jonof[P]jfaudiolib/src/vorbis.c
// Function: MV_GetNextVorbisBlock
static playbackstatus MV_GetNextVorbisBlock
(
 VoiceNode *voice
 )

{
   vorbis_data * vd = (vorbis_data *) voice->extra;
   int bytes = 0, bytesread = 0;
   int bitstream = 0, err = 0;

   voice->Playing = TRUE;
   
   bytesread = 0;
   do {
      bytes = (int)ov_read(&vd->vf, vd->block + bytesread, sizeof(vd->block) - bytesread, 0, 2, 1, &bitstream);
      //ASS_Message("ov_read = %d\n", bytes);
      if (bytes == OV_HOLE) continue;
      if (bytes == 0) {
         if (voice->LoopCount) {
            err = ov_pcm_seek_page(&vd->vf, 0);
            if (err != 0) {
               ASS_Message("MV_GetNextVorbisBlock ov_pcm_seek_page: err %d\n", err);
            } else {
               continue;
            }
         } else {
           break;
         }
      } else if (bytes < 0) {
         ASS_Message("MV_GetNextVorbisBlock ov_read: err %d\n", bytes);
         voice->Playing = FALSE;
         return NoMoreData;
      }

      bytesread += bytes;
   } while (bytesread < (int)sizeof(vd->block));

   if (bytesread == 0) {
      voice->Playing = FALSE;
      return NoMoreData;
   }
      
   if (bitstream != vd->lastbitstream) {
      vorbis_info * vi = 0;
      
      vi = ov_info(&vd->vf, -1);
      if (!vi) {
         voice->Playing = FALSE;
         return NoMoreData;
      }
      
      if (vi->channels != 1 && vi->channels != 2) {
         voice->Playing = FALSE;
         return NoMoreData;
      }
      
      voice->channels = vi->channels;
      voice->SamplingRate = (unsigned)vi->rate;
      voice->RateScale    = ( voice->SamplingRate * voice->PitchScale ) / MV_MixRate;
      voice->FixedPointBufferSize = ( voice->RateScale * MixBufferSize ) -
         voice->RateScale;
      MV_SetVoiceMixMode( voice );
   }
   vd->lastbitstream = bitstream;
   
   bytesread /= 2 * voice->channels;
   
   voice->position    = 0;
   voice->sound       = vd->block;
   voice->BlockLength = 0;
   voice->length      = bytesread << 16;
   
   return( KeepPlaying );
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq 0x88(%rdi), %rax
leaq 0x1c(%rsp), %rcx
andl $0x0, (%rcx)
movq %rdi, 0x10(%rsp)
movl $0x1, 0x70(%rdi)
leaq 0x18(%rax), %r15
movq %rax, 0x20(%rsp)
leaq 0x3c8(%rax), %rbx
pushq $0x2
popq %r12
pushq $0x1
popq %rbp
xorl %r14d, %r14d
movslq %r14d, %rax
leaq (%rbx,%rax), %rsi
movl $0x8000, %edx           # imm = 0x8000
subl %eax, %edx
leaq 0x1c(%rsp), %rax
movq %rax, (%rsp)
movq %r15, %rdi
xorl %ecx, %ecx
movl %r12d, %r8d
movl %ebp, %r9d
callq 0x23d0
movq %rax, %r13
cmpl $-0x3, %r13d
je 0x63d3
testl %r13d, %r13d
jne 0x63ca
movq 0x10(%rsp), %rax
cmpl $0x0, 0x40(%rax)
je 0x6469
movq %r15, %rdi
xorl %esi, %esi
callq 0x2380
testl %eax, %eax
je 0x63d3
leaq 0x384e(%rip), %rdi      # 0x9c0d
movl %eax, %esi
xorl %eax, %eax
callq 0x813d
jmp 0x63d0
js 0x647f
addl %r13d, %r14d
cmpl $0x8000, %r14d          # imm = 0x8000
jl 0x6366
movl 0x1c(%rsp), %eax
movq 0x20(%rsp), %r12
cmpl 0x83c8(%r12), %eax
je 0x643c
pushq $-0x1
popq %rsi
movq %r15, %rdi
callq 0x2320
testq %rax, %rax
je 0x6472
movl 0x4(%rax), %ecx
leal -0x1(%rcx), %edx
cmpl $0x2, %edx
jae 0x6472
movq 0x10(%rsp), %rdi
movb %cl, 0x15(%rdi)
movl 0x8(%rax), %eax
movl %eax, 0x64(%rdi)
imull 0x4c(%rdi), %eax
leaq 0x120ed(%rip), %rcx     # 0x18510
xorl %edx, %edx
divl (%rcx)
movl %eax, 0x68(%rdi)
imull $0xff, %eax, %eax
movl %eax, 0x50(%rdi)
callq 0x3b4d
movl 0x1c(%rsp), %eax
movl %eax, 0x83c8(%r12)
movq 0x10(%rsp), %rsi
movsbl 0x15(%rsi), %ecx
addl %ecx, %ecx
movl %r14d, %eax
cltd
idivl %ecx
andl $0x0, 0x6c(%rsi)
movq %rbx, 0x58(%rsi)
andl $0x0, 0x48(%rsi)
shll $0x10, %eax
movl %eax, 0x60(%rsi)
jmp 0x649b
testl %r14d, %r14d
jne 0x63dc
movq 0x10(%rsp), %rax
andl $0x0, 0x70(%rax)
xorl %ebp, %ebp
jmp 0x649b
leaq 0x37b7(%rip), %rdi      # 0x9c3d
xorl %ebp, %ebp
movl %r13d, %esi
xorl %eax, %eax
callq 0x813d
movq 0x10(%rsp), %rax
andl $0x0, 0x70(%rax)
movl %ebp, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq