LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O3/zuocheng-liu[P]ae-memcached/src/connection.c
// Function: conn_close
void conn_close(conn *c) {
    /* delete the event, the socket and the conn */
    aeDeleteFileEvent(g_el, c->sfd, AE_READABLE); 
    aeDeleteFileEvent(g_el, c->sfd, AE_WRITABLE);

    LOG_DEBUG_F1("<%d connection closed.\n", c->sfd);

    close(c->sfd);
    conn_cleanup(c);

    /* if the connection has big buffers, just free it */
    if (c->rsize > READ_BUFFER_HIGHWAT) {
        conn_free(c);
    } else if (freecurr < freetotal) {
        /* if we have enough space in the free connections array, put the structure there */
        freeconns[freecurr++] = c;
    } else {
        /* try to enlarge free connections array */
        conn **new_freeconns = realloc(freeconns, sizeof(conn *)*freetotal*2);
        if (new_freeconns) {
            freetotal *= 2;
            freeconns = new_freeconns;
            freeconns[freecurr++] = c;
        } else {
            conn_free(c);
        }
    }

    -- stats.curr_conns;

    return;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdi, %rbx
leaq 0x932a(%rip), %r14      # 0xd278
movq (%r14), %rdi
movl (%rbx), %esi
movl $0x1, %edx
callq 0x2f8c
movq (%r14), %rdi
movl (%rbx), %esi
movl $0x2, %edx
callq 0x2f8c
leaq 0x9315(%rip), %rax      # 0xd288
cmpl $0x2, 0x18(%rax)
jge 0x400a
movl (%rbx), %edi
callq 0x21b0
movq %rbx, %rdi
callq 0x3ecf
cmpl $0x2001, 0x28(%rbx)     # imm = 0x2001
jl 0x3f9f
movq %rbx, %rdi
callq 0x4017
jmp 0x3ffa
movslq 0x92be(%rip), %r14      # 0xd264
movslq 0x92b3(%rip), %r15      # 0xd260
movq 0x92b4(%rip), %rdi      # 0xd268
cmpl %r15d, %r14d
jge 0x3fca
movl %r14d, %eax
incl %eax
movl %eax, 0x92a0(%rip)      # 0xd264
movq %rbx, (%rdi,%r14,8)
jmp 0x3ffa
movq %r15, %rsi
shlq $0x4, %rsi
callq 0x2310
testq %rax, %rax
je 0x3f95
addl %r15d, %r15d
movl %r15d, 0x927b(%rip)     # 0xd260
movq %rax, 0x927c(%rip)      # 0xd268
leal 0x1(%r14), %ecx
movl %ecx, 0x926e(%rip)      # 0xd264
movq %rbx, (%rax,%r14,8)
leaq 0x92df(%rip), %rax      # 0xd2e0
decl 0x10(%rax)
popq %rbx
popq %r14
popq %r15
retq
movq %rbx, %rdi
callq 0x255e
jmp 0x3f7d
// File: /workspace/github_c_makefile_star2_O3/zuocheng-liu[P]ae-memcached/src/connection.c
// Function: conn_free
static void conn_free(conn *c) {
    if (c) {
        if (c->hdrbuf)
            free(c->hdrbuf);
        if (c->msglist)
            free(c->msglist);
        if (c->rbuf)
            free(c->rbuf);
        if (c->wbuf)
            free(c->wbuf);
        if (c->ilist)
            free(c->ilist);
        if (c->iov)
            free(c->iov);
        free(c);
    }
}

// Assembly:
testq %rdi, %rdi
je 0x4086
pushq %rbx
movq %rdi, %rbx
movq 0xd8(%rdi), %rdi
testq %rdi, %rdi
je 0x4031
callq 0x2030
movq 0x88(%rbx), %rdi
testq %rdi, %rdi
je 0x4042
callq 0x2030
movq 0x18(%rbx), %rdi
testq %rdi, %rdi
je 0x4050
callq 0x2030
movq 0x30(%rbx), %rdi
testq %rdi, %rdi
je 0x405e
callq 0x2030
movq 0xa0(%rbx), %rdi
testq %rdi, %rdi
je 0x406f
callq 0x2030
movq 0x78(%rbx), %rdi
testq %rdi, %rdi
je 0x407d
callq 0x2030
movq %rbx, %rdi
popq %rbx
jmp 0x2030
retq
// File: /workspace/github_c_makefile_star2_O3/zuocheng-liu[P]ae-memcached/src/connection.c
// Function: do_realloc
int do_realloc(void **orig, int newsize, int bytes_per_item, int *size) {
    void *newbuf = realloc(*orig, newsize * bytes_per_item);
    if (newbuf) {
        *orig = newbuf;
        *size = newsize;
       return 1;
    }
    return 0;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movq %rcx, %rbx
movl %esi, %ebp
movq %rdi, %r14
movq (%rdi), %rdi
imull %esi, %edx
movslq %edx, %rsi
callq 0x2310
testq %rax, %rax
je 0x40b2
movq %rax, (%r14)
movl %ebp, (%rbx)
movl $0x1, %eax
jmp 0x40b4
xorl %eax, %eax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/zuocheng-liu[P]ae-memcached/src/connection.c
// Function: conn_shrink
void conn_shrink(conn *c) {
    if (c->udp)
        return;

    if (c->rsize > READ_BUFFER_HIGHWAT && c->rbytes < DATA_BUFFER_SIZE) {
       do_realloc((void **)&c->rbuf, DATA_BUFFER_SIZE, 1, &c->rsize);
    }

    if (c->isize > ITEM_LIST_HIGHWAT) {
        do_realloc((void **)&c->ilist, ITEM_LIST_INITIAL, sizeof(c->ilist[0]), &c->isize);
    }

    if (c->msgsize > MSG_LIST_HIGHWAT) {
        do_realloc((void **)&c->msglist, MSG_LIST_INITIAL, sizeof(c->msglist[0]), &c->msgsize);
    }

    if (c->iovsize > IOV_LIST_HIGHWAT) {
        do_realloc((void **)&c->iov, IOV_LIST_INITIAL, sizeof(c->iov[0]), &c->iovsize);
    }
}

// Assembly:
cmpl $0x0, 0xbc(%rdi)
je 0x40c3
retq
pushq %rbx
movq %rdi, %rbx
cmpl $0x2001, 0x28(%rdi)     # imm = 0x2001
jl 0x40f7
cmpl $0x7ff, 0x2c(%rbx)      # imm = 0x7FF
jg 0x40f7
movq 0x18(%rbx), %rdi
movl $0x800, %esi            # imm = 0x800
callq 0x2310
testq %rax, %rax
je 0x40f7
movq %rax, 0x18(%rbx)
movl $0x800, 0x28(%rbx)      # imm = 0x800
cmpl $0x191, 0xa8(%rbx)      # imm = 0x191
jl 0x412a
movq 0xa0(%rbx), %rdi
movl $0x640, %esi            # imm = 0x640
callq 0x2310
testq %rax, %rax
je 0x412a
movq %rax, 0xa0(%rbx)
movl $0xc8, 0xa8(%rbx)
cmpl $0x65, 0x90(%rbx)
jl 0x415a
movq 0x88(%rbx), %rdi
movl $0x230, %esi            # imm = 0x230
callq 0x2310
testq %rax, %rax
je 0x415a
movq %rax, 0x88(%rbx)
movl $0xa, 0x90(%rbx)
cmpl $0x259, 0x80(%rbx)      # imm = 0x259
jl 0x4187
movq 0x78(%rbx), %rdi
movl $0x1900, %esi           # imm = 0x1900
callq 0x2310
testq %rax, %rax
je 0x4187
movq %rax, 0x78(%rbx)
movl $0x190, 0x80(%rbx)      # imm = 0x190
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O3/zuocheng-liu[P]ae-memcached/src/connection.c
// Function: conn_set_state
void conn_set_state(conn *c, int state) {
    if (state != c->state) {
        if (state == conn_read) {
            conn_shrink(c);
        }
        c->state = state;
    }
}

// Assembly:
cmpl %esi, 0x4(%rdi)
je 0x41af
pushq %r14
pushq %rbx
pushq %rax
movl %esi, %ebx
movq %rdi, %r14
cmpl $0x1, %esi
jne 0x41a4
movq %r14, %rdi
callq 0x40b9
movl %ebx, 0x4(%r14)
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O3/zuocheng-liu[P]ae-memcached/src/connection.c
// Function: out_string
void out_string(conn *c, char *str) {
    int len;

    LOG_DEBUG_F2(">%d %s\n", c->sfd, str);

    len = strlen(str);
    if (len + 2 > c->wsize) {
        /* ought to be always enough. just fail for simplicity */
        str = "SERVER_ERROR output line too long";
        len = strlen(str);
    }

    strcpy(c->wbuf, str);
    strcpy(c->wbuf + len, "\r\n");
    c->wbytes = len + 2;
    c->wcurr = c->wbuf;

    conn_set_state(c, conn_write);
    c->write_and_go = conn_read;
    return;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x90c7(%rip), %rax      # 0xd288
cmpl $0x2, 0x18(%rax)
jge 0x422a
movq %r14, %rdi
callq 0x2120
leal 0x2(%rax), %ecx
cmpl 0x40(%rbx), %ecx
leaq 0x4071(%rip), %rsi      # 0x824d
cmovleq %r14, %rsi
movl $0x21, %ebp
cmovlel %eax, %ebp
movq 0x30(%rbx), %rdi
callq 0x2090
movq 0x30(%rbx), %rax
movslq %ebp, %rcx
movw $0xa0d, (%rax,%rcx)     # imm = 0xA0D
movb $0x0, 0x2(%rax,%rcx)
addl $0x2, %ecx
movl %ecx, 0x44(%rbx)
movq 0x30(%rbx), %rax
movq %rax, 0x38(%rbx)
cmpl $0x2, 0x4(%rbx)
je 0x421e
movl $0x2, 0x4(%rbx)
movl $0x1, 0x48(%rbx)
popq %rbx
popq %r14
popq %rbp
retq
movq 0x8dc7(%rip), %rax      # 0xcff8
movq (%rax), %rdi
movl (%rbx), %edx
leaq 0x4008(%rip), %rsi      # 0x8245
movq %r14, %rcx
xorl %eax, %eax
callq 0x2260
jmp 0x41c7
// File: /workspace/github_c_makefile_star2_O3/zuocheng-liu[P]ae-memcached/src/connection.c
// Function: add_iov
int add_iov(conn *c, const void *buf, int len) {
    struct msghdr *m;
    int leftover;
    int limit_to_mtu;

    do {
        m = &c->msglist[c->msgused - 1];

        /*
         * Limit UDP packets, and the first payloads of TCP replies, to
         * UDP_MAX_PAYLOAD_SIZE bytes.
         */
        limit_to_mtu = c->udp || (1 == c->msgused);

        /* We may need to start a new msghdr if this one is full. */
        if (m->msg_iovlen == IOV_MAX ||
                (limit_to_mtu && c->msgbytes >= UDP_MAX_PAYLOAD_SIZE)) {
            add_msghdr(c);
            m = &c->msglist[c->msgused - 1];
        }

        if (ensure_iov_space(c))
            return -1;

        /* If the fragment is too big to fit in the datagram, split it up */
        if (limit_to_mtu && len + c->msgbytes > UDP_MAX_PAYLOAD_SIZE) {
            leftover = len + c->msgbytes - UDP_MAX_PAYLOAD_SIZE;
            len -= leftover;
        } else {
            leftover = 0;
        }

        m = &c->msglist[c->msgused - 1];
        m->msg_iov[m->msg_iovlen].iov_base = (void*) buf;
        m->msg_iov[m->msg_iovlen].iov_len = len;

        c->msgbytes += len;
        c->iovused++;
        m->msg_iovlen++;

        buf = ((char *)buf) + len;
        len = leftover;
    } while (leftover > 0);

    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %edx, %ebp
movq %rsi, %rbx
movq %rdi, %r14
movq 0x88(%rdi), %rcx
movslq 0x94(%rdi), %rax
imulq $0x38, %rax, %rdx
movq -0x20(%rcx,%rdx), %rcx
cmpl $0x0, 0xbc(%r14)
setne %dl
cmpl $0x1, %eax
sete %r15b
orb %dl, %r15b
cmpq $0x400, %rcx            # imm = 0x400
jne 0x42b1
movq %r14, %rdi
callq 0x4372
movq %r14, %rdi
xorl %eax, %eax
callq 0x4f17
testl %eax, %eax
jne 0x4362
testb %r15b, %r15b
jne 0x42d5
jmp 0x42f4
testb %r15b, %r15b
je 0x42f9
cmpl $0x578, 0x9c(%r14) # imm = 0x578
jge 0x4290
movq %r14, %rdi
xorl %eax, %eax
callq 0x4f17
testl %eax, %eax
jne 0x4362
movl 0x9c(%r14), %r15d
addl %ebp, %r15d
cmpl $0x579, %r15d           # imm = 0x579
jl 0x42f4
addl $0xfffffa88, %r15d      # imm = 0xFFFFFA88
subl %r15d, %ebp
jmp 0x430a
xorl %r15d, %r15d
jmp 0x430a
xorl %r15d, %r15d
movq %r14, %rdi
xorl %eax, %eax
callq 0x4f17
testl %eax, %eax
jne 0x4362
movq 0x88(%r14), %rdx
movslq 0x94(%r14), %rax
imulq $0x38, %rax, %rsi
movq -0x28(%rdx,%rsi), %rdi
movq -0x20(%rdx,%rsi), %rcx
movq %rcx, %r8
shlq $0x4, %r8
movq %rbx, (%rdi,%r8)
movslq %ebp, %r9
movq %r9, 0x8(%rdi,%r8)
addl %r9d, 0x9c(%r14)
incl 0x84(%r14)
incq %rcx
movq %rcx, -0x20(%rdx,%rsi)
addq %r9, %rbx
movl %r15d, %ebp
testl %r15d, %r15d
jne 0x4272
xorl %eax, %eax
jmp 0x4367
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/zuocheng-liu[P]ae-memcached/src/connection.c
// Function: add_msghdr
int add_msghdr(conn *c) {
    struct msghdr *msg;

    if (c->msgsize == c->msgused) {
        msg = realloc(c->msglist, c->msgsize * 2 * sizeof(struct msghdr));
        if (! msg)
            return -1;
        c->msglist = msg;
        c->msgsize *= 2;
    }

    msg = c->msglist + c->msgused;

    /* this wipes msg_iovlen, msg_control, msg_controllen, and
       msg_flags, the last 3 of which aren't defined on solaris: */
    memset(msg, 0, sizeof(struct msghdr));

    msg->msg_iov = &c->iov[c->iovused];
    msg->msg_name = &c->request_addr;
    msg->msg_namelen = c->request_addr_size;

    c->msgbytes = 0;
    c->msgused++;

    if (c->udp) {
        /* Leave room for the UDP header, which we'll fill in later. */
        return add_iov(c, NULL, UDP_HEADER_SIZE);
    }

    return 0;
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
movslq 0x90(%rdi), %rdx
movl 0x94(%rdi), %ecx
movq 0x88(%rdi), %rax
cmpl %ecx, %edx
jne 0x43b6
imulq $0x70, %rdx, %rsi
movq %rax, %rdi
callq 0x2310
testq %rax, %rax
je 0x442d
movq %rax, 0x88(%rbx)
shll 0x90(%rbx)
movl 0x94(%rbx), %ecx
movslq %ecx, %rcx
imulq $0x38, %rcx, %rcx
xorps %xmm0, %xmm0
movups %xmm0, 0x20(%rax,%rcx)
movups %xmm0, 0x10(%rax,%rcx)
movups %xmm0, (%rax,%rcx)
movq $0x0, 0x30(%rax,%rcx)
movslq 0x84(%rbx), %rdx
shlq $0x4, %rdx
addq 0x78(%rbx), %rdx
movq %rdx, 0x10(%rax,%rcx)
leaq 0xc4(%rbx), %rdx
movq %rdx, (%rax,%rcx)
movl 0xd4(%rbx), %edx
movl %edx, 0x8(%rax,%rcx)
movl $0x0, 0x9c(%rbx)
incl 0x94(%rbx)
cmpl $0x0, 0xbc(%rbx)
je 0x4429
movq %rbx, %rdi
xorl %esi, %esi
movl $0x8, %edx
popq %rbx
jmp 0x424c
xorl %eax, %eax
jmp 0x4432
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O3/zuocheng-liu[P]ae-memcached/src/daemon.c
// Function: daemon
int daemon(int nochdir, int noclose) {
    int fd;

    switch (fork()) {
        case -1:
            return (-1);
        case 0:
            break;
        default:
            _exit(0);
    }

    if (setsid() == -1)
        return (-1);

    if (!nochdir) {
        if (chdir("/") < 0) {
            return -1;
        }
    }

    if (!noclose && (fd = open("/dev/null", O_RDWR, 0)) != -1) {
        (void)dup2(fd, STDIN_FILENO);
        (void)dup2(fd, STDOUT_FILENO);
        (void)dup2(fd, STDERR_FILENO);
        if (fd > STDERR_FILENO)
            (void)close(fd);
    }
    return (0);
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movl %esi, %ebp
movl %edi, %r14d
callq 0x2450
movl %eax, %ebx
cmpl $-0x1, %eax
je 0x447b
testl %ebx, %ebx
jne 0x44d1
callq 0x21c0
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
cmpl $-0x1, %eax
je 0x447b
testl %r14d, %r14d
jne 0x4475
leaq 0x3e03(%rip), %rdi      # 0x826f
callq 0x2130
testl %eax, %eax
js 0x447b
xorl %ebx, %ebx
testl %ebp, %ebp
je 0x4482
movl %ebx, %eax
popq %rbx
popq %r14
popq %rbp
retq
leaq 0x3de8(%rip), %rdi      # 0x8271
xorl %ebx, %ebx
movl $0x2, %esi
xorl %edx, %edx
xorl %eax, %eax
callq 0x2380
cmpl $-0x1, %eax
je 0x447b
movl %eax, %ebp
xorl %ebx, %ebx
movl %eax, %edi
xorl %esi, %esi
callq 0x2160
movl %ebp, %edi
movl $0x1, %esi
callq 0x2160
movl %ebp, %edi
movl $0x2, %esi
callq 0x2160
cmpl $0x3, %ebp
jl 0x447b
movl %ebp, %edi
callq 0x21b0
jmp 0x447b
xorl %edi, %edi
callq 0x2080
// File: /workspace/github_c_makefile_star2_O3/zuocheng-liu[P]ae-memcached/src/items.c
// Function: item_init
void item_init() {
    int i;
    for(i=0; i<LARGEST_ID; i++) {
        heads[i]=0;
        tails[i]=0;
        sizes[i]=0;
    }
}

// Assembly:
pushq %rax
leaq 0x8e70(%rip), %rdi      # 0xd350
movl $0x7f8, %edx            # imm = 0x7F8
xorl %esi, %esi
callq 0x2190
leaq 0x965d(%rip), %rdi      # 0xdb50
movl $0x7f8, %edx            # imm = 0x7F8
xorl %esi, %esi
callq 0x2190
leaq 0x9e4a(%rip), %rdi      # 0xe350
movl $0x3fc, %edx            # imm = 0x3FC
xorl %esi, %esi
popq %rax
jmp 0x2190
// File: /workspace/github_c_makefile_star2_O3/zuocheng-liu[P]ae-memcached/src/items.c
// Function: item_unlink
void item_unlink(item *it) {
    if (it->it_flags & ITEM_LINKED) {
        it->it_flags &= ~ITEM_LINKED;
        stats.curr_bytes -= ITEM_ntotal(it);
        stats.curr_items -= 1;
        assoc_delete(ITEM_key(it));
        item_unlink_q(it);
    }
    if (it->refcount == 0) {
        item_free(it);
    }
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
movb 0x27(%rdi), %al
testb $0x1, %al
je 0x470b
andb $-0x2, %al
movb %al, 0x27(%rbx)
movzbl 0x29(%rbx), %eax
movzbl 0x26(%rbx), %ecx
addq %rax, %rcx
movslq 0x20(%rbx), %rax
addq %rcx, %rax
leaq 0x8bfa(%rip), %rcx      # 0xd2e0
movq 0x8(%rcx), %rdx
negq %rax
addq %rdx, %rax
addq $-0x30, %rax
movq %rax, 0x8(%rcx)
decl (%rcx)
leaq 0x30(%rbx), %rdi
callq 0x38d4
movq %rbx, %rdi
callq 0x47e3
cmpw $0x0, 0x24(%rbx)
je 0x4714
popq %rbx
retq
movzbl 0x29(%rbx), %eax
movzbl 0x26(%rbx), %ecx
addl %eax, %ecx
movl 0x20(%rbx), %eax
leal (%rax,%rcx), %edx
addl $0x30, %edx
movb $0x0, 0x28(%rbx)
orb $0x4, 0x27(%rbx)
leaq 0x8c02(%rip), %rax      # 0xd338
movq (%rax), %rdi
movq %rbx, %rsi
popq %rbx
jmp 0x4e24
// File: /workspace/github_c_makefile_star2_O3/zuocheng-liu[P]ae-memcached/src/items.c
// Function: item_link_q
void item_link_q(item *it) { /* item is the new head */
    item **head, **tail;
    /* always true, warns: assert(it->slabs_clsid <= LARGEST_ID); */
    assert((it->it_flags & ITEM_SLABBED) == 0);

    head = &heads[it->slabs_clsid];
    tail = &tails[it->slabs_clsid];
    assert(it != *head);
    assert((*head && *tail) || (*head == 0 && *tail == 0));
    it->prev = 0;
    it->next = *head;
    if (it->next) it->next->prev = it;
    *head = it;
    if (*tail == 0) *tail = it;
    sizes[it->slabs_clsid]++;
    return;
}

// Assembly:
movzbl 0x28(%rdi), %eax
leaq 0x8bad(%rip), %rcx      # 0xd350
movq $0x0, 0x8(%rdi)
movq (%rcx,%rax,8), %rdx
movq %rdx, (%rdi)
testq %rdx, %rdx
je 0x47bb
movq %rdi, 0x8(%rdx)
leal (,%rax,8), %edx
movq %rdi, (%rdx,%rcx)
leaq 0x9383(%rip), %rcx      # 0xdb50
cmpq $0x0, (%rdx,%rcx)
jne 0x47d8
movq %rdi, (%rcx,%rax,8)
leaq 0x9b71(%rip), %rcx      # 0xe350
incl (%rcx,%rax,4)
retq
// File: /workspace/github_c_makefile_star2_O3/zuocheng-liu[P]ae-memcached/src/items.c
// Function: item_unlink_q
void item_unlink_q(item *it) {
    item **head, **tail;
    /* always true, warns: assert(it->slabs_clsid <= LARGEST_ID); */
    head = &heads[it->slabs_clsid];
    tail = &tails[it->slabs_clsid];

    if (*head == it) {
        assert(it->prev == 0);
        *head = it->next;
    }
    if (*tail == it) {
        assert(it->next == 0);
        *tail = it->prev;
    }
    assert(it->next != it);
    assert(it->prev != it);

    if (it->next) it->next->prev = it->prev;
    if (it->prev) it->prev->next = it->next;
    sizes[it->slabs_clsid]--;
    return;
}

// Assembly:
movzbl 0x28(%rdi), %eax
leaq 0x8b62(%rip), %rcx      # 0xd350
cmpq %rdi, (%rcx,%rax,8)
jne 0x47fb
movq (%rdi), %rdx
movq %rdx, (%rcx,%rax,8)
leaq 0x934e(%rip), %rcx      # 0xdb50
cmpq %rdi, (%rcx,%rax,8)
jne 0x4810
movq 0x8(%rdi), %rdx
movq %rdx, (%rcx,%rax,8)
movq (%rdi), %rcx
movq 0x8(%rdi), %rdx
testq %rcx, %rcx
je 0x4820
movq %rdx, 0x8(%rcx)
testq %rdx, %rdx
je 0x4828
movq %rcx, (%rdx)
leaq 0x9b21(%rip), %rcx      # 0xe350
decl (%rcx,%rax,4)
retq
// File: /workspace/github_c_makefile_star2_O3/zuocheng-liu[P]ae-memcached/src/items.c
// Function: item_link
int item_link(item *it) {
    assert((it->it_flags & (ITEM_LINKED|ITEM_SLABBED)) == 0);
    assert(it->nbytes < 1048576);
    it->it_flags |= ITEM_LINKED;
    it->time = current_time;
    assoc_insert(ITEM_key(it), it);

    stats.curr_bytes += ITEM_ntotal(it);
    stats.curr_items += 1;
    stats.total_items += 1;

    item_link_q(it);

    return 1;
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
orb $0x1, 0x27(%rdi)
leaq 0x8afe(%rip), %rax      # 0xd340
movl (%rax), %eax
movl %eax, 0x18(%rdi)
addq $0x30, %rdi
movq %rbx, %rsi
callq 0x3893
movzbl 0x29(%rbx), %eax
movzbl 0x26(%rbx), %ecx
addq %rax, %rcx
movslq 0x20(%rbx), %rax
addq %rcx, %rax
leaq 0x8a74(%rip), %rcx      # 0xd2e0
movq 0x8(%rcx), %rdx
addq %rdx, %rax
addq $0x30, %rax
movq %rax, 0x8(%rcx)
movq (%rcx), %xmm0
pcmpeqd %xmm1, %xmm1
psubd %xmm1, %xmm0
movq %xmm0, (%rcx)
movq %rbx, %rdi
callq 0x4798
movl $0x1, %eax
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O3/zuocheng-liu[P]ae-memcached/src/items.c
// Function: item_remove
void item_remove(item *it) {
    assert((it->it_flags & ITEM_SLABBED) == 0);
    if (it->refcount) {
        -- it->refcount;
    }
    assert((it->it_flags & ITEM_DELETED) == 0 || it->refcount);
    if (it->refcount == 0 && (it->it_flags & ITEM_LINKED) == 0) {
        item_free(it);
    }
}

// Assembly:
movq %rdi, %rsi
movzwl 0x24(%rdi), %eax
testw %ax, %ax
je 0x48af
decw %ax
movw %ax, 0x24(%rsi)
jne 0x48e0
movb 0x27(%rsi), %al
testb $0x1, %al
jne 0x48e0
movzbl 0x29(%rsi), %ecx
movzbl 0x26(%rsi), %edx
addl %ecx, %edx
movl 0x20(%rsi), %ecx
addl %ecx, %edx
addl $0x30, %edx
movb $0x0, 0x28(%rsi)
orb $0x4, %al
movb %al, 0x27(%rsi)
leaq 0x8a60(%rip), %rax      # 0xd338
movq (%rax), %rdi
jmp 0x4e24
retq
// File: /workspace/github_c_makefile_star2_O3/zuocheng-liu[P]ae-memcached/src/items.c
// Function: item_update
void item_update(item *it) {
    assert((it->it_flags & ITEM_SLABBED) == 0);

    item_unlink_q(it);
    it->time = current_time;
    item_link_q(it);
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
callq 0x47e3
leaq 0x8a4f(%rip), %rax      # 0xd340
movl (%rax), %eax
movl %eax, 0x18(%rbx)
movq %rbx, %rdi
popq %rbx
jmp 0x4798
// File: /workspace/github_c_makefile_star2_O3/zuocheng-liu[P]ae-memcached/src/items.c
// Function: item_cachedump
char *item_cachedump(unsigned int slabs_clsid, unsigned int limit, unsigned int *bytes) {

    int memlimit = 2*1024*1024;
    char *buffer;
    int bufcurr;
    item *it;
    int len;
    int shown = 0;
    char temp[512];

    if (slabs_clsid > LARGEST_ID) return 0;
    it = heads[slabs_clsid];

    buffer = malloc(memlimit);
    if (buffer == 0) return 0;
    bufcurr = 0;

    while (it && (!limit || shown < (int)limit)) {
        len = sprintf(temp, "ITEM %s [%u b; %lu s]\r\n", ITEM_key(it), it->nbytes - 2, it->time + stats.started);
        if (bufcurr + len + 6 > memlimit)  /* 6 is END\r\n\0 */
            break;
        strcpy(buffer + bufcurr, temp);
        bufcurr+=len;
        shown++;
        it = it->next;
    }

    strcpy(buffer+bufcurr, "END\r\n");
    bufcurr+=5;

    *bytes = bufcurr;
    return buffer;
}

// Assembly:
cmpl $0xff, %edi
jbe 0x4922
xorl %eax, %eax
retq
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x218, %rsp            # imm = 0x218
movq %rdx, %rbx
movl %esi, %ebp
movl %edi, %r15d
movl $0x200000, %edi         # imm = 0x200000
callq 0x22c0
xorl %r13d, %r13d
testq %rax, %rax
je 0x49e2
movq %rax, (%rsp)
movq %rbx, 0x8(%rsp)
movl %r15d, %eax
leaq 0x89ec(%rip), %rcx      # 0xd350
movq (%rcx,%rax,8), %rbx
testq %rbx, %rbx
je 0x49e9
xorl %r15d, %r15d
xorl %r12d, %r12d
testl %ebp, %ebp
sete %al
cmpl %ebp, %r15d
setl %cl
orb %al, %cl
cmpb $0x1, %cl
jne 0x49e6
leaq 0x30(%rbx), %rdx
movl 0x18(%rbx), %r8d
movl 0x20(%rbx), %ecx
addl $-0x2, %ecx
leaq 0x8946(%rip), %rax      # 0xd2e0
addq 0x40(%rax), %r8
leaq 0x10(%rsp), %r14
movq %r14, %rdi
leaq 0x38d7(%rip), %rsi      # 0x8284
xorl %eax, %eax
callq 0x2400
movl %eax, %r13d
addl %r12d, %r13d
cmpl $0x1ffffa, %r13d        # imm = 0x1FFFFA
jg 0x49e6
movslq %r12d, %rdi
addq (%rsp), %rdi
movq %r14, %rsi
callq 0x2090
incl %r15d
movq (%rbx), %rbx
movl %r13d, %r12d
testq %rbx, %rbx
jne 0x4973
jmp 0x49e9
xorl %eax, %eax
jmp 0x4a08
movl %r12d, %r13d
movslq %r13d, %rdx
movq (%rsp), %rax
movw $0xa, 0x4(%rax,%rdx)
movl $0xd444e45, (%rax,%rdx) # imm = 0xD444E45
addl $0x5, %edx
movq 0x8(%rsp), %rcx
movl %edx, (%rcx)
addq $0x218, %rsp            # imm = 0x218
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/zuocheng-liu[P]ae-memcached/src/items.c
// Function: item_stats
void item_stats(char *buffer, int buflen) {
    int i;
    char *bufcurr = buffer;
    rel_time_t now = current_time;

    if (buflen < 4096) {
        strcpy(buffer, "SERVER_ERROR out of memory");
        return;
    }

    for (i=0; i<LARGEST_ID; i++) {
        if (tails[i])
            bufcurr += sprintf(bufcurr, "STAT items:%u:number %u\r\nSTAT items:%u:age %u\r\n",
                               i, sizes[i], i, now - tails[i]->time);
    }
    strcpy(bufcurr, "END");
    return;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
leaq 0x8911(%rip), %rax      # 0xd340
movl (%rax), %ebp
cmpl $0x1000, %esi           # imm = 0x1000
jge 0x4a50
movups 0x386d(%rip), %xmm0     # 0x82ad
movups %xmm0, 0xb(%rbx)
movups 0x3857(%rip), %xmm0     # 0x82a2
movups %xmm0, (%rbx)
jmp 0x4aae
leaq 0x98f9(%rip), %r12      # 0xe350
leaq 0x90f2(%rip), %r13      # 0xdb50
leaq 0x3858(%rip), %r14      # 0x82bd
xorl %r15d, %r15d
movq (%r13), %rax
testq %rax, %rax
je 0x4a94
movl (%r12), %ecx
movl %ebp, %r9d
subl 0x18(%rax), %r9d
movq %rbx, %rdi
movq %r14, %rsi
movl %r15d, %edx
movl %r15d, %r8d
xorl %eax, %eax
callq 0x2400
cltq
addq %rax, %rbx
incq %r15
addq $0x4, %r12
addq $0x8, %r13
cmpq $0xff, %r15
jne 0x4a68
movl $0x444e45, (%rbx)       # imm = 0x444E45
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/zuocheng-liu[P]ae-memcached/src/items.c
// Function: item_stats_sizes
char* item_stats_sizes(int *bytes) {
    int num_buckets = 32768;   /* max 1MB object, divided into 32 bytes size buckets */
    unsigned int *histogram = (unsigned int*) malloc(num_buckets * sizeof(int));
    char *buf = (char*) malloc(1024*1024*2*sizeof(char));
    int i;

    if (histogram == 0 || buf == 0) {
        if (histogram) free(histogram);
        if (buf) free(buf);
        return 0;
    }

    /* build the histogram */
    memset(histogram, 0, num_buckets * sizeof(int));
    for (i=0; i<LARGEST_ID; i++) {
        item *iter = heads[i];
        while (iter) {
            int ntotal = ITEM_ntotal(iter);
            int bucket = ntotal / 32;
            if (ntotal % 32) bucket++;
            if (bucket < num_buckets) histogram[bucket]++;
            iter = iter->next;
        }
    }

    /* write the buffer */
    *bytes = 0;
    for (i=0; i<num_buckets; i++) {
        if (histogram[i]) {
            *bytes += sprintf(&buf[*bytes], "%u %u\r\n", i*32, histogram[i]);
        }
    }
    *bytes += sprintf(&buf[*bytes], "END\r\n");
    free(histogram);
    return buf;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %r15
movl $0x20000, %edi          # imm = 0x20000
callq 0x22c0
movq %rax, %r14
movl $0x200000, %edi         # imm = 0x200000
callq 0x22c0
movq %rax, %rbx
testq %r14, %r14
setne %al
testq %rbx, %rbx
setne %cl
testb %cl, %al
jne 0x4b1a
testq %r14, %r14
je 0x4b02
movq %r14, %rdi
callq 0x2030
xorl %eax, %eax
movq %rbx, %r14
testq %rbx, %rbx
movl $0x0, %ebx
jne 0x4be2
jmp 0x4bed
xorl %r12d, %r12d
movl $0x20000, %edx          # imm = 0x20000
movq %r14, %rdi
xorl %esi, %esi
callq 0x2190
leaq 0x881d(%rip), %rax      # 0xd350
movq (%rax,%r12,8), %rcx
testq %rcx, %rcx
je 0x4b79
movzbl 0x29(%rcx), %edx
movzbl 0x26(%rcx), %esi
addl %edx, %esi
movl 0x20(%rcx), %edx
leal (%rdx,%rsi), %edi
addl $0x30, %edi
addl %esi, %edx
addl $0x4f, %edx
testl %edi, %edi
cmovnsl %edi, %edx
sarl $0x5, %edx
andl $0x1f, %edi
cmpl $0x1, %edi
sbbl $-0x1, %edx
cmpl $0x7fff, %edx           # imm = 0x7FFF
jg 0x4b74
movslq %edx, %rdx
incl (%r14,%rdx,4)
movq (%rcx), %rcx
jmp 0x4b37
incq %r12
cmpq $0xff, %r12
jne 0x4b33
movl $0x0, (%r15)
leaq 0x36e9(%rip), %r12      # 0x827c
movq %r14, %rbp
xorl %r13d, %r13d
xorl %eax, %eax
movl (%rbp), %ecx
testl %ecx, %ecx
je 0x4bbb
movslq %eax, %rdi
addq %rbx, %rdi
movq %r12, %rsi
movl %r13d, %edx
xorl %eax, %eax
callq 0x2400
addl (%r15), %eax
movl %eax, (%r15)
addq $0x20, %r13
addq $0x4, %rbp
cmpq $0x100000, %r13         # imm = 0x100000
jne 0x4b9b
cltq
movw $0xa, 0x4(%rbx,%rax)
movl $0xd444e45, (%rbx,%rax) # imm = 0xD444E45
addl $0x5, %eax
movl %eax, (%r15)
movq %r14, %rdi
callq 0x2030
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/zuocheng-liu[P]ae-memcached/src/mem_cache.c
// Function: mem_cache_alloc
void *mem_cache_alloc(mem_cache_ptr mem_cache, size_t size) {
    void *ptr;
    slab_ptr slab;
    size_t org_page_total;
    
    if (NULL == mem_cache || size <= 0) {
        return 0;
    }

    if (mem_cache->mem_malloced >= mem_cache->mem_limit) {
        return NULL;
    }

    size_t slab_id = mem_cache_clsid(mem_cache, size);
    if (slab_id <= 0) {
        return NULL;
    }

    slab = mem_cache->slabclass[slab_id];
    org_page_total = slab->page_total;
    ptr = slab_alloc_chunk(slab);

    if (NULL == ptr) {
        return NULL;
    }

    if (org_page_total < slab->page_total) {
        mem_cache->mem_malloced += slab->page_size;
    }

    return ptr;
}

// Assembly:
testq %rdi, %rdi
sete %al
testq %rsi, %rsi
sete %cl
orb %al, %cl
je 0x4d89
xorl %eax, %eax
retq
pushq %r15
pushq %r14
pushq %rbx
movq %rdi, %rbx
movq 0x30(%rdi), %rax
cmpq 0x28(%rdi), %rax
jae 0x4dec
movq 0x18(%rbx), %rcx
movq 0x38(%rbx), %rdx
movq (%rdx,%rcx,8), %r14
cmpq %rsi, (%r14)
jae 0x4dc6
movq 0x20(%rbx), %rdi
xorl %eax, %eax
cmpq %rdi, %rcx
jae 0x4dee
movq 0x8(%rdx,%rcx,8), %r14
incq %rcx
cmpq %rsi, (%r14)
jb 0x4db2
jmp 0x4dcb
testq %rcx, %rcx
je 0x4dec
movq 0x28(%r14), %r15
movq %r14, %rdi
callq 0x7b35
testq %rax, %rax
je 0x4dec
cmpq 0x28(%r14), %r15
jae 0x4dee
movq 0x8(%r14), %rcx
addq %rcx, 0x30(%rbx)
jmp 0x4dee
xorl %eax, %eax
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O3/zuocheng-liu[P]ae-memcached/src/mem_cache.c
// Function: mem_cache_clsid
size_t mem_cache_clsid(mem_cache_ptr mem_cache, size_t size) {
    size_t res;
    if(0 == size) {
        return 0;
    }

    res = mem_cache->power_smallest;
    while (size > mem_cache->slabclass[res]->chunk_size) {
        /* won't fit in the biggest slab */
        if (res >= mem_cache->power_largest) {
            return 0;
        }
        ++ res;
    }
    return res;
}

// Assembly:
testq %rsi, %rsi
je 0x4e21
movq 0x18(%rdi), %rax
movq 0x38(%rdi), %rcx
movq (%rcx,%rax,8), %rdx
cmpq %rsi, (%rdx)
jae 0x4e20
movq 0x20(%rdi), %rdx
cmpq %rdx, %rax
jae 0x4e21
movq 0x8(%rcx,%rax,8), %rdi
incq %rax
cmpq %rsi, (%rdi)
jb 0x4e0e
retq
xorl %eax, %eax
retq
// File: /workspace/github_c_makefile_star2_O3/zuocheng-liu[P]ae-memcached/src/memcached.c
// Function: get_item_notedeleted
item *get_item_notedeleted(char *key, int *delete_locked) {
    item *it = assoc_find(key);
    if (delete_locked) *delete_locked = 0;
    if (it && (it->it_flags & ITEM_DELETED)) {
        /* it's flagged as delete-locked.  let's see if that condition
           is past due, and the 5-second delete_timer just hasn't
           gotten to it yet... */
        if (! item_delete_lock_over(it)) {
            if (delete_locked) *delete_locked = 1;
            it = 0;
        }
    }
    if (it && settings.oldest_live && settings.oldest_live <= current_time &&
        it->time <= settings.oldest_live) {
        item_unlink(it);
        it = 0;
    }
    if (it && it->exptime && it->exptime <= current_time) {
        item_unlink(it);
        it = 0;
    }
    return it;
}

// Assembly:
pushq %rbx
movq %rsi, %rbx
callq 0x3837
testq %rbx, %rbx
je 0x4e8a
movl $0x0, (%rbx)
testq %rax, %rax
je 0x4f0c
testb $0x2, 0x27(%rax)
je 0x4eb4
testq %rbx, %rbx
sete %cl
leaq 0x849e(%rip), %rdx      # 0xd340
movl (%rdx), %edx
xorl %esi, %esi
cmpl 0x1c(%rax), %edx
setae %dl
cmovbq %rsi, %rax
orb %cl, %dl
je 0x4f06
testq %rax, %rax
setne %dl
leaq 0x83c7(%rip), %rcx      # 0xd288
movl 0x1c(%rcx), %ecx
testl %ecx, %ecx
setne %sil
andb %dl, %sil
cmpb $0x1, %sil
jne 0x4ee5
leaq 0x8466(%rip), %rdx      # 0xd340
cmpl (%rdx), %ecx
ja 0x4eea
cmpl %ecx, 0x18(%rax)
ja 0x4eea
jmp 0x4efc
testq %rax, %rax
je 0x4f0c
movl 0x1c(%rax), %ecx
testl %ecx, %ecx
je 0x4f0e
leaq 0x8448(%rip), %rdx      # 0xd340
cmpl (%rdx), %ecx
ja 0x4f0e
movq %rax, %rdi
callq 0x46bd
jmp 0x4f0c
movl $0x1, (%rbx)
xorl %eax, %eax
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O3/zuocheng-liu[P]ae-memcached/src/memcached.c
// Function: ensure_iov_space
int ensure_iov_space(conn *c) {
    if (c->iovused >= c->iovsize) {
        int i, iovnum;
        struct iovec *new_iov = (struct iovec *) realloc(c->iov,
                                (c->iovsize * 2) * sizeof(struct iovec));
        if (! new_iov)
            return -1;
        c->iov = new_iov;
        c->iovsize *= 2;

        /* Point all the msghdr structures at the new list. */
        for (i = 0, iovnum = 0; i < c->msgused; i++) {
            c->msglist[i].msg_iov = &c->iov[iovnum];
            iovnum += c->msglist[i].msg_iovlen;
        }
    }

    return 0;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movslq 0x80(%rdi), %rsi
xorl %ebx, %ebx
cmpl %esi, 0x84(%rdi)
jl 0x4f90
movq %rdi, %r14
movq 0x78(%rdi), %rdi
shlq $0x5, %rsi
callq 0x2310
testq %rax, %rax
je 0x4f8b
movq %rax, 0x78(%r14)
shll 0x80(%r14)
movslq 0x94(%r14), %rdx
testq %rdx, %rdx
jle 0x4f90
movq 0x88(%r14), %rcx
imulq $0x38, %rdx, %rdx
xorl %ebx, %ebx
xorl %esi, %esi
xorl %edi, %edi
movslq %edi, %rdi
movq %rdi, %r8
shlq $0x4, %r8
addq %rax, %r8
movq %r8, 0x10(%rcx,%rsi)
addq 0x18(%rcx,%rsi), %rdi
addq $0x38, %rsi
cmpq %rsi, %rdx
jne 0x4f69
jmp 0x4f90
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O3/zuocheng-liu[P]ae-memcached/src/memcached.c
// Function: build_udp_headers
int build_udp_headers(conn *c) {
    int i;
    unsigned char *hdr;

    if (c->msgused > c->hdrsize) {
        void *new_hdrbuf;
        if (c->hdrbuf)
            new_hdrbuf = realloc(c->hdrbuf, c->msgused * 2 * UDP_HEADER_SIZE);
        else
            new_hdrbuf = malloc(c->msgused * 2 * UDP_HEADER_SIZE);
        if (! new_hdrbuf)
            return -1;
        c->hdrbuf = (unsigned char *) new_hdrbuf;
        c->hdrsize = c->msgused * 2;
    }

    hdr = c->hdrbuf;
    for (i = 0; i < c->msgused; i++) {
        c->msglist[i].msg_iov[0].iov_base = hdr;
        c->msglist[i].msg_iov[0].iov_len = UDP_HEADER_SIZE;
        *hdr++ = c->request_id / 256;
        *hdr++ = c->request_id % 256;
        *hdr++ = i / 256;
        *hdr++ = i % 256;
        *hdr++ = c->msgused / 256;
        *hdr++ = c->msgused % 256;
        *hdr++ = 0;
        *hdr++ = 0;
        assert((void*) hdr == (void*) c->msglist[i].msg_iov[0].iov_base + UDP_HEADER_SIZE);
    }

    return 0;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %r14
movl 0x94(%rdi), %eax
cmpl 0xe0(%rdi), %eax
jle 0x4ff2
movslq %eax, %rsi
movq 0xd8(%r14), %rdi
shlq $0x4, %rsi
testq %rdi, %rdi
je 0x4fc9
callq 0x2310
jmp 0x4fd1
movq %rsi, %rdi
callq 0x22c0
testq %rax, %rax
je 0x5088
movq %rax, 0xd8(%r14)
movl 0x94(%r14), %eax
leal (%rax,%rax), %ecx
movl %ecx, 0xe0(%r14)
testl %eax, %eax
jle 0x5083
movq 0xd8(%r14), %rcx
movl $0x2, %r8d
xorl %r9d, %r9d
movl $0xff, %esi
xorl %eax, %eax
movq 0x88(%r14), %rdi
movq (%rdi,%r8,8), %rdi
movq %rcx, (%rdi)
movq $0x8, 0x8(%rdi)
movl 0xc0(%r14), %edi
leal (%rdi,%rsi), %edx
testl %edi, %edi
cmovnsl %edi, %edx
movb %dh, (%rcx)
movb 0xc0(%r14), %dl
movb %dl, 0x1(%rcx)
movb %ah, 0x2(%rcx)
movb %al, 0x3(%rcx)
movl 0x94(%r14), %edx
leal (%rdx,%rsi), %ebx
testl %edx, %edx
cmovnsl %edx, %ebx
movb %bh, 0x4(%rcx)
movb 0x94(%r14), %dl
movb %dl, 0x5(%rcx)
movw $0x0, 0x6(%rcx)
incq %rax
movslq 0x94(%r14), %rdx
addq $0x7, %r8
addq $0x8, %rcx
cmpq %rdx, %rax
jl 0x5011
jmp 0x508e
xorl %r9d, %r9d
jmp 0x508e
movl $0xffffffff, %r9d       # imm = 0xFFFFFFFF
movl %r9d, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O3/zuocheng-liu[P]ae-memcached/src/memcached.c
// Function: complete_nread
void complete_nread(conn *c) {
    item *it = c->item;
    int comm = c->item_comm;
    item *old_it;
    int delete_locked = 0;
    char *key = ITEM_key(it);

    stats.set_cmds++;

    if (strncmp(ITEM_data(it) + it->nbytes - 2, "\r\n", 2) != 0) {
        out_string(c, "CLIENT_ERROR bad data chunk");
        goto err;
    }

    old_it = get_item_notedeleted(key, &delete_locked);

    if (old_it && comm == NREAD_ADD) {
        item_update(old_it);  /* touches item, promotes to head of LRU */
        out_string(c, "NOT_STORED");
        goto err;
    }

    if (!old_it && comm == NREAD_REPLACE) {
        out_string(c, "NOT_STORED");
        goto err;
    }

    if (delete_locked) {
        if (comm == NREAD_REPLACE || comm == NREAD_ADD) {
            out_string(c, "NOT_STORED");
            goto err;
        }

        /* but "set" commands can override the delete lock
         window... in which case we have to find the old hidden item
         that's in the namespace/LRU but wasn't returned by
         get_item.... because we need to replace it (below) */
        old_it = assoc_find(key);
    }

    if (old_it)
        item_replace(old_it, it);
    else
        item_link(it);

    c->item = 0;
    out_string(c, "STORED");
    return;

err:
     item_free(it);
     c->item = 0;
     return;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x68(%rdi), %r14
movl 0x70(%rdi), %ebp
leaq 0x822f(%rip), %rax      # 0xd2e0
incq 0x28(%rax)
movl $0x0, 0x4(%rsp)
movzbl 0x29(%r14), %eax
leaq (%r14,%rax), %rcx
addq $0x30, %rcx
movzbl 0x26(%r14), %eax
addq %rcx, %rax
movslq 0x20(%r14), %rcx
cmpb $0xd, -0x2(%rcx,%rax)
jne 0x5112
cmpb $0xa, -0x1(%rax,%rcx)
jne 0x5112
leaq 0x30(%r14), %r15
leaq 0x4(%rsp), %rsi
movq %r15, %rdi
callq 0x4e76
testq %rax, %rax
setne %cl
cmpl $0x1, %ebp
sete %dl
andb %cl, %dl
cmpb $0x1, %dl
jne 0x511b
movq %rax, %rdi
callq 0x48e1
jmp 0x513d
leaq 0x3257(%rip), %rsi      # 0x8370
jmp 0x5144
testq %rax, %rax
sete %cl
cmpl $0x3, %ebp
sete %dl
andb %cl, %dl
cmpb $0x1, %dl
je 0x513d
cmpl $0x0, 0x4(%rsp)
je 0x516f
orl $0x2, %ebp
cmpl $0x3, %ebp
jne 0x5167
leaq 0x3248(%rip), %rsi      # 0x838c
movq %rbx, %rdi
callq 0x41b0
movq %r14, %rdi
callq 0x4742
movq $0x0, 0x68(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq %r15, %rdi
callq 0x3837
testq %rax, %rax
je 0x5181
movq %rax, %rdi
movq %r14, %rsi
callq 0x48ff
jmp 0x5189
movq %r14, %rdi
callq 0x4833
movq $0x0, 0x68(%rbx)
leaq 0x31f8(%rip), %rsi      # 0x8390
movq %rbx, %rdi
callq 0x41b0
jmp 0x515c
// File: /workspace/github_c_makefile_star2_O3/zuocheng-liu[P]ae-memcached/src/memcached.c
// Function: command_replace
int32_t command_replace(char *command, conn *c, int com_type) {
    int comm = com_type;
    char key[251];
    int flags;
    time_t expire;
    int len, res;
    item *it;

    res = sscanf(command, "%*s %250s %u %ld %d\n", key, &flags, &expire, &len);
    if (res!=4 || strlen(key)==0 ) {
        out_string(c, "CLIENT_ERROR bad command line format");
        return COMMAND_OK;
    }

    if (settings.managed) {
        int bucket = c->bucket;
        if (bucket == -1) {
            out_string(c, "CLIENT_ERROR no BG data in managed mode");
            return COMMAND_OK;
        }
        c->bucket = -1;
        if (buckets[bucket] != c->gen) {
            out_string(c, "ERROR_NOT_OWNER");
            return COMMAND_OK;
        }
    }

    expire = realtime(expire, &stats);
    it = item_alloc(key, flags, expire, len+2);

    if (it == 0) {
        if (! item_size_ok(key, flags, len + 2))
            out_string(c, "SERVER_ERROR object too large for cache");
        else
            out_string(c, "SERVER_ERROR out of memory");
        /* swallow the data line */
        c->write_and_go = conn_swallow;
        c->sbytes = len+2;
        return COMMAND_OK;
    }

    c->item_comm = comm;
    c->item = it;
    c->ritem = ITEM_data(it);
    c->rlbytes = it->nbytes;
    conn_set_state(c, conn_nread);
    return COMMAND_OK;
}

// Assembly:
pushq %rbp
pushq %rbx
subq $0x118, %rsp            # imm = 0x118
movl %edx, %ebp
movq %rsi, %rbx
leaq 0x2f92(%rip), %rsi      # 0x83fc
leaq 0x10(%rsp), %rdx
leaq 0x4(%rsp), %rcx
leaq 0x8(%rsp), %r8
movq %rsp, %r9
xorl %eax, %eax
callq 0x22d0
cmpl $0x4, %eax
jne 0x553a
cmpb $0x0, 0x10(%rsp)
je 0x553a
leaq 0x7dea(%rip), %rax      # 0xd288
cmpl $0x0, 0x20(%rax)
je 0x54d5
movslq 0xe8(%rbx), %rax
cmpq $-0x1, %rax
je 0x5555
movl $0xffffffff, 0xe8(%rbx) # imm = 0xFFFFFFFF
movq 0x928a(%rip), %rcx      # 0xe750
movl (%rcx,%rax,4), %eax
cmpl 0xec(%rbx), %eax
jne 0x55a0
movq 0x8(%rsp), %rdi
leaq 0x7dff(%rip), %rsi      # 0xd2e0
callq 0x7759
movl %eax, %ecx
movq %rcx, 0x8(%rsp)
movl 0x4(%rsp), %esi
movl (%rsp), %ecx
addl $0x2, %ecx
leaq 0x10(%rsp), %rdi
movl %eax, %edx
callq 0x457b
testq %rax, %rax
je 0x555e
movl %ebp, 0x70(%rbx)
movq %rax, 0x68(%rbx)
movzbl 0x29(%rax), %ecx
addq %rax, %rcx
movzbl 0x26(%rax), %edx
addq %rdx, %rcx
addq $0x30, %rcx
movq %rcx, 0x58(%rbx)
movl 0x20(%rax), %eax
movl %eax, 0x60(%rbx)
movq %rbx, %rdi
movl $0x3, %esi
callq 0x4189
jmp 0x5549
leaq 0x2ed0(%rip), %rsi      # 0x8411
movq %rbx, %rdi
callq 0x41b0
xorl %eax, %eax
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %rbp
retq
leaq 0x2e3b(%rip), %rsi      # 0x8397
jmp 0x5541
movl 0x4(%rsp), %esi
movl (%rsp), %edx
addl $0x2, %edx
leaq 0x10(%rsp), %rdi
callq 0x476f
testl %eax, %eax
leaq 0x2ebb(%rip), %rax      # 0x8436
leaq 0x2d20(%rip), %rsi      # 0x82a2
cmoveq %rax, %rsi
movq %rbx, %rdi
callq 0x41b0
movl $0x4, 0x48(%rbx)
movl (%rsp), %eax
addl $0x2, %eax
movl %eax, 0x74(%rbx)
jmp 0x5549
leaq 0x2e18(%rip), %rsi      # 0x83bf
jmp 0x5541
// File: /workspace/github_c_makefile_star2_O3/zuocheng-liu[P]ae-memcached/src/memcached.c
// Function: own_handler
int32_t own_handler(char *command, int argc, char ** argv) {
    AE_NOTUSED(argc); 
    int bucket, gen;
    char *start = command+4;
    conn *c = (conn*)argv;
    if (!settings.managed) {
        out_string(c, "CLIENT_ERROR not a managed instance");
        return COMMAND_OK;
    }
    if (sscanf(start, "%u:%u\r\n", &bucket,&gen) == 2) {
        if ((bucket < 0) || (bucket >= MAX_BUCKETS)) {
            out_string(c, "CLIENT_ERROR bucket number out of range");
            return COMMAND_OK;
        }
        buckets[bucket] = gen;
        out_string(c, "OWNED");
        return COMMAND_OK;
    } else {
        out_string(c, "CLIENT_ERROR bad format");
        return COMMAND_OK;
    }
}

// Assembly:
pushq %rbx
subq $0x10, %rsp
movq %rdx, %rbx
leaq 0x790e(%rip), %rax      # 0xd288
cmpl $0x0, 0x20(%rax)
je 0x59b6
addq $0x4, %rdi
leaq 0x2b2e(%rip), %rsi      # 0x84b9
leaq 0xc(%rsp), %rdx
leaq 0x8(%rsp), %rcx
xorl %eax, %eax
callq 0x22d0
cmpl $0x2, %eax
jne 0x59bf
movl 0xc(%rsp), %eax
cmpq $0x8000, %rax           # imm = 0x8000
jb 0x59c8
leaq 0x2b0d(%rip), %rsi      # 0x84c1
jmp 0x59dd
leaq 0x2ad8(%rip), %rsi      # 0x8495
jmp 0x59dd
leaq 0x2b23(%rip), %rsi      # 0x84e9
jmp 0x59dd
movl 0x8(%rsp), %ecx
movq 0x8d7d(%rip), %rdx      # 0xe750
movl %ecx, (%rdx,%rax,4)
leaq 0x2b27(%rip), %rsi      # 0x8504
movq %rbx, %rdi
callq 0x41b0
xorl %eax, %eax
addq $0x10, %rsp
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O3/zuocheng-liu[P]ae-memcached/src/memcached.c
// Function: disown_handler
int32_t disown_handler(char *command, int argc, char ** argv) {
    AE_NOTUSED(argc); 
    int bucket;
    char *start = command+7;
    conn *c = (conn*)argv;
    if (!settings.managed) {
        out_string(c, "CLIENT_ERROR not a managed instance");
        return COMMAND_OK;
    }
    if (sscanf(start, "%u\r\n", &bucket) == 1) {
        if ((bucket < 0) || (bucket >= MAX_BUCKETS)) {
            out_string(c, "CLIENT_ERROR bucket number out of range");
            return COMMAND_OK;
        }
        buckets[bucket] = 0;
        out_string(c, "DISOWNED");
        return COMMAND_OK;
    } else {
        out_string(c, "CLIENT_ERROR bad format");
        return COMMAND_OK;
    }
}

// Assembly:
pushq %rbx
subq $0x10, %rsp
movq %rdx, %rbx
leaq 0x788c(%rip), %rax      # 0xd288
cmpl $0x0, 0x20(%rax)
je 0x5a33
addq $0x7, %rdi
leaq 0x2b06(%rip), %rsi      # 0x8513
leaq 0xc(%rsp), %rdx
xorl %eax, %eax
callq 0x22d0
cmpl $0x1, %eax
jne 0x5a3c
movl 0xc(%rsp), %eax
cmpq $0x8000, %rax           # imm = 0x8000
jb 0x5a45
leaq 0x2a90(%rip), %rsi      # 0x84c1
jmp 0x5a5a
leaq 0x2a5b(%rip), %rsi      # 0x8495
jmp 0x5a5a
leaq 0x2aa6(%rip), %rsi      # 0x84e9
jmp 0x5a5a
movq 0x8d04(%rip), %rcx      # 0xe750
movl $0x0, (%rcx,%rax,4)
leaq 0x2aa7(%rip), %rsi      # 0x8501
movq %rbx, %rdi
callq 0x41b0
xorl %eax, %eax
addq $0x10, %rsp
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O3/zuocheng-liu[P]ae-memcached/src/memcached.c
// Function: stats_reset_handler
int32_t stats_reset_handler(char *command, int argc, char ** argv) {
    AE_NOTUSED(command); 
    AE_NOTUSED(argc); 
    conn *c = (conn*)argv;
    stats_reset(&stats);
    out_string(c, "RESET");
    return COMMAND_OK;
}

// Assembly:
pushq %rbx
movq %rdx, %rbx
leaq 0x75cd(%rip), %rdi      # 0xd2e0
callq 0x7c36
leaq 0x29b7(%rip), %rsi      # 0x86d6
movq %rbx, %rdi
callq 0x41b0
xorl %eax, %eax
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O3/zuocheng-liu[P]ae-memcached/src/memcached.c
// Function: stats_malloc_handler
int32_t stats_malloc_handler(char *command, int argc, char ** argv) {
    AE_NOTUSED(command); 
    AE_NOTUSED(argc); 
    conn *c = (conn*)argv;
    char temp[512];
    struct mallinfo info;
    char *pos = temp;
    info = mallinfo();
    pos += sprintf(pos, "STAT arena_size %d\r\n", info.arena);
    pos += sprintf(pos, "STAT free_chunks %d\r\n", info.ordblks);
    pos += sprintf(pos, "STAT fastbin_blocks %d\r\n", info.smblks);
    pos += sprintf(pos, "STAT mmapped_regions %d\r\n", info.hblks);
    pos += sprintf(pos, "STAT mmapped_space %d\r\n", info.hblkhd);
    pos += sprintf(pos, "STAT max_total_alloc %d\r\n", info.usmblks);
    pos += sprintf(pos, "STAT fastbin_space %d\r\n", info.fsmblks);
    pos += sprintf(pos, "STAT total_alloc %d\r\n", info.uordblks);
    pos += sprintf(pos, "STAT total_free %d\r\n", info.fordblks);
    pos += sprintf(pos, "STAT releasable_space %d\r\nEND", info.keepcost);
    out_string(c, temp);
    return COMMAND_OK;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x228, %rsp            # imm = 0x228
movq %rdx, 0x18(%rsp)
leaq 0x20(%rsp), %r12
movq %r12, %rdi
callq 0x2170
movl (%r12), %edx
movl 0x4(%r12), %r13d
movl 0x8(%r12), %r15d
movl 0xc(%r12), %ebp
movl 0x10(%r12), %ebx
movl 0x14(%r12), %r14d
movl 0x18(%r12), %eax
movl %eax, 0x8(%rsp)
movl 0x1c(%r12), %eax
movl %eax, 0xc(%rsp)
movl 0x20(%r12), %eax
movl %eax, 0x10(%rsp)
movl 0x24(%r12), %eax
movl %eax, 0x14(%rsp)
leaq 0x2946(%rip), %rsi      # 0x86dc
leaq 0x20(%rsp), %rdi
xorl %eax, %eax
callq 0x2400
cltq
leaq (%rsp,%rax), %r12
addq $0x20, %r12
leaq 0x293e(%rip), %rsi      # 0x86f1
movq %r12, %rdi
movl %r13d, %edx
xorl %eax, %eax
callq 0x2400
movslq %eax, %r13
addq %r12, %r13
leaq 0x293a(%rip), %rsi      # 0x8707
movq %r13, %rdi
movl %r15d, %edx
xorl %eax, %eax
callq 0x2400
movslq %eax, %r15
addq %r13, %r15
leaq 0x2939(%rip), %rsi      # 0x8720
movq %r15, %rdi
movl %ebp, %edx
xorl %eax, %eax
callq 0x2400
movslq %eax, %r12
addq %r15, %r12
leaq 0x293a(%rip), %rsi      # 0x873a
movq %r12, %rdi
movl %ebx, %edx
xorl %eax, %eax
callq 0x2400
movslq %eax, %rbx
addq %r12, %rbx
leaq 0x2939(%rip), %rsi      # 0x8752
movq %rbx, %rdi
movl %r14d, %edx
xorl %eax, %eax
callq 0x2400
movslq %eax, %r14
addq %rbx, %r14
leaq 0x2939(%rip), %rsi      # 0x876c
movq %r14, %rdi
movl 0x8(%rsp), %edx
xorl %eax, %eax
callq 0x2400
movslq %eax, %rbx
addq %r14, %rbx
leaq 0x2936(%rip), %rsi      # 0x8784
movq %rbx, %rdi
movl 0xc(%rsp), %edx
xorl %eax, %eax
callq 0x2400
movslq %eax, %r14
addq %rbx, %r14
leaq 0x2931(%rip), %rsi      # 0x879a
movq %r14, %rdi
movl 0x10(%rsp), %edx
xorl %eax, %eax
callq 0x2400
movslq %eax, %rdi
addq %r14, %rdi
leaq 0x292b(%rip), %rsi      # 0x87af
movl 0x14(%rsp), %edx
xorl %eax, %eax
callq 0x2400
movq 0x18(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0x41b0
xorl %eax, %eax
addq $0x228, %rsp            # imm = 0x228
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/zuocheng-liu[P]ae-memcached/src/memcached.c
// Function: stats_maps_handler
int32_t stats_maps_handler(char *command, int argc, char ** argv) {
    AE_NOTUSED(command); 
    AE_NOTUSED(argc); 
    char *wbuf;
    int wsize = 8192; /* should be enough */
    int fd;
    int res;
    conn *c = (conn*)argv;

    wbuf = (char *)malloc(wsize);
    if (wbuf == 0) {
        out_string(c, "SERVER_ERROR out of memory");
        return COMMAND_OK;
    }

    fd = open("/proc/self/maps", O_RDONLY);
    if (fd == -1) {
        out_string(c, "SERVER_ERROR cannot open the maps file");
        free(wbuf);
        return COMMAND_OK;
    }

    res = read(fd, wbuf, wsize - 6);  /* 6 = END\r\n\0 */
    if (res == wsize - 6) {
        out_string(c, "SERVER_ERROR buffer overflow");
        free(wbuf); close(fd);
        return COMMAND_OK;
    }
    if (res == 0 || res == -1) {
        out_string(c, "SERVER_ERROR can't read the maps file");
        free(wbuf); close(fd);
        return COMMAND_OK;
    }
    strcpy(wbuf + res, "END\r\n");
    c->write_and_free=wbuf;
    c->wcurr=wbuf;
    c->wbytes = res + 6;
    conn_set_state(c, conn_write);
    c->write_and_go = conn_read;
    close(fd);

    return COMMAND_OK;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movq %rdx, %rbx
movl $0x2000, %edi           # imm = 0x2000
callq 0x22c0
testq %rax, %rax
je 0x5f01
movq %rax, %r14
leaq 0x28fb(%rip), %rdi      # 0x87cd
xorl %esi, %esi
xorl %eax, %eax
callq 0x2380
cmpl $-0x1, %eax
je 0x5f12
movl %eax, %ebp
movl $0x1ffa, %edx           # imm = 0x1FFA
movl %eax, %edi
movq %r14, %rsi
callq 0x21f0
cmpl $0x1ffa, %eax           # imm = 0x1FFA
jne 0x5f2b
leaq 0x2905(%rip), %rsi      # 0x8804
jmp 0x5f3a
leaq 0x239a(%rip), %rsi      # 0x82a2
movq %rbx, %rdi
callq 0x41b0
jmp 0x5f88
leaq 0x28c4(%rip), %rsi      # 0x87dd
movq %rbx, %rdi
callq 0x41b0
movq %r14, %rdi
callq 0x2030
jmp 0x5f88
leal 0x1(%rax), %ecx
cmpl $0x1, %ecx
ja 0x5f4c
leaq 0x28e7(%rip), %rsi      # 0x8821
movq %rbx, %rdi
callq 0x41b0
movq %r14, %rdi
callq 0x2030
jmp 0x5f81
movslq %eax, %rcx
movw $0xa, 0x4(%r14,%rcx)
movl $0xd444e45, (%r14,%rcx) # imm = 0xD444E45
movq %r14, 0x50(%rbx)
movq %r14, 0x38(%rbx)
addl $0x6, %eax
movl %eax, 0x44(%rbx)
movq %rbx, %rdi
movl $0x2, %esi
callq 0x4189
movl $0x1, 0x48(%rbx)
movl %ebp, %edi
callq 0x21b0
xorl %eax, %eax
popq %rbx
popq %r14
popq %rbp
retq