// File: /workspace/github_c_makefile_star2_O0/jonof[P]jfaudiolib/src/multivoc.c
// Function: MV_Mix
static void MV_Mix
   (
   VoiceNode *voice,
   int        buffer
   )

   {
   char          *start;
   int            length;
   int            voclength;
   unsigned int   position;
   unsigned int   rate;
   unsigned int   FixedPointBufferSize;

   if ( ( voice->length == 0 ) && ( voice->GetSound( voice ) != KeepPlaying ) )
      {
      return;
      }

   length               = MixBufferSize;
   FixedPointBufferSize = voice->FixedPointBufferSize;

   MV_MixDestination    = MV_MixBuffer[ buffer ];
   MV_LeftVolume        = voice->LeftVolume;
   MV_RightVolume       = voice->RightVolume;

   if ( ( MV_Channels == 2 ) && ( IS_QUIET( MV_LeftVolume ) ) )
      {
      MV_LeftVolume      = MV_RightVolume;
      MV_MixDestination += MV_RightChannelOffset;
      }

   // Add this voice to the mix
   while( length > 0 )
      {
      start    = voice->sound;
      rate     = voice->RateScale;
      position = voice->position;

      // Check if the last sample in this buffer would be
      // beyond the length of the sample block
      if ( ( position + FixedPointBufferSize ) >= voice->length )
         {
         if ( position < voice->length )
            {
            voclength = ( voice->length - position + rate - voice->channels ) / rate;
            }
         else
            {
            voice->GetSound( voice );
            return;
            }
         }
      else
         {
         voclength = length;
         }

      if (voice->mix) {
         voice->mix( position, rate, start, voclength );
      }

      voice->position = MV_MixPosition;

      length -= voclength;

      if ( voice->position >= voice->length )
         {
         // Get the next block of sound
         if ( voice->GetSound( voice ) != KeepPlaying )
            {
            return;
            }

         if ( length > (voice->channels - 1) )
            {
            // Get the position of the last sample in the buffer
            FixedPointBufferSize = voice->RateScale * ( length - voice->channels );
            }
         }
      }
   }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq -0x8(%rbp), %rax
cmpl $0x0, 0x60(%rax)
jne 0x5981
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x8(%rbp), %rdi
callq *%rax
cmpl $0x1, %eax
je 0x5981
jmp 0x5b22
movl $0x100, -0x1c(%rbp)     # imm = 0x100
movq -0x8(%rbp), %rax
movl 0x50(%rax), %eax
movl %eax, -0x2c(%rbp)
movslq -0xc(%rbp), %rcx
leaq 0x194b3(%rip), %rax     # 0x1ee50
movq (%rax,%rcx,8), %rax
movq %rax, 0x195b0(%rip)     # 0x1ef58
movq -0x8(%rbp), %rax
movq 0x90(%rax), %rax
movq %rax, 0x1844e(%rip)     # 0x1de08
movq -0x8(%rbp), %rax
movq 0x98(%rax), %rax
movq %rax, 0x18434(%rip)     # 0x1de00
cmpl $0x2, 0xfd55(%rip)      # 0x15728
jne 0x5a0d
leaq 0x10424(%rip), %rax     # 0x15e00
cmpq %rax, 0x18425(%rip)     # 0x1de08
jne 0x5a0d
movq 0x18414(%rip), %rax     # 0x1de00
movq %rax, 0x18415(%rip)     # 0x1de08
movl 0x19447(%rip), %ecx     # 0x1ee40
movq 0x19558(%rip), %rax     # 0x1ef58
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, 0x1954b(%rip)     # 0x1ef58
jmp 0x5a0f
cmpl $0x0, -0x1c(%rbp)
jle 0x5b22
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x8(%rbp), %rax
movl 0x68(%rax), %eax
movl %eax, -0x28(%rbp)
movq -0x8(%rbp), %rax
movl 0x6c(%rax), %eax
movl %eax, -0x24(%rbp)
movl -0x24(%rbp), %eax
addl -0x2c(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x60(%rcx), %eax
jb 0x5a8a
movl -0x24(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x60(%rcx), %eax
jae 0x5a75
movq -0x8(%rbp), %rax
movl 0x60(%rax), %eax
subl -0x24(%rbp), %eax
addl -0x28(%rbp), %eax
movq -0x8(%rbp), %rcx
movsbl 0x15(%rcx), %ecx
subl %ecx, %eax
xorl %edx, %edx
divl -0x28(%rbp)
movl %eax, -0x20(%rbp)
jmp 0x5a88
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x8(%rbp), %rdi
callq *%rax
jmp 0x5b22
jmp 0x5a90
movl -0x1c(%rbp), %eax
movl %eax, -0x20(%rbp)
movq -0x8(%rbp), %rax
cmpq $0x0, 0x20(%rax)
je 0x5ab2
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rax
movl -0x24(%rbp), %edi
movl -0x28(%rbp), %esi
movq -0x18(%rbp), %rdx
movl -0x20(%rbp), %ecx
callq *%rax
movl 0x194a8(%rip), %ecx     # 0x1ef60
movq -0x8(%rbp), %rax
movl %ecx, 0x6c(%rax)
movl -0x20(%rbp), %ecx
movl -0x1c(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x1c(%rbp)
movq -0x8(%rbp), %rax
movl 0x6c(%rax), %eax
movq -0x8(%rbp), %rcx
cmpl 0x60(%rcx), %eax
jb 0x5b1d
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x8(%rbp), %rdi
callq *%rax
cmpl $0x1, %eax
je 0x5aef
jmp 0x5b22
movl -0x1c(%rbp), %eax
movq -0x8(%rbp), %rcx
movsbl 0x15(%rcx), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jle 0x5b1b
movq -0x8(%rbp), %rax
movl 0x68(%rax), %eax
movl -0x1c(%rbp), %ecx
movq -0x8(%rbp), %rdx
movsbl 0x15(%rdx), %edx
subl %edx, %ecx
imull %ecx, %eax
movl %eax, -0x2c(%rbp)
jmp 0x5b1d
jmp 0x5a0f
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax,%rax)