// File: /workspace/github_cpp_makefile_star2_O2/melop[P]admixem/config.cpp
// Function: RecombProbConfigurations::LoadFromFile(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
void RecombProbConfigurations::LoadFromFile(string szConfigFile) {
	#ifdef _OPENMP
		int nTotalCPUCore =  omp_get_max_threads();//omp_get_num_threads();
		//printf("OpenMP enabled\n");
	#else
		int nTotalCPUCore = 1;
		//printf("OpenMP disabled \n");
	#endif

	FILE *pConfigFile;
	char szBuffer[12048];

	this->_nHaploidChrNum = ((SimulationConfigurations *)this->_pParentConfig)->pMarkerConfig->GetHaploidChromosomeNum(); // save a copy of the haploid chromosome number
	//Initialize arrays:
	this->_nExpectedMaleRecPerMeiosisArm1 = new double[_nHaploidChrNum];
	this->_nExpectedMaleRecPerMeiosisArm2 = new double[_nHaploidChrNum];
	this->_nExpectedFemaleRecPerMeiosisArm1 = new double[_nHaploidChrNum];
	this->_nExpectedFemaleRecPerMeiosisArm2 = new double[_nHaploidChrNum];

	this->pvBreakpointSamplePositions = new vector<double>[_nHaploidChrNum];
	this->pvMaleAccuProb = new vector<double>[_nHaploidChrNum];
	this->pvFemaleAccuProb = new vector<double>[_nHaploidChrNum];
	this->pvMaleMapDistance = new vector<double>[_nHaploidChrNum];
	this->pvFemaleMapDistance = new vector<double>[_nHaploidChrNum];
	this->pvAvgMapDistance = new vector<double>[_nHaploidChrNum];
	this->pvMaleRecArm1Gen = new vector< Poisson * >[nTotalCPUCore];
	this->pvMaleRecArm2Gen = new vector< Poisson * >[nTotalCPUCore];
	this->pvFemaleRecArm1Gen = new vector< Poisson * >[nTotalCPUCore];
	this->pvFemaleRecArm2Gen = new vector< Poisson * >[nTotalCPUCore];
	
	
	printf("Start loading marker probability file %s ...\n", szConfigFile.c_str());

	if (((SimulationConfigurations *)this->_pParentConfig)->GetConfig("UseUniformRec") == "yes") {
		printf("Instructed by configuration to use uniform distribution, will ignore candidate breakpoints in recombination file. But expected number of recombinations will still be used.\n");
		this->_bUseUniform = true;
		
	}
	else {
		this->_bUseUniform = false;
	}

	_szConfigFilename = szConfigFile; // save name of config file

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

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



	int nCurrChr;
	char szCmd[100];
	double nVal, nPos, nMaleAccu, nFemaleAccu, nMaleMapDistance, nFemaleMapDistance, nAvgMapDistance;

	long nLastBpArm1=0; // the index of the last break point at arm 1
	long nBpIndex = -1;
	double nPrevProb = 0.0; // previous probability. 

	while(fgets(szBuffer, 12048, pConfigFile) != NULL) 
	{

		//sscanf(szBuffer, "%d %*f %f %f %f", &nNum, &nAbsPos, &nFreqPop1, &nFreqPop2);


		if (szBuffer[0] == ':') { // it's metadata line

			if (szBuffer[1] == 'c') { // it's the chr line
				//parse chromosome number:

				sscanf(szBuffer, ":chr %d", &nCurrChr);

				if (nCurrChr > this->_nHaploidChrNum || nCurrChr <=0 ) {
					throw "Chromosome number in marker probability file incorrect!";
				}

				if (nBpIndex > 0) {
					vLastBpOnArm1.push_back(nLastBpArm1==0? nBpIndex : nLastBpArm1); // this is the previous record.
				}
				nLastBpArm1=0;
				nBpIndex = -1;
				nPrevProb = 0.0; // previous probability. 
				nCurrChr--;
				continue; // go to the next line
			}
			else { // it's a command line

				sscanf(szBuffer, "%s = %lf", szCmd, &nVal);
				
				//printf("%s\n",szCmd);

				if (strcmp(szCmd, ":ExpectedMaleRecPerMeiosisArm1")==0) {
					this->_nExpectedMaleRecPerMeiosisArm1[nCurrChr] = nVal;
					for(int nCPU=0;nCPU<nTotalCPUCore;nCPU++) {
						Poisson * pPosGen = new Poisson(nVal);
						this->pvMaleRecArm1Gen[nCPU].push_back(pPosGen);
					}
				}
				if (strcmp(szCmd,":ExpectedMaleRecPerMeiosisArm2")==0) {
					this->_nExpectedMaleRecPerMeiosisArm2[nCurrChr] = nVal;
					for(int nCPU=0;nCPU<nTotalCPUCore;nCPU++) {
						Poisson * pPosGen = new Poisson(nVal);
						this->pvMaleRecArm2Gen[nCPU].push_back(pPosGen);
					}
				}

				if (strcmp(szCmd,":ExpectedFemaleRecPerMeiosisArm1")==0) {
					this->_nExpectedFemaleRecPerMeiosisArm1[nCurrChr] = nVal;
					for(int nCPU=0;nCPU<nTotalCPUCore;nCPU++) {
						Poisson * pPosGen = new Poisson(nVal);
						this->pvFemaleRecArm1Gen[nCPU].push_back(pPosGen);
					}
				}
				if (strcmp(szCmd,":ExpectedFemaleRecPerMeiosisArm2")==0) {
					this->_nExpectedFemaleRecPerMeiosisArm2[nCurrChr] = nVal;
					for(int nCPU=0;nCPU<nTotalCPUCore;nCPU++) {
						Poisson * pPosGen = new Poisson(nVal);
						this->pvFemaleRecArm2Gen[nCPU].push_back(pPosGen);
					}
				}

			}

			continue;

		}

		if (szBuffer[0] == '\t') {
			
			continue; //title line, skip
		}
		else { //parse real data

			if (sscanf(szBuffer, "%lf %*lf %lf %*lf %lf %*lf %*lf %*lf %lf %*lf %lf %*lf %lf %*lf", &nPos, &nMaleAccu, &nFemaleAccu, &nMaleMapDistance, &nFemaleMapDistance, &nAvgMapDistance)!=6) {
				continue; // couldn't parse line.	
			};

			nBpIndex++;
			if (nMaleAccu < nPrevProb ) { //switch in prob. crossing the centromere?
				if (nLastBpArm1 != 0) { // this was already set, the sequence is not monotonic.
					throw("Error: accumulative recombination rate must be monotonic within each arm.\n");
				}

				nLastBpArm1 = nBpIndex - 1;//the previous bp is the last one in arm 1.
				
			}
			this->pvBreakpointSamplePositions[nCurrChr].push_back(nPos);
			this->pvMaleAccuProb[nCurrChr].push_back(nMaleAccu);
			this->pvFemaleAccuProb[nCurrChr].push_back(nFemaleAccu);
			this->pvMaleMapDistance[nCurrChr].push_back(nMaleMapDistance);
			this->pvFemaleMapDistance[nCurrChr].push_back(nFemaleMapDistance);
			this->pvAvgMapDistance[nCurrChr].push_back(nAvgMapDistance);

			nPrevProb = nMaleAccu;
		}


	}

	//check that recombination break points on arms are complete:
	if ( pvMaleRecArm1Gen[0].size() != pvMaleRecArm2Gen[0].size() || pvMaleRecArm2Gen[0].size() != pvFemaleRecArm1Gen[0].size() || pvFemaleRecArm1Gen[0].size() != pvFemaleRecArm2Gen[0].size()) {
		throw(new Exception("The number of Recombination break point defined are not equal.\n"));
	}

	vLastBpOnArm1.push_back(nLastBpArm1==0? nBpIndex : nLastBpArm1); // this is the last chromosome.


	//calculate splines
	for(int nCurrChr=0;nCurrChr < this->_nHaploidChrNum; nCurrChr++) {
		double nChrLen = ((SimulationConfigurations*)this->_pParentConfig)->pMarkerConfig->GetChromosomeLength(nCurrChr);
		tk::spline oMaleSplineArm1, oFemaleSplineArm1,oMaleSplineArm2, oFemaleSplineArm2;
		oMaleSplineArm1.set_boundary(spline::first_deriv, 0.0, spline::first_deriv, this->pvBreakpointSamplePositions[nCurrChr].at(this->vLastBpOnArm1[nCurrChr]), false);
		oFemaleSplineArm1.set_boundary(spline::first_deriv, 0.0, spline::first_deriv, this->pvBreakpointSamplePositions[nCurrChr].at(this->vLastBpOnArm1[nCurrChr]), false);
		oMaleSplineArm2.set_boundary(spline::first_deriv, this->pvBreakpointSamplePositions[nCurrChr].at(this->vLastBpOnArm1[nCurrChr]), spline::first_deriv, nChrLen, false);
		oFemaleSplineArm2.set_boundary(spline::first_deriv, this->pvBreakpointSamplePositions[nCurrChr].at(this->vLastBpOnArm1[nCurrChr]), spline::first_deriv, nChrLen, false);
		size_t nTotalBps = this->pvBreakpointSamplePositions[nCurrChr].size();
		vector<double> vPosArm1, vPosArm2, vAccMaleArm1, vAccMaleArm2, vAccFemaleArm1, vAccFemaleArm2;
		copy(this->pvBreakpointSamplePositions[nCurrChr].begin(), this->pvBreakpointSamplePositions[nCurrChr].begin() + this->vLastBpOnArm1[nCurrChr] + 1 ,back_inserter(vPosArm1));
		copy(this->pvBreakpointSamplePositions[nCurrChr].begin() + this->vLastBpOnArm1[nCurrChr] + 1, this->pvBreakpointSamplePositions[nCurrChr].end() ,back_inserter(vPosArm2));
		copy(this->pvMaleAccuProb[nCurrChr].begin(), this->pvMaleAccuProb[nCurrChr].begin() + this->vLastBpOnArm1[nCurrChr] + 1 ,back_inserter(vAccMaleArm1));
		copy(this->pvMaleAccuProb[nCurrChr].begin() + this->vLastBpOnArm1[nCurrChr] + 1, this->pvMaleAccuProb[nCurrChr].end() ,back_inserter(vAccMaleArm2));
		copy(this->pvFemaleAccuProb[nCurrChr].begin(), this->pvFemaleAccuProb[nCurrChr].begin() + this->vLastBpOnArm1[nCurrChr] + 1 ,back_inserter(vAccFemaleArm1));
		copy(this->pvFemaleAccuProb[nCurrChr].begin() + this->vLastBpOnArm1[nCurrChr] + 1, this->pvFemaleAccuProb[nCurrChr].end() ,back_inserter(vAccFemaleArm2));

		// erase elements in case not monotonic:

		if (vPosArm1.size() > 2) { // must have more than 2 pairs of dots to predict a spline.
			this->fnEraseNonMonotonic(&vAccMaleArm1 , &vAccFemaleArm1, &vPosArm1);
			oMaleSplineArm1.set_points(vAccMaleArm1 , vPosArm1);
			oFemaleSplineArm1.set_points(vAccFemaleArm1 , vPosArm1);
		}

		if (vPosArm2.size() > 2) {
			this->fnEraseNonMonotonic(&vAccMaleArm2 , &vAccFemaleArm2, &vPosArm2);

			oMaleSplineArm2.set_points(vAccMaleArm2 , vPosArm2);
			oFemaleSplineArm2.set_points(vAccFemaleArm2 , vPosArm2);
		}


		this->vMaleAccuProbSplineArm1.push_back(oMaleSplineArm1);
		this->vMaleAccuProbSplineArm2.push_back(oMaleSplineArm2);
		this->vFemaleAccuProbSplineArm1.push_back(oFemaleSplineArm1);
		this->vFemaleAccuProbSplineArm2.push_back(oFemaleSplineArm2);
	}

	///printf("%f %f %f", this->pvBreakpointSamplePositions[0].at(0), this->pvMaleAccuProb[0].at(0), this->pvFemaleAccuProb[0].at(0));

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x33b8, %rsp           # imm = 0x33B8
movq %rdi, %rbx
movq (%rdi), %rax
movq (%rax), %rax
movl 0x8(%rax), %r14d
movslq %r14d, %r12
pushq $0x18
popq %rcx
movq %r12, %rax
mulq %rcx
movq %rax, %r15
movq %rsi, 0x8(%rsp)
seto %al
movq %r15, %r13
addq $0x8, %r13
pushq $-0x1
popq %rcx
cmovbq %rcx, %r13
movl %r14d, 0x8(%rdi)
testb %al, %al
cmovneq %rcx, %r13
leaq (,%r12,8), %rbp
testl %r12d, %r12d
cmovsq %rcx, %rbp
movq %rbp, %rdi
callq 0x7030
movq %rax, 0x30(%rbx)
movq %rbp, %rdi
callq 0x7030
movq %rax, 0x38(%rbx)
movq %rbp, %rdi
callq 0x7030
movq %rax, 0x40(%rbx)
movq %rbp, %rdi
callq 0x7030
movq %rax, 0x48(%rbx)
movq %r13, %rdi
callq 0x7030
leaq 0x8(%rax), %rbp
movq %r12, (%rax)
testl %r12d, %r12d
je 0xfae1
leaq -0x18(%r15), %rcx
movq %rcx, %rax
xorl %edx, %edx
pushq $0x18
popq %rsi
divq %rsi
subq %rdx, %rcx
addq $0x18, %rcx
movq %rbp, %rdi
xorl %esi, %esi
movq %rcx, %rdx
callq 0x7230
movq %rbp, 0x78(%rbx)
movq %r13, %rdi
callq 0x7030
leaq 0x8(%rax), %rbp
movq %r12, (%rax)
testl %r14d, %r14d
je 0xfb1c
leaq -0x18(%r15), %rcx
movq %rcx, %rax
xorl %edx, %edx
pushq $0x18
popq %rsi
divq %rsi
subq %rdx, %rcx
addq $0x18, %rcx
movq %rbp, %rdi
xorl %esi, %esi
movq %rcx, %rdx
callq 0x7230
movq %rbp, 0x80(%rbx)
movq %r13, %rdi
callq 0x7030
leaq 0x8(%rax), %rbp
movq %r12, (%rax)
testl %r14d, %r14d
je 0xfb5a
leaq -0x18(%r15), %rcx
movq %rcx, %rax
xorl %edx, %edx
pushq $0x18
popq %rsi
divq %rsi
subq %rdx, %rcx
addq $0x18, %rcx
movq %rbp, %rdi
xorl %esi, %esi
movq %rcx, %rdx
callq 0x7230
movq %rbp, 0x88(%rbx)
movq %r13, %rdi
callq 0x7030
leaq 0x8(%rax), %rbp
movq %r12, (%rax)
testl %r14d, %r14d
je 0xfb98
leaq -0x18(%r15), %rcx
movq %rcx, %rax
xorl %edx, %edx
pushq $0x18
popq %rsi
divq %rsi
subq %rdx, %rcx
addq $0x18, %rcx
movq %rbp, %rdi
xorl %esi, %esi
movq %rcx, %rdx
callq 0x7230
movq %rbp, 0x108(%rbx)
movq %r13, %rdi
callq 0x7030
leaq 0x8(%rax), %rbp
movq %r12, (%rax)
testl %r14d, %r14d
je 0xfbd6
leaq -0x18(%r15), %rcx
movq %rcx, %rax
xorl %edx, %edx
pushq $0x18
popq %rsi
divq %rsi
subq %rdx, %rcx
addq $0x18, %rcx
movq %rbp, %rdi
xorl %esi, %esi
movq %rcx, %rdx
callq 0x7230
movq %rbp, 0x110(%rbx)
movq %r13, %rdi
callq 0x7030
leaq 0x8(%rax), %r13
movq %r12, (%rax)
testl %r14d, %r14d
je 0xfc14
addq $-0x18, %r15
movq %r15, %rax
xorl %edx, %edx
pushq $0x18
popq %rcx
divq %rcx
subq %rdx, %r15
addq $0x18, %r15
movq %r13, %rdi
xorl %esi, %esi
movq %r15, %rdx
callq 0x7230
movq %r13, 0x118(%rbx)
pushq $0x20
popq %r15
movq %r15, %rdi
callq 0x7030
pushq $0x1
popq %r14
movq %r14, (%rax)
leaq 0x8(%rax), %rcx
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%rax)
andq $0x0, 0x18(%rax)
movq %rcx, 0x50(%rbx)
movq %r15, %rdi
callq 0x7030
movq %r14, (%rax)
leaq 0x8(%rax), %rcx
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%rax)
andq $0x0, 0x18(%rax)
movq %rcx, 0x58(%rbx)
movq %r15, %rdi
callq 0x7030
movq %r14, (%rax)
leaq 0x8(%rax), %rcx
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%rax)
andq $0x0, 0x18(%rax)
movq %rcx, 0x60(%rbx)
movq %r15, %rdi
callq 0x7030
movq %r14, (%rax)
andq $0x0, 0x18(%rax)
leaq 0x8(%rax), %rcx
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%rax)
movq %rcx, 0x68(%rbx)
movq 0x8(%rsp), %r14
movq (%r14), %rsi
leaq 0x1df5a(%rip), %rdi     # 0x2dc08
xorl %eax, %eax
callq 0x7050
movq (%rbx), %r15
leaq 0x1df77(%rip), %rsi     # 0x2dc36
leaq 0x2b0(%rsp), %rdi
leaq 0x200(%rsp), %rdx
callq 0x9512
leaq 0x150(%rsp), %rdi
leaq 0x2b0(%rsp), %rdx
movq %r15, %rsi
callq 0xf118
leaq 0x1f943(%rip), %rsi     # 0x2f636
leaq 0x150(%rsp), %r15
movq %r15, %rdi
callq 0x954d
movl %eax, %ebp
movq %r15, %rdi
callq 0x71a0
leaq 0x2b0(%rsp), %rdi
callq 0x71a0
testb %bpl, %bpl
je 0xfd2f
leaq 0x1ef15(%rip), %rdi     # 0x2ec3b
callq 0x75c0
movb $0x1, %al
jmp 0xfd31
xorl %eax, %eax
movb %al, 0x70(%rbx)
leaq 0x10(%rbx), %rdi
movq %r14, %rsi
callq 0x7220
movq (%r14), %rdi
leaq 0x1ff50(%rip), %rsi     # 0x2fc9a
callq 0x74a0
testq %rax, %rax
je 0x10871
movq %rax, %r12
leaq 0x10(%rsp), %rax
andq $0x0, (%rax)
leaq 0x18(%rsp), %rax
orq $-0x1, (%rax)
leaq 0xf0(%rbx), %rax
movq %rax, 0x28(%rsp)
xorps %xmm0, %xmm0
movsd %xmm0, 0x20(%rsp)
leaq 0x4a0(%rsp), %r13
leaq 0x430(%rsp), %r15
pushq $0x1f
popq %r14
pushq $0x21
popq %rbp
movq %r13, %rdi
movl $0x2f10, %esi           # imm = 0x2F10
movq %r12, %rdx
callq 0x75e0
testq %rax, %rax
je 0x10138
movzbl 0x4a0(%rsp), %eax
cmpl $0x9, %eax
je 0xfd99
cmpl $0x3a, %eax
jne 0xff90
cmpb $0x63, 0x4a1(%rsp)
je 0x100c3
movq %r13, %rdi
leaq 0x1dea4(%rip), %rsi     # 0x2dc84
movq %r15, %rdx
leaq 0x30(%rsp), %rcx
xorl %eax, %eax
callq 0x73c0
movq %r15, %rdi
leaq 0x1de94(%rip), %rsi     # 0x2dc8d
movq %r14, %rdx
callq 0x7420
testl %eax, %eax
jne 0xfe55
movsd 0x30(%rsp), %xmm0
movsd %xmm0, 0x8(%rsp)
movq 0x30(%rbx), %rax
movslq 0x4(%rsp), %rcx
movsd %xmm0, (%rax,%rcx,8)
pushq $0x10
popq %rdi
callq 0x73f0
movq %rax, %r14
movq %rax, %rdi
movsd 0x8(%rsp), %xmm0
callq 0xc584
movq %r14, 0x150(%rsp)
movq 0x50(%rbx), %rdi
leaq 0x150(%rsp), %rsi
callq 0x17084
pushq $0x1f
popq %r14
movq %r15, %rdi
leaq 0x1de4d(%rip), %rsi     # 0x2dcac
movq %r14, %rdx
callq 0x7420
testl %eax, %eax
jne 0xfebb
movsd 0x30(%rsp), %xmm0
movsd %xmm0, 0x8(%rsp)
movq 0x38(%rbx), %rax
movslq 0x4(%rsp), %rcx
movsd %xmm0, (%rax,%rcx,8)
pushq $0x10
popq %rdi
callq 0x73f0
movq %rax, %r14
movq %rax, %rdi
movsd 0x8(%rsp), %xmm0
callq 0xc584
movq %r14, 0x150(%rsp)
movq 0x58(%rbx), %rdi
leaq 0x150(%rsp), %rsi
callq 0x17084
pushq $0x1f
popq %r14
movq %r15, %rdi
leaq 0x1de06(%rip), %rsi     # 0x2dccb
movq %rbp, %rdx
callq 0x7420
testl %eax, %eax
jne 0xff21
movsd 0x30(%rsp), %xmm0
movsd %xmm0, 0x8(%rsp)
movq 0x40(%rbx), %rax
movslq 0x4(%rsp), %rcx
movsd %xmm0, (%rax,%rcx,8)
pushq $0x10
popq %rdi
callq 0x73f0
movq %rax, %r14
movq %rax, %rdi
movsd 0x8(%rsp), %xmm0
callq 0xc584
movq %r14, 0x150(%rsp)
movq 0x60(%rbx), %rdi
leaq 0x150(%rsp), %rsi
callq 0x17084
pushq $0x1f
popq %r14
movq %r15, %rdi
leaq 0x1ddc1(%rip), %rsi     # 0x2dcec
movq %rbp, %rdx
callq 0x7420
testl %eax, %eax
jne 0xfd99
movsd 0x30(%rsp), %xmm0
movsd %xmm0, 0x8(%rsp)
movq 0x48(%rbx), %rax
movslq 0x4(%rsp), %rcx
movsd %xmm0, (%rax,%rcx,8)
pushq $0x10
popq %rdi
callq 0x73f0
movq %rax, %r14
movq %rax, %rdi
movsd 0x8(%rsp), %xmm0
callq 0xc584
movq %r14, 0x150(%rsp)
movq 0x68(%rbx), %rdi
leaq 0x150(%rsp), %rsi
callq 0x17084
pushq $0x1f
popq %r14
jmp 0xfd99
movq %r13, %rdi
leaq 0x1dd73(%rip), %rsi     # 0x2dd0d
leaq 0x148(%rsp), %rdx
leaq 0x38(%rsp), %rcx
leaq 0x140(%rsp), %r8
leaq 0x138(%rsp), %r9
xorl %eax, %eax
leaq 0x128(%rsp), %r10
pushq %r10
leaq 0x138(%rsp), %r10
pushq %r10
callq 0x73c0
popq %rcx
popq %rdx
cmpl $0x6, %eax
jne 0xfd99
movq 0x18(%rsp), %rax
leaq 0x1(%rax), %rcx
movq %rcx, 0x18(%rsp)
movsd 0x20(%rsp), %xmm0
ucomisd 0x38(%rsp), %xmm0
jbe 0x1000a
cmpq $0x0, 0x10(%rsp)
jne 0x1089f
movq %rax, 0x10(%rsp)
movslq 0x4(%rsp), %rax
imulq $0x18, %rax, %rdi
addq 0x78(%rbx), %rdi
leaq 0x148(%rsp), %rsi
callq 0x170a2
movslq 0x4(%rsp), %rax
imulq $0x18, %rax, %rdi
addq 0x80(%rbx), %rdi
leaq 0x38(%rsp), %rsi
callq 0x170a2
movslq 0x4(%rsp), %rax
imulq $0x18, %rax, %rdi
addq 0x88(%rbx), %rdi
leaq 0x140(%rsp), %rsi
callq 0x170a2
movslq 0x4(%rsp), %rax
imulq $0x18, %rax, %rdi
addq 0x108(%rbx), %rdi
leaq 0x138(%rsp), %rsi
callq 0x170a2
movslq 0x4(%rsp), %rax
imulq $0x18, %rax, %rdi
addq 0x110(%rbx), %rdi
leaq 0x130(%rsp), %rsi
callq 0x170a2
movslq 0x4(%rsp), %rax
imulq $0x18, %rax, %rdi
addq 0x118(%rbx), %rdi
leaq 0x128(%rsp), %rsi
callq 0x170a2
movsd 0x38(%rsp), %xmm0
movsd %xmm0, 0x20(%rsp)
jmp 0xfd99
movq %r13, %rdi
leaq 0x1db77(%rip), %rsi     # 0x2dc44
leaq 0x4(%rsp), %rdx
xorl %eax, %eax
callq 0x73c0
movl 0x4(%rsp), %eax
testl %eax, %eax
jle 0x1088e
cmpl 0x8(%rbx), %eax
jg 0x1088e
cmpq $0x0, 0x18(%rsp)
jle 0x10118
cmpq $0x0, 0x10(%rsp)
leaq 0x10(%rsp), %rsi
leaq 0x18(%rsp), %rax
cmoveq %rax, %rsi
movq 0x28(%rsp), %rdi
callq 0x17064
movl 0x4(%rsp), %eax
andq $0x0, 0x10(%rsp)
orq $-0x1, 0x18(%rsp)
decl %eax
movl %eax, 0x4(%rsp)
xorps %xmm0, %xmm0
movsd %xmm0, 0x20(%rsp)
jmp 0xfd99
movq 0x50(%rbx), %rcx
movq 0x58(%rbx), %rdx
movq 0x8(%rcx), %rax
subq (%rcx), %rax
movq 0x8(%rdx), %rcx
subq (%rdx), %rcx
cmpq %rcx, %rax
jne 0x1083d
movq 0x60(%rbx), %rcx
movq 0x8(%rcx), %rdx
subq (%rcx), %rdx
cmpq %rdx, %rax
jne 0x1083d
movq 0x68(%rbx), %rcx
movq 0x8(%rcx), %rdx
subq (%rcx), %rdx
cmpq %rdx, %rax
jne 0x1083d
cmpq $0x0, 0x10(%rsp)
leaq 0x10(%rsp), %rsi
leaq 0x18(%rsp), %rax
cmoveq %rax, %rsi
movq 0x28(%rsp), %rdi
callq 0x17064
movl $0x90, %ecx
leaq 0x150(%rsp), %rax
addq %rcx, %rax
movq %rax, 0x28(%rsp)
leaq 0x200(%rsp), %rax
addq %rcx, %rax
movq %rax, 0x20(%rsp)
leaq 0x380(%rsp), %rax
addq %rcx, %rax
movq %rax, 0x120(%rsp)
leaq 0x2d0(%rsp), %rax
addq %rcx, %rax
movq %rax, 0x118(%rsp)
addq %rbx, %rcx
movq %rcx, 0x110(%rsp)
leaq 0xc0(%rbx), %rax
movq %rax, 0x108(%rsp)
leaq 0xa8(%rbx), %rax
movq %rax, 0x100(%rsp)
leaq 0xd8(%rbx), %rax
movq %rax, 0xf8(%rsp)
xorl %r14d, %r14d
movabsq $0x200000002, %r13      # imm = 0x200000002
movabsq $0x100000001, %rbp      # imm = 0x100000001
xorl %r12d, %r12d
xorl %r15d, %r15d
movslq 0x8(%rbx), %rax
cmpq %rax, %r15
jge 0x10806
movq (%rbx), %rax
movq (%rax), %rax
movq 0x30(%rax), %rax
movsd (%rax,%r15,8), %xmm0
movsd %xmm0, 0x8(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x1b0(%rsp)
movaps %xmm0, 0x1a0(%rsp)
movaps %xmm0, 0x190(%rsp)
movaps %xmm0, 0x180(%rsp)
movaps %xmm0, 0x170(%rsp)
andq $0x0, 0x1c0(%rsp)
movaps %xmm0, 0x160(%rsp)
movaps %xmm0, 0x150(%rsp)
movq %r13, 0x1d8(%rsp)
movq 0x28(%rsp), %rax
movb %r14b, 0x10(%rax)
movups %xmm0, (%rax)
movaps %xmm0, 0x260(%rsp)
movaps %xmm0, 0x250(%rsp)
movaps %xmm0, 0x240(%rsp)
movaps %xmm0, 0x230(%rsp)
movaps %xmm0, 0x220(%rsp)
movaps %xmm0, 0x210(%rsp)
movaps %xmm0, 0x200(%rsp)
andq $0x0, 0x270(%rsp)
movq %r13, 0x288(%rsp)
movq 0x20(%rsp), %rax
movb %r14b, 0x10(%rax)
movups %xmm0, (%rax)
movaps %xmm0, 0x3e0(%rsp)
movaps %xmm0, 0x3d0(%rsp)
movaps %xmm0, 0x3c0(%rsp)
movaps %xmm0, 0x3b0(%rsp)
movaps %xmm0, 0x3a0(%rsp)
movaps %xmm0, 0x390(%rsp)
movaps %xmm0, 0x380(%rsp)
andq $0x0, 0x3f0(%rsp)
movq %r13, 0x408(%rsp)
movq 0x120(%rsp), %rax
movb %r14b, 0x10(%rax)
movups %xmm0, (%rax)
movaps %xmm0, 0x330(%rsp)
movaps %xmm0, 0x320(%rsp)
movaps %xmm0, 0x310(%rsp)
movaps %xmm0, 0x300(%rsp)
movaps %xmm0, 0x2f0(%rsp)
movaps %xmm0, 0x2e0(%rsp)
andq $0x0, 0x340(%rsp)
movaps %xmm0, 0x2d0(%rsp)
movq %r13, 0x358(%rsp)
movq 0x118(%rsp), %rax
movb %r14b, 0x10(%rax)
movups %xmm0, (%rax)
movq 0x78(%rbx), %rdi
addq %r12, %rdi
movq 0xf0(%rbx), %rax
movq (%rax,%r15,8), %rsi
callq 0x16fbc
movq 0x158(%rsp), %rcx
cmpq 0x150(%rsp), %rcx
jne 0x10818
movsd (%rax), %xmm0
movq %rbp, 0x1d8(%rsp)
andq $0x0, 0x1e0(%rsp)
movsd %xmm0, 0x1e8(%rsp)
movb $0x0, 0x1f0(%rsp)
movq 0x78(%rbx), %rdi
addq %r12, %rdi
movq 0xf0(%rbx), %rax
movq (%rax,%r15,8), %rsi
callq 0x16fbc
movq 0x208(%rsp), %rcx
cmpq 0x200(%rsp), %rcx
jne 0x1081e
movsd (%rax), %xmm0
movq %rbp, 0x288(%rsp)
andq $0x0, 0x290(%rsp)
movsd %xmm0, 0x298(%rsp)
movb $0x0, 0x2a0(%rsp)
movq 0x78(%rbx), %rdi
addq %r12, %rdi
movq 0xf0(%rbx), %rax
movq (%rax,%r15,8), %rsi
callq 0x16fbc
movq 0x388(%rsp), %rcx
cmpq 0x380(%rsp), %rcx
jne 0x1081a
movsd (%rax), %xmm0
movq %rbp, 0x408(%rsp)
movsd %xmm0, 0x410(%rsp)
movsd 0x8(%rsp), %xmm0
movsd %xmm0, 0x418(%rsp)
movb $0x0, 0x420(%rsp)
movq 0x78(%rbx), %rdi
addq %r12, %rdi
movq 0xf0(%rbx), %rax
movq (%rax,%r15,8), %rsi
callq 0x16fbc
movq 0x2d8(%rsp), %rcx
cmpq 0x2d0(%rsp), %rcx
jne 0x1081c
movsd (%rax), %xmm0
movq %rbp, 0x358(%rsp)
movsd %xmm0, 0x360(%rsp)
movsd 0x8(%rsp), %xmm0
movsd %xmm0, 0x368(%rsp)
movb $0x0, 0x370(%rsp)
movq 0x78(%rbx), %rax
xorps %xmm0, %xmm0
movaps %xmm0, 0x60(%rsp)
andq $0x0, 0x70(%rsp)
movaps %xmm0, 0x40(%rsp)
andq $0x0, 0x50(%rsp)
movaps %xmm0, 0xe0(%rsp)
andq $0x0, 0xf0(%rsp)
movaps %xmm0, 0xc0(%rsp)
andq $0x0, 0xd0(%rsp)
movaps %xmm0, 0xa0(%rsp)
andq $0x0, 0xb0(%rsp)
movaps %xmm0, 0x80(%rsp)
andq $0x0, 0x90(%rsp)
movq (%rax,%r12), %rdi
movq 0xf0(%rbx), %rax
movq (%rax,%r15,8), %rax
leaq (%rdi,%rax,8), %rsi
addq $0x8, %rsi
leaq 0x60(%rsp), %rdx
callq 0x1a586
movq 0x78(%rbx), %rax
movq 0xf0(%rbx), %rcx
movq (%rcx,%r15,8), %rcx
movq (%rax,%r12), %rdx
movq 0x8(%rax,%r12), %rsi
leaq 0x8(%rdx,%rcx,8), %rdi
leaq 0x40(%rsp), %rdx
callq 0x1a586
movq 0x80(%rbx), %rax
movq 0xf0(%rbx), %rcx
movq (%rax,%r12), %rdi
movq (%rcx,%r15,8), %rax
leaq (%rdi,%rax,8), %rsi
addq $0x8, %rsi
leaq 0xe0(%rsp), %rdx
callq 0x1a586
movq 0x80(%rbx), %rax
movq 0xf0(%rbx), %rcx
movq (%rcx,%r15,8), %rcx
movq (%rax,%r12), %rdx
movq 0x8(%rax,%r12), %rsi
leaq 0x8(%rdx,%rcx,8), %rdi
leaq 0xc0(%rsp), %rdx
callq 0x1a586
movq 0x88(%rbx), %rax
movq 0xf0(%rbx), %rcx
movq (%rax,%r12), %rdi
movq (%rcx,%r15,8), %rax
leaq (%rdi,%rax,8), %rsi
addq $0x8, %rsi
leaq 0xa0(%rsp), %rdx
callq 0x1a586
movq 0x88(%rbx), %rax
movq 0xf0(%rbx), %rcx
movq (%rcx,%r15,8), %rcx
movq (%rax,%r12), %rdx
movq 0x8(%rax,%r12), %rsi
leaq 0x8(%rdx,%rcx,8), %rdi
leaq 0x80(%rsp), %rdx
callq 0x1a586
movq 0x68(%rsp), %rax
subq 0x60(%rsp), %rax
cmpq $0x11, %rax
jb 0x106cc
leaq 0xe0(%rsp), %rsi
leaq 0xa0(%rsp), %rdx
leaq 0x60(%rsp), %rcx
callq 0xf8a2
leaq 0x150(%rsp), %rdi
leaq 0xe0(%rsp), %rsi
leaq 0x60(%rsp), %rdx
callq 0x109be
leaq 0x200(%rsp), %rdi
leaq 0xa0(%rsp), %rsi
leaq 0x60(%rsp), %rdx
callq 0x109be
movq 0x48(%rsp), %rax
subq 0x40(%rsp), %rax
cmpq $0x11, %rax
jb 0x1072a
leaq 0xc0(%rsp), %rsi
leaq 0x80(%rsp), %rdx
leaq 0x40(%rsp), %rcx
callq 0xf8a2
leaq 0x380(%rsp), %rdi
leaq 0xc0(%rsp), %rsi
leaq 0x40(%rsp), %rdx
callq 0x109be
leaq 0x2d0(%rsp), %rdi
leaq 0x80(%rsp), %rsi
leaq 0x40(%rsp), %rdx
callq 0x109be
movq 0x110(%rsp), %rdi
leaq 0x150(%rsp), %rsi
callq 0x117c8
movq 0x108(%rsp), %rdi
leaq 0x380(%rsp), %rsi
callq 0x117c8
movq 0x100(%rsp), %rdi
leaq 0x200(%rsp), %rsi
callq 0x117c8
movq 0xf8(%rsp), %rdi
leaq 0x2d0(%rsp), %rsi
callq 0x117c8
leaq 0x80(%rsp), %rdi
callq 0x181e8
leaq 0xa0(%rsp), %rdi
callq 0x181e8
leaq 0xc0(%rsp), %rdi
callq 0x181e8
leaq 0xe0(%rsp), %rdi
callq 0x181e8
leaq 0x40(%rsp), %rdi
callq 0x181e8
leaq 0x60(%rsp), %rdi
callq 0x181e8
leaq 0x2d0(%rsp), %rdi
callq 0x1192e
leaq 0x380(%rsp), %rdi
callq 0x1192e
leaq 0x200(%rsp), %rdi
callq 0x1192e
leaq 0x150(%rsp), %rdi
callq 0x1192e
incq %r15
addq $0x18, %r12
jmp 0x1023d
addq $0x33b8, %rsp           # imm = 0x33B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x1081e
jmp 0x1081e
jmp 0x1081e
leaq 0x1deb8(%rip), %rdi     # 0x2e6dd
leaq 0x1debf(%rip), %rsi     # 0x2e6eb
leaq 0x1dec3(%rip), %rcx     # 0x2e6f6
movl $0x113, %edx            # imm = 0x113
callq 0x7270
pushq $0x8
popq %rdi
callq 0x71d0
movq %rax, %r14
pushq $0x1
popq %rdi
callq 0x73f0
movq %rax, %r15
leaq 0x1d53e(%rip), %rsi     # 0x2dd98
movq %rax, %rdi
callq 0xad94
movq %r15, (%r14)
leaq 0x3446c(%rip), %rsi     # 0x44cd8
movq %r14, %rdi
jmp 0x108bb
leaq 0x1d19a(%rip), %rdi     # 0x2da12
callq 0x75c0
pushq $0x8
popq %rdi
callq 0x71d0
leaq 0x1d1a2(%rip), %rcx     # 0x2da2e
jmp 0x108ae
pushq $0x8
popq %rdi
callq 0x71d0
leaq 0x1d3af(%rip), %rcx     # 0x2dc4c
jmp 0x108ae
pushq $0x8
popq %rdi
callq 0x71d0
leaq 0x1d49f(%rip), %rcx     # 0x2dd4d
movq %rcx, (%rax)
movq 0x34698(%rip), %rsi     # 0x44f50
movq %rax, %rdi
xorl %edx, %edx
callq 0x76a0
movq %rax, %rbx
pushq $0x1
popq %rsi
movq %r15, %rdi
callq 0x7400
jmp 0x108f2
movq %rax, %rbx
leaq 0x2b0(%rsp), %rdi
callq 0x71a0
jmp 0x109a8
movq %rax, %rbx
jmp 0x109a8
movq %rax, %rbx
movq %r14, %rdi
callq 0x7300
jmp 0x109a8
jmp 0x10905
jmp 0x10905
jmp 0x10905
movq %rax, %rbx
pushq $0x10
popq %rsi
movq %r14, %rdi
callq 0x7400
jmp 0x109a8
jmp 0x10929
jmp 0x10929
jmp 0x10929
jmp 0x10929
jmp 0x10929
jmp 0x10929
movq %rax, %rbx
jmp 0x10974
movq %rax, %rbx
leaq 0x80(%rsp), %rdi
callq 0x181e8
leaq 0xa0(%rsp), %rdi
callq 0x181e8
leaq 0xc0(%rsp), %rdi
callq 0x181e8
leaq 0xe0(%rsp), %rdi
callq 0x181e8
leaq 0x40(%rsp), %rdi
callq 0x181e8
leaq 0x60(%rsp), %rdi
callq 0x181e8
leaq 0x2d0(%rsp), %rdi
callq 0x1192e
leaq 0x380(%rsp), %rdi
callq 0x1192e
leaq 0x200(%rsp), %rdi
callq 0x1192e
leaq 0x150(%rsp), %rdi
callq 0x1192e
movq %rbx, %rdi
callq 0x76d0