// File: /workspace/github_c_makefile_star2_O0/erikdubbelboer[P]discnt/src/cluster.c
// Function: cluserReadShard
void cluserReadShard(const clusterMsgDataCounter *msg, clusterNode *node) {
    uint32_t name_length, revision;
    long double predict_value, predict_change;
    mstime_t predict_time;
    sds name;
    counter *cntr;
    listNode *ln;
    listIter li;
    shard *shrd = NULL;

    name_length = intrev16ifbe(msg->name_length);
    name = sdsnewlen(msg->name,name_length);

    revision       = intrev32ifbe(msg->revision);
    predict_time   = intrev64ifbe(msg->predict_time);
    predict_value  = unpack754(intrev64ifbe(msg->predict_value), 64, 11);
    predict_change = unpack754(intrev64ifbe(msg->predict_change), 64, 11);

    serverLog(LL_DEBUG,"Read shard for %s from %.40s %llu %Lf %Lf",
        name, node->name, predict_time, predict_value, predict_change);

    cntr = counterLookup(name);
    if (cntr == NULL) {
        cntr = counterCreate(name);
    } else {
        listRewind(cntr->shards,&li);
        while ((ln = listNext(&li)) != NULL) {
            shrd = listNodeValue(ln);

            if (shrd->node == node) {
                break;
            }
        }
    }

    if ((shrd == NULL) || (shrd->node != node)) {
        shrd = counterAddShard(cntr,node,node->name);
    }

    shrd->value          = predict_value;
    shrd->predict_time   = predict_time;
    shrd->predict_value  = predict_value;
    shrd->predict_change = predict_change;

    clusterSendAck(node, revision, name);
    
    server.dirty++;

    sdsfree(name);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq $0x0, -0x78(%rbp)
movq -0x8(%rbp), %rax
movzwl 0x1c(%rax), %eax
movl %eax, -0x14(%rbp)
movq -0x8(%rbp), %rdi
addq $0x1e, %rdi
movl -0x14(%rbp), %eax
movl %eax, %esi
callq 0x1dfe0
movq %rax, -0x50(%rbp)
movq -0x8(%rbp), %rax
movl 0x18(%rax), %eax
movl %eax, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x48(%rbp)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rdi
movl $0x40, %esi
movl %esi, -0x80(%rbp)
movl $0xb, %edx
movl %edx, -0x7c(%rbp)
callq 0x36290
movl -0x80(%rbp), %esi
movl -0x7c(%rbp), %edx
fstpt -0x30(%rbp)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x36290
fstpt -0x40(%rbp)
movq -0x50(%rbp), %rdx
movq -0x10(%rbp), %rcx
movq -0x48(%rbp), %r8
fldt -0x30(%rbp)
fldt -0x40(%rbp)
xorl %eax, %eax
movq %rsp, %rax
fstpt 0x10(%rax)
fstpt (%rax)
leaq 0x73578(%rip), %rsi     # 0xa7ba2
xorl %edi, %edi
movb %dil, %al
callq 0x18b10
movq -0x50(%rbp), %rdi
callq 0x396f0
movq %rax, -0x58(%rbp)
cmpq $0x0, -0x58(%rbp)
jne 0x34657
movq -0x50(%rbp), %rdi
callq 0x39740
movq %rax, -0x58(%rbp)
jmp 0x3469a
movq -0x58(%rbp), %rax
movq 0x8(%rax), %rdi
leaq -0x70(%rbp), %rsi
callq 0x13000
leaq -0x70(%rbp), %rdi
callq 0x13060
movq %rax, -0x60(%rbp)
cmpq $0x0, %rax
je 0x34698
movq -0x60(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x78(%rbp)
movq -0x78(%rbp), %rax
movq (%rax), %rax
cmpq -0x10(%rbp), %rax
jne 0x34696
jmp 0x34698
jmp 0x34668
jmp 0x3469a
cmpq $0x0, -0x78(%rbp)
je 0x346ae
movq -0x78(%rbp), %rax
movq (%rax), %rax
cmpq -0x10(%rbp), %rax
je 0x346c3
movq -0x58(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x10(%rbp), %rdx
callq 0x39810
movq %rax, -0x78(%rbp)
fldt -0x30(%rbp)
movq -0x78(%rbp), %rax
fstpt 0x30(%rax)
movq -0x48(%rbp), %rcx
movq -0x78(%rbp), %rax
movq %rcx, 0x40(%rax)
fldt -0x30(%rbp)
movq -0x78(%rbp), %rax
fstpt 0x50(%rax)
fldt -0x40(%rbp)
movq -0x78(%rbp), %rax
fstpt 0x60(%rax)
movq -0x10(%rbp), %rdi
movl -0x18(%rbp), %esi
movq -0x50(%rbp), %rdx
callq 0x35d40
leaq 0x8a9e4(%rip), %rax     # 0xbf0e8
movq 0x6a0(%rax), %rcx
addq $0x1, %rcx
leaq 0x8a9d2(%rip), %rax     # 0xbf0e8
movq %rcx, 0x6a0(%rax)
movq -0x50(%rbp), %rdi
callq 0x1e3c0
addq $0xa0, %rsp
popq %rbp
retq
nop