// File: /workspace/github_c_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %r9, %r15
movq %r8, %r12
movq %rcx, %r14
movq %rdi, %r13
movq 0xb8(%rsp), %rdi
movq 0x8(%r13), %rax
movq %rax, 0x30(%rsp)
movq 0x1c644(%rip), %rax     # 0x315b8
movslq %esi, %rcx
movq (%rax), %rsi
movq 0x8(%rax), %rax
movq (%rsi,%rcx,8), %rsi
movslq %edx, %rdx
movl (%rsi,%rdx,4), %esi
movq %rsi, 0x18(%rsp)
addl $-0x7, %esi
testl $0xfffffffd, %esi       # imm = 0xFFFFFFFD
setne %bl
movq (%rax,%rcx,8), %rax
movl (%rax,%rdx,4), %eax
movq %rax, 0x8(%rsp)
addl $-0x7, %eax
testl $0xfffffffd, %eax       # imm = 0xFFFFFFFD
setne %bpl
movsd 0x1b4b7(%rip), %xmm0    # 0x30470
ucomisd 0xa0ef(%rip), %xmm0     # 0x1f0b0
jne 0x14fe0
jp 0x14fe0
movsd 0x1b4ab(%rip), %xmm0    # 0x30478
movsd 0x1b4ab(%rip), %xmm1    # 0x30480
callq 0x14edd
movapd %xmm0, %xmm1
jmp 0x14fe8
movsd 0xa0e0(%rip), %xmm1     # 0x1f0c8
andb %bpl, %bl
cmpb $0x1, 0x1b3fe(%rip)     # 0x303f0
jne 0x15057
testb %bl, %bl
movq 0x30(%rsp), %rbp
je 0x150b0
movsd 0x1b3df(%rip), %xmm0    # 0x303e8
mulsd %xmm1, %xmm0
movsd %xmm1, 0x10(%rsp)
movsd 0x1b35d(%rip), %xmm1    # 0x30378
movq 0xb8(%rsp), %rdi
callq 0x1673d
movl %eax, %ebx
movsd 0xa07e(%rip), %xmm0     # 0x1f0b0
subsd 0x10(%rsp), %xmm0
mulsd 0x1b3a8(%rip), %xmm0    # 0x303e8
movsd 0x1b330(%rip), %xmm1    # 0x30378
movq 0xb8(%rsp), %rdi
callq 0x1673d
jmp 0x150a8
testb %bl, %bl
movq 0x30(%rsp), %rbp
je 0x15101
movsd 0x1b37c(%rip), %xmm0    # 0x303e8
mulsd %xmm1, %xmm0
movq 0xb8(%rsp), %rdi
movsd %xmm1, 0x10(%rsp)
callq 0x13e90
movl %eax, %ebx
movsd 0xa023(%rip), %xmm0     # 0x1f0b0
subsd 0x10(%rsp), %xmm0
mulsd 0x1b34d(%rip), %xmm0    # 0x303e8
movq 0xb8(%rsp), %rdi
callq 0x13e90
movl %ebx, %r9d
jmp 0x151dc
movq 0x8(%rsp), %rax
cmpl $0x9, %eax
je 0x150c3
cmpl $0x7, %eax
jne 0x1514c
movq 0x18(%rsp), %rax
cmpl $0x7, %eax
je 0x1515b
cmpl $0x9, %eax
je 0x1515b
movsd 0x1b386(%rip), %xmm0    # 0x30468
mulsd 0x1b2fe(%rip), %xmm0    # 0x303e8
movsd 0x1b286(%rip), %xmm1    # 0x30378
movq 0xb8(%rsp), %rdi
callq 0x1673d
jmp 0x15144
movq 0x8(%rsp), %rax
cmpl $0x9, %eax
je 0x15114
cmpl $0x7, %eax
jne 0x15194
movq 0x18(%rsp), %rax
cmpl $0x7, %eax
je 0x151a3
cmpl $0x9, %eax
je 0x151a3
movsd 0x1b339(%rip), %xmm0    # 0x30468
mulsd 0x1b2b1(%rip), %xmm0    # 0x303e8
movq 0xb8(%rsp), %rdi
callq 0x13e90
movl %eax, %r9d
jmp 0x151da
movq 0x18(%rsp), %rax
cmpl $0x9, %eax
je 0x1515b
cmpl $0x7, %eax
jne 0x151d7
xorl %r9d, %r9d
movq 0x8(%rsp), %rax
cmpl $0x7, %eax
je 0x151da
cmpl $0x9, %eax
je 0x151da
movsd 0x1b2f3(%rip), %xmm0    # 0x30468
mulsd 0x1b26b(%rip), %xmm0    # 0x303e8
movsd 0x1b1f3(%rip), %xmm1    # 0x30378
movq 0xb8(%rsp), %rdi
callq 0x1673d
jmp 0x151d2
movq 0x18(%rsp), %rax
cmpl $0x9, %eax
je 0x151a3
cmpl $0x7, %eax
jne 0x151d7
xorl %r9d, %r9d
movq 0x8(%rsp), %rax
cmpl $0x7, %eax
je 0x151da
cmpl $0x9, %eax
je 0x151da
movsd 0x1b2ab(%rip), %xmm0    # 0x30468
mulsd 0x1b223(%rip), %xmm0    # 0x303e8
movq 0xb8(%rsp), %rdi
callq 0x13e90
xorl %r9d, %r9d
jmp 0x151dc
xorl %r9d, %r9d
xorl %eax, %eax
movl %eax, %ecx
xorpd %xmm0, %xmm0
movupd %xmm0, (%rbp)
addl %r9d, %ecx
jle 0x153cd
movl %ecx, 0x3c(%rsp)
movl %eax, 0x5c(%rsp)
movq %r13, 0x48(%rsp)
movq 0x18(%rsp), %rbp
movslq %ebp, %rax
movq %rax, 0x70(%rsp)
movslq 0x8(%rsp), %rax
movq %rax, 0x60(%rsp)
movsd 0x1b234(%rip), %xmm0    # 0x30450
xorpd %xmm4, %xmm4
ucomisd %xmm4, %xmm0
xorpd %xmm5, %xmm5
jbe 0x15270
movsd 0x1b226(%rip), %xmm1    # 0x30458
movq 0xb8(%rsp), %rbx
movq %rbx, %rdi
movl %r9d, %r13d
callq 0x14edd
movsd %xmm0, 0x10(%rsp)
movsd 0x1b1fd(%rip), %xmm0    # 0x30450
movsd 0x1b1fd(%rip), %xmm1    # 0x30458
movq %rbx, %rdi
callq 0x14edd
movl %r13d, %r9d
movsd 0x10(%rsp), %xmm4
movapd %xmm0, %xmm5
movq 0xb0(%rsp), %r13
movsd 0x9e30(%rip), %xmm7     # 0x1f0b0
subsd %xmm4, %xmm7
leaq 0x1b045(%rip), %rax     # 0x302d0
xorl %ecx, %ecx
leaq 0x1b3ac(%rip), %rbx     # 0x30640
cmpq $0x4, %rcx
je 0x152e4
movq %rcx, %rdx
shlq $0x5, %rdx
addq %rbx, %rdx
addq $0x18, %rdx
movq (%r15,%rcx,8), %rsi
xorl %edi, %edi
cmpq $0x4, %rdi
je 0x152db
movq %rcx, %r8
movapd %xmm7, %xmm0
cmpq %rdi, %rcx
je 0x152d0
movsd (%rax,%rdi,8), %xmm0
divsd (%rdx), %xmm0
mulsd %xmm4, %xmm0
movq %rdi, %r8
movsd %xmm0, (%rsi,%r8,8)
incq %rdi
jmp 0x152ae
incq %rcx
addq $0x20, %rax
jmp 0x15294
movsd 0x9dc4(%rip), %xmm6     # 0x1f0b0
subsd %xmm5, %xmm6
leaq 0x1afd9(%rip), %rax     # 0x302d0
xorl %ecx, %ecx
cmpq $0x4, %rcx
je 0x1534a
movq %rcx, %rdx
shlq $0x5, %rdx
addq %rbx, %rdx
addq $0x18, %rdx
movq (%r13,%rcx,8), %rsi
xorl %edi, %edi
cmpq $0x4, %rdi
je 0x15341
movq %rcx, %r8
movapd %xmm6, %xmm0
cmpq %rdi, %rcx
je 0x15336
movsd (%rax,%rdi,8), %xmm0
divsd (%rdx), %xmm0
mulsd %xmm5, %xmm0
movq %rdi, %r8
movsd %xmm0, (%rsi,%r8,8)
incq %rdi
jmp 0x15314
incq %rcx
addq $0x20, %rax
jmp 0x152f9
cmpl $0x1, 0x1b10f(%rip)     # 0x30460
movsd %xmm4, 0x10(%rsp)
movsd %xmm5, 0x50(%rsp)
movsd %xmm6, 0x68(%rsp)
jne 0x153df
xorpd %xmm0, %xmm0
ucomisd %xmm0, %xmm4
jbe 0x1540f
movq %rbp, %rax
cmpl $0x7, %eax
je 0x1540f
movl %eax, %ebp
cmpl $0x9, %eax
je 0x1540f
movsd %xmm7, 0x20(%rsp)
movl %r9d, 0x28(%rsp)
movq 0xb8(%rsp), %rdi
callq 0x10279
movq 0x70(%rsp), %rax
shlq $0x5, %rax
mulsd 0x18(%rax,%rbx), %xmm0
xorl %ebp, %ebp
cmpq $0x4, %rbp
je 0x153e9
leaq (%rax,%rbp,8), %rcx
movsd (%rbx,%rcx), %xmm1
ucomisd %xmm0, %xmm1
jae 0x153ee
incq %rbp
jmp 0x153b3
xorpd %xmm4, %xmm4
xorpd %xmm5, %xmm5
movq 0x8(%rsp), %r15
jmp 0x157f4
pushq $-0x9
popq %rbp
movl %ebp, %eax
jmp 0x1548d
movq 0x18(%rsp), %rbp
movsd 0x10(%rsp), %xmm4
movsd 0x50(%rsp), %xmm5
movl 0x28(%rsp), %r9d
movsd 0x68(%rsp), %xmm6
movsd 0x20(%rsp), %xmm7
xorpd %xmm0, %xmm0
ucomisd %xmm0, %xmm5
jbe 0x15488
movq 0x8(%rsp), %rax
cmpl $0x7, %eax
je 0x1548d
cmpl $0x9, %eax
je 0x1548d
movq 0xb8(%rsp), %rdi
movl %r9d, 0x28(%rsp)
movsd %xmm7, 0x20(%rsp)
callq 0x10279
movsd 0x20(%rsp), %xmm7
movsd 0x68(%rsp), %xmm6
movl 0x28(%rsp), %r9d
movsd 0x50(%rsp), %xmm5
movsd 0x10(%rsp), %xmm4
movq 0x60(%rsp), %rax
shlq $0x5, %rax
mulsd 0x18(%rax,%rbx), %xmm0
xorl %edx, %edx
cmpq $0x4, %rdx
je 0x15488
leaq (%rax,%rdx,8), %rcx
movsd (%rbx,%rcx), %xmm1
ucomisd %xmm0, %xmm1
jae 0x15857
incq %rdx
jmp 0x1546a
movq 0x8(%rsp), %rax
movq %rax, 0x40(%rsp)
movsd 0x1af9e(%rip), %xmm0    # 0x30438
xorpd %xmm2, %xmm2
xorpd %xmm1, %xmm1
movsd %xmm1, 0x20(%rsp)
ucomisd %xmm2, %xmm5
movl 0x3c(%rsp), %ecx
movq 0x60(%rsp), %r8
movq 0x70(%rsp), %r10
ja 0x154ea
ucomisd 0x9c1c(%rip), %xmm4     # 0x1f0e0
ja 0x154ea
ucomisd %xmm1, %xmm0
ja 0x154ea
movq 0x30(%rsp), %rbp
addl %r9d, (%rbp,%r10,4)
movq 0x48(%rsp), %r13
movq 0x8(%rsp), %r15
movl 0x5c(%rsp), %r12d
jmp 0x157ef
movq 0x18(%rsp), %rax
cmpl $0x7, %eax
je 0x1567d
cmpl $0x9, %eax
je 0x1567d
cmpl $0x1, 0x1af58(%rip)     # 0x30460
jne 0x155a7
movsd 0x9b9a(%rip), %xmm2     # 0x1f0b0
subsd %xmm0, %xmm2
movslq %ebp, %rax
movapd %xmm4, %xmm0
mulsd %xmm2, %xmm0
movl %eax, %ecx
xorl %edx, %edx
movapd %xmm7, %xmm1
movsd %xmm2, 0x20(%rsp)
mulsd %xmm2, %xmm1
movq 0x18(%rsp), %rbp
cmpq $0x4, %rdx
je 0x155f5
cmpq %rdx, %rbp
jne 0x15564
movq (%r12,%rax,8), %rsi
movsd (%rsi,%rbp,8), %xmm2
mulsd %xmm4, %xmm2
addsd %xmm1, %xmm2
movsd %xmm2, (%r14,%rbp,8)
jmp 0x155a2
movq (%r12,%r10,8), %rsi
cmpq %rdx, %rcx
jne 0x15582
movsd (%rsi,%rcx,8), %xmm2
mulsd %xmm7, %xmm2
addsd %xmm0, %xmm2
movsd %xmm2, (%r14,%rcx,8)
jmp 0x155a2
movq (%r12,%rax,8), %rdi
movsd (%rdi,%rdx,8), %xmm2
mulsd %xmm4, %xmm2
movsd (%rsi,%rdx,8), %xmm3
mulsd %xmm7, %xmm3
addsd %xmm2, %xmm3
movsd %xmm3, (%r14,%rdx,8)
incq %rdx
jmp 0x1553c
movq (%r15,%r10,8), %rax
xorl %ecx, %ecx
movq 0x18(%rsp), %rbp
cmpq $0x4, %rcx
je 0x155eb
andq $0x0, (%r14,%rcx,8)
xorpd %xmm0, %xmm0
xorl %edx, %edx
cmpq $0x4, %rdx
je 0x155e6
movsd (%rax,%rdx,8), %xmm1
movq (%r12,%rdx,8), %rsi
mulsd (%rsi,%rcx,8), %xmm1
addsd %xmm1, %xmm0
movsd %xmm0, (%r14,%rcx,8)
incq %rdx
jmp 0x155c3
incq %rcx
jmp 0x155b2
xorpd %xmm0, %xmm0
movsd %xmm0, 0x20(%rsp)
xorpd %xmm2, %xmm2
xorl %ebx, %ebx
cmpq $0x4, %rbx
je 0x15666
cmpq %rbx, %rbp
je 0x15661
movsd (%r14,%rbx,8), %xmm0
movsd 0x9a9c(%rip), %xmm1     # 0x1f0b0
subsd %xmm2, %xmm1
divsd %xmm1, %xmm0
movl %r9d, %edi
movq 0xb8(%rsp), %rsi
movl %r9d, %r15d
movsd %xmm2, 0x28(%rsp)
callq 0x13e47
movsd 0x28(%rsp), %xmm2
movsd 0x68(%rsp), %xmm6
movl %r15d, %r9d
movsd 0x50(%rsp), %xmm5
movsd 0x10(%rsp), %xmm4
movq 0x30(%rsp), %rcx
addl %eax, (%rcx,%rbx,4)
subl %eax, %r9d
addsd (%r14,%rbx,8), %xmm2
incq %rbx
jmp 0x155fb
movq 0x70(%rsp), %rax
movq 0x30(%rsp), %rcx
addl %r9d, (%rcx,%rax,4)
movl 0x3c(%rsp), %ecx
movq 0x60(%rsp), %r8
movq 0x8(%rsp), %r15
cmpl $0x7, %r15d
je 0x1568e
cmpl $0x9, %r15d
jne 0x1569d
movq 0x48(%rsp), %r13
movq 0x30(%rsp), %rbp
jmp 0x157f4
cmpl $0x1, 0x1adbc(%rip)     # 0x30460
movq 0x30(%rsp), %rbp
jne 0x1573b
movslq 0x40(%rsp), %rax
movapd %xmm5, %xmm0
movsd 0x20(%rsp), %xmm3
mulsd %xmm3, %xmm0
movl %eax, %ecx
xorl %edx, %edx
mulsd %xmm6, %xmm3
movq 0x48(%rsp), %r13
cmpq $0x4, %rdx
je 0x15780
cmpq %rdx, %r15
jne 0x156f8
movq (%r12,%rax,8), %rsi
movsd (%rsi,%r15,8), %xmm1
mulsd %xmm5, %xmm1
addsd %xmm3, %xmm1
movsd %xmm1, (%r14,%r15,8)
jmp 0x15736
movq (%r12,%r8,8), %rsi
cmpq %rdx, %rcx
jne 0x15716
movsd (%rsi,%rcx,8), %xmm1
mulsd %xmm6, %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, (%r14,%rcx,8)
jmp 0x15736
movq (%r12,%rax,8), %rdi
movsd (%rdi,%rdx,8), %xmm1
mulsd %xmm5, %xmm1
movsd (%rsi,%rdx,8), %xmm2
mulsd %xmm6, %xmm2
addsd %xmm1, %xmm2
movsd %xmm2, (%r14,%rdx,8)
incq %rdx
jmp 0x156cf
movq (%r13,%r8,8), %rax
xorl %ecx, %ecx
movq 0x48(%rsp), %r13
cmpq $0x4, %rcx
je 0x15780
andq $0x0, (%r14,%rcx,8)
xorpd %xmm0, %xmm0
xorl %edx, %edx
cmpq $0x4, %rdx
je 0x1577b
movsd (%rax,%rdx,8), %xmm1
movq (%r12,%rdx,8), %rsi
mulsd (%rsi,%rcx,8), %xmm1
addsd %xmm1, %xmm0
movsd %xmm0, (%r14,%rcx,8)
incq %rdx
jmp 0x15758
incq %rcx
jmp 0x15747
xorpd %xmm2, %xmm2
xorl %ebx, %ebx
movl 0x5c(%rsp), %r12d
cmpq $0x4, %rbx
je 0x157e6
cmpq %rbx, %r15
je 0x157e1
movsd (%r14,%rbx,8), %xmm0
movsd 0x990c(%rip), %xmm1     # 0x1f0b0
subsd %xmm2, %xmm1
divsd %xmm1, %xmm0
movl %r12d, %edi
movq 0xb8(%rsp), %rsi
movsd %xmm2, 0x28(%rsp)
callq 0x13e47
movsd 0x28(%rsp), %xmm2
movsd 0x50(%rsp), %xmm5
movsd 0x10(%rsp), %xmm4
addl %eax, (%rbp,%rbx,4)
subl %eax, %r12d
addsd (%r14,%rbx,8), %xmm2
incq %rbx
jmp 0x1578b
movl 0x3c(%rsp), %ecx
movq 0x60(%rsp), %r8
addl %r12d, (%rbp,%r8,4)
movd %r15d, %xmm0
movq 0x18(%rsp), %rax
movd %eax, %xmm1
punpckldq %xmm0, %xmm1    # xmm1 = xmm1[0],xmm0[0],xmm1[1],xmm0[1]
paddd 0x9872(%rip), %xmm1     # 0x1f080
movl %ecx, (%r13)
movq %rbp, 0x8(%r13)
pand 0x9872(%rip), %xmm1     # 0x1f090
movl %eax, 0x18(%r13)
pcmpeqd 0x9836(%rip), %xmm1     # 0x1f060
pandn 0x986e(%rip), %xmm1     # 0x1f0a0
movl %r15d, 0x1c(%r13)
movq %xmm1, 0x20(%r13)
movsd %xmm4, 0x28(%r13)
movsd %xmm5, 0x30(%r13)
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rdx, 0x40(%rsp)
jmp 0x15492