// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/sentinel.c
// Function: addReplySentinelRedisInstance
void addReplySentinelRedisInstance(redisClient *c, sentinelRedisInstance *ri) {
    char *flags = sdsempty();
    void *mbl;
    int fields = 0;

    mbl = addDeferredMultiBulkLength(c);

    addReplyBulkCString(c,"name");
    addReplyBulkCString(c,ri->name);
    fields++;

    addReplyBulkCString(c,"ip");
    addReplyBulkCString(c,ri->addr->ip);
    fields++;

    addReplyBulkCString(c,"port");
    addReplyBulkLongLong(c,ri->addr->port);
    fields++;

    addReplyBulkCString(c,"runid");
    addReplyBulkCString(c,ri->runid ? ri->runid : "");
    fields++;

    addReplyBulkCString(c,"flags");
    if (ri->flags & SRI_S_DOWN) flags = sdscat(flags,"s_down,");
    if (ri->flags & SRI_O_DOWN) flags = sdscat(flags,"o_down,");
    if (ri->flags & SRI_MASTER) flags = sdscat(flags,"master,");
    if (ri->flags & SRI_SLAVE) flags = sdscat(flags,"slave,");
    if (ri->flags & SRI_SENTINEL) flags = sdscat(flags,"sentinel,");
    if (ri->flags & SRI_DISCONNECTED) flags = sdscat(flags,"disconnected,");
    if (ri->flags & SRI_MASTER_DOWN) flags = sdscat(flags,"master_down,");
    if (ri->flags & SRI_FAILOVER_IN_PROGRESS)
        flags = sdscat(flags,"failover_in_progress,");
    if (ri->flags & SRI_PROMOTED) flags = sdscat(flags,"promoted,");
    if (ri->flags & SRI_RECONF_SENT) flags = sdscat(flags,"reconf_sent,");
    if (ri->flags & SRI_RECONF_INPROG) flags = sdscat(flags,"reconf_inprog,");
    if (ri->flags & SRI_RECONF_DONE) flags = sdscat(flags,"reconf_done,");

    if (sdslen(flags) != 0) sdsrange(flags,0,-2); /* remove last "," */
    addReplyBulkCString(c,flags);
    sdsfree(flags);
    fields++;

    addReplyBulkCString(c,"pending-commands");
    addReplyBulkLongLong(c,ri->pending_commands);
    fields++;

    if (ri->flags & SRI_FAILOVER_IN_PROGRESS) {
        addReplyBulkCString(c,"failover-state");
        addReplyBulkCString(c,(char*)sentinelFailoverStateStr(ri->failover_state));
        fields++;
    }

    addReplyBulkCString(c,"last-ping-sent");
    addReplyBulkLongLong(c,
        ri->last_ping_time ? (mstime() - ri->last_ping_time) : 0);
    fields++;

    addReplyBulkCString(c,"last-ok-ping-reply");
    addReplyBulkLongLong(c,mstime() - ri->last_avail_time);
    fields++;

    addReplyBulkCString(c,"last-ping-reply");
    addReplyBulkLongLong(c,mstime() - ri->last_pong_time);
    fields++;

    if (ri->flags & SRI_S_DOWN) {
        addReplyBulkCString(c,"s-down-time");
        addReplyBulkLongLong(c,mstime()-ri->s_down_since_time);
        fields++;
    }

    if (ri->flags & SRI_O_DOWN) {
        addReplyBulkCString(c,"o-down-time");
        addReplyBulkLongLong(c,mstime()-ri->o_down_since_time);
        fields++;
    }

    addReplyBulkCString(c,"down-after-milliseconds");
    addReplyBulkLongLong(c,ri->down_after_period);
    fields++;

    /* Masters and Slaves */
    if (ri->flags & (SRI_MASTER|SRI_SLAVE)) {
        addReplyBulkCString(c,"info-refresh");
        addReplyBulkLongLong(c,mstime() - ri->info_refresh);
        fields++;

        addReplyBulkCString(c,"role-reported");
        addReplyBulkCString(c, (ri->role_reported == SRI_MASTER) ? "master" :
                                                                   "slave");
        fields++;

        addReplyBulkCString(c,"role-reported-time");
        addReplyBulkLongLong(c,mstime() - ri->role_reported_time);
        fields++;
    }

    /* Only masters */
    if (ri->flags & SRI_MASTER) {
        addReplyBulkCString(c,"config-epoch");
        addReplyBulkLongLong(c,ri->config_epoch);
        fields++;

        addReplyBulkCString(c,"num-slaves");
        addReplyBulkLongLong(c,dictSize(ri->slaves));
        fields++;

        addReplyBulkCString(c,"num-other-sentinels");
        addReplyBulkLongLong(c,dictSize(ri->sentinels));
        fields++;

        addReplyBulkCString(c,"quorum");
        addReplyBulkLongLong(c,ri->quorum);
        fields++;

        addReplyBulkCString(c,"failover-timeout");
        addReplyBulkLongLong(c,ri->failover_timeout);
        fields++;

        addReplyBulkCString(c,"parallel-syncs");
        addReplyBulkLongLong(c,ri->parallel_syncs);
        fields++;

        if (ri->notification_script) {
            addReplyBulkCString(c,"notification-script");
            addReplyBulkCString(c,ri->notification_script);
            fields++;
        }

        if (ri->client_reconfig_script) {
            addReplyBulkCString(c,"client-reconfig-script");
            addReplyBulkCString(c,ri->client_reconfig_script);
            fields++;
        }
    }

    /* Only slaves */
    if (ri->flags & SRI_SLAVE) {
        addReplyBulkCString(c,"master-link-down-time");
        addReplyBulkLongLong(c,ri->master_link_down_time);
        fields++;

        addReplyBulkCString(c,"master-link-status");
        addReplyBulkCString(c,
            (ri->slave_master_link_status == SENTINEL_MASTER_LINK_STATUS_UP) ?
            "ok" : "err");
        fields++;

        addReplyBulkCString(c,"master-host");
        addReplyBulkCString(c,
            ri->slave_master_host ? ri->slave_master_host : "?");
        fields++;

        addReplyBulkCString(c,"master-port");
        addReplyBulkLongLong(c,ri->slave_master_port);
        fields++;

        addReplyBulkCString(c,"slave-priority");
        addReplyBulkLongLong(c,ri->slave_priority);
        fields++;

        addReplyBulkCString(c,"slave-repl-offset");
        addReplyBulkLongLong(c,ri->slave_repl_offset);
        fields++;
    }

    /* Only sentinels */
    if (ri->flags & SRI_SENTINEL) {
        addReplyBulkCString(c,"last-hello-message");
        addReplyBulkLongLong(c,mstime() - ri->last_hello_time);
        fields++;

        addReplyBulkCString(c,"voted-leader");
        addReplyBulkCString(c,ri->leader ? ri->leader : "?");
        fields++;

        addReplyBulkCString(c,"voted-leader-epoch");
        addReplyBulkLongLong(c,ri->leader_epoch);
        fields++;
    }

    setDeferredMultiBulkLength(c,mbl,fields*2);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r15
movq %rdi, %rbx
callq 0x281b2
movq %rax, %r12
movq %rbx, %rdi
callq 0x2dc0a
movq %rax, %r14
leaq 0x411cb(%rip), %rsi     # 0x9fa0e
movq %rbx, %rdi
callq 0x2ddc1
movq 0x8(%r15), %rsi
movq %rbx, %rdi
callq 0x2ddc1
leaq 0x40ed2(%rip), %rsi     # 0x9f730
movq %rbx, %rdi
callq 0x2ddc1
movq 0x20(%r15), %rax
movq (%rax), %rsi
movq %rbx, %rdi
callq 0x2ddc1
leaq 0x3aebe(%rip), %rsi     # 0x9973a
movq %rbx, %rdi
callq 0x2ddc1
movq 0x20(%r15), %rax
movslq 0x8(%rax), %rsi
movq %rbx, %rdi
callq 0x2dfe7
leaq 0x4074f(%rip), %rsi     # 0x9efea
movq %rbx, %rdi
callq 0x2ddc1
movq 0x10(%r15), %rax
testq %rax, %rax
leaq 0x38a30(%rip), %rsi     # 0x972e1
cmovneq %rax, %rsi
movq %rbx, %rdi
callq 0x2ddc1
leaq 0x3d3e1(%rip), %rsi     # 0x9bca5
movq %rbx, %rdi
callq 0x2ddc1
testb $0x10, (%r15)
je 0x5e8e4
leaq 0x40e5a(%rip), %rsi     # 0x9f733
movq %r12, %rdi
callq 0x283d7
movq %rax, %r12
testb $0x20, (%r15)
je 0x5e8fc
leaq 0x40e4a(%rip), %rsi     # 0x9f73b
movq %r12, %rdi
callq 0x283d7
movq %rax, %r12
testb $0x1, (%r15)
je 0x5e914
leaq 0x3d820(%rip), %rsi     # 0x9c129
movq %r12, %rdi
callq 0x283d7
movq %rax, %r12
testb $0x2, (%r15)
je 0x5e92c
leaq 0x3d810(%rip), %rsi     # 0x9c131
movq %r12, %rdi
callq 0x283d7
movq %rax, %r12
testb $0x4, (%r15)
je 0x5e944
leaq 0x40e0a(%rip), %rsi     # 0x9f743
movq %r12, %rdi
callq 0x283d7
movq %rax, %r12
testb $0x8, (%r15)
je 0x5e95c
leaq 0x40dfc(%rip), %rsi     # 0x9f74d
movq %r12, %rdi
callq 0x283d7
movq %rax, %r12
testb $0x40, (%r15)
je 0x5e974
leaq 0x40df2(%rip), %rsi     # 0x9f75b
movq %r12, %rdi
callq 0x283d7
movq %rax, %r12
testb $-0x80, (%r15)
je 0x5e98c
leaq 0x40de7(%rip), %rsi     # 0x9f768
movq %r12, %rdi
callq 0x283d7
movq %rax, %r12
testb $0x1, 0x1(%r15)
je 0x5e9a5
leaq 0x40de4(%rip), %rsi     # 0x9f77e
movq %r12, %rdi
callq 0x283d7
movq %rax, %r12
testb $0x2, 0x1(%r15)
je 0x5e9be
leaq 0x40dd5(%rip), %rsi     # 0x9f788
movq %r12, %rdi
callq 0x283d7
movq %rax, %r12
testb $0x4, 0x1(%r15)
je 0x5e9d7
leaq 0x40dc9(%rip), %rsi     # 0x9f795
movq %r12, %rdi
callq 0x283d7
movq %rax, %r12
testb $0x8, 0x1(%r15)
je 0x5e9f0
leaq 0x40dbf(%rip), %rsi     # 0x9f7a4
movq %r12, %rdi
callq 0x283d7
movq %rax, %r12
cmpl $0x0, -0x8(%r12)
je 0x5ea07
movq %r12, %rdi
xorl %esi, %esi
movl $0xfffffffe, %edx       # imm = 0xFFFFFFFE
callq 0x28c31
movq %rbx, %rdi
movq %r12, %rsi
callq 0x2ddc1
movq %r12, %rdi
callq 0x28204
leaq 0x40d90(%rip), %rsi     # 0x9f7b1
movq %rbx, %rdi
callq 0x2ddc1
movslq 0x38(%r15), %rsi
movq %rbx, %rdi
callq 0x2dfe7
movl $0x9, %r12d
testb $-0x80, (%r15)
je 0x5ea7f
leaq 0x40d7a(%rip), %rsi     # 0x9f7c2
movq %rbx, %rdi
callq 0x2ddc1
movl 0x130(%r15), %eax
cmpq $0x6, %rax
ja 0x5ea6a
leaq 0x649cc(%rip), %rcx     # 0xc3430
movq (%rcx,%rax,8), %rsi
jmp 0x5ea71
leaq 0x38a1d(%rip), %rsi     # 0x9748e
movq %rbx, %rdi
callq 0x2ddc1
movl $0xa, %r12d
leaq 0x40d4b(%rip), %rsi     # 0x9f7d1
movq %rbx, %rdi
callq 0x2ddc1
cmpq $0x0, 0x60(%r15)
je 0x5eaa3
callq 0x232a3
movq %rax, %rsi
subq 0x60(%r15), %rsi
jmp 0x5eaa5
xorl %esi, %esi
movq %rbx, %rdi
callq 0x2dfe7
leaq 0x40d2c(%rip), %rsi     # 0x9f7e0
movq %rbx, %rdi
callq 0x2ddc1
callq 0x232a3
subq 0x58(%r15), %rax
movq %rbx, %rdi
movq %rax, %rsi
callq 0x2dfe7
leaq 0x40d1c(%rip), %rsi     # 0x9f7f3
movq %rbx, %rdi
callq 0x2ddc1
callq 0x232a3
subq 0x68(%r15), %rax
movq %rbx, %rdi
movq %rax, %rsi
callq 0x2dfe7
testb $0x10, (%r15)
je 0x5eb22
leaq 0x40d03(%rip), %rsi     # 0x9f803
movq %rbx, %rdi
callq 0x2ddc1
callq 0x232a3
subq 0x88(%r15), %rax
movq %rbx, %rdi
movq %rax, %rsi
callq 0x2dfe7
incl %r12d
testb $0x20, (%r15)
je 0x5eb51
leaq 0x40ce0(%rip), %rsi     # 0x9f80f
movq %rbx, %rdi
callq 0x2ddc1
callq 0x232a3
subq 0x90(%r15), %rax
movq %rbx, %rdi
movq %rax, %rsi
callq 0x2dfe7
incl %r12d
leaq 0x40521(%rip), %rsi     # 0x9f079
movq %rbx, %rdi
callq 0x2ddc1
movq 0x98(%r15), %rsi
movq %rbx, %rdi
callq 0x2dfe7
testb $0x3, (%r15)
je 0x5ebfc
leaq 0x40c9b(%rip), %rsi     # 0x9f81b
movq %rbx, %rdi
callq 0x2ddc1
callq 0x232a3
subq 0xa0(%r15), %rax
movq %rbx, %rdi
movq %rax, %rsi
callq 0x2dfe7
leaq 0x40c82(%rip), %rsi     # 0x9f828
movq %rbx, %rdi
callq 0x2ddc1
cmpl $0x1, 0xa8(%r15)
leaq 0x3e24a(%rip), %rax     # 0x9ce07
leaq 0x3e276(%rip), %rsi     # 0x9ce3a
cmoveq %rax, %rsi
movq %rbx, %rdi
callq 0x2ddc1
leaq 0x40c5f(%rip), %rsi     # 0x9f836
movq %rbx, %rdi
callq 0x2ddc1
callq 0x232a3
subq 0xb0(%r15), %rax
movq %rbx, %rdi
movq %rax, %rsi
callq 0x2dfe7
addl $0x4, %r12d
jmp 0x5ebff
incl %r12d
testb $0x1, (%r15)
je 0x5ed27
leaq 0x3e297(%rip), %rsi     # 0x9cea7
movq %rbx, %rdi
callq 0x2ddc1
movq 0x18(%r15), %rsi
movq %rbx, %rdi
callq 0x2dfe7
leaq 0x40c1e(%rip), %rsi     # 0x9f849
movq %rbx, %rdi
callq 0x2ddc1
movq 0xc8(%r15), %rax
movq 0x48(%rax), %rsi
addq 0x28(%rax), %rsi
movq %rbx, %rdi
callq 0x2dfe7
leaq 0x40c03(%rip), %rsi     # 0x9f854
movq %rbx, %rdi
callq 0x2ddc1
movq 0xc0(%r15), %rax
movq 0x48(%rax), %rsi
addq 0x28(%rax), %rsi
movq %rbx, %rdi
callq 0x2dfe7
leaq 0x40d61(%rip), %rsi     # 0x9f9d8
movq %rbx, %rdi
callq 0x2ddc1
movslq 0xd0(%r15), %rsi
movq %rbx, %rdi
callq 0x2dfe7
leaq 0x40441(%rip), %rsi     # 0x9f0d6
movq %rbx, %rdi
callq 0x2ddc1
movq 0x148(%r15), %rsi
movq %rbx, %rdi
callq 0x2dfe7
leaq 0x40434(%rip), %rsi     # 0x9f0e7
movq %rbx, %rdi
callq 0x2ddc1
movslq 0xd4(%r15), %rsi
movq %rbx, %rdi
callq 0x2dfe7
cmpq $0x0, 0x160(%r15)
je 0x5ecf8
leaq 0x4041b(%rip), %rsi     # 0x9f0f6
movq %rbx, %rdi
callq 0x2ddc1
movq 0x160(%r15), %rsi
movq %rbx, %rdi
callq 0x2ddc1
addl $0x7, %r12d
jmp 0x5ecfc
addl $0x6, %r12d
cmpq $0x0, 0x168(%r15)
je 0x5ed27
leaq 0x40437(%rip), %rsi     # 0x9f144
movq %rbx, %rdi
callq 0x2ddc1
movq 0x168(%r15), %rsi
movq %rbx, %rdi
callq 0x2ddc1
incl %r12d
testb $0x2, (%r15)
je 0x5ee0a
leaq 0x40b30(%rip), %rsi     # 0x9f868
movq %rbx, %rdi
callq 0x2ddc1
movq 0xe0(%r15), %rsi
movq %rbx, %rdi
callq 0x2dfe7
leaq 0x40b28(%rip), %rsi     # 0x9f87e
movq %rbx, %rdi
callq 0x2ddc1
cmpl $0x0, 0x10c(%r15)
leaq 0x42e6e(%rip), %rax     # 0xa1bdb
leaq 0x36ba9(%rip), %rsi     # 0x9591d
cmoveq %rax, %rsi
movq %rbx, %rdi
callq 0x2ddc1
leaq 0x40b0a(%rip), %rsi     # 0x9f891
movq %rbx, %rdi
callq 0x2ddc1
movq 0x100(%r15), %rax
testq %rax, %rax
leaq 0x42f22(%rip), %rsi     # 0xa1cc2
cmovneq %rax, %rsi
movq %rbx, %rdi
callq 0x2ddc1
leaq 0x40aea(%rip), %rsi     # 0x9f89d
movq %rbx, %rdi
callq 0x2ddc1
movslq 0x108(%r15), %rsi
movq %rbx, %rdi
callq 0x2dfe7
leaq 0x3b1b3(%rip), %rsi     # 0x99f84
movq %rbx, %rdi
callq 0x2ddc1
movslq 0xe8(%r15), %rsi
movq %rbx, %rdi
callq 0x2dfe7
leaq 0x40aba(%rip), %rsi     # 0x9f8a9
movq %rbx, %rdi
callq 0x2ddc1
movq 0x110(%r15), %rsi
movq %rbx, %rdi
callq 0x2dfe7
addl $0x6, %r12d
testb $0x4, (%r15)
je 0x5ee81
leaq 0x40aa4(%rip), %rsi     # 0x9f8bb
movq %rbx, %rdi
callq 0x2ddc1
callq 0x232a3
subq 0x78(%r15), %rax
movq %rbx, %rdi
movq %rax, %rsi
callq 0x2dfe7
leaq 0x40a94(%rip), %rsi     # 0x9f8ce
movq %rbx, %rdi
callq 0x2ddc1
movq 0x118(%r15), %rax
testq %rax, %rax
leaq 0x42e6f(%rip), %rsi     # 0xa1cc2
cmovneq %rax, %rsi
movq %rbx, %rdi
callq 0x2ddc1
leaq 0x40a75(%rip), %rsi     # 0x9f8db
movq %rbx, %rdi
callq 0x2ddc1
movq 0x120(%r15), %rsi
movq %rbx, %rdi
callq 0x2dfe7
addl $0x3, %r12d
addl %r12d, %r12d
movq %rbx, %rdi
movq %r14, %rsi
movq %r12, %rdx
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0x2dc46