// File: /workspace/github_c_makefile_star2_O1/zhou-yuxin[P]redis-aof-no-cow/src/sentinel.c
// Function: sentinelHandleConfiguration
char *sentinelHandleConfiguration(char **argv, int argc) {
    sentinelRedisInstance *ri;

    if (!strcasecmp(argv[0],"monitor") && argc == 5) {
        /* monitor <name> <host> <port> <quorum> */
        int quorum = atoi(argv[4]);

        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";
            }
        }
    } 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);
    } 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.";
   } 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]);
   } 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]);
   } 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]);
   } 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;
    } else if (!strcasecmp(argv[0],"myid") && argc == 2) {
        if (strlen(argv[1]) != CONFIG_RUN_ID_SIZE)
            return "Malformed Sentinel id in myid option.";
        memcpy(sentinel.myid,argv[1],CONFIG_RUN_ID_SIZE);
    } 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);
    } 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.";
        }
    } else if (!strcasecmp(argv[0],"known-sentinel") &&
               (argc == 4 || argc == 5)) {
        sentinelRedisInstance *si;

        if (argc == 5) { /* Ignore the old form without runid. */
            /* known-sentinel <name> <ip> <port> [runid] */
            ri = sentinelGetMasterByName(argv[1]);
            if (!ri) return "No such master with specified name.";
            if ((si = createSentinelRedisInstance(argv[4],SRI_SENTINEL,argv[2],
                        atoi(argv[3]), ri->quorum, ri)) == NULL)
            {
                return "Wrong hostname or port for sentinel.";
            }
            si->runid = sdsnew(argv[4]);
            sentinelTryConnectionSharing(si);
        }
    } else if (!strcasecmp(argv[0],"announce-ip") && argc == 2) {
        /* announce-ip <ip-address> */
        if (strlen(argv[1]))
            sentinel.announce_ip = sdsnew(argv[1]);
    } else if (!strcasecmp(argv[0],"announce-port") && argc == 2) {
        /* announce-port <port> */
        sentinel.announce_port = atoi(argv[1]);
    } else {
        return "Unrecognized sentinel configuration statement.";
    }
    return NULL;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %esi, %ebp
