// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %rax
movl %esi, %r15d
movq %rdi, %rbx
movl 0x4(%rdi), %r12d
testq %rcx, %rcx
movq %rdx, -0x30(%rbp)
je 0x84c33
movq %rcx, %r14
subq %rdx, %r14
jmp 0x84c3e
movq %rdx, %rdi
callq 0xc380
movq %rax, %r14
movl 0x20(%rbx), %eax
leal (%rax,%r14), %ecx
cmpl 0x24(%rbx), %ecx
jl 0x84cef
btl $0x12, %r12d
jae 0x84d53
leaq 0x5f080(%rip), %rcx     # 0xe3ce0
movq (%rcx), %r12
movl 0x2160(%r12), %ecx
testl %ecx, %ecx
je 0x84d62
cmpl %ecx, 0x1b30(%r12)
jne 0x84d62
movq 0x18(%rbx), %rcx
cmpq 0x2188(%r12), %rcx
jne 0x84d81
leaq 0x2180(%r12), %rdi
leal (,%r14,4), %ecx
cmpl $0x101, %r14d           # imm = 0x101
movl $0x100, %edx            # imm = 0x100
cmovgel %r14d, %edx
cmpl %edx, %ecx
cmovll %ecx, %edx
cmpl $0x8, %r14d
pushq $0x20
popq %rcx
cmovgel %edx, %ecx
leal (%rcx,%rax), %r13d
incl %r13d
leal (%rcx,%rax), %esi
addl $0x2, %esi
callq 0x49c66
movq 0x2188(%r12), %rax
movq %rax, 0x18(%rbx)
movl %r13d, 0x21a4(%r12)
movl %r13d, 0x24(%rbx)
movl 0x20(%rbx), %eax
movslq %r15d, %r13
subl %r15d, %eax
jne 0x84cfc
movslq %r14d, %r12
jmp 0x84d12
movq 0x18(%rbx), %rsi
addq %r13, %rsi
movslq %r14d, %r12
leaq (%rsi,%r12), %rdi
movslq %eax, %rdx
callq 0xc130
movq -0x30(%rbp), %rsi
addq 0x18(%rbx), %r13
movq %r13, %rdi
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 0x84d45
addl %r14d, %eax
movl %eax, 0x2c(%rbx)
movl %eax, 0x34(%rbx)
movl %eax, 0x30(%rbx)
movb $0x1, 0x28(%rbx)
addl %r14d, 0x20(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x345d7(%rip), %rdi     # 0xb9340
leaq 0x33618(%rip), %rsi     # 0xb8388
leaq 0x345fd(%rip), %rcx     # 0xb9374
movl $0xe72, %edx            # imm = 0xE72
callq 0xc140
leaq 0x3463a(%rip), %rdi     # 0xb93c2
leaq 0x335f9(%rip), %rsi     # 0xb8388
leaq 0x345de(%rip), %rcx     # 0xb9374
movl $0xe73, %edx            # imm = 0xE73
callq 0xc140