// File: /workspace/github_c_makefile_star2_O1/samtools[P]htslib/hts.c
// Function: reg2bins
static inline int reg2bins(int64_t beg, int64_t end, hts_itr_t *itr, int min_shift, int n_lvls, bidx_t *bidx)
{
    int l, t, s = min_shift + (n_lvls<<1) + n_lvls;
    size_t reg_bin_count = 0, hash_bin_count = kh_n_buckets(bidx), max_bins;
    hts_pos_t end1;
    if (end >= 1LL<<s) end = 1LL<<s;
    if (beg >= end) return 0;
    end1 = end - 1;

    // Count bins to see if it's faster to iterate through the hash table
    // or the set of bins covering the region
    for (l = 0, t = 0; l <= n_lvls; s -= 3, t += 1<<((l<<1)+l), ++l) {
        reg_bin_count += (end1 >> s) - (beg >> s) + 1;
    }
    max_bins = reg_bin_count < kh_size(bidx) ? reg_bin_count : kh_size(bidx);
    if (itr->bins.m - itr->bins.n < max_bins) {
        // Worst-case memory usage.  May be wasteful on very sparse
        // data, but the bin list usually won't be too big anyway.
        size_t new_m = max_bins + itr->bins.n;
        if (new_m > INT_MAX || new_m > SIZE_MAX / sizeof(int)) {
            errno = ENOMEM;
            return -1;
        }
        int *new_a = realloc(itr->bins.a, new_m * sizeof(*new_a));
        if (!new_a) return -1;
        itr->bins.a = new_a;
        itr->bins.m = new_m;
    }
    if (reg_bin_count < hash_bin_count) {
        return reg2bins_narrow(beg, end, itr, min_shift, n_lvls, bidx);
    } else {
        return reg2bins_wide(beg, end, itr, min_shift, n_lvls, bidx);
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %ecx, %r10d
movq %rdx, %r14
leal (%r8,%r10), %eax
movq %rax, %rbp
leal (%rax,%r8,2), %ecx
movl $0x1, %edx
shlq %cl, %rdx
cmpq %rsi, %rdx
cmovgeq %rsi, %rdx
xorl %eax, %eax
cmpq %rdi, %rdx
jle 0x18a06
movq %r9, %rbx
decq %rdx
testl %r8d, %r8d
js 0x18753
leal 0x1(%r8), %eax
xorl %r15d, %r15d
movq %rdx, %r9
sarq %cl, %rdx
movq %rdi, %rsi
sarq %cl, %rsi
subq %rsi, %r15
addq %rdx, %r15
incq %r15
movq %r9, %rdx
addl $-0x3, %ecx
decl %eax
jne 0x18732
jmp 0x18756
xorl %r15d, %r15d
movl (%rbx), %esi
movl 0x4(%rbx), %r12d
cmpq %r12, %r15
cmovbq %r15, %r12
movslq 0x84(%r14), %rcx
movslq 0x80(%r14), %rax
subq %rax, %rcx
cmpq %rcx, %r12
movq %r8, (%rsp)
movq %rdx, 0x18(%rsp)
jbe 0x187e7
addq %rax, %r12
testq $-0x80000000, %r12      # imm = 0x80000000
je 0x1879e
callq 0x4050
movl $0xc, (%rax)
jmp 0x18914
movq %rsi, 0x8(%rsp)
movq %r10, 0x10(%rsp)
movq %rdi, %r13
movq 0x88(%r14), %rdi
leaq (,%r12,4), %rsi
callq 0x4840
testq %rax, %rax
je 0x18914
movq %rax, 0x88(%r14)
movl %r12d, 0x84(%r14)
movq (%rsp), %r8
movq %r13, %rdi
movq 0x10(%rsp), %r10
movq 0x8(%rsp), %rsi
cmpq %rsi, %r15
jae 0x1891e
movq %rdi, 0x20(%rsp)
testl %r8d, %r8d
js 0x189ff
leal (%r8,%r8), %eax
addl %eax, %ebp
xorl %eax, %eax
xorl %edx, %edx
movq %rax, 0x8(%rsp)
movslq %edx, %rdi
movq 0x20(%rsp), %rsi
movl %ebp, %ecx
sarq %cl, %rsi
movq 0x18(%rsp), %r8
movq %rbp, 0x10(%rsp)
sarq %cl, %r8
leaq (%r8,%rdi), %rcx
addl %edi, %esi
movslq %esi, %rsi
cmpq %rsi, %rcx
jl 0x188ea
addq %r8, %rdi
incq %rdi
movl (%rbx), %r8d
testl %r8d, %r8d
je 0x188ad
leal -0x1(%r8), %r10d
movl %r10d, %r11d
andl %esi, %r11d
movq 0x10(%rbx), %r15
movl $0x1, %r12d
movl %r11d, %r9d
movl %r9d, %ecx
shrl $0x4, %ecx
movl (%r15,%rcx,4), %r13d
leal (%r9,%r9), %ecx
andl $0x1e, %ecx
movl %r13d, %ebp
shrl %cl, %ebp
testb $0x2, %bpl
jne 0x188a0
testb $0x1, %bpl
jne 0x1888d
movq 0x18(%rbx), %rbp
movl %r9d, %eax
cmpl %esi, (%rbp,%rax,4)
je 0x188a0
addl %r12d, %r9d
andl %r10d, %r9d
incl %r12d
cmpl %r11d, %r9d
jne 0x1885e
movl %r8d, %r9d
jmp 0x188b0
shrl %cl, %r13d
testb $0x3, %r13b
cmovnel %r8d, %r9d
jmp 0x188b0
xorl %r9d, %r9d
cmpl %r8d, %r9d
je 0x188de
movslq 0x80(%r14), %rcx
cmpl 0x84(%r14), %ecx
jge 0x18a15
movq 0x88(%r14), %rax
leal 0x1(%rcx), %r8d
movl %r8d, 0x80(%r14)
movl %esi, (%rax,%rcx,4)
incq %rsi
cmpq %rdi, %rsi
jne 0x1883f
movq 0x10(%rsp), %rbp
addl $-0x3, %ebp
movq 0x8(%rsp), %rsi
leal (%rsi,%rsi,2), %ecx
movl $0x1, %eax
shll %cl, %eax
addl %eax, %edx
leal 0x1(%rsi), %eax
cmpl (%rsp), %esi
jne 0x18808
jmp 0x189ff
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x18a06
xorl %eax, %eax
testq %rdi, %rdi
cmovleq %rax, %rdi
cmpl $0x0, (%rbx)
je 0x189ff
movq %rdi, %r11
movq (%rsp), %rcx
leal (%rcx,%rcx,2), %ecx
addl %r10d, %ecx
movslq %ecx, %rdx
movq 0x10(%rbx), %rsi
movl $0x92492493, %edi       # imm = 0x92492493
movl %eax, %ecx
shrl $0x4, %ecx
movl (%rsi,%rcx,4), %r8d
leal (%rax,%rax), %ecx
shrl %cl, %r8d
testb $0x3, %r8b
jne 0x189f5
movq 0x18(%rbx), %rcx
movl %eax, %r8d
movl (%rcx,%r8,4), %r8d
xorl %ecx, %ecx
testq %r8, %r8
je 0x1898c
movl %r8d, %r9d
incl %ecx
decl %r9d
movl %r9d, %r10d
sarl $0x3, %r10d
cmpl $0x7, %r9d
movl %r10d, %r9d
ja 0x18977
cmpl (%rsp), %ecx
jg 0x189f5
leal (%rcx,%rcx,2), %ecx
movl $0xffffffff, %r9d       # imm = 0xFFFFFFFF
shll %cl, %r9d
notl %r9d
movslq %ecx, %r10
movq %rdx, %rcx
subq %r10, %rcx
movq %r11, %r10
shrq %cl, %r10
imulq %rdi, %r9
shrq $0x22, %r9
addq %r9, %r10
cmpq %r8, %r10
ja 0x189f5
movq 0x18(%rsp), %r10
sarq %cl, %r10
addq %r9, %r10
cmpq %r8, %r10
jl 0x189f5
movslq 0x80(%r14), %rcx
cmpl 0x84(%r14), %ecx
jge 0x18a34
movq 0x88(%r14), %r9
leal 0x1(%rcx), %r10d
movl %r10d, 0x80(%r14)
movl %r8d, (%r9,%rcx,4)
incl %eax
cmpl (%rbx), %eax
jne 0x18949
movl 0x80(%r14), %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x80f7c(%rip), %rdi     # 0x99998
leaq 0x808dd(%rip), %rsi     # 0x99300
leaq 0x80f88(%rip), %rcx     # 0x999b2
movl $0xc22, %edx            # imm = 0xC22
callq 0x42f0
leaq 0x80f5d(%rip), %rdi     # 0x99998
leaq 0x808be(%rip), %rsi     # 0x99300
leaq 0x80fb0(%rip), %rcx     # 0x999f9
movl $0xc39, %edx            # imm = 0xC39
callq 0x42f0