// File: /workspace/github_cpp_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rdx, 0x8(%rsp)
movq %rdi, %r14
movq %rsi, 0x10(%rsp)
movl 0x14(%rsi), %r13d
movl $0x7fffffff, %ebx       # imm = 0x7FFFFFFF
andq %rbx, %r13
movl $0x8, %esi
movq %r13, %rdi
callq 0x2120
movq %rax, (%rsp)
movl $0x1, %esi
movq %r13, %rdi
callq 0x2120
movq %rax, %r13
movq 0x18(%r14), %rax
movl 0x14(%rax), %ecx
andq %rbx, %rcx
movq %rcx, 0x28(%rsp)
je 0xc5ddc
movq 0x20(%rax), %rax
movq %rax, 0x20(%rsp)
xorl %ebx, %ebx
movq %r14, 0x18(%rsp)
movq 0x20(%rsp), %rax
cmpl $0x0, (%rax,%rbx,8)
js 0xc5dce
movq %r14, %rdi
movl %ebx, %esi
movq %r13, %rdx
movl $0x1, %ecx
callq 0xc5a70
movq 0x10(%r14), %rax
movq %rbx, 0x30(%rsp)
leaq (%rbx,%rbx,4), %rcx
movl 0x10(%rax,%rcx,8), %edx
movq %rdx, 0x40(%rsp)
testq %rdx, %rdx
movq 0x8(%rsp), %rdx
je 0xc5db5
leaq (%rax,%rcx,8), %rax
movq 0x18(%rax), %rax
movq %rax, 0x38(%rsp)
xorl %ecx, %ecx
movq 0x38(%rsp), %rax
movq %rcx, 0x50(%rsp)
movq (%rax,%rcx,8), %rax
shrq $0x21, %rax
movq %rax, 0x48(%rsp)
leaq (%rax,%rax,2), %rcx
movl 0xc(%rdx,%rcx,8), %eax
testq %rax, %rax
je 0xc5d88
leaq (%rdx,%rcx,8), %rcx
movq (%rcx), %rbp
movq 0x10(%rsp), %rcx
movq 0x20(%rcx), %r14
shlq $0x3, %rax
leaq (%rax,%rax,4), %rbx
xorl %r12d, %r12d
xorl %r15d, %r15d
movl 0xc(%rbp,%r12), %ecx
movl (%r14,%rcx,8), %eax
testl %eax, %eax
js 0xc5d55
cmpb $0x0, (%r13,%rcx)
je 0xc5d7d
testl %eax, %eax
jns 0xc5d70
movq 0x10(%rsp), %rdi
movq 0x8(%rsp), %rsi
movq %r13, %rdx
callq 0xc5bd3
movq 0x8(%rsp), %rdx
testl %eax, %eax
je 0xc5d7d
movl 0x8(%rbp,%r12), %eax
subl (%rbp,%r12), %eax
addq %rax, %r15
addq $0x28, %r12
cmpq %r12, %rbx
jne 0xc5d3c
jmp 0xc5d8b
xorl %r15d, %r15d
movq (%rsp), %rax
movq 0x48(%rsp), %rsi
cmpq (%rax,%rsi,8), %r15
movq 0x50(%rsp), %rcx
jbe 0xc5da7
movq (%rsp), %rax
movq %r15, (%rax,%rsi,8)
incq %rcx
cmpq 0x40(%rsp), %rcx
jne 0xc5cfa
movq 0x18(%rsp), %r14
movq %r14, %rdi
movq 0x30(%rsp), %rbx
movl %ebx, %esi
movq %r13, %rdx
xorl %ecx, %ecx
callq 0xc5a70
incq %rbx
cmpq 0x28(%rsp), %rbx
jne 0xc5ca6
movq %r13, %rdi
callq 0x2220
movq (%rsp), %rax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq