// File: /workspace/github_c_makefile_star2_O3/nilyang[P]redis-tdd-annotation/src/redis-cli.c
// Function: cliSendCommand
static int cliSendCommand(int argc, char **argv, int repeat) {
    char *command = argv[0];
    size_t *argvlen;
    int j, output_raw;

    if (!strcasecmp(command,"help") || !strcasecmp(command,"?")) {
        cliOutputHelp(--argc, ++argv);
        return REDIS_OK;
    }

    if (context == NULL) return REDIS_ERR;

    output_raw = 0;
    if (!strcasecmp(command,"info") ||
        (argc == 2 && !strcasecmp(command,"cluster") &&
                      (!strcasecmp(argv[1],"nodes") ||
                       !strcasecmp(argv[1],"info"))) ||
        (argc == 2 && !strcasecmp(command,"client") &&
                       !strcasecmp(argv[1],"list")))

    {
        output_raw = 1;
    }

    if (!strcasecmp(command,"shutdown")) config.shutdown = 1;
    if (!strcasecmp(command,"monitor")) config.monitor_mode = 1;
    if (!strcasecmp(command,"subscribe") ||
        !strcasecmp(command,"psubscribe")) config.pubsub_mode = 1;
    if (!strcasecmp(command,"sync") ||
        !strcasecmp(command,"psync")) config.slave_mode = 1;

    /* Setup argument length */
    argvlen = malloc(argc*sizeof(size_t));
    for (j = 0; j < argc; j++)
        argvlen[j] = sdslen(argv[j]);

    while(repeat--) {
        redisAppendCommandArgv(context,argc,(const char**)argv,argvlen);
        while (config.monitor_mode) {
            if (cliReadReply(output_raw) != REDIS_OK) exit(1);
            fflush(stdout);
        }

        if (config.pubsub_mode) {
            if (config.output != OUTPUT_RAW)
                printf("Reading messages... (press Ctrl-C to quit)\n");
            while (1) {
                if (cliReadReply(output_raw) != REDIS_OK) exit(1);
            }
        }

        if (config.slave_mode) {
            printf("Entering slave output mode...  (press Ctrl-C to quit)\n");
            slaveMode();
            config.slave_mode = 0;
            return REDIS_ERR;  /* Error = slaveMode lost connection to master */
        }

        if (cliReadReply(output_raw) != REDIS_OK) {
            free(argvlen);
            return REDIS_ERR;
        } else {
            /* Store database number when SELECT was successfully executed. */
            if (!strcasecmp(command,"select") && argc == 2) {
                config.dbnum = atoi(argv[1]);
                cliRefreshPrompt();
            }
        }
        if (config.interval) usleep(config.interval);
        fflush(stdout); /* Make it grep friendly */
    }

    free(argvlen);
    return REDIS_OK;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %edx, %r15d
movq %rsi, %rbx
movl %edi, %r14d
movq (%rsi), %r12
leaq 0x1f80b(%rip), %rsi     # 0x32cfa
movq %r12, %rdi
callq 0xd080
testl %eax, %eax
je 0x13598
leaq 0x20c24(%rip), %rsi     # 0x3412a
movq %r12, %rdi
callq 0xd080
testl %eax, %eax
je 0x13598
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
cmpq $0x0, 0x3094d(%rip)     # 0x43e70
je 0x13894
leaq 0x20bfc(%rip), %rsi     # 0x3412c
movq %r12, %rdi
callq 0xd080
testl %eax, %eax
je 0x136f3
xorl %r13d, %r13d
cmpl $0x2, %r14d
jne 0x136f9
leaq 0x20bdd(%rip), %rsi     # 0x34131
movq %r12, %rdi
callq 0xd080
testl %eax, %eax
je 0x136c5
leaq 0x1d120(%rip), %rsi     # 0x3068b
movq %r12, %rdi
callq 0xd080
testl %eax, %eax
jne 0x136f9
movq 0x8(%rbx), %rdi
leaq 0x1dc5c(%rip), %rsi     # 0x311e2
callq 0xd080
testl %eax, %eax
jne 0x136f9
jmp 0x136f3
movl %r14d, %eax
decl %eax
movl %eax, 0x14(%rsp)
je 0x135eb
cmpl $0x2, %r14d
jl 0x138e6
movq 0x8(%rbx), %r14
cmpb $0x40, (%r14)
jne 0x135e1
incq %r14
leaq 0x2d19f(%rip), %r13     # 0x40760
xorl %r12d, %r12d
movq (%r13), %rsi
movq %r14, %rdi
callq 0xd080
testl %eax, %eax
je 0x13613
incq %r12
addq $0x8, %r13
cmpq $0xc, %r12
jne 0x135c4
movl $0xffffffff, 0x8(%rsp)  # imm = 0xFFFFFFFF
jmp 0x13618
callq 0x12b83
movq %rax, %rbx
leaq 0x20b98(%rip), %rdi     # 0x34192
xorl %ebp, %ebp
movq %rax, %rsi
xorl %eax, %eax
callq 0xd1d0
movq %rbx, %rdi
callq 0xed21
jmp 0x13894
movl %r12d, 0x8(%rsp)
cmpb $0x1, 0x30841(%rip)     # 0x43e60
jne 0x136b4
movl 0x14(%rsp), %r12d
xorl %r13d, %r13d
movq 0x30834(%rip), %rax     # 0x43e68
movq %r13, %rcx
shlq $0x5, %rcx
cmpl $0x1, (%rax,%rcx)
jne 0x1369b
addq %rcx, %rax
movq 0x18(%rax), %r14
movl 0x8(%rsp), %ecx
cmpl $-0x1, %ecx
je 0x1365e
cmpl 0x18(%r14), %ecx
jne 0x1369b
movq %r14, %rdi
xorl %esi, %esi
jmp 0x13696
movl 0x14(%rsp), %ecx
cmpl %ecx, 0x4(%rax)
jne 0x1369b
movq 0x8(%rax), %r15
xorl %ebp, %ebp
movq 0x8(%rbx,%rbp,8), %rdi
movq (%r15,%rbp,8), %rsi
callq 0xd080
testl %eax, %eax
jne 0x13689
incq %rbp
cmpq %rbp, %r12
jne 0x1366d
jmp 0x1368e
cmpl %ebp, %r12d
jne 0x1369b
movq %r14, %rdi
movl $0x1, %esi
callq 0x13905
cmpq $0xaa, %r13
ja 0x136b4
incq %r13
testb $0x1, 0x307b2(%rip)     # 0x43e60
jne 0x1362d
leaq 0x20984(%rip), %rdi     # 0x3403f
callq 0xd0d0
jmp 0x13892
movq 0x8(%rbx), %rbp
leaq 0x20a69(%rip), %rsi     # 0x34139
movq %rbp, %rdi
callq 0xd080
testl %eax, %eax
je 0x136f3
leaq 0x20a49(%rip), %rsi     # 0x3412c
movq %rbp, %rdi
callq 0xd080
testl %eax, %eax
jne 0x13564
movl $0x1, %r13d
leaq 0x20a3f(%rip), %rsi     # 0x3413f
movq %r12, %rdi
callq 0xd080
testl %eax, %eax
jne 0x13716
movl $0x1, 0x30652(%rip)     # 0x43d68
leaq 0x20a2b(%rip), %rsi     # 0x34148
movq %r12, %rdi
callq 0xd080
testl %eax, %eax
jne 0x13733
movl $0x1, 0x30639(%rip)     # 0x43d6c
leaq 0x20a17(%rip), %rsi     # 0x34151
movq %r12, %rdi
callq 0xd080
testl %eax, %eax
je 0x13759
leaq 0x20a03(%rip), %rsi     # 0x34150
movq %r12, %rdi
callq 0xd080
testl %eax, %eax
jne 0x13763
movl $0x1, 0x3060d(%rip)     # 0x43d70
leaq 0x209f2(%rip), %rsi     # 0x3415c
movq %r12, %rdi
callq 0xd080
testl %eax, %eax
je 0x13789
leaq 0x209de(%rip), %rsi     # 0x3415b
movq %r12, %rdi
callq 0xd080
testl %eax, %eax
jne 0x13793
movl $0x1, 0x305f1(%rip)     # 0x43d84
movq %r12, 0x8(%rsp)
movslq %r14d, %rdi
shlq $0x3, %rdi
callq 0xd3e0
movq %rax, %rbp
testl %r14d, %r14d
jle 0x137c6
movl %r14d, %eax
xorl %ecx, %ecx
movq (%rbx,%rcx,8), %rdx
movslq -0x8(%rdx), %rdx
movq %rdx, (%rbp,%rcx,8)
incq %rcx
cmpq %rcx, %rax
jne 0x137b1
testl %r15d, %r15d
je 0x1388a
movq 0x2e7ca(%rip), %r12     # 0x41fa0
movq 0x30693(%rip), %rdi     # 0x43e70
movl %r14d, %esi
movq %rbx, %rdx
movq %rbp, %rcx
callq 0x16018
cmpl $0x0, 0x3057a(%rip)     # 0x43d6c
je 0x1380f
movl %r13d, %edi
callq 0x12c1b
testl %eax, %eax
jne 0x138dc
movq (%r12), %rdi
callq 0xd400
jmp 0x137eb
cmpl $0x0, 0x3055a(%rip)     # 0x43d70
jne 0x138bb
cmpl $0x0, 0x30561(%rip)     # 0x43d84
jne 0x138b4
movl %r13d, %edi
callq 0x12c1b
testl %eax, %eax
jne 0x138a5
movq 0x8(%rsp), %rdi
leaq 0x20920(%rip), %rsi     # 0x34161
callq 0xd080
cmpl $0x2, %r14d
jne 0x13864
testl %eax, %eax
jne 0x13864
movq 0x8(%rbx), %rdi
callq 0xd590
movl %eax, 0x30501(%rip)     # 0x43d60
callq 0x12e0d
movq 0x304ed(%rip), %rdi     # 0x43d58
testq %rdi, %rdi
je 0x13875
callq 0xd6c0
decl %r15d
movq (%r12), %rdi
callq 0xd400
testl %r15d, %r15d
jne 0x137d6
movq %rbp, %rdi
callq 0xd060
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rbp, %rdi
callq 0xd060
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
jmp 0x13894
callq 0xdde8
jmp 0x138ad
cmpl $0x1, 0x30506(%rip)     # 0x43dc8
je 0x138d0
leaq 0x20c3c(%rip), %rdi     # 0x34507
callq 0xd0d0
movl %r13d, %edi
callq 0x12c1b
testl %eax, %eax
je 0x138d0
movl $0x1, %edi
callq 0xd5d0
leaq 0x2087b(%rip), %rdi     # 0x34168
leaq 0x204ea(%rip), %rsi     # 0x33dde
leaq 0x20876(%rip), %rcx     # 0x34171
movl $0xf4, %edx
callq 0xd220