// File: /workspace/github_cpp_makefile_star2_O1/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 0x4446
movq %rdi, %rbx
movq 0x18(%rdi), %rdi
callq 0xce42
movl %eax, %ebp
movl 0xa0(%rbx), %eax
addl $0x1e, %eax
cmpl %ebp, %eax
jle 0x443e
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 0xced2
movl %eax, 0x4(%rsp)
movq %r14, %rdi
callq 0xced6
movw %ax, 0x2(%rsp)
movl 0xa4(%rbx), %r14d
movl 0x4(%rsp), %r15d
movl $0xc, %edi
callq 0x3370
movl $0x3, (%rax)
movl %r14d, 0x4(%rax)
movq %rax, 0x70(%rsp)
movl %r15d, 0x8(%rax)
movl %r15d, %r12d
negl %r12d
cmovsl %r15d, %r12d
movl $0x1, %r13d
cmpl $0xa, %r12d
jb 0x41c8
movl $0x4, %r13d
movl $0xd1b71759, %eax       # imm = 0xD1B71759
movl %r12d, %ecx
cmpl $0x63, %ecx
jbe 0x41bf
cmpl $0x3e7, %ecx            # imm = 0x3E7
jbe 0x41c5
cmpl $0x2710, %ecx           # imm = 0x2710
jb 0x41c8
movl %ecx, %edx
imulq %rax, %rdx
shrq $0x2d, %rdx
addl $0x4, %r13d
cmpl $0x1869f, %ecx          # imm = 0x1869F
movl %edx, %ecx
ja 0x418c
addl $-0x3, %r13d
jmp 0x41c8
addl $-0x2, %r13d
jmp 0x41c8
decl %r13d
shrl $0x1f, %r15d
movl %r15d, %esi
addl %r13d, %esi
leaq 0x88(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x78(%rsp), %r14
movq %r14, %rdi
movl $0x2d, %edx
callq 0x32f0
movq (%r14), %rdi
addq %r15, %rdi
movl %r13d, %esi
movl %r12d, %edx
callq 0x5d13
leaq 0x14bd5(%rip), %rsi     # 0x18ddd
movq %r14, %rdi
callq 0x34a0
leaq 0x58(%rsp), %rsi
movq %rsi, -0x10(%rsi)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x423a
movq %rsi, %r13
movq %rdx, 0x48(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x58(%rsp)
jmp 0x4243
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), %r14d
movl %r14d, %r15d
negl %r15d
cmovsl %r14d, %r15d
movl $0x1, %r12d
cmpl $0xa, %r15d
jb 0x42a3
movl $0x2, %r12d
cmpl $0x64, %r15d
jb 0x42a3
movl $0x3, %r12d
cmpl $0x3e8, %r15d           # imm = 0x3E8
jb 0x42a3
cmpl $0x2710, %r15d          # imm = 0x2710
movl $0x5, %r12d
sbbl $0x0, %r12d
shrl $0x1f, %r14d
leal (%r12,%r14), %esi
leaq 0x18(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x8(%rsp), %rdi
movl $0x2d, %edx
callq 0x32f0
movl %r14d, %edi
addq 0x8(%rsp), %rdi
movl %r12d, %esi
movl %r15d, %edx
callq 0x5d13
movq 0x48(%rsp), %rcx
movq 0x50(%rsp), %r8
movq 0x10(%rsp), %rdx
leaq (%rdx,%r8), %rax
movl $0xf, %esi
cmpq %r13, %rcx
je 0x42f8
movq 0x58(%rsp), %rsi
cmpq %rsi, %rax
leaq 0x18(%rsp), %r15
jbe 0x4318
movl $0xf, %esi
cmpq %r15, 0x8(%rsp)
je 0x4313
movq 0x18(%rsp), %rsi
cmpq %rsi, %rax
jbe 0x4329
movq 0x8(%rsp), %rsi
leaq 0x48(%rsp), %rdi
callq 0x30d0
jmp 0x4337
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 0x435b
movq %rsi, 0x28(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x38(%rsp)
jmp 0x4361
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 0x57dc
leaq 0x38(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x43a8
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x3280
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
je 0x43bf
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x3280
movq 0x48(%rsp), %rdi
cmpq %r13, %rdi
je 0x43d6
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x3280
movq 0x78(%rsp), %rdi
leaq 0x88(%rsp), %rax
cmpq %rax, %rdi
je 0x43f8
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 0x69dc
addl $0xa, %ebp
movslq %ebp, %r14
leaq 0x68(%rbx), %rdi
leaq 0x4(%rsp), %rsi
callq 0x62a6
movl $0x0, (%rax)
movq %r14, 0x8(%rax)
movl $0xffffffff, 0x10(%rax) # imm = 0xFFFFFFFF
movq %rbx, %rdi
callq 0x5254
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 0x447b
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x3280
jmp 0x447b
movq %rax, %rbx
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x449c
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x3280
jmp 0x449c
movq %rax, %rbx
movq 0x48(%rsp), %rdi
cmpq %r13, %rdi
je 0x44b8
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x3280
jmp 0x44b8
movq %rax, %rbx
movq 0x78(%rsp), %rdi
leaq 0x88(%rsp), %rax
cmpq %rax, %rdi
je 0x44da
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x3280
movq %rbx, %rdi
callq 0x3470