// File: /workspace/github_c_makefile_star2_O1/zhou-yuxin[P]redis-aof-no-cow/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 0x39222
leaq 0x53385(%rip), %rsi     # 0xcf670
leaq 0x9f386(%rip), %rdx     # 0x11b678
movq %rax, %rdi
xorl %eax, %eax
callq 0x39eb7
leaq 0x537c3(%rip), %rsi     # 0xcfac6
movq %rbx, %rdi
movq %rax, %rdx
movl $0x1, %ecx
callq 0x5f4ab
movq 0x9f396(%rip), %rdi     # 0x11b6b0
callq 0x320bb
movq %rax, (%rsp)
movq %rax, %rdi
callq 0x32116
testq %rax, %rax
je 0x7c687
leaq 0x5378b(%rip), %r12     # 0xcfac6
movq 0x8(%rax), %r14
testb $0x40, (%r14)
je 0x7c35b
movq 0x118(%r14), %rax
testq %rax, %rax
je 0x7c35b
cmpl $0x4, 0xf0(%r14)
jg 0x7c35e
movq %r14, %rax
movq 0x20(%rax), %r15
callq 0x39222
movq 0x8(%r14), %rdx
movq (%r15), %rcx
movl 0x8(%r15), %r8d
movl 0x90(%r14), %r9d
movq %rax, %rdi
leaq 0x532fe(%rip), %rsi     # 0xcf681
xorl %eax, %eax
callq 0x39eb7
movq %rbx, %rdi
movq %r12, %rsi
movq %rax, %rdx
movl $0x1, %ecx
callq 0x5f4ab
cmpq $0x7530, 0x58(%r14)     # imm = 0x7530
je 0x7c3d8
callq 0x39222
movq 0x8(%r14), %rdx
movq 0x58(%r14), %rcx
movq %rax, %rdi
leaq 0x532e0(%rip), %rsi     # 0xcf69e
xorl %eax, %eax
callq 0x39eb7
movq %rbx, %rdi
movq %r12, %rsi
movq %rax, %rdx
movl $0x1, %ecx
callq 0x5f4ab
cmpq $0x2bf20, 0x108(%r14) # imm = 0x2BF20
je 0x7c419
callq 0x39222
movq 0x8(%r14), %rdx
movq 0x108(%r14), %rcx
movq %rax, %rdi
leaq 0x532c7(%rip), %rsi     # 0xcf6c6
xorl %eax, %eax
callq 0x39eb7
movq %rbx, %rdi
movq %r12, %rsi
movq %rax, %rdx
movl $0x1, %ecx
callq 0x5f4ab
cmpl $0x1, 0x94(%r14)
je 0x7c457
callq 0x39222
movq 0x8(%r14), %rdx
movl 0x94(%r14), %ecx
movq %rax, %rdi
leaq 0x532aa(%rip), %rsi     # 0xcf6e7
xorl %eax, %eax
callq 0x39eb7
movq %rbx, %rdi
movq %r12, %rsi
movq %rax, %rdx
movl $0x1, %ecx
callq 0x5f4ab
cmpq $0x0, 0x120(%r14)
je 0x7c495
callq 0x39222
movq 0x8(%r14), %rdx
movq 0x120(%r14), %rcx
movq %rax, %rdi
leaq 0x5328a(%rip), %rsi     # 0xcf705
xorl %eax, %eax
callq 0x39eb7
movq %rbx, %rdi
movq %r12, %rsi
movq %rax, %rdx
movl $0x1, %ecx
callq 0x5f4ab
cmpq $0x0, 0x128(%r14)
je 0x7c4d3
callq 0x39222
movq 0x8(%r14), %rdx
movq 0x128(%r14), %rcx
movq %rax, %rdi
leaq 0x5326f(%rip), %rsi     # 0xcf728
xorl %eax, %eax
callq 0x39eb7
movq %rbx, %rdi
movq %r12, %rsi
movq %rax, %rdx
movl $0x1, %ecx
callq 0x5f4ab
cmpq $0x0, 0x98(%r14)
je 0x7c511
callq 0x39222
movq 0x8(%r14), %rdx
movq 0x98(%r14), %rcx
movq %rax, %rdi
leaq 0x53257(%rip), %rsi     # 0xcf74e
xorl %eax, %eax
callq 0x39eb7
movq %rbx, %rdi
movq %r12, %rsi
movq %rax, %rdx
movl $0x1, %ecx
callq 0x5f4ab
callq 0x39222
movq 0x8(%r14), %rdx
movq 0x18(%r14), %rcx
movq %rax, %rdi
leaq 0x5323f(%rip), %rsi     # 0xcf767
xorl %eax, %eax
callq 0x39eb7
movq %rbx, %rdi
movq %r12, %rsi
movq %rax, %rdx
movl $0x1, %ecx
callq 0x5f4ab
callq 0x39222
movq 0x8(%r14), %rdx
movq 0xe0(%r14), %rcx
movq %rax, %rdi
leaq 0x53229(%rip), %rsi     # 0xcf785
xorl %eax, %eax
callq 0x39eb7
movq %rbx, %rdi
movq %r12, %rsi
movq %rax, %rdx
movl $0x1, %ecx
callq 0x5f4ab
movq 0x88(%r14), %rdi
callq 0x320bb
movq %rax, %rbp
movq %rax, %rdi
callq 0x32116
testq %rax, %rax
je 0x7c5f2
movq 0x8(%rax), %rax
movq 0x20(%rax), %r13
movl 0x8(%r13), %eax
cmpl 0x8(%r15), %eax
jne 0x7c5b8
movq (%r13), %rdi
movq (%r15), %rsi
callq 0x26300
testl %eax, %eax
jne 0x7c5b8
movq 0x20(%r14), %r13
callq 0x39222
movq 0x8(%r14), %rdx
movq (%r13), %rcx
movl 0x8(%r13), %r8d
movq %rax, %rdi
leaq 0x531d0(%rip), %rsi     # 0xcf7a3
xorl %eax, %eax
callq 0x39eb7
movq %rbx, %rdi
movq %r12, %rsi
movq %rax, %rdx
movl $0x1, %ecx
callq 0x5f4ab
movq %rbp, %rdi
jmp 0x7c588
movq %rbp, %rdi
callq 0x321d3
movq 0x80(%r14), %rdi
callq 0x320bb
movq %rax, %rbp
movq %rax, %rdi
callq 0x32116
testq %rax, %rax
leaq 0x531a6(%rip), %r13     # 0xcf7c1
je 0x7c66d
movq 0x8(%rax), %r15
cmpq $0x0, 0x10(%r15)
je 0x7c660
callq 0x39222
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 0x39eb7
movq %rbx, %rdi
movq %r12, %rsi
movq %rax, %rdx
movl $0x1, %ecx
callq 0x5f4ab
movq %rbp, %rdi
callq 0x32116
testq %rax, %rax
jne 0x7c61d
movq %rbp, %rdi
callq 0x321d3
movq (%rsp), %rdi
callq 0x32116
testq %rax, %rax
jne 0x7c33b
callq 0x39222
movq 0x9f015(%rip), %rdx     # 0x11b6a8
leaq 0x5314b(%rip), %rsi     # 0xcf7e5
movq %rax, %rdi
xorl %eax, %eax
callq 0x39eb7
leaq 0x5341b(%rip), %rsi     # 0xcfac6
movq %rbx, %rdi
movq %rax, %rdx
movl $0x1, %ecx
callq 0x5f4ab
cmpq $0x0, 0x9f015(%rip)     # 0x11b6d8
je 0x7c733
leaq 0x53135(%rip), %rdi     # 0xcf801
callq 0x39245
movq 0x9f000(%rip), %rsi     # 0x11b6d8
movzbl -0x1(%rsi), %edx
movl %edx, %ecx
andl $0x7, %ecx
cmpl $0x4, %ecx
ja 0x7c712
leaq 0x52913(%rip), %rdi     # 0xcf000
movslq (%rdi,%rcx,4), %rcx
addq %rdi, %rcx
jmpq *%rcx
shrl $0x3, %edx
jmp 0x7c714
movq -0x11(%rsi), %rdx
jmp 0x7c714
movzwl -0x5(%rsi), %edx
jmp 0x7c714
movl -0x9(%rsi), %edx
jmp 0x7c714
movzbl -0x3(%rsi), %edx
jmp 0x7c714
xorl %edx, %edx
movq %rax, %rdi
callq 0x3abb1
leaq 0x533a3(%rip), %rsi     # 0xcfac6
movq %rbx, %rdi
movq %rax, %rdx
movl $0x1, %ecx
callq 0x5f4ab
cmpl $0x0, 0x9efa6(%rip)     # 0x11b6e0
je 0x7c76f
callq 0x39222
movl 0x9ef99(%rip), %edx     # 0x11b6e0
leaq 0x530c9(%rip), %rsi     # 0xcf817
movq %rax, %rdi
xorl %eax, %eax
callq 0x39eb7
leaq 0x53367(%rip), %rsi     # 0xcfac6
movq %rbx, %rdi
movq %rax, %rdx
movl $0x1, %ecx
callq 0x5f4ab
movq (%rsp), %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x321d3