// File: /workspace/github_c_makefile_star2_O3/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 0xc463
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 0xf6a7
testl %eax, %eax
jne 0xc5fe
cmpl $0x0, 0x40(%rbx)
je 0xc5f1
movq (%rbx), %rdi
movq %rsp, %rsi
callq 0xf8c3
testl %eax, %eax
jne 0xc53d
movq %rsp, %r14
movq (%rsp), %rdi
testq %rdi, %rdi
je 0xc5f1
cmpq $0x6, %rdi
je 0xc5f9
callq 0xe3fc
movl 0x44(%rbx), %esi
testl %esi, %esi
je 0xc4fb
decl 0x40(%rbx)
movq 0x8(%rbx), %rdi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0xd154
movq 0x18(%rbx), %rax
testq %rax, %rax
je 0xc4e9
movslq 0x44(%rbx), %rcx
negq %rcx
xorl %edx, %edx
movq 0x10(%rbx), %rsi
addq %rcx, (%rsi,%rdx,8)
incq %rdx
cmpq %rdx, %rax
jne 0xc4d9
movl $0x0, 0x44(%rbx)
cmpl $0x0, 0x40(%rbx)
jne 0xc52a
jmp 0xc5f1
movl 0x29ef7(%rip), %eax     # 0x363f8
movl 0x29ee9(%rip), %ecx     # 0x363f0
cmpl %ecx, %eax
jge 0xc525
movslq %eax, %rdx
movq 0x38(%rbx), %rsi
movq 0x29f0f(%rip), %rdi     # 0x36428
incl %eax
movl %eax, 0x29ed7(%rip)     # 0x363f8
movq %rsi, (%rdi,%rdx,8)
decl 0x40(%rbx)
je 0xc545
movq (%rbx), %rdi
movq %r14, %rsi
callq 0xf8c3
testl %eax, %eax
je 0xc493
movq %rbx, %rdi
callq 0x9708
cmpl %ecx, %eax
jne 0xc562
movq %rbx, %rdi
callq 0xc385
movq 0x29e70(%rip), %rdi     # 0x363c8
callq 0x9c26
jmp 0xc5f1
cmpl $0x0, 0x29ea3(%rip)     # 0x3640c
je 0xc5d5
movq 0x29e56(%rip), %rdi     # 0x363c8
movq (%rbx), %rax
movl 0x84(%rax), %esi
movl $0x2, %edx
callq 0x9cf4
movq 0x29e3c(%rip), %rdi     # 0x363c8
movq (%rbx), %rax
movl 0x84(%rax), %esi
movl $0x1, %edx
callq 0x9cf4
movq 0x29e22(%rip), %rdi     # 0x363c8
movq (%rbx), %rax
movl 0x84(%rax), %esi
leaq -0x3a7(%rip), %rcx      # 0xc20f
movl $0x2, %edx
movq %rbx, %r8
callq 0x9c2e
movl $0x0, 0x28(%rbx)
movl 0x29e40(%rip), %eax     # 0x36410
movl %eax, 0x40(%rbx)
jmp 0xc5f1
decl 0x29e11(%rip)           # 0x363ec
movq %rbx, %rdi
callq 0xbf0f
incl 0x29e03(%rip)           # 0x363ec
movq %rbx, %rdi
callq 0xc385
addq $0x18, %rsp
popq %rbx
popq %r14
retq
callq 0x96e3
movq %rbx, %rdi
callq 0x96b8