// File: /workspace/github_c_makefile_star2_O1/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, %r13
movq 0x81809(%rip), %rdi     # 0xde8f0
callq 0x228b5
movq %rax, 0x8(%rsp)
movq %rax, %rdi
callq 0x22913
testq %rax, %rax
je 0x5d48a
leaq 0x42561(%rip), %rbx     # 0x9f66a
movq 0x8(%rax), %r15
testb $-0x80, (%r15)
je 0x5d129
movq 0x158(%r15), %rax
testq %rax, %rax
je 0x5d129
cmpl $0x4, 0x130(%r15)
jg 0x5d12c
movq %r15, %rax
movq 0x20(%rax), %rbp
callq 0x281b2
movq 0x8(%r15), %rdx
movq (%rbp), %rcx
movl 0x8(%rbp), %r8d
movl 0xd0(%r15), %r9d
movq %rax, %rdi
leaq 0x420f6(%rip), %rsi     # 0x9f248
xorl %eax, %eax
callq 0x28760
movq %r13, %rdi
movq %rbx, %rsi
movq %rax, %rdx
movl $0x1, %ecx
callq 0x47f92
cmpq $0x7530, 0x98(%r15) # imm = 0x7530
je 0x5d1ad
callq 0x281b2
movq 0x8(%r15), %rdx
movq 0x98(%r15), %rcx
movq %rax, %rdi
leaq 0x420d2(%rip), %rsi     # 0x9f265
xorl %eax, %eax
callq 0x28760
movq %r13, %rdi
movq %rbx, %rsi
movq %rax, %rdx
movl $0x1, %ecx
callq 0x47f92
cmpq $0x2bf20, 0x148(%r15) # imm = 0x2BF20
je 0x5d1ee
callq 0x281b2
movq 0x8(%r15), %rdx
movq 0x148(%r15), %rcx
movq %rax, %rdi
leaq 0x420b9(%rip), %rsi     # 0x9f28d
xorl %eax, %eax
callq 0x28760
movq %r13, %rdi
movq %rbx, %rsi
movq %rax, %rdx
movl $0x1, %ecx
callq 0x47f92
cmpl $0x1, 0xd4(%r15)
je 0x5d22c
callq 0x281b2
movq 0x8(%r15), %rdx
movl 0xd4(%r15), %ecx
movq %rax, %rdi
leaq 0x4209c(%rip), %rsi     # 0x9f2ae
xorl %eax, %eax
callq 0x28760
movq %r13, %rdi
movq %rbx, %rsi
movq %rax, %rdx
movl $0x1, %ecx
callq 0x47f92
cmpq $0x0, 0x160(%r15)
je 0x5d26a
callq 0x281b2
movq 0x8(%r15), %rdx
movq 0x160(%r15), %rcx
movq %rax, %rdi
leaq 0x4207c(%rip), %rsi     # 0x9f2cc
xorl %eax, %eax
callq 0x28760
movq %r13, %rdi
movq %rbx, %rsi
movq %rax, %rdx
movl $0x1, %ecx
callq 0x47f92
cmpq $0x0, 0x168(%r15)
je 0x5d2a8
callq 0x281b2
movq 0x8(%r15), %rdx
movq 0x168(%r15), %rcx
movq %rax, %rdi
leaq 0x42061(%rip), %rsi     # 0x9f2ef
xorl %eax, %eax
callq 0x28760
movq %r13, %rdi
movq %rbx, %rsi
movq %rax, %rdx
movl $0x1, %ecx
callq 0x47f92
cmpq $0x0, 0xd8(%r15)
je 0x5d2e6
callq 0x281b2
movq 0x8(%r15), %rdx
movq 0xd8(%r15), %rcx
movq %rax, %rdi
leaq 0x42049(%rip), %rsi     # 0x9f315
xorl %eax, %eax
callq 0x28760
movq %r13, %rdi
movq %rbx, %rsi
movq %rax, %rdx
movl $0x1, %ecx
callq 0x47f92
callq 0x281b2
movq 0x8(%r15), %rdx
movq 0x18(%r15), %rcx
movq %rax, %rdi
leaq 0x42031(%rip), %rsi     # 0x9f32e
xorl %eax, %eax
callq 0x28760
movq %r13, %rdi
movq %rbx, %rsi
movq %rax, %rdx
movl $0x1, %ecx
callq 0x47f92
callq 0x281b2
movq 0x8(%r15), %rdx
movq 0x120(%r15), %rcx
movq %rax, %rdi
leaq 0x4201b(%rip), %rsi     # 0x9f34c
xorl %eax, %eax
callq 0x28760
movq %r13, %rdi
movq %rbx, %rsi
movq %rax, %rdx
movl $0x1, %ecx
callq 0x47f92
movq 0xc8(%r15), %rdi
callq 0x228b5
movq %rax, %r14
movq %rax, %rdi
callq 0x22913
testq %rax, %rax
movq %r15, %rbp
leaq 0x41ffb(%rip), %r15     # 0x9f36a
je 0x5d3bc
movq %r13, %r12
movq 0x8(%rax), %r13
callq 0x281b2
movq 0x8(%rbp), %rdx
movq 0x20(%r13), %rsi
movq %r12, %r13
movq (%rsi), %rcx
movl 0x8(%rsi), %r8d
movq %rax, %rdi
movq %r15, %rsi
xorl %eax, %eax
callq 0x28760
movq %r12, %rdi
movq %rbx, %rsi
movq %rax, %rdx
movl $0x1, %ecx
callq 0x47f92
movq %r14, %rdi
callq 0x22913
testq %rax, %rax
jne 0x5d371
movq %r14, %rdi
callq 0x229b9
movq 0xc0(%rbp), %rdi
callq 0x228b5
movq %rax, %r15
movq %rax, %rdi
callq 0x22913
testq %rax, %rax
leaq 0x39efc(%rip), %r12     # 0x972e1
leaq 0x41f9c(%rip), %r14     # 0x9f388
movq %rbp, 0x10(%rsp)
je 0x5d46f
movq %r15, %rbp
movq %r14, %r15
movq %rbx, %r14
movq %r13, %rbx
movq 0x8(%rax), %r13
callq 0x281b2
movq 0x10(%rsp), %rcx
movq 0x8(%rcx), %rdx
movq 0x10(%r13), %rsi
movq 0x20(%r13), %rdi
movq %rbx, %r13
movq %r14, %rbx
movq %r15, %r14
movq %rbp, %r15
movq (%rdi), %rcx
movl 0x8(%rdi), %r8d
testq %rsi, %rsi
leaq 0x3cf91(%rip), %r9      # 0x9a3c7
cmoveq %r12, %r9
cmoveq %r12, %rsi
movq %rsi, (%rsp)
movq %rax, %rdi
movq %r14, %rsi
xorl %eax, %eax
callq 0x28760
movq %r13, %rdi
movq %rbx, %rsi
movq %rax, %rdx
movl $0x1, %ecx
callq 0x47f92
movq %rbp, %rdi
callq 0x22913
testq %rax, %rax
jne 0x5d3f3
movq %r15, %rdi
callq 0x229b9
movq 0x8(%rsp), %rdi
callq 0x22913
testq %rax, %rax
jne 0x5d109
callq 0x281b2
movq 0x81452(%rip), %rdx     # 0xde8e8
leaq 0x41f10(%rip), %rsi     # 0x9f3ad
movq %rax, %rdi
xorl %eax, %eax
callq 0x28760
leaq 0x421bc(%rip), %rsi     # 0x9f66a
movq %r13, %rdi
movq %rax, %rdx
movl $0x1, %ecx
callq 0x47f92
movq 0x8(%rsp), %rdi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x229b9