// File: 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:
subq $0x98, %rsp
movq %rdi, 0x90(%rsp)
movl %esi, 0x8c(%rsp)
movsd %xmm0, 0x80(%rsp)
movsd %xmm1, 0x78(%rsp)
movl %edx, 0x74(%rsp)
movq 0x90(%rsp), %rdi
movq %rdi, 0x30(%rsp)
movl 0x8c(%rsp), %eax
movl %eax, 0x30(%rdi)
movl 0x8c(%rsp), %eax
movl %eax, 0x34(%rdi)
movsd 0x80(%rsp), %xmm0
movsd %xmm0, 0x48(%rdi)
movsd 0x78(%rsp), %xmm0
movsd %xmm0, 0x50(%rdi)
movl 0x74(%rsp), %eax
movl %eax, 0x38(%rdi)
addq $0x100, %rdi            # imm = 0x100
movslq 0x4c7d8(%rip), %rsi     # 0x50fb0
callq 0x80f0
movl $0x0, 0x70(%rsp)
movl 0x70(%rsp), %eax
cmpl 0x4c7c1(%rip), %eax     # 0x50fb0
jge 0x4939
movq 0x30(%rsp), %rdi
addq $0x100, %rdi            # imm = 0x100
movslq 0x70(%rsp), %rsi
callq 0x8190
movq %rax, %rdi
movq 0x30(%rsp), %rax
movslq 0x30(%rax), %rsi
callq 0x81b0
movl $0x0, 0x6c(%rsp)
movq 0x30(%rsp), %rcx
movl 0x6c(%rsp), %eax
cmpl 0x30(%rcx), %eax
jge 0x4927
movq 0x30(%rsp), %rdi
addq $0x100, %rdi            # imm = 0x100
movslq 0x70(%rsp), %rsi
callq 0x8190
movq %rax, %rdi
movslq 0x6c(%rsp), %rsi
callq 0x8250
movq %rax, %rdi
movq 0x30(%rsp), %rax
movslq 0x34(%rax), %rsi
callq 0x8270
movl $0x0, 0x68(%rsp)
movq 0x30(%rsp), %rcx
movl 0x68(%rsp), %eax
cmpl 0x34(%rcx), %eax
jge 0x4915
movl 0x68(%rsp), %eax
cmpl 0x6c(%rsp), %eax
jne 0x48cc
movq 0x30(%rsp), %rdi
addq $0x100, %rdi            # imm = 0x100
movslq 0x70(%rsp), %rsi
callq 0x8190
movq %rax, %rdi
movslq 0x6c(%rsp), %rsi
callq 0x8250
movq %rax, %rdi
movslq 0x68(%rsp), %rsi
callq 0x3c80
movsd 0x1175a(%rip), %xmm0    # 0x16020
movsd %xmm0, (%rax)
jmp 0x4903
movq 0x30(%rsp), %rdi
addq $0x100, %rdi            # imm = 0x100
movslq 0x70(%rsp), %rsi
callq 0x8190
movq %rax, %rdi
movslq 0x6c(%rsp), %rsi
callq 0x8250
movq %rax, %rdi
movslq 0x68(%rsp), %rsi
callq 0x3c80
xorps %xmm0, %xmm0
movsd %xmm0, (%rax)
jmp 0x4905
movl 0x68(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x68(%rsp)
jmp 0x4872
jmp 0x4917
movl 0x6c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x6c(%rsp)
jmp 0x4824
jmp 0x4929
movl 0x70(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x70(%rsp)
jmp 0x47e5
movq 0x30(%rsp), %rdi
addq $0xa0, %rdi
movslq 0x4c664(%rip), %rsi     # 0x50fb0
callq 0x81b0
movl $0x0, 0x64(%rsp)
movq 0x30(%rsp), %rdi
movslq 0x64(%rsp), %rax
movq %rax, 0x28(%rsp)
addq $0xa0, %rdi
callq 0x8310
movq %rax, %rcx
movq 0x28(%rsp), %rax
cmpq %rcx, %rax
jae 0x49b5
movq 0x30(%rsp), %rdi
addq $0xa0, %rdi
movslq 0x64(%rsp), %rsi
callq 0x8250
movq %rax, %rdi
movq 0x30(%rsp), %rax
movslq 0x34(%rax), %rsi
callq 0x8270
movl 0x64(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x64(%rsp)
jmp 0x4959
movq 0x30(%rsp), %rdi
addq $0xb8, %rdi
movslq 0x4c5ec(%rip), %rsi     # 0x50fb4
callq 0x81b0
movl $0x0, 0x60(%rsp)
movq 0x30(%rsp), %rdi
movslq 0x60(%rsp), %rax
movq %rax, 0x20(%rsp)
addq $0xb8, %rdi
callq 0x8310
movq %rax, %rcx
movq 0x20(%rsp), %rax
cmpq %rcx, %rax
jae 0x4a31
movq 0x30(%rsp), %rdi
addq $0xb8, %rdi
movslq 0x60(%rsp), %rsi
callq 0x8250
movq %rax, %rdi
movq 0x30(%rsp), %rax
movslq 0x30(%rax), %rsi
callq 0x8270
movl 0x60(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x60(%rsp)
jmp 0x49d5
movl $0x0, 0x5c(%rsp)
movl 0x5c(%rsp), %eax
cmpl 0x4c56d(%rip), %eax     # 0x50fb0
jge 0x4adf
movl $0x0, 0x58(%rsp)
movq 0x30(%rsp), %rcx
movl 0x58(%rsp), %eax
cmpl 0x34(%rcx), %eax
jge 0x4acd
movq 0x30(%rsp), %rax
cvtsi2sdl 0x34(%rax), %xmm0
movsd 0x115af(%rip), %xmm1    # 0x16020
divsd %xmm0, %xmm1
xorps %xmm0, %xmm0
movsd 0x11598(%rip), %xmm2    # 0x16018
movsd 0x11598(%rip), %xmm3    # 0x16020
callq 0x2950
movq 0x30(%rsp), %rdi
movsd %xmm0, 0x18(%rsp)
addq $0xa0, %rdi
movslq 0x5c(%rsp), %rsi
callq 0x8250
movq %rax, %rdi
movslq 0x58(%rsp), %rsi
callq 0x3c80
movsd 0x18(%rsp), %xmm0
movsd %xmm0, (%rax)
movl 0x58(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x58(%rsp)
jmp 0x4a51
jmp 0x4acf
movl 0x5c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x5c(%rsp)
jmp 0x4a39
leaq 0x1166b(%rip), %rdi     # 0x16151
leaq 0x115a9(%rip), %rsi     # 0x16096
callq 0x22b0
movq %rax, 0x50(%rsp)
movl $0x0, 0x4c(%rsp)
movl 0x4c(%rsp), %eax
cmpl 0x4c4ab(%rip), %eax     # 0x50fb4
jge 0x4ba8
movl $0x0, 0x48(%rsp)
movq 0x30(%rsp), %rcx
movl 0x48(%rsp), %eax
cmpl 0x30(%rcx), %eax
jge 0x4b75
movq 0x30(%rsp), %rdi
movq 0x50(%rsp), %rax
movq %rax, 0x10(%rsp)
addq $0xb8, %rdi
movslq 0x4c(%rsp), %rsi
callq 0x8250
movq %rax, %rdi
movslq 0x48(%rsp), %rsi
callq 0x3c80
movq 0x10(%rsp), %rdi
movq %rax, %rdx
leaq 0x1160a(%rip), %rsi     # 0x1616b
movb $0x0, %al
callq 0x23e0
movl 0x48(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x48(%rsp)
jmp 0x4b17
movq 0x30(%rsp), %rdi
addq $0xb8, %rdi
movslq 0x4c(%rsp), %rsi
callq 0x8250
movq 0x30(%rsp), %rdi
movq %rax, %rsi
callq 0x8330
movl 0x4c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x4c(%rsp)
jmp 0x4aff
movq 0x50(%rsp), %rdi
callq 0x2210
leaq 0x115b6(%rip), %rdi     # 0x1616f
leaq 0x114d6(%rip), %rsi     # 0x16096
callq 0x22b0
movq %rax, 0x40(%rsp)
movl $0x0, 0x3c(%rsp)
movl 0x3c(%rsp), %eax
cmpl 0x4c3d4(%rip), %eax     # 0x50fb0
jge 0x4c56
movl $0x0, 0x38(%rsp)
movq 0x30(%rsp), %rcx
movl 0x38(%rsp), %eax
cmpl 0x30(%rcx), %eax
jge 0x4c44
movq 0x30(%rsp), %rdi
movq 0x40(%rsp), %rax
movq %rax, 0x8(%rsp)
addq $0xa0, %rdi
movslq 0x3c(%rsp), %rsi
callq 0x8250
movq %rax, %rdi
movslq 0x38(%rsp), %rsi
callq 0x3c80
movq 0x8(%rsp), %rdi
movq %rax, %rdx
leaq 0x1153b(%rip), %rsi     # 0x1616b
movb $0x0, %al
callq 0x23e0
movl 0x38(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x38(%rsp)
jmp 0x4be6
jmp 0x4c46
movl 0x3c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x3c(%rsp)
jmp 0x4bd2
movq 0x40(%rsp), %rdi
callq 0x2210
movq 0x30(%rsp), %rdi
callq 0x83d0
addq $0x98, %rsp
retq
nopw %cs:(%rax,%rax)
nopl (%rax)