// File: /workspace/github_c_makefile_star2_O0/erikdubbelboer[P]discnt/src/discnt-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);
                }

                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 $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 0xe909
callq 0xe880
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 0x11e00
cmpl $0x0, %eax
je 0xe947
movq 0x7f6d7(%rip), %rax     # 0x8dff8
movq (%rax), %rdi
movq -0x28(%rbp), %rax
movq (%rax), %rdx
addq $0x4, %rdx
leaq 0x6e3c7(%rip), %rsi     # 0x7ccfd
movb $0x0, %al
callq 0xa2d0
movl $0x1, %edi
callq 0xa4e0
jmp 0xe949
movq -0x28(%rbp), %rax
cmpl $0x0, 0x40(%rax)
je 0xeadf
movq -0x28(%rbp), %rax
movq (%rax), %rdi
leaq -0x30(%rbp), %rsi
callq 0x12110
cmpl $0x0, %eax
je 0xe999
movq 0x7f685(%rip), %rax     # 0x8dff8
movq (%rax), %rdi
movq -0x28(%rbp), %rax
movq (%rax), %rdx
addq $0x4, %rdx
leaq 0x6e375(%rip), %rsi     # 0x7ccfd
movb $0x0, %al
callq 0xa2d0
movl $0x1, %edi
callq 0xa4e0
cmpq $0x0, -0x30(%rbp)
je 0xead8
movl $0x6, %eax
cmpq %rax, -0x30(%rbp)
jne 0xe9d1
movq 0x7f642(%rip), %rax     # 0x8dff8
movq (%rax), %rdi
leaq 0x6e348(%rip), %rsi     # 0x7cd08
movb $0x0, %al
callq 0xa2d0
movl $0x1, %edi
callq 0xa4e0
movq -0x30(%rbp), %rdi
callq 0xfff0
movq -0x28(%rbp), %rax
cmpl $0x0, 0x44(%rax)
jle 0xea7f
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 0xea7a
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x28(%rbp), %rax
movl 0x48(%rax), %esi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x15370
movq $0x0, -0x38(%rbp)
movq -0x38(%rbp), %rax
movq -0x28(%rbp), %rcx
cmpq 0x18(%rcx), %rax
jae 0xea6f
movq -0x28(%rbp), %rax
movl 0x48(%rax), %esi
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x38(%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 -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0xea2d
movq -0x28(%rbp), %rax
movl $0x0, 0x48(%rax)
jmp 0xe949
movl 0x7f983(%rip), %eax     # 0x8e408
cmpl 0x7f975(%rip), %eax     # 0x8e400
jge 0xeab4
movq -0x28(%rbp), %rax
movq 0x38(%rax), %rdx
movq 0x7f99c(%rip), %rax     # 0x8e438
movl 0x7f966(%rip), %ecx     # 0x8e408
movl %ecx, %esi
addl $0x1, %esi
movl %esi, 0x7f95b(%rip)     # 0x8e408
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 0xead6
movq -0x28(%rbp), %rdi
callq 0xeaf0
jmp 0xeadf
jmp 0xeada
jmp 0xeadf
jmp 0xe949
jmp 0xeae1
addq $0x40, %rsp
popq %rbp
retq
nopw (%rax,%rax)