// File: /workspace/github_c_makefile_star2_O1/xtanitfy[P]Murphy/src/layers/samp_layer.c
// Function: SampLayerForward
int SampLayerForward(NET_PARA_s *pNetPara,LAYER_s *pLayer)
{
	SAMP_LAYER_PARA_s *pPara = &pLayer->para->select.sampLayer;

	BLOB_s *pPrevBlob = pLayer->pPrev[0]->pData;
	int nx =  pPrevBlob->widthSize/ pPara->stride;
	int ny =  pPrevBlob->heightSize/ pPara->stride;

	BLOB_s *pData = pLayer->pData;
	BLOB_DATA_PTR(pData,ptrCurr);
	BLOB_DATA_PTR(pPrevBlob,ptrPrev);
	double scale = (double)1 / (pPara->stride * pPara->stride);
	int xStart = 0,yStart = 0;
	
	
	for (int i_batch = 0;i_batch < pData->numSize;i_batch++) {
		for (int i_out = 0;i_out < pData->channelSize;i_out++) {
			for (int y =0;y < ny;y++) {
				for (int x = 0;x < nx;x++) {
					yStart = y * pPara->stride;
					xStart = x * pPara->stride;
					ptrCurr[i_batch][i_out][y][x] = 0;
					for (int by = yStart; by < yStart + pPara->stride;by++) {
						for (int bx = xStart; bx < xStart + pPara->stride;bx++) {
							ptrCurr[i_batch][i_out][y][x] += \
									ptrPrev[i_batch][i_out][by][bx] * scale;
						}
					}
				}
			}
		}
	}
	
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x20, %rsp
movq 0x10(%rsi), %rdi
movq 0x10(%rdi), %rax
movq %rax, -0x30(%rsp)
testq %rax, %rax
je 0x6daf
movq 0xa8(%rsi), %rax
movq 0x10(%rax), %rax
movq 0x28(%rax), %rcx
movq 0x8(%rsi), %rdx
movslq 0x28c(%rdx), %r9
movq 0x20(%rax), %rsi
movq 0x18(%rdi), %r8
movq 0x28(%rdi), %r10
movq 0x8(%rdi), %rdx
movq %rdx, -0x40(%rsp)
movq 0x8(%rax), %rdx
movq %rdx, -0x58(%rsp)
movl %r9d, %edx
imull %r9d, %edx
cvtsi2sd %edx, %xmm1
movq 0x18(%rax), %r11
movsd 0x177b(%rip), %xmm0     # 0x8320
divsd %xmm1, %xmm0
movabsq $0x100000000, %r12      # imm = 0x100000000
movq $0x0, -0x80(%rsp)
movq %rsi, %rax
xorl %edx, %edx
divq %r9
movq %rax, %rbx
movq %rcx, %rax
xorl %edx, %edx
divq %r9
movq 0x20(%rdi), %rdx
movq %r10, -0x8(%rsp)
imulq %r10, %rdx
movq %rdx, -0x28(%rsp)
movq %r8, -0x50(%rsp)
imulq %r8, %rdx
movq %rdx, -0x48(%rsp)
movq %rax, 0x10(%rsp)
cltq
movq %rax, 0x18(%rsp)
imulq %rcx, %rsi
imulq %rsi, %r11
shlq $0x3, %r11
movq %r11, -0x38(%rsp)
shlq $0x3, %rsi
movq %rsi, -0x10(%rsp)
shlq $0x3, %rcx
movq %rbx, -0x18(%rsp)
movslq %ebx, %rax
movq %rax, 0x8(%rsp)
cmpq $0x0, -0x50(%rsp)
je 0x6d8d
movq -0x48(%rsp), %rax
imulq -0x80(%rsp), %rax
movq -0x40(%rsp), %rdx
leaq (%rdx,%rax,8), %rax
movq %rax, -0x20(%rsp)
movq -0x58(%rsp), %rax
movq %rax, -0x70(%rsp)
movq $0x0, -0x78(%rsp)
cmpl $0x0, -0x18(%rsp)
jle 0x6d66
movq -0x28(%rsp), %rax
imulq -0x78(%rsp), %rax
movq -0x20(%rsp), %rdx
leaq (%rdx,%rax,8), %rax
movq %rax, (%rsp)
movq $0x0, -0x68(%rsp)
xorl %eax, %eax
movl %eax, %eax
movq %rax, -0x60(%rsp)
cmpl $0x0, 0x10(%rsp)
jle 0x6d46
movq %rcx, %rsi
imulq -0x60(%rsp), %rsi
movq -0x68(%rsp), %rdi
movq %rdi, %rdx
imulq %r9, %rdx
movq -0x8(%rsp), %rax
imulq %rdi, %rax
movq (%rsp), %rdi
leaq (%rdi,%rax,8), %rdi
addq %r9, %rdx
addq -0x70(%rsp), %rsi
xorl %eax, %eax
xorl %r11d, %r11d
movq $0x0, (%rdi,%rax,8)
testl %r9d, %r9d
jle 0x6d39
movl %r11d, %r10d
leaq (%rsi,%r10,8), %rbx
shlq $0x20, %r10
addq %r12, %r10
movq %rax, %r15
imulq %r9, %r15
addq %r9, %r15
movsd (%rdi,%rax,8), %xmm1
movq -0x60(%rsp), %r8
movq %r10, %r13
movq %rbx, %rbp
movsd (%rbp), %xmm2
mulsd %xmm0, %xmm2
addsd %xmm2, %xmm1
movsd %xmm1, (%rdi,%rax,8)
movq %r13, %r14
sarq $0x20, %r14
addq $0x8, %rbp
addq %r12, %r13
cmpq %r15, %r14
jl 0x6d06
incq %r8
movslq %r8d, %r13
addq %rcx, %rbx
cmpq %rdx, %r13
jl 0x6d00
incq %rax
addl %r9d, %r11d
cmpq 0x18(%rsp), %rax
jl 0x6cd1
movq -0x68(%rsp), %rsi
incq %rsi
movq -0x60(%rsp), %rax
addl %r9d, %eax
movq %rsi, -0x68(%rsp)
cmpq 0x8(%rsp), %rsi
jl 0x6c8c
movq -0x78(%rsp), %rdx
incq %rdx
movq -0x70(%rsp), %rax
addq -0x10(%rsp), %rax
movq %rax, -0x70(%rsp)
movq %rdx, -0x78(%rsp)
cmpq -0x50(%rsp), %rdx
jne 0x6c5e
movq -0x80(%rsp), %rdx
incq %rdx
movq -0x38(%rsp), %rax
addq %rax, -0x58(%rsp)
movq %rdx, -0x80(%rsp)
cmpq -0x30(%rsp), %rdx
jne 0x6c26
xorl %eax, %eax
addq $0x20, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq