// File: /workspace/github_cpp_makefile_star2_O3/devanshdalal[P]cloud-computing-concepts-part-2/MP1Node.cpp
// Function: MP1Node::nodeLoopOps()
void MP1Node::nodeLoopOps()
{
    // std::cout << "Start nodeLoopOps " << this_node_ << " " << last_detection_ << "\n";
    if (!memberNode->memberList.size())
        return;
    const auto current_time = par->getcurrtime();
    if (last_detection_ + DETECTION_INTERVAL > current_time)
    {
        last_detection_ = current_time;
        int x = rand() % memberNode->memberList.size();
        auto &e = memberNode->memberList[x];
        const int &id = e.getid();
        const int &port = e.getport();

        MessageHdr *msg = CreateMessage(PING, this_node_, id);
        Address target_address = std::to_string(id) + ":" + std::to_string(port);

        if (!emulNet->ENsend(&memberNode->addr, &target_address, (char *)msg, MSGSIZE))
        {
            // local_state_[id] = {TIMEOUTWAITING, current_time, -1};
            // failed, so send.
        }
        else
        {
        }
        local_state_[id] = {TIMEOUTWAITING, current_time + WAITING_TIMEOUT, -1};
    }

    ModifyLocalState();

    // std::cout << "End nodeLoopOps\n";
    return;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movq 0x20(%rdi), %rax
movq 0x30(%rax), %rcx
cmpq 0x28(%rax), %rcx
je 0x43f4
movq %rdi, %rbx
movq 0x18(%rdi), %rdi
callq 0xcd1e
movl %eax, %ebp
movl 0xa0(%rbx), %eax
addl $0x1e, %eax
cmpl %ebp, %eax
jle 0x43ec
movl %ebp, 0xa0(%rbx)
callq 0x30a0
cltq
movq 0x20(%rbx), %rcx
movq 0x28(%rcx), %rsi
movq 0x30(%rcx), %rcx
subq %rsi, %rcx
sarq $0x3, %rcx
movabsq $-0x5555555555555555, %rdi # imm = 0xAAAAAAAAAAAAAAAB
imulq %rcx, %rdi
xorl %edx, %edx
divq %rdi
movslq %edx, %rax
leaq (%rax,%rax,2), %rax
leaq (%rsi,%rax,8), %r14
movq %r14, %rdi
callq 0xcdae
movl %eax, %r12d
movl %eax, 0x4(%rsp)
movq %r14, %rdi
callq 0xcdb2
movw %ax, 0x2(%rsp)
movl 0xa4(%rbx), %r14d
movl $0xc, %edi
callq 0x3370
movl $0x3, (%rax)
movl %r14d, 0x4(%rax)
movq %rax, 0x70(%rsp)
movl %r12d, 0x8(%rax)
movl %r12d, %r13d
negl %r13d
cmovsl %r12d, %r13d
movl $0x1, %r14d
cmpl $0xa, %r13d
jb 0x417a
movl $0x4, %r14d
movl $0xd1b71759, %eax       # imm = 0xD1B71759
movl %r13d, %ecx
cmpl $0x63, %ecx
jbe 0x4171
cmpl $0x3e7, %ecx            # imm = 0x3E7
jbe 0x4177
cmpl $0x2710, %ecx           # imm = 0x2710
jb 0x417a
movl %ecx, %edx
imulq %rax, %rdx
shrq $0x2d, %rdx
addl $0x4, %r14d
cmpl $0x1869f, %ecx          # imm = 0x1869F
movl %edx, %ecx
ja 0x413e
addl $-0x3, %r14d
jmp 0x417a
addl $-0x2, %r14d
jmp 0x417a
decl %r14d
shrl $0x1f, %r12d
leal (%r14,%r12), %esi
leaq 0x88(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x78(%rsp), %r15
movq %r15, %rdi
movl $0x2d, %edx
callq 0x32f0
addq (%r15), %r12
movq %r12, %rdi
movl %r14d, %esi
movl %r13d, %edx
callq 0x5c6b
leaq 0x14be5(%rip), %rsi     # 0x18d9d
movq %r15, %rdi
callq 0x34a0
leaq 0x58(%rsp), %rsi
movq %rsi, -0x10(%rsi)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x41ea
movq %rsi, %r13
movq %rdx, 0x48(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x58(%rsp)
jmp 0x41f3
movups (%rcx), %xmm0
movq %rsi, %r13
movups %xmm0, (%rsi)
movq 0x8(%rax), %rdx
movq %rdx, 0x50(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movswl 0x2(%rsp), %r12d
movl %r12d, %r14d
negl %r14d
cmovsl %r12d, %r14d
movl $0x1, %r15d
cmpl $0xa, %r14d
jb 0x4253
movl $0x2, %r15d
cmpl $0x64, %r14d
jb 0x4253
movl $0x3, %r15d
cmpl $0x3e8, %r14d           # imm = 0x3E8
jb 0x4253
cmpl $0x2710, %r14d          # imm = 0x2710
movl $0x5, %r15d
sbbl $0x0, %r15d
shrl $0x1f, %r12d
leal (%r15,%r12), %esi
leaq 0x18(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x8(%rsp), %rdi
movl $0x2d, %edx
callq 0x32f0
movl %r12d, %edi
addq 0x8(%rsp), %rdi
movl %r15d, %esi
movl %r14d, %edx
callq 0x5c6b
movq 0x48(%rsp), %rcx
movq 0x50(%rsp), %r8
movq 0x10(%rsp), %rdx
leaq (%rdx,%r8), %rax
movl $0xf, %edi
cmpq %r13, %rcx
je 0x42a8
movq 0x58(%rsp), %rdi
movq 0x8(%rsp), %rsi
cmpq %rdi, %rax
leaq 0x18(%rsp), %r15
jbe 0x42cb
movl $0xf, %edi
cmpq %r15, %rsi
je 0x42c6
movq 0x18(%rsp), %rdi
cmpq %rdi, %rax
jbe 0x42d7
leaq 0x48(%rsp), %rdi
callq 0x30d0
jmp 0x42e5
leaq 0x8(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x32c0
leaq 0x38(%rsp), %rdx
movq %rdx, -0x10(%rdx)
movq (%rax), %rsi
leaq 0x10(%rax), %rcx
cmpq %rcx, %rsi
je 0x4309
movq %rsi, 0x28(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x38(%rsp)
jmp 0x430f
movups (%rcx), %xmm0
movups %xmm0, (%rdx)
movq %rax, %rdx
addq $0x8, %rdx
movq 0x8(%rax), %rsi
movq %rsi, 0x30(%rsp)
movq %rcx, (%rax)
movq $0x0, (%rdx)
movb $0x0, (%rcx)
leaq 0x6a(%rsp), %rdi
leaq 0x28(%rsp), %rsi
callq 0x572e
leaq 0x38(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x4356
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x3280
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
je 0x436d
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x3280
movq 0x48(%rsp), %rdi
cmpq %r13, %rdi
je 0x4384
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x3280
movq 0x78(%rsp), %rdi
leaq 0x88(%rsp), %rax
cmpq %rax, %rdi
je 0x43a6
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x3280
movq 0x8(%rbx), %rdi
movq 0x20(%rbx), %rsi
addq $0x8, %rsi
leaq 0x6a(%rsp), %rdx
movq 0x70(%rsp), %rcx
movl $0xc, %r8d
callq 0x6994
addl $0xa, %ebp
movslq %ebp, %r14
leaq 0x68(%rbx), %rdi
leaq 0x4(%rsp), %rsi
callq 0x622a
movl $0x0, (%rax)
movq %r14, 0x8(%rax)
movl $0xffffffff, 0x10(%rax) # imm = 0xFFFFFFFF
movq %rbx, %rdi
callq 0x5198
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x38(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x4429
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x3280
jmp 0x4429
movq %rax, %rbx
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x444a
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x3280
jmp 0x444a
movq %rax, %rbx
movq 0x48(%rsp), %rdi
cmpq %r13, %rdi
je 0x4466
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x3280
jmp 0x4466
movq %rax, %rbx
movq 0x78(%rsp), %rdi
leaq 0x88(%rsp), %rax
cmpq %rax, %rdi
je 0x4488
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x3280
movq %rbx, %rdi
callq 0x3470