// File: /workspace/github_c_makefile_star2_O0/jonof[P]jfaudiolib/src/mix.c
// Function: MV_Mix16BitStereo
void MV_Mix16BitStereo( 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];
        sample1 = sample0;
        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 0x16a88(%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 0x8615
movq -0x20(%rbp), %rax
movl -0x4(%rbp), %ecx
shrl $0x10, %ecx
movl %ecx, %ecx
movzbl (%rax,%rcx), %eax
movl %eax, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
movl %eax, -0x30(%rbp)
movl -0x8(%rbp), %eax
addl -0x4(%rbp), %eax
movl %eax, -0x4(%rbp)
leaq 0x158f4(%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 0x158ce(%rip), %rax     # 0x1de00
movq (%rax), %rax
movslq -0x30(%rbp), %rcx
movswl (%rax,%rcx,2), %eax
movl %eax, -0x34(%rbp)
movq -0x28(%rbp), %rcx
leaq 0x168f5(%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 0x8578
movl $0xffff8000, -0x2c(%rbp) # imm = 0xFFFF8000
jmp 0x858a
cmpl $0x7fff, -0x2c(%rbp)    # imm = 0x7FFF
jle 0x8588
movl $0x7fff, -0x2c(%rbp)    # imm = 0x7FFF
jmp 0x858a
cmpl $0xffff8000, -0x30(%rbp) # imm = 0xFFFF8000
jge 0x859c
movl $0xffff8000, -0x30(%rbp) # imm = 0xFFFF8000
jmp 0x85ae
cmpl $0x7fff, -0x30(%rbp)    # imm = 0x7FFF
jle 0x85ac
movl $0x7fff, -0x30(%rbp)    # imm = 0x7FFF
jmp 0x85ae
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 0x1686f(%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 0xd129(%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 0x84d7
movl -0x4(%rbp), %ecx
leaq 0x16941(%rip), %rax     # 0x1ef60
movl %ecx, (%rax)
movq -0x28(%rbp), %rcx
leaq 0x1692c(%rip), %rax     # 0x1ef58
movq %rcx, (%rax)
popq %rbp
retq
nopw %cs:(%rax,%rax)