// File: /workspace/github_cpp_makefile_star2_O1/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
movl 0x18(%rdi), %eax
testl %eax, %eax
jle 0x4780
xorl %r14d, %r14d
callq 0x55e0
movq 0x40(%rbx), %rcx
xorps %xmm0, %xmm0
cvtsi2sd %r14d, %xmm0
mulsd 0x10(%rcx), %xmm0
cvttsd2si %xmm0, %ecx
cmpl %ecx, %eax
jle 0x4770
movq 0x38(%rbx), %rax
movq (%rax,%r14,8), %rdi
movq 0x20(%rdi), %rax
cmpb $0x0, 0x10(%rax)
jne 0x4770
callq 0x262a
incq %r14
movq 0x40(%rbx), %rdi
movslq 0x18(%rdi), %rax
cmpq %rax, %r14
jl 0x473b
testl %eax, %eax
jle 0x4933
leaq 0x8(%rbx), %r14
leaq 0x18(%rsp), %r15
movl %eax, %r12d
incq %r12
movq 0x7832(%rip), %r13      # 0xbfd0
movq 0x40(%rbx), %rdi
callq 0x55e0
movq 0x40(%rbx), %rdi
leal -0x2(%r12), %ecx
xorps %xmm1, %xmm1
cvtsi2sd %ecx, %xmm1
movsd 0x10(%rdi), %xmm0
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %ecx
cmpl %ecx, %eax
jne 0x488d
movq 0x38(%rbx), %rax
movq -0x10(%rax,%r12,8), %rax
movswl 0x30(%rdi), %edx
movq %rax, %rdi
movq %r14, %rsi
callq 0x2688
leal -0x2(%r12), %esi
movq %r13, %rdi
callq 0x22d0
movq %rax, %rbp
movl $0x32, %edx
movq %rax, %rdi
leaq 0x3a90(%rip), %rsi      # 0x8293
callq 0x21c0
movq 0x38(%rbx), %rax
movq -0x10(%rax,%r12,8), %rax
movq 0x20(%rax), %rsi
addq $0x8, %rsi
leaq 0x8(%rsp), %rdi
callq 0x4b18
movq 0x8(%rsp), %rsi
movq 0x10(%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 0x8(%rsp), %rdi
cmpq %r15, %rdi
je 0x4876
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x21a0
movl 0x8158(%rip), %eax      # 0xc9d4
addl %r12d, %eax
addl $-0x2, %eax
movl %eax, 0x814c(%rip)      # 0xc9d4
jmp 0x4926
movsd %xmm1, (%rsp)
callq 0x55e0
movq 0x40(%rbx), %rcx
movsd (%rsp), %xmm0
mulsd 0x10(%rcx), %xmm0
cvttsd2si %xmm0, %ecx
cmpl %ecx, %eax
jle 0x4926
movq 0x38(%rbx), %rax
movq -0x10(%rax,%r12,8), %rdi
movq 0x20(%rdi), %rax
cmpb $0x0, 0x10(%rax)
jne 0x4926
callq 0x280a
cmpq $0x2, %r12
jne 0x4926
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 0x4926
movq 0x30(%rbx), %rax
movq %rax, (%rsp)
movq 0x38(%rbx), %rax
movq -0x10(%rax,%r12,8), %rax
movq %r13, %rbp
movq %r15, %r13
movq 0x20(%rax), %r15
addq $0x8, %r15
callq 0x55e0
movq (%rsp), %rdi
movq %r15, %rsi
movq %r13, %r15
movq %rbp, %r13
leaq 0x39a9(%rip), %rdx      # 0x82c6
movl %eax, %ecx
xorl %eax, %eax
callq 0x5090
decq %r12
cmpq $0x1, %r12
jg 0x479e
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
je 0x495c
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x21a0
movq %rbx, %rdi
callq 0x22e0