// File: /workspace/github_cpp_makefile_star2_O3/karel-brinda[P]ococo/ext/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
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rdi, %rbx
leaq 0x8898(%rdi), %r14
movl $0x1, %ebp
movq 0x38(%rbx), %r15
testq %r15, %r15
je 0x23a39
movq 0x80(%r15), %rdi
testq %rdi, %rdi
je 0x23ac9
movslq 0x5c(%r15), %rcx
cmpl 0x58(%r15), %ecx
jge 0x23ac9
movl 0x228(%rbx), %edx
movq 0x28(%rdi), %rax
cmpl $-0x1, %edx
je 0x23e52
cmpl $-0x2, %edx
je 0x23eae
imulq $0x70, %rcx, %rsi
movl 0x8(%rax,%rsi), %r8d
cmpl %edx, %r8d
setl %r9b
cmpl $-0x1, %r8d
setne %r10b
testb %r10b, %r9b
jne 0x23e5d
cmpl %edx, %r8d
jne 0x23ebe
cmpl $-0x1, %edx
je 0x23eae
movl 0x18(%rax,%rsi), %edx
cmpl 0x230(%rbx), %edx
jg 0x23ebe
movl 0x5c(%rax,%rsi), %edx
cmpl 0x22c(%rbx), %edx
jl 0x23e5d
jmp 0x23eae
movq %rbx, %rdi
callq 0x3530f
movq %rax, 0x38(%rbx)
testq %rax, %rax
je 0x23eec
movq %rax, %r15
movl (%rax), %eax
testl %eax, %eax
je 0x23a39
cmpl $-0x2, 0x228(%rbx)
jne 0x23de6
movq %rbx, %rdi
callq 0x31aab
movq %rax, 0x48(%r15)
testq %rax, %rax
je 0x23eec
cmpl $0x1, 0x8(%rax)
jne 0x23eec
movq %rbx, %rdi
movq %rax, %rsi
callq 0x1c855
movq %rax, 0x40(%r15)
testq %rax, %rax
je 0x23eec
cmpl $0x0, 0x34(%rax)
jne 0x23ac9
movq 0x18(%rbx), %rdi
callq 0x3f24f
cmpl $0x2, %eax
je 0x23ac9
movq %r14, %rdi
callq 0x47a0
movl $0x1, 0x8854(%rbx)
movq %r14, %rdi
callq 0x43f0
movq 0x80(%r15), %rdi
testq %rdi, %rdi
je 0x23ae5
movq $0x0, 0x80(%r15)
callq 0x35120
movl 0x54(%r15), %ecx
movl $0x0, %r12d
movl $0x0, %eax
cmpl 0x50(%r15), %ecx
jne 0x23b08
movq %r15, %rdi
callq 0x34f02
movq %r12, %rax
xorl %r15d, %r15d
movq %rax, %r12
movq 0x88f0(%rbx), %rdi
testq %rdi, %rdi
jne 0x23c62
cmpl $0x0, 0x88f8(%rbx)
jne 0x23c7a
testq %r15, %r15
je 0x23b3b
movl 0x54(%r15), %eax
cmpl 0x50(%r15), %eax
jne 0x23c10
movq %rbx, %rdi
callq 0x3530f
movq %rax, 0x38(%rbx)
testq %rax, %rax
je 0x23d71
movq %rax, %r15
movslq (%rax), %rsi
testq %rsi, %rsi
je 0x23b3b
cmpl $0x0, 0x88f8(%rbx)
jne 0x23e84
movl 0x228(%rbx), %eax
cmpl $-0x2, %eax
je 0x23bab
movl 0x4(%r15), %ecx
cmpl $-0x2, %ecx
je 0x23bab
orb $0x8, 0x224(%rbx)
cmpl %eax, %ecx
jne 0x23e68
movl 0x8(%r15), %eax
cmpl 0x230(%rbx), %eax
jg 0x23e68
addl 0xc(%r15), %eax
cmpl 0x22c(%rbx), %eax
jle 0x23c2b
movq %rbx, %rdi
callq 0x31aab
movq %rax, 0x48(%r15)
testq %rax, %rax
je 0x23eec
cmpl $0x1, 0x8(%rax)
jne 0x23eec
movq %rbx, %rdi
movq %rax, %rsi
callq 0x1c855
movq %rax, 0x40(%r15)
testq %rax, %rax
je 0x23eec
cmpl $0x0, 0x34(%rax)
jne 0x23c10
movq 0x18(%rbx), %rdi
callq 0x3f24f
cmpl $0x2, %eax
je 0x23c10
movq %r14, %rdi
callq 0x47a0
movl $0x1, 0x8854(%rbx)
movq %r14, %rdi
callq 0x43f0
cmpl $0x0, 0x20(%r15)
jne 0x23ce2
movq %r15, %rdi
callq 0x34f02
xorl %r15d, %r15d
jmp 0x23b28
movl 0x50(%r15), %eax
movl 0x58(%r15), %ecx
movl %ecx, 0x5c(%r15)
movl %eax, 0x54(%r15)
movq %rbx, %rdi
movl $0x1, %edx
callq 0x38546
movq %r15, %rdi
callq 0x34f02
movq 0x88f0(%rbx), %rdi
movl $0x0, %r15d
jmp 0x23b12
movq 0x8(%rdi), %r15
movq 0x10(%rdi), %r12
callq 0x4610
movq $0x0, 0x88f0(%rbx)
testq %r15, %r15
je 0x23e84
testq %r12, %r12
je 0x23e84
movq 0x18(%rbx), %rcx
movq %rbx, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x238cb
testl %eax, %eax
jne 0x23ee1
cmpq $0x0, 0x8860(%rbx)
je 0x2399a
cmpq $0x0, 0x88f0(%rbx)
jne 0x23e92
movq 0x8868(%rbx), %rdi
callq 0x410bd
movq 0x8860(%rbx), %rcx
cmpl (%rcx), %eax
jle 0x23b0b
jmp 0x23e92
movq %rbx, %rdi
callq 0x36ba5
movq %rax, 0x80(%r15)
testq %rax, %rax
je 0x23eec
movq %rax, %r12
incl 0x54(%r15)
movl $0x0, 0x5c(%r15)
movq (%rax), %rax
movl 0x10(%rax), %ecx
movl %ecx, 0x58(%r15)
movl 0x8(%rax), %ecx
movl %ecx, 0x20(%r12)
movl 0x228(%rbx), %edx
cmpl $-0x2, %edx
je 0x23c7a
movl 0x4(%rax), %esi
cmpl $-0x2, %esi
je 0x23c7a
cmpl %edx, %esi
jne 0x23ef7
cmpl 0x230(%rbx), %ecx
jg 0x23ef7
addl 0xc(%rax), %ecx
cmpl 0x22c(%rbx), %ecx
jg 0x23c7a
movq %r12, %rdi
callq 0x35120
movq $0x0, 0x80(%r15)
jmp 0x23afa
cmpq $0x0, 0x8860(%rbx)
je 0x23eec
movl $0x1, 0x88f8(%rbx)
movq 0x8868(%rbx), %rdi
callq 0x41087
testl %eax, %eax
jne 0x23eec
movq 0x8868(%rbx), %rdi
callq 0x40ff1
testq %rax, %rax
je 0x23eda
movq 0x10(%rax), %rcx
testq %rcx, %rcx
je 0x23eda
movq 0x8(%rcx), %rdx
movq 0x10(%rcx), %r12
movq %rdx, 0x38(%rbx)
movq %rax, %rdi
movl $0x1, %esi
callq 0x4110d
testq %r12, %r12
jne 0x2399a
jmp 0x23eec
movl 0x4(%r15), %ecx
cmpl $-0x2, %ecx
je 0x23a64
movl 0x228(%rbx), %edx
cmpl %edx, %ecx
jl 0x23e11
movl 0xc(%r15), %esi
addl 0x8(%r15), %esi
cmpl 0x22c(%rbx), %esi
jg 0x23ea4
movslq %eax, %rsi
movq %rbx, %rdi
movl $0x1, %edx
callq 0x38546
testl %eax, %eax
jne 0x23eec
movq 0x38(%rbx), %rdi
callq 0x34f02
movq %rbx, %rdi
callq 0x3530f
movq %rax, 0x38(%rbx)
testq %rax, %rax
je 0x23eec
movq %rax, %r15
movl (%rax), %eax
testl %eax, %eax
je 0x23e32
jmp 0x23de6
imulq $0x70, %rcx, %rdx
cmpl $-0x1, 0x8(%rax,%rdx)
je 0x23eae
incl %ecx
movl %ecx, 0x5c(%r15)
jmp 0x2399a
movq %r15, %rdi
callq 0x34f02
movq $0x0, 0x38(%rbx)
movl %ebp, 0x88f8(%rbx)
movl %ebp, 0x8848(%rbx)
cmpq $0x0, 0x8860(%rbx)
je 0x23dd8
cmpl $0x0, 0x88f8(%rbx)
jne 0x23d89
jmp 0x23d9d
cmpl %edx, %ecx
je 0x23a64
jmp 0x23eec
leal 0x1(%rcx), %edx
movl %edx, 0x5c(%r15)
imulq $0x70, %rcx, %rcx
addq %rcx, %rax
jmp 0x23eee
movl $0x1, 0x8848(%rbx)
callq 0x35120
movq $0x0, 0x80(%r15)
jmp 0x23eec
callq 0x536a
jmp 0x23eec
movq %r12, %rdi
movq %r15, %rsi
callq 0x532c
xorl %eax, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movl $0x1, 0x8848(%rbx)
movq %r12, %rdi
jmp 0x23ec8