// File: /workspace/github_c_makefile_star2_O0/icebert[P]pblat/htslib/sam.c
// Function: cram_itr_query
static hts_itr_t *cram_itr_query(const hts_idx_t *idx, int tid, int beg, int 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->read_rest = 1;
    iter->off = NULL;
    iter->bins.a = NULL;
    iter->readrec = readrec;

    if (tid >= 0 || tid == HTS_IDX_NOCOOR) {
        cram_range r = { tid == HTS_IDX_NOCOOR ? -1 : 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:
        fprintf(stderr, "[cram_itr_query] tid=%d not implemented for CRAM files -- Exiting\n", tid);
        abort();
        break;
    }

    return iter;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movl %edx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movq %r8, -0x28(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x30(%rbp)
movl $0x1, %edi
movl $0x50, %esi
callq 0x6460
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
jne 0xa7138
movq $0x0, -0x8(%rbp)
jmp 0xa729c
movq -0x38(%rbp), %rax
movl (%rax), %ecx
andl $-0x2, %ecx
orl $0x1, %ecx
movl %ecx, (%rax)
movq -0x38(%rbp), %rax
movq $0x0, 0x30(%rax)
movq -0x38(%rbp), %rax
movq $0x0, 0x48(%rax)
movq -0x28(%rbp), %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x38(%rax)
cmpl $0x0, -0x14(%rbp)
jge 0xa717a
cmpl $-0x2, -0x14(%rbp)
jne 0xa7231
leaq -0x44(%rbp), %rax
movq %rax, -0x50(%rbp)
cmpl $-0x2, -0x14(%rbp)
jne 0xa7192
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %eax, -0x54(%rbp)
jmp 0xa7198
movl -0x14(%rbp), %eax
movl %eax, -0x54(%rbp)
movq -0x50(%rbp), %rax
movl -0x54(%rbp), %ecx
movl %ecx, (%rax)
movl -0x18(%rbp), %eax
incl %eax
movl %eax, -0x40(%rbp)
movl -0x1c(%rbp), %eax
movl %eax, -0x3c(%rbp)
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rdi
xorl %eax, %eax
movl $0x5, %esi
leaq -0x44(%rbp), %rdx
callq 0x8afa0
movl %eax, -0x48(%rbp)
movq -0x38(%rbp), %rax
movq $0x0, 0x28(%rax)
movl -0x14(%rbp), %ecx
movq -0x38(%rbp), %rax
movl %ecx, 0x4(%rax)
movl -0x18(%rbp), %ecx
movq -0x38(%rbp), %rax
movl %ecx, 0x8(%rax)
movl -0x1c(%rbp), %ecx
movq -0x38(%rbp), %rax
movl %ecx, 0xc(%rax)
movl -0x48(%rbp), %eax
movl %eax, -0x58(%rbp)
subl $-0x2, %eax
je 0xa720c
jmp 0xa7201
movl -0x58(%rbp), %eax
testl %eax, %eax
jne 0xa721c
jmp 0xa720a
jmp 0xa722f
movq -0x38(%rbp), %rax
movl (%rax), %ecx
andl $-0x3, %ecx
orl $0x2, %ecx
movl %ecx, (%rax)
jmp 0xa722f
movq -0x38(%rbp), %rdi
callq 0x6880
movq $0x0, -0x8(%rbp)
jmp 0xa729c
jmp 0xa7294
movl -0x14(%rbp), %eax
movl %eax, -0x5c(%rbp)
subl $-0x5, %eax
je 0xa7256
jmp 0xa723e
movl -0x5c(%rbp), %eax
subl $-0x4, %eax
jne 0xa7272
jmp 0xa7248
movq -0x38(%rbp), %rax
movq $0x0, 0x28(%rax)
jmp 0xa7292
movq -0x38(%rbp), %rax
movq $0x0, 0x28(%rax)
movq -0x38(%rbp), %rax
movl (%rax), %ecx
andl $-0x3, %ecx
orl $0x2, %ecx
movl %ecx, (%rax)
jmp 0xa7292
movq 0x5dd57(%rip), %rax     # 0x104fd0
movq (%rax), %rdi
movl -0x14(%rbp), %edx
leaq 0x3d64d(%rip), %rsi     # 0xe48d3
movb $0x0, %al
callq 0x6a80
callq 0x63b0
jmp 0xa7294
movq -0x38(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)