// File: /workspace/github_cpp_makefile_star2_O3/statgen[P]statgen/lib/samtools-0.1.7a-hybrid/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;

	/*** 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) {
		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) Pr += -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 $0xf8, %rsp
movq %r8, %r15
movl %ecx, %ebp
movq %rdx, 0x70(%rsp)
movl %esi, %ebx
movq %rdi, 0x78(%rsp)
cmpq $0x0, 0x130(%rsp)
setne %al
cmpq $0x0, 0x138(%rsp)
setne %r12b
andb %al, %r12b
movl %esi, %ecx
subl %ebp, %ecx
movl %ebp, %edx
cmovgl %esi, %edx
movq %r9, 0x58(%rsp)
movl 0x8(%r9), %eax
cmpl %eax, %edx
cmovgel %eax, %edx
movl %ecx, %eax
negl %eax
movl %ecx, 0x14(%rsp)
cmovsl %ecx, %eax
cmpl %eax, %edx
movl %edx, 0x10(%rsp)
cmovgl %edx, %eax
movq %rax, 0x28(%rsp)
leal 0x1(%rbp), %eax
movl %eax, 0x4(%rsp)
movslq %eax, %r14
movl $0x8, %esi
movq %r14, %rdi
callq 0x3530
movq %rax, %r13
movb %r12b, 0x40(%rsp)
cmpb $0x1, %r12b
movq %r14, 0x48(%rsp)
jne 0x20c28
movl $0x8, %esi
movq %r14, %rdi
callq 0x3530
movq %rax, 0x20(%rsp)
jmp 0x20c31
movq $0x0, 0x20(%rsp)
movl %ebx, (%rsp)
movq 0x28(%rsp), %rax
leal 0x1(,%rax,2), %eax
movq %rax, 0x60(%rsp)
testl %ebp, %ebp
js 0x20c94
movq 0x60(%rsp), %rax
leal (%rax,%rax,2), %r12d
addl $0x6, %r12d
movl 0x4(%rsp), %ebx
xorl %r14d, %r14d
movl $0x8, %esi
movq %r12, %rdi
callq 0x3530
movq %rax, (%r13,%r14,8)
cmpb $0x0, 0x40(%rsp)
je 0x20c8c
movl $0x8, %esi
movq %r12, %rdi
callq 0x3530
movq 0x20(%rsp), %rcx
movq %rax, (%rcx,%r14,8)
incq %r14
cmpq %r14, %rbx
jne 0x20c5d
leal 0x2(%rbp), %eax
movl %eax, 0x80(%rsp)
movslq %eax, %rdi
movl $0x8, %esi
callq 0x3530
movq %rax, 0x8(%rsp)
movslq %ebp, %rdi
movl $0x4, %esi
movq %rdi, 0x68(%rsp)
callq 0x3530
movq %rax, 0x38(%rsp)
movss 0xe661(%rip), %xmm0     # 0x2f330
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
leaq 0xe654(%rip), %rbx      # 0x2f330
jne 0x20d19
jp 0x20d19
xorl %r14d, %r14d
movq %rbx, %r12
xorps %xmm1, %xmm1
cvtsi2sd %r14d, %xmm1
movsd 0x27e2(%rip), %xmm0     # 0x234d8
divsd %xmm0, %xmm1
callq 0x3650
cvtsd2ss %xmm0, %xmm0
movss %xmm0, (%r12)
decq %r14
addq $0x4, %r12
cmpq $-0x100, %r14
jne 0x20ce6
testl %ebp, %ebp
movl (%rsp), %r14d
movq 0x38(%rsp), %rsi
jle 0x20d4d
movl %ebp, %eax
xorl %ecx, %ecx
testq %r15, %r15
je 0x20d36
movzbl (%r15,%rcx), %edx
jmp 0x20d3b
movl $0x1e, %edx
movss (%rbx,%rdx,4), %xmm0
movss %xmm0, (%rsi,%rcx,4)
incq %rcx
cmpq %rcx, %rax
jne 0x20d2a
leal 0x2(,%rbp,2), %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
movsd 0x276c(%rip), %xmm12    # 0x234d0
movapd %xmm12, %xmm1
divsd %xmm0, %xmm1
movsd %xmm1, 0x50(%rsp)
movq 0x58(%rsp), %rax
movss (%rax), %xmm1
movss 0x4(%rax), %xmm0
movss 0x2797(%rip), %xmm2     # 0x23520
movaps %xmm2, %xmm4
subss %xmm1, %xmm4
movaps %xmm4, %xmm3
subss %xmm1, %xmm3
cvtsi2ss %r14d, %xmm5
subss %xmm0, %xmm2
divss %xmm5, %xmm4
cvtss2sd %xmm4, %xmm10
movaps %xmm1, %xmm4
divss %xmm5, %xmm4
cvtss2sd %xmm4, %xmm11
movabsq $0x3ff0000000000000, %rax # imm = 0x3FF0000000000000
movq 0x8(%rsp), %rcx
movq %rax, (%rcx)
movq (%r13), %rcx
movq %rax, 0x18(%rcx)
movq 0x8(%r13), %rax
movq 0x28(%rsp), %rsi
leal 0x1(%rsi), %edx
cmpl %r14d, %edx
cmovgel %r14d, %edx
movl $0x1, %ecx
movl $0x1, %r8d
subl %esi, %r8d
xorl %edi, %edi
testl %r8d, %r8d
movl $0x0, %esi
movl %r8d, 0xc4(%rsp)
cmovgl %r8d, %esi
testl %r14d, %r14d
jle 0x20ee6
movsd 0x61c9(%rip), %xmm5     # 0x26fe0
mulsd %xmm11, %xmm5
movl %edx, %r8d
movl %ebp, %r9d
subl %r14d, %r9d
movl 0x10(%rsp), %r10d
cmpl %r9d, %r10d
cmovgl %r10d, %r9d
movl 0x14(%rsp), %r10d
cmpl %r10d, %r9d
cmovlel %r10d, %r9d
movl $0x1, %r10d
subl %r9d, %r10d
testl %r10d, %r10d
cmovlel %edi, %r10d
leal (%r10,%r10,2), %r10d
movl $0x7, %r9d
subl %r10d, %r9d
xorps %xmm4, %xmm4
movsd 0x6183(%rip), %xmm6     # 0x26fe8
movq 0x38(%rsp), %rbx
movq 0x78(%rsp), %r10
movb (%r10,%rdi), %r10b
movapd %xmm12, %xmm7
cmpb $0x3, %r10b
ja 0x20eb5
movq 0x70(%rsp), %r11
movb (%r11), %r11b
movapd %xmm12, %xmm7
cmpb $0x3, %r11b
ja 0x20eb5
xorps %xmm8, %xmm8
cvtss2sd (%rbx), %xmm8
cmpb %r11b, %r10b
jne 0x20eab
movapd %xmm12, %xmm7
subsd %xmm8, %xmm7
jmp 0x20eb5
mulsd %xmm6, %xmm8
movapd %xmm8, %xmm7
leal -0x1(%r9), %r10d
mulsd %xmm10, %xmm7
movslq %r10d, %r10
movsd %xmm7, (%rax,%r10,8)
movslq %r9d, %r9
movsd %xmm5, (%rax,%r9,8)
addsd %xmm5, %xmm7
addsd %xmm7, %xmm4
incq %rdi
addl $0x3, %r9d
cmpq %r8, %rdi
jb 0x20e6a
jmp 0x20ee9
xorps %xmm4, %xmm4
cvtss2sd %xmm3, %xmm13
subsd 0x50(%rsp), %xmm12
cvtss2sd %xmm1, %xmm14
cvtss2sd %xmm2, %xmm15
cvtss2sd %xmm0, %xmm0
movsd %xmm0, 0x58(%rsp)
movq 0x8(%rsp), %rdi
movsd %xmm4, 0x8(%rdi)
movq 0x28(%rsp), %rdi
testl %edi, %edi
cmovlel %edi, %ecx
leal (%rcx,%rcx,2), %edi
addl $0x3, %edi
subl %esi, %edx
leal (%rdx,%rdx,2), %edx
addl $0x5, %edx
cmpl %edx, %edi
jg 0x20f51
leal (%rcx,%rcx,2), %ecx
movl %edi, %esi
addl $0x2, %ecx
leaq (%rax,%rsi,8), %rsi
movsd (%rsi), %xmm0
divsd %xmm4, %xmm0
movsd %xmm0, (%rsi)
incl %ecx
addq $0x8, %rsi
cmpl %ecx, %edx
jg 0x20f3b
mulsd %xmm12, %xmm13
mulsd %xmm12, %xmm14
movapd %xmm12, %xmm0
mulsd %xmm15, %xmm0
movsd %xmm0, 0xc8(%rsp)
mulsd 0x58(%rsp), %xmm12
movq %rbp, 0x18(%rsp)
cmpl $0x2, %ebp
movq %r13, 0xb8(%rsp)
jl 0x21272
movq 0x18(%rsp), %rcx
movl %ecx, %edx
subl %r14d, %edx
movl 0x10(%rsp), %ecx
cmpl %edx, %ecx
cmovgl %ecx, %edx
movl 0x14(%rsp), %ecx
cmpl %ecx, %edx
cmovlel %ecx, %edx
movl $0x2, %esi
subl %edx, %esi
movl 0x4(%rsp), %r8d
movl $0x1, %r11d
subl %edx, %r11d
movl $0x2, %edi
movsd 0x2507(%rip), %xmm0     # 0x234d0
movsd 0x6017(%rip), %xmm1     # 0x26fe8
movsd 0x6007(%rip), %xmm2     # 0x26fe0
movq %r8, 0x90(%rsp)
cmpl $0x2, %esi
movl $0x1, %r12d
cmovgel %esi, %r12d
leal (%r12,%r12,2), %r10d
testl %esi, %esi
movl $0x0, %edx
cmovgl %esi, %edx
leal (%rdx,%rdx,2), %ebx
testl %r11d, %r11d
movl $0x0, %edx
cmovgl %r11d, %edx
movq (%r13,%rdi,8), %r9
movq 0x28(%rsp), %rcx
leal (%rcx,%rdi), %r15d
movl %edi, %ebp
subl %ecx, %ebp
cmpl $0x2, %ebp
movl $0x1, %ecx
cmovgel %ebp, %ecx
cmpl %r14d, %r15d
cmovgel %r14d, %r15d
cmpl %r15d, %ecx
jle 0x21046
testl %ebp, %ebp
movl $0x0, %eax
cmovlel %eax, %ebp
xorps %xmm3, %xmm3
jmp 0x21204
movq %rcx, 0x98(%rsp)
movl %r11d, 0xb0(%rsp)
movl %esi, 0x34(%rsp)
decq %r12
movq %r15, %rsi
leal (%rdx,%rdx,2), %r15d
negl %r15d
movl %ebx, 0xa8(%rsp)
movl %ebx, %r14d
negl %r14d
movq 0x70(%rsp), %rcx
movb -0x1(%rcx,%rdi), %r8b
movq 0x38(%rsp), %rcx
xorps %xmm4, %xmm4
cvtss2sd -0x4(%rcx,%rdi,4), %xmm4
movapd %xmm0, %xmm5
subsd %xmm4, %xmm5
mulsd %xmm1, %xmm4
testl %ebp, %ebp
movl $0x0, %ecx
cmovlel %ecx, %ebp
movq %rsi, 0xa0(%rsp)
movl %esi, %edx
xorps %xmm3, %xmm3
movq 0x78(%rsp), %rcx
movb (%rcx,%r12), %r11b
movapd %xmm5, %xmm6
cmpb %r8b, %r11b
je 0x210c5
movapd %xmm4, %xmm6
movapd %xmm0, %xmm8
cmpb $0x4, %r8b
jae 0x210d5
movapd %xmm6, %xmm8
movapd %xmm0, %xmm7
cmpb $0x4, %r11b
jae 0x210e4
movapd %xmm8, %xmm7
leal (%r10,%r14), %r11d
leal (%r10,%r14), %esi
addl $0x3, %esi
leal (%r10,%r15), %ecx
leal 0x3(%r10,%r15), %r13d
movslq %ecx, %rcx
leal 0x1(%r10,%r15), %ebx
movslq %ebx, %rbx
movsd (%rax,%rbx,8), %xmm6
mulsd 0xc8(%rsp), %xmm6
movsd (%rax,%rcx,8), %xmm8
mulsd %xmm13, %xmm8
addsd %xmm6, %xmm8
leal 0x2(%r10,%r15), %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm6
mulsd %xmm15, %xmm6
addsd %xmm8, %xmm6
mulsd %xmm7, %xmm6
movslq %esi, %rcx
movsd %xmm6, (%r9,%rcx,8)
movslq %r13d, %rcx
leal 0x4(%r10,%r15), %esi
movslq %esi, %rsi
movsd (%rax,%rsi,8), %xmm7
mulsd %xmm12, %xmm7
movsd (%rax,%rcx,8), %xmm8
mulsd %xmm14, %xmm8
addsd %xmm7, %xmm8
mulsd %xmm2, %xmm8
leal 0x4(%r10,%r14), %ecx
movslq %ecx, %rcx
movsd %xmm8, (%r9,%rcx,8)
movslq %r11d, %rcx
leal 0x2(%r10,%r14), %esi
movslq %esi, %rsi
movsd (%r9,%rsi,8), %xmm7
mulsd 0x58(%rsp), %xmm7
movsd (%r9,%rcx,8), %xmm9
mulsd %xmm14, %xmm9
addsd %xmm7, %xmm9
leal 0x5(%r10,%r14), %ecx
movslq %ecx, %rcx
movsd %xmm9, (%r9,%rcx,8)
addsd %xmm6, %xmm8
addsd %xmm9, %xmm8
addsd %xmm8, %xmm3
incq %r12
addl $0x3, %r15d
addl $0x3, %r14d
cmpq %rdx, %r12
jb 0x210af
movl (%rsp), %r14d
movl 0x34(%rsp), %esi
movq 0x90(%rsp), %r8
movl 0xb0(%rsp), %r11d
movl 0xa8(%rsp), %ebx
movq 0xa0(%rsp), %r15
movq 0x98(%rsp), %rcx
movq 0x8(%rsp), %rax
movsd %xmm3, (%rax,%rdi,8)
subl %ebp, %ecx
leal (%rcx,%rcx,2), %eax
addl $0x3, %eax
subl %ebp, %r15d
leal (%r15,%r15,2), %edx
addl $0x5, %edx
cmpl %edx, %eax
jg 0x21256
subl %ebx, %r10d
addl $0x3, %r10d
movslq %r10d, %rax
decq %rax
movapd %xmm0, %xmm4
divsd %xmm3, %xmm4
movslq %edx, %rdx
movsd 0x8(%r9,%rax,8), %xmm3
mulsd %xmm4, %xmm3
movsd %xmm3, 0x8(%r9,%rax,8)
incq %rax
cmpq %rdx, %rax
jl 0x2123c
incq %rdi
incl %esi
incl %r11d
movq %r9, %rax
cmpq %r8, %rdi
movq 0xb8(%rsp), %r13
jne 0x20fe1
testl %r14d, %r14d
movq 0x20(%rsp), %rbp
jle 0x212f7
movq 0x18(%rsp), %r11
movl %r11d, %eax
subl 0x28(%rsp), %eax
xorl %edx, %edx
testl %eax, %eax
cmovgl %eax, %edx
movq 0x60(%rsp), %rax
leal 0x3(%rax,%rax,2), %eax
movl %r14d, %ecx
leal (%rdx,%rdx,2), %esi
movl $0x3, %edx
subl %esi, %edx
xorpd %xmm0, %xmm0
movq 0x48(%rsp), %r9
movq 0x68(%rsp), %r10
movsd 0x50(%rsp), %xmm3
movl %edx, %esi
leal 0x3(%rsi), %edx
cmpl $0x7ffffffc, %esi       # imm = 0x7FFFFFFC
ja 0x212f0
cmpl %eax, %edx
jge 0x212f0
movq (%r13,%r10,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 0x212b9
jmp 0x21305
xorpd %xmm0, %xmm0
movq 0x18(%rsp), %r11
movq 0x48(%rsp), %r9
movq 0x8(%rsp), %rax
movsd %xmm0, (%rax,%r9,8)
cmpl $-0x1, %r11d
movsd %xmm13, 0xe0(%rsp)
movsd %xmm15, 0xd0(%rsp)
movsd %xmm10, 0xf0(%rsp)
movsd %xmm11, 0xe8(%rsp)
movsd %xmm12, 0x88(%rsp)
movsd %xmm14, 0xd8(%rsp)
jge 0x2135c
movsd 0x2176(%rip), %xmm0     # 0x234d0
jmp 0x213a4
movl 0x80(%rsp), %ebx
movsd 0x2165(%rip), %xmm0     # 0x234d0
xorl %r14d, %r14d
movsd 0x5c7a(%rip), %xmm1     # 0x26ff0
movq 0x8(%rsp), %rax
mulsd (%rax,%r14,8), %xmm0
ucomisd %xmm0, %xmm1
jbe 0x2139c
callq 0x32a0
movsd 0x5c5c(%rip), %xmm1     # 0x26ff0
movsd 0x2134(%rip), %xmm0     # 0x234d0
incq %r14
cmpq %r14, %rbx
jne 0x21376
movl (%rsp), %ebx
xorps %xmm1, %xmm1
cvtsi2sd %ebx, %xmm1
mulsd %xmm0, %xmm1
movq 0x18(%rsp), %r14
xorps %xmm0, %xmm0
cvtsi2sd %r14d, %xmm0
mulsd %xmm1, %xmm0
callq 0x32a0
movsd %xmm0, 0x80(%rsp)
cmpb $0x0, 0x40(%rsp)
je 0x21909
testl %ebx, %ebx
movq 0x138(%rsp), %r13
movsd 0xf0(%rsp), %xmm9
movsd 0xe8(%rsp), %xmm10
movsd 0x88(%rsp), %xmm11
movsd 0xe0(%rsp), %xmm12
movsd 0xd8(%rsp), %xmm13
movsd 0xd0(%rsp), %xmm14
movq 0x48(%rsp), %r9
movq 0x68(%rsp), %r10
movsd 0x50(%rsp), %xmm1
jle 0x21499
movq (%rbp,%r10,8), %rax
movl %r14d, %ecx
subl 0x28(%rsp), %ecx
xorl %esi, %esi
testl %ecx, %ecx
cmovgl %ecx, %esi
movq 0x60(%rsp), %rcx
leal 0x3(%rcx,%rcx,2), %ecx
movl (%rsp), %edx
leal (%rsi,%rsi,2), %edi
movl $0x3, %esi
subl %edi, %esi
movl %esi, %edi
leal 0x3(%rdi), %esi
cmpl $0x7ffffffc, %edi       # imm = 0x7FFFFFFC
ja 0x21494
cmpl %ecx, %esi
jge 0x21494
movapd %xmm1, %xmm0
movq 0x8(%rsp), %r8
divsd (%r8,%r10,8), %xmm0
divsd (%r8,%r9,8), %xmm0
movl %esi, %r8d
movsd %xmm0, (%rax,%r8,8)
movl %edi, %edi
movsd %xmm0, 0x20(%rax,%rdi,8)
decq %rdx
jne 0x2145d
cmpl $0x2, %r14d
jl 0x21807
movsd 0x5b35(%rip), %xmm1     # 0x26fe0
movapd %xmm13, %xmm0
mulsd %xmm1, %xmm0
movq 0x18(%rsp), %rcx
movl %ecx, %esi
movl (%rsp), %edx
subl %edx, %esi
movl 0x10(%rsp), %eax
cmpl %esi, %eax
cmovgl %eax, %esi
mulsd %xmm1, %xmm11
movl 0x14(%rsp), %eax
cmpl %eax, %esi
cmovlel %eax, %esi
leal -0x1(%rsi,%rcx), %eax
movslq %eax, %rbx
movslq %edx, %rax
movq %rax, 0x40(%rsp)
movl %ecx, %edi
subl %esi, %edi
notl %esi
addl %ecx, %esi
movl %ecx, %r8d
movq (%rbp,%r8,8), %r9
movsd 0x1fd2(%rip), %xmm1     # 0x234d0
movsd 0x5ae2(%rip), %xmm2     # 0x26fe8
movq %rbp, 0x20(%rsp)
movq %r8, %r10
movq %r9, %r12
cmpl $0x2, %esi
movl $0x1, %r11d
cmovgel %esi, %r11d
testl %esi, %esi
movl $0x0, %edx
cmovgl %esi, %edx
movq 0x40(%rsp), %rax
cmpq %rax, %rbx
cmovlq %rbx, %rax
testl %edi, %edi
movl $0x0, %ecx
cmovgl %edi, %ecx
movapd %xmm1, %xmm3
cmpq $0x2, %r8
jne 0x2154c
xorpd %xmm3, %xmm3
leal (%rdx,%rdx,2), %r13d
leaq -0x1(%r10), %r8
movq -0x8(%rbp,%r10,8), %r9
movq 0x28(%rsp), %rdx
leal (%rdx,%r8), %ebp
movl %r8d, %r14d
subl %edx, %r14d
cmpl $0x2, %r14d
movl $0x1, %edx
cmovgel %r14d, %edx
movl (%rsp), %r15d
cmpl %r15d, %ebp
cmovgel %r15d, %ebp
movq %rbp, 0xb0(%rsp)
cmpl %edx, %ebp
movl %r13d, 0x34(%rsp)
jge 0x215af
testl %r14d, %r14d
movl $0x0, %eax
cmovlel %eax, %r14d
movq 0x138(%rsp), %r13
movq 0x20(%rsp), %rbp
jmp 0x2179a
movq %r11, 0x48(%rsp)
movq %r8, 0x90(%rsp)
movl %edi, 0x98(%rsp)
movq %rsi, 0xa8(%rsp)
leal (%rax,%rax,2), %r15d
leal (%rcx,%rcx,2), %eax
movl $0x4, %r11d
subl %eax, %r11d
movl $0x5, %edi
subl %r13d, %edi
movl $0x4, %r8d
subl %r13d, %r8d
movq %r10, %rbp
movl $0x3, %r10d
subl %r13d, %r10d
movl $0x8, %esi
subl %r13d, %esi
movl $0x6, %ecx
subl %eax, %ecx
movq %rdx, %r13
movq 0x40(%rsp), %rdx
cmpq %rdx, %rbx
movq %rbx, 0xa0(%rsp)
cmovlq %rbx, %rdx
movq 0x38(%rsp), %rax
cvtss2sd -0x4(%rax,%rbp,4), %xmm4
movq 0x70(%rsp), %rax
movq %rbp, 0x50(%rsp)
movb -0x1(%rax,%rbp), %al
testl %r14d, %r14d
movl $0x0, %ebx
cmovlel %ebx, %r14d
movl %r14d, 0x68(%rsp)
movapd %xmm1, %xmm5
subsd %xmm4, %xmm5
mulsd %xmm2, %xmm4
movq %r13, 0x88(%rsp)
movl %r13d, %r13d
xorpd %xmm6, %xmm6
cmpq 0x40(%rsp), %rdx
jge 0x2168f
movq 0x78(%rsp), %rbx
movb (%rbx,%rdx), %bl
movapd %xmm1, %xmm6
cmpb $0x3, %bl
ja 0x2168f
movapd %xmm1, %xmm6
cmpb $0x3, %al
ja 0x2168f
movapd %xmm5, %xmm6
cmpb %al, %bl
je 0x2168f
movapd %xmm4, %xmm6
leal (%r15,%rcx), %ebx
movslq %ebx, %rbx
mulsd (%r12,%rbx,8), %xmm6
leal (%r15,%r10), %ebx
leal (%r15,%r11), %ebp
movslq %ebp, %rbp
movsd (%r12,%rbp,8), %xmm7
mulsd %xmm0, %xmm7
movapd %xmm6, %xmm8
mulsd %xmm12, %xmm8
addsd %xmm7, %xmm8
leal (%r15,%rsi), %r14d
movslq %r14d, %r14
movsd (%r9,%r14,8), %xmm7
mulsd %xmm13, %xmm7
addsd %xmm8, %xmm7
movslq %ebx, %rbx
movsd %xmm7, (%r9,%rbx,8)
movsd (%r12,%rbp,8), %xmm7
mulsd %xmm11, %xmm7
movapd %xmm6, %xmm8
mulsd 0xc8(%rsp), %xmm8
addsd %xmm7, %xmm8
leal (%r15,%r8), %ebx
movslq %ebx, %rbx
movsd %xmm8, (%r9,%rbx,8)
movsd (%r9,%r14,8), %xmm7
mulsd 0x58(%rsp), %xmm7
mulsd %xmm14, %xmm6
addsd %xmm7, %xmm6
mulsd %xmm3, %xmm6
leal (%r15,%rdi), %ebx
movslq %ebx, %rbx
movsd %xmm6, (%r9,%rbx,8)
leaq -0x1(%rdx), %rbx
addl $-0x3, %r11d
addl $-0x3, %edi
addl $-0x3, %r8d
addl $-0x3, %r10d
addl $-0x3, %esi
addl $-0x3, %ecx
cmpq %r13, %rdx
movq %rbx, %rdx
jg 0x2165f
movq 0x138(%rsp), %r13
movq 0x20(%rsp), %rbp
movq 0xa8(%rsp), %rsi
movq 0xa0(%rsp), %rbx
movl 0x98(%rsp), %edi
movq 0x90(%rsp), %r8
movq 0x50(%rsp), %r10
movq 0x48(%rsp), %r11
movl 0x68(%rsp), %r14d
movq 0x88(%rsp), %rdx
subl %r14d, %edx
leal (%rdx,%rdx,2), %eax
addl $0x3, %eax
movq 0xb0(%rsp), %rcx
subl %r14d, %ecx
leal (%rcx,%rcx,2), %ecx
addl $0x5, %ecx
cmpl %ecx, %eax
movl 0x34(%rsp), %edx
jg 0x217f6
leal (%r11,%r11,2), %eax
subl %edx, %eax
addl $0x3, %eax
cltq
decq %rax
movapd %xmm1, %xmm3
movq 0x8(%rsp), %rdx
divsd (%rdx,%r8,8), %xmm3
movslq %ecx, %rcx
movsd 0x8(%r9,%rax,8), %xmm4
mulsd %xmm3, %xmm4
movsd %xmm4, 0x8(%r9,%rax,8)
incq %rax
cmpq %rcx, %rax
jl 0x217dc
decq %rbx
decl %esi
decl %edi
cmpq $0x2, %r10
jg 0x2150b
movl (%rsp), %ecx
testl %ecx, %ecx
jle 0x21930
movq 0x18(%rsp), %r10
movl %r10d, %esi
subl %ecx, %esi
movl 0x10(%rsp), %eax
cmpl %esi, %eax
cmovgl %eax, %esi
movl 0x14(%rsp), %eax
cmpl %eax, %esi
cmovlel %eax, %esi
leal 0x1(%rsi), %edx
cmpl %edx, %ecx
cmovll %ecx, %edx
movq 0x78(%rsp), %rax
addq %rdx, %rax
decq %rax
leal (%rdx,%rdx,2), %ecx
incl %edx
movl $0x1, %edi
subl %esi, %edi
xorl %r8d, %r8d
testl %edi, %edi
cmovgl %edi, %r8d
movq 0x60(%rsp), %rsi
leal (%rsi,%rsi,2), %esi
addl $0x3, %esi
leal (%r8,%r8,2), %edi
subl %edi, %ecx
addl $0x4, %ecx
xorpd %xmm0, %xmm0
movsd 0x1c5a(%rip), %xmm1     # 0x234d0
movsd 0x5762(%rip), %xmm2     # 0x26fe0
movsd 0x5762(%rip), %xmm3     # 0x26fe8
movq 0x38(%rsp), %r9
movb (%rax), %dil
movapd %xmm1, %xmm4
cmpb $0x3, %dil
ja 0x218c9
movq 0x70(%rsp), %r8
movb (%r8), %r8b
movapd %xmm1, %xmm4
cmpb $0x3, %r8b
ja 0x218c9
xorps %xmm5, %xmm5
cvtss2sd (%r9), %xmm5
cmpb %r8b, %dil
jne 0x218c1
movapd %xmm1, %xmm4
subsd %xmm5, %xmm4
jmp 0x218c9
mulsd %xmm3, %xmm5
movapd %xmm5, %xmm4
leal -0x1(%rcx), %edi
cmpl %esi, %edi
jge 0x218fa
movq 0x8(%rbp), %r8
movl %edi, %edi
mulsd (%r8,%rdi,8), %xmm4
movl %ecx, %edi
movsd (%r8,%rdi,8), %xmm5
mulsd %xmm2, %xmm5
mulsd %xmm10, %xmm5
mulsd %xmm9, %xmm4
addsd %xmm5, %xmm4
addsd %xmm4, %xmm0
decq %rax
decl %edx
addl $-0x3, %ecx
cmpl $0x1, %edx
jg 0x2188b
jmp 0x21939
testl %r14d, %r14d
js 0x21ad9
movl 0x4(%rsp), %ebx
xorl %r14d, %r14d
movq (%r13,%r14,8), %rdi
callq 0x32c0
incq %r14
cmpq %r14, %rbx
jne 0x21919
jmp 0x21ad9
xorpd %xmm0, %xmm0
movq 0x18(%rsp), %r10
movq 0x8(%rsp), %rax
divsd (%rax), %xmm0
movq (%rbp), %rax
movsd %xmm0, 0x18(%rax)
testl %r10d, %r10d
movl 0xc4(%rsp), %eax
jle 0x21a9b
movl 0x4(%rsp), %ebx
movl $0x1, %r14d
movl $0x1, %ebp
movl $0x63, %r15d
cmpl $0x2, %eax
movl $0x1, %edx
cmovgel %eax, %edx
testl %eax, %eax
movl $0x0, %esi
movl %eax, %r12d
cmovgl %eax, %esi
movl %r14d, %eax
movq 0x28(%rsp), %rcx
subl %ecx, %eax
cmpl $0x2, %eax
cmovll %ebp, %eax
leal (%rcx,%r14), %r9d
movl (%rsp), %ecx
cmpl %ecx, %r9d
cmovgel %ecx, %r9d
movl $0xffffffff, %r8d       # imm = 0xFFFFFFFF
movsd 0x5644(%rip), %xmm1     # 0x26ff8
cmpl %r9d, %eax
jg 0x21a4c
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 0xb8(%rsp), %rsi
movq (%rsi,%r14,8), %rsi
movq 0x20(%rsp), %rdi
movq (%rdi,%r14,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 0x219f3
divsd %xmm0, %xmm1
movsd 0x1a7c(%rip), %xmm0     # 0x234d0
subsd %xmm1, %xmm0
movq 0x130(%rsp), %rax
movl %r8d, -0x4(%rax,%r14,4)
callq 0x32a0
mulsd 0x1a76(%rip), %xmm0     # 0x234e8
addsd 0x1a86(%rip), %xmm0     # 0x23500
cvttsd2si %xmm0, %eax
cmpl $0x65, %eax
cmovgel %r15d, %eax
movb %al, -0x1(%r13,%r14)
incq %r14
movl %r12d, %eax
incl %eax
cmpq %rbx, %r14
jne 0x21970
cmpl $0x0, 0x18(%rsp)
movq 0xb8(%rsp), %r15
movq 0x20(%rsp), %r13
js 0x21ad1
movl 0x4(%rsp), %ebx
xorl %r14d, %r14d
movq (%r15,%r14,8), %rdi
callq 0x32c0
movq (%r13,%r14,8), %rdi
callq 0x32c0
incq %r14
cmpq %r14, %rbx
jne 0x21ab6
movq %r15, %rdi
callq 0x32c0
movq %r13, %rdi
callq 0x32c0
movq 0x8(%rsp), %rdi
callq 0x32c0
movq 0x38(%rsp), %rdi
callq 0x32c0
movsd 0x80(%rsp), %xmm1
mulsd 0x19e2(%rip), %xmm1     # 0x234e8
xorpd %xmm0, %xmm0
addsd %xmm1, %xmm0
addsd 0x19ea(%rip), %xmm0     # 0x23500
cvttsd2si %xmm0, %eax
addq $0xf8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq