// File: /workspace/github_cpp_makefile_star2_O3/kebwi[P]Trifid/src/main.cpp
// Function: programBehaviorNoisify()
void programBehaviorNoisify()
{
	readNoiseParamsFile();
	
	if (sInputFilenames.size() < 1)
		die("Supply at least one image as argument:\n  -- PGM - original gray image\n  -- PPM - original RGB image\n");
	
	for (int imageIdx = 0; imageIdx < sInputFilenames.size(); imageIdx++)
	{
		string fileExtension = sInputFilenames[imageIdx].substr(sInputFilenames[imageIdx].length() - 3, 3);
		myAssert(fileExtension == "pgm" || fileExtension == "ppm");
		
		if (fileExtension == "pgm")	//Noisify a grayscale image
		{
			ImageReal grayImg;
			grayImg.readFile(sInputFilenames[imageIdx]);
			
			if (sNoiseParams.ampGain_ >= 0)	//No auto-ISO
				addSensorNoise(grayImg, false, sNoiseParams);
			else addSensorNoiseWithAutoISO(grayImg, false, sNoiseParams);	//Auto-ISO
			
			cout << endl;
			grayImg.writeFile(1);
			//Write 16-bit file --- grayImg.writeFile(2);
		}
		else if (fileExtension == "ppm")	//Noisify a color image
		{
			Image3ChnlReal rgbImg;
			rgbImg.readFile(sInputFilenames[imageIdx]);
			
			if (!sBayerize)
			{
				if (sNoiseParams.ampGain_ >= 0)	//No auto-ISO
					addSensorNoise(rgbImg, false, sNoiseParams);
				else addSensorNoiseWithAutoISO(rgbImg, false, sNoiseParams);	//Auto-ISO
				
				cout << endl;
				rgbImg.writeFile(1);
				//Write 16-bit file --- rgbImg.writeFile(2);
			}
			else	//Bayerize
			{
				//Bayerize the input image (convert from rgb to gray)
				ImageReal grayImg;
				grayImg.resize(rgbImg.width(), rgbImg.height());
				bayer(rgbImg, grayImg);
				
				if (gGenerateIntermediateImages)
				{
					grayImg.writeFile(1);
					//Write 16-bit file --- grayImg.writeFile(2);
				}
				
				if (gGenerateIntermediateImages)
				{
					//Immediately deBayer
					//Strictly speaking, this isn't an "intermediate" image (ala gGenerateIntermediateImages),
					//but it might be interesting to see.
					deBayer(grayImg, rgbImg);
					rgbImg.writeFile(1);
				}
				
				//Denoise the gray Bayer image
				if (sNoiseParams.ampGain_ >= 0)	//No auto-ISO
					addSensorNoise(grayImg, true, sNoiseParams);
				else addSensorNoiseWithAutoISO(grayImg, true, sNoiseParams);	//Auto-ISO
				
				if (gGenerateIntermediateImages)
				{
					//Strictly speaking, this isn't an "intermediate" image (ala gGenerateIntermediateImages),
					//but it might be interesting to see.
					cout << endl;
					grayImg.writeFile(1);
					//Write 16-bit file --- grayImg.writeFile(2);
				}
				
				//Debayerize back to color
				deBayer(grayImg, rgbImg);
				rgbImg.writeFile(1);
				//Write 16-bit file --- rgbImg.writeFile(2);
			}
		}
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x628, %rsp            # imm = 0x628
callq 0x60d9
movq 0x31019(%rip), %rsi     # 0x37538
cmpq %rsi, 0x3101a(%rip)     # 0x37540
je 0x6adc
xorl %r12d, %r12d
leaq 0x48(%rsp), %rbx
leaq 0x24ca3(%rip), %r14     # 0x2b1de
leaq 0x168(%rsp), %r15
xorl %r13d, %r13d
movq 0x8(%rsi,%r12), %rdx
addq %r12, %rsi
addq $-0x3, %rdx
movl $0x3, %ecx
movq %rbx, %rdi
callq 0x3330
movq %rbx, %rdi
movq %r14, %rsi
callq 0x30c0
testl %eax, %eax
je 0x6585
movq %rbx, %rdi
leaq 0x24e57(%rip), %rsi     # 0x2b3cf
callq 0x30c0
testl %eax, %eax
jne 0x6abd
movq %rbx, %rdi
movq %r14, %rsi
callq 0x30c0
testl %eax, %eax
je 0x6742
movq %rbx, %rdi
leaq 0x24e2d(%rip), %rsi     # 0x2b3cf
callq 0x30c0
testl %eax, %eax
jne 0x6a6a
movq %r15, %rdi
callq 0xdf68
movq 0x30f7a(%rip), %rax     # 0x37538
leaq 0x18(%rsp), %rcx
movq %rcx, 0x8(%rsp)
movq (%rax,%r12), %rsi
movq 0x8(%rax,%r12), %rdx
addq %rsi, %rdx
leaq 0x8(%rsp), %rdi
callq 0xa92c
movq %r15, %rdi
leaq 0x8(%rsp), %rsi
callq 0xe5f4
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x6607
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x3310
cmpb $0x0, 0x3106e(%rip)     # 0x3767c
je 0x6881
leaq 0x68(%rsp), %rbp
movq %rbp, %rdi
callq 0xcf0c
movl 0x190(%rsp), %esi
movl 0x194(%rsp), %edx
movq %rbp, %rdi
callq 0xd0cc
leaq 0x1b8(%rsp), %rdi
movq %r15, %rsi
callq 0xe04c
leaq 0x1b8(%rsp), %rbp
movq %rbp, %rdi
leaq 0x68(%rsp), %rsi
callq 0x11c67
movq %rbp, %rdi
callq 0xe2a6
cmpb $0x1, 0x30e86(%rip)     # 0x374f1
jne 0x66a9
leaq 0x108(%rsp), %rdi
leaq 0x68(%rsp), %rsi
movl $0x1, %edx
callq 0xd9fc
movq 0x108(%rsp), %rdi
leaq 0x118(%rsp), %rax
cmpq %rax, %rdi
je 0x66a9
movq 0x118(%rsp), %rsi
incq %rsi
callq 0x3310
cmpb $0x1, 0x30e41(%rip)     # 0x374f1
jne 0x66f9
leaq 0x68(%rsp), %rdi
movq %r15, %rsi
callq 0x11e1b
leaq 0xe8(%rsp), %rdi
movq %r15, %rsi
movl $0x1, %edx
callq 0xea48
movq 0xe8(%rsp), %rdi
leaq 0xf8(%rsp), %rax
cmpq %rax, %rdi
je 0x66f9
movq 0xf8(%rsp), %rsi
incq %rsi
callq 0x3310
movsd 0x30f57(%rip), %xmm0    # 0x37658
ucomisd 0x2396f(%rip), %xmm0    # 0x2a078
jae 0x6964
leaq 0x208(%rsp), %rdi
leaq 0x30e9a(%rip), %rsi     # 0x375b8
callq 0xa486
leaq 0x68(%rsp), %rdi
movl $0x1, %esi
leaq 0x208(%rsp), %rbp
movq %rbp, %rdx
callq 0x165d4
jmp 0x6992
movq %r15, %rdi
callq 0xcf0c
movq 0x30de7(%rip), %rax     # 0x37538
leaq 0x38(%rsp), %rcx
movq %rcx, 0x28(%rsp)
movq (%rax,%r12), %rsi
movq 0x8(%rax,%r12), %rdx
addq %rsi, %rdx
leaq 0x28(%rsp), %rdi
callq 0xa92c
movq %r15, %rdi
leaq 0x28(%rsp), %rsi
callq 0xd5da
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x679a
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x3310
movsd 0x30eb6(%rip), %xmm0    # 0x37658
ucomisd 0x238ce(%rip), %xmm0    # 0x2a078
jae 0x67d7
leaq 0x4c8(%rsp), %rdi
leaq 0x30dfd(%rip), %rsi     # 0x375b8
callq 0xa486
movq %r15, %rdi
xorl %esi, %esi
leaq 0x4c8(%rsp), %rbp
movq %rbp, %rdx
callq 0x165d4
jmp 0x6800
leaq 0x578(%rsp), %rdi
leaq 0x30dd2(%rip), %rsi     # 0x375b8
callq 0xa486
movq %r15, %rdi
xorl %esi, %esi
leaq 0x578(%rsp), %rbp
movq %rbp, %rdx
callq 0x140d6
movq %rbp, %rdi
callq 0x9f80
movq 0x307c1(%rip), %rcx     # 0x36fd0
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x32e0
movsbl %al, %esi
movq 0x307a3(%rip), %rdi     # 0x36fd0
callq 0x3040
movq %rax, %rdi
callq 0x31f0
leaq 0x148(%rsp), %rdi
movq %r15, %rsi
movl $0x1, %edx
callq 0xd9fc
movq 0x148(%rsp), %rdi
leaq 0x158(%rsp), %rax
cmpq %rax, %rdi
je 0x6874
movq 0x158(%rsp), %rsi
incq %rsi
callq 0x3310
movq %r15, %rdi
callq 0xd038
jmp 0x6a6a
movsd 0x30dcf(%rip), %xmm0    # 0x37658
ucomisd 0x237e7(%rip), %xmm0    # 0x2a078
jae 0x68be
leaq 0x368(%rsp), %rdi
leaq 0x30d16(%rip), %rsi     # 0x375b8
callq 0xa486
movq %r15, %rdi
xorl %esi, %esi
leaq 0x368(%rsp), %rbp
movq %rbp, %rdx
callq 0x17107
jmp 0x68e7
leaq 0x418(%rsp), %rdi
leaq 0x30ceb(%rip), %rsi     # 0x375b8
callq 0xa486
movq %r15, %rdi
xorl %esi, %esi
leaq 0x418(%rsp), %rbp
movq %rbp, %rdx
callq 0x16e2d
movq %rbp, %rdi
callq 0x9f80
movq 0x306da(%rip), %rcx     # 0x36fd0
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x32e0
movsbl %al, %esi
movq 0x306bc(%rip), %rdi     # 0x36fd0
callq 0x3040
movq %rax, %rdi
callq 0x31f0
leaq 0x128(%rsp), %rdi
movq %r15, %rsi
movl $0x1, %edx
callq 0xea48
movq 0x128(%rsp), %rdi
leaq 0x138(%rsp), %rax
cmpq %rax, %rdi
je 0x6a62
movq 0x138(%rsp), %rsi
incq %rsi
callq 0x3310
jmp 0x6a62
leaq 0x2b8(%rsp), %rdi
leaq 0x30c45(%rip), %rsi     # 0x375b8
callq 0xa486
leaq 0x68(%rsp), %rdi
movl $0x1, %esi
leaq 0x2b8(%rsp), %rbp
movq %rbp, %rdx
callq 0x140d6
movq %rbp, %rdi
callq 0x9f80
cmpb $0x1, 0x30b50(%rip)     # 0x374f1
jne 0x6a11
movq 0x30626(%rip), %rcx     # 0x36fd0
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x32e0
movsbl %al, %esi
movq 0x30608(%rip), %rdi     # 0x36fd0
callq 0x3040
movq %rax, %rdi
callq 0x31f0
leaq 0xc8(%rsp), %rdi
leaq 0x68(%rsp), %rsi
movl $0x1, %edx
callq 0xd9fc
movq 0xc8(%rsp), %rdi
leaq 0xd8(%rsp), %rax
cmpq %rax, %rdi
je 0x6a11
movq 0xd8(%rsp), %rsi
incq %rsi
callq 0x3310
leaq 0x68(%rsp), %rdi
movq %r15, %rsi
callq 0x11e1b
leaq 0xa8(%rsp), %rdi
movq %r15, %rsi
movl $0x1, %edx
callq 0xea48
movq 0xa8(%rsp), %rdi
leaq 0xb8(%rsp), %rax
cmpq %rax, %rdi
je 0x6a58
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x3310
leaq 0x68(%rsp), %rdi
callq 0xd038
movq %r15, %rdi
callq 0xe2a6
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
je 0x6a86
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x3310
incq %r13
movq 0x30ab0(%rip), %rax     # 0x37540
movq 0x30aa1(%rip), %rsi     # 0x37538
subq %rsi, %rax
sarq $0x5, %rax
addq $0x20, %r12
cmpq %r13, %rax
ja 0x6546
addq $0x628, %rsp            # imm = 0x628
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x237a6(%rip), %rdi     # 0x2a26a
leaq 0x237aa(%rip), %rsi     # 0x2a275
leaq 0x237ac(%rip), %rcx     # 0x2a27e
movl $0x9d, %edx
callq 0x31c0
leaq 0x23d11(%rip), %rdi     # 0x2a7f4
callq 0x403c
movq %rax, %rbx
leaq 0x2b8(%rsp), %rdi
jmp 0x6b22
movq %rax, %rbx
leaq 0x368(%rsp), %rdi
jmp 0x6b0d
movq %rax, %rbx
leaq 0x418(%rsp), %rdi
callq 0x9f80
jmp 0x6bba
movq %rax, %rbx
leaq 0x208(%rsp), %rdi
callq 0x9f80
jmp 0x6bb0
movq %rax, %rbx
leaq 0x1b8(%rsp), %rdi
callq 0xe2a6
jmp 0x6bb0
jmp 0x6ba8
movq %rax, %rbx
leaq 0x4c8(%rsp), %rdi
jmp 0x6b58
movq %rax, %rbx
leaq 0x578(%rsp), %rdi
callq 0x9f80
jmp 0x6bcc
movq %rax, %rbx
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x6bba
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x3310
jmp 0x6bba
jmp 0x6ba3
movq %rax, %rbx
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x6bcc
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x3310
jmp 0x6bcc
movq %rax, %rbx
jmp 0x6bd9
movq %rax, %rbx
jmp 0x6bba
movq %rax, %rbx
leaq 0x68(%rsp), %rdi
callq 0xd038
leaq 0x168(%rsp), %rdi
callq 0xe2a6
jmp 0x6bd9
movq %rax, %rbx
leaq 0x168(%rsp), %rdi
callq 0xd038
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
je 0x6bf5
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x3310
movq %rbx, %rdi
callq 0x3500