// File: /workspace/github_cpp_makefile_star2_O3/Ciaxur[P]yagb-emu/include/imgui/imgui_widgets.cpp
// Function: ImGuiInputTextCallbackData::InsertChars(int, char const*, char const*)
void ImGuiInputTextCallbackData::InsertChars(int pos, const char* new_text, const char* new_text_end)
{
    const bool is_resizable = (Flags & ImGuiInputTextFlags_CallbackResize) != 0;
    const int new_text_len = new_text_end ? (int)(new_text_end - new_text) : (int)strlen(new_text);
    if (new_text_len + BufTextLen >= BufSize)
    {
        if (!is_resizable)
            return;

        // Contrary to STB_TEXTEDIT_INSERTCHARS() this is working in the UTF8 buffer, hence the mildly similar code (until we remove the U16 buffer altogether!)
        ImGuiContext& g = *GImGui;
        ImGuiInputTextState* edit_state = &g.InputTextState;
        IM_ASSERT(edit_state->ID != 0 && g.ActiveId == edit_state->ID);
        IM_ASSERT(Buf == edit_state->TextA.Data);
        int new_buf_size = BufTextLen + ImClamp(new_text_len * 4, 32, ImMax(256, new_text_len)) + 1;
        edit_state->TextA.reserve(new_buf_size + 1);
        Buf = edit_state->TextA.Data;
        BufSize = edit_state->BufCapacityA = new_buf_size;
    }

    if (BufTextLen != pos)
        memmove(Buf + pos + new_text_len, Buf + pos, (size_t)(BufTextLen - pos));
    memcpy(Buf + pos, new_text, (size_t)new_text_len * sizeof(char));
    Buf[BufTextLen + new_text_len] = '\0';

    if (CursorPos >= pos)
        CursorPos += new_text_len;
    SelectionStart = SelectionEnd = CursorPos;
    BufDirty = true;
    BufTextLen += new_text_len;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdx, %r8
movl %esi, %r15d
movq %rdi, %rbx
movl 0x4(%rdi), %r12d
testq %rcx, %rcx
je 0x9c68d
movq %rcx, %r14
subq %r8, %r14
jmp 0x9c69e
movq %r8, %rdi
movq %r8, %r14
callq 0xc350
movq %r14, %r8
movq %rax, %r14
movl 0x20(%rbx), %eax
leal (%rax,%r14), %ecx
cmpl 0x24(%rbx), %ecx
jl 0x9c79b
btl $0x12, %r12d
jae 0x9c80c
leaq 0x5f610(%rip), %rcx     # 0xfbcd0
movq (%rcx), %r12
movl 0x2160(%r12), %ecx
testl %ecx, %ecx
je 0x9c81b
cmpl %ecx, 0x1b30(%r12)
jne 0x9c81b
movq 0x2188(%r12), %r13
cmpq %r13, 0x18(%rbx)
jne 0x9c83a
cmpl $0x101, %r14d           # imm = 0x101
movl $0x100, %ecx            # imm = 0x100
cmovgel %r14d, %ecx
leal (,%r14,4), %edx
cmpl %ecx, %edx
cmovll %edx, %ecx
cmpl $0x8, %r14d
movl $0x20, %edx
cmovgel %ecx, %edx
leal (%rdx,%rax), %ecx
incl %ecx
addl %eax, %edx
addl $0x2, %edx
cmpl %edx, 0x2184(%r12)
jge 0x9c78c
movl %ecx, -0x38(%rbp)
movq %r8, -0x30(%rbp)
movl %edx, -0x34(%rbp)
movslq %edx, %rdi
callq 0x41c63
movq %rax, %r13
movq 0x2188(%r12), %rsi
testq %rsi, %rsi
je 0x9c76f
movslq 0x2180(%r12), %rdx
movq %r13, %rdi
callq 0xc080
movq 0x2188(%r12), %rdi
callq 0x41d3c
movq %r13, 0x2188(%r12)
movl -0x34(%rbp), %eax
movl %eax, 0x2184(%r12)
movl 0x20(%rbx), %eax
movq -0x30(%rbp), %r8
movl -0x38(%rbp), %ecx
movq %r13, 0x18(%rbx)
movl %ecx, 0x21a4(%r12)
movl %ecx, 0x24(%rbx)
movslq %r15d, %r13
subl %r15d, %eax
jne 0x9c7a8
movslq %r14d, %r12
jmp 0x9c7cc
movq 0x18(%rbx), %rsi
addq %r13, %rsi
movslq %r14d, %r12
leaq (%rsi,%r12), %rdi
movslq %eax, %rdx
movl %r15d, -0x30(%rbp)
movq %r8, %r15
callq 0xc130
movq %r15, %r8
movl -0x30(%rbp), %r15d
addq 0x18(%rbx), %r13
movq %r13, %rdi
movq %r8, %rsi
movq %r12, %rdx
callq 0xc080
movq 0x18(%rbx), %rax
movslq 0x20(%rbx), %rcx
movslq %r14d, %rdx
addq %rcx, %rdx
movb $0x0, (%rax,%rdx)
movl 0x2c(%rbx), %eax
cmpl %r15d, %eax
jl 0x9c7fe
addl %r14d, %eax
movl %eax, 0x2c(%rbx)
movl %eax, 0x34(%rbx)
movl %eax, 0x30(%rbx)
movb $0x1, 0x28(%rbx)
addl %r14d, 0x20(%rbx)
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x357ae(%rip), %rdi     # 0xd1fd0
leaq 0x347ef(%rip), %rsi     # 0xd1018
leaq 0x357d4(%rip), %rcx     # 0xd2004
movl $0xe72, %edx            # imm = 0xE72
callq 0xc140
leaq 0x35811(%rip), %rdi     # 0xd2052
leaq 0x347d0(%rip), %rsi     # 0xd1018
leaq 0x357b5(%rip), %rcx     # 0xd2004
movl $0xe73, %edx            # imm = 0xE73
callq 0xc140