// File: melop[P]admixem/makemarkerfile.cpp
// Function: UIMakeNewMarkerFile()
void UIMakeNewMarkerFile() {

int nCurrChromosome = 1;
int nHaploidChromosomeNum, nTotalMarkers;
string sOutFile = "";
double nChromosomeSize, nCentromerePos, nPop1AvgAlleleFreq, nPop1AvgAlleleFreqStdDev,  nPop2AvgAlleleFreq, nPop2AvgAlleleFreqStdDev;

	//Random::Set(0.42);

		while(true) { //Get random seed from user
		
			std::cout << "\nEnter a random seed (0.0~1.0). Write down this number to repeat simulation: ";
			std::cin >> nRandSeed;
			
			if (nRandSeed > 0 && nRandSeed < 1.0 ) {
				Random::Set(nRandSeed);
				break; // 
			}
			
			
			
		}

			
			/*
		  ofstream myfile;
			myfile.open("testnormal.txt");
			
			for (int i=0;i<=999;i++)
			{
				myfile << NormalExt(0.8, 0.1 , 0.5, 1.0) << "\n"; // draw from normal distribution, mean=0.8, stdev=0.1, >=0.5, <= 1.0
			
			}
			myfile.close();
	*/

	//std::cout << NormalExt(0.8, 0.1) << "\n";

		while(true) { //Get haploid chromosome number from user
		
			std::cout << "\nEnter the number of chromosomes in the haploid genome (n): ";
			std::cin >> nHaploidChromosomeNum;
			
			if (nHaploidChromosomeNum > 0 ) {
				break; // 
			}
			
			
			
		}
		
		pChromosomeSizes = new double[nHaploidChromosomeNum];
		double * pCentromerePos = new double[nHaploidChromosomeNum];
		
		while(true) { // Get sizes of each chromosome from user
		
			std::cout << "\nEnter the size of chromosome " << nCurrChromosome << "(enter a negative number to finish, enter 0 set it to the same number as the previous one): ";
			std::cin >> nChromosomeSize;

			if (nChromosomeSize == 0 && nCurrChromosome == 1) {
				std::cout << "Can't use this option\n";
				continue;
			}

			if (nChromosomeSize == 0) { //set it to the same as the previous one
				pChromosomeSizes[nCurrChromosome-1]  = pChromosomeSizes[nCurrChromosome-2];
				nChromosomeSize = pChromosomeSizes[nCurrChromosome-1];
			}
			
			if (nChromosomeSize < 0 ) {
				break; // 
			}
			
			if (nChromosomeSize > 0) {
				pChromosomeSizes[nCurrChromosome-1] = nChromosomeSize;
			}
			
			/*
			Now do not allow users to move centromere any more since centromere can be simply a marker, and it's forced 
			to the end of the chromosome.

			std::cout << "\nEnter the centromere position of chromosome " << nCurrChromosome << " (in same unit as chromosome size. -1 default: at 50% of chromosome, enter 0 set it to the same as the previous): ";
			std::cin >> nCentromerePos;
			 
			if  (nCentromerePos == -1) {
				pCentromerePos[nCurrChromosome-1] = nChromosomeSize / 2 ;
				
			}
			
			else if (nCentromerePos < 0 || nCentromerePos > nChromosomeSize ) {
				cout << "Centromere position out of bound, enter chromosome info again" << endl ;
				continue;
			}
			
			else if (nCentromerePos == 0 && nCurrChromosome > 1) {
				pCentromerePos[nCurrChromosome-1] =  pCentromerePos[nCurrChromosome-2];
			}
			
			else {
				pCentromerePos[nCurrChromosome-1] =  nCentromerePos;
			}

			*/

			pCentromerePos[nCurrChromosome-1] = nChromosomeSize;
			
			nCurrChromosome++;
			if (nCurrChromosome > nHaploidChromosomeNum ) {
				break;
			}
		}
		
		while(true) { // Get total number of markers
		
			std::cout << "\nHow many markers in total? (this will be distributed to all chromosomes weighted by their lengths): ";
			std::cin >> nTotalMarkers;
			
			if (nTotalMarkers <= 0 ) {
				continue; // 
			}
			
			break;
			
		}
		
		while(true) { // Get average freq of the more abundant allele in pop 1
		
			std::cout << "\nFor parental population 1, what is the average frequency of the more abundant allele [ 0.5~1.0 ] : ";
			std::cin >> nPop1AvgAlleleFreq;
			
			if (nPop1AvgAlleleFreq < 0.5 || nPop1AvgAlleleFreq > 1.0) {
				continue; // 
			}
			
			break;
		}
		
		while(true) { //  Get std. dev of the more abundant allele in pop 1
		
			std::cout << "\nFor parental population 1, what is the standard deviation of the more abundant allele [ 0~0.5 ] : ";
			std::cin >> nPop1AvgAlleleFreqStdDev;
			
			if (nPop1AvgAlleleFreqStdDev < 0 || nPop1AvgAlleleFreqStdDev > 0.5) {
				continue; // 
			}
			
			break;
		}
		
		while(true) { // Get average freq of the more abundant allele in pop 2
		
			std::cout << "\nFor parental population 2, what is the average frequency of the more abundant allele [ 0.5~1.0 ] : ";
			std::cin >> nPop2AvgAlleleFreq;
			
			if (nPop2AvgAlleleFreq < 0.5 || nPop2AvgAlleleFreq > 1.0) {
				continue; // 
			}
			
			break;
		}
		
		while(true) { //  Get std. dev of the more abundant allele in pop 2
		
			std::cout << "\nFor parental population 2, what is the standard deviation of the frequency of the more abundant allele [ 0~0.5 ] : ";
			std::cin >> nPop2AvgAlleleFreqStdDev;
			
			if (nPop2AvgAlleleFreqStdDev < 0 || nPop2AvgAlleleFreqStdDev > 0.5) {
				continue; // 
			}
			
			break;
		}
		
		cout << "Output File name : ";
		
		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());
		fOutFile << "HaploidChromosomeNum = " << nHaploidChromosomeNum << endl; //Write haploid n.
		fOutFile << "RandomSeed = " << nRandSeed << endl; //Write random seed n.
		fOutFile << "Pop1AvgAlleleFreq = " << nPop1AvgAlleleFreq << endl; //
		fOutFile << "Pop1AvgAlleleFreqStdev = " << nPop1AvgAlleleFreqStdDev << endl; //
		fOutFile << "Pop2AvgAlleleFreq = " << nPop2AvgAlleleFreq << endl; //
		fOutFile << "Pop2AvgAlleleFreqStdev = " << nPop2AvgAlleleFreqStdDev << endl; //
			/*	
			for (int i=0;i<=999;i++)
			{
				myfile << NormalExt(0.8, 0.1 , 0.5, 1.0) << "\n"; // draw from normal distribution, mean=0.8, stdev=0.1, >=0.5, <= 1.0
			
			}
			*/
			
			
		
		double nSumLens = fnSum(pChromosomeSizes , nHaploidChromosomeNum); // get sum of chromosome lengths
		double nLargestChromSize = 0;
		
		for (int i=0;  i < nHaploidChromosomeNum; i++) { // generate markers chromosome by chromosome
			
			double nChrLen = pChromosomeSizes[i];
			int	   nNumMarkers = (int) ceil( ((double) nTotalMarkers) * (nChrLen / nSumLens));
			//fOutFile << nNumMarkers <<endl;
			
			nLargestChromSize = (nLargestChromSize < nChrLen)? nChrLen : nLargestChromSize;
			
			//cout<< "MarkerNum:" << nNumMarkers << endl;
			
			fOutFile << ":chr " << (i+1) << "\tlen = " << nChrLen << "\tcentromere = " << pCentromerePos[i] << endl; // chromosome number
			fOutFile << "\nNum\tPosition Percentage\tPosition Abs.\tFreq. Pop 1\tFreq. Pop 2\n" ;
			
			double * pPos = new double[nNumMarkers];
			for (int j=0;j<nNumMarkers;j++) {
				pPos[j] = UniformGen.Next(); // create random set of uniformly distributed markers
			}
			
			//cout<< "MarkerNum:" << nNumMarkers << endl;
			//Sort markers according to position on chromosome:
			
			qsort (pPos , nNumMarkers , sizeof(double), fnCompare);
			
			//cout<< "MarkerNum:" << pPos[0] << endl;
			
			for (int j=0;j<nNumMarkers;j++) {
				fOutFile << (j + 1);
				fOutFile << '\t';
				fOutFile << pPos[j] ;
				fOutFile << '\t';
				fOutFile << pPos[j] * nChrLen ;
				fOutFile << '\t';
				fOutFile << NormalExt(nPop1AvgAlleleFreq ,nPop1AvgAlleleFreqStdDev , 0.5, 1.0);
				fOutFile << '\t';
				fOutFile <<  NormalExt( 1.0 - nPop2AvgAlleleFreq ,nPop2AvgAlleleFreqStdDev , 0, 0.5);
				fOutFile << endl; 
			}
			
			//cout<< "MarkerNum:" << nNumMarkers << endl;
			
			delete[] pPos;
		}
		
		fOutFile.close();
		
		
		while(true) { //  Get std. dev of the more abundant allele in pop 2
		
			char sRs;
			std::cout << "\nDo you want to generate random recombination probabilities along these chromosomes? y - yes, n - no : ";
			std::cin >> sRs;
			
			if (sRs == 'y') {
				
				UIGenerateRecombinationFreqMap(nHaploidChromosomeNum , nLargestChromSize, pChromosomeSizes, pCentromerePos); 
			}
			
			break;
		}

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x3b0, %rsp            # imm = 0x3B0
movl $0x1, -0x4(%rbp)
leaq -0x31(%rbp), %rdi
movq %rdi, -0x2c8(%rbp)
callq 0x8870
movq -0x2c8(%rbp), %rdx
leaq 0x14a2e(%rip), %rsi     # 0x772be
leaq -0x30(%rbp), %rdi
callq 0xcb30
jmp 0x6289b
leaq -0x31(%rbp), %rdi
callq 0x8540
jmp 0x628a6
movq 0x476db(%rip), %rdi     # 0xa9f88
leaq 0x159cc(%rip), %rsi     # 0x78280
callq 0x84a0
jmp 0x628bb
movq 0x4770e(%rip), %rdi     # 0xa9fd0
leaq 0x482cf(%rip), %rsi     # 0xaab98
callq 0x83c0
jmp 0x628d0
leaq 0x482c1(%rip), %rax     # 0xaab98
movsd (%rax), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x62938
movsd 0x13724(%rip), %xmm0    # 0x76010
leaq 0x482a5(%rip), %rax     # 0xaab98
ucomisd (%rax), %xmm0
jbe 0x62938
leaq 0x48298(%rip), %rax     # 0xaab98
movsd (%rax), %xmm0
callq 0x132f0
jmp 0x6290b
jmp 0x6293d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x31(%rbp), %rdi
callq 0x8540
jmp 0x63387
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x6337e
jmp 0x628a4
jmp 0x6293f
jmp 0x62941
movq 0x47640(%rip), %rdi     # 0xa9f88
leaq 0x1597f(%rip), %rsi     # 0x782ce
callq 0x84a0
jmp 0x62956
movq 0x47673(%rip), %rdi     # 0xa9fd0
leaq -0x8(%rbp), %rsi
callq 0x82d0
jmp 0x62968
cmpl $0x0, -0x8(%rbp)
jle 0x62970
jmp 0x62972
jmp 0x6293f
movslq -0x8(%rbp), %rax
movl $0x8, %ecx
mulq %rcx
movq %rax, %rdi
movq $-0x1, %rax
cmovoq %rax, %rdi
callq 0x8040
movq %rax, -0x2d0(%rbp)
jmp 0x6299a
movq -0x2d0(%rbp), %rax
movq %rax, 0x481b0(%rip)     # 0xaab58
movslq -0x8(%rbp), %rax
movl $0x8, %ecx
mulq %rcx
movq %rax, %rdi
movq $-0x1, %rax
cmovoq %rax, %rdi
callq 0x8040
movq %rax, -0x2d8(%rbp)
jmp 0x629d0
movq -0x2d8(%rbp), %rax
movq %rax, -0x80(%rbp)
jmp 0x629dd
movq 0x475a4(%rip), %rdi     # 0xa9f88
leaq 0x15920(%rip), %rsi     # 0x7830b
callq 0x84a0
movq %rax, -0x2e0(%rbp)
jmp 0x629f9
movq -0x2e0(%rbp), %rdi
movl -0x4(%rbp), %esi
callq 0x8840
movq %rax, -0x2e8(%rbp)
jmp 0x62a11
movq -0x2e8(%rbp), %rdi
leaq 0x1590b(%rip), %rsi     # 0x7832a
callq 0x84a0
jmp 0x62a26
movq 0x475a3(%rip), %rdi     # 0xa9fd0
leaq -0x50(%rbp), %rsi
callq 0x83c0
jmp 0x62a38
movsd -0x50(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x62a68
jp 0x62a68
cmpl $0x1, -0x4(%rbp)
jne 0x62a68
movq 0x47533(%rip), %rdi     # 0xa9f88
leaq 0x1592b(%rip), %rsi     # 0x78387
callq 0x84a0
jmp 0x62a63
jmp 0x629db
movsd -0x50(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x62abc
jp 0x62abc
movq 0x480d9(%rip), %rax     # 0xaab58
movl -0x4(%rbp), %ecx
subl $0x2, %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm0
movq 0x480c4(%rip), %rax     # 0xaab58
movl -0x4(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movsd %xmm0, (%rax,%rcx,8)
movq 0x480af(%rip), %rax     # 0xaab58
movl -0x4(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm0
movsd %xmm0, -0x50(%rbp)
xorps %xmm0, %xmm0
ucomisd -0x50(%rbp), %xmm0
jbe 0x62ac8
jmp 0x62b1f
movsd -0x50(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x62af0
movsd -0x50(%rbp), %xmm0
movq 0x48076(%rip), %rax     # 0xaab58
movl -0x4(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movsd %xmm0, (%rax,%rcx,8)
movsd -0x50(%rbp), %xmm0
movq -0x80(%rbp), %rax
movl -0x4(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0x4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
cmpl -0x8(%rbp), %eax
jle 0x62b1a
jmp 0x62b1f
jmp 0x629db
jmp 0x62b21
jmp 0x62b23
movq 0x4745e(%rip), %rdi     # 0xa9f88
leaq 0x1586d(%rip), %rsi     # 0x7839e
callq 0x84a0
jmp 0x62b38
movq 0x47491(%rip), %rdi     # 0xa9fd0
leaq -0xc(%rbp), %rsi
callq 0x82d0
jmp 0x62b4a
cmpl $0x0, -0xc(%rbp)
jg 0x62b52
jmp 0x62b21
jmp 0x62b54
jmp 0x62b56
jmp 0x62b58
movq 0x47429(%rip), %rdi     # 0xa9f88
leaq 0x1589e(%rip), %rsi     # 0x78404
callq 0x84a0
jmp 0x62b6d
movq 0x4745c(%rip), %rdi     # 0xa9fd0
leaq -0x60(%rbp), %rsi
callq 0x83c0
jmp 0x62b7f
movsd 0x13b09(%rip), %xmm0    # 0x76690
ucomisd -0x60(%rbp), %xmm0
ja 0x62ba1
movsd -0x60(%rbp), %xmm0
movsd 0x13475(%rip), %xmm1    # 0x76010
ucomisd %xmm1, %xmm0
jbe 0x62ba3
jmp 0x62b56
jmp 0x62ba5
jmp 0x62ba7
jmp 0x62ba9
movq 0x473d8(%rip), %rdi     # 0xa9f88
leaq 0x158b2(%rip), %rsi     # 0x78469
callq 0x84a0
jmp 0x62bbe
movq 0x4740b(%rip), %rdi     # 0xa9fd0
leaq -0x68(%rbp), %rsi
callq 0x83c0
jmp 0x62bd0
xorps %xmm0, %xmm0
ucomisd -0x68(%rbp), %xmm0
ja 0x62bed
movsd -0x68(%rbp), %xmm0
movsd 0x13aa9(%rip), %xmm1    # 0x76690
ucomisd %xmm1, %xmm0
jbe 0x62bef
jmp 0x62ba7
jmp 0x62bf1
jmp 0x62bf3
jmp 0x62bf5
movq 0x4738c(%rip), %rdi     # 0xa9f88
leaq 0x158ca(%rip), %rsi     # 0x784cd
callq 0x84a0
jmp 0x62c0a
movq 0x473bf(%rip), %rdi     # 0xa9fd0
leaq -0x70(%rbp), %rsi
callq 0x83c0
jmp 0x62c1c
movsd 0x13a6c(%rip), %xmm0    # 0x76690
ucomisd -0x70(%rbp), %xmm0
ja 0x62c3e
movsd -0x70(%rbp), %xmm0
movsd 0x133d8(%rip), %xmm1    # 0x76010
ucomisd %xmm1, %xmm0
jbe 0x62c40
jmp 0x62bf3
jmp 0x62c42
jmp 0x62c44
jmp 0x62c46
movq 0x4733b(%rip), %rdi     # 0xa9f88
leaq 0x158de(%rip), %rsi     # 0x78532
callq 0x84a0
jmp 0x62c5b
movq 0x4736e(%rip), %rdi     # 0xa9fd0
leaq -0x78(%rbp), %rsi
callq 0x83c0
jmp 0x62c6d
xorps %xmm0, %xmm0
ucomisd -0x78(%rbp), %xmm0
ja 0x62c8a
movsd -0x78(%rbp), %xmm0
movsd 0x13a0c(%rip), %xmm1    # 0x76690
ucomisd %xmm1, %xmm0
jbe 0x62c8c
jmp 0x62c44
jmp 0x62c8e
movq 0x472f3(%rip), %rdi     # 0xa9f88
leaq 0x1590b(%rip), %rsi     # 0x785a7
callq 0x84a0
jmp 0x62ca3
jmp 0x62ca5
jmp 0x62ca7
movq 0x47322(%rip), %rdi     # 0xa9fd0
leaq -0x30(%rbp), %rsi
callq 0x80f0
jmp 0x62cb9
leaq -0x30(%rbp), %rdi
callq 0x8340
cmpq $0x3, %rax
jbe 0x62cca
jmp 0x62ccc
jmp 0x62ca5
leaq -0x280(%rbp), %rdi
callq 0x8810
jmp 0x62cda
leaq -0x30(%rbp), %rdi
callq 0x81d0
movq %rax, %rsi
leaq -0x280(%rbp), %rdi
movl $0x10, %edx
callq 0x8090
jmp 0x62cf9
leaq 0x158bb(%rip), %rsi     # 0x785bb
leaq -0x280(%rbp), %rdi
callq 0x84a0
movq %rax, -0x2f0(%rbp)
jmp 0x62d15
movq -0x2f0(%rbp), %rdi
movl -0x8(%rbp), %esi
callq 0x8840
movq %rax, -0x2f8(%rbp)
jmp 0x62d2d
movq -0x2f8(%rbp), %rdi
movq 0x471f5(%rip), %rsi     # 0xa9f30
callq 0x8520
jmp 0x62d42
leaq 0x1588a(%rip), %rsi     # 0x785d3
leaq -0x280(%rbp), %rdi
callq 0x84a0
movq %rax, -0x300(%rbp)
jmp 0x62d5e
movq -0x300(%rbp), %rdi
leaq 0x47e2c(%rip), %rax     # 0xaab98
movsd (%rax), %xmm0
callq 0x88c0
movq %rax, -0x308(%rbp)
jmp 0x62d7e
movq -0x308(%rbp), %rdi
movq 0x471a4(%rip), %rsi     # 0xa9f30
callq 0x8520
jmp 0x62d93
leaq 0x15847(%rip), %rsi     # 0x785e1
leaq -0x280(%rbp), %rdi
callq 0x84a0
movq %rax, -0x310(%rbp)
jmp 0x62daf
movq -0x310(%rbp), %rdi
movsd -0x60(%rbp), %xmm0
callq 0x88c0
movq %rax, -0x318(%rbp)
jmp 0x62dc9
movq -0x318(%rbp), %rdi
movq 0x47159(%rip), %rsi     # 0xa9f30
callq 0x8520
jmp 0x62dde
leaq 0x15811(%rip), %rsi     # 0x785f6
leaq -0x280(%rbp), %rdi
callq 0x84a0
movq %rax, -0x320(%rbp)
jmp 0x62dfa
movq -0x320(%rbp), %rdi
movsd -0x68(%rbp), %xmm0
callq 0x88c0
movq %rax, -0x328(%rbp)
jmp 0x62e14
movq -0x328(%rbp), %rdi
movq 0x4710e(%rip), %rsi     # 0xa9f30
callq 0x8520
jmp 0x62e29
leaq 0x157e0(%rip), %rsi     # 0x78610
leaq -0x280(%rbp), %rdi
callq 0x84a0
movq %rax, -0x330(%rbp)
jmp 0x62e45
movq -0x330(%rbp), %rdi
movsd -0x70(%rbp), %xmm0
callq 0x88c0
movq %rax, -0x338(%rbp)
jmp 0x62e5f
movq -0x338(%rbp), %rdi
movq 0x470c3(%rip), %rsi     # 0xa9f30
callq 0x8520
jmp 0x62e74
leaq 0x157aa(%rip), %rsi     # 0x78625
leaq -0x280(%rbp), %rdi
callq 0x84a0
movq %rax, -0x340(%rbp)
jmp 0x62e90
movq -0x340(%rbp), %rdi
movsd -0x78(%rbp), %xmm0
callq 0x88c0
movq %rax, -0x348(%rbp)
jmp 0x62eaa
movq -0x348(%rbp), %rdi
movq 0x47078(%rip), %rsi     # 0xa9f30
callq 0x8520
jmp 0x62ebf
movq 0x47c92(%rip), %rdi     # 0xaab58
movl -0x8(%rbp), %esi
callq 0x65da0
movsd %xmm0, -0x350(%rbp)
jmp 0x62ed8
movsd -0x350(%rbp), %xmm0
movsd %xmm0, -0x288(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x290(%rbp)
movl $0x0, -0x294(%rbp)
movl -0x294(%rbp), %eax
cmpl -0x8(%rbp), %eax
jge 0x632f7
movq 0x47c45(%rip), %rax     # 0xaab58
movslq -0x294(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movsd %xmm0, -0x2a0(%rbp)
cvtsi2sdl -0xc(%rbp), %xmm0
movsd -0x2a0(%rbp), %xmm1
divsd -0x288(%rbp), %xmm1
mulsd %xmm1, %xmm0
callq 0x8920
cvttsd2si %xmm0, %eax
movl %eax, -0x2a4(%rbp)
movsd -0x290(%rbp), %xmm1
movsd -0x2a0(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x62f77
movsd -0x2a0(%rbp), %xmm0
movsd %xmm0, -0x358(%rbp)
jmp 0x62f87
movsd -0x290(%rbp), %xmm0
movsd %xmm0, -0x358(%rbp)
movsd -0x358(%rbp), %xmm0
movsd %xmm0, -0x290(%rbp)
leaq 0x156a1(%rip), %rsi     # 0x7863f
leaq -0x280(%rbp), %rdi
callq 0x84a0
movq %rax, -0x360(%rbp)
jmp 0x62fb3
movq -0x360(%rbp), %rdi
movl -0x294(%rbp), %esi
incl %esi
callq 0x8840
movq %rax, -0x368(%rbp)
jmp 0x62fd0
movq -0x368(%rbp), %rdi
leaq 0x15667(%rip), %rsi     # 0x78645
callq 0x84a0
movq %rax, -0x370(%rbp)
jmp 0x62fec
movq -0x370(%rbp), %rdi
movsd -0x2a0(%rbp), %xmm0
callq 0x88c0
movq %rax, -0x378(%rbp)
jmp 0x63009
movq -0x378(%rbp), %rdi
leaq 0x15636(%rip), %rsi     # 0x7864d
callq 0x84a0
movq %rax, -0x380(%rbp)
jmp 0x63025
movq -0x380(%rbp), %rdi
movq -0x80(%rbp), %rax
movslq -0x294(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
callq 0x88c0
movq %rax, -0x388(%rbp)
jmp 0x6304a
movq -0x388(%rbp), %rdi
movq 0x46ed8(%rip), %rsi     # 0xa9f30
callq 0x8520
jmp 0x6305f
leaq 0x155f6(%rip), %rsi     # 0x7865c
leaq -0x280(%rbp), %rdi
callq 0x84a0
jmp 0x63074
movslq -0x2a4(%rbp), %rax
movl $0x8, %ecx
mulq %rcx
movq %rax, %rdi
movq $-0x1, %rax
cmovoq %rax, %rdi
callq 0x8040
movq %rax, -0x390(%rbp)
jmp 0x6309f
movq -0x390(%rbp), %rax
movq %rax, -0x2b0(%rbp)
movl $0x0, -0x2b4(%rbp)
movl -0x2b4(%rbp), %eax
cmpl -0x2a4(%rbp), %eax
jge 0x63124
leaq 0x47ac4(%rip), %rdi     # 0xaab90
callq 0x19e20
movsd %xmm0, -0x398(%rbp)
jmp 0x630db
movsd -0x398(%rbp), %xmm0
movq -0x2b0(%rbp), %rax
movslq -0x2b4(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0x2b4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2b4(%rbp)
jmp 0x630b7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x280(%rbp), %rdi
callq 0x8700
jmp 0x6337e
movq -0x2b0(%rbp), %rdi
movslq -0x2a4(%rbp), %rsi
leaq 0x2cb7(%rip), %rcx      # 0x65df0
movl $0x8, %edx
callq 0x88d0
jmp 0x63145
movl $0x0, -0x2b8(%rbp)
movl -0x2b8(%rbp), %eax
cmpl -0x2a4(%rbp), %eax
jge 0x632c1
movl -0x2b8(%rbp), %esi
incl %esi
leaq -0x280(%rbp), %rdi
callq 0x8840
jmp 0x63177
leaq -0x280(%rbp), %rdi
movl $0x9, %esi
callq 0x85d0
jmp 0x6318a
movq -0x2b0(%rbp), %rax
movslq -0x2b8(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
leaq -0x280(%rbp), %rdi
callq 0x88c0
jmp 0x631ab
leaq -0x280(%rbp), %rdi
movl $0x9, %esi
callq 0x85d0
jmp 0x631be
movq -0x2b0(%rbp), %rax
movslq -0x2b8(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movsd -0x2a0(%rbp), %xmm1
mulsd %xmm1, %xmm0
leaq -0x280(%rbp), %rdi
callq 0x88c0
jmp 0x631eb
leaq -0x280(%rbp), %rdi
movl $0x9, %esi
callq 0x85d0
jmp 0x631fe
movsd -0x60(%rbp), %xmm0
movsd -0x68(%rbp), %xmm1
movsd 0x13480(%rip), %xmm2    # 0x76690
movsd 0x12df8(%rip), %xmm3    # 0x76010
callq 0x65d00
movsd %xmm0, -0x3a0(%rbp)
jmp 0x63227
movsd -0x3a0(%rbp), %xmm0
leaq -0x280(%rbp), %rdi
callq 0x88c0
jmp 0x6323d
leaq -0x280(%rbp), %rdi
movl $0x9, %esi
callq 0x85d0
jmp 0x63250
movsd -0x70(%rbp), %xmm1
movsd 0x12db3(%rip), %xmm0    # 0x76010
subsd %xmm1, %xmm0
movsd -0x78(%rbp), %xmm1
xorps %xmm2, %xmm2
movsd 0x1341f(%rip), %xmm3    # 0x76690
callq 0x65d00
movsd %xmm0, -0x3a8(%rbp)
jmp 0x63280
movsd -0x3a8(%rbp), %xmm0
leaq -0x280(%rbp), %rdi
callq 0x88c0
jmp 0x63296
movq 0x46c93(%rip), %rsi     # 0xa9f30
leaq -0x280(%rbp), %rdi
callq 0x8520
jmp 0x632ab
jmp 0x632ad
movl -0x2b8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2b8(%rbp)
jmp 0x6314f
movq -0x2b0(%rbp), %rax
movq %rax, -0x3b0(%rbp)
cmpq $0x0, %rax
je 0x632e1
movq -0x3b0(%rbp), %rdi
callq 0x8640
jmp 0x632e3
movl -0x294(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x294(%rbp)
jmp 0x62efd
leaq -0x280(%rbp), %rdi
callq 0x86d0
jmp 0x63305
jmp 0x63307
jmp 0x63309
movq 0x46c78(%rip), %rdi     # 0xa9f88
leaq 0x15385(%rip), %rsi     # 0x7869c
callq 0x84a0
jmp 0x6331e
movq 0x46cab(%rip), %rdi     # 0xa9fd0
leaq -0x2b9(%rbp), %rsi
callq 0x8660
jmp 0x63333
movsbl -0x2b9(%rbp), %eax
cmpl $0x79, %eax
jne 0x6335e
movl -0x8(%rbp), %edi
movsd -0x290(%rbp), %xmm0
movq 0x47807(%rip), %rsi     # 0xaab58
movq -0x80(%rbp), %rdx
callq 0x63390
jmp 0x6335c
jmp 0x6335e
jmp 0x63360
leaq -0x280(%rbp), %rdi
callq 0x8700
leaq -0x30(%rbp), %rdi
callq 0x82e0
addq $0x3b0, %rsp            # imm = 0x3B0
popq %rbp
retq
leaq -0x30(%rbp), %rdi
callq 0x82e0
movq -0x40(%rbp), %rdi
callq 0x8860