// File: /workspace/github_c_makefile_star2_O2/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 0x37f8(%rip), %rsi      # 0x841e
leaq 0x30(%rsp), %rdx
leaq 0xc(%rsp), %rcx
xorl %eax, %eax
callq 0x22d0
cmpl $0x2, %eax
jne 0x4d75
cmpb $0x0, 0x30(%rsp)
je 0x4d75
leaq 0x8636(%rip), %rax      # 0xd288
cmpl $0x0, 0x20(%rax)
je 0x4c86
movslq 0xe8(%rbx), %rax
cmpq $-0x1, %rax
je 0x4d7e
orl $-0x1, 0xe8(%rbx)
movq 0x9ad9(%rip), %rcx      # 0xe750
movl (%rcx,%rax,4), %eax
cmpl 0xec(%rbx), %eax
jne 0x4d90
leaq 0x30(%rsp), %rdi
callq 0x45ad
testq %rax, %rax
je 0x4d87
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
xorl %esi, %esi
subl %ecx, %eax
cmovbl %esi, %eax
testl %ebp, %ebp
cmovel %eax, %edx
leaq 0x3764(%rip), %rsi      # 0x8436
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 0x4d99
incq %rdi
callq 0x23e0
movl 0x1c(%r14), %edx
movq %r15, %rdi
movl %eax, %esi
movl %ebp, %ecx
callq 0x3cc6
testq %rax, %rax
je 0x4dfa
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 0x3fef
jmp 0x4dd9
leaq 0x3655(%rip), %rsi      # 0x83d1
jmp 0x4dde
leaq 0x35d2(%rip), %rsi      # 0x8357
jmp 0x4dde
leaq 0x369e(%rip), %rsi      # 0x842c
jmp 0x4dde
leaq 0x35e8(%rip), %rsi      # 0x837f
jmp 0x4dde
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
pushq $0x20
popq %rsi
callq 0x2190
leaq 0x10(%rsp), %rsi
movq %rbx, %rdi
callq 0x3946
xorl %eax, %eax
addq $0x138, %rsp            # imm = 0x138
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x3455(%rip), %rsi      # 0x8256
jmp 0x4dde