// File: /workspace/github_cpp_makefile_star2_O1/kebwi[P]Trifid/src/DebayerProcs.cpp
// Function: hue_constructRedOrBlueAtBlueOrRed(ImageReal&, Image3ChnlReal&, ImageReal&, int, int)
void hue_constructRedOrBlueAtBlueOrRed(
	ImageReal &grayImage, Image3ChnlReal &rgbImage,
	ImageReal &rgbImageRorB, int x, int y)
{
	if (&rgbImageRorB == rgbImage[0])
		assert(determineBayerColor(x, y) == B);
	else assert(determineBayerColor(x, y) == R);
	
	int width = grayImage.width(), height = grayImage.height();
	
	Float_t color1L = rgbImage(G, x, y);
	Float_t color2L = 0;
	int divisor = 0;
	if (x > 0 && y > 0)
	{
		color2L += (Float_t)grayImage(x - 1, y - 1) /
					(Float_t)rgbImage(G, x - 1, y - 1);
		divisor++;
	}
	if (x < width - 1 && y > 0)
	{
		color2L += (Float_t)grayImage(x + 1, y - 1) /
					(Float_t)rgbImage(G, x + 1, y - 1);
		divisor++;
	}
	if (x < width - 1 && y < height - 1)
	{
		color2L += (Float_t)grayImage(x + 1, y + 1) /
					(Float_t)rgbImage(G, x + 1, y + 1);
		divisor++;
	}
	if (x > 0 && y < height - 1)
	{
		color2L += (Float_t)grayImage(x - 1, y + 1) /
					(Float_t)rgbImage(G, x - 1, y + 1);
		divisor++;
	}
	
	assert(divisor > 0);
	color1L = ((Float_t)color1L / (Float_t)divisor) * color2L;
	if (color1L > pow(2, sBitDepth) - 1)
		color1L = pow(2, sBitDepth) - 1;
	
	rgbImageRorB(x, y) = color1L;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movl %r8d, %ebx
movl %ecx, %r14d
movq %rdx, %r12
movq %rdi, %r13
movq %rsi, 0x10(%rsp)
movq 0x38(%rsi), %rax
movq (%rax), %r15
movl %ecx, %edi
movl %r8d, %esi
callq 0x23404
movq %r12, 0x30(%rsp)
cmpq %r12, %r15
je 0x1003a
testl %eax, %eax
je 0x10043
leaq 0x1c698(%rip), %rdi     # 0x2c6ba
leaq 0x1c49f(%rip), %rsi     # 0x2c4c8
leaq 0x1c62d(%rip), %rcx     # 0x2c65d
movl $0x1ac, %edx            # imm = 0x1AC
callq 0x31c0
cmpl $0x2, %eax
jne 0x10264
movl 0x28(%r13), %r12d
movl 0x2c(%r13), %eax
movl %eax, 0x18(%rsp)
movl $0x1, %ebp
movq 0x10(%rsp), %r15
movq %r15, %rdi
movl $0x1, %esi
movl %r14d, %edx
movl %ebx, %ecx
callq 0xe55c
movsd (%rax), %xmm0
movsd %xmm0, 0x28(%rsp)
testl %r14d, %r14d
setle %al
testl %ebx, %ebx
setle %cl
orb %al, %cl
jne 0x100c7
leal -0x1(%r14), %edx
leal -0x1(%rbx), %ecx
movq 0x38(%r13), %rax
movl 0x28(%r13), %esi
imull %ecx, %esi
addl %r14d, %esi
decl %esi
movsd (%rax,%rsi,8), %xmm0
movsd %xmm0, 0x8(%rsp)
movq %r15, %rdi
movl $0x1, %esi
callq 0xe55c
movsd 0x8(%rsp), %xmm0
divsd (%rax), %xmm0
xorpd %xmm2, %xmm2
addsd %xmm0, %xmm2
jmp 0x100cd
xorl %ebp, %ebp
xorpd %xmm2, %xmm2
testl %ebx, %ebx
setle %al
decl %r12d
cmpl %r14d, %r12d
setle %cl
orb %al, %cl
movl 0x18(%rsp), %r15d
jne 0x10131
leal 0x1(%r14), %edx
leal -0x1(%rbx), %ecx
movq 0x38(%r13), %rax
movl 0x28(%r13), %esi
imull %ecx, %esi
addl %r14d, %esi
incl %esi
movsd (%rax,%rsi,8), %xmm0
movsd %xmm0, 0x20(%rsp)
movq 0x10(%rsp), %rdi
movl $0x1, %esi
movsd %xmm2, 0x8(%rsp)
callq 0xe55c
movsd 0x8(%rsp), %xmm2
movsd 0x20(%rsp), %xmm0
divsd (%rax), %xmm0
addsd %xmm0, %xmm2
incl %ebp
cmpl %r14d, %r12d
setg %al
decl %r15d
cmpl %ebx, %r15d
setg %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x10199
leal 0x1(%r14), %edx
leal 0x1(%rbx), %ecx
movq 0x38(%r13), %rax
movl 0x28(%r13), %esi
imull %ecx, %esi
addl %r14d, %esi
incl %esi
movsd (%rax,%rsi,8), %xmm0
movsd %xmm0, 0x18(%rsp)
movq 0x10(%rsp), %r12
movq %r12, %rdi
movl $0x1, %esi
movsd %xmm2, 0x8(%rsp)
callq 0xe55c
movsd 0x8(%rsp), %xmm2
movsd 0x18(%rsp), %xmm0
divsd (%rax), %xmm0
addsd %xmm0, %xmm2
incl %ebp
jmp 0x1019e
movq 0x10(%rsp), %r12
cmpl %ebx, %r15d
setg %al
testl %r14d, %r14d
setg %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x101fc
leal -0x1(%r14), %edx
leal 0x1(%rbx), %ecx
movq 0x38(%r13), %rax
movl 0x28(%r13), %esi
imull %ecx, %esi
addl %r14d, %esi
decl %esi
movsd (%rax,%rsi,8), %xmm0
movsd %xmm0, 0x10(%rsp)
movq %r12, %rdi
movl $0x1, %esi
movsd %xmm2, 0x8(%rsp)
callq 0xe55c
movsd 0x8(%rsp), %xmm2
movsd 0x10(%rsp), %xmm0
divsd (%rax), %xmm0
addsd %xmm0, %xmm2
incl %ebp
testl %ebp, %ebp
jle 0x10245
xorps %xmm0, %xmm0
cvtsi2sd %ebp, %xmm0
movsd 0x28(%rsp), %xmm1
divsd %xmm0, %xmm1
mulsd %xmm1, %xmm2
movsd 0x1bddb(%rip), %xmm0    # 0x2bff8
minsd %xmm2, %xmm0
movq 0x30(%rsp), %rcx
movq 0x38(%rcx), %rax
imull 0x28(%rcx), %ebx
addl %r14d, %ebx
movsd %xmm0, (%rax,%rbx,8)
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1c2cb(%rip), %rdi     # 0x2c517
leaq 0x1c275(%rip), %rsi     # 0x2c4c8
leaq 0x1c403(%rip), %rcx     # 0x2c65d
movl $0x1cc, %edx            # imm = 0x1CC
callq 0x31c0
leaq 0x1c3d3(%rip), %rdi     # 0x2c63e
leaq 0x1c256(%rip), %rsi     # 0x2c4c8
leaq 0x1c3e4(%rip), %rcx     # 0x2c65d
movl $0x1ab, %edx            # imm = 0x1AB
callq 0x31c0