// File: /workspace/github_c_makefile_star2_O0/dapogon[P]cellcoal/src/cellcoal.c
// Function: EvolveCNLOHonTree
void EvolveCNLOHonTree (TreeNode *p, int genome, long int *seed)
	{
    int		i, trials, numCNLOH, CNLOHsoFar;
    double	totalCNLOHbranchSum;

	totalCNLOHbranchSum = numSites * totalTreeLength / mutationRate * CNLOHrate;
	numCNLOH = RandomPoisson (totalCNLOHbranchSum, seed); /* the number of CNLOH events will be distributed as a Poisson with parameter totalCNLOHbranchSum */
	
     /* if the number of CNLOH events is bigger than the number of sites quit the program and warn the user about violation of ISM */
     if (numISMCNLOH + numCNLOH > (2*numSites))
        {
        fprintf (stderr, "\n\nERROR: The haploid infinite sites model (ISM) for CNLOH events has been violated. There will be");
        fprintf (stderr, "\nmore CNLOH events (%d existing + %d proposed]) than available sites under this model (%d).", numISMCNLOH, numCNLOH, 2*numSites);
        fprintf (stderr, "\nTry using a smaller deletion rate.");
        fprintf (stderr, "\nIf using a user tree, try introducing smaller branch lengths.\n");
        exit (-1);
        }
	
    numISMCNLOH += numCNLOH;
    trials = 0;
    CNLOHsoFar = 0;
    while (CNLOHsoFar < numCNLOH)
        {
        i = RandomUniformTo(numSites, seed);  /* choose a site at random */
        while ((genome == MATERNAL && allSites[i].numCNLOHmaternal != 0) ||
               (genome == PATERNAL && allSites[i].numCNLOHpaternal != 0))
            {
            i = RandomUniformTo(numSites, seed);
            if (trials++ > 100*numSites)
                {
                fprintf (stderr, "\n\n ERROR: after %d trials cannot find a site without CNLOH",100*numSites);
                fprintf (stderr, "\nCNLOH = %d  CNLOH so far = %d\n\n",numCNLOH, CNLOHsoFar);
                for (i=0; i<numSites; i++)
                    fprintf (stderr, "\nsite %d has %d CNLOHs",i+1, allSites[i].numCNLOH);
                 fprintf (stderr, "\n");
                 exit(-1);
                }
            }
	
		SimulateCNLOHforSite (p, genome, i, seed);
			
        CNLOHsoFar++;
			
        #ifdef MYDEBUG
            fprintf (stderr, "\nCNLOH = %d   nCNLOH so far = %d\n",numCNLOH, CNLOHsoFar);
            if (allSites[i]].numDeletions > 1)
                {
                fprintf (stderr, "\n\n ERROR: %d CNLOH in site %d",allSites[i].numCNLOH, i+1);
                exit(-1);
                }
            for (i=0; i<numSites; i++)
                fprintf (stderr, "%2d[%d] ",i+1, allSites[i].numCNLOH);
        #endif
			
        }
	}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
