// File: /workspace/github_c_makefile_star2_O2/genevalab[P]msmove/streec.c
// Function: xover
int xover(int nsam, int ic, int is)
{
	int i, k, lsgm1, newsg, jseg, in;
	int lsg = chrom[ic].nseg;	
	struct seg *pseg = chrom[ic].pseg;
	struct seg *pseg2;
	double len = (pseg+lsg-1)->end - pseg->beg;
	
	cleft -= 1.0-pow(pc, len);

	for (jseg=0; is >= (pseg + jseg)->end; jseg++);
	if (is >= (pseg+jseg)->beg)
		in = 1;
	else
		in = 0;
	newsg = lsg-jseg;
	nchrom++;
	if ((unsigned int)nchrom >= maxchr)
	{
		maxchr += 20;
		chrom = (struct chromo*)realloc(chrom, (size_t)maxchr*sizeof(struct chromo));
		if (chrom == NULL)
			perror("malloc error. segtre2");
	}
	if (!(pseg2 = chrom[nchrom-1].pseg = (struct seg*)calloc((size_t)newsg, sizeof(struct seg))))
		perror(" alloc error. re1");
	chrom[nchrom-1].nseg = newsg;
	chrom[nchrom-1].pop = chrom[ic].pop;
	pseg2->end = (pseg+jseg)->end;
	if (in)
	{
		pseg2->beg = is+1;
		(pseg+jseg)->end = is;
	}
	else
		pseg2->beg = (pseg+jseg)->beg;
	pseg2->desc = (pseg+jseg)->desc;
	for (k=1; k < newsg; k++)
	{
		(pseg2+k)->beg = (pseg+jseg+k)->beg;
		(pseg2+k)->end = (pseg+jseg+k)->end;
		(pseg2+k)->desc = (pseg+jseg+k)->desc;
	}
	lsg = chrom[ic].nseg = lsg-newsg+in;
	lsgm1 = lsg-1;
	nlinks -= pseg2->beg - (pseg+lsgm1)->end;
	len = (pseg+lsgm1)->end - (pseg->beg);
	cleft += 1.0-pow(pc, len);
	len = (pseg2+newsg-1)->end - pseg2->beg;
	cleft += 1.0-pow(pc, len);
	if (!(chrom[ic].pseg = (struct seg*)realloc(chrom[ic].pseg, (size_t)lsg*sizeof(struct seg))))
		perror("realloc error. re2");
	if (in)
	{
		begs = pseg2->beg;
		for (i=0, k=0; (k < nsegs-1) && (begs > seglst[seglst[i].next].beg-1); i=seglst[i].next, k++);
		if (begs != seglst[i].beg)
		{
			if ((unsigned int)nsegs >= seglimit)
			{
				seglimit += SEGINC;
				nnodes = (int*)realloc(nnodes, (size_t)seglimit*sizeof(int));
				if (nnodes == NULL)
					perror("realloc error. 1. segtre_mig.c");
				seglst = (struct segl*)realloc(seglst,(size_t)seglimit*sizeof(struct segl));
				if (seglst == NULL)
					perror("realloc error. 2. segtre_mig.c");
			}
			seglst[nsegs].next = seglst[i].next;
			seglst[i].next = nsegs;
			seglst[nsegs].beg = begs;
			if (!(seglst[nsegs].ptree = (struct node*)calloc((size_t)(2*nsam), sizeof(struct node))))
				perror("calloc error. re3.");
			nnodes[nsegs] = nnodes[i];
			ptree1 = seglst[i].ptree;
			ptree2 = seglst[nsegs].ptree;
			nsegs++;
			for (k=0; k <= nnodes[i]; k++)
			{
				(ptree2+k)->abv = (ptree1+k)->abv;
				(ptree2+k)->time = (ptree1+k)->time;
			}
		}
	}
	return ic;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movl %edx, %r15d
movq 0x5070(%rip), %rax      # 0xa520
movl %esi, -0x44(%rbp)
movslq %esi, %rcx
shlq $0x4, %rcx
movslq (%rax,%rcx), %r13
movq %rcx, -0x50(%rbp)
movq 0x8(%rax,%rcx), %rbx
imulq $0xc, %r13, %rax
movl -0x8(%rbx,%rax), %eax
subl (%rbx), %eax
movl %edi, -0x3c(%rbp)
cvtsi2sd %eax, %xmm1
movsd 0x5080(%rip), %xmm0     # 0xa560
callq 0x1170
movsd 0xb1b(%rip), %xmm1      # 0x6008
subsd %xmm0, %xmm1
movsd 0x5077(%rip), %xmm0     # 0xa570
subsd %xmm1, %xmm0
movsd %xmm0, 0x506b(%rip)     # 0xa570
movq %rbx, -0x60(%rbp)
leaq 0x8(%rbx), %r12
pushq $-0x1
popq %rbx
movq %r12, %rax
addq $0xc, %r12
incl %ebx
cmpl %r15d, -0x4(%rax)
jle 0x5510
movl -0x14(%r12), %eax
movl %eax, -0x40(%rbp)
cmpl %r15d, %eax
setle -0x29(%rbp)
subl %ebx, %r13d
movl 0x5009(%rip), %eax      # 0xa540
incl %eax
movl %eax, 0x5001(%rip)      # 0xa540
movl 0x4fe3(%rip), %esi      # 0xa528
movq 0x4fd4(%rip), %r14      # 0xa520
cmpl %esi, %eax
jb 0x5578
addl $0x14, %esi
movl %esi, 0x4fcf(%rip)      # 0xa528
shlq $0x4, %rsi
movq %r14, %rdi
callq 0x1150
movq %rax, %r14
movq %rax, 0x4fb1(%rip)      # 0xa520
testq %rax, %rax
je 0x588e
movq %r13, -0x58(%rbp)
movslq %r13d, %r13
pushq $0xc
popq %rsi
movq %r13, %rdi
callq 0x1040
movslq 0x4faf(%rip), %rdx      # 0xa540
movq %rdx, %rcx
shlq $0x4, %rcx
movq %rax, -0x8(%r14,%rcx)
testq %rax, %rax
movq %rax, -0x38(%rbp)
je 0x585a
shlq $0x4, %rdx
movq -0x58(%rbp), %rcx
movl %ecx, -0x10(%r14,%rdx)
movslq 0x4f82(%rip), %rdx      # 0xa540
shlq $0x4, %rdx
movq -0x50(%rbp), %rcx
movl 0x4(%r14,%rcx), %ecx
movl %ecx, -0xc(%r14,%rdx)
movl -0x10(%r12), %ecx
movl %ecx, 0x4(%rax)
cmpl %r15d, -0x40(%rbp)
jg 0x55e8
movl %r15d, -0x10(%r12)
incl %r15d
jmp 0x55ed
movl -0x14(%r12), %r15d
xorl %esi, %esi
movb -0x29(%rbp), %cl
movb %cl, %sil
movl %r15d, (%rax)
movl -0xc(%r12), %ecx
movl %ecx, 0x8(%rax)
addq $0x14, %rax
pushq $0x1
popq %rcx
cmpq %r13, %rcx
jge 0x562f
movl -0x8(%r12), %edx
movl %edx, -0x8(%rax)
movl -0x4(%r12), %edx
movl %edx, -0x4(%rax)
movl (%r12), %edx
movl %edx, (%rax)
incq %rcx
addq $0xc, %rax
addq $0xc, %r12
jmp 0x5607
addl %esi, %ebx
movq -0x50(%rbp), %r12
movl %ebx, (%r14,%r12)
imulq $0xc, %rbx, %r14
movq -0x60(%rbp), %rdx
movl -0x8(%rdx,%r14), %eax
subl %eax, %r15d
movslq %r15d, %rcx
subq %rcx, 0x4ef5(%rip)      # 0xa548
subl (%rdx), %eax
cvtsi2sd %eax, %xmm1
movsd 0x4eff(%rip), %xmm0     # 0xa560
movl %esi, %r15d
callq 0x1170
movsd 0x997(%rip), %xmm1      # 0x6008
subsd %xmm0, %xmm1
addsd 0x4ef3(%rip), %xmm1     # 0xa570
imulq $0xc, %r13, %rax
movq -0x38(%rbp), %rcx
movl -0x8(%rcx,%rax), %eax
subl (%rcx), %eax
movsd %xmm1, 0x4edd(%rip)     # 0xa570
cvtsi2sd %eax, %xmm1
movsd 0x4ec1(%rip), %xmm0     # 0xa560
callq 0x1170
movsd 0x95c(%rip), %xmm1      # 0x6008
subsd %xmm0, %xmm1
addsd 0x4eb8(%rip), %xmm1     # 0xa570
movsd %xmm1, 0x4eb0(%rip)     # 0xa570
movq 0x4e59(%rip), %rbx      # 0xa520
movq 0x8(%rbx,%r12), %rdi
movq %r14, %rsi
callq 0x1150
movq %rax, 0x8(%rbx,%r12)
testq %rax, %rax
je 0x587d
testl %r15d, %r15d
je 0x572f
movq -0x38(%rbp), %rax
movl (%rax), %ecx
movl %ecx, 0x4e85(%rip)      # 0xa578
movl 0x4e57(%rip), %eax      # 0xa550
movq 0x4e38(%rip), %r15      # 0xa538
cmpl $0x2, %eax
pushq $0x1
popq %rdx
cmovgel %eax, %edx
xorl %esi, %esi
movslq %esi, %rbx
decl %edx
je 0x5725
imulq $0x18, %rbx, %rsi
movslq 0x10(%r15,%rsi), %rsi
imulq $0x18, %rsi, %rdi
cmpl (%r15,%rdi), %ecx
jge 0x570b
imulq $0x18, %rbx, %r14
cmpl (%r15,%r14), %ecx
jne 0x5741
movl -0x44(%rbp), %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl 0x39a8(%rip), %r12d     # 0x90f0
cmpl %r12d, %eax
jb 0x579b
addl $0x50, %r12d
movl %r12d, 0x3998(%rip)     # 0x90f0
movq 0x4dd1(%rip), %rdi      # 0xa530
leaq (,%r12,4), %rsi
callq 0x1150
movq %rax, 0x4dbd(%rip)      # 0xa530
testq %rax, %rax
je 0x58c5
imulq $0x18, %r12, %rsi
movq %r15, %rdi
callq 0x1150
movq %rax, %r15
movq %rax, 0x4da6(%rip)      # 0xa538
testq %rax, %rax
je 0x58e4
movl 0x10(%r15,%r14), %eax
movslq 0x4da9(%rip), %rcx      # 0xa550
imulq $0x18, %rcx, %rcx
movl %eax, 0x10(%r15,%rcx)
movslq 0x4d99(%rip), %rax      # 0xa550
movl %eax, 0x10(%r15,%r14)
movl 0x4db6(%rip), %ecx      # 0xa578
imulq $0x18, %rax, %rax
movl %ecx, (%r15,%rax)
movl -0x3c(%rbp), %eax
addl %eax, %eax
movslq %eax, %rdi
pushq $0x10
popq %rsi
callq 0x1040
movslq 0x4d6f(%rip), %rcx      # 0xa550
imulq $0x18, %rcx, %rdx
movq %rax, 0x8(%r15,%rdx)
testq %rax, %rax
je 0x58a6
movq 0x4d36(%rip), %rax      # 0xa530
movl (%rax,%rbx,4), %edx
movl %edx, (%rax,%rcx,4)
movq 0x8(%r15,%r14), %rcx
movq %rcx, 0x4d74(%rip)      # 0xa580
movslq 0x4d3d(%rip), %rsi      # 0xa550
imulq $0x18, %rsi, %rdx
movq 0x8(%r15,%rdx), %rdx
movq %rdx, 0x4d65(%rip)      # 0xa588
incl %esi
movl %esi, 0x4d25(%rip)      # 0xa550
pushq $0x8
popq %rsi
xorl %edi, %edi
movslq (%rax,%rbx,4), %r8
cmpq %r8, %rdi
jg 0x572f
movl -0x8(%rcx,%rsi), %r8d
movl %r8d, -0x8(%rdx,%rsi)
movsd (%rcx,%rsi), %xmm0
movsd %xmm0, (%rdx,%rsi)
incq %rdi
addq $0x10, %rsi
jmp 0x5830
leaq 0x15fc(%rip), %rdi      # 0x6e5d
callq 0x1070
movq -0x38(%rbp), %rax
movq 0x4caf(%rip), %r14      # 0xa520
movslq 0x4cc8(%rip), %rdx      # 0xa540
jmp 0x55aa
leaq 0x15eb(%rip), %rdi      # 0x6e6f
callq 0x1070
jmp 0x56e2
leaq 0x15b2(%rip), %rdi      # 0x6e47
callq 0x1070
movq 0x4c7f(%rip), %r14      # 0xa520
jmp 0x5578
leaq 0x1613(%rip), %rdi      # 0x6ec0
callq 0x1070
movslq 0x4c97(%rip), %rcx      # 0xa550
movq 0x4c78(%rip), %r15      # 0xa538
jmp 0x57f3
leaq 0x15b6(%rip), %rdi      # 0x6e82
callq 0x1070
movq 0x4c60(%rip), %r15      # 0xa538
movl 0x3811(%rip), %r12d     # 0x90f0
jmp 0x577c
leaq 0x15b6(%rip), %rdi      # 0x6ea1
callq 0x1070
movq 0x4c41(%rip), %r15      # 0xa538
jmp 0x579b