// File: /workspace/github_c_makefile_star2_O1/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 %r14
pushq %rbx
subq $0x18, %rsp
movq %rdx, %rbx
movq $0x0, (%rsp)
cmpq $0x0, 0x38(%rdx)
jns 0xc296
leaq 0x8(%rsp), %r14
movq %r14, %rdi
xorl %esi, %esi
callq 0x91f0
imulq $0xf4240, (%r14), %rax  # imm = 0xF4240
addq 0x8(%r14), %rax
subq 0x30(%rbx), %rax
movq %rax, 0x38(%rbx)
movq (%rbx), %rdi
callq 0xf578
testl %eax, %eax
jne 0xc427
cmpl $0x0, 0x40(%rbx)
je 0xc35d
movq %rsp, %r14
movq (%rbx), %rdi
movq %r14, %rsi
callq 0xf794
testl %eax, %eax
jne 0xc41a
movq (%rsp), %rdi
testq %rdi, %rdi
je 0xc35d
cmpq $0x6, %rdi
je 0xc422
callq 0xe23c
movl 0x44(%rbx), %esi
testl %esi, %esi
je 0xc325
decl 0x40(%rbx)
movq 0x8(%rbx), %rdi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0xcf1d
movq 0x18(%rbx), %rax
testq %rax, %rax
je 0xc31c
movslq 0x44(%rbx), %rcx
negq %rcx
xorl %edx, %edx
movq 0x10(%rbx), %rsi
addq %rcx, (%rsi,%rdx,8)
incq %rdx
cmpq %rdx, %rax
jne 0xc30c
movl $0x0, 0x44(%rbx)
jmp 0xc353
movslq 0x290cc(%rip), %rcx     # 0x353f8
movl 0x290be(%rip), %eax     # 0x353f0
cmpl %eax, %ecx
jge 0xc34e
movq 0x38(%rbx), %rdx
movq 0x290e7(%rip), %rsi     # 0x35428
leal 0x1(%rcx), %edi
movl %edi, 0x290ae(%rip)     # 0x353f8
movq %rdx, (%rsi,%rcx,8)
decl 0x40(%rbx)
je 0xc365
cmpl $0x0, 0x40(%rbx)
jne 0xc2b3
addq $0x18, %rsp
popq %rbx
popq %r14
retq
cmpl %eax, 0x2908d(%rip)     # 0x353f8
jne 0xc383
movq %rbx, %rdi
callq 0xc1b8
movq 0x2904c(%rip), %rdi     # 0x353c8
callq 0x9a3b
jmp 0xc35d
cmpl $0x0, 0x29082(%rip)     # 0x3540c
je 0xc3f9
movq 0x29035(%rip), %rdi     # 0x353c8
movq (%rbx), %rax
movl 0x84(%rax), %esi
movl $0x2, %edx
callq 0x9b09
movq 0x2901b(%rip), %rdi     # 0x353c8
movq (%rbx), %rax
movl 0x84(%rax), %esi
movl $0x1, %edx
callq 0x9b09
movq 0x29001(%rip), %rdi     # 0x353c8
movq (%rbx), %rax
movl 0x84(%rax), %esi
leaq -0x392(%rip), %rcx      # 0xc045
movl $0x2, %edx
movq %rbx, %r8
callq 0x9a43
movl $0x0, 0x28(%rbx)
movl 0x2901f(%rip), %eax     # 0x35410
movl %eax, 0x40(%rbx)
jmp 0xc35d
decl 0x28fed(%rip)           # 0x353ec
movq %rbx, %rdi
callq 0xbd47
incl 0x28fdf(%rip)           # 0x353ec
movq %rbx, %rdi
callq 0xc1b8
jmp 0xc35d
movq %rbx, %rdi
callq 0x96e3
callq 0x970e
movq %rbx, %rdi
callq 0x96b8