// File: /workspace/github_c_makefile_star2_O3/genevalab[P]msmove/streec.c
// Function: ca
int ca(int nsam, int nsites, int c1, int c2)
{
	int yes1, yes2, seg, start, end, desc, k;
	int seg1 = 0;
	int seg2 = 0;
	int tseg = -1;
	struct seg *pseg;
	struct node *ptree;

	if (!(pseg = (struct seg*)calloc((size_t)nsegs, sizeof(struct seg)))) 
		perror("alloc error.ca1");

	for (seg=0, k=0; k < nsegs; seg = seglst[seg].next, k++)
	{
		start = seglst[seg].beg;
		yes1 = isseg(start, c1, &seg1);
		yes2 = isseg(start, c2, &seg2);
		if (yes1 || yes2)
		{
			tseg++;
			(pseg+tseg)->beg = seglst[seg].beg;
			end = k < nsegs-1 ? seglst[seglst[seg].next].beg-1 : nsites-1;
			(pseg+tseg)->end = end;
			if (yes1 && yes2)
			{
				nnodes[seg]++;
				if (nnodes[seg] >= 2*nsam-2)
					tseg--;
				else
					(pseg+tseg)->desc = nnodes[seg];
				ptree = seglst[seg].ptree;
				desc = (chrom[c1].pseg+seg1)->desc;
				(ptree+desc)->abv = nnodes[seg];
				desc = (chrom[c2].pseg+seg2)-> desc;
				(ptree+desc)->abv = nnodes[seg];
				(ptree+nnodes[seg])->time = t;
			}
			else
				(pseg+tseg)->desc = yes1 ? (chrom[c1].pseg+seg1)->desc : (chrom[c2].pseg+seg2)->desc;
		}
	}
	nlinks -= links(c1);
	cleft -= 1.0-pow(pc, (double)links(c1));
	free(chrom[c1].pseg);
	if (tseg < 0)
	{
		free(pseg);
		chrom[c1].pseg = chrom[nchrom-1].pseg;
		chrom[c1].nseg = chrom[nchrom-1].nseg;
		chrom[c1].pop = chrom[nchrom-1].pop;
		if (c2 == nchrom-1)
			c2 = c1;
		nchrom--;
	}
	else
	{
		if(!(pseg = (struct seg*)realloc(pseg, (size_t)(tseg+1)*sizeof(struct seg))))
			perror(" realloc error. ca1");
		chrom[c1].pseg = pseg;
		chrom[c1].nseg = tseg+1;
		nlinks += links(c1);
	   	cleft += 1.0-pow(pc, (double)links(c1));
	}
	nlinks -= links(c2);
	cleft -= 1.0-pow(pc, (double)links(c2));
	free(chrom[c2].pseg);
	chrom[c2].pseg = chrom[nchrom-1].pseg;
	chrom[c2].nseg = chrom[nchrom-1].nseg;
	chrom[c2].pop = chrom[nchrom-1].pop;
	nchrom--;
	if (tseg < 0)
		return 2;
	else 
		return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movl %ecx, %r15d
movl %edx, %ebx
movl %esi, -0x44(%rbp)
movl %edi, %r13d
movl 0x5ad0(%rip), %r14d     # 0xb560
movslq %r14d, %rdi
movl $0xc, %esi
callq 0x1050
movq %rax, -0x38(%rbp)
testq %rax, %rax
je 0x5f0e
movq 0x5a7f(%rip), %rcx      # 0xb530
testl %r14d, %r14d
movl %r15d, -0x2c(%rbp)
movl %ebx, -0x3c(%rbp)
jle 0x5cf5
movq 0x5a80(%rip), %rdx      # 0xb548
movslq %ebx, %rax
movq %rax, -0x70(%rbp)
shlq $0x4, %rax
leaq (%rcx,%rax), %rsi
movq %rsi, -0x90(%rbp)
movq 0x8(%rcx,%rax), %rsi
movslq %r15d, %rax
shlq $0x4, %rax
leaq (%rcx,%rax), %rdi
movq %rdi, -0x88(%rbp)
movq %rcx, -0x68(%rbp)
movq 0x8(%rcx,%rax), %rax
movq %rsi, %rcx
movq 0x5a38(%rip), %rsi      # 0xb540
movq %rsi, -0x50(%rbp)
leal -0x2(%r13,%r13), %esi
movl %esi, -0x40(%rbp)
leaq 0xc(%rcx), %rsi
movq %rsi, -0x78(%rbp)
movq %rax, -0x58(%rbp)
addq $0x4, %rax
movq %rax, -0x80(%rbp)
xorl %ebx, %ebx
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
xorl %eax, %eax
xorl %r11d, %r11d
xorl %r10d, %r10d
movq %rcx, -0x60(%rbp)
movslq %eax, %r12
leaq (%r12,%r12,2), %rax
movl (%rdx,%rax,8), %r8d
movq -0x90(%rbp), %rsi
movl (%rsi), %esi
cmpl %esi, %r10d
jge 0x5b90
movslq %r10d, %rdi
leaq (%rdi,%rdi,2), %rdi
cmpl %r8d, (%rcx,%rdi,4)
jg 0x5b90
movq -0x78(%rbp), %r9
leaq (%r9,%rdi,4), %r9
leal -0x1(%rsi), %r15d
cmpl %r8d, -0x8(%r9)
jge 0x5cce
cmpl %r10d, %r15d
je 0x5cd6
incl %r10d
leaq 0xc(%r9), %rdi
cmpl %r8d, (%r9)
movq %rdi, %r9
jle 0x5b6e
xorl %r9d, %r9d
movq -0x88(%rbp), %rsi
movl (%rsi), %esi
cmpl %esi, %r11d
jge 0x5bca
movslq %r11d, %rdi
leaq (%rdi,%rdi,2), %rdi
movq -0x80(%rbp), %r15
leaq (%r15,%rdi,4), %r15
cmpl %r8d, -0x4(%r15)
jg 0x5bca
cmpl %r8d, (%r15)
jge 0x5bd7
incl %r11d
addq $0xc, %r15
cmpl %r11d, %esi
jne 0x5bb0
movl %esi, %r11d
testb %r9b, %r9b
je 0x5cbd
xorl %esi, %esi
jmp 0x5bda
movb $0x1, %sil
movq %r13, %rcx
leal 0x1(%r13), %r15d
movslq %r15d, %rdi
leaq (%rdi,%rdi,2), %r13
movq -0x38(%rbp), %rdi
movl %r8d, (%rdi,%r13,4)
leal -0x1(%r14), %r8d
movl -0x44(%rbp), %edi
cmpl %r8d, %ebx
jge 0x5c08
movslq 0x10(%rdx,%rax,8), %rdi
leaq (%rdi,%rdi,2), %rdi
movl (%rdx,%rdi,8), %edi
movq -0x38(%rbp), %r8
leaq (%r8,%r13,4), %r8
decl %edi
movl %edi, 0x4(%r8)
andb %r9b, %sil
cmpb $0x1, %sil
jne 0x5c95
movq -0x50(%rbp), %rdi
movl (%rdi,%r12,4), %esi
incl %esi
movl %esi, (%rdi,%r12,4)
cmpl -0x40(%rbp), %esi
movq %rcx, %r13
jge 0x5c3c
movl %esi, 0x8(%r8)
movl %r15d, %r13d
movq 0x8(%rdx,%rax,8), %rdi
movslq %r10d, %r8
leaq (%r8,%r8,2), %r8
movq -0x60(%rbp), %rcx
movslq 0x8(%rcx,%r8,4), %r8
shlq $0x4, %r8
movl %esi, (%rdi,%r8)
movslq %r11d, %rsi
leaq (%rsi,%rsi,2), %rsi
movq -0x58(%rbp), %r8
movslq 0x8(%r8,%rsi,4), %rsi
movq -0x50(%rbp), %r8
movslq (%r8,%r12,4), %r8
shlq $0x4, %rsi
movl %r8d, (%rdi,%rsi)
movsd 0x58e7(%rip), %xmm0     # 0xb568
shlq $0x4, %r8
movsd %xmm0, 0x8(%rdi,%r8)
movl 0x58cd(%rip), %r14d     # 0xb560
jmp 0x5cbd
testb %r9b, %r9b
movl %r11d, %esi
cmovnel %r10d, %esi
movq -0x58(%rbp), %rdi
movq -0x60(%rbp), %rcx
cmovneq %rcx, %rdi
movslq %esi, %rsi
leaq (%rsi,%rsi,2), %rsi
movl 0x8(%rdi,%rsi,4), %esi
movl %esi, 0x8(%r8)
movl %r15d, %r13d
movl 0x10(%rdx,%rax,8), %eax
incl %ebx
cmpl %r14d, %ebx
jl 0x5b3c
jmp 0x5ce1
movb $0x1, %r9b
jmp 0x5b93
xorl %r9d, %r9d
movl %esi, %r10d
jmp 0x5b93
movl -0x2c(%rbp), %r15d
movq %r13, %r12
movq -0x70(%rbp), %r13
movq %rcx, %rdx
movq -0x68(%rbp), %rcx
jmp 0x5d0a
movslq %ebx, %r13
movq %r13, %rax
shlq $0x4, %rax
movq 0x8(%rcx,%rax), %rdx
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
shlq $0x4, %r13
movslq (%rcx,%r13), %rax
leaq (%rax,%rax,2), %rax
movslq -0x8(%rdx,%rax,4), %rax
movslq (%rdx), %rcx
subq %rcx, %rax
subq %rax, 0x5830(%rip)      # 0xb558
movsd 0x5840(%rip), %xmm0     # 0xb570
cvtsi2sd %eax, %xmm1
callq 0x1190
movsd 0x12c7(%rip), %xmm1     # 0x7008
subsd %xmm0, %xmm1
movsd 0x5833(%rip), %xmm0     # 0xb580
subsd %xmm1, %xmm0
movsd %xmm0, 0x5827(%rip)     # 0xb580
movq 0x57d0(%rip), %rbx      # 0xb530
movq 0x8(%rbx,%r13), %rdi
callq 0x10e0
testl %r12d, %r12d
js 0x5dff
movl %r12d, %r15d
incl %r12d
leaq 0x4(,%r15,4), %rax
incq %r15
leaq (%rax,%rax,2), %rsi
movq -0x38(%rbp), %rdi
callq 0x1170
movq %rax, %r14
testq %rax, %rax
je 0x5f26
movq %r14, 0x8(%rbx,%r13)
movl %r12d, (%rbx,%r13)
leaq (%r15,%r15,2), %rax
movslq -0x8(%r14,%rax,4), %rax
movslq (%r14), %rcx
subq %rcx, %rax
addq %rax, 0x579c(%rip)      # 0xb558
movsd 0x57ac(%rip), %xmm0     # 0xb570
xorps %xmm1, %xmm1
cvtsi2sd %eax, %xmm1
callq 0x1190
movsd 0x1230(%rip), %xmm1     # 0x7008
subsd %xmm0, %xmm1
addsd 0x579c(%rip), %xmm1     # 0xb580
movsd %xmm1, 0x5794(%rip)     # 0xb580
movl $0x1, %r14d
movq 0x5737(%rip), %rbx      # 0xb530
movl -0x2c(%rbp), %r15d
jmp 0x5e5a
leaq (%rbx,%r13), %r14
addq $0x8, %r14
movq -0x38(%rbp), %rdi
callq 0x10e0
movslq 0x5739(%rip), %rax      # 0xb550
shlq $0x4, %rax
movq -0x8(%rbx,%rax), %rcx
movq %rcx, (%r14)
movl -0x10(%rbx,%rax), %eax
movl %eax, -0x8(%r14)
movslq 0x571e(%rip), %rax      # 0xb550
shlq $0x4, %rax
movl -0xc(%rbx,%rax), %eax
movl %eax, -0x4(%r14)
movl 0x570c(%rip), %eax      # 0xb550
decl %eax
cmpl %r15d, %eax
cmovel -0x3c(%rbp), %r15d
movl %eax, 0x56fc(%rip)      # 0xb550
movl $0x2, %r14d
movslq %r15d, %r15
shlq $0x4, %r15
movslq (%rbx,%r15), %rax
movq 0x8(%rbx,%r15), %rcx
leaq (%rax,%rax,2), %rax
movslq -0x8(%rcx,%rax,4), %rax
movslq (%rcx), %rcx
subq %rcx, %rax
subq %rax, 0x56d8(%rip)      # 0xb558
movsd 0x56e8(%rip), %xmm0     # 0xb570
xorps %xmm1, %xmm1
cvtsi2sd %eax, %xmm1
callq 0x1190
movsd 0x116c(%rip), %xmm1     # 0x7008
subsd %xmm0, %xmm1
movsd 0x56d8(%rip), %xmm0     # 0xb580
subsd %xmm1, %xmm0
movsd %xmm0, 0x56cc(%rip)     # 0xb580
movq 0x5675(%rip), %rbx      # 0xb530
movq 0x8(%rbx,%r15), %rdi
callq 0x10e0
movslq 0x5684(%rip), %rax      # 0xb550
shlq $0x4, %rax
movq -0x8(%rbx,%rax), %rcx
movq %rcx, 0x8(%rbx,%r15)
movl -0x10(%rbx,%rax), %eax
movl %eax, (%rbx,%r15)
movslq 0x5667(%rip), %rax      # 0xb550
shlq $0x4, %rax
movl -0xc(%rbx,%rax), %eax
movl %eax, 0x4(%rbx,%r15)
decl 0x5654(%rip)            # 0xb550
movl %r14d, %eax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1fbe(%rip), %rdi      # 0x7ed3
callq 0x1090
movl 0x563f(%rip), %r14d     # 0xb560
jmp 0x5aaa
leaq 0x1fb6(%rip), %rdi      # 0x7ee3
callq 0x1090
movq 0x55f7(%rip), %rbx      # 0xb530
jmp 0x5d9d