cvtsi2sdl 0x3f521(%rip), %xmm0 # 0x4e1dc
mulsd 0x40ac5(%rip), %xmm0    # 0x4f788
divsd 0x3f53d(%rip), %xmm0    # 0x4e208
mulsd 0x40b0d(%rip), %xmm0    # 0x4f7e0
movsd %xmm0, -0x30(%rbp)
movsd -0x30(%rbp), %xmm0
movq -0x18(%rbp), %rdi
callq 0x1b370
movl %eax, -0x24(%rbp)
movl 0x40ae9(%rip), %eax     # 0x4f7d8
addl -0x24(%rbp), %eax
movl 0x3f4e4(%rip), %ecx     # 0x4e1dc
shll %ecx
cmpl %ecx, %eax
jle 0xed7b
movq 0x3f2f3(%rip), %rax     # 0x4dff8
movq (%rax), %rdi
leaq 0x3280a(%rip), %rsi     # 0x41519
movb $0x0, %al
callq 0x21b0
movq 0x3f2db(%rip), %rax     # 0x4dff8
movq (%rax), %rdi
movl 0x40ab2(%rip), %edx     # 0x4f7d8
movl -0x24(%rbp), %ecx
movl 0x3f4ac(%rip), %r8d     # 0x4e1dc
shll %r8d
leaq 0x32841(%rip), %rsi     # 0x4157b
movb $0x0, %al
callq 0x21b0
movq 0x3f2b0(%rip), %rax     # 0x4dff8
movq (%rax), %rdi
leaq 0x32885(%rip), %rsi     # 0x415d7
movb $0x0, %al
callq 0x21b0
movq 0x3f298(%rip), %rax     # 0x4dff8
movq (%rax), %rdi
leaq 0x32891(%rip), %rsi     # 0x415fb
movb $0x0, %al
callq 0x21b0
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x2290
movl -0x24(%rbp), %eax
addl 0x40a54(%rip), %eax     # 0x4f7d8
movl %eax, 0x40a4e(%rip)     # 0x4f7d8
movl $0x0, -0x20(%rbp)
movl $0x0, -0x28(%rbp)
movl -0x28(%rbp), %eax
cmpl -0x24(%rbp), %eax
jge 0xef1c
movl 0x3f432(%rip), %edi     # 0x4e1dc
movq -0x18(%rbp), %rsi
callq 0x1ba30
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0xc(%rbp)
jne 0xeddc
movq 0x409e5(%rip), %rcx     # 0x4f7a8
movslq -0x1c(%rbp), %rax
imulq $0x88, %rax, %rax
addq %rax, %rcx
movb $0x1, %al
cmpl $0x0, 0x28(%rcx)
movb %al, -0x31(%rbp)
jne 0xee0c
xorl %eax, %eax
cmpl $0x1, -0xc(%rbp)
movb %al, -0x32(%rbp)
jne 0xee06
movq 0x409ba(%rip), %rax     # 0x4f7a8
movslq -0x1c(%rbp), %rcx
imulq $0x88, %rcx, %rcx
addq %rcx, %rax
cmpl $0x0, 0x2c(%rax)
setne %al
movb %al, -0x32(%rbp)
movb -0x32(%rbp), %al
movb %al, -0x31(%rbp)
movb -0x31(%rbp), %al
testb $0x1, %al
jne 0xee18
jmp 0xeefb
movl 0x3f3be(%rip), %edi     # 0x4e1dc
movq -0x18(%rbp), %rsi
callq 0x1ba30
movl %eax, -0x1c(%rbp)
movl -0x20(%rbp), %eax
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, -0x20(%rbp)
imull $0x64, 0x3f3a0(%rip), %ecx # 0x4e1dc
cmpl %ecx, %eax
jle 0xeef6
movq 0x3f1ad(%rip), %rax     # 0x4dff8
movq (%rax), %rdi
imull $0x64, 0x3f387(%rip), %edx # 0x4e1dc
leaq 0x327df(%rip), %rsi     # 0x4163b
movb $0x0, %al
callq 0x21b0
movq 0x3f18e(%rip), %rax     # 0x4dff8
movq (%rax), %rdi
movl -0x24(%rbp), %edx
movl -0x28(%rbp), %ecx
leaq 0x327fc(%rip), %rsi     # 0x41676
movb $0x0, %al
callq 0x21b0
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
cmpl 0x3f34b(%rip), %eax     # 0x4e1dc
jge 0xeed4
movq 0x3f15e(%rip), %rax     # 0x4dff8
movq (%rax), %rdi
movl -0x1c(%rbp), %edx
addl $0x1, %edx
movq 0x408fe(%rip), %rax     # 0x4f7a8
movslq -0x1c(%rbp), %rcx
imulq $0x88, %rcx, %rcx
addq %rcx, %rax
movl 0x24(%rax), %ecx
leaq 0x327d5(%rip), %rsi     # 0x41697
movb $0x0, %al
callq 0x21b0
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0xee88
movq 0x3f11d(%rip), %rax     # 0x4dff8
movq (%rax), %rdi
leaq 0x38150(%rip), %rsi     # 0x47035
movb $0x0, %al
callq 0x21b0
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x2290
jmp 0xedb6
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
movl -0x1c(%rbp), %edx
movq -0x18(%rbp), %rcx
callq 0x1cca0
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0xed98
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)