// File: /workspace/github_cpp_makefile_star2_O1/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 0x39413(%rip), %rsi     # 0x3cf30
movq %r14, %rdi
callq 0x4524
movl 0x39405(%rip), %eax     # 0x3cf30
testl %eax, %eax
jle 0x3bd9
xorl %r15d, %r15d
leaq (%r15,%r15,2), %r12
leaq (,%r12,8), %rdi
addq 0x100(%rbx), %rdi
movslq 0x30(%rbx), %rsi
callq 0x45a0
cmpl $0x0, 0x30(%rbx)
jle 0x3bc6
xorl %r13d, %r13d
movq 0x100(%rbx), %rax
leaq (,%r13,2), %rbp
addq %r13, %rbp
leaq (,%rbp,8), %rdi
addq (%rax,%r12,8), %rdi
movslq 0x34(%rbx), %rsi
callq 0x45dc
movslq 0x34(%rbx), %rax
testq %rax, %rax
movsd 0x448f(%rip), %xmm1     # 0x8020
jle 0x3bba
movq (%r14), %rcx
movq (%rcx,%r12,8), %rcx
movq (%rcx,%rbp,8), %rcx
xorl %edx, %edx
movapd %xmm1, %xmm0
cmpq %rdx, %r13
je 0x3bad
xorpd %xmm0, %xmm0
movsd %xmm0, (%rcx,%rdx,8)
incq %rdx
cmpq %rdx, %rax
jne 0x3ba0
incq %r13
movslq 0x30(%rbx), %rax
cmpq %rax, %r13
jl 0x3b5b
incq %r15
movslq 0x39360(%rip), %rax     # 0x3cf30
cmpq %rax, %r15
jl 0x3b36
leaq 0xa0(%rbx), %rdi
movslq %eax, %rsi
callq 0x45a0
movq 0xa0(%rbx), %rdi
movabsq $-0x5555555555555555, %r14 # imm = 0xAAAAAAAAAAAAAAAB
cmpq %rdi, 0xa8(%rbx)
je 0x3c39
xorl %r15d, %r15d
xorl %r12d, %r12d
addq %r15, %rdi
movslq 0x34(%rbx), %rsi
callq 0x45dc
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 0x3c08
leaq 0xb8(%rbx), %rdi
movslq 0x392ed(%rip), %rsi     # 0x3cf34
callq 0x45a0
movq 0xb8(%rbx), %rdi
cmpq %rdi, 0xc0(%rbx)
je 0x3c93
xorl %r15d, %r15d
xorl %r12d, %r12d
addq %r15, %rdi
movslq 0x30(%rbx), %rsi
callq 0x45dc
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 0x3c62
cmpl $0x0, 0x39296(%rip)     # 0x3cf30
jle 0x3d0d
xorl %r14d, %r14d
movsd 0x4379(%rip), %xmm1     # 0x8020
movl 0x34(%rbx), %eax
testl %eax, %eax
jle 0x3cfe
leaq (%r14,%r14,2), %r15
xorl %r12d, %r12d
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
divsd %xmm0, %xmm1
xorpd %xmm0, %xmm0
movsd 0x4364(%rip), %xmm2     # 0x8030
movsd 0x434c(%rip), %xmm3     # 0x8020
callq 0x288b
movsd 0x433f(%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 0x3cb5
incq %r14
movslq 0x39228(%rip), %rax     # 0x3cf30
cmpq %rax, %r14
jl 0x3ca7
leaq 0x446d(%rip), %rdi      # 0x8181
leaq 0x43ab(%rip), %rsi      # 0x80c6
callq 0x2200
movq %rax, %r14
cmpl $0x0, 0x3920a(%rip)     # 0x3cf34
jle 0x3d9c
leaq 0x4468(%rip), %r15      # 0x819b
xorl %ecx, %ecx
cmpl $0x0, 0x30(%rbx)
movq %rcx, (%rsp)
leaq (%rcx,%rcx,2), %r12
jle 0x3d73
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 0x3d48
shlq $0x3, %r12
addq 0xb8(%rbx), %r12
movq %rbx, %rdi
movq %r12, %rsi
callq 0x460e
movq (%rsp), %rcx
incq %rcx
movslq 0x3919d(%rip), %rax     # 0x3cf34
cmpq %rax, %rcx
jl 0x3d35
movq %r14, %rdi
callq 0x21b0
leaq 0x43f4(%rip), %rdi      # 0x819f
leaq 0x4314(%rip), %rsi      # 0x80c6
callq 0x2200
movq %rax, %r14
cmpl $0x0, 0x3916f(%rip)     # 0x3cf30
jle 0x3e27
leaq 0x43d1(%rip), %r15      # 0x819b
movq $0x0, (%rsp)
cmpl $0x0, 0x30(%rbx)
jle 0x3e10
movq (%rsp), %rax
leaq (%rax,%rax,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 0x3de5
movq (%rsp), %rdx
incq %rdx
movslq 0x39112(%rip), %rax     # 0x3cf30
movq %rdx, (%rsp)
cmpq %rax, %rdx
jl 0x3dd2
movq %r14, %rdi
callq 0x21b0
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x4696