// File: /workspace/github_cpp_makefile_star2_O1/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 %r12
pushq %rbx
pushq %rax
movq %rdx, %r14
movq %rdi, %rbx
movq (%rdi), %r15
movl $0x0, 0x4(%rsp)
movzbl (%r15), %eax
movl $0x1, %r12d
testb %al, %al
jns 0xaec8
movl %eax, %ecx
andl $-0x20, %ecx
movl $0x2, %r12d
cmpl $0xc0, %ecx
je 0xaec8
movl %eax, %ecx
andl $-0x10, %ecx
movl $0x3, %r12d
cmpl $0xe0, %ecx
je 0xaec8
movl %eax, %ecx
andl $-0x8, %ecx
xorl %r12d, %r12d
cmpl $0xf0, %ecx
sete %r12b
shll $0x2, %r12d
leaq 0x18e1(%rip), %rcx      # 0xc7b0
movslq (%rcx,%r12,4), %rdx
addq %rcx, %rdx
jmpq *%rdx
movl $0x2, %eax
jmp 0xaf6a
leaq 0x4(%rsp), %rdx
movq %rbx, %rdi
callq 0xb08e
jmp 0xaf21
leaq 0x4(%rsp), %rdx
movq %rbx, %rdi
callq 0xafa8
jmp 0xaf21
leaq 0x4(%rsp), %rdx
movq %rbx, %rdi
callq 0xaff9
jmp 0xaf21
cmpq %rsi, %r15
je 0xaf1c
movl %eax, 0x4(%rsp)
xorl %eax, %eax
jmp 0xaf21
movl $0x1, %eax
testl %eax, %eax
jne 0xaf67
movl 0x4(%rsp), %ecx
cmpl $0x110000, %ecx         # imm = 0x110000
setae %dl
movl %ecx, %eax
andl $0xfffff800, %eax       # imm = 0xFFFFF800
cmpl $0xd800, %eax           # imm = 0xD800
sete %sil
movl $0x5, %eax
orb %dl, %sil
jne 0xaf67
cmpl $0x7f, %ecx
ja 0xaf76
movl $0x4, %eax
cmpl $0x1, %r12d
jne 0xaf67
movl %ecx, (%r14)
movq (%rbx), %r15
incq %r15
xorl %eax, %eax
movq %r15, (%rbx)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
cmpl $0x7ff, %ecx            # imm = 0x7FF
ja 0xaf8b
movl $0x4, %eax
cmpl $0x2, %r12d
je 0xaf5c
jmp 0xaf67
cmpl $0x10000, %ecx          # imm = 0x10000
setb %dl
cmpl $0x3, %r12d
setne %sil
movl $0x4, %eax
testb %dl, %sil
je 0xaf5c
jmp 0xaf67