// File: /workspace/github_c_makefile_star2_O2/nilyang[P]redis-tdd-annotation/src/sentinel.c
// Function: rewriteConfigSentinelOption
void rewriteConfigSentinelOption(struct rewriteConfigState *state) {
    dictIterator *di, *di2;
    dictEntry *de;
    sds line;

    /* For every master emit a "sentinel monitor" config entry. */
    di = dictGetIterator(sentinel.masters);
    while((de = dictNext(di)) != NULL) {
        sentinelRedisInstance *master, *ri;
        sentinelAddr *master_addr;

        /* sentinel monitor */
        master = dictGetVal(de);
        master_addr = sentinelGetCurrentMasterAddress(master);
        line = sdscatprintf(sdsempty(),"sentinel monitor %s %s %d %d",
            master->name, master_addr->ip, master_addr->port,
            master->quorum);
        rewriteConfigRewriteLine(state,"sentinel",line,1);

        /* sentinel down-after-milliseconds */
        if (master->down_after_period != SENTINEL_DEFAULT_DOWN_AFTER) {
            line = sdscatprintf(sdsempty(),
                "sentinel down-after-milliseconds %s %ld",
                master->name, (long) master->down_after_period);
            rewriteConfigRewriteLine(state,"sentinel",line,1);
        }

        /* sentinel failover-timeout */
        if (master->failover_timeout != SENTINEL_DEFAULT_FAILOVER_TIMEOUT) {
            line = sdscatprintf(sdsempty(),
                "sentinel failover-timeout %s %ld",
                master->name, (long) master->failover_timeout);
            rewriteConfigRewriteLine(state,"sentinel",line,1);
        }

        /* sentinel parallel-syncs */
        if (master->parallel_syncs != SENTINEL_DEFAULT_PARALLEL_SYNCS) {
            line = sdscatprintf(sdsempty(),
                "sentinel parallel-syncs %s %d",
                master->name, master->parallel_syncs);
            rewriteConfigRewriteLine(state,"sentinel",line,1);
        }

        /* sentinel notification-script */
        if (master->notification_script) {
            line = sdscatprintf(sdsempty(),
                "sentinel notification-script %s %s",
                master->name, master->notification_script);
            rewriteConfigRewriteLine(state,"sentinel",line,1);
        }

        /* sentinel client-reconfig-script */
        if (master->client_reconfig_script) {
            line = sdscatprintf(sdsempty(),
                "sentinel client-reconfig-script %s %s",
                master->name, master->client_reconfig_script);
            rewriteConfigRewriteLine(state,"sentinel",line,1);
        }

        /* sentinel auth-pass */
        if (master->auth_pass) {
            line = sdscatprintf(sdsempty(),
                "sentinel auth-pass %s %s",
                master->name, master->auth_pass);
            rewriteConfigRewriteLine(state,"sentinel",line,1);
        }

        /* sentinel config-epoch */
        line = sdscatprintf(sdsempty(),
            "sentinel config-epoch %s %llu",
            master->name, (unsigned long long) master->config_epoch);
        rewriteConfigRewriteLine(state,"sentinel",line,1);

        /* sentinel leader-epoch */
        line = sdscatprintf(sdsempty(),
            "sentinel leader-epoch %s %llu",
            master->name, (unsigned long long) master->leader_epoch);
        rewriteConfigRewriteLine(state,"sentinel",line,1);

        /* sentinel known-slave */
        di2 = dictGetIterator(master->slaves);
        while((de = dictNext(di2)) != NULL) {
            sentinelAddr *slave_addr;

            ri = dictGetVal(de);
            slave_addr = ri->addr;

            /* If master_addr (obtained using sentinelGetCurrentMasterAddress()
             * so it may be the address of the promoted slave) is equal to this
             * slave's address, a failover is in progress and the slave was
             * already successfully promoted. So as the address of this slave
             * we use the old master address instead. */
            if (sentinelAddrIsEqual(slave_addr,master_addr))
                slave_addr = master->addr;
            line = sdscatprintf(sdsempty(),
                "sentinel known-slave %s %s %d",
                master->name, ri->addr->ip, ri->addr->port);
            rewriteConfigRewriteLine(state,"sentinel",line,1);
        }
        dictReleaseIterator(di2);

        /* sentinel known-sentinel */
        di2 = dictGetIterator(master->sentinels);
        while((de = dictNext(di2)) != NULL) {
            ri = dictGetVal(de);
            line = sdscatprintf(sdsempty(),
                "sentinel known-sentinel %s %s %d%s%s",
                master->name, ri->addr->ip, ri->addr->port,
                ri->runid ? " " : "",
                ri->runid ? ri->runid : "");
            rewriteConfigRewriteLine(state,"sentinel",line,1);
        }
        dictReleaseIterator(di2);
    }

    /* sentinel current-epoch is a global state valid for all the masters. */
    line = sdscatprintf(sdsempty(),
        "sentinel current-epoch %llu", (unsigned long long) sentinel.current_epoch);
    rewriteConfigRewriteLine(state,"sentinel",line,1);

    dictReleaseIterator(di);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %r14
movq 0x838e4(%rip), %rdi     # 0xdb8f0
callq 0x21ef6
movq %rax, 0x10(%rsp)
leaq 0x3d631(%rip), %r12     # 0x9564e
pushq $0x1
popq %rbp
movq 0x10(%rsp), %rdi
callq 0x21f2f
testq %rax, %rax
je 0x58324
movq 0x8(%rax), %rbx
movq %rbx, %rdi
callq 0x57ae9
movq %rax, %r13
callq 0x271bf
movq 0x8(%rbx), %rdx
movq (%r13), %rcx
movl 0x8(%r13), %r8d
movl 0xd0(%rbx), %r9d
movq %rax, %rdi
leaq 0x3d1c8(%rip), %rsi     # 0x9522c
xorl %eax, %eax
callq 0x2763d
movq %r14, %rdi
movq %r12, %rsi
movq %rax, %rdx
movl %ebp, %ecx
callq 0x446a9
cmpq $0x7530, 0x98(%rbx) # imm = 0x7530
je 0x580b9
callq 0x271bf
movq 0x8(%rbx), %rdx
movq 0x98(%rbx), %rcx
movq %rax, %rdi
leaq 0x3d1a7(%rip), %rsi     # 0x95249
xorl %eax, %eax
callq 0x2763d
movq %r14, %rdi
movq %r12, %rsi
movq %rax, %rdx
movl %ebp, %ecx
callq 0x446a9
cmpq $0x2bf20, 0x148(%rbx) # imm = 0x2BF20
je 0x580f7
callq 0x271bf
movq 0x8(%rbx), %rdx
movq 0x148(%rbx), %rcx
movq %rax, %rdi
leaq 0x3d191(%rip), %rsi     # 0x95271
xorl %eax, %eax
callq 0x2763d
movq %r14, %rdi
movq %r12, %rsi
movq %rax, %rdx
movl %ebp, %ecx
callq 0x446a9
cmpl $0x1, 0xd4(%rbx)
je 0x58130
callq 0x271bf
movq 0x8(%rbx), %rdx
movl 0xd4(%rbx), %ecx
movq %rax, %rdi
leaq 0x3d179(%rip), %rsi     # 0x95292
xorl %eax, %eax
callq 0x2763d
movq %r14, %rdi
movq %r12, %rsi
movq %rax, %rdx
movl %ebp, %ecx
callq 0x446a9
cmpq $0x0, 0x160(%rbx)
je 0x5816b
callq 0x271bf
movq 0x8(%rbx), %rdx
movq 0x160(%rbx), %rcx
movq %rax, %rdi
leaq 0x3d15c(%rip), %rsi     # 0x952b0
xorl %eax, %eax
callq 0x2763d
movq %r14, %rdi
movq %r12, %rsi
movq %rax, %rdx
movl %ebp, %ecx
callq 0x446a9
cmpq $0x0, 0x168(%rbx)
je 0x581a6
callq 0x271bf
movq 0x8(%rbx), %rdx
movq 0x168(%rbx), %rcx
movq %rax, %rdi
leaq 0x3d144(%rip), %rsi     # 0x952d3
xorl %eax, %eax
callq 0x2763d
movq %r14, %rdi
movq %r12, %rsi
movq %rax, %rdx
movl %ebp, %ecx
callq 0x446a9
cmpq $0x0, 0xd8(%rbx)
je 0x581e1
callq 0x271bf
movq 0x8(%rbx), %rdx
movq 0xd8(%rbx), %rcx
movq %rax, %rdi
leaq 0x3d12f(%rip), %rsi     # 0x952f9
xorl %eax, %eax
callq 0x2763d
movq %r14, %rdi
movq %r12, %rsi
movq %rax, %rdx
movl %ebp, %ecx
callq 0x446a9
callq 0x271bf
movq 0x8(%rbx), %rdx
movq 0x18(%rbx), %rcx
movq %rax, %rdi
leaq 0x3d11a(%rip), %rsi     # 0x95312
xorl %eax, %eax
callq 0x2763d
movq %r14, %rdi
movq %r12, %rsi
movq %rax, %rdx
movl %ebp, %ecx
callq 0x446a9
callq 0x271bf
movq 0x8(%rbx), %rdx
movq 0x120(%rbx), %rcx
movq %rax, %rdi
leaq 0x3d107(%rip), %rsi     # 0x95330
xorl %eax, %eax
callq 0x2763d
movq %r14, %rdi
movq %r12, %rsi
movq %rax, %rdx
movl %ebp, %ecx
callq 0x446a9
movq 0xc8(%rbx), %rdi
callq 0x21ef6
movq %rax, %r13
movq %r13, %rdi
callq 0x21f2f
testq %rax, %rax
je 0x58297
movq 0x8(%rax), %r15
callq 0x271bf
movq 0x8(%rbx), %rdx
movq 0x20(%r15), %rsi
movq (%rsi), %rcx
movl 0x8(%rsi), %r8d
movq %rax, %rdi
leaq 0x3d0d0(%rip), %rsi     # 0x9534e
xorl %eax, %eax
callq 0x2763d
movq %r14, %rdi
movq %r12, %rsi
movq %rax, %rdx
movl %ebp, %ecx
callq 0x446a9
jmp 0x5824f
movq %r13, %rdi
callq 0x21fe6
movq 0xc0(%rbx), %rdi
callq 0x21ef6
movq %rax, %r13
movq %r13, %rdi
callq 0x21f2f
testq %rax, %rax
je 0x58317
movq 0x8(%rax), %r15
callq 0x271bf
movq 0x8(%rbx), %rdx
movq 0x10(%r15), %rsi
movq 0x20(%r15), %rdi
movq (%rdi), %rcx
movl 0x8(%rdi), %r8d
testq %rsi, %rsi
leaq 0x380f2(%rip), %r9      # 0x903d3
leaq 0x35029(%rip), %rdi     # 0x8d311
cmoveq %rdi, %r9
cmoveq %rdi, %rsi
movq %rsi, (%rsp)
movq %rax, %rdi
leaq 0x3d06e(%rip), %rsi     # 0x9536c
xorl %eax, %eax
callq 0x2763d
movq %r14, %rdi
movq %r12, %rsi
movq %rax, %rdx
movl %ebp, %ecx
callq 0x446a9
jmp 0x582ae
movq %r13, %rdi
callq 0x21fe6
jmp 0x58020
callq 0x271bf
movq 0x835b8(%rip), %rdx     # 0xdb8e8
leaq 0x3d05a(%rip), %rsi     # 0x95391
movq %rax, %rdi
xorl %eax, %eax
callq 0x2763d
leaq 0x3d306(%rip), %rsi     # 0x9564e
pushq $0x1
popq %rcx
movq %r14, %rdi
movq %rax, %rdx
callq 0x446a9
movq 0x10(%rsp), %rdi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x21fe6