// File: /workspace/github_cpp_makefile_star2_O2/chhylp123[P]hifiasm/inter.cpp
// Function: mg_gchain1_dp(void*, ma_ug_t const*, asg_t const*, int*, mg_lchain_t*, int, int, int, int, int, int, float, float, int, ug_opt_t const*, mg128_t const*, unsigned long**)
int32_t mg_gchain1_dp(void *km, const ma_ug_t *ug, const asg_t *rg, int32_t *n_lc_, mg_lchain_t *lc, int32_t qlen, int32_t max_dist_g, int32_t max_dist_q, int32_t bw, int32_t max_skip,
                      int32_t ref_bonus, float chn_pen_gap, float mask_level, int32_t max_gc_seq_ext, const ug_opt_t *uopt, const mg128_t *an, uint64_t **u_)
{
    int32_t i, j, k, m_dst, n_dst, n_ext, n_u, n_v, n_lc = *n_lc_, rrs, rre;
    int32_t *f, *v, *t, li_qs, li_qe, li_rs, li_re, lj_qs, lj_qe, lj_rs, lj_re;
    int64_t *p;
    uint64_t *u;
    mg_path_dst_t *dst;
    gc_frag_t *a;
    mg_lchain_t *swap;
    // char *qs;
    asg_t *g = ug->g;

    *u_ = 0;
    if (n_lc == 0) return 0;

	// extend_lchain(lc, n_lc, qlen, ug);
    KMALLOC(km, a, n_lc);
    ///n_lc how many linear chains; just filter some linear chains
    for (i = n_ext = 0; i < n_lc; ++i) { // a[] is a view of frag[]; for sorting
        mg_lchain_t *r = &lc[i];
        gc_frag_t *ai = &a[i];
        int32_t is_isolated = 0, min_end_dist_g;
		transfor_coord(r, qlen, ug->u.a[r->v>>1].len, NULL, NULL, &rrs, &rre);
        r->dist_pre = -1;///indicate parent in graph chain
        min_end_dist_g = g->seq[r->v>>1].len - rre;///r->v: ref_id|rev
        if (rrs < min_end_dist_g) min_end_dist_g = rrs;
        if (min_end_dist_g > max_dist_g) is_isolated = 1; // if too far from segment ends
        else if (min_end_dist_g>>3 > r->score) is_isolated = 1; // if the lchain too small relative to distance to the segment ends
        ai->srt = (uint32_t)is_isolated<<31 | r->qe;
        ai->i = i;
        if (!is_isolated) ++n_ext;
    }
    ///if the alignment is too far from segment ends, which means it cannot contribute to graph alignment
    if (n_ext < 2) { // no graph chaining needed; early return
        kfree(km, a);
        KMALLOC(km, u, n_lc);
        for (i = 0; i < n_lc; ++i)
            u[i] = (uint64_t)lc[i].score<<32 | 1;
        *u_ = u;
		// compress_lchain(lc, n_lc, qlen, ug, an);
        return n_lc;
    }
    radix_sort_gc(a, a + n_lc);///sort by: is_isolated(1):qe

    KMALLOC(km, v, n_lc);
    KMALLOC(km, f, n_ext);
    KMALLOC(km, p, n_ext);
    KCALLOC(km, t, n_ext);
    // KMALLOC(km, qs, max_dist_q + 1);//for 

    m_dst = n_dst = 0, dst = 0;
    ///n_ext is number of linear chains that might be included in graph chains
    ///sorted by the positions in query; sorted by qe of each chain
    for (i = 0; i < n_ext; ++i) { // core loop
        gc_frag_t *ai = &a[i];
        mg_lchain_t *li = &lc[ai->i];///linear chain; sorted by qe, i.e. end position in query
		int32_t mm_ovlp = max_ovlp(ug->g, li->v^1);
		transfor_coord(li, qlen, ug->u.a[li->v>>1].len, &li_qs, &li_qe, &li_rs, &li_re);
        ///note segi is query id, instead of ref id; it is not such useful
        /**
         * a[].x: idx_in_minimizer_arr(32)r_pos(32)
         * a[].y: weight(8)query_id(8)flag(8)span(8)q_pos(32)
        **/
        { // collect end points potentially reachable from _i_
            int32_t x = li->qs + bw + mm_ovlp, n_skip = 0;
            if (x > qlen) x = qlen;
            ///collect alignments that can be reachable from the left side
            ///that is, a[x].qe <= x
            x = find_max(i, a, x);
            n_dst = 0;
            for (j = x; j >= 0; --j) { // collect potential destination vertices
                gc_frag_t *aj = &a[j];
                //potential chains that might be overlapped with the left side of li
                mg_lchain_t *lj = &lc[aj->i];
                mg_path_dst_t *q;
                int32_t target_dist, dq/**, so = specific_ovlp(ug, uopt, li->v^1, lj->v^1)**/;
				transfor_coord(lj, qlen, ug->u.a[lj->v>>1].len, &lj_qs, &lj_qe, &lj_rs, &lj_re);
                ///lj->qs >= li->qs && lj->qe <= li->qs, so lj is contained
                if (lj->qs >= li->qs) continue; // lj is contained in li on the query coordinate
				/**
				  * doesn't work for overlap graph
                if (lj_qe > li_qs) { // test overlap on the query
                    int o = lj_qe - li_qs - so;///get_lchain_ovlp(lj, li, ug->g, qlen, ug); 
					///mask_level = 0.5, if overlap is too long
                    ///note here is the overlap in query, so too long overlaps might be wrong
                    if (o > (lj->qe - lj->qs) * mask_level || o > (li->qe - li->qs) * mask_level)
                        continue;
                }
				**/
                dq = li_qs - lj_qe;///dq might be smaller than 0
                if (dq > max_dist_q) break; // if query gap too large, stop
                ///The above filter chains like:
                ///1. lj is contained in li
                ///2. the overlap between li and lj is too large
                ///3. li and lj are too far
                ///above we have checked gap/overlap in query 
                ///then we need to check gap/overlap in reference
                if (li->v != lj->v) { // the two linear chains are on two different refs
                    // minimal graph gap; the real graph gap might be larger
                    int32_t min_dist = li_rs + (g->seq[lj->v>>1].len - lj_re); 
                    if (min_dist > max_dist_g) continue; // graph gap too large
                    //note here min_dist - (lj->qs - li->qe) > bw is important
                    //min_dist is always larger than 0, (lj->qs - li->qe) might be negative 
					/**
				  	  * doesn't work for overlap graph
					min_dist -= so;
					if (min_dist - bw > li->qs - lj->qe) continue; ///note seg* is the query id, instead of ref id
					**/
					target_dist = mg_target_dist(g, lj, li);
                    if (target_dist < 0) continue; // this may happen if the query overlap is far too large
                } else if (lj->rs >= li->rs || lj->re >= li->re) { // not colinear
                    continue;
                } else {///li->v == lj->v and colinear; at the same ref id
                    ///w is indel, w is always positive
                    int32_t dr = li->rs - lj->re, dq = li->qs - lj->qe, w = dr > dq? dr - dq : dq - dr;
                    ///note that l*->v is the ref id, while seg* is the query id
                    if (w > bw) continue; // test bandwidth
                    if (dr > max_dist_g || dr < -max_dist_g) continue;
                    if (lj->re > li->rs) { // test overlap on the graph segment
                        int o = lj->re - li->rs;
                        if (o > (lj->re - lj->rs) * mask_level || o > (li->re - li->rs) * mask_level)
                            continue;
                    }
                    target_dist = mg_target_dist(g, lj, li);
                }
                if (n_dst == m_dst) KEXPAND(km, dst, m_dst); // TODO: watch out the quadratic behavior!
                q = &dst[n_dst++];///q saves information for i->j
                memset(q, 0, sizeof(mg_path_dst_t));
                ///note v is (rid:rev), so two alignment chains might be at the same ref id with different directions
                q->inner = (li->v == lj->v);
                q->v = lj->v^1;///must be v^1 instead of v
                q->meta = j;
                q->qlen = li->qs - lj->qe;///might be negative
				/**
				  * doesn't work for overlap graph
				q->so = 0;
				if(li->v != lj->v && lj->qe > li->qs) {
					lj_qe = lj->qe; li_qs = li->qs + g->seq[lj->v>>1].len - so;
					q->so = lj_qe - li_qs;
					if(q->so < 0) q->so = 0;
				}
				**/
                q->target_dist = target_dist;///cannot understand the target_dist
                q->target_hash = 0;
                q->check_hash = 0;
                if (t[j] == i) {///this pre-cut is weird; attention
                    if (++n_skip > max_skip)
                        break;
                }
                if (p[j] >= 0) t[p[j]] = i;
            }
        }
        ///the above saves all linear chains that might be reached to the left side of chain i
        ///all those chains are saved to dst<n_dst>
        { // confirm reach-ability
            int32_t k;
            // test reach-ability without sequences
            // (g->seg[li->v>>1].len - li->rs) ----> is like the node length in string graph
            mg_shortest_k(km, g, li->v^1, n_dst, dst, max_dist_g + (g->seq[li->v>>1].len - li->rs), MG_MAX_SHORT_K, /**0, 0, 1,**/ 0);
            // remove unreachable destinations
            for (j = k = 0; j < n_dst; ++j) {
                mg_path_dst_t *dj = &dst[j];
                int32_t sc;
                if (dj->n_path == 0) continue; // unreachable
                sc = cal_sc(dj, li, lc, an, a, f, bw, ref_bonus, chn_pen_gap);
                if (sc == INT32_MIN) continue; // out of band
                if (sc + li->score < 0) continue; // negative score and too low
                dst[k] = dst[j];
                dst[k++].srt_key = INT64_MAX/2 - (int64_t)sc; // sort in the descending order
            }
            n_dst = k;
            if (n_dst > 0) {
                radix_sort_dst(dst, dst + n_dst);
                // discard weaker chains if the best score is much larger (assuming base-level heuristic won't lift it to the top chain)
                // dst[0].srt_key has the largest score
                for (j = 1; j < n_dst; ++j) 
                    if ((int64_t)(dst[j].srt_key - dst[0].srt_key) > li->score)//discard chains with too small weight
                        break;
                n_dst = j;
                if (n_dst > max_gc_seq_ext) n_dst = max_gc_seq_ext; // discard weaker chains
            }
        }
		/** //path
        if (n_dst > 0) { // find paths with sequences
            int32_t min_qs = li->qs;
            for (j = 0; j < n_dst; ++j) {
                const mg_lchain_t *lj;
                assert(dst[j].n_path > 0);
                ///a[]->srt = (uint32_t)is_isolated<<31 | r->qe;
                ///a[]->i = i;
                lj = &lc[a[dst[j].meta].i];
                if (lj->qe < min_qs) min_qs = lj->qe;
            }
            ///qs keeps the sequence at the gap between the li and lj in query
            memcpy(qs, &qseq[min_qs], li->qs - min_qs);
            mg_shortest_k(km, g, li->v^1, n_dst, dst, max_dist_g + (g->seg[li->v>>1].len - li->rs), MG_MAX_SHORT_K, li->qs - min_qs, qs, 1, 0);
            if (mg_dbg_flag & MG_DBG_GC1) fprintf(stderr, "[src:%d] q_intv=[%d,%d), src=%c%s[%d], n_dst=%d, max_dist=%d, min_qs=%d, lc_score=%d\n", ai->i, li->qs, li->qe, "><"[(li->v&1)^1], g->seg[li->v>>1].name, li->v^1, n_dst, max_dist_g + (g->seg[li->v>>1].len - li->rs), min_qs, li->score);
        }**/
        { // DP
            int32_t max_f = li->score, max_j = -1, max_d = -1, max_inner = 0;
            uint32_t max_hash = 0;
            for (j = 0; j < n_dst; ++j) {
                mg_path_dst_t *dj = &dst[j];
                int32_t sc;
                sc = cal_sc(dj, li, lc, an, a, f, bw, ref_bonus, chn_pen_gap);
                if (sc == INT32_MIN) continue;
                if (sc > max_f) max_f = sc, max_j = dj->meta, max_d = dj->dist, max_hash = dj->hash, max_inner = dj->inner;
            }
            f[i] = max_f, p[i] = max_j;
            li->dist_pre = max_d;
            li->hash_pre = max_hash;
            li->inner_pre = max_inner;
            v[i] = max_j >= 0 && v[max_j] > max_f? v[max_j] : max_f;
        }
    }
    kfree(km, dst);

	// print_gchain(a, p, lc, n_ext, ug, qlen);

    // kfree(km, qs);
    ///n_ext: number of useful chains
    ///n_lc - n_ext: number of isoated chains
    u = mg_chain_backtrack(km, n_ext, f, p, v, t, 0, 0, n_lc - n_ext, &n_u, &n_v);
    kfree(km, f); kfree(km, p); kfree(km, t);
    ///store the extra isoated chains
    for (i = 0; i < n_lc - n_ext; ++i) {
        u[n_u++] = (uint64_t)lc[a[n_ext + i].i].score << 32 | 1;
        v[n_v++] = n_ext + i;
    }

    ///reorganize lc;
    KMALLOC(km, swap, n_v);
    for (i = 0, k = 0; i < n_u; ++i) {
        int32_t k0 = k, ni = (int32_t)u[i];
        for (j = 0; j < ni; ++j)
            swap[k++] = lc[a[v[k0 + (ni - j - 1)]].i];
    }
    assert(k == n_v);
    memcpy(lc, swap, n_v * sizeof(mg_lchain_t));
    *n_lc_ = n_v;
    *u_ = u;
	// compress_lchain(lc, *n_lc_, qlen, ug, an);

    kfree(km, a);
    kfree(km, swap);
    kfree(km, v);
    return n_u;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x108, %rsp            # imm = 0x108
movss %xmm0, 0x84(%rsp)
movq 0x180(%rsp), %rax
movslq (%rcx), %rbx
movq %rsi, 0xb8(%rsp)
movq 0x18(%rsi), %rdx
movq %rdx, 0x58(%rsp)
andq $0x0, (%rax)
testq %rbx, %rbx
je 0x15db86
movl %r9d, %ebp
movss %xmm1, 0xc8(%rsp)
movq %rcx, 0xf0(%rsp)
leaq (,%rbx,8), %rsi
movq %rdi, 0x50(%rsp)
movq %rsi, 0x48(%rsp)
movq %r8, 0x40(%rsp)
callq 0x1a39c4
movq %rax, 0x38(%rsp)
movslq %ebp, %rax
movq %rax, 0xb0(%rsp)
xorl %ebp, %ebp
testl %ebx, %ebx
movl $0x0, %r13d
movq %rbx, 0x98(%rsp)
cmovgl %ebx, %r13d
movq 0x40(%rsp), %r12
xorl %r15d, %r15d
cmpq %rbp, %r13
je 0x15db2f
movq 0xb8(%rsp), %rax
movq 0x10(%rax), %rax
movl 0x8(%r12), %r14d
shrl %r14d
imulq $0x28, %r14, %rcx
movl (%rax,%rcx), %edx
andl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
leaq 0xe0(%rsp), %rax
movq %rax, (%rsp)
xorl %ebx, %ebx
movq %r12, %rdi
movq 0xb0(%rsp), %rsi
xorl %ecx, %ecx
xorl %r8d, %r8d
leaq 0xe4(%rsp), %r9
callq 0x15d0dd
orl $-0x1, 0x20(%r12)
movq 0x58(%rsp), %rax
movq 0x20(%rax), %rax
movl (%rax,%r14,8), %ecx
movl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
andl %eax, %ecx
subl 0xe0(%rsp), %ecx
movl 0xe4(%rsp), %eax
cmpl %ecx, %eax
cmovll %eax, %ecx
movl $0x80000000, %eax       # imm = 0x80000000
cmpl 0x140(%rsp), %ecx
jg 0x15db0c
sarl $0x3, %ecx
xorl %eax, %eax
xorl %ebx, %ebx
cmpl 0x1c(%r12), %ecx
setg %al
setle %bl
shll $0x1f, %eax
orl 0x18(%r12), %eax
movq 0x38(%rsp), %rcx
movl %eax, (%rcx,%rbp,8)
movl %ebp, 0x4(%rcx,%rbp,8)
addl %r15d, %ebx
incq %rbp
addq $0x28, %r12
movl %ebx, %r15d
jmp 0x15da67
cmpl $0x1, %r15d
ja 0x15db8d
movq 0x50(%rsp), %rbx
movq %rbx, %rdi
movq 0x38(%rsp), %rsi
callq 0x1a38cf
movq %rbx, %rdi
movq 0x48(%rsp), %rsi
callq 0x1a39c4
movq 0x40(%rsp), %rsi
addq $0x1c, %rsi
xorl %ecx, %ecx
movq 0x98(%rsp), %rdi
cmpq %rcx, %r13
je 0x15e2de
movl (%rsi), %edx
shlq $0x20, %rdx
incq %rdx
movq %rdx, (%rax,%rcx,8)
incq %rcx
addq $0x28, %rsi
jmp 0x15db67
xorl %edi, %edi
jmp 0x15e532
movq 0x98(%rsp), %rbx
movq 0x38(%rsp), %rbp
leaq (,%rbx,8), %rsi
addq %rbp, %rsi
movq %rbp, %rdi
callq 0x159858
movq %rbx, %rsi
shlq $0x2, %rsi
movq 0x50(%rsp), %rbx
movq %rbx, %rdi
callq 0x1a39c4
movq %rax, 0x68(%rsp)
movl %r15d, 0xc4(%rsp)
movl %r15d, %r14d
leaq (,%r14,4), %rsi
movq %rbx, %rdi
callq 0x1a39c4
movq %rax, 0x70(%rsp)
leaq (,%r14,8), %rsi
movq %rbx, %rdi
callq 0x1a39c4
movq %rax, 0xa0(%rsp)
pushq $0x4
popq %rdx
movq %rbx, %rdi
movq %r14, 0x88(%rsp)
movq %r14, %rsi
callq 0x1a3848
movq %rax, 0x90(%rsp)
movl 0x140(%rsp), %eax
negl %eax
movl %eax, 0xcc(%rsp)
xorl %r8d, %r8d
xorl %r15d, %r15d
movl $0x0, 0x80(%rsp)
movq 0x40(%rsp), %rdx
cmpq 0x88(%rsp), %r8
je 0x15e2ee
movslq 0x4(%rbp,%r8,8), %rax
imulq $0x28, %rax, %rbx
leaq (%rdx,%rbx), %r13
movq %r8, 0x60(%rsp)
movq 0xb8(%rsp), %r12
movq 0x18(%r12), %rdi
movl 0x8(%rdx,%rbx), %r14d
movl %r14d, %esi
xorl $0x1, %esi
callq 0x15d450
movq %rax, %rbp
movq 0x10(%r12), %rax
shrl %r14d
imulq $0x28, %r14, %rcx
movl (%rax,%rcx), %edx
andl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
leaq 0x100(%rsp), %rax
movq %rax, (%rsp)
movq %r13, 0x48(%rsp)
movq %r13, %rdi
movq 0xb0(%rsp), %r14
movq %r14, %rsi
leaq 0xdc(%rsp), %rcx
leaq 0x104(%rsp), %r8
leaq 0xd8(%rsp), %r9
callq 0x15d0dd
movq 0x40(%rsp), %r10
addl 0x150(%rsp), %ebp
addl 0x14(%r10,%rbx), %ebp
cmpl %r14d, %ebp
cmovgel %r14d, %ebp
pushq $-0x1
popq %rax
movl %eax, %r12d
movq 0x60(%rsp), %rax
testq %rax, %rax
je 0x15dd5a
movq 0x38(%rsp), %rax
movq 0x60(%rsp), %rcx
cmpl %ebp, -0x8(%rax,%rcx,8)
jae 0x15dd11
leaq -0x1(%rcx), %r12
jmp 0x15dd5a
pushq $-0x1
popq %rcx
movl %ecx, %r12d
cmpl %ebp, (%rax)
jae 0x15dd5a
xorl %r12d, %r12d
movq 0x60(%rsp), %rax
movl %eax, %ecx
movl %ecx, %eax
subl %r12d, %eax
jle 0x15dd54
cltd
pushq $0x2
popq %rsi
idivl %esi
leal (%rax,%r12), %edx
movslq %edx, %rdx
movq 0x38(%rsp), %rsi
cmpl %ebp, (%rsi,%rdx,8)
leal 0x1(%rax,%r12), %eax
cmovael %r12d, %eax
cmovbl %ecx, %edx
movl %eax, %r12d
movl %edx, %ecx
jmp 0x15dd25
jne 0x15e546
xorl %edi, %edi
movq $0x0, 0xa8(%rsp)
movq 0x38(%rsp), %r9
movq 0x48(%rsp), %r11
testl %r12d, %r12d
js 0x15e059
movl %edi, 0x34(%rsp)
movl %r12d, %eax
movq %rax, 0x78(%rsp)
movslq 0x4(%r9,%rax,8), %rax
imulq $0x28, %rax, %r13
leaq (%r10,%r13), %rbp
movq 0xb8(%rsp), %rax
movq 0x10(%rax), %rax
movl 0x8(%r10,%r13), %r14d
movl %r14d, %ebx
shrl %ebx
imulq $0x28, %rbx, %rcx
movl (%rax,%rcx), %edx
andl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
leaq 0xd0(%rsp), %rax
movq %rax, (%rsp)
movq %rbp, %rdi
movq 0xb0(%rsp), %rsi
leaq 0xfc(%rsp), %rcx
leaq 0xd4(%rsp), %r8
leaq 0xf8(%rsp), %r9
callq 0x15d0dd
movq 0x48(%rsp), %r11
movq 0x40(%rsp), %r10
movl 0x14(%r11), %edi
cmpl %edi, 0x14(%r10,%r13)
jge 0x15defc
movl 0xdc(%rsp), %eax
subl 0xd4(%rsp), %eax
cmpl 0x148(%rsp), %eax
jg 0x15e059
cmpl %r14d, 0x8(%r11)
jne 0x15ded0
movl 0xc(%rbp), %edx
movl 0xc(%r11), %eax
cmpl %eax, %edx
jge 0x15defc
movl 0x10(%rbp), %esi
movl 0x10(%r11), %ecx
cmpl %ecx, %esi
jge 0x15defc
movl %eax, %r8d
subl %esi, %r8d
movl %r8d, %r9d
subl %edi, %r9d
addl 0x18(%rbp), %r9d
movl %r9d, %edi
negl %edi
cmovsl %r9d, %edi
cmpl 0x150(%rsp), %edi
jg 0x15defc
cmpl 0x140(%rsp), %r8d
setg %dil
cmpl 0xcc(%rsp), %r8d
setl %r8b
orb %dil, %r8b
jne 0x15defc
movl %esi, %edi
subl %eax, %edi
jle 0x15debb
cvtsi2ss %edi, %xmm0
subl %edx, %esi
cvtsi2ss %esi, %xmm1
movss 0xc8(%rsp), %xmm2
mulss %xmm2, %xmm1
ucomiss %xmm1, %xmm0
ja 0x15defc
subl %eax, %ecx
cvtsi2ss %ecx, %xmm1
mulss %xmm2, %xmm1
ucomiss %xmm1, %xmm0
ja 0x15defc
movq 0x58(%rsp), %rdi
movq %rbp, %rsi
movq %r11, %rdx
callq 0x15e584
movl %eax, %r14d
jmp 0x15df1f
movl 0xd8(%rsp), %eax
movq 0x58(%rsp), %rdi
movq 0x20(%rdi), %rcx
movl (%rcx,%rbx,8), %ecx
movl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
andl %edx, %ecx
subl 0xd0(%rsp), %eax
addl %ecx, %eax
cmpl 0x140(%rsp), %eax
jle 0x15df0d
movq 0x38(%rsp), %r9
movl 0x34(%rsp), %edi
decl %r12d
jmp 0x15dd72
movq %rbp, %rsi
movq %r11, %rdx
callq 0x15e584
movl %eax, %r14d
testl %eax, %eax
js 0x15df70
movq 0xa8(%rsp), %r8
cmpl 0x80(%rsp), %r8d
jne 0x15df81
movl %r8d, %ecx
sarl %ecx
addl %r8d, %ecx
cmpl $0x4, %r8d
pushq $0x10
popq %rax
cmovll %eax, %ecx
movl %ecx, 0x80(%rsp)
movslq %ecx, %rax
imulq $0x30, %rax, %rdx
movq 0x50(%rsp), %rdi
movq %r15, %rsi
movq %r8, %rbx
callq 0x1a3acc
movq %rax, %r15
movq 0x40(%rsp), %r10
movq 0x58(%rsp), %rsi
jmp 0x15df8e
movq 0x40(%rsp), %r10
movq 0x38(%rsp), %r9
movq 0x48(%rsp), %r11
jmp 0x15df01
movq 0x40(%rsp), %r10
movq 0x58(%rsp), %rsi
movq %r8, %rbx
movq 0x48(%rsp), %r11
movl 0x34(%rsp), %edi
movq 0x78(%rsp), %r8
movslq %ebx, %rax
incl %ebx
movq %rbx, 0xa8(%rsp)
imulq $0x30, %rax, %rax
xorps %xmm0, %xmm0
movups %xmm0, 0x20(%r15,%rax)
movups %xmm0, 0x10(%r15,%rax)
movups %xmm0, (%r15,%rax)
movl 0x8(%r11), %ecx
xorl %edx, %edx
cmpl 0x8(%rbp), %ecx
sete %dl
shll $0x1f, %edx
movl %edx, 0xc(%r15,%rax)
movl 0x8(%rbp), %ecx
xorl $0x1, %ecx
movl %ecx, (%r15,%rax)
movl %r12d, %ecx
andl $0x3fffffff, %ecx       # imm = 0x3FFFFFFF
orl %edx, %ecx
movl %ecx, 0xc(%r15,%rax)
movl 0x14(%r11), %edx
subl 0x18(%rbp), %edx
movl %edx, 0x10(%r15,%rax)
movl %r14d, 0x4(%r15,%rax)
movl %ecx, 0xc(%r15,%rax)
movq 0x90(%rsp), %rax
movl (%rax,%r8,4), %eax
cmpq %rax, 0x60(%rsp)
jne 0x15e02a
cmpl 0x158(%rsp), %edi
movq 0x38(%rsp), %r9
jge 0x15e05e
incl %edi
jmp 0x15e02f
movq 0x38(%rsp), %r9
movq 0xa0(%rsp), %rax
movq (%rax,%r8,8), %rax
testq %rax, %rax
js 0x15df05
movq 0x90(%rsp), %rcx
movq 0x60(%rsp), %rdx
movl %edx, (%rcx,%rax,4)
jmp 0x15df05
movq 0x58(%rsp), %rsi
movl 0x8(%r11), %eax
movl %eax, %edx
xorl $0x1, %edx
movq 0x20(%rsi), %rcx
shrl %eax
movl (%rcx,%rax,8), %eax
movl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
andl %ecx, %eax
movl 0x140(%rsp), %r9d
subl 0xc(%r11), %r9d
addl %eax, %r9d
andq $0x0, 0x8(%rsp)
movl $0xf, (%rsp)
movq 0x50(%rsp), %rdi
movq 0xa8(%rsp), %r14
movl %r14d, %ecx
movq %r15, %r8
callq 0x15bcd0
movq 0x48(%rsp), %rsi
xorl %ebx, %ebx
testl %r14d, %r14d
cmovlel %ebx, %r14d
imulq $0x30, %r14, %r14
xorl %r13d, %r13d
movq 0x40(%rsp), %rdx
cmpq %rbx, %r14
je 0x15e187
testl $0x7fffffff, 0x14(%r15,%rbx) # imm = 0x7FFFFFFF
je 0x15e17e
movq %r15, %rbp
leaq (%r15,%rbx), %r12
movl 0x160(%rsp), %eax
movl %eax, (%rsp)
movq %r12, %rdi
movq 0x38(%rsp), %rcx
movq 0x70(%rsp), %r8
movl 0x150(%rsp), %r9d
movss 0x84(%rsp), %xmm0
movq %rsi, %r15
callq 0x15e5ba
movl %eax, %ecx
negl %ecx
jno 0x15e124
movq 0x40(%rsp), %rdx
movq %r15, %rsi
jmp 0x15e17b
movl 0x1c(%r15), %ecx
addl %eax, %ecx
movq %r15, %rsi
js 0x15e176
movslq %r13d, %r13
imulq $0x30, %r13, %rcx
movq 0x20(%r12), %rdx
movq %rbp, %r15
movq %rdx, 0x20(%rbp,%rcx)
movups (%r12), %xmm0
movups 0x10(%r12), %xmm1
movups %xmm1, 0x10(%rbp,%rcx)
movups %xmm0, (%rbp,%rcx)
cltq
movabsq $0x3fffffffffffffff, %rdx # imm = 0x3FFFFFFFFFFFFFFF
subq %rax, %rdx
incl %r13d
movq %rdx, 0x28(%rbp,%rcx)
movq 0x40(%rsp), %rdx
jmp 0x15e17e
movq 0x40(%rsp), %rdx
movq %rbp, %r15
addq $0x30, %rbx
jmp 0x15e0c5
testl %r13d, %r13d
jle 0x15e1df
movl %r13d, %ebx
imulq $0x30, %rbx, %rsi
addq %r15, %rsi
movq %r15, %rdi
callq 0x159b25
movq 0x48(%rsp), %rsi
leaq 0x58(%r15), %rax
pushq $0x1
popq %r13
cmpq %r13, %rbx
je 0x15e1c9
movq (%rax), %rcx
subq 0x28(%r15), %rcx
movslq 0x1c(%rsi), %rdx
cmpq %rdx, %rcx
jg 0x15e1cc
incq %r13
addq $0x30, %rax
jmp 0x15e1ab
movl %ebx, %r13d
movl 0x168(%rsp), %eax
cmpl %eax, %r13d
cmovgel %eax, %r13d
movq 0x40(%rsp), %rdx
movl 0x1c(%rsi), %ebp
xorl %r12d, %r12d
testl %r13d, %r13d
cmovlel %r12d, %r13d
imulq $0x30, %r13, %r14
pushq $-0x1
popq %rax
movl %eax, %ebx
movl %eax, 0x34(%rsp)
xorl %r13d, %r13d
movl $0x0, 0x78(%rsp)
cmpq %r12, %r14
je 0x15e277
leaq (%r15,%r12), %rdi
movl 0x160(%rsp), %eax
movl %eax, (%rsp)
movq 0x38(%rsp), %rcx
movq 0x70(%rsp), %r8
movl 0x150(%rsp), %r9d
movss 0x84(%rsp), %xmm0
callq 0x15e5ba
movl %eax, %ecx
negl %ecx
jo 0x15e267
cmpl %ebp, %eax
jle 0x15e267
movl 0xc(%r15,%r12), %r13d
movl 0x1c(%r15,%r12), %ecx
movl %ecx, 0x34(%rsp)
movl %r13d, %ebx
andl $0x3fffffff, %ebx       # imm = 0x3FFFFFFF
movl 0x24(%r15,%r12), %ecx
movl %ecx, 0x78(%rsp)
shrl $0x1f, %r13d
movl %eax, %ebp
addq $0x30, %r12
movq 0x40(%rsp), %rdx
movq 0x48(%rsp), %rsi
jmp 0x15e204
movq 0x70(%rsp), %rax
movq 0x60(%rsp), %r8
movl %ebp, (%rax,%r8,4)
movslq %ebx, %rax
movq 0xa0(%rsp), %rcx
movq %rax, (%rcx,%r8,8)
movl 0x34(%rsp), %ecx
movl %ecx, 0x20(%rsi)
movl 0x78(%rsp), %ecx
movl %ecx, 0x24(%rsi)
shll $0x1f, %r13d
movl 0x4(%rsi), %ecx
movl $0x7fffffff, %edi       # imm = 0x7FFFFFFF
andl %edi, %ecx
orl %r13d, %ecx
movl %ecx, 0x4(%rsi)
testl %eax, %eax
js 0x15e2c6
movq 0x68(%rsp), %rcx
movl (%rcx,%rax,4), %eax
cmpl %ebp, %eax
jg 0x15e2c8
movl %ebp, %eax
movq 0x68(%rsp), %rcx
movl %eax, (%rcx,%r8,4)
incq %r8
movq 0x38(%rsp), %rbp
jmp 0x15dc42
movq 0x180(%rsp), %rcx
movq %rax, (%rcx)
jmp 0x15e532
movq 0x50(%rsp), %r13
movq %r13, %rdi
movq %r15, %rsi
callq 0x1a38cf
movq 0x98(%rsp), %r12
subl 0xc4(%rsp), %r12d
leaq 0xe8(%rsp), %rax
movq %rax, 0x20(%rsp)
andl $0x0, 0x8(%rsp)
leaq 0xec(%rsp), %rax
andl $0x0, (%rsp)
movq %rax, 0x18(%rsp)
movl %r12d, 0x10(%rsp)
movq %r13, %rdi
movq 0x88(%rsp), %rsi
movq 0x70(%rsp), %r15
movq %r15, %rdx
movq 0xa0(%rsp), %rbx
movq %rbx, %rcx
movq 0x68(%rsp), %r8
movq 0x90(%rsp), %r9
callq 0x15b018
movq %rax, %r14
movq %r13, %rdi
movq %r15, %rsi
callq 0x1a38cf
movq %r13, %rdi
movq %rbx, %rsi
callq 0x1a38cf
movq %r13, %rdi
movq 0x90(%rsp), %rsi
callq 0x1a38cf
movq 0x40(%rsp), %r9
leaq 0xec(%rsp), %rax
movslq (%rax), %rdx
movq %r12, %r15
movl %edx, %r13d
leaq 0xe8(%rsp), %rax
movslq (%rax), %rax
movq %rbp, %rcx
movl %eax, %ebp
xorl %r12d, %r12d
testl %r15d, %r15d
cmovlel %r12d, %r15d
movq 0x88(%rsp), %rsi
leaq 0x4(%rcx,%rsi,8), %rcx
leaq (%r14,%rdx,8), %rdx
movq 0x68(%rsp), %rsi
leaq (%rsi,%rax,4), %rsi
shlq $0x20, %rax
movabsq $0x100000000, %rdi      # imm = 0x100000000
cmpq %r12, %r15
je 0x15e41b
movslq (%rcx,%r12,8), %r8
imulq $0x28, %r8, %r8
movl 0x1c(%r9,%r8), %r8d
shlq $0x20, %r8
incq %r8
movq %r8, (%rdx,%r12,8)
movq 0x88(%rsp), %r8
addl %r12d, %r8d
movl %r8d, (%rsi,%r12,4)
incq %r12
addq %rdi, %rax
jmp 0x15e3e7
movl %r13d, %ebx
addq %r12, %r13
leaq (%r12,%rbp), %rcx
movq %rcx, 0x48(%rsp)
sarq $0x20, %rax
imulq $0x28, %rax, %rsi
movq 0x50(%rsp), %rdi
movq %rsi, 0x70(%rsp)
callq 0x1a39c4
movq 0x40(%rsp), %rdi
movq %r15, %rcx
movq %rax, %r15
addl %ebx, %ecx
xorl %eax, %eax
testl %ecx, %ecx
cmovlel %eax, %ecx
movq %rcx, %rbx
xorl %ecx, %ecx
cmpq %rbx, %rax
je 0x15e4d3
movl (%r14,%rax,8), %esi
movslq %ecx, %r8
testl %esi, %esi
movl $0x0, %edx
cmovgl %esi, %edx
addl %r8d, %esi
decl %esi
negq %rdx
imulq $0x28, %r8, %r11
addq %r15, %r11
xorl %r8d, %r8d
cmpq %r8, %rdx
je 0x15e4cb
leal (%rsi,%r8), %r9d
movslq %r9d, %r9
movq 0x68(%rsp), %r10
movslq (%r10,%r9,4), %r9
movq 0x38(%rsp), %r10
movslq 0x4(%r10,%r9,8), %r9
imulq $0x28, %r9, %r9
movq 0x20(%rdi,%r9), %r10
movq %r10, 0x20(%r11)
movups (%rdi,%r9), %xmm0
movups 0x10(%rdi,%r9), %xmm1
movups %xmm1, 0x10(%r11)
movups %xmm0, (%r11)
decq %r8
addq $0x28, %r11
jmp 0x15e482
subl %r8d, %ecx
incq %rax
jmp 0x15e45a
subl %ecx, %ebp
addl %ebp, %r12d
jne 0x15e565
movq %r15, %rsi
movq 0x70(%rsp), %rdx
callq 0x2160
movq 0xf0(%rsp), %rax
movq 0x48(%rsp), %rcx
movl %ecx, (%rax)
movq 0x180(%rsp), %rax
movq %r14, (%rax)
movq 0x50(%rsp), %rbx
movq %rbx, %rdi
movq 0x38(%rsp), %rsi
callq 0x1a38cf
movq %rbx, %rdi
movq %r15, %rsi
callq 0x1a38cf
movq %rbx, %rdi
movq 0x68(%rsp), %rsi
callq 0x1a38cf
movl %r13d, %edi
movl %edi, %eax
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x93c77(%rip), %rdi     # 0x1f21c4
leaq 0x935cf(%rip), %rsi     # 0x1f1b23
leaq 0x987bc(%rip), %rcx     # 0x1f6d17
movl $0x3ee, %edx            # imm = 0x3EE
callq 0x2110
leaq 0x937cd(%rip), %rdi     # 0x1f1d39
leaq 0x935b0(%rip), %rsi     # 0x1f1b23
leaq 0x937c8(%rip), %rcx     # 0x1f1d42
movl $0x724, %edx            # imm = 0x724
callq 0x2110