// File: /workspace/github_c_makefile_star2_O0/samtools[P]htslib/hts.c
// Function: hts_itr_next
int hts_itr_next(BGZF *fp, hts_itr_t *iter, void *r, void *data)
{
    int ret, tid;
    hts_pos_t beg, end;
    if (iter == NULL || iter->finished) return -1;
    if (iter->read_rest) {
        if (iter->curr_off) { // seek to the start
            if (bgzf_seek(fp, iter->curr_off, SEEK_SET) < 0) {
                hts_log_error("Failed to seek to offset %"PRIu64"%s%s",
                              iter->curr_off,
                              errno ? ": " : "", strerror(errno));
                return -2;
            }
            iter->curr_off = 0; // only seek once
        }
        ret = iter->readrec(fp, data, r, &tid, &beg, &end);
        if (ret < 0) iter->finished = 1;
        iter->curr_tid = tid;
        iter->curr_beg = beg;
        iter->curr_end = end;
        return ret;
    }
    // A NULL iter->off should always be accompanied by iter->finished.
    assert(iter->off != NULL);
    for (;;) {
        if (iter->curr_off == 0 || iter->curr_off >= iter->off[iter->i].v) { // then jump to the next chunk
            if (iter->i == iter->n_off - 1) { ret = -1; break; } // no more chunks
            if (iter->i < 0 || iter->off[iter->i].v != iter->off[iter->i+1].u) { // not adjacent chunks; then seek
                if (bgzf_seek(fp, iter->off[iter->i+1].u, SEEK_SET) < 0) {
                    hts_log_error("Failed to seek to offset %"PRIu64"%s%s",
                                  iter->off[iter->i+1].u,
                                  errno ? ": " : "", strerror(errno));
                    return -2;
                }
                iter->curr_off = bgzf_tell(fp);
            }
            ++iter->i;
        }
        if ((ret = iter->readrec(fp, data, r, &tid, &beg, &end)) >= 0) {
            iter->curr_off = bgzf_tell(fp);
            if (tid != iter->tid || beg >= iter->end) { // no need to proceed
                ret = -1; break;
            } else if (end > iter->beg && iter->end > beg) {
                iter->curr_tid = tid;
                iter->curr_beg = beg;
                iter->curr_end = end;
                return ret;
            }
        } else break; // end of file or error
    }
    iter->finished = 1;
    return ret;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
cmpq $0x0, -0x18(%rbp)
je 0x2437f
movq -0x18(%rbp), %rax
movl (%rax), %eax
shrl %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x2438b
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x2472e
movq -0x18(%rbp), %rax
movl (%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x244a0
movq -0x18(%rbp), %rax
cmpq $0x0, 0x50(%rax)
je 0x2443a
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x50(%rax), %rsi
xorl %edx, %edx
callq 0x10a80
cmpq $0x0, %rax
jge 0x2442e
movq -0x18(%rbp), %rax
movq 0x50(%rax), %rax
movq %rax, -0x50(%rbp)
callq 0x4050
movl (%rax), %edx
leaq 0xcbb96(%rip), %rax     # 0xeff75
leaq 0xcbd68(%rip), %rcx     # 0xf014e
cmpl $0x0, %edx
cmovneq %rcx, %rax
movq %rax, -0x48(%rbp)
callq 0x4050
movl (%rax), %edi
callq 0x4130
movq -0x50(%rbp), %rcx
movq -0x48(%rbp), %r8
movq %rax, %r9
movl $0x1, %edi
leaq 0xcc66f(%rip), %rsi     # 0xf0a83
leaq 0xcc675(%rip), %rdx     # 0xf0a90
movb $0x0, %al
callq 0x1b030
movl $0xfffffffe, -0x4(%rbp) # imm = 0xFFFFFFFE
jmp 0x2472e
movq -0x18(%rbp), %rax
movq $0x0, 0x50(%rax)
movq -0x18(%rbp), %rax
movq 0x68(%rax), %rax
movq -0x10(%rbp), %rdi
movq -0x28(%rbp), %rsi
movq -0x20(%rbp), %rdx
leaq -0x30(%rbp), %rcx
leaq -0x38(%rbp), %r8
leaq -0x40(%rbp), %r9
callq *%rax
movl %eax, -0x2c(%rbp)
cmpl $0x0, -0x2c(%rbp)
jge 0x24473
movq -0x18(%rbp), %rax
movl (%rax), %ecx
andl $-0x3, %ecx
orl $0x2, %ecx
movl %ecx, (%rax)
movl -0x30(%rbp), %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x30(%rax)
movq -0x38(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x40(%rax)
movq -0x40(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x48(%rax)
movl -0x2c(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x2472e
movq -0x18(%rbp), %rax
cmpq $0x0, 0x60(%rax)
je 0x244ad
jmp 0x244cc
leaq 0xcc5fd(%rip), %rdi     # 0xf0ab1
leaq 0xcc11d(%rip), %rsi     # 0xf05d8
movl $0x1094, %edx           # imm = 0x1094
leaq 0xcc5fc(%rip), %rcx     # 0xf0ac3
callq 0x42e0
jmp 0x244ce
movq -0x18(%rbp), %rax
cmpq $0x0, 0x50(%rax)
je 0x24502
movq -0x18(%rbp), %rax
movq 0x50(%rax), %rax
movq -0x18(%rbp), %rcx
movq 0x60(%rcx), %rcx
movq -0x18(%rbp), %rdx
movslq 0xc(%rdx), %rdx
imulq $0x18, %rdx, %rdx
addq %rdx, %rcx
cmpq 0x8(%rcx), %rax
jb 0x24653
movq -0x18(%rbp), %rax
movl 0xc(%rax), %eax
movq -0x18(%rbp), %rcx
movl 0x8(%rcx), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jne 0x24523
movl $0xffffffff, -0x2c(%rbp) # imm = 0xFFFFFFFF
jmp 0x2471a
movq -0x18(%rbp), %rax
cmpl $0x0, 0xc(%rax)
jl 0x2456d
movq -0x18(%rbp), %rax
movq 0x60(%rax), %rax
movq -0x18(%rbp), %rcx
movslq 0xc(%rcx), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movq -0x18(%rbp), %rcx
movq 0x60(%rcx), %rcx
movq -0x18(%rbp), %rdx
movl 0xc(%rdx), %edx
addl $0x1, %edx
movslq %edx, %rdx
imulq $0x18, %rdx, %rdx
addq %rdx, %rcx
cmpq (%rcx), %rax
je 0x24646
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x60(%rax), %rax
movq -0x18(%rbp), %rcx
movl 0xc(%rcx), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rsi
xorl %edx, %edx
callq 0x10a80
cmpq $0x0, %rax
jge 0x24621
movq -0x18(%rbp), %rax
movq 0x60(%rax), %rax
movq -0x18(%rbp), %rcx
movl 0xc(%rcx), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rax
movq %rax, -0x60(%rbp)
callq 0x4050
movl (%rax), %edx
leaq 0xcb9a3(%rip), %rax     # 0xeff75
leaq 0xcbb75(%rip), %rcx     # 0xf014e
cmpl $0x0, %edx
cmovneq %rcx, %rax
movq %rax, -0x58(%rbp)
callq 0x4050
movl (%rax), %edi
callq 0x4130
movq -0x60(%rbp), %rcx
movq -0x58(%rbp), %r8
movq %rax, %r9
movl $0x1, %edi
leaq 0xcc47c(%rip), %rsi     # 0xf0a83
leaq 0xcc482(%rip), %rdx     # 0xf0a90
movb $0x0, %al
callq 0x1b030
movl $0xfffffffe, -0x4(%rbp) # imm = 0xFFFFFFFE
jmp 0x2472e
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rcx
shlq $0x10, %rcx
movq -0x10(%rbp), %rax
movl 0x10(%rax), %eax
andl $0xffff, %eax           # imm = 0xFFFF
cltq
orq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x50(%rax)
movq -0x18(%rbp), %rax
movl 0xc(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0xc(%rax)
movq -0x18(%rbp), %rax
movq 0x68(%rax), %rax
movq -0x10(%rbp), %rdi
movq -0x28(%rbp), %rsi
movq -0x20(%rbp), %rdx
leaq -0x30(%rbp), %rcx
leaq -0x38(%rbp), %r8
leaq -0x40(%rbp), %r9
callq *%rax
movl %eax, -0x2c(%rbp)
cmpl $0x0, %eax
jl 0x24713
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rcx
shlq $0x10, %rcx
movq -0x10(%rbp), %rax
movl 0x10(%rax), %eax
andl $0xffff, %eax           # imm = 0xFFFF
cltq
orq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x50(%rax)
movl -0x30(%rbp), %eax
movq -0x18(%rbp), %rcx
cmpl 0x4(%rcx), %eax
jne 0x246c0
movq -0x38(%rbp), %rax
movq -0x18(%rbp), %rcx
cmpq 0x20(%rcx), %rax
jl 0x246c9
movl $0xffffffff, -0x2c(%rbp) # imm = 0xFFFFFFFF
jmp 0x2471a
movq -0x40(%rbp), %rax
movq -0x18(%rbp), %rcx
cmpq 0x18(%rcx), %rax
jle 0x2470f
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rax
cmpq -0x38(%rbp), %rax
jle 0x2470f
movl -0x30(%rbp), %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x30(%rax)
movq -0x38(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x40(%rax)
movq -0x40(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x48(%rax)
movl -0x2c(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x2472e
jmp 0x24711
jmp 0x24715
jmp 0x2471a
jmp 0x244ce
movq -0x18(%rbp), %rax
movl (%rax), %ecx
andl $-0x3, %ecx
orl $0x2, %ecx
movl %ecx, (%rax)
movl -0x2c(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x60, %rsp
popq %rbp
retq
nopw (%rax,%rax)