// File: /workspace/github_cpp_makefile_star2_O1/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, 0x8(%rsp)
movq %r9, %r15
movq %r8, %r12
movq %rcx, %rbp
movq %rdx, %r14
movq %rsi, %r13
movq 0xd0(%rsp), %r9
movq 0x20(%r15), %rax
movq %rax, 0x50(%rsp)
xorl %ebx, %ebx
movq %rdi, (%rsp)
movq %r15, %rsi
movq %rcx, %rdx
xorl %ecx, %ecx
movq %r14, %r8
callq 0x19f426
movq 0x8(%rbp), %rdx
testq %rdx, %rdx
je 0x1a5d4e
movq %rax, 0x20(%rsp)
xorl %ecx, %ecx
movq %rcx, 0x30(%rsp)
movq %rcx, 0x60(%rsp)
movq %rcx, 0x70(%rsp)
cmpq %rdx, 0x50(%rbp)
jae 0x1a5081
decq %rdx
movq %rdx, %rcx
shrq %rcx
orq %rdx, %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(%rbp)
movq 0x58(%rbp), %rsi
leaq 0x8(,%rcx,8), %rdx
movq 0xd0(%rsp), %rdi
callq 0x1e3800
movq %rax, 0x58(%rbp)
movq %r12, 0x68(%rsp)
movq 0x8(%rbp), %rax
cmpq %rax, 0x240(%r14)
jae 0x1a50f5
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(%r14)
movq 0x248(%r14), %rsi
leaq 0x8(,%rcx,8), %rdx
movq 0xd0(%rsp), %rdi
callq 0x1e3800
movq %rax, 0x248(%r14)
movq 0xb8(%rsp), %rbx
movq 0x8(%rbp), %rax
addq 0x20(%rbp), %rax
cmpq %rax, 0x28(%rbp)
jae 0x1a516b
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, 0x28(%rbp)
movq 0x18(%rbp), %rsi
leaq (%rax,%rax,8), %rax
leaq (%rax,%rax,2), %rax
leaq (%rcx,%rax), %rdx
incq %rdx
movq 0xd0(%rsp), %rdi
callq 0x1e3800
movq %rax, 0x18(%rbp)
movq 0x20(%rbp), %rax
leaq (%rax,%rax,8), %rcx
leaq (%rcx,%rcx,2), %rsi
addq %rax, %rsi
addq 0x18(%rbp), %rsi
movq 0x58(%rbp), %rax
movq %r13, %r12
movq 0x28(%r13), %rcx
movq 0x248(%r14), %rdx
movq (%r15), %rdi
subq $0x50, %rsp
movq %rdi, 0x38(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, 0x28(%rsp)
movq %rdx, 0x18(%rsp)
movq %rax, 0x10(%rsp)
movq %rcx, 0x8(%rsp)
movq $-0x1, 0x20(%rsp)
movl $0x10, %r8d
movq %rbp, %rdi
movq %r15, 0x60(%rsp)
movq %r15, %rdx
movq 0x110(%rsp), %rcx
movsd 0x58(%rsp), %xmm0
movq %rbx, %r9
callq 0x1a2b62
addq $0x50, %rsp
movb $0x1, %r8b
testq %rax, %rax
je 0x1a553e
movq %rax, %r13
movq 0x8(%rbp), %rcx
testq %rcx, %rcx
movq (%rsp), %rdi
je 0x1a5292
movq (%rbp), %rdx
leaq (%rcx,%rcx,8), %rax
leaq (%rax,%rax,2), %rax
addq %rcx, %rax
movl -0x14(%rdx,%rax), %ecx
subl -0x18(%rdx,%rax), %ecx
xorps %xmm0, %xmm0
cvtsi2ss %rcx, %xmm0
cvtsi2ss %rbx, %xmm1
mulss 0x8e6b5(%rip), %xmm1    # 0x2338e8
ucomiss %xmm0, %xmm1
jae 0x1a5292
movq (%rbp), %rcx
movl -0xc(%rcx,%rax), %esi
movl -0x8(%rcx,%rax), %eax
cmpl %eax, %esi
jae 0x1a5539
movq 0x20(%rbp), %r8
movq (%rdi), %rcx
subq %rsi, %rax
leaq (%r8,%r8,8), %rdx
leaq (%rdx,%rdx,2), %rdx
addq %r8, %rdx
leaq (%rsi,%rsi,8), %r8
leaq (%r8,%r8,2), %r8
addq %rsi, %r8
addq 0x18(%rbp), %rdx
addq %r8, %rdx
movl (%rdx), %esi
imulq $0xa8, %rsi, %rsi
movl $0x1, 0xc(%rcx,%rsi)
addq $0x1c, %rdx
decq %rax
jne 0x1a5273
jmp 0x1a5539
cmpq $0x0, 0x20(%rsp)
je 0x1a5545
movq %rbx, %r15
movq 0x10(%rsp), %rbx
movq %rbx, %rsi
movq %rbp, %rdx
movl $0x1, %ecx
movq %r14, %r8
movq 0xd0(%rsp), %r9
callq 0x19f426
movq 0x8(%rbp), %rax
cmpq %rax, 0x50(%rbp)
jae 0x1a5324
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(%rbp)
movq 0x58(%rbp), %rsi
leaq 0x8(,%rcx,8), %rdx
movq 0xd0(%rsp), %rdi
callq 0x1e3800
movq %rax, 0x58(%rbp)
movq 0x8(%rbp), %rax
cmpq %rax, 0x240(%r14)
jae 0x1a5393
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(%r14)
movq 0x248(%r14), %rsi
leaq 0x8(,%rcx,8), %rdx
movq 0xd0(%rsp), %rdi
callq 0x1e3800
movq %rax, 0x248(%r14)
movq 0x8(%rbp), %rax
addq 0x20(%rbp), %rax
cmpq %rax, 0x28(%rbp)
jae 0x1a5401
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, 0x28(%rbp)
movq 0x18(%rbp), %rsi
leaq (%rax,%rax,8), %rax
leaq (%rax,%rax,2), %rax
leaq (%rcx,%rax), %rdx
incq %rdx
movq 0xd0(%rsp), %rdi
callq 0x1e3800
movq %rax, 0x18(%rbp)
movq 0x20(%rbp), %rax
leaq (%rax,%rax,8), %rcx
leaq (%rcx,%rcx,2), %rsi
addq %rax, %rsi
addq 0x18(%rbp), %rsi
movq 0x58(%rbp), %rax
movq 0x28(%r12), %rcx
movq 0x248(%r14), %rdx
movq (%rbx), %rdi
subq $0x50, %rsp
movq %rdi, 0x38(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, 0x28(%rsp)
movq %rdx, 0x18(%rsp)
movq %rax, 0x10(%rsp)
movq %rcx, 0x8(%rsp)
movq $-0x1, 0x20(%rsp)
movl $0x10, %r8d
movq %rbp, %rdi
movq %rbx, %rdx
movq 0x110(%rsp), %rcx
movsd 0x58(%rsp), %xmm0
movq %r15, %r9
callq 0x1a2b62
addq $0x50, %rsp
movq %rax, %r13
movq 0x20(%rbp), %rax
leaq (%rax,%rax,8), %rcx
leaq (%rcx,%rcx,2), %rdx
addq %rax, %rdx
addq 0x18(%rbp), %rdx
movss 0x8e454(%rip), %xmm0    # 0x2338e8
movss 0x8e450(%rip), %xmm1    # 0x2338ec
movq %rbp, %rdi
movq %r15, %rsi
movq (%rsp), %rcx
movq %r14, %r8
movq %rbx, %r9
movsd 0x8(%rsp), %xmm2
pushq 0xd0(%rsp)
pushq 0xb8(%rsp)
callq 0x1a3cd7
addq $0x10, %rsp
testl %eax, %eax
je 0x1a5d60
movq (%rbp), %rax
movq 0x8(%rbp), %rcx
leaq (%rcx,%rcx,8), %rdx
leaq (%rdx,%rdx,2), %rdx
addq %rcx, %rdx
movl -0xc(%rax,%rdx), %esi
movl -0x8(%rax,%rdx), %eax
cmpl %eax, %esi
jae 0x1a5d6c
movq (%rsp), %rdi
movq (%rdi), %rcx
movq 0x20(%rbp), %rdx
subq %rsi, %rax
leaq (%rdx,%rdx,8), %r8
leaq (%r8,%r8,2), %r8
addq %rdx, %r8
leaq (%rsi,%rsi,8), %rdx
leaq (%rdx,%rdx,2), %rdx
addq %rsi, %rdx
addq %r8, %rdx
addq 0x18(%rbp), %rdx
movl (%rdx), %esi
imulq $0xa8, %rsi, %rsi
movl $0x1, 0xc(%rcx,%rsi)
addq $0x1c, %rdx
decq %rax
jne 0x1a551f
xorl %r8d, %r8d
jmp 0x1a5545
xorl %r13d, %r13d
movq (%rsp), %rdi
testb %r8b, %r8b
je 0x1a557f
testq %r13, %r13
je 0x1a557f
movq (%rdi), %rax
movq 0x20(%rbp), %rdx
leaq (%rdx,%rdx,8), %rcx
leaq (%rcx,%rcx,2), %rcx
addq %rdx, %rcx
addq 0x18(%rbp), %rcx
movl (%rcx), %edx
imulq $0xa8, %rdx, %rdx
movl $0x1, 0xc(%rax,%rdx)
addq $0x1c, %rcx
decq %r13
jne 0x1a5565
movq %r14, 0x28(%rsp)
leaq 0x18(%rbp), %rax
movq %rax, 0x20(%rsp)
movq $0x0, 0x8(%rbp)
movq 0x20(%rbp), %rax
movq %rax, 0x38(%rsp)
cmpq $0x0, 0x10(%rdi)
je 0x1a57df
xorl %r14d, %r14d
xorl %ecx, %ecx
movq $0x0, 0x40(%rsp)
xorl %r12d, %r12d
movl %r8d, 0x1c(%rsp)
movq %rbp, 0x48(%rsp)
movq (%rdi), %r15
leaq (%r15,%r14), %rbx
cmpl $0x0, 0xc(%r15,%r14)
je 0x1a5659
testb %r8b, %r8b
je 0x1a55e4
cmpb $0x1, 0x2c(%r15,%r14)
jne 0x1a5659
movq 0x10(%rsp), %rdi
movq (%rdi), %rax
movq %rbp, %r13
movq %rcx, %rbp
movl 0x10(%r15,%r14), %ecx
leaq (%rcx,%rcx,4), %r8
shlq $0x3, %r8
addq 0x10(%rax), %r8
subq $0x20, %rsp
movq 0xf0(%rsp), %rax
movq %rax, 0x18(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%rsp)
movq $-0x1, (%rsp)
movq %rbx, %rsi
xorl %edx, %edx
xorl %ecx, %ecx
movq 0x40(%rsp), %r9
movsd 0x7ff00(%rip), %xmm0    # 0x225538
callq 0x1a0ae8
movq %rbp, %rcx
movq %r13, %rbp
movl 0x3c(%rsp), %r8d
movq 0x20(%rsp), %rdi
addq $0x20, %rsp
addq %rax, %rcx
jmp 0x1a57b4
testb %r8b, %r8b
je 0x1a57b4
cmpb $0x2, 0x2c(%r15,%r14)
jne 0x1a57b4
movq %rcx, 0x58(%rsp)
movl $0x1, %r8d
movq 0x28(%rsp), %rdi
movq %r12, %rsi
leaq 0x30(%rsp), %rdx
leaq 0x60(%rsp), %rcx
callq 0x19f226
testq %rax, %rax
je 0x1a5d74
movq %rax, %r13
movq 0x50(%rsp), %rsi
movq 0x10(%rsi), %rax
movl 0x10(%r15,%r14), %ecx
movq (%rax,%rcx,8), %rax
movq %rax, %r9
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
andq %rcx, %r9
je 0x1a5718
movq 0x30(%rsp), %rcx
leaq (%rcx,%rcx,2), %rdx
shlq $0x3, %rdx
movq 0x28(%rsp), %rcx
addq (%rcx), %rdx
shrq $0x20, %rax
leaq (%rax,%rax,2), %r8
shlq $0x2, %r8
addq 0x28(%rsi), %r8
movq 0x10(%rsp), %rbp
movq %rbp, %rdi
movq %rbx, %rsi
movq %r13, %rcx
movsd 0x8(%rsp), %xmm0
pushq 0xd0(%rsp)
pushq $0x0
pushq 0xc0(%rsp)
pushq 0x60(%rsp)
callq 0x1a0658
addq $0x20, %rsp
addq %rax, 0x40(%rsp)
jmp 0x1a571d
movq 0x10(%rsp), %rbp
movq (%rbp), %rax
movq 0x10(%rax), %rax
movl 0x10(%r15,%r14), %ecx
leaq (%rcx,%rcx,4), %rcx
cmpl $0x1, 0x10(%rax,%rcx,8)
ja 0x1a5741
cmpl $0x0, 0xc(%r15,%r14)
je 0x1a57ca
leaq (%rax,%rcx,8), %r8
movq 0x30(%rsp), %rax
leaq (%rax,%rax,2), %rdx
shlq $0x3, %rdx
movq 0x28(%rsp), %rax
addq (%rax), %rdx
movl 0xc(%r15,%r14), %eax
movq 0x10(%rsp), %rdi
movq %rbx, %rsi
movq %r13, %rcx
movq 0x20(%rsp), %r9
movsd 0x8(%rsp), %xmm0
pushq 0xd0(%rsp)
leaq 0x78(%rsp), %r10
pushq %r10
pushq %rax
pushq 0xc8(%rsp)
callq 0x1a0ae8
addq $0x20, %rsp
movq 0x58(%rsp), %rcx
addq %rax, %rcx
movq 0x48(%rsp), %rbp
movq (%rsp), %rdi
movl 0x1c(%rsp), %r8d
movq 0x60(%rsp), %rax
movq %rax, 0x30(%rsp)
incq %r12
addq $0xa8, %r14
cmpq 0x10(%rdi), %r12
jb 0x1a55c4
jmp 0x1a57ea
movq 0x48(%rsp), %rbp
movq (%rsp), %rdi
movl 0x1c(%rsp), %r8d
movq 0x58(%rsp), %rcx
jmp 0x1a57aa
movq $0x0, 0x40(%rsp)
xorl %ecx, %ecx
movq 0x20(%rbp), %rsi
movq 0x38(%rsp), %r15
addq %r15, %rcx
cmpq %rcx, %rsi
movq 0xb8(%rsp), %rbx
jne 0x1a5d93
movq 0x8(%rbp), %rax
movq 0x40(%rsp), %rcx
cmpq %rcx, %rax
movq 0x28(%rsp), %r13
jne 0x1a5db2
testq %rcx, %rcx
sete %cl
orb %r8b, %cl
je 0x1a5dd1
testb %r8b, %r8b
je 0x1a5bf4
testq %rax, %rax
je 0x1a5866
movq (%rbp), %rdi
leaq (%rax,%rax,8), %rcx
leaq (%rcx,%rcx,2), %rcx
addq %rdi, %rax
addq %rcx, %rax
movq %rax, %rsi
callq 0x195abc
movq (%rbp), %rdi
movq 0x8(%rbp), %rsi
callq 0x1a1016
movq %rax, 0x8(%rbp)
movq 0x8(%rbp), %rbx
cmpq 0x20(%rbp), %r15
jae 0x1a592e
movq 0x38(%rsp), %r12
leaq (%r12,%r12,8), %rax
leaq (%rax,%rax,2), %r14
addq %r12, %r14
movl $0x2, %r15d
movq 0x10(%rbp), %rax
cmpq %rax, 0x8(%rbp)
jne 0x1a58c3
leaq (%rax,%rax), %rcx
testq %rax, %rax
cmoveq %r15, %rcx
movq %rcx, 0x10(%rbp)
movq (%rbp), %rsi
leaq (%rcx,%rcx,8), %rax
leaq (%rax,%rax,2), %rdx
addq %rcx, %rdx
movq 0xd0(%rsp), %rdi
callq 0x1e3800
movq %rax, (%rbp)
movq 0x18(%rbp), %rax
movq (%rbp), %rcx
movq 0x8(%rbp), %rdx
leaq 0x1(%rdx), %rsi
movq %rsi, 0x8(%rbp)
leaq (%rdx,%rdx,8), %rsi
leaq (%rsi,%rsi,2), %rsi
addq %rdx, %rsi
movups (%rax,%r14), %xmm0
movups 0xc(%rax,%r14), %xmm1
movups %xmm1, 0xc(%rcx,%rsi)
movups %xmm0, (%rcx,%rsi)
movq (%rbp), %rax
movq 0x8(%rbp), %rdx
leaq (%rdx,%rdx,8), %rcx
leaq (%rcx,%rcx,2), %rcx
addq %rdx, %rcx
movl -0x10(%rax,%rcx), %edx
testl %edx, %edx
jns 0x1a591d
addq %rcx, %rax
andl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
movl %edx, -0x10(%rax)
incq %r12
addq $0x1c, %r14
cmpq 0x20(%rbp), %r12
jb 0x1a588a
movq 0x38(%rsp), %r15
movq %r15, 0x20(%rbp)
movq (%rbp), %rdi
movq 0x8(%rbp), %rsi
leaq (%rsi,%rsi,8), %rax
leaq (%rax,%rax,2), %rax
addq %rdi, %rsi
addq %rax, %rsi
callq 0x195511
testq %rbx, %rbx
je 0x1a5975
movq (%rbp), %rdi
movq 0x8(%rbp), %rsi
movq 0x50(%rsp), %rdx
movq 0xc0(%rsp), %rcx
callq 0x1a404e
movq %rax, 0x8(%rbp)
movq 0x8(%rbp), %rax
movq 0x68(%rsp), %r14
cmpq %rax, 0x8(%r14)
jae 0x1a59dd
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(%r14)
movq 0x10(%r14), %rsi
leaq 0x8(,%rcx,8), %rdx
movq 0xd0(%rsp), %rdi
callq 0x1e3800
movq %rax, 0x10(%r14)
movq 0x8(%rbp), %rax
cmpq %rax, 0x50(%rbp)
movq 0xb8(%rsp), %rbx
jae 0x1a5a48
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(%rbp)
movq 0x58(%rbp), %rsi
leaq 0x8(,%rcx,8), %rdx
movq 0xd0(%rsp), %rdi
callq 0x1e3800
movq %rax, 0x58(%rbp)
movq 0x8(%rbp), %rax
cmpq %rax, 0x240(%r13)
jae 0x1a5ab7
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(%r13)
movq 0x248(%r13), %rsi
leaq 0x8(,%rcx,8), %rdx
movq 0xd0(%rsp), %rdi
callq 0x1e3800
movq %rax, 0x248(%r13)
movq 0x8(%rbp), %rax
addq 0x20(%rbp), %rax
cmpq %rax, 0x28(%rbp)
jae 0x1a5b25
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, 0x28(%rbp)
movq 0x18(%rbp), %rsi
leaq (%rax,%rax,8), %rax
leaq (%rax,%rax,2), %rax
leaq (%rcx,%rax), %rdx
incq %rdx
movq 0xd0(%rsp), %rdi
callq 0x1e3800
movq %rax, 0x18(%rbp)
movq 0x20(%rbp), %rax
movq 0x58(%rbp), %rcx
leaq (%rax,%rax,8), %rdx
leaq (%rdx,%rdx,2), %rsi
addq %rax, %rsi
addq 0x18(%rbp), %rsi
movq 0x10(%r14), %rax
movq 0x248(%r13), %rdx
subq $0x50, %rsp
leaq 0xe56de(%rip), %rdi     # 0x28b230
movq %rdi, 0x30(%rsp)
movq %rdx, 0x18(%rsp)
movq %rcx, 0x10(%rsp)
movq %rax, 0x8(%rsp)
movq $0x0, 0x38(%rsp)
movq $0x1, 0x28(%rsp)
movq $-0x1, 0x20(%rsp)
movl $0x10, %r8d
movq %rbp, %rdi
movq 0x60(%rsp), %rdx
movq 0x110(%rsp), %rcx
movsd 0x58(%rsp), %xmm0
movq %rbx, %r9
callq 0x1a2b62
addq $0x50, %rsp
movss 0x8dd37(%rip), %xmm0    # 0x2338e8
movss 0x8400f(%rip), %xmm1    # 0x229bc8
movss 0x8dd2f(%rip), %xmm2    # 0x2338f0
movss 0x83fef(%rip), %xmm3    # 0x229bb8
movss 0x8dd1b(%rip), %xmm4    # 0x2338ec
movl $0x124f8, %r8d          # imm = 0x124F8
movq %rbp, %rdi
movq 0x20(%rsp), %rsi
movq %rax, %rdx
movq %rbx, %rcx
callq 0x1a4480
testq %rax, %rax
jne 0x1a5c2d
jmp 0x1a5d49
leaq (%r15,%r15,8), %rax
leaq (%rax,%rax,2), %rdi
addq %r15, %rdi
movq 0x20(%rsp), %rax
addq (%rax), %rdi
subq %r15, %rsi
movl $0x1, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
movsd 0x8(%rsp), %xmm0
pushq $0x1
pushq %rbx
pushq $0x10
pushq $0x0
callq 0x1a4b67
addq $0x20, %rsp
movq 0x20(%rbp), %rax
subq %r15, %rax
cmpq %rax, 0x50(%rbp)
jae 0x1a5c93
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(%rbp)
movq 0x58(%rbp), %rsi
leaq 0x8(,%rcx,8), %rdx
movq 0xd0(%rsp), %rdi
callq 0x1e3800
movq %rax, 0x58(%rbp)
movq 0x20(%rbp), %rax
subq %r15, %rax
cmpq %rax, 0x240(%r13)
jae 0x1a5d05
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(%r13)
movq 0x248(%r13), %rsi
leaq 0x8(,%rcx,8), %rdx
movq 0xd0(%rsp), %rdi
callq 0x1e3800
movq %rax, 0x248(%r13)
leaq (%r15,%r15,8), %rax
leaq (%rax,%rax,2), %rdi
addq %r15, %rdi
addq 0x18(%rbp), %rdi
movq 0x20(%rbp), %rsi
movq 0x58(%rbp), %r9
subq %r15, %rsi
xorl %edx, %edx
movq 0x10(%rsp), %rcx
movq 0xc0(%rsp), %r8
movsd 0x8(%rsp), %xmm0
pushq $0x1
pushq %rbx
pushq $0x10
pushq 0x248(%r13)
callq 0x1a4b67
addq $0x20, %rsp
movl $0x1, %ebx
movq %rbx, %rax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq (%rsp), %rdi
movb $0x1, %r8b
jmp 0x1a5545
xorl %r8d, %r8d
jmp 0x1a5541
leaq 0x8e898(%rip), %rdi     # 0x234613
leaq 0x8dc09(%rip), %rsi     # 0x23398b
leaq 0x8e891(%rip), %rcx     # 0x23461a
movl $0x113d, %edx           # imm = 0x113D
callq 0x2110
leaq 0x8e94b(%rip), %rdi     # 0x2346e5
leaq 0x8dbea(%rip), %rsi     # 0x23398b
leaq 0x8e872(%rip), %rcx     # 0x23461a
movl $0x1150, %edx           # imm = 0x1150
callq 0x2110
leaq 0x8e946(%rip), %rdi     # 0x2346ff
leaq 0x8dbcb(%rip), %rsi     # 0x23398b
leaq 0x8e853(%rip), %rcx     # 0x23461a
movl $0x1151, %edx           # imm = 0x1151
callq 0x2110
leaq 0x8e936(%rip), %rdi     # 0x23470e
leaq 0x8dbac(%rip), %rsi     # 0x23398b
leaq 0x8e834(%rip), %rcx     # 0x23461a
movl $0x1152, %edx           # imm = 0x1152
callq 0x2110