// File: /workspace/github_cpp_makefile_star2_O2/Ciaxur[P]yagb-emu/include/imgui/imgui_widgets.cpp
// Function: ImStb::STB_TEXTEDIT_INSERTCHARS(ImGuiInputTextState*, int, unsigned short const*, int)
static bool STB_TEXTEDIT_INSERTCHARS(STB_TEXTEDIT_STRING* obj, int pos, const ImWchar* new_text, int new_text_len)
{
    const bool is_resizable = (obj->UserFlags & ImGuiInputTextFlags_CallbackResize) != 0;
    const int text_len = obj->CurLenW;
    IM_ASSERT(pos <= text_len);

    const int new_text_len_utf8 = ImTextCountUtf8BytesFromStr(new_text, new_text + new_text_len);
    if (!is_resizable && (new_text_len_utf8 + obj->CurLenA + 1 > obj->BufCapacityA))
        return false;

    // Grow internal buffer if needed
    if (new_text_len + text_len + 1 > obj->TextW.Size)
    {
        if (!is_resizable)
            return false;
        IM_ASSERT(text_len < obj->TextW.Size);
        obj->TextW.resize(text_len + ImClamp(new_text_len * 4, 32, ImMax(256, new_text_len)) + 1);
    }

    ImWchar* text = obj->TextW.Data;
    if (pos != text_len)
        memmove(text + pos + new_text_len, text + pos, (size_t)(text_len - pos) * sizeof(ImWchar));
    memcpy(text + pos, new_text, (size_t)new_text_len * sizeof(ImWchar));

    obj->Edited = true;
    obj->CurLenW += new_text_len;
    obj->CurLenA += new_text_len_utf8;
    obj->TextW[obj->CurLenW] = '\0';

    return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl 0x4(%rdi), %r15d
movl %esi, -0x30(%rbp)
cmpl %esi, %r15d
jl 0x8df82
movl %ecx, %ebx
movq %rdi, %r14
movl 0xe80(%rdi), %r13d
movslq %ecx, %r12
leaq (%rdx,%r12,2), %rsi
movq %rdx, -0x40(%rbp)
movq %rdx, %rdi
callq 0x34bb3
btl $0x12, %r13d
jb 0x8debf
movl 0x8(%r14), %ecx
addl %eax, %ecx
cmpl 0x44(%r14), %ecx
jge 0x8df71
leal (%r15,%rbx), %ecx
cmpl 0x10(%r14), %ecx
jge 0x8df71
movl %eax, -0x2c(%rbp)
leaq 0x10(%r14), %rax
movq %rax, -0x38(%rbp)
jmp 0x8df0c
movl %eax, -0x2c(%rbp)
leal (%r15,%rbx), %ecx
leaq 0x10(%r14), %rdi
movl 0x10(%r14), %eax
cmpl %eax, %ecx
movq %rdi, -0x38(%rbp)
jl 0x8df0c
cmpl %eax, %r15d
jge 0x8dfa1
leal (,%rbx,4), %eax
cmpl $0x101, %ebx            # imm = 0x101
movl $0x100, %ecx            # imm = 0x100
cmovgel %ebx, %ecx
cmpl %ecx, %eax
cmovbl %eax, %ecx
incl %ecx
cmpl $0x8, %ebx
pushq $0x21
popq %rsi
cmovgel %ecx, %esi
addl %r15d, %esi
callq 0x49a10
movq 0x18(%r14), %rcx
movl -0x30(%rbp), %eax
movslq %eax, %r13
subl %eax, %r15d
je 0x8df34
leaq (%rcx,%r13,2), %rsi
leaq (%rsi,%r12,2), %rdi
movslq %r15d, %rdx
addq %rdx, %rdx
movq %rcx, %r15
callq 0xc130
movq %r15, %rcx
leaq (%rcx,%r13,2), %rdi
addq %r12, %r12
movq -0x40(%rbp), %rsi
movq %r12, %rdx
callq 0xc080
movb $0x1, 0xe7e(%r14)
addl 0x4(%r14), %ebx
movl %ebx, 0x4(%r14)
movl -0x2c(%rbp), %eax
addl %eax, 0x8(%r14)
movq -0x38(%rbp), %rdi
movl %ebx, %esi
callq 0x5f790
andw $0x0, (%rax)
movb $0x1, %al
jmp 0x8df73
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x2c335(%rip), %rdi     # 0xba2be
leaq 0x2a3f8(%rip), %rsi     # 0xb8388
leaq 0x2c337(%rip), %rcx     # 0xba2ce
movl $0xe00, %edx            # imm = 0xE00
callq 0xc140
leaq 0x2c37d(%rip), %rdi     # 0xba325
leaq 0x2a3d9(%rip), %rsi     # 0xb8388
leaq 0x2c318(%rip), %rcx     # 0xba2ce
movl $0xe0b, %edx            # imm = 0xE0B
callq 0xc140