// File: /workspace/github_cpp_makefile_star2_O3/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, 0x28(%rsp)
movsd %xmm0, 0x68(%rsp)
movq %r9, 0x20(%rsp)
movq %rsi, 0x90(%rsp)
movq %rdi, 0xa0(%rsp)
movq 0x150(%rsp), %rax
movq $0x0, (%rax)
movq 0x8(%rcx), %r15
testq %r15, %r15
je 0x1b655d
movq %r8, %r13
movq %rcx, %rbp
movq 0x178(%rsp), %rbx
movq 0x148(%rsp), %rdi
movq 0x18(%rdx), %r12
testq %rbx, %rbx
movq %r12, 0x58(%rsp)
movq %rdx, 0x88(%rsp)
je 0x1b6564
testq %r15, %r15
jle 0x1b6646
movabsq $-0x8000000000000000, %rax # imm = 0x8000000000000000
movq (%rbp), %rcx
movq 0x20(%r12), %rdx
addq $0x20, %rcx
xorl %esi, %esi
movl $0x7fffffff, %r11d      # imm = 0x7FFFFFFF
xorl %r8d, %r8d
xorl %r12d, %r12d
movl $0xffffffff, (%rcx)     # imm = 0xFFFFFFFF
movl -0x18(%rcx), %r9d
shrl %r9d
movl (%rdx,%r9,8), %r9d
andl %r11d, %r9d
cmpl %r9d, -0x10(%rcx)
jge 0x1b6492
xorl %r10d, %r10d
cmpl $0x0, -0x14(%rcx)
setle %r10b
movq %rax, %r9
cmovleq %rsi, %r9
jmp 0x1b649b
movl $0x1, %r10d
xorl %r9d, %r9d
addq %r10, %r12
movl -0x8(%rcx), %r10d
shlq $0x20, %r10
orq %r8, %r9
orq %r10, %r9
movq 0x148(%rsp), %rdi
movq %r9, (%rdi,%r8,8)
incq %r8
addq $0x28, %rcx
cmpq %r8, %r15
jne 0x1b6464
leaq (%rdi,%r15,8), %rsi
callq 0x19dd99
movq 0x148(%rsp), %r8
movl $0x1, %r14d
xorl %eax, %eax
cmpq %r15, %r14
je 0x1b64f5
movq (%r8,%rax,8), %rcx
xorq (%r8,%r14,8), %rcx
shrq $0x20, %rcx
jne 0x1b64f5
movq %rax, %rcx
jmp 0x1b6541
movq %r14, %rdx
subq %rax, %rdx
movq %r14, %rcx
cmpq $0x2, %rdx
jl 0x1b6541
cmpq %rax, %r14
jle 0x1b6529
movq (%rbp), %rcx
movq %rax, %rdx
movl (%r8,%rdx,8), %esi
leaq (%rsi,%rsi,4), %rsi
movl 0x14(%rcx,%rsi,8), %esi
movl %esi, 0x4(%r8,%rdx,8)
incq %rdx
cmpq %rdx, %r14
jne 0x1b6510
leaq (%r8,%rax,8), %rdi
leaq (%r8,%r14,8), %rsi
callq 0x19dd99
movq 0x148(%rsp), %r8
movq %r14, %rcx
leaq 0x1(%r14), %rdx
movq %rcx, %rax
cmpq %r15, %r14
movq %rdx, %r14
jne 0x1b64dd
movq %r12, %r14
movq 0x58(%rsp), %r12
jmp 0x1b6667
xorl %ebx, %ebx
jmp 0x1b7283
testq %r15, %r15
jle 0x1b6654
movq (%rbp), %rax
movq 0x20(%r12), %rcx
addq $0x20, %rax
xorl %edx, %edx
movl $0x7fffffff, %esi       # imm = 0x7FFFFFFF
xorl %r14d, %r14d
movl $0xffffffff, (%rax)     # imm = 0xFFFFFFFF
movl -0x18(%rax), %r8d
shrl %r8d
movl (%rcx,%r8,8), %r8d
andl %esi, %r8d
cmpl %r8d, -0x10(%rax)
jge 0x1b65a4
cmpl $0x0, -0x14(%rax)
jg 0x1b65b6
movl -0x8(%rax), %r8d
shlq $0x20, %r8
orq %rdx, %r8
movq %r8, (%rdi,%r14,8)
incq %r14
incq %rdx
addq $0x28, %rax
cmpq %rdx, %r15
jne 0x1b6584
testq %r15, %r15
setle %al
cmpq %r15, %r14
setge %cl
orb %al, %cl
jne 0x1b665b
movabsq $-0x8000000000000000, %rax # imm = 0x8000000000000000
movq (%rbp), %rdx
movq 0x20(%r12), %rsi
addq $0x20, %rdx
xorl %edi, %edi
movl $0x7fffffff, %r8d       # imm = 0x7FFFFFFF
movq %r14, %rcx
movl $0xffffffff, (%rdx)     # imm = 0xFFFFFFFF
movl -0x18(%rdx), %r9d
shrl %r9d
movl (%rsi,%r9,8), %r9d
andl %r8d, %r9d
cmpl %r9d, -0x10(%rdx)
jge 0x1b6638
cmpl $0x0, -0x14(%rdx)
jle 0x1b6638
movl -0x8(%rdx), %r9d
shlq $0x20, %r9
movq %rdi, %r10
orq %rax, %r10
orq %r9, %r10
movq 0x148(%rsp), %r9
movq %r10, (%r9,%rcx,8)
incq %rcx
incq %rdi
addq $0x28, %rdx
cmpq %rdi, %r15
jne 0x1b65f8
jmp 0x1b665e
leaq (%rdi,%r15,8), %rsi
callq 0x19dd99
xorl %r14d, %r14d
jmp 0x1b6675
xorl %r14d, %r14d
xorl %ecx, %ecx
jmp 0x1b665e
movq %r14, %rcx
cmpq %r15, %rcx
jne 0x1b72b7
testq %rbx, %rbx
jne 0x1b6675
cmpq %r15, %r14
je 0x1b673b
cmpq %r15, 0x10(%r13)
jae 0x1b66d1
leaq -0x1(%r15), %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, 0x10(%r13)
movq (%r13), %rdi
leaq 0x8(,%rcx,8), %rax
leaq (%rax,%rax,4), %rsi
callq 0x2370
movq %rax, (%r13)
movq %r15, 0x8(%r13)
testq %r15, %r15
movq 0x148(%rsp), %r9
jle 0x1b6722
xorl %eax, %eax
xorl %ecx, %ecx
movq (%rbp), %rdx
movl (%r9,%rcx,8), %esi
leaq (%rsi,%rsi,4), %rsi
movq (%r13), %rdi
movq 0x20(%rdx,%rsi,8), %r8
movq %r8, 0x20(%rdi,%rax)
movupd (%rdx,%rsi,8), %xmm0
movupd 0x10(%rdx,%rsi,8), %xmm1
movupd %xmm1, 0x10(%rdi,%rax)
movupd %xmm0, (%rdi,%rax)
incq %rcx
addq $0x28, %rax
cmpq %rcx, %r15
jne 0x1b66e6
movq (%rbp), %rdi
movq (%r13), %rsi
leaq (,%r15,8), %rax
leaq (%rax,%rax,4), %rdx
callq 0x2160
movq 0x158(%rsp), %rbx
movq 0x130(%rsp), %rax
movq %rax, 0x80(%rsp)
movq %rbx, %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0x3ecb0
movq 0x28(%rbx), %rax
movq (%rbx), %rcx
movq %rcx, 0x30(%rsp)
movq 0x8(%rbx), %r10
xorpd %xmm1, %xmm1
movsd 0x28(%rsp), %xmm0
ucomisd %xmm1, %xmm0
movq %rax, 0x38(%rsp)
movq %r10, 0x8(%rsp)
jb 0x1b683a
subq $0x8, %rsp
movq 0x98(%rsp), %rdi
movq 0x90(%rsp), %rsi
movq %rbp, %rdx
movq %r13, %rcx
movq 0x138(%rsp), %r8
movq 0x140(%rsp), %r9
pushq %r14
pushq %rax
pushq %r10
pushq 0x50(%rsp)
pushq 0x198(%rsp)
pushq 0x198(%rsp)
pushq 0x198(%rsp)
pushq 0x190(%rsp)
pushq 0x188(%rsp)
callq 0x1b590b
addq $0x50, %rsp
movq %rax, %rbx
xorpd %xmm0, %xmm0
ucomisd 0x68(%rsp), %xmm0
ja 0x1b7283
testq %rbx, %rbx
js 0x1b6826
movq 0x150(%rsp), %rax
movq (%rax), %rsi
movq 0x10(%rax), %rdi
movq (%rbp), %rdx
callq 0x1b576d
testq %rax, %rax
jne 0x1b7283
movq 0x150(%rsp), %rax
movq $0x0, (%rax)
movq 0x38(%rsp), %rax
leaq (,%r14,8), %rdx
movq %rax, %rdi
xorl %esi, %esi
callq 0x20e0
testq %r14, %r14
movq %r13, 0x60(%rsp)
movq %rbp, 0x28(%rsp)
movq %r15, 0x48(%rsp)
jle 0x1b6f11
incq 0x80(%rsp)
movq 0x160(%rsp), %rax
sarq %rax
movq %rax, 0xa8(%rsp)
movsd 0x7aa89(%rip), %xmm1    # 0x231310
movsd 0x68(%rsp), %xmm0
addsd %xmm0, %xmm1
movsd %xmm1, 0x98(%rsp)
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x74(%rsp)
xorl %edi, %edi
movq $0x0, 0x40(%rsp)
movq %r14, 0x78(%rsp)
movq (%rbp), %rsi
movq %rdi, 0x50(%rsp)
leaq (%rdi,%rdi,4), %rax
movl $0x7fffffff, %edi       # imm = 0x7FFFFFFF
movl 0x8(%rsi,%rax,8), %ecx
movl %ecx, %edx
shrl %edx
movl %edx, 0xd8(%rsp)
shll $0x1f, %ecx
movl 0xe4(%rsp), %edx
andl %edi, %edx
orl %ecx, %edx
movl %edx, 0xe4(%rsp)
movq 0xc(%rsi,%rax,8), %rcx
movq %rcx, 0xdc(%rsp)
movq 0x14(%rsi,%rax,8), %rcx
movq %rcx, 0xd0(%rsp)
movl 0x8(%rsi,%rax,8), %edx
xorq $0x1, %rdx
movq 0x28(%r12), %rdi
movq (%rdi,%rdx,8), %rdi
movq %rdi, %rdx
movl $0xffffffff, %r8d       # imm = 0xFFFFFFFF
andq %r8, %rdx
je 0x1b696c
movq 0x8(%r12), %r8
shrq $0x20, %rdi
shlq $0x3, %rdx
leaq (%rdx,%rdx,2), %rdx
leaq (%rdi,%rdi,2), %rdi
leaq (%r8,%rdi,8), %rdi
addq $0xc, %rdi
xorl %r8d, %r8d
xorl %r9d, %r9d
movl %r9d, %r10d
movl (%rdi,%r8), %r11d
cmpl %r11d, %r9d
movl %r11d, %r9d
cmoval %r10d, %r9d
testl %r11d, %r11d
cmovsl %r10d, %r9d
addq $0x18, %r8
cmpq %r8, %rdx
jne 0x1b6946
movl %r9d, %edx
jmp 0x1b696e
xorl %edx, %edx
movq 0x50(%rsp), %rdi
movq %rcx, %xmm0
movd %xmm0, %ecx
movslq %ecx, %rcx
addq %rdx, %rcx
xorps %xmm0, %xmm0
cvtsi2sd %rcx, %xmm0
leaq (%rsi,%rax,8), %r15
mulsd 0x68(%rsp), %xmm0
cvttsd2si %xmm0, %rdx
movq 0x140(%rsp), %rax
cmpq %rax, %rdx
cmovleq %rax, %rdx
addq %rcx, %rdx
movq 0x80(%rsp), %rax
cmpq %rax, %rdx
cmovgeq %rax, %rdx
subl $-0x80, %edx
callq 0x1b5673
movq 0x20(%rsp), %rdi
movq $0x0, 0x8(%rdi)
testq %rax, %rax
js 0x1b6e47
movq %rax, %rbx
shlq $0x3, %rax
leaq (%rax,%rax,4), %rbp
movq $-0x1, %r12
xorl %r14d, %r14d
movq $0x0, 0x10(%rsp)
movq %r15, %r8
movq %r15, 0x18(%rsp)
movq 0x28(%rsp), %rax
movq (%rax), %r15
movl 0x14(%r15,%rbp), %eax
cmpl 0x14(%r8), %eax
jge 0x1b6c13
leaq (%r15,%rbp), %rdx
movq 0x58(%rsp), %rdi
movq %r8, %rsi
callq 0x1b56f4
testq %rax, %rax
js 0x1b6c1b
movq %rax, %r13
movq 0x20(%rsp), %rdi
movq (%rdi), %rax
movq 0x8(%rdi), %rcx
cmpq 0x10(%rdi), %rcx
jne 0x1b6a74
leaq (%rcx,%rcx), %rdx
testq %rcx, %rcx
movl $0x2, %ecx
cmoveq %rcx, %rdx
movq %rdx, 0x10(%rdi)
shlq $0x4, %rdx
leaq (%rdx,%rdx,2), %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)
leaq (%rcx,%rcx,2), %rcx
shlq $0x4, %rcx
xorpd %xmm0, %xmm0
movupd %xmm0, 0x20(%rax,%rcx)
movupd %xmm0, 0x10(%rax,%rcx)
movupd %xmm0, (%rax,%rcx)
movl 0x8(%r15,%rbp), %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(%r15,%rbp), %esi
movl %esi, 0x10(%rax,%rcx)
movl %r13d, 0x4(%rax,%rcx)
movl %edx, 0xc(%rax,%rcx)
cmpq %r13, %r12
cmovgq %r12, %r13
movq 0x38(%rsp), %rax
movq 0x50(%rsp), %rdx
cmpq %rdx, (%rax,%rbx,8)
jne 0x1b6afd
movq 0x10(%rsp), %rax
cmpq 0x160(%rsp), %rax
jge 0x1b6c51
incq %rax
movq %rax, 0x10(%rsp)
movq 0x30(%rsp), %rax
movslq (%rax,%rbx,4), %rax
testq %rax, %rax
js 0x1b6b14
movq 0x38(%rsp), %rcx
movq %rdx, (%rcx,%rax,8)
movl $0x1, %r12d
testq %r14, %r14
jne 0x1b6c2b
movl 0x18(%r15,%rbp), %eax
subl $-0x80, %eax
cmpl 0x14(%r8), %eax
jle 0x1b6c47
movl 0x8(%r15,%rbp), %eax
movl %eax, %ecx
shrl %ecx
movl %ecx, 0xbc(%rsp)
shll $0x1f, %eax
movl 0xc8(%rsp), %ecx
movl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
andl %edx, %ecx
orl %eax, %ecx
movl %ecx, 0xc8(%rsp)
movq 0xc(%r15,%rbp), %rax
movq %rax, 0xc0(%rsp)
movq 0x14(%r15,%rbp), %rax
movq %rax, 0xb4(%rsp)
leaq 0xcc(%rsp), %rdi
leaq 0xb0(%rsp), %rsi
xorl %edx, %edx
xorl %ecx, %ecx
movq %r8, %r14
xorl %r8d, %r8d
movq 0x88(%rsp), %r9
callq 0x6ea22
movl 0x8(%r14), %edx
xorl $0x1, %edx
movl 0x8(%r15,%rbp), %ecx
xorl $0x1, %ecx
subq $0x10, %rsp
xorpd %xmm0, %xmm0
movupd %xmm0, (%rsp)
movq 0xa0(%rsp), %rdi
movq 0x148(%rsp), %rsi
movq 0x150(%rsp), %r8
movsd 0x7aa0c(%rip), %xmm0    # 0x2315e8
movq %rax, %r9
callq 0x1ab640
addq $0x10, %rsp
testq %rax, %rax
je 0x1b6c4c
xorl %eax, %eax
movq 0x10(%rsp), %rcx
testq %rcx, %rcx
setg %al
subq %rax, %rcx
movq 0xa8(%rsp), %rax
cmpq %rax, %rcx
cmovleq %rax, %rcx
movq %rcx, 0x10(%rsp)
jmp 0x1b6c21
movq %r12, %r13
movq %r14, %r12
jmp 0x1b6c2b
movq %r12, %r13
movq %r14, %r12
movq 0x20(%rsp), %rdi
movq 0x18(%rsp), %r8
leaq -0x1(%rbx), %rax
addq $-0x28, %rbp
movq %r12, %r14
movq %r13, %r12
testq %rbx, %rbx
movq %rax, %rbx
jg 0x1b69fe
jmp 0x1b6c51
xorl %r12d, %r12d
jmp 0x1b6c2b
xorl %r12d, %r12d
jmp 0x1b6c21
movq 0x8(%rdi), %rcx
leaq 0x1c(%r8), %r15
movslq 0x1c(%r8), %rbx
movl $0xffffffff, %r9d       # imm = 0xFFFFFFFF
testq %rcx, %rcx
je 0x1b6e69
xorps %xmm0, %xmm0
cvtsi2sd %r13, %xmm0
mulsd 0x98(%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
xorl %r12d, %r12d
xorpd %xmm0, %xmm0
movq 0xa8(%rsp), %rdi
movq 0x60(%rsp), %rsi
pushq %r12
pushq $0x1
pushq %r12
pushq 0x140(%rsp)
pushq 0x170(%rsp)
pushq 0x180(%rsp)
pushq $0xf
callq 0x1b100b
movq 0x60(%rsp), %rax
addq $0x40, %rsp
movq 0x8(%rax), %rdx
testq %rdx, %rdx
movq 0x28(%rsp), %rbp
movq 0x78(%rsp), %r14
jle 0x1b6e8c
movq (%rax), %rsi
addq $0x24, %rsi
xorl %eax, %eax
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
movl $0xffffffff, 0x10(%rsp) # imm = 0xFFFFFFFF
xorl %r12d, %r12d
movq 0x60(%rsp), %r13
movq 0x8(%rsp), %r11
movss 0x74(%rsp), %xmm4
testl $0x7fffffff, -0x10(%rsi) # imm = 0x7FFFFFFF
je 0x1b6e27
movl -0x20(%rsi), %r9d
movl -0x8(%rsi), %edi
movl %edi, %r10d
subl %r9d, %r10d
movl %r10d, %r8d
negl %r8d
cmovsl %r10d, %r8d
xorps %xmm1, %xmm1
cvtsi2ss %r8d, %xmm1
xorps %xmm0, %xmm0
cvtsi2ss %r9d, %xmm0
mulss %xmm4, %xmm0
ucomiss %xmm0, %xmm1
jbe 0x1b6d69
cmpq 0x140(%rsp), %r8
jg 0x1b6e27
movaps %xmm1, %xmm0
mulss 0x7f03c(%rip), %xmm0    # 0x235db0
xorps %xmm2, %xmm2
cmpl $0x2, %r8d
jb 0x1b6dcc
movd %xmm1, %r8d
movl %r8d, %r9d
shrl $0x17, %r9d
addl $-0x80, %r9d
xorps %xmm1, %xmm1
cvtsi2ss %r9, %xmm1
andl $0x7fffff, %r8d         # imm = 0x7FFFFF
orl $0x3f800000, %r8d       # imm = 0x3F800000
movd %r8d, %xmm3
movdqa %xmm3, %xmm2
mulss 0x88dec(%rip), %xmm2    # 0x23fba0
addss 0x88de8(%rip), %xmm2    # 0x23fba4
mulss %xmm3, %xmm2
addss 0x88de0(%rip), %xmm2    # 0x23fba8
addss %xmm1, %xmm2
addss %xmm2, %xmm0
movl (%r15), %r10d
cvttss2si %xmm0, %r8d
subl %r8d, %r10d
movl -0x18(%rsi), %r8d
movl %r8d, %r9d
andl $0x3fffffff, %r9d       # imm = 0x3FFFFFFF
addl (%r11,%r9,8), %r10d
movslq %r10d, %r10
movl %r10d, %r11d
negl %r11d
setno %r11b
cmpq %r10, %rbx
setl %bpl
andb %r11b, %bpl
movq 0x8(%rsp), %r11
cmpb $0x1, %bpl
movq 0x28(%rsp), %rbp
jne 0x1b6e27
movl (%rsi), %eax
shrl $0x1f, %r8d
movl %r8d, %r12d
movl %edi, 0x10(%rsp)
movl %r9d, %ecx
movq %r10, %rbx
addq $0x30, %rsi
decq %rdx
jne 0x1b6d1e
movq %r15, %rsi
shll $0x1f, %r12d
movq 0x18(%rsp), %r8
movl 0x10(%rsp), %r9d
jmp 0x1b6eab
leaq 0x1c(%r15), %rsi
movslq 0x1c(%r15), %rbx
movl $0xffffffff, %r9d       # imm = 0xFFFFFFFF
xorl %r12d, %r12d
xorl %eax, %eax
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
movq 0x8(%rsp), %r11
movq %r15, %r8
jmp 0x1b6eab
movq %r15, %rsi
xorl %r12d, %r12d
xorl %eax, %eax
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
movq 0x60(%rsp), %r13
movq 0x28(%rsp), %rbp
movq 0x78(%rsp), %r14
movq 0x8(%rsp), %r11
jmp 0x1b6eab
movq %r15, %rsi
xorl %eax, %eax
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
movq 0x60(%rsp), %r13
movq 0x8(%rsp), %r11
movq 0x18(%rsp), %r8
movl $0xffffffff, %r9d       # imm = 0xFFFFFFFF
testq %rbx, %rbx
movq 0x30(%rsp), %rdx
jns 0x1b6ebd
movslq (%rsi), %rbx
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
movq 0x50(%rsp), %rdi
movq %rbx, (%r11,%rdi,8)
movl %ecx, (%rdx,%rdi,4)
movl %r9d, 0x20(%r8)
movl %eax, 0x24(%r8)
movl 0x4(%r8), %eax
movl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
andl %ecx, %eax
orl %r12d, %eax
movl %eax, 0x4(%r8)
movq 0x40(%rsp), %rax
cmpq %rax, %rbx
cmovlq %rbx, %rax
movq %rax, 0x40(%rsp)
incq %rdi
cmpq %r14, %rdi
movq 0x48(%rsp), %r15
movq 0x58(%rsp), %r12
jne 0x1b68b4
movq 0x30(%rsp), %rdi
jmp 0x1b6f27
movq $0x0, 0x40(%rsp)
xorl %r14d, %r14d
movq 0x30(%rsp), %rdi
movq 0x8(%rsp), %r11
cmpq %r15, %r14
movq 0x40(%rsp), %r8
jge 0x1b6f79
leaq (%r14,%r14,4), %rax
leaq 0x12(,%rax,4), %rcx
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movq (%rbp), %rsi
movslq -0x8(%rsi,%rcx,2), %rax
movq %rax, (%r11,%r14,8)
movl $0xffffffff, (%rdi,%r14,4) # imm = 0xFFFFFFFF
movq %rdx, -0x4(%rsi,%rcx,2)
andb $0x7f, -0x1d(%rsi,%rcx,2)
cmpq %rax, %r8
cmovlq %r8, %rax
incq %r14
addq $0x14, %rcx
movq %rax, %r8
cmpq %r14, %r15
jne 0x1b6f42
jmp 0x1b6f7c
movq %r8, %rax
testq %r15, %r15
movq 0x38(%rsp), %r14
jle 0x1b6fb7
movq %rax, %rcx
shlq $0x20, %rcx
negq %rcx
xorl %edx, %edx
movq (%r11,%rdx,8), %rsi
movq %rsi, %rdi
subq %rax, %rdi
movq %rdi, (%r11,%rdx,8)
shlq $0x20, %rsi
addq %rcx, %rsi
movq %rsi, (%r14,%rdx,8)
incq %rdx
addq $0x2, %rcx
cmpq %rdx, %r15
jne 0x1b6f92
movq $0x0, 0x8(%r13)
cmpq %r15, 0x10(%r13)
jae 0x1b701b
leaq -0x1(%r15), %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, 0x10(%r13)
movq (%r13), %rdi
leaq 0x8(,%rcx,8), %rax
leaq (%rax,%rax,4), %rsi
callq 0x2370
movq %rax, (%r13)
movq 0x150(%rsp), %rbx
cmpq %r15, 0x8(%rbx)
jae 0x1b7080
leaq -0x1(%r15), %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(%rbx)
movq 0x10(%rbx), %rdi
leaq 0x8(,%rcx,8), %rsi
callq 0x2370
movq %rax, %r12
movq %rax, 0x10(%rbx)
jmp 0x1b7084
movq 0x10(%rbx), %r12
leaq (%r14,%r15,8), %rsi
movq %r14, %rdi
callq 0x19e008
testq %r15, %r15
jle 0x1b725f
movabsq $-0x8000000000000000, %rsi # imm = 0x8000000000000000
xorl %edx, %edx
xorl %ecx, %ecx
xorl %eax, %eax
movq %rcx, %r9
movq 0x48(%rsp), %rdi
leaq -0x1(%rdi), %r8
movq %r8, 0x48(%rsp)
movl -0x8(%r14,%rdi,8), %r8d
shrl %r8d
leaq (,%rcx,8), %r10
leaq (%r10,%r10,4), %r10
testb $0x1, (%r14,%r8,8)
jne 0x1b7124
movq (%rbp), %r11
leaq (%r8,%r8,4), %rbx
movq (%r13), %r14
movq 0x20(%r11,%rbx,8), %r15
movq %r15, 0x20(%r14,%r10)
movupd (%r11,%rbx,8), %xmm0
movupd 0x10(%r11,%rbx,8), %xmm1
movupd %xmm1, 0x10(%r14,%r10)
movupd %xmm0, (%r14,%r10)
movq 0x38(%rsp), %r14
orb $0x1, (%r14,%r8,8)
incq %rcx
movq 0x30(%rsp), %r11
movslq (%r11,%r8,4), %r8
addq $0x28, %r10
testq %r8, %r8
jns 0x1b70ce
movq %rcx, %r10
subq %r9, %r10
je 0x1b716f
movq 0x48(%rsp), %r9
movslq 0x4(%r14,%r9,8), %r9
testq %r8, %r8
js 0x1b7144
movq 0x8(%rsp), %r11
subq (%r11,%r8,8), %r9
cmpq %rdx, %r9
cmovlq %r9, %rdx
movq %r9, %r8
notq %r8
movq %r9, %r11
negq %r11
cmovsq %r9, %r11
andq %rsi, %r8
orq %r8, %r10
shlq $0x20, %r11
orq %r10, %r11
movq %r11, (%r12,%rax,8)
incq %rax
cmpq $0x1, %rdi
jg 0x1b70a9
testq %rax, %rax
jle 0x1b726a
movq $-0x1, %r9
xorl %edi, %edi
movq $-0x1, %r8
xorl %esi, %esi
movq (%r12,%rdi,8), %r10
movq %r10, %r11
shrq $0x20, %r11
movl %r11d, %ebx
andl $0x7fffffff, %ebx       # imm = 0x7FFFFFFF
negl %r11d
testq %r10, %r10
cmovsl %ebx, %r11d
subl %edx, %r11d
movl %r10d, %r10d
shlq $0x20, %r11
orq %r10, %r11
movq %r11, (%r12,%rdi,8)
testq %r10, %r10
je 0x1b7231
leaq (,%rsi,8), %r11
leaq (%r11,%r11,4), %r11
leaq (%r10,%r10,4), %rbx
negq %r10
leaq (%r11,%rbx,8), %rbx
xorl %r14d, %r14d
movq (%r13), %r15
movq (%rbp), %r13
movq -0x8(%rbx,%r15), %rbp
movq %rbp, 0x20(%r13,%r11)
movq 0x28(%rsp), %rbp
movupd -0x28(%rbx,%r15), %xmm0
movupd -0x18(%rbx,%r15), %xmm1
movupd %xmm1, 0x10(%r13,%r11)
movupd %xmm0, (%r13,%r11)
movq 0x60(%rsp), %r13
decq %r14
addq $-0x28, %rbx
addq $0x28, %r11
cmpq %r14, %r10
jne 0x1b71e2
movq (%r12,%rdi,8), %r11
subq %r14, %rsi
shrq $0x20, %r11
cmpq %r11, %r8
cmovleq %r11, %r8
movq %r9, %rbx
cmovlq %rdi, %rbx
testq %r9, %r9
cmovsq %r11, %r8
cmovsq %rdi, %rbx
incq %rdi
movq %rbx, %r9
cmpq %rax, %rdi
jne 0x1b7194
jmp 0x1b7273
xorl %eax, %eax
movq $-0x1, %rbx
jmp 0x1b7278
movq $-0x1, %rbx
xorl %esi, %esi
cmpq %rcx, %rsi
jne 0x1b7298
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 0x88bd2(%rip), %rdi     # 0x23fe71
leaq 0x889b5(%rip), %rsi     # 0x23fc5b
leaq 0x8a0dc(%rip), %rcx     # 0x241389
movl $0x175f, %edx           # imm = 0x175F
callq 0x2110
leaq 0x8a0c1(%rip), %rdi     # 0x24137f
leaq 0x88996(%rip), %rsi     # 0x23fc5b
leaq 0x8a0bd(%rip), %rcx     # 0x241389
movl $0x16b7, %edx           # imm = 0x16B7
callq 0x2110