// File: /workspace/github_cpp_makefile_star2_O2/evincarofautumn[P]protodata/vendor/utf8/core.h
// Function: utf8::internal::utf_error utf8::internal::validate_next<__gnu_cxx::__normal_iterator<char*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>>(__gnu_cxx::__normal_iterator<char*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>&, __gnu_cxx::__normal_iterator<char*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>, unsigned int&)
utf_error validate_next(octet_iterator& it, octet_iterator end, uint32_t& code_point)
    {
        // Save the original value of it so we can go back in case of failure
        // Of course, it does not make much sense with i.e. stream iterators
        octet_iterator original_it = it;

        uint32_t cp = 0;
        // Determine the sequence length based on the lead octet
        typedef typename std::iterator_traits<octet_iterator>::difference_type octet_difference_type;
        const octet_difference_type length = utf8::internal::sequence_length(it);

        // Get trail octets and calculate the code point
        utf_error err = UTF8_OK;
        switch (length) {
            case 0: 
                return INVALID_LEAD;
            case 1:
                err = utf8::internal::get_sequence_1(it, end, cp);
                break;
            case 2:
                err = utf8::internal::get_sequence_2(it, end, cp);
            break;
            case 3:
                err = utf8::internal::get_sequence_3(it, end, cp);
            break;
            case 4:
                err = utf8::internal::get_sequence_4(it, end, cp);
            break;
        }

        if (err == UTF8_OK) {
            // Decoding succeeded. Now, security checks...
            if (utf8::internal::is_code_point_valid(cp)) {
                if (!utf8::internal::is_overlong_sequence(cp, length)){
                    // Passed! Return here.
                    code_point = cp;
                    ++it;
                    return UTF8_OK;
                }
                else
                    err = OVERLONG_SEQUENCE;
            }
            else 
                err = INVALID_CODE_POINT;
        }

        // Failure branch - restore the original value of the iterator
        it = original_it;
        return err;
    }

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x10, %rsp
movq %rdx, %r15
movq %rsi, %r13
movq %rdi, %rbx
movq (%rdi), %r14
andl $0x0, 0xc(%rsp)
movq %r14, %rdi
callq 0x9b8c
movq %rax, %r12
cmpq $0x4, %rax
ja 0x9b33
leaq 0x1cdd(%rip), %rax      # 0xb7b0
movslq (%rax,%r12,4), %rcx
addq %rax, %rcx
jmpq *%rcx
pushq $0x2
popq %rax
jmp 0x9b7e
leaq 0xc(%rsp), %rdx
movq %rbx, %rdi
movq %r13, %rsi
callq 0x9c75
jmp 0x9b18
leaq 0xc(%rsp), %rdx
movq %rbx, %rdi
movq %r13, %rsi
callq 0x9bc9
jmp 0x9b18
leaq 0xc(%rsp), %rdx
movq %rbx, %rdi
movq %r13, %rsi
callq 0x9c08
testl %eax, %eax
jne 0x9b7b
movl 0xc(%rsp), %edi
jmp 0x9b35
movq (%rbx), %rax
cmpq %r13, %rax
je 0x9b78
movzbl (%rax), %edi
movl %edi, 0xc(%rsp)
jmp 0x9b35
xorl %edi, %edi
cmpl $0x110000, %edi         # imm = 0x110000
setae %al
movl %edi, %ecx
andl $0xfffff800, %ecx       # imm = 0xFFFFF800
cmpl $0xd800, %ecx           # imm = 0xD800
sete %cl
orb %al, %cl
jne 0x9b63
movq %r12, %rsi
callq 0x9d15
testb %al, %al
je 0x9b67
pushq $0x4
jmp 0x9b7a
pushq $0x5
jmp 0x9b7a
movl 0xc(%rsp), %eax
movl %eax, (%r15)
movq (%rbx), %r14
incq %r14
xorl %eax, %eax
jmp 0x9b7b
pushq $0x1
popq %rax
movq %r14, (%rbx)
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq