// File: /workspace/github_c_makefile_star2_O0/zuocheng-liu[P]ae-memcached/src/memcached.c
// Function: complete_nread
void complete_nread(conn *c) {
    item *it = c->item;
    int comm = c->item_comm;
    item *old_it;
    int delete_locked = 0;
    char *key = ITEM_key(it);

    stats.set_cmds++;

    if (strncmp(ITEM_data(it) + it->nbytes - 2, "\r\n", 2) != 0) {
        out_string(c, "CLIENT_ERROR bad data chunk");
        goto err;
    }

    old_it = get_item_notedeleted(key, &delete_locked);

    if (old_it && comm == NREAD_ADD) {
        item_update(old_it);  /* touches item, promotes to head of LRU */
        out_string(c, "NOT_STORED");
        goto err;
    }

    if (!old_it && comm == NREAD_REPLACE) {
        out_string(c, "NOT_STORED");
        goto err;
    }

    if (delete_locked) {
        if (comm == NREAD_REPLACE || comm == NREAD_ADD) {
            out_string(c, "NOT_STORED");
            goto err;
        }

        /* but "set" commands can override the delete lock
         window... in which case we have to find the old hidden item
         that's in the namespace/LRU but wasn't returned by
         get_item.... because we need to replace it (below) */
        old_it = assoc_find(key);
    }

    if (old_it)
        item_replace(old_it, it);
    else
        item_link(it);

    c->item = 0;
    out_string(c, "STORED");
    return;

err:
     item_free(it);
     c->item = 0;
     return;
}

// Assembly:
subq $0x38, %rsp
movq %rdi, 0x30(%rsp)
movq 0x30(%rsp), %rax
movq 0x68(%rax), %rax
movq %rax, 0x28(%rsp)
movq 0x30(%rsp), %rax
movl 0x70(%rax), %eax
movl %eax, 0x24(%rsp)
movl $0x0, 0x14(%rsp)
movq 0x28(%rsp), %rax
addq $0x30, %rax
movq %rax, 0x8(%rsp)
leaq 0xa730(%rip), %rax      # 0x112f0
movq 0x28(%rax), %rcx
addq $0x1, %rcx
leaq 0xa721(%rip), %rax      # 0x112f0
movq %rcx, 0x28(%rax)
movq 0x28(%rsp), %rdi
addq $0x30, %rdi
movq 0x28(%rsp), %rax
movzbl 0x29(%rax), %eax
cltq
addq %rax, %rdi
movq 0x28(%rsp), %rax
movzbl 0x26(%rax), %eax
cltq
addq %rax, %rdi
movq 0x28(%rsp), %rax
movslq 0x20(%rax), %rax
addq %rax, %rdi
addq $-0x2, %rdi
leaq 0x590c(%rip), %rsi      # 0xc51b
movl $0x2, %edx
callq 0x2070
cmpl $0x0, %eax
je 0x6c34
movq 0x30(%rsp), %rdi
leaq 0x5716(%rip), %rsi      # 0xc340
callq 0x4fc0
jmp 0x6d13
movq 0x8(%rsp), %rdi
leaq 0x14(%rsp), %rsi
callq 0x66e0
movq %rax, 0x18(%rsp)
cmpq $0x0, 0x18(%rsp)
je 0x6c77
cmpl $0x1, 0x24(%rsp)
jne 0x6c77
movq 0x18(%rsp), %rdi
callq 0x5cd0
movq 0x30(%rsp), %rdi
leaq 0x56ef(%rip), %rsi      # 0xc35c
callq 0x4fc0
jmp 0x6d13
cmpq $0x0, 0x18(%rsp)
jne 0x6c99
cmpl $0x3, 0x24(%rsp)
jne 0x6c99
movq 0x30(%rsp), %rdi
leaq 0x56ca(%rip), %rsi      # 0xc35c
callq 0x4fc0
jmp 0x6d13
cmpl $0x0, 0x14(%rsp)
je 0x6cd0
cmpl $0x3, 0x24(%rsp)
je 0x6cae
cmpl $0x1, 0x24(%rsp)
jne 0x6cc1
movq 0x30(%rsp), %rdi
leaq 0x56a2(%rip), %rsi      # 0xc35c
callq 0x4fc0
jmp 0x6d13
movq 0x8(%rsp), %rdi
callq 0x3f90
movq %rax, 0x18(%rsp)
cmpq $0x0, 0x18(%rsp)
je 0x6ce9
movq 0x18(%rsp), %rdi
movq 0x28(%rsp), %rsi
callq 0x5d00
jmp 0x6cf3
movq 0x28(%rsp), %rdi
callq 0x5bd0
movq 0x30(%rsp), %rax
movq $0x0, 0x68(%rax)
movq 0x30(%rsp), %rdi
leaq 0x5654(%rip), %rsi      # 0xc360
callq 0x4fc0
jmp 0x6d2a
movq 0x28(%rsp), %rdi
callq 0x5950
movq 0x30(%rsp), %rax
movq $0x0, 0x68(%rax)
addq $0x38, %rsp
retq
nop