// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/src/sentinel.c
// Function: sentinelResetMaster
void sentinelResetMaster(sentinelRedisInstance *ri, int flags) {

    redisAssert(ri->flags & SRI_MASTER);

    dictRelease(ri->slaves);
    ri->slaves = dictCreate(&instancesDictType,NULL);

    if (!(flags & SENTINEL_RESET_NO_SENTINELS)) {
        dictRelease(ri->sentinels);
        ri->sentinels = dictCreate(&instancesDictType,NULL);
    }

    if (ri->cc) sentinelKillLink(ri,ri->cc);

    if (ri->pc) sentinelKillLink(ri,ri->pc);

    // 设置标识为断线的主服务器
    ri->flags &= SRI_MASTER|SRI_DISCONNECTED;

    if (ri->leader) {
        sdsfree(ri->leader);
        ri->leader = NULL;
    }

    ri->failover_state = SENTINEL_FAILOVER_STATE_NONE;
    ri->failover_state_change_time = 0;
    ri->failover_start_time = 0;
    ri->promoted_slave = NULL;
    sdsfree(ri->runid);
    sdsfree(ri->slave_master_host);
    ri->runid = NULL;
    ri->slave_master_host = NULL;
    ri->last_ping_time = mstime();
    ri->last_avail_time = mstime();
    ri->last_pong_time = mstime();
    ri->role_reported_time = mstime();
    ri->role_reported = SRI_MASTER;
    // 发送主服务器重置事件
    if (flags & SENTINEL_GENERATE_EVENT)
        sentinelEvent(REDIS_WARNING,"+reset-master",ri,"%@");
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq -0x8(%rbp), %rax
movl (%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x7b32f
jmp 0x7b351
leaq 0x6dccb(%rip), %rdi     # 0xe9001
leaq 0x6daab(%rip), %rsi     # 0xe8de8
movl $0x662, %edx            # imm = 0x662
callq 0x63ca0
movl $0x1, %edi
callq 0x1f3b0
movq -0x8(%rbp), %rax
movq 0xc8(%rax), %rdi
callq 0x24000
leaq 0x978e8(%rip), %rdi     # 0x112c50
xorl %eax, %eax
movl %eax, %esi
callq 0x231a0
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0xc8(%rax)
movl -0xc(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
jne 0x7b3b8
movq -0x8(%rbp), %rax
movq 0xc0(%rax), %rdi
callq 0x24000
leaq 0x978af(%rip), %rdi     # 0x112c50
xorl %eax, %eax
movl %eax, %esi
callq 0x231a0
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0xc0(%rax)
movq -0x8(%rbp), %rax
cmpq $0x0, 0x28(%rax)
je 0x7b3d4
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rsi
callq 0x7aee0
movq -0x8(%rbp), %rax
cmpq $0x0, 0x30(%rax)
je 0x7b3f0
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rsi
callq 0x7aee0
movq -0x8(%rbp), %rax
movl (%rax), %ecx
andl $0x9, %ecx
movl %ecx, (%rax)
movq -0x8(%rbp), %rax
cmpq $0x0, 0x118(%rax)
je 0x7b428
movq -0x8(%rbp), %rax
movq 0x118(%rax), %rdi
callq 0x2c160
movq -0x8(%rbp), %rax
movq $0x0, 0x118(%rax)
movq -0x8(%rbp), %rax
movl $0x0, 0x130(%rax)
movq -0x8(%rbp), %rax
movq $0x0, 0x138(%rax)
movq -0x8(%rbp), %rax
movq $0x0, 0x140(%rax)
movq -0x8(%rbp), %rax
movq $0x0, 0x158(%rax)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x2c160
movq -0x8(%rbp), %rax
movq 0x100(%rax), %rdi
callq 0x2c160
movq -0x8(%rbp), %rax
movq $0x0, 0x10(%rax)
movq -0x8(%rbp), %rax
movq $0x0, 0x100(%rax)
callq 0x252e0
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x60(%rax)
callq 0x252e0
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x58(%rax)
callq 0x252e0
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x68(%rax)
callq 0x252e0
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0xb0(%rax)
movq -0x8(%rbp), %rax
movl $0x1, 0xa8(%rax)
movl -0xc(%rbp), %eax
andl $0x10000, %eax          # imm = 0x10000
cmpl $0x0, %eax
je 0x7b517
movq -0x8(%rbp), %rdx
movl $0x3, %edi
leaq 0x6db1b(%rip), %rsi     # 0xe9024
leaq 0x6db22(%rip), %rcx     # 0xe9032
movb $0x0, %al
callq 0x79b10
addq $0x10, %rsp
popq %rbp
retq
nopl (%rax)