// File: /workspace/github_c_makefile_star2_O1/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, %ebp
movq (%rsi), %r12
leaq 0x1f6df(%rip), %rsi     # 0x32c9d
movq %r12, %rdi
callq 0xd080
testl %eax, %eax
je 0x13667
leaq 0x20b16(%rip), %rsi     # 0x340eb
movq %r12, %rdi
callq 0xd080
testl %eax, %eax
je 0x13667
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
cmpq $0x0, 0x3087d(%rip)     # 0x43e70
je 0x13973
leaq 0x20aed(%rip), %rsi     # 0x340ed
movq %r12, %rdi
callq 0xd080
testl %eax, %eax
je 0x137d6
xorl %r13d, %r13d
cmpl $0x2, %ebp
jne 0x137dc
leaq 0x20acf(%rip), %rsi     # 0x340f2
movq %r12, %rdi
callq 0xd080
testl %eax, %eax
je 0x137a8
leaq 0x1cff1(%rip), %rsi     # 0x3062b
movq %r12, %rdi
callq 0xd080
testl %eax, %eax
jne 0x137dc
movq 0x8(%rbx), %rdi
leaq 0x1db2d(%rip), %rsi     # 0x31182
callq 0xd080
testl %eax, %eax
jne 0x137dc
jmp 0x137d6
movl %ebp, %r12d
decl %r12d
je 0x136b5
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
cmpl $0x2, %ebp
jl 0x136e1
movq 0x8(%rbx), %r14
cmpb $0x40, (%r14)
jne 0x136e1
incq %r14
leaq 0x2d0d2(%rip), %r15     # 0x40760
xorl %r13d, %r13d
movq (%r15), %rsi
movq %r14, %rdi
callq 0xd080
testl %eax, %eax
je 0x136de
incq %r13
addq $0x8, %r15
cmpq $0xc, %r13
jne 0x13691
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
jmp 0x136e1
callq 0x12c62
movq %rax, %rbx
leaq 0x20a8f(%rip), %rdi     # 0x34153
xorl %r14d, %r14d
movq %rax, %rsi
xorl %eax, %eax
callq 0xd1d0
movq %rbx, %rdi
callq 0xed74
jmp 0x13973
movl %r13d, %r15d
cmpl $0x2, %ebp
jl 0x139c7
cmpb $0x1, 0x3076f(%rip)     # 0x43e60
jne 0x13797
movl %r12d, %r13d
xorl %ebp, %ebp
movl %r12d, 0x8(%rsp)
movl %r15d, 0x14(%rsp)
movq 0x3075b(%rip), %rax     # 0x43e68
movq %rbp, %rcx
shlq $0x5, %rcx
cmpl $0x1, (%rax,%rcx)
jne 0x1377e
addq %rcx, %rax
movq 0x18(%rax), %r14
cmpl $-0x1, %r15d
je 0x13731
xorl %esi, %esi
cmpl 0x18(%r14), %r15d
je 0x13776
jmp 0x1377e
cmpl %r12d, 0x4(%rax)
jne 0x1377e
movq 0x8(%rax), %r12
xorl %r15d, %r15d
movq 0x8(%rbx,%r15,8), %rdi
movq (%r12,%r15,8), %rsi
callq 0xd080
testl %eax, %eax
jne 0x13762
incq %r15
cmpq %r15, %r13
jne 0x1373e
movl 0x8(%rsp), %r12d
movl %r12d, %r15d
jmp 0x13767
movl 0x8(%rsp), %r12d
movl $0x1, %esi
cmpl %r12d, %r15d
movl 0x14(%rsp), %r15d
jne 0x1377e
movq %r14, %rdi
callq 0x139e6
cmpq $0xaa, %rbp
ja 0x13797
incq %rbp
testb $0x1, 0x306cf(%rip)     # 0x43e60
jne 0x13706
leaq 0x20862(%rip), %rdi     # 0x34000
callq 0xd0d0
jmp 0x13970
movq 0x8(%rbx), %r14
leaq 0x20947(%rip), %rsi     # 0x340fa
movq %r14, %rdi
callq 0xd080
testl %eax, %eax
je 0x137d6
leaq 0x20927(%rip), %rsi     # 0x340ed
movq %r14, %rdi
callq 0xd080
testl %eax, %eax
jne 0x13633
movl $0x1, %r13d
leaq 0x2091d(%rip), %rsi     # 0x34100
movq %r12, %rdi
callq 0xd080
testl %eax, %eax
jne 0x137f9
movl $0x1, 0x3056f(%rip)     # 0x43d68
leaq 0x20909(%rip), %rsi     # 0x34109
movq %r12, %rdi
callq 0xd080
testl %eax, %eax
jne 0x13816
movl $0x1, 0x30556(%rip)     # 0x43d6c
leaq 0x208f5(%rip), %rsi     # 0x34112
movq %r12, %rdi
callq 0xd080
testl %eax, %eax
je 0x1383c
leaq 0x208e1(%rip), %rsi     # 0x34111
movq %r12, %rdi
callq 0xd080
testl %eax, %eax
jne 0x13846
movl $0x1, 0x3052a(%rip)     # 0x43d70
leaq 0x208d0(%rip), %rsi     # 0x3411d
movq %r12, %rdi
callq 0xd080
testl %eax, %eax
je 0x1386c
leaq 0x208bc(%rip), %rsi     # 0x3411c
movq %r12, %rdi
callq 0xd080
testl %eax, %eax
jne 0x13876
movl $0x1, 0x3050e(%rip)     # 0x43d84
movq %r12, 0x8(%rsp)
movslq %ebp, %rdi
shlq $0x3, %rdi
callq 0xd3e0
movq %rax, %r14
testl %ebp, %ebp
jle 0x138a6
movl %ebp, %eax
xorl %ecx, %ecx
movq (%rbx,%rcx,8), %rdx
movslq -0x8(%rdx), %rdx
movq %rdx, (%r14,%rcx,8)
incq %rcx
cmpq %rcx, %rax
jne 0x13892
testl %r15d, %r15d
je 0x13968
movq 0x2e6ea(%rip), %r12     # 0x41fa0
movq 0x305b3(%rip), %rdi     # 0x43e70
movl %ebp, %esi
movq %rbx, %rdx
movq %r14, %rcx
callq 0x15f9c
cmpl $0x0, 0x3049b(%rip)     # 0x43d6c
je 0x138ee
movl %r13d, %edi
callq 0x12cfa
testl %eax, %eax
jne 0x139bd
movq (%r12), %rdi
callq 0xd400
jmp 0x138ca
cmpl $0x0, 0x3047b(%rip)     # 0x43d70
jne 0x1399c
cmpl $0x0, 0x30482(%rip)     # 0x43d84
jne 0x13995
movl %r13d, %edi
callq 0x12cfa
testl %eax, %eax
jne 0x13985
movq 0x8(%rsp), %rdi
leaq 0x20802(%rip), %rsi     # 0x34122
callq 0xd080
cmpl $0x2, %ebp
jne 0x13942
testl %eax, %eax
jne 0x13942
movq 0x8(%rbx), %rdi
callq 0xd590
movl %eax, 0x30423(%rip)     # 0x43d60
callq 0x12ef5
movq 0x3040f(%rip), %rdi     # 0x43d58
testq %rdi, %rdi
je 0x13953
callq 0xd6c0
decl %r15d
movq (%r12), %rdi
callq 0xd400
testl %r15d, %r15d
jne 0x138b6
movq %r14, %rdi
callq 0xd060
xorl %r14d, %r14d
movl %r14d, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r14, %rdi
callq 0xd060
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
jmp 0x13973
callq 0xde30
jmp 0x1398d
cmpl $0x1, 0x30425(%rip)     # 0x43dc8
je 0x139b1
leaq 0x20b1c(%rip), %rdi     # 0x344c8
callq 0xd0d0
movl %r13d, %edi
callq 0x12cfa
testl %eax, %eax
je 0x139b1
movl $0x1, %edi
callq 0xd5d0
leaq 0x2075b(%rip), %rdi     # 0x34129
leaq 0x203ca(%rip), %rsi     # 0x33d9f
leaq 0x20756(%rip), %rcx     # 0x34132
movl $0xf4, %edx
callq 0xd220