// File: /workspace/github_c_makefile_star2_O0/dapogon[P]cellcoal/src/cellcoal.c
// Function: SimulateSignatureISMforSite
void SimulateSignatureISMforSite (TreeNode *p, int genome, int site, int newState, long int *seed)
	{
    static double	cumBranchLength, uniform;
    int             cell, anccell, ancState;
	
    if (p != NULL)
        {
        cell = p->label;
			
        if (p->isHealthyRoot == YES)
            {
            cumBranchLength = 0;
             uniform = RandomUniform(seed) * totalTreeLength;
			//fprintf (stderr, "\nsimulating at root of position %d", site+1);
            }
        else
            {
            anccell = p->anc->label;
            ancState = data[genome][anccell][site];
            cumBranchLength += p->branchLength;
				
            if (cumBranchLength < uniform || allSites[site].numMutations > 0)/* => there will be no change; forcing ISM diploid */
                {
                data[genome][cell][site] = ancState;
 				//fprintf (stderr, "\ncopying ancstate %c", WhichNuc(ancstate));
               }
            else /* => there will be change */
                {
				data[genome][cell][site] = newState;
                if (genome == MATERNAL)
                    allSites[site].numMutationsMaternal++;
                else if (genome == PATERNAL)
                    allSites[site].numMutationsPaternal++;
                allSites[site].numMutations++;
                numMU++;
				//fprintf (stderr, "\nchange at site %d from %c to %c  (numMU = %d)", site+1, WhichNuc(ancState), WhichNuc(newState), numMU);
 				}
            }
        SimulateSignatureISMforSite (p->left, genome, site, newState, seed);
        SimulateSignatureISMforSite (p->right, genome, site, newState, 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 0x1b97f
movq -0x8(%rbp), %rax
movl 0x1c(%rax), %eax
movl %eax, -0x24(%rbp)
movq -0x8(%rbp), %rax
cmpl $0x1, 0x24(%rax)
jne 0x1b811
xorps %xmm0, %xmm0
movsd %xmm0, 0x341e5(%rip)    # 0x4f9d8
movq -0x20(%rbp), %rdi
callq 0xa500
mulsd 0x33f84(%rip), %xmm0    # 0x4f788
movsd %xmm0, 0x341d4(%rip)    # 0x4f9e0
jmp 0x1b94c
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movl 0x1c(%rax), %eax
movl %eax, -0x28(%rbp)
movq 0x33f7a(%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 (%rax,%rcx,4), %eax
movl %eax, -0x2c(%rbp)
movq -0x8(%rbp), %rax
movsd 0x40(%rax), %xmm0
addsd 0x34187(%rip), %xmm0    # 0x4f9d8
movsd %xmm0, 0x3417f(%rip)    # 0x4f9d8
movsd 0x34177(%rip), %xmm1    # 0x4f9d8
movsd 0x34177(%rip), %xmm0    # 0x4f9e0
ucomisd %xmm1, %xmm0
ja 0x1b88a
movq 0x33f32(%rip), %rax     # 0x4f7a8
movslq -0x10(%rbp), %rcx
imulq $0x88, %rcx, %rcx
addq %rcx, %rax
cmpl $0x0, 0xc(%rax)
jle 0x1b8b0
movl -0x2c(%rbp), %edx
movq 0x33f0c(%rip), %rax     # 0x4f7a0
movslq -0xc(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x24(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x10(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
jmp 0x1b94a
movl -0x14(%rbp), %edx
movq 0x33ee6(%rip), %rax     # 0x4f7a0
movslq -0xc(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x24(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x10(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
cmpl $0x0, -0xc(%rbp)
jne 0x1b8f7
movq 0x33eca(%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 0x1b91d
cmpl $0x1, -0xc(%rbp)
jne 0x1b91b
movq 0x33ea4(%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 0x1b91d
movq 0x33e84(%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 0x33e23(%rip), %eax     # 0x4f764
addl $0x1, %eax
movl %eax, 0x33e1a(%rip)     # 0x4f764
jmp 0x1b94c
movq -0x8(%rbp), %rax
movq (%rax), %rdi
movl -0xc(%rbp), %esi
movl -0x10(%rbp), %edx
movl -0x14(%rbp), %ecx
movq -0x20(%rbp), %r8
callq 0x1b7b0
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 0x1b7b0
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)