// File: /workspace/github_c_makefile_star2_O0/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 %rbp
movq %rsp, %rbp
subq $0xe0, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
movl %ecx, -0x24(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
jne 0x4b25
leaq 0x6516(%rip), %rdi      # 0xb015
leaq 0x68d7(%rip), %rsi      # 0xb3dd
leaq 0x6a1b(%rip), %rdx      # 0xb528
movl $0xc9, %ecx
movb $0x0, %al
callq 0x1030
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x4d9b
movq -0x30(%rbp), %rax
movslq -0x14(%rbp), %rcx
movq 0x240(%rax,%rcx,8), %rax
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
jne 0x4b6d
leaq 0x64ce(%rip), %rdi      # 0xb015
leaq 0x688f(%rip), %rsi      # 0xb3dd
leaq 0x69d3(%rip), %rdx      # 0xb528
movl $0xcc, %ecx
movb $0x0, %al
callq 0x1030
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x4d9b
movq -0x38(%rbp), %rax
cmpq $0x0, 0x50(%rax)
jne 0x4ba5
leaq 0x6496(%rip), %rdi      # 0xb015
leaq 0x6857(%rip), %rsi      # 0xb3dd
leaq 0x699b(%rip), %rdx      # 0xb528
movl $0xce, %ecx
movb $0x0, %al
callq 0x1030
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x4d9b
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
cmpl -0x24(%rbp), %eax
jge 0x4be7
movq -0x30(%rbp), %rax
movq -0x20(%rbp), %rcx
movslq -0x3c(%rbp), %rdx
movslq (%rcx,%rdx,4), %rcx
movq 0x240(%rax,%rcx,8), %rdx
movq -0x38(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movq %rdx, 0xa8(%rax,%rcx,8)
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x4bac
movl -0x24(%rbp), %ecx
movq -0x38(%rbp), %rax
movl %ecx, 0xe8(%rax)
callq 0x5360
movq -0x38(%rbp), %rax
cmpq $0x0, 0x50(%rax)
jne 0x4c31
leaq 0x640a(%rip), %rdi      # 0xb015
leaq 0x67cb(%rip), %rsi      # 0xb3dd
leaq 0x690f(%rip), %rdx      # 0xb528
movl $0xd5, %ecx
movb $0x0, %al
callq 0x1030
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x4d9b
movq -0x38(%rbp), %rax
movq 0x50(%rax), %rax
movq -0x30(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq *%rax
movl %eax, -0x40(%rbp)
cmpl $0x0, -0x40(%rbp)
je 0x4c79
leaq 0x63c2(%rip), %rdi      # 0xb015
leaq 0x6783(%rip), %rsi      # 0xb3dd
leaq 0x68c7(%rip), %rdx      # 0xb528
movl $0xd7, %ecx
movb $0x0, %al
callq 0x1030
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x4d9b
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rdi
addq $0x44, %rdi
callq 0x5380
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
movl $0x0, (%rax)
leaq -0xd0(%rbp), %rdi
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rcx
addq $0x44, %rcx
movl $0x80, %esi
leaq 0x6874(%rip), %rdx      # 0xb533
movb $0x0, %al
callq 0x1130
leaq -0xd0(%rbp), %rdi
movq -0x48(%rbp), %rsi
callq 0x5460
movq -0x38(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0xd8(%rbp)
cmpq $0x0, -0xd8(%rbp)
je 0x4d35
movq -0xd8(%rbp), %rax
movl $0x1, (%rax)
leaq -0xd0(%rbp), %rdi
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rcx
addq $0x44, %rcx
movl $0x80, %esi
leaq 0x6824(%rip), %rdx      # 0xb53f
movb $0x0, %al
callq 0x1130
leaq -0xd0(%rbp), %rdi
movq -0xd8(%rbp), %rsi
callq 0x5460
movq -0x38(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0xe0(%rbp)
cmpq $0x0, -0xe0(%rbp)
je 0x4d94
movq -0xe0(%rbp), %rax
movl $0x2, (%rax)
leaq -0xd0(%rbp), %rdi
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rcx
addq $0x44, %rcx
movl $0x80, %esi
leaq 0x67ce(%rip), %rdx      # 0xb548
movb $0x0, %al
callq 0x1130
leaq -0xd0(%rbp), %rdi
movq -0xe0(%rbp), %rsi
callq 0x5460
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xe0, %rsp
popq %rbp
retq
nopw (%rax,%rax)