// File: /workspace/github_cpp_makefile_star2_O2/chhylp123[P]hifiasm/gfa_ut.cpp
// Function: deep_graph_clean(ug_opt_t*, asg_t*, unsigned char, unsigned char, long, double, double, double, long, long, long)
void deep_graph_clean(ug_opt_t *uopt, asg_t *sg, uint8_t is_ou, uint8_t is_trio, int64_t max_ext, 
double min_ovlp_drop_ratio, double max_ovlp_drop_ratio, double ou_rat, int64_t min_ou, int64_t clean_round, int64_t long_tip)
{
    ug_clean_t *sl; asg64_v b; double step; int64_t i;
    kv_init(b); hic_clean_adv(sg, uopt);
    step = (clean_round==1?max_ovlp_drop_ratio:((max_ovlp_drop_ratio-min_ovlp_drop_ratio)/(clean_round-1)));
    sl = init_ug_clean_t(uopt, sg, is_ou, is_trio, max_ext, min_ovlp_drop_ratio, ou_rat, min_ou);

    // print_debug_gfa(sg, NULL, uopt->coverage_cut, "debug", uopt->sources, uopt->ruIndex, uopt->max_hang, uopt->min_ovlp, 0, 0, 0);
    for (i = 0, sl->len_rat = min_ovlp_drop_ratio; i < clean_round; i++, sl->len_rat += step) {
        if(sl->len_rat > max_ovlp_drop_ratio) sl->len_rat = max_ovlp_drop_ratio;
        update_ug_clean_t(sl);
        kt_for(asm_opt.thread_num, cal_bub_best, sl, sl->ug->g->n_seq);
        cal_bub_best_by_len(sl, &b, max_ext, is_trio, sl->is_ou, sl->len_rat, sl->ou_rat, min_ou, long_tip);
    }

    // if(is_ou) {
    //     uint64_t k; sl->is_ou = 0;
    //     for (k = 0; k < sl->ug->g->n_arc; k++) sl->ug->g->arc[k].ou = 0;
    //     max_ovlp_drop_ratio = 0.6;
    //     if(max_ovlp_drop_ratio > min_ovlp_drop_ratio) {
    //         step = (clean_round==1?max_ovlp_drop_ratio:((max_ovlp_drop_ratio-min_ovlp_drop_ratio)/(clean_round-1)));
    //         for (i = 0, sl->len_rat = min_ovlp_drop_ratio; i < clean_round; i++, sl->len_rat += step) {
    //             if(sl->len_rat > max_ovlp_drop_ratio) sl->len_rat = max_ovlp_drop_ratio;
    //             update_ug_clean_t(sl);
    //             kt_for(asm_opt.thread_num, cal_bub_best, sl, sl->ug->g->n_seq);
    //             cal_bub_best_by_len(sl, &b, max_ext, is_trio, sl->is_ou, sl->len_rat, sl->ou_rat, min_ou);
    //         }
    //     }
    // }

    // update_ug_clean_t(sl);
    // cal_bub_best_by_topo(sl, &b, max_ext, is_trio, sl->is_ou, sl->len_rat, sl->ou_rat, min_ou, long_tip);

    kv_destroy(b); destroy_ug_clean_t(sl); free(sl);
    hic_clean_adv(sg, uopt);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %r9, %r15
movsd %xmm2, 0x30(%rsp)
movsd %xmm1, 0x10(%rsp)
movsd %xmm0, 0x18(%rsp)
movq %r8, %r12
movl %ecx, %ebp
movl %edx, %ebx
movq %rdi, %r13
movq 0x90(%rsp), %r14
xorps %xmm0, %xmm0
movaps %xmm0, 0x40(%rsp)
andq $0x0, 0x50(%rsp)
movq %rsi, 0x20(%rsp)
movq %rsi, %rdi
movq %r13, %rsi
callq 0x857d0
movsd 0x18(%rsp), %xmm0
movsd 0x10(%rsp), %xmm1
movsd %xmm1, 0x28(%rsp)
cmpq $0x1, %r14
je 0x1dd097
leaq -0x1(%r14), %rax
movsd 0x10(%rsp), %xmm1
subsd %xmm0, %xmm1
cvtsi2sd %rax, %xmm2
divsd %xmm2, %xmm1
movsd %xmm1, 0x28(%rsp)
movq %r13, 0x38(%rsp)
movq %r13, %rdi
movq 0x20(%rsp), %rsi
movl %ebx, %edx
movl %ebp, %ecx
movq %r12, %r8
movsd 0x30(%rsp), %xmm1
movq %r15, %r9
callq 0x1dd1af
movsd 0x18(%rsp), %xmm0
xorl %ebx, %ebx
testq %r14, %r14
cmovgq %r14, %rbx
movq %rax, %r13
leaq 0x40(%rsp), %r14
movsd %xmm0, 0xb0(%r13)
subq $0x1, %rbx
jb 0x1dd177
ucomisd 0x10(%rsp), %xmm0
jbe 0x1dd0fa
movsd 0x10(%rsp), %xmm0
movsd %xmm0, 0xb0(%r13)
movq %r13, %rdi
callq 0x1dd364
leaq 0x7664f(%rip), %rax     # 0x253758
movl 0x7c(%rax), %edi
movq 0x10(%r13), %rax
movq 0x18(%rax), %rax
movl 0x14(%rax), %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
leaq 0x1236(%rip), %rsi      # 0x1de35a
movq %r13, %rdx
callq 0xc67c0
movzbl 0x98(%r13), %r8d
movsd 0xb0(%r13), %xmm0
movsd 0xb8(%r13), %xmm1
movl 0x98(%rsp), %eax
movl %eax, (%rsp)
movq %r13, %rdi
movq %r14, %rsi
movl %r12d, %edx
movl %ebp, %ecx
movl %r15d, %r9d
callq 0x1dd97d
movsd 0xb0(%r13), %xmm0
addsd 0x28(%rsp), %xmm0
jmp 0x1dd0d0
movq 0x50(%rsp), %rdi
callq 0x2220
movq %r13, %rdi
callq 0x1dd311
movq %r13, %rdi
callq 0x2220
movq 0x20(%rsp), %rdi
movq 0x38(%rsp), %rsi
callq 0x857d0
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq