// File: /workspace/github_cpp_makefile_star2_O3/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 0x7c43
leaq 0x1678c(%rip), %rax     # 0x1e278
movslq (%rax,%rcx,4), %rcx
addq %rax, %rcx
jmpq *%rcx
movl (%rdi), %eax
testl %eax, %eax
jle 0x7c43
xorl %ecx, %ecx
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
cmpl %ecx, %eax
jne 0x7b01
jmp 0x7c43
movl (%rdi), %eax
testl %eax, %eax
jle 0x7c43
xorl %ecx, %ecx
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)
movw $0xffff, 0x6(%rdx,%rcx,8) # imm = 0xFFFF
incq %rcx
cmpl %ecx, %eax
jne 0x7b3f
jmp 0x7c43
movl (%rdi), %eax
testl %eax, %eax
jle 0x7c43
xorl %ecx, %ecx
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)
movw $0xffff, 0x6(%rdx,%rcx,8) # imm = 0xFFFF
incq %rcx
addq $0x6, %rsi
cmpl %ecx, %eax
jne 0x7b74
jmp 0x7c43
movl (%rdi), %eax
testl %eax, %eax
jle 0x7c43
xorl %ecx, %ecx
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)
movw $0xffff, 0x6(%rdx,%rcx,8) # imm = 0xFFFF
incq %rcx
addq $0x6, %rsi
cmpl %ecx, %eax
jne 0x7bb0
jmp 0x7c43
movl (%rdi), %eax
testl %eax, %eax
jle 0x7c43
xorl %ecx, %ecx
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
cmpl %ecx, %eax
jne 0x7be5
jmp 0x7c43
movl (%rdi), %eax
testl %eax, %eax
jle 0x7c43
xorl %ecx, %ecx
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
cmpl %ecx, %eax
jne 0x7c1c
retq