// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x3584
leaq 0x7ab7(%rip), %rdi      # 0xb015
leaq 0x7e78(%rip), %rsi      # 0xb3dd
leaq 0x7e77(%rip), %rdx      # 0xb3e3
movl $0x9, %ecx
movb $0x0, %al
callq 0x1030
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x37b3
cmpq $0x0, -0x18(%rbp)
jne 0x35b8
leaq 0x7a83(%rip), %rdi      # 0xb015
leaq 0x7e44(%rip), %rsi      # 0xb3dd
leaq 0x7e43(%rip), %rdx      # 0xb3e3
movl $0xa, %ecx
movb $0x0, %al
callq 0x1030
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x37b3
movl $0x128, %edi            # imm = 0x128
callq 0x10e0
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0x35fa
leaq 0x7a41(%rip), %rdi      # 0xb015
leaq 0x7e02(%rip), %rsi      # 0xb3dd
leaq 0x7e01(%rip), %rdx      # 0xb3e3
movl $0xd, %ecx
movb $0x0, %al
callq 0x1030
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x37b3
movq -0x20(%rbp), %rdi
xorl %esi, %esi
movl $0x128, %edx            # imm = 0x128
callq 0x1070
movq -0x18(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x28(%rbp)
movb $0x0, -0x29(%rbp)
movl $0x0, -0x30(%rbp)
movl $0x0, -0x30(%rbp)
movslq -0x30(%rbp), %rax
cmpq $0x5, %rax
jae 0x3665
movslq -0x30(%rbp), %rax
leaq 0xaac3(%rip), %rdi      # 0xe100
imulq $0x58, %rax, %rax
addq %rax, %rdi
movq -0x28(%rbp), %rsi
callq 0x10f0
cmpl $0x0, %eax
jne 0x3658
movb $0x1, -0x29(%rbp)
jmp 0x3665
jmp 0x365a
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x3628
movsbl -0x29(%rbp), %eax
cmpl $0x0, %eax
jne 0x369b
leaq 0x79a0(%rip), %rdi      # 0xb015
leaq 0x7d61(%rip), %rsi      # 0xb3dd
leaq 0x7d60(%rip), %rdx      # 0xb3e3
movl $0x19, %ecx
movb $0x0, %al
callq 0x1030
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x37b3
movslq -0x30(%rbp), %rcx
leaq 0xaa5a(%rip), %rax      # 0xe100
imulq $0x58, %rcx, %rcx
addq %rcx, %rax
movq 0x40(%rax), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x48(%rax)
movslq -0x30(%rbp), %rcx
leaq 0xaa3c(%rip), %rax      # 0xe100
imulq $0x58, %rcx, %rcx
addq %rcx, %rax
movq 0x48(%rax), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x50(%rax)
movslq -0x30(%rbp), %rcx
leaq 0xaa1e(%rip), %rax      # 0xe100
imulq $0x58, %rcx, %rcx
addq %rcx, %rax
movq 0x50(%rax), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x58(%rax)
movl $0x2b8, %edi            # imm = 0x2B8
callq 0x10e0
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
jne 0x3734
leaq 0x7904(%rip), %rdi      # 0xb015
leaq 0x7cc5(%rip), %rsi      # 0xb3dd
leaq 0x7cc4(%rip), %rdx      # 0xb3e3
movl $0x1e, %ecx
movb $0x0, %al
callq 0x1030
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x37b3
movq -0x38(%rbp), %rdi
movq -0x18(%rbp), %rsi
movl $0x2b8, %edx            # imm = 0x2B8
callq 0x1090
movq -0x38(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x37c0
movl %eax, -0x3c(%rbp)
cmpl $0x0, -0x3c(%rbp)
je 0x3792
leaq 0x78a6(%rip), %rdi      # 0xb015
leaq 0x7c67(%rip), %rsi      # 0xb3dd
leaq 0x7c66(%rip), %rdx      # 0xb3e3
movl $0x23, %ecx
movb $0x0, %al
callq 0x1030
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x37b3
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rsi
addq $0x44, %rsi
leaq 0x7c4b(%rip), %rdi      # 0xb3f0
movb $0x0, %al
callq 0x1030
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax)