// File: /workspace/github_c_makefile_star2_O2/gplessis[P]dotdeb-redis/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
subq $0x18, %rsp
movq %rdi, %rbx
movq 0x40(%rdi), %r15
movq 0x8(%r15), %rax
movq 0x8(%rax), %r14
leaq 0x604d3(%rip), %rsi     # 0xb7091
movq %r14, %rdi
callq 0x262f0
testl %eax, %eax
jne 0x56be8
movl 0x38(%rbx), %eax
movl %eax, %ecx
andl $-0x2, %ecx
cmpl $0x2, %ecx
jne 0x56be8
cmpl $0x2, %eax
jne 0x56cde
xorl %r14d, %r14d
jmp 0x56ce6
leaq 0x604ab(%rip), %rsi     # 0xb709a
movq %r14, %rdi
callq 0x262f0
testl %eax, %eax
jne 0x56c6c
movl 0x38(%rbx), %eax
cmpl $0x2, %eax
jl 0x56c6c
leal -0x4(,%rax,2), %esi
movq %rbx, %rdi
callq 0x370d9
pushq $0x2
popq %r15
leaq 0xa2c8b(%rip), %r12     # 0xf98a8
movslq 0x38(%rbx), %rax
cmpq %rax, %r15
jge 0x56ccf
movq 0x988(%r12), %rdi
movq 0x40(%rbx), %rax
movq (%rax,%r15,8), %rsi
callq 0x2a900
movq %rax, %r14
movq 0x40(%rbx), %rax
movq (%rax,%r15,8), %rsi
movq %rbx, %rdi
callq 0x36fd9
testq %r14, %r14
je 0x56c5d
movq 0x28(%r14), %rsi
jmp 0x56c5f
xorl %esi, %esi
movq %rbx, %rdi
callq 0x370a6
incq %r15
jmp 0x56c1d
leaq 0x6042e(%rip), %rsi     # 0xb70a1
movq %r14, %rdi
callq 0x262f0
testl %eax, %eax
jne 0x56cad
cmpl $0x2, 0x38(%rbx)
jne 0x56cad
leaq 0xa2c1c(%rip), %rax     # 0xf98a8
movq 0x990(%rax), %rax
movq 0x28(%rax), %rsi
movq %rbx, %rdi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x370a6
leaq 0x603f4(%rip), %rsi     # 0xb70a8
movq %rbx, %rdi
movq %r14, %rdx
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x36b96
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x10(%r15), %rax
movq 0x8(%rax), %r14
leaq 0xa2bbb(%rip), %rax     # 0xf98a8
movq 0x988(%rax), %rdi
callq 0x2a99f
movq %rax, %r15
movq %rbx, %rdi
callq 0x36dad
movq %rax, 0x10(%rsp)
movq $0x0, 0x8(%rsp)
movq %r15, %rdi
callq 0x2a9d3
testq %rax, %rax
je 0x56d67
movq (%rax), %rbp
testq %r14, %r14
je 0x56d55
movq 0x8(%rbp), %r12
movq %r14, %rdi
callq 0x569cc
movq %rax, %r13
movq %r12, %rdi
callq 0x569cc
movq %r14, %rdi
movl %r13d, %esi
movq %r12, %rdx
movl %eax, %ecx
xorl %r8d, %r8d
callq 0x3929c
testl %eax, %eax
je 0x56d12
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x36fd9
incq 0x8(%rsp)
jmp 0x56d12
movq %r15, %rdi
callq 0x2aa94
movq %rbx, %rdi
movq 0x10(%rsp), %rsi
movq 0x8(%rsp), %rdx
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x36de9
nop