// File: /workspace/github_cpp_makefile_star2_O3/kylegranger[P]ImageScaling/linear16.cpp
// Function: CLinear16::Downsample(CLinear16*)
void CLinear16::Downsample(CLinear16 *bmp)
{
	assert((mWidth  & 0xfffe) == bmp->mWidth*2);
	assert((mHeight & 0xfffe) == bmp->mHeight*2);
	color_t *src1 = mData - 1 - mWidth;
	color_t *src2 = mData - 1;
	color_t *src3 = mData - 1 + mWidth;
	color_t *src4 = mData - 1 + mWidth * 2;
	color_t *dst = bmp->mData;
	int padw = mWidth & 1;
	for (int y = 0; y < bmp->mHeight; y++)
	{
		if (y == 0)
		{
			DownfilterLeft(src4, src2, src3, dst++);
			src1 += 2;
			src2 += 2;
			src3 += 2;
			src4 += 2;
			for (int x = 1; x < bmp->mWidth-1; x++)
			{
				Downfilter(src4, src2, src3, dst++);
				src1 += 2;
				src2 += 2;
				src3 += 2;
				src4 += 2;
			}
			DownfilterRight(src4, src2, src3, dst++);
			src1 += 2 + padw;
			src2 += 2 + padw;
			src3 += 2 + padw;
			src4 += 2 + padw;
		}
		else if (y == bmp->mHeight - 1)
		{
			DownfilterLeft(src1, src2, src3, dst++);
			src1 += 2;
			src2 += 2;
			src3 += 2;
			src4 += 2;
			for (int x = 1; x < bmp->mWidth-1; x++)
			{
				Downfilter(src1, src2, src3, dst++);
				src1 += 2;
				src2 += 2;
				src3 += 2;
				src4 += 2;
			}
			DownfilterRight(src1, src2, src3, dst++);
			src1 += 2 + padw;
			src2 += 2 + padw;
			src3 += 2 + padw;
			src4 += 2 + padw;
		}
		else
		{
			DownfilterLeft(src1, src2, src3, src4, dst++);
			src1 += 2;
			src2 += 2;
			src3 += 2;
			src4 += 2;
			for (int x = 1; x < bmp->mWidth-1; x++)
			{
				Downfilter(src1, src2, src3, src4, dst++);
				src1 += 2;
				src2 += 2;
				src3 += 2;
				src4 += 2;
			}
			DownfilterRight(src1, src2, src3, src4, dst++);
			src1 += 2 + padw;
			src2 += 2 + padw;
			src3 += 2 + padw;
			src4 += 2 + padw;
		}
		src1 += mWidth;
		src2 += mWidth;
		src3 += mWidth;
		src4 += mWidth;
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movslq (%rdi), %rcx
movl %ecx, %eax
andl $0xfffe, %eax           # imm = 0xFFFE
movl (%rsi), %edx
addl %edx, %edx
cmpl %edx, %eax
jne 0x74ee
movq %rsi, %rbx
movl $0xfffe, %edx           # imm = 0xFFFE
andl 0x4(%rdi), %edx
movl 0x4(%rsi), %eax
leal (%rax,%rax), %esi
cmpl %esi, %edx
jne 0x750d
testl %eax, %eax
jle 0x74df
movl %ecx, %r8d
andl $0x1, %r8d
movq 0x18(%rbx), %r15
movq 0x18(%rdi), %rdx
leaq -0x8(%rdx), %r12
movq %rcx, %rsi
shlq $0x4, %rsi
leaq (%rdx,%rsi), %r13
addq $-0x8, %r13
leaq (%rdx,%rcx,8), %rbp
addq $-0x8, %rbp
shlq $0x3, %rcx
negq %rcx
leaq (%rdx,%rcx), %r14
addq $-0x8, %r14
orl $0x2, %r8d
xorl %ecx, %ecx
shll $0x3, %r8d
movq %r8, 0x18(%rsp)
movq %rdi, 0x20(%rsp)
movq %rbx, 0x8(%rsp)
testl %ecx, %ecx
movl %ecx, 0x14(%rsp)
je 0x738c
decl %eax
movq %r14, %rdi
movq %r12, %rsi
movq %rbp, %rdx
cmpl %eax, %ecx
jne 0x73f6
movq %r15, %rcx
callq 0x5b65
addq $0x10, %rbp
addq $0x10, %r12
addq $0x10, %r14
cmpl $0x3, (%rbx)
jl 0x746e
movl $0x1, %ebx
addq $0x8, %r15
addq $0x10, %r13
movq %r14, %rdi
movq %r12, %rsi
movq %rbp, %rdx
movq %r15, %rcx
callq 0x5989
incl %ebx
addq $0x10, %rbp
addq $0x10, %r12
addq $0x10, %r14
movq 0x8(%rsp), %rax
movl (%rax), %eax
decl %eax
cmpl %eax, %ebx
jl 0x734a
leaq 0x8(%r15), %rcx
movq 0x8(%rsp), %rbx
jmp 0x7472
movq %r13, %rdi
movq %r12, %rsi
movq %rbp, %rdx
movq %r15, %rcx
callq 0x5b65
addq $0x10, %r13
addq $0x10, %rbp
addq $0x10, %r12
cmpl $0x3, (%rbx)
jl 0x745d
movl $0x1, %ebx
addq $0x8, %r15
addq $0x10, %r14
movq %r13, %rdi
movq %r12, %rsi
movq %rbp, %rdx
movq %r15, %rcx
callq 0x5989
incl %ebx
addq $0x10, %r13
addq $0x10, %rbp
addq $0x10, %r12
movq 0x8(%rsp), %rax
movl (%rax), %eax
decl %eax
cmpl %eax, %ebx
jl 0x73b7
leaq 0x8(%r15), %rcx
movq 0x8(%rsp), %rbx
jmp 0x7461
movq %r13, %rcx
movq %r15, %r8
callq 0x5a75
addq $0x10, %r13
addq $0x10, %rbp
addq $0x10, %r12
addq $0x10, %r14
cmpl $0x3, (%rbx)
jl 0x748a
movl $0x1, %ebx
addq $0x8, %r15
movq %r14, %rdi
movq %r12, %rsi
movq %rbp, %rdx
movq %r13, %rcx
movq %r15, %r8
callq 0x5882
incl %ebx
addq $0x10, %r13
addq $0x10, %rbp
addq $0x10, %r12
addq $0x10, %r14
movq 0x8(%rsp), %rax
movl (%rax), %eax
decl %eax
cmpl %eax, %ebx
jl 0x741b
leaq 0x8(%r15), %r8
movq 0x8(%rsp), %rbx
jmp 0x748e
leaq 0x8(%r15), %rcx
addq $0x10, %r14
addq $0x10, %r15
movq %r13, %rdi
jmp 0x747d
leaq 0x8(%r15), %rcx
addq $0x10, %r13
addq $0x10, %r15
movq %r14, %rdi
movq %r12, %rsi
movq %rbp, %rdx
callq 0x5d1f
jmp 0x74a3
leaq 0x8(%r15), %r8
addq $0x10, %r15
movq %r14, %rdi
movq %r12, %rsi
movq %rbp, %rdx
movq %r13, %rcx
callq 0x5c33
movq 0x18(%rsp), %rax
addq %rax, %r14
addq %rax, %r12
addq %rax, %rbp
addq %rax, %r13
movq 0x20(%rsp), %rax
movslq (%rax), %rax
leaq (%r14,%rax,8), %r14
leaq (%r12,%rax,8), %r12
leaq (%rbp,%rax,8), %rbp
leaq (%r13,%rax,8), %r13
movl 0x14(%rsp), %ecx
incl %ecx
movl 0x4(%rbx), %eax
cmpl %eax, %ecx
jl 0x730d
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x16e4c(%rip), %rdi     # 0x1e341
leaq 0x16dc4(%rip), %rsi     # 0x1e2c0
leaq 0x16e61(%rip), %rcx     # 0x1e364
movl $0x19c, %edx            # imm = 0x19C
callq 0x4100
leaq 0x16e78(%rip), %rdi     # 0x1e38c
leaq 0x16da5(%rip), %rsi     # 0x1e2c0
leaq 0x16e42(%rip), %rcx     # 0x1e364
movl $0x19d, %edx            # imm = 0x19D
callq 0x4100