// File: /workspace/github_c_makefile_star2_O2/gplessis[P]dotdeb-redis/src/cluster.c
// Function: clusterReset
void clusterReset(int hard) {
    dictIterator *di;
    dictEntry *de;
    int j;

    /* Turn into master. */
    if (nodeIsSlave(myself)) {
        clusterSetNodeAsMaster(myself);
        replicationUnsetMaster();
        emptyDb(NULL);
    }

    /* Close slots, reset manual failover state. */
    clusterCloseAllSlots();
    resetManualFailover();

    /* Unassign all the slots. */
    for (j = 0; j < CLUSTER_SLOTS; j++) clusterDelSlot(j);

    /* Forget all the nodes, but myself. */
    di = dictGetSafeIterator(server.cluster->nodes);
    while((de = dictNext(di)) != NULL) {
        clusterNode *node = dictGetVal(de);

        if (node == myself) continue;
        clusterDelNode(node);
    }
    dictReleaseIterator(di);

    /* Hard reset only: set epochs to 0, change node ID. */
    if (hard) {
        sds oldname;

        server.cluster->currentEpoch = 0;
        server.cluster->lastVoteEpoch = 0;
        myself->configEpoch = 0;
        serverLog(LL_WARNING, "configEpoch set to 0 via CLUSTER RESET HARD");

        /* To change the Node ID we need to remove the old name from the
         * nodes table, change the ID, and re-add back with new name. */
        oldname = sdsnewlen(myself->name, CLUSTER_NAMELEN);
        dictDelete(server.cluster->nodes,oldname);
        sdsfree(oldname);
        getRandomHexChars(myself->name, CLUSTER_NAMELEN);
        clusterAddNode(myself);
        serverLog(LL_NOTICE,"Node hard reset, now I'm %.40s", myself->name);
    }

    /* Make sure to persist the new config and update the state. */
    clusterDoBeforeSleep(CLUSTER_TODO_SAVE_CONFIG|
                         CLUSTER_TODO_UPDATE_STATE|
                         CLUSTER_TODO_FSYNC_CONFIG);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %edi, %ebx
movq 0xb2763(%rip), %rdi     # 0x10e230
testb $0x2, 0x30(%rdi)
je 0x5bae4
callq 0x5bc2e
callq 0x3f6ed
xorl %edi, %edi
callq 0x3b308
leaq 0x9ddbd(%rip), %r15     # 0xf98a8
movq 0x9b0(%r15), %rdi
addq $0x28, %rdi
xorl %ebp, %ebp
movl $0x20000, %edx          # imm = 0x20000
xorl %esi, %esi
callq 0x26110
movl $0x20028, %edi          # imm = 0x20028
addq 0x9b0(%r15), %rdi
movl $0x20000, %edx          # imm = 0x20000
xorl %esi, %esi
callq 0x26110
callq 0x5ba74
cmpl $0x4000, %ebp           # imm = 0x4000
je 0x5bb34
movl %ebp, %edi
callq 0x5bc88
incl %ebp
jmp 0x5bb21
movq 0x9b0(%r15), %rax
movq 0x18(%rax), %rdi
callq 0x2a9c4
movq %rax, %r14
movq %r14, %rdi
callq 0x2a9d3
testq %rax, %rax
je 0x5bb68
movq 0x8(%rax), %rdi
cmpq 0xb26d1(%rip), %rdi     # 0x10e230
je 0x5bb47
callq 0x5bcf4
jmp 0x5bb47
movq %r14, %rdi
callq 0x2aa94
testl %ebx, %ebx
je 0x5bc15
movq 0x9b0(%r15), %rax
andq $0x0, 0x8(%rax)
andq $0x0, 0x60078(%rax)
movq 0xb269d(%rip), %rax     # 0x10e230
andq $0x0, 0x38(%rax)
leaq 0x5ce51(%rip), %rsi     # 0xb89f0
pushq $0x3
popq %rdi
xorl %eax, %eax
callq 0x2b699
movq 0xb2680(%rip), %rdi     # 0x10e230
addq $0x8, %rdi
pushq $0x28
popq %rsi
callq 0x31018
movq %rax, %rbx
movq 0x9b0(%r15), %rax
movq 0x18(%rax), %rdi
movq %rbx, %rsi
callq 0x2a6dc
movq %rbx, %rdi
callq 0x311c8
movq 0xb264f(%rip), %rdi     # 0x10e230
addq $0x8, %rdi
pushq $0x28
popq %rsi
callq 0x39a57
movq 0xb263c(%rip), %rdi     # 0x10e230
callq 0x5b2c3
movq 0xb2630(%rip), %rdx     # 0x10e230
addq $0x8, %rdx
leaq 0x5ce11(%rip), %rsi     # 0xb8a1c
pushq $0x2
popq %rdi
xorl %eax, %eax
callq 0x2b699
movq 0x9b0(%r15), %rax
orl $0xe, 0x60080(%rax)
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq