// File: /workspace/github_cpp_makefile_star2_O1/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 %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %r14
leaq 0x8898(%rdi), %r15
xorl %ebx, %ebx
movl $0x1, %ebp
movq 0x38(%r14), %r12
testq %r12, %r12
je 0x2472d
movq 0x80(%r12), %rdi
testq %rdi, %rdi
je 0x24444
movslq 0x5c(%r12), %rax
cmpl 0x58(%r12), %eax
jge 0x24444
movl 0x228(%r14), %ecx
cmpl $-0x1, %ecx
je 0x247d7
cmpl $-0x2, %ecx
jne 0x247e6
jmp 0x24993
testq %r12, %r12
je 0x2472d
movq 0x80(%r12), %rdi
testq %rdi, %rdi
je 0x2446b
movq $0x0, 0x80(%r12)
callq 0x35ef7
movl 0x54(%r12), %ecx
movl $0x0, %r13d
movl $0x0, %eax
cmpl 0x50(%r12), %ecx
jne 0x24490
movq %r12, %rdi
callq 0x35cde
movq %r13, %rax
xorl %r12d, %r12d
movq %rax, %r13
movq 0x88f0(%r14), %rdi
testq %rdi, %rdi
jne 0x24617
cmpl $0x0, 0x88f8(%r14)
jne 0x2462f
testq %r12, %r12
je 0x244c6
movl 0x54(%r12), %eax
cmpl 0x50(%r12), %eax
jne 0x245bc
movq %r14, %rdi
callq 0x360e5
movq %rax, %r12
movq %rax, 0x38(%r14)
testq %rax, %rax
je 0x244e3
cmpl $0x0, (%r12)
je 0x244c6
jmp 0x244fc
cmpq $0x0, 0x8860(%r14)
je 0x24904
movl $0x1, 0x88f8(%r14)
cmpl $0x0, 0x88f8(%r14)
jne 0x248e0
movl 0x228(%r14), %eax
cmpl $-0x2, %eax
je 0x24554
movl 0x4(%r12), %ecx
cmpl $-0x2, %ecx
je 0x24554
orb $0x8, 0x224(%r14)
cmpl %eax, %ecx
jne 0x248c2
movl 0x8(%r12), %eax
cmpl 0x230(%r14), %eax
jg 0x248c2
addl 0xc(%r12), %eax
cmpl 0x22c(%r14), %eax
jle 0x245d8
movq %r14, %rdi
callq 0x32631
movq %rax, 0x48(%r12)
testq %rax, %rax
je 0x24904
cmpl $0x1, 0x8(%rax)
jne 0x24904
movq %r14, %rdi
movq %rax, %rsi
callq 0x1caed
movq %rax, 0x40(%r12)
testq %rax, %rax
je 0x24904
cmpl $0x0, 0x34(%rax)
jne 0x245bc
movq 0x18(%r14), %rdi
callq 0x4012e
cmpl $0x2, %eax
je 0x245bc
movq %r15, %rdi
callq 0x47a0
movl $0x1, 0x8854(%r14)
movq %r15, %rdi
callq 0x43f0
cmpl $0x0, 0x20(%r12)
jne 0x24697
movq %r12, %rdi
callq 0x35cde
xorl %r12d, %r12d
jmp 0x244b1
movl 0x50(%r12), %eax
movl 0x58(%r12), %ecx
movl %ecx, 0x5c(%r12)
movl %eax, 0x54(%r12)
movslq (%r12), %rsi
movq %r14, %rdi
movl $0x1, %edx
callq 0x391a3
movq %r12, %rdi
callq 0x35cde
movq 0x88f0(%r14), %rdi
movl $0x0, %r12d
jmp 0x2449a
movq 0x8(%rdi), %r12
movq 0x10(%rdi), %r13
callq 0x4610
movq $0x0, 0x88f0(%r14)
testq %r12, %r12
je 0x248e0
testq %r13, %r13
je 0x248e0
movq 0x18(%r14), %rcx
movq %r14, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x2432c
testl %eax, %eax
jne 0x24962
cmpq $0x0, 0x8860(%r14)
je 0x248e0
cmpq $0x0, 0x88f0(%r14)
jne 0x248e0
movq 0x8868(%r14), %rdi
callq 0x420dd
movq 0x8860(%r14), %rcx
cmpl (%rcx), %eax
jle 0x24493
jmp 0x248e0
movq %r14, %rdi
callq 0x379b4
movq %rax, 0x80(%r12)
testq %rax, %rax
je 0x24904
movq %rax, %r13
incl 0x54(%r12)
movl $0x0, 0x5c(%r12)
movq (%rax), %rax
movl 0x10(%rax), %ecx
movl %ecx, 0x58(%r12)
movl 0x8(%rax), %ecx
movl %ecx, 0x20(%r13)
movl 0x228(%r14), %edx
cmpl $-0x2, %edx
je 0x2462f
movl 0x4(%rax), %esi
cmpl $-0x2, %esi
je 0x2462f
cmpl %edx, %esi
jne 0x2496f
cmpl 0x230(%r14), %ecx
jg 0x2496f
addl 0xc(%rax), %ecx
cmpl 0x22c(%r14), %ecx
jg 0x2462f
movq %r13, %rdi
callq 0x35ef7
movq $0x0, 0x80(%r12)
jmp 0x24482
movq %r14, %rdi
callq 0x360e5
movq %rax, 0x38(%r14)
testq %rax, %rax
je 0x24904
movq %rax, %r12
cmpl $0x0, (%rax)
je 0x2472d
cmpl $-0x2, 0x228(%r14)
je 0x24762
movl 0x4(%r12), %eax
cmpl $-0x2, %eax
jne 0x24855
movq %r14, %rdi
callq 0x32631
movq %rax, 0x48(%r12)
testq %rax, %rax
je 0x24904
cmpl $0x1, 0x8(%rax)
jne 0x24904
movq %r14, %rdi
movq %rax, %rsi
callq 0x1caed
movq %rax, 0x40(%r12)
testq %rax, %rax
je 0x24904
cmpl $0x0, 0x34(%rax)
jne 0x2444d
movq 0x18(%r14), %rdi
callq 0x4012e
cmpl $0x2, %eax
je 0x2444d
movq %r15, %rdi
callq 0x47a0
movl $0x1, 0x8854(%r14)
movq %r15, %rdi
callq 0x43f0
jmp 0x2444d
movq 0x28(%rdi), %rdx
imulq $0x70, %rax, %rsi
cmpl $-0x1, 0x8(%rdx,%rsi)
jne 0x24849
movq 0x28(%rdi), %rdx
imulq $0x70, %rax, %rsi
movl 0x8(%rdx,%rsi), %r8d
cmpl %ecx, %r8d
setl %r9b
cmpl $-0x1, %r8d
setne %r8b
testb %r8b, %r9b
jne 0x24849
cmpl %ecx, 0x8(%rdx,%rsi)
jne 0x249a5
cmpl $-0x1, %ecx
je 0x24993
leaq (%rdx,%rsi), %r8
movl 0x18(%r8), %r8d
cmpl 0x230(%r14), %r8d
jg 0x249a5
cmpl $-0x1, %ecx
je 0x24993
movl 0x5c(%rdx,%rsi), %ecx
cmpl 0x22c(%r14), %ecx
jge 0x24993
incl %eax
movl %eax, 0x5c(%r12)
jmp 0x24400
xorl %ecx, %ecx
movl 0x228(%r14), %edx
cmpl %edx, %eax
jl 0x24879
movl 0xc(%r12), %esi
addl 0x8(%r12), %esi
cmpl 0x22c(%r14), %esi
jg 0x24951
movslq (%r12), %rsi
movq %r14, %rdi
movl $0x1, %edx
callq 0x391a3
testl %eax, %eax
jne 0x24904
movq 0x38(%r14), %rdi
callq 0x35cde
movq %r14, %rdi
callq 0x360e5
movq %rax, 0x38(%r14)
testq %rax, %rax
je 0x24904
movq %rax, %r12
cmpl $0x0, (%rax)
je 0x24897
movl 0x4(%r12), %eax
cmpl $-0x2, %eax
sete %cl
jne 0x24857
jmp 0x24762
movq %r12, %rdi
callq 0x35cde
movq $0x0, 0x38(%r14)
movl %ebp, 0x88f8(%r14)
movl %ebp, 0x8848(%r14)
cmpq $0x0, 0x8860(%r14)
je 0x24907
cmpl $0x0, 0x88f8(%r14)
je 0x24915
movq 0x8868(%r14), %rdi
callq 0x420a7
testl %eax, %eax
je 0x24915
xorl %r13d, %r13d
testq %r13, %r13
jne 0x24400
jmp 0x249c3
movq 0x8868(%r14), %rdi
callq 0x42011
testq %rax, %rax
je 0x2494a
movq 0x10(%rax), %rcx
testq %rcx, %rcx
je 0x2494a
movq 0x8(%rcx), %rdx
movq 0x10(%rcx), %r13
movq %rdx, 0x38(%r14)
movq %rax, %rdi
movl $0x1, %esi
callq 0x4212d
jmp 0x24907
callq 0x5402
jmp 0x24904
cmpl %edx, %eax
setne %al
notb %cl
testb %al, %cl
je 0x24762
jmp 0x24904
movq %r13, %rdi
movq %r12, %rsi
callq 0x53c4
jmp 0x24904
movl $0x1, 0x8848(%r14)
movq %r13, %rdi
callq 0x35ef7
movq $0x0, 0x80(%r12)
jmp 0x24904
leal 0x1(%rax), %ecx
imulq $0x70, %rax, %rbx
addq 0x28(%rdi), %rbx
movl %ecx, 0x5c(%r12)
jmp 0x249c3
movl $0x1, 0x8848(%r14)
callq 0x35ef7
movq $0x0, 0x80(%r12)
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq