// File: /workspace/github_c_makefile_star2_O3/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 0x81f83(%rip), %rsi     # 0xc0dce
movq %r14, %rdi
callq 0x262f0
testl %eax, %eax
jne 0x3ee8f
cmpl $0x2, 0x38(%rbx)
jne 0x3ee8f
callq 0x3ed94
movq %rax, %r14
movzbl -0x1(%rax), %edx
movl %edx, %eax
andl $0x7, %eax
cmpl $0x4, %eax
ja 0x3f3cc
leaq 0x8109e(%rip), %rcx     # 0xbff1c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
shrl $0x3, %edx
jmp 0x3f3ce
leaq 0x8dec8(%rip), %rsi     # 0xccd5e
movq %r14, %rdi
callq 0x262f0
testl %eax, %eax
jne 0x3ef15
cmpl $0x3, 0x38(%rbx)
jne 0x3ef15
movq 0x10(%r15), %rax
movq 0x8(%rax), %r14
leaq 0x91434(%rip), %rsi     # 0xd02eb
movq %r14, %rdi
callq 0x262f0
testl %eax, %eax
je 0x3f209
leaq 0x81419(%rip), %rsi     # 0xc02e7
movq %r14, %rdi
callq 0x262f0
testl %eax, %eax
je 0x3f218
leaq 0x81406(%rip), %rsi     # 0xc02eb
movq %r14, %rdi
callq 0x262f0
testl %eax, %eax
jne 0x3f1f6
movl 0x98(%rbx), %eax
btl $0x16, %eax
jb 0x3f3a3
orl $0x800000, %eax         # imm = 0x800000
movl %eax, 0x98(%rbx)
jmp 0x3f3a3
leaq 0x813d4(%rip), %rsi     # 0xc02f0
movq %r14, %rdi
callq 0x262f0
testl %eax, %eax
je 0x3f039
leaq 0x813f5(%rip), %rsi     # 0xc0328
movq %r14, %rdi
callq 0x262f0
testl %eax, %eax
jne 0x3ef77
cmpl $0x3, 0x38(%rbx)
jne 0x3ef77
movq 0x10(%r15), %rdi
movq 0x8(%rdi), %rax
movzbl -0x1(%rax), %ecx
movl %ecx, %edx
andl $0x7, %edx
cmpl $0x4, %edx
ja 0x3f459
leaq 0x80fa2(%rip), %rsi     # 0xbff08
movslq (%rsi,%rdx,4), %rdx
addq %rsi, %rdx
jmpq *%rdx
shrl $0x3, %ecx
jmp 0x3f411
leaq 0x813f6(%rip), %rsi     # 0xc0374
movq %r14, %rdi
callq 0x262f0
testl %eax, %eax
jne 0x3efb3
cmpl $0x2, 0x38(%rbx)
jne 0x3efb3
movq 0x20(%rbx), %rsi
testq %rsi, %rsi
je 0x3f3ef
movq %rbx, %rdi
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x3d170
leaq 0x91f3d(%rip), %rsi     # 0xd0ef7
movq %r14, %rdi
callq 0x262f0
testl %eax, %eax
jne 0x3f061
cmpl $0x3, 0x38(%rbx)
jne 0x3f061
movq 0x10(%r15), %rsi
leaq 0x28(%rsp), %rdx
movq %rbx, %rdi
movl $0x1, %ecx
callq 0x7cb4c
testl %eax, %eax
jne 0x3f3a3
movq 0x28(%rsp), %rcx
leaq 0xc28aa(%rip), %rax     # 0x1018a8
cmpl $0x0, 0x1f8(%rax)
je 0x3f010
cmpq %rcx, 0x200(%rax)
jge 0x3f017
movq %rcx, 0x200(%rax)
movl $0x1, 0x1f8(%rax)
leaq 0xc32e8(%rip), %rax     # 0x102310
movq 0x8(%rax), %rsi
movq %rbx, %rdi
callq 0x3c854
jmp 0x3f3a3
movl 0x38(%rbx), %r13d
cmpl $0x3, %r13d
jne 0x3f083
movq 0x10(%r15), %rax
movq 0x8(%rax), %r14
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
movq $0x0, 0x20(%rsp)
xorl %r13d, %r13d
jmp 0x3f232
leaq 0x81314(%rip), %rsi     # 0xc037c
movl $0x4a, %edx
movq %rbx, %rdi
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x3cbc0
jle 0x3f1f6
movl $0x1, 0x1c(%rsp)
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
movl $0x3, %r15d
movq $0x0, 0x10(%rsp)
movq $0x0, 0x20(%rsp)
movl %ebp, 0xc(%rsp)
movslq %r13d, %rbp
movq %rbx, %r14
movq 0x40(%rbx), %rbx
movq -0x8(%rbx,%r15,8), %rax
movq 0x8(%rax), %r12
movq %r12, %rdi
leaq 0x86494(%rip), %rsi     # 0xc5563
callq 0x262f0
testl %eax, %eax
jne 0x3f10b
cmpq %rbp, %r15
jge 0x3f10b
movq (%rbx,%r15,8), %rsi
movq %r14, %rbx
movq %r14, %rdi
leaq 0x28(%rsp), %rdx
xorl %ecx, %ecx
callq 0x416bb
testl %eax, %eax
jne 0x3f3a3
movq 0x28(%rsp), %rax
movq %rax, 0x20(%rsp)
movl 0x38(%rbx), %r13d
jmp 0x3f16a
movq %r12, %rdi
leaq 0x905ff(%rip), %rsi     # 0xcf714
callq 0x262f0
testl %eax, %eax
jne 0x3f142
cmpq %rbp, %r15
jge 0x3f142
movq (%rbx,%r15,8), %rax
movq 0x8(%rax), %r12
movq %r12, %rdi
callq 0x3f4e3
movl %eax, %ebp
cmpl $-0x1, %eax
movq %r14, %rbx
jne 0x3f16e
jmp 0x3f4a1
movq %r12, %rdi
leaq 0x8da74(%rip), %rsi     # 0xccbc0
callq 0x262f0
testl %eax, %eax
jne 0x3f184
cmpq %rbp, %r15
jge 0x3f184
movq (%rbx,%r15,8), %rax
movq 0x8(%rax), %rax
movq %rax, 0x10(%rsp)
movq %r14, %rbx
movl 0xc(%rsp), %ebp
addq $0x2, %r15
leal -0x1(%r15), %eax
cmpl %eax, %r13d
jg 0x3f0ae
jmp 0x3f224
movq %r12, %rdi
leaq 0x81180(%rip), %rsi     # 0xc030e
callq 0x262f0
testl %eax, %eax
jne 0x3f4ba
cmpq %rbp, %r15
jge 0x3f4ba
movq (%rbx,%r15,8), %rax
movq 0x8(%rax), %r12
movq %r12, %rdi
leaq 0x8115f(%rip), %rsi     # 0xc0315
callq 0x262f0
testl %eax, %eax
movl 0xc(%rsp), %ebp
je 0x3f1e6
movq %r12, %rdi
leaq 0x8b3e1(%rip), %rsi     # 0xca5ae
callq 0x262f0
movl $0x0, 0x1c(%rsp)
testl %eax, %eax
movq %r14, %rbx
je 0x3f16e
jmp 0x3f4d0
movl $0x1, 0x1c(%rsp)
movq %r14, %rbx
jmp 0x3f16e
leaq 0xc3113(%rip), %rax     # 0x102310
movq 0x80(%rax), %rsi
jmp 0x3f47a
andl $0xfebfffff, 0x98(%rbx) # imm = 0xFEBFFFFF
jmp 0x3f46f
orb $0x40, 0x9a(%rbx)
jmp 0x3f3a3
cmpl $0x0, 0x1c(%rsp)
setne %r13b
movq 0x10(%rsp), %r14
leaq 0xc266f(%rip), %rax     # 0x1018a8
movq 0x1c8(%rax), %rdi
leaq 0x28(%rsp), %r15
movq %r15, %rsi
callq 0x2b3b7
movq %r15, %rdi
callq 0x2b3d4
testq %rax, %rax
je 0x3f367
xorl %ecx, %ecx
leaq 0x28(%rsp), %r15
xorl %r12d, %r12d
movl %ecx, 0x10(%rsp)
movl %r12d, 0xc(%rsp)
movq 0x10(%rax), %r12
testq %r14, %r14
je 0x3f291
movq %r12, %rdi
callq 0x3ed41
movq %rax, %rdi
movq %r14, %rsi
callq 0x268f0
testl %eax, %eax
jne 0x3f2ef
cmpl $-0x1, %ebp
je 0x3f2c2
movl 0x98(%r12), %eax
movl $0x3, %ecx
testb $0x2, %al
jne 0x3f2be
movl %eax, %edx
andl $0x5, %edx
movl $0x1, %ecx
cmpl $0x1, %edx
je 0x3f2be
shrl $0x11, %eax
andl $0x2, %eax
movl %eax, %ecx
cmpl %ebp, %ecx
jne 0x3f2ef
movq 0x20(%rsp), %rax
testq %rax, %rax
je 0x3f2e4
cmpq %rax, (%r12)
setne %cl
cmpq %rbx, %r12
sete %al
movl %eax, %edx
andb %r13b, %dl
orb %cl, %dl
jne 0x3f2ef
jmp 0x3f302
cmpq %rbx, %r12
sete %al
testb %r13b, %al
je 0x3f302
movq %r15, %rdi
callq 0x2b3d4
testq %rax, %rax
jne 0x3f271
jmp 0x3f33c
movl $0x1, %ecx
testb %al, %al
jne 0x3f317
movq %r12, %rdi
callq 0x3d73b
movl 0x10(%rsp), %ecx
movl %ecx, 0x10(%rsp)
movl 0xc(%rsp), %r12d
incl %r12d
movq %r15, %rdi
callq 0x2b3d4
movl 0x10(%rsp), %ecx
movl %ecx, %edx
testq %rax, %rax
jne 0x3f268
jmp 0x3f345
movl 0x10(%rsp), %edx
movl 0xc(%rsp), %r12d
cmpl $0x3, 0x38(%rbx)
jne 0x3f38b
testl %r12d, %r12d
movl %edx, %ebp
je 0x3f375
leaq 0xc2fb7(%rip), %rax     # 0x102310
movq 0x8(%rax), %rsi
movq %rbx, %rdi
callq 0x3c854
jmp 0x3f398
xorl %ebp, %ebp
cmpl $0x3, 0x38(%rbx)
movl $0x0, %r12d
jne 0x3f38d
leaq 0x80f9d(%rip), %rsi     # 0xc0319
movl $0xe, %edx
movq %rbx, %rdi
callq 0x3cbc0
jmp 0x3f398
movl %edx, %ebp
movslq %r12d, %rsi
movq %rbx, %rdi
callq 0x3d23f
testl %ebp, %ebp
je 0x3f3a3
orb $0x40, 0x98(%rbx)
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq -0x11(%r14), %rdx
jmp 0x3f3ce
movzwl -0x5(%r14), %edx
jmp 0x3f3ce
movl -0x9(%r14), %edx
jmp 0x3f3ce
movzbl -0x3(%r14), %edx
jmp 0x3f3ce
xorl %edx, %edx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x3d346
movq %r14, %rdi
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x36330
leaq 0xc2f1a(%rip), %rax     # 0x102310
movq 0x50(%rax), %rsi
jmp 0x3f47a
movq -0x11(%rax), %rcx
jmp 0x3f411
movzwl -0x5(%rax), %ecx
jmp 0x3f411
movl -0x9(%rax), %ecx
jmp 0x3f411
movzbl -0x3(%rax), %ecx
testl %ecx, %ecx
je 0x3f459
jle 0x3f435
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
xorl %edx, %edx
movb (%rax,%rdx), %sil
addb $-0x7f, %sil
cmpb $-0x5f, %sil
jbe 0x3f490
incq %rdx
cmpq %rdx, %rcx
jne 0x3f41f
movq 0x20(%rbx), %rax
testq %rax, %rax
je 0x3f44e
movq %rax, %rdi
callq 0x40c8f
movq 0x40(%rbx), %rax
movq 0x10(%rax), %rdi
movq %rdi, 0x20(%rbx)
callq 0x407a8
jmp 0x3f46f
movq 0x20(%rbx), %rdi
testq %rdi, %rdi
je 0x3f467
callq 0x40c8f
movq $0x0, 0x20(%rbx)
leaq 0xc2e9a(%rip), %rax     # 0x102310
movq 0x8(%rax), %rsi
movq %rbx, %rdi
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x3c854
leaq 0x80e99(%rip), %rsi     # 0xc0330
movl $0x43, %edx
jmp 0x3f06d
leaq 0x80e4d(%rip), %rsi     # 0xc02f5
movq %rbx, %rdi
movq %r12, %rdx
xorl %eax, %eax
callq 0x3cc2d
jmp 0x3f3a3
leaq 0xc2e4f(%rip), %rax     # 0x102310
movq 0x80(%rax), %rsi
movq %r14, %rdi
jmp 0x3f02f
leaq 0xc2e39(%rip), %rax     # 0x102310
movq 0x80(%rax), %rsi
jmp 0x3f02c