// File: /workspace/github_cpp_makefile_star2_O3/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 $0x2f8, %rsp            # imm = 0x2F8
leaq 0x3a07(%rip), %rdi      # 0x6020
leaq 0x3a7f(%rip), %r14      # 0x609f
movq %r14, %rsi
callq 0x21e0
movq %rax, %rbx
leaq 0x3a04(%rip), %rdi      # 0x6036
movq %r14, %rsi
callq 0x21e0
movq %rax, %r14
leaq 0x3a0a(%rip), %rsi      # 0x604e
leaq 0x6c15(%rip), %r15      # 0x9260
leaq 0x4(%rsp), %rcx
movq %rbx, 0x8(%rsp)
movq %rbx, %rdi
movq %r15, %rdx
xorl %eax, %eax
callq 0x22a0
cmpl $0x2, %eax
jne 0x271e
leaq 0x170(%rsp), %r12
leaq 0x4(%rsp), %r13
leaq 0x39cf(%rip), %rbp      # 0x604e
leaq 0x180(%rsp), %rax
movq %rax, 0x170(%rsp)
movq %r15, %rdi
callq 0x20c0
leaq (%rax,%r15), %rdx
movq %r12, %rdi
movq %r15, %rsi
callq 0x3dac
movl 0x4(%rsp), %ebx
leaq 0x6b17(%rip), %rdi      # 0x91c8
movq %r12, %rsi
callq 0x3988
movl %ebx, (%rax)
leaq 0x6b36(%rip), %rdi      # 0x91f8
movq %r13, %rsi
callq 0x3a04
movq %rax, %rdi
movq %r12, %rsi
callq 0x20e0
incl 0x6b7d(%rip)            # 0x9258
movq 0x170(%rsp), %rdi
leaq 0x180(%rsp), %rax
cmpq %rax, %rdi
je 0x2700
movq 0x180(%rsp), %rsi
incq %rsi
callq 0x21b0
movq 0x8(%rsp), %rdi
movq %rbp, %rsi
movq %r15, %rdx
movq %r13, %rcx
xorl %eax, %eax
callq 0x22a0
cmpl $0x2, %eax
je 0x267f
leaq 0x3929(%rip), %rsi      # 0x604e
leaq 0x6b34(%rip), %rbx      # 0x9260
leaq 0x4(%rsp), %rcx
movq %r14, %rdi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x22a0
cmpl $0x2, %eax
jne 0x2802
leaq 0x170(%rsp), %r15
leaq 0x6ad2(%rip), %r13      # 0x9228
leaq 0x4(%rsp), %rbp
leaq 0x38ec(%rip), %r12      # 0x604e
leaq 0x180(%rsp), %rax
movq %rax, 0x170(%rsp)
movq %rbx, %rdi
callq 0x20c0
leaq (%rax,%rbx), %rdx
movq %r15, %rdi
movq %rbx, %rsi
callq 0x3dac
movl 0x4(%rsp), %ebx
leaq 0x6a04(%rip), %rdi      # 0x9198
movq %r15, %rsi
callq 0x3988
movl %ebx, (%rax)
movq %r13, %rdi
movq %rbp, %rsi
callq 0x3a04
movq %rax, %rdi
movq %r15, %rsi
callq 0x20e0
incl 0x6aa2(%rip)            # 0x925c
movq 0x170(%rsp), %rdi
leaq 0x180(%rsp), %rax
cmpq %rax, %rdi
je 0x27df
movq 0x180(%rsp), %rsi
incq %rsi
callq 0x21b0
movq %r14, %rdi
movq %r12, %rsi
leaq 0x6a74(%rip), %rbx      # 0x9260
movq %rbx, %rdx
movq %rbp, %rcx
xorl %eax, %eax
callq 0x22a0
cmpl $0x2, %eax
je 0x2762
movq 0x8(%rsp), %rdi
callq 0x2190
movq %r14, %rdi
callq 0x2190
leaq 0x3838(%rip), %rdi      # 0x6053
leaq 0x387d(%rip), %rsi      # 0x609f
callq 0x21e0
movq %rax, %rbx
movslq 0x6a27(%rip), %rsi      # 0x9258
leaq 0x37768(%rip), %rdi     # 0x39fa0
callq 0x3a6a
cmpl $0x0, 0x6a14(%rip)      # 0x9258
jle 0x28a7
leaq 0x3820(%rip), %r14      # 0x606d
xorl %r15d, %r15d
leaq (%r15,%r15,2), %r12
leaq (,%r12,8), %rdi
addq 0x3773d(%rip), %rdi     # 0x39fa0
movl $0x32, %esi
callq 0x3aa6
xorl %r13d, %r13d
movq 0x37729(%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 0x2870
incq %r15
movslq 0x69b6(%rip), %rax      # 0x9258
cmpq %rax, %r15
jl 0x2850
movq %rbx, %rdi
callq 0x2190
leaq 0x37bb(%rip), %rdi      # 0x6071
leaq 0x37e2(%rip), %rsi      # 0x609f
callq 0x21e0
movq %rax, %rbx
xorl %eax, %eax
leaq 0x100(%rsp), %rcx
movq %rax, 0x10(%rcx)
xorpd %xmm0, %xmm0
movapd %xmm0, (%rcx)
leaq 0xe0(%rsp), %rcx
movq %rax, 0x10(%rcx)
movapd %xmm0, (%rcx)
leaq 0xc0(%rsp), %rcx
movq %rax, 0x10(%rcx)
movapd %xmm0, (%rcx)
movq %rax, 0x130(%rsp)
movapd %xmm0, 0x120(%rsp)
leaq 0x3770(%rip), %r13      # 0x6083
leaq 0x140(%rsp), %r14
leaq 0x90(%rsp), %r15
leaq 0x689e(%rip), %r12      # 0x91c8
movq $0x0, 0x50(%rsp)
movq %rbx, %rdi
movq %r13, %rsi
leaq 0x6920(%rip), %rdx      # 0x9260
xorl %eax, %eax
callq 0x22a0
cmpl $0x1, %eax
jne 0x2b4e
leaq 0x180(%rsp), %rax
movq %rax, 0x170(%rsp)
leaq 0x68f9(%rip), %rbp      # 0x9260
movq %rbp, %rdi
callq 0x20c0
leaq (%rax,%rbp), %rdx
leaq 0x170(%rsp), %rdi
movq %rbp, %rsi
callq 0x3dac
movq %rbx, %rdi
movq %r13, %rsi
movq %rbp, %rdx
xorl %eax, %eax
callq 0x22a0
leaq 0x150(%rsp), %rax
movq %rax, 0x140(%rsp)
movq %rbp, %rdi
callq 0x20c0
leaq (%rax,%rbp), %rdx
movq %r14, %rdi
movq %rbp, %rsi
callq 0x3dac
movq %rbx, %rdi
movq %r13, %rsi
movq %rbp, %rdx
xorl %eax, %eax
callq 0x22a0
leaq 0xa0(%rsp), %rax
movq %rax, 0x90(%rsp)
movq %rbp, %rdi
callq 0x20c0
leaq (%rax,%rbp), %rdx
movq %r15, %rdi
movq %rbp, %rsi
callq 0x3dac
movq %r12, %rdi
leaq 0x170(%rsp), %rsi
callq 0x3988
movl (%rax), %eax
movl %eax, 0x10(%rsp)
movq %r12, %rdi
movq %r14, %rsi
callq 0x3988
movl (%rax), %eax
movl %eax, 0x30(%rsp)
leaq 0x6779(%rip), %rdi      # 0x9198
movq %r15, %rsi
callq 0x3988
movl (%rax), %eax
movl %eax, 0x68(%rsp)
movq 0x108(%rsp), %rsi
cmpq 0x110(%rsp), %rsi
je 0x2a53
movl 0x10(%rsp), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x108(%rsp)
jmp 0x2a65
leaq 0x100(%rsp), %rdi
leaq 0x10(%rsp), %rdx
callq 0x47a6
movq 0xe8(%rsp), %rsi
cmpq 0xf0(%rsp), %rsi
je 0x2a8b
movl 0x30(%rsp), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0xe8(%rsp)
jmp 0x2a9d
leaq 0xe0(%rsp), %rdi
leaq 0x30(%rsp), %rdx
callq 0x47a6
movq 0xc8(%rsp), %rsi
cmpq 0xd0(%rsp), %rsi
je 0x2ac3
movl 0x68(%rsp), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0xc8(%rsp)
jmp 0x2ad5
leaq 0xc0(%rsp), %rdi
leaq 0x68(%rsp), %rdx
callq 0x47a6
movq 0x90(%rsp), %rdi
leaq 0xa0(%rsp), %rax
cmpq %rax, %rdi
je 0x2afa
movq 0xa0(%rsp), %rsi
incq %rsi
callq 0x21b0
movq 0x140(%rsp), %rdi
leaq 0x150(%rsp), %rax
cmpq %rax, %rdi
je 0x2b1f
movq 0x150(%rsp), %rsi
incq %rsi
callq 0x21b0
movq 0x170(%rsp), %rdi
leaq 0x180(%rsp), %rax
cmpq %rax, %rdi
je 0x2b44
movq 0x180(%rsp), %rsi
incq %rsi
callq 0x21b0
incq 0x50(%rsp)
jmp 0x2933
leaq 0x120(%rsp), %rdi
movq 0x50(%rsp), %rsi
callq 0x3ad8
movq %rbx, %rdi
callq 0x2190
xorl %eax, %eax
movl %eax, (%rsp)
leaq 0x148(%rsp), %rcx
movl %eax, (%rcx)
movq %rax, 0x8(%rcx)
movq %rcx, 0x10(%rcx)
movq %rcx, 0x18(%rcx)
movq %rax, 0x20(%rcx)
movslq 0x66ce(%rip), %rsi      # 0x925c
leaq 0x37423(%rip), %rdi     # 0x39fb8
callq 0x3b0a
cmpl $0x0, 0x66bb(%rip)      # 0x925c
jle 0x30bb
leaq 0x40(%rsp), %r12
leaq 0x90(%rsp), %r13
leaq 0x170(%rsp), %rbp
leaq 0x64(%rsp), %r15
leaq 0x30(%rsp), %r14
movl $0x0, 0x58(%rsp)
movl $0x0, 0x98(%rsp)
xorl %ebx, %ebx
movq %rbx, 0xa0(%rsp)
leaq 0x98(%rsp), %rax
movq %rax, 0xa8(%rsp)
movq %rax, 0xb0(%rsp)
movq %rbx, 0xb8(%rsp)
movq %r13, %rdi
callq 0x4bec
leaq 0x20(%rsp), %rax
movq %rax, 0x10(%rsp)
movq %rbx, 0x18(%rsp)
movb $0x0, 0x20(%rsp)
movq %rbp, %rdi
callq 0x2120
leaq 0x180(%rsp), %rdi
movl 0x58(%rsp), %esi
callq 0x2270
movq %rbp, %rdi
leaq 0x10(%rsp), %rsi
callq 0x2200
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rdx
movq 0x6382(%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 0x68(%rsp), %rbx
movq %rbx, %rdi
leaq 0x33f2(%rip), %rsi      # 0x6086
leaq 0x10(%rsp), %rdx
callq 0x3b46
movq %rbx, %rdi
leaq 0x33a1(%rip), %rsi      # 0x6049
callq 0x22b0
movq %r12, 0x30(%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x2cd0
movq %rdx, 0x30(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x40(%rsp)
jmp 0x2cda
movupd (%rcx), %xmm0
movupd %xmm0, (%r12)
movq 0x8(%rax), %rdx
movq %rdx, 0x38(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq 0x30(%rsp), %rdi
leaq 0x33a1(%rip), %rsi      # 0x609f
callq 0x21e0
movq %rax, %rbx
movq 0x30(%rsp), %rdi
cmpq %r12, %rdi
je 0x2d1d
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x21b0
movq 0x68(%rsp), %rdi
leaq 0x78(%rsp), %rax
cmpq %rax, %rdi
je 0x2d39
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x21b0
leaq 0x68(%rsp), %rbp
movq %rbp, %rdi
leaq 0x334c(%rip), %rsi      # 0x6094
leaq 0x10(%rsp), %rdx
callq 0x3b46
movq %rbp, %rdi
leaq 0x32ed(%rip), %rsi      # 0x6049
callq 0x22b0
movq %r12, 0x30(%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x2d84
movq %rdx, 0x30(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x40(%rsp)
jmp 0x2d8e
movupd (%rcx), %xmm0
movupd %xmm0, (%r12)
movq %r12, %rbp
movq 0x8(%rax), %rdx
movq %rdx, 0x38(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq 0x30(%rsp), %rdi
leaq 0x32ea(%rip), %rsi      # 0x609f
callq 0x21e0
movq %rax, %r12
movq 0x30(%rsp), %rdi
cmpq %rbp, %rdi
je 0x2dd4
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x21b0
movq 0x68(%rsp), %rdi
leaq 0x78(%rsp), %rax
cmpq %rax, %rdi
je 0x3024
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x21b0
jmp 0x3024
testq %r12, %r12
je 0x2e14
movq %r12, %rdi
leaq 0x3248(%rip), %rsi      # 0x6050
movq %r15, %rdx
xorl %eax, %eax
callq 0x22a0
jmp 0x2e1c
movl $0x0, 0x64(%rsp)
movq 0xa0(%rsp), %rdi
testq %rdi, %rdi
je 0x2e73
movl 0x64(%rsp), %eax
leaq 0x98(%rsp), %r8
movq %r8, %rcx
movq %rdi, %rdx
movl 0x20(%rdi), %esi
xorl %edi, %edi
cmpl %eax, %esi
setl %dil
movq %rdx, %r8
cmovlq %rcx, %r8
movq 0x10(%rdx,%rdi,8), %rdi
testq %rdi, %rdi
jne 0x2e35
leaq 0x98(%rsp), %rdi
cmpq %rdi, %r8
je 0x2e73
cmpl %eax, %esi
cmovlq %rcx, %rdx
cmpl 0x20(%rdx), %eax
jge 0x2f5d
movl (%rsp), %ebp
movq %r13, %rdi
movq %r15, %rsi
callq 0x3bce
movl %ebp, (%rax)
movl 0x68(%rsp), %ebp
leaq 0x140(%rsp), %rdi
movq %rsp, %rsi
callq 0x3bce
movl %ebp, (%rax)
movslq 0x68(%rsp), %rax
movq 0xc0(%rsp), %rcx
movslq (%rcx,%rax,4), %rax
movq 0x37107(%rip), %rcx     # 0x39fb8
leaq (%rax,%rax,2), %rax
leaq (%rcx,%rax,8), %rdi
movq 0x8(%rdi), %rsi
cmpq 0x10(%rdi), %rsi
je 0x2ed2
movl (%rsp), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rdi)
jmp 0x2eda
movq %rsp, %rdx
callq 0x47a6
movl $0x0, 0x30(%rsp)
movq 0x37107(%rip), %rsi     # 0x39ff0
cmpq 0x37108(%rip), %rsi     # 0x39ff8
je 0x2f05
movl $0x0, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x370ed(%rip)     # 0x39ff0
jmp 0x2f14
leaq 0x370dc(%rip), %rdi     # 0x39fe8
movq %r14, %rdx
callq 0x4e1e
xorpd %xmm0, %xmm0
movapd %xmm0, 0x30(%rsp)
movq $0x0, 0x40(%rsp)
movl $0x32, %esi
movq %r14, %rdi
callq 0x3aa6
leaq 0x37095(%rip), %rdi     # 0x39fd0
movq %r14, %rsi
callq 0x3c34
incl (%rsp)
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x2f5d
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x21b0
xorl %ebp, %ebp
movslq 0x68(%rsp), %rax
movq 0x100(%rsp), %rcx
movslq (%rcx,%rax,4), %rcx
movq 0x37029(%rip), %rdx     # 0x39fa0
leaq (%rcx,%rcx,2), %rcx
movq (%rdx,%rcx,8), %rcx
movsd (%rcx,%rbp,8), %xmm0
movsd %xmm0, 0x8(%rsp)
movq 0xe0(%rsp), %rcx
movslq (%rcx,%rax,4), %rax
leaq (%rax,%rax,2), %rax
movq (%rdx,%rax,8), %rax
movsd (%rax,%rbp,8), %xmm0
movsd %xmm0, 0x88(%rsp)
movq %r13, %rdi
movq %r15, %rsi
callq 0x3bce
movsd 0x8(%rsp), %xmm0
subsd 0x88(%rsp), %xmm0
movslq (%rax), %rax
movq 0x37000(%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 0x2f5f
movq %r13, %rdi
movq %r15, %rsi
callq 0x3bce
movl (%rax), %eax
movslq 0x68(%rsp), %rcx
movq 0x120(%rsp), %rdx
movl %eax, (%rdx,%rcx,4)
movq %r13, %rdi
movq %r15, %rsi
callq 0x3bce
movslq (%rax), %rax
movq 0x36fc7(%rip), %rcx     # 0x39fe8
incl (%rcx,%rax,4)
movq %rbx, %rdi
leaq 0x3022(%rip), %rsi      # 0x6050
leaq 0x68(%rsp), %rdx
xorl %eax, %eax
callq 0x22a0
cmpl $0x1, %eax
je 0x2df9
movq %rbx, %rdi
callq 0x2190
testq %r12, %r12
je 0x3058
movq %r12, %rdi
callq 0x2190
leaq 0x170(%rsp), %rbp
movq %rbp, %rdi
movq 0x5f56(%rip), %rsi      # 0x8fc0
callq 0x2140
leaq 0x1f0(%rsp), %rdi
callq 0x2090
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x3098
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x21b0
movq %r13, %rdi
callq 0x3d5c
movl 0x58(%rsp), %eax
incl %eax
movl %eax, 0x58(%rsp)
cmpl 0x61ac(%rip), %eax      # 0x925c
leaq 0x40(%rsp), %r12
jl 0x2bce
leaq 0x2fdf(%rip), %rdi      # 0x60a1
leaq 0x2ff1(%rip), %rsi      # 0x60ba
callq 0x21e0
movq %rax, %rbx
movq 0x50(%rsp), %r12
testl %r12d, %r12d
je 0x3107
leaq 0x2fda(%rip), %r14      # 0x60bc
xorl %r15d, %r15d
movq 0x120(%rsp), %rax
movl (%rax,%r15), %edx
movq %rbx, %rdi
movq %r14, %rsi
xorl %eax, %eax
callq 0x2210
addq $0x4, %r15
decq %r12
jne 0x30e5
movq %rbx, %rdi
callq 0x2190
movl (%rsp), %esi
movq 0x5ebf(%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 0x2f71(%rip), %rdi      # 0x60c0
leaq 0x2f64(%rip), %rsi      # 0x60ba
callq 0x21e0
movq %rax, %rbp
leaq 0x2f73(%rip), %rdi      # 0x60d8
leaq 0x2f33(%rip), %rsi      # 0x609f
callq 0x21e0
movq %rax, %r14
leaq 0x2f08(%rip), %r15      # 0x6083
leaq 0x170(%rsp), %r12
movl $0x0, 0x88(%rsp)
leaq 0x60cb(%rip), %rbx      # 0x9260
movq %rax, 0x50(%rsp)
movq %r14, %rdi
movq %r15, %rsi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x22a0
cmpl $0x1, %eax
jne 0x3580
movq 0x5e1e(%rip), %rdi      # 0x8fd8
movl 0x88(%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 0x180(%rsp), %rax
movq %rax, 0x170(%rsp)
movq %rbx, %rdi
callq 0x20c0
leaq (%rax,%rbx), %rdx
movq %r12, %rdi
movq %rbx, %rsi
callq 0x3dac
movq %r14, %rdi
movq %r15, %rsi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x22a0
leaq 0xa0(%rsp), %rax
movq %rax, 0x90(%rsp)
movq %rbx, %rdi
callq 0x20c0
leaq (%rax,%rbx), %rdx
leaq 0x90(%rsp), %rdi
movq %rbx, %rsi
callq 0x3dac
movq %r14, %rdi
movq %r15, %rsi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x22a0
leaq 0x20(%rsp), %rax
movq %rax, 0x10(%rsp)
movq %rbx, %rdi
callq 0x20c0
leaq (%rax,%rbx), %rdx
leaq 0x10(%rsp), %rdi
movq %rbx, %rsi
callq 0x3dac
leaq 0x5f3b(%rip), %rbx      # 0x91c8
movq %rbx, %rdi
movq %r12, %rsi
callq 0x3988
movslq (%rax), %r15
movq %rbx, %rdi
leaq 0x90(%rsp), %rsi
callq 0x3988
movq %r15, 0x58(%rsp)
movq %rbp, %r15
movslq (%rax), %rbx
leaq 0x5edb(%rip), %rdi      # 0x9198
leaq 0x10(%rsp), %rsi
callq 0x3988
movslq (%rax), %rax
movq %rax, 0x8(%rsp)
cmpl $0x0, 0x5f82(%rip)      # 0x9258
jle 0x33d0
movq 0x8(%rsp), %rax
leaq (%rax,%rax,2), %r14
leaq (%rbx,%rbx,2), %r12
xorl %ebp, %ebp
movq 0x36cc6(%rip), %rcx     # 0x39fb8
movq (%rcx,%r14,8), %rax
movq 0x8(%rcx,%r14,8), %rcx
subq %rax, %rcx
je 0x33a7
sarq $0x2, %rcx
movq 0x36c91(%rip), %rdx     # 0x39fa0
leaq (,%rbp,2), %rsi
addq %rbp, %rsi
movq (%rdx,%rsi,8), %rsi
movq (%rdx,%r12,8), %rdi
movq 0x36ca7(%rip), %r8      # 0x39fd0
cmpq $0x1, %rcx
adcq $0x0, %rcx
movq 0x36cb0(%rip), %r9      # 0x39fe8
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
xorl %r10d, %r10d
movsd 0x2cc0(%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 0x3363
ucomisd %xmm1, %xmm0
cmoval %r11d, %edx
minsd %xmm0, %xmm1
incq %r10
movapd %xmm1, %xmm0
cmpq %rcx, %r10
jne 0x3348
jmp 0x33ac
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movq %r15, %rdi
leaq 0x2d33(%rip), %rsi      # 0x60e9
xorl %eax, %eax
callq 0x2210
incq %rbp
movslq 0x5e91(%rip), %rax      # 0x9258
cmpq %rax, %rbp
jl 0x32eb
movl $0xa, %edi
movq %r15, %rbp
movq %r15, %rsi
callq 0x21f0
cmpl $0x0, 0x5e71(%rip)      # 0x9258
movq 0x58(%rsp), %r15
movq 0x8(%rsp), %r13
jle 0x34e6
xorl %r14d, %r14d
movq 0x36bb7(%rip), %rcx     # 0x39fb8
leaq (,%r13,2), %rdx
addq %r13, %rdx
movq (%rcx,%rdx,8), %rax
movq 0x8(%rcx,%rdx,8), %rcx
subq %rax, %rcx
je 0x34bd
sarq $0x2, %rcx
movq 0x36b77(%rip), %rdx     # 0x39fa0
leaq (%r15,%r15,2), %rsi
movq (%rdx,%rsi,8), %rsi
leaq (%r14,%r14,2), %rdi
movq (%rdx,%rdi,8), %rdi
movq 0x36b90(%rip), %r8      # 0x39fd0
cmpq $0x1, %rcx
adcq $0x0, %rcx
movq 0x36b99(%rip), %r9      # 0x39fe8
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
xorl %r10d, %r10d
movsd 0x2ba9(%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 0x347a
ucomisd %xmm1, %xmm0
cmoval %r11d, %edx
minsd %xmm0, %xmm1
incq %r10
movapd %xmm1, %xmm0
cmpq %rcx, %r10
jne 0x345f
jmp 0x34c2
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movq %rbp, %rdi
leaq 0x2c1d(%rip), %rsi      # 0x60e9
xorl %eax, %eax
callq 0x2210
incq %r14
movslq 0x5d7b(%rip), %rax      # 0x9258
cmpq %rax, %r14
jl 0x33fa
movl $0xa, %edi
movq %rbp, %rsi
callq 0x21f0
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
leaq 0x170(%rsp), %r12
je 0x3517
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x21b0
movq 0x90(%rsp), %rdi
leaq 0xa0(%rsp), %rax
cmpq %rax, %rdi
leaq 0x5d2f(%rip), %rbx      # 0x9260
movq 0x50(%rsp), %r14
leaq 0x2b46(%rip), %r15      # 0x6083
je 0x354f
movq 0xa0(%rsp), %rsi
incq %rsi
callq 0x21b0
movq 0x170(%rsp), %rdi
leaq 0x180(%rsp), %rax
cmpq %rax, %rdi
je 0x3574
movq 0x180(%rsp), %rsi
incq %rsi
callq 0x21b0
incl 0x88(%rsp)
jmp 0x319a
movq %r14, %rdi
callq 0x2190
leaq 0x140(%rsp), %rdi
callq 0x3d5c
movq 0x120(%rsp), %rdi
testq %rdi, %rdi
je 0x35b2
movq 0x130(%rsp), %rsi
subq %rdi, %rsi
callq 0x21b0
movq 0xc0(%rsp), %rdi
testq %rdi, %rdi
je 0x35cf
movq 0xd0(%rsp), %rsi
subq %rdi, %rsi
callq 0x21b0
movq 0xe0(%rsp), %rdi
testq %rdi, %rdi
je 0x35ec
movq 0xf0(%rsp), %rsi
subq %rdi, %rsi
callq 0x21b0
movq 0x100(%rsp), %rdi
testq %rdi, %rdi
je 0x3609
movq 0x110(%rsp), %rsi
subq %rdi, %rsi
callq 0x21b0
xorl %eax, %eax
addq $0x2f8, %rsp            # imm = 0x2F8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x37c0
jmp 0x370d
jmp 0x37c0
jmp 0x362e
movq %rax, %rbx
jmp 0x38b3
jmp 0x37e5
movq %rax, %rbx
jmp 0x3809
jmp 0x364a
jmp 0x37e5
movq %rax, %rbx
movq 0x68(%rsp), %rdi
leaq 0x78(%rsp), %rax
cmpq %rax, %rdi
je 0x37e8
movq 0x78(%rsp), %rsi
incq %rsi
jmp 0x37dc
jmp 0x3671
jmp 0x3671
movq %rax, %rbx
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x3697
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x21b0
jmp 0x3697
jmp 0x3694
movq %rax, %rbx
movq 0x90(%rsp), %rdi
leaq 0xa0(%rsp), %rax
cmpq %rax, %rdi
je 0x36c3
movq 0xa0(%rsp), %rsi
incq %rsi
callq 0x21b0
jmp 0x36c3
jmp 0x36c0
movq %rax, %rbx
movq 0x170(%rsp), %rdi
leaq 0x180(%rsp), %rax
cmpq %rax, %rdi
je 0x3832
movq 0x180(%rsp), %rsi
incq %rsi
callq 0x21b0
jmp 0x3832
jmp 0x37c0
jmp 0x3743
jmp 0x3743
jmp 0x36fc
movq %rax, %rbx
jmp 0x376b
jmp 0x3703
movq %rax, %rbx
jmp 0x3790
jmp 0x370d
movq %rax, %rbx
jmp 0x383f
jmp 0x3717
movq %rax, %rbx
movq 0x170(%rsp), %rdi
leaq 0x180(%rsp), %rax
cmpq %rax, %rdi
je 0x38b3
movq 0x180(%rsp), %rsi
incq %rsi
jmp 0x38ae
movq %rax, %rbx
movq 0x90(%rsp), %rdi
leaq 0xa0(%rsp), %rax
cmpq %rax, %rdi
je 0x376b
movq 0xa0(%rsp), %rsi
incq %rsi
callq 0x21b0
movq 0x140(%rsp), %rdi
leaq 0x150(%rsp), %rax
cmpq %rax, %rdi
je 0x3790
movq 0x150(%rsp), %rsi
incq %rsi
callq 0x21b0
movq 0x170(%rsp), %rdi
leaq 0x180(%rsp), %rax
cmpq %rax, %rdi
je 0x383f
movq 0x180(%rsp), %rsi
incq %rsi
callq 0x21b0
jmp 0x383f
jmp 0x37e5
movq %rax, %rbx
jmp 0x3832
jmp 0x37e5
movq %rax, %rbx
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x37e8
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x21b0
jmp 0x37e8
jmp 0x37e5
movq %rax, %rbx
movq 0x57d1(%rip), %rsi      # 0x8fc0
leaq 0x170(%rsp), %rdi
callq 0x2140
leaq 0x1f0(%rsp), %rdi
callq 0x2090
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x3825
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x21b0
leaq 0x90(%rsp), %rdi
callq 0x3d5c
leaq 0x140(%rsp), %rdi
callq 0x3d5c
movq 0x120(%rsp), %rdi
testq %rdi, %rdi
je 0x385c
movq 0x130(%rsp), %rsi
subq %rdi, %rsi
callq 0x21b0
movq 0xc0(%rsp), %rdi
testq %rdi, %rdi
je 0x3879
movq 0xd0(%rsp), %rsi
subq %rdi, %rsi
callq 0x21b0
movq 0xe0(%rsp), %rdi
testq %rdi, %rdi
je 0x3896
movq 0xf0(%rsp), %rsi
subq %rdi, %rsi
callq 0x21b0
movq 0x100(%rsp), %rdi
testq %rdi, %rdi
je 0x38b3
movq 0x110(%rsp), %rsi
subq %rdi, %rsi
callq 0x21b0
movq %rbx, %rdi
callq 0x2280
nop