// File: /workspace/github_c_makefile_star2_O0/samtools[P]htslib/sam.c
// Function: cram_itr_query
static hts_itr_t *cram_itr_query(const hts_idx_t *idx, int tid, hts_pos_t beg, hts_pos_t end, hts_readrec_func *readrec)
{
    const hts_cram_idx_t *cidx = (const hts_cram_idx_t *) idx;
    hts_itr_t *iter = (hts_itr_t *) calloc(1, sizeof(hts_itr_t));
    if (iter == NULL) return NULL;

    // Cons up a dummy iterator for which hts_itr_next() will simply invoke
    // the readrec function:
    iter->is_cram = 1;
    iter->read_rest = 1;
    iter->off = NULL;
    iter->bins.a = NULL;
    iter->readrec = readrec;

    if (tid >= 0 || tid == HTS_IDX_NOCOOR || tid == HTS_IDX_START) {
        cram_range r = { tid, beg+1, end };
        int ret = cram_set_option(cidx->cram, CRAM_OPT_RANGE, &r);

        iter->curr_off = 0;
        // The following fields are not required by hts_itr_next(), but are
        // filled in in case user code wants to look at them.
        iter->tid = tid;
        iter->beg = beg;
        iter->end = end;

        switch (ret) {
        case 0:
            break;

        case -2:
            // No data vs this ref, so mark iterator as completed.
            // Same as HTS_IDX_NONE.
            iter->finished = 1;
            break;

        default:
            free(iter);
            return NULL;
        }
    }
    else switch (tid) {
    case HTS_IDX_REST:
        iter->curr_off = 0;
        break;
    case HTS_IDX_NONE:
        iter->curr_off = 0;
        iter->finished = 1;
        break;
    default:
        hts_log_error("Query with tid=%d not implemented for CRAM files", tid);
        abort();
        break;
    }

    return iter;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x38(%rbp)
movl $0x1, %edi
movl $0x90, %esi
callq 0x42f0
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
jne 0x36fca
movq $0x0, -0x8(%rbp)
jmp 0x3712f
movq -0x40(%rbp), %rax
movl (%rax), %ecx
andl $-0x5, %ecx
orl $0x4, %ecx
movl %ecx, (%rax)
movq -0x40(%rbp), %rax
movl (%rax), %ecx
andl $-0x2, %ecx
orl $0x1, %ecx
movl %ecx, (%rax)
movq -0x40(%rbp), %rax
movq $0x0, 0x60(%rax)
movq -0x40(%rbp), %rax
movq $0x0, 0x88(%rax)
movq -0x30(%rbp), %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x68(%rax)
cmpl $0x0, -0x14(%rbp)
jge 0x37023
cmpl $-0x2, -0x14(%rbp)
je 0x37023
cmpl $-0x3, -0x14(%rbp)
jne 0x370c2
movl -0x14(%rbp), %eax
movl %eax, -0x58(%rbp)
movq -0x20(%rbp), %rax
incq %rax
movq %rax, -0x50(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rdi
xorl %eax, %eax
movl $0x5, %esi
leaq -0x58(%rbp), %rdx
callq 0x79f60
movl %eax, -0x5c(%rbp)
movq -0x40(%rbp), %rax
movq $0x0, 0x50(%rax)
movl -0x14(%rbp), %ecx
movq -0x40(%rbp), %rax
movl %ecx, 0x4(%rax)
movq -0x20(%rbp), %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x28(%rbp), %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x20(%rax)
movl -0x5c(%rbp), %eax
movl %eax, -0x60(%rbp)
subl $-0x2, %eax
je 0x3709d
jmp 0x37092
movl -0x60(%rbp), %eax
testl %eax, %eax
jne 0x370ad
jmp 0x3709b
jmp 0x370c0
movq -0x40(%rbp), %rax
movl (%rax), %ecx
andl $-0x3, %ecx
orl $0x2, %ecx
movl %ecx, (%rax)
jmp 0x370c0
movq -0x40(%rbp), %rdi
callq 0x45a0
movq $0x0, -0x8(%rbp)
jmp 0x3712f
jmp 0x37127
movl -0x14(%rbp), %eax
movl %eax, -0x64(%rbp)
subl $-0x5, %eax
je 0x370e7
jmp 0x370cf
movl -0x64(%rbp), %eax
subl $-0x4, %eax
jne 0x37103
jmp 0x370d9
movq -0x40(%rbp), %rax
movq $0x0, 0x50(%rax)
jmp 0x37125
movq -0x40(%rbp), %rax
movq $0x0, 0x50(%rax)
movq -0x40(%rbp), %rax
movl (%rax), %ecx
andl $-0x3, %ecx
orl $0x2, %ecx
movl %ecx, (%rax)
jmp 0x37125
movl -0x14(%rbp), %ecx
movl $0x1, %edi
leaq 0xbb50d(%rip), %rsi     # 0xf261f
leaq 0xb9761(%rip), %rdx     # 0xf087a
movb $0x0, %al
callq 0x1b030
callq 0x4260
jmp 0x37127
movq -0x40(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x70, %rsp
popq %rbp
retq
nopl (%rax)