// File: thunlp[P]KB2E/TransR/Train_TransR.cpp
// Function: Train::norm(std::vector<double, std::allocator<double>>&, std::vector<std::vector<double, std::allocator<double>>, std::allocator<std::vector<double, std::allocator<double>>>>&)
void norm(vector<double> &a, vector<vector<double> > &A)
    {
    	while (true)
    	{
		    double x=0;
		    for (int ii=0; ii<m; ii++)
		    {
		        double tmp = 0;
		        for (int jj=0; jj<n; jj++)
		            tmp+=A[jj][ii]*a[jj];
		        x+=sqr(tmp);
		    }
		    if (x>1)
		    {
		        double lambda=1;
		        for (int ii=0; ii<m; ii++)
		        {
		            double tmp = 0;
		            for (int jj=0; jj<n; jj++)
		                tmp+=A[jj][ii]*a[jj];
		            tmp*=2;
		            for (int jj=0; jj<n; jj++)
		            {
		                A[jj][ii]-=rate*lambda*tmp*a[jj];
		                a[jj]-=rate*lambda*tmp*A[jj][ii];
		            }
		        }
		    }
		    else
		    	break;
		}
    }

// Assembly:
subq $0x98, %rsp
movq %rdi, 0x90(%rsp)
movq %rsi, 0x88(%rsp)
movq %rdx, 0x80(%rsp)
movq 0x90(%rsp), %rax
movq %rax, 0x38(%rsp)
xorps %xmm0, %xmm0
movsd %xmm0, 0x78(%rsp)
movl $0x0, 0x74(%rsp)
movq 0x38(%rsp), %rcx
movl 0x74(%rsp), %eax
cmpl 0x34(%rcx), %eax
jge 0xb85b
xorps %xmm0, %xmm0
movsd %xmm0, 0x68(%rsp)
movl $0x0, 0x64(%rsp)
movq 0x38(%rsp), %rcx
movl 0x64(%rsp), %eax
cmpl 0x30(%rcx), %eax
jge 0xb834
movq 0x80(%rsp), %rdi
movslq 0x64(%rsp), %rsi
callq 0x8250
movq %rax, %rdi
movslq 0x74(%rsp), %rsi
callq 0x3c80
movsd (%rax), %xmm0
movsd %xmm0, 0x30(%rsp)
movq 0x88(%rsp), %rdi
movslq 0x64(%rsp), %rsi
callq 0x3c80
movsd 0x30(%rsp), %xmm0
movsd (%rax), %xmm2
movsd 0x68(%rsp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x68(%rsp)
movl 0x64(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x64(%rsp)
jmp 0xb7c0
movsd 0x68(%rsp), %xmm0
callq 0x29e0
addsd 0x78(%rsp), %xmm0
movsd %xmm0, 0x78(%rsp)
movl 0x74(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x74(%rsp)
jmp 0xb79d
movsd 0x78(%rsp), %xmm0
movsd 0xa7b7(%rip), %xmm1     # 0x16020
ucomisd %xmm1, %xmm0
jbe 0xba89
movsd 0xa7a5(%rip), %xmm0     # 0x16020
movsd %xmm0, 0x58(%rsp)
movl $0x0, 0x54(%rsp)
movq 0x38(%rsp), %rcx
movl 0x54(%rsp), %eax
cmpl 0x34(%rcx), %eax
jge 0xba87
xorps %xmm0, %xmm0
movsd %xmm0, 0x48(%rsp)
movl $0x0, 0x44(%rsp)
movq 0x38(%rsp), %rcx
movl 0x44(%rsp), %eax
cmpl 0x30(%rcx), %eax
jge 0xb920
movq 0x80(%rsp), %rdi
movslq 0x44(%rsp), %rsi
callq 0x8250
movq %rax, %rdi
movslq 0x54(%rsp), %rsi
callq 0x3c80
movsd (%rax), %xmm0
movsd %xmm0, 0x28(%rsp)
movq 0x88(%rsp), %rdi
movslq 0x44(%rsp), %rsi
callq 0x3c80
movsd 0x28(%rsp), %xmm0
movsd (%rax), %xmm2
movsd 0x48(%rsp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x48(%rsp)
movl 0x44(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x44(%rsp)
jmp 0xb8ac
movsd 0xa6e8(%rip), %xmm0     # 0x16010
mulsd 0x48(%rsp), %xmm0
movsd %xmm0, 0x48(%rsp)
movl $0x0, 0x40(%rsp)
movq 0x38(%rsp), %rcx
movl 0x40(%rsp), %eax
cmpl 0x30(%rcx), %eax
jge 0xba75
movq 0x38(%rsp), %rax
movsd 0x48(%rax), %xmm0
mulsd 0x58(%rsp), %xmm0
mulsd 0x48(%rsp), %xmm0
movsd %xmm0, 0x8(%rsp)
movq 0x88(%rsp), %rdi
movslq 0x40(%rsp), %rsi
callq 0x3c80
movsd (%rax), %xmm0
movsd %xmm0, 0x10(%rsp)
movq 0x80(%rsp), %rdi
movslq 0x40(%rsp), %rsi
callq 0x8250
movq %rax, %rdi
movslq 0x54(%rsp), %rsi
callq 0x3c80
movsd 0x8(%rsp), %xmm0
movsd 0x10(%rsp), %xmm2
movq %rax, %rcx
movq 0x38(%rsp), %rax
movsd (%rcx), %xmm1
movq %xmm0, %rdx
movabsq $-0x8000000000000000, %rsi # imm = 0x8000000000000000
xorq %rsi, %rdx
movq %rdx, %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, (%rcx)
movsd 0x48(%rax), %xmm0
mulsd 0x58(%rsp), %xmm0
mulsd 0x48(%rsp), %xmm0
movsd %xmm0, 0x18(%rsp)
movq 0x80(%rsp), %rdi
movslq 0x40(%rsp), %rsi
callq 0x8250
movq %rax, %rdi
movslq 0x54(%rsp), %rsi
callq 0x3c80
movsd (%rax), %xmm0
movsd %xmm0, 0x20(%rsp)
movq 0x88(%rsp), %rdi
movslq 0x40(%rsp), %rsi
callq 0x3c80
movsd 0x18(%rsp), %xmm0
movsd 0x20(%rsp), %xmm2
movsd (%rax), %xmm1
movq %xmm0, %rcx
movabsq $-0x8000000000000000, %rdx # imm = 0x8000000000000000
xorq %rdx, %rcx
movq %rcx, %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, (%rax)
movl 0x40(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x40(%rsp)
jmp 0xb93c
jmp 0xba77
movl 0x54(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x54(%rsp)
jmp 0xb889
jmp 0xba8b
jmp 0xba90
jmp 0xb78c
addq $0x98, %rsp
retq
nopl (%rax,%rax)