// File: /workspace/github_cpp_makefile_star2_O3/kebwi[P]Trifid/src/main.cpp
// Function: readNoiseParamsFile()
void readNoiseParamsFile()
{
	ifstream ifs;
	ifs.open(sNoiseParamsFilename.c_str());
	if (!ifs)
		die(string("Noise params file not found: " + sNoiseParamsFilename).c_str());
	
	for (int paramIdx = 0; paramIdx < 19; paramIdx++)
	{
		while (true)
		{
			while (ifs && isspace(ifs.peek()))	//Skip any whitespace (blank lines, leading spaces, etc).
				ifs.get();
			if (ifs && ifs.peek() != '#')	//Next line isn't a comment, so proceed with reading data from it
				break;
			//Next line is a comment, so skip the entire line
			while (ifs && ifs.get() != '\n');
		}
		
		if (ifs)
		{
			switch (paramIdx)
			{
				case 0:	ifs >> sNoiseParams.label_;	break;	//Note, this label string cannot contain whitespace
				case 1:	ifs >> sNoiseParams.lux_;	break;
				case 2:	ifs >> sNoiseParams.minReflectance_;	break;
				case 3:	ifs >> sNoiseParams.maxReflectance_;	break;
				case 4:	ifs >> sNoiseParams.temperatureC_;	break;
				case 5:	ifs >> sNoiseParams.pixelPitchMicrons_;	break;
				case 6:	ifs >> sNoiseParams.fullWellCapacity_;	break;
				case 7:	ifs >> sNoiseParams.readNoise_;	break;
				case 8:	ifs >> sNoiseParams.ampVarFactor_;	break;
				case 9:	ifs >> sNoiseParams.darkCurrentRoomTempElectronsPerPixPerSec_;	break;
				case 10:	ifs >> sNoiseParams.hotPixelFactor_;	break;
				case 11:	ifs >> sHotpixelMapFilename;	break;	//Note, this filename string cannot contain whitespace
				case 12:	ifs >> sNoiseParams.quantumEfficiency_[R];	break;
				case 13:	ifs >> sNoiseParams.quantumEfficiency_[G];	break;
				case 14:	ifs >> sNoiseParams.quantumEfficiency_[B];	break;
				case 15:	ifs >> sNoiseParams.ampGlowElectronsPerPixPerSec_;	break;
				case 16:	ifs >> sNoiseParams.exposureSecs_;	break;
				case 17:	ifs >> sNoiseParams.ampGain_;	break;
				case 18:	ifs >> sNoiseParams.focalRatio_;	break;
			}
		}
		
		if (!ifs)
		{
			stringstream ss;
			ss << "Invalid noise params file " << sNoiseParamsFilename << " at row " << paramIdx << " (0 indexed)";
			die(ss.str().c_str());
		}
		
		while (ifs && ifs.get() != '\n');	//The rest of the line can be a comment
	}
	
	ifs.close();
	
	sNoiseParams.selfCheck();
	
	//Read the hot pixel map
	if (sHotpixelMapFilename != "" && sHotpixelMapFilename != "NONE")
	{
		ImageReal *hotpixelMapImg = new ImageReal();
		hotpixelMapImg->readFile(sHotpixelMapFilename);
		sNoiseParams.hotPixelScalars_ = hotpixelMapImg;
	}
	
	//cout << "Noise params read:" << endl;
	//sNoiseParams.dump();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x3d8, %rsp            # imm = 0x3D8
leaq 0x48(%rsp), %rbx
movq %rbx, %rdi
callq 0x3350
movq 0x3141a(%rip), %rsi     # 0x37518
movq %rbx, %rdi
movl $0x8, %edx
callq 0x31b0
movq 0x48(%rsp), %rax
movq -0x18(%rax), %rax
testb $0x5, 0x68(%rsp,%rax)
jne 0x6426
xorl %ebx, %ebx
leaq 0x48(%rsp), %r14
leaq 0x314ab(%rip), %r12     # 0x375d8
leaq 0x31484(%rip), %r13     # 0x375b8
leaq 0x23f45(%rip), %rbp     # 0x2a080
leaq 0x3151e(%rip), %r15     # 0x37660
movq 0x48(%rsp), %rax
movq -0x18(%rax), %rax
movl 0x68(%rsp,%rax), %eax
testb $0x5, %al
je 0x6183
testb $0x5, %al
jne 0x6164
movq %r14, %rdi
callq 0x3100
cmpl $0x23, %eax
jne 0x61af
movq 0x48(%rsp), %rax
movq -0x18(%rax), %rax
testb $0x5, 0x68(%rsp,%rax)
jne 0x6142
movq %r14, %rdi
callq 0x3380
cmpl $0xa, %eax
jne 0x6164
jmp 0x6142
movq %r14, %rdi
callq 0x3100
movl %eax, %edi
callq 0x3060
testl %eax, %eax
je 0x61a0
movq %r14, %rdi
callq 0x3380
jmp 0x6142
movq 0x48(%rsp), %rax
movq -0x18(%rax), %rax
movl 0x68(%rsp,%rax), %eax
jmp 0x6153
movq 0x48(%rsp), %rax
movq -0x18(%rax), %rax
testb $0x5, 0x68(%rsp,%rax)
jne 0x6295
cmpl $0x12, %ebx
ja 0x6295
movl %ebx, %eax
movslq (%rbp,%rax,4), %rcx
addq %rbp, %rcx
movq %r13, %rax
movq %r12, %rsi
jmpq *%rcx
leaq 0x313fb(%rip), %rsi     # 0x375e0
jmp 0x628d
leaq 0x3145f(%rip), %rsi     # 0x37650
jmp 0x628d
leaq 0x31443(%rip), %rsi     # 0x37640
jmp 0x628d
leaq 0x312ef(%rip), %rax     # 0x374f8
movq %r14, %rdi
movq %rax, %rsi
callq 0x33b0
jmp 0x6295
leaq 0x313d3(%rip), %rsi     # 0x375f0
jmp 0x628d
leaq 0x3140a(%rip), %rsi     # 0x37630
jmp 0x628d
leaq 0x313e9(%rip), %rsi     # 0x37618
jmp 0x628d
leaq 0x31410(%rip), %rsi     # 0x37648
jmp 0x628d
leaq 0x313a7(%rip), %rsi     # 0x375e8
jmp 0x628d
leaq 0x313be(%rip), %rsi     # 0x37608
jmp 0x628d
leaq 0x31405(%rip), %rsi     # 0x37658
jmp 0x628d
leaq 0x3139c(%rip), %rsi     # 0x375f8
jmp 0x628d
leaq 0x313d3(%rip), %rsi     # 0x37638
jmp 0x628d
movq %r14, %rdi
leaq 0x3138f(%rip), %rsi     # 0x37600
callq 0x3180
jmp 0x6295
movq %r15, %rsi
jmp 0x628d
leaq 0x3139c(%rip), %rsi     # 0x37620
jmp 0x628d
leaq 0x31383(%rip), %rsi     # 0x37610
movq %r14, %rdi
callq 0x31d0
movq 0x48(%rsp), %rax
movq -0x18(%rax), %rax
testb $0x5, 0x68(%rsp,%rax)
jne 0x6396
movq 0x48(%rsp), %rax
movq -0x18(%rax), %rax
testb $0x5, 0x68(%rsp,%rax)
jne 0x62c6
movq %r14, %rdi
callq 0x3380
cmpl $0xa, %eax
jne 0x62a9
incl %ebx
cmpl $0x13, %ebx
jne 0x6142
leaq 0x48(%rsp), %rdi
callq 0x3080
leaq 0x312d6(%rip), %rdi     # 0x375b8
callq 0xa0a6
leaq 0x3120a(%rip), %rdi     # 0x374f8
leaq 0x24563(%rip), %rsi     # 0x2a858
callq 0x30c0
testl %eax, %eax
je 0x637a
leaq 0x311f3(%rip), %rdi     # 0x374f8
leaq 0x23e4b(%rip), %rsi     # 0x2a157
callq 0x30c0
testl %eax, %eax
je 0x637a
movl $0x40, %edi
callq 0x3300
movq %rax, %r14
movq %rax, %rdi
callq 0xcf0c
leaq 0x18(%rsp), %r15
movq %r15, -0x10(%r15)
movq 0x311be(%rip), %rsi     # 0x374f8
movq 0x311bf(%rip), %rdx     # 0x37500
addq %rsi, %rdx
leaq 0x8(%rsp), %rdi
callq 0xa92c
movq (%r14), %rax
leaq 0x8(%rsp), %rsi
movq %r14, %rdi
callq *0x60(%rax)
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
je 0x6373
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x3310
movq %r14, 0x312ae(%rip)     # 0x37628
leaq 0x48(%rsp), %rdi
callq 0x3090
addq $0x3d8, %rsp            # imm = 0x3D8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x250(%rsp), %rdi
callq 0x3200
leaq 0x260(%rsp), %r14
leaq 0x24411(%rip), %rsi     # 0x2a7c3
movl $0x1a, %edx
movq %r14, %rdi
callq 0x3360
movq 0x31152(%rip), %rsi     # 0x37518
movq 0x31153(%rip), %rdx     # 0x37520
movq %r14, %rdi
callq 0x3360
movq %rax, %r14
leaq 0x243ff(%rip), %rsi     # 0x2a7de
movl $0x8, %edx
movq %rax, %rdi
callq 0x3360
movq %r14, %rdi
movl %ebx, %esi
callq 0x34e0
leaq 0x243ea(%rip), %rsi     # 0x2a7e7
movl $0xc, %edx
movq %rax, %rdi
callq 0x3360
leaq 0x268(%rsp), %rsi
leaq 0x28(%rsp), %rdi
callq 0x3450
movq 0x28(%rsp), %rdi
callq 0x403c
leaq 0x24378(%rip), %rsi     # 0x2a7a5
leaq 0x310e4(%rip), %rdx     # 0x37518
leaq 0x250(%rsp), %rdi
callq 0x9fad
movq 0x250(%rsp), %rdi
callq 0x403c
movq %rax, %rbx
leaq 0x38(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x64c2
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x3310
jmp 0x64c2
jmp 0x64bf
movq %rax, %rbx
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
je 0x64f0
movq 0x18(%rsp), %rsi
jmp 0x64ad
movq %rax, %rbx
movl $0x40, %esi
movq %r14, %rdi
jmp 0x64b0
movq %rax, %rbx
leaq 0x260(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x64f0
movq 0x260(%rsp), %rsi
incq %rsi
callq 0x3310
jmp 0x64f0
jmp 0x64ed
jmp 0x64ed
jmp 0x64ed
jmp 0x64ed
movq %rax, %rbx
movq 0x30adf(%rip), %rsi     # 0x36fa8
leaq 0x250(%rsp), %rdi
callq 0x3220
leaq 0x2d0(%rsp), %rdi
callq 0x30e0
jmp 0x64f0
jmp 0x64ed
jmp 0x64ed
jmp 0x64ed
jmp 0x64ed
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0x3090
movq %rbx, %rdi
callq 0x3500