// File: /workspace/github_c_makefile_star2_O0/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:
subq $0x28, %rsp
movq %rdi, 0x18(%rsp)
movl $0x0, 0x14(%rsp)
movq 0x18(%rsp), %rax
movq 0x20(%rax), %rax
movq 0x18(%rsp), %rcx
cmpq 0x18(%rcx), %rax
je 0x8f42
movq 0x18(%rsp), %rax
cmpl $0x0, 0x2c(%rax)
je 0x8f30
movq 0x18(%rsp), %rax
movq 0x18(%rax), %rdi
movq 0x18(%rsp), %rax
movq 0x20(%rax), %rsi
movq 0x18(%rsp), %rax
movslq 0x2c(%rax), %rdx
callq 0x2380
movq 0x18(%rsp), %rax
movq 0x18(%rax), %rcx
movq 0x18(%rsp), %rax
movq %rcx, 0x20(%rax)
jmp 0x8f44
movq 0x18(%rsp), %rax
movl 0x2c(%rax), %eax
movq 0x18(%rsp), %rcx
cmpl 0x28(%rcx), %eax
jl 0x9005
movq 0x18(%rsp), %rax
movq 0x18(%rax), %rdi
movq 0x18(%rsp), %rax
movl 0x28(%rax), %eax
shll %eax
movslq %eax, %rsi
callq 0x2330
movq %rax, 0x8(%rsp)
cmpq $0x0, 0x8(%rsp)
jne 0x8fe1
jmp 0x8f84
leaq 0x830d(%rip), %rax      # 0x11298
cmpl $0x0, 0x18(%rax)
jle 0x8fa9
movq 0x8060(%rip), %rax      # 0x10ff8
movq (%rax), %rdi
leaq 0x38ee(%rip), %rsi      # 0xc890
movb $0x0, %al
callq 0x2280
jmp 0x8fab
movq 0x18(%rsp), %rax
movl $0x0, 0x2c(%rax)
movq 0x18(%rsp), %rdi
leaq 0x3293(%rip), %rsi      # 0xc256
callq 0x4fc0
movq 0x18(%rsp), %rax
movl $0x5, 0x48(%rax)
movl $0x1, 0x24(%rsp)
jmp 0x90fd
movq 0x8(%rsp), %rcx
movq 0x18(%rsp), %rax
movq %rcx, 0x18(%rax)
movq 0x18(%rsp), %rax
movq %rcx, 0x20(%rax)
movq 0x18(%rsp), %rax
movl 0x28(%rax), %ecx
shll %ecx
movl %ecx, 0x28(%rax)
leaq 0x828c(%rip), %rax      # 0x11298
cmpq $0x0, 0x28(%rax)
jne 0x9024
movq 0x18(%rsp), %rax
movl $0x10, 0xd4(%rax)
jmp 0x9033
movq 0x18(%rsp), %rax
movl $0x0, 0xd4(%rax)
movq 0x18(%rsp), %rax
movl (%rax), %edi
movq 0x18(%rsp), %rax
movq 0x18(%rax), %rsi
movq 0x18(%rsp), %rax
movslq 0x2c(%rax), %rax
addq %rax, %rsi
movq 0x18(%rsp), %rax
movl 0x28(%rax), %eax
movq 0x18(%rsp), %rcx
subl 0x2c(%rcx), %eax
movslq %eax, %rdx
callq 0x2210
movl %eax, 0x10(%rsp)
cmpl $0x0, 0x10(%rsp)
jle 0x90a9
movslq 0x10(%rsp), %rcx
leaq 0x8272(%rip), %rax      # 0x112f0
addq 0x48(%rax), %rcx
leaq 0x8267(%rip), %rax      # 0x112f0
movq %rcx, 0x48(%rax)
movl $0x1, 0x14(%rsp)
movl 0x10(%rsp), %ecx
movq 0x18(%rsp), %rax
addl 0x2c(%rax), %ecx
movl %ecx, 0x2c(%rax)
jmp 0x8f44
cmpl $0x0, 0x10(%rsp)
jne 0x90c9
movq 0x18(%rsp), %rdi
movl $0x5, %esi
callq 0x4f80
movl $0x1, 0x24(%rsp)
jmp 0x90fd
cmpl $-0x1, 0x10(%rsp)
jne 0x90f0
callq 0x2040
cmpl $0xb, (%rax)
je 0x90e4
callq 0x2040
cmpl $0xb, (%rax)
jne 0x90e6
jmp 0x90f5
movl $0x0, 0x24(%rsp)
jmp 0x90fd
jmp 0x8f44
movl 0x14(%rsp), %eax
movl %eax, 0x24(%rsp)
movl 0x24(%rsp), %eax
addq $0x28, %rsp
retq
nopw %cs:(%rax,%rax)