// File: /workspace/github_c_makefile_star2_O0/c-zhou[P]oatk/syncasm.c
// Function: scg_ra_arc_coverage
void scg_ra_arc_coverage(scg_t *g, sr_db_t *sr_db, scg_ra_v *ra_v, int refine, int verbose)
{
    uint64_t i, j, n, m, s, l0, c0, *a;
    asmg_t *utg_g;
    asmg_arc_t *arc;
    double score, intpart;
    kh_dbl_t *dup_s; // spanning duplets
    khint_t k;
    kvec_t(uint8_t) uniq;
    ra_frg_t *ra;
    int absent;
    
    utg_g = g->utg_asmg;

    dup_s = kh_dbl_init();
    kv_init(uniq);
    for (i = 0, n = ra_v->n; i < n; ++i) {
        m = ra_v->a[i].n;
        if (m < 2)
            continue;
        ra = ra_v->a[i].a;
        score = modf(ra_v->a[i].s, &intpart);
        if (score < DBL_EPSILON)
            score = 1.0;

        if (m > uniq.m)
            kv_resize(uint8_t, uniq, m);
        if (score < .99) { // score < 1.0
            // read was not uniquely mapped
            MYBZERO(uniq.a, m);
            for (j = 0; j < m; ++j) {
                a = utg_g->vtx[ra[j].uid>>1].a;
                for (s = ra[j].u_beg; s <= ra[j].u_end; ++s) {
                    if (scm_utg_n(g, a[s]>>1) == 1) {
                        // find a unique syncmer in the alignment
                        uniq.a[j] = 1;
                        break;
                    }
                }
            }
        } else {
            // no need to check one by one
            MYBONE(uniq.a, m);
        }

        for (j = 1; j < m; ++j) {
            arc = asmg_arc(utg_g, ra[j-1].uid, ra[j].uid);
            l0 = asmg_arc_id(*arc);
            c0 = asmg_comp_arc_id(arc);
            if (uniq.a[j-1] && uniq.a[j]) {
                k = kh_dbl_put(dup_s, (uint128_t) l0, &absent);
                if (absent) {
                    kh_val(dup_s, k) = score;
                    k = kh_dbl_put(dup_s, (uint128_t) c0, &absent);
                    kh_val(dup_s, k) = score;
                } else {
                    kh_val(dup_s, k) += score;
                    k = kh_dbl_put(dup_s, (uint128_t) c0, &absent);
                    kh_val(dup_s, k) += score;
                }
            }
        }
    }
    
    for (i = 0, n = utg_g->n_arc; i < n; ++i) {
        arc = &utg_g->arc[i];
        if (arc->del) continue;
        l0 = asmg_arc_id(*arc);
        k = kh_dbl_get(dup_s, l0);
        score = k < kh_end(dup_s)? kh_val(dup_s, k) : 0;
        arc->cov = (uint32_t) score;
    }

    kv_destroy(uniq);
    kh_dbl_destroy(dup_s);

    if (refine)
        scg_refine_arc_coverage(g, verbose);
    else
        asmg_arc_fix_cov(utg_g);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x110, %rsp            # imm = 0x110
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movl %r8d, -0x20(%rbp)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x68(%rbp)
callq 0x9660
movq %rax, -0x88(%rbp)
movq $0x0, -0xa0(%rbp)
movq $0x0, -0xa8(%rbp)
movq $0x0, -0x98(%rbp)
movq $0x0, -0x28(%rbp)
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x38(%rbp)
movq -0x28(%rbp), %rax
cmpq -0x38(%rbp), %rax
jae 0xd05d
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x28(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
movq %rax, -0x40(%rbp)
cmpq $0x2, -0x40(%rbp)
jae 0xcb9e
jmp 0xd04c
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x28(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq 0x10(%rax), %rax
movq %rax, -0xb0(%rbp)
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x28(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movsd 0x18(%rax), %xmm0
leaq -0x80(%rbp), %rdi
callq 0x21b0
movsd %xmm0, -0x78(%rbp)
movsd 0x20b8e(%rip), %xmm0    # 0x2d778
ucomisd -0x78(%rbp), %xmm0
jbe 0xcbfe
movsd 0x20b8f(%rip), %xmm0    # 0x2d788
movsd %xmm0, -0x78(%rbp)
movq -0x40(%rbp), %rax
cmpq -0xa0(%rbp), %rax
jbe 0xccef
jmp 0xcc11
movq -0xa0(%rbp), %rax
cmpq -0x40(%rbp), %rax
jae 0xcceb
movq -0x40(%rbp), %rax
movq %rax, -0xa0(%rbp)
movq -0xa0(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0xa0(%rbp)
movq -0xa0(%rbp), %rax
shrq %rax
orq -0xa0(%rbp), %rax
movq %rax, -0xa0(%rbp)
movq -0xa0(%rbp), %rax
shrq $0x2, %rax
orq -0xa0(%rbp), %rax
movq %rax, -0xa0(%rbp)
movq -0xa0(%rbp), %rax
shrq $0x4, %rax
orq -0xa0(%rbp), %rax
movq %rax, -0xa0(%rbp)
movq -0xa0(%rbp), %rax
shrq $0x8, %rax
orq -0xa0(%rbp), %rax
movq %rax, -0xa0(%rbp)
movq -0xa0(%rbp), %rax
shrq $0x10, %rax
orq -0xa0(%rbp), %rax
movq %rax, -0xa0(%rbp)
movq -0xa0(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xa0(%rbp)
movq -0x98(%rbp), %rdi
movq -0xa0(%rbp), %rsi
shlq $0x0, %rsi
callq 0x2360
movq %rax, -0x98(%rbp)
jmp 0xcced
jmp 0xccef
movsd 0x20a99(%rip), %xmm0    # 0x2d790
ucomisd -0x78(%rbp), %xmm0
jbe 0xce10
movq -0x98(%rbp), %rdi
movq -0x40(%rbp), %rdx
shlq $0x0, %rdx
xorl %esi, %esi
callq 0x21f0
movq $0x0, -0x30(%rbp)
movq -0x30(%rbp), %rax
cmpq -0x40(%rbp), %rax
jae 0xce0e
movq -0x68(%rbp), %rax
movq 0x10(%rax), %rax
movq -0xb0(%rbp), %rcx
movq -0x30(%rbp), %rdx
shlq $0x5, %rdx
addq %rdx, %rcx
movq (%rcx), %rcx
shrq %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movq %rax, -0x60(%rbp)
movq -0xb0(%rbp), %rax
movq -0x30(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
movq -0xb0(%rbp), %rcx
movq -0x30(%rbp), %rdx
shlq $0x5, %rdx
addq %rdx, %rcx
cmpq 0x10(%rcx), %rax
ja 0xcdfb
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x60(%rbp), %rcx
movq -0x48(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
shrq %rcx
movq 0x8(%rax,%rcx,8), %rax
movq -0x8(%rbp), %rcx
movq 0x18(%rcx), %rcx
movq -0x60(%rbp), %rdx
movq -0x48(%rbp), %rsi
movq (%rdx,%rsi,8), %rdx
shrq %rdx
movq (%rcx,%rdx,8), %rcx
subq %rcx, %rax
sarq $0x4, %rax
cmpq $0x1, %rax
jne 0xcde8
movq -0x98(%rbp), %rax
movq -0x30(%rbp), %rcx
movb $0x1, (%rax,%rcx)
jmp 0xcdfb
jmp 0xcdea
movq -0x48(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x48(%rbp)
jmp 0xcd77
jmp 0xcdfd
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
jmp 0xcd20
jmp 0xce29
movq -0x98(%rbp), %rdi
movq -0x40(%rbp), %rdx
shlq $0x0, %rdx
movl $0xff, %esi
callq 0x21f0
movq $0x1, -0x30(%rbp)
movq -0x30(%rbp), %rax
cmpq -0x40(%rbp), %rax
jae 0xd04a
movq -0x68(%rbp), %rdi
movq -0xb0(%rbp), %rax
movq -0x30(%rbp), %rcx
subq $0x1, %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq (%rax), %rsi
movq -0xb0(%rbp), %rax
movq -0x30(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq (%rax), %rdx
callq 0x6f90
movq %rax, -0x70(%rbp)
movq -0x70(%rbp), %rax
movq 0x28(%rax), %rax
shlq %rax
movq -0x70(%rbp), %rcx
movl 0x20(%rcx), %ecx
shrl $0x1f, %ecx
movl %ecx, %ecx
orq %rcx, %rax
movq %rax, -0x50(%rbp)
movq -0x70(%rbp), %rdi
callq 0x9670
movq %rax, -0x58(%rbp)
movq -0x98(%rbp), %rax
movq -0x30(%rbp), %rcx
subq $0x1, %rcx
movzbl (%rax,%rcx), %eax
cmpl $0x0, %eax
je 0xd037
movq -0x98(%rbp), %rax
movq -0x30(%rbp), %rcx
movzbl (%rax,%rcx), %eax
cmpl $0x0, %eax
je 0xd037
movq -0x88(%rbp), %rdi
movq -0x50(%rbp), %rax
movq %rax, -0xd0(%rbp)
movq $0x0, -0xc8(%rbp)
movq -0xd0(%rbp), %rsi
movq -0xc8(%rbp), %rdx
leaq -0xb4(%rbp), %rcx
callq 0x96f0
movl %eax, -0x8c(%rbp)
cmpl $0x0, -0xb4(%rbp)
je 0xcfa7
movsd -0x78(%rbp), %xmm0
movq -0x88(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x8c(%rbp), %ecx
leaq (%rcx,%rcx,2), %rcx
movsd %xmm0, 0x10(%rax,%rcx,8)
movq -0x88(%rbp), %rdi
movq -0x58(%rbp), %rax
movq %rax, -0xe0(%rbp)
movq $0x0, -0xd8(%rbp)
movq -0xe0(%rbp), %rsi
movq -0xd8(%rbp), %rdx
leaq -0xb4(%rbp), %rcx
callq 0x96f0
movl %eax, -0x8c(%rbp)
movsd -0x78(%rbp), %xmm0
movq -0x88(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x8c(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movsd %xmm0, 0x10(%rax)
jmp 0xd035
movsd -0x78(%rbp), %xmm1
movq -0x88(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x8c(%rbp), %ecx
leaq (%rcx,%rcx,2), %rcx
movsd 0x10(%rax,%rcx,8), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x10(%rax,%rcx,8)
movq -0x88(%rbp), %rdi
movq -0x58(%rbp), %rax
movq %rax, -0xf0(%rbp)
movq $0x0, -0xe8(%rbp)
movq -0xf0(%rbp), %rsi
movq -0xe8(%rbp), %rdx
leaq -0xb4(%rbp), %rcx
callq 0x96f0
movl %eax, -0x8c(%rbp)
movsd -0x78(%rbp), %xmm0
movq -0x88(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x8c(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
addsd 0x10(%rax), %xmm0
movsd %xmm0, 0x10(%rax)
jmp 0xd037
jmp 0xd039
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
jmp 0xce31
jmp 0xd04c
movq -0x28(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x28(%rbp)
jmp 0xcb6a
movq $0x0, -0x28(%rbp)
movq -0x68(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x38(%rbp)
movq -0x28(%rbp), %rax
cmpq -0x38(%rbp), %rax
jae 0xd1b4
movq -0x68(%rbp), %rax
movq 0x28(%rax), %rax
imulq $0x30, -0x28(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x70(%rbp)
movq -0x70(%rbp), %rax
movl 0x20(%rax), %eax
shrl $0x1e, %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0xd0aa
jmp 0xd1a3
movq -0x70(%rbp), %rax
movq 0x28(%rax), %rcx
movl 0x20(%rax), %eax
shrl $0x1f, %eax
leaq (%rax,%rcx,2), %rax
movq %rax, -0x50(%rbp)
movq -0x88(%rbp), %rdi
movq -0x50(%rbp), %rax
movq %rax, -0x100(%rbp)
movq $0x0, -0xf8(%rbp)
movq -0x100(%rbp), %rsi
movq -0xf8(%rbp), %rdx
callq 0x97e0
movl %eax, -0x8c(%rbp)
movl -0x8c(%rbp), %eax
movl %eax, -0x104(%rbp)
movq -0x88(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0xd128
movq -0x88(%rbp), %rax
movl (%rax), %ecx
movl $0x1, %eax
shll %cl, %eax
movl %eax, -0x108(%rbp)
jmp 0xd132
xorl %eax, %eax
movl %eax, -0x108(%rbp)
jmp 0xd132
movl -0x104(%rbp), %eax
movl -0x108(%rbp), %ecx
cmpl %ecx, %eax
jae 0xd169
movq -0x88(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x8c(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movsd 0x10(%rax), %xmm0
movsd %xmm0, -0x110(%rbp)
jmp 0xd176
xorps %xmm0, %xmm0
movsd %xmm0, -0x110(%rbp)
jmp 0xd176
movsd -0x110(%rbp), %xmm0
movsd %xmm0, -0x78(%rbp)
cvttsd2si -0x78(%rbp), %rax
movl %eax, %edx
movq -0x70(%rbp), %rax
movl 0x20(%rax), %ecx
andl $0x3fffffff, %edx       # imm = 0x3FFFFFFF
andl $0xc0000000, %ecx       # imm = 0xC0000000
orl %edx, %ecx
movl %ecx, 0x20(%rax)
movq -0x28(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x28(%rbp)
jmp 0xd071
movq -0x98(%rbp), %rdi
callq 0x2060
movq -0x88(%rbp), %rdi
callq 0x98f0
cmpl $0x0, -0x1c(%rbp)
je 0xd1e0
movq -0x8(%rbp), %rdi
movl -0x20(%rbp), %esi
callq 0xd200
jmp 0xd1e9
movq -0x68(%rbp), %rdi
callq 0x20020
addq $0x110, %rsp            # imm = 0x110
popq %rbp
retq
nopw %cs:(%rax,%rax)