// File: /workspace/github_c_makefile_star2_O0/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 %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rax
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
je 0x59302
movq -0x18(%rbp), %rax
cmpq $0x0, 0x90(%rax)
je 0x59302
movq -0x18(%rbp), %rax
movq 0x90(%rax), %rax
movl 0xe4(%rax), %eax
movq -0x18(%rbp), %rcx
movq 0x90(%rcx), %rcx
cmpl 0xe0(%rcx), %eax
jge 0x59302
movq -0x18(%rbp), %rax
movq 0x90(%rax), %rax
movq %rax, -0x20(%rbp)
jmp 0x59328
movq -0x10(%rbp), %rdi
leaq -0x18(%rbp), %rsi
callq 0x587d0
movq %rax, -0x20(%rbp)
cmpq $0x0, %rax
jne 0x59326
movq $0x0, -0x8(%rbp)
jmp 0x59555
jmp 0x592ac
movq -0x10(%rbp), %rax
cmpl $-0x2, 0x258(%rax)
je 0x5950a
movq -0x10(%rbp), %rax
cmpl $-0x1, 0x258(%rax)
jne 0x59381
movq -0x20(%rbp), %rax
movq 0x30(%rax), %rax
movq -0x20(%rbp), %rcx
movslq 0xe4(%rcx), %rcx
imulq $0x90, %rcx, %rcx
addq %rcx, %rax
cmpl $-0x1, 0x8(%rax)
je 0x59381
movq -0x20(%rbp), %rax
movl 0xe4(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0xe4(%rax)
jmp 0x592ac
movq -0x20(%rbp), %rax
movq 0x30(%rax), %rax
movq -0x20(%rbp), %rcx
movslq 0xe4(%rcx), %rcx
imulq $0x90, %rcx, %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
movq -0x10(%rbp), %rcx
cmpl 0x258(%rcx), %eax
jge 0x593e8
movq -0x20(%rbp), %rax
movq 0x30(%rax), %rax
movq -0x20(%rbp), %rcx
movslq 0xe4(%rcx), %rcx
imulq $0x90, %rcx, %rcx
addq %rcx, %rax
cmpl $-0x1, 0x8(%rax)
je 0x593e8
movq -0x20(%rbp), %rax
movl 0xe4(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0xe4(%rax)
jmp 0x592ac
movq -0x20(%rbp), %rax
movq 0x30(%rax), %rax
movq -0x20(%rbp), %rcx
movslq 0xe4(%rcx), %rcx
imulq $0x90, %rcx, %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
movq -0x10(%rbp), %rcx
cmpl 0x258(%rcx), %eax
je 0x59447
movq -0x10(%rbp), %rax
movl $0x1, 0x8890(%rax)
movq -0x20(%rbp), %rdi
callq 0x74f20
movq -0x18(%rbp), %rax
movq $0x0, 0x90(%rax)
movq $0x0, -0x8(%rbp)
jmp 0x59555
movq -0x10(%rbp), %rax
cmpl $-0x1, 0x258(%rax)
je 0x594b5
movq -0x20(%rbp), %rax
movq 0x30(%rax), %rax
movq -0x20(%rbp), %rcx
movslq 0xe4(%rcx), %rcx
imulq $0x90, %rcx, %rcx
addq %rcx, %rax
movq 0x18(%rax), %rax
movq -0x10(%rbp), %rcx
cmpq 0x268(%rcx), %rax
jle 0x594b5
movq -0x10(%rbp), %rax
movl $0x1, 0x8890(%rax)
movq -0x20(%rbp), %rdi
callq 0x74f20
movq -0x18(%rbp), %rax
movq $0x0, 0x90(%rax)
movq $0x0, -0x8(%rbp)
jmp 0x59555
movq -0x10(%rbp), %rax
cmpl $-0x1, 0x258(%rax)
je 0x59508
movq -0x20(%rbp), %rax
movq 0x30(%rax), %rax
movq -0x20(%rbp), %rcx
movslq 0xe4(%rcx), %rcx
imulq $0x90, %rcx, %rcx
addq %rcx, %rax
movq 0x78(%rax), %rax
movq -0x10(%rbp), %rcx
cmpq 0x260(%rcx), %rax
jge 0x59508
movq -0x20(%rbp), %rax
movl 0xe4(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0xe4(%rax)
jmp 0x592ac
jmp 0x5950a
jmp 0x5950c
movq -0x18(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x38(%rax)
movq -0x20(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x90(%rax)
movq -0x20(%rbp), %rax
movq 0x30(%rax), %rax
movq -0x20(%rbp), %rdx
movl 0xe4(%rdx), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, 0xe4(%rdx)
movslq %ecx, %rcx
imulq $0x90, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x20, %rsp
popq %rbp
retq
nop