// File: /workspace/github_cpp_makefile_star2_O2/melop[P]admixem/Individual.cpp
// Function: Individual::GetGamete(std::vector<std::vector<Marker, std::allocator<Marker>>, std::allocator<std::vector<Marker, std::allocator<Marker>>>>&, std::vector<std::vector<Gene, std::allocator<Gene>>, std::allocator<std::vector<Gene, std::allocator<Gene>>>>&)
void Individual::GetGamete(vector< vector<Marker> > &vMarkers, vector< vector<Gene> > &vGenes ) {
	
		#ifdef _OPENMP
		int nCPU = omp_get_thread_num();
			#ifdef DEBUG
			printf("CPU %d: %s : %d\n", nCPU, "SexSelFormulae # ", nCPU);
			#endif
		#else
			int nCPU = 0;
		#endif
	//do recombination. 

	bool bSex = (this->_bSex == Male);
	vector< map<double, int> > * pMarkerIndex = SimulConfig.pMarkerConfig->GetMpMarkerIndex();
	vector< map<double, int> > * pGeneIndex = SimulConfig.pGeneConfig->GetMpGeneIndex();

	for (int nChr=0;nChr<this->_nHaploidChrNum;nChr++) { // go over each chromosome
		
		int nMainChr, nOtherChr;
		//int nWhichToPick = (UniformGen.Next() <=0.5)? 0:1;
		double nPaternalTransBias = SimulConfig.pMarkerConfig->GetPaternalTransBias(nChr);
		// 0 is paternal chr, 1 is maternal chr.
		int nWhichToPick = nPaternalTransBias==0.5? (int)vBinomGen[nCPU]->Next() : ( vUniformGen[nCPU]->Next()<=nPaternalTransBias? 0:1 );
		nMainChr = nChr*2 + nWhichToPick;
		nOtherChr = nWhichToPick==0? nMainChr+1:nMainChr-1;
		map<double, int> * pMarkerIndexOnChr = & (pMarkerIndex->at(nChr));
		map<double, int> * pGeneIndexOnChr = & (pGeneIndex->at(nChr));
		double nCentromerePos = SimulConfig.pMarkerConfig->GetCentromerePosition(nChr);
		double nChrLen = SimulConfig.pMarkerConfig->GetChromosomeLength(nChr);

		vector<Marker> vNewMarkers;
		vNewMarkers.reserve(pMarkerIndexOnChr->size());
		vector<Gene> vNewGenes;
		vNewGenes.reserve(pGeneIndexOnChr->size());

					
		size_t nLastIndex = pMarkerIndexOnChr->size()-1;
		map<double,int>::iterator oMarkerCentromereIt = pMarkerIndexOnChr->upper_bound(nCentromerePos);
		//nLastIndex =  pMarkerIndexOnChr->size()-1;

		size_t nCentromereIndex = (oMarkerCentromereIt == pMarkerIndexOnChr->end())? nLastIndex + 1 :oMarkerCentromereIt->second ;
			
		size_t nCentromereIndex_gene=-1, nLastIndex_gene=-1;

		//if (pGeneIndexOnChr->size() != 0)
		//{
			map<double,int>::iterator oGeneCentromereIt = pGeneIndexOnChr->upper_bound(nCentromerePos);
			nLastIndex_gene =  pGeneIndexOnChr->size()-1;
			nCentromereIndex_gene = (oGeneCentromereIt == pGeneIndexOnChr->end())? nLastIndex_gene + 1 :oGeneCentromereIt->second ;
				
		//}

		for (int nArm=1;nArm<=2;nArm++) 
		{


			vector<double> oBreakPoints;
			SimulConfig.pRecombProbConfig->GetBreakPointsByArm(bSex, nChr, nArm, oBreakPoints);
			
			/*
			if (pBreakPoints->size() > 0){
				printf("%d break points, first: %f\n",pBreakPoints->size(), *(pBreakPoints->begin()));
			}
			else {
				printf("No break point on Chr %d arm %d\n", nChr, nArm);
			}
			*/
			int nBreakPoints = oBreakPoints.size();

			bool bSelf = (nArm==1)? (nBreakPoints % 2 ==0) : true; //if it's arm 1, determine which chromosome to start
			int nBpCount = 0;




			int nStartIndex = (nArm == 1)? ((nCentromereIndex!=0)?  0 : INT_MAX ) : nCentromereIndex; // start copying from index 0
			int nEndIndex = 0;

			int nStartIndex_gene = (nArm == 1)? ((nCentromereIndex_gene!=0)?  0 : INT_MAX ): nCentromereIndex_gene; // start copying from index 0
			int nEndIndex_gene = 0;
			/*
			if (nChr == 5 ) {
				printf("break");
			}
			*/
			if (nBreakPoints == 0) { // if no break point, copy the whole damn arm.
				nEndIndex = (nArm == 1)? nCentromereIndex - 1 : nLastIndex;
				nEndIndex_gene = (nArm == 1)? nCentromereIndex_gene - 1 : nLastIndex_gene ;

				vector<Marker> * pvSourceMarkers = &this->_arrMarkers[nMainChr];
				vector<Gene> * pvSourceGenes = &this->_arrGenes[nMainChr];
				if (nStartIndex <= nEndIndex) {
					copy(pvSourceMarkers->begin()+nStartIndex,pvSourceMarkers->begin()+nEndIndex+1,back_inserter(vNewMarkers));
				}
				if (nStartIndex_gene <= nEndIndex_gene) {
					copy(pvSourceGenes->begin()+nStartIndex_gene,pvSourceGenes->begin()+nEndIndex_gene+1,back_inserter(vNewGenes));
				}
				continue; // go to next arm
			}

			bool bNoNeedContinueMarker = false;
			bool bNoNeedContinueGene = false;
			

			for (vector<double>::iterator nBreakPos=oBreakPoints.begin(); nBpCount <= nBreakPoints;) 
			{//Go over each break point
				//find index using position:
				int nChrIndex = bSelf? nMainChr:nOtherChr;
				vector<Marker> * pvSourceMarkers = &this->_arrMarkers[nChrIndex];
				vector<Gene> * pvSourceGenes = &this->_arrGenes[nChrIndex];

				//printf("max size %d\n",  pvSourceMarkers->max_size());

				if (nBpCount == nBreakPoints) // if it's beyond the last break point
				{
					nEndIndex = (nArm == 1)? nCentromereIndex - 1 : nLastIndex;
					nEndIndex_gene = (nArm == 1)? nCentromereIndex_gene - 1 : nLastIndex_gene;
				}
				else {

					map<double, int>::iterator oMarkerBreakPosIt = pMarkerIndexOnChr->upper_bound(*nBreakPos);
					map<double, int>::iterator oGeneBreakPosIt = pGeneIndexOnChr->upper_bound( *nBreakPos);

					if (oMarkerBreakPosIt == pMarkerIndexOnChr->end()) { // there is no more markers beyond the break point
						
						nEndIndex = (nArm == 1)? nCentromereIndex - 1 : nLastIndex;
						if (nStartIndex <= nEndIndex && !bNoNeedContinueMarker) {
							copy(pvSourceMarkers->begin()+nStartIndex,pvSourceMarkers->begin()+nEndIndex+1,back_inserter(vNewMarkers));
						}
						bNoNeedContinueMarker = true;
					}
					else {
						if (!bNoNeedContinueMarker) {
							nEndIndex = (oMarkerBreakPosIt->second < nCentromereIndex)? oMarkerBreakPosIt->second - 1: nCentromereIndex - 1; // need to minus 1 so that all markers on left but not right of Break point are copied
						}
					}

					if (oGeneBreakPosIt == pGeneIndexOnChr->end()) {
						nEndIndex_gene = (nArm == 1)? nCentromereIndex_gene - 1 : nLastIndex_gene;
						if (nStartIndex_gene <= nEndIndex_gene && !bNoNeedContinueGene ) {
							copy(pvSourceGenes->begin()+nStartIndex_gene,pvSourceGenes->begin()+nEndIndex_gene+1,back_inserter(vNewGenes));
						}
						bNoNeedContinueGene = true;
						
					}
					else {
						if (!bNoNeedContinueGene) {
							nEndIndex_gene = ( oGeneBreakPosIt->second < nCentromereIndex_gene)? oGeneBreakPosIt->second - 1: nCentromereIndex_gene - 1 ;
						}
					}

				}



				if (nStartIndex <= nEndIndex && !bNoNeedContinueMarker) {
					copy(pvSourceMarkers->begin()+nStartIndex,pvSourceMarkers->begin()+nEndIndex+1,back_inserter(vNewMarkers));
				}
				if (nStartIndex_gene <= nEndIndex_gene  && !bNoNeedContinueGene) {
					copy(pvSourceGenes->begin()+nStartIndex_gene,pvSourceGenes->begin()+nEndIndex_gene+1,back_inserter(vNewGenes));
				}

				bSelf = !bSelf; // flip
				nStartIndex = nEndIndex + 1;
				nStartIndex_gene = nEndIndex_gene + 1;
				nBpCount++;
				if (nBreakPos != oBreakPoints.end()) {
					++nBreakPos;
				}

	
			}

			
		}

		vMarkers.push_back(vNewMarkers);
		vGenes.push_back(vNewGenes);



	}

	//Perform mutation of genes:
	vector< map<double , GeneProperties> > * pGenes = SimulConfig.pGeneConfig->GetMpGenes();

	for (int nChr=0;nChr<this->_nHaploidChrNum;nChr++) {
		vector< Gene > * pChrmToMutate = &vGenes.at(nChr);
		int nInx = 0;
		for (map<double, GeneProperties>::iterator it2=pGenes->at(nChr).begin(); it2!=pGenes->at(nChr).end(); ++it2) {// genes
			//see if apply mutation rule:
			if (  (*it2).second.MutationProb > 0
					&&
				  (
					(*it2).second.Pops.find("!ANYPOP")!=(*it2).second.Pops.end()
						||
					(*it2).second.Pops.find( ((Population*)this->GetPop())->GetPopName()) !=(*it2).second.Pops.end()
				  )
				   &&
				  (
						(*it2).second.StartGen==-1
							||
						(
							SimulConfig.GetCurrGen() >= (*it2).second.StartGen
							&&
							SimulConfig.GetCurrGen() <= (*it2).second.EndGen
						)

				  )
				
				)
			{
			
				double nMuteProb = (*it2).second.MutationProb;
				if (nMuteProb==0) {//no mutation needed for this locus

				}
				else if( vUniformGen[nCPU]->Next() <= nMuteProb){ // if need to mutate this locus
					//#pragma omp critical
					//{
						double nCurrVal = pChrmToMutate->at(nInx).Value;
						(*it2).second.pFormula->symbols_["CurrVal"] = nCurrVal; //give value to symbol;
						double nNewVal = (*it2).second.pFormula->Evaluate();
						pChrmToMutate->at(nInx).Value = (nNewVal > (*it2).second.UpperBound)? (*it2).second.UpperBound : ((nNewVal < (*it2).second.LowerBound)? (*it2).second.LowerBound : nNewVal);
					//}
				}
			}
			nInx++;
		}
	}
	

	
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x198, %rsp            # imm = 0x198
movq %rdx, 0xe8(%rsp)
movq %rsi, 0x120(%rsp)
movq %rdi, %r13
movl 0x28(%rdi), %eax
movl %eax, 0x74(%rsp)
leaq 0x24c6a(%rip), %rbx     # 0x45938
movq (%rbx), %rdi
callq 0xf7f8
movq %rax, 0x130(%rsp)
movq 0x18(%rbx), %rdi
callq 0x15eee
movq %rax, 0x128(%rsp)
xorl %r15d, %r15d
movq %r13, 0x58(%rsp)
movslq 0x44(%r13), %rax
cmpq %rax, %r15
jge 0x2139f
leaq 0x24c2d(%rip), %rax     # 0x45938
movq (%rax), %rdi
movl %r15d, %esi
callq 0x11bd8
ucomisd 0xc6da(%rip), %xmm0     # 0x2d3f8
jne 0x20d3a
jp 0x20d3a
leaq 0x24d67(%rip), %rax     # 0x45a90
movq (%rax), %rax
movq (%rax), %rdi
movq (%rdi), %rax
callq *(%rax)
cvttsd2si %xmm0, %ebx
jmp 0x20d61
leaq 0x24d7f(%rip), %rax     # 0x45ac0
movq (%rax), %rax
movq (%rax), %rdi
movq (%rdi), %rax
movsd %xmm0, 0x18(%rsp)
callq *(%rax)
xorl %ebx, %ebx
movsd 0x18(%rsp), %xmm1
ucomisd %xmm0, %xmm1
setb %bl
movl %ebx, %eax
negl %eax
movl $0x0, %eax
sbbl %eax, %eax
movl %eax, 0x34(%rsp)
movq 0x130(%rsp), %rdi
movq %r15, %rsi
callq 0x16f9e
movq %rax, %r12
movq 0x128(%rsp), %rdi
movq %r15, %rsi
callq 0x16f9e
movq %rax, %rbp
leaq 0x24b9b(%rip), %r14     # 0x45938
movq (%r14), %rdi
movl %r15d, %esi
callq 0x11bb6
movsd %xmm0, 0x118(%rsp)
movq (%r14), %rdi
movq %r12, %r14
movl %r15d, %esi
callq 0x109b0
xorpd %xmm0, %xmm0
movapd %xmm0, 0xc0(%rsp)
andq $0x0, 0xd0(%rsp)
movq 0x28(%r12), %rsi
leaq 0xc0(%rsp), %rdi
callq 0x232d4
xorpd %xmm0, %xmm0
movapd %xmm0, 0xa0(%rsp)
andq $0x0, 0xb0(%rsp)
movq 0x28(%rbp), %rsi
leaq 0xa0(%rsp), %rdi
callq 0x23368
movq 0x28(%r14), %r12
movq %r14, %rdi
leaq 0x118(%rsp), %rsi
callq 0x24474
movq %r14, %rcx
addq $0x8, %rcx
movq %r12, 0x38(%rsp)
movq %rcx, 0x170(%rsp)
cmpq %rcx, %rax
je 0x20e44
movslq 0x28(%rax), %rax
movq %rax, 0x38(%rsp)
movq %rbp, %rdi
leaq 0x118(%rsp), %rsi
callq 0x24474
movq 0x28(%rbp), %rcx
movq %rbp, %rdx
addq $0x8, %rdx
movq %rcx, 0x68(%rsp)
movq %rcx, %rsi
movq %rdx, 0x168(%rsp)
cmpq %rdx, %rax
je 0x20e78
movslq 0x28(%rax), %rsi
leal (%rbx,%r15,2), %edx
orl $0x1, 0x34(%rsp)
decq %r12
decq 0x68(%rsp)
movq 0x38(%rsp), %rcx
testq %rcx, %rcx
movl $0x0, %edi
movl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
cmoveq %rax, %rdi
movq %rdi, 0x150(%rsp)
testq %rsi, %rsi
movl $0x0, %edi
cmoveq %rax, %rdi
movq %rdi, 0x148(%rsp)
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
leaq (%rcx,%rax), %rcx
movq %rcx, 0xf8(%rsp)
movq %rsi, 0x100(%rsp)
leaq (%rsi,%rax), %rax
movq %rax, 0xf0(%rsp)
movl %edx, 0x7c(%rsp)
movslq %edx, %rax
movq %rax, 0x138(%rsp)
pushq $0x1
popq %rbx
movq %r15, 0x140(%rsp)
movq %r14, 0x180(%rsp)
movq %rbp, 0x178(%rsp)
movq %r12, 0x188(%rsp)
cmpl $0x3, %ebx
je 0x21353
xorl %esi, %esi
cmpl $0x0, 0x74(%rsp)
sete %sil
xorpd %xmm0, %xmm0
movapd %xmm0, 0x80(%rsp)
andq $0x0, 0x90(%rsp)
leaq 0x249f5(%rip), %rax     # 0x45938
movq 0x8(%rax), %rdi
movl %r15d, %edx
movl %ebx, %ecx
leaq 0x80(%rsp), %r8
callq 0x11960
movq 0x80(%rsp), %rax
movq 0x88(%rsp), %rdx
movq %rax, %rcx
subq %rax, %rdx
sarq $0x3, %rdx
cmpl $0x1, %ebx
movq 0x150(%rsp), %rsi
cmovneq 0x38(%rsp), %rsi
movq 0x148(%rsp), %rax
cmovneq 0x100(%rsp), %rax
movq %rax, 0x18(%rsp)
testl %edx, %edx
movl %ebx, 0x78(%rsp)
je 0x212a0
movq %rsi, 0x28(%rsp)
movq %rdx, 0x190(%rsp)
movl %edx, %eax
xorb $0x1, %al
cmpl $0x1, %ebx
setne %dl
movq 0xf8(%rsp), %rsi
cmovneq %r12, %rsi
movq 0xf0(%rsp), %rdi
cmovneq 0x68(%rsp), %rdi
orb %al, %dl
movb %dl, 0x60(%rsp)
movq %rsi, 0x48(%rsp)
movslq %esi, %rax
addq %rax, %rax
movq %rax, 0x160(%rsp)
movq %rdi, 0x40(%rsp)
movslq %edi, %rax
shlq $0x4, %rax
movq %rax, 0x158(%rsp)
movl $0x0, 0xc(%rsp)
movl $0x0, 0x10(%rsp)
xorl %r14d, %r14d
xorl %r13d, %r13d
xorl %esi, %esi
movq %rcx, %rbx
movq 0x190(%rsp), %rdx
cmpl %edx, %esi
jg 0x2132e
testb $0x1, 0x60(%rsp)
movl 0x34(%rsp), %eax
movl $0x0, %ecx
cmovnel %ecx, %eax
addl 0x7c(%rsp), %eax
cltq
imulq $0x18, %rax, %r12
movq 0x58(%rsp), %rax
movq 0x110(%rax), %rbp
addq %r12, %rbp
addq 0x128(%rax), %r12
movslq 0x28(%rsp), %rax
movq %rax, 0x110(%rsp)
movslq 0x18(%rsp), %rax
movq %rax, 0x108(%rsp)
movl %esi, 0x20(%rsp)
cmpl %esi, %edx
jne 0x21091
movq 0x40(%rsp), %r14
movq 0x48(%rsp), %r13
jmp 0x21188
movq 0x180(%rsp), %rdi
movq %rbx, %rsi
callq 0x24474
movq %rax, %r15
movq 0x178(%rsp), %rdi
movq %rbx, 0x50(%rsp)
movq %rbx, %rsi
callq 0x24474
movq %rax, %rbx
cmpq 0x170(%rsp), %r15
je 0x210e7
movl 0x10(%rsp), %ecx
testb $0x1, %cl
jne 0x210e2
movslq 0x28(%r15), %rax
movq 0x38(%rsp), %r13
cmpq %rax, %r13
cmoval %eax, %r13d
decl %r13d
movl %ecx, %r15d
jmp 0x21136
movb $0x1, %r15b
movq 0x48(%rsp), %r13
cmpl %r13d, 0x28(%rsp)
jg 0x21102
testb $0x1, 0x10(%rsp)
je 0x21104
movq 0x48(%rsp), %r13
jmp 0x21136
movq (%rbp), %rax
movq 0x110(%rsp), %rcx
leaq (%rax,%rcx,2), %rdi
movq 0x160(%rsp), %rcx
leaq (%rax,%rcx), %rsi
addq $0x2, %rsi
leaq 0xc0(%rsp), %rdx
callq 0x244aa
movq 0x48(%rsp), %r13
cmpq 0x168(%rsp), %rbx
je 0x21166
testb $0x1, 0xc(%rsp)
jne 0x2115d
movslq 0x28(%rbx), %rax
movq 0x100(%rsp), %r14
cmpq %rax, %r14
cmoval %eax, %r14d
decl %r14d
movl %r15d, %eax
movl %eax, 0x10(%rsp)
jmp 0x21183
movq 0x40(%rsp), %r14
cmpl %r14d, 0x18(%rsp)
jle 0x21236
movb $0x1, %al
movl %eax, 0xc(%rsp)
movl %r15d, %eax
movl %eax, 0x10(%rsp)
movq 0x50(%rsp), %rbx
cmpl %r13d, 0x28(%rsp)
jg 0x211be
testb $0x1, 0x10(%rsp)
jne 0x211be
movq (%rbp), %rax
movq 0x110(%rsp), %rcx
leaq (%rax,%rcx,2), %rdi
movslq %r13d, %rcx
leaq (%rax,%rcx,2), %rsi
addq $0x2, %rsi
leaq 0xc0(%rsp), %rdx
callq 0x244aa
cmpl %r14d, 0x18(%rsp)
jg 0x211fb
testb $0x1, 0xc(%rsp)
jne 0x211fb
movq (%r12), %rax
movq 0x108(%rsp), %rdi
shlq $0x4, %rdi
addq %rax, %rdi
movslq %r14d, %rcx
shlq $0x4, %rcx
leaq (%rax,%rcx), %rsi
addq $0x10, %rsi
leaq 0xa0(%rsp), %rdx
callq 0x244e0
xorb $0x1, 0x60(%rsp)
leal 0x1(%r13), %eax
movq %rax, 0x28(%rsp)
leal 0x1(%r14), %eax
movq %rax, 0x18(%rsp)
movl 0x20(%rsp), %esi
incl %esi
xorl %eax, %eax
cmpq 0x88(%rsp), %rbx
setne %al
leaq (%rbx,%rax,8), %rbx
movq 0x188(%rsp), %r12
jmp 0x2101f
testb $0x1, 0xc(%rsp)
movq 0x50(%rsp), %rbx
je 0x21259
movb $0x1, %al
movl %eax, 0xc(%rsp)
movl %r15d, %eax
movl %eax, 0x10(%rsp)
movq 0x40(%rsp), %r14
jmp 0x21188
movq (%r12), %rax
movq 0x108(%rsp), %rdi
shlq $0x4, %rdi
addq %rax, %rdi
movq 0x158(%rsp), %rcx
leaq (%rax,%rcx), %rsi
addq $0x10, %rsi
leaq 0xa0(%rsp), %rdx
callq 0x244e0
movb $0x1, %al
movl %eax, 0xc(%rsp)
movl %r15d, %eax
movl %eax, 0x10(%rsp)
movq 0x40(%rsp), %r14
jmp 0x21188
cmpl $0x1, %ebx
movq 0xf8(%rsp), %rax
cmovneq %r12, %rax
movq 0xf0(%rsp), %rbx
cmovneq 0x68(%rsp), %rbx
imulq $0x18, 0x138(%rsp), %rcx
movq 0x128(%r13), %r14
addq %rcx, %r14
cmpl %eax, %esi
jg 0x212fd
movq 0x110(%r13), %rdx
movq (%rdx,%rcx), %rcx
movslq %esi, %rdx
leaq (%rcx,%rdx,2), %rdi
cltq
leaq (%rcx,%rax,2), %rsi
addq $0x2, %rsi
leaq 0xc0(%rsp), %rdx
callq 0x244aa
cmpl %ebx, 0x18(%rsp)
jg 0x2132e
movq (%r14), %rax
movslq 0x18(%rsp), %rdi
shlq $0x4, %rdi
addq %rax, %rdi
movslq %ebx, %rcx
shlq $0x4, %rcx
leaq (%rax,%rcx), %rsi
addq $0x10, %rsi
leaq 0xa0(%rsp), %rdx
callq 0x244e0
leaq 0x80(%rsp), %rdi
callq 0x181e8
movl 0x78(%rsp), %ebx
incl %ebx
movq 0x58(%rsp), %r13
movq 0x140(%rsp), %r15
jmp 0x20f12
movq 0x120(%rsp), %rdi
leaq 0xc0(%rsp), %rsi
callq 0x22f22
movq 0xe8(%rsp), %rdi
leaq 0xa0(%rsp), %rsi
callq 0x22f8a
leaq 0xa0(%rsp), %rdi
callq 0x238e8
leaq 0xc0(%rsp), %rdi
callq 0x234fa
incq %r15
jmp 0x20cf7
leaq 0x24592(%rip), %rax     # 0x45938
movq 0x18(%rax), %rdi
callq 0x15eda
movq %rax, %r14
xorl %r15d, %r15d
leaq 0xc0(%rsp), %rbp
movq %rax, 0x60(%rsp)
movslq 0x44(%r13), %rax
cmpq %rax, %r15
jge 0x2160e
movq 0xe8(%rsp), %rdi
movq %r15, %rsi
callq 0x22fb6
movq %rax, 0x10(%rsp)
movq %r14, %rdi
movq %r15, %rsi
callq 0x22f4e
movq 0x18(%rax), %r12
xorl %ebx, %ebx
movq %r15, 0x28(%rsp)
movq %r14, %rdi
movq %r15, %rsi
callq 0x22f4e
addq $0x8, %rax
cmpq %rax, %r12
je 0x21606
movsd 0x78(%r12), %xmm0
ucomisd 0xbbf7(%rip), %xmm0     # 0x2d018
jbe 0x215f3
movq %rbp, %rdi
leaq 0xd0a4(%rip), %rsi      # 0x2e4d5
leaq 0x80(%rsp), %rdx
callq 0x9512
movq %rbx, 0x18(%rsp)
leaq 0xb8(%r12), %rbx
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x24518
movq %rax, %r13
leaq 0xc0(%r12), %r14
cmpq %r14, %rax
jne 0x2148f
movq 0x58(%rsp), %rax
movq 0x18(%rax), %rsi
leaq 0xa0(%rsp), %r15
movq %r15, %rdi
callq 0x27b7e
movq %rbx, %rdi
movq %r15, %rsi
callq 0x24518
cmpq %r13, %rax
je 0x214d1
cmpl $-0x1, 0xe8(%r12)
sete %bl
je 0x214ca
leaq 0x24494(%rip), %rdi     # 0x45938
callq 0x16ac0
cmpl 0xe8(%r12), %eax
jl 0x214ca
leaq 0x2447e(%rip), %rdi     # 0x45938
callq 0x16ac0
cmpl 0xec(%r12), %eax
setle %bl
cmpq %r14, %r13
jne 0x214e0
jmp 0x214d3
xorl %ebx, %ebx
leaq 0xa0(%rsp), %rdi
callq 0x71a0
movq %rbp, %rdi
callq 0x71a0
testb %bl, %bl
movq 0x58(%rsp), %r13
movq 0x60(%rsp), %r14
movq 0x28(%rsp), %r15
movq 0x18(%rsp), %rbx
je 0x215f3
movsd 0x78(%r12), %xmm0
ucomisd 0xbb05(%rip), %xmm0     # 0x2d018
jne 0x2151b
jnp 0x215f3
leaq 0x2459e(%rip), %rax     # 0x45ac0
movq (%rax), %rax
movq (%rax), %rdi
movq (%rdi), %rax
movsd %xmm0, 0x20(%rsp)
callq *(%rax)
movsd 0x20(%rsp), %xmm1
ucomisd %xmm0, %xmm1
jb 0x215f3
movq 0x10(%rsp), %rdi
movq %rbx, %rsi
callq 0x22fd4
movsd 0x8(%rax), %xmm0
movsd %xmm0, 0x20(%rsp)
movq 0x90(%r12), %rbx
movq %rbp, %rdi
leaq 0xd975(%rip), %rsi      # 0x2eee2
leaq 0x80(%rsp), %rdx
callq 0x9512
addq $0x68, %rbx
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x18432
movsd 0x20(%rsp), %xmm0
movsd %xmm0, (%rax)
movq %rbp, %rdi
callq 0x71a0
movq 0x90(%r12), %rdi
callq 0x920c
movsd 0x88(%r12), %xmm2
ucomisd %xmm2, %xmm0
movq 0x18(%rsp), %rbx
ja 0x215d5
movsd 0x80(%r12), %xmm1
ucomisd %xmm0, %xmm1
movapd %xmm0, %xmm2
jbe 0x215d5
movapd %xmm1, %xmm2
movsd %xmm2, 0x20(%rsp)
movq 0x10(%rsp), %rdi
movq %rbx, %rsi
callq 0x22fd4
movsd 0x20(%rsp), %xmm0
movsd %xmm0, 0x8(%rax)
incq %rbx
movq %r12, %rdi
callq 0x72d0
movq %rax, %r12
jmp 0x213fa
incq %r15
jmp 0x213c2
addq $0x198, %rsp            # imm = 0x198
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x2162d
jmp 0x2162d
movq %rax, %rbx
jmp 0x21694
jmp 0x21659
jmp 0x21654
movq %rax, %rbx
jmp 0x21687
movq %rax, %rbx
jmp 0x21645
jmp 0x21659
jmp 0x21677
jmp 0x21677
movq %rax, %rbx
cmpq %r14, %r13
jne 0x2165c
leaq 0xa0(%rsp), %rdi
callq 0x71a0
jmp 0x2165c
movq %rax, %rbx
jmp 0x216a1
movq %rax, %rbx
leaq 0xc0(%rsp), %rdi
callq 0x71a0
jmp 0x216a1
jmp 0x21677
jmp 0x21677
jmp 0x21677
jmp 0x21677
jmp 0x21677
jmp 0x21677
movq %rax, %rbx
leaq 0x80(%rsp), %rdi
callq 0x181e8
leaq 0xa0(%rsp), %rdi
callq 0x238e8
leaq 0xc0(%rsp), %rdi
callq 0x234fa
movq %rbx, %rdi
callq 0x76d0
nop