// File: /workspace/github_c_makefile_star2_O1/zhou-yuxin[P]redis-aof-no-cow/src/cluster.c
// Function: clusterProcessGossipSection
void clusterProcessGossipSection(clusterMsg *hdr, clusterLink *link) {
    uint16_t count = ntohs(hdr->count);
    clusterMsgDataGossip *g = (clusterMsgDataGossip*) hdr->data.ping.gossip;
    clusterNode *sender = link->node ? link->node : clusterLookupNode(hdr->sender);

    while(count--) {
        uint16_t flags = ntohs(g->flags);
        clusterNode *node;
        sds ci;

        ci = representClusterNodeFlags(sdsempty(), flags);
        serverLog(LL_DEBUG,"GOSSIP %.40s %s:%d %s",
            g->nodename,
            g->ip,
            ntohs(g->port),
            ci);
        sdsfree(ci);

        /* Update our state accordingly to the gossip sections */
        node = clusterLookupNode(g->nodename);
        if (node) {
            /* We already know this node.
               Handle failure reports, only when the sender is a master. */
            if (sender && nodeIsMaster(sender) && node != myself) {
                if (flags & (CLUSTER_NODE_FAIL|CLUSTER_NODE_PFAIL)) {
                    if (clusterNodeAddFailureReport(node,sender)) {
                        serverLog(LL_VERBOSE,
                            "Node %.40s reported node %.40s as not reachable.",
                            sender->name, node->name);
                    }
                    markNodeAsFailingIfNeeded(node);
                } else {
                    if (clusterNodeDelFailureReport(node,sender)) {
                        serverLog(LL_VERBOSE,
                            "Node %.40s reported node %.40s is back online.",
                            sender->name, node->name);
                    }
                }
            }

            /* If we already know this node, but it is not reachable, and
             * we see a different address in the gossip section of a node that
             * can talk with this other node, update the address, disconnect
             * the old link if any, so that we'll attempt to connect with the
             * new address. */
            if (node->flags & (CLUSTER_NODE_FAIL|CLUSTER_NODE_PFAIL) &&
                !(flags & CLUSTER_NODE_NOADDR) &&
                !(flags & (CLUSTER_NODE_FAIL|CLUSTER_NODE_PFAIL)) &&
                (strcasecmp(node->ip,g->ip) || node->port != ntohs(g->port)))
            {
                if (node->link) freeClusterLink(node->link);
                memcpy(node->ip,g->ip,NET_IP_STR_LEN);
                node->port = ntohs(g->port);
                node->flags &= ~CLUSTER_NODE_NOADDR;
            }
        } else {
            /* If it's not in NOADDR state and we don't have it, we
             * start a handshake process against this IP/PORT pairs.
             *
             * Note that we require that the sender of this gossip message
             * is a well known node in our cluster, otherwise we risk
             * joining another cluster. */
            if (sender &&
                !(flags & CLUSTER_NODE_NOADDR) &&
                !clusterBlacklistExists(g->nodename))
            {
                clusterStartHandshake(g->ip,ntohs(g->port));
            }
        }

        /* Next node */
        g++;
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
movzwl 0xe(%rdi), %r12d
movq 0x20(%rsi), %r14
testq %r14, %r14
jne 0x6addb
leaq 0x28(%rbx), %rdi
callq 0x693d1
movq %rax, %r14
testw %r12w, %r12w
je 0x6af9e
rolw $0x8, %r12w
addq $0x8a0, %rbx            # imm = 0x8A0
leaq 0x8(%r14), %rax
movq %rax, (%rsp)
movzwl 0x60(%rbx), %ebp
rolw $0x8, %bp
callq 0x39222
movzwl %bp, %esi
movq %rax, %rdi
callq 0x6afad
movq %rax, %r15
leaq 0x30(%rbx), %r13
movzwl 0x5e(%rbx), %eax
rolw $0x8, %ax
movzwl %ax, %r8d
xorl %edi, %edi
leaq 0x5fd87(%rip), %rsi     # 0xcabb4
movq %rbx, %rdx
movq %r13, %rcx
movq %r15, %r9
xorl %eax, %eax
callq 0x32ea6
movq %r15, %rdi
callq 0x392b6
movq %rbx, %rdi
callq 0x693d1
testq %rax, %rax
je 0x6aeb0
movq %rax, %r15
testq %r14, %r14
je 0x6af0e
testb $0x1, 0x30(%r14)
je 0x6af0e
cmpq 0xb0360(%rip), %r15     # 0x11b1d0
je 0x6af0e
movq %r15, %rdi
movq %r14, %rsi
testb $0xc, %bpl
je 0x6aeea
callq 0x6a3e5
testl %eax, %eax
je 0x6aea6
leaq 0x8(%r15), %rcx
movl $0x1, %edi
leaq 0x5fd2f(%rip), %rsi     # 0xcabca
movq (%rsp), %rdx
xorl %eax, %eax
callq 0x32ea6
movq %r15, %rdi
callq 0x6a9c8
jmp 0x6af0e
testq %r14, %r14
je 0x6af8d
andl $0x40, %ebp
jne 0x6af8d
movq %rbx, %rdi
callq 0x6a97f
testl %eax, %eax
jne 0x6af8d
movzwl 0x5e(%rbx), %eax
rolw $0x8, %ax
movzwl %ax, %esi
movq %r13, %rdi
callq 0x6ac7b
jmp 0x6af8d
callq 0x6a4e5
testl %eax, %eax
je 0x6af0e
leaq 0x8(%r15), %rcx
movl $0x1, %edi
leaq 0x5fcf8(%rip), %rsi     # 0xcabfb
movq (%rsp), %rdx
xorl %eax, %eax
callq 0x32ea6
testb $0x4c, %bpl
jne 0x6af8d
movl 0x30(%r15), %eax
andl $0xc, %eax
je 0x6af8d
movq %r15, %rbp
addq $0x890, %rbp            # imm = 0x890
movq %rbp, %rdi
movq %r13, %rsi
callq 0x26300
testl %eax, %eax
jne 0x6af4a
movzwl 0x5e(%rbx), %eax
rolw $0x8, %ax
movzwl %ax, %eax
cmpl %eax, 0x8c0(%r15)
je 0x6af8d
movq 0x8c8(%r15), %rdi
testq %rdi, %rdi
je 0x6af5b
callq 0x6a18e
movups (%r13), %xmm0
movups 0x10(%r13), %xmm1
movups 0x1e(%r13), %xmm2
movups %xmm2, 0x1e(%rbp)
movups %xmm1, 0x10(%rbp)
movups %xmm0, (%rbp)
movzwl 0x5e(%rbx), %eax
rolw $0x8, %ax
movzwl %ax, %eax
movl %eax, 0x8c0(%r15)
andb $-0x41, 0x30(%r15)
decl %r12d
addq $0x68, %rbx
testw %r12w, %r12w
jne 0x6adf9
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq