// File: chhylp123[P]hifiasm/inter.cpp
// Function: gen_max_gchain_adv(void*, ul_idx_t const*, long, st_mt_t*, vec_mg_lchain_t*, kv_ul_ov_t*, kv_ul_ov_t*, long, float, float, float, unsigned long, asg_t const*, st_mt_t*, vec_sp_node_t*, vec_mg_pathv_t*, unsigned long*, vec_mg_lchain_t*)
uint32_t gen_max_gchain_adv(void *km, const ul_idx_t *uref, int64_t ulid, st_mt_t *idx, vec_mg_lchain_t *e, kv_ul_ov_t *raw_idx, kv_ul_ov_t *raw_chn,
int64_t qlen, float primary_cov_rate, float primary_fragment_cov_rate, float primary_fragment_second_score_rate, uint64_t mini_primary_fragment_len, 
const asg_t *g, st_mt_t *dst_done, vec_sp_node_t *out, vec_mg_pathv_t *res, uint64_t *b, vec_mg_lchain_t *gchains)
{
	gchains->n = 0;
	if(idx->n <= 0) return 0;
	int64_t a_n, idx_n = idx->n, i, k, is_done = 0, n_mchain = 0; uint64_t om, ok, ovlp, novlp; 
	ul_ov_t *m = NULL, *p = NULL; mg_lchain_t *a = e->a, *g_item; int64_t raw_idx_n = raw_idx->n;
	ul_ov_t *gb = NULL; int64_t gb_n = 0;
	for (i = a_n = 0; i < idx_n; ++i) {
		kv_pushp(ul_ov_t, *raw_idx, &p);
		p->qn = ((int64_t)(idx->a[i]>>32));//score
		p->ts = a_n; p->te = a_n + ((uint32_t)idx->a[i]);
		p->qs = a[p->ts].qs; p->qe = a[p->te-1].qe; p->tn = 0;//(tn = 1) -> normal; (t = 0) -> duplicated chain
		a_n += ((uint32_t)idx->a[i]);
		// fprintf(stderr, "[M::%s::i->%ld] score->%u, qs->%u, qe->%u, occ->%u\n", __func__, i, p->qn, p->qs, p->qe, p->te-p->ts); 
	}
	gb = raw_idx->a + raw_idx_n; gb_n = raw_idx->n - raw_idx_n;
	radix_sort_ul_ov_srt_qn(gb, gb + gb_n);//sort by scores
	m = &(gb[gb_n-1]);///max chain
	// assert(a[m.ts].qs<=a[m.te-1].qs && a[m.te-1].qe>=a[m.ts].qe);
	// print_chain(a + m.ts, m.te - m.ts);
	///for debug
	// dedup_second_chain(uref, idx->a, idx_n, m.ts, m.te, a, raw_idx, raw_chn, b, bw, diff_ec_ul);
	// debug_ll_chains(uref, idx->a, idx_n, m.ts, m.te, a, raw_idx, raw_chn, b, bw, diff_ec_ul, qlen);

	if((m->qe - m->qs) > (qlen*primary_cov_rate)) {
		is_done = 1; m->tn = 1; n_mchain = 1;
	}

	if(is_done == 0) {
		for (i = gb_n - 2; i >= 0; i--) {///from the second best chain
			p = &(gb[i]);
			ovlp = ((MIN(m->qe, p->qe) > MAX(m->qs, p->qs))? (MIN(m->qe, p->qe) - MAX(m->qs, p->qs)):0);
			novlp = (p->qe - p->qs) - ovlp;
			if(novlp > ((m->qe-m->qs)*GC_OFFSET_RATE) && novlp > GC_OFFSET_POS) break;
		}
		if(i < 0) { ///no alignment that is on the left or the right side of the primary chain
			is_done = 2; m->tn = 1; n_mchain = 1;
		}
	}

	if(is_done == 0) {
		if(((m->qe - m->qs) > (qlen*primary_fragment_cov_rate)) || ((m->qe - m->qs) > mini_primary_fragment_len)) {
			// dedup_second_chain(uref, idx->a, idx_n, m.ts, m.te, a, raw_idx, raw_chn, b, bw, diff_ec_ul, qlen);
			if(raw_chn && raw_idx) dedup_second_chain_adv(uref, gb, gb_n, a, raw_idx, raw_chn, b, qlen, ulid);
			for (k = gb_n-1, n_mchain = 0; k >= 0; k--) {
				m = &(gb[k]);///max chain
				// fprintf(stderr, "++[M::%s::k->%ld] score->%u, qs->%u, qe->%u\n", __func__, k, m->qn, m->qs, m->qe); 
				if(((m->qe - m->qs) <= (qlen*primary_fragment_cov_rate)) && 
															((m->qe - m->qs) <= mini_primary_fragment_len)) break;
				om = m->qe - m->qs;
				for (i = gb_n-1; i >= 0; i--) {
					if(i == k) continue;
					p = &(gb[i]);
					// fprintf(stderr, "--[M::%s::i->%ld] score->%u, qs->%u, qe->%u\n", __func__, i, p->qn, p->qs, p->qe); 
					ovlp = ((MIN(m->qe, p->qe) > MAX(m->qs, p->qs))? (MIN(m->qe, p->qe) - MAX(m->qs, p->qs)):0);
					if(ovlp == 0) continue;
					ok = p->qe - p->qs;
					if(p->tn == 1 && ((ovlp > ok*0.1) || (ovlp > om*0.1))) break;
					if(ok > om) ok = om;
					if((ovlp > ok*0.1) && (p->qn > (m->qn*primary_fragment_second_score_rate))) break;
				}
				if(i < 0) {
					is_done = 3; m->tn = 1; n_mchain++;
				} else {
					 break;
				 }
			}
		}
	}

	if(is_done) {
		gchains->n = 0;
		for (k = gb_n - n_mchain; k < gb_n; k++) {
			kv_pushp(mg_lchain_t, *gchains, &g_item);
			g_item->v = (uint32_t)-1; 
			g_item->qs = gb[k].qs; g_item->qe = gb[k].qe; 
			g_item->rs = gb[k].ts; g_item->re = gb[k].te; 
			g_item->cnt = g_item->off = 0;
			gen_gchain_track(km, a + g_item->rs, g_item->re - g_item->rs, g, dst_done, out, res);
			kv_resize(mg_lchain_t, *gchains, gchains->n + res->n); ///a = gchains->a + gchains->n;
			for (i = 0, g_item = &(gchains->a[gchains->n-1]); i < ((int64_t)res->n); i++) {
				if(res->a[i].v == (uint32_t)-1) {
					gchains->a[i+gchains->n] = a[res->a[i].pre + g_item->rs]; 
					gchains->a[i+gchains->n].dist_pre = res->a[i].d;

					// fprintf(stderr, "+[M::%s::]\tutg%.6dl(%c)\n", __func__, 
					// (int32_t)(gchains->a[i+gchains->n].v>>1)+1, "+-"[gchains->a[i+gchains->n].v&1]);
				} else {
					gchains->a[i+gchains->n].v = res->a[i].v; 
					gchains->a[i+gchains->n].off = -1; 
					gchains->a[i+gchains->n].dist_pre = res->a[i].d;
					///the nodes detected by the graph chaining should be fully covered
					gchains->a[i+gchains->n].rs = 0;
					gchains->a[i+gchains->n].re = uref->ug->g->seq[res->a[i].v>>1].len;
					// fprintf(stderr, "aaaaaaa, ulid->%ld\n", ulid);
					// fprintf(stderr, "-[M::%s::]\tutg%.6dl(%c)\n", __func__, 
					// (int32_t)(gchains->a[i+gchains->n].v>>1)+1, "+-"[gchains->a[i+gchains->n].v&1]);
				}
			}
			g_item->cnt = res->n;
			gchains->n += res->n;
			// fprintf(stderr, "sbsbsbsb, ulid->%ld\n", ulid);
			// debug_gchain(km, g, gchains->a + gchains->n - res->n, res->n, dst_done, out);
		}
	}
	raw_idx->n = raw_idx_n;
	return n_mchain;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x130, %rsp            # imm = 0x130
movq 0x50(%rbp), %rax
movq 0x48(%rbp), %rax
movq 0x40(%rbp), %rax
movq 0x38(%rbp), %rax
movq 0x30(%rbp), %rax
movq 0x28(%rbp), %rax
movq 0x20(%rbp), %rax
movq 0x18(%rbp), %rax
movq 0x10(%rbp), %rax
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movq %r9, -0x38(%rbp)
movss %xmm0, -0x3c(%rbp)
movss %xmm1, -0x40(%rbp)
movss %xmm2, -0x44(%rbp)
movq 0x50(%rbp), %rax
movq $0x0, 0x8(%rax)
movq -0x28(%rbp), %rax
cmpq $0x0, (%rax)
ja 0x29fa68
movl $0x0, -0x4(%rbp)
jmp 0x2a08c4
movq -0x28(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x58(%rbp)
movq $0x0, -0x70(%rbp)
movq $0x0, -0x78(%rbp)
movq $0x0, -0xa0(%rbp)
movq $0x0, -0xa8(%rbp)
movq -0x30(%rbp), %rax
movq (%rax), %rax
movq %rax, -0xb0(%rbp)
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0xc0(%rbp)
movq $0x0, -0xc8(%rbp)
movq $0x0, -0xd0(%rbp)
movq $0x0, -0x50(%rbp)
movq $0x0, -0x60(%rbp)
movq -0x60(%rbp), %rax
cmpq -0x58(%rbp), %rax
jge 0x29fc5d
jmp 0x29faec
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x38(%rbp), %rcx
cmpq 0x10(%rcx), %rax
jne 0x29fb59
movq -0x38(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0x29fb1d
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rax
shlq %rax
movq %rax, -0xd8(%rbp)
jmp 0x29fb2b
movl $0x2, %eax
movq %rax, -0xd8(%rbp)
jmp 0x29fb2b
movq -0xd8(%rbp), %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x38(%rbp), %rax
movq (%rax), %rdi
movq -0x38(%rbp), %rax
imulq $0x1c, 0x10(%rax), %rsi
callq 0x2360
movq %rax, %rcx
movq -0x38(%rbp), %rax
movq %rcx, (%rax)
movq -0x38(%rbp), %rax
movq (%rax), %rax
movq -0x38(%rbp), %rdx
movq 0x8(%rdx), %rcx
movq %rcx, %rsi
addq $0x1, %rsi
movq %rsi, 0x8(%rdx)
imulq $0x1c, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0xa8(%rbp)
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x60(%rbp), %rcx
movq (%rax,%rcx,8), %rax
shrq $0x20, %rax
movl %eax, %ecx
movq -0xa8(%rbp), %rax
movl %ecx, (%rax)
movq -0x50(%rbp), %rax
movl %eax, %ecx
movq -0xa8(%rbp), %rax
movl %ecx, 0x10(%rax)
movq -0x50(%rbp), %rax
movq -0x28(%rbp), %rcx
movq 0x10(%rcx), %rcx
movq -0x60(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
movl %ecx, %ecx
addq %rcx, %rax
movl %eax, %ecx
movq -0xa8(%rbp), %rax
movl %ecx, 0x14(%rax)
movq -0xb0(%rbp), %rax
movq -0xa8(%rbp), %rcx
movl 0x10(%rcx), %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl 0x14(%rax), %ecx
movq -0xa8(%rbp), %rax
movl %ecx, 0x4(%rax)
movq -0xb0(%rbp), %rax
movq -0xa8(%rbp), %rcx
movl 0x14(%rcx), %ecx
subl $0x1, %ecx
movl %ecx, %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl 0x18(%rax), %ecx
movq -0xa8(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0xa8(%rbp), %rax
movl $0x0, 0xc(%rax)
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x60(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movl %eax, %eax
addq -0x50(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x60(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x60(%rbp)
jmp 0x29fadc
movq -0x38(%rbp), %rax
movq (%rax), %rax
movq -0xc0(%rbp), %rdx
leaq (%rdx,%rdx,8), %rcx
leaq (%rcx,%rcx,2), %rcx
addq %rdx, %rcx
addq %rcx, %rax
movq %rax, -0xc8(%rbp)
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rax
movq -0xc0(%rbp), %rcx
subq %rcx, %rax
movq %rax, -0xd0(%rbp)
movq -0xc8(%rbp), %rdi
movq -0xd0(%rbp), %rcx
leaq (%rcx,%rcx,8), %rax
leaq (%rax,%rax,2), %rax
addq %rcx, %rax
movq %rdi, %rsi
addq %rax, %rsi
callq 0x27c310
movq -0xc8(%rbp), %rax
movq -0xd0(%rbp), %rdx
leaq (%rdx,%rdx,8), %rcx
leaq (%rcx,%rcx,2), %rcx
addq %rdx, %rcx
leaq -0x1c(%rax,%rcx), %rax
movq %rax, -0xa0(%rbp)
movq -0xa0(%rbp), %rax
movl 0x4(%rax), %ecx
movl 0x8(%rax), %eax
subl %ecx, %eax
cvtsi2ss %rax, %xmm0
cvtsi2ssq 0x18(%rbp), %xmm1
mulss -0x3c(%rbp), %xmm1
ucomiss %xmm1, %xmm0
jbe 0x29fd24
movq $0x1, -0x70(%rbp)
movq -0xa0(%rbp), %rax
movl $0x1, 0xc(%rax)
movq $0x1, -0x78(%rbp)
cmpq $0x0, -0x70(%rbp)
jne 0x29ff50
movq -0xd0(%rbp), %rax
subq $0x2, %rax
movq %rax, -0x60(%rbp)
cmpq $0x0, -0x60(%rbp)
jl 0x29ff29
movq -0xc8(%rbp), %rax
imulq $0x1c, -0x60(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0xa8(%rbp)
movq -0xa0(%rbp), %rax
movl 0x8(%rax), %eax
movq -0xa8(%rbp), %rcx
cmpl 0x8(%rcx), %eax
ja 0x29fd87
movq -0xa0(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, -0xdc(%rbp)
jmp 0x29fd97
movq -0xa8(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, -0xdc(%rbp)
movl -0xdc(%rbp), %eax
movl %eax, -0xe0(%rbp)
movq -0xa0(%rbp), %rax
movl 0x4(%rax), %eax
movq -0xa8(%rbp), %rcx
cmpl 0x4(%rcx), %eax
jb 0x29fdcb
movq -0xa0(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, -0xe4(%rbp)
jmp 0x29fddb
movq -0xa8(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, -0xe4(%rbp)
movl -0xe0(%rbp), %eax
movl -0xe4(%rbp), %ecx
cmpl %ecx, %eax
jbe 0x29fe81
movq -0xa0(%rbp), %rax
movl 0x8(%rax), %eax
movq -0xa8(%rbp), %rcx
cmpl 0x8(%rcx), %eax
ja 0x29fe17
movq -0xa0(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, -0xe8(%rbp)
jmp 0x29fe27
movq -0xa8(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, -0xe8(%rbp)
movl -0xe8(%rbp), %eax
movl %eax, -0xec(%rbp)
movq -0xa0(%rbp), %rax
movl 0x4(%rax), %eax
movq -0xa8(%rbp), %rcx
cmpl 0x4(%rcx), %eax
jb 0x29fe5b
movq -0xa0(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, -0xf0(%rbp)
jmp 0x29fe6b
movq -0xa8(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, -0xf0(%rbp)
movl -0xec(%rbp), %eax
movl -0xf0(%rbp), %ecx
subl %ecx, %eax
movl %eax, -0xf4(%rbp)
jmp 0x29fe8b
xorl %eax, %eax
movl %eax, -0xf4(%rbp)
jmp 0x29fe8b
movl -0xf4(%rbp), %eax
movl %eax, %eax
movq %rax, -0x90(%rbp)
movq -0xa8(%rbp), %rax
movl 0x4(%rax), %ecx
movl 0x8(%rax), %eax
subl %ecx, %eax
movq -0x90(%rbp), %rcx
subq %rcx, %rax
movq %rax, -0x98(%rbp)
movaps 0xe214f(%rip), %xmm1    # 0x382010
movq -0x98(%rbp), %xmm0
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movapd 0xe214b(%rip), %xmm1    # 0x382020
subpd %xmm1, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movq -0xa0(%rbp), %rax
movl 0x4(%rax), %ecx
movl 0x8(%rax), %eax
subl %ecx, %eax
cvtsi2sd %rax, %xmm1
movsd 0xf0830(%rip), %xmm2    # 0x390730
mulsd %xmm2, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x29ff16
cmpq $0x8, -0x98(%rbp)
jbe 0x29ff16
jmp 0x29ff29
jmp 0x29ff18
movq -0x60(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x60(%rbp)
jmp 0x29fd3e
cmpq $0x0, -0x60(%rbp)
jge 0x29ff4e
movq $0x2, -0x70(%rbp)
movq -0xa0(%rbp), %rax
movl $0x1, 0xc(%rax)
movq $0x1, -0x78(%rbp)
jmp 0x29ff50
cmpq $0x0, -0x70(%rbp)
jne 0x2a03e3
movq -0xa0(%rbp), %rax
movl 0x4(%rax), %ecx
movl 0x8(%rax), %eax
subl %ecx, %eax
cvtsi2ss %rax, %xmm0
cvtsi2ssq 0x18(%rbp), %xmm1
mulss -0x40(%rbp), %xmm1
ucomiss %xmm1, %xmm0
ja 0x29ff9f
movq -0xa0(%rbp), %rax
movl 0x8(%rax), %eax
movq -0xa0(%rbp), %rcx
subl 0x4(%rcx), %eax
movl %eax, %eax
cmpq 0x20(%rbp), %rax
jbe 0x2a03e1
cmpq $0x0, 0x10(%rbp)
je 0x29ffed
cmpq $0x0, -0x38(%rbp)
je 0x29ffed
movq -0x18(%rbp), %rdi
movq -0xc8(%rbp), %rsi
movq -0xd0(%rbp), %rdx
movq -0xb0(%rbp), %rcx
movq -0x38(%rbp), %r8
movq 0x10(%rbp), %r9
movq 0x48(%rbp), %r11
movq 0x18(%rbp), %r10
movq -0x20(%rbp), %rax
movq %r11, (%rsp)
movq %r10, 0x8(%rsp)
movq %rax, 0x10(%rsp)
callq 0x2d7970
movq -0xd0(%rbp), %rax
subq $0x1, %rax
movq %rax, -0x68(%rbp)
movq $0x0, -0x78(%rbp)
cmpq $0x0, -0x68(%rbp)
jl 0x2a03df
movq -0xc8(%rbp), %rax
movq -0x68(%rbp), %rdx
leaq (%rdx,%rdx,8), %rcx
leaq (%rcx,%rcx,2), %rcx
addq %rdx, %rcx
addq %rcx, %rax
movq %rax, -0xa0(%rbp)
movq -0xa0(%rbp), %rax
movl 0x4(%rax), %ecx
movl 0x8(%rax), %eax
subl %ecx, %eax
cvtsi2ss %rax, %xmm1
cvtsi2ssq 0x18(%rbp), %xmm0
mulss -0x40(%rbp), %xmm0
ucomiss %xmm1, %xmm0
jb 0x2a0074
movq -0xa0(%rbp), %rax
movl 0x8(%rax), %eax
movq -0xa0(%rbp), %rcx
subl 0x4(%rcx), %eax
movl %eax, %eax
cmpq 0x20(%rbp), %rax
ja 0x2a0074
jmp 0x2a03df
movq -0xa0(%rbp), %rax
movl 0x8(%rax), %eax
movq -0xa0(%rbp), %rcx
subl 0x4(%rcx), %eax
movl %eax, %eax
movq %rax, -0x80(%rbp)
movq -0xd0(%rbp), %rax
subq $0x1, %rax
movq %rax, -0x60(%rbp)
cmpq $0x0, -0x60(%rbp)
jl 0x2a039f
movq -0x60(%rbp), %rax
cmpq -0x68(%rbp), %rax
jne 0x2a00b7
jmp 0x2a038e
movq -0xc8(%rbp), %rax
imulq $0x1c, -0x60(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0xa8(%rbp)
movq -0xa0(%rbp), %rax
movl 0x8(%rax), %eax
movq -0xa8(%rbp), %rcx
cmpl 0x8(%rcx), %eax
ja 0x2a00f5
movq -0xa0(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, -0xf8(%rbp)
jmp 0x2a0105
movq -0xa8(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, -0xf8(%rbp)
movl -0xf8(%rbp), %eax
movl %eax, -0xfc(%rbp)
movq -0xa0(%rbp), %rax
movl 0x4(%rax), %eax
movq -0xa8(%rbp), %rcx
cmpl 0x4(%rcx), %eax
jb 0x2a0139
movq -0xa0(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, -0x100(%rbp)
jmp 0x2a0149
movq -0xa8(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, -0x100(%rbp)
movl -0xfc(%rbp), %eax
movl -0x100(%rbp), %ecx
cmpl %ecx, %eax
jbe 0x2a01ef
movq -0xa0(%rbp), %rax
movl 0x8(%rax), %eax
movq -0xa8(%rbp), %rcx
cmpl 0x8(%rcx), %eax
ja 0x2a0185
movq -0xa0(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, -0x104(%rbp)
jmp 0x2a0195
movq -0xa8(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, -0x104(%rbp)
movl -0x104(%rbp), %eax
movl %eax, -0x108(%rbp)
movq -0xa0(%rbp), %rax
movl 0x4(%rax), %eax
movq -0xa8(%rbp), %rcx
cmpl 0x4(%rcx), %eax
jb 0x2a01c9
movq -0xa0(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, -0x10c(%rbp)
jmp 0x2a01d9
movq -0xa8(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, -0x10c(%rbp)
movl -0x108(%rbp), %eax
movl -0x10c(%rbp), %ecx
subl %ecx, %eax
movl %eax, -0x110(%rbp)
jmp 0x2a01f9
xorl %eax, %eax
movl %eax, -0x110(%rbp)
jmp 0x2a01f9
movl -0x110(%rbp), %eax
movl %eax, %eax
movq %rax, -0x90(%rbp)
cmpq $0x0, -0x90(%rbp)
jne 0x2a0217
jmp 0x2a038e
movq -0xa8(%rbp), %rax
movl 0x8(%rax), %eax
movq -0xa8(%rbp), %rcx
subl 0x4(%rcx), %eax
movl %eax, %eax
movq %rax, -0x88(%rbp)
movq -0xa8(%rbp), %rax
cmpl $0x1, 0xc(%rax)
jne 0x2a02f5
movq -0x90(%rbp), %xmm0
movaps 0xe1dbc(%rip), %xmm3    # 0x382010
punpckldq %xmm3, %xmm0    # xmm0 = xmm0[0],xmm3[0],xmm0[1],xmm3[1]
movapd 0xe1dc0(%rip), %xmm2    # 0x382020
subpd %xmm2, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movq -0x88(%rbp), %xmm1
punpckldq %xmm3, %xmm1    # xmm1 = xmm1[0],xmm3[0],xmm1[1],xmm3[1]
subpd %xmm2, %xmm1
movaps %xmm1, %xmm2
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
addsd %xmm2, %xmm1
movsd 0xded86(%rip), %xmm2    # 0x37f018
mulsd %xmm2, %xmm1
ucomisd %xmm1, %xmm0
ja 0x2a02f0
movq -0x90(%rbp), %xmm0
movaps 0xe1d65(%rip), %xmm3    # 0x382010
punpckldq %xmm3, %xmm0    # xmm0 = xmm0[0],xmm3[0],xmm0[1],xmm3[1]
movapd 0xe1d69(%rip), %xmm2    # 0x382020
subpd %xmm2, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movq -0x80(%rbp), %xmm1
punpckldq %xmm3, %xmm1    # xmm1 = xmm1[0],xmm3[0],xmm1[1],xmm3[1]
subpd %xmm2, %xmm1
movaps %xmm1, %xmm2
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
addsd %xmm2, %xmm1
movsd 0xded32(%rip), %xmm2    # 0x37f018
mulsd %xmm2, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x2a02f5
jmp 0x2a039f
movq -0x88(%rbp), %rax
cmpq -0x80(%rbp), %rax
jbe 0x2a030d
movq -0x80(%rbp), %rax
movq %rax, -0x88(%rbp)
movq -0x90(%rbp), %xmm0
movaps 0xe1cf4(%rip), %xmm3    # 0x382010
punpckldq %xmm3, %xmm0    # xmm0 = xmm0[0],xmm3[0],xmm0[1],xmm3[1]
movapd 0xe1cf8(%rip), %xmm2    # 0x382020
subpd %xmm2, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movq -0x88(%rbp), %xmm1
punpckldq %xmm3, %xmm1    # xmm1 = xmm1[0],xmm3[0],xmm1[1],xmm3[1]
subpd %xmm2, %xmm1
movaps %xmm1, %xmm2
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
addsd %xmm2, %xmm1
movsd 0xdecbe(%rip), %xmm2    # 0x37f018
mulsd %xmm2, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x2a038c
movq -0xa8(%rbp), %rax
movl (%rax), %eax
cvtsi2ss %rax, %xmm0
movq -0xa0(%rbp), %rax
movl (%rax), %eax
cvtsi2ss %rax, %xmm1
mulss -0x44(%rbp), %xmm1
ucomiss %xmm1, %xmm0
jbe 0x2a038c
jmp 0x2a039f
jmp 0x2a038e
movq -0x60(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x60(%rbp)
jmp 0x2a009d
cmpq $0x0, -0x60(%rbp)
jge 0x2a03ca
movq $0x3, -0x70(%rbp)
movq -0xa0(%rbp), %rax
movl $0x1, 0xc(%rax)
movq -0x78(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x78(%rbp)
jmp 0x2a03cc
jmp 0x2a03df
jmp 0x2a03ce
movq -0x68(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x68(%rbp)
jmp 0x2a0004
jmp 0x2a03e1
jmp 0x2a03e3
cmpq $0x0, -0x70(%rbp)
je 0x2a08ae
movq 0x50(%rbp), %rax
movq $0x0, 0x8(%rax)
movq -0xd0(%rbp), %rax
subq -0x78(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rax
cmpq -0xd0(%rbp), %rax
jge 0x2a08ac
jmp 0x2a041c
movq 0x50(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x50(%rbp), %rcx
cmpq 0x10(%rcx), %rax
jne 0x2a0489
movq 0x50(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0x2a044d
movq 0x50(%rbp), %rax
movq 0x10(%rax), %rax
shlq %rax
movq %rax, -0x118(%rbp)
jmp 0x2a045b
movl $0x2, %eax
movq %rax, -0x118(%rbp)
jmp 0x2a045b
movq -0x118(%rbp), %rcx
movq 0x50(%rbp), %rax
movq %rcx, 0x10(%rax)
movq 0x50(%rbp), %rax
movq (%rax), %rdi
movq 0x50(%rbp), %rax
imulq $0x28, 0x10(%rax), %rsi
callq 0x2360
movq %rax, %rcx
movq 0x50(%rbp), %rax
movq %rcx, (%rax)
movq 0x50(%rbp), %rax
movq (%rax), %rax
movq 0x50(%rbp), %rdx
movq 0x8(%rdx), %rcx
movq %rcx, %rsi
addq $0x1, %rsi
movq %rsi, 0x8(%rdx)
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0xb8(%rbp)
movq -0xb8(%rbp), %rax
movl $0xffffffff, 0x8(%rax)  # imm = 0xFFFFFFFF
movq -0xc8(%rbp), %rax
imulq $0x1c, -0x68(%rbp), %rcx
addq %rcx, %rax
movl 0x4(%rax), %ecx
movq -0xb8(%rbp), %rax
movl %ecx, 0x14(%rax)
movq -0xc8(%rbp), %rax
imulq $0x1c, -0x68(%rbp), %rcx
addq %rcx, %rax
movl 0x8(%rax), %ecx
movq -0xb8(%rbp), %rax
movl %ecx, 0x18(%rax)
movq -0xc8(%rbp), %rax
imulq $0x1c, -0x68(%rbp), %rcx
addq %rcx, %rax
movl 0x10(%rax), %ecx
movq -0xb8(%rbp), %rax
movl %ecx, 0xc(%rax)
movq -0xc8(%rbp), %rax
imulq $0x1c, -0x68(%rbp), %rcx
addq %rcx, %rax
movl 0x14(%rax), %ecx
movq -0xb8(%rbp), %rax
movl %ecx, 0x10(%rax)
movq -0xb8(%rbp), %rax
movl $0x0, (%rax)
movq -0xb8(%rbp), %rax
movl 0x4(%rax), %ecx
andl $0x80000000, %ecx       # imm = 0x80000000
orl $0x0, %ecx
movl %ecx, 0x4(%rax)
movq -0x10(%rbp), %rdi
movq -0xb0(%rbp), %rsi
movq -0xb8(%rbp), %rax
movslq 0xc(%rax), %rax
imulq $0x28, %rax, %rax
addq %rax, %rsi
movq -0xb8(%rbp), %rax
movl 0x10(%rax), %eax
movq -0xb8(%rbp), %rcx
subl 0xc(%rcx), %eax
movslq %eax, %rdx
movq 0x28(%rbp), %rcx
movq 0x30(%rbp), %r8
movq 0x38(%rbp), %r9
movq 0x40(%rbp), %rax
movq %rax, (%rsp)
callq 0x2a98b0
movq 0x50(%rbp), %rax
movq 0x10(%rax), %rax
movq 0x50(%rbp), %rcx
movq 0x8(%rcx), %rcx
movq 0x40(%rbp), %rdx
addq 0x8(%rdx), %rcx
cmpq %rcx, %rax
jae 0x2a068e
movq 0x50(%rbp), %rax
movq 0x8(%rax), %rcx
movq 0x40(%rbp), %rax
addq 0x8(%rax), %rcx
movq 0x50(%rbp), %rax
movq %rcx, 0x10(%rax)
movq 0x50(%rbp), %rax
movq 0x10(%rax), %rcx
addq $-0x1, %rcx
movq %rcx, 0x10(%rax)
movq 0x50(%rbp), %rax
movq 0x10(%rax), %rcx
shrq %rcx
movq 0x50(%rbp), %rax
orq 0x10(%rax), %rcx
movq %rcx, 0x10(%rax)
movq 0x50(%rbp), %rax
movq 0x10(%rax), %rcx
shrq $0x2, %rcx
movq 0x50(%rbp), %rax
orq 0x10(%rax), %rcx
movq %rcx, 0x10(%rax)
movq 0x50(%rbp), %rax
movq 0x10(%rax), %rcx
shrq $0x4, %rcx
movq 0x50(%rbp), %rax
orq 0x10(%rax), %rcx
movq %rcx, 0x10(%rax)
movq 0x50(%rbp), %rax
movq 0x10(%rax), %rcx
shrq $0x8, %rcx
movq 0x50(%rbp), %rax
orq 0x10(%rax), %rcx
movq %rcx, 0x10(%rax)
movq 0x50(%rbp), %rax
movq 0x10(%rax), %rcx
shrq $0x10, %rcx
movq 0x50(%rbp), %rax
orq 0x10(%rax), %rcx
movq %rcx, 0x10(%rax)
movq 0x50(%rbp), %rax
movq 0x10(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x10(%rax)
movq 0x50(%rbp), %rax
movq (%rax), %rdi
movq 0x50(%rbp), %rax
imulq $0x28, 0x10(%rax), %rsi
callq 0x2360
movq %rax, %rcx
movq 0x50(%rbp), %rax
movq %rcx, (%rax)
jmp 0x2a0690
movq $0x0, -0x60(%rbp)
movq 0x50(%rbp), %rax
movq (%rax), %rax
movq 0x50(%rbp), %rcx
movq 0x8(%rcx), %rcx
subq $0x1, %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0xb8(%rbp)
movq -0x60(%rbp), %rax
movq 0x40(%rbp), %rcx
cmpq 0x8(%rcx), %rax
jge 0x2a0862
movq 0x40(%rbp), %rax
movq (%rax), %rax
imulq $0xc, -0x60(%rbp), %rcx
addq %rcx, %rax
cmpl $-0x1, (%rax)
jne 0x2a0767
movq -0xb0(%rbp), %rsi
movq 0x40(%rbp), %rax
movq (%rax), %rax
imulq $0xc, -0x60(%rbp), %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
movq -0xb8(%rbp), %rcx
addl 0xc(%rcx), %eax
cltq
imulq $0x28, %rax, %rax
addq %rax, %rsi
movq 0x50(%rbp), %rax
movq (%rax), %rdi
movq -0x60(%rbp), %rax
movq 0x50(%rbp), %rcx
addq 0x8(%rcx), %rax
imulq $0x28, %rax, %rax
addq %rax, %rdi
movl $0x28, %edx
callq 0x2180
movq 0x40(%rbp), %rax
movq (%rax), %rax
imulq $0xc, -0x60(%rbp), %rcx
addq %rcx, %rax
movl 0x4(%rax), %ecx
movq 0x50(%rbp), %rax
movq (%rax), %rax
movq -0x60(%rbp), %rdx
movq 0x50(%rbp), %rsi
addq 0x8(%rsi), %rdx
imulq $0x28, %rdx, %rdx
addq %rdx, %rax
movl %ecx, 0x20(%rax)
jmp 0x2a084f
movq 0x40(%rbp), %rax
movq (%rax), %rax
imulq $0xc, -0x60(%rbp), %rcx
addq %rcx, %rax
movl (%rax), %ecx
movq 0x50(%rbp), %rax
movq (%rax), %rax
movq -0x60(%rbp), %rdx
movq 0x50(%rbp), %rsi
addq 0x8(%rsi), %rdx
imulq $0x28, %rdx, %rdx
addq %rdx, %rax
movl %ecx, 0x8(%rax)
movq 0x50(%rbp), %rax
movq (%rax), %rax
movq -0x60(%rbp), %rcx
movq 0x50(%rbp), %rdx
addq 0x8(%rdx), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl $0xffffffff, (%rax)     # imm = 0xFFFFFFFF
movq 0x40(%rbp), %rax
movq (%rax), %rax
imulq $0xc, -0x60(%rbp), %rcx
addq %rcx, %rax
movl 0x4(%rax), %ecx
movq 0x50(%rbp), %rax
movq (%rax), %rax
movq -0x60(%rbp), %rdx
movq 0x50(%rbp), %rsi
addq 0x8(%rsi), %rdx
imulq $0x28, %rdx, %rdx
addq %rdx, %rax
movl %ecx, 0x20(%rax)
movq 0x50(%rbp), %rax
movq (%rax), %rax
movq -0x60(%rbp), %rcx
movq 0x50(%rbp), %rdx
addq 0x8(%rdx), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl $0x0, 0xc(%rax)
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq 0x18(%rax), %rax
movq 0x20(%rax), %rax
movq 0x40(%rbp), %rcx
movq (%rcx), %rcx
imulq $0xc, -0x60(%rbp), %rdx
addq %rdx, %rcx
movl (%rcx), %ecx
shrl %ecx
movl %ecx, %ecx
movl (%rax,%rcx,8), %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
movq 0x50(%rbp), %rax
movq (%rax), %rax
movq -0x60(%rbp), %rdx
movq 0x50(%rbp), %rsi
addq 0x8(%rsi), %rdx
imulq $0x28, %rdx, %rdx
addq %rdx, %rax
movl %ecx, 0x10(%rax)
jmp 0x2a0851
movq -0x60(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x60(%rbp)
jmp 0x2a06b9
movq 0x40(%rbp), %rax
movq 0x8(%rax), %rax
movl %eax, %edx
movq -0xb8(%rbp), %rax
movl 0x4(%rax), %ecx
andl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
andl $0x80000000, %ecx       # imm = 0x80000000
orl %edx, %ecx
movl %ecx, 0x4(%rax)
movq 0x40(%rbp), %rax
movq 0x8(%rax), %rcx
movq 0x50(%rbp), %rax
addq 0x8(%rax), %rcx
movq %rcx, 0x8(%rax)
movq -0x68(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x68(%rbp)
jmp 0x2a0409
jmp 0x2a08ae
movq -0xc0(%rbp), %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x78(%rbp), %rax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x130, %rsp            # imm = 0x130
popq %rbp
retq