// File: /workspace/github_c_makefile_star2_O1/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 $0x38, %rsp
movq %rcx, %r10
movl %esi, 0x8(%rsp)
movq 0x18(%rdi), %rax
movq %rax, (%rsp)
movl (%rax), %eax
testl %eax, %eax
je 0x8572a
movq %rax, 0x10(%rsp)
leal -0x1(%rax), %esi
movb (%r10), %cl
testb %cl, %cl
movq %r9, 0x28(%rsp)
movq %r8, 0x20(%rsp)
movq %rdx, 0x18(%rsp)
je 0x85731
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 0x85712
jmp 0x85737
xorl %ebx, %ebx
jmp 0x857cc
movl $0x811c9dc5, %r12d      # imm = 0x811C9DC5
andl %esi, %r12d
movq (%rsp), %rax
movq 0x10(%rax), %r15
movl $0x1, %ebp
movl %r12d, %ebx
movl %esi, 0xc(%rsp)
movq %r10, 0x30(%rsp)
movl %ebx, %eax
shrl $0x4, %eax
movl (%r15,%rax,4), %r14d
leal (%rbx,%rbx), %r13d
andl $0x1e, %r13d
movl %r14d, %eax
movl %r13d, %ecx
shrl %cl, %eax
testb $0x2, %al
jne 0x857ab
testb $0x1, %al
jne 0x85797
movq (%rsp), %rax
movq 0x18(%rax), %rax
movl %ebx, %ecx
movq (%rax,%rcx,8), %rdi
movq %r10, %rsi
callq 0x46c0
movl 0xc(%rsp), %esi
movq 0x30(%rsp), %r10
testl %eax, %eax
je 0x857ab
addl %ebp, %ebx
andl %esi, %ebx
incl %ebp
cmpl %r12d, %ebx
jne 0x85753
movq 0x10(%rsp), %rax
movl %eax, %ebx
jmp 0x857bd
movl %r13d, %ecx
shrl %cl, %r14d
testb $0x3, %r14b
movq 0x10(%rsp), %rax
cmovnel %eax, %ebx
movq 0x28(%rsp), %r9
movq 0x20(%rsp), %r8
movq 0x18(%rsp), %rdx
cmpl %eax, %ebx
jne 0x85806
movq 0x70(%rsp), %rax
testq %rax, %rax
je 0x857e1
movq $-0x2, (%rax)
leaq 0x1ed79(%rip), %rsi     # 0xa4561
leaq 0x1ed88(%rip), %rdx     # 0xa4577
movl $0x1, %r14d
movl $0x1, %edi
movq %r10, %rcx
xorl %eax, %eax
callq 0x14378
jmp 0x85880
movl %ebx, %eax
leaq (%rax,%rax,4), %rax
shlq $0x3, %rax
movq (%rsp), %rcx
addq 0x20(%rcx), %rax
testq %rdx, %rdx
je 0x85833
movq 0x20(%rax), %rcx
movq %rcx, 0x20(%rdx)
movups (%rax), %xmm0
movups 0x10(%rax), %xmm1
movups %xmm1, 0x10(%rdx)
movups %xmm0, (%rdx)
movq (%r9), %rcx
cmpq (%r8), %rcx
jge 0x8583e
movq %rcx, (%r8)
movq (%r8), %rdx
testq %rdx, %rdx
js 0x85851
movq 0x10(%rax), %rcx
cmpq %rdx, %rcx
jbe 0x85853
jmp 0x85856
xorl %ecx, %ecx
movq %rcx, (%r8)
movq (%r9), %rcx
testq %rcx, %rcx
js 0x85876
movq 0x10(%rax), %rax
xorl %r14d, %r14d
cmpq %rcx, %rax
ja 0x85880
movl 0x8(%rsp), %ecx
subq %rcx, %rax
movq %rax, (%r9)
jmp 0x85880
movq $0x0, (%r9)
xorl %r14d, %r14d
movl %r14d, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq