// File: chhylp123[P]hifiasm/inter.cpp
// Function: work_ctg_path_trans(uldat_t*, asg_t*, ma_ug_t*, scaf_res_t*, ma_ug_t*, scaf_res_t*, ma_ug_t*, kv_u_trans_t*, unsigned int, unsigned int, bubble_type*, kv_u_trans_t*)
void work_ctg_path_trans(uldat_t *sl, asg_t *sg, ma_ug_t *qry, scaf_res_t *qry_sc, ma_ug_t *ref, scaf_res_t *ref_sc, ma_ug_t *gfa, kv_u_trans_t *ta, uint32_t qoff, uint32_t toff, bubble_type *bu, kv_u_trans_t *res)
{
	utepdat_t s; uint64_t i; memset(&s, 0, sizeof(s)); 
	s.id = 0; s.opt = sl->opt; s.ug = sl->ug; s.uopt = sl->uopt; s.rg = sl->rg; s.uu = sl->uu; 
	CALLOC(s.hab, sl->n_thread); CALLOC(s.buf, sl->n_thread); CALLOC(s.ll, sl->n_thread); 
	CALLOC(s.gdp, sl->n_thread); CALLOC(s.mzs, sl->n_thread); CALLOC(s.sps, sl->n_thread); 

	for (i = 0; i < sl->n_thread; ++i) {
		s.hab[i] = ha_ovec_init(0, 0, 1); s.buf[i] = mg_tbuf_init();
	}

	ctdat_t c; memset(&c, 0, sizeof(c)); c.soff = (uint64_t)-1; /**uint8_t *bf = NULL; c.bub = gen_bubble_chain(sg, gfa, (ug_opt_t *)(sl->uopt), &bf, 0); free(bf);**/c.bub = bu;
	c.s = &(s); c.qry = qry; c.qry_sc = qry_sc; c.ref = ref; c.ref_sc = ref_sc; c.gfa = gfa; c.ta = ta;

	// detect_outlier_len("+++work_ul_gchains");

	kt_for(sl->n_thread, worker_for_ctg_trans_alignment, &c, c.qry_sc->n);

	// detect_outlier_len("---work_ul_gchains");
	/**destory_bubbles(c.bub); free(c.bub);**/
	fill_ctg_path_trans_idx(s.ll, sl->n_thread, qry->u.n, qoff, toff, res);
	for (i = 0; i < sl->n_thread; ++i) {
		s.sum_len += s.hab[i]->num_read_base; s.n += s.hab[i]->num_correct_base;
		ha_ovec_destroy(s.hab[i]); mg_tbuf_destroy(s.buf[i]); hc_glchain_destroy(&(s.ll[i]));
		hc_gdpchain_destroy(&(s.gdp[i])); kv_destroy(s.mzs[i]); kv_destroy(s.sps[i]);
	}

	free(s.hab); free(s.buf); free(s.ll); free(s.gdp); free(s.mzs); free(s.sps);
	fprintf(stderr, "[M::%s::] # try:%d, # done:%d\n", __func__, s.sum_len, s.n); 
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x160, %rsp            # imm = 0x160
movq 0x38(%rbp), %rax
movq 0x30(%rbp), %rax
movl 0x28(%rbp), %eax
movl 0x20(%rbp), %eax
movq 0x18(%rbp), %rax
movq 0x10(%rbp), %rax
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
leaq -0x100(%rbp), %rdi
xorl %esi, %esi
movl $0xd0, %edx
callq 0x2100
movq $0x0, -0xb0(%rbp)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x100(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0xe8(%rbp)
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rax
movq %rax, -0xd8(%rbp)
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0xe0(%rbp)
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rax
movq %rax, -0xd0(%rbp)
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rdi
movl $0x8, %esi
callq 0x2140
movq %rax, -0x80(%rbp)
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rdi
movl $0x8, %esi
callq 0x2140
movq %rax, -0x88(%rbp)
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rdi
movl $0x68, %esi
callq 0x2140
movq %rax, -0x78(%rbp)
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rdi
movl $0xc0, %esi
callq 0x2140
movq %rax, -0x70(%rbp)
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rdi
movl $0x10, %esi
callq 0x2140
movq %rax, -0xa0(%rbp)
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rdi
movl $0x18, %esi
callq 0x2140
movq %rax, -0x98(%rbp)
movq $0x0, -0x108(%rbp)
movq -0x108(%rbp), %rax
movq -0x8(%rbp), %rcx
cmpq 0x58(%rcx), %rax
jae 0x2ed199
xorl %esi, %esi
movl $0x1, %edx
movl %esi, %edi
callq 0x14c90
movq %rax, %rdx
movq -0x80(%rbp), %rax
movq -0x108(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
callq 0x27e560
movq %rax, %rdx
movq -0x88(%rbp), %rax
movq -0x108(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movq -0x108(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x108(%rbp)
jmp 0x2ed13a
leaq -0x160(%rbp), %rdi
xorl %esi, %esi
movl $0x58, %edx
callq 0x2100
movq $-0x1, -0x118(%rbp)
movq 0x30(%rbp), %rax
movq %rax, -0x130(%rbp)
leaq -0x100(%rbp), %rax
movq %rax, -0x160(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x158(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x150(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0x148(%rbp)
movq -0x30(%rbp), %rax
movq %rax, -0x140(%rbp)
movq 0x10(%rbp), %rax
movq %rax, -0x138(%rbp)
movq 0x18(%rbp), %rax
movq %rax, -0x128(%rbp)
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movl %eax, %edi
movq -0x150(%rbp), %rax
movq 0x8(%rax), %rcx
leaq 0x1c2(%rip), %rsi       # 0x2ed3f0
leaq -0x160(%rbp), %rdx
callq 0x16d710
movq -0x78(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rsi
movq -0x18(%rbp), %rax
movq (%rax), %rdx
movl 0x20(%rbp), %ecx
movl 0x28(%rbp), %r8d
movq 0x38(%rbp), %r9
callq 0x2ec780
movq $0x0, -0x108(%rbp)
movq -0x108(%rbp), %rax
movq -0x8(%rbp), %rcx
cmpq 0x58(%rcx), %rax
jae 0x2ed36f
movq -0x80(%rbp), %rax
movq -0x108(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq 0xf0(%rax), %rcx
movslq -0xc0(%rbp), %rax
addq %rcx, %rax
movl %eax, -0xc0(%rbp)
movq -0x80(%rbp), %rax
movq -0x108(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq 0xf8(%rax), %rcx
movslq -0xc8(%rbp), %rax
addq %rcx, %rax
movl %eax, -0xc8(%rbp)
movq -0x80(%rbp), %rax
movq -0x108(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x14f00
movq -0x88(%rbp), %rax
movq -0x108(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x27e5a0
movq -0x78(%rbp), %rdi
imulq $0x68, -0x108(%rbp), %rax
addq %rax, %rdi
callq 0x282c10
movq -0x70(%rbp), %rdi
imulq $0xc0, -0x108(%rbp), %rax
addq %rax, %rdi
callq 0x282c60
movq -0xa0(%rbp), %rax
movq -0x108(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rdi
callq 0x2210
movq -0x98(%rbp), %rax
imulq $0x18, -0x108(%rbp), %rcx
addq %rcx, %rax
movq 0x10(%rax), %rdi
callq 0x2210
movq -0x108(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x108(%rbp)
jmp 0x2ed268
movq -0x80(%rbp), %rdi
callq 0x2210
movq -0x88(%rbp), %rdi
callq 0x2210
movq -0x78(%rbp), %rdi
callq 0x2210
movq -0x70(%rbp), %rdi
callq 0x2210
movq -0xa0(%rbp), %rdi
callq 0x2210
movq -0x98(%rbp), %rdi
callq 0x2210
movq 0xd6c2b(%rip), %rax     # 0x3c3fe0
movq (%rax), %rdi
movl -0xc0(%rbp), %ecx
movl -0xc8(%rbp), %r8d
leaq 0xa7368(%rip), %rsi     # 0x394734
leaq 0xa742e(%rip), %rdx     # 0x394801
movb $0x0, %al
callq 0x22a0
addq $0x160, %rsp            # imm = 0x160
popq %rbp
retq
nopw %cs:(%rax,%rax)