// File: /workspace/github_cpp_makefile_star2_O2/melop[P]admixem/config.cpp
// Function: SimulationConfigurations::LoadFromFile(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
void SimulationConfigurations::LoadFromFile(string szConfigFile) {


	FILE *pConfigFile;

	printf("%s\n", "Start loading config ...");

	_szConfigFilename = szConfigFile; // save name of config file

	pConfigFile = fopen(szConfigFile.c_str(), "r");

	if (!pConfigFile) {
		printf("%s\n", "Cannot open config file ...");
		throw "Cannot open config file!";
	}

	//Go over each line:
	char szBuffer[1024];


	while(fgets(szBuffer, 1024, pConfigFile) != NULL) 
	{
		char * szKey = new char[1024];
		char * szValue = new char[1024];
		sscanf(szBuffer, "%s = %s %*s", szKey, szValue);
		string sKey(szKey);
		string sVal(szValue);

		this->_mpConfigs[sKey] = sVal;
		printf("%s = %s \n", sKey.c_str(), sVal.c_str());
		//printf("Size of map: %d\n", this->_mpConfigs.size());
	}

	fclose(pConfigFile);

	this->fnParseNumericConfigs();
	//printf("Size of map: %d\n", this->_mpConfigs.size());
	printf("%s = %s \n", "PhenotypeFile", this->GetConfig("PhenotypeFile").c_str());
	printf("%s = %f \n", "pop1_init_size", this->GetNumericConfig("pop1_init_size"));
	//printf("Size of map: %d\n", this->_mpConfigs.size());

	/*
	for (std::map<char *,char *>::iterator it = this->_mpConfigs.begin(); it != this->_mpConfigs.end(); ++it) { // go over the configuration map with string values

		printf("%s%s", it->first, it->second);
	}
	*/
	
	#ifdef _OPENMP

		int nThreads = (int)this->GetNumericConfig("NumThreads");
		if (nThreads <= 0 ) {
			omp_set_num_threads( 2 );
		}
		else {
			omp_set_num_threads( nThreads );
		}
	#endif

	//Load other config files:
	this->pMarkerConfig->LoadFromFile(this->GetConfig("MarkerFile"));
	this->pRecombProbConfig->LoadFromFile(this->GetConfig("MarkerProbFile"));
	this->pPhenotypeConfig->LoadFromFile(this->GetConfig("PhenotypeFile"));
	this->pGeneConfig->LoadFromFile(this->GetConfig("GeneFile"));
	this->pNaturalSelConfig->LoadFromFile(this->GetConfig("NaturalSelection"));
	this->pSexualSelConfig->LoadFromFile(this->GetConfig("SexualSelection"));
	this->pMarkerConfig->CalculateMapDistances();
	this->fnParseSampleGenDef();

	if (this->GetNumericConfig("LogVerbose") == -1) {
		this->_nVerboseLogLevel = 0;//default, not verbose
	}
	else {
		this->_nVerboseLogLevel = this->GetNumericConfig("LogVerbose");
	}

	this->bOutputFirst3Gens = (this->GetConfig("DisableOutputForFirst3Gens")!="yes");

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x688, %rsp            # imm = 0x688
movq %rsi, %rbx
movq %rdi, %r15
leaq 0x18422(%rip), %rdi     # 0x2e53a
callq 0x75c0
leaq 0x38(%r15), %rdi
movq %rbx, %rsi
callq 0x7220
movq (%rbx), %rdi
leaq 0x19b67(%rip), %rsi     # 0x2fc9a
callq 0x74a0
testq %rax, %rax
je 0x16614
movq %rax, %r14
movq %r15, 0x38(%rsp)
leaq 0x58(%r15), %rax
movq %rax, 0x10(%rsp)
leaq 0x280(%rsp), %r12
leaq 0x18(%rsp), %rbp
leaq 0x40(%rsp), %rbx
movq %r12, %rdi
movl $0x400, %esi            # imm = 0x400
movq %r14, %rdx
callq 0x75e0
testq %rax, %rax
je 0x16211
movl $0x400, %edi            # imm = 0x400
callq 0x7030
movq %rax, %r15
movl $0x400, %edi            # imm = 0x400
callq 0x7030
movq %rax, %r13
movq %r12, %rdi
leaq 0x183e7(%rip), %rsi     # 0x2e588
movq %r15, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0x73c0
movq %rbp, %rdi
movq %r15, %rsi
movq %rbx, %rdx
callq 0x9512
movq %rbx, %rdi
movq %r13, %rsi
leaq 0xf(%rsp), %rdx
callq 0x9512
movq 0x10(%rsp), %rdi
movq %rbp, %rsi
callq 0x170e6
movq %rax, %rdi
movq %rbx, %rsi
callq 0x7220
movq 0x18(%rsp), %rsi
movq 0x40(%rsp), %rdx
leaq 0x1839f(%rip), %rdi     # 0x2e594
xorl %eax, %eax
callq 0x7050
movq %rbx, %rdi
callq 0x71a0
movq %rbp, %rdi
callq 0x71a0
jmp 0x16164
movq %r14, %rdi
callq 0x73e0
movq 0x38(%rsp), %r14
movq %r14, %rdi
callq 0x1679e
leaq 0x18371(%rip), %rsi     # 0x2e59e
leaq 0x260(%rsp), %rdi
leaq 0x40(%rsp), %rdx
callq 0x9512
leaq 0x18(%rsp), %rdi
leaq 0x260(%rsp), %rdx
movq %r14, %rsi
callq 0xf118
leaq 0x18(%rsp), %rbx
movq (%rbx), %rdx
leaq 0x18331(%rip), %rdi     # 0x2e594
leaq 0x18334(%rip), %rsi     # 0x2e59e
xorl %eax, %eax
callq 0x7050
movq %rbx, %rdi
callq 0x71a0
leaq 0x260(%rsp), %rdi
callq 0x71a0
leaq 0x18329(%rip), %rsi     # 0x2e5b6
leaq 0x240(%rsp), %rdi
leaq 0x18(%rsp), %rdx
callq 0x9512
leaq 0x240(%rsp), %rsi
movq %r14, %rdi
callq 0x16872
leaq 0x182f6(%rip), %rdi     # 0x2e5ac
leaq 0x182f9(%rip), %rsi     # 0x2e5b6
movb $0x1, %al
callq 0x7050
leaq 0x240(%rsp), %rdi
callq 0x71a0
movq (%r14), %rbx
leaq 0x182ea(%rip), %rsi     # 0x2e5c5
leaq 0x200(%rsp), %rdi
leaq 0x18(%rsp), %rdx
callq 0x9512
leaq 0x220(%rsp), %rdi
leaq 0x200(%rsp), %rdx
movq %r14, %rsi
callq 0xf118
leaq 0x220(%rsp), %rsi
movq %rbx, %rdi
callq 0xebd0
leaq 0x220(%rsp), %rdi
callq 0x71a0
leaq 0x200(%rsp), %rdi
callq 0x71a0
movq 0x8(%r14), %rbx
leaq 0x18296(%rip), %rsi     # 0x2e5d0
leaq 0x1c0(%rsp), %rdi
leaq 0x18(%rsp), %rdx
callq 0x9512
leaq 0x1e0(%rsp), %rdi
leaq 0x1c0(%rsp), %rdx
movq %r14, %rsi
callq 0xf118
leaq 0x1e0(%rsp), %rsi
movq %rbx, %rdi
callq 0xfa1e
leaq 0x1e0(%rsp), %rdi
callq 0x71a0
leaq 0x1c0(%rsp), %rdi
callq 0x71a0
movq 0x10(%r14), %rbx
leaq 0x18205(%rip), %rsi     # 0x2e59e
leaq 0x180(%rsp), %rdi
leaq 0x18(%rsp), %rdx
callq 0x9512
leaq 0x1a0(%rsp), %rdi
leaq 0x180(%rsp), %rdx
movq %r14, %rsi
callq 0xf118
leaq 0x1a0(%rsp), %rsi
movq %rbx, %rdi
callq 0x11d0e
leaq 0x1a0(%rsp), %rdi
callq 0x71a0
leaq 0x180(%rsp), %rdi
callq 0x71a0
movq 0x18(%r14), %rbx
leaq 0x181e7(%rip), %rsi     # 0x2e5df
leaq 0x140(%rsp), %rdi
leaq 0x18(%rsp), %rdx
callq 0x9512
leaq 0x160(%rsp), %rdi
leaq 0x140(%rsp), %rdx
movq %r14, %rsi
callq 0xf118
leaq 0x160(%rsp), %rsi
movq %rbx, %rdi
callq 0x152bc
leaq 0x160(%rsp), %rdi
callq 0x71a0
leaq 0x140(%rsp), %rdi
callq 0x71a0
movq 0x20(%r14), %rbx
leaq 0x18191(%rip), %rsi     # 0x2e5e8
leaq 0x100(%rsp), %rdi
leaq 0x18(%rsp), %rdx
callq 0x9512
leaq 0x120(%rsp), %rdi
leaq 0x100(%rsp), %rdx
movq %r14, %rsi
callq 0xf118
leaq 0x120(%rsp), %rsi
movq %rbx, %rdi
callq 0x1285c
leaq 0x120(%rsp), %rdi
callq 0x71a0
leaq 0x100(%rsp), %rdi
callq 0x71a0
movq 0x28(%r14), %rbx
leaq 0x18143(%rip), %rsi     # 0x2e5f9
leaq 0xc0(%rsp), %rdi
leaq 0x18(%rsp), %rdx
callq 0x9512
leaq 0xe0(%rsp), %rdi
leaq 0xc0(%rsp), %rdx
movq %r14, %rsi
callq 0xf118
leaq 0xe0(%rsp), %rsi
movq %rbx, %rdi
callq 0x13d64
leaq 0xe0(%rsp), %rdi
callq 0x71a0
leaq 0xc0(%rsp), %rdi
callq 0x71a0
movq (%r14), %rdi
callq 0xf17c
movq %r14, %rdi
callq 0x168b8
leaq 0x180e8(%rip), %rsi     # 0x2e609
leaq 0xa0(%rsp), %rdi
leaq 0x18(%rsp), %rdx
callq 0x9512
leaq 0xa0(%rsp), %rsi
movq %r14, %rdi
callq 0x16872
movsd %xmm0, 0x10(%rsp)
leaq 0xa0(%rsp), %rdi
callq 0x71a0
movsd 0x10(%rsp), %xmm0
ucomisd 0x16ec4(%rip), %xmm0    # 0x2d428
jne 0x1656f
jp 0x1656f
andl $0x0, 0x30(%r14)
jmp 0x165ad
leaq 0x18093(%rip), %rsi     # 0x2e609
leaq 0x80(%rsp), %rdi
leaq 0x18(%rsp), %rdx
callq 0x9512
leaq 0x80(%rsp), %rsi
movq %r14, %rdi
callq 0x16872
cvttsd2si %xmm0, %eax
movl %eax, 0x30(%r14)
leaq 0x80(%rsp), %rdi
callq 0x71a0
leaq 0x18060(%rip), %rsi     # 0x2e614
leaq 0x60(%rsp), %rdi
leaq 0x40(%rsp), %rdx
callq 0x9512
leaq 0x18(%rsp), %rdi
leaq 0x60(%rsp), %rdx
movq %r14, %rsi
callq 0xf118
leaq 0x1905a(%rip), %rsi     # 0x2f636
leaq 0x18(%rsp), %rbx
movq %rbx, %rdi
callq 0x17c35
movb %al, 0xd4(%r14)
movq %rbx, %rdi
callq 0x71a0
leaq 0x60(%rsp), %rdi
callq 0x71a0
addq $0x688, %rsp            # imm = 0x688
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x17f38(%rip), %rdi     # 0x2e553
callq 0x75c0
pushq $0x8
popq %rdi
callq 0x71d0
leaq 0x17f40(%rip), %rcx     # 0x2e56f
movq %rcx, (%rax)
movq 0x2e917(%rip), %rsi     # 0x44f50
movq %rax, %rdi
xorl %edx, %edx
callq 0x76a0
movq %rax, %rbx
leaq 0x80(%rsp), %rdi
jmp 0x16791
jmp 0x16775
movq %rax, %rbx
leaq 0x60(%rsp), %rdi
jmp 0x16791
jmp 0x16775
movq %rax, %rbx
leaq 0xa0(%rsp), %rdi
jmp 0x16791
jmp 0x16775
movq %rax, %rbx
leaq 0xe0(%rsp), %rdi
callq 0x71a0
jmp 0x16694
movq %rax, %rbx
leaq 0xc0(%rsp), %rdi
jmp 0x16791
jmp 0x16775
movq %rax, %rbx
leaq 0x120(%rsp), %rdi
callq 0x71a0
jmp 0x166bb
movq %rax, %rbx
leaq 0x100(%rsp), %rdi
jmp 0x16791
jmp 0x16775
movq %rax, %rbx
leaq 0x160(%rsp), %rdi
callq 0x71a0
jmp 0x166e2
movq %rax, %rbx
leaq 0x140(%rsp), %rdi
jmp 0x16791
jmp 0x16775
movq %rax, %rbx
leaq 0x1a0(%rsp), %rdi
callq 0x71a0
jmp 0x16709
movq %rax, %rbx
leaq 0x180(%rsp), %rdi
jmp 0x16791
jmp 0x16775
movq %rax, %rbx
leaq 0x1e0(%rsp), %rdi
callq 0x71a0
jmp 0x1672a
movq %rax, %rbx
leaq 0x1c0(%rsp), %rdi
jmp 0x16791
jmp 0x16775
movq %rax, %rbx
leaq 0x220(%rsp), %rdi
callq 0x71a0
jmp 0x1674b
movq %rax, %rbx
leaq 0x200(%rsp), %rdi
jmp 0x16791
jmp 0x16775
movq %rax, %rbx
leaq 0x240(%rsp), %rdi
jmp 0x16791
jmp 0x16775
movq %rax, %rbx
leaq 0x260(%rsp), %rdi
jmp 0x16791
jmp 0x16775
movq %rax, %rbx
jmp 0x16796
movq %rax, %rbx
jmp 0x1678c
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
callq 0x71a0
leaq 0x18(%rsp), %rdi
callq 0x71a0
movq %rbx, %rdi
callq 0x76d0