// File: /workspace/github_c_makefile_star2_O0/xtanitfy[P]Murphy/examples/mnist/mnist_train.c
// Function: MnistTrainRun
int MnistTrainRun(SIZE_s *pTrainXSize,SIZE_s *pTrainYSize)
{
	int ret = -1;
	int batchCnt = pTrainXSize->n / netTrainPara.batchsize;
    //int batchCnt = 1;
	int xdim = netTrainPara.batchsize * pTrainXSize->h * pTrainXSize->w;
	int ydim = netTrainPara.batchsize * pTrainYSize->h * pTrainYSize->w;
	int testCnt = 0;

	for (int i = 0;i < batchCnt;i++){
		//CalTimeStart();
		printf("=======Batches:%d==========\n",i);
		NET_setInputData(pNetTrain,gTrainX + xdim * i,xdim);
		NET_setTableYData(pNetTrain,gTrainY + ydim * i,ydim);

		//CalTimeStart();
		ret = NET_Forward(pNetTrain);
		CHECK_EXPR_RET(ret != 0,-1);
		//CalTimeEnd("NET_Forward");
		
		//CalTimeStart();
		ret = NET_Backward(pNetTrain);
		CHECK_EXPR_RET(ret != 0,-1);
		//CalTimeEnd("NET_Backward");

		//CalTimeStart();
		ret = NET_Update(pNetTrain);
		CHECK_EXPR_RET(ret != 0,-1);
		//CalTimeEnd("NET_Update");

		double loss = NET_GetLoss(pNetTrain,"output");
		printf("Output loss:%lf\n",loss);
		//CalTimeEnd("all");

	}
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl $0xffffffff, -0x1c(%rbp) # imm = 0xFFFFFFFF
movq -0x10(%rbp), %rax
movl 0x8(%rax), %eax
cltd
idivl 0xcc23(%rip)            # 0xe4d8
movl %eax, -0x20(%rbp)
movl 0xcc1a(%rip), %eax      # 0xe4d8
movq -0x10(%rbp), %rcx
imull (%rcx), %eax
movq -0x10(%rbp), %rcx
imull 0x4(%rcx), %eax
movl %eax, -0x24(%rbp)
movl 0xcc02(%rip), %eax      # 0xe4d8
movq -0x18(%rbp), %rcx
imull (%rcx), %eax
movq -0x18(%rbp), %rcx
imull 0x4(%rcx), %eax
movl %eax, -0x28(%rbp)
movl $0x0, -0x2c(%rbp)
movl $0x0, -0x30(%rbp)
movl -0x30(%rbp), %eax
cmpl -0x20(%rbp), %eax
jge 0x1a58
movl -0x30(%rbp), %esi
leaq 0x9778(%rip), %rdi      # 0xb084
movb $0x0, %al
callq 0x1030
movq 0xc9a6(%rip), %rdi      # 0xe2c0
movq 0xcbd7(%rip), %rsi      # 0xe4f8
movl -0x24(%rbp), %eax
imull -0x30(%rbp), %eax
cltq
shlq $0x3, %rax
addq %rax, %rsi
movl -0x24(%rbp), %edx
callq 0x4760
movq 0xc980(%rip), %rdi      # 0xe2c0
movq 0xcbb9(%rip), %rsi      # 0xe500
movl -0x28(%rbp), %eax
imull -0x30(%rbp), %eax
cltq
shlq $0x3, %rax
addq %rax, %rsi
movl -0x28(%rbp), %edx
callq 0x47a0
movq 0xc95a(%rip), %rdi      # 0xe2c0
callq 0x4f70
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0x1c(%rbp)
je 0x19a1
leaq 0x969a(%rip), %rdi      # 0xb015
leaq 0x96a9(%rip), %rsi      # 0xb02b
leaq 0x9718(%rip), %rdx      # 0xb0a1
movl $0xf0, %ecx
movb $0x0, %al
callq 0x1030
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x1a5f
movq 0xc918(%rip), %rdi      # 0xe2c0
callq 0x4fa0
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0x1c(%rbp)
je 0x19e0
leaq 0x9658(%rip), %rdi      # 0xb015
leaq 0x9667(%rip), %rsi      # 0xb02b
leaq 0x96d6(%rip), %rdx      # 0xb0a1
movl $0xf5, %ecx
movb $0x0, %al
callq 0x1030
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x1a5f
movq 0xc8d9(%rip), %rdi      # 0xe2c0
callq 0x3e40
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0x1c(%rbp)
je 0x1a1f
leaq 0x9619(%rip), %rdi      # 0xb015
leaq 0x9628(%rip), %rsi      # 0xb02b
leaq 0x9697(%rip), %rdx      # 0xb0a1
movl $0xfa, %ecx
movb $0x0, %al
callq 0x1030
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x1a5f
movq 0xc89a(%rip), %rdi      # 0xe2c0
leaq 0x9650(%rip), %rsi      # 0xb07d
callq 0x4db0
movsd %xmm0, -0x38(%rbp)
movsd -0x38(%rbp), %xmm0
leaq 0x966c(%rip), %rdi      # 0xb0af
movb $0x1, %al
callq 0x1030
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x18f6
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax,%rax)