// File: /workspace/github_c_makefile_star2_O2/gplessis[P]dotdeb-redis/src/server.c
// Function: processCommand
int processCommand(client *c) {
    /* The QUIT command is handled separately. Normal command procs will
     * go through checking for replication and QUIT will cause trouble
     * when FORCE_REPLICATION is enabled and would be implemented in
     * a regular command proc. */
    if (!strcasecmp(c->argv[0]->ptr,"quit")) {
        addReply(c,shared.ok);
        c->flags |= CLIENT_CLOSE_AFTER_REPLY;
        return C_ERR;
    }

    /* Now lookup the command and check ASAP about trivial error conditions
     * such as wrong arity, bad command name and so forth. */
    c->cmd = c->lastcmd = lookupCommand(c->argv[0]->ptr);
    if (!c->cmd) {
        flagTransaction(c);
        addReplyErrorFormat(c,"unknown command '%s'",
            (char*)c->argv[0]->ptr);
        return C_OK;
    } else if ((c->cmd->arity > 0 && c->cmd->arity != c->argc) ||
               (c->argc < -c->cmd->arity)) {
        flagTransaction(c);
        addReplyErrorFormat(c,"wrong number of arguments for '%s' command",
            c->cmd->name);
        return C_OK;
    }

    /* Check if the user is authenticated */
    if (server.requirepass && !c->authenticated && c->cmd->proc != authCommand)
    {
        flagTransaction(c);
        addReply(c,shared.noautherr);
        return C_OK;
    }

    /* If cluster is enabled perform the cluster redirection here.
     * However we don't perform the redirection if:
     * 1) The sender of this command is our master.
     * 2) The command has no key arguments. */
    if (server.cluster_enabled &&
        !(c->flags & CLIENT_MASTER) &&
        !(c->flags & CLIENT_LUA &&
          server.lua_caller->flags & CLIENT_MASTER) &&
        !(c->cmd->getkeys_proc == NULL && c->cmd->firstkey == 0 &&
          c->cmd->proc != execCommand))
    {
        int hashslot;
        int error_code;
        clusterNode *n = getNodeByQuery(c,c->cmd,c->argv,c->argc,
                                        &hashslot,&error_code);
        if (n == NULL || n != server.cluster->myself) {
            if (c->cmd->proc == execCommand) {
                discardTransaction(c);
            } else {
                flagTransaction(c);
            }
            clusterRedirectClient(c,n,hashslot,error_code);
            return C_OK;
        }
    }

    /* Handle the maxmemory directive.
     *
     * First we try to free some memory if possible (if there are volatile
     * keys in the dataset). If there are not the only thing we can do
     * is returning an error. */
    if (server.maxmemory) {
        int retval = freeMemoryIfNeeded();
        /* freeMemoryIfNeeded may flush slave output buffers. This may result
         * into a slave, that may be the active client, to be freed. */
        if (server.current_client == NULL) return C_ERR;

        /* It was impossible to free enough memory, and the command the client
         * is trying to execute is denied during OOM conditions? Error. */
        if ((c->cmd->flags & CMD_DENYOOM) && retval == C_ERR) {
            flagTransaction(c);
            addReply(c, shared.oomerr);
            return C_OK;
        }
    }

    /* Don't accept write commands if there are problems persisting on disk
     * and if this is a master instance. */
    if (((server.stop_writes_on_bgsave_err &&
          server.saveparamslen > 0 &&
          server.lastbgsave_status == C_ERR) ||
          server.aof_last_write_status == C_ERR) &&
        server.masterhost == NULL &&
        (c->cmd->flags & CMD_WRITE ||
         c->cmd->proc == pingCommand))
    {
        flagTransaction(c);
        if (server.aof_last_write_status == C_OK)
            addReply(c, shared.bgsaveerr);
        else
            addReplySds(c,
                sdscatprintf(sdsempty(),
                "-MISCONF Errors writing to the AOF file: %s\r\n",
                strerror(server.aof_last_write_errno)));
        return C_OK;
    }

    /* Don't accept write commands if there are not enough good slaves and
     * user configured the min-slaves-to-write option. */
    if (server.masterhost == NULL &&
        server.repl_min_slaves_to_write &&
        server.repl_min_slaves_max_lag &&
        c->cmd->flags & CMD_WRITE &&
        server.repl_good_slaves_count < server.repl_min_slaves_to_write)
    {
        flagTransaction(c);
        addReply(c, shared.noreplicaserr);
        return C_OK;
    }

    /* Don't accept write commands if this is a read only slave. But
     * accept write commands if this is our master. */
    if (server.masterhost && server.repl_slave_ro &&
        !(c->flags & CLIENT_MASTER) &&
        c->cmd->flags & CMD_WRITE)
    {
        addReply(c, shared.roslaveerr);
        return C_OK;
    }

    /* Only allow SUBSCRIBE and UNSUBSCRIBE in the context of Pub/Sub */
    if (c->flags & CLIENT_PUBSUB &&
        c->cmd->proc != pingCommand &&
        c->cmd->proc != subscribeCommand &&
        c->cmd->proc != unsubscribeCommand &&
        c->cmd->proc != psubscribeCommand &&
        c->cmd->proc != punsubscribeCommand) {
        addReplyError(c,"only (P)SUBSCRIBE / (P)UNSUBSCRIBE / PING / QUIT allowed in this context");
        return C_OK;
    }

    /* Only allow INFO and SLAVEOF when slave-serve-stale-data is no and
     * we are a slave with a broken link with master. */
    if (server.masterhost && server.repl_state != REPL_STATE_CONNECTED &&
        server.repl_serve_stale_data == 0 &&
        !(c->cmd->flags & CMD_STALE))
    {
        flagTransaction(c);
        addReply(c, shared.masterdownerr);
        return C_OK;
    }

    /* Loading DB? Return an error if the command has not the
     * CMD_LOADING flag. */
    if (server.loading && !(c->cmd->flags & CMD_LOADING)) {
        addReply(c, shared.loadingerr);
        return C_OK;
    }

    /* Lua script too slow? Only allow a limited number of commands. */
    if (server.lua_timedout &&
          c->cmd->proc != authCommand &&
          c->cmd->proc != replconfCommand &&
        !(c->cmd->proc == shutdownCommand &&
          c->argc == 2 &&
          tolower(((char*)c->argv[1]->ptr)[0]) == 'n') &&
        !(c->cmd->proc == scriptCommand &&
          c->argc == 2 &&
          tolower(((char*)c->argv[1]->ptr)[0]) == 'k'))
    {
        flagTransaction(c);
        addReply(c, shared.slowscripterr);
        return C_OK;
    }

    /* Exec the command */
    if (c->flags & CLIENT_MULTI &&
        c->cmd->proc != execCommand && c->cmd->proc != discardCommand &&
        c->cmd->proc != multiCommand && c->cmd->proc != watchCommand)
    {
        queueMultiCommand(c);
        addReply(c,shared.queued);
    } else {
        call(c,CMD_CALL_FULL);
        c->woff = server.master_repl_offset;
        if (listLength(server.ready_keys))
            handleClientsBlockedOnLists();
    }
    return C_OK;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0x10, %rsp
movq %rdi, %rbx
movq 0x40(%rdi), %rax
movq (%rax), %rax
movq 0x8(%rax), %r14
leaq 0x81040(%rip), %rsi     # 0xaf55a
movq %r14, %rdi
callq 0x262f0
pushq $-0x1
popq %rbp
testl %eax, %eax
je 0x2e56c
movq %r14, %rdi
callq 0x2e0f6
movq %rax, 0x50(%rbx)
movq %rax, 0x48(%rbx)
testq %rax, %rax
je 0x2e584
movl 0x10(%rax), %edx
movl 0x38(%rbx), %ecx
testl %edx, %edx
jle 0x2e54e
cmpl %ecx, %edx
movl %edx, %ecx
jne 0x2e554
negl %edx
cmpl %edx, %ecx
jge 0x2e5b5
movq %rbx, %rdi
callq 0x56fa9
movq 0x48(%rbx), %rax
movq (%rax), %rdx
leaq 0x8100a(%rip), %rsi     # 0xaf574
jmp 0x2e59e
movq 0xcbda5(%rip), %rsi     # 0xfa318
movq %rbx, %rdi
callq 0x36987
orb $0x40, 0x98(%rbx)
jmp 0x2e5aa
movq %rbx, %rdi
callq 0x56fa9
movq 0x40(%rbx), %rax
movq (%rax), %rax
movq 0x8(%rax), %rdx
leaq 0x80fc1(%rip), %rsi     # 0xaf55f
xorl %ebp, %ebp
movq %rbx, %rdi
xorl %eax, %eax
callq 0x36b96
movl %ebp, %eax
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq
cmpq $0x0, 0xcb343(%rip)     # 0xf9900
je 0x2e5cc
cmpl $0x0, 0x9c(%rbx)
je 0x2e65b
cmpl $0x0, 0xcbc71(%rip)     # 0xfa244
je 0x2e6ae
movl 0x98(%rbx), %edx
testb $0x2, %dl
jne 0x2e6ae
btl $0x8, %edx
jae 0x2e602
movq 0xcbc8b(%rip), %rdx     # 0xfa280
testb $0x2, 0x98(%rdx)
jne 0x2e6ae
cmpq $0x0, 0x28(%rax)
jne 0x2e613
cmpl $0x0, 0x30(%rax)
je 0x2e69d
movq 0x40(%rbx), %rdx
leaq 0xc(%rsp), %r8
leaq 0x8(%rsp), %r9
movq %rbx, %rdi
movq %rax, %rsi
callq 0x619bf
movq %rax, %r14
testq %rax, %rax
je 0x2e640
movq 0xcbc1d(%rip), %rax     # 0xfa258
cmpq (%rax), %r14
je 0x2e6ae
movq 0x48(%rbx), %rax
movq 0x8(%rax), %rax
movq %rbx, %rdi
cmpq 0xc68be(%rip), %rax     # 0xf4f10
je 0x2e680
callq 0x56fa9
jmp 0x2e685
leaq -0x34fe(%rip), %rdx     # 0x2b164
cmpq %rdx, 0x8(%rax)
je 0x2e5cc
movq %rbx, %rdi
callq 0x56fa9
movq 0xcbd65(%rip), %rsi     # 0xfa3e0
jmp 0x2ea04
callq 0x56ea3
movl 0xc(%rsp), %edx
movl 0x8(%rsp), %ecx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x61d3e
jmp 0x2ea0c
movq 0x8(%rax), %rdx
cmpq 0xc6868(%rip), %rdx     # 0xf4f10
je 0x2e613
cmpq $0x0, 0xcbafa(%rip)     # 0xfa1b0
je 0x2e6f0
callq 0x2ea13
cmpq $0x0, 0xcb3d3(%rip)     # 0xf9a98
je 0x2e5aa
cmpl $-0x1, %eax
jne 0x2e6f0
movq 0x48(%rbx), %rax
movl 0x20(%rax), %eax
andl $0x4, %eax
je 0x2e6f0
movq %rbx, %rdi
callq 0x56fa9
movq 0xcbd0d(%rip), %rsi     # 0xfa3f8
jmp 0x2ea04
cmpl $0x0, 0xcb935(%rip)     # 0xfa02c
setne %al
cmpl $0x0, 0xcb8e7(%rip)     # 0xf9fe8
setg %cl
andb %al, %cl
cmpl $-0x1, 0xcb91b(%rip)    # 0xfa028
sete %al
andb %cl, %al
cmpl $-0x1, 0xcb87b(%rip)    # 0xf9f94
sete %cl
orb %al, %cl
movq 0xcb9ab(%rip), %rax     # 0xfa0d0
testq %rax, %rax
sete %dl
andb %cl, %dl
cmpb $0x1, %dl
jne 0x2e751
movq 0x48(%rbx), %rcx
testb $0x1, 0x20(%rcx)
jne 0x2e802
leaq -0x3584(%rip), %rdx     # 0x2b1c3
cmpq %rdx, 0x8(%rcx)
je 0x2e802
testq %rax, %rax
jne 0x2e78f
movl 0xcb954(%rip), %ecx     # 0xfa0b0
testl %ecx, %ecx
je 0x2e78f
cmpl $0x0, 0xcb94d(%rip)     # 0xfa0b4
je 0x2e78f
movq 0x48(%rbx), %rdx
testb $0x1, 0x20(%rdx)
je 0x2e78f
cmpl %ecx, 0xcb93f(%rip)     # 0xfa0b8
jge 0x2e78f
movq %rbx, %rdi
callq 0x56fa9
movq 0xcbc5e(%rip), %rsi     # 0xfa3e8
jmp 0x2ea04
testq %rax, %rax
setne %cl
cmpl $0x0, 0xcb990(%rip)     # 0xfa12c
setne %dl
andb %cl, %dl
movl 0x98(%rbx), %ebp
testb $0x2, %bpl
sete %cl
andb %dl, %cl
cmpb $0x1, %cl
jne 0x2e7c3
movq 0x48(%rbx), %rcx
testb $0x1, 0x20(%rcx)
jne 0x2e948
btl $0x12, %ebp
jb 0x2e86f
testq %rax, %rax
je 0x2e850
cmpl $0xf, 0xcb91b(%rip)     # 0xfa0f4
je 0x2e850
cmpl $0x0, 0xcb946(%rip)     # 0xfa128
jne 0x2e850
movq 0x48(%rbx), %rax
testb $0x4, 0x21(%rax)
jne 0x2e850
movq %rbx, %rdi
callq 0x56fa9
movq 0xcbbcb(%rip), %rsi     # 0xfa3c8
jmp 0x2ea04
movq %rbx, %rdi
callq 0x56fa9
cmpl $0x0, 0xcb783(%rip)     # 0xf9f94
je 0x2e93c
callq 0x3114c
movq %rax, %r14
movl 0xcb773(%rip), %edi     # 0xf9f98
callq 0x26680
leaq 0x80d6e(%rip), %rsi     # 0xaf59f
xorl %ebp, %ebp
movq %r14, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x31a38
movq %rbx, %rdi
movq %rax, %rsi
callq 0x36a9d
jmp 0x2e5aa
cmpl $0x0, 0xcb36d(%rip)     # 0xf9bc4
je 0x2e8cf
movq 0x48(%rbx), %rax
testb $0x2, 0x21(%rax)
jne 0x2e8cf
movq 0xcbb46(%rip), %rsi     # 0xfa3b0
jmp 0x2ea04
movq 0x48(%rbx), %rcx
movq 0x8(%rcx), %rcx
cmpq 0xc66d2(%rip), %rcx     # 0xf4f50
je 0x2e7cd
cmpq 0xc6715(%rip), %rcx     # 0xf4fa0
je 0x2e7cd
cmpq 0xc66f8(%rip), %rcx     # 0xf4f90
je 0x2e7cd
leaq -0x36e2(%rip), %rdx     # 0x2b1c3
cmpq %rdx, %rcx
je 0x2e7cd
cmpq 0xc66b3(%rip), %rcx     # 0xf4f68
je 0x2e7cd
leaq 0x80d0b(%rip), %rsi     # 0xaf5cd
movq %rbx, %rdi
callq 0x36b6f
jmp 0x2ea0c
cmpl $0x0, 0xcb9de(%rip)     # 0xfa2b4
je 0x2e8ff
movq 0x48(%rbx), %rax
movq 0x8(%rax), %rax
leaq -0x3783(%rip), %rcx     # 0x2b164
cmpq %rcx, %rax
sete %cl
cmpq 0xc66a4(%rip), %rax     # 0xf4f98
sete %dl
orb %cl, %dl
je 0x2e991
testb $0x8, %bpl
jne 0x2e954
pushq $0xf
popq %rsi
movq %rbx, %rdi
callq 0x2e246
movq 0xcb751(%rip), %rax     # 0xfa068
movq %rax, 0x198(%rbx)
movq 0xcb8ab(%rip), %rax     # 0xfa1d0
xorl %ebp, %ebp
cmpq $0x0, 0x28(%rax)
je 0x2e5aa
callq 0x457dd
jmp 0x2e5aa
movq 0xcba7d(%rip), %rsi     # 0xfa3c0
jmp 0x2ea04
movq 0xcba81(%rip), %rsi     # 0xfa3d0
jmp 0x2ea04
movq 0x48(%rbx), %rax
movq 0x8(%rax), %rax
cmpq 0xc661d(%rip), %rax     # 0xf4f80
je 0x2e905
cmpq 0xc65dc(%rip), %rax     # 0xf4f48
je 0x2e905
cmpq 0xc659b(%rip), %rax     # 0xf4f10
je 0x2e905
cmpq 0xc6672(%rip), %rax     # 0xf4ff0
je 0x2e905
movq %rbx, %rdi
callq 0x56e02
movq 0xcb9e1(%rip), %rsi     # 0xfa370
jmp 0x2ea04
cmpq 0xc6610(%rip), %rax     # 0xf4fa8
je 0x2e9cd
cmpq 0xc658f(%rip), %rax     # 0xf4f30
jne 0x2e9f5
cmpl $0x2, 0x38(%rbx)
jne 0x2e9f5
callq 0x269a0
movq (%rax), %rax
movq 0x40(%rbx), %rcx
movq 0x8(%rcx), %rcx
movq 0x8(%rcx), %rcx
movsbq (%rcx), %rcx
cmpl $0x6b, (%rax,%rcx,4)
je 0x2e8ff
jmp 0x2e9f5
cmpl $0x2, 0x38(%rbx)
jne 0x2e9f5
callq 0x269a0
movq (%rax), %rax
movq 0x40(%rbx), %rcx
movq 0x8(%rcx), %rcx
movq 0x8(%rcx), %rcx
movsbq (%rcx), %rcx
cmpl $0x6e, (%rax,%rcx,4)
je 0x2e8ff
movq %rbx, %rdi
callq 0x56fa9
movq 0xcb9b4(%rip), %rsi     # 0xfa3b8
movq %rbx, %rdi
callq 0x36987
xorl %ebp, %ebp
jmp 0x2e5aa