// File: /workspace/github_c_makefile_star2_O0/gplessis[P]dotdeb-redis/src/redis-cli.c
// Function: evalMode
static int evalMode(int argc, char **argv) {
    sds script = NULL;
    FILE *fp;
    char buf[1024];
    size_t nread;
    char **argv2;
    int j, got_comma, keys;
    int retval = REDIS_OK;

    while(1) {
        if (config.eval_ldb) {
            printf(
            "Lua debugging session started, please use:\n"
            "quit    -- End the session.\n"
            "restart -- Restart the script in debug mode again.\n"
            "help    -- Show Lua script debugging commands.\n\n"
            );
        }

        sdsfree(script);
        script = sdsempty();
        got_comma = 0;
        keys = 0;

        /* Load the script from the file, as an sds string. */
        fp = fopen(config.eval,"r");
        if (!fp) {
            fprintf(stderr,
                "Can't open file '%s': %s\n", config.eval, strerror(errno));
            exit(1);
        }
        while((nread = fread(buf,1,sizeof(buf),fp)) != 0) {
            script = sdscatlen(script,buf,nread);
        }
        fclose(fp);

        /* If we are debugging a script, enable the Lua debugger. */
        if (config.eval_ldb) {
            redisReply *reply = redisCommand(context,
                    config.eval_ldb_sync ?
                    "SCRIPT DEBUG sync": "SCRIPT DEBUG yes");
            if (reply) freeReplyObject(reply);
        }

        /* Create our argument vector */
        argv2 = zmalloc(sizeof(sds)*(argc+3));
        argv2[0] = sdsnew("EVAL");
        argv2[1] = script;
        for (j = 0; j < argc; j++) {
            if (!got_comma && argv[j][0] == ',' && argv[j][1] == 0) {
                got_comma = 1;
                continue;
            }
            argv2[j+3-got_comma] = sdsnew(argv[j]);
            if (!got_comma) keys++;
        }
        argv2[2] = sdscatprintf(sdsempty(),"%d",keys);

        /* Call it */
        int eval_ldb = config.eval_ldb; /* Save it, may be reverteed. */
        retval = issueCommand(argc+3-got_comma, argv2);
        if (eval_ldb) {
            if (!config.eval_ldb) {
                /* If the debugging session ended immediately, there was an
                 * error compiling the script. Show it and don't enter
                 * the REPL at all. */
                printf("Eval debugging session can't start:\n");
                cliReadReply(0);
                break; /* Return to the caller. */
            } else {
                strncpy(config.prompt,"lua debugger> ",sizeof(config.prompt));
                repl();
                /* Restart the session if repl() returned. */
                cliConnect(1);
                printf("\n");
            }
        } else {
            break; /* Return to the caller. */
        }
    }
    return retval;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x460, %rsp            # imm = 0x460
movl %edi, -0x4(%rbp)
movq %rsi, -0x10(%rbp)
movq $0x0, -0x18(%rbp)
movl $0x0, -0x440(%rbp)
cmpl $0x0, 0x8acb5(%rip)     # 0xa15c0
je 0x1691b
leaq 0x763c8(%rip), %rdi     # 0x8ccdc
movb $0x0, %al
callq 0x101d0
movq -0x18(%rbp), %rdi
callq 0x1ee80
callq 0x1ed50
movq %rax, -0x18(%rbp)
movl $0x0, -0x438(%rbp)
movl $0x0, -0x43c(%rbp)
movq 0x8ac70(%rip), %rdi     # 0xa15b8
leaq 0x7458a(%rip), %rsi     # 0x8aed9
callq 0x10390
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0x169b3
movq 0x8868a(%rip), %rax     # 0x9eff0
movq (%rax), %rax
movq %rax, -0x460(%rbp)
movq 0x8ac41(%rip), %rax     # 0xa15b8
movq %rax, -0x458(%rbp)
callq 0x10080
movl (%rax), %edi
callq 0x10660
movq -0x460(%rbp), %rdi
movq -0x458(%rbp), %rdx
movq %rax, %rcx
leaq 0x763e5(%rip), %rsi     # 0x8cd87
movb $0x0, %al
callq 0x10360
movl $0x1, %edi
callq 0x10600
jmp 0x169b5
leaq -0x420(%rbp), %rdi
movq -0x20(%rbp), %rcx
movl $0x1, %esi
movl $0x400, %edx            # imm = 0x400
callq 0x100e0
movq %rax, -0x428(%rbp)
cmpq $0x0, %rax
je 0x169f9
movq -0x18(%rbp), %rdi
leaq -0x420(%rbp), %rsi
movq -0x428(%rbp), %rdx
callq 0x1f8a0
movq %rax, -0x18(%rbp)
jmp 0x169b5
movq -0x20(%rbp), %rdi
callq 0x10190
cmpl $0x0, 0x8abb7(%rip)     # 0xa15c0
je 0x16a53
movq 0x8abc6(%rip), %rdi     # 0xa15d8
movl 0x8abac(%rip), %ecx     # 0xa15c4
leaq 0x76394(%rip), %rsi     # 0x8cdb3
leaq 0x7637b(%rip), %rax     # 0x8cda1
cmpl $0x0, %ecx
cmovneq %rax, %rsi
movb $0x0, %al
callq 0x1d7f0
movq %rax, -0x448(%rbp)
cmpq $0x0, -0x448(%rbp)
je 0x16a51
movq -0x448(%rbp), %rdi
callq 0x1b290
jmp 0x16a53
movl -0x4(%rbp), %eax
addl $0x3, %eax
movslq %eax, %rdi
shlq $0x3, %rdi
callq 0x19760
movq %rax, -0x430(%rbp)
leaq 0x718f8(%rip), %rdi     # 0x8836b
callq 0x1ed70
movq %rax, %rcx
movq -0x430(%rbp), %rax
movq %rcx, (%rax)
movq -0x18(%rbp), %rcx
movq -0x430(%rbp), %rax
movq %rcx, 0x8(%rax)
movl $0x0, -0x434(%rbp)
movl -0x434(%rbp), %eax
cmpl -0x4(%rbp), %eax
jge 0x16b53
cmpl $0x0, -0x438(%rbp)
jne 0x16af1
movq -0x10(%rbp), %rax
movslq -0x434(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbl (%rax), %eax
cmpl $0x2c, %eax
jne 0x16af1
movq -0x10(%rbp), %rax
movslq -0x434(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbl 0x1(%rax), %eax
cmpl $0x0, %eax
jne 0x16af1
movl $0x1, -0x438(%rbp)
jmp 0x16b3f
movq -0x10(%rbp), %rax
movslq -0x434(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x1ed70
movq %rax, %rdx
movq -0x430(%rbp), %rax
movl -0x434(%rbp), %ecx
addl $0x3, %ecx
subl -0x438(%rbp), %ecx
movslq %ecx, %rcx
movq %rdx, (%rax,%rcx,8)
cmpl $0x0, -0x438(%rbp)
jne 0x16b3d
movl -0x43c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x43c(%rbp)
jmp 0x16b3f
movl -0x434(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x434(%rbp)
jmp 0x16a9e
callq 0x1ed50
movq %rax, %rdi
movl -0x43c(%rbp), %edx
leaq 0x7060c(%rip), %rsi     # 0x87174
movb $0x0, %al
callq 0x1fe10
movq %rax, %rcx
movq -0x430(%rbp), %rax
movq %rcx, 0x10(%rax)
movl 0x8aa3d(%rip), %eax     # 0xa15c0
movl %eax, -0x44c(%rbp)
movl -0x4(%rbp), %edi
addl $0x3, %edi
subl -0x438(%rbp), %edi
movq -0x430(%rbp), %rsi
callq 0x19670
movl %eax, -0x440(%rbp)
cmpl $0x0, -0x44c(%rbp)
je 0x16c0e
cmpl $0x0, 0x8aa09(%rip)     # 0xa15c0
jne 0x16bd0
leaq 0x76204(%rip), %rdi     # 0x8cdc4
movb $0x0, %al
callq 0x101d0
xorl %edi, %edi
callq 0x17150
jmp 0x16c15
leaq 0x8a8b1(%rip), %rdi     # 0xa1488
addq $0xb0, %rdi
leaq 0x76204(%rip), %rsi     # 0x8cde9
movl $0x80, %edx
callq 0x10090
callq 0x16530
movl $0x1, %edi
callq 0x14530
leaq 0x75796(%rip), %rdi     # 0x8c39b
movb $0x0, %al
callq 0x101d0
jmp 0x16c10
jmp 0x16c15
jmp 0x16904
movl -0x440(%rbp), %eax
addq $0x460, %rsp            # imm = 0x460
popq %rbp
retq
nopw %cs:(%rax,%rax)