// File: /workspace/github_c_makefile_star2_O0/icebert[P]pblat/htslib/./cram/cram_io.h
// Function: safe_itf8_get
static inline int safe_itf8_get(const char *cp, const char *endp,
                                int32_t *val_p) {
    const unsigned char *up = (unsigned char *)cp;

    if (endp - cp < 5 &&
        (cp >= endp || endp - cp < itf8_bytes[up[0]>>4])) {
        *val_p = 0;
        return 0;
    }

    if (up[0] < 0x80) {
        *val_p =   up[0];
        return 1;
    } else if (up[0] < 0xc0) {
        *val_p = ((up[0] <<8) |  up[1])                           & 0x3fff;
        return 2;
    } else if (up[0] < 0xe0) {
        *val_p = ((up[0]<<16) | (up[1]<< 8) |  up[2])             & 0x1fffff;
        return 3;
    } else if (up[0] < 0xf0) {
        *val_p = ((up[0]<<24) | (up[1]<<16) | (up[2]<<8) | up[3]) & 0x0fffffff;
        return 4;
    } else {
        *val_p = ((up[0] & 0x0f)<<28) | (up[1]<<20) | (up[2]<<12) | (up[3]<<4) | (up[4] & 0x0f);
        return 5;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x18(%rbp), %rax
movq -0x10(%rbp), %rcx
subq %rcx, %rax
cmpq $0x5, %rax
jge 0xaf0b1
movq -0x10(%rbp), %rax
cmpq -0x18(%rbp), %rax
jae 0xaf09b
movq -0x18(%rbp), %rax
movq -0x10(%rbp), %rcx
subq %rcx, %rax
movq -0x28(%rbp), %rcx
movzbl (%rcx), %ecx
sarl $0x4, %ecx
movslq %ecx, %rdx
leaq 0x33a9e(%rip), %rcx     # 0xe2b30
movslq (%rcx,%rdx,4), %rcx
cmpq %rcx, %rax
jge 0xaf0b1
movq -0x20(%rbp), %rax
movl $0x0, (%rax)
movl $0x0, -0x4(%rbp)
jmp 0xaf1f8
movq -0x28(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x80, %eax
jge 0xaf0d8
movq -0x28(%rbp), %rax
movzbl (%rax), %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
movl $0x1, -0x4(%rbp)
jmp 0xaf1f8
movq -0x28(%rbp), %rax
movzbl (%rax), %eax
cmpl $0xc0, %eax
jge 0xaf112
movq -0x28(%rbp), %rax
movzbl (%rax), %ecx
shll $0x8, %ecx
movq -0x28(%rbp), %rax
movzbl 0x1(%rax), %eax
orl %eax, %ecx
andl $0x3fff, %ecx           # imm = 0x3FFF
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
movl $0x2, -0x4(%rbp)
jmp 0xaf1f8
movq -0x28(%rbp), %rax
movzbl (%rax), %eax
cmpl $0xe0, %eax
jge 0xaf159
movq -0x28(%rbp), %rax
movzbl (%rax), %ecx
shll $0x10, %ecx
movq -0x28(%rbp), %rax
movzbl 0x1(%rax), %eax
shll $0x8, %eax
orl %eax, %ecx
movq -0x28(%rbp), %rax
movzbl 0x2(%rax), %eax
orl %eax, %ecx
andl $0x1fffff, %ecx         # imm = 0x1FFFFF
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
movl $0x3, -0x4(%rbp)
jmp 0xaf1f8
movq -0x28(%rbp), %rax
movzbl (%rax), %eax
cmpl $0xf0, %eax
jge 0xaf1aa
movq -0x28(%rbp), %rax
movzbl (%rax), %ecx
shll $0x18, %ecx
movq -0x28(%rbp), %rax
movzbl 0x1(%rax), %eax
shll $0x10, %eax
orl %eax, %ecx
movq -0x28(%rbp), %rax
movzbl 0x2(%rax), %eax
shll $0x8, %eax
orl %eax, %ecx
movq -0x28(%rbp), %rax
movzbl 0x3(%rax), %eax
orl %eax, %ecx
andl $0xfffffff, %ecx        # imm = 0xFFFFFFF
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
movl $0x4, -0x4(%rbp)
jmp 0xaf1f8
movq -0x28(%rbp), %rax
movzbl (%rax), %ecx
andl $0xf, %ecx
shll $0x1c, %ecx
movq -0x28(%rbp), %rax
movzbl 0x1(%rax), %eax
shll $0x14, %eax
orl %eax, %ecx
movq -0x28(%rbp), %rax
movzbl 0x2(%rax), %eax
shll $0xc, %eax
orl %eax, %ecx
movq -0x28(%rbp), %rax
movzbl 0x3(%rax), %eax
shll $0x4, %eax
orl %eax, %ecx
movq -0x28(%rbp), %rax
movzbl 0x4(%rax), %eax
andl $0xf, %eax
orl %eax, %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
movl $0x5, -0x4(%rbp)
movl -0x4(%rbp), %eax
popq %rbp
retq
nopl (%rax)