// File: /workspace/github_c_makefile_star2_O3/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 0x5abe9
movq 0x38(%r13), %rax
movq 0x8(%rax), %rax
movq 0x8(%rax), %r15
jmp 0x5abf0
leaq 0x3a96b(%rip), %r15     # 0x9555b
callq 0x2845e
movq %rax, %r14
leaq 0x3a95c(%rip), %rsi     # 0x9555b
movq %r15, %rdi
callq 0x1f2e0
cmpl $0x3, 0x30(%r13)
jl 0x5ac21
leaq 0x6fbeb(%rip), %rax     # 0xca800
movq 0x80(%rax), %rsi
jmp 0x5adf7
movl %eax, %ebp
testl %eax, %eax
sete %bl
leaq 0x443b4(%rip), %rsi     # 0x9efe3
movq %r15, %rdi
callq 0x1f2e0
testl %eax, %eax
sete %al
orb %bl, %al
cmpb $0x1, %al
jne 0x5aca0
testl %ebp, %ebp
sete %bl
leaq 0x44395(%rip), %rdi     # 0x9efe3
callq 0x26b5d
movq %rax, %r12
movslq -0x8(%rax), %rdx
movq %r14, %rdi
movq %rax, %rsi
callq 0x28689
movq %rax, %r14
movq %r12, %rdi
callq 0x2850d
leaq 0x44a63(%rip), %rsi     # 0x9f6da
movq %r15, %rdi
callq 0x1f2e0
testl %eax, %eax
sete %al
orb %bl, %al
je 0x5adbd
leaq 0x3ea7c(%rip), %rsi     # 0x9970f
movq %r14, %rdi
callq 0x286db
movq %rax, %r14
jmp 0x5acb7
leaq 0x44a33(%rip), %rsi     # 0x9f6da
movq %r15, %rdi
callq 0x1f2e0
testl %eax, %eax
jne 0x5adbd
movq %r13, (%rsp)
movq 0x83c2e(%rip), %rax     # 0xde8f0
movq 0x48(%rax), %rdx
addq 0x28(%rax), %rdx
movl 0x83c28(%rip), %ecx     # 0xde8f8
movl 0x83c25(%rip), %r8d     # 0xde8fc
movq 0x83c32(%rip), %rax     # 0xde910
movq 0x28(%rax), %r9
leaq 0x44e1d(%rip), %rsi     # 0x9fb06
movq %r14, %rdi
xorl %eax, %eax
callq 0x28a5e
movq %rax, %r14
movq 0x83bf3(%rip), %rdi     # 0xde8f0
callq 0x22a71
movq %rax, %r15
movq %rax, %rdi
callq 0x22acf
testq %rax, %rax
je 0x5adb1
leaq 0x44fc4(%rip), %rbx     # 0x9fce1
leaq 0x44e57(%rip), %r12     # 0x9fb7b
xorl %edx, %edx
movq 0x8(%rax), %rax
movl (%rax), %ecx
testb $0x10, %cl
leaq 0x44f9d(%rip), %r8      # 0x9fcd3
leaq 0x46f2e(%rip), %rsi     # 0xa1c6b
cmoveq %rsi, %r8
testb $0x20, %cl
cmovneq %rbx, %r8
leal 0x1(%rdx), %r13d
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), %rbp
incq %rbp
subq $0x8, %rsp
movq %r14, %rdi
movq %r12, %rsi
xorl %eax, %eax
pushq %rbp
pushq %r11
pushq %r10
callq 0x28a5e
addq $0x20, %rsp
movq %rax, %r14
movq %r15, %rdi
callq 0x22acf
movl %r13d, %edx
testq %rax, %rax
jne 0x5ad26
movq %r15, %rdi
callq 0x22b86
movq (%rsp), %r13
callq 0x2845e
movslq -0x8(%r14), %rdx
leaq 0x3b1b2(%rip), %rsi     # 0x95f7f
movq %rax, %rdi
xorl %eax, %eax
callq 0x28a5e
movq %r13, %rdi
movq %rax, %rsi
callq 0x2db20
movq %r13, %rdi
movq %r14, %rsi
callq 0x2db20
leaq 0x6fa0c(%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 0x2d97c