// File: /workspace/github_c_makefile_star2_O1/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:
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
movl %esi, %eax
movq %rax, 0x10(%rsp)
movslq %edx, %rcx
movq %rcx, 0x8(%rsp)
movq %rcx, %rax
shlq $0x7, %rax
leaq (%rax,%rcx,8), %r12
movq %r12, (%rsp)
testq %r15, %r15
je 0x17c0d
cmpl $0x0, 0x24(%r15)
jne 0x17bf4
cmpb $0x1, 0x2a8b5(%rip)     # 0x42384
jne 0x17ad9
movsd 0x40(%r15), %xmm0
jmp 0x17b01
movsd 0x2aab7(%rip), %xmm0    # 0x42598
mulsd 0x30(%r15), %xmm0
cmpb $0x1, 0x2a872(%rip)     # 0x42360
jne 0x17b01
movq 0x2bac9(%rip), %rax     # 0x435c0
mulsd 0x80(%rax,%r12), %xmm0
movslq 0x1c(%r15), %r13
movq 0x10(%r15), %rax
movslq 0x1c(%rax), %r12
mulsd 0x1c55b(%rip), %xmm0    # 0x34070
callq 0x22d0
mulsd 0x1c53e(%rip), %xmm0    # 0x34060
addsd 0x1c4f6(%rip), %xmm0    # 0x34020
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 0x1c49f(%rip), %xmm1    # 0x34028
ucomisd %xmm0, %xmm1
movq 0x2ba24(%rip), %rax     # 0x435b8
movq 0x10(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movq (%rax,%r12,8), %rcx
movq 0x8(%rsp), %rsi
movl (%rcx,%rsi,4), %ecx
jae 0x17bd0
xorl %edx, %edx
testl %ecx, %ecx
sete %dl
movq (%rax,%r13,8), %rax
movl %edx, (%rax,%rsi,4)
movq 0x2ba00(%rip), %rax     # 0x435c0
testl %r14d, %r14d
movq (%rsp), %r12
je 0x17bdd
incl 0x14(%rax,%r12)
jmp 0x17be2
movq (%rax,%r13,8), %rax
movl %ecx, (%rax,%rsi,4)
movq (%rsp), %r12
jmp 0x17bf4
incl 0x10(%rax,%r12)
movq 0x2b9d7(%rip), %rax     # 0x435c0
incl 0xc(%rax,%r12)
incl 0x2b98c(%rip)           # 0x43580
movq (%r15), %rdi
movl %r14d, %esi
movl %ebp, %edx
movq %rbx, %rcx
callq 0x17a7d
movq 0x8(%r15), %r15
jmp 0x17ab4
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq