// File: /workspace/github_c_makefile_star2_O3/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 0xbfd(%rip), %r8        # 0x835b4
leaq 0x1c(%rsp), %rsi
leaq 0x50(%rsp), %rdx
leaq 0x48(%rsp), %rcx
movq %r13, %rdi
movq %rbp, %r9
callq 0x19c07
testq %rax, %rax
je 0x82a31
movq 0x18(%rbp), %rax
movq %rax, 0x10(%rsp)
movl (%rax), %edx
testl %edx, %edx
movq %rbx, 0x38(%rsp)
movq %r14, 0x30(%rsp)
movq %r15, 0x28(%rsp)
je 0x82a60
movq 0x10(%rbp), %rax
movslq 0x1c(%rsp), %rcx
movq (%rax,%rcx,8), %r12
leal -0x1(%rdx), %esi
movb (%r12), %cl
testb %cl, %cl
movq %rdx, 0x20(%rsp)
je 0x82a68
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 0x82a1b
jmp 0x82a6d
leaq 0x1f197(%rip), %rsi     # 0xa1bcf
leaq 0x1f19c(%rip), %rdx     # 0xa1bdb
movl $0x3, %edi
movq %r13, %rcx
xorl %eax, %eax
callq 0x13de5
movq $-0x2, (%r12)
movl $0x1, %eax
jmp 0x82b5c
xorl %r15d, %r15d
jmp 0x82af4
movl $0x811c9dc5, %ebx       # imm = 0x811C9DC5
andl %esi, %ebx
movq 0x10(%rsp), %rax
movq 0x10(%rax), %rdx
movl $0x1, %r13d
movl %ebx, %r15d
movl %esi, 0x18(%rsp)
movq %rdx, 0x40(%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 0x82ae2
testb $0x1, %al
jne 0x82acf
movq 0x10(%rsp), %rax
movq 0x18(%rax), %rax
movl %r15d, %ecx
movq (%rax,%rcx,8), %rdi
movq %r12, %rsi
callq 0x46c0
movq 0x40(%rsp), %rdx
movl 0x18(%rsp), %esi
testl %eax, %eax
je 0x82ae2
addl %r13d, %r15d
andl %esi, %r15d
incl %r13d
cmpl %ebx, %r15d
jne 0x82a8a
callq 0x4270
movl %ebp, %ecx
shrl %cl, %r14d
testb $0x3, %r14b
movq 0x20(%rsp), %rdx
cmovnel %edx, %r15d
cmpl %edx, %r15d
jae 0x82add
movq 0x10(%rsp), %rax
movq 0x20(%rax), %rax
movl %r15d, %ecx
leaq (%rcx,%rcx,4), %rcx
movq 0x20(%rax,%rcx,8), %rdx
movq 0x28(%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 0x50(%rsp), %rax
movq 0x10(%rsi), %rcx
cmpq %rcx, %rax
cmovaeq %rcx, %rax
movq 0x48(%rsp), %rdx
cmpq %rcx, %rdx
cmovbq %rdx, %rcx
cmpq %rcx, %rax
cmovgeq %rcx, %rax
movq 0x30(%rsp), %rdx
movq %rax, (%rdx)
movq 0x38(%rsp), %rax
movq %rcx, (%rax)
xorl %eax, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq