// File: /workspace/github_c_makefile_star2_O3/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 0x81e15(%rip), %rdi     # 0xde8f0
callq 0x22a71
movq %rax, 0x8(%rsp)
movq %rax, %rdi
callq 0x22acf
testq %rax, %rax
je 0x5ce7e
leaq 0x42bdd(%rip), %rbx     # 0x9f6da
movq 0x8(%rax), %r15
testb $-0x80, (%r15)
je 0x5cb1d
movq 0x158(%r15), %rax
testq %rax, %rax
je 0x5cb1d
cmpl $0x4, 0x130(%r15)
jg 0x5cb20
movq %r15, %rax
movq 0x20(%rax), %rbp
callq 0x2845e
movq 0x8(%r15), %rdx
movq (%rbp), %rcx
movl 0x8(%rbp), %r8d
movl 0xd0(%r15), %r9d
movq %rax, %rdi
leaq 0x42772(%rip), %rsi     # 0x9f2b8
xorl %eax, %eax
callq 0x28a5e
movq %r13, %rdi
movq %rbx, %rsi
movq %rax, %rdx
movl $0x1, %ecx
callq 0x47a6a
cmpq $0x7530, 0x98(%r15) # imm = 0x7530
je 0x5cba1
callq 0x2845e
movq 0x8(%r15), %rdx
movq 0x98(%r15), %rcx
movq %rax, %rdi
leaq 0x4274e(%rip), %rsi     # 0x9f2d5
xorl %eax, %eax
callq 0x28a5e
movq %r13, %rdi
movq %rbx, %rsi
movq %rax, %rdx
movl $0x1, %ecx
callq 0x47a6a
cmpq $0x2bf20, 0x148(%r15) # imm = 0x2BF20
je 0x5cbe2
callq 0x2845e
movq 0x8(%r15), %rdx
movq 0x148(%r15), %rcx
movq %rax, %rdi
leaq 0x42735(%rip), %rsi     # 0x9f2fd
xorl %eax, %eax
callq 0x28a5e
movq %r13, %rdi
movq %rbx, %rsi
movq %rax, %rdx
movl $0x1, %ecx
callq 0x47a6a
cmpl $0x1, 0xd4(%r15)
je 0x5cc20
callq 0x2845e
movq 0x8(%r15), %rdx
movl 0xd4(%r15), %ecx
movq %rax, %rdi
leaq 0x42718(%rip), %rsi     # 0x9f31e
xorl %eax, %eax
callq 0x28a5e
movq %r13, %rdi
movq %rbx, %rsi
movq %rax, %rdx
movl $0x1, %ecx
callq 0x47a6a
cmpq $0x0, 0x160(%r15)
je 0x5cc5e
callq 0x2845e
movq 0x8(%r15), %rdx
movq 0x160(%r15), %rcx
movq %rax, %rdi
leaq 0x426f8(%rip), %rsi     # 0x9f33c
xorl %eax, %eax
callq 0x28a5e
movq %r13, %rdi
movq %rbx, %rsi
movq %rax, %rdx
movl $0x1, %ecx
callq 0x47a6a
cmpq $0x0, 0x168(%r15)
je 0x5cc9c
callq 0x2845e
movq 0x8(%r15), %rdx
movq 0x168(%r15), %rcx
movq %rax, %rdi
leaq 0x426dd(%rip), %rsi     # 0x9f35f
xorl %eax, %eax
callq 0x28a5e
movq %r13, %rdi
movq %rbx, %rsi
movq %rax, %rdx
movl $0x1, %ecx
callq 0x47a6a
cmpq $0x0, 0xd8(%r15)
je 0x5ccda
callq 0x2845e
movq 0x8(%r15), %rdx
movq 0xd8(%r15), %rcx
movq %rax, %rdi
leaq 0x426c5(%rip), %rsi     # 0x9f385
xorl %eax, %eax
callq 0x28a5e
movq %r13, %rdi
movq %rbx, %rsi
movq %rax, %rdx
movl $0x1, %ecx
callq 0x47a6a
callq 0x2845e
movq 0x8(%r15), %rdx
movq 0x18(%r15), %rcx
movq %rax, %rdi
leaq 0x426ad(%rip), %rsi     # 0x9f39e
xorl %eax, %eax
callq 0x28a5e
movq %r13, %rdi
movq %rbx, %rsi
movq %rax, %rdx
movl $0x1, %ecx
callq 0x47a6a
callq 0x2845e
movq 0x8(%r15), %rdx
movq 0x120(%r15), %rcx
movq %rax, %rdi
leaq 0x42697(%rip), %rsi     # 0x9f3bc
xorl %eax, %eax
callq 0x28a5e
movq %r13, %rdi
movq %rbx, %rsi
movq %rax, %rdx
movl $0x1, %ecx
callq 0x47a6a
movq 0xc8(%r15), %rdi
callq 0x22a71
movq %rax, %r14
movq %rax, %rdi
callq 0x22acf
testq %rax, %rax
movq %r15, %rbp
leaq 0x42677(%rip), %r15     # 0x9f3da
je 0x5cdb0
movq %r13, %r12
movq 0x8(%rax), %r13
callq 0x2845e
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 0x28a5e
movq %r12, %rdi
movq %rbx, %rsi
movq %rax, %rdx
movl $0x1, %ecx
callq 0x47a6a
movq %r14, %rdi
callq 0x22acf
testq %rax, %rax
jne 0x5cd65
movq %r14, %rdi
callq 0x22b86
movq 0xc0(%rbp), %rdi
callq 0x22a71
movq %rax, %r15
movq %rax, %rdi
callq 0x22acf
testq %rax, %rax
leaq 0x3a568(%rip), %r12     # 0x97341
leaq 0x42618(%rip), %r14     # 0x9f3f8
movq %rbp, 0x10(%rsp)
je 0x5ce63
movq %r15, %rbp
movq %r14, %r15
movq %rbx, %r14
movq %r13, %rbx
movq 0x8(%rax), %r13
callq 0x2845e
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 0x3d5e5(%rip), %r9      # 0x9a40f
cmoveq %r12, %r9
cmoveq %r12, %rsi
movq %rsi, (%rsp)
movq %rax, %rdi
movq %r14, %rsi
xorl %eax, %eax
callq 0x28a5e
movq %r13, %rdi
movq %rbx, %rsi
movq %rax, %rdx
movl $0x1, %ecx
callq 0x47a6a
movq %rbp, %rdi
callq 0x22acf
testq %rax, %rax
jne 0x5cde7
movq %r15, %rdi
callq 0x22b86
movq 0x8(%rsp), %rdi
callq 0x22acf
testq %rax, %rax
jne 0x5cafd
callq 0x2845e
movq 0x81a5e(%rip), %rdx     # 0xde8e8
leaq 0x4258c(%rip), %rsi     # 0x9f41d
movq %rax, %rdi
xorl %eax, %eax
callq 0x28a5e
leaq 0x42838(%rip), %rsi     # 0x9f6da
movq %r13, %rdi
movq %rax, %rdx
movl $0x1, %ecx
callq 0x47a6a
movq 0x8(%rsp), %rdi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x22b86