// File: /workspace/github_c_makefile_star2_O1/zuocheng-liu[P]ae-memcached/src/memcached.c
// Function: command_get
int32_t command_get(char *command, conn *c) {
    char key[251];
    int next;
    item *it;
    char *start = command + 4;
    int i = 0;
    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;
        }
    }

    while(sscanf(start, " %250s%n", key, &next) >= 1) {
        start+=next;
        stats.get_cmds++;
        it = get_item(key);
        if (it) {
            if (i >= c->isize) {
                item **new_list = realloc(c->ilist, sizeof(item *)*c->isize*2);
                if (new_list) {
                    c->isize *= 2;
                    c->ilist = new_list;
                } else break;
            }

            /*
             * Construct the response. Each hit adds three elements to the
             * outgoing data list:
             *   "VALUE "
             *   key
             *   " " + flags + " " + data length + "\r\n" + data (with \r\n)
             */
            /* TODO: can we avoid the strlen() func call and cache that in wasted byte in item struct? */
            if (add_iov(c, "VALUE ", 6) ||
                    add_iov(c, ITEM_key(it), strlen(ITEM_key(it))) ||
                    add_iov(c, ITEM_suffix(it), it->nsuffix + it->nbytes))
            {
                break;
            }

            LOG_DEBUG_F2(">%d sending key %s\n", c->sfd, ITEM_key(it));

            stats.get_hits++;
            it->refcount++;
            item_update(it);
            *(c->ilist + i) = it;
            i++;
        } else stats.get_misses++;
    }

    c->icurr = c->ilist;
    c->ileft = i;

    LOG_DEBUG_F1(">%d END\n", c->sfd);
    add_iov(c, "END\r\n", 5);

    if (c->udp && build_udp_headers(c)) {
        out_string(c, "SERVER_ERROR out of memory");
    }
    else {
        conn_set_state(c, conn_mwrite);
        c->msgcurr = 0;
    }
    return COMMAND_OK;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x118, %rsp            # imm = 0x118
movq %rsi, %r13
movq %rdi, %r14
leaq 0x8086(%rip), %rax      # 0xd288
cmpl $0x0, 0x20(%rax)
je 0x523b
movslq 0xe8(%r13), %rax
cmpq $-0x1, %rax
je 0x53c8
movl $0xffffffff, 0xe8(%r13) # imm = 0xFFFFFFFF
movq 0x9525(%rip), %rcx      # 0xe750
movl (%rcx,%rax,4), %eax
cmpl 0xec(%r13), %eax
jne 0x53d1
addq $0x4, %r14
leaq 0x3189(%rip), %rsi      # 0x83cf
movl $0x0, (%rsp)
leaq 0x10(%rsp), %rdx
leaq 0x4(%rsp), %rcx
movq %r14, %rdi
xorl %eax, %eax
callq 0x22d0
testl %eax, %eax
jle 0x53dd
leaq 0x8070(%rip), %r12      # 0xd2e0
leaq 0x10(%rsp), %r15
movl $0x0, (%rsp)
movslq 0x4(%rsp), %rbx
incq 0x20(%r12)
movq %r15, %rdi
xorl %esi, %esi
callq 0x4ea2
testq %rax, %rax
je 0x537a
movq %rax, %rbp
movslq 0xa8(%r13), %rsi
cmpl %esi, (%rsp)
jl 0x52cf
movq 0xa0(%r13), %rdi
shlq $0x4, %rsi
callq 0x2310
testq %rax, %rax
je 0x53dd
shll 0xa8(%r13)
movq %rax, 0xa0(%r13)
movq %r13, %rdi
leaq 0x30ff(%rip), %rsi      # 0x83d8
movl $0x6, %edx
callq 0x4265
testl %eax, %eax
jne 0x53dd
movq %rbx, 0x8(%rsp)
movq %r12, %rbx
leaq 0x30(%rbp), %r12
movq %r12, %rdi
callq 0x2120
movq %r13, %rdi
movq %r12, %rsi
movl %eax, %edx
callq 0x4265
testl %eax, %eax
jne 0x53dd
movzbl 0x29(%rbp), %esi
addq %r12, %rsi
movzbl 0x26(%rbp), %edx
addl 0x20(%rbp), %edx
movq %r13, %r15
movq %r13, %rdi
callq 0x4265
testl %eax, %eax
jne 0x53da
leaq 0x7f4c(%rip), %rax      # 0xd288
cmpl $0x2, 0x18(%rax)
jge 0x53a5
movq %rbx, %r12
incq 0x30(%rbx)
incw 0x24(%rbp)
movq %rbp, %rdi
callq 0x48ea
movq %r15, %r13
movq 0xa0(%r15), %rax
movl (%rsp), %edx
movslq %edx, %rcx
movq %rbp, (%rax,%rcx,8)
incl %edx
movl %edx, (%rsp)
leaq 0x10(%rsp), %r15
movq 0x8(%rsp), %rbx
jmp 0x537f
incq 0x38(%r12)
addq %rbx, %r14
movq %r14, %rdi
leaq 0x3043(%rip), %rsi      # 0x83cf
movq %r15, %rdx
leaq 0x4(%rsp), %rcx
xorl %eax, %eax
callq 0x22d0
testl %eax, %eax
jg 0x527c
jmp 0x53dd
movq 0x7c4c(%rip), %rax      # 0xcff8
movq (%rax), %rdi
movl (%r15), %edx
leaq 0x3026(%rip), %rsi      # 0x83df
movq %r12, %rcx
xorl %eax, %eax
callq 0x2260
jmp 0x5342
leaq 0x2fc8(%rip), %rsi      # 0x8397
jmp 0x5433
leaq 0x2fe7(%rip), %rsi      # 0x83bf
jmp 0x5433
movq %r15, %r13
movq 0xa0(%r13), %rax
movq %rax, 0xb0(%r13)
movl (%rsp), %eax
movl %eax, 0xb8(%r13)
leaq 0x7e8c(%rip), %rax      # 0xd288
cmpl $0x2, 0x18(%rax)
jge 0x5469
leaq 0x2e93(%rip), %rsi      # 0x829c
movq %r13, %rdi
movl $0x5, %edx
callq 0x4265
cmpl $0x0, 0xbc(%r13)
je 0x543d
movq %r13, %rdi
callq 0x4fc7
testl %eax, %eax
je 0x543d
leaq 0x2e6f(%rip), %rsi      # 0x82a2
movq %r13, %rdi
callq 0x41c9
jmp 0x5455
movq %r13, %rdi
movl $0x6, %esi
callq 0x41a2
movl $0x0, 0x98(%r13)
xorl %eax, %eax
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r13, %rdi
callq 0x257b
jmp 0x5402