// File: Ciaxur[P]yagb-emu/include/imgui/imgui_widgets.cpp
// Function: InputTextFilterCharacter(unsigned int*, int, int (*)(ImGuiInputTextCallbackData*), void*)
static bool InputTextFilterCharacter(unsigned int* p_char, ImGuiInputTextFlags flags, ImGuiInputTextCallback callback, void* user_data)
{
    unsigned int c = *p_char;

    // Filter non-printable (NB: isprint is unreliable! see #2467)
    if (c < 0x20)
    {
        bool pass = false;
        pass |= (c == '\n' && (flags & ImGuiInputTextFlags_Multiline));
        pass |= (c == '\t' && (flags & ImGuiInputTextFlags_AllowTabInput));
        if (!pass)
            return false;
    }

    // We ignore Ascii representation of delete (emitted from Backspace on OSX, see #2578, #2817)
    if (c == 127)
        return false;

    // Filter private Unicode range. GLFW on OSX seems to send private characters for special keys like arrow keys (FIXME)
    if (c >= 0xE000 && c <= 0xF8FF)
        return false;

    // Filter Unicode ranges we are not handling in this build.
    if (c > IM_UNICODE_CODEPOINT_MAX)
        return false;

    // Generic named filters
    if (flags & (ImGuiInputTextFlags_CharsDecimal | ImGuiInputTextFlags_CharsHexadecimal | ImGuiInputTextFlags_CharsUppercase | ImGuiInputTextFlags_CharsNoBlank | ImGuiInputTextFlags_CharsScientific))
    {
        // The libc allows overriding locale, with e.g. 'setlocale(LC_NUMERIC, "de_DE.UTF-8");' which affect the output/input of printf/scanf.
        // The standard mandate that programs starts in the "C" locale where the decimal point is '.'.
        // We don't really intend to provide widespread support for it, but out of empathy for people stuck with using odd API, we support the bare minimum aka overriding the decimal point.
        // Change the default decimal_point with:
        //   ImGui::GetCurrentContext()->PlatformLocaleDecimalPoint = *localeconv()->decimal_point;
        ImGuiContext& g = *GImGui;
        const unsigned c_decimal_point = (unsigned int)g.PlatformLocaleDecimalPoint;

        // Allow 0-9 . - + * /
        if (flags & ImGuiInputTextFlags_CharsDecimal)
            if (!(c >= '0' && c <= '9') && (c != c_decimal_point) && (c != '-') && (c != '+') && (c != '*') && (c != '/'))
                return false;

        // Allow 0-9 . - + * / e E
        if (flags & ImGuiInputTextFlags_CharsScientific)
            if (!(c >= '0' && c <= '9') && (c != c_decimal_point) && (c != '-') && (c != '+') && (c != '*') && (c != '/') && (c != 'e') && (c != 'E'))
                return false;

        // Allow 0-9 a-F A-F
        if (flags & ImGuiInputTextFlags_CharsHexadecimal)
            if (!(c >= '0' && c <= '9') && !(c >= 'a' && c <= 'f') && !(c >= 'A' && c <= 'F'))
                return false;

        // Turn a-z into A-Z
        if (flags & ImGuiInputTextFlags_CharsUppercase)
            if (c >= 'a' && c <= 'z')
                *p_char = (c += (unsigned int)('A' - 'a'));

        if (flags & ImGuiInputTextFlags_CharsNoBlank)
            if (ImCharIsBlankW(c))
                return false;
    }

    // Custom callback filter
    if (flags & ImGuiInputTextFlags_CallbackCharFilter)
    {
        ImGuiInputTextCallbackData callback_data;
        memset(&callback_data, 0, sizeof(ImGuiInputTextCallbackData));
        callback_data.EventFlag = ImGuiInputTextFlags_CallbackCharFilter;
        callback_data.EventChar = (ImWchar)c;
        callback_data.Flags = flags;
        callback_data.UserData = user_data;
        if (callback(&callback_data) != 0)
            return false;
        *p_char = callback_data.EventChar;
        if (!callback_data.EventChar)
            return false;
    }

    return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq -0x10(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x2c(%rbp)
cmpl $0x20, -0x2c(%rbp)
jae 0x14b904
movb $0x0, -0x2d(%rbp)
xorl %eax, %eax
cmpl $0xa, -0x2c(%rbp)
movb %al, -0x79(%rbp)
jne 0x14b89d
movl -0x14(%rbp), %eax
andl $0x100000, %eax         # imm = 0x100000
cmpl $0x0, %eax
setne %al
movb %al, -0x79(%rbp)
movb -0x79(%rbp), %al
andb $0x1, %al
movzbl %al, %ecx
movb -0x2d(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
orl %ecx, %eax
cmpl $0x0, %eax
setne %al
andb $0x1, %al
movb %al, -0x2d(%rbp)
xorl %eax, %eax
cmpl $0x9, -0x2c(%rbp)
movb %al, -0x7a(%rbp)
jne 0x14b8d6
movl -0x14(%rbp), %eax
andl $0x400, %eax            # imm = 0x400
cmpl $0x0, %eax
setne %al
movb %al, -0x7a(%rbp)
movb -0x7a(%rbp), %al
andb $0x1, %al
movzbl %al, %ecx
movb -0x2d(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
orl %ecx, %eax
cmpl $0x0, %eax
setne %al
andb $0x1, %al
movb %al, -0x2d(%rbp)
testb $0x1, -0x2d(%rbp)
jne 0x14b902
movb $0x0, -0x1(%rbp)
jmp 0x14baf5
jmp 0x14b904
cmpl $0x7f, -0x2c(%rbp)
jne 0x14b913
movb $0x0, -0x1(%rbp)
jmp 0x14baf5
cmpl $0xe000, -0x2c(%rbp)    # imm = 0xE000
jb 0x14b92e
cmpl $0xf8ff, -0x2c(%rbp)    # imm = 0xF8FF
ja 0x14b92e
movb $0x0, -0x1(%rbp)
jmp 0x14baf5
cmpl $0xffff, -0x2c(%rbp)    # imm = 0xFFFF
jbe 0x14b940
movb $0x0, -0x1(%rbp)
jmp 0x14baf5
movl -0x14(%rbp), %eax
andl $0x2000f, %eax          # imm = 0x2000F
cmpl $0x0, %eax
je 0x14ba84
leaq 0xc75e8(%rip), %rax     # 0x212f40
movq (%rax), %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
movsbl 0x30e0(%rax), %eax
movl %eax, -0x3c(%rbp)
movl -0x14(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x14b9af
cmpl $0x30, -0x2c(%rbp)
jb 0x14b984
cmpl $0x39, -0x2c(%rbp)
jbe 0x14b9ad
movl -0x2c(%rbp), %eax
cmpl -0x3c(%rbp), %eax
je 0x14b9ad
cmpl $0x2d, -0x2c(%rbp)
je 0x14b9ad
cmpl $0x2b, -0x2c(%rbp)
je 0x14b9ad
cmpl $0x2a, -0x2c(%rbp)
je 0x14b9ad
cmpl $0x2f, -0x2c(%rbp)
je 0x14b9ad
movb $0x0, -0x1(%rbp)
jmp 0x14baf5
jmp 0x14b9af
movl -0x14(%rbp), %eax
andl $0x20000, %eax          # imm = 0x20000
cmpl $0x0, %eax
je 0x14b9ff
cmpl $0x30, -0x2c(%rbp)
jb 0x14b9c8
cmpl $0x39, -0x2c(%rbp)
jbe 0x14b9fd
movl -0x2c(%rbp), %eax
cmpl -0x3c(%rbp), %eax
je 0x14b9fd
cmpl $0x2d, -0x2c(%rbp)
je 0x14b9fd
cmpl $0x2b, -0x2c(%rbp)
je 0x14b9fd
cmpl $0x2a, -0x2c(%rbp)
je 0x14b9fd
cmpl $0x2f, -0x2c(%rbp)
je 0x14b9fd
cmpl $0x65, -0x2c(%rbp)
je 0x14b9fd
cmpl $0x45, -0x2c(%rbp)
je 0x14b9fd
movb $0x0, -0x1(%rbp)
jmp 0x14baf5
jmp 0x14b9ff
movl -0x14(%rbp), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x14ba39
cmpl $0x30, -0x2c(%rbp)
jb 0x14ba16
cmpl $0x39, -0x2c(%rbp)
jbe 0x14ba37
cmpl $0x61, -0x2c(%rbp)
jb 0x14ba22
cmpl $0x66, -0x2c(%rbp)
jbe 0x14ba37
cmpl $0x41, -0x2c(%rbp)
jb 0x14ba2e
cmpl $0x46, -0x2c(%rbp)
jbe 0x14ba37
movb $0x0, -0x1(%rbp)
jmp 0x14baf5
jmp 0x14ba39
movl -0x14(%rbp), %eax
andl $0x4, %eax
cmpl $0x0, %eax
je 0x14ba61
cmpl $0x61, -0x2c(%rbp)
jb 0x14ba5f
cmpl $0x7a, -0x2c(%rbp)
ja 0x14ba5f
movl -0x2c(%rbp), %ecx
addl $-0x20, %ecx
movl %ecx, -0x2c(%rbp)
movq -0x10(%rbp), %rax
movl %ecx, (%rax)
jmp 0x14ba61
movl -0x14(%rbp), %eax
andl $0x8, %eax
cmpl $0x0, %eax
je 0x14ba82
movl -0x2c(%rbp), %edi
callq 0x15a270
testb $0x1, %al
jne 0x14ba7a
jmp 0x14ba80
movb $0x0, -0x1(%rbp)
jmp 0x14baf5
jmp 0x14ba82
jmp 0x14ba84
movl -0x14(%rbp), %eax
andl $0x200, %eax            # imm = 0x200
cmpl $0x0, %eax
je 0x14baf1
leaq -0x78(%rbp), %rdi
callq 0x14b3a0
leaq -0x78(%rbp), %rdi
xorl %esi, %esi
movl $0x38, %edx
callq 0xd2f0
movl $0x200, -0x78(%rbp)     # imm = 0x200
movl -0x2c(%rbp), %eax
movw %ax, -0x68(%rbp)
movl -0x14(%rbp), %eax
movl %eax, -0x74(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0x70(%rbp)
leaq -0x78(%rbp), %rdi
callq *-0x20(%rbp)
cmpl $0x0, %eax
je 0x14bad8
movb $0x0, -0x1(%rbp)
jmp 0x14baf5
movzwl -0x68(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, (%rax)
cmpw $0x0, -0x68(%rbp)
jne 0x14baef
movb $0x0, -0x1(%rbp)
jmp 0x14baf5
jmp 0x14baf1
movb $0x1, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x80, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)