// File: /workspace/github_c_makefile_star2_O2/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:
xorl %eax, %eax
leaq 0x3dfb(%rip), %rcx      # 0x5160
leaq 0x3e34(%rip), %rdx      # 0x51a0
cmpq $0x40, %rax
je 0x1382
andq $0x0, (%rax,%rcx)
andq $0x0, (%rax,%rdx)
addq $0x8, %rax
jmp 0x136c
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
callq 0x157c
leaq 0x3da1(%rip), %rax      # 0x5140
movl (%rax), %r15d
leaq 0x3d9b(%rip), %rax      # 0x5144
movl (%rax), %r14d
testl %r15d, %r15d
jne 0x13bd
leaq 0x1c71(%rip), %rdi      # 0x3029
callq 0x1080
xorl %eax, %eax
testl %r14d, %r14d
cmovlel %eax, %r14d
incl %r14d
pushq $0x1
popq %rbx
leaq 0x3d8d(%rip), %r12      # 0x5160
leaq 0x3dc6(%rip), %r13      # 0x51a0
movl %r14d, -0x2c(%rbp)
cmpl %r14d, %ebx
je 0x1525
callq 0x1570
leaq 0x3ded(%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 0x3dcc(%rip), %rax      # 0x51e0
cvtsi2sd %rax, %xmm1
subq 0x3dc8(%rip), %rcx      # 0x51e8
cvtsi2sd %rcx, %xmm0
mulsd 0x1bdb(%rip), %xmm0     # 0x3008
mulsd 0x1bdb(%rip), %xmm1     # 0x3010
addsd %xmm0, %xmm1
movapd %xmm1, -0x60(%rbp)
subsd 0x1bd2(%rip), %xmm1     # 0x3018
movapd %xmm1, -0x50(%rbp)
movl %r15d, %r14d
cmpl %ebx, %r15d
jge 0x147e
xorl %r15d, %r15d
cmpl $0x63, %r15d
ja 0x147e
xorl %edi, %edi
xorl %esi, %esi
movl %ebx, %edx
movq %r12, %rcx
callq 0x153c
xorl %edi, %edi
xorl %esi, %esi
movl %ebx, %edx
movq %r13, %rcx
callq 0x153c
addl $0x2, %r15d
jmp 0x1456
leaq -0x40(%rbp), %rdi
xorl %esi, %esi
callq 0x1120
movl %r14d, %r15d
testl %r14d, %r14d
jne 0x151a
cvttsd2si -0x60(%rbp), %rax
movq %rax, %rdx
sarq $0x3f, %rdx
cvttsd2si -0x50(%rbp), %rcx
andq %rdx, %rcx
movq -0x40(%rbp), %rdx
movq -0x38(%rbp), %rsi
subq 0x3d26(%rip), %rdx      # 0x51e0
cvtsi2sd %rdx, %xmm0
subq 0x3d22(%rip), %rsi      # 0x51e8
orq %rax, %rcx
cvtsi2sd %rsi, %xmm1
mulsd 0x1b32(%rip), %xmm1     # 0x3008
mulsd 0x1b32(%rip), %xmm0     # 0x3010
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %rax
movq %rax, %rdx
subsd 0x1b26(%rip), %xmm0     # 0x3018
cvttsd2si %xmm0, %rsi
sarq $0x3f, %rdx
andl %edx, %esi
orl %esi, %eax
subl %ecx, %eax
xorl %edx, %edx
pushq $0x64
popq %rcx
divl %ecx
leaq 0x1b11(%rip), %rdi      # 0x3020
movl %ebx, %esi
movl %eax, %edx
xorl %eax, %eax
callq 0x10f0
incl %ebx
movl -0x2c(%rbp), %r14d
jmp 0x13de
callq 0x1b75
xorl %eax, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop