// File: /workspace/github_c_makefile_star2_O1/lh3[P]minigraph/gchain1.c
// Function: mg_gchain1_dp
int32_t mg_gchain1_dp(void *km, const gfa_t *g, int32_t *n_lc_, mg_lchain_t *lc, int32_t qlen, int32_t max_dist_g, int32_t max_dist_q, int32_t bw, int32_t max_skip,
					  int32_t ref_bonus, float chn_pen_gap, float chn_pen_skip, float mask_level, const mg128_t *an, uint64_t **u_)
{
	int32_t i, j, k, m_dst, n_dst, n_ext, n_u, n_v, n_lc = *n_lc_;
	int32_t *f, *v, *t;
	int64_t *p;
	uint64_t *u;
	mg_path_dst_t *dst;
	gc_frag_t *a;
	mg_lchain_t *swap;
	char *qs;

	*u_ = 0;
	if (n_lc == 0) return 0;

	KMALLOC(km, a, n_lc);
	for (i = n_ext = 0; i < n_lc; ++i) { // a[] is a view of frag[]; for sorting
		mg_lchain_t *r = &lc[i];
		gc_frag_t *ai = &a[i];
		int32_t is_isolated = 0, min_end_dist_g;
		r->dist_pre = -1;
		min_end_dist_g = g->seg[r->v>>1].len - r->re;
		if (r->rs < min_end_dist_g) min_end_dist_g = r->rs;
		if (min_end_dist_g > max_dist_g) is_isolated = 1; // if too far from segment ends
		else if (min_end_dist_g>>3 > r->score) is_isolated = 1; // if the lchain too small relative to distance to the segment ends
		ai->srt = (uint32_t)is_isolated<<31 | r->qe;
		ai->i = i;
		if (!is_isolated) ++n_ext;
	}
	if (n_ext < 2) { // no graph chaining needed; early return
		kfree(km, a);
		KMALLOC(km, u, n_lc);
		for (i = 0; i < n_lc; ++i)
			u[i] = (uint64_t)lc[i].score<<32 | 1;
		*u_ = u;
		return n_lc;
	}
	radix_sort_gc(a, a + n_lc);

	KMALLOC(km, v, n_lc);
	KMALLOC(km, f, n_ext);
	KMALLOC(km, p, n_ext);
	KCALLOC(km, t, n_ext);

	KMALLOC(km, qs, max_dist_q + 1);
	m_dst = n_dst = 0, dst = 0;
	for (i = 0; i < n_ext; ++i) { // core loop
		gc_frag_t *ai = &a[i];
		mg_lchain_t *li = &lc[ai->i];
		int32_t segi = (an[li->off].y & MG_SEED_SEG_MASK) >> MG_SEED_SEG_SHIFT;
		{ // collect end points potentially reachable from _i_
			int32_t x = li->qs + bw, n_skip = 0;
			if (x > qlen) x = qlen;
			x = find_max(i, a, x);
			n_dst = 0;
			for (j = x; j >= 0; --j) { // collect potential destination vertices
				gc_frag_t *aj = &a[j];
				mg_lchain_t *lj = &lc[aj->i];
				mg_path_dst_t *q;
				int32_t target_dist, segj, dq;
				if (lj->qs >= li->qs) continue; // lj is contained in li on the query coordinate
				if (lj->qe > li->qs) { // test overlap on the query
					int o = lj->qe - li->qs;
					if (o > (lj->qe - lj->qs) * mask_level || o > (li->qe - li->qs) * mask_level)
						continue;
				}
				dq = li->qs - lj->qe;
				segj = (an[lj->off + lj->cnt - 1].y & MG_SEED_SEG_MASK) >> MG_SEED_SEG_SHIFT;
				if (segi == segj) {
					if (dq > max_dist_q) break; // if query gap too large, stop
				} else {
					if (dq > max_dist_g && dq > max_dist_q) break;
				}
				if (li->v != lj->v) { // the two linear chains are on two different segments
					int32_t min_dist = li->rs + (g->seg[lj->v>>1].len - lj->re); // minimal graph gap
					if (min_dist > max_dist_g) continue; // graph gap too large
					if (segi == segj && min_dist - bw > li->qs - lj->qe) continue; // when li->qs < lj->qe, the condition turns to min_dist + (lj->qe - li->qs) > bw, which is desired
					target_dist = mg_target_dist(g, lj, li);
					if (target_dist < 0) continue; // this may happen if the query overlap is far too large
				} else if (lj->rs >= li->rs || lj->re >= li->re) { // not colinear
					continue;
				} else {
					int32_t dr = li->rs - lj->re, w = dr > dq? dr - dq : dq - dr;
					if (segi == segj && w > bw) continue; // test bandwidth
					if (dr > max_dist_g || dr < -max_dist_g) continue;
					if (lj->re > li->rs) { // test overlap on the graph segment
						int o = lj->re - li->rs;
						if (o > (lj->re - lj->rs) * mask_level || o > (li->re - li->rs) * mask_level)
							continue;
					}
					target_dist = mg_target_dist(g, lj, li);
				}
				if (n_dst == m_dst) KEXPAND(km, dst, m_dst); // TODO: watch out the quadratic behavior!
				q = &dst[n_dst++];
				memset(q, 0, sizeof(mg_path_dst_t));
				q->inner = (li->v == lj->v);
				q->v = lj->v^1;
				q->meta = j;
				q->qlen = li->qs - lj->qe;
				q->target_dist = target_dist;
				q->target_hash = 0;
				q->check_hash = 0;
				if (t[j] == i) {
					if (++n_skip > max_skip)
						break;
				}
				if (p[j] >= 0) t[p[j]] = i;
			}
		}
		{ // confirm reach-ability
			int32_t k;
			// test reach-ability without sequences
			mg_shortest_k(km, g, li->v^1, n_dst, dst, max_dist_g + (g->seg[li->v>>1].len - li->rs), MG_MAX_SHORT_K, 0);
			// remove unreachable destinations
			for (j = k = 0; j < n_dst; ++j) {
				mg_path_dst_t *dj = &dst[j];
				int32_t sc;
				if (dj->n_path == 0) continue; // not reachable
				sc = cal_sc(dj, li, lc, an, a, f, bw, ref_bonus, chn_pen_gap);
				if (sc == INT32_MIN) continue; // out of band
				if (sc + li->score < 0) continue; // negative score and too low
				dst[k++] = dst[j];
			}
			n_dst = k;
		}
		{ // DP
			int32_t max_f = li->score, max_j = -1, max_d = -1, max_inner = 0;
			uint32_t max_hash = 0;
			for (j = 0; j < n_dst; ++j) {
				mg_path_dst_t *dj = &dst[j];
				int32_t sc;
				sc = cal_sc(dj, li, lc, an, a, f, bw, ref_bonus, chn_pen_gap);
				if (sc == INT32_MIN) continue;
				if (mg_dbg_flag & MG_DBG_GC1) {
					mg_lchain_t *lj = &lc[a[dj->meta].i];
					fprintf(stderr, "  [dst:%d] dst=%c%s[%d], n_path=%d, target=%d, opt_dist=%d, score=%d, q_intv=[%d,%d), g_intv=[%d,%d)\n", dj->meta, "><"[dj->v&1], g->seg[dj->v>>1].name, dj->v, dj->n_path, dj->target_dist - g->seg[li->v>>1].len, dj->dist - g->seg[li->v>>1].len, sc, lj->qs, lj->qe, lj->rs, lj->re);
				}
				if (sc > max_f) max_f = sc, max_j = dj->meta, max_d = dj->dist, max_hash = dj->hash, max_inner = dj->inner;
			}
			f[i] = max_f, p[i] = max_j;
			li->dist_pre = max_d;
			li->hash_pre = max_hash;
			li->inner_pre = max_inner;
			v[i] = max_j >= 0 && v[max_j] > max_f? v[max_j] : max_f;
			if (mg_dbg_flag & MG_DBG_GC1) fprintf(stderr, " [opt:%d] opt=%d, max_f=%d\n", ai->i, max_j, max_f);
		}
	}
	kfree(km, dst);
	kfree(km, qs);
	if (mg_dbg_flag & MG_DBG_GC1) {
		int32_t mmax_f = 0, mmax_i = -1;
		for (i = 0; i < n_ext; ++i) if (f[i] > mmax_f) mmax_f = f[i], mmax_i = i;
		i = mmax_i; while (i >= 0) { fprintf(stderr, "[best] i=%d, seg=%s, max_f=%d, chn_pen_gap=%f\n", a[i].i, g->seg[lc[a[i].i].v>>1].name, f[i], chn_pen_gap); i = p[i]; }
	}

	u = mg_chain_backtrack(km, n_ext, f, p, v, t, 0, 0, INT32_MAX, n_lc - n_ext, &n_u, &n_v);
	kfree(km, f); kfree(km, p); kfree(km, t);

	for (i = 0; i < n_lc - n_ext; ++i) {
		u[n_u++] = (uint64_t)lc[a[n_ext + i].i].score << 32 | 1;
		v[n_v++] = n_ext + i;
	}

	KMALLOC(km, swap, n_v);
	for (i = 0, k = 0; i < n_u; ++i) {
		int32_t k0 = k, ni = (int32_t)u[i];
		for (j = 0; j < ni; ++j)
			swap[k++] = lc[a[v[k0 + (ni - j - 1)]].i];
	}
	assert(k == n_v);
	memcpy(lc, swap, n_v * sizeof(mg_lchain_t));
	*n_lc_ = n_v;
	*u_ = u;

	kfree(km, a);
	kfree(km, swap);
	kfree(km, v);
	return n_u;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x108, %rsp            # imm = 0x108
movl %r9d, 0x24(%rsp)
movl %r8d, 0xd0(%rsp)
movq %rcx, 0x18(%rsp)
movq %rsi, 0x78(%rsp)
movq 0x168(%rsp), %rbx
movslq (%rdx), %r13
movq $0x0, (%rbx)
testq %r13, %r13
je 0x18ab4
movq %rdx, %r12
movq %rdi, %r15
movss %xmm2, 0x34(%rsp)
movss %xmm0, 0x60(%rsp)
leaq (,%r13,8), %r14
movq %r14, %rsi
callq 0x31c1
testl %r13d, %r13d
jle 0x18abc
movq 0x78(%rsp), %rcx
movq 0x10(%rcx), %r9
movq 0x18(%rsp), %rcx
addq $0x20, %rcx
xorl %edx, %edx
xorl %r10d, %r10d
movl $0xffffffff, (%rcx)     # imm = 0xFFFFFFFF
movl -0x18(%rcx), %esi
shrl %esi
shlq $0x6, %rsi
movl (%r9,%rsi), %r8d
subl -0x10(%rcx), %r8d
movl -0x14(%rcx), %esi
cmpl %r8d, %esi
cmovll %esi, %r8d
movl $0x80000000, %esi       # imm = 0x80000000
movl $0x0, %edi
cmpl 0x24(%rsp), %r8d
jg 0x18a99
sarl $0x3, %r8d
xorl %esi, %esi
xorl %edi, %edi
cmpl -0x4(%rcx), %r8d
setg %sil
setle %dil
shll $0x1f, %esi
addl %edi, %r10d
orl -0x8(%rcx), %esi
movl %esi, (%rax,%rdx,8)
movl %edx, 0x4(%rax,%rdx,8)
incq %rdx
addq $0x28, %rcx
cmpq %rdx, %r13
jne 0x18a50
jmp 0x18abf
xorl %r13d, %r13d
jmp 0x19a1e
xorl %r10d, %r10d
cmpl $0x1, %r10d
jg 0x18b0c
movq %r15, %rdi
movq %rax, %rsi
callq 0x30f6
movq %r15, %rdi
movq %r14, %rsi
callq 0x31c1
testl %r13d, %r13d
movq 0x18(%rsp), %rsi
jle 0x18b04
addq $0x1c, %rsi
xorl %ecx, %ecx
movl (%rsi), %edx
shlq $0x20, %rdx
incq %rdx
movq %rdx, (%rax,%rcx,8)
incq %rcx
addq $0x28, %rsi
cmpq %rcx, %r13
jne 0x18aeb
movq %rax, (%rbx)
jmp 0x19a1e
movq %r12, 0xd8(%rsp)
movq 0x160(%rsp), %r14
movl 0x140(%rsp), %r12d
leaq (%rax,%r13,8), %rsi
movq %rax, %rdi
movq %rax, 0x8(%rsp)
movl %r10d, %ebx
callq 0x189a9
movq %r13, 0xe8(%rsp)
shlq $0x2, %r13
movq %r15, %rdi
movq %r13, %rsi
callq 0x31c1
movq %rax, 0x70(%rsp)
movl %ebx, 0x90(%rsp)
movl %ebx, %ebx
leaq (,%rbx,4), %rsi
movq %r15, %rdi
callq 0x31c1
movq %rax, %rbp
leaq (,%rbx,8), %rsi
movq %r15, %rdi
callq 0x31c1
movq %rax, 0xa8(%rsp)
movl $0x4, %edx
movq %r15, %rdi
movq %rbx, 0x98(%rsp)
movq %rbx, %rsi
callq 0x3054
movq %rax, 0xa0(%rsp)
leal 0x1(%r12), %eax
movslq %eax, %rsi
movq %r15, 0x68(%rsp)
movq %r15, %rdi
callq 0x31c1
movq 0x8(%rsp), %r11
movq %rax, 0xe0(%rsp)
leaq -0x8(%r14), %rax
movq %rax, 0x88(%rsp)
movl 0x24(%rsp), %eax
cmpl %r12d, %eax
movl %r12d, %ecx
cmovgl %eax, %ecx
movl %ecx, 0xd4(%rsp)
negl %eax
movl %eax, 0xcc(%rsp)
xorl %r14d, %r14d
xorl %r15d, %r15d
xorl %r13d, %r13d
movq 0x18(%rsp), %rbx
movss 0x34(%rsp), %xmm2
movq %rbp, 0xb8(%rsp)
movslq 0x4(%r11,%r14,8), %rax
leaq (%rax,%rax,4), %rax
movslq (%rbx,%rax,8), %rcx
shlq $0x4, %rcx
movq 0x160(%rsp), %rdx
movq 0x8(%rdx,%rcx), %rdi
movl 0x14(%rbx,%rax,8), %edx
addl 0x148(%rsp), %edx
movl 0xd0(%rsp), %ecx
cmpl %ecx, %edx
cmovgel %ecx, %edx
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
testq %r14, %r14
movq %rdi, 0x10(%rsp)
je 0x18ca0
cmpl %edx, -0x8(%r11,%r14,8)
jae 0x18c60
leaq -0x1(%r14), %rcx
jmp 0x18ca0
cmpl %edx, (%r11)
jae 0x18ca0
xorl %ecx, %ecx
movl %r14d, %esi
movl %esi, %r8d
subl %ecx, %r8d
movl %r8d, %edi
shrl $0x1f, %edi
addl %r8d, %edi
sarl %edi
leal (%rdi,%rcx), %r8d
movslq %r8d, %r9
cmpl %edx, (%r11,%r9,8)
jb 0x18c8d
movl %r8d, %esi
jmp 0x18c91
addl %edi, %ecx
incl %ecx
cmpl %ecx, %esi
jg 0x18c6a
movq 0x10(%rsp), %rdi
jne 0x19a33
movl %r15d, 0x64(%rsp)
movq %r14, 0xb0(%rsp)
leaq (%rbx,%rax,8), %r15
movl $0x0, 0x40(%rsp)
testl %ecx, %ecx
js 0x190ee
movl %ecx, %r14d
movl $0x0, 0x50(%rsp)
movq $0x0, 0x80(%rsp)
movslq 0x4(%r11,%r14,8), %rax
leaq (%rax,%rax,4), %rcx
movl 0x14(%rbx,%rcx,8), %edx
movl 0x14(%r15), %eax
movb $0x1, %bpl
cmpl %eax, %edx
jge 0x18d7c
leaq (%rbx,%rcx,8), %r12
movl 0x18(%r12), %ecx
movl %ecx, %esi
subl %eax, %esi
jle 0x18d34
xorps %xmm0, %xmm0
cvtsi2ss %esi, %xmm0
movl %ecx, %esi
subl %edx, %esi
xorps %xmm1, %xmm1
cvtsi2ss %esi, %xmm1
mulss %xmm2, %xmm1
ucomiss %xmm1, %xmm0
ja 0x18d7c
movl 0x18(%r15), %edx
subl %eax, %edx
xorps %xmm1, %xmm1
cvtsi2ss %edx, %xmm1
mulss %xmm2, %xmm1
ucomiss %xmm1, %xmm0
ja 0x18d7c
movl %eax, %r9d
subl %ecx, %r9d
movslq (%r12), %rdx
movl 0x4(%r12), %esi
shlq $0x21, %rsi
sarq $0x21, %rsi
addq %rdx, %rsi
shlq $0x4, %rsi
movq 0x88(%rsp), %rdx
movq (%rdx,%rsi), %r10
xorq %rdi, %r10
movabsq $0xff000000000000, %rdx # imm = 0xFF000000000000
testq %rdx, %r10
je 0x18d9a
cmpl 0xd4(%rsp), %r9d
jle 0x18da6
xorl %ebp, %ebp
testb %bpl, %bpl
je 0x190f6
leaq -0x1(%r14), %rax
testq %r14, %r14
movq %rax, %r14
jg 0x18cd8
jmp 0x190f6
movl 0x140(%rsp), %edx
cmpl %edx, %r9d
jg 0x18d7a
movl 0x8(%r15), %edx
movl 0x8(%r12), %esi
cmpl %esi, %edx
jne 0x18e59
movl 0xc(%r12), %r8d
movl 0xc(%r15), %edi
movl %edi, 0x28(%rsp)
movl %r8d, 0x5c(%rsp)
cmpl %edi, %r8d
jge 0x18e92
movl 0x10(%r12), %r8d
movl 0x10(%r15), %edi
movl %edi, 0xc0(%rsp)
cmpl %edi, %r8d
movq 0x10(%rsp), %rdi
jge 0x18d7c
movq %rdx, 0x48(%rsp)
movl 0x28(%rsp), %r11d
subl %r8d, %r11d
movl %r11d, %edi
subl %r9d, %edi
movl %edi, %edx
negl %edx
cmovsl %edi, %edx
movl $0xd, %r9d
movabsq $0xff000000000000, %rdi # imm = 0xFF000000000000
testq %rdi, %r10
jne 0x18e24
cmpl 0x148(%rsp), %edx
jg 0x18e41
cmpl 0x24(%rsp), %r11d
setg %dl
cmpl 0xcc(%rsp), %r11d
setl %dil
orb %dl, %dil
je 0x1904e
movq 0x8(%rsp), %r11
movq 0x10(%rsp), %rdi
testl %r9d, %r9d
jne 0x18d7c
jmp 0x18ef4
movq %rdx, 0x48(%rsp)
movl 0xc(%r15), %r8d
movq 0x78(%rsp), %rdx
movq 0x10(%rdx), %rdx
shrl %esi
shlq $0x6, %rsi
movq %rdx, 0x28(%rsp)
movl (%rdx,%rsi), %edx
movl 0x10(%r12), %esi
movl %edx, %r11d
subl %esi, %r11d
addl %r8d, %r11d
cmpl 0x24(%rsp), %r11d
jle 0x18e9c
xorl %ecx, %ecx
jmp 0x18ee7
movq 0x10(%rsp), %rdi
jmp 0x18d7c
movabsq $0xff000000000000, %rdi # imm = 0xFF000000000000
testq %rdi, %r10
jne 0x18ebc
subl 0x148(%rsp), %r11d
cmpl %r9d, %r11d
jle 0x18ebc
xorl %ecx, %ecx
jmp 0x18ee2
movq 0x48(%rsp), %rdi
shrl %edi
shlq $0x6, %rdi
addl %r8d, %ecx
addl %edx, %ecx
subl %ecx, %eax
addl %esi, %eax
movq 0x28(%rsp), %rcx
addl (%rcx,%rdi), %eax
setns %cl
movl %eax, 0x94(%rsp)
movq 0x10(%rsp), %rdi
testb %cl, %cl
movq 0x8(%rsp), %r11
je 0x18d7c
movl 0x64(%rsp), %eax
movl 0x50(%rsp), %ecx
cmpl %eax, %ecx
jne 0x18f44
movl %eax, %ebx
sarl %ebx
addl %eax, %ebx
cmpl $0x4, %eax
movl $0x10, %eax
cmovll %eax, %ebx
movslq %ebx, %rax
shlq $0x2, %rax
leaq (%rax,%rax,8), %rdx
movq 0x68(%rsp), %rdi
movq %r13, %rsi
callq 0x32c4
movl 0x50(%rsp), %ecx
movss 0x34(%rsp), %xmm2
movq 0x8(%rsp), %r11
movq %rax, %r13
movl %ebx, 0x64(%rsp)
movq 0x18(%rsp), %rbx
movslq %ecx, %rax
incl %ecx
movl %ecx, 0x50(%rsp)
leaq (%rax,%rax,8), %rax
xorl %edi, %edi
movl %edi, 0x20(%r13,%rax,4)
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%r13,%rax,4)
movups %xmm0, (%r13,%rax,4)
movl 0x8(%r15), %edx
xorl %ecx, %ecx
cmpl 0x8(%r12), %edx
sete %cl
shll $0x1f, %ecx
movl 0xc(%r13,%rax,4), %edx
movl $0x7fffffff, %esi       # imm = 0x7FFFFFFF
andl %esi, %edx
orl %ecx, %edx
movl %edx, 0xc(%r13,%rax,4)
movl 0x8(%r12), %esi
xorl $0x1, %esi
movl %esi, (%r13,%rax,4)
movl %r14d, %esi
andl $0x3fffffff, %esi       # imm = 0x3FFFFFFF
andl $0xc0000000, %edx       # imm = 0xC0000000
orl %esi, %edx
movl %edx, 0xc(%r13,%rax,4)
movl 0x14(%r15), %edx
subl 0x18(%r12), %edx
movl %edx, 0x10(%r13,%rax,4)
movl 0x94(%rsp), %edx
movl %edx, 0x4(%r13,%rax,4)
movl %edi, 0x8(%r13,%rax,4)
orl %ecx, %esi
movl %esi, 0xc(%r13,%rax,4)
movq 0xa0(%rsp), %rax
movl (%rax,%r14,4), %eax
cmpq %rax, 0xb0(%rsp)
jne 0x1900d
movq 0x80(%rsp), %rcx
leal 0x1(%rcx), %eax
cmpl 0x150(%rsp), %ecx
movq 0x10(%rsp), %rdi
jge 0x1903f
movq %rax, 0x80(%rsp)
jmp 0x19012
movq 0x10(%rsp), %rdi
movq 0xa8(%rsp), %rax
movq (%rax,%r14,8), %rax
testq %rax, %rax
js 0x18d7c
movq 0xa0(%rsp), %rcx
movq 0xb0(%rsp), %rdx
movl %edx, (%rcx,%rax,4)
jmp 0x18d7c
xorl %ebp, %ebp
movq %rax, 0x80(%rsp)
jmp 0x18d7c
movl %r8d, %edx
subl 0x28(%rsp), %edx
movq 0x8(%rsp), %r11
movq 0x10(%rsp), %rdi
jle 0x190b1
cvtsi2ss %edx, %xmm0
movl %r8d, %edx
subl 0x5c(%rsp), %edx
xorps %xmm1, %xmm1
cvtsi2ss %edx, %xmm1
mulss %xmm2, %xmm1
ucomiss %xmm1, %xmm0
jbe 0x19080
xorl %edi, %edi
jmp 0x190a3
movl 0xc0(%rsp), %edx
subl 0x28(%rsp), %edx
xorps %xmm1, %xmm1
cvtsi2ss %edx, %xmm1
mulss %xmm2, %xmm1
xorl %edi, %edi
ucomiss %xmm1, %xmm0
ja 0x190a3
movb $0x1, %dil
xorl %r9d, %r9d
testb %dil, %dil
movq 0x10(%rsp), %rdi
je 0x18e4b
movq 0x78(%rsp), %rdx
movq 0x10(%rdx), %rdx
shrl %esi
shlq $0x6, %rsi
movl %r8d, %r9d
movq 0x48(%rsp), %r8
shrl %r8d
shlq $0x6, %r8
addl 0x28(%rsp), %ecx
addl %r9d, %eax
addl (%rdx,%rsi), %ecx
subl %ecx, %eax
addl (%rdx,%r8), %eax
xorl %r9d, %r9d
movl %eax, 0x94(%rsp)
jmp 0x18e4b
movl $0x0, 0x50(%rsp)
movl 0x8(%r15), %eax
movl %eax, %edx
xorl $0x1, %edx
movq 0x78(%rsp), %rsi
movq 0x10(%rsi), %rcx
shrl %eax
shlq $0x6, %rax
movl (%rcx,%rax), %r9d
addl 0x24(%rsp), %r9d
subl 0xc(%r15), %r9d
movq 0x68(%rsp), %rdi
movl 0x50(%rsp), %ebp
movl %ebp, %ecx
movq %r13, %r8
pushq $0x0
pushq $0xf
callq 0x10beb
movl %ebp, %eax
movq 0x18(%rsp), %r11
addq $0x10, %rsp
testl %ebp, %ebp
movss 0x60(%rsp), %xmm4
movq 0xb8(%rsp), %rbp
movsd 0x102eb(%rip), %xmm5    # 0x29440
movss 0x10077(%rip), %xmm6    # 0x291d4
movss 0x10073(%rip), %xmm7    # 0x291d8
movss 0x1006e(%rip), %xmm8    # 0x291dc
movq 0xb0(%rsp), %r14
jle 0x19337
movl %eax, %eax
shlq $0x2, %rax
leaq (%rax,%rax,8), %rax
xorl %ecx, %ecx
movl $0x0, 0x40(%rsp)
movl 0x14(%r13,%rcx), %edx
testl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
je 0x1932a
movslq (%r15), %rdi
shlq $0x4, %rdi
movl 0xc(%r13,%rcx), %esi
movl 0x1c(%r13,%rcx), %r10d
subl 0x4(%r13,%rcx), %r10d
andl $0x3fffffff, %esi       # imm = 0x3FFFFFFF
movslq 0x4(%r11,%rsi,8), %r8
leaq (%r8,%r8,4), %r9
movslq (%rbx,%r9,8), %r8
movl 0x4(%rbx,%r9,8), %r11d
shlq $0x21, %r11
sarq $0x21, %r11
addq %r8, %r11
shlq $0x4, %r11
movl %r10d, %r8d
negl %r8d
cmovsl %r10d, %r8d
movq 0x88(%rsp), %r10
movq (%r10,%r11), %r10
movq 0x160(%rsp), %r11
xorq 0x8(%r11,%rdi), %r10
movabsq $0xff000000000000, %rdi # imm = 0xFF000000000000
testq %rdi, %r10
jne 0x19223
movl $0x80000000, %edi       # imm = 0x80000000
cmpl 0x148(%rsp), %r8d
jg 0x192e2
leaq (%rbx,%r9,8), %rdi
movl 0x18(%rdi), %r9d
movl 0x14(%r15), %edi
cmpl %edi, %r9d
jle 0x1926c
movl 0x18(%r15), %r10d
movl %r10d, %r11d
subl %r9d, %r11d
xorps %xmm0, %xmm0
cvtsi2sd %r11d, %xmm0
subl %edi, %r10d
xorps %xmm1, %xmm1
cvtsi2sd %r10d, %xmm1
divsd %xmm1, %xmm0
xorps %xmm1, %xmm1
cvtsi2sdl 0x1c(%r15), %xmm1
mulsd %xmm0, %xmm1
addsd %xmm5, %xmm1
cvttsd2si %xmm1, %edi
jmp 0x19270
movl 0x1c(%r15), %edi
xorps %xmm0, %xmm0
cvtsi2ss %r8d, %xmm0
xorps %xmm1, %xmm1
cmpl $0x2, %r8d
jb 0x192c2
movd %xmm0, %r8d
movl %r8d, %r9d
shrl $0x17, %r9d
addl $-0x80, %r9d
cvtsi2ss %r9, %xmm2
andl $0x7fffff, %r8d         # imm = 0x7FFFFF
orl $0x3f800000, %r8d       # imm = 0x3F800000
movd %r8d, %xmm3
movdqa %xmm3, %xmm1
mulss %xmm6, %xmm1
addss %xmm7, %xmm1
mulss %xmm3, %xmm1
addss %xmm8, %xmm1
addss %xmm2, %xmm1
sarl $0x1f, %edx
andl 0x158(%rsp), %edx
mulss %xmm4, %xmm0
addss %xmm1, %xmm0
cvttss2si %xmm0, %r8d
addl %edx, %edi
addl (%rbp,%rsi,4), %edi
subl %r8d, %edi
movl %edi, %edx
negl %edx
jno 0x192ef
movq 0x8(%rsp), %r11
jmp 0x1932a
addl 0x1c(%r15), %edi
movq 0x8(%rsp), %r11
js 0x1932a
leaq (%rcx,%r13), %rdx
movl 0x40(%rsp), %edi
movslq %edi, %rsi
incl %edi
movl %edi, 0x40(%rsp)
leaq (%rsi,%rsi,8), %rsi
movl 0x20(%rdx), %edi
movl %edi, 0x20(%r13,%rsi,4)
movups (%rdx), %xmm0
movups 0x10(%rdx), %xmm1
movups %xmm1, 0x10(%r13,%rsi,4)
movups %xmm0, (%r13,%rsi,4)
addq $0x24, %rcx
cmpq %rcx, %rax
jne 0x19190
movl 0x1c(%r15), %eax
movl %eax, 0x48(%rsp)
movl 0x40(%rsp), %eax
testl %eax, %eax
jle 0x196a5
movl %eax, %eax
shlq $0x2, %rax
leaq (%rax,%rax,8), %rax
movq %rax, 0x50(%rsp)
movl $0xffffffff, %r8d       # imm = 0xFFFFFFFF
xorl %r14d, %r14d
xorl %ebx, %ebx
xorl %r9d, %r9d
movl $0xffffffff, 0x28(%rsp) # imm = 0xFFFFFFFF
movq %r15, 0x40(%rsp)
movq %r13, 0x10(%rsp)
movl 0x14(%r13,%r14), %eax
movl %eax, %r10d
movl $0x80000000, %ebp       # imm = 0x80000000
andl $0x7fffffff, %r10d      # imm = 0x7FFFFFFF
je 0x19476
movslq (%r15), %rsi
shlq $0x4, %rsi
movl 0xc(%r13,%r14), %ecx
movl %r8d, %r12d
movl 0x1c(%r13,%r14), %r8d
subl 0x4(%r13,%r14), %r8d
andl $0x3fffffff, %ecx       # imm = 0x3FFFFFFF
movq %r11, %r15
movslq 0x4(%r11,%rcx,8), %rdx
leaq (%rdx,%rdx,4), %rdi
movq 0x18(%rsp), %r13
movslq (%r13,%rdi,8), %rdx
movl %r9d, %r11d
movl 0x4(%r13,%rdi,8), %r9d
shlq $0x21, %r9
sarq $0x21, %r9
addq %rdx, %r9
shlq $0x4, %r9
movl %r8d, %edx
negl %edx
cmovsl %r8d, %edx
movq 0x88(%rsp), %r8
movq (%r8,%r9), %r8
movq 0x160(%rsp), %r9
xorq 0x8(%r9,%rsi), %r8
movl %r11d, %r9d
movabsq $0xff000000000000, %rsi # imm = 0xFF000000000000
testq %rsi, %r8
movl %r12d, %r8d
jne 0x19424
cmpl 0x148(%rsp), %edx
jg 0x194ec
movq 0x18(%rsp), %rsi
leaq (%rsi,%rdi,8), %rsi
movl 0x18(%rsi), %edi
movq 0x40(%rsp), %rbp
movl 0x14(%rbp), %esi
cmpl %esi, %edi
jle 0x1947b
movl 0x18(%rbp), %r8d
movl %r8d, %r9d
subl %edi, %r9d
xorps %xmm0, %xmm0
cvtsi2sd %r9d, %xmm0
movl %r11d, %r9d
subl %esi, %r8d
cvtsi2sd %r8d, %xmm1
movl %r12d, %r8d
divsd %xmm1, %xmm0
xorps %xmm1, %xmm1
cvtsi2sdl 0x1c(%rbp), %xmm1
mulsd %xmm0, %xmm1
addsd %xmm5, %xmm1
cvttsd2si %xmm1, %ebp
jmp 0x1947e
movq %r11, %r15
jmp 0x194ec
movl 0x1c(%rbp), %ebp
xorps %xmm0, %xmm0
cvtsi2ss %edx, %xmm0
xorps %xmm1, %xmm1
cmpl $0x2, %edx
jb 0x194c7
movd %xmm0, %edx
movl %edx, %esi
shrl $0x17, %esi
addl $-0x80, %esi
cvtsi2ss %rsi, %xmm2
andl $0x7fffff, %edx         # imm = 0x7FFFFF
orl $0x3f800000, %edx       # imm = 0x3F800000
movd %edx, %xmm3
movdqa %xmm3, %xmm1
mulss %xmm6, %xmm1
addss %xmm7, %xmm1
mulss %xmm3, %xmm1
addss %xmm8, %xmm1
addss %xmm2, %xmm1
sarl $0x1f, %eax
andl 0x158(%rsp), %eax
mulss %xmm4, %xmm0
addss %xmm1, %xmm0
cvttss2si %xmm0, %edx
addl %eax, %ebp
movq 0xb8(%rsp), %rax
addl (%rax,%rcx,4), %ebp
subl %edx, %ebp
movl %ebp, %eax
negl %eax
jno 0x19501
movq %r15, %r11
movq 0x40(%rsp), %r15
movq 0x10(%rsp), %r13
jmp 0x19543
leaq 0x19170(%rip), %rax     # 0x32678
testb $0x40, (%rax)
movq %r15, %r11
movq 0x40(%rsp), %r15
movq 0x10(%rsp), %r13
jne 0x19557
cmpl 0x48(%rsp), %ebp
jle 0x19543
movl 0xc(%r13,%r14), %r9d
movl 0x1c(%r13,%r14), %r8d
movl %r9d, %eax
andl $0x3fffffff, %eax       # imm = 0x3FFFFFFF
movl %eax, 0x28(%rsp)
movl 0x20(%r13,%r14), %ebx
shrl $0x1f, %r9d
movl %ebp, 0x48(%rsp)
addq $0x24, %r14
cmpq %r14, 0x50(%rsp)
jne 0x1937a
jmp 0x19685
movl 0xc(%r13,%r14), %edx
andl $0x3fffffff, %edx       # imm = 0x3FFFFFFF
movslq 0x4(%r11,%rdx,8), %rax
leaq (%rax,%rax,4), %rax
movq 0x18a86(%rip), %rcx     # 0x31ff8
movq (%rcx), %rdi
movl %r9d, 0x80(%rsp)
movl (%r13,%r14), %r9d
movl 0x4(%r13,%r14), %r12d
movl %r9d, %ecx
andl $0x1, %ecx
leaq 0xf116(%rip), %rsi      # 0x286aa
movsbl (%rcx,%rsi), %ecx
movq 0x78(%rsp), %rsi
movq 0x10(%rsi), %rsi
movl %r8d, 0x5c(%rsp)
movl %r9d, %r8d
shrl %r8d
shlq $0x6, %r8
movq 0x18(%rsi,%r8), %r8
movl 0x8(%r15), %r11d
shrl %r11d
shlq $0x6, %r11
movl (%rsi,%r11), %esi
subl %esi, %r12d
movq %r12, 0xc0(%rsp)
movl 0x1c(%r13,%r14), %r11d
subl %esi, %r11d
movq 0x18(%rsp), %rsi
movl 0x14(%rsi,%rax,8), %r12d
movq %r12, 0x100(%rsp)
movl 0x18(%rsi,%rax,8), %r12d
movq %r12, 0xf8(%rsp)
movl 0xc(%rsi,%rax,8), %esi
movq %rsi, 0xf0(%rsp)
movq 0x18(%rsp), %rsi
movl 0x10(%rsi,%rax,8), %r12d
leaq 0xfe73(%rip), %rsi      # 0x29486
xorl %eax, %eax
pushq %r12
pushq 0xf8(%rsp)
pushq 0x108(%rsp)
pushq 0x118(%rsp)
pushq %rbp
pushq %r11
pushq 0xf0(%rsp)
pushq %r10
callq 0x2210
movl 0xc0(%rsp), %r9d
movl 0x9c(%rsp), %r8d
movss 0xfb86(%rip), %xmm8     # 0x291dc
movss 0xfb7a(%rip), %xmm7     # 0x291d8
movss 0xfb6e(%rip), %xmm6     # 0x291d4
movsd 0xfdd2(%rip), %xmm5     # 0x29440
movss 0xa0(%rsp), %xmm4
movq 0x48(%rsp), %r11
addq $0x40, %rsp
jmp 0x1951a
shll $0x1f, %r9d
movq 0xb8(%rsp), %rbp
movq 0xb0(%rsp), %r14
movl 0x28(%rsp), %eax
movl %r8d, %edx
movl %r9d, %esi
jmp 0x196b3
xorl %esi, %esi
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
xorl %ebx, %ebx
movl 0x48(%rsp), %r8d
movl %r8d, (%rbp,%r14,4)
movl %eax, %r9d
cltq
movq 0xa8(%rsp), %rcx
movq %rax, (%rcx,%r14,8)
movl %edx, 0x20(%r15)
movl %ebx, 0x24(%r15)
movl 0x4(%r15), %ecx
movl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
andl %edx, %ecx
orl %esi, %ecx
movl %ecx, 0x4(%r15)
testl %eax, %eax
movss 0x34(%rsp), %xmm2
js 0x196fe
movq 0x70(%rsp), %rcx
movl (%rcx,%rax,4), %eax
cmpl %r8d, %eax
jg 0x19701
movl %r8d, %eax
movq 0x70(%rsp), %rcx
movl %eax, (%rcx,%r14,4)
leaq 0x18f67(%rip), %rax     # 0x32678
testb $0x40, (%rax)
movl 0x64(%rsp), %r15d
movq 0x18(%rsp), %rbx
jne 0x19733
incq %r14
cmpq 0x98(%rsp), %r14
jne 0x18c0f
jmp 0x19760
movq 0x188be(%rip), %rax     # 0x31ff8
movq (%rax), %rdi
movl 0x4(%r11,%r14,8), %edx
leaq 0xfda3(%rip), %rsi      # 0x294ec
movl %r9d, %ecx
xorl %eax, %eax
callq 0x2210
movss 0x34(%rsp), %xmm2
movq 0x8(%rsp), %r11
jmp 0x19720
movq 0x68(%rsp), %r14
movq %r14, %rdi
movq %r13, %rsi
callq 0x30f6
movq %r14, %rdi
movq 0xe0(%rsp), %rsi
callq 0x30f6
movss 0x60(%rsp), %xmm0
leaq 0x18eeb(%rip), %rax     # 0x32678
testb $0x40, (%rax)
je 0x19836
xorl %ecx, %ecx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
xorl %edx, %edx
movq 0x98(%rsp), %rdi
movl (%rbp,%rcx,4), %esi
cmpl %edx, %esi
cmovgl %esi, %edx
cmovgl %ecx, %eax
incq %rcx
cmpq %rcx, %rdi
jne 0x197a7
testl %eax, %eax
js 0x19836
cvtss2sd %xmm0, %xmm0
movsd %xmm0, 0x88(%rsp)
leaq 0xfd35(%rip), %r14      # 0x29508
movq 0x1881e(%rip), %rcx     # 0x31ff8
movq (%rcx), %rdi
movl %eax, %ebx
movq 0x8(%rsp), %rax
movslq 0x4(%rax,%rbx,8), %rdx
movq 0x78(%rsp), %rax
movq 0x10(%rax), %rax
leaq (%rdx,%rdx,4), %rcx
movq 0x18(%rsp), %rsi
movl 0x8(%rsi,%rcx,8), %ecx
shrl %ecx
shlq $0x6, %rcx
movq 0x18(%rax,%rcx), %rcx
movl (%rbp,%rbx,4), %r8d
movq %r14, %rsi
movsd 0x88(%rsp), %xmm0
movb $0x1, %al
callq 0x2210
movq 0xa8(%rsp), %rax
movl (%rax,%rbx,8), %eax
movq 0x18(%rsp), %rbx
testl %eax, %eax
jns 0x197d3
leaq 0x38(%rsp), %rax
leaq 0x3c(%rsp), %r10
movq %rbp, %rdx
movq 0xe8(%rsp), %rbp
movl %ebp, %r11d
subl 0x90(%rsp), %r11d
xorl %r12d, %r12d
movq 0x68(%rsp), %r15
movq %r15, %rdi
movq 0x98(%rsp), %rsi
movq 0xa8(%rsp), %r13
movq %r13, %rcx
movq 0x70(%rsp), %r8
movq 0xa0(%rsp), %r9
pushq %rax
pushq %r10
pushq %r11
pushq $0x7fffffff             # imm = 0x7FFFFFFF
pushq %r12
pushq %r12
callq 0x15cbc
addq $0x30, %rsp
movq %rax, %r14
movq %r15, %rdi
movq 0xb8(%rsp), %rsi
callq 0x30f6
movq %r15, %rdi
movq %r13, %rsi
callq 0x30f6
movq %r15, %rdi
movq 0xa0(%rsp), %rsi
callq 0x30f6
movq 0x98(%rsp), %r8
movq 0x70(%rsp), %r13
subl 0x90(%rsp), %ebp
movq 0x8(%rsp), %rdi
jle 0x19920
movl %ebp, %eax
movslq 0x4(%rdi,%r8,8), %rcx
leaq (%rcx,%rcx,4), %rcx
movl 0x1c(%rbx,%rcx,8), %ecx
shlq $0x20, %rcx
incq %rcx
movslq 0x3c(%rsp), %rdx
leal 0x1(%rdx), %esi
movl %esi, 0x3c(%rsp)
movq %rcx, (%r14,%rdx,8)
movslq 0x38(%rsp), %rcx
leal 0x1(%rcx), %edx
movl %edx, 0x38(%rsp)
movl %r8d, (%r13,%rcx,4)
incq %r8
decq %rax
jne 0x198e3
movslq 0x38(%rsp), %rax
shlq $0x3, %rax
leaq (%rax,%rax,4), %rsi
movq 0x68(%rsp), %rdi
callq 0x31c1
movq 0x70(%rsp), %r11
movq 0x8(%rsp), %r10
movq %rax, %r15
movslq 0x3c(%rsp), %rax
testq %rax, %rax
jle 0x199b7
xorl %ecx, %ecx
xorl %r12d, %r12d
movq (%r14,%rcx,8), %rdi
testl %edi, %edi
jle 0x199af
movslq %r12d, %r8
movl %edi, %edx
andl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
leaq (%r8,%r8,4), %rsi
leaq (%r15,%rsi,8), %rsi
addl %r8d, %edi
decl %edi
movl %edx, %r12d
addl %r8d, %r12d
movslq %edi, %rdi
movslq (%r11,%rdi,4), %r8
movslq 0x4(%r10,%r8,8), %r8
leaq (%r8,%r8,4), %r8
movq 0x20(%rbx,%r8,8), %r9
movq %r9, 0x20(%rsi)
movups (%rbx,%r8,8), %xmm0
movups 0x10(%rbx,%r8,8), %xmm1
movups %xmm1, 0x10(%rsi)
movups %xmm0, (%rsi)
addq $0x28, %rsi
decl %edi
decq %rdx
jne 0x19979
incq %rcx
cmpq %rax, %rcx
jne 0x19953
movl 0x38(%rsp), %ebp
cmpl %ebp, %r12d
jne 0x19a52
movslq %ebp, %rax
shlq $0x3, %rax
leaq (%rax,%rax,4), %rdx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x2230
movq 0xd8(%rsp), %rax
movl %ebp, (%rax)
movq 0x168(%rsp), %rax
movq %r14, (%rax)
movq 0x68(%rsp), %rbx
movq %rbx, %rdi
movq 0x8(%rsp), %rsi
callq 0x30f6
movq %rbx, %rdi
movq %r15, %rsi
callq 0x30f6
movq %rbx, %rdi
movq 0x70(%rsp), %rsi
callq 0x30f6
movl 0x3c(%rsp), %r13d
movl %r13d, %eax
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xfd43(%rip), %rdi      # 0x2977d
leaq 0xfa07(%rip), %rsi      # 0x29448
leaq 0xfd3c(%rip), %rcx      # 0x29784
movl $0x1b, %edx
callq 0x2160
leaq 0xfade(%rip), %rdi      # 0x29537
leaq 0xf9e8(%rip), %rsi      # 0x29448
leaq 0xfad9(%rip), %rcx      # 0x29540
movl $0xe7, %edx
callq 0x2160