// File: chhylp123[P]hifiasm/Overlaps.cpp
// Function: debug_hapS(unsigned int*, unsigned int)
void debug_hapS(uint32_t *hapS, uint32_t rn)
{
    uint32_t i, p, tot, nt, max_tot = 0, *occ = NULL, *freq = NULL;
    for (i = 0; i < rn; i++) {
        for (p = hapS[i], tot = 0; p; p>>=1, tot++);   
        max_tot = MAX(max_tot, tot); 
    }
    fprintf(stderr, "[M::%s:] ==> %u haplotypes in total\n", __func__, max_tot);
    if(max_tot){
        CALLOC(occ, max_tot+1);
        CALLOC(freq, max_tot+1);
        for (i = 0; i < rn; i++) {
            for (p = hapS[i], tot = nt = 0; p; p>>=1, tot++){
                if(p&1) occ[tot+1]++, nt++;
            }
            freq[nt]++;
        }
        for (i = 1; i <= max_tot; i++) {
            fprintf(stderr, "[M::%s:] ==> # reads in hap%u: %u\n", __func__, i, occ[i]);
        }
        for (i = 0; i <= max_tot; i++) {
            fprintf(stderr, "[M::%s:] ==> # reads within %u haplotypes: %u\n", __func__, i, freq[i]);
        }
        free(occ); free(freq);
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl $0x0, -0x20(%rbp)
movq $0x0, -0x28(%rbp)
movq $0x0, -0x30(%rbp)
movl $0x0, -0x10(%rbp)
movl -0x10(%rbp), %eax
cmpl -0xc(%rbp), %eax
jae 0x1009bb
movq -0x8(%rbp), %rax
movl -0x10(%rbp), %ecx
movl (%rax,%rcx,4), %eax
movl %eax, -0x14(%rbp)
movl $0x0, -0x18(%rbp)
cmpl $0x0, -0x14(%rbp)
je 0x100994
jmp 0x100981
movl -0x14(%rbp), %eax
shrl %eax
movl %eax, -0x14(%rbp)
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x100979
movl -0x20(%rbp), %eax
cmpl -0x18(%rbp), %eax
jb 0x1009a4
movl -0x20(%rbp), %eax
movl %eax, -0x34(%rbp)
jmp 0x1009aa
movl -0x18(%rbp), %eax
movl %eax, -0x34(%rbp)
movl -0x34(%rbp), %eax
movl %eax, -0x20(%rbp)
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0x10095d
movq 0x2c361e(%rip), %rax    # 0x3c3fe0
movq (%rax), %rdi
movl -0x20(%rbp), %ecx
leaq 0x286b36(%rip), %rsi    # 0x387505
leaq 0x286b54(%rip), %rdx    # 0x38752a
movb $0x0, %al
callq 0x22a0
cmpl $0x0, -0x20(%rbp)
je 0x100b43
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, %eax
movl %eax, %edi
movl $0x4, %esi
callq 0x2140
movq %rax, -0x28(%rbp)
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, %eax
movl %eax, %edi
movl $0x4, %esi
callq 0x2140
movq %rax, -0x30(%rbp)
movl $0x0, -0x10(%rbp)
movl -0x10(%rbp), %eax
cmpl -0xc(%rbp), %eax
jae 0x100aa3
movq -0x8(%rbp), %rax
movl -0x10(%rbp), %ecx
movl (%rax,%rcx,4), %eax
movl %eax, -0x14(%rbp)
movl $0x0, -0x1c(%rbp)
movl $0x0, -0x18(%rbp)
cmpl $0x0, -0x14(%rbp)
je 0x100a85
movl -0x14(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x100a70
movq -0x28(%rbp), %rax
movl -0x18(%rbp), %ecx
addl $0x1, %ecx
movl %ecx, %ecx
movl (%rax,%rcx,4), %edx
addl $0x1, %edx
movl %edx, (%rax,%rcx,4)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x100a72
movl -0x14(%rbp), %eax
shrl %eax
movl %eax, -0x14(%rbp)
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x100a41
movq -0x30(%rbp), %rax
movl -0x1c(%rbp), %ecx
movl (%rax,%rcx,4), %edx
addl $0x1, %edx
movl %edx, (%rax,%rcx,4)
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0x100a1e
movl $0x1, -0x10(%rbp)
movl -0x10(%rbp), %eax
cmpl -0x20(%rbp), %eax
ja 0x100aea
movq 0x2c3527(%rip), %rax    # 0x3c3fe0
movq (%rax), %rdi
movl -0x10(%rbp), %ecx
movq -0x28(%rbp), %rax
movl -0x10(%rbp), %edx
movl (%rax,%rdx,4), %r8d
leaq 0x286a64(%rip), %rsi    # 0x387535
leaq 0x286a52(%rip), %rdx    # 0x38752a
movb $0x0, %al
callq 0x22a0
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0x100aaa
movl $0x0, -0x10(%rbp)
movl -0x10(%rbp), %eax
cmpl -0x20(%rbp), %eax
ja 0x100b31
movq 0x2c34e0(%rip), %rax    # 0x3c3fe0
movq (%rax), %rdi
movl -0x10(%rbp), %ecx
movq -0x30(%rbp), %rax
movl -0x10(%rbp), %edx
movl (%rax,%rdx,4), %r8d
leaq 0x286a40(%rip), %rsi    # 0x387558
leaq 0x286a0b(%rip), %rdx    # 0x38752a
movb $0x0, %al
callq 0x22a0
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0x100af1
movq -0x28(%rbp), %rdi
callq 0x2210
movq -0x30(%rbp), %rdi
callq 0x2210
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax)