// File: /workspace/github_c_makefile_star2_O3/USArmyResearchLab[P]ARL_OpenSHMEM/test/barrier.c
// Function: main
int main (void)
{
	int i, npe;
	static long pSyncA[SHMEM_BARRIER_SYNC_SIZE];
	static long pSyncB[SHMEM_BARRIER_SYNC_SIZE];
	for (i = 0; i < SHMEM_BARRIER_SYNC_SIZE; i++) {
		pSyncA[i] = SHMEM_SYNC_VALUE;
		pSyncB[i] = SHMEM_SYNC_VALUE;
	}

	shmem_init();
	int me = shmem_my_pe();
	int npes = shmem_n_pes();

	if (me == 0) {
		printf("# SHMEM Barrier times for variable NPES\n" \
			"# NPES\tLatency (nanoseconds)\n");
	}

	for (npe = 1; npe <= npes; npe++)
	{
		shmem_barrier_all();
		ctimer_start();

		unsigned int t = ctimer();
		if (me < npe) {
			for (i = 0; i < NLOOP; i += 2) {
				shmem_barrier(0, 0, npe, pSyncA);
				shmem_barrier(0, 0, npe, pSyncB);
			}
		}
		t -= ctimer();

		if (me == 0) {
			unsigned int nsec = ctimer_nsec(t / NLOOP);
			printf("%5d %7u\n", npe, nsec);
		}
	}
	shmem_finalize();

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
xorpd %xmm0, %xmm0
movapd %xmm0, 0x4da7(%rip)     # 0x6190
movapd %xmm0, 0x4d8f(%rip)     # 0x6180
movapd %xmm0, 0x4d77(%rip)     # 0x6170
movapd %xmm0, 0x4d5f(%rip)     # 0x6160
movapd %xmm0, 0x4d97(%rip)     # 0x61a0
movapd %xmm0, 0x4d9f(%rip)     # 0x61b0
movapd %xmm0, 0x4da7(%rip)     # 0x61c0
movapd %xmm0, 0x4daf(%rip)     # 0x61d0
callq 0x1618
leaq 0x4d13(%rip), %rax      # 0x6140
movl (%rax), %r15d
leaq 0x4d0d(%rip), %rax      # 0x6144
movl (%rax), %ebx
testl %r15d, %r15d
jne 0x144a
leaq 0x2be4(%rip), %rdi      # 0x4029
callq 0x1080
testl %ebx, %ebx
jle 0x15c0
movl $0x1, %r14d
leaq 0x4d01(%rip), %r12      # 0x6160
leaq 0x4d3a(%rip), %r13      # 0x61a0
movl %ebx, -0x2c(%rbp)
callq 0x160c
leaq 0x4d6b(%rip), %rdi      # 0x61e0
xorl %esi, %esi
callq 0x1120
leaq -0x40(%rbp), %rdi
xorl %esi, %esi
callq 0x1120
movq -0x40(%rbp), %rax
movq -0x38(%rbp), %rcx
subq 0x4d4a(%rip), %rax      # 0x61e0
xorps %xmm1, %xmm1
cvtsi2sd %rax, %xmm1
subq 0x4d43(%rip), %rcx      # 0x61e8
xorps %xmm0, %xmm0
cvtsi2sd %rcx, %xmm0
mulsd 0x2b53(%rip), %xmm0     # 0x4008
mulsd 0x2b53(%rip), %xmm1     # 0x4010
addsd %xmm0, %xmm1
movapd %xmm1, -0x60(%rbp)
subsd 0x2b4a(%rip), %xmm1     # 0x4018
movapd %xmm1, -0x50(%rbp)
movl %r15d, %ebx
cmpl %r14d, %r15d
jge 0x1509
movl $0xfffffffe, %r15d      # imm = 0xFFFFFFFE
xorl %edi, %edi
xorl %esi, %esi
movl %r14d, %edx
movq %r12, %rcx
callq 0x15d8
xorl %edi, %edi
xorl %esi, %esi
movl %r14d, %edx
movq %r13, %rcx
callq 0x15d8
addl $0x2, %r15d
cmpl $0x62, %r15d
jb 0x14e1
leaq -0x40(%rbp), %rdi
xorl %esi, %esi
callq 0x1120
movl %ebx, %r15d
testl %ebx, %ebx
jne 0x15ad
cvttsd2si -0x60(%rbp), %rcx
movq %rcx, %rdx
cvttsd2si -0x50(%rbp), %rax
sarq $0x3f, %rdx
andq %rdx, %rax
movq -0x40(%rbp), %rdx
movq -0x38(%rbp), %rsi
subq 0x4c9c(%rip), %rdx      # 0x61e0
xorps %xmm0, %xmm0
cvtsi2sd %rdx, %xmm0
subq 0x4c95(%rip), %rsi      # 0x61e8
xorps %xmm1, %xmm1
cvtsi2sd %rsi, %xmm1
orq %rcx, %rax
mulsd 0x2aa2(%rip), %xmm1     # 0x4008
mulsd 0x2aa2(%rip), %xmm0     # 0x4010
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %rcx
movq %rcx, %rdx
sarq $0x3f, %rdx
subsd 0x2a92(%rip), %xmm0     # 0x4018
cvttsd2si %xmm0, %rsi
andl %edx, %esi
orl %esi, %ecx
subl %eax, %ecx
imulq $0x51eb851f, %rcx, %rdx # imm = 0x51EB851F
shrq $0x25, %rdx
leaq 0x2a7d(%rip), %rdi      # 0x4020
movl %r14d, %esi
xorl %eax, %eax
callq 0x10f0
leal 0x1(%r14), %eax
movl -0x2c(%rbp), %ebx
cmpl %ebx, %r14d
movl %eax, %r14d
jne 0x1469
callq 0x1c19
xorl %eax, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop