// File: /workspace/github_c_makefile_star2_O1/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 0x15515
movl 0x36ff3(%rip), %eax     # 0x4c464
leal 0x1(%rax), %ecx
movl %ecx, 0x36fea(%rip)     # 0x4c464
cmpl 0x36fe0(%rip), %eax     # 0x4c460
jge 0x155f3
cmpl $0x0, 0x36fe7(%rip)     # 0x4c474
je 0x154ef
cmpq $0x0, 0x18(%rbx)
je 0x154ef
xorl %r14d, %r14d
movabsq $-0x3333333333333333, %r15 # imm = 0xCCCCCCCCCCCCCCCD
movq 0x10(%rbx), %rax
movq (%rax,%r14,8), %r12
callq 0xb370
movslq 0x36fc1(%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 0x154c4
incq %r14
cmpq 0x18(%rbx), %r14
jb 0x154a3
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 0x15555
leaq 0x23cce(%rip), %rsi     # 0x391fc
movslq (%rsi,%rcx,4), %rdi
addq %rsi, %rdi
jmpq *%rdi
movl %edx, %esi
shrl $0x3, %esi
jmp 0x15557
movq -0x11(%rax), %rsi
jmp 0x15557
movzwl -0x5(%rax), %esi
jmp 0x15557
movl -0x9(%rax), %esi
jmp 0x15557
movzbl -0x3(%rax), %esi
jmp 0x15557
xorl %esi, %esi
movq 0x28(%rbx), %r8
cmpq %r8, %rsi
jbe 0x1566a
leaq (%rax,%r8), %rsi
movq (%rbx), %rdi
movl 0x84(%rdi), %edi
cmpl $0x4, %ecx
ja 0x155a4
movl %ecx, %ecx
leaq 0x23c91(%rip), %r9      # 0x39210
movslq (%r9,%rcx,4), %rcx
addq %r9, %rcx
jmpq *%rcx
shrl $0x3, %edx
jmp 0x155a6
movq -0x11(%rax), %rdx
jmp 0x155a6
movzwl -0x5(%rax), %edx
jmp 0x155a6
movl -0x9(%rax), %edx
jmp 0x155a6
movzbl -0x3(%rax), %edx
jmp 0x155a6
xorl %edx, %edx
subq %r8, %rdx
callq 0xb150
cmpq $-0x1, %rax
je 0x155e3
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 0x1561a
leaq 0x23c4f(%rip), %rdi     # 0x39224
movslq (%rdi,%rsi,4), %rsi
addq %rdi, %rsi
jmpq *%rsi
shrl $0x3, %ecx
jmp 0x1561c
callq 0xb080
movl (%rax), %edi
cmpl $0x20, %edi
jne 0x15676
movq %rbx, %rdi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0x15680
movq -0x11(%rdx), %rcx
jmp 0x1561c
movzwl -0x5(%rdx), %ecx
jmp 0x1561c
movl -0x9(%rdx), %ecx
jmp 0x1561c
movzbl -0x3(%rdx), %ecx
jmp 0x1561c
xorl %ecx, %ecx
cmpq %rax, %rcx
jne 0x1566a
movq 0x36e10(%rip), %rdi     # 0x4c438
movq (%rbx), %rax
movl 0x84(%rax), %esi
movl $0x2, %edx
callq 0x12a32
movq 0x36df6(%rip), %rdi     # 0x4c438
movq (%rbx), %rax
movl 0x84(%rax), %esi
leaq 0xd1(%rip), %rcx        # 0x15723
movl $0x1, %edx
movq %rbx, %r8
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0x12963
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
callq 0xb6b8
jmp 0x155f3