// File: /workspace/github_cpp_makefile_star2_O2/chhylp123[P]hifiasm/inter.cpp
// Function: gl_chain_graph(void*, ul_idx_t const*, ma_ug_t const*, vec_mg_lchain_t*, vec_mg_lchain_t*, vec_mg_path_dst_t*, vec_sp_node_t*, vec_mg_pathv_t*, long, ug_opt_t const*, long, double, double, unsigned long*, st_mt_t*, Chain_Data*, long, long, long, long)
int64_t gl_chain_graph(void *km, const ul_idx_t *uref, const ma_ug_t *ug, vec_mg_lchain_t *lc, 
vec_mg_lchain_t *sw, vec_mg_path_dst_t *dst, vec_sp_node_t *out, vec_mg_pathv_t *path,
int64_t qlen, const ug_opt_t *uopt, int64_t bw, double diff_thre, double ng_diff_thre, uint64_t *srt, 
st_mt_t *bf, Chain_Data* dp, int64_t max_skip, int64_t max_iter, int64_t max_dis, int64_t need_srt)
{
	bf->n = 0;
    if(lc->n == 0) return 0;
	int64_t i, j, lc_n = lc->n, n_ext, mm_ovlp, target_dist, max_target_dist, x, m_idx, m_sc, qo, sc; 
    int64_t max_f, max_j = -1, max_d = -1, max_inner = 0; uint32_t max_hash = 0; int64_t k, k0, n_u, n_v, ni;
    mg_lchain_t *r, *li, *lj; mg_path_dst_t *q; asg_t *g = ug->g; uint64_t isolated, *u, ff; ul_ov_t ui, uj;
	if(!need_srt) {
		for (i = n_ext = 0; i < lc_n; i++) {
			r = &lc->a[i]; r->dist_pre = -1; isolated = 0;///dist_pre -> parent in graph chain
			if((r->re < g->seq[r->v>>1].len) && (r->rs > 0)) isolated = 1;///UL contained in one vertice
			if (!isolated) {
				srt[n_ext] = r->qe; srt[n_ext] <<= 32; 
				srt[n_ext] |= (uint64_t)i; srt[n_ext] |= (isolated<<63);
				++n_ext;
			}
		}
		j = n_ext;
		if(j < lc_n) {
			for (i = 0; i < lc_n; i++) {
				r = &lc->a[i]; r->dist_pre = -1; isolated = 0;///dist_pre -> parent in graph chain
				if((r->re < g->seq[r->v>>1].len) && (r->rs > 0)) isolated = 1;///UL contained in one vertice
				if (isolated) {
					srt[j] = r->qe; srt[j] <<= 32; srt[j] |= (uint64_t)i; srt[j] |= (isolated<<63); ++j;
				}
			}
		}
		assert(j == lc_n);
	} else {
		for (i = n_ext = 0; i < lc_n; i++) {
			r = &lc->a[i]; r->dist_pre = -1; isolated = 0;///dist_pre -> parent in graph chain
			if((r->re < g->seq[r->v>>1].len) && (r->rs > 0)) isolated = 1;///UL contained in one vertice
			if (!isolated) ++n_ext;
			srt[i] = r->qe; srt[i] <<= 32; srt[i] |= (uint64_t)i; srt[i] |= (isolated<<63);
		}
		radix_sort_gfa64(srt, srt+lc_n); 
		for (i = 1, j = 0; i <= lc_n; i++) {
			if (i == lc_n || (srt[i]>>32) != (srt[j]>>32)) {
				if(i - j > 1) {
					for (x = j; x < i; x++) {
						srt[x] <<= 32; srt[x] >>= 32; srt[x] |= ((uint64_t)lc->a[(uint32_t)srt[x]].qs)<<32;
					}
					radix_sort_gfa64(srt+j, srt+i);
				}
				j = i;
			}
		}
	}
	if((n_ext != lc_n) || (need_srt)) {
		kv_resize(mg_lchain_t, *sw, (uint64_t)lc_n); sw->n = lc_n;
		for (i = 0; i < lc_n; i++) sw->a[i] = lc->a[(uint32_t)srt[i]];
		memcpy(lc->a, sw->a, lc_n *sizeof((*(lc->a))));
	}

	resize_Chain_Data(dp, lc_n, NULL);
	int32_t *p; int64_t *f, *t, n_skip, dst_n, is_f, plus, n_v0; mg_path_dst_t *dj;
	t = dp->tmp; p = dp->score; f = dp->pre;
	if(ng_diff_thre >= 0) {
		m_idx = gl_chain_linear(uref, ug, lc, sw, qlen, uopt, bw, ng_diff_thre, bf, 
			max_skip, max_iter, max_dis, p, f, t, n_ext, -1);
		if(diff_thre < 0) return m_idx;
		if(m_idx >= 0 && primary_chain_check(bf->a, bf->n, lc->a)) return m_idx;
		else m_idx = -1;
		// if(m_idx >= 0) return m_idx;
		bf->n = 0;
	}

	memset(t, 0, (n_ext*sizeof((*t))));
	for (i = plus = 0; i < n_ext; ++i) { // core loop
        li = &lc->a[i]; set_ul_ov_t_by_mg_lchain_t(&ui, li);
        mm_ovlp = max_ovlp(g, li->v^1);
        x = (li->qs + mm_ovlp)*diff_thre; if(x < bw) x = bw; 
        x += li->qs + mm_ovlp;
        if (x > qlen+1) x = qlen+1;
        x = find_mg_lchain_max(i, lc->a, x+G_CHAIN_INDEL);

		n_skip = 0; is_f = 0;
        // collect potential destination vertices
        for (dst->n = 0, max_target_dist = -1, j = x; j >= 0; --j) { 
            lj = &lc->a[j]; ///extend_end_coord(lj, qlen, g->seq[lj->v>>1].len, &jqs, &jqe, &jrs, &jre);
            //lj contained in li; actually in circle, this might happen; need to deal with it later
            if(lj->qs >= li->qs/**+G_CHAIN_INDEL**/) continue;
            ///if there is a circle, the two linear chains might be at the same vertice
            target_dist = hc_target_len(g, li, lj);
            if(target_dist < 0) continue;
            kv_pushp(mg_path_dst_t, *dst, &q);
            memset(q, 0, sizeof(*q));
            q->inner = 0;//we set q->inner = 0 to allow circles
            q->v = lj->v^1;///must be v^1 instead of v
            q->meta = j;
            ///lj->qs************lj->qe
            ///         li->qs************li->qe
            q->qlen = li->qs - lj->qe;///might be negative; this is the region that need to be checked in base-level
            q->target_dist = target_dist;///cannot understand the target_dist
            q->target_hash = 0;
            q->check_hash = 0;
            if(max_target_dist < target_dist) max_target_dist = target_dist;
			if (t[j] == i) {
				if (++n_skip > max_skip)
					break;
			}
			if (p[j] >= 0) t[p[j]] = i;
			if((!is_f) && (lj->qe+G_CHAIN_INDEL > li->qs)) {
				set_ul_ov_t_by_mg_lchain_t(&uj, lj);
                qo = infer_rovlp(&ui, &uj, NULL, NULL, NULL, (ma_ug_t *)ug);
				if(/**li->v!=lj->v &&**/ get_ecov_adv(uref, uopt, li->v^1, lj->v^1, bw, N_GCHAIN_RATE, qo, 0, NULL)) {
					is_f = 1; if(n_skip > 0) n_skip--; 
					if(n_skip < (max_skip>>1)) n_skip= (max_skip>>1);
				}
			}
        }

        // confirm reach-ability
        max_f = li->score, max_j = -1, max_d = -1, max_inner = 0; max_hash = 0;
        if(dst->n) {
            max_target_dist *= (1+diff_thre); if(max_target_dist < bw) max_target_dist = bw;
            hc_shortest_k(km, g, li->v^1, dst->n, dst->a, max_target_dist, MG_MAX_SHORT_K, bf, srt, out, NULL, 1, 0, 0);
            // remove unreachable destinations
            //TODO: check sequence identity
			dst_n = dst->n;
            for (j = 0; j < dst_n; ++j) {
                dj = &dst->a[j];
                if (dj->n_path == 0) continue; // unreachable
                sc = cal_gchain_sc(dj, li, lc->a, f, bw, diff_thre, W_CHN_PEN_GAP);     

                if (sc == INT32_MIN) continue; // out of band
                // if (sc < 0) continue;// negative score
                if (sc > max_f) {
                    max_f = sc, max_j = dj->meta, max_d = dj->dist, max_hash = dj->hash, max_inner = dj->inner;
                }
            }
        }
		if(max_f < 0) {
            max_f = li->score; max_j = -1; 
        }

        f[i] = max_f; p[i] = max_j;
        ///same time for gchain
        li->dist_pre = max_d;
        li->hash_pre = max_hash;
        li->inner_pre = max_inner;
		if(max_f < plus) plus = max_f;//minmun negative
    }

	for (; i < lc_n; i++) {
		li = &lc->a[i];
		max_f = li->score, max_j = -1, max_d = -1, max_inner = 0; max_hash = 0;
		f[i] = max_f; p[i] = max_j;
        ///same time for gchain
        li->dist_pre = max_d;
        li->hash_pre = max_hash;
        li->inner_pre = max_inner;
		if(max_f < plus) plus = max_f;//minmun negative
	}
	
	for (i = 0; i < lc_n; ++i) {
		f[i]-=plus; t[i] = f[i]<<32; t[i] += (i<<1);
	}

	sw->n = 0; kv_resize(mg_lchain_t, *sw, (uint64_t)lc_n);
	kv_resize(uint64_t, *bf, (uint64_t)lc_n); u = bf->a;
	n_u = n_v = 0; radix_sort_gfa64i(t, t + lc_n); plus = 0;
	for (k = lc_n-1, n_v = n_u = 0; k >= 0; --k) {
        n_v0 = n_v;
        for (i = ((uint32_t)t[k])>>1; i >= 0 && (t[i]&1) == 0; ) {
            sw->a[n_v++] = lc->a[i]; t[i] |= 1; i = p[i];
        }
        if(n_v0 == n_v) continue;
        sc = (i<0?(t[k]>>32):((t[k]>>32)-f[i]));
		if(sc < plus) plus = sc;
		if(sc >= 0) {
			ff = ((uint64_t)(0x8000000000000000));
		} else {
			ff = 0; sc = -sc;
		}
		u[n_u++] = (((uint64_t)sc)<<32)|((uint64_t)(n_v-n_v0))|ff;
    }
	
	m_idx = m_sc = -1; 
	for (i = 0, k = 0; i < n_u; ++i) {
		if((u[i]&((uint64_t)(0x8000000000000000)))) {
			u[i] -= ((uint64_t)(0x8000000000000000)); sc = u[i]>>32;
		} else {
			sc = u[i]>>32; sc = -sc; 
		}
		sc -= plus; u[i] <<= 32; u[i] >>= 32; u[i] |= (((uint64_t)sc)<<32);

        k0 = k, ni = (uint32_t)u[i];
        for (j = 0; j < ni; ++j) {
            lc->a[k++] = sw->a[k0 + (ni - j - 1)];
        }
        if(m_idx < 0 || m_sc < ((int64_t)(u[i]>>32))) {
            m_idx = i; m_sc = ((int64_t)(u[i]>>32));
        }
    }
    assert(k == n_v); bf->n = n_u;
	return m_idx;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xe8, %rsp
movsd %xmm1, 0x48(%rsp)
movsd %xmm0, 0x50(%rsp)
movq %r9, 0x20(%rsp)
movq 0x150(%rsp), %rax
andq $0x0, (%rax)
movq %rsi, 0x80(%rsp)
movq %rdi, 0x98(%rsp)
movq %rcx, (%rsp)
movq 0x8(%rcx), %r14
testq %r14, %r14
je 0x16cca3
movq %r8, %rbp
movq 0x178(%rsp), %r15
movq 0x148(%rsp), %rdi
movq %rdx, 0x78(%rsp)
movq 0x18(%rdx), %rax
movq %rax, 0x30(%rsp)
xorl %ebx, %ebx
testq %r14, %r14
cmovgq %r14, %rbx
testq %r15, %r15
movq %r14, 0x58(%rsp)
je 0x16ccaa
pushq $0x4
popq %rax
xorl %ecx, %ecx
movl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
pushq $0x1
popq %rsi
xorl %r12d, %r12d
xorl %r11d, %r11d
cmpq %r11, %rbx
je 0x16cc0c
movq (%rsp), %r8
movq (%r8), %r8
orl $-0x1, (%r8,%rax,8)
movl -0x18(%r8,%rax,8), %r9d
movq 0x30(%rsp), %rdi
movq 0x20(%rdi), %r10
shrl %r9d
movl (%r10,%r9,8), %r9d
andl %edx, %r9d
cmpl %r9d, -0x10(%r8,%rax,8)
jge 0x16cbdf
xorl %r10d, %r10d
cmpl $0x0, -0x14(%r8,%rax,8)
setle %r10b
movabsq $-0x8000000000000000, %r9 # imm = 0x8000000000000000
cmovleq %rcx, %r9
jmp 0x16cbe5
movq %rsi, %r10
xorl %r9d, %r9d
addq %r10, %r12
movl -0x8(%r8,%rax,8), %r8d
shlq $0x20, %r8
orq %r11, %r9
orq %r8, %r9
movq 0x148(%rsp), %rdi
movq %r9, (%rdi,%r11,8)
incq %r11
addq $0x5, %rax
jmp 0x16cb92
leaq (%rdi,%r14,8), %rsi
callq 0x156b0d
incq %rbx
pushq $0x1
popq %r14
xorl %eax, %eax
cmpq %rbx, %r14
je 0x16cc99
cmpq 0x58(%rsp), %r14
movq 0x148(%rsp), %rdx
je 0x16cc45
movq (%rdx,%rax,8), %rcx
xorq (%rdx,%r14,8), %rcx
shrq $0x20, %rcx
jne 0x16cc45
movq %rax, %rcx
jmp 0x16cc91
movq %r14, %rdx
subq %rax, %rdx
movq %r14, %rcx
cmpq $0x2, %rdx
jl 0x16cc91
movq %rax, %rcx
movq 0x148(%rsp), %r8
cmpq %r14, %rcx
jge 0x16cc81
movl (%r8,%rcx,8), %edx
movq (%rsp), %rsi
movq (%rsi), %rsi
imulq $0x28, %rdx, %rdx
movl 0x14(%rsi,%rdx), %edx
movl %edx, 0x4(%r8,%rcx,8)
incq %rcx
jmp 0x16cc5f
leaq (%r8,%rax,8), %rdi
leaq (%r8,%r14,8), %rsi
callq 0x156b0d
movq %r14, %rcx
incq %r14
movq %rcx, %rax
jmp 0x16cc1e
movq 0x58(%rsp), %r14
jmp 0x16cd8f
xorl %ebx, %ebx
jmp 0x16d7a4
pushq $0x20
popq %rax
xorl %r12d, %r12d
movl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
xorl %edx, %edx
cmpq %rdx, %rbx
je 0x16cd08
movq (%rsp), %rsi
movq (%rsi), %rsi
orl $-0x1, (%rsi,%rax)
movl -0x18(%rsi,%rax), %r9d
movq 0x30(%rsp), %r8
movq 0x20(%r8), %r8
shrl %r9d
movl (%r8,%r9,8), %r8d
andl %ecx, %r8d
cmpl %r8d, -0x10(%rsi,%rax)
jge 0x16cced
cmpl $0x0, -0x14(%rsi,%rax)
jg 0x16ccff
movl -0x8(%rsi,%rax), %esi
shlq $0x20, %rsi
orq %rdx, %rsi
movq %rsi, (%rdi,%r12,8)
incq %r12
incq %rdx
addq $0x28, %rax
jmp 0x16ccb7
movq %r12, %rax
cmpq %r14, %r12
jge 0x16cd86
pushq $0x20
popq %rcx
xorl %edx, %edx
movl $0x7fffffff, %esi       # imm = 0x7FFFFFFF
movq %r12, %rax
cmpq %rdx, %rbx
je 0x16cd86
movq (%rsp), %rdi
movq (%rdi), %rdi
orl $-0x1, (%rdi,%rcx)
movl -0x18(%rdi,%rcx), %r8d
movq 0x30(%rsp), %r9
movq 0x20(%r9), %r9
shrl %r8d
movl (%r9,%r8,8), %r8d
andl %esi, %r8d
cmpl %r8d, -0x10(%rdi,%rcx)
jge 0x16cd7d
cmpl $0x0, -0x14(%rdi,%rcx)
jle 0x16cd7d
movl -0x8(%rdi,%rcx), %edi
shlq $0x20, %rdi
movq %rdx, %r8
movabsq $-0x8000000000000000, %r9 # imm = 0x8000000000000000
orq %r9, %r8
orq %rdi, %r8
movq 0x148(%rsp), %rdi
movq %r8, (%rdi,%rax,8)
incq %rax
incq %rdx
addq $0x28, %rcx
jmp 0x16cd1d
cmpq %r14, %rax
jne 0x16d7d8
movq 0x158(%rsp), %r13
testq %r15, %r15
jne 0x16cda5
cmpq %r14, %r12
je 0x16ce63
cmpq %r14, 0x10(%rbp)
jae 0x16cdf8
leaq -0x1(%r14), %rax
movq %rax, %rcx
shrq %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x2, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x4, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x8, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x10, %rcx
orq %rax, %rcx
incq %rcx
movq %rcx, 0x10(%rbp)
movq (%rbp), %rdi
imulq $0x28, %rcx, %rsi
callq 0x2370
movq %rax, (%rbp)
movq %r14, 0x8(%rbp)
xorl %eax, %eax
testq %r14, %r14
movl $0x0, %ecx
cmovgq %r14, %rcx
xorl %edx, %edx
movq (%rsp), %rsi
movq (%rsi), %rdi
cmpq %rdx, %rcx
movq 0x148(%rsp), %rsi
je 0x16ce56
movl (%rsi,%rdx,8), %esi
imulq $0x28, %rsi, %rsi
movq (%rbp), %r8
movq 0x20(%rdi,%rsi), %r9
movq %r9, 0x20(%r8,%rax)
movupd (%rdi,%rsi), %xmm0
movupd 0x10(%rdi,%rsi), %xmm1
movupd %xmm1, 0x10(%r8,%rax)
movupd %xmm0, (%r8,%rax)
incq %rdx
addq $0x28, %rax
jmp 0x16ce0c
movq (%rbp), %rsi
imulq $0x28, %r14, %rdx
callq 0x2160
movq %r12, 0x40(%rsp)
movq 0x160(%rsp), %r12
movq 0x130(%rsp), %rbx
movq %r13, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x1383e
movq 0x28(%r13), %r15
movq (%r13), %rax
movq %rax, 0x38(%rsp)
movq 0x8(%r13), %rax
movq %r12, %r13
movq %rax, 0x28(%rsp)
xorpd %xmm1, %xmm1
movsd 0x48(%rsp), %xmm0
ucomisd %xmm1, %xmm0
jb 0x16cf66
subq $0x8, %rsp
movq 0x88(%rsp), %rdi
movq 0x80(%rsp), %rsi
movq 0x8(%rsp), %rdx
movq %rbp, %rcx
movq %rbx, %r8
movq 0x140(%rsp), %r9
pushq 0x48(%rsp)
pushq %r15
pushq 0x40(%rsp)
pushq 0x58(%rsp)
pushq 0x198(%rsp)
pushq 0x198(%rsp)
pushq %r13
pushq 0x190(%rsp)
pushq 0x188(%rsp)
callq 0x16c201
addq $0x50, %rsp
movq %rax, %rbx
xorpd %xmm0, %xmm0
ucomisd 0x50(%rsp), %xmm0
ja 0x16d7a4
testq %rbx, %rbx
js 0x16cf4a
movq 0x150(%rsp), %rax
movq (%rax), %rsi
movq 0x10(%rax), %rdi
movq (%rsp), %rax
movq (%rax), %rdx
callq 0x16c091
testq %rax, %rax
jne 0x16d7a4
movq 0x150(%rsp), %rax
andq $0x0, (%rax)
movq 0x160(%rsp), %r13
movq 0x130(%rsp), %rbx
movq 0x40(%rsp), %r12
leaq (,%r12,8), %rdx
movq %r15, %rdi
xorl %esi, %esi
callq 0x20e0
incq %rbx
sarq %r13
movq %r13, 0xa0(%rsp)
movq %r12, %r8
movsd 0x7630a(%rip), %xmm1    # 0x1e32a0
movsd 0x50(%rsp), %xmm0
addsd %xmm0, %xmm1
movsd %xmm1, 0x90(%rsp)
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x74(%rsp)
testq %r12, %r12
movl $0x0, %eax
movq %rax, 0x60(%rsp)
movl $0x0, %eax
cmovleq %rax, %r8
xorl %r12d, %r12d
movq %rbp, 0x48(%rsp)
movq %r15, 0x68(%rsp)
movq %r8, 0x40(%rsp)
movq %rbx, 0xa8(%rsp)
cmpq %r8, %r12
je 0x16d497
movq %rbx, %r15
movq (%rsp), %rax
movq (%rax), %rbx
imulq $0x28, %r12, %r14
leaq (%rbx,%r14), %r13
leaq 0xb0(%rsp), %rdi
movq %r13, %rsi
callq 0x16bf75
movl 0x8(%rbx,%r14), %esi
xorl $0x1, %esi
movq 0x30(%rsp), %rdi
callq 0x15d450
movslq 0x14(%rbx,%r14), %rcx
addq %rax, %rcx
cvtsi2sd %rcx, %xmm0
mulsd 0x50(%rsp), %xmm0
cvttsd2si %xmm0, %rdx
movq 0x140(%rsp), %rax
cmpq %rax, %rdx
cmovleq %rax, %rdx
addq %rcx, %rdx
cmpq %r15, %rdx
cmovgeq %r15, %rdx
subl $-0x80, %edx
movq %r12, 0x88(%rsp)
movq %r12, %rdi
movq %rbx, %rsi
callq 0x16bfa0
movq %r13, %r8
movq 0x20(%rsp), %rdi
movq %rax, %rbx
andq $0x0, 0x8(%rdi)
imulq $0x28, %rax, %r12
pushq $-0x1
popq %rbp
movq $0x0, 0x10(%rsp)
movq $0x0, 0x8(%rsp)
movq %r13, 0x18(%rsp)
testq %rbx, %rbx
js 0x16d2ce
movq (%rsp), %rax
movq (%rax), %r14
movl 0x14(%r14,%r12), %eax
cmpl 0x14(%r8), %eax
jge 0x16d195
leaq (%r14,%r12), %r15
movq 0x30(%rsp), %rdi
movq %r8, %rsi
movq %r15, %rdx
callq 0x16c018
testq %rax, %rax
js 0x16d19d
movq %rax, %r13
movq 0x20(%rsp), %rdi
movq (%rdi), %rax
movq 0x8(%rdi), %rcx
cmpq 0x10(%rdi), %rcx
jne 0x16d110
leaq (%rcx,%rcx), %rdx
testq %rcx, %rcx
pushq $0x2
popq %rcx
cmoveq %rcx, %rdx
movq %rdx, 0x10(%rdi)
imulq $0x30, %rdx, %rsi
movq %rax, %rdi
callq 0x2370
movq 0x20(%rsp), %rdi
movq %rax, (%rdi)
movq 0x8(%rdi), %rcx
movq 0x18(%rsp), %r8
leaq 0x1(%rcx), %rdx
movq %rdx, 0x8(%rdi)
imulq $0x30, %rcx, %rcx
xorpd %xmm0, %xmm0
movupd %xmm0, 0x20(%rax,%rcx)
movupd %xmm0, 0x10(%rax,%rcx)
movupd %xmm0, (%rax,%rcx)
movl 0x8(%r14,%r12), %edx
xorl $0x1, %edx
movl %edx, (%rax,%rcx)
movl %ebx, %edx
andl $0x3fffffff, %edx       # imm = 0x3FFFFFFF
movl %edx, 0xc(%rax,%rcx)
movl 0x14(%r8), %esi
subl 0x18(%r14,%r12), %esi
movl %esi, 0x10(%rax,%rcx)
movl %r13d, 0x4(%rax,%rcx)
movl %edx, 0xc(%rax,%rcx)
cmpq %r13, %rbp
cmovgq %rbp, %r13
movq 0x68(%rsp), %rax
movq 0x88(%rsp), %rdx
cmpq %rdx, (%rax,%rbx,8)
jne 0x16d1af
movq 0x10(%rsp), %rsi
cmpq 0x160(%rsp), %rsi
jge 0x16d2cb
incq %rsi
jmp 0x16d1b4
movq %rbp, %r13
jmp 0x16d2ae
movq %rbp, %r13
movq 0x20(%rsp), %rdi
movq 0x18(%rsp), %r8
jmp 0x16d2ae
movq 0x10(%rsp), %rsi
movq 0x38(%rsp), %rax
movslq (%rax,%rbx,4), %rax
testq %rax, %rax
js 0x16d1cb
movq 0x68(%rsp), %rcx
movq %rdx, (%rcx,%rax,8)
movq %rsi, 0x10(%rsp)
cmpq $0x0, 0x8(%rsp)
je 0x16d1e5
pushq $0x1
popq %rax
movq %rax, 0x8(%rsp)
jmp 0x16d2ae
movl 0x18(%r14,%r12), %eax
subl $-0x80, %eax
cmpl 0x14(%r8), %eax
jle 0x16d2a5
leaq 0xcc(%rsp), %rbp
movq %rbp, %rdi
movq %r15, %rsi
movq %r8, %r15
callq 0x16bf75
leaq 0xb0(%rsp), %rdi
movq %rbp, %rsi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
movq 0x78(%rsp), %r9
callq 0x3d261
movl 0x8(%r15), %edx
xorl $0x1, %edx
movl 0x8(%r14,%r12), %ecx
xorl $0x1, %ecx
subq $0x10, %rsp
xorpd %xmm0, %xmm0
movupd %xmm0, (%rsp)
movq 0x90(%rsp), %rdi
movq 0x148(%rsp), %rsi
movq 0x150(%rsp), %r8
movsd 0x762d3(%rip), %xmm0    # 0x1e3538
movq %rax, %r9
callq 0x1631f5
popq %rcx
popq %rdx
testq %rax, %rax
je 0x16d2bd
xorl %eax, %eax
movq 0x10(%rsp), %rcx
testq %rcx, %rcx
setg %al
subq %rax, %rcx
movq 0xa0(%rsp), %rax
cmpq %rax, %rcx
cmovleq %rax, %rcx
movq %rcx, 0x10(%rsp)
pushq $0x1
popq %rax
movq %rax, 0x8(%rsp)
jmp 0x16d1a0
movq $0x0, 0x8(%rsp)
decq %rbx
addq $-0x28, %r12
movq %r13, %rbp
jmp 0x16d095
movq $0x0, 0x8(%rsp)
jmp 0x16d1a0
movq %r13, %rbp
movslq 0x1c(%r8), %rbx
movq 0x8(%rdi), %rcx
testq %rcx, %rcx
je 0x16d40f
cvtsi2sd %rbp, %xmm0
mulsd 0x90(%rsp), %xmm0
cvttsd2si %xmm0, %r9
movq 0x140(%rsp), %rax
cmpq %rax, %r9
cmovleq %rax, %r9
movl 0x8(%r8), %edx
xorl $0x1, %edx
movq (%rdi), %r8
subq $0x8, %rsp
xorpd %xmm0, %xmm0
movq 0xa0(%rsp), %rdi
movq 0x38(%rsp), %rsi
pushq $0x0
pushq $0x1
pushq $0x0
pushq 0x140(%rsp)
pushq 0x170(%rsp)
pushq 0x180(%rsp)
pushq $0xf
callq 0x168290
movq 0x60(%rsp), %rsi
addq $0x40, %rsp
movq 0x8(%rsi), %rbp
xorl %r15d, %r15d
testq %rbp, %rbp
cmovleq %r15, %rbp
xorl %r14d, %r14d
movl $0x0, 0x10(%rsp)
pushq $-0x1
popq %r13
movl %r13d, 0x8(%rsp)
subq $0x1, %rbp
jb 0x16d401
movq (%rsi), %r12
testl $0x7fffffff, 0x14(%r12,%r15) # imm = 0x7FFFFFFF
je 0x16d3f8
leaq (%r12,%r15), %rdi
movq (%rsp), %rax
movq (%rax), %rdx
movq 0x18(%rsp), %rsi
movq 0x28(%rsp), %rcx
movq 0x140(%rsp), %r8
movss 0x74(%rsp), %xmm0
movss 0x7a900(%rip), %xmm1    # 0x1e7cb0
callq 0x1a2f00
movq 0x20(%rsp), %rsi
cltq
movl %eax, %ecx
negl %ecx
setno %cl
cmpq %rax, %rbx
setl %dl
andb %cl, %dl
cmpb $0x1, %dl
jne 0x16d3f8
movl 0xc(%r12,%r15), %r14d
movl 0x1c(%r12,%r15), %ecx
movl %ecx, 0x8(%rsp)
movl %r14d, %r13d
andl $0x3fffffff, %r13d      # imm = 0x3FFFFFFF
movl 0x24(%r12,%r15), %ecx
movl %ecx, 0x10(%rsp)
shrl $0x1f, %r14d
movq %rax, %rbx
addq $0x30, %r15
jmp 0x16d36d
shll $0x1f, %r14d
movl 0x10(%rsp), %ecx
movl 0x8(%rsp), %esi
jmp 0x16d41b
xorl %r14d, %r14d
xorl %ecx, %ecx
pushq $-0x1
popq %r13
movl %r13d, %esi
testq %rbx, %rbx
movq 0x48(%rsp), %rbp
movq 0x40(%rsp), %r8
movq 0x68(%rsp), %r15
jns 0x16d43c
movq 0x18(%rsp), %rax
movslq 0x1c(%rax), %rbx
pushq $-0x1
popq %r13
movq 0x28(%rsp), %rax
movq 0x88(%rsp), %r12
movq %rbx, (%rax,%r12,8)
movq 0x38(%rsp), %rax
movl %r13d, (%rax,%r12,4)
movq 0x18(%rsp), %rdx
movl %esi, 0x20(%rdx)
movl %ecx, 0x24(%rdx)
movl 0x4(%rdx), %eax
movl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
andl %ecx, %eax
orl %r14d, %eax
movl %eax, 0x4(%rdx)
movq 0x60(%rsp), %rax
cmpq %rax, %rbx
cmovlq %rbx, %rax
movq %rax, 0x60(%rsp)
incq %r12
movq 0x58(%rsp), %r14
movq 0xa8(%rsp), %rbx
jmp 0x16cfe3
imulq $0xa, %r8, %rax
addq $0x9, %rax
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
movq 0x60(%rsp), %r9
cmpq %r14, %r8
jge 0x16d4e7
movq (%rsp), %rdx
movq (%rdx), %rdx
movslq -0x8(%rdx,%rax,4), %rsi
movq 0x28(%rsp), %rdi
movq %rsi, (%rdi,%r8,8)
movq 0x38(%rsp), %rdi
orl $-0x1, (%rdi,%r8,4)
movq %rcx, -0x4(%rdx,%rax,4)
andb $0x7f, -0x1d(%rdx,%rax,4)
cmpq %rsi, %r9
cmovgeq %rsi, %r9
incq %r8
addq $0xa, %rax
jmp 0x16d4a9
xorl %eax, %eax
testq %r14, %r14
movl $0x0, %ecx
cmovgq %r14, %rcx
movq %r9, %rdx
shlq $0x20, %rdx
negq %rdx
movq 0x28(%rsp), %r8
cmpq %rax, %rcx
je 0x16d52b
movq (%r8,%rax,8), %rsi
movq %rsi, %rdi
subq %r9, %rdi
movq %rdi, (%r8,%rax,8)
shlq $0x20, %rsi
addq %rdx, %rsi
movq %rsi, (%r15,%rax,8)
incq %rax
addq $0x2, %rdx
jmp 0x16d504
andq $0x0, 0x8(%rbp)
cmpq %r14, 0x10(%rbp)
jae 0x16d583
leaq -0x1(%r14), %rax
movq %rax, %rcx
shrq %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x2, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x4, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x8, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x10, %rcx
orq %rax, %rcx
incq %rcx
movq %rcx, 0x10(%rbp)
movq (%rbp), %rdi
imulq $0x28, %rcx, %rsi
callq 0x2370
movq %rax, (%rbp)
movq 0x150(%rsp), %rdx
cmpq %r14, 0x8(%rdx)
jae 0x16d5eb
leaq -0x1(%r14), %rax
movq %rax, %rcx
shrq %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x2, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x4, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x8, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x10, %rcx
orq %rax, %rcx
leaq 0x1(%rcx), %rax
movq %rax, 0x8(%rdx)
movq 0x10(%rdx), %rdi
leaq 0x8(,%rcx,8), %rsi
movq %rdx, %rbx
callq 0x2370
movq %rax, %r12
movq %rax, 0x10(%rbx)
jmp 0x16d5ef
movq 0x10(%rdx), %r12
leaq (%r15,%r14,8), %rsi
movq %r15, %rdi
callq 0x156cf6
xorl %eax, %eax
xorl %r8d, %r8d
xorl %ecx, %ecx
movq %r8, %rdx
testq %r14, %r14
jle 0x16d6d2
decq %r14
movl (%r15,%r14,8), %edi
shrl %edi
imulq $0x28, %rdx, %r8
xorl %esi, %esi
testq %rdi, %rdi
js 0x16d671
testb $0x1, (%r15,%rdi,8)
jne 0x16d671
movq (%rsp), %r9
movq (%r9), %r9
imulq $0x28, %rdi, %r10
movq (%rbp), %r11
movq 0x20(%r9,%r10), %rbx
movq %rbx, 0x20(%r11,%r8)
movups (%r9,%r10), %xmm0
movupd 0x10(%r9,%r10), %xmm1
movupd %xmm1, 0x10(%r11,%r8)
movups %xmm0, (%r11,%r8)
orb $0x1, (%r15,%rdi,8)
movq 0x38(%rsp), %r9
movslq (%r9,%rdi,4), %rdi
decq %rsi
addq $0x28, %r8
jmp 0x16d61d
movq %rdx, %r8
subq %rsi, %r8
testq %rsi, %rsi
je 0x16d602
movslq 0x4(%r15,%r14,8), %r8
testq %rdi, %rdi
js 0x16d68f
movq 0x28(%rsp), %r9
subq (%r9,%rdi,8), %r8
subq %rsi, %rdx
cmpq %rcx, %r8
cmovlq %r8, %rcx
movq %r8, %rdi
notq %rdi
movq %r8, %r9
negq %r9
cmovsq %r8, %r9
movabsq $-0x8000000000000000, %r8 # imm = 0x8000000000000000
andq %r8, %rdi
shlq $0x20, %r9
negq %rsi
orq %rdi, %rsi
orq %r9, %rsi
movq %rsi, (%r12,%rax,8)
incq %rax
movq %rdx, %r8
jmp 0x16d602
pushq $-0x1
popq %rdi
xorl %esi, %esi
movq %rdi, %rbx
xorl %r8d, %r8d
cmpq %rax, %r8
je 0x16d794
movq (%r12,%r8,8), %r9
movq %r9, %r11
shrq $0x20, %r11
movl %r11d, %r10d
andl $0x7fffffff, %r10d      # imm = 0x7FFFFFFF
negl %r11d
testq %r9, %r9
cmovsl %r10d, %r11d
subl %ecx, %r11d
movl %r9d, %r10d
movl %r11d, 0x4(%r12,%r8,8)
imulq $0x28, %rsi, %r11
imulq $0x28, %r10, %r14
negq %r10
addq %r11, %r14
xorl %r9d, %r9d
cmpq %r9, %r10
je 0x16d768
movq (%rbp), %r15
movq (%rsp), %r13
movq (%r13), %r13
movq -0x8(%r14,%r15), %rbp
movq %rbp, 0x20(%r13,%r11)
movq 0x48(%rsp), %rbp
movups -0x28(%r14,%r15), %xmm0
movupd -0x18(%r14,%r15), %xmm1
movupd %xmm1, 0x10(%r13,%r11)
movups %xmm0, (%r13,%r11)
decq %r9
addq $0x28, %r11
addq $-0x28, %r14
jmp 0x16d721
movl 0x4(%r12,%r8,8), %r10d
cmpq %r10, %rdi
cmovleq %r10, %rdi
movq %rbx, %r11
cmovlq %r8, %r11
testq %rbx, %rbx
cmovsq %r10, %rdi
cmovsq %r8, %r11
incq %r8
subq %r9, %rsi
movq %r11, %rbx
jmp 0x16d6dd
cmpq %rdx, %rsi
jne 0x16d7b9
movq 0x150(%rsp), %rcx
movq %rax, (%rcx)
movq %rbx, %rax
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x84579(%rip), %rdi     # 0x1f1d39
leaq 0x8435c(%rip), %rsi     # 0x1f1b23
leaq 0x85a83(%rip), %rcx     # 0x1f3251
movl $0x175f, %edx           # imm = 0x175F
callq 0x2110
leaq 0x85a68(%rip), %rdi     # 0x1f3247
leaq 0x8433d(%rip), %rsi     # 0x1f1b23
leaq 0x85a64(%rip), %rcx     # 0x1f3251
movl $0x16b7, %edx           # imm = 0x16B7
callq 0x2110