// File: /workspace/github_c_makefile_star2_O3/gplessis[P]dotdeb-redis/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;

        if (server.verbosity == LL_DEBUG) {
            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
subq $0x18, %rsp
movq %rdi, %rbx
movzwl 0xe(%rdi), %r12d
movq 0x20(%rsi), %rax
movq %rax, 0x8(%rsp)
testq %rax, %rax
jne 0x6718c
leaq 0x28(%rbx), %rdi
callq 0x6575c
movq %rax, 0x8(%rsp)
testw %r12w, %r12w
je 0x6738c
rolw $0x8, %r12w
addq $0x8a0, %rbx            # imm = 0x8A0
movq 0x8(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x10(%rsp)
movzwl 0x60(%rbx), %r13d
rolw $0x8, %r13w
leaq 0x9a6e7(%rip), %rax     # 0x1018a8
cmpl $0x0, 0x5f8(%rax)
jne 0x6720c
callq 0x3628d
movzwl %r13w, %esi
movq %rax, %rdi
callq 0x6739b
movq %rax, %r15
leaq 0x30(%rbx), %rcx
movzwl 0x5e(%rbx), %eax
rolw $0x8, %ax
movzwl %ax, %r8d
xorl %edi, %edi
leaq 0x60a45(%rip), %rsi     # 0xc7c3c
movq %rbx, %rdx
movq %r15, %r9
xorl %eax, %eax
callq 0x2fdad
movq %r15, %rdi
callq 0x36330
movq %rbx, %rdi
callq 0x6575c
testq %rax, %rax
je 0x67281
movq %rax, %rbp
cmpq $0x0, 0x8(%rsp)
je 0x672ea
movq 0x8(%rsp), %rax
testb $0x1, 0x30(%rax)
je 0x672ea
cmpq 0xaeff2(%rip), %rbp     # 0x116230
je 0x672ea
movq %rbp, %rdi
testb $0xc, %r13b
je 0x672c0
movq 0x8(%rsp), %rsi
callq 0x6676e
testl %eax, %eax
je 0x67277
leaq 0x8(%rbp), %rcx
movl $0x1, %edi
leaq 0x609e7(%rip), %rsi     # 0xc7c52
movq 0x10(%rsp), %rdx
xorl %eax, %eax
callq 0x2fdad
movq %rbp, %rdi
callq 0x66d57
jmp 0x672ea
cmpq $0x0, 0x8(%rsp)
je 0x6737b
andl $0x40, %r13d
jne 0x6737b
movq %rbx, %rdi
callq 0x66d0e
testl %eax, %eax
jne 0x6737b
leaq 0x30(%rbx), %rdi
movzwl 0x5e(%rbx), %eax
rolw $0x8, %ax
movzwl %ax, %esi
callq 0x67013
jmp 0x6737b
movq 0x8(%rsp), %rsi
callq 0x6686e
testl %eax, %eax
je 0x672ea
leaq 0x8(%rbp), %rcx
movl $0x1, %edi
leaq 0x609a5(%rip), %rsi     # 0xc7c83
movq 0x10(%rsp), %rdx
xorl %eax, %eax
callq 0x2fdad
movl 0x30(%rbp), %r14d
testb $0xc, %r14b
sete %al
testb $0x4c, %r13b
setne %cl
orb %al, %cl
jne 0x6737b
movq %rbp, %r13
addq $0x890, %r13            # imm = 0x890
leaq 0x30(%rbx), %r15
movq %r13, %rdi
movq %r15, %rsi
callq 0x262f0
testl %eax, %eax
jne 0x67330
movzwl 0x5e(%rbx), %eax
rolw $0x8, %ax
movzwl %ax, %eax
cmpl %eax, 0x8c0(%rbp)
je 0x6737b
movq 0x8c8(%rbp), %rdi
testq %rdi, %rdi
je 0x67345
callq 0x6651c
movl 0x30(%rbp), %r14d
movups (%r15), %xmm0
movups 0x10(%r15), %xmm1
movups 0x1e(%r15), %xmm2
movups %xmm2, 0x1e(%r13)
movups %xmm1, 0x10(%r13)
movups %xmm0, (%r13)
movzwl 0x5e(%rbx), %eax
rolw $0x8, %ax
movzwl %ax, %eax
movl %eax, 0x8c0(%rbp)
andl $-0x41, %r14d
movl %r14d, 0x30(%rbp)
decl %r12d
addq $0x68, %rbx
testw %r12w, %r12w
jne 0x671b0
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq