// File: /workspace/github_c_makefile_star2_O0/samtools[P]htslib/hts.c
// Function: reg2intervals
static inline int reg2intervals(hts_itr_t *iter, const hts_idx_t *idx, int tid, int64_t beg, int64_t end, uint32_t interval, uint64_t min_off, uint64_t max_off, int min_shift, int n_lvls)
{
    int l, t, s;
    int i, j;
    hts_pos_t end1;
    bidx_t *bidx;
    int start_n_off;
    size_t reg_bin_count = 0, hash_bin_count;
    int res;

    if (!iter || !idx || (bidx = idx->bidx[tid]) == NULL || beg > end)
        return -1;

    hash_bin_count = kh_n_buckets(bidx);

    s = min_shift + (n_lvls<<1) + n_lvls;
    if (end >= 1LL<<s)
        end = 1LL<<s;

    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;
    }

    start_n_off = iter->n_off;

    // Populate iter->off with the intervals for this region
    if (reg_bin_count < hash_bin_count) {
        res = reg2intervals_narrow(iter, bidx, tid, beg, end, interval,
                                   min_off, max_off, min_shift, n_lvls);
    } else {
        res = reg2intervals_wide(iter, bidx, tid, beg, end, interval,
                                 min_off, max_off, min_shift, n_lvls);
    }
    if (res < 0)
        return res;

    if (iter->n_off - start_n_off > 1) {
        ks_introsort(_off_max, iter->n_off - start_n_off, iter->off + start_n_off);
        for (i = start_n_off, j = start_n_off + 1; j < iter->n_off; j++) {
            if (iter->off[i].v >= iter->off[j].u) {
                if (iter->off[i].v < iter->off[j].v)
                    iter->off[i].v = iter->off[j].v;
            } else {
                i++;
                if (i < j)
                    iter->off[i] = iter->off[j];
            }
        }
        iter->n_off = i + 1;
    }

    return iter->n_off;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
