// File: /workspace/github_c_makefile_star2_O0/gplessis[P]dotdeb-redis/src/scripting.c
// Function: luaReplyToRedisReply
void luaReplyToRedisReply(client *c, lua_State *lua) {
    int t = lua_type(lua,-1);

    switch(t) {
    case LUA_TSTRING:
        addReplyBulkCBuffer(c,(char*)lua_tostring(lua,-1),lua_strlen(lua,-1));
        break;
    case LUA_TBOOLEAN:
        addReply(c,lua_toboolean(lua,-1) ? shared.cone : shared.nullbulk);
        break;
    case LUA_TNUMBER:
        addReplyLongLong(c,(long long)lua_tonumber(lua,-1));
        break;
    case LUA_TTABLE:
        /* We need to check if it is an array, an error, or a status reply.
         * Error are returned as a single element table with 'err' field.
         * Status replies are returned as single element table with 'ok'
         * field. */
        lua_pushstring(lua,"err");
        lua_gettable(lua,-2);
        t = lua_type(lua,-1);
        if (t == LUA_TSTRING) {
            sds err = sdsnew(lua_tostring(lua,-1));
            sdsmapchars(err,"\r\n","  ",2);
            addReplySds(c,sdscatprintf(sdsempty(),"-%s\r\n",err));
            sdsfree(err);
            lua_pop(lua,2);
            return;
        }

        lua_pop(lua,1);
        lua_pushstring(lua,"ok");
        lua_gettable(lua,-2);
        t = lua_type(lua,-1);
        if (t == LUA_TSTRING) {
            sds ok = sdsnew(lua_tostring(lua,-1));
            sdsmapchars(ok,"\r\n","  ",2);
            addReplySds(c,sdscatprintf(sdsempty(),"+%s\r\n",ok));
            sdsfree(ok);
            lua_pop(lua,1);
        } else {
            void *replylen = addDeferredMultiBulkLength(c);
            int j = 1, mbulklen = 0;

            lua_pop(lua,1); /* Discard the 'ok' field value we popped */
            while(1) {
                lua_pushnumber(lua,j++);
                lua_gettable(lua,-2);
                t = lua_type(lua,-1);
                if (t == LUA_TNIL) {
                    lua_pop(lua,1);
                    break;
                }
                luaReplyToRedisReply(c, lua);
                mbulklen++;
            }
            setDeferredMultiBulkLength(c,replylen,mbulklen);
        }
        break;
    default:
        addReply(c,shared.nullbulk);
    }
    lua_pop(lua,1);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x10(%rbp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xacaa0
movl %eax, -0x14(%rbp)
movl -0x14(%rbp), %eax
decl %eax
movl %eax, %ecx
movq %rcx, -0x40(%rbp)
subl $0x4, %eax
ja 0x889ac
movq -0x40(%rbp), %rax
leaq 0xbb0b1(%rip), %rcx     # 0x143774
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x8(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x10(%rbp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
xorl %eax, %eax
movl %eax, %edx
callq 0xacf60
movq %rax, -0x48(%rbp)
movq -0x10(%rbp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xad020
movq -0x50(%rbp), %rdi
movq -0x48(%rbp), %rsi
movq %rax, %rdx
callq 0x43920
jmp 0x889c0
movq -0x8(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x10(%rbp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xacf00
cmpl $0x0, %eax
je 0x88739
leaq 0xf0511(%rip), %rax     # 0x178c40
movq 0x28(%rax), %rax
movq %rax, -0x60(%rbp)
jmp 0x88748
leaq 0xf0500(%rip), %rax     # 0x178c40
movq 0x50(%rax), %rax
movq %rax, -0x60(%rbp)
movq -0x58(%rbp), %rdi
movq -0x60(%rbp), %rsi
callq 0x42cc0
jmp 0x889c0
movq -0x8(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x10(%rbp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xace10
movq -0x68(%rbp), %rdi
cvttsd2si %xmm0, %rsi
callq 0x43780
jmp 0x889c0
movq -0x10(%rbp), %rdi
leaq 0xb067a(%rip), %rsi     # 0x138e08
callq 0xad410
movq -0x10(%rbp), %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0xad800
movq -0x10(%rbp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xacaa0
movl %eax, -0x14(%rbp)
cmpl $0x4, -0x14(%rbp)
jne 0x88840
movq -0x10(%rbp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
xorl %eax, %eax
movl %eax, %edx
callq 0xacf60
movq %rax, %rdi
callq 0x38510
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rdi
leaq 0xb5aa3(%rip), %rsi     # 0x13e288
leaq 0xbbe8f(%rip), %rdx     # 0x14467b
movl $0x2, %ecx
callq 0x3aa80
movq -0x8(%rbp), %rax
movq %rax, -0x70(%rbp)
callq 0x384f0
movq %rax, %rdi
movq -0x20(%rbp), %rdx
leaq 0xbb081(%rip), %rsi     # 0x143892
movb $0x0, %al
callq 0x395b0
movq -0x70(%rbp), %rdi
movq %rax, %rsi
callq 0x42e50
movq -0x20(%rbp), %rdi
callq 0x38620
movq -0x10(%rbp), %rdi
movl $0xfffffffd, %esi       # imm = 0xFFFFFFFD
callq 0xac570
jmp 0x889ce
movq -0x10(%rbp), %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0xac570
movq -0x10(%rbp), %rdi
leaq 0xc275e(%rip), %rsi     # 0x14afb7
callq 0xad410
movq -0x10(%rbp), %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0xad800
movq -0x10(%rbp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xacaa0
movl %eax, -0x14(%rbp)
cmpl $0x4, -0x14(%rbp)
jne 0x8890b
movq -0x10(%rbp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
xorl %eax, %eax
movl %eax, %edx
callq 0xacf60
movq %rax, %rdi
callq 0x38510
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rdi
leaq 0xb59d8(%rip), %rsi     # 0x13e288
leaq 0xbbdc4(%rip), %rdx     # 0x14467b
movl $0x2, %ecx
callq 0x3aa80
movq -0x8(%rbp), %rax
movq %rax, -0x78(%rbp)
callq 0x384f0
movq %rax, %rdi
movq -0x28(%rbp), %rdx
leaq 0xbafbc(%rip), %rsi     # 0x143898
movb $0x0, %al
callq 0x395b0
movq -0x78(%rbp), %rdi
movq %rax, %rsi
callq 0x42e50
movq -0x28(%rbp), %rdi
callq 0x38620
movq -0x10(%rbp), %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0xac570
jmp 0x889aa
movq -0x8(%rbp), %rdi
callq 0x432a0
movq %rax, -0x30(%rbp)
movl $0x1, -0x34(%rbp)
movl $0x0, -0x38(%rbp)
movq -0x10(%rbp), %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0xac570
movq -0x10(%rbp), %rdi
movl -0x34(%rbp), %eax
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, -0x34(%rbp)
cvtsi2sd %eax, %xmm0
callq 0xad2f0
movq -0x10(%rbp), %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0xad800
movq -0x10(%rbp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xacaa0
movl %eax, -0x14(%rbp)
cmpl $0x0, -0x14(%rbp)
jne 0x88981
movq -0x10(%rbp), %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0xac570
jmp 0x88999
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x88680
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x88934
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rsi
movslq -0x38(%rbp), %rdx
callq 0x43310
jmp 0x889c0
movq -0x8(%rbp), %rdi
leaq 0xf0289(%rip), %rax     # 0x178c40
movq 0x50(%rax), %rsi
callq 0x42cc0
movq -0x10(%rbp), %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0xac570
addq $0x80, %rsp
popq %rbp
retq
nopw (%rax,%rax)