// File: /workspace/github_c_makefile_star2_O0/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:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %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)
cmpl $0x0, 0xecf0(%rip)      # 0x15c90
jne 0x6fb8
movl $0x2, 0xece8(%rip)      # 0x15c94
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x713e
movq -0x10(%rbp), %rdi
leaq 0x8727(%rip), %rsi      # 0xf6ea
movl $0x13, %edx
callq 0x20e0
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
je 0x6fec
movl $0x7, 0xecb4(%rip)      # 0x15c94
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x713e
movl 0x20(%rbp), %edi
callq 0x4af0
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
jne 0x7015
movl $0x4, 0xec8b(%rip)      # 0x15c94
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x713e
movq -0x30(%rbp), %rax
movl $0x1, 0x10(%rax)
movq -0x30(%rbp), %rax
movb $0x8, 0x14(%rax)
movq -0x30(%rbp), %rax
movb $0x1, 0x15(%rax)
movq -0x30(%rbp), %rax
leaq 0x115(%rip), %rcx       # 0x7150
movq %rcx, 0x18(%rax)
movq -0x10(%rbp), %rcx
movq -0x10(%rbp), %rax
movzwl 0x14(%rax), %eax
cltq
addq %rax, %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x28(%rax)
movq -0x30(%rbp), %rax
movq $0x0, 0x80(%rax)
movq -0x30(%rbp), %rax
movq $0x0, 0x30(%rax)
movq -0x30(%rbp), %rax
movl $0x0, 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)
movslq -0x18(%rbp), %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x30(%rax)
movslq -0x1c(%rbp), %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x38(%rax)
movl -0x1c(%rbp), %ecx
subl -0x18(%rbp), %ecx
addl $0x1, %ecx
movq -0x30(%rbp), %rax
movl %ecx, 0x44(%rax)
cmpl $0x0, -0x18(%rbp)
jge 0x7119
movq -0x30(%rbp), %rax
movq $0x0, 0x30(%rax)
movq -0x30(%rbp), %rax
movq $0x0, 0x38(%rax)
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 $0x40, %rsp
popq %rbp
retq
nopw (%rax,%rax)