// File: /workspace/github_c_makefile_star2_O0/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:
subq $0x158, %rsp            # imm = 0x158
movq %rdi, 0x148(%rsp)
movq %rsi, 0x140(%rsp)
movq 0x148(%rsp), %rax
addq $0x4, %rax
movq %rax, 0x28(%rsp)
movl $0x0, 0x24(%rsp)
leaq 0xa531(%rip), %rax      # 0x11298
cmpl $0x0, 0x20(%rax)
je 0x6e05
movq 0x140(%rsp), %rax
movl 0xe8(%rax), %eax
movl %eax, 0x20(%rsp)
cmpl $-0x1, 0x20(%rsp)
jne 0x6dae
movq 0x140(%rsp), %rdi
leaq 0x55ce(%rip), %rsi      # 0xc367
callq 0x4fc0
movl $0x0, 0x154(%rsp)
jmp 0x712c
movq 0x140(%rsp), %rax
movl $0xffffffff, 0xe8(%rax) # imm = 0xFFFFFFFF
movq 0xb999(%rip), %rax      # 0x12760
movslq 0x20(%rsp), %rcx
movl (%rax,%rcx,4), %eax
movq 0x140(%rsp), %rcx
cmpl 0xec(%rcx), %eax
je 0x6e03
movq 0x140(%rsp), %rdi
leaq 0x55a1(%rip), %rsi      # 0xc38f
callq 0x4fc0
movl $0x0, 0x154(%rsp)
jmp 0x712c
jmp 0x6e05
jmp 0x6e07
movq 0x28(%rsp), %rdi
leaq 0x40(%rsp), %rdx
leaq 0x5587(%rip), %rsi      # 0xc39f
leaq 0x3c(%rsp), %rcx
movb $0x0, %al
callq 0x22f0
cmpl $0x1, %eax
jl 0x704a
movl 0x3c(%rsp), %ecx
movq 0x28(%rsp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, 0x28(%rsp)
leaq 0xa4a8(%rip), %rax      # 0x112f0
movq 0x20(%rax), %rcx
addq $0x1, %rcx
leaq 0xa499(%rip), %rax      # 0x112f0
movq %rcx, 0x20(%rax)
leaq 0x40(%rsp), %rdi
callq 0x67e0
movq %rax, 0x30(%rsp)
cmpq $0x0, 0x30(%rsp)
je 0x702b
movl 0x24(%rsp), %eax
movq 0x140(%rsp), %rcx
cmpl 0xa8(%rcx), %eax
jl 0x6ef4
movq 0x140(%rsp), %rax
movq 0xa0(%rax), %rdi
movq 0x140(%rsp), %rax
movslq 0xa8(%rax), %rsi
shlq $0x3, %rsi
shlq %rsi
callq 0x2330
movq %rax, 0x18(%rsp)
cmpq $0x0, 0x18(%rsp)
je 0x6eed
movq 0x140(%rsp), %rax
movl 0xa8(%rax), %ecx
shll %ecx
movl %ecx, 0xa8(%rax)
movq 0x18(%rsp), %rcx
movq 0x140(%rsp), %rax
movq %rcx, 0xa0(%rax)
jmp 0x6ef2
jmp 0x704a
jmp 0x6ef4
movq 0x140(%rsp), %rdi
leaq 0x54a5(%rip), %rsi      # 0xc3a8
movl $0x6, %edx
callq 0x50b0
cmpl $0x0, %eax
jne 0x6f8b
movq 0x140(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0x30(%rsp), %rax
addq $0x30, %rax
movq %rax, 0x10(%rsp)
movq 0x30(%rsp), %rdi
addq $0x30, %rdi
callq 0x2110
movq 0x8(%rsp), %rdi
movq 0x10(%rsp), %rsi
movl %eax, %edx
callq 0x50b0
cmpl $0x0, %eax
jne 0x6f8b
movq 0x140(%rsp), %rdi
movq 0x30(%rsp), %rsi
addq $0x30, %rsi
movq 0x30(%rsp), %rax
movzbl 0x29(%rax), %eax
cltq
addq %rax, %rsi
movq 0x30(%rsp), %rax
movzbl 0x26(%rax), %edx
movq 0x30(%rsp), %rax
addl 0x20(%rax), %edx
callq 0x50b0
cmpl $0x0, %eax
je 0x6f90
jmp 0x704a
jmp 0x6f92
leaq 0xa2ff(%rip), %rax      # 0x11298
cmpl $0x1, 0x18(%rax)
jle 0x6fca
movq 0xa052(%rip), %rax      # 0x10ff8
movq (%rax), %rdi
movq 0x140(%rsp), %rax
movl (%rax), %edx
movq 0x30(%rsp), %rcx
addq $0x30, %rcx
leaq 0x53ec(%rip), %rsi      # 0xc3af
movb $0x0, %al
callq 0x2280
jmp 0x6fcc
leaq 0xa31d(%rip), %rax      # 0x112f0
movq 0x30(%rax), %rcx
addq $0x1, %rcx
leaq 0xa30e(%rip), %rax      # 0x112f0
movq %rcx, 0x30(%rax)
movq 0x30(%rsp), %rax
movw 0x24(%rax), %cx
addw $0x1, %cx
movw %cx, 0x24(%rax)
movq 0x30(%rsp), %rdi
callq 0x5cd0
movq 0x30(%rsp), %rdx
movq 0x140(%rsp), %rax
movq 0xa0(%rax), %rax
movslq 0x24(%rsp), %rcx
movq %rdx, (%rax,%rcx,8)
movl 0x24(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x24(%rsp)
jmp 0x7045
leaq 0xa2be(%rip), %rax      # 0x112f0
movq 0x38(%rax), %rcx
addq $0x1, %rcx
leaq 0xa2af(%rip), %rax      # 0x112f0
movq %rcx, 0x38(%rax)
jmp 0x6e07
movq 0x140(%rsp), %rax
movq 0xa0(%rax), %rcx
movq 0x140(%rsp), %rax
movq %rcx, 0xb0(%rax)
movl 0x24(%rsp), %ecx
movq 0x140(%rsp), %rax
movl %ecx, 0xb8(%rax)
leaq 0xa217(%rip), %rax      # 0x11298
cmpl $0x1, 0x18(%rax)
jle 0x70a9
movq 0x9f6a(%rip), %rax      # 0x10ff8
movq (%rax), %rdi
movq 0x140(%rsp), %rax
movl (%rax), %edx
leaq 0x5321(%rip), %rsi      # 0xc3c3
movb $0x0, %al
callq 0x2280
jmp 0x70ab
movq 0x140(%rsp), %rdi
leaq 0x5196(%rip), %rsi      # 0xc250
movl $0x5, %edx
callq 0x50b0
movq 0x140(%rsp), %rax
cmpl $0x0, 0xbc(%rax)
je 0x70fd
movq 0x140(%rsp), %rdi
callq 0x6920
cmpl $0x0, %eax
je 0x70fd
movq 0x140(%rsp), %rdi
leaq 0x5160(%rip), %rsi      # 0xc256
callq 0x4fc0
jmp 0x7121
movq 0x140(%rsp), %rdi
movl $0x6, %esi
callq 0x4f80
movq 0x140(%rsp), %rax
movl $0x0, 0x98(%rax)
movl $0x0, 0x154(%rsp)
movl 0x154(%rsp), %eax
addq $0x158, %rsp            # imm = 0x158
retq
nopl (%rax,%rax)