// File: /workspace/github_c_makefile_star2_O1/zhou-yuxin[P]redis-aof-no-cow/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 0xbc836(%rip), %r15     # 0x106858
cmpl $0x0, 0x98c(%r15)
je 0x4a044
leaq 0x7b332(%rip), %rsi     # 0xc5365
movq %rbx, %rdi
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
jmp 0x3ffcb
movq 0x40(%rbx), %r14
movq 0x8(%r14), %rax
movq 0x8(%rax), %rdi
leaq 0x834bf(%rip), %rsi     # 0xcd516
callq 0x26300
testl %eax, %eax
jne 0x4a07c
movq 0x10(%r14), %rax
movq 0x8(%rax), %rdi
leaq 0x8ae8f(%rip), %rsi     # 0xd4efe
callq 0x26300
testl %eax, %eax
je 0x4a143
movq 0x10(%r14), %rsi
leaq 0x8(%rsp), %rdx
movq %rbx, %rdi
xorl %ecx, %ecx
callq 0x44ba1
testl %eax, %eax
jne 0x4a196
movq 0x818(%r15), %rdi
testq %rdi, %rdi
je 0x4a0f5
movq 0x40(%rbx), %rax
movq 0x8(%rax), %rax
movq 0x8(%rax), %rsi
callq 0x26300
testl %eax, %eax
jne 0x4a0f5
movslq 0x820(%r15), %rax
cmpq %rax, 0x8(%rsp)
jne 0x4a0f5
leaq 0x7b2ea(%rip), %rsi     # 0xc53b7
movl $0x2, %edi
xorl %eax, %eax
callq 0x32ea6
leaq 0x7b349(%rip), %rdi     # 0xc5429
callq 0x39245
movq %rbx, %rdi
movq %rax, %rsi
callq 0x3fe4b
jmp 0x4a196
movq 0x40(%rbx), %rax
movq 0x8(%rax), %rax
movq 0x8(%rax), %rdi
movl 0x8(%rsp), %esi
callq 0x49ef3
callq 0x39222
movq %rax, %rdi
movq %rbx, %rsi
callq 0x41cda
movq %rax, %r14
movq 0x818(%r15), %rdx
movl 0x820(%r15), %ecx
leaq 0x7b323(%rip), %rsi     # 0xc5455
movl $0x2, %edi
movq %rax, %r8
xorl %eax, %eax
callq 0x32ea6
jmp 0x4a17b
cmpq $0x0, 0x818(%r15)
je 0x4a183
callq 0x49f71
callq 0x39222
movq %rax, %rdi
movq %rbx, %rsi
callq 0x41cda
movq %rax, %r14
leaq 0x7b21e(%rip), %rsi     # 0xc538a
movl $0x2, %edi
movq %rax, %rdx
xorl %eax, %eax
callq 0x32ea6
movq %r14, %rdi
callq 0x392b6
leaq 0xbd126(%rip), %rax     # 0x1072b0
movq 0x8(%rax), %rsi
movq %rbx, %rdi
callq 0x3fc19
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
retq