movq %rdi, %rbx
movq (%rdi), %r14
leaq 0x53495(%rip), %rsi     # 0xcf1fc
movq %r14, %rdi
callq 0x26300
cmpl $0x5, %ebp
jne 0x7bdc4
testl %eax, %eax
jne 0x7bdc4
movq 0x20(%rbx), %rdi
callq 0x26770
testl %eax, %eax
jle 0x7be5d
movl %eax, %ebp
movq 0x8(%rbx), %r14
movq 0x10(%rbx), %r15
movq 0x18(%rbx), %rdi
callq 0x26770
movq %r14, %rdi
movl $0x1, %esi
movq %r15, %rdx
movl %eax, %ecx
movl %ebp, %r8d
xorl %r9d, %r9d
callq 0x7b48e
testq %rax, %rax
je 0x7beb4
movb $0x1, %cl
jmp 0x7be66
leaq 0x536b0(%rip), %rsi     # 0xcf47b
movq %r14, %rdi
callq 0x26300
cmpl $0x3, %ebp
jne 0x7be0e
testl %eax, %eax
jne 0x7be0e
movq 0x8(%rbx), %rdi
callq 0x7b804
testq %rax, %rax
je 0x7c11e
movq %rax, %r14
movq 0x10(%rbx), %rdi
callq 0x26770
cltq
movq %rax, 0x58(%r14)
testl %eax, %eax
jle 0x7be51
movq %r14, %rdi
callq 0x7bca5
jmp 0x7be6e
leaq 0x536c3(%rip), %rsi     # 0xcf4d8
movq %r14, %rdi
callq 0x26300
cmpl $0x3, %ebp
jne 0x7be75
testl %eax, %eax
jne 0x7be75
movq 0x8(%rbx), %rdi
callq 0x7b804
testq %rax, %rax
je 0x7c11e
movq %rax, %r14
movq 0x10(%rbx), %rdi
callq 0x26770
cltq
movq %rax, 0x108(%r14)
testl %eax, %eax
jg 0x7be6e
leaq 0x5365f(%rip), %rax     # 0xcf4b7
jmp 0x7c125
leaq 0x535a6(%rip), %rax     # 0xcf40a
xorl %ecx, %ecx
testb %cl, %cl
je 0x7c125
xorl %eax, %eax
jmp 0x7c125
leaq 0x5366d(%rip), %rsi     # 0xcf4e9
movq %r14, %rdi
callq 0x26300
cmpl $0x3, %ebp
jne 0x7bedf
testl %eax, %eax
jne 0x7bedf
movq 0x8(%rbx), %rdi
callq 0x7b804
testq %rax, %rax
je 0x7c11e
movq %rax, %r14
movq 0x10(%rbx), %rdi
callq 0x26770
movl %eax, 0x94(%r14)
jmp 0x7be6e
callq 0x26890
movl (%rax), %eax
cmpl $0x16, %eax
je 0x7bf9d
cmpl $0x10, %eax
je 0x7bf91
cmpl $0x2, %eax
jne 0x7bdbd
leaq 0x53562(%rip), %rax     # 0xcf43f
jmp 0x7be64
leaq 0x53612(%rip), %rsi     # 0xcf4f8
movq %r14, %rdi
callq 0x26300
cmpl $0x3, %ebp
jne 0x7bf38
testl %eax, %eax
jne 0x7bf38
movq 0x8(%rbx), %rdi
callq 0x7b804
testq %rax, %rax
je 0x7c11e
movq %rax, %r14
movq 0x10(%rbx), %rdi
movl $0x1, %esi
callq 0x26ab0
cmpl $-0x1, %eax
je 0x7c02c
movq 0x10(%rbx), %rdi
callq 0x39245
movq %rax, 0x120(%r14)
jmp 0x7be6e
leaq 0x53607(%rip), %rsi     # 0xcf546
movq %r14, %rdi
callq 0x26300
cmpl $0x3, %ebp
jne 0x7bfa9
testl %eax, %eax
jne 0x7bfa9
movq 0x8(%rbx), %rdi
callq 0x7b804
testq %rax, %rax
je 0x7c11e
movq %rax, %r14
movq 0x10(%rbx), %rdi
movl $0x1, %esi
callq 0x26ab0
cmpl $-0x1, %eax
je 0x7c08b
movq 0x10(%rbx), %rdi
callq 0x39245
movq %rax, 0x128(%r14)
jmp 0x7be6e
leaq 0x5348f(%rip), %rax     # 0xcf427
jmp 0x7be64
leaq 0x534c3(%rip), %rax     # 0xcf467
jmp 0x7be64
leaq 0x535f1(%rip), %rsi     # 0xcf5a1
movq %r14, %rdi
callq 0x26300
cmpl $0x3, %ebp
jne 0x7bfeb
testl %eax, %eax
jne 0x7bfeb
movq 0x8(%rbx), %rdi
callq 0x7b804
testq %rax, %rax
je 0x7c11e
movq %rax, %r14
movq 0x10(%rbx), %rdi
callq 0x39245
movq %rax, 0x98(%r14)
jmp 0x7be6e
leaq 0x535b9(%rip), %rsi     # 0xcf5ab
movq %r14, %rdi
callq 0x26300
cmpl $0x2, %ebp
jne 0x7c038
testl %eax, %eax
jne 0x7c038
movq 0x8(%rbx), %rdi
xorl %esi, %esi
movl $0xa, %edx
callq 0x26a80
cmpq 0x9f68e(%rip), %rax     # 0x11b6a8
jbe 0x7be6e
movq %rax, 0x9f681(%rip)     # 0x11b6a8
jmp 0x7be6e
leaq 0x534d9(%rip), %rax     # 0xcf50c
jmp 0x7c125
leaq 0x4f6e9(%rip), %rsi     # 0xcb728
movq %r14, %rdi
callq 0x26300
cmpl $0x2, %ebp
jne 0x7c097
testl %eax, %eax
jne 0x7c097
movq 0x8(%rbx), %rbx
movq %rbx, %rdi
callq 0x26510
cmpq $0x28, %rax
jne 0x7c134
movq 0x20(%rbx), %rax
movq %rax, 0x9f627(%rip)     # 0x11b698
movups (%rbx), %xmm0
movups 0x10(%rbx), %xmm1
movups %xmm1, 0x9f609(%rip)    # 0x11b688
movups %xmm0, 0x9f5f2(%rip)    # 0x11b678
jmp 0x7be6e
leaq 0x534cb(%rip), %rax     # 0xcf55d
jmp 0x7c125
leaq 0x4fcb5(%rip), %rsi     # 0xcbd53
movq %r14, %rdi
callq 0x26300
cmpl $0x3, %ebp
jne 0x7c0d9
testl %eax, %eax
jne 0x7c0d9
movq 0x8(%rbx), %rdi
callq 0x7b804
testq %rax, %rax
je 0x7c11e
movq %rax, %r14
movq 0x10(%rbx), %rdi
xorl %esi, %esi
movl $0xa, %edx
callq 0x26a80
movq %rax, 0x18(%r14)
jmp 0x7c013
leaq 0x53c72(%rip), %rsi     # 0xcfd52
movq %r14, %rdi
callq 0x26300
cmpl $0x3, %ebp
jne 0x7c13d
testl %eax, %eax
jne 0x7c13d
movq 0x8(%rbx), %rdi
callq 0x7b804
testq %rax, %rax
je 0x7c11e
movq %rax, %r14
movq 0x10(%rbx), %rdi
xorl %esi, %esi
movl $0xa, %edx
callq 0x26a80
movq %rax, 0xe0(%r14)
jmp 0x7be6e
leaq 0x5336e(%rip), %rax     # 0xcf493
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x5347e(%rip), %rax     # 0xcf5b9
jmp 0x7c125
leaq 0x5349b(%rip), %rsi     # 0xcf5df
movq %r14, %rdi
callq 0x26300
cmpl $0x4, %ebp
jne 0x7c1a4
testl %eax, %eax
jne 0x7c1a4
movq 0x8(%rbx), %rdi
callq 0x7b804
testq %rax, %rax
je 0x7c267
movq %rax, %r14
movq 0x10(%rbx), %r15
movq 0x18(%rbx), %rdi
callq 0x26770
movl 0x90(%r14), %r8d
xorl %edi, %edi
movl $0x2, %esi
movq %r15, %rdx
movl %eax, %ecx
movq %r14, %r9
callq 0x7b48e
testq %rax, %rax
setne %cl
leaq 0x5344c(%rip), %rax     # 0xcf5eb
jmp 0x7be66
leaq 0x53462(%rip), %rsi     # 0xcf60d
movq %r14, %rdi
callq 0x26300
movl %ebp, %ecx
andl $-0x2, %ecx
cmpl $0x4, %ecx
jne 0x7c231
testl %eax, %eax
jne 0x7c231
movb $0x1, %r13b
cmpl $0x5, %ebp
jne 0x7c22c
movq 0x8(%rbx), %rdi
callq 0x7b804
testq %rax, %rax
je 0x7c2b0
movq %rax, %r14
movq 0x20(%rbx), %r15
movq 0x10(%rbx), %r12
movq 0x18(%rbx), %rdi
callq 0x26770
movl 0x90(%r14), %r8d
movq %r15, %rdi
movl $0x4, %esi
movq %r12, %rdx
movl %eax, %ecx
movq %r14, %r9
callq 0x7b48e
testq %rax, %rax
je 0x7c2b9
movq %rax, %r14
movq 0x20(%rbx), %rdi
callq 0x39245
movq %rax, 0x10(%r14)
movq %r14, %rdi
callq 0x7b12f
jmp 0x7c2c3
leaq 0x4b543(%rip), %rsi     # 0xc777b
movq %r14, %rdi
callq 0x26300
cmpl $0x2, %ebp
jne 0x7c273
testl %eax, %eax
jne 0x7c273
movq 0x8(%rbx), %rdi
cmpb $0x0, (%rdi)
je 0x7be6e
callq 0x39245
movq %rax, 0x9f476(%rip)     # 0x11b6d8
jmp 0x7be6e
leaq 0x53225(%rip), %rax     # 0xcf493
jmp 0x7be64
leaq 0x4b513(%rip), %rsi     # 0xc778d
movq %r14, %rdi
callq 0x26300
movl %eax, %ecx
leaq 0x533b6(%rip), %rax     # 0xcf641
cmpl $0x2, %ebp
jne 0x7c125
testl %ecx, %ecx
jne 0x7c125
movq 0x8(%rbx), %rdi
callq 0x26770
movl %eax, 0x9f435(%rip)     # 0x11b6e0
jmp 0x7be6e
leaq 0x531dc(%rip), %rax     # 0xcf493
jmp 0x7c2c0
leaq 0x5335c(%rip), %rax     # 0xcf61c
xorl %r13d, %r13d
testb %r13b, %r13b
jne 0x7be6e
jmp 0x7c125