// File: /workspace/github_c_makefile_star2_O2/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
pushq %r14
pushq %rbx
subq $0x10, %rsp
andq $0x0, 0x8(%rsp)
movq %rdx, %rbx
cmpq $0x0, 0x38(%rdx)
jns 0xbebc
callq 0xbe74
subq 0x30(%rbx), %rax
movq %rax, 0x38(%rbx)
movq (%rbx), %rdi
callq 0xeb19
testl %eax, %eax
jne 0xc025
leaq 0x8(%rsp), %r14
pushq $-0x1
popq %rbp
cmpl $0x0, 0x40(%rbx)
je 0xc01c
movq (%rbx), %rdi
movq %r14, %rsi
callq 0xec8a
testl %eax, %eax
jne 0xc025
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0xc01c
cmpq $0x6, %rdi
je 0xc046
callq 0xd920
movl 0x44(%rbx), %esi
testl %esi, %esi
je 0xbf45
decl 0x40(%rbx)
movq 0x8(%rbx), %rdi
movl %ebp, %edx
callq 0xc956
movq 0x18(%rbx), %rax
xorl %ecx, %ecx
cmpq %rcx, %rax
je 0xbf3f
movslq 0x44(%rbx), %rdx
movq 0x10(%rbx), %rsi
subq %rdx, (%rsi,%rcx,8)
incq %rcx
jmp 0xbf29
andl $0x0, 0x44(%rbx)
jmp 0xbed4
movl 0x284ad(%rip), %eax     # 0x343f8
movl 0x2849f(%rip), %ecx     # 0x343f0
cmpl %ecx, %eax
jge 0xbf6f
movslq %eax, %rdx
movq 0x38(%rbx), %rsi
movq 0x284c5(%rip), %rdi     # 0x34428
incl %eax
movl %eax, 0x2848d(%rip)     # 0x343f8
movq %rsi, (%rdi,%rdx,8)
decl 0x40(%rbx)
jne 0xbed4
cmpl %ecx, %eax
jne 0xbf95
movq %rbx, %rdi
callq 0xbdd5
movq 0x2843d(%rip), %rdi     # 0x343c8
callq 0x98f0
jmp 0xc01c
cmpl $0x0, 0x28470(%rip)     # 0x3440c
je 0xc000
movq 0x28423(%rip), %rdi     # 0x343c8
movq (%rbx), %rax
movl 0x84(%rax), %esi
pushq $0x2
popq %rbp
movl %ebp, %edx
callq 0x99b9
movq 0x28409(%rip), %rdi     # 0x343c8
movq (%rbx), %rax
movl 0x84(%rax), %esi
pushq $0x1
popq %rdx
callq 0x99b9
movq 0x283f1(%rip), %rdi     # 0x343c8
movq (%rbx), %rax
movl 0x84(%rax), %esi
leaq -0x372(%rip), %rcx      # 0xbc75
movl %ebp, %edx
movq %rbx, %r8
callq 0x98f8
andl $0x0, 0x28(%rbx)
movl 0x28415(%rip), %eax     # 0x34410
movl %eax, 0x40(%rbx)
jmp 0xc01c
decl 0x283e6(%rip)           # 0x343ec
movq %rbx, %rdi
callq 0xba0f
incl 0x283d8(%rip)           # 0x343ec
movq %rbx, %rdi
callq 0xbdd5
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq
movq 0x27fcc(%rip), %rax     # 0x33ff8
movq (%rax), %rdi
movq (%rbx), %rdx
addq $0x4, %rdx
leaq 0x194bd(%rip), %rsi     # 0x254fa
xorl %eax, %eax
callq 0x9300
jmp 0xc062
movq 0x27fab(%rip), %rax     # 0x33ff8
movq (%rax), %rcx
leaq 0x194ae(%rip), %rdi     # 0x25505
pushq $0x23
popq %rsi
pushq $0x1
popq %rdx
callq 0x9520
pushq $0x1
popq %rdi
callq 0x9500