// File: /workspace/github_c_makefile_star2_O1/zhou-yuxin[P]redis-aof-no-cow/src/sentinel.c
// Function: sentinelSendHello
int sentinelSendHello(sentinelRedisInstance *ri) {
    char ip[NET_IP_STR_LEN];
    char payload[NET_IP_STR_LEN+1024];
    int retval;
    char *announce_ip;
    int announce_port;
    sentinelRedisInstance *master = (ri->flags & SRI_MASTER) ? ri : ri->master;
    sentinelAddr *master_addr = sentinelGetCurrentMasterAddress(master);

    if (ri->link->disconnected) return C_ERR;

    /* Use the specified announce address if specified, otherwise try to
     * obtain our own IP address. */
    if (sentinel.announce_ip) {
        announce_ip = sentinel.announce_ip;
    } else {
        if (anetSockName(ri->link->cc->c.fd,ip,sizeof(ip),NULL) == -1)
            return C_ERR;
        announce_ip = ip;
    }
    announce_port = sentinel.announce_port ?
                    sentinel.announce_port : server.port;

    /* Format and send the Hello message. */
    snprintf(payload,sizeof(payload),
        "%s,%d,%s,%llu," /* Info about this sentinel. */
        "%s,%s,%d,%llu", /* Info about current master. */
        announce_ip, announce_port, sentinel.myid,
        (unsigned long long) sentinel.current_epoch,
        /* --- */
        master->name,master_addr->ip,master_addr->port,
        (unsigned long long) master->config_epoch);
    retval = redisAsyncCommand(ri->link->cc,
        sentinelPublishReplyCallback, ri, "PUBLISH %s %s",
            SENTINEL_HELLO_CHANNEL,payload);
    if (retval != C_OK) return C_ERR;
    ri->link->pending_commands++;
    return C_OK;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x468, %rsp            # imm = 0x468
movq %rdi, %rbx
testb $0x1, (%rdi)
movq %rdi, %r12
jne 0x7dc8e
movq 0xb8(%rbx), %r12
testb $0x40, (%r12)
je 0x7dcad
movq 0x118(%r12), %rax
testq %rax, %rax
je 0x7dcad
cmpl $0x4, 0xf0(%r12)
jg 0x7dcb0
movq %r12, %rax
movq 0x28(%rbx), %rcx
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
cmpl $0x0, 0x4(%rcx)
jne 0x7dd90
movq 0x20(%rax), %r13
movq 0x9da0a(%rip), %r14     # 0x11b6d8
testq %r14, %r14
jne 0x7dcf8
movq 0x10(%rcx), %rax
movl 0x84(%rax), %edi
movq %rsp, %r14
movl $0x2e, %edx
movq %r14, %rsi
xorl %ecx, %ecx
callq 0x3150f
cmpl $-0x1, %eax
je 0x7dd90
leaq 0x9d979(%rip), %r9      # 0x11b678
movl 0x9d9da(%rip), %r8d     # 0x11b6e0
testl %r8d, %r8d
jne 0x7dd19
leaq 0x88b46(%rip), %rax     # 0x106858
movl 0xa0(%rax), %r8d
movl 0x8(%r13), %r10d
subq $0x8, %rsp
leaq 0x51de4(%rip), %rdx     # 0xcfb0c
leaq 0x38(%rsp), %r15
movl $0x42e, %esi            # imm = 0x42E
movq %r15, %rdi
movq %r14, %rcx
xorl %eax, %eax
pushq 0x18(%r12)
pushq %r10
pushq (%r13)
pushq 0x8(%r12)
pushq 0x9d958(%rip)           # 0x11b6a8
callq 0x26120
addq $0x30, %rsp
movq 0x28(%rbx), %rax
movq 0x10(%rax), %rdi
leaq -0x44e(%rip), %rsi      # 0x7d91a
leaq 0x51db9(%rip), %rcx     # 0xcfb28
leaq 0x51b7b(%rip), %r8      # 0xcf8f1
movq %rbx, %rdx
movq %r15, %r9
xorl %eax, %eax
callq 0x867a1
testl %eax, %eax
jne 0x7dd90
movq 0x28(%rbx), %rax
incl 0x8(%rax)
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x468, %rsp            # imm = 0x468
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq