// File: /workspace/github_c_makefile_star2_O0/jonof[P]jfaudiolib/src/vorbis.c
// Function: MV_PlayLoopedVorbis
int MV_PlayLoopedVorbis
(
 char *ptr,
 unsigned int ptrlength,
 int   loopstart,
 int   loopend,
 int   pitchoffset,
 int   vol,
 int   left,
 int   right,
 int   priority,
 unsigned int callbackval
 )

{
   VoiceNode   *voice;
   int          status;
   vorbis_data * vd = 0;
   vorbis_info * vi = 0;

   (void)loopend;

   if ( !MV_Installed )
   {
      MV_SetErrorCode( MV_NotInstalled );
      return( MV_Error );
   }
   
   vd = (vorbis_data *) malloc( sizeof(vorbis_data) );
   if (!vd) {
      MV_SetErrorCode( MV_InvalidVorbisFile );
      return MV_Error;
   }
   
   memset(vd, 0, sizeof(vorbis_data));
   vd->ptr = ptr;
   vd->pos = 0;
   vd->length = ptrlength;
   vd->lastbitstream = -1;
   
   status = ov_open_callbacks((void *) vd, &vd->vf, 0, 0, vorbis_callbacks);
   if (status < 0) {
      ASS_Message("MV_PlayLoopedVorbis: err %d\n", status);
      MV_SetErrorCode( MV_InvalidVorbisFile );
      return MV_Error;
   }
   
   vi = ov_info(&vd->vf, 0);
   if (!vi) {
      ov_clear(&vd->vf);
      free(vd);
      MV_SetErrorCode( MV_InvalidVorbisFile );
      return MV_Error;
   }
   
   if (vi->channels != 1 && vi->channels != 2) {
      ov_clear(&vd->vf);
      free(vd);
      MV_SetErrorCode( MV_InvalidVorbisFile );
      return MV_Error;
   }
   
   // Request a voice from the voice pool
   voice = MV_AllocVoice( priority );
   if ( voice == NULL )
   {
      ov_clear(&vd->vf);
      free(vd);
      MV_SetErrorCode( MV_NoVoices );
      return( MV_Error );
   }
   
   voice->wavetype    = Vorbis;
   voice->bits        = 16;
   voice->channels    = vi->channels;
   voice->extra       = (void *) vd;
   voice->GetSound    = MV_GetNextVorbisBlock;
   voice->NextBlock   = vd->block;
   voice->DemandFeed  = NULL;
   voice->LoopCount   = (loopstart >= 0 ? TRUE : FALSE);
   voice->BlockLength = 0;
   voice->PitchScale  = PITCH_GetScale( pitchoffset );
   voice->length      = 0;
   voice->next        = NULL;
   voice->prev        = NULL;
   voice->priority    = priority;
   voice->callbackval = callbackval;
   voice->LoopStart   = 0;
   voice->LoopEnd     = 0;
   voice->LoopSize    = 0;
   voice->Playing     = TRUE;
   voice->Paused      = FALSE;
   
   voice->SamplingRate = (unsigned)vi->rate;
   voice->RateScale    = ( voice->SamplingRate * voice->PitchScale ) / MV_MixRate;
   voice->FixedPointBufferSize = ( voice->RateScale * MixBufferSize ) -
      voice->RateScale;
   MV_SetVoiceMixMode( voice );

   MV_SetVoiceVolume( voice, vol, left, right );
   MV_PlayVoice( voice );
   
   return( voice->handle );
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movl 0x28(%rbp), %eax
movl 0x20(%rbp), %eax
movl 0x18(%rbp), %eax
movl 0x10(%rbp), %eax
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movl %edx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movl %r8d, -0x20(%rbp)
movl %r9d, -0x24(%rbp)
movq $0x0, -0x40(%rbp)
movq $0x0, -0x48(%rbp)
leaq 0xbff0(%rip), %rax      # 0x15c90
cmpl $0x0, (%rax)
jne 0x9cbe
leaq 0xbfe8(%rip), %rax      # 0x15c94
movl $0x2, (%rax)
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x9ff2
movl $0x83d0, %edi           # imm = 0x83D0
callq 0x2290
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
jne 0x9cec
leaq 0xbfba(%rip), %rax      # 0x15c94
movl $0x9, (%rax)
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x9ff2
movq -0x40(%rbp), %rdi
xorl %esi, %esi
movl $0x83d0, %edx           # imm = 0x83D0
callq 0x2100
movq -0x10(%rbp), %rcx
movq -0x40(%rbp), %rax
movq %rcx, (%rax)
movq -0x40(%rbp), %rax
movq $0x0, 0x10(%rax)
movl -0x14(%rbp), %eax
movl %eax, %ecx
movq -0x40(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x40(%rbp), %rax
movl $0xffffffff, 0x83c8(%rax) # imm = 0xFFFFFFFF
movq -0x40(%rbp), %rdi
movq -0x40(%rbp), %rsi
addq $0x18, %rsi
xorl %eax, %eax
movl %eax, %ecx
leaq 0xbeab(%rip), %rax      # 0x15bf0
movq %rcx, %rdx
movq (%rax), %r8
movq %r8, (%rsp)
movq 0x8(%rax), %r8
movq %r8, 0x8(%rsp)
movq 0x10(%rax), %r8
movq %r8, 0x10(%rsp)
movq 0x18(%rax), %rax
movq %rax, 0x18(%rsp)
callq 0x22c0
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
jge 0x9da2
movl -0x34(%rbp), %esi
leaq 0x597c(%rip), %rdi      # 0xf6fe
movb $0x0, %al
callq 0xd640
leaq 0xbf04(%rip), %rax      # 0x15c94
movl $0x9, (%rax)
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x9ff2
movq -0x40(%rbp), %rdi
addq $0x18, %rdi
xorl %esi, %esi
callq 0x2300
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
jne 0x9deb
movq -0x40(%rbp), %rdi
addq $0x18, %rdi
callq 0x2110
movq -0x40(%rbp), %rdi
callq 0x2270
leaq 0xbebb(%rip), %rax      # 0x15c94
movl $0x9, (%rax)
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x9ff2
movq -0x48(%rbp), %rax
cmpl $0x1, 0x4(%rax)
je 0x9e2e
movq -0x48(%rbp), %rax
cmpl $0x2, 0x4(%rax)
je 0x9e2e
movq -0x40(%rbp), %rdi
addq $0x18, %rdi
callq 0x2110
movq -0x40(%rbp), %rdi
callq 0x2270
leaq 0xbe78(%rip), %rax      # 0x15c94
movl $0x9, (%rax)
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x9ff2
movl 0x20(%rbp), %edi
callq 0x4af0
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
jne 0x9e70
movq -0x40(%rbp), %rdi
addq $0x18, %rdi
callq 0x2110
movq -0x40(%rbp), %rdi
callq 0x2270
leaq 0xbe36(%rip), %rax      # 0x15c94
movl $0x4, (%rax)
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x9ff2
movq -0x30(%rbp), %rax
movl $0x4, 0x10(%rax)
movq -0x30(%rbp), %rax
movb $0x10, 0x14(%rax)
movq -0x48(%rbp), %rax
movl 0x4(%rax), %eax
movb %al, %cl
movq -0x30(%rbp), %rax
movb %cl, 0x15(%rax)
movq -0x40(%rbp), %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x88(%rax)
movq -0x30(%rbp), %rax
leaq 0x153(%rip), %rcx       # 0xa000
movq %rcx, 0x18(%rax)
movq -0x40(%rbp), %rcx
addq $0x3c8, %rcx            # imm = 0x3C8
movq -0x30(%rbp), %rax
movq %rcx, 0x28(%rax)
movq -0x30(%rbp), %rax
movq $0x0, 0x80(%rax)
movl -0x18(%rbp), %edx
xorl %ecx, %ecx
movl $0x1, %eax
cmpl $0x0, %edx
cmovgel %eax, %ecx
movq -0x30(%rbp), %rax
movl %ecx, 0x40(%rax)
movq -0x30(%rbp), %rax
movl $0x0, 0x48(%rax)
movl -0x20(%rbp), %edi
callq 0x9990
movl %eax, %ecx
movq -0x30(%rbp), %rax
movl %ecx, 0x4c(%rax)
movq -0x30(%rbp), %rax
movl $0x0, 0x60(%rax)
movq -0x30(%rbp), %rax
movq $0x0, (%rax)
movq -0x30(%rbp), %rax
movq $0x0, 0x8(%rax)
movl 0x20(%rbp), %ecx
movq -0x30(%rbp), %rax
movl %ecx, 0x7c(%rax)
movl 0x28(%rbp), %ecx
movq -0x30(%rbp), %rax
movl %ecx, 0xa0(%rax)
movq -0x30(%rbp), %rax
movq $0x0, 0x30(%rax)
movq -0x30(%rbp), %rax
movq $0x0, 0x38(%rax)
movq -0x30(%rbp), %rax
movl $0x0, 0x44(%rax)
movq -0x30(%rbp), %rax
movl $0x1, 0x70(%rax)
movq -0x30(%rbp), %rax
movl $0x0, 0x74(%rax)
movq -0x48(%rbp), %rax
movq 0x8(%rax), %rax
movl %eax, %ecx
movq -0x30(%rbp), %rax
movl %ecx, 0x64(%rax)
movq -0x30(%rbp), %rax
movl 0x64(%rax), %eax
movq -0x30(%rbp), %rcx
imull 0x4c(%rcx), %eax
leaq 0x14f95(%rip), %rcx     # 0x1ef34
xorl %edx, %edx
divl (%rcx)
movl %eax, %ecx
movq -0x30(%rbp), %rax
movl %ecx, 0x68(%rax)
movq -0x30(%rbp), %rax
movl 0x68(%rax), %ecx
shll $0x8, %ecx
movq -0x30(%rbp), %rax
subl 0x68(%rax), %ecx
movq -0x30(%rbp), %rax
movl %ecx, 0x50(%rax)
movq -0x30(%rbp), %rdi
callq 0x4f40
movq -0x30(%rbp), %rdi
movl -0x24(%rbp), %esi
movl 0x10(%rbp), %edx
movl 0x18(%rbp), %ecx
callq 0x5220
movq -0x30(%rbp), %rdi
callq 0x45a0
movq -0x30(%rbp), %rax
movl 0x78(%rax), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x70, %rsp
popq %rbp
retq
nopl (%rax,%rax)