// File: /workspace/github_cpp_makefile_star2_O3/hunterlxt[P]swim-membership-protocol/Application.cpp
// Function: Application::mp1Run()
void Application::mp1Run() {
	int i;

	// For all the nodes in the system
	for( i = 0; i <= par->EN_GPSZ-1; i++) {

		/*
		 * Receive messages from the network and queue them in the membership protocol queue
		 */
		if( par->getcurrtime() > (int)(par->STEP_RATE*i) && !(mp1[i]->getMemberNode()->bFailed) ) {
			// Receive messages from the network and queue them
			mp1[i]->recvLoop();
		}

	}

	// For all the nodes in the system
	for( i = par->EN_GPSZ - 1; i >= 0; i-- ) {

		/*
		 * Introduce nodes into the distributed system
		 */
		if( par->getcurrtime() == (int)(par->STEP_RATE*i) ) {
			// introduce the ith node into the system at time STEPRATE*i
			mp1[i]->nodeStart(JOINADDR, par->PORTNUM);
			cout<<i<<"-th introduced node is assigned with the address: "<<mp1[i]->getMemberNode()->addr.getAddress() << endl;
			nodeCount += i;
		}

		/*
		 * Handle all the messages in your queue and send heartbeats
		 */
		else if( par->getcurrtime() > (int)(par->STEP_RATE*i) && !(mp1[i]->getMemberNode()->bFailed) ) {
			// handle messages and send heartbeats
			mp1[i]->nodeLoop();
			#ifdef DEBUGLOG
			if( (i == 0) && (par->globaltime % 500 == 0) ) {
				log->LOG(&mp1[i]->getMemberNode()->addr, "@@time=%d", par->getcurrtime());
			}
			#endif
		}

	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdi, %rbx
movq 0x40(%rdi), %rdi
cmpl $0x0, 0x18(%rdi)
jle 0x4880
xorl %r14d, %r14d
callq 0x5534
movq 0x40(%rbx), %rdi
xorps %xmm0, %xmm0
cvtsi2sd %r14d, %xmm0
mulsd 0x10(%rdi), %xmm0
cvttsd2si %xmm0, %ecx
cmpl %ecx, %eax
jle 0x4724
movq 0x38(%rbx), %rax
movq (%rax,%r14,8), %rax
movq 0x20(%rax), %rcx
cmpb $0x0, 0x10(%rcx)
jne 0x4724
movq %rax, %rdi
callq 0x261a
movq 0x40(%rbx), %rdi
incq %r14
movslq 0x18(%rdi), %r15
cmpq %r15, %r14
jl 0x46e8
testl %r15d, %r15d
jle 0x4880
leaq 0x8(%rbx), %r14
incq %r15
leaq 0x2b4c(%rip), %r12      # 0x7293
movq %rsp, %r13
movq 0x40(%rbx), %rdi
callq 0x5534
movq 0x40(%rbx), %rdi
leaq -0x2(%r15), %rbp
xorps %xmm1, %xmm1
cvtsi2sd %ebp, %xmm1
movsd 0x10(%rdi), %xmm0
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %ecx
cmpl %ecx, %eax
jne 0x4833
movq 0x38(%rbx), %rax
movq -0x10(%rax,%r15,8), %rax
movswl 0x30(%rdi), %edx
movq %rax, %rdi
movq %r14, %rsi
callq 0x2678
movq 0x683a(%rip), %rdi      # 0xafd0
movl %ebp, %esi
callq 0x22c0
movq %rax, %rbp
movl $0x32, %edx
movq %rax, %rdi
movq %r12, %rsi
callq 0x21c0
movq 0x38(%rbx), %rax
movq -0x10(%rax,%r15,8), %rax
movq 0x20(%rax), %rsi
addq $0x8, %rsi
movq %r13, %rdi
callq 0x4ab0
movq (%rsp), %rsi
movq 0x8(%rsp), %rdx
movq %rbp, %rdi
callq 0x21c0
movq %rax, %rbp
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbp, %rdi
movl $0xa, %esi
callq 0x2170
movsbl %al, %esi
movq %rbp, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x20f0
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x481f
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x21a0
movl 0x71af(%rip), %eax      # 0xb9d4
addl %r15d, %eax
addl $-0x2, %eax
movl %eax, 0x71a3(%rip)      # 0xb9d4
jmp 0x4873
movsd %xmm1, 0x20(%rsp)
callq 0x5534
movq 0x40(%rbx), %rcx
movsd 0x20(%rsp), %xmm0
mulsd 0x10(%rcx), %xmm0
cvttsd2si %xmm0, %ecx
cmpl %ecx, %eax
jle 0x4873
movq 0x38(%rbx), %rax
movq -0x10(%rax,%r15,8), %rdi
movq 0x20(%rdi), %rax
cmpb $0x0, 0x10(%rax)
jne 0x4873
callq 0x27fa
cmpq $0x2, %r15
je 0x488f
decq %r15
cmpq $0x1, %r15
ja 0x474a
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x40(%rbx), %rdi
imull $0x26e978d5, 0x28(%rdi), %eax # imm = 0x26E978D5
addl $0x10624dc, %eax        # imm = 0x10624DC
rorl $0x2, %eax
cmpl $0x83126e, %eax         # imm = 0x83126E
ja 0x4880
movq 0x30(%rbx), %r14
movq 0x38(%rbx), %rax
movq (%rax), %rax
movq 0x20(%rax), %rbx
addq $0x8, %rbx
callq 0x5534
leaq 0x29fe(%rip), %rdx      # 0x72c6
movq %r14, %rdi
movq %rbx, %rsi
movl %eax, %ecx
xorl %eax, %eax
callq 0x502c
jmp 0x4880
movq %rax, %rbx
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x48f7
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x21a0
movq %rbx, %rdi
callq 0x22d0
nop