// File: /workspace/github_c_makefile_star2_O3/zhou-yuxin[P]redis-aof-no-cow/src/redis-benchmark.c
// Function: writeHandler
static void writeHandler(aeEventLoop *el, int fd, void *privdata, int mask) {
    client c = privdata;
    UNUSED(el);
    UNUSED(fd);
    UNUSED(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;
        ssize_t 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
cmpq $0x0, 0x28(%rdx)
jne 0x152ec
movl 0x3721c(%rip), %eax     # 0x4c464
leal 0x1(%rax), %ecx
movl %ecx, 0x37213(%rip)     # 0x4c464
cmpl 0x37209(%rip), %eax     # 0x4c460
jge 0x153c1
cmpl $0x0, 0x37210(%rip)     # 0x4c474
je 0x152c6
cmpq $0x0, 0x18(%rbx)
je 0x152c6
xorl %r14d, %r14d
movabsq $-0x3333333333333333, %r15 # imm = 0xCCCCCCCCCCCCCCCD
movq 0x10(%rbx), %rax
movq (%rax,%r14,8), %r12
callq 0xb370
movslq 0x371ea(%rip), %rcx     # 0x4c478
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 0x1529b
incq %r14
cmpq 0x18(%rbx), %r14
jb 0x1527a
leaq 0x8(%rsp), %r14
movq %r14, %rdi
xorl %esi, %esi
callq 0xb200
imulq $0xf4240, (%r14), %rax  # imm = 0xF4240
addq 0x8(%r14), %rax
movq %rax, 0x30(%rbx)
movq $-0x1, 0x38(%rbx)
movq 0x8(%rbx), %rax
movzbl -0x1(%rax), %edx
movl %edx, %ecx
andl $0x7, %ecx
cmpl $0x4, %ecx
ja 0x15438
leaq 0x23f53(%rip), %rsi     # 0x3925c
movslq (%rsi,%rcx,4), %rdi
addq %rsi, %rdi
jmpq *%rdi
movl %edx, %esi
shrl $0x3, %esi
jmp 0x1532e
movq -0x11(%rax), %rsi
jmp 0x1532e
movzwl -0x5(%rax), %esi
jmp 0x1532e
movl -0x9(%rax), %esi
jmp 0x1532e
movzbl -0x3(%rax), %esi
movq 0x28(%rbx), %r8
cmpq %r8, %rsi
jbe 0x15438
leaq (%rax,%r8), %rsi
movq (%rbx), %rdi
movl 0x84(%rdi), %edi
movl %ecx, %ecx
leaq 0x23f1f(%rip), %r9      # 0x39270
movslq (%r9,%rcx,4), %rcx
addq %r9, %rcx
jmpq *%rcx
shrl $0x3, %edx
jmp 0x15374
movq -0x11(%rax), %rdx
jmp 0x15374
movzwl -0x5(%rax), %edx
jmp 0x15374
movl -0x9(%rax), %edx
jmp 0x15374
movzbl -0x3(%rax), %edx
subq %r8, %rdx
callq 0xb150
cmpq $-0x1, %rax
je 0x153b1
addq 0x28(%rbx), %rax
movq %rax, 0x28(%rbx)
movq 0x8(%rbx), %rdx
movzbl -0x1(%rdx), %ecx
movl %ecx, %esi
andl $0x7, %esi
cmpl $0x4, %esi
ja 0x153e8
leaq 0x23ee1(%rip), %rdi     # 0x39284
movslq (%rdi,%rsi,4), %rsi
addq %rdi, %rsi
jmpq *%rsi
shrl $0x3, %ecx
jmp 0x153ea
callq 0xb080
movl (%rax), %edi
cmpl $0x20, %edi
jne 0x15444
movq %rbx, %rdi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0x1544e
movq -0x11(%rdx), %rcx
jmp 0x153ea
movzwl -0x5(%rdx), %ecx
jmp 0x153ea
movl -0x9(%rdx), %ecx
jmp 0x153ea
movzbl -0x3(%rdx), %ecx
jmp 0x153ea
xorl %ecx, %ecx
cmpq %rax, %rcx
jne 0x15438
movq 0x37042(%rip), %rdi     # 0x4c438
movq (%rbx), %rax
movl 0x84(%rax), %esi
movl $0x2, %edx
callq 0x12826
movq 0x37028(%rip), %rdi     # 0x4c438
movq (%rbx), %rax
movl 0x84(%rax), %esi
leaq 0xd1(%rip), %rcx        # 0x154f1
movl $0x1, %edx
movq %rbx, %r8
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0x1275e
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
callq 0xb6b8
jmp 0x153c1