// File: /workspace/github_c_makefile_star2_O0/dapogon[P]cellcoal/src/cellcoal.c
// Function: SiteReadCounts
void SiteReadCounts (CellSiteStr *c, int i, int j, double *probs, double **ngsEij, double **ampEijmat, double **ampEijpat, long int *seed)
	{
	int		k, l, m;
	int		read, template;
	int		numMaternalReads, numPaternalReads;
	int		numReads;
	int		*readCount;
	int		maternalAllele, paternalAllele;
	int		thereIsMaternalAllele, thereIsPaternalAllele;
	double  maternalSiteAmplificationError, paternalSiteAmplificationError;
	int		ampErrorMaternalAllele, ampErrorPaternalAllele, goodTemplate, badTemplate;
	int		readsLeft, badReads;
	double	cumProb;
	double	uniform, goodTemplateProb, badTemplateProb, noSeqError;
	double 	allelicImbalance;
	
	readCount = c->readCount;
	
	thereIsMaternalAllele = YES;
	thereIsPaternalAllele = YES;
	
	maternalAllele = data[MATERNAL][i][j];
	if (maternalAllele == ADO || maternalAllele == DELETION)
		thereIsMaternalAllele = NO;
	
	paternalAllele = data[PATERNAL][i][j];
	if (paternalAllele == ADO || paternalAllele == DELETION)
		thereIsPaternalAllele = NO;
	
	/* initialize some variables */
	noSeqError = 0;
	badTemplateProb = 0;
	goodTemplateProb = 0;
	ampErrorMaternalAllele = -9;
	ampErrorPaternalAllele = -9;
	badTemplate = -9;
	goodTemplate = -9;
	maternalSiteAmplificationError = 0;
	paternalSiteAmplificationError = 0;
	
	/* sample maternal allelic imbalance for this genotype */
	if (doAllelicImbalance == YES)
		allelicImbalance = RandomBetaMeanVar(meanAllelicImbalance, varAllelicImbalance, seed);
	else
		allelicImbalance = 0.5;

	/* number of reads will follow a Poisson or a Negative Binomial distribution (overdispersed coverage) around mean coverage, and are randomly assigned to maternal/paternal chromosome */
	numMaternalReads = 0;
	numPaternalReads = 0;
	
	if (rateVarCoverage == YES) /* Negative Binomial */
		{
		if (thereIsMaternalAllele == YES && thereIsPaternalAllele == YES) /* both alleles are present */
			{
			numMaternalReads = RandomNegativeBinomial(allelicImbalance*coverage, alphaCoverage, seed);
			numPaternalReads = RandomNegativeBinomial((1.0-allelicImbalance)*coverage, alphaCoverage, seed);
			}
		else if (thereIsMaternalAllele == YES && thereIsPaternalAllele == NO)  /* only maternal allele */
			{
			numMaternalReads = RandomNegativeBinomial(haploidCoverageReduction*coverage, alphaCoverage, seed);
			numPaternalReads = 0;
			}
		else if (thereIsMaternalAllele == NO && thereIsPaternalAllele == YES)  /* only paternal allele */
			{
			numMaternalReads = 0;
			numPaternalReads = RandomNegativeBinomial(haploidCoverageReduction*coverage, alphaCoverage, seed);
			}
		else /* no allele is present (locus dropout/deletion) */
			{
			numMaternalReads = 0;
			numPaternalReads = 0;
			}
		}
	else /* Poisson distributed */
		{
		if (thereIsMaternalAllele == YES && thereIsPaternalAllele == YES) /* both alleles are present */
			{
			numMaternalReads = RandomPoisson(allelicImbalance*coverage, seed);
			numPaternalReads = RandomPoisson((1.0-allelicImbalance)*coverage, seed);
			}
		else if (thereIsMaternalAllele == YES && thereIsPaternalAllele == NO)  /* only maternal allele */
			{
			numMaternalReads = RandomPoisson(haploidCoverageReduction*coverage, seed);
			numPaternalReads = 0;
			}
		else if (thereIsMaternalAllele == NO && thereIsPaternalAllele == YES)  /* only paternal allele */
			{
			numMaternalReads = 0;
			numPaternalReads = RandomPoisson(haploidCoverageReduction*coverage, seed);
			}
		else /* no allele is present (locus dropout/deletion) */
			{
			numMaternalReads = 0;
			numPaternalReads = 0;
			}
		}
	
	numReads = numMaternalReads + numPaternalReads;
	
	/* read count simulation */
	readCount[A] = readCount[C] = readCount[G] = readCount[T] = 0;

	if (numReads > 0)
		{
		/* choose amplification error for this site. In this case we will have a proportion of alternative templates depending on whether the error occurred early or late in the amplification (we use a Beta distribution to modelize this proportion) */
		if (meanAmplificationError > 0)
			{
			maternalSiteAmplificationError = RandomBetaMeanVar(meanAmplificationError, varAmplificationError, seed);
			paternalSiteAmplificationError = RandomBetaMeanVar(meanAmplificationError, varAmplificationError, seed);
			}
		
		/* initialize ampEijmat */
		for (k=0; k<4; k++)
			for (l=0; l<4; l++)
				{
				if (k == l)
					ampEijmat[k][l] = 1.0 - maternalSiteAmplificationError;
				else
					ampEijmat[k][l] = Eij[k][l]/cumEij[k][3] * maternalSiteAmplificationError;
				}
		
		/* initialize ampEijpat */
		for (k=0; k<4; k++)
			for (l=0; l<4; l++)
				{
				if (k == l)
					ampEijpat[k][l] = 1.0 - paternalSiteAmplificationError;
				else
					ampEijpat[k][l] = Eij[k][l]/cumEij[k][3] * paternalSiteAmplificationError;
				}
		
		if (simulateOnlyTwoTemplates == YES)
			{
			/* choose base for wrong maternal template */
			ampErrorMaternalAllele = maternalAllele;
			if (maternalSiteAmplificationError > 0 && thereIsMaternalAllele == YES )
				{
				uniform = RandomUniform(seed) * cumEij[maternalAllele][3];
				for (m=0; m<4; m++)
					if (uniform <= cumEij[maternalAllele][m])
						{
						ampErrorMaternalAllele = m;
						break;
						}
				}
			/* choose base for wrong paternal template */
			ampErrorPaternalAllele = paternalAllele;
			if (paternalSiteAmplificationError > 0 && thereIsPaternalAllele == YES )
				{
				uniform = RandomUniform(seed) * cumEij[paternalAllele][3];
				for (m=0; m<4; m++)
					if (uniform <= cumEij[paternalAllele][m])
						{
						ampErrorPaternalAllele = m;
						break;
						}
				}
			}
		
		/* probabilities for the different types of reads  */
		if (sequencingError > 0 || maternalSiteAmplificationError > 0 || paternalSiteAmplificationError > 0)
			{
			if (thereIsMaternalAllele == YES)
				{
				if (simulateOnlyTwoTemplates == YES)
					{
					/* probabilities for maternal reads  (assuming a chosen template )*/
					noSeqError = 1.0 - sequencingError;
					badTemplateProb = maternalSiteAmplificationError;
					goodTemplateProb = 1.0 - maternalSiteAmplificationError;
					badTemplate = ampErrorMaternalAllele;
					goodTemplate = maternalAllele;
					for (read=0; read<4; read++)
						{
						if (read == maternalAllele)
							probs[read] = goodTemplateProb * noSeqError + badTemplateProb * ngsEij[badTemplate][read];
						else if (read == ampErrorMaternalAllele)
							probs[read] = goodTemplateProb * ngsEij[goodTemplate][read] + badTemplateProb * noSeqError;
						else
							probs[read] = goodTemplateProb * ngsEij[goodTemplate][read] + badTemplateProb * ngsEij[badTemplate][read];
						}
					}
				else
					{
					/* probabilities for maternal reads integrating over all potential templates) */
					for (read=0; read<4; read++)
						{
						probs[read] = 0;
						for (template=0; template<4; template++)
							probs[read] += ampEijmat[maternalAllele][template] * ngsEij[template][read];
						}
					}
				
				cumProb = 0;
				readsLeft = numMaternalReads;
				/* multinomial assignment of reads */
				for (read=0; read<4; read++)
					{
					if (read != maternalAllele)
						{
						badReads = RandomBinomial (probs[read] / (1 - cumProb), readsLeft, seed);
						readsLeft -= badReads;
						readCount[read] += badReads;
						cumProb += probs[read];
						}
					}
				readCount[maternalAllele] += readsLeft; /* good reads */
				}
			
			if (thereIsPaternalAllele == YES)
				{
				if (simulateOnlyTwoTemplates == YES)
					{
					/* probabilities for paternal reads  (assuming a chosen template )*/
					badTemplateProb = paternalSiteAmplificationError;
					goodTemplateProb = 1.0 - paternalSiteAmplificationError;
					badTemplate = ampErrorPaternalAllele;
					goodTemplate = paternalAllele;
					
					for (read=0; read<4; read++)
						{
						if (read == paternalAllele)
							probs[read] = goodTemplateProb * noSeqError + badTemplateProb * ngsEij[badTemplate][read];
						else if (read == ampErrorPaternalAllele)
							probs[read] = goodTemplateProb * ngsEij[goodTemplate][read] + badTemplateProb * noSeqError;
						else
							probs[read] = goodTemplateProb * ngsEij[goodTemplate][read] + badTemplateProb * ngsEij[badTemplate][read];
						}
					}
				else
					{
					/* probabilities for paternal reads  (integrating over all potential templates) */
					for (read=0; read<4; read++)
						{
						probs[read] = 0;
						for (template=0; template<4; template++)
							probs[read] += ampEijpat[paternalAllele][template] * ngsEij[template][read];
						}
					}
				
				cumProb = 0;
				readsLeft = numPaternalReads;
				/* multinomial assignment of reads */
				for (read=0; read<4; read++)
					{
					if (read != paternalAllele)
						{
						badReads = RandomBinomial (probs[read] / (1 - cumProb), readsLeft, seed);
						readsLeft -= badReads;
						readCount[read] += badReads;
						cumProb += probs[read];
						}
					}
				readCount[paternalAllele] += readsLeft; // good reads
				}
			}
		else /* no sequencing or amplification error */
			{
			readCount[maternalAllele] += numMaternalReads;
			readCount[paternalAllele] += numPaternalReads;
			}
		} // numReads > 0
	
	c->numReads = numReads;
	c->readCount = readCount;
	c->maternalAllele = maternalAllele;
	c->paternalAllele = paternalAllele;
	c->thereIsMaternalAllele = thereIsMaternalAllele;
	c->thereIsPaternalAllele = thereIsPaternalAllele;
	c->maternalSiteAmplificationError = maternalSiteAmplificationError;
	c->paternalSiteAmplificationError = paternalSiteAmplificationError;
	}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xc0, %rsp
