// File: /workspace/github_c_makefile_star2_O0/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 %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x28(%rbp)
movq $0x0, -0x30(%rbp)
movq -0x28(%rbp), %rax
cmpq $0x0, 0x38(%rax)
jge 0xfe49
callq 0xfdc0
movq %rax, %rcx
movq -0x28(%rbp), %rax
subq 0x30(%rax), %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x38(%rax)
movq -0x28(%rbp), %rax
movq (%rax), %rdi
callq 0x13340
cmpl $0x0, %eax
je 0xfe87
movq 0x93197(%rip), %rax     # 0xa2ff8
movq (%rax), %rdi
movq -0x28(%rbp), %rax
movq (%rax), %rdx
addq $0x4, %rdx
leaq 0x7f194(%rip), %rsi     # 0x8f00a
movb $0x0, %al
callq 0xb2e0
movl $0x1, %edi
callq 0xb4f0
jmp 0xfe89
movq -0x28(%rbp), %rax
cmpl $0x0, 0x40(%rax)
je 0x10076
movq -0x28(%rbp), %rax
movq (%rax), %rdi
leaq -0x30(%rbp), %rsi
callq 0x13650
cmpl $0x0, %eax
je 0xfed9
movq 0x93145(%rip), %rax     # 0xa2ff8
movq (%rax), %rdi
movq -0x28(%rbp), %rax
movq (%rax), %rdx
addq $0x4, %rdx
leaq 0x7f142(%rip), %rsi     # 0x8f00a
movb $0x0, %al
callq 0xb2e0
movl $0x1, %edi
callq 0xb4f0
cmpq $0x0, -0x30(%rbp)
je 0x1006f
movl $0x6, %eax
cmpq %rax, -0x30(%rbp)
jne 0xff11
movq 0x93102(%rip), %rax     # 0xa2ff8
movq (%rax), %rdi
leaq 0x7f115(%rip), %rsi     # 0x8f015
movb $0x0, %al
callq 0xb2e0
movl $0x1, %edi
callq 0xb4f0
cmpl $0x0, 0x9354c(%rip)     # 0xa3464
je 0xff68
xorl %eax, %eax
movl %eax, %edi
callq 0xb320
movq %rax, -0x38(%rbp)
movq -0x30(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
cmpl $0x6, (%rax)
jne 0xff66
movq 0x93581(%rip), %rax     # 0xa34c0
cmpq -0x38(%rbp), %rax
je 0xff66
movq -0x38(%rbp), %rax
movq %rax, 0x93570(%rip)     # 0xa34c0
movq -0x40(%rbp), %rax
movq 0x18(%rax), %rsi
leaq 0x7f0da(%rip), %rdi     # 0x8f039
movb $0x0, %al
callq 0xb1a0
jmp 0xff68
movq -0x30(%rbp), %rdi
callq 0x11530
movq -0x28(%rbp), %rax
cmpl $0x0, 0x44(%rax)
jle 0x10016
movq -0x28(%rbp), %rax
movl 0x44(%rax), %ecx
addl $-0x1, %ecx
movl %ecx, 0x44(%rax)
movq -0x28(%rbp), %rax
movl 0x40(%rax), %ecx
addl $-0x1, %ecx
movl %ecx, 0x40(%rax)
movq -0x28(%rbp), %rax
cmpl $0x0, 0x48(%rax)
jle 0x10011
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x28(%rbp), %rax
movl 0x48(%rax), %esi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x168b0
movq $0x0, -0x48(%rbp)
movq -0x48(%rbp), %rax
movq -0x28(%rbp), %rcx
cmpq 0x18(%rcx), %rax
jae 0x10006
movq -0x28(%rbp), %rax
movl 0x48(%rax), %esi
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x48(%rbp), %rcx
movq (%rax,%rcx,8), %rdx
movslq %esi, %rdi
xorl %esi, %esi
subq %rdi, %rsi
addq %rsi, %rdx
movq %rdx, (%rax,%rcx,8)
movq -0x48(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x48(%rbp)
jmp 0xffc4
movq -0x28(%rbp), %rax
movl $0x0, 0x48(%rax)
jmp 0xfe89
movl 0x9342c(%rip), %eax     # 0xa3448
cmpl 0x9341e(%rip), %eax     # 0xa3440
jge 0x1004b
movq -0x28(%rbp), %rax
movq 0x38(%rax), %rdx
movq 0x93445(%rip), %rax     # 0xa3478
movl 0x9340f(%rip), %ecx     # 0xa3448
movl %ecx, %esi
addl $0x1, %esi
movl %esi, 0x93404(%rip)     # 0xa3448
movslq %ecx, %rcx
movq %rdx, (%rax,%rcx,8)
movq -0x28(%rbp), %rax
movl 0x40(%rax), %ecx
addl $-0x1, %ecx
movl %ecx, 0x40(%rax)
movq -0x28(%rbp), %rax
cmpl $0x0, 0x40(%rax)
jne 0x1006d
movq -0x28(%rbp), %rdi
callq 0x10080
jmp 0x10076
jmp 0x10071
jmp 0x10076
jmp 0xfe89
jmp 0x10078
addq $0x50, %rsp
popq %rbp
retq
nop