// File: /workspace/github_cpp_makefile_star2_O1/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 0x138eb
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 0x125af
movsd 0x17895(%rip), %xmm9    # 0x2b058
movsd 0x20(%rsp), %xmm1
movsd 0x18(%rsp), %xmm2
movsd 0x10(%rsp), %xmm0
movapd %xmm2, %xmm3
mulsd 0x19357(%rip), %xmm3    # 0x2cb38
movapd %xmm1, %xmm4
mulsd 0x19353(%rip), %xmm4    # 0x2cb40
addsd %xmm3, %xmm4
movapd %xmm0, %xmm8
mulsd 0x19349(%rip), %xmm8    # 0x2cb48
addsd %xmm4, %xmm8
movapd %xmm2, %xmm6
mulsd 0x19340(%rip), %xmm6    # 0x2cb50
movapd %xmm1, %xmm7
mulsd 0x1933c(%rip), %xmm7    # 0x2cb58
movapd %xmm0, %xmm5
mulsd 0x19338(%rip), %xmm5    # 0x2cb60
mulsd 0x19338(%rip), %xmm2    # 0x2cb68
mulsd 0x19338(%rip), %xmm1    # 0x2cb70
mulsd 0x19338(%rip), %xmm0    # 0x2cb78
xorpd %xmm3, %xmm3
ucomisd %xmm8, %xmm3
xorpd %xmm4, %xmm4
ja 0x13860
ucomisd %xmm9, %xmm8
movapd %xmm8, %xmm4
jbe 0x13860
movapd %xmm9, %xmm4
addsd %xmm6, %xmm7
addsd %xmm7, %xmm5
ucomisd %xmm5, %xmm3
ja 0x1387e
ucomisd %xmm9, %xmm5
movapd %xmm5, %xmm3
jbe 0x1387e
movapd %xmm9, %xmm3
addsd %xmm2, %xmm1
addsd %xmm1, %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm0, %xmm1
ja 0x138a0
ucomisd %xmm9, %xmm0
movapd %xmm0, %xmm1
jbe 0x138a0
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 0x1377d
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 0xa97e
movq %rbx, %rdi
movq %r14, %rsi
callq 0xcf04
movq 0x28(%rsp), %rdi
cmpq %r15, %rdi
je 0x1392e
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x3310
leaq 0x58(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x1817e(%rip), %rsi     # 0x2babc
leaq 0x1817b(%rip), %rdx     # 0x2bac0
leaq 0x48(%rsp), %r14
movq %r14, %rdi
callq 0xaa0e
movq %rbx, %rdi
movq %r14, %rsi
callq 0xcf1e
movq 0x48(%rsp), %rdi
cmpq %r15, %rdi
je 0x13974
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 0x139b1
movq 0x58(%rsp), %rsi
jmp 0x139a9
movq %rax, %rbx
movq 0x28(%rsp), %rdi
cmpq %r15, %rdi
je 0x139b1
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x3310
movq %rbx, %rdi
callq 0x3500