// File: /workspace/github_c_makefile_star2_O3/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 $0x38, %rsp
movq %r9, %rbx
movl %r8d, %r13d
movl %ecx, %r10d
leal (%r13,%r10), %eax
leal (%rax,%r13,2), %r9d
movl $0x1, %r8d
movl %r9d, %ecx
shlq %cl, %r8
cmpq %rsi, %r8
cmovgeq %rsi, %r8
xorl %eax, %eax
cmpq %rdi, %r8
jle 0x184d8
movq %rdx, %r14
movq %rdi, %rbp
decq %r8
testl %r13d, %r13d
js 0x18218
leal 0x1(%r13), %eax
xorl %r15d, %r15d
movl %r9d, %ecx
movq %r8, %rdx
sarq %cl, %rdx
movq %rbp, %rsi
sarq %cl, %rsi
subq %rsi, %r15
addq %rdx, %r15
incq %r15
addl $-0x3, %ecx
decl %eax
jne 0x181fa
jmp 0x1821b
xorl %r15d, %r15d
movl (%rbx), %edx
movl 0x4(%rbx), %r12d
cmpq %r12, %r15
cmovbq %r15, %r12
movslq 0x84(%r14), %rcx
movslq 0x80(%r14), %rax
subq %rax, %rcx
cmpq %rcx, %r12
jbe 0x182ad
addq %rax, %r12
testq $-0x80000000, %r12      # imm = 0x80000000
je 0x1825a
callq 0x4050
movl $0xc, (%rax)
jmp 0x183e3
movq %rdx, 0x20(%rsp)
movq %r10, 0x18(%rsp)
movl %r9d, 0xc(%rsp)
movq %r8, 0x10(%rsp)
movq 0x88(%r14), %rdi
leaq (,%r12,4), %rsi
callq 0x4840
testq %rax, %rax
je 0x183e3
movq %rax, 0x88(%r14)
movl %r12d, 0x84(%r14)
movq 0x10(%rsp), %r8
movl 0xc(%rsp), %r9d
movq 0x18(%rsp), %r10
movq 0x20(%rsp), %rdx
cmpq %rdx, %r15
jae 0x183ed
testl %r13d, %r13d
js 0x184d1
xorl %eax, %eax
xorl %edx, %edx
movq %r13, 0x30(%rsp)
movq %rbp, 0x28(%rsp)
movq %r8, 0x10(%rsp)
movq %rax, 0x18(%rsp)
movslq %edx, %rdi
movl %r9d, %ecx
sarq %cl, %rbp
movl %r9d, 0xc(%rsp)
sarq %cl, %r8
leaq (%r8,%rdi), %rcx
addl %edi, %ebp
movslq %ebp, %rsi
cmpq %rsi, %rcx
jl 0x183a9
addq %r8, %rdi
incq %rdi
movl (%rbx), %r8d
testl %r8d, %r8d
je 0x1836c
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), %ebp
leal (%r9,%r9), %ecx
andl $0x1e, %ecx
movl %ebp, %r13d
shrl %cl, %r13d
testb $0x2, %r13b
jne 0x18360
testb $0x1, %r13b
jne 0x18350
movq 0x18(%rbx), %r13
movl %r9d, %eax
cmpl %esi, (%r13,%rax,4)
je 0x18360
addl %r12d, %r9d
andl %r10d, %r9d
incl %r12d
cmpl %r11d, %r9d
jne 0x1831f
jmp 0x1839d
shrl %cl, %ebp
testb $0x3, %bpl
cmovnel %r8d, %r9d
jmp 0x1836f
xorl %r9d, %r9d
cmpl %r8d, %r9d
je 0x1839d
movslq 0x80(%r14), %rcx
cmpl 0x84(%r14), %ecx
jge 0x184e7
movq 0x88(%r14), %rax
leal 0x1(%rcx), %r8d
movl %r8d, 0x80(%r14)
movl %esi, (%rax,%rcx,4)
incq %rsi
cmpq %rdi, %rsi
jne 0x18300
movl 0xc(%rsp), %r9d
addl $-0x3, %r9d
movq 0x18(%rsp), %rsi
leal (%rsi,%rsi,2), %ecx
movl $0x1, %eax
shll %cl, %eax
addl %eax, %edx
leal 0x1(%rsi), %eax
movq 0x30(%rsp), %r13
cmpl %r13d, %esi
movq 0x28(%rsp), %rbp
movq 0x10(%rsp), %r8
jne 0x182d2
jmp 0x184d1
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x184d8
movq %r8, %r15
xorl %eax, %eax
testq %rbp, %rbp
cmovleq %rax, %rbp
movl (%rbx), %r8d
testl %r8d, %r8d
je 0x184d1
leal (%r13,%r13,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), %r9d
leal (%rax,%rax), %ecx
shrl %cl, %r9d
testb $0x3, %r9b
jne 0x184c6
movq 0x18(%rbx), %rcx
movl %eax, %r9d
movl (%rcx,%r9,4), %r9d
xorl %ecx, %ecx
testq %r9, %r9
je 0x1845c
movl %r9d, %r10d
incl %ecx
decl %r10d
movl %r10d, %r11d
sarl $0x3, %r11d
cmpl $0x7, %r10d
movl %r11d, %r10d
ja 0x18447
cmpl %r13d, %ecx
jg 0x184c6
leal (%rcx,%rcx,2), %ecx
movl $0xffffffff, %r10d      # imm = 0xFFFFFFFF
shll %cl, %r10d
notl %r10d
movslq %ecx, %r11
movq %rdx, %rcx
subq %r11, %rcx
movq %rbp, %r11
shrq %cl, %r11
imulq %rdi, %r10
shrq $0x22, %r10
addq %r10, %r11
cmpq %r9, %r11
ja 0x184c6
movq %r15, %r11
sarq %cl, %r11
addq %r10, %r11
cmpq %r9, %r11
jl 0x184c6
movslq 0x80(%r14), %rcx
cmpl 0x84(%r14), %ecx
jge 0x18506
movq 0x88(%r14), %r8
leal 0x1(%rcx), %r10d
movl %r10d, 0x80(%r14)
movl %r9d, (%r8,%rcx,4)
movl (%rbx), %r8d
incl %eax
cmpl %r8d, %eax
jne 0x18419
movl 0x80(%r14), %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x7e54a(%rip), %rdi     # 0x96a38
leaq 0x7deab(%rip), %rsi     # 0x963a0
leaq 0x7e556(%rip), %rcx     # 0x96a52
movl $0xc22, %edx            # imm = 0xC22
callq 0x42f0
leaq 0x7e52b(%rip), %rdi     # 0x96a38
leaq 0x7de8c(%rip), %rsi     # 0x963a0
leaq 0x7e57e(%rip), %rcx     # 0x96a99
movl $0xc39, %edx            # imm = 0xC39
callq 0x42f0