// File: /workspace/github_c_makefile_star2_O0/jonof[P]jfaudiolib/src/mixst.c
// Function: MV_Mix16BitStereo8Stereo
void MV_Mix16BitStereo8Stereo( unsigned int position, unsigned int rate,
                       char *start, unsigned int length )
{
    unsigned char *source = (unsigned char *) start;
    short *dest = (short *) MV_MixDestination;
    int sample0, sample1;
    
    while (length--) {
        sample0 = source[(position >> 16) << 1];
        sample1 = source[((position >> 16) << 1) + 1];
        position += rate;
        
        sample0 = MV_LeftVolume[sample0] + *dest;
        sample1 = MV_RightVolume[sample1] + *(dest + MV_RightChannelOffset / 2);
        if (sample0 < -32768) sample0 = -32768;
        else if (sample0 > 32767) sample0 = 32767;
        if (sample1 < -32768) sample1 = -32768;
        else if (sample1 > 32767) sample1 = 32767;
        
        *dest = (short) sample0;
        *(dest + MV_RightChannelOffset/2) = (short) sample1;
        
        dest += MV_SampleSize / 2;
    }
    
    MV_MixPosition = position;
    MV_MixDestination = (char *) dest;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movl %edi, -0x4(%rbp)
movl %esi, -0x8(%rbp)
movq %rdx, -0x10(%rbp)
movl %ecx, -0x14(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x20(%rbp)
leaq 0x15db8(%rip), %rax     # 0x1ef58
movq (%rax), %rax
movq %rax, -0x28(%rbp)
movl -0x14(%rbp), %eax
movl %eax, %ecx
addl $-0x1, %ecx
movl %ecx, -0x14(%rbp)
cmpl $0x0, %eax
je 0x92f9
movq -0x20(%rbp), %rax
movl -0x4(%rbp), %ecx
shrl $0x10, %ecx
shll %ecx
movl %ecx, %ecx
movzbl (%rax,%rcx), %eax
movl %eax, -0x2c(%rbp)
movq -0x20(%rbp), %rax
movl -0x4(%rbp), %ecx
shrl $0x10, %ecx
shll %ecx
addl $0x1, %ecx
movl %ecx, %ecx
movzbl (%rax,%rcx), %eax
movl %eax, -0x30(%rbp)
movl -0x8(%rbp), %eax
addl -0x4(%rbp), %eax
movl %eax, -0x4(%rbp)
leaq 0x14c10(%rip), %rax     # 0x1de08
movq (%rax), %rax
movslq -0x2c(%rbp), %rcx
movswl (%rax,%rcx,2), %eax
movq -0x28(%rbp), %rcx
movswl (%rcx), %ecx
addl %ecx, %eax
movl %eax, -0x2c(%rbp)
leaq 0x14bea(%rip), %rax     # 0x1de00
movq (%rax), %rax
movslq -0x30(%rbp), %rcx
movswl (%rax,%rcx,2), %eax
movl %eax, -0x34(%rbp)
movq -0x28(%rbp), %rcx
leaq 0x15c11(%rip), %rax     # 0x1ee40
movl (%rax), %eax
movl $0x2, %esi
cltd
idivl %esi
movl %eax, %edx
movl -0x34(%rbp), %eax
movslq %edx, %rdx
movswl (%rcx,%rdx,2), %ecx
addl %ecx, %eax
movl %eax, -0x30(%rbp)
cmpl $0xffff8000, -0x2c(%rbp) # imm = 0xFFFF8000
jge 0x925c
movl $0xffff8000, -0x2c(%rbp) # imm = 0xFFFF8000
jmp 0x926e
cmpl $0x7fff, -0x2c(%rbp)    # imm = 0x7FFF
jle 0x926c
movl $0x7fff, -0x2c(%rbp)    # imm = 0x7FFF
jmp 0x926e
cmpl $0xffff8000, -0x30(%rbp) # imm = 0xFFFF8000
jge 0x9280
movl $0xffff8000, -0x30(%rbp) # imm = 0xFFFF8000
jmp 0x9292
cmpl $0x7fff, -0x30(%rbp)    # imm = 0x7FFF
jle 0x9290
movl $0x7fff, -0x30(%rbp)    # imm = 0x7FFF
jmp 0x9292
movl -0x2c(%rbp), %eax
movw %ax, %cx
movq -0x28(%rbp), %rax
movw %cx, (%rax)
movl -0x30(%rbp), %eax
movw %ax, -0x42(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0x40(%rbp)
leaq 0x15b8b(%rip), %rax     # 0x1ee40
movl (%rax), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movw -0x42(%rbp), %dx
movl %eax, %ecx
movq -0x40(%rbp), %rax
movslq %ecx, %rcx
movw %dx, (%rax,%rcx,2)
leaq 0xc445(%rip), %rax      # 0x1571c
movl (%rax), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movq -0x28(%rbp), %rax
movslq %ecx, %rcx
shlq %rcx
addq %rcx, %rax
movq %rax, -0x28(%rbp)
jmp 0x91a7
movl -0x4(%rbp), %ecx
leaq 0x15c5d(%rip), %rax     # 0x1ef60
movl %ecx, (%rax)
movq -0x28(%rbp), %rcx
leaq 0x15c48(%rip), %rax     # 0x1ef58
movq %rcx, (%rax)
popq %rbp
retq
nopw %cs:(%rax,%rax)