// File: /workspace/github_c_makefile_star2_O0/erikdubbelboer[P]discnt/src/cluster.c
// Function: clusterSendShardToNode
void clusterSendShardToNode(counter *cntr, clusterNode *node) {
    unsigned char buf[sizeof(clusterMsg) + 64], *payload;
    clusterMsg *hdr = (clusterMsg*) buf;
    uint32_t totlen;

    if (node->link == NULL) return;

    totlen = sizeof(clusterMsg)-sizeof(union clusterMsgData);
    totlen += sizeof(clusterMsgDataCounter) - sizeof(hdr->data.counter.shard.name);
    totlen += sdslen(cntr->name);

    clusterBuildMessageHdr(hdr,CLUSTERMSG_TYPE_COUNTER);
    hdr->totlen = htonl(totlen);

    hdr->data.counter.shard.revision       = intrev32ifbe(cntr->revision);
    hdr->data.counter.shard.predict_time   = intrev64ifbe(cntr->myshard->predict_time);
    hdr->data.counter.shard.predict_value  = intrev64ifbe(pack754(cntr->myshard->predict_value, 64, 11));
    hdr->data.counter.shard.predict_change = intrev64ifbe(pack754(cntr->myshard->predict_change, 64, 11));
    hdr->data.counter.shard.name_length    = intrev16ifbe(sdslen(cntr->name));

    if (totlen < sizeof(buf)) {
        payload = buf;
    } else {
        payload = zmalloc(totlen);
        memcpy(payload,buf,sizeof(clusterMsg));
        hdr = (clusterMsg*) payload;

        serverLog(LL_DEBUG,"Need to resize payload buffer to %u bytes for counter for %s",
            totlen, cntr->name);
    }

    memcpy(hdr->data.counter.shard.name, cntr->name, sdslen(cntr->name));

    clusterSendMessage(node->link,payload,totlen);

    if (totlen >= sizeof(buf)) {
        zfree(payload);
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x160, %rsp            # imm = 0x160
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
leaq -0x120(%rbp), %rax
movq %rax, -0x130(%rbp)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x88(%rax)
jne 0x35aa4
jmp 0x35c92
movl $0x60, -0x134(%rbp)
movl -0x134(%rbp), %eax
addl $0x1e, %eax
movl %eax, -0x134(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rdi
callq 0x32160
movq %rax, %rcx
movl -0x134(%rbp), %eax
addl %ecx, %eax
movl %eax, -0x134(%rbp)
movq -0x130(%rbp), %rdi
movl $0x4, %esi
callq 0x34a10
movl -0x134(%rbp), %edi
callq 0x12360
movl %eax, %ecx
movq -0x130(%rbp), %rax
movl %ecx, 0x4(%rax)
movq -0x8(%rbp), %rax
movl 0x38(%rax), %ecx
movq -0x130(%rbp), %rax
movl %ecx, 0x78(%rax)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movq 0x40(%rax), %rcx
movq -0x130(%rbp), %rax
movq %rcx, 0x60(%rax)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
fldt 0x50(%rax)
movq %rsp, %rax
fstpt (%rax)
movl $0x40, %edi
movl $0xb, %esi
callq 0x36120
movq %rax, %rcx
movq -0x130(%rbp), %rax
movq %rcx, 0x68(%rax)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
fldt 0x60(%rax)
movq %rsp, %rax
fstpt (%rax)
movl $0x40, %edi
movl $0xb, %esi
callq 0x36120
movq %rax, %rcx
movq -0x130(%rbp), %rax
movq %rcx, 0x70(%rax)
movq -0x8(%rbp), %rax
movq (%rax), %rdi
callq 0x32160
movw %ax, %cx
movq -0x130(%rbp), %rax
movw %cx, 0x7c(%rax)
movl -0x134(%rbp), %eax
cmpq $0x108, %rax            # imm = 0x108
jae 0x35bbc
leaq -0x120(%rbp), %rax
movq %rax, -0x128(%rbp)
jmp 0x35c13
movl -0x134(%rbp), %eax
movl %eax, %edi
callq 0x20a00
movq %rax, -0x128(%rbp)
movq -0x128(%rbp), %rdi
leaq -0x120(%rbp), %rsi
movl $0xc8, %edx
callq 0x12500
movq -0x128(%rbp), %rax
movq %rax, -0x130(%rbp)
movl -0x134(%rbp), %edx
movq -0x8(%rbp), %rax
movq (%rax), %rcx
xorl %edi, %edi
leaq 0x71f59(%rip), %rsi     # 0xa7b65
movb $0x0, %al
callq 0x18b10
movq -0x130(%rbp), %rax
addq $0x60, %rax
addq $0x1e, %rax
movq %rax, -0x148(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x140(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rdi
callq 0x32160
movq -0x148(%rbp), %rdi
movq -0x140(%rbp), %rsi
movq %rax, %rdx
callq 0x12500
movq -0x10(%rbp), %rax
movq 0x88(%rax), %rdi
movq -0x128(%rbp), %rsi
movl -0x134(%rbp), %eax
movl %eax, %edx
callq 0x348e0
movl -0x134(%rbp), %eax
cmpq $0x108, %rax            # imm = 0x108
jb 0x35c92
movq -0x128(%rbp), %rdi
callq 0x20ce0
addq $0x160, %rsp            # imm = 0x160
popq %rbp
retq
nopl (%rax,%rax)