// File: /workspace/github_c_makefile_star2_O3/zuocheng-liu[P]ae-memcached/src/memcached.c
// Function: command_vary_delta
int32_t command_vary_delta(char *command, conn *c, int incr) {
    char temp[32];
    unsigned int value;
    item *it;
    unsigned int delta;
    char key[251];
    int res;
    char *ptr;
    res = sscanf(command, "%*s %250s %u\n", key, &delta);
    if (res!=2 || 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;
        }
    }
    it = get_item(key);
    if (!it) {
        out_string(c, "NOT_FOUND");
        return COMMAND_OK;
    }
    ptr = ITEM_data(it);
    while (*ptr && (*ptr<'0' && *ptr>'9')) ptr++;    /* BUG: can't be true */
    value = atoi(ptr);
    if (incr)
        value+=delta;
    else {
        if (delta >= value) value = 0;
        else value-=delta;
    }
    sprintf(temp, "%u", value);
    res = strlen(temp);
    if (res + 2 > it->nbytes) { /* need to realloc */
        item *new_it;
        new_it = item_alloc(ITEM_key(it), atoi(ITEM_suffix(it) + 1), it->exptime, res + 2 );
        if (new_it == 0) {
            out_string(c, "SERVER_ERROR out of memory");
            return COMMAND_OK;
        }
        memcpy(ITEM_data(new_it), temp, res);
        memcpy(ITEM_data(new_it) + res, "\r\n", 2);
        item_replace(it, new_it);
    } else { /* replace in-place */
        memcpy(ITEM_data(it), temp, res);
        memset(ITEM_data(it) + res, ' ', it->nbytes-res-2);
    }
    out_string(c, temp);
    return COMMAND_OK;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x138, %rsp            # imm = 0x138
movl %edx, %ebp
movq %rsi, %rbx
leaq 0x2e62(%rip), %rsi      # 0x845e
leaq 0x30(%rsp), %rdx
leaq 0xc(%rsp), %rcx
xorl %eax, %eax
callq 0x22d0
cmpl $0x2, %eax
jne 0x5752
cmpb $0x0, 0x30(%rsp)
je 0x5752
leaq 0x7c60(%rip), %rax      # 0xd288
cmpl $0x0, 0x20(%rax)
je 0x565f
movslq 0xe8(%rbx), %rax
cmpq $-0x1, %rax
je 0x575b
movl $0xffffffff, 0xe8(%rbx) # imm = 0xFFFFFFFF
movq 0x9100(%rip), %rcx      # 0xe750
movl (%rcx,%rax,4), %eax
cmpl 0xec(%rbx), %eax
jne 0x576d
xorl %r12d, %r12d
leaq 0x30(%rsp), %rdi
xorl %esi, %esi
callq 0x4e76
testq %rax, %rax
je 0x5764
movq %rax, %r14
leaq 0x30(%rax), %r15
movzbl 0x29(%rax), %eax
addq %r14, %rax
addq $0x30, %rax
movzbl 0x26(%r14), %edi
addq %rax, %rdi
callq 0x23e0
movl 0xc(%rsp), %ecx
leal (%rcx,%rax), %edx
subl %ecx, %eax
cmovbl %r12d, %eax
testl %ebp, %ebp
cmovel %eax, %edx
leaq 0x2dc7(%rip), %rsi      # 0x8476
leaq 0x10(%rsp), %r12
movq %r12, %rdi
xorl %eax, %eax
callq 0x2400
movq %r12, %rdi
callq 0x2120
movq %rax, %r12
leal 0x2(%rax), %ebp
movzbl 0x29(%r14), %eax
leaq (%r14,%rax), %rdi
addq $0x30, %rdi
cmpl 0x20(%r14), %ebp
jle 0x5776
incq %rdi
callq 0x23e0
movl 0x1c(%r14), %edx
movq %r15, %rdi
movl %eax, %esi
movl %ebp, %ecx
callq 0x457b
testq %rax, %rax
je 0x57d9
movq %rax, %r15
movzbl 0x29(%rax), %eax
addq %r15, %rax
addq $0x30, %rax
movzbl 0x26(%r15), %edi
addq %rax, %rdi
movslq %r12d, %r12
leaq 0x10(%rsp), %rsi
movq %r12, %rdx
callq 0x2280
movzbl 0x29(%r15), %eax
addq %r15, %rax
addq $0x30, %rax
movzbl 0x26(%r15), %ecx
addq %rax, %rcx
movw $0xa0d, (%r12,%rcx)     # imm = 0xA0D
movq %r14, %rdi
movq %r15, %rsi
callq 0x48ff
jmp 0x57b8
leaq 0x2cb8(%rip), %rsi      # 0x8411
jmp 0x57bd
leaq 0x2c35(%rip), %rsi      # 0x8397
jmp 0x57bd
leaq 0x2d01(%rip), %rsi      # 0x846c
jmp 0x57bd
leaq 0x2c4b(%rip), %rsi      # 0x83bf
jmp 0x57bd
movzbl 0x26(%r14), %eax
addq %rax, %rdi
movslq %r12d, %r13
leaq 0x10(%rsp), %rsi
movq %r13, %rdx
callq 0x2280
movzbl 0x29(%r14), %eax
addq %rax, %r15
movzbl 0x26(%r14), %edi
addq %r13, %rdi
addq %r15, %rdi
movl 0x20(%r14), %eax
subl %r12d, %eax
addl $-0x2, %eax
movslq %eax, %rdx
movl $0x20, %esi
callq 0x2190
leaq 0x10(%rsp), %rsi
movq %rbx, %rdi
callq 0x41b0
xorl %eax, %eax
addq $0x138, %rsp            # imm = 0x138
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x2ac2(%rip), %rsi      # 0x82a2
jmp 0x57bd