// File: /workspace/github_c_makefile_star2_O3/xtanitfy[P]Murphy/src/net.c
// Function: NETForward
static int NETForward(void *usr,int idCurr,int *idPrev,int nIdPrev)
{
	NET_s *pNet = (NET_s *)usr;
	CHECK_EXPR_RET(pNet == NULL,-1);
		
	LAYER_s *pLayerCurr = pNet->layers[idCurr];
	CHECK_EXPR_RET(pLayerCurr == NULL,-1);

	CHECK_EXPR_RET(pLayerCurr->forward == NULL,-1);
	for (int i = 0;i < nIdPrev;i++) {
		pLayerCurr->pPrev[i] = pNet->layers[idPrev[i]];
	}
	pLayerCurr->nPrev = nIdPrev;

	CalTimeStart();
	CHECK_EXPR_RET(pLayerCurr->forward == NULL,-1);
	int ret = pLayerCurr->forward(&pNet->para,pLayerCurr);
	CHECK_EXPR_RET(ret != 0,-1);
	CalTimeEnd(pLayerCurr->para->name);
	
#if defined(DEBUG)
	BLOB_s *pData = pLayerCurr->pData;
	char filename[128];
	pData->type =  BLOB_TYPE_DATA;
	snprintf(filename,sizeof(filename),"%s_data.txt",pLayerCurr->para->name);
	LOG_writeBlobToTxtFile(filename,pData);
	
	BLOB_s *pK = pLayerCurr->k;
	if (pK != NULL) {
		pK->type = BLOB_TYPE_WEIGHT;
		snprintf(filename,sizeof(filename),"%s_k.txt",pLayerCurr->para->name);
		LOG_writeBlobToTxtFile(filename,pK);
	}

	BLOB_s *pB = pLayerCurr->b;
	if (pB != NULL) {
		pB->type = BLOB_TYPE_BIAS;
		snprintf(filename,sizeof(filename),"%s_b.txt",pLayerCurr->para->name);
		LOG_writeBlobToTxtFile(filename,pB);
	}
#endif

	return 0;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x80, %rsp
testq %rdi, %rdi
je 0x3683
movq %rdi, %r14
movslq %esi, %rax
movq 0x240(%rdi,%rax,8), %rbx
testq %rbx, %rbx
je 0x369f
cmpq $0x0, 0x50(%rbx)
je 0x36bb
testl %ecx, %ecx
jle 0x363f
movl %ecx, %eax
xorl %esi, %esi
movslq (%rdx,%rsi,4), %rdi
movq 0x240(%r14,%rdi,8), %rdi
movq %rdi, 0xa8(%rbx,%rsi,8)
incq %rsi
cmpq %rsi, %rax
jne 0x3623
movl %ecx, 0xe8(%rbx)
callq 0x3b50
movq 0x50(%rbx), %rax
testq %rax, %rax
je 0x36d7
movq %r14, %rdi
movq %rbx, %rsi
callq *%rax
testl %eax, %eax
je 0x370a
leaq 0x39d7(%rip), %rdi      # 0x7045
leaq 0x3db8(%rip), %rsi      # 0x742d
leaq 0x3ebd(%rip), %rdx      # 0x7539
movl $0xd7, %ecx
jmp 0x36f1
leaq 0x39bb(%rip), %rdi      # 0x7045
leaq 0x3d9c(%rip), %rsi      # 0x742d
leaq 0x3ea1(%rip), %rdx      # 0x7539
movl $0xc9, %ecx
jmp 0x36f1
leaq 0x399f(%rip), %rdi      # 0x7045
leaq 0x3d80(%rip), %rsi      # 0x742d
leaq 0x3e85(%rip), %rdx      # 0x7539
movl $0xcc, %ecx
jmp 0x36f1
leaq 0x3983(%rip), %rdi      # 0x7045
leaq 0x3d64(%rip), %rsi      # 0x742d
leaq 0x3e69(%rip), %rdx      # 0x7539
movl $0xce, %ecx
jmp 0x36f1
leaq 0x3967(%rip), %rdi      # 0x7045
leaq 0x3d48(%rip), %rsi      # 0x742d
leaq 0x3e4d(%rip), %rdx      # 0x7539
movl $0xd5, %ecx
xorl %eax, %eax
callq 0x1030
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x80, %rsp
popq %rbx
popq %r14
popq %r15
retq
movq 0x8(%rbx), %rdi
addq $0x44, %rdi
callq 0x3b5e
movq 0x10(%rbx), %r14
movl $0x0, (%r14)
movq 0x8(%rbx), %rcx
addq $0x44, %rcx
leaq 0x3e13(%rip), %rdx      # 0x7544
movq %rsp, %r15
movl $0x80, %esi
movq %r15, %rdi
xorl %eax, %eax
callq 0x1150
movq %r15, %rdi
movq %r14, %rsi
callq 0x3c0d
movq 0x18(%rbx), %r14
testq %r14, %r14
je 0x378a
movl $0x1, (%r14)
movq 0x8(%rbx), %rcx
addq $0x44, %rcx
leaq 0x3de3(%rip), %rdx      # 0x7550
movq %rsp, %r15
movl $0x80, %esi
movq %r15, %rdi
xorl %eax, %eax
callq 0x1150
movq %r15, %rdi
movq %r14, %rsi
callq 0x3c0d
movq 0x20(%rbx), %r14
testq %r14, %r14
je 0x37c6
movl $0x2, (%r14)
movq 0x8(%rbx), %rcx
addq $0x44, %rcx
leaq 0x3db0(%rip), %rdx      # 0x7559
movq %rsp, %rbx
movl $0x80, %esi
movq %rbx, %rdi
xorl %eax, %eax
callq 0x1150
movq %rbx, %rdi
movq %r14, %rsi
callq 0x3c0d
xorl %eax, %eax
jmp 0x36fd