// File: /workspace/github_c_makefile_star2_O3/genevalab[P]msmove/ms.c
// Function: gensam
int gensam(char **list, double *pprobss, double *ptmrca, double *pttot, int *migflag) 
{
	int nsegs, i, k, seg, ns, start, end, len, segsit;
	int *ss, segsitesin, nsites, nsam, mfreq;
	double nsinv, tseg, tt, theta, es, *pk;
	struct segl *seglst;

	nsites = pars.cp.nsites;
	nsinv = 1.0/nsites;
	*migflag = 0;
	seglst = segtre_mig(&(pars.cp), &nsegs, migflag);
	nsam = pars.cp.nsam;
	segsitesin = pars.mp.segsitesin;
	theta = pars.mp.theta;
	mfreq = pars.mp.mfreq;

	if (pars.mp.treeflag) 
	{
	  	ns = 0;
	    for (seg=0, k=0; k < nsegs; seg = seglst[seg].next, k++)
		{
			if ( (pars.cp.r > 0) || (pars.cp.f > 0) )
			{
				end = k < nsegs-1 ? seglst[seglst[seg].next].beg-1 : nsites-1;
				start = seglst[seg].beg;
				len = end-start+1;
				fprintf(stdout, "[%d]", len);
			}
			prtree(seglst[seg].ptree, nsam);
			if ((segsitesin == 0) && (theta == 0) && (pars.mp.timeflag == 0)) 
				free(seglst[seg].ptree);
		}
	}

	if (pars.mp.timeflag)
	{
		tt = 0;
		for (seg=0, k=0; k < nsegs; seg = seglst[seg].next, k++)
		{ 
			if (mfreq > 1) 
				ndes_setup(seglst[seg].ptree, nsam);
			end = k < nsegs-1 ? seglst[seglst[seg].next].beg-1 : nsites-1;
			start = seglst[seg].beg;
			if ((nsegs == 1) || ((start <= nsites/2) && (end >= nsites/2)))
				*ptmrca = (seglst[seg].ptree+2*nsam-2)->time;
			len = end-start+1;
			tseg = len / (double)nsites;
			if (mfreq == 1)
				tt += ttime(seglst[seg].ptree, nsam) * tseg;
			else 
				tt += ttimemf(seglst[seg].ptree, nsam, mfreq)*tseg;
			if ((segsitesin == 0) && (theta == 0)) 
				free(seglst[seg].ptree);
		}
		*pttot = tt;
	}	
	
    if ((segsitesin == 0) && (theta > 0))
	{
		ns = 0;
		for (seg=0, k=0; k < nsegs; seg = seglst[seg].next, k++)
		{ 
			if (mfreq > 1)
				ndes_setup(seglst[seg].ptree, nsam);
			end = k < nsegs-1 ? seglst[seglst[seg].next].beg-1 : nsites-1;
			start = seglst[seg].beg;
			len = end-start+1;
			tseg = len*theta/nsites;
			if (mfreq == 1)
				tt = ttime(seglst[seg].ptree, nsam);
			else
				tt = ttimemf(seglst[seg].ptree, nsam, mfreq);
			segsit = poisso(tseg*tt);
			if ((unsigned int)(segsit+ns) >= maxsites)
			{
				maxsites = segsit+ns+SITESINC;
				posit = (double*)realloc(posit, (size_t)maxsites*sizeof(double));
				if (posit == NULL)
					perror("Realloc failure for posit");
				biggerlist(nsam, list); 
			}
			make_gametes(nsam, mfreq, seglst[seg].ptree, tt, segsit, ns, list);
			free(seglst[seg].ptree);
			locate(segsit, start * nsinv, len * nsinv, posit + ns);   
			ns += segsit;
		}
	}
	else
		if (segsitesin > 0)
		{
			pk = (double*)malloc((size_t)nsegs*sizeof(double));
			ss = (int*)malloc((size_t)nsegs*sizeof(int));
			if ((pk == 0) || (ss == 0))
				perror("malloc error. gensam.2");
			tt = 0;
			for (seg=0, k=0; k < nsegs; seg = seglst[seg].next, k++)
			{ 
				if (mfreq > 1)
					ndes_setup(seglst[seg].ptree, nsam);
				end = k < nsegs-1 ? seglst[seglst[seg].next].beg-1 : nsites-1;
				start = seglst[seg].beg;
				len = end-start+1;
				tseg = len/(double)nsites;
				if (mfreq == 1)
					pk[k] = ttime(seglst[seg].ptree, nsam)*tseg;
				else 
					pk[k] = ttimemf(seglst[seg].ptree, nsam, mfreq)*tseg;
				tt += pk[k];
			}
			if (theta > 0)
			{ 
				es = theta*tt;
				*pprobss = exp(-1.0*es)*pow(es, (double)segsitesin)/segfac;
			}
			if (tt > 0)
			{
				for (k=0; k < nsegs; k++)
					pk[k] *= 1.0/tt;
				mnmial(segsitesin, nsegs, pk, ss);
			}
			else
				for (k=0; k < nsegs; k++)
					ss[k] = 0;
			ns = 0;
			for (seg=0, k=0; k < nsegs; seg = seglst[seg].next, k++)
			{ 
				end = k < nsegs-1 ? seglst[seglst[seg].next].beg-1 : nsites-1;
				start = seglst[seg].beg;
				len = end-start+1;
				tseg = len/(double)nsites;
				make_gametes(nsam, mfreq, seglst[seg].ptree, tt*pk[k]/tseg, ss[k], ns, list);
				free(seglst[seg].ptree);
				locate(ss[k], start*nsinv, len*nsinv, posit+ns);
				ns += ss[k];
			}
			free(pk);
			free(ss);
		}
		
		for (i=0; i < nsam; i++)
			list[i][ns] = '\0';
		return ns;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movq %rcx, -0xb8(%rbp)
movq %rdx, -0x90(%rbp)
movq %rsi, -0xb0(%rbp)
movq %rdi, -0xa8(%rbp)
movl 0x75b0(%rip), %eax      # 0xa140
movl %eax, -0x40(%rbp)
leaq 0x7586(%rip), %rdi      # 0xa120
movl $0x0, (%r8)
leaq -0x2c(%rbp), %rsi
movq %r8, %rdx
callq 0x4580
movq %rax, %rsi
movslq 0x756d(%rip), %rax      # 0xa124
movq %rax, -0x38(%rbp)
movl 0x75b7(%rip), %eax      # 0xa178
movl %eax, -0x70(%rbp)
movsd 0x75a4(%rip), %xmm0     # 0xa170
movapd %xmm0, -0x80(%rbp)
movl 0x75ad(%rip), %eax      # 0xa184
movl %eax, -0x3c(%rbp)
cmpl $0x0, 0x759b(%rip)      # 0xa17c
movq %rsi, -0x50(%rbp)
je 0x2cd5
movl -0x2c(%rbp), %eax
testl %eax, %eax
jle 0x2cd5
cmpl $0x0, -0x70(%rbp)
sete %cl
xorpd %xmm1, %xmm1
movapd -0x80(%rbp), %xmm0
ucomisd %xmm1, %xmm0
setnp %dl
sete %r14b
andb %dl, %r14b
andb %cl, %r14b
movq 0x73aa(%rip), %r15      # 0x9fc8
leaq 0x4534(%rip), %rbx      # 0x7159
xorl %r12d, %r12d
xorl %ecx, %ecx
movsd 0x7506(%rip), %xmm0     # 0xa138
ucomisd %xmm1, %xmm0
ja 0x2c4b
movsd 0x7508(%rip), %xmm0     # 0xa148
ucomisd %xmm1, %xmm0
ja 0x2c4b
movslq %ecx, %r13
jmp 0x2c83
decl %eax
movslq %ecx, %r13
leaq (,%r13,2), %rcx
addq %r13, %rcx
movl -0x40(%rbp), %edx
cmpl %eax, %r12d
jge 0x2c6f
movslq 0x10(%rsi,%rcx,8), %rax
leaq (%rax,%rax,2), %rax
movl (%rsi,%rax,8), %edx
subl (%rsi,%rcx,8), %edx
movq (%r15), %rdi
movq %rbx, %rsi
xorl %eax, %eax
callq 0x1150
movq -0x50(%rbp), %rsi
leaq (,%r13,2), %rax
addq %r13, %rax
leaq (%rsi,%rax,8), %r13
movq 0x8(%rsi,%rax,8), %rdi
movq -0x38(%rbp), %rsi
callq 0x3510
cmpl $0x0, 0x74d9(%rip)      # 0xa180
sete %al
andb %r14b, %al
cmpb $0x1, %al
jne 0x2cba
movq 0x8(%r13), %rdi
callq 0x10e0
movl 0x10(%r13), %ecx
incl %r12d
movl -0x2c(%rbp), %eax
cmpl %eax, %r12d
movq -0x50(%rbp), %rsi
xorpd %xmm1, %xmm1
jl 0x2c2a
xorps %xmm0, %xmm0
cvtsi2sdl -0x40(%rbp), %xmm0
movsd %xmm0, -0x98(%rbp)
movsd 0x431b(%rip), %xmm1     # 0x7008
cmpl $0x0, 0x748c(%rip)      # 0xa180
movapd -0x80(%rbp), %xmm0
je 0x2efa
movl -0x2c(%rbp), %r8d
testl %r8d, %r8d
jle 0x2ee1
movl -0x40(%rbp), %eax
movl %eax, %ecx
shrl $0x1f, %ecx
addl %eax, %ecx
sarl %ecx
movl %ecx, -0x60(%rbp)
movq -0x38(%rbp), %rdx
leal (%rdx,%rdx), %eax
movslq %eax, %rdi
leal -0x1(,%rdx,2), %eax
movl %eax, -0x88(%rbp)
cmpl $0x0, -0x70(%rbp)
sete %al
xorpd %xmm2, %xmm2
xorpd %xmm1, %xmm1
movsd %xmm1, -0x48(%rbp)
ucomisd %xmm2, %xmm0
setnp %cl
sete %r13b
andb %cl, %r13b
andb %al, %r13b
leal -0x2(,%rdx,2), %eax
cltq
subq %rdx, %rax
incq %rax
movq %rax, -0xc8(%rbp)
shlq $0x4, %rdx
orq $0x8, %rdx
movq %rdx, -0xc0(%rbp)
xorl %r14d, %r14d
shlq $0x4, %rdi
movq %rdi, -0x58(%rbp)
xorl %eax, %eax
movslq %eax, %rbx
cmpl $0x2, -0x3c(%rbp)
jl 0x2dac
leaq (%rbx,%rbx,2), %rax
movq 0x8(%rsi,%rax,8), %rdi
movq -0x38(%rbp), %rsi
callq 0x35f6
movq -0x50(%rbp), %rsi
movl -0x2c(%rbp), %r8d
leal -0x1(%r8), %ecx
leaq (%rbx,%rbx,2), %rax
movl -0x40(%rbp), %r15d
cmpl %ecx, %r14d
jge 0x2dca
movslq 0x10(%rsi,%rax,8), %rcx
leaq (%rcx,%rcx,2), %rcx
movl (%rsi,%rcx,8), %r15d
leaq (%rsi,%rax,8), %r12
movl (%rsi,%rax,8), %ebx
cmpl $0x1, %r8d
movl -0x3c(%rbp), %edx
je 0x2de5
cmpl -0x60(%rbp), %ebx
jg 0x2dff
cmpl -0x60(%rbp), %r15d
jle 0x2dff
movq 0x8(%r12), %rax
movq -0x58(%rbp), %rcx
movsd -0x18(%rax,%rcx), %xmm0
movq -0x90(%rbp), %rax
movsd %xmm0, (%rax)
movq 0x8(%r12), %rdi
cmpl $0x1, %edx
movq %rdi, -0x68(%rbp)
jne 0x2e4a
movq -0x58(%rbp), %rax
movsd -0x18(%rdi,%rax), %xmm2
movl -0x88(%rbp), %eax
cmpl -0x38(%rbp), %eax
jle 0x2e79
movq -0xc0(%rbp), %rax
addq %rdi, %rax
movq -0xc8(%rbp), %rcx
movsd 0x41cd(%rip), %xmm1     # 0x7008
addsd (%rax), %xmm2
addq $0x10, %rax
decq %rcx
jne 0x2e3b
jmp 0x2e81
movq -0x38(%rbp), %rsi
movl %ebx, -0xa0(%rbp)
movq %r12, %rbx
movl %r13d, %r12d
movq %r8, %r13
callq 0x36ca
movq %r13, %r8
movl %r12d, %r13d
movq %rbx, %r12
movl -0xa0(%rbp), %ebx
movq -0x50(%rbp), %rsi
movapd %xmm0, %xmm2
movsd 0x4187(%rip), %xmm1     # 0x7008
testb %r13b, %r13b
je 0x2ea9
movq -0x68(%rbp), %rdi
movsd %xmm2, -0x68(%rbp)
callq 0x10e0
movsd -0x68(%rbp), %xmm2
movsd 0x4167(%rip), %xmm1     # 0x7008
movq -0x50(%rbp), %rsi
movl -0x2c(%rbp), %r8d
subl %ebx, %r15d
xorps %xmm0, %xmm0
cvtsi2sd %r15d, %xmm0
divsd -0x98(%rbp), %xmm0
mulsd %xmm0, %xmm2
movsd -0x48(%rbp), %xmm0
addsd %xmm2, %xmm0
movsd %xmm0, -0x48(%rbp)
movl 0x10(%r12), %eax
incl %r14d
cmpl %r8d, %r14d
jl 0x2d89
jmp 0x2eea
xorpd %xmm0, %xmm0
movsd %xmm0, -0x48(%rbp)
movq -0xb8(%rbp), %rax
movsd -0x48(%rbp), %xmm0
movsd %xmm0, (%rax)
movapd %xmm1, %xmm0
divsd -0x98(%rbp), %xmm0
movsd %xmm0, -0xa0(%rbp)
cmpl $0x0, -0x70(%rbp)
jne 0x3155
xorpd %xmm0, %xmm0
movapd -0x80(%rbp), %xmm1
ucomisd %xmm0, %xmm1
movapd -0x80(%rbp), %xmm0
jbe 0x3155
movl -0x2c(%rbp), %eax
testl %eax, %eax
movq -0x38(%rbp), %rdx
jle 0x3384
leal (%rdx,%rdx), %ecx
movslq %ecx, %rdi
leal -0x1(,%rdx,2), %ecx
movl %ecx, -0x90(%rbp)
leal -0x2(,%rdx,2), %ecx
movslq %ecx, %rcx
subq %rdx, %rcx
incq %rcx
movq %rcx, -0x88(%rbp)
shlq $0x4, %rdx
orq $0x8, %rdx
movq %rdx, -0x70(%rbp)
xorl %r14d, %r14d
shlq $0x4, %rdi
movq %rdi, -0x60(%rbp)
xorl %ecx, %ecx
xorl %r13d, %r13d
movslq %ecx, %rbx
movl -0x3c(%rbp), %edx
cmpl $0x2, %edx
jl 0x2fb1
leaq (%rbx,%rbx,2), %rax
movq 0x8(%rsi,%rax,8), %rdi
movq -0x38(%rbp), %rsi
callq 0x35f6
movapd -0x80(%rbp), %xmm0
movl -0x3c(%rbp), %edx
movq -0x50(%rbp), %rsi
movl -0x2c(%rbp), %eax
decl %eax
leaq (%rbx,%rbx,2), %r15
movl -0x40(%rbp), %ebx
cmpl %eax, %r14d
jge 0x2fcb
movslq 0x10(%rsi,%r15,8), %rax
leaq (%rax,%rax,2), %rax
movl (%rsi,%rax,8), %ebx
movl (%rsi,%r15,8), %r12d
movq 0x8(%rsi,%r15,8), %rdi
cmpl $0x1, %edx
jne 0x3008
movq -0x60(%rbp), %rax
movsd -0x18(%rdi,%rax), %xmm2
movl -0x90(%rbp), %eax
cmpl -0x38(%rbp), %eax
jle 0x301a
addq -0x70(%rbp), %rdi
movq -0x88(%rbp), %rax
addsd (%rdi), %xmm2
addq $0x10, %rdi
decq %rax
jne 0x2ff9
jmp 0x301a
movq -0x38(%rbp), %rsi
callq 0x36ca
movapd %xmm0, %xmm2
movapd -0x80(%rbp), %xmm0
movl %r12d, -0x58(%rbp)
subl %r12d, %ebx
xorps %xmm1, %xmm1
cvtsi2sd %ebx, %xmm1
movsd %xmm1, -0x48(%rbp)
mulsd %xmm1, %xmm0
divsd -0x98(%rbp), %xmm0
movsd %xmm2, -0x68(%rbp)
mulsd %xmm2, %xmm0
callq 0x372d
movl %eax, %r12d
leal (%r12,%r13), %ebx
cmpl 0x70a4(%rip), %ebx      # 0xa0f8
jb 0x308f
leal 0xa(%rbx), %esi
movl %esi, 0x7099(%rip)      # 0xa0f8
movq 0x7122(%rip), %rdi      # 0xa188
shlq $0x3, %rsi
callq 0x1170
movq %rax, 0x7112(%rip)      # 0xa188
testq %rax, %rax
je 0x3144
movq -0x38(%rbp), %rdi
movq -0xa8(%rbp), %rsi
callq 0x37bb
movq -0x50(%rbp), %rax
leaq (%rax,%r15,8), %r15
movq 0x8(%r15), %rdx
movq -0x38(%rbp), %rdi
movl -0x3c(%rbp), %esi
movsd -0x68(%rbp), %xmm0
movl %r12d, %ecx
movl %r13d, %r8d
movq -0xa8(%rbp), %r9
callq 0x3811
movq 0x8(%r15), %rdi
callq 0x10e0
movslq %r13d, %r13
shlq $0x3, %r13
addq 0x70b8(%rip), %r13      # 0xa188
movl %r12d, %edi
movq %r13, %rsi
callq 0x39ce
testl %r12d, %r12d
movsd -0x48(%rbp), %xmm2
jle 0x3120
xorps %xmm0, %xmm0
cvtsi2sdl -0x58(%rbp), %xmm0
movsd -0xa0(%rbp), %xmm1
mulsd %xmm1, %xmm0
mulsd %xmm1, %xmm2
movl %r12d, %eax
xorl %ecx, %ecx
movsd (%r13,%rcx,8), %xmm1
mulsd %xmm2, %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, (%r13,%rcx,8)
incq %rcx
cmpq %rcx, %rax
jne 0x3102
movl 0x10(%r15), %ecx
incl %r14d
movl -0x2c(%rbp), %eax
movl %ebx, %r13d
cmpl %eax, %r14d
movq -0x50(%rbp), %rsi
movapd -0x80(%rbp), %xmm0
jl 0x2f85
jmp 0x34c4
leaq 0x4013(%rip), %rdi      # 0x715e
callq 0x1090
jmp 0x307f
cmpl $0x0, -0x70(%rbp)
jle 0x3384
movslq -0x2c(%rbp), %rbx
leaq (,%rbx,8), %rdi
callq 0x1120
movq %rax, %r15
leaq (,%rbx,4), %rdi
callq 0x1120
movq %rax, %r14
testq %r15, %r15
je 0x34fc
testq %r14, %r14
je 0x34fc
movq %r14, -0x60(%rbp)
xorpd %xmm0, %xmm0
movsd %xmm0, -0x48(%rbp)
testl %ebx, %ebx
movq -0x50(%rbp), %rsi
movq %r15, -0x68(%rbp)
jle 0x32c8
movq -0x38(%rbp), %rcx
leal (%rcx,%rcx), %eax
movslq %eax, %r14
leal -0x1(,%rcx,2), %eax
movl %eax, -0x58(%rbp)
leal -0x2(,%rcx,2), %eax
cltq
subq %rcx, %rax
incq %rax
movq %rax, -0x90(%rbp)
shlq $0x4, %rcx
orq $0x8, %rcx
movq %rcx, -0x88(%rbp)
movsd %xmm0, -0x48(%rbp)
xorl %r13d, %r13d
shlq $0x4, %r14
xorl %eax, %eax
movslq %eax, %r15
movl -0x3c(%rbp), %edx
cmpl $0x2, %edx
jl 0x3220
leaq (%r15,%r15,2), %rax
movq 0x8(%rsi,%rax,8), %rdi
movq -0x38(%rbp), %rsi
callq 0x35f6
movl -0x3c(%rbp), %edx
movq -0x50(%rbp), %rsi
movl -0x2c(%rbp), %ebx
leal -0x1(%rbx), %eax
cltq
leaq (%r15,%r15,2), %r15
movl -0x40(%rbp), %r12d
cmpq %rax, %r13
jge 0x323f
movslq 0x10(%rsi,%r15,8), %rax
leaq (%rax,%rax,2), %rax
movl (%rsi,%rax,8), %r12d
subl (%rsi,%r15,8), %r12d
movq 0x8(%rsi,%r15,8), %rdi
cmpl $0x1, %edx
jne 0x3279
movsd -0x18(%rdi,%r14), %xmm0
movl -0x58(%rbp), %eax
cmpl -0x38(%rbp), %eax
jle 0x3286
addq -0x88(%rbp), %rdi
movq -0x90(%rbp), %rax
addsd (%rdi), %xmm0
addq $0x10, %rdi
decq %rax
jne 0x326a
jmp 0x3286
movq -0x38(%rbp), %rsi
callq 0x36ca
movq -0x50(%rbp), %rsi
leaq (%rsi,%r15,8), %rax
xorps %xmm1, %xmm1
cvtsi2sd %r12d, %xmm1
divsd -0x98(%rbp), %xmm1
mulsd %xmm0, %xmm1
movq -0x68(%rbp), %r15
movsd %xmm1, (%r15,%r13,8)
movsd -0x48(%rbp), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x48(%rbp)
movl 0x10(%rax), %eax
incq %r13
movslq %ebx, %rcx
cmpq %rcx, %r13
jl 0x31f9
movapd -0x80(%rbp), %xmm0
ucomisd 0x3d3b(%rip), %xmm0     # 0x7010
jbe 0x3325
mulsd -0x48(%rbp), %xmm0
movapd %xmm0, %xmm1
movapd %xmm0, -0x80(%rbp)
movapd 0x3d63(%rip), %xmm0     # 0x7050
xorpd %xmm1, %xmm0
callq 0x11a0
movsd %xmm0, -0x58(%rbp)
xorps %xmm1, %xmm1
cvtsi2sdl -0x70(%rbp), %xmm1
movapd -0x80(%rbp), %xmm0
callq 0x1190
mulsd -0x58(%rbp), %xmm0
divsd 0x6e76(%rip), %xmm0     # 0xa190
movq -0xb0(%rbp), %rax
movsd %xmm0, (%rax)
xorpd %xmm0, %xmm0
movsd -0x48(%rbp), %xmm1
ucomisd %xmm0, %xmm1
movl -0x2c(%rbp), %r12d
movsd 0x3cca(%rip), %xmm1     # 0x7008
jbe 0x338b
testl %r12d, %r12d
jle 0x3364
divsd -0x48(%rbp), %xmm1
xorl %eax, %eax
movsd (%r15,%rax,8), %xmm0
mulsd %xmm1, %xmm0
movsd %xmm0, (%r15,%rax,8)
incq %rax
cmpq %rax, %r12
jne 0x334c
movl -0x70(%rbp), %edi
movl %r12d, %esi
movq %r15, %rdx
movq -0x60(%rbp), %rcx
callq 0x391f
movl -0x2c(%rbp), %r12d
testl %r12d, %r12d
jg 0x33a7
jmp 0x34b0
xorl %ebx, %ebx
jmp 0x34c4
testl %r12d, %r12d
jle 0x34b0
leaq (,%r12,4), %rdx
movq -0x60(%rbp), %rdi
xorl %esi, %esi
callq 0x1040
xorl %r14d, %r14d
xorl %eax, %eax
xorl %r13d, %r13d
movq -0x50(%rbp), %rsi
decl %r12d
movslq %r12d, %rcx
cltq
leaq (%rax,%rax,2), %r15
movl -0x40(%rbp), %eax
cmpq %rcx, %r14
jge 0x33d3
movslq 0x10(%rsi,%r15,8), %rax
leaq (%rax,%rax,2), %rax
movl (%rsi,%rax,8), %eax
movl (%rsi,%r15,8), %ecx
movl %ecx, -0x58(%rbp)
subl %ecx, %eax
xorps %xmm1, %xmm1
cvtsi2sd %eax, %xmm1
movsd %xmm1, -0x80(%rbp)
divsd -0x98(%rbp), %xmm1
movq 0x8(%rsi,%r15,8), %rdx
movq -0x68(%rbp), %rax
movsd (%rax,%r14,8), %xmm0
mulsd -0x48(%rbp), %xmm0
divsd %xmm1, %xmm0
movq -0x60(%rbp), %rax
movslq (%rax,%r14,4), %rbx
movq -0x38(%rbp), %rdi
movq %rsi, %r12
movl -0x3c(%rbp), %esi
movl %ebx, %ecx
movl %r13d, %r8d
movq -0xa8(%rbp), %r9
callq 0x3811
movq 0x8(%r12,%r15,8), %rdi
callq 0x10e0
movslq %r13d, %r12
shlq $0x3, %r12
addq 0x6d45(%rip), %r12      # 0xa188
movl %ebx, %edi
movq %r12, %rsi
callq 0x39ce
movsd -0x80(%rbp), %xmm2
testq %rbx, %rbx
jle 0x348d
xorps %xmm0, %xmm0
cvtsi2sdl -0x58(%rbp), %xmm0
movsd -0xa0(%rbp), %xmm1
mulsd %xmm1, %xmm0
mulsd %xmm1, %xmm2
xorl %eax, %eax
movsd (%r12,%rax,8), %xmm1
mulsd %xmm2, %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, (%r12,%rax,8)
incq %rax
cmpq %rax, %rbx
jne 0x3471
movq -0x50(%rbp), %rsi
leaq (%rsi,%r15,8), %rax
addl %r13d, %ebx
movl 0x10(%rax), %eax
incq %r14
movslq -0x2c(%rbp), %r12
movl %ebx, %r13d
cmpq %r12, %r14
jl 0x33b3
jmp 0x34b2
xorl %ebx, %ebx
movq -0x68(%rbp), %rdi
callq 0x10e0
movq -0x60(%rbp), %rdi
callq 0x10e0
movq -0x38(%rbp), %rdi
testl %edi, %edi
movq -0xa8(%rbp), %rsi
jle 0x34e8
movslq %ebx, %rax
xorl %ecx, %ecx
movq (%rsi,%rcx,8), %rdx
movb $0x0, (%rdx,%rax)
incq %rcx
cmpq %rcx, %rdi
jne 0x34d8
movl %ebx, %eax
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x3c75(%rip), %rdi      # 0x7178
callq 0x1090
movl -0x2c(%rbp), %ebx
jmp 0x3195