movq 0x18(%rbp), %rax
movq 0x10(%rbp), %rax
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movq %rcx, -0x18(%rbp)
movq %r8, -0x20(%rbp)
movq %r9, -0x28(%rbp)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x50(%rbp)
movl $0x1, -0x5c(%rbp)
movl $0x1, -0x60(%rbp)
movq 0x324b6(%rip), %rax     # 0x4f7a0
movq (%rax), %rax
movslq -0xc(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x10(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x54(%rbp)
cmpl $0x9, -0x54(%rbp)
je 0x1d30b
cmpl $0x7, -0x54(%rbp)
jne 0x1d312
movl $0x0, -0x5c(%rbp)
movq 0x32487(%rip), %rax     # 0x4f7a0
movq 0x8(%rax), %rax
movslq -0xc(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x10(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x58(%rbp)
cmpl $0x9, -0x58(%rbp)
je 0x1d33b
cmpl $0x7, -0x58(%rbp)
jne 0x1d342
movl $0x0, -0x60(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0xb0(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0xa8(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0xa0(%rbp)
movl $0xfffffff7, -0x74(%rbp) # imm = 0xFFFFFFF7
movl $0xfffffff7, -0x78(%rbp) # imm = 0xFFFFFFF7
movl $0xfffffff7, -0x80(%rbp) # imm = 0xFFFFFFF7
movl $0xfffffff7, -0x7c(%rbp) # imm = 0xFFFFFFF7
xorps %xmm0, %xmm0
movsd %xmm0, -0x68(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x70(%rbp)
movsd 0x31119(%rip), %xmm0    # 0x4e4b0
movsd 0x21c81(%rip), %xmm1    # 0x3f020
ucomisd %xmm1, %xmm0
jne 0x1d3ca
jp 0x1d3ca
movsd 0x31109(%rip), %xmm0    # 0x4e4b8
movsd 0x31109(%rip), %xmm1    # 0x4e4c0
movq 0x18(%rbp), %rdi
callq 0x1d1e0
movsd %xmm0, -0xb8(%rbp)
jmp 0x1d3da
movsd 0x21c3e(%rip), %xmm0    # 0x3f010
movsd %xmm0, -0xb8(%rbp)
movl $0x0, -0x40(%rbp)
movl $0x0, -0x44(%rbp)
cmpl $0x1, 0x31041(%rip)     # 0x4e430
jne 0x1d4df
cmpl $0x1, -0x5c(%rbp)
jne 0x1d456
cmpl $0x1, -0x60(%rbp)
jne 0x1d456
movsd -0xb8(%rbp), %xmm0
mulsd 0x31017(%rip), %xmm0    # 0x4e428
movsd 0x30f9f(%rip), %xmm1    # 0x4e3b8
movq 0x18(%rbp), %rdi
callq 0x215d0
movl %eax, -0x40(%rbp)
movsd 0x21bf3(%rip), %xmm0    # 0x3f020
subsd -0xb8(%rbp), %xmm0
mulsd 0x30feb(%rip), %xmm0    # 0x4e428
movsd 0x30f73(%rip), %xmm1    # 0x4e3b8
movq 0x18(%rbp), %rdi
callq 0x215d0
movl %eax, -0x44(%rbp)
jmp 0x1d4da
cmpl $0x1, -0x5c(%rbp)
jne 0x1d48f
cmpl $0x0, -0x60(%rbp)
jne 0x1d48f
movsd 0x3103e(%rip), %xmm0    # 0x4e4a8
mulsd 0x30fb6(%rip), %xmm0    # 0x4e428
movsd 0x30f3e(%rip), %xmm1    # 0x4e3b8
movq 0x18(%rbp), %rdi
callq 0x215d0
movl %eax, -0x40(%rbp)
movl $0x0, -0x44(%rbp)
jmp 0x1d4d8
cmpl $0x0, -0x5c(%rbp)
jne 0x1d4c8
cmpl $0x1, -0x60(%rbp)
jne 0x1d4c8
movl $0x0, -0x40(%rbp)
movsd 0x30ffe(%rip), %xmm0    # 0x4e4a8
mulsd 0x30f76(%rip), %xmm0    # 0x4e428
movsd 0x30efe(%rip), %xmm1    # 0x4e3b8
movq 0x18(%rbp), %rdi
callq 0x215d0
movl %eax, -0x44(%rbp)
jmp 0x1d4d6
movl $0x0, -0x40(%rbp)
movl $0x0, -0x44(%rbp)
jmp 0x1d4d8
jmp 0x1d4da
jmp 0x1d5a3
cmpl $0x1, -0x5c(%rbp)
jne 0x1d52d
cmpl $0x1, -0x60(%rbp)
jne 0x1d52d
movsd -0xb8(%rbp), %xmm0
mulsd 0x30f2d(%rip), %xmm0    # 0x4e428
movq 0x18(%rbp), %rdi
callq 0x1b370
movl %eax, -0x40(%rbp)
movsd 0x21b11(%rip), %xmm0    # 0x3f020
subsd -0xb8(%rbp), %xmm0
mulsd 0x30f09(%rip), %xmm0    # 0x4e428
movq 0x18(%rbp), %rdi
callq 0x1b370
movl %eax, -0x44(%rbp)
jmp 0x1d5a1
cmpl $0x1, -0x5c(%rbp)
jne 0x1d55e
cmpl $0x0, -0x60(%rbp)
jne 0x1d55e
movsd 0x30f67(%rip), %xmm0    # 0x4e4a8
mulsd 0x30edf(%rip), %xmm0    # 0x4e428
movq 0x18(%rbp), %rdi
callq 0x1b370
movl %eax, -0x40(%rbp)
movl $0x0, -0x44(%rbp)
jmp 0x1d59f
cmpl $0x0, -0x5c(%rbp)
jne 0x1d58f
cmpl $0x1, -0x60(%rbp)
jne 0x1d58f
movl $0x0, -0x40(%rbp)
movsd 0x30f2f(%rip), %xmm0    # 0x4e4a8
mulsd 0x30ea7(%rip), %xmm0    # 0x4e428
movq 0x18(%rbp), %rdi
callq 0x1b370
movl %eax, -0x44(%rbp)
jmp 0x1d59d
movl $0x0, -0x40(%rbp)
movl $0x0, -0x44(%rbp)
jmp 0x1d59f
jmp 0x1d5a1
jmp 0x1d5a3
movl -0x40(%rbp), %eax
addl -0x44(%rbp), %eax
movl %eax, -0x48(%rbp)
movq -0x50(%rbp), %rax
movl $0x0, 0xc(%rax)
movq -0x50(%rbp), %rax
movl $0x0, 0x8(%rax)
movq -0x50(%rbp), %rax
movl $0x0, 0x4(%rax)
movq -0x50(%rbp), %rax
movl $0x0, (%rax)
cmpl $0x0, -0x48(%rbp)
jle 0x1de94
movsd 0x30ea7(%rip), %xmm0    # 0x4e490
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x1d62e
movsd 0x30e96(%rip), %xmm0    # 0x4e490
movsd 0x30e96(%rip), %xmm1    # 0x4e498
movq 0x18(%rbp), %rdi
callq 0x1d1e0
movsd %xmm0, -0x68(%rbp)
movsd 0x30e78(%rip), %xmm0    # 0x4e490
movsd 0x30e78(%rip), %xmm1    # 0x4e498
movq 0x18(%rbp), %rdi
callq 0x1d1e0
movsd %xmm0, -0x70(%rbp)
movl $0x0, -0x2c(%rbp)
cmpl $0x4, -0x2c(%rbp)
jge 0x1d6e8
movl $0x0, -0x30(%rbp)
cmpl $0x4, -0x30(%rbp)
jge 0x1d6d8
movl -0x2c(%rbp), %eax
cmpl -0x30(%rbp), %eax
jne 0x1d67c
movsd 0x219c0(%rip), %xmm0    # 0x3f020
subsd -0x68(%rbp), %xmm0
movq -0x28(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x30(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
jmp 0x1d6c8
movslq -0x2c(%rbp), %rcx
leaq 0x30c89(%rip), %rax     # 0x4e310
shlq $0x5, %rcx
addq %rcx, %rax
movslq -0x30(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movslq -0x2c(%rbp), %rcx
leaq 0x30ffe(%rip), %rax     # 0x4e6a0
shlq $0x5, %rcx
addq %rcx, %rax
divsd 0x18(%rax), %xmm0
mulsd -0x68(%rbp), %xmm0
movq -0x28(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x30(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
jmp 0x1d6ca
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x1d646
jmp 0x1d6da
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x1d635
movl $0x0, -0x2c(%rbp)
cmpl $0x4, -0x2c(%rbp)
jge 0x1d7a2
movl $0x0, -0x30(%rbp)
cmpl $0x4, -0x30(%rbp)
jge 0x1d792
movl -0x2c(%rbp), %eax
cmpl -0x30(%rbp), %eax
jne 0x1d736
movsd 0x21906(%rip), %xmm0    # 0x3f020
subsd -0x70(%rbp), %xmm0
movq 0x10(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x30(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
jmp 0x1d782
movslq -0x2c(%rbp), %rcx
leaq 0x30bcf(%rip), %rax     # 0x4e310
shlq $0x5, %rcx
addq %rcx, %rax
movslq -0x30(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movslq -0x2c(%rbp), %rcx
leaq 0x30f44(%rip), %rax     # 0x4e6a0
shlq $0x5, %rcx
addq %rcx, %rax
divsd 0x18(%rax), %xmm0
mulsd -0x70(%rbp), %xmm0
movq 0x10(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x30(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
jmp 0x1d784
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x1d700
jmp 0x1d794
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x1d6ef
cmpl $0x1, 0x30cf7(%rip)     # 0x4e4a0
jne 0x1d8cf
movl -0x54(%rbp), %eax
movl %eax, -0x74(%rbp)
movsd -0x68(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x1d83e
cmpl $0x1, -0x5c(%rbp)
jne 0x1d83e
movq 0x18(%rbp), %rdi
callq 0xa500
movslq -0x54(%rbp), %rcx
leaq 0x30ec3(%rip), %rax     # 0x4e6a0
shlq $0x5, %rcx
addq %rcx, %rax
mulsd 0x18(%rax), %xmm0
movsd %xmm0, -0x98(%rbp)
movl $0x0, -0x34(%rbp)
cmpl $0x4, -0x34(%rbp)
jge 0x1d83c
movsd -0x98(%rbp), %xmm1
movslq -0x54(%rbp), %rcx
leaq 0x30e8f(%rip), %rax     # 0x4e6a0
shlq $0x5, %rcx
addq %rcx, %rax
movslq -0x34(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
ucomisd %xmm1, %xmm0
jb 0x1d82f
movl -0x34(%rbp), %eax
movl %eax, -0x74(%rbp)
jmp 0x1d83c
jmp 0x1d831
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x1d7f8
jmp 0x1d83e
movl -0x58(%rbp), %eax
movl %eax, -0x78(%rbp)
movsd -0x70(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x1d8cd
cmpl $0x1, -0x60(%rbp)
jne 0x1d8cd
movq 0x18(%rbp), %rdi
callq 0xa500
movslq -0x58(%rbp), %rcx
leaq 0x30e34(%rip), %rax     # 0x4e6a0
shlq $0x5, %rcx
addq %rcx, %rax
mulsd 0x18(%rax), %xmm0
movsd %xmm0, -0x98(%rbp)
movl $0x0, -0x34(%rbp)
cmpl $0x4, -0x34(%rbp)
jge 0x1d8cb
movsd -0x98(%rbp), %xmm1
movslq -0x58(%rbp), %rcx
leaq 0x30e00(%rip), %rax     # 0x4e6a0
shlq $0x5, %rcx
addq %rcx, %rax
movslq -0x34(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
ucomisd %xmm1, %xmm0
jb 0x1d8be
movl -0x34(%rbp), %eax
movl %eax, -0x78(%rbp)
jmp 0x1d8cb
jmp 0x1d8c0
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x1d887
jmp 0x1d8cd
jmp 0x1d8cf
movsd 0x30ba1(%rip), %xmm0    # 0x4e478
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
ja 0x1d900
movsd -0x68(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
ja 0x1d900
movsd -0x70(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x1de70
cmpl $0x1, -0x5c(%rbp)
jne 0x1dbc3
cmpl $0x1, 0x30b8f(%rip)     # 0x4e4a0
jne 0x1da6f
movsd 0x21701(%rip), %xmm0    # 0x3f020
subsd 0x30b51(%rip), %xmm0    # 0x4e478
movsd %xmm0, -0xb0(%rbp)
movsd -0x68(%rbp), %xmm0
movsd %xmm0, -0xa8(%rbp)
movsd 0x216dc(%rip), %xmm0    # 0x3f020
subsd -0x68(%rbp), %xmm0
movsd %xmm0, -0xa0(%rbp)
movl -0x74(%rbp), %eax
movl %eax, -0x80(%rbp)
movl -0x54(%rbp), %eax
movl %eax, -0x7c(%rbp)
movl $0x0, -0x38(%rbp)
cmpl $0x4, -0x38(%rbp)
jge 0x1da6a
movl -0x38(%rbp), %eax
cmpl -0x54(%rbp), %eax
jne 0x1d9bd
movsd -0xa0(%rbp), %xmm0
movsd -0xb0(%rbp), %xmm2
movsd -0xa8(%rbp), %xmm1
movq -0x20(%rbp), %rax
movslq -0x80(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x38(%rbp), %rcx
mulsd (%rax,%rcx,8), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movq -0x18(%rbp), %rax
movslq -0x38(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
jmp 0x1da5a
movl -0x38(%rbp), %eax
cmpl -0x74(%rbp), %eax
jne 0x1da09
movsd -0xa0(%rbp), %xmm0
movq -0x20(%rbp), %rax
movslq -0x7c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x38(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm2
movsd -0xa8(%rbp), %xmm1
mulsd -0xb0(%rbp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movq -0x18(%rbp), %rax
movslq -0x38(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
jmp 0x1da58
movsd -0xa0(%rbp), %xmm0
movq -0x20(%rbp), %rax
movslq -0x7c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x38(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm2
movsd -0xa8(%rbp), %xmm1
movq -0x20(%rbp), %rax
movslq -0x80(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x38(%rbp), %rcx
mulsd (%rax,%rcx,8), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movq -0x18(%rbp), %rax
movslq -0x38(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
jmp 0x1da5a
jmp 0x1da5c
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x1d964
jmp 0x1daf7
movl $0x0, -0x38(%rbp)
cmpl $0x4, -0x38(%rbp)
jge 0x1daf5
movq -0x18(%rbp), %rax
movslq -0x38(%rbp), %rcx
xorps %xmm0, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movl $0x0, -0x3c(%rbp)
cmpl $0x4, -0x3c(%rbp)
jge 0x1dae8
movq -0x28(%rbp), %rax
movslq -0x54(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x3c(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x20(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x38(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm2
movq -0x18(%rbp), %rax
movslq -0x38(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x1da93
jmp 0x1daea
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x1da76
jmp 0x1daf7
xorps %xmm0, %xmm0
movsd %xmm0, -0x90(%rbp)
movl -0x40(%rbp), %eax
movl %eax, -0x84(%rbp)
movl $0x0, -0x38(%rbp)
cmpl $0x4, -0x38(%rbp)
jge 0x1dbaf
movl -0x38(%rbp), %eax
cmpl -0x54(%rbp), %eax
je 0x1db9f
movq -0x18(%rbp), %rax
movslq -0x38(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movsd 0x214e7(%rip), %xmm1    # 0x3f020
subsd -0x90(%rbp), %xmm1
divsd %xmm1, %xmm0
movl -0x84(%rbp), %edi
movq 0x18(%rbp), %rsi
callq 0x1b310
movl %eax, -0x88(%rbp)
movl -0x88(%rbp), %ecx
movl -0x84(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x84(%rbp)
movl -0x88(%rbp), %edx
movq -0x50(%rbp), %rax
movslq -0x38(%rbp), %rcx
addl (%rax,%rcx,4), %edx
movl %edx, (%rax,%rcx,4)
movq -0x18(%rbp), %rax
movslq -0x38(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
addsd -0x90(%rbp), %xmm0
movsd %xmm0, -0x90(%rbp)
jmp 0x1dba1
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x1db12
movl -0x84(%rbp), %edx
movq -0x50(%rbp), %rax
movslq -0x54(%rbp), %rcx
addl (%rax,%rcx,4), %edx
movl %edx, (%rax,%rcx,4)
cmpl $0x1, -0x60(%rbp)
jne 0x1de6e
cmpl $0x1, 0x308cc(%rip)     # 0x4e4a0
jne 0x1dd1a
movsd -0x70(%rbp), %xmm0
movsd %xmm0, -0xa8(%rbp)
movsd 0x21431(%rip), %xmm0    # 0x3f020
subsd -0x70(%rbp), %xmm0
movsd %xmm0, -0xa0(%rbp)
movl -0x78(%rbp), %eax
movl %eax, -0x80(%rbp)
movl -0x58(%rbp), %eax
movl %eax, -0x7c(%rbp)
movl $0x0, -0x38(%rbp)
cmpl $0x4, -0x38(%rbp)
jge 0x1dd15
movl -0x38(%rbp), %eax
cmpl -0x58(%rbp), %eax
jne 0x1dc68
movsd -0xa0(%rbp), %xmm0
movsd -0xb0(%rbp), %xmm2
movsd -0xa8(%rbp), %xmm1
movq -0x20(%rbp), %rax
movslq -0x80(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x38(%rbp), %rcx
mulsd (%rax,%rcx,8), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movq -0x18(%rbp), %rax
movslq -0x38(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
jmp 0x1dd05
movl -0x38(%rbp), %eax
cmpl -0x78(%rbp), %eax
jne 0x1dcb4
movsd -0xa0(%rbp), %xmm0
movq -0x20(%rbp), %rax
movslq -0x7c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x38(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm2
movsd -0xa8(%rbp), %xmm1
mulsd -0xb0(%rbp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movq -0x18(%rbp), %rax
movslq -0x38(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
jmp 0x1dd03
movsd -0xa0(%rbp), %xmm0
movq -0x20(%rbp), %rax
movslq -0x7c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x38(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm2
movsd -0xa8(%rbp), %xmm1
movq -0x20(%rbp), %rax
movslq -0x80(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x38(%rbp), %rcx
mulsd (%rax,%rcx,8), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movq -0x18(%rbp), %rax
movslq -0x38(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
jmp 0x1dd05
jmp 0x1dd07
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x1dc0f
jmp 0x1dda2
movl $0x0, -0x38(%rbp)
cmpl $0x4, -0x38(%rbp)
jge 0x1dda0
movq -0x18(%rbp), %rax
movslq -0x38(%rbp), %rcx
xorps %xmm0, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movl $0x0, -0x3c(%rbp)
cmpl $0x4, -0x3c(%rbp)
jge 0x1dd93
movq 0x10(%rbp), %rax
movslq -0x58(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x3c(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x20(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x38(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm2
movq -0x18(%rbp), %rax
movslq -0x38(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x1dd3e
jmp 0x1dd95
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x1dd21
jmp 0x1dda2
xorps %xmm0, %xmm0
movsd %xmm0, -0x90(%rbp)
movl -0x44(%rbp), %eax
movl %eax, -0x84(%rbp)
movl $0x0, -0x38(%rbp)
cmpl $0x4, -0x38(%rbp)
jge 0x1de5a
movl -0x38(%rbp), %eax
cmpl -0x58(%rbp), %eax
je 0x1de4a
movq -0x18(%rbp), %rax
movslq -0x38(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movsd 0x2123c(%rip), %xmm1    # 0x3f020
subsd -0x90(%rbp), %xmm1
divsd %xmm1, %xmm0
movl -0x84(%rbp), %edi
movq 0x18(%rbp), %rsi
callq 0x1b310
movl %eax, -0x88(%rbp)
movl -0x88(%rbp), %ecx
movl -0x84(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x84(%rbp)
movl -0x88(%rbp), %edx
movq -0x50(%rbp), %rax
movslq -0x38(%rbp), %rcx
addl (%rax,%rcx,4), %edx
movl %edx, (%rax,%rcx,4)
movq -0x18(%rbp), %rax
movslq -0x38(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
addsd -0x90(%rbp), %xmm0
movsd %xmm0, -0x90(%rbp)
jmp 0x1de4c
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x1ddbd
movl -0x84(%rbp), %edx
movq -0x50(%rbp), %rax
movslq -0x58(%rbp), %rcx
addl (%rax,%rcx,4), %edx
movl %edx, (%rax,%rcx,4)
jmp 0x1de92
movl -0x40(%rbp), %edx
movq -0x50(%rbp), %rax
movslq -0x54(%rbp), %rcx
addl (%rax,%rcx,4), %edx
movl %edx, (%rax,%rcx,4)
movl -0x44(%rbp), %edx
movq -0x50(%rbp), %rax
movslq -0x58(%rbp), %rcx
addl (%rax,%rcx,4), %edx
movl %edx, (%rax,%rcx,4)
jmp 0x1de94
movl -0x48(%rbp), %ecx
movq -0x8(%rbp), %rax
movl %ecx, (%rax)
movq -0x50(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x8(%rax)
movl -0x54(%rbp), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x18(%rax)
movl -0x58(%rbp), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x1c(%rax)
movl -0x5c(%rbp), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x20(%rax)
movl -0x60(%rbp), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x24(%rax)
movsd -0x68(%rbp), %xmm0
movq -0x8(%rbp), %rax
movsd %xmm0, 0x28(%rax)
movsd -0x70(%rbp), %xmm0
movq -0x8(%rbp), %rax
movsd %xmm0, 0x30(%rax)
addq $0xc0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)