// File: /workspace/github_cpp_makefile_star2_O1/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 $0x28, %rsp
movl 0x4(%rdi), %r15d
movl %esi, -0x40(%rbp)
cmpl %esi, %r15d
jl 0xa8543
movl %ecx, %ebx
movq %rdx, %r12
movq %rdi, %r14
movl 0xe80(%rdi), %r13d
movslq %ecx, %rax
movq %rax, -0x48(%rbp)
leaq (%rdx,%rax,2), %rsi
movq %rdx, %rdi
callq 0x42d4e
btl $0x12, %r13d
jb 0xa83ee
movl 0x8(%r14), %ecx
addl %eax, %ecx
cmpl 0x44(%r14), %ecx
jge 0xa8405
leal (%r15,%rbx), %ecx
movl 0x10(%r14), %edx
cmpl %edx, %ecx
jl 0xa84b8
btl $0x12, %r13d
jb 0xa840c
xorl %eax, %eax
jmp 0xa8534
cmpl %edx, %r15d
jge 0xa8581
cmpl $0x101, %ebx            # imm = 0x101
movl $0x100, %edx            # imm = 0x100
cmovgel %ebx, %edx
leal (,%rbx,4), %ecx
cmpl %edx, %ecx
cmovll %ecx, %edx
cmpl $0x8, %ebx
movl $0x20, %ecx
cmovgel %edx, %ecx
leal (%r15,%rcx), %edx
leal (%r15,%rcx), %esi
incl %esi
movl 0x14(%r14), %ecx
cmpl %edx, %ecx
jg 0xa84b4
testl %ecx, %ecx
je 0xa845d
movl %ecx, %edx
shrl $0x1f, %edx
addl %ecx, %edx
sarl %edx
addl %ecx, %edx
jmp 0xa8462
movl $0x8, %edx
cmpl %esi, %edx
cmovlel %esi, %edx
cmpl %edx, %ecx
jge 0xa84b4
movl %esi, -0x38(%rbp)
movl %eax, -0x2c(%rbp)
movl %edx, -0x3c(%rbp)
movslq %edx, %rdi
addq %rdi, %rdi
callq 0x424fb
movq %rax, %r13
movq 0x18(%r14), %rsi
testq %rsi, %rsi
je 0xa84a3
movslq 0x10(%r14), %rdx
addq %rdx, %rdx
movq %r13, %rdi
callq 0xc080
movq 0x18(%r14), %rdi
callq 0x425d4
movq %r13, 0x18(%r14)
movl -0x3c(%rbp), %eax
movl %eax, 0x14(%r14)
movl -0x2c(%rbp), %eax
movl -0x38(%rbp), %esi
movl %esi, 0x10(%r14)
movl %eax, -0x2c(%rbp)
movq %r12, -0x38(%rbp)
movq 0x18(%r14), %r13
movl -0x40(%rbp), %eax
movslq %eax, %r12
subl %eax, %r15d
je 0xa84ec
leaq (,%r12,2), %rsi
addq %r13, %rsi
movq -0x48(%rbp), %rax
leaq (%rsi,%rax,2), %rdi
movslq %r15d, %rdx
addq %rdx, %rdx
callq 0xc130
leaq (,%r12,2), %rdi
addq %r13, %rdi
movq -0x48(%rbp), %rdx
addq %rdx, %rdx
movq -0x38(%rbp), %rsi
callq 0xc080
movb $0x1, 0xe7e(%r14)
movl -0x2c(%rbp), %eax
addl %eax, 0x8(%r14)
addl 0x4(%r14), %ebx
movl %ebx, 0x4(%r14)
js 0xa8562
cmpl %ebx, 0x10(%r14)
jle 0xa8562
movq 0x18(%r14), %rax
movl %ebx, %ecx
movw $0x0, (%rax,%rcx,2)
movb $0x1, %al
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x2cb57(%rip), %rdi     # 0xd50a1
leaq 0x2abf7(%rip), %rsi     # 0xd3148
leaq 0x2cb59(%rip), %rcx     # 0xd50b1
movl $0xe00, %edx            # imm = 0xE00
callq 0xc140
leaq 0x1310f(%rip), %rdi     # 0xbb678
leaq 0x1311b(%rip), %rsi     # 0xbb68b
leaq 0x28481(%rip), %rcx     # 0xd09f8
movl $0x65c, %edx            # imm = 0x65C
callq 0xc140
leaq 0x2cb80(%rip), %rdi     # 0xd5108
leaq 0x2abb9(%rip), %rsi     # 0xd3148
leaq 0x2cb1b(%rip), %rcx     # 0xd50b1
movl $0xe0b, %edx            # imm = 0xE0B
callq 0xc140