// File: /workspace/github_c_makefile_star2_O1/samtools[P]htslib/faidx.c
// Function: fai_get_val
static int fai_get_val(const faidx_t *fai, const char *str,
                       hts_pos_t *len, faidx1_t *val, hts_pos_t *fbeg, hts_pos_t *fend) {
    khiter_t iter;
    khash_t(s) *h;
    int id;
    hts_pos_t beg, end;

    if (!fai_parse_region(fai, str, &id, &beg, &end, 0)) {
        hts_log_warning("Reference %s not found in FASTA file, returning empty sequence", str);
        *len = -2;
        return 1;
    }

    h = fai->hash;
    iter = kh_get(s, h, faidx_iseq(fai, id));
    if (iter >= kh_end(h)) {
        // should have already been caught above
        abort();
    }
    *val = kh_value(h, iter);

    if (beg >= val->len) beg = val->len;
    if (end >= val->len) end = val->len;
    if (beg > end) beg = end;

    *fbeg = beg;
    *fend = end;

    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %r9, %rbx
movq %r8, %r14
movq %rcx, %r15
movq %rdx, %r12
movq %rsi, %r13
movq %rdi, %rbp
movl $0x0, (%rsp)
leaq 0xbd8(%rip), %r8        # 0x85aec
leaq 0x2c(%rsp), %rsi
leaq 0x10(%rsp), %rdx
leaq 0x20(%rsp), %rcx
movq %r13, %rdi
movq %rbp, %r9
callq 0x1a16d
testq %rax, %rax
je 0x84f8e
movq 0x18(%rbp), %rax
movq %rax, 0x18(%rsp)
movl (%rax), %edx
testl %edx, %edx
movq %r15, 0x48(%rsp)
je 0x84fbd
movq %rbx, 0x40(%rsp)
movq 0x10(%rbp), %rax
movslq 0x2c(%rsp), %rcx
movq (%rax,%rcx,8), %r12
leal -0x1(%rdx), %esi
movb (%r12), %cl
testb %cl, %cl
movq %r14, 0x38(%rsp)
movq %rdx, 0x30(%rsp)
je 0x84fc5
leaq 0x1(%r12), %rax
movl $0x811c9dc5, %ebx       # imm = 0x811C9DC5
movzbl %cl, %ecx
xorl %ebx, %ecx
imull $0x1000193, %ecx, %ebx  # imm = 0x1000193
movb (%rax), %cl
incq %rax
testb %cl, %cl
jne 0x84f78
jmp 0x84fca
leaq 0x1f4aa(%rip), %rsi     # 0xa443f
leaq 0x1f4af(%rip), %rdx     # 0xa444b
movl $0x3, %edi
movq %r13, %rcx
xorl %eax, %eax
callq 0x14378
movq $-0x2, (%r12)
movl $0x1, %eax
jmp 0x850cd
xorl %r15d, %r15d
jmp 0x85060
movl $0x811c9dc5, %ebx       # imm = 0x811C9DC5
andl %esi, %ebx
movq 0x18(%rsp), %rax
movq 0x10(%rax), %rdx
movl $0x1, %r13d
movl %ebx, %r15d
movl %esi, 0x28(%rsp)
movq %rdx, 0x50(%rsp)
movl %r15d, %eax
shrl $0x4, %eax
movl (%rdx,%rax,4), %r14d
leal (%r15,%r15), %ebp
andl $0x1e, %ebp
movl %r14d, %eax
movl %ebp, %ecx
shrl %cl, %eax
testb $0x2, %al
jne 0x85044
testb $0x1, %al
jne 0x8502c
movq 0x18(%rsp), %rax
movq 0x18(%rax), %rax
movl %r15d, %ecx
movq (%rax,%rcx,8), %rdi
movq %r12, %rsi
callq 0x46c0
movq 0x50(%rsp), %rdx
movl 0x28(%rsp), %esi
testl %eax, %eax
je 0x85044
addl %r13d, %r15d
andl %esi, %r15d
incl %r13d
cmpl %ebx, %r15d
jne 0x84fe7
movq 0x30(%rsp), %rdx
movl %edx, %r15d
jmp 0x85056
movl %ebp, %ecx
shrl %cl, %r14d
testb $0x3, %r14b
movq 0x30(%rsp), %rdx
cmovnel %edx, %r15d
movq 0x40(%rsp), %rbx
movq 0x38(%rsp), %r14
cmpl %edx, %r15d
jae 0x850dc
movq 0x18(%rsp), %rax
movq 0x20(%rax), %rax
movl %r15d, %ecx
leaq (%rcx,%rcx,4), %rcx
movq 0x20(%rax,%rcx,8), %rdx
movq 0x48(%rsp), %rsi
movq %rdx, 0x20(%rsi)
movups (%rax,%rcx,8), %xmm0
movups 0x10(%rax,%rcx,8), %xmm1
movups %xmm1, 0x10(%rsi)
movups %xmm0, (%rsi)
movq 0x10(%rsi), %rax
cmpq %rax, 0x10(%rsp)
jb 0x850a3
movq %rax, 0x10(%rsp)
cmpq %rax, 0x20(%rsp)
jb 0x850af
movq %rax, 0x20(%rsp)
movq 0x20(%rsp), %rax
cmpq %rax, 0x10(%rsp)
jle 0x850c0
movq %rax, 0x10(%rsp)
movq 0x10(%rsp), %rcx
movq %rcx, (%r14)
movq %rax, (%rbx)
xorl %eax, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x4270