// File: /workspace/github_c_makefile_star2_O0/jonof[P]jfaudiolib/src/multivoc.c
// Function: MV_ServiceVoc
static void MV_ServiceVoc
   (
   void
   )

   {
   VoiceNode *voice;
   VoiceNode *next;
   //int        flags;

   // Toggle which buffer we'll mix next
   MV_MixPage++;
   if ( MV_MixPage >= MV_NumberOfBuffers )
      {
      MV_MixPage -= MV_NumberOfBuffers;
      }

   if ( MV_ReverbLevel == 0 )
      {
      // Initialize buffer
      //Commented out so that the buffer is always cleared.
      //This is so the guys at Echo Speech can mix into the
      //buffer even when no sounds are playing.
      //if ( !MV_BufferEmpty[ MV_MixPage ] )
         {
         ClearBuffer_DW( MV_MixBuffer[ MV_MixPage ], MV_Silence, MV_BufferSize >> 2 );
         MV_BufferEmpty[ MV_MixPage ] = TRUE;
         }
      }
   else
      {
      char *end;
      char *source;
      char *dest;
      unsigned int   count;
      unsigned int   length;

      end = MV_MixBuffer[ 0 ] + MV_BufferLength;;
      dest = MV_MixBuffer[ MV_MixPage ];
      source = MV_MixBuffer[ MV_MixPage ] - MV_ReverbDelay;
      if ( source < MV_MixBuffer[ 0 ] )
         {
         source += MV_BufferLength;
         }

      length = MV_BufferSize;
      while( length > 0 )
         {
         count = length;
         if ( source + count > end )
            {
            count = (unsigned int)(end - source);
            }

         if ( MV_Bits == 16 )
            {
            if ( MV_ReverbTable != NULL )
               {
               MV_16BitReverb( source, dest, MV_ReverbTable, count / 2 );
               }
            else
               {
               MV_16BitReverbFast( source, dest, count / 2, MV_ReverbLevel );
               }
            }
         else
            {
            if ( MV_ReverbTable != NULL )
               {
               MV_8BitReverb( (signed char *) source, (signed char *) dest, MV_ReverbTable, count );
               }
            else
               {
               MV_8BitReverbFast( (signed char *) source, (signed char *) dest, count, MV_ReverbLevel );
               }
            }

         // if we go through the loop again, it means that we've wrapped around the buffer
         source  = MV_MixBuffer[ 0 ];
         dest   += count;
         length -= count;
         }
      }

   // Play any waiting voices
   //flags = DisableInterrupts();

   for( voice = VoiceList.next; voice != &VoiceList; voice = next )
      {
      if ( voice->Paused )
         {
         next = voice->next;
         continue;
         }

      MV_BufferEmpty[ MV_MixPage ] = FALSE;

      MV_MixFunction( voice, MV_MixPage );

      next = voice->next;

      // Is this voice done?
      if ( !voice->Playing )
         {
         //JBF: prevent a deadlock caused by MV_StopVoice grabbing the mutex again
         //MV_StopVoice( voice );
         LL_Remove( voice, next, prev );
         LL_Add( (VoiceNode*) &VoicePool, voice, next, prev );

         if ( MV_CallBackFunc )
            {
            MV_CallBackFunc( voice->callbackval );
            }
         }
      }

   //RestoreInterrupts(flags);
   }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movl 0x193e2(%rip), %eax     # 0x1ef20
