// File: /workspace/github_c_makefile_star2_O0/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:
subq $0x98, %rsp
movq %rdi, 0x88(%rsp)
movq $0x0, 0x78(%rsp)
movq 0x88(%rsp), %rdi
movl $0x1, %esi
xorl %eax, %eax
movl %eax, %edx
leaq 0x8e390(%rip), %rcx     # 0xa7280
callq 0x130f0
movq %rax, 0x70(%rsp)
movq 0x70(%rsp), %rax
addq $0x31d0, %rax           # imm = 0x31D0
movq %rax, 0x68(%rsp)
movq 0x68(%rsp), %rdi
callq 0x14450
movq %rax, 0x60(%rsp)
movq 0x88(%rsp), %rdi
movl $0x2, %esi
callq 0x14070
movl %eax, 0x5c(%rsp)
movq 0x88(%rsp), %rdi
movl $0x3, %esi
leaq 0x80(%rsp), %rdx
callq 0x13df0
movq %rax, 0x50(%rsp)
movq 0x88(%rsp), %rdi
movl $0x4, %esi
callq 0x14070
movl %eax, 0x4c(%rsp)
movq 0x80(%rsp), %rax
movl %eax, 0x48(%rsp)
movl $0x0, 0x44(%rsp)
movq 0x88(%rsp), %rdi
movl $0x5, %esi
callq 0x15090
cmpl $0x6, %eax
jne 0x18f99
movl $0x1, 0x44(%rsp)
jmp 0x18fb0
movq 0x88(%rsp), %rdi
movl $0x5, %esi
callq 0x148f0
movq %rax, 0x78(%rsp)
cmpl $0x0, 0x4c(%rsp)
je 0x18fc1
movl 0x4c(%rsp), %eax
cmpl 0x48(%rsp), %eax
jge 0x18ff6
movq 0x88(%rsp), %rax
movq %rax, 0x38(%rsp)
movl $0xfffffffd, %edi       # imm = 0xFFFFFFFD
callq 0x14d10
movq 0x38(%rsp), %rdi
movq %rax, %rdx
movl $0x4, %esi
callq 0x134c0
movl %eax, 0x94(%rsp)
jmp 0x1921a
movq 0x60(%rsp), %rax
cmpq $0x0, 0x88(%rax)
je 0x19016
movq 0x60(%rsp), %rax
movl 0x90(%rax), %eax
cmpl 0x4c(%rsp), %eax
jge 0x1906e
movq 0x60(%rsp), %rax
cmpq $0x0, 0x88(%rax)
je 0x1903e
movq 0x88(%rsp), %rdi
movq 0x60(%rsp), %rax
movq 0x88(%rax), %rsi
callq 0x14230
movq 0x88(%rsp), %rdi
movslq 0x4c(%rsp), %rsi
callq 0x14c40
movq %rax, %rcx
movq 0x60(%rsp), %rax
movq %rcx, 0x88(%rax)
movl 0x4c(%rsp), %ecx
movq 0x60(%rsp), %rax
movl %ecx, 0x90(%rax)
cmpq $0x0, 0x80(%rsp)
jbe 0x19097
movq 0x60(%rsp), %rax
movq 0x88(%rax), %rdi
movq 0x50(%rsp), %rsi
movq 0x80(%rsp), %rdx
callq 0x14160
cmpl $0x0, 0x44(%rsp)
je 0x19151
movq 0x88(%rsp), %rdi
movl $0x5, %esi
callq 0x15090
cmpl $0x6, %eax
je 0x190ee
movq 0x88(%rsp), %rax
movq %rax, 0x30(%rsp)
movl $0xfffffffe, %edi       # imm = 0xFFFFFFFE
callq 0x14d10
movq 0x30(%rsp), %rdi
movq %rax, %rdx
movl $0x5, %esi
callq 0x134c0
movl %eax, 0x94(%rsp)
jmp 0x1921a
jmp 0x190f0
movq 0x60(%rsp), %rax
cmpl $-0x2, 0x74(%rax)
je 0x19121
movq 0x88(%rsp), %rdi
movq 0x60(%rsp), %rax
movl 0x74(%rax), %edx
movl $0xfff0b9d8, %esi       # imm = 0xFFF0B9D8
callq 0x15200
movq 0x60(%rsp), %rax
movl $0xfffffffe, 0x74(%rax) # imm = 0xFFFFFFFE
jmp 0x19123
movq 0x88(%rsp), %rdi
movl $0x5, %esi
callq 0x13eb0
movq 0x88(%rsp), %rdi
movl $0xfff0b9d8, %esi       # imm = 0xFFF0B9D8
callq 0x13840
movl %eax, %ecx
movq 0x60(%rsp), %rax
movl %ecx, 0x74(%rax)
movq 0x70(%rsp), %rax
movq %rax, 0x10(%rsp)
movl 0x5c(%rsp), %eax
movl %eax, 0x1c(%rsp)
movq 0x60(%rsp), %rax
movq 0x88(%rax), %rax
movq %rax, 0x20(%rsp)
movl 0x4c(%rsp), %eax
movl %eax, 0x2c(%rsp)
cmpl $0x0, 0x44(%rsp)
je 0x19191
leaq 0xa6(%rip), %rax        # 0x19230
movq %rax, 0x8(%rsp)
jmp 0x1919b
movq 0x78(%rsp), %rax
movq %rax, 0x8(%rsp)
movl 0x2c(%rsp), %r8d
movq 0x20(%rsp), %rdx
movl 0x1c(%rsp), %esi
movq 0x10(%rsp), %rdi
movq 0x8(%rsp), %r9
leaq 0x48(%rsp), %rcx
callq 0x15140
movl %eax, 0x5c(%rsp)
cmpl $0x0, 0x48(%rsp)
jne 0x191de
movq 0x88(%rsp), %rdi
leaq 0x99029(%rip), %rsi     # 0xb2200
callq 0x15240
jmp 0x191fc
movq 0x88(%rsp), %rdi
movq 0x60(%rsp), %rax
movq 0x88(%rax), %rsi
movslq 0x48(%rsp), %rdx
callq 0x14860
movq 0x88(%rsp), %rdi
movl 0x5c(%rsp), %eax
movl %eax, %esi
callq 0x13c50
movl $0x2, 0x94(%rsp)
movl 0x94(%rsp), %eax
addq $0x98, %rsp
retq
nopl (%rax)