// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/redis-cli.c
// Function: cliReadReply
static int cliReadReply(int output_raw_strings) {
    void *_reply;
    redisReply *reply;
    sds out = NULL;
    int output = 1;

    if (redisGetReply(context,&_reply) != REDIS_OK) {
        if (config.shutdown)
            return REDIS_OK;
        if (config.interactive) {
            /* Filter cases where we should reconnect */
            if (context->err == REDIS_ERR_IO && errno == ECONNRESET)
                return REDIS_ERR;
            if (context->err == REDIS_ERR_EOF)
                return REDIS_ERR;
        }
        cliPrintContextError();
        exit(1);
        return REDIS_ERR; /* avoid compiler warning */
    }

    reply = (redisReply*)_reply;

    /* Check if we need to connect to a different node and reissue the
     * request. */
    if (config.cluster_mode && reply->type == REDIS_REPLY_ERROR &&
        (!strncmp(reply->str,"MOVED",5) || !strcmp(reply->str,"ASK")))
    {
        char *p = reply->str, *s;
        int slot;

        output = 0;
        /* Comments show the position of the pointer as:
         *
         * [S] for pointer 's'
         * [P] for pointer 'p'
         */
        s = strchr(p,' ');      /* MOVED[S]3999 127.0.0.1:6381 */
        p = strchr(s+1,' ');    /* MOVED[S]3999[P]127.0.0.1:6381 */
        *p = '\0';
        slot = atoi(s+1);
        s = strchr(p+1,':');    /* MOVED 3999[P]127.0.0.1[S]6381 */
        *s = '\0';
        sdsfree(config.hostip);
        config.hostip = sdsnew(p+1);
        config.hostport = atoi(s+1);
        if (config.interactive)
            printf("-> Redirected to slot [%d] located at %s:%d\n",
                slot, config.hostip, config.hostport);
        config.cluster_reissue_command = 1;
        cliRefreshPrompt();
    }

    if (output) {
        if (output_raw_strings) {
            out = cliFormatReplyRaw(reply);
        } else {
            if (config.output == OUTPUT_RAW) {
                out = cliFormatReplyRaw(reply);
                out = sdscat(out,"\n");
            } else if (config.output == OUTPUT_STANDARD) {
                out = cliFormatReplyTTY(reply,"");
            } else if (config.output == OUTPUT_CSV) {
                out = cliFormatReplyCSV(reply);
                out = sdscat(out,"\n");
            }
        }
        fwrite(out,sdslen(out),1,stdout);
        sdsfree(out);
    }
    freeReplyObject(reply);
    return REDIS_OK;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %edi, %ebp
movq 0x31162(%rip), %rdi     # 0x43e70
movq %rsp, %rsi
callq 0x15d7c
testl %eax, %eax
je 0x12d74
xorl %ebx, %ebx
cmpl $0x0, 0x31045(%rip)     # 0x43d68
jne 0x12ee4
cmpl $0x0, 0x31034(%rip)     # 0x43d64
je 0x12d65
movq 0x31137(%rip), %rax     # 0x43e70
movl (%rax), %ebp
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
cmpl $0x3, %ebp
je 0x12ee4
cmpl $0x1, %ebp
jne 0x12d65
callq 0xd0a0
cmpl $0x3, %ebp
je 0x12ee4
cmpl $0x68, (%rax)
je 0x12ee4
callq 0x133c1
movl $0x1, %edi
callq 0xd5d0
movq (%rsp), %rbx
cmpl $0x0, 0x30ffd(%rip)     # 0x43d7c
je 0x12db5
cmpl $0x6, (%rbx)
jne 0x12db5
movq 0x18(%rbx), %r14
leaq 0x20b4f(%rip), %rsi     # 0x338e0
movl $0x5, %edx
movq %r14, %rdi
callq 0xd0c0
testl %eax, %eax
je 0x12dea
leaq 0x20b3d(%rip), %rsi     # 0x338e6
movq %r14, %rdi
callq 0xd330
testl %eax, %eax
je 0x12dea
testl %ebp, %ebp
je 0x12dc6
movq %rbx, %rdi
callq 0x12fc9
jmp 0x12eb4
movl 0x30ffc(%rip), %eax     # 0x43dc8
testl %eax, %eax
je 0x12e8f
movq %rbx, %rdi
cmpl $0x2, %eax
jne 0x12ea0
callq 0x13287
jmp 0x12ea5
movq %r14, %rdi
movl $0x20, %esi
callq 0xd1c0
leaq 0x1(%rax), %r14
movq %r14, %rdi
movl $0x20, %esi
callq 0xd1c0
movq %rax, %r15
xorl %r13d, %r13d
movb %r13b, (%rax)
movq %r14, %rdi
callq 0xd590
movl %eax, %ebp
incq %r15
movq %r15, %rdi
movl $0x3a, %esi
callq 0xd1c0
movq %rax, %r12
movb %r13b, (%rax)
movq 0x30f00(%rip), %rdi     # 0x43d38
callq 0xed74
movq %r15, %rdi
callq 0xed4a
movq %rax, %r14
movq %rax, 0x30ee9(%rip)     # 0x43d38
incq %r12
movq %r12, %rdi
callq 0xd590
movl %eax, 0x30ee0(%rip)     # 0x43d40
cmpl $0x0, 0x30efd(%rip)     # 0x43d64
je 0x12e7e
leaq 0x20a7a(%rip), %rdi     # 0x338ea
movl %ebp, %esi
movq %r14, %rdx
movl %eax, %ecx
xorl %eax, %eax
callq 0xd1d0
movl $0x1, 0x30ef8(%rip)     # 0x43d80
callq 0x12ef5
jmp 0x12eda
leaq 0x20e06(%rip), %rsi     # 0x33c9c
movq %rbx, %rdi
callq 0x130c2
jmp 0x12eb4
callq 0x12fc9
leaq 0x20def(%rip), %rsi     # 0x33c9b
movq %rax, %rdi
callq 0xef47
movq %rax, %r14
movslq -0x8(%rax), %rsi
movq 0x2f0de(%rip), %rax     # 0x41fa0
movq (%rax), %rcx
movl $0x1, %edx
movq %r14, %rdi
callq 0xd5f0
movq %r14, %rdi
callq 0xed74
movq %rbx, %rdi
callq 0x14824
xorl %ebx, %ebx
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq