// File: /workspace/github_c_makefile_star2_O3/xiongxu[P]bam2bedGraph2/samtools-0.1.19/kprobaln.c
// Function: kpa_glocal
int kpa_glocal(const uint8_t *_ref, int l_ref, const uint8_t *_query, int l_query, const uint8_t *iqual,
			   const kpa_par_t *c, int *state, uint8_t *q)
{
	double **f, **b = 0, *s, m[9], sI, sM, bI, bM, pb;
	float *qual, *_qual;
	const uint8_t *ref, *query;
	int bw, bw2, i, k, is_diff = 0, is_backward = 1, Pr;

    if ( l_ref<=0 || l_query<=0 ) return 0; // FIXME: this may not be an ideal fix, just prevents sefgault

	/*** initialization ***/
	is_backward = state && q? 1 : 0;
	ref = _ref - 1; query = _query - 1; // change to 1-based coordinate
	bw = l_ref > l_query? l_ref : l_query;
	if (bw > c->bw) bw = c->bw;
	if (bw < abs(l_ref - l_query)) bw = abs(l_ref - l_query);
	bw2 = bw * 2 + 1;
	// allocate the forward and backward matrices f[][] and b[][] and the scaling array s[]
	f = calloc(l_query+1, sizeof(void*));
	if (is_backward) b = calloc(l_query+1, sizeof(void*));
	for (i = 0; i <= l_query; ++i) {    // FIXME: this will lead in segfault for l_query==0
		f[i] = calloc(bw2 * 3 + 6, sizeof(double)); // FIXME: this is over-allocated for very short seqs
		if (is_backward) b[i] = calloc(bw2 * 3 + 6, sizeof(double));
	}
	s = calloc(l_query+2, sizeof(double)); // s[] is the scaling factor to avoid underflow
	// initialize qual
	_qual = calloc(l_query, sizeof(float));
	if (g_qual2prob[0] == 0)
		for (i = 0; i < 256; ++i)
			g_qual2prob[i] = pow(10, -i/10.);
	for (i = 0; i < l_query; ++i) _qual[i] = g_qual2prob[iqual? iqual[i] : 30];
	qual = _qual - 1;
	// initialize transition probability
	sM = sI = 1. / (2 * l_query + 2); // the value here seems not to affect results; FIXME: need proof
	m[0*3+0] = (1 - c->d - c->d) * (1 - sM); m[0*3+1] = m[0*3+2] = c->d * (1 - sM);
	m[1*3+0] = (1 - c->e) * (1 - sI); m[1*3+1] = c->e * (1 - sI); m[1*3+2] = 0.;
	m[2*3+0] = 1 - c->e; m[2*3+1] = 0.; m[2*3+2] = c->e;
	bM = (1 - c->d) / l_ref; bI = c->d / l_ref; // (bM+bI)*l_ref==1
	/*** forward ***/
	// f[0]
	set_u(k, bw, 0, 0);
	f[0][k] = s[0] = 1.;
	{ // f[1]
		double *fi = f[1], sum;
		int beg = 1, end = l_ref < bw + 1? l_ref : bw + 1, _beg, _end;
		for (k = beg, sum = 0.; k <= end; ++k) {
			int u;
			double e = (ref[k] > 3 || query[1] > 3)? 1. : ref[k] == query[1]? 1. - qual[1] : qual[1] * EM;
			set_u(u, bw, 1, k);
			fi[u+0] = e * bM; fi[u+1] = EI * bI;
			sum += fi[u] + fi[u+1];
		}
		// rescale
		s[1] = sum;
		set_u(_beg, bw, 1, beg); set_u(_end, bw, 1, end); _end += 2;
		for (k = _beg; k <= _end; ++k) fi[k] /= sum;
	}
	// f[2..l_query]
	for (i = 2; i <= l_query; ++i) {
		double *fi = f[i], *fi1 = f[i-1], sum, qli = qual[i];
		int beg = 1, end = l_ref, x, _beg, _end;
		uint8_t qyi = query[i];
		x = i - bw; beg = beg > x? beg : x; // band start
		x = i + bw; end = end < x? end : x; // band end
		for (k = beg, sum = 0.; k <= end; ++k) {
			int u, v11, v01, v10;
			double e;
			e = (ref[k] > 3 || qyi > 3)? 1. : ref[k] == qyi? 1. - qli : qli * EM;
			set_u(u, bw, i, k); set_u(v11, bw, i-1, k-1); set_u(v10, bw, i-1, k); set_u(v01, bw, i, k-1);
			fi[u+0] = e * (m[0] * fi1[v11+0] + m[3] * fi1[v11+1] + m[6] * fi1[v11+2]);
			fi[u+1] = EI * (m[1] * fi1[v10+0] + m[4] * fi1[v10+1]);
			fi[u+2] = m[2] * fi[v01+0] + m[8] * fi[v01+2];
			sum += fi[u] + fi[u+1] + fi[u+2];
//			fprintf(stderr, "F (%d,%d;%d): %lg,%lg,%lg\n", i, k, u, fi[u], fi[u+1], fi[u+2]); // DEBUG
		}
		// rescale
		s[i] = sum;
		set_u(_beg, bw, i, beg); set_u(_end, bw, i, end); _end += 2;
		for (k = _beg, sum = 1./sum; k <= _end; ++k) fi[k] *= sum;
	}
	{ // f[l_query+1]
		double sum;
		for (k = 1, sum = 0.; k <= l_ref; ++k) {
			int u;
			set_u(u, bw, l_query, k);
			if (u < 3 || u >= bw2*3+3) continue;
		    sum += f[l_query][u+0] * sM + f[l_query][u+1] * sI;
		}
		s[l_query+1] = sum; // the last scaling factor
	}
	{ // compute likelihood
		double p = 1., Pr1 = 0.;
		for (i = 0; i <= l_query + 1; ++i) {
			p *= s[i];
			if (p < 1e-100) Pr1 += -4.343 * log(p), p = 1.;
		}
		Pr1 += -4.343 * log(p * l_ref * l_query);
		Pr = (int)(Pr1 + .499);
		if (!is_backward) { // skip backward and MAP
			for (i = 0; i <= l_query; ++i) free(f[i]);
			free(f); free(s); free(_qual);
			return Pr;
		}
	}
	/*** backward ***/
	// b[l_query] (b[l_query+1][0]=1 and thus \tilde{b}[][]=1/s[l_query+1]; this is where s[l_query+1] comes from)
	for (k = 1; k <= l_ref; ++k) {
		int u;
		double *bi = b[l_query];
		set_u(u, bw, l_query, k);
		if (u < 3 || u >= bw2*3+3) continue;
		bi[u+0] = sM / s[l_query] / s[l_query+1]; bi[u+1] = sI / s[l_query] / s[l_query+1];
	}
	// b[l_query-1..1]
	for (i = l_query - 1; i >= 1; --i) {
		int beg = 1, end = l_ref, x, _beg, _end;
		double *bi = b[i], *bi1 = b[i+1], y = (i > 1), qli1 = qual[i+1];
		uint8_t qyi1 = query[i+1];
		x = i - bw; beg = beg > x? beg : x;
		x = i + bw; end = end < x? end : x;
		for (k = end; k >= beg; --k) {
			int u, v11, v01, v10;
			double e;
			set_u(u, bw, i, k); set_u(v11, bw, i+1, k+1); set_u(v10, bw, i+1, k); set_u(v01, bw, i, k+1);
			e = (k >= l_ref? 0 : (ref[k+1] > 3 || qyi1 > 3)? 1. : ref[k+1] == qyi1? 1. - qli1 : qli1 * EM) * bi1[v11];
			bi[u+0] = e * m[0] + EI * m[1] * bi1[v10+1] + m[2] * bi[v01+2]; // bi1[v11] has been foled into e.
			bi[u+1] = e * m[3] + EI * m[4] * bi1[v10+1];
			bi[u+2] = (e * m[6] + m[8] * bi[v01+2]) * y;
//			fprintf(stderr, "B (%d,%d;%d): %lg,%lg,%lg\n", i, k, u, bi[u], bi[u+1], bi[u+2]); // DEBUG
		}
		// rescale
		set_u(_beg, bw, i, beg); set_u(_end, bw, i, end); _end += 2;
		for (k = _beg, y = 1./s[i]; k <= _end; ++k) bi[k] *= y;
	}
	{ // b[0]
		int beg = 1, end = l_ref < bw + 1? l_ref : bw + 1;
		double sum = 0.;
		for (k = end; k >= beg; --k) {
			int u;
			double e = (ref[k] > 3 || query[1] > 3)? 1. : ref[k] == query[1]? 1. - qual[1] : qual[1] * EM;
			set_u(u, bw, 1, k);
			if (u < 3 || u >= bw2*3+3) continue;
		    sum += e * b[1][u+0] * bM + EI * b[1][u+1] * bI;
		}
		set_u(k, bw, 0, 0);
		pb = b[0][k] = sum / s[0]; // if everything works as is expected, pb == 1.0
	}
	is_diff = fabs(pb - 1.) > 1e-7? 1 : 0;
	/*** MAP ***/
	for (i = 1; i <= l_query; ++i) {
		double sum = 0., *fi = f[i], *bi = b[i], max = 0.;
		int beg = 1, end = l_ref, x, max_k = -1;
		x = i - bw; beg = beg > x? beg : x;
		x = i + bw; end = end < x? end : x;
		for (k = beg; k <= end; ++k) {
			int u;
			double z;
			set_u(u, bw, i, k);
			z = fi[u+0] * bi[u+0]; if (z > max) max = z, max_k = (k-1)<<2 | 0; sum += z;
			z = fi[u+1] * bi[u+1]; if (z > max) max = z, max_k = (k-1)<<2 | 1; sum += z;
		}
		max /= sum; sum *= s[i]; // if everything works as is expected, sum == 1.0
		if (state) state[i-1] = max_k;
		if (q) k = (int)(-4.343 * log(1. - max) + .499), q[i-1] = k > 100? 99 : k;
#ifdef _MAIN
		fprintf(stderr, "(%.10lg,%.10lg) (%d,%d:%c,%c:%d) %lg\n", pb, sum, i-1, max_k>>2,
				"ACGT"[query[i]], "ACGT"[ref[(max_k>>2)+1]], max_k&3, max); // DEBUG
#endif
	}
	/*** free ***/
	for (i = 0; i <= l_query; ++i) {
		free(f[i]); free(b[i]);
	}
	free(f); free(b); free(s); free(_qual);
	return Pr;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x108, %rsp            # imm = 0x108
movq %rdx, 0x70(%rsp)
movq %rdi, 0x80(%rsp)
testl %esi, %esi
setle %al
testl %ecx, %ecx
setle %dl
xorl %ebx, %ebx
orb %al, %dl
jne 0x3918d
movq %r8, %r14
movl %esi, %r12d
cmpq $0x0, 0x140(%rsp)
setne %al
cmpq $0x0, 0x148(%rsp)
setne %bl
andb %al, %bl
movl %esi, %edx
subl %ecx, %edx
movl %ecx, %esi
cmoval %r12d, %esi
movq %r9, 0x8(%rsp)
movl 0x8(%r9), %eax
cmpl %eax, %esi
cmovgel %eax, %esi
movl %edx, %eax
negl %eax
movl %edx, 0x1c(%rsp)
cmovsl %edx, %eax
cmpl %eax, %esi
movl %esi, 0x18(%rsp)
cmovgl %esi, %eax
movq %rax, 0x38(%rsp)
leal 0x1(%rax,%rax), %eax
movq %rax, 0x68(%rsp)
movq %rcx, 0x20(%rsp)
leal 0x1(%rcx), %r15d
movl $0x8, %esi
movq %r15, %rdi
callq 0x3610
movq %rax, %rbp
movb %bl, 0x40(%rsp)
cmpb $0x1, %bl
movq %r12, 0x60(%rsp)
jne 0x38339
movl $0x8, %esi
movq %r15, %rdi
callq 0x3610
movq %rax, %r12
jmp 0x3833c
xorl %r12d, %r12d
movq 0x68(%rsp), %rax
leal (%rax,%rax,2), %r13d
addl $0x6, %r13d
xorl %ebx, %ebx
movl $0x8, %esi
movq %r13, %rdi
callq 0x3610
movq %rax, (%rbp,%rbx,8)
cmpb $0x0, 0x40(%rsp)
je 0x38375
movl $0x8, %esi
movq %r13, %rdi
callq 0x3610
movq %rax, (%r12,%rbx,8)
incq %rbx
cmpq %rbx, %r15
jne 0x3834b
movq %r12, 0xa8(%rsp)
movq %r15, 0x30(%rsp)
movq 0x20(%rsp), %rbx
leal 0x2(%rbx), %edi
movl $0x8, %esi
movq %rdi, 0xb0(%rsp)
callq 0x3610
movq %rax, 0x10(%rsp)
movl %ebx, %edi
movl $0x4, %esi
movq %rdi, 0x48(%rsp)
callq 0x3610
movq %rax, 0x58(%rsp)
movss 0x18fb9(%rip), %xmm0    # 0x51380
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
leaq 0x18fac(%rip), %rbx     # 0x51380
movq 0x60(%rsp), %r13
jne 0x38416
jp 0x38416
xorl %r15d, %r15d
movq %rbx, %r12
xorps %xmm1, %xmm1
cvtsi2sd %r15d, %xmm1
movsd 0x998d(%rip), %xmm0     # 0x41d80
divsd %xmm0, %xmm1
callq 0x3790
cvtsd2ss %xmm0, %xmm0
movss %xmm0, (%r12)
decq %r15
addq $0x4, %r12
cmpq $-0x100, %r15
jne 0x383e3
xorl %eax, %eax
movq 0x58(%rsp), %r10
movq 0x48(%rsp), %rdx
testq %r14, %r14
je 0x3842e
movzbl (%r14,%rax), %ecx
jmp 0x38433
movl $0x1e, %ecx
movss (%rbx,%rcx,4), %xmm0
movss %xmm0, (%r10,%rax,4)
incq %rax
cmpq %rax, %rdx
jne 0x38422
movq 0x20(%rsp), %r9
leal 0x2(,%r9,2), %eax
xorps %xmm1, %xmm1
cvtsi2sd %eax, %xmm1
movsd 0x9596(%rip), %xmm0     # 0x419f8
movapd %xmm0, %xmm6
divsd %xmm1, %xmm6
movq 0x8(%rsp), %rax
movss (%rax), %xmm1
movss 0x4(%rax), %xmm2
movss 0xd6a8(%rip), %xmm3     # 0x45b28
movaps %xmm3, %xmm4
subss %xmm1, %xmm4
movaps %xmm4, %xmm5
subss %xmm1, %xmm5
cvtss2sd %xmm5, %xmm10
movapd %xmm0, %xmm11
movsd %xmm6, 0x78(%rsp)
subsd %xmm6, %xmm11
mulsd %xmm11, %xmm10
cvtss2sd %xmm1, %xmm12
mulsd %xmm11, %xmm12
subss %xmm2, %xmm3
cvtss2sd %xmm3, %xmm13
movapd %xmm11, %xmm14
mulsd %xmm13, %xmm14
cvtss2sd %xmm2, %xmm15
mulsd %xmm15, %xmm11
xorps %xmm2, %xmm2
cvtsi2ss %r13d, %xmm2
divss %xmm2, %xmm4
cvtss2sd %xmm4, %xmm9
divss %xmm2, %xmm1
cvtss2sd %xmm1, %xmm1
movabsq $0x3ff0000000000000, %rax # imm = 0x3FF0000000000000
movq 0x10(%rsp), %rcx
movq %rax, (%rcx)
movq (%rbp), %rcx
movq %rax, 0x18(%rcx)
movq 0x8(%rbp), %rax
movq 0x38(%rsp), %rdx
leal 0x1(%rdx), %ecx
cmpl %r13d, %ecx
cmovgel %r13d, %ecx
movl $0x1, %edi
movl $0x1, %r8d
subl %edx, %r8d
xorl %esi, %esi
testl %r8d, %r8d
movl $0x0, %edx
movl %r8d, 0xbc(%rsp)
cmovgl %r8d, %edx
movsd 0xd5c7(%rip), %xmm2     # 0x45b08
movsd %xmm1, 0xe8(%rsp)
mulsd %xmm1, %xmm2
movl %r9d, %r8d
subl %r13d, %r8d
movl 0x18(%rsp), %r9d
cmpl %r8d, %r9d
movq %r8, 0x88(%rsp)
cmovgl %r9d, %r8d
movl 0x1c(%rsp), %r9d
cmpl %r9d, %r8d
cmovlel %r9d, %r8d
subl %r8d, %edi
testl %edi, %edi
cmovlel %esi, %edi
leal (%rdi,%rdi,2), %r8d
movl $0x7, %edi
subl %r8d, %edi
xorpd %xmm1, %xmm1
movq 0x30(%rsp), %r11
movq 0x70(%rsp), %rbx
movq 0x80(%rsp), %r8
movb (%r8,%rsi), %r8b
movapd %xmm0, %xmm3
cmpb $0x3, %r8b
ja 0x385dc
movb (%rbx), %r9b
movapd %xmm0, %xmm3
cmpb $0x3, %r9b
ja 0x385dc
xorps %xmm4, %xmm4
cvtss2sd (%r10), %xmm4
cmpb %r9b, %r8b
jne 0x385d0
movapd %xmm0, %xmm3
subsd %xmm4, %xmm3
jmp 0x385dc
mulsd 0xd538(%rip), %xmm4     # 0x45b10
movapd %xmm4, %xmm3
leal -0x1(%rdi), %r8d
mulsd %xmm9, %xmm3
movslq %r8d, %r8
movsd %xmm3, (%rax,%r8,8)
movslq %edi, %rdi
movsd %xmm2, (%rax,%rdi,8)
addsd %xmm2, %xmm3
addsd %xmm3, %xmm1
incq %rsi
addl $0x3, %edi
cmpq %rcx, %rsi
jb 0x38596
movq 0x10(%rsp), %rsi
movsd %xmm1, 0x8(%rsi)
movq 0x38(%rsp), %rdi
testl %edi, %edi
movl $0x1, %esi
cmovlel %edi, %esi
leal (%rsi,%rsi,2), %edi
addl $0x3, %edi
subl %edx, %ecx
leal (%rcx,%rcx,2), %ecx
addl $0x5, %ecx
cmpl %ecx, %edi
jg 0x38656
leal (%rsi,%rsi,2), %edx
movl %edi, %esi
addl $0x2, %edx
leaq (%rax,%rsi,8), %rsi
movsd (%rsi), %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, (%rsi)
incl %edx
addq $0x8, %rsi
cmpl %edx, %ecx
jg 0x38640
cmpl $0x2, 0x20(%rsp)
movq %rbp, 0xa0(%rsp)
movq 0xa8(%rsp), %r12
jl 0x38938
movl 0x18(%rsp), %ecx
movq 0x88(%rsp), %rdx
cmpl %edx, %ecx
movl %edx, %esi
cmovgl %ecx, %esi
movl 0x1c(%rsp), %ecx
cmpl %ecx, %esi
cmovlel %ecx, %esi
movl $0x2, %edx
subl %esi, %edx
movl $0x1, %r14d
subl %esi, %r14d
movl $0x2, %esi
movsd 0x934e(%rip), %xmm0     # 0x419f8
movsd 0xd456(%rip), %xmm1     # 0x45b08
cmpl $0x2, %edx
movl $0x1, %r12d
cmovgel %edx, %r12d
leal (%r12,%r12,2), %r9d
testl %edx, %edx
movl $0x0, %edi
cmovgl %edx, %edi
leal (%rdi,%rdi,2), %r15d
testl %r14d, %r14d
movl $0x0, %r10d
cmovgl %r14d, %r10d
movq (%rbp,%rsi,8), %r8
movq 0x38(%rsp), %rcx
leal (%rcx,%rsi), %edi
movl %esi, %ebx
subl %ecx, %ebx
movq %rdi, %rcx
cmpl $0x2, %ebx
movl $0x1, %edi
cmovgel %ebx, %edi
cmpl %r13d, %ecx
cmovgel %r13d, %ecx
movq %rdi, 0x8(%rsp)
cmpl %ecx, %edi
jle 0x38720
testl %ebx, %ebx
movl $0x0, %eax
cmovlel %eax, %ebx
xorpd %xmm2, %xmm2
jmp 0x388c7
movl %r14d, 0x2c(%rsp)
movl %edx, 0x50(%rsp)
decq %r12
leal (%r10,%r10,2), %r14d
negl %r14d
movl %r15d, 0x98(%rsp)
negl %r15d
movq %rcx, %rdx
movq 0x70(%rsp), %rcx
movb -0x1(%rcx,%rsi), %r13b
movq 0x58(%rsp), %rcx
xorps %xmm3, %xmm3
cvtss2sd -0x4(%rcx,%rsi,4), %xmm3
movapd %xmm0, %xmm4
subsd %xmm3, %xmm4
mulsd 0xd3a7(%rip), %xmm3     # 0x45b10
testl %ebx, %ebx
movl $0x0, %ecx
cmovlel %ecx, %ebx
movq %rdx, 0x90(%rsp)
movl %edx, %r10d
xorpd %xmm2, %xmm2
movq 0x80(%rsp), %rcx
movb (%rcx,%r12), %bpl
movapd %xmm4, %xmm5
cmpb %r13b, %bpl
je 0x3879b
movapd %xmm3, %xmm5
movapd %xmm0, %xmm7
cmpb $0x4, %r13b
jae 0x387a9
movapd %xmm5, %xmm7
movapd %xmm0, %xmm6
cmpb $0x4, %bpl
jae 0x387b7
movapd %xmm7, %xmm6
leal (%r9,%r15), %ebp
leal (%r9,%r15), %edx
addl $0x3, %edx
leal (%r9,%r14), %ecx
leal 0x3(%r9,%r14), %edi
movslq %ecx, %rcx
leal 0x1(%r9,%r14), %r11d
movslq %r11d, %r11
movsd (%rax,%r11,8), %xmm5
mulsd %xmm14, %xmm5
movsd (%rax,%rcx,8), %xmm7
mulsd %xmm10, %xmm7
addsd %xmm5, %xmm7
leal 0x2(%r9,%r14), %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm5
mulsd %xmm13, %xmm5
addsd %xmm7, %xmm5
mulsd %xmm6, %xmm5
movslq %edx, %rcx
movsd %xmm5, (%r8,%rcx,8)
movslq %edi, %rcx
leal 0x4(%r9,%r14), %edx
movslq %edx, %rdx
movsd (%rax,%rdx,8), %xmm6
mulsd %xmm11, %xmm6
movsd (%rax,%rcx,8), %xmm7
mulsd %xmm12, %xmm7
addsd %xmm6, %xmm7
mulsd %xmm1, %xmm7
leal 0x4(%r9,%r15), %ecx
movslq %ecx, %rcx
movsd %xmm7, (%r8,%rcx,8)
movslq %ebp, %rcx
leal 0x2(%r9,%r15), %edx
movslq %edx, %rdx
movsd (%r8,%rdx,8), %xmm6
mulsd %xmm15, %xmm6
movsd (%r8,%rcx,8), %xmm8
mulsd %xmm12, %xmm8
addsd %xmm6, %xmm8
leal 0x5(%r9,%r15), %ecx
movslq %ecx, %rcx
movsd %xmm8, (%r8,%rcx,8)
addsd %xmm5, %xmm7
addsd %xmm8, %xmm7
addsd %xmm7, %xmm2
incq %r12
addl $0x3, %r14d
addl $0x3, %r15d
cmpq %r10, %r12
jb 0x38782
movq 0x30(%rsp), %r11
movq 0x60(%rsp), %r13
movq 0xa0(%rsp), %rbp
movl 0x50(%rsp), %edx
movl 0x2c(%rsp), %r14d
movl 0x98(%rsp), %r15d
movq 0x90(%rsp), %rcx
movq 0x10(%rsp), %rax
movsd %xmm2, (%rax,%rsi,8)
movq 0x8(%rsp), %rax
subl %ebx, %eax
leal (%rax,%rax,2), %eax
addl $0x3, %eax
subl %ebx, %ecx
leal (%rcx,%rcx,2), %edi
addl $0x5, %edi
cmpl %edi, %eax
movq 0xa8(%rsp), %r12
jg 0x38924
subl %r15d, %r9d
addl $0x3, %r9d
movslq %r9d, %rax
decq %rax
movapd %xmm0, %xmm3
divsd %xmm2, %xmm3
movslq %edi, %rdi
movsd 0x8(%r8,%rax,8), %xmm2
mulsd %xmm3, %xmm2
movsd %xmm2, 0x8(%r8,%rax,8)
incq %rax
cmpq %rdi, %rax
jl 0x3890a
incq %rsi
incl %edx
incl %r14d
movq %r8, %rax
cmpq %r11, %rsi
jne 0x386b2
movq 0x20(%rsp), %rax
movl %eax, %r14d
subl 0x38(%rsp), %r14d
xorl %ecx, %ecx
testl %r14d, %r14d
cmovgl %r14d, %ecx
movq 0x68(%rsp), %rax
leal 0x3(%rax,%rax,2), %eax
leal 0x1(%r13), %ebx
leal (%rcx,%rcx,2), %ecx
movl $0x3, %edx
subl %ecx, %edx
leaq -0x1(%rbx), %rcx
xorpd %xmm0, %xmm0
movq 0x48(%rsp), %r9
movsd 0x78(%rsp), %xmm3
movl %edx, %esi
leal 0x3(%rsi), %edx
cmpl $0x7ffffffc, %esi       # imm = 0x7FFFFFFC
ja 0x389af
cmpl %eax, %edx
jge 0x389af
movq (%rbp,%r9,8), %rdi
movl %edx, %r8d
movl %esi, %esi
movsd 0x20(%rdi,%rsi,8), %xmm1
mulsd %xmm3, %xmm1
movsd (%rdi,%r8,8), %xmm2
mulsd %xmm3, %xmm2
addsd %xmm1, %xmm2
addsd %xmm2, %xmm0
decq %rcx
jne 0x38978
movsd %xmm12, 0xd8(%rsp)
movsd %xmm11, 0x50(%rsp)
movq 0x10(%rsp), %rax
movsd %xmm0, (%rax,%r11,8)
xorpd %xmm0, %xmm0
movsd %xmm0, 0x8(%rsp)
movsd 0x9016(%rip), %xmm0     # 0x419f8
xorl %r15d, %r15d
movsd 0xd12b(%rip), %xmm1     # 0x45b18
movsd %xmm9, 0xf0(%rsp)
movsd %xmm10, 0xe0(%rsp)
movsd %xmm13, 0xd0(%rsp)
movsd %xmm14, 0xc8(%rsp)
movsd %xmm15, 0xc0(%rsp)
movq 0x10(%rsp), %rax
mulsd (%rax,%r15,8), %xmm0
ucomisd %xmm0, %xmm1
jbe 0x38a5d
callq 0x3330
mulsd 0x9043(%rip), %xmm0     # 0x41a80
movsd 0x8(%rsp), %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, 0x8(%rsp)
movsd 0xd0c3(%rip), %xmm1     # 0x45b18
movsd 0x8f9b(%rip), %xmm0     # 0x419f8
incq %r15
cmpq %r15, 0xb0(%rsp)
jne 0x38a1f
xorps %xmm1, %xmm1
cvtsi2sd %r13d, %xmm1
mulsd %xmm1, %xmm0
xorps %xmm1, %xmm1
cvtsi2sdl 0x20(%rsp), %xmm1
mulsd %xmm0, %xmm1
movapd %xmm1, %xmm0
callq 0x3330
mulsd 0x8fec(%rip), %xmm0     # 0x41a80
addsd 0x8(%rsp), %xmm0
addsd 0x658e(%rip), %xmm0     # 0x3f030
movsd %xmm0, 0xf8(%rsp)
cmpb $0x0, 0x40(%rsp)
je 0x3914c
movq %r12, %rax
movq 0x48(%rsp), %r12
movq %rax, %r9
movq (%rax,%r12,8), %rax
xorl %edx, %edx
testl %r14d, %r14d
cmovgl %r14d, %edx
movq 0x68(%rsp), %rcx
leal (%rcx,%rcx,2), %ecx
addl $0x3, %ecx
leal (%rdx,%rdx,2), %esi
movl $0x3, %edx
subl %esi, %edx
decq %rbx
movq 0x30(%rsp), %r15
movq 0x20(%rsp), %r8
movsd 0xf0(%rsp), %xmm8
movsd 0xe8(%rsp), %xmm9
movsd 0xe0(%rsp), %xmm10
movsd 0x50(%rsp), %xmm11
movsd 0xd8(%rsp), %xmm12
movsd 0xd0(%rsp), %xmm13
movsd 0xc8(%rsp), %xmm14
movsd 0xc0(%rsp), %xmm15
movl %edx, %esi
leal 0x3(%rsi), %edx
cmpl $0x7ffffffc, %esi       # imm = 0x7FFFFFFC
ja 0x38b74
cmpl %ecx, %edx
jge 0x38b74
movsd 0x78(%rsp), %xmm0
movq 0x10(%rsp), %rdi
divsd (%rdi,%r12,8), %xmm0
divsd (%rdi,%r15,8), %xmm0
movl %edx, %edi
movsd %xmm0, (%rax,%rdi,8)
movl %esi, %esi
movsd %xmm0, 0x20(%rax,%rsi,8)
decq %rbx
jne 0x38b3d
cmpl $0x2, %r8d
jl 0x38ed0
movsd 0xcf7d(%rip), %xmm1     # 0x45b08
movapd %xmm12, %xmm0
mulsd %xmm1, %xmm0
mulsd %xmm1, %xmm11
movl 0x18(%rsp), %ecx
movq 0x88(%rsp), %rax
cmpl %eax, %ecx
cmovgl %ecx, %eax
movl 0x1c(%rsp), %ecx
cmpl %ecx, %eax
cmovlel %ecx, %eax
leal -0x1(%rax,%r8), %ecx
movslq %ecx, %rsi
movl %r13d, %ecx
movq %rcx, 0x40(%rsp)
movl %eax, %r10d
notl %r10d
addl %r8d, %r10d
movq (%r9,%r12,8), %rdi
subl %eax, %r8d
movsd 0x8e1d(%rip), %xmm1     # 0x419f8
movq %r9, %r13
movq %r12, %r14
movq %rdi, %r11
cmpl $0x2, %r10d
movl $0x1, %eax
cmovgel %r10d, %eax
movq %rax, 0x78(%rsp)
testl %r10d, %r10d
movl $0x0, %edx
cmovgl %r10d, %edx
movq 0x40(%rsp), %rax
cmpq %rax, %rsi
cmovlq %rsi, %rax
testl %r8d, %r8d
movl $0x0, %ecx
cmovgl %r8d, %ecx
movapd %xmm1, %xmm2
cmpq $0x2, %r12
jne 0x38c28
xorpd %xmm2, %xmm2
leal (%rdx,%rdx,2), %ebx
leaq -0x1(%r14), %r12
movq -0x8(%r13,%r14,8), %rdi
movq 0x38(%rsp), %r15
leal (%r15,%r12), %ebp
movl %r12d, %edx
subl %r15d, %edx
cmpl $0x2, %edx
movl $0x1, %r9d
cmovgel %edx, %r9d
movq 0x60(%rsp), %r15
cmpl %r15d, %ebp
cmovgel %r15d, %ebp
movq %rbp, 0xb0(%rsp)
cmpl %r9d, %ebp
movq %r9, %rbp
movl %ebx, 0x8(%rsp)
jge 0x38c8c
testl %edx, %edx
movl $0x0, %eax
cmovlel %eax, %edx
movq 0x30(%rsp), %r15
movq %r13, %r9
movq 0x60(%rsp), %r13
jmp 0x38e63
movl %r10d, 0x2c(%rsp)
movq %r12, 0x48(%rsp)
movq %r8, 0x20(%rsp)
leal (%rax,%rax,2), %r15d
leal (%rcx,%rcx,2), %ecx
movl $0x4, %r13d
subl %ecx, %r13d
movl $0x5, %r9d
subl %ebx, %r9d
movl $0x4, %r10d
subl %ebx, %r10d
movq %r14, %r12
movl $0x3, %r14d
subl %ebx, %r14d
movl $0x8, %r8d
subl %ebx, %r8d
movl $0x6, %eax
subl %ecx, %eax
movq 0x40(%rsp), %rcx
cmpq %rcx, %rsi
movq %rsi, 0x50(%rsp)
cmovlq %rsi, %rcx
movl %edx, %esi
movq 0x58(%rsp), %rdx
cvtss2sd -0x4(%rdx,%r12,4), %xmm3
movq %r12, 0x98(%rsp)
movq 0x70(%rsp), %rdx
movb -0x1(%rdx,%r12), %dl
testl %esi, %esi
movl $0x0, %ebx
cmovlel %ebx, %esi
movl %esi, 0x90(%rsp)
movapd %xmm1, %xmm4
subsd %xmm3, %xmm4
mulsd 0xcde5(%rip), %xmm3     # 0x45b10
movq %rbp, 0x100(%rsp)
movl %ebp, %esi
xorps %xmm5, %xmm5
cmpq 0x40(%rsp), %rcx
jge 0x38d6b
movq 0x80(%rsp), %rbx
movb (%rbx,%rcx), %bpl
movapd %xmm1, %xmm5
cmpb $0x3, %bpl
ja 0x38d6b
movapd %xmm1, %xmm5
cmpb $0x3, %dl
ja 0x38d6b
movapd %xmm4, %xmm5
cmpb %dl, %bpl
je 0x38d6b
movapd %xmm3, %xmm5
leal (%r15,%rax), %ebp
movslq %ebp, %rbp
mulsd (%r11,%rbp,8), %xmm5
leal (%r15,%r14), %ebp
leal (%r15,%r13), %r12d
movslq %r12d, %r12
movsd (%r11,%r12,8), %xmm6
mulsd %xmm0, %xmm6
movapd %xmm5, %xmm7
mulsd %xmm10, %xmm7
addsd %xmm6, %xmm7
leal (%r15,%r8), %ebx
movslq %ebx, %rbx
movsd (%rdi,%rbx,8), %xmm6
mulsd %xmm12, %xmm6
addsd %xmm7, %xmm6
movslq %ebp, %rbp
movsd %xmm6, (%rdi,%rbp,8)
movsd (%r11,%r12,8), %xmm6
mulsd %xmm11, %xmm6
movapd %xmm5, %xmm7
mulsd %xmm14, %xmm7
addsd %xmm6, %xmm7
leal (%r15,%r10), %ebp
movslq %ebp, %r12
movsd %xmm7, (%rdi,%r12,8)
movsd (%rdi,%rbx,8), %xmm6
mulsd %xmm15, %xmm6
mulsd %xmm13, %xmm5
addsd %xmm6, %xmm5
mulsd %xmm2, %xmm5
leal (%r15,%r9), %ebx
movslq %ebx, %rbx
movsd %xmm5, (%rdi,%rbx,8)
leaq -0x1(%rcx), %rbx
addl $-0x3, %r13d
addl $-0x3, %r9d
addl $-0x3, %r10d
addl $-0x3, %r14d
addl $-0x3, %r8d
addl $-0x3, %eax
cmpq %rsi, %rcx
movq %rbx, %rcx
jg 0x38d35
movq 0x30(%rsp), %r15
movq 0x60(%rsp), %r13
movq 0xa8(%rsp), %r9
movq 0x20(%rsp), %r8
movq 0x48(%rsp), %r12
movq 0x50(%rsp), %rsi
movl 0x2c(%rsp), %r10d
movq 0x98(%rsp), %r14
movl 0x90(%rsp), %edx
movq 0x100(%rsp), %rbp
subl %edx, %ebp
leal 0x3(%rbp,%rbp,2), %eax
movq 0xb0(%rsp), %rcx
subl %edx, %ecx
leal (%rcx,%rcx,2), %ecx
addl $0x5, %ecx
cmpl %ecx, %eax
movl 0x8(%rsp), %edx
jg 0x38ebd
movq 0x78(%rsp), %rax
leal (%rax,%rax,2), %eax
subl %edx, %eax
addl $0x3, %eax
cltq
decq %rax
movapd %xmm1, %xmm2
movq 0x10(%rsp), %rdx
divsd (%rdx,%r12,8), %xmm2
movslq %ecx, %rcx
movsd 0x8(%rdi,%rax,8), %xmm3
mulsd %xmm2, %xmm3
movsd %xmm3, 0x8(%rdi,%rax,8)
incq %rax
cmpq %rcx, %rax
jl 0x38ea5
decq %rsi
decl %r10d
decl %r8d
cmpq $0x2, %r14
jg 0x38bdb
movl 0x18(%rsp), %eax
movq 0x88(%rsp), %r8
cmpl %r8d, %eax
cmovgl %eax, %r8d
movq 0x68(%rsp), %rax
leal (%rax,%rax,2), %eax
addl $0x3, %eax
movl 0x1c(%rsp), %ecx
cmpl %ecx, %r8d
cmovlel %ecx, %r8d
leal 0x1(%r8), %esi
cmpl %esi, %r13d
cmovll %r13d, %esi
movq 0x80(%rsp), %rcx
addq %rsi, %rcx
decq %rcx
leal (%rsi,%rsi,2), %edx
incl %esi
movl $0x1, %edi
subl %r8d, %edi
xorl %r8d, %r8d
testl %edi, %edi
cmovgl %edi, %r8d
leal (%r8,%r8,2), %edi
subl %edi, %edx
addl $0x4, %edx
xorpd %xmm0, %xmm0
movsd 0x8abb(%rip), %xmm1     # 0x419f8
movsd 0xcbc3(%rip), %xmm2     # 0x45b08
movq 0x70(%rsp), %r10
movq %r9, %r12
movq 0x58(%rsp), %r9
movb (%rcx), %dil
movapd %xmm1, %xmm3
cmpb $0x3, %dil
ja 0x38f8f
movb (%r10), %r8b
movapd %xmm1, %xmm3
cmpb $0x3, %r8b
ja 0x38f8f
xorps %xmm4, %xmm4
cvtss2sd (%r9), %xmm4
cmpb %r8b, %dil
jne 0x38f83
movapd %xmm1, %xmm3
subsd %xmm4, %xmm3
jmp 0x38f8f
mulsd 0xcb85(%rip), %xmm4     # 0x45b10
movapd %xmm4, %xmm3
leal -0x1(%rdx), %edi
cmpl %eax, %edi
jge 0x38fc1
movq 0x8(%r12), %r8
movl %edi, %edi
mulsd (%r8,%rdi,8), %xmm3
movl %edx, %edi
movsd (%r8,%rdi,8), %xmm4
mulsd %xmm2, %xmm4
mulsd %xmm9, %xmm4
mulsd %xmm8, %xmm3
addsd %xmm4, %xmm3
addsd %xmm3, %xmm0
decq %rcx
decl %esi
addl $-0x3, %edx
cmpl $0x1, %esi
jg 0x38f52
movq 0x10(%rsp), %rax
divsd (%rax), %xmm0
movq (%r12), %rax
movsd %xmm0, 0x18(%rax)
movl $0x1, %ebx
movl $0x63, %r14d
movl 0xbc(%rsp), %eax
cmpl $0x2, %eax
movl $0x1, %edx
cmovgel %eax, %edx
testl %eax, %eax
movl $0x0, %esi
movl %eax, %ebp
cmovgl %eax, %esi
movl %ebx, %eax
movq 0x38(%rsp), %rcx
subl %ecx, %eax
cmpl $0x2, %eax
movl $0x1, %edi
cmovll %edi, %eax
leal (%rcx,%rbx), %r9d
cmpl %r13d, %r9d
cmovgel %r13d, %r9d
movl $0xffffffff, %r8d       # imm = 0xFFFFFFFF
movsd 0xcaea(%rip), %xmm1     # 0x45b20
cmpl %r9d, %eax
jg 0x390c9
leaq -0x1(%rdx), %rax
leal (%rdx,%rdx,2), %ecx
leal (%rsi,%rsi,2), %esi
subl %esi, %ecx
addl $0x4, %ecx
leal -0x4(,%rdx,4), %edx
movq 0xa0(%rsp), %rsi
movq (%rsi,%rbx,8), %rsi
movq (%r12,%rbx,8), %rdi
movl %r9d, %r9d
xorpd %xmm1, %xmm1
xorpd %xmm0, %xmm0
leal -0x1(%rcx), %r10d
movslq %r10d, %r10
movsd (%rsi,%r10,8), %xmm2
mulsd (%rdi,%r10,8), %xmm2
ucomisd %xmm1, %xmm2
movl %r8d, %r10d
cmoval %edx, %r10d
addsd %xmm2, %xmm0
maxsd %xmm1, %xmm2
movslq %ecx, %rcx
movsd (%rsi,%rcx,8), %xmm1
mulsd (%rdi,%rcx,8), %xmm1
ucomisd %xmm2, %xmm1
leal 0x1(%rdx), %r8d
cmovbel %r10d, %r8d
addsd %xmm1, %xmm0
maxsd %xmm2, %xmm1
incq %rax
addl $0x3, %ecx
addl $0x4, %edx
cmpq %r9, %rax
jb 0x39070
divsd %xmm0, %xmm1
movsd 0x8927(%rip), %xmm0     # 0x419f8
subsd %xmm1, %xmm0
movq 0x140(%rsp), %rax
movl %r8d, -0x4(%rax,%rbx,4)
callq 0x3330
mulsd 0x8991(%rip), %xmm0     # 0x41a80
addsd 0x5f39(%rip), %xmm0     # 0x3f030
cvttsd2si %xmm0, %eax
cmpl $0x65, %eax
cmovgel %r14d, %eax
movq 0x148(%rsp), %rcx
movb %al, -0x1(%rcx,%rbx)
incq %rbx
movl %ebp, %eax
incl %eax
cmpq %r15, %rbx
jne 0x38ff2
xorl %ebx, %ebx
movq 0xa0(%rsp), %r14
movq (%r14,%rbx,8), %rdi
callq 0x3350
movq (%r12,%rbx,8), %rdi
callq 0x3350
incq %rbx
cmpq %rbx, %r15
jne 0x39128
movq %r14, %rdi
callq 0x3350
jmp 0x39168
xorl %ebx, %ebx
movq 0x30(%rsp), %r14
movq (%rbp,%rbx,8), %rdi
callq 0x3350
incq %rbx
cmpq %rbx, %r14
jne 0x39153
movq %rbp, %r12
cvttsd2si 0xf8(%rsp), %ebx
movq %r12, %rdi
callq 0x3350
movq 0x10(%rsp), %rdi
callq 0x3350
movq 0x58(%rsp), %rdi
callq 0x3350
movl %ebx, %eax
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nopl (%rax)