// File: /workspace/github_c_makefile_star2_O0/xtanitfy[P]Murphy/src/layers/conv_layer.c
// Function: ConvLayerForward
int ConvLayerForward(NET_PARA_s *pNetPara,LAYER_s *pLayer)
{
	CONV_LAYER_s *pConvLayer = (CONV_LAYER_s *)pLayer->currLayer;
	BLOB_s *pData = pLayer->pData;
	
	CONV_LAYER_PARA_s *pPara = &pLayer->para->select.convLayer;

	BLOB_s *pPrevData = pLayer->pPrev[0]->pData;
	
	BLOB_DATA_PTR(pLayer->pData,ptrCurr);
	BLOB_DATA_PTR(pLayer->k,ptrK);
	BLOB_DATA_PTR(pPrevData,ptrPrevData);
	BLOB_DATA_PTR(pLayer->b,ptrB);

	//CalTimeStart();
	int blockMinX = 0,blockMinY = 0;
	int ytmp = pPara->kernelY-1;
	int xtmp = pPara->kernelX-1;
	double tmp = 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 h = 0;h < pConvLayer->imgheight;h++) {
				for (int w = 0;w < pConvLayer->imgWidth;w++) {
					tmp = 0;
					blockMinY = h*pPara->strideY;
					blockMinX = w*pPara->strideX;
					for (int i_in = 0;i_in < pPrevData->channelSize;i_in++) {
						for (int offsetY = blockMinY;offsetY < (blockMinY + pPara->kernelY);offsetY++) {
							for (int offsetX = blockMinX;offsetX < (blockMinX + pPara->kernelX);offsetX++) {	
								tmp += ptrK[i_out][i_in][ytmp-offsetY+blockMinY][xtmp-offsetX+blockMinX] * \
										ptrPrevData[i_batch][i_in][offsetY][offsetX];
								
							}
						}
					}	
					ptrCurr[i_batch][i_out][h][w]  = pPara->function(tmp + \
								ptrB[0][i_out][0][0],FUNC_VALUE);

				}
		
			}
			
		}
	}
	
	//CalTimeEnd("conv");

#if 0
	static int cnt = 0;
	cnt++;
	if (cnt == 1) {
		LOG_writeBlobToTxtFile("murphy_conv1.txt",pData);
		LOG_writeBlobToBinFile("murphy_conv1.bin",pData);
		LOG_compBinFile("murphy_conv1.bin","a1.bin",sizeof(BLOB_DATA_TYPE)*pData->size);
	}
#endif
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xf0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
addq $0x288, %rax            # imm = 0x288
movq %rax, -0x28(%rbp)
movq -0x10(%rbp), %rax
movq 0xa8(%rax), %rax
movq 0x10(%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq 0x18(%rax), %rax
movq %rax, -0xe8(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq 0x20(%rax), %rax
movq %rax, -0xe0(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq 0x28(%rax), %rax
movq %rax, -0xd8(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq 0x8(%rax), %rax
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq 0x18(%rax), %rax
movq %rax, -0xd0(%rbp)
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq 0x20(%rax), %rax
movq %rax, -0xc8(%rbp)
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq 0x28(%rax), %rax
movq %rax, -0xc0(%rbp)
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq 0x8(%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0xb8(%rbp)
movq -0x30(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0xb0(%rbp)
movq -0x30(%rbp), %rax
movq 0x28(%rax), %rax
movq %rax, -0xa8(%rbp)
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x48(%rbp)
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movq 0x18(%rax), %rax
movq %rax, -0xa0(%rbp)
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movq 0x20(%rax), %rax
movq %rax, -0x98(%rbp)
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movq 0x28(%rax), %rax
movq %rax, -0x90(%rbp)
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movq 0x8(%rax), %rax
movq %rax, -0x50(%rbp)
movl $0x0, -0x54(%rbp)
movl $0x0, -0x58(%rbp)
movq -0x28(%rbp), %rax
movl 0x8(%rax), %eax
subl $0x1, %eax
movl %eax, -0x5c(%rbp)
movq -0x28(%rbp), %rax
movl 0x4(%rax), %eax
subl $0x1, %eax
movl %eax, -0x60(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x68(%rbp)
movl $0x0, -0x6c(%rbp)
movslq -0x6c(%rbp), %rax
movq -0x20(%rbp), %rcx
cmpq 0x10(%rcx), %rax
jae 0x7900
movl $0x0, -0x70(%rbp)
movslq -0x70(%rbp), %rax
movq -0x20(%rbp), %rcx
cmpq 0x18(%rcx), %rax
jae 0x78f0
movl $0x0, -0x74(%rbp)
movl -0x74(%rbp), %eax
movq -0x18(%rbp), %rcx
cmpl 0x8(%rcx), %eax
jge 0x78e0
movl $0x0, -0x78(%rbp)
movl -0x78(%rbp), %eax
movq -0x18(%rbp), %rcx
cmpl 0x4(%rcx), %eax
jge 0x78d0
xorps %xmm0, %xmm0
movsd %xmm0, -0x68(%rbp)
movl -0x74(%rbp), %eax
movq -0x28(%rbp), %rcx
imull 0x10(%rcx), %eax
movl %eax, -0x58(%rbp)
movl -0x78(%rbp), %eax
movq -0x28(%rbp), %rcx
imull 0xc(%rcx), %eax
movl %eax, -0x54(%rbp)
movl $0x0, -0x7c(%rbp)
movslq -0x7c(%rbp), %rax
movq -0x30(%rbp), %rcx
cmpq 0x18(%rcx), %rax
jae 0x780e
movl -0x58(%rbp), %eax
movl %eax, -0x80(%rbp)
movl -0x80(%rbp), %eax
movl -0x58(%rbp), %ecx
movq -0x28(%rbp), %rdx
addl 0x8(%rdx), %ecx
cmpl %ecx, %eax
jge 0x77fe
movl -0x54(%rbp), %eax
movl %eax, -0x84(%rbp)
movl -0x84(%rbp), %eax
movl -0x54(%rbp), %ecx
movq -0x28(%rbp), %rdx
addl 0x4(%rdx), %ecx
cmpl %ecx, %eax
jge 0x77ee
movq -0xa8(%rbp), %rdx
movq -0xb0(%rbp), %rsi
movq -0xb8(%rbp), %rdi
movq -0xc0(%rbp), %r8
movq -0xc8(%rbp), %r9
movq -0xd0(%rbp), %r10
movq -0x40(%rbp), %rax
movslq -0x70(%rbp), %rcx
imulq %r9, %r10
imulq %r8, %r10
imulq %r10, %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movslq -0x7c(%rbp), %rcx
imulq %r8, %r9
imulq %r9, %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movl -0x5c(%rbp), %ecx
subl -0x80(%rbp), %ecx
addl -0x58(%rbp), %ecx
movslq %ecx, %rcx
imulq %r8, %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movl -0x60(%rbp), %ecx
subl -0x84(%rbp), %ecx
addl -0x54(%rbp), %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x48(%rbp), %rax
movslq -0x6c(%rbp), %rcx
imulq %rsi, %rdi
imulq %rdx, %rdi
imulq %rdi, %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movslq -0x7c(%rbp), %rcx
imulq %rdx, %rsi
imulq %rsi, %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movslq -0x80(%rbp), %rcx
imulq %rdx, %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movslq -0x84(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm2
movsd -0x68(%rbp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x68(%rbp)
movl -0x84(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x84(%rbp)
jmp 0x76e4
jmp 0x77f0
movl -0x80(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x80(%rbp)
jmp 0x76c6
jmp 0x7800
movl -0x7c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x7c(%rbp)
jmp 0x76ae
movq -0x90(%rbp), %rdx
movq -0x98(%rbp), %rdi
movq -0xa0(%rbp), %rsi
movq -0x28(%rbp), %rax
movq 0x18(%rax), %rax
movsd -0x68(%rbp), %xmm0
movq -0x50(%rbp), %rcx
imulq %rdi, %rsi
imulq %rdx, %rsi
imulq $0x0, %rsi, %rsi
shlq $0x3, %rsi
addq %rsi, %rcx
movslq -0x70(%rbp), %rsi
imulq %rdx, %rdi
imulq %rdi, %rsi
shlq $0x3, %rsi
addq %rsi, %rcx
imulq $0x0, %rdx, %rdx
addsd (%rcx,%rdx,8), %xmm0
xorl %edi, %edi
callq *%rax
movq -0xe8(%rbp), %rdi
movq -0xe0(%rbp), %rsi
movq -0xd8(%rbp), %rdx
movq -0x38(%rbp), %rax
movslq -0x6c(%rbp), %rcx
imulq %rsi, %rdi
imulq %rdx, %rdi
imulq %rdi, %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movslq -0x70(%rbp), %rcx
imulq %rdx, %rsi
imulq %rsi, %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movslq -0x74(%rbp), %rcx
imulq %rdx, %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movslq -0x78(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0x78(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x78(%rbp)
jmp 0x7673
jmp 0x78d2
movl -0x74(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x74(%rbp)
jmp 0x765c
jmp 0x78e2
movl -0x70(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x70(%rbp)
jmp 0x7643
jmp 0x78f2
movl -0x6c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x6c(%rbp)
jmp 0x762a
xorl %eax, %eax
addq $0xf0, %rsp
popq %rbp
retq
nopl (%rax,%rax)