// File: /workspace/github_c_makefile_star2_O2/genevalab[P]msmove/streec.c
// Function: segtre_mig
struct segl *segtre_mig(struct c_params *cp, int *pnsegs, int *migflag) 
{
	int i, j, k, dec, pop, pop2, c1, c2, ind, rchrom;
	int migrant, source_pop, *config, flagint;
	int eflag, cpop, ic, nsam, npop, nsites, *inconfig;
	double sum, x, ttemp, rft, clefta, tmin, p;
	double prec, cin, prect, mig, ran, coal_prob, rdum, arg;
	double r, f, rf, track_len, **migm;
	double *size, *alphag, *tlast;
	char ev;
	struct devent *nextevent;
	
	nsam = cp->nsam;
	npop = cp->npop;
	nsites = cp->nsites;
	inconfig = cp->config;
	r = cp->r;
	f = cp->f;
	track_len = cp->track_len;
	migm = (double**)malloc((size_t)npop*sizeof(double*));
	for (i=0; i < npop; i++)
	{
		migm[i] = (double*)malloc((size_t)npop*sizeof(double));
		for (j=0; j < npop; j++)
			migm[i][j] = (cp->mig_mat)[i][j];
	}
	nextevent = cp->deventlist;
	
	if (chrom == NULL)
	{
		maxchr = nsam+20;
		chrom = (struct chromo*)malloc((size_t)maxchr*sizeof(struct chromo));
		if (chrom == NULL)
			perror("malloc error. segtre");
	}
	if (nnodes == NULL)
	{
		nnodes = (int*)malloc((size_t)seglimit*sizeof(int));
		if (nnodes == NULL)
			perror("malloc error. segtre_mig");
	}
	if (seglst == NULL)
	{
		seglst = (struct segl*)malloc((size_t)seglimit*sizeof(struct segl));
		if (seglst == NULL)
			perror("malloc error. segtre_mig.c 2");
	}
	config = (int*)malloc((size_t)(npop+1)*sizeof(int));
	if (config == NULL)
		perror("malloc error. segtre.");
	size = (double*)malloc((size_t)npop*sizeof(double));
	if (size == NULL)
		perror("malloc error. segtre.");
	alphag = (double*)malloc((size_t)npop*sizeof(double));
	if (alphag == NULL)
		perror("malloc error. segtre.");
	tlast = (double*)malloc((size_t)npop*sizeof(double));
	if (tlast == NULL)
		perror("malloc error. segtre.");
	for (pop=0; pop < npop; pop++)
	{
		config[pop] = inconfig[pop];
		size[pop] = (cp->size)[pop];
		alphag[pop] = (cp->alphag)[pop];
		tlast[pop] = 0;
	}
	for (pop=ind=0; pop < npop; pop++)
		for (j=0; j < inconfig[pop]; j++, ind++)
		{
			chrom[ind].nseg = 1;
			if (!(chrom[ind].pseg = (struct seg*)malloc(sizeof(struct seg))))
				perror("calloc error. se1");
			(chrom[ind].pseg)->beg = 0;
			(chrom[ind].pseg)->end = nsites-1;
			(chrom[ind].pseg)->desc = ind;
			chrom[ind].pop = pop;
		}
	seglst[0].beg = 0;
	if (!(seglst[0].ptree = (struct node*)calloc((size_t)(2*nsam), sizeof(struct node))))
		perror("calloc error. se2");
	nnodes[0] = nsam-1;
	nchrom = nsam;
	nlinks = (long int)(nsam*(nsites-1));
	nsegs = 1;
	t = 0;
	r /= nsites-1;
	if (f > 0)
		pc = (track_len-1.0)/track_len;
	else
		pc = 1.0;
	lnpc = log(pc);
	cleft = nsam * (1.0-pow(pc, (double)(nsites-1)));
	if (r > 0)
		rf = r*f;
	else
		rf = f/(nsites-1);
	rft = rf*track_len;
	flagint = 0;

