// File: /workspace/github_c_makefile_star2_O2/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
subq $0x18, %rsp
movq %rcx, %rbx
movl %edx, %ebp
movl %esi, %r14d
movq %rdi, %r15
movslq %edx, %r12
movq 0x1c9cf(%rip), %rax     # 0x315b8
movq %rax, (%rsp)
movl %esi, %eax
movq %rax, 0x8(%rsp)
movsd 0x1c9a4(%rip), %xmm0    # 0x315a0
movsd %xmm0, 0x10(%rsp)
imulq $0x88, %r12, %r8
movq %r8, %r13
testq %r15, %r15
je 0x14d3e
cmpl $0x1, 0x24(%r15)
jne 0x14c4f
andq $0x0, 0x1d3fc(%rip)     # 0x32020
movq %rbx, %rdi
callq 0x10279
mulsd 0x10(%rsp), %xmm0
divsd 0x1b59e(%rip), %xmm0    # 0x301d8
mulsd 0x1c9b6(%rip), %xmm0    # 0x315f8
movsd %xmm0, 0x1d3de(%rip)    # 0x32028
jmp 0x14d22
movslq 0x1c(%r15), %rax
movq 0x10(%r15), %rcx
movslq 0x1c(%rcx), %rdx
movsd 0x40(%r15), %xmm0
divsd 0x1b56f(%rip), %xmm0    # 0x301d8
mulsd 0x1c987(%rip), %xmm0    # 0x315f8
addsd 0x1d3a7(%rip), %xmm0    # 0x32020
movsd %xmm0, 0x1d39f(%rip)    # 0x32020
movsd 0x1d39f(%rip), %xmm1    # 0x32028
ucomisd %xmm0, %xmm1
jbe 0x14cae
movq 0x8(%rsp), %rcx
movq (%rsp), %rsi
movq (%rsi,%rcx,8), %rcx
movq (%rcx,%rdx,8), %rdx
movl (%rdx,%r12,4), %edx
movq (%rcx,%rax,8), %rax
movl %edx, (%rax,%r12,4)
jmp 0x14d22
movq 0x1c90b(%rip), %rcx     # 0x315c0
cmpl $0x1, %r14d
je 0x14cef
testl %r14d, %r14d
jne 0x14cf7
cmpl $0x0, 0x28(%rcx,%r8)
jg 0x14c8f
leaq (%rcx,%r8), %rdx
addq $0x28, %rdx
movq (%rsp), %rdi
movq (%rdi), %rsi
movq 0x8(%rdi), %rdi
movq (%rdi,%rax,8), %rdi
movl (%rdi,%r12,4), %edi
movq (%rsi,%rax,8), %rax
movl %edi, (%rax,%r12,4)
incl (%rdx)
jmp 0x14d17
cmpl $0x0, 0x2c(%rcx,%r8)
jg 0x14c8f
movq (%rsp), %rsi
movq (%rsi), %rdx
movq 0x8(%rsi), %rsi
movq (%rdx,%rax,8), %rdx
movl (%rdx,%r12,4), %edx
movq (%rsi,%rax,8), %rax
movl %edx, (%rax,%r12,4)
incl 0x2c(%rcx,%r8)
incl 0x24(%rcx,%r8)
incl 0x1c856(%rip)           # 0x31578
movq (%r15), %rdi
movl %r14d, %esi
movl %ebp, %edx
movq %rbx, %rcx
callq 0x14bc6
movq 0x8(%r15), %r15
movq %r13, %r8
jmp 0x14c0c
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq