// File: /workspace/github_c_makefile_star2_O2/gplessis[P]dotdeb-redis/src/replication.c
// Function: slaveofCommand
void slaveofCommand(client *c) {
    /* SLAVEOF is not allowed in cluster mode as replication is automatically
     * configured using the current address of the master node. */
    if (server.cluster_enabled) {
        addReplyError(c,"SLAVEOF not allowed in cluster mode.");
        return;
    }

    /* The special host/port combination "NO" "ONE" turns the instance
     * into a master. Otherwise the new master address is set. */
    if (!strcasecmp(c->argv[1]->ptr,"no") &&
        !strcasecmp(c->argv[2]->ptr,"one")) {
        if (server.masterhost) {
            replicationUnsetMaster();
            sds client = catClientInfoString(sdsempty(),c);
            serverLog(LL_NOTICE,"MASTER MODE enabled (user request from '%s')",
                client);
            sdsfree(client);
        }
    } else {
        long port;

        if ((getLongFromObjectOrReply(c, c->argv[2], &port, NULL) != C_OK))
            return;

        /* Check if we are already attached to the specified slave */
        if (server.masterhost && !strcasecmp(server.masterhost,c->argv[1]->ptr)
            && server.masterport == port) {
            serverLog(LL_NOTICE,"SLAVE OF would result into synchronization with the master we are already connected with. No operation performed.");
            addReplySds(c,sdsnew("+OK Already connected to specified master\r\n"));
            return;
        }
        /* There was no previous master or the user specified a different one,
         * we can continue. */
        replicationSetMaster(c->argv[1]->ptr, port);
        sds client = catClientInfoString(sdsempty(),c);
        serverLog(LL_NOTICE,"SLAVE OF %s:%d enabled (user request from '%s')",
            server.masterhost, server.masterport, client);
        sdsfree(client);
    }
    addReply(c,shared.ok);
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x10, %rsp
movq %rdi, %rbx
leaq 0xba113(%rip), %r15     # 0xf98a8
cmpl $0x0, 0x99c(%r15)
je 0x3f7b7
leaq 0x743a3(%rip), %rsi     # 0xb3b49
movq %rbx, %rdi
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
jmp 0x36b6f
movq 0x40(%rbx), %r14
movq 0x8(%r14), %rax
movq 0x8(%rax), %rdi
leaq 0x7bc14(%rip), %rsi     # 0xbb3de
callq 0x262f0
movq 0x10(%r14), %r14
testl %eax, %eax
jne 0x3f7ef
movq 0x8(%r14), %rdi
leaq 0x83340(%rip), %rsi     # 0xc2b22
callq 0x262f0
testl %eax, %eax
je 0x3f86f
leaq 0x8(%rsp), %rdx
movq %rbx, %rdi
movq %r14, %rsi
xorl %ecx, %ecx
callq 0x3ab5e
testl %eax, %eax
jne 0x3f904
movq 0x828(%r15), %rdi
movq 0x40(%rbx), %rax
movq 0x8(%rax), %rax
movq 0x8(%rax), %r14
testq %rdi, %rdi
je 0x3f8a7
movq %r14, %rsi
callq 0x262f0
movq 0x8(%rsp), %rsi
testl %eax, %eax
jne 0x3f8ac
movslq 0x830(%r15), %rax
cmpq %rax, %rsi
jne 0x3f8ac
leaq 0x74352(%rip), %rsi     # 0xb3b9b
pushq $0x2
popq %rdi
xorl %eax, %eax
callq 0x2b699
leaq 0x743b3(%rip), %rdi     # 0xb3c0d
callq 0x3115a
movq %rbx, %rdi
movq %rax, %rsi
callq 0x36a9d
jmp 0x3f904
cmpq $0x0, 0x828(%r15)
je 0x3f8f1
callq 0x3f6ed
callq 0x3114c
movq %rax, %rdi
movq %rbx, %rsi
callq 0x383ac
movq %rax, %r14
leaq 0x742d6(%rip), %rsi     # 0xb3b6e
pushq $0x2
popq %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x2b699
jmp 0x3f8e9
movq 0x8(%rsp), %rsi
movq %r14, %rdi
callq 0x3f66f
callq 0x3114c
movq %rax, %rdi
movq %rbx, %rsi
callq 0x383ac
movq %rax, %r14
movq 0x828(%r15), %rdx
movl 0x830(%r15), %ecx
leaq 0x7435d(%rip), %rsi     # 0xb3c39
pushq $0x2
popq %rdi
movq %rax, %r8
xorl %eax, %eax
callq 0x2b699
movq %r14, %rdi
callq 0x311c8
leaq 0xbaa18(%rip), %rax     # 0xfa310
movq 0x8(%rax), %rsi
movq %rbx, %rdi
callq 0x36987
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
retq