// File: /workspace/github_cpp_makefile_star2_O3/Ciaxur[P]yagb-emu/include/imgui/imgui.cpp
// Function: ImGuiIO::AddInputCharacterUTF16(unsigned short)
void ImGuiIO::AddInputCharacterUTF16(ImWchar16 c)
{
    if (c == 0 && InputQueueSurrogate == 0)
        return;

    if ((c & 0xFC00) == 0xD800) // High surrogate, must save
    {
        if (InputQueueSurrogate != 0)
            InputQueueCharacters.push_back(IM_UNICODE_CODEPOINT_INVALID);
        InputQueueSurrogate = c;
        return;
    }

    ImWchar cp = c;
    if (InputQueueSurrogate != 0)
    {
        if ((c & 0xFC00) != 0xDC00) // Invalid low surrogate
            InputQueueCharacters.push_back(IM_UNICODE_CODEPOINT_INVALID);
        else if (IM_UNICODE_CODEPOINT_MAX == (0xFFFF)) // Codepoint will not fit in ImWchar (extra parenthesis around 0xFFFF somehow fixes -Wunreachable-code with Clang)
            cp = IM_UNICODE_CODEPOINT_INVALID;
        else
            cp = (ImWchar)(((InputQueueSurrogate - 0xD800) << 10) + (c - 0xDC00) + 0x10000);
        InputQueueSurrogate = 0;
    }
    InputQueueCharacters.push_back(cp);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movl %esi, %r14d
movzwl 0x1544(%rdi), %eax
movl %r14d, %ecx
orw %ax, %cx
je 0x40e3e
movq %rdi, %rbx
movl %r14d, %ecx
andl $0xfc00, %ecx           # imm = 0xFC00
cmpl $0xd800, %ecx           # imm = 0xD800
jne 0x40bb7
testw %ax, %ax
je 0x40cb5
movl 0x1548(%rbx), %eax
cmpl 0x154c(%rbx), %eax
jne 0x40bfd
leal 0x1(%rax), %r12d
testl %eax, %eax
je 0x40c15
movl %eax, %ecx
shrl $0x1f, %ecx
addl %eax, %ecx
sarl %ecx
addl %eax, %ecx
jmp 0x40c1a
testw %ax, %ax
je 0x40d71
movzwl %cx, %ecx
movw $0xfffd, %ax            # imm = 0xFFFD
cmpl $0xdc00, %ecx           # imm = 0xDC00
je 0x40d65
movl 0x1548(%rbx), %eax
cmpl 0x154c(%rbx), %eax
jne 0x40c09
leal 0x1(%rax), %r12d
testl %eax, %eax
je 0x40cc2
movl %eax, %ecx
shrl $0x1f, %ecx
addl %eax, %ecx
sarl %ecx
addl %eax, %ecx
jmp 0x40cc7
movq 0x1550(%rbx), %r15
jmp 0x40ca6
movq 0x1550(%rbx), %r15
jmp 0x40d53
movl $0x8, %ecx
cmpl %r12d, %ecx
cmovgl %ecx, %r12d
movslq %r12d, %rdi
addq %rdi, %rdi
movq 0xbb0a2(%rip), %rax     # 0xfbcd0
testq %rax, %rax
je 0x40c39
incl 0x3b4(%rax)
movq 0xbb0a0(%rip), %rsi     # 0xfbce0
callq *0xb68ca(%rip)          # 0xf7510
movq %rax, %r15
movq 0x1550(%rbx), %rsi
testq %rsi, %rsi
je 0x40c92
movslq 0x1548(%rbx), %rdx
addq %rdx, %rdx
movq %r15, %rdi
callq 0xc080
movq 0x1550(%rbx), %rdi
testq %rdi, %rdi
je 0x40c85
movq 0xbb056(%rip), %rax     # 0xfbcd0
testq %rax, %rax
je 0x40c85
decl 0x3b4(%rax)
movq 0xbb054(%rip), %rsi     # 0xfbce0
callq *0xb6886(%rip)          # 0xf7518
movq %r15, 0x1550(%rbx)
movl %r12d, 0x154c(%rbx)
movl 0x1548(%rbx), %eax
cltq
movw $0xfffd, (%r15,%rax,2)  # imm = 0xFFFD
incl 0x1548(%rbx)
movw %r14w, 0x1544(%rbx)
jmp 0x40e3e
movl $0x8, %ecx
cmpl %r12d, %ecx
cmovgl %ecx, %r12d
movslq %r12d, %rdi
addq %rdi, %rdi
movq 0xbaff5(%rip), %rax     # 0xfbcd0
testq %rax, %rax
je 0x40ce6
incl 0x3b4(%rax)
movq 0xbaff3(%rip), %rsi     # 0xfbce0
callq *0xb681d(%rip)          # 0xf7510
movq %rax, %r15
movq 0x1550(%rbx), %rsi
testq %rsi, %rsi
je 0x40d3f
movslq 0x1548(%rbx), %rdx
addq %rdx, %rdx
movq %r15, %rdi
callq 0xc080
movq 0x1550(%rbx), %rdi
testq %rdi, %rdi
je 0x40d32
movq 0xbafa9(%rip), %rax     # 0xfbcd0
testq %rax, %rax
je 0x40d32
decl 0x3b4(%rax)
movq 0xbafa7(%rip), %rsi     # 0xfbce0
callq *0xb67d9(%rip)          # 0xf7518
movq %r15, 0x1550(%rbx)
movl %r12d, 0x154c(%rbx)
movl 0x1548(%rbx), %eax
cltq
movw $0xfffd, (%r15,%rax,2)  # imm = 0xFFFD
incl 0x1548(%rbx)
movl %r14d, %eax
movw $0x0, 0x1544(%rbx)
movl %eax, %r14d
movl 0x1548(%rbx), %eax
cmpl 0x154c(%rbx), %eax
jne 0x40d94
leal 0x1(%rax), %r12d
testl %eax, %eax
je 0x40da0
movl %eax, %ecx
shrl $0x1f, %ecx
addl %eax, %ecx
sarl %ecx
addl %eax, %ecx
jmp 0x40da5
movq 0x1550(%rbx), %r15
jmp 0x40e31
movl $0x8, %ecx
cmpl %r12d, %ecx
cmovgl %ecx, %r12d
movslq %r12d, %rdi
addq %rdi, %rdi
movq 0xbaf17(%rip), %rax     # 0xfbcd0
testq %rax, %rax
je 0x40dc4
incl 0x3b4(%rax)
movq 0xbaf15(%rip), %rsi     # 0xfbce0
callq *0xb673f(%rip)          # 0xf7510
movq %rax, %r15
movq 0x1550(%rbx), %rsi
testq %rsi, %rsi
je 0x40e1d
movslq 0x1548(%rbx), %rdx
addq %rdx, %rdx
movq %r15, %rdi
callq 0xc080
movq 0x1550(%rbx), %rdi
testq %rdi, %rdi
je 0x40e10
movq 0xbaecb(%rip), %rax     # 0xfbcd0
testq %rax, %rax
je 0x40e10
decl 0x3b4(%rax)
movq 0xbaec9(%rip), %rsi     # 0xfbce0
callq *0xb66fb(%rip)          # 0xf7518
movq %r15, 0x1550(%rbx)
movl %r12d, 0x154c(%rbx)
movl 0x1548(%rbx), %eax
cltq
movw %r14w, (%r15,%rax,2)
incl 0x1548(%rbx)
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
nop