// File: /workspace/github_cpp_makefile_star2_O2/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 0x3310
movq 0x2b0d7(%rip), %rsi     # 0x30508
pushq $0x8
popq %rdx
movq %rbx, %rdi
callq 0x3190
movq 0x48(%rsp), %rax
movq -0x18(%rax), %rax
testb $0x5, 0x68(%rsp,%rax)
jne 0x571e
xorl %ebx, %ebx
leaq 0x48(%rsp), %r14
leaq 0x2b16a(%rip), %r12     # 0x305c8
leaq 0x2b143(%rip), %r13     # 0x305a8
leaq 0x1cc14(%rip), %rbp     # 0x22080
leaq 0x2b1dd(%rip), %r15     # 0x30650
cmpl $0x13, %ebx
je 0x5607
movq 0x48(%rsp), %rax
movq -0x18(%rax), %rax
movl 0x68(%rsp,%rax), %eax
testb $0x5, %al
je 0x54bd
testb $0x5, %al
jne 0x549e
movq %r14, %rdi
callq 0x30e0
cmpl $0x23, %eax
jne 0x54e9
movq 0x48(%rsp), %rax
movq -0x18(%rax), %rax
testb $0x5, 0x68(%rsp,%rax)
jne 0x547c
movq %r14, %rdi
callq 0x3340
cmpl $0xa, %eax
jne 0x549e
jmp 0x547c
movq %r14, %rdi
callq 0x30e0
movl %eax, %edi
callq 0x3060
testl %eax, %eax
je 0x54da
movq %r14, %rdi
callq 0x3340
jmp 0x547c
movq 0x48(%rsp), %rax
movq -0x18(%rax), %rax
movl 0x68(%rsp,%rax), %eax
jmp 0x548d
movq 0x48(%rsp), %rax
movq -0x18(%rax), %rax
testb $0x5, 0x68(%rsp,%rax)
jne 0x55cf
cmpl $0x12, %ebx
ja 0x55cf
movl %ebx, %eax
movslq (%rbp,%rax,4), %rcx
addq %rbp, %rcx
movq %r13, %rax
movq %r12, %rsi
jmpq *%rcx
leaq 0x2b0b1(%rip), %rsi     # 0x305d0
jmp 0x55c7
leaq 0x2b115(%rip), %rsi     # 0x30640
jmp 0x55c7
leaq 0x2b0f9(%rip), %rsi     # 0x30630
jmp 0x55c7
leaq 0x2afa5(%rip), %rax     # 0x304e8
movq %r14, %rdi
movq %rax, %rsi
callq 0x3370
jmp 0x55cf
leaq 0x2b089(%rip), %rsi     # 0x305e0
jmp 0x55c7
leaq 0x2b0c0(%rip), %rsi     # 0x30620
jmp 0x55c7
leaq 0x2b09f(%rip), %rsi     # 0x30608
jmp 0x55c7
leaq 0x2b0c6(%rip), %rsi     # 0x30638
jmp 0x55c7
leaq 0x2b05d(%rip), %rsi     # 0x305d8
jmp 0x55c7
leaq 0x2b074(%rip), %rsi     # 0x305f8
jmp 0x55c7
leaq 0x2b0bb(%rip), %rsi     # 0x30648
jmp 0x55c7
leaq 0x2b052(%rip), %rsi     # 0x305e8
jmp 0x55c7
leaq 0x2b089(%rip), %rsi     # 0x30628
jmp 0x55c7
movq %r14, %rdi
leaq 0x2b045(%rip), %rsi     # 0x305f0
callq 0x3160
jmp 0x55cf
movq %r15, %rsi
jmp 0x55c7
leaq 0x2b052(%rip), %rsi     # 0x30610
jmp 0x55c7
leaq 0x2b039(%rip), %rsi     # 0x30600
movq %r14, %rdi
callq 0x31b0
movq 0x48(%rsp), %rax
movq -0x18(%rax), %rax
testb $0x5, 0x68(%rsp,%rax)
jne 0x56aa
movq 0x48(%rsp), %rax
movq -0x18(%rax), %rax
testb $0x5, 0x68(%rsp,%rax)
jne 0x5600
movq %r14, %rdi
callq 0x3340
cmpl $0xa, %eax
jne 0x55e3
incl %ebx
jmp 0x5473
leaq 0x48(%rsp), %rdi
callq 0x3080
leaq 0x2af90(%rip), %rdi     # 0x305a8
callq 0x815a
leaq 0x2aec4(%rip), %rdi     # 0x304e8
leaq 0x1d219(%rip), %rsi     # 0x22844
callq 0x853a
testb %al, %al
je 0x568e
leaq 0x2aead(%rip), %rdi     # 0x304e8
leaq 0x1cb01(%rip), %rsi     # 0x22143
callq 0x853a
testb %al, %al
je 0x568e
pushq $0x40
popq %rdi
callq 0x32d0
movq %rax, %r14
movq %rax, %rdi
callq 0xa588
leaq 0x2ae83(%rip), %rsi     # 0x304e8
leaq 0x8(%rsp), %rdi
callq 0x33b0
movq (%r14), %rax
leaq 0x8(%rsp), %rsi
movq %r14, %rdi
callq *0x60(%rax)
leaq 0x8(%rsp), %rdi
callq 0x3548
movq %r14, 0x2af8a(%rip)     # 0x30618
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 0x31e0
leaq 0x260(%rsp), %rdi
leaq 0x1d0e9(%rip), %rsi     # 0x227af
callq 0x32c0
leaq 0x2ae36(%rip), %rsi     # 0x30508
movq %rax, %rdi
callq 0x3270
leaq 0x1d0e9(%rip), %rsi     # 0x227ca
movq %rax, %rdi
callq 0x32c0
movq %rax, %rdi
movl %ebx, %esi
callq 0x34b0
leaq 0x1d0d9(%rip), %rsi     # 0x227d3
movq %rax, %rdi
callq 0x32c0
leaq 0x268(%rsp), %rsi
leaq 0x28(%rsp), %rdi
callq 0x3420
movq 0x28(%rsp), %rdi
callq 0x3b3c
leaq 0x1d06c(%rip), %rsi     # 0x22791
leaq 0x2addc(%rip), %rdx     # 0x30508
leaq 0x250(%rsp), %rdi
callq 0x8078
movq 0x250(%rsp), %rdi
callq 0x3b3c
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0x3548
jmp 0x578e
jmp 0x578b
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
jmp 0x577e
movq %rax, %rbx
pushq $0x40
popq %rsi
movq %r14, %rdi
callq 0x32e0
jmp 0x57a8
jmp 0x57a5
movq %rax, %rbx
leaq 0x250(%rsp), %rdi
callq 0x3548
jmp 0x57a8
jmp 0x57a5
jmp 0x57a5
jmp 0x57a5
movq %rax, %rbx
leaq 0x250(%rsp), %rdi
callq 0x3200
jmp 0x57a8
jmp 0x57a5
jmp 0x57a5
jmp 0x57a5
jmp 0x57a5
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0x3090
movq %rbx, %rdi
callq 0x34d0