// File: /workspace/github_c_makefile_star2_O1/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 0x2e20(%rip), %rsi      # 0x845e
leaq 0x30(%rsp), %rdx
leaq 0xc(%rsp), %rcx
xorl %eax, %eax
callq 0x22d0
leaq 0x2dbb(%rip), %r14      # 0x8411
cmpl $0x2, %eax
jne 0x5812
cmpb $0x0, 0x30(%rsp)
je 0x5812
leaq 0x7c17(%rip), %rax      # 0xd288
cmpl $0x0, 0x20(%rax)
je 0x56a8
movslq 0xe8(%rbx), %rax
cmpq $-0x1, %rax
je 0x57a1
movl $0xffffffff, 0xe8(%rbx) # imm = 0xFFFFFFFF
movq 0x90b7(%rip), %rcx      # 0xe750
movl (%rcx,%rax,4), %eax
cmpl 0xec(%rbx), %eax
jne 0x57b3
xorl %r14d, %r14d
leaq 0x30(%rsp), %rdi
xorl %esi, %esi
callq 0x4ea2
testq %rax, %rax
je 0x57aa
movq %rax, %r15
leaq 0x30(%rax), %r12
movzbl 0x29(%rax), %eax
addq %r15, %rax
addq $0x30, %rax
movzbl 0x26(%r15), %edi
addq %rax, %rdi
callq 0x23e0
movl 0xc(%rsp), %ecx
leal (%rcx,%rax), %edx
subl %ecx, %eax
cmovbl %r14d, %eax
testl %ebp, %ebp
cmovel %eax, %edx
leaq 0x2d7e(%rip), %rsi      # 0x8476
leaq 0x10(%rsp), %r14
movq %r14, %rdi
xorl %eax, %eax
callq 0x2400
movq %r14, %rdi
callq 0x2120
movq %rax, %r13
leal 0x2(%rax), %ebp
movzbl 0x29(%r15), %eax
leaq (%r15,%rax), %rdi
addq $0x30, %rdi
cmpl 0x20(%r15), %ebp
jle 0x57bc
incq %rdi
callq 0x23e0
movl 0x1c(%r15), %edx
movq %r12, %rdi
movl %eax, %esi
movl %ebp, %ecx
callq 0x4563
movq %rax, %r12
testq %rax, %rax
je 0x57fe
movzbl 0x29(%r12), %eax
addq %r12, %rax
addq $0x30, %rax
movzbl 0x26(%r12), %edi
addq %rax, %rdi
movslq %r13d, %r13
leaq 0x10(%rsp), %rsi
movq %r13, %rdx
callq 0x2280
movzbl 0x29(%r12), %eax
addq %r12, %rax
addq $0x30, %rax
movzbl 0x26(%r12), %ecx
addq %rax, %rcx
movw $0xa0d, (%r13,%rcx)     # imm = 0xA0D
movq %r15, %rdi
movq %r12, %rsi
callq 0x4908
jmp 0x580d
leaq 0x2bef(%rip), %r14      # 0x8397
jmp 0x5812
leaq 0x2cbb(%rip), %r14      # 0x846c
jmp 0x5812
leaq 0x2c05(%rip), %r14      # 0x83bf
jmp 0x5812
movzbl 0x26(%r15), %eax
addq %rax, %rdi
movslq %r13d, %rbp
movq %r14, %rsi
movq %rbp, %rdx
callq 0x2280
movzbl 0x29(%r15), %eax
addq %rax, %r12
movzbl 0x26(%r15), %edi
addq %rbp, %rdi
addq %r12, %rdi
movl 0x20(%r15), %eax
subl %r13d, %eax
addl $-0x2, %eax
movslq %eax, %rdx
movl $0x20, %esi
callq 0x2190
jmp 0x5812
leaq 0x2a9d(%rip), %rsi      # 0x82a2
movq %rbx, %rdi
callq 0x41c9
testq %r12, %r12
je 0x581d
movq %rbx, %rdi
movq %r14, %rsi
callq 0x41c9
xorl %eax, %eax
addq $0x138, %rsp            # imm = 0x138
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq