// File: /workspace/github_c_makefile_star2_O1/zhou-yuxin[P]redis-aof-no-cow/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, %rbx
movq %rdi, %r14
leaq 0xa28db(%rip), %r15     # 0x106858
movq 0x978(%r15), %rdi
movq %r14, %rsi
callq 0x31cca
testq %rax, %rax
je 0x6400d
movq 0x8(%rax), %rdi
leaq 0x8(%rsp), %r15
movq %r15, %rsi
callq 0x2e582
movq %r15, %rdi
callq 0x2e59f
xorl %ebp, %ebp
testq %rax, %rax
je 0x64004
leaq 0xa32f8(%rip), %r13     # 0x1072b0
leaq 0x8(%rsp), %r15
movq 0x10(%rax), %r12
movq 0x13a48(%r13), %rsi
movq %r12, %rdi
callq 0x3fc19
movq 0xf8(%r13), %rsi
movq %r12, %rdi
callq 0x3fc19
movq %r12, %rdi
movq %r14, %rsi
callq 0x40537
movq %r12, %rdi
movq %rbx, %rsi
callq 0x40537
incl %ebp
movq %r15, %rdi
callq 0x2e59f
testq %rax, %rax
jne 0x63fbd
leaq 0xa284d(%rip), %r15     # 0x106858
jmp 0x6400f
xorl %ebp, %ebp
movq 0x980(%r15), %rdi
cmpq $0x0, 0x28(%rdi)
je 0x64149
leaq 0x8(%rsp), %r15
movq %r15, %rsi
callq 0x2e582
movq %r14, %rdi
callq 0x444b2
movq %rax, %r14
movq %r15, %rdi
callq 0x2e59f
testq %rax, %rax
je 0x64141
leaq 0x64cb3(%rip), %r15     # 0xc8d04
movq 0x10(%rax), %r12
movq 0x8(%r12), %rax
movq 0x8(%rax), %rdi
movzbl -0x1(%rdi), %esi
movl %esi, %eax
andl $0x7, %eax
cmpl $0x4, %eax
ja 0x64091
movslq (%r15,%rax,4), %rax
addq %r15, %rax
jmpq *%rax
shrl $0x3, %esi
jmp 0x64093
movq -0x11(%rdi), %rsi
jmp 0x64093
movzwl -0x5(%rdi), %esi
jmp 0x64093
movl -0x9(%rdi), %esi
jmp 0x64093
movzbl -0x3(%rdi), %esi
jmp 0x64093
xorl %esi, %esi
movq 0x8(%r14), %rdx
movzbl -0x1(%rdx), %ecx
movl %ecx, %eax
andl $0x7, %eax
cmpl $0x4, %eax
ja 0x640d1
leaq 0x64c6c(%rip), %r8      # 0xc8d18
movslq (%r8,%rax,4), %rax
addq %r8, %rax
jmpq *%rax
shrl $0x3, %ecx
jmp 0x640d3
movq -0x11(%rdx), %rcx
jmp 0x640d3
movzwl -0x5(%rdx), %ecx
jmp 0x640d3
movl -0x9(%rdx), %ecx
jmp 0x640d3
movzbl -0x3(%rdx), %ecx
jmp 0x640d3
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x42e7c
testl %eax, %eax
je 0x6412e
movq (%r12), %rdi
leaq 0xa31c6(%rip), %r13     # 0x1072b0
movq 0x13a50(%r13), %rsi
callq 0x3fc19
movq (%r12), %rdi
movq 0x100(%r13), %rsi
callq 0x3fc19
movq (%r12), %rdi
movq 0x8(%r12), %rsi
callq 0x40537
movq (%r12), %rdi
movq %r14, %rsi
callq 0x40537
movq (%r12), %rdi
movq %rbx, %rsi
callq 0x40537
incl %ebp
leaq 0x8(%rsp), %rdi
callq 0x2e59f
testq %rax, %rax
jne 0x64051
movq %r14, %rdi
callq 0x440f3
movl %ebp, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq