// File: /workspace/github_c_makefile_star2_O0/erikdubbelboer[P]discnt/src/cluster.c
// Function: clusterCommand
void clusterCommand(client *c) {
    if (!strcasecmp(c->argv[1]->ptr,"meet") && c->argc == 4) {
        long long port;

        if (getLongLongFromObject(c->argv[3], &port) != C_OK) {
            addReplyErrorFormat(c,"Invalid TCP port specified: %s",
                                (char*)c->argv[3]->ptr);
            return;
        }

        if (clusterStartHandshake(c->argv[2]->ptr,port) == 0 &&
            errno == EINVAL)
        {
            addReplyErrorFormat(c,"Invalid node address specified: %s:%s",
                            (char*)c->argv[2]->ptr, (char*)c->argv[3]->ptr);
        } else {
            addReply(c,shared.ok);
        }
    } else if (!strcasecmp(c->argv[1]->ptr,"nodes") && c->argc == 2) {
        /* CLUSTER NODES */
        robj *o;
        sds ci = clusterGenNodesDescription(0);

        o = createObject(OBJ_STRING,ci);
        addReplyBulk(c,o);
        decrRefCount(o);
    } else if (!strcasecmp(c->argv[1]->ptr,"myid") && c->argc == 2) {
        /* CLUSTER MYID */
        addReplyBulkCBuffer(c,myself->name, CLUSTER_NAMELEN);
    } else if (!strcasecmp(c->argv[1]->ptr,"info") && c->argc == 2) {
        /* CLUSTER INFO */
        char *statestr[] = {"ok","fail","needhelp"};

        sds info = sdscatprintf(sdsempty(),
            "cluster_state:%s\r\n"
            "cluster_known_nodes:%lu\r\n"
            "cluster_reachable_nodes:%d\r\n"
            "cluster_size:%d\r\n"
            "cluster_stats_messages_sent:%lld\r\n"
            "cluster_stats_messages_received:%lld\r\n"
            , statestr[server.cluster->state],
            dictSize(server.cluster->nodes),
            server.cluster->reachable_nodes_count,
            server.cluster->size,
            server.cluster->stats_bus_messages_sent,
            server.cluster->stats_bus_messages_received
        );
        addReplyBulkSds(c, info);
    } else if (!strcasecmp(c->argv[1]->ptr,"saveconfig") && c->argc == 2) {
        int retval = clusterSaveConfig(1);

        if (retval == 0)
            addReply(c,shared.ok);
        else
            addReplyErrorFormat(c,"error saving the cluster node config: %s",
                strerror(errno));
    } else if (!strcasecmp(c->argv[1]->ptr,"forget") && c->argc == 3) {
        /* CLUSTER FORGET <NODE ID> */
        clusterNode *n;

        if (sdslen(c->argv[2]->ptr) != CLUSTER_NAMELEN) {
            addReplyError(c,"Invalid node identifier");
            return;
        }

        n = clusterLookupNode(c->argv[2]->ptr);

        if (!n) {
            addReplyErrorFormat(c,"Unknown node %s", (char*)c->argv[2]->ptr);
            return;
        } else if (n == myself) {
            addReplyError(c,"I tried hard but I can't forget myself...");
            return;
        }

        if (counterShardsForNode(n) > 0) {
              addReplyErrorFormat(c,"node still has active shards");
              return;
        }

        counterDeleteShards(n);
        clusterBlacklistAddNode(n);
        clusterDelNode(n);
        clusterDoBeforeSleep(CLUSTER_TODO_UPDATE_STATE|
                             CLUSTER_TODO_SAVE_CONFIG);
        addReply(c,shared.ok);
    } else if (!strcasecmp(c->argv[1]->ptr,"reset") &&
               (c->argc == 2 || c->argc == 3))
    {
        /* CLUSTER RESET [SOFT|HARD] */
        int hard = 0;

        /* Parse soft/hard argument. Default is soft. */
        if (c->argc == 3) {
            if (!strcasecmp(c->argv[2]->ptr,"hard")) {
                hard = 1;
            } else if (!strcasecmp(c->argv[2]->ptr,"soft")) {
                hard = 0;
            } else {
                addReply(c,shared.syntaxerr);
                return;
            }
        }

        clusterReset(hard);
        addReply(c,shared.ok);
    } else {
        addReplyError(c,"Wrong CLUSTER subcommand or number of arguments");
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rax
movq 0x8(%rax), %rax
movq 0x8(%rax), %rdi
leaq 0x725d1(%rip), %rsi     # 0xa7987
callq 0x12070
cmpl $0x0, %eax
jne 0x3548a
movq -0x8(%rbp), %rax
cmpl $0x4, 0x28(%rax)
jne 0x3548a
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rax
movq 0x18(%rax), %rdi
leaq -0x10(%rbp), %rsi
callq 0x2a470
cmpl $0x0, %eax
je 0x35413
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rax
movq 0x18(%rax), %rax
movq 0x8(%rax), %rdx
leaq 0x72585(%rip), %rsi     # 0xa798c
movb $0x0, %al
callq 0x24360
jmp 0x358ef
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rax
movq 0x10(%rax), %rax
movq 0x8(%rax), %rdi
movq -0x10(%rbp), %rax
movl %eax, %esi
callq 0x33610
cmpl $0x0, %eax
jne 0x35471
callq 0x120b0
cmpl $0x16, (%rax)
jne 0x35471
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rax
movq 0x10(%rax), %rax
movq 0x8(%rax), %rdx
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rax
movq 0x18(%rax), %rax
movq 0x8(%rax), %rcx
leaq 0x72543(%rip), %rsi     # 0xa79ab
movb $0x0, %al
callq 0x24360
jmp 0x35485
movq -0x8(%rbp), %rdi
leaq 0x8a37c(%rip), %rax     # 0xbf7f8
movq 0x8(%rax), %rsi
callq 0x24050
jmp 0x358ef
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rax
movq 0x8(%rax), %rax
movq 0x8(%rax), %rdi
leaq 0x72530(%rip), %rsi     # 0xa79d1
callq 0x12070
cmpl $0x0, %eax
jne 0x354ea
movq -0x8(%rbp), %rax
cmpl $0x2, 0x28(%rax)
jne 0x354ea
xorl %edi, %edi
callq 0x320a0
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rsi
xorl %edi, %edi
callq 0x29150
movq %rax, -0x18(%rbp)
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x24c50
movq -0x18(%rbp), %rdi
callq 0x296f0
jmp 0x358ed
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rax
movq 0x8(%rax), %rax
movq 0x8(%rax), %rdi
leaq 0x724d6(%rip), %rsi     # 0xa79d7
callq 0x12070
cmpl $0x0, %eax
jne 0x3552f
movq -0x8(%rbp), %rax
cmpl $0x2, 0x28(%rax)
jne 0x3552f
movq -0x8(%rbp), %rdi
movq 0x9e0e0(%rip), %rsi     # 0xd3600
movl $0x28, %edx
callq 0x24ca0
jmp 0x358eb
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rax
movq 0x8(%rax), %rax
movq 0x8(%rax), %rdi
leaq 0x6df73(%rip), %rsi     # 0xa34b9
callq 0x12070
cmpl $0x0, %eax
jne 0x35643
movq -0x8(%rbp), %rax
cmpl $0x2, 0x28(%rax)
jne 0x35643
movq 0x86d77(%rip), %rax     # 0xbc2e0
movq %rax, -0x40(%rbp)
movq 0x86d74(%rip), %rax     # 0xbc2e8
movq %rax, -0x38(%rbp)
movq 0x86d71(%rip), %rax     # 0xbc2f0
movq %rax, -0x30(%rbp)
callq 0x1e290
movq %rax, %rdi
leaq 0x89b56(%rip), %rax     # 0xbf0e8
movq 0x668(%rax), %rax
movslq 0x8(%rax), %rax
movq -0x40(%rbp,%rax,8), %rdx
leaq 0x89b3f(%rip), %rax     # 0xbf0e8
movq 0x668(%rax), %rax
movq 0x10(%rax), %rax
movq 0x28(%rax), %rcx
leaq 0x89b29(%rip), %rax     # 0xbf0e8
movq 0x668(%rax), %rax
movq 0x10(%rax), %rax
addq 0x48(%rax), %rcx
leaq 0x89b13(%rip), %rax     # 0xbf0e8
movq 0x668(%rax), %rax
movl 0x38(%rax), %r8d
leaq 0x89b01(%rip), %rax     # 0xbf0e8
movq 0x668(%rax), %rax
movl 0xc(%rax), %r9d
leaq 0x89aef(%rip), %rax     # 0xbf0e8
movq 0x668(%rax), %rax
movq 0x40(%rax), %r10
leaq 0x89add(%rip), %rax     # 0xbf0e8
movq 0x668(%rax), %rax
movq 0x48(%rax), %rax
leaq 0x723c8(%rip), %rsi     # 0xa79e5
movq %r10, (%rsp)
movq %rax, 0x8(%rsp)
movb $0x0, %al
callq 0x1f350
movq %rax, -0x48(%rbp)
movq -0x8(%rbp), %rdi
movq -0x48(%rbp), %rsi
callq 0x24cf0
jmp 0x358e9
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rax
movq 0x8(%rax), %rax
movq 0x8(%rax), %rdi
leaq 0x7242c(%rip), %rsi     # 0xa7a86
callq 0x12070
cmpl $0x0, %eax
jne 0x356c5
movq -0x8(%rbp), %rax
cmpl $0x2, 0x28(%rax)
jne 0x356c5
movl $0x1, %edi
callq 0x31ed0
movl %eax, -0x4c(%rbp)
cmpl $0x0, -0x4c(%rbp)
jne 0x35697
movq -0x8(%rbp), %rdi
leaq 0x8a16c(%rip), %rax     # 0xbf7f8
movq 0x8(%rax), %rsi
callq 0x24050
jmp 0x356c0
movq -0x8(%rbp), %rax
movq %rax, -0x68(%rbp)
callq 0x120b0
movl (%rax), %edi
callq 0x12900
movq -0x68(%rbp), %rdi
movq %rax, %rdx
leaq 0x723d8(%rip), %rsi     # 0xa7a91
movb $0x0, %al
callq 0x24360
jmp 0x358e7
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rax
movq 0x8(%rax), %rax
movq 0x8(%rax), %rdi
leaq 0x723de(%rip), %rsi     # 0xa7aba
callq 0x12070
cmpl $0x0, %eax
jne 0x357f6
movq -0x8(%rbp), %rax
cmpl $0x3, 0x28(%rax)
jne 0x357f6
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rax
movq 0x10(%rax), %rax
movq 0x8(%rax), %rdi
callq 0x32160
cmpq $0x28, %rax
je 0x35728
movq -0x8(%rbp), %rdi
leaq 0x723a3(%rip), %rsi     # 0xa7ac1
callq 0x24320
jmp 0x358ef
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rax
movq 0x10(%rax), %rax
movq 0x8(%rax), %rdi
callq 0x31d30
movq %rax, -0x58(%rbp)
cmpq $0x0, -0x58(%rbp)
jne 0x3576f
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rax
movq 0x10(%rax), %rax
movq 0x8(%rax), %rdx
leaq 0x72376(%rip), %rsi     # 0xa7ad9
movb $0x0, %al
callq 0x24360
jmp 0x358ef
movq -0x58(%rbp), %rax
cmpq 0x9de86(%rip), %rax     # 0xd3600
jne 0x35791
movq -0x8(%rbp), %rdi
leaq 0x72362(%rip), %rsi     # 0xa7ae9
callq 0x24320
jmp 0x358ef
jmp 0x35793
movq -0x58(%rbp), %rdi
callq 0x39c50
cmpl $0x0, %eax
jle 0x357b8
movq -0x8(%rbp), %rdi
leaq 0x72367(%rip), %rsi     # 0xa7b13
movb $0x0, %al
callq 0x24360
jmp 0x358ef
movq -0x58(%rbp), %rdi
callq 0x39d00
movq -0x58(%rbp), %rdi
callq 0x33280
movq -0x58(%rbp), %rdi
callq 0x32a20
movl $0x3, %edi
callq 0x32aa0
movq -0x8(%rbp), %rdi
leaq 0x8a010(%rip), %rax     # 0xbf7f8
movq 0x8(%rax), %rsi
callq 0x24050
jmp 0x358e5
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rax
movq 0x8(%rax), %rax
movq 0x8(%rax), %rdi
leaq 0x711e3(%rip), %rsi     # 0xa69f0
callq 0x12070
cmpl $0x0, %eax
jne 0x358d3
movq -0x8(%rbp), %rax
cmpl $0x2, 0x28(%rax)
je 0x35833
movq -0x8(%rbp), %rax
cmpl $0x3, 0x28(%rax)
jne 0x358d3
movl $0x0, -0x5c(%rbp)
movq -0x8(%rbp), %rax
cmpl $0x3, 0x28(%rax)
jne 0x358b5
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rax
movq 0x10(%rax), %rax
movq 0x8(%rax), %rdi
leaq 0x712a0(%rip), %rsi     # 0xa6afb
callq 0x12070
cmpl $0x0, %eax
jne 0x3586e
movl $0x1, -0x5c(%rbp)
jmp 0x358b3
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rax
movq 0x10(%rax), %rax
movq 0x8(%rax), %rdi
leaq 0x722ab(%rip), %rsi     # 0xa7b30
callq 0x12070
cmpl $0x0, %eax
jne 0x35898
movl $0x0, -0x5c(%rbp)
jmp 0x358b1
movq -0x8(%rbp), %rdi
leaq 0x89f55(%rip), %rax     # 0xbf7f8
movq 0x80(%rax), %rsi
callq 0x24050
jmp 0x358ef
jmp 0x358b3
jmp 0x358b5
movl -0x5c(%rbp), %edi
callq 0x32940
movq -0x8(%rbp), %rdi
leaq 0x89f30(%rip), %rax     # 0xbf7f8
movq 0x8(%rax), %rsi
callq 0x24050
jmp 0x358e3
movq -0x8(%rbp), %rdi
leaq 0x72257(%rip), %rsi     # 0xa7b35
callq 0x24320
jmp 0x358e5
jmp 0x358e7
jmp 0x358e9
jmp 0x358eb
jmp 0x358ed
jmp 0x358ef
addq $0x80, %rsp
popq %rbp
retq
nopl (%rax,%rax)