// File: /workspace/github_cpp_makefile_star2_O3/kebwi[P]Trifid/src/DebayerProcs.cpp
// Function: hue_constructHorizontalRedOrBlueAtGreen(ImageReal&, Image3ChnlReal&, ImageReal&, int, int)
void hue_constructHorizontalRedOrBlueAtGreen(
	ImageReal &grayImage, Image3ChnlReal &rgbImage,
	ImageReal &rgbImageRorB, int x, int y)
{
	assert(determineBayerColor(x, y) == G);
	if (&rgbImageRorB == rgbImage[0] && x > 0)
		assert(determineBayerColor(x - 1, y) == R);
	else if (&rgbImageRorB == rgbImage[2] && x > 0)
		assert(determineBayerColor(x - 1, y) == B);
	
	int width = grayImage.width();
	
	Float_t color1L = rgbImage(G, x, y);
	Float_t color2L = 0;
	int divisor = 0;
	
	if (x > 0)
	{
		color2L += (Float_t)grayImage(x - 1, y) /
					(Float_t)rgbImage(G, x - 1, y);
		divisor++;
	}
	if (x < width - 1)
	{
		color2L += (Float_t)grayImage(x + 1, y) /
					(Float_t)rgbImage(G, x + 1, y);
		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, %r15
movq %rsi, %r12
movq %rdi, %r13
movl %ecx, %edi
movl %r8d, %esi
callq 0x23198
cmpl $0x1, %eax
jne 0x103b0
movq 0x38(%r12), %rax
testl %r14d, %r14d
jle 0x1023c
cmpq %r15, (%rax)
jne 0x1023c
leal -0x1(%r14), %edi
movl %ebx, %esi
callq 0x23198
testl %eax, %eax
je 0x10263
leaq 0x1b51f(%rip), %rdi     # 0x2b743
leaq 0x1b285(%rip), %rsi     # 0x2b4b0
leaq 0x1b4ae(%rip), %rcx     # 0x2b6e0
movl $0x1da, %edx            # imm = 0x1DA
callq 0x31c0
testl %r14d, %r14d
jle 0x1036a
cmpq %r15, 0x10(%rax)
jne 0x1036a
leal -0x1(%r14), %edi
movl %ebx, %esi
callq 0x23198
cmpl $0x2, %eax
jne 0x103cf
movl 0x28(%r13), %ebp
movq %r12, %rdi
movl $0x1, %esi
movl %r14d, %edx
movl %ebx, %ecx
callq 0xe49a
movsd (%rax), %xmm0
movsd %xmm0, 0x18(%rsp)
leal -0x1(%r14), %edx
movq 0x38(%r13), %rax
movl 0x28(%r13), %ecx
imull %ebx, %ecx
addl %r14d, %ecx
decl %ecx
movsd (%rax,%rcx,8), %xmm0
movsd %xmm0, 0x8(%rsp)
movq %r12, %rdi
movl $0x1, %esi
movl %ebx, %ecx
callq 0xe49a
movsd 0x8(%rsp), %xmm1
divsd (%rax), %xmm1
xorpd %xmm0, %xmm0
addsd %xmm1, %xmm0
decl %ebp
cmpl %r14d, %ebp
jle 0x10328
movsd %xmm0, 0x8(%rsp)
movsd 0x1b190(%rip), %xmm0    # 0x2b468
movsd %xmm0, 0x10(%rsp)
leal 0x1(%r14), %edx
movq 0x38(%r13), %rax
movl 0x28(%r13), %ecx
imull %ebx, %ecx
addl %r14d, %ecx
incl %ecx
movsd (%rax,%rcx,8), %xmm0
movsd %xmm0, 0x20(%rsp)
movq %r12, %rdi
movl $0x1, %esi
movl %ebx, %ecx
callq 0xe49a
movsd 0x20(%rsp), %xmm1
divsd (%rax), %xmm1
movsd 0x8(%rsp), %xmm0
addsd %xmm1, %xmm0
movsd 0x10(%rsp), %xmm2
jmp 0x10330
movsd 0x19d28(%rip), %xmm2    # 0x2a058
movsd 0x18(%rsp), %xmm1
divsd %xmm2, %xmm1
mulsd %xmm0, %xmm1
movsd 0x1ac8a(%rip), %xmm0    # 0x2afd0
minsd %xmm1, %xmm0
movq 0x38(%r15), %rax
imull 0x28(%r15), %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
movl 0x28(%r13), %ebp
movq %r12, %rdi
movl $0x1, %esi
movl %r14d, %edx
movl %ebx, %ecx
callq 0xe49a
movsd (%rax), %xmm0
testl %r14d, %r14d
movsd %xmm0, 0x18(%rsp)
jg 0x10283
decl %ebp
cmpl %r14d, %ebp
jle 0x103ee
xorps %xmm0, %xmm0
movsd %xmm0, 0x8(%rsp)
movsd 0x19cad(%rip), %xmm0    # 0x2a058
jmp 0x102d8
leaq 0x1b30a(%rip), %rdi     # 0x2b6c1
leaq 0x1b0f2(%rip), %rsi     # 0x2b4b0
leaq 0x1b31b(%rip), %rcx     # 0x2b6e0
movl $0x1d8, %edx            # imm = 0x1D8
callq 0x31c0
leaq 0x1b390(%rip), %rdi     # 0x2b766
leaq 0x1b0d3(%rip), %rsi     # 0x2b4b0
leaq 0x1b2fc(%rip), %rcx     # 0x2b6e0
movl $0x1dc, %edx            # imm = 0x1DC
callq 0x31c0
leaq 0x1b10a(%rip), %rdi     # 0x2b4ff
leaq 0x1b0b4(%rip), %rsi     # 0x2b4b0
leaq 0x1b2dd(%rip), %rcx     # 0x2b6e0
movl $0x1f1, %edx            # imm = 0x1F1
callq 0x31c0