// File: /workspace/github_cpp_makefile_star2_O3/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 $0x1b8, %rsp            # imm = 0x1B8
movsd %xmm1, 0x80(%rsp)
movsd %xmm0, 0x68(%rsp)
movq %r9, 0x60(%rsp)
movq %r8, 0xd8(%rsp)
movq %rcx, 0xd0(%rsp)
movq %rsi, %r12
movq %rdi, 0xc8(%rsp)
movq 0x8(%rsi), %rsi
testq %rsi, %rsi
je 0x1c1218
movq %rdx, 0xb8(%rsp)
movq 0x258(%rsp), %rbx
movq 0x218(%rsp), %r15
movq %r15, %rdi
movq %rsi, 0x98(%rsp)
xorl %edx, %edx
callq 0x3ecb0
movq 0x28(%r15), %r13
movq (%r15), %rax
movq %rax, 0x28(%rsp)
movq 0x8(%r15), %rax
movq %rax, 0x38(%rsp)
movq 0x20(%r15), %rax
movq %rax, 0x18(%rsp)
movq 0x18(%r15), %rax
movq %rax, 0x50(%rsp)
movq 0x10(%r15), %rbp
testq %rbx, %rbx
je 0x1c0a89
movq (%r12), %rdi
movq 0x98(%rsp), %rbx
leaq (%rbx,%rbx,8), %rax
leaq (%rax,%rax,2), %rsi
addq %rdi, %rsi
addq %rbx, %rsi
callq 0x19e2b4
testq %rbx, %rbx
jle 0x1c152d
negq %rbx
movl $0x1, %r14d
movl $0x1c, %r15d
xorl %eax, %eax
movq (%r12), %rcx
notl -0x18(%rcx,%r15)
movq %rbx, %rdx
addq %r14, %rdx
je 0x1c0a49
movl 0x8(%rcx,%r15), %edx
leaq (%rax,%rax,8), %rsi
leaq (%rsi,%rsi,2), %rsi
addq %rax, %rsi
cmpl 0x8(%rcx,%rsi), %edx
jne 0x1c0a49
movq %rax, %rdx
jmp 0x1c0a72
movq %r14, %rsi
subq %rax, %rsi
movq %r14, %rdx
cmpq $0x2, %rsi
jl 0x1c0a72
leaq (%rcx,%r15), %rsi
leaq (%rax,%rax,8), %rdx
leaq (%rdx,%rdx,2), %rdi
addq %rax, %rdi
addq %rcx, %rdi
callq 0x19e55c
movq %r14, %rdx
leaq (%rbx,%r14), %rcx
incq %rcx
incq %r14
addq $0x1c, %r15
movq %rdx, %rax
cmpq $0x1, %rcx
jne 0x1c0a1d
movq 0x98(%rsp), %rbx
leaq (,%rbx,8), %rdx
movq %r13, %rdi
xorl %esi, %esi
callq 0x20e0
testq %rbx, %rbx
jle 0x1c153f
movq %rbp, %r11
movq %r13, 0x58(%rsp)
movq 0x1f8(%rsp), %rax
incq %rax
movq %rax, 0xe0(%rsp)
movq $-0x1, %r14
movq $-0x14, 0xc0(%rsp)
xorl %eax, %eax
xorl %r13d, %r13d
movq $-0x1, (%rsp)
movq $0x0, 0x30(%rsp)
movq %r12, 0x88(%rsp)
movq %rbp, 0x48(%rsp)
movq %r14, 0xa0(%rsp)
movq 0x30(%rsp), %rbx
movq %rax, 0xf8(%rsp)
movq (%r12), %r15
leaq (,%r13,8), %rax
addq %r13, %rax
leaq (%rax,%rax,2), %r14
addq %r13, %r14
movl 0xc(%r15,%r14), %eax
movl 0x18(%r15,%r14), %esi
shrdl $0x1f, %eax, %esi
leaq (%r15,%r14), %rax
movq %rax, 0x90(%rsp)
notl 0x4(%r15,%r14)
movq 0x50(%rsp), %rax
movl $0x7fffffff, (%rax,%r13,4) # imm = 0x7FFFFFFF
movl $0x80000000, (%r11,%r13,4) # imm = 0x80000000
movq 0x228(%rsp), %rax
movq $-0x1, (%rax,%r13,8)
xorl $0x1, %esi
movq 0x60(%rsp), %rdi
callq 0x1be0f4
movl 0x4(%r15,%r14), %ecx
addq %rax, %rcx
xorps %xmm0, %xmm0
cvtsi2sd %rcx, %xmm0
mulsd 0x68(%rsp), %xmm0
cvttsd2si %xmm0, %rdx
movq 0x1f0(%rsp), %rax
cmpq %rax, %rdx
cmovleq %rax, %rdx
addq %rcx, %rdx
movq 0xe0(%rsp), %rax
cmpq %rax, %rdx
cmovgeq %rax, %rdx
subl $-0x80, %edx
movl %r13d, %edi
movq %r15, %rsi
callq 0x1a83b5
movl %eax, 0xb4(%rsp)
cltq
movl 0x8(%r15,%r14), %ecx
movl 0x18(%r15,%r14), %edx
movq %rdx, 0xe8(%rsp)
movq %r14, 0xa8(%rsp)
subl 0x4(%r15,%r14), %ecx
movq %rcx, 0xf0(%rsp)
movq $0x7fffffff, 0x120(%rsp) # imm = 0x7FFFFFFF
movq %rax, %rcx
subq %rbx, %rcx
movq %rax, %rsi
movq 0x208(%rsp), %rdx
subq %rdx, %rsi
cmpq %rdx, %rcx
cmovleq %rbx, %rsi
movq %rsi, 0x30(%rsp)
cmpq %rax, %rsi
jle 0x1c0c45
movq $-0x80000000, 0x8(%rsp) # imm = 0x80000000
movq $-0x1, 0x10(%rsp)
xorl %ebx, %ebx
movl $0x0, 0x24(%rsp)
jmp 0x1c0dbf
movq %rax, %rbp
shlq $0x4, %rbp
subq %rax, %rbp
subq %rax, %rbp
addq $0x4, %rbp
movq $-0x1, 0x10(%rsp)
movq $-0x80000000, 0x8(%rsp) # imm = 0x80000000
xorl %r14d, %r14d
movq %rax, %r15
movl $0x0, 0x24(%rsp)
xorl %r12d, %r12d
movq 0x88(%rsp), %rax
movq (%rax), %rdi
movl (%rdi,%rbp,2), %eax
movq 0x90(%rsp), %rcx
cmpl 0x4(%rcx), %eax
jbe 0x1c0db9
subq $0x8, %rsp
movq %r13, %rdx
movq %r15, %rcx
movq 0x240(%rsp), %r8
movq 0x58(%rsp), %r9
movsd 0x70(%rsp), %xmm0
movsd 0x88(%rsp), %xmm1
leaq 0x4c(%rsp), %rax
pushq %rax
pushq 0x240(%rsp)
pushq 0x238(%rsp)
pushq 0xe8(%rsp)
pushq 0x270(%rsp)
pushq 0x270(%rsp)
pushq 0x108(%rsp)
leaq 0x160(%rsp), %rax
pushq %rax
pushq 0x70(%rsp)
pushq 0x88(%rsp)
pushq 0x248(%rsp)
pushq 0xc0(%rsp)
pushq 0x140(%rsp)
callq 0x1bdcad
addq $0x70, %rsp
cmpq $-0x80000000, %rax      # imm = 0x80000000
jne 0x1c0d2d
movq %r12, %rbx
jmp 0x1c0d9e
movq 0x18(%rsp), %rcx
movslq (%rcx,%r15,4), %rbx
incq %rbx
movq 0x8(%rsp), %rcx
cmpq %rcx, %rax
jg 0x1c0d4a
jne 0x1c0d67
cmpq %rbx, %r12
jge 0x1c0d67
movl 0x44(%rsp), %ecx
movl %ecx, 0x24(%rsp)
xorl %ecx, %ecx
testq %r14, %r14
setg %cl
subq %rcx, %r14
movq %r15, 0x10(%rsp)
movq %rax, %rcx
jmp 0x1c0d82
movq 0x58(%rsp), %rax
cmpq %r13, (%rax,%r15,8)
jne 0x1c0d7f
cmpq 0x200(%rsp), %r14
jge 0x1c0db9
incq %r14
movq %r12, %rbx
movq %rcx, 0x8(%rsp)
movq 0x38(%rsp), %rax
movq (%rax,%r15,8), %rax
testq %rax, %rax
js 0x1c0d9e
movq 0x58(%rsp), %rcx
movq %r13, (%rcx,%rax,8)
leaq -0x1(%r15), %rax
addq $-0xe, %rbp
movq %rbx, %r12
cmpq 0x30(%rsp), %r15
movq %rax, %r15
jg 0x1c0c79
jmp 0x1c0dbf
movq %r12, %rbx
movq %r15, %rax
movq %rbx, 0x70(%rsp)
movq 0x10(%rsp), %rcx
movq %rcx, 0x78(%rsp)
cmpq $0x0, (%rsp)
movq 0x88(%rsp), %r12
movq 0x48(%rsp), %r11
movq 0x210(%rsp), %r15
movq 0xa0(%rsp), %r14
js 0x1c0e21
movq (%r12), %rcx
movq 0xa8(%rsp), %rdx
movl 0x8(%rcx,%rdx), %edx
movq (%rsp), %rdi
leaq (%rdi,%rdi,8), %rsi
leaq (%rsi,%rsi,2), %rsi
addq %rdi, %rsi
movl 0x8(%rcx,%rsi), %ecx
addq %r15, %rcx
cmpq %rdx, %rcx
jge 0x1c0eb4
cmpq 0x30(%rsp), %r13
jle 0x1c0f98
movq (%r12), %rcx
movq 0xa8(%rsp), %rdx
movl 0x8(%rcx,%rdx), %edx
addq 0xc0(%rsp), %rcx
movq $-0x1, (%rsp)
movq $-0x80000000, %rdi      # imm = 0x80000000
movq %r14, %rsi
movq $-0x80000000, %r8       # imm = 0x80000000
movl (%rcx), %r9d
addq %r15, %r9
cmpq %rdx, %r9
jl 0x1c0eb4
movq 0x28(%rsp), %r9
movslq (%r9,%rsi,4), %r9
cmpq %r9, %r8
jge 0x1c0e88
movq 0x18(%rsp), %rdi
movslq (%rdi,%rsi,4), %rdi
movq %rsi, (%rsp)
movq %r9, %r8
jmp 0x1c0ea2
jne 0x1c0ea2
movq 0x18(%rsp), %r10
movslq (%r10,%rsi,4), %r10
cmpq %r10, %rdi
jge 0x1c0ea2
movq %rsi, (%rsp)
movq %r9, %r8
movq %r10, %rdi
leaq -0x1(%rsi), %r9
addq $-0x1c, %rcx
cmpq 0x30(%rsp), %rsi
movq %r9, %rsi
jg 0x1c0e5d
movq (%rsp), %rbp
testq %rbp, %rbp
js 0x1c0f93
cmpq %rax, %rbp
jge 0x1c0f93
movq (%r12), %rdi
leaq (,%rbp,8), %rax
addq %rbp, %rax
leaq (%rax,%rax,2), %rax
addq %rbp, %rax
movl 0x8(%rdi,%rax), %eax
movq 0x90(%rsp), %rcx
cmpl 0x4(%rcx), %eax
jbe 0x1c0f93
subq $0x8, %rsp
movq %r13, %rdx
movq %rbp, %rcx
movq 0x240(%rsp), %r8
movq 0x58(%rsp), %r9
movsd 0x70(%rsp), %xmm0
movsd 0x88(%rsp), %xmm1
leaq 0x4c(%rsp), %rax
pushq %rax
pushq 0x240(%rsp)
pushq 0x238(%rsp)
pushq 0xe8(%rsp)
pushq 0x270(%rsp)
pushq 0x270(%rsp)
pushq 0x108(%rsp)
leaq 0x160(%rsp), %rax
pushq %rax
pushq 0x70(%rsp)
pushq 0x88(%rsp)
pushq 0x248(%rsp)
pushq 0xc0(%rsp)
pushq 0x140(%rsp)
callq 0x1bdcad
addq $0x70, %rsp
cmpq $-0x80000000, %rax      # imm = 0x80000000
jne 0x1c11ab
movq %rbx, %rcx
movq 0x48(%rsp), %r11
jmp 0x1c0fa2
movq %rbx, %rcx
jmp 0x1c0fa2
movq %rbx, %rcx
movq $-0x1, %rbp
movq 0x8(%rsp), %rdi
movq 0x10(%rsp), %r8
movq 0xe8(%rsp), %rax
andl $0x3fffffff, %eax       # imm = 0x3FFFFFFF
imulq 0x230(%rsp), %rax
movq 0xf0(%rsp), %rsi
subq %rax, %rsi
cmpq %rdi, %rsi
jg 0x1c0fd9
jne 0x1c0ff9
testq %rcx, %rcx
jg 0x1c0ff9
movq $-0x1, 0x78(%rsp)
movq $0x1, 0x70(%rsp)
testq %rsi, %rsi
jns 0x1c1102
jmp 0x1c10f0
testq %rdi, %rdi
js 0x1c10f0
testq %r8, %r8
js 0x1c11ee
movq %rbp, (%rsp)
movq (%r12), %r8
movl 0xb4(%rsp), %r9d
incl %r9d
subq $0x50, %rsp
leaq 0xc0(%rsp), %rax
movq %rax, 0x40(%rsp)
leaq 0xc8(%rsp), %rax
movq %rax, 0x38(%rsp)
movq 0xa8(%rsp), %rax
movq %rax, 0x28(%rsp)
movq 0x68(%rsp), %rbp
movq %rbp, 0x20(%rsp)
movq 0x88(%rsp), %rbx
movq %rbx, 0x18(%rsp)
movq 0xa0(%rsp), %rax
movq %rax, 0x8(%rsp)
movq %r13, (%rsp)
movq 0xb0(%rsp), %rsi
movq 0x288(%rsp), %rdx
movq 0x240(%rsp), %rcx
movsd 0xb8(%rsp), %xmm0
movq %rdi, %r14
callq 0x1c0730
movq %r14, %rdi
addq $0x50, %rsp
movq 0x78(%rsp), %rcx
movq 0x28(%rsp), %rax
leaq (%rax,%r13,4), %rax
movl %edi, (%rax)
movq %rcx, (%rbx,%r13,8)
movl 0x70(%rsp), %edx
movl %edx, (%rbp,%r13,4)
testq %rcx, %rcx
js 0x1c11f6
cmpl $0x0, 0x24(%rsp)
movq 0x48(%rsp), %r11
movslq (%r11,%rcx,4), %rcx
movl %ecx, %edx
cmovel %edi, %edx
cmpq %rcx, %rdi
cmovlel %ecx, %edx
movl %edx, %edi
movq 0xa0(%rsp), %r14
movq (%rsp), %rbp
jmp 0x1c112d
movq $-0x1, 0x78(%rsp)
movq $0x1, 0x70(%rsp)
movq $-0x1, %r8
movl $0x1, %ecx
movq 0x28(%rsp), %rax
leaq (%rax,%r13,4), %rax
movl %esi, (%rax)
movq 0x38(%rsp), %rdx
movq %r8, (%rdx,%r13,8)
movq 0x18(%rsp), %rdx
movl %ecx, (%rdx,%r13,4)
movl %esi, %edi
movl %edi, (%r11,%r13,4)
testq %rbp, %rbp
js 0x1c1170
movq (%r12), %rcx
movq 0xa8(%rsp), %rdx
movl 0x8(%rcx,%rdx), %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
jl 0x1c1173
movq 0x28(%rsp), %rcx
movl (%rcx,%rbp,4), %ecx
cmpl (%rax), %ecx
jge 0x1c1173
movq %r13, %rbp
movq %rbp, (%rsp)
movslq %edi, %rax
movq 0xf8(%rsp), %rcx
cmpq %rax, %rcx
cmovlq %rcx, %rax
incq %r13
incq %r14
addq $0x1c, 0xc0(%rsp)
movq 0x98(%rsp), %rbx
cmpq %rbx, %r13
jne 0x1c0afd
jmp 0x1c1220
movq 0x18(%rsp), %rcx
movslq (%rcx,%rbp,4), %rcx
incq %rcx
movq 0x8(%rsp), %rdi
cmpq %rdi, %rax
movq 0x48(%rsp), %r11
jg 0x1c11cd
jne 0x1c120c
cmpq %rcx, %rbx
jge 0x1c120c
movq (%rsp), %rbp
movq %rbp, 0x78(%rsp)
movq %rcx, 0x70(%rsp)
movl 0x44(%rsp), %edx
movl %edx, 0x24(%rsp)
movq %rbp, %r8
movq %rax, %rdi
jmp 0x1c0fac
movq %rdi, %rsi
jmp 0x1c110e
movq 0xa0(%rsp), %r14
movq (%rsp), %rbp
movq 0x48(%rsp), %r11
jmp 0x1c112d
movq %rbx, %rcx
movq (%rsp), %rbp
jmp 0x1c0fa7
xorl %r15d, %r15d
jmp 0x1c1574
testq %rbx, %rbx
movq 0x58(%rsp), %r13
jle 0x1c153f
xorl %ecx, %ecx
movq %rbx, %rdx
movl (%r11,%rcx,2), %esi
subl %eax, %esi
movl %esi, (%r11,%rcx,2)
shlq $0x20, %rsi
addq %rcx, %rsi
movq %rsi, (%r13,%rcx,4)
addq $0x2, %rcx
decq %rdx
jne 0x1c1233
leaq (,%rbx,8), %rsi
addq %r13, %rsi
movq %r13, %rdi
callq 0x19e008
testq %rbx, %rbx
jle 0x1c1552
xorl %r10d, %r10d
xorl %eax, %eax
xorl %r14d, %r14d
movq 0xb8(%rsp), %r11
movq %rax, %rdx
movq %rbx, %rcx
decq %rbx
movl -0x8(%r13,%rcx,8), %esi
shrl %esi
leaq (%rax,%rax,8), %rdi
leaq (%rdi,%rdi,2), %rdi
addq %r11, %rdi
addq %rax, %rdi
testb $0x1, (%r13,%rsi,8)
jne 0x1c12e2
movq (%r12), %r8
leaq (%rsi,%rsi,8), %r9
leaq (%r9,%r9,2), %r9
addq %rsi, %r9
movupd (%r8,%r9), %xmm0
movups 0xc(%r8,%r9), %xmm1
movups %xmm1, 0xc(%rdi)
movupd %xmm0, (%rdi)
orb $0x1, (%r13,%rsi,8)
incq %rax
movq 0x38(%rsp), %r8
movq (%r8,%rsi,8), %rsi
addq $0x1c, %rdi
testq %rsi, %rsi
jns 0x1c129c
cmpq %rdx, %rax
je 0x1c131d
movslq 0x4(%r13,%rbx,8), %rdi
testq %rsi, %rsi
js 0x1c12fd
movq 0x28(%rsp), %r8
movslq (%r8,%rsi,4), %rsi
subq %rsi, %rdi
movl %eax, %esi
subl %edx, %esi
movq 0x18(%rsp), %rdx
movl %esi, (%rdx,%r10,4)
movq 0x50(%rsp), %rdx
movl %edi, (%rdx,%r10,4)
incq %r10
cmpq %r14, %rdi
cmovlq %rdi, %r14
cmpq $0x1, %rcx
jg 0x1c127e
movq (%r12), %rdi
testq %r10, %r10
jle 0x1c1559
leaq 0x18(%r11), %rax
movq %rax, 0x90(%rsp)
leaq -0x1c(%r11), %rax
movq %rax, 0x80(%rsp)
xorl %eax, %eax
movl $0x3fffffff, %ebp       # imm = 0x3FFFFFFF
xorl %r12d, %r12d
movq 0x88(%rsp), %rbx
movq 0x18(%rsp), %rsi
movslq (%rsi,%r12,4), %r15
addq %rax, %r15
movq 0x50(%rsp), %rcx
movl (%rcx,%r12,4), %ecx
subl %r14d, %ecx
leaq (%r12,%r12,8), %rdx
leaq (%rdx,%rdx,2), %r13
addq %r12, %r13
movl %ecx, (%rdi,%r13)
movl %eax, 0x10(%rdi,%r13)
movl %r15d, 0x14(%rdi,%r13)
movl (%rsi,%r12,4), %edx
cmpl $0x2, %edx
jae 0x1c139f
xorl %ecx, %ecx
jmp 0x1c1448
sarl %edx
cmpl $0x1, %edx
movl %edx, %ecx
adcl $0x0, %ecx
leaq (%rcx,%rcx,8), %rdx
leaq (%rdx,%rdx,2), %rdx
addq %rcx, %rdx
leaq (%rax,%rax,8), %rsi
leaq (%rsi,%rsi,2), %rsi
movq 0x90(%rsp), %rdi
addq %rax, %rdi
addq %rdi, %rsi
leaq (%r15,%r15,8), %rdi
leaq (%rdi,%rdi,2), %rdi
movq 0x80(%rsp), %r8
addq %r15, %r8
addq %r8, %rdi
xorl %r8d, %r8d
movups -0x18(%rsi,%r8), %xmm0
movups -0xc(%rsi,%r8), %xmm1
movups %xmm1, 0x10c(%rsp)
movaps %xmm0, 0x100(%rsp)
movups (%rdi), %xmm0
movups 0xc(%rdi), %xmm1
movups %xmm1, -0xc(%rsi,%r8)
movups %xmm0, -0x18(%rsi,%r8)
movups 0x10c(%rsp), %xmm0
movups %xmm0, 0xc(%rdi)
movapd 0x100(%rsp), %xmm0
movupd %xmm0, (%rdi)
orl %ebp, 0x18(%rdi)
orl %ebp, (%rsi,%r8)
addq $0x1c, %r8
addq $-0x1c, %rdi
cmpq %r8, %rdx
jne 0x1c13e3
movq 0x18(%rsp), %rdx
movl (%rdx,%r12,4), %edx
movq %r14, 0x8(%rsp)
movq %r10, 0x30(%rsp)
testb $0x1, %dl
je 0x1c1478
leaq (%rax,%rax,8), %rdx
leaq (%rdx,%rdx,2), %rdx
addq %r11, %rax
addq %rdx, %rax
leaq (%rcx,%rcx,8), %rdx
leaq (%rdx,%rdx,2), %rdx
addq %rcx, %rdx
orl $0x3fffffff, 0x18(%rax,%rdx) # imm = 0x3FFFFFFF
movq (%rbx), %rax
leaq (%rax,%r13), %rsi
movl 0x10(%rax,%r13), %r14d
movl 0x14(%rax,%r13), %eax
leaq (%r14,%r14,8), %rcx
leaq (%rcx,%rcx,2), %rcx
movq %r14, %r10
addq %r11, %r10
addq %rcx, %r10
subl %r14d, %eax
subq $0x8, %rsp
movq 0x240(%rsp), %rdi
movq 0x68(%rsp), %rdx
movq 0x1f8(%rsp), %rcx
movsd 0x70(%rsp), %xmm0
movq 0x200(%rsp), %r8
movq 0x208(%rsp), %r9
pushq %rsi
pushq 0x68(%rsp)
pushq 0x50(%rsp)
pushq 0x68(%rsp)
pushq 0x50(%rsp)
pushq %rax
pushq %r10
pushq 0x250(%rsp)
pushq 0x250(%rsp)
callq 0x1bffa5
movq 0x108(%rsp), %r11
addq $0x50, %rsp
addl %r14d, %eax
movq (%rbx), %rdi
movl %eax, 0x14(%rdi,%r13)
incq %r12
movq %r15, %rax
movq 0x30(%rsp), %r10
cmpq %r10, %r12
movq 0x8(%rsp), %r14
jne 0x1c135e
movq 0x88(%rsp), %r12
jmp 0x1c155c
leaq (,%rbx,8), %rdx
movq %r13, %rdi
xorl %esi, %esi
callq 0x20e0
leaq (,%rbx,8), %rsi
addq %r13, %rsi
movq %r13, %rdi
callq 0x19e008
movq (%r12), %rdi
xorl %r10d, %r10d
xorl %r15d, %r15d
movq %r10, 0x8(%r12)
leaq (%r10,%r10,8), %rax
leaq (%rax,%rax,2), %rsi
addq %r10, %rsi
addq %rdi, %rsi
callq 0x19ead4
movq %r15, %rax
addq $0x1b8, %rsp            # imm = 0x1B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq