// File: /workspace/github_c_makefile_star2_O3/stetre[P]moonnuklear/src/./nuklear/nuklear.h
// Function: nk_str_insert_at_char
NK_API int
nk_str_insert_at_char(struct nk_str *s, int pos, const char *str, int len)
{
    int i;
    void *mem;
    char *src;
    char *dst;

    int copylen;
    NK_ASSERT(s);
    NK_ASSERT(str);
    NK_ASSERT(len >= 0);
    if (!s || !str || !len || (nk_size)pos > s->buffer.allocated) return 0;
    if ((s->buffer.allocated + (nk_size)len >= s->buffer.memory.size) &&
        (s->buffer.type == NK_BUFFER_FIXED)) return 0;

    copylen = (int)s->buffer.allocated - pos;
    if (!copylen) {
        nk_str_append_text_char(s, str, len);
        return 1;
    }
    mem = nk_buffer_alloc(&s->buffer, NK_BUFFER_FRONT, (nk_size)len * sizeof(char), 0);
    if (!mem) return 0;

    /* memmove */
    NK_ASSERT(((int)pos + (int)len + ((int)copylen - 1)) >= 0);
    NK_ASSERT(((int)pos + ((int)copylen - 1)) >= 0);
    dst = nk_ptr_add(char, s->buffer.memory.ptr, pos + len + (copylen - 1));
    src = nk_ptr_add(char, s->buffer.memory.ptr, pos + (copylen-1));
    for (i = 0; i < copylen; ++i) *dst-- = *src--;
    mem = nk_ptr_add(void, s->buffer.memory.ptr, pos);
    NK_MEMCPY(mem, str, (nk_size)len * sizeof(char));
    s->len = nk_utf_len((char *)s->buffer.memory.ptr, (int)s->buffer.allocated);
    return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %ecx, %r15d
movq %rdx, %r14
movl %esi, %ebp
movq %rdi, %rbx
testq %rdi, %rdi
jne 0x2627c
movq 0x60d9b(%rip), %r12     # 0x86ff0
movq (%r12), %rdi
leaq 0x4ab3c(%rip), %rsi     # 0x70d9c
leaq 0x4ab53(%rip), %rdx     # 0x70dba
movl $0x219f, %ecx           # imm = 0x219F
xorl %eax, %eax
callq 0x12d80
movq (%r12), %rdi
callq 0x13780
testq %r14, %r14
jne 0x262af
movq 0x60d68(%rip), %r12     # 0x86ff0
movq (%r12), %rdi
leaq 0x4ab09(%rip), %rsi     # 0x70d9c
leaq 0x4ab20(%rip), %rdx     # 0x70dba
movl $0x21a0, %ecx           # imm = 0x21A0
xorl %eax, %eax
callq 0x12d80
movq (%r12), %rdi
callq 0x13780
testl %r15d, %r15d
jns 0x262e2
movq 0x60d35(%rip), %r12     # 0x86ff0
movq (%r12), %rdi
leaq 0x4aad6(%rip), %rsi     # 0x70d9c
leaq 0x4aaed(%rip), %rdx     # 0x70dba
movl $0x21a1, %ecx           # imm = 0x21A1
xorl %eax, %eax
callq 0x12d80
movq (%r12), %rdi
callq 0x13780
xorl %r13d, %r13d
testq %rbx, %rbx
je 0x26437
testq %r14, %r14
je 0x26437
testl %r15d, %r15d
je 0x26437
movl %ebp, 0x4(%rsp)
movslq %ebp, %rcx
movq 0x58(%rbx), %rbp
cmpq %rcx, %rbp
jb 0x26437
movslq %r15d, %rdx
leaq (%rdx,%rbp), %rax
cmpq 0x48(%rbx), %rax
jb 0x2632b
cmpl $0x0, 0x38(%rbx)
je 0x26437
movl %ebp, %r12d
subl 0x4(%rsp), %r12d
jne 0x26348
movq %rbx, %rdi
movq %r14, %rsi
movl %r15d, %edx
callq 0x13640
jmp 0x26431
xorl %r13d, %r13d
movq %rbx, %rdi
movq %rcx, 0x10(%rsp)
xorl %esi, %esi
xorl %ecx, %ecx
movq %rdx, 0x8(%rsp)
callq 0x256b9
movq 0x8(%rsp), %rdx
movq 0x10(%rsp), %rsi
testq %rax, %rax
je 0x26437
movl 0x4(%rsp), %r13d
addl %r15d, %r13d
addl %r12d, %r13d
decl %r13d
jns 0x263ba
movq 0x60c65(%rip), %r15     # 0x86ff0
movq (%r15), %rdi
leaq 0x4aa07(%rip), %rsi     # 0x70d9c
leaq 0x4aa1e(%rip), %rdx     # 0x70dba
movl $0x21af, %ecx           # imm = 0x21AF
xorl %eax, %eax
callq 0x12d80
movq (%r15), %rdi
callq 0x13780
movq 0x8(%rsp), %rdx
movq 0x10(%rsp), %rsi
decl %ebp
jns 0x263f4
movq 0x60c2b(%rip), %r15     # 0x86ff0
movq (%r15), %rdi
leaq 0x4a9cd(%rip), %rsi     # 0x70d9c
leaq 0x4a9e4(%rip), %rdx     # 0x70dba
movl $0x21b0, %ecx           # imm = 0x21B0
xorl %eax, %eax
callq 0x12d80
movq (%r15), %rdi
callq 0x13780
movq 0x8(%rsp), %rdx
movq 0x10(%rsp), %rsi
movq 0x40(%rbx), %rdi
testl %r12d, %r12d
jle 0x26417
movslq %ebp, %rax
movslq %r13d, %rcx
movb (%rdi,%rax), %r8b
movb %r8b, (%rdi,%rcx)
decq %rdi
decl %r12d
jne 0x26403
movq 0x40(%rbx), %rdi
addq %rsi, %rdi
movq %r14, %rsi
callq 0x25a38
movq 0x40(%rbx), %rdi
movl 0x58(%rbx), %esi
callq 0x12730
movl %eax, 0x78(%rbx)
movl $0x1, %r13d
movl %r13d, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq