// File: /workspace/github_c_makefile_star2_O2/gplessis[P]dotdeb-redis/src/pubsub.c
// Function: pubsubPublishMessage
int pubsubPublishMessage(robj *channel, robj *message) {
    int receivers = 0;
    dictEntry *de;
    listNode *ln;
    listIter li;

    /* Send to clients listening for that channel */
    de = dictFind(server.pubsub_channels,channel);
    if (de) {
        list *list = dictGetVal(de);
        listNode *ln;
        listIter li;

        listRewind(list,&li);
        while ((ln = listNext(&li)) != NULL) {
            client *c = ln->value;

            addReply(c,shared.mbulkhdr[3]);
            addReply(c,shared.messagebulk);
            addReplyBulk(c,channel);
            addReplyBulk(c,message);
            receivers++;
        }
    }
    /* Send to clients listening to matching channels */
    if (listLength(server.pubsub_patterns)) {
        listRewind(server.pubsub_patterns,&li);
        channel = getDecodedObject(channel);
        while ((ln = listNext(&li)) != NULL) {
            pubsubPattern *pat = ln->value;

            if (stringmatchlen((char*)pat->pattern->ptr,
                                sdslen(pat->pattern->ptr),
                                (char*)channel->ptr,
                                sdslen(channel->ptr),0)) {
                addReply(pat->client,shared.mbulkhdr[4]);
                addReply(pat->client,shared.pmessagebulk);
                addReplyBulk(pat->client,pat->pattern);
                addReplyBulk(pat->client,channel);
                addReplyBulk(pat->client,message);
                receivers++;
            }
        }
        decrRefCount(channel);
    }
    return receivers;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, (%rsp)
movq %rdi, %r15
leaq 0xa3032(%rip), %r13     # 0xf98a8
movq 0x988(%r13), %rdi
movq %r15, %rsi
callq 0x2a5f9
testq %rax, %rax
je 0x568ee
movq 0x8(%rax), %rdi
leaq 0x8(%rsp), %r14
movq %r14, %rsi
callq 0x2702c
xorl %ebp, %ebp
leaq 0xa3a6c(%rip), %rbx     # 0xfa310
movq %r14, %rdi
callq 0x27046
testq %rax, %rax
je 0x568f0
movq 0x10(%rax), %r12
movq 0x13a48(%rbx), %rsi
movq %r12, %rdi
callq 0x36987
movq 0xf8(%rbx), %rsi
movq %r12, %rdi
callq 0x36987
movq %r12, %rdi
movq %r15, %rsi
callq 0x36fd9
movq %r12, %rdi
movq (%rsp), %rsi
callq 0x36fd9
incl %ebp
jmp 0x568a4
xorl %ebp, %ebp
movq 0x990(%r13), %rdi
cmpq $0x0, 0x28(%rdi)
je 0x569bb
leaq 0x8(%rsp), %rsi
callq 0x2702c
movq %r15, %rdi
callq 0x3a57d
movq %rax, %r15
leaq 0x8(%rsp), %rdi
callq 0x27046
testq %rax, %rax
je 0x569b3
movq 0x10(%rax), %rbx
movq 0x8(%rbx), %rax
movq 0x8(%rax), %r12
movq %r12, %rdi
callq 0x569cc
movq %rax, %r13
movq 0x8(%r15), %r14
movq %r14, %rdi
callq 0x569cc
movq %r12, %rdi
movl %r13d, %esi
movq %r14, %rdx
movl %eax, %ecx
xorl %r8d, %r8d
callq 0x3929c
testl %eax, %eax
je 0x56917
movq (%rbx), %rdi
leaq 0xa39a2(%rip), %r14     # 0xfa310
movq 0x13a50(%r14), %rsi
callq 0x36987
movq (%rbx), %rdi
movq 0x100(%r14), %rsi
callq 0x36987
movq (%rbx), %rdi
movq 0x8(%rbx), %rsi
callq 0x36fd9
movq (%rbx), %rdi
movq %r15, %rsi
callq 0x36fd9
movq (%rbx), %rdi
movq (%rsp), %rsi
callq 0x36fd9
incl %ebp
jmp 0x56917
movq %r15, %rdi
callq 0x3a265
movl %ebp, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq