// File: /workspace/github_c_makefile_star2_O1/zhou-yuxin[P]redis-aof-no-cow/src/scripting.c
// Function: ldbCatStackValueRec
sds ldbCatStackValueRec(sds s, lua_State *lua, int idx, int level) {
    int t = lua_type(lua,idx);

    if (level++ == LDB_MAX_VALUES_DEPTH)
        return sdscat(s,"<max recursion level reached! Nested table?>");

    switch(t) {
    case LUA_TSTRING:
        {
        size_t strl;
        char *strp = (char*)lua_tolstring(lua,idx,&strl);
        s = sdscatrepr(s,strp,strl);
        }
        break;
    case LUA_TBOOLEAN:
        s = sdscat(s,lua_toboolean(lua,idx) ? "true" : "false");
        break;
    case LUA_TNUMBER:
        s = sdscatprintf(s,"%g",(double)lua_tonumber(lua,idx));
        break;
    case LUA_TNIL:
        s = sdscatlen(s,"nil",3);
        break;
    case LUA_TTABLE:
        {
        int expected_index = 1; /* First index we expect in an array. */
        int is_array = 1; /* Will be set to null if check fails. */
        /* Note: we create two representations at the same time, one
         * assuming the table is an array, one assuming it is not. At the
         * end we know what is true and select the right one. */
        sds repr1 = sdsempty();
        sds repr2 = sdsempty();
        lua_pushnil(lua); /* The first key to start the iteration is nil. */
        while (lua_next(lua,idx-1)) {
            /* Test if so far the table looks like an array. */
            if (is_array &&
                (lua_type(lua,-2) != LUA_TNUMBER ||
                 lua_tonumber(lua,-2) != expected_index)) is_array = 0;
            /* Stack now: table, key, value */
            /* Array repr. */
            repr1 = ldbCatStackValueRec(repr1,lua,-1,level);
            repr1 = sdscatlen(repr1,"; ",2);
            /* Full repr. */
            repr2 = sdscatlen(repr2,"[",1);
            repr2 = ldbCatStackValueRec(repr2,lua,-2,level);
            repr2 = sdscatlen(repr2,"]=",2);
            repr2 = ldbCatStackValueRec(repr2,lua,-1,level);
            repr2 = sdscatlen(repr2,"; ",2);
            lua_pop(lua,1); /* Stack: table, key. Ready for next iteration. */
            expected_index++;
        }
        /* Strip the last " ;" from both the representations. */
        if (sdslen(repr1)) sdsrange(repr1,0,-3);
        if (sdslen(repr2)) sdsrange(repr2,0,-3);
        /* Select the right one and discard the other. */
        s = sdscatlen(s,"{",1);
        s = sdscatsds(s,is_array ? repr1 : repr2);
        s = sdscatlen(s,"}",1);
        sdsfree(repr1);
        sdsfree(repr2);
        }
        break;
    case LUA_TFUNCTION:
    case LUA_TUSERDATA:
    case LUA_TTHREAD:
    case LUA_TLIGHTUSERDATA:
        {
        const void *p = lua_topointer(lua,idx);
        char *typename = "unknown";
        if (t == LUA_TFUNCTION) typename = "function";
        else if (t == LUA_TUSERDATA) typename = "userdata";
        else if (t == LUA_TTHREAD) typename = "thread";
        else if (t == LUA_TLIGHTUSERDATA) typename = "light-userdata";
        s = sdscatprintf(s,"\"%s@%p\"",typename,p);
        }
        break;
    default:
        s = sdscat(s,"\"<unknown-lua-type>\"");
        break;
    }
    return s;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %ecx, %r13d
movl %edx, %ebp
movq %rsi, %r12
movq %rdi, %r14
movq %rsi, %rdi
movl %edx, %esi
callq 0x89bc4
cmpl $0xa, %r13d
jne 0x74766
leaq 0x58f80(%rip), %rsi     # 0xcd6d0
movq %r14, %rdi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x39b26
movl %eax, %ebx
cmpl $0x8, %eax
ja 0x749c1
movl %ebx, %eax
leaq 0x58032(%rip), %rcx     # 0xcc7ac
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %r12, %rdi
movl %ebp, %esi
callq 0x89f2f
addl $-0x2, %ebx
cmpl $0x6, %ebx
ja 0x747a7
movl %ebx, %ecx
leaq 0x580d2(%rip), %rsi     # 0xcc870
movslq (%rsi,%rcx,4), %rdx
addq %rsi, %rdx
jmp 0x747ae
leaq 0x4f5e5(%rip), %rdx     # 0xc3d93
leaq 0x58f73(%rip), %rsi     # 0xcd728
movq %r14, %rdi
movq %rax, %rcx
xorl %eax, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x39eb7
leaq 0x20(%rsp), %rbx
movq %r12, %rdi
movl %ebp, %esi
movq %rbx, %rdx
callq 0x89e02
movq (%rbx), %rdx
movq %r14, %rdi
movq %rax, %rsi
callq 0x3abb1
jmp 0x74adf
leaq 0x5f0e3(%rip), %rsi     # 0xd38df
movl $0x3, %edx
movq %r14, %rdi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x39a56
movq %r12, %rdi
movl %ebp, %esi
callq 0x89ddc
testl %eax, %eax
leaq 0x58ed3(%rip), %rax     # 0xcd6fd
leaq 0x55144(%rip), %rsi     # 0xc9975
cmoveq %rax, %rsi
jmp 0x74750
movq %r12, %rdi
movl %ebp, %esi
callq 0x89d7e
leaq 0x58eb8(%rip), %rsi     # 0xcd703
movq %r14, %rdi
movb $0x1, %al
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x39eb7
callq 0x39222
movq %rax, %rbx
callq 0x39222
movq %rax, %r15
movq %r12, %rdi
callq 0x89f91
decl %ebp
movq %r12, %rdi
movl %ebp, %esi
callq 0x8a92c
testl %eax, %eax
je 0x749e3
movq %r14, 0x18(%rsp)
incl %r13d
movl $0x1, 0xc(%rsp)
movl $0x1, %r14d
movl %ebp, 0x14(%rsp)
movl 0xc(%rsp), %eax
testl %eax, %eax
je 0x748e4
movq %r12, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x89bc4
cmpl $0x3, %eax
jne 0x748e4
movq %r12, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x89d7e
xorps %xmm1, %xmm1
cvtsi2sd %r14d, %xmm1
ucomisd %xmm1, %xmm0
jne 0x748e4
jnp 0x749a9
movb $0x1, %al
movl %eax, 0x10(%rsp)
movl $0x0, 0xc(%rsp)
movq %r15, %rbp
movq %rbx, %rdi
movq %r12, %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movl %r13d, %ecx
callq 0x74720
movl $0x2, %edx
movq %rax, %rdi
leaq 0x58def(%rip), %r15     # 0xcd706
movq %r15, %rsi
callq 0x39a56
movq %rax, %rbx
movl $0x1, %edx
movq %rbp, %rdi
leaq 0x58dd8(%rip), %rsi     # 0xcd709
callq 0x39a56
movq %rax, %rdi
movq %r12, %rsi
movl $0xfffffffe, %edx       # imm = 0xFFFFFFFE
movl %r13d, %ecx
callq 0x74720
movl $0x2, %edx
movq %rax, %rdi
leaq 0x58db3(%rip), %rsi     # 0xcd70b
callq 0x39a56
movq %rax, %rdi
movq %r12, %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movl %r13d, %ecx
callq 0x74720
movl $0x2, %edx
movq %rax, %rdi
movq %r15, %rsi
callq 0x39a56
movq %rax, %r15
movq %r12, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x89976
incl %r14d
movq %r12, %rdi
movl 0x14(%rsp), %esi
callq 0x8a92c
testl %eax, %eax
jne 0x748a9
jmp 0x749cd
movq %r15, %rbp
movl $0x1, 0xc(%rsp)
movl $0x0, 0x10(%rsp)
jmp 0x748f5
leaq 0x58d68(%rip), %rsi     # 0xcd730
jmp 0x74750
cmpb $0x0, 0x10(%rsp)
movq %rbx, %r12
movq %rbx, %r13
cmovneq %r15, %r13
movq 0x18(%rsp), %r14
jmp 0x749e9
movq %rbx, %r13
movq %rbx, %r12
movzbl -0x1(%r12), %eax
movl %eax, %ecx
andl $0x7, %ecx
cmpl $0x4, %ecx
ja 0x74a2c
leaq 0x57dd0(%rip), %rdx     # 0xcc7d0
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
shrl $0x3, %eax
jmp 0x74a2e
movq -0x11(%r12), %rax
jmp 0x74a2e
movzwl -0x5(%r12), %eax
jmp 0x74a2e
movl -0x9(%r12), %eax
jmp 0x74a2e
movzbl -0x3(%r12), %eax
jmp 0x74a2e
xorl %eax, %eax
testq %rax, %rax
je 0x74a42
movq %r12, %rdi
xorl %esi, %esi
movl $0xfffffffd, %edx       # imm = 0xFFFFFFFD
callq 0x3a73b
movzbl -0x1(%r15), %eax
movl %eax, %ecx
andl $0x7, %ecx
cmpl $0x4, %ecx
ja 0x74a80
leaq 0x57d8c(%rip), %rdx     # 0xcc7e4
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
shrl $0x3, %eax
jmp 0x74a82
movq -0x11(%r15), %rax
jmp 0x74a82
movzwl -0x5(%r15), %eax
jmp 0x74a82
movl -0x9(%r15), %eax
jmp 0x74a82
movzbl -0x3(%r15), %eax
jmp 0x74a82
xorl %eax, %eax
testq %rax, %rax
je 0x74a96
movq %r15, %rdi
xorl %esi, %esi
movl $0xfffffffd, %edx       # imm = 0xFFFFFFFD
callq 0x3a73b
leaq 0x58c71(%rip), %rsi     # 0xcd70e
movl $0x1, %edx
movq %r14, %rdi
callq 0x39a56
movq %rax, %rdi
movq %r13, %rsi
callq 0x39b4d
leaq 0x58c54(%rip), %rsi     # 0xcd710
movl $0x1, %edx
movq %rax, %rdi
callq 0x39a56
movq %rax, %rbx
movq %r12, %rdi
callq 0x392b6
movq %r15, %rdi
callq 0x392b6
movq %rbx, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq