// File: /workspace/github_cpp_makefile_star2_O1/chhylp123[P]hifiasm/inter.cpp
// Function: gl_chain_linear(ul_idx_t const*, ma_ug_t const*, vec_mg_lchain_t*, vec_mg_lchain_t*, long, ug_opt_t const*, long, double, st_mt_t*, long, long, long, int*, long*, long*, long, unsigned long)
int64_t gl_chain_linear(const ul_idx_t *uref, const ma_ug_t *ug, vec_mg_lchain_t *lc, 
vec_mg_lchain_t *sw, int64_t qlen, const ug_opt_t *uopt, int64_t bw, double ng_diff_thre, 
st_mt_t *bf, int64_t max_skip, int64_t max_iter, int64_t max_dis, int32_t *p, int64_t *f, 
int64_t *t, int64_t n_ext, uint64_t id)
{
	int64_t i, j, lc_n = lc->n, mm_ovlp, x, m_idx, m_sc, qo, n_skip, k, k0, n_u, n_v, ni;
    int64_t max_f, st, max_ii, sc, csc, mm_sc, mm_idx, end_j, max, n_v0;
    mg_lchain_t *li, *lj; asg_t *g = ug->g; uint64_t *u, ff; ul_ov_t ui, uj;

	memset(t, 0, (n_ext*sizeof((*t))));
	for (i = st = 0, max_ii = -1; 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)*ng_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);
		csc = li->score;
		mm_sc = csc; mm_idx = -1; 
		n_skip = 0; end_j = -1;
		if ((x-st) > max_iter) st = x-max_iter;
		// if(id == 123/** || id == 192**/) {
		// 	fprintf(stderr, "[M::id->%lu::i->%ld::utg%.6d%c] q::[%u, %u); t::[%u, %u); st->%ld; x->%ld\n", id, i, (li->v>>1)+1, "lc"[ug->u.a[li->v>>1].circ], li->qs, li->qe, li->rs, li->re, st, x);
		// }
		for (j = x; j >= st; --j) { // collect potential destination vertices
			lj = &lc->a[j];
			if(lj->qe+G_CHAIN_INDEL <= li->qs) break;
			if(lj->qs >= li->qs) continue;
			set_ul_ov_t_by_mg_lchain_t(&uj, lj);
			qo = infer_rovlp(&ui, &uj, NULL, NULL, NULL, (ma_ug_t *)ug); ///overlap length in query (UL read)
			// if(id == 123/** || id == 192**/) {
			// 	fprintf(stderr, "[M::id->%lu::j->%ld] qo->%ld\n", id, j, qo);
			// }
			if(/**li->v!=lj->v &&**/get_ecov_adv(uref, uopt, li->v^1, lj->v^1, bw, ng_diff_thre, qo, 0, NULL)) {
				sc = csc + f[j];
                if(sc > mm_sc) {
					mm_sc = sc, mm_idx = j;
					if (n_skip > 0) --n_skip;
				} else if (t[j] == i) {
					if (++n_skip > max_skip)
						break;
				}
				if (p[j] >= 0) t[p[j]] = i;
			}
		}

		end_j = j;
		if (max_ii < 0 || (lc->a[i].qe>(lc->a[max_ii].qe+max_dis))) {//too long
			max = INT32_MIN; max_ii = -1;
            for (j = i - 1; (j >= st) && (lc->a[i].qe<=(max_dis+lc->a[j].qe)); --j) {
                if (max < f[j]) {
                    max = f[j], max_ii = j;
                }
            }
		}

		if (max_ii >= 0 && max_ii < end_j) {///just have a try with a[i]<->a[max_ii]
			lj = &(lc->a[max_ii]); 
			if(lj->qe+G_CHAIN_INDEL > li->qs && lj->qs < li->qs) {
				set_ul_ov_t_by_mg_lchain_t(&uj, lj);
				qo = infer_rovlp(&ui, &uj, NULL, NULL, NULL, (ma_ug_t *)ug);///overlap length in query (UL read)
				if(/**li->v!=lj->v &&**/get_ecov_adv(uref, uopt, li->v^1, lj->v^1, bw, ng_diff_thre, qo, 0, NULL)) {
					sc = csc + f[max_ii];
					if(sc > mm_sc) {
						mm_sc = sc; mm_idx = max_ii;
					}
				}
			}
		}

		f[i] = mm_sc; p[i] = mm_idx;
        if ((max_ii < 0) || ((lc->a[i].qe<=max_dis+lc->a[max_ii].qe) && (f[max_ii]<f[i]))) {
            max_ii = i;
        }

		li->dist_pre = mm_idx<0?-1:g_adjacent_dis(g, li->v^1, lc->a[mm_idx].v^1); li->inner_pre = 0;
		li->hash_pre = mm_idx<0?0:(__ac_Wang_hash((li->v^1))+__ac_Wang_hash((lc->a[mm_idx].v^1))); 
    }

	for (; i < lc_n; i++) {
		li = &lc->a[i];
		max_f = li->score; f[i] = max_f; p[i] = -1;
        ///same time for gchain
        li->dist_pre = -1;
        li->hash_pre = 0;
        li->inner_pre = 0;
	}
	
	for (i = 0; i < lc_n; ++i) {///all sc are positive
		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); 
	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 >= 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; 
		}
		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 %xmm0, 0x78(%rsp)
