// File: /workspace/github_cpp_makefile_star2_O1/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 $0x178, %rsp            # imm = 0x178
movq %rdx, 0x100(%rsp)
movq %rsi, 0x130(%rsp)
movq %rdi, %r14
movl 0x28(%rdi), %eax
movl %eax, 0xf4(%rsp)
leaq 0x262ad(%rip), %rbx     # 0x49908
movq (%rbx), %rdi
callq 0x10834
movq %rax, 0x140(%rsp)
movq 0x18(%rbx), %rdi
callq 0x18892
movq %rax, 0x138(%rsp)
cmpl $0x0, 0x44(%r14)
movq %r14, 0x28(%rsp)
jle 0x23eca
xorl %r13d, %r13d
leaq 0x26272(%rip), %rax     # 0x49908
movq (%rax), %rdi
movl %r13d, %esi
callq 0x13470
ucomisd 0x11d67(%rip), %xmm0    # 0x35410
jne 0x236c6
jp 0x236c6
leaq 0x263ac(%rip), %rax     # 0x49a60
movq (%rax), %rax
movq (%rax), %rdi
movq (%rdi), %rax
callq *(%rax)
cvttsd2si %xmm0, %r12d
jmp 0x236ed
leaq 0x263c3(%rip), %rax     # 0x49a90
movq (%rax), %rax
movq (%rax), %rdi
movq (%rdi), %rax
movsd %xmm0, (%rsp)
callq *(%rax)
xorl %r12d, %r12d
movsd (%rsp), %xmm1
ucomisd %xmm0, %xmm1
setb %r12b
movl %r12d, %eax
negl %eax
movl $0x0, %eax
sbbl %eax, %eax
movl %eax, 0x14(%rsp)
movq 0x140(%rsp), %rax
movq (%rax), %rcx
movq 0x8(%rax), %rdx
subq %rcx, %rdx
sarq $0x4, %rdx
movabsq $-0x5555555555555555, %rax # imm = 0xAAAAAAAAAAAAAAAB
imulq %rax, %rdx
cmpq %r13, %rdx
jbe 0x2429d
movq %rcx, %rsi
movq 0x138(%rsp), %rcx
movq (%rcx), %rdi
movq 0x8(%rcx), %rdx
subq %rdi, %rdx
sarq $0x4, %rdx
imulq %rax, %rdx
cmpq %r13, %rdx
jbe 0x2429d
movq %rdi, %rbx
leaq (,%r13,2), %r14
addq %r13, %r14
shlq $0x4, %r14
movq %rsi, %rbp
addq %r14, %rbp
leaq 0x26199(%rip), %r15     # 0x49908
movq (%r15), %rdi
movl %r13d, %esi
callq 0x13434
movsd %xmm0, 0x8(%rsp)
movq (%r15), %rdi
movl %r13d, %esi
callq 0x11fa0
xorpd %xmm0, %xmm0
movapd %xmm0, 0x40(%rsp)
movq $0x0, 0x50(%rsp)
movq %rbp, 0xe8(%rsp)
movq 0x28(%rbp), %rsi
leaq 0x40(%rsp), %rdi
callq 0x26b7c
addq %r14, %rbx
xorpd %xmm0, %xmm0
movapd %xmm0, 0xa0(%rsp)
movq $0x0, 0xb0(%rsp)
movq %rbx, 0xe0(%rsp)
movq 0x28(%rbx), %rsi
leaq 0xa0(%rsp), %rdi
callq 0x26c10
movq 0xe8(%rsp), %rax
movq 0x10(%rax), %rcx
addq $0x8, %rax
movq %rax, (%rsp)
testq %rcx, %rcx
movsd 0x8(%rsp), %xmm1
je 0x23828
movq (%rsp), %rax
movsd 0x20(%rcx), %xmm0
xorl %edx, %edx
ucomisd %xmm1, %xmm0
cmovaq %rcx, %rax
setbe %dl
movq 0x10(%rcx,%rdx,8), %rcx
testq %rcx, %rcx
jne 0x2380c
movq 0xe8(%rsp), %rcx
movq 0x28(%rcx), %rcx
movq %rcx, 0xd0(%rsp)
movq %rcx, 0x68(%rsp)
cmpq (%rsp), %rax
je 0x23850
movslq 0x28(%rax), %rax
movq %rax, 0x68(%rsp)
movq 0xe0(%rsp), %rax
movq 0x10(%rax), %rcx
addq $0x8, %rax
movq %rax, 0x20(%rsp)
testq %rcx, %rcx
je 0x2388b
movq 0x20(%rsp), %rax
movsd 0x20(%rcx), %xmm0
xorl %edx, %edx
ucomisd %xmm1, %xmm0
cmovaq %rcx, %rax
setbe %dl
movq 0x10(%rcx,%rdx,8), %rcx
testq %rcx, %rcx
jne 0x2386f
movq 0xe0(%rsp), %rcx
movq 0x28(%rcx), %rcx
movq %rcx, 0xc8(%rsp)
movq %rcx, %r14
cmpq 0x20(%rsp), %rax
je 0x238ad
movslq 0x28(%rax), %r14
leal (%r12,%r13,2), %edx
orl $0x1, 0x14(%rsp)
decq 0xd0(%rsp)
decq 0xc8(%rsp)
movq 0x68(%rsp), %rcx
testq %rcx, %rcx
movl $0x0, %esi
movl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
cmoveq %rax, %rsi
movq %rsi, 0x170(%rsp)
testq %r14, %r14
movl $0x0, %esi
cmoveq %rax, %rsi
movq %rsi, 0x168(%rsp)
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq %rax, %rcx
movq %rcx, 0x110(%rsp)
addq %r14, %rax
movq %rax, 0x108(%rsp)
movl %edx, 0x78(%rsp)
movslq %edx, %rax
movq %rax, 0x148(%rsp)
movl $0x1, %ebp
movq %r13, 0x160(%rsp)
movq %r14, 0x118(%rsp)
xorl %esi, %esi
cmpl $0x0, 0xf4(%rsp)
sete %sil
xorpd %xmm0, %xmm0
movapd %xmm0, 0x80(%rsp)
movq $0x0, 0x90(%rsp)
leaq 0x25fa3(%rip), %rax     # 0x49908
movq 0x8(%rax), %rdi
movl %r13d, %edx
movl %ebp, %ecx
leaq 0x80(%rsp), %r8
callq 0x13178
movq 0x80(%rsp), %r13
movq 0x88(%rsp), %r8
subq %r13, %r8
sarq $0x3, %r8
movl %r8d, %eax
xorb $0x1, %al
cmpl $0x1, %ebp
setne %bl
movq 0x170(%rsp), %r11
cmovneq 0x68(%rsp), %r11
movq 0x168(%rsp), %rdi
cmovneq %r14, %rdi
orb %al, %bl
testl %r8d, %r8d
movl %ebp, 0x3c(%rsp)
je 0x23d76
js 0x23e1e
cmpl $0x1, 0x3c(%rsp)
movq 0x110(%rsp), %rdx
movq %rdx, %r9
movq 0xd0(%rsp), %rax
cmovneq %rax, %r9
movq 0x108(%rsp), %rsi
movq %rsi, %r10
movq 0xc8(%rsp), %rcx
cmovneq %rcx, %r10
cmovnel %eax, %edx
movl %edx, 0xfc(%rsp)
movq %r9, 0x128(%rsp)
movslq %r9d, %rax
movl %esi, %edx
cmovnel %ecx, %edx
movl %edx, 0xf8(%rsp)
addq %rax, %rax
movq %rax, 0x158(%rsp)
movq %r10, 0x120(%rsp)
movslq %r10d, %rax
shlq $0x4, %rax
movq %rax, 0x150(%rsp)
xorl %r15d, %r15d
xorl %r9d, %r9d
xorl %r10d, %r10d
xorl %edx, %edx
xorl %esi, %esi
movq %r8, 0x70(%rsp)
testb $0x1, %bl
movl 0x14(%rsp), %eax
movl $0x0, %ecx
cmovnel %ecx, %eax
addl 0x78(%rsp), %eax
cltq
shlq $0x3, %rax
leaq (%rax,%rax,2), %r14
movq 0x28(%rsp), %rax
movq 0x110(%rax), %r12
addq %r14, %r12
addq 0x128(%rax), %r14
cmpl %r8d, %r15d
jne 0x23aa8
movq %rdi, %rbp
movl 0xf8(%rsp), %eax
movl %eax, %r10d
movl 0xfc(%rsp), %eax
movl %eax, %r9d
jmp 0x23c14
movq %r12, 0x18(%rsp)
movq %rdx, %rbp
movq 0xe8(%rsp), %rax
movq 0x10(%rax), %rcx
movq (%rsp), %rax
testq %rcx, %rcx
je 0x23aeb
movsd (%r13), %xmm0
movq (%rsp), %rax
movsd 0x20(%rcx), %xmm1
xorl %edx, %edx
ucomisd %xmm0, %xmm1
cmovaq %rcx, %rax
setbe %dl
movq 0x10(%rcx,%rdx,8), %rcx
testq %rcx, %rcx
jne 0x23acf
movq 0xe0(%rsp), %rcx
movq 0x10(%rcx), %rcx
movq 0x20(%rsp), %r12
testq %rcx, %rcx
je 0x23b28
movsd (%r13), %xmm0
movq 0x20(%rsp), %r12
movsd 0x20(%rcx), %xmm1
xorl %edx, %edx
ucomisd %xmm0, %xmm1
cmovaq %rcx, %r12
setbe %dl
movq 0x10(%rcx,%rdx,8), %rcx
testq %rcx, %rcx
jne 0x23b0c
cmpq (%rsp), %rax
je 0x23b4e
testb $0x1, %bpl
jne 0x23b4a
movslq 0x28(%rax), %rax
movq 0x68(%rsp), %rcx
cmpq %rax, %rcx
movl %ecx, %r9d
cmoval %eax, %r9d
decl %r9d
movl %ebp, %edx
jmp 0x23bca
movb $0x1, %dl
movq 0x128(%rsp), %rax
cmpl %eax, %r11d
jg 0x23b63
testb $0x1, %bpl
je 0x23b68
movl %eax, %r9d
jmp 0x23bca
movq 0x18(%rsp), %rax
movq (%rax), %rax
movslq %r11d, %rcx
movq %rdi, 0x30(%rsp)
leaq (%rax,%rcx,2), %rdi
movq 0x158(%rsp), %rcx
movq %rsi, 0x8(%rsp)
leaq 0x2(%rax,%rcx), %rsi
leaq 0x40(%rsp), %rdx
movq %r11, %rbp
movq %r10, 0xd8(%rsp)
callq 0x27ab4
movb $0x1, %dl
movq 0xd8(%rsp), %r10
movq 0x8(%rsp), %rsi
movq %rbp, %r11
movq 0x70(%rsp), %r8
movq 0x30(%rsp), %rdi
movq 0x128(%rsp), %rax
movl %eax, %r9d
cmpq 0x20(%rsp), %r12
je 0x23bf6
movq %rdi, %rbp
testb $0x1, %sil
jne 0x23bf4
movslq 0x28(%r12), %rax
movq 0x118(%rsp), %rcx
cmpq %rax, %rcx
movl %ecx, %r10d
cmoval %eax, %r10d
decl %r10d
jmp 0x23c0f
movq 0x120(%rsp), %rax
cmpl %eax, %edi
jle 0x23cf7
movq %rdi, %rbp
movb $0x1, %sil
movl %eax, %r10d
movq 0x18(%rsp), %r12
cmpl %r9d, %r11d
jg 0x23c70
testb $0x1, %dl
jne 0x23c70
movq (%r12), %rax
movslq %r11d, %rcx
leaq (%rax,%rcx,2), %rdi
movslq %r9d, %rcx
movq %rsi, 0x8(%rsp)
leaq 0x2(%rax,%rcx,2), %rsi
movq %rdx, 0x30(%rsp)
leaq 0x40(%rsp), %rdx
movq %r9, %r12
movq %r15, 0x18(%rsp)
movq %r14, %r15
movq %r10, %r14
callq 0x27ab4
movq 0x30(%rsp), %rdx
movq %r14, %r10
movq %r15, %r14
movq 0x18(%rsp), %r15
movq %r12, %r9
movq 0x8(%rsp), %rsi
movq 0x70(%rsp), %r8
cmpl %r10d, %ebp
jg 0x23cc5
testb $0x1, %sil
jne 0x23cc5
movq (%r14), %rax
movslq %ebp, %rdi
shlq $0x4, %rdi
addq %rax, %rdi
movslq %r10d, %rcx
shlq $0x4, %rcx
movq %rsi, 0x8(%rsp)
leaq (%rax,%rcx), %rsi
addq $0x10, %rsi
movq %rdx, %r14
leaq 0xa0(%rsp), %rdx
movq %r9, %rbp
movq %r10, %r12
callq 0x27b0a
movq %r14, %rdx
movq %r12, %r10
movq %rbp, %r9
movq 0x8(%rsp), %rsi
movq 0x70(%rsp), %r8
xorb $0x1, %bl
leal 0x1(%r9), %r11d
leal 0x1(%r10), %edi
leal 0x1(%r15), %eax
xorl %ecx, %ecx
cmpq 0x88(%rsp), %r13
setne %cl
leaq (%r13,%rcx,8), %r13
cmpl %r8d, %r15d
movl %eax, %r15d
jne 0x23a54
jmp 0x23e1e
testb $0x1, %sil
movq 0x18(%rsp), %r12
je 0x23d10
movq %rdi, %rbp
movb $0x1, %sil
movl %eax, %r10d
jmp 0x23c14
movq (%r14), %rax
movq %rdi, %rbp
movslq %edi, %rdi
shlq $0x4, %rdi
addq %rax, %rdi
movq 0x150(%rsp), %rcx
leaq (%rax,%rcx), %rsi
addq $0x10, %rsi
movb %dl, 0xd8(%rsp)
leaq 0xa0(%rsp), %rdx
movq %r11, 0x8(%rsp)
movq %r9, 0x30(%rsp)
callq 0x27b0a
movq 0x30(%rsp), %r9
movq 0x8(%rsp), %r11
movq 0x70(%rsp), %r8
movb $0x1, %sil
movb 0xd8(%rsp), %al
movl %eax, %edx
movq 0x120(%rsp), %r10
jmp 0x23c14
cmpl $0x1, %ebp
movq 0x110(%rsp), %rax
cmovneq 0xd0(%rsp), %rax
movq 0x108(%rsp), %rbx
cmovneq 0xc8(%rsp), %rbx
movq 0x148(%rsp), %rcx
leaq (%rcx,%rcx,2), %rcx
leaq (,%rcx,8), %r14
movq 0x28(%rsp), %rdx
addq 0x128(%rdx), %r14
cmpl %eax, %r11d
jg 0x23df1
movq 0x28(%rsp), %rdx
movq 0x110(%rdx), %rdx
movq (%rdx,%rcx,8), %rcx
movslq %r11d, %rdx
movq %rdi, %r15
leaq (%rcx,%rdx,2), %rdi
cltq
leaq (%rcx,%rax,2), %rsi
addq $0x2, %rsi
leaq 0x40(%rsp), %rdx
callq 0x27ab4
movq %r15, %rdi
cmpl %ebx, %edi
jg 0x23e1e
movq (%r14), %rax
movslq %edi, %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 0x27b0a
movq 0x80(%rsp), %rdi
testq %rdi, %rdi
je 0x23e3b
movq 0x90(%rsp), %rsi
subq %rdi, %rsi
callq 0x7390
movl 0x3c(%rsp), %ebp
incl %ebp
cmpl $0x3, %ebp
movq 0x160(%rsp), %r13
movq 0x118(%rsp), %r14
jne 0x23937
movq 0x130(%rsp), %rdi
leaq 0x40(%rsp), %rsi
callq 0x2682e
movq 0x100(%rsp), %rdi
leaq 0xa0(%rsp), %rsi
callq 0x2685a
movq 0xa0(%rsp), %rdi
testq %rdi, %rdi
je 0x23e9e
movq 0xb0(%rsp), %rsi
subq %rdi, %rsi
callq 0x7390
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x23eb5
movq 0x50(%rsp), %rsi
subq %rdi, %rsi
callq 0x7390
incq %r13
movq 0x28(%rsp), %rax
movslq 0x44(%rax), %rax
cmpq %rax, %r13
jl 0x2368f
leaq 0x25a37(%rip), %rax     # 0x49908
movq 0x18(%rax), %rdi
callq 0x1887a
movq 0x28(%rsp), %rcx
cmpl $0x0, 0x44(%rcx)
jle 0x24263
leaq 0x50(%rsp), %r15
xorl %esi, %esi
movq %rax, 0x18(%rsp)
movq 0x100(%rsp), %rdx
movq (%rdx), %rcx
movq 0x8(%rdx), %rdx
subq %rcx, %rdx
sarq $0x3, %rdx
movabsq $-0x5555555555555555, %rdi # imm = 0xAAAAAAAAAAAAAAAB
imulq %rdi, %rdx
cmpq %rsi, %rdx
jbe 0x24294
movq (%rax), %r8
movq 0x8(%rax), %rdx
subq %r8, %rdx
sarq $0x4, %rdx
imulq %rdi, %rdx
cmpq %rsi, %rdx
jbe 0x24294
movq (%rax), %r9
movq 0x8(%rax), %rdx
subq %r9, %rdx
sarq $0x4, %rdx
imulq %rdi, %rdx
movq %rsi, 0x20(%rsp)
cmpq %rsi, %rdx
jbe 0x24275
movq 0x20(%rsp), %rdx
leaq (%rdx,%rdx,2), %rax
leaq (%rcx,%rax,8), %rcx
movq %rcx, 0x78(%rsp)
shlq $0x4, %rax
movq %rax, 0x8(%rsp)
movq 0x18(%r8,%rax), %r13
movl $0x8, %ebx
xorl %r12d, %r12d
movq 0x8(%rsp), %rax
addq %r9, %rax
addq $0x8, %rax
cmpq %rax, %r13
je 0x24244
movsd 0x78(%r13), %xmm0
movsd %xmm0, (%rsp)
ucomisd 0x11073(%rip), %xmm0    # 0x35020
jbe 0x2404d
movq %r15, 0x40(%rsp)
leaq 0x40(%rsp), %r14
movq %r14, %rdi
leaq 0x1253e(%rip), %rsi     # 0x36505
leaq 0x1253e(%rip), %rdx     # 0x3650c
callq 0xa886
leaq 0xb8(%r13), %rbp
movq %rbp, %rdi
movq %r14, %rsi
callq 0x27b60
leaq 0xc0(%r13), %r15
cmpq %r15, %rax
sete %al
movl %eax, 0x14(%rsp)
jne 0x24021
movq 0x28(%rsp), %rax
movq 0x18(%rax), %rsi
leaq 0xa0(%rsp), %r14
movq %r14, %rdi
callq 0x2c3c8
movq %rbp, %rdi
movq %r14, %rsi
callq 0x27b60
cmpq %r15, %rax
je 0x2407c
cmpl $-0x1, 0xe8(%r13)
je 0x24053
leaq 0x258d6(%rip), %rdi     # 0x49908
movl 0x14(%rsp), %ebp
callq 0x198ee
leaq 0x50(%rsp), %r15
cmpl 0xe8(%r13), %eax
jge 0x24061
movl %ebp, %eax
jmp 0x2404f
xorl %eax, %eax
xorl %ebp, %ebp
jmp 0x24085
movb $0x1, %bpl
leaq 0x50(%rsp), %r15
movl 0x14(%rsp), %eax
jmp 0x24085
leaq 0x258a0(%rip), %rdi     # 0x49908
callq 0x198ee
cmpl 0xec(%r13), %eax
movl %ebp, %eax
setle %bpl
jmp 0x24085
movb $0x1, %al
xorl %ebp, %ebp
leaq 0x50(%rsp), %r15
testb %al, %al
je 0x240ae
movq 0xa0(%rsp), %rdi
leaq 0xb0(%rsp), %rax
cmpq %rax, %rdi
je 0x240ae
movq 0xb0(%rsp), %rsi
incq %rsi
callq 0x7390
movsd (%rsp), %xmm0
ucomisd 0x10f65(%rip), %xmm0    # 0x35020
jbe 0x240d4
movq 0x40(%rsp), %rdi
cmpq %r15, %rdi
je 0x240d4
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x7390
testb %bpl, %bpl
je 0x24204
movsd 0x78(%r13), %xmm0
ucomisd 0x10f35(%rip), %xmm0    # 0x35020
jne 0x240f3
jnp 0x24204
leaq 0x25996(%rip), %rax     # 0x49a90
movq (%rax), %rax
movq (%rax), %rdi
movq (%rdi), %rax
movsd %xmm0, (%rsp)
callq *(%rax)
movsd (%rsp), %xmm1
ucomisd %xmm0, %xmm1
jb 0x24204
movq 0x78(%rsp), %rcx
movq (%rcx), %rax
movq 0x8(%rcx), %rdx
subq %rax, %rdx
sarq $0x4, %rdx
cmpq %r12, %rdx
jbe 0x24288
movsd (%rax,%rbx), %xmm0
movsd %xmm0, (%rsp)
movq 0x90(%r13), %rbp
leaq 0x90(%rsp), %rax
movq %rax, 0x80(%rsp)
leaq 0x80(%rsp), %r14
movq %r14, %rdi
leaq 0x12dfa(%rip), %rsi     # 0x36f62
leaq 0x12dfa(%rip), %rdx     # 0x36f69
callq 0xa886
addq $0x68, %rbp
movq %rbp, %rdi
movq %r14, %rsi
callq 0x1b39a
movsd (%rsp), %xmm0
movsd %xmm0, (%rax)
movq 0x80(%rsp), %rdi
leaq 0x90(%rsp), %rax
cmpq %rax, %rdi
je 0x241b1
movq 0x90(%rsp), %rsi
incq %rsi
callq 0x7390
movq 0x90(%r13), %rdi
callq 0x9836
movsd 0x88(%r13), %xmm1
ucomisd %xmm1, %xmm0
ja 0x241e3
movsd 0x80(%r13), %xmm2
ucomisd %xmm0, %xmm2
movapd %xmm0, %xmm1
jbe 0x241e3
movapd %xmm2, %xmm1
movq 0x78(%rsp), %rcx
movq (%rcx), %rax
movq 0x8(%rcx), %rdx
subq %rax, %rdx
sarq $0x4, %rdx
cmpq %r12, %rdx
jbe 0x24288
movsd %xmm1, (%rax,%rbx)
incq %r12
movq %r13, %rdi
callq 0x7270
movq %rax, %r13
movq 0x18(%rsp), %rax
movq (%rax), %r9
movq 0x8(%rax), %rdx
subq %r9, %rdx
sarq $0x4, %rdx
movabsq $-0x5555555555555555, %rcx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rcx, %rdx
addq $0x10, %rbx
cmpq 0x20(%rsp), %rdx
ja 0x23f85
jmp 0x24275
movq 0x20(%rsp), %rsi
incq %rsi
movq 0x28(%rsp), %rax
movslq 0x44(%rax), %rax
cmpq %rax, %rsi
movq 0x18(%rsp), %rax
jl 0x23ef5
addq $0x178, %rsp            # imm = 0x178
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x129a5(%rip), %rdi     # 0x36c21
movq 0x20(%rsp), %rsi
xorl %eax, %eax
callq 0x7530
leaq 0x12992(%rip), %rdi     # 0x36c21
movq %r12, %rsi
jmp 0x24281
leaq 0x12986(%rip), %rdi     # 0x36c21
jmp 0x24281
leaq 0x1297d(%rip), %rdi     # 0x36c21
movq %r13, %rsi
jmp 0x24281
movq %rax, %rbx
jmp 0x24394
jmp 0x242b3
movq %rax, %rbx
jmp 0x24377
movq %rax, %rbx
movq 0x80(%rsp), %rdi
leaq 0x90(%rsp), %rax
cmpq %rax, %rdi
je 0x243ab
movq 0x90(%rsp), %rsi
jmp 0x2434a
jmp 0x24333
movq %rax, %rbx
movb $0x1, %bpl
jmp 0x242ff
movq %rax, %rbx
movb $0x1, %bpl
leaq 0x50(%rsp), %r15
jmp 0x2432e
jmp 0x24357
jmp 0x24357
movq %rax, %rbx
leaq 0x50(%rsp), %r15
testb %bpl, %bpl
je 0x2432e
movq 0xa0(%rsp), %rdi
leaq 0xb0(%rsp), %rax
cmpq %rax, %rdi
je 0x2432e
movq 0xb0(%rsp), %rsi
incq %rsi
callq 0x7390
testb %bpl, %bpl
jmp 0x2433b
movq %rax, %rbx
jmp 0x243ab
movq %rax, %rbx
movq 0x40(%rsp), %rdi
cmpq %r15, %rdi
je 0x243ab
movq 0x50(%rsp), %rsi
incq %rsi
jmp 0x243a6
jmp 0x24357
jmp 0x24357
jmp 0x24357
jmp 0x24357
movq %rax, %rbx
movq 0x80(%rsp), %rdi
testq %rdi, %rdi
je 0x24377
movq 0x90(%rsp), %rsi
subq %rdi, %rsi
callq 0x7390
movq 0xa0(%rsp), %rdi
testq %rdi, %rdi
je 0x24394
movq 0xb0(%rsp), %rsi
subq %rdi, %rsi
callq 0x7390
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x243ab
movq 0x50(%rsp), %rsi
subq %rdi, %rsi
callq 0x7390
movq %rbx, %rdi
callq 0x76a0
nop