// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x60, %rsp
movq 0x18(%rbp), %rax
movq 0x10(%rbp), %rax
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl %ecx, -0x18(%rbp)
movl %r8d, -0x1c(%rbp)
movl %r9d, -0x20(%rbp)
movl -0x20(%rbp), %eax
movl -0x1c(%rbp), %ecx
shll %cl, %eax
movl %eax, -0x24(%rbp)
movl -0x1c(%rbp), %ecx
movl $0x1, %eax
shll %cl, %eax
movl %eax, -0x28(%rbp)
movl -0x24(%rbp), %eax
addl -0x18(%rbp), %eax
movl %eax, -0x2c(%rbp)
movl -0x14(%rbp), %eax
sarl %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
cmpl $0x8, -0x30(%rbp)
jle 0x43d0
movl -0x30(%rbp), %eax
movl %eax, -0x58(%rbp)
jmp 0x43da
movl $0x8, %eax
movl %eax, -0x58(%rbp)
jmp 0x43da
movl -0x58(%rbp), %eax
movl %eax, -0x34(%rbp)
movl $0x0, -0x38(%rbp)
movl -0x38(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x4410
movq -0x10(%rbp), %rax
movslq -0x38(%rbp), %rcx
movl (%rax,%rcx,4), %edx
movq -0x8(%rbp), %rax
movslq -0x38(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x43e7
leaq 0x2dd9(%rip), %rax      # 0x71f0
movl 0x4(%rax), %eax
movl %eax, -0x44(%rbp)
movl $0x1, -0x40(%rbp)
movl -0x40(%rbp), %eax
cmpl -0x20(%rbp), %eax
jge 0x4550
movl -0x28(%rbp), %eax
addl -0x44(%rbp), %eax
movl %eax, -0x44(%rbp)
movl -0x44(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jl 0x444c
movl -0x24(%rbp), %ecx
movl -0x44(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x44(%rbp)
movq 0x10(%rbp), %rdi
movl -0x44(%rbp), %esi
callq 0x21a0
movq %rax, -0x50(%rbp)
movl $0x0, -0x38(%rbp)
movl -0x38(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x4540
movl -0x14(%rbp), %eax
subl -0x38(%rbp), %eax
movl %eax, -0x54(%rbp)
movl -0x54(%rbp), %eax
cmpl -0x34(%rbp), %eax
jle 0x4488
movl -0x34(%rbp), %eax
movl %eax, -0x5c(%rbp)
jmp 0x448e
movl -0x54(%rbp), %eax
movl %eax, -0x5c(%rbp)
movl -0x5c(%rbp), %eax
movl %eax, -0x54(%rbp)
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
cmpl -0x54(%rbp), %eax
jge 0x44c9
movq -0x10(%rbp), %rax
movl -0x38(%rbp), %ecx
addl -0x3c(%rbp), %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %edx
movq -0x50(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x449b
movl -0x18(%rbp), %edi
movl -0x1c(%rbp), %esi
movl -0x20(%rbp), %edx
movq 0x18(%rbp), %rcx
callq 0x45a0
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
cmpl -0x54(%rbp), %eax
jge 0x4520
movq -0x8(%rbp), %rax
movl -0x38(%rbp), %ecx
addl -0x3c(%rbp), %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %edx
movq 0x10(%rbp), %rax
movslq -0x3c(%rbp), %rcx
addl (%rax,%rcx,4), %edx
movq -0x8(%rbp), %rax
movl -0x38(%rbp), %ecx
addl -0x3c(%rbp), %ecx
movslq %ecx, %rcx
movl %edx, (%rax,%rcx,4)
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x44e2
movl -0x18(%rbp), %edi
movl -0x1c(%rbp), %esi
movl -0x20(%rbp), %edx
movq 0x18(%rbp), %rcx
callq 0x45a0
movl -0x34(%rbp), %eax
addl -0x38(%rbp), %eax
movl %eax, -0x38(%rbp)
jmp 0x4463
jmp 0x4542
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0x4424
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)