// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x158, %rsp            # imm = 0x158
movq %r9, 0x18(%rsp)
movq %r8, 0x10(%rsp)
movq %rcx, 0x20(%rsp)
movq %rdx, 0x28(%rsp)
movq %rdi, %r14
leaq 0x38(%rsp), %r12
xorl %ebx, %ebx
movl $0xc8, %edx
movq %r12, %rdi
xorl %esi, %esi
callq 0x20e0
movq 0x10(%r14), %rax
movq %rax, -0x8(%r12)
movups 0x18(%r14), %xmm0
movups %xmm0, 0x10(%r12)
movups 0x28(%r14), %xmm0
movups %xmm0, 0x20(%r12)
movq %r14, 0x8(%rsp)
movq 0x58(%r14), %rbp
pushq $0x8
popq %r14
movq %rbp, %rdi
movq %r14, %rsi
callq 0x2120
movq %rax, %r13
movq %rax, 0x78(%r12)
movq %rbp, %rdi
movq %r14, %rsi
callq 0x2120
movq %rax, %r15
movq %rax, 0x70(%r12)
pushq $0x68
popq %rsi
movq %rbp, %rdi
callq 0x2120
movq %rax, 0x80(%r12)
movl $0xc0, %esi
movq %rbp, %rdi
callq 0x2120
movq %rax, 0x88(%r12)
pushq $0x10
popq %rsi
movq %rbp, %rdi
callq 0x2120
movq %rax, 0x58(%r12)
pushq $0x18
popq %rsi
movq %rbp, %rdi
callq 0x2120
movq %rax, 0x60(%r12)
pushq $0x1
popq %r12
cmpq %rbp, %rbx
jae 0x191aca
xorl %edi, %edi
xorl %esi, %esi
movl %r12d, %edx
callq 0xc44b
movq %rax, (%r13,%rbx,8)
callq 0x1588bc
movq %rax, (%r15,%rbx,8)
incq %rbx
movq 0x8(%rsp), %rax
movq 0x58(%rax), %rbp
jmp 0x191a9d
xorps %xmm0, %xmm0
leaq 0x100(%rsp), %rdx
andq $0x0, 0x50(%rdx)
movups %xmm0, 0x40(%rdx)
orq $-0x1, 0x48(%rdx)
movq 0x1b0(%rsp), %rax
movq %rax, 0x30(%rdx)
leaq 0x30(%rsp), %rbx
movq %rbx, (%rdx)
movq 0x28(%rsp), %r15
movq %r15, 0x8(%rdx)
movq 0x20(%rsp), %rax
movq %rax, 0x10(%rdx)
movq 0x10(%rsp), %rcx
movq %rcx, 0x18(%rdx)
movq 0x18(%rsp), %rcx
movq %rcx, 0x20(%rdx)
movq 0x190(%rsp), %rcx
movq %rcx, 0x28(%rdx)
movq 0x198(%rsp), %rcx
movq %rcx, 0x38(%rdx)
movq 0x8(%rax), %rcx
leaq 0x15e(%rip), %rsi       # 0x191c9c
movl %ebp, %edi
callq 0xc67c0
movq 0x88(%rbx), %rdi
movq 0x8(%rsp), %rbp
movq 0x58(%rbp), %rsi
movq (%r15), %rdx
movl 0x1a0(%rsp), %ecx
movl 0x1a8(%rsp), %r8d
movq 0x1b8(%rsp), %r9
callq 0x191604
xorl %ebx, %ebx
xorl %r15d, %r15d
movq %r14, %r12
xorl %r13d, %r13d
movq 0xb0(%rsp), %rdi
cmpq 0x58(%rbp), %r13
jae 0x191c1c
movq (%rdi,%r13,8), %rdi
movl 0xf0(%rdi), %eax
addl %eax, 0x70(%rsp)
movl 0xf8(%rdi), %eax
addl %eax, 0x68(%rsp)
callq 0xc5d1
movq 0xa8(%rsp), %rax
movq (%rax,%r13,8), %rdi
callq 0x1588d8
movq 0xb8(%rsp), %rdi
addq %r15, %rdi
callq 0x15a8d7
movq 0xc0(%rsp), %rdi
addq %rbx, %rdi
callq 0x15a905
movq 0x90(%rsp), %rax
movq (%rax,%r14), %rdi
callq 0x2220
movq 0x98(%rsp), %rax
movq (%rax,%r12,2), %rdi
callq 0x2220
incq %r13
addq $0xc, %r12
addq $0x10, %r14
addq $0x68, %r15
addq $0xc0, %rbx
jmp 0x191b7f
callq 0x2220
movq 0xa8(%rsp), %rdi
callq 0x2220
movq 0xb8(%rsp), %rdi
callq 0x2220
movq 0xc0(%rsp), %rdi
callq 0x2220
movq 0x90(%rsp), %rdi
callq 0x2220
movq 0x98(%rsp), %rdi
callq 0x2220
movq 0xc1377(%rip), %rax     # 0x252fe0
movq (%rax), %rdi
movl 0x68(%rsp), %r8d
movl 0x70(%rsp), %ecx
leaq 0x63dac(%rip), %rsi     # 0x1f5a28
leaq 0x63e72(%rip), %rdx     # 0x1f5af5
xorl %eax, %eax
callq 0x22b0
addq $0x158, %rsp            # imm = 0x158
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq