// File: 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
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movl $0xffffffff, -0x24(%rbp) # imm = 0xFFFFFFFF
movq -0x18(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movzbl (%rax), %eax
andl $0x80, %eax
cmpl $0x0, %eax
jne 0x98aa
movq -0x30(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x30(%rbp)
movzbl (%rax), %eax
movl %eax, -0x24(%rbp)
movl -0x24(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, (%rax)
movl $0x1, -0x4(%rbp)
jmp 0x9c87
movq -0x30(%rbp), %rax
movzbl (%rax), %eax
andl $0xe0, %eax
cmpl $0xc0, %eax
jne 0x9973
movq -0x10(%rbp), %rax
movl $0xfffd, (%rax)         # imm = 0xFFFD
cmpq $0x0, -0x20(%rbp)
je 0x98ef
movq -0x20(%rbp), %rax
movq -0x30(%rbp), %rcx
subq %rcx, %rax
cmpq $0x2, %rax
jge 0x98ef
movl $0x0, -0x4(%rbp)
jmp 0x9c87
movq -0x30(%rbp), %rax
movzbl (%rax), %eax
cmpl $0xc2, %eax
jge 0x9909
movl $0x2, -0x4(%rbp)
jmp 0x9c87
movq -0x30(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x30(%rbp)
movzbl (%rax), %eax
andl $0x1f, %eax
shll $0x6, %eax
movl %eax, -0x24(%rbp)
movq -0x30(%rbp), %rax
movzbl (%rax), %eax
andl $0xc0, %eax
cmpl $0x80, %eax
je 0x9943
movl $0x2, -0x4(%rbp)
jmp 0x9c87
movq -0x30(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x30(%rbp)
movzbl (%rax), %eax
andl $0x3f, %eax
addl -0x24(%rbp), %eax
movl %eax, -0x24(%rbp)
movl -0x24(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, (%rax)
movl $0x2, -0x4(%rbp)
jmp 0x9c87
movq -0x30(%rbp), %rax
movzbl (%rax), %eax
andl $0xf0, %eax
cmpl $0xe0, %eax
jne 0x9ac0
movq -0x10(%rbp), %rax
movl $0xfffd, (%rax)         # imm = 0xFFFD
cmpq $0x0, -0x20(%rbp)
je 0x99b8
movq -0x20(%rbp), %rax
movq -0x30(%rbp), %rcx
subq %rcx, %rax
cmpq $0x3, %rax
jge 0x99b8
movl $0x0, -0x4(%rbp)
jmp 0x9c87
movq -0x30(%rbp), %rax
movzbl (%rax), %eax
cmpl $0xe0, %eax
jne 0x99f0
movq -0x30(%rbp), %rax
movzbl 0x1(%rax), %eax
cmpl $0xa0, %eax
jl 0x99e4
movq -0x30(%rbp), %rax
movzbl 0x1(%rax), %eax
cmpl $0xbf, %eax
jle 0x99f0
movl $0x3, -0x4(%rbp)
jmp 0x9c87
movq -0x30(%rbp), %rax
movzbl (%rax), %eax
cmpl $0xed, %eax
jne 0x9a19
movq -0x30(%rbp), %rax
movzbl 0x1(%rax), %eax
cmpl $0x9f, %eax
jle 0x9a19
movl $0x3, -0x4(%rbp)
jmp 0x9c87
movq -0x30(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x30(%rbp)
movzbl (%rax), %eax
andl $0xf, %eax
shll $0xc, %eax
movl %eax, -0x24(%rbp)
movq -0x30(%rbp), %rax
movzbl (%rax), %eax
andl $0xc0, %eax
cmpl $0x80, %eax
je 0x9a53
movl $0x3, -0x4(%rbp)
jmp 0x9c87
movq -0x30(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x30(%rbp)
movzbl (%rax), %eax
andl $0x3f, %eax
shll $0x6, %eax
addl -0x24(%rbp), %eax
movl %eax, -0x24(%rbp)
movq -0x30(%rbp), %rax
movzbl (%rax), %eax
andl $0xc0, %eax
cmpl $0x80, %eax
je 0x9a90
movl $0x3, -0x4(%rbp)
jmp 0x9c87
movq -0x30(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x30(%rbp)
movzbl (%rax), %eax
andl $0x3f, %eax
addl -0x24(%rbp), %eax
movl %eax, -0x24(%rbp)
movl -0x24(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, (%rax)
movl $0x3, -0x4(%rbp)
jmp 0x9c87
movq -0x30(%rbp), %rax
movzbl (%rax), %eax
andl $0xf8, %eax
cmpl $0xf0, %eax
jne 0x9c76
movq -0x10(%rbp), %rax
movl $0xfffd, (%rax)         # imm = 0xFFFD
cmpq $0x0, -0x20(%rbp)
je 0x9b05
movq -0x20(%rbp), %rax
movq -0x30(%rbp), %rcx
subq %rcx, %rax
cmpq $0x4, %rax
jge 0x9b05
movl $0x0, -0x4(%rbp)
jmp 0x9c87
movq -0x30(%rbp), %rax
movzbl (%rax), %eax
cmpl $0xf4, %eax
jle 0x9b1f
movl $0x4, -0x4(%rbp)
jmp 0x9c87
movq -0x30(%rbp), %rax
movzbl (%rax), %eax
cmpl $0xf0, %eax
jne 0x9b57
movq -0x30(%rbp), %rax
movzbl 0x1(%rax), %eax
cmpl $0x90, %eax
jl 0x9b4b
movq -0x30(%rbp), %rax
movzbl 0x1(%rax), %eax
cmpl $0xbf, %eax
jle 0x9b57
movl $0x4, -0x4(%rbp)
jmp 0x9c87
movq -0x30(%rbp), %rax
movzbl (%rax), %eax
cmpl $0xf4, %eax
jne 0x9b80
movq -0x30(%rbp), %rax
movzbl 0x1(%rax), %eax
cmpl $0x8f, %eax
jle 0x9b80
movl $0x4, -0x4(%rbp)
jmp 0x9c87
movq -0x30(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x30(%rbp)
movzbl (%rax), %eax
andl $0x7, %eax
shll $0x12, %eax
movl %eax, -0x24(%rbp)
movq -0x30(%rbp), %rax
movzbl (%rax), %eax
andl $0xc0, %eax
cmpl $0x80, %eax
je 0x9bba
movl $0x4, -0x4(%rbp)
jmp 0x9c87
movq -0x30(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x30(%rbp)
movzbl (%rax), %eax
andl $0x3f, %eax
shll $0xc, %eax
addl -0x24(%rbp), %eax
movl %eax, -0x24(%rbp)
movq -0x30(%rbp), %rax
movzbl (%rax), %eax
andl $0xc0, %eax
cmpl $0x80, %eax
je 0x9bf7
movl $0x4, -0x4(%rbp)
jmp 0x9c87
movq -0x30(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x30(%rbp)
movzbl (%rax), %eax
andl $0x3f, %eax
shll $0x6, %eax
addl -0x24(%rbp), %eax
movl %eax, -0x24(%rbp)
movq -0x30(%rbp), %rax
movzbl (%rax), %eax
andl $0xc0, %eax
cmpl $0x80, %eax
je 0x9c31
movl $0x4, -0x4(%rbp)
jmp 0x9c87
movq -0x30(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x30(%rbp)
movzbl (%rax), %eax
andl $0x3f, %eax
addl -0x24(%rbp), %eax
movl %eax, -0x24(%rbp)
movl -0x24(%rbp), %eax
andl $0xfffff800, %eax       # imm = 0xFFFFF800
cmpl $0xd800, %eax           # imm = 0xD800
jne 0x9c64
movl $0x4, -0x4(%rbp)
jmp 0x9c87
movl -0x24(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, (%rax)
movl $0x4, -0x4(%rbp)
jmp 0x9c87
movq -0x10(%rbp), %rax
movl $0x0, (%rax)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
popq %rbp
retq
nopl (%rax)