// File: /workspace/github_cpp_makefile_star2_O2/kebwi[P]Trifid/src/DebayerProcs.cpp
// Function: hue_constructVerticalRedOrBlueAtGreen(ImageReal&, Image3ChnlReal&, ImageReal&, int, int)
void hue_constructVerticalRedOrBlueAtGreen(
	ImageReal &grayImage, Image3ChnlReal &rgbImage,
	ImageReal &rgbImageRorB, int x, int y)
{
	assert(determineBayerColor(x, y) == G);
	if (&rgbImageRorB == rgbImage[0] && y > 0)
		assert(determineBayerColor(x, y - 1) == R);
	else if (&rgbImageRorB == rgbImage[2] && y > 0)
		assert(determineBayerColor(x, y - 1) == 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, y - 1) /
					(Float_t)rgbImage(G, x, y - 1);
		divisor++;
	}
	if (x < width - 1)
	{
		color2L += (Float_t)grayImage(x, y + 1) /
					(Float_t)rgbImage(G, x, 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, %ebp
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %r12
movl %ecx, %edi
movl %r8d, %esi
callq 0x1c294
cmpl $0x1, %eax
jne 0xd720
movq 0x38(%r15), %rax
testl %ebx, %ebx
jle 0xd5dd
cmpq %r14, (%rax)
jne 0xd5dd
leal -0x1(%rbx), %esi
movl %ebp, %edi
callq 0x1c294
testl %eax, %eax
je 0xd5fa
leaq 0x16215(%rip), %rdi     # 0x237da
leaq 0x15ed4(%rip), %rsi     # 0x234a0
leaq 0x161a6(%rip), %rcx     # 0x23779
movl $0x1ff, %edx            # imm = 0x1FF
callq 0x31a0
testl %ebx, %ebx
jle 0xd5fa
cmpq %r14, 0x10(%rax)
jne 0xd5fa
leal -0x1(%rbx), %esi
movl %ebp, %edi
callq 0x1c294
cmpl $0x2, %eax
jne 0xd75e
movl 0x28(%r12), %r13d
pushq $0x1
popq %rsi
movq %r15, %rdi
movl %ebp, %edx
movl %ebx, %ecx
callq 0xb868
movsd (%rax), %xmm0
testl %ebp, %ebp
movsd %xmm0, 0x20(%rsp)
jle 0xd676
leal -0x1(%rbx), %ecx
movq 0x38(%r12), %rax
movl 0x28(%r12), %edx
imull %ecx, %edx
addl %ebp, %edx
movsd (%rax,%rdx,8), %xmm0
movsd %xmm0, 0x8(%rsp)
pushq $0x1
popq %rsi
movq %r15, %rdi
movl %ebp, %edx
callq 0xb868
movsd 0x8(%rsp), %xmm1
divsd (%rax), %xmm1
xorpd %xmm0, %xmm0
addsd %xmm1, %xmm0
decl %r13d
cmpl %ebp, %r13d
jle 0xd6df
movsd 0x15df0(%rip), %xmm1    # 0x23458
movsd %xmm1, 0x8(%rsp)
movsd %xmm0, 0x10(%rsp)
jmp 0xd699
decl %r13d
cmpl %ebp, %r13d
jle 0xd73f
xorps %xmm0, %xmm0
movsd %xmm0, 0x10(%rsp)
movsd 0x149c5(%rip), %xmm0    # 0x22058
movsd %xmm0, 0x8(%rsp)
leal 0x1(%rbx), %ecx
movq 0x38(%r12), %rax
movl 0x28(%r12), %edx
imull %ecx, %edx
addl %ebp, %edx
movsd (%rax,%rdx,8), %xmm0
movsd %xmm0, 0x18(%rsp)
pushq $0x1
popq %rsi
movq %r15, %rdi
movl %ebp, %edx
callq 0xb868
movsd 0x18(%rsp), %xmm1
divsd (%rax), %xmm1
movsd 0x10(%rsp), %xmm0
addsd %xmm1, %xmm0
movsd 0x8(%rsp), %xmm2
jmp 0xd6e7
movsd 0x14971(%rip), %xmm2    # 0x22058
movsd 0x20(%rsp), %xmm1
divsd %xmm2, %xmm1
mulsd %xmm0, %xmm1
movsd 0x158c3(%rip), %xmm0    # 0x22fc0
minsd %xmm1, %xmm0
movq 0x38(%r14), %rax
imull 0x28(%r14), %ebx
addl %ebp, %ebx
movsd %xmm0, (%rax,%rbx,8)
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x15f8a(%rip), %rdi     # 0x236b1
leaq 0x15d72(%rip), %rsi     # 0x234a0
leaq 0x16044(%rip), %rcx     # 0x23779
movl $0x1fd, %edx            # imm = 0x1FD
callq 0x31a0
leaq 0x15da9(%rip), %rdi     # 0x234ef
leaq 0x15d53(%rip), %rsi     # 0x234a0
leaq 0x16025(%rip), %rcx     # 0x23779
movl $0x216, %edx            # imm = 0x216
callq 0x31a0
leaq 0x16098(%rip), %rdi     # 0x237fd
leaq 0x15d34(%rip), %rsi     # 0x234a0
leaq 0x16006(%rip), %rcx     # 0x23779
movl $0x201, %edx            # imm = 0x201
callq 0x31a0