// File: 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 %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rsi, -0x10(%rbp)
movq %rdi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x28(%rbp)
movl $0x0, -0x2c(%rbp)
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rdi
callq 0x16d80
movq %rax, -0x38(%rbp)
movl $0x0, -0x44(%rbp)
movq -0x38(%rbp), %rax
movq %rax, -0x70(%rbp)
subq $0x4, %rax
ja 0x16c2d
movq -0x70(%rbp), %rax
leaq 0x3cba(%rip), %rcx      # 0x1a85c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl $0x2, -0x4(%rbp)
jmp 0x16c8f
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rsi
leaq -0x2c(%rbp), %rdx
callq 0x16e10
movl %eax, -0x44(%rbp)
jmp 0x16c2d
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rsi
leaq -0x2c(%rbp), %rdx
callq 0x16e70
movl %eax, -0x44(%rbp)
jmp 0x16c2d
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rsi
leaq -0x2c(%rbp), %rdx
callq 0x16f20
movl %eax, -0x44(%rbp)
jmp 0x16c2d
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rsi
leaq -0x2c(%rbp), %rdx
callq 0x17020
movl %eax, -0x44(%rbp)
cmpl $0x0, -0x44(%rbp)
jne 0x16c7e
movl -0x2c(%rbp), %edi
callq 0xa6e0
testb $0x1, %al
jne 0x16c41
jmp 0x16c75
movl -0x2c(%rbp), %edi
movq -0x38(%rbp), %rsi
callq 0x17170
testb $0x1, %al
jne 0x16c6c
movl -0x2c(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
movq -0x18(%rbp), %rdi
callq 0x171e0
movl $0x0, -0x4(%rbp)
jmp 0x16c8f
movl $0x4, -0x44(%rbp)
jmp 0x16c7c
movl $0x5, -0x44(%rbp)
jmp 0x16c7e
movq -0x18(%rbp), %rax
movq -0x28(%rbp), %rcx
movq %rcx, (%rax)
movl -0x44(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x70, %rsp
popq %rbp
retq
nopl (%rax,%rax)