// File: /workspace/github_c_makefile_star2_O0/mijallen[P]SimpleHTTPServer/lib/libyaml/src/api.c
// Function: yaml_check_utf8
static int
yaml_check_utf8(yaml_char_t *start, size_t length)
{
    yaml_char_t *end = start+length;
    yaml_char_t *pointer = start;

    while (pointer < end) {
        unsigned char octet;
        unsigned int width;
        unsigned int value;
        size_t k;

        octet = pointer[0];
        width = (octet & 0x80) == 0x00 ? 1 :
                (octet & 0xE0) == 0xC0 ? 2 :
                (octet & 0xF0) == 0xE0 ? 3 :
                (octet & 0xF8) == 0xF0 ? 4 : 0;
        value = (octet & 0x80) == 0x00 ? octet & 0x7F :
                (octet & 0xE0) == 0xC0 ? octet & 0x1F :
                (octet & 0xF0) == 0xE0 ? octet & 0x0F :
                (octet & 0xF8) == 0xF0 ? octet & 0x07 : 0;
        if (!width) return 0;
        if (pointer+width > end) return 0;
        for (k = 1; k < width; k ++) {
            octet = pointer[k];
            if ((octet & 0xC0) != 0x80) return 0;
            value = (value << 6) + (octet & 0x3F);
        }
        if (!((width == 1) ||
            (width == 2 && value >= 0x80) ||
            (width == 3 && value >= 0x800) ||
            (width == 4 && value >= 0x10000))) return 0;

        pointer += width;
    }

    return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rax
addq -0x18(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
cmpq -0x20(%rbp), %rax
jae 0x4b59
movq -0x28(%rbp), %rax
movb (%rax), %al
movb %al, -0x29(%rbp)
movzbl -0x29(%rbp), %eax
andl $0x80, %eax
cmpl $0x0, %eax
jne 0x498f
movl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x49ec
movzbl -0x29(%rbp), %eax
andl $0xe0, %eax
cmpl $0xc0, %eax
jne 0x49a9
movl $0x2, %eax
movl %eax, -0x48(%rbp)
jmp 0x49e6
movzbl -0x29(%rbp), %eax
andl $0xf0, %eax
cmpl $0xe0, %eax
jne 0x49c3
movl $0x3, %eax
movl %eax, -0x4c(%rbp)
jmp 0x49e0
movzbl -0x29(%rbp), %edx
andl $0xf8, %edx
xorl %eax, %eax
movl $0x4, %ecx
cmpl $0xf0, %edx
cmovel %ecx, %eax
movl %eax, -0x4c(%rbp)
movl -0x4c(%rbp), %eax
movl %eax, -0x48(%rbp)
movl -0x48(%rbp), %eax
movl %eax, -0x44(%rbp)
movl -0x44(%rbp), %eax
movl %eax, -0x30(%rbp)
movzbl -0x29(%rbp), %eax
andl $0x80, %eax
cmpl $0x0, %eax
jne 0x4a0c
movzbl -0x29(%rbp), %eax
andl $0x7f, %eax
movl %eax, -0x50(%rbp)
jmp 0x4a79
movzbl -0x29(%rbp), %eax
andl $0xe0, %eax
cmpl $0xc0, %eax
jne 0x4a28
movzbl -0x29(%rbp), %eax
andl $0x1f, %eax
movl %eax, -0x54(%rbp)
jmp 0x4a73
movzbl -0x29(%rbp), %eax
andl $0xf0, %eax
cmpl $0xe0, %eax
jne 0x4a44
movzbl -0x29(%rbp), %eax
andl $0xf, %eax
movl %eax, -0x58(%rbp)
jmp 0x4a6d
movzbl -0x29(%rbp), %eax
andl $0xf8, %eax
cmpl $0xf0, %eax
jne 0x4a60
movzbl -0x29(%rbp), %eax
andl $0x7, %eax
movl %eax, -0x5c(%rbp)
jmp 0x4a67
xorl %eax, %eax
movl %eax, -0x5c(%rbp)
jmp 0x4a67
movl -0x5c(%rbp), %eax
movl %eax, -0x58(%rbp)
movl -0x58(%rbp), %eax
movl %eax, -0x54(%rbp)
movl -0x54(%rbp), %eax
movl %eax, -0x50(%rbp)
movl -0x50(%rbp), %eax
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x30(%rbp)
jne 0x4a91
movl $0x0, -0x4(%rbp)
jmp 0x4b60
movq -0x28(%rbp), %rax
movl -0x30(%rbp), %ecx
addq %rcx, %rax
cmpq -0x20(%rbp), %rax
jbe 0x4aad
movl $0x0, -0x4(%rbp)
jmp 0x4b60
movq $0x1, -0x40(%rbp)
movq -0x40(%rbp), %rax
movl -0x30(%rbp), %ecx
cmpq %rcx, %rax
jae 0x4b08
movq -0x28(%rbp), %rax
movq -0x40(%rbp), %rcx
movb (%rax,%rcx), %al
movb %al, -0x29(%rbp)
movzbl -0x29(%rbp), %eax
andl $0xc0, %eax
cmpl $0x80, %eax
je 0x4ae8
movl $0x0, -0x4(%rbp)
jmp 0x4b60
movl -0x34(%rbp), %eax
shll $0x6, %eax
movzbl -0x29(%rbp), %ecx
andl $0x3f, %ecx
addl %ecx, %eax
movl %eax, -0x34(%rbp)
movq -0x40(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x40(%rbp)
jmp 0x4ab5
cmpl $0x1, -0x30(%rbp)
je 0x4b44
cmpl $0x2, -0x30(%rbp)
jne 0x4b1d
cmpl $0x80, -0x34(%rbp)
jae 0x4b44
cmpl $0x3, -0x30(%rbp)
jne 0x4b2c
cmpl $0x800, -0x34(%rbp)     # imm = 0x800
jae 0x4b44
cmpl $0x4, -0x30(%rbp)
jne 0x4b3b
cmpl $0x10000, -0x34(%rbp)   # imm = 0x10000
jae 0x4b44
movl $0x0, -0x4(%rbp)
jmp 0x4b60
movl -0x30(%rbp), %ecx
movq -0x28(%rbp), %rax
movl %ecx, %ecx
addq %rcx, %rax
movq %rax, -0x28(%rbp)
jmp 0x4960
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
popq %rbp
retq
nopw %cs:(%rax,%rax)