// File: /workspace/github_c_makefile_star2_O1/zhou-yuxin[P]redis-aof-no-cow/src/pubsub.c
// Function: pubsubCommand
void pubsubCommand(client *c) {
    if (!strcasecmp(c->argv[1]->ptr,"channels") &&
        (c->argc == 2 || c->argc ==3))
    {
        /* PUBSUB CHANNELS [<pattern>] */
        sds pat = (c->argc == 2) ? NULL : c->argv[2]->ptr;
        dictIterator *di = dictGetIterator(server.pubsub_channels);
        dictEntry *de;
        long mblen = 0;
        void *replylen;

        replylen = addDeferredMultiBulkLength(c);
        while((de = dictNext(di)) != NULL) {
            robj *cobj = dictGetKey(de);
            sds channel = cobj->ptr;

            if (!pat || stringmatchlen(pat, sdslen(pat),
                                       channel, sdslen(channel),0))
            {
                addReplyBulk(c,cobj);
                mblen++;
            }
        }
        dictReleaseIterator(di);
        setDeferredMultiBulkLength(c,replylen,mblen);
    } else if (!strcasecmp(c->argv[1]->ptr,"numsub") && c->argc >= 2) {
        /* PUBSUB NUMSUB [Channel_1 ... Channel_N] */
        int j;

        addReplyMultiBulkLen(c,(c->argc-2)*2);
        for (j = 2; j < c->argc; j++) {
            list *l = dictFetchValue(server.pubsub_channels,c->argv[j]);

            addReplyBulk(c,c->argv[j]);
            addReplyLongLong(c,l ? listLength(l) : 0);
        }
    } else if (!strcasecmp(c->argv[1]->ptr,"numpat") && c->argc == 2) {
        /* PUBSUB NUMPAT */
        addReplyLongLong(c,listLength(server.pubsub_patterns));
    } else {
        addReplyErrorFormat(c,
            "Unknown PUBSUB subcommand or wrong number of arguments for '%s'",
            (char*)c->argv[1]->ptr);
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x40(%rdi), %r15
movq 0x8(%r15), %rax
movq 0x8(%rax), %r14
leaq 0x64a2a(%rip), %rsi     # 0xc8d5d
movq %r14, %rdi
callq 0x26300
testl %eax, %eax
jne 0x6435d
movl 0x38(%rbx), %eax
movl %eax, %ecx
andl $-0x2, %ecx
cmpl $0x2, %ecx
jne 0x6435d
cmpl $0x2, %eax
jne 0x64459
xorl %r14d, %r14d
jmp 0x64461
leaq 0x64a02(%rip), %rsi     # 0xc8d66
movq %r14, %rdi
callq 0x26300
testl %eax, %eax
jne 0x643f6
movl 0x38(%rbx), %eax
cmpl $0x2, %eax
jl 0x643f6
leal -0x4(,%rax,2), %esi
movq %rbx, %rdi
callq 0x4063b
cmpl $0x3, 0x38(%rbx)
jl 0x643e7
movl $0x2, %r15d
leaq 0xa24ba(%rip), %r12     # 0x106858
movq 0x978(%r12), %rdi
movq 0x40(%rbx), %rax
movq (%rax,%r15,8), %rsi
callq 0x32019
movq %rax, %r14
movq 0x40(%rbx), %rax
movq (%rax,%r15,8), %rsi
movq %rbx, %rdi
callq 0x40537
testq %r14, %r14
je 0x643d1
movq 0x28(%r14), %rsi
jmp 0x643d3
xorl %esi, %esi
movq %rbx, %rdi
callq 0x40606
incq %r15
movslq 0x38(%rbx), %rax
cmpq %rax, %r15
jl 0x6439e
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x64970(%rip), %rsi     # 0xc8d6d
movq %r14, %rdi
callq 0x26300
testl %eax, %eax
jne 0x64437
cmpl $0x2, 0x38(%rbx)
jne 0x64437
leaq 0xa2442(%rip), %rax     # 0x106858
movq 0x980(%rax), %rax
movq 0x28(%rax), %rsi
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x40606
leaq 0x64936(%rip), %rsi     # 0xc8d74
movq %rbx, %rdi
movq %r14, %rdx
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x3fff2
movq 0x10(%r15), %rax
movq 0x8(%rax), %r14
leaq 0xa23f0(%rip), %rax     # 0x106858
movq 0x978(%rax), %rdi
callq 0x320bb
movq %rax, %r15
movq %rbx, %rdi
callq 0x402b0
movq %rax, (%rsp)
movq %r15, %rdi
callq 0x32116
xorl %r13d, %r13d
testq %rax, %rax
je 0x64551
leaq 0x6488e(%rip), %r12     # 0xc8d2c
movq (%rax), %rbp
testq %r14, %r14
je 0x64532
movzbl -0x1(%r14), %esi
movl %esi, %eax
andl $0x7, %eax
cmpl $0x4, %eax
ja 0x644e1
movslq (%r12,%rax,4), %rax
addq %r12, %rax
jmpq *%rax
shrl $0x3, %esi
jmp 0x644e3
movq -0x11(%r14), %rsi
jmp 0x644e3
movzwl -0x5(%r14), %esi
jmp 0x644e3
movl -0x9(%r14), %esi
jmp 0x644e3
movzbl -0x3(%r14), %esi
jmp 0x644e3
xorl %esi, %esi
movq 0x8(%rbp), %rdx
movzbl -0x1(%rdx), %ecx
movl %ecx, %eax
andl $0x7, %eax
cmpl $0x4, %eax
ja 0x64521
leaq 0x64844(%rip), %rdi     # 0xc8d40
movslq (%rdi,%rax,4), %rax
addq %rdi, %rax
jmpq *%rax
shrl $0x3, %ecx
jmp 0x64523
movq -0x11(%rdx), %rcx
jmp 0x64523
movzwl -0x5(%rdx), %ecx
jmp 0x64523
movl -0x9(%rdx), %ecx
jmp 0x64523
movzbl -0x3(%rdx), %ecx
jmp 0x64523
xorl %ecx, %ecx
movq %r14, %rdi
xorl %r8d, %r8d
callq 0x42e7c
testl %eax, %eax
je 0x64540
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x40537
incq %r13
movq %r15, %rdi
callq 0x32116
testq %rax, %rax
jne 0x6449e
movq %r15, %rdi
callq 0x321d3
movq %rbx, %rdi
movq (%rsp), %rsi
movq %r13, %rdx
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x402ec
nop