// File: /workspace/github_c_makefile_star2_O3/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 0xbab69(%rip), %r15     # 0x1018a8
cmpl $0x0, 0x99c(%r15)
je 0x46d61
leaq 0x7b6a9(%rip), %rsi     # 0xc23f9
movq %rbx, %rdi
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
jmp 0x3cc06
movq 0x40(%rbx), %r14
movq 0x8(%r14), %rax
movq 0x8(%rax), %rdi
leaq 0x8383a(%rip), %rsi     # 0xca5ae
callq 0x262f0
movq 0x10(%r14), %r14
testl %eax, %eax
jne 0x46d99
movq 0x8(%r14), %rdi
leaq 0x8b2d2(%rip), %rsi     # 0xd205e
callq 0x262f0
testl %eax, %eax
je 0x46e1b
leaq 0x8(%rsp), %rdx
movq %rbx, %rdi
movq %r14, %rsi
xorl %ecx, %ecx
callq 0x41718
testl %eax, %eax
jne 0x46eb4
movq 0x828(%r15), %rdi
movq 0x40(%rbx), %rax
movq 0x8(%rax), %rax
movq 0x8(%rax), %r14
testq %rdi, %rdi
je 0x46e55
movq %r14, %rsi
callq 0x262f0
movq 0x8(%rsp), %rsi
testl %eax, %eax
jne 0x46e5a
movslq 0x830(%r15), %rax
cmpq %rax, %rsi
jne 0x46e5a
leaq 0x7b658(%rip), %rsi     # 0xc244b
movl $0x2, %edi
xorl %eax, %eax
callq 0x2fdad
leaq 0x7b6b7(%rip), %rdi     # 0xc24bd
callq 0x362b0
movq %rbx, %rdi
movq %rax, %rsi
callq 0x3ca86
jmp 0x46eb4
cmpq $0x0, 0x828(%r15)
je 0x46ea1
callq 0x46c8e
callq 0x3628d
movq %rax, %rdi
movq %rbx, %rsi
callq 0x3e908
movq %rax, %r14
leaq 0x7b5da(%rip), %rsi     # 0xc241e
movl $0x2, %edi
movq %rax, %rdx
xorl %eax, %eax
callq 0x2fdad
jmp 0x46e99
movq 0x8(%rsp), %rsi
movq %r14, %rdi
callq 0x46c10
callq 0x3628d
movq %rax, %rdi
movq %rbx, %rsi
callq 0x3e908
movq %rax, %r14
movq 0x828(%r15), %rdx
movl 0x830(%r15), %ecx
leaq 0x7b65f(%rip), %rsi     # 0xc24e9
movl $0x2, %edi
movq %rax, %r8
xorl %eax, %eax
callq 0x2fdad
movq %r14, %rdi
callq 0x36330
leaq 0xbb468(%rip), %rax     # 0x102310
movq 0x8(%rax), %rsi
movq %rbx, %rdi
callq 0x3c854
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
retq