// File: /workspace/github_cpp_makefile_star2_O1/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 0x56ee(%rip), %rdi      # 0x8094
leaq 0x56fd(%rip), %rbx      # 0x80aa
movq %rbx, %rsi
callq 0x21d0
movq %rax, %r14
leaq 0x56ed(%rip), %rdi      # 0x80ac
movq %rbx, %rsi
callq 0x21d0
movq %rax, 0x58(%rsp)
leaq 0x56f1(%rip), %rsi      # 0x80c4
leaq 0x9a56(%rip), %r15      # 0xc430
leaq 0xc(%rsp), %rcx
movq %r14, %rdi
movq %r15, %rdx
xorl %eax, %eax
callq 0x22a0
cmpl $0x2, %eax
jne 0x2ab6
leaq 0x20(%rsp), %rbx
leaq 0x10(%rsp), %r12
leaq 0xc(%rsp), %r13
movq %rbx, 0x10(%rsp)
movq %r15, %rdi
callq 0x20b0
leaq (%rax,%r15), %rdx
movq %r12, %rdi
movq %r15, %rsi
callq 0x6b74
movl 0xc(%rsp), %ebp
leaq 0x97dd(%rip), %rdi      # 0xc208
movq %r12, %rsi
callq 0x34c8
movl %ebp, (%rax)
leaq 0x97fc(%rip), %rdi      # 0xc238
movq %r13, %rsi
callq 0x3544
movq %rax, %rdi
movq %r12, %rsi
callq 0x20e0
leaq 0x9872(%rip), %rdi      # 0xc2c8
movq %r12, %rsi
callq 0x35a8
movq 0x8(%rax), %rdx
movl $0x4, %r8d
movq %rax, %rdi
xorl %esi, %esi
leaq 0x5655(%rip), %rcx      # 0x80c9
callq 0x2210
incl 0x993d(%rip)            # 0xc3bc
movq 0x10(%rsp), %rdi
cmpq %rbx, %rdi
je 0x2a96
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x21a0
movq %r14, %rdi
leaq 0x5624(%rip), %rsi      # 0x80c4
movq %r15, %rdx
movq %r13, %rcx
xorl %eax, %eax
callq 0x22a0
cmpl $0x2, %eax
je 0x2a04
leaq 0x5607(%rip), %rsi      # 0x80c4
leaq 0x996c(%rip), %r14      # 0xc430
leaq 0xc(%rsp), %rcx
movq 0x58(%rsp), %rdi
movq %r14, %rdx
xorl %eax, %eax
callq 0x22a0
cmpl $0x2, %eax
jne 0x2b7f
leaq 0x20(%rsp), %r12
leaq 0x10(%rsp), %r15
leaq 0xc(%rsp), %rbp
leaq 0x55cd(%rip), %rbx      # 0x80c4
movq %r12, 0x10(%rsp)
movq %r14, %rdi
callq 0x20b0
leaq (%rax,%r14), %rdx
movq %r15, %rdi
movq %r14, %rsi
callq 0x6b74
movl 0xc(%rsp), %r13d
leaq 0x96b9(%rip), %rdi      # 0xc1d8
movq %r15, %rsi
callq 0x34c8
movl %r13d, (%rax)
leaq 0x9737(%rip), %rdi      # 0xc268
movq %rbp, %rsi
callq 0x3544
movq %rax, %rdi
movq %r15, %rsi
callq 0x20e0
incl 0x9876(%rip)            # 0xc3c0
movq 0x10(%rsp), %rdi
cmpq %r12, %rdi
je 0x2b61
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x21a0
movq 0x58(%rsp), %rdi
movq %rbx, %rsi
movq %r14, %rdx
movq %rbp, %rcx
xorl %eax, %eax
callq 0x22a0
cmpl $0x2, %eax
je 0x2af7
leaq 0x5548(%rip), %rdi      # 0x80ce
leaq 0x551d(%rip), %r14      # 0x80aa
movq %r14, %rsi
callq 0x21d0
movq %rax, %rbp
leaq 0x5541(%rip), %rdi      # 0x80e0
movq %r14, %rsi
callq 0x21d0
movq %rax, 0x58(%rsp)
leaq 0x5551(%rip), %rsi      # 0x8104
leaq 0x9876(%rip), %r14      # 0xc430
movq %rbp, %rdi
movq %r14, %rdx
xorl %eax, %eax
callq 0x22a0
cmpl $0x1, %eax
jne 0x2e10
leaq 0x20(%rsp), %r15
leaq 0x48(%rsp), %r12
leaq 0x70(%rsp), %rbx
leaq 0x60(%rsp), %r13
movq %rbp, 0x80(%rsp)
movq %r15, 0x10(%rsp)
movq %r14, %rdi
callq 0x20b0
leaq (%rax,%r14), %rdx
leaq 0x10(%rsp), %rdi
movq %r14, %rsi
callq 0x6b74
movq %rbp, %rdi
leaq 0x54f0(%rip), %rsi      # 0x8104
movq %r14, %rdx
xorl %eax, %eax
callq 0x22a0
movq %r12, 0x38(%rsp)
movq %r14, %rdi
callq 0x20b0
leaq (%rax,%r14), %rdx
leaq 0x38(%rsp), %rdi
movq %r14, %rsi
callq 0x6b74
movq %rbp, %rdi
leaq 0x54be(%rip), %rsi      # 0x8104
movq %r14, %rdx
xorl %eax, %eax
callq 0x22a0
movq %rbx, 0x60(%rsp)
movq %r14, %rdi
callq 0x20b0
leaq (%rax,%r14), %rdx
movq %r13, %rdi
movq %r14, %rsi
callq 0x6b74
movq %r13, %rsi
leaq 0x9562(%rip), %rdi      # 0xc1d8
callq 0x34c8
movl (%rax), %eax
movl %eax, 0x30(%rsp)
movq 0x58(%rsp), %rdi
leaq 0x5439(%rip), %rsi      # 0x80c6
leaq 0x8(%rsp), %rdx
xorl %eax, %eax
callq 0x22a0
movq 0x9738(%rip), %rcx      # 0xc3d8
leaq 0x9729(%rip), %rdi      # 0xc3d0
movq %rdi, %rax
testq %rcx, %rcx
je 0x2ccd
movl 0x8(%rsp), %edx
movq %rdi, %rax
xorl %esi, %esi
cmpl %edx, 0x20(%rcx)
setl %sil
cmovgeq %rcx, %rax
movq 0x10(%rcx,%rsi,8), %rcx
testq %rcx, %rcx
jne 0x2cb6
cmpq %rdi, %rax
je 0x2cdb
movl 0x8(%rsp), %ecx
cmpl 0x20(%rax), %ecx
jge 0x2d23
incl 0x96d7(%rip)            # 0xc3b8
movl 0x30(%rsp), %ebp
leaq 0x96dc(%rip), %rdi      # 0xc3c8
leaq 0x8(%rsp), %rsi
callq 0x366e
movl %ebp, (%rax)
leaq 0x96f9(%rip), %rdi      # 0xc3f8
leaq 0x30(%rsp), %rsi
callq 0x36d2
movq 0x8(%rax), %rsi
cmpq 0x10(%rax), %rsi
je 0x2d41
movl 0x8(%rsp), %ecx
movl %ecx, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rax)
jmp 0x2d4e
leaq 0x969e(%rip), %rdi      # 0xc3c8
leaq 0x8(%rsp), %rsi
callq 0x366e
movl (%rax), %eax
cmpl 0x30(%rsp), %eax
je 0x2d4e
jmp 0x3171
movq %rax, %rdi
leaq 0x8(%rsp), %rdx
callq 0x6c04
leaq 0x94b3(%rip), %rdi      # 0xc208
leaq 0x10(%rsp), %rsi
callq 0x34c8
movl (%rax), %r14d
leaq 0x949f(%rip), %rdi      # 0xc208
leaq 0x38(%rsp), %rsi
callq 0x34c8
movl (%rax), %ebp
leaq 0x945c(%rip), %rdi      # 0xc1d8
movq %r13, %rsi
callq 0x34c8
movl (%rax), %ecx
leaq 0x3a3e3(%rip), %rdi     # 0x3d170
movl %r14d, %esi
movl %ebp, %edx
xorl %r8d, %r8d
callq 0x3736
movq 0x60(%rsp), %rdi
cmpq %rbx, %rdi
je 0x2db1
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x21a0
movq 0x38(%rsp), %rdi
cmpq %r12, %rdi
leaq 0x20(%rsp), %r15
movq 0x80(%rsp), %rbp
leaq 0x9663(%rip), %r14      # 0xc430
je 0x2ddc
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x21a0
movq 0x10(%rsp), %rdi
cmpq %r15, %rdi
je 0x2df3
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x21a0
movq %rbp, %rdi
leaq 0x5307(%rip), %rsi      # 0x8104
movq %r14, %rdx
xorl %eax, %eax
callq 0x22a0
cmpl $0x1, %eax
je 0x2bec
movq 0x58(%rsp), %rdi
callq 0x2180
movq %rbp, %rdi
callq 0x2180
leaq 0x52e9(%rip), %rdi      # 0x8112
leaq 0x527a(%rip), %rsi      # 0x80aa
callq 0x21d0
movq %rax, %rbx
leaq 0x52c5(%rip), %rsi      # 0x8104
leaq 0x95ea(%rip), %r14      # 0xc430
movq %rax, %rdi
movq %r14, %rdx
xorl %eax, %eax
callq 0x22a0
cmpl $0x1, %eax
jne 0x2fba
leaq 0x20(%rsp), %r13
leaq 0x48(%rsp), %rbp
leaq 0x5297(%rip), %r12      # 0x8104
movq %r13, 0x10(%rsp)
movq %r14, %rdi
callq 0x20b0
leaq (%rax,%r14), %rdx
leaq 0x10(%rsp), %rdi
movq %r14, %rsi
callq 0x6b74
movq %rbx, %rdi
movq %r12, %rsi
movq %r14, %rdx
xorl %eax, %eax
callq 0x22a0
movq %rbp, 0x38(%rsp)
movq %r14, %rdi
callq 0x20b0
leaq (%rax,%r14), %rdx
leaq 0x38(%rsp), %rdi
movq %r14, %rsi
callq 0x6b74
movq %r14, %r13
movq %rbx, %r15
movq %rbx, %rdi
movq %r12, %rbx
movq %r12, %rsi
movq %r14, %rdx
xorl %eax, %eax
callq 0x22a0
leaq 0x70(%rsp), %rax
movq %rax, %r12
movq %rax, 0x60(%rsp)
movq %r13, %rdi
callq 0x20b0
leaq (%rax,%r13), %rdx
leaq 0x60(%rsp), %rdi
movq %r13, %r14
movq %r13, %rsi
callq 0x6b74
leaq 0x9306(%rip), %rdi      # 0xc208
leaq 0x10(%rsp), %rsi
callq 0x34c8
movl (%rax), %r13d
leaq 0x92f2(%rip), %rdi      # 0xc208
leaq 0x38(%rsp), %rsi
callq 0x34c8
movl (%rax), %ebp
leaq 0x92af(%rip), %rdi      # 0xc1d8
leaq 0x60(%rsp), %rsi
callq 0x34c8
movl (%rax), %ecx
leaq 0x3a234(%rip), %rdi     # 0x3d170
movl %r13d, %esi
movl %ebp, %edx
movl $0x1, %r8d
callq 0x3736
movq 0x60(%rsp), %rdi
cmpq %r12, %rdi
je 0x2f63
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x21a0
movq 0x38(%rsp), %rdi
leaq 0x48(%rsp), %rbp
cmpq %rbp, %rdi
leaq 0x20(%rsp), %r13
movq %rbx, %r12
je 0x2f87
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x21a0
movq 0x10(%rsp), %rdi
cmpq %r13, %rdi
movq %r15, %rbx
je 0x2fa1
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x21a0
movq %rbx, %rdi
movq %r12, %rsi
movq %r14, %rdx
xorl %eax, %eax
callq 0x22a0
cmpl $0x1, %eax
je 0x2e6d
movq %rbx, %rdi
callq 0x2180
leaq 0x515a(%rip), %rdi      # 0x8123
leaq 0x50da(%rip), %rsi      # 0x80aa
callq 0x21d0
movq %rax, %rbx
leaq 0x5125(%rip), %rsi      # 0x8104
leaq 0x944a(%rip), %r14      # 0xc430
movq %rax, %rdi
movq %r14, %rdx
xorl %eax, %eax
callq 0x22a0
cmpl $0x1, %eax
jne 0x3157
leaq 0x20(%rsp), %r13
leaq 0x48(%rsp), %rbp
leaq 0x50f7(%rip), %r12      # 0x8104
movq %r13, 0x10(%rsp)
movq %r14, %rdi
callq 0x20b0
leaq (%rax,%r14), %rdx
leaq 0x10(%rsp), %rdi
movq %r14, %rsi
callq 0x6b74
movq %rbx, %rdi
movq %r12, %rsi
movq %r14, %rdx
xorl %eax, %eax
callq 0x22a0
movq %rbp, 0x38(%rsp)
movq %r14, %rdi
callq 0x20b0
leaq (%rax,%r14), %rdx
leaq 0x38(%rsp), %rdi
movq %r14, %rsi
callq 0x6b74
movq %r14, %r13
movq %rbx, %r15
movq %rbx, %rdi
movq %r12, %rbx
movq %r12, %rsi
movq %r14, %rdx
xorl %eax, %eax
callq 0x22a0
leaq 0x70(%rsp), %rax
movq %rax, %r12
movq %rax, 0x60(%rsp)
movq %r13, %rdi
callq 0x20b0
leaq (%rax,%r13), %rdx
leaq 0x60(%rsp), %rdi
movq %r13, %r14
movq %r13, %rsi
callq 0x6b74
leaq 0x9166(%rip), %rdi      # 0xc208
leaq 0x10(%rsp), %rsi
callq 0x34c8
movl (%rax), %r13d
leaq 0x9152(%rip), %rdi      # 0xc208
leaq 0x38(%rsp), %rsi
callq 0x34c8
movl (%rax), %ebp
leaq 0x910f(%rip), %rdi      # 0xc1d8
leaq 0x60(%rsp), %rsi
callq 0x34c8
movl (%rax), %ecx
leaq 0x3a094(%rip), %rdi     # 0x3d170
movl %r13d, %esi
movl %ebp, %edx
xorl %r8d, %r8d
callq 0x3736
movq 0x60(%rsp), %rdi
cmpq %r12, %rdi
je 0x3100
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x21a0
movq 0x38(%rsp), %rdi
leaq 0x48(%rsp), %rbp
cmpq %rbp, %rdi
leaq 0x20(%rsp), %r13
movq %rbx, %r12
je 0x3124
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x21a0
movq 0x10(%rsp), %rdi
cmpq %r13, %rdi
movq %r15, %rbx
je 0x313e
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x21a0
movq %rbx, %rdi
movq %r12, %rsi
movq %r14, %rdx
xorl %eax, %eax
callq 0x22a0
cmpl $0x1, %eax
je 0x300d
movq %rbx, %rdi
callq 0x2180
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x8e60(%rip), %rdi      # 0xbfd8
leaq 0x4f88(%rip), %rsi      # 0x8107
movl $0x8, %edx
callq 0x21c0
leaq 0x9078(%rip), %rdi      # 0xc208
leaq 0x10(%rsp), %rsi
callq 0x34c8
movl (%rax), %esi
movq 0x8e35(%rip), %rdi      # 0xbfd8
callq 0x2260
movq %rax, %r14
leaq 0x4f5e(%rip), %rsi      # 0x8110
movl $0x1, %edx
movq %rax, %rdi
callq 0x21c0
leaq 0x9042(%rip), %rdi      # 0xc208
leaq 0x38(%rsp), %rsi
callq 0x34c8
movl (%rax), %esi
movq %r14, %rdi
callq 0x2260
movq %rax, %r14
leaq 0x4f2c(%rip), %rsi      # 0x8110
movl $0x1, %edx
movq %rax, %rdi
callq 0x21c0
movl 0x8(%rsp), %esi
movq %r14, %rdi
callq 0x2260
leaq 0x37(%rsp), %rsi
movb $0x20, (%rsi)
movl $0x1, %edx
movq %rax, %rdi
callq 0x21c0
movl 0x30(%rsp), %esi
movq %rax, %rdi
callq 0x2260
movq %rax, %rdi
callq 0x20c0
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x21e0
jmp 0x32ee
jmp 0x326f
jmp 0x3241
jmp 0x3246
jmp 0x324d
jmp 0x324d
jmp 0x326f
movq %rax, %r14
jmp 0x32c0
movq %rax, %r14
jmp 0x32bb
jmp 0x324d
movq %rax, %r14
jmp 0x329f
jmp 0x326f
jmp 0x3256
movq %rax, %r14
jmp 0x3324
jmp 0x3260
movq %rax, %r14
jmp 0x330d
jmp 0x32ee
jmp 0x326f
movq %rax, %r14
jmp 0x32d7
movq %rax, %r14
movq 0x10(%rsp), %rdi
cmpq %r12, %rdi
jne 0x32ca
jmp 0x32d7
jmp 0x3285
movq %rax, %r14
movq 0x60(%rsp), %rdi
cmpq %r12, %rdi
je 0x329f
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x21a0
movq 0x38(%rsp), %rdi
leaq 0x48(%rsp), %rax
cmpq %rax, %rdi
je 0x32bb
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x21a0
leaq 0x20(%rsp), %r13
movq 0x10(%rsp), %rdi
cmpq %r13, %rdi
je 0x32d7
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x21a0
movq %r14, %rdi
callq 0x2270
movq %rax, %r14
movq 0x10(%rsp), %rdi
cmpq %rbx, %rdi
jne 0x32ca
jmp 0x32d7
movq %rax, %r14
movq 0x60(%rsp), %rdi
cmpq %rbx, %rdi
leaq 0x20(%rsp), %r15
je 0x330d
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x21a0
movq 0x38(%rsp), %rdi
cmpq %r12, %rdi
je 0x3324
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x21a0
movq 0x10(%rsp), %rdi
cmpq %r15, %rdi
jne 0x32ca
jmp 0x32d7