// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/src/redis-benchmark.c
// Function: readHandler
static void readHandler(aeEventLoop *el, int fd, void *privdata, int mask) {
    client c = privdata;
    void *reply = NULL;
    REDIS_NOTUSED(el);
    REDIS_NOTUSED(fd);
    REDIS_NOTUSED(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);
                }

                freeReplyObject(reply);

                if (c->selectlen) {
                    int j;

                    /* This is the OK from SELECT. Just discard the SELECT
                     * from the buffer. */
                    c->pending--;
                    sdsrange(c->obuf,c->selectlen,-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->selectlen;
                    c->selectlen = 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 $0x40, %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 0xd949
callq 0xd8c0
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 0x12b50
cmpl $0x0, %eax
je 0xd987
movq 0x4368f(%rip), %rax     # 0x50ff0
movq (%rax), %rdi
movq -0x28(%rbp), %rax
movq (%rax), %rdx
addq $0x4, %rdx
leaq 0x3450f(%rip), %rsi     # 0x41e85
movb $0x0, %al
callq 0x92e0
movl $0x1, %edi
callq 0x9500
jmp 0xd989
movq -0x28(%rbp), %rax
cmpl $0x0, 0x40(%rax)
je 0xdb00
movq -0x28(%rbp), %rax
movq (%rax), %rdi
leaq -0x30(%rbp), %rsi
callq 0x12e50
cmpl $0x0, %eax
je 0xd9d9
movq 0x4363d(%rip), %rax     # 0x50ff0
movq (%rax), %rdi
movq -0x28(%rbp), %rax
movq (%rax), %rdx
addq $0x4, %rdx
leaq 0x344bd(%rip), %rsi     # 0x41e85
movb $0x0, %al
callq 0x92e0
movl $0x1, %edi
callq 0x9500
cmpq $0x0, -0x30(%rbp)
je 0xdaf9
movl $0x6, %eax
cmpq %rax, -0x30(%rbp)
jne 0xda11
movq 0x435fa(%rip), %rax     # 0x50ff0
movq (%rax), %rdi
leaq 0x34490(%rip), %rsi     # 0x41e90
movb $0x0, %al
callq 0x92e0
movl $0x1, %edi
callq 0x9500
movq -0x30(%rbp), %rdi
callq 0x11090
movq -0x28(%rbp), %rax
cmpl $0x0, 0x44(%rax)
je 0xdaa0
movq -0x28(%rbp), %rax
movl 0x40(%rax), %ecx
addl $-0x1, %ecx
movl %ecx, 0x40(%rax)
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x28(%rbp), %rax
movl 0x44(%rax), %esi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0xf1d0
movl $0x0, -0x34(%rbp)
movslq -0x34(%rbp), %rax
movq -0x28(%rbp), %rcx
cmpq 0x18(%rcx), %rax
jae 0xda90
movq -0x28(%rbp), %rax
movl 0x44(%rax), %esi
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x34(%rbp), %rcx
movq (%rax,%rcx,8), %rdx
movslq %esi, %rdi
xorl %esi, %esi
subq %rdi, %rsi
addq %rsi, %rdx
movq %rdx, (%rax,%rcx,8)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0xda51
movq -0x28(%rbp), %rax
movl $0x0, 0x44(%rax)
jmp 0xd989
movl 0x43942(%rip), %eax     # 0x513e8
cmpl 0x43934(%rip), %eax     # 0x513e0
jge 0xdad5
movq -0x28(%rbp), %rax
movq 0x38(%rax), %rdx
movq 0x4395b(%rip), %rax     # 0x51418
movl 0x43925(%rip), %ecx     # 0x513e8
movl %ecx, %esi
addl $0x1, %esi
movl %esi, 0x4391a(%rip)     # 0x513e8
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 0xdaf7
movq -0x28(%rbp), %rdi
callq 0xdb10
jmp 0xdb00
jmp 0xdafb
jmp 0xdb00
jmp 0xd989
jmp 0xdb02
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax,%rax)