// File: 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
movq %rsp, %rbp
subq $0x490, %rsp            # imm = 0x490
leaq -0x208(%rbp), %rdi
movq %rdi, -0x418(%rbp)
callq 0x4420
leaq 0x52263(%rip), %rdi     # 0x5a5d8
callq 0x4160
movq -0x418(%rbp), %rdi
movq %rax, %rsi
movl $0x8, %edx
callq 0x4230
jmp 0x8390
movq -0x208(%rbp), %rax
movq -0x18(%rax), %rax
leaq -0x208(%rbp,%rax), %rdi
callq 0x41b0
movb %al, -0x419(%rbp)
jmp 0x83b0
movb -0x419(%rbp), %al
testb $0x1, %al
jne 0x83bc
jmp 0x8436
leaq 0x414a1(%rip), %rsi     # 0x49864
leaq 0x5220e(%rip), %rdx     # 0x5a5d8
leaq -0x238(%rbp), %rdi
callq 0xe460
jmp 0x83d8
leaq -0x238(%rbp), %rdi
callq 0x4160
movq %rax, %rdi
callq 0x5360
jmp 0x83ee
leaq -0x238(%rbp), %rdi
callq 0x46c8
jmp 0x8436
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x210(%rbp)
movl %eax, -0x214(%rbp)
jmp 0x8ae2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x210(%rbp)
movl %eax, -0x214(%rbp)
leaq -0x238(%rbp), %rdi
callq 0x46c8
jmp 0x8ae2
movl $0x0, -0x23c(%rbp)
cmpl $0x13, -0x23c(%rbp)
jge 0x8991
jmp 0x844f
jmp 0x8451
jmp 0x8453
movq -0x208(%rbp), %rax
movq -0x18(%rax), %rax
leaq -0x208(%rbp,%rax), %rdi
callq 0x44a0
movb %al, -0x41a(%rbp)
jmp 0x8473
movb -0x41a(%rbp), %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, -0x41b(%rbp)
jne 0x8488
jmp 0x84b3
leaq -0x208(%rbp), %rdi
callq 0x4130
movl %eax, -0x420(%rbp)
jmp 0x849c
movl -0x420(%rbp), %edi
callq 0x4080
cmpl $0x0, %eax
setne %al
movb %al, -0x41b(%rbp)
movb -0x41b(%rbp), %al
testb $0x1, %al
jne 0x84bf
jmp 0x84cf
leaq -0x208(%rbp), %rdi
callq 0x4460
jmp 0x84cd
jmp 0x8453
movq -0x208(%rbp), %rax
movq -0x18(%rax), %rax
leaq -0x208(%rbp,%rax), %rdi
callq 0x44a0
movb %al, -0x421(%rbp)
jmp 0x84ef
movb -0x421(%rbp), %al
testb $0x1, %al
jne 0x84fb
jmp 0x851c
leaq -0x208(%rbp), %rdi
callq 0x4130
movl %eax, -0x428(%rbp)
jmp 0x850f
movl -0x428(%rbp), %eax
cmpl $0x23, %eax
je 0x851c
jmp 0x858c
jmp 0x851e
movq -0x208(%rbp), %rax
movq -0x18(%rax), %rax
leaq -0x208(%rbp,%rax), %rdi
callq 0x44a0
movb %al, -0x429(%rbp)
jmp 0x853e
movb -0x429(%rbp), %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, -0x42a(%rbp)
jne 0x8553
jmp 0x8579
leaq -0x208(%rbp), %rdi
callq 0x4460
movl %eax, -0x430(%rbp)
jmp 0x8567
movl -0x430(%rbp), %eax
cmpl $0xa, %eax
setne %al
movb %al, -0x42a(%rbp)
movb -0x42a(%rbp), %al
testb $0x1, %al
jne 0x8585
jmp 0x8587
jmp 0x851e
jmp 0x844f
movq -0x208(%rbp), %rax
movq -0x18(%rax), %rax
leaq -0x208(%rbp,%rax), %rdi
callq 0x44a0
movb %al, -0x431(%rbp)
jmp 0x85ac
movb -0x431(%rbp), %al
testb $0x1, %al
jne 0x85bb
jmp 0x87c7
movl -0x23c(%rbp), %eax
movq %rax, -0x440(%rbp)
subq $0x12, %rax
ja 0x87c5
movq -0x440(%rbp), %rax
leaq 0x40b34(%rip), %rcx     # 0x49114
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x52088(%rip), %rsi     # 0x5a678
leaq -0x208(%rbp), %rdi
callq 0x44b0
jmp 0x85fe
jmp 0x87c5
leaq 0x5208e(%rip), %rsi     # 0x5a698
leaq -0x208(%rbp), %rdi
callq 0x42f0
jmp 0x8618
jmp 0x87c5
leaq 0x5207c(%rip), %rsi     # 0x5a6a0
leaq -0x208(%rbp), %rdi
callq 0x42f0
jmp 0x8632
jmp 0x87c5
leaq 0x5206a(%rip), %rsi     # 0x5a6a8
leaq -0x208(%rbp), %rdi
callq 0x42f0
jmp 0x864c
jmp 0x87c5
leaq 0x52058(%rip), %rsi     # 0x5a6b0
leaq -0x208(%rbp), %rdi
callq 0x42f0
jmp 0x8666
jmp 0x87c5
leaq 0x52046(%rip), %rsi     # 0x5a6b8
leaq -0x208(%rbp), %rdi
callq 0x42f0
jmp 0x8680
jmp 0x87c5
leaq 0x52034(%rip), %rsi     # 0x5a6c0
leaq -0x208(%rbp), %rdi
callq 0x4510
jmp 0x869a
jmp 0x87c5
leaq 0x52022(%rip), %rsi     # 0x5a6c8
leaq -0x208(%rbp), %rdi
callq 0x42f0
jmp 0x86b4
jmp 0x87c5
leaq 0x52010(%rip), %rsi     # 0x5a6d0
leaq -0x208(%rbp), %rdi
callq 0x42f0
jmp 0x86ce
jmp 0x87c5
leaq 0x51ffe(%rip), %rsi     # 0x5a6d8
leaq -0x208(%rbp), %rdi
callq 0x42f0
jmp 0x86e8
jmp 0x87c5
leaq 0x51fec(%rip), %rsi     # 0x5a6e0
leaq -0x208(%rbp), %rdi
callq 0x42f0
jmp 0x8702
jmp 0x87c5
leaq 0x51eaa(%rip), %rsi     # 0x5a5b8
leaq -0x208(%rbp), %rdi
callq 0x44b0
jmp 0x871c
jmp 0x87c5
leaq 0x51fc8(%rip), %rsi     # 0x5a6f0
leaq -0x208(%rbp), %rdi
callq 0x42f0
jmp 0x8736
jmp 0x87c5
leaq 0x51fb6(%rip), %rsi     # 0x5a6f8
leaq -0x208(%rbp), %rdi
callq 0x42f0
jmp 0x8750
jmp 0x87c5
leaq 0x51fa7(%rip), %rsi     # 0x5a700
leaq -0x208(%rbp), %rdi
callq 0x42f0
jmp 0x8767
jmp 0x87c5
leaq 0x51f98(%rip), %rsi     # 0x5a708
leaq -0x208(%rbp), %rdi
callq 0x42f0
jmp 0x877e
jmp 0x87c5
leaq 0x51f89(%rip), %rsi     # 0x5a710
leaq -0x208(%rbp), %rdi
callq 0x42f0
jmp 0x8795
jmp 0x87c5
leaq 0x51f7a(%rip), %rsi     # 0x5a718
leaq -0x208(%rbp), %rdi
callq 0x42f0
jmp 0x87ac
jmp 0x87c5
leaq 0x51f6b(%rip), %rsi     # 0x5a720
leaq -0x208(%rbp), %rdi
callq 0x42f0
jmp 0x87c3
jmp 0x87c5
jmp 0x87c7
movq -0x208(%rbp), %rax
movq -0x18(%rax), %rax
leaq -0x208(%rbp,%rax), %rdi
callq 0x41b0
movb %al, -0x441(%rbp)
jmp 0x87e7
movb -0x441(%rbp), %al
testb $0x1, %al
jne 0x87f6
jmp 0x8910
leaq -0x3c8(%rbp), %rdi
callq 0x4280
jmp 0x8804
leaq -0x3b8(%rbp), %rdi
leaq 0x41070(%rip), %rsi     # 0x49882
callq 0x4390
movq %rax, -0x450(%rbp)
jmp 0x8820
movq -0x450(%rbp), %rdi
leaq 0x51daa(%rip), %rsi     # 0x5a5d8
callq 0x4330
movq %rax, -0x458(%rbp)
jmp 0x883c
movq -0x458(%rbp), %rdi
leaq 0x41053(%rip), %rsi     # 0x4989d
callq 0x4390
movq %rax, -0x460(%rbp)
jmp 0x8858
movq -0x460(%rbp), %rdi
movl -0x23c(%rbp), %esi
callq 0x4600
movq %rax, -0x468(%rbp)
jmp 0x8873
movq -0x468(%rbp), %rdi
leaq 0x41025(%rip), %rsi     # 0x498a6
callq 0x4390
jmp 0x8888
leaq -0x3e8(%rbp), %rdi
leaq -0x3c8(%rbp), %rsi
callq 0x4380
jmp 0x889d
leaq -0x3e8(%rbp), %rdi
callq 0x4160
movq %rax, %rdi
callq 0x5360
jmp 0x88b3
leaq -0x3e8(%rbp), %rdi
callq 0x46c8
leaq -0x3c8(%rbp), %rdi
callq 0x42a0
jmp 0x8910
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x210(%rbp)
movl %eax, -0x214(%rbp)
jmp 0x88ff
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x210(%rbp)
movl %eax, -0x214(%rbp)
leaq -0x3e8(%rbp), %rdi
callq 0x46c8
leaq -0x3c8(%rbp), %rdi
callq 0x42a0
jmp 0x8ae2
jmp 0x8912
movq -0x208(%rbp), %rax
movq -0x18(%rax), %rax
leaq -0x208(%rbp,%rax), %rdi
callq 0x44a0
movb %al, -0x469(%rbp)
jmp 0x8932
movb -0x469(%rbp), %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, -0x46a(%rbp)
jne 0x8947
jmp 0x896d
leaq -0x208(%rbp), %rdi
callq 0x4460
movl %eax, -0x470(%rbp)
jmp 0x895b
movl -0x470(%rbp), %eax
cmpl $0xa, %eax
setne %al
movb %al, -0x46a(%rbp)
movb -0x46a(%rbp), %al
testb $0x1, %al
jne 0x8979
jmp 0x897b
jmp 0x8912
jmp 0x897d
movl -0x23c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x23c(%rbp)
jmp 0x8440
leaq -0x208(%rbp), %rdi
callq 0x40b0
jmp 0x899f
leaq 0x51cd2(%rip), %rdi     # 0x5a678
callq 0xe770
jmp 0x89ad
leaq 0x51c04(%rip), %rdi     # 0x5a5b8
leaq 0x40f5c(%rip), %rsi     # 0x49917
callq 0xec60
movb %al, -0x471(%rbp)
jmp 0x89c8
movb -0x471(%rbp), %al
testb $0x1, %al
jne 0x89d7
jmp 0x8acd
leaq 0x51bda(%rip), %rdi     # 0x5a5b8
leaq 0x407e6(%rip), %rsi     # 0x491cb
callq 0xec60
movb %al, -0x472(%rbp)
jmp 0x89f2
movb -0x472(%rbp), %al
testb $0x1, %al
jne 0x8a01
jmp 0x8acd
movl $0x40, %edi
callq 0x43a0
movq %rax, -0x480(%rbp)
jmp 0x8a14
movq -0x480(%rbp), %rdi
callq 0x155e0
jmp 0x8a22
movq -0x480(%rbp), %rax
movq %rax, -0x3f0(%rbp)
movq -0x3f0(%rbp), %rax
movq %rax, -0x488(%rbp)
leaq 0x51b73(%rip), %rsi     # 0x5a5b8
leaq -0x410(%rbp), %rdi
callq 0x4180
jmp 0x8a53
movq -0x488(%rbp), %rdi
movq (%rdi), %rax
movq 0x60(%rax), %rax
leaq -0x410(%rbp), %rsi
callq *%rax
jmp 0x8a6c
leaq -0x410(%rbp), %rdi
callq 0x46c8
movq -0x3f0(%rbp), %rax
movq %rax, 0x51c62(%rip)     # 0x5a6e8
jmp 0x8acd
movq -0x480(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x210(%rbp)
movl %eax, -0x214(%rbp)
movl $0x40, %esi
callq 0x43b0
jmp 0x8ae2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x210(%rbp)
movl %eax, -0x214(%rbp)
leaq -0x410(%rbp), %rdi
callq 0x46c8
jmp 0x8ae2
leaq -0x208(%rbp), %rdi
callq 0x40d0
addq $0x490, %rsp            # imm = 0x490
popq %rbp
retq
leaq -0x208(%rbp), %rdi
callq 0x40d0
movq -0x210(%rbp), %rdi
callq 0x4620
nopw (%rax,%rax)