// File: /workspace/github_c_makefile_star2_O2/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, %r14d
andl $0x0, -0x40(%rbp)
movl %edx, %r15d
andl $0x0, -0x3c(%rbp)
movl %esi, -0x58(%rbp)
movl %edi, %ebx
movl 0x54e5(%rip), %eax      # 0xa550
movq %rax, -0x50(%rbp)
movslq %eax, %rdi
pushq $0xc
popq %rsi
callq 0x1040
movq %rax, -0x48(%rbp)
testq %rax, %rax
je 0x5462
movq 0x54aa(%rip), %r9       # 0xa538
movq 0x548b(%rip), %rax      # 0xa520
movl %r14d, -0x34(%rbp)
movslq %r14d, %r13
movq %r13, %rcx
shlq $0x4, %rcx
addq %rax, %rcx
addq $0x8, %rcx
movq %rcx, -0x78(%rbp)
movl %r15d, -0x38(%rbp)
movslq %r15d, %rcx
shlq $0x4, %rcx
movq %rcx, -0x60(%rbp)
addq %rcx, %rax
addq $0x8, %rax
movq %rax, -0x70(%rbp)
movq 0x5461(%rip), %rax      # 0xa530
movq %rax, -0x68(%rbp)
leal -0x2(%rbx,%rbx), %eax
movl %eax, -0x54(%rbp)
pushq $-0x1
popq %r15
xorl %eax, %eax
xorl %r10d, %r10d
movq %r13, -0x80(%rbp)
cmpl -0x50(%rbp), %r10d
jge 0x5257
movl %r10d, -0x30(%rbp)
cltq
movq %rax, -0x88(%rbp)
imulq $0x18, %rax, %rax
movq %r9, %r13
movq %rax, %r12
movl (%r9,%rax), %r14d
movl %r14d, %edi
movl -0x38(%rbp), %esi
leaq -0x40(%rbp), %rdx
callq 0x5923
movl %eax, %ebx
movl %r14d, %edi
movl -0x34(%rbp), %esi
leaq -0x3c(%rbp), %rdx
callq 0x5923
movl %ebx, %ecx
orl %eax, %ecx
je 0x520f
leal 0x1(%r15), %ecx
movslq %ecx, %rdx
imulq $0xc, %rdx, %rdx
movq -0x48(%rbp), %rsi
movl %r14d, (%rsi,%rdx)
movq -0x50(%rbp), %rsi
leal -0x1(%rsi), %edi
movl -0x58(%rbp), %esi
movl -0x30(%rbp), %r10d
cmpl %edi, %r10d
movq %r13, %r9
jge 0x516c
movslq 0x10(%r9,%r12), %rsi
imulq $0x18, %rsi, %rsi
movl (%r9,%rsi), %esi
addq -0x48(%rbp), %rdx
testl %eax, %eax
setne %al
testl %ebx, %ebx
setne %dil
decl %esi
movl %esi, 0x4(%rdx)
andb %al, %dil
cmpb $0x1, %dil
jne 0x521b
movq -0x68(%rbp), %rsi
movq -0x88(%rbp), %rdi
movl (%rsi,%rdi,4), %eax
incl %eax
movl %eax, (%rsi,%rdi,4)
cmpl -0x54(%rbp), %eax
jge 0x51ab
movl %eax, 0x8(%rdx)
movl %ecx, %r15d
movq 0x8(%r9,%r12), %rcx
movq -0x70(%rbp), %rdx
movq (%rdx), %rdx
movslq -0x40(%rbp), %rsi
imulq $0xc, %rsi, %rsi
movslq 0x8(%rdx,%rsi), %rdx
shlq $0x4, %rdx
movl %eax, (%rcx,%rdx)
movq -0x78(%rbp), %rax
movq (%rax), %rax
movslq -0x3c(%rbp), %rdx
imulq $0xc, %rdx, %rdx
movslq 0x8(%rax,%rdx), %rax
movq -0x68(%rbp), %rdx
movslq (%rdx,%rdi,4), %rdx
shlq $0x4, %rax
movl %edx, (%rcx,%rax)
movsd 0x5362(%rip), %xmm0     # 0xa558
shlq $0x4, %rdx
movsd %xmm0, 0x8(%rcx,%rdx)
movl 0x534a(%rip), %eax      # 0xa550
movq %rax, -0x50(%rbp)
movl %r15d, %ecx
jmp 0x5243
movl %r15d, %ecx
movq %r13, %r9
movl -0x30(%rbp), %r10d
jmp 0x5243
testl %ebx, %ebx
movq -0x78(%rbp), %rax
cmovneq -0x70(%rbp), %rax
movq (%rax), %rax
leaq -0x3c(%rbp), %rsi
leaq -0x40(%rbp), %rdi
cmovneq %rdi, %rsi
movslq (%rsi), %rsi
imulq $0xc, %rsi, %rsi
movl 0x8(%rax,%rsi), %eax
movl %eax, 0x8(%rdx)
movl 0x10(%r9,%r12), %eax
incl %r10d
movl %ecx, %r15d
movq -0x80(%rbp), %r13
jmp 0x50e7
movl -0x38(%rbp), %r12d
movl %r12d, %edi
callq 0x58fc
cltq
subq %rax, 0x52dc(%rip)      # 0xa548
movsd 0x52ec(%rip), %xmm0     # 0xa560
movsd %xmm0, -0x30(%rbp)
movl %r12d, %edi
callq 0x58fc
cvtsi2sd %eax, %xmm1
movsd -0x30(%rbp), %xmm0
callq 0x1170
movsd 0xd71(%rip), %xmm1      # 0x6008
subsd %xmm0, %xmm1
movsd 0x52cd(%rip), %xmm0     # 0xa570
subsd %xmm1, %xmm0
movsd %xmm0, 0x52c1(%rip)     # 0xa570
movq 0x526a(%rip), %r14      # 0xa520
movq -0x60(%rbp), %rbx
movq 0x8(%r14,%rbx), %rdi
callq 0x10c0
testl %r15d, %r15d
js 0x5352
incl %r15d
imulq $0xc, %r15, %rsi
movq -0x48(%rbp), %rdi
movq %r15, %r12
callq 0x1150
movq %rax, %rbx
testq %rax, %rax
movl -0x34(%rbp), %r15d
je 0x547d
movq -0x60(%rbp), %rax
movq %rbx, 0x8(%r14,%rax)
movl %r12d, (%r14,%rax)
movl -0x38(%rbp), %ebx
movl %ebx, %edi
callq 0x58fc
cltq
addq %rax, 0x5238(%rip)      # 0xa548
movsd 0x5248(%rip), %xmm0     # 0xa560
movsd %xmm0, -0x30(%rbp)
movl %ebx, %edi
callq 0x58fc
cvtsi2sd %eax, %xmm1
movsd -0x30(%rbp), %xmm0
callq 0x1170
movsd 0xcce(%rip), %xmm1      # 0x6008
subsd %xmm0, %xmm1
addsd 0x522a(%rip), %xmm1     # 0xa570
movsd %xmm1, 0x5222(%rip)     # 0xa570
pushq $0x1
jmp 0x53ae
addq %r14, %rbx
addq $0x8, %rbx
movq -0x48(%rbp), %rdi
callq 0x10c0
movslq 0x51d7(%rip), %rax      # 0xa540
shlq $0x4, %rax
movq -0x8(%r14,%rax), %rcx
movq %rcx, (%rbx)
movl -0x10(%r14,%rax), %eax
movl %eax, -0x8(%rbx)
movslq 0x51bc(%rip), %rax      # 0xa540
shlq $0x4, %rax
movl -0xc(%r14,%rax), %eax
movl %eax, -0x4(%rbx)
movl 0x51aa(%rip), %eax      # 0xa540
decl %eax
movl -0x34(%rbp), %r15d
cmpl %r15d, %eax
cmovel %r12d, %r15d
movl %eax, 0x5197(%rip)      # 0xa540
movslq %r15d, %r13
pushq $0x2
popq %r14
movl %r15d, %edi
callq 0x58fc
cltq
subq %rax, 0x5187(%rip)      # 0xa548
movsd 0x5197(%rip), %xmm0     # 0xa560
movsd %xmm0, -0x30(%rbp)
movl %r15d, %edi
callq 0x58fc
cvtsi2sd %eax, %xmm1
movsd -0x30(%rbp), %xmm0
callq 0x1170
movsd 0xc1c(%rip), %xmm1      # 0x6008
subsd %xmm0, %xmm1
movsd 0x5178(%rip), %xmm0     # 0xa570
subsd %xmm1, %xmm0
movsd %xmm0, 0x516c(%rip)     # 0xa570
movq 0x5115(%rip), %rbx      # 0xa520
shlq $0x4, %r13
movq 0x8(%rbx,%r13), %rdi
callq 0x10c0
movslq 0x5120(%rip), %rax      # 0xa540
shlq $0x4, %rax
movq -0x8(%rbx,%rax), %rcx
movq %rcx, 0x8(%rbx,%r13)
movl -0x10(%rbx,%rax), %eax
movl %eax, (%rbx,%r13)
movslq 0x5103(%rip), %rax      # 0xa540
shlq $0x4, %rax
movl -0xc(%rbx,%rax), %eax
movl %eax, 0x4(%rbx,%r13)
decl 0x50f0(%rip)            # 0xa540
movl %r14d, %eax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1a6a(%rip), %rdi      # 0x6ed3
callq 0x1070
movl 0x50dc(%rip), %eax      # 0xa550
movq %rax, -0x50(%rbp)
jmp 0x5087
leaq 0x1a5f(%rip), %rdi      # 0x6ee3
callq 0x1070
movq 0x5090(%rip), %r14      # 0xa520
jmp 0x52f0