// File: /workspace/github_c_makefile_star2_O1/zhou-yuxin[P]redis-aof-no-cow/src/sentinel.c
// Function: sentinelReconnectInstance
void sentinelReconnectInstance(sentinelRedisInstance *ri) {
    if (ri->link->disconnected == 0) return;
    if (ri->addr->port == 0) return; /* port == 0 means invalid address. */
    instanceLink *link = ri->link;
    mstime_t now = mstime();

    if (now - ri->link->last_reconn_time < SENTINEL_PING_PERIOD) return;
    ri->link->last_reconn_time = now;

    /* Commands connection. */
    if (link->cc == NULL) {
        link->cc = redisAsyncConnectBind(ri->addr->ip,ri->addr->port,NET_FIRST_BIND_ADDR);
        if (link->cc->err) {
            sentinelEvent(LL_DEBUG,"-cmd-link-reconnection",ri,"%@ #%s",
                link->cc->errstr);
            instanceLinkCloseConnection(link,link->cc);
        } else {
            link->pending_commands = 0;
            link->cc_conn_time = mstime();
            link->cc->data = link;
            redisAeAttach(server.el,link->cc);
            redisAsyncSetConnectCallback(link->cc,
                    sentinelLinkEstablishedCallback);
            redisAsyncSetDisconnectCallback(link->cc,
                    sentinelDisconnectCallback);
            sentinelSendAuthIfNeeded(ri,link->cc);
            sentinelSetClientName(ri,link->cc,"cmd");

            /* Send a PING ASAP when reconnecting. */
            sentinelSendPing(ri);
        }
    }
    /* Pub / Sub */
    if ((ri->flags & (SRI_MASTER|SRI_SLAVE)) && link->pc == NULL) {
        link->pc = redisAsyncConnectBind(ri->addr->ip,ri->addr->port,NET_FIRST_BIND_ADDR);
        if (link->pc->err) {
            sentinelEvent(LL_DEBUG,"-pubsub-link-reconnection",ri,"%@ #%s",
                link->pc->errstr);
            instanceLinkCloseConnection(link,link->pc);
        } else {
            int retval;

            link->pc_conn_time = mstime();
            link->pc->data = link;
            redisAeAttach(server.el,link->pc);
            redisAsyncSetConnectCallback(link->pc,
                    sentinelLinkEstablishedCallback);
            redisAsyncSetDisconnectCallback(link->pc,
                    sentinelDisconnectCallback);
            sentinelSendAuthIfNeeded(ri,link->pc);
            sentinelSetClientName(ri,link->pc,"pubsub");
            /* Now we subscribe to the Sentinels "Hello" channel. */
            retval = redisAsyncCommand(link->pc,
                sentinelReceiveHelloMessages, ri, "SUBSCRIBE %s",
                    SENTINEL_HELLO_CHANNEL);
            if (retval != C_OK) {
                /* If we can't subscribe, the Pub/Sub connection is useless
                 * and we can simply disconnect it and try again. */
                instanceLinkCloseConnection(link,link->pc);
                return;
            }
        }
    }
    /* Clear the disconnected status only if we have both the connections
     * (or just the commands connection if this is a sentinel instance). */
    if (link->cc && (ri->flags & SRI_SENTINEL || link->pc))
        link->disconnected = 0;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq 0x28(%rdi), %rbx
cmpl $0x0, 0x4(%rbx)
je 0x7ca1c
movq %rdi, %r14
movq 0x20(%rdi), %rax
cmpl $0x0, 0x8(%rax)
je 0x7ca1c
callq 0x330c8
movq 0x28(%r14), %rcx
movq %rax, %rdx
subq 0x58(%rcx), %rdx
cmpq $0x3e8, %rdx            # imm = 0x3E8
jl 0x7ca1c
movq %rax, 0x58(%rcx)
cmpq $0x0, 0x10(%rbx)
jne 0x7c98f
movq 0x20(%r14), %rax
movq (%rax), %rdi
movl 0x8(%rax), %esi
leaq 0x89f8a(%rip), %r15     # 0x106858
cmpl $0x0, 0x128(%r15)
je 0x7c8e1
movq 0xa8(%r15), %rdx
jmp 0x7c8e3
xorl %edx, %edx
callq 0x85bd9
movq %rax, 0x10(%rbx)
cmpl $0x0, 0xa0(%rax)
je 0x7c924
movq 0xa8(%rax), %r8
leaq 0x52fa5(%rip), %rsi     # 0xcf8a8
leaq 0x52fb5(%rip), %rcx     # 0xcf8bf
xorl %edi, %edi
movq %r14, %rdx
xorl %eax, %eax
callq 0x7a50c
movq 0x10(%rbx), %rsi
movq %rbx, %rdi
callq 0x7b040
jmp 0x7c98f
movl $0x0, 0x8(%rbx)
callq 0x330c8
movq %rax, 0x20(%rbx)
movq 0x10(%rbx), %rsi
movq %rbx, 0xb0(%rsi)
movq 0x40(%r15), %rdi
callq 0x7caba
movq 0x10(%rbx), %rdi
leaq -0x1515(%rip), %rsi     # 0x7b43e
callq 0x85c3b
movq 0x10(%rbx), %rdi
leaq -0x14fb(%rip), %rsi     # 0x7b468
callq 0x85c6d
movq 0x10(%rbx), %rsi
movq %r14, %rdi
callq 0x7c7be
movq 0x10(%rbx), %rsi
leaq 0x52f47(%rip), %rdx     # 0xcf8c6
movq %r14, %rdi
callq 0x7c808
movq %r14, %rdi
callq 0x7cb46
testb $0x3, (%r14)
je 0x7ca01
cmpq $0x0, 0x18(%rbx)
jne 0x7ca01
movq 0x20(%r14), %rax
movq (%rax), %rdi
movl 0x8(%rax), %esi
leaq 0x89eab(%rip), %r15     # 0x106858
cmpl $0x0, 0x128(%r15)
je 0x7c9c0
movq 0xa8(%r15), %rdx
jmp 0x7c9c2
xorl %edx, %edx
callq 0x85bd9
movq %rax, 0x18(%rbx)
cmpl $0x0, 0xa0(%rax)
je 0x7ca22
movq 0xa8(%rax), %r8
leaq 0x52ee8(%rip), %rsi     # 0xcf8ca
leaq 0x52ed6(%rip), %rcx     # 0xcf8bf
xorl %edi, %edi
movq %r14, %rdx
xorl %eax, %eax
callq 0x7a50c
movq 0x18(%rbx), %rsi
movq %rbx, %rdi
callq 0x7b040
cmpq $0x0, 0x10(%rbx)
je 0x7ca1c
testb $0x4, (%r14)
jne 0x7ca15
cmpq $0x0, 0x18(%rbx)
je 0x7ca1c
movl $0x0, 0x4(%rbx)
popq %rbx
popq %r14
popq %r15
retq
callq 0x330c8
movq %rax, 0x28(%rbx)
movq 0x18(%rbx), %rsi
movq %rbx, 0xb0(%rsi)
movq 0x40(%r15), %rdi
callq 0x7caba
movq 0x18(%rbx), %rdi
leaq -0x160c(%rip), %rsi     # 0x7b43e
callq 0x85c3b
movq 0x18(%rbx), %rdi
leaq -0x15f2(%rip), %rsi     # 0x7b468
callq 0x85c6d
movq 0x18(%rbx), %rsi
movq %r14, %rdi
callq 0x7c7be
movq 0x18(%rbx), %rsi
leaq 0x42e1a(%rip), %rdx     # 0xbf890
movq %r14, %rdi
callq 0x7c808
movq 0x18(%rbx), %rdi
leaq 0x116(%rip), %rsi       # 0x7cb9f
leaq 0x52e54(%rip), %rcx     # 0xcf8e4
leaq 0x52e5a(%rip), %r8      # 0xcf8f1
movq %r14, %rdx
xorl %eax, %eax
callq 0x867a1
testl %eax, %eax
je 0x7ca01
movq 0x18(%rbx), %rsi
movq %rbx, %rdi
popq %rbx
popq %r14
popq %r15
jmp 0x7b040