// File: /workspace/github_c_makefile_star2_O3/samtools[P]htslib/faidx.c
// Function: faidx_adjust_position
static int faidx_adjust_position(const faidx_t *fai, int end_adjust,
                                 faidx1_t *val_out, const char *c_name,
                                 hts_pos_t *p_beg_i, hts_pos_t *p_end_i,
                                 hts_pos_t *len) {
    khiter_t iter;
    faidx1_t *val;

    // Adjust position
    iter = kh_get(s, fai->hash, c_name);

    if (iter == kh_end(fai->hash)) {
        if (len)
            *len = -2;
        hts_log_error("The sequence \"%s\" was not found", c_name);
        return 1;
    }

    val = &kh_value(fai->hash, iter);

    if (val_out)
        *val_out = *val;

    if(*p_end_i < *p_beg_i)
        *p_beg_i = *p_end_i;

    if(*p_beg_i < 0)
        *p_beg_i = 0;
    else if(val->len <= *p_beg_i)
        *p_beg_i = val->len;

    if(*p_end_i < 0)
        *p_end_i = 0;
    else if(val->len <= *p_end_i)
        *p_end_i = val->len - end_adjust;

    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rcx, %r10
movq %rdx, 0x20(%rsp)
movl %esi, 0x14(%rsp)
movq %rdi, 0x8(%rsp)
movl (%rdi), %eax
testl %eax, %eax
movq %r9, 0x30(%rsp)
movq %r8, 0x28(%rsp)
je 0x831dd
movq %rax, 0x18(%rsp)
leal -0x1(%rax), %r15d
movb (%r10), %cl
testb %cl, %cl
je 0x831e5
leaq 0x1(%r10), %rax
movl $0x811c9dc5, %r12d      # imm = 0x811C9DC5
movzbl %cl, %ecx
xorl %r12d, %ecx
imull $0x1000193, %ecx, %r12d # imm = 0x1000193
movb (%rax), %cl
incq %rax
testb %cl, %cl
jne 0x831c5
jmp 0x831eb
xorl %r14d, %r14d
jmp 0x8326e
movl $0x811c9dc5, %r12d      # imm = 0x811C9DC5
andl %r15d, %r12d
movq 0x8(%rsp), %rax
movq 0x10(%rax), %rsi
movl $0x1, %r13d
movl %r12d, %r14d
movq %r10, 0x40(%rsp)
movq %rsi, 0x38(%rsp)
movl %r14d, %eax
shrl $0x4, %eax
movl (%rsi,%rax,4), %ebx
leal (%r14,%r14), %ebp
andl $0x1e, %ebp
movl %ebx, %eax
movl %ebp, %ecx
shrl %cl, %eax
testb $0x2, %al
jne 0x8325e
testb $0x1, %al
jne 0x8324e
movq 0x8(%rsp), %rax
movq 0x18(%rax), %rax
movl %r14d, %ecx
movq (%rax,%rcx,8), %rdi
movq %r10, %rsi
callq 0x46c0
movq 0x38(%rsp), %rsi
movq 0x40(%rsp), %r10
testl %eax, %eax
je 0x8325e
addl %r13d, %r14d
andl %r15d, %r14d
incl %r13d
cmpl %r12d, %r14d
jne 0x8320a
jmp 0x83273
movl %ebp, %ecx
shrl %cl, %ebx
testb $0x3, %bl
movq 0x18(%rsp), %rax
cmovnel %eax, %r14d
cmpl %eax, %r14d
jne 0x832ba
movq 0x80(%rsp), %rax
testq %rax, %rax
je 0x83287
movq $-0x2, (%rax)
leaq 0x1ea63(%rip), %rsi     # 0xa1cf1
leaq 0x1ea72(%rip), %rdx     # 0xa1d07
movl $0x1, %ebp
movl $0x1, %edi
movq %r10, %rcx
xorl %eax, %eax
callq 0x13de5
movl %ebp, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl %r14d, %eax
leaq (%rax,%rax,4), %rax
shlq $0x3, %rax
movq 0x8(%rsp), %rcx
addq 0x20(%rcx), %rax
movq 0x20(%rsp), %rdx
testq %rdx, %rdx
je 0x832ee
movq 0x20(%rax), %rcx
movq %rcx, 0x20(%rdx)
movups (%rax), %xmm0
movups 0x10(%rax), %xmm1
movups %xmm1, 0x10(%rdx)
movups %xmm0, (%rdx)
movq 0x30(%rsp), %rsi
movq (%rsi), %rdx
movq 0x28(%rsp), %rdi
movq (%rdi), %rcx
cmpq %rcx, %rdx
jge 0x83309
movq %rdx, (%rdi)
movq %rdx, %rcx
testq %rcx, %rcx
js 0x83319
movq 0x10(%rax), %rdx
cmpq %rcx, %rdx
jbe 0x8331b
jmp 0x8331e
xorl %edx, %edx
movq %rdx, (%rdi)
movq (%rsi), %rcx
testq %rcx, %rcx
js 0x83344
movq 0x10(%rax), %rax
xorl %ebp, %ebp
cmpq %rcx, %rax
ja 0x832a9
movl 0x14(%rsp), %ecx
subq %rcx, %rax
movq %rax, (%rsi)
jmp 0x832a9
movq $0x0, (%rsi)
xorl %ebp, %ebp
jmp 0x832a9