// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movl %ecx, -0x20(%rbp)
movl -0x20(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jge 0x81c17
movl -0x1c(%rbp), %eax
movl %eax, -0x20(%rbp)
movq -0x18(%rbp), %rax
cmpl $0x0, 0x24(%rax)
je 0x81c71
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x70(%rbp)
movl -0x1c(%rbp), %eax
subl $0x1, %eax
movq -0x18(%rbp), %rcx
cltd
idivl 0x20(%rcx)
movl %eax, %ecx
movq -0x70(%rbp), %rax
movq -0x18(%rbp), %rdx
imull 0x24(%rdx), %ecx
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x68(%rbp)
movl -0x1c(%rbp), %eax
subl $0x1, %eax
movq -0x18(%rbp), %rcx
cltd
idivl 0x20(%rcx)
movq -0x68(%rbp), %rax
movslq %edx, %rcx
addq %rcx, %rax
movq %rax, -0x60(%rbp)
jmp 0x81c7d
movl -0x1c(%rbp), %eax
subl $0x1, %eax
cltq
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x18(%rbp), %rax
cmpl $0x0, 0x24(%rax)
je 0x81ce5
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x88(%rbp)
movl -0x20(%rbp), %eax
subl $0x1, %eax
movq -0x18(%rbp), %rcx
cltd
idivl 0x20(%rcx)
movl %eax, %ecx
movq -0x88(%rbp), %rax
movq -0x18(%rbp), %rdx
imull 0x24(%rdx), %ecx
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x80(%rbp)
movl -0x20(%rbp), %eax
subl $0x1, %eax
movq -0x18(%rbp), %rcx
cltd
idivl 0x20(%rcx)
movq -0x80(%rbp), %rax
movslq %edx, %rcx
addq %rcx, %rax
movq %rax, -0x78(%rbp)
jmp 0x81cf1
movl -0x20(%rbp), %eax
subl $0x1, %eax
cltq
movq %rax, -0x78(%rbp)
movq -0x78(%rbp), %rax
subq -0x28(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rdi
movq -0x28(%rbp), %rsi
xorl %edx, %edx
callq 0x9e5b0
cmpl $0x0, %eax
jge 0x81d2e
leaq 0x61407(%rip), %rdi     # 0xe3123
callq 0x6590
movq $0x0, -0x8(%rbp)
jmp 0x81ece
cmpq $0x0, -0x30(%rbp)
je 0x81d48
movq -0x30(%rbp), %rdi
callq 0x69c0
movq %rax, -0x38(%rbp)
cmpq $0x0, %rax
jne 0x81d55
movq $0x0, -0x8(%rbp)
jmp 0x81ece
movq -0x30(%rbp), %rax
movq %rax, -0x90(%rbp)
movq -0x10(%rbp), %rdi
movq -0x38(%rbp), %rsi
movq -0x30(%rbp), %rdx
callq 0x9c7b0
movq %rax, %rcx
movq -0x90(%rbp), %rax
cmpq %rcx, %rax
je 0x81da2
leaq 0x613bb(%rip), %rdi     # 0xe3142
callq 0x6590
movq -0x38(%rbp), %rdi
callq 0x6880
movq $0x0, -0x8(%rbp)
jmp 0x81ece
movq -0x30(%rbp), %rax
movl -0x20(%rbp), %ecx
subl -0x1c(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
cmpq %rcx, %rax
je 0x81e8a
movq -0x38(%rbp), %rax
movq %rax, -0x48(%rbp)
movl $0x0, -0x40(%rbp)
movl $0x0, -0x3c(%rbp)
movslq -0x3c(%rbp), %rax
cmpq -0x30(%rbp), %rax
jge 0x81e32
movq -0x48(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x21, %eax
jl 0x81e25
movq -0x48(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x7e, %eax
jg 0x81e25
movq -0x48(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movsbl (%rax,%rcx), %edi
callq 0x6de0
movb %al, %dl
movq -0x48(%rbp), %rax
movl -0x40(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x40(%rbp)
movslq %ecx, %rcx
movb %dl, (%rax,%rcx)
jmp 0x81e27
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x81dd1
movq -0x48(%rbp), %rax
movslq -0x40(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
movq -0x38(%rbp), %rcx
subq %rcx, %rax
movl -0x20(%rbp), %ecx
subl -0x1c(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
cmpq %rcx, %rax
je 0x81e88
movq 0x8316c(%rip), %rax     # 0x104fd0
movq (%rax), %rdi
leaq 0x612f2(%rip), %rsi     # 0xe3160
movb $0x0, %al
callq 0x6a80
movq -0x38(%rbp), %rdi
callq 0x6880
movq $0x0, -0x8(%rbp)
jmp 0x81ece
jmp 0x81ec6
movl $0x0, -0x54(%rbp)
movslq -0x54(%rbp), %rax
cmpq -0x30(%rbp), %rax
jge 0x81ec4
movq -0x38(%rbp), %rax
movslq -0x54(%rbp), %rcx
movsbl (%rax,%rcx), %edi
callq 0x6de0
movb %al, %dl
movq -0x38(%rbp), %rax
movslq -0x54(%rbp), %rcx
movb %dl, (%rax,%rcx)
movl -0x54(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x54(%rbp)
jmp 0x81e91
jmp 0x81ec6
movq -0x38(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x90, %rsp
popq %rbp
retq
nopl (%rax,%rax)