// File: /workspace/github_c_makefile_star2_O0/neosploit[P]compiler/libfort/lib/fort.c
// Function: utf8valid
void *utf8valid(const void *str)
{
    const char *s = (const char *)str;

    while ('\0' != *s) {
        if (0xf0 == (0xf8 & *s)) {
            // ensure each of the 3 following bytes in this 4-byte
            // utf8 codepoint began with 0b10xxxxxx
            if ((0x80 != (0xc0 & s[1])) || (0x80 != (0xc0 & s[2])) ||
                (0x80 != (0xc0 & s[3]))) {
                return (void *)s;
            }

            // ensure that our utf8 codepoint ended after 4 bytes
            if (0x80 == (0xc0 & s[4])) {
                return (void *)s;
            }

            // ensure that the top 5 bits of this 4-byte utf8
            // codepoint were not 0, as then we could have used
            // one of the smaller encodings
            if ((0 == (0x07 & s[0])) && (0 == (0x30 & s[1]))) {
                return (void *)s;
            }

            // 4-byte utf8 code point (began with 0b11110xxx)
            s += 4;
        } else if (0xe0 == (0xf0 & *s)) {
            // ensure each of the 2 following bytes in this 3-byte
            // utf8 codepoint began with 0b10xxxxxx
            if ((0x80 != (0xc0 & s[1])) || (0x80 != (0xc0 & s[2]))) {
                return (void *)s;
            }

            // ensure that our utf8 codepoint ended after 3 bytes
            if (0x80 == (0xc0 & s[3])) {
                return (void *)s;
            }

            // ensure that the top 5 bits of this 3-byte utf8
            // codepoint were not 0, as then we could have used
            // one of the smaller encodings
            if ((0 == (0x0f & s[0])) && (0 == (0x20 & s[1]))) {
                return (void *)s;
            }

            // 3-byte utf8 code point (began with 0b1110xxxx)
            s += 3;
        } else if (0xc0 == (0xe0 & *s)) {
            // ensure the 1 following byte in this 2-byte
            // utf8 codepoint began with 0b10xxxxxx
            if (0x80 != (0xc0 & s[1])) {
                return (void *)s;
            }

            // ensure that our utf8 codepoint ended after 2 bytes
            if (0x80 == (0xc0 & s[2])) {
                return (void *)s;
            }

            // ensure that the top 4 bits of this 2-byte utf8
            // codepoint were not 0, as then we could have used
            // one of the smaller encodings
            if (0 == (0x1e & s[0])) {
                return (void *)s;
            }

            // 2-byte utf8 code point (began with 0b110xxxxx)
            s += 2;
        } else if (0x00 == (0x80 & *s)) {
            // 1-byte ascii (began with 0b0xxxxxxx)
            s += 1;
        } else {
            // we have an invalid 0b1xxxxxxx utf8 code point entry
            return (void *)s;
        }
    }

    return utf8_null;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movsbl (%rax), %ecx
xorl %eax, %eax
cmpl %ecx, %eax
je 0x124d1
movq -0x18(%rbp), %rax
movsbl (%rax), %ecx
andl $0xf8, %ecx
movl $0xf0, %eax
cmpl %ecx, %eax
jne 0x12360
movq -0x18(%rbp), %rax
movsbl 0x1(%rax), %ecx
andl $0xc0, %ecx
movl $0x80, %eax
cmpl %ecx, %eax
jne 0x122f0
movq -0x18(%rbp), %rax
movsbl 0x2(%rax), %ecx
andl $0xc0, %ecx
movl $0x80, %eax
cmpl %ecx, %eax
jne 0x122f0
movq -0x18(%rbp), %rax
movsbl 0x3(%rax), %ecx
andl $0xc0, %ecx
movl $0x80, %eax
cmpl %ecx, %eax
je 0x122fd
movq -0x18(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x124d9
movq -0x18(%rbp), %rax
movsbl 0x4(%rax), %ecx
andl $0xc0, %ecx
movl $0x80, %eax
cmpl %ecx, %eax
jne 0x12321
movq -0x18(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x124d9
movq -0x18(%rbp), %rax
movsbl (%rax), %ecx
andl $0x7, %ecx
xorl %eax, %eax
cmpl %ecx, %eax
jne 0x1234f
movq -0x18(%rbp), %rax
movsbl 0x1(%rax), %ecx
andl $0x30, %ecx
xorl %eax, %eax
cmpl %ecx, %eax
jne 0x1234f
movq -0x18(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x124d9
movq -0x18(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x18(%rbp)
jmp 0x124cc
movq -0x18(%rbp), %rax
movsbl (%rax), %ecx
andl $0xf0, %ecx
movl $0xe0, %eax
cmpl %ecx, %eax
jne 0x12418
movq -0x18(%rbp), %rax
movsbl 0x1(%rax), %ecx
andl $0xc0, %ecx
movl $0x80, %eax
cmpl %ecx, %eax
jne 0x123a8
movq -0x18(%rbp), %rax
movsbl 0x2(%rax), %ecx
andl $0xc0, %ecx
movl $0x80, %eax
cmpl %ecx, %eax
je 0x123b5
movq -0x18(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x124d9
movq -0x18(%rbp), %rax
movsbl 0x3(%rax), %ecx
andl $0xc0, %ecx
movl $0x80, %eax
cmpl %ecx, %eax
jne 0x123d9
movq -0x18(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x124d9
movq -0x18(%rbp), %rax
movsbl (%rax), %ecx
andl $0xf, %ecx
xorl %eax, %eax
cmpl %ecx, %eax
jne 0x12407
movq -0x18(%rbp), %rax
movsbl 0x1(%rax), %ecx
andl $0x20, %ecx
xorl %eax, %eax
cmpl %ecx, %eax
jne 0x12407
movq -0x18(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x124d9
movq -0x18(%rbp), %rax
addq $0x3, %rax
movq %rax, -0x18(%rbp)
jmp 0x124ca
movq -0x18(%rbp), %rax
movsbl (%rax), %ecx
andl $0xe0, %ecx
movl $0xc0, %eax
cmpl %ecx, %eax
jne 0x1249b
movq -0x18(%rbp), %rax
movsbl 0x1(%rax), %ecx
andl $0xc0, %ecx
movl $0x80, %eax
cmpl %ecx, %eax
je 0x12452
movq -0x18(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x124d9
movq -0x18(%rbp), %rax
movsbl 0x2(%rax), %ecx
andl $0xc0, %ecx
movl $0x80, %eax
cmpl %ecx, %eax
jne 0x12473
movq -0x18(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x124d9
movq -0x18(%rbp), %rax
movsbl (%rax), %ecx
andl $0x1e, %ecx
xorl %eax, %eax
cmpl %ecx, %eax
jne 0x1248d
movq -0x18(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x124d9
movq -0x18(%rbp), %rax
addq $0x2, %rax
movq %rax, -0x18(%rbp)
jmp 0x124c8
movq -0x18(%rbp), %rax
movsbl (%rax), %ecx
andl $0x80, %ecx
xorl %eax, %eax
cmpl %ecx, %eax
jne 0x124bc
movq -0x18(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x18(%rbp)
jmp 0x124c6
movq -0x18(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x124d9
jmp 0x124c8
jmp 0x124ca
jmp 0x124cc
jmp 0x12280
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
popq %rbp
retq
nop