// File: /workspace/github_cpp_makefile_star2_O2/kylegranger[P]ImageScaling/linear16.cpp
// Function: CLinear16::DrawMonochromeAnaglyph(CLinear16*, CLinear16*)
void CLinear16::DrawMonochromeAnaglyph(CLinear16 *left, CLinear16 *right)
{
	if (left && right)
	{
		assert(left->mWidth == mWidth);
		assert(left->mHeight == mHeight);
		assert(right->mWidth == mWidth);
		assert(right->mHeight == mHeight);
		color_t *src1 = left->mData;
		color_t *src2 = right->mData;
		color_t *dst = mData;
		for (int y = 0; y < mHeight; y++)
		{
			for (int x = 0; x < mWidth; x++)
			{
				int luma1 = src1->r * 2126 + src1->g * 7152 + src1->b * 722 + 5000;
				int luma2 = src2->r * 2126 + src2->g * 7152 + src2->b * 722 + 5000;
				luma1 /= 10000;
				luma2 /= 10000;
				dst->r = luma1;
				dst->g = luma2 * 3 / 4;
				dst->b = luma2;
				dst->a = 0xffff;
				dst++;
			}
		}
	}
	else if (left)
	{
		assert(left->mWidth == mWidth);
		assert(left->mHeight == mHeight);
		color_t *src = left->mData;
		color_t *dst = mData;
		for (int y = 0; y < mHeight; y++)
		{
			for (int x = 0; x < mWidth; x++)
			{
				int luma1 = src->r * 2126 + src->g * 7152 + src->b * 722 + 5000;
				luma1 /= 10000;
				dst->r = luma1;
				dst->a = 0xffff;
				dst++;
				src++;
			}
		}
	}
	else if (right)
	{
		assert(right->mWidth == mWidth);
		assert(right->mHeight == mHeight);
		color_t *src = right->mData;
		color_t *dst = mData;
		for (int y = 0; y < mHeight; y++)
		{
			for (int x = 0; x < mWidth; x++)
			{
				int luma2 = src->r * 2126 + src->g * 7152 + src->b * 722 + 5000;
				luma2 /= 10000;
				dst->g = luma2 * 3 / 4;
				dst->b = luma2;
				dst++;
				src++;
			}
		}
	}
	else
		assert(0);

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
testq %rsi, %rsi
sete %al
testq %rdx, %rdx
sete %cl
orb %al, %cl
jne 0x7f22
movl (%rsi), %r8d
cmpl (%rdi), %r8d
jne 0x8069
movl 0x4(%rsi), %r9d
cmpl 0x4(%rdi), %r9d
jne 0x8088
cmpl %r8d, (%rdx)
jne 0x80a7
cmpl %r9d, 0x4(%rdx)
jne 0x80c6
movq 0x18(%rsi), %r10
movq 0x18(%rdx), %r11
movq 0x18(%rdi), %rdi
xorl %ebx, %ebx
testl %r8d, %r8d
cmovlel %ebx, %r8d
testl %r9d, %r9d
cmovlel %ebx, %r9d
movl $0x1388, %ebp           # imm = 0x1388
movl $0x2710, %r14d          # imm = 0x2710
cmpl %r9d, %ebx
je 0x805e
movl %r8d, %r15d
subl $0x1, %r15d
jb 0x7f1b
movzwl 0x4(%r10), %eax
imull $0x84e, %eax, %eax      # imm = 0x84E
movzwl 0x2(%r10), %ecx
imull $0x1bf0, %ecx, %ecx     # imm = 0x1BF0
addl %eax, %ecx
movzwl (%r10), %eax
imull $0x2d2, %eax, %eax      # imm = 0x2D2
addl %ebp, %eax
addl %ecx, %eax
movzwl 0x4(%r11), %ecx
imull $0x84e, %ecx, %ecx      # imm = 0x84E
movzwl 0x2(%r11), %edx
imull $0x1bf0, %edx, %edx     # imm = 0x1BF0
addl %ecx, %edx
movzwl (%r11), %ecx
imull $0x2d2, %ecx, %ecx      # imm = 0x2D2
addl %ebp, %ecx
addl %edx, %ecx
xorl %edx, %edx
divl %r14d
movl %eax, %esi
movl %ecx, %eax
xorl %edx, %edx
divl %r14d
movw %si, 0x4(%rdi)
leal (%rax,%rax,2), %ecx
shrl $0x2, %ecx
movw %cx, 0x2(%rdi)
movw %ax, (%rdi)
orw $-0x1, 0x6(%rdi)
addq $0x8, %rdi
jmp 0x7e9f
incl %ebx
jmp 0x7e93
testq %rsi, %rsi
je 0x7fc0
movl (%rsi), %ecx
cmpl (%rdi), %ecx
jne 0x80e5
movl 0x4(%rsi), %r8d
cmpl 0x4(%rdi), %r8d
jne 0x8104
movq 0x18(%rsi), %rsi
movq 0x18(%rdi), %rdi
xorl %r9d, %r9d
testl %ecx, %ecx
cmovlel %r9d, %ecx
testl %r8d, %r8d
cmovlel %r9d, %r8d
movl $0x2710, %r10d          # imm = 0x2710
cmpl %r8d, %r9d
je 0x805e
xorl %ebx, %ebx
xorl %r11d, %r11d
cmpl %ebx, %ecx
je 0x7fb5
movzwl 0x4(%rsi,%rbx,8), %eax
imull $0x84e, %eax, %eax      # imm = 0x84E
movzwl 0x2(%rsi,%rbx,8), %edx
imull $0x1bf0, %edx, %edx     # imm = 0x1BF0
addl %eax, %edx
movzwl (%rsi,%rbx,8), %eax
imull $0x2d2, %eax, %eax      # imm = 0x2D2
addl %edx, %eax
addl $0x1388, %eax           # imm = 0x1388
xorl %edx, %edx
divl %r10d
movw %ax, 0x4(%rdi,%rbx,8)
orw $-0x1, 0x6(%rdi,%rbx,8)
addq $-0x8, %r11
incq %rbx
jmp 0x7f6f
incl %r9d
subq %r11, %rsi
subq %r11, %rdi
jmp 0x7f61
testq %rdx, %rdx
je 0x8123
movl (%rdx), %ecx
cmpl (%rdi), %ecx
jne 0x8142
movl 0x4(%rdx), %esi
cmpl 0x4(%rdi), %esi
jne 0x8161
movq 0x18(%rdx), %r8
movq 0x18(%rdi), %rdi
xorl %r9d, %r9d
testl %ecx, %ecx
cmovlel %r9d, %ecx
testl %esi, %esi
cmovlel %r9d, %esi
movl $0x2710, %r10d          # imm = 0x2710
cmpl %esi, %r9d
je 0x805e
xorl %ebx, %ebx
xorl %r11d, %r11d
cmpl %ebx, %ecx
je 0x8053
movzwl 0x4(%r8,%rbx,8), %eax
imull $0x84e, %eax, %eax      # imm = 0x84E
movzwl 0x2(%r8,%rbx,8), %edx
imull $0x1bf0, %edx, %edx     # imm = 0x1BF0
addl %eax, %edx
movzwl (%r8,%rbx,8), %eax
imull $0x2d2, %eax, %eax      # imm = 0x2D2
addl %edx, %eax
addl $0x1388, %eax           # imm = 0x1388
xorl %edx, %edx
divl %r10d
leal (%rax,%rax,2), %edx
shrl $0x2, %edx
movw %dx, 0x2(%rdi,%rbx,8)
movw %ax, (%rdi,%rbx,8)
addq $-0x8, %r11
incq %rbx
jmp 0x8006
incl %r9d
subq %r11, %r8
subq %r11, %rdi
jmp 0x7ffc
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
leaq 0x16491(%rip), %rdi     # 0x1e501
leaq 0x16219(%rip), %rsi     # 0x1e290
leaq 0x1649a(%rip), %rcx     # 0x1e518
movl $0x39d, %edx            # imm = 0x39D
callq 0x4100
leaq 0x164ca(%rip), %rdi     # 0x1e559
leaq 0x161fa(%rip), %rsi     # 0x1e290
leaq 0x1647b(%rip), %rcx     # 0x1e518
movl $0x39e, %edx            # imm = 0x39E
callq 0x4100
leaq 0x164c4(%rip), %rdi     # 0x1e572
leaq 0x161db(%rip), %rsi     # 0x1e290
leaq 0x1645c(%rip), %rcx     # 0x1e518
movl $0x39f, %edx            # imm = 0x39F
callq 0x4100
leaq 0x164bd(%rip), %rdi     # 0x1e58a
leaq 0x161bc(%rip), %rsi     # 0x1e290
leaq 0x1643d(%rip), %rcx     # 0x1e518
movl $0x3a0, %edx            # imm = 0x3A0
callq 0x4100
leaq 0x16415(%rip), %rdi     # 0x1e501
leaq 0x1619d(%rip), %rsi     # 0x1e290
leaq 0x1641e(%rip), %rcx     # 0x1e518
movl $0x3b6, %edx            # imm = 0x3B6
callq 0x4100
leaq 0x1644e(%rip), %rdi     # 0x1e559
leaq 0x1617e(%rip), %rsi     # 0x1e290
leaq 0x163ff(%rip), %rcx     # 0x1e518
movl $0x3b7, %edx            # imm = 0x3B7
callq 0x4100
leaq 0x162f1(%rip), %rdi     # 0x1e41b
leaq 0x1615f(%rip), %rsi     # 0x1e290
leaq 0x163e0(%rip), %rcx     # 0x1e518
movl $0x3db, %edx            # imm = 0x3DB
callq 0x4100
leaq 0x16429(%rip), %rdi     # 0x1e572
leaq 0x16140(%rip), %rsi     # 0x1e290
leaq 0x163c1(%rip), %rcx     # 0x1e518
movl $0x3c9, %edx            # imm = 0x3C9
callq 0x4100
leaq 0x16422(%rip), %rdi     # 0x1e58a
leaq 0x16121(%rip), %rsi     # 0x1e290
leaq 0x163a2(%rip), %rcx     # 0x1e518
movl $0x3ca, %edx            # imm = 0x3CA
callq 0x4100