// File: /workspace/github_c_makefile_star2_O2/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 %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
pushq $0x50
popq %rdi
callq 0x1ab29
leaq 0x44a45(%rip), %r14     # 0x6a088
movq %rax, 0x668(%r14)
andq $0x0, (%rax)
movabsq $0x100000000, %rcx      # imm = 0x100000000
movq %rcx, 0x8(%rax)
andl $0x0, 0x28(%rax)
leaq 0x446d9(%rip), %rbx     # 0x69d40
movq %rbx, %rdi
xorl %esi, %esi
callq 0x1464a
movq 0x668(%r14), %rcx
movq %rax, 0x10(%rcx)
movq %rbx, %rdi
xorl %esi, %esi
callq 0x1464a
movq 0x668(%r14), %rcx
movq %rax, 0x18(%rcx)
leaq 0x446d8(%rip), %rdi     # 0x69d70
xorl %esi, %esi
callq 0x1464a
movq 0x668(%r14), %rcx
movq %rax, 0x20(%rcx)
andq $0x0, 0x30(%rcx)
andl $0x0, 0x38(%rcx)
xorps %xmm0, %xmm0
movups %xmm0, 0x40(%rcx)
movq 0x660(%r14), %rdi
callq 0x25588
cmpl $-0x1, %eax
je 0x257f3
movq 0x660(%r14), %rdi
callq 0x24ec8
cmpl $-0x1, %eax
jne 0x25723
pushq $0x4
popq %rsi
xorl %edi, %edi
callq 0x252ba
movq 0x668(%r14), %rcx
movq %rax, (%rcx)
movq %rax, 0x58ea5(%rip)     # 0x7e5a0
leaq 0x2ac41(%rip), %rsi     # 0x50343
pushq $0x2
popq %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x15b9e
movq 0x58e8a(%rip), %rdi     # 0x7e5a0
callq 0x2534c
pushq $0x1
popq %rdi
callq 0x25562
andl $0x0, 0x1dc(%r14)
movl 0xb4(%r14), %edi
cmpl $0xd8f0, %edi           # imm = 0xD8F0
jge 0x257e2
addl $0x2710, %edi           # imm = 0x2710
leaq 0x19c(%r14), %rsi
leaq 0x1dc(%r14), %rdx
callq 0x1729d
cmpl $-0x1, %eax
je 0x257f3
xorl %r15d, %r15d
leaq 0x91(%rip), %rbx        # 0x257fb
pushq $0x1
popq %rbp
movslq 0x1dc(%r14), %rax
cmpq %rax, %r15
jge 0x257ba
movq 0x38(%r14), %rdi
movl 0x19c(%r14,%r15,4), %esi
movl %ebp, %edx
movq %rbx, %rcx
xorl %r8d, %r8d
callq 0x1306c
incq %r15
cmpl $-0x1, %eax
jne 0x2576d
leaq 0x2ac75(%rip), %rdi     # 0x50416
leaq 0x2a9d1(%rip), %rsi     # 0x50179
movl $0x180, %edx            # imm = 0x180
callq 0x24359
pushq $0x1
popq %rdi
callq 0x12120
movl 0xb4(%r14), %eax
movq 0x58dd8(%rip), %rcx     # 0x7e5a0
movl %eax, 0x80(%rcx)
callq 0x258db
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x25933
leaq 0x2ab84(%rip), %rsi     # 0x5036d
pushq $0x3
popq %rdi
xorl %eax, %eax
callq 0x15b9e
pushq $0x1
popq %rdi
callq 0x12860