// File: /workspace/github_c_makefile_star2_O2/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 0x24b42
movq 0x604d5(%rip), %r12     # 0x84ff0
movq (%r12), %rdi
leaq 0x451e6(%rip), %rsi     # 0x69d0c
leaq 0x451fd(%rip), %rdx     # 0x69d2a
movl $0x219f, %ecx           # imm = 0x219F
xorl %eax, %eax
callq 0x12ea0
movq (%r12), %rdi
callq 0x13960
testq %r14, %r14
jne 0x24b75
movq 0x604a2(%rip), %r12     # 0x84ff0
movq (%r12), %rdi
leaq 0x451b3(%rip), %rsi     # 0x69d0c
leaq 0x451ca(%rip), %rdx     # 0x69d2a
movl $0x21a0, %ecx           # imm = 0x21A0
xorl %eax, %eax
callq 0x12ea0
movq (%r12), %rdi
callq 0x13960
testl %r15d, %r15d
jns 0x24ba8
movq 0x6046f(%rip), %r12     # 0x84ff0
movq (%r12), %rdi
leaq 0x45180(%rip), %rsi     # 0x69d0c
leaq 0x45197(%rip), %rdx     # 0x69d2a
movl $0x21a1, %ecx           # imm = 0x21A1
xorl %eax, %eax
callq 0x12ea0
movq (%r12), %rdi
callq 0x13960
xorl %r13d, %r13d
testq %rbx, %rbx
je 0x24d08
testq %r14, %r14
je 0x24d08
testl %r15d, %r15d
je 0x24d08
movl %ebp, 0x4(%rsp)
movslq %ebp, %rcx
movq 0x58(%rbx), %rbp
cmpq %rcx, %rbp
jb 0x24d08
movslq %r15d, %rdx
leaq (%rdx,%rbp), %rax
cmpq 0x48(%rbx), %rax
jb 0x24bf1
cmpl $0x0, 0x38(%rbx)
je 0x24d08
movl %ebp, %r12d
subl 0x4(%rsp), %r12d
jne 0x24c0e
movq %rbx, %rdi
movq %r14, %rsi
movl %r15d, %edx
callq 0x13800
jmp 0x24d04
xorl %r13d, %r13d
movq %rcx, 0x10(%rsp)
movq %rbx, %rdi
xorl %esi, %esi
xorl %ecx, %ecx
movq %rdx, 0x8(%rsp)
callq 0x2403e
movq 0x8(%rsp), %rdx
movq 0x10(%rsp), %rdi
testq %rax, %rax
je 0x24d08
movl 0x4(%rsp), %r13d
addl %r15d, %r13d
addl %r12d, %r13d
decl %r13d
jns 0x24c80
movq 0x6039f(%rip), %r15     # 0x84ff0
movq (%r15), %rdi
leaq 0x450b1(%rip), %rsi     # 0x69d0c
leaq 0x450c8(%rip), %rdx     # 0x69d2a
movl $0x21af, %ecx           # imm = 0x21AF
xorl %eax, %eax
callq 0x12ea0
movq (%r15), %rdi
callq 0x13960
movq 0x8(%rsp), %rdx
movq 0x10(%rsp), %rdi
decl %ebp
jns 0x24cba
movq 0x60365(%rip), %r15     # 0x84ff0
movq (%r15), %rdi
leaq 0x45077(%rip), %rsi     # 0x69d0c
leaq 0x4508e(%rip), %rdx     # 0x69d2a
movl $0x21b0, %ecx           # imm = 0x21B0
xorl %eax, %eax
callq 0x12ea0
movq (%r15), %rdi
callq 0x13960
movq 0x8(%rsp), %rdx
movq 0x10(%rsp), %rdi
movq 0x40(%rbx), %rsi
movslq %r13d, %rax
addq %rsi, %rax
movslq %ebp, %rcx
addq %rsi, %rcx
xorl %r8d, %r8d
testl %r12d, %r12d
cmovlel %r8d, %r12d
negl %r12d
cmpl %r8d, %r12d
je 0x24ce9
movb (%rcx,%r8), %sil
movb %sil, (%rax,%r8)
decq %r8
jmp 0x24cd7
addq 0x40(%rbx), %rdi
movq %r14, %rsi
callq 0x24323
movq 0x40(%rbx), %rdi
movl 0x58(%rbx), %esi
callq 0x127b0
movl %eax, 0x78(%rbx)
pushq $0x1
popq %r13
movl %r13d, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq