// File: /workspace/github_c_makefile_star2_O1/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 0x378c
movq %rdi, %r14
movslq %esi, %rax
movq 0x240(%rdi,%rax,8), %rbx
testq %rbx, %rbx
je 0x37a8
cmpq $0x0, 0x50(%rbx)
je 0x37c4
testl %ecx, %ecx
jle 0x3748
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 0x372c
movl %ecx, 0xe8(%rbx)
callq 0x3c7c
movq 0x50(%rbx), %rax
testq %rax, %rax
je 0x37e0
movq %r14, %rdi
movq %rbx, %rsi
callq *%rax
testl %eax, %eax
je 0x3813
leaq 0x48ce(%rip), %rdi      # 0x8045
leaq 0x4caf(%rip), %rsi      # 0x842d
leaq 0x4db4(%rip), %rdx      # 0x8539
movl $0xd7, %ecx
jmp 0x37fa
leaq 0x48b2(%rip), %rdi      # 0x8045
leaq 0x4c93(%rip), %rsi      # 0x842d
leaq 0x4d98(%rip), %rdx      # 0x8539
movl $0xc9, %ecx
jmp 0x37fa
leaq 0x4896(%rip), %rdi      # 0x8045
leaq 0x4c77(%rip), %rsi      # 0x842d
leaq 0x4d7c(%rip), %rdx      # 0x8539
movl $0xcc, %ecx
jmp 0x37fa
leaq 0x487a(%rip), %rdi      # 0x8045
leaq 0x4c5b(%rip), %rsi      # 0x842d
leaq 0x4d60(%rip), %rdx      # 0x8539
movl $0xce, %ecx
jmp 0x37fa
leaq 0x485e(%rip), %rdi      # 0x8045
leaq 0x4c3f(%rip), %rsi      # 0x842d
leaq 0x4d44(%rip), %rdx      # 0x8539
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 0x3c8a
movq 0x10(%rbx), %r14
movl $0x0, (%r14)
movq 0x8(%rbx), %rcx
addq $0x44, %rcx
leaq 0x4d0a(%rip), %rdx      # 0x8544
movq %rsp, %r15
movl $0x80, %esi
movq %r15, %rdi
xorl %eax, %eax
callq 0x1140
movq %r15, %rdi
movq %r14, %rsi
callq 0x3d39
movq 0x18(%rbx), %r14
testq %r14, %r14
je 0x3893
movl $0x1, (%r14)
movq 0x8(%rbx), %rcx
addq $0x44, %rcx
leaq 0x4cda(%rip), %rdx      # 0x8550
movq %rsp, %r15
movl $0x80, %esi
movq %r15, %rdi
xorl %eax, %eax
callq 0x1140
movq %r15, %rdi
movq %r14, %rsi
callq 0x3d39
movq 0x20(%rbx), %r14
testq %r14, %r14
je 0x38cf
movl $0x2, (%r14)
movq 0x8(%rbx), %rcx
addq $0x44, %rcx
leaq 0x4ca7(%rip), %rdx      # 0x8559
movq %rsp, %rbx
movl $0x80, %esi
movq %rbx, %rdi
xorl %eax, %eax
callq 0x1140
movq %rbx, %rdi
movq %r14, %rsi
callq 0x3d39
xorl %eax, %eax
jmp 0x3806