// File: chhylp123[P]hifiasm/inter.cpp
// Function: update_ul_vec_t(ul_idx_t const*, kv_ul_ov_t*, kv_ul_ov_t*, ul_vec_t*, vec_mg_lchain_t*, vec_mg_lchain_t*, long, asg_t const*, Chain_Data*, long, long, long)
void update_ul_vec_t(const ul_idx_t *uref, kv_ul_ov_t *raw_idx, kv_ul_ov_t *raw_chn, ul_vec_t *rch, 
vec_mg_lchain_t *uc, vec_mg_lchain_t *swap, int64_t ulid, const asg_t *rg, Chain_Data* dp, 
int64_t dp_max_skip, int64_t dp_max_iter, int64_t dp_max_dis)
{
	// fprintf(stderr, "\n++[M::%s::%.*s(id:%ld), len:%u]\n", __func__, 
	// UL_INF.nid.a[ulid].n, UL_INF.nid.a[ulid].a, ulid, rch->rlen);

	int64_t k, ucn = uc->n; mg_lchain_t *ix; 
	for (k = 0, swap->n = 0; k < ucn; k += ix->cnt + 1) {
		ix = &(uc->a[k]); assert(ix->v == (uint32_t)-1);
		// if(ulid == 14714) {
		// 	fprintf(stderr, "\n[M::%s::ucn->%ld, k->%ld, kcnt->%d]\n", __func__, ucn, k, ix->cnt);
		// 	print_debug_gchain(uref, uc->a + k + 1, ix->cnt, rch);
		// }
		gen_rovlp_chain_by_ul(rg, rch, uref, raw_idx, raw_chn, uc->a + k + 1, ix->cnt, swap, dp, 
		dp_max_skip, dp_max_iter, dp_max_dis, ulid);
	}

	///up to now, given a <x> in swap
	///x->ts and x->te are the coordinates in unitig (x->score>>1), instead of HiFi read (x->v>>1)
	///x->qs and x->qe are the coordinates in UL
	///x->dist_pre is the idx of this chain at rch 
	// debug_intermediate_chain(uref->ug, swap->a, swap->n);
	dd_ul_vec_t(uref, swap->a, swap->n, rch, ulid);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x80, %rsp
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, -0x28(%rbp)
movq %rsi, -0x30(%rbp)
movq %rdx, -0x38(%rbp)
movq %rcx, -0x40(%rbp)
movq %r8, -0x48(%rbp)
movq %r9, -0x50(%rbp)
movq -0x48(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x60(%rbp)
movq $0x0, -0x58(%rbp)
movq -0x50(%rbp), %rax
movq $0x0, 0x8(%rax)
movq -0x58(%rbp), %rax
cmpq -0x60(%rbp), %rax
jge 0x2dc47f
movq -0x48(%rbp), %rax
movq (%rax), %rax
imulq $0x28, -0x58(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rax
cmpl $-0x1, 0x8(%rax)
jne 0x2dc3cf
jmp 0x2dc3ee
leaq 0xb5375(%rip), %rdi     # 0x39174b
leaq 0xb4452(%rip), %rsi     # 0x39082f
movl $0x3ea5, %edx           # imm = 0x3EA5
leaq 0xb7997(%rip), %rcx     # 0x393d80
callq 0x2130
movq 0x18(%rbp), %rdi
movq -0x40(%rbp), %rsi
movq -0x28(%rbp), %rdx
movq -0x30(%rbp), %rcx
movq -0x38(%rbp), %r8
movq -0x48(%rbp), %rax
movq (%rax), %r9
imulq $0x28, -0x58(%rbp), %rax
addq %rax, %r9
addq $0x28, %r9
movq -0x68(%rbp), %rax
movl 0x4(%rax), %eax
shll %eax
sarl %eax
movslq %eax, %r12
movq -0x50(%rbp), %r15
movq 0x20(%rbp), %r14
movq 0x28(%rbp), %rbx
movq 0x30(%rbp), %r11
movq 0x38(%rbp), %r10
movq 0x10(%rbp), %rax
movq %r12, (%rsp)
movq %r15, 0x8(%rsp)
movq %r14, 0x10(%rsp)
movq %rbx, 0x18(%rsp)
movq %r11, 0x20(%rsp)
movq %r10, 0x28(%rsp)
movq %rax, 0x30(%rsp)
callq 0x2da720
movq -0x68(%rbp), %rax
movl 0x4(%rax), %eax
shll %eax
sarl %eax
addl $0x1, %eax
cltq
addq -0x58(%rbp), %rax
movq %rax, -0x58(%rbp)
jmp 0x2dc3a2
movq -0x28(%rbp), %rdi
movq -0x50(%rbp), %rax
movq (%rax), %rsi
movq -0x50(%rbp), %rax
movq 0x8(%rax), %rdx
movq -0x40(%rbp), %rcx
movq 0x10(%rbp), %r8
callq 0x2db150
addq $0x80, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
nop