// File: /workspace/github_c_makefile_star2_O3/gplessis[P]dotdeb-redis/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 0x860ba
cmpl $0xa, %r13d
jne 0x70cbf
leaq 0x59abf(%rip), %rsi     # 0xca768
movq %r14, %rdi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x36b9c
movl %eax, %ebx
cmpl $0x8, %eax
ja 0x70f1a
movl %ebx, %eax
leaq 0x58b71(%rip), %rcx     # 0xc9844
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %r12, %rdi
movl %ebp, %esi
callq 0x86425
addl $-0x2, %ebx
cmpl $0x6, %ebx
ja 0x70d00
movl %ebx, %ecx
leaq 0x58c11(%rip), %rsi     # 0xc9908
movslq (%rsi,%rcx,4), %rdx
addq %rsi, %rdx
jmp 0x70d07
leaq 0x500dc(%rip), %rdx     # 0xc0de3
leaq 0x59ab2(%rip), %rsi     # 0xca7c0
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 0x36f2d
leaq 0x20(%rsp), %rbx
movq %r12, %rdi
movl %ebp, %esi
movq %rbx, %rdx
callq 0x862f8
movq (%rbx), %rdx
movq %r14, %rdi
movq %rax, %rsi
callq 0x37c36
jmp 0x71030
leaq 0x5fcba(%rip), %rsi     # 0xd0a0f
movl $0x3, %edx
movq %r14, %rdi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x36ad1
movq %r12, %rdi
movl %ebp, %esi
callq 0x862d2
testl %eax, %eax
leaq 0x59a12(%rip), %rax     # 0xca795
leaq 0x55c47(%rip), %rsi     # 0xc69d1
cmoveq %rax, %rsi
jmp 0x70ca9
movq %r12, %rdi
movl %ebp, %esi
callq 0x86274
leaq 0x599f7(%rip), %rsi     # 0xca79b
movq %r14, %rdi
movb $0x1, %al
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x36f2d
callq 0x3628d
movq %rax, %rbx
callq 0x3628d
movq %rax, %r15
movq %r12, %rdi
callq 0x86487
decl %ebp
movq %r12, %rdi
movl %ebp, %esi
callq 0x86e33
testl %eax, %eax
je 0x70f3c
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 0x70e3d
movq %r12, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x860ba
cmpl $0x3, %eax
jne 0x70e3d
movq %r12, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x86274
xorps %xmm1, %xmm1
cvtsi2sd %r14d, %xmm1
ucomisd %xmm1, %xmm0
jne 0x70e3d
jnp 0x70f02
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 0x70c79
movl $0x2, %edx
movq %rax, %rdi
leaq 0x5992e(%rip), %r15     # 0xca79e
movq %r15, %rsi
callq 0x36ad1
movq %rax, %rbx
movl $0x1, %edx
movq %rbp, %rdi
leaq 0x59917(%rip), %rsi     # 0xca7a1
callq 0x36ad1
movq %rax, %rdi
movq %r12, %rsi
movl $0xfffffffe, %edx       # imm = 0xFFFFFFFE
movl %r13d, %ecx
callq 0x70c79
movl $0x2, %edx
movq %rax, %rdi
leaq 0x598f2(%rip), %rsi     # 0xca7a3
callq 0x36ad1
movq %rax, %rdi
movq %r12, %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movl %r13d, %ecx
callq 0x70c79
movl $0x2, %edx
movq %rax, %rdi
movq %r15, %rsi
callq 0x36ad1
movq %rax, %r15
movq %r12, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x85d59
incl %r14d
movq %r12, %rdi
movl 0x14(%rsp), %esi
callq 0x86e33
testl %eax, %eax
jne 0x70e02
jmp 0x70f26
movq %r15, %rbp
movl $0x1, 0xc(%rsp)
movl $0x0, 0x10(%rsp)
jmp 0x70e4e
leaq 0x598a7(%rip), %rsi     # 0xca7c8
jmp 0x70ca9
cmpb $0x0, 0x10(%rsp)
movq %rbx, %r12
movq %rbx, %r13
cmovneq %r15, %r13
movq 0x18(%rsp), %r14
jmp 0x70f42
movq %rbx, %r13
movq %rbx, %r12
movzbl -0x1(%r12), %eax
movl %eax, %ecx
andl $0x7, %ecx
cmpl $0x4, %ecx
ja 0x70f97
leaq 0x5890f(%rip), %rdx     # 0xc9868
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
shrl $0x3, %eax
jmp 0x70f83
movq -0x11(%r12), %rax
jmp 0x70f83
movzwl -0x5(%r12), %eax
jmp 0x70f83
movl -0x9(%r12), %eax
jmp 0x70f83
movzbl -0x3(%r12), %eax
testq %rax, %rax
je 0x70f97
movq %r12, %rdi
xorl %esi, %esi
movl $0xfffffffd, %edx       # imm = 0xFFFFFFFD
callq 0x377b2
movzbl -0x1(%r15), %eax
movl %eax, %ecx
andl $0x7, %ecx
cmpl $0x4, %ecx
ja 0x70fe7
leaq 0x588cf(%rip), %rdx     # 0xc987c
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
shrl $0x3, %eax
jmp 0x70fd3
movq -0x11(%r15), %rax
jmp 0x70fd3
movzwl -0x5(%r15), %eax
jmp 0x70fd3
movl -0x9(%r15), %eax
jmp 0x70fd3
movzbl -0x3(%r15), %eax
testq %rax, %rax
je 0x70fe7
movq %r15, %rdi
xorl %esi, %esi
movl $0xfffffffd, %edx       # imm = 0xFFFFFFFD
callq 0x377b2
leaq 0x597b8(%rip), %rsi     # 0xca7a6
movl $0x1, %edx
movq %r14, %rdi
callq 0x36ad1
movq %rax, %rdi
movq %r13, %rsi
callq 0x36bc3
leaq 0x5979b(%rip), %rsi     # 0xca7a8
movl $0x1, %edx
movq %rax, %rdi
callq 0x36ad1
movq %rax, %rbx
movq %r12, %rdi
callq 0x36330
movq %r15, %rdi
callq 0x36330
movq %rbx, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq