// File: /workspace/github_c_makefile_star2_O0/xtanitfy[P]Murphy/src/net.c
// Function: NETUpdate
static int NETUpdate(void *usr,int idCurr,int *idPrev,int nIdPrev)
{
	NET_s *pNet = (void *)usr;
	CHECK_EXPR_RET(pNet == NULL,-1);

	LAYER_s *pLayer = pNet->layers[idCurr];
	CHECK_EXPR_RET(pLayer == NULL,-1);
	if (pLayer->k == NULL || pLayer->b == NULL \
				|| pLayer->pDK == NULL || pLayer->pDB == NULL) {
		//DBG_PRT;
		return 0;
	}

	double alpha = pNet->para.alpha;
	BLOB_DATA_PTR(pLayer->k,ptrK);
	BLOB_DATA_PTR(pLayer->b,ptrB);
	BLOB_DATA_PTR(pLayer->pDK,ptrDK);
	BLOB_DATA_PTR(pLayer->pDB,ptrDB);

	unsigned long numOut = pLayer->k->numSize;
	unsigned long numIn = pLayer->k->channelSize;
	unsigned long width = pLayer->k->widthSize;
	unsigned long height = pLayer->k->heightSize;
	
	for (int i_out = 0;i_out < numOut;i_out++) {
		for (int i_in = 0;i_in < numIn;i_in++) {
			for (int i_h = 0;i_h < height;i_h++) {
				for (int i_w = 0;i_w < width;i_w++) {
					ptrK[i_out][i_in][i_h][i_w] -=  alpha * \
						ptrDK[i_out][i_in][i_h][i_w];		
				}
			}
		}
	}


	unsigned long b_out = pLayer->b->channelSize;	
	for (int i_out = 0;i_out < b_out;i_out++) {
		ptrB[0][i_out][0][0] = alpha * \
			ptrDB[0][i_out][0][0];	
	}


#if defined(DEBUG)
	char filename[128];
	snprintf(filename,128,"%s_newk.txt",pLayer->para->name);
	pLayer->k->type = BLOB_TYPE_WEIGHT;
	LOG_writeBlobToTxtFile(filename,pLayer->k);

	snprintf(filename,128,"%s_newb.txt",pLayer->para->name);
	pLayer->b->type = BLOB_TYPE_BIAS;
	LOG_writeBlobToTxtFile(filename,pLayer->b);
#endif
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x180, %rsp            # imm = 0x180
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 0x3ec5
leaq 0x7176(%rip), %rdi      # 0xb015
leaq 0x7537(%rip), %rsi      # 0xb3dd
leaq 0x75f6(%rip), %rdx      # 0xb4a3
movl $0x48, %ecx
movb $0x0, %al
callq 0x1030
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x43ea
movq -0x30(%rbp), %rax
movslq -0x14(%rbp), %rcx
movq 0x240(%rax,%rcx,8), %rax
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
jne 0x3f0d
leaq 0x712e(%rip), %rdi      # 0xb015
leaq 0x74ef(%rip), %rsi      # 0xb3dd
leaq 0x75ae(%rip), %rdx      # 0xb4a3
movl $0x4b, %ecx
movb $0x0, %al
callq 0x1030
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x43ea
movq -0x38(%rbp), %rax
cmpq $0x0, 0x18(%rax)
je 0x3f39
movq -0x38(%rbp), %rax
cmpq $0x0, 0x20(%rax)
je 0x3f39
movq -0x38(%rbp), %rax
cmpq $0x0, 0x30(%rax)
je 0x3f39
movq -0x38(%rbp), %rax
cmpq $0x0, 0x38(%rax)
jne 0x3f45
movl $0x0, -0x4(%rbp)
jmp 0x43ea
movq -0x30(%rbp), %rax
movsd 0x208(%rax), %xmm0
movsd %xmm0, -0x40(%rbp)
movq -0x38(%rbp), %rax
movq 0x18(%rax), %rax
movq 0x18(%rax), %rax
movq %rax, -0x180(%rbp)
movq -0x38(%rbp), %rax
movq 0x18(%rax), %rax
movq 0x20(%rax), %rax
movq %rax, -0x178(%rbp)
movq -0x38(%rbp), %rax
movq 0x18(%rax), %rax
movq 0x28(%rax), %rax
movq %rax, -0x170(%rbp)
movq -0x38(%rbp), %rax
movq 0x18(%rax), %rax
movq 0x8(%rax), %rax
movq %rax, -0x48(%rbp)
movq -0x38(%rbp), %rax
movq 0x20(%rax), %rax
movq 0x18(%rax), %rax
movq %rax, -0x168(%rbp)
movq -0x38(%rbp), %rax
movq 0x20(%rax), %rax
movq 0x20(%rax), %rax
movq %rax, -0x160(%rbp)
movq -0x38(%rbp), %rax
movq 0x20(%rax), %rax
movq 0x28(%rax), %rax
movq %rax, -0x158(%rbp)
movq -0x38(%rbp), %rax
movq 0x20(%rax), %rax
movq 0x8(%rax), %rax
movq %rax, -0x50(%rbp)
movq -0x38(%rbp), %rax
movq 0x30(%rax), %rax
movq 0x18(%rax), %rax
movq %rax, -0x150(%rbp)
movq -0x38(%rbp), %rax
movq 0x30(%rax), %rax
movq 0x20(%rax), %rax
movq %rax, -0x148(%rbp)
movq -0x38(%rbp), %rax
movq 0x30(%rax), %rax
movq 0x28(%rax), %rax
movq %rax, -0x140(%rbp)
movq -0x38(%rbp), %rax
movq 0x30(%rax), %rax
movq 0x8(%rax), %rax
movq %rax, -0x58(%rbp)
movq -0x38(%rbp), %rax
movq 0x38(%rax), %rax
movq 0x18(%rax), %rax
movq %rax, -0x138(%rbp)
movq -0x38(%rbp), %rax
movq 0x38(%rax), %rax
movq 0x20(%rax), %rax
movq %rax, -0x130(%rbp)
movq -0x38(%rbp), %rax
movq 0x38(%rax), %rax
movq 0x28(%rax), %rax
movq %rax, -0x128(%rbp)
movq -0x38(%rbp), %rax
movq 0x38(%rax), %rax
movq 0x8(%rax), %rax
movq %rax, -0x60(%rbp)
movq -0x38(%rbp), %rax
movq 0x18(%rax), %rax
movq 0x10(%rax), %rax
movq %rax, -0x68(%rbp)
movq -0x38(%rbp), %rax
movq 0x18(%rax), %rax
movq 0x18(%rax), %rax
movq %rax, -0x70(%rbp)
movq -0x38(%rbp), %rax
movq 0x18(%rax), %rax
movq 0x28(%rax), %rax
movq %rax, -0x78(%rbp)
movq -0x38(%rbp), %rax
movq 0x18(%rax), %rax
movq 0x20(%rax), %rax
movq %rax, -0x80(%rbp)
movl $0x0, -0x84(%rbp)
movslq -0x84(%rbp), %rax
cmpq -0x68(%rbp), %rax
jae 0x4273
movl $0x0, -0x88(%rbp)
movslq -0x88(%rbp), %rax
cmpq -0x70(%rbp), %rax
jae 0x425d
movl $0x0, -0x8c(%rbp)
movslq -0x8c(%rbp), %rax
cmpq -0x80(%rbp), %rax
jae 0x4247
movl $0x0, -0x90(%rbp)
movslq -0x90(%rbp), %rax
cmpq -0x78(%rbp), %rax
jae 0x4231
movq -0x170(%rbp), %rdx
movq -0x178(%rbp), %rsi
movq -0x180(%rbp), %rdi
movq -0x140(%rbp), %r8
movq -0x148(%rbp), %r9
movq -0x150(%rbp), %r10
movsd -0x40(%rbp), %xmm0
movq -0x58(%rbp), %rax
movslq -0x84(%rbp), %rcx
imulq %r9, %r10
imulq %r8, %r10
imulq %r10, %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movslq -0x88(%rbp), %rcx
imulq %r8, %r9
imulq %r9, %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movslq -0x8c(%rbp), %rcx
imulq %r8, %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movslq -0x90(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm2
movq -0x48(%rbp), %rax
movslq -0x84(%rbp), %rcx
imulq %rsi, %rdi
imulq %rdx, %rdi
imulq %rdi, %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movslq -0x88(%rbp), %rcx
imulq %rdx, %rsi
imulq %rsi, %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movslq -0x8c(%rbp), %rcx
imulq %rdx, %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movslq -0x90(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm1
movq %xmm0, %rdx
movabsq $-0x8000000000000000, %rsi # imm = 0x8000000000000000
xorq %rsi, %rdx
movq %rdx, %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movl -0x90(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x90(%rbp)
jmp 0x4115
jmp 0x4233
movl -0x8c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8c(%rbp)
jmp 0x40fa
jmp 0x4249
movl -0x88(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x88(%rbp)
jmp 0x40df
jmp 0x425f
movl -0x84(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x84(%rbp)
jmp 0x40c4
movq -0x38(%rbp), %rax
movq 0x20(%rax), %rax
movq 0x18(%rax), %rax
movq %rax, -0x98(%rbp)
movl $0x0, -0x9c(%rbp)
movslq -0x9c(%rbp), %rax
cmpq -0x98(%rbp), %rax
jae 0x4353
movq -0x158(%rbp), %rcx
movq -0x160(%rbp), %rsi
movq -0x168(%rbp), %rdx
movq -0x128(%rbp), %rdi
movq -0x130(%rbp), %r9
movq -0x138(%rbp), %r8
movsd -0x40(%rbp), %xmm0
movq -0x60(%rbp), %rax
imulq %r9, %r8
imulq %rdi, %r8
imulq $0x0, %r8, %r8
shlq $0x3, %r8
addq %r8, %rax
movslq -0x9c(%rbp), %r8
imulq %rdi, %r9
imulq %r9, %r8
shlq $0x3, %r8
addq %r8, %rax
imulq $0x0, %rdi, %rdi
mulsd (%rax,%rdi,8), %xmm0
movq -0x50(%rbp), %rax
imulq %rsi, %rdx
imulq %rcx, %rdx
imulq $0x0, %rdx, %rdx
shlq $0x3, %rdx
addq %rdx, %rax
movslq -0x9c(%rbp), %rdx
imulq %rcx, %rsi
imulq %rsi, %rdx
shlq $0x3, %rdx
addq %rdx, %rax
imulq $0x0, %rcx, %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0x9c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x9c(%rbp)
jmp 0x4290
leaq -0x120(%rbp), %rdi
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rcx
addq $0x44, %rcx
movl $0x80, %esi
leaq 0x713b(%rip), %rdx      # 0xb4ad
movb $0x0, %al
callq 0x1130
movq -0x38(%rbp), %rax
movq 0x18(%rax), %rax
movl $0x1, (%rax)
leaq -0x120(%rbp), %rdi
movq -0x38(%rbp), %rax
movq 0x18(%rax), %rsi
callq 0x5460
leaq -0x120(%rbp), %rdi
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rcx
addq $0x44, %rcx
movl $0x80, %esi
leaq 0x70ff(%rip), %rdx      # 0xb4b9
movb $0x0, %al
callq 0x1130
movq -0x38(%rbp), %rax
movq 0x20(%rax), %rax
movl $0x2, (%rax)
leaq -0x120(%rbp), %rdi
movq -0x38(%rbp), %rax
movq 0x20(%rax), %rsi
callq 0x5460
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x180, %rsp            # imm = 0x180
popq %rbp
retq
nopw %cs:(%rax,%rax)