// File: /workspace/github_cpp_makefile_star2_O1/kylegranger[P]ImageScaling/linear16.cpp
// Function: CLinear16::Upsample(CLinear16*)
void CLinear16::Upsample(CLinear16 *bmp)
{
	color_t *src1 = mData - 1 - mWidth;
	color_t *src2 = mData - 1;
	color_t *src3 = mData - 1 + mWidth;
	color_t *dst1 = bmp->mData;
	color_t *dst2 = bmp->mData + bmp->mWidth;
	for (int y = 0; y < mHeight; y++)
	{
		if (y == 0)
		{
			UpfilterLeft(src2, src2, src3, dst1, dst2);
			src1++; src2++; src3++;
			dst1 += 2;
			dst2 += 2;
			for (int x = 1; x < mWidth-1; x++)
			{
				Upfilter(src2, src2, src3, dst1, dst2);
				dst1 += 2;
				dst2 += 2;
				src1++; src2++; src3++;
			}
			UpfilterRight(src1, src2, src2, dst1, dst2);
			src1++; src2++; src3++;
			dst1 += 2;
			dst2 += 2;
		}
		else if (y == mHeight - 1)
		{
			UpfilterLeft(src1, src2, src2, dst1, dst2);
			src1++; src2++; src3++;
			dst1 += 2;
			dst2 += 2;
			for (int x = 1; x < mWidth-1; x++)
			{
				Upfilter(src1, src2, src2, dst1, dst2);
				src1++; src2++; src3++;
				dst1 += 2;
				dst2 += 2;
			}
			UpfilterRight(src1, src2, src2, dst1, dst2);
			src1++; src2++; src3++;
			dst1 += 2;
			dst2 += 2;
		}
		else
		{
			UpfilterLeft(src1++, src2++, src3++, dst1, dst2);
			dst1 += 2;
			dst2 += 2;
			for (int x = 1; x < mWidth-1; x++)
			{
				Upfilter(src1++, src2++, src3++, dst1, dst2);
				dst1 += 2;
				dst2 += 2;
			}
			UpfilterRight(src1++, src2++, src3++, dst1, dst2);
			dst1 += 2;
			dst2 += 2;
		}
		dst1 += bmp->mWidth;
		dst2 += bmp->mWidth;
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rsi, 0x18(%rsp)
movl 0x4(%rdi), %eax
testl %eax, %eax
jle 0x773a
movq %rdi, %r14
movq 0x18(%rsp), %rcx
movq 0x18(%rcx), %r15
movslq (%rcx), %rcx
leaq (%r15,%rcx,8), %r12
movq 0x18(%rdi), %rcx
leaq -0x8(%rcx), %r13
movslq (%rdi), %rdx
leaq (%rcx,%rdx,8), %rbp
addq $-0x8, %rbp
shlq $0x3, %rdx
negq %rdx
leaq (%rcx,%rdx), %rbx
addq $-0x8, %rbx
xorl %ecx, %ecx
movq %rdi, 0x8(%rsp)
testl %ecx, %ecx
movq %rcx, 0x20(%rsp)
je 0x7584
decl %eax
leaq 0x10(%r12), %rdx
movq %rdx, (%rsp)
leaq 0x10(%r15), %rdx
movq %rdx, 0x10(%rsp)
movq %rbx, %rdi
movq %r13, %rsi
cmpl %eax, %ecx
jne 0x7614
movq %r13, %rdx
movq %r15, %rcx
movq %r12, %r8
callq 0x68f9
cmpl $0x3, (%r14)
jl 0x76c2
movl $0x1, %r14d
addq $0x8, %rbx
addq $0x8, %r13
addq $0x10, %r15
addq $0x10, %r12
addq $0x8, %rbp
movq %rbx, %rdi
movq %r13, %rsi
movq %r13, %rdx
movq %r15, %rcx
movq %r12, %r8
callq 0x6645
incl %r14d
movq 0x8(%rsp), %rax
movl (%rax), %eax
decl %eax
cmpl %eax, %r14d
jl 0x7535
leaq 0x8(%rbx), %rdi
leaq 0x8(%r13), %rdx
leaq 0x10(%r15), %rcx
leaq 0x10(%r12), %r8
jmp 0x760a
movq %r13, %rdi
movq %r13, %rsi
movq %rbp, %rdx
movq %r15, %rcx
movq %r12, %r8
callq 0x68f9
cmpl $0x3, (%r14)
jl 0x76af
movq %rbx, (%rsp)
movl $0x1, %ebx
xorl %r14d, %r14d
addq $0x10, %r15
addq $0x10, %r12
leaq (%r14,%r13), %rdi
addq $0x8, %rdi
leaq 0x8(%r14,%rbp), %rdx
movq %rdi, %rsi
movq %r15, %rcx
movq %r12, %r8
callq 0x6645
incl %ebx
movq 0x8(%rsp), %rax
movl (%rax), %eax
decl %eax
addq $0x8, %r14
cmpl %eax, %ebx
jl 0x75ae
leaq 0x10(%r15), %rcx
leaq 0x10(%r12), %r8
movq (%rsp), %rbx
leaq (%rbx,%r14), %rdi
addq $0x8, %rdi
addq %r14, %rbx
leaq (%r14,%r13), %rdx
addq $0x8, %rdx
addq %r14, %r13
addq %r14, %rbp
movq 0x8(%rsp), %r14
jmp 0x76d3
movq %rbp, %rdx
movq %r15, %rcx
movq %r12, %r8
callq 0x68f9
cmpl $0x3, (%r14)
jl 0x76e9
movq %rbx, (%rsp)
movl $0x1, %ebx
xorl %r14d, %r14d
movq (%rsp), %rax
leaq (%r14,%rax), %rdi
addq $0x8, %rdi
leaq (%r14,%r13), %rsi
addq $0x8, %rsi
leaq (%r14,%rbp), %rdx
addq $0x8, %rdx
addq $0x10, %r15
addq $0x10, %r12
movq %r15, %rcx
movq %r12, %r8
callq 0x6645
incl %ebx
movq 0x8(%rsp), %rax
movl (%rax), %eax
decl %eax
addq $0x8, %r14
cmpl %eax, %ebx
jl 0x7638
movq (%rsp), %rbx
leaq (%rbx,%r14), %rdi
addq $0x8, %rdi
addq %r14, %rbx
leaq (%r14,%r13), %rsi
addq $0x8, %rsi
addq %r14, %r13
leaq (%r14,%rbp), %rdx
addq $0x8, %rdx
addq %r14, %rbp
leaq 0x10(%r15), %rcx
leaq 0x10(%r12), %r8
movq 0x8(%rsp), %r14
jmp 0x76fe
leaq 0x8(%r13), %rdx
leaq 0x8(%rbx), %rdi
leaq 0x10(%r12), %r8
leaq 0x10(%r15), %rcx
jmp 0x76d3
leaq 0x8(%r13), %rdx
leaq 0x8(%rbx), %rdi
movq (%rsp), %r8
movq 0x10(%rsp), %rcx
movq %rdx, %rsi
callq 0x6b7c
addq $0x10, %rbx
addq $0x10, %r13
addq $0x10, %rbp
jmp 0x770f
leaq 0x8(%rbp), %rdx
leaq 0x8(%r13), %rsi
leaq 0x8(%rbx), %rdi
movq (%rsp), %r8
movq 0x10(%rsp), %rcx
addq $0x10, %rbx
addq $0x10, %r13
addq $0x10, %rbp
callq 0x6b7c
movq 0x18(%rsp), %rax
movslq (%rax), %rax
leaq (%r15,%rax,8), %r15
addq $0x20, %r15
leaq (%r12,%rax,8), %r12
addq $0x20, %r12
movq 0x20(%rsp), %rcx
incl %ecx
movl 0x4(%r14), %eax
cmpl %eax, %ecx
jl 0x74e8
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop