// File: /workspace/github_cpp_makefile_star2_O2/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
subq $0x18, %rsp
movq %rdi, %rbx
movl %esi, 0x30(%rdi)
movl %esi, 0x34(%rdi)
movsd %xmm0, 0x48(%rdi)
movsd %xmm1, 0x50(%rdi)
movl %edx, 0x38(%rdi)
addq $0x100, %rdi            # imm = 0x100
movslq 0x3890a(%rip), %rsi     # 0x3bf40
callq 0x40a8
xorl %r14d, %r14d
xorl %r15d, %r15d
movslq 0x388f8(%rip), %rsi     # 0x3bf40
cmpq %rsi, %r15
jge 0x36dc
imulq $0x18, %r15, %r12
movq 0x100(%rbx), %rdi
addq %r12, %rdi
movslq 0x30(%rbx), %rsi
callq 0x40de
xorl %r13d, %r13d
movslq 0x30(%rbx), %rax
cmpq %rax, %r13
jge 0x36d4
movq 0x100(%rbx), %rax
imulq $0x18, %r13, %rbp
movq (%rax,%r12), %rdi
addq %rbp, %rdi
movslq 0x34(%rbx), %rsi
callq 0x4114
movsd 0x3989(%rip), %xmm1     # 0x7020
movl 0x34(%rbx), %eax
movq 0x100(%rbx), %rcx
addq %r12, %rcx
testl %eax, %eax
cmovlel %r14d, %eax
xorl %edx, %edx
cmpq %rdx, %rax
je 0x36cf
movapd %xmm1, %xmm0
cmpq %rdx, %r13
je 0x36be
xorpd %xmm0, %xmm0
movq (%rcx), %rsi
movq (%rsi,%rbp), %rsi
movsd %xmm0, (%rsi,%rdx,8)
incq %rdx
jmp 0x36ac
incq %r13
jmp 0x366b
incq %r15
jmp 0x3641
leaq 0xa0(%rbx), %rdi
movq %rdi, 0x10(%rsp)
callq 0x40de
xorl %r12d, %r12d
pushq $0x18
popq %r15
xorl %r13d, %r13d
movq 0xa0(%rbx), %rdi
movq 0xa8(%rbx), %rax
subq %rdi, %rax
cqto
idivq %r15
cmpq %r13, %rax
jbe 0x3727
addq %r12, %rdi
movslq 0x34(%rbx), %rsi
callq 0x4114
incq %r13
addq $0x18, %r12
jmp 0x36f7
leaq 0xb8(%rbx), %rdi
movslq 0x3880f(%rip), %rsi     # 0x3bf44
callq 0x40de
xorl %r12d, %r12d
xorl %r13d, %r13d
movq 0xb8(%rbx), %rdi
movq 0xc0(%rbx), %rax
subq %rdi, %rax
cqto
idivq %r15
cmpq %r13, %rax
jbe 0x3770
addq %r12, %rdi
movslq 0x30(%rbx), %rsi
callq 0x4114
incq %r13
addq $0x18, %r12
jmp 0x3740
xorl %r15d, %r15d
movslq 0x387c6(%rip), %rax     # 0x3bf40
cmpq %rax, %r15
jge 0x37d0
imulq $0x18, %r15, %r12
xorl %r14d, %r14d
movslq 0x34(%rbx), %rax
cmpq %rax, %r14
jge 0x37cb
cvtsi2sd %eax, %xmm0
movsd 0x3885(%rip), %xmm3     # 0x7020
movapd %xmm3, %xmm1
divsd %xmm0, %xmm1
xorpd %xmm0, %xmm0
movsd 0x3881(%rip), %xmm2     # 0x7030
callq 0x2858
movq 0x10(%rsp), %rax
movq (%rax), %rax
movq (%rax,%r12), %rax
movsd %xmm0, (%rax,%r14,8)
incq %r14
jmp 0x3786
incq %r15
jmp 0x3773
leaq 0x39aa(%rip), %rdi      # 0x7181
leaq 0x38e8(%rip), %rsi      # 0x70c6
callq 0x21f0
movq %rax, %r15
leaq 0x39ae(%rip), %r14      # 0x719b
xorl %ecx, %ecx
movslq 0x3874e(%rip), %rax     # 0x3bf44
cmpq %rax, %rcx
jge 0x384b
movq %rcx, 0x8(%rsp)
imulq $0x18, %rcx, %rbp
xorl %r13d, %r13d
xorl %r12d, %r12d
movslq 0x30(%rbx), %rax
movq 0xb8(%rbx), %rsi
addq %rbp, %rsi
cmpq %rax, %r12
jge 0x3839
movq (%rsi), %rdx
addq %r13, %rdx
movq %r15, %rdi
movq %r14, %rsi
xorl %eax, %eax
callq 0x2300
incq %r12
addq $0x8, %r13
jmp 0x380a
movq %rbx, %rdi
callq 0x4146
movq 0x8(%rsp), %rcx
incq %rcx
jmp 0x37ef
movq %r15, %rdi
callq 0x21a0
leaq 0x3945(%rip), %rdi      # 0x719f
leaq 0x3865(%rip), %rsi      # 0x70c6
callq 0x21f0
movq %rax, %r15
leaq 0x392b(%rip), %r12      # 0x719b
xorl %ecx, %ecx
movslq 0x386c7(%rip), %rax     # 0x3bf40
cmpq %rax, %rcx
jge 0x38c5
movq %rcx, 0x8(%rsp)
imulq $0x18, %rcx, %rbp
xorl %r13d, %r13d
xorl %r14d, %r14d
movslq 0x30(%rbx), %rax
cmpq %rax, %r14
jge 0x38bb
movq 0x10(%rsp), %rax
movq (%rax), %rax
movq (%rax,%rbp), %rdx
addq %r13, %rdx
movq %r15, %rdi
movq %r12, %rsi
xorl %eax, %eax
callq 0x2300
incq %r14
addq $0x8, %r13
jmp 0x388d
movq 0x8(%rsp), %rcx
incq %rcx
jmp 0x3872
movq %r15, %rdi
callq 0x21a0
movq %rbx, %rdi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x4186