// File: /workspace/github_cpp_makefile_star2_O1/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, %r15
movl %esi, %r12d
movq %rdi, %rbx
movl 0x4(%rdi), %r13d
testq %rcx, %rcx
je 0x9e10d
movq %rcx, %r14
subq %r15, %r14
jmp 0x9e118
movq %r15, %rdi
callq 0xc350
movq %rax, %r14
movl 0x20(%rbx), %eax
leal (%rax,%r14), %ecx
cmpl 0x24(%rbx), %ecx
jl 0x9e20c
btl $0x12, %r13d
jae 0x9e26f
leaq 0x5fb96(%rip), %rcx     # 0xfdcd0
movq (%rcx), %r13
movl 0x2160(%r13), %ecx
testl %ecx, %ecx
je 0x9e27e
cmpl %ecx, 0x1b30(%r13)
jne 0x9e27e
movq 0x18(%rbx), %rcx
cmpq 0x2188(%r13), %rcx
jne 0x9e29d
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 %edx, %eax
addl $0x2, %eax
cmpl %eax, 0x2184(%r13)
jge 0x9e1f7
movl %ecx, -0x30(%rbp)
movl %eax, -0x2c(%rbp)
movslq %eax, %rdi
callq 0x424fb
movq 0x2188(%r13), %rsi
testq %rsi, %rsi
je 0x9e1e3
movslq 0x2180(%r13), %rdx
movq %rax, %rdi
movq %rax, -0x38(%rbp)
callq 0xc080
movq 0x2188(%r13), %rdi
callq 0x425d4
movq -0x38(%rbp), %rax
movq %rax, 0x2188(%r13)
movl -0x2c(%rbp), %eax
movl %eax, 0x2184(%r13)
movl -0x30(%rbp), %ecx
movq 0x2188(%r13), %rax
movq %rax, 0x18(%rbx)
movl %ecx, 0x21a4(%r13)
movl %ecx, 0x24(%rbx)
movl 0x20(%rbx), %eax
movslq %r12d, %r13
subl %r12d, %eax
je 0x9e22c
movq 0x18(%rbx), %rsi
addq %r13, %rsi
movslq %r14d, %rdi
addq %rsi, %rdi
movslq %eax, %rdx
callq 0xc130
movq 0x18(%rbx), %rdi
addq %r13, %rdi
movslq %r14d, %rdx
movq %r15, %rsi
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 %r13d, %eax
jl 0x9e25e
addl %r14d, %eax
movl %eax, 0x2c(%rbx)
movl 0x2c(%rbx), %eax
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 0x35e9e(%rip), %rdi     # 0xd4123
leaq 0x34ebc(%rip), %rsi     # 0xd3148
leaq 0x35ec4(%rip), %rcx     # 0xd4157
movl $0xe72, %edx            # imm = 0xE72
callq 0xc140
leaq 0x35f01(%rip), %rdi     # 0xd41a5
leaq 0x34e9d(%rip), %rsi     # 0xd3148
leaq 0x35ea5(%rip), %rcx     # 0xd4157
movl $0xe73, %edx            # imm = 0xE73
callq 0xc140