// File: /workspace/github_c_makefile_star2_O3/dapogon[P]cellcoal/src/cellcoal.c
// Function: SimulateMk2forSite
void SimulateMk2forSite (TreeNode *p, int genome, int site, long int *seed)
    {
    double	probOfChange, uniform, branchLength;
    int     cell, anccell;
		
    if (p != NULL)
		{
		if (p->isHealthyRoot == NO)
			{
			cell = p->label;
			anccell = p->anc->label;
			
			if (doUserTree == YES)
				branchLength = p->branchLength;
			else
				{
				if (rateVarAmongSites == YES)
					branchLength = altModelMutationRate * p->length * allSites[site].rateMultiplier;
				else
					branchLength = altModelMutationRate * p->length;
				}
	
			probOfChange = 0.5 - 0.5 * exp (-2.0 * branchLength);

			uniform = RandomUniform(seed);
			if (uniform >= probOfChange) /* => no change */
				data[genome][cell][site] = data[genome][anccell][site];
			else /* => there will be change */
				{
				if (data[genome][anccell][site] == 0)
					data[genome][cell][site] = 1;
				else
					data[genome][cell][site] = 0;
					
				if (genome == MATERNAL)
					allSites[site].numMutationsMaternal++;
				else if (genome == PATERNAL)
					allSites[site].numMutationsPaternal++;
				allSites[site].numMutations++;
				numMU++;
				}
			}
		SimulateMk2forSite (p->left,  genome, site, seed);
		SimulateMk2forSite (p->right, genome, site, seed);
		}
	}

// Assembly:
testq %rdi, %rdi
je 0x17f97
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rcx, %rbx
movl %edx, %ebp
movl %esi, %r14d
movq %rdi, %r15
movslq %edx, %rcx
movq %rcx, 0x10(%rsp)
movl %esi, %eax
movq %rax, 0x8(%rsp)
movq %rcx, %rax
shlq $0x7, %rax
leaq (%rax,%rcx,8), %r12
movq %r12, (%rsp)
cmpl $0x0, 0x24(%r15)
jne 0x17f6c
cmpb $0x1, 0x1e536(%rip)     # 0x36384
jne 0x17e58
movsd 0x40(%r15), %xmm0
jmp 0x17e80
movsd 0x1e738(%rip), %xmm0    # 0x36598
mulsd 0x30(%r15), %xmm0
cmpb $0x1, 0x1e4f3(%rip)     # 0x36360
jne 0x17e80
movq 0x1f74a(%rip), %rax     # 0x375c0
mulsd 0x80(%rax,%r12), %xmm0
movslq 0x1c(%r15), %r13
movq 0x10(%r15), %rax
movslq 0x1c(%rax), %r12
mulsd 0xb2d4(%rip), %xmm0     # 0x23168
callq 0x22d0
mulsd 0xb2b7(%rip), %xmm0     # 0x23158
addsd 0xb26f(%rip), %xmm0     # 0x23118
movq (%rbx), %rcx
movq %rcx, %rax
movabsq $0x41a705af1fe3fb79, %rdx # imm = 0x41A705AF1FE3FB79
imulq %rdx
movq %rdx, %rax
shrq $0x3f, %rax
sarq $0xf, %rdx
addq %rax, %rdx
imulq $0x1f31d, %rdx, %rax    # imm = 0x1F31D
subq %rax, %rcx
imulq $0x41a7, %rcx, %rax     # imm = 0x41A7
imulq $-0xb14, %rdx, %rcx     # imm = 0xF4EC
leaq (%rcx,%rax), %rdx
testq %rdx, %rdx
leaq 0x7fffffff(%rcx,%rax), %rax
cmovgq %rdx, %rax
xorps %xmm1, %xmm1
cvtsi2sd %rax, %xmm1
movq %rax, (%rbx)
divsd 0xb218(%rip), %xmm1     # 0x23120
ucomisd %xmm0, %xmm1
movq 0x1f6a5(%rip), %rax     # 0x375b8
movq 0x8(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movq (%rax,%r12,8), %rcx
movq 0x10(%rsp), %rsi
movl (%rcx,%rsi,4), %ecx
jae 0x17f4f
xorl %edx, %edx
testl %ecx, %ecx
sete %dl
movq (%rax,%r13,8), %rax
movl %edx, (%rax,%rsi,4)
movq 0x1f681(%rip), %rax     # 0x375c0
testl %r14d, %r14d
movq (%rsp), %r12
je 0x17f5c
incl 0x14(%rax,%r12)
jmp 0x17f61
movq (%rax,%r13,8), %rax
movl %ecx, (%rax,%rsi,4)
movq (%rsp), %r12
jmp 0x17f6c
incl 0x10(%rax,%r12)
incl 0xc(%rax,%r12)
incl 0x1f614(%rip)           # 0x37580
movq (%r15), %rdi
movl %r14d, %esi
movl %ebp, %edx
movq %rbx, %rcx
callq 0x17dfc
movq 0x8(%r15), %r15
testq %r15, %r15
jne 0x17e3c
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq