// File: /workspace/github_cpp_makefile_star2_O1/thunlp[P]KB2E/cluster/prepare.cpp
// Function: main
int main()
{
    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;
		entity_num++;
	}
	while (fscanf(f2,"%s%d",buf,&x)==2)
	{
		string st=buf;
		relation2id[st]=x;
		id2relation[x]=st;
		relation_num++;
	}
	fclose(f1);
	fclose(f2);
    FILE* f_ent_vec = fopen("../TransE/entity2vec.txt2","r");
    int vec_size=50;
    entity_vec.resize(entity_num);
    for (int i=0; i<entity_num;i++)
    {
        entity_vec[i].resize(vec_size);
        for (int ii=0; ii<vec_size; ii++)
        {
            fscanf(f_ent_vec,"%lf",&entity_vec[i][ii]);
        }
    }
    fclose(f_ent_vec);
    FILE* f_kb_train = fopen("../data/train.txt","r");
    vector<int> train_e1,train_e2,train_rel,train_index,train_cluster;
    int train_num=0;
	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 e1 = entity2id[s1];
        int e2 = entity2id[s2];
        int rel = relation2id[s3];
        train_num+=1;
        train_e1.push_back(e1);
        train_e2.push_back(e2);
        train_rel.push_back(rel);
    }
    train_cluster.resize(train_num);
    fclose(f_kb_train);
    int cluster_num=0;
    map<int,int> cluster2id;
    rel_cluster_set.resize(relation_num);
    for (int rel =0; rel<relation_num; rel++)
    {
        map<int,int> ok;
        ok.clear();
        string s;
        stringstream ss;
        ss<<rel;
        ss>>s;
        cout<<s<<endl;
        FILE* f_index = fopen(("data/id2index"+s+".txt").c_str(),"r");
        FILE* f_cluster = fopen(("data/cluster"+s+".txt").c_str(),"r");
        int x,y;
        while (fscanf(f_index,"%d",&x)==1)
        {
            if (f_cluster!=NULL)
                fscanf(f_cluster,"%d",&y);
            else
                y=0;
            if (ok.count(y)==0)
            {
                ok[y]=cluster_num;
                cluster2id[cluster_num]=x;
                rel_cluster_set[train_rel[x]].push_back(cluster_num);

                cluster_size.push_back(0);
                vector<double> tmp;
                tmp.resize(vec_size);
                cluster_center.push_back(tmp);
                cluster_num+=1;
            }
            for (int ii=0; ii<vec_size; ii++)
                cluster_center[ok[y]][ii]+=entity_vec[train_e1[x]][ii]-entity_vec[train_e2[x]][ii];
            train_cluster[x]=ok[y];
            cluster_size[ok[y]]+=1;
        }
        fclose(f_index);
        if (f_cluster!=NULL)
            fclose(f_cluster);
    }
    FILE* f_train_cluster = fopen("output/train_cluster.txt","w");
    for (int i=0; i<train_num; i++)
        fprintf(f_train_cluster,"%d\n",train_cluster[i]);
    fclose(f_train_cluster);
    cout<<cluster_num<<endl;
    FILE* f_test_cluster = fopen("output/test_cluster.txt","w");
    FILE* f_kb_test = fopen("../data/test.txt","r");
   // for (int i=0; i<cluster_num; i++)
   // {
  //      cout<<cluster_center[i][0]/cluster_size[i]<<endl;
   // }
    int step=0;
	while (fscanf(f_kb_test,"%s",buf)==1)
    {
        cout<<step++<<endl;
        string s1=buf;
        fscanf(f_kb_test,"%s",buf);
        string s2=buf;
        fscanf(f_kb_test,"%s",buf);
        string s3=buf;
        int e1 = entity2id[s1];
        int e2 = entity2id[s2];
        int rel = relation2id[s3];
       // cout<<"here"<<endl;
        for (int h=0; h<entity_num; h++)
        {
            double dis = 1e9;
            int k=-1;
            for (int i=0; i<rel_cluster_set[rel].size(); i++)
            {
                double tmp = 0;
                int x = rel_cluster_set[rel][i];
               // cout<<x<<' '<<rel_cluster_set[rel][i]<<' '<<h<<' '<<train_e1[x]<<' '<<train_e2[x]<<endl;
                for (int ii=0; ii<50; ii++)
                    tmp+=sqr(entity_vec[h][ii]-entity_vec[e2][ii]-cluster_center[x][ii]/cluster_size[x]);

               // cout<<x<<endl;
                if (tmp<dis)
                {
                    dis = tmp;
                    k = rel_cluster_set[rel][i];
                }
            }
            fprintf(f_test_cluster,"%d\t",k);
        }

       // cout<<"here"<<endl;
        fprintf(f_test_cluster,"\n");
        for (int t=0; t<entity_num; t++)
        {
            double dis = 1e9;
            int k=-1;
            for (int i=0; i<rel_cluster_set[rel].size(); i++)
            {
                double tmp = 0;
                int x = rel_cluster_set[rel][i];
                for (int ii=0; ii<50; ii++)
                    tmp+=sqr(entity_vec[e1][ii]-entity_vec[t][ii]-cluster_center[x][ii]/cluster_size[x]);
               // cout<<"tmp="<<tmp<<' '<<rel_cluster_set[rel][i]<<endl;
                if (tmp<dis)
                {
                    dis = tmp;
                    k = rel_cluster_set[rel][i];
                }
            }
            fprintf(f_test_cluster,"%d\t",k);
        }
        fprintf(f_test_cluster,"\n");
    }
    fclose(f_kb_test);
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x308, %rsp            # imm = 0x308
leaq 0x3a17(%rip), %rdi      # 0x6020
leaq 0x3a8f(%rip), %r14      # 0x609f
movq %r14, %rsi
callq 0x21e0
movq %rax, %rbx
leaq 0x3a14(%rip), %rdi      # 0x6036
movq %r14, %rsi
callq 0x21e0
movq %rax, %r14
leaq 0x3a1a(%rip), %rsi      # 0x604e
leaq 0x6c25(%rip), %r15      # 0x9260
leaq 0xc(%rsp), %rcx
movq %rbx, 0x10(%rsp)
movq %rbx, %rdi
movq %r15, %rdx
xorl %eax, %eax
callq 0x22a0
cmpl $0x2, %eax
jne 0x270e
leaq 0x180(%rsp), %r12
leaq 0xc(%rsp), %r13
leaq 0x39df(%rip), %rbp      # 0x604e
leaq 0x190(%rsp), %rax
movq %rax, 0x180(%rsp)
movq %r15, %rdi
callq 0x20c0
leaq (%rax,%r15), %rdx
movq %r12, %rdi
movq %r15, %rsi
callq 0x3da4
movl 0xc(%rsp), %ebx
leaq 0x6b27(%rip), %rdi      # 0x91c8
movq %r12, %rsi
callq 0x3984
movl %ebx, (%rax)
leaq 0x6b46(%rip), %rdi      # 0x91f8
movq %r13, %rsi
callq 0x3a00
movq %rax, %rdi
movq %r12, %rsi
callq 0x20e0
incl 0x6b8d(%rip)            # 0x9258
movq 0x180(%rsp), %rdi
leaq 0x190(%rsp), %rax
cmpq %rax, %rdi
je 0x26f0
movq 0x190(%rsp), %rsi
incq %rsi
callq 0x21b0
movq 0x10(%rsp), %rdi
movq %rbp, %rsi
movq %r15, %rdx
movq %r13, %rcx
xorl %eax, %eax
callq 0x22a0
cmpl $0x2, %eax
je 0x266f
leaq 0x3939(%rip), %rsi      # 0x604e
leaq 0x6b44(%rip), %rbx      # 0x9260
leaq 0xc(%rsp), %rcx
movq %r14, %rdi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x22a0
cmpl $0x2, %eax
jne 0x27f2
leaq 0x180(%rsp), %r15
leaq 0x6ae2(%rip), %r13      # 0x9228
leaq 0xc(%rsp), %rbp
leaq 0x38fc(%rip), %r12      # 0x604e
leaq 0x190(%rsp), %rax
movq %rax, 0x180(%rsp)
movq %rbx, %rdi
callq 0x20c0
leaq (%rax,%rbx), %rdx
movq %r15, %rdi
movq %rbx, %rsi
callq 0x3da4
movl 0xc(%rsp), %ebx
leaq 0x6a14(%rip), %rdi      # 0x9198
movq %r15, %rsi
callq 0x3984
movl %ebx, (%rax)
movq %r13, %rdi
movq %rbp, %rsi
callq 0x3a00
movq %rax, %rdi
movq %r15, %rsi
callq 0x20e0
incl 0x6ab2(%rip)            # 0x925c
movq 0x180(%rsp), %rdi
leaq 0x190(%rsp), %rax
cmpq %rax, %rdi
je 0x27cf
movq 0x190(%rsp), %rsi
incq %rsi
callq 0x21b0
movq %r14, %rdi
movq %r12, %rsi
leaq 0x6a84(%rip), %rbx      # 0x9260
movq %rbx, %rdx
movq %rbp, %rcx
xorl %eax, %eax
callq 0x22a0
cmpl $0x2, %eax
je 0x2752
movq 0x10(%rsp), %rdi
callq 0x2190
movq %r14, %rdi
callq 0x2190
leaq 0x3848(%rip), %rdi      # 0x6053
leaq 0x388d(%rip), %rsi      # 0x609f
callq 0x21e0
movq %rax, %rbx
movslq 0x6a37(%rip), %rsi      # 0x9258
leaq 0x37778(%rip), %rdi     # 0x39fa0
callq 0x3a64
cmpl $0x0, 0x6a24(%rip)      # 0x9258
jle 0x2897
leaq 0x3830(%rip), %r14      # 0x606d
xorl %r15d, %r15d
leaq (%r15,%r15,2), %r12
leaq (,%r12,8), %rdi
addq 0x3774d(%rip), %rdi     # 0x39fa0
movl $0x32, %esi
callq 0x3aa0
xorl %r13d, %r13d
movq 0x37739(%rip), %rax     # 0x39fa0
movq (%rax,%r12,8), %rdx
addq %r13, %rdx
movq %rbx, %rdi
movq %r14, %rsi
xorl %eax, %eax
callq 0x22a0
addq $0x8, %r13
cmpq $0x190, %r13            # imm = 0x190
jne 0x2860
incq %r15
movslq 0x69c6(%rip), %rax      # 0x9258
cmpq %rax, %r15
jl 0x2840
movq %rbx, %rdi
callq 0x2190
leaq 0x37cb(%rip), %rdi      # 0x6071
leaq 0x37f2(%rip), %rsi      # 0x609f
callq 0x21e0
movq %rax, %rbx
xorl %eax, %eax
leaq 0x110(%rsp), %rcx
movq %rax, 0x10(%rcx)
xorpd %xmm0, %xmm0
movapd %xmm0, (%rcx)
leaq 0xf0(%rsp), %rcx
movq %rax, 0x10(%rcx)
movapd %xmm0, (%rcx)
leaq 0xd0(%rsp), %rcx
movq %rax, 0x10(%rcx)
movapd %xmm0, (%rcx)
movq %rax, 0x140(%rsp)
movapd %xmm0, 0x130(%rsp)
leaq 0x3780(%rip), %r13      # 0x6083
leaq 0x150(%rsp), %r14
leaq 0xa0(%rsp), %r15
leaq 0x68ae(%rip), %r12      # 0x91c8
movq $0x0, 0x68(%rsp)
movq %rbx, %rdi
movq %r13, %rsi
leaq 0x6930(%rip), %rdx      # 0x9260
xorl %eax, %eax
callq 0x22a0
cmpl $0x1, %eax
jne 0x2b3e
leaq 0x190(%rsp), %rax
movq %rax, 0x180(%rsp)
leaq 0x6909(%rip), %rbp      # 0x9260
movq %rbp, %rdi
callq 0x20c0
leaq (%rax,%rbp), %rdx
leaq 0x180(%rsp), %rdi
movq %rbp, %rsi
callq 0x3da4
movq %rbx, %rdi
movq %r13, %rsi
movq %rbp, %rdx
xorl %eax, %eax
callq 0x22a0
leaq 0x160(%rsp), %rax
movq %rax, 0x150(%rsp)
movq %rbp, %rdi
callq 0x20c0
leaq (%rax,%rbp), %rdx
movq %r14, %rdi
movq %rbp, %rsi
callq 0x3da4
movq %rbx, %rdi
movq %r13, %rsi
movq %rbp, %rdx
xorl %eax, %eax
callq 0x22a0
leaq 0xb0(%rsp), %rax
movq %rax, 0xa0(%rsp)
movq %rbp, %rdi
callq 0x20c0
leaq (%rax,%rbp), %rdx
movq %r15, %rdi
movq %rbp, %rsi
callq 0x3da4
movq %r12, %rdi
leaq 0x180(%rsp), %rsi
callq 0x3984
movl (%rax), %eax
movl %eax, 0x18(%rsp)
movq %r12, %rdi
movq %r14, %rsi
callq 0x3984
movl (%rax), %eax
movl %eax, 0x40(%rsp)
leaq 0x6789(%rip), %rdi      # 0x9198
movq %r15, %rsi
callq 0x3984
movl (%rax), %eax
movl %eax, 0x78(%rsp)
movq 0x118(%rsp), %rsi
cmpq 0x120(%rsp), %rsi
je 0x2a43
movl 0x18(%rsp), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x118(%rsp)
jmp 0x2a55
leaq 0x110(%rsp), %rdi
leaq 0x18(%rsp), %rdx
callq 0x478e
movq 0xf8(%rsp), %rsi
cmpq 0x100(%rsp), %rsi
je 0x2a7b
movl 0x40(%rsp), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0xf8(%rsp)
jmp 0x2a8d
leaq 0xf0(%rsp), %rdi
leaq 0x40(%rsp), %rdx
callq 0x478e
movq 0xd8(%rsp), %rsi
cmpq 0xe0(%rsp), %rsi
je 0x2ab3
movl 0x78(%rsp), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0xd8(%rsp)
jmp 0x2ac5
leaq 0xd0(%rsp), %rdi
leaq 0x78(%rsp), %rdx
callq 0x478e
movq 0xa0(%rsp), %rdi
leaq 0xb0(%rsp), %rax
cmpq %rax, %rdi
je 0x2aea
movq 0xb0(%rsp), %rsi
incq %rsi
callq 0x21b0
movq 0x150(%rsp), %rdi
leaq 0x160(%rsp), %rax
cmpq %rax, %rdi
je 0x2b0f
movq 0x160(%rsp), %rsi
incq %rsi
callq 0x21b0
movq 0x180(%rsp), %rdi
leaq 0x190(%rsp), %rax
cmpq %rax, %rdi
je 0x2b34
movq 0x190(%rsp), %rsi
incq %rsi
callq 0x21b0
incq 0x68(%rsp)
jmp 0x2923
leaq 0x130(%rsp), %rdi
movq 0x68(%rsp), %rsi
callq 0x3ad2
movq %rbx, %rdi
callq 0x2190
xorl %eax, %eax
movl %eax, 0x8(%rsp)
leaq 0x158(%rsp), %rcx
movl %eax, (%rcx)
movq %rax, 0x8(%rcx)
movq %rcx, 0x10(%rcx)
movq %rcx, 0x18(%rcx)
movq %rax, 0x20(%rcx)
movslq 0x66dd(%rip), %rsi      # 0x925c
leaq 0x37432(%rip), %rdi     # 0x39fb8
callq 0x3b04
cmpl $0x0, 0x66ca(%rip)      # 0x925c
leaq 0x28(%rsp), %rbp
jle 0x30bc
leaq 0xa8(%rsp), %r12
leaq 0x50(%rsp), %r14
leaq 0xa0(%rsp), %r13
leaq 0x3c(%rsp), %r15
movl $0x0, 0x70(%rsp)
movl $0x0, 0xa8(%rsp)
xorl %ebx, %ebx
movq %rbx, 0xb0(%rsp)
movq %r12, 0xb8(%rsp)
movq %r12, 0xc0(%rsp)
movq %rbx, 0xc8(%rsp)
movq %r13, %rdi
callq 0x4bce
movq %rbp, 0x18(%rsp)
movq %rbx, 0x20(%rsp)
movb $0x0, 0x28(%rsp)
leaq 0x180(%rsp), %rdi
callq 0x2120
leaq 0x190(%rsp), %rdi
movl 0x70(%rsp), %esi
callq 0x2270
leaq 0x180(%rsp), %rdi
leaq 0x18(%rsp), %rsi
callq 0x2200
movq 0x18(%rsp), %rsi
movq 0x20(%rsp), %rdx
movq 0x6394(%rip), %rdi      # 0x8fd8
callq 0x21d0
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2180
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2100
leaq 0x78(%rsp), %rbx
movq %rbx, %rdi
leaq 0x3404(%rip), %rsi      # 0x6086
leaq 0x18(%rsp), %rdx
callq 0x3b40
movq %rbx, %rdi
leaq 0x33b3(%rip), %rsi      # 0x6049
callq 0x22b0
movq %r14, 0x40(%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x2cbe
movq %rdx, 0x40(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x50(%rsp)
jmp 0x2cc7
movupd (%rcx), %xmm0
movupd %xmm0, (%r14)
movq %r14, %rbx
movq 0x8(%rax), %rdx
movq %rdx, 0x48(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq 0x40(%rsp), %rdi
leaq 0x33b1(%rip), %rsi      # 0x609f
callq 0x21e0
movq %rax, %r14
movq 0x40(%rsp), %rdi
cmpq %rbx, %rdi
je 0x2d0d
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x21b0
movq 0x78(%rsp), %rdi
leaq 0x88(%rsp), %rax
cmpq %rax, %rdi
je 0x2d2f
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x21b0
leaq 0x78(%rsp), %rbx
movq %rbx, %rdi
leaq 0x3356(%rip), %rsi      # 0x6094
leaq 0x18(%rsp), %rdx
callq 0x3b40
movq %rbx, %rdi
leaq 0x32f7(%rip), %rsi      # 0x6049
callq 0x22b0
leaq 0x50(%rsp), %rbp
movq %rbp, 0x40(%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x2d7f
movq %rdx, 0x40(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x50(%rsp)
jmp 0x2d88
movupd (%rcx), %xmm0
movupd %xmm0, (%rbp)
movq 0x8(%rax), %rdx
movq %rdx, 0x48(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq 0x40(%rsp), %rdi
leaq 0x32f3(%rip), %rsi      # 0x609f
callq 0x21e0
movq %rax, %rbx
movq 0x40(%rsp), %rdi
cmpq %rbp, %rdi
je 0x2dcb
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x21b0
movq 0x78(%rsp), %rdi
leaq 0x88(%rsp), %rax
cmpq %rax, %rdi
je 0x3028
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x21b0
jmp 0x3028
testq %rbx, %rbx
je 0x2e11
movq %rbx, %rdi
leaq 0x324b(%rip), %rsi      # 0x6050
movq %r15, %rdx
xorl %eax, %eax
callq 0x22a0
jmp 0x2e19
movl $0x0, 0x3c(%rsp)
movq 0xb0(%rsp), %rcx
movq %r12, %rax
testq %rcx, %rcx
je 0x2e47
movl 0x3c(%rsp), %edx
movq %r12, %rax
xorl %esi, %esi
cmpl %edx, 0x20(%rcx)
setl %sil
cmovgeq %rcx, %rax
movq 0x10(%rcx,%rsi,8), %rcx
testq %rcx, %rcx
jne 0x2e30
movq %r12, %rcx
cmpq %r12, %rax
je 0x2e5d
movl 0x3c(%rsp), %ecx
cmpl 0x20(%rax), %ecx
cmovlq %r12, %rax
movq %rax, %rcx
cmpq %r12, %rcx
jne 0x2f61
movl 0x8(%rsp), %ebp
movq %r13, %rdi
movq %r15, %rsi
callq 0x3bc8
movl %ebp, (%rax)
movl 0x78(%rsp), %ebp
leaq 0x150(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x3bc8
movl %ebp, (%rax)
movslq 0x78(%rsp), %rax
movq 0xd0(%rsp), %rcx
movslq (%rcx,%rax,4), %rax
movq 0x37111(%rip), %rcx     # 0x39fb8
leaq (%rax,%rax,2), %rax
leaq (%rcx,%rax,8), %rdi
movq 0x8(%rdi), %rsi
cmpq 0x10(%rdi), %rsi
je 0x2ec9
movl 0x8(%rsp), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rdi)
jmp 0x2ed3
leaq 0x8(%rsp), %rdx
callq 0x478e
movl $0x0, 0x40(%rsp)
movq 0x3710e(%rip), %rsi     # 0x39ff0
cmpq 0x3710f(%rip), %rsi     # 0x39ff8
je 0x2f03
movl $0x0, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x370f4(%rip)     # 0x39ff0
leaq 0x40(%rsp), %rbp
jmp 0x2f17
leaq 0x370de(%rip), %rdi     # 0x39fe8
leaq 0x40(%rsp), %rbp
movq %rbp, %rdx
callq 0x4e02
xorpd %xmm0, %xmm0
movapd %xmm0, 0x40(%rsp)
movq $0x0, 0x50(%rsp)
movl $0x32, %esi
movq %rbp, %rdi
callq 0x3aa0
leaq 0x37092(%rip), %rdi     # 0x39fd0
movq %rbp, %rsi
callq 0x3c2c
incl 0x8(%rsp)
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x2f61
movq 0x50(%rsp), %rsi
subq %rdi, %rsi
callq 0x21b0
xorl %ebp, %ebp
movslq 0x78(%rsp), %rax
movq 0x110(%rsp), %rcx
movslq (%rcx,%rax,4), %rcx
movq 0x37025(%rip), %rdx     # 0x39fa0
leaq (%rcx,%rcx,2), %rcx
movq (%rdx,%rcx,8), %rcx
movsd (%rcx,%rbp,8), %xmm0
movsd %xmm0, 0x10(%rsp)
movq 0xf0(%rsp), %rcx
movslq (%rcx,%rax,4), %rax
leaq (%rax,%rax,2), %rax
movq (%rdx,%rax,8), %rax
movsd (%rax,%rbp,8), %xmm0
movsd %xmm0, 0x98(%rsp)
movq %r13, %rdi
movq %r15, %rsi
callq 0x3bc8
movsd 0x10(%rsp), %xmm0
subsd 0x98(%rsp), %xmm0
movslq (%rax), %rax
movq 0x36ffc(%rip), %rcx     # 0x39fd0
leaq (%rax,%rax,2), %rax
movq (%rcx,%rax,8), %rax
addsd (%rax,%rbp,8), %xmm0
movsd %xmm0, (%rax,%rbp,8)
incq %rbp
cmpq $0x32, %rbp
jne 0x2f63
movq %r13, %rdi
movq %r15, %rsi
callq 0x3bc8
movl (%rax), %eax
movslq 0x78(%rsp), %rcx
movq 0x130(%rsp), %rdx
movl %eax, (%rdx,%rcx,4)
movq %r13, %rdi
movq %r15, %rsi
callq 0x3bc8
movslq (%rax), %rax
movq 0x36fc3(%rip), %rcx     # 0x39fe8
incl (%rcx,%rax,4)
movq %r14, %rdi
leaq 0x301e(%rip), %rsi      # 0x6050
leaq 0x78(%rsp), %rdx
xorl %eax, %eax
callq 0x22a0
cmpl $0x1, %eax
je 0x2df6
movq %r14, %rdi
callq 0x2190
testq %rbx, %rbx
je 0x305c
movq %rbx, %rdi
callq 0x2190
leaq 0x180(%rsp), %rdi
movq 0x5f55(%rip), %rsi      # 0x8fc0
callq 0x2140
leaq 0x200(%rsp), %rdi
callq 0x2090
movq 0x18(%rsp), %rdi
leaq 0x28(%rsp), %rbp
cmpq %rbp, %rdi
leaq 0x50(%rsp), %r14
je 0x309e
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x21b0
movq %r13, %rdi
callq 0x3d54
movl 0x70(%rsp), %eax
incl %eax
movl %eax, 0x70(%rsp)
cmpl 0x61a6(%rip), %eax      # 0x925c
jl 0x2bbf
leaq 0x2fde(%rip), %rdi      # 0x60a1
leaq 0x2ff0(%rip), %rsi      # 0x60ba
callq 0x21e0
movq %rax, %rbx
movq 0x68(%rsp), %r12
testl %r12d, %r12d
je 0x3108
leaq 0x2fd9(%rip), %r14      # 0x60bc
xorl %r15d, %r15d
movq 0x130(%rsp), %rax
movl (%rax,%r15), %edx
movq %rbx, %rdi
movq %r14, %rsi
xorl %eax, %eax
callq 0x2210
addq $0x4, %r15
decq %r12
jne 0x30e6
movq %rbx, %rdi
callq 0x2190
movl 0x8(%rsp), %esi
movq 0x5ebd(%rip), %rdi      # 0x8fd8
callq 0x2270
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2180
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2100
leaq 0x2f6f(%rip), %rdi      # 0x60c0
leaq 0x2f62(%rip), %rsi      # 0x60ba
callq 0x21e0
movq %rax, 0x10(%rsp)
leaq 0x2f6f(%rip), %rdi      # 0x60d8
leaq 0x2f2f(%rip), %rsi      # 0x609f
callq 0x21e0
movq %rax, %r14
leaq 0x2f04(%rip), %r15      # 0x6083
leaq 0x180(%rsp), %r12
movl $0x0, 0x98(%rsp)
leaq 0x60c7(%rip), %rbx      # 0x9260
movq %rax, 0x68(%rsp)
movq %r14, %rdi
movq %r15, %rsi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x22a0
cmpl $0x1, %eax
jne 0x3572
movq 0x5e1a(%rip), %rdi      # 0x8fd8
movl 0x98(%rsp), %esi
callq 0x2270
movq %rax, %r13
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x2180
movsbl %al, %esi
movq %r13, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2100
leaq 0x190(%rsp), %rax
movq %rax, 0x180(%rsp)
movq %rbx, %rdi
callq 0x20c0
leaq (%rax,%rbx), %rdx
movq %r12, %rdi
movq %rbx, %rsi
callq 0x3da4
movq %r14, %rdi
movq %r15, %rsi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x22a0
leaq 0xb0(%rsp), %rax
movq %rax, 0xa0(%rsp)
movq %rbx, %rdi
callq 0x20c0
leaq (%rax,%rbx), %rdx
leaq 0xa0(%rsp), %rdi
movq %rbx, %rsi
callq 0x3da4
movq %r14, %rdi
movq %r15, %rsi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x22a0
movq %rbp, 0x18(%rsp)
movq %rbx, %rdi
callq 0x20c0
leaq (%rax,%rbx), %rdx
leaq 0x18(%rsp), %rdi
movq %rbx, %rsi
callq 0x3da4
leaq 0x5f3c(%rip), %rbx      # 0x91c8
movq %rbx, %rdi
movq %r12, %rsi
callq 0x3984
movslq (%rax), %r15
movq %rbx, %rdi
leaq 0xa0(%rsp), %rsi
callq 0x3984
movq %r15, 0x70(%rsp)
movslq (%rax), %rbx
leaq 0x5edf(%rip), %rdi      # 0x9198
leaq 0x18(%rsp), %rsi
callq 0x3984
movslq (%rax), %r15
cmpl $0x0, 0x5f8b(%rip)      # 0x9258
jle 0x33c4
leaq (%r15,%r15,2), %r14
leaq (%rbx,%rbx,2), %r12
xorl %ebp, %ebp
movq 0x36cd4(%rip), %rcx     # 0x39fb8
movq (%rcx,%r14,8), %rax
movq 0x8(%rcx,%r14,8), %rcx
subq %rax, %rcx
je 0x3399
sarq $0x2, %rcx
movq 0x36c9f(%rip), %rdx     # 0x39fa0
leaq (,%rbp,2), %rsi
addq %rbp, %rsi
movq (%rdx,%rsi,8), %rsi
movq (%rdx,%r12,8), %rdi
movq 0x36cb5(%rip), %r8      # 0x39fd0
cmpq $0x1, %rcx
adcq $0x0, %rcx
movq 0x36cbe(%rip), %r9      # 0x39fe8
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
xorl %r10d, %r10d
movsd 0x2cce(%rip), %xmm0     # 0x6008
movslq (%rax,%r10,4), %r11
leaq (%r11,%r11,2), %rbx
movq (%r8,%rbx,8), %r13
xorps %xmm2, %xmm2
cvtsi2sdl (%r9,%r11,4), %xmm2
xorpd %xmm1, %xmm1
xorl %ebx, %ebx
movsd (%rsi,%rbx,8), %xmm3
subsd (%rdi,%rbx,8), %xmm3
movsd (%r13,%rbx,8), %xmm4
divsd %xmm2, %xmm4
subsd %xmm4, %xmm3
mulsd %xmm3, %xmm3
addsd %xmm3, %xmm1
incq %rbx
cmpq $0x32, %rbx
jne 0x3355
ucomisd %xmm1, %xmm0
cmoval %r11d, %edx
minsd %xmm0, %xmm1
incq %r10
movapd %xmm1, %xmm0
cmpq %rcx, %r10
jne 0x333a
jmp 0x339e
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movq 0x10(%rsp), %rdi
leaq 0x2d3f(%rip), %rsi      # 0x60e9
xorl %eax, %eax
callq 0x2210
incq %rbp
movslq 0x5e9d(%rip), %rax      # 0x9258
cmpq %rax, %rbp
jl 0x32dd
movl $0xa, %edi
movq 0x10(%rsp), %rsi
callq 0x21f0
cmpl $0x0, 0x5e7e(%rip)      # 0x9258
leaq 0x28(%rsp), %rbp
movq 0x70(%rsp), %r13
jle 0x34db
xorl %r14d, %r14d
movq 0x36bc4(%rip), %rcx     # 0x39fb8
leaq (%r15,%r15,2), %rdx
movq (%rcx,%rdx,8), %rax
movq 0x8(%rcx,%rdx,8), %rcx
subq %rax, %rcx
je 0x34b0
sarq $0x2, %rcx
movq 0x36b8b(%rip), %rdx     # 0x39fa0
leaq (,%r13,2), %rsi
addq %r13, %rsi
movq (%rdx,%rsi,8), %rsi
leaq (%r14,%r14,2), %rdi
movq (%rdx,%rdi,8), %rdi
movq 0x36b9d(%rip), %r8      # 0x39fd0
cmpq $0x1, %rcx
adcq $0x0, %rcx
movq 0x36ba6(%rip), %r9      # 0x39fe8
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
xorl %r10d, %r10d
movsd 0x2bb6(%rip), %xmm0     # 0x6008
movslq (%rax,%r10,4), %r11
leaq (%r11,%r11,2), %rbx
movq (%r8,%rbx,8), %r12
xorps %xmm2, %xmm2
cvtsi2sdl (%r9,%r11,4), %xmm2
xorpd %xmm1, %xmm1
xorl %ebx, %ebx
movsd (%rsi,%rbx,8), %xmm3
subsd (%rdi,%rbx,8), %xmm3
movsd (%r12,%rbx,8), %xmm4
divsd %xmm2, %xmm4
subsd %xmm4, %xmm3
mulsd %xmm3, %xmm3
addsd %xmm3, %xmm1
incq %rbx
cmpq $0x32, %rbx
jne 0x346d
ucomisd %xmm1, %xmm0
cmoval %r11d, %edx
minsd %xmm0, %xmm1
incq %r10
movapd %xmm1, %xmm0
cmpq %rcx, %r10
jne 0x3452
jmp 0x34b5
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movq 0x10(%rsp), %rdi
leaq 0x2c28(%rip), %rsi      # 0x60e9
xorl %eax, %eax
callq 0x2210
incq %r14
movslq 0x5d86(%rip), %rax      # 0x9258
cmpq %rax, %r14
jl 0x33ed
movl $0xa, %edi
movq 0x10(%rsp), %rsi
callq 0x21f0
movq 0x18(%rsp), %rdi
cmpq %rbp, %rdi
leaq 0x180(%rsp), %r12
je 0x3509
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x21b0
movq 0xa0(%rsp), %rdi
leaq 0xb0(%rsp), %rax
cmpq %rax, %rdi
leaq 0x5d3d(%rip), %rbx      # 0x9260
movq 0x68(%rsp), %r14
leaq 0x2b54(%rip), %r15      # 0x6083
je 0x3541
movq 0xb0(%rsp), %rsi
incq %rsi
callq 0x21b0
movq 0x180(%rsp), %rdi
leaq 0x190(%rsp), %rax
cmpq %rax, %rdi
je 0x3566
movq 0x190(%rsp), %rsi
incq %rsi
callq 0x21b0
incl 0x98(%rsp)
jmp 0x319e
movq %r14, %rdi
callq 0x2190
leaq 0x150(%rsp), %rdi
callq 0x3d54
movq 0x130(%rsp), %rdi
testq %rdi, %rdi
je 0x35a4
movq 0x140(%rsp), %rsi
subq %rdi, %rsi
callq 0x21b0
movq 0xd0(%rsp), %rdi
testq %rdi, %rdi
je 0x35c1
movq 0xe0(%rsp), %rsi
subq %rdi, %rsi
callq 0x21b0
movq 0xf0(%rsp), %rdi
testq %rdi, %rdi
je 0x35de
movq 0x100(%rsp), %rsi
subq %rdi, %rsi
callq 0x21b0
movq 0x110(%rsp), %rdi
testq %rdi, %rdi
je 0x35fb
movq 0x120(%rsp), %rsi
subq %rdi, %rsi
callq 0x21b0
xorl %eax, %eax
addq $0x308, %rsp            # imm = 0x308
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x37c5
jmp 0x370d
jmp 0x37c5
jmp 0x3620
movq %rax, %rbx
jmp 0x38bb
movq %rax, %rbx
jmp 0x3816
jmp 0x3637
jmp 0x37ed
movq %rax, %rbx
movq 0x78(%rsp), %rdi
leaq 0x88(%rsp), %rax
cmpq %rax, %rdi
je 0x37f0
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x21b0
jmp 0x37f0
jmp 0x37ed
movq %rax, %rbx
leaq 0x28(%rsp), %rbp
jmp 0x3679
jmp 0x3676
movq %rax, %rbx
movq 0x18(%rsp), %rdi
cmpq %rbp, %rdi
je 0x3697
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x21b0
jmp 0x3697
jmp 0x3694
movq %rax, %rbx
movq 0xa0(%rsp), %rdi
leaq 0xb0(%rsp), %rax
cmpq %rax, %rdi
je 0x36c3
movq 0xb0(%rsp), %rsi
incq %rsi
callq 0x21b0
jmp 0x36c3
jmp 0x36c0
movq %rax, %rbx
movq 0x180(%rsp), %rdi
leaq 0x190(%rsp), %rax
cmpq %rax, %rdi
je 0x383a
movq 0x190(%rsp), %rsi
incq %rsi
callq 0x21b0
jmp 0x383a
jmp 0x37c5
jmp 0x3743
jmp 0x3743
jmp 0x36fc
movq %rax, %rbx
jmp 0x376b
jmp 0x3703
movq %rax, %rbx
jmp 0x3790
jmp 0x370d
movq %rax, %rbx
jmp 0x3847
jmp 0x3717
movq %rax, %rbx
movq 0x180(%rsp), %rdi
leaq 0x190(%rsp), %rax
cmpq %rax, %rdi
je 0x38bb
movq 0x190(%rsp), %rsi
incq %rsi
jmp 0x38b6
movq %rax, %rbx
movq 0xa0(%rsp), %rdi
leaq 0xb0(%rsp), %rax
cmpq %rax, %rdi
je 0x376b
movq 0xb0(%rsp), %rsi
incq %rsi
callq 0x21b0
movq 0x150(%rsp), %rdi
leaq 0x160(%rsp), %rax
cmpq %rax, %rdi
je 0x3790
movq 0x160(%rsp), %rsi
incq %rsi
callq 0x21b0
movq 0x180(%rsp), %rdi
leaq 0x190(%rsp), %rax
cmpq %rax, %rdi
je 0x3847
movq 0x190(%rsp), %rsi
incq %rsi
callq 0x21b0
jmp 0x3847
jmp 0x37ed
movq %rax, %rbx
jmp 0x37f5
movq %rax, %rbx
jmp 0x383a
movq %rax, %rbx
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
leaq 0x28(%rsp), %rbp
je 0x37f5
movq 0x50(%rsp), %rsi
subq %rdi, %rsi
callq 0x21b0
jmp 0x37f5
jmp 0x37ed
movq %rax, %rbx
leaq 0x28(%rsp), %rbp
movq 0x57c4(%rip), %rsi      # 0x8fc0
leaq 0x180(%rsp), %rdi
callq 0x2140
leaq 0x200(%rsp), %rdi
callq 0x2090
movq 0x18(%rsp), %rdi
cmpq %rbp, %rdi
je 0x382d
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x21b0
leaq 0xa0(%rsp), %rdi
callq 0x3d54
leaq 0x150(%rsp), %rdi
callq 0x3d54
movq 0x130(%rsp), %rdi
testq %rdi, %rdi
je 0x3864
movq 0x140(%rsp), %rsi
subq %rdi, %rsi
callq 0x21b0
movq 0xd0(%rsp), %rdi
testq %rdi, %rdi
je 0x3881
movq 0xe0(%rsp), %rsi
subq %rdi, %rsi
callq 0x21b0
movq 0xf0(%rsp), %rdi
testq %rdi, %rdi
je 0x389e
movq 0x100(%rsp), %rsi
subq %rdi, %rsi
callq 0x21b0
movq 0x110(%rsp), %rdi
testq %rdi, %rdi
je 0x38bb
movq 0x120(%rsp), %rsi
subq %rdi, %rsi
callq 0x21b0
movq %rbx, %rdi
callq 0x2280
nop