// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq 0x88(%rax), %rax
movq %rax, -0x18(%rbp)
movl $0x0, -0x1c(%rbp)
movl $0x0, -0x20(%rbp)
movl $0x0, -0x24(%rbp)
movl $0x0, -0x28(%rbp)
movq -0x10(%rbp), %rax
movl $0x1, 0x70(%rax)
movl $0x0, -0x20(%rbp)
movq -0x18(%rbp), %rdi
addq $0x18, %rdi
movq -0x18(%rbp), %rsi
addq $0x3c8, %rsi            # imm = 0x3C8
movslq -0x20(%rbp), %rax
addq %rax, %rsi
movslq -0x20(%rbp), %rcx
movl $0x8000, %eax           # imm = 0x8000
subq %rcx, %rax
movl %eax, %edx
xorl %ecx, %ecx
movl $0x2, %r8d
movl $0x1, %r9d
leaq -0x24(%rbp), %rax
movq %rax, (%rsp)
callq 0x23b0
movl %eax, -0x1c(%rbp)
cmpl $-0x3, -0x1c(%rbp)
jne 0xa097
jmp 0xa115
cmpl $0x0, -0x1c(%rbp)
jne 0xa0dc
movq -0x10(%rbp), %rax
cmpl $0x0, 0x40(%rax)
je 0xa0d8
movq -0x18(%rbp), %rdi
addq $0x18, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x2360
movl %eax, -0x28(%rbp)
cmpl $0x0, -0x28(%rbp)
je 0xa0d4
movl -0x28(%rbp), %esi
leaq 0x5650(%rip), %rdi      # 0xf71b
movb $0x0, %al
callq 0xd640
jmp 0xa0d6
jmp 0xa115
jmp 0xa0da
jmp 0xa122
jmp 0xa10c
cmpl $0x0, -0x1c(%rbp)
jge 0xa10a
movl -0x1c(%rbp), %esi
leaq 0x565f(%rip), %rdi      # 0xf74b
movb $0x0, %al
callq 0xd640
movq -0x10(%rbp), %rax
movl $0x0, 0x70(%rax)
movl $0x0, -0x4(%rbp)
jmp 0xa27b
jmp 0xa10c
movl -0x1c(%rbp), %eax
addl -0x20(%rbp), %eax
movl %eax, -0x20(%rbp)
cmpl $0x8000, -0x20(%rbp)    # imm = 0x8000
jl 0xa049
cmpl $0x0, -0x20(%rbp)
jne 0xa13f
movq -0x10(%rbp), %rax
movl $0x0, 0x70(%rax)
movl $0x0, -0x4(%rbp)
jmp 0xa27b
movl -0x24(%rbp), %eax
movq -0x18(%rbp), %rcx
cmpl 0x83c8(%rcx), %eax
je 0xa21e
movq $0x0, -0x30(%rbp)
movq -0x18(%rbp), %rdi
addq $0x18, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x2300
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
jne 0xa18e
movq -0x10(%rbp), %rax
movl $0x0, 0x70(%rax)
movl $0x0, -0x4(%rbp)
jmp 0xa27b
movq -0x30(%rbp), %rax
cmpl $0x1, 0x4(%rax)
je 0xa1b9
movq -0x30(%rbp), %rax
cmpl $0x2, 0x4(%rax)
je 0xa1b9
movq -0x10(%rbp), %rax
movl $0x0, 0x70(%rax)
movl $0x0, -0x4(%rbp)
jmp 0xa27b
movq -0x30(%rbp), %rax
movl 0x4(%rax), %eax
movb %al, %cl
movq -0x10(%rbp), %rax
movb %cl, 0x15(%rax)
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rax
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x64(%rax)
movq -0x10(%rbp), %rax
movl 0x64(%rax), %eax
movq -0x10(%rbp), %rcx
imull 0x4c(%rcx), %eax
leaq 0x14d44(%rip), %rcx     # 0x1ef34
xorl %edx, %edx
divl (%rcx)
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x68(%rax)
movq -0x10(%rbp), %rax
movl 0x68(%rax), %ecx
shll $0x8, %ecx
movq -0x10(%rbp), %rax
subl 0x68(%rax), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x50(%rax)
movq -0x10(%rbp), %rdi
callq 0x4f40
movl -0x24(%rbp), %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x83c8(%rax)
movq -0x10(%rbp), %rax
movsbl 0x15(%rax), %ecx
shll %ecx
movl -0x20(%rbp), %eax
cltd
idivl %ecx
movl %eax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movl $0x0, 0x6c(%rax)
movq -0x18(%rbp), %rcx
addq $0x3c8, %rcx            # imm = 0x3C8
movq -0x10(%rbp), %rax
movq %rcx, 0x58(%rax)
movq -0x10(%rbp), %rax
movl $0x0, 0x48(%rax)
movl -0x20(%rbp), %ecx
shll $0x10, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x60(%rax)
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)