// File: /workspace/github_c_makefile_star2_O3/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 0x4ade3
movq 0x3c232(%rip), %r14     # 0x86ff0
movq (%r14), %rdi
leaq 0x25fd4(%rip), %rsi     # 0x70d9c
leaq 0x25feb(%rip), %rdx     # 0x70dba
movl $0x67d0, %ecx           # imm = 0x67D0
xorl %eax, %eax
callq 0x12d80
movq (%r14), %rdi
callq 0x13780
testq %r13, %r13
je 0x4afe7
testl %ebx, %ebx
je 0x4afd8
cmpb $0x0, 0xb4(%r15)
je 0x4afd8
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 0x4afd8
leaq 0x18(%r15), %rax
movq %rax, (%rsp)
leaq 0xc0(%r15), %rax
movq %rax, 0x10(%rsp)
xorl %r14d, %r14d
movq %r13, 0x18(%rsp)
movl 0x8(%rsp), %esi
cmpl $0x7f, %esi
je 0x4afb0
cmpl $0xa, %esi
jne 0x4ae64
cmpb $0x0, 0xb8(%r15)
jne 0x4afb0
movq 0x98(%r15), %rax
testq %rax, %rax
je 0x4ae7d
movq %r15, %rdi
callq *%rax
testl %eax, %eax
je 0x4afb0
movl 0xac(%r15), %eax
movslq %r14d, %r12
cmpl 0xb0(%r15), %eax
jne 0x4af48
movl 0xa8(%r15), %r13d
cmpl 0x90(%r15), %r13d
jge 0x4af48
cmpb $0x2, 0xb4(%r15)
jne 0x4af1a
movq 0x10(%rsp), %rdi
movl %r13d, %esi
movl $0x1, %edx
movl $0x1, %ecx
callq 0x58016
testq %rax, %rax
movq (%rsp), %rcx
je 0x4aeff
movl $0x0, 0xc(%rsp)
movq (%rsp), %rdi
movl %r13d, %esi
leaq 0xc(%rsp), %rdx
leaq 0x24(%rsp), %rcx
movq %rax, %r13
callq 0x13f60
movq (%rsp), %rcx
movl 0xc(%rsp), %eax
movl %eax, (%r13)
movl 0xa8(%r15), %esi
movq %rcx, %rdi
movl $0x1, %edx
callq 0x12d10
movl 0xa8(%r15), %r13d
movq (%rsp), %rdi
movq 0x18(%rsp), %rax
addq %rax, %r12
movl %r13d, %esi
movq %rax, %r13
movq %r12, %rdx
movl $0x1, %ecx
callq 0x139a0
testl %eax, %eax
je 0x4afb0
movl 0xa8(%r15), %eax
incl %eax
jmp 0x4afa1
movq %r15, %rdi
callq 0x13e30
movl 0xa8(%r15), %esi
movq 0x18(%rsp), %r13
addq %r13, %r12
movq (%rsp), %rdi
movq %r12, %rdx
movl $0x1, %ecx
callq 0x139a0
testl %eax, %eax
je 0x4afb0
movl 0xa8(%r15), %esi
movq 0x10(%rsp), %rdi
xorl %edx, %edx
movl $0x1, %ecx
callq 0x58016
movl 0x90(%r15), %ecx
movl 0xa8(%r15), %eax
incl %eax
cmpl %ecx, %eax
cmovgel %ecx, %eax
movl %eax, 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 0x4afd8
movl %eax, %ebp
testl %eax, %eax
jne 0x4ae44
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x3c002(%rip), %rbx     # 0x86ff0
movq (%rbx), %rdi
leaq 0x25da4(%rip), %rsi     # 0x70d9c
leaq 0x25dbb(%rip), %rdx     # 0x70dba
movl $0x67d1, %ecx           # imm = 0x67D1
xorl %eax, %eax
callq 0x12d80
movq (%rbx), %rdi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x13780