// File: /workspace/github_cpp_makefile_star2_O3/kebwi[P]Trifid/src/ImageProcs.cpp
// Function: labImgToRgbImg(double, Image3ChnlReal const&, Image3ChnlReal&)
void labImgToRgbImg(Float_t maxVal, const Image3ChnlReal &labImg, Image3ChnlReal &rgbImg)
{
	rgbImg.resize(labImg.width(), labImg.height());
	
	Float_t r, g, b;
	Float_t x, y, z;
	Float_t l, a, b2;
	int totalPixels = labImg.totalPixels();
	for (int i = 0; i < totalPixels; i++)
	{
		l = (*labImg[0])[i];
		a = (*labImg[1])[i];
		b2 = (*labImg[2])[i];
		
		cielab2xyz(l, a, b2, x, y, z);
		xyz2rgb(x, y, z, r, g, b);
		
		(*rgbImg[0])[i] = r * maxVal;
		(*rgbImg[1])[i] = g * maxVal;
		(*rgbImg[2])[i] = b * maxVal;
	}
	
	rgbImg.setFilename(labImg.filename());
	rgbImg.appendFilename("_rgb");
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rsi, %rbx
movq %rdi, %r14
movsd %xmm0, 0x8(%rsp)
movl 0x28(%rdi), %esi
movl 0x2c(%rdi), %edx
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x28(%rax)
movslq 0x30(%r14), %rbp
testq %rbp, %rbp
jle 0x13886
xorl %r15d, %r15d
leaq 0x18(%rsp), %r12
leaq 0x10(%rsp), %r13
movq 0x38(%r14), %rax
movq (%rax), %rcx
movq 0x8(%rax), %rdx
movq 0x38(%rcx), %rcx
movsd (%rcx,%r15,8), %xmm0
movq 0x38(%rdx), %rcx
movsd (%rcx,%r15,8), %xmm1
movq 0x10(%rax), %rax
movq 0x38(%rax), %rax
movsd (%rax,%r15,8), %xmm2
leaq 0x20(%rsp), %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x1254b
movsd 0x168fa(%rip), %xmm9    # 0x2a058
movsd 0x20(%rsp), %xmm1
movsd 0x18(%rsp), %xmm2
movsd 0x10(%rsp), %xmm0
movapd %xmm2, %xmm3
mulsd 0x183a4(%rip), %xmm3    # 0x2bb20
movapd %xmm1, %xmm4
mulsd 0x183a0(%rip), %xmm4    # 0x2bb28
addsd %xmm3, %xmm4
movapd %xmm0, %xmm8
mulsd 0x18396(%rip), %xmm8    # 0x2bb30
addsd %xmm4, %xmm8
movapd %xmm2, %xmm6
mulsd 0x1838d(%rip), %xmm6    # 0x2bb38
movapd %xmm1, %xmm7
mulsd 0x18389(%rip), %xmm7    # 0x2bb40
movapd %xmm0, %xmm5
mulsd 0x18385(%rip), %xmm5    # 0x2bb48
mulsd 0x18385(%rip), %xmm2    # 0x2bb50
mulsd 0x18385(%rip), %xmm1    # 0x2bb58
mulsd 0x18385(%rip), %xmm0    # 0x2bb60
xorpd %xmm3, %xmm3
ucomisd %xmm8, %xmm3
xorpd %xmm4, %xmm4
ja 0x137fb
ucomisd %xmm9, %xmm8
movapd %xmm8, %xmm4
jbe 0x137fb
movapd %xmm9, %xmm4
addsd %xmm6, %xmm7
addsd %xmm7, %xmm5
ucomisd %xmm5, %xmm3
ja 0x13819
ucomisd %xmm9, %xmm5
movapd %xmm5, %xmm3
jbe 0x13819
movapd %xmm9, %xmm3
addsd %xmm2, %xmm1
addsd %xmm1, %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm0, %xmm1
ja 0x1383b
ucomisd %xmm9, %xmm0
movapd %xmm0, %xmm1
jbe 0x1383b
movapd %xmm9, %xmm1
movsd 0x8(%rsp), %xmm0
mulsd %xmm0, %xmm4
movq 0x38(%rbx), %rax
movq (%rax), %rcx
movq 0x38(%rcx), %rcx
movsd %xmm4, (%rcx,%r15,8)
mulsd %xmm0, %xmm3
movq 0x8(%rax), %rcx
movq 0x38(%rcx), %rcx
movsd %xmm3, (%rcx,%r15,8)
mulsd %xmm0, %xmm1
movq 0x10(%rax), %rax
movq 0x38(%rax), %rax
movsd %xmm1, (%rax,%r15,8)
incq %r15
cmpq %r15, %rbp
jne 0x13718
leaq 0x38(%rsp), %r15
movq %r15, -0x10(%r15)
movq 0x8(%r14), %rsi
movq 0x10(%r14), %rdx
addq %rsi, %rdx
leaq 0x28(%rsp), %r14
movq %r14, %rdi
callq 0xa92c
movq %rbx, %rdi
movq %r14, %rsi
callq 0xce40
movq 0x28(%rsp), %rdi
cmpq %r15, %rdi
je 0x138c9
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x3310
leaq 0x58(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x171c1(%rip), %rsi     # 0x2aa9a
leaq 0x171be(%rip), %rdx     # 0x2aa9e
leaq 0x48(%rsp), %r14
movq %r14, %rdi
callq 0xa9c2
movq %rbx, %rdi
movq %r14, %rsi
callq 0xce5a
movq 0x48(%rsp), %rdi
cmpq %r15, %rdi
je 0x1390f
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x3310
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq 0x48(%rsp), %rdi
cmpq %r15, %rdi
je 0x1394c
movq 0x58(%rsp), %rsi
jmp 0x13944
movq %rax, %rbx
movq 0x28(%rsp), %rdi
cmpq %r15, %rdi
je 0x1394c
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x3310
movq %rbx, %rdi
callq 0x3500