// File: /workspace/github_cpp_makefile_star2_O3/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, 0x58(%rsp)
movq %r9, 0xc0(%rsp)
movq %r8, %r13
movq %rcx, %r15
movq %rdx, %r14
movq %rdi, 0xb0(%rsp)
movq 0x160(%rsp), %rcx
movq 0x158(%rsp), %rbp
movq 0x150(%rsp), %r12
movq 0x148(%rsp), %rbx
movq 0x8(%rdx), %rax
movq %rax, 0x18(%rsp)
movq %rsi, 0xb8(%rsp)
movq 0x18(%rsi), %rax
movq %rax, 0xa0(%rsp)
leaq (,%rcx,8), %rdx
movq %rbp, %rdi
xorl %esi, %esi
callq 0x20e0
cmpq $0x0, 0x160(%rsp)
movq %r15, 0x60(%rsp)
jle 0x1b6052
incq %r13
movq $-0x1, 0x98(%rsp)
movq $-0x10, 0x90(%rsp)
xorl %r11d, %r11d
movq $-0x1, 0x40(%rsp)
xorl %r9d, %r9d
movq %r14, 0x28(%rsp)
movq %r13, 0x88(%rsp)
movq %r9, %rbx
movq (%r14), %rsi
leaq (%r11,%r11,4), %r14
movl 0x8(%rsi,%r14,8), %eax
movl %eax, %ecx
shrl %ecx
movl %ecx, 0xd8(%rsp)
shll $0x1f, %eax
movl 0xe4(%rsp), %ecx
movl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
andl %edx, %ecx
orl %eax, %ecx
movl %ecx, 0xe4(%rsp)
movq 0xc(%rsi,%r14,8), %rax
movq %rax, 0xdc(%rsp)
movq 0x14(%rsi,%r14,8), %rax
movq %rax, 0xd0(%rsp)
movl 0x8(%rsi,%r14,8), %ecx
xorq $0x1, %rcx
movq 0xa0(%rsp), %rdi
movq 0x28(%rdi), %rdx
movq (%rdx,%rcx,8), %rdx
movq %rdx, %rcx
movl $0xffffffff, %r8d       # imm = 0xFFFFFFFF
andq %r8, %rcx
je 0x1b5a91
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 0x1b5a6b
movl %r8d, %ecx
jmp 0x1b5a93
xorl %ecx, %ecx
movq %rax, %xmm0
movd %xmm0, %eax
cltq
addq %rcx, %rax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
movq %r14, 0x50(%rsp)
leaq (%rsi,%r14,8), %r14
mulsd 0x58(%rsp), %xmm0
cvttsd2si %xmm0, %rdx
movq 0x120(%rsp), %rcx
cmpq %rcx, %rdx
cmovleq %rcx, %rdx
addq %rax, %rdx
cmpq %r13, %rdx
cmovgeq %r13, %rdx
subl $-0x80, %edx
movq %r11, 0x38(%rsp)
movq %r11, %rdi
callq 0x1b5673
movq %r14, %r10
movq %rax, %r13
movslq 0x1c(%r14), %r12
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 %r12, 0xa8(%rsp)
jge 0x1b5b36
movq $-0x1, 0x20(%rsp)
movq %r12, %r15
movq %r13, %rax
movq 0x38(%rsp), %r11
movq 0x28(%rsp), %r14
jmp 0x1b5cfe
leaq (,%r13,4), %rax
addq %r13, %rax
leaq 0x4(,%rax,4), %rbx
movq $-0x1, 0x20(%rsp)
movq $0x0, 0x30(%rsp)
movq 0x38(%rsp), %r11
movq 0x28(%rsp), %r14
movq %r9, 0x48(%rsp)
movq (%r14), %r15
movl 0x10(%r15,%rbx,2), %ecx
subl $-0x80, %ecx
movl 0x14(%r10), %eax
cmpl %eax, %ecx
jle 0x1b5cf8
cmpl %eax, 0xc(%r15,%rbx,2)
jge 0x1b5c76
movl (%r15,%rbx,2), %eax
movl %eax, %ecx
shrl %ecx
movl %ecx, 0x78(%rsp)
shll $0x1f, %eax
movl 0x84(%rsp), %ecx
movl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
andl %edx, %ecx
orl %eax, %ecx
movl %ecx, 0x84(%rsp)
movq 0x4(%r15,%rbx,2), %rax
movq %rax, 0x7c(%rsp)
movq 0xc(%r15,%rbx,2), %rax
movq %rax, 0x70(%rsp)
leaq 0xcc(%rsp), %rdi
leaq 0x6c(%rsp), %rsi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
movq 0xb8(%rsp), %r9
movq %r10, %r14
callq 0x6ea22
movq %r14, %rbp
movl 0x8(%r14), %edx
xorl $0x1, %edx
movl (%r15,%rbx,2), %ecx
xorl $0x1, %ecx
xorpd %xmm0, %xmm0
movupd %xmm0, (%rsp)
movq 0xb0(%rsp), %rdi
movq 0xc0(%rsp), %rsi
movq 0x120(%rsp), %r8
movsd 0x58(%rsp), %xmm0
movq %rax, %r9
callq 0x1ab640
testq %rax, %rax
je 0x1b5c7b
movq 0x150(%rsp), %rax
movq (%rax,%r13,8), %r15
addq 0xa8(%rsp), %r15
cmpq %r12, %r15
movq 0x38(%rsp), %r11
movq 0x48(%rsp), %r9
jle 0x1b5c92
xorl %eax, %eax
movq 0x30(%rsp), %rcx
testq %rcx, %rcx
setg %al
subq %rax, %rcx
movq %rcx, 0x30(%rsp)
movq %r13, 0x20(%rsp)
movq %rbp, %r10
movq 0x28(%rsp), %r14
jmp 0x1b5cc2
movq %r12, %r15
jmp 0x1b5cdf
movq %r12, %r15
movq 0x38(%rsp), %r11
movq 0x48(%rsp), %r9
movq %rbp, %r10
movq 0x28(%rsp), %r14
jmp 0x1b5cdf
movq 0x158(%rsp), %rax
cmpq %r11, (%rax,%r13,8)
movq %rbp, %r10
movq 0x28(%rsp), %r14
jne 0x1b5cbf
movq 0x30(%rsp), %rax
cmpq 0x130(%rsp), %rax
jge 0x1b5cf8
incq %rax
movq %rax, 0x30(%rsp)
movq %r12, %r15
movq 0x148(%rsp), %rax
movslq (%rax,%r13,4), %rax
testq %rax, %rax
js 0x1b5cdf
movq 0x158(%rsp), %rcx
movq %r11, (%rcx,%rax,8)
leaq -0x1(%r13), %rax
addq $-0x14, %rbx
movq %r15, %r12
cmpq %r9, %r13
movq %rax, %r13
jg 0x1b5b6a
jmp 0x1b5cfe
movq %r12, %r15
movq %r13, %rax
movq 0x40(%rsp), %r13
testq %r13, %r13
movq 0x158(%rsp), %rbp
movq 0x150(%rsp), %r12
movq 0x148(%rsp), %rbx
js 0x1b5d4a
movq (%r14), %rcx
movq 0x50(%rsp), %rdx
movslq 0x18(%rcx,%rdx,8), %rdx
leaq (,%r13,4), %rsi
addq %r13, %rsi
movslq 0x18(%rcx,%rsi,8), %rcx
addq 0x140(%rsp), %rcx
cmpq %rdx, %rcx
jge 0x1b5dad
cmpq %r9, %r11
jle 0x1b5ed2
movq (%r14), %rcx
movq 0x50(%rsp), %rdx
movslq 0x18(%rcx,%rdx,8), %rdx
addq 0x90(%rsp), %rcx
movq $-0x1, %r13
movq $-0x80000000, %rsi      # imm = 0x80000000
movq 0x98(%rsp), %rdi
movslq (%rcx), %r8
addq 0x140(%rsp), %r8
cmpq %rdx, %r8
jl 0x1b5dad
movq (%r12,%rdi,8), %r8
cmpq %r8, %rsi
cmovlq %rdi, %r13
cmovleq %r8, %rsi
leaq -0x1(%rdi), %r8
addq $-0x28, %rcx
cmpq %r9, %rdi
movq %r8, %rdi
jg 0x1b5d7e
testq %r13, %r13
js 0x1b5ee6
cmpq %rax, %r13
jge 0x1b5ee6
movq (%r14), %rax
leaq (,%r13,4), %rcx
addq %r13, %rcx
movl 0x18(%rax,%rcx,8), %esi
subl $-0x80, %esi
movl 0x14(%r10), %edx
cmpl %edx, %esi
jle 0x1b5f07
leaq (%rax,%rcx,8), %rbx
cmpl %edx, 0x14(%rbx)
jge 0x1b5eff
movq %r9, 0x48(%rsp)
movl 0x8(%rbx), %eax
movl %eax, %ecx
shrl %ecx
movl %ecx, 0x78(%rsp)
shll $0x1f, %eax
movl 0x84(%rsp), %ecx
movl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
andl %edx, %ecx
orl %eax, %ecx
movl %ecx, 0x84(%rsp)
movq 0xc(%rbx), %rax
movq %rax, 0x7c(%rsp)
movq 0x14(%rbx), %rax
movq %rax, 0x70(%rsp)
leaq 0xcc(%rsp), %rdi
leaq 0x6c(%rsp), %rsi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
movq 0xb8(%rsp), %r9
movq %r10, %r14
callq 0x6ea22
movq %r14, 0x30(%rsp)
movl 0x8(%r14), %edx
xorl $0x1, %edx
movl 0x8(%rbx), %ecx
xorl $0x1, %ecx
xorpd %xmm0, %xmm0
movupd %xmm0, (%rsp)
movq 0xb0(%rsp), %rdi
movq 0xc0(%rsp), %rsi
movq 0x120(%rsp), %r8
movsd 0x58(%rsp), %xmm0
movq %rax, %r9
callq 0x1ab640
testq %rax, %rax
je 0x1b5eb4
movq 0xa8(%rsp), %rax
addq (%r12,%r13,8), %rax
cmpq %r15, %rax
cmovgq %rax, %r15
movq 0x20(%rsp), %rax
cmovgq %r13, %rax
movq %rax, 0x20(%rsp)
movq 0x148(%rsp), %rbx
movq 0x38(%rsp), %r11
movq 0x48(%rsp), %r9
movq 0x30(%rsp), %r10
movq 0x28(%rsp), %r14
jmp 0x1b5f07
movq %r15, (%r12,%r11,8)
movq 0x20(%rsp), %rax
movl %eax, (%rbx,%r11,4)
movq %r11, 0x40(%rsp)
jmp 0x1b5f4b
movq %r15, (%r12,%r11,8)
movq 0x20(%rsp), %rax
movl %eax, (%rbx,%r11,4)
movq %r11, 0x40(%rsp)
testq %r13, %r13
jns 0x1b5f14
jmp 0x1b5f4b
movq 0x148(%rsp), %rbx
movq %r15, (%r12,%r11,8)
movq 0x20(%rsp), %rax
movl %eax, (%rbx,%r11,4)
movq (%r14), %rax
movq 0x50(%rsp), %rcx
movslq 0x18(%rax,%rcx,8), %rcx
leaq (,%r13,4), %rdx
addq %r13, %rdx
movslq 0x18(%rax,%rdx,8), %rax
addq 0x140(%rsp), %rax
cmpq %rcx, %rax
jl 0x1b5f46
cmpq %r15, (%r12,%r13,8)
cmovlq %r11, %r13
movq %r13, 0x40(%rsp)
movq 0x20(%rsp), %rcx
testq %rcx, %rcx
js 0x1b600a
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 0xa0(%rsp), %rdi
movl %r13d, %esi
movq %r9, %r15
movq %r10, %r14
callq 0x1af06e
movq %r14, %r10
movq 0x28(%rsp), %r14
movq %r15, %r9
movq 0x38(%rsp), %r11
andb $0x7f, 0x7(%r10)
movl %r13d, %ecx
shll $0xf, %ecx
notl %ecx
addl %r13d, %ecx
movl %ecx, %edx
shrl $0xa, %edx
xorl %ecx, %edx
leal (%rdx,%rdx,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
movq (%r14), %rdx
movl 0x8(%rdx,%rbx), %edx
movq 0x148(%rsp), %rbx
xorl $0x1, %edx
movl %edx, %esi
shll $0xf, %esi
notl %esi
addl %edx, %esi
movl %esi, %edx
shrl $0xa, %edx
xorl %esi, %edx
leal (%rdx,%rdx,8), %edx
movl %edx, %esi
shrl $0x6, %esi
xorl %edx, %esi
movl %esi, %edi
shll $0xb, %edi
notl %edi
addl %esi, %edi
movl %edi, %edx
shrl $0x10, %edx
xorl %edi, %edx
addl %ecx, %edx
jmp 0x1b6016
andb $0x7f, 0x7(%r10)
xorl %edx, %edx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movq 0x60(%rsp), %r15
movq 0x88(%rsp), %r13
movl %eax, 0x20(%r10)
movl %edx, 0x24(%r10)
incq %r11
incq 0x98(%rsp)
addq $0x28, 0x90(%rsp)
movq 0x160(%rsp), %rdi
cmpq %rdi, %r11
jne 0x1b59d5
jmp 0x1b6054
xorl %edi, %edi
movq 0x18(%rsp), %rdx
cmpq %rdx, %rdi
jge 0x1b609d
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, (%r12,%rdi,8)
movl $0xffffffff, (%rbx,%rdi,4) # imm = 0xFFFFFFFF
movq %rcx, -0x4(%rdx,%rax,2)
andb $0x7f, -0x1d(%rdx,%rax,2)
movq 0x18(%rsp), %rdx
incq %rdi
addq $0x14, %rax
cmpq %rdi, %rdx
jne 0x1b606f
testq %rdx, %rdx
jle 0x1b60c2
xorl %eax, %eax
movq 0x18(%rsp), %rcx
movq (%r12,%rax,4), %rdx
shlq $0x20, %rdx
addq %rax, %rdx
movq %rdx, (%rbp,%rax,4)
addq $0x2, %rax
decq %rcx
jne 0x1b60a9
movq 0x128(%rsp), %rbx
movq $0x0, 0x8(%r15)
movq 0x18(%rsp), %rcx
cmpq %rcx, 0x10(%r15)
jae 0x1b6136
leaq -0x1(%rcx), %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(%r15)
movq (%r15), %rdi
leaq 0x8(,%rcx,8), %rax
leaq (%rax,%rax,4), %rsi
callq 0x2370
movq 0x18(%rsp), %rcx
movq %rax, (%r15)
cmpq %rcx, 0x8(%rbx)
jae 0x1b6198
leaq -0x1(%rcx), %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 0x18(%rsp), %rcx
movq %rax, %r12
movq %rax, 0x10(%rbx)
jmp 0x1b619c
movq 0x10(%rbx), %r12
leaq (,%rcx,8), %rsi
addq %rbp, %rsi
movq %rbp, %rdi
callq 0x19e008
cmpq $0x0, 0x18(%rsp)
jle 0x1b6363
movabsq $-0x8000000000000000, %rax # imm = 0x8000000000000000
xorl %edx, %edx
xorl %ecx, %ecx
movq %rdx, %r8
movq 0x18(%rsp), %rsi
leaq -0x1(%rsi), %rdi
movq %rdi, 0x18(%rsp)
movl -0x8(%rbp,%rsi,8), %edi
shrl %edi
leaq (,%rdx,8), %r9
leaq (%r9,%r9,4), %r9
testb $0x1, (%rbp,%rdi,8)
jne 0x1b623c
movq (%r14), %r10
leaq (%rdi,%rdi,4), %r11
movq (%r15), %rbx
movq 0x20(%r10,%r11,8), %r13
movq %r13, 0x20(%rbx,%r9)
movupd (%r10,%r11,8), %xmm0
movups 0x10(%r10,%r11,8), %xmm1
movups %xmm1, 0x10(%rbx,%r9)
movupd %xmm0, (%rbx,%r9)
orb $0x1, (%rbp,%rdi,8)
incq %rdx
movq 0x148(%rsp), %r10
movslq (%r10,%rdi,4), %rdi
addq $0x28, %r9
testq %rdi, %rdi
jns 0x1b61ec
movq %rdx, %r9
subq %r8, %r9
je 0x1b6280
movq 0x18(%rsp), %r8
movslq 0x4(%rbp,%r8,8), %r8
testq %rdi, %rdi
js 0x1b625f
movq 0x150(%rsp), %r10
subq (%r10,%rdi,8), %r8
movq %r8, %rdi
negq %rdi
cmovsq %r8, %rdi
notq %r8
andq %rax, %r8
orq %r8, %r9
shlq $0x20, %rdi
orq %r9, %rdi
movq %rdi, (%r12,%rcx,8)
incq %rcx
cmpq $0x1, %rsi
jg 0x1b61c9
testq %rcx, %rcx
jle 0x1b636e
movq $-0x1, %r9
xorl %edi, %edi
movq $-0x1, %r8
xorl %esi, %esi
movq (%r12,%rdi,8), %rax
movq %rax, %r10
shrq $0x20, %r10
movl %r10d, %r11d
andl $0x7fffffff, %r11d      # imm = 0x7FFFFFFF
negl %r10d
testq %rax, %rax
cmovsq %r11, %r10
movl %eax, %eax
shlq $0x20, %r10
orq %rax, %r10
movq %r10, (%r12,%rdi,8)
testq %rax, %rax
je 0x1b6335
leaq (,%rsi,8), %r10
leaq (%r10,%r10,4), %r10
leaq (%rax,%rax,4), %r11
negq %rax
leaq (%r10,%r11,8), %r11
xorl %ebx, %ebx
movq (%r15), %r13
movq (%r14), %rbp
movq -0x8(%r11,%r13), %r15
movq %r15, 0x20(%rbp,%r10)
movq 0x60(%rsp), %r15
movupd -0x28(%r11,%r13), %xmm0
movups -0x18(%r11,%r13), %xmm1
movups %xmm1, 0x10(%rbp,%r10)
movupd %xmm0, (%rbp,%r10)
decq %rbx
addq $-0x28, %r11
addq $0x28, %r10
cmpq %rbx, %rax
jne 0x1b62ef
movq (%r12,%rdi,8), %r10
subq %rbx, %rsi
shrq $0x20, %r10
cmpq %r10, %r8
cmovleq %r10, %r8
movq %r9, %rax
cmovlq %rdi, %rax
testq %r9, %r9
cmovsq %r10, %r8
cmovsq %rdi, %rax
incq %rdi
movq %rax, %r9
cmpq %rcx, %rdi
jne 0x1b62a5
jmp 0x1b6377
xorl %ecx, %ecx
movq $-0x1, %rax
jmp 0x1b637c
movq $-0x1, %rax
xorl %esi, %esi
cmpq %rdx, %rsi
jne 0x1b6399
movq 0x128(%rsp), %rdx
movq %rcx, (%rdx)
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x89ad1(%rip), %rdi     # 0x23fe71
leaq 0x898b4(%rip), %rsi     # 0x23fc5b
leaq 0x8aeea(%rip), %rcx     # 0x241298
movl $0x1695, %edx           # imm = 0x1695
callq 0x2110