// File: /workspace/github_cpp_makefile_star2_O3/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, %r14d
movl %edx, %ebp
movq %rdi, %r13
movq 0x90(%rsp), %rbx
xorps %xmm0, %xmm0
movaps %xmm0, 0x40(%rsp)
movq $0x0, 0x50(%rsp)
movq %rsi, 0x20(%rsp)
movq %rsi, %rdi
movq %r13, %rsi
callq 0xc1328
movsd 0x18(%rsp), %xmm0
movsd 0x10(%rsp), %xmm1
movsd %xmm1, 0x28(%rsp)
cmpq $0x1, %rbx
je 0x22af07
leaq -0x1(%rbx), %rax
movsd 0x10(%rsp), %xmm1
subsd %xmm0, %xmm1
xorps %xmm2, %xmm2
cvtsi2sd %rax, %xmm2
divsd %xmm2, %xmm1
movsd %xmm1, 0x28(%rsp)
movq %r13, 0x38(%rsp)
movq %r13, %rdi
movq 0x20(%rsp), %rsi
movl %ebp, %edx
movl %r14d, %ecx
movq %r12, %r8
movsd 0x30(%rsp), %xmm1
movq %r15, %r9
callq 0x22b02b
movsd 0x18(%rsp), %xmm0
movq %rax, %r13
movsd %xmm0, 0xb0(%rax)
testq %rbx, %rbx
jle 0x22aff6
movzbl %r14b, %ebp
leaq 0x40(%rsp), %r14
ucomisd 0x10(%rsp), %xmm0
jbe 0x22af64
movsd 0x10(%rsp), %xmm0
movsd %xmm0, 0xb0(%r13)
movq %r13, %rdi
callq 0x22b1f3
leaq 0x6a7e5(%rip), %rax     # 0x295758
movl 0x7c(%rax), %edi
movq 0x10(%r13), %rax
movq 0x18(%rax), %rax
movl 0x14(%rax), %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
leaq 0x16ea(%rip), %rsi      # 0x22c678
movq %r13, %rdx
callq 0x108f2c
movzbl 0x98(%r13), %r8d
movsd 0xb0(%r13), %xmm0
movsd 0xb8(%r13), %xmm1
movq 0x98(%rsp), %rax
movl %eax, (%rsp)
movq %r13, %rdi
movq %r14, %rsi
movl %r12d, %edx
movl %ebp, %ecx
movl %r15d, %r9d
callq 0x22b92d
movsd 0xb0(%r13), %xmm0
addsd 0x28(%rsp), %xmm0
movsd %xmm0, 0xb0(%r13)
decq %rbx
jne 0x22af4d
movq 0x50(%rsp), %rdi
jmp 0x22aff8
xorl %edi, %edi
callq 0x2220
movq %r13, %rdi
callq 0x22b1a0
movq %r13, %rdi
callq 0x2220
movq 0x20(%rsp), %rdi
movq 0x38(%rsp), %rsi
callq 0xc1328
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq