// File: /workspace/github_cpp_makefile_star2_O1/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
movl 0x18(%rdi), %eax
testl %eax, %eax
jle 0x3ef0
xorl %r14d, %r14d
callq 0x4d50
movq 0x40(%rbx), %rcx
xorps %xmm0, %xmm0
cvtsi2sd %r14d, %xmm0
mulsd 0x10(%rcx), %xmm0
cvttsd2si %xmm0, %ecx
cmpl %ecx, %eax
jle 0x3ee0
movq 0x38(%rbx), %rax
movq (%rax,%r14,8), %rdi
movq 0x20(%rdi), %rax
cmpb $0x0, 0x10(%rax)
jne 0x3ee0
callq 0x2636
incq %r14
movq 0x40(%rbx), %rdi
movslq 0x18(%rdi), %rax
cmpq %rax, %r14
jl 0x3eab
testl %eax, %eax
jle 0x40a3
leaq 0x8(%rbx), %r14
leaq 0x18(%rsp), %r15
movl %eax, %r12d
incq %r12
movq 0x70c2(%rip), %r13      # 0xafd0
movq 0x40(%rbx), %rdi
callq 0x4d50
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 0x3ffd
movq 0x38(%rbx), %rax
movq -0x10(%rax,%r12,8), %rax
movswl 0x30(%rdi), %edx
movq %rax, %rdi
movq %r14, %rsi
callq 0x2694
leal -0x2(%r12), %esi
movq %r13, %rdi
callq 0x22e0
movq %rax, %rbp
movl $0x32, %edx
movq %rax, %rdi
leaq 0x32e8(%rip), %rsi      # 0x725b
callq 0x21d0
movq 0x38(%rbx), %rax
movq -0x10(%rax,%r12,8), %rax
movq 0x20(%rax), %rsi
addq $0x8, %rsi
leaq 0x8(%rsp), %rdi
callq 0x4288
movq 0x8(%rsp), %rsi
movq 0x10(%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 0x8(%rsp), %rdi
cmpq %r15, %rdi
je 0x3fe6
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x21b0
movl 0x7e08(%rip), %eax      # 0xbdf4
addl %r12d, %eax
addl $-0x2, %eax
movl %eax, 0x7dfc(%rip)      # 0xbdf4
jmp 0x4096
movsd %xmm1, (%rsp)
callq 0x4d50
movq 0x40(%rbx), %rcx
movsd (%rsp), %xmm0
mulsd 0x10(%rcx), %xmm0
cvttsd2si %xmm0, %ecx
cmpl %ecx, %eax
jle 0x4096
movq 0x38(%rbx), %rax
movq -0x10(%rax,%r12,8), %rdi
movq 0x20(%rdi), %rax
cmpb $0x0, 0x10(%rax)
jne 0x4096
callq 0x2940
cmpq $0x2, %r12
jne 0x4096
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 0x4096
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 0x4d50
movq (%rsp), %rdi
movq %r15, %rsi
movq %r13, %r15
movq %rbp, %r13
leaq 0x3201(%rip), %rdx      # 0x728e
movl %eax, %ecx
xorl %eax, %eax
callq 0x4800
decq %r12
cmpq $0x1, %r12
jg 0x3f0e
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 0x40cc
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x21b0
movq %rbx, %rdi
callq 0x22f0