// File: /workspace/github_cpp_makefile_star2_O3/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 $0x28, %rsp
movl %r8d, %ebx
movl %ecx, %r14d
movq %rdx, %r12
movq %rdi, %r13
movq %rsi, 0x8(%rsp)
movq 0x38(%rsi), %rax
movq (%rax), %r15
movl %ecx, %edi
movl %r8d, %esi
callq 0x23198
movq %r12, 0x20(%rsp)
cmpq %r12, %r15
je 0xff95
testl %eax, %eax
je 0xff9e
leaq 0x1b725(%rip), %rdi     # 0x2b6a2
leaq 0x1b52c(%rip), %rsi     # 0x2b4b0
leaq 0x1b6ba(%rip), %rcx     # 0x2b645
movl $0x1ac, %edx            # imm = 0x1AC
callq 0x31c0
cmpl $0x2, %eax
jne 0x101b0
movl 0x28(%r13), %r12d
movl 0x2c(%r13), %r15d
movq 0x8(%rsp), %rbp
movq %rbp, %rdi
movl $0x1, %esi
movl %r14d, %edx
movl %ebx, %ecx
callq 0xe49a
movsd (%rax), %xmm0
movsd %xmm0, 0x18(%rsp)
testl %r14d, %r14d
setle %al
testl %ebx, %ebx
setle %cl
orb %al, %cl
jne 0x1001c
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, (%rsp)
movq %rbp, %rdi
movl $0x1, %esi
callq 0xe49a
movsd (%rsp), %xmm0
divsd (%rax), %xmm0
xorpd %xmm2, %xmm2
addsd %xmm0, %xmm2
movl $0x1, %ebp
jmp 0x10022
xorl %ebp, %ebp
xorpd %xmm2, %xmm2
testl %ebx, %ebx
setle %al
decl %r12d
cmpl %r14d, %r12d
setle %cl
orb %al, %cl
jne 0x1007f
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, 0x10(%rsp)
movq 0x8(%rsp), %rdi
movl $0x1, %esi
movsd %xmm2, (%rsp)
callq 0xe49a
movsd (%rsp), %xmm2
movsd 0x10(%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 0x100e5
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, 0x10(%rsp)
movq 0x8(%rsp), %r12
movq %r12, %rdi
movl $0x1, %esi
movsd %xmm2, (%rsp)
callq 0xe49a
movsd (%rsp), %xmm2
movsd 0x10(%rsp), %xmm0
divsd (%rax), %xmm0
addsd %xmm0, %xmm2
incl %ebp
jmp 0x100ea
movq 0x8(%rsp), %r12
cmpl %ebx, %r15d
setg %al
testl %r14d, %r14d
setg %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x10148
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 %r12, %rdi
movl $0x1, %esi
movsd %xmm2, (%rsp)
callq 0xe49a
movsd (%rsp), %xmm2
movsd 0x8(%rsp), %xmm0
divsd (%rax), %xmm0
addsd %xmm0, %xmm2
incl %ebp
jmp 0x1014c
testl %ebp, %ebp
je 0x10191
xorps %xmm0, %xmm0
cvtsi2sd %ebp, %xmm0
movsd 0x18(%rsp), %xmm1
divsd %xmm0, %xmm1
mulsd %xmm2, %xmm1
movsd 0x1ae67(%rip), %xmm0    # 0x2afd0
minsd %xmm1, %xmm0
movq 0x20(%rsp), %rcx
movq 0x38(%rcx), %rax
imull 0x28(%rcx), %ebx
addl %r14d, %ebx
movsd %xmm0, (%rax,%rbx,8)
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1b367(%rip), %rdi     # 0x2b4ff
leaq 0x1b311(%rip), %rsi     # 0x2b4b0
leaq 0x1b49f(%rip), %rcx     # 0x2b645
movl $0x1cc, %edx            # imm = 0x1CC
callq 0x31c0
leaq 0x1b46f(%rip), %rdi     # 0x2b626
leaq 0x1b2f2(%rip), %rsi     # 0x2b4b0
leaq 0x1b480(%rip), %rcx     # 0x2b645
movl $0x1ab, %edx            # imm = 0x1AB
callq 0x31c0