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

    /* sentinel unique ID. */
    line = sdscatprintf(sdsempty(), "sentinel myid %s", sentinel.myid);
    rewriteConfigRewriteLine(state,"sentinel",line,1);

    /* 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, slave_addr->ip, slave_addr->port);
            rewriteConfigRewriteLine(state,"sentinel",line,1);
        }
        dictReleaseIterator(di2);

        /* sentinel known-sentinel */
        di2 = dictGetIterator(master->sentinels);
        while((de = dictNext(di2)) != NULL) {
            ri = dictGetVal(de);
            if (ri->runid == NULL) continue;
            line = sdscatprintf(sdsempty(),
                "sentinel known-sentinel %s %s %d %s",
                master->name, ri->addr->ip, ri->addr->port, 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);

    /* sentinel announce-ip. */
    if (sentinel.announce_ip) {
        line = sdsnew("sentinel announce-ip ");
        line = sdscatrepr(line, sentinel.announce_ip, sdslen(sentinel.announce_ip));
        rewriteConfigRewriteLine(state,"sentinel",line,1);
    }

    /* sentinel announce-port. */
    if (sentinel.announce_port) {
        line = sdscatprintf(sdsempty(),"sentinel announce-port %d",
                            sentinel.announce_port);
        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, %rbx
callq 0x3114c
leaq 0x510e5(%rip), %rsi     # 0xbd3bc
leaq 0xa23fa(%rip), %rdx     # 0x10e6d8
movq %rax, %rdi
xorl %eax, %eax
callq 0x31a38
leaq 0x51523(%rip), %rbp     # 0xbd812
pushq $0x1
popq %r13
movq %rbx, %rdi
movq %rbp, %rsi
movq %rax, %rdx
movl %r13d, %ecx
callq 0x524ce
movq 0xa2405(%rip), %rdi     # 0x10e710
callq 0x2a99f
movq %rax, 0x8(%rsp)
movq 0x8(%rsp), %rdi
callq 0x2a9d3
testq %rax, %rax
je 0x6c630
movq 0x8(%rax), %r14
movq %r14, %rdi
callq 0x6bcc0
movl %r13d, %r12d
movq %rax, %r13
callq 0x3114c
movq 0x8(%r14), %rdx
movq (%r13), %rcx
movq %r13, 0x10(%rsp)
movl 0x8(%r13), %r8d
movl 0x90(%r14), %r9d
movq %rax, %rdi
leaq 0x5106c(%rip), %rsi     # 0xbd3cd
xorl %eax, %eax
callq 0x31a38
movq %rbx, %rdi
movq %rbp, %rsi
movq %rax, %rdx
movl %r12d, %r13d
movl %r12d, %ecx
callq 0x524ce
cmpq $0x7530, 0x58(%r14)     # imm = 0x7530
je 0x6c3b5
callq 0x3114c
movq 0x8(%r14), %rdx
movq 0x58(%r14), %rcx
movq %rax, %rdi
leaq 0x5104d(%rip), %rsi     # 0xbd3ea
xorl %eax, %eax
callq 0x31a38
movq %rbx, %rdi
movq %rbp, %rsi
movq %rax, %rdx
movl %r13d, %ecx
callq 0x524ce
cmpq $0x2bf20, 0x108(%r14) # imm = 0x2BF20
je 0x6c3f4
callq 0x3114c
movq 0x8(%r14), %rdx
movq 0x108(%r14), %rcx
movq %rax, %rdi
leaq 0x51036(%rip), %rsi     # 0xbd412
xorl %eax, %eax
callq 0x31a38
movq %rbx, %rdi
movq %rbp, %rsi
movq %rax, %rdx
movl %r13d, %ecx
callq 0x524ce
cmpl $0x1, 0x94(%r14)
je 0x6c430
callq 0x3114c
movq 0x8(%r14), %rdx
movl 0x94(%r14), %ecx
movq %rax, %rdi
leaq 0x5101b(%rip), %rsi     # 0xbd433
xorl %eax, %eax
callq 0x31a38
movq %rbx, %rdi
movq %rbp, %rsi
movq %rax, %rdx
movl %r13d, %ecx
callq 0x524ce
cmpq $0x0, 0x120(%r14)
je 0x6c46c
callq 0x3114c
movq 0x8(%r14), %rdx
movq 0x120(%r14), %rcx
movq %rax, %rdi
leaq 0x50ffd(%rip), %rsi     # 0xbd451
xorl %eax, %eax
callq 0x31a38
movq %rbx, %rdi
movq %rbp, %rsi
movq %rax, %rdx
movl %r13d, %ecx
callq 0x524ce
cmpq $0x0, 0x128(%r14)
je 0x6c4a8
callq 0x3114c
movq 0x8(%r14), %rdx
movq 0x128(%r14), %rcx
movq %rax, %rdi
leaq 0x50fe4(%rip), %rsi     # 0xbd474
xorl %eax, %eax
callq 0x31a38
movq %rbx, %rdi
movq %rbp, %rsi
movq %rax, %rdx
movl %r13d, %ecx
callq 0x524ce
cmpq $0x0, 0x98(%r14)
movq %rbp, %r15
movl %r13d, %r12d
je 0x6c4ea
callq 0x3114c
movq 0x8(%r14), %rdx
movq 0x98(%r14), %rcx
movq %rax, %rdi
leaq 0x50fc8(%rip), %rsi     # 0xbd49a
xorl %eax, %eax
callq 0x31a38
movq %rbx, %rdi
movq %r15, %rsi
movq %rax, %rdx
movl %r12d, %ecx
callq 0x524ce
callq 0x3114c
movq 0x8(%r14), %rdx
movq 0x18(%r14), %rcx
movq %rax, %rdi
leaq 0x50fb2(%rip), %rsi     # 0xbd4b3
xorl %eax, %eax
callq 0x31a38
movq %rbx, %rdi
movq %r15, %rsi
movq %rax, %rdx
movl %r12d, %ecx
callq 0x524ce
callq 0x3114c
movq 0x8(%r14), %rdx
movq 0xe0(%r14), %rcx
movq %rax, %rdi
leaq 0x50f9e(%rip), %rsi     # 0xbd4d1
xorl %eax, %eax
callq 0x31a38
movq %rbx, %rdi
movq %r15, %rsi
movq %rax, %rdx
movl %r12d, %ecx
callq 0x524ce
movq 0x88(%r14), %rdi
callq 0x2a99f
movq %rax, %r12
movq %r12, %rdi
callq 0x2a9d3
testq %rax, %rax
je 0x6c5b8
movq 0x8(%rax), %rax
movq 0x20(%rax), %r15
movq %r15, %rdi
movq 0x10(%rsp), %rsi
callq 0x6a797
testl %eax, %eax
je 0x6c584
movq 0x20(%r14), %r15
callq 0x3114c
movq 0x8(%r14), %rdx
movq (%r15), %rcx
movl 0x8(%r15), %r8d
movq %rax, %rdi
leaq 0x50f51(%rip), %rsi     # 0xbd4ef
xorl %eax, %eax
callq 0x31a38
movq %rbx, %rdi
movq %rbp, %rsi
movq %rax, %rdx
movl %r13d, %ecx
callq 0x524ce
jmp 0x6c55a
movq %r12, %rdi
callq 0x2aa94
movq 0x80(%r14), %rdi
callq 0x2a99f
movq %rax, %r12
movq %r12, %rdi
callq 0x2a9d3
testq %rax, %rax
je 0x6c623
movq 0x8(%rax), %r15
cmpq $0x0, 0x10(%r15)
je 0x6c5cf
callq 0x3114c
movq 0x8(%r14), %rdx
movq 0x10(%r15), %r9
movq 0x20(%r15), %rsi
movq (%rsi), %rcx
movl 0x8(%rsi), %r8d
movq %rax, %rdi
leaq 0x50f04(%rip), %rsi     # 0xbd50d
xorl %eax, %eax
callq 0x31a38
movq %rbx, %rdi
movq %rbp, %rsi
movq %rax, %rdx
movl %r13d, %ecx
callq 0x524ce
jmp 0x6c5cf
movq %r12, %rdi
callq 0x2aa94
jmp 0x6c315
callq 0x3114c
movq 0xa20cc(%rip), %rdx     # 0x10e708
leaq 0x50eee(%rip), %rsi     # 0xbd531
movq %rax, %rdi
xorl %eax, %eax
callq 0x31a38
leaq 0x511be(%rip), %rsi     # 0xbd812
pushq $0x1
popq %rcx
movq %rbx, %rdi
movq %rax, %rdx
callq 0x524ce
cmpq $0x0, 0xa20ce(%rip)     # 0x10e738
je 0x6c6ad
leaq 0x50eda(%rip), %rdi     # 0xbd54d
callq 0x3115a
movq %rax, %r14
movq 0xa20b6(%rip), %r15     # 0x10e738
movq %r15, %rdi
callq 0x6c6ff
movq %r14, %rdi
movq %r15, %rsi
movq %rax, %rdx
callq 0x321f1
leaq 0x51173(%rip), %rsi     # 0xbd812
pushq $0x1
popq %rcx
movq %rbx, %rdi
movq %rax, %rdx
callq 0x524ce
cmpl $0x0, 0xa208c(%rip)     # 0x10e740
je 0x6c6e7
callq 0x3114c
movl 0xa207f(%rip), %edx     # 0x10e740
leaq 0x50e9b(%rip), %rsi     # 0xbd563
movq %rax, %rdi
xorl %eax, %eax
callq 0x31a38
leaq 0x51139(%rip), %rsi     # 0xbd812
pushq $0x1
popq %rcx
movq %rbx, %rdi
movq %rax, %rdx
callq 0x524ce
movq 0x8(%rsp), %rdi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2aa94