// File: /workspace/github_c_makefile_star2_O3/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
pushq %rax
movq %rdi, %rbx
callq 0x3628d
leaq 0x53fc3(%rip), %rsi     # 0xcc770
leaq 0x9df24(%rip), %rdx     # 0x1166d8
movq %rax, %rdi
xorl %eax, %eax
callq 0x36f2d
leaq 0x54401(%rip), %rsi     # 0xccbc6
movq %rbx, %rdi
movq %rax, %rdx
movl $0x1, %ecx
callq 0x5b894
movq 0x9df34(%rip), %rdi     # 0x116710
callq 0x2efbb
movq %rax, (%rsp)
movq %rax, %rdi
callq 0x2f015
testq %rax, %rax
je 0x78b49
leaq 0x543c9(%rip), %r12     # 0xccbc6
movq 0x8(%rax), %r14
testb $0x40, (%r14)
je 0x7881d
movq 0x118(%r14), %rax
testq %rax, %rax
je 0x7881d
cmpl $0x4, 0xf0(%r14)
jg 0x78820
movq %r14, %rax
movq 0x20(%rax), %r15
callq 0x3628d
movq 0x8(%r14), %rdx
movq (%r15), %rcx
movl 0x8(%r15), %r8d
movl 0x90(%r14), %r9d
movq %rax, %rdi
leaq 0x53f3c(%rip), %rsi     # 0xcc781
xorl %eax, %eax
callq 0x36f2d
movq %rbx, %rdi
movq %r12, %rsi
movq %rax, %rdx
movl $0x1, %ecx
callq 0x5b894
cmpq $0x7530, 0x58(%r14)     # imm = 0x7530
je 0x7889a
callq 0x3628d
movq 0x8(%r14), %rdx
movq 0x58(%r14), %rcx
movq %rax, %rdi
leaq 0x53f1e(%rip), %rsi     # 0xcc79e
xorl %eax, %eax
callq 0x36f2d
movq %rbx, %rdi
movq %r12, %rsi
movq %rax, %rdx
movl $0x1, %ecx
callq 0x5b894
cmpq $0x2bf20, 0x108(%r14) # imm = 0x2BF20
je 0x788db
callq 0x3628d
movq 0x8(%r14), %rdx
movq 0x108(%r14), %rcx
movq %rax, %rdi
leaq 0x53f05(%rip), %rsi     # 0xcc7c6
xorl %eax, %eax
callq 0x36f2d
movq %rbx, %rdi
movq %r12, %rsi
movq %rax, %rdx
movl $0x1, %ecx
callq 0x5b894
cmpl $0x1, 0x94(%r14)
je 0x78919
callq 0x3628d
movq 0x8(%r14), %rdx
movl 0x94(%r14), %ecx
movq %rax, %rdi
leaq 0x53ee8(%rip), %rsi     # 0xcc7e7
xorl %eax, %eax
callq 0x36f2d
movq %rbx, %rdi
movq %r12, %rsi
movq %rax, %rdx
movl $0x1, %ecx
callq 0x5b894
cmpq $0x0, 0x120(%r14)
je 0x78957
callq 0x3628d
movq 0x8(%r14), %rdx
movq 0x120(%r14), %rcx
movq %rax, %rdi
leaq 0x53ec8(%rip), %rsi     # 0xcc805
xorl %eax, %eax
callq 0x36f2d
movq %rbx, %rdi
movq %r12, %rsi
movq %rax, %rdx
movl $0x1, %ecx
callq 0x5b894
cmpq $0x0, 0x128(%r14)
je 0x78995
callq 0x3628d
movq 0x8(%r14), %rdx
movq 0x128(%r14), %rcx
movq %rax, %rdi
leaq 0x53ead(%rip), %rsi     # 0xcc828
xorl %eax, %eax
callq 0x36f2d
movq %rbx, %rdi
movq %r12, %rsi
movq %rax, %rdx
movl $0x1, %ecx
callq 0x5b894
cmpq $0x0, 0x98(%r14)
je 0x789d3
callq 0x3628d
movq 0x8(%r14), %rdx
movq 0x98(%r14), %rcx
movq %rax, %rdi
leaq 0x53e95(%rip), %rsi     # 0xcc84e
xorl %eax, %eax
callq 0x36f2d
movq %rbx, %rdi
movq %r12, %rsi
movq %rax, %rdx
movl $0x1, %ecx
callq 0x5b894
callq 0x3628d
movq 0x8(%r14), %rdx
movq 0x18(%r14), %rcx
movq %rax, %rdi
leaq 0x53e7d(%rip), %rsi     # 0xcc867
xorl %eax, %eax
callq 0x36f2d
movq %rbx, %rdi
movq %r12, %rsi
movq %rax, %rdx
movl $0x1, %ecx
callq 0x5b894
callq 0x3628d
movq 0x8(%r14), %rdx
movq 0xe0(%r14), %rcx
movq %rax, %rdi
leaq 0x53e67(%rip), %rsi     # 0xcc885
xorl %eax, %eax
callq 0x36f2d
movq %rbx, %rdi
movq %r12, %rsi
movq %rax, %rdx
movl $0x1, %ecx
callq 0x5b894
movq 0x88(%r14), %rdi
callq 0x2efbb
movq %rax, %rbp
movq %rax, %rdi
callq 0x2f015
testq %rax, %rax
je 0x78ab4
movq 0x8(%rax), %rax
movq 0x20(%rax), %r13
movl 0x8(%r13), %eax
cmpl 0x8(%r15), %eax
jne 0x78a7a
movq (%r13), %rdi
movq (%r15), %rsi
callq 0x262f0
testl %eax, %eax
jne 0x78a7a
movq 0x20(%r14), %r13
callq 0x3628d
movq 0x8(%r14), %rdx
movq (%r13), %rcx
movl 0x8(%r13), %r8d
movq %rax, %rdi
leaq 0x53e0e(%rip), %rsi     # 0xcc8a3
xorl %eax, %eax
callq 0x36f2d
movq %rbx, %rdi
movq %r12, %rsi
movq %rax, %rdx
movl $0x1, %ecx
callq 0x5b894
movq %rbp, %rdi
jmp 0x78a4a
movq %rbp, %rdi
callq 0x2f0dd
movq 0x80(%r14), %rdi
callq 0x2efbb
movq %rax, %rbp
movq %rax, %rdi
callq 0x2f015
testq %rax, %rax
leaq 0x53de4(%rip), %r13     # 0xcc8c1
je 0x78b2f
movq 0x8(%rax), %r15
cmpq $0x0, 0x10(%r15)
je 0x78b22
callq 0x3628d
movq 0x8(%r14), %rdx
movq 0x10(%r15), %r9
movq 0x20(%r15), %rsi
movq (%rsi), %rcx
movl 0x8(%rsi), %r8d
movq %rax, %rdi
movq %r13, %rsi
xorl %eax, %eax
callq 0x36f2d
movq %rbx, %rdi
movq %r12, %rsi
movq %rax, %rdx
movl $0x1, %ecx
callq 0x5b894
movq %rbp, %rdi
callq 0x2f015
testq %rax, %rax
jne 0x78adf
movq %rbp, %rdi
callq 0x2f0dd
movq (%rsp), %rdi
callq 0x2f015
testq %rax, %rax
jne 0x787fd
callq 0x3628d
movq 0x9dbb3(%rip), %rdx     # 0x116708
leaq 0x53d89(%rip), %rsi     # 0xcc8e5
movq %rax, %rdi
xorl %eax, %eax
callq 0x36f2d
leaq 0x54059(%rip), %rsi     # 0xccbc6
movq %rbx, %rdi
movq %rax, %rdx
movl $0x1, %ecx
callq 0x5b894
cmpq $0x0, 0x9dbb3(%rip)     # 0x116738
je 0x78bf5
leaq 0x53d73(%rip), %rdi     # 0xcc901
callq 0x362b0
movq 0x9db9e(%rip), %rsi     # 0x116738
movzbl -0x1(%rsi), %edx
movl %edx, %ecx
andl $0x7, %ecx
cmpl $0x4, %ecx
ja 0x78bd4
leaq 0x53551(%rip), %rdi     # 0xcc100
movslq (%rdi,%rcx,4), %rcx
addq %rdi, %rcx
jmpq *%rcx
shrl $0x3, %edx
jmp 0x78bd6
movq -0x11(%rsi), %rdx
jmp 0x78bd6
movzwl -0x5(%rsi), %edx
jmp 0x78bd6
movl -0x9(%rsi), %edx
jmp 0x78bd6
movzbl -0x3(%rsi), %edx
jmp 0x78bd6
xorl %edx, %edx
movq %rax, %rdi
callq 0x37c36
leaq 0x53fe1(%rip), %rsi     # 0xccbc6
movq %rbx, %rdi
movq %rax, %rdx
movl $0x1, %ecx
callq 0x5b894
cmpl $0x0, 0x9db44(%rip)     # 0x116740
je 0x78c31
callq 0x3628d
movl 0x9db37(%rip), %edx     # 0x116740
leaq 0x53d07(%rip), %rsi     # 0xcc917
movq %rax, %rdi
xorl %eax, %eax
callq 0x36f2d
leaq 0x53fa5(%rip), %rsi     # 0xccbc6
movq %rbx, %rdi
movq %rax, %rdx
movl $0x1, %ecx
callq 0x5b894
movq (%rsp), %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2f0dd