// File: /workspace/github_c_makefile_star2_O1/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 0x260fa
movq 0x61f1d(%rip), %r12     # 0x87ff0
movq (%r12), %rdi
leaq 0x4bcae(%rip), %rsi     # 0x71d8c
leaq 0x4bcc5(%rip), %rdx     # 0x71daa
movl $0x219f, %ecx           # imm = 0x219F
xorl %eax, %eax
callq 0x12d80
movq (%r12), %rdi
callq 0x13780
testq %r14, %r14
jne 0x2612d
movq 0x61eea(%rip), %r12     # 0x87ff0
movq (%r12), %rdi
leaq 0x4bc7b(%rip), %rsi     # 0x71d8c
leaq 0x4bc92(%rip), %rdx     # 0x71daa
movl $0x21a0, %ecx           # imm = 0x21A0
xorl %eax, %eax
callq 0x12d80
movq (%r12), %rdi
callq 0x13780
testl %r15d, %r15d
jns 0x26160
movq 0x61eb7(%rip), %r12     # 0x87ff0
movq (%r12), %rdi
leaq 0x4bc48(%rip), %rsi     # 0x71d8c
leaq 0x4bc5f(%rip), %rdx     # 0x71daa
movl $0x21a1, %ecx           # imm = 0x21A1
xorl %eax, %eax
callq 0x12d80
movq (%r12), %rdi
callq 0x13780
xorl %r13d, %r13d
testq %rbx, %rbx
je 0x262b2
testq %r14, %r14
je 0x262b2
testl %r15d, %r15d
je 0x262b2
movl %ebp, 0x4(%rsp)
movslq %ebp, %rcx
movq 0x58(%rbx), %rbp
cmpq %rcx, %rbp
jb 0x262b2
movslq %r15d, %rdx
leaq (%rdx,%rbp), %rax
cmpq 0x48(%rbx), %rax
jb 0x261a9
cmpl $0x0, 0x38(%rbx)
je 0x262b2
movl %ebp, %r12d
subl 0x4(%rsp), %r12d
jne 0x261c6
movq %rbx, %rdi
movq %r14, %rsi
movl %r15d, %edx
callq 0x13640
jmp 0x262ac
xorl %r13d, %r13d
movq %rcx, 0x10(%rsp)
movq %rbx, %rdi
xorl %esi, %esi
xorl %ecx, %ecx
movq %rdx, 0x8(%rsp)
callq 0x25548
movq 0x8(%rsp), %rdx
movq 0x10(%rsp), %rdi
testq %rax, %rax
je 0x262b2
movl 0x4(%rsp), %r13d
addl %r15d, %r13d
addl %r12d, %r13d
decl %r13d
jns 0x26238
movq 0x61de7(%rip), %r15     # 0x87ff0
movq (%r15), %rdi
leaq 0x4bb79(%rip), %rsi     # 0x71d8c
leaq 0x4bb90(%rip), %rdx     # 0x71daa
movl $0x21af, %ecx           # imm = 0x21AF
xorl %eax, %eax
callq 0x12d80
movq (%r15), %rdi
callq 0x13780
movq 0x8(%rsp), %rdx
movq 0x10(%rsp), %rdi
decl %ebp
jns 0x26272
movq 0x61dad(%rip), %r15     # 0x87ff0
movq (%r15), %rdi
leaq 0x4bb3f(%rip), %rsi     # 0x71d8c
leaq 0x4bb56(%rip), %rdx     # 0x71daa
movl $0x21b0, %ecx           # imm = 0x21B0
xorl %eax, %eax
callq 0x12d80
movq (%r15), %rdi
callq 0x13780
movq 0x8(%rsp), %rdx
movq 0x10(%rsp), %rdi
testl %r12d, %r12d
jle 0x26291
movq 0x40(%rbx), %rax
movslq %ebp, %rcx
movslq %r13d, %r8
movb (%rax,%rcx), %sil
movb %sil, (%rax,%r8)
decq %rax
decl %r12d
jne 0x26281
addq 0x40(%rbx), %rdi
movq %r14, %rsi
callq 0x258b3
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