// File: /workspace/github_cpp_makefile_star2_O2/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, 0xc8(%rsp)
movsd %xmm0, 0x80(%rsp)
movq %r9, 0x78(%rsp)
movq %r8, 0xc0(%rsp)
movq %rcx, 0xb8(%rsp)
movq %rdx, 0x50(%rsp)
movq %rdi, 0xb0(%rsp)
movq 0x8(%rsi), %rbp
testq %rbp, %rbp
je 0x172bc0
movq %rsi, %rbx
movq 0x230(%rsp), %r15
movq 0x1f8(%rsp), %r14
movq 0x1d8(%rsp), %rax
movq %rax, 0x98(%rsp)
movq %r14, %rdi
movq %rbp, %rsi
xorl %edx, %edx
callq 0x1383e
movq 0x28(%r14), %rax
movq %rax, 0x30(%rsp)
movq (%r14), %rax
movq %rax, 0x70(%rsp)
movq 0x8(%r14), %r12
movq 0x20(%r14), %rax
movq %rax, 0x48(%rsp)
movq 0x18(%r14), %rax
movq %rax, 0x90(%rsp)
testq %r15, %r15
movq %r12, 0x68(%rsp)
je 0x172bc8
movq (%rbx), %rdi
imulq $0x1c, %rbp, %rsi
addq %rdi, %rsi
callq 0x156f5c
xorl %eax, %eax
testq %rbp, %rbp
movl $0x0, %r14d
cmovgq %rbp, %r14
movq %r14, 0x58(%rsp)
negq %r14
pushq $0x1
popq %r15
pushq $0x1c
popq %r12
leaq (%r14,%r15), %rcx
cmpq $0x1, %rcx
je 0x172bb9
cmpq %r15, %rbp
je 0x172b89
movq (%rbx), %rcx
movl 0x8(%rcx,%r12), %edx
imulq $0x1c, %rax, %rsi
cmpl 0x8(%rcx,%rsi), %edx
jne 0x172b89
movq %rax, %rcx
jmp 0x172bad
movq %r15, %rdx
subq %rax, %rdx
movq %r15, %rcx
cmpq $0x2, %rdx
jl 0x172bad
movq (%rbx), %rsi
imulq $0x1c, %rax, %rdi
addq %rsi, %rdi
addq %r12, %rsi
callq 0x1571fa
movq %r15, %rcx
incq %r15
addq $0x1c, %r12
movq %rcx, %rax
jmp 0x172b63
movq 0x68(%rsp), %r12
jmp 0x172bd6
xorl %r14d, %r14d
jmp 0x1733ca
xorl %eax, %eax
testq %rbp, %rbp
cmovgq %rbp, %rax
movq %rax, 0x58(%rsp)
leaq (,%rbp,8), %rdx
xorl %r13d, %r13d
movq 0x30(%rsp), %r14
movq %r14, %rdi
xorl %esi, %esi
callq 0x20e0
incq 0x98(%rsp)
pushq $-0x1
popq %rax
pushq $-0x5
popq %rcx
movq %rcx, 0xa8(%rsp)
movq %rax, 0xa0(%rsp)
movq %rax, %r8
xorl %ecx, %ecx
movq $0x0, 0x60(%rsp)
movq 0x70(%rsp), %r15
movq %rbp, 0x40(%rsp)
movq %rbx, 0x38(%rsp)
cmpq 0x58(%rsp), %rcx
je 0x17318d
movq (%rbx), %r14
imulq $0x1c, %rcx, %r12
leaq (%r14,%r12), %rbp
movl 0xc(%r14,%r12), %eax
movl 0x18(%r14,%r12), %esi
shrdl $0x1f, %eax, %esi
movl %esi, 0x2c(%rsp)
xorl $0x1, %esi
movq 0x78(%rsp), %rdi
movl %esi, 0x28(%rsp)
movq %rcx, %r15
movq %r8, (%rsp)
callq 0x15d49a
movl 0x4(%r14,%r12), %ecx
addq %rax, %rcx
cvtsi2sd %rcx, %xmm0
mulsd 0x80(%rsp), %xmm0
cvttsd2si %xmm0, %rdx
movq 0x1d0(%rsp), %rax
cmpq %rax, %rdx
cmovleq %rax, %rdx
addq %rcx, %rdx
movq 0x98(%rsp), %rax
cmpq %rax, %rdx
cmovgeq %rax, %rdx
movq (%rbx), %rsi
subl $-0x80, %edx
movq %r15, 0x20(%rsp)
movl %r15d, %edi
callq 0x160717
movq %rbp, %r9
movq (%rsp), %r8
movslq %eax, %rbp
movl 0x8(%r14,%r12), %esi
subl 0x4(%r14,%r12), %esi
movq %r12, 0x88(%rsp)
movl 0x18(%r14,%r12), %eax
andl $0x3fffffff, %eax       # imm = 0x3FFFFFFF
imulq 0x208(%rsp), %rax
subq %rax, %rsi
movq $0x7fffffff, 0x100(%rsp) # imm = 0x7FFFFFFF
movq %rbp, %rax
subq %r13, %rax
movq %rbp, %rcx
movq 0x1e8(%rsp), %rdx
subq %rdx, %rcx
cmpq %rdx, %rax
cmovgq %rcx, %r13
imulq $0x1c, %rbp, %r14
movq %rsi, 0xd8(%rsp)
movq %rsi, %r10
pushq $-0x1
popq %rax
movq %rax, 0x8(%rsp)
movq $0x0, 0x10(%rsp)
movq %r13, 0x18(%rsp)
cmpq %r13, %rbp
jl 0x172ef7
movq (%rbx), %r15
movl 0x4(%r9), %eax
cmpl %eax, 0x8(%r15,%r14)
jbe 0x172ef7
cmpl %eax, 0x4(%r15,%r14)
jae 0x172e7e
movq %r10, %rbx
leaq (%r15,%r14), %rsi
movl 0xc(%r15,%r14), %eax
movl 0x18(%r15,%r14), %r13d
shrdl $0x1f, %eax, %r13d
movq %r9, %r12
movq %r9, %rdi
xorl %edx, %edx
xorl %ecx, %ecx
movq 0x210(%rsp), %r8
xorl %r9d, %r9d
callq 0x3d261
cmpl %r13d, 0x2c(%rsp)
je 0x172e83
xorl $0x1, %r13d
subq $0x8, %rsp
movq 0x80(%rsp), %rsi
movl 0x30(%rsp), %edx
movl %r13d, %ecx
movq 0x1d8(%rsp), %r8
movsd 0x88(%rsp), %xmm0
movq %rax, %r9
pushq $0x0
callq 0x1728e0
popq %rcx
popq %rdx
testq %rax, %rax
je 0x172e83
movl 0x8(%r15,%r14), %eax
subq $0x8, %rsp
leaq 0x108(%rsp), %rdi
movq %r12, %rsi
movq 0xc0(%rsp), %rdx
xorl %ecx, %ecx
movq 0xc8(%rsp), %r8
movq 0x220(%rsp), %r9
movsd 0xd0(%rsp), %xmm0
pushq %rax
pushq 0x210(%rsp)
pushq $0x0
pushq 0xd0(%rsp)
pushq 0x248(%rsp)
callq 0x4cafd
movq %r12, %r9
addq $0x30, %rsp
movl 0x8(%r12), %ecx
movq 0x70(%rsp), %rdx
addl (%rdx,%rbp,4), %ecx
subl 0x8(%r15,%r14), %ecx
imulq 0x208(%rsp), %rax
subq %rax, %rcx
cmpq %rbx, %rcx
movq 0x18(%rsp), %r13
jle 0x172e99
xorl %eax, %eax
movq 0x10(%rsp), %rdx
testq %rdx, %rdx
setg %al
subq %rax, %rdx
movq %rdx, 0x10(%rsp)
movq %rbp, 0x8(%rsp)
movq 0x38(%rsp), %rbx
movq (%rsp), %r8
jmp 0x172ecc
movq %r10, %rcx
jmp 0x172ee8
movq %rbx, %rcx
movq 0x18(%rsp), %r13
movq 0x38(%rsp), %rbx
movq (%rsp), %r8
movq %r12, %r9
jmp 0x172ee8
movq %rbx, %r10
movq 0x30(%rsp), %rax
movq 0x20(%rsp), %rcx
cmpq %rcx, (%rax,%rbp,8)
movq 0x38(%rsp), %rbx
movq (%rsp), %r8
jne 0x172ec9
movq 0x10(%rsp), %rax
cmpq 0x1e0(%rsp), %rax
jge 0x172ef7
incq 0x10(%rsp)
movq %r10, %rcx
movq 0x68(%rsp), %rax
movq (%rax,%rbp,8), %rax
testq %rax, %rax
js 0x172ee8
movq 0x30(%rsp), %rdx
movq 0x20(%rsp), %rsi
movq %rsi, (%rdx,%rax,8)
decq %rbp
addq $-0x1c, %r14
movq %rcx, %r10
jmp 0x172d38
testq %r8, %r8
movq 0x30(%rsp), %r14
movq 0x70(%rsp), %r15
js 0x172f2a
movq (%rbx), %rax
movq 0x88(%rsp), %rcx
movl 0x8(%rax,%rcx), %ecx
imulq $0x1c, %r8, %rdx
movl 0x8(%rax,%rdx), %eax
addq 0x1f0(%rsp), %rax
cmpq %rcx, %rax
jge 0x172f85
movq $-0x80000000, %rax      # imm = 0x80000000
movq 0xa8(%rsp), %rcx
movq 0xa0(%rsp), %rdx
pushq $-0x1
popq %r8
leaq 0x1(%rdx), %rsi
cmpq %r13, %rsi
jle 0x172f85
movq (%rbx), %rsi
movq 0x88(%rsp), %rdi
movl 0x8(%rsi,%rdi), %edi
movl (%rsi,%rcx,4), %esi
addq 0x1f0(%rsp), %rsi
cmpq %rdi, %rsi
jl 0x172f85
movslq (%r15,%rdx,4), %rsi
cmpq %rsi, %rax
cmovlq %rdx, %r8
cmovleq %rsi, %rax
decq %rdx
addq $-0x7, %rcx
jmp 0x172f45
testq %r8, %r8
js 0x1730d8
cmpq %rbp, %r8
jge 0x1730d8
movq (%rbx), %rax
imulq $0x1c, %r8, %rcx
movl 0x4(%r9), %edx
cmpl %edx, 0x8(%rax,%rcx)
movq 0x40(%rsp), %rbp
jbe 0x1730dd
leaq (%rax,%rcx), %rsi
cmpl %edx, 0x4(%rsi)
jae 0x1730dd
movq %r10, 0x10(%rsp)
movq %r8, (%rsp)
movl 0xc(%rax,%rcx), %edx
movl 0x18(%rax,%rcx), %r13d
shrdl $0x1f, %edx, %r13d
movq %r9, 0xd0(%rsp)
movq %r9, %rdi
movq %rsi, %r12
xorl %edx, %edx
xorl %ecx, %ecx
movq 0x210(%rsp), %r8
xorl %r9d, %r9d
callq 0x3d261
cmpl %r13d, 0x2c(%rsp)
je 0x173175
xorl $0x1, %r13d
subq $0x8, %rsp
movq 0x80(%rsp), %rsi
movl 0x30(%rsp), %edx
movl %r13d, %ecx
movq 0x1d8(%rsp), %r8
movsd 0x88(%rsp), %xmm0
movq %rax, %r9
pushq $0x0
callq 0x1728e0
popq %rcx
popq %rdx
testq %rax, %rax
je 0x173175
movl 0x8(%r12), %eax
subq $0x8, %rsp
leaq 0x108(%rsp), %rdi
movq 0xd8(%rsp), %r13
movq %r13, %rsi
movq 0xc0(%rsp), %rdx
xorl %ecx, %ecx
movq 0xc8(%rsp), %r8
movq 0x220(%rsp), %r9
movsd 0xd0(%rsp), %xmm0
pushq %rax
pushq 0x210(%rsp)
pushq $0x0
pushq 0xd0(%rsp)
pushq 0x248(%rsp)
callq 0x4cafd
addq $0x30, %rsp
movl 0x8(%r13), %ecx
movq (%rsp), %r8
addl (%r15,%r8,4), %ecx
subl 0x8(%r12), %ecx
imulq 0x208(%rsp), %rax
subq %rax, %rcx
movq 0x10(%rsp), %r10
cmpq %r10, %rcx
cmovgq %rcx, %r10
movq 0x8(%rsp), %rdi
cmovgq %r8, %rdi
movq 0x18(%rsp), %r13
jmp 0x1730e2
movq 0x40(%rsp), %rbp
movq 0x8(%rsp), %rdi
testq %r10, %r10
movq 0xd8(%rsp), %rdx
cmovnsq %r10, %rdx
pushq $-0x1
popq %rax
cmovsq %rax, %rdi
movq 0x20(%rsp), %rcx
movq %rdx, %rsi
movl %edx, (%r15,%rcx,4)
movq 0x68(%rsp), %r12
movq %rdi, (%r12,%rcx,8)
testq %r8, %r8
js 0x173148
movq (%rbx), %rax
movq 0x88(%rsp), %rcx
movl 0x8(%rax,%rcx), %ecx
imulq $0x1c, %r8, %rdx
movl 0x8(%rax,%rdx), %eax
addq 0x1f0(%rsp), %rax
cmpq %rcx, %rax
jge 0x17313d
movq 0x20(%rsp), %rcx
jmp 0x17314b
cmpl %esi, (%r15,%r8,4)
movq 0x20(%rsp), %rcx
jge 0x17314b
movq %rcx, %r8
movq 0x60(%rsp), %rax
cmpq %rax, %rsi
cmovlq %rsi, %rax
movq %rax, 0x60(%rsp)
incq %rcx
incq 0xa0(%rsp)
addq $0x7, 0xa8(%rsp)
jmp 0x172c2b
movq 0x18(%rsp), %r13
movq (%rsp), %r8
movq 0x8(%rsp), %rdi
movq 0x10(%rsp), %r10
jmp 0x1730e2
xorl %eax, %eax
subq $0x1, 0x58(%rsp)
jb 0x1731b4
movl (%r15,%rax,2), %ecx
subl 0x60(%rsp), %ecx
movl %ecx, (%r15,%rax,2)
shlq $0x20, %rcx
addq %rax, %rcx
movq %rcx, (%r14,%rax,4)
addq $0x2, %rax
jmp 0x17318f
leaq (%r14,%rbp,8), %rsi
movq %r14, %rdi
callq 0x156cf6
xorl %eax, %eax
xorl %r8d, %r8d
xorl %ecx, %ecx
testq %rbp, %rbp
jle 0x173269
movq %r8, %rdx
decq %rbp
movl (%r14,%rbp,8), %edi
shrl %edi
imulq $0x1c, %r8, %r8
addq 0x50(%rsp), %r8
xorl %esi, %esi
testq %rdi, %rdi
js 0x173222
testb $0x1, (%r14,%rdi,8)
jne 0x173222
movq (%rbx), %r9
imulq $0x1c, %rdi, %r10
movupd (%r9,%r10), %xmm0
movups 0xc(%r9,%r10), %xmm1
movups %xmm1, 0xc(%r8)
movupd %xmm0, (%r8)
orb $0x1, (%r14,%rdi,8)
movq (%r12,%rdi,8), %rdi
decq %rsi
addq $0x1c, %r8
jmp 0x1731e7
movq %rdx, %r8
subq %rsi, %r8
testq %rsi, %rsi
je 0x1731c7
movslq 0x4(%r14,%rbp,8), %r8
testq %rdi, %rdi
js 0x17323e
movslq (%r15,%rdi,4), %rdi
subq %rdi, %r8
subq %rsi, %rdx
negl %esi
movq 0x48(%rsp), %rdi
movl %esi, (%rdi,%rcx,4)
movq 0x90(%rsp), %rsi
movl %r8d, (%rsi,%rcx,4)
incq %rcx
cmpq %rax, %r8
cmovlq %r8, %rax
movq %rdx, %r8
jmp 0x1731c7
movq 0x50(%rsp), %rdx
addq $-0x1c, %rdx
xorl %esi, %esi
movl $0x3fffffff, %edi       # imm = 0x3FFFFFFF
xorl %r14d, %r14d
cmpq %rcx, %rsi
je 0x1733b7
movq 0x48(%rsp), %r15
movslq (%r15,%rsi,4), %r8
addq %r14, %r8
movq 0x90(%rsp), %r9
movl (%r9,%rsi,4), %r10d
subl %eax, %r10d
movq (%rbx), %r11
imulq $0x1c, %rsi, %r9
movl %r10d, (%r11,%r9)
movl %r14d, 0x10(%r11,%r9)
movl %r8d, 0x14(%r11,%r9)
movl (%r15,%rsi,4), %r15d
sarl %r15d
orl $-0x1, 0x4(%r11,%r9)
imulq $0x1c, %r14, %r14
movq 0x50(%rsp), %r12
leaq (%r12,%r14), %r10
movl 0x8(%r12,%r14), %ebp
movl %ebp, 0x8(%r11,%r9)
imulq $0x1c, %r15, %r11
imulq $0x1c, %r8, %r14
addq %rdx, %r14
xorl %r15d, %r15d
cmpq %r15, %r11
je 0x17337c
movups (%r10,%r15), %xmm0
movups 0xc(%r10,%r15), %xmm1
movups %xmm1, 0xec(%rsp)
movaps %xmm0, 0xe0(%rsp)
movups (%r14), %xmm0
movups 0xc(%r14), %xmm1
movups %xmm1, 0xc(%r10,%r15)
movups %xmm0, (%r10,%r15)
movups 0xec(%rsp), %xmm0
movups %xmm0, 0xc(%r14)
movapd 0xe0(%rsp), %xmm0
movupd %xmm0, (%r14)
movq (%rbx), %r12
addq %r9, %r12
addq $0x4, %r12
movl (%r12), %ebp
movl 0x4(%r10,%r15), %r13d
cmpl %r13d, %ebp
jbe 0x173359
movl %r13d, (%r12)
movl %r13d, %ebp
movl 0x4(%r14), %r13d
cmpl %r13d, %ebp
jbe 0x173366
movl %r13d, (%r12)
orl %edi, 0x18(%r14)
orl %edi, 0x18(%r10,%r15)
addq $0x1c, %r15
addq $-0x1c, %r14
jmp 0x1732e7
movq 0x48(%rsp), %r14
testb $0x1, (%r14,%rsi,4)
je 0x1733ac
movq (%rbx), %r14
movl 0x4(%r10,%r11), %ebp
cmpl %ebp, 0x4(%r14,%r9)
jbe 0x1733a1
addq %r14, %r9
addq $0x4, %r9
movl %ebp, (%r9)
addq %r11, %r10
orl $0x3fffffff, 0x18(%r10) # imm = 0x3FFFFFFF
incq %rsi
movq %r8, %r14
jmp 0x17327c
movq %rcx, 0x8(%rbx)
movq (%rbx), %rdi
imulq $0x1c, %rcx, %rsi
addq %rdi, %rsi
callq 0x15775d
movq %r14, %rax
addq $0x198, %rsp            # imm = 0x198
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq