// File: /workspace/github_c_makefile_star2_O0/icebert[P]pblat/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->curr_rec < c->max_rec) {
	    s = c->slice;
	} else {
	    if (!(s = cram_next_slice(fd, &c)))
		return NULL;
	    continue; /* In case slice contains no records */
	}

	if (fd->range.refid != -2) {
	    if (fd->range.refid == -1 && s->crecs[c->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
		c->curr_rec++;
		continue;
	    }
	    if (s->crecs[c->curr_rec].ref_id < fd->range.refid &&
		s->crecs[c->curr_rec].ref_id != -1) {
		// Looking for a mapped read, but not there yet.  Special case
		// as -1 (unmapped) shouldn't be considered < refid.
		c->curr_rec++;
		continue;
	    }

	    if (s->crecs[c->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[c->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[c->curr_rec].aend < fd->range.start) {
		c->curr_rec++;
		continue;
	    }
	}

	break;
    }

    fd->ctr = c;
    c->slice = s;
    return &s->crecs[c->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 0xb882e
movq -0x18(%rbp), %rax
cmpq $0x0, 0x80(%rax)
je 0xb882e
movq -0x18(%rbp), %rax
movl 0x5c(%rax), %eax
movq -0x18(%rbp), %rcx
cmpl 0x58(%rcx), %eax
jge 0xb882e
movq -0x18(%rbp), %rax
movq 0x80(%rax), %rax
movq %rax, -0x20(%rbp)
jmp 0xb8854
movq -0x10(%rbp), %rdi
leaq -0x18(%rbp), %rsi
callq 0xb8a50
movq %rax, -0x20(%rbp)
cmpq $0x0, %rax
jne 0xb8852
movq $0x0, -0x8(%rbp)
jmp 0xb8a3e
jmp 0xb87ec
movq -0x10(%rbp), %rax
cmpl $-0x2, 0x228(%rax)
je 0xb89fc
movq -0x10(%rbp), %rax
cmpl $-0x1, 0x228(%rax)
jne 0xb88a1
movq -0x20(%rbp), %rax
movq 0x28(%rax), %rax
movq -0x18(%rbp), %rcx
movslq 0x5c(%rcx), %rcx
imulq $0x70, %rcx, %rcx
addq %rcx, %rax
cmpl $-0x1, 0x8(%rax)
je 0xb88a1
movq -0x18(%rbp), %rax
movl 0x5c(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x5c(%rax)
jmp 0xb87ec
movq -0x20(%rbp), %rax
movq 0x28(%rax), %rax
movq -0x18(%rbp), %rcx
movslq 0x5c(%rcx), %rcx
imulq $0x70, %rcx, %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
movq -0x10(%rbp), %rcx
cmpl 0x228(%rcx), %eax
jge 0xb88f6
movq -0x20(%rbp), %rax
movq 0x28(%rax), %rax
movq -0x18(%rbp), %rcx
movslq 0x5c(%rcx), %rcx
imulq $0x70, %rcx, %rcx
addq %rcx, %rax
cmpl $-0x1, 0x8(%rax)
je 0xb88f6
movq -0x18(%rbp), %rax
movl 0x5c(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x5c(%rax)
jmp 0xb87ec
movq -0x20(%rbp), %rax
movq 0x28(%rax), %rax
movq -0x18(%rbp), %rcx
movslq 0x5c(%rcx), %rcx
imulq $0x70, %rcx, %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
movq -0x10(%rbp), %rcx
cmpl 0x228(%rcx), %eax
je 0xb894f
movq -0x10(%rbp), %rax
movl $0x1, 0x8848(%rax)
movq -0x20(%rbp), %rdi
callq 0x83eb0
movq -0x18(%rbp), %rax
movq $0x0, 0x80(%rax)
movq $0x0, -0x8(%rbp)
jmp 0xb8a3e
movq -0x10(%rbp), %rax
cmpl $-0x1, 0x228(%rax)
je 0xb89b5
movq -0x20(%rbp), %rax
movq 0x28(%rax), %rax
movq -0x18(%rbp), %rcx
movslq 0x5c(%rcx), %rcx
imulq $0x70, %rcx, %rcx
addq %rcx, %rax
movl 0x18(%rax), %eax
movq -0x10(%rbp), %rcx
cmpl 0x230(%rcx), %eax
jle 0xb89b5
movq -0x10(%rbp), %rax
movl $0x1, 0x8848(%rax)
movq -0x20(%rbp), %rdi
callq 0x83eb0
movq -0x18(%rbp), %rax
movq $0x0, 0x80(%rax)
movq $0x0, -0x8(%rbp)
jmp 0xb8a3e
movq -0x10(%rbp), %rax
cmpl $-0x1, 0x228(%rax)
je 0xb89fa
movq -0x20(%rbp), %rax
movq 0x28(%rax), %rax
movq -0x18(%rbp), %rcx
movslq 0x5c(%rcx), %rcx
imulq $0x70, %rcx, %rcx
addq %rcx, %rax
movl 0x5c(%rax), %eax
movq -0x10(%rbp), %rcx
cmpl 0x22c(%rcx), %eax
jge 0xb89fa
movq -0x18(%rbp), %rax
movl 0x5c(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x5c(%rax)
jmp 0xb87ec
jmp 0xb89fc
jmp 0xb89fe
movq -0x18(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x38(%rax)
movq -0x20(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x80(%rax)
movq -0x20(%rbp), %rax
movq 0x28(%rax), %rax
movq -0x18(%rbp), %rdx
movl 0x5c(%rdx), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, 0x5c(%rdx)
movslq %ecx, %rcx
imulq $0x70, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax,%rax)