// File: /workspace/github_c_makefile_star2_O0/jonof[P]jfaudiolib/src/mixst.c
// Function: MV_Mix16BitStereo16Stereo
void MV_Mix16BitStereo16Stereo( unsigned int position, unsigned int rate,
                         char *start, unsigned int length )
{
    unsigned short *source = (unsigned short *) start;
    short *dest = (short *) MV_MixDestination;
    int sample0l, sample0h, sample0;
    int sample1l, sample1h, sample1;
    
    while (length--) {
        sample0 = source[(position >> 16) << 1];
        sample1 = source[((position >> 16) << 1) + 1];
#ifdef BIGENDIAN
        sample0l = sample0 >> 8;
        sample0h = (sample0 & 255) ^ 128;
        sample1l = sample1 >> 8;
        sample1h = (sample1 & 255) ^ 128;
#else
        sample0l = sample0 & 255;
        sample0h = (sample0 >> 8) ^ 128;
        sample1l = sample1 & 255;
        sample1h = (sample1 >> 8) ^ 128;
#endif
        position += rate;
        
        sample0l = MV_LeftVolume[sample0l] >> 8;
        sample0h = MV_LeftVolume[sample0h];
        sample1l = MV_RightVolume[sample1l] >> 8;
        sample1h = MV_RightVolume[sample1h];
        sample0 = sample0l + sample0h + 128 + *dest;
        sample1 = sample1l + sample1h + 128 + *(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 0x157c8(%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 0x9967
movq -0x20(%rbp), %rax
movl -0x4(%rbp), %ecx
shrl $0x10, %ecx
shll %ecx
movl %ecx, %ecx
movzwl (%rax,%rcx,2), %eax
movl %eax, -0x34(%rbp)
movq -0x20(%rbp), %rax
movl -0x4(%rbp), %ecx
shrl $0x10, %ecx
shll %ecx
addl $0x1, %ecx
movl %ecx, %ecx
movzwl (%rax,%rcx,2), %eax
movl %eax, -0x40(%rbp)
movl -0x34(%rbp), %eax
andl $0xff, %eax
movl %eax, -0x2c(%rbp)
movl -0x34(%rbp), %eax
sarl $0x8, %eax
xorl $0x80, %eax
movl %eax, -0x30(%rbp)
movl -0x40(%rbp), %eax
andl $0xff, %eax
movl %eax, -0x38(%rbp)
movl -0x40(%rbp), %eax
sarl $0x8, %eax
xorl $0x80, %eax
movl %eax, -0x3c(%rbp)
movl -0x8(%rbp), %eax
addl -0x4(%rbp), %eax
movl %eax, -0x4(%rbp)
leaq 0x145ee(%rip), %rax     # 0x1de08
movq (%rax), %rax
movslq -0x2c(%rbp), %rcx
movswl (%rax,%rcx,2), %eax
sarl $0x8, %eax
movl %eax, -0x2c(%rbp)
leaq 0x145d6(%rip), %rax     # 0x1de08
movq (%rax), %rax
movslq -0x30(%rbp), %rcx
movswl (%rax,%rcx,2), %eax
movl %eax, -0x30(%rbp)
leaq 0x145b9(%rip), %rax     # 0x1de00
movq (%rax), %rax
movslq -0x38(%rbp), %rcx
movswl (%rax,%rcx,2), %eax
sarl $0x8, %eax
movl %eax, -0x38(%rbp)
leaq 0x145a1(%rip), %rax     # 0x1de00
movq (%rax), %rax
movslq -0x3c(%rbp), %rcx
movswl (%rax,%rcx,2), %eax
movl %eax, -0x3c(%rbp)
movl -0x2c(%rbp), %eax
addl -0x30(%rbp), %eax
addl $0x80, %eax
movq -0x28(%rbp), %rcx
movswl (%rcx), %ecx
addl %ecx, %eax
movl %eax, -0x34(%rbp)
movl -0x38(%rbp), %eax
addl -0x3c(%rbp), %eax
addl $0x80, %eax
movl %eax, -0x44(%rbp)
movq -0x28(%rbp), %rcx
leaq 0x155a3(%rip), %rax     # 0x1ee40
movl (%rax), %eax
movl $0x2, %esi
cltd
idivl %esi
movl %eax, %edx
movl -0x44(%rbp), %eax
movslq %edx, %rdx
movswl (%rcx,%rdx,2), %ecx
addl %ecx, %eax
movl %eax, -0x40(%rbp)
cmpl $0xffff8000, -0x34(%rbp) # imm = 0xFFFF8000
jge 0x98ca
movl $0xffff8000, -0x34(%rbp) # imm = 0xFFFF8000
jmp 0x98dc
cmpl $0x7fff, -0x34(%rbp)    # imm = 0x7FFF
jle 0x98da
movl $0x7fff, -0x34(%rbp)    # imm = 0x7FFF
jmp 0x98dc
cmpl $0xffff8000, -0x40(%rbp) # imm = 0xFFFF8000
jge 0x98ee
movl $0xffff8000, -0x40(%rbp) # imm = 0xFFFF8000
jmp 0x9900
cmpl $0x7fff, -0x40(%rbp)    # imm = 0x7FFF
jle 0x98fe
movl $0x7fff, -0x40(%rbp)    # imm = 0x7FFF
jmp 0x9900
movl -0x34(%rbp), %eax
movw %ax, %cx
movq -0x28(%rbp), %rax
movw %cx, (%rax)
movl -0x40(%rbp), %eax
movw %ax, -0x52(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0x50(%rbp)
leaq 0x1551d(%rip), %rax     # 0x1ee40
movl (%rax), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movw -0x52(%rbp), %dx
movl %eax, %ecx
movq -0x50(%rbp), %rax
movslq %ecx, %rcx
movw %dx, (%rax,%rcx,2)
leaq 0xbdd7(%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 0x9797
movl -0x4(%rbp), %ecx
leaq 0x155ef(%rip), %rax     # 0x1ef60
movl %ecx, (%rax)
movq -0x28(%rbp), %rcx
leaq 0x155da(%rip), %rax     # 0x1ef58
movq %rcx, (%rax)
popq %rbp
retq
nopw %cs:(%rax,%rax)
nopl (%rax)