// File: /workspace/github_c_makefile_star2_O2/gplessis[P]dotdeb-redis/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 0x6c98d
movq %rdi, %r14
movq 0x20(%rdi), %rax
cmpl $0x0, 0x8(%rax)
je 0x6c98d
callq 0x2b8ae
movq 0x28(%r14), %rcx
movq %rax, %rdx
subq 0x58(%rcx), %rdx
cmpq $0x3e8, %rdx            # imm = 0x3E8
jl 0x6c98d
movq %rax, 0x58(%rcx)
cmpq $0x0, 0x10(%rbx)
jne 0x6c903
movq 0x20(%r14), %rax
movq (%rax), %rdi
movl 0x8(%rax), %esi
leaq 0x8d063(%rip), %r15     # 0xf98a8
cmpl $0x0, 0x128(%r15)
je 0x6c858
movq 0xa8(%r15), %rdx
jmp 0x6c85a
xorl %edx, %edx
callq 0x74ef5
movq %rax, 0x10(%rbx)
cmpl $0x0, 0xa0(%rax)
je 0x6c89b
movq 0xa8(%rax), %r8
leaq 0x50d7a(%rip), %rsi     # 0xbd5f4
leaq 0x50d8a(%rip), %rcx     # 0xbd60b
xorl %edi, %edi
movq %r14, %rdx
xorl %eax, %eax
callq 0x6a7bb
movq 0x10(%rbx), %rsi
movq %rbx, %rdi
callq 0x6b1e4
jmp 0x6c903
andl $0x0, 0x8(%rbx)
callq 0x2b8ae
movq %rax, 0x20(%rbx)
movq 0x10(%rbx), %rsi
movq %rbx, 0xb0(%rsi)
movq 0x40(%r15), %rdi
callq 0x6ca2b
movq 0x10(%rbx), %rdi
leaq -0x1380(%rip), %rsi     # 0x6b547
callq 0x74f57
movq 0x10(%rbx), %rdi
leaq -0x1387(%rip), %rsi     # 0x6b550
callq 0x74f89
movq 0x10(%rbx), %rsi
movq %r14, %rdi
callq 0x6c737
movq 0x10(%rbx), %rsi
leaq 0x50d1f(%rip), %rdx     # 0xbd612
movq %r14, %rdi
callq 0x6c781
movq %r14, %rdi
callq 0x6cab2
testb $0x3, (%r14)
je 0x6c975
cmpq $0x0, 0x18(%rbx)
jne 0x6c975
movq 0x20(%r14), %rax
movq (%rax), %rdi
movl 0x8(%rax), %esi
leaq 0x8cf87(%rip), %r15     # 0xf98a8
cmpl $0x0, 0x128(%r15)
je 0x6c934
movq 0xa8(%r15), %rdx
jmp 0x6c936
xorl %edx, %edx
callq 0x74ef5
movq %rax, 0x18(%rbx)
cmpl $0x0, 0xa0(%rax)
je 0x6c993
movq 0xa8(%rax), %r8
leaq 0x50cc0(%rip), %rsi     # 0xbd616
leaq 0x50cae(%rip), %rcx     # 0xbd60b
xorl %edi, %edi
movq %r14, %rdx
xorl %eax, %eax
callq 0x6a7bb
movq 0x18(%rbx), %rsi
movq %rbx, %rdi
callq 0x6b1e4
cmpq $0x0, 0x10(%rbx)
je 0x6c98d
testb $0x4, (%r14)
jne 0x6c989
cmpq $0x0, 0x18(%rbx)
je 0x6c98d
andl $0x0, 0x4(%rbx)
popq %rbx
popq %r14
popq %r15
retq
callq 0x2b8ae
movq %rax, 0x28(%rbx)
movq 0x18(%rbx), %rsi
movq %rbx, 0xb0(%rsi)
movq 0x40(%r15), %rdi
callq 0x6ca2b
movq 0x18(%rbx), %rdi
leaq -0x1474(%rip), %rsi     # 0x6b547
callq 0x74f57
movq 0x18(%rbx), %rdi
leaq -0x147b(%rip), %rsi     # 0x6b550
callq 0x74f89
movq 0x18(%rbx), %rsi
movq %r14, %rdi
callq 0x6c737
movq 0x18(%rbx), %rsi
leaq 0x41de9(%rip), %rdx     # 0xae7d0
movq %r14, %rdi
callq 0x6c781
movq 0x18(%rbx), %rdi
leaq 0x10f(%rip), %rsi       # 0x6cb09
leaq 0x50c2f(%rip), %rcx     # 0xbd630
leaq 0x50c35(%rip), %r8      # 0xbd63d
movq %r14, %rdx
xorl %eax, %eax
callq 0x7597e
testl %eax, %eax
je 0x6c975
movq 0x18(%rbx), %rsi
movq %rbx, %rdi
popq %rbx
popq %r14
popq %r15
jmp 0x6b1e4