// File: /workspace/github_cpp_makefile_star2_O3/Luthaf[P]zeopp/feature.cc
// Function: FEATURE::calculateSurfaceArea(ATOM_NETWORK*, std::vector<DIJKSTRA_NODE, std::allocator<DIJKSTRA_NODE>>*, std::vector<int, std::allocator<int>>*, int, char*, int)
double FEATURE::calculateSurfaceArea(ATOM_NETWORK *uc,vector<DIJKSTRA_NODE> *ChanNodeList,vector <int> *featnodemap,int curr_f,char *name,int fid){
 
  long int i,j,k,counter=0;  
  int step;
  double r_tr; // threshold for r
  Point pt;

  vector <double> SA_holo;  // stores hologram for each feature
  vector <double> SA_holo_otherf; // as above but excluding surface that is covered by other segments

  srand(randSeed2);
  SPHERE sph,sph2;
  vector <SPHERE> object; // a vector of spheres that define object (segemnt/feature/channel)

  vector <SPHERE> other_object; // vectors of spheres corresponding to other segments



// Create object (current feature) and a list of spheres that overlap with the current feature

vector <int> conn_feat;

 for(j=0;j<(int)ChanNodeList->size();j++)
    {
    if(featnodemap->at(j)==curr_f)
      {
      /* if current feature, build object */
      sph.x=ChanNodeList->at(j).x; sph.y=ChanNodeList->at(j).y; sph.z=ChanNodeList->at(j).z;
      sph.r=SPHERE_SCALE*ChanNodeList->at(j).max_radius;

      object.push_back(sph);

      /* check feature two which it is connected */
      for(i=0;i<(int)(ChanNodeList->at(j).connections.size());i++)      
         {
         if(featnodemap->at(ChanNodeList->at(j).connections.at(i).to)!=curr_f)
            {
            int flag=0;
            for(k=0;k<(int)conn_feat.size();k++)
               {
               if(conn_feat[k]==featnodemap->at(ChanNodeList->at(j).connections.at(i).to)) flag=1;
               };
            if(flag==0) conn_feat.push_back(featnodemap->at(ChanNodeList->at(j).connections.at(i).to));
            };
         };
      };
    }

for(i=0;i<(int)conn_feat.size();i++)
 for(j=0;j<(int)ChanNodeList->size();j++)
    {
    if(featnodemap->at(j)==i)
       {
       sph2.x=ChanNodeList->at(j).x; sph2.y=ChanNodeList->at(j).y; sph2.z=ChanNodeList->at(j).z;
       sph2.r=ChanNodeList->at(j).max_radius*SPHERE_SCALE;

       int flag=0;
       for(k=0;k<(int)object.size();k++)
           {
           Point pp;
           pp[0]=ChanNodeList->at(j).x; pp[1]=ChanNodeList->at(j).y; pp[2]=ChanNodeList->at(j).z;
           Point pt_s=uc->minimizePointDistance(pp,object[k].x, object[k].y, object[k].z); // pt_s shifted
           double d = calcEuclideanDistance(pt_s[0],pt_s[1],pt_s[2],object[k].x, object[k].y, object[k].z);
           if(d<object[k].r+sph2.r) 
              {
              flag=1; break;
              };
           };
       if(flag==0) other_object.push_back(sph2);

       };
    };



cout << "Outside spheres list contain " << other_object.size() << " spheres (of " << ChanNodeList->size() << " nodes)." << "\n";



// Now MC integration of surface


SA_holo.resize(NBINS_SA_HOLO,0);
SA_holo_otherf.resize(NBINS_SA_HOLO,0);

for(step=0;step<NBINS_SA_HOLO;step++) // loop over all bins for surface area holograms
   {
   r_tr=(double)step*SA_HOLO_STEP;

   counter=0;

   for(j=0;j<(int)object.size();j++)
      {
      if(object[j].r>r_tr) { counter++;break;}; // at least one sphere larger than r_tr, sampling makes sense
      };


   if(counter>0)
     { // sampling makes sense


     // Sample around each of the object's spheres
     for(int i = 0; i < (int)object.size(); i++){

        int count = 0;
        int count_otherf=0;

        if(object[i].r-r_tr>0)
        for(int j = 0; j < N_MC_SA_SAMPLE; j++){

        bool overlap=false;
        bool overlap_otherf=false; // overlap with other features

        // Randomly sample point on a sphere of radius 1
        double theta = (rand()*1.0/RAND_MAX)*2*PI;
        double cosphi = 1.0 - (rand()*1.0/RAND_MAX)*2.0;
        double phi = acos(cosphi);

        // Convert spherical coordinates to xyz coordinates
        double xpoint = sin(phi)*cos(theta); //Don't need abs(sin(phi)) becase phi is from 0 to pi
        double ypoint = sin(phi)*sin(theta);
        double zpoint = cosphi;	
      
        // Scale the point to lie on a radius of r_probe + r_atom#i
        xpoint *= (object[i].r-r_tr);
        ypoint *= (object[i].r-r_tr);
        zpoint *= (object[i].r-r_tr);

        // move the point to the segment

        pt[0]=object[i].x+xpoint;
        pt[1]=object[i].y+ypoint;
        pt[2]=object[i].z+zpoint;

//             if(fid==0) cout << "### draw point { "<< pt.x << "  " << pt.y << "  " << pt.z<< " } " << "\n";
 
        Point newpt=uc->xyz_to_abc(pt);
        newpt=uc->shiftABCInUC(newpt);
        pt=uc->abc_to_xyz(newpt);
//        pt = uc->shiftXYZInUC(pt);
//             if(fid==0) cout << "### draw point { "<< pt.x << "  " << pt.y << "  " << pt.z<< " } " << "\n";

        for(k=0;k<(int)object.size();k++)
           {
           if(k!=i)
             {
//             Point pt_s=minimizePointDistance(pt,object[k].x, object[k].y, object[k].z, uc); // pt_s shifted
//             double centerDist = calcEuclideanDistance(pt_s.x,pt_s.y,pt_s.z,object[k].x, object[k].y, object[k].z); 

             double centerDist = uc->calcDistanceXYZ(pt[0],pt[1],pt[2],object[k].x, object[k].y, object[k].z);

             if(centerDist < (object[k].r-r_tr) - 0.00001){
                overlap=true; break;
                };
             };
           };

          if(overlap==false) count++;

         // check otherlap with other segments
  
         if(overlap==false)
         for(int jk=0;jk<(int)other_object.size();jk++)
            {

//           Point pt_s=minimizePointDistance(pt,other_object[jk].x,other_object[jk].y,other_object[jk].z,uc);
//            double dist = calcEuclideanDistance(pt_s.x,pt_s.y,pt_s.z,other_object[jk].x,other_object[jk].y,other_object[jk].z);

            double dist = uc->calcDistanceXYZ(pt[0],pt[1],pt[2],object[jk].x, object[jk].y, object[jk].z);

            if(dist<other_object[jk].r) {
                 overlap_otherf=true; break;
                 };

           };
          

          if(overlap==false&&overlap_otherf==false) 
             {
             count_otherf++;

//             if(fid==0) cout << "### draw point { "<< pt.x << "  " << pt.y << "  " << pt.z<< " } " << "\n"; 

             };


     
       }; // ends for(int j = 0; j < N_MC_SA_SAMPLE; j++){

     cout << " count= " << count << "    cont_otherf= " << count_otherf << "\n";

     SA_holo[step]+= ((double)count/(double)N_MC_SA_SAMPLE)* 4.0 * PI * pow(object[i].r-r_tr,2);
     SA_holo_otherf[step]+= ((double)count_otherf/(double)N_MC_SA_SAMPLE)* 4.0 * PI * pow(object[i].r-r_tr,2);
     }; // ends for(int i = 0; i < (int)object.size() 

     }else   // from if(counter>0)
     {
     // surface area is 0
     SA_holo[step]=0;
     }; // ends  if(counter>0)

   }; // ends for(step=0;step<NBINS_SA_HOLO;step++)


cout << "##SA_holo:  " << name << "  Feature=  " << fid << "   ";
for(i=0;i<NBINS_SA_HOLO;i++)
   {
   cout << SA_holo[i] << "   ";
   };

cout << " Other:  ";
for(i=0;i<NBINS_SA_HOLO;i++)
   {
   cout << SA_holo_otherf[i] << "   ";
   };

cout << "\n";

//volume=volume*((double)(N_MC_SAMPLE-counter))/(double)N_MC_SAMPLE;

return SA_holo[0];


}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1a8, %rsp            # imm = 0x1A8
movq %r9, 0x120(%rsp)
movl %r8d, %ebx
movq %rcx, 0x58(%rsp)
movq %rdx, %r15
movq %rsi, 0x48(%rsp)
leaq 0x100(%rsp), %rdi
xorpd %xmm0, %xmm0
xorpd %xmm1, %xmm1
xorpd %xmm2, %xmm2
callq 0x83f68
xorl %r14d, %r14d
movq %r14, 0xd0(%rsp)
xorpd %xmm0, %xmm0
movapd %xmm0, 0xc0(%rsp)
movq %r14, 0xf0(%rsp)
movapd %xmm0, 0xe0(%rsp)
movl $0x3b4ca6f5, %edi       # imm = 0x3B4CA6F5
callq 0x4410
movq %r14, 0x40(%rsp)
xorpd %xmm0, %xmm0
movapd %xmm0, 0x30(%rsp)
movq %r14, 0x70(%rsp)
movapd %xmm0, 0x60(%rsp)
movq %r14, 0xb0(%rsp)
movapd %xmm0, 0xa0(%rsp)
movq (%r15), %rax
movq 0x8(%r15), %rcx
movq %rcx, %rsi
subq %rax, %rsi
sarq $0x3, %rsi
movabsq $-0x71c71c71c71c71c7, %rdx # imm = 0x8E38E38E38E38E39
imulq %rdx, %rsi
testl %esi, %esi
jle 0x795e2
xorl %r13d, %r13d
movabsq $-0x3333333333333333, %r14 # imm = 0xCCCCCCCCCCCCCCCD
movl $0x1, %ebp
movq 0x58(%rsp), %rdx
movq (%rdx), %rdi
movq 0x8(%rdx), %rdx
subq %rdi, %rdx
sarq $0x2, %rdx
cmpq %r13, %rdx
jbe 0x7a18d
cmpl %ebx, (%rdi,%r13,4)
jne 0x795a9
cmpq %r13, %rsi
jbe 0x7a18a
leaq (,%r13,8), %rcx
addq %r13, %rcx
movups 0x8(%rax,%rcx,8), %xmm0
movaps %xmm0, 0x180(%rsp)
movsd 0x18(%rax,%rcx,8), %xmm0
movsd %xmm0, 0x190(%rsp)
movq %rcx, 0x18(%rsp)
movsd 0x38(%rax,%rcx,8), %xmm0
mulsd 0xd8da0(%rip), %xmm0    # 0x1521d0
movsd %xmm0, 0x198(%rsp)
movq 0x38(%rsp), %rsi
cmpq 0x40(%rsp), %rsi
je 0x7946b
movapd 0x180(%rsp), %xmm0
movapd 0x190(%rsp), %xmm1
movupd %xmm1, 0x10(%rsi)
movupd %xmm0, (%rsi)
addq $0x20, %rsi
movq %rsi, 0x38(%rsp)
jmp 0x7947d
leaq 0x30(%rsp), %rdi
leaq 0x180(%rsp), %rdx
callq 0x499ba
movq (%r15), %rax
movq 0x8(%r15), %rcx
movq %rcx, %rdx
subq %rax, %rdx
sarq $0x3, %rdx
movabsq $-0x71c71c71c71c71c7, %rsi # imm = 0x8E38E38E38E38E39
imulq %rsi, %rdx
cmpq %r13, %rdx
jbe 0x7a18d
xorl %r12d, %r12d
movq 0x18(%rsp), %rdx
movq 0x20(%rax,%rdx,8), %rsi
movq 0x28(%rax,%rdx,8), %rdx
subq %rsi, %rdx
sarq $0x3, %rdx
imulq %r14, %rdx
movslq %edx, %rdi
cmpq %rdi, %r12
jge 0x795a9
cmpq %r12, %rdx
jbe 0x7a180
leaq (%r12,%r12,4), %rdx
movslq 0x4(%rsi,%rdx,8), %rdi
movq 0x58(%rsp), %rdx
movq (%rdx), %r8
movq 0x8(%rdx), %rdx
subq %r8, %rdx
sarq $0x2, %rdx
cmpq %rdi, %rdx
jbe 0x7a185
movl (%r8,%rdi,4), %edx
cmpl %ebx, %edx
je 0x79580
movq 0xa0(%rsp), %r9
movq 0xa8(%rsp), %rsi
movq %rsi, %r10
subq %r9, %r10
shrq $0x2, %r10
movslq %r10d, %r10
testq %r10, %r10
jle 0x7954e
movl %ebx, %r14d
xorl %r11d, %r11d
xorl %ebx, %ebx
cmpl %edx, (%r9,%r11,4)
cmovel %ebp, %ebx
incq %r11
cmpq %r11, %r10
jne 0x7952e
testl %ebx, %ebx
movl %r14d, %ebx
movabsq $-0x3333333333333333, %r14 # imm = 0xCCCCCCCCCCCCCCCD
jne 0x79580
cmpq 0xb0(%rsp), %rsi
je 0x79568
movl %edx, (%rsi)
addq $0x4, %rsi
movq %rsi, 0xa8(%rsp)
jmp 0x79580
leaq (%r8,%rdi,4), %rdx
leaq 0xa0(%rsp), %rdi
callq 0xf864
movq (%r15), %rax
movq 0x8(%r15), %rcx
incq %r12
movq %rcx, %rdx
subq %rax, %rdx
sarq $0x3, %rdx
movabsq $-0x71c71c71c71c71c7, %rsi # imm = 0x8E38E38E38E38E39
imulq %rsi, %rdx
cmpq %r13, %rdx
ja 0x794a8
jmp 0x7a18d
incq %r13
movq %rcx, %rsi
subq %rax, %rsi
sarq $0x3, %rsi
movabsq $-0x71c71c71c71c71c7, %rdx # imm = 0x8E38E38E38E38E39
imulq %rdx, %rsi
movslq %esi, %rdx
cmpq %rdx, %r13
jl 0x793c7
movq 0xa0(%rsp), %rdx
movq 0xa8(%rsp), %r14
jmp 0x795e4
xorl %edx, %edx
subq %rdx, %r14
shlq $0x1e, %r14
testq %r14, %r14
jle 0x7993c
movq $0x0, 0x50(%rsp)
leaq 0x148(%rsp), %rbp
movq %rcx, %rsi
subq %rax, %rsi
sarq $0x3, %rsi
movabsq $-0x71c71c71c71c71c7, %rdi # imm = 0x8E38E38E38E38E39
imulq %rdi, %rsi
testl %esi, %esi
jle 0x79914
xorl %r13d, %r13d
movq 0x58(%rsp), %rdx
movq (%rdx), %rcx
movq 0x8(%rdx), %rdx
subq %rcx, %rdx
sarq $0x2, %rdx
cmpq %r13, %rdx
jbe 0x7a18d
movslq (%rcx,%r13,4), %rcx
cmpq %rcx, 0x50(%rsp)
jne 0x798de
cmpq %r13, %rsi
jbe 0x7a18a
leaq (,%r13,8), %r14
addq %r13, %r14
movups 0x8(%rax,%r14,8), %xmm0
movaps %xmm0, 0x160(%rsp)
movsd 0x18(%rax,%r14,8), %xmm0
movsd %xmm0, 0x170(%rsp)
movsd 0x38(%rax,%r14,8), %xmm0
mulsd 0xd8b3c(%rip), %xmm0    # 0x1521d0
movsd %xmm0, 0x178(%rsp)
movq 0x38(%rsp), %rax
subq 0x30(%rsp), %rax
shlq $0x1b, %rax
testq %rax, %rax
jle 0x7989a
xorl %r12d, %r12d
xorl %ebx, %ebx
xorpd %xmm0, %xmm0
xorpd %xmm1, %xmm1
xorpd %xmm2, %xmm2
leaq 0x80(%rsp), %rdi
callq 0x83f68
movq (%r15), %rax
movq 0x8(%r15), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
movabsq $-0x71c71c71c71c71c7, %rcx # imm = 0x8E38E38E38E38E39
imulq %rcx, %rdx
cmpq %r13, %rdx
jbe 0x7a16f
movsd 0x8(%rax,%r14,8), %xmm0
movsd %xmm0, 0x18(%rsp)
leaq 0x80(%rsp), %rdi
xorl %esi, %esi
callq 0x83f9a
movsd 0x18(%rsp), %xmm0
movsd %xmm0, (%rax)
movq (%r15), %rax
movq 0x8(%r15), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
movabsq $-0x71c71c71c71c71c7, %rcx # imm = 0x8E38E38E38E38E39
imulq %rcx, %rdx
cmpq %r13, %rdx
jbe 0x7a16f
movsd 0x10(%rax,%r14,8), %xmm0
movsd %xmm0, 0x18(%rsp)
leaq 0x80(%rsp), %rdi
movl $0x1, %esi
callq 0x83f9a
movsd 0x18(%rsp), %xmm0
movsd %xmm0, (%rax)
movq (%r15), %rax
movq 0x8(%r15), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
movabsq $-0x71c71c71c71c71c7, %rcx # imm = 0x8E38E38E38E38E39
imulq %rcx, %rdx
cmpq %r13, %rdx
jbe 0x7a16f
movsd 0x18(%rax,%r14,8), %xmm0
movsd %xmm0, 0x18(%rsp)
leaq 0x80(%rsp), %rdi
movl $0x2, %esi
callq 0x83f9a
movsd 0x18(%rsp), %xmm0
movsd %xmm0, (%rax)
movq 0x30(%rsp), %rax
movsd (%rax,%r12), %xmm0
movsd 0x8(%rax,%r12), %xmm1
movsd 0x10(%rax,%r12), %xmm2
movq 0x90(%rsp), %rax
movq %rax, 0x10(%rsp)
movupd 0x80(%rsp), %xmm3
movupd %xmm3, (%rsp)
movq %rbp, %rdi
movq 0x48(%rsp), %rsi
callq 0x53bfe
movq %rbp, %rdi
xorl %esi, %esi
callq 0x83f9a
movsd (%rax), %xmm0
movsd %xmm0, 0x18(%rsp)
movq %rbp, %rdi
movl $0x1, %esi
callq 0x83f9a
movsd (%rax), %xmm0
movsd %xmm0, 0x20(%rsp)
movq %rbp, %rdi
movl $0x2, %esi
callq 0x83f9a
movsd (%rax), %xmm2
movq 0x30(%rsp), %rax
movsd (%rax,%r12), %xmm3
movsd 0x8(%rax,%r12), %xmm4
movsd 0x10(%rax,%r12), %xmm5
movsd 0x18(%rsp), %xmm0
movsd 0x20(%rsp), %xmm1
callq 0x84cbb
movq 0x30(%rsp), %rax
movsd 0x18(%rax,%r12), %xmm1
addsd 0x178(%rsp), %xmm1
ucomisd %xmm0, %xmm1
ja 0x798de
incq %rbx
movq 0x38(%rsp), %rcx
subq %rax, %rcx
shrq $0x5, %rcx
movslq %ecx, %rax
addq $0x20, %r12
cmpq %rax, %rbx
jl 0x796b9
movq 0x68(%rsp), %rsi
cmpq 0x70(%rsp), %rsi
je 0x798cc
movapd 0x160(%rsp), %xmm0
movapd 0x170(%rsp), %xmm1
movupd %xmm1, 0x10(%rsi)
movupd %xmm0, (%rsi)
addq $0x20, %rsi
movq %rsi, 0x68(%rsp)
jmp 0x798de
leaq 0x60(%rsp), %rdi
leaq 0x160(%rsp), %rdx
callq 0x499ba
incq %r13
movq (%r15), %rax
movq 0x8(%r15), %rcx
movq %rcx, %rsi
subq %rax, %rsi
sarq $0x3, %rsi
movabsq $-0x71c71c71c71c71c7, %rdx # imm = 0x8E38E38E38E38E39
imulq %rdx, %rsi
movslq %esi, %rdx
cmpq %rdx, %r13
jl 0x79628
movq 0xa0(%rsp), %rdx
movq 0x50(%rsp), %r8
incq %r8
movq 0xa8(%rsp), %rsi
subq %rdx, %rsi
shrq $0x2, %rsi
movslq %esi, %rsi
movq %r8, 0x50(%rsp)
cmpq %rsi, %r8
jl 0x79605
movq 0x11b67d(%rip), %rdi    # 0x194fc0
leaq 0xdb5f5(%rip), %rsi     # 0x154f3f
movl $0x1d, %edx
callq 0x44e0
movq 0x68(%rsp), %rsi
subq 0x60(%rsp), %rsi
sarq $0x5, %rsi
movq 0x11b657(%rip), %rdi    # 0x194fc0
callq 0x42b0
movq %rax, %rbx
leaq 0xdb5e5(%rip), %rsi     # 0x154f5d
movl $0xd, %edx
movq %rax, %rdi
callq 0x44e0
movq 0x8(%r15), %rsi
subq (%r15), %rsi
sarq $0x3, %rsi
movabsq $-0x71c71c71c71c71c7, %rax # imm = 0x8E38E38E38E38E39
imulq %rax, %rsi
movq %rbx, %rdi
callq 0x42b0
movq %rax, %rbx
leaq 0xdb5bb(%rip), %rsi     # 0x154f6b
movl $0x8, %edx
movq %rax, %rdi
callq 0x44e0
leaq 0xd9c5a(%rip), %rsi     # 0x15361e
movl $0x1, %edx
movq %rbx, %rdi
callq 0x44e0
leaq 0x80(%rsp), %rdx
movq $0x0, (%rdx)
leaq 0xc0(%rsp), %rdi
movl $0x1, %esi
callq 0x48ca6
leaq 0x80(%rsp), %rdx
movq $0x0, (%rdx)
leaq 0xe0(%rsp), %rdi
movl $0x1, %esi
callq 0x48ca6
movq 0x30(%rsp), %rax
movq 0x38(%rsp), %rcx
subq %rax, %rcx
shrq $0x5, %rcx
movslq %ecx, %rdx
testq %rdx, %rdx
movq 0x48(%rsp), %r14
jle 0x79a4c
leaq 0x18(%rax), %rsi
xorpd %xmm0, %xmm0
movsd (%rsi), %xmm1
ucomisd %xmm0, %xmm1
ja 0x79a60
addq $0x20, %rsi
decq %rdx
jne 0x79a39
movq 0xc0(%rsp), %rax
movq $0x0, (%rax)
jmp 0x79f9e
testl %ecx, %ecx
jle 0x79f9e
xorl %r13d, %r13d
leaq 0x100(%rsp), %r15
leaq 0x148(%rsp), %rbp
movq %r13, %rbx
shlq $0x5, %rbx
movsd 0x18(%rax,%rbx), %xmm0
ucomisd 0xd78c0(%rip), %xmm0    # 0x151350
movl $0x0, 0x2c(%rsp)
movl $0x0, 0x28(%rsp)
jbe 0x79ea1
xorl %r12d, %r12d
movl $0x0, 0x28(%rsp)
movl $0x0, 0x2c(%rsp)
movq %rbx, 0x128(%rsp)
callq 0x4150
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
divsd 0xd7b1b(%rip), %xmm0    # 0x1515f0
addsd %xmm0, %xmm0
mulsd 0xd7b2f(%rip), %xmm0    # 0x151610
movsd %xmm0, 0x18(%rsp)
callq 0x4150
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
divsd 0xd7b1d(%rip), %xmm0    # 0x151618
addsd %xmm0, %xmm0
addsd 0xd3551(%rip), %xmm0    # 0x14d058
movsd %xmm0, 0x130(%rsp)
callq 0x4400
movsd %xmm0, 0x20(%rsp)
callq 0x4100
movsd %xmm0, 0x58(%rsp)
movsd 0x18(%rsp), %xmm0
callq 0x4800
movsd %xmm0, 0x50(%rsp)
movsd 0x20(%rsp), %xmm0
callq 0x4100
movsd %xmm0, 0x140(%rsp)
movsd 0x18(%rsp), %xmm0
callq 0x4100
movsd %xmm0, 0x138(%rsp)
movq 0x30(%rsp), %rax
movsd (%rax,%rbx), %xmm0
movsd %xmm0, 0x20(%rsp)
movsd 0x18(%rax,%rbx), %xmm0
movsd %xmm0, 0x18(%rsp)
movq %r15, %rdi
xorl %esi, %esi
callq 0x83f9a
movsd 0x58(%rsp), %xmm0
mulsd 0x50(%rsp), %xmm0
mulsd 0x18(%rsp), %xmm0
movsd 0x20(%rsp), %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, (%rax)
movq 0x30(%rsp), %rax
movsd 0x8(%rax,%rbx), %xmm0
movsd %xmm0, 0x20(%rsp)
movq %r15, %rdi
movl $0x1, %esi
callq 0x83f9a
movsd 0x140(%rsp), %xmm0
mulsd 0x138(%rsp), %xmm0
mulsd 0x18(%rsp), %xmm0
addsd 0x20(%rsp), %xmm0
movsd %xmm0, (%rax)
movq 0x30(%rsp), %rax
movsd 0x10(%rax,%rbx), %xmm0
movsd %xmm0, 0x20(%rsp)
movq %r15, %rdi
movl $0x2, %esi
callq 0x83f9a
movsd 0x130(%rsp), %xmm0
mulsd 0x18(%rsp), %xmm0
addsd 0x20(%rsp), %xmm0
movsd %xmm0, (%rax)
movq 0x110(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x100(%rsp), %xmm0
movups %xmm0, (%rsp)
leaq 0x80(%rsp), %rdi
movq %r14, %rsi
callq 0x51c42
movq 0x90(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x80(%rsp), %xmm0
movups %xmm0, (%rsp)
movq %rbp, %rdi
movq %r14, %rsi
callq 0x53a92
movq 0x158(%rsp), %rax
movq %rax, 0x90(%rsp)
movups 0x148(%rsp), %xmm0
movaps %xmm0, 0x80(%rsp)
movq 0x90(%rsp), %rax
movq %rax, 0x10(%rsp)
movaps 0x80(%rsp), %xmm0
movups %xmm0, (%rsp)
movq %rbp, %rbx
movq %rbp, %rdi
movq %r14, %rsi
callq 0x51d04
movq 0x158(%rsp), %rax
movq %rax, 0x110(%rsp)
movupd 0x148(%rsp), %xmm0
movapd %xmm0, 0x100(%rsp)
movq 0x30(%rsp), %rax
movq 0x38(%rsp), %rcx
movq %rcx, %rdx
subq %rax, %rdx
shlq $0x1b, %rdx
movabsq $0x100000000, %rsi      # imm = 0x100000000
cmpq %rsi, %rdx
jl 0x79db2
xorl %r14d, %r14d
xorl %ebp, %ebp
cmpq %rbp, %r13
je 0x79d95
movq %r15, %rdi
xorl %esi, %esi
callq 0x83f9a
movsd (%rax), %xmm0
movsd %xmm0, 0x18(%rsp)
movq %r15, %rdi
movl $0x1, %esi
callq 0x83f9a
movsd (%rax), %xmm0
movsd %xmm0, 0x20(%rsp)
movq %r15, %rdi
movl $0x2, %esi
callq 0x83f9a
movsd (%rax), %xmm2
movq 0x30(%rsp), %rax
movsd (%rax,%r14), %xmm3
movsd 0x8(%rax,%r14), %xmm4
movsd 0x10(%rax,%r14), %xmm5
movq 0x48(%rsp), %rdi
movsd 0x18(%rsp), %xmm0
movsd 0x20(%rsp), %xmm1
callq 0x5364c
movq 0x30(%rsp), %rax
movsd 0x18(%rax,%r14), %xmm1
addsd 0xdaefa(%rip), %xmm1    # 0x154c80
ucomisd %xmm0, %xmm1
ja 0x79e81
movq 0x38(%rsp), %rcx
incq %rbp
movq %rcx, %rdx
subq %rax, %rdx
shrq $0x5, %rdx
movslq %edx, %rdx
addq $0x20, %r14
cmpq %rdx, %rbp
jl 0x79cfe
movq 0x68(%rsp), %rax
subq 0x60(%rsp), %rax
shrq $0x5, %rax
testl %eax, %eax
jle 0x79e74
xorl %r14d, %r14d
xorl %ebp, %ebp
movq %r15, %rdi
xorl %esi, %esi
callq 0x83f9a
movsd (%rax), %xmm0
movsd %xmm0, 0x18(%rsp)
movq %r15, %rdi
movl $0x1, %esi
callq 0x83f9a
movsd (%rax), %xmm0
movsd %xmm0, 0x20(%rsp)
movq %r15, %rdi
movl $0x2, %esi
callq 0x83f9a
movsd (%rax), %xmm2
movq 0x30(%rsp), %rax
movsd (%rax,%r14), %xmm3
movsd 0x8(%rax,%r14), %xmm4
movsd 0x10(%rax,%r14), %xmm5
movq 0x48(%rsp), %rdi
movsd 0x18(%rsp), %xmm0
movsd 0x20(%rsp), %xmm1
callq 0x5364c
movq 0x60(%rsp), %rax
movsd 0x18(%rax,%r14), %xmm1
ucomisd %xmm0, %xmm1
ja 0x79e69
incq %rbp
movq 0x68(%rsp), %rcx
subq %rax, %rcx
shrq $0x5, %rcx
movslq %ecx, %rax
addq $0x20, %r14
cmpq %rax, %rbp
jl 0x79dcd
xorl %eax, %eax
ucomisd %xmm0, %xmm1
setbe %al
jmp 0x79e79
movl $0x1, %eax
incl 0x2c(%rsp)
addl %eax, 0x28(%rsp)
movq 0x48(%rsp), %r14
movq %rbx, %rbp
incl %r12d
cmpl $0x1f4, %r12d           # imm = 0x1F4
movq 0x128(%rsp), %rbx
jne 0x79ac1
movl $0x8, %edx
movq 0x11b113(%rip), %rdi    # 0x194fc0
leaq 0xdb0e4(%rip), %rsi     # 0x154f98
callq 0x44e0
movq 0x11b100(%rip), %rdi    # 0x194fc0
movl 0x2c(%rsp), %esi
callq 0x4750
movq %rax, %r12
movl $0x11, %edx
movq %rax, %rdi
leaq 0xdb0c6(%rip), %rsi     # 0x154fa1
callq 0x44e0
movq %r12, %rdi
movl 0x28(%rsp), %esi
callq 0x4750
movl $0x1, %edx
movq %rax, %rdi
leaq 0xd9723(%rip), %rsi     # 0x15361e
callq 0x44e0
xorps %xmm0, %xmm0
cvtsi2sdl 0x2c(%rsp), %xmm0
movsd 0xdad77(%rip), %xmm3    # 0x154c88
divsd %xmm3, %xmm0
movsd 0xd7703(%rip), %xmm4    # 0x151620
mulsd %xmm4, %xmm0
movsd 0xd76e7(%rip), %xmm2    # 0x151610
mulsd %xmm2, %xmm0
movq 0x30(%rsp), %rax
movsd 0x18(%rax,%rbx), %xmm1
mulsd %xmm1, %xmm1
mulsd %xmm0, %xmm1
movq 0xc0(%rsp), %rcx
addsd (%rcx), %xmm1
movsd %xmm1, (%rcx)
xorps %xmm0, %xmm0
cvtsi2sdl 0x28(%rsp), %xmm0
divsd %xmm3, %xmm0
mulsd %xmm4, %xmm0
mulsd %xmm2, %xmm0
movsd 0x18(%rax,%rbx), %xmm1
mulsd %xmm1, %xmm1
mulsd %xmm0, %xmm1
movq 0xe0(%rsp), %rcx
addsd (%rcx), %xmm1
movsd %xmm1, (%rcx)
incq %r13
movq 0x38(%rsp), %rcx
subq %rax, %rcx
shrq $0x5, %rcx
movslq %ecx, %rcx
cmpq %rcx, %r13
jl 0x79a7b
movq 0x11b01b(%rip), %rbx    # 0x194fc0
leaq 0xdafc8(%rip), %rsi     # 0x154f74
movl $0xc, %edx
movq %rbx, %rdi
callq 0x44e0
movq 0x120(%rsp), %r14
testq %r14, %r14
je 0x79fe2
movq %r14, %rdi
callq 0x41e0
movq 0x11afeb(%rip), %rdi    # 0x194fc0
movq %r14, %rsi
movq %rax, %rdx
callq 0x44e0
jmp 0x79ff9
movq (%rbx), %rax
movq -0x18(%rax), %rax
leaq (%rbx,%rax), %rdi
movl 0x20(%rbx,%rax), %esi
orl $0x1, %esi
callq 0x4710
movq 0x11afc0(%rip), %rdi    # 0x194fc0
leaq 0xdaf7a(%rip), %rsi     # 0x154f81
movl $0xc, %edx
callq 0x44e0
movl 0x1e0(%rsp), %esi
movq 0x11afa1(%rip), %rdi    # 0x194fc0
callq 0x4750
leaq 0xd34b3(%rip), %rsi     # 0x14d4de
movl $0x3, %edx
movq %rax, %rdi
callq 0x44e0
movq 0xc0(%rsp), %rax
movsd (%rax), %xmm0
movq 0x11af75(%rip), %rdi    # 0x194fc0
callq 0x46b0
leaq 0xd3487(%rip), %rsi     # 0x14d4de
movl $0x3, %edx
movq %rax, %rdi
callq 0x44e0
movq 0x11af55(%rip), %rdi    # 0x194fc0
leaq 0xdaf1c(%rip), %rsi     # 0x154f8e
movl $0x9, %edx
callq 0x44e0
movq 0xe0(%rsp), %rax
movsd (%rax), %xmm0
movq 0x11af31(%rip), %rdi    # 0x194fc0
callq 0x46b0
leaq 0xd3443(%rip), %rsi     # 0x14d4de
movl $0x3, %edx
movq %rax, %rdi
callq 0x44e0
movq 0x11af11(%rip), %rdi    # 0x194fc0
leaq 0xd9568(%rip), %rsi     # 0x15361e
movl $0x1, %edx
callq 0x44e0
movq 0xc0(%rsp), %rax
movsd (%rax), %xmm0
movsd %xmm0, 0x18(%rsp)
movq 0xa0(%rsp), %rdi
testq %rdi, %rdi
je 0x7a0ef
movq 0xb0(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movq 0x60(%rsp), %rdi
testq %rdi, %rdi
je 0x7a106
movq 0x70(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x7a11d
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movq 0xe0(%rsp), %rdi
testq %rdi, %rdi
je 0x7a13a
movq 0xf0(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movq 0xc0(%rsp), %rdi
testq %rdi, %rdi
je 0x7a157
movq 0xd0(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movsd 0x18(%rsp), %xmm0
addq $0x1a8, %rsp            # imm = 0x1A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xd357f(%rip), %rdi     # 0x14d6f5
movq %r13, %rsi
xorl %eax, %eax
callq 0x4630
movq %r12, %r13
jmp 0x7a18d
movq %rdi, %r13
jmp 0x7a18d
movq %rsi, %rdx
leaq 0xd3561(%rip), %rdi     # 0x14d6f5
movq %r13, %rsi
xorl %eax, %eax
callq 0x4630
jmp 0x7a1be
jmp 0x7a1be
jmp 0x7a1be
jmp 0x7a1be
jmp 0x7a1be
jmp 0x7a1be
jmp 0x7a1be
jmp 0x7a1be
jmp 0x7a1be
jmp 0x7a1be
jmp 0x7a1be
jmp 0x7a1be
jmp 0x7a1be
jmp 0x7a1be
jmp 0x7a1be
jmp 0x7a1be
movq %rax, %rbx
movq 0xa0(%rsp), %rdi
testq %rdi, %rdi
je 0x7a1de
movq 0xb0(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movq 0x60(%rsp), %rdi
testq %rdi, %rdi
je 0x7a1f5
movq 0x70(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x7a20c
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movq 0xe0(%rsp), %rdi
testq %rdi, %rdi
je 0x7a229
movq 0xf0(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movq 0xc0(%rsp), %rdi
testq %rdi, %rdi
je 0x7a246
movq 0xd0(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movq %rbx, %rdi
callq 0x4780