// File: /workspace/github_cpp_makefile_star2_O1/thunlp[P]KB2E/CTransR/Train_CTransR.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(fb_relation_num);
		for (int i=0; i<fb_relation_num; i++)
		{
		    A[i].resize(n);
		    for (int jj=0; jj<n; jj++)
		        A[i][jj].resize(m);
		}

        relation_vec.resize(relation_num);
		for (int i=0; i<relation_vec.size(); i++)
        {
			relation_vec[i].resize(m);
			for (int ii=0; ii<m; ii++)
                relation_vec[i][ii] = randn(0,1.0/m,-1,1);
        }
        fb_relation_vec.resize(fb_relation_num);
		for (int i=0; i<fb_relation_vec.size(); i++)
        {
			fb_relation_vec[i].resize(m);
			for (int ii=0; ii<m; ii++)
                fb_relation_vec[i][ii] = randn(0,1.0/m,-1,1);
        }
        entity_vec.resize(entity_num);
		for (int i=0; i<entity_vec.size(); i++)
			entity_vec[i].resize(n);
        FILE* f1 = fopen("../TransR/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("../TransR/relation2vec.unif","r");
        for (int i=0; i<fb_relation_num; i++)
        {
            for (int ii=0; ii<n; ii++)
            	fscanf(f2,"%lf",&fb_relation_vec[i][ii]);
        }
        fclose(f2);
        for (int i=0; i<relation_num; i++)
        {
            for (int ii=0; ii<n; ii++)
                relation_vec[i][ii] = fb_relation_vec[cluster2fb[i]][ii];
        }
        FILE* f3 = fopen("../TransR/A.unif","r");
        for (int i=0; i<fb_relation_num; i++)
            for (int jj=0; jj<m; jj++)
                for (int ii=0; ii<n; ii++)
                    fscanf(f3,"%lf",&A[i][jj][ii]);
        fclose(f3);
        bfgs();
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdi, %rbp
movl %esi, 0x68(%rdi)
movl %esi, 0x6c(%rdi)
movsd %xmm0, 0x80(%rdi)
movsd %xmm1, 0x88(%rdi)
movl %edx, 0x70(%rdi)
addq $0x168, %rdi            # imm = 0x168
movslq 0x38ff8(%rip), %rsi     # 0x3cf48
callq 0x4bde
cmpl $0x0, 0x38fec(%rip)     # 0x3cf48
jle 0x3fbe
xorl %r14d, %r14d
leaq (%r14,%r14,2), %r15
leaq (,%r15,8), %rdi
addq 0x168(%rbp), %rdi
movslq 0x68(%rbp), %rsi
callq 0x4c5a
cmpl $0x0, 0x68(%rbp)
jle 0x3faf
xorl %ebx, %ebx
xorl %r12d, %r12d
movq 0x168(%rbp), %rax
movq (%rax,%r15,8), %rdi
addq %rbx, %rdi
movslq 0x6c(%rbp), %rsi
callq 0x4c96
incq %r12
movslq 0x68(%rbp), %rax
addq $0x18, %rbx
cmpq %rax, %r12
jl 0x3f88
incq %r14
movslq 0x38f8f(%rip), %rax     # 0x3cf48
cmpq %rax, %r14
jl 0x3f61
leaq 0xd8(%rbp), %rdi
movslq 0x38f74(%rip), %rsi     # 0x3cf40
callq 0x4c5a
movq 0xd8(%rbp), %rax
movabsq $-0x5555555555555555, %r14 # imm = 0xAAAAAAAAAAAAAAAB
cmpq %rax, 0xe0(%rbp)
je 0x4083
xorl %r15d, %r15d
leaq (%r15,%r15,2), %r12
leaq (%rax,%r12,8), %rdi
movslq 0x6c(%rbp), %rsi
callq 0x4c96
movl 0x6c(%rbp), %eax
testl %eax, %eax
movsd 0x4010(%rip), %xmm1     # 0x8020
jle 0x405e
xorl %r13d, %r13d
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
divsd %xmm0, %xmm1
xorpd %xmm0, %xmm0
movsd 0x400c(%rip), %xmm2     # 0x8038
movsd 0x3fec(%rip), %xmm3     # 0x8020
callq 0x298b
movsd 0x3fdf(%rip), %xmm1     # 0x8020
movq 0xd8(%rbp), %rax
movq (%rax,%r12,8), %rax
movsd %xmm0, (%rax,%r13,8)
incq %r13
movslq 0x6c(%rbp), %rax
cmpq %rax, %r13
jl 0x4015
incq %r15
movq 0xd8(%rbp), %rax
movq 0xe0(%rbp), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
imulq %r14, %rcx
cmpq %r15, %rcx
ja 0x3ff2
leaq 0x108(%rbp), %rdi
movslq 0x38eb7(%rip), %rsi     # 0x3cf48
callq 0x4c5a
movq 0x108(%rbp), %rax
cmpq %rax, 0x110(%rbp)
je 0x413e
xorl %r15d, %r15d
leaq (%r15,%r15,2), %r12
leaq (%rax,%r12,8), %rdi
movslq 0x6c(%rbp), %rsi
callq 0x4c96
movl 0x6c(%rbp), %eax
testl %eax, %eax
movsd 0x3f55(%rip), %xmm1     # 0x8020
jle 0x4119
xorl %r13d, %r13d
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
divsd %xmm0, %xmm1
xorpd %xmm0, %xmm0
movsd 0x3f51(%rip), %xmm2     # 0x8038
movsd 0x3f31(%rip), %xmm3     # 0x8020
callq 0x298b
movsd 0x3f24(%rip), %xmm1     # 0x8020
movq 0x108(%rbp), %rax
movq (%rax,%r12,8), %rax
movsd %xmm0, (%rax,%r13,8)
incq %r13
movslq 0x6c(%rbp), %rax
cmpq %rax, %r13
jl 0x40d0
incq %r15
movq 0x108(%rbp), %rax
movq 0x110(%rbp), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
imulq %r14, %rcx
cmpq %r15, %rcx
ja 0x40ad
leaq 0xf0(%rbp), %rdi
movslq 0x38df8(%rip), %rsi     # 0x3cf44
callq 0x4c5a
movq 0xf0(%rbp), %rdi
cmpq %rdi, 0xf8(%rbp)
je 0x4198
xorl %r15d, %r15d
xorl %r12d, %r12d
addq %r15, %rdi
movslq 0x68(%rbp), %rsi
callq 0x4c96
incq %r12
movq 0xf0(%rbp), %rdi
movq 0xf8(%rbp), %rax
subq %rdi, %rax
sarq $0x3, %rax
imulq %r14, %rax
addq $0x18, %r15
cmpq %r12, %rax
ja 0x4167
leaq 0x4036(%rip), %rdi      # 0x81d5
leaq 0x3f20(%rip), %rsi      # 0x80c6
callq 0x2210
movq %rax, %r14
cmpl $0x0, 0x38d8f(%rip)     # 0x3cf44
jle 0x422e
leaq 0x4031(%rip), %r15      # 0x81ef
xorl %ecx, %ecx
cmpl $0x0, 0x68(%rbp)
movq %rcx, 0x10(%rsp)
leaq (%rcx,%rcx,2), %r12
movq %rbp, %r13
jle 0x4201
xorl %ebx, %ebx
xorl %ebp, %ebp
movq 0xf0(%r13), %rax
movq (%rax,%r12,8), %rdx
addq %rbx, %rdx
movq %r14, %rdi
movq %r15, %rsi
xorl %eax, %eax
callq 0x2320
incq %rbp
movslq 0x68(%r13), %rax
addq $0x8, %rbx
cmpq %rax, %rbp
jl 0x41d6
shlq $0x3, %r12
addq 0xf0(%r13), %r12
movq %r13, %rdi
movq %r12, %rsi
callq 0x4cc8
movq 0x10(%rsp), %rcx
incq %rcx
movslq 0x38d1e(%rip), %rax     # 0x3cf44
cmpq %rax, %rcx
movq %r13, %rbp
jl 0x41c0
movq %r14, %rdi
callq 0x21c0
leaq 0x3fb6(%rip), %rdi      # 0x81f3
leaq 0x3e82(%rip), %rsi      # 0x80c6
callq 0x2210
movq %rax, %r14
cmpl $0x0, 0x38cf5(%rip)     # 0x3cf48
jle 0x42c4
leaq 0x3f93(%rip), %r15      # 0x81ef
movq $0x0, 0x10(%rsp)
cmpl $0x0, 0x68(%rbp)
movq %rbp, %r12
jle 0x42a8
movq 0x10(%rsp), %rax
leaq (%rax,%rax,2), %r13
xorl %ebx, %ebx
xorl %ebp, %ebp
movq 0x108(%r12), %rax
movq (%rax,%r13,8), %rdx
addq %rbx, %rdx
movq %r14, %rdi
movq %r15, %rsi
xorl %eax, %eax
callq 0x2320
incq %rbp
movslq 0x68(%r12), %rax
addq $0x8, %rbx
cmpq %rax, %rbp
jl 0x427b
movq 0x10(%rsp), %rdx
incq %rdx
movslq 0x38c91(%rip), %rax     # 0x3cf48
movq %rdx, 0x10(%rsp)
cmpq %rax, %rdx
movq %r12, %rbp
jl 0x4265
movq %r14, %rdi
callq 0x21c0
movl $0x0, 0xc(%rsp)
cmpl $0x0, 0x38c65(%rip)     # 0x3cf40
jle 0x434a
leaq 0x38c6c(%rip), %r14     # 0x3cf50
leaq 0xc(%rsp), %r15
cmpl $0x0, 0x68(%rbp)
jle 0x4338
xorl %ebx, %ebx
movq %r14, %rdi
movq %r15, %rsi
callq 0x3cc8
movslq (%rax), %rax
movq 0xd8(%rbp), %rcx
movq 0x108(%rbp), %rdx
leaq (%rax,%rax,2), %rax
movq (%rdx,%rax,8), %rax
movsd (%rax,%rbx,8), %xmm0
movslq 0xc(%rsp), %rax
leaq (%rax,%rax,2), %rax
movq (%rcx,%rax,8), %rax
movsd %xmm0, (%rax,%rbx,8)
incq %rbx
movslq 0x68(%rbp), %rax
cmpq %rax, %rbx
jl 0x42f1
movl 0xc(%rsp), %eax
incl %eax
movl %eax, 0xc(%rsp)
cmpl 0x38bf8(%rip), %eax     # 0x3cf40
jl 0x42e9
leaq 0x3ebe(%rip), %rdi      # 0x820f
leaq 0x3d6e(%rip), %rsi      # 0x80c6
callq 0x2210
movq %rax, %r13
cmpl $0x0, 0x38be1(%rip)     # 0x3cf48
jle 0x441a
leaq 0x3e7b(%rip), %r14      # 0x81ef
movq $0x0, 0x18(%rsp)
cmpl $0x0, 0x6c(%rbp)
jle 0x43fd
movq 0x18(%rsp), %rax
leaq (%rax,%rax,2), %r12
movq $0x0, 0x20(%rsp)
cmpl $0x0, 0x68(%rbp)
movq %rbp, %r15
jle 0x43e4
movq 0x20(%rsp), %rax
leaq (%rax,%rax,2), %rax
movq %rax, 0x10(%rsp)
xorl %ebx, %ebx
xorl %ebp, %ebp
movq 0x168(%r15), %rax
movq (%rax,%r12,8), %rax
movq 0x10(%rsp), %rdx
movq (%rax,%rdx,8), %rdx
addq %rbx, %rdx
movq %r13, %rdi
movq %r14, %rsi
xorl %eax, %eax
callq 0x2320
incq %rbp
movslq 0x68(%r15), %rax
addq $0x8, %rbx
cmpq %rax, %rbp
jl 0x43b0
movq 0x20(%rsp), %rsi
incq %rsi
movslq 0x6c(%r15), %rax
movq %rsi, 0x20(%rsp)
cmpq %rax, %rsi
movq %r15, %rbp
jl 0x4395
movq 0x18(%rsp), %rdx
incq %rdx
movslq 0x38b3c(%rip), %rax     # 0x3cf48
movq %rdx, 0x18(%rsp)
cmpq %rax, %rdx
jl 0x437d
movq %r13, %rdi
callq 0x21c0
movq %rbp, %rdi
callq 0x4d50
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq