// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movl %ecx, -0x24(%rbp)
movl %r8d, -0x28(%rbp)
movq %r9, -0x30(%rbp)
movl -0x24(%rbp), %eax
movl -0x28(%rbp), %ecx
shll %ecx
addl %ecx, %eax
addl -0x28(%rbp), %eax
movl %eax, -0x3c(%rbp)
movq $0x0, -0x48(%rbp)
movq -0x30(%rbp), %rax
movl (%rax), %eax
movq %rax, -0x50(%rbp)
movq -0x18(%rbp), %rax
movl -0x3c(%rbp), %ecx
movl $0x1, %edx
shlq %cl, %rdx
movq %rdx, %rcx
cmpq %rcx, %rax
jl 0x2190c
movl -0x3c(%rbp), %eax
movl %eax, %ecx
movl $0x1, %eax
shlq %cl, %rax
movq %rax, -0x18(%rbp)
movq -0x10(%rbp), %rax
cmpq -0x18(%rbp), %rax
jl 0x21922
movl $0x0, -0x4(%rbp)
jmp 0x21abc
movq -0x18(%rbp), %rax
subq $0x1, %rax
movq %rax, -0x60(%rbp)
movl $0x0, -0x34(%rbp)
movl $0x0, -0x38(%rbp)
movl -0x34(%rbp), %eax
cmpl -0x28(%rbp), %eax
jg 0x21993
movq -0x60(%rbp), %rax
movl -0x3c(%rbp), %ecx
sarq %cl, %rax
movq -0x10(%rbp), %rdx
movl -0x3c(%rbp), %ecx
sarq %cl, %rdx
movq %rdx, %rcx
subq %rcx, %rax
addq $0x1, %rax
addq -0x48(%rbp), %rax
movq %rax, -0x48(%rbp)
movl -0x3c(%rbp), %eax
subl $0x3, %eax
movl %eax, -0x3c(%rbp)
movl -0x34(%rbp), %ecx
shll %ecx
addl -0x34(%rbp), %ecx
movl $0x1, %eax
shll %cl, %eax
addl -0x38(%rbp), %eax
movl %eax, -0x38(%rbp)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x2193c
movq -0x48(%rbp), %rax
movq -0x30(%rbp), %rcx
movl 0x4(%rcx), %ecx
cmpq %rcx, %rax
jae 0x219ad
movq -0x48(%rbp), %rax
movq %rax, -0x78(%rbp)
jmp 0x219b8
movq -0x30(%rbp), %rax
movl 0x4(%rax), %eax
movq %rax, -0x78(%rbp)
movq -0x78(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x20(%rbp), %rax
movl 0x84(%rax), %eax
movq -0x20(%rbp), %rcx
subl 0x80(%rcx), %eax
cltq
cmpq -0x58(%rbp), %rax
jae 0x21a72
movq -0x58(%rbp), %rax
movq -0x20(%rbp), %rcx
movslq 0x80(%rcx), %rcx
addq %rcx, %rax
movq %rax, -0x68(%rbp)
cmpq $0x7fffffff, -0x68(%rbp) # imm = 0x7FFFFFFF
ja 0x21a10
movabsq $0x3fffffffffffffff, %rax # imm = 0x3FFFFFFFFFFFFFFF
cmpq %rax, -0x68(%rbp)
jbe 0x21a27
callq 0x4050
movl $0xc, (%rax)
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x21abc
movq -0x20(%rbp), %rax
movq 0x88(%rax), %rdi
movq -0x68(%rbp), %rsi
shlq $0x2, %rsi
callq 0x4820
movq %rax, -0x70(%rbp)
cmpq $0x0, -0x70(%rbp)
jne 0x21a53
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x21abc
movq -0x70(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x88(%rax)
movq -0x68(%rbp), %rax
movl %eax, %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x84(%rax)
movq -0x48(%rbp), %rax
cmpq -0x50(%rbp), %rax
jae 0x21a9d
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
movl -0x24(%rbp), %ecx
movl -0x28(%rbp), %r8d
movq -0x30(%rbp), %r9
callq 0x28650
movl %eax, -0x4(%rbp)
jmp 0x21abc
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
movl -0x24(%rbp), %ecx
movl -0x28(%rbp), %r8d
movq -0x30(%rbp), %r9
callq 0x287b0
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x80, %rsp
popq %rbp
retq
nopl (%rax,%rax)