// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x30, %rsp
movl %edi, -0x4(%rbp)
movq 0x10f42e(%rip), %rax    # 0x18cb60
movl 0x30(%rax), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x7d757
movq 0x10f41c(%rip), %rdi    # 0x18cb60
callq 0x7d8d0
callq 0x51860
xorl %eax, %eax
movl %eax, %edi
callq 0x4adc0
callq 0x7d4f0
callq 0x7d670
movl $0x0, -0x1c(%rbp)
cmpl $0x4000, -0x1c(%rbp)    # imm = 0x4000
jge 0x7d784
movl -0x1c(%rbp), %edi
callq 0x7d970
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x7d768
leaq 0xfaa4d(%rip), %rax     # 0x1781d8
movq 0x9b0(%rax), %rax
movq 0x18(%rax), %rdi
callq 0x2e470
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rdi
callq 0x2e4a0
movq %rax, -0x18(%rbp)
cmpq $0x0, %rax
je 0x7d7d8
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
cmpq 0x10f397(%rip), %rax    # 0x18cb60
jne 0x7d7cd
jmp 0x7d79f
movq -0x28(%rbp), %rdi
callq 0x7da10
jmp 0x7d79f
movq -0x10(%rbp), %rdi
callq 0x2e600
cmpl $0x0, -0x4(%rbp)
je 0x7d8b8
leaq 0xfa9e6(%rip), %rax     # 0x1781d8
movq 0x9b0(%rax), %rax
movq $0x0, 0x8(%rax)
leaq 0xfa9d0(%rip), %rax     # 0x1781d8
movq 0x9b0(%rax), %rax
movq $0x0, 0x60078(%rax)
movq 0x10f33f(%rip), %rax    # 0x18cb60
movq $0x0, 0x38(%rax)
movl $0x3, %edi
leaq 0xc4254(%rip), %rsi     # 0x141a89
movb $0x0, %al
callq 0x2fc60
movq 0x10f31d(%rip), %rdi    # 0x18cb60
addq $0x8, %rdi
movl $0x28, %esi
callq 0x38230
movq %rax, -0x30(%rbp)
leaq 0xfa97c(%rip), %rax     # 0x1781d8
movq 0x9b0(%rax), %rax
movq 0x18(%rax), %rdi
movq -0x30(%rbp), %rsi
callq 0x2de50
movq -0x30(%rbp), %rdi
callq 0x38620
movq 0x10f2e0(%rip), %rdi    # 0x18cb60
addq $0x8, %rdi
movl $0x28, %esi
callq 0x47e40
movq 0x10f2cb(%rip), %rdi    # 0x18cb60
callq 0x7ca30
movq 0x10f2bf(%rip), %rdx    # 0x18cb60
addq $0x8, %rdx
movl $0x2, %edi
leaq 0xc4204(%rip), %rsi     # 0x141ab5
movb $0x0, %al
callq 0x2fc60
movl $0xe, %edi
callq 0x7db50
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax,%rax)