// File: /workspace/github_cpp_makefile_star2_O1/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, 0x24(%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 0xced2
cmpl %ebp, %eax
je 0x56b9
movl %eax, %r13d
cmpl 0xa4(%r14), %eax
je 0x56b9
movq %r12, 0x90(%rsp)
movq %r15, %rdi
callq 0xced6
movl %eax, %r12d
movl %r13d, %r15d
negl %r15d
cmovsl %r13d, %r15d
movl $0x1, %ebp
cmpl $0xa, %r15d
jb 0x543f
movl $0x4, %ebp
movl %r15d, %eax
cmpl $0x63, %eax
jbe 0x5438
cmpl $0x3e7, %eax            # imm = 0x3E7
jbe 0x543d
cmpl $0x2710, %eax           # imm = 0x2710
jb 0x543f
movl %eax, %ecx
imulq %rbx, %rcx
shrq $0x2d, %rcx
addl $0x4, %ebp
cmpl $0x1869f, %eax          # imm = 0x1869F
movl %ecx, %eax
ja 0x540a
addl $-0x3, %ebp
jmp 0x543f
addl $-0x2, %ebp
jmp 0x543f
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 0x5d13
movq %rbx, %rdi
leaq 0x1395a(%rip), %rsi     # 0x18ddd
callq 0x34a0
leaq 0x38(%rsp), %rbx
movq %rbx, 0x28(%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x54b0
movq %rdx, 0x28(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x38(%rsp)
jmp 0x54b6
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 0x550f
movl $0x2, %r15d
cmpl $0x64, %ebp
jb 0x550f
movl $0x3, %r15d
cmpl $0x3e8, %ebp            # imm = 0x3E8
jb 0x550f
cmpl $0x2710, %ebp           # imm = 0x2710
movl $0x5, %r15d
sbbl $0x0, %r15d
shrl $0x1f, %r12d
leal (%r15,%r12), %esi
leaq 0x10(%rsp), %rax
movq %rax, (%rsp)
movq %rsp, %rdi
movl $0x2d, %edx
callq 0x32f0
movl %r12d, %edi
addq (%rsp), %rdi
movl %r15d, %esi
movl %ebp, %edx
callq 0x5d13
movq 0x28(%rsp), %rcx
movl $0xf, %esi
cmpq %rbx, %rcx
je 0x5552
movq 0x38(%rsp), %rsi
movq 0x30(%rsp), %r8
movq 0x8(%rsp), %rdx
leaq (%rdx,%r8), %rax
cmpq %rsi, %rax
leaq 0x58(%rsp), %r15
movq 0x90(%rsp), %r12
jbe 0x558c
movl $0xf, %esi
leaq 0x10(%rsp), %rdi
cmpq %rdi, (%rsp)
je 0x5587
movq 0x10(%rsp), %rsi
cmpq %rsi, %rax
jbe 0x559c
movq (%rsp), %rsi
leaq 0x28(%rsp), %rdi
callq 0x30d0
jmp 0x55a8
movq %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 0x55c8
movq %rdx, 0x48(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x58(%rsp)
jmp 0x55cf
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 0x57dc
movq 0x48(%rsp), %rdi
cmpq %r15, %rdi
je 0x5612
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x3280
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x562d
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3280
movq 0x28(%rsp), %rdi
cmpq %rbx, %rdi
je 0x5644
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 0x566b
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 0x24(%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 0x69dc
movq %r15, %rdi
callq 0x3320
incl %r12d
cmpl $0x2, %r12d
jl 0x5382
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r14
jmp 0x5735
movq %rax, %r14
jmp 0x56fe
movq %rax, %r14
jmp 0x5719
movq %rax, %r14
movq 0x48(%rsp), %rdi
cmpq %r15, %rdi
je 0x56fe
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x3280
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x5719
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3280
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x5735
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x3280
movq 0x70(%rsp), %rdi
leaq 0x80(%rsp), %rax
cmpq %rax, %rdi
je 0x5757
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x3280
movq %r14, %rdi
callq 0x3470
nop