// File: /workspace/github_c_makefile_star2_O0/c-zhou[P]oatk/path.c
// Function: graph_sequence_coverage_rough
static double graph_sequence_coverage_rough(asg_t *asg, double min_cf)
{
    uint32_t i, j, len, cov, best1;
    double tot_len, tot_len_c, tot_rm, avg_cov, near1, diff1;
    asmg_t *g;
    kvec_t(uint64_t) lc_p;

    g = asg->asmg;
    kv_init(lc_p);
    for (i = 0; i < g->n_vtx; ++i) {
        if (g->vtx[i].del) continue;
        kv_push(uint64_t, lc_p, (uint64_t) (g->vtx[i].cov) << 32 | (g->vtx[i].len));
    }
    if (lc_p.n == 0) return .0;

    qsort(lc_p.a, lc_p.n, sizeof(uint64_t), u64_cmpfunc);

    best1 = 0;
    near1 = DBL_MAX;
    for (i = 0; i < lc_p.n; ++i) {
        avg_cov = (double) (lc_p.a[i] >> 32);
        if (avg_cov == 0)
            continue;
        tot_len = tot_len_c = tot_rm = 0;
        for (j = 0; j < lc_p.n; ++j) {
            len = (uint32_t) lc_p.a[j];
            cov = lc_p.a[j] >> 32;
            if (cov / avg_cov >= min_cf) {
                tot_len += len;
                tot_len_c += (double) len * cov / avg_cov;
            } else {
                tot_rm += len;
            }
        }

        // TODO is this good?
        if (tot_rm / (tot_rm + tot_len) > 0.7) break;

        if (tot_len > 0) {
            diff1 = fabs(tot_len_c / tot_len - 1.0);
            if (diff1 < near1) {
                near1 = diff1;
                best1 = i;
            }
#ifdef DEBUG_SEG_COV_EST
            fprintf(stderr, "[DEBUG_SEG_COV_EST::%s] seg %u [%u %lu] - len: %.0f; len_rm: %.0f; len_c: %.3f; diff1: %.3f; best: [%u %.3f]\n",
                    __func__, i, (uint32_t) lc_p.a[i], lc_p.a[i]>>32, tot_len, tot_rm, tot_len_c, diff1, best1, near1);
#endif
        }
    }
    if (near1 == DBL_MAX) {
        kv_destroy(lc_p);
        return .0;
    }

    avg_cov = (double) (lc_p.a[best1] >> 32);

#ifdef DEBUG_SEG_COV_EST
    fprintf(stderr, "[DEBUG_SEG_COV_EST::%s] estimated sequence coverage: %.3f\n", __func__, avg_cov);
#endif

    kv_destroy(lc_p);
    return avg_cov;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x10(%rbp)
movsd %xmm0, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x68(%rbp)
movq $0x0, -0x78(%rbp)
movq $0x0, -0x80(%rbp)
movq $0x0, -0x70(%rbp)
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
movq -0x68(%rbp), %rcx
cmpq (%rcx), %rax
jae 0x4884
movq -0x68(%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 0x47d4
jmp 0x4876
jmp 0x47d6
movq -0x80(%rbp), %rax
cmpq -0x78(%rbp), %rax
jne 0x4825
cmpq $0x0, -0x78(%rbp)
je 0x47f7
movq -0x78(%rbp), %rax
shlq %rax
movq %rax, -0x88(%rbp)
jmp 0x4805
movl $0x2, %eax
movq %rax, -0x88(%rbp)
jmp 0x4805
movq -0x88(%rbp), %rax
movq %rax, -0x78(%rbp)
movq -0x70(%rbp), %rdi
movq -0x78(%rbp), %rsi
shlq $0x3, %rsi
callq 0x2330
movq %rax, -0x70(%rbp)
movq -0x68(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x1c(%rbp), %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl 0x20(%rax), %eax
andl $0x3fffffff, %eax       # imm = 0x3FFFFFFF
movl %eax, %eax
movl %eax, %edx
shlq $0x20, %rdx
movq -0x68(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x1c(%rbp), %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
orq 0x18(%rax), %rdx
movq -0x70(%rbp), %rax
movq -0x80(%rbp), %rcx
movq %rcx, %rsi
addq $0x1, %rsi
movq %rsi, -0x80(%rbp)
movq %rdx, (%rax,%rcx,8)
jmp 0x4876
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x479f
cmpq $0x0, -0x80(%rbp)
jne 0x4898
xorps %xmm0, %xmm0
movsd %xmm0, -0x8(%rbp)
jmp 0x4a94
movq -0x70(%rbp), %rdi
movq -0x80(%rbp), %rsi
movl $0x8, %edx
leaq 0xee94(%rip), %rcx      # 0x13740
callq 0x20c0
movl $0x0, -0x2c(%rbp)
movsd 0x1ebd8(%rip), %xmm0    # 0x23498
movsd %xmm0, -0x58(%rbp)
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
cmpq -0x80(%rbp), %rax
jae 0x4a44
movq -0x70(%rbp), %rax
movl -0x1c(%rbp), %ecx
movl 0x4(%rax,%rcx,8), %eax
cvtsi2sd %rax, %xmm0
movsd %xmm0, -0x50(%rbp)
movsd -0x50(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x4903
jp 0x4903
jmp 0x4a36
xorps %xmm0, %xmm0
movsd %xmm0, -0x48(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x40(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x38(%rbp)
movl $0x0, -0x20(%rbp)
movl -0x20(%rbp), %eax
cmpq -0x80(%rbp), %rax
jae 0x49bb
movq -0x70(%rbp), %rax
movl -0x20(%rbp), %ecx
movl (%rax,%rcx,8), %eax
movl %eax, -0x24(%rbp)
movq -0x70(%rbp), %rax
movl -0x20(%rbp), %ecx
movl 0x4(%rax,%rcx,8), %eax
movl %eax, -0x28(%rbp)
movl -0x28(%rbp), %eax
cvtsi2sd %rax, %xmm0
divsd -0x50(%rbp), %xmm0
ucomisd -0x18(%rbp), %xmm0
jb 0x4999
movl -0x24(%rbp), %eax
cvtsi2sd %rax, %xmm1
movsd -0x38(%rbp), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x38(%rbp)
movl -0x24(%rbp), %eax
cvtsi2sd %rax, %xmm0
movl -0x28(%rbp), %eax
cvtsi2sd %rax, %xmm1
mulsd %xmm1, %xmm0
divsd -0x50(%rbp), %xmm0
addsd -0x40(%rbp), %xmm0
movsd %xmm0, -0x40(%rbp)
jmp 0x49ab
movl -0x24(%rbp), %eax
cvtsi2sd %rax, %xmm0
addsd -0x48(%rbp), %xmm0
movsd %xmm0, -0x48(%rbp)
jmp 0x49ad
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x4922
movsd -0x48(%rbp), %xmm0
movsd -0x48(%rbp), %xmm1
addsd -0x38(%rbp), %xmm1
divsd %xmm1, %xmm0
movsd 0x1eada(%rip), %xmm1    # 0x234b0
ucomisd %xmm1, %xmm0
jbe 0x49de
jmp 0x4a44
movsd -0x38(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x4a34
movsd -0x40(%rbp), %xmm0
divsd -0x38(%rbp), %xmm0
movsd 0x1eaaa(%rip), %xmm1    # 0x234a8
subsd %xmm1, %xmm0
movaps 0x1eb57(%rip), %xmm1    # 0x23560
pand %xmm1, %xmm0
movsd %xmm0, -0x60(%rbp)
movsd -0x60(%rbp), %xmm1
movsd -0x58(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x4a32
movsd -0x60(%rbp), %xmm0
movsd %xmm0, -0x58(%rbp)
movl -0x1c(%rbp), %eax
movl %eax, -0x2c(%rbp)
jmp 0x4a34
jmp 0x4a36
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x48cc
movsd -0x58(%rbp), %xmm0
movsd 0x1ea47(%rip), %xmm1    # 0x23498
ucomisd %xmm1, %xmm0
jne 0x4a6c
jp 0x4a6c
movq -0x70(%rbp), %rdi
callq 0x2060
xorps %xmm0, %xmm0
movsd %xmm0, -0x8(%rbp)
jmp 0x4a94
movq -0x70(%rbp), %rax
movl -0x2c(%rbp), %ecx
movl 0x4(%rax,%rcx,8), %eax
cvtsi2sd %rax, %xmm0
movsd %xmm0, -0x50(%rbp)
movq -0x70(%rbp), %rdi
callq 0x2060
movsd -0x50(%rbp), %xmm0
movsd %xmm0, -0x8(%rbp)
movsd -0x8(%rbp), %xmm0
addq $0x90, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)