// File: /workspace/github_c_makefile_star2_O2/samtools[P]htslib/cram/cram_decode.c
// Function: cram_get_seq
cram_record *cram_get_seq(cram_fd *fd) {
    cram_container *c;
    cram_slice *s;

    for (;;) {
        c = fd->ctr;
        if (c && c->slice && c->slice->curr_rec < c->slice->max_rec) {
            s = c->slice;
        } else {
            if (!(s = cram_next_slice(fd, &c)))
                return NULL;
            continue; /* In case slice contains no records */
        }

        // No need to lock here as get_seq is running in the main thread,
        // which is also the same one that does the range modifications.
        if (fd->range.refid != -2) {
            if (fd->range.refid == -1 && s->crecs[s->curr_rec].ref_id != -1) {
                // Special case when looking for unmapped blocks at end.
                // If these are mixed in with mapped data (c->ref_id == -2)
                // then we need skip until we find the unmapped data, if at all
                s->curr_rec++;
                continue;
            }
            if (s->crecs[s->curr_rec].ref_id < fd->range.refid &&
                s->crecs[s->curr_rec].ref_id != -1) {
                // Looking for a mapped read, but not there yet.  Special case
                // as -1 (unmapped) shouldn't be considered < refid.
                s->curr_rec++;
                continue;
            }

            if (s->crecs[s->curr_rec].ref_id != fd->range.refid) {
                fd->eof = 1;
                cram_free_slice(s);
                c->slice = NULL;
                return NULL;
            }

            if (fd->range.refid != -1 && s->crecs[s->curr_rec].apos > fd->range.end) {
                fd->eof = 1;
                cram_free_slice(s);
                c->slice = NULL;
                return NULL;
            }

            if (fd->range.refid != -1 && s->crecs[s->curr_rec].aend < fd->range.start) {
                s->curr_rec++;
                continue;
            }
        }

        break;
    }

    fd->ctr = c;
    c->slice = s;
    return &s->crecs[s->curr_rec++];
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x10, %rsp
movq %rdi, %rbx
leaq 0x8(%rsp), %r14
movq 0x38(%rbx), %r15
testq %r15, %r15
je 0x333a3
movq 0x90(%r15), %rdi
testq %rdi, %rdi
je 0x333a3
movslq 0xe4(%rdi), %rcx
cmpl 0xe0(%rdi), %ecx
jge 0x333a3
movl 0x258(%rbx), %edx
movq 0x30(%rdi), %rax
cmpl $-0x1, %edx
je 0x333b9
cmpl $-0x2, %edx
je 0x333d4
imulq $0x90, %rcx, %rsi
movl 0x8(%rax,%rsi), %r8d
cmpl %edx, %r8d
setl %r9b
cmpl $-0x1, %r8d
setne %r10b
testb %r10b, %r9b
jne 0x333c7
cmpl %edx, %r8d
jne 0x333e9
cmpl $-0x1, %edx
je 0x333d4
movq 0x18(%rax,%rsi), %rdx
cmpq 0x268(%rbx), %rdx
jg 0x333e9
movq 0x78(%rax,%rsi), %rdx
cmpq 0x260(%rbx), %rdx
jl 0x333c7
jmp 0x333d4
movq %rbx, %rdi
movq %r14, %rsi
callq 0x32cfc
testq %rax, %rax
jne 0x33323
jmp 0x33400
imulq $0x90, %rcx, %rdx
cmpl $-0x1, 0x8(%rax,%rdx)
je 0x333d4
incl %ecx
movl %ecx, 0xe4(%rdi)
jmp 0x33323
leal 0x1(%rcx), %edx
movl %edx, 0xe4(%rdi)
imulq $0x90, %rcx, %rcx
addq %rcx, %rax
jmp 0x33402
movl $0x1, 0x8890(%rbx)
callq 0x42611
andq $0x0, 0x90(%r15)
xorl %eax, %eax
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
retq