subq $0x98, %rsp
movl 0x28(%rbp), %eax
movl 0x20(%rbp), %eax
movq 0x18(%rbp), %rax
movq 0x10(%rbp), %rax
movq %rdi, -0x18(%rbp)
movq %rsi, -0x20(%rbp)
movl %edx, -0x24(%rbp)
movq %rcx, -0x30(%rbp)
movq %r8, -0x38(%rbp)
movl %r9d, -0x3c(%rbp)
movq $0x0, -0x70(%rbp)
cmpq $0x0, -0x18(%rbp)
je 0x228fb
cmpq $0x0, -0x20(%rbp)
je 0x228fb
movq -0x20(%rbp), %rax
movq 0x28(%rax), %rax
movslq -0x24(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x60(%rbp)
cmpq $0x0, %rax
je 0x228fb
movq -0x30(%rbp), %rax
cmpq -0x38(%rbp), %rax
jle 0x22907
movl $0xffffffff, -0xc(%rbp) # imm = 0xFFFFFFFF
jmp 0x22bbd
movq -0x60(%rbp), %rax
movl (%rax), %eax
movq %rax, -0x78(%rbp)
movl 0x20(%rbp), %eax
movl 0x28(%rbp), %ecx
shll %ecx
addl %ecx, %eax
addl 0x28(%rbp), %eax
movl %eax, -0x48(%rbp)
movq -0x38(%rbp), %rax
movl -0x48(%rbp), %ecx
movl $0x1, %edx
shlq %cl, %rdx
movq %rdx, %rcx
cmpq %rcx, %rax
jl 0x22949
movl -0x48(%rbp), %eax
movl %eax, %ecx
movl $0x1, %eax
shlq %cl, %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
subq $0x1, %rax
movq %rax, -0x58(%rbp)
movl $0x0, -0x40(%rbp)
movl $0x0, -0x44(%rbp)
movl -0x40(%rbp), %eax
cmpl 0x28(%rbp), %eax
jg 0x229ba
movq -0x58(%rbp), %rax
movl -0x48(%rbp), %ecx
sarq %cl, %rax
movq -0x30(%rbp), %rdx
movl -0x48(%rbp), %ecx
sarq %cl, %rdx
movq %rdx, %rcx
subq %rcx, %rax
addq $0x1, %rax
addq -0x70(%rbp), %rax
movq %rax, -0x70(%rbp)
movl -0x48(%rbp), %eax
subl $0x3, %eax
movl %eax, -0x48(%rbp)
movl -0x40(%rbp), %ecx
shll %ecx
addl -0x40(%rbp), %ecx
movl $0x1, %eax
shll %cl, %eax
addl -0x44(%rbp), %eax
movl %eax, -0x44(%rbp)
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0x22963
movq -0x18(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, -0x64(%rbp)
movq -0x70(%rbp), %rax
cmpq -0x78(%rbp), %rax
jae 0x22a10
movq -0x18(%rbp), %rdi
movq -0x60(%rbp), %rsi
movl -0x24(%rbp), %edx
movq -0x30(%rbp), %rcx
movq -0x38(%rbp), %r8
movl -0x3c(%rbp), %r9d
movq 0x10(%rbp), %rbx
movq 0x18(%rbp), %r11
movl 0x20(%rbp), %r10d
movl 0x28(%rbp), %eax
movq %rbx, (%rsp)
movq %r11, 0x8(%rsp)
movl %r10d, 0x10(%rsp)
movl %eax, 0x18(%rsp)
callq 0x28c50
movl %eax, -0x7c(%rbp)
jmp 0x22a50
movq -0x18(%rbp), %rdi
movq -0x60(%rbp), %rsi
movl -0x24(%rbp), %edx
movq -0x30(%rbp), %rcx
movq -0x38(%rbp), %r8
movl -0x3c(%rbp), %r9d
movq 0x10(%rbp), %rbx
movq 0x18(%rbp), %r11
movl 0x20(%rbp), %r10d
movl 0x28(%rbp), %eax
movq %rbx, (%rsp)
movq %r11, 0x8(%rsp)
movl %r10d, 0x10(%rsp)
movl %eax, 0x18(%rsp)
callq 0x28da0
movl %eax, -0x7c(%rbp)
cmpl $0x0, -0x7c(%rbp)
jge 0x22a61
movl -0x7c(%rbp), %eax
movl %eax, -0xc(%rbp)
jmp 0x22bbd
movq -0x18(%rbp), %rax
movl 0x8(%rax), %eax
subl -0x64(%rbp), %eax
cmpl $0x1, %eax
jle 0x22bb3
movq -0x18(%rbp), %rax
movl 0x8(%rax), %eax
subl -0x64(%rbp), %eax
movslq %eax, %rdi
movq -0x18(%rbp), %rax
movq 0x60(%rax), %rsi
movslq -0x64(%rbp), %rax
imulq $0x18, %rax, %rax
addq %rax, %rsi
callq 0x21b50
movl -0x64(%rbp), %eax
movl %eax, -0x4c(%rbp)
movl -0x64(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x50(%rbp)
movl -0x50(%rbp), %eax
movq -0x18(%rbp), %rcx
cmpl 0x8(%rcx), %eax
jge 0x22ba6
movq -0x18(%rbp), %rax
movq 0x60(%rax), %rax
movslq -0x4c(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movq -0x18(%rbp), %rcx
movq 0x60(%rcx), %rcx
movslq -0x50(%rbp), %rdx
imulq $0x18, %rdx, %rdx
addq %rdx, %rcx
cmpq (%rcx), %rax
jb 0x22b47
movq -0x18(%rbp), %rax
movq 0x60(%rax), %rax
movslq -0x4c(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movq -0x18(%rbp), %rcx
movq 0x60(%rcx), %rcx
movslq -0x50(%rbp), %rdx
imulq $0x18, %rdx, %rdx
addq %rdx, %rcx
cmpq 0x8(%rcx), %rax
jae 0x22b45
movq -0x18(%rbp), %rax
movq 0x60(%rax), %rax
movslq -0x50(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rcx
movq -0x18(%rbp), %rax
movq 0x60(%rax), %rax
movslq -0x4c(%rbp), %rdx
imulq $0x18, %rdx, %rdx
addq %rdx, %rax
movq %rcx, 0x8(%rax)
jmp 0x22b96
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
movl -0x4c(%rbp), %eax
cmpl -0x50(%rbp), %eax
jge 0x22b94
movq -0x18(%rbp), %rax
movq 0x60(%rax), %rax
movslq -0x4c(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq -0x18(%rbp), %rcx
movq 0x60(%rcx), %rcx
movslq -0x50(%rbp), %rdx
imulq $0x18, %rdx, %rdx
addq %rdx, %rcx
movq (%rcx), %rdx
movq %rdx, (%rax)
movq 0x8(%rcx), %rdx
movq %rdx, 0x8(%rax)
movq 0x10(%rcx), %rcx
movq %rcx, 0x10(%rax)
jmp 0x22b96
jmp 0x22b98
movl -0x50(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x50(%rbp)
jmp 0x22aa8
movl -0x4c(%rbp), %ecx
addl $0x1, %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0x18(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, -0xc(%rbp)
movl -0xc(%rbp), %eax
addq $0x98, %rsp
popq %rbx
popq %rbp
retq
nopw (%rax,%rax)