// File: /workspace/github_c_makefile_star2_O1/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, 0x3d87(%rip)     # 0x5190
movapd %xmm0, 0x3d6f(%rip)     # 0x5180
movapd %xmm0, 0x3d57(%rip)     # 0x5170
movapd %xmm0, 0x3d3f(%rip)     # 0x5160
movapd %xmm0, 0x3d77(%rip)     # 0x51a0
movapd %xmm0, 0x3d7f(%rip)     # 0x51b0
movapd %xmm0, 0x3d87(%rip)     # 0x51c0
movapd %xmm0, 0x3d8f(%rip)     # 0x51d0
callq 0x1638
leaq 0x3cf3(%rip), %rax      # 0x5140
movl (%rax), %r15d
leaq 0x3ced(%rip), %rax      # 0x5144
movl (%rax), %ebx
testl %r15d, %r15d
jne 0x146a
leaq 0x1bc4(%rip), %rdi      # 0x3029
callq 0x1080
testl %ebx, %ebx
jle 0x15e0
movl $0x1, %r14d
leaq 0x3ce1(%rip), %r12      # 0x5160
leaq 0x3d1a(%rip), %r13      # 0x51a0
movl %ebx, -0x2c(%rbp)
callq 0x162c
leaq 0x3d4b(%rip), %rdi      # 0x51e0
xorl %esi, %esi
callq 0x1120
leaq -0x40(%rbp), %rdi
xorl %esi, %esi
callq 0x1120
movq -0x40(%rbp), %rax
movq -0x38(%rbp), %rcx
subq 0x3d2a(%rip), %rax      # 0x51e0
xorps %xmm1, %xmm1
cvtsi2sd %rax, %xmm1
subq 0x3d23(%rip), %rcx      # 0x51e8
xorps %xmm0, %xmm0
cvtsi2sd %rcx, %xmm0
mulsd 0x1b33(%rip), %xmm0     # 0x3008
mulsd 0x1b33(%rip), %xmm1     # 0x3010
addsd %xmm0, %xmm1
movapd %xmm1, -0x60(%rbp)
subsd 0x1b2a(%rip), %xmm1     # 0x3018
movapd %xmm1, -0x50(%rbp)
movl %r15d, %ebx
cmpl %r14d, %r15d
jge 0x1529
movl $0xfffffffe, %r15d      # imm = 0xFFFFFFFE
xorl %edi, %edi
xorl %esi, %esi
movl %r14d, %edx
movq %r12, %rcx
callq 0x15f8
xorl %edi, %edi
xorl %esi, %esi
movl %r14d, %edx
movq %r13, %rcx
callq 0x15f8
addl $0x2, %r15d
cmpl $0x62, %r15d
jb 0x1501
leaq -0x40(%rbp), %rdi
xorl %esi, %esi
callq 0x1120
movl %ebx, %r15d
testl %ebx, %ebx
jne 0x15cd
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 0x3c7c(%rip), %rdx      # 0x51e0
xorps %xmm0, %xmm0
cvtsi2sd %rdx, %xmm0
subq 0x3c75(%rip), %rsi      # 0x51e8
xorps %xmm1, %xmm1
cvtsi2sd %rsi, %xmm1
orq %rcx, %rax
mulsd 0x1a82(%rip), %xmm1     # 0x3008
mulsd 0x1a82(%rip), %xmm0     # 0x3010
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %rcx
movq %rcx, %rdx
sarq $0x3f, %rdx
subsd 0x1a72(%rip), %xmm0     # 0x3018
cvttsd2si %xmm0, %rsi
andl %edx, %esi
orl %esi, %ecx
subl %eax, %ecx
imulq $0x51eb851f, %rcx, %rdx # imm = 0x51EB851F
shrq $0x25, %rdx
leaq 0x1a5d(%rip), %rdi      # 0x3020
movl %r14d, %esi
xorl %eax, %eax
callq 0x10f0
leal 0x1(%r14), %eax
movl -0x2c(%rbp), %ebx
cmpl %ebx, %r14d
movl %eax, %r14d
jne 0x1489
callq 0x1bfe
xorl %eax, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop