// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/sentinel.c
// Function: sentinelInfoCommand
void sentinelInfoCommand(redisClient *c) {
    char *section = c->argc == 2 ? c->argv[1]->ptr : "default";
    sds info = sdsempty();
    int defsections = !strcasecmp(section,"default");
    int sections = 0;

    if (c->argc > 2) {
        addReply(c,shared.syntaxerr);
        return;
    }

    if (!strcasecmp(section,"server") || defsections) {
        if (sections++) info = sdscat(info,"\r\n");
        sds serversection = genRedisInfoString("server");
        info = sdscatlen(info,serversection,sdslen(serversection));
        sdsfree(serversection);
    }

    if (!strcasecmp(section,"sentinel") || defsections) {
        dictIterator *di;
        dictEntry *de;
        int master_id = 0;

        if (sections++) info = sdscat(info,"\r\n");
        info = sdscatprintf(info,
            "# Sentinel\r\n"
            "sentinel_masters:%lu\r\n"
            "sentinel_tilt:%d\r\n"
            "sentinel_running_scripts:%d\r\n"
            "sentinel_scripts_queue_length:%ld\r\n",
            dictSize(sentinel.masters),
            sentinel.tilt,
            sentinel.running_scripts,
            listLength(sentinel.scripts_queue));

        di = dictGetIterator(sentinel.masters);
        while((de = dictNext(di)) != NULL) {
            sentinelRedisInstance *ri = dictGetVal(de);
            char *status = "ok";

            if (ri->flags & SRI_O_DOWN) status = "odown";
            else if (ri->flags & SRI_S_DOWN) status = "sdown";
            info = sdscatprintf(info,
                "master%d:name=%s,status=%s,address=%s:%d,"
                "slaves=%lu,sentinels=%lu\r\n",
                master_id++, ri->name, status,
                ri->addr->ip, ri->addr->port,
                dictSize(ri->slaves),
                dictSize(ri->sentinels)+1);
        }
        dictReleaseIterator(di);
    }

    addReplySds(c,sdscatprintf(sdsempty(),"$%lu\r\n",
        (unsigned long)sdslen(info)));
    addReplySds(c,info);
    addReply(c,shared.crlf);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %r13
cmpl $0x2, 0x30(%rdi)
jne 0x5b1be
movq 0x38(%r13), %rax
movq 0x8(%rax), %rax
movq 0x8(%rax), %r15
jmp 0x5b1c5
leaq 0x3a346(%rip), %r15     # 0x9550b
callq 0x281b2
movq %rax, %r14
leaq 0x3a337(%rip), %rsi     # 0x9550b
movq %r15, %rdi
callq 0x1f2e0
movl %eax, %ebp
leaq 0x6f61b(%rip), %rax     # 0xca800
cmpl $0x2, 0x30(%r13)
jle 0x5b1f5
subq $-0x80, %rax
jmp 0x5b3b7
testl %ebp, %ebp
sete %r12b
leaq 0x43d71(%rip), %rsi     # 0x9ef73
movq %r15, %rdi
callq 0x1f2e0
testl %eax, %eax
sete %bl
orb %r12b, %bl
cmpb $0x1, %bl
jne 0x5b240
leaq 0x43d55(%rip), %rdi     # 0x9ef73
callq 0x2690c
movq %rax, %r12
movslq -0x8(%rax), %rdx
movq %r14, %rdi
movq %rax, %rsi
callq 0x28380
movq %rax, %r14
movq %r12, %rdi
callq 0x28204
testl %ebp, %ebp
sete %bpl
leaq 0x4441d(%rip), %rsi     # 0x9f66a
movq %r15, %rdi
callq 0x1f2e0
testl %eax, %eax
sete %al
orb %bpl, %al
cmpb $0x1, %al
jne 0x5b380
testb %bl, %bl
movq %r13, (%rsp)
je 0x5b27f
leaq 0x3e453(%rip), %rsi     # 0x996c7
movq %r14, %rdi
callq 0x283d7
movq %rax, %r14
movq 0x8366a(%rip), %rax     # 0xde8f0
movq 0x48(%rax), %rdx
addq 0x28(%rax), %rdx
movl 0x83664(%rip), %ecx     # 0xde8f8
movl 0x83661(%rip), %r8d     # 0xde8fc
movq 0x8366e(%rip), %rax     # 0xde910
movq 0x28(%rax), %r9
leaq 0x447e9(%rip), %rsi     # 0x9fa96
movq %r14, %rdi
xorl %eax, %eax
callq 0x28760
movq %rax, %r14
movq 0x8362f(%rip), %rdi     # 0xde8f0
callq 0x228b5
movq %rax, %r15
movq %rax, %rdi
callq 0x22913
testq %rax, %rax
je 0x5b374
leaq 0x44990(%rip), %rbx     # 0x9fc71
leaq 0x44823(%rip), %r12     # 0x9fb0b
xorl %edx, %edx
movq 0x8(%rax), %rax
movl (%rax), %ecx
testb $0x10, %cl
leaq 0x44969(%rip), %r8      # 0x9fc63
leaq 0x468da(%rip), %rsi     # 0xa1bdb
cmoveq %rsi, %r8
testb $0x20, %cl
cmovneq %rbx, %r8
leal 0x1(%rdx), %ebp
movq 0x8(%rax), %rcx
movq 0x20(%rax), %rsi
movq (%rsi), %r9
movl 0x8(%rsi), %r10d
movq 0xc8(%rax), %rsi
movq 0x48(%rsi), %r11
addq 0x28(%rsi), %r11
movq 0xc0(%rax), %rax
movq 0x28(%rax), %rsi
movq 0x48(%rax), %rax
leaq (%rsi,%rax), %r13
incq %r13
subq $0x8, %rsp
movq %r14, %rdi
movq %r12, %rsi
xorl %eax, %eax
pushq %r13
pushq %r11
pushq %r10
callq 0x28760
addq $0x20, %rsp
movq %rax, %r14
movq %r15, %rdi
callq 0x22913
movl %ebp, %edx
testq %rax, %rax
jne 0x5b2ea
movq %r15, %rdi
callq 0x229b9
movq (%rsp), %r13
callq 0x281b2
movslq -0x8(%r14), %rdx
leaq 0x3ab9f(%rip), %rsi     # 0x95f2f
movq %rax, %rdi
xorl %eax, %eax
callq 0x28760
movq %r13, %rdi
movq %rax, %rsi
callq 0x2d894
movq %r13, %rdi
movq %r14, %rsi
callq 0x2d894
leaq 0x6f449(%rip), %rax     # 0xca800
movq (%rax), %rsi
movq %r13, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2d6f0