// File: /workspace/github_c_makefile_star2_O3/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 0x17ff6
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x128, %rsp            # imm = 0x128
movq %rcx, %rbx
movl %edx, %ebp
movl %esi, %r14d
movq %rdi, %r15
cmpl $0x0, 0x24(%rdi)
jne 0x1856a
movq 0x10(%r15), %rax
movslq 0x1c(%rax), %rax
movq 0x1f5e6(%rip), %rcx     # 0x375b8
movl %r14d, %edi
movq (%rcx,%rdi,8), %rcx
movq (%rcx,%rax,8), %rax
movslq %ebp, %rsi
cmpb $0x1, 0x1e39d(%rip)     # 0x36384
movq %rbx, 0x60(%rsp)
jne 0x17ff7
movsd 0x40(%r15), %xmm1
jmp 0x1802d
retq
movsd 0x1e599(%rip), %xmm0    # 0x36598
mulsd 0x30(%r15), %xmm0
cmpb $0x1, 0x1e354(%rip)     # 0x36360
jne 0x18029
movq 0x1f5ab(%rip), %rcx     # 0x375c0
movq %rsi, %rdx
shlq $0x7, %rdx
leaq (%rdx,%rsi,8), %rdx
mulsd 0x80(%rcx,%rdx), %xmm0
movapd %xmm0, %xmm1
movslq 0x1c(%r15), %rcx
movslq (%rax,%rsi,4), %rax
movsd 0xb13b(%rip), %xmm0     # 0x23178
ucomisd %xmm1, %xmm0
movl %ebp, 0x34(%rsp)
movl %r14d, 0x30(%rsp)
movq %r15, 0x58(%rsp)
movq %rsi, 0x50(%rsp)
movq %rdi, 0x48(%rsp)
movq %rax, 0x40(%rsp)
movq %rcx, 0x38(%rsp)
jbe 0x180d1
leaq 0xa0(%rsp), %rax
xorl %ecx, %ecx
movdqa 0xafe9(%rip), %xmm0     # 0x23060
movdqa 0xafa1(%rip), %xmm1     # 0x23020
movdqa 0xaff9(%rip), %xmm2     # 0x23080
movq %rcx, %xmm3
pshufd $0x44, %xmm3, %xmm3     # xmm3 = xmm3[0,1,0,1]
xorl %edx, %edx
movdqa %xmm0, %xmm4
movdqa %xmm3, %xmm5
pcmpeqd %xmm4, %xmm5
pshufd $0xb1, %xmm5, %xmm6     # xmm6 = xmm5[1,0,3,2]
pand %xmm5, %xmm6
pand %xmm1, %xmm6
movdqa %xmm6, (%rax,%rdx,8)
addq $0x2, %rdx
paddq %xmm2, %xmm4
cmpq $0x4, %rdx
jne 0x18097
incq %rcx
addq $0x20, %rax
cmpq $0x4, %rcx
jne 0x18087
jmp 0x184dc
movapd %xmm1, %xmm0
cmpb $0x1, 0x1e274(%rip)     # 0x36350
jne 0x18151
xorpd 0xaf5a(%rip), %xmm0     # 0x23040
movapd %xmm0, 0x20(%rsp)
leaq 0xa0(%rsp), %rbx
xorl %r14d, %r14d
leaq 0xafc2(%rip), %r15      # 0x230c0
xorl %r12d, %r12d
xorl %r13d, %r13d
cmpq %r12, %r14
sete %r13b
movsd 0x1f6cd(%rip), %xmm0    # 0x377e0
mulsd 0x20(%rsp), %xmm0
callq 0x22d0
movsd 0xb05a(%rip), %xmm1     # 0x23180
mulsd (%r15,%r13,8), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, (%rbx,%r12,8)
incq %r12
cmpq $0x4, %r12
jne 0x18101
incq %r14
addq $0x20, %rbx
cmpq $0x4, %r14
jne 0x180fe
jmp 0x184dc
movapd %xmm0, 0x20(%rsp)
cmpb $0x1, 0x1e1f6(%rip)     # 0x36354
jne 0x1841d
leaq 0xa0(%rsp), %r13
xorl %r12d, %r12d
leaq 0x1e09a(%rip), %rbp     # 0x36210
movsd 0xafc2(%rip), %xmm0     # 0x23140
movsd 0xaf7a(%rip), %xmm2     # 0x23100
movq %r12, %rax
shlq $0x5, %rax
addq %rsp, %rax
addq $0xa0, %rax
leaq (%rax,%r12,8), %r15
movq %r12, %rax
xorq $0x3, %rax
movq %rax, 0x78(%rsp)
movq %r12, %rax
xorq $0x2, %rax
movq %rax, 0x70(%rsp)
movq %r12, %rax
xorq $0x1, %rax
movq %rax, 0x68(%rsp)
movq %rbp, %rbx
xorl %r14d, %r14d
testb $0x1, %r14b
leaq 0x1f621(%rip), %rax     # 0x377f0
leaq 0x1f612(%rip), %rcx     # 0x377e8
cmoveq %rcx, %rax
movsd (%rax), %xmm3
movsd 0x1f612(%rip), %xmm1    # 0x377f8
addsd %xmm0, %xmm1
mulsd %xmm3, %xmm1
addsd %xmm2, %xmm1
cmpq %r14, %r12
jne 0x182b1
movsd (%rbp,%r12,8), %xmm4
movsd %xmm4, (%rsp)
divsd %xmm3, %xmm2
addsd %xmm0, %xmm2
mulsd %xmm4, %xmm2
movsd %xmm2, 0x8(%rsp)
movsd 0x1f5bf(%rip), %xmm0    # 0x377e0
movsd %xmm1, 0x18(%rsp)
movapd 0xae11(%rip), %xmm1     # 0x23040
xorpd %xmm1, %xmm0
mulsd 0x20(%rsp), %xmm0
movsd %xmm3, 0x10(%rsp)
callq 0x22d0
mulsd 0x8(%rsp), %xmm0
addsd (%rsp), %xmm0
movsd %xmm0, (%rsp)
movsd 0x10(%rsp), %xmm1
movapd %xmm1, %xmm0
subsd (%rbp,%r12,8), %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, 0x10(%rsp)
movsd 0x1f569(%rip), %xmm1    # 0x377e0
xorpd 0xadc1(%rip), %xmm1     # 0x23040
mulsd 0x20(%rsp), %xmm1
movsd 0x18(%rsp), %xmm0
mulsd %xmm1, %xmm0
callq 0x22d0
movsd 0xae64(%rip), %xmm2     # 0x23100
mulsd 0x10(%rsp), %xmm0
addsd (%rsp), %xmm0
movsd %xmm0, (%r15)
jmp 0x183ee
movq %r14, %rax
xorq $0x2, %rax
orq %r12, %rax
jne 0x18370
movsd (%rbx), %xmm4
movsd %xmm4, (%rsp)
divsd %xmm3, %xmm2
addsd %xmm0, %xmm2
mulsd %xmm4, %xmm2
movsd %xmm2, 0x8(%rsp)
movsd 0x1f4fc(%rip), %xmm0    # 0x377e0
movsd %xmm1, 0x18(%rsp)
movapd 0xad4e(%rip), %xmm1     # 0x23040
xorpd %xmm1, %xmm0
mulsd 0x20(%rsp), %xmm0
movsd %xmm3, 0x10(%rsp)
callq 0x22d0
mulsd 0x8(%rsp), %xmm0
addsd (%rsp), %xmm0
movsd %xmm0, (%rsp)
movsd (%rbx), %xmm0
movsd %xmm0, 0x8(%rsp)
movsd 0x1f4b7(%rip), %xmm1    # 0x377e0
xorpd 0xad0f(%rip), %xmm1     # 0x23040
mulsd 0x20(%rsp), %xmm1
movsd 0x18(%rsp), %xmm0
mulsd %xmm1, %xmm0
callq 0x22d0
movsd 0xadb2(%rip), %xmm2     # 0x23100
movsd 0x8(%rsp), %xmm1
divsd 0x10(%rsp), %xmm1
mulsd %xmm0, %xmm1
movsd (%rsp), %xmm0
subsd %xmm1, %xmm0
movsd %xmm0, (%r13,%r14,8)
jmp 0x183ee
movq %r14, %rax
xorq $0x3, %rax
orq 0x68(%rsp), %rax
sete %cl
movq 0x70(%rsp), %rax
orq %r14, %rax
sete %al
movq %r14, %rdx
xorq $0x1, %rdx
orq 0x78(%rsp), %rdx
je 0x182c1
testb %cl, %cl
jne 0x182c1
testb %al, %al
jne 0x182c1
movsd (%rbx), %xmm0
movsd %xmm0, 0x18(%rsp)
movsd 0x1f422(%rip), %xmm0    # 0x377e0
xorpd 0xac7a(%rip), %xmm0     # 0x23040
mulsd 0x20(%rsp), %xmm0
callq 0x22d0
movsd 0xad27(%rip), %xmm2     # 0x23100
movapd %xmm2, %xmm1
subsd %xmm0, %xmm1
mulsd 0x18(%rsp), %xmm1
movsd %xmm1, (%r13,%r14,8)
incq %r14
addq $0x8, %rbx
cmpq $0x4, %r14
movsd 0xad3f(%rip), %xmm0     # 0x23140
jne 0x181c4
incq %r12
addq $0x20, %r13
cmpq $0x4, %r12
jne 0x18186
jmp 0x184dc
cmpb $0x0, 0x1df34(%rip)     # 0x36358
jne 0x18433
cmpb $0x1, 0x1df2f(%rip)     # 0x3635c
jne 0x184dc
movl $0x1, %ebx
leaq 0x1f3c1(%rip), %r14     # 0x37800
movsd (%r14,%rbx,8), %xmm0
mulsd 0x20(%rsp), %xmm0
callq 0x22d0
movsd %xmm0, 0x80(%rsp,%rbx,8)
incq %rbx
cmpq $0x4, %rbx
jne 0x1843f
leaq 0x1f3b7(%rip), %rax     # 0x37820
xorl %ecx, %ecx
movq %rax, %rdx
movq %rcx, %rsi
shlq $0x4, %rsi
movq %rcx, %rdi
shlq $0x5, %rdi
addq %rsp, %rdi
addq $0xa0, %rdi
movq %rdx, %r8
xorl %r9d, %r9d
leaq (%rsi,%r9,4), %r10
movsd (%rax,%r10,8), %xmm0
leaq (%rdi,%r9,8), %r10
movl $0x1, %r11d
movsd (%r8,%r11,8), %xmm1
mulsd 0x80(%rsp,%r11,8), %xmm1
addsd %xmm1, %xmm0
incq %r11
cmpq $0x4, %r11
jne 0x184a0
movsd %xmm0, (%r10)
incq %r9
addq $0x20, %r8
cmpq $0x4, %r9
jne 0x1848c
incq %rcx
subq $-0x80, %rdx
cmpq $0x4, %rcx
jne 0x1846e
movq 0x40(%rsp), %r14
movq %r14, %rax
shlq $0x5, %rax
leaq (%rsp,%rax), %rdi
addq $0xa0, %rdi
movq 0x60(%rsp), %rbx
movq %rbx, %rsi
callq 0x17041
movq 0x1f0b1(%rip), %rcx     # 0x375b8
movq 0x48(%rsp), %rdx
movq (%rcx,%rdx,8), %rcx
movq 0x38(%rsp), %rdx
movq (%rcx,%rdx,8), %rcx
movq 0x50(%rsp), %rdx
movl %eax, (%rcx,%rdx,4)
cmpl %r14d, %eax
movl 0x34(%rsp), %ebp
movl 0x30(%rsp), %r14d
movq 0x58(%rsp), %r15
je 0x1856a
movq 0x1f085(%rip), %rax     # 0x375c0
movq %rdx, %rcx
shlq $0x7, %rcx
leaq (%rcx,%rdx,8), %rcx
testl %r14d, %r14d
je 0x18551
incl 0x14(%rax,%rcx)
jmp 0x18555
incl 0x10(%rax,%rcx)
movq %rdx, %rcx
shlq $0x7, %rcx
leaq (%rcx,%rdx,8), %rcx
incl 0xc(%rax,%rcx)
incl 0x1f016(%rip)           # 0x37580
movq (%r15), %rdi
movl %r14d, %esi
movl %ebp, %edx
movq %rbx, %rcx
callq 0x17f98
movq 0x8(%r15), %rdi
movl %r14d, %esi
movl %ebp, %edx
movq %rbx, %rcx
addq $0x128, %rsp            # imm = 0x128
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x17f98