// File: /workspace/github_c_makefile_star2_O0/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 %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movsd %xmm0, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x50(%rbp)
movl $0x0, -0x18(%rbp)
movq $0x0, -0x30(%rbp)
movq -0x50(%rbp), %rax
movq (%rax), %rdi
shlq $0x3, %rdi
callq 0x22f0
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rdi
movq -0x50(%rbp), %rax
movq (%rax), %rdx
shlq $0x3, %rdx
movl $0xff, %esi
callq 0x21c0
movl $0x0, -0x14(%rbp)
movl -0x14(%rbp), %eax
movq -0x50(%rbp), %rcx
cmpq (%rcx), %rax
jae 0x45d4
movq -0x50(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x14(%rbp), %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl 0x20(%rax), %eax
shrl $0x1e, %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x4562
jmp 0x45c6
movq -0x50(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x14(%rbp), %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq 0x18(%rax), %rax
movl %eax, -0x1c(%rbp)
movq -0x50(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x14(%rbp), %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl 0x20(%rax), %eax
andl $0x3fffffff, %eax       # imm = 0x3FFFFFFF
movl %eax, -0x20(%rbp)
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
movl -0x1c(%rbp), %eax
addq -0x30(%rbp), %rax
movq %rax, -0x30(%rbp)
movl -0x20(%rbp), %eax
movl %eax, %edx
shlq $0x20, %rdx
movl -0x1c(%rbp), %eax
orq %rax, %rdx
movq -0x28(%rbp), %rax
movl -0x14(%rbp), %ecx
movq %rdx, (%rax,%rcx,8)
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x4530
movq -0x28(%rbp), %rdi
movq -0x50(%rbp), %rax
movq (%rax), %rsi
leaq 0xf15a(%rip), %rcx      # 0x13740
movl $0x8, %edx
callq 0x20c0
movaps 0x1ef79(%rip), %xmm1    # 0x23570
movq -0x30(%rbp), %xmm0
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movapd 0x1ef78(%rip), %xmm1    # 0x23580
subpd %xmm1, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movsd -0x10(%rbp), %xmm1
mulsd %xmm1, %xmm0
movaps %xmm0, %xmm1
cvttsd2si %xmm1, %rax
movq %rax, %rdx
sarq $0x3f, %rdx
movsd 0x1ee69(%rip), %xmm1    # 0x234a0
subsd %xmm1, %xmm0
cvttsd2si %xmm0, %rcx
andq %rdx, %rcx
orq %rcx, %rax
movq %rax, -0x40(%rbp)
movl $0x0, -0x14(%rbp)
movq -0x28(%rbp), %rax
movl -0x14(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movl %eax, -0x1c(%rbp)
movq $0x0, -0x38(%rbp)
movq $0x0, -0x30(%rbp)
movq -0x30(%rbp), %rax
movl -0x1c(%rbp), %ecx
addq %rcx, %rax
cmpq -0x40(%rbp), %rax
ja 0x46c0
movq -0x28(%rbp), %rax
movl -0x14(%rbp), %ecx
movq (%rax,%rcx,8), %rax
shrq $0x20, %rax
movl -0x1c(%rbp), %ecx
imulq %rcx, %rax
addq -0x38(%rbp), %rax
movq %rax, -0x38(%rbp)
movl -0x1c(%rbp), %eax
addq -0x30(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x28(%rbp), %rax
movl -0x14(%rbp), %ecx
addl $0x1, %ecx
movl %ecx, -0x14(%rbp)
movl %ecx, %ecx
movq (%rax,%rcx,8), %rax
movl %eax, -0x1c(%rbp)
jmp 0x466f
movq -0x30(%rbp), %rax
cmpq -0x40(%rbp), %rax
jae 0x46ed
movq -0x28(%rbp), %rax
movl -0x14(%rbp), %ecx
movq (%rax,%rcx,8), %rax
shrq $0x20, %rax
movq -0x40(%rbp), %rcx
subq -0x30(%rbp), %rcx
imulq %rcx, %rax
addq -0x38(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %xmm0
movaps 0x1ee77(%rip), %xmm3    # 0x23570
punpckldq %xmm3, %xmm0    # xmm0 = xmm0[0],xmm3[0],xmm0[1],xmm3[1]
movapd 0x1ee7b(%rip), %xmm2    # 0x23580
subpd %xmm2, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movq -0x40(%rbp), %xmm1
punpckldq %xmm3, %xmm1    # xmm1 = xmm1[0],xmm3[0],xmm1[1],xmm3[1]
subpd %xmm2, %xmm1
movaps %xmm1, %xmm2
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
addsd %xmm2, %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0x48(%rbp)
movq -0x28(%rbp), %rdi
callq 0x2060
movsd 0x1ed62(%rip), %xmm0    # 0x234a8
subsd -0x10(%rbp), %xmm0
mulsd -0x48(%rbp), %xmm0
movsd %xmm0, -0x48(%rbp)
movsd -0x48(%rbp), %xmm0
addq $0x50, %rsp
popq %rbp
retq