// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x30, %rsp
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rdi
leaq 0x37ba9(%rip), %rsi     # 0x4dd51
callq 0xd060
cmpl $0x0, %eax
je 0x161c7
movq -0x20(%rbp), %rdi
leaq 0x391bc(%rip), %rsi     # 0x4f379
callq 0xd060
cmpl $0x0, %eax
jne 0x161ed
movl -0x8(%rbp), %edi
addl $-0x1, %edi
movl %edi, -0x8(%rbp)
movq -0x10(%rbp), %rsi
addq $0x8, %rsi
movq %rsi, -0x10(%rbp)
callq 0x16500
movl $0x0, -0x4(%rbp)
jmp 0x164f7
cmpq $0x0, 0x4acfb(%rip)     # 0x60ef0
jne 0x16203
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x164f7
movl $0x0, -0x30(%rbp)
movq -0x20(%rbp), %rdi
leaq 0x39166(%rip), %rsi     # 0x4f37b
callq 0xd060
cmpl $0x0, %eax
je 0x162a4
cmpl $0x2, -0x8(%rbp)
jne 0x16270
movq -0x20(%rbp), %rdi
leaq 0x3914c(%rip), %rsi     # 0x4f380
callq 0xd060
cmpl $0x0, %eax
jne 0x16270
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
leaq 0x3913b(%rip), %rsi     # 0x4f388
callq 0xd060
cmpl $0x0, %eax
je 0x162a4
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
leaq 0x39115(%rip), %rsi     # 0x4f37b
callq 0xd060
cmpl $0x0, %eax
je 0x162a4
cmpl $0x2, -0x8(%rbp)
jne 0x162ab
movq -0x20(%rbp), %rdi
leaq 0x3545e(%rip), %rsi     # 0x4b6df
callq 0xd060
cmpl $0x0, %eax
jne 0x162ab
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
leaq 0x35f9c(%rip), %rsi     # 0x4c236
callq 0xd060
cmpl $0x0, %eax
jne 0x162ab
movl $0x1, -0x30(%rbp)
movq -0x20(%rbp), %rdi
leaq 0x390d8(%rip), %rsi     # 0x4f38e
callq 0xd060
cmpl $0x0, %eax
jne 0x162ca
movl $0x1, 0x4ab1e(%rip)     # 0x60de8
movq -0x20(%rbp), %rdi
leaq 0x390c2(%rip), %rsi     # 0x4f397
callq 0xd060
cmpl $0x0, %eax
jne 0x162e9
movl $0x1, 0x4ab03(%rip)     # 0x60dec
movq -0x20(%rbp), %rdi
leaq 0x390ac(%rip), %rsi     # 0x4f3a0
callq 0xd060
cmpl $0x0, %eax
je 0x16313
movq -0x20(%rbp), %rdi
leaq 0x39096(%rip), %rsi     # 0x4f39f
callq 0xd060
cmpl $0x0, %eax
jne 0x1631d
movl $0x1, 0x4aad3(%rip)     # 0x60df0
movq -0x20(%rbp), %rdi
leaq 0x39083(%rip), %rsi     # 0x4f3ab
callq 0xd060
cmpl $0x0, %eax
je 0x16347
movq -0x20(%rbp), %rdi
leaq 0x3906d(%rip), %rsi     # 0x4f3aa
callq 0xd060
cmpl $0x0, %eax
jne 0x16351
movl $0x1, 0x4aab3(%rip)     # 0x60e04
movslq -0x8(%rbp), %rdi
shlq $0x3, %rdi
callq 0xd3d0
movq %rax, -0x28(%rbp)
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
cmpl -0x8(%rbp), %eax
jge 0x1639c
movq -0x10(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x118e0
movq %rax, %rdx
movq -0x28(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x16369
jmp 0x1639e
movl -0x14(%rbp), %eax
movl %eax, %ecx
addl $-0x1, %ecx
movl %ecx, -0x14(%rbp)
cmpl $0x0, %eax
je 0x164e7
movq 0x4ab37(%rip), %rdi     # 0x60ef0
movl -0x8(%rbp), %esi
movq -0x10(%rbp), %rdx
movq -0x28(%rbp), %rcx
callq 0x1a340
cmpl $0x0, 0x4aa1c(%rip)     # 0x60dec
je 0x163fa
movl -0x30(%rbp), %edi
callq 0x14540
cmpl $0x0, %eax
je 0x163e9
movl $0x1, %edi
callq 0xd5c0
movq 0x48bc0(%rip), %rax     # 0x5efb0
movq (%rax), %rdi
callq 0xd3f0
jmp 0x163c9
cmpl $0x0, 0x4a9ef(%rip)     # 0x60df0
je 0x16435
cmpl $0x1, 0x4aa3e(%rip)     # 0x60e48
je 0x1641a
leaq 0x38f9d(%rip), %rdi     # 0x4f3b0
movb $0x0, %al
callq 0xd1c0
jmp 0x1641c
movl -0x30(%rbp), %edi
callq 0x14540
cmpl $0x0, %eax
je 0x16433
movl $0x1, %edi
callq 0xd5c0
jmp 0x1641c
cmpl $0x0, 0x4a9c8(%rip)     # 0x60e04
je 0x16467
leaq 0x38f97(%rip), %rdi     # 0x4f3dc
movb $0x0, %al
callq 0xd1c0
callq 0x12ae0
movl $0x0, 0x4a9a9(%rip)     # 0x60e04
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x164f7
movl -0x30(%rbp), %edi
callq 0x14540
cmpl $0x0, %eax
je 0x16486
movq -0x28(%rbp), %rdi
callq 0xd050
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x164f7
movq -0x20(%rbp), %rdi
leaq 0x38f82(%rip), %rsi     # 0x4f413
callq 0xd060
cmpl $0x0, %eax
jne 0x164b9
cmpl $0x2, -0x8(%rbp)
jne 0x164b9
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0xd580
movl %eax, 0x4a92c(%rip)     # 0x60de0
callq 0x14800
jmp 0x164bb
cmpq $0x0, 0x4a915(%rip)     # 0x60dd8
je 0x164d3
movq 0x4a90c(%rip), %rax     # 0x60dd8
movl %eax, %edi
callq 0xd6a0
movq 0x48ad6(%rip), %rax     # 0x5efb0
movq (%rax), %rdi
callq 0xd3f0
jmp 0x1639e
movq -0x28(%rbp), %rdi
callq 0xd050
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq