// File: /workspace/github_cpp_makefile_star2_O1/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, 0x40(%rsp)
movsd %xmm0, 0x48(%rsp)
movq %rsi, 0x80(%rsp)
movq %rdi, 0xd0(%rsp)
movq 0x150(%rsp), %rax
movq $0x0, (%rax)
movq 0x8(%rcx), %rbp
testq %rbp, %rbp
je 0x1ad252
movq %r9, %r14
movq %r8, %r13
movq %rcx, (%rsp)
movq 0x178(%rsp), %r15
movq 0x148(%rsp), %rdi
movq 0x18(%rdx), %rax
movq %rax, 0x8(%rsp)
testq %r15, %r15
movq %rdx, 0x78(%rsp)
je 0x1ad259
testq %rbp, %rbp
jle 0x1ad2c3
movq (%rsp), %rax
movq (%rax), %rax
movq 0x8(%rsp), %rcx
movq 0x20(%rcx), %rcx
addq $0x20, %rax
xorl %edx, %edx
movl $0x7fffffff, %esi       # imm = 0x7FFFFFFF
xorl %r10d, %r10d
xorl %r12d, %r12d
movl $0xffffffff, (%rax)     # imm = 0xFFFFFFFF
movl -0x18(%rax), %r8d
shrl %r8d
movl (%rcx,%r8,8), %r8d
andl %esi, %r8d
cmpl %r8d, -0x10(%rax)
jge 0x1ad21e
xorl %r9d, %r9d
cmpl $0x0, -0x14(%rax)
setle %r9b
movabsq $-0x8000000000000000, %r8 # imm = 0x8000000000000000
cmovleq %rdx, %r8
jmp 0x1ad227
movl $0x1, %r9d
xorl %r8d, %r8d
addq %r9, %r12
movl -0x8(%rax), %r9d
shlq $0x20, %r9
orq %r10, %r8
orq %r9, %r8
movq 0x148(%rsp), %rdi
movq %r8, (%rdi,%r10,8)
incq %r10
addq $0x28, %rax
cmpq %r10, %rbp
jne 0x1ad1e9
jmp 0x1ad2c6
xorl %ebx, %ebx
jmp 0x1ae035
testq %rbp, %rbp
jle 0x1ad36c
movq (%rsp), %rax
movq (%rax), %rax
movq 0x8(%rsp), %rcx
movq 0x20(%rcx), %rcx
addq $0x20, %rax
xorl %edx, %edx
movl $0x7fffffff, %esi       # imm = 0x7FFFFFFF
xorl %r12d, %r12d
movl $0xffffffff, (%rax)     # imm = 0xFFFFFFFF
movl -0x18(%rax), %r8d
shrl %r8d
movl (%rcx,%r8,8), %r8d
andl %esi, %r8d
cmpl %r8d, -0x10(%rax)
jge 0x1ad2a0
cmpl $0x0, -0x14(%rax)
jg 0x1ad2b2
movl -0x8(%rax), %r8d
shlq $0x20, %r8
orq %rdx, %r8
movq %r8, (%rdi,%r12,8)
incq %r12
incq %rdx
addq $0x28, %rax
cmpq %rdx, %rbp
jne 0x1ad280
jmp 0x1ad36f
xorl %r12d, %r12d
leaq (%rdi,%rbp,8), %rsi
callq 0x194fef
testq %rbp, %rbp
jle 0x1ad3ff
movl $0x1, %ebx
xorl %eax, %eax
movq 0x148(%rsp), %r8
cmpq %rbp, %rbx
je 0x1ad2ff
movq (%r8,%rax,8), %rcx
xorq (%r8,%rbx,8), %rcx
shrq $0x20, %rcx
jne 0x1ad2ff
movq %rax, %rcx
jmp 0x1ad358
movq %rbx, %rdx
subq %rax, %rdx
movq %rbx, %rcx
cmpq $0x2, %rdx
jl 0x1ad358
cmpq %rax, %rbx
jle 0x1ad340
movq (%rsp), %rcx
movq (%rcx), %rcx
movq %rax, %rdx
movl (%r8,%rdx,8), %esi
movq %rsi, (%r8,%rdx,8)
leaq (%rsi,%rsi,4), %rdi
movl 0x14(%rcx,%rdi,8), %edi
shlq $0x20, %rdi
orq %rsi, %rdi
movq %rdi, (%r8,%rdx,8)
incq %rdx
cmpq %rdx, %rbx
jne 0x1ad31d
leaq (%r8,%rax,8), %rdi
leaq (%r8,%rbx,8), %rsi
callq 0x194fef
movq 0x148(%rsp), %r8
movq %rbx, %rcx
leaq 0x1(%rbx), %rdx
movq %rcx, %rax
cmpq %rbp, %rbx
movq %rdx, %rbx
jne 0x1ad2e7
jmp 0x1ad3ff
xorl %r12d, %r12d
cmpq %rbp, %r12
setge %al
testq %rbp, %rbp
setle %cl
orb %al, %cl
movq %r12, %rdx
jne 0x1ad3f6
movq (%rsp), %rax
movq (%rax), %rax
movq 0x8(%rsp), %rcx
movq 0x20(%rcx), %rcx
addq $0x20, %rax
xorl %esi, %esi
movl $0x7fffffff, %edi       # imm = 0x7FFFFFFF
movq %r12, %rdx
movabsq $-0x8000000000000000, %r10 # imm = 0x8000000000000000
movl $0xffffffff, (%rax)     # imm = 0xFFFFFFFF
movl -0x18(%rax), %r8d
shrl %r8d
movl (%rcx,%r8,8), %r8d
andl %edi, %r8d
cmpl %r8d, -0x10(%rax)
jge 0x1ad3ea
cmpl $0x0, -0x14(%rax)
jle 0x1ad3ea
movl -0x8(%rax), %r8d
shlq $0x20, %r8
movq %rsi, %r9
orq %r10, %r9
orq %r8, %r9
movq 0x148(%rsp), %r8
movq %r9, (%r8,%rdx,8)
incq %rdx
incq %rsi
addq $0x28, %rax
cmpq %rsi, %rbp
jne 0x1ad3aa
cmpq %rbp, %rdx
jne 0x1ae069
movq 0x158(%rsp), %rbx
testq %r15, %r15
movq (%rsp), %r15
jne 0x1ad419
cmpq %rbp, %r12
je 0x1ad4dd
cmpq %rbp, 0x10(%r13)
jae 0x1ad475
leaq -0x1(%rbp), %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 %rbp, 0x8(%r13)
testq %rbp, %rbp
movq 0x148(%rsp), %r9
jle 0x1ad4c5
xorl %eax, %eax
xorl %ecx, %ecx
movq (%r15), %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, %rbp
jne 0x1ad48a
movq (%r15), %rdi
movq (%r13), %rsi
leaq (,%rbp,8), %rax
leaq (%rax,%rax,4), %rdx
callq 0x2160
movq 0x130(%rsp), %rax
movq %rax, 0x70(%rsp)
movq %rbx, %rdi
movq %rbp, %rsi
xorl %edx, %edx
callq 0x3f828
movq 0x28(%rbx), %rax
movq (%rbx), %rcx
movq %rcx, 0x28(%rsp)
movq 0x8(%rbx), %rcx
movq %rcx, 0x20(%rsp)
xorpd %xmm1, %xmm1
movsd 0x40(%rsp), %xmm0
ucomisd %xmm1, %xmm0
movq %rax, 0x10(%rsp)
jb 0x1ad5d2
subq $0x8, %rsp
movq 0x88(%rsp), %rdi
movq 0x80(%rsp), %rsi
movq %r15, %rdx
movq %r13, %rcx
movq 0x138(%rsp), %r8
movq 0x140(%rsp), %r9
pushq %r12
pushq %rax
pushq 0x38(%rsp)
pushq 0x48(%rsp)
pushq 0x198(%rsp)
pushq 0x198(%rsp)
pushq 0x198(%rsp)
pushq 0x190(%rsp)
pushq 0x188(%rsp)
callq 0x1ac67f
addq $0x50, %rsp
movq %rax, %rbx
xorpd %xmm0, %xmm0
ucomisd 0x48(%rsp), %xmm0
ja 0x1ae035
testq %rbx, %rbx
js 0x1ad5be
movq 0x150(%rsp), %rax
movq (%rax), %rsi
movq 0x10(%rax), %rdi
movq (%r15), %rdx
callq 0x1ac4e1
testq %rax, %rax
jne 0x1ae035
movq 0x150(%rsp), %rax
movq $0x0, (%rax)
movq 0x10(%rsp), %rax
leaq (,%r12,8), %rdx
movq %rax, %rdi
xorl %esi, %esi
callq 0x20e0
testq %r12, %r12
movq %r13, 0x40(%rsp)
jle 0x1adcc5
incq 0x70(%rsp)
movq 0x160(%rsp), %rax
sarq %rax
movq %rax, 0xc8(%rsp)
movsd 0x77c5e(%rip), %xmm1    # 0x225270
movsd 0x48(%rsp), %xmm0
addsd %xmm0, %xmm1
movsd %xmm1, 0xc0(%rsp)
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x6c(%rsp)
xorl %edx, %edx
xorl %r11d, %r11d
movq %rbp, 0xe0(%rsp)
movq %r12, 0xd8(%rsp)
movl $0x7fffffff, %r8d       # imm = 0x7FFFFFFF
movq 0x140(%rsp), %r10
movq %r14, 0x58(%rsp)
movq %r11, 0x50(%rsp)
movq (%r15), %rsi
movq %rdx, 0x60(%rsp)
leaq (%rdx,%rdx,4), %rax
movl 0x8(%rsi,%rax,8), %ecx
movl %ecx, %edx
shrl %edx
movl %edx, 0xb0(%rsp)
shll $0x1f, %ecx
movl 0xbc(%rsp), %edx
andl %r8d, %edx
orl %ecx, %edx
movl %edx, 0xbc(%rsp)
movl 0xc(%rsi,%rax,8), %ecx
movl %ecx, 0xb4(%rsp)
movl 0x10(%rsi,%rax,8), %ecx
movl %ecx, 0xb8(%rsp)
movslq 0x14(%rsi,%rax,8), %rcx
movl %ecx, 0xa8(%rsp)
movl 0x18(%rsi,%rax,8), %edx
movl %edx, 0xac(%rsp)
movl 0x8(%rsi,%rax,8), %edx
xorq $0x1, %rdx
movq 0x8(%rsp), %rbp
movq 0x28(%rbp), %rdi
movq (%rdi,%rdx,8), %rdi
movq %rdi, %rdx
movl $0xffffffff, %r8d       # imm = 0xFFFFFFFF
andq %r8, %rdx
je 0x1ad72d
movq 0x8(%rbp), %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 0x1ad6ff
movl %r9d, %edi
movq 0x140(%rsp), %r10
jmp 0x1ad72f
xorl %edi, %edi
addq %rcx, %rdi
xorps %xmm0, %xmm0
cvtsi2sd %rdi, %xmm0
leaq (%rsi,%rax,8), %rbx
mulsd 0x48(%rsp), %xmm0
cvttsd2si %xmm0, %rdx
cmpq %r10, %rdx
cmovleq %r10, %rdx
addq %rdi, %rdx
movq 0x70(%rsp), %rax
cmpq %rax, %rdx
cmovgeq %rax, %rdx
subl $-0x80, %edx
movq 0x60(%rsp), %rdi
callq 0x1ac3e0
movq %rbx, %r10
movq $0x0, 0x8(%r14)
movsd 0x77db9(%rip), %xmm0    # 0x225538
testq %rax, %rax
movq %rbx, 0x18(%rsp)
js 0x1ada6f
movq %rax, %rbx
shlq $0x3, %rax
leaq (%rax,%rax,4), %r12
movq $-0x1, %r13
xorl %r14d, %r14d
movq $0x0, 0x30(%rsp)
movq (%r15), %r15
movl 0x14(%r15,%r12), %eax
cmpl 0x14(%r10), %eax
jge 0x1ad8d1
leaq (%r15,%r12), %rdx
movq %rbp, %rdi
movq %r10, %rsi
callq 0x1ac461
testq %rax, %rax
js 0x1ad8dc
movq %rax, %rdi
movq 0x58(%rsp), %rbp
movq 0x10(%rbp), %rax
cmpq %rax, 0x8(%rbp)
jne 0x1ad81a
leaq (%rax,%rax), %rcx
testq %rax, %rax
movl $0x2, %eax
cmoveq %rax, %rcx
movq %rcx, 0x10(%rbp)
movq %rdi, 0x38(%rsp)
movq (%rbp), %rdi
shlq $0x4, %rcx
leaq (%rcx,%rcx,2), %rsi
callq 0x2370
movq 0x38(%rsp), %rdi
movq %rax, (%rbp)
movq (%rbp), %rax
movq 0x8(%rbp), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x8(%rbp)
leaq (%rcx,%rcx,2), %rcx
shlq $0x4, %rcx
xorpd %xmm0, %xmm0
movupd %xmm0, (%rax,%rcx)
movupd %xmm0, 0x20(%rax,%rcx)
movupd %xmm0, 0x10(%rax,%rcx)
movl 0xc(%rax,%rcx), %edx
movl %edx, %esi
andl $0x7fffffff, %esi       # imm = 0x7FFFFFFF
movl %esi, 0xc(%rax,%rcx)
movl 0x8(%r15,%r12), %esi
xorl $0x1, %esi
movl %esi, (%rax,%rcx)
movl %ebx, %esi
andl $0x3fffffff, %esi       # imm = 0x3FFFFFFF
andl $0x40000000, %edx       # imm = 0x40000000
orl %esi, %edx
movl %edx, 0xc(%rax,%rcx)
movq 0x18(%rsp), %r10
movl 0x14(%r10), %edx
subl 0x18(%r15,%r12), %edx
movl %edx, 0x10(%rax,%rcx)
movl %edi, 0x4(%rax,%rcx)
movl $0x0, 0x8(%rax,%rcx)
movl %esi, 0xc(%rax,%rcx)
cmpq %rdi, %r13
cmovgq %r13, %rdi
movq 0x10(%rsp), %rax
movq 0x60(%rsp), %rdx
cmpq %rdx, (%rax,%rbx,8)
jne 0x1ad8f0
movq 0x30(%rsp), %rax
cmpq 0x160(%rsp), %rax
movq 0x8(%rsp), %rbp
jge 0x1ada59
incq %rax
movq %rax, 0x30(%rsp)
jmp 0x1ad8f5
movq %r13, %rdi
movq %r14, %r13
jmp 0x1ada26
movq %r13, %rdi
movq %r14, %r13
movq (%rsp), %r15
movq 0x18(%rsp), %r10
jmp 0x1ada2a
movq 0x8(%rsp), %rbp
movq 0x28(%rsp), %rax
movslq (%rax,%rbx,4), %rax
testq %rax, %rax
js 0x1ad90c
movq 0x10(%rsp), %rcx
movq %rdx, (%rcx,%rax,8)
movl $0x1, %r13d
testq %r14, %r14
jne 0x1ada26
movl 0x18(%r15,%r12), %eax
subl $-0x80, %eax
cmpl 0x14(%r10), %eax
jle 0x1ada23
movq %rdi, 0x38(%rsp)
movl 0x8(%r15,%r12), %eax
movl %eax, %ecx
shrl %ecx
movl %ecx, 0x94(%rsp)
shll $0x1f, %eax
movl 0xa0(%rsp), %ecx
movl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
andl %edx, %ecx
orl %eax, %ecx
movl %ecx, 0xa0(%rsp)
movl 0xc(%r15,%r12), %eax
movl %eax, 0x98(%rsp)
movl 0x10(%r15,%r12), %eax
movl %eax, 0x9c(%rsp)
movl 0x14(%r15,%r12), %eax
movl %eax, 0x8c(%rsp)
movl 0x18(%r15,%r12), %eax
movl %eax, 0x90(%rsp)
leaq 0xa4(%rsp), %rdi
leaq 0x88(%rsp), %rsi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
movq 0x78(%rsp), %r9
movq %r10, %r14
callq 0x6f050
movl 0x8(%r14), %edx
xorl $0x1, %edx
movl 0x8(%r15,%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 0x77afc(%rip), %xmm0    # 0x2254e8
movq %rax, %r9
callq 0x1a24f3
addq $0x10, %rsp
testq %rax, %rax
je 0x1ada46
xorl %eax, %eax
movq 0x30(%rsp), %rcx
testq %rcx, %rcx
setg %al
subq %rax, %rcx
movq 0xc8(%rsp), %rax
cmpq %rax, %rcx
cmovleq %rax, %rcx
movq %rcx, 0x30(%rsp)
jmp 0x1ada49
xorl %r13d, %r13d
movq (%rsp), %r15
leaq -0x1(%rbx), %rax
addq $-0x28, %r12
movq %r13, %r14
movq %rdi, %r13
testq %rbx, %rbx
movq %rax, %rbx
jg 0x1ad7ab
jmp 0x1ada5d
xorl %r13d, %r13d
movq (%rsp), %r15
movq 0x18(%rsp), %r10
movq 0x38(%rsp), %rdi
jmp 0x1ada2a
movq (%rsp), %r15
xorps %xmm0, %xmm0
cvtsi2sd %rdi, %xmm0
movq 0x40(%rsp), %r13
movq 0x58(%rsp), %r14
movslq 0x1c(%r10), %rbx
movq 0x8(%r14), %rcx
movq $-0x1, %r12
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
testq %rcx, %rcx
je 0x1adc27
mulsd 0xc0(%rsp), %xmm0
cvttsd2si %xmm0, %r9
movq 0x140(%rsp), %rax
cmpq %rax, %r9
cmovleq %rax, %r9
movl 0x8(%r10), %edx
xorl $0x1, %edx
movq (%r14), %r8
subq $0x8, %rsp
xorl %ebp, %ebp
xorpd %xmm0, %xmm0
movq 0xd8(%rsp), %rdi
movq 0x10(%rsp), %rsi
pushq %rbp
pushq $0x1
pushq %rbp
pushq 0x140(%rsp)
pushq 0x170(%rsp)
pushq 0x180(%rsp)
pushq $0xf
callq 0x1a7dd4
addq $0x40, %rsp
movq 0x8(%r14), %rcx
testq %rcx, %rcx
jle 0x1adc3f
movq (%r14), %rdx
addq $0x24, %rdx
xorl %eax, %eax
movq $-0x1, %r12
movq $-0x1, %r14
xorl %ebp, %ebp
movq 0x20(%rsp), %r9
movq 0x140(%rsp), %r10
movq 0x50(%rsp), %r11
movss 0x6c(%rsp), %xmm4
movss 0x7c084(%rip), %xmm5    # 0x229bb8
testl $0x7fffffff, -0x10(%rdx) # imm = 0x7FFFFFFF
je 0x1adc12
movl -0x20(%rdx), %esi
movl -0x8(%rdx), %r8d
subl %esi, %r8d
movl %r8d, %edi
negl %edi
cmovsl %r8d, %edi
xorps %xmm1, %xmm1
cvtsi2ss %edi, %xmm1
xorps %xmm0, %xmm0
cvtsi2ss %esi, %xmm0
mulss %xmm4, %xmm0
ucomiss %xmm0, %xmm1
jbe 0x1adb75
movl $0x80000000, %esi       # imm = 0x80000000
cmpq %r10, %rdi
jg 0x1adbeb
movaps %xmm1, %xmm0
mulss %xmm5, %xmm0
xorps %xmm2, %xmm2
cmpl $0x2, %edi
jb 0x1adbcc
movd %xmm1, %esi
movl %esi, %edi
shrl $0x17, %edi
addl $-0x80, %edi
xorps %xmm1, %xmm1
cvtsi2ss %rdi, %xmm1
andl $0x7fffff, %esi         # imm = 0x7FFFFF
orl $0x3f800000, %esi       # imm = 0x3F800000
movd %esi, %xmm3
movdqa %xmm3, %xmm2
mulss 0x85d1c(%rip), %xmm2    # 0x2338d0
addss 0x85d18(%rip), %xmm2    # 0x2338d4
mulss %xmm3, %xmm2
addss 0x85d10(%rip), %xmm2    # 0x2338d8
addss %xmm1, %xmm2
addss %xmm2, %xmm0
movq 0x18(%rsp), %rsi
movl 0x1c(%rsi), %esi
cvttss2si %xmm0, %edi
subl %edi, %esi
movl -0x18(%rdx), %edi
andl $0x3fffffff, %edi       # imm = 0x3FFFFFFF
addl (%r9,%rdi,8), %esi
movl %esi, %edi
negl %edi
jo 0x1adc12
movslq %esi, %rsi
cmpq %rsi, %rbx
jge 0x1adc12
movl -0x18(%rdx), %ebp
movl -0x8(%rdx), %r14d
movl %ebp, %r12d
andl $0x3fffffff, %r12d      # imm = 0x3FFFFFFF
movl (%rdx), %eax
shrl $0x1f, %ebp
movq %rsi, %rbx
addq $0x30, %rdx
decq %rcx
jne 0x1adb34
shll $0x1f, %ebp
movq %r14, %rsi
jmp 0x1adc58
xorl %ebp, %ebp
xorl %eax, %eax
movq 0x20(%rsp), %r9
movq 0x140(%rsp), %r10
movq 0x50(%rsp), %r11
jmp 0x1adc58
xorl %eax, %eax
movq 0x20(%rsp), %r9
movq 0x140(%rsp), %r10
movq 0x50(%rsp), %r11
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
testq %rbx, %rbx
jns 0x1adc6d
movq 0x18(%rsp), %rcx
movslq 0x1c(%rcx), %rbx
movq $-0x1, %r12
movq 0x60(%rsp), %rdx
movq %rbx, (%r9,%rdx,8)
movq 0x28(%rsp), %rcx
movl %r12d, (%rcx,%rdx,4)
movq 0x18(%rsp), %rcx
movl %esi, 0x20(%rcx)
movl %eax, 0x24(%rcx)
movl 0x4(%rcx), %eax
movl $0x7fffffff, %r8d       # imm = 0x7FFFFFFF
andl %r8d, %eax
orl %ebp, %eax
movl %eax, 0x4(%rcx)
cmpq %r11, %rbx
cmovlq %rbx, %r11
incq %rdx
movq 0xd8(%rsp), %rdi
cmpq %rdi, %rdx
movq 0xe0(%rsp), %rbp
movq 0x58(%rsp), %r14
jne 0x1ad657
jmp 0x1adccf
xorl %edi, %edi
movq 0x20(%rsp), %r9
xorl %r11d, %r11d
cmpq %rbp, %rdi
movq 0x28(%rsp), %r8
jge 0x1add20
leaq (%rdi,%rdi,4), %rax
leaq 0x12(,%rax,4), %rcx
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movq (%r15), %rsi
movslq -0x8(%rsi,%rcx,2), %rax
movq %rax, (%r9,%rdi,8)
movl $0xffffffff, (%r8,%rdi,4) # imm = 0xFFFFFFFF
movq %rdx, -0x4(%rsi,%rcx,2)
andb $0x7f, -0x1d(%rsi,%rcx,2)
cmpq %rax, %r11
cmovlq %r11, %rax
incq %rdi
addq $0x14, %rcx
movq %rax, %r11
cmpq %rdi, %rbp
jne 0x1adcea
jmp 0x1add23
movq %r11, %rax
testq %rbp, %rbp
movq 0x10(%rsp), %r8
jle 0x1add5e
movq %rax, %rcx
shlq $0x20, %rcx
negq %rcx
xorl %edx, %edx
movq (%r9,%rdx,8), %rsi
movq %rsi, %rdi
subq %rax, %rdi
movq %rdi, (%r9,%rdx,8)
shlq $0x20, %rsi
addq %rcx, %rsi
movq %rsi, (%r8,%rdx,8)
incq %rdx
addq $0x2, %rcx
cmpq %rdx, %rbp
jne 0x1add39
movq $0x0, 0x8(%r13)
cmpq %rbp, 0x10(%r13)
jae 0x1addc2
leaq -0x1(%rbp), %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), %rdx
cmpq %rbp, 0x8(%rdx)
jae 0x1ade2a
leaq -0x1(%rbp), %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
callq 0x2370
movq 0x150(%rsp), %rdx
movq %rax, 0x10(%rdx)
movq 0x10(%rdx), %r12
movq 0x10(%rsp), %rdi
leaq (%rdi,%rbp,8), %rsi
callq 0x19525e
testq %rbp, %rbp
jle 0x1adf28
xorl %edx, %edx
xorl %ecx, %ecx
movq $0x0, (%rsp)
movq 0x10(%rsp), %rax
movq %rcx, %r8
movq %rbp, %rsi
decq %rbp
movl -0x8(%rax,%rsi,8), %edi
shrl %edi
leaq (,%rcx,8), %r9
leaq (%r9,%r9,4), %r9
testb $0x1, (%rax,%rdi,8)
jne 0x1adebf
movq (%r15), %r10
leaq (%rdi,%rdi,4), %r11
movq (%r13), %rbx
movq 0x20(%r10,%r11,8), %r14
movq %r14, 0x20(%rbx,%r9)
movupd (%r10,%r11,8), %xmm0
movupd 0x10(%r10,%r11,8), %xmm1
movupd %xmm1, 0x10(%rbx,%r9)
movupd %xmm0, (%rbx,%r9)
orb $0x1, (%rax,%rdi,8)
incq %rcx
movq 0x28(%rsp), %r10
movslq (%r10,%rdi,4), %rdi
addq $0x28, %r9
testq %rdi, %rdi
jns 0x1ade71
movq %rcx, %r9
subq %r8, %r9
je 0x1adf1c
movslq 0x4(%rax,%rbp,8), %r8
testq %rdi, %rdi
js 0x1adeda
movq 0x20(%rsp), %rax
subq (%rax,%rdi,8), %r8
cmpq %rdx, %r8
cmovlq %r8, %rdx
movq %r8, %rdi
notq %rdi
movq %r8, %r10
negq %r10
cmovsq %r8, %r10
movabsq $-0x8000000000000000, %rax # imm = 0x8000000000000000
andq %rax, %rdi
orq %rdi, %r9
shlq $0x20, %r10
orq %r9, %r10
movq (%rsp), %rax
movq %r10, (%r12,%rax,8)
incq %rax
movq %rax, (%rsp)
movq 0x10(%rsp), %rax
cmpq $0x1, %rsi
jg 0x1ade56
jmp 0x1adf34
movq $0x0, (%rsp)
xorl %ecx, %ecx
xorl %edx, %edx
cmpq $0x0, (%rsp)
jle 0x1ae018
movq $-0x1, %rbx
xorl %edi, %edi
movq $-0x1, %r8
xorl %esi, %esi
movq (%r12,%rdi,8), %r10
testq %r10, %r10
js 0x1adf63
shrq $0x20, %r10
negq %r10
jmp 0x1adf7c
movabsq $-0x8000000000000000, %rax # imm = 0x8000000000000000
leaq -0x1(%rax), %r9
andq %r9, %r10
movq %r10, (%r12,%rdi,8)
shrq $0x20, %r10
subl %edx, %r10d
movl (%r12,%rdi,8), %r9d
movl %r10d, 0x4(%r12,%rdi,8)
testq %r9, %r9
je 0x1adff2
leaq (,%rsi,8), %r10
leaq (%r10,%r10,4), %r10
leaq (%r9,%r9,4), %r11
negq %r9
leaq (%r10,%r11,8), %r11
xorl %r14d, %r14d
movq %r15, %rax
movq (%r13), %r15
movq (%rax), %r13
movq -0x8(%r11,%r15), %rbp
movq %rbp, 0x20(%r13,%r10)
movupd -0x28(%r11,%r15), %xmm0
movupd -0x18(%r11,%r15), %xmm1
movupd %xmm1, 0x10(%r13,%r10)
movupd %xmm0, (%r13,%r10)
movq 0x40(%rsp), %r13
decq %r14
addq $-0x28, %r11
addq $0x28, %r10
cmpq %r14, %r9
jne 0x1adfaa
subq %r14, %rsi
movq %rax, %r15
testq %rbx, %rbx
js 0x1ae001
movl 0x4(%r12,%rdi,8), %r9d
cmpq %r9, %r8
jge 0x1ae009
movl 0x4(%r12,%rdi,8), %r8d
movq %rdi, %rbx
incq %rdi
cmpq (%rsp), %rdi
jne 0x1adf51
jmp 0x1ae021
movq $-0x1, %rbx
xorl %esi, %esi
cmpq %rcx, %rsi
jne 0x1ae04a
movq 0x150(%rsp), %rcx
movq (%rsp), %rax
movq %rax, (%rcx)
movq %rbx, %rax
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x85b50(%rip), %rdi     # 0x233ba1
leaq 0x85933(%rip), %rsi     # 0x23398b
leaq 0x8705a(%rip), %rcx     # 0x2350b9
movl $0x175f, %edx           # imm = 0x175F
callq 0x2110
leaq 0x8703f(%rip), %rdi     # 0x2350af
leaq 0x85914(%rip), %rsi     # 0x23398b
leaq 0x8703b(%rip), %rcx     # 0x2350b9
movl $0x16b7, %edx           # imm = 0x16B7
callq 0x2110