// File: /workspace/github_c_makefile_star2_O0/gplessis[P]dotdeb-redis/src/scripting.c
// Function: ldbRepl
int ldbRepl(lua_State *lua) {
    sds *argv;
    int argc;

    /* We continue processing commands until a command that should return
     * to the Lua interpreter is found. */
    while(1) {
        while((argv = ldbReplParseCommand(&argc)) == NULL) {
            char buf[1024];
            int nread = read(ldb.fd,buf,sizeof(buf));
            if (nread <= 0) {
                /* Make sure the script runs without user input since the
                 * client is no longer connected. */
                ldb.step = 0;
                ldb.bpcount = 0;
                return C_ERR;
            }
            ldb.cbuf = sdscatlen(ldb.cbuf,buf,nread);
        }

        /* Flush the old buffer. */
        sdsfree(ldb.cbuf);
        ldb.cbuf = sdsempty();

        /* Execute the command. */
        if (!strcasecmp(argv[0],"h") || !strcasecmp(argv[0],"help")) {
ldbLog(sdsnew("Redis Lua debugger help:"));
ldbLog(sdsnew("[h]elp               Show this help."));
ldbLog(sdsnew("[s]tep               Run current line and stop again."));
ldbLog(sdsnew("[n]ext               Alias for step."));
ldbLog(sdsnew("[c]continue          Run till next breakpoint."));
ldbLog(sdsnew("[l]list              List source code around current line."));
ldbLog(sdsnew("[l]list [line]       List source code around [line]."));
ldbLog(sdsnew("                     line = 0 means: current position."));
ldbLog(sdsnew("[l]list [line] [ctx] In this form [ctx] specifies how many lines"));
ldbLog(sdsnew("                     to show before/after [line]."));
ldbLog(sdsnew("[w]hole              List all source code. Alias for 'list 1 1000000'."));
ldbLog(sdsnew("[p]rint              Show all the local variables."));
ldbLog(sdsnew("[p]rint <var>        Show the value of the specified variable."));
ldbLog(sdsnew("                     Can also show global vars KEYS and ARGV."));
ldbLog(sdsnew("[b]reak              Show all breakpoints."));
ldbLog(sdsnew("[b]reak <line>       Add a breakpoint to the specified line."));
ldbLog(sdsnew("[b]reak -<line>      Remove breakpoint from the specified line."));
ldbLog(sdsnew("[b]reak 0            Remove all breakpoints."));
ldbLog(sdsnew("[t]race              Show a backtrace."));
ldbLog(sdsnew("[e]eval <code>       Execute some Lua code (in a different callframe)."));
ldbLog(sdsnew("[r]edis <cmd>        Execute a Redis command."));
ldbLog(sdsnew("[m]axlen [len]       Trim logged Redis replies and Lua var dumps to len."));
ldbLog(sdsnew("                     Specifying zero as <len> means unlimited."));
ldbLog(sdsnew("[a]bort              Stop the execution of the script. In sync"));
ldbLog(sdsnew("                     mode dataset changes will be retained."));
ldbLog(sdsnew(""));
ldbLog(sdsnew("Debugger functions you can call from Lua scripts:"));
ldbLog(sdsnew("redis.debug()        Produce logs in the debugger console."));
ldbLog(sdsnew("redis.breakpoint()   Stop execution like if there was a breakpoing."));
ldbLog(sdsnew("                     in the next line of code."));
            ldbSendLogs();
        } else if (!strcasecmp(argv[0],"s") || !strcasecmp(argv[0],"step") ||
                   !strcasecmp(argv[0],"n") || !strcasecmp(argv[0],"next")) {
            ldb.step = 1;
            break;
        } else if (!strcasecmp(argv[0],"c") || !strcasecmp(argv[0],"continue")){
            break;
        } else if (!strcasecmp(argv[0],"t") || !strcasecmp(argv[0],"trace")) {
            ldbTrace(lua);
            ldbSendLogs();
        } else if (!strcasecmp(argv[0],"m") || !strcasecmp(argv[0],"maxlen")) {
            ldbMaxlen(argv,argc);
            ldbSendLogs();
        } else if (!strcasecmp(argv[0],"b") || !strcasecmp(argv[0],"break")) {
            ldbBreak(argv,argc);
            ldbSendLogs();
        } else if (!strcasecmp(argv[0],"e") || !strcasecmp(argv[0],"eval")) {
            ldbEval(lua,argv,argc);
            ldbSendLogs();
        } else if (!strcasecmp(argv[0],"a") || !strcasecmp(argv[0],"abort")) {
            lua_pushstring(lua, "script aborted for user request");
            lua_error(lua);
        } else if (argc > 1 &&
                   (!strcasecmp(argv[0],"r") || !strcasecmp(argv[0],"redis"))) {
            ldbRedis(lua,argv,argc);
            ldbSendLogs();
        } else if ((!strcasecmp(argv[0],"p") || !strcasecmp(argv[0],"print"))) {
            if (argc == 2)
                ldbPrint(lua,argv[1]);
            else
                ldbPrintAll(lua);
            ldbSendLogs();
        } else if (!strcasecmp(argv[0],"l") || !strcasecmp(argv[0],"list")){
            int around = ldb.currentline, ctx = 5;
            if (argc > 1) {
                int num = atoi(argv[1]);
                if (num > 0) around = num;
            }
            if (argc > 2) ctx = atoi(argv[2]);
            ldbList(around,ctx);
            ldbSendLogs();
        } else if (!strcasecmp(argv[0],"w") || !strcasecmp(argv[0],"whole")){
            ldbList(1,1000000);
            ldbSendLogs();
        } else {
            ldbLog(sdsnew("<error> Unknown Redis Lua debugger command or "
                          "wrong number of arguments."));
            ldbSendLogs();
        }

        /* Free the command vector. */
        sdsfreesplitres(argv,argc);
    }

    /* Free the current command argv if we break inside the while loop. */
    sdsfreesplitres(argv,argc);
    return C_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x430, %rsp            # imm = 0x430
movq %rdi, -0x10(%rbp)
jmp 0x8d981
leaq -0x1c(%rbp), %rdi
callq 0x8c560
movq %rax, -0x18(%rbp)
cmpq $0x0, %rax
jne 0x8d9fd
movl 0xff1f6(%rip), %edi     # 0x18cb90
leaq -0x420(%rbp), %rsi
movl $0x400, %edx            # imm = 0x400
callq 0x26340
movl %eax, -0x424(%rbp)
cmpl $0x0, -0x424(%rbp)
jg 0x8d9da
movl $0x0, 0xff2f8(%rip)     # 0x18ccbc
movl $0x0, 0xff2ea(%rip)     # 0x18ccb8
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x8e0a2
movq 0xff2f7(%rip), %rdi     # 0x18ccd8
leaq -0x420(%rbp), %rsi
movslq -0x424(%rbp), %rdx
callq 0x39040
movq %rax, 0xff2dd(%rip)     # 0x18ccd8
jmp 0x8d981
movq 0xff2d4(%rip), %rdi     # 0x18ccd8
callq 0x38620
callq 0x384f0
movq %rax, 0xff2c3(%rip)     # 0x18ccd8
movq -0x18(%rbp), %rax
movq (%rax), %rdi
leaq 0xac6c0(%rip), %rsi     # 0x13a0e3
callq 0x26300
cmpl $0x0, %eax
je 0x8da49
movq -0x18(%rbp), %rax
movq (%rax), %rdi
leaq 0xac6a2(%rip), %rsi     # 0x13a0dd
callq 0x26300
cmpl $0x0, %eax
jne 0x8dcab
leaq 0xb6e94(%rip), %rdi     # 0x1448e4
callq 0x38510
movq %rax, %rdi
callq 0x88530
leaq 0xb6e99(%rip), %rdi     # 0x1448fd
callq 0x38510
movq %rax, %rdi
callq 0x88530
leaq 0xb6eaa(%rip), %rdi     # 0x144922
callq 0x38510
movq %rax, %rdi
callq 0x88530
leaq 0xb6ecc(%rip), %rdi     # 0x144958
callq 0x38510
movq %rax, %rdi
callq 0x88530
leaq 0xb6edd(%rip), %rdi     # 0x14497d
callq 0x38510
movq %rax, %rdi
callq 0x88530
leaq 0xb6ef8(%rip), %rdi     # 0x1449ac
callq 0x38510
movq %rax, %rdi
callq 0x88530
leaq 0xb6f1f(%rip), %rdi     # 0x1449e7
callq 0x38510
movq %rax, %rdi
callq 0x88530
leaq 0xb6f40(%rip), %rdi     # 0x144a1c
callq 0x38510
movq %rax, %rdi
callq 0x88530
leaq 0xb6f63(%rip), %rdi     # 0x144a53
callq 0x38510
movq %rax, %rdi
callq 0x88530
leaq 0xb6f90(%rip), %rdi     # 0x144a94
callq 0x38510
movq %rax, %rdi
callq 0x88530
leaq 0xb6fae(%rip), %rdi     # 0x144ac6
callq 0x38510
movq %rax, %rdi
callq 0x88530
leaq 0xb6fe1(%rip), %rdi     # 0x144b0d
callq 0x38510
movq %rax, %rdi
callq 0x88530
leaq 0xb7000(%rip), %rdi     # 0x144b40
callq 0x38510
movq %rax, %rdi
callq 0x88530
leaq 0xb702b(%rip), %rdi     # 0x144b7f
callq 0x38510
movq %rax, %rdi
callq 0x88530
leaq 0xb7055(%rip), %rdi     # 0x144bbd
callq 0x38510
movq %rax, %rdi
callq 0x88530
leaq 0xb706c(%rip), %rdi     # 0x144be8
callq 0x38510
movq %rax, %rdi
callq 0x88530
leaq 0xb7095(%rip), %rdi     # 0x144c25
callq 0x38510
movq %rax, %rdi
callq 0x88530
leaq 0xb70c1(%rip), %rdi     # 0x144c65
callq 0x38510
movq %rax, %rdi
callq 0x88530
leaq 0xb70da(%rip), %rdi     # 0x144c92
callq 0x38510
movq %rax, %rdi
callq 0x88530
leaq 0xb70ed(%rip), %rdi     # 0x144cb9
callq 0x38510
movq %rax, %rdi
callq 0x88530
leaq 0xb7120(%rip), %rdi     # 0x144d00
callq 0x38510
movq %rax, %rdi
callq 0x88530
leaq 0xb713a(%rip), %rdi     # 0x144d2e
callq 0x38510
movq %rax, %rdi
callq 0x88530
leaq 0xb716f(%rip), %rdi     # 0x144d77
callq 0x38510
movq %rax, %rdi
callq 0x88530
leaq 0xb719a(%rip), %rdi     # 0x144db6
callq 0x38510
movq %rax, %rdi
callq 0x88530
leaq 0xb71c5(%rip), %rdi     # 0x144df5
callq 0x38510
movq %rax, %rdi
callq 0x88530
leaq 0xad9ce(%rip), %rdi     # 0x13b612
callq 0x38510
movq %rax, %rdi
callq 0x88530
leaq 0xb71d9(%rip), %rdi     # 0x144e31
callq 0x38510
movq %rax, %rdi
callq 0x88530
leaq 0xb71f7(%rip), %rdi     # 0x144e63
callq 0x38510
movq %rax, %rdi
callq 0x88530
leaq 0xb721e(%rip), %rdi     # 0x144e9e
callq 0x38510
movq %rax, %rdi
callq 0x88530
leaq 0xb724e(%rip), %rdi     # 0x144ee2
callq 0x38510
movq %rax, %rdi
callq 0x88530
callq 0x8be40
jmp 0x8e07e
movq -0x18(%rbp), %rax
movq (%rax), %rdi
leaq 0xb89ce(%rip), %rsi     # 0x146687
callq 0x26300
cmpl $0x0, %eax
je 0x8dd0b
movq -0x18(%rbp), %rax
movq (%rax), %rdi
leaq 0xb7240(%rip), %rsi     # 0x144f11
callq 0x26300
cmpl $0x0, %eax
je 0x8dd0b
movq -0x18(%rbp), %rax
movq (%rax), %rdi
leaq 0xb6b7e(%rip), %rsi     # 0x144867
callq 0x26300
cmpl $0x0, %eax
je 0x8dd0b
movq -0x18(%rbp), %rax
movq (%rax), %rdi
leaq 0xb7215(%rip), %rsi     # 0x144f16
callq 0x26300
cmpl $0x0, %eax
jne 0x8dd1a
movl $0x1, 0xfefa7(%rip)     # 0x18ccbc
jmp 0x8e08f
movq -0x18(%rbp), %rax
movq (%rax), %rdi
leaq 0xaca9b(%rip), %rsi     # 0x13a7c3
callq 0x26300
cmpl $0x0, %eax
je 0x8dd4a
movq -0x18(%rbp), %rax
movq (%rax), %rdi
leaq 0xb31d8(%rip), %rsi     # 0x140f18
callq 0x26300
cmpl $0x0, %eax
jne 0x8dd4f
jmp 0x8e08f
movq -0x18(%rbp), %rax
movq (%rax), %rdi
leaq 0xaca6f(%rip), %rsi     # 0x13a7cc
callq 0x26300
cmpl $0x0, %eax
je 0x8dd7f
movq -0x18(%rbp), %rax
movq (%rax), %rdi
leaq 0xbff18(%rip), %rsi     # 0x14dc8d
callq 0x26300
cmpl $0x0, %eax
jne 0x8dd92
movq -0x10(%rbp), %rdi
callq 0x8d790
callq 0x8be40
jmp 0x8e078
movq -0x18(%rbp), %rax
movq (%rax), %rdi
leaq 0xbb284(%rip), %rsi     # 0x149024
callq 0x26300
cmpl $0x0, %eax
je 0x8ddc2
movq -0x18(%rbp), %rax
movq (%rax), %rdi
leaq 0xb7163(%rip), %rsi     # 0x144f1b
callq 0x26300
cmpl $0x0, %eax
jne 0x8ddd8
movq -0x18(%rbp), %rdi
movl -0x1c(%rbp), %esi
callq 0x8d8c0
callq 0x8be40
jmp 0x8e076
movq -0x18(%rbp), %rax
movq (%rax), %rdi
leaq 0xbd9c5(%rip), %rsi     # 0x14b7ab
callq 0x26300
cmpl $0x0, %eax
je 0x8de08
movq -0x18(%rbp), %rax
movq (%rax), %rdi
leaq 0xbc97e(%rip), %rsi     # 0x14a77c
callq 0x26300
cmpl $0x0, %eax
jne 0x8de1e
movq -0x18(%rbp), %rdi
movl -0x1c(%rbp), %esi
callq 0x8d2d0
callq 0x8be40
jmp 0x8e074
movq -0x18(%rbp), %rax
movq (%rax), %rdi
leaq 0xbd989(%rip), %rsi     # 0x14b7b5
callq 0x26300
cmpl $0x0, %eax
je 0x8de4e
movq -0x18(%rbp), %rax
movq (%rax), %rdi
leaq 0xb675a(%rip), %rsi     # 0x14459e
callq 0x26300
cmpl $0x0, %eax
jne 0x8de68
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movl -0x1c(%rbp), %edx
callq 0x8d4c0
callq 0x8be40
jmp 0x8e072
movq -0x18(%rbp), %rax
movq (%rax), %rdi
leaq 0xbd993(%rip), %rsi     # 0x14b809
callq 0x26300
cmpl $0x0, %eax
je 0x8de98
movq -0x18(%rbp), %rax
movq (%rax), %rdi
leaq 0xbfc8b(%rip), %rsi     # 0x14db19
callq 0x26300
cmpl $0x0, %eax
jne 0x8deb6
movq -0x10(%rbp), %rdi
leaq 0xb707f(%rip), %rsi     # 0x144f22
callq 0xad410
movq -0x10(%rbp), %rdi
callq 0xae670
jmp 0x8e070
cmpl $0x1, -0x1c(%rbp)
jle 0x8df06
movq -0x18(%rbp), %rax
movq (%rax), %rdi
leaq 0xac8ff(%rip), %rsi     # 0x13a7c9
callq 0x26300
cmpl $0x0, %eax
je 0x8deec
movq -0x18(%rbp), %rax
movq (%rax), %rdi
leaq 0xaa156(%rip), %rsi     # 0x138038
callq 0x26300
cmpl $0x0, %eax
jne 0x8df06
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movl -0x1c(%rbp), %edx
callq 0x8d680
callq 0x8be40
jmp 0x8e06e
movq -0x18(%rbp), %rax
movq (%rax), %rdi
leaq 0xb3f42(%rip), %rsi     # 0x141e56
callq 0x26300
cmpl $0x0, %eax
je 0x8df36
movq -0x18(%rbp), %rax
movq (%rax), %rdi
leaq 0xbfcc6(%rip), %rsi     # 0x14dbf2
callq 0x26300
cmpl $0x0, %eax
jne 0x8df62
cmpl $0x2, -0x1c(%rbp)
jne 0x8df4f
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rsi
callq 0x8d060
jmp 0x8df58
movq -0x10(%rbp), %rdi
callq 0x8d1b0
callq 0x8be40
jmp 0x8e06c
movq -0x18(%rbp), %rax
movq (%rax), %rdi
leaq 0xb58fd(%rip), %rsi     # 0x14386d
callq 0x26300
cmpl $0x0, %eax
je 0x8df92
movq -0x18(%rbp), %rax
movq (%rax), %rdi
leaq 0xad880(%rip), %rsi     # 0x13b808
callq 0x26300
cmpl $0x0, %eax
jne 0x8e009
movl 0xfed3c(%rip), %eax     # 0x18ccd4
movl %eax, -0x428(%rbp)
movl $0x5, -0x42c(%rbp)
cmpl $0x1, -0x1c(%rbp)
jle 0x8dfd8
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x26760
movl %eax, -0x430(%rbp)
cmpl $0x0, -0x430(%rbp)
jle 0x8dfd6
movl -0x430(%rbp), %eax
movl %eax, -0x428(%rbp)
jmp 0x8dfd8
cmpl $0x2, -0x1c(%rbp)
jle 0x8dff1
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x26760
movl %eax, -0x42c(%rbp)
movl -0x428(%rbp), %edi
movl -0x42c(%rbp), %esi
callq 0x8c830
callq 0x8be40
jmp 0x8e06a
movq -0x18(%rbp), %rax
movq (%rax), %rdi
leaq 0xad7ea(%rip), %rsi     # 0x13b801
callq 0x26300
cmpl $0x0, %eax
je 0x8e039
movq -0x18(%rbp), %rax
movq (%rax), %rdi
leaq 0xb6f13(%rip), %rsi     # 0x144f42
callq 0x26300
cmpl $0x0, %eax
jne 0x8e04f
movl $0x1, %edi
movl $0xf4240, %esi          # imm = 0xF4240
callq 0x8c830
callq 0x8be40
jmp 0x8e068
leaq 0xb6ef2(%rip), %rdi     # 0x144f48
callq 0x38510
movq %rax, %rdi
callq 0x88530
callq 0x8be40
jmp 0x8e06a
jmp 0x8e06c
jmp 0x8e06e
jmp 0x8e070
jmp 0x8e072
jmp 0x8e074
jmp 0x8e076
jmp 0x8e078
jmp 0x8e07a
jmp 0x8e07c
jmp 0x8e07e
movq -0x18(%rbp), %rdi
movl -0x1c(%rbp), %esi
callq 0x3a270
jmp 0x8d97f
movq -0x18(%rbp), %rdi
movl -0x1c(%rbp), %esi
callq 0x3a270
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x430, %rsp            # imm = 0x430
popq %rbp
retq
nop