// File: /workspace/github_c_makefile_star2_O3/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 0x1552f
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 0x17488
testl %eax, %eax
jne 0x1571e
cmpl $0x0, 0x40(%rbx)
je 0x15655
leaq 0x8(%rsp), %r14
leaq 0x2415f(%rip), %r15     # 0x396b4
movq (%rbx), %rdi
movq %r14, %rsi
callq 0x1779f
testl %eax, %eax
jne 0x15711
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x15655
cmpq $0x6, %rdi
je 0x15719
cmpl $0x0, 0x36efd(%rip)     # 0x4c484
je 0x155bd
xorl %edi, %edi
callq 0xb350
movq 0x8(%rsp), %rdi
cmpl $0x6, (%rdi)
jne 0x155bd
cmpq %rax, 0x36f3f(%rip)     # 0x4c4e0
je 0x155bd
movq %rax, 0x36f36(%rip)     # 0x4c4e0
movq 0x18(%rdi), %rsi
movq %r15, %rdi
xorl %eax, %eax
callq 0xb1c0
movq 0x8(%rsp), %rdi
callq 0x15f10
movl 0x44(%rbx), %eax
testl %eax, %eax
jle 0x15619
decl %eax
movl %eax, 0x44(%rbx)
movl 0x40(%rbx), %edx
movl 0x48(%rbx), %esi
decl %edx
movl %edx, 0x40(%rbx)
testl %esi, %esi
jle 0x1564d
movq 0x8(%rbx), %rdi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x196af
movq 0x18(%rbx), %rax
testq %rax, %rax
je 0x1560d
movslq 0x48(%rbx), %rcx
negq %rcx
xorl %edx, %edx
movq 0x10(%rbx), %rsi
addq %rcx, (%rsi,%rdx,8)
incq %rdx
cmpq %rdx, %rax
jne 0x155fd
movl $0x0, 0x48(%rbx)
movl 0x40(%rbx), %edx
jmp 0x1564d
movl 0x36e49(%rip), %eax     # 0x4c468
movl 0x36e3b(%rip), %ecx     # 0x4c460
cmpl %ecx, %eax
jge 0x15643
movslq %eax, %rdx
movq 0x38(%rbx), %rsi
movq 0x36e61(%rip), %rdi     # 0x4c498
incl %eax
movl %eax, 0x36e29(%rip)     # 0x4c468
movq %rsi, (%rdi,%rdx,8)
movl 0x40(%rbx), %edx
decl %edx
movl %edx, 0x40(%rbx)
je 0x1565f
testl %edx, %edx
jne 0x15555
addq $0x20, %rsp
popq %rbx
popq %r14
popq %r15
retq
cmpl %ecx, %eax
jne 0x15679
movq %rbx, %rdi
callq 0x1544e
movq 0x36dc6(%rip), %rdi     # 0x4c438
callq 0x12756
jmp 0x15655
cmpl $0x0, 0x36dfc(%rip)     # 0x4c47c
je 0x156f0
movq 0x36daf(%rip), %rdi     # 0x4c438
movq (%rbx), %rax
movl 0x84(%rax), %esi
movl $0x2, %edx
callq 0x12826
movq 0x36d95(%rip), %rdi     # 0x4c438
movq (%rbx), %rax
movl 0x84(%rax), %esi
movl $0x1, %edx
callq 0x12826
movq 0x36d7b(%rip), %rdi     # 0x4c438
movq (%rbx), %rax
movl 0x84(%rax), %esi
leaq -0x4a4(%rip), %rcx      # 0x15229
movl $0x2, %edx
movq %rbx, %r8
callq 0x1275e
movq $0x0, 0x28(%rbx)
movl 0x36d98(%rip), %eax     # 0x4c480
movl %eax, 0x40(%rbx)
jmp 0x15655
decl 0x36d66(%rip)           # 0x4c45c
movq %rbx, %rdi
callq 0x14f29
incl 0x36d58(%rip)           # 0x4c45c
movq %rbx, %rdi
callq 0x1544e
jmp 0x15655
movq %rbx, %rdi
callq 0xb708
callq 0xb733
movq %rbx, %rdi
callq 0xb6dd