// File: /workspace/github_c_makefile_star2_O1/erikdubbelboer[P]discnt/src/networking.c
// Function: readQueryFromClient
void readQueryFromClient(aeEventLoop *el, int fd, void *privdata, int mask) {
    client *c = (client*) privdata;
    int nread, readlen;
    size_t qblen;
    UNUSED(el);
    UNUSED(mask);

    readlen = PROTO_IOBUF_LEN;
    /* If this is a multi bulk request, and we are processing a bulk reply
     * that is large enough, try to maximize the probability that the query
     * buffer contains exactly the SDS string representing the object, even
     * at the risk of requiring more read(2) calls. This way the function
     * processMultiBulkBuffer() can avoid copying buffers to create the
     * Disque Object representing the argument. */
    if (c->reqtype == PROTO_REQ_MULTIBULK && c->multibulklen && c->bulklen != -1
        && c->bulklen >= PROTO_MBULK_BIG_ARG)
    {
        int remaining = (unsigned)(c->bulklen+2)-sdslen(c->querybuf);

        if (remaining < readlen) readlen = remaining;
    }

    qblen = sdslen(c->querybuf);
    if (c->querybuf_peak < qblen) c->querybuf_peak = qblen;
    c->querybuf = sdsMakeRoomFor(c->querybuf, readlen);
    nread = read(fd, c->querybuf+qblen, readlen);
    if (nread == -1) {
        if (errno == EAGAIN) {
            return;
        } else {
            serverLog(LL_VERBOSE, "Reading from client: %s",strerror(errno));
            freeClient(c);
            return;
        }
    } else if (nread == 0) {
        serverLog(LL_VERBOSE, "Client closed connection");
        freeClient(c);
        return;
    }

    sdsIncrLen(c->querybuf,nread);
    c->lastinteraction = server.unixtime;
    server.stat_net_input_bytes += nread;
    if (sdslen(c->querybuf) > server.client_max_querybuf_len) {
        sds ci = catClientInfoString(sdsempty(),c), bytes = sdsempty();

        bytes = sdscatrepr(bytes,c->querybuf,64);
        serverLog(LL_WARNING,"Closing client that reached max query buffer length: %s (qbuf initial bytes: %s)", ci, bytes);
        sdsfree(ci);
        sdsfree(bytes);
        freeClient(c);
        return;
    }
    processInputBuffer(c);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdx, %rbx
movl %esi, %ebp
movl $0x4000, %r14d          # imm = 0x4000
cmpl $0x2, 0x48(%rdx)
jne 0x2180d
cmpl $0x0, 0x4c(%rbx)
je 0x2180d
movq 0x50(%rbx), %rax
cmpq $0x8000, %rax           # imm = 0x8000
jl 0x2180d
addq $0x2, %rax
movq 0x18(%rbx), %rdx
movzbl -0x1(%rdx), %ecx
movl %ecx, %esi
andl $0x7, %esi
cmpl $0x4, %esi
ja 0x217fd
leaq 0x33108(%rip), %rdi     # 0x548e0
movslq (%rdi,%rsi,4), %rsi
addq %rdi, %rsi
jmpq *%rsi
shrl $0x3, %ecx
jmp 0x217ff
movq -0x11(%rdx), %rcx
jmp 0x217ff
movzwl -0x5(%rdx), %ecx
jmp 0x217ff
movl -0x9(%rdx), %ecx
jmp 0x217ff
movzbl -0x3(%rdx), %ecx
jmp 0x217ff
xorl %ecx, %ecx
subq %rcx, %rax
cmpl $0x4000, %eax           # imm = 0x4000
cltq
cmovlq %rax, %r14
movq 0x18(%rbx), %rdi
movzbl -0x1(%rdi), %r15d
movl %r15d, %eax
andl $0x7, %eax
cmpl $0x4, %eax
ja 0x21851
leaq 0x330cc(%rip), %rcx     # 0x548f4
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
shrl $0x3, %r15d
jmp 0x21854
movq -0x11(%rdi), %r15
jmp 0x21854
movzwl -0x5(%rdi), %r15d
jmp 0x21854
movl -0x9(%rdi), %r15d
jmp 0x21854
movzbl -0x3(%rdi), %r15d
jmp 0x21854
xorl %r15d, %r15d
cmpq %r15, 0x20(%rbx)
jae 0x2185e
movq %r15, 0x20(%rbx)
movq %r14, %rsi
callq 0x1df85
movq %rax, 0x18(%rbx)
addq %rax, %r15
movl %ebp, %edi
movq %r15, %rsi
movq %r14, %rdx
callq 0x12420
movq %rax, %r14
testl %r14d, %r14d
je 0x2189f
cmpl $-0x1, %r14d
jne 0x218b7
callq 0x120d0
movl (%rax), %edi
cmpl $0xb, %edi
jne 0x21906
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
leaq 0x335be(%rip), %rsi     # 0x54e64
movl $0x1, %edi
xorl %eax, %eax
callq 0x19fb1
jmp 0x2199a
movq 0x18(%rbx), %rdi
movl %r14d, %esi
callq 0x1e3ca
leaq 0x4d7be(%rip), %rax     # 0x6f088
movq 0x648(%rax), %rcx
movq %rcx, 0x78(%rbx)
movslq %r14d, %rcx
addq %rcx, 0x3b0(%rax)
movq 0x18(%rbx), %rdx
movzbl -0x1(%rdx), %ecx
movl %ecx, %esi
andl $0x7, %esi
cmpl $0x4, %esi
ja 0x2193a
leaq 0x33010(%rip), %rdi     # 0x54908
movslq (%rdi,%rsi,4), %rsi
addq %rdi, %rsi
jmpq *%rsi
shrl $0x3, %ecx
jmp 0x2193c
callq 0x128f0
leaq 0x3353a(%rip), %rsi     # 0x54e4c
movl $0x1, %edi
movq %rax, %rdx
xorl %eax, %eax
callq 0x19fb1
jmp 0x2199a
movq -0x11(%rdx), %rcx
jmp 0x2193c
movzwl -0x5(%rdx), %ecx
jmp 0x2193c
movl -0x9(%rdx), %ecx
jmp 0x2193c
movzbl -0x3(%rdx), %ecx
jmp 0x2193c
xorl %ecx, %ecx
cmpq 0x5a8(%rax), %rcx
jbe 0x219ac
callq 0x1de3f
movq %rax, %rdi
movq %rbx, %rsi
callq 0x23e1d
movq %rax, %r14
callq 0x1de3f
movq 0x18(%rbx), %rsi
movl $0x40, %edx
movq %rax, %rdi
callq 0x1f7c8
movq %rax, %r15
leaq 0x33505(%rip), %rsi     # 0x54e7d
movl $0x3, %edi
movq %r14, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0x19fb1
movq %r14, %rdi
callq 0x1ded3
movq %r15, %rdi
callq 0x1ded3
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x22f00
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x23c34