// File: /workspace/github_cpp_makefile_star2_O3/chhylp123[P]hifiasm/inter.cpp
// Function: flat_contain_adv(overlap_region_alloc*, All_reads*, ul_idx_t const*, ug_opt_t const*, long, double, long, long, long, long, bit_extz_t*, long, char*, UC_Read*, double, kv_rtrace_t*, ul_ov_t*, long, int*, int*, int*, int*, int*, long*, long*, ul_ov_t*, unsigned long*, unsigned long, long*, ul_ov_t*)
int64_t flat_contain_adv(overlap_region_alloc* ol, All_reads *ridx, 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, bit_extz_t *exz, int64_t trans_sc, char* qstr, UC_Read *tu, double e_rate, 
kv_rtrace_t *trace, ul_ov_t *a, int64_t a_n, int32_t *f0, int32_t *c_n0, int32_t *c_sc0, 
int32_t *rch0, int32_t *ssc0, int64_t *p0, int64_t *t0, ul_ov_t *ori_a, uint64_t *flag, 
uint64_t rechain_w, int64_t *vis, ul_ov_t *idx)
{
	if(a_n <= 0) return 0;
	int32_t *t = f0, *c_n = c_n0; int64_t *p = p0, *f = t0, rech = 0, nf = 0, ori_i, ori_j, ncl; uint64_t qs;
	int64_t mm_ovlp, x, i, j, st, max_ii, mm_sc, mm_n, mm_idx, n_skip, end_j, qo, sc, sn, is_c, cl, csc, cl1; 
	uint32_t li_v, lj_v; ul_ov_t *li, *lj; int64_t max, max_n, tot_sc = INT32_MIN, tot_n = INT32_MIN, tot_i = -1;
	for (i = 1, j = 0; i <= a_n; i++) {
		if (i == a_n || a[i].qe != a[j].qe) {
			if(i - j > 1) radix_sort_ul_ov_srt_qs(a+j, a+i);
			j = i;
		}
	}
	// fprintf(stderr, "\n[M::%s::] sc::%u\n", __func__, idx->qn);
	memset(t, 0, (a_n*sizeof((*t)))); 
	for (i = st = 0, max_ii = -1; i < a_n; ++i) {
        li = &(a[i]); li_v = (li->tn<<1)|li->rev; 
		flag[i] = li->sec; li->sec = ori_a[li->sec>>1].sec; 
		
		csc = ((li->el)?(li->qe-li->qs):(0));
		mm_sc = csc; mm_n = 1; mm_idx = -1; n_skip = 0; end_j = -1; 
		if(flag[i]&1) {//low prority
			rech++; f[i] = INT32_MIN; p[i] = mm_idx; c_n[i] = 0; continue;
		}
		// fprintf(stderr, "[i::%ld] (id::%u)\n", i, li->tn);
		// fprintf(stderr, "[i::%ld] (id::%u)%.*s\t%c\tq::[%u, %u)\tt::[%u, %u)\tc::%u\n", i, li->tn,
        //             (int)Get_NAME_LENGTH(R_INF, a[i].tn), Get_NAME(R_INF, a[i].tn), 
		// 			"+-"[a[i].rev], a[i].qs, a[i].qe, a[i].ts, a[i].te, !a[i].el);
		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, a, x+G_CHAIN_INDEL); 
		
		if ((x-st) > max_iter) st = x-max_iter;
		for (j = x; j >= st; --j) { // collect potential destination vertices
			lj = &(a[j]); lj_v = (lj->tn<<1)|lj->rev;
			if(flag[j]&1) continue;//low prority
			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
			if(lj->qs > li->qs) continue;///no contain, must be > instad of >=
			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, &is_c)) {
				if(is_c == 0) {
					sc = f[j] + csc; sn = c_n[j] + 1;
					// if(li->tn == 6312) {
					// 	fprintf(stderr, "***[i::%ld] (id::%u)%.*s\t%c\tj::%ld\t%.*s\tsc::%ld\tsn::%ld\n", i, li->tn,
					// 		(int)Get_NAME_LENGTH(R_INF, a[i].tn), Get_NAME(R_INF, a[i].tn), 
					// 		"+-"[a[i].rev], j, (int)Get_NAME_LENGTH(R_INF, a[j].tn), Get_NAME(R_INF, a[j].tn),
					// 		sc, sn);
					// }
					if((sc > mm_sc) || ((sc == mm_sc) && (sn > mm_n))) {
						mm_sc = sc, mm_idx = j; mm_n = sn;
						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 || ((a[i].qe) > (a[max_ii].qe+max_dis))) {//too long
			max = INT32_MIN; max_n = INT32_MIN; max_ii = -1;
			for (j = i - 1; (j >= st) && (a[i].qe<=(max_dis+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 = &(a[max_ii]); lj_v = (lj->tn<<1)|lj->rev;
			if((lj->qe > li->qs) && (lj->qs <= li->qs) && (!(flag[max_ii]&1))) {
				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, &is_c)) {
					if(is_c == 0) {
						sc = f[max_ii] + csc; sn = c_n[max_ii] + 1;
						if((sc > mm_sc) || ((sc == mm_sc) && (sn > mm_n))) {
							mm_sc = sc; mm_idx = max_ii; mm_n = sn;
						}
					}
				}
			}
		}

		f[i] = mm_sc; p[i] = mm_idx; c_n[i] = mm_n; 
		if ((max_ii < 0) || ((a[i].qe<=max_dis+a[max_ii].qe) && (f[max_ii]<f[i]))) {
			max_ii = i;
		}

		if((tot_sc < f[i]) || ((tot_sc == f[i]) && (tot_n < c_n[i]))) {
			tot_sc = f[i]; tot_n = c_n[i]; tot_i = i;
		}
	}
	// fprintf(stderr, "+++[i::%ld] (id::%u)\n", i, li->tn);
	cl = 0; i = tot_i; t = NULL;
	while (i >= 0) {
        flag[cl] |= (((uint64_t)i)<<32); 
		i = p[i]; cl++;
    }
	// fprintf(stderr, "+++[i::%ld] (cl::%ld)\n", i, cl);

	st = flag[cl-1]>>32; qs = a[st].qs; cl1 = 0;
	// fprintf(stderr, "[M::%s] qs::%lu\trechain_w::%lu\trech::%ld\tcl::%ld\n", 
	// 	__func__, qs, rechain_w, rech, cl);
	if((qs <= rechain_w) && (rech > 0)) {
		for (i = nf = 0; i < cl; i++) {
			st = flag[cl-i-1]>>32;
			if(a[st].el) break;
			if((a[st].ts == 0) && (a[st].te == Get_READ_LENGTH(R_INF, a[st].tn))) nf++;
		}
		if(i < cl && a[st].qs > qs && nf > 0) {
			
			cl1 = quick_rechain(ol, a, st+1, trace, uref, uopt, bw, diff_ec_ul, qlen, max_skip, max_iter, max_dis, 
			exz, trans_sc, ridx, qstr, tu, e_rate, f0, c_n0, c_sc0, rch0, p0, t0);
			// fprintf(stderr, "st::%ld\tcl1::%ld[M::%s]\t(id::%u)\t%.*s\t%c\tq::[%u, %u)\tt::[%u, %u)\tc::%u\n", 
			// st, cl1, __func__, a[st].tn, (int)Get_NAME_LENGTH(R_INF, a[st].tn), Get_NAME(R_INF, a[st].tn), 
			// 		"+-"[a[st].rev], a[st].qs, a[st].qe, a[st].ts, a[st].te, !a[st].el);
			
			// fprintf(stderr, "i::%ld\t[M::%s]\t(id::%u)\t%.*s\t%c\tq::[%u, %u)\tt::[%u, %u)\tc::%u\n", 
			// i, __func__, a[t0[cl1-1]].tn, (int)Get_NAME_LENGTH(R_INF, a[t0[cl1-1]].tn), 
			// 		Get_NAME(R_INF, a[t0[cl1-1]].tn), "+-"[a[t0[cl1-1]].rev], a[t0[cl1-1]].qs, a[t0[cl1-1]].qe, 
			// 		a[t0[cl1-1]].ts, a[t0[cl1-1]].te, !a[t0[cl1-1]].el);

			if(cl1 > 0 && a[t0[cl1-1]].qs <= qs) {
				cl = cl-i-1; assert(st == t0[0]);
				for (i = 0; i < cl1; i++) {
					flag[cl] <<= 32; flag[cl] >>= 32; 
					flag[cl] |= ((uint64_t)t0[i])<<32; cl++;
				}
			}
		}
	}
	// fprintf(stderr, "---[i::%ld] (cl::%ld)\n", i, cl);
	for (i = 0; i < cl; i++) {
		// fprintf(stderr, "[i::%ld] flag[cl-i-1]>>32::%lu\n", i, flag[cl-i-1]>>32);
		t0[i] = flag[cl-i-1]>>32; 
		vis[((uint32_t)flag[t0[i]])>>1] |= 1;///set as used 
		// fprintf(stderr, "[i::%ld]\t%.*s\traw_i::%u\n", i, 
		// (int)Get_NAME_LENGTH(R_INF, a[t0[i]].tn), Get_NAME(R_INF, a[t0[i]].tn), ((uint32_t)flag[t0[i]])>>1);
		// flag[cl-i-1] = (uint32_t)flag[cl-i-1];
	}

	i = 0; ncl = 0;
	if(cl1 > 1) {
		// for (i = 0; i < cl; i++) vis[((uint32_t)flag[t0[i]])>>1] |= 1;///set as used 
		for (i = 0; i < cl1; i++) {
			if(flag[t0[i]]&1) flag[t0[i]]-=1; 
			vis[((uint32_t)flag[t0[i]])>>1] |= 1;
			c_n[ncl++] = ((uint32_t)flag[t0[i]])>>1;

			// a[ncl] = a[t0[i]];
			// if(a[ncl].qs < idx->qs) idx->qs = a[ncl].qs;
			// if(a[ncl].qe > idx->qe) idx->qe = a[ncl].qe;
			// fprintf(stderr, "[ncl::%ld]\t%.*s\n", ncl, 
			// (int)Get_NAME_LENGTH(R_INF, a[ncl].tn), Get_NAME(R_INF, a[ncl].tn));
			// ncl++;

			if(i < cl1 - 1) {
				ori_i = ((uint32_t)flag[t0[i]])>>1; 
				ori_j = ((uint32_t)flag[t0[i+1]])>>1; 
				ncl += push_trans_aln(uref, uopt, bw, diff_ec_ul, ridx, ori_a, ori_i, ori_j, vis, c_n+ncl);
			}
		}
	}


	for (; i < cl; i++) {
		///t0[i] -> idx of a; (uint32_t)flag[t0[i]] -> idx of ori_a
		if(flag[t0[i]]&1) flag[t0[i]]-=1;
		vis[((uint32_t)flag[t0[i]])>>1] |= 1;
		c_n[ncl++] = ((uint32_t)flag[t0[i]])>>1;
		// a[ncl] = a[t0[i]];
		// if(a[ncl].qs < idx->qs) idx->qs = a[ncl].qs;
		// if(a[ncl].qe > idx->qe) idx->qe = a[ncl].qe;
		// fprintf(stderr, "[ncl::%ld]\t%.*s\n", ncl, 
		// 	(int)Get_NAME_LENGTH(R_INF, a[ncl].tn), Get_NAME(R_INF, a[ncl].tn));
		// ncl++;
		// fprintf(stderr, "[M::%s] (id::%u)%.*s\t%c\tq::[%u, %u)\tt::[%u, %u)\tc::%u\n", 
		// __func__, a[i].tn, (int)Get_NAME_LENGTH(R_INF, a[i].tn), Get_NAME(R_INF, a[i].tn), 
		// 			"+-"[a[i].rev], a[i].qs, a[i].qe, a[i].ts, a[i].te, !a[i].el);
	}
	assert(ncl >= cl);
	if(ncl <= 0) return ncl;

	idx->qs = ori_a[c_n[0]].qs; 
	idx->qe = ori_a[c_n[0]].qe;
	for (i = 0; i < ncl; i++) {
		a[i] = ori_a[c_n[i]];
		if(a[i].qs < idx->qs) idx->qs = a[i].qs;
		if(a[i].qe > idx->qe) idx->qe = a[i].qe;
	}
	return ncl;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x148, %rsp            # imm = 0x148
movsd %xmm1, 0x138(%rsp)
movq %r9, 0x110(%rsp)
movsd %xmm0, 0xd0(%rsp)
movq %r8, 0xc8(%rsp)
movq %rcx, 0xc0(%rsp)
movq %rsi, 0xe8(%rsp)
movq 0x1c8(%rsp), %r14
testq %r14, %r14
jle 0x1bfb73
movq %rdi, 0x128(%rsp)
movq %rdx, 0x130(%rsp)
movq 0x1f8(%rsp), %r12
movq 0x1c0(%rsp), %r13
negq %r14
leaq 0x1c(%r13), %rbx
movl $0x1, %r15d
xorl %eax, %eax
movq %r14, %rcx
addq %r15, %rcx
je 0x1bf1dd
movl 0x8(%rbx), %ecx
leaq (%rax,%rax,8), %rdx
leaq (%rdx,%rdx,2), %rdx
addq %rax, %rdx
cmpl 0x8(%r13,%rdx), %ecx
jne 0x1bf1dd
movq %rax, %rcx
jmp 0x1bf205
movq %r15, %rdx
subq %rax, %rdx
movq %r15, %rcx
cmpq $0x2, %rdx
jl 0x1bf205
leaq (%rax,%rax,8), %rcx
leaq (%rcx,%rcx,2), %rdi
addq %rax, %rdi
addq %r13, %rdi
movq %rbx, %rsi
callq 0x19e55c
movq %r15, %rcx
leaq (%r14,%r15), %rdx
incq %rdx
incq %r15
addq $0x1c, %rbx
movq %rcx, %rax
cmpq $0x1, %rdx
jne 0x1bf1bb
movq 0x1c8(%rsp), %r15
leaq (,%r15,4), %rdx
movq $0x0, 0x118(%rsp)
movq 0x1d0(%rsp), %rdi
xorl %esi, %esi
callq 0x20e0
movq 0x210(%rsp), %r11
movq 0x110(%rsp), %rax
incq %rax
movq %rax, 0x140(%rsp)
leaq -0x14(%r13), %r8
movq $-0x80000000, %rdx      # imm = 0x80000000
movq $-0x1, %r9
movq $-0x1, 0xf0(%rsp)
movq $-0x80000000, 0xf8(%rsp) # imm = 0x80000000
movq $-0x1, 0x88(%rsp)
xorl %r10d, %r10d
xorl %edi, %edi
movq 0x1d8(%rsp), %r14
movq 0x200(%rsp), %rbx
movq %r14, %r15
movq %r12, %r14
movq %rdx, 0x100(%rsp)
leaq (%rdi,%rdi,8), %rax
leaq (%rax,%rax,2), %rcx
addq %rdi, %rcx
leaq (%rcx,%r13), %rbp
movl 0xc(%r13,%rcx), %r12d
movl 0x18(%r13,%rcx), %eax
movl %eax, %edx
andl $0x3fffffff, %edx       # imm = 0x3FFFFFFF
movq %rdi, 0xa8(%rsp)
movq %rdx, (%r11,%rdi,8)
movl 0x18(%r13,%rcx), %edx
movl %edx, %esi
shrl %esi
andl $0x1fffffff, %esi       # imm = 0x1FFFFFFF
leaq (%rsi,%rsi,8), %rdi
leaq (%rdi,%rdi,2), %rdi
addq %rsi, %rdi
movq 0x208(%rsp), %rsi
movl 0x18(%rsi,%rdi), %esi
movl $0x3fffffff, %edi       # imm = 0x3FFFFFFF
andl %edi, %esi
movl %edx, %edi
andl $0xc0000000, %edi       # imm = 0xC0000000
orl %esi, %edi
movl %edi, 0x18(%r13,%rcx)
btl $0x1e, %edx
movq %rbp, 0x90(%rsp)
jb 0x1bf336
xorl %ebp, %ebp
jmp 0x1bf33f
movl 0x8(%rbp), %ecx
subl 0x4(%rbp), %ecx
movq %rcx, %rbp
movq 0xa8(%rsp), %rdi
testb $0x1, (%r11,%rdi,8)
jne 0x1bf43d
movq %r9, 0x98(%rsp)
movq %r8, 0xa0(%rsp)
shldl $0x1, %eax, %r12d
movl %r12d, 0xdc(%rsp)
xorl $0x1, %r12d
movq %rdi, %r14
movq 0xc0(%rsp), %rdi
movl %r12d, 0xd8(%rsp)
movl %r12d, %esi
movq %r10, %rbx
callq 0x1a4c50
movq 0x90(%rsp), %rcx
movl 0x4(%rcx), %ecx
addq %rax, %rcx
cvtsi2sd %rcx, %xmm0
mulsd 0xd0(%rsp), %xmm0
cvttsd2si %xmm0, %rdx
movq 0xc8(%rsp), %rax
cmpq %rax, %rdx
cmovleq %rax, %rdx
addq %rcx, %rdx
movq 0x140(%rsp), %rax
cmpq %rax, %rdx
cmovgeq %rax, %rdx
subl $-0x80, %edx
movl %r14d, %edi
movq %r13, %rsi
callq 0x1a83b5
movq %rbx, %r10
cltq
movq %rax, %rcx
subq %rbx, %rcx
movq %rax, %rdx
movq 0x188(%rsp), %rsi
subq %rsi, %rdx
cmpq %rsi, %rcx
cmovgq %rdx, %r10
cmpq %rax, %r10
movq %r10, 0xb0(%rsp)
movq %rbp, 0x120(%rsp)
jle 0x1bf470
movq $-0x1, 0xb8(%rsp)
movl $0x1, %r12d
movq 0x210(%rsp), %r11
movq 0x88(%rsp), %rcx
jmp 0x1bf67b
incq 0x118(%rsp)
movq $-0x80000000, (%rbx,%rdi,8) # imm = 0x80000000
movq %r14, %r12
movq $-0x1, (%r14,%rdi,8)
movq %r15, %r14
movl $0x0, (%r15,%rdi,4)
movq 0x100(%rsp), %rdx
jmp 0x1bf958
movq %r13, %rdx
leaq (%rax,%rax,8), %rcx
leaq (%rcx,%rcx,2), %r13
addq %rdx, %r13
addq %rax, %r13
movl $0x1, %r15d
movq $-0x1, 0xb8(%rsp)
movq $0x0, 0xe0(%rsp)
movq %rbp, %r14
movq %rax, %rbx
movq 0x210(%rsp), %r11
movq 0x88(%rsp), %rcx
movq 0x90(%rsp), %rdi
testb $0x1, (%r11,%rbx,8)
jne 0x1bf4d7
movl 0x4(%rdi), %eax
cmpl %eax, 0x8(%r13)
jbe 0x1bf672
cmpl %eax, 0x4(%r13)
jbe 0x1bf4f8
movq %r14, %rbp
movq %r15, %r12
leaq -0x1(%rbx), %rax
addq $-0x1c, %r13
movq %r12, %r15
movq %rbp, %r14
cmpq %r10, %rbx
movq %rax, %rbx
jg 0x1bf4bd
jmp 0x1bf67b
movl 0xc(%r13), %eax
movl 0x18(%r13), %ebp
shrdl $0x1f, %eax, %ebp
movq %r13, %rsi
xorl %edx, %edx
xorl %ecx, %ecx
movq 0xe8(%rsp), %r8
xorl %r9d, %r9d
callq 0x6ea22
cmpl %ebp, 0xdc(%rsp)
jne 0x1bf54c
movq %r14, %rbp
movq %r15, %r12
movq 0x210(%rsp), %r11
movq 0xb0(%rsp), %r10
movq 0x88(%rsp), %rcx
movq 0x90(%rsp), %rdi
jmp 0x1bf4dd
xorl $0x1, %ebp
leaq 0x108(%rsp), %rcx
movq %rcx, (%rsp)
movq 0xc0(%rsp), %rsi
movl 0xd8(%rsp), %edx
movl %ebp, %ecx
movq 0xc8(%rsp), %r8
movsd 0xd0(%rsp), %xmm0
movq %rax, %r9
callq 0x1bcf0f
testq %rax, %rax
je 0x1bf524
cmpq $0x0, 0x108(%rsp)
movq 0x210(%rsp), %r11
movq 0xb0(%rsp), %r10
movq 0xa8(%rsp), %rdx
movq 0x90(%rsp), %rdi
jne 0x1bf609
movq 0x200(%rsp), %rax
movq (%rax,%rbx,8), %rbp
addq 0x120(%rsp), %rbp
movq 0x1d8(%rsp), %rax
movslq (%rax,%rbx,4), %r12
incq %r12
cmpq %r14, %rbp
jg 0x1bf5e4
jne 0x1bf611
cmpq %r12, %r15
jge 0x1bf611
xorl %eax, %eax
movq 0xe0(%rsp), %rcx
testq %rcx, %rcx
setg %al
subq %rax, %rcx
movq %rcx, 0xe0(%rsp)
movq %rbx, 0xb8(%rsp)
jmp 0x1bf649
movq %r14, %rbp
movq %r15, %r12
jmp 0x1bf665
movq 0x1d0(%rsp), %rax
movslq (%rax,%rbx,4), %rax
cmpq %rax, %rdx
jne 0x1bf643
movq 0xe0(%rsp), %rax
cmpq 0x180(%rsp), %rax
jge 0x1bfa98
incq %rax
movq %rax, 0xe0(%rsp)
movq %r14, %rbp
movq %r15, %r12
movq 0x1f8(%rsp), %rax
movq (%rax,%rbx,8), %rax
testq %rax, %rax
js 0x1bf665
movq 0x1d0(%rsp), %rcx
movl %edx, (%rcx,%rax,4)
movq 0x88(%rsp), %rcx
jmp 0x1bf4dd
movq %rbx, %rax
movq %r14, %rbp
movq %r15, %r12
testq %rcx, %rcx
movq 0x1d8(%rsp), %r14
movq 0x1c0(%rsp), %r13
movq 0x200(%rsp), %rbx
movq 0x190(%rsp), %r15
js 0x1bf6cf
movq 0x90(%rsp), %rcx
movl 0x8(%rcx), %ecx
movq 0x88(%rsp), %rsi
leaq (%rsi,%rsi,8), %rdx
leaq (%rdx,%rdx,2), %rdx
addq %rsi, %rdx
movl 0x8(%r13,%rdx), %edx
addq %r15, %rdx
cmpq %rcx, %rdx
jge 0x1bf76b
movq 0xa8(%rsp), %rdi
cmpq %r10, %rdi
jle 0x1bf84c
movq 0x90(%rsp), %rcx
movl 0x8(%rcx), %ecx
movq $-0x1, 0x88(%rsp)
movq $-0x80000000, %rdi      # imm = 0x80000000
movq 0xa0(%rsp), %rdx
movq 0x98(%rsp), %rsi
movq $-0x80000000, %r8       # imm = 0x80000000
movl (%rdx), %r9d
addq %r15, %r9
cmpq %rcx, %r9
jl 0x1bf76b
movq (%rbx,%rsi,8), %r9
cmpq %r9, %r8
jge 0x1bf73a
movslq (%r14,%rsi,4), %rdi
movq %rsi, 0x88(%rsp)
movq %r9, %r8
jmp 0x1bf753
jne 0x1bf753
movslq (%r14,%rsi,4), %r10
cmpq %r10, %rdi
jge 0x1bf753
movq %rsi, 0x88(%rsp)
movq %r9, %r8
movq %r10, %rdi
leaq -0x1(%rsi), %r9
addq $-0x1c, %rdx
movq 0xb0(%rsp), %r10
cmpq %r10, %rsi
movq %r9, %rsi
jg 0x1bf715
movq 0x88(%rsp), %rdx
testq %rdx, %rdx
js 0x1bf883
cmpq %rax, %rdx
jge 0x1bf883
leaq (%rdx,%rdx,8), %rax
leaq (%rax,%rax,2), %rax
addq %rdx, %rax
movq 0x90(%rsp), %rcx
movl 0x4(%rcx), %ecx
cmpl %ecx, 0x8(%r13,%rax)
movq 0xa8(%rsp), %rdi
jbe 0x1bf8c4
leaq (%rax,%r13), %rsi
cmpl %ecx, 0x4(%rsi)
movq 0xa0(%rsp), %r8
movq 0x98(%rsp), %r9
ja 0x1bf8d4
testb $0x1, (%r11,%rdx,8)
jne 0x1bf8d4
movl 0xc(%r13,%rax), %ecx
movl 0x18(%r13,%rax), %r13d
shrdl $0x1f, %ecx, %r13d
movq 0x90(%rsp), %rdi
xorl %edx, %edx
xorl %ecx, %ecx
movq 0xe8(%rsp), %r8
xorl %r9d, %r9d
callq 0x6ea22
cmpl %r13d, 0xdc(%rsp)
jne 0x1bf9d0
movq 0x1c0(%rsp), %r13
movq 0x210(%rsp), %r11
movq 0xa0(%rsp), %r8
movq 0x98(%rsp), %r9
movq 0xb0(%rsp), %r10
movq 0xa8(%rsp), %rdi
movq 0x88(%rsp), %rdx
jmp 0x1bf8d4
leaq (%rbx,%rdi,8), %rax
movq %rbp, (%rax)
movq 0x1f8(%rsp), %rcx
movq 0xb8(%rsp), %rdx
movq %rdx, (%rcx,%rdi,8)
movl %r12d, (%r14,%rdi,4)
movq %rdi, %rcx
movq 0xa0(%rsp), %r8
movq 0x98(%rsp), %r9
jmp 0x1bf928
movq 0xa8(%rsp), %rdi
leaq (%rbx,%rdi,8), %rax
movq %rbp, (%rax)
movq 0x1f8(%rsp), %rcx
movq 0xb8(%rsp), %rsi
movq %rsi, (%rcx,%rdi,8)
movl %r12d, (%r14,%rdi,4)
movq %rdi, %rcx
testq %rdx, %rdx
movq 0xa0(%rsp), %r8
movq 0x98(%rsp), %r9
jns 0x1bf8f3
jmp 0x1bf928
movq 0xa0(%rsp), %r8
movq 0x98(%rsp), %r9
leaq (%rbx,%rdi,8), %rax
movq %rbp, (%rax)
movq 0x1f8(%rsp), %rcx
movq 0xb8(%rsp), %rsi
movq %rsi, (%rcx,%rdi,8)
movl %r12d, (%r14,%rdi,4)
movq 0x90(%rsp), %rcx
movl 0x8(%rcx), %ecx
movq %rdx, %rsi
leaq (%rdx,%rdx,8), %rdx
leaq (%rdx,%rdx,2), %rdx
addq %rsi, %rdx
movl 0x8(%r13,%rdx), %edx
addq %r15, %rdx
cmpq %rcx, %rdx
jl 0x1bf925
movq (%rbx,%rsi,8), %rcx
cmpq (%rbx,%rdi,8), %rcx
cmovlq %rdi, %rsi
movq %rsi, %rcx
movq (%rax), %rax
movslq %r12d, %rdx
cmpq %rax, 0xf8(%rsp)
jge 0x1bf978
movq %rcx, 0x88(%rsp)
movq %rax, 0xf8(%rsp)
movq %rdi, 0xf0(%rsp)
movq 0x1f8(%rsp), %r12
movq 0x1c8(%rsp), %r15
incq %rdi
incq %r9
addq $0x1c, %r8
cmpq %r15, %rdi
jne 0x1bf2ad
jmp 0x1bfaa6
movq 0x1f8(%rsp), %r12
movq 0x1c8(%rsp), %r15
jne 0x1bf9be
movq 0x100(%rsp), %rsi
cmpq %rdx, %rsi
jge 0x1bf9b1
movq %rcx, 0x88(%rsp)
movq %rax, 0xf8(%rsp)
movq %rdi, 0xf0(%rsp)
jmp 0x1bf960
movq %rcx, 0x88(%rsp)
movq %rsi, %rdx
jmp 0x1bf960
movq %rcx, 0x88(%rsp)
movq 0x100(%rsp), %rdx
jmp 0x1bf960
xorl $0x1, %r13d
leaq 0x108(%rsp), %rcx
movq %rcx, (%rsp)
movq 0xc0(%rsp), %rsi
movl 0xd8(%rsp), %edx
movl %r13d, %ecx
movq 0xc8(%rsp), %r8
movsd 0xd0(%rsp), %xmm0
movq %rax, %r9
callq 0x1bcf0f
testq %rax, %rax
je 0x1bf80f
cmpq $0x0, 0x108(%rsp)
movq 0x1c0(%rsp), %r13
movq 0x210(%rsp), %r11
movq 0xa0(%rsp), %r8
movq 0x98(%rsp), %r9
movq 0xb0(%rsp), %r10
movq 0xa8(%rsp), %rdi
movq 0x88(%rsp), %rdx
jne 0x1bf8d4
movq 0x120(%rsp), %rsi
addq (%rbx,%rdx,8), %rsi
movslq (%r14,%rdx,4), %rax
incq %rax
movq %rsi, %rcx
cmpq %rbp, %rsi
jg 0x1bfa85
jne 0x1bf8d4
cmpq %rax, %r12
jge 0x1bf8d4
movq %rcx, %rbp
movq %rax, %r12
movq %rdx, 0xb8(%rsp)
jmp 0x1bf8d4
movq %rbx, %rax
movq %r14, %rbp
movq %r15, %r12
jmp 0x1bf430
movq 0xf0(%rsp), %rcx
xorl %r15d, %r15d
movq 0x220(%rsp), %r10
testq %rcx, %rcx
js 0x1bfad2
movq %rcx, %rax
shlq $0x20, %rax
orq %rax, (%r11,%r15,8)
movq (%r12,%rcx,8), %rcx
incq %r15
jmp 0x1bfab9
movl -0x4(%r11,%r15,8), %eax
leaq (%rax,%rax,8), %rcx
leaq (%rcx,%rcx,2), %rcx
addq %rax, %rcx
movl 0x4(%r13,%rcx), %r12d
cmpq 0x218(%rsp), %r12
seta %al
cmpq $0x0, 0x118(%rsp)
setle %cl
testq %r15, %r15
sete %dl
orb %cl, %dl
orb %al, %dl
jne 0x1bfb7b
leaq 0xd671f(%rip), %rax     # 0x296230
movq 0x18(%rax), %rcx
leaq -0x1(%r15), %r14
xorl %ebx, %ebx
xorl %eax, %eax
movq %r13, %rsi
movq (%r11,%r14,8), %r13
shrq $0x20, %r13
leaq (,%r13,8), %rdx
addq %r13, %rdx
leaq (%rdx,%rdx,2), %rdx
addq %r13, %rdx
testb $0x40, 0x1b(%rsi,%rdx)
jne 0x1bfb82
addq %rsi, %rdx
cmpl $0x0, 0x10(%rdx)
movq %rsi, %r13
jne 0x1bfb60
movl 0xc(%rdx), %esi
movl 0x14(%rdx), %edx
xorl %edi, %edi
cmpq %rdx, (%rcx,%rsi,8)
sete %dil
addq %rdi, %rax
addq $-0x1, %r14
jb 0x1bfb1d
movq 0x1d8(%rsp), %r14
jmp 0x1bfd0a
xorl %r12d, %r12d
jmp 0x1bff15
xorl %ebx, %ebx
jmp 0x1bfd0a
xorl %ebx, %ebx
cmpl %r12d, 0x4(%rsi,%rdx)
jbe 0x1bfcd8
testq %rax, %rax
jle 0x1bfcd8
leaq 0x1(%r13), %rdx
movq 0x1f8(%rsp), %rax
movq %rax, 0x70(%rsp)
movq 0x1e8(%rsp), %rax
movq %rax, 0x68(%rsp)
movq 0x1d0(%rsp), %rax
movq %rax, 0x50(%rsp)
movq 0x1b0(%rsp), %rax
movq %rax, 0x48(%rsp)
movq 0x1a8(%rsp), %rax
movq %rax, 0x40(%rsp)
movq 0x1a0(%rsp), %rax
movq %rax, 0x30(%rsp)
movq 0x198(%rsp), %rax
movq %rax, 0x28(%rsp)
movq 0x190(%rsp), %rax
movq %rax, 0x20(%rsp)
movq 0x188(%rsp), %rax
movq %rax, 0x18(%rsp)
movq 0x180(%rsp), %rax
movq %rax, 0x10(%rsp)
movq 0x110(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0x200(%rsp), %rbp
movq %rbp, 0x78(%rsp)
movq 0x1d8(%rsp), %rax
movq %rax, 0x58(%rsp)
movq 0xe8(%rsp), %rax
movq %rax, 0x38(%rsp)
movq 0xc8(%rsp), %rax
movq %rax, (%rsp)
movq 0x128(%rsp), %rdi
movq 0x1c0(%rsp), %rsi
movq 0x1b8(%rsp), %rcx
movq 0x130(%rsp), %r8
movq 0xc0(%rsp), %r9
movsd 0xd0(%rsp), %xmm0
movsd 0x138(%rsp), %xmm1
callq 0x1be6eb
movq %rax, %rbx
testq %rax, %rax
jle 0x1bfcea
movq -0x8(%rbp,%rbx,8), %rax
leaq (%rax,%rax,8), %rcx
leaq (%rcx,%rcx,2), %rcx
addq %rax, %rcx
movq 0x1c0(%rsp), %rax
cmpl %r12d, 0x4(%rax,%rcx)
movq 0x220(%rsp), %r10
movq 0x210(%rsp), %r11
jbe 0x1bff2a
movq 0x1d8(%rsp), %r14
movq 0x1c0(%rsp), %r13
jmp 0x1bfd0a
movq 0x1d8(%rsp), %r14
movq 0x1c0(%rsp), %r13
movq 0x220(%rsp), %r10
movq 0x210(%rsp), %r11
testq %r15, %r15
jle 0x1bfd3a
movq 0x200(%rsp), %rax
movq %r15, %rcx
movq -0x8(%r11,%rcx,8), %rdx
shrq $0x20, %rdx
movq %rdx, (%rax)
movl (%r11,%rdx,8), %edx
shrl %edx
orq $0x1, (%r10,%rdx,8)
addq $0x8, %rax
decq %rcx
jne 0x1bfd1a
cmpq $0x2, %rbx
jl 0x1bfe18
leaq -0x1(%rbx), %r14
xorl %r13d, %r13d
xorl %r12d, %r12d
movq 0x200(%rsp), %rdx
movq (%rdx,%r13,8), %rcx
movq (%r11,%rcx,8), %rax
testb $0x1, %al
je 0x1bfd71
decq %rax
movq %rax, (%r11,%rcx,8)
movq (%rdx,%r13,8), %rax
movq (%r11,%rax,8), %rax
shrl %eax
orb $0x1, (%r10,%rax,8)
movq (%rdx,%r13,8), %rax
movq (%r11,%rax,8), %r9
movl %r9d, %eax
shrl %eax
movq 0x1d8(%rsp), %rcx
movl %eax, (%rcx,%r12,4)
incq %r12
cmpq %r14, %r13
jge 0x1bfdfa
shrl %r9d
movq 0x8(%rdx,%r13,8), %rax
movl (%r11,%rax,8), %eax
shrl %eax
leaq (%rcx,%r12,4), %rcx
movq %rcx, 0x10(%rsp)
movq %r10, 0x8(%rsp)
movq %rax, (%rsp)
movq 0xc0(%rsp), %rsi
movq 0xc8(%rsp), %rdx
movsd 0xd0(%rsp), %xmm0
movq 0xe8(%rsp), %rcx
movq 0x208(%rsp), %r8
callq 0x1beeee
movq 0x210(%rsp), %r11
movq 0x220(%rsp), %r10
addq %rax, %r12
incq %r13
cmpq %r13, %rbx
jne 0x1bfd4e
movq 0x1d8(%rsp), %r14
movq 0x1c0(%rsp), %r13
jmp 0x1bfe1d
xorl %r12d, %r12d
xorl %ebx, %ebx
movq %r15, %rax
subq %rbx, %rax
jle 0x1bfe73
movq 0x200(%rsp), %rcx
leaq (%rcx,%rbx,8), %rdx
leaq (%r14,%r12,4), %rsi
xorl %ecx, %ecx
movq (%rdx,%rcx,8), %r8
movq (%r11,%r8,8), %rdi
testb $0x1, %dil
je 0x1bfe54
decq %rdi
movq %rdi, (%r11,%r8,8)
movq (%rdx,%rcx,8), %rdi
movq (%r11,%rdi,8), %rdi
shrl %edi
orb $0x1, (%r10,%rdi,8)
movq (%rdx,%rcx,8), %rdi
movl (%r11,%rdi,8), %edi
shrl %edi
movl %edi, (%rsi,%rcx,4)
incq %rcx
cmpq %rcx, %rax
jne 0x1bfe37
addq %rcx, %r12
cmpq %r15, %r12
jl 0x1bff67
testq %r12, %r12
movq 0x228(%rsp), %rsi
jle 0x1bff15
movslq (%r14), %rax
leaq (%rax,%rax,8), %rcx
leaq (%rcx,%rcx,2), %rcx
addq %rax, %rcx
movq 0x208(%rsp), %rdx
movl 0x4(%rdx,%rcx), %eax
movl %eax, 0x4(%rsi)
movslq (%r14), %rax
leaq (%rax,%rax,8), %rcx
leaq (%rcx,%rcx,2), %rcx
addq %rax, %rcx
movl 0x8(%rdx,%rcx), %eax
movl %eax, 0x8(%rsi)
addq $0x8, %r13
xorl %eax, %eax
movslq (%r14,%rax,4), %rcx
leaq (%rcx,%rcx,8), %rdx
leaq (%rdx,%rdx,2), %rdx
addq %rcx, %rdx
movq 0x208(%rsp), %rcx
movupd (%rcx,%rdx), %xmm0
movups 0xc(%rcx,%rdx), %xmm1
movupd %xmm0, -0x8(%r13)
movups %xmm1, 0x4(%r13)
movl -0x4(%r13), %ecx
cmpl 0x4(%rsi), %ecx
jae 0x1bfefd
movl %ecx, 0x4(%rsi)
movl (%r13), %ecx
cmpl 0x8(%rsi), %ecx
jbe 0x1bff09
movl %ecx, 0x8(%rsi)
incq %rax
addq $0x1c, %r13
cmpq %rax, %r12
jne 0x1bfec5
movq %r12, %rax
addq $0x148, %rsp            # imm = 0x148
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpq (%rbp), %r13
jne 0x1bff86
movq %rbp, %rsi
xorl %eax, %eax
movq 0x1c0(%rsp), %r13
movl (%r11,%r14,8), %ecx
movq %rcx, (%r11,%r14,8)
movq (%rsi,%rax,8), %rdx
shlq $0x20, %rdx
orq %rcx, %rdx
movq %rdx, (%r11,%r14,8)
incq %r14
incq %rax
cmpq %rax, %rbx
jne 0x1bff3d
movq %r14, %r15
jmp 0x1bfb66
leaq 0x81b06(%rip), %rdi     # 0x241a74
leaq 0x7fce6(%rip), %rsi     # 0x23fc5b
leaq 0x81988(%rip), %rcx     # 0x241904
movl $0x20a8, %edx           # imm = 0x20A8
callq 0x2110
leaq 0x8196b(%rip), %rdi     # 0x2418f8
leaq 0x7fcc7(%rip), %rsi     # 0x23fc5b
leaq 0x81969(%rip), %rcx     # 0x241904
movl $0x206f, %edx           # imm = 0x206F
callq 0x2110