// File: /workspace/github_cpp_makefile_star2_O2/chhylp123[P]hifiasm/inter.cpp
// Function: gl_rchain_lin_contain(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*, unsigned long*, long, All_reads*, char*, UC_Read*, long, double, long)
int64_t gl_rchain_lin_contain(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, uint64_t *a,
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, rev_n, is_fc, cc; int32_t *f, *c_n, *c_sc, *rch, *ssc; int64_t *p, *t, res_n = res->n, st, max_ii, max, max_n; 
    int64_t mm_ovlp, x, i, j, k, sc, csc, mm_sc, mm_idx, mm_n, sn, 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 = rch = dp->self_length; ssc = dp->indels;
	if(need_srt) {
        radix_sort_ul_ov_srt_qe(res->a, res->a + res_n);
        for (i = 1, j = 0; i <= res_n; i++) {
			res->a[i-1].qs = ((uint32_t)-1)-res->a[i-1].qs;
            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; li->qs = ((uint32_t)-1)-li->qs;
		rch[i] = INT32_MAX; ssc[i] = INT32_MIN; a[i] = ((uint64_t)-1); 
        mm_ovlp = max_ovlp_src_contain(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;
		// if(li->tn == 20171 || li->tn == 20209 || li->tn == 20204) {
		// 	fprintf(stderr, "\n[i::%ld] (id::%u)%.*s\t%c\tq::[%u, %u)\tt::[%u, %u)\tc::%u\tmax_d::%ld\n", i, li->tn,
        //             (int)Get_NAME_LENGTH(R_INF, res->a[i].tn), Get_NAME(R_INF, res->a[i].tn), 
		// 			"+-"[res->a[i].rev], res->a[i].qs, res->a[i].qe, res->a[i].ts, res->a[i].te,
		// 			!res->a[i].el, x+G_CHAIN_INDEL);
		// }
        x = find_ul_ov_max(i, res->a, x+G_CHAIN_INDEL); 
		// if(li->tn == 20171 || li->tn == 20209 || li->tn == 20204) {
		// 	fprintf(stderr, "[i::%ld] (id::%u)%.*s\t%c\tq::[%u, %u)\tt::[%u, %u)\tc::%u\tmax_j::%ld\n", i, li->tn,
        //             (int)Get_NAME_LENGTH(R_INF, res->a[i].tn), Get_NAME(R_INF, res->a[i].tn), 
		// 			"+-"[res->a[i].rev], res->a[i].qs, res->a[i].qe, res->a[i].ts, res->a[i].te,
		// 			!res->a[i].el, x);
		// }
        csc = li->qe - li->qs; csc -= (((int64_t)li->sec)*trans_sc);
        // mm_sc = csc; mm_idx = -1; mm_n = 1;
		mm_sc = INT32_MIN; mm_idx = -1; mm_n = 0; is_fc = 0;
        n_skip = 0; end_j = -1; tc.k = INT32_MAX;
        if ((x-st) > max_iter) st = x-max_iter;
        for (j = x; j >= st; --j) { // collect potential destination vertices
            lj = &(res->a[j]); 
			if(lj->qe <= li->qs) break;//even this pair has a overlap, its length will be very small; just ignore
			sc = connect_detect(res->a, res->n, i, j, ridx, rch, uref, uopt, bw, diff_ec_ul, p, f, &tc,
																trace, qstr, tu, ol, exz, e_rate, trans_sc, &cc);
			if(sc == INT32_MIN) continue;
			sn = c_n[j] + 1;
			// if(li->tn == 6312 || li->tn == 6322 || li->tn == 6317 || li->tn == 6319/** && lj->tn == 6329**/) {
			// 	fprintf(stderr, "(id::%u)%.*s\t%c\t(id::%u)%.*s\t%c\tsc::%ld\tsn::%ld\tc_n[j]::%d\tmsc::%ld\ti::%ld\tj::%ld\tm_idx::%ld\n", 
			// 		li->tn,	(int)Get_NAME_LENGTH(R_INF, li->tn), Get_NAME(R_INF, li->tn), "+-"[li->rev],
			// 		lj->tn,	(int)Get_NAME_LENGTH(R_INF, lj->tn), Get_NAME(R_INF, lj->tn), "+-"[lj->rev], 
			// 		sc, sn, c_n[j], mm_sc, i, j, mm_idx);
			// }
			// if(li->tn == 20209) {
			// 	fprintf(stderr, "[i::%ld] (id::%u)%.*s\t%c\tj::%ld\tsc::%ld\tsn::%ld\n", i, li->tn,
            //         (int)Get_NAME_LENGTH(R_INF, res->a[i].tn), Get_NAME(R_INF, res->a[i].tn), 
			// 		"+-"[res->a[i].rev], j, sc, sn);
			// }
			if((sc > mm_sc) || ((sc == mm_sc) && (sn > mm_n))) {
				mm_sc = sc, mm_idx = j; mm_n = sn; is_fc = cc;
				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_n = 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_n < c_n[j]))) {
                    max = f[j]; max_n = c_n[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]); 
            if(lj->qe > li->qs/** && lj->qs < li->qs**/) {
				///as max_ii < end_j, get_rid_backward_cigar_err still works
				sc = connect_detect(res->a, res->n, i, max_ii, ridx, rch, uref, uopt, bw, diff_ec_ul, p, f, &tc,
																trace, qstr, tu, ol, exz, e_rate, trans_sc, &cc);
				if(sc != INT32_MIN) {
					sn = c_n[max_ii] + 1;
					// if(li->tn == 6312 || li->tn == 6322 || li->tn == 6317 || li->tn == 6319/** && lj->tn == 6329**/) {
					// 	fprintf(stderr, "(id::%u)%.*s\t%c\t(id::%u)%.*s\t%c\tsc::%ld\tsn::%ld\tc_n[j]::%d\tmsc::%ld\ti::%ld\tmax_ii::%ld\tm_idx::%ld\n", 
					// 		li->tn,	(int)Get_NAME_LENGTH(R_INF, li->tn), Get_NAME(R_INF, li->tn), "+-"[li->rev],
					// 		lj->tn,	(int)Get_NAME_LENGTH(R_INF, lj->tn), Get_NAME(R_INF, lj->tn), "+-"[lj->rev], 
					// 		sc, sn, c_n[j], mm_sc, i, max_ii, mm_idx);
					// }
					if((sc > mm_sc) || ((sc == mm_sc) && (sn > mm_n))) {
                        mm_sc = sc; mm_idx = max_ii; mm_n = sn; is_fc = cc;
                    }
				}
            }
        }

		sc = csc; sn = 1;///for i itself
		if((sc > mm_sc) || ((sc == mm_sc) && (sn > mm_n))) {
			mm_sc = sc, mm_idx = -1; mm_n = sn; is_fc = 0;
		}

        if(mm_sc < 0) {
            mm_sc = csc; mm_idx = -1; mm_n = 1;
        }

		// if(li->tn == 6317) {
		// 	fprintf(stderr, "+(id::%u)%.*s\t%c\tmm_idx::%ld\tmm_sc::%ld\tmm_n::%ld\n", 
		// 		li->tn,	(int)Get_NAME_LENGTH(R_INF, li->tn), Get_NAME(R_INF, li->tn), "+-"[li->rev], mm_idx, mm_sc, mm_n);
		// }

		if(mm_idx >= 0) {
			///mo meed to update mm_sc and is_fc
			propagate_transitive_reduction(uref, uopt, ridx, bw, diff_ec_ul, res->a, x+1, i, rch, f, p, c_n, t, &mm_sc, &mm_idx, &mm_n);
		}
		// if(li->tn == 6317) {
		// 	fprintf(stderr, "-(id::%u)%.*s\t%c\tmm_idx::%ld\tmm_sc::%ld\tmm_n::%ld\n", 
		// 		li->tn,	(int)Get_NAME_LENGTH(R_INF, li->tn), Get_NAME(R_INF, li->tn), "+-"[li->rev], mm_idx, mm_sc, mm_n);
		// }
		// collapse_contain(res->a, res_n, i, &mm_idx, &mm_sc, p, c_sc, end_j);

        f[i] = mm_sc; p[i] = mm_idx; c_n[i] = mm_n; 
		if(mm_idx < 0 || ((ssc[mm_idx] < mm_sc) && (is_fc == 0))) ssc[i] = mm_sc;
		else ssc[i] = ssc[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(ssc[i] < plus) plus = ssc[i];//minmun negative
		// if(li->tn == 20171 || li->tn == 20209 || li->tn == 20204) {
		// 	fprintf(stderr, "[i::%ld]\tf::%d\tp::%ld\n", i, f[i], p[i]);
		// }
        
    }

	for (i = 0; i < res_n; ++i) {///make all f[] positive
        ssc[i] -= plus; t[i] = ((uint64_t)ssc[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]));
        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; 
        }
		// flat_contain(ex+n_v0, n_v-n_v0);
		res->a[k].te = res->a[k].ts + flat_contain(ridx, uref, uopt, bw, diff_ec_ul, qlen, max_skip, max_iter, max_dis, 
		ex + res->a[k].ts, res->a[k].te - res->a[k].ts, f, ssc, p, t, &(res->a[k]));
    }
    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, 0x50(%rsp)
