// File: /workspace/github_c_makefile_star2_O0/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
subq $0x70, %rsp
movl %edi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movl %ecx, -0x14(%rbp)
movl $0x0, -0x34(%rbp)
movl $0x0, -0x38(%rbp)
movl $0xffffffff, -0x3c(%rbp) # imm = 0xFFFFFFFF
movslq 0x5800(%rip), %rdi      # 0xc560
movl $0xc, %esi
callq 0x1040
movq %rax, -0x48(%rbp)
cmpq $0x0, %rax
jne 0x6d80
leaq 0x22b8(%rip), %rdi      # 0x9033
callq 0x1070
movl $0x0, -0x20(%rbp)
movl $0x0, -0x30(%rbp)
movl -0x30(%rbp), %eax
cmpl 0x57c9(%rip), %eax      # 0xc560
jge 0x7049
movq 0x57a4(%rip), %rax      # 0xc548
movslq -0x20(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %eax
movl %eax, -0x24(%rbp)
movl -0x24(%rbp), %edi
movl -0x10(%rbp), %esi
leaq -0x34(%rbp), %rdx
callq 0x7b20
movl %eax, -0x18(%rbp)
movl -0x24(%rbp), %edi
movl -0x14(%rbp), %esi
leaq -0x38(%rbp), %rdx
callq 0x7b20
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0x18(%rbp)
jne 0x6de8
cmpl $0x0, -0x1c(%rbp)
je 0x7021
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
movq 0x5750(%rip), %rax      # 0xc548
movslq -0x20(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %ecx
movq -0x48(%rbp), %rax
movslq -0x3c(%rbp), %rdx
imulq $0xc, %rdx, %rdx
addq %rdx, %rax
movl %ecx, (%rax)
movl -0x30(%rbp), %eax
movl 0x5741(%rip), %ecx      # 0xc560
subl $0x1, %ecx
cmpl %ecx, %eax
jge 0x6e54
movq 0x571b(%rip), %rax      # 0xc548
movq 0x5714(%rip), %rcx      # 0xc548
movslq -0x20(%rbp), %rdx
imulq $0x18, %rdx, %rdx
addq %rdx, %rcx
movslq 0x10(%rcx), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %eax
subl $0x1, %eax
movl %eax, -0x54(%rbp)
jmp 0x6e5d
movl -0xc(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x54(%rbp)
movl -0x54(%rbp), %eax
movl %eax, -0x28(%rbp)
movl -0x28(%rbp), %ecx
movq -0x48(%rbp), %rax
movslq -0x3c(%rbp), %rdx
imulq $0xc, %rdx, %rdx
addq %rdx, %rax
movl %ecx, 0x4(%rax)
cmpl $0x0, -0x18(%rbp)
je 0x6fb4
cmpl $0x0, -0x1c(%rbp)
je 0x6fb4
movq 0x56ad(%rip), %rax      # 0xc540
movslq -0x20(%rbp), %rcx
movl (%rax,%rcx,4), %edx
addl $0x1, %edx
movl %edx, (%rax,%rcx,4)
movq 0x5699(%rip), %rax      # 0xc540
movslq -0x20(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl -0x8(%rbp), %ecx
shll %ecx
subl $0x2, %ecx
cmpl %ecx, %eax
jl 0x6ec5
movl -0x3c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x6ee5
movq 0x5674(%rip), %rax      # 0xc540
movslq -0x20(%rbp), %rcx
movl (%rax,%rcx,4), %ecx
movq -0x48(%rbp), %rax
movslq -0x3c(%rbp), %rdx
imulq $0xc, %rdx, %rdx
addq %rdx, %rax
movl %ecx, 0x8(%rax)
movq 0x565c(%rip), %rax      # 0xc548
movslq -0x20(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movq %rax, -0x50(%rbp)
movq 0x562a(%rip), %rax      # 0xc530
movslq -0x10(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movslq -0x34(%rbp), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
movl %eax, -0x2c(%rbp)
movq 0x5613(%rip), %rax      # 0xc540
movslq -0x20(%rbp), %rcx
movl (%rax,%rcx,4), %ecx
movq -0x50(%rbp), %rax
movslq -0x2c(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rax
movl %ecx, (%rax)
movq 0x55e4(%rip), %rax      # 0xc530
movslq -0x14(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movslq -0x38(%rbp), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
movl %eax, -0x2c(%rbp)
movq 0x55cd(%rip), %rax      # 0xc540
movslq -0x20(%rbp), %rcx
movl (%rax,%rcx,4), %ecx
movq -0x50(%rbp), %rax
movslq -0x2c(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rax
movl %ecx, (%rax)
movsd 0x55d5(%rip), %xmm0     # 0xc568
movq -0x50(%rbp), %rax
movq 0x55a2(%rip), %rcx      # 0xc540
movslq -0x20(%rbp), %rdx
movslq (%rcx,%rdx,4), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movsd %xmm0, 0x8(%rax)
jmp 0x701f
cmpl $0x0, -0x18(%rbp)
je 0x6fe3
movq 0x556f(%rip), %rax      # 0xc530
movslq -0x10(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movslq -0x34(%rbp), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
movl %eax, -0x58(%rbp)
jmp 0x700a
movq 0x5546(%rip), %rax      # 0xc530
movslq -0x14(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movslq -0x38(%rbp), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
movl %eax, -0x58(%rbp)
movl -0x58(%rbp), %ecx
movq -0x48(%rbp), %rax
movslq -0x3c(%rbp), %rdx
imulq $0xc, %rdx, %rdx
addq %rdx, %rax
movl %ecx, 0x8(%rax)
jmp 0x7021
jmp 0x7023
movq 0x551e(%rip), %rax      # 0xc548
movslq -0x20(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0x10(%rax), %eax
movl %eax, -0x20(%rbp)
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x6d8e
movl -0x10(%rbp), %edi
callq 0x7ac0
movslq %eax, %rcx
movq 0x54fd(%rip), %rax      # 0xc558
subq %rcx, %rax
movq %rax, 0x54f3(%rip)      # 0xc558
movsd 0x5503(%rip), %xmm0     # 0xc570
movsd %xmm0, -0x60(%rbp)
movl -0x10(%rbp), %edi
callq 0x7ac0
movsd -0x60(%rbp), %xmm0
cvtsi2sd %eax, %xmm1
callq 0x1150
movsd 0xf78(%rip), %xmm1      # 0x8008
subsd %xmm0, %xmm1
movsd 0x54e4(%rip), %xmm0     # 0xc580
subsd %xmm1, %xmm0
movsd %xmm0, 0x54d8(%rip)     # 0xc580
movq 0x5481(%rip), %rax      # 0xc530
movslq -0x10(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rdi
callq 0x10c0
cmpl $0x0, -0x3c(%rbp)
jge 0x7196
movq -0x48(%rbp), %rdi
callq 0x10c0
movq 0x5453(%rip), %rax      # 0xc530
movl 0x546d(%rip), %ecx      # 0xc550
subl $0x1, %ecx
movslq %ecx, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rcx
movq 0x5435(%rip), %rax      # 0xc530
movslq -0x10(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rax
movq %rcx, 0x8(%rax)
movq 0x541f(%rip), %rax      # 0xc530
movl 0x5439(%rip), %ecx      # 0xc550
subl $0x1, %ecx
movslq %ecx, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movl (%rax), %ecx
movq 0x5403(%rip), %rax      # 0xc530
movslq -0x10(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rax
movl %ecx, (%rax)
movq 0x53ef(%rip), %rax      # 0xc530
movl 0x5409(%rip), %ecx      # 0xc550
subl $0x1, %ecx
movslq %ecx, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movl 0x4(%rax), %ecx
movq 0x53d2(%rip), %rax      # 0xc530
movslq -0x10(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rax
movl %ecx, 0x4(%rax)
movl -0x14(%rbp), %eax
movl 0x53db(%rip), %ecx      # 0xc550
subl $0x1, %ecx
cmpl %ecx, %eax
jne 0x7182
movl -0x10(%rbp), %eax
movl %eax, -0x14(%rbp)
movl 0x53c8(%rip), %eax      # 0xc550
addl $-0x1, %eax
movl %eax, 0x53bf(%rip)      # 0xc550
jmp 0x724f
movq -0x48(%rbp), %rdi
movl -0x3c(%rbp), %eax
addl $0x1, %eax
cltq
imulq $0xc, %rax, %rsi
callq 0x1130
movq %rax, -0x48(%rbp)
cmpq $0x0, %rax
jne 0x71c1
leaq 0x1e87(%rip), %rdi      # 0x9043
callq 0x1070
movq -0x48(%rbp), %rcx
movq 0x5364(%rip), %rax      # 0xc530
movslq -0x10(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rax
movq %rcx, 0x8(%rax)
movl -0x3c(%rbp), %ecx
addl $0x1, %ecx
movq 0x5348(%rip), %rax      # 0xc530
movslq -0x10(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rax
movl %ecx, (%rax)
movl -0x10(%rbp), %edi
callq 0x7ac0
cltq
addq 0x5352(%rip), %rax      # 0xc558
movq %rax, 0x534b(%rip)      # 0xc558
movsd 0x535b(%rip), %xmm0     # 0xc570
movsd %xmm0, -0x68(%rbp)
movl -0x10(%rbp), %edi
callq 0x7ac0
movsd -0x68(%rbp), %xmm0
cvtsi2sd %eax, %xmm1
callq 0x1150
movaps %xmm0, %xmm1
movsd 0xdcd(%rip), %xmm0      # 0x8008
subsd %xmm1, %xmm0
addsd 0x5339(%rip), %xmm0     # 0xc580
movsd %xmm0, 0x5331(%rip)     # 0xc580
movl -0x14(%rbp), %edi
callq 0x7ac0
movslq %eax, %rcx
movq 0x52f7(%rip), %rax      # 0xc558
subq %rcx, %rax
movq %rax, 0x52ed(%rip)      # 0xc558
movsd 0x52fd(%rip), %xmm0     # 0xc570
movsd %xmm0, -0x70(%rbp)
movl -0x14(%rbp), %edi
callq 0x7ac0
movsd -0x70(%rbp), %xmm0
cvtsi2sd %eax, %xmm1
callq 0x1150
movsd 0xd72(%rip), %xmm1      # 0x8008
subsd %xmm0, %xmm1
movsd 0x52de(%rip), %xmm0     # 0xc580
subsd %xmm1, %xmm0
movsd %xmm0, 0x52d2(%rip)     # 0xc580
movq 0x527b(%rip), %rax      # 0xc530
movslq -0x14(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rdi
callq 0x10c0
movq 0x5260(%rip), %rax      # 0xc530
movl 0x527a(%rip), %ecx      # 0xc550
subl $0x1, %ecx
movslq %ecx, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rcx
movq 0x5242(%rip), %rax      # 0xc530
movslq -0x14(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rax
movq %rcx, 0x8(%rax)
movq 0x522c(%rip), %rax      # 0xc530
movl 0x5246(%rip), %ecx      # 0xc550
subl $0x1, %ecx
movslq %ecx, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movl (%rax), %ecx
movq 0x5210(%rip), %rax      # 0xc530
movslq -0x14(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rax
movl %ecx, (%rax)
movq 0x51fc(%rip), %rax      # 0xc530
movl 0x5216(%rip), %ecx      # 0xc550
subl $0x1, %ecx
movslq %ecx, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movl 0x4(%rax), %ecx
movq 0x51df(%rip), %rax      # 0xc530
movslq -0x14(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rax
movl %ecx, 0x4(%rax)
movl 0x51eb(%rip), %eax      # 0xc550
addl $-0x1, %eax
movl %eax, 0x51e2(%rip)      # 0xc550
cmpl $0x0, -0x3c(%rbp)
jge 0x737d
movl $0x2, -0x4(%rbp)
jmp 0x7384
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x70, %rsp
popq %rbp
retq
nopl (%rax)