// File: /workspace/github_c_makefile_star2_O1/zuocheng-liu[P]ae-memcached/src/memcached.c
// Function: delete_handler
int32_t delete_handler(char *command, int argc, char ** argv) {
    AE_NOTUSED(argc); 
    char key[251];
    item *it;
    int res;
    time_t exptime = 0;
    conn *c = (conn*)argv;

    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;
        }
    }
    res = sscanf(command, "%*s %250s %ld", key, &exptime);
    if (res < 0) {
        out_string(c, "ERROR");
        return COMMAND_OK;
    }
    it = get_item(key);
    if (!it) {
        out_string(c, "NOT_FOUND");
        return COMMAND_OK;
    }
    if (exptime == 0) {
        item_unlink(it);
        out_string(c, "DELETED");
        return COMMAND_OK;
    }
    if (delcurr >= deltotal) {
        item **new_delete = realloc(todelete, sizeof(item *) * deltotal * 2);
        if (new_delete) {
            todelete = new_delete;
            deltotal *= 2;
        } else {
            /*
             * can't delete it immediately, user wants a delay,
             * but we ran out of memory for the delete queue
             */
            out_string(c, "SERVER_ERROR out of memory");
            return COMMAND_OK;
        }
    }

    it->refcount++;
    /* use its expiration time as its deletion time now */
    it->exptime = realtime(exptime, &stats);
    it->it_flags |= ITEM_DELETED;
    todelete[delcurr++] = it;
    out_string(c, "DELETED");
    return COMMAND_OK;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x118, %rsp            # imm = 0x118
movq %rdx, %rbx
movq $0x0, 0x8(%rsp)
leaq 0x7a15(%rip), %rax      # 0xd288
cmpl $0x0, 0x20(%rax)
je 0x58aa
movslq 0xe8(%rbx), %rax
cmpq $-0x1, %rax
je 0x5920
movl $0xffffffff, 0xe8(%rbx) # imm = 0xFFFFFFFF
movq 0x8eb5(%rip), %rcx      # 0xe750
movl (%rcx,%rax,4), %eax
cmpl 0xec(%rbx), %eax
jne 0x5932
leaq 0x2bc8(%rip), %rsi      # 0x8479
leaq 0x10(%rsp), %rdx
leaq 0x8(%rsp), %rcx
xorl %eax, %eax
callq 0x22d0
testl %eax, %eax
js 0x5929
leaq 0x10(%rsp), %rdi
xorl %esi, %esi
callq 0x4ea2
testq %rax, %rax
je 0x593b
movq %rax, %r14
cmpq $0x0, 0x8(%rsp)
je 0x5944
movslq 0x8e73(%rip), %r12      # 0xe75c
cmpl %r12d, 0x8e68(%rip)     # 0xe758
jl 0x5962
movq 0x8e67(%rip), %rdi      # 0xe760
movq %r12, %rsi
shlq $0x4, %rsi
callq 0x2310
movq %rax, %r15
testq %rax, %rax
je 0x594e
movq %r15, 0x8e4c(%rip)      # 0xe760
addl %r12d, %r12d
movl %r12d, 0x8e3e(%rip)     # 0xe75c
jmp 0x595d
leaq 0x2a70(%rip), %rsi      # 0x8397
jmp 0x59a3
leaq 0x2b57(%rip), %rsi      # 0x8487
jmp 0x59a3
leaq 0x2a86(%rip), %rsi      # 0x83bf
jmp 0x59a3
leaq 0x2b2a(%rip), %rsi      # 0x846c
jmp 0x59a3
movq %r14, %rdi
callq 0x46be
jmp 0x599c
leaq 0x294d(%rip), %rsi      # 0x82a2
movq %rbx, %rdi
callq 0x41c9
testq %r15, %r15
je 0x59ab
incw 0x24(%r14)
movq 0x8(%rsp), %rdi
leaq 0x796d(%rip), %rsi      # 0xd2e0
callq 0x786d
movl %eax, 0x1c(%r14)
orb $0x2, 0x27(%r14)
movq 0x8dd8(%rip), %rax      # 0xe760
movslq 0x8dc9(%rip), %rcx      # 0xe758
leal 0x1(%rcx), %edx
movl %edx, 0x8dc0(%rip)      # 0xe758
movq %r14, (%rax,%rcx,8)
leaq 0x2aea(%rip), %rsi      # 0x848d
movq %rbx, %rdi
callq 0x41c9
xorl %eax, %eax
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r14
popq %r15
retq