addl $0x1, %eax
movl %eax, 0x193d9(%rip)     # 0x1ef20
movl 0x193d3(%rip), %eax     # 0x1ef20
cmpl 0xfbd9(%rip), %eax      # 0x1572c
jl 0x5b69
movl 0xfbd1(%rip), %ecx      # 0x1572c
movl 0x193bf(%rip), %eax     # 0x1ef20
subl %ecx, %eax
movl %eax, 0x193b7(%rip)     # 0x1ef20
cmpl $0x0, 0x192b0(%rip)     # 0x1ee20
jne 0x5bb2
movslq 0x193a7(%rip), %rcx     # 0x1ef20
leaq 0x192d0(%rip), %rax     # 0x1ee50
movq (%rax,%rcx,8), %rdi
movl 0xfba6(%rip), %esi      # 0x15730
movl 0xfba4(%rip), %edx      # 0x15734
shrl $0x2, %edx
callq 0x8150
movslq 0x19381(%rip), %rcx     # 0x1ef20
leaq 0x1933a(%rip), %rax     # 0x1eee0
movl $0x1, (%rax,%rcx,4)
jmp 0x5d08
movq 0x19297(%rip), %rax     # 0x1ee50
movl 0x1927d(%rip), %ecx     # 0x1ee3c
addq %rcx, %rax
movq %rax, -0x18(%rbp)
movslq 0x19353(%rip), %rcx     # 0x1ef20
leaq 0x1927c(%rip), %rax     # 0x1ee50
movq (%rax,%rcx,8), %rax
movq %rax, -0x28(%rbp)
movslq 0x1933d(%rip), %rcx     # 0x1ef20
leaq 0x19266(%rip), %rax     # 0x1ee50
movq (%rax,%rcx,8), %rax
movslq 0x1923b(%rip), %rdx     # 0x1ee30
xorl %ecx, %ecx
subq %rdx, %rcx
addq %rcx, %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
cmpq 0x19244(%rip), %rax     # 0x1ee50
jae 0x5c21
movl 0x19228(%rip), %ecx     # 0x1ee3c
movq -0x20(%rbp), %rax
movl %ecx, %ecx
addq %rcx, %rax
movq %rax, -0x20(%rbp)
movl 0xfb0d(%rip), %eax      # 0x15734
movl %eax, -0x30(%rbp)
cmpl $0x0, -0x30(%rbp)
jbe 0x5d06
movl -0x30(%rbp), %eax
movl %eax, -0x2c(%rbp)
movq -0x20(%rbp), %rax
movl -0x2c(%rbp), %ecx
addq %rcx, %rax
cmpq -0x18(%rbp), %rax
jbe 0x5c58
movq -0x18(%rbp), %rax
movq -0x20(%rbp), %rcx
subq %rcx, %rax
movl %eax, -0x2c(%rbp)
cmpl $0x10, 0xfac5(%rip)     # 0x15724
jne 0x5ca0
cmpq $0x0, 0x191bf(%rip)     # 0x1ee28
je 0x5c86
movq -0x20(%rbp), %rdi
movq -0x28(%rbp), %rsi
movq 0x191ae(%rip), %rdx     # 0x1ee28
movl -0x2c(%rbp), %ecx
shrl %ecx
callq 0x8bb0
jmp 0x5c9e
movq -0x20(%rbp), %rdi
movq -0x28(%rbp), %rsi
movl -0x2c(%rbp), %edx
shrl %edx
movl 0x19187(%rip), %ecx     # 0x1ee20
callq 0x8ce0
jmp 0x5cdb
cmpq $0x0, 0x19180(%rip)     # 0x1ee28
je 0x5cc3
movq -0x20(%rbp), %rdi
movq -0x28(%rbp), %rsi
movq 0x1916f(%rip), %rdx     # 0x1ee28
movl -0x2c(%rbp), %ecx
callq 0x8c70
jmp 0x5cd9
movq -0x20(%rbp), %rdi
movq -0x28(%rbp), %rsi
movl -0x2c(%rbp), %edx
movl 0x1914c(%rip), %ecx     # 0x1ee20
callq 0x8d50
jmp 0x5cdb
movq 0x1916e(%rip), %rax     # 0x1ee50
movq %rax, -0x20(%rbp)
movl -0x2c(%rbp), %ecx
movq -0x28(%rbp), %rax
movl %ecx, %ecx
addq %rcx, %rax
movq %rax, -0x28(%rbp)
movl -0x2c(%rbp), %ecx
movl -0x30(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x30(%rbp)
jmp 0x5c2a
jmp 0x5d08
movq 0xff89(%rip), %rax      # 0x15c98
movq %rax, -0x8(%rbp)
leaq 0xff7e(%rip), %rax      # 0x15c98
cmpq %rax, -0x8(%rbp)
je 0x5e1f
movq -0x8(%rbp), %rax
cmpl $0x0, 0x74(%rax)
je 0x5d3e
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x10(%rbp)
jmp 0x5e12
movslq 0x191db(%rip), %rcx     # 0x1ef20
leaq 0x19194(%rip), %rax     # 0x1eee0
movl $0x0, (%rax,%rcx,4)
movq 0x191ce(%rip), %rax     # 0x1ef28
movq -0x8(%rbp), %rdi
movl 0x191bc(%rip), %esi     # 0x1ef20
callq *%rax
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x10(%rbp)
movq -0x8(%rbp), %rax
cmpl $0x0, 0x70(%rax)
jne 0x5e10
movq -0x8(%rbp), %rax
movq (%rax), %rcx
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq %rcx, (%rax)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rcx
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq %rcx, 0x8(%rax)
movq -0x8(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, (%rax)
movq -0x8(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x8(%rbp), %rax
leaq 0xff8a(%rip), %rcx      # 0x15d50
movq %rcx, (%rax)
movq 0xff88(%rip), %rcx      # 0x15d58
movq -0x8(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x8(%rbp), %rcx
movq 0xff75(%rip), %rax      # 0x15d58
movq %rcx, (%rax)
movq -0x8(%rbp), %rax
movq %rax, 0xff67(%rip)      # 0x15d58
cmpq $0x0, 0xff47(%rip)      # 0x15d40
je 0x5e0e
movq 0xff3e(%rip), %rax      # 0x15d40
movq -0x8(%rbp), %rcx
movl 0xa0(%rcx), %edi
callq *%rax
jmp 0x5e10
jmp 0x5e12
movq -0x10(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x5d13
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)