// File: /workspace/github_cpp_makefile_star2_O3/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 0x20183(%rip), %r15     # 0x36fd0
leaq 0x15a71(%rip), %rsi     # 0x2c8c5
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 0x131bb(%rip), %xmm1    # 0x2a058
xorpd %xmm2, %xmm2
testl %eax, %eax
jle 0x16edc
movq (%rcx,%rdx,8), %rsi
movq 0x38(%rsi), %rsi
xorl %edi, %edi
movapd %xmm2, %xmm3
movsd (%rsi,%rdi,8), %xmm2
ucomisd %xmm0, %xmm2
jb 0x170a3
ucomisd %xmm2, %xmm1
jb 0x170a3
maxsd %xmm3, %xmm2
incq %rdi
movapd %xmm2, %xmm3
cmpq %rdi, %rax
jne 0x16eb3
incq %rdx
cmpq $0x3, %rdx
jne 0x16ea1
ucomisd 0x1316b(%rip), %xmm2    # 0x2a058
jne 0x16ef1
jnp 0x16f2c
leaq 0x157c1(%rip), %rsi     # 0x2c6b9
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 0x1584d(%rip), %rsi     # 0x2c7d0
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 0xa486
movq %r12, %rdi
movl %ebp, %esi
movq %r15, %rdx
callq 0x140d6
movq %r15, %rdi
callq 0x9f80
incq %r13
cmpq $0x3, %r13
jne 0x16fd7
leaq 0x38(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x1559f(%rip), %rsi     # 0x2c5b8
leaq 0x1559b(%rip), %rdx     # 0x2c5bb
leaq 0x28(%rsp), %r15
movq %r15, %rdi
callq 0xa9c2
movq %rbx, %rdi
movq %r15, %rsi
callq 0xce5a
movq 0x28(%rsp), %rdi
cmpq %r12, %rdi
je 0x1704f
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 0xa92c
movq %rbx, %rdi
movq %r14, %rsi
callq 0xce5a
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
je 0x17091
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 0x15838(%rip), %rdi     # 0x2c8e2
leaq 0x14c10(%rip), %rsi     # 0x2bcc1
leaq 0x1585d(%rip), %rcx     # 0x2c915
movl $0x473, %edx            # imm = 0x473
callq 0x31c0
movq %rax, %rbx
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
je 0x170ff
movq 0x18(%rsp), %rsi
jmp 0x170e8
movq %rax, %rbx
movq 0x28(%rsp), %rdi
cmpq %r12, %rdi
je 0x170ff
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x3310
jmp 0x170ff
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0x9f80
movq %rbx, %rdi
callq 0x3500