// File: chhylp123[P]hifiasm/Overlaps.cpp
// Function: get_utg_ovlp(ma_ug_t**, asg_t*, ma_hit_t_alloc*, ma_hit_t_alloc*, ma_sub_t*, R_to_U*, int, int, kvec_asg_arc_t_warp*, bub_label_t*, unsigned char*)
kv_u_trans_t *get_utg_ovlp(ma_ug_t **ug, asg_t* read_g, ma_hit_t_alloc* sources, ma_hit_t_alloc* reverse_sources, ma_sub_t* coverage_cut, 
R_to_U* ruIndex, int max_hang, int min_ovlp, kvec_asg_arc_t_warp* new_rtg_edges, bub_label_t* b_mask_t, uint8_t* r_het)
{
    ///print_debug_gfa(read_g, *ug, coverage_cut, "init", sources, ruIndex, asm_opt.max_hang_Len, asm_opt.min_overlap_Len);
    kv_u_trans_t *ta = pt_pdist(*ug, read_g,coverage_cut, sources, new_rtg_edges, max_hang, min_ovlp, 5);
    kv_gg_status *sa = init_mc_gg_status(*ug, read_g, coverage_cut, sources, ruIndex, 
    asm_opt.hom_global_coverage_set?asm_opt.hom_global_coverage:((double)asm_opt.hom_global_coverage)/((double)HOM_PEAK_RATE), 
    asm_opt.polyploidy);
    mc_solve_general(ta, (*ug)->u.n, sa, asm_opt.polyploidy, 1, 1);
    if(r_het) set_r_het_status(r_het, sa, *ug, asm_opt.polyploidy);
    free(sa->a); free(sa);
    return ta;
    // ma_ug_seq(*ug, read_g, coverage_cut, sources, new_rtg_edges, max_hang, min_ovlp, 0, 0);
    // ug_idx_build(*ug, asm_opt.polyploidy);
    // topo_ovlp_collect(*ug, read_g, sources, reverse_sources, coverage_cut, tipsLen, tip_drop_ratio, 
    // stops_threshold, ruIndex, chimeric_rate, drop_ratio, max_hang, min_ovlp, cov);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq 0x30(%rbp), %rax
movq 0x28(%rbp), %rax
movq 0x20(%rbp), %rax
movl 0x18(%rbp), %eax
movl 0x10(%rbp), %eax
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rdi
movq -0x10(%rbp), %rsi
movq -0x28(%rbp), %rdx
movq -0x18(%rbp), %rcx
movq 0x20(%rbp), %r8
movl 0x10(%rbp), %r9d
movl 0x18(%rbp), %eax
movl %eax, (%rsp)
movl $0x5, 0x8(%rsp)
callq 0x279150
movq %rax, -0x38(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x68(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x30(%rbp), %rax
movq %rax, -0x48(%rbp)
leaq 0x2b59df(%rip), %rax    # 0x3c47f8
cmpl $0x0, 0x148(%rax)
je 0x10ee38
leaq 0x2b59cf(%rip), %rax    # 0x3c47f8
cvtsi2sdl 0x144(%rax), %xmm0
movsd %xmm0, -0x70(%rbp)
jmp 0x10ee58
leaq 0x2b59b9(%rip), %rax    # 0x3c47f8
cvtsi2sdl 0x144(%rax), %xmm0
movsd 0x2779f1(%rip), %xmm1   # 0x386840
divsd %xmm1, %xmm0
movsd %xmm0, -0x70(%rbp)
movq -0x48(%rbp), %r8
movq -0x50(%rbp), %rcx
movq -0x58(%rbp), %rdx
movq -0x60(%rbp), %rsi
movq -0x68(%rbp), %rdi
movsd -0x70(%rbp), %xmm0
movsd 0x27317f(%rip), %xmm2   # 0x381ff8
movaps %xmm0, %xmm1
subsd %xmm2, %xmm1
cvttsd2si %xmm1, %rax
cvttsd2si %xmm0, %r9
movq %r9, %r10
sarq $0x3f, %r10
andq %r10, %rax
orq %rax, %r9
leaq 0x2b595a(%rip), %rax    # 0x3c47f8
movl 0x1bc(%rax), %eax
movzwl %ax, %eax
movl %eax, (%rsp)
callq 0x227e70
movq %rax, -0x40(%rbp)
movq -0x38(%rbp), %rdi
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq (%rax), %rax
movl %eax, %esi
movq -0x40(%rbp), %rdx
leaq 0x2b592a(%rip), %rax    # 0x3c47f8
movl 0x1bc(%rax), %eax
movl $0x1, %r9d
movzwl %ax, %ecx
movl %r9d, %r8d
callq 0x22ad50
cmpq $0x0, 0x30(%rbp)
je 0x10ef0d
movq 0x30(%rbp), %rdi
movq -0x40(%rbp), %rsi
movq -0x8(%rbp), %rax
movq (%rax), %rdx
leaq 0x2b58f6(%rip), %rax    # 0x3c47f8
movl 0x1bc(%rax), %ecx
callq 0x14ee80
movq -0x40(%rbp), %rax
movq (%rax), %rdi
callq 0x2210
movq -0x40(%rbp), %rdi
callq 0x2210
movq -0x38(%rbp), %rax
addq $0x80, %rsp
popq %rbp
retq
nop