// File: /workspace/github_cpp_makefile_star2_O2/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 0x540c
movq 0x2ad59(%rip), %rax     # 0x30530
movq 0x2ad4a(%rip), %rsi     # 0x30528
cmpq %rsi, %rax
je 0x5c14
xorl %ebp, %ebp
leaq 0x198(%rsp), %rbx
leaq 0x1d9d6(%rip), %r15     # 0x231ce
leaq 0x128(%rsp), %r12
xorl %r14d, %r14d
subq %rsi, %rax
sarq $0x5, %rax
cmpq %r14, %rax
jbe 0x5c02
movq 0x8(%rsi,%rbp), %rdx
addq %rbp, %rsi
addq $-0x3, %rdx
movq %rbx, %rdi
pushq $0x3
popq %rcx
callq 0x3300
movq %rbx, %rdi
movq %r15, %rsi
callq 0x80ee
movl %eax, %ecx
movb $0x1, %al
testb %cl, %cl
jne 0x584c
movq %rbx, %rdi
leaq 0x1db78(%rip), %rsi     # 0x233bf
callq 0x80ee
movzbl %al, %edi
callq 0x3be6
movq %rbx, %rdi
movq %r15, %rsi
callq 0x80ee
testb %al, %al
je 0x58db
movq %r12, %rdi
callq 0xa588
movq 0x2acb6(%rip), %rsi     # 0x30528
addq %rbp, %rsi
leaq 0x68(%rsp), %rdi
callq 0x33b0
movq %r12, %rdi
leaq 0x68(%rsp), %r13
movq %r13, %rsi
callq 0xac74
movq %r13, %rdi
callq 0x3548
movsd 0x2ada9(%rip), %xmm0    # 0x30648
ucomisd 0x1c7d1(%rip), %xmm0    # 0x22078
jae 0x5a2d
leaq 0x4c8(%rsp), %rdi
leaq 0x2acec(%rip), %rsi     # 0x305a8
callq 0x8544
movq %r12, %rdi
xorl %esi, %esi
leaq 0x4c8(%rsp), %r13
movq %r13, %rdx
callq 0x11fd2
jmp 0x5a56
movq %rbx, %rdi
leaq 0x1dada(%rip), %rsi     # 0x233bf
callq 0x80ee
testb %al, %al
je 0x5be0
movq %r12, %rdi
callq 0xb390
movq 0x2ac27(%rip), %rsi     # 0x30528
addq %rbp, %rsi
leaq 0x48(%rsp), %rdi
callq 0x33b0
movq %r12, %rdi
leaq 0x48(%rsp), %r13
movq %r13, %rsi
callq 0xb9be
movq %r13, %rdi
callq 0x3548
cmpb $0x0, 0x2ad3f(%rip)     # 0x3066c
je 0x5a97
leaq 0x8(%rsp), %r13
movq %r13, %rdi
callq 0xa588
movl 0x150(%rsp), %esi
movl 0x154(%rsp), %edx
movq %r13, %rdi
callq 0xa738
leaq 0x1b8(%rsp), %rdi
movq %r12, %rsi
callq 0xb45c
leaq 0x1b8(%rsp), %r13
movq %r13, %rdi
leaq 0x8(%rsp), %rsi
callq 0xeaf0
movq %r13, %rdi
callq 0xb686
movb 0x2ab58(%rip), %al      # 0x304e1
cmpb $0x1, %al
jne 0x59b5
leaq 0xe8(%rsp), %rdi
leaq 0x8(%rsp), %rsi
pushq $0x1
popq %rdx
callq 0xb028
leaq 0xe8(%rsp), %rdi
callq 0x3548
movb 0x2ab2c(%rip), %al      # 0x304e1
testb $0x1, %al
je 0x59e6
leaq 0x8(%rsp), %rdi
movq %r12, %rsi
callq 0xebfd
leaq 0xc8(%rsp), %rdi
movq %r12, %rsi
pushq $0x1
popq %rdx
callq 0xbda4
leaq 0xc8(%rsp), %rdi
callq 0x3548
movsd 0x2ac5a(%rip), %xmm0    # 0x30648
ucomisd 0x1c682(%rip), %xmm0    # 0x22078
jae 0x5b36
leaq 0x208(%rsp), %rdi
leaq 0x2ab9d(%rip), %rsi     # 0x305a8
callq 0x8544
leaq 0x8(%rsp), %rdi
pushq $0x1
popq %rsi
leaq 0x208(%rsp), %r13
movq %r13, %rdx
callq 0x11fd2
jmp 0x5b62
leaq 0x578(%rsp), %rdi
leaq 0x2ab6c(%rip), %rsi     # 0x305a8
callq 0x8544
movq %r12, %rdi
xorl %esi, %esi
leaq 0x578(%rsp), %r13
movq %r13, %rdx
callq 0x105a0
movq %r13, %rdi
callq 0x805c
movq 0x2a56b(%rip), %rdi     # 0x2ffd0
callq 0x3120
leaq 0x178(%rsp), %rdi
movq %r12, %rsi
pushq $0x1
popq %rdx
callq 0xb028
leaq 0x178(%rsp), %rdi
callq 0x3548
movq %r12, %rdi
callq 0xa6a6
jmp 0x5be0
movsd 0x2aba9(%rip), %xmm0    # 0x30648
ucomisd 0x1c5d1(%rip), %xmm0    # 0x22078
jae 0x5ad4
leaq 0x368(%rsp), %rdi
leaq 0x2aaf0(%rip), %rsi     # 0x305a8
callq 0x8544
movq %r12, %rdi
xorl %esi, %esi
leaq 0x368(%rsp), %r13
movq %r13, %rdx
callq 0x1274c
jmp 0x5afd
leaq 0x418(%rsp), %rdi
leaq 0x2aac5(%rip), %rsi     # 0x305a8
callq 0x8544
movq %r12, %rdi
xorl %esi, %esi
leaq 0x418(%rsp), %r13
movq %r13, %rdx
callq 0x12573
movq %r13, %rdi
callq 0x805c
movq 0x2a4c4(%rip), %rdi     # 0x2ffd0
callq 0x3120
leaq 0x108(%rsp), %rdi
movq %r12, %rsi
pushq $0x1
popq %rdx
callq 0xbda4
leaq 0x108(%rsp), %rdi
callq 0x3548
jmp 0x5bd8
leaq 0x2b8(%rsp), %rdi
leaq 0x2aa63(%rip), %rsi     # 0x305a8
callq 0x8544
leaq 0x8(%rsp), %rdi
pushq $0x1
popq %rsi
leaq 0x2b8(%rsp), %r13
movq %r13, %rdx
callq 0x105a0
movq %r13, %rdi
callq 0x805c
cmpb $0x1, 0x2a970(%rip)     # 0x304e1
jne 0x5ba1
movq 0x2a456(%rip), %rdi     # 0x2ffd0
callq 0x3120
leaq 0xa8(%rsp), %rdi
leaq 0x8(%rsp), %rsi
pushq $0x1
popq %rdx
callq 0xb028
leaq 0xa8(%rsp), %rdi
callq 0x3548
leaq 0x8(%rsp), %rdi
movq %r12, %rsi
callq 0xebfd
leaq 0x88(%rsp), %rdi
movq %r12, %rsi
pushq $0x1
popq %rdx
callq 0xbda4
leaq 0x88(%rsp), %rdi
callq 0x3548
leaq 0x8(%rsp), %rdi
callq 0xa6a6
movq %r12, %rdi
callq 0xb686
movq %rbx, %rdi
callq 0x3548
incq %r14
movq 0x2a93e(%rip), %rax     # 0x30530
movq 0x2a92f(%rip), %rsi     # 0x30528
addq $0x20, %rbp
jmp 0x5803
addq $0x628, %rsp            # imm = 0x628
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1cbc5(%rip), %rdi     # 0x227e0
callq 0x3b3c
movq %rax, %rbx
leaq 0x368(%rsp), %rdi
jmp 0x5c57
movq %rax, %rbx
leaq 0x2b8(%rsp), %rdi
jmp 0x5c45
movq %rax, %rbx
leaq 0x208(%rsp), %rdi
callq 0x805c
jmp 0x5cbe
movq %rax, %rbx
leaq 0x418(%rsp), %rdi
callq 0x805c
jmp 0x5cc8
jmp 0x5cb6
movq %rax, %rbx
leaq 0x1b8(%rsp), %rdi
callq 0xb686
jmp 0x5cbe
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0x3548
jmp 0x5cc8
movq %rax, %rbx
leaq 0x4c8(%rsp), %rdi
jmp 0x5c99
movq %rax, %rbx
leaq 0x578(%rsp), %rdi
callq 0x805c
jmp 0x5cda
jmp 0x5ca2
movq %rax, %rbx
jmp 0x5ce7
movq %rax, %rbx
leaq 0x68(%rsp), %rdi
callq 0x3548
jmp 0x5cda
movq %rax, %rbx
jmp 0x5cc8
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0xa6a6
leaq 0x128(%rsp), %rdi
callq 0xb686
jmp 0x5ce7
movq %rax, %rbx
leaq 0x128(%rsp), %rdi
callq 0xa6a6
leaq 0x198(%rsp), %rdi
callq 0x3548
movq %rbx, %rdi
callq 0x34d0