movq %r9, 0x48(%rsp)
movq %r8, 0xb0(%rsp)
movq %rcx, 0xa8(%rsp)
movq %rdi, 0xa0(%rsp)
movq 0x8(%rsi), %rbp
testq %rbp, %rbp
je 0x175cb4
movq %rsi, %r14
movq %rdx, 0x98(%rsp)
movq 0x238(%rsp), %rbx
movq 0x1f8(%rsp), %r12
movq %r12, %rdi
movq %rbp, %rsi
xorl %edx, %edx
callq 0x1383e
movq 0x28(%r12), %r13
movq (%r12), %rax
movq %rax, 0x20(%rsp)
movq 0x8(%r12), %rax
movq %rax, 0x10(%rsp)
movq 0x20(%r12), %rax
movq %rax, 0x8(%rsp)
movq 0x18(%r12), %rax
movq %rax, 0x38(%rsp)
movq 0x10(%r12), %r15
testq %rbx, %rbx
movq %r15, 0x78(%rsp)
je 0x175cbb
pushq $0x1
popq %rbx
movq (%r14), %rdi
imulq $0x1c, %rbp, %rsi
addq %rdi, %rsi
callq 0x156f5c
xorl %eax, %eax
testq %rbp, %rbp
movl $0x0, %r15d
cmovgq %rbp, %r15
movq %r15, 0x90(%rsp)
negq %r15
pushq $0x1c
popq %r12
leaq (%r15,%rbx), %rcx
cmpq $0x1, %rcx
je 0x175cad
movq (%r14), %rcx
notl -0x18(%rcx,%r12)
cmpq %rbx, %rbp
je 0x175c7f
movl 0x8(%rcx,%r12), %edx
imulq $0x1c, %rax, %rsi
cmpl 0x8(%rcx,%rsi), %edx
jne 0x175c7f
movq %rax, %rdx
jmp 0x175ca1
movq %rbx, %rsi
subq %rax, %rsi
movq %rbx, %rdx
cmpq $0x2, %rsi
jl 0x175ca1
leaq (%rcx,%r12), %rsi
imulq $0x1c, %rax, %rdi
addq %rcx, %rdi
callq 0x1571fa
movq %rbx, %rdx
incq %rbx
addq $0x1c, %r12
movq %rdx, %rax
jmp 0x175c54
movq 0x78(%rsp), %r15
jmp 0x175ccc
xorl %ebx, %ebx
jmp 0x17657e
xorl %eax, %eax
testq %rbp, %rbp
cmovgq %rbp, %rax
movq %rax, 0x90(%rsp)
movq %rbp, 0xc0(%rsp)
leaq (,%rbp,8), %rdx
movq $0x0, 0x18(%rsp)
movq %r13, 0x40(%rsp)
movq %r13, %rdi
xorl %esi, %esi
callq 0x20e0
movq 0x1d8(%rsp), %rax
incq %rax
movq %rax, 0xc8(%rsp)
pushq $-0x1
popq %r12
xorl %ebp, %ebp
xorl %edi, %edi
movq 0x90(%rsp), %rdx
cmpq %rdx, %rbp
je 0x1762f3
movq %r12, 0xd0(%rsp)
movq %rdi, 0xd8(%rsp)
movq (%r14), %rbx
imulq $0x1c, %rbp, %r13
leaq (%rbx,%r13), %rax
movq %rax, 0x30(%rsp)
movl 0xc(%rbx,%r13), %eax
movl 0x18(%rbx,%r13), %esi
notl 0x4(%rbx,%r13)
shrdl $0x1f, %eax, %esi
movq 0x38(%rsp), %rax
movl $0x7fffffff, (%rax,%rbp,4) # imm = 0x7FFFFFFF
movl $0x80000000, (%r15,%rbp,4) # imm = 0x80000000
movq 0x208(%rsp), %rax
orq $-0x1, (%rax,%rbp,8)
xorl $0x1, %esi
movq 0x48(%rsp), %rdi
callq 0x173810
movl 0x4(%rbx,%r13), %ecx
addq %rax, %rcx
cvtsi2sd %rcx, %xmm0
mulsd 0x50(%rsp), %xmm0
cvttsd2si %xmm0, %rdx
movq 0x1d0(%rsp), %rax
cmpq %rax, %rdx
cmovleq %rax, %rdx
addq %rcx, %rdx
movq 0xc8(%rsp), %rax
cmpq %rax, %rdx
cmovgeq %rax, %rdx
movq (%r14), %rsi
subl $-0x80, %edx
movl %ebp, %edi
callq 0x160717
movq 0x10(%rsp), %r10
movl %eax, 0x8c(%rsp)
movslq %eax, %r12
movl 0x8(%rbx,%r13), %ecx
movl 0x18(%rbx,%r13), %eax
movq %r13, 0x80(%rsp)
subl 0x4(%rbx,%r13), %ecx
andl $0x3fffffff, %eax       # imm = 0x3FFFFFFF
imulq 0x210(%rsp), %rax
subq %rax, %rcx
movq %rcx, 0x68(%rsp)
movq %r12, %rax
movq 0x18(%rsp), %rsi
subq %rsi, %rax
movq %r12, %rcx
movq 0x1e8(%rsp), %rdx
subq %rdx, %rcx
cmpq %rdx, %rax
cmovgq %rcx, %rsi
movq %rsi, 0x18(%rsp)
movq $0x7fffffff, 0x100(%rsp) # imm = 0x7FFFFFFF
imulq $0xe, %r12, %r13
addq $0x4, %r13
xorl %r15d, %r15d
movq $-0x80000000, (%rsp)    # imm = 0x80000000
pushq $-0x1
popq %rax
movq %rax, 0x70(%rsp)
movl $0x0, 0x28(%rsp)
xorl %ebx, %ebx
cmpq 0x18(%rsp), %r12
jl 0x175f8b
movq (%r14), %rdi
movl (%rdi,%r13,2), %eax
movq 0x30(%rsp), %rcx
cmpl 0x4(%rcx), %eax
jbe 0x175f8b
subq $0x8, %rsp
movq %rbp, %rdx
movq %r12, %rcx
movq 0x220(%rsp), %r8
movq 0x40(%rsp), %r9
movsd 0x58(%rsp), %xmm0
movsd 0xc0(%rsp), %xmm1
leaq 0x34(%rsp), %rax
pushq %rax
pushq 0x220(%rsp)
pushq 0x218(%rsp)
pushq 0xc0(%rsp)
pushq 0x250(%rsp)
pushq 0x250(%rsp)
pushq 0xe0(%rsp)
leaq 0x140(%rsp), %rax
pushq %rax
pushq 0x68(%rsp)
pushq %r10
pushq 0x228(%rsp)
pushq 0xa8(%rsp)
pushq 0x118(%rsp)
callq 0x1733e0
addq $0x70, %rsp
cmpq $-0x80000000, %rax      # imm = 0x80000000
jne 0x175f0e
movq %r15, %rcx
movq 0x10(%rsp), %r10
jmp 0x175f7c
movq 0x8(%rsp), %rcx
movslq (%rcx,%r12,4), %rcx
incq %rcx
cmpq (%rsp), %rax
jg 0x175f27
jne 0x175f4a
cmpq %rcx, %r15
jge 0x175f4a
movl 0x2c(%rsp), %edx
movl %edx, 0x28(%rsp)
xorl %edx, %edx
testq %rbx, %rbx
setg %dl
subq %rdx, %rbx
movq %r12, 0x70(%rsp)
movq %rax, (%rsp)
movq 0x10(%rsp), %r10
jmp 0x175f6a
movq 0x40(%rsp), %rax
cmpq %rbp, (%rax,%r12,8)
movq 0x10(%rsp), %r10
jne 0x175f67
cmpq 0x1e0(%rsp), %rbx
jge 0x175f8b
incq %rbx
movq %r15, %rcx
movq (%r10,%r12,8), %rax
testq %rax, %rax
js 0x175f7c
movq 0x40(%rsp), %rdx
movq %rbp, (%rdx,%rax,8)
decq %r12
addq $-0xe, %r13
movq %rcx, %r15
jmp 0x175e59
movq %r15, 0x58(%rsp)
movq 0x70(%rsp), %rax
movq %rax, 0x60(%rsp)
movq 0xd0(%rsp), %rbx
testq %rbx, %rbx
movq 0x1f0(%rsp), %r13
js 0x175fd2
movq (%r14), %rax
movq 0x80(%rsp), %rcx
movl 0x8(%rax,%rcx), %ecx
imulq $0x1c, %rbx, %rdx
movl 0x8(%rax,%rdx), %eax
addq %r13, %rax
cmpq %rcx, %rax
jge 0x17605a
movq $-0x80000000, %rcx      # imm = 0x80000000
pushq $-0x1
popq %rbx
movq $-0x80000000, %rdx      # imm = 0x80000000
movq %rbp, %rax
imulq $0x7, %rax, %rsi
decq %rax
addq $-0x5, %rsi
leaq 0x1(%rax), %rdi
cmpq 0x18(%rsp), %rdi
jle 0x17605a
movq (%r14), %rdi
movq 0x80(%rsp), %r8
movl 0x8(%rdi,%r8), %r8d
movl (%rdi,%rsi,4), %edi
addq %r13, %rdi
cmpq %r8, %rdi
jl 0x17605a
movq 0x20(%rsp), %rdi
movslq (%rdi,%rax,4), %rdi
cmpq %rdi, %rcx
jl 0x17603e
jne 0x176035
movq 0x8(%rsp), %r8
movslq (%r8,%rax,4), %r8
cmpq %r8, %rdx
jl 0x17604f
decq %rax
addq $-0x7, %rsi
jmp 0x175ff1
movq 0x8(%rsp), %rcx
movslq (%rcx,%rax,4), %rdx
movq %rax, %rbx
movq %rdi, %rcx
jmp 0x175fe6
movq %rax, %rbx
movq %rdi, %rcx
movq %r8, %rdx
jmp 0x175fe6
testq %rbx, %rbx
movq 0x68(%rsp), %rdx
js 0x176123
cmpq %r12, %rbx
jge 0x176123
movq (%r14), %rdi
imulq $0x1c, %rbx, %rax
movl 0x8(%rdi,%rax), %eax
movq 0x30(%rsp), %rcx
cmpl 0x4(%rcx), %eax
jbe 0x17611e
subq $0x8, %rsp
movq %rbp, %rdx
movq %rbx, %rcx
movq 0x220(%rsp), %r8
movq 0x40(%rsp), %r9
movsd 0x58(%rsp), %xmm0
movsd 0xc0(%rsp), %xmm1
leaq 0x34(%rsp), %rax
pushq %rax
pushq 0x220(%rsp)
pushq 0x218(%rsp)
pushq 0xc0(%rsp)
pushq 0x250(%rsp)
pushq 0x250(%rsp)
pushq 0xe0(%rsp)
leaq 0x140(%rsp), %rax
pushq %rax
pushq 0x68(%rsp)
pushq %r10
pushq 0x228(%rsp)
pushq 0xa8(%rsp)
pushq 0x118(%rsp)
callq 0x1733e0
addq $0x70, %rsp
cmpq $-0x80000000, %rax      # imm = 0x80000000
jne 0x1762a5
movq 0x10(%rsp), %r10
movq 0x68(%rsp), %rdx
movq %rbx, %r12
cmpq (%rsp), %rdx
jg 0x176133
jne 0x176152
testq %r15, %r15
jg 0x176152
orq $-0x1, 0x60(%rsp)
movq $0x1, 0x58(%rsp)
movb $0x1, %bl
testq %rdx, %rdx
jns 0x17621a
jmp 0x17620b
cmpl $0x0, 0x28(%rsp)
sete %bl
cmpq $0x0, (%rsp)
js 0x17620b
movq 0x70(%rsp), %rcx
testq %rcx, %rcx
js 0x176205
movq (%r14), %r8
movl 0x8c(%rsp), %r9d
incl %r9d
subq $0x50, %rsp
leaq 0xa8(%rsp), %rax
movq %rax, 0x40(%rsp)
leaq 0xb0(%rsp), %rax
movq %rax, 0x38(%rsp)
movq 0x90(%rsp), %rax
movq %rax, 0x28(%rsp)
movq 0x58(%rsp), %rax
movq %rax, 0x20(%rsp)
movq %r10, 0x18(%rsp)
movq 0x88(%rsp), %rax
movq %rax, 0x8(%rsp)
movq %rbp, (%rsp)
movq 0x98(%rsp), %rsi
movq 0x268(%rsp), %rdx
movq 0x220(%rsp), %rcx
movsd 0xa0(%rsp), %xmm0
callq 0x175983
movq 0x60(%rsp), %r10
addq $0x50, %rsp
movq 0x60(%rsp), %rcx
movq 0x58(%rsp), %r15
movq (%rsp), %rdx
jmp 0x176221
orq $-0x1, 0x60(%rsp)
movq $0x1, 0x58(%rsp)
pushq $0x1
popq %r15
pushq $-0x1
popq %rcx
movq 0x20(%rsp), %rax
movl %edx, (%rax,%rbp,4)
movq %rcx, (%r10,%rbp,8)
movq 0x8(%rsp), %rax
movl %r15d, (%rax,%rbp,4)
testq %rcx, %rcx
movq 0x78(%rsp), %r15
js 0x176251
movslq (%r15,%rcx,4), %rax
cmpq %rax, %rdx
setg %cl
andb %bl, %cl
cmpb $0x1, %cl
jne 0x176253
movl %edx, %eax
movl %eax, (%r15,%rbp,4)
testq %r12, %r12
movq 0xd8(%rsp), %rdi
js 0x176291
movq (%r14), %rcx
movq 0x80(%rsp), %rdx
movl 0x8(%rcx,%rdx), %edx
imulq $0x1c, %r12, %rsi
movl 0x8(%rcx,%rsi), %ecx
addq %r13, %rcx
cmpq %rdx, %rcx
jl 0x176294
movq 0x20(%rsp), %rdx
movl (%rdx,%r12,4), %ecx
cmpl (%rdx,%rbp,4), %ecx
jge 0x176294
movq %rbp, %r12
cltq
cmpq %rax, %rdi
cmovgeq %rax, %rdi
incq %rbp
jmp 0x175d0f
movq 0x8(%rsp), %rcx
movslq (%rcx,%rbx,4), %rcx
incq %rcx
cmpq (%rsp), %rax
movq 0x10(%rsp), %r10
movq 0x68(%rsp), %rdx
jg 0x1762d0
jne 0x176123
cmpq %rcx, %r15
jge 0x176123
movq %rbx, 0x60(%rsp)
movq %rcx, 0x58(%rsp)
movl 0x2c(%rsp), %esi
movl %esi, 0x28(%rsp)
movq %rbx, 0x70(%rsp)
movq %rcx, %r15
movq %rax, (%rsp)
jmp 0x176123
xorl %eax, %eax
movq 0x40(%rsp), %rbx
movq 0xc0(%rsp), %r12
subq $0x1, %rdx
jb 0x176323
movl (%r15,%rax,2), %ecx
subl %edi, %ecx
movl %ecx, (%r15,%rax,2)
shlq $0x20, %rcx
addq %rax, %rcx
movq %rcx, (%rbx,%rax,4)
addq $0x2, %rax
jmp 0x176302
leaq (%rbx,%r12,8), %rsi
movq %rbx, %rdi
callq 0x156cf6
movq 0x10(%rsp), %r10
movq $0x0, 0x30(%rsp)
xorl %esi, %esi
movq $0x0, 0x18(%rsp)
movq 0x98(%rsp), %r9
testq %r12, %r12
jle 0x176401
movq %rsi, %rax
decq %r12
movl (%rbx,%r12,8), %edx
shrl %edx
imulq $0x1c, %rsi, %rsi
addq %r9, %rsi
xorl %ecx, %ecx
testq %rdx, %rdx
js 0x1763a5
testb $0x1, (%rbx,%rdx,8)
jne 0x1763a5
movq (%r14), %rdi
imulq $0x1c, %rdx, %r8
movupd (%rdi,%r8), %xmm0
movups 0xc(%rdi,%r8), %xmm1
movups %xmm1, 0xc(%rsi)
movupd %xmm0, (%rsi)
orb $0x1, (%rbx,%rdx,8)
movq (%r10,%rdx,8), %rdx
decq %rcx
addq $0x1c, %rsi
jmp 0x17636e
movq %rax, %rsi
subq %rcx, %rsi
testq %rcx, %rcx
je 0x176350
movslq 0x4(%rbx,%r12,8), %rsi
testq %rdx, %rdx
js 0x1763c6
movq 0x20(%rsp), %rdi
movslq (%rdi,%rdx,4), %rdx
subq %rdx, %rsi
subq %rcx, %rax
negl %ecx
movq 0x8(%rsp), %rdx
movq 0x18(%rsp), %rdi
movl %ecx, (%rdx,%rdi,4)
movq 0x38(%rsp), %rcx
movl %esi, (%rcx,%rdi,4)
incq %rdi
movq %rdi, 0x18(%rsp)
movq 0x30(%rsp), %rcx
cmpq %rcx, %rsi
cmovlq %rsi, %rcx
movq %rcx, 0x30(%rsp)
movq %rax, %rsi
jmp 0x176350
leaq -0x1c(%r9), %rax
movq %rax, (%rsp)
xorl %ebp, %ebp
movl $0x3fffffff, %r15d      # imm = 0x3FFFFFFF
xorl %ebx, %ebx
cmpq 0x18(%rsp), %rbp
je 0x176566
movq 0x8(%rsp), %rdx
movslq (%rdx,%rbp,4), %r12
addq %rbx, %r12
movq 0x38(%rsp), %rax
movl (%rax,%rbp,4), %eax
subl 0x30(%rsp), %eax
movq (%r14), %rcx
imulq $0x1c, %rbp, %r13
movl %eax, (%rcx,%r13)
movl %ebx, 0x10(%rcx,%r13)
movl %r12d, 0x14(%rcx,%r13)
movl (%rdx,%rbp,4), %ecx
sarl %ecx
imulq $0x1c, %rbx, %rax
movq 0x98(%rsp), %rdi
addq %rdi, %rax
imulq $0x1c, %rcx, %rcx
imulq $0x1c, %r12, %rdx
addq (%rsp), %rdx
xorl %esi, %esi
cmpq %rsi, %rcx
je 0x1764c7
movups (%rax,%rsi), %xmm0
movups 0xc(%rax,%rsi), %xmm1
movups %xmm1, 0xec(%rsp)
movaps %xmm0, 0xe0(%rsp)
movups (%rdx), %xmm0
movups 0xc(%rdx), %xmm1
movups %xmm1, 0xc(%rax,%rsi)
movups %xmm0, (%rax,%rsi)
movups 0xec(%rsp), %xmm0
movups %xmm0, 0xc(%rdx)
movapd 0xe0(%rsp), %xmm0
movupd %xmm0, (%rdx)
orl %r15d, 0x18(%rdx)
orl %r15d, 0x18(%rax,%rsi)
addq $0x1c, %rsi
addq $-0x1c, %rdx
jmp 0x17646d
movq 0x8(%rsp), %rdx
testb $0x1, (%rdx,%rbp,4)
je 0x1764da
orl $0x3fffffff, 0x18(%rax,%rcx) # imm = 0x3FFFFFFF
movq (%r14), %rax
leaq (%rax,%r13), %rsi
movl 0x10(%rax,%r13), %ebx
movl 0x14(%rax,%r13), %eax
imulq $0x1c, %rbx, %r10
addq %rdi, %r10
subl %ebx, %eax
subq $0x8, %rsp
movq 0x220(%rsp), %rdi
movq 0x50(%rsp), %rdx
movq 0x1d8(%rsp), %rcx
movsd 0x58(%rsp), %xmm0
movq 0x1e0(%rsp), %r8
movq 0x1e8(%rsp), %r9
pushq %rsi
pushq 0x50(%rsp)
pushq 0x28(%rsp)
pushq 0x98(%rsp)
pushq 0x48(%rsp)
pushq %rax
pushq %r10
pushq 0x230(%rsp)
pushq 0x230(%rsp)
callq 0x175342
addq $0x50, %rsp
addl %ebx, %eax
movq (%r14), %rcx
movl %eax, 0x14(%rcx,%r13)
incq %rbp
movq %r12, %rbx
jmp 0x176413
movq 0x18(%rsp), %rax
movq %rax, 0x8(%r14)
movq (%r14), %rdi
imulq $0x1c, %rax, %rsi
addq %rdi, %rsi
callq 0x15775d
movq %rbx, %rax
addq $0x198, %rsp            # imm = 0x198
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq