// File: /workspace/github_c_makefile_star2_O2/gplessis[P]dotdeb-redis/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 %r12
pushq %rbx
movl %esi, %ebp
movq %rdi, %rbx
movq (%rdi), %r14
leaq 0x511b0(%rip), %rsi     # 0xbcf48
movq %r14, %rdi
callq 0x262f0
cmpl $0x5, %ebp
jne 0x6be1a
testl %eax, %eax
jne 0x6be1a
movq 0x20(%rbx), %rdi
callq 0x26760
testl %eax, %eax
jle 0x6beba
movl %eax, %ebp
movq 0x8(%rbx), %r14
movq 0x10(%rbx), %r15
movq 0x18(%rbx), %rdi
callq 0x26760
pushq $0x1
popq %rsi
movq %r14, %rdi
movq %r15, %rdx
movl %eax, %ecx
movl %ebp, %r8d
xorl %r9d, %r9d
callq 0x6b555
testq %rax, %rax
jne 0x6c2a6
callq 0x26880
movl (%rax), %eax
cmpl $0x16, %eax
je 0x6bfc2
cmpl $0x10, %eax
je 0x6bfb6
cmpl $0x2, %eax
jne 0x6c2a6
leaq 0x51376(%rip), %rax     # 0xbd18b
jmp 0x6c2a8
leaq 0x513a6(%rip), %rsi     # 0xbd1c7
movq %r14, %rdi
callq 0x262f0
cmpl $0x3, %ebp
jne 0x6be67
testl %eax, %eax
jne 0x6be67
movq 0x8(%rbx), %rdi
callq 0x6b8b4
testq %rax, %rax
je 0x6c23e
movq %rax, %r14
movq 0x10(%rbx), %rdi
callq 0x26760
cltq
movq %rax, 0x58(%r14)
testl %eax, %eax
jle 0x6beae
movq %r14, %rdi
callq 0x6bce2
jmp 0x6c2a6
leaq 0x513b6(%rip), %rsi     # 0xbd224
movq %r14, %rdi
callq 0x262f0
cmpl $0x3, %ebp
jne 0x6bec6
testl %eax, %eax
jne 0x6bec6
movq 0x8(%rbx), %rdi
callq 0x6b8b4
testq %rax, %rax
je 0x6c23e
movq %rax, %r14
movq 0x10(%rbx), %rdi
callq 0x26760
cltq
movq %rax, 0x108(%r14)
testl %eax, %eax
jg 0x6c2a6
leaq 0x5134e(%rip), %rax     # 0xbd203
jmp 0x6c2a8
leaq 0x51295(%rip), %rax     # 0xbd156
jmp 0x6c2a8
leaq 0x51368(%rip), %rsi     # 0xbd235
movq %r14, %rdi
callq 0x262f0
cmpl $0x3, %ebp
jne 0x6bf08
testl %eax, %eax
jne 0x6bf08
movq 0x8(%rbx), %rdi
callq 0x6b8b4
testq %rax, %rax
je 0x6c23e
movq %rax, %r14
movq 0x10(%rbx), %rdi
callq 0x26760
movl %eax, 0x94(%r14)
jmp 0x6c2a6
leaq 0x51335(%rip), %rsi     # 0xbd244
movq %r14, %rdi
callq 0x262f0
cmpl $0x3, %ebp
jne 0x6bf5f
testl %eax, %eax
jne 0x6bf5f
movq 0x8(%rbx), %rdi
callq 0x6b8b4
testq %rax, %rax
je 0x6c23e
movq %rax, %r14
movq 0x10(%rbx), %rdi
pushq $0x1
popq %rsi
callq 0x26aa0
cmpl $-0x1, %eax
je 0x6c04f
movq 0x10(%rbx), %rdi
callq 0x3115a
movq %rax, 0x120(%r14)
jmp 0x6c2a6
leaq 0x5132c(%rip), %rsi     # 0xbd292
movq %r14, %rdi
callq 0x262f0
cmpl $0x3, %ebp
jne 0x6bfce
testl %eax, %eax
jne 0x6bfce
movq 0x8(%rbx), %rdi
callq 0x6b8b4
testq %rax, %rax
je 0x6c23e
movq %rax, %r14
movq 0x10(%rbx), %rdi
pushq $0x1
popq %rsi
callq 0x26aa0
cmpl $-0x1, %eax
je 0x6c0ae
movq 0x10(%rbx), %rdi
callq 0x3115a
movq %rax, 0x128(%r14)
jmp 0x6c2a6
leaq 0x511b6(%rip), %rax     # 0xbd173
jmp 0x6c2a8
leaq 0x511ea(%rip), %rax     # 0xbd1b3
jmp 0x6c2a8
leaq 0x51318(%rip), %rsi     # 0xbd2ed
movq %r14, %rdi
callq 0x262f0
cmpl $0x3, %ebp
jne 0x6c010
testl %eax, %eax
jne 0x6c010
movq 0x8(%rbx), %rdi
callq 0x6b8b4
testq %rax, %rax
je 0x6c23e
movq %rax, %r14
movq 0x10(%rbx), %rdi
callq 0x3115a
movq %rax, 0x98(%r14)
jmp 0x6c2a6
leaq 0x512e0(%rip), %rsi     # 0xbd2f7
movq %r14, %rdi
callq 0x262f0
cmpl $0x2, %ebp
jne 0x6c05b
testl %eax, %eax
jne 0x6c05b
movq 0x8(%rbx), %rdi
pushq $0xa
popq %rdx
xorl %esi, %esi
callq 0x26a70
cmpq 0xa26cb(%rip), %rax     # 0x10e708
jbe 0x6c2a6
movq %rax, 0xa26be(%rip)     # 0x10e708
jmp 0x6c2a6
leaq 0x51202(%rip), %rax     # 0xbd258
jmp 0x6c2a8
leaq 0x4d736(%rip), %rsi     # 0xb9798
movq %r14, %rdi
callq 0x262f0
cmpl $0x2, %ebp
jne 0x6c0ba
testl %eax, %eax
jne 0x6c0ba
movq 0x8(%rbx), %rbx
movq %rbx, %rdi
callq 0x26500
cmpq $0x28, %rax
jne 0x6c145
movq 0x20(%rbx), %rax
movq %rax, 0xa2664(%rip)     # 0x10e6f8
movups (%rbx), %xmm0
movups 0x10(%rbx), %xmm1
movups %xmm1, 0xa2646(%rip)    # 0x10e6e8
movups %xmm0, 0xa262f(%rip)    # 0x10e6d8
jmp 0x6c2a6
leaq 0x511f4(%rip), %rax     # 0xbd2a9
jmp 0x6c2a8
leaq 0x4dd02(%rip), %rsi     # 0xb9dc3
movq %r14, %rdi
callq 0x262f0
cmpl $0x3, %ebp
jne 0x6c0fe
testl %eax, %eax
jne 0x6c0fe
movq 0x8(%rbx), %rdi
callq 0x6b8b4
testq %rax, %rax
je 0x6c23e
movq %rax, %r14
movq 0x10(%rbx), %rdi
pushq $0xa
popq %rdx
xorl %esi, %esi
callq 0x26a70
movq %rax, 0x18(%r14)
jmp 0x6c036
leaq 0x51999(%rip), %rsi     # 0xbda9e
movq %r14, %rdi
callq 0x262f0
cmpl $0x3, %ebp
jne 0x6c151
testl %eax, %eax
jne 0x6c151
movq 0x8(%rbx), %rdi
callq 0x6b8b4
testq %rax, %rax
je 0x6c23e
movq %rax, %r14
movq 0x10(%rbx), %rdi
pushq $0xa
popq %rdx
xorl %esi, %esi
callq 0x26a70
movq %rax, 0xe0(%r14)
jmp 0x6c2a6
leaq 0x511b9(%rip), %rax     # 0xbd305
jmp 0x6c2a8
leaq 0x511d3(%rip), %rsi     # 0xbd32b
movq %r14, %rdi
callq 0x262f0
cmpl $0x4, %ebp
jne 0x6c1b9
testl %eax, %eax
jne 0x6c1b9
movq 0x8(%rbx), %rdi
callq 0x6b8b4
testq %rax, %rax
je 0x6c23e
movq %rax, %r14
movq 0x10(%rbx), %r15
movq 0x18(%rbx), %rdi
callq 0x26760
movl 0x90(%r14), %r8d
pushq $0x2
popq %rsi
xorl %edi, %edi
movq %r15, %rdx
movl %eax, %ecx
movq %r14, %r9
callq 0x6b555
testq %rax, %rax
jne 0x6c2a6
leaq 0x51183(%rip), %rax     # 0xbd337
jmp 0x6c2a8
leaq 0x51199(%rip), %rsi     # 0xbd359
movq %r14, %rdi
callq 0x262f0
movl %ebp, %ecx
andl $-0x2, %ecx
cmpl $0x4, %ecx
jne 0x6c247
testl %eax, %eax
jne 0x6c247
cmpl $0x5, %ebp
jne 0x6c2a6
movq 0x8(%rbx), %rdi
callq 0x6b8b4
testq %rax, %rax
je 0x6c23e
movq %rax, %r14
movq 0x20(%rbx), %r15
movq 0x10(%rbx), %r12
movq 0x18(%rbx), %rdi
callq 0x26760
movl 0x90(%r14), %r8d
pushq $0x4
popq %rsi
movq %r15, %rdi
movq %r12, %rdx
movl %eax, %ecx
movq %r14, %r9
callq 0x6b555
testq %rax, %rax
je 0x6c2b1
movq %rax, %r14
movq 0x20(%rbx), %rdi
callq 0x3115a
movq %rax, 0x10(%r14)
movq %r14, %rdi
callq 0x6b2bb
jmp 0x6c2a6
leaq 0x50f9a(%rip), %rax     # 0xbd1df
jmp 0x6c2a8
leaq 0x4994d(%rip), %rsi     # 0xb5b9b
movq %r14, %rdi
callq 0x262f0
cmpl $0x2, %ebp
jne 0x6c276
testl %eax, %eax
jne 0x6c276
movq 0x8(%rbx), %rdi
cmpb $0x0, (%rdi)
je 0x6c2a6
callq 0x3115a
movq %rax, 0xa24c4(%rip)     # 0x10e738
jmp 0x6c2a6
leaq 0x49930(%rip), %rsi     # 0xb5bad
movq %r14, %rdi
callq 0x262f0
movl %eax, %ecx
leaq 0x510ff(%rip), %rax     # 0xbd38d
cmpl $0x2, %ebp
jne 0x6c2a8
testl %ecx, %ecx
jne 0x6c2a8
movq 0x8(%rbx), %rdi
callq 0x26760
movl %eax, 0xa249a(%rip)     # 0x10e740
xorl %eax, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0x510b0(%rip), %rax     # 0xbd368
jmp 0x6c2a8