	while (nchrom > 1)
	{
		prec = nlinks*r;
		cin = nlinks*rf;
		clefta = cleft*rft;
		prect = prec+cin+clefta;
		mig = 0;
		for (i=0; i < npop; i++)
			mig += config[i]*migm[i][i];
		if ((npop > 1) && (mig == 0) && (nextevent == 0))
		{
			i = 0;
			for (j=0; j < npop; j++) 
				if (config[j] > 0)
					i++;
			if (i > 1)
			{
				fprintf(stderr, " Infinite coalescent time. No migration.\n");
				exit(EXIT_FAILURE);
		   }
		}
		eflag = 0;
		if (prect > 0)
		{
			while ((rdum = genrand_real3()) == 0);
			ttemp = -1.0*log(rdum)/prect;
			if ((eflag == 0) || (ttemp < tmin))
			{
				tmin = ttemp;
				ev = 'r';
				eflag = 1;
			}
		}
		if (mig > 0)
		{
			while ((rdum = genrand_real3()) == 0);
			ttemp = -1.0*log(rdum)/mig;
			if ((eflag == 0) || (ttemp < tmin))
			{
				tmin = ttemp;
				ev = 'm';
				eflag = 1;
			}
		}
		for (pop=0; pop < npop; pop++)
		{
			coal_prob = (double)config[pop]*(config[pop]-1);
			if (coal_prob > 0)
			{
				while ((rdum = genrand_real3()) == 0);
				if (alphag[pop] == 0)
				{
					ttemp = -1.0*log(rdum)*size[pop]/coal_prob;
					if ((eflag == 0) || (ttemp < tmin))
					{
						tmin = ttemp;
						ev = 'c';
						eflag = 1;
						cpop = pop;
					}
				}
				else
				{
					arg = 1.0-alphag[pop]*size[pop]*exp(-1.0*alphag[pop]*(t-tlast[pop]))*log(rdum)/coal_prob;
					if (arg > 0)
					{
						ttemp = log(arg)/alphag[pop];
						if ((eflag == 0) || (ttemp < tmin))
						{
							tmin = ttemp;
							ev = 'c';
							eflag = 1;
							cpop = pop;
						}
					}
				}
			}
		}
		if ((eflag == 0) && (nextevent == 0))
		{
			fprintf(stderr, " Infinite time to next event. Negative growth rate in last time interval or non-communicating subpops.\n");
			exit(EXIT_FAILURE);
		}
		if (((eflag == 0) && (nextevent != 0)) || ((nextevent != 0) && ((t+tmin) >= nextevent->time)))
		{
			t = nextevent->time;
			switch (nextevent->detype)
			{
				case 'N' :
					for (pop=0; pop < npop; pop++)
					{
						size[pop]= nextevent->paramv;
						alphag[pop] = 0;
					}
					nextevent = nextevent->nextde;
					break;
				case 'n' :
					size[nextevent->popi] = nextevent->paramv;
					alphag[nextevent->popi] = 0;
					nextevent = nextevent->nextde;
					break;
				case 'G' :
					for (pop=0; pop < npop; pop++)
					{
						size[pop] = size[pop]*exp(-1.0*alphag[pop]*(t-tlast[pop]));
						alphag[pop]= nextevent->paramv;
						tlast[pop] = t;
					}
					nextevent = nextevent->nextde;
					break;
				case 'g' :
					pop = nextevent->popi;
					size[pop] = size[pop]*exp(-1.0*alphag[pop]*(t-tlast[pop]));
					alphag[pop]= nextevent->paramv;
					tlast[pop] = t;
					nextevent = nextevent->nextde;
					break;
				case 'M' :
					for (pop=0; pop < npop; pop++)
						for (pop2=0; pop2 < npop; pop2++)
							migm[pop][pop2] = (nextevent->paramv)/(npop-1.0);
					for (pop = 0; pop < npop; pop++)
						migm[pop][pop] = nextevent->paramv;
					nextevent = nextevent->nextde;
					break;
				case 'a' :
					for (pop=0; pop < npop; pop++)
						for (pop2=0; pop2 < npop; pop2++)
							migm[pop][pop2] = (nextevent->mat)[pop][pop2];
					nextevent = nextevent->nextde;
					break;
				case 'm' :
					i = nextevent->popi;
					j = nextevent->popj;
					migm[i][i] += nextevent->paramv - migm[i][j];
					migm[i][j]= nextevent->paramv;
					nextevent = nextevent->nextde;
					break;
				case 'j' :
					i = nextevent->popi;
					j = nextevent->popj;
					config[j] += config[i];
					config[i] = 0;
					for (ic=0; ic < nchrom; ic++)
						if (chrom[ic].pop == i)
							chrom[ic].pop = j;
					for (k=0; k < npop; k++)
					{
						if (k != i)
						{
							migm[k][k] -= migm[k][i];
							migm[k][i] = 0;
						}
					}
					nextevent = nextevent->nextde;
					break;
				case 'v' :
					i = nextevent->popi;
					j = nextevent->popj;
					/* start new code here-- old code below */
					config[i] = 0;
					for (ic=0; ic < nchrom; ic++)
					{
						if (chrom[ic].pop == i)
						{
							if (genrand_real3() > nextevent->pmove)
								config[i]++;
							else
							{
								chrom[ic].pop = j;
								config[j]++;
								*migflag = 1;
							}
						}
					}
					nextevent = nextevent->nextde;
					break;
				case 's' :
					i = nextevent->popi;
					p = nextevent->paramv;
					npop++;
					config = (int*)realloc(config, (size_t)npop*sizeof(int));
					size = (double*)realloc(size, (size_t)npop*sizeof(double));
					alphag = (double*)realloc(alphag, (size_t)npop*sizeof(double));
					tlast = (double*)realloc(tlast, (size_t)npop*sizeof(double));
					tlast[npop-1] = t;
					size[npop-1] = 1.0;
					alphag[npop-1] = 0;
					migm = (double**)realloc(migm, (size_t)npop*sizeof(double*));
					for (j=0; j < npop-1; j++)
						migm[j] = (double*)realloc(migm[j], (size_t)npop*sizeof(double));
					migm[npop-1] = (double*)malloc((size_t)npop * sizeof(double));
					for (j=0; j < npop; j++)
						migm[npop-1][j] = migm[j][npop-1] = 0;
					config[npop-1] = 0;
					config[i] = 0;
					for (ic=0; ic < nchrom; ic++)
					{
						if (chrom[ic].pop == i)
						{
							if (genrand_real3() < p)
								config[i]++;
							else
							{
								chrom[ic].pop = npop-1;
								config[npop-1]++;
							}
						}
					}
					nextevent = nextevent->nextde;
					break;
			}
		}
		else
		{
			t += tmin;
			if (ev == 'r')
			{
				if ((ran = genrand_real3()) < prec/prect)
				{
					rchrom = re(nsam);
					config[chrom[rchrom].pop] += 1;
				}
				else if (ran < (prec+clefta)/prect)
				{
					rchrom = cleftr(nsam);
					config[chrom[rchrom].pop] += 1;
				}
				else
				{
					rchrom = cinr(nsam, nsites);
					if (rchrom >= 0)
						config[chrom[rchrom].pop] += 1;
				}
			}
			else if (ev == 'm')
			{
				x = mig*genrand_real3();
				sum = 0;
				for (i=0; i < nchrom; i++)
				{
					sum += migm[chrom[i].pop][chrom[i].pop];
					if (x < sum)
						break;
				}
				migrant = i;
				x = genrand_real3()*migm[chrom[i].pop][chrom[i].pop];
				sum = 0;
				for (i=0; i < npop; i++)
				{
					if (i != chrom[migrant].pop)
					{
						sum += migm[chrom[migrant].pop][i];
						if (x < sum)
							break;
					}
				}
				source_pop = i;
				config[chrom[migrant].pop] -= 1;
				config[source_pop] += 1;
				chrom[migrant].pop = source_pop;
			}
			else
			{
				pick2_chrom(cpop, config, &c1, &c2);
				dec = ca(nsam, nsites, c1, c2);
				config[cpop] -= dec;
			}
		}
	}  
	*pnsegs = nsegs;
	free(config); 
	free(size);
	free(alphag);
	free(tlast);
	for (i=0; i < npop; i++)
		free(migm[i]);
	free(migm);
	return seglst;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xe8, %rsp
movq %rdx, -0xe0(%rbp)
movq %rsi, -0xd8(%rbp)
movq %rdi, %r15
movl (%rdi), %r12d
movl 0x4(%rdi), %eax
movq %rax, -0x88(%rbp)
cltq
movq %rax, -0xa0(%rbp)
movslq %r12d, %r13
movl 0x20(%rdi), %eax
movq %rax, -0xc8(%rbp)
movq 0x8(%rdi), %rax
movq %rax, -0x40(%rbp)
movsd 0x18(%rdi), %xmm0
movsd %xmm0, -0xb0(%rbp)
movsd 0x28(%rdi), %xmm0
movaps %xmm0, -0xc0(%rbp)
movsd 0x30(%rdi), %xmm0
movsd %xmm0, -0xa8(%rbp)
leaq (,%r13,8), %rdi
movq %rdi, %r14
callq 0x1100
movq %rax, -0x48(%rbp)
xorl %ebx, %ebx
movq %r13, %rax
testl %eax, %eax
movl $0x0, %r13d
movq %rax, -0x80(%rbp)
cmovgl %eax, %r13d
cmpq %r13, %rbx
je 0x3dff
movq %r14, %rdi
callq 0x1100
movq -0x48(%rbp), %rcx
movq %rax, (%rcx,%rbx,8)
xorl %ecx, %ecx
cmpq %rcx, %r12
je 0x3dfa
movq 0x10(%r15), %rdx
movq (%rdx,%rbx,8), %rdx
movsd (%rdx,%rcx,8), %xmm0
movsd %xmm0, (%rax,%rcx,8)
incq %rcx
jmp 0x3dde
incq %rbx
jmp 0x3dc7
movq 0x48(%r15), %rax
movq %rax, -0x38(%rbp)
cmpq $0x0, 0x6711(%rip)      # 0xa520
jne 0x3e3a
movq -0x88(%rbp), %rax
leal 0x14(%rax), %edi
movl %edi, 0x6707(%rip)      # 0xa528
shlq $0x4, %rdi
callq 0x1100
movq %rax, 0x66ef(%rip)      # 0xa520
testq %rax, %rax
je 0x4c23
cmpq $0x0, 0x66ee(%rip)      # 0xa530
jne 0x3e63
movl 0x52a6(%rip), %edi      # 0x90f0
shlq $0x2, %rdi
callq 0x1100
movq %rax, 0x66d6(%rip)      # 0xa530
testq %rax, %rax
je 0x4c34
cmpq $0x0, 0x66cd(%rip)      # 0xa538
jne 0x3e8c
movl 0x527d(%rip), %eax      # 0x90f0
imulq $0x18, %rax, %rdi
callq 0x1100
movq %rax, 0x66b5(%rip)      # 0xa538
testq %rax, %rax
je 0x4c45
movq -0x80(%rbp), %rax
leaq 0x4(,%rax,4), %rdi
callq 0x1100
movq %rax, -0x30(%rbp)
testq %rax, %rax
je 0x4bce
movq %r14, %rdi
callq 0x1100
movq %rax, -0x50(%rbp)
testq %rax, %rax
je 0x4bdf
movq %r14, %rdi
callq 0x1100
movq %rax, -0x58(%rbp)
testq %rax, %rax
je 0x4bf0
movq %r14, %rdi
callq 0x1100
movq %rax, -0x60(%rbp)
testq %rax, %rax
je 0x4c01
leaq (,%r13,4), %rax
xorl %ecx, %ecx
movq -0x30(%rbp), %rsi
cmpq %rcx, %rax
je 0x3f39
movq -0x40(%rbp), %rdx
movl (%rdx,%rcx), %edx
movl %edx, (%rsi,%rcx)
movq 0x38(%r15), %rdx
movsd (%rdx,%rcx,2), %xmm0
movq -0x50(%rbp), %rdx
movsd %xmm0, (%rdx,%rcx,2)
movq 0x40(%r15), %rdx
movsd (%rdx,%rcx,2), %xmm0
movq -0x58(%rbp), %rdx
movsd %xmm0, (%rdx,%rcx,2)
movq -0x60(%rbp), %rdx
andq $0x0, (%rdx,%rcx,2)
addq $0x4, %rcx
jmp 0x3ef7
movq %r12, -0x90(%rbp)
movq -0xc8(%rbp), %rax
decl %eax
movl %eax, -0x80(%rbp)
xorl %r12d, %r12d
xorl %ebx, %ebx
movq %r13, -0x98(%rbp)
cmpq %r13, %r12
je 0x3fe8
movslq %ebx, %r15
movq %r15, -0x68(%rbp)
shlq $0x4, %r15
xorl %r13d, %r13d
movq -0x40(%rbp), %rax
cmpl (%rax,%r12,4), %r13d
jge 0x3fd2
movq 0x65a0(%rip), %r14      # 0xa520
movl $0x1, (%r14,%r15)
pushq $0xc
popq %rdi
callq 0x1100
movq %rax, 0x8(%r14,%r15)
testq %rax, %rax
je 0x3fb8
andl $0x0, (%rax)
movl -0x80(%rbp), %ecx
movl %ecx, 0x4(%rax)
leal (%rbx,%r13), %ecx
movl %ecx, 0x8(%rax)
movl %r12d, 0x4(%r14,%r15)
incq %r13
addq $0x10, %r15
jmp 0x3f6f
leaq 0x2dd2(%rip), %rdi      # 0x6d91
callq 0x1070
movq 0x6555(%rip), %r14      # 0xa520
movq 0x8(%r14,%r15), %rax
jmp 0x3f9a
incq %r12
movq -0x68(%rbp), %rbx
addq %r13, %rbx
movq -0x98(%rbp), %r13
jmp 0x3f58
movq 0x6549(%rip), %rbx      # 0xa538
andl $0x0, (%rbx)
movq -0xa0(%rbp), %rdi
addq %rdi, %rdi
pushq $0x10
popq %rsi
callq 0x1040
movq %rax, 0x8(%rbx)
testq %rax, %rax
je 0x4c12
movq -0x88(%rbp), %rbx
leal -0x1(%rbx), %eax
movq 0x650e(%rip), %rcx      # 0xa530
movl %eax, (%rcx)
movl -0x80(%rbp), %eax
cvtsi2sd %eax, %xmm0
movsd %xmm0, -0x40(%rbp)
movl %ebx, 0x650a(%rip)      # 0xa540
imull %ebx, %eax
cltq
movq %rax, 0x6506(%rip)      # 0xa548
movl $0x1, 0x6504(%rip)      # 0xa550
andq $0x0, 0x6504(%rip)      # 0xa558
movsd -0xb0(%rbp), %xmm1
divsd %xmm0, %xmm1
movsd %xmm1, -0xb0(%rbp)
movsd 0x1fb8(%rip), %xmm1     # 0x6028
movsd -0xa8(%rbp), %xmm0
addsd %xmm0, %xmm1
divsd %xmm0, %xmm1
xorpd %xmm0, %xmm0
cmpltsd -0xc0(%rbp), %xmm0
andpd %xmm0, %xmm1
movsd 0x1f6f(%rip), %xmm2     # 0x6008
andnpd %xmm2, %xmm0
orpd %xmm1, %xmm0
movlpd %xmm0, 0x64b7(%rip)     # 0xa560
callq 0x1060
movsd %xmm0, 0x64b2(%rip)     # 0xa568
cvtsi2sd %ebx, %xmm0
movsd %xmm0, -0x80(%rbp)
movsd 0x6499(%rip), %xmm0     # 0xa560
movsd -0x40(%rbp), %xmm1
callq 0x1170
movsd 0x1f2f(%rip), %xmm1     # 0x6008
subsd %xmm0, %xmm1
mulsd -0x80(%rbp), %xmm1
movsd %xmm1, 0x6486(%rip)     # 0xa570
movsd -0xb0(%rbp), %xmm2
movapd %xmm2, %xmm0
movapd -0xc0(%rbp), %xmm1
mulsd %xmm1, %xmm0
divsd -0x40(%rbp), %xmm1
movapd %xmm1, %xmm3
xorpd %xmm1, %xmm1
cmpltsd %xmm2, %xmm1
andpd %xmm1, %xmm0
andnpd %xmm3, %xmm1
orpd %xmm0, %xmm1
movapd %xmm1, -0x110(%rbp)
mulsd -0xa8(%rbp), %xmm1
movapd %xmm1, -0x100(%rbp)
movq -0x90(%rbp), %r12
movq -0x48(%rbp), %rbx
movq -0x38(%rbp), %r9
movq -0x30(%rbp), %r10
testl %r12d, %r12d
movl $0x0, %r13d
cmovgl %r12d, %r13d
cmpl $0x2, 0x63e1(%rip)      # 0xa540
jl 0x4b5c
cvtsi2sdq 0x63da(%rip), %xmm3 # 0xa548
movsd -0xb0(%rbp), %xmm0
mulsd %xmm3, %xmm0
mulsd -0x110(%rbp), %xmm3
movsd 0x63e6(%rip), %xmm4     # 0xa570
movsd %xmm0, -0xf0(%rbp)
addsd %xmm0, %xmm3
xorpd %xmm2, %xmm2
xorl %eax, %eax
xorpd %xmm1, %xmm1
cmpq %rax, %r13
je 0x41bd
cvtsi2sdl (%r10,%rax,4), %xmm0
movq (%rbx,%rax,8), %rcx
mulsd (%rcx,%rax,8), %xmm0
addsd %xmm0, %xmm2
incq %rax
jmp 0x41a0
movl %r12d, %r15d
cmpl $0x2, %r12d
jl 0x41f6
ucomisd %xmm1, %xmm2
jne 0x41f6
jp 0x41f6
testq %r9, %r9
jne 0x41f6
xorl %eax, %eax
xorl %ecx, %ecx
cmpq %rax, %r15
je 0x41ed
xorl %edx, %edx
cmpl $0x0, (%r10,%rax,4)
setg %dl
addl %edx, %ecx
incq %rax
jmp 0x41d7
cmpl $0x2, %ecx
jae 0x4c6b
mulsd -0x100(%rbp), %xmm4
movsd %xmm4, -0xe8(%rbp)
addsd %xmm4, %xmm3
movsd %xmm3, -0xa0(%rbp)
xorl %r14d, %r14d
ucomisd %xmm1, %xmm3
movq %r9, -0x38(%rbp)
movq %r10, -0x30(%rbp)
movsd %xmm2, -0xc0(%rbp)
jbe 0x4275
callq 0x3ca9
ucomisd 0x1dd8(%rip), %xmm0     # 0x6010
jne 0x423c
jnp 0x422b
callq 0x1060
xorpd 0x1e07(%rip), %xmm0     # 0x6050
divsd -0xa0(%rbp), %xmm0
movapd %xmm0, -0x80(%rbp)
movb $0x72, -0x98(%rbp)
pushq $0x1
popq %r14
movq -0x38(%rbp), %r9
movq -0x30(%rbp), %r10
xorpd %xmm1, %xmm1
movsd -0xc0(%rbp), %xmm2
ucomisd %xmm1, %xmm2
movq %r12, -0x90(%rbp)
jbe 0x42e5
callq 0x3ca9
ucomisd 0x1d81(%rip), %xmm0     # 0x6010
jne 0x4293
jnp 0x4282
callq 0x1060
movsd -0xa0(%rbp), %xmm1
ucomisd 0x1d68(%rip), %xmm1     # 0x6010
xorpd 0x1da0(%rip), %xmm0     # 0x6050
divsd -0xc0(%rbp), %xmm0
movq -0x38(%rbp), %r9
movq -0x30(%rbp), %r10
xorpd %xmm1, %xmm1
jbe 0x42d5
movapd -0x80(%rbp), %xmm2
ucomisd %xmm0, %xmm2
pushq $0x1
popq %r14
jbe 0x42e5
movb $0x6d, -0x98(%rbp)
movapd %xmm0, -0x80(%rbp)
pushq $0x1
popq %r14
xorl %r12d, %r12d
cmpq %r13, %r12
je 0x443a
movl (%r10,%r12,4), %eax
cvtsi2sd %eax, %xmm0
decl %eax
cvtsi2sd %eax, %xmm2
mulsd %xmm0, %xmm2
ucomisd %xmm1, %xmm2
jbe 0x4432
movsd %xmm2, -0x40(%rbp)
callq 0x3ca9
xorpd %xmm2, %xmm2
ucomisd %xmm2, %xmm0
jne 0x4323
jnp 0x4312
movq -0x58(%rbp), %rax
movsd (%rax,%r12,8), %xmm1
ucomisd %xmm2, %xmm1
jne 0x436b
jp 0x436b
callq 0x1060
xorpd 0x1d0e(%rip), %xmm0     # 0x6050
movq -0x50(%rbp), %rax
mulsd (%rax,%r12,8), %xmm0
divsd -0x40(%rbp), %xmm0
testl %r14d, %r14d
movq -0x38(%rbp), %r9
movq -0x30(%rbp), %r10
xorpd %xmm1, %xmm1
jne 0x4402
jmp 0x4411
movq -0x50(%rbp), %rax
movsd (%rax,%r12,8), %xmm2
mulsd %xmm1, %xmm2
movsd %xmm2, -0x68(%rbp)
xorpd 0x1cca(%rip), %xmm1     # 0x6050
movsd %xmm0, -0x48(%rbp)
movsd 0x61c5(%rip), %xmm0     # 0xa558
movq -0x60(%rbp), %rax
subsd (%rax,%r12,8), %xmm0
mulsd %xmm1, %xmm0
callq 0x1180
mulsd -0x68(%rbp), %xmm0
movsd %xmm0, -0x68(%rbp)
movsd -0x48(%rbp), %xmm0
callq 0x1060
movapd %xmm0, %xmm1
mulsd -0x68(%rbp), %xmm1
divsd -0x40(%rbp), %xmm1
movsd 0x1c38(%rip), %xmm0     # 0x6008
subsd %xmm1, %xmm0
ucomisd 0x1c34(%rip), %xmm0     # 0x6010
xorpd %xmm1, %xmm1
jbe 0x442a
callq 0x1060
xorpd %xmm1, %xmm1
movq -0x58(%rbp), %rax
divsd (%rax,%r12,8), %xmm0
testl %r14d, %r14d
movq -0x38(%rbp), %r9
movq -0x30(%rbp), %r10
je 0x4411
movapd -0x80(%rbp), %xmm2
ucomisd %xmm0, %xmm2
pushq $0x1
popq %r14
jbe 0x4432
movb $0x63, -0x98(%rbp)
movl %r12d, -0xa8(%rbp)
movapd %xmm0, -0x80(%rbp)
pushq $0x1
popq %r14
jmp 0x4432
movq -0x38(%rbp), %r9
movq -0x30(%rbp), %r10
incq %r12
jmp 0x42e8
testl %r14d, %r14d
jne 0x4448
testq %r9, %r9
je 0x4c56
testl %r14d, %r14d
movq -0x90(%rbp), %r12
jne 0x4460
testq %r9, %r9
je 0x4460
movsd (%r9), %xmm0
jmp 0x44d7
movsd 0x60f0(%rip), %xmm1     # 0xa558
addsd -0x80(%rbp), %xmm1
testq %r9, %r9
je 0x447d
movsd (%r9), %xmm0
ucomisd %xmm0, %xmm1
jae 0x44d7
movsd %xmm1, 0x60d3(%rip)     # 0xa558
movb -0x98(%rbp), %al
cmpb $0x6d, %al
je 0x462b
movzbl %al, %eax
cmpl $0x72, %eax
jne 0x4688
callq 0x3ca9
movsd -0xa0(%rbp), %xmm3
movsd -0xf0(%rbp), %xmm2
movapd %xmm2, %xmm1
divsd %xmm3, %xmm1
ucomisd %xmm0, %xmm1
jbe 0x479e
movq -0x88(%rbp), %rdi
callq 0x4c8f
jmp 0x47c0
movsd %xmm0, 0x6079(%rip)     # 0xa558
movzbl 0x28(%r9), %eax
leal -0x67(%rax), %ecx
cmpl $0x7, %ecx
jbe 0x45a1
cmpl $0x47, %eax
je 0x4a83
cmpl $0x4d, %eax
je 0x4a2c
cmpl $0x4e, %eax
je 0x4842
cmpl $0x61, %eax
je 0x49e7
cmpl $0x73, %eax
je 0x486a
cmpl $0x76, %eax
jne 0x414b
movq %rbx, %r13
movslq 0x8(%r9), %rbx
movl 0xc(%r9), %eax
andl $0x0, (%r10,%rbx,4)
movslq %eax, %r14
pushq $0x4
popq %r15
xorl %r12d, %r12d
movslq 0x5ff9(%rip), %rax      # 0xa540
cmpq %rax, %r12
jge 0x4a19
movq 0x5fc9(%rip), %rax      # 0xa520
cmpl %ebx, (%rax,%r15)
jne 0x4598
callq 0x3ca9
movq -0x38(%rbp), %r9
ucomisd 0x10(%r9), %xmm0
jbe 0x4578
movq -0x30(%rbp), %r10
incl (%r10,%rbx,4)
jmp 0x4598
movq 0x5fa1(%rip), %rax      # 0xa520
movl %r14d, (%rax,%r15)
movq -0x30(%rbp), %r10
incl (%r10,%r14,4)
movq -0xe0(%rbp), %rax
movl $0x1, (%rax)
incq %r12
addq $0x10, %r15
jmp 0x4540
leaq 0x2768(%rip), %rdx      # 0x6d10
movslq (%rdx,%rcx,4), %rax
addq %rdx, %rax
jmpq *%rax
movq %rbx, -0x48(%rbp)
movslq 0x8(%r9), %rbx
movq -0x50(%rbp), %r15
movsd (%r15,%rbx,8), %xmm1
movsd %xmm1, -0x40(%rbp)
movq -0x58(%rbp), %r13
movsd (%r13,%rbx,8), %xmm1
xorpd 0x1a75(%rip), %xmm1     # 0x6050
movq %r12, %r14
movq -0x60(%rbp), %r12
subsd (%r12,%rbx,8), %xmm0
mulsd %xmm1, %xmm0
callq 0x1180
movq -0x30(%rbp), %r10
movq -0x38(%rbp), %r9
mulsd -0x40(%rbp), %xmm0
movsd %xmm0, (%r15,%rbx,8)
movsd 0x18(%r9), %xmm0
movsd %xmm0, (%r13,%rbx,8)
movsd 0x5f3f(%rip), %xmm0     # 0xa558
movsd %xmm0, (%r12,%rbx,8)
movq %r14, %r12
movq -0x48(%rbp), %rbx
jmp 0x4725
movq %rbx, %r14
callq 0x3ca9
movsd -0xc0(%rbp), %xmm1
mulsd %xmm0, %xmm1
movl 0x5efb(%rip), %ebx      # 0xa540
testl %ebx, %ebx
movl $0x0, %eax
cmovlel %eax, %ebx
movq 0x5eca(%rip), %rax      # 0xa520
addq $0x4, %rax
xorpd %xmm0, %xmm0
xorl %ecx, %ecx
cmpq %rcx, %rbx
je 0x47e6
movslq (%rax), %rdx
movq (%r14,%rdx,8), %rsi
addsd (%rsi,%rdx,8), %xmm0
ucomisd %xmm1, %xmm0
ja 0x47e3
incq %rcx
addq $0x10, %rax
jmp 0x4660
movl -0xa8(%rbp), %r14d
movl %r14d, %edi
movq %r10, %rsi
leaq -0xd0(%rbp), %rdx
leaq -0xcc(%rbp), %rcx
callq 0x4f81
movl -0xd0(%rbp), %edx
movl -0xcc(%rbp), %ecx
movq -0x88(%rbp), %rdi
movq -0xc8(%rbp), %rsi
callq 0x5041
movq -0x30(%rbp), %r10
movslq %r14d, %rcx
subl %eax, (%r10,%rcx,4)
movq -0x38(%rbp), %r9
jmp 0x414b
movslq 0x8(%r9), %rax
movslq 0xc(%r9), %rcx
movsd 0x18(%r9), %xmm0
movq (%rbx,%rax,8), %rdx
subsd (%rdx,%rcx,8), %xmm0
addsd (%rdx,%rax,8), %xmm0
movsd %xmm0, (%rdx,%rax,8)
movsd 0x18(%r9), %xmm0
movsd %xmm0, (%rdx,%rcx,8)
jmp 0x4725
movsd 0x18(%r9), %xmm0
movslq 0x8(%r9), %rax
movq -0x50(%rbp), %rcx
movsd %xmm0, (%rcx,%rax,8)
movq -0x58(%rbp), %rcx
andq $0x0, (%rcx,%rax,8)
movq 0x30(%r9), %r9
jmp 0x414b
movslq 0x8(%r9), %rax
movslq 0xc(%r9), %rcx
movl (%r10,%rax,4), %edx
addl %edx, (%r10,%rcx,4)
andl $0x0, (%r10,%rax,4)
movq 0x5dd6(%rip), %rdx      # 0xa520
movl 0x5df0(%rip), %esi      # 0xa540
addq $0x4, %rdx
xorl %edi, %edi
movslq %esi, %r8
cmpq %r8, %rdi
jge 0x4773
cmpl %eax, (%rdx)
jne 0x476a
movl %ecx, (%rdx)
movl 0x5dd6(%rip), %esi      # 0xa540
incq %rdi
addq $0x10, %rdx
jmp 0x4756
movl %eax, %ecx
xorl %edx, %edx
cmpq %rdx, %r13
je 0x4725
cmpq %rdx, %rcx
je 0x4799
movq (%rbx,%rdx,8), %rsi
movsd (%rsi,%rdx,8), %xmm0
subsd (%rsi,%rax,8), %xmm0
movsd %xmm0, (%rsi,%rdx,8)
andq $0x0, (%rsi,%rax,8)
incq %rdx
jmp 0x4777
addsd -0xe8(%rbp), %xmm2
divsd %xmm3, %xmm2
ucomisd %xmm0, %xmm2
jbe 0x4b1e
movq -0x88(%rbp), %rdi
callq 0x4d16
movq 0x5d59(%rip), %rcx      # 0xa520
cltq
shlq $0x4, %rax
movslq 0x4(%rcx,%rax), %rax
movq -0x30(%rbp), %r10
incl (%r10,%rax,4)
movq -0x38(%rbp), %r9
jmp 0x414b
movq %rcx, %rbx
callq 0x3ca9
movq 0x5d2e(%rip), %rax      # 0xa520
shlq $0x4, %rbx
addq %rbx, %rax
addq $0x4, %rax
movl (%rax), %esi
movslq %esi, %rcx
movq %r14, %rbx
movq (%r14,%rcx,8), %rdi
mulsd (%rdi,%rcx,8), %xmm0
xorpd %xmm1, %xmm1
xorl %edx, %edx
movq -0x38(%rbp), %r9
movq -0x30(%rbp), %r10
cmpq %rdx, %r13
je 0x483a
cmpq %rdx, %rsi
je 0x4835
addsd (%rdi,%rdx,8), %xmm1
ucomisd %xmm0, %xmm1
ja 0x4b0b
incq %rdx
jmp 0x481c
movq %r13, %rdx
jmp 0x4b0e
xorl %eax, %eax
cmpq %rax, %r13
je 0x4725
movsd 0x18(%r9), %xmm0
movq -0x50(%rbp), %rcx
movsd %xmm0, (%rcx,%rax,8)
movq -0x58(%rbp), %rcx
andq $0x0, (%rcx,%rax,8)
incq %rax
jmp 0x4844
movslq 0x8(%r9), %rax
movq %rax, -0x68(%rbp)
movsd 0x18(%r9), %xmm0
movsd %xmm0, -0x40(%rbp)
leal 0x1(%r12), %eax
movl %eax, -0xc0(%rbp)
movslq %r12d, %r12
leaq 0x4(,%r12,4), %rsi
movq %r10, %rdi
callq 0x1150
movq %rax, -0x30(%rbp)
leaq 0x8(,%r12,8), %r15
movq -0x50(%rbp), %rdi
movq %r15, %rsi
callq 0x1150
movq %rax, -0x50(%rbp)
movq -0x58(%rbp), %rdi
movq %r15, %rsi
callq 0x1150
movq %rax, %r14
movq -0x60(%rbp), %rdi
movq %r15, %rsi
callq 0x1150
movsd 0x5c7e(%rip), %xmm0     # 0xa558
movq %rax, -0x60(%rbp)
movsd %xmm0, (%rax,%r12,8)
movabsq $0x3ff0000000000000, %rax # imm = 0x3FF0000000000000
movq -0x50(%rbp), %rcx
movq %rax, (%rcx,%r12,8)
movq %r14, -0x58(%rbp)
andq $0x0, (%r14,%r12,8)
movq %rbx, %rdi
movq %r15, %rsi
callq 0x1150
movq %rax, -0x48(%rbp)
xorl %ebx, %ebx
cmpq %rbx, %r13
je 0x492e
movq -0x48(%rbp), %r14
movq (%r14,%rbx,8), %rdi
movq %r15, %rsi
callq 0x1150
movq %rax, (%r14,%rbx,8)
incq %rbx
jmp 0x4910
movq %r15, %rdi
callq 0x1100
movq -0x48(%rbp), %rsi
movq %rax, (%rsi,%r12,8)
xorl %ecx, %ecx
movq -0x38(%rbp), %r9
movq -0x30(%rbp), %r10
movq -0x68(%rbp), %r14
cmpq %r12, %rcx
jg 0x4964
movq (%rsi,%rcx,8), %rdx
andq $0x0, (%rdx,%r12,8)
andq $0x0, (%rax,%rcx,8)
incq %rcx
jmp 0x494c
andl $0x0, (%r10,%r12,4)
andl $0x0, (%r10,%r14,4)
leaq (%r10,%r12,4), %rbx
leaq (%r10,%r14,4), %r15
pushq $0x4
popq %r12
xorl %r13d, %r13d
movslq 0x5bbc(%rip), %rax      # 0xa540
cmpq %rax, %r13
jge 0x49d1
movq 0x5b90(%rip), %rax      # 0xa520
cmpl %r14d, (%rax,%r12)
jne 0x49c8
callq 0x3ca9
movsd -0x40(%rbp), %xmm1
ucomisd %xmm0, %xmm1
movq %r15, %rax
ja 0x49be
movq 0x5b70(%rip), %rax      # 0xa520
movq -0x90(%rbp), %rcx
movl %ecx, (%rax,%r12)
movq %rbx, %rax
incl (%rax)
movq -0x38(%rbp), %r9
movq -0x30(%rbp), %r10
incq %r13
addq $0x10, %r12
jmp 0x497d
movq 0x30(%r9), %r9
movl -0xc0(%rbp), %eax
movl %eax, %r12d
movq -0x48(%rbp), %rbx
jmp 0x414b
xorl %eax, %eax
cmpq %r13, %rax
je 0x4725
xorl %ecx, %ecx
cmpq %rcx, %r15
je 0x4a14
movq 0x20(%r9), %rdx
movq (%rdx,%rax,8), %rdx
movsd (%rdx,%rcx,8), %xmm0
movq (%rbx,%rax,8), %rdx
movsd %xmm0, (%rdx,%rcx,8)
incq %rcx
jmp 0x49f4
incq %rax
jmp 0x49e9
movq 0x30(%r9), %r9
movq -0x90(%rbp), %r12
movq %r13, %rbx
jmp 0x414b
cvtsi2sd %r12d, %xmm0
addsd 0x15ef(%rip), %xmm0     # 0x6028
xorl %eax, %eax
cmpq %r13, %rax
je 0x4a64
xorl %ecx, %ecx
cmpq %rcx, %r15
je 0x4a5f
movsd 0x18(%r9), %xmm1
divsd %xmm0, %xmm1
movq (%rbx,%rax,8), %rdx
movsd %xmm1, (%rdx,%rcx,8)
incq %rcx
jmp 0x4a42
incq %rax
jmp 0x4a3b
xorl %eax, %eax
cmpq %rax, %r13
je 0x4725
movsd 0x18(%r9), %xmm0
movq (%rbx,%rax,8), %rcx
movsd %xmm0, (%rcx,%rax,8)
incq %rax
jmp 0x4a66
movq %rbx, -0x48(%rbp)
xorl %ebx, %ebx
cmpq %rbx, %r13
je 0x4af3
movq -0x50(%rbp), %r15
movsd (%r15,%rbx,8), %xmm1
movsd %xmm1, -0x40(%rbp)
movq -0x58(%rbp), %r14
movsd (%r14,%rbx,8), %xmm1
xorpd 0x15a1(%rip), %xmm1     # 0x6050
movq -0x60(%rbp), %r12
subsd (%r12,%rbx,8), %xmm0
mulsd %xmm1, %xmm0
callq 0x1180
movq -0x30(%rbp), %r10
mulsd -0x40(%rbp), %xmm0
movsd %xmm0, (%r15,%rbx,8)
movq -0x38(%rbp), %rax
movsd 0x18(%rax), %xmm0
movsd %xmm0, (%r14,%rbx,8)
movsd 0x5a70(%rip), %xmm0     # 0xa558
movsd %xmm0, (%r12,%rbx,8)
incq %rbx
jmp 0x4a89
movq -0x38(%rbp), %r9
movq 0x30(%r9), %r9
movq -0x48(%rbp), %rbx
movq -0x90(%rbp), %r12
jmp 0x414b
movl %edx, %r13d
decl (%r10,%rcx,4)
incl (%r10,%rdx,4)
movl %r13d, (%rax)
jmp 0x414b
movq -0x88(%rbp), %rdi
movq -0xc8(%rbp), %rsi
callq 0x4e4c
testl %eax, %eax
movq -0x38(%rbp), %r9
movq -0x30(%rbp), %r10
js 0x414b
movq 0x59d8(%rip), %rcx      # 0xa520
movl %eax, %eax
shlq $0x4, %rax
movslq 0x4(%rcx,%rax), %rax
incl (%r10,%rax,4)
jmp 0x414b
movq %rbx, %r14
movl 0x59eb(%rip), %eax      # 0xa550
movq -0xd8(%rbp), %rcx
movl %eax, (%rcx)
movq %r10, %rdi
callq 0x10c0
movq -0x50(%rbp), %rdi
callq 0x10c0
movq -0x58(%rbp), %rdi
callq 0x10c0
movq -0x60(%rbp), %rdi
callq 0x10c0
xorl %ebx, %ebx
testl %r12d, %r12d
cmovlel %ebx, %r12d
cmpq %rbx, %r12
je 0x4bad
movq (%r14,%rbx,8), %rdi
callq 0x10c0
incq %rbx
jmp 0x4b9a
movq %r14, %rdi
callq 0x10c0
movq 0x597c(%rip), %rax      # 0xa538
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x21a6(%rip), %rdi      # 0x6d7b
callq 0x1070
jmp 0x3eaa
leaq 0x2195(%rip), %rdi      # 0x6d7b
callq 0x1070
jmp 0x3ebf
leaq 0x2184(%rip), %rdi      # 0x6d7b
callq 0x1070
jmp 0x3ed4
leaq 0x2173(%rip), %rdi      # 0x6d7b
callq 0x1070
jmp 0x3ee9
leaq 0x218a(%rip), %rdi      # 0x6da3
callq 0x1070
jmp 0x4011
leaq 0x2106(%rip), %rdi      # 0x6d30
callq 0x1070
jmp 0x3e3a
leaq 0x210a(%rip), %rdi      # 0x6d45
callq 0x1070
jmp 0x3e63
leaq 0x2112(%rip), %rdi      # 0x6d5e
callq 0x1070
jmp 0x3e8c
movq 0x4383(%rip), %rax      # 0x8fe0
movq (%rax), %rcx
leaq 0x2178(%rip), %rdi      # 0x6ddf
pushq $0x67
jmp 0x4c7e
movq 0x436e(%rip), %rax      # 0x8fe0
movq (%rax), %rcx
leaq 0x2139(%rip), %rdi      # 0x6db5
pushq $0x29
popq %rsi
pushq $0x1
popq %rdx
callq 0x11a0
pushq $0x1
popq %rdi
callq 0x10d0