// File: /workspace/github_cpp_makefile_star2_O2/thunlp[P]KB2E/CTransR/Test_CTransR.cpp
// Function: prepare()
void prepare()
{
    FILE* f1 = fopen("../data/entity2id.txt","r");
	FILE* f2 = fopen("../data/relation2id.txt","r");
	int x;
	while (fscanf(f1,"%s%d",buf,&x)==2)
	{
		string st=buf;
		entity2id[st]=x;
		id2entity[x]=st;
		mid2type[st]="None";
		entity_num++;
	}
	while (fscanf(f2,"%s%d",buf,&x)==2)
	{
		string st=buf;
		relation2id[st]=x;
		id2relation[x]=st;
		fb_relation_num++;
	}


	FILE* f_kb_train = fopen("../data/train.txt","r");
	FILE* f_train_cluster = fopen("../cluster/output/train_cluster.txt","r");
	while (fscanf(f_kb_train,"%s",buf)==1)
    {
        string s1=buf;
        fscanf(f_kb_train,"%s",buf);
        string s2=buf;
        fscanf(f_kb_train,"%s",buf);
        string s3=buf;
        int rel_fb = relation2id[s3];
        int rel;
        fscanf(f_train_cluster,"%d",&rel);
        if (cluster2fb.count(rel)==0)
        {
            relation_num+=1;
            cluster2fb[rel]=rel_fb;
            fb2cluster[rel_fb].push_back(rel);
        }
        else
        if (cluster2fb[rel]!=rel_fb)
        {
            cout<<"not map:"<<entity2id[s1]<<" "<<entity2id[s2]<<" "<<rel<<' '<<rel_fb<<endl;
            exit(-1);
        }
        test.add(entity2id[s1],entity2id[s2],relation2id[s3],false);
    }

    fclose(f_train_cluster);
    fclose(f_kb_train);

    FILE* f_kb_test = fopen("../data/test.txt","r");
	while (fscanf(f_kb_test,"%s",buf)==1)
    {
        string s1=buf;
        fscanf(f_kb_test,"%s",buf);
        string s2=buf;
        fscanf(f_kb_test,"%s",buf);
        string s3=buf;
        test.add(entity2id[s1],entity2id[s2],relation2id[s3],true);
    }
    fclose(f_kb_test);

    FILE* f_kb_valid = fopen("../data/valid.txt","r");
	while (fscanf(f_kb_valid,"%s",buf)==1)
    {
        string s1=buf;
        fscanf(f_kb_valid,"%s",buf);
        string s2=buf;
        fscanf(f_kb_valid,"%s",buf);
        string s3=buf;
        test.add(entity2id[s1],entity2id[s2],relation2id[s3],false);
    }
    fclose(f_kb_valid);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
leaq 0x57a6(%rip), %rdi      # 0x8099
leaq 0x57b5(%rip), %rbx      # 0x80af
movq %rbx, %rsi
callq 0x21b0
movq %rax, %r14
leaq 0x57a5(%rip), %rdi      # 0x80b1
movq %rbx, %rsi
callq 0x21b0
movq %rax, 0x18(%rsp)
leaq 0x9b10(%rip), %r12      # 0xc430
leaq 0x14(%rsp), %r13
leaq 0x40(%rsp), %rbp
leaq 0x579d(%rip), %r15      # 0x80ce
movq %r14, %rdi
leaq 0x578e(%rip), %rsi      # 0x80c9
movq %r12, %rdx
movq %r13, %rcx
xorl %eax, %eax
callq 0x2280
cmpl $0x2, %eax
jne 0x29b9
movq %rbp, %rdi
movq %r12, %rsi
leaq 0x20(%rsp), %rdx
callq 0x2f9a
movl 0x14(%rsp), %ebx
leaq 0x98a0(%rip), %rdi      # 0xc208
movq %rbp, %rsi
callq 0x3082
movl %ebx, (%rax)
leaq 0x98bf(%rip), %rdi      # 0xc238
movq %r13, %rsi
callq 0x30e8
movq %rax, %rdi
movq %rbp, %rsi
callq 0x20c0
leaq 0x9935(%rip), %rdi      # 0xc2c8
movq %rbp, %rsi
callq 0x3136
movq %rax, %rdi
movq %r15, %rsi
callq 0x2290
incl 0x9a10(%rip)            # 0xc3bc
movq %rbp, %rdi
callq 0x22b8
jmp 0x2931
leaq 0x9a70(%rip), %r15      # 0xc430
leaq 0x14(%rsp), %r12
leaq 0x40(%rsp), %r13
leaq 0x9807(%rip), %r14      # 0xc1d8
leaq 0x9890(%rip), %rbx      # 0xc268
movq 0x18(%rsp), %rdi
leaq 0x56e5(%rip), %rsi      # 0x80c9
movq %r15, %rdx
movq %r12, %rcx
xorl %eax, %eax
callq 0x2280
cmpl $0x2, %eax
jne 0x2a3d
movq %r13, %rdi
movq %r15, %rsi
leaq 0x20(%rsp), %rdx
callq 0x2f9a
movl 0x14(%rsp), %ebp
movq %r14, %rdi
movq %r13, %rsi
callq 0x3082
movl %ebp, (%rax)
movq %rbx, %rdi
movq %r12, %rsi
callq 0x30e8
movq %rax, %rdi
movq %r13, %rsi
callq 0x20c0
incl 0x998d(%rip)            # 0xc3c0
movq %r13, %rdi
callq 0x22b8
jmp 0x29d8
leaq 0x568f(%rip), %rdi      # 0x80d3
leaq 0x5664(%rip), %r14      # 0x80af
movq %r14, %rsi
callq 0x21b0
movq %rax, 0x18(%rsp)
leaq 0x5686(%rip), %rdi      # 0x80e5
movq %r14, %rsi
callq 0x21b0
movq %rax, 0x60(%rsp)
leaq 0x5696(%rip), %rbp      # 0x8109
leaq 0x99b6(%rip), %r12      # 0xc430
leaq 0x20(%rsp), %r14
leaq 0x68(%rsp), %r13
movq 0x18(%rsp), %rdi
movq %rbp, %rsi
movq %r12, %rdx
xorl %eax, %eax
callq 0x2280
cmpl $0x1, %eax
jne 0x2c00
leaq 0x40(%rsp), %rdi
movq %r12, %rsi
movq %r14, %rdx
callq 0x2f9a
movq 0x18(%rsp), %rdi
movq %rbp, %rsi
movq %r12, %rdx
xorl %eax, %eax
callq 0x2280
movq %r14, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x2f9a
movq 0x18(%rsp), %rdi
movq %rbp, %rsi
movq %r12, %rdx
xorl %eax, %eax
callq 0x2280
movq %r13, %rdi
movq %r12, %rsi
leaq 0xc(%rsp), %rdx
callq 0x2f9a
leaq 0x96e0(%rip), %rdi      # 0xc1d8
movq %r13, %rbx
movq %r13, %rsi
callq 0x3082
movl (%rax), %eax
movl %eax, 0xc(%rsp)
movq 0x60(%rsp), %rdi
leaq 0x55b6(%rip), %rsi      # 0x80cb
leaq 0x10(%rsp), %rdx
xorl %eax, %eax
callq 0x2280
leaq 0x98a0(%rip), %rdi      # 0xc3c8
leaq 0x10(%rsp), %rsi
callq 0x319c
testq %rax, %rax
je 0x2b55
leaq 0x988a(%rip), %rdi      # 0xc3c8
leaq 0x10(%rsp), %rsi
callq 0x31b6
movl (%rax), %eax
cmpl 0xc(%rsp), %eax
je 0x2b92
jmp 0x2e4d
incl 0x985d(%rip)            # 0xc3b8
movl 0xc(%rsp), %r15d
leaq 0x9861(%rip), %rdi      # 0xc3c8
leaq 0x10(%rsp), %rsi
callq 0x31b6
movl %r15d, (%rax)
leaq 0x987d(%rip), %rdi      # 0xc3f8
leaq 0xc(%rsp), %rsi
callq 0x3204
movq %rax, %rdi
leaq 0x10(%rsp), %rsi
callq 0x3252
leaq 0x966f(%rip), %rdi      # 0xc208
leaq 0x40(%rsp), %rsi
callq 0x3082
movl (%rax), %r13d
leaq 0x965b(%rip), %rdi      # 0xc208
movq %r14, %rsi
callq 0x3082
movl (%rax), %r15d
leaq 0x9619(%rip), %rdi      # 0xc1d8
movq %rbx, %rsi
callq 0x3082
movl (%rax), %ecx
leaq 0x3a5a0(%rip), %rdi     # 0x3d170
movl %r13d, %esi
movl %r15d, %edx
xorl %r8d, %r8d
callq 0x3270
movq %rbx, %r13
movq %rbx, %rdi
callq 0x22b8
movq %r14, %rdi
callq 0x22b8
leaq 0x40(%rsp), %rdi
callq 0x22b8
jmp 0x2a84
movq 0x60(%rsp), %rdi
callq 0x2160
movq 0x18(%rsp), %rdi
callq 0x2160
leaq 0x54fc(%rip), %rdi      # 0x8117
leaq 0x548d(%rip), %rsi      # 0x80af
callq 0x21b0
movq %rax, %rbx
leaq 0x54d8(%rip), %r13      # 0x8109
leaq 0x97f8(%rip), %r15      # 0xc430
leaq 0x40(%rsp), %r12
movq %rbx, %rdi
movq %r13, %rsi
movq %r15, %rdx
xorl %eax, %eax
callq 0x2280
cmpl $0x1, %eax
jne 0x2d20
movq %r12, %rdi
movq %r15, %rsi
leaq 0x20(%rsp), %rdx
callq 0x2f9a
movq %rbx, %rdi
movq %r13, %rsi
movq %r15, %rdx
xorl %eax, %eax
callq 0x2280
leaq 0x20(%rsp), %rdi
movq %r15, %rsi
leaq 0x68(%rsp), %rdx
callq 0x2f9a
movq %rbx, %rdi
movq %r13, %rsi
movq %r15, %rdx
xorl %eax, %eax
callq 0x2280
leaq 0x68(%rsp), %rdi
movq %r15, %rsi
leaq 0xc(%rsp), %rdx
callq 0x2f9a
leaq 0x9557(%rip), %rdi      # 0xc208
movq %r12, %rbp
movq %r12, %rsi
callq 0x3082
movl (%rax), %r14d
leaq 0x9542(%rip), %rdi      # 0xc208
leaq 0x20(%rsp), %rsi
callq 0x3082
movl (%rax), %r12d
leaq 0x94fe(%rip), %rdi      # 0xc1d8
leaq 0x68(%rsp), %rsi
callq 0x3082
movl (%rax), %ecx
leaq 0x3a483(%rip), %rdi     # 0x3d170
movl %r14d, %esi
movl %r12d, %edx
pushq $0x1
popq %r8
callq 0x3270
leaq 0x68(%rsp), %rdi
callq 0x22b8
leaq 0x20(%rsp), %rdi
callq 0x22b8
movq %rbp, %r12
movq %rbp, %rdi
callq 0x22b8
jmp 0x2c3d
movq %rbx, %rdi
callq 0x2160
leaq 0x53f9(%rip), %rdi      # 0x8128
leaq 0x5379(%rip), %rsi      # 0x80af
callq 0x21b0
movq %rax, %rbx
leaq 0x53c4(%rip), %r13      # 0x8109
leaq 0x96e4(%rip), %r15      # 0xc430
leaq 0x40(%rsp), %r12
movq %rbx, %rdi
movq %r13, %rsi
movq %r15, %rdx
xorl %eax, %eax
callq 0x2280
cmpl $0x1, %eax
jne 0x2e33
movq %r12, %rdi
movq %r15, %rsi
leaq 0x20(%rsp), %rdx
callq 0x2f9a
movq %rbx, %rdi
movq %r13, %rsi
movq %r15, %rdx
xorl %eax, %eax
callq 0x2280
leaq 0x20(%rsp), %rdi
movq %r15, %rsi
leaq 0x68(%rsp), %rdx
callq 0x2f9a
movq %rbx, %rdi
movq %r13, %rsi
movq %r15, %rdx
xorl %eax, %eax
callq 0x2280
leaq 0x68(%rsp), %rdi
movq %r15, %rsi
leaq 0xc(%rsp), %rdx
callq 0x2f9a
leaq 0x9443(%rip), %rdi      # 0xc208
movq %r12, %rbp
movq %r12, %rsi
callq 0x3082
movl (%rax), %r14d
leaq 0x942e(%rip), %rdi      # 0xc208
leaq 0x20(%rsp), %rsi
callq 0x3082
movl (%rax), %r12d
leaq 0x93ea(%rip), %rdi      # 0xc1d8
leaq 0x68(%rsp), %rsi
callq 0x3082
movl (%rax), %ecx
leaq 0x3a36f(%rip), %rdi     # 0x3d170
movl %r14d, %esi
movl %r12d, %edx
xorl %r8d, %r8d
callq 0x3270
leaq 0x68(%rsp), %rdi
callq 0x22b8
leaq 0x20(%rsp), %rdi
callq 0x22b8
movq %rbp, %r12
movq %rbp, %rdi
callq 0x22b8
jmp 0x2d51
movq %rbx, %rdi
callq 0x2160
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x9184(%rip), %rdi      # 0xbfd8
leaq 0x52b1(%rip), %rsi      # 0x810c
callq 0x2150
movq %rax, %rbx
leaq 0x939e(%rip), %rdi      # 0xc208
leaq 0x40(%rsp), %rsi
callq 0x3082
movl (%rax), %esi
movq %rbx, %rdi
callq 0x2240
leaq 0x5290(%rip), %rsi      # 0x8115
movq %rax, %rdi
callq 0x2150
movq %rax, %rbx
leaq 0x9371(%rip), %rdi      # 0xc208
leaq 0x20(%rsp), %rsi
callq 0x3082
movl (%rax), %esi
movq %rbx, %rdi
callq 0x2240
leaq 0x5263(%rip), %rsi      # 0x8115
movq %rax, %rdi
callq 0x2150
movl 0x10(%rsp), %esi
movq %rax, %rdi
callq 0x2240
pushq $0x20
popq %rsi
movq %rax, %rdi
callq 0x21a0
movl 0xc(%rsp), %esi
movq %rax, %rdi
callq 0x2240
movq %rax, %rdi
callq 0x20a0
pushq $-0x1
popq %rdi
callq 0x21c0
jmp 0x2f24
jmp 0x2f14
jmp 0x2f1f
jmp 0x2f1f
jmp 0x2f09
jmp 0x2f09
jmp 0x2f14
jmp 0x2f1f
jmp 0x2f1f
jmp 0x2f09
jmp 0x2f09
jmp 0x2f1f
jmp 0x2f24
jmp 0x2f09
movq %rax, %rbx
jmp 0x2f31
jmp 0x2f1f
jmp 0x2f14
jmp 0x2f14
movq %rax, %rbx
jmp 0x2f45
jmp 0x2f1f
jmp 0x2f24
jmp 0x2f24
movq %rax, %rbx
jmp 0x2f3b
movq %rax, %rbx
leaq 0x68(%rsp), %rdi
callq 0x22b8
leaq 0x20(%rsp), %rdi
callq 0x22b8
leaq 0x40(%rsp), %rdi
callq 0x22b8
movq %rbx, %rdi
callq 0x2250