// File: /workspace/github_c_makefile_star2_O1/stetre[P]moonnuklear/src/edit.c
// Function: moonnuklear_edit_string
int edit_string(lua_State *L)
    {
    size_t in_len;
    nk_plugin_filter filter = NULL;
    nk_context_t *context = checkcontext(L, 1, NULL);
    nk_edit_t *edit = &context->text_edit;
    ud_t *ud = userdata(edit);
    nk_flags flags = checkflags(L, 2); /* editflags */
    const char *in_text = luaL_checklstring(L, 3, &in_len);
    int max = luaL_checkinteger(L, 4);
    int len = (int)in_len;
    int custom_filter = 0;
    if(lua_isfunction(L, 5))
        custom_filter = 1;
    else
        filter = testpluginfilter(L, 5);

    if(max == 0 || max < len) return argerrorc(L, 4, ERR_VALUE); /* too small */
    /* allocate or reallocate the internal buffer, if needed */
    if(!ud->buf || ud->bufsize < max)
        {
        if(ud->buf) Free(L, ud->buf);
        ud->buf = (char*)Malloc(L, max);
        ud->bufsize = max;
        }
    if(in_len>0) 
        memcpy(ud->buf, in_text, in_len);

    if(custom_filter)
        {
        /* get the plugin filter */
        if(!lua_isfunction(L, 5))
            return argerrorc(L, 5, ERR_TYPE);
        unreference(L, ud->ref1);
        lua_pushvalue(L, 5);
        ud->ref1 = luaL_ref(L, LUA_REGISTRYINDEX);
        }
    /* eventually execute the function */
    flags = nk_edit_string(context, flags, ud->buf, &len, max, custom_filter ? Filter : filter);
    if(len == 0)
        lua_pushstring(L, "");
    else
        lua_pushlstring(L, ud->buf, len);
    pushflags(L, flags); /* widgetlayoutstates */
    return 2;
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdi, %rbx
leaq 0x518da(%rip), %rcx     # 0x68280
xorl %ebp, %ebp
movl $0x1, %esi
xorl %edx, %edx
callq 0x120d0
movq %rax, %r15
leaq 0x31d0(%rax), %rdi
callq 0x132d0
movq %rax, %r14
movq %rbx, %rdi
movl $0x2, %esi
callq 0x12f30
movq %rax, 0x18(%rsp)
leaq 0x20(%rsp), %r12
movq %rbx, %rdi
movl $0x3, %esi
movq %r12, %rdx
callq 0x12cd0
movq %rax, 0x10(%rsp)
movq %rbx, %rdi
movl $0x4, %esi
callq 0x12f30
movq %rax, %r13
movl (%r12), %eax
movl %eax, 0xc(%rsp)
movq %rbx, %rdi
movl $0x5, %esi
callq 0x13df0
movl %eax, %r12d
cmpl $0x6, %eax
je 0x16a2f
movq %rbx, %rdi
movl $0x5, %esi
callq 0x136e0
movq %rax, %rbp
testl %r13d, %r13d
je 0x16b36
cmpl %r13d, 0xc(%rsp)
jg 0x16b36
movq 0x88(%r14), %rsi
testq %rsi, %rsi
je 0x16a65
cmpl %r13d, 0x90(%r14)
jge 0x16a7e
testq %rsi, %rsi
je 0x16a65
movq %rbx, %rdi
callq 0x130d0
movslq %r13d, %rsi
movq %rbx, %rdi
callq 0x13a00
movq %rax, 0x88(%r14)
movl %r13d, 0x90(%r14)
movq 0x20(%rsp), %rdx
testq %rdx, %rdx
je 0x16a99
movq 0x88(%r14), %rdi
movq 0x10(%rsp), %rsi
callq 0x13010
cmpl $0x6, %r12d
jne 0x16af8
movq %rbx, %rdi
movl $0x5, %esi
callq 0x13df0
cmpl $0x6, %eax
jne 0x16b7f
movl 0x74(%r14), %edx
cmpl $-0x2, %edx
je 0x16ad3
movq %rbx, %rdi
movl $0xfff0b9d8, %esi       # imm = 0xFFF0B9D8
callq 0x13f50
movl $0xfffffffe, 0x74(%r14) # imm = 0xFFFFFFFE
movq %rbx, %rdi
movl $0x5, %esi
callq 0x12d70
movq %rbx, %rdi
movl $0xfff0b9d8, %esi       # imm = 0xFFF0B9D8
callq 0x12780
movl %eax, 0x74(%r14)
leaq 0x9b(%rip), %rbp        # 0x16b93
movq 0x88(%r14), %rdx
leaq 0xc(%rsp), %r12
movq %r15, %rdi
movq 0x18(%rsp), %rsi
movq %r12, %rcx
movl %r13d, %r8d
movq %rbp, %r9
callq 0x13ea0
movl %eax, %ebp
movslq (%r12), %rdx
testq %rdx, %rdx
je 0x16b52
movq 0x88(%r14), %rsi
movq %rbx, %rdi
callq 0x13670
jmp 0x16b61
movl $0xfffffffd, %edi       # imm = 0xFFFFFFFD
callq 0x13ac0
movq %rbx, %rdi
movl $0x4, %esi
movq %rax, %rdx
callq 0x12460
jmp 0x16b70
leaq 0x5c808(%rip), %rsi     # 0x73361
movq %rbx, %rdi
callq 0x13f90
movl %ebp, %esi
movq %rbx, %rdi
callq 0x12b60
movl $0x2, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0xfffffffe, %edi       # imm = 0xFFFFFFFE
callq 0x13ac0
movq %rbx, %rdi
movl $0x5, %esi
jmp 0x16b48