// File: /workspace/github_c_makefile_star2_O0/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:
subq $0x158, %rsp            # imm = 0x158
movq %rdi, 0x148(%rsp)
movq %rsi, 0x140(%rsp)
movl %edx, 0x13c(%rsp)
movl 0x13c(%rsp), %eax
movl %eax, 0x138(%rsp)
movq 0x148(%rsp), %rdi
leaq 0x30(%rsp), %rdx
leaq 0x51dc(%rip), %rsi      # 0xc3cc
leaq 0x2c(%rsp), %rcx
leaq 0x20(%rsp), %r8
leaq 0x1c(%rsp), %r9
movb $0x0, %al
callq 0x22f0
movl %eax, 0x18(%rsp)
cmpl $0x4, 0x18(%rsp)
jne 0x7221
leaq 0x30(%rsp), %rdi
callq 0x2110
cmpq $0x0, %rax
jne 0x7245
movq 0x140(%rsp), %rdi
leaq 0x51b1(%rip), %rsi      # 0xc3e1
callq 0x4fc0
movl $0x0, 0x154(%rsp)
jmp 0x7424
leaq 0xa04c(%rip), %rax      # 0x11298
cmpl $0x0, 0x20(%rax)
je 0x72ea
movq 0x140(%rsp), %rax
movl 0xe8(%rax), %eax
movl %eax, 0xc(%rsp)
cmpl $-0x1, 0xc(%rsp)
jne 0x7293
movq 0x140(%rsp), %rdi
leaq 0x50e9(%rip), %rsi      # 0xc367
callq 0x4fc0
movl $0x0, 0x154(%rsp)
jmp 0x7424
movq 0x140(%rsp), %rax
movl $0xffffffff, 0xe8(%rax) # imm = 0xFFFFFFFF
movq 0xb4b4(%rip), %rax      # 0x12760
movslq 0xc(%rsp), %rcx
movl (%rax,%rcx,4), %eax
movq 0x140(%rsp), %rcx
cmpl 0xec(%rcx), %eax
je 0x72e8
movq 0x140(%rsp), %rdi
leaq 0x50bc(%rip), %rsi      # 0xc38f
callq 0x4fc0
movl $0x0, 0x154(%rsp)
jmp 0x7424
jmp 0x72ea
movq 0x20(%rsp), %rdi
leaq 0x9ffa(%rip), %rsi      # 0x112f0
callq 0xaf70
movl %eax, %eax
movq %rax, 0x20(%rsp)
leaq 0x30(%rsp), %rdi
movl 0x2c(%rsp), %esi
movq 0x20(%rsp), %rax
movl %eax, %edx
movl 0x1c(%rsp), %ecx
addl $0x2, %ecx
callq 0x5630
movq %rax, 0x10(%rsp)
cmpq $0x0, 0x10(%rsp)
jne 0x73a0
leaq 0x30(%rsp), %rdi
movl 0x2c(%rsp), %esi
movl 0x1c(%rsp), %edx
addl $0x2, %edx
callq 0x59c0
cmpl $0x0, %eax
jne 0x735b
movq 0x140(%rsp), %rdi
leaq 0x50b2(%rip), %rsi      # 0xc406
callq 0x4fc0
jmp 0x736f
movq 0x140(%rsp), %rdi
leaq 0x4eec(%rip), %rsi      # 0xc256
callq 0x4fc0
movq 0x140(%rsp), %rax
movl $0x4, 0x48(%rax)
movl 0x1c(%rsp), %ecx
addl $0x2, %ecx
movq 0x140(%rsp), %rax
movl %ecx, 0x74(%rax)
movl $0x0, 0x154(%rsp)
jmp 0x7424
movl 0x138(%rsp), %ecx
movq 0x140(%rsp), %rax
movl %ecx, 0x70(%rax)
movq 0x10(%rsp), %rcx
movq 0x140(%rsp), %rax
movq %rcx, 0x68(%rax)
movq 0x10(%rsp), %rcx
addq $0x30, %rcx
movq 0x10(%rsp), %rax
movzbl 0x29(%rax), %eax
cltq
addq %rax, %rcx
movq 0x10(%rsp), %rax
movzbl 0x26(%rax), %eax
cltq
addq %rax, %rcx
movq 0x140(%rsp), %rax
movq %rcx, 0x58(%rax)
movq 0x10(%rsp), %rax
movl 0x20(%rax), %ecx
movq 0x140(%rsp), %rax
movl %ecx, 0x60(%rax)
movq 0x140(%rsp), %rdi
movl $0x3, %esi
callq 0x4f80
movl $0x0, 0x154(%rsp)
movl 0x154(%rsp), %eax
addq $0x158, %rsp            # imm = 0x158
retq
nopw %cs:(%rax,%rax)