// File: /workspace/github_c_makefile_star2_O1/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 0x1fea5
leaq 0x42ce2(%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 0x42974(%rip), %rbx     # 0x6ed40
movq %rbx, %rdi
xorl %esi, %esi
callq 0x18875
movq 0x668(%r14), %rcx
movq %rax, 0x10(%rcx)
movq %rbx, %rdi
xorl %esi, %esi
callq 0x18875
movq 0x668(%r14), %rcx
movq %rax, 0x18(%rcx)
leaq 0x42973(%rip), %rdi     # 0x6ed70
xorl %esi, %esi
callq 0x18875
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 0x2c2df
cmpl $-0x1, %eax
je 0x2c577
movq 0x660(%r14), %rdi
callq 0x2bb1c
cmpl $-0x1, %eax
jne 0x2c49b
xorl %edi, %edi
movl $0x4, %esi
callq 0x2bf69
movq 0x668(%r14), %rcx
movq %rax, (%rcx)
movq %rax, 0x5713f(%rip)     # 0x835a0
leaq 0x2a807(%rip), %rsi     # 0x56c6f
movl $0x2, %edi
movq %rax, %rdx
xorl %eax, %eax
callq 0x19fb1
movq 0x57122(%rip), %rdx     # 0x835a0
movq 0x668(%r14), %rax
movq 0x10(%rax), %rdi
movq %rdx, %rsi
callq 0x18b97
movl $0x1, %edi
callq 0x2c2b5
movl $0x0, 0x1dc(%r14)
movl 0xb4(%r14), %edi
cmpl $0xd8f0, %edi           # imm = 0xD8F0
jge 0x2c564
addl $0x2710, %edi           # imm = 0x2710
leaq 0x19c(%r14), %rsi
leaq 0x1dc(%r14), %rdx
callq 0x1b96a
cmpl $-0x1, %eax
je 0x2c577
cmpl $0x0, 0x1dc(%r14)
jle 0x2c51f
xorl %r15d, %r15d
leaq 0x92(%rip), %rbx        # 0x2c581
movq 0x38(%r14), %rdi
movl 0x19c(%r14,%r15,4), %esi
movl $0x1, %edx
movq %rbx, %rcx
xorl %r8d, %r8d
callq 0x17077
cmpl $-0x1, %eax
je 0x2c542
incq %r15
movslq 0x1dc(%r14), %rax
cmpq %rax, %r15
jl 0x2c4ef
movl 0xb4(%r14), %eax
movq 0x57073(%rip), %rcx     # 0x835a0
movl %eax, 0x80(%rcx)
callq 0x2c664
popq %rbx
popq %r14
popq %r15
jmp 0x2c6c2
leaq 0x2a7f9(%rip), %rdi     # 0x56d42
leaq 0x2a555(%rip), %rsi     # 0x56aa5
movl $0x180, %edx            # imm = 0x180
callq 0x2ade4
movl $0x1, %edi
callq 0x12120
leaq 0x2a72e(%rip), %rsi     # 0x56c99
movl $0x3, %edi
xorl %eax, %eax
callq 0x19fb1
movl $0x1, %edi
callq 0x12870