// File: /workspace/github_cpp_makefile_star2_O3/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 %rbx
subq $0x10, %rsp
movq %rdx, %r14
movq %rdi, %rbx
movq (%rdi), %r15
movl $0x0, 0xc(%rsp)
movzbl (%r15), %ecx
testb %cl, %cl
js 0xaa53
movl $0x1, %edx
cmpq %rsi, %r15
je 0xaaa9
cmpl $0x110000, %ecx         # imm = 0x110000
setae %sil
movl %ecx, %eax
andl $0xfffff800, %eax       # imm = 0xFFFFF800
cmpl $0xd800, %eax           # imm = 0xD800
sete %dil
movl $0x5, %eax
orb %sil, %dil
jne 0xab3b
cmpl $0x7f, %ecx
ja 0xaad3
movl $0x4, %eax
cmpl $0x1, %edx
je 0xab30
jmp 0xab3b
movl %ecx, %eax
andl $-0x20, %eax
cmpl $0xc0, %eax
jne 0xaab3
movl $0x1, %eax
cmpq %rsi, %r15
je 0xab3b
leaq 0x1(%r15), %rdx
movq %rdx, (%rbx)
cmpq %rsi, %rdx
je 0xab3b
movzbl (%rdx), %edx
movl %edx, %esi
andb $-0x40, %sil
movl $0x3, %eax
negb %sil
jno 0xab3b
andl $0x1f, %ecx
shll $0x6, %ecx
andl $0x3f, %edx
orl %edx, %ecx
movl $0x2, %edx
jmp 0xaa0f
movl $0x1, %eax
jmp 0xab3b
movl %ecx, %eax
andl $-0x10, %eax
cmpl $0xe0, %eax
jne 0xaae7
leaq 0xc(%rsp), %rdx
movq %rbx, %rdi
callq 0xab48
movl $0x3, %edx
jmp 0xab09
cmpl $0x7ff, %ecx            # imm = 0x7FF
ja 0xab16
movl $0x4, %eax
cmpl $0x2, %edx
je 0xab30
jmp 0xab3b
andl $-0x8, %ecx
movl $0x2, %eax
cmpl $0xf0, %ecx
jne 0xab3e
leaq 0xc(%rsp), %rdx
movq %rbx, %rdi
callq 0xabb7
movl $0x4, %edx
testl %eax, %eax
jne 0xab3b
movl 0xc(%rsp), %ecx
jmp 0xaa0f
cmpl $0x10000, %ecx          # imm = 0x10000
setb %sil
cmpl $0x3, %edx
setne %dl
movl $0x4, %eax
testb %dl, %sil
jne 0xab3b
movl %ecx, (%r14)
movq (%rbx), %r15
incq %r15
xorl %eax, %eax
movq %r15, (%rbx)
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
retq