// File: /workspace/github_c_makefile_star2_O3/c-zhou[P]oatk/path.c
// Function: graph_sequence_coverage_lower_bound
static double graph_sequence_coverage_lower_bound(asg_t *asg, double cov_nq)
{
    uint32_t i, n_seg, len, cov;
    uint64_t *seqcovs, tot_seg_len, tot_cov, len_thresh;
    double cov_bound;
    asmg_t *g;

    g = asg->asmg;
    n_seg = 0;
    tot_seg_len = 0;
    MYMALLOC(seqcovs, g->n_vtx);
    MYBONE(seqcovs, g->n_vtx);
    for (i = 0; i < g->n_vtx; ++i) {
        if (g->vtx[i].del) continue;
        len = g->vtx[i].len;
        cov = g->vtx[i].cov;
        
        ++n_seg;
        tot_seg_len += len;
        seqcovs[i] = (uint64_t) cov << 32 | len;
    }

    qsort(seqcovs, g->n_vtx, sizeof(uint64_t), u64_cmpfunc);
    len_thresh = tot_seg_len * cov_nq;
    i = 0;
    len = (uint32_t) seqcovs[i];
    tot_seg_len = tot_cov = 0;
    while (tot_seg_len + len <= len_thresh) {
        tot_cov += (seqcovs[i] >> 32) * len;
        tot_seg_len += len;
        len = (uint32_t) seqcovs[++i];
    }
    if (tot_seg_len < len_thresh)
        tot_cov += (seqcovs[i] >> 32) * (len_thresh - tot_seg_len);
    cov_bound = (double) tot_cov / len_thresh;
    free(seqcovs);

    cov_bound *= 1 - cov_nq;

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

    return cov_bound;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %r15
movq (%rdi), %r14
leaq (,%r14,8), %r12
movq %r12, %rdi
callq 0x32f0
movq %rax, %rbx
movq %rax, %rdi
movl $0xff, %esi
movq %r12, %rdx
callq 0x31b0
testq %r14, %r14
je 0x5364
movq 0x10(%r15), %rax
addq $0x20, %rax
xorl %ecx, %ecx
xorl %edx, %edx
movl (%rax), %esi
btl $0x1e, %esi
jb 0x530c
movl -0x8(%rax), %edi
andl $0x3fffffff, %esi       # imm = 0x3FFFFFFF
addq %rdi, %rdx
shlq $0x20, %rsi
orq %rdi, %rsi
movq %rsi, (%rbx,%rcx,8)
incq %rcx
movl %ecx, %esi
addq $0x28, %rax
cmpq %rsi, %r14
ja 0x52ed
movq %rdx, %xmm0
punpckldq 0x15269(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x15271(%rip), %xmm0    # 0x1a5a0
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
mulsd 0x1516d(%rip), %xmm1    # 0x1a4b0
cvttsd2si %xmm1, %rax
movq %rax, %rcx
sarq $0x3f, %rcx
subsd 0x15161(%rip), %xmm1    # 0x1a4b8
cvttsd2si %xmm1, %r15
andq %rcx, %r15
orq %rax, %r15
jmp 0x5367
xorl %r15d, %r15d
leaq 0xbdce(%rip), %rcx      # 0x1113c
movl $0x8, %edx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x30c0
movq (%rbx), %rax
movl %eax, %edi
cmpq %r15, %rdi
jbe 0x538e
xorl %esi, %esi
xorl %ecx, %ecx
jmp 0x53b9
movl $0x1, %edx
xorl %ecx, %ecx
movq %rdi, %r8
movq %rdi, %rsi
shrq $0x20, %rax
imulq %r8, %rax
addq %rax, %rcx
movl %edx, %eax
movq (%rbx,%rax,8), %rax
movl %eax, %r8d
addq %r8, %rdi
incl %edx
cmpq %r15, %rdi
jbe 0x5398
movq %r15, %rdx
subq %rsi, %rdx
jbe 0x53cc
shrq $0x20, %rax
imulq %rdx, %rax
addq %rax, %rcx
movq %rcx, %xmm0
movq 0x151b7(%rip), %xmm1    # 0x1a590
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movapd 0x151bb(%rip), %xmm2    # 0x1a5a0
subpd %xmm2, %xmm0
movapd %xmm0, %xmm3
unpckhpd %xmm0, %xmm3            # xmm3 = xmm3[1],xmm0[1]
addsd %xmm0, %xmm3
movq %r15, %xmm0
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
subpd %xmm2, %xmm0
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
divsd %xmm1, %xmm3
movapd %xmm3, (%rsp)
movq %rbx, %rdi
callq 0x3060
movapd (%rsp), %xmm0
mulsd 0x1506c(%rip), %xmm0    # 0x1a498
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq