// File: chhylp123[P]hifiasm/anchor.cpp
// Function: ug_map_lchain(ha_abufl_s*, unsigned int, char*, unsigned long, unsigned long, unsigned long, ul_idx_t const*, overlap_region_alloc*, Candidates_list*, double, double, int, int, kvec_t_u8_warp*, overlap_region*, kvec_t_u64_warp*, st_mt_t*, unsigned int*, unsigned int*, unsigned int, unsigned int, double, unsigned int, unsigned int, ha_mzl_t*, unsigned long, ha_mzl_t*, unsigned long, unsigned long, unsigned long, kv_u_trans_t*)
int64_t ug_map_lchain(ha_abufl_t *ab, uint32_t rid, char* rs, uint64_t rl, uint64_t mz_w, uint64_t mz_k, const ul_idx_t *uref, overlap_region_alloc *overlap_list, Candidates_list *cl, double bw_thres, double bw_thres_sec,
								 int max_n_chain, int apend_be, kvec_t_u8_warp* k_flag, overlap_region* f_cigar, kvec_t_u64_warp* dbg_ct, st_mt_t *sp, uint32_t *high_occ, uint32_t *low_occ, uint32_t is_accurate, 
								 uint32_t gen_off, double mcopy_rate, uint32_t mcopy_khit_cut, uint32_t is_hpc, ha_mzl_t *res, uint64_t res_n, ha_mzl_t *idx, uint64_t idx_n, uint64_t mzl_cutoff, uint64_t chain_cutoff, kv_u_trans_t *kov)
{
	int64_t max_skip, max_iter, max_dis, quick_check; double chn_pen_gap, chn_pen_skip;
	set_lchain_dp_op(is_accurate, mz_k, &max_skip, &max_iter, &max_dis, &chn_pen_gap, &chn_pen_skip, &quick_check);
	if((!overlap_list) || (!cl)) {
		ab->mz.n = 0;
		mz2_ha_sketch(rs, rl, mz_w, mz_k, rid, is_hpc, &ab->mz, NULL, asm_opt.mz_sample_dist, k_flag, dbg_ct, NULL, -1, asm_opt.dp_min_len, -1, sp, asm_opt.mz_rewin, 0, NULL);
		if(res) memcpy(res, ab->mz.a, ab->mz.n * (sizeof((*(ab->mz.a)))));
		return ab->mz.n;
	} else {
		sp->n = 0;
		minimizers_qgen_input(ab, rid, rs, rl, mz_w, mz_k, cl, k_flag, ha_flt_tab, ha_idx, NULL, uref, dbg_ct, sp, high_occ, low_occ, res, res_n, idx, idx_n, mzl_cutoff, chain_cutoff, kov);
		lchain_qgen_mcopy_input(cl, overlap_list, rid, rl, NULL, uref, apend_be, max_n_chain, max_skip, max_iter, max_dis, chn_pen_gap, chn_pen_skip, bw_thres, bw_thres_sec, quick_check, gen_off, mcopy_rate, mcopy_khit_cut, sp);
		return 0;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x158, %rsp            # imm = 0x158
movq 0xb8(%rbp), %rax
movq 0xb0(%rbp), %rax
movq 0xa8(%rbp), %rax
movq 0xa0(%rbp), %rax
movq 0x98(%rbp), %rax
movq 0x90(%rbp), %rax
movq 0x88(%rbp), %rax
movl 0x80(%rbp), %eax
movl 0x78(%rbp), %eax
movl 0x70(%rbp), %eax
movl 0x68(%rbp), %eax
movq 0x60(%rbp), %rax
movq 0x58(%rbp), %rax
movq 0x50(%rbp), %rax
movq 0x48(%rbp), %rax
movq 0x40(%rbp), %rax
movq 0x38(%rbp), %rax
movl 0x30(%rbp), %eax
movl 0x28(%rbp), %eax
movq 0x20(%rbp), %rax
movq 0x18(%rbp), %rax
movq 0x10(%rbp), %rax
movq %rdi, -0x38(%rbp)
movl %esi, -0x3c(%rbp)
movq %rdx, -0x48(%rbp)
movq %rcx, -0x50(%rbp)
movq %r8, -0x58(%rbp)
movq %r9, -0x60(%rbp)
movsd %xmm0, -0x68(%rbp)
movsd %xmm1, -0x70(%rbp)
movsd %xmm2, -0x78(%rbp)
movl 0x68(%rbp), %edi
movq -0x60(%rbp), %rax
movl %eax, %esi
leaq -0x80(%rbp), %rdx
leaq -0x88(%rbp), %rcx
leaq -0x90(%rbp), %r8
leaq -0xa0(%rbp), %r9
leaq -0xa8(%rbp), %r10
leaq -0x98(%rbp), %rax
movq %r10, (%rsp)
movq %rax, 0x8(%rsp)
callq 0x1aca80
cmpq $0x0, 0x18(%rbp)
je 0x1b3f54
cmpq $0x0, 0x20(%rbp)
jne 0x1b4055
movq -0x38(%rbp), %rax
movl $0x0, 0x18(%rax)
movq -0x48(%rbp), %rdi
movq -0x50(%rbp), %rax
movl %eax, %esi
movq -0x58(%rbp), %rax
movl %eax, %edx
movq -0x60(%rbp), %rax
movl %eax, %ecx
movl -0x3c(%rbp), %r8d
movl 0x80(%rbp), %r9d
movq -0x38(%rbp), %r12
addq $0x18, %r12
leaq 0x210869(%rip), %rax    # 0x3c47f8
movl 0xa8(%rax), %r15d
movq 0x38(%rbp), %r14
movq 0x48(%rbp), %rbx
leaq 0x210853(%rip), %rax    # 0x3c47f8
movl 0x1f8(%rax), %r11d
movq 0x50(%rbp), %r10
leaq 0x210841(%rip), %rax    # 0x3c47f8
movl 0xa0(%rax), %eax
xorl %r13d, %r13d
movss 0x1cb0a8(%rip), %xmm0   # 0x37f070
xorl %r13d, %r13d
movq %r12, (%rsp)
movq $0x0, 0x8(%rsp)
movl %r15d, 0x10(%rsp)
movq %r14, 0x18(%rsp)
movq %rbx, 0x20(%rsp)
movq $0x0, 0x28(%rsp)
movl $0xffffffff, 0x30(%rsp) # imm = 0xFFFFFFFF
movl %r11d, 0x38(%rsp)
movq %r10, 0x40(%rsp)
movl %eax, 0x48(%rsp)
movl $0x0, 0x50(%rsp)
movq $0x0, 0x58(%rsp)
callq 0x1995e0
cmpq $0x0, 0x88(%rbp)
je 0x1b4045
movq 0x88(%rbp), %rdi
movq -0x38(%rbp), %rax
movq 0x20(%rax), %rsi
movq -0x38(%rbp), %rax
movl 0x18(%rax), %eax
imulq $0x18, %rax, %rdx
callq 0x2180
movq -0x38(%rbp), %rax
movl 0x18(%rax), %eax
movq %rax, -0x30(%rbp)
jmp 0x1b4261
movq 0x50(%rbp), %rax
movq $0x0, (%rax)
movq -0x38(%rbp), %rdi
movl -0x3c(%rbp), %eax
movl %eax, %esi
movq -0x48(%rbp), %rdx
movq -0x50(%rbp), %rcx
movq -0x58(%rbp), %r8
movq -0x60(%rbp), %r9
movq 0x20(%rbp), %rax
movq %rax, -0xf8(%rbp)
movq 0x38(%rbp), %rax
movq %rax, -0xf0(%rbp)
leaq 0x21143a(%rip), %rax    # 0x3c54d0
movq (%rax), %rax
movq %rax, -0xe8(%rbp)
leaq 0x211431(%rip), %rax    # 0x3c54d8
movq (%rax), %rax
movq %rax, -0xe0(%rbp)
movq 0x10(%rbp), %rax
movq %rax, -0xd8(%rbp)
movq 0x48(%rbp), %rax
movq %rax, -0xd0(%rbp)
movq 0x50(%rbp), %rax
movq %rax, -0xc8(%rbp)
movq 0x58(%rbp), %rax
movq %rax, -0xc0(%rbp)
movq 0x60(%rbp), %r13
movq 0x88(%rbp), %r12
movq 0x90(%rbp), %r15
movq 0x98(%rbp), %r14
movq 0xa0(%rbp), %rbx
movq 0xa8(%rbp), %r11
movq 0xb0(%rbp), %r10
movq 0xb8(%rbp), %rax
movq %rax, -0xb8(%rbp)
xorl %eax, %eax
movq -0xf8(%rbp), %rax
movq %rax, (%rsp)
movq -0xf0(%rbp), %rax
movq %rax, 0x8(%rsp)
movq -0xe8(%rbp), %rax
movq %rax, 0x10(%rsp)
movq -0xe0(%rbp), %rax
movq %rax, 0x18(%rsp)
movq -0xd8(%rbp), %rax
movq $0x0, 0x20(%rsp)
movq %rax, 0x28(%rsp)
movq -0xd0(%rbp), %rax
movq %rax, 0x30(%rsp)
movq -0xc8(%rbp), %rax
movq %rax, 0x38(%rsp)
movq -0xc0(%rbp), %rax
movq %rax, 0x40(%rsp)
movq -0xb8(%rbp), %rax
movq %r13, 0x48(%rsp)
movq %r12, 0x50(%rsp)
movq %r15, 0x58(%rsp)
movq %r14, 0x60(%rsp)
movq %rbx, 0x68(%rsp)
movq %r11, 0x70(%rsp)
movq %r10, 0x78(%rsp)
movq %rax, 0x80(%rsp)
callq 0x1a7ab0
movq 0x20(%rbp), %rdi
movq 0x18(%rbp), %rsi
movl -0x3c(%rbp), %edx
movq -0x50(%rbp), %rcx
movq 0x10(%rbp), %r9
movl 0x30(%rbp), %eax
movslq 0x28(%rbp), %r13
movq -0x80(%rbp), %r12
movq -0x88(%rbp), %r15
movq -0x90(%rbp), %r14
movsd -0xa0(%rbp), %xmm0
movsd -0xa8(%rbp), %xmm1
movsd -0x68(%rbp), %xmm2
movsd -0x70(%rbp), %xmm3
movq -0x98(%rbp), %rbx
movl 0x70(%rbp), %r11d
movsd -0x78(%rbp), %xmm4
movl 0x78(%rbp), %r10d
movq 0x50(%rbp), %r8
movq %r8, -0xb0(%rbp)
xorl %r8d, %r8d
movl %eax, (%rsp)
movq -0xb0(%rbp), %rax
movq %r13, 0x8(%rsp)
movq %r12, 0x10(%rsp)
movq %r15, 0x18(%rsp)
movq %r14, 0x20(%rsp)
movq %rbx, 0x28(%rsp)
movl %r11d, 0x30(%rsp)
movl %r10d, 0x38(%rsp)
movq %rax, 0x40(%rsp)
callq 0x1ac2c0
movq $0x0, -0x30(%rbp)
movq -0x30(%rbp), %rax
addq $0x158, %rsp            # imm = 0x158
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nopw (%rax,%rax)