// File: /workspace/github_c_makefile_star2_O2/gplessis[P]dotdeb-redis/src/cluster.c
// Function: restoreCommand
void restoreCommand(client *c) {
    long long ttl;
    rio payload;
    int j, type, replace = 0;
    robj *obj;

    /* Parse additional options */
    for (j = 4; j < c->argc; j++) {
        if (!strcasecmp(c->argv[j]->ptr,"replace")) {
            replace = 1;
        } else {
            addReply(c,shared.syntaxerr);
            return;
        }
    }

    /* Make sure this key does not already exist here... */
    if (!replace && lookupKeyWrite(c->db,c->argv[1]) != NULL) {
        addReply(c,shared.busykeyerr);
        return;
    }

    /* Check if the TTL value makes sense */
    if (getLongLongFromObjectOrReply(c,c->argv[2],&ttl,NULL) != C_OK) {
        return;
    } else if (ttl < 0) {
        addReplyError(c,"Invalid TTL value, must be >= 0");
        return;
    }

    /* Verify RDB version and data checksum. */
    if (verifyDumpPayload(c->argv[3]->ptr,sdslen(c->argv[3]->ptr)) == C_ERR)
    {
        addReplyError(c,"DUMP payload version or checksum are wrong");
        return;
    }

    rioInitWithBuffer(&payload,c->argv[3]->ptr);
    if (((type = rdbLoadObjectType(&payload)) == -1) ||
        ((obj = rdbLoadObject(type,&payload)) == NULL))
    {
        addReplyError(c,"Bad data format");
        return;
    }

    /* Remove the old key if needed. */
    if (replace) dbDelete(c->db,c->argv[1]);

    /* Create the key and set the TTL if any */
    dbAdd(c->db,c->argv[1],obj);
    if (ttl) setExpire(c->db,c->argv[1],mstime()+ttl);
    signalModifiedKey(c->db,c->argv[1]);
    addReply(c,shared.ok);
    server.dirty++;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %rdi, %rbx
movslq 0x38(%rdi), %r12
movq 0x40(%rdi), %r15
movb $0x1, %bpl
pushq $0x4
popq %r13
leaq 0x5940f(%rip), %r14     # 0xb9f5a
cmpq %r12, %r13
jge 0x60b79
movq (%r15,%r13,8), %rax
movq 0x8(%rax), %rdi
movq %r14, %rsi
callq 0x262f0
incq %r13
xorl %ebp, %ebp
testl %eax, %eax
je 0x60b4b
leaq 0x997a0(%rip), %rax     # 0xfa310
movq 0x80(%rax), %rsi
jmp 0x60b9f
testb $0x1, %bpl
je 0x60bb9
movq 0x10(%rbx), %rdi
movq 0x8(%r15), %rsi
callq 0x3aec2
testq %rax, %rax
je 0x60bb5
leaq 0x99778(%rip), %rax     # 0xfa310
movq 0xe0(%rax), %rsi
movq %rbx, %rdi
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x36987
movq 0x40(%rbx), %r15
movq 0x10(%r15), %rsi
leaq 0x8(%rsp), %rdx
movq %rbx, %rdi
xorl %ecx, %ecx
callq 0x3ab03
testl %eax, %eax
jne 0x60cf6
cmpq $0x0, 0x8(%rsp)
js 0x60cd5
movq 0x40(%rbx), %rax
movq 0x18(%rax), %rax
movq 0x8(%rax), %r14
movq %r14, %rdi
callq 0x5b5fd
movq %r14, %rdi
movq %rax, %rsi
callq 0x60a6f
cmpl $-0x1, %eax
je 0x60ce7
movq 0x40(%rbx), %rax
movq 0x18(%rax), %rax
movq 0x8(%rax), %rsi
leaq 0x10(%rsp), %r14
movq %r14, %rdi
callq 0x66a98
movq %r14, %rdi
callq 0x4100d
cmpl $-0x1, %eax
je 0x60cde
leaq 0x10(%rsp), %rsi
movl %eax, %edi
callq 0x41d5b
testq %rax, %rax
je 0x60cde
movq %rax, %r14
testb $0x1, %bpl
jne 0x60c61
movq 0x10(%rbx), %rdi
movq 0x40(%rbx), %rax
movq 0x8(%rax), %rsi
callq 0x3b1df
movq 0x10(%rbx), %rdi
movq 0x40(%rbx), %rax
movq 0x8(%rax), %rsi
movq %r14, %rdx
callq 0x3af45
cmpq $0x0, 0x8(%rsp)
je 0x60ca1
movq 0x10(%rbx), %r14
movq 0x40(%rbx), %rax
movq 0x8(%rax), %r15
callq 0x2b8ae
addq 0x8(%rsp), %rax
movq %r14, %rdi
movq %r15, %rsi
movq %rax, %rdx
callq 0x3c14f
movq 0x10(%rbx), %rdi
movq 0x40(%rbx), %rax
movq 0x8(%rax), %rsi
callq 0x3b125
leaq 0x99657(%rip), %rax     # 0xfa310
movq 0x8(%rax), %rsi
movq %rbx, %rdi
callq 0x36987
leaq 0x98bdc(%rip), %rax     # 0xf98a8
incq 0x720(%rax)
jmp 0x60cf6
leaq 0x59286(%rip), %rsi     # 0xb9f62
jmp 0x60cee
leaq 0x592c8(%rip), %rsi     # 0xb9fad
jmp 0x60cee
leaq 0x59294(%rip), %rsi     # 0xb9f82
movq %rbx, %rdi
callq 0x36b6f
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq