// File: /workspace/github_c_makefile_star2_O1/zhou-yuxin[P]redis-aof-no-cow/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 0x39222
leaq 0x5a210(%rip), %rsi     # 0xcd183
movq %rax, %rdi
callq 0x39b26
movl $0x2a, %edx
movq %rax, %rdi
movq %r12, %rsi
callq 0x39a56
leaq 0x5a1fb(%rip), %rsi     # 0xcd18d
movl $0x3, %edx
movq %rax, %rdi
callq 0x39a56
movq 0x8(%r15), %rsi
movzbl -0x1(%rsi), %edx
movl %edx, %ecx
andl $0x7, %ecx
cmpl $0x4, %ecx
ja 0x72fdd
leaq 0x59718(%rip), %rdi     # 0xcc6d0
movslq (%rdi,%rcx,4), %rcx
addq %rdi, %rcx
jmpq *%rcx
shrl $0x3, %edx
jmp 0x72fdf
movq -0x11(%rsi), %rdx
jmp 0x72fdf
movzwl -0x5(%rsi), %edx
jmp 0x72fdf
movl -0x9(%rsi), %edx
jmp 0x72fdf
movzbl -0x3(%rsi), %edx
jmp 0x72fdf
xorl %edx, %edx
movq %rax, %rdi
callq 0x39a56
leaq 0x5a1a3(%rip), %rsi     # 0xcd191
movl $0x4, %edx
movq %rax, %rdi
callq 0x39a56
movq %rax, %r13
movzbl -0x1(%rax), %edx
movl %edx, %eax
andl $0x7, %eax
cmpl $0x4, %eax
ja 0x7303b
leaq 0x596d1(%rip), %rcx     # 0xcc6e4
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
shrl $0x3, %edx
jmp 0x7303d
movq -0x11(%r13), %rdx
jmp 0x7303d
movzwl -0x5(%r13), %edx
jmp 0x7303d
movl -0x9(%r13), %edx
jmp 0x7303d
movzbl -0x3(%r13), %edx
jmp 0x7303d
xorl %edx, %edx
leaq 0x5a152(%rip), %rcx     # 0xcd196
movq %r14, %rdi
movq %r13, %rsi
callq 0x9558c
testl %eax, %eax
je 0x73095
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
movq %r14, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
xorl %edx, %edx
callq 0x89e02
leaq 0x5a135(%rip), %rsi     # 0xcd1a3
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x3fff2
movq %r14, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x89976
movq %r13, %rdi
callq 0x392b6
jmp 0x73121
movq %r13, %rdi
callq 0x392b6
movq %r14, %rdi
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x8a6ac
testl %eax, %eax
je 0x730e6
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
movq %r14, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
xorl %edx, %edx
callq 0x89e02
leaq 0x5a104(%rip), %rsi     # 0xcd1ce
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x3fff2
movq %r14, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x89976
jmp 0x73121
leaq 0x9376b(%rip), %rax     # 0x106858
movq 0x9d0(%rax), %r14
addq $0x2, %r12
movl $0x28, %esi
movq %r12, %rdi
callq 0x3910c
movq %r14, %rdi
movq %rax, %rsi
movq %r15, %rdx
callq 0x31a95
testl %eax, %eax
jne 0x73132
movq %r15, %rdi
callq 0x43c0c
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x50d93(%rip), %rdx     # 0xc3ecc
leaq 0x5a0b7(%rip), %rcx     # 0xcd1f7
movq %rbx, %rdi
xorl %esi, %esi
movl $0x497, %r8d            # imm = 0x497
callq 0x66380
movl $0x1, %edi
callq 0x263d0