// File: /workspace/github_cpp_makefile_star2_O3/thunlp[P]KB2E/TransR/Train_TransR.cpp
// Function: Train::run(int, double, double, int)
void run(int n_in,double rate_in,double margin_in,int method_in)
    {
        n = n_in;
        m = n_in;
        rate = rate_in;
        margin = margin_in;
        method = method_in;
		A.resize(relation_num);
		for (int i=0; i<relation_num; i++)
		{
		    A[i].resize(n);
		    for (int jj=0; jj<n; jj++)
		    {
		        A[i][jj].resize(m);
		        for (int ii=0; ii<m; ii++)
		        {
					if (ii==jj)
						A[i][jj][ii]=1;
					else
						A[i][jj][ii]=0;
		        }
		    }
		}
        relation_vec.resize(relation_num);
		for (int i=0; i<relation_vec.size(); i++)
			relation_vec[i].resize(m);
        entity_vec.resize(entity_num);
		for (int i=0; i<entity_vec.size(); i++)
			entity_vec[i].resize(n);
        for (int i=0; i<relation_num; i++)
        {
            for (int ii=0; ii<m; ii++)
                relation_vec[i][ii] = randn(0,1.0/m,-1,1);
        }
        FILE* f1 = fopen("../TransE/entity2vec.unif","r");
        for (int i=0; i<entity_num; i++)
        {
            for (int ii=0; ii<n; ii++)
            	fscanf(f1,"%lf",&entity_vec[i][ii]);
            norm(entity_vec[i]);
        }
        fclose(f1);

		FILE* f2 = fopen("../TransE/relation2vec.unif","r");
        for (int i=0; i<relation_num; i++)
        {
            for (int ii=0; ii<n; ii++)
            	fscanf(f2,"%lf",&relation_vec[i][ii]);
        }
        fclose(f2);
        bfgs();
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
movl %esi, 0x30(%rdi)
movl %esi, 0x34(%rdi)
movsd %xmm0, 0x48(%rdi)
movsd %xmm1, 0x50(%rdi)
movl %edx, 0x38(%rdi)
leaq 0x100(%rdi), %r14
movslq 0x39407(%rip), %rsi     # 0x3cf30
movq %r14, %rdi
callq 0x4518
movslq 0x393f8(%rip), %rsi     # 0x3cf30
testq %rsi, %rsi
jle 0x3bec
movl 0x30(%rbx), %ecx
xorl %r15d, %r15d
leaq (%r15,%r15,2), %r12
leaq (,%r12,8), %rdi
addq 0x100(%rbx), %rdi
movslq %ecx, %rsi
callq 0x4594
movl 0x30(%rbx), %ecx
testl %ecx, %ecx
jle 0x3bd9
movl 0x34(%rbx), %eax
xorl %r13d, %r13d
movq 0x100(%rbx), %rcx
leaq (,%r13,2), %rbp
addq %r13, %rbp
leaq (,%rbp,8), %rdi
addq (%rcx,%r12,8), %rdi
movslq %eax, %rsi
callq 0x45d0
movslq 0x34(%rbx), %rax
testq %rax, %rax
movsd 0x447c(%rip), %xmm1     # 0x8020
jle 0x3bcd
movq (%r14), %rcx
movq (%rcx,%r12,8), %rcx
movq (%rcx,%rbp,8), %rcx
xorl %edx, %edx
movapd %xmm1, %xmm0
cmpq %rdx, %r13
je 0x3bc0
xorpd %xmm0, %xmm0
movsd %xmm0, (%rcx,%rdx,8)
incq %rdx
cmpq %rdx, %rax
jne 0x3bb3
incq %r13
movslq 0x30(%rbx), %rcx
cmpq %rcx, %r13
jl 0x3b6f
incq %r15
movslq 0x3934d(%rip), %rsi     # 0x3cf30
cmpq %rsi, %r15
jl 0x3b47
leaq 0xa0(%rbx), %rdi
callq 0x4594
movq 0xa0(%rbx), %rdi
movabsq $-0x5555555555555555, %r14 # imm = 0xAAAAAAAAAAAAAAAB
cmpq %rdi, 0xa8(%rbx)
je 0x3c49
xorl %r15d, %r15d
xorl %r12d, %r12d
addq %r15, %rdi
movslq 0x34(%rbx), %rsi
callq 0x45d0
incq %r12
movq 0xa0(%rbx), %rdi
movq 0xa8(%rbx), %rax
subq %rdi, %rax
sarq $0x3, %rax
imulq %r14, %rax
addq $0x18, %r15
cmpq %r12, %rax
ja 0x3c18
leaq 0xb8(%rbx), %rdi
movslq 0x392dd(%rip), %rsi     # 0x3cf34
callq 0x4594
movq 0xb8(%rbx), %rdi
cmpq %rdi, 0xc0(%rbx)
je 0x3ca3
xorl %r15d, %r15d
xorl %r12d, %r12d
addq %r15, %rdi
movslq 0x30(%rbx), %rsi
callq 0x45d0
incq %r12
movq 0xb8(%rbx), %rdi
movq 0xc0(%rbx), %rax
subq %rdi, %rax
sarq $0x3, %rax
imulq %r14, %rax
addq $0x18, %r15
cmpq %r12, %rax
ja 0x3c72
movl 0x39287(%rip), %ecx     # 0x3cf30
testl %ecx, %ecx
jle 0x3d20
movl 0x34(%rbx), %eax
xorl %r14d, %r14d
movsd 0x4365(%rip), %xmm1     # 0x8020
testl %eax, %eax
jle 0x3d15
leaq (%r14,%r14,2), %r15
xorl %r12d, %r12d
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
divsd %xmm0, %xmm1
xorpd %xmm0, %xmm0
movsd 0x4353(%rip), %xmm2     # 0x8030
movsd 0x433b(%rip), %xmm3     # 0x8020
callq 0x288b
movsd 0x432e(%rip), %xmm1     # 0x8020
movq 0xa0(%rbx), %rax
movq (%rax,%r15,8), %rax
movsd %xmm0, (%rax,%r12,8)
incq %r12
movslq 0x34(%rbx), %rax
cmpq %rax, %r12
jl 0x3cc6
movl 0x3921b(%rip), %ecx     # 0x3cf30
incq %r14
movslq %ecx, %rdx
cmpq %rdx, %r14
jl 0x3cbb
leaq 0x445a(%rip), %rdi      # 0x8181
leaq 0x4398(%rip), %rsi      # 0x80c6
callq 0x2200
movq %rax, %r14
cmpl $0x0, 0x391f7(%rip)     # 0x3cf34
jle 0x3daf
leaq 0x4455(%rip), %r15      # 0x819b
xorl %ecx, %ecx
cmpl $0x0, 0x30(%rbx)
movq %rcx, (%rsp)
leaq (%rcx,%rcx,2), %r12
jle 0x3d86
xorl %ebp, %ebp
xorl %r13d, %r13d
movq 0xb8(%rbx), %rax
movq (%rax,%r12,8), %rdx
addq %rbp, %rdx
movq %r14, %rdi
movq %r15, %rsi
xorl %eax, %eax
callq 0x2310
incq %r13
movslq 0x30(%rbx), %rax
addq $0x8, %rbp
cmpq %rax, %r13
jl 0x3d5b
shlq $0x3, %r12
addq 0xb8(%rbx), %r12
movq %rbx, %rdi
movq %r12, %rsi
callq 0x4602
movq (%rsp), %rcx
incq %rcx
movslq 0x3918a(%rip), %rax     # 0x3cf34
cmpq %rax, %rcx
jl 0x3d48
movq %r14, %rdi
callq 0x21b0
leaq 0x43e1(%rip), %rdi      # 0x819f
leaq 0x4301(%rip), %rsi      # 0x80c6
callq 0x2200
movq %rax, %r14
movl 0x3915d(%rip), %ecx     # 0x3cf30
testl %ecx, %ecx
jle 0x3e34
movl 0x30(%rbx), %eax
leaq 0x43ba(%rip), %r15      # 0x819b
xorl %esi, %esi
testl %eax, %eax
jle 0x3e29
movq %rsi, (%rsp)
leaq (%rsi,%rsi,2), %r13
xorl %ebp, %ebp
xorl %r12d, %r12d
movq 0xa0(%rbx), %rax
movq (%rax,%r13,8), %rdx
addq %rbp, %rdx
movq %r14, %rdi
movq %r15, %rsi
xorl %eax, %eax
callq 0x2310
incq %r12
movslq 0x30(%rbx), %rax
addq $0x8, %rbp
cmpq %rax, %r12
jl 0x3df4
movl 0x3910b(%rip), %ecx     # 0x3cf30
movq (%rsp), %rsi
incq %rsi
movslq %ecx, %rdx
cmpq %rdx, %rsi
jl 0x3de3
movq %r14, %rdi
callq 0x21b0
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x468a