// File: /workspace/github_c_makefile_star2_O2/zuocheng-liu[P]ae-memcached/src/memcached.c
// Function: try_read_network
int try_read_network(conn *c) {
    int gotdata = 0;
    int res;

    if (c->rcurr != c->rbuf) {
        if (c->rbytes != 0) /* otherwise there's nothing to copy */
            memmove(c->rbuf, c->rcurr, c->rbytes);
        c->rcurr = c->rbuf;
    }

    while (1) {
        if (c->rbytes >= c->rsize) {
            char *new_rbuf = realloc(c->rbuf, c->rsize*2);
            if (!new_rbuf) {
                LOG_INFO("Couldn't realloc input buffer\n");
                c->rbytes = 0; /* ignore what we read */
                out_string(c, "SERVER_ERROR out of memory");
                c->write_and_go = conn_closing;
                return 1;
            }
            c->rcurr  = c->rbuf = new_rbuf;
            c->rsize *= 2;
        }

        /* unix socket mode doesn't need this, so zeroed out.  but why
         * is this done for every command?  presumably for UDP
         * mode.  */
        if (!settings.socketpath) {
            c->request_addr_size = sizeof(c->request_addr);
        } else {
            c->request_addr_size = 0;
        }

        res = read(c->sfd, c->rbuf + c->rbytes, c->rsize - c->rbytes);
        if (res > 0) {
            stats.bytes_read += res;
            gotdata = 1;
            c->rbytes += res;
            continue;
        }
        if (res == 0) {
            /* connection closed */
            conn_set_state(c, conn_closing);
            return 1;
        }
        if (res == -1) {
            if (errno == EAGAIN || errno == EWOULDBLOCK) break;
            else return 0;
        }
    }
    return gotdata;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rdi, %rbx
movq 0x18(%rdi), %rdi
movq 0x20(%rbx), %rsi
cmpq %rdi, %rsi
je 0x59c4
movslq 0x2c(%rbx), %rdx
testq %rdx, %rdx
je 0x59c0
callq 0x2360
movq 0x18(%rbx), %rdi
movq %rdi, 0x20(%rbx)
xorl %ebp, %ebp
leaq 0x78bb(%rip), %r14      # 0xd288
leaq 0x790c(%rip), %r15      # 0xd2e0
pushq $0x1
popq %r12
movl 0x28(%rbx), %eax
cmpl %eax, 0x2c(%rbx)
jl 0x5a04
movslq %eax, %rsi
movq 0x18(%rbx), %rdi
addq %rsi, %rsi
callq 0x2310
testq %rax, %rax
je 0x5a71
movq %rax, 0x18(%rbx)
movq %rax, 0x20(%rbx)
movl 0x28(%rbx), %eax
addl %eax, %eax
movl %eax, 0x28(%rbx)
xorl %ecx, %ecx
cmpq $0x0, 0x28(%r14)
sete %cl
shll $0x4, %ecx
movl %ecx, 0xd4(%rbx)
movl (%rbx), %edi
movslq 0x2c(%rbx), %rcx
movq 0x18(%rbx), %rsi
addq %rcx, %rsi
movslq %eax, %rdx
subq %rcx, %rdx
callq 0x21f0
testl %eax, %eax
jg 0x5a3e
cmpl $-0x1, %eax
je 0x5a52
testl %eax, %eax
jne 0x59d8
jmp 0x5a64
movl %eax, %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
addq %rcx, 0x48(%r15)
addl %eax, 0x2c(%rbx)
movl %r12d, %ebp
jmp 0x59d8
callq 0x2040
movq %rax, %rcx
xorl %eax, %eax
cmpl $0xb, (%rcx)
cmovel %ebp, %eax
jmp 0x5a95
pushq $0x5
popq %rsi
movq %rbx, %rdi
callq 0x391f
jmp 0x5a92
cmpl $0x0, 0x18(%r14)
jg 0x5a9e
andl $0x0, 0x2c(%rbx)
leaq 0x27d3(%rip), %rsi      # 0x8256
movq %rbx, %rdi
callq 0x3946
movl $0x5, 0x48(%rbx)
pushq $0x1
popq %rax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq 0x7553(%rip), %rax      # 0xcff8
movq (%rax), %rcx
leaq 0x2dd1(%rip), %rdi      # 0x8880
pushq $0x1e
popq %rsi
pushq $0x1
popq %rdx
callq 0x2420
jmp 0x5a78