// File: chhylp123[P]hifiasm/Overlaps.cpp
// Function: gen_cov_rg(ma_ug_t*, asg_t*, ma_hit_t_alloc*)
uint64_t *gen_cov_rg(ma_ug_t *ug, asg_t *sg, ma_hit_t_alloc *src)
{
    uint32_t i, k, rid, j, tn; uint8_t *ff; 
    uint64_t C_bases, *cc; ma_hit_t *h; ma_utg_t *u;
    CALLOC(cc, sg->n_seq); CALLOC(ff, sg->n_seq);

    for (i = 0; i < ug->g->n_seq; i++) {
        if(ug->g->seq[i].del) continue;
        set_rset(ug, i, ff, 1);

        u = &(ug->u.a[i]);
        for (k = 0; k < u->n; k++) {
            C_bases = 0; rid = u->a[k]>>33;
            for (j = 0; j < src[rid].length; j++) {
                h = &(src[rid].buffer[j]);
                tn = Get_tn((*h));
                if((!sg->seq[tn].del) && (!ff[tn])) continue;
                if((sg->seq[tn].del) && (!check_nc_status(sg, src, ff, tn))) continue;
                C_bases += (Get_qe((*h)) - Get_qs((*h)));
            }
            if(C_bases > cc[rid]) cc[rid] = C_bases;
        }

        set_rset(ug, i, ff, 0);
    }
    free(ff);

    return cc;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x10(%rbp), %rax
movl 0x14(%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movl %eax, %eax
movl %eax, %edi
movl $0x8, %esi
callq 0x2140
movq %rax, -0x48(%rbp)
movq -0x10(%rbp), %rax
movl 0x14(%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movl %eax, %eax
movl %eax, %edi
movl $0x1, %esi
callq 0x2140
movq %rax, -0x38(%rbp)
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
movq -0x8(%rbp), %rcx
movq 0x18(%rcx), %rcx
movl 0x14(%rcx), %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
cmpl %ecx, %eax
jae 0x107b3a
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movq 0x20(%rax), %rax
movl -0x1c(%rbp), %ecx
movl (%rax,%rcx,8), %eax
shrl $0x1f, %eax
cmpl $0x0, %eax
je 0x1079c2
jmp 0x107b2c
movq -0x8(%rbp), %rdi
movl -0x1c(%rbp), %esi
movq -0x38(%rbp), %rdx
movl $0x1, %ecx
callq 0x107590
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x1c(%rbp), %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x58(%rbp)
movl $0x0, -0x20(%rbp)
movl -0x20(%rbp), %eax
movq -0x58(%rbp), %rcx
cmpl 0x10(%rcx), %eax
jae 0x107b1a
movq $0x0, -0x40(%rbp)
movq -0x58(%rbp), %rax
movq 0x18(%rax), %rax
movl -0x20(%rbp), %ecx
movq (%rax,%rcx,8), %rax
shrq $0x21, %rax
movl %eax, -0x24(%rbp)
movl $0x0, -0x28(%rbp)
movl -0x28(%rbp), %eax
movq -0x18(%rbp), %rcx
movl -0x24(%rbp), %edx
imulq $0x18, %rdx, %rdx
addq %rdx, %rcx
cmpl 0xc(%rcx), %eax
jae 0x107aea
movq -0x18(%rbp), %rax
movl -0x24(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rax
movl -0x28(%rbp), %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
movl 0xc(%rax), %eax
movl %eax, -0x2c(%rbp)
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movl -0x2c(%rbp), %ecx
movl (%rax,%rcx,8), %eax
shrl $0x1f, %eax
cmpl $0x0, %eax
jne 0x107a91
movq -0x38(%rbp), %rax
movl -0x2c(%rbp), %ecx
cmpb $0x0, (%rax,%rcx)
jne 0x107a91
jmp 0x107adc
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movl -0x2c(%rbp), %ecx
movl (%rax,%rcx,8), %eax
shrl $0x1f, %eax
cmpl $0x0, %eax
je 0x107ac2
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x38(%rbp), %rdx
movl -0x2c(%rbp), %ecx
callq 0x107850
cmpl $0x0, %eax
jne 0x107ac2
jmp 0x107adc
movq -0x50(%rbp), %rax
movl 0x8(%rax), %eax
movq -0x50(%rbp), %rcx
movq (%rcx), %rcx
subl %ecx, %eax
movl %eax, %eax
addq -0x40(%rbp), %rax
movq %rax, -0x40(%rbp)
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x107a29
movq -0x40(%rbp), %rax
movq -0x48(%rbp), %rcx
movl -0x24(%rbp), %edx
cmpq (%rcx,%rdx,8), %rax
jbe 0x107b0a
movq -0x40(%rbp), %rdx
movq -0x48(%rbp), %rax
movl -0x24(%rbp), %ecx
movq %rdx, (%rax,%rcx,8)
jmp 0x107b0c
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x1079f4
movq -0x8(%rbp), %rdi
movl -0x1c(%rbp), %esi
movq -0x38(%rbp), %rdx
xorl %ecx, %ecx
callq 0x107590
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x107987
movq -0x38(%rbp), %rdi
callq 0x2210
movq -0x48(%rbp), %rax
addq $0x60, %rsp
popq %rbp
retq
nopl (%rax)