// File: /workspace/github_c_makefile_star2_O0/dapogon[P]cellcoal/src/cellcoal.c
// Function: SimulateISMDNAforSite
void SimulateISMDNAforSite (TreeNode *p, int genome, int site, int doISMhaploid, long int *seed)
	{
    static double	cumBranchLength, uniform, ran;
    int             j, cell, anccell, ancstate;
	
    if (p != NULL)
        {
        cell = p->label;
			
        if (p->isHealthyRoot == YES)
            {
            cumBranchLength = 0;
            uniform = RandomUniform(seed) * totalTreeLength;
            }
        else
            {
            anccell = p->anc->label;
            ancstate = data[genome][anccell][site];
            cumBranchLength += p->branchLength;
				
            if ((cumBranchLength < uniform) || /* => there will be no change */
                ((doISMhaploid == NO)  && (allSites[site].numMutations > 0))  ||
                ((doISMhaploid == YES) && (genome == MATERNAL) && (allSites[site].numMutationsMaternal > 0)) ||
                ((doISMhaploid == YES) && (genome == PATERNAL) && (allSites[site].numMutationsPaternal > 0)))
                {
                data[genome][cell][site] = ancstate;
                }
            else /* => there will be change */
                {
                ran = RandomUniform(seed) * cumMij[ancstate][3];
                for (j=0; j<4; j++)
                    {
                    if (ran <= cumMij[ancstate][j])
                        {
                        data[genome][cell][site] = j;
                        break;
                        }
					}
                if (genome == MATERNAL)
                    allSites[site].numMutationsMaternal++;
                else if (genome == PATERNAL)
                    allSites[site].numMutationsPaternal++;
                allSites[site].numMutations++;
                numMU++;
 				}
            }
        SimulateISMDNAforSite (p->left, genome, site, doISMhaploid, seed);
        SimulateISMDNAforSite (p->right, genome, site, doISMhaploid, seed);
		}
	}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movl %ecx, -0x14(%rbp)
movq %r8, -0x20(%rbp)
cmpq $0x0, -0x8(%rbp)
je 0x1bde0
movq -0x8(%rbp), %rax
movl 0x1c(%rax), %eax
movl %eax, -0x28(%rbp)
movq -0x8(%rbp), %rax
cmpl $0x1, 0x24(%rax)
jne 0x1bbb1
xorps %xmm0, %xmm0
movsd %xmm0, 0x33e55(%rip)    # 0x4f9e8
movq -0x20(%rbp), %rdi
callq 0xa500
mulsd 0x33be4(%rip), %xmm0    # 0x4f788
movsd %xmm0, 0x33e44(%rip)    # 0x4f9f0
jmp 0x1bdad
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movl 0x1c(%rax), %eax
movl %eax, -0x2c(%rbp)
movq 0x33bda(%rip), %rax     # 0x4f7a0
movslq -0xc(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x2c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x10(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x30(%rbp)
movq -0x8(%rbp), %rax
movsd 0x40(%rax), %xmm0
addsd 0x33df7(%rip), %xmm0    # 0x4f9e8
movsd %xmm0, 0x33def(%rip)    # 0x4f9e8
movsd 0x33de7(%rip), %xmm1    # 0x4f9e8
movsd 0x33de7(%rip), %xmm0    # 0x4f9f0
ucomisd %xmm1, %xmm0
ja 0x1bc7e
cmpl $0x0, -0x14(%rbp)
jne 0x1bc30
movq 0x33b8c(%rip), %rax     # 0x4f7a8
movslq -0x10(%rbp), %rcx
imulq $0x88, %rcx, %rcx
addq %rcx, %rax
cmpl $0x0, 0xc(%rax)
jg 0x1bc7e
cmpl $0x1, -0x14(%rbp)
jne 0x1bc57
cmpl $0x0, -0xc(%rbp)
jne 0x1bc57
movq 0x33b65(%rip), %rax     # 0x4f7a8
movslq -0x10(%rbp), %rcx
imulq $0x88, %rcx, %rcx
addq %rcx, %rax
cmpl $0x0, 0x10(%rax)
jg 0x1bc7e
cmpl $0x1, -0x14(%rbp)
jne 0x1bca4
cmpl $0x1, -0xc(%rbp)
jne 0x1bca4
movq 0x33b3e(%rip), %rax     # 0x4f7a8
movslq -0x10(%rbp), %rcx
imulq $0x88, %rcx, %rcx
addq %rcx, %rax
cmpl $0x0, 0x14(%rax)
jle 0x1bca4
movl -0x30(%rbp), %edx
movq 0x33b18(%rip), %rax     # 0x4f7a0
movslq -0xc(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x28(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x10(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
jmp 0x1bdab
movq -0x20(%rbp), %rdi
callq 0xa500
movslq -0x30(%rbp), %rcx
leaq 0x32968(%rip), %rax     # 0x4e620
shlq $0x5, %rcx
addq %rcx, %rax
mulsd 0x18(%rax), %xmm0
movsd %xmm0, 0x33d2c(%rip)    # 0x4f9f8
movl $0x0, -0x24(%rbp)
cmpl $0x4, -0x24(%rbp)
jge 0x1bd32
movsd 0x33d17(%rip), %xmm1    # 0x4f9f8
movslq -0x30(%rbp), %rcx
leaq 0x32934(%rip), %rax     # 0x4e620
shlq $0x5, %rcx
addq %rcx, %rax
movslq -0x24(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
ucomisd %xmm1, %xmm0
jb 0x1bd25
movl -0x24(%rbp), %edx
movq 0x33a94(%rip), %rax     # 0x4f7a0
movslq -0xc(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x28(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x10(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
jmp 0x1bd32
jmp 0x1bd27
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x1bcd3
cmpl $0x0, -0xc(%rbp)
jne 0x1bd58
movq 0x33a69(%rip), %rax     # 0x4f7a8
movslq -0x10(%rbp), %rcx
imulq $0x88, %rcx, %rcx
addq %rcx, %rax
movl 0x10(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x10(%rax)
jmp 0x1bd7e
cmpl $0x1, -0xc(%rbp)
jne 0x1bd7c
movq 0x33a43(%rip), %rax     # 0x4f7a8
movslq -0x10(%rbp), %rcx
imulq $0x88, %rcx, %rcx
addq %rcx, %rax
movl 0x14(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x14(%rax)
jmp 0x1bd7e
movq 0x33a23(%rip), %rax     # 0x4f7a8
movslq -0x10(%rbp), %rcx
imulq $0x88, %rcx, %rcx
addq %rcx, %rax
movl 0xc(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0xc(%rax)
movl 0x339c2(%rip), %eax     # 0x4f764
addl $0x1, %eax
movl %eax, 0x339b9(%rip)     # 0x4f764
jmp 0x1bdad
movq -0x8(%rbp), %rax
movq (%rax), %rdi
movl -0xc(%rbp), %esi
movl -0x10(%rbp), %edx
movl -0x14(%rbp), %ecx
movq -0x20(%rbp), %r8
callq 0x1bb50
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rdi
movl -0xc(%rbp), %esi
movl -0x10(%rbp), %edx
movl -0x14(%rbp), %ecx
movq -0x20(%rbp), %r8
callq 0x1bb50
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)