// File: /workspace/github_c_makefile_star2_O0/c-zhou[P]yahs/cov.c
// Function: pos_compression
uint64_t pos_compression(cov_t *cov)
{
    uint32_t i, p, p1;
    int32_t c;
    size_t j, k, n;
    uint64_t m, *a;
    
    m = 0;
    for (i = 0; i < cov->n; ++i) {
        a = cov->p[i].a;
        n = cov->p[i].n;
        if (n == 0) continue;

        qsort(a, n, sizeof(uint64_t), u64_cmpfunc);
        p = (uint32_t) (a[0] >> 32);
        c = (int32_t) a[0];
        k = 0;
        for(j = 1; j < n; ++j) {
            p1 = (uint32_t) (a[j] >> 32);
            if (p != p1) {
                if (c != 0) a[k++] = (uint64_t) p << 32 | (uint32_t) c;
                p = p1;
                c = (int32_t) a[j];
            } else {
                c += (int32_t) a[j];
            }
        }
        if (c != 0) a[k++] = (uint64_t) p << 32 | (uint32_t) c;
        cov->p[i].n = k;
        m += k;
    }

    return m;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq $0x0, -0x38(%rbp)
movl $0x0, -0xc(%rbp)
movl -0xc(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl (%rcx), %eax
jae 0x1d1ea
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movl -0xc(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq 0x10(%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movl -0xc(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rax
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
jne 0x1d0b9
jmp 0x1d1dc
movq -0x40(%rbp), %rdi
movq -0x30(%rbp), %rsi
movl $0x8, %edx
leaq 0x133(%rip), %rcx       # 0x1d200
callq 0x20e0
movq -0x40(%rbp), %rax
movq (%rax), %rax
shrq $0x20, %rax
movl %eax, -0x10(%rbp)
movq -0x40(%rbp), %rax
movq (%rax), %rax
movl %eax, -0x18(%rbp)
movq $0x0, -0x28(%rbp)
movq $0x1, -0x20(%rbp)
movq -0x20(%rbp), %rax
cmpq -0x30(%rbp), %rax
jae 0x1d18b
movq -0x40(%rbp), %rax
movq -0x20(%rbp), %rcx
movq (%rax,%rcx,8), %rax
shrq $0x20, %rax
movl %eax, -0x14(%rbp)
movl -0x10(%rbp), %eax
cmpl -0x14(%rbp), %eax
je 0x1d166
cmpl $0x0, -0x18(%rbp)
je 0x1d14f
movl -0x10(%rbp), %eax
movl %eax, %edx
shlq $0x20, %rdx
movl -0x18(%rbp), %eax
orq %rax, %rdx
movq -0x40(%rbp), %rax
movq -0x28(%rbp), %rcx
movq %rcx, %rsi
addq $0x1, %rsi
movq %rsi, -0x28(%rbp)
movq %rdx, (%rax,%rcx,8)
movl -0x14(%rbp), %eax
movl %eax, -0x10(%rbp)
movq -0x40(%rbp), %rax
movq -0x20(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movl %eax, -0x18(%rbp)
jmp 0x1d178
movq -0x40(%rbp), %rax
movq -0x20(%rbp), %rcx
movq (%rax,%rcx,8), %rax
addl -0x18(%rbp), %eax
movl %eax, -0x18(%rbp)
jmp 0x1d17a
movq -0x20(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x20(%rbp)
jmp 0x1d0fa
cmpl $0x0, -0x18(%rbp)
je 0x1d1b7
movl -0x10(%rbp), %eax
movl %eax, %edx
shlq $0x20, %rdx
movl -0x18(%rbp), %eax
orq %rax, %rdx
movq -0x40(%rbp), %rax
movq -0x28(%rbp), %rcx
movq %rcx, %rsi
addq $0x1, %rsi
movq %rsi, -0x28(%rbp)
movq %rdx, (%rax,%rcx,8)
movq -0x28(%rbp), %rcx
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movl -0xc(%rbp), %edx
imulq $0x18, %rdx, %rdx
addq %rdx, %rax
movq %rcx, (%rax)
movq -0x28(%rbp), %rax
addq -0x38(%rbp), %rax
movq %rax, -0x38(%rbp)
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x1d06b
movq -0x38(%rbp), %rax
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)