// File: /workspace/github_c_makefile_star2_O0/USArmyResearchLab[P]ARL_OpenSHMEM/test/broadcast32.c
// Function: main
int main (void)
{
	int i, elements;
	static long pSyncA[SHMEM_BCAST_SYNC_SIZE];
	static long pSyncB[SHMEM_BCAST_SYNC_SIZE];
	for (i = 0; i < SHMEM_BCAST_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();

	int* source = (int*)shmem_malloc(NELEMENT * sizeof (*source));
	int* target = (int*)shmem_malloc(NELEMENT * sizeof (*target));

	if (me == 0) {
		printf("# SHMEM Broadcast32 times for NPES = %d\n" \
			"# Bytes\tLatency (nanoseconds)\n", npes);
	}

	for (elements = 1; elements <= NELEMENT; elements <<= 1)
	{
		// reset values for each iteration
		for (i = 0; i < NELEMENT; i++) {
			source[i] = i + 1;
			target[i] = -90;
		}
		shmem_barrier_all();
		ctimer_start();

		unsigned int t = ctimer();
		for (i = 0; i < NLOOP; i += 2) {
			shmem_broadcast32 (target, source, elements, 0, 0, 0, npes, pSyncA);
			shmem_broadcast32 (target, source, elements, 0, 0, 0, npes, pSyncB);
		}
		t -= ctimer();

		if (me == 0) {
			unsigned int bytes = elements * sizeof(*source);
			unsigned int nsec = ctimer_nsec(t / NLOOP);
			printf("%5d %7u\n", bytes, nsec);
		}
		else {
			int err = 0;
			for (i = 0; i < elements; i++) if (target[i] != source[i]) err++;
			for (i = elements; i < NELEMENT; i++) if (target[i] != -90) err++;
			if (err) printf("# %d: ERROR: %d incorrect value(s) copied\n", me, err);
		}
	}

	shmem_free(target);
	shmem_free(source);

	shmem_finalize();

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movl $0x0, -0x34(%rbp)
movl $0x0, -0x38(%rbp)
movslq -0x38(%rbp), %rax
cmpq $0x8, %rax
jae 0x13a4
movslq -0x38(%rbp), %rcx
leaq 0x5de2(%rip), %rax      # 0x7160
movq $0x0, (%rax,%rcx,8)
movslq -0x38(%rbp), %rcx
leaq 0x5e0f(%rip), %rax      # 0x71a0
movq $0x0, (%rax,%rcx,8)
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x1369
callq 0x1750
leaq 0x5d88(%rip), %rax      # 0x7138
movl (%rax), %eax
movl %eax, -0x40(%rbp)
leaq 0x5d80(%rip), %rax      # 0x713c
movl (%rax), %eax
movl %eax, -0x44(%rbp)
movl $0x2000, %edi           # imm = 0x2000
callq 0x20f0
movq %rax, -0x50(%rbp)
movl $0x2000, %edi           # imm = 0x2000
callq 0x20f0
movq %rax, -0x58(%rbp)
cmpl $0x0, -0x40(%rbp)
jne 0x13f4
movl -0x44(%rbp), %esi
leaq 0x3c33(%rip), %rdi      # 0x5020
movb $0x0, %al
callq 0x10f0
movl $0x1, -0x3c(%rbp)
cmpl $0x800, -0x3c(%rbp)     # imm = 0x800
jg 0x16b9
movl $0x0, -0x38(%rbp)
cmpl $0x800, -0x38(%rbp)     # imm = 0x800
jge 0x1443
movl -0x38(%rbp), %edx
addl $0x1, %edx
movq -0x50(%rbp), %rax
movslq -0x38(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movq -0x58(%rbp), %rax
movslq -0x38(%rbp), %rcx
movl $0xffffffa6, (%rax,%rcx,4) # imm = 0xFFFFFFA6
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x140f
callq 0x1710
callq 0x16e0
xorl %eax, %eax
movl %eax, %esi
leaq -0x18(%rbp), %rdi
callq 0x1120
movq 0x5d7f(%rip), %rdx      # 0x71e0
movq -0x18(%rbp), %rcx
movq -0x10(%rbp), %rax
subq %rdx, %rcx
cvtsi2sd %rcx, %xmm0
movq 0x5d70(%rip), %rcx      # 0x71e8
subq %rcx, %rax
cvtsi2sd %rax, %xmm1
movsd 0x3b80(%rip), %xmm2     # 0x5008
mulsd %xmm2, %xmm1
movsd 0x3b7c(%rip), %xmm2     # 0x5010
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movaps %xmm0, %xmm1
cvttsd2si %xmm1, %rax
movq %rax, %rdx
sarq $0x3f, %rdx
movsd 0x3b65(%rip), %xmm1     # 0x5018
subsd %xmm1, %xmm0
cvttsd2si %xmm0, %rcx
andq %rdx, %rcx
orq %rcx, %rax
movq %rax, -0x8(%rbp)
movq $-0x1, %rax
subq -0x8(%rbp), %rax
movl %eax, -0x5c(%rbp)
movl $0x0, -0x38(%rbp)
cmpl $0xa, -0x38(%rbp)
jge 0x1548
movq -0x58(%rbp), %rdi
movq -0x50(%rbp), %rsi
movslq -0x3c(%rbp), %rdx
movl -0x44(%rbp), %r10d
xorl %r9d, %r9d
leaq 0x5c65(%rip), %rax      # 0x7160
movl %r9d, %ecx
movl %r9d, %r8d
movl %r10d, (%rsp)
movq %rax, 0x8(%rsp)
callq 0x42f0
movq -0x58(%rbp), %rdi
movq -0x50(%rbp), %rsi
movslq -0x3c(%rbp), %rdx
movl -0x44(%rbp), %r10d
xorl %r9d, %r9d
leaq 0x5c77(%rip), %rax      # 0x71a0
movl %r9d, %ecx
movl %r9d, %r8d
movl %r10d, (%rsp)
movq %rax, 0x8(%rsp)
callq 0x42f0
movl -0x38(%rbp), %eax
addl $0x2, %eax
movl %eax, -0x38(%rbp)
jmp 0x14db
xorl %eax, %eax
movl %eax, %esi
leaq -0x30(%rbp), %rdi
callq 0x1120
movq 0x5c84(%rip), %rdx      # 0x71e0
movq -0x30(%rbp), %rcx
movq -0x28(%rbp), %rax
subq %rdx, %rcx
cvtsi2sd %rcx, %xmm0
movq 0x5c75(%rip), %rcx      # 0x71e8
subq %rcx, %rax
cvtsi2sd %rax, %xmm1
movsd 0x3a85(%rip), %xmm2     # 0x5008
mulsd %xmm2, %xmm1
movsd 0x3a81(%rip), %xmm2     # 0x5010
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movaps %xmm0, %xmm1
cvttsd2si %xmm1, %rax
movq %rax, %rdx
sarq $0x3f, %rdx
movsd 0x3a6a(%rip), %xmm1     # 0x5018
subsd %xmm1, %xmm0
cvttsd2si %xmm0, %rcx
andq %rdx, %rcx
orq %rcx, %rax
movq %rax, -0x20(%rbp)
movq $-0x1, %rcx
subq -0x20(%rbp), %rcx
movl -0x5c(%rbp), %eax
subq %rcx, %rax
movl %eax, -0x5c(%rbp)
cmpl $0x0, -0x40(%rbp)
jne 0x1617
movslq -0x3c(%rbp), %rax
shlq $0x2, %rax
movl %eax, -0x60(%rbp)
movl -0x5c(%rbp), %eax
movl $0xa, %ecx
xorl %edx, %edx
divl %ecx
movl %eax, %eax
movl %eax, %edi
callq 0x1700
movl %eax, -0x64(%rbp)
movl -0x60(%rbp), %esi
movl -0x64(%rbp), %edx
leaq 0x3a5c(%rip), %rdi      # 0x5067
movb $0x0, %al
callq 0x10f0
jmp 0x16aa
movl $0x0, -0x68(%rbp)
movl $0x0, -0x38(%rbp)
movl -0x38(%rbp), %eax
cmpl -0x3c(%rbp), %eax
jge 0x165b
movq -0x58(%rbp), %rax
movslq -0x38(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movq -0x50(%rbp), %rcx
movslq -0x38(%rbp), %rdx
cmpl (%rcx,%rdx,4), %eax
je 0x164e
movl -0x68(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x68(%rbp)
jmp 0x1650
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x1625
movl -0x3c(%rbp), %eax
movl %eax, -0x38(%rbp)
cmpl $0x800, -0x38(%rbp)     # imm = 0x800
jge 0x168e
movq -0x58(%rbp), %rax
movslq -0x38(%rbp), %rcx
cmpl $-0x5a, (%rax,%rcx,4)
je 0x1681
movl -0x68(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x68(%rbp)
jmp 0x1683
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x1661
cmpl $0x0, -0x68(%rbp)
je 0x16a8
movl -0x40(%rbp), %esi
movl -0x68(%rbp), %edx
leaq 0x39cf(%rip), %rdi      # 0x5070
movb $0x0, %al
callq 0x10f0
jmp 0x16aa
jmp 0x16ac
movl -0x3c(%rbp), %eax
shll %eax
movl %eax, -0x3c(%rbp)
jmp 0x13fb
movq -0x58(%rbp), %rdi
callq 0x1720
movq -0x50(%rbp), %rdi
callq 0x1720
callq 0x20e0
xorl %eax, %eax
addq $0x80, %rsp
popq %rbp
retq
nopl (%rax,%rax)