// File: /workspace/github_c_makefile_star2_O3/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:
cmpq $0x0, 0x88(%rsi)
je 0x2e736
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x120, %rsp            # imm = 0x120
movq %rsi, %rbx
movq %rdi, %r12
movq (%rdi), %rax
movzbl -0x1(%rax), %r14d
movl %r14d, %ecx
andl $0x7, %ecx
cmpl $0x4, %ecx
ja 0x2e55a
leaq 0x28447(%rip), %rdx     # 0x56978
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
shrl $0x3, %r14d
jmp 0x2e55d
movq -0x11(%rax), %r14
jmp 0x2e55d
movzwl -0x5(%rax), %r14d
jmp 0x2e55d
movl -0x9(%rax), %r14d
jmp 0x2e55d
movzbl -0x3(%rax), %r14d
jmp 0x2e55d
xorl %r14d, %r14d
addl $0x7e, %r14d
leaq 0x10(%rsp), %r15
xorl %r13d, %r13d
movl $0xc8, %edx
movq %r15, %rdi
xorl %esi, %esi
callq 0x12380
movl $0x5a756244, (%r15)     # imm = 0x5A756244
movw $0x400, 0xc(%r15)       # imm = 0x400
movq 0x55013(%rip), %rax     # 0x835a0
movups (%rax), %xmm0
movups 0x10(%rax), %xmm1
movaps %xmm0, 0x10(%r15)
movaps %xmm1, 0x20(%r15)
movq 0x20(%rax), %rcx
movq %rcx, 0x30(%r15)
leaq 0x40adb(%rip), %rcx     # 0x6f088
movzwl 0xb4(%rcx), %edx
rolw $0x8, %dx
movw %dx, 0x58(%r15)
movzwl 0x30(%rax), %eax
rolw $0x8, %ax
movw %ax, 0x5a(%r15)
movq 0x668(%rcx), %rax
movb 0x8(%rax), %al
movb %al, 0x5c(%r15)
movl %r14d, %eax
bswapl %eax
movl %eax, 0x4(%r15)
movl 0x38(%r12), %eax
movl %eax, 0x78(%r15)
movq 0x10(%r12), %rax
movq 0x40(%rax), %rcx
movq %rcx, 0x60(%r15)
fldt 0x50(%rax)
fstpt (%rsp)
movl $0x40, %edi
movl $0xb, %esi
callq 0x2ea96
movq %rax, 0x68(%r15)
movq 0x10(%r12), %rax
fldt 0x60(%rax)
fstpt (%rsp)
movl $0x40, %edi
movl $0xb, %esi
callq 0x2ea96
movq %rax, 0x70(%r15)
movq (%r12), %rsi
movzbl -0x1(%rsi), %edx
movl %edx, %eax
andl $0x7, %eax
cmpl $0x4, %eax
ja 0x2e671
leaq 0x28345(%rip), %rcx     # 0x5698c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl %edx, %r13d
shrl $0x3, %r13d
jmp 0x2e671
movq -0x11(%rsi), %r13
jmp 0x2e671
movzwl -0x5(%rsi), %r13d
jmp 0x2e671
movl -0x9(%rsi), %r13d
jmp 0x2e671
movzbl -0x3(%rsi), %r13d
movw %r13w, 0x8c(%rsp)
movl %r14d, %r13d
cmpl $0x108, %r14d           # imm = 0x108
jb 0x2e6c2
movq %r13, %rdi
callq 0x1fbbd
movq %rax, %r15
leaq 0x10(%rsp), %rsi
movl $0xc8, %edx
movq %rax, %rdi
callq 0x12510
movq (%r12), %rcx
leaq 0x28c8b(%rip), %rsi     # 0x57339
xorl %edi, %edi
movl %r14d, %edx
xorl %eax, %eax
callq 0x19c06
movq (%r12), %rsi
movzbl -0x1(%rsi), %edx
leaq 0x7e(%r15), %rdi
movl %edx, %eax
andl $0x7, %eax
cmpl $0x4, %eax
ja 0x2e6fc
leaq 0x282c9(%rip), %rcx     # 0x569a0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
shrl $0x3, %edx
jmp 0x2e6fe
movq -0x11(%rsi), %rdx
jmp 0x2e6fe
movzwl -0x5(%rsi), %edx
jmp 0x2e6fe
movl -0x9(%rsi), %edx
jmp 0x2e6fe
movzbl -0x3(%rsi), %edx
jmp 0x2e6fe
xorl %edx, %edx
callq 0x12510
movq 0x88(%rbx), %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0x2d8da
cmpl $0x108, %r14d           # imm = 0x108
jb 0x2e726
movq %r15, %rdi
callq 0x1fd17
addq $0x120, %rsp            # imm = 0x120
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq