// File: /workspace/github_c_makefile_star2_O3/gplessis[P]dotdeb-redis/src/scripting.c
// Function: luaCreateFunction
int luaCreateFunction(client *c, lua_State *lua, char *funcname, robj *body) {
    sds funcdef = sdsempty();

    funcdef = sdscat(funcdef,"function ");
    funcdef = sdscatlen(funcdef,funcname,42);
    funcdef = sdscatlen(funcdef,"() ",3);
    funcdef = sdscatlen(funcdef,body->ptr,sdslen(body->ptr));
    funcdef = sdscatlen(funcdef,"\nend",4);

    if (luaL_loadbuffer(lua,funcdef,sdslen(funcdef),"@user_script")) {
        addReplyErrorFormat(c,"Error compiling script (new function): %s\n",
            lua_tostring(lua,-1));
        lua_pop(lua,1);
        sdsfree(funcdef);
        return C_ERR;
    }
    sdsfree(funcdef);
    if (lua_pcall(lua,0,0,0)) {
        addReplyErrorFormat(c,"Error running script (new function): %s\n",
            lua_tostring(lua,-1));
        lua_pop(lua,1);
        return C_ERR;
    }

    /* We also save a SHA1 -> Original script map in a dictionary
     * so that we can replicate / write in the AOF all the
     * EVALSHA commands as EVAL using the original script. */
    {
        int retval = dictAdd(server.lua_scripts,
                             sdsnewlen(funcname+2,40),body);
        serverAssertWithInfo(c,NULL,retval == DICT_OK);
        incrRefCount(body);
    }
    return C_OK;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rcx, %r15
movq %rdx, %r12
movq %rsi, %r14
movq %rdi, %rbx
callq 0x3628d
leaq 0x5ad47(%rip), %rsi     # 0xca21b
movq %rax, %rdi
callq 0x36b9c
movl $0x2a, %edx
movq %rax, %rdi
movq %r12, %rsi
callq 0x36ad1
leaq 0x5ad32(%rip), %rsi     # 0xca225
movl $0x3, %edx
movq %rax, %rdi
callq 0x36ad1
movq 0x8(%r15), %rsi
movzbl -0x1(%rsi), %edx
movl %edx, %ecx
andl $0x7, %ecx
cmpl $0x4, %ecx
ja 0x6f53e
leaq 0x5a23f(%rip), %rdi     # 0xc9758
movslq (%rdi,%rcx,4), %rcx
addq %rdi, %rcx
jmpq *%rcx
shrl $0x3, %edx
jmp 0x6f540
movq -0x11(%rsi), %rdx
jmp 0x6f540
movzwl -0x5(%rsi), %edx
jmp 0x6f540
movl -0x9(%rsi), %edx
jmp 0x6f540
movzbl -0x3(%rsi), %edx
jmp 0x6f540
xorl %edx, %edx
movq %rax, %rdi
callq 0x36ad1
leaq 0x5acda(%rip), %rsi     # 0xca229
movl $0x4, %edx
movq %rax, %rdi
callq 0x36ad1
movq %rax, %r13
movzbl -0x1(%rax), %edx
movl %edx, %eax
andl $0x7, %eax
cmpl $0x4, %eax
ja 0x6f59c
leaq 0x5a1f8(%rip), %rcx     # 0xc976c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
shrl $0x3, %edx
jmp 0x6f59e
movq -0x11(%r13), %rdx
jmp 0x6f59e
movzwl -0x5(%r13), %edx
jmp 0x6f59e
movl -0x9(%r13), %edx
jmp 0x6f59e
movzbl -0x3(%r13), %edx
jmp 0x6f59e
xorl %edx, %edx
leaq 0x5ac89(%rip), %rcx     # 0xca22e
movq %r14, %rdi
movq %r13, %rsi
callq 0x9204c
testl %eax, %eax
je 0x6f5f6
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
movq %r14, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
xorl %edx, %edx
callq 0x862f8
leaq 0x5ac6c(%rip), %rsi     # 0xca23b
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x3cc2d
movq %r14, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x85d59
movq %r13, %rdi
callq 0x36330
jmp 0x6f682
movq %r13, %rdi
callq 0x36330
movq %r14, %rdi
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x86bad
testl %eax, %eax
je 0x6f647
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
movq %r14, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
xorl %edx, %edx
callq 0x862f8
leaq 0x5ac3b(%rip), %rsi     # 0xca266
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x3cc2d
movq %r14, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x85d59
jmp 0x6f682
leaq 0x9225a(%rip), %rax     # 0x1018a8
movq 0x9e0(%rax), %r14
addq $0x2, %r12
movl $0x28, %esi
movq %r12, %rdi
callq 0x36178
movq %r14, %rdi
movq %rax, %rsi
movq %r15, %rdx
callq 0x2e9b8
testl %eax, %eax
jne 0x6f693
movq %r15, %rdi
callq 0x407a8
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x51896(%rip), %rdx     # 0xc0f30
leaq 0x5abee(%rip), %rcx     # 0xca28f
movq %rbx, %rdi
xorl %esi, %esi
movl $0x497, %r8d            # imm = 0x497
callq 0x627c3
movl $0x1, %edi
callq 0x263c0