// File: /workspace/github_c_makefile_star2_O3/dapogon[P]cellcoal/src/cellcoal.c
// Function: SimulateCNLOHforSite
void SimulateCNLOHforSite (TreeNode *p, int genome, int site, long int *seed)
    {
    static double	cumCNLOHbranchLength, uniform;
    int             cell, anccell;
		
	if (p != NULL)
        {
        cell = p->label;
			
        if (p->isHealthyRoot == YES)
            {
            cumCNLOHbranchLength = 0;
            uniform = RandomUniform(seed) * totalTreeLength / mutationRate * CNLOHrate;;
            }
        else
            {
            anccell = p->anc->label;
            cumCNLOHbranchLength += p->branchLength / mutationRate * CNLOHrate;
				
             if ((cumCNLOHbranchLength < uniform) || /* => there will be no change at this branch */
                ((genome == MATERNAL) && (allSites[site].numCNLOHmaternal > 0)) ||
                ((genome == PATERNAL) && (allSites[site].numCNLOHpaternal > 0)))
                {
                data[genome][cell][site] = data[genome][anccell][site];
                }
			else /* => there will be a CN_LOH event */
                {
				if (genome == MATERNAL)
					{
					data[genome][cell][site] = data[PATERNAL][cell][site];
					allSites[site].numCNLOHmaternal++;
					}
				else
					{
					data[genome][cell][site] = data[MATERNAL][cell][site];
					allSites[site].numCNLOHpaternal++;
					}

                allSites[site].numCNLOH++;
                numCNLOH++;
                }
            }
            SimulateCNLOHforSite (p->left, genome, site, seed);
            SimulateCNLOHforSite (p->right, genome, site, seed);
        }
    }

// Assembly:
testq %rdi, %rdi
je 0x18788
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
movslq %edx, %r12
movq 0x1eff0(%rip), %r13     # 0x375b8
movl %esi, %eax
movq %rax, 0x8(%rsp)
movsd 0x1efc9(%rip), %xmm0    # 0x375a0
movsd %xmm0, 0x10(%rsp)
movq %r12, %rax
shlq $0x7, %rax
leaq (%rax,%r12,8), %rax
movq %rax, (%rsp)
cmpl $0x1, 0x24(%r15)
jne 0x18684
movq $0x0, 0x1fa1e(%rip) # 0x38020
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
movq %rax, (%rbx)
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
divsd 0xaabf(%rip), %xmm0     # 0x23120
mulsd 0x10(%rsp), %xmm0
divsd 0x1db69(%rip), %xmm0    # 0x361d8
mulsd 0x1ef81(%rip), %xmm0    # 0x375f8
movsd %xmm0, 0x1f9a9(%rip)    # 0x38028
jmp 0x1875d
movslq 0x1c(%r15), %rax
movq 0x10(%r15), %rcx
movslq 0x1c(%rcx), %rdx
movsd 0x40(%r15), %xmm0
divsd 0x1db3a(%rip), %xmm0    # 0x361d8
mulsd 0x1ef52(%rip), %xmm0    # 0x375f8
addsd 0x1f972(%rip), %xmm0    # 0x38020
movsd %xmm0, 0x1f96a(%rip)    # 0x38020
movsd 0x1f96a(%rip), %xmm1    # 0x38028
ucomisd %xmm0, %xmm1
jbe 0x186e0
movq 0x8(%rsp), %rcx
movq (%r13,%rcx,8), %rcx
movq (%rcx,%rdx,8), %rdx
movl (%rdx,%r12,4), %edx
movq (%rcx,%rax,8), %rax
movl %edx, (%rax,%r12,4)
jmp 0x1875d
movq 0x1eed9(%rip), %rcx     # 0x375c0
cmpl $0x1, %r14d
je 0x18728
testl %r14d, %r14d
jne 0x18733
movq (%rsp), %rsi
cmpl $0x0, 0x28(%rcx,%rsi)
jg 0x186c4
movq (%rsp), %r8
leaq (%rcx,%r8), %rdx
addq $0x28, %rdx
movq (%r13), %rsi
movq 0x8(%r13), %rdi
movq (%rdi,%rax,8), %rdi
movl (%rdi,%r12,4), %edi
movq (%rsi,%rax,8), %rax
movl %edi, (%rax,%r12,4)
movq %r8, %rax
incl (%rdx)
jmp 0x18753
movq (%rsp), %rsi
cmpl $0x0, 0x2c(%rcx,%rsi)
jg 0x186c4
movq (%r13), %rdx
movq 0x8(%r13), %rsi
movq (%rdx,%rax,8), %rdx
movl (%rdx,%r12,4), %edx
movq (%rsi,%rax,8), %rax
movl %edx, (%rax,%r12,4)
movq (%rsp), %rax
incl 0x2c(%rcx,%rax)
incl 0x24(%rcx,%rax)
incl 0x1ee1b(%rip)           # 0x37578
movq (%r15), %rdi
movl %r14d, %esi
movl %ebp, %edx
movq %rbx, %rcx
callq 0x1859c
movq 0x8(%r15), %r15
testq %r15, %r15
jne 0x185ec
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq