// File: /workspace/github_c_makefile_star2_O1/zhou-yuxin[P]redis-aof-no-cow/src/redis-benchmark.c
// Function: readHandler
static void readHandler(aeEventLoop *el, int fd, void *privdata, int mask) {
    client c = privdata;
    void *reply = NULL;
    UNUSED(el);
    UNUSED(fd);
    UNUSED(mask);

    /* Calculate latency only for the first read event. This means that the
     * server already sent the reply and we need to parse it. Parsing overhead
     * is not part of the latency, so calculate it only once, here. */
    if (c->latency < 0) c->latency = ustime()-(c->start);

    if (redisBufferRead(c->context) != REDIS_OK) {
        fprintf(stderr,"Error: %s\n",c->context->errstr);
        exit(1);
    } else {
        while(c->pending) {
            if (redisGetReply(c->context,&reply) != REDIS_OK) {
                fprintf(stderr,"Error: %s\n",c->context->errstr);
                exit(1);
            }
            if (reply != NULL) {
                if (reply == (void*)REDIS_REPLY_ERROR) {
                    fprintf(stderr,"Unexpected error reply, exiting...\n");
                    exit(1);
                }

                if (config.showerrors) {
                    static time_t lasterr_time = 0;
                    time_t now = time(NULL);
                    redisReply *r = reply;
                    if (r->type == REDIS_REPLY_ERROR && lasterr_time != now) {
                        lasterr_time = now;
                        printf("Error from server: %s\n", r->str);
                    }
                }

                freeReplyObject(reply);
                /* This is an OK for prefix commands such as auth and select.*/
                if (c->prefix_pending > 0) {
                    c->prefix_pending--;
                    c->pending--;
                    /* Discard prefix commands on first response.*/
                    if (c->prefixlen > 0) {
                        size_t j;
                        sdsrange(c->obuf, c->prefixlen, -1);
                        /* We also need to fix the pointers to the strings
                        * we need to randomize. */
                        for (j = 0; j < c->randlen; j++)
                            c->randptr[j] -= c->prefixlen;
                        c->prefixlen = 0;
                    }
                    continue;
                }

                if (config.requests_finished < config.requests)
                    config.latency[config.requests_finished++] = c->latency;
                c->pending--;
                if (c->pending == 0) {
                    clientDone(c);
                    break;
                }
            } else {
                break;
            }
        }
    }
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x20, %rsp
movq %rdx, %rbx
movq $0x0, 0x8(%rsp)
cmpq $0x0, 0x38(%rdx)
jns 0x15761
leaq 0x10(%rsp), %r14
movq %r14, %rdi
xorl %esi, %esi
callq 0xb200
imulq $0xf4240, (%r14), %rax  # imm = 0xF4240
addq 0x8(%r14), %rax
subq 0x30(%rbx), %rax
movq %rax, 0x38(%rbx)
movq (%rbx), %rdi
callq 0x17738
testl %eax, %eax
jne 0x15948
cmpl $0x0, 0x40(%rbx)
je 0x1587b
leaq 0x8(%rsp), %r14
leaq 0x23efa(%rip), %r15     # 0x39681
movq (%rbx), %rdi
movq %r14, %rsi
callq 0x17a6f
testl %eax, %eax
jne 0x1593b
movq 0x8(%rsp), %rax
testq %rax, %rax
je 0x1587b
cmpq $0x6, %rax
je 0x15943
cmpl $0x0, 0x36ccb(%rip)     # 0x4c484
je 0x157ea
xorl %edi, %edi
callq 0xb350
movq 0x8(%rsp), %rcx
cmpl $0x6, (%rcx)
jne 0x157ea
cmpq %rax, 0x36d0d(%rip)     # 0x4c4e0
je 0x157ea
movq %rax, 0x36d04(%rip)     # 0x4c4e0
movq 0x18(%rcx), %rsi
movq %r15, %rdi
xorl %eax, %eax
callq 0xb1c0
movq 0x8(%rsp), %rdi
callq 0x1616c
movl 0x44(%rbx), %eax
testl %eax, %eax
jle 0x15843
decl %eax
movl %eax, 0x44(%rbx)
decl 0x40(%rbx)
movl 0x48(%rbx), %esi
testl %esi, %esi
jle 0x15871
movq 0x8(%rbx), %rdi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x19982
movq 0x18(%rbx), %rax
testq %rax, %rax
je 0x1583a
movslq 0x48(%rbx), %rcx
negq %rcx
xorl %edx, %edx
movq 0x10(%rbx), %rsi
addq %rcx, (%rsi,%rdx,8)
incq %rdx
cmpq %rdx, %rax
jne 0x1582a
movl $0x0, 0x48(%rbx)
jmp 0x15871
movslq 0x36c1e(%rip), %rcx     # 0x4c468
movl 0x36c10(%rip), %eax     # 0x4c460
cmpl %eax, %ecx
jge 0x1586c
movq 0x38(%rbx), %rdx
movq 0x36c39(%rip), %rsi     # 0x4c498
leal 0x1(%rcx), %edi
movl %edi, 0x36c00(%rip)     # 0x4c468
movq %rdx, (%rsi,%rcx,8)
decl 0x40(%rbx)
je 0x15885
cmpl $0x0, 0x40(%rbx)
jne 0x15787
addq $0x20, %rsp
popq %rbx
popq %r14
popq %r15
retq
cmpl %eax, 0x36bdd(%rip)     # 0x4c468
jne 0x158a3
movq %rbx, %rdi
callq 0x15680
movq 0x36b9c(%rip), %rdi     # 0x4c438
callq 0x1295b
jmp 0x1587b
cmpl $0x0, 0x36bd2(%rip)     # 0x4c47c
je 0x1591a
movq 0x36b85(%rip), %rdi     # 0x4c438
movq (%rbx), %rax
movl 0x84(%rax), %esi
movl $0x2, %edx
callq 0x12a32
movq 0x36b6b(%rip), %rdi     # 0x4c438
movq (%rbx), %rax
movl 0x84(%rax), %esi
movl $0x1, %edx
callq 0x12a32
movq 0x36b51(%rip), %rdi     # 0x4c438
movq (%rbx), %rax
movl 0x84(%rax), %esi
leaq -0x4a5(%rip), %rcx      # 0x15452
movl $0x2, %edx
movq %rbx, %r8
callq 0x12963
movq $0x0, 0x28(%rbx)
movl 0x36b6e(%rip), %eax     # 0x4c480
movl %eax, 0x40(%rbx)
jmp 0x1587b
decl 0x36b3c(%rip)           # 0x4c45c
movq %rbx, %rdi
callq 0x15154
incl 0x36b2e(%rip)           # 0x4c45c
movq %rbx, %rdi
callq 0x15680
jmp 0x1587b
movq %rbx, %rdi
callq 0xb708
callq 0xb733
movq %rbx, %rdi
callq 0xb6dd