// File: /workspace/github_cpp_makefile_star2_O2/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 $0x318, %rsp            # imm = 0x318
leaq 0x2a77(%rip), %rdi      # 0x5020
leaq 0x2aef(%rip), %r14      # 0x509f
movq %r14, %rsi
callq 0x21a0
movq %rax, %rbx
leaq 0x2a74(%rip), %rdi      # 0x5036
movq %r14, %rsi
callq 0x21a0
movq %rax, %r14
leaq 0x5c7c(%rip), %r12      # 0x8250
leaq 0xc(%rsp), %r13
leaq 0x190(%rsp), %rbp
movq %rbx, %rdi
leaq 0x2a63(%rip), %rsi      # 0x504e
movq %r12, %rdx
movq %r13, %rcx
xorl %eax, %eax
callq 0x2280
cmpl $0x2, %eax
jne 0x2651
movq %rbp, %rdi
movq %r12, %rsi
leaq 0x160(%rsp), %rdx
callq 0x32ae
movl 0xc(%rsp), %r15d
leaq 0x5b9c(%rip), %rdi      # 0x81b8
movq %rbp, %rsi
callq 0x32ea
movl %r15d, (%rax)
leaq 0x5bba(%rip), %rdi      # 0x81e8
movq %r13, %rsi
callq 0x3350
movq %rax, %rdi
movq %rbp, %rsi
callq 0x20d0
incl 0x5c01(%rip)            # 0x8248
movq %rbp, %rdi
callq 0x20a0
jmp 0x25e1
leaq 0x5bf8(%rip), %r12      # 0x8250
leaq 0xc(%rsp), %r13
leaq 0x190(%rsp), %rbp
movq %r14, %rdi
leaq 0x29df(%rip), %rsi      # 0x504e
movq %r12, %rdx
movq %r13, %rcx
xorl %eax, %eax
callq 0x2280
cmpl $0x2, %eax
jne 0x26d5
movq %rbp, %rdi
movq %r12, %rsi
leaq 0x160(%rsp), %rdx
callq 0x32ae
movl 0xc(%rsp), %r15d
leaq 0x5ae8(%rip), %rdi      # 0x8188
movq %rbp, %rsi
callq 0x32ea
movl %r15d, (%rax)
leaq 0x5b66(%rip), %rdi      # 0x8218
movq %r13, %rsi
callq 0x3350
movq %rax, %rdi
movq %rbp, %rsi
callq 0x20d0
incl 0x5b81(%rip)            # 0x824c
movq %rbp, %rdi
callq 0x20a0
jmp 0x2665
movq %rbx, %rdi
callq 0x2160
movq %r14, %rdi
callq 0x2160
leaq 0x2967(%rip), %rdi      # 0x5053
leaq 0x29ac(%rip), %rsi      # 0x509f
callq 0x21a0
movq %rax, %rbx
movslq 0x5b46(%rip), %rsi      # 0x8248
leaq 0x36887(%rip), %rdi     # 0x38f90
callq 0x339e
pushq $0x32
popq %r14
leaq 0x2954(%rip), %r15      # 0x506d
xorl %r12d, %r12d
movslq 0x5b25(%rip), %rax      # 0x8248
cmpq %rax, %r12
jge 0x276f
imulq $0x18, %r12, %r13
movq 0x3685d(%rip), %rdi     # 0x38f90
addq %r13, %rdi
movq %r14, %rsi
callq 0x33d4
xorl %ebp, %ebp
cmpq $0x190, %rbp            # imm = 0x190
je 0x276a
movq 0x36840(%rip), %rax     # 0x38f90
movq (%rax,%r13), %rdx
addq %rbp, %rdx
movq %rbx, %rdi
movq %r15, %rsi
xorl %eax, %eax
callq 0x2280
addq $0x8, %rbp
jmp 0x2740
incq %r12
jmp 0x271c
movq %rbx, %rdi
callq 0x2160
leaq 0x28f3(%rip), %rdi      # 0x5071
leaq 0x291a(%rip), %rsi      # 0x509f
callq 0x21a0
movq %rax, %rbx
xorpd %xmm0, %xmm0
leaq 0x120(%rsp), %rax
movapd %xmm0, (%rax)
andq $0x0, 0x10(%rax)
leaq 0x100(%rsp), %rax
movapd %xmm0, (%rax)
andq $0x0, 0x10(%rax)
leaq 0xe0(%rsp), %rax
andq $0x0, 0x10(%rax)
movapd %xmm0, (%rax)
andq $0x0, 0x150(%rsp)
movapd %xmm0, 0x140(%rsp)
andq $0x0, 0xb0(%rsp)
movapd %xmm0, 0xa0(%rsp)
leaq 0x5a61(%rip), %rbp      # 0x8250
leaq 0x190(%rsp), %r14
leaq 0x160(%rsp), %r15
leaq 0x70(%rsp), %r12
movq $0x0, 0x18(%rsp)
movq %rbx, %rdi
leaq 0x286c(%rip), %rsi      # 0x5083
movq %rbp, %rdx
xorl %eax, %eax
callq 0x2280
cmpl $0x1, %eax
jne 0x291a
movq %r14, %rdi
movq %rbp, %rsi
movq %r15, %rdx
callq 0x32ae
movq %rbx, %rdi
leaq 0x2841(%rip), %rsi      # 0x5083
movq %rbp, %rdx
xorl %eax, %eax
callq 0x2280
movq %r15, %rdi
movq %rbp, %rsi
movq %r12, %rdx
callq 0x32ae
movq %rbx, %rdi
leaq 0x281f(%rip), %rsi      # 0x5083
movq %rbp, %rdx
xorl %eax, %eax
callq 0x2280
movq %r12, %rdi
movq %rbp, %rsi
leaq 0x28(%rsp), %rdx
callq 0x32ae
leaq 0x5933(%rip), %r13      # 0x81b8
movq %r13, %rdi
movq %r14, %rsi
callq 0x32ea
movl (%rax), %eax
movl %eax, 0x28(%rsp)
movq %r13, %rdi
movq %r15, %rsi
callq 0x32ea
movl (%rax), %eax
movl %eax, 0x50(%rsp)
leaq 0x58da(%rip), %rdi      # 0x8188
movq %r12, %rsi
callq 0x32ea
movl (%rax), %eax
movl %eax, 0xb8(%rsp)
leaq 0x120(%rsp), %rdi
leaq 0x28(%rsp), %rsi
callq 0x3406
leaq 0x100(%rsp), %rdi
leaq 0x50(%rsp), %rsi
callq 0x3406
leaq 0xe0(%rsp), %rdi
leaq 0xb8(%rsp), %rsi
callq 0x3406
movq %r12, %rdi
callq 0x20a0
movq %r15, %rdi
callq 0x20a0
movq %r14, %rdi
callq 0x20a0
incq 0x18(%rsp)
jmp 0x280d
leaq 0xa0(%rsp), %rdi
movq 0x18(%rsp), %rsi
callq 0x3424
movq %rbx, %rdi
callq 0x2160
andl $0x0, 0x8(%rsp)
leaq 0x168(%rsp), %rax
andl $0x0, (%rax)
andq $0x0, 0x8(%rax)
movq %rax, 0x10(%rax)
movq %rax, 0x18(%rax)
andq $0x0, 0x20(%rax)
movslq 0x58ef(%rip), %rsi      # 0x824c
leaq 0x36644(%rip), %rdi     # 0x38fa8
callq 0x3456
leaq 0x70(%rsp), %r15
leaq 0x190(%rsp), %rbx
leaq 0xb8(%rsp), %r14
leaq 0x26c4(%rip), %rbp      # 0x5049
leaq 0x4c(%rsp), %r13
xorl %eax, %eax
cmpl 0x58ba(%rip), %eax      # 0x824c
jge 0x2cd3
movl %eax, 0x4(%rsp)
andl $0x0, 0x78(%rsp)
andq $0x0, 0x80(%rsp)
leaq 0x78(%rsp), %rax
movq %rax, 0x88(%rsp)
movq %rax, 0x90(%rsp)
andq $0x0, 0x98(%rsp)
movq %r15, %rdi
callq 0x476c
leaq 0x38(%rsp), %rax
movq %rax, 0x28(%rsp)
andq $0x0, 0x30(%rsp)
movb $0x0, 0x38(%rsp)
movq %rbx, %rdi
callq 0x20f0
leaq 0x1a0(%rsp), %rdi
movl 0x4(%rsp), %esi
callq 0x2250
movq %rbx, %rdi
leaq 0x28(%rsp), %rsi
callq 0x21c0
movq 0x55c6(%rip), %rdi      # 0x7fd8
leaq 0x28(%rsp), %rsi
callq 0x2150
movq %rax, %rdi
callq 0x20b0
movq %r14, %rdi
leaq 0x2658(%rip), %rsi      # 0x5086
leaq 0x28(%rsp), %rdx
callq 0x34aa
leaq 0x50(%rsp), %r12
movq %r12, %rdi
movq %r14, %rsi
movq %rbp, %rdx
callq 0x348b
movq 0x50(%rsp), %rdi
leaq 0x2648(%rip), %rsi      # 0x509f
callq 0x21a0
movq %rax, %rbx
movq %r12, %rdi
callq 0x20a0
movq %r14, %rdi
callq 0x20a0
movq %r14, %rdi
leaq 0x261b(%rip), %rsi      # 0x5094
leaq 0x28(%rsp), %rdx
callq 0x34aa
movq %r12, %rdi
movq %r14, %rsi
movq %rbp, %rdx
callq 0x348b
movq 0x50(%rsp), %rdi
leaq 0x2602(%rip), %rsi      # 0x509f
callq 0x21a0
movq %rax, %rbp
movq %r12, %rdi
callq 0x20a0
movq %r14, %r12
movq %r14, %rdi
callq 0x20a0
movq %rbx, %rdi
leaq 0x258e(%rip), %rsi      # 0x5050
movq %r12, %rdx
xorl %eax, %eax
callq 0x2280
cmpl $0x1, %eax
jne 0x2c87
testq %rbp, %rbp
je 0x2af0
movq %rbp, %rdi
leaq 0x256c(%rip), %rsi      # 0x5050
movq %r13, %rdx
xorl %eax, %eax
callq 0x2280
jmp 0x2af5
andl $0x0, 0x4c(%rsp)
movq %r15, %rdi
movq %r13, %rsi
callq 0x3520
testq %rax, %rax
jne 0x2bb1
movl 0x8(%rsp), %r14d
movq %r15, %rdi
movq %r13, %rsi
callq 0x353a
movl %r14d, (%rax)
movl 0xb8(%rsp), %r14d
leaq 0x160(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x353a
movl %r14d, (%rax)
movslq 0xb8(%rsp), %rax
movq 0xe0(%rsp), %rcx
movslq (%rcx,%rax,4), %rax
imulq $0x18, %rax, %rdi
addq 0x36450(%rip), %rdi     # 0x38fa8
leaq 0x8(%rsp), %rsi
callq 0x3406
andl $0x0, 0x50(%rsp)
leaq 0x3646a(%rip), %rdi     # 0x38fd8
leaq 0x50(%rsp), %r14
movq %r14, %rsi
callq 0x4a5a
xorpd %xmm0, %xmm0
movapd %xmm0, 0x50(%rsp)
andq $0x0, 0x60(%rsp)
movq %r14, %rdi
pushq $0x32
popq %rsi
callq 0x33d4
leaq 0x36423(%rip), %rdi     # 0x38fc0
movq %r14, %rsi
callq 0x3588
incl 0x8(%rsp)
movq %r14, %rdi
callq 0x4b50
xorl %r14d, %r14d
cmpq $0x32, %r14
je 0x2c4a
movslq 0xb8(%rsp), %rax
movq 0x120(%rsp), %rcx
movslq (%rcx,%rax,4), %rcx
movq 0x363b7(%rip), %rdx     # 0x38f90
imulq $0x18, %rcx, %rcx
movq (%rdx,%rcx), %rcx
movsd (%rcx,%r14,8), %xmm0
movsd %xmm0, 0x10(%rsp)
movq 0x100(%rsp), %rcx
movslq (%rcx,%rax,4), %rax
imulq $0x18, %rax, %rax
movq (%rdx,%rax), %rax
movsd (%rax,%r14,8), %xmm0
movsd %xmm0, 0x20(%rsp)
movq %r15, %rdi
movq %r13, %rsi
callq 0x353a
movsd 0x10(%rsp), %xmm0
subsd 0x20(%rsp), %xmm0
movslq (%rax), %rax
movq 0x36392(%rip), %rcx     # 0x38fc0
imulq $0x18, %rax, %rax
movq (%rcx,%rax), %rax
addsd (%rax,%r14,8), %xmm0
movsd %xmm0, (%rax,%r14,8)
incq %r14
jmp 0x2bb4
movq %r15, %rdi
movq %r13, %rsi
callq 0x353a
movl (%rax), %eax
movslq 0xb8(%rsp), %rcx
movq 0xa0(%rsp), %rdx
movl %eax, (%rdx,%rcx,4)
movq %r15, %rdi
movq %r13, %rsi
callq 0x353a
movslq (%rax), %rax
movq 0x36359(%rip), %rcx     # 0x38fd8
incl (%rcx,%rax,4)
jmp 0x2ab8
movq %rbx, %rdi
callq 0x2160
testq %rbp, %rbp
leaq 0x190(%rsp), %rbx
je 0x2ca4
movq %rbp, %rdi
callq 0x2160
movq %rbx, %rdi
callq 0x2110
leaq 0x28(%rsp), %rdi
callq 0x20a0
movq %r15, %rdi
callq 0x3688
movl 0x4(%rsp), %eax
incl %eax
movq %r12, %r14
leaq 0x237b(%rip), %rbp      # 0x5049
jmp 0x298c
leaq 0x23c7(%rip), %rdi      # 0x50a1
leaq 0x23d9(%rip), %rsi      # 0x50ba
callq 0x21a0
movq %rax, %rbx
leaq 0x23cc(%rip), %r14      # 0x50bc
xorl %r15d, %r15d
subq $0x1, 0x18(%rsp)
jb 0x2d1a
movq 0xa0(%rsp), %rax
movl (%rax,%r15), %edx
movq %rbx, %rdi
movq %r14, %rsi
xorl %eax, %eax
callq 0x21f0
addq $0x4, %r15
jmp 0x2cf3
movq %rbx, %rdi
callq 0x2160
movl 0x8(%rsp), %esi
movq 0x52ab(%rip), %rdi      # 0x7fd8
callq 0x2250
movq %rax, %rdi
callq 0x20b0
leaq 0x237f(%rip), %rdi      # 0x50c0
leaq 0x2372(%rip), %rsi      # 0x50ba
callq 0x21a0
movq %rax, 0x10(%rsp)
leaq 0x237f(%rip), %rdi      # 0x50d8
leaq 0x233f(%rip), %rsi      # 0x509f
callq 0x21a0
movq %rax, %rbx
leaq 0x2314(%rip), %r14      # 0x5083
leaq 0x54da(%rip), %r15      # 0x8250
leaq 0x190(%rsp), %r12
movl $0x0, 0x4(%rsp)
movq %rax, 0xd8(%rsp)
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
xorl %eax, %eax
callq 0x2280
cmpl $0x1, %eax
jne 0x307f
movq 0x522a(%rip), %rdi      # 0x7fd8
movl 0x4(%rsp), %esi
callq 0x2250
movq %rax, %rdi
callq 0x20b0
movq %r12, %rdi
movq %r15, %rsi
leaq 0x70(%rsp), %rdx
callq 0x32ae
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
xorl %eax, %eax
callq 0x2280
leaq 0x70(%rsp), %rdi
movq %r15, %rsi
leaq 0x28(%rsp), %rdx
callq 0x32ae
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
xorl %eax, %eax
callq 0x2280
leaq 0x28(%rsp), %rdi
movq %r15, %rsi
leaq 0x50(%rsp), %rdx
callq 0x32ae
leaq 0x539e(%rip), %r14      # 0x81b8
movq %r14, %rdi
movq %r12, %rsi
callq 0x32ea
movslq (%rax), %r15
movq %r14, %rdi
leaq 0x70(%rsp), %rsi
callq 0x32ea
movq %r15, 0x18(%rsp)
movslq (%rax), %rbx
leaq 0x5344(%rip), %rdi      # 0x8188
leaq 0x28(%rsp), %rsi
callq 0x32ea
incl 0x4(%rsp)
movslq (%rax), %rax
imulq $0x18, %rax, %r12
imulq $0x18, %rbx, %rax
movq %rax, 0x20(%rsp)
xorl %r14d, %r14d
movslq 0x53dc(%rip), %rax      # 0x8248
cmpq %rax, %r14
jge 0x2f3d
movq 0x3612c(%rip), %rcx     # 0x38fa8
movq (%rcx,%r12), %rax
movq 0x8(%rcx,%r12), %rcx
subq %rax, %rcx
sarq $0x2, %rcx
movq 0x360fd(%rip), %rsi     # 0x38f90
imulq $0x18, %r14, %rdi
addq %rsi, %rdi
addq 0x20(%rsp), %rsi
movq 0x3611a(%rip), %r8      # 0x38fc0
movq 0x3612b(%rip), %r9      # 0x38fd8
xorl %r10d, %r10d
movsd 0x2150(%rip), %xmm0     # 0x5008
pushq $-0x1
popq %rdx
cmpq %rcx, %r10
je 0x2f22
movslq (%rax,%r10,4), %r11
movq (%rdi), %rbp
movq (%rsi), %r15
imulq $0x18, %r11, %rbx
movq (%r8,%rbx), %rbx
cvtsi2sdl (%r9,%r11,4), %xmm2
xorpd %xmm1, %xmm1
xorl %r13d, %r13d
cmpq $0x32, %r13
je 0x2f0d
movsd (%rbp,%r13,8), %xmm3
subsd (%r15,%r13,8), %xmm3
movsd (%rbx,%r13,8), %xmm4
divsd %xmm2, %xmm4
subsd %xmm4, %xmm3
mulsd %xmm3, %xmm3
addsd %xmm3, %xmm1
incq %r13
jmp 0x2edf
ucomisd %xmm1, %xmm0
cmoval %r11d, %edx
minsd %xmm0, %xmm1
incq %r10
movapd %xmm1, %xmm0
jmp 0x2ebb
movq 0x10(%rsp), %rdi
leaq 0x21bb(%rip), %rsi      # 0x50e9
xorl %eax, %eax
callq 0x21f0
incq %r14
jmp 0x2e65
pushq $0xa
popq %rdi
movq 0x10(%rsp), %rsi
callq 0x21b0
imulq $0x18, 0x18(%rsp), %rax
movq %rax, 0x20(%rsp)
xorl %r13d, %r13d
movslq 0x52e9(%rip), %rax      # 0x8248
cmpq %rax, %r13
jge 0x3033
movq 0x36039(%rip), %rcx     # 0x38fa8
movq (%rcx,%r12), %rax
movq 0x8(%rcx,%r12), %rcx
subq %rax, %rcx
sarq $0x2, %rcx
movq 0x3600a(%rip), %rdx     # 0x38f90
movq 0x20(%rsp), %rsi
addq %rdx, %rsi
imulq $0x18, %r13, %rdi
addq %rdx, %rdi
movq 0x36024(%rip), %r8      # 0x38fc0
movq 0x36035(%rip), %r9      # 0x38fd8
xorl %r10d, %r10d
movsd 0x205a(%rip), %xmm0     # 0x5008
pushq $-0x1
popq %rdx
cmpq %rcx, %r10
je 0x3018
movslq (%rax,%r10,4), %r11
movq (%rsi), %rbp
movq (%rdi), %r15
imulq $0x18, %r11, %rbx
movq (%r8,%rbx), %rbx
cvtsi2sdl (%r9,%r11,4), %xmm2
xorpd %xmm1, %xmm1
xorl %r14d, %r14d
cmpq $0x32, %r14
je 0x3003
movsd (%rbp,%r14,8), %xmm3
subsd (%r15,%r14,8), %xmm3
movsd (%rbx,%r14,8), %xmm4
divsd %xmm2, %xmm4
subsd %xmm4, %xmm3
mulsd %xmm3, %xmm3
addsd %xmm3, %xmm1
incq %r14
jmp 0x2fd5
ucomisd %xmm1, %xmm0
cmoval %r11d, %edx
minsd %xmm0, %xmm1
incq %r10
movapd %xmm1, %xmm0
jmp 0x2fb1
movq 0x10(%rsp), %rdi
leaq 0x20c5(%rip), %rsi      # 0x50e9
xorl %eax, %eax
callq 0x21f0
incq %r13
jmp 0x2f58
pushq $0xa
popq %rdi
movq 0x10(%rsp), %rsi
callq 0x21b0
leaq 0x28(%rsp), %rdi
callq 0x20a0
leaq 0x70(%rsp), %rdi
callq 0x20a0
leaq 0x190(%rsp), %r12
movq %r12, %rdi
callq 0x20a0
movq 0xd8(%rsp), %rbx
leaq 0x2010(%rip), %r14      # 0x5083
leaq 0x51d6(%rip), %r15      # 0x8250
jmp 0x2d8e
movq %rbx, %rdi
callq 0x2160
leaq 0x160(%rsp), %rdi
callq 0x3688
leaq 0xa0(%rsp), %rdi
callq 0x37a4
leaq 0x140(%rsp), %rdi
callq 0x37a4
leaq 0xe0(%rsp), %rdi
callq 0x37a4
leaq 0x100(%rsp), %rdi
callq 0x37a4
leaq 0x120(%rsp), %rdi
callq 0x37a4
xorl %eax, %eax
addq $0x318, %rsp            # imm = 0x318
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x3184
jmp 0x317c
jmp 0x3184
jmp 0x30fc
jmp 0x30fc
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0x20a0
jmp 0x3110
jmp 0x310d
movq %rax, %rbx
leaq 0x70(%rsp), %rdi
callq 0x20a0
jmp 0x3121
jmp 0x311e
movq %rax, %rbx
leaq 0x190(%rsp), %rdi
callq 0x20a0
jmp 0x3202
jmp 0x3184
jmp 0x313c
jmp 0x31de
movq %rax, %rbx
leaq 0xb8(%rsp), %rdi
callq 0x20a0
jmp 0x31e1
jmp 0x31de
movq %rax, %rbx
jmp 0x31ee
jmp 0x31a2
jmp 0x31a2
jmp 0x3164
movq %rax, %rbx
jmp 0x31af
jmp 0x316b
movq %rax, %rbx
jmp 0x31bc
jmp 0x317c
jmp 0x3174
movq %rax, %rbx
jmp 0x3250
movq %rax, %rbx
jmp 0x320f
movq %rax, %rbx
jmp 0x3202
jmp 0x318b
movq %rax, %rbx
leaq 0x190(%rsp), %rdi
callq 0x20a0
jmp 0x3250
jmp 0x31de
movq %rax, %rbx
leaq 0x70(%rsp), %rdi
callq 0x20a0
leaq 0x160(%rsp), %rdi
callq 0x20a0
leaq 0x190(%rsp), %rdi
callq 0x20a0
jmp 0x320f
jmp 0x31de
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
callq 0x4b50
jmp 0x31e1
jmp 0x31de
movq %rax, %rbx
leaq 0x190(%rsp), %rdi
callq 0x2110
leaq 0x28(%rsp), %rdi
callq 0x20a0
leaq 0x70(%rsp), %rdi
callq 0x3688
leaq 0x160(%rsp), %rdi
callq 0x3688
leaq 0xa0(%rsp), %rdi
callq 0x37a4
leaq 0x140(%rsp), %rdi
callq 0x37a4
leaq 0xe0(%rsp), %rdi
callq 0x37a4
leaq 0x100(%rsp), %rdi
callq 0x37a4
leaq 0x120(%rsp), %rdi
callq 0x37a4
movq %rbx, %rdi
callq 0x2260