// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/src/redis-cli.c
// Function: repl
static void repl() {
    sds historyfile = NULL;
    int history = 0;
    char *line;
    int argc;
    sds *argv;

    config.interactive = 1;
    linenoiseSetMultiLine(1);
    linenoiseSetCompletionCallback(completionCallback);

    /* Only use history when stdin is a tty. */
    if (isatty(fileno(stdin))) {
        history = 1;

        if (getenv("HOME") != NULL) {
            historyfile = sdscatprintf(sdsempty(),"%s/.rediscli_history",getenv("HOME"));
            linenoiseHistoryLoad(historyfile);
        }
    }

    cliRefreshPrompt();
    while((line = linenoise(context ? config.prompt : "not connected> ")) != NULL) {
        if (line[0] != '\0') {
            argv = sdssplitargs(line,&argc);
            if (history) linenoiseHistoryAdd(line);
            if (historyfile) linenoiseHistorySave(historyfile);

            if (argv == NULL) {
                printf("Invalid argument(s)\n");
                free(line);
                continue;
            } else if (argc > 0) {
                if (strcasecmp(argv[0],"quit") == 0 ||
                    strcasecmp(argv[0],"exit") == 0)
                {
                    exit(0);
                } else if (argc == 3 && !strcasecmp(argv[0],"connect")) {
                    sdsfree(config.hostip);
                    config.hostip = sdsnew(argv[1]);
                    config.hostport = atoi(argv[2]);
                    cliRefreshPrompt();
                    cliConnect(1);
                } else if (argc == 1 && !strcasecmp(argv[0],"clear")) {
                    linenoiseClearScreen();
                } else {
                    long long start_time = mstime(), elapsed;
                    int repeat, skipargs = 0;

                    repeat = atoi(argv[0]);
                    if (argc > 1 && repeat) {
                        skipargs = 1;
                    } else {
                        repeat = 1;
                    }

                    while (1) {
                        config.cluster_reissue_command = 0;
                        if (cliSendCommand(argc-skipargs,argv+skipargs,repeat)
                            != REDIS_OK)
                        {
                            cliConnect(1);

                            /* If we still cannot send the command print error.
                             * We'll try to reconnect the next time. */
                            if (cliSendCommand(argc-skipargs,argv+skipargs,repeat)
                                != REDIS_OK)
                                cliPrintContextError();
                        }
                        /* Issue the command again if we got redirected in cluster mode */
                        if (config.cluster_mode && config.cluster_reissue_command) {
                            cliConnect(1);
                        } else {
                            break;
                        }
                    }
                    elapsed = mstime()-start_time;
                    if (elapsed >= 500) {
                        printf("(%.2fs)\n",(double)elapsed/1000);
                    }
                }
            }
            /* Free the argument vector */
            sdsfreesplitres(argv,argc);
        }
        /* linenoise() returns malloc-ed lines like readline() */
        free(line);
    }
    exit(0);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq $0x0, -0x8(%rbp)
movl $0x0, -0xc(%rbp)
movl $0x1, 0x4b0e3(%rip)     # 0x60de4
movl $0x1, %edi
callq 0x1c0e0
leaq 0x30e(%rip), %rdi       # 0x16020
callq 0x1c130
movq 0x4929a(%rip), %rax     # 0x5efb8
movq (%rax), %rdi
callq 0xd390
movl %eax, %edi
callq 0xd0d0
cmpl $0x0, %eax
je 0x15d84
movl $0x1, -0xc(%rbp)
leaq 0x395d3(%rip), %rdi     # 0x4f313
callq 0xd040
cmpq $0x0, %rax
je 0x15d82
callq 0xefd0
movq %rax, -0x48(%rbp)
leaq 0x395b8(%rip), %rdi     # 0x4f313
callq 0xd040
movq -0x48(%rbp), %rdi
movq %rax, %rdx
leaq 0x395aa(%rip), %rsi     # 0x4f318
movb $0x0, %al
callq 0xf9e0
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rdi
callq 0x1d0b0
jmp 0x15d84
callq 0x14800
movq 0x4b160(%rip), %rcx     # 0x60ef0
leaq 0x39596(%rip), %rdi     # 0x4f32d
leaq 0x4b01a(%rip), %rax     # 0x60db8
addq $0xa0, %rax
cmpq $0x0, %rcx
cmovneq %rax, %rdi
callq 0x1cab0
movq %rax, -0x18(%rbp)
cmpq $0x0, %rax
je 0x1600c
movq -0x18(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
je 0x15ffe
movq -0x18(%rbp), %rdi
leaq -0x1c(%rbp), %rsi
callq 0x10a60
movq %rax, -0x28(%rbp)
cmpl $0x0, -0xc(%rbp)
je 0x15def
movq -0x18(%rbp), %rdi
callq 0x1cdb0
cmpq $0x0, -0x8(%rbp)
je 0x15dff
movq -0x8(%rbp), %rdi
callq 0x1d020
cmpq $0x0, -0x28(%rbp)
jne 0x15e22
leaq 0x39530(%rip), %rdi     # 0x4f33d
movb $0x0, %al
callq 0xd1c0
movq -0x18(%rbp), %rdi
callq 0xd050
jmp 0x15d89
cmpl $0x0, -0x1c(%rbp)
jle 0x15ff0
movq -0x28(%rbp), %rax
movq (%rax), %rdi
leaq 0x39518(%rip), %rsi     # 0x4f352
callq 0xd060
cmpl $0x0, %eax
je 0x15e5c
movq -0x28(%rbp), %rax
movq (%rax), %rdi
leaq 0x39505(%rip), %rsi     # 0x4f357
callq 0xd060
cmpl $0x0, %eax
jne 0x15e63
xorl %edi, %edi
callq 0xd5c0
cmpl $0x3, -0x1c(%rbp)
jne 0x15ec8
movq -0x28(%rbp), %rax
movq (%rax), %rdi
leaq 0x394e5(%rip), %rsi     # 0x4f35c
callq 0xd060
cmpl $0x0, %eax
jne 0x15ec8
movq 0x4af30(%rip), %rdi     # 0x60db8
callq 0xf070
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0xeff0
movq %rax, 0x4af17(%rip)     # 0x60db8
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0xd580
movl %eax, 0x4af0c(%rip)     # 0x60dc0
callq 0x14800
movl $0x1, %edi
callq 0x12770
jmp 0x15fec
cmpl $0x1, -0x1c(%rbp)
jne 0x15ef0
movq -0x28(%rbp), %rax
movq (%rax), %rdi
leaq 0x39488(%rip), %rsi     # 0x4f364
callq 0xd060
cmpl $0x0, %eax
jne 0x15ef0
callq 0x1c100
jmp 0x15fea
callq 0x144e0
movq %rax, -0x30(%rbp)
movl $0x0, -0x40(%rbp)
movq -0x28(%rbp), %rax
movq (%rax), %rdi
callq 0xd580
movl %eax, -0x3c(%rbp)
cmpl $0x1, -0x1c(%rbp)
jle 0x15f24
cmpl $0x0, -0x3c(%rbp)
je 0x15f24
movl $0x1, -0x40(%rbp)
jmp 0x15f2b
movl $0x1, -0x3c(%rbp)
jmp 0x15f2d
movl $0x0, 0x4aec9(%rip)     # 0x60e00
movl -0x1c(%rbp), %edi
subl -0x40(%rbp), %edi
movq -0x28(%rbp), %rsi
movslq -0x40(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rsi
movl -0x3c(%rbp), %edx
callq 0x16180
cmpl $0x0, %eax
je 0x15f8c
movl $0x1, %edi
callq 0x12770
movl -0x1c(%rbp), %edi
subl -0x40(%rbp), %edi
movq -0x28(%rbp), %rsi
movslq -0x40(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rsi
movl -0x3c(%rbp), %edx
callq 0x16180
cmpl $0x0, %eax
je 0x15f8a
callq 0x14f40
jmp 0x15f8c
cmpl $0x0, 0x4ae69(%rip)     # 0x60dfc
je 0x15faa
cmpl $0x0, 0x4ae64(%rip)     # 0x60e00
je 0x15faa
movl $0x1, %edi
callq 0x12770
jmp 0x15fac
jmp 0x15fb1
jmp 0x15f2d
callq 0x144e0
subq -0x30(%rbp), %rax
movq %rax, -0x38(%rbp)
cmpq $0x1f4, -0x38(%rbp)     # imm = 0x1F4
jl 0x15fe8
cvtsi2sdq -0x38(%rbp), %xmm0
movsd 0x3533a(%rip), %xmm1    # 0x4b310
divsd %xmm1, %xmm0
leaq 0x39389(%rip), %rdi     # 0x4f36a
movb $0x1, %al
callq 0xd1c0
jmp 0x15fea
jmp 0x15fec
jmp 0x15fee
jmp 0x15ff0
jmp 0x15ff2
movq -0x28(%rbp), %rdi
movl -0x1c(%rbp), %esi
callq 0x106e0
movq -0x18(%rbp), %rdi
callq 0xd050
jmp 0x15d89
xorl %edi, %edi
callq 0xd5c0
nopw %cs:(%rax,%rax)