// File: chhylp123[P]hifiasm/inter.cpp
// Function: gen_max_gchain(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, asg_t const*, st_mt_t*, vec_sp_node_t*, vec_mg_pathv_t*, unsigned long*, long, double)
uint32_t gen_max_gchain(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, const asg_t *g, st_mt_t *dst_done, 
vec_sp_node_t *out, vec_mg_pathv_t *res, uint64_t *b, int64_t bw, double diff_ec_ul)
{
	if(idx->n <= 0) return 0;
	int64_t a_n, idx_n = idx->n, i, m_sc = 0, is_done = 0; uint64_t s_idx, e_idx, om, ok, ovlp, novlp; 
	ul_ov_t m; memset(&m, 0, sizeof(m)); m_sc = -1; mg_lchain_t *a = e->a;
	for (i = a_n = 0; i < idx_n; ++i) {
		if(((int64_t)(idx->a[i]>>32)) > m_sc) {
			m_sc = ((int64_t)(idx->a[i]>>32)); m.qn = i;
			m.ts = a_n; m.te = a_n + ((uint32_t)idx->a[i]);
			m.qs = a[m.ts].qs; m.qe = a[m.te-1].qe;
		}
		// dedup_second_chain(NULL, 0, a_n, a_n + ((uint32_t)idx->a[i]), a, raw_idx, raw_chn);
		a_n += ((uint32_t)idx->a[i]);
	}
	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;
	if(is_done == 0) {
		// for (i = a_n = 0; i < idx_n; ++i) {
		// 	s_idx = a[a_n].qs; a_n += ((uint32_t)idx->a[i]); e_idx = a[a_n-1].qe;
		// 	if(i == m.qn) continue;
		// 	if(s_idx < m.qs || e_idx < m.qs || s_idx > m.qe || e_idx > m.qe) break;
		// }
		// if(i >= idx_n) is_done = 2;///no alignment that is on the left or the right side of the primary chain
		for (i = a_n = 0; i < idx_n; ++i) {
			s_idx = a[a_n].qs; a_n += ((uint32_t)idx->a[i]); e_idx = a[a_n-1].qe;
			if(i == m.qn) continue;
			ovlp = ((MIN(m.qe, e_idx) > MAX(m.qs, s_idx))? (MIN(m.qe, e_idx) - MAX(m.qs, s_idx)):0);
			novlp = (e_idx - s_idx) - ovlp;
			if(novlp > ((m.qe-m.qs)*GC_OFFSET_RATE) && novlp > GC_OFFSET_POS) break;
		}
		if(i >= idx_n) is_done = 2;///no alignment that is on the left or the right side of the primary chain
	}

	if(is_done == 0) {
		if((m.qe - m.qs) > (qlen*primary_fragment_cov_rate)) {
			dedup_second_chain(uref, idx->a, idx_n, m.ts, m.te, a, raw_idx, raw_chn, b, bw, diff_ec_ul, qlen);

			om = m.qe - m.qs;
			for (i = a_n = 0; i < idx_n; ++i) {
				s_idx = a[a_n].qs; a_n += ((uint32_t)idx->a[i]); e_idx = a[a_n-1].qe;
				if(i == m.qn) continue;
				ovlp = ((MIN(m.qe, e_idx) > MAX(m.qs, s_idx))? (MIN(m.qe, e_idx) - MAX(m.qs, s_idx)):0);
				if(ovlp == 0) continue;
				ok = e_idx - s_idx;
				if(ok > om) ok = om;
				if((ovlp > ok*0.1) && ((int64_t)(idx->a[i]>>32)) > (m_sc*primary_fragment_second_score_rate)) break;
			}
			if(i >= idx_n) is_done = 3;
		}
	}

	if(is_done && gen_gchain_track(km, a + m.ts, m.te - m.ts, g, dst_done, out, res)) {///try to find a path
		for (i = m.ts, e->n = 0; i < (int64_t)m.te; i++) a[e->n++] = a[i];
		// fprintf(stderr, "--[M::%s::id->%ld] [%u, %u), res->n:%lu\n", __func__, ulid, m.qs, m.qe, (uint64_t)res->n);
		kv_resize(mg_lchain_t, *e, res->n); a = e->a;
		for (i = ((int64_t)res->n)-1; i >= 0; i--) {
			
			if(res->a[i].v == (uint32_t)-1) {
				a[i] = a[res->a[i].pre]; a[i].dist_pre = res->a[i].d;
				// fprintf(stderr, "ulid:%ld\t%u\t%u\t%c\tutg%.6dl\t%u\t%u\tdist_pre:%d\n", ulid, a[i].qs, a[i].qe, "+-"[a[i].v&1], (int32_t)(a[i].v>>1)+1, a[i].rs, a[i].re, a[i].dist_pre);
			}
			else {
				a[i].v = res->a[i].v; a[i].off = -1; a[i].dist_pre = res->a[i].d;
				// fprintf(stderr, "ulid:%ld\t*\t*\t%c\tutg%.6dl\t*\t*\tdist_pre:%d\n", ulid, "+-"[a[i].v&1], (int32_t)(a[i].v>>1)+1, a[i].dist_pre);
			}
		}
		e->n = res->n;

		


		// debug_gchain(km, g, e->a, e->n, dst_done, out);


		return 1;
	}

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x170, %rsp            # imm = 0x170
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, -0x20(%rbp)
movq %rsi, -0x28(%rbp)
movq %rdx, -0x30(%rbp)
movq %rcx, -0x38(%rbp)
movq %r8, -0x40(%rbp)
movq %r9, -0x48(%rbp)
movss %xmm0, -0x4c(%rbp)
movss %xmm1, -0x50(%rbp)
movss %xmm2, -0x54(%rbp)
movsd %xmm3, -0x60(%rbp)
movq -0x38(%rbp), %rax
cmpq $0x0, (%rax)
ja 0x2d6c80
movl $0x0, -0x14(%rbp)
jmp 0x2d76e4
movq -0x38(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x70(%rbp)
movq $0x0, -0x80(%rbp)
movq $0x0, -0x88(%rbp)
leaq -0xd4(%rbp), %rdi
xorl %esi, %esi
movl $0x1c, %edx
callq 0x2100
movq $-0x1, -0x80(%rbp)
movq -0x40(%rbp), %rax
movq (%rax), %rax
movq %rax, -0xe0(%rbp)
movq $0x0, -0x68(%rbp)
movq $0x0, -0x78(%rbp)
movq -0x78(%rbp), %rax
cmpq -0x70(%rbp), %rax
jge 0x2d6db8
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x78(%rbp), %rcx
movq (%rax,%rcx,8), %rax
shrq $0x20, %rax
cmpq -0x80(%rbp), %rax
jle 0x2d6d8d
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x78(%rbp), %rcx
movq (%rax,%rcx,8), %rax
shrq $0x20, %rax
movq %rax, -0x80(%rbp)
movq -0x78(%rbp), %rax
movl %eax, -0xd4(%rbp)
movq -0x68(%rbp), %rax
movl %eax, -0xc4(%rbp)
movq -0x68(%rbp), %rax
movq -0x38(%rbp), %rcx
movq 0x10(%rcx), %rcx
movq -0x78(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
movl %ecx, %ecx
addq %rcx, %rax
movl %eax, -0xc0(%rbp)
movq -0xe0(%rbp), %rax
movl -0xc4(%rbp), %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl 0x14(%rax), %eax
movl %eax, -0xd0(%rbp)
movq -0xe0(%rbp), %rax
movl -0xc0(%rbp), %ecx
subl $0x1, %ecx
movl %ecx, %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl 0x18(%rax), %eax
movl %eax, -0xcc(%rbp)
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x78(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movl %eax, %eax
addq -0x68(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x78(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x78(%rbp)
jmp 0x2d6cd7
movq -0xe0(%rbp), %rax
movl -0xc4(%rbp), %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl 0x14(%rax), %ecx
movq -0xe0(%rbp), %rdx
movl -0xc0(%rbp), %eax
subl $0x1, %eax
movl %eax, %eax
imulq $0x28, %rax, %rax
addq %rax, %rdx
xorl %eax, %eax
cmpl 0x14(%rdx), %ecx
movb %al, -0xe1(%rbp)
jg 0x2d6e31
movq -0xe0(%rbp), %rax
movl -0xc0(%rbp), %ecx
subl $0x1, %ecx
movl %ecx, %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl 0x18(%rax), %eax
movq -0xe0(%rbp), %rcx
movl -0xc4(%rbp), %edx
imulq $0x28, %rdx, %rdx
addq %rdx, %rcx
cmpl 0x18(%rcx), %eax
setge %al
movb %al, -0xe1(%rbp)
movb -0xe1(%rbp), %al
testb $0x1, %al
jne 0x2d6e3d
jmp 0x2d6e3f
jmp 0x2d6e5e
leaq 0xbafb0(%rip), %rdi     # 0x391df6
leaq 0xb99e2(%rip), %rsi     # 0x39082f
movl $0x3a77, %edx           # imm = 0x3A77
leaq 0xbc899(%rip), %rcx     # 0x3936f2
callq 0x2130
movl -0xd0(%rbp), %ecx
movl -0xcc(%rbp), %eax
subl %ecx, %eax
cvtsi2ss %rax, %xmm0
cvtsi2ssq 0x18(%rbp), %xmm1
mulss -0x4c(%rbp), %xmm1
ucomiss %xmm1, %xmm0
jbe 0x2d6e8c
movq $0x1, -0x88(%rbp)
cmpq $0x0, -0x88(%rbp)
jne 0x2d70de
movq $0x0, -0x68(%rbp)
movq $0x0, -0x78(%rbp)
movq -0x78(%rbp), %rax
cmpq -0x70(%rbp), %rax
jge 0x2d70c7
movq -0xe0(%rbp), %rax
imulq $0x28, -0x68(%rbp), %rcx
addq %rcx, %rax
movslq 0x14(%rax), %rax
movq %rax, -0x90(%rbp)
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x78(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movl %eax, %eax
addq -0x68(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0xe0(%rbp), %rax
movq -0x68(%rbp), %rcx
subq $0x1, %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movslq 0x18(%rax), %rax
movq %rax, -0x98(%rbp)
movq -0x78(%rbp), %rax
movl -0xd4(%rbp), %ecx
cmpq %rcx, %rax
jne 0x2d6f21
jmp 0x2d70b6
movl -0xcc(%rbp), %eax
cmpq -0x98(%rbp), %rax
ja 0x2d6f3f
movl -0xcc(%rbp), %eax
movq %rax, -0xf0(%rbp)
jmp 0x2d6f4d
movq -0x98(%rbp), %rax
movq %rax, -0xf0(%rbp)
movq -0xf0(%rbp), %rax
movq %rax, -0xf8(%rbp)
movl -0xd0(%rbp), %eax
cmpq -0x90(%rbp), %rax
jb 0x2d6f79
movl -0xd0(%rbp), %eax
movq %rax, -0x100(%rbp)
jmp 0x2d6f87
movq -0x90(%rbp), %rax
movq %rax, -0x100(%rbp)
movq -0xf8(%rbp), %rax
movq -0x100(%rbp), %rcx
cmpq %rcx, %rax
jbe 0x2d701e
movl -0xcc(%rbp), %eax
cmpq -0x98(%rbp), %rax
ja 0x2d6fbc
movl -0xcc(%rbp), %eax
movq %rax, -0x108(%rbp)
jmp 0x2d6fca
movq -0x98(%rbp), %rax
movq %rax, -0x108(%rbp)
movq -0x108(%rbp), %rax
movq %rax, -0x110(%rbp)
movl -0xd0(%rbp), %eax
cmpq -0x90(%rbp), %rax
jb 0x2d6ff6
movl -0xd0(%rbp), %eax
movq %rax, -0x118(%rbp)
jmp 0x2d7004
movq -0x90(%rbp), %rax
movq %rax, -0x118(%rbp)
movq -0x110(%rbp), %rax
movq -0x118(%rbp), %rcx
subq %rcx, %rax
movq %rax, -0x120(%rbp)
jmp 0x2d7029
xorl %eax, %eax
movq %rax, -0x120(%rbp)
jmp 0x2d7029
movq -0x120(%rbp), %rax
movq %rax, -0xb0(%rbp)
movq -0x98(%rbp), %rax
movq -0x90(%rbp), %rcx
subq %rcx, %rax
movq -0xb0(%rbp), %rcx
subq %rcx, %rax
movq %rax, -0xb8(%rbp)
movaps 0xaafb0(%rip), %xmm1    # 0x382010
movq -0xb8(%rbp), %xmm0
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movapd 0xaafac(%rip), %xmm1    # 0x382020
subpd %xmm1, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movl -0xd0(%rbp), %ecx
movl -0xcc(%rbp), %eax
subl %ecx, %eax
cvtsi2sd %rax, %xmm1
movsd 0xb9692(%rip), %xmm2    # 0x390730
mulsd %xmm2, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x2d70b4
cmpq $0x8, -0xb8(%rbp)
jbe 0x2d70b4
jmp 0x2d70c7
jmp 0x2d70b6
movq -0x78(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x78(%rbp)
jmp 0x2d6eaa
movq -0x78(%rbp), %rax
cmpq -0x70(%rbp), %rax
jl 0x2d70dc
movq $0x2, -0x88(%rbp)
jmp 0x2d70de
cmpq $0x0, -0x88(%rbp)
jne 0x2d7413
movl -0xd0(%rbp), %ecx
movl -0xcc(%rbp), %eax
subl %ecx, %eax
cvtsi2ss %rax, %xmm0
cvtsi2ssq 0x18(%rbp), %xmm1
mulss -0x50(%rbp), %xmm1
ucomiss %xmm1, %xmm0
jbe 0x2d7411
movq -0x28(%rbp), %rdi
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rsi
movq -0x70(%rbp), %rdx
movl -0xc4(%rbp), %eax
movl %eax, %ecx
movl -0xc0(%rbp), %eax
movl %eax, %r8d
movq -0xe0(%rbp), %r9
movq -0x48(%rbp), %r14
movq 0x10(%rbp), %rbx
movq 0x40(%rbp), %r11
movq 0x48(%rbp), %r10
movsd -0x60(%rbp), %xmm0
movq 0x18(%rbp), %rax
movq %r14, (%rsp)
movq %rbx, 0x8(%rsp)
movq %r11, 0x10(%rsp)
movq %r10, 0x18(%rsp)
movq %rax, 0x20(%rsp)
callq 0x2d6070
movl -0xcc(%rbp), %eax
subl -0xd0(%rbp), %eax
movl %eax, %eax
movq %rax, -0xa0(%rbp)
movq $0x0, -0x68(%rbp)
movq $0x0, -0x78(%rbp)
movq -0x78(%rbp), %rax
cmpq -0x70(%rbp), %rax
jge 0x2d73fa
movq -0xe0(%rbp), %rax
imulq $0x28, -0x68(%rbp), %rcx
addq %rcx, %rax
movslq 0x14(%rax), %rax
movq %rax, -0x90(%rbp)
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x78(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movl %eax, %eax
addq -0x68(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0xe0(%rbp), %rax
movq -0x68(%rbp), %rcx
subq $0x1, %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movslq 0x18(%rax), %rax
movq %rax, -0x98(%rbp)
movq -0x78(%rbp), %rax
movl -0xd4(%rbp), %ecx
cmpq %rcx, %rax
jne 0x2d720d
jmp 0x2d73e9
movl -0xcc(%rbp), %eax
cmpq -0x98(%rbp), %rax
ja 0x2d722b
movl -0xcc(%rbp), %eax
movq %rax, -0x128(%rbp)
jmp 0x2d7239
movq -0x98(%rbp), %rax
movq %rax, -0x128(%rbp)
movq -0x128(%rbp), %rax
movq %rax, -0x130(%rbp)
movl -0xd0(%rbp), %eax
cmpq -0x90(%rbp), %rax
jb 0x2d7265
movl -0xd0(%rbp), %eax
movq %rax, -0x138(%rbp)
jmp 0x2d7273
movq -0x90(%rbp), %rax
movq %rax, -0x138(%rbp)
movq -0x130(%rbp), %rax
movq -0x138(%rbp), %rcx
cmpq %rcx, %rax
jbe 0x2d730a
movl -0xcc(%rbp), %eax
cmpq -0x98(%rbp), %rax
ja 0x2d72a8
movl -0xcc(%rbp), %eax
movq %rax, -0x140(%rbp)
jmp 0x2d72b6
movq -0x98(%rbp), %rax
movq %rax, -0x140(%rbp)
movq -0x140(%rbp), %rax
movq %rax, -0x148(%rbp)
movl -0xd0(%rbp), %eax
cmpq -0x90(%rbp), %rax
jb 0x2d72e2
movl -0xd0(%rbp), %eax
movq %rax, -0x150(%rbp)
jmp 0x2d72f0
movq -0x90(%rbp), %rax
movq %rax, -0x150(%rbp)
movq -0x148(%rbp), %rax
movq -0x150(%rbp), %rcx
subq %rcx, %rax
movq %rax, -0x158(%rbp)
jmp 0x2d7315
xorl %eax, %eax
movq %rax, -0x158(%rbp)
jmp 0x2d7315
movq -0x158(%rbp), %rax
movq %rax, -0xb0(%rbp)
cmpq $0x0, -0xb0(%rbp)
jne 0x2d7332
jmp 0x2d73e9
movq -0x98(%rbp), %rax
subq -0x90(%rbp), %rax
movq %rax, -0xa8(%rbp)
movq -0xa8(%rbp), %rax
cmpq -0xa0(%rbp), %rax
jbe 0x2d7365
movq -0xa0(%rbp), %rax
movq %rax, -0xa8(%rbp)
movq -0xb0(%rbp), %xmm0
movaps 0xaac9c(%rip), %xmm3    # 0x382010
punpckldq %xmm3, %xmm0    # xmm0 = xmm0[0],xmm3[0],xmm0[1],xmm3[1]
movapd 0xaaca0(%rip), %xmm2    # 0x382020
subpd %xmm2, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movq -0xa8(%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 0xa7c66(%rip), %xmm2    # 0x37f018
mulsd %xmm2, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x2d73e7
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x78(%rbp), %rcx
movq (%rax,%rcx,8), %rax
shrq $0x20, %rax
cvtsi2ss %rax, %xmm0
cvtsi2ssq -0x80(%rbp), %xmm1
mulss -0x54(%rbp), %xmm1
ucomiss %xmm1, %xmm0
jbe 0x2d73e7
jmp 0x2d73fa
jmp 0x2d73e9
movq -0x78(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x78(%rbp)
jmp 0x2d7196
movq -0x78(%rbp), %rax
cmpq -0x70(%rbp), %rax
jl 0x2d740f
movq $0x3, -0x88(%rbp)
jmp 0x2d7411
jmp 0x2d7413
cmpq $0x0, -0x88(%rbp)
je 0x2d76dd
movq -0x20(%rbp), %rdi
movq -0xe0(%rbp), %rsi
movl -0xc4(%rbp), %eax
imulq $0x28, %rax, %rax
addq %rax, %rsi
movl -0xc0(%rbp), %eax
subl -0xc4(%rbp), %eax
movl %eax, %eax
movl %eax, %edx
movq 0x20(%rbp), %rcx
movq 0x28(%rbp), %r8
movq 0x30(%rbp), %r9
movq 0x38(%rbp), %rax
movq %rax, (%rsp)
callq 0x2a98b0
cmpl $0x0, %eax
je 0x2d76dd
movl -0xc4(%rbp), %eax
movq %rax, -0x78(%rbp)
movq -0x40(%rbp), %rax
movq $0x0, 0x8(%rax)
movq -0x78(%rbp), %rax
movl -0xc0(%rbp), %ecx
cmpq %rcx, %rax
jge 0x2d74d8
movq -0xe0(%rbp), %rsi
imulq $0x28, -0x78(%rbp), %rax
addq %rax, %rsi
movq -0xe0(%rbp), %rdi
movq -0x40(%rbp), %rcx
movq 0x8(%rcx), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, 0x8(%rcx)
imulq $0x28, %rax, %rax
addq %rax, %rdi
movl $0x28, %edx
callq 0x2180
movq -0x78(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x78(%rbp)
jmp 0x2d7481
jmp 0x2d74da
movq -0x40(%rbp), %rax
movq 0x10(%rax), %rax
movq 0x38(%rbp), %rcx
cmpq 0x8(%rcx), %rax
jae 0x2d75b6
movq 0x38(%rbp), %rax
movq 0x8(%rax), %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x40(%rbp), %rax
movq 0x10(%rax), %rcx
addq $-0x1, %rcx
movq %rcx, 0x10(%rax)
movq -0x40(%rbp), %rax
movq 0x10(%rax), %rcx
shrq %rcx
movq -0x40(%rbp), %rax
orq 0x10(%rax), %rcx
movq %rcx, 0x10(%rax)
movq -0x40(%rbp), %rax
movq 0x10(%rax), %rcx
shrq $0x2, %rcx
movq -0x40(%rbp), %rax
orq 0x10(%rax), %rcx
movq %rcx, 0x10(%rax)
movq -0x40(%rbp), %rax
movq 0x10(%rax), %rcx
shrq $0x4, %rcx
movq -0x40(%rbp), %rax
orq 0x10(%rax), %rcx
movq %rcx, 0x10(%rax)
movq -0x40(%rbp), %rax
movq 0x10(%rax), %rcx
shrq $0x8, %rcx
movq -0x40(%rbp), %rax
orq 0x10(%rax), %rcx
movq %rcx, 0x10(%rax)
movq -0x40(%rbp), %rax
movq 0x10(%rax), %rcx
shrq $0x10, %rcx
movq -0x40(%rbp), %rax
orq 0x10(%rax), %rcx
movq %rcx, 0x10(%rax)
movq -0x40(%rbp), %rax
movq 0x10(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x10(%rax)
movq -0x40(%rbp), %rax
movq (%rax), %rdi
movq -0x40(%rbp), %rax
imulq $0x28, 0x10(%rax), %rsi
callq 0x2360
movq %rax, %rcx
movq -0x40(%rbp), %rax
movq %rcx, (%rax)
jmp 0x2d75b8
movq -0x40(%rbp), %rax
movq (%rax), %rax
movq %rax, -0xe0(%rbp)
movq 0x38(%rbp), %rax
movq 0x8(%rax), %rax
subq $0x1, %rax
movq %rax, -0x78(%rbp)
cmpq $0x0, -0x78(%rbp)
jl 0x2d76c4
movq 0x38(%rbp), %rax
movq (%rax), %rax
imulq $0xc, -0x78(%rbp), %rcx
addq %rcx, %rax
cmpl $-0x1, (%rax)
jne 0x2d7655
movq -0xe0(%rbp), %rsi
movq 0x38(%rbp), %rax
movq (%rax), %rax
imulq $0xc, -0x78(%rbp), %rcx
addq %rcx, %rax
movslq 0x8(%rax), %rax
imulq $0x28, %rax, %rax
addq %rax, %rsi
movq -0xe0(%rbp), %rdi
imulq $0x28, -0x78(%rbp), %rax
addq %rax, %rdi
movl $0x28, %edx
callq 0x2180
movq 0x38(%rbp), %rax
movq (%rax), %rax
imulq $0xc, -0x78(%rbp), %rcx
addq %rcx, %rax
movl 0x4(%rax), %ecx
movq -0xe0(%rbp), %rax
imulq $0x28, -0x78(%rbp), %rdx
addq %rdx, %rax
movl %ecx, 0x20(%rax)
jmp 0x2d76b1
movq 0x38(%rbp), %rax
movq (%rax), %rax
imulq $0xc, -0x78(%rbp), %rcx
addq %rcx, %rax
movl (%rax), %ecx
movq -0xe0(%rbp), %rax
imulq $0x28, -0x78(%rbp), %rdx
addq %rdx, %rax
movl %ecx, 0x8(%rax)
movq -0xe0(%rbp), %rax
imulq $0x28, -0x78(%rbp), %rcx
addq %rcx, %rax
movl $0xffffffff, (%rax)     # imm = 0xFFFFFFFF
movq 0x38(%rbp), %rax
movq (%rax), %rax
imulq $0xc, -0x78(%rbp), %rcx
addq %rcx, %rax
movl 0x4(%rax), %ecx
movq -0xe0(%rbp), %rax
imulq $0x28, -0x78(%rbp), %rdx
addq %rdx, %rax
movl %ecx, 0x20(%rax)
jmp 0x2d76b3
movq -0x78(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x78(%rbp)
jmp 0x2d75d6
movq 0x38(%rbp), %rax
movq 0x8(%rax), %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x8(%rax)
movl $0x1, -0x14(%rbp)
jmp 0x2d76e4
movl $0x0, -0x14(%rbp)
movl -0x14(%rbp), %eax
addq $0x170, %rsp            # imm = 0x170
popq %rbx
popq %r14
popq %rbp
retq
nopw %cs:(%rax,%rax)