// File: /workspace/github_c_makefile_star2_O3/jonof[P]jfaudiolib/src/multivoc.c
// Function: MV_PlayLoopedVOC
int MV_PlayLoopedVOC
   (
   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;

   (void)ptrlength;

   if ( !MV_Installed )
      {
      MV_SetErrorCode( MV_NotInstalled );
      return( MV_Error );
      }

   // Make sure it's a valid VOC file.
   status = memcmp( ptr, "Creative Voice File", 19 );
   if ( status != 0 )
      {
      MV_SetErrorCode( MV_InvalidVOCFile );
      return( MV_Error );
      }

   // Request a voice from the voice pool
   voice = MV_AllocVoice( priority );
   if ( voice == NULL )
      {
      MV_SetErrorCode( MV_NoVoices );
      return( MV_Error );
      }

   voice->wavetype    = VOC;
   voice->bits        = 8;
   voice->channels    = 1;
   voice->GetSound    = MV_GetNextVOCBlock;
   voice->NextBlock   = ptr + LITTLE16(*( unsigned short * )( ptr + 0x14 ));
   voice->DemandFeed  = NULL;
   voice->LoopStart   = NULL;
   voice->LoopCount   = 0;
   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   = ( char * )(intptr_t)loopstart;
   voice->LoopEnd     = ( char * )(intptr_t)loopend;
   voice->LoopSize    = loopend - loopstart + 1;

   if ( loopstart < 0 )
      {
      voice->LoopStart = NULL;
      voice->LoopEnd   = NULL;
      }

   MV_SetVoiceVolume( voice, vol, left, right );
   MV_PlayVoice( voice );

   return( voice->handle );
   }

// Assembly:
cmpl $0x0, 0xb51d(%rip)      # 0x102d0
je 0x4dff
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %r12
movdqu (%rdi), %xmm0
movdqu 0x3(%rdi), %xmm1
pcmpeqb 0x57cc(%rip), %xmm1     # 0xa5a0
pcmpeqb 0x55c4(%rip), %xmm0     # 0xa3a0
pand %xmm1, %xmm0
pmovmskb %xmm0, %eax
cmpl $0xffff, %eax           # imm = 0xFFFF
je 0x4e0f
movl $0x7, 0xb4df(%rip)      # 0x102d4
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x4ed9
movl $0x2, 0xb4cb(%rip)      # 0x102d4
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
retq
movl %r9d, %ebx
movl %r8d, %r13d
movl %ecx, %ebp
movl %edx, %r15d
movl 0x50(%rsp), %edi
callq 0x3a07
testq %rax, %rax
je 0x4ee8
movq %rax, %r14
movl $0x1, 0x10(%rax)
movw $0x108, 0x14(%rax)      # imm = 0x108
leaq 0xb4(%rip), %rax        # 0x4ef7
movq %rax, 0x18(%r14)
movzwl 0x14(%r12), %eax
addq %r12, %rax
movq %rax, 0x28(%r14)
xorl %r12d, %r12d
movq %r12, 0x80(%r14)
movq %r12, 0x30(%r14)
movl %r12d, 0x40(%r14)
movl %r12d, 0x48(%r14)
movl %r13d, %edi
callq 0x6520
movl %eax, 0x4c(%r14)
movl %r12d, 0x60(%r14)
pxor %xmm0, %xmm0
movdqu %xmm0, (%r14)
movl 0x50(%rsp), %eax
movl %eax, 0x7c(%r14)
movl 0x58(%rsp), %eax
movl %eax, 0xa0(%r14)
movslq %r15d, %rax
movq %rax, 0x30(%r14)
movslq %ebp, %rcx
movq %rcx, 0x38(%r14)
subl %eax, %ecx
incl %ecx
movl %ecx, 0x44(%r14)
testl %eax, %eax
jns 0x4ebb
movq %r14, %rax
addq $0x30, %rax
movdqu %xmm0, (%rax)
movq %r14, %rdi
movl %ebx, %esi
movl 0x40(%rsp), %edx
movl 0x48(%rsp), %ecx
callq 0x3e4d
movq %r14, %rdi
callq 0x360b
movl 0x78(%r14), %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x4, 0xb3e2(%rip)      # 0x102d4
jmp 0x4df5