// File: /workspace/github_c_makefile_star2_O2/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 0x3478
movq %rdi, %r14
movslq %esi, %rax
movq 0x240(%rdi,%rax,8), %rbx
testq %rbx, %rbx
je 0x34d7
cmpq $0x0, 0x50(%rbx)
je 0x34f3
xorl %eax, %eax
testl %ecx, %ecx
movl $0x0, %esi
cmovgl %ecx, %esi
cmpq %rax, %rsi
je 0x3497
movslq (%rdx,%rax,4), %rdi
movq 0x240(%r14,%rdi,8), %rdi
movq %rdi, 0xa8(%rbx,%rax,8)
incq %rax
jmp 0x345a
leaq 0x3bc6(%rip), %rdi      # 0x7045
leaq 0x3fa7(%rip), %rsi      # 0x742d
leaq 0x40ac(%rip), %rdx      # 0x7539
movl $0xc9, %ecx
jmp 0x3529
movl %ecx, 0xe8(%rbx)
callq 0x3954
movq 0x50(%rbx), %rax
testq %rax, %rax
je 0x350f
movq %r14, %rdi
movq %rbx, %rsi
callq *%rax
testl %eax, %eax
je 0x3540
leaq 0x3b83(%rip), %rdi      # 0x7045
leaq 0x3f64(%rip), %rsi      # 0x742d
leaq 0x4069(%rip), %rdx      # 0x7539
movl $0xd7, %ecx
jmp 0x3529
leaq 0x3b67(%rip), %rdi      # 0x7045
leaq 0x3f48(%rip), %rsi      # 0x742d
leaq 0x404d(%rip), %rdx      # 0x7539
movl $0xcc, %ecx
jmp 0x3529
leaq 0x3b4b(%rip), %rdi      # 0x7045
leaq 0x3f2c(%rip), %rsi      # 0x742d
leaq 0x4031(%rip), %rdx      # 0x7539
movl $0xce, %ecx
jmp 0x3529
leaq 0x3b2f(%rip), %rdi      # 0x7045
leaq 0x3f10(%rip), %rsi      # 0x742d
leaq 0x4015(%rip), %rdx      # 0x7539
movl $0xd5, %ecx
xorl %eax, %eax
callq 0x1030
pushq $-0x1
popq %rax
addq $0x80, %rsp
popq %rbx
popq %r14
popq %r15
retq
movq 0x8(%rbx), %rdi
addq $0x44, %rdi
callq 0x3962
movq 0x10(%rbx), %r14
andl $0x0, (%r14)
movq 0x8(%rbx), %rcx
addq $0x44, %rcx
leaq 0x3fe0(%rip), %rdx      # 0x7544
movq %rsp, %r15
movl $0x80, %esi
movq %r15, %rdi
xorl %eax, %eax
callq 0x1150
movq %r15, %rdi
movq %r14, %rsi
callq 0x39ff
movq 0x18(%rbx), %r14
testq %r14, %r14
je 0x35bd
movl $0x1, (%r14)
movq 0x8(%rbx), %rcx
addq $0x44, %rcx
leaq 0x3fb0(%rip), %rdx      # 0x7550
movq %rsp, %r15
movl $0x80, %esi
movq %r15, %rdi
xorl %eax, %eax
callq 0x1150
movq %r15, %rdi
movq %r14, %rsi
callq 0x39ff
movq 0x20(%rbx), %r14
testq %r14, %r14
je 0x35f9
movl $0x2, (%r14)
movq 0x8(%rbx), %rcx
addq $0x44, %rcx
leaq 0x3f7d(%rip), %rdx      # 0x7559
movq %rsp, %rbx
movl $0x80, %esi
movq %rbx, %rdi
xorl %eax, %eax
callq 0x1150
movq %rbx, %rdi
movq %r14, %rsi
callq 0x39ff
xorl %eax, %eax
jmp 0x3533