// File: /workspace/github_c_makefile_star2_O3/gplessis[P]dotdeb-redis/src/sentinel.c
// Function: sentinelSendSlaveOf
int sentinelSendSlaveOf(sentinelRedisInstance *ri, char *host, int port) {
    char portstr[32];
    int retval;

    ll2string(portstr,sizeof(portstr),port);

    /* If host is NULL we send SLAVEOF NO ONE that will turn the instance
     * into a master. */
    if (host == NULL) {
        host = "NO";
        memcpy(portstr,"ONE",4);
    }

    /* In order to send SLAVEOF in a safe way, we send a transaction performing
     * the following tasks:
     * 1) Reconfigure the instance according to the specified host/port params.
     * 2) Rewrite the configuraiton.
     * 3) Disconnect all clients (but this one sending the commnad) in order
     *    to trigger the ask-master-on-reconnection protocol for connected
     *    clients.
     *
     * Note that we don't check the replies returned by commands, since we
     * will observe instead the effects in the next INFO output. */
    retval = redisAsyncCommand(ri->link->cc,
        sentinelDiscardReplyCallback, ri, "MULTI");
    if (retval == C_ERR) return retval;
    ri->link->pending_commands++;

    retval = redisAsyncCommand(ri->link->cc,
        sentinelDiscardReplyCallback, ri, "SLAVEOF %s %s", host, portstr);
    if (retval == C_ERR) return retval;
    ri->link->pending_commands++;

    retval = redisAsyncCommand(ri->link->cc,
        sentinelDiscardReplyCallback, ri, "CONFIG REWRITE");
    if (retval == C_ERR) return retval;
    ri->link->pending_commands++;

    /* CLIENT KILL TYPE <type> is only supported starting from Redis 2.8.12,
     * however sending it to an instance not understanding this command is not
     * an issue because CLIENT is variadic command, so Redis will not
     * recognized as a syntax error, and the transaction will not fail (but
     * only the unsupported command will fail). */
    retval = redisAsyncCommand(ri->link->cc,
        sentinelDiscardReplyCallback, ri, "CLIENT KILL TYPE normal");
    if (retval == C_ERR) return retval;
    ri->link->pending_commands++;

    retval = redisAsyncCommand(ri->link->cc,
        sentinelDiscardReplyCallback, ri, "EXEC");
    if (retval == C_ERR) return retval;
    ri->link->pending_commands++;

    return C_OK;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0x20, %rsp
movq %rsi, %r14
movq %rdi, %rbx
movslq %edx, %rdx
movq %rsp, %rdi
movl $0x20, %esi
callq 0x3ff83
testq %r14, %r14
jne 0x79c41
movl $0x454e4f, (%rsp)       # imm = 0x454E4F
leaq 0x538d4(%rip), %r14     # 0xcd515
movq 0x28(%rbx), %rax
movq 0x10(%rax), %rdi
leaq -0x2618(%rip), %rsi     # 0x77638
leaq 0x4c21e(%rip), %rcx     # 0xc5e75
movq %rbx, %rdx
xorl %eax, %eax
callq 0x82c47
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
cmpl $-0x1, %eax
je 0x79d22
movq 0x28(%rbx), %rax
incl 0x8(%rax)
movq 0x10(%rax), %rdi
leaq -0x2649(%rip), %rsi     # 0x77638
leaq 0x53890(%rip), %rcx     # 0xcd518
movq %rsp, %r9
movq %rbx, %rdx
movq %r14, %r8
xorl %eax, %eax
callq 0x82c47
cmpl $-0x1, %eax
je 0x79d22
movq 0x28(%rbx), %rax
incl 0x8(%rax)
movq 0x10(%rax), %rdi
leaq -0x267b(%rip), %rsi     # 0x77638
leaq 0x4aff4(%rip), %rcx     # 0xc4cae
movq %rbx, %rdx
xorl %eax, %eax
callq 0x82c47
cmpl $-0x1, %eax
je 0x79d22
movq 0x28(%rbx), %rax
incl 0x8(%rax)
movq 0x10(%rax), %rdi
leaq -0x26a3(%rip), %rsi     # 0x77638
leaq 0x53844(%rip), %rcx     # 0xcd526
movq %rbx, %rdx
xorl %eax, %eax
callq 0x82c47
cmpl $-0x1, %eax
je 0x79d22
movq 0x28(%rbx), %rax
incl 0x8(%rax)
movq 0x10(%rax), %rdi
leaq -0x26cb(%rip), %rsi     # 0x77638
leaq 0x5071a(%rip), %rcx     # 0xca424
movq %rbx, %rdx
xorl %eax, %eax
callq 0x82c47
cmpl $-0x1, %eax
je 0x79d22
movq 0x28(%rbx), %rax
incl 0x8(%rax)
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x20, %rsp
popq %rbx
popq %r14
popq %rbp
retq