// File: /workspace/github_c_makefile_star2_O3/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 0x8a47e(%rip), %rsi     # 0xbd66a
movq %r14, %rdi
callq 0x262f0
testl %eax, %eax
je 0x33242
movq 0xce6d9(%rip), %rdi     # 0x1018d8
movq %r14, %rsi
callq 0x2ef19
movq %rax, 0x50(%rbx)
movq %rax, 0x48(%rbx)
testq %rax, %rax
je 0x3325f
movl 0x10(%rax), %edx
movl 0x38(%rbx), %ecx
testl %edx, %edx
jle 0x33224
cmpl %ecx, %edx
movl %edx, %ecx
jne 0x3322a
negl %edx
cmpl %edx, %ecx
jge 0x33290
movq %rbx, %rdi
callq 0x60bdc
movq 0x48(%rbx), %rax
movq (%rax), %rdx
leaq 0x8a444(%rip), %rsi     # 0xbd684
jmp 0x33279
movq 0xcf0cf(%rip), %rsi     # 0x102318
movq %rbx, %rdi
callq 0x3c854
orb $0x40, 0x98(%rbx)
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
jmp 0x33285
movq %rbx, %rdi
callq 0x60bdc
movq 0x40(%rbx), %rax
movq (%rax), %rax
movq 0x8(%rax), %rdx
leaq 0x8a3f6(%rip), %rsi     # 0xbd66f
xorl %ebp, %ebp
movq %rbx, %rdi
xorl %eax, %eax
callq 0x3cc2d
movl %ebp, %eax
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq
cmpq $0x0, 0xce668(%rip)     # 0x101900
je 0x332a7
cmpl $0x0, 0x9c(%rbx)
je 0x33336
cmpl $0x0, 0xcef96(%rip)     # 0x102244
je 0x33389
movl 0x98(%rbx), %edx
testb $0x2, %dl
jne 0x33389
btl $0x8, %edx
jae 0x332dd
movq 0xcefb0(%rip), %rdx     # 0x102280
testb $0x2, 0x98(%rdx)
jne 0x33389
cmpq $0x0, 0x28(%rax)
jne 0x332ee
cmpl $0x0, 0x30(%rax)
je 0x33378
movq 0x40(%rbx), %rdx
leaq 0xc(%rsp), %r8
leaq 0x8(%rsp), %r9
movq %rbx, %rdi
movq %rax, %rsi
callq 0x6cae4
movq %rax, %r14
testq %rax, %rax
je 0x3331b
movq 0xcef42(%rip), %rax     # 0x102258
cmpq (%rax), %r14
je 0x33389
movq 0x48(%rbx), %rax
movq 0x8(%rax), %rax
movq %rbx, %rdi
cmpq 0xc9be3(%rip), %rax     # 0xfcf10
je 0x3335b
callq 0x60bdc
jmp 0x33360
leaq -0x3b09(%rip), %rdx     # 0x2f834
cmpq %rdx, 0x8(%rax)
je 0x332a7
movq %rbx, %rdi
callq 0x60bdc
movq 0xcf08a(%rip), %rsi     # 0x1023e0
jmp 0x336d6
callq 0x60ab4
movl 0xc(%rsp), %edx
movl 0x8(%rsp), %ecx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x6cee7
jmp 0x336de
movq 0x8(%rax), %rdx
cmpq 0xc9b8d(%rip), %rdx     # 0xfcf10
je 0x332ee
cmpq $0x0, 0xcee1f(%rip)     # 0x1021b0
je 0x333cb
callq 0x336e5
cmpq $0x0, 0xce6f8(%rip)     # 0x101a98
je 0x33258
cmpl $-0x1, %eax
jne 0x333cb
movq 0x48(%rbx), %rax
movl 0x20(%rax), %eax
andl $0x4, %eax
je 0x333cb
movq %rbx, %rdi
callq 0x60bdc
movq 0xcf032(%rip), %rsi     # 0x1023f8
jmp 0x336d6
cmpl $0x0, 0xcec5a(%rip)     # 0x10202c
setne %al
cmpl $0x0, 0xcec0c(%rip)     # 0x101fe8
setg %cl
andb %al, %cl
cmpl $-0x1, 0xcec40(%rip)    # 0x102028
sete %al
andb %cl, %al
cmpl $-0x1, 0xceba0(%rip)    # 0x101f94
sete %cl
orb %al, %cl
movq 0xcecd0(%rip), %rax     # 0x1020d0
testq %rax, %rax
sete %dl
andb %cl, %dl
cmpb $0x1, %dl
jne 0x33424
movq 0x48(%rbx), %rcx
testb $0x1, 0x20(%rcx)
jne 0x33474
leaq -0x3b88(%rip), %rdx     # 0x2f896
cmpq %rdx, 0x8(%rcx)
je 0x33474
testq %rax, %rax
jne 0x334c2
movl 0xcec7d(%rip), %ecx     # 0x1020b0
testl %ecx, %ecx
je 0x334c2
cmpl $0x0, 0xcec72(%rip)     # 0x1020b4
je 0x334c2
movq 0x48(%rbx), %rdx
xorl %eax, %eax
testb $0x1, 0x20(%rdx)
je 0x334ec
cmpl %ecx, 0xcec5e(%rip)     # 0x1020b8
jge 0x334ec
movq %rbx, %rdi
callq 0x60bdc
movq 0xcef79(%rip), %rsi     # 0x1023e8
jmp 0x336d6
movq %rbx, %rdi
callq 0x60bdc
cmpl $0x0, 0xceb11(%rip)     # 0x101f94
je 0x33611
callq 0x3628d
movq %rax, %r14
movl 0xceb01(%rip), %edi     # 0x101f98
callq 0x26680
leaq 0x8a20c(%rip), %rsi     # 0xbd6af
xorl %ebp, %ebp
movq %r14, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x36f2d
movq %rbx, %rdi
movq %rax, %rsi
callq 0x3ca86
jmp 0x33285
testq %rax, %rax
setne %al
je 0x334ec
cmpl $0x0, 0xcec5b(%rip)     # 0x10212c
je 0x334ec
movb $0x1, %al
testb $0x2, 0x98(%rbx)
jne 0x334ec
movq 0x48(%rbx), %rcx
testb $0x1, 0x20(%rcx)
jne 0x33696
movl 0x98(%rbx), %ebp
btl $0x12, %ebp
jb 0x3354e
cmpl $0xf, 0xcebf5(%rip)     # 0x1020f4
setne %cl
andb %cl, %al
cmpb $0x1, %al
jne 0x3352f
cmpl $0x0, 0xcec19(%rip)     # 0x102128
jne 0x3352f
movq 0x48(%rbx), %rax
testb $0x4, 0x21(%rax)
jne 0x3352f
movq %rbx, %rdi
callq 0x60bdc
movq 0xcee9e(%rip), %rsi     # 0x1023c8
jmp 0x336d6
cmpl $0x0, 0xce68e(%rip)     # 0x101bc4
je 0x335a2
movq 0x48(%rbx), %rax
testb $0x2, 0x21(%rax)
jne 0x335a2
movq 0xcee67(%rip), %rsi     # 0x1023b0
jmp 0x336d6
movq 0x48(%rbx), %rcx
movq 0x8(%rcx), %rcx
cmpq 0xc99f3(%rip), %rcx     # 0xfcf50
je 0x334f8
cmpq 0xc9a3a(%rip), %rcx     # 0xfcfa0
je 0x334f8
cmpq 0xc9a21(%rip), %rcx     # 0xfcf90
je 0x334f8
leaq -0x3ce2(%rip), %rdx     # 0x2f896
cmpq %rdx, %rcx
je 0x334f8
cmpq 0xc99e0(%rip), %rcx     # 0xfcf68
je 0x334f8
leaq 0x8a148(%rip), %rsi     # 0xbd6dd
movq %rbx, %rdi
callq 0x3cc06
jmp 0x336de
cmpl $0x0, 0xced0b(%rip)     # 0x1022b4
je 0x335d2
movq 0x48(%rbx), %rax
movq 0x8(%rax), %rax
leaq -0x3d86(%rip), %rcx     # 0x2f834
cmpq %rcx, %rax
sete %cl
cmpq 0xc99d1(%rip), %rax     # 0xfcf98
sete %dl
orb %cl, %dl
je 0x3365a
testb $0x8, %bpl
jne 0x3361d
movq %rbx, %rdi
movl $0xf, %esi
callq 0x32eba
movq 0xcea7c(%rip), %rax     # 0x102068
movq %rax, 0x198(%rbx)
movq 0xcebd6(%rip), %rax     # 0x1021d0
xorl %ebp, %ebp
cmpq $0x0, 0x28(%rax)
je 0x33285
callq 0x4db5c
jmp 0x33285
movq 0xceda8(%rip), %rsi     # 0x1023c0
jmp 0x336d6
movq 0x48(%rbx), %rax
movq 0x8(%rax), %rax
cmpq 0xc9954(%rip), %rax     # 0xfcf80
je 0x335d8
cmpq 0xc9913(%rip), %rax     # 0xfcf48
je 0x335d8
cmpq 0xc98d2(%rip), %rax     # 0xfcf10
je 0x335d8
cmpq 0xc99a9(%rip), %rax     # 0xfcff0
je 0x335d8
movq %rbx, %rdi
callq 0x60a14
movq 0xced18(%rip), %rsi     # 0x102370
jmp 0x336d6
cmpq 0xc9947(%rip), %rax     # 0xfcfa8
je 0x3369f
cmpq 0xc98c6(%rip), %rax     # 0xfcf30
jne 0x336c7
cmpl $0x2, 0x38(%rbx)
jne 0x336c7
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 0x335d2
jmp 0x336c7
movq 0xced33(%rip), %rsi     # 0x1023d0
jmp 0x336d6
cmpl $0x2, 0x38(%rbx)
jne 0x336c7
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 0x335d2
movq %rbx, %rdi
callq 0x60bdc
movq 0xcece2(%rip), %rsi     # 0x1023b8
movq %rbx, %rdi
callq 0x3c854
xorl %ebp, %ebp
jmp 0x33285