// File: /workspace/github_cpp_makefile_star2_O2/melop[P]admixem/makemarkerfile.cpp
// Function: UIGenerateRecombinationFreqMap(int, double, double*, double*)
void UIGenerateRecombinationFreqMap(int nChromosomes, double nLargestChromSize, double * pChromosomeSizes, double * pCentromerePos) { //UI generating recombination map
		
		//double nLogMaxAvgRecombRate; // Log(Max(recombination rate));
		char nRate; //1 - uniform, 2 - parabola
		double nTotalExpectedRecombPerMeiosis; // The total expected recombination events per meiosis in the whole genome
		double nParabolaA; // shape of male parabola
		double nParabolaAFemale; //shape of female parabola
		//double nFemCorrA ; // linear function to correct for female rates: y=ax + b; negative values make rates higher near centromere and lower at telomere and vice versa
		//double nFemCorrB ; // This should be larger than one b/c females have higher recombination rate in general. usually 3 
		double nFemFold; //Fold factor compared to max
		double nTotalSamplePoint; //How often to put a point. 
		double nSumLens = fnSum(pChromosomeSizes , nChromosomes); // get sum of chromosome lengths
		
		while(true) { //  Get std. dev of the more abundant allele in pop 2
		
			//std::cout << "\nThe logarithm of the max average recombination rate at the telomere of the longest chromosome per chromosome length unit per gamete (< 0) : ";
			
			std::cout << "\nThe total expected recombination event in the whole genome per meiosis (>= 0), set this to be 4n should be fine : ";
			std::cin >> nTotalExpectedRecombPerMeiosis;
			
			if (nTotalExpectedRecombPerMeiosis < 0 ) {
				std::cout << "Input out of bound, retry." <<endl;
				continue; // 
			}
			
			break;
		}
		/*
		while(true) { //  Get std. dev of the more abundant allele in pop 2
		
			std::cout << "\nDistribution of recombination frequencies 1 - Uniform, 2 - Parabola ... ";
			std::cin >> nRate;
			
			if (nRate < '1' || nRate > '2' ) {
				std::cout << "Input out of bound, retry." <<endl;
				continue; // 
			}
			
			break;
		}
		*/
		nRate = '1';
		
		if (nRate == '2') { 
				while(true) { //  Get std. dev of the more abundant allele in pop 2
		
					std::cout << "\nShape of the male parabola (0, 5] : ";
					std::cin >> nParabolaA;
			
					if (nParabolaA <= 0 || nParabolaA > 5 ) {
						std::cout << "Input out of bound, retry." <<endl;
						continue; // 
					}
			
					break;
				}
		
	
				while(true) { //  Get std. dev of the more abundant allele in pop 2
		
					std::cout << "\nShape of the female parabola (0, 5] : ";
					std::cin >> nParabolaAFemale;
			
					if (nParabolaAFemale <= 0 || nParabolaAFemale > 5 ) {
						std::cout << "Input out of bound, retry." <<endl;
						continue; // 
					}
			
					break;
				}
		}
		
		if (nRate == '1') { // if uniform, just put two since users can specify Use UseUniformRec = yes
			std::cout << "===========================================" <<endl;
			std::cout  <<endl;
			std::cout << "By default Admixem uses the uniform rate" <<endl;
			std::cout << "In addition to files generated here," <<endl;
			std::cout << "Please make sure you ADD THE FOLLOWING OPTION" <<endl;
			std::cout << "in your MAIN CONFIGURATION file:" <<endl;
			std::cout << endl << "        UseUniformRec  =  yes" <<endl;
			std::cout  <<endl;
			std::cout  <<"In case you really want to use the candidate ";
			std::cout  <<"break point approach, refer to the manual. ";
			std::cout << "===========================================" <<endl;

			nTotalSamplePoint = 20 * nChromosomes;
		}
		else {
			while(true) { //  Get std. dev of the more abundant allele in pop 2
		
				std::cout << "\nHow many sample points to put in total?: ";
				std::cin >> nTotalSamplePoint;
			
				if (nTotalSamplePoint <= 0  ) {
					std::cout << "Input out of bound, retry." <<endl;
					continue; // 
				}
			
				break;
			}
		}
		
		while(true) { //  Get std. dev of the more abundant allele in pop 2
		
			std::cout << "\nFold difference between female:male [0.1,10]: ";
			std::cin >> nFemFold;
			
			if (nFemFold < 0.1 || nFemFold > 10 ) {
				std::cout << "Input out of bound, retry." <<endl;
				continue; // 
			}
			
			break;
		}
		
		/*
		while(true) { //  Get std. dev of the more abundant allele in pop 2
		
			std::cout << "\n A linear model y=a*prob(male)+b will be used to generate the female recomb. rate from the male rates. "<<endl;
			std::cout << "A -b < a < 10:"<<endl;
			std::cin >> nFemCorrA;
			std::cout << "B [1,10]:"<<endl;
			std::cin >> nFemCorrB;
			

			
			if (nFemCorrB < 1 || nFemCorrB > 10 ) {
				std::cout << "Parameter B out of bound, retry." <<endl;
				continue; // 
			}
			
				if (nFemCorrA < -nFemCorrB || nFemCorrA > 10 ) {
				std::cout << "Parameter A out of bound, retry." <<endl;
				continue; // 
			}
			
			break;
		}
		*/
		
		
	cout << "Output File name : ";
	string sOutFile;
		
		while(true) { //  Get std. dev of the more abundant allele in pop 2
		
			
		
			
			getline(cin, sOutFile) ;
			
			
			if (sOutFile.size() > 3 ) {
				break;
			}
			
			
			continue;
		}
		
		
		// now prepare file:
		//Figure out how to distribute the markers
		
		ofstream fOutFile;
		fOutFile.open(sOutFile.c_str());
		
		
		for (int i=0;i< nChromosomes;i++) {
			

			
			int nChrIndex =i;
			double nChrLen = pChromosomeSizes[nChrIndex];
			double nCentromerePos =  pCentromerePos[nChrIndex];	
			//double nMaxAvgRecombRate = pow(10, nLogMaxAvgRecombRate);	
			//nLongestArmExpectedRecombPerMeiosis
			
			int	   nNumSamplePoints = (int) ceil( ((double) nTotalSamplePoint) * (nChrLen / nSumLens));

			double nArm1Len =  nCentromerePos;
			double nArm2Len =  nChrLen - nCentromerePos;
				
			fOutFile << ":chr " << (nChrIndex+1) << endl;
			
			double nExpectedMaleRecPerMeiosisArm1 = nTotalExpectedRecombPerMeiosis * ( nArm1Len/nSumLens) / 2;
			double nExpectedMaleRecPerMeiosisArm2 = nTotalExpectedRecombPerMeiosis * ( nArm2Len/nSumLens) / 2;
			double nExpectedFemaleRecPerMeiosisArm1 = nTotalExpectedRecombPerMeiosis * nFemFold * ( nArm1Len/nSumLens) / 2;
			double nExpectedFemaleRecPerMeiosisArm2 = nTotalExpectedRecombPerMeiosis * nFemFold * ( nArm2Len/nSumLens) / 2;
			double nExpectedRecPerMeiosisArm1 = ( nExpectedMaleRecPerMeiosisArm1 + nExpectedFemaleRecPerMeiosisArm1 ) / 2;
			double nExpectedRecPerMeiosisArm2 = ( nExpectedMaleRecPerMeiosisArm2 + nExpectedFemaleRecPerMeiosisArm2 ) / 2;
			
			//fOutFile << "\tmale"<<"\tmale_accumulative\tmale*max\tmale*max_accumulative" << "\tfemale\tfemale_accumulative\tfemale*max\tfemale*max_accumulative" << endl;
			fOutFile << ":ExpectedMaleRecPerMeiosisArm1 = " << nExpectedMaleRecPerMeiosisArm1 << endl;
			fOutFile << ":ExpectedMaleRecPerMeiosisArm2 = " << nExpectedMaleRecPerMeiosisArm2 << endl;
			fOutFile << ":ExpectedFemaleRecPerMeiosisArm1 = " << nExpectedFemaleRecPerMeiosisArm1 << endl;
			fOutFile << ":ExpectedFemaleRecPerMeiosisArm2 = " << nExpectedFemaleRecPerMeiosisArm2 << endl;
			fOutFile << "\tmale"<<"\tmale_accumulative" << "\tfemale\tfemale_accumulative\tMale_recombination_fraction\tFemale_recombination_fraction\tAvg_recombination_fraction\tKosambi_male_interval\tKosambi_male_pos\tKosambi_female_interval\tKosambi_female_pos\tKosambi_both_interval\tKosambi_both_pos" << endl;
		
			std::map<double, double *>  mSamplePoints;

			
			for (int j=0; j < nNumSamplePoints; j++) {
			
				double nPos = nChrLen * UniformGen.Next(); // random position
				
				double nDistanceFromCentromere = ( nPos - nCentromerePos ) / nLargestChromSize; //  distance from centromere standarized by the longest chromosome
				nDistanceFromCentromere = (nDistanceFromCentromere >= 0 )? nDistanceFromCentromere: -nDistanceFromCentromere;
				
				double nArmLen = (nPos > nCentromerePos)? nChrLen - nCentromerePos : nCentromerePos;
				double nDistanceFromCentromereOnArm = (nPos > nCentromerePos)? (nPos - nCentromerePos)/nArmLen : (nCentromerePos - nPos)/nArmLen ;
				
				double nProbAtPosMale =  (nRate=='1')? 0.1 : pow(nParabolaA * nDistanceFromCentromere, 2);
				//double nProbAtPosFemale = nProbAtPosMale * nFemCorrA  + nFemCorrB;
				
				double nProbAtPosFemale = (nRate=='1')? 0.1 * nFemFold : pow(nParabolaAFemale * nDistanceFromCentromere, 2) * nFemFold ; 
				
				double * pProbs = new double[4];
				
				pProbs[0] = NormalExt(nProbAtPosMale , nProbAtPosMale / 2, 0, 1);
				//pProbs[1] = nMaxAvgRecombRate * pProbs[0] ;
				pProbs[2] = NormalExt(nProbAtPosFemale , nProbAtPosFemale / 2, 0, 1);
				//pProbs[3] = nMaxAvgRecombRate * pProbs[2] ;
				
				if (mSamplePoints.find(nPos) == mSamplePoints.end()) {
					mSamplePoints[nPos] = pProbs ;
				}
				else {
					j--;
					continue; // won't work because same position already exists.
				}
				
			}
			
			double nMaleArm1Accum = 0;
			double nFemaleArm1Accum = 0;
			double nMaleArm2Accum = 0;
			double nFemaleArm2Accum = 0;


			
			for (std::map<double,double *>::iterator it = mSamplePoints.begin(); it != mSamplePoints.end(); ++it) {
			
				double nMaleAccum, nFemaleAccum;
				if (it->first < nCentromerePos) { //on arm 1
					/*
					nMaleAccum = nMaleArm1Accum += (it->second)[0];
					nFemaleAccum = nFemaleArm1Accum += (it->second)[2];
					*/
					nMaleArm1Accum += (it->second)[0];
					nFemaleArm1Accum += (it->second)[2];
				}
				else {
					/*
					nMaleAccum = nMaleArm2Accum += (it->second)[0];
					nFemaleAccum = nFemaleArm2Accum += (it->second)[2];
					*/
					 nMaleArm2Accum += (it->second)[0];
					 nFemaleArm2Accum += (it->second)[2];
				}
				
				//fOutFile << setprecision (10) << it->first << '\t' << (it->second)[0] << '\t' << nMaleAccum << '\t' << (it->second)[1] << '\t' << nMaleAccum * nMaxAvgRecombRate  << '\t' << (it->second)[2] << '\t' << nFemaleAccum << '\t' << (it->second)[3] << '\t' << nFemaleAccum * nMaxAvgRecombRate << endl;
			}


			double nScaledMaleArm1Accum = 0;
			double nScaledFemaleArm1Accum = 0;
			double nScaledMaleArm2Accum = 0;
			double nScaledFemaleArm2Accum = 0;

			double nScaledMaleProb = 0;
			double nScaledFemaleProb = 0;
			
			double nPrevScaledMaleArm1Accum =0;
			double nPrevScaledFemaleArm1Accum =0;
			double nPrevScaledMaleArm2Accum =0;
			double nPrevScaledFemaleArm2Accum =0;
			
			double nKosambiMapDistance_male = 0;
			double nKosambiMapDistance_female = 0;
			double nKosambiMapDistance_both = 0;			
			
			double nKosambiMapPos_male = 0;
			double nKosambiMapPos_female = 0;
			double nKosambiMapPos_both = 0;
			
			double nRecombFraction_male = 0;
			double nRecombFraction_female = 0;
			double nRecombFraction_both = 0;
			
	
			for (std::map<double,double *>::iterator it = mSamplePoints.begin(); it != mSamplePoints.end(); ++it) {
			
				double nMaleAccum, nFemaleAccum;
				if (it->first < nCentromerePos) { //on arm 1
					nScaledMaleProb = (it->second)[0] / nMaleArm1Accum;
					nScaledFemaleProb = (it->second)[2] / nFemaleArm1Accum;
					nMaleAccum = nScaledMaleArm1Accum += nScaledMaleProb;
					nFemaleAccum = nScaledFemaleArm1Accum += nScaledFemaleProb;
					
					 nRecombFraction_male = nExpectedMaleRecPerMeiosisArm1 * nScaledMaleProb  ;
					 nKosambiMapPos_male += nKosambiMapDistance_male = 0.25 * log( (1+2 * nRecombFraction_male)/(1-2 * nRecombFraction_male) ) ;
					 nRecombFraction_female = nExpectedFemaleRecPerMeiosisArm1 * nScaledFemaleProb ;
					 nKosambiMapPos_female += nKosambiMapDistance_female = 0.25 * log( (1+2 * nRecombFraction_female)/(1-2 * nRecombFraction_female) ) ;
		
					
					
				}
				else {
					nScaledMaleProb = (it->second)[0] / nMaleArm2Accum;
					nScaledFemaleProb = (it->second)[2] / nFemaleArm2Accum;
					nMaleAccum = nScaledMaleArm2Accum += nScaledMaleProb;
					nFemaleAccum = nScaledFemaleArm2Accum += nScaledFemaleProb;
					
					nRecombFraction_male = nExpectedMaleRecPerMeiosisArm2 * nScaledMaleProb  ;
					 nKosambiMapPos_male += nKosambiMapDistance_male = 0.25 * log( (1+2 * nRecombFraction_male)/(1-2 * nRecombFraction_male) ) ;
					 nRecombFraction_female = nExpectedFemaleRecPerMeiosisArm2 * nScaledFemaleProb  ;
					 nKosambiMapPos_female += nKosambiMapDistance_female = 0.25 * log( (1+2 * nRecombFraction_female)/(1-2 * nRecombFraction_female) ) ;
					 
					
				}
				
				nRecombFraction_both = (nRecombFraction_male + nRecombFraction_female)/2;
				nKosambiMapPos_both += nKosambiMapDistance_both = 0.25 * log( (1+2 * nRecombFraction_both)/(1-2 * nRecombFraction_both) ) ;
					 

				
				fOutFile << setprecision (10) << it->first << '\t' << nScaledMaleProb << '\t' << nMaleAccum << '\t' << nScaledFemaleProb << '\t' << nFemaleAccum;
				fOutFile << setprecision (10) << '\t' << nRecombFraction_male << '\t' << nRecombFraction_female << '\t' << nRecombFraction_both << '\t' << nKosambiMapDistance_male << '\t' << nKosambiMapPos_male << '\t' << nKosambiMapDistance_female << '\t' << nKosambiMapPos_female << '\t' << nKosambiMapDistance_both << '\t' << nKosambiMapPos_both << endl;
			
				double nPrevScaledMaleArm1Accum = nScaledMaleArm1Accum;
				double nPrevScaledFemaleArm1Accum = nScaledFemaleArm1Accum;
				double nPrevScaledMaleArm2Accum = nScaledMaleArm2Accum;
				double nPrevScaledFemaleArm2Accum = nScaledFemaleArm2Accum;
				
			
			}
		
		
		
		}
		
		fOutFile.close();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x388, %rsp            # imm = 0x388
movq %rdx, 0xe0(%rsp)
movl %edi, %eax
movq %rsi, 0xd8(%rsp)
movq %rsi, %rdi
movq %rax, 0x10(%rsp)
movl %eax, %esi
callq 0x25c06
movsd %xmm0, 0x30(%rsp)
movq 0x2012c(%rip), %rbx     # 0x44f90
leaq 0xa659(%rip), %r14      # 0x2f4c4
movq 0x2015e(%rip), %r15     # 0x44fd0
leaq 0x78(%rsp), %r12
leaq 0xa6ba(%rip), %r13      # 0x2f538
movq %rbx, %rdi
movq %r14, %rsi
callq 0x73d0
movq %r15, %rdi
movq %r12, %rsi
callq 0x7280
xorpd %xmm0, %xmm0
ucomisd 0x78(%rsp), %xmm0
jbe 0x24eb5
movq %rbx, %rdi
movq %r13, %rsi
callq 0x73d0
movq %rax, %rdi
callq 0x71c0
jmp 0x24e7e
movq 0x200d4(%rip), %rbx     # 0x44f90
leaq 0xa690(%rip), %r14      # 0x2f553
movq %rbx, %rdi
movq %r14, %rsi
callq 0x73d0
movq %rax, %rdi
callq 0x71c0
movq %rbx, %rdi
callq 0x71c0
leaq 0xa69a(%rip), %rsi      # 0x2f57f
movq %rbx, %rdi
callq 0x73d0
movq %rax, %rdi
callq 0x71c0
leaq 0xa6ac(%rip), %rsi      # 0x2f5a8
movq %rbx, %rdi
callq 0x73d0
movq %rax, %rdi
callq 0x71c0
leaq 0xa6ba(%rip), %rsi      # 0x2f5cd
movq %rbx, %rdi
callq 0x73d0
movq %rax, %rdi
callq 0x71c0
leaq 0xa6d1(%rip), %rsi      # 0x2f5fb
movq %rbx, %rdi
callq 0x73d0
movq %rax, %rdi
callq 0x71c0
movq %rbx, %rdi
callq 0x71c0
leaq 0xa6d3(%rip), %rsi      # 0x2f61c
movq %rax, %rdi
callq 0x73d0
movq %rax, %rdi
callq 0x71c0
movq %rbx, %rdi
callq 0x71c0
leaq 0xa6d2(%rip), %rsi      # 0x2f63a
movq %rbx, %rdi
callq 0x73d0
leaq 0xa6f1(%rip), %rsi      # 0x2f668
movq %rbx, %rdi
callq 0x73d0
movq %rbx, %rdi
movq %r14, %rsi
callq 0x73d0
movq %rax, %rdi
callq 0x71c0
imull $0x14, 0x10(%rsp), %ebp
leaq 0xa6f6(%rip), %r14      # 0x2f694
movq 0x2002b(%rip), %r15     # 0x44fd0
leaq 0x38(%rsp), %r12
leaq 0xa587(%rip), %r13      # 0x2f538
movq %rbx, %rdi
movq %r14, %rsi
callq 0x73d0
movq %r15, %rdi
movq %r12, %rsi
callq 0x7280
movsd 0x38(%rsp), %xmm0
movsd 0xa013(%rip), %xmm1     # 0x2efe8
ucomisd %xmm0, %xmm1
ja 0x24fe5
ucomisd 0x84bd(%rip), %xmm0     # 0x2d4a0
jbe 0x24ffa
movq %rbx, %rdi
movq %r13, %rsi
callq 0x73d0
movq %rax, %rdi
callq 0x71c0
jmp 0x24fb1
cvtsi2sd %ebp, %xmm0
movsd %xmm0, 0xd0(%rsp)
movq 0x1ff82(%rip), %rdi     # 0x44f90
leaq 0xa352(%rip), %rsi      # 0x2f367
callq 0x73d0
leaq 0x160(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movq 0x1ff9b(%rip), %rbx     # 0x44fd0
leaq 0x150(%rsp), %r14
movq %rbx, %rdi
movq %r14, %rsi
callq 0x70b0
cmpq $0x3, 0x158(%rsp)
jbe 0x2503d
leaq 0x188(%rsp), %rdi
callq 0x7690
movq 0x150(%rsp), %rsi
leaq 0x188(%rsp), %rdi
pushq $0x10
popq %rdx
callq 0x7060
leaq 0xf8(%rsp), %rbx
xorl %ecx, %ecx
movq 0x10(%rsp), %rax
testl %eax, %eax
cmovlel %ecx, %eax
movq %rax, 0x10(%rsp)
leaq 0x188(%rsp), %rbp
pushq $0x9
popq %r12
cmpq 0x10(%rsp), %rcx
je 0x25784
movq 0xd8(%rsp), %rax
movsd (%rax,%rcx,8), %xmm1
movq 0xe0(%rsp), %rax
movq %rcx, %r14
movsd (%rax,%rcx,8), %xmm0
movsd %xmm0, 0x18(%rsp)
movsd %xmm1, 0x20(%rsp)
movapd %xmm1, %xmm0
divsd 0x30(%rsp), %xmm0
mulsd 0xd0(%rsp), %xmm0
callq 0x7760
movsd %xmm0, 0x40(%rsp)
movq %rbp, %rdi
leaq 0xa306(%rip), %rsi      # 0x2f3ff
callq 0x73d0
movq %r14, %rsi
incq %rsi
movq %rax, %rdi
movq %rsi, 0xe8(%rsp)
callq 0x76b0
movq %rax, %rdi
callq 0x71c0
movsd 0x78(%rsp), %xmm0
movsd 0x38(%rsp), %xmm1
movapd %xmm0, (%rsp)
mulsd %xmm0, %xmm1
movapd %xmm1, 0x50(%rsp)
movq %rbp, %rdi
leaq 0xa583(%rip), %rsi      # 0x2f6c4
callq 0x73d0
movsd 0x18(%rsp), %xmm0
divsd 0x30(%rsp), %xmm0
unpcklpd %xmm0, %xmm0            # xmm0 = xmm0[0,0]
movapd (%rsp), %xmm1
unpcklpd 0x50(%rsp), %xmm1       # xmm1 = xmm1[0],mem[0]
movapd %xmm1, (%rsp)
mulpd %xmm1, %xmm0
mulpd 0x9e8e(%rip), %xmm0     # 0x2f000
movq %rax, %rdi
movapd %xmm0, 0x130(%rsp)
callq 0x7620
movq %rax, %rdi
callq 0x71c0
movq %rbp, %rdi
leaq 0xa551(%rip), %rsi      # 0x2f6e6
callq 0x73d0
movsd 0x20(%rsp), %xmm0
subsd 0x18(%rsp), %xmm0
divsd 0x30(%rsp), %xmm0
unpcklpd %xmm0, %xmm0            # xmm0 = xmm0[0,0]
mulpd (%rsp), %xmm0
mulpd 0x9e43(%rip), %xmm0     # 0x2f000
movq %rax, %rdi
movapd %xmm0, 0x120(%rsp)
callq 0x7620
movq %rax, %rdi
callq 0x71c0
movq %rbp, %rdi
leaq 0xa528(%rip), %rsi      # 0x2f708
callq 0x73d0
movapd 0x130(%rsp), %xmm0
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
movq %rax, %rdi
callq 0x7620
movq %rax, %rdi
callq 0x71c0
movq %rbp, %rdi
leaq 0xa520(%rip), %rsi      # 0x2f72c
callq 0x73d0
movapd 0x120(%rsp), %xmm0
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
movq %rax, %rdi
callq 0x7620
movq %rax, %rdi
callq 0x71c0
movq %rbp, %rdi
leaq 0xa518(%rip), %rsi      # 0x2f750
callq 0x73d0
movq %rax, %rdi
leaq 0xa50f(%rip), %rsi      # 0x2f756
callq 0x73d0
movq %rax, %rdi
leaq 0xa513(%rip), %rsi      # 0x2f769
callq 0x73d0
movq %rax, %rdi
callq 0x71c0
andl $0x0, 0xf8(%rsp)
andq $0x0, 0x100(%rsp)
cvttsd2si 0x40(%rsp), %r15d
movq %rbx, 0x108(%rsp)
movq %rbx, 0x110(%rsp)
andq $0x0, 0x118(%rsp)
xorl %r14d, %r14d
cmpl %r15d, %r14d
jge 0x2535d
leaq 0x207c9(%rip), %rdi     # 0x45a70
callq 0xb2e2
mulsd 0x20(%rsp), %xmm0
movsd %xmm0, 0x70(%rsp)
movsd 0x38(%rsp), %xmm0
mulsd 0x9d22(%rip), %xmm0     # 0x2efe8
movsd %xmm0, (%rsp)
pushq $0x20
popq %rdi
callq 0x7030
movq %rax, %r13
xorpd %xmm2, %xmm2
movsd 0x9d06(%rip), %xmm0     # 0x2efe8
movsd 0x9d0e(%rip), %xmm1     # 0x2eff8
movsd 0x7d1e(%rip), %xmm3     # 0x2d010
callq 0x25ba4
movsd %xmm0, (%r13)
movsd (%rsp), %xmm0
movapd %xmm0, %xmm1
mulsd 0x80ea(%rip), %xmm1     # 0x2d3f8
xorpd %xmm2, %xmm2
movsd 0x7cf6(%rip), %xmm3     # 0x2d010
callq 0x25ba4
movsd %xmm0, 0x10(%r13)
leaq 0xf0(%rsp), %rdi
leaq 0x70(%rsp), %rsi
callq 0x258b0
cmpq %rbx, %rax
jne 0x25297
leaq 0xf0(%rsp), %rdi
leaq 0x70(%rsp), %rsi
callq 0x25806
movq %r13, (%rax)
incl %r14d
jmp 0x25297
xorpd %xmm0, %xmm0
movapd %xmm0, 0xb0(%rsp)
movq 0x108(%rsp), %r13
movq %r13, %rax
movapd %xmm0, 0xa0(%rsp)
cmpq %rbx, %rax
je 0x253d5
movsd 0x18(%rsp), %xmm0
ucomisd 0x20(%rax), %xmm0
movq 0x28(%rax), %rcx
movsd (%rcx), %xmm0
movhpd 0x10(%rcx), %xmm0       # xmm0 = xmm0[0],mem[0]
ja 0x253b5
movapd 0xa0(%rsp), %xmm1
addpd %xmm0, %xmm1
movapd %xmm1, 0xa0(%rsp)
jmp 0x253cb
movapd 0xb0(%rsp), %xmm1
addpd %xmm0, %xmm1
movapd %xmm1, 0xb0(%rsp)
movq %rax, %rdi
callq 0x72d0
jmp 0x2537e
xorpd %xmm0, %xmm0
movapd %xmm0, 0x90(%rsp)
xorpd %xmm0, %xmm0
movsd %xmm0, 0x60(%rsp)
xorpd %xmm0, %xmm0
movapd %xmm0, 0x80(%rsp)
movapd %xmm0, 0x50(%rsp)
cmpq %rbx, %r13
je 0x2576a
movsd 0x18(%rsp), %xmm0
ucomisd 0x20(%r13), %xmm0
movq 0x28(%r13), %rax
movsd (%rax), %xmm1
movsd 0x10(%rax), %xmm0
unpcklpd %xmm0, %xmm1            # xmm1 = xmm1[0],xmm0[0]
jbe 0x25493
divpd 0xb0(%rsp), %xmm1
movapd 0x90(%rsp), %xmm0
addpd %xmm1, %xmm0
movapd %xmm0, 0x90(%rsp)
movapd 0x130(%rsp), %xmm0
movapd %xmm1, 0x40(%rsp)
mulpd %xmm1, %xmm0
movapd %xmm0, 0x20(%rsp)
unpcklpd %xmm0, %xmm0            # xmm0 = xmm0[0,0]
mulpd 0x9ba5(%rip), %xmm0     # 0x2f010
addpd 0x9bad(%rip), %xmm0     # 0x2f020
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
divsd %xmm1, %xmm0
callq 0x7780
movapd %xmm0, (%rsp)
movaps 0x90(%rsp), %xmm0
jmp 0x254fd
divpd 0xa0(%rsp), %xmm1
movapd 0x80(%rsp), %xmm0
addpd %xmm1, %xmm0
movapd %xmm0, 0x80(%rsp)
movapd 0x120(%rsp), %xmm0
movapd %xmm1, 0x40(%rsp)
mulpd %xmm1, %xmm0
movapd %xmm0, 0x20(%rsp)
unpcklpd %xmm0, %xmm0            # xmm0 = xmm0[0,0]
mulpd 0x9b39(%rip), %xmm0     # 0x2f010
addpd 0x9b41(%rip), %xmm0     # 0x2f020
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
divsd %xmm1, %xmm0
callq 0x7780
movapd %xmm0, (%rsp)
movaps 0x80(%rsp), %xmm0
movaps %xmm0, 0xc0(%rsp)
movapd 0x20(%rsp), %xmm0
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
movapd %xmm0, 0x140(%rsp)
addsd %xmm0, %xmm0
movsd 0x7aec(%rip), %xmm2     # 0x2d010
movapd %xmm2, %xmm1
subsd %xmm0, %xmm1
addsd %xmm2, %xmm0
divsd %xmm1, %xmm0
callq 0x7780
movapd (%rsp), %xmm1
unpcklpd %xmm0, %xmm1            # xmm1 = xmm1[0],xmm0[0]
mulpd 0x9ae6(%rip), %xmm1     # 0x2f030
movapd %xmm1, (%rsp)
movapd 0x20(%rsp), %xmm0
addsd 0x140(%rsp), %xmm0
mulsd 0x7e92(%rip), %xmm0     # 0x2d3f8
movapd %xmm0, 0x170(%rsp)
addsd %xmm0, %xmm0
movsd 0x7a95(%rip), %xmm2     # 0x2d010
movapd %xmm2, %xmm1
subsd %xmm0, %xmm1
addsd %xmm2, %xmm0
divsd %xmm1, %xmm0
callq 0x7780
mulsd 0x9a58(%rip), %xmm0     # 0x2eff0
movsd %xmm0, 0x68(%rsp)
movq 0x188(%rsp), %rax
movq -0x18(%rax), %rax
movq $0xa, 0x190(%rsp,%rax)
movsd 0x20(%r13), %xmm0
movq %rbp, %rdi
callq 0x7620
movq %rax, %rdi
movl %r12d, %esi
callq 0x7490
movq %rax, %rdi
movapd 0x40(%rsp), %xmm0
callq 0x7620
movq %rax, %rdi
movl %r12d, %esi
callq 0x7490
movq %rax, %rdi
movapd 0xc0(%rsp), %xmm0
callq 0x7620
movq %rax, %rdi
movl %r12d, %esi
callq 0x7490
movapd 0x40(%rsp), %xmm0
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
movq %rax, %rdi
callq 0x7620
movq %rax, %rdi
movl %r12d, %esi
callq 0x7490
movapd 0xc0(%rsp), %xmm0
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
movq %rax, %rdi
callq 0x7620
movq 0x188(%rsp), %rax
movq -0x18(%rax), %rax
movq $0xa, 0x190(%rsp,%rax)
movq %rbp, %rdi
movl %r12d, %esi
callq 0x7490
movq %rax, %rdi
movapd 0x20(%rsp), %xmm0
callq 0x7620
movq %rax, %rdi
movl %r12d, %esi
callq 0x7490
movq %rax, %rdi
movapd 0x140(%rsp), %xmm0
callq 0x7620
movq %rax, %rdi
movl %r12d, %esi
callq 0x7490
movq %rax, %rdi
movapd 0x170(%rsp), %xmm0
callq 0x7620
movq %rax, %rdi
movl %r12d, %esi
callq 0x7490
movq %rax, %rdi
movapd (%rsp), %xmm0
callq 0x7620
movq %rax, %rdi
movl %r12d, %esi
callq 0x7490
movapd 0x50(%rsp), %xmm0
addpd (%rsp), %xmm0
movq %rax, %rdi
movapd %xmm0, 0x50(%rsp)
callq 0x7620
movq %rax, %rdi
movl %r12d, %esi
callq 0x7490
movapd (%rsp), %xmm0
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
movq %rax, %rdi
callq 0x7620
movq %rax, %rdi
movl %r12d, %esi
callq 0x7490
movapd 0x50(%rsp), %xmm0
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
movq %rax, %rdi
callq 0x7620
movq %rax, %rdi
movl %r12d, %esi
callq 0x7490
movq %rax, %rdi
movsd 0x68(%rsp), %xmm0
callq 0x7620
movq %rax, %rdi
movl %r12d, %esi
callq 0x7490
movsd 0x60(%rsp), %xmm0
addsd 0x68(%rsp), %xmm0
movq %rax, %rdi
movsd %xmm0, 0x60(%rsp)
callq 0x7620
movq %rax, %rdi
callq 0x71c0
movq %r13, %rdi
callq 0x72d0
movq %rax, %r13
jmp 0x253ff
leaq 0xf0(%rsp), %rdi
callq 0x25858
movq 0xe8(%rsp), %rcx
jmp 0x2509d
leaq 0x188(%rsp), %rdi
callq 0x7560
leaq 0x188(%rsp), %rdi
callq 0x7590
leaq 0x150(%rsp), %rdi
callq 0x71a0
addq $0x388, %rsp            # imm = 0x388
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x257c1
jmp 0x257c8
movq %rax, %rbx
jmp 0x257f0
jmp 0x257c8
movq %rax, %rbx
jmp 0x257e3
jmp 0x257d3
jmp 0x257d3
jmp 0x257d3
movq %rax, %rbx
leaq 0xf0(%rsp), %rdi
callq 0x25858
leaq 0x188(%rsp), %rdi
callq 0x7590
leaq 0x150(%rsp), %rdi
callq 0x71a0
movq %rbx, %rdi
callq 0x76d0
nop