// File: /workspace/github_c_makefile_star2_O3/erikdubbelboer[P]discnt/src/cluster.c
// Function: clusterInit
void clusterInit(void) {
    int saveconf = 0;

    server.cluster = zmalloc(sizeof(clusterState));
    server.cluster->myself = NULL;
    server.cluster->state = CLUSTER_OK;
    server.cluster->size = 1;
    server.cluster->todo_before_sleep = 0;
    server.cluster->nodes = dictCreate(&clusterNodesDictType,NULL);
    server.cluster->deleted_nodes = dictCreate(&clusterNodesDictType,NULL);
    server.cluster->nodes_black_list =
        dictCreate(&clusterNodesBlackListDictType,NULL);
    server.cluster->stats_bus_messages_sent = 0;
    server.cluster->stats_bus_messages_received = 0;
    server.cluster->reachable_nodes = NULL;
    server.cluster->reachable_nodes_count = 0;

    /* Lock the cluster config file to make sure every node uses
     * its own nodes.conf. */
    if (clusterLockConfig(server.cluster_configfile) == C_ERR)
        exit(1);

    /* Load or create a new nodes configuration. */
    if (clusterLoadConfig(server.cluster_configfile) == C_ERR) {
        /* No configuration found. We will just use the random name provided
         * by the createClusterNode() function. */
        myself = server.cluster->myself =
            createClusterNode(NULL,CLUSTER_NODE_MYSELF);
        serverLog(LL_NOTICE,"No cluster configuration found, I'm %.40s",
            myself->name);
        clusterAddNode(myself);
        saveconf = 1;
    }
    if (saveconf) clusterSaveConfigOrDie(1);

    /* We need a listening TCP port for our cluster messaging needs. */
    server.cfd_count = 0;

    /* Port sanity check II
     * The other handshake port check is triggered too late to stop
     * us from trying to use a too-high cluster port number. */
    if (server.port > (65535-CLUSTER_PORT_INCR)) {
        serverLog(LL_WARNING, "Discnt port number too high. "
                   "Cluster communication port is 10,000 port "
                   "numbers higher than your Discnt node port. "
                   "Your Discnt node port number must be "
                   "lower than 55535.");
        exit(1);
    }

    if (listenToPort(server.port+CLUSTER_PORT_INCR,
        server.cfd,&server.cfd_count) == C_ERR)
    {
        exit(1);
    } else {
        int j;

        for (j = 0; j < server.cfd_count; j++) {
            if (aeCreateFileEvent(server.el, server.cfd[j], AE_READABLE,
                clusterAcceptHandler, NULL) == AE_ERR)
                    serverPanic("Unrecoverable error creating Discnt Cluster "
                                "Bus file event.");
        }
    }

    /* Set myself->port to my listening port, we'll just need to discover
     * the IP address via MEET messages. */
    myself->port = server.port;

    /* Update state and list of reachable nodes. */
    clusterUpdateState();
    clusterUpdateReachableNodes();
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movl $0x50, %edi
callq 0x1fbbd
leaq 0x432cd(%rip), %r14     # 0x6f088
movq %rax, 0x668(%r14)
xorl %r15d, %r15d
movq %r15, (%rax)
movabsq $0x100000000, %rcx      # imm = 0x100000000
movq %rcx, 0x8(%rax)
movl %r15d, 0x28(%rax)
leaq 0x42f5f(%rip), %rbx     # 0x6ed40
movq %rbx, %rdi
xorl %esi, %esi
callq 0x184d5
movq 0x668(%r14), %rcx
movq %rax, 0x10(%rcx)
movq %rbx, %rdi
xorl %esi, %esi
callq 0x184d5
movq 0x668(%r14), %rcx
movq %rax, 0x18(%rcx)
leaq 0x42f5e(%rip), %rdi     # 0x6ed70
xorl %esi, %esi
callq 0x184d5
movq 0x668(%r14), %rcx
movq %rax, 0x20(%rcx)
movq %r15, 0x30(%rcx)
movl %r15d, 0x38(%rcx)
xorps %xmm0, %xmm0
movups %xmm0, 0x40(%rcx)
movq 0x660(%r14), %rdi
callq 0x2bcf4
cmpl $-0x1, %eax
je 0x2bf8c
movq 0x660(%r14), %rdi
callq 0x2b53c
cmpl $-0x1, %eax
jne 0x2beb0
xorl %edi, %edi
movl $0x4, %esi
callq 0x2b97c
movq 0x668(%r14), %rcx
movq %rax, (%rcx)
movq %rax, 0x5772a(%rip)     # 0x835a0
leaq 0x2adde(%rip), %rsi     # 0x56c5b
movl $0x2, %edi
movq %rax, %rdx
xorl %eax, %eax
callq 0x19c06
movq 0x5770d(%rip), %rdx     # 0x835a0
movq 0x668(%r14), %rax
movq 0x10(%rax), %rdi
movq %rdx, %rsi
callq 0x18802
movl $0x1, %edi
callq 0x2bcca
movl $0x0, 0x1dc(%r14)
movl 0xb4(%r14), %edi
cmpl $0xd8f0, %edi           # imm = 0xD8F0
jge 0x2bf79
addl $0x2710, %edi           # imm = 0x2710
leaq 0x19c(%r14), %rsi
leaq 0x1dc(%r14), %rdx
callq 0x1b612
cmpl $-0x1, %eax
je 0x2bf8c
cmpl $0x0, 0x1dc(%r14)
jle 0x2bf34
xorl %r15d, %r15d
leaq 0x92(%rip), %rbx        # 0x2bf96
movq 0x38(%r14), %rdi
movl 0x19c(%r14,%r15,4), %esi
movl $0x1, %edx
movq %rbx, %rcx
xorl %r8d, %r8d
callq 0x16d02
cmpl $-0x1, %eax
je 0x2bf57
incq %r15
movslq 0x1dc(%r14), %rax
cmpq %rax, %r15
jl 0x2bf04
movl 0xb4(%r14), %eax
movq 0x5765e(%rip), %rcx     # 0x835a0
movl %eax, 0x80(%rcx)
callq 0x2c079
popq %rbx
popq %r14
popq %r15
jmp 0x2c0d7
leaq 0x2add0(%rip), %rdi     # 0x56d2e
leaq 0x2ab2c(%rip), %rsi     # 0x56a91
movl $0x180, %edx            # imm = 0x180
callq 0x2a81d
movl $0x1, %edi
callq 0x12120
leaq 0x2ad05(%rip), %rsi     # 0x56c85
movl $0x3, %edi
xorl %eax, %eax
callq 0x19c06
movl $0x1, %edi
callq 0x12860