// File: /workspace/github_cpp_makefile_star2_O2/kylegranger[P]ImageScaling/linear16.cpp
// Function: CLinear16::WriteSimpleScanline(color_t*, unsigned short*, ESimpleFormat)
void CLinear16::WriteSimpleScanline(color_t *src, uint16_t *dst, 
	ESimpleFormat format)
{

	switch (format)
	{
	case ESimpleFormatRgba:
		for (int i = 0; i < mWidth; i++)
		{
			*dst++ = src->r;
			*dst++ = src->g;
			*dst++ = src->b;
			*dst++ = src->a;
			src++;
		}
		break;
	case ESimpleFormatBgra:
		for (int i = 0; i < mWidth; i++)
		{
			*dst++ = src->b;
			*dst++ = src->g;
			*dst++ = src->r;
			*dst++ = src->a;
			src++;
		}
		break;
	case ESimpleFormatRgb:
		for (int i = 0; i < mWidth; i++)
		{
			*dst++ = src->r;
			*dst++ = src->g;
			*dst++ = src->b;
			src++;
		}
		break;
	case ESimpleFormatBgr:
		for (int i = 0; i < mWidth; i++)
		{
			*dst++ = src->b;
			*dst++ = src->g;
			*dst++ = src->r;
			src++;
		}
		break;
	case ESimpleFormatL:
		for (int i = 0; i < mWidth; i++)
		{
			*dst++ = (src->r * 299 + src->g * 587 + src->b * 114) / 1000;
			src++;
		}
		break;
	case ESimpleFormatLa:
		for (int i = 0; i < mWidth; i++)
		{
			*dst++ = (src->r * 299 + src->g * 587 + src->b * 114) / 1000;
			*dst++ = src->a;
			src++;
		}
		break;
	}
}

// Assembly:
addl $0xfffff3c5, %ecx       # imm = 0xFFFFF3C5
cmpl $0x5, %ecx
ja 0x7715
movq %rdx, %r8
leaq 0x16ca1(%rip), %rax     # 0x1e230
movslq (%rax,%rcx,4), %rcx
addq %rax, %rcx
jmpq *%rcx
movl (%rdi), %eax
xorl %ecx, %ecx
testl %eax, %eax
cmovlel %ecx, %eax
cmpl %ecx, %eax
je 0x7715
movzwl 0x4(%rsi,%rcx,8), %edx
movw %dx, (%r8,%rcx,8)
movzwl 0x2(%rsi,%rcx,8), %edx
movw %dx, 0x2(%r8,%rcx,8)
movzwl (%rsi,%rcx,8), %edx
movw %dx, 0x4(%r8,%rcx,8)
movzwl 0x6(%rsi,%rcx,8), %edx
movw %dx, 0x6(%r8,%rcx,8)
incq %rcx
jmp 0x75a1
movl (%rdi), %ecx
xorl %edi, %edi
testl %ecx, %ecx
cmovlel %edi, %ecx
movl $0x3e8, %r9d            # imm = 0x3E8
cmpl %edi, %ecx
je 0x7715
movzwl 0x4(%rsi,%rdi,8), %eax
imull $0x12b, %eax, %eax      # imm = 0x12B
movzwl 0x2(%rsi,%rdi,8), %edx
imull $0x24b, %edx, %edx      # imm = 0x24B
addl %eax, %edx
movzwl (%rsi,%rdi,8), %eax
imull $0x72, %eax, %eax
addl %edx, %eax
xorl %edx, %edx
divl %r9d
movw %ax, (%r8,%rdi,2)
incq %rdi
jmp 0x75e7
movl (%rdi), %eax
xorl %ecx, %ecx
testl %eax, %eax
cmovlel %ecx, %eax
cmpl %ecx, %eax
je 0x7715
movzwl 0x4(%rsi,%rcx,8), %edx
movw %dx, (%r8)
movzwl 0x2(%rsi,%rcx,8), %edx
movw %dx, 0x2(%r8)
movzwl (%rsi,%rcx,8), %edx
movw %dx, 0x4(%r8)
addq $0x6, %r8
incq %rcx
jmp 0x7628
movl (%rdi), %eax
xorl %ecx, %ecx
testl %eax, %eax
cmovlel %ecx, %eax
cmpl %ecx, %eax
je 0x7715
movzwl (%rsi,%rcx,8), %edx
movw %dx, (%r8)
movzwl 0x2(%rsi,%rcx,8), %edx
movw %dx, 0x2(%r8)
movzwl 0x4(%rsi,%rcx,8), %edx
movw %dx, 0x4(%r8)
addq $0x6, %r8
incq %rcx
jmp 0x765e
movl (%rdi), %eax
xorl %ecx, %ecx
testl %eax, %eax
cmovlel %ecx, %eax
cmpl %ecx, %eax
je 0x7715
movzwl (%rsi,%rcx,8), %edx
movw %dx, (%r8,%rcx,8)
movzwl 0x2(%rsi,%rcx,8), %edx
movw %dx, 0x2(%r8,%rcx,8)
movzwl 0x4(%rsi,%rcx,8), %edx
movw %dx, 0x4(%r8,%rcx,8)
movzwl 0x6(%rsi,%rcx,8), %edx
movw %dx, 0x6(%r8,%rcx,8)
incq %rcx
jmp 0x7694
movl (%rdi), %ecx
xorl %edi, %edi
testl %ecx, %ecx
cmovlel %edi, %ecx
movl $0x3e8, %r9d            # imm = 0x3E8
cmpl %edi, %ecx
je 0x7715
movzwl 0x4(%rsi,%rdi,8), %eax
imull $0x12b, %eax, %eax      # imm = 0x12B
movzwl 0x2(%rsi,%rdi,8), %edx
imull $0x24b, %edx, %edx      # imm = 0x24B
addl %eax, %edx
movzwl (%rsi,%rdi,8), %eax
imull $0x72, %eax, %eax
addl %edx, %eax
xorl %edx, %edx
divl %r9d
movw %ax, (%r8,%rdi,4)
movzwl 0x6(%rsi,%rdi,8), %eax
movw %ax, 0x2(%r8,%rdi,4)
incq %rdi
jmp 0x76d6
retq