// File: /workspace/github_cpp_makefile_star2_O1/donfreiday[P]gb/./imgui/imgui.cpp
// Function: ImTextCharFromUtf8(unsigned int*, char const*, char const*)
int ImTextCharFromUtf8(unsigned int* out_char, const char* in_text, const char* in_text_end)
{
    unsigned int c = (unsigned int)-1;
    const unsigned char* str = (const unsigned char*)in_text;
    if (!(*str & 0x80))
    {
        c = (unsigned int)(*str++);
        *out_char = c;
        return 1;
    }
    if ((*str & 0xe0) == 0xc0)
    {
        *out_char = 0xFFFD; // will be invalid but not end of string
        if (in_text_end && in_text_end - (const char*)str < 2) return 0;
        if (*str < 0xc2) return 2;
        c = (unsigned int)((*str++ & 0x1f) << 6);
        if ((*str & 0xc0) != 0x80) return 2;
        c += (*str++ & 0x3f);
        *out_char = c;
        return 2;
    }
    if ((*str & 0xf0) == 0xe0)
    {
        *out_char = 0xFFFD; // will be invalid but not end of string
        if (in_text_end && in_text_end - (const char*)str < 3) return 0; 
        if (*str == 0xe0 && (str[1] < 0xa0 || str[1] > 0xbf)) return 3;
        if (*str == 0xed && str[1] > 0x9f) return 3; // str[1] < 0x80 is checked below
        c = (unsigned int)((*str++ & 0x0f) << 12);
        if ((*str & 0xc0) != 0x80) return 3;
        c += (unsigned int)((*str++ & 0x3f) << 6);
        if ((*str & 0xc0) != 0x80) return 3;
        c += (*str++ & 0x3f);
        *out_char = c;
        return 3;
    }
    if ((*str & 0xf8) == 0xf0)
    {
        *out_char = 0xFFFD; // will be invalid but not end of string
        if (in_text_end && in_text_end - (const char*)str < 4) return 0;
        if (*str > 0xf4) return 4;
        if (*str == 0xf0 && (str[1] < 0x90 || str[1] > 0xbf)) return 4;
        if (*str == 0xf4 && str[1] > 0x8f) return 4; // str[1] < 0x80 is checked below
        c = (unsigned int)((*str++ & 0x07) << 18);
        if ((*str & 0xc0) != 0x80) return 4;
        c += (unsigned int)((*str++ & 0x3f) << 12);
        if ((*str & 0xc0) != 0x80) return 4;
        c += (unsigned int)((*str++ & 0x3f) << 6);
        if ((*str & 0xc0) != 0x80) return 4;
        c += (*str++ & 0x3f);
        // utf-8 encodings of values used in surrogate pairs are invalid
        if ((c & 0xFFFFF800) == 0xD800) return 4;
        *out_char = c;
        return 4;
    }
    *out_char = 0;
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movzbl (%rsi), %ecx
movl $0x1, %eax
testb %cl, %cl
js 0x8861
movl %ecx, (%rdi)
popq %rbp
retq
movl %ecx, %eax
andl $-0x20, %eax
cmpl $0xc0, %eax
jne 0x88b9
movl $0xfffd, (%rdi)         # imm = 0xFFFD
testq %rdx, %rdx
setne %al
subq %rsi, %rdx
cmpq $0x2, %rdx
setl %cl
testb %cl, %al
jne 0x89a2
movzbl (%rsi), %edx
movl $0x2, %eax
cmpl $0xc2, %edx
jb 0x885f
movzbl 0x1(%rsi), %ecx
movl %ecx, %esi
andl $-0x40, %esi
cmpl $0x80, %esi
jne 0x885f
andl $0x1f, %edx
shll $0x6, %edx
andl $0x3f, %ecx
orl %edx, %ecx
jmp 0x885d
movl %ecx, %eax
andl $-0x10, %eax
cmpl $0xe0, %eax
jne 0x8972
movl $0xfffd, (%rdi)         # imm = 0xFFFD
testq %rdx, %rdx
setne %al
subq %rsi, %rdx
cmpq $0x3, %rdx
setl %cl
testb %cl, %al
jne 0x89a2
movzbl (%rsi), %edx
cmpl $0xed, %edx
je 0x8916
cmpl $0xe0, %edx
jne 0x8925
movb 0x1(%rsi), %cl
addb $0x40, %cl
movl $0x3, %eax
cmpb $-0x20, %cl
jb 0x885f
cmpl $0xed, %edx
jne 0x8925
movl $0x3, %eax
cmpb $-0x61, 0x1(%rsi)
ja 0x885f
movzbl 0x1(%rsi), %r8d
movl %r8d, %ecx
andl $-0x40, %ecx
movl $0x3, %eax
cmpl $0x80, %ecx
jne 0x885f
movzbl 0x2(%rsi), %ecx
movl %ecx, %esi
andl $-0x40, %esi
cmpl $0x80, %esi
jne 0x885f
andl $0xf, %edx
shll $0xc, %edx
andl $0x3f, %r8d
shll $0x6, %r8d
orl %edx, %r8d
andl $0x3f, %ecx
orl %r8d, %ecx
jmp 0x885d
andl $-0x8, %ecx
xorl %eax, %eax
cmpl $0xf0, %ecx
movl $0x0, %ecx
jne 0x885d
movl $0xfffd, (%rdi)         # imm = 0xFFFD
testq %rdx, %rdx
setne %al
subq %rsi, %rdx
cmpq $0x4, %rdx
setl %cl
testb %cl, %al
je 0x89a9
xorl %eax, %eax
jmp 0x885f
movzbl (%rsi), %edx
movl $0x4, %eax
cmpl $0xf4, %edx
ja 0x885f
je 0x89de
cmpl $0xf0, %edx
jne 0x89e8
movb 0x1(%rsi), %cl
addb $0x40, %cl
cmpb $-0x30, %cl
jb 0x885f
cmpl $0xf4, %edx
jne 0x89e8
cmpb $-0x71, 0x1(%rsi)
ja 0x885f
movzbl 0x1(%rsi), %r9d
movl %r9d, %ecx
andl $-0x40, %ecx
cmpl $0x80, %ecx
jne 0x885f
movzbl 0x2(%rsi), %r8d
movl %r8d, %ecx
andl $-0x40, %ecx
cmpl $0x80, %ecx
jne 0x885f
movzbl 0x3(%rsi), %ecx
movl %ecx, %esi
andl $-0x40, %esi
cmpl $0x80, %esi
jne 0x885f
andl $0x7, %edx
shll $0x12, %edx
andl $0x3f, %r9d
shll $0xc, %r9d
orl %edx, %r9d
andl $0x3f, %r8d
shll $0x6, %r8d
orl %r9d, %r8d
movl %r8d, %edx
andl $0x1ff800, %edx         # imm = 0x1FF800
cmpl $0xd800, %edx           # imm = 0xD800
je 0x885f
jmp 0x8967