// File: /workspace/github_cpp_makefile_star2_O3/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, -0x3c(%rbp)
cmpl %esi, %r15d
jl 0xa6a22
movl %ecx, %ebx
movq %rdx, %r13
movq %rdi, %r14
movl 0xe80(%rdi), %r12d
movslq %ecx, %rax
movq %rax, -0x48(%rbp)
leaq (%rdx,%rax,2), %rsi
movq %rdx, %rdi
callq 0x424b1
btl $0x12, %r12d
jb 0xa68e3
movl 0x8(%r14), %ecx
addl %eax, %ecx
cmpl 0x44(%r14), %ecx
jge 0xa68dc
movl %eax, -0x2c(%rbp)
leal (%r15,%rbx), %eax
cmpl 0x10(%r14), %eax
jl 0xa699a
xorl %eax, %eax
jmp 0xa6a13
movl %eax, -0x2c(%rbp)
leal (%r15,%rbx), %ecx
movl 0x10(%r14), %eax
cmpl %eax, %ecx
jl 0xa699a
cmpl %eax, %r15d
jge 0xa6a60
cmpl $0x101, %ebx            # imm = 0x101
movl $0x100, %eax            # imm = 0x100
cmovael %ebx, %eax
leal (,%rbx,4), %ecx
cmpl %eax, %ecx
cmovbl %ecx, %eax
cmpl $0x8, %ebx
movl $0x20, %ecx
cmovgel %eax, %ecx
leal (%r15,%rcx), %edx
leal (%r15,%rcx), %r12d
incl %r12d
movl 0x14(%r14), %eax
cmpl %edx, %eax
jg 0xa6996
testl %eax, %eax
je 0xa6948
movl %eax, %ecx
shrl $0x1f, %ecx
addl %eax, %ecx
sarl %ecx
addl %eax, %ecx
jmp 0xa694d
movl $0x8, %ecx
cmpl %r12d, %ecx
cmovlel %r12d, %ecx
movl %ecx, -0x38(%rbp)
movslq %ecx, %rdi
addq %rdi, %rdi
callq 0x41c63
movq 0x18(%r14), %rsi
testq %rsi, %rsi
je 0xa698b
movslq 0x10(%r14), %rdx
addq %rdx, %rdx
movq %rax, %rdi
movq %rax, -0x50(%rbp)
callq 0xc080
movq 0x18(%r14), %rdi
callq 0x41d3c
movq -0x50(%rbp), %rax
movq %rax, 0x18(%r14)
movl -0x38(%rbp), %eax
movl %eax, 0x14(%r14)
movl %r12d, 0x10(%r14)
movq %r13, -0x38(%rbp)
movq 0x18(%r14), %r13
movl -0x3c(%rbp), %eax
movslq %eax, %r12
subl %eax, %r15d
je 0xa69cb
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 0xa6a41
cmpl %ebx, 0x10(%r14)
jle 0xa6a41
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 0x2c525(%rip), %rdi     # 0xd2f4e
leaq 0x2a5e8(%rip), %rsi     # 0xd1018
leaq 0x2c527(%rip), %rcx     # 0xd2f5e
movl $0xe00, %edx            # imm = 0xE00
callq 0xc140
leaq 0x12c30(%rip), %rdi     # 0xb9678
leaq 0x12c3c(%rip), %rsi     # 0xb968b
leaq 0x27f3e(%rip), %rcx     # 0xce994
movl $0x65c, %edx            # imm = 0x65C
callq 0xc140
leaq 0x2c54e(%rip), %rdi     # 0xd2fb5
leaq 0x2a5aa(%rip), %rsi     # 0xd1018
leaq 0x2c4e9(%rip), %rcx     # 0xd2f5e
movl $0xe0b, %edx            # imm = 0xE0B
callq 0xc140