// File: /workspace/github_c_makefile_star2_O2/USArmyResearchLab[P]ARL_OpenSHMEM/src/autogen/shmem_int_sum_to_all.c
// Function: shmem_int_sum_to_all
void shmem_int_sum_to_all( int* dst, const int* src, int nreduce,
	int pe_start, int log_pe_stride, int pe_size, int* pwork, long* psync)
{
	debug("shmem_x_op_to_all begin");

	int pe_size_stride = pe_size << log_pe_stride;
	int pe_step = 0x1 << log_pe_stride;
	int pe_end = pe_size_stride + pe_start;
	int nreduced2p1 = (nreduce >> 1) + 1;

	int nwrk = (nreduced2p1 > (int)SHMEM_REDUCE_MIN_WRKDATA_SIZE) ?
		 nreduced2p1 : (int)SHMEM_REDUCE_MIN_WRKDATA_SIZE;

	int i, j, r;

	for (i = 0; i < nreduce; i++) {
		dst[i] = src[i];
	}

	int to = __shmem.my_pe;

	for(r = 1; r < pe_size; r++) {

		to += pe_step;
		if (to >= pe_end) to -= pe_size_stride;

		int* remote_work = (int*)shmem_ptr((void*)pwork, to);

		for(i = 0; i < nreduce; i += nwrk) {

			int nrem = nreduce - i;
			nrem = (nrem > nwrk) ? nwrk : nrem;

			for(j = 0; j < nrem; j++) {
				remote_work[j] = src[i+j];
			}

			shmem_barrier(pe_start, log_pe_stride, pe_size, psync);

			for(j = 0; j < nrem; j++) {
				dst[i+j] = __sum(dst[i+j],pwork[j]);
			}

			shmem_barrier(pe_start, log_pe_stride, pe_size, psync);

		}
	}

	debug("shmem_x_op_to_all end");
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movl %r9d, 0x4(%rsp)
movq %rcx, 0x10(%rsp)
movq %rsi, %rbx
movq %rdi, %r14
pushq $0x1
popq %r9
movl %r9d, %eax
movl %r8d, 0x8(%rsp)
movl %r8d, %ecx
shll %cl, %eax
movl %eax, 0x1c(%rsp)
movq 0x90(%rsp), %r13
movl %edx, %ecx
sarl %ecx
cmpl $0x8, %ecx
pushq $0x7
popq %rax
cmovgel %ecx, %eax
xorl %ecx, %ecx
testl %edx, %edx
movl $0x0, %edi
movl %edx, 0xc(%rsp)
cmovgl %edx, %edi
cmpq %rcx, %rdi
je 0x2f81
movl (%rbx,%rcx,4), %esi
movl %esi, (%r14,%rcx,4)
incq %rcx
jmp 0x2f70
movl 0x4(%rsp), %ecx
movl %ecx, %edx
movl 0x8(%rsp), %ecx
shll %cl, %edx
movq 0x10(%rsp), %rcx
movq %rdx, 0x28(%rsp)
addl %edx, %ecx
movl %ecx, 0x18(%rsp)
leal 0x1(%rax), %r12d
leaq 0x4258(%rip), %rcx      # 0x7200
movl 0x4(%rcx), %esi
movslq 0xc(%rsp), %rcx
movq %rcx, 0x50(%rsp)
movl %eax, %eax
leaq 0x4(,%rax,4), %rax
movq %rax, 0x40(%rsp)
movq %rbx, 0x38(%rsp)
movq %r14, 0x30(%rsp)
movq %r12, 0x48(%rsp)
cmpl 0x4(%rsp), %r9d
jge 0x30b5
movl %r9d, 0x24(%rsp)
addl 0x1c(%rsp), %esi
cmpl 0x18(%rsp), %esi
movq 0x28(%rsp), %rax
movl $0x0, %ecx
cmovll %ecx, %eax
subl %eax, %esi
movq %r13, %rdi
movl %esi, 0x20(%rsp)
callq 0x1ca8
movq %rax, %r15
xorl %ebp, %ebp
cmpq 0x50(%rsp), %rbp
jge 0x309a
movl 0xc(%rsp), %eax
subl %ebp, %eax
cmpl %r12d, %eax
cmovgel %r12d, %eax
movslq %eax, %r12
xorl %eax, %eax
cmpq %r12, %rax
jge 0x3039
movl (%rbx,%rax,4), %ecx
movl %ecx, (%r15,%rax,4)
incq %rax
jmp 0x3028
movq 0x10(%rsp), %rdi
movl 0x8(%rsp), %esi
movl 0x4(%rsp), %edx
movq 0x98(%rsp), %rcx
callq 0x30ec
xorl %eax, %eax
cmpq %r12, %rax
jge 0x3068
movl (%r13,%rax,4), %ecx
addl %ecx, (%r14,%rax,4)
incq %rax
jmp 0x3055
movq 0x10(%rsp), %rdi
movl 0x8(%rsp), %esi
movl 0x4(%rsp), %edx
movq 0x98(%rsp), %rcx
callq 0x30ec
movq 0x48(%rsp), %r12
addq %r12, %rbp
movq 0x40(%rsp), %rax
addq %rax, %rbx
addq %rax, %r14
jmp 0x300b
movl 0x24(%rsp), %r9d
incl %r9d
movq 0x38(%rsp), %rbx
movq 0x30(%rsp), %r14
movl 0x20(%rsp), %esi
jmp 0x2fd3
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq