// File: /workspace/github_cpp_makefile_star2_O2/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 $0x48, %rsp
movss %xmm2, 0xc(%rsp)
movss %xmm1, 0x8(%rsp)
movss %xmm0, 0x4(%rsp)
movq %r9, %r13
movq %r9, 0x18(%rsp)
movq %r8, %rbp
movq %rcx, %r15
movq %rdx, 0x38(%rsp)
movq %rsi, 0x30(%rsp)
movq %rdi, %r14
leaq 0x40(%rsp), %rbx
andq $0x0, (%rbx)
leaq 0x20(%rsp), %rax
andq $0x0, (%rax)
movq 0xc8(%rsp), %rdx
movq %r9, %rdi
movq %r14, %rsi
movq %rbx, %rcx
xorl %r8d, %r8d
callq 0x1afe25
movq %rax, %r12
movq %rax, 0x10(%rsp)
movq (%rbx), %rdi
callq 0x2220
movq %r12, %rdi
movq %r15, %rsi
movq %rbp, %rdx
movq %r13, %rcx
movq %r14, %r8
movq 0x80(%rsp), %r12
movq %r12, %r9
movss 0x4(%rsp), %xmm0
movss 0x8(%rsp), %xmm1
movss 0xc(%rsp), %xmm2
pushq 0xc0(%rsp)
movl 0xc0(%rsp), %eax
pushq %rax
movl 0xc0(%rsp), %eax
pushq %rax
pushq 0xc0(%rsp)
pushq 0xc0(%rsp)
pushq 0xc0(%rsp)
pushq 0xc0(%rsp)
pushq 0xc0(%rsp)
callq 0xa1cd9
addq $0x40, %rsp
movq %rax, %rbx
subq $0x8, %rsp
movq %rax, %rdi
movq %r15, %rsi
movq %rbp, %rdx
movq %r13, %rcx
movq %r14, %r13
movq %r14, 0x30(%rsp)
movq %r14, %r8
movq %r12, %r9
movss 0xc(%rsp), %xmm0
movss 0x10(%rsp), %xmm1
movss 0x14(%rsp), %xmm2
pushq 0xd0(%rsp)
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 0xa1e65
addq $0x50, %rsp
movq %rax, %r14
movq 0x10(%rbx), %rdi
callq 0x2220
movq 0x28(%rbx), %rdi
callq 0x2220
movq %rbx, %rdi
callq 0x2220
movq 0xf0(%rsp), %rax
testq %rax, %rax
leaq 0x20(%rsp), %r10
cmoveq %rax, %r10
movq %r13, %rdi
movq 0x30(%rsp), %r13
movq %r13, %rsi
movq 0x38(%rsp), %r12
movq %r12, %rdx
movq %r15, %rcx
movq %rbp, %r8
movq 0x18(%rsp), %r9
pushq %r10
pushq 0xe8(%rsp)
pushq $0x0
pushq %r14
pushq 0xe8(%rsp)
pushq 0x38(%rsp)
callq 0xa26c1
addq $0x30, %rsp
movq %rax, %rbx
movq 0x28(%rsp), %rdi
movq %r13, %rsi
movq %r14, %r13
movq %r12, %rdx
movq %r15, %rcx
movq 0xd0(%rsp), %r15
movq %rbp, %r8
pushq 0xd8(%rsp)
pushq %r15
pushq $0x64
pushq %rax
callq 0xa10e5
addq $0x20, %rsp
movq 0x10(%rbx), %rdi
callq 0x2220
movq 0x28(%rbx), %rdi
callq 0x2220
movq %rbx, %rdi
callq 0x2220
movq 0xf0(%rsp), %rax
movq %rax, %rbx
testq %rax, %rax
je 0xa358b
movq (%r15), %r9
subq $0x8, %rsp
movq 0xd0(%rsp), %rdi
movq 0x30(%rsp), %rsi
movq 0x18(%rsp), %rdx
movq %r13, %rcx
movq 0x20(%rsp), %r8
pushq 0x28(%rsp)
movq 0xf0(%rsp), %rax
pushq (%rax)
movq 0xf0(%rsp), %rax
pushq (%rax)
callq 0xa2cf6
addq $0x20, %rsp
movq %rax, (%rbx)
movq 0x20(%rsp), %rdi
callq 0xbb11
movq 0xe8(%rsp), %r12
movq 0x10(%rsp), %r14
movq %r14, %rdi
callq 0xf6a60
movq %r14, %rdi
callq 0x2220
movq 0x10(%r13), %rdi
callq 0x2220
movq 0x28(%r13), %rdi
callq 0x2220
movq %r13, %rdi
callq 0x2220
movq (%r15), %rdi
movq 0xd8(%rsp), %rax
movq (%rax), %rsi
movq 0xe0(%rsp), %rax
movq (%rax), %rdx
testq %rbx, %rbx
je 0xa35e5
movq (%rbx), %rax
jmp 0xa35e7
xorl %eax, %eax
movq 0x18(%rsp), %rcx
movq 0x80(%rsp), %r8
movq 0x88(%rsp), %r9
pushq %rax
movl 0xc0(%rsp), %eax
pushq %rax
movl 0xc0(%rsp), %eax
pushq %rax
pushq %r12
callq 0xa2f6b
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq