// File: /workspace/github_cpp_makefile_star2_O1/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 0x6192
movq 0x30f6c(%rip), %rax     # 0x37540
cmpq 0x30f5d(%rip), %rax     # 0x37538
je 0x6ba5
movq 0x30f50(%rip), %rsi     # 0x37538
cmpq %rsi, 0x30f51(%rip)     # 0x37540
je 0x6b74
xorl %r12d, %r12d
leaq 0x48(%rsp), %rbx
leaq 0x25c02(%rip), %r14     # 0x2c206
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 0x664e
movq %rbx, %rdi
leaq 0x25db6(%rip), %rsi     # 0x2c3f7
callq 0x30c0
testl %eax, %eax
jne 0x6b86
movq %rbx, %rdi
movq %r14, %rsi
callq 0x30c0
testl %eax, %eax
je 0x680b
movq %rbx, %rdi
leaq 0x25d8c(%rip), %rsi     # 0x2c3f7
callq 0x30c0
testl %eax, %eax
jne 0x6b33
movq %r15, %rdi
callq 0xe034
movq 0x30eb1(%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 0xa97e
movq %r15, %rdi
leaq 0x8(%rsp), %rsi
callq 0xe6b6
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x66d0
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x3310
cmpb $0x0, 0x30fa5(%rip)     # 0x3767c
je 0x694a
leaq 0x68(%rsp), %rbp
movq %rbp, %rdi
callq 0xcfd0
movl 0x190(%rsp), %esi
movl 0x194(%rsp), %edx
movq %rbp, %rdi
callq 0xd190
leaq 0x1b8(%rsp), %rdi
movq %r15, %rsi
callq 0xe118
leaq 0x1b8(%rsp), %rbp
movq %rbp, %rdi
leaq 0x68(%rsp), %rsi
callq 0x11cd0
movq %rbp, %rdi
callq 0xe372
cmpb $0x1, 0x30dbd(%rip)     # 0x374f1
jne 0x6772
leaq 0x108(%rsp), %rdi
leaq 0x68(%rsp), %rsi
movl $0x1, %edx
callq 0xdabe
movq 0x108(%rsp), %rdi
leaq 0x118(%rsp), %rax
cmpq %rax, %rdi
je 0x6772
movq 0x118(%rsp), %rsi
incq %rsi
callq 0x3310
cmpb $0x1, 0x30d78(%rip)     # 0x374f1
jne 0x67c2
leaq 0x68(%rsp), %rdi
movq %r15, %rsi
callq 0x11e84
leaq 0xe8(%rsp), %rdi
movq %r15, %rsi
movl $0x1, %edx
callq 0xeb0a
movq 0xe8(%rsp), %rdi
leaq 0xf8(%rsp), %rax
cmpq %rax, %rdi
je 0x67c2
movq 0xf8(%rsp), %rsi
incq %rsi
callq 0x3310
movsd 0x30e8e(%rip), %xmm0    # 0x37658
ucomisd 0x248a6(%rip), %xmm0    # 0x2b078
jae 0x6a2d
leaq 0x208(%rsp), %rdi
leaq 0x30dd1(%rip), %rsi     # 0x375b8
callq 0xa4d4
leaq 0x68(%rsp), %rdi
movl $0x1, %esi
leaq 0x208(%rsp), %rbp
movq %rbp, %rdx
callq 0x16ace
jmp 0x6a5b
movq %r15, %rdi
callq 0xcfd0
movq 0x30d1e(%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 0xa97e
movq %r15, %rdi
leaq 0x28(%rsp), %rsi
callq 0xd69c
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x6863
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x3310
movsd 0x30ded(%rip), %xmm0    # 0x37658
ucomisd 0x24805(%rip), %xmm0    # 0x2b078
jae 0x68a0
leaq 0x4c8(%rsp), %rdi
leaq 0x30d34(%rip), %rsi     # 0x375b8
callq 0xa4d4
movq %r15, %rdi
xorl %esi, %esi
leaq 0x4c8(%rsp), %rbp
movq %rbp, %rdx
callq 0x16ace
jmp 0x68c9
leaq 0x578(%rsp), %rdi
leaq 0x30d09(%rip), %rsi     # 0x375b8
callq 0xa4d4
movq %r15, %rdi
xorl %esi, %esi
leaq 0x578(%rsp), %rbp
movq %rbp, %rdx
callq 0x14127
movq %rbp, %rdi
callq 0x9fce
movq 0x306f8(%rip), %rcx     # 0x36fd0
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x32e0
movsbl %al, %esi
movq 0x306da(%rip), %rdi     # 0x36fd0
callq 0x3040
movq %rax, %rdi
callq 0x31f0
leaq 0x148(%rsp), %rdi
movq %r15, %rsi
movl $0x1, %edx
callq 0xdabe
movq 0x148(%rsp), %rdi
leaq 0x158(%rsp), %rax
cmpq %rax, %rdi
je 0x693d
movq 0x158(%rsp), %rsi
incq %rsi
callq 0x3310
movq %r15, %rdi
callq 0xd0fc
jmp 0x6b33
movsd 0x30d06(%rip), %xmm0    # 0x37658
ucomisd 0x2471e(%rip), %xmm0    # 0x2b078
jae 0x6987
leaq 0x368(%rsp), %rdi
leaq 0x30c4d(%rip), %rsi     # 0x375b8
callq 0xa4d4
movq %r15, %rdi
xorl %esi, %esi
leaq 0x368(%rsp), %rbp
movq %rbp, %rdx
callq 0x175c6
jmp 0x69b0
leaq 0x418(%rsp), %rdi
leaq 0x30c22(%rip), %rsi     # 0x375b8
callq 0xa4d4
movq %r15, %rdi
xorl %esi, %esi
leaq 0x418(%rsp), %rbp
movq %rbp, %rdx
callq 0x172ec
movq %rbp, %rdi
callq 0x9fce
movq 0x30611(%rip), %rcx     # 0x36fd0
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x32e0
movsbl %al, %esi
movq 0x305f3(%rip), %rdi     # 0x36fd0
callq 0x3040
movq %rax, %rdi
callq 0x31f0
leaq 0x128(%rsp), %rdi
movq %r15, %rsi
movl $0x1, %edx
callq 0xeb0a
movq 0x128(%rsp), %rdi
leaq 0x138(%rsp), %rax
cmpq %rax, %rdi
je 0x6b2b
movq 0x138(%rsp), %rsi
incq %rsi
callq 0x3310
jmp 0x6b2b
leaq 0x2b8(%rsp), %rdi
leaq 0x30b7c(%rip), %rsi     # 0x375b8
callq 0xa4d4
leaq 0x68(%rsp), %rdi
movl $0x1, %esi
leaq 0x2b8(%rsp), %rbp
movq %rbp, %rdx
callq 0x14127
movq %rbp, %rdi
callq 0x9fce
cmpb $0x1, 0x30a87(%rip)     # 0x374f1
jne 0x6ada
movq 0x3055d(%rip), %rcx     # 0x36fd0
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x32e0
movsbl %al, %esi
movq 0x3053f(%rip), %rdi     # 0x36fd0
callq 0x3040
movq %rax, %rdi
callq 0x31f0
leaq 0xc8(%rsp), %rdi
leaq 0x68(%rsp), %rsi
movl $0x1, %edx
callq 0xdabe
movq 0xc8(%rsp), %rdi
leaq 0xd8(%rsp), %rax
cmpq %rax, %rdi
je 0x6ada
movq 0xd8(%rsp), %rsi
incq %rsi
callq 0x3310
leaq 0x68(%rsp), %rdi
movq %r15, %rsi
callq 0x11e84
leaq 0xa8(%rsp), %rdi
movq %r15, %rsi
movl $0x1, %edx
callq 0xeb0a
movq 0xa8(%rsp), %rdi
leaq 0xb8(%rsp), %rax
cmpq %rax, %rdi
je 0x6b21
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x3310
leaq 0x68(%rsp), %rdi
callq 0xd0fc
movq %r15, %rdi
callq 0xe372
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
je 0x6b4f
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x3310
incq %r13
movq 0x309e7(%rip), %rax     # 0x37540
movq 0x309d8(%rip), %rsi     # 0x37538
subq %rsi, %rax
sarq $0x5, %rax
addq $0x20, %r12
cmpq %r13, %rax
ja 0x660f
addq $0x628, %rsp            # imm = 0x628
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x246c5(%rip), %rdi     # 0x2b252
leaq 0x246c9(%rip), %rsi     # 0x2b25d
leaq 0x246cb(%rip), %rcx     # 0x2b266
movl $0x9d, %edx
callq 0x31c0
leaq 0x24c6a(%rip), %rdi     # 0x2b816
callq 0x403c
movq %rax, %rbx
leaq 0x2b8(%rsp), %rdi
jmp 0x6beb
movq %rax, %rbx
leaq 0x368(%rsp), %rdi
jmp 0x6bd6
movq %rax, %rbx
leaq 0x418(%rsp), %rdi
callq 0x9fce
jmp 0x6c83
movq %rax, %rbx
leaq 0x208(%rsp), %rdi
callq 0x9fce
jmp 0x6c79
movq %rax, %rbx
leaq 0x1b8(%rsp), %rdi
callq 0xe372
jmp 0x6c79
jmp 0x6c71
movq %rax, %rbx
leaq 0x4c8(%rsp), %rdi
jmp 0x6c21
movq %rax, %rbx
leaq 0x578(%rsp), %rdi
callq 0x9fce
jmp 0x6c95
movq %rax, %rbx
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x6c83
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x3310
jmp 0x6c83
jmp 0x6c6c
movq %rax, %rbx
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x6c95
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x3310
jmp 0x6c95
movq %rax, %rbx
jmp 0x6ca2
movq %rax, %rbx
jmp 0x6c83
movq %rax, %rbx
leaq 0x68(%rsp), %rdi
callq 0xd0fc
leaq 0x168(%rsp), %rdi
callq 0xe372
jmp 0x6ca2
movq %rax, %rbx
leaq 0x168(%rsp), %rdi
callq 0xd0fc
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
je 0x6cbe
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x3310
movq %rbx, %rdi
callq 0x3500