// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/src/sentinel.c
// Function: sentinelHandleConfiguration
char *sentinelHandleConfiguration(char **argv, int argc) {
    sentinelRedisInstance *ri;

    // SENTINEL monitor 选项
    if (!strcasecmp(argv[0],"monitor") && argc == 5) {
        /* monitor <name> <host> <port> <quorum> */

        // 读入 quorum 参数
        int quorum = atoi(argv[4]);

        // 检查 quorum 参数必须大于 0
        if (quorum <= 0) return "Quorum must be 1 or greater.";

        // 创建主服务器实例
        if (createSentinelRedisInstance(argv[1],SRI_MASTER,argv[2],
                                        atoi(argv[3]),quorum,NULL) == NULL)
        {
            switch(errno) {
            case EBUSY: return "Duplicated master name.";
            case ENOENT: return "Can't resolve master instance hostname.";
            case EINVAL: return "Invalid port number";
            }
        }

    // SENTINEL down-after-milliseconds 选项
    } else if (!strcasecmp(argv[0],"down-after-milliseconds") && argc == 3) {

        /* down-after-milliseconds <name> <milliseconds> */

        // 查找主服务器
        ri = sentinelGetMasterByName(argv[1]);
        if (!ri) return "No such master with specified name.";

        // 设置选项
        ri->down_after_period = atoi(argv[2]);
        if (ri->down_after_period <= 0)
            return "negative or zero time parameter.";

        sentinelPropagateDownAfterPeriod(ri);

    // SENTINEL failover-timeout 选项
    } else if (!strcasecmp(argv[0],"failover-timeout") && argc == 3) {

        /* failover-timeout <name> <milliseconds> */

        // 查找主服务器
        ri = sentinelGetMasterByName(argv[1]);
        if (!ri) return "No such master with specified name.";

        // 设置选项
        ri->failover_timeout = atoi(argv[2]);
        if (ri->failover_timeout <= 0)
            return "negative or zero time parameter.";

   // Sentinel parallel-syncs 选项
   } else if (!strcasecmp(argv[0],"parallel-syncs") && argc == 3) {

        /* parallel-syncs <name> <milliseconds> */

        // 查找主服务器
        ri = sentinelGetMasterByName(argv[1]);
        if (!ri) return "No such master with specified name.";

        // 设置选项
        ri->parallel_syncs = atoi(argv[2]);

    // SENTINEL notification-script 选项
   } else if (!strcasecmp(argv[0],"notification-script") && argc == 3) {

        /* notification-script <name> <path> */
        
        // 查找主服务器
        ri = sentinelGetMasterByName(argv[1]);
        if (!ri) return "No such master with specified name.";

        // 检查给定路径所指向的文件是否存在，以及是否可执行
        if (access(argv[2],X_OK) == -1)
            return "Notification script seems non existing or non executable.";

        // 设置选项
        ri->notification_script = sdsnew(argv[2]);

    // SENTINEL client-reconfig-script 选项
   } else if (!strcasecmp(argv[0],"client-reconfig-script") && argc == 3) {

        /* client-reconfig-script <name> <path> */

        // 查找主服务器
        ri = sentinelGetMasterByName(argv[1]);
        if (!ri) return "No such master with specified name.";
        // 检查给定路径所指向的文件是否存在，以及是否可执行
        if (access(argv[2],X_OK) == -1)
            return "Client reconfiguration script seems non existing or "
                   "non executable.";

        // 设置选项
        ri->client_reconfig_script = sdsnew(argv[2]);

    // 设置 SENTINEL auth-pass 选项
   } else if (!strcasecmp(argv[0],"auth-pass") && argc == 3) {

        /* auth-pass <name> <password> */

        // 查找主服务器
        ri = sentinelGetMasterByName(argv[1]);
        if (!ri) return "No such master with specified name.";

        // 设置选项
        ri->auth_pass = sdsnew(argv[2]);

    } else if (!strcasecmp(argv[0],"current-epoch") && argc == 2) {
        /* current-epoch <epoch> */
        unsigned long long current_epoch = strtoull(argv[1],NULL,10);
        if (current_epoch > sentinel.current_epoch)
            sentinel.current_epoch = current_epoch;

    // SENTINEL config-epoch 选项
    } else if (!strcasecmp(argv[0],"config-epoch") && argc == 3) {

        /* config-epoch <name> <epoch> */

        ri = sentinelGetMasterByName(argv[1]);
        if (!ri) return "No such master with specified name.";

        ri->config_epoch = strtoull(argv[2],NULL,10);
        /* The following update of current_epoch is not really useful as
         * now the current epoch is persisted on the config file, but
         * we leave this check here for redundancy. */
        if (ri->config_epoch > sentinel.current_epoch)
            sentinel.current_epoch = ri->config_epoch;

    } else if (!strcasecmp(argv[0],"leader-epoch") && argc == 3) {
        /* leader-epoch <name> <epoch> */
        ri = sentinelGetMasterByName(argv[1]);
        if (!ri) return "No such master with specified name.";
        ri->leader_epoch = strtoull(argv[2],NULL,10);

    // SENTINEL known-slave 选项
    } else if (!strcasecmp(argv[0],"known-slave") && argc == 4) {
        sentinelRedisInstance *slave;

        /* known-slave <name> <ip> <port> */

        ri = sentinelGetMasterByName(argv[1]);
        if (!ri) return "No such master with specified name.";
        if ((slave = createSentinelRedisInstance(NULL,SRI_SLAVE,argv[2],
                    atoi(argv[3]), ri->quorum, ri)) == NULL)
        {
            return "Wrong hostname or port for slave.";
        }

    // SENTINEL known-sentinel 选项
    } else if (!strcasecmp(argv[0],"known-sentinel") &&
               (argc == 4 || argc == 5)) {
        sentinelRedisInstance *si;

        /* known-sentinel <name> <ip> <port> [runid] */

        ri = sentinelGetMasterByName(argv[1]);
        if (!ri) return "No such master with specified name.";
        if ((si = createSentinelRedisInstance(NULL,SRI_SENTINEL,argv[2],
                    atoi(argv[3]), ri->quorum, ri)) == NULL)
        {
            return "Wrong hostname or port for sentinel.";
        }
        if (argc == 5) si->runid = sdsnew(argv[4]);

    } else {
        return "Unrecognized sentinel configuration statement.";
    }
    return NULL;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rdi
leaq 0x6d40a(%rip), %rsi     # 0xe8e97
callq 0x1f2f0
cmpl $0x0, %eax
jne 0x7bb6f
cmpl $0x5, -0x14(%rbp)
jne 0x7bb6f
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rdi
callq 0x1f700
movl %eax, -0x24(%rbp)
cmpl $0x0, -0x24(%rbp)
jg 0x7bacb
leaq 0x6d57a(%rip), %rax     # 0xe903c
movq %rax, -0x8(%rbp)
jmp 0x7c14f
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x50(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x48(%rbp)
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdi
callq 0x1f700
movq -0x50(%rbp), %rdi
movq -0x48(%rbp), %rdx
movl %eax, %ecx
movl -0x24(%rbp), %r8d
movl $0x1, %esi
xorl %eax, %eax
movl %eax, %r9d
callq 0x7a9e0
cmpq $0x0, %rax
jne 0x7bb6a
callq 0x1f820
movl (%rax), %eax
movl %eax, -0x54(%rbp)
subl $0x2, %eax
je 0x7bb48
jmp 0x7bb24
movl -0x54(%rbp), %eax
subl $0x10, %eax
je 0x7bb38
jmp 0x7bb2e
movl -0x54(%rbp), %eax
subl $0x16, %eax
je 0x7bb58
jmp 0x7bb68
leaq 0x6d51a(%rip), %rax     # 0xe9059
movq %rax, -0x8(%rbp)
jmp 0x7c14f
leaq 0x6d522(%rip), %rax     # 0xe9071
movq %rax, -0x8(%rbp)
jmp 0x7c14f
leaq 0x6d53a(%rip), %rax     # 0xe9099
movq %rax, -0x8(%rbp)
jmp 0x7c14f
jmp 0x7bb6a
jmp 0x7c147
movq -0x10(%rbp), %rax
movq (%rax), %rdi
leaq 0x6d530(%rip), %rsi     # 0xe90ad
callq 0x1f2f0
cmpl $0x0, %eax
jne 0x7bbfc
cmpl $0x3, -0x14(%rbp)
jne 0x7bbfc
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x7b210
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0x7bbb5
leaq 0x6d519(%rip), %rax     # 0xe90c5
movq %rax, -0x8(%rbp)
jmp 0x7c14f
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x1f700
movslq %eax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x98(%rax)
movq -0x20(%rbp), %rax
cmpq $0x0, 0x98(%rax)
jg 0x7bbee
leaq 0x6d504(%rip), %rax     # 0xe90e9
movq %rax, -0x8(%rbp)
jmp 0x7c14f
movq -0x20(%rbp), %rdi
callq 0x7b9c0
jmp 0x7c145
movq -0x10(%rbp), %rax
movq (%rax), %rdi
leaq 0x6d500(%rip), %rsi     # 0xe910a
callq 0x1f2f0
cmpl $0x0, %eax
jne 0x7bc80
cmpl $0x3, -0x14(%rbp)
jne 0x7bc80
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x7b210
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0x7bc42
leaq 0x6d48c(%rip), %rax     # 0xe90c5
movq %rax, -0x8(%rbp)
jmp 0x7c14f
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x1f700
movslq %eax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x148(%rax)
movq -0x20(%rbp), %rax
cmpq $0x0, 0x148(%rax)
jg 0x7bc7b
leaq 0x6d477(%rip), %rax     # 0xe90e9
movq %rax, -0x8(%rbp)
jmp 0x7c14f
jmp 0x7c143
movq -0x10(%rbp), %rax
movq (%rax), %rdi
leaq 0x6d48d(%rip), %rsi     # 0xe911b
callq 0x1f2f0
cmpl $0x0, %eax
jne 0x7bce4
cmpl $0x3, -0x14(%rbp)
jne 0x7bce4
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x7b210
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0x7bcc6
leaq 0x6d408(%rip), %rax     # 0xe90c5
movq %rax, -0x8(%rbp)
jmp 0x7c14f
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x1f700
movl %eax, %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0xd4(%rax)
jmp 0x7c141
movq -0x10(%rbp), %rax
movq (%rax), %rdi
leaq 0x6d438(%rip), %rsi     # 0xe912a
callq 0x1f2f0
cmpl $0x0, %eax
jne 0x7bd71
cmpl $0x3, -0x14(%rbp)
jne 0x7bd71
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x7b210
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0x7bd2a
leaq 0x6d3a4(%rip), %rax     # 0xe90c5
movq %rax, -0x8(%rbp)
jmp 0x7c14f
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
movl $0x1, %esi
callq 0x1fa30
cmpl $-0x1, %eax
jne 0x7bd51
leaq 0x6d3f6(%rip), %rax     # 0xe913e
movq %rax, -0x8(%rbp)
jmp 0x7c14f
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x2c0e0
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x160(%rax)
jmp 0x7c13f
movq -0x10(%rbp), %rax
movq (%rax), %rdi
leaq 0x6d3f9(%rip), %rsi     # 0xe9178
callq 0x1f2f0
cmpl $0x0, %eax
jne 0x7bdfe
cmpl $0x3, -0x14(%rbp)
jne 0x7bdfe
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x7b210
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0x7bdb7
leaq 0x6d317(%rip), %rax     # 0xe90c5
movq %rax, -0x8(%rbp)
jmp 0x7c14f
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
movl $0x1, %esi
callq 0x1fa30
cmpl $-0x1, %eax
jne 0x7bdde
leaq 0x6d3ba(%rip), %rax     # 0xe918f
movq %rax, -0x8(%rbp)
jmp 0x7c14f
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x2c0e0
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x168(%rax)
jmp 0x7c13d
movq -0x10(%rbp), %rax
movq (%rax), %rdi
leaq 0x6d3c7(%rip), %rsi     # 0xe91d3
callq 0x1f2f0
cmpl $0x0, %eax
jne 0x7be64
cmpl $0x3, -0x14(%rbp)
jne 0x7be64
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x7b210
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0x7be44
leaq 0x6d28a(%rip), %rax     # 0xe90c5
movq %rax, -0x8(%rbp)
jmp 0x7c14f
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x2c0e0
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0xd8(%rax)
jmp 0x7c13b
movq -0x10(%rbp), %rax
movq (%rax), %rdi
leaq 0x6d36b(%rip), %rsi     # 0xe91dd
callq 0x1f2f0
cmpl $0x0, %eax
jne 0x7beb9
cmpl $0x2, -0x14(%rbp)
jne 0x7beb9
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
xorl %eax, %eax
movl %eax, %esi
movl $0xa, %edx
callq 0x1fa10
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
cmpq 0xac391(%rip), %rax     # 0x128238
jbe 0x7beb4
movq -0x30(%rbp), %rax
movq %rax, 0xac384(%rip)     # 0x128238
jmp 0x7c139
movq -0x10(%rbp), %rax
movq (%rax), %rdi
leaq 0x6b008(%rip), %rsi     # 0xe6ecf
callq 0x1f2f0
cmpl $0x0, %eax
jne 0x7bf45
cmpl $0x3, -0x14(%rbp)
jne 0x7bf45
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x7b210
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0x7beff
leaq 0x6d1cf(%rip), %rax     # 0xe90c5
movq %rax, -0x8(%rbp)
jmp 0x7c14f
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
xorl %eax, %eax
movl %eax, %esi
movl $0xa, %edx
callq 0x1fa10
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x20(%rbp), %rax
movq 0x18(%rax), %rax
cmpq 0xac309(%rip), %rax     # 0x128238
jbe 0x7bf40
movq -0x20(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, 0xac2f8(%rip)     # 0x128238
jmp 0x7c137
movq -0x10(%rbp), %rax
movq (%rax), %rdi
leaq 0x6d9c2(%rip), %rsi     # 0xe9915
callq 0x1f2f0
cmpl $0x0, %eax
jne 0x7bfb4
cmpl $0x3, -0x14(%rbp)
jne 0x7bfb4
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x7b210
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0x7bf8b
leaq 0x6d143(%rip), %rax     # 0xe90c5
movq %rax, -0x8(%rbp)
jmp 0x7c14f
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
xorl %eax, %eax
movl %eax, %esi
movl $0xa, %edx
callq 0x1fa10
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x120(%rax)
jmp 0x7c135
movq -0x10(%rbp), %rax
movq (%rax), %rdi
leaq 0x6d229(%rip), %rsi     # 0xe91eb
callq 0x1f2f0
cmpl $0x0, %eax
jne 0x7c05d
cmpl $0x4, -0x14(%rbp)
jne 0x7c05d
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x7b210
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0x7c002
leaq 0x6d0cc(%rip), %rax     # 0xe90c5
movq %rax, -0x8(%rbp)
jmp 0x7c14f
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x60(%rbp)
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdi
callq 0x1f700
movq -0x60(%rbp), %rdx
movl %eax, %ecx
movq -0x20(%rbp), %rax
movl 0xd0(%rax), %r8d
movq -0x20(%rbp), %r9
xorl %eax, %eax
movl %eax, %edi
movl $0x2, %esi
callq 0x7a9e0
movq %rax, -0x38(%rbp)
cmpq $0x0, %rax
jne 0x7c058
leaq 0x6d1a8(%rip), %rax     # 0xe91f7
movq %rax, -0x8(%rbp)
jmp 0x7c14f
jmp 0x7c133
movq -0x10(%rbp), %rax
movq (%rax), %rdi
leaq 0x6d1ae(%rip), %rsi     # 0xe9219
callq 0x1f2f0
cmpl $0x0, %eax
jne 0x7c124
cmpl $0x4, -0x14(%rbp)
je 0x7c089
cmpl $0x5, -0x14(%rbp)
jne 0x7c124
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x7b210
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0x7c0b1
leaq 0x6d01d(%rip), %rax     # 0xe90c5
movq %rax, -0x8(%rbp)
jmp 0x7c14f
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x68(%rbp)
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdi
callq 0x1f700
movq -0x68(%rbp), %rdx
movl %eax, %ecx
movq -0x20(%rbp), %rax
movl 0xd0(%rax), %r8d
movq -0x20(%rbp), %r9
xorl %eax, %eax
movl %eax, %edi
movl $0x4, %esi
callq 0x7a9e0
movq %rax, -0x40(%rbp)
cmpq $0x0, %rax
jne 0x7c104
leaq 0x6d12a(%rip), %rax     # 0xe9228
movq %rax, -0x8(%rbp)
jmp 0x7c14f
cmpl $0x5, -0x14(%rbp)
jne 0x7c122
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rdi
callq 0x2c0e0
movq %rax, %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x10(%rax)
jmp 0x7c131
leaq 0x6d122(%rip), %rax     # 0xe924d
movq %rax, -0x8(%rbp)
jmp 0x7c14f
jmp 0x7c133
jmp 0x7c135
jmp 0x7c137
jmp 0x7c139
jmp 0x7c13b
jmp 0x7c13d
jmp 0x7c13f
jmp 0x7c141
jmp 0x7c143
jmp 0x7c145
jmp 0x7c147
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x70, %rsp
popq %rbp
retq
nopl (%rax)