// File: /workspace/github_c_makefile_star2_O2/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
movq %rsi, %rbx
movq %rdi, %r15
testq %rdi, %rdi
movl %edx, 0x8(%rsp)
jne 0x4700e
movq 0x3e00b(%rip), %r14     # 0x84ff0
movq (%r14), %rdi
leaq 0x22d1d(%rip), %rsi     # 0x69d0c
leaq 0x22d34(%rip), %rdx     # 0x69d2a
movl $0x67d0, %ecx           # imm = 0x67D0
xorl %eax, %eax
callq 0x12ea0
movq (%r14), %rdi
callq 0x13960
movl 0x8(%rsp), %edx
testq %rbx, %rbx
je 0x47207
movq %rbx, 0x10(%rsp)
testl %edx, %edx
je 0x471f8
cmpb $0x0, 0xb4(%r15)
je 0x471f8
leaq 0xc(%rsp), %r13
movq 0x10(%rsp), %rdi
movq %r13, %rsi
movl %edx, %r12d
callq 0x13020
movl %eax, %ebp
leaq 0x18(%r15), %rbx
leaq 0xc0(%r15), %rax
movq %rax, 0x20(%rsp)
xorl %r14d, %r14d
movq %rbx, 0x18(%rsp)
cmpl %r12d, %r14d
jge 0x471f8
testl %ebp, %ebp
je 0x471f8
movl 0xc(%rsp), %esi
cmpl $0x7f, %esi
je 0x471d5
cmpl $0xa, %esi
jne 0x47092
cmpb $0x0, 0xb8(%r15)
jne 0x471d5
movq 0x98(%r15), %rax
testq %rax, %rax
je 0x470b0
movq %r15, %rdi
callq *%rax
movl 0x8(%rsp), %r12d
testl %eax, %eax
je 0x471d5
movl 0xac(%r15), %eax
movslq %r14d, %r13
cmpl 0xb0(%r15), %eax
jne 0x4713b
movl 0xa8(%r15), %r12d
cmpl 0x90(%r15), %r12d
jge 0x4713b
cmpb $0x2, 0xb4(%r15)
jne 0x47199
movq 0x20(%rsp), %rdi
movl %r12d, %esi
pushq $0x1
popq %rcx
movl %ecx, %edx
callq 0x52be2
testq %rax, %rax
movq %rbx, %rcx
je 0x47114
movq 0x18(%rsp), %rdi
movl %r12d, %esi
movq %rax, %r12
callq 0x12a60
movq 0x18(%rsp), %rcx
movl %eax, (%r12)
movl 0xa8(%r15), %esi
movq %rcx, %rdi
pushq $0x1
popq %r12
movl %r12d, %edx
callq 0x12e20
movl %r12d, %ecx
movl 0xa8(%r15), %r12d
movq 0x18(%rsp), %rdi
jmp 0x4719f
movq %r15, %rdi
callq 0x14070
movl 0xa8(%r15), %esi
addq 0x10(%rsp), %r13
movq %rbx, %rdi
movq %r13, %rdx
pushq $0x1
popq %rcx
callq 0x13ba0
movl 0x8(%rsp), %r12d
testl %eax, %eax
leaq 0xc(%rsp), %r13
je 0x471d5
movl 0xa8(%r15), %esi
movq %r15, %rdi
pushq $0x1
popq %rdx
callq 0x46fb1
movl 0x8(%rsp), %r12d
movl 0x90(%r15), %ecx
movl 0xa8(%r15), %eax
incl %eax
cmpl %ecx, %eax
cmovgel %ecx, %eax
jmp 0x471c6
movq %rbx, %rdi
pushq $0x1
popq %rcx
addq 0x10(%rsp), %r13
movl %r12d, %esi
movq %r13, %rdx
callq 0x13ba0
testl %eax, %eax
leaq 0xc(%rsp), %r13
movl 0x8(%rsp), %r12d
je 0x471d5
movl 0xa8(%r15), %eax
incl %eax
movl %eax, 0xa8(%r15)
movb $0x0, 0xb7(%r15)
addl %ebp, %r14d
movslq %r14d, %rax
movq 0x10(%rsp), %rcx
leaq (%rcx,%rax), %rdi
movl %r12d, %edx
subl %eax, %edx
movq %r13, %rsi
callq 0x13020
movl %eax, %ebp
jmp 0x47061
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x3dde2(%rip), %rbx     # 0x84ff0
movq (%rbx), %rdi
leaq 0x22af4(%rip), %rsi     # 0x69d0c
leaq 0x22b0b(%rip), %rdx     # 0x69d2a
movl $0x67d1, %ecx           # imm = 0x67D1
xorl %eax, %eax
callq 0x12ea0
movq (%rbx), %rdi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x13960