// File: /workspace/github_c_makefile_star2_O0/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:
subq $0x188, %rsp            # imm = 0x188
movq %rdi, 0x178(%rsp)
movq %rsi, 0x170(%rsp)
movl %edx, 0x16c(%rsp)
movq 0x178(%rsp), %rdi
leaq 0x30(%rsp), %rdx
leaq 0x4f2c(%rip), %rsi      # 0xc42e
leaq 0x12c(%rsp), %rcx
movb $0x0, %al
callq 0x22f0
movl %eax, 0x2c(%rsp)
cmpl $0x2, 0x2c(%rsp)
jne 0x752c
leaq 0x30(%rsp), %rdi
callq 0x2110
cmpq $0x0, %rax
jne 0x7550
movq 0x170(%rsp), %rdi
leaq 0x4ea6(%rip), %rsi      # 0xc3e1
callq 0x4fc0
movl $0x0, 0x184(%rsp)
jmp 0x7931
leaq 0x9d41(%rip), %rax      # 0x11298
cmpl $0x0, 0x20(%rax)
je 0x75f5
movq 0x170(%rsp), %rax
movl 0xe8(%rax), %eax
movl %eax, 0x1c(%rsp)
cmpl $-0x1, 0x1c(%rsp)
jne 0x759e
movq 0x170(%rsp), %rdi
leaq 0x4dde(%rip), %rsi      # 0xc367
callq 0x4fc0
movl $0x0, 0x184(%rsp)
jmp 0x7931
movq 0x170(%rsp), %rax
movl $0xffffffff, 0xe8(%rax) # imm = 0xFFFFFFFF
movq 0xb1a9(%rip), %rax      # 0x12760
movslq 0x1c(%rsp), %rcx
movl (%rax,%rcx,4), %eax
movq 0x170(%rsp), %rcx
cmpl 0xec(%rcx), %eax
je 0x75f3
movq 0x170(%rsp), %rdi
leaq 0x4db1(%rip), %rsi      # 0xc38f
callq 0x4fc0
movl $0x0, 0x184(%rsp)
jmp 0x7931
jmp 0x75f5
leaq 0x30(%rsp), %rdi
callq 0x67e0
movq %rax, 0x130(%rsp)
cmpq $0x0, 0x130(%rsp)
jne 0x7636
movq 0x170(%rsp), %rdi
leaq 0x4e1b(%rip), %rsi      # 0xc43c
callq 0x4fc0
movl $0x0, 0x184(%rsp)
jmp 0x7931
movq 0x130(%rsp), %rax
addq $0x30, %rax
movq 0x130(%rsp), %rcx
movzbl 0x29(%rcx), %ecx
movslq %ecx, %rcx
addq %rcx, %rax
movq 0x130(%rsp), %rcx
movzbl 0x26(%rcx), %ecx
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, 0x20(%rsp)
movq 0x20(%rsp), %rax
movsbl (%rax), %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, 0xf(%rsp)
je 0x76ab
movq 0x20(%rsp), %rax
movsbl (%rax), %ecx
xorl %eax, %eax
cmpl $0x30, %ecx
movb %al, 0xe(%rsp)
jge 0x76a3
movq 0x20(%rsp), %rax
movsbl (%rax), %eax
cmpl $0x39, %eax
setg %al
movb %al, 0xe(%rsp)
movb 0xe(%rsp), %al
movb %al, 0xf(%rsp)
movb 0xf(%rsp), %al
testb $0x1, %al
jne 0x76b5
jmp 0x76c5
movq 0x20(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x20(%rsp)
jmp 0x766b
movq 0x20(%rsp), %rdi
callq 0x2400
movl %eax, 0x13c(%rsp)
cmpl $0x0, 0x16c(%rsp)
je 0x76f7
movl 0x12c(%rsp), %eax
addl 0x13c(%rsp), %eax
movl %eax, 0x13c(%rsp)
jmp 0x772d
movl 0x12c(%rsp), %eax
cmpl 0x13c(%rsp), %eax
jb 0x7714
movl $0x0, 0x13c(%rsp)
jmp 0x772b
movl 0x12c(%rsp), %ecx
movl 0x13c(%rsp), %eax
subl %ecx, %eax
movl %eax, 0x13c(%rsp)
jmp 0x772d
leaq 0x140(%rsp), %rdi
movl 0x13c(%rsp), %edx
leaq 0x4d03(%rip), %rsi      # 0xc446
movb $0x0, %al
callq 0x2420
leaq 0x140(%rsp), %rdi
callq 0x2110
movl %eax, 0x2c(%rsp)
movl 0x2c(%rsp), %eax
addl $0x2, %eax
movq 0x130(%rsp), %rcx
cmpl 0x20(%rcx), %eax
jle 0x787c
movq 0x130(%rsp), %rax
addq $0x30, %rax
movq %rax, (%rsp)
movq 0x130(%rsp), %rdi
addq $0x30, %rdi
movq 0x130(%rsp), %rax
movzbl 0x29(%rax), %eax
cltq
addq %rax, %rdi
addq $0x1, %rdi
callq 0x2400
movq (%rsp), %rdi
movl %eax, %esi
movq 0x130(%rsp), %rax
movl 0x1c(%rax), %edx
movl 0x2c(%rsp), %ecx
addl $0x2, %ecx
callq 0x5630
movq %rax, 0x10(%rsp)
cmpq $0x0, 0x10(%rsp)
jne 0x77f7
movq 0x170(%rsp), %rdi
leaq 0x4a74(%rip), %rsi      # 0xc256
callq 0x4fc0
movl $0x0, 0x184(%rsp)
jmp 0x7931
movq 0x10(%rsp), %rdi
addq $0x30, %rdi
movq 0x10(%rsp), %rax
movzbl 0x29(%rax), %eax
cltq
addq %rax, %rdi
movq 0x10(%rsp), %rax
movzbl 0x26(%rax), %eax
cltq
addq %rax, %rdi
leaq 0x140(%rsp), %rsi
movslq 0x2c(%rsp), %rdx
callq 0x22a0
movq 0x10(%rsp), %rax
addq $0x30, %rax
movq 0x10(%rsp), %rcx
movzbl 0x29(%rcx), %ecx
movslq %ecx, %rcx
addq %rcx, %rax
movq 0x10(%rsp), %rcx
movzbl 0x26(%rcx), %ecx
movslq %ecx, %rcx
addq %rcx, %rax
movslq 0x2c(%rsp), %rcx
movw 0x4cba(%rip), %dx       # 0xc51b
movw %dx, (%rax,%rcx)
movq 0x130(%rsp), %rdi
movq 0x10(%rsp), %rsi
callq 0x5d00
jmp 0x7911
movq 0x130(%rsp), %rdi
addq $0x30, %rdi
movq 0x130(%rsp), %rax
movzbl 0x29(%rax), %eax
cltq
addq %rax, %rdi
movq 0x130(%rsp), %rax
movzbl 0x26(%rax), %eax
cltq
addq %rax, %rdi
leaq 0x140(%rsp), %rsi
movslq 0x2c(%rsp), %rdx
callq 0x22a0
movq 0x130(%rsp), %rdi
addq $0x30, %rdi
movq 0x130(%rsp), %rax
movzbl 0x29(%rax), %eax
cltq
addq %rax, %rdi
movq 0x130(%rsp), %rax
movzbl 0x26(%rax), %eax
cltq
addq %rax, %rdi
movslq 0x2c(%rsp), %rax
addq %rax, %rdi
movq 0x130(%rsp), %rax
movl 0x20(%rax), %eax
subl 0x2c(%rsp), %eax
subl $0x2, %eax
movslq %eax, %rdx
movl $0x20, %esi
callq 0x21b0
movq 0x170(%rsp), %rdi
leaq 0x140(%rsp), %rsi
callq 0x4fc0
movl $0x0, 0x184(%rsp)
movl 0x184(%rsp), %eax
addq $0x188, %rsp            # imm = 0x188
retq