// File: /workspace/github_c_makefile_star2_O3/gplessis[P]dotdeb-redis/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
     * Redis 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;
    if (c->flags & CLIENT_MASTER) c->reploff += nread;
    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, 0x58(%rdx)
jne 0x3c045
cmpl $0x0, 0x5c(%rbx)
je 0x3c045
movq 0x60(%rbx), %rax
cmpq $0x8000, %rax           # imm = 0x8000
jl 0x3c045
addq $0x2, %rax
movq 0x28(%rbx), %rdx
movzbl -0x1(%rdx), %ecx
movl %ecx, %esi
andl $0x7, %esi
cmpl $0x4, %esi
ja 0x3c035
leaq 0x83c90(%rip), %rdi     # 0xbfca0
movslq (%rdi,%rsi,4), %rsi
addq %rdi, %rsi
jmpq *%rsi
shrl $0x3, %ecx
jmp 0x3c037
movq -0x11(%rdx), %rcx
jmp 0x3c037
movzwl -0x5(%rdx), %ecx
jmp 0x3c037
movl -0x9(%rdx), %ecx
jmp 0x3c037
movzbl -0x3(%rdx), %ecx
jmp 0x3c037
xorl %ecx, %ecx
subq %rcx, %rax
cmpl $0x4000, %eax           # imm = 0x4000
cltq
cmovlq %rax, %r14
movq 0x28(%rbx), %rdi
movzbl -0x1(%rdi), %r15d
movl %r15d, %eax
andl $0x7, %eax
cmpl $0x4, %eax
ja 0x3c093
leaq 0x83c54(%rip), %rcx     # 0xbfcb4
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
shrl $0x3, %r15d
jmp 0x3c087
movq -0x11(%rdi), %r15
jmp 0x3c087
movzwl -0x5(%rdi), %r15d
jmp 0x3c087
movl -0x9(%rdi), %r15d
jmp 0x3c087
movzbl -0x3(%rdi), %r15d
cmpq %r15, 0x30(%rbx)
jae 0x3c096
movq %r15, 0x30(%rbx)
jmp 0x3c096
xorl %r15d, %r15d
movq %r14, %rsi
callq 0x363e2
movq %rax, 0x28(%rbx)
addq %rax, %r15
movl %ebp, %edi
movq %r15, %rsi
movq %r14, %rdx
callq 0x26340
movq %rax, %r14
testl %r14d, %r14d
je 0x3c0db
cmpl $-0x1, %r14d
jne 0x3c0f3
callq 0x26880
movl (%rax), %edi
cmpl $0xb, %edi
jne 0x3c159
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
leaq 0x84108(%rip), %rsi     # 0xc01ea
movl $0x1, %edi
xorl %eax, %eax
callq 0x2fdad
jmp 0x3c1e9
movq 0x28(%rbx), %rdi
movl %r14d, %esi
callq 0x36820
leaq 0xc57a2(%rip), %rax     # 0x1018a8
movq 0x978(%rax), %rcx
movq %rcx, 0x88(%rbx)
testb $0x2, 0x98(%rbx)
movslq %r14d, %rcx
je 0x3c127
addq %rcx, 0xc8(%rbx)
addq %rcx, 0x420(%rax)
movq 0x28(%rbx), %rdx
movzbl -0x1(%rdx), %ecx
movl %ecx, %esi
andl $0x7, %esi
cmpl $0x4, %esi
ja 0x3c1fb
leaq 0x83b7d(%rip), %rdi     # 0xbfcc8
movslq (%rdi,%rsi,4), %rsi
addq %rdi, %rsi
jmpq *%rsi
shrl $0x3, %ecx
jmp 0x3c18b
callq 0x26680
leaq 0x8406d(%rip), %rsi     # 0xc01d2
movl $0x1, %edi
movq %rax, %rdx
xorl %eax, %eax
callq 0x2fdad
jmp 0x3c1e9
movq -0x11(%rdx), %rcx
jmp 0x3c18b
movzwl -0x5(%rdx), %ecx
jmp 0x3c18b
movl -0x9(%rdx), %ecx
jmp 0x3c18b
movzbl -0x3(%rdx), %ecx
cmpq 0x608(%rax), %rcx
jbe 0x3c1fb
callq 0x3628d
movq %rax, %rdi
movq %rbx, %rsi
callq 0x3e908
movq %rax, %r14
callq 0x3628d
movq 0x28(%rbx), %rsi
movl $0x40, %edx
movq %rax, %rdi
callq 0x37c36
movq %rax, %r15
leaq 0x8403c(%rip), %rsi     # 0xc0203
movl $0x3, %edi
movq %r14, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0x2fdad
movq %r14, %rdi
callq 0x36330
movq %r15, %rdi
callq 0x36330
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x3d73b
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x3e73e