// File: 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:
subq $0xd8, %rsp
movq %rdi, 0xd0(%rsp)
movl %esi, 0xcc(%rsp)
movsd %xmm0, 0xc0(%rsp)
movsd %xmm1, 0xb8(%rsp)
movl %edx, 0xb4(%rsp)
movq 0xd0(%rsp), %rdi
movq %rdi, 0x50(%rsp)
movl 0xcc(%rsp), %eax
movl %eax, 0x68(%rdi)
movl 0xcc(%rsp), %eax
movl %eax, 0x6c(%rdi)
movsd 0xc0(%rsp), %xmm0
movsd %xmm0, 0x80(%rdi)
movsd 0xb8(%rsp), %xmm0
movsd %xmm0, 0x88(%rdi)
movl 0xb4(%rsp), %eax
movl %eax, 0x70(%rdi)
addq $0x168, %rdi            # imm = 0x168
movslq 0x4b49e(%rip), %rsi     # 0x4ffb8
callq 0x8b80
movl $0x0, 0xb0(%rsp)
movl 0xb0(%rsp), %eax
cmpl 0x4b481(%rip), %eax     # 0x4ffb8
jge 0x4be8
movq 0x50(%rsp), %rdi
addq $0x168, %rdi            # imm = 0x168
movslq 0xb0(%rsp), %rsi
callq 0x8c20
movq %rax, %rdi
movq 0x50(%rsp), %rax
movslq 0x68(%rax), %rsi
callq 0x8c40
movl $0x0, 0xac(%rsp)
movq 0x50(%rsp), %rcx
movl 0xac(%rsp), %eax
cmpl 0x68(%rcx), %eax
jge 0x4bd0
movq 0x50(%rsp), %rdi
addq $0x168, %rdi            # imm = 0x168
movslq 0xb0(%rsp), %rsi
callq 0x8c20
movq %rax, %rdi
movslq 0xac(%rsp), %rsi
callq 0x8ce0
movq %rax, %rdi
movq 0x50(%rsp), %rax
movslq 0x6c(%rax), %rsi
callq 0x8d00
movl 0xac(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xac(%rsp)
jmp 0x4b72
jmp 0x4bd2
movl 0xb0(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xb0(%rsp)
jmp 0x4b2a
movq 0x50(%rsp), %rdi
addq $0xd8, %rdi
movslq 0x4b3b5(%rip), %rsi     # 0x4ffb0
callq 0x8c40
movl $0x0, 0xa8(%rsp)
movq 0x50(%rsp), %rdi
movslq 0xa8(%rsp), %rax
movq %rax, 0x48(%rsp)
addq $0xd8, %rdi
callq 0x8da0
movq %rax, %rcx
movq 0x48(%rsp), %rax
cmpq %rcx, %rax
jae 0x4d15
movq 0x50(%rsp), %rdi
addq $0xd8, %rdi
movslq 0xa8(%rsp), %rsi
callq 0x8ce0
movq %rax, %rdi
movq 0x50(%rsp), %rax
movslq 0x6c(%rax), %rsi
callq 0x8d00
movl $0x0, 0xa4(%rsp)
movq 0x50(%rsp), %rcx
movl 0xa4(%rsp), %eax
cmpl 0x6c(%rcx), %eax
jge 0x4cfd
movq 0x50(%rsp), %rax
cvtsi2sdl 0x6c(%rax), %xmm0
movsd 0x1138e(%rip), %xmm1    # 0x16020
divsd %xmm0, %xmm1
xorps %xmm0, %xmm0
movsd 0x11377(%rip), %xmm2    # 0x16018
movsd 0x11377(%rip), %xmm3    # 0x16020
callq 0x29f0
movq 0x50(%rsp), %rdi
movsd %xmm0, 0x40(%rsp)
addq $0xd8, %rdi
movslq 0xa8(%rsp), %rsi
callq 0x8ce0
movq %rax, %rdi
movslq 0xa4(%rsp), %rsi
callq 0x3fb0
movsd 0x40(%rsp), %xmm0
movsd %xmm0, (%rax)
movl 0xa4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xa4(%rsp)
jmp 0x4c6f
jmp 0x4cff
movl 0xa8(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xa8(%rsp)
jmp 0x4c0b
movq 0x50(%rsp), %rdi
addq $0x108, %rdi            # imm = 0x108
movslq 0x4b290(%rip), %rsi     # 0x4ffb8
callq 0x8c40
movl $0x0, 0xa0(%rsp)
movq 0x50(%rsp), %rdi
movslq 0xa0(%rsp), %rax
movq %rax, 0x38(%rsp)
addq $0x108, %rdi            # imm = 0x108
callq 0x8da0
movq %rax, %rcx
movq 0x38(%rsp), %rax
cmpq %rcx, %rax
jae 0x4e42
movq 0x50(%rsp), %rdi
addq $0x108, %rdi            # imm = 0x108
movslq 0xa0(%rsp), %rsi
callq 0x8ce0
movq %rax, %rdi
movq 0x50(%rsp), %rax
movslq 0x6c(%rax), %rsi
callq 0x8d00
movl $0x0, 0x9c(%rsp)
movq 0x50(%rsp), %rcx
movl 0x9c(%rsp), %eax
cmpl 0x6c(%rcx), %eax
jge 0x4e2a
movq 0x50(%rsp), %rax
cvtsi2sdl 0x6c(%rax), %xmm0
movsd 0x11261(%rip), %xmm1    # 0x16020
divsd %xmm0, %xmm1
xorps %xmm0, %xmm0
movsd 0x1124a(%rip), %xmm2    # 0x16018
movsd 0x1124a(%rip), %xmm3    # 0x16020
callq 0x29f0
movq 0x50(%rsp), %rdi
movsd %xmm0, 0x30(%rsp)
addq $0x108, %rdi            # imm = 0x108
movslq 0xa0(%rsp), %rsi
callq 0x8ce0
movq %rax, %rdi
movslq 0x9c(%rsp), %rsi
callq 0x3fb0
movsd 0x30(%rsp), %xmm0
movsd %xmm0, (%rax)
movl 0x9c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x9c(%rsp)
jmp 0x4d9c
jmp 0x4e2c
movl 0xa0(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xa0(%rsp)
jmp 0x4d38
movq 0x50(%rsp), %rdi
addq $0xf0, %rdi
movslq 0x4b15f(%rip), %rsi     # 0x4ffb4
callq 0x8c40
movl $0x0, 0x98(%rsp)
movq 0x50(%rsp), %rdi
movslq 0x98(%rsp), %rax
movq %rax, 0x28(%rsp)
addq $0xf0, %rdi
callq 0x8da0
movq %rax, %rcx
movq 0x28(%rsp), %rax
cmpq %rcx, %rax
jae 0x4ecd
movq 0x50(%rsp), %rdi
addq $0xf0, %rdi
movslq 0x98(%rsp), %rsi
callq 0x8ce0
movq %rax, %rdi
movq 0x50(%rsp), %rax
movslq 0x68(%rax), %rsi
callq 0x8d00
movl 0x98(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x98(%rsp)
jmp 0x4e65
leaq 0x112c1(%rip), %rdi     # 0x16195
leaq 0x111ab(%rip), %rsi     # 0x16086
callq 0x22b0
movq %rax, 0x90(%rsp)
movl $0x0, 0x8c(%rsp)
movl 0x8c(%rsp), %eax
cmpl 0x4b0b4(%rip), %eax     # 0x4ffb4
jge 0x4fbd
movl $0x0, 0x88(%rsp)
movq 0x50(%rsp), %rcx
movl 0x88(%rsp), %eax
cmpl 0x68(%rcx), %eax
jge 0x4f81
movq 0x50(%rsp), %rdi
movq 0x90(%rsp), %rax
movq %rax, 0x20(%rsp)
addq $0xf0, %rdi
movslq 0x8c(%rsp), %rsi
callq 0x8ce0
movq %rax, %rdi
movslq 0x88(%rsp), %rsi
callq 0x3fb0
movq 0x20(%rsp), %rdi
movq %rax, %rdx
leaq 0x11248(%rip), %rsi     # 0x161af
movb $0x0, %al
callq 0x23e0
movl 0x88(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x88(%rsp)
jmp 0x4f11
movq 0x50(%rsp), %rdi
addq $0xf0, %rdi
movslq 0x8c(%rsp), %rsi
callq 0x8ce0
movq 0x50(%rsp), %rdi
movq %rax, %rsi
callq 0x8dc0
movl 0x8c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x8c(%rsp)
jmp 0x4ef3
movq 0x90(%rsp), %rdi
callq 0x2210
leaq 0x111e2(%rip), %rdi     # 0x161b3
leaq 0x110ae(%rip), %rsi     # 0x16086
callq 0x22b0
movq %rax, 0x80(%rsp)
movl $0x0, 0x7c(%rsp)
movl 0x7c(%rsp), %eax
cmpl 0x4afc1(%rip), %eax     # 0x4ffb8
jge 0x5074
movl $0x0, 0x78(%rsp)
movq 0x50(%rsp), %rcx
movl 0x78(%rsp), %eax
cmpl 0x68(%rcx), %eax
jge 0x5062
movq 0x50(%rsp), %rdi
movq 0x80(%rsp), %rax
movq %rax, 0x18(%rsp)
addq $0x108, %rdi            # imm = 0x108
movslq 0x7c(%rsp), %rsi
callq 0x8ce0
movq %rax, %rdi
movslq 0x78(%rsp), %rsi
callq 0x3fb0
movq 0x18(%rsp), %rdi
movq %rax, %rdx
leaq 0x11161(%rip), %rsi     # 0x161af
movb $0x0, %al
callq 0x23e0
movl 0x78(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x78(%rsp)
jmp 0x5001
jmp 0x5064
movl 0x7c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x7c(%rsp)
jmp 0x4fed
movq 0x80(%rsp), %rdi
callq 0x2210
movl $0x0, 0x74(%rsp)
movl 0x74(%rsp), %eax
cmpl 0x4af1d(%rip), %eax     # 0x4ffb0
jge 0x5147
movl $0x0, 0x70(%rsp)
movq 0x50(%rsp), %rcx
movl 0x70(%rsp), %eax
cmpl 0x68(%rcx), %eax
jge 0x5135
movq 0x50(%rsp), %rax
addq $0x108, %rax            # imm = 0x108
movq %rax, 0x8(%rsp)
leaq 0x4aef6(%rip), %rdi     # 0x4ffc0
leaq 0x74(%rsp), %rsi
callq 0x4680
movq 0x8(%rsp), %rdi
movslq (%rax), %rsi
callq 0x8ce0
movq %rax, %rdi
movslq 0x70(%rsp), %rsi
callq 0x3fb0
movq 0x50(%rsp), %rdi
movsd (%rax), %xmm0
movsd %xmm0, 0x10(%rsp)
addq $0xd8, %rdi
movslq 0x74(%rsp), %rsi
callq 0x8ce0
movq %rax, %rdi
movslq 0x70(%rsp), %rsi
callq 0x3fb0
movsd 0x10(%rsp), %xmm0
movsd %xmm0, (%rax)
movl 0x70(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x70(%rsp)
jmp 0x50a1
jmp 0x5137
movl 0x74(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x74(%rsp)
jmp 0x5089
leaq 0x11081(%rip), %rdi     # 0x161cf
leaq 0x10f31(%rip), %rsi     # 0x16086
callq 0x22b0
movq %rax, 0x68(%rsp)
movl $0x0, 0x64(%rsp)
movl 0x64(%rsp), %eax
cmpl 0x4ae47(%rip), %eax     # 0x4ffb8
jge 0x5226
movl $0x0, 0x60(%rsp)
movq 0x50(%rsp), %rcx
movl 0x60(%rsp), %eax
cmpl 0x6c(%rcx), %eax
jge 0x5214
movl $0x0, 0x5c(%rsp)
movq 0x50(%rsp), %rcx
movl 0x5c(%rsp), %eax
cmpl 0x68(%rcx), %eax
jge 0x5202
movq 0x50(%rsp), %rdi
movq 0x68(%rsp), %rax
movq %rax, (%rsp)
addq $0x168, %rdi            # imm = 0x168
movslq 0x64(%rsp), %rsi
callq 0x8c20
movq %rax, %rdi
movslq 0x60(%rsp), %rsi
callq 0x8ce0
movq %rax, %rdi
movslq 0x5c(%rsp), %rsi
callq 0x3fb0
movq (%rsp), %rdi
movq %rax, %rdx
leaq 0x10fc1(%rip), %rsi     # 0x161af
movb $0x0, %al
callq 0x23e0
movl 0x5c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x5c(%rsp)
jmp 0x5199
jmp 0x5204
movl 0x60(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x60(%rsp)
jmp 0x517f
jmp 0x5216
movl 0x64(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x64(%rsp)
jmp 0x5167
movq 0x68(%rsp), %rdi
callq 0x2210
movq 0x50(%rsp), %rdi
callq 0x8e60
addq $0xd8, %rsp
retq
nopw %cs:(%rax,%rax)
nopl (%rax)