// File: /workspace/github_c_makefile_star2_O3/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 0x80c8(%rip), %rax      # 0xd288
cmpl $0x0, 0x20(%rax)
je 0x51f9
movslq 0xe8(%r13), %rax
cmpq $-0x1, %rax
je 0x5386
movl $0xffffffff, 0xe8(%r13) # imm = 0xFFFFFFFF
movq 0x9567(%rip), %rcx      # 0xe750
movl (%rcx,%rax,4), %eax
cmpl 0xec(%r13), %eax
jne 0x538f
addq $0x4, %r14
leaq 0x31cb(%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 0x539b
leaq 0x80b2(%rip), %r12      # 0xd2e0
leaq 0x10(%rsp), %r15
movl $0x0, (%rsp)
movslq 0x4(%rsp), %rbx
incq 0x20(%r12)
movq %r15, %rdi
xorl %esi, %esi
callq 0x4e76
testq %rax, %rax
je 0x5338
movq %rax, %rbp
movslq 0xa8(%r13), %rsi
cmpl %esi, (%rsp)
jl 0x528d
movq 0xa0(%r13), %rdi
shlq $0x4, %rsi
callq 0x2310
testq %rax, %rax
je 0x539b
shll 0xa8(%r13)
movq %rax, 0xa0(%r13)
movq %r13, %rdi
leaq 0x3141(%rip), %rsi      # 0x83d8
movl $0x6, %edx
callq 0x424c
testl %eax, %eax
jne 0x539b
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 0x424c
testl %eax, %eax
jne 0x539b
movzbl 0x29(%rbp), %esi
addq %r12, %rsi
movzbl 0x26(%rbp), %edx
addl 0x20(%rbp), %edx
movq %r13, %r15
movq %r13, %rdi
callq 0x424c
testl %eax, %eax
jne 0x5398
leaq 0x7f8e(%rip), %rax      # 0xd288
cmpl $0x2, 0x18(%rax)
jge 0x5363
movq %rbx, %r12
incq 0x30(%rbx)
incw 0x24(%rbp)
movq %rbp, %rdi
callq 0x48e1
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 0x533d
incq 0x38(%r12)
addq %rbx, %r14
movq %r14, %rdi
leaq 0x3085(%rip), %rsi      # 0x83cf
movq %r15, %rdx
leaq 0x4(%rsp), %rcx
xorl %eax, %eax
callq 0x22d0
testl %eax, %eax
jg 0x523a
jmp 0x539b
movq 0x7c8e(%rip), %rax      # 0xcff8
movq (%rax), %rdi
movl (%r15), %edx
leaq 0x3068(%rip), %rsi      # 0x83df
movq %r12, %rcx
xorl %eax, %eax
callq 0x2260
jmp 0x5300
leaq 0x300a(%rip), %rsi      # 0x8397
jmp 0x53f1
leaq 0x3029(%rip), %rsi      # 0x83bf
jmp 0x53f1
movq %r15, %r13
movq 0xa0(%r13), %rax
movq %rax, 0xb0(%r13)
movl (%rsp), %eax
movl %eax, 0xb8(%r13)
leaq 0x7ece(%rip), %rax      # 0xd288
cmpl $0x2, 0x18(%rax)
jge 0x5427
leaq 0x2ed5(%rip), %rsi      # 0x829c
movq %r13, %rdi
movl $0x5, %edx
callq 0x424c
cmpl $0x0, 0xbc(%r13)
je 0x53fb
movq %r13, %rdi
callq 0x4f9a
testl %eax, %eax
je 0x53fb
leaq 0x2eb1(%rip), %rsi      # 0x82a2
movq %r13, %rdi
callq 0x41b0
jmp 0x5413
movq %r13, %rdi
movl $0x6, %esi
callq 0x4189
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 0x53c0