// File: /workspace/github_cpp_makefile_star2_O3/csMOOC[P]UIUC/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 0x4044
xorl %r14d, %r14d
callq 0x4cf8
movq 0x40(%rbx), %rdi
xorps %xmm0, %xmm0
cvtsi2sd %r14d, %xmm0
mulsd 0x10(%rdi), %xmm0
cvttsd2si %xmm0, %ecx
cmpl %ecx, %eax
jle 0x3ee8
movq 0x38(%rbx), %rax
movq (%rax,%r14,8), %rax
movq 0x20(%rax), %rcx
cmpb $0x0, 0x10(%rcx)
jne 0x3ee8
movq %rax, %rdi
callq 0x2626
movq 0x40(%rbx), %rdi
incq %r14
movslq 0x18(%rdi), %r15
cmpq %r15, %r14
jl 0x3eac
testl %r15d, %r15d
jle 0x4044
leaq 0x8(%rbx), %r14
incq %r15
leaq 0x3350(%rip), %r12      # 0x725b
movq %rsp, %r13
movq 0x40(%rbx), %rdi
callq 0x4cf8
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 0x3ff7
movq 0x38(%rbx), %rax
movq -0x10(%rax,%r15,8), %rax
movswl 0x30(%rdi), %edx
movq %rax, %rdi
movq %r14, %rsi
callq 0x2684
movq 0x7076(%rip), %rdi      # 0xafd0
movl %ebp, %esi
callq 0x22d0
movq %rax, %rbp
movl $0x32, %edx
movq %rax, %rdi
movq %r12, %rsi
callq 0x21d0
movq 0x38(%rbx), %rax
movq -0x10(%rax,%r15,8), %rax
movq 0x20(%rax), %rsi
addq $0x8, %rsi
movq %r13, %rdi
callq 0x4274
movq (%rsp), %rsi
movq 0x8(%rsp), %rdx
movq %rbp, %rdi
callq 0x21d0
movq %rax, %rbp
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbp, %rdi
movl $0xa, %esi
callq 0x2180
movsbl %al, %esi
movq %rbp, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2100
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x3fe3
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x21b0
movl 0x7dfb(%rip), %eax      # 0xbde4
addl %r15d, %eax
addl $-0x2, %eax
movl %eax, 0x7def(%rip)      # 0xbde4
jmp 0x4037
movsd %xmm1, 0x20(%rsp)
callq 0x4cf8
movq 0x40(%rbx), %rcx
movsd 0x20(%rsp), %xmm0
mulsd 0x10(%rcx), %xmm0
cvttsd2si %xmm0, %ecx
cmpl %ecx, %eax
jle 0x4037
movq 0x38(%rbx), %rax
movq -0x10(%rax,%r15,8), %rdi
movq 0x20(%rdi), %rax
cmpb $0x0, 0x10(%rax)
jne 0x4037
callq 0x292a
cmpq $0x2, %r15
je 0x4053
decq %r15
cmpq $0x1, %r15
ja 0x3f0e
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 0x4044
movq 0x30(%rbx), %r14
movq 0x38(%rbx), %rax
movq (%rax), %rax
movq 0x20(%rax), %rbx
addq $0x8, %rbx
callq 0x4cf8
leaq 0x3202(%rip), %rdx      # 0x728e
movq %r14, %rdi
movq %rbx, %rsi
movl %eax, %ecx
xorl %eax, %eax
callq 0x47f0
jmp 0x4044
movq %rax, %rbx
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x40bb
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x21b0
movq %rbx, %rdi
callq 0x22e0
nop