// File: /workspace/github_c_makefile_star2_O1/stetre[P]moonnuklear/src/./nuklear/nuklear.h
// Function: nk_textedit_text
NK_API void
nk_textedit_text(struct nk_text_edit *state, const char *text, int total_len)
{
    nk_rune unicode;
    int glyph_len;
    int text_len = 0;

    NK_ASSERT(state);
    NK_ASSERT(text);
    if (!text || !total_len || state->mode == NK_TEXT_EDIT_MODE_VIEW) return;

    glyph_len = nk_utf_decode(text, &unicode, total_len);
    while ((text_len < total_len) && glyph_len)
    {
        /* don't insert a backward delete, just process the event */
        if (unicode == 127) goto next;
        /* can't add newline in single-line mode */
        if (unicode == '\n' && state->single_line) goto next;
        /* filter incoming text */
        if (state->filter && !state->filter(state, unicode)) goto next;

        if (!NK_TEXT_HAS_SELECTION(state) &&
            state->cursor < state->string.len)
        {
            if (state->mode == NK_TEXT_EDIT_MODE_REPLACE) {
                nk_textedit_makeundo_replace(state, state->cursor, 1, 1);
                nk_str_delete_runes(&state->string, state->cursor, 1);
            }
            if (nk_str_insert_text_utf8(&state->string, state->cursor,
                                        text+text_len, 1))
            {
                ++state->cursor;
                state->has_preferred_x = 0;
            }
        } else {
            nk_textedit_delete_selection(state); /* implicitly clamps */
            if (nk_str_insert_text_utf8(&state->string, state->cursor,
                                        text+text_len, 1))
            {
                nk_textedit_makeundo_insert(state, state->cursor, 1);
                state->cursor = NK_MIN(state->cursor + 1, state->string.len);
                state->has_preferred_x = 0;
            }
        }
        next:
        text_len += glyph_len;
        glyph_len = nk_utf_decode(text + text_len, &unicode, total_len-text_len);
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %edx, %ebx
movq %rsi, %r13
movq %rdi, %r15
testq %rdi, %rdi
jne 0x4b9f0
movq 0x3c625(%rip), %r14     # 0x87ff0
movq (%r14), %rdi
leaq 0x263b7(%rip), %rsi     # 0x71d8c
leaq 0x263ce(%rip), %rdx     # 0x71daa
movl $0x67d0, %ecx           # imm = 0x67D0
xorl %eax, %eax
callq 0x12d80
movq (%r14), %rdi
callq 0x13780
testq %r13, %r13
jne 0x4ba21
movq 0x3c5f4(%rip), %r14     # 0x87ff0
movq (%r14), %rdi
leaq 0x26386(%rip), %rsi     # 0x71d8c
leaq 0x2639d(%rip), %rdx     # 0x71daa
movl $0x67d1, %ecx           # imm = 0x67D1
xorl %eax, %eax
callq 0x12d80
movq (%r14), %rdi
callq 0x13780
testq %r13, %r13
sete %al
testl %ebx, %ebx
sete %cl
orb %al, %cl
jne 0x4bc07
cmpb $0x0, 0xb4(%r15)
je 0x4bc07
leaq 0x8(%rsp), %rsi
movq %r13, %rdi
movl %ebx, %edx
callq 0x12ef0
movl %eax, %ebp
testl %ebx, %ebx
setg %al
testl %ebp, %ebp
setne %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x4bc07
leaq 0x18(%r15), %rax
movq %rax, (%rsp)
leaq 0xc0(%r15), %rax
movq %rax, 0x18(%rsp)
xorl %r14d, %r14d
movl 0x8(%rsp), %esi
cmpl $0x7f, %esi
je 0x4bbdf
cmpl $0xa, %esi
jne 0x4ba9f
cmpb $0x0, 0xb8(%r15)
jne 0x4bbdf
movq 0x98(%r15), %rax
testq %rax, %rax
je 0x4bab8
movq %r15, %rdi
callq *%rax
testl %eax, %eax
je 0x4bbdf
movl 0xac(%r15), %eax
movslq %r14d, %r12
cmpl 0xb0(%r15), %eax
jne 0x4bb7c
movl 0xa8(%r15), %eax
cmpl 0x90(%r15), %eax
jge 0x4bb7c
cmpb $0x2, 0xb4(%r15)
jne 0x4bb54
movq 0x18(%rsp), %rdi
movl %eax, %esi
movl %eax, 0x10(%rsp)
movl $0x1, %edx
movl $0x1, %ecx
callq 0x58bcf
testq %rax, %rax
movq (%rsp), %rdi
je 0x4bb43
movl $0x0, 0xc(%rsp)
movq (%rsp), %rdi
movl 0x10(%rsp), %esi
leaq 0xc(%rsp), %rdx
leaq 0x24(%rsp), %rcx
movq %rax, 0x10(%rsp)
callq 0x13f60
movq (%rsp), %rdi
movl 0xc(%rsp), %eax
movq 0x10(%rsp), %rcx
movl %eax, (%rcx)
movl 0xa8(%r15), %esi
movl $0x1, %edx
callq 0x12d10
movl 0xa8(%r15), %esi
addq %r13, %r12
movq (%rsp), %rdi
movq %r12, %rdx
movl $0x1, %ecx
callq 0x139a0
testl %eax, %eax
je 0x4bbdf
incl 0xa8(%r15)
jmp 0x4bbd7
movq %r15, %rdi
callq 0x13e30
movl 0xa8(%r15), %esi
addq %r13, %r12
movq (%rsp), %rdi
movq %r12, %rdx
movl $0x1, %ecx
callq 0x139a0
testl %eax, %eax
je 0x4bbdf
movl 0xa8(%r15), %esi
movq 0x18(%rsp), %rdi
xorl %edx, %edx
movl $0x1, %ecx
callq 0x58bcf
movl 0x90(%r15), %eax
movl 0xa8(%r15), %ecx
incl %ecx
cmpl %eax, %ecx
cmovgel %eax, %ecx
movl %ecx, 0xa8(%r15)
movb $0x0, 0xb7(%r15)
addl %ebp, %r14d
movslq %r14d, %r12
leaq (%r12,%r13), %rdi
movl %ebx, %edx
subl %r12d, %edx
leaq 0x8(%rsp), %rsi
callq 0x12ef0
cmpl %r12d, %ebx
jle 0x4bc07
movl %eax, %ebp
testl %eax, %eax
jne 0x4ba7f
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq