// File: /workspace/github_cpp_makefile_star2_O1/kebwi[P]Trifid/src/ImageProcs.cpp
// Function: addSensorNoise(Image3ChnlReal&, bool, NoiseParam)
void addSensorNoise(Image3ChnlReal &rgbImage, bool applyBayer, NoiseParam noiseParams)
{
	cout << "Adding color sensor noise..." << endl;
	
	//Check to see if the image is normalized
	int totalPixels = rgbImage.totalPixels();
	Float_t maxVal = 0;
	for (int c = 0; c < 3; c++)
		for (int i = 0; i < totalPixels; i++)
		{
			assert((*rgbImage[c])[i] >= 0 && (*rgbImage[c])[i] <= 1.0);
			if ((*rgbImage[c])[i] > maxVal)
				maxVal = (*rgbImage[c])[i];
		}
	if (maxVal != 1.0)
		cout << "***  NOTE  ***  This input image is not normalized yet" << endl;
	
	//Noisify the image
	cout << endl << setw(40) << left << "  Noisifying with ags: " << noiseParams.ampGain_ << endl;
	for (int c = 0; c < 3; c++)
		addSensorNoise(*rgbImage[c], applyBayer, noiseParams);
	
	rgbImage.appendFilename("_n-");
	rgbImage.appendFilename(noiseParams.label_);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xf8, %rsp
movq %rdx, %r14
movl %esi, %ebp
movq %rdi, %rbx
movq 0x1fcc4(%rip), %r15     # 0x36fd0
leaq 0x165aa(%rip), %rsi     # 0x2d8bd
movl $0x1c, %edx
movq %r15, %rdi
callq 0x3360
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x32e0
movsbl %al, %esi
movq %r15, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x31f0
movl 0x30(%rbx), %eax
movq 0x38(%rbx), %rcx
xorpd %xmm0, %xmm0
xorl %edx, %edx
movsd 0x13cfc(%rip), %xmm1    # 0x2b058
xorpd %xmm2, %xmm2
testl %eax, %eax
jle 0x1739b
movq (%rcx,%rdx,8), %rsi
movq 0x38(%rsi), %rsi
xorl %edi, %edi
movapd %xmm2, %xmm3
movsd (%rsi,%rdi,8), %xmm2
ucomisd %xmm0, %xmm2
jb 0x17562
ucomisd %xmm2, %xmm1
jb 0x17562
maxsd %xmm3, %xmm2
incq %rdi
movapd %xmm2, %xmm3
cmpq %rdi, %rax
jne 0x17372
incq %rdx
cmpq $0x3, %rdx
jne 0x17360
ucomisd 0x13cac(%rip), %xmm2    # 0x2b058
jne 0x173b0
jnp 0x173eb
leaq 0x162fa(%rip), %rsi     # 0x2d6b1
movl $0x36, %edx
movq %r15, %rdi
callq 0x3360
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x32e0
movsbl %al, %esi
movq %r15, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x31f0
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x32e0
movsbl %al, %esi
movq %r15, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x31f0
movq %rax, %r15
movq (%rax), %rax
movq -0x18(%rax), %rcx
movq $0x28, 0x10(%r15,%rcx)
movq -0x18(%rax), %rax
movl $0xffffff4f, %ecx       # imm = 0xFFFFFF4F
andl 0x18(%r15,%rax), %ecx
orl $0x20, %ecx
movl %ecx, 0x18(%r15,%rax)
leaq 0x16386(%rip), %rsi     # 0x2d7c8
movl $0x17, %edx
movq %r15, %rdi
callq 0x3360
movsd 0xa0(%r14), %xmm0
movq %r15, %rdi
callq 0x3480
movq %rax, %r15
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x32e0
movsbl %al, %esi
movq %r15, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x31f0
xorl %r13d, %r13d
leaq 0x48(%rsp), %r15
movzbl %bpl, %ebp
movq 0x38(%rbx), %rax
movq (%rax,%r13,8), %r12
movq %r15, %rdi
movq %r14, %rsi
callq 0xa4d4
movq %r12, %rdi
movl %ebp, %esi
movq %r15, %rdx
callq 0x14127
movq %r15, %rdi
callq 0x9fce
incq %r13
cmpq $0x3, %r13
jne 0x17496
leaq 0x38(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x160d8(%rip), %rsi     # 0x2d5b0
leaq 0x160d4(%rip), %rdx     # 0x2d5b3
leaq 0x28(%rsp), %r15
movq %r15, %rdi
callq 0xaa0e
movq %rbx, %rdi
movq %r15, %rsi
callq 0xcf1e
movq 0x28(%rsp), %rdi
cmpq %r12, %rdi
je 0x1750e
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x3310
leaq 0x18(%rsp), %r15
movq %r15, -0x10(%r15)
movq (%r14), %rsi
movq 0x8(%r14), %rdx
addq %rsi, %rdx
leaq 0x8(%rsp), %r14
movq %r14, %rdi
callq 0xa97e
movq %rbx, %rdi
movq %r14, %rsi
callq 0xcf1e
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
je 0x17550
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x3310
addq $0xf8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x16371(%rip), %rdi     # 0x2d8da
leaq 0x15749(%rip), %rsi     # 0x2ccb9
leaq 0x16396(%rip), %rcx     # 0x2d90d
movl $0x473, %edx            # imm = 0x473
callq 0x31c0
movq %rax, %rbx
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
je 0x175be
movq 0x18(%rsp), %rsi
jmp 0x175a7
movq %rax, %rbx
movq 0x28(%rsp), %rdi
cmpq %r12, %rdi
je 0x175be
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x3310
jmp 0x175be
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0x9fce
movq %rbx, %rdi
callq 0x3500