// File: /workspace/github_cpp_makefile_star2_O3/chhylp123[P]hifiasm/inter.cpp
// Function: gl_rchain_lin(overlap_region_alloc*, kv_ul_ov_t*, ul_ov_t*, kv_rtrace_t*, ul_idx_t const*, ug_opt_t const*, long, double, long, long, long, long, Chain_Data*, bit_extz_t*, long, All_reads*, char*, UC_Read*, long, double, long)
int64_t gl_rchain_lin(overlap_region_alloc* ol, kv_ul_ov_t *res, ul_ov_t *ex, kv_rtrace_t *trace, const ul_idx_t *uref, const ug_opt_t *uopt, int64_t bw, 
double diff_ec_ul, int64_t qlen, int64_t max_skip, int64_t max_iter, int64_t max_dis, Chain_Data* dp, bit_extz_t *exz,
int64_t trans_sc, All_reads *ridx, char* qstr, UC_Read *tu, int64_t rid, double e_rate, int64_t need_srt)
{
	if(res->n == 0) return 0;
    uint32_t li_v, lj_v, rev_n; int32_t *f, *c_n, *c_sc; int64_t *p, *t, res_n = res->n, st, max_ii, max, err; 
    int64_t mm_ovlp, x, i, j, k, sc, csc, mm_sc, mm_idx, qo, n_skip, end_j, plus; ul_ov_t *li, *lj, rev_t; rtrace_iter tc;
    resize_Chain_Data(dp, res_n, NULL);
    t = dp->tmp; f = dp->score; p = dp->pre; c_n = dp->occ; c_sc = dp->self_length;
	if(need_srt) {
        radix_sort_ul_ov_srt_qe(res->a, res->a + res_n);
        for (i = 1, j = 0; i <= res_n; i++) {
            if (i == res_n || res->a[i].qe != res->a[j].qe) {
                if(i-j>1) radix_sort_ul_ov_srt_qs(res->a+j, res->a+i);
                j = i;
            }
        }
    }

	memset(t, 0, (res_n*sizeof((*t))));
	for (i = st = plus = 0, max_ii = -1; i < res_n; ++i) {
        li = &(res->a[i]); li_v = (li->tn<<1)|li->rev;
        mm_ovlp = max_ovlp_src(uopt, li_v^1);        
        x = (li->qs + mm_ovlp)*diff_ec_ul; 
        if(x < bw) x = bw; 
        x += li->qs + mm_ovlp;
        if (x > qlen+1) x = qlen+1;
        x = find_ul_ov_max(i, res->a, x+G_CHAIN_INDEL); 
        csc = li->qe - li->qs; csc -= (((int64_t)li->sec)*trans_sc);
        mm_sc = csc; mm_idx = -1; 
        n_skip = 0; end_j = -1; tc.k = INT32_MAX;
        if ((x-st) > max_iter) st = x-max_iter;
		// fprintf(stderr, "[M::%s] i::%ld, iq::[%u, %u)\n", __func__, i, li->qs, li->qe);
        for (j = x; j >= st; --j) { // collect potential destination vertices
            lj = &(res->a[j]); lj_v = (lj->tn<<1)|lj->rev;
            if(lj->qe <= li->qs) break;//even this pair has a overlap, its length will be very small; just ignore
			if(lj->qs >= li->qs) continue;///no contain
            qo = infer_rovlp(li, lj, NULL, NULL, ridx, NULL); ///overlap length in query (UL read)
            if(li_v != lj_v && get_ecov_contain_adv(uref, uopt, li_v^1, lj_v^1, bw, diff_ec_ul, qo, NULL)) {
				// fprintf(stderr, "[M::%s] j::%ld, jq::[%u, %u)\n", __func__, j, lj->qs, lj->qe);
				err = get_rid_backward_cigar_err(&tc, li, trace, NULL, uref, qstr, tu, ol, NULL, exz, e_rate, lj->qe);
                sc = f[j] + (li->qe - lj->qe) - (err*trans_sc);
                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 || (res->a[i].qe>(res->a[max_ii].qe+max_dis))) {//too long
            max = INT32_MIN; max_ii = -1;
            for (j = i - 1; (j >= st) && (res->a[i].qe<=(max_dis+res->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 = &(res->a[max_ii]); lj_v = (lj->tn<<1)|lj->rev;
            if(lj->qe > li->qs && lj->qs < li->qs) {
                qo = infer_rovlp(li, lj, NULL, NULL, ridx, NULL); ///overlap length in query (UL read)
                if(li_v != lj_v && get_ecov_contain_adv(uref, uopt, li_v^1, lj_v^1, bw, diff_ec_ul, qo, NULL)) {
					///as max_ii < end_j, get_rid_backward_cigar_err still works
					// fprintf(stderr, "[M::%s] max_ii::%ld, max_ii::[%u, %u)\n", __func__, max_ii, lj->qs, lj->qe);
                    err = get_rid_backward_cigar_err(&tc, li, trace, NULL, uref, qstr, tu, ol, NULL, exz, e_rate, lj->qe);
                	sc = f[max_ii] + (li->qe - lj->qe) - (err*trans_sc);
                    if(sc > mm_sc) {
                        mm_sc = sc; mm_idx = max_ii;
                    }
                }
            }
        }
        if(mm_sc < 0) {
            mm_sc = csc; mm_idx = -1; 
        }
        f[i] = mm_sc; p[i] = mm_idx;
        if ((max_ii < 0) || ((res->a[i].qe<=max_dis+res->a[max_ii].qe) && (f[max_ii]<f[i]))) {
            max_ii = i;
        }
        if(mm_sc < plus) plus = mm_sc;//minmun negative
        // fprintf(stderr, "-5-[M::%s::utg%.6dl] i::%ld, res_n::%ld, csc::%ld, f[i]::%d, p[i]::%ld, q::[%u, %u)\n", 
        //                      __func__, (int32_t)li->tn+1, i, res_n, csc, f[i], p[i], li->qs, li->qe);
    }

	for (i = 0; i < res_n; ++i) {///make all f[] positive
        f[i] -= plus; t[i] = ((uint64_t)f[i])<<32; t[i] += (i<<1);
    }

	int64_t n_v, n_u, n_v0; 
    radix_sort_gfa64i(t, t + res_n); plus = 0;
    for (k = res_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; ) {
            ex[n_v++] = res->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]));
        // fprintf(stderr, "[M::%s::] n_v::%ld, n_v0::%ld, t[k]::%ld, sc::%ld\n", 
        //                      __func__, n_v, n_v0, t[k]>>32, sc);
        c_n[n_u] = n_v-n_v0; c_sc[n_u] = sc; n_u++; if(sc < plus) plus = sc;
    }
    // fprintf(stderr, "---[M::%s] n_u:%ld, n_v:%ld\n", __func__, n_u, n_v);
    for (k = 0, n_v = n_v0 = 0; k < n_u; k++) {
        n_v0 = n_v; n_v += c_n[k];
        res->a[k].qn = c_sc[k]-plus;//score
        res->a[k].ts = n_v0; res->a[k].te = n_v;///idx
        // fprintf(stderr, "[M::%s] k:%ld, c_sc:%d\n", __func__, k, c_sc[k]);

        rev_n = c_n[k]>>1; 
        ///we need to consider contained reads; so determining qs is not such easy
        res->a[k].qs = (uint32_t)-1; res->a[k].qe = ex[n_v0].qe;
        for (i = 0; i < rev_n; i++) {
            rev_t = ex[n_v0+i]; ex[n_v0+i] = ex[n_v-i-1]; ex[n_v-i-1] = rev_t;
            
            if(res->a[k].qs > ex[n_v0+i].qs) res->a[k].qs = ex[n_v0+i].qs;
            if(res->a[k].qs > ex[n_v-i-1].qs) res->a[k].qs = ex[n_v-i-1].qs;
            ex[n_v0+i].sec = ex[n_v-i-1].sec = SEC_MODE; 
        }
        if(c_n[k]&1) {
            if(res->a[k].qs > ex[n_v0+i].qs) res->a[k].qs = ex[n_v0+i].qs;
            ex[n_v0+i].sec = SEC_MODE; 
        }
    }
    res->n = n_u;
    radix_sort_ul_ov_srt_qn(res->a, res->a + res->n);//sort by score
	// if(res->n > 0) {
	// 	fprintf(stderr, "[M::%s::rid->%ld] qlen::%ld, q::[%u, %u), sc::%u\n", 
	// 	__func__, rid, qlen, res->a[res->n-1].qs, res->a[res->n-1].qe, res->a[res->n-1].qn);
	// }
    return n_v;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x198, %rsp            # imm = 0x198
movsd %xmm1, 0xb8(%rsp)
movsd %xmm0, 0x80(%rsp)
movq %r9, 0x78(%rsp)
movq %r8, 0xb0(%rsp)
movq %rcx, 0xa8(%rsp)
movq %rsi, %rax
movq %rdi, 0xa0(%rsp)
movq 0x8(%rsi), %rsi
testq %rsi, %rsi
je 0x1bdc47
movq %rdx, %r12
movq 0x230(%rsp), %rbx
movq 0x1f8(%rsp), %r14
movq %r14, %rdi
movq %rsi, 0x38(%rsp)
xorl %edx, %edx
movq %rax, 0x8(%rsp)
callq 0x3ecb0
movq 0x8(%rsp), %rax
movq 0x28(%r14), %rcx
movq %rcx, 0x30(%rsp)
movq (%r14), %rcx
movq %rcx, 0x58(%rsp)
movq 0x8(%r14), %rcx
movq %rcx, 0x40(%rsp)
movq 0x20(%r14), %r13
movq 0x18(%r14), %rbp
testq %rbx, %rbx
je 0x1bd2e6
movq (%rax), %rdi
movq 0x38(%rsp), %rbx
leaq (%rbx,%rbx,8), %rax
leaq (%rax,%rax,2), %rsi
addq %rdi, %rsi
addq %rbx, %rsi
callq 0x19e2b4
testq %rbx, %rbx
jle 0x1bdc4c
negq %rbx
movl $0x1, %r14d
movl $0x1c, %r15d
xorl %eax, %eax
movq 0x8(%rsp), %rdi
movq %rbx, %rcx
addq %r14, %rcx
je 0x1bd29f
movq (%rdi), %rcx
movl 0x8(%rcx,%r15), %edx
leaq (%rax,%rax,8), %rsi
leaq (%rsi,%rsi,2), %rsi
addq %rax, %rsi
cmpl 0x8(%rcx,%rsi), %edx
jne 0x1bd29f
movq %rax, %rcx
jmp 0x1bd2cf
movq %r14, %rdx
subq %rax, %rdx
movq %r14, %rcx
cmpq $0x2, %rdx
jl 0x1bd2cf
movq (%rdi), %rsi
leaq (%rax,%rax,8), %rcx
leaq (%rcx,%rcx,2), %rdi
addq %rax, %rdi
addq %rsi, %rdi
addq %r15, %rsi
callq 0x19e55c
movq 0x8(%rsp), %rdi
movq %r14, %rcx
leaq (%rbx,%r14), %rdx
incq %rdx
incq %r14
addq $0x1c, %r15
movq %rcx, %rax
cmpq $0x1, %rdx
jne 0x1bd279
movq 0x38(%rsp), %rbx
leaq (,%rbx,8), %rdx
movq 0x30(%rsp), %rdi
xorl %esi, %esi
callq 0x20e0
testq %rbx, %rbx
jle 0x1bdc60
movq %rbp, 0x88(%rsp)
movq %r13, 0x90(%rsp)
movq %r12, 0x98(%rsp)
movq 0x1d8(%rsp), %rax
incq %rax
movq %rax, 0xd0(%rsp)
movq $-0x14, 0xc8(%rsp)
movq $0x0, 0x70(%rsp)
movq $-0x1, 0xc0(%rsp)
xorl %esi, %esi
movq $-0x1, %rbp
xorl %r10d, %r10d
movq 0x8(%rsp), %r9
movq %r10, %r14
movq %rsi, %rbx
movq (%r9), %r13
leaq (%rsi,%rsi,8), %rax
leaq (%rax,%rax,2), %r15
addq %rsi, %r15
leaq (%r15,%r13), %rax
movq %rax, 0x18(%rsp)
movl 0xc(%r13,%r15), %eax
movl 0x18(%r13,%r15), %esi
shrdl $0x1f, %eax, %esi
movl %esi, 0x60(%rsp)
xorl $0x1, %esi
movq 0x78(%rsp), %rdi
movl %esi, 0x54(%rsp)
callq 0x1a4c50
movl 0x4(%r13,%r15), %ecx
addq %rax, %rcx
xorps %xmm0, %xmm0
cvtsi2sd %rcx, %xmm0
mulsd 0x80(%rsp), %xmm0
cvttsd2si %xmm0, %rdx
movq 0x1d0(%rsp), %rax
cmpq %rax, %rdx
cmovleq %rax, %rdx
addq %rcx, %rdx
movq 0xd0(%rsp), %rax
cmpq %rax, %rdx
cmovgeq %rax, %rdx
subl $-0x80, %edx
movq %rbx, 0x48(%rsp)
movl %ebx, %edi
movq %r13, %rsi
callq 0x1a83b5
movslq %eax, %rbx
movl 0x8(%r13,%r15), %ecx
movl 0x18(%r13,%r15), %eax
movq %r15, 0xd8(%rsp)
subl 0x4(%r13,%r15), %ecx
movq %rcx, %r13
andl $0x3fffffff, %eax       # imm = 0x3FFFFFFF
imulq 0x208(%rsp), %rax
subq %rax, %r13
movq $0x7fffffff, 0x100(%rsp) # imm = 0x7FFFFFFF
movq %rbx, %rax
subq %r14, %rax
movq %rbx, %r10
movq 0x1e8(%rsp), %rcx
subq %rcx, %r10
cmpq %rcx, %rax
cmovleq %r14, %r10
cmpq %rbx, %r10
movq %r13, 0x68(%rsp)
jle 0x1bd470
movq %rbx, %rax
movq $-0x1, 0x28(%rsp)
movq 0x8(%rsp), %r9
movq 0x18(%rsp), %rdi
jmp 0x1bd662
leaq (%rbx,%rbx,8), %rax
leaq (%rax,%rax,2), %r15
addq %rbx, %r15
movq $-0x1, 0x28(%rsp)
movq $0x0, 0x20(%rsp)
movq %r13, %r14
movq 0x8(%rsp), %r9
movq 0x18(%rsp), %rdi
movq %r10, 0x10(%rsp)
movq (%r9), %r12
movl 0x4(%rdi), %eax
cmpl %eax, 0x8(%r12,%r15)
jbe 0x1bd65c
cmpl %eax, 0x4(%r12,%r15)
jae 0x1bd5d0
leaq (%r12,%r15), %rsi
movl 0xc(%r12,%r15), %eax
movl 0x18(%r12,%r15), %r13d
shrdl $0x1f, %eax, %r13d
xorl %edx, %edx
xorl %ecx, %ecx
movq 0x210(%rsp), %r8
xorl %r9d, %r9d
callq 0x6ea22
cmpl %r13d, 0x60(%rsp)
je 0x1bd5d5
xorl $0x1, %r13d
subq $0x8, %rsp
movq 0x80(%rsp), %rsi
movl 0x5c(%rsp), %edx
movl %r13d, %ecx
movq 0x1d8(%rsp), %r8
movsd 0x88(%rsp), %xmm0
movq %rax, %r9
pushq $0x0
callq 0x1bcf0f
addq $0x10, %rsp
testq %rax, %rax
je 0x1bd5d5
movl 0x8(%r12,%r15), %eax
subq $0x8, %rsp
leaq 0x108(%rsp), %rdi
movq 0x20(%rsp), %r13
movq %r13, %rsi
movq 0xb0(%rsp), %rdx
xorl %ecx, %ecx
movq 0xb8(%rsp), %r8
movq 0x220(%rsp), %r9
movsd 0xc0(%rsp), %xmm0
pushq %rax
pushq 0x210(%rsp)
pushq $0x0
pushq 0xc0(%rsp)
pushq 0x248(%rsp)
callq 0x7fea8
movq %r13, %rdi
addq $0x30, %rsp
movl 0x8(%r13), %r13d
movq 0x58(%rsp), %rcx
addl (%rcx,%rbx,4), %r13d
subl 0x8(%r12,%r15), %r13d
imulq 0x208(%rsp), %rax
subq %rax, %r13
cmpq %r14, %r13
jle 0x1bd5e9
xorl %eax, %eax
movq 0x20(%rsp), %rcx
testq %rcx, %rcx
setg %al
subq %rax, %rcx
movq %rcx, 0x20(%rsp)
movq %rbx, 0x28(%rsp)
movq 0x8(%rsp), %r9
jmp 0x1bd622
movq %r14, %r13
jmp 0x1bd643
movq %r14, %r13
movq 0x8(%rsp), %r9
movq 0x10(%rsp), %r10
movq 0x18(%rsp), %rdi
jmp 0x1bd643
movq 0x30(%rsp), %rax
movq 0x48(%rsp), %rcx
cmpq %rcx, (%rax,%rbx,8)
movq 0x8(%rsp), %r9
jne 0x1bd61f
movq 0x20(%rsp), %rax
cmpq 0x1e0(%rsp), %rax
movq 0x10(%rsp), %r10
jge 0x1bd65c
incq %rax
movq %rax, 0x20(%rsp)
movq %r14, %r13
jmp 0x1bd627
movq %r14, %r13
movq 0x10(%rsp), %r10
movq 0x40(%rsp), %rax
movq (%rax,%rbx,8), %rax
testq %rax, %rax
js 0x1bd643
movq 0x30(%rsp), %rcx
movq 0x48(%rsp), %rdx
movq %rdx, (%rcx,%rax,8)
leaq -0x1(%rbx), %rax
addq $-0x1c, %r15
movq %r13, %r14
cmpq %r10, %rbx
movq %rax, %rbx
jg 0x1bd49f
jmp 0x1bd662
movq %rbx, %rax
movq %r14, %r13
testq %rbp, %rbp
movq 0x38(%rsp), %rbx
movq 0x58(%rsp), %r14
movq 0x1f0(%rsp), %r15
movq 0xd8(%rsp), %r12
js 0x1bd6a7
movq (%r9), %rcx
movl 0x8(%rcx,%r12), %edx
leaq (,%rbp,8), %rsi
addq %rbp, %rsi
leaq (%rsi,%rsi,2), %rsi
addq %rbp, %rsi
movl 0x8(%rcx,%rsi), %ecx
addq %r15, %rcx
cmpq %rdx, %rcx
jge 0x1bd705
movq 0x48(%rsp), %rsi
cmpq %r10, %rsi
jle 0x1bd78e
movq (%r9), %rcx
movl 0x8(%rcx,%r12), %edx
addq 0xc8(%rsp), %rcx
movq $-0x1, %rbp
movq $-0x80000000, %rsi      # imm = 0x80000000
movq 0xc0(%rsp), %r11
movl (%rcx), %r8d
addq %r15, %r8
cmpq %rdx, %r8
jl 0x1bd705
movslq (%r14,%r11,4), %r8
cmpq %r8, %rsi
cmovlq %r11, %rbp
cmovleq %r8, %rsi
leaq -0x1(%r11), %r8
addq $-0x1c, %rcx
cmpq %r10, %r11
movq %r8, %r11
jg 0x1bd6db
testq %rbp, %rbp
js 0x1bd7bf
cmpq %rax, %rbp
jge 0x1bd7bf
movq (%r9), %rax
leaq (,%rbp,8), %rcx
addq %rbp, %rcx
leaq (%rcx,%rcx,2), %rcx
addq %rbp, %rcx
movl 0x4(%rdi), %edx
cmpl %edx, 0x8(%rax,%rcx)
jbe 0x1bd8dc
leaq (%rax,%rcx), %rsi
cmpl %edx, 0x4(%rsi)
jae 0x1bd8dc
movq %r10, 0x10(%rsp)
movl 0xc(%rax,%rcx), %edx
movl 0x18(%rax,%rcx), %ebx
shrdl $0x1f, %edx, %ebx
movq %rsi, 0x20(%rsp)
xorl %edx, %edx
xorl %ecx, %ecx
movq 0x210(%rsp), %r8
xorl %r9d, %r9d
callq 0x6ea22
cmpl %ebx, 0x60(%rsp)
jne 0x1bd7fe
movq 0x8(%rsp), %r9
movq 0x10(%rsp), %r10
movq 0x38(%rsp), %rbx
jmp 0x1bd8dc
testq %r13, %r13
movq 0x68(%rsp), %rdi
cmovnsq %r13, %rdi
movq $-0x1, %rax
movq 0x28(%rsp), %rcx
cmovsq %rax, %rcx
movl %edi, (%r14,%rsi,4)
movq 0x40(%rsp), %rax
movq %rcx, (%rax,%rsi,8)
movq %rsi, %rax
jmp 0x1bd93b
testq %r13, %r13
movq 0x68(%rsp), %rdi
cmovnsq %r13, %rdi
movq $-0x1, %rax
movq 0x28(%rsp), %rcx
cmovsq %rax, %rcx
movq 0x48(%rsp), %rsi
movl %edi, (%r14,%rsi,4)
movq 0x40(%rsp), %rax
movq %rcx, (%rax,%rsi,8)
movq %rsi, %rax
testq %rbp, %rbp
jns 0x1bd90a
jmp 0x1bd93b
xorl $0x1, %ebx
subq $0x8, %rsp
movq 0x80(%rsp), %rsi
movl 0x5c(%rsp), %edx
movl %ebx, %ecx
movq 0x1d8(%rsp), %r8
movsd 0x88(%rsp), %xmm0
movq %rax, %r9
pushq $0x0
callq 0x1bcf0f
addq $0x10, %rsp
testq %rax, %rax
movq 0x38(%rsp), %rbx
je 0x1bd8d2
movq 0x20(%rsp), %rax
movl 0x8(%rax), %eax
subq $0x8, %rsp
leaq 0x108(%rsp), %rdi
movq 0x20(%rsp), %rsi
movq 0xb0(%rsp), %rdx
xorl %ecx, %ecx
movq 0xb8(%rsp), %r8
movq 0x220(%rsp), %r9
movsd 0xc0(%rsp), %xmm0
pushq %rax
pushq 0x210(%rsp)
pushq $0x0
pushq 0xc0(%rsp)
pushq 0x248(%rsp)
callq 0x7fea8
addq $0x30, %rsp
movq 0x18(%rsp), %rcx
movl 0x8(%rcx), %ecx
addl (%r14,%rbp,4), %ecx
movq 0x20(%rsp), %rdx
subl 0x8(%rdx), %ecx
imulq 0x208(%rsp), %rax
subq %rax, %rcx
cmpq %r13, %rcx
cmovgq %rcx, %r13
movq 0x28(%rsp), %rax
cmovgq %rbp, %rax
movq %rax, 0x28(%rsp)
movq 0x8(%rsp), %r9
movq 0x10(%rsp), %r10
testq %r13, %r13
movq 0x68(%rsp), %rdi
cmovnsq %r13, %rdi
movq $-0x1, %rax
movq 0x28(%rsp), %rcx
cmovsq %rax, %rcx
movq 0x48(%rsp), %rsi
movl %edi, (%r14,%rsi,4)
movq 0x40(%rsp), %rax
movq %rcx, (%rax,%rsi,8)
movq (%r9), %rax
movl 0x8(%rax,%r12), %ecx
leaq (,%rbp,8), %rdx
addq %rbp, %rdx
leaq (%rdx,%rdx,2), %rdx
addq %rbp, %rdx
movl 0x8(%rax,%rdx), %eax
addq %r15, %rax
cmpq %rcx, %rax
jl 0x1bd938
cmpl %edi, (%r14,%rbp,4)
cmovlq %rsi, %rbp
movq %rbp, %rax
movq 0x70(%rsp), %rcx
cmpq %rcx, %rdi
cmovlq %rdi, %rcx
movq %rcx, 0x70(%rsp)
incq %rsi
incq 0xc0(%rsp)
addq $0x1c, 0xc8(%rsp)
movq %rax, %rbp
cmpq %rbx, %rsi
jne 0x1bd365
testq %rbx, %rbx
movq 0x98(%rsp), %r15
movq 0x90(%rsp), %r12
movq 0x88(%rsp), %r13
jle 0x1bdc60
xorl %eax, %eax
movq %rbx, %rcx
movq 0x30(%rsp), %r14
movq 0x58(%rsp), %rsi
movq 0x70(%rsp), %rdi
movl (%rsi,%rax,2), %edx
subl %edi, %edx
movl %edx, (%rsi,%rax,2)
shlq $0x20, %rdx
addq %rax, %rdx
movq %rdx, (%r14,%rax,4)
addq $0x2, %rax
decq %rcx
jne 0x1bd9a1
leaq (%r14,%rbx,8), %rsi
movq %r14, %rdi
callq 0x19e008
testq %rbx, %rbx
movq 0x40(%rsp), %rbp
jle 0x1bdc6e
xorl %eax, %eax
xorl %edx, %edx
movq $0x0, 0x18(%rsp)
movq 0x8(%rsp), %r11
movq %rdx, %rdi
movq %rbx, %rsi
decq %rbx
movl -0x8(%r14,%rsi,8), %r8d
shrl %r8d
leaq (%rdx,%rdx,8), %rcx
leaq (%rcx,%rcx,2), %r9
addq %r15, %r9
addq %rdx, %r9
testb $0x1, (%r14,%r8,8)
jne 0x1bda49
movq (%r11), %rcx
leaq (%r8,%r8,8), %r10
leaq (%r10,%r10,2), %r10
addq %r8, %r10
movupd (%rcx,%r10), %xmm0
movups 0xc(%rcx,%r10), %xmm1
movups %xmm1, 0xc(%r9)
movupd %xmm0, (%r9)
orb $0x1, (%r14,%r8,8)
incq %rdx
movq (%rbp,%r8,8), %r8
addq $0x1c, %r9
testq %r8, %r8
jns 0x1bda08
cmpq %rdi, %rdx
je 0x1bda85
movslq 0x4(%r14,%rbx,8), %r9
testq %r8, %r8
js 0x1bda64
movq 0x58(%rsp), %rcx
movslq (%rcx,%r8,4), %rcx
subq %rcx, %r9
movl %edx, %ecx
subl %edi, %ecx
movl %ecx, (%r12,%rax,4)
movl %r9d, (%r13,%rax,4)
incq %rax
movq 0x18(%rsp), %rcx
cmpq %rcx, %r9
cmovlq %r9, %rcx
movq %rcx, 0x18(%rsp)
cmpq $0x1, %rsi
jg 0x1bd9e9
testq %rax, %rax
jle 0x1bdca7
leaq 0x18(%r15), %rcx
movq %rcx, 0x60(%rsp)
leaq -0x1c(%r15), %rcx
movq %rcx, 0x10(%rsp)
xorl %r9d, %r9d
movl $0x3fffffff, %edi       # imm = 0x3FFFFFFF
xorl %r8d, %r8d
movslq (%r12,%r8,4), %r14
addq %r9, %r14
movl (%r13,%r8,4), %ecx
subl 0x18(%rsp), %ecx
movq (%r11), %rdx
leaq (%r8,%r8,8), %rsi
leaq (%rsi,%rsi,2), %r10
addq %r8, %r10
movl %ecx, (%rdx,%r10)
movl %r9d, 0x10(%rdx,%r10)
movl %r14d, 0x14(%rdx,%r10)
movl (%r12,%r8,4), %r11d
movl $0xffffffff, 0x4(%rdx,%r10) # imm = 0xFFFFFFFF
leaq (%r9,%r9,8), %rcx
leaq (%rcx,%rcx,2), %rbx
leaq (%rbx,%r9), %rcx
movl 0x8(%r15,%rcx), %ecx
movl %ecx, 0x8(%rdx,%r10)
cmpl $0x2, %r11d
jae 0x1bdb12
xorl %r11d, %r11d
jmp 0x1bdbf1
sarl %r11d
cmpl $0x1, %r11d
adcl $0x0, %r11d
leaq (%r11,%r11,8), %rcx
leaq (%rcx,%rcx,2), %r15
addq %r11, %r15
movq 0x60(%rsp), %rcx
leaq (%rcx,%r9), %r12
addq %rbx, %r12
leaq (%r14,%r14,8), %rcx
leaq (%rcx,%rcx,2), %r13
movq 0x10(%rsp), %rcx
addq %r14, %rcx
addq %rcx, %r13
xorl %ebp, %ebp
movups -0x18(%r12,%rbp), %xmm0
movups -0xc(%r12,%rbp), %xmm1
movups %xmm1, 0xec(%rsp)
movaps %xmm0, 0xe0(%rsp)
movups (%r13), %xmm0
movups 0xc(%r13), %xmm1
movups %xmm1, -0xc(%r12,%rbp)
movups %xmm0, -0x18(%r12,%rbp)
movups 0xec(%rsp), %xmm0
movups %xmm0, 0xc(%r13)
movapd 0xe0(%rsp), %xmm0
movupd %xmm0, (%r13)
movq 0x8(%rsp), %rcx
movq (%rcx), %rcx
leaq (%rcx,%r10), %rdx
addq $0x4, %rdx
movl (%rdx), %esi
movl -0x14(%r12,%rbp), %ecx
cmpl %ecx, %esi
jbe 0x1bdbb6
movl %ecx, (%rdx)
movl %ecx, %esi
movl 0x4(%r13), %ecx
cmpl %ecx, %esi
jbe 0x1bdbc0
movl %ecx, (%rdx)
orl %edi, 0x18(%r13)
orl %edi, (%r12,%rbp)
addq $0x1c, %rbp
addq $-0x1c, %r13
cmpq %rbp, %r15
jne 0x1bdb49
movq 0x98(%rsp), %r15
movq 0x90(%rsp), %r12
movq 0x88(%rsp), %r13
testb $0x1, (%r12,%r8,4)
je 0x1bdc31
movq 0x8(%rsp), %rcx
movq (%rcx), %rdx
addq %r15, %r9
addq %rbx, %r9
leaq (%r11,%r11,8), %rcx
leaq (%rcx,%rcx,2), %rbx
addq %r11, %rbx
movl 0x4(%r9,%rbx), %ecx
cmpl %ecx, 0x4(%rdx,%r10)
jbe 0x1bdc26
addq %r10, %rdx
addq $0x4, %rdx
movl %ecx, (%rdx)
addq %rbx, %r9
orl $0x3fffffff, 0x18(%r9)  # imm = 0x3FFFFFFF
incq %r8
movq %r14, %r9
cmpq %rax, %r8
movq 0x8(%rsp), %r11
jne 0x1bdab5
jmp 0x1bdc78
xorl %r14d, %r14d
jmp 0x1bdc92
leaq (,%rbx,8), %rdx
movq 0x30(%rsp), %rdi
xorl %esi, %esi
callq 0x20e0
movq 0x30(%rsp), %rdi
leaq (%rdi,%rbx,8), %rsi
callq 0x19e008
xorl %eax, %eax
xorl %r14d, %r14d
movq 0x8(%rsp), %r11
movq %rax, 0x8(%r11)
movq (%r11), %rdi
leaq (%rax,%rax,8), %rcx
leaq (%rcx,%rcx,2), %rsi
addq %rax, %rsi
addq %rdi, %rsi
callq 0x19ead4
movq %r14, %rax
addq $0x198, %rsp            # imm = 0x198
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %r14d, %r14d
jmp 0x1bdc78