movq %r9, 0xb8(%rsp)
movq %r8, %r13
movq %rcx, %r12
movq %rdx, %r14
movq %rdi, 0xa8(%rsp)
movq 0x160(%rsp), %rcx
movq 0x158(%rsp), %rdi
movq 0x150(%rsp), %rbp
movq 0x148(%rsp), %r15
movq 0x8(%rdx), %rbx
movq %rsi, 0xb0(%rsp)
movq 0x18(%rsi), %rax
movq %rax, 0x98(%rsp)
leaq (,%rcx,8), %rdx
xorl %esi, %esi
callq 0x20e0
cmpq $0x0, 0x160(%rsp)
movq %rbx, 0x30(%rsp)
jle 0x1acde0
movq %r12, 0xe0(%rsp)
incq %r13
movq $-0x1, 0x90(%rsp)
movq $-0x10, 0x88(%rsp)
xorl %r11d, %r11d
movq $-0x1, %r12
xorl %r9d, %r9d
movq %r14, 0x28(%rsp)
movq %r13, 0x80(%rsp)
movq %r9, %rbx
movq (%r14), %rsi
leaq (%r11,%r11,4), %r15
movl 0x8(%rsi,%r15,8), %eax
movl %eax, %ecx
shrl %ecx
movl %ecx, 0xd0(%rsp)
shll $0x1f, %eax
movl 0xdc(%rsp), %ecx
movl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
andl %edx, %ecx
orl %eax, %ecx
movl %ecx, 0xdc(%rsp)
movl 0xc(%rsi,%r15,8), %eax
movl %eax, 0xd4(%rsp)
movl 0x10(%rsi,%r15,8), %eax
movl %eax, 0xd8(%rsp)
movslq 0x14(%rsi,%r15,8), %rax
movl %eax, 0xc8(%rsp)
movl 0x18(%rsi,%r15,8), %ecx
movl %ecx, 0xcc(%rsp)
movl 0x8(%rsi,%r15,8), %ecx
xorq $0x1, %rcx
movq 0x98(%rsp), %rdi
movq 0x28(%rdi), %rdx
movq (%rdx,%rcx,8), %rdx
movq %rdx, %rcx
movl $0xffffffff, %r8d       # imm = 0xFFFFFFFF
andq %r8, %rcx
je 0x1ac819
movq 0x8(%rdi), %rdi
shrq $0x20, %rdx
shlq $0x3, %rcx
leaq (%rcx,%rcx,2), %rcx
leaq (%rdx,%rdx,2), %rdx
leaq (%rdi,%rdx,8), %rdx
addq $0xc, %rdx
xorl %edi, %edi
xorl %r8d, %r8d
movl %r8d, %r9d
movl (%rdx,%rdi), %r10d
cmpl %r10d, %r8d
movl %r10d, %r8d
cmoval %r9d, %r8d
testl %r10d, %r10d
cmovsl %r9d, %r8d
addq $0x18, %rdi
cmpq %rdi, %rcx
jne 0x1ac7f3
movl %r8d, %ecx
jmp 0x1ac81b
xorl %ecx, %ecx
addq %rax, %rcx
cvtsi2sd %rcx, %xmm0
movq %r15, 0x70(%rsp)
leaq (%rsi,%r15,8), %r15
mulsd 0x78(%rsp), %xmm0
cvttsd2si %xmm0, %rdx
movq 0x120(%rsp), %rax
cmpq %rax, %rdx
cmovleq %rax, %rdx
addq %rcx, %rdx
cmpq %r13, %rdx
cmovgeq %r13, %rdx
subl $-0x80, %edx
movq %r11, 0x18(%rsp)
movq %r11, %rdi
callq 0x1ac3e0
movq %r15, %r10
movq %rax, %r13
movslq 0x1c(%r15), %rbp
movq %rbx, %r9
subq %rbx, %rax
movq %r13, %rcx
movq 0x138(%rsp), %rdx
subq %rdx, %rcx
cmpq %rdx, %rax
cmovgq %rcx, %r9
cmpq %r9, %r13
movq %rbp, 0xa0(%rsp)
jge 0x1ac8ab
movq $-0x1, 0x20(%rsp)
movq %rbp, %rbx
movq %r13, %rax
movq 0x18(%rsp), %r11
jmp 0x1aca8a
leaq (,%r13,4), %rax
addq %r13, %rax
leaq 0xc(,%rax,4), %r15
movq $-0x1, 0x20(%rsp)
movq $0x0, 0x48(%rsp)
movq 0x18(%rsp), %r11
movq %r9, 0x40(%rsp)
movq %r12, 0x38(%rsp)
movq (%r14), %rbx
movl (%rbx,%r15,2), %ecx
subl $-0x80, %ecx
movl 0x14(%r10), %eax
cmpl %eax, %ecx
jle 0x1aca84
cmpl %eax, -0x4(%rbx,%r15,2)
jge 0x1aca03
movl -0x10(%rbx,%r15,2), %eax
movl %eax, %ecx
shrl %ecx
movl %ecx, 0x60(%rsp)
shll $0x1f, %eax
movl 0x6c(%rsp), %ecx
movl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
andl %edx, %ecx
orl %eax, %ecx
movl %ecx, 0x6c(%rsp)
movl -0xc(%rbx,%r15,2), %eax
movl %eax, 0x64(%rsp)
movl -0x8(%rbx,%r15,2), %eax
movl %eax, 0x68(%rsp)
movl -0x4(%rbx,%r15,2), %eax
movl %eax, 0x58(%rsp)
movl (%rbx,%r15,2), %eax
movl %eax, 0x5c(%rsp)
leaq 0xc4(%rsp), %rdi
leaq 0x54(%rsp), %rsi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
movq 0xb0(%rsp), %r9
movq %r10, %r12
callq 0x6f050
movq %r12, %r14
movl 0x8(%r12), %edx
xorl $0x1, %edx
movl -0x10(%rbx,%r15,2), %ecx
xorl $0x1, %ecx
xorpd %xmm0, %xmm0
movupd %xmm0, (%rsp)
movq 0xa8(%rsp), %rdi
movq 0xb8(%rsp), %rsi
movq 0x120(%rsp), %r8
movsd 0x78(%rsp), %xmm0
movq %rax, %r9
callq 0x1a24f3
testq %rax, %rax
je 0x1aca08
movq 0x150(%rsp), %rax
movq (%rax,%r13,8), %rbx
addq 0xa0(%rsp), %rbx
cmpq %rbp, %rbx
movq 0x158(%rsp), %rcx
movq 0x18(%rsp), %r11
movq 0x40(%rsp), %r9
movq 0x38(%rsp), %r12
jle 0x1aca27
xorl %eax, %eax
movq 0x48(%rsp), %rdx
testq %rdx, %rdx
setg %al
subq %rax, %rdx
movq %rdx, 0x48(%rsp)
movq %r13, 0x20(%rsp)
movq 0x28(%rsp), %rdx
movq %r14, %r10
jmp 0x1aca53
movq %rbp, %rbx
jmp 0x1aca6b
movq %rbp, %rbx
movq 0x18(%rsp), %r11
movq 0x40(%rsp), %r9
movq 0x28(%rsp), %rax
movq %r14, %r10
movq %rax, %r14
movq 0x38(%rsp), %r12
jmp 0x1aca6b
cmpq %r11, (%rcx,%r13,8)
movq 0x28(%rsp), %rdx
movq %r14, %r10
jne 0x1aca50
movq 0x48(%rsp), %rax
cmpq 0x130(%rsp), %rax
jge 0x1acdc0
incq %rax
movq %rax, 0x48(%rsp)
movq %rbp, %rbx
movq 0x148(%rsp), %rax
movslq (%rax,%r13,4), %rax
testq %rax, %rax
js 0x1aca68
movq %r11, (%rcx,%rax,8)
movq %rdx, %r14
leaq -0x1(%r13), %rax
addq $-0x14, %r15
movq %rbx, %rbp
cmpq %r9, %r13
movq %rax, %r13
jg 0x1ac8df
jmp 0x1aca8a
movq %rbp, %rbx
movq %r13, %rax
testq %r12, %r12
movq 0x150(%rsp), %rbp
movq 0x148(%rsp), %r15
movq 0x140(%rsp), %r13
js 0x1acac5
movq (%r14), %rcx
movq 0x70(%rsp), %rdx
movslq 0x18(%rcx,%rdx,8), %rdx
leaq (%r12,%r12,4), %rsi
movslq 0x18(%rcx,%rsi,8), %rcx
addq %r13, %rcx
cmpq %rdx, %rcx
jge 0x1acb20
movq $-0x1, %r12
cmpq %r9, %r11
jle 0x1acb20
movq (%r14), %rcx
movq 0x70(%rsp), %rdx
movslq 0x18(%rcx,%rdx,8), %rdx
addq 0x88(%rsp), %rcx
movq $-0x80000000, %rsi      # imm = 0x80000000
movq 0x90(%rsp), %rdi
movslq (%rcx), %r8
addq %r13, %r8
cmpq %rdx, %r8
jl 0x1acb20
movq (%rbp,%rdi,8), %r8
cmpq %r8, %rsi
cmovlq %rdi, %r12
cmovleq %r8, %rsi
leaq -0x1(%rdi), %r8
addq $-0x28, %rcx
cmpq %r9, %rdi
movq %r8, %rdi
jg 0x1acaf5
testq %r12, %r12
js 0x1acc77
cmpq %rax, %r12
jge 0x1acc77
movq (%r14), %rax
leaq (%r12,%r12,4), %rcx
movl 0x18(%rax,%rcx,8), %esi
subl $-0x80, %esi
movl 0x14(%r10), %edx
cmpl %edx, %esi
jle 0x1acc77
leaq (%rax,%rcx,8), %r15
cmpl %edx, 0x14(%r15)
jge 0x1acc4e
movq %r12, 0x38(%rsp)
movq %r9, 0x40(%rsp)
movl 0x8(%r15), %eax
movl %eax, %ecx
shrl %ecx
movl %ecx, 0x60(%rsp)
shll $0x1f, %eax
movl 0x6c(%rsp), %ecx
movl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
andl %edx, %ecx
orl %eax, %ecx
movl %ecx, 0x6c(%rsp)
movl 0xc(%r15), %eax
movl %eax, 0x64(%rsp)
movl 0x10(%r15), %eax
movl %eax, 0x68(%rsp)
movl 0x14(%r15), %eax
movl %eax, 0x58(%rsp)
movl 0x18(%r15), %eax
movl %eax, 0x5c(%rsp)
leaq 0xc4(%rsp), %rdi
leaq 0x54(%rsp), %rsi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
movq 0xb0(%rsp), %r9
movq %r10, %r14
callq 0x6f050
movq %r14, %r12
movl 0x8(%r14), %edx
xorl $0x1, %edx
movl 0x8(%r15), %ecx
xorl $0x1, %ecx
xorpd %xmm0, %xmm0
movupd %xmm0, (%rsp)
movq 0xa8(%rsp), %rdi
movq 0xb8(%rsp), %rsi
movq 0x120(%rsp), %r8
movsd 0x78(%rsp), %xmm0
movq %rax, %r9
callq 0x1a24f3
testq %rax, %rax
je 0x1acc58
movq 0x38(%rsp), %rax
movq 0xa0(%rsp), %rcx
addq (%rbp,%rax,8), %rcx
cmpq %rbx, %rcx
cmovgq %rcx, %rbx
movq 0x20(%rsp), %rcx
cmovgq %rax, %rcx
movq 0x148(%rsp), %r15
movq 0x18(%rsp), %r11
movq 0x40(%rsp), %r9
movq %r12, %r10
movq %rax, %r12
movq 0x28(%rsp), %r14
jmp 0x1acc7c
movq 0x148(%rsp), %r15
jmp 0x1acc77
movq 0x148(%rsp), %r15
movq 0x18(%rsp), %r11
movq 0x40(%rsp), %r9
movq %r12, %r10
movq 0x28(%rsp), %r14
movq 0x38(%rsp), %r12
movq 0x20(%rsp), %rcx
movq %rbx, (%rbp,%r11,8)
movl %ecx, (%r15,%r11,4)
testq %r12, %r12
js 0x1accba
movq %rcx, %rsi
movq (%r14), %rax
movq 0x70(%rsp), %rcx
movslq 0x18(%rax,%rcx,8), %rcx
leaq (%r12,%r12,4), %rdx
movslq 0x18(%rax,%rdx,8), %rax
addq %r13, %rax
cmpq %rcx, %rax
jge 0x1accb0
movq %rsi, %rcx
jmp 0x1accbd
cmpq %rbx, (%rbp,%r12,8)
movq %rsi, %rcx
jge 0x1accbd
movq %r11, %r12
testq %rcx, %rcx
js 0x1acd79
movl 0x8(%r10), %r13d
xorl $0x1, %r13d
movq (%r14), %rax
shlq $0x3, %rcx
leaq (%rcx,%rcx,4), %rbx
movl 0x8(%rax,%rbx), %edx
xorl $0x1, %edx
movq 0x98(%rsp), %rdi
movl %r13d, %esi
movq %r9, %r14
movq %r12, %rbp
movq %r10, %r12
callq 0x1a5df0
movq %r12, %r10
movq %rbp, %r12
movq %r14, %r9
movq 0x28(%rsp), %r14
movq 0x18(%rsp), %r11
movl %eax, 0x20(%r10)
andb $0x7f, 0x7(%r10)
movl %r13d, %eax
shll $0xf, %eax
notl %eax
addl %r13d, %eax
movl %eax, %ecx
shrl $0xa, %ecx
xorl %eax, %ecx
leal (%rcx,%rcx,8), %eax
movl %eax, %ecx
shrl $0x6, %ecx
xorl %eax, %ecx
movl %ecx, %edx
shll $0xb, %edx
notl %edx
addl %ecx, %edx
movl %edx, %eax
shrl $0x10, %eax
xorl %edx, %eax
movq (%r14), %rcx
movl 0x8(%rcx,%rbx), %ecx
xorl $0x1, %ecx
movl %ecx, %edx
shll $0xf, %edx
notl %edx
addl %ecx, %edx
movl %edx, %ecx
shrl $0xa, %ecx
xorl %edx, %ecx
leal (%rcx,%rcx,8), %ecx
movl %ecx, %edx
shrl $0x6, %edx
xorl %ecx, %edx
movl %edx, %esi
shll $0xb, %esi
notl %esi
addl %edx, %esi
movl %esi, %ecx
shrl $0x10, %ecx
xorl %esi, %ecx
addl %eax, %ecx
jmp 0x1acd88
movl $0xffffffff, 0x20(%r10) # imm = 0xFFFFFFFF
andb $0x7f, 0x7(%r10)
xorl %ecx, %ecx
movq 0x30(%rsp), %rbx
movq 0x80(%rsp), %r13
movl %ecx, 0x24(%r10)
incq %r11
incq 0x90(%rsp)
addq $0x28, 0x88(%rsp)
movq 0x160(%rsp), %rdi
cmpq %rdi, %r11
jne 0x1ac747
jmp 0x1acdce
movq %rbp, %rbx
movq %r13, %rax
movq %rdx, %r14
jmp 0x1aca8a
movq 0xe0(%rsp), %r12
movq 0x150(%rsp), %rbp
jmp 0x1acde2
xorl %edi, %edi
cmpq %rbx, %rdi
jge 0x1ace23
leaq (%rdi,%rdi,4), %rax
leaq 0x12(,%rax,4), %rax
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
movq (%r14), %rdx
movslq -0x8(%rdx,%rax,2), %rsi
movq %rsi, (%rbp,%rdi,8)
movl $0xffffffff, (%r15,%rdi,4) # imm = 0xFFFFFFFF
movq %rcx, -0x4(%rdx,%rax,2)
andb $0x7f, -0x1d(%rdx,%rax,2)
incq %rdi
addq $0x14, %rax
cmpq %rdi, %rbx
jne 0x1acdf8
testq %rbx, %rbx
movq 0x158(%rsp), %rsi
jle 0x1ace4e
xorl %eax, %eax
movq %rbx, %rcx
movq (%rbp,%rax,4), %rdx
shlq $0x20, %rdx
addq %rax, %rdx
movq %rdx, (%rsi,%rax,4)
addq $0x2, %rax
decq %rcx
jne 0x1ace35
movq 0x128(%rsp), %r13
movq $0x0, 0x8(%r12)
cmpq %rbx, 0x10(%r12)
jae 0x1acebd
leaq -0x1(%rbx), %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(%r12)
movq (%r12), %rdi
leaq 0x8(,%rcx,8), %rax
leaq (%rax,%rax,4), %rsi
callq 0x2370
movq %rax, (%r12)
cmpq %rbx, 0x8(%r13)
jae 0x1acf15
leaq -0x1(%rbx), %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(%r13)
movq 0x10(%r13), %rdi
leaq 0x8(,%rcx,8), %rsi
callq 0x2370
movq %rax, 0x10(%r13)
movq 0x10(%r13), %r13
movq 0x158(%rsp), %rdi
leaq (%rdi,%rbx,8), %rsi
callq 0x19525e
testq %rbx, %rbx
jle 0x1ad00e
xorl %edx, %edx
movq $0x0, 0x18(%rsp)
movq 0x158(%rsp), %rcx
movq %rdx, %rdi
movq 0x30(%rsp), %rax
leaq -0x1(%rax), %rsi
movq %rsi, 0x30(%rsp)
movl -0x8(%rcx,%rax,8), %esi
shrl %esi
leaq (,%rdx,8), %r8
leaq (%r8,%r8,4), %r8
testb $0x1, (%rcx,%rsi,8)
jne 0x1acfb0
movq (%r14), %r9
leaq (%rsi,%rsi,4), %r10
movq (%r12), %r11
movq 0x20(%r9,%r10,8), %rbx
movq %rbx, 0x20(%r11,%r8)
movupd (%r9,%r10,8), %xmm0
movups 0x10(%r9,%r10,8), %xmm1
movups %xmm1, 0x10(%r11,%r8)
movupd %xmm0, (%r11,%r8)
orb $0x1, (%rcx,%rsi,8)
incq %rdx
movslq (%r15,%rsi,4), %rsi
addq $0x28, %r8
testq %rsi, %rsi
jns 0x1acf69
movq %rdx, %r8
subq %rdi, %r8
je 0x1ad002
movq 0x30(%rsp), %rdi
movslq 0x4(%rcx,%rdi,8), %rdi
testq %rsi, %rsi
js 0x1acfcc
subq (%rbp,%rsi,8), %rdi
movq %rdi, %rsi
negq %rsi
cmovsq %rdi, %rsi
notq %rdi
movabsq $-0x8000000000000000, %r9 # imm = 0x8000000000000000
andq %r9, %rdi
orq %rdi, %r8
shlq $0x20, %rsi
orq %r8, %rsi
movq 0x18(%rsp), %rdi
movq %rsi, (%r13,%rdi,8)
incq %rdi
movq %rdi, 0x18(%rsp)
cmpq $0x1, %rax
jg 0x1acf46
jmp 0x1ad019
movq $0x0, 0x18(%rsp)
xorl %edx, %edx
cmpq $0x0, 0x18(%rsp)
jle 0x1ad0f6
movq $-0x1, %rax
xorl %edi, %edi
movq $-0x1, %r8
xorl %esi, %esi
movq (%r13,%rdi,8), %r10
testq %r10, %r10
js 0x1ad04a
shrq $0x20, %r10
negq %r10
jmp 0x1ad064
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
leaq -0x1(%rcx), %r9
andq %r9, %r10
movq %r10, (%r13,%rdi,8)
shrq $0x20, %r10
movl (%r13,%rdi,8), %r9d
movl %r10d, 0x4(%r13,%rdi,8)
testq %r9, %r9
je 0x1ad0cf
leaq (,%rsi,8), %r10
leaq (%r10,%r10,4), %r10
leaq (%r9,%r9,4), %r11
negq %r9
leaq (%r10,%r11,8), %r11
xorl %ebx, %ebx
movq (%r12), %rbp
movq (%r14), %r15
movq %r12, %rcx
movq -0x8(%r11,%rbp), %r12
movq %r12, 0x20(%r15,%r10)
movq %rcx, %r12
movupd -0x28(%r11,%rbp), %xmm0
movups -0x18(%r11,%rbp), %xmm1
movups %xmm1, 0x10(%r15,%r10)
movupd %xmm0, (%r15,%r10)
decq %rbx
addq $-0x28, %r11
addq $0x28, %r10
cmpq %rbx, %r9
jne 0x1ad08c
subq %rbx, %rsi
testq %rax, %rax
js 0x1ad0de
movl 0x4(%r13,%rdi,8), %r9d
cmpq %r9, %r8
jge 0x1ad0e6
movl 0x4(%r13,%rdi,8), %r8d
movq %rdi, %rax
incq %rdi
cmpq 0x18(%rsp), %rdi
jne 0x1ad037
jmp 0x1ad0ff
movq $-0x1, %rax
xorl %esi, %esi
cmpq %rdx, %rsi
jne 0x1ad126
movq 0x128(%rsp), %rcx
movq 0x18(%rsp), %rdx
movq %rdx, (%rcx)
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x86a74(%rip), %rdi     # 0x233ba1
leaq 0x86857(%rip), %rsi     # 0x23398b
leaq 0x87e8d(%rip), %rcx     # 0x234fc8
movl $0x1695, %edx           # imm = 0x1695
callq 0x2110