// File: /workspace/github_c_makefile_star2_O0/gplessis[P]dotdeb-redis/src/sentinel.c
// Function: sentinelProcessHelloMessage
void sentinelProcessHelloMessage(char *hello, int hello_len) {
    /* Format is composed of 8 tokens:
     * 0=ip,1=port,2=runid,3=current_epoch,4=master_name,
     * 5=master_ip,6=master_port,7=master_config_epoch. */
    int numtokens, port, removed, master_port;
    uint64_t current_epoch, master_config_epoch;
    char **token = sdssplitlen(hello, hello_len, ",", 1, &numtokens);
    sentinelRedisInstance *si, *master;

    if (numtokens == 8) {
        /* Obtain a reference to the master this hello message is about */
        master = sentinelGetMasterByName(token[4]);
        if (!master) goto cleanup; /* Unknown master, skip the message. */

        /* First, try to see if we already have this sentinel. */
        port = atoi(token[1]);
        master_port = atoi(token[6]);
        si = getSentinelRedisInstanceByAddrAndRunID(
                        master->sentinels,token[0],port,token[2]);
        current_epoch = strtoull(token[3],NULL,10);
        master_config_epoch = strtoull(token[7],NULL,10);

        if (!si) {
            /* If not, remove all the sentinels that have the same runid
             * because there was an address change, and add the same Sentinel
             * with the new address back. */
            removed = removeMatchingSentinelFromMaster(master,token[2]);
            if (removed) {
                sentinelEvent(LL_NOTICE,"+sentinel-address-switch",master,
                    "%@ ip %s port %d for %s", token[0],port,token[2]);
            } else {
                /* Check if there is another Sentinel with the same address this
                 * new one is reporting. What we do if this happens is to set its
                 * port to 0, to signal the address is invalid. We'll update it
                 * later if we get an HELLO message. */
                sentinelRedisInstance *other =
                    getSentinelRedisInstanceByAddrAndRunID(
                        master->sentinels, token[0],port,NULL);
                if (other) {
                    sentinelEvent(LL_NOTICE,"+sentinel-invalid-addr",other,"%@");
                    other->addr->port = 0; /* It means: invalid address. */
                    sentinelUpdateSentinelAddressInAllMasters(other);
                }
            }

            /* Add the new sentinel. */
            si = createSentinelRedisInstance(token[2],SRI_SENTINEL,
                            token[0],port,master->quorum,master);

            if (si) {
                if (!removed) sentinelEvent(LL_NOTICE,"+sentinel",si,"%@");
                /* The runid is NULL after a new instance creation and
                 * for Sentinels we don't have a later chance to fill it,
                 * so do it now. */
                si->runid = sdsnew(token[2]);
                sentinelTryConnectionSharing(si);
                if (removed) sentinelUpdateSentinelAddressInAllMasters(si);
                sentinelFlushConfig();
            }
        }

        /* Update local current_epoch if received current_epoch is greater.*/
        if (current_epoch > sentinel.current_epoch) {
            sentinel.current_epoch = current_epoch;
            sentinelFlushConfig();
            sentinelEvent(LL_WARNING,"+new-epoch",master,"%llu",
                (unsigned long long) sentinel.current_epoch);
        }

        /* Update master info if received configuration is newer. */
        if (si && master->config_epoch < master_config_epoch) {
            master->config_epoch = master_config_epoch;
            if (master_port != master->addr->port ||
                strcmp(master->addr->ip, token[5]))
            {
                sentinelAddr *old_addr;

                sentinelEvent(LL_WARNING,"+config-update-from",si,"%@");
                sentinelEvent(LL_WARNING,"+switch-master",
                    master,"%s %s %d %s %d",
                    master->name,
                    master->addr->ip, master->addr->port,
                    token[5], master_port);

                old_addr = dupSentinelAddr(master->addr);
                sentinelResetMasterAndChangeAddress(master, token[5], master_port);
                sentinelCallClientReconfScript(master,
                    SENTINEL_OBSERVER,"start",
                    old_addr,master->addr);
                releaseSentinelAddr(old_addr);
            }
        }

        /* Update the state of the Sentinel. */
        if (si) si->last_hello_time = mstime();
    }

cleanup:
    sdsfreesplitres(token,numtokens);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
leaq 0xaa04d(%rip), %rdx     # 0x14346a
movl $0x1, %ecx
leaq -0x10(%rbp), %r8
callq 0x3a040
movq %rax, -0x38(%rbp)
cmpl $0x8, -0x10(%rbp)
jne 0x99797
movq -0x38(%rbp), %rax
movq 0x20(%rax), %rdi
callq 0x96540
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
jne 0x99456
jmp 0x99799
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x26760
movl %eax, -0x14(%rbp)
movq -0x38(%rbp), %rax
movq 0x30(%rax), %rdi
callq 0x26760
movl %eax, -0x1c(%rbp)
movq -0x48(%rbp), %rax
movq 0x80(%rax), %rdi
movq -0x38(%rbp), %rax
movq (%rax), %rsi
movl -0x14(%rbp), %edx
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rcx
callq 0x95c60
movq %rax, -0x40(%rbp)
movq -0x38(%rbp), %rax
movq 0x18(%rax), %rdi
xorl %eax, %eax
movl %eax, %esi
movl $0xa, %edx
callq 0x26a70
movq %rax, -0x28(%rbp)
movq -0x38(%rbp), %rax
movq 0x38(%rax), %rdi
xorl %eax, %eax
movl %eax, %esi
movl $0xa, %edx
callq 0x26a70
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x40(%rbp)
jne 0x9961e
movq -0x48(%rbp), %rdi
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rsi
callq 0x96480
movl %eax, -0x18(%rbp)
cmpl $0x0, -0x18(%rbp)
je 0x9952c
movq -0x48(%rbp), %rdx
movq -0x38(%rbp), %rax
movq (%rax), %r8
movl -0x14(%rbp), %r9d
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rax
movl $0x2, %edi
leaq 0xad371(%rip), %rsi     # 0x146889
leaq 0xad383(%rip), %rcx     # 0x1468a2
movq %rax, (%rsp)
movb $0x0, %al
callq 0x94990
jmp 0x9958d
movq -0x48(%rbp), %rax
movq 0x80(%rax), %rdi
movq -0x38(%rbp), %rax
movq (%rax), %rsi
movl -0x14(%rbp), %edx
xorl %eax, %eax
movl %eax, %ecx
callq 0x95c60
movq %rax, -0x50(%rbp)
cmpq $0x0, -0x50(%rbp)
je 0x9958b
movq -0x50(%rbp), %rdx
movl $0x2, %edi
leaq 0xad355(%rip), %rsi     # 0x1468ba
leaq 0xacca0(%rip), %rcx     # 0x14620c
movb $0x0, %al
callq 0x94990
movq -0x50(%rbp), %rax
movq 0x20(%rax), %rax
movl $0x0, 0x8(%rax)
movq -0x50(%rbp), %rdi
callq 0x95d60
jmp 0x9958d
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x38(%rbp), %rax
movq (%rax), %rdx
movl -0x14(%rbp), %ecx
movq -0x48(%rbp), %rax
movl 0x90(%rax), %r8d
movq -0x48(%rbp), %r9
movl $0x4, %esi
callq 0x95f90
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
je 0x9961c
cmpl $0x0, -0x18(%rbp)
jne 0x995e7
movq -0x40(%rbp), %rdx
movl $0x2, %edi
leaq 0xad2f8(%rip), %rsi     # 0x1468d1
leaq 0xacc2c(%rip), %rcx     # 0x14620c
movb $0x0, %al
callq 0x94990
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x38510
movq %rax, %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x40(%rbp), %rdi
callq 0x95b20
cmpl $0x0, -0x18(%rbp)
je 0x99617
movq -0x40(%rbp), %rdi
callq 0x95d60
callq 0x946c0
jmp 0x9961e
movq -0x28(%rbp), %rax
cmpq 0xf3a0f(%rip), %rax     # 0x18d038
jbe 0x99660
movq -0x28(%rbp), %rax
movq %rax, 0xf3a02(%rip)     # 0x18d038
callq 0x946c0
movq -0x48(%rbp), %rdx
movq 0xf39f2(%rip), %r8      # 0x18d038
movl $0x3, %edi
leaq 0xad289(%rip), %rsi     # 0x1468db
leaq 0xa8b11(%rip), %rcx     # 0x14216a
movb $0x0, %al
callq 0x94990
cmpq $0x0, -0x40(%rbp)
je 0x9977e
movq -0x48(%rbp), %rax
movq 0x18(%rax), %rax
cmpq -0x30(%rbp), %rax
jae 0x9977e
movq -0x30(%rbp), %rcx
movq -0x48(%rbp), %rax
movq %rcx, 0x18(%rax)
movl -0x1c(%rbp), %eax
movq -0x48(%rbp), %rcx
movq 0x20(%rcx), %rcx
cmpl 0x8(%rcx), %eax
jne 0x996ba
movq -0x48(%rbp), %rax
movq 0x20(%rax), %rax
movq (%rax), %rdi
movq -0x38(%rbp), %rax
movq 0x28(%rax), %rsi
callq 0x268f0
cmpl $0x0, %eax
je 0x9977c
movq -0x40(%rbp), %rdx
movl $0x3, %edi
leaq 0xad21c(%rip), %rsi     # 0x1468e6
leaq 0xacb3b(%rip), %rcx     # 0x14620c
movb $0x0, %al
callq 0x94990
movq -0x48(%rbp), %rdx
movq -0x48(%rbp), %rax
movq 0x8(%rax), %r8
movq -0x48(%rbp), %rax
movq 0x20(%rax), %rax
movq (%rax), %r9
movq -0x48(%rbp), %rax
movq 0x20(%rax), %rax
movl 0x8(%rax), %r11d
movq -0x38(%rbp), %rax
movq 0x28(%rax), %r10
movl -0x1c(%rbp), %eax
movl $0x3, %edi
leaq 0xad1e8(%rip), %rsi     # 0x1468fa
leaq 0xad1f0(%rip), %rcx     # 0x146909
movl %r11d, (%rsp)
movq %r10, 0x8(%rsp)
movl %eax, 0x10(%rsp)
movb $0x0, %al
callq 0x94990
movq -0x48(%rbp), %rax
movq 0x20(%rax), %rdi
callq 0x948b0
movq %rax, -0x58(%rbp)
movq -0x48(%rbp), %rdi
movq -0x38(%rbp), %rax
movq 0x28(%rax), %rsi
movl -0x1c(%rbp), %edx
callq 0x96900
movq -0x48(%rbp), %rdi
movq -0x58(%rbp), %rcx
movq -0x48(%rbp), %rax
movq 0x20(%rax), %r8
movl $0x40000, %esi          # imm = 0x40000
leaq 0xad1de(%rip), %rdx     # 0x14694c
callq 0x957a0
movq -0x58(%rbp), %rdi
callq 0x94900
jmp 0x9977e
cmpq $0x0, -0x40(%rbp)
je 0x99795
callq 0x2ff70
movq %rax, %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x38(%rax)
jmp 0x99797
jmp 0x99799
movq -0x38(%rbp), %rdi
movl -0x10(%rbp), %esi
callq 0x3a270
addq $0x70, %rsp
popq %rbp
retq
nopl (%rax,%rax)