// File: /workspace/github_c_makefile_star2_O2/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 $0x128, %rsp            # imm = 0x128
movq %rsi, %rdx
movq %rdi, %r14
leaq 0x8a6c(%rip), %rax      # 0xd288
cmpl $0x0, 0x20(%rax)
je 0x4850
movslq 0xe8(%rdx), %rax
cmpq $-0x1, %rax
je 0x4a15
orl $-0x1, 0xe8(%rdx)
movq 0x9f0f(%rip), %rcx      # 0xe750
movl (%rcx,%rax,4), %eax
cmpl 0xec(%rdx), %eax
jne 0x4a1e
movq %rdx, 0x10(%rsp)
addq $0x4, %r14
leaq 0x20(%rsp), %r12
leaq 0x1c(%rsp), %r13
leaq 0x8a76(%rip), %rbx      # 0xd2e0
movl $0x0, 0xc(%rsp)
movq %r14, %rdi
leaq 0x3b13(%rip), %rsi      # 0x838f
movq %r12, %rdx
movq %r13, %rcx
xorl %eax, %eax
callq 0x22d0
testl %eax, %eax
jle 0x49a4
movslq 0x1c(%rsp), %rax
addq %rax, %r14
incq 0x20(%rbx)
movq %r12, %rdi
callq 0x45ad
testq %rax, %rax
jne 0x48b0
incq 0x38(%rbx)
jmp 0x4872
movq %rax, %rbp
movq 0x10(%rsp), %rdi
movslq 0xa8(%rdi), %rsi
cmpl %esi, 0xc(%rsp)
jl 0x48f0
movq 0xa0(%rdi), %rdi
shlq $0x4, %rsi
callq 0x2310
testq %rax, %rax
je 0x49a4
movq 0x10(%rsp), %rdi
shll 0xa8(%rdi)
movq %rax, 0xa0(%rdi)
leaq 0x3aa1(%rip), %rsi      # 0x8398
pushq $0x6
popq %rdx
callq 0x39dd
testl %eax, %eax
jne 0x49a4
leaq 0x30(%rbp), %r15
movq %r15, %rdi
callq 0x2120
movq 0x10(%rsp), %rdi
movq %r15, %rsi
movl %eax, %edx
callq 0x39dd
testl %eax, %eax
jne 0x49a4
movzbl 0x29(%rbp), %esi
addq %r15, %rsi
movzbl 0x26(%rbp), %edx
addl 0x20(%rbp), %edx
movq 0x10(%rsp), %rdi
callq 0x39dd
testl %eax, %eax
jne 0x49a4
leaq 0x893f(%rip), %rax      # 0xd288
cmpl $0x2, 0x18(%rax)
jge 0x4980
incq 0x30(%rbx)
incw 0x24(%rbp)
movq %rbp, %rdi
callq 0x3fd1
movq 0x10(%rsp), %rax
movq 0xa0(%rax), %rax
movl 0xc(%rsp), %edx
movl %edx, %ecx
movq %rbp, (%rax,%rcx,8)
incl %edx
movl %edx, 0xc(%rsp)
jmp 0x4872
movq 0x8671(%rip), %rax      # 0xcff8
movq (%rax), %rdi
movq 0x10(%rsp), %rax
movl (%rax), %edx
leaq 0x3a07(%rip), %rsi      # 0x839f
movq %r15, %rcx
xorl %eax, %eax
callq 0x2260
jmp 0x494f
movq 0x10(%rsp), %rbx
movq 0xa0(%rbx), %rax
movq %rax, 0xb0(%rbx)
movl 0xc(%rsp), %eax
movl %eax, 0xb8(%rbx)
leaq 0x88c0(%rip), %rax      # 0xd288
cmpl $0x2, 0x18(%rax)
jge 0x4a41
leaq 0x387b(%rip), %rsi      # 0x8250
pushq $0x5
popq %rdx
movq %rbx, %rdi
callq 0x39dd
cmpl $0x0, 0xbc(%rbx)
je 0x4a01
movq %rbx, %rdi
callq 0x462b
testl %eax, %eax
je 0x4a01
leaq 0x385a(%rip), %rsi      # 0x8256
movq %rbx, %rdi
jmp 0x4a28
pushq $0x6
popq %rsi
movq %rbx, %rdi
callq 0x391f
andl $0x0, 0x98(%rbx)
jmp 0x4a2d
leaq 0x393b(%rip), %rsi      # 0x8357
jmp 0x4a25
leaq 0x395a(%rip), %rsi      # 0x837f
movq %rdx, %rdi
callq 0x3946
xorl %eax, %eax
addq $0x128, %rsp            # imm = 0x128
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x85b0(%rip), %rax      # 0xcff8
movq (%rax), %rdi
movl (%rbx), %edx
leaq 0x395f(%rip), %rsi      # 0x83b3
xorl %eax, %eax
callq 0x2260
jmp 0x49ce