// File: /workspace/github_c_makefile_star2_O1/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:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rcx, %rbx
movl %edx, %ebp
movl %esi, %r14d
movq %rdi, %r15
movl %esi, %eax
movq %rax, (%rsp)
movslq %edx, %r12
movq %r12, %rax
shlq $0x7, %rax
leaq (%rax,%r12,8), %r13
testq %r15, %r15
je 0x183ec
cmpl $0x1, 0x24(%r15)
jne 0x182de
movq $0x0, 0x2bdc6(%rip) # 0x44020
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 0x1bd6f(%rip), %xmm0    # 0x34028
mulsd 0x2b2df(%rip), %xmm0    # 0x435a0
divsd 0x29f0f(%rip), %xmm0    # 0x421d8
mulsd 0x2b327(%rip), %xmm0    # 0x435f8
movsd %xmm0, 0x2bd4f(%rip)    # 0x44028
jmp 0x183d3
movslq 0x1c(%r15), %rax
movq 0x10(%r15), %rcx
movslq 0x1c(%rcx), %rcx
movsd 0x40(%r15), %xmm0
divsd 0x29ee0(%rip), %xmm0    # 0x421d8
mulsd 0x2b2f8(%rip), %xmm0    # 0x435f8
addsd 0x2bd18(%rip), %xmm0    # 0x44020
movsd %xmm0, 0x2bd10(%rip)    # 0x44020
movsd 0x2bd10(%rip), %xmm1    # 0x44028
ucomisd %xmm0, %xmm1
jbe 0x18342
movq 0x2b293(%rip), %rdx     # 0x435b8
movq (%rsp), %rsi
movq (%rdx,%rsi,8), %rdx
movq (%rdx,%rcx,8), %rcx
movl (%rcx,%r12,4), %ecx
movq (%rdx,%rax,8), %rax
movl %ecx, (%rax,%r12,4)
jmp 0x183d3
testl %r14d, %r14d
je 0x1838d
cmpl $0x1, %r14d
jne 0x1835c
movq 0x2b26c(%rip), %rdx     # 0x435c0
cmpl $0x0, 0x2c(%rdx,%r13)
jg 0x1831e
movq 0x2b255(%rip), %rcx     # 0x435b8
testl %r14d, %r14d
je 0x1839e
movq (%rcx), %rdx
movq 0x8(%rcx), %rcx
movq (%rdx,%rax,8), %rdx
movl (%rdx,%r12,4), %edx
movq (%rcx,%rax,8), %rax
movl %edx, (%rax,%r12,4)
movq 0x2b23a(%rip), %rax     # 0x435c0
incl 0x2c(%rax,%r13)
jmp 0x183c1
movq 0x2b22c(%rip), %rdx     # 0x435c0
cmpl $0x0, 0x28(%rdx,%r13)
jg 0x1831e
jmp 0x18347
movq (%rcx), %rdx
movq 0x8(%rcx), %rcx
movq (%rcx,%rax,8), %rcx
movl (%rcx,%r12,4), %ecx
movq (%rdx,%rax,8), %rax
movl %ecx, (%rax,%r12,4)
movq 0x2b204(%rip), %rax     # 0x435c0
incl 0x28(%rax,%r13)
movq 0x2b1f8(%rip), %rax     # 0x435c0
incl 0x24(%rax,%r13)
incl 0x2b1a5(%rip)           # 0x43578
movq (%r15), %rdi
movl %r14d, %esi
movl %ebp, %edx
movq %rbx, %rcx
callq 0x18211
movq 0x8(%r15), %r15
jmp 0x1823b
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq