// File: /workspace/github_c_makefile_star2_O3/openshmem-org[P]openshmem-examples/c/bcast1.c
// Function: main
int
main(void)
{
    int i;
    long *target;
    long *source;
    int me, npes;

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

    source = (long *) shmem_malloc(npes * sizeof(*source));
    for (i = 0; i < npes; i += 1) {
        source[i] = i + 1;
    }

    target = (long *) shmem_malloc(npes * sizeof(*target));
    for (i = 0; i < npes; i += 1) {
        target[i] = -999;
    }

    for (i = 0; i < SHMEM_BCAST_SYNC_SIZE; i += 1) {
        pSync[i] = SHMEM_SYNC_VALUE;
    }
    shmem_barrier_all();

    shmem_broadcast64(target, source, npes, 0, 0, 0, npes, pSync);

    for (i = 0; i < npes; i++) {
        printf("%-8d %ld\n", me, target[i]);
    }

    shmem_barrier_all();

    shmem_free(target);
    shmem_free(source);
    shmem_finalize();

    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
callq 0x1090
callq 0x1060
movl %eax, %ebx
callq 0x1040
movl %eax, %ebp
movslq %eax, %r15
leaq (,%r15,8), %r12
movq %r12, %rdi
callq 0x1070
movq %rax, %r14
testl %r15d, %r15d
jle 0x133c
leal 0x1(%r15), %eax
leaq -0x1(%r15), %rcx
movq %rcx, %xmm0
pshufd $0x44, %xmm0, %xmm4     # xmm4 = xmm0[0,1,0,1]
shrl %eax
shlq $0x4, %rax
movdqa 0xdf4(%rip), %xmm0      # 0x2010
xorl %ecx, %ecx
movdqa 0xdfa(%rip), %xmm5      # 0x2020
pxor %xmm5, %xmm4
pcmpeqd %xmm1, %xmm1
movdqa %xmm0, %xmm2
pxor %xmm5, %xmm2
movdqa %xmm2, %xmm3
pcmpgtd %xmm4, %xmm3
pcmpeqd %xmm4, %xmm2
pshufd $0xf5, %xmm2, %xmm2     # xmm2 = xmm2[1,1,3,3]
pand %xmm3, %xmm2
pshufd $0xf5, %xmm3, %xmm3     # xmm3 = xmm3[1,1,3,3]
por %xmm2, %xmm3
movdqa %xmm0, %xmm2
psubq %xmm1, %xmm2
movd %xmm3, %edx
notl %edx
testb $0x1, %dl
je 0x126d
movq %xmm2, (%r14,%rcx)
pxor %xmm1, %xmm3
pextrw $0x4, %xmm3, %edx
testb $0x1, %dl
je 0x1287
pshufd $0xee, %xmm2, %xmm2     # xmm2 = xmm2[2,3,2,3]
movq %xmm2, 0x8(%r14,%rcx)
paddq 0xda1(%rip), %xmm0      # 0x2030
addq $0x10, %rcx
cmpq %rcx, %rax
jne 0x122e
movdqa %xmm4, (%rsp)
movq %r12, %rdi
callq 0x1070
movq %rax, %r12
testl %ebp, %ebp
jle 0x1347
leal 0x1(%r15), %eax
shrl %eax
shlq $0x4, %rax
movdqa 0xd4e(%rip), %xmm0      # 0x2010
xorl %ecx, %ecx
pcmpeqd %xmm1, %xmm1
movdqa (%rsp), %xmm5
movdqa 0xd4b(%rip), %xmm6      # 0x2020
movdqa 0xd53(%rip), %xmm7      # 0x2030
movdqa %xmm0, %xmm2
pxor %xmm6, %xmm2
movdqa %xmm2, %xmm3
pcmpgtd %xmm5, %xmm3
pcmpeqd %xmm5, %xmm2
pshufd $0xf5, %xmm2, %xmm4     # xmm4 = xmm2[1,1,3,3]
pand %xmm3, %xmm4
pshufd $0xf5, %xmm3, %xmm2     # xmm2 = xmm3[1,1,3,3]
por %xmm4, %xmm2
movd %xmm2, %edx
notl %edx
testb $0x1, %dl
je 0x1316
movq $-0x3e7, (%r12,%rcx)    # imm = 0xFC19
pxor %xmm1, %xmm2
pextrw $0x4, %xmm2, %edx
testb $0x1, %dl
je 0x132d
movq $-0x3e7, 0x8(%r12,%rcx) # imm = 0xFC19
paddq %xmm7, %xmm0
addq $0x10, %rcx
cmpq %rcx, %rax
jne 0x12dd
jmp 0x1347
movq %r12, %rdi
callq 0x1070
movq %rax, %r12
pcmpeqd %xmm0, %xmm0
movdqa %xmm0, 0x2d2d(%rip)     # 0x4080
leaq 0x2d26(%rip), %r13      # 0x4080
callq 0x1080
movq %r12, %rdi
movq %r14, %rsi
movq %r15, %rdx
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
pushq %r13
pushq %r15
callq 0x10b0
addq $0x10, %rsp
testl %r15d, %r15d
jle 0x13a3
leaq 0xcb7(%rip), %r13       # 0x2040
xorl %ebp, %ebp
movq (%r12,%rbp,8), %rdx
movq %r13, %rdi
movl %ebx, %esi
xorl %eax, %eax
callq 0x1030
incq %rbp
cmpq %rbp, %r15
jne 0x138b
callq 0x1080
movq %r12, %rdi
callq 0x10a0
movq %r14, %rdi
callq 0x10a0
callq 0x1050
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq