// File: /workspace/github_cpp_makefile_star2_O3/chhylp123[P]hifiasm/Overlaps.cpp
// Function: double_scaffold(ma_ug_t*, ma_ug_t*, ma_ug_t*, scaf_res_t*, scaf_res_t*, asg_t*, ma_sub_t*, ma_hit_t_alloc*, ma_hit_t_alloc*, long long, float, long long, R_to_U*, float, float, int, int, bub_label_t*, ug_opt_t*, kvect_sec_t**, kvect_sec_t**, ma_ug_t**, kvec_asg_arc_t_warp*, kv_u_trans_t**)
void double_scaffold(ma_ug_t *ref, ma_ug_t *hu0, ma_ug_t *hu1, scaf_res_t *cp0, scaf_res_t *cp1, asg_t *sg, ma_sub_t* cover, ma_hit_t_alloc* src, ma_hit_t_alloc* rev,
long long tipsLen, float tip_drop_ratio, long long stops_threshold, R_to_U* ruIndex, float chimeric_rate, float drop_ratio, int max_hang, int min_ovlp, bub_label_t* b_mask_t, ug_opt_t *opt, kvect_sec_t **sc0, kvect_sec_t **sc1, ma_ug_t **rmg, kvec_asg_arc_t_warp *arcs, kv_u_trans_t **rs_trans)
{
    bubble_type *bu = NULL; uint8_t *bf = NULL; scaf_res_t *rms = NULL;
    bu = gen_bubble_chain(sg, ref, opt, &bf, 0); free(bf);

    kv_u_trans_t *bs = gen_shallow_ref_trans(bu, cp0, cp1, sg, ref, cover, src, rev, tipsLen, tip_drop_ratio, stops_threshold, ruIndex, chimeric_rate, drop_ratio, max_hang, min_ovlp, b_mask_t);
    kv_u_trans_t *bd = gen_deep_ref_trans(bs, cp0, cp1, sg, ref, cover, src, rev, tipsLen, tip_drop_ratio, stops_threshold, ruIndex, chimeric_rate, drop_ratio, max_hang, min_ovlp, b_mask_t, opt);
    kv_destroy((*bs)); kv_destroy(bs->idx); free(bs);

    kv_u_trans_t *os = gen_contig_trans_func(ref, hu0, hu1, cp0, cp1, sg, bu, opt, bd, 0/**1**/, rmg, (rs_trans?(&rms):(NULL)));
    

    // print_ctg_trans_ovlp(os, ref, hu0, cp0, hu1, cp1);
    gen_double_scaffold_gfa(ref, hu0, hu1, cp0, cp1, sg, os, 100, sc0, sc1); kv_destroy((*os)); kv_destroy(os->idx); free(os);

    if(rs_trans) {
        (*rs_trans) = cal_scaf_trans(opt, ref, bu, bd, sg, *sc0, *sc1, *rmg, rms);
        destroy_scaf_res_t(rms);
    }
    destory_bubbles(bu); free(bu); kv_destroy((*bd)); kv_destroy(bd->idx); free(bd);

    gen_scaffold_bases(*sc0, *sc1, *rmg, sg, cover, src, arcs, max_hang, min_ovlp, ((rs_trans)?(*rs_trans):(NULL)));

    // ma_ug_seq(*rmg, sg, cover, src, arcs, max_hang, min_ovlp, 0, 1);

    // if(rs_trans) adjust_scaffold_ovlp(sc0, sc1, rmg, (*rs_trans));
    
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movss %xmm2, 0x8(%rsp)
movss %xmm1, 0x4(%rsp)
movss %xmm0, (%rsp)
movq %r9, %r15
movq %r9, 0x10(%rsp)
movq %r8, %r13
movq %rcx, %r12
movq %rdx, 0x48(%rsp)
movq %rsi, 0x40(%rsp)
movq %rdi, %r14
xorl %eax, %eax
leaq 0x50(%rsp), %rbx
movq %rax, (%rbx)
leaq 0x18(%rsp), %rcx
movq %rax, (%rcx)
movq 0xd8(%rsp), %rdx
movq %r9, %rdi
movq %r14, %rsi
movq %rbx, %rcx
xorl %r8d, %r8d
callq 0x1fba56
movq %rax, %rbp
movq %rax, 0x38(%rsp)
movq (%rbx), %rdi
callq 0x2220
movq %rbp, %rdi
movq %r12, 0x30(%rsp)
movq %r12, %rsi
movq %r13, 0x28(%rsp)
movq %r13, %rdx
movq %r15, %rcx
movq %r15, %rbp
movq %r14, %r8
movq 0x90(%rsp), %r15
movq %r15, %r9
movss (%rsp), %xmm0
movss 0x4(%rsp), %xmm1
movss 0x8(%rsp), %xmm2
pushq 0xd0(%rsp)
movl 0xd0(%rsp), %eax
pushq %rax
movl 0xd0(%rsp), %eax
pushq %rax
pushq 0xd0(%rsp)
pushq 0xd0(%rsp)
pushq 0xd0(%rsp)
pushq 0xd0(%rsp)
pushq 0xd0(%rsp)
callq 0xdf530
addq $0x40, %rsp
movq %rax, %rbx
subq $0x8, %rsp
movq %rax, %rdi
movq %r12, %rsi
movq %r13, %rdx
movq %rbp, %rcx
movq %r14, %r8
movq %r14, 0x28(%rsp)
movq %r15, %r9
movss 0x8(%rsp), %xmm0
movss 0xc(%rsp), %xmm1
movss 0x10(%rsp), %xmm2
pushq 0xe0(%rsp)
pushq 0xe0(%rsp)
movl 0xe0(%rsp), %eax
pushq %rax
movl 0xe0(%rsp), %eax
pushq %rax
pushq 0xe0(%rsp)
pushq 0xe0(%rsp)
pushq 0xe0(%rsp)
pushq 0xe0(%rsp)
pushq 0xe0(%rsp)
callq 0xdf6be
addq $0x50, %rsp
movq %rax, %r13
movq %rax, 0x8(%rsp)
movq 0x10(%rbx), %rdi
callq 0x2220
movq 0x28(%rbx), %rdi
callq 0x2220
movq %rbx, %rdi
callq 0x2220
movq 0x100(%rsp), %rax
testq %rax, %rax
leaq 0x18(%rsp), %r10
cmoveq %rax, %r10
movq %r14, %rdi
movq 0x40(%rsp), %r15
movq %r15, %rsi
movq 0x48(%rsp), %r12
movq %r12, %rdx
movq 0x30(%rsp), %rbp
movq %rbp, %rcx
movq 0x28(%rsp), %r14
movq %r14, %r8
movq 0x10(%rsp), %r9
pushq %r10
pushq 0xf8(%rsp)
pushq $0x0
pushq %r13
pushq 0xf8(%rsp)
movq 0x60(%rsp), %r13
pushq %r13
callq 0xdff82
addq $0x30, %rsp
movq %rax, %rbx
movq 0x20(%rsp), %rdi
movq %r15, %rsi
movq 0x8(%rsp), %r15
movq %r12, %rdx
movq %rbp, %rcx
movq %r14, %r8
pushq 0xe8(%rsp)
pushq 0xe8(%rsp)
pushq $0x64
pushq %rax
callq 0xde71f
addq $0x20, %rsp
movq 0x10(%rbx), %rdi
callq 0x2220
movq 0x28(%rbx), %rdi
callq 0x2220
movq %rbx, %rdi
callq 0x2220
movq 0x100(%rsp), %rax
movq %rax, %r14
testq %rax, %rax
je 0xe0f51
movq 0xe0(%rsp), %rax
movq (%rax), %r9
subq $0x8, %rsp
movq 0xe0(%rsp), %rdi
movq 0x28(%rsp), %rsi
movq %r13, %rdx
movq %r15, %rcx
movq 0x18(%rsp), %r8
pushq 0x20(%rsp)
movq 0x100(%rsp), %rax
pushq (%rax)
movq 0x100(%rsp), %rax
pushq (%rax)
callq 0xe05fc
addq $0x20, %rsp
movq %rax, (%r14)
movq 0x18(%rsp), %rdi
callq 0x37e37
movq 0xf8(%rsp), %rbx
movq %r13, %rdi
callq 0x13dea7
movq %r13, %rdi
callq 0x2220
movq 0x10(%r15), %rdi
callq 0x2220
movq 0x28(%r15), %rdi
callq 0x2220
movq %r15, %rdi
callq 0x2220
movq 0xe0(%rsp), %rax
movq (%rax), %rdi
movq 0xe8(%rsp), %rax
movq (%rax), %rsi
movq 0xf0(%rsp), %rax
movq (%rax), %rdx
testq %r14, %r14
je 0xe0fae
movq (%r14), %rax
jmp 0xe0fb0
xorl %eax, %eax
movq 0x10(%rsp), %rcx
movq 0x90(%rsp), %r8
movq 0x98(%rsp), %r9
pushq %rax
movl 0xd0(%rsp), %eax
pushq %rax
movl 0xd0(%rsp), %eax
pushq %rax
pushq %rbx
callq 0xe0882
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq