// File: /workspace/github_c_makefile_star2_O1/xtanitfy[P]Murphy/src/net.c
// Function: NET_addLayer
int NET_addLayer(NET_s *pNet,LAYER_PARA_s *pLayerPara)
{
	CHECK_EXPR_RET(pNet == NULL,-1);
	CHECK_EXPR_RET(pLayerPara == NULL,-1);

	LAYER_s *pLayer = (LAYER_s *)malloc(sizeof(LAYER_s));
	CHECK_EXPR_RET(pLayer == NULL,-1);
	memset(pLayer,'\0',sizeof(LAYER_s));

	char *typename = pLayerPara->typeName;
	BOOL isFind = FALSE;
	int i = 0;
	for (i = 0;i < DIM_OF(gLayerRegInfo);i++) {
		if (!strcmp(gLayerRegInfo[i].typename,typename)) {
			isFind = TRUE;
			break;
		}
	}
	CHECK_EXPR_RET(isFind == FALSE,-1);
	pLayer->init = gLayerRegInfo[i].funcInit;
	pLayer->forward = gLayerRegInfo[i].funcForward;
	pLayer->backward = gLayerRegInfo[i].funcBackward;
	LAYER_PARA_s *para = (LAYER_PARA_s *)malloc(sizeof(LAYER_PARA_s));
	CHECK_EXPR_RET(para == NULL,-1);
	memcpy(para,pLayerPara,sizeof(LAYER_PARA_s));	
	pLayer->para = para;
	
	int ret = NET_Register(pNet,pLayer);
	CHECK_EXPR_RET(ret != 0,-1);

	printf("Add %s layer ok!\n",pLayer->para->name);
	
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
testq %rdi, %rdi
je 0x2978
movq %rsi, %r15
testq %rsi, %rsi
je 0x2997
movq %rdi, %rbx
movl $0x128, %edi            # imm = 0x128
callq 0x10d0
testq %rax, %rax
je 0x29b6
movq %rax, %r14
xorl %r13d, %r13d
movl $0x128, %edx            # imm = 0x128
movq %rax, %rdi
xorl %esi, %esi
callq 0x1070
leaq 0x4(%r15), %r12
leaq 0x87ca(%rip), %rbp      # 0xb100
movq %r13, %rdi
addq %rbp, %rdi
movq %r12, %rsi
callq 0x10f0
testl %eax, %eax
je 0x29d5
addq $0x58, %r13
cmpq $0x1b8, %r13            # imm = 0x1B8
jne 0x2936
leaq 0x56e5(%rip), %rdi      # 0x8045
leaq 0x5ac6(%rip), %rsi      # 0x842d
leaq 0x5ac5(%rip), %rdx      # 0x8433
movl $0x19, %ecx
jmp 0x2a5b
leaq 0x56c6(%rip), %rdi      # 0x8045
leaq 0x5aa7(%rip), %rsi      # 0x842d
leaq 0x5aa6(%rip), %rdx      # 0x8433
movl $0x9, %ecx
jmp 0x2a5b
leaq 0x56a7(%rip), %rdi      # 0x8045
leaq 0x5a88(%rip), %rsi      # 0x842d
leaq 0x5a87(%rip), %rdx      # 0x8433
movl $0xa, %ecx
jmp 0x2a5b
leaq 0x5688(%rip), %rdi      # 0x8045
leaq 0x5a69(%rip), %rsi      # 0x842d
leaq 0x5a68(%rip), %rdx      # 0x8433
movl $0xd, %ecx
jmp 0x2a5b
movq 0x40(%rbp,%r13), %rax
movq %rax, 0x48(%r14)
movq 0x48(%rbp,%r13), %rax
movq %rax, 0x50(%r14)
movq 0x50(%rbp,%r13), %rax
movq %rax, 0x58(%r14)
movl $0x2b8, %edi            # imm = 0x2B8
callq 0x10d0
testq %rax, %rax
je 0x2a41
movq %rax, %r12
movl $0x2b8, %edx            # imm = 0x2B8
movq %rax, %rdi
movq %r15, %rsi
callq 0x1090
movq %r12, 0x8(%r14)
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2a92
testl %eax, %eax
je 0x2a78
leaq 0x5619(%rip), %rdi      # 0x8045
leaq 0x59fa(%rip), %rsi      # 0x842d
leaq 0x59f9(%rip), %rdx      # 0x8433
movl $0x23, %ecx
jmp 0x2a5b
leaq 0x55fd(%rip), %rdi      # 0x8045
leaq 0x59de(%rip), %rsi      # 0x842d
leaq 0x59dd(%rip), %rdx      # 0x8433
movl $0x1e, %ecx
xorl %eax, %eax
callq 0x1030
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x8(%r14), %rsi
addq $0x44, %rsi
leaq 0x59b9(%rip), %rdi      # 0x8440
xorl %ebx, %ebx
xorl %eax, %eax
callq 0x1030
jmp 0x2a67