// File: /workspace/github_c_makefile_star2_O0/c-zhou[P]oatk/path.c
// Function: clean_graph_by_sequence_coverage
int clean_graph_by_sequence_coverage(asg_t *asg, double min_cf, int max_copy, int verbose)
{
    uint32_t i, j, n_seg, nv;
    uint8_t *visited;
    double avg_cov;
    kvec_t(uint32_t) rm_v;
    asmg_t *g;

    g = asg->asmg;
    n_seg = asg->n_seg;
    kv_init(rm_v);

    MYCALLOC(visited, n_seg);
    for (i = 0; i < n_seg; ++i) {
        if (visited[i] || g->vtx[i].del) continue;
        asg->asmg = asg_make_asmg_copy(g, 0);
        asmg_subgraph(asg->asmg, &i, 1, 0, 0, 0, 1);
        avg_cov = graph_sequence_coverage_precise(asg, min_cf, 0, max_copy, 0);
        if (verbose > 1)
            fprintf(stderr, "[M::%s] subgraph seeding from %s per copy average coverage: %.3f\n", 
                    __func__, asg->seg[i].name, avg_cov);
        for (j = 0; j < n_seg; ++j) {
            if (asg->asmg->vtx[j].del) continue;
            if (avg_cov && asg->asmg->vtx[j].cov / avg_cov < min_cf)
                kv_push(uint32_t, rm_v, j);
            visited[j] = 1;
        }
        asmg_destroy(asg->asmg);
    }
    asg->asmg = g; // roll back

    nv = rm_v.n;
    for (i = 0; i < nv; ++i)
        asmg_vtx_del(g, rm_v.a[i], 1);
    asmg_finalize(g, 0);

    if (verbose > 1) {
        if (verbose > 2) {
            fprintf(stderr, "[M::%s] graph after cleaning\n", __func__);
            asg_print(asg, stderr, 1);
        }
        fprintf(stderr, "[M::%s] number sequence cleaned: %u\n", __func__, nv);
        for (i = 0; i < nv; ++i)
            fprintf(stderr, "[M::%s] %s removed\n", __func__, asg->seg[rm_v.a[i]].name);
        fprintf(stderr, "[M::%s] graph stats after cleaning\n", __func__);
        asg_stat(asg, stderr);
    }
    
    kv_destroy(rm_v);
    free(visited);

    return nv;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x8(%rbp)
movsd %xmm0, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movl %edx, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x58(%rbp)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movl %eax, -0x24(%rbp)
movq $0x0, -0x48(%rbp)
movq $0x0, -0x50(%rbp)
movq $0x0, -0x40(%rbp)
movl -0x24(%rbp), %eax
movl %eax, %edi
movl $0x1, %esi
callq 0x2240
movq %rax, -0x30(%rbp)
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
cmpl -0x24(%rbp), %eax
jae 0xbaf5
movq -0x30(%rbp), %rax
movl -0x1c(%rbp), %ecx
movzbl (%rax,%rcx), %eax
cmpl $0x0, %eax
jne 0xb93c
movq -0x58(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x1c(%rbp), %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl 0x20(%rax), %eax
shrl $0x1e, %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0xb941
jmp 0xbae7
movq -0x58(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0xb610
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rdi
leaq -0x1c(%rbp), %rsi
movl $0x1, %edx
xorl %ecx, %ecx
xorl %eax, %eax
movl %eax, %r9d
movq %r9, %r8
movl $0x1, (%rsp)
callq 0x1bb00
movq -0x8(%rbp), %rdi
movsd -0x10(%rbp), %xmm0
movl -0x14(%rbp), %edx
xorl %esi, %esi
xorl %eax, %eax
movl %eax, %ecx
callq 0x3f50
movsd %xmm0, -0x38(%rbp)
cmpl $0x1, -0x18(%rbp)
jle 0xb9db
movq 0x1e64f(%rip), %rax     # 0x29ff8
movq (%rax), %rdi
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x1c(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rcx
movsd -0x38(%rbp), %xmm0
leaq 0x17fd4(%rip), %rsi     # 0x239a1
leaq 0x1800f(%rip), %rdx     # 0x239e3
movb $0x1, %al
callq 0x2290
movl $0x0, -0x20(%rbp)
movl -0x20(%rbp), %eax
cmpl -0x24(%rbp), %eax
jae 0xbada
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rax
movq 0x10(%rax), %rax
movl -0x20(%rbp), %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl 0x20(%rax), %eax
shrl $0x1e, %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0xba17
jmp 0xbacc
movsd -0x38(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0xba2c
jp 0xba2c
jmp 0xbac1
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rax
movq 0x10(%rax), %rax
movl -0x20(%rbp), %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl 0x20(%rax), %eax
andl $0x3fffffff, %eax       # imm = 0x3FFFFFFF
cvtsi2sd %eax, %xmm1
divsd -0x38(%rbp), %xmm1
movsd -0x10(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0xbac1
jmp 0xba60
movq -0x50(%rbp), %rax
cmpq -0x48(%rbp), %rax
jne 0xbaa6
cmpq $0x0, -0x48(%rbp)
je 0xba7e
movq -0x48(%rbp), %rax
shlq %rax
movq %rax, -0x60(%rbp)
jmp 0xba89
movl $0x2, %eax
movq %rax, -0x60(%rbp)
jmp 0xba89
movq -0x60(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x40(%rbp), %rdi
movq -0x48(%rbp), %rsi
shlq $0x2, %rsi
callq 0x2330
movq %rax, -0x40(%rbp)
movl -0x20(%rbp), %edx
movq -0x40(%rbp), %rax
movq -0x50(%rbp), %rcx
movq %rcx, %rsi
addq $0x1, %rsi
movq %rsi, -0x50(%rbp)
movl %edx, (%rax,%rcx,4)
jmp 0xbac1
movq -0x30(%rbp), %rax
movl -0x20(%rbp), %ecx
movb $0x1, (%rax,%rcx)
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0xb9e2
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rdi
callq 0x17d40
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0xb900
movq -0x58(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x50(%rbp), %rax
movl %eax, -0x28(%rbp)
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
cmpl -0x28(%rbp), %eax
jae 0xbb3c
movq -0x58(%rbp), %rdi
movq -0x40(%rbp), %rax
movl -0x1c(%rbp), %ecx
movl (%rax,%rcx,4), %eax
movl %eax, %esi
movl $0x1, %edx
callq 0x6640
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0xbb0f
movq -0x58(%rbp), %rdi
xorl %esi, %esi
callq 0x18500
cmpl $0x1, -0x18(%rbp)
jle 0xbc37
cmpl $0x2, -0x18(%rbp)
jle 0xbb8e
movq 0x1e49a(%rip), %rax     # 0x29ff8
movq (%rax), %rdi
leaq 0x17e9c(%rip), %rsi     # 0x23a04
leaq 0x17e74(%rip), %rdx     # 0x239e3
movb $0x0, %al
callq 0x2290
movq -0x8(%rbp), %rdi
movq 0x1e477(%rip), %rax     # 0x29ff8
movq (%rax), %rsi
movl $0x1, %edx
callq 0xbc60
movq 0x1e463(%rip), %rax     # 0x29ff8
movq (%rax), %rdi
movl -0x28(%rbp), %ecx
leaq 0x17e80(%rip), %rsi     # 0x23a22
leaq 0x17e3a(%rip), %rdx     # 0x239e3
movb $0x0, %al
callq 0x2290
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
cmpl -0x28(%rbp), %eax
jae 0xbc05
movq 0x1e432(%rip), %rax     # 0x29ff8
movq (%rax), %rdi
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x40(%rbp), %rcx
movl -0x1c(%rbp), %edx
movl (%rcx,%rdx,4), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rcx
leaq 0x17e5b(%rip), %rsi     # 0x23a47
leaq 0x17df0(%rip), %rdx     # 0x239e3
movb $0x0, %al
callq 0x2290
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0xbbb7
movq 0x1e3ec(%rip), %rax     # 0x29ff8
movq (%rax), %rdi
leaq 0x17e45(%rip), %rsi     # 0x23a5b
leaq 0x17dc6(%rip), %rdx     # 0x239e3
movb $0x0, %al
callq 0x2290
movq -0x8(%rbp), %rdi
movq 0x1e3c9(%rip), %rax     # 0x29ff8
movq (%rax), %rsi
callq 0xbeb0
movq -0x40(%rbp), %rdi
callq 0x2060
movq -0x30(%rbp), %rdi
callq 0x2060
movl -0x28(%rbp), %eax
addq $0x70, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)