// File: /workspace/github_c_makefile_star2_O2/dapogon[P]cellcoal/src/cellcoal.c
// Function: SimulateFiniteDNAforSite
void SimulateFiniteDNAforSite (TreeNode *p, int genome, int site, long int *seed)
	{
    double	branchLength, Pij[4][4];
    int     cell, anccell, ancstate, newstate;
		
    if (p != NULL)
        {
		if (p->isHealthyRoot == NO)
			{
			cell = p->label;
			anccell = p->anc->label;
			ancstate = data[genome][anccell][site];
	
			if (doUserTree == YES)
				branchLength = p->branchLength;
			else
				{
				if (rateVarAmongSites == YES)
					branchLength = altModelMutationRate * p->length * allSites[site].rateMultiplier;
				else
					branchLength = altModelMutationRate * p->length;
				}
				
			FillSubstitutionMatrix (Pij, branchLength);
			newstate = data[genome][cell][site] = ChooseUniformState (Pij[ancstate], seed);
			
			if (newstate != ancstate)
				{
				if (genome == MATERNAL)
					allSites[site].numMutationsMaternal++;
				else if (genome == PATERNAL)
					allSites[site].numMutationsPaternal++;
				allSites[site].numMutations++;
				numMU++;
				}
			}
		SimulateFiniteDNAforSite (p->left,  genome, site, seed);
        SimulateFiniteDNAforSite (p->right, genome, site, seed);
        }
 	}

// Assembly:
testq %rdi, %rdi
je 0x1464f
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x138, %rsp            # imm = 0x138
movq %rcx, %rbx
movl %edx, %ebp
movl %esi, %r14d
movq %rdi, %r15
cmpl $0x0, 0x24(%rdi)
jne 0x14b94
movq 0x10(%r15), %rax
movslq 0x1c(%rax), %rax
movq 0x1cf8d(%rip), %rcx     # 0x315b8
movl %r14d, %edx
movq %rdx, 0x58(%rsp)
movq (%rcx,%rdx,8), %rcx
movq (%rcx,%rax,8), %rax
movslq %ebp, %rsi
cmpb $0x1, 0x1bd3f(%rip)     # 0x30384
jne 0x14650
movsd 0x40(%r15), %xmm1
jmp 0x1467e
retq
movsd 0x1bf40(%rip), %xmm1    # 0x30598
mulsd 0x30(%r15), %xmm1
cmpb $0x1, 0x1bcfb(%rip)     # 0x30360
jne 0x1467e
movq 0x1cf52(%rip), %rcx     # 0x315c0
imulq $0x88, %rsi, %rdx
mulsd 0x80(%rcx,%rdx), %xmm1
movslq 0x1c(%r15), %rcx
movq %rcx, 0x48(%rsp)
movslq (%rax,%rsi,4), %rax
movq %rax, 0x50(%rsp)
movsd 0xaa90(%rip), %xmm0     # 0x1f128
ucomisd %xmm1, %xmm0
movq %rbx, 0x70(%rsp)
movl %ebp, 0x2c(%rsp)
movl %r14d, 0x28(%rsp)
movq %r15, 0x68(%rsp)
movq %rsi, 0x60(%rsp)
jbe 0x146fa
leaq 0xb0(%rsp), %rax
xorl %ecx, %ecx
movsd 0xa9e8(%rip), %xmm0     # 0x1f0b0
cmpq $0x4, %rcx
je 0x14b0e
xorl %edx, %edx
cmpq $0x4, %rdx
je 0x146f1
movapd %xmm0, %xmm1
cmpq %rdx, %rcx
je 0x146e7
xorpd %xmm1, %xmm1
movsd %xmm1, (%rax,%rdx,8)
incq %rdx
jmp 0x146d4
incq %rcx
addq $0x20, %rax
jmp 0x146c8
cmpb $0x1, 0x1bc4f(%rip)     # 0x30350
jne 0x14779
xorpd 0xa945(%rip), %xmm1     # 0x1f050
leaq 0xb0(%rsp), %rbx
xorl %r14d, %r14d
leaq 0xa953(%rip), %r15      # 0x1f070
movapd %xmm1, 0x30(%rsp)
cmpq $0x4, %r14
je 0x14b0e
xorl %r12d, %r12d
cmpq $0x4, %r12
je 0x14770
xorl %r13d, %r13d
cmpq %r12, %r14
sete %r13b
movsd 0x1d098(%rip), %xmm0    # 0x317e0
mulsd %xmm1, %xmm0
callq 0x22d0
movapd 0x30(%rsp), %xmm1
mulsd (%r15,%r13,8), %xmm0
addsd 0xa9cb(%rip), %xmm0     # 0x1f130
movsd %xmm0, (%rbx,%r12,8)
incq %r12
jmp 0x14730
incq %r14
addq $0x20, %rbx
jmp 0x14723
cmpb $0x1, 0x1bbd4(%rip)     # 0x30354
movapd %xmm1, 0x30(%rsp)
jne 0x14a46
leaq 0xb0(%rsp), %r13
xorl %r12d, %r12d
leaq 0x1ba72(%rip), %rbp     # 0x30210
movsd 0xa94a(%rip), %xmm0     # 0x1f0f0
cmpq $0x4, %r12
je 0x14b0e
movq %r12, %rax
shlq $0x5, %rax
addq %rsp, %rax
addq $0xb0, %rax
leaq (%rax,%r12,8), %r15
movq %r12, %rax
xorq $0x3, %rax
movq %rax, 0x88(%rsp)
movq %r12, %rax
xorq $0x2, %rax
movq %rax, 0x80(%rsp)
movq %r12, %rax
xorq $0x1, %rax
movq %rax, 0x78(%rsp)
movq %rbp, %rbx
xorl %r14d, %r14d
cmpq $0x4, %r14
je 0x14a3a
testb $0x1, %r14b
leaq 0x1cfe7(%rip), %rax     # 0x317f0
leaq 0x1cfd8(%rip), %rcx     # 0x317e8
cmoveq %rcx, %rax
movsd (%rax), %xmm4
movsd 0x1cfd8(%rip), %xmm3    # 0x317f8
addsd %xmm0, %xmm3
mulsd %xmm4, %xmm3
movsd 0xa880(%rip), %xmm2     # 0x1f0b0
addsd %xmm2, %xmm3
divsd %xmm4, %xmm2
cmpq %r14, %r12
jne 0x148ed
movsd (%rbp,%r12,8), %xmm5
movsd %xmm5, 0x18(%rsp)
addsd %xmm0, %xmm2
mulsd %xmm5, %xmm2
movsd %xmm2, 0x8(%rsp)
movsd 0x1cf7c(%rip), %xmm0    # 0x317e0
movapd 0xa7e4(%rip), %xmm2     # 0x1f050
xorpd %xmm2, %xmm0
mulsd %xmm1, %xmm0
movsd %xmm3, 0x20(%rsp)
movsd %xmm4, 0x10(%rsp)
callq 0x22d0
mulsd 0x8(%rsp), %xmm0
addsd 0x18(%rsp), %xmm0
movsd %xmm0, 0x8(%rsp)
movsd 0x10(%rsp), %xmm1
movapd %xmm1, %xmm0
subsd (%rbp,%r12,8), %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, 0x10(%rsp)
movsd 0x1cf26(%rip), %xmm1    # 0x317e0
xorpd 0xa78e(%rip), %xmm1     # 0x1f050
mulsd 0x30(%rsp), %xmm1
movsd 0x20(%rsp), %xmm0
mulsd %xmm1, %xmm0
callq 0x22d0
mulsd 0x10(%rsp), %xmm0
addsd 0x8(%rsp), %xmm0
movsd %xmm0, (%r15)
jmp 0x14a20
movq %r14, %rax
xorq $0x2, %rax
orq %r12, %rax
jne 0x149a2
movsd (%rbx), %xmm5
movsd %xmm5, 0x18(%rsp)
addsd %xmm0, %xmm2
mulsd %xmm5, %xmm2
movsd %xmm2, 0x8(%rsp)
movsd 0x1cec3(%rip), %xmm0    # 0x317e0
movapd 0xa72b(%rip), %xmm2     # 0x1f050
xorpd %xmm2, %xmm0
mulsd %xmm1, %xmm0
movsd %xmm3, 0x20(%rsp)
movsd %xmm4, 0x10(%rsp)
callq 0x22d0
mulsd 0x8(%rsp), %xmm0
addsd 0x18(%rsp), %xmm0
movsd %xmm0, 0x8(%rsp)
movsd (%rbx), %xmm0
movsd %xmm0, 0x18(%rsp)
movsd 0x1ce7e(%rip), %xmm1    # 0x317e0
xorpd 0xa6e6(%rip), %xmm1     # 0x1f050
mulsd 0x30(%rsp), %xmm1
movsd 0x20(%rsp), %xmm0
mulsd %xmm1, %xmm0
callq 0x22d0
movsd 0x18(%rsp), %xmm1
divsd 0x10(%rsp), %xmm1
mulsd %xmm0, %xmm1
movsd 0x8(%rsp), %xmm0
subsd %xmm1, %xmm0
movsd %xmm0, (%r13,%r14,8)
jmp 0x14a20
movq %r14, %rax
xorq $0x3, %rax
orq 0x78(%rsp), %rax
sete %cl
movq 0x80(%rsp), %rax
orq %r14, %rax
sete %al
movq %r14, %rdx
xorq $0x1, %rdx
orq 0x88(%rsp), %rdx
je 0x148fd
testb %cl, %cl
jne 0x148fd
testb %al, %al
jne 0x148fd
movsd (%rbx), %xmm0
movsd %xmm0, 0x10(%rsp)
movsd 0x1cdea(%rip), %xmm0    # 0x317e0
xorpd 0xa652(%rip), %xmm0     # 0x1f050
mulsd %xmm1, %xmm0
callq 0x22d0
movsd 0xa6a1(%rip), %xmm1     # 0x1f0b0
subsd %xmm0, %xmm1
mulsd 0x10(%rsp), %xmm1
movsd %xmm1, (%r13,%r14,8)
incq %r14
addq $0x8, %rbx
movapd 0x30(%rsp), %xmm1
movsd 0xa6bb(%rip), %xmm0     # 0x1f0f0
jmp 0x147f4
incq %r12
addq $0x20, %r13
jmp 0x147a6
cmpb $0x0, 0x1b90b(%rip)     # 0x30358
jne 0x14a5c
cmpb $0x1, 0x1b906(%rip)     # 0x3035c
jne 0x14b0e
pushq $0x1
popq %rbx
leaq 0x1cd9a(%rip), %r14     # 0x31800
cmpq $0x4, %rbx
je 0x14a8f
movsd (%r14,%rbx,8), %xmm0
mulsd %xmm1, %xmm0
callq 0x22d0
movapd 0x30(%rsp), %xmm1
movsd %xmm0, 0x90(%rsp,%rbx,8)
incq %rbx
jmp 0x14a66
leaq 0x1cd8a(%rip), %rax     # 0x31820
xorl %ecx, %ecx
pushq $0x1
popq %rdx
movq %rax, %rsi
cmpq $0x4, %rcx
je 0x14b0e
movq %rcx, %rdi
shlq $0x4, %rdi
movq %rcx, %r8
shlq $0x5, %r8
addq %rsp, %r8
addq $0xb0, %r8
movq %rsi, %r9
xorl %r10d, %r10d
cmpq $0x4, %r10
je 0x14b05
leaq (%rdi,%r10,4), %r11
movsd (%rax,%r11,8), %xmm0
leaq (%r8,%r10,8), %r11
movq %rdx, %rbx
cmpq $0x4, %rbx
je 0x14af7
movsd (%r9,%rbx,8), %xmm1
mulsd 0x90(%rsp,%rbx,8), %xmm1
addsd %xmm1, %xmm0
incq %rbx
jmp 0x14ad9
movsd %xmm0, (%r11)
incq %r10
addq $0x20, %r9
jmp 0x14ac2
incq %rcx
subq $-0x80, %rsi
jmp 0x14a9e
movq 0x50(%rsp), %r14
movq %r14, %rax
shlq $0x5, %rax
leaq (%rsp,%rax), %rdi
addq $0xb0, %rdi
movq 0x70(%rsp), %rbx
movq %rbx, %rsi
callq 0x138c8
movq 0x1ca7f(%rip), %rcx     # 0x315b8
movq 0x58(%rsp), %rdx
movq (%rcx,%rdx,8), %rcx
movq 0x48(%rsp), %rdx
movq (%rcx,%rdx,8), %rcx
movq 0x60(%rsp), %rdx
movl %eax, (%rcx,%rdx,4)
cmpl %r14d, %eax
movl 0x2c(%rsp), %ebp
movl 0x28(%rsp), %r14d
movq 0x68(%rsp), %r15
je 0x14b94
movq 0x1ca53(%rip), %rax     # 0x315c0
imulq $0x88, %rdx, %rcx
testl %r14d, %r14d
je 0x14b7f
incl 0x14(%rax,%rcx)
jmp 0x14b83
incl 0x10(%rax,%rcx)
imulq $0x88, %rdx, %rcx
incl 0xc(%rax,%rcx)
incl 0x1c9ec(%rip)           # 0x31580
movq (%r15), %rdi
movl %r14d, %esi
movl %ebp, %edx
movq %rbx, %rcx
callq 0x145f1
movq 0x8(%r15), %rdi
movl %r14d, %esi
movl %ebp, %edx
movq %rbx, %rcx
addq $0x138, %rsp            # imm = 0x138
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x145f1