// File: /workspace/github_c_makefile_star2_O1/zhou-yuxin[P]redis-aof-no-cow/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 %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x70, %rsp
movq %rdi, %rbx
movslq 0x38(%rdi), %r15
cmpq $0x5, %r15
jge 0x6f51b
movq 0x10(%rbx), %rdi
movq 0x40(%rbx), %rax
movq 0x8(%rax), %rsi
callq 0x44f66
testq %rax, %rax
je 0x6f54e
leaq 0x97da1(%rip), %rax     # 0x1072b0
movq 0xe0(%rax), %rsi
jmp 0x6f5af
movq 0x40(%rbx), %r12
movl $0x4, %r13d
leaq 0x5c9be(%rip), %r14     # 0xcbeea
movq (%r12,%r13,8), %rax
movq 0x8(%rax), %rdi
movq %r14, %rsi
callq 0x26300
testl %eax, %eax
jne 0x6f5a1
incq %r13
cmpq %r13, %r15
jne 0x6f52c
cmpl $0x4, %r15d
jle 0x6f4f2
movq 0x40(%rbx), %rax
movq 0x10(%rax), %rsi
movq %rsp, %rdx
movq %rbx, %rdi
xorl %ecx, %ecx
callq 0x44b44
testl %eax, %eax
jne 0x6f6da
cmpq $0x0, (%rsp)
js 0x6f5c4
movq 0x40(%rbx), %rax
movq 0x18(%rax), %rax
movq 0x8(%rax), %rdi
movzbl -0x1(%rdi), %esi
movl %esi, %eax
andl $0x7, %eax
cmpl $0x4, %eax
ja 0x6f5e7
leaq 0x5af25(%rip), %rcx     # 0xca4b8
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
shrl $0x3, %esi
jmp 0x6f5e9
leaq 0x97d08(%rip), %rax     # 0x1072b0
movq 0x80(%rax), %rsi
movq %rbx, %rdi
addq $0x70, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0x3fc19
leaq 0x5c927(%rip), %rsi     # 0xcbef2
jmp 0x6f6d2
movq -0x11(%rdi), %rsi
jmp 0x6f5e9
movzwl -0x5(%rdi), %esi
jmp 0x6f5e9
movl -0x9(%rdi), %esi
jmp 0x6f5e9
movzbl -0x3(%rdi), %esi
jmp 0x6f5e9
xorl %esi, %esi
callq 0x6f41f
cmpl $-0x1, %eax
je 0x6f6cb
movq 0x40(%rbx), %rax
movq 0x18(%rax), %rax
movq 0x8(%rax), %rsi
leaq 0x8(%rsp), %r14
movq %r14, %rdi
callq 0x76150
movq %r14, %rdi
callq 0x4c019
cmpl $-0x1, %eax
je 0x6f6c2
leaq 0x8(%rsp), %rsi
movl %eax, %edi
callq 0x4cfb6
testq %rax, %rax
je 0x6f6c2
movq %rax, %r14
cmpl $0x5, %r15d
jl 0x6f650
movq 0x10(%rbx), %rdi
movq 0x40(%rbx), %rax
movq 0x8(%rax), %rsi
callq 0x452f3
movq 0x10(%rbx), %rdi
movq 0x40(%rbx), %rax
movq 0x8(%rax), %rsi
movq %r14, %rdx
callq 0x45007
cmpq $0x0, (%rsp)
je 0x6f68e
movq 0x10(%rbx), %r14
movq 0x40(%rbx), %rax
movq 0x8(%rax), %r15
callq 0x330c8
addq (%rsp), %rax
movq %r14, %rdi
movq %r15, %rsi
movq %rax, %rdx
callq 0x46505
movq 0x10(%rbx), %rdi
movq 0x40(%rbx), %rax
movq 0x8(%rax), %rsi
callq 0x45220
leaq 0x97c0a(%rip), %rax     # 0x1072b0
movq 0x8(%rax), %rsi
movq %rbx, %rdi
callq 0x3fc19
leaq 0x9719f(%rip), %rax     # 0x106858
incq 0x710(%rax)
jmp 0x6f6da
leaq 0x5c874(%rip), %rsi     # 0xcbf3d
jmp 0x6f6d2
leaq 0x5c840(%rip), %rsi     # 0xcbf12
movq %rbx, %rdi
callq 0x3ffcb
addq $0x70, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq