// File: /workspace/github_cpp_makefile_star2_O2/chhylp123[P]hifiasm/inter.cpp
// Function: gl_chain_refine_advance(overlap_region_alloc*, Correct_dumy*, haplotype_evdience_alloc*, glchain_t*, st_mt_t*, ul_idx_t const*, double, long, long, ug_opt_t const*, long, void*)
int64_t gl_chain_refine_advance(overlap_region_alloc* olist, Correct_dumy* dumy, haplotype_evdience_alloc *hap, glchain_t *ll, st_mt_t *sps, const ul_idx_t *uref, double diff_ec_ul, int64_t winLen, int64_t qlen, const ug_opt_t *uopt, 
int64_t debug_i, void *km)
{
	// ll->tk.n = ll->lo.n = 0;
	kv_ul_ov_t *idx = &(ll->lo);
	ul_contain *ct = uref->ct;
	uint64_t o2 = gl_chain_gen(olist, uref, idx, 0, hap, km);
	if(idx->n == 0) return 0;
	// fprintf(stderr, "[M::%s] qlen:%ld, idx->n:%u\n", __func__, qlen, (uint32_t)idx->n);
	uint64_t k, an, cn, si = 0, ei = 0, resc = 0, resc_tk = 0, tk_pl = 0, f = 0, occ = 0, cis_occ = 0, t_cis = 0;
	ma_utg_t *u = NULL; overlap_region *o = NULL;

	kv_resize_km(km, uint64_t, ll->srt.a, idx->n);
    kv_resize_km(km, uint64_t, hap->snp_srt, idx->n);
	kv_resize_km(km, ul_ov_t, ll->tk, ll->tk.n+idx->n);
	///note: there are three rounds of gl_chain_advance()
	///the first two rounds could reuse dumy->overlapID. But for the last round, dumy->overlapID is not long enough 
	occ = gl_chain_advance(idx, ll->tk.a+ll->tk.n, uref, uopt, G_CHAIN_BW, diff_ec_ul, qlen, UG_SKIP, dumy->overlapID, ll->srt.a.a, hap->snp_srt.a, G_CHAIN_TRANS_WEIGHT, 0, NULL, uref->ug, debug_i, km);
	if(occ) {
		if(ff_chain(idx, qlen, P_CHAIN_COV, -1/**G_CHAIN_TRANS_RATE**/, ll->tk.a+ll->tk.n, NULL, NULL, NULL, diff_ec_ul, winLen, km)) {
			f = 1; //dump_chain(idx, ll->tk.a+ll->tk.n, &(idx->a[idx->n-1]), km); 
			for (k = idx->a[idx->n-1].ts; k < idx->a[idx->n-1].te; k++) {
				olist->list[ll->tk.a[ll->tk.n+k].qn].x_pos_strand = 1;
			}
		} else if(o2) {///means there are trans overlaps
			gl_chain_gen(olist, uref, idx, 1, hap, km);
			kv_resize_km(km, uint64_t, ll->srt.a, idx->n);
    		kv_resize_km(km, uint64_t, hap->snp_srt, idx->n);
			kv_resize_km(km, ul_ov_t, ll->tk, ll->tk.n+idx->n);
			///chain all U-matches
			occ = gl_chain_advance(idx, ll->tk.a+ll->tk.n, uref, uopt, G_CHAIN_BW, diff_ec_ul, qlen, UG_SKIP, dumy->overlapID, ll->srt.a.a, hap->snp_srt.a, G_CHAIN_TRANS_WEIGHT, 0, NULL, uref->ug, debug_i, km);
			if(ff_chain(idx, qlen, P_CHAIN_COV, G_CHAIN_TRANS_RATE, ll->tk.a+ll->tk.n, olist, hap, uref, diff_ec_ul, winLen, km)) {
				f = 1; //dump_chain(idx, ll->tk.a+ll->tk.n, &(idx->a[idx->n-1]), km); 
				for (k = idx->a[idx->n-1].ts; k < idx->a[idx->n-1].te; k++) {
					olist->list[ll->tk.a[ll->tk.n+k].qn].x_pos_strand = 1;
				}
			}
		}
	}

	if(!f) {///if f == 1, only dump primary chain; otherwise dump all chains
		///we can save all data to buffer like ll->srt.a in advance; in case we don't need third round of chaining
		///means no trans overlaps, no need to do third round of chaining
		// if(!o2) {
		// 	;
		// }
		/**
		uint64_t z;
		for (k = 0; k < idx->n; k++) {
			if(check_trans_rate(ll->tk.a+ll->tk.n+idx->a[k].ts, idx->a[k].te-idx->a[k].ts, G_CHAIN_TRANS_RATE)) {
				for (z = idx->a[k].ts; z < idx->a[k].te; z++) {
					olist->list[ll->tk.a[ll->tk.n+z].qn].x_pos_strand = 1;
				}
			} else {
				for (z = idx->a[k].ts; z < idx->a[k].te; z++) {
					if(!(ll->tk.a[ll->tk.n+z].el)) continue;
					olist->list[ll->tk.a[ll->tk.n+z].qn].x_pos_strand = 1;
				}
			}	
		}
		**/
		for (k = 0; k < occ; k++) {
			olist->list[ll->tk.a[ll->tk.n+k].qn].x_pos_strand = 1;
		}
		// kv_resize_km(km, ul_ov_t, *idx, occ); idx->n = occ;
		// memcpy(idx->a, ll->tk.a+ll->tk.n, occ*sizeof((*(idx->a))));
	}
	// for (k = 0; k < idx->n; k++) olist->list[idx->a[k].qn].x_pos_strand = 1;
		
	for (k = 0, idx->n = 0, tk_pl = ll->tk.n, t_cis = 0; k < olist->length; k++) {
		o = &(olist->list[k]);
		///if f == 1, no matter 
		if(o->x_pos_strand && (f || o->is_match == 1)){
			u = &(uref->ug->u.a[o->y_id]);///overlaped reads
			resc_tk += rescue_trans_ul_chains(uref, o, NULL, 0, u, &(ll->tk), -1, -1, 0, NULL, km);
		} else if((!f) && o->is_match == 2) {
			// fprintf(stderr, "###[M::%s] # k:%lu, # o->y_id:%u\n", __func__, k, o->y_id);
			an = update_ava_het_site(hap, k, &si, &ei, 1);
			// if(an != get_het_site(hap, k)) fprintf(stderr, "an->%lu, get_het_site->%lu\n", an, get_het_site(hap, k));
			assert(an > 0);

			cn = ((uint32_t)(ct->idx.a[o->y_id]));		
			if(cn > 0) {
				resc += rescue_contain_ul_chains(uref, o, hap->list+si, an, 
				ct->rids.a + ((ct->idx.a[o->y_id])>>32), cn, idx, diff_ec_ul, winLen, 0, km);
			}

			u = &(uref->ug->u.a[o->y_id]);
			if(u->n > 1 || o->x_pos_strand) {///no redundant items here
				resc_tk += rescue_trans_ul_chains(uref, o, hap->list+si, an, u, 
				&(ll->tk), diff_ec_ul, winLen, o->x_pos_strand, &cis_occ, km);
				t_cis += cis_occ;
			}

			si = ei;
		} 
	}

	assert(ll->tk.n == resc_tk+tk_pl);
	assert(idx->n == resc);
	if(f) assert(resc==0);

		
	if(!f) {///dedup contained alignments
		if(idx->n) {///if some contained alignments have been rescued
			radix_sort_ul_ov_srt_tn(idx->a, idx->a + idx->n);
			idx->n = dedup_sort_ul_ov_t(idx->a, idx->n);///different trans alignments may have the same contained alignment
		}
		resc = idx->n;
		// fprintf(stderr, "***[M::%s] # contain:%lu, # non-contain:%lu\n", __func__, resc, (uint64_t)(ll->tk.n-tk_pl));
		for (k = tk_pl; k < ll->tk.n; k++) {///dump all non-contained reads
			kv_push_km(km, ul_ov_t, *idx, ll->tk.a[k]);
			if(idx->a[idx->n-1].tn&((uint32_t)(0x80000000))) {
				idx->a[idx->n-1].tn -= ((uint32_t)(0x80000000));
			}
		}
		ll->tk.n = tk_pl;

		radix_sort_ul_ov_srt_qe(idx->a, idx->a + idx->n);
		if(resc) {///need to dedup contained alignment again
			// fprintf(stderr, "[M::%s] idx->n:%lu, resc:%lu\n", __func__, (uint64_t)idx->n, resc);
			idx->n = dedup_sort_contains(idx->a, idx->n, ct, uopt);
		}
		
		///note: need sps for third round of gl_chain_advance() as dumy->overlapID might be not long enough
		kv_resize_km(km, uint64_t, *sps, idx->n);
		kv_resize_km(km, uint64_t, ll->srt.a, idx->n);
		kv_resize_km(km, uint64_t, hap->snp_srt, idx->n);
		kv_resize_km(km, ul_ov_t, ll->tk, ll->tk.n+idx->n);
		occ = gl_chain_advance(idx, ll->tk.a+ll->tk.n, uref, uopt, G_CHAIN_BW, diff_ec_ul, qlen, UG_SKIP, sps->a, ll->srt.a.a, hap->snp_srt.a, G_CHAIN_TRANS_WEIGHT, 1, &R_INF, NULL, debug_i, km);
		// fprintf(stderr, "***[M::%s] ll->tk.n:%u, occ:%lu\n", __func__, (uint32_t)ll->tk.n, occ);
		f = dump_all_chain_simple(idx, &(ll->tk), occ, qlen, P_CHAIN_COV, P_FRAGEMENT_CHAIN_COV, 
		P_FRAGEMENT_PRIMARY_CHAIN_COV, 0.1/**P_FRAGEMENT_PRIMARY_SECOND_COV**/, G_CHAIN_TRANS_RATE, PRIMARY_UL_CHAIN_MIN);
		// fprintf(stderr, ">>>[M::%s] ll->tk.n:%u\n", __func__, (uint32_t)ll->tk.n);
		// dump_all_chain(idx, &(ll->tk), occ, qlen, P_CHAIN_COV, P_CHAIN_SCORE);
	} else {
		///for primary chain, each element x: (x->tn & (uint32_t)(0x80000000))
		assgin_primary_chains(ll->tk.a+tk_pl, ll->tk.n-tk_pl, 1, NULL, NULL, NULL, NULL, G_CHAIN_BW, diff_ec_ul, qlen, 1);
		// radix_sort_ul_ov_srt_qe(ll->tk.a+tk_pl, ll->tk.a+ll->tk.n);
	} 

	///if f == 0, results have already been sorted by qe|qs
	if(f) {
		kv_resize_km(km, uint64_t, ll->srt.a, ll->tk.n-tk_pl); kv_resize_km(km, uint64_t, hap->snp_srt, ll->tk.n-tk_pl);
		assgin_primary_chains(ll->tk.a+tk_pl, ll->tk.n-tk_pl, 0, uref, uopt, ll->srt.a.a, hap->snp_srt.a, G_CHAIN_BW, diff_ec_ul, qlen, 1);
	}
	// debug_reverse_chain(ll->tk.a+tk_pl, ll->tk.n-tk_pl);
	/**
	if(idx->n > 0) {
		an = infer_read_ovlp(uref, olist, idx	, &(ll->tk), diff_ec_ul, winLen, uopt, ct, km);
		// if(an) fill_edge_weight(ll->tk.a+ll->tk.n-an, an, uopt, G_CHAIN_BW, diff_ec_ul, qlen);
	}
	**/
	return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movsd %xmm0, (%rsp)
movq %r8, %r15
movq %rcx, %r14
movq %rdx, %rbx
movq %rsi, 0x28(%rsp)
movq 0xd0(%rsp), %r12
movq 0x20(%r9), %rax
movq %rax, 0x60(%rsp)
xorl %r13d, %r13d
movq %rdi, 0x10(%rsp)
movq %r9, 0x8(%rsp)
movq %r9, %rsi
movq %rcx, %rdx
xorl %ecx, %ecx
movq %rbx, %r8
movq %r12, %r9
callq 0x1604c4
movq 0x8(%r14), %rcx
testq %rcx, %rcx
je 0x166437
movq %rax, %rbp
andq $0x0, 0x38(%rsp)
andq $0x0, 0x68(%rsp)
andq $0x0, 0x70(%rsp)
cmpq %rcx, 0x50(%r14)
jae 0x16586b
decq %rcx
movq %rcx, %rax
shrq %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x2, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x4, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x8, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x10, %rax
orq %rcx, %rax
leaq 0x1(%rax), %rcx
movq %rcx, 0x50(%r14)
movq 0x58(%r14), %rsi
leaq 0x8(,%rax,8), %rdx
movq %r12, %rdi
callq 0x1a3acc
movq %rax, 0x58(%r14)
movq 0x8(%r14), %rcx
cmpq %rcx, 0x240(%rbx)
movq %r15, 0x58(%rsp)
jae 0x1658da
decq %rcx
movq %rcx, %rax
shrq %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x2, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x4, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x8, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x10, %rax
orq %rcx, %rax
leaq 0x1(%rax), %rcx
movq %rcx, 0x240(%rbx)
movq 0x248(%rbx), %rsi
leaq 0x8(,%rax,8), %rdx
movq %r12, %rdi
callq 0x1a3acc
movq %rax, 0x248(%rbx)
movq 0x8(%r14), %rcx
movq 0xc0(%rsp), %r15
movq 0xb8(%rsp), %r13
movq 0x18(%r14), %rax
movq 0x20(%r14), %rdx
addq %rdx, %rcx
cmpq %rcx, 0x28(%r14)
jae 0x16594d
decq %rcx
movq %rcx, %rdx
shrq %rdx
orq %rcx, %rdx
movq %rdx, %rcx
shrq $0x2, %rcx
orq %rdx, %rcx
movq %rcx, %rdx
shrq $0x4, %rdx
orq %rcx, %rdx
movq %rdx, %rcx
shrq $0x8, %rcx
orq %rdx, %rcx
movq %rcx, %rdx
shrq $0x10, %rdx
orq %rcx, %rdx
incq %rdx
movq %rdx, 0x28(%r14)
imulq $0x1c, %rdx, %rdx
movq %r12, %rdi
movq %rax, %rsi
callq 0x1a3acc
movq %rax, 0x18(%r14)
movq 0x20(%r14), %rdx
imulq $0x1c, %rdx, %rsi
addq %rax, %rsi
movq 0x28(%rsp), %rax
movq 0x28(%rax), %rax
movq 0x58(%r14), %rcx
movq 0x248(%rbx), %r8
movq 0x8(%rsp), %rdx
movq (%rdx), %rdi
subq $0x50, %rsp
movq %rdi, 0x38(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, 0x28(%rsp)
movq %r8, 0x18(%rsp)
movq %rcx, 0x10(%rsp)
movq %rax, 0x8(%rsp)
orq $-0x1, 0x20(%rsp)
pushq $0x10
popq %r8
movq %r14, %rdi
movq %r15, %rcx
movsd 0x50(%rsp), %xmm0
movq %r13, %r9
callq 0x1637c6
addq $0x50, %rsp
testq %rax, %rax
movq %rbx, 0x20(%rsp)
je 0x165a5b
movq %rax, %r15
imulq $0x1c, 0x20(%r14), %rdx
addq 0x18(%r14), %rdx
movss 0x8c0a0(%rip), %xmm0    # 0x1f1a74
movss 0x870c4(%rip), %xmm1    # 0x1ecaa0
movq %r14, %rdi
movq %r13, %rsi
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
movsd (%rsp), %xmm2
pushq %r12
pushq 0xb8(%rsp)
callq 0x164670
popq %rcx
popq %rdx
testl %eax, %eax
je 0x165aa0
imulq $0x1c, 0x8(%r14), %rcx
movq (%r14), %rdx
movl -0xc(%rdx,%rcx), %eax
movl -0x8(%rdx,%rcx), %ecx
imulq $0x1c, %rax, %rdx
movsd (%rsp), %xmm0
movq 0x8(%rsp), %rbp
movq 0x10(%rsp), %rdi
cmpq %rcx, %rax
jae 0x165cf9
imulq $0x1c, 0x20(%r14), %rsi
movq (%rdi), %r8
addq 0x18(%r14), %rsi
movl (%rdx,%rsi), %esi
imulq $0xa8, %rsi, %rsi
movl $0x1, 0xc(%r8,%rsi)
incq %rax
addq $0x1c, %rdx
jmp 0x165a2a
xorl %r15d, %r15d
movsd (%rsp), %xmm0
movq 0x8(%rsp), %rbp
movq 0x10(%rsp), %rdi
xorl %eax, %eax
subq $0x1, %r15
jb 0x165a99
movq (%rdi), %rcx
imulq $0x1c, 0x20(%r14), %rdx
addq 0x18(%r14), %rdx
movl (%rax,%rdx), %edx
imulq $0xa8, %rdx, %rdx
movl $0x1, 0xc(%rcx,%rdx)
addq $0x1c, %rax
jmp 0x165a6f
movb $0x1, %cl
jmp 0x165cfb
testq %rbp, %rbp
movq 0x10(%rsp), %rdi
je 0x166449
pushq $0x1
popq %rcx
movq 0x8(%rsp), %rbp
movq %rbp, %rsi
movq %r14, %rdx
movq %rbx, %r8
movq %r12, %r9
callq 0x1604c4
movq 0x8(%r14), %rcx
cmpq %rcx, 0x50(%r14)
jae 0x165b29
decq %rcx
movq %rcx, %rax
shrq %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x2, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x4, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x8, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x10, %rax
orq %rcx, %rax
leaq 0x1(%rax), %rcx
movq %rcx, 0x50(%r14)
movq 0x58(%r14), %rsi
leaq 0x8(,%rax,8), %rdx
movq %r12, %rdi
callq 0x1a3acc
movq %rax, 0x58(%r14)
movq 0x8(%r14), %rcx
movq 0xc0(%rsp), %r15
cmpq %rcx, 0x240(%rbx)
jae 0x165b9b
decq %rcx
movq %rcx, %rax
shrq %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x2, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x4, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x8, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x10, %rax
orq %rcx, %rax
leaq 0x1(%rax), %rcx
movq %rcx, 0x240(%rbx)
movq 0x248(%rbx), %rsi
leaq 0x8(,%rax,8), %rdx
movq %r12, %rdi
callq 0x1a3acc
movq %rax, 0x248(%rbx)
movq 0x8(%r14), %rcx
movq 0x18(%r14), %rax
movq 0x20(%r14), %rdx
addq %rdx, %rcx
cmpq %rcx, 0x28(%r14)
jae 0x165bfe
decq %rcx
movq %rcx, %rdx
shrq %rdx
orq %rcx, %rdx
movq %rdx, %rcx
shrq $0x2, %rcx
orq %rdx, %rcx
movq %rcx, %rdx
shrq $0x4, %rdx
orq %rcx, %rdx
movq %rdx, %rcx
shrq $0x8, %rcx
orq %rdx, %rcx
movq %rcx, %rdx
shrq $0x10, %rdx
orq %rcx, %rdx
incq %rdx
movq %rdx, 0x28(%r14)
imulq $0x1c, %rdx, %rdx
movq %r12, %rdi
movq %rax, %rsi
callq 0x1a3acc
movq %rax, 0x18(%r14)
movq 0x20(%r14), %rdx
imulq $0x1c, %rdx, %rsi
addq %rax, %rsi
movq 0x28(%rsp), %rax
movq 0x28(%rax), %rax
movq 0x58(%r14), %rcx
movq 0x248(%rbx), %rdx
movq (%rbp), %rdi
subq $0x50, %rsp
movq %rdi, 0x38(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, 0x28(%rsp)
movq %rdx, 0x18(%rsp)
movq %rcx, 0x10(%rsp)
movq %rax, 0x8(%rsp)
orq $-0x1, 0x20(%rsp)
pushq $0x10
popq %r8
movq %r14, %rdi
movq %rbp, %rdx
movq %r15, %rcx
movsd 0x50(%rsp), %xmm0
movq %r13, %r9
callq 0x1637c6
addq $0x50, %rsp
movq %rax, %r15
imulq $0x1c, 0x20(%r14), %rdx
addq 0x18(%r14), %rdx
movss 0x8bdfe(%rip), %xmm0    # 0x1f1a74
movss 0x8bdfa(%rip), %xmm1    # 0x1f1a78
movq %r14, %rdi
movq %r13, %rsi
movq 0x10(%rsp), %rcx
movq %rbx, %r8
movq %rbp, %r9
movsd (%rsp), %xmm2
pushq %r12
movq 0xb8(%rsp), %rax
pushq %rax
callq 0x164670
popq %rcx
popq %rdx
testl %eax, %eax
je 0x166458
imulq $0x1c, 0x8(%r14), %rcx
movq (%r14), %rdx
movl -0xc(%rdx,%rcx), %eax
movl -0x8(%rdx,%rcx), %ecx
imulq $0x1c, %rax, %rdx
movsd (%rsp), %xmm0
movq 0x10(%rsp), %rdi
cmpq %rcx, %rax
jae 0x165cf9
imulq $0x1c, 0x20(%r14), %rsi
movq (%rdi), %r8
addq 0x18(%r14), %rsi
movl (%rdx,%rsi), %esi
imulq $0xa8, %rsi, %rsi
movl $0x1, 0xc(%r8,%rsi)
incq %rax
addq $0x1c, %rdx
jmp 0x165ccc
xorl %ecx, %ecx
leaq 0x18(%r14), %rax
movq %rax, 0x30(%rsp)
andq $0x0, 0x8(%r14)
movq 0x20(%r14), %rax
movq %rax, 0x18(%rsp)
xorl %r13d, %r13d
xorl %r12d, %r12d
movq $0x0, 0x40(%rsp)
movq $0x0, 0x50(%rsp)
movl %ecx, 0x28(%rsp)
movq %r14, 0x48(%rsp)
cmpq 0x10(%rdi), %r12
jae 0x165f12
movq (%rdi), %rbx
leaq (%rbx,%r13), %r15
cmpl $0x0, 0xc(%rbx,%r13)
je 0x165dbb
testb %cl, %cl
je 0x165d59
movb 0x2c(%rbx,%r13), %al
cmpb $0x1, %al
jne 0x165dc8
movq (%rbp), %rax
movl 0x10(%rbx,%r13), %ecx
imulq $0x28, %rcx, %r8
addq 0x10(%rax), %r8
subq $0x20, %rsp
movq 0xf0(%rsp), %rax
movq %rax, 0x18(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%rsp)
orq $-0x1, (%rsp)
movq %rbp, %rdi
movq %r15, %rsi
xorl %edx, %edx
xorl %ecx, %ecx
movq 0x50(%rsp), %r9
movsd 0x7d7e1(%rip), %xmm0    # 0x1e3580
callq 0x1619a7
movl 0x48(%rsp), %ecx
movq 0x30(%rsp), %rdi
addq $0x20, %rsp
addq %rax, 0x50(%rsp)
jmp 0x165e6c
testb %cl, %cl
je 0x165f03
movb 0x2c(%rbx,%r13), %al
cmpb $0x2, %al
jne 0x165e6c
movq 0x20(%rsp), %rdi
movq %r12, %rsi
leaq 0x38(%rsp), %rdx
leaq 0x68(%rsp), %rcx
pushq $0x1
popq %r8
callq 0x160309
testq %rax, %rax
je 0x166462
movq %rax, %rbp
movq 0x60(%rsp), %rsi
movq 0x10(%rsi), %rcx
movl 0x10(%rbx,%r13), %eax
movq (%rcx,%rax,8), %rcx
movq %rcx, %r9
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
andq %rdx, %r9
movsd (%rsp), %xmm0
je 0x165e76
imulq $0x18, 0x38(%rsp), %rdx
movq 0x20(%rsp), %rax
addq (%rax), %rdx
shrq $0x20, %rcx
imulq $0xc, %rcx, %r8
addq 0x28(%rsi), %r8
movq 0x8(%rsp), %r14
movq %r14, %rdi
movq %r15, %rsi
movq %rbp, %rcx
pushq 0xd0(%rsp)
pushq $0x0
pushq 0xc0(%rsp)
pushq 0x60(%rsp)
callq 0x161567
addq $0x20, %rsp
addq %rax, 0x40(%rsp)
movl 0x10(%rbx,%r13), %eax
jmp 0x165e7b
movsd (%rsp), %xmm0
jmp 0x165f03
movq 0x8(%rsp), %r14
movq (%r14), %rcx
movq 0x10(%rcx), %r8
imulq $0x28, %rax, %rcx
cmpl $0x1, 0x10(%r8,%rcx)
movl 0xc(%rbx,%r13), %eax
ja 0x165e97
testl %eax, %eax
je 0x165ee1
addq %rcx, %r8
imulq $0x18, 0x38(%rsp), %rdx
movq 0x20(%rsp), %rcx
addq (%rcx), %rdx
movq 0x8(%rsp), %rdi
movq %r15, %rsi
movq %rbp, %rcx
movq 0x30(%rsp), %r9
movsd (%rsp), %xmm0
pushq 0xd0(%rsp)
leaq 0x78(%rsp), %r10
pushq %r10
pushq %rax
pushq 0xc8(%rsp)
callq 0x1619a7
addq $0x20, %rsp
addq %rax, 0x50(%rsp)
movq 0x48(%rsp), %r14
movq 0x10(%rsp), %rdi
movl 0x28(%rsp), %ecx
movq 0x68(%rsp), %rax
movq %rax, 0x38(%rsp)
movsd (%rsp), %xmm0
movq 0x8(%rsp), %rbp
incq %r12
addq $0xa8, %r13
jmp 0x165d33
movq 0x20(%r14), %rsi
movq 0x50(%rsp), %rax
addq 0x18(%rsp), %rax
cmpq %rax, %rsi
jne 0x166481
movq 0x40(%rsp), %rax
cmpq %rax, 0x8(%r14)
movq 0x20(%rsp), %rbx
movq 0xb8(%rsp), %r12
pushq $0x1
popq %r13
jne 0x1664a0
testq %rax, %rax
sete %al
orb %cl, %al
je 0x1664bf
testb %cl, %cl
je 0x165f89
movq 0x40(%rsp), %rax
testq %rax, %rax
je 0x165fd6
movq (%r14), %rdi
imulq $0x1c, %rax, %rsi
addq %rdi, %rsi
callq 0x1574e1
movq (%r14), %rdi
movq 0x8(%r14), %rsi
callq 0x161e4a
movq %rax, %r15
movq %rax, 0x8(%r14)
jmp 0x165fd9
movq 0x18(%rsp), %r15
imulq $0x1c, %r15, %rdi
movq 0x30(%rsp), %rax
addq (%rax), %rdi
subq %r15, %rsi
subq $0x20, %rsp
movq %r12, 0x10(%rsp)
movq $0x1, 0x18(%rsp)
movq $0x10, 0x8(%rsp)
andq $0x0, (%rsp)
pushq $0x1
popq %rdx
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0x165372
addq $0x20, %rsp
jmp 0x166316
xorl %r15d, %r15d
movq 0x18(%rsp), %r13
imulq $0x1c, %r13, %rbx
pushq $0x2
popq %r12
movq %r15, %rcx
cmpq 0x20(%r14), %r13
jae 0x166073
movq (%r14), %rax
cmpq 0x10(%r14), %rcx
jne 0x166026
leaq (%rcx,%rcx), %rdx
testq %rcx, %rcx
cmoveq %r12, %rdx
movq %rdx, 0x10(%r14)
imulq $0x1c, %rdx, %rdx
movq 0xd0(%rsp), %rdi
movq %rax, %rsi
callq 0x1a3acc
movq %rax, (%r14)
movq 0x8(%r14), %rcx
movq 0x18(%r14), %rdx
leaq 0x1(%rcx), %rsi
movq %rsi, 0x8(%r14)
imulq $0x1c, %rcx, %rcx
movups (%rdx,%rbx), %xmm0
movups 0xc(%rdx,%rbx), %xmm1
movups %xmm1, 0xc(%rax,%rcx)
movups %xmm0, (%rax,%rcx)
movq (%r14), %rax
movq 0x8(%r14), %rcx
imulq $0x1c, %rcx, %rsi
movl -0x10(%rax,%rsi), %edx
testl %edx, %edx
jns 0x166067
addq %rsi, %rax
andl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
movl %edx, -0x10(%rax)
incq %r13
addq $0x1c, %rbx
jmp 0x165fe9
movq 0x18(%rsp), %rax
movq %rax, 0x20(%r14)
movq (%r14), %rdi
imulq $0x1c, %rcx, %rsi
addq %rdi, %rsi
callq 0x156f5c
movq 0x8(%r14), %rax
testq %r15, %r15
je 0x1660b0
movq (%r14), %rdi
movq %rax, %rsi
movq 0x60(%rsp), %rdx
movq 0xc0(%rsp), %rcx
callq 0x164996
movq %rax, 0x8(%r14)
movq 0x20(%rsp), %rbx
movq 0xd0(%rsp), %r15
movq 0xb8(%rsp), %r12
movq 0x58(%rsp), %r13
cmpq %rax, 0x8(%r13)
jae 0x166128
decq %rax
movq %rax, %rcx
shrq %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x2, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x4, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x8, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x10, %rcx
orq %rax, %rcx
leaq 0x1(%rcx), %rax
movq %rax, 0x8(%r13)
movq 0x10(%r13), %rsi
leaq 0x8(,%rcx,8), %rdx
movq %r15, %rdi
callq 0x1a3acc
movq %rax, 0x10(%r13)
movq 0x8(%r14), %rax
cmpq %rax, 0x50(%r14)
jae 0x166186
decq %rax
movq %rax, %rcx
shrq %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x2, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x4, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x8, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x10, %rcx
orq %rax, %rcx
leaq 0x1(%rcx), %rax
movq %rax, 0x50(%r14)
movq 0x58(%r14), %rsi
leaq 0x8(,%rcx,8), %rdx
movq %r15, %rdi
callq 0x1a3acc
movq %rax, 0x58(%r14)
movq 0x8(%r14), %rax
cmpq %rax, 0x240(%rbx)
jae 0x1661f0
decq %rax
movq %rax, %rcx
shrq %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x2, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x4, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x8, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x10, %rcx
orq %rax, %rcx
leaq 0x1(%rcx), %rax
movq %rax, 0x240(%rbx)
movq 0x248(%rbx), %rsi
leaq 0x8(,%rcx,8), %rdx
movq %r15, %rdi
callq 0x1a3acc
movq %rax, 0x248(%rbx)
movq 0x8(%r14), %rax
movq 0x18(%r14), %rcx
movq 0x20(%r14), %rdx
addq %rdx, %rax
cmpq %rax, 0x28(%r14)
jae 0x166256
decq %rax
movq %rax, %rdx
shrq %rdx
orq %rax, %rdx
movq %rdx, %rax
shrq $0x2, %rax
orq %rdx, %rax
movq %rax, %rdx
shrq $0x4, %rdx
orq %rax, %rdx
movq %rdx, %rax
shrq $0x8, %rax
orq %rdx, %rax
movq %rax, %rdx
shrq $0x10, %rdx
orq %rax, %rdx
incq %rdx
movq %rdx, 0x28(%r14)
imulq $0x1c, %rdx, %rdx
movq %r15, %rdi
movq %rcx, %rsi
callq 0x1a3acc
movq %rax, %rcx
movq %rax, 0x18(%r14)
movq 0x20(%r14), %rdx
movsd (%rsp), %xmm0
imulq $0x1c, %rdx, %rsi
addq %rcx, %rsi
movq 0x10(%r13), %rax
movq 0x58(%r14), %rcx
movq 0x248(%rbx), %rdx
subq $0x50, %rsp
leaq 0xedfb4(%rip), %rdi     # 0x254230
movq %rdi, 0x30(%rsp)
movq %rdx, 0x18(%rsp)
movq %rcx, 0x10(%rsp)
movq %rax, 0x8(%rsp)
andq $0x0, 0x38(%rsp)
movq $0x1, 0x28(%rsp)
orq $-0x1, 0x20(%rsp)
pushq $0x10
popq %r8
movq %r14, %rdi
movq %rbp, %rdx
movq 0x110(%rsp), %rcx
movq %r12, %r9
callq 0x1637c6
addq $0x50, %rsp
movss 0x8b7a9(%rip), %xmm0    # 0x1f1a74
movss 0x819ed(%rip), %xmm1    # 0x1e7cc0
movss 0x8b7a1(%rip), %xmm2    # 0x1f1a7c
movss 0x819cd(%rip), %xmm3    # 0x1e7cb0
movss 0x8b78d(%rip), %xmm4    # 0x1f1a78
movl $0x124f8, %r8d          # imm = 0x124F8
movq %r14, %rdi
movq 0x30(%rsp), %rsi
movq %rax, %rdx
movq %r12, %rcx
callq 0x164d4e
testq %rax, %rax
pushq $0x1
popq %r13
movq 0x18(%rsp), %r15
je 0x166437
movq 0x20(%r14), %rsi
subq %r15, %rsi
cmpq %rsi, 0x50(%r14)
jae 0x166383
decq %rsi
movq %rsi, %rax
shrq %rax
orq %rsi, %rax
movq %rax, %rcx
shrq $0x2, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x4, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x8, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x10, %rax
orq %rcx, %rax
leaq 0x1(%rax), %rcx
movq %rcx, 0x50(%r14)
movq 0x58(%r14), %rsi
leaq 0x8(,%rax,8), %rdx
movq 0xd0(%rsp), %rdi
callq 0x1a3acc
movq %rax, 0x58(%r14)
movq 0x20(%r14), %rsi
subq %r15, %rsi
movq 0x248(%rbx), %rax
cmpq %rsi, 0x240(%rbx)
jae 0x166404
decq %rsi
movq %rsi, %rcx
shrq %rcx
orq %rsi, %rcx
movq %rcx, %rdx
shrq $0x2, %rdx
orq %rcx, %rdx
movq %rdx, %rcx
shrq $0x4, %rcx
orq %rdx, %rcx
movq %rcx, %rdx
shrq $0x8, %rdx
orq %rcx, %rdx
movq %rdx, %rcx
shrq $0x10, %rcx
orq %rdx, %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x240(%rbx)
leaq 0x8(,%rcx,8), %rdx
movq 0xd0(%rsp), %rdi
movq %rax, %rsi
callq 0x1a3acc
movq %rax, 0x248(%rbx)
movq 0x20(%r14), %rsi
movq 0x18(%rsp), %rcx
subq %rcx, %rsi
movsd (%rsp), %xmm0
jmp 0x16640e
movsd (%rsp), %xmm0
movq 0x18(%rsp), %rcx
imulq $0x1c, %rcx, %rdi
addq 0x18(%r14), %rdi
movq 0x58(%r14), %r9
xorl %edx, %edx
movq %rbp, %rcx
movq 0xc0(%rsp), %r8
pushq $0x1
pushq %r12
pushq $0x10
pushq %rax
callq 0x165372
addq $0x20, %rsp
movq %r13, %rax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movsd (%rsp), %xmm0
movq 0x8(%rsp), %rbp
jmp 0x165a6d
movsd (%rsp), %xmm0
jmp 0x165a68
leaq 0x8c342(%rip), %rdi     # 0x1f27ab
leaq 0x8b6b3(%rip), %rsi     # 0x1f1b23
leaq 0x8c33b(%rip), %rcx     # 0x1f27b2
movl $0x113d, %edx           # imm = 0x113D
callq 0x2110
leaq 0x8c3f5(%rip), %rdi     # 0x1f287d
leaq 0x8b694(%rip), %rsi     # 0x1f1b23
leaq 0x8c31c(%rip), %rcx     # 0x1f27b2
movl $0x1150, %edx           # imm = 0x1150
callq 0x2110
leaq 0x8c3f0(%rip), %rdi     # 0x1f2897
leaq 0x8b675(%rip), %rsi     # 0x1f1b23
leaq 0x8c2fd(%rip), %rcx     # 0x1f27b2
movl $0x1151, %edx           # imm = 0x1151
callq 0x2110
leaq 0x8c3e0(%rip), %rdi     # 0x1f28a6
leaq 0x8b656(%rip), %rsi     # 0x1f1b23
leaq 0x8c2de(%rip), %rcx     # 0x1f27b2
movl $0x1152, %edx           # imm = 0x1152
callq 0x2110