// File: /workspace/github_cpp_makefile_star2_O1/kebwi[P]Trifid/src/DebayerProcs.cpp
// Function: nn_procOnePixel(ImageReal&, Image3ChnlReal&, int, int)
void nn_procOnePixel(
	ImageReal &grayImage, Image3ChnlReal &rgbImage,
	int x, int y)
{
	Color color = determineBayerColor(x, y);
	int width = grayImage.width(), height = grayImage.height();
	
	Float_t bayerValue = 0, bayerValueRight = 0, bayerValueDown = 0, bayerValueRightDown = 0;
	bool rightEdge = false, bottomEdge = false;
	
	bayerValue = grayImage(x, y);
	if (x + 1 < width)
		bayerValueRight = grayImage(x + 1, y);
	else rightEdge = true;
	if (y + 1 < height)
		bayerValueDown = grayImage(x, y + 1);
	else bottomEdge = true;
	if (x + 1 < width && y + 1 < height)
		bayerValueRightDown = grayImage(x + 1, y + 1);
	
	//Fill in the output
	switch (color)
	{
		case R:
			rgbImage(R, x, y) = bayerValue;
			if (!rightEdge)
			{
				rgbImage(G, x, y) = bayerValueRight;
				if (!bottomEdge)
					rgbImage(B, x, y) = bayerValueRightDown;
			}
			break;
		case G:
			{
				Color colorRight;
				if (x < width - 1)
					colorRight = determineBayerColor(x + 1, y);
				else colorRight = determineBayerColor(x - 1, y);
				assert(colorRight != G);
				if (colorRight == R)
				{
					if (!rightEdge)
						rgbImage(R, x, y) = bayerValueRight;
					rgbImage(G, x, y) = bayerValue;
					if (!bottomEdge)
						rgbImage(B, x, y) = bayerValueDown;
				}
				else //if (colorRight == B)
				{
					if (!bottomEdge)
						rgbImage(R, x, y) = bayerValueDown;
					rgbImage(G, x, y) = bayerValue;
					if (!rightEdge)
						rgbImage(B, x, y) = bayerValueRight;
				}
			}
			break;
		case B:
			if (!rightEdge)
			{
				if (!bottomEdge)
					rgbImage(R, x, y) = bayerValueRightDown;
				rgbImage(G, x, y) = bayerValueRight;
			}
			rgbImage(B, x, y) = bayerValue;
			break;
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %ecx, %ebx
movl %edx, %r14d
movq %rsi, 0x18(%rsp)
movq %rdi, %r12
movl %edx, %edi
movl %ecx, %esi
callq 0x23404
movl 0x28(%r12), %r13d
movl 0x2c(%r12), %ebp
movq 0x38(%r12), %rcx
movl %r13d, %edx
imull %ebx, %edx
leal 0x1(%r14), %r12d
xorps %xmm1, %xmm1
xorps %xmm0, %xmm0
cmpl %r13d, %r12d
jge 0xf2ed
leal (%rdx,%r12), %esi
movsd (%rcx,%rsi,8), %xmm0
addl %r14d, %edx
leal 0x1(%rbx), %r15d
cmpl %ebp, %r15d
jge 0xf308
movl %r13d, %esi
imull %r15d, %esi
addl %r14d, %esi
movsd (%rcx,%rsi,8), %xmm1
cmpl %ebp, %r15d
setge %sil
cmpl %r13d, %r12d
setge %dil
orb %sil, %dil
xorps %xmm3, %xmm3
jne 0xf32d
movl %r13d, %esi
imull %r15d, %esi
addl %r12d, %esi
movsd (%rcx,%rsi,8), %xmm3
movsd (%rcx,%rdx,8), %xmm2
cmpl $0x2, %eax
je 0xf43b
movsd %xmm0, 0x20(%rsp)
cmpl $0x1, %eax
je 0xf3b5
movsd %xmm3, (%rsp)
movl %ebp, 0xc(%rsp)
testl %eax, %eax
movq 0x18(%rsp), %rbp
jne 0xf510
movq %rbp, %rdi
xorl %esi, %esi
movl %r14d, %edx
movl %ebx, %ecx
movsd %xmm2, 0x10(%rsp)
callq 0xe55c
movsd 0x10(%rsp), %xmm0
movsd %xmm0, (%rax)
cmpl %r13d, %r12d
jge 0xf510
movq %rbp, %rdi
movl $0x1, %esi
movl %r14d, %edx
movl %ebx, %ecx
callq 0xe55c
movsd 0x20(%rsp), %xmm0
movsd %xmm0, (%rax)
movsd (%rsp), %xmm2
cmpl 0xc(%rsp), %r15d
jl 0xf4f0
jmp 0xf510
movsd %xmm2, 0x10(%rsp)
movsd %xmm1, (%rsp)
leal -0x1(%r13), %eax
leal -0x1(%r14), %edi
cmpl %r14d, %eax
cmovgl %r12d, %edi
movl %ebx, %esi
callq 0x23404
testl %eax, %eax
je 0xf4a1
cmpl $0x1, %eax
je 0xf51f
cmpl %ebp, %r15d
jge 0xf406
movq 0x18(%rsp), %rdi
xorl %esi, %esi
movl %r14d, %edx
movl %ebx, %ecx
callq 0xe55c
movsd (%rsp), %xmm0
movsd %xmm0, (%rax)
movq 0x18(%rsp), %rbp
movq %rbp, %rdi
movl $0x1, %esi
movl %r14d, %edx
movl %ebx, %ecx
callq 0xe55c
movsd 0x10(%rsp), %xmm0
movsd %xmm0, (%rax)
movsd 0x20(%rsp), %xmm2
cmpl %r13d, %r12d
jl 0xf4f0
jmp 0xf510
cmpl %r13d, %r12d
jl 0xf44a
movq 0x18(%rsp), %rbp
jmp 0xf4f0
movsd %xmm2, 0x10(%rsp)
movsd %xmm0, 0x20(%rsp)
cmpl %ebp, %r15d
movq 0x18(%rsp), %rbp
jge 0xf47d
movq %rbp, %rdi
xorl %esi, %esi
movl %r14d, %edx
movl %ebx, %ecx
movsd %xmm3, (%rsp)
callq 0xe55c
movsd (%rsp), %xmm0
movsd %xmm0, (%rax)
movq %rbp, %rdi
movl $0x1, %esi
movl %r14d, %edx
movl %ebx, %ecx
callq 0xe55c
movsd 0x20(%rsp), %xmm0
movsd %xmm0, (%rax)
movsd 0x10(%rsp), %xmm2
jmp 0xf4f0
movl %ebp, 0xc(%rsp)
cmpl %r13d, %r12d
movq 0x18(%rsp), %rbp
jge 0xf4c8
movq %rbp, %rdi
xorl %esi, %esi
movl %r14d, %edx
movl %ebx, %ecx
callq 0xe55c
movsd 0x20(%rsp), %xmm0
movsd %xmm0, (%rax)
movq %rbp, %rdi
movl $0x1, %esi
movl %r14d, %edx
movl %ebx, %ecx
callq 0xe55c
movsd 0x10(%rsp), %xmm0
movsd %xmm0, (%rax)
cmpl 0xc(%rsp), %r15d
movsd (%rsp), %xmm2
jge 0xf510
movsd %xmm2, (%rsp)
movq %rbp, %rdi
movl $0x2, %esi
movl %r14d, %edx
movl %ebx, %ecx
callq 0xe55c
movsd (%rsp), %xmm0
movsd %xmm0, (%rax)
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1cf92(%rip), %rdi     # 0x2c4b8
leaq 0x1cf9b(%rip), %rsi     # 0x2c4c8
leaq 0x1cfa5(%rip), %rcx     # 0x2c4d9
movl $0x40, %edx
callq 0x31c0