// File: /workspace/github_c_makefile_star2_O3/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 0x78ede
movq %rdi, %r14
movq 0x20(%rdi), %rax
cmpl $0x0, 0x8(%rax)
je 0x78ede
callq 0x2ffce
movq 0x28(%r14), %rcx
movq %rax, %rdx
subq 0x58(%rcx), %rdx
cmpq $0x3e8, %rdx            # imm = 0x3E8
jl 0x78ede
movq %rax, 0x58(%rcx)
cmpq $0x0, 0x10(%rbx)
jne 0x78e51
movq 0x20(%r14), %rax
movq (%rax), %rdi
movl 0x8(%rax), %esi
leaq 0x88b18(%rip), %r15     # 0x1018a8
cmpl $0x0, 0x128(%r15)
je 0x78da3
movq 0xa8(%r15), %rdx
jmp 0x78da5
xorl %edx, %edx
callq 0x820a9
movq %rax, 0x10(%rbx)
cmpl $0x0, 0xa0(%rax)
je 0x78de6
movq 0xa8(%rax), %r8
leaq 0x53be3(%rip), %rsi     # 0xcc9a8
leaq 0x53bf3(%rip), %rcx     # 0xcc9bf
xorl %edi, %edi
movq %r14, %rdx
xorl %eax, %eax
callq 0x76a24
movq 0x10(%rbx), %rsi
movq %rbx, %rdi
callq 0x77559
jmp 0x78e51
movl $0x0, 0x8(%rbx)
callq 0x2ffce
movq %rax, 0x20(%rbx)
movq 0x10(%rbx), %rsi
movq %rbx, 0xb0(%rsi)
movq 0x40(%r15), %rdi
callq 0x78f7c
movq 0x10(%rbx), %rdi
leaq -0x14da(%rip), %rsi     # 0x7793b
callq 0x8210b
movq 0x10(%rbx), %rdi
leaq -0x14c0(%rip), %rsi     # 0x77965
callq 0x8213d
movq 0x10(%rbx), %rsi
movq %r14, %rdi
callq 0x78c80
movq 0x10(%rbx), %rsi
leaq 0x53b85(%rip), %rdx     # 0xcc9c6
movq %r14, %rdi
callq 0x78cca
movq %r14, %rdi
callq 0x79008
testb $0x3, (%r14)
je 0x78ec3
cmpq $0x0, 0x18(%rbx)
jne 0x78ec3
movq 0x20(%r14), %rax
movq (%rax), %rdi
movl 0x8(%rax), %esi
leaq 0x88a39(%rip), %r15     # 0x1018a8
cmpl $0x0, 0x128(%r15)
je 0x78e82
movq 0xa8(%r15), %rdx
jmp 0x78e84
xorl %edx, %edx
callq 0x820a9
movq %rax, 0x18(%rbx)
cmpl $0x0, 0xa0(%rax)
je 0x78ee4
movq 0xa8(%rax), %r8
leaq 0x53b26(%rip), %rsi     # 0xcc9ca
leaq 0x53b14(%rip), %rcx     # 0xcc9bf
xorl %edi, %edi
movq %r14, %rdx
xorl %eax, %eax
callq 0x76a24
movq 0x18(%rbx), %rsi
movq %rbx, %rdi
callq 0x77559
cmpq $0x0, 0x10(%rbx)
je 0x78ede
testb $0x4, (%r14)
jne 0x78ed7
cmpq $0x0, 0x18(%rbx)
je 0x78ede
movl $0x0, 0x4(%rbx)
popq %rbx
popq %r14
popq %r15
retq
callq 0x2ffce
movq %rax, 0x28(%rbx)
movq 0x18(%rbx), %rsi
movq %rbx, 0xb0(%rsi)
movq 0x40(%r15), %rdi
callq 0x78f7c
movq 0x18(%rbx), %rdi
leaq -0x15d1(%rip), %rsi     # 0x7793b
callq 0x8210b
movq 0x18(%rbx), %rdi
leaq -0x15b7(%rip), %rsi     # 0x77965
callq 0x8213d
movq 0x18(%rbx), %rsi
movq %r14, %rdi
callq 0x78c80
movq 0x18(%rbx), %rsi
leaq 0x439a8(%rip), %rdx     # 0xbc8e0
movq %r14, %rdi
callq 0x78cca
movq 0x18(%rbx), %rdi
leaq 0x116(%rip), %rsi       # 0x79061
leaq 0x53a92(%rip), %rcx     # 0xcc9e4
leaq 0x53a98(%rip), %r8      # 0xcc9f1
movq %r14, %rdx
xorl %eax, %eax
callq 0x82c47
testl %eax, %eax
je 0x78ec3
movq 0x18(%rbx), %rsi
movq %rbx, %rdi
popq %rbx
popq %r14
popq %r15
jmp 0x77559