// File: /workspace/github_c_makefile_star2_O2/icebert[P]pblat/htslib/cram/cram_io.c
// Function: load_ref_portion
static char *load_ref_portion(BGZF *fp, ref_entry *e, int start, int end) {
    off_t offset, len;
    char *seq;

    if (end < start)
	end = start;

    /*
     * Compute locations in file. This is trivial for the MD5 files, but
     * is still necessary for the fasta variants.
     */
    offset = e->line_length
	? e->offset + (start-1)/e->bases_per_line * e->line_length +
	  (start-1) % e->bases_per_line
	: start-1;

    len = (e->line_length
	   ? e->offset + (end-1)/e->bases_per_line * e->line_length + 
	     (end-1) % e->bases_per_line
	   : end-1) - offset + 1;

    if (bgzf_useek(fp, offset, SEEK_SET) < 0) {
	perror("bgzf_useek() on reference file");
	return NULL;
    }

    if (len == 0 || !(seq = malloc(len))) {
	return NULL;
    }

    if (len != bgzf_read(fp, seq, len)) {
	perror("bgzf_read() on reference file");
	free(seq);
	return NULL;
    }

    /* Strip white-space if required. */
    if (len != end-start+1) {
	int i, j;
	char *cp = seq;
	char *cp_to;

	for (i = j = 0; i < len; i++) {
	    if (cp[i] >= '!' && cp[i] <= '~')
		cp[j++] = toupper(cp[i]);
	}
	cp_to = cp+j;

	if (cp_to - seq != end-start+1) {
	    fprintf(stderr, "Malformed reference file?\n");
	    free(seq);
	    return NULL;
	}
    } else {
	int i;
	for (i = 0; i < len; i++) {
	    seq[i] = toupper(seq[i]);
	}
    }

    return seq;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %ecx, %ebx
movl %edx, %r12d
movq %rdi, %r13
cmpl %edx, %ecx
cmovlel %edx, %ebx
movl 0x24(%rsi), %edi
testl %edi, %edi
je 0x4f7ae
movq 0x18(%rsi), %r8
leal -0x1(%r12), %eax
movl 0x20(%rsi), %esi
cltd
idivl %esi
movl %eax, %ecx
movl %edx, %r14d
leal -0x1(%rbx), %eax
cltd
idivl %esi
movl %edx, %r15d
imull %edi, %ecx
movslq %ecx, %rcx
addq %r8, %r14
addq %rcx, %r14
imull %edi, %eax
cltq
addq %r8, %r15
addq %rax, %r15
jmp 0x4f7b7
leal -0x1(%r12), %r14d
leal -0x1(%rbx), %r15d
movq %r13, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x5db46
testl %eax, %eax
js 0x4f88a
subq %r14, %r15
movq %r15, %rbp
incq %rbp
je 0x4f8ac
movq %rbp, %rdi
callq 0x69d0
testq %rax, %rax
je 0x4f8ac
movq %rax, %r14
movq %r13, %rdi
movq %rax, %rsi
movq %rbp, %rdx
callq 0x5ca56
cmpq %rax, %rbp
jne 0x4f898
subl %r12d, %ebx
incl %ebx
movslq %ebx, %rax
cmpq %rax, %rbp
jne 0x4f837
xorl %ebx, %ebx
cmpq %rbx, %r15
jl 0x4f8af
callq 0x6100
movq (%rax), %rax
movsbq (%r14,%rbx), %rcx
movb (%rax,%rcx,4), %al
movb %al, (%r14,%rbx)
incq %rbx
jmp 0x4f815
xorl %r12d, %r12d
xorl %ebp, %ebp
cmpq %r12, %r15
jl 0x4f868
movzbl (%r14,%r12), %r13d
leal -0x7f(%r13), %eax
cmpb $-0x5e, %al
jb 0x4f863
callq 0x6100
movq (%rax), %rax
movb (%rax,%r13,4), %al
movslq %ebp, %rcx
incl %ebp
movb %al, (%r14,%rcx)
incq %r12
jmp 0x4f83c
cmpl %ebx, %ebp
je 0x4f8af
movq 0x63765(%rip), %rax     # 0xb2fd8
movq (%rax), %rcx
leaq 0x388e6(%rip), %rdi     # 0x88163
pushq $0x1a
popq %rsi
pushq $0x1
popq %rdx
callq 0x6e70
jmp 0x4f8a4
leaq 0x38895(%rip), %rdi     # 0x88126
callq 0x6590
jmp 0x4f8ac
leaq 0x388a6(%rip), %rdi     # 0x88145
callq 0x6590
movq %r14, %rdi
callq 0x68a0
xorl %r14d, %r14d
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq