// File: /workspace/github_c_makefile_star2_O0/erikdubbelboer[P]discnt/src/discnt-cli.c
// Function: repl
static void repl(void) {
    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/.discnt_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;
                    }

                    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();
                    }

                    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, 0x83daf(%rip)     # 0x96be0
movl $0x1, %edi
callq 0x1ab30
leaq 0xabe(%rip), %rdi       # 0x13900
callq 0x1ab80
movq 0x8317a(%rip), %rax     # 0x95fc8
movq (%rax), %rdi
callq 0xc380
movl %eax, %edi
callq 0xc0d0
cmpl $0x0, %eax
je 0x12eb4
movl $0x1, -0xc(%rbp)
leaq 0x70eeb(%rip), %rdi     # 0x83d5b
callq 0xc040
cmpq $0x0, %rax
je 0x12eb2
callq 0xe410
movq %rax, -0x48(%rbp)
leaq 0x70ed0(%rip), %rdi     # 0x83d5b
callq 0xc040
movq -0x48(%rbp), %rdi
movq %rax, %rdx
leaq 0x70ec2(%rip), %rsi     # 0x83d60
movb $0x0, %al
callq 0xf4d0
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rdi
callq 0x1bb00
jmp 0x12eb4
callq 0x13a60
movq 0x83e08(%rip), %rcx     # 0x96cc8
leaq 0x70eac(%rip), %rdi     # 0x83d73
leaq 0x83cea(%rip), %rax     # 0x96bb8
addq $0x70, %rax
cmpq $0x0, %rcx
cmovneq %rax, %rdi
callq 0x1b500
movq %rax, -0x18(%rbp)
cmpq $0x0, %rax
je 0x13109
movq -0x18(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
je 0x130fb
movq -0x18(%rbp), %rdi
leaq -0x1c(%rbp), %rsi
callq 0x10510
movq %rax, -0x28(%rbp)
cmpl $0x0, -0xc(%rbp)
je 0x12f1d
movq -0x18(%rbp), %rdi
callq 0x1b800
cmpq $0x0, -0x8(%rbp)
je 0x12f2d
movq -0x8(%rbp), %rdi
callq 0x1ba70
cmpq $0x0, -0x28(%rbp)
jne 0x12f50
leaq 0x70e48(%rip), %rdi     # 0x83d83
movb $0x0, %al
callq 0xc1c0
movq -0x18(%rbp), %rdi
callq 0xc050
jmp 0x12eb9
cmpl $0x0, -0x1c(%rbp)
jle 0x130ed
movq -0x28(%rbp), %rax
movq (%rax), %rdi
leaq 0x70e30(%rip), %rsi     # 0x83d98
callq 0xc060
cmpl $0x0, %eax
je 0x12f8a
movq -0x28(%rbp), %rax
movq (%rax), %rdi
leaq 0x70e1d(%rip), %rsi     # 0x83d9d
callq 0xc060
cmpl $0x0, %eax
jne 0x12f91
xorl %edi, %edi
callq 0xc590
cmpl $0x3, -0x1c(%rbp)
jne 0x12ff6
movq -0x28(%rbp), %rax
movq (%rax), %rdi
leaq 0x70dfd(%rip), %rsi     # 0x83da2
callq 0xc060
cmpl $0x0, %eax
jne 0x12ff6
movq 0x83c02(%rip), %rdi     # 0x96bb8
callq 0xe540
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0xe430
movq %rax, 0x83be9(%rip)     # 0x96bb8
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0xc550
movl %eax, 0x83bde(%rip)     # 0x96bc0
callq 0x13a60
movl $0x1, %edi
callq 0x120b0
jmp 0x130e9
cmpl $0x1, -0x1c(%rbp)
jne 0x1301e
movq -0x28(%rbp), %rax
movq (%rax), %rdi
leaq 0x70da0(%rip), %rsi     # 0x83daa
callq 0xc060
cmpl $0x0, %eax
jne 0x1301e
callq 0x1ab50
jmp 0x130e7
callq 0x135e0
movq %rax, -0x30(%rbp)
movl $0x0, -0x40(%rbp)
movq -0x28(%rbp), %rax
movq (%rax), %rdi
callq 0xc550
movl %eax, -0x3c(%rbp)
cmpl $0x1, -0x1c(%rbp)
jle 0x13052
cmpl $0x0, -0x3c(%rbp)
je 0x13052
movl $0x1, -0x40(%rbp)
jmp 0x13059
movl $0x1, -0x3c(%rbp)
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 0x13b20
cmpl $0x0, %eax
je 0x130ae
movl $0x1, %edi
callq 0x120b0
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 0x13b20
cmpl $0x0, %eax
je 0x130ac
callq 0x13e80
jmp 0x130ae
callq 0x135e0
subq -0x30(%rbp), %rax
movq %rax, -0x38(%rbp)
cmpq $0x1f4, -0x38(%rbp)     # imm = 0x1F4
jl 0x130e5
cvtsi2sdq -0x38(%rbp), %xmm0
movsd 0x6f47d(%rip), %xmm1    # 0x82550
divsd %xmm1, %xmm0
leaq 0x70cd2(%rip), %rdi     # 0x83db0
movb $0x1, %al
callq 0xc1c0
jmp 0x130e7
jmp 0x130e9
jmp 0x130eb
jmp 0x130ed
jmp 0x130ef
movq -0x28(%rbp), %rdi
movl -0x1c(%rbp), %esi
callq 0x10190
movq -0x18(%rbp), %rdi
callq 0xc050
jmp 0x12eb9
xorl %edi, %edi
callq 0xc590