// File: /workspace/github_c_makefile_star2_O0/samtools[P]htslib/region.c
// Function: reg_compact
static int reg_compact(reghash_t *h) {
    khint_t i;
    uint32_t j, new_n;
    reglist_t *p;
    int count = 0;

    if (!h)
        return 0;

    for (i = kh_begin(h); i < kh_end(h); i++) {
        if (!kh_exist(h,i) || !(p = &kh_val(h,i)) || !(p->n))
            continue;

        qsort(p->a, p->n, sizeof(p->a[0]), compare_hts_pair_pos_t);
        for (new_n = 0, j = 1; j < p->n; j++) {
            if (p->a[new_n].end < p->a[j].beg) {
                p->a[++new_n].beg = p->a[j].beg;
                p->a[new_n].end = p->a[j].end;
            } else {
                if (p->a[new_n].end < p->a[j].end)
                    p->a[new_n].end = p->a[j].end;
            }
        }
        ++new_n;
        if (p->n > new_n) {
            // Shrink array to required size.
            hts_pair_pos_t *new_a = realloc(p->a, new_n * sizeof(p->a[0]));
            if (new_a) p->a = new_a;
        }
        p->n = new_n;
        count++;
    }

    return count;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movl $0x0, -0x2c(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x31016
movl $0x0, -0x4(%rbp)
jmp 0x3121b
movl $0x0, -0x14(%rbp)
movl -0x14(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl (%rcx), %eax
jae 0x31215
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x14(%rbp), %ecx
shrl $0x4, %ecx
movl %ecx, %ecx
movl (%rax,%rcx,4), %eax
movl -0x14(%rbp), %ecx
andl $0xf, %ecx
shll %ecx
shrl %cl, %eax
andl $0x3, %eax
cmpl $0x0, %eax
jne 0x31076
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movl -0x14(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x28(%rbp)
cmpq $0x0, %rax
je 0x31076
movq -0x28(%rbp), %rax
cmpl $0x0, (%rax)
jne 0x3107b
jmp 0x31207
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x28(%rbp), %rax
movl (%rax), %eax
movl %eax, %esi
movl $0x10, %edx
leaq 0xca9(%rip), %rcx       # 0x31d40
callq 0x4990
movl $0x0, -0x1c(%rbp)
movl $0x1, -0x18(%rbp)
movl -0x18(%rbp), %eax
movq -0x28(%rbp), %rcx
cmpl (%rcx), %eax
jae 0x311b2
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rax
movl -0x1c(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movq -0x28(%rbp), %rcx
movq 0x8(%rcx), %rcx
movl -0x18(%rbp), %edx
shlq $0x4, %rdx
addq %rdx, %rcx
cmpq (%rcx), %rax
jge 0x31146
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rax
movl -0x18(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rcx
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rax
movl -0x1c(%rbp), %edx
addl $0x1, %edx
movl %edx, -0x1c(%rbp)
movl %edx, %edx
shlq $0x4, %rdx
addq %rdx, %rax
movq %rcx, (%rax)
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rax
movl -0x18(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rcx
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rax
movl -0x1c(%rbp), %edx
shlq $0x4, %rdx
addq %rdx, %rax
movq %rcx, 0x8(%rax)
jmp 0x311a2
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rax
movl -0x1c(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movq -0x28(%rbp), %rcx
movq 0x8(%rcx), %rcx
movl -0x18(%rbp), %edx
shlq $0x4, %rdx
addq %rdx, %rcx
cmpq 0x8(%rcx), %rax
jge 0x311a0
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rax
movl -0x18(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rcx
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rax
movl -0x1c(%rbp), %edx
shlq $0x4, %rdx
addq %rdx, %rax
movq %rcx, 0x8(%rax)
jmp 0x311a2
jmp 0x311a4
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x310aa
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
movq -0x28(%rbp), %rax
movl (%rax), %eax
cmpl -0x1c(%rbp), %eax
jbe 0x311f5
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rdi
movl -0x1c(%rbp), %eax
movl %eax, %esi
shlq $0x4, %rsi
callq 0x4820
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
je 0x311f3
movq -0x38(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x8(%rax)
jmp 0x311f5
movl -0x1c(%rbp), %ecx
movq -0x28(%rbp), %rax
movl %ecx, (%rax)
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x3101d
movl -0x2c(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)