// File: /workspace/github_c_makefile_star2_O2/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 0x562ec
movq 0x38(%r13), %rax
movq 0x8(%rax), %rax
movq 0x8(%rax), %r15
jmp 0x562f3
leaq 0x35228(%rip), %r15     # 0x8b51b
callq 0x271bf
movq %rax, %r14
leaq 0x35219(%rip), %rsi     # 0x8b51b
movq %r15, %rdi
callq 0x1f2e0
cmpl $0x3, 0x30(%r13)
jl 0x56324
leaq 0x714e8(%rip), %rax     # 0xc7800
movq 0x80(%rax), %rsi
jmp 0x564e4
movl %eax, %ebp
testl %eax, %eax
sete %r12b
leaq 0x3ec24(%rip), %rsi     # 0x94f57
movq %r15, %rdi
callq 0x1f2e0
testl %eax, %eax
sete %bl
orb %r12b, %bl
cmpb $0x1, %bl
jne 0x56371
leaq 0x3ec08(%rip), %rdi     # 0x94f57
callq 0x25a0f
movq %rax, %r12
movslq -0x8(%rax), %rdx
movq %r14, %rdi
movq %rax, %rsi
callq 0x2736d
movq %rax, %r14
movq %r12, %rdi
callq 0x271f7
testl %ebp, %ebp
sete %bpl
leaq 0x3f2d0(%rip), %rsi     # 0x9564e
movq %r15, %rdi
callq 0x1f2e0
testl %eax, %eax
sete %al
orb %bpl, %al
cmpb $0x1, %al
jne 0x564aa
testb %bl, %bl
movq %r13, (%rsp)
je 0x563b0
leaq 0x3932e(%rip), %rsi     # 0x8f6d3
movq %r14, %rdi
callq 0x273bf
movq %rax, %r14
movq 0x85539(%rip), %rax     # 0xdb8f0
movq 0x48(%rax), %rdx
addq 0x28(%rax), %rdx
movl 0x85533(%rip), %ecx     # 0xdb8f8
movl 0x85530(%rip), %r8d     # 0xdb8fc
movq 0x8553d(%rip), %rax     # 0xdb910
movq 0x28(%rax), %r9
leaq 0x3f69c(%rip), %rsi     # 0x95a7a
movq %r14, %rdi
xorl %eax, %eax
callq 0x2763d
movq %rax, %r14
movq 0x854fe(%rip), %rdi     # 0xdb8f0
callq 0x21ef6
movq %rax, %r15
leaq 0x3f6ee(%rip), %r12     # 0x95aef
xorl %r13d, %r13d
movq %r15, %rdi
callq 0x21f2f
testq %rax, %rax
je 0x5649e
movq 0x8(%rax), %rax
movl (%rax), %ecx
testb $0x10, %cl
leaq 0x3f822(%rip), %r8      # 0x95c47
leaq 0x417cf(%rip), %rdx     # 0x97bfb
cmoveq %rdx, %r8
testb $0x20, %cl
leaq 0x3f81b(%rip), %rcx     # 0x95c55
cmovneq %rcx, %r8
leal 0x1(%r13), %ebx
movq 0x8(%rax), %rcx
movq 0x20(%rax), %rdx
movq (%rdx), %r9
movl 0x8(%rdx), %r10d
movq 0xc8(%rax), %rdx
movq 0x48(%rdx), %r11
addq 0x28(%rdx), %r11
movq 0xc0(%rax), %rax
movq 0x28(%rax), %rdx
movq 0x48(%rax), %rax
leaq (%rdx,%rax), %rbp
incq %rbp
subq $0x8, %rsp
movq %r14, %rdi
movq %r12, %rsi
movl %r13d, %edx
xorl %eax, %eax
pushq %rbp
pushq %r11
pushq %r10
callq 0x2763d
addq $0x20, %rsp
movq %rax, %r14
movl %ebx, %r13d
jmp 0x56404
movq %r15, %rdi
callq 0x21fe6
movq (%rsp), %r13
callq 0x271bf
movslq -0x8(%r14), %rdx
leaq 0x35a85(%rip), %rsi     # 0x8bf3f
movq %rax, %rdi
xorl %eax, %eax
callq 0x2763d
movq %r13, %rdi
movq %rax, %rsi
callq 0x2c20f
movq %r13, %rdi
movq %r14, %rsi
callq 0x2c20f
leaq 0x7131f(%rip), %rax     # 0xc7800
movq (%rax), %rsi
movq %r13, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2c10d