// File: /workspace/github_cpp_makefile_star2_O3/devanshdalal[P]cloud-computing-concepts-part-2/MP1Node.cpp
// Function: MP1Node::PingK(int)
void MP1Node::PingK(int node_id)
{
    // std::cout << "Start PingK " << this_node_ << " " << node_id << "\n";
    // const auto current_time = par->getcurrtime();
    for (int i = 0; i < SWIMK; ++i)
    {
        int new_x = rand() % memberNode->memberList.size();
        auto &e = memberNode->memberList[new_x];
        const int &new_id = e.getid();
        if (new_id == this_node_ || new_id == node_id)
        {
            --i;
            continue;
        }
        const int &port = e.getport();
        Address a(std::to_string(new_id) + ":" + std::to_string(port));
        MessageHdr *msg = CreateMessage(PING, this_node_, node_id);
        if (!emulNet->ENsend(&memberNode->addr, &a, (char *)msg, MSGSIZE))
        {
            // std::cout << "SWIMK ENsend failed\n";
            // failed to send to this node.
        }
        else
        {
            // std::cout << "SWIMK ENsend passed" << new_id << "\n";
        }
        free(msg);
    }
    // std::cout << "End PingK\n";
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movl %esi, %ebp
movq %rdi, %r14
xorl %r12d, %r12d
movl $0xd1b71759, %ebx       # imm = 0xD1B71759
movl %esi, 0x4(%rsp)
callq 0x30a0
cltq
movq 0x20(%r14), %rcx
movq 0x28(%rcx), %rsi
movq 0x30(%rcx), %rcx
subq %rsi, %rcx
sarq $0x3, %rcx
movabsq $-0x5555555555555555, %rdx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rdx, %rcx
xorl %edx, %edx
divq %rcx
movslq %edx, %rax
leaq (%rax,%rax,2), %rax
leaq (%rsi,%rax,8), %r15
movq %r15, %rdi
callq 0xcdae
cmpl %ebp, %eax
je 0x5604
movl %eax, %r13d
cmpl 0xa4(%r14), %eax
je 0x5604
movq %r12, 0x90(%rsp)
movq %r15, %rdi
callq 0xcdb2
movl %eax, %r12d
movl %r13d, %r15d
negl %r15d
cmovsl %r13d, %r15d
movl $0x1, %ebp
cmpl $0xa, %r15d
jb 0x5383
movl $0x4, %ebp
movl %r15d, %eax
cmpl $0x63, %eax
jbe 0x537c
cmpl $0x3e7, %eax            # imm = 0x3E7
jbe 0x5381
cmpl $0x2710, %eax           # imm = 0x2710
jb 0x5383
movl %eax, %ecx
imulq %rbx, %rcx
shrq $0x2d, %rcx
addl $0x4, %ebp
cmpl $0x1869f, %eax          # imm = 0x1869F
movl %ecx, %eax
ja 0x534e
addl $-0x3, %ebp
jmp 0x5383
addl $-0x2, %ebp
jmp 0x5383
decl %ebp
shrl $0x1f, %r13d
leal (%rbp,%r13), %esi
leaq 0x80(%rsp), %rax
movq %rax, 0x70(%rsp)
leaq 0x70(%rsp), %rbx
movq %rbx, %rdi
movl $0x2d, %edx
callq 0x32f0
addq 0x70(%rsp), %r13
movq %r13, %rdi
movl %ebp, %esi
movl %r15d, %edx
callq 0x5c6b
movq %rbx, %rdi
leaq 0x139d6(%rip), %rsi     # 0x18d9d
callq 0x34a0
leaq 0x38(%rsp), %rbx
movq %rbx, 0x28(%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x53f4
movq %rdx, 0x28(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x38(%rsp)
jmp 0x53fa
movups (%rcx), %xmm0
movups %xmm0, (%rbx)
movq 0x8(%rax), %rdx
movq %rdx, 0x30(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movswl %r12w, %r12d
movl %r12d, %ebp
negl %ebp
cmovsl %r12d, %ebp
movl $0x1, %r15d
cmpl $0xa, %ebp
jb 0x5453
movl $0x2, %r15d
cmpl $0x64, %ebp
jb 0x5453
movl $0x3, %r15d
cmpl $0x3e8, %ebp            # imm = 0x3E8
jb 0x5453
cmpl $0x2710, %ebp           # imm = 0x2710
movl $0x5, %r15d
sbbl $0x0, %r15d
shrl $0x1f, %r12d
leal (%r15,%r12), %esi
leaq 0x18(%rsp), %rax
movq %rax, 0x8(%rsp)
leaq 0x8(%rsp), %rdi
movl $0x2d, %edx
callq 0x32f0
movl %r12d, %edi
addq 0x8(%rsp), %rdi
movl %r15d, %esi
movl %ebp, %edx
callq 0x5c6b
movq 0x28(%rsp), %rcx
movl $0xf, %edi
cmpq %rbx, %rcx
je 0x549a
movq 0x38(%rsp), %rdi
movq 0x30(%rsp), %r8
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
leaq (%rdx,%r8), %rax
cmpq %rdi, %rax
leaq 0x58(%rsp), %r15
movq 0x90(%rsp), %r12
jbe 0x54d8
movl $0xf, %edi
leaq 0x18(%rsp), %r9
cmpq %r9, %rsi
je 0x54d3
movq 0x18(%rsp), %rdi
cmpq %rdi, %rax
jbe 0x54e4
leaq 0x28(%rsp), %rdi
callq 0x30d0
jmp 0x54f2
leaq 0x8(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x32c0
movq %r15, 0x48(%rsp)
movq (%rax), %rdx
leaq 0x10(%rax), %rcx
cmpq %rcx, %rdx
je 0x5512
movq %rdx, 0x48(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x58(%rsp)
jmp 0x5519
movups (%rcx), %xmm0
movups %xmm0, (%r15)
movq %rax, %rdx
addq $0x8, %rdx
movq 0x8(%rax), %rsi
movq %rsi, 0x50(%rsp)
movq %rcx, (%rax)
movq $0x0, (%rdx)
movb $0x0, (%rcx)
leaq 0x6a(%rsp), %rdi
leaq 0x48(%rsp), %rsi
callq 0x572e
movq 0x48(%rsp), %rdi
cmpq %r15, %rdi
je 0x555c
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x3280
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x5578
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x3280
movq 0x28(%rsp), %rdi
cmpq %rbx, %rdi
je 0x558f
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x3280
movq 0x70(%rsp), %rdi
leaq 0x80(%rsp), %rax
cmpq %rax, %rdi
movl $0xd1b71759, %ebx       # imm = 0xD1B71759
je 0x55b6
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x3280
movl 0xa4(%r14), %ebp
movl $0xc, %edi
callq 0x3370
movq %rax, %r15
movl $0x3, (%rax)
movl %ebp, 0x4(%rax)
movl 0x4(%rsp), %ebp
movl %ebp, 0x8(%rax)
movq 0x8(%r14), %rdi
movq 0x20(%r14), %rsi
addq $0x8, %rsi
leaq 0x6a(%rsp), %rdx
movq %rax, %rcx
movl $0xc, %r8d
callq 0x6994
movq %r15, %rdi
callq 0x3320
incl %r12d
cmpl $0x2, %r12d
jl 0x52c6
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r14
jmp 0x5681
movq %rax, %r14
jmp 0x5649
movq %rax, %r14
jmp 0x5665
movq %rax, %r14
movq 0x48(%rsp), %rdi
cmpq %r15, %rdi
je 0x5649
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x3280
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x5665
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x3280
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x5681
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x3280
movq 0x70(%rsp), %rdi
leaq 0x80(%rsp), %rax
cmpq %rax, %rdi
je 0x56a3
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x3280
movq %r14, %rdi
callq 0x3470
nop