// File: /workspace/github_cpp_makefile_star2_O2/kylegranger[P]ImageScaling/linear16.cpp
// Function: CLinear16::ReadSimpleScanline(unsigned short*, color_t*, ESimpleFormat)
void CLinear16::ReadSimpleScanline(uint16_t *src, color_t *dst, 
	ESimpleFormat format)
{
	switch (format)
	{
	case ESimpleFormatRgba:
		for (int i = 0; i < mWidth; i++)
		{
			dst->r = *src++;
			dst->g = *src++;
			dst->b = *src++;
			dst->a = *src++;
			dst++;
		}
		break;
	case ESimpleFormatBgra:
		for (int i = 0; i < mWidth; i++)
		{
			dst->b = *src++;
			dst->g = *src++;
			dst->r = *src++;
			dst->a = *src++;
			dst++;
		}
		break;
	case ESimpleFormatRgb:
		for (int i = 0; i < mWidth; i++)
		{
			dst->r = *src++;
			dst->g = *src++;
			dst->b = *src++;
			dst->a = 0xffff;
			dst++;
		}
		break;
	case ESimpleFormatBgr:
		for (int i = 0; i < mWidth; i++)
		{
			dst->b = *src++;
			dst->g = *src++;
			dst->r = *src++;
			dst->a = 0xffff;
			dst++;
		}
		break;
	case ESimpleFormatL:
		for (int i = 0; i < mWidth; i++)
		{
			dst->b = *src;
			dst->g = *src;
			dst->r = *src++;
			dst->a = 0xffff;
			dst++;
		}
		break;
	case ESimpleFormatLa:
		for (int i = 0; i < mWidth; i++)
		{
			dst->b = *src;
			dst->g = *src;
			dst->r = *src++;
			dst->a = *src++;
			dst++;
		}
		break;
	}
}

// Assembly:
addl $0xfffff3c5, %ecx       # imm = 0xFFFFF3C5
cmpl $0x5, %ecx
ja 0x787f
leaq 0x16b1c(%rip), %rax     # 0x1e248
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 0x787f
movzwl (%rsi,%rcx,8), %edi
movw %di, 0x4(%rdx,%rcx,8)
movzwl 0x2(%rsi,%rcx,8), %edi
movw %di, 0x2(%rdx,%rcx,8)
movzwl 0x4(%rsi,%rcx,8), %edi
movw %di, (%rdx,%rcx,8)
movzwl 0x6(%rsi,%rcx,8), %edi
movw %di, 0x6(%rdx,%rcx,8)
incq %rcx
jmp 0x773e
movl (%rdi), %eax
xorl %ecx, %ecx
testl %eax, %eax
cmovlel %ecx, %eax
cmpl %ecx, %eax
je 0x787f
movzwl (%rsi,%rcx,2), %edi
movw %di, (%rdx,%rcx,8)
movw %di, 0x2(%rdx,%rcx,8)
movzwl (%rsi,%rcx,2), %edi
movw %di, 0x4(%rdx,%rcx,8)
orw $-0x1, 0x6(%rdx,%rcx,8)
incq %rcx
jmp 0x777a
movl (%rdi), %eax
xorl %ecx, %ecx
testl %eax, %eax
cmovlel %ecx, %eax
cmpl %ecx, %eax
je 0x787f
movzwl (%rsi), %edi
movw %di, 0x4(%rdx,%rcx,8)
movzwl 0x2(%rsi), %edi
movw %di, 0x2(%rdx,%rcx,8)
movzwl 0x4(%rsi), %edi
movw %di, (%rdx,%rcx,8)
orw $-0x1, 0x6(%rdx,%rcx,8)
incq %rcx
addq $0x6, %rsi
jmp 0x77ac
movl (%rdi), %eax
xorl %ecx, %ecx
testl %eax, %eax
cmovlel %ecx, %eax
cmpl %ecx, %eax
je 0x787f
movzwl (%rsi), %edi
movw %di, (%rdx,%rcx,8)
movzwl 0x2(%rsi), %edi
movw %di, 0x2(%rdx,%rcx,8)
movzwl 0x4(%rsi), %edi
movw %di, 0x4(%rdx,%rcx,8)
orw $-0x1, 0x6(%rdx,%rcx,8)
incq %rcx
addq $0x6, %rsi
jmp 0x77e5
movl (%rdi), %eax
xorl %ecx, %ecx
testl %eax, %eax
cmovlel %ecx, %eax
cmpl %ecx, %eax
je 0x787f
movzwl (%rsi,%rcx,8), %edi
movw %di, (%rdx,%rcx,8)
movzwl 0x2(%rsi,%rcx,8), %edi
movw %di, 0x2(%rdx,%rcx,8)
movzwl 0x4(%rsi,%rcx,8), %edi
movw %di, 0x4(%rdx,%rcx,8)
movzwl 0x6(%rsi,%rcx,8), %edi
movw %di, 0x6(%rdx,%rcx,8)
incq %rcx
jmp 0x781e
movl (%rdi), %eax
xorl %ecx, %ecx
testl %eax, %eax
cmovlel %ecx, %eax
cmpl %ecx, %eax
je 0x787f
movzwl (%rsi,%rcx,4), %edi
movw %di, (%rdx,%rcx,8)
movw %di, 0x2(%rdx,%rcx,8)
movzwl (%rsi,%rcx,4), %edi
movw %di, 0x4(%rdx,%rcx,8)
movzwl 0x2(%rsi,%rcx,4), %edi
movw %di, 0x6(%rdx,%rcx,8)
incq %rcx
jmp 0x7856
retq