// File: /workspace/github_c_makefile_star2_O2/gplessis[P]dotdeb-redis/src/networking.c
// Function: clientCommand
void clientCommand(client *c) {
    listNode *ln;
    listIter li;
    client *client;

    if (!strcasecmp(c->argv[1]->ptr,"list") && c->argc == 2) {
        /* CLIENT LIST */
        sds o = getAllClientsInfoString();
        addReplyBulkCBuffer(c,o,sdslen(o));
        sdsfree(o);
    } else if (!strcasecmp(c->argv[1]->ptr,"reply") && c->argc == 3) {
        /* CLIENT REPLY ON|OFF|SKIP */
        if (!strcasecmp(c->argv[2]->ptr,"on")) {
            c->flags &= ~(CLIENT_REPLY_SKIP|CLIENT_REPLY_OFF);
            addReply(c,shared.ok);
        } else if (!strcasecmp(c->argv[2]->ptr,"off")) {
            c->flags |= CLIENT_REPLY_OFF;
        } else if (!strcasecmp(c->argv[2]->ptr,"skip")) {
            if (!(c->flags & CLIENT_REPLY_OFF))
                c->flags |= CLIENT_REPLY_SKIP_NEXT;
        } else {
            addReply(c,shared.syntaxerr);
            return;
        }
    } else if (!strcasecmp(c->argv[1]->ptr,"kill")) {
        /* CLIENT KILL <ip:port>
         * CLIENT KILL <option> [value] ... <option> [value] */
        char *addr = NULL;
        int type = -1;
        uint64_t id = 0;
        int skipme = 1;
        int killed = 0, close_this_client = 0;

        if (c->argc == 3) {
            /* Old style syntax: CLIENT KILL <addr> */
            addr = c->argv[2]->ptr;
            skipme = 0; /* With the old form, you can kill yourself. */
        } else if (c->argc > 3) {
            int i = 2; /* Next option index. */

            /* New style syntax: parse options. */
            while(i < c->argc) {
                int moreargs = c->argc > i+1;

                if (!strcasecmp(c->argv[i]->ptr,"id") && moreargs) {
                    long long tmp;

                    if (getLongLongFromObjectOrReply(c,c->argv[i+1],&tmp,NULL)
                        != C_OK) return;
                    id = tmp;
                } else if (!strcasecmp(c->argv[i]->ptr,"type") && moreargs) {
                    type = getClientTypeByName(c->argv[i+1]->ptr);
                    if (type == -1) {
                        addReplyErrorFormat(c,"Unknown client type '%s'",
                            (char*) c->argv[i+1]->ptr);
                        return;
                    }
                } else if (!strcasecmp(c->argv[i]->ptr,"addr") && moreargs) {
                    addr = c->argv[i+1]->ptr;
                } else if (!strcasecmp(c->argv[i]->ptr,"skipme") && moreargs) {
                    if (!strcasecmp(c->argv[i+1]->ptr,"yes")) {
                        skipme = 1;
                    } else if (!strcasecmp(c->argv[i+1]->ptr,"no")) {
                        skipme = 0;
                    } else {
                        addReply(c,shared.syntaxerr);
                        return;
                    }
                } else {
                    addReply(c,shared.syntaxerr);
                    return;
                }
                i += 2;
            }
        } else {
            addReply(c,shared.syntaxerr);
            return;
        }

        /* Iterate clients killing all the matching clients. */
        listRewind(server.clients,&li);
        while ((ln = listNext(&li)) != NULL) {
            client = listNodeValue(ln);
            if (addr && strcmp(getClientPeerId(client),addr) != 0) continue;
            if (type != -1 && getClientType(client) != type) continue;
            if (id != 0 && client->id != id) continue;
            if (c == client && skipme) continue;

            /* Kill it. */
            if (c == client) {
                close_this_client = 1;
            } else {
                freeClient(client);
            }
            killed++;
        }

        /* Reply according to old/new format. */
        if (c->argc == 3) {
            if (killed == 0)
                addReplyError(c,"No such client");
            else
                addReply(c,shared.ok);
        } else {
            addReplyLongLong(c,killed);
        }

        /* If this client has to be closed, flag it as CLOSE_AFTER_REPLY
         * only after we queued the reply to its output buffers. */
        if (close_this_client) c->flags |= CLIENT_CLOSE_AFTER_REPLY;
    } else if (!strcasecmp(c->argv[1]->ptr,"setname") && c->argc == 3) {
        int j, len = sdslen(c->argv[2]->ptr);
        char *p = c->argv[2]->ptr;

        /* Setting the client name to an empty string actually removes
         * the current name. */
        if (len == 0) {
            if (c->name) decrRefCount(c->name);
            c->name = NULL;
            addReply(c,shared.ok);
            return;
        }

        /* Otherwise check if the charset is ok. We need to do this otherwise
         * CLIENT LIST format will break. You should always be able to
         * split by space to get the different fields. */
        for (j = 0; j < len; j++) {
            if (p[j] < '!' || p[j] > '~') { /* ASCII is assumed. */
                addReplyError(c,
                    "Client names cannot contain spaces, "
                    "newlines or special characters.");
                return;
            }
        }
        if (c->name) decrRefCount(c->name);
        c->name = c->argv[2];
        incrRefCount(c->name);
        addReply(c,shared.ok);
    } else if (!strcasecmp(c->argv[1]->ptr,"getname") && c->argc == 2) {
        if (c->name)
            addReplyBulk(c,c->name);
        else
            addReply(c,shared.nullbulk);
    } else if (!strcasecmp(c->argv[1]->ptr,"pause") && c->argc == 3) {
        long long duration;

        if (getTimeoutFromObjectOrReply(c,c->argv[2],&duration,UNIT_MILLISECONDS)
                                        != C_OK) return;
        pauseClients(duration);
        addReply(c,shared.ok);
    } else {
        addReplyError(c, "Syntax error, try CLIENT (LIST | KILL | GETNAME | SETNAME | PAUSE | REPLY)");
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdi, %rbx
movq 0x40(%rdi), %r15
movq 0x8(%r15), %rax
movq 0x8(%rax), %r14
leaq 0x79e7a(%rip), %rsi     # 0xb26a6
movq %r14, %rdi
callq 0x262f0
testl %eax, %eax
jne 0x38872
cmpl $0x2, 0x38(%rbx)
jne 0x38872
callq 0x3877b
movq %rax, %r14
movq %rax, %rdi
callq 0x3670c
movq %rbx, %rdi
movq %r14, %rsi
movq %rax, %rdx
callq 0x3716c
movq %r14, %rdi
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x311c8
leaq 0x85131(%rip), %rsi     # 0xbd9aa
movq %r14, %rdi
callq 0x262f0
testl %eax, %eax
jne 0x388f8
cmpl $0x3, 0x38(%rbx)
jne 0x388f8
movq 0x10(%r15), %rax
movq 0x8(%rax), %r14
leaq 0x88511(%rip), %rsi     # 0xc0dab
movq %r14, %rdi
callq 0x262f0
testl %eax, %eax
je 0x38bd5
leaq 0x793da(%rip), %rsi     # 0xb1c8b
movq %r14, %rdi
callq 0x262f0
testl %eax, %eax
je 0x38be4
leaq 0x793c7(%rip), %rsi     # 0xb1c8f
movq %r14, %rdi
callq 0x262f0
testl %eax, %eax
jne 0x38bc2
movl 0x98(%rbx), %eax
btl $0x16, %eax
jb 0x38d00
orl $0x800000, %eax         # imm = 0x800000
movl %eax, 0x98(%rbx)
jmp 0x38d00
leaq 0x79395(%rip), %rsi     # 0xb1c94
movq %r14, %rdi
callq 0x262f0
testl %eax, %eax
je 0x389fe
leaq 0x793b6(%rip), %rsi     # 0xb1ccc
movq %r14, %rdi
callq 0x262f0
testl %eax, %eax
jne 0x3896b
cmpl $0x3, 0x38(%rbx)
jne 0x3896b
movq 0x10(%r15), %r14
movq 0x8(%r14), %r15
movq %r15, %rdi
callq 0x3670c
testl %eax, %eax
je 0x38d0f
xorl %ecx, %ecx
testl %eax, %eax
cmovlel %ecx, %eax
cmpq %rcx, %rax
je 0x38d24
movb (%r15,%rcx), %dl
addb $-0x7f, %dl
incq %rcx
cmpb $-0x5f, %dl
ja 0x38947
leaq 0x7936e(%rip), %rsi     # 0xb1cd4
jmp 0x38a29
leaq 0x793a6(%rip), %rsi     # 0xb1d18
movq %r14, %rdi
callq 0x262f0
testl %eax, %eax
jne 0x389a7
cmpl $0x2, 0x38(%rbx)
jne 0x389a7
movq 0x20(%rbx), %rsi
testq %rsi, %rsi
je 0x38d67
movq %rbx, %rdi
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x36fd9
leaq 0x89009(%rip), %rsi     # 0xc19b7
movq %r14, %rdi
callq 0x262f0
testl %eax, %eax
jne 0x38a22
cmpl $0x3, 0x38(%rbx)
jne 0x38a22
movq 0x10(%r15), %rsi
leaq 0x28(%rsp), %rdx
pushq $0x1
popq %rcx
movq %rbx, %rdi
callq 0x7001c
testl %eax, %eax
jne 0x38d00
movq 0x28(%rsp), %rdi
callq 0x38e3e
leaq 0xc1923(%rip), %rax     # 0xfa310
movq 0x8(%rax), %rsi
movq %rbx, %rdi
callq 0x36987
jmp 0x38d00
movl 0x38(%rbx), %edx
cmpl $0x3, %edx
jne 0x38a3f
movq 0x10(%r15), %rax
movq 0x8(%rax), %r14
pushq $-0x1
popq %rbp
movq $0x0, 0x20(%rsp)
xorl %r13d, %r13d
jmp 0x38bfd
leaq 0x792f7(%rip), %rsi     # 0xb1d20
movq %rbx, %rdi
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x36b6f
jle 0x38bc2
pushq $0x1
popq %rcx
pushq $-0x1
popq %rax
movl %eax, 0x10(%rsp)
pushq $0x2
popq %r13
xorl %eax, %eax
movl %ecx, 0x14(%rsp)
xorl %r14d, %r14d
movq %rbx, 0x18(%rsp)
movslq %edx, %rbp
cmpq %rbp, %r13
movq %rax, 0x20(%rsp)
jge 0x38bf0
movl %edx, 0xc(%rsp)
leaq 0x1(%r13), %r15
movq 0x40(%rbx), %rbx
movq (%rbx,%r13,8), %rax
movq 0x8(%rax), %r12
movq %r12, %rdi
leaq 0x7ddbf(%rip), %rsi     # 0xb684f
callq 0x262f0
testl %eax, %eax
jne 0x38acc
cmpq %rbp, %r15
jge 0x38acc
movq 0x8(%rbx,%r13,8), %rsi
movq 0x18(%rsp), %rbx
movq %rbx, %rdi
leaq 0x28(%rsp), %rdx
xorl %ecx, %ecx
callq 0x3ab03
testl %eax, %eax
jne 0x38d00
movq 0x28(%rsp), %rax
movl 0x38(%rbx), %edx
jmp 0x38bb7
movq %r12, %rdi
leaq 0x877fe(%rip), %rsi     # 0xc02d4
callq 0x262f0
testl %eax, %eax
jne 0x38b15
cmpq %rbp, %r15
jge 0x38b15
movq 0x8(%rbx,%r13,8), %rax
movq 0x8(%rax), %r12
movq %r12, %rdi
callq 0x38db8
movl %eax, 0x10(%rsp)
cmpl $-0x1, %eax
movq 0x18(%rsp), %rbx
movq 0x20(%rsp), %rax
movl 0xc(%rsp), %edx
jne 0x38bb7
jmp 0x38d74
movq %r12, %rdi
leaq 0x84ced(%rip), %rsi     # 0xbd80c
callq 0x262f0
testl %eax, %eax
jne 0x38b38
cmpq %rbp, %r15
jge 0x38b38
movq 0x8(%rbx,%r13,8), %rax
movq 0x8(%rax), %r14
jmp 0x38ba9
movq %r12, %rdi
leaq 0x79170(%rip), %rsi     # 0xb1cb2
callq 0x262f0
testl %eax, %eax
jne 0x38d8d
cmpq %rbp, %r15
jge 0x38d8d
movq 0x8(%rbx,%r13,8), %rax
movq 0x8(%rax), %r12
movq %r12, %rdi
leaq 0x7914e(%rip), %rsi     # 0xb1cb9
callq 0x262f0
testl %eax, %eax
je 0x38ba2
movq %r12, %rdi
leaq 0x82860(%rip), %rsi     # 0xbb3de
callq 0x262f0
movl $0x0, 0x14(%rsp)
testl %eax, %eax
movq 0x18(%rsp), %rbx
movq 0x20(%rsp), %rax
movl 0xc(%rsp), %edx
je 0x38bb7
jmp 0x38da5
pushq $0x1
popq %rax
movl %eax, 0x14(%rsp)
movq 0x18(%rsp), %rbx
movq 0x20(%rsp), %rax
movl 0xc(%rsp), %edx
incq %r15
movq %r15, %r13
jmp 0x38a61
leaq 0xc1747(%rip), %rax     # 0xfa310
movq 0x80(%rax), %rsi
jmp 0x38d51
andl $0xfebfffff, 0x98(%rbx) # imm = 0xFEBFFFFF
jmp 0x38d46
orb $0x40, 0x9a(%rbx)
jmp 0x38d00
cmpl $0x0, 0x14(%rsp)
setne %r13b
movl 0x10(%rsp), %ebp
leaq 0xc0ca4(%rip), %rax     # 0xf98a8
movq 0x1c8(%rax), %rdi
leaq 0x28(%rsp), %r15
movq %r15, %rsi
callq 0x2702c
movl $0x0, 0x10(%rsp)
movl $0x0, 0xc(%rsp)
movq %r15, %rdi
callq 0x27046
testq %rax, %rax
je 0x38cb3
movq 0x10(%rax), %r12
testq %r14, %r14
je 0x38c55
movq %r12, %rdi
callq 0x38731
movq %rax, %rdi
movq %r14, %rsi
callq 0x268f0
testl %eax, %eax
jne 0x38c28
cmpl $-0x1, %ebp
je 0x38c66
movq %r12, %rdi
callq 0x38e1b
cmpl %ebp, %eax
jne 0x38c28
movq 0x20(%rsp), %rax
testq %rax, %rax
je 0x38c88
cmpq %rax, (%r12)
setne %cl
cmpq %rbx, %r12
sete %al
movl %eax, %edx
andb %r13b, %dl
orb %cl, %dl
jne 0x38c28
jmp 0x38c93
cmpq %rbx, %r12
sete %al
testb %r13b, %al
jne 0x38c28
pushq $0x1
popq %rcx
testb %al, %al
jne 0x38ca6
movq %r12, %rdi
callq 0x37527
movl 0xc(%rsp), %ecx
incl 0x10(%rsp)
movl %ecx, 0xc(%rsp)
jmp 0x38c28
cmpl $0x3, 0x38(%rbx)
jne 0x38cd5
cmpl $0x0, 0x10(%rsp)
je 0x38ce3
leaq 0xc1649(%rip), %rax     # 0xfa310
movq 0x8(%rax), %rsi
movq %rbx, %rdi
callq 0x36987
jmp 0x38cf2
movl 0x10(%rsp), %esi
movq %rbx, %rdi
callq 0x370a6
jmp 0x38cf2
leaq 0x78fd3(%rip), %rsi     # 0xb1cbd
movq %rbx, %rdi
callq 0x36b6f
cmpl $0x0, 0xc(%rsp)
je 0x38d00
orb $0x40, 0x98(%rbx)
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x20(%rbx), %rdi
testq %rdi, %rdi
je 0x38d1d
callq 0x3a265
andq $0x0, 0x20(%rbx)
jmp 0x38d46
movq 0x20(%rbx), %rdi
testq %rdi, %rdi
je 0x38d3a
callq 0x3a265
movq 0x40(%rbx), %rax
movq 0x10(%rax), %r14
movq %r14, 0x20(%rbx)
movq %r14, %rdi
callq 0x39e74
leaq 0xc15c3(%rip), %rax     # 0xfa310
movq 0x8(%rax), %rsi
movq %rbx, %rdi
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x36987
leaq 0xc15a2(%rip), %rax     # 0xfa310
movq 0x50(%rax), %rsi
jmp 0x38d51
leaq 0x78f1e(%rip), %rsi     # 0xb1c99
movq %rbx, %rdi
movq %r12, %rdx
xorl %eax, %eax
callq 0x36b96
jmp 0x38d00
leaq 0xc157c(%rip), %rax     # 0xfa310
movq 0x80(%rax), %rsi
movq 0x18(%rsp), %rdi
jmp 0x389f4
leaq 0xc1564(%rip), %rax     # 0xfa310
movq 0x80(%rax), %rsi
jmp 0x389f1