// File: /workspace/github_c_makefile_star2_O3/nilyang[P]redis-tdd-annotation/src/redis-benchmark.c
// Function: writeHandler
static void writeHandler(aeEventLoop *el, int fd, void *privdata, int mask) {
    client c = privdata;
    REDIS_NOTUSED(el);
    REDIS_NOTUSED(fd);
    REDIS_NOTUSED(mask);

    /* Initialize request when nothing was written. */
    if (c->written == 0) {
        /* Enforce upper bound to number of requests. */
        if (config.requests_issued++ >= config.requests) {
            freeClient(c);
            return;
        }

        /* Really initialize: randomize keys and set start time. */
        if (config.randomkeys) randomizeClientKey(c);
        c->start = ustime();
        c->latency = -1;
    }

    if (sdslen(c->obuf) > c->written) {
        void *ptr = c->obuf+c->written;
        int nwritten = write(c->context->fd,ptr,sdslen(c->obuf)-c->written);
        if (nwritten == -1) {
            if (errno != EPIPE)
                fprintf(stderr, "Writing to socket: %s\n", strerror(errno));
            freeClient(c);
            return;
        }
        c->written += nwritten;
        if (sdslen(c->obuf) == c->written) {
            aeDeleteFileEvent(config.el,c->context->fd,AE_WRITABLE);
            aeCreateFileEvent(config.el,c->context->fd,AE_READABLE,readHandler,c);
        }
    }
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdx, %rbx
movl 0x28(%rdx), %eax
testl %eax, %eax
jne 0xc2d5
movl 0x2a1c6(%rip), %eax     # 0x363f4
leal 0x1(%rax), %ecx
movl %ecx, 0x2a1bd(%rip)     # 0x363f4
cmpl 0x2a1b3(%rip), %eax     # 0x363f0
jge 0xc36e
cmpl $0x0, 0x2a1ba(%rip)     # 0x36404
je 0xc2ac
cmpq $0x0, 0x18(%rbx)
je 0xc2ac
xorl %r14d, %r14d
movabsq $-0x3333333333333333, %r15 # imm = 0xCCCCCCCCCCCCCCCD
movq 0x10(%rbx), %rax
movq (%rax,%r14,8), %r12
callq 0x9360
movslq 0x2a194(%rip), %rcx     # 0x36408
cqto
idivq %rcx
movq %rdx, %rcx
movl $0xc, %esi
movq %rcx, %rax
mulq %r15
shrq $0x3, %rdx
leal (%rdx,%rdx), %eax
leal (%rax,%rax,4), %eax
subl %eax, %ecx
orb $0x30, %cl
movb %cl, -0x1(%r12,%rsi)
movq %rdx, %rcx
decq %rsi
jne 0xc281
incq %r14
cmpq 0x18(%rbx), %r14
jb 0xc260
leaq 0x8(%rsp), %r14
movq %r14, %rdi
xorl %esi, %esi
callq 0x91f0
imulq $0xf4240, (%r14), %rax  # imm = 0xF4240
addq 0x8(%r14), %rax
movq %rax, 0x30(%rbx)
movq $-0x1, 0x38(%rbx)
movl 0x28(%rbx), %eax
movq 0x8(%rbx), %rsi
movslq -0x8(%rsi), %rdx
movl %eax, %eax
subq %rax, %rdx
jbe 0xc356
addq %rax, %rsi
movq (%rbx), %rax
movl 0x84(%rax), %edi
callq 0x9140
cmpl $-0x1, %eax
je 0xc362
addl 0x28(%rbx), %eax
movl %eax, 0x28(%rbx)
movq 0x8(%rbx), %rcx
movslq -0x8(%rcx), %rcx
cmpq %rax, %rcx
jne 0xc356
movq 0x2a0b4(%rip), %rdi     # 0x363c8
movq (%rbx), %rax
movl 0x84(%rax), %esi
movl $0x2, %edx
callq 0x9cf4
movq 0x2a09a(%rip), %rdi     # 0x363c8
movq (%rbx), %rax
movl 0x84(%rax), %esi
leaq 0xea(%rip), %rcx        # 0xc428
movl $0x1, %edx
movq %rbx, %r8
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0x9c2e
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
callq 0x9090
movl (%rax), %edi
cmpl $0x20, %edi
jne 0xc37e
movq %rbx, %rdi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0xc385
callq 0x9693
jmp 0xc36e