// File: /workspace/github_c_makefile_star2_O0/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:
subq $0x158, %rsp            # imm = 0x158
movq %rdi, 0x148(%rsp)
movl %esi, 0x144(%rsp)
movq %rdx, 0x138(%rsp)
movq $0x0, 0x18(%rsp)
movq 0x138(%rsp), %rax
movq %rax, 0x10(%rsp)
leaq 0x98bd(%rip), %rax      # 0x11298
cmpl $0x0, 0x20(%rax)
je 0x7a6a
movq 0x10(%rsp), %rax
movl 0xe8(%rax), %eax
movl %eax, 0xc(%rsp)
cmpl $-0x1, 0xc(%rsp)
jne 0x7a1c
movq 0x10(%rsp), %rdi
leaq 0x4960(%rip), %rsi      # 0xc367
callq 0x4fc0
movl $0x0, 0x154(%rsp)
jmp 0x7c0a
movq 0x10(%rsp), %rax
movl $0xffffffff, 0xe8(%rax) # imm = 0xFFFFFFFF
movq 0xad2e(%rip), %rax      # 0x12760
movslq 0xc(%rsp), %rcx
movl (%rax,%rcx,4), %eax
movq 0x10(%rsp), %rcx
cmpl 0xec(%rcx), %eax
je 0x7a68
movq 0x10(%rsp), %rdi
leaq 0x493c(%rip), %rsi      # 0xc38f
callq 0x4fc0
movl $0x0, 0x154(%rsp)
jmp 0x7c0a
jmp 0x7a6a
movq 0x148(%rsp), %rdi
leaq 0x30(%rsp), %rdx
leaq 0x49cb(%rip), %rsi      # 0xc449
leaq 0x18(%rsp), %rcx
movb $0x0, %al
callq 0x22f0
movl %eax, 0x24(%rsp)
cmpl $0x0, 0x24(%rsp)
jge 0x7ab6
movq 0x10(%rsp), %rdi
leaq 0x49b6(%rip), %rsi      # 0xc457
callq 0x4fc0
movl $0x0, 0x154(%rsp)
jmp 0x7c0a
leaq 0x30(%rsp), %rdi
callq 0x67e0
movq %rax, 0x28(%rsp)
cmpq $0x0, 0x28(%rsp)
jne 0x7aee
movq 0x10(%rsp), %rdi
leaq 0x4963(%rip), %rsi      # 0xc43c
callq 0x4fc0
movl $0x0, 0x154(%rsp)
jmp 0x7c0a
cmpq $0x0, 0x18(%rsp)
jne 0x7b21
movq 0x28(%rsp), %rdi
callq 0x58a0
movq 0x10(%rsp), %rdi
leaq 0x4951(%rip), %rsi      # 0xc45d
callq 0x4fc0
movl $0x0, 0x154(%rsp)
jmp 0x7c0a
movl 0xac41(%rip), %eax      # 0x12768
cmpl 0xac3f(%rip), %eax      # 0x1276c
jl 0x7b8f
movq 0xac3a(%rip), %rdi      # 0x12770
movslq 0xac2f(%rip), %rsi      # 0x1276c
shlq $0x3, %rsi
shlq %rsi
callq 0x2330
movq %rax, (%rsp)
cmpq $0x0, (%rsp)
je 0x7b6f
movq (%rsp), %rax
movq %rax, 0xac11(%rip)      # 0x12770
movl 0xac07(%rip), %eax      # 0x1276c
shll %eax
movl %eax, 0xabff(%rip)      # 0x1276c
jmp 0x7b8d
movq 0x10(%rsp), %rdi
leaq 0x46db(%rip), %rsi      # 0xc256
callq 0x4fc0
movl $0x0, 0x154(%rsp)
jmp 0x7c0a
jmp 0x7b8f
movq 0x28(%rsp), %rax
movw 0x24(%rax), %cx
addw $0x1, %cx
movw %cx, 0x24(%rax)
movq 0x18(%rsp), %rdi
leaq 0x9744(%rip), %rsi      # 0x112f0
callq 0xaf70
movl %eax, %ecx
movq 0x28(%rsp), %rax
movl %ecx, 0x1c(%rax)
movq 0x28(%rsp), %rax
movzbl 0x27(%rax), %ecx
orl $0x2, %ecx
movb %cl, 0x27(%rax)
movq 0x28(%rsp), %rdx
movq 0xab9a(%rip), %rax      # 0x12770
movl 0xab8c(%rip), %ecx      # 0x12768
movl %ecx, %esi
addl $0x1, %esi
movl %esi, 0xab81(%rip)      # 0x12768
movslq %ecx, %rcx
movq %rdx, (%rax,%rcx,8)
movq 0x10(%rsp), %rdi
leaq 0x4863(%rip), %rsi      # 0xc45d
callq 0x4fc0
movl $0x0, 0x154(%rsp)
movl 0x154(%rsp), %eax
addq $0x158, %rsp            # imm = 0x158
retq
nopl (%rax)