// File: /workspace/github_cpp_makefile_star2_O1/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 0x31361(%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 0x64db
xorl %ebx, %ebx
leaq 0x48(%rsp), %r14
leaq 0x313f2(%rip), %r12     # 0x375d8
leaq 0x313cb(%rip), %r13     # 0x375b8
leaq 0x24e8c(%rip), %rbp     # 0x2b080
leaq 0x31465(%rip), %r15     # 0x37660
movq 0x48(%rsp), %rax
movq -0x18(%rax), %rax
testb $0x5, 0x68(%rsp,%rax)
je 0x6247
movq 0x48(%rsp), %rax
movq -0x18(%rax), %rax
testb $0x5, 0x68(%rsp,%rax)
jne 0x6228
movq %r14, %rdi
callq 0x3100
cmpl $0x23, %eax
jne 0x6264
movq 0x48(%rsp), %rax
movq -0x18(%rax), %rax
testb $0x5, 0x68(%rsp,%rax)
jne 0x61fb
movq %r14, %rdi
callq 0x3380
cmpl $0xa, %eax
jne 0x6228
jmp 0x61fb
movq %r14, %rdi
callq 0x3100
movl %eax, %edi
callq 0x3060
testl %eax, %eax
je 0x620b
movq %r14, %rdi
callq 0x3380
jmp 0x61fb
movq 0x48(%rsp), %rax
movq -0x18(%rax), %rax
testb $0x5, 0x68(%rsp,%rax)
jne 0x634a
cmpl $0x12, %ebx
ja 0x634a
movl %ebx, %eax
movslq (%rbp,%rax,4), %rcx
addq %rbp, %rcx
movq %r13, %rax
movq %r12, %rsi
jmpq *%rcx
leaq 0x31346(%rip), %rsi     # 0x375e0
jmp 0x6342
leaq 0x313aa(%rip), %rsi     # 0x37650
jmp 0x6342
leaq 0x3138e(%rip), %rsi     # 0x37640
jmp 0x6342
leaq 0x3123a(%rip), %rax     # 0x374f8
movq %r14, %rdi
movq %rax, %rsi
callq 0x33b0
jmp 0x634a
leaq 0x3131e(%rip), %rsi     # 0x375f0
jmp 0x6342
leaq 0x31355(%rip), %rsi     # 0x37630
jmp 0x6342
leaq 0x31334(%rip), %rsi     # 0x37618
jmp 0x6342
leaq 0x3135b(%rip), %rsi     # 0x37648
jmp 0x6342
leaq 0x312f2(%rip), %rsi     # 0x375e8
jmp 0x6342
leaq 0x31309(%rip), %rsi     # 0x37608
jmp 0x6342
leaq 0x31350(%rip), %rsi     # 0x37658
jmp 0x6342
leaq 0x312e7(%rip), %rsi     # 0x375f8
jmp 0x6342
leaq 0x3131e(%rip), %rsi     # 0x37638
jmp 0x6342
movq %r14, %rdi
leaq 0x312da(%rip), %rsi     # 0x37600
callq 0x3180
jmp 0x634a
movq %r15, %rsi
jmp 0x6342
leaq 0x312e7(%rip), %rsi     # 0x37620
jmp 0x6342
leaq 0x312ce(%rip), %rsi     # 0x37610
movq %r14, %rdi
callq 0x31d0
movq 0x48(%rsp), %rax
movq -0x18(%rax), %rax
testb $0x5, 0x68(%rsp,%rax)
jne 0x644b
movq 0x48(%rsp), %rax
movq -0x18(%rax), %rax
testb $0x5, 0x68(%rsp,%rax)
jne 0x637b
movq %r14, %rdi
callq 0x3380
cmpl $0xa, %eax
jne 0x635e
incl %ebx
cmpl $0x13, %ebx
jne 0x61fb
leaq 0x48(%rsp), %rdi
callq 0x3080
leaq 0x31221(%rip), %rdi     # 0x375b8
callq 0xa0f4
leaq 0x31155(%rip), %rdi     # 0x374f8
leaq 0x254d0(%rip), %rsi     # 0x2b87a
callq 0x30c0
testl %eax, %eax
je 0x642f
leaq 0x3113e(%rip), %rdi     # 0x374f8
leaq 0x24d7e(%rip), %rsi     # 0x2b13f
callq 0x30c0
testl %eax, %eax
je 0x642f
movl $0x40, %edi
callq 0x3300
movq %rax, %r14
movq %rax, %rdi
callq 0xcfd0
leaq 0x18(%rsp), %r15
movq %r15, -0x10(%r15)
movq 0x31109(%rip), %rsi     # 0x374f8
movq 0x3110a(%rip), %rdx     # 0x37500
addq %rsi, %rdx
leaq 0x8(%rsp), %rdi
callq 0xa97e
movq (%r14), %rax
leaq 0x8(%rsp), %rsi
movq %r14, %rdi
callq *0x60(%rax)
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
je 0x6428
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x3310
movq %r14, 0x311f9(%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 0x2537e(%rip), %rsi     # 0x2b7e5
movl $0x1a, %edx
movq %r14, %rdi
callq 0x3360
movq 0x3109d(%rip), %rsi     # 0x37518
movq 0x3109e(%rip), %rdx     # 0x37520
movq %r14, %rdi
callq 0x3360
movq %rax, %r14
leaq 0x2536c(%rip), %rsi     # 0x2b800
movl $0x8, %edx
movq %rax, %rdi
callq 0x3360
movq %r14, %rdi
movl %ebx, %esi
callq 0x34e0
leaq 0x25357(%rip), %rsi     # 0x2b809
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 0x252e5(%rip), %rsi     # 0x2b7c7
leaq 0x3102f(%rip), %rdx     # 0x37518
leaq 0x250(%rsp), %rdi
callq 0x9ffb
movq 0x250(%rsp), %rdi
callq 0x403c
movq %rax, %rbx
leaq 0x38(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x6577
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x3310
jmp 0x6577
jmp 0x6574
movq %rax, %rbx
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
je 0x65a5
movq 0x18(%rsp), %rsi
jmp 0x6562
movq %rax, %rbx
movl $0x40, %esi
movq %r14, %rdi
jmp 0x6565
movq %rax, %rbx
leaq 0x260(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x65a5
movq 0x260(%rsp), %rsi
incq %rsi
callq 0x3310
jmp 0x65a5
jmp 0x65a2
jmp 0x65a2
jmp 0x65a2
jmp 0x65a2
movq %rax, %rbx
movq 0x30a2a(%rip), %rsi     # 0x36fa8
leaq 0x250(%rsp), %rdi
callq 0x3220
leaq 0x2d0(%rsp), %rdi
callq 0x30e0
jmp 0x65a5
jmp 0x65a2
jmp 0x65a2
jmp 0x65a2
jmp 0x65a2
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0x3090
movq %rbx, %rdi
callq 0x3500