// File: /workspace/github_cpp_makefile_star2_O2/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
pushq $0x1
popq %rbp
movq 0x38(%rbx), %r15
testq %r15, %r15
je 0x1bb7e
movq 0x80(%r15), %rdi
testq %rdi, %rdi
je 0x1bc0e
movslq 0x5c(%r15), %rcx
cmpl 0x58(%r15), %ecx
jge 0x1bc0e
movl 0x228(%rbx), %edx
movq 0x28(%rdi), %rax
cmpl $-0x1, %edx
je 0x1bf58
cmpl $-0x2, %edx
je 0x1bfc6
imulq $0x70, %rcx, %rsi
movl 0x8(%rax,%rsi), %r8d
cmpl %edx, %r8d
setl %r9b
cmpl $-0x1, %r8d
setne %r10b
testb %r10b, %r9b
jne 0x1bf63
cmpl %edx, %r8d
jne 0x1bfd6
cmpl $-0x1, %edx
je 0x1bfc6
movl 0x18(%rax,%rsi), %edx
cmpl 0x230(%rbx), %edx
jg 0x1bfd6
movl 0x5c(%rax,%rsi), %edx
cmpl 0x22c(%rbx), %edx
jl 0x1bf63
jmp 0x1bfc6
movq %rbx, %rdi
callq 0x2ad26
movq %rax, 0x38(%rbx)
testq %rax, %rax
je 0x1c00b
movq %rax, %r15
movl (%rax), %eax
testl %eax, %eax
je 0x1bb7e
cmpl $-0x2, 0x228(%rbx)
jne 0x1beef
movq %rbx, %rdi
callq 0x27b4b
movq %rax, 0x48(%r15)
testq %rax, %rax
je 0x1c00b
cmpl $0x1, 0x8(%rax)
jne 0x1c00b
movq %rbx, %rdi
movq %rax, %rsi
callq 0x16125
movq %rax, 0x40(%r15)
testq %rax, %rax
je 0x1c00b
cmpl $0x0, 0x34(%rax)
jne 0x1bc0e
movq 0x18(%rbx), %rdi
callq 0x33543
cmpl $0x2, %eax
je 0x1bc0e
movq %r14, %rdi
callq 0x47a0
movl $0x1, 0x8854(%rbx)
movq %r14, %rdi
callq 0x43f0
movq 0x80(%r15), %rdi
testq %rdi, %rdi
je 0x1bc27
andq $0x0, 0x80(%r15)
callq 0x2ab94
movl 0x54(%r15), %ecx
movl $0x0, %r12d
movl $0x0, %eax
cmpl 0x50(%r15), %ecx
jne 0x1bc4a
movq %r15, %rdi
callq 0x2a9b7
movq %r12, %rax
xorl %r15d, %r15d
movq %rax, %r12
movq 0x88f0(%rbx), %rdi
testq %rdi, %rdi
jne 0x1bdd6
cmpl $0x0, 0x88f8(%rbx)
jne 0x1bdeb
testq %r15, %r15
je 0x1bc7d
movl 0x54(%r15), %eax
cmpl 0x50(%r15), %eax
jne 0x1bd52
movq %rbx, %rdi
callq 0x2ad26
movq %rax, 0x38(%rbx)
testq %rax, %rax
je 0x1be7d
movq %rax, %r15
movslq (%rax), %rsi
testq %rsi, %rsi
je 0x1bc7d
cmpl $0x0, 0x88f8(%rbx)
jne 0x1bf87
movl 0x228(%rbx), %eax
cmpl $-0x2, %eax
je 0x1bced
movl 0x4(%r15), %ecx
cmpl $-0x2, %ecx
je 0x1bced
orb $0x8, 0x224(%rbx)
cmpl %eax, %ecx
jne 0x1bf6e
movl 0x8(%r15), %eax
cmpl 0x230(%rbx), %eax
jg 0x1bf6e
addl 0xc(%r15), %eax
cmpl 0x22c(%rbx), %eax
jle 0x1be53
movq %rbx, %rdi
callq 0x27b4b
movq %rax, 0x48(%r15)
testq %rax, %rax
je 0x1c00b
cmpl $0x1, 0x8(%rax)
jne 0x1c00b
movq %rbx, %rdi
movq %rax, %rsi
callq 0x16125
movq %rax, 0x40(%r15)
testq %rax, %rax
je 0x1c00b
cmpl $0x0, 0x34(%rax)
jne 0x1bd52
movq 0x18(%rbx), %rdi
callq 0x33543
cmpl $0x2, %eax
je 0x1bd52
movq %r14, %rdi
callq 0x47a0
movl $0x1, 0x8854(%rbx)
movq %r14, %rdi
callq 0x43f0
cmpl $0x0, 0x20(%r15)
jne 0x1bd69
movq %r15, %rdi
callq 0x2a9b7
xorl %r15d, %r15d
jmp 0x1bc6a
movq %rbx, %rdi
callq 0x2c402
movq %rax, 0x80(%r15)
testq %rax, %rax
je 0x1c00b
movq %rax, %r12
incl 0x54(%r15)
andl $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 0x1bdeb
movl 0x4(%rax), %esi
cmpl $-0x2, %esi
je 0x1bdeb
cmpl %edx, %esi
jne 0x1c016
cmpl 0x230(%rbx), %ecx
jg 0x1c016
addl 0xc(%rax), %ecx
cmpl 0x22c(%rbx), %ecx
jg 0x1bdeb
jmp 0x1bfb1
movq 0x8(%rdi), %r15
movq 0x10(%rdi), %r12
callq 0x4600
andq $0x0, 0x88f0(%rbx)
testq %r15, %r15
je 0x1bf87
testq %r12, %r12
je 0x1bf87
movq 0x18(%rbx), %rcx
movq %rbx, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x1ba19
testl %eax, %eax
jne 0x1c022
cmpq $0x0, 0x8860(%rbx)
je 0x1badf
cmpq $0x0, 0x88f0(%rbx)
jne 0x1bf95
movq 0x8868(%rbx), %rdi
callq 0x34a0f
movq 0x8860(%rbx), %rcx
cmpl (%rcx), %eax
jle 0x1bc4d
jmp 0x1bf95
movl 0x50(%r15), %eax
movl 0x58(%r15), %ecx
movl %ecx, 0x5c(%r15)
movl %eax, 0x54(%r15)
movq %rbx, %rdi
movl %ebp, %edx
callq 0x2d9e3
movq %r15, %rdi
callq 0x2a9b7
xorl %r15d, %r15d
jmp 0x1bc4d
cmpq $0x0, 0x8860(%rbx)
je 0x1c00b
movl $0x1, 0x88f8(%rbx)
movq 0x8868(%rbx), %rdi
callq 0x349d9
testl %eax, %eax
jne 0x1c00b
movq 0x8868(%rbx), %rdi
callq 0x3494e
testq %rax, %rax
je 0x1bfef
movq 0x10(%rax), %rcx
testq %rcx, %rcx
je 0x1bfef
movq 0x8(%rcx), %rdx
movq 0x10(%rcx), %r12
movq %rdx, 0x38(%rbx)
movq %rax, %rdi
movl %ebp, %esi
callq 0x34a5f
testq %r12, %r12
jne 0x1badf
jmp 0x1c00b
movl 0x4(%r15), %ecx
cmpl $-0x2, %ecx
je 0x1bba9
movl 0x228(%rbx), %edx
cmpl %edx, %ecx
jl 0x1bf1a
movl 0xc(%r15), %esi
addl 0x8(%r15), %esi
cmpl 0x22c(%rbx), %esi
jg 0x1bfa7
movslq %eax, %rsi
movq %rbx, %rdi
movl %ebp, %edx
callq 0x2d9e3
testl %eax, %eax
jne 0x1c00b
movq 0x38(%rbx), %rdi
callq 0x2a9b7
movq %rbx, %rdi
callq 0x2ad26
movq %rax, 0x38(%rbx)
testq %rax, %rax
je 0x1c00b
movq %rax, %r15
movl (%rax), %eax
testl %eax, %eax
je 0x1bf38
jmp 0x1beef
imulq $0x70, %rcx, %rdx
cmpl $-0x1, 0x8(%rax,%rdx)
je 0x1bfc6
incl %ecx
movl %ecx, 0x5c(%r15)
jmp 0x1badf
movq %r15, %rdi
callq 0x2a9b7
andq $0x0, 0x38(%rbx)
movl %ebp, 0x88f8(%rbx)
movl %ebp, 0x8848(%rbx)
cmpq $0x0, 0x8860(%rbx)
je 0x1bee1
cmpl $0x0, 0x88f8(%rbx)
jne 0x1be95
jmp 0x1bea9
cmpl %edx, %ecx
je 0x1bba9
jmp 0x1c00b
movq %r12, %rdi
callq 0x2ab94
andq $0x0, 0x80(%r15)
jmp 0x1bc3c
leal 0x1(%rcx), %edx
movl %edx, 0x5c(%r15)
imulq $0x70, %rcx, %rcx
addq %rcx, %rax
jmp 0x1c00d
movl $0x1, 0x8848(%rbx)
callq 0x2ab94
andq $0x0, 0x80(%r15)
jmp 0x1c00b
movq 0x3afda(%rip), %rax     # 0x56fd0
movq (%rax), %rcx
leaq 0x28d7a(%rip), %rdi     # 0x44d7a
pushq $0x1b
popq %rsi
pushq $0x1
popq %rdx
callq 0x4a20
xorl %eax, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movl $0x1, 0x8848(%rbx)
jmp 0x1c03e
movq 0x3afa7(%rip), %rax     # 0x56fd0
movq (%rax), %rcx
leaq 0x28d2e(%rip), %rdi     # 0x44d61
pushq $0x18
popq %rsi
pushq $0x1
popq %rdx
callq 0x4a20
movq %r12, %rdi
jmp 0x1bfe0