// File: /workspace/github_cpp_makefile_star2_O1/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 $0x198, %rsp            # imm = 0x198
movq %r9, 0x108(%rsp)
movl %r8d, %ebp
movq %rcx, 0x58(%rsp)
movq %rdx, %r14
movq %rsi, 0xb8(%rsp)
leaq 0x130(%rsp), %rdi
xorpd %xmm0, %xmm0
xorpd %xmm1, %xmm1
xorpd %xmm2, %xmm2
callq 0x85436
xorl %ebx, %ebx
movq %rbx, 0xe0(%rsp)
xorpd %xmm0, %xmm0
movapd %xmm0, 0xd0(%rsp)
movq %rbx, 0x100(%rsp)
movapd %xmm0, 0xf0(%rsp)
movl $0x3b4ca6f5, %edi       # imm = 0x3B4CA6F5
callq 0x4410
movq %rbx, 0x40(%rsp)
xorpd %xmm0, %xmm0
movapd %xmm0, 0x30(%rsp)
movq %rbx, 0x70(%rsp)
movapd %xmm0, 0x60(%rsp)
movq %rbx, 0xb0(%rsp)
movapd %xmm0, 0xa0(%rsp)
movq (%r14), %rax
movq %r14, 0x18(%rsp)
movq 0x8(%r14), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
movabsq $-0x71c71c71c71c71c7, %r15 # imm = 0x8E38E38E38E38E39
imulq %r15, %rcx
testl %ecx, %ecx
jle 0x7a60d
xorl %r13d, %r13d
movl $0x1, %r12d
movq 0x58(%rsp), %rdx
movq (%rdx), %rsi
movq 0x8(%rdx), %rdx
subq %rsi, %rdx
sarq $0x2, %rdx
cmpq %r13, %rdx
jbe 0x7b252
movq %r13, %r14
cmpl %ebp, (%rsi,%r13,4)
movabsq $-0x3333333333333333, %r15 # imm = 0xCCCCCCCCCCCCCCCD
jne 0x7a5da
movq %r14, %r13
cmpq %r14, %rcx
jbe 0x7b24f
leaq (%r13,%r13,8), %r13
movsd 0x8(%rax,%r13,8), %xmm0
movsd %xmm0, 0x178(%rsp)
movsd 0x10(%rax,%r13,8), %xmm0
movsd %xmm0, 0x180(%rsp)
movsd 0x18(%rax,%r13,8), %xmm0
movsd %xmm0, 0x188(%rsp)
movsd 0x38(%rax,%r13,8), %xmm0
mulsd 0xd9cb9(%rip), %xmm0    # 0x154120
movsd %xmm0, 0x190(%rsp)
movq 0x38(%rsp), %rsi
cmpq 0x40(%rsp), %rsi
je 0x7a4ac
movupd 0x178(%rsp), %xmm0
movupd 0x188(%rsp), %xmm1
movupd %xmm1, 0x10(%rsi)
movupd %xmm0, (%rsi)
addq $0x20, %rsi
movq %rsi, 0x38(%rsp)
movabsq $-0x71c71c71c71c71c7, %rcx # imm = 0x8E38E38E38E38E39
jmp 0x7a4c8
leaq 0x30(%rsp), %rdi
leaq 0x178(%rsp), %rdx
callq 0x49c88
movabsq $-0x71c71c71c71c71c7, %rcx # imm = 0x8E38E38E38E38E39
movq 0x18(%rsp), %rdx
movq (%rdx), %rax
movq 0x8(%rdx), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
imulq %rcx, %rdx
cmpq %r14, %rdx
jbe 0x7b240
xorl %ebx, %ebx
movq 0x20(%rax,%r13,8), %rcx
movq 0x28(%rax,%r13,8), %rdx
subq %rcx, %rdx
sarq $0x3, %rdx
imulq %r15, %rdx
movslq %edx, %rax
cmpq %rax, %rbx
jge 0x7a5da
cmpq %rbx, %rdx
jbe 0x7b245
leaq (%rbx,%rbx,4), %rax
movslq 0x4(%rcx,%rax,8), %rax
movq 0x58(%rsp), %rdx
movq (%rdx), %rcx
movq 0x8(%rdx), %rdx
subq %rcx, %rdx
sarq $0x2, %rdx
cmpq %rax, %rdx
jbe 0x7b24a
movl (%rcx,%rax,4), %edx
cmpl %ebp, %edx
je 0x7a5a8
movq 0xa0(%rsp), %rdi
movq 0xa8(%rsp), %rsi
movq %rsi, %r8
subq %rdi, %r8
shrq $0x2, %r8
movslq %r8d, %r8
testq %r8, %r8
jle 0x7a57d
xorl %r9d, %r9d
xorl %r10d, %r10d
cmpl %edx, (%rdi,%r9,4)
cmovel %r12d, %r10d
incq %r9
cmpq %r9, %r8
jne 0x7a568
testl %r10d, %r10d
jne 0x7a5a8
cmpq 0xb0(%rsp), %rsi
je 0x7a597
movl %edx, (%rsi)
addq $0x4, %rsi
movq %rsi, 0xa8(%rsp)
jmp 0x7a5a8
leaq (%rcx,%rax,4), %rdx
leaq 0xa0(%rsp), %rdi
callq 0xf7b4
incq %rbx
movq 0x18(%rsp), %rcx
movq (%rcx), %rax
movq 0x8(%rcx), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
movabsq $-0x71c71c71c71c71c7, %rcx # imm = 0x8E38E38E38E38E39
imulq %rcx, %rdx
cmpq %r14, %rdx
ja 0x7a4ea
jmp 0x7b240
movq %r14, %r13
incq %r13
movq 0x18(%rsp), %rcx
movq (%rcx), %rax
movq 0x8(%rcx), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
movabsq $-0x71c71c71c71c71c7, %r15 # imm = 0x8E38E38E38E38E39
imulq %r15, %rcx
movslq %ecx, %rdx
cmpq %rdx, %r13
jl 0x7a3e4
movq 0xa8(%rsp), %rax
subq 0xa0(%rsp), %rax
shlq $0x1e, %rax
testq %rax, %rax
jle 0x7a99a
xorl %ebx, %ebx
movq 0x18(%rsp), %rcx
movq (%rcx), %rax
movq 0x8(%rcx), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
imulq %r15, %rcx
testl %ecx, %ecx
jle 0x7a978
xorl %r13d, %r13d
movq %rbx, 0xc0(%rsp)
movq 0x58(%rsp), %rdx
movq (%rdx), %rsi
movq 0x8(%rdx), %rdx
subq %rsi, %rdx
sarq $0x2, %rdx
cmpq %r13, %rdx
jbe 0x7b252
movslq (%rsi,%r13,4), %rdx
cmpq %rdx, %rbx
jne 0x7a952
cmpq %r13, %rcx
jbe 0x7b24f
leaq (,%r13,8), %r14
addq %r13, %r14
movsd 0x8(%rax,%r14,8), %xmm0
movsd %xmm0, 0x158(%rsp)
movsd 0x10(%rax,%r14,8), %xmm0
movsd %xmm0, 0x160(%rsp)
movsd 0x18(%rax,%r14,8), %xmm0
movsd %xmm0, 0x168(%rsp)
movsd 0x38(%rax,%r14,8), %xmm0
mulsd 0xd9a4e(%rip), %xmm0    # 0x154120
movsd %xmm0, 0x170(%rsp)
movq 0x38(%rsp), %rax
subq 0x30(%rsp), %rax
shlq $0x1b, %rax
testq %rax, %rax
jle 0x7a90e
movq %r13, 0x20(%rsp)
xorl %r12d, %r12d
xorl %ebp, %ebp
xorl %r13d, %r13d
xorpd %xmm0, %xmm0
xorpd %xmm1, %xmm1
xorpd %xmm2, %xmm2
leaq 0x80(%rsp), %rdi
callq 0x85436
movq 0x18(%rsp), %rcx
movq (%rcx), %rax
movq 0x8(%rcx), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
imulq %r15, %rdx
cmpq 0x20(%rsp), %rdx
jbe 0x7b22d
movsd 0x8(%rax,%r14,8), %xmm0
movsd %xmm0, 0x28(%rsp)
leaq 0x80(%rsp), %rdi
xorl %esi, %esi
callq 0x85478
movsd 0x28(%rsp), %xmm0
movsd %xmm0, (%rax)
movq 0x18(%rsp), %rcx
movq (%rcx), %rax
movq 0x8(%rcx), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
imulq %r15, %rdx
cmpq 0x20(%rsp), %rdx
jbe 0x7b22d
movsd 0x10(%rax,%r14,8), %xmm0
movsd %xmm0, 0x28(%rsp)
leaq 0x80(%rsp), %rdi
movl $0x1, %esi
callq 0x85478
movsd 0x28(%rsp), %xmm0
movsd %xmm0, (%rax)
movq 0x18(%rsp), %rcx
movq (%rcx), %rax
movq 0x8(%rcx), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
imulq %r15, %rdx
cmpq 0x20(%rsp), %rdx
jbe 0x7b22d
movsd 0x18(%rax,%r14,8), %xmm0
movsd %xmm0, 0x28(%rsp)
leaq 0x80(%rsp), %rdi
movl $0x2, %esi
callq 0x85478
movsd 0x28(%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)
leaq 0x118(%rsp), %rbx
movq %rbx, %rdi
movq 0xb8(%rsp), %rsi
callq 0x53efc
movq %rbx, %rdi
xorl %esi, %esi
callq 0x85478
movsd (%rax), %xmm0
movsd %xmm0, 0x28(%rsp)
leaq 0x118(%rsp), %rdi
movl $0x1, %esi
callq 0x85478
movsd (%rax), %xmm0
movsd %xmm0, 0xc8(%rsp)
leaq 0x118(%rsp), %rdi
movl $0x2, %esi
callq 0x85478
movsd (%rax), %xmm2
movq 0x30(%rsp), %rax
movsd (%rax,%r12), %xmm3
movsd 0x8(%rax,%r12), %xmm4
movsd 0x10(%rax,%r12), %xmm5
movsd 0x28(%rsp), %xmm0
movsd 0xc8(%rsp), %xmm1
callq 0x868fa
movq 0x30(%rsp), %rax
movsd 0x18(%rax,%r12), %xmm1
addsd 0x170(%rsp), %xmm1
ucomisd %xmm0, %xmm1
movl $0x1, %eax
cmoval %eax, %r13d
ja 0x7a8fc
incq %rbp
movq 0x38(%rsp), %rax
subq 0x30(%rsp), %rax
shrq $0x5, %rax
cltq
addq $0x20, %r12
cmpq %rax, %rbp
jl 0x7a6ff
testl %r13d, %r13d
movq 0x20(%rsp), %r13
movq 0xc0(%rsp), %rbx
jne 0x7a952
movq 0x68(%rsp), %rsi
cmpq 0x70(%rsp), %rsi
je 0x7a940
movupd 0x158(%rsp), %xmm0
movupd 0x168(%rsp), %xmm1
movupd %xmm1, 0x10(%rsi)
movupd %xmm0, (%rsi)
addq $0x20, %rsi
movq %rsi, 0x68(%rsp)
jmp 0x7a952
leaq 0x60(%rsp), %rdi
leaq 0x158(%rsp), %rdx
callq 0x49c88
incq %r13
movq 0x18(%rsp), %rcx
movq (%rcx), %rax
movq 0x8(%rcx), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
imulq %r15, %rcx
movslq %ecx, %rdx
cmpq %rdx, %r13
jl 0x7a656
movq 0xa8(%rsp), %rax
subq 0xa0(%rsp), %rax
incq %rbx
shrq $0x2, %rax
cltq
cmpq %rax, %rbx
jl 0x7a62c
movq 0x11c61f(%rip), %rdi    # 0x196fc0
leaq 0xdc47f(%rip), %rsi     # 0x156e27
movl $0x1d, %edx
callq 0x44e0
movq 0x108(%rsp), %r14
movq 0x68(%rsp), %rsi
subq 0x60(%rsp), %rsi
sarq $0x5, %rsi
movq 0x11c5f1(%rip), %rdi    # 0x196fc0
callq 0x42b0
movq %rax, %rbx
leaq 0xdc467(%rip), %rsi     # 0x156e45
movl $0xd, %edx
movq %rax, %rdi
callq 0x44e0
movq 0x18(%rsp), %rax
movq 0x8(%rax), %rsi
subq (%rax), %rsi
sarq $0x3, %rsi
movabsq $-0x71c71c71c71c71c7, %rax # imm = 0x8E38E38E38E38E39
imulq %rax, %rsi
movq %rbx, %rdi
callq 0x42b0
movq %rax, %rbx
leaq 0xdc438(%rip), %rsi     # 0x156e53
movl $0x8, %edx
movq %rax, %rdi
callq 0x44e0
leaq 0xdaaff(%rip), %rsi     # 0x15552e
movl $0x1, %edx
movq %rbx, %rdi
callq 0x44e0
leaq 0x80(%rsp), %rdx
movq $0x0, (%rdx)
leaq 0xd0(%rsp), %rdi
movl $0x1, %esi
callq 0x49580
leaq 0x80(%rsp), %rdx
movq $0x0, (%rdx)
leaq 0xf0(%rsp), %rdi
movl $0x1, %esi
callq 0x49580
movq 0x30(%rsp), %rax
movq 0x38(%rsp), %rcx
subq %rax, %rcx
shrq $0x5, %rcx
movslq %ecx, %rcx
testq %rcx, %rcx
jle 0x7aab2
addq $0x18, %rax
xorpd %xmm0, %xmm0
movsd (%rax), %xmm1
ucomisd %xmm0, %xmm1
ja 0x7aac6
addq $0x20, %rax
decq %rcx
jne 0x7aa9f
movq 0xd0(%rsp), %rax
movq $0x0, (%rax)
jmp 0x7b064
movq 0x30(%rsp), %rax
movq 0x38(%rsp), %rcx
subq %rax, %rcx
shrq $0x5, %rcx
testl %ecx, %ecx
jle 0x7b064
xorl %r13d, %r13d
leaq 0x130(%rsp), %r15
movl $0x1, %r12d
movq %r13, %rbx
shlq $0x5, %rbx
movsd 0x18(%rax,%rbx), %xmm0
ucomisd 0xd87bb(%rip), %xmm0    # 0x1532c0
movl $0x0, 0x54(%rsp)
movl $0x0, 0x50(%rsp)
jbe 0x7af5d
xorl %ecx, %ecx
movl $0x0, 0x50(%rsp)
movl $0x0, 0x54(%rsp)
movq %rbx, 0x110(%rsp)
movl %ecx, 0x28(%rsp)
callq 0x4150
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
divsd 0xd8a13(%rip), %xmm0    # 0x153560
addsd %xmm0, %xmm0
mulsd 0xd8a27(%rip), %xmm0    # 0x153580
movsd %xmm0, 0x18(%rsp)
callq 0x4150
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
divsd 0xd8a15(%rip), %xmm0    # 0x153588
addsd %xmm0, %xmm0
addsd 0xd44d9(%rip), %xmm0    # 0x14f058
movsd %xmm0, 0x148(%rsp)
callq 0x4400
movsd %xmm0, 0x20(%rsp)
callq 0x4100
movsd %xmm0, 0xc8(%rsp)
movsd 0x18(%rsp), %xmm0
callq 0x4800
movsd %xmm0, 0x58(%rsp)
movsd 0x20(%rsp), %xmm0
callq 0x4100
movsd %xmm0, 0xc0(%rsp)
movsd 0x18(%rsp), %xmm0
callq 0x4100
movsd %xmm0, 0x150(%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 0x85478
movsd 0xc8(%rsp), %xmm0
mulsd 0x58(%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 0x85478
movsd 0xc0(%rsp), %xmm0
mulsd 0x150(%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 0x85478
movsd 0x148(%rsp), %xmm0
mulsd 0x18(%rsp), %xmm0
addsd 0x20(%rsp), %xmm0
movsd %xmm0, (%rax)
movq 0x140(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x130(%rsp), %xmm0
movups %xmm0, (%rsp)
leaq 0x80(%rsp), %rdi
movq 0xb8(%rsp), %rbx
movq %rbx, %rsi
callq 0x52082
movq 0x90(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x80(%rsp), %xmm0
movups %xmm0, (%rsp)
leaq 0x118(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x53d90
movq 0x128(%rsp), %rax
movq %rax, 0x90(%rsp)
movups 0x118(%rsp), %xmm0
movaps %xmm0, 0x80(%rsp)
movq 0x90(%rsp), %rax
movq %rax, 0x10(%rsp)
movaps 0x80(%rsp), %xmm0
movups %xmm0, (%rsp)
movq %r14, %rdi
movq %rbx, %rsi
callq 0x52144
movq 0x128(%rsp), %rax
movq %rax, 0x140(%rsp)
movupd 0x118(%rsp), %xmm0
movq 0x38(%rsp), %rax
subq 0x30(%rsp), %rax
movapd %xmm0, 0x130(%rsp)
shlq $0x1b, %rax
xorl %edx, %edx
testq %rax, %rax
jle 0x7ae3a
xorl %ebp, %ebp
xorl %ebx, %ebx
xorl %r14d, %r14d
cmpq %rbx, %r13
je 0x7ae12
movq %r15, %rdi
xorl %esi, %esi
callq 0x85478
movsd (%rax), %xmm0
movsd %xmm0, 0x18(%rsp)
movq %r15, %rdi
movl $0x1, %esi
callq 0x85478
movsd (%rax), %xmm0
movsd %xmm0, 0x20(%rsp)
movq %r15, %rdi
movl $0x2, %esi
callq 0x85478
movsd (%rax), %xmm2
movq 0x30(%rsp), %rax
movsd (%rax,%rbp), %xmm3
movsd 0x8(%rax,%rbp), %xmm4
movsd 0x10(%rax,%rbp), %xmm5
movq 0xb8(%rsp), %rdi
movsd 0x18(%rsp), %xmm0
movsd 0x20(%rsp), %xmm1
callq 0x5394a
movq 0x30(%rsp), %rax
movsd 0x18(%rax,%rbp), %xmm1
addsd 0xdbd64(%rip), %xmm1    # 0x156b68
ucomisd %xmm0, %xmm1
movzbl %r14b, %r14d
cmoval %r12d, %r14d
ja 0x7ae32
incq %rbx
movq 0x38(%rsp), %rax
subq 0x30(%rsp), %rax
shrq $0x5, %rax
cltq
addq $0x20, %rbp
cmpq %rax, %rbx
jl 0x7ad7d
andb $0x1, %r14b
xorl %edx, %edx
jmp 0x7ae3d
xorl %r14d, %r14d
testb %r14b, %r14b
movq 0x110(%rsp), %rbx
movl 0x28(%rsp), %ecx
jne 0x7af37
movq 0x68(%rsp), %rax
subq 0x60(%rsp), %rax
shrq $0x5, %rax
testl %eax, %eax
jle 0x7af2e
xorl %ebp, %ebp
xorl %r12d, %r12d
xorl %ebx, %ebx
movq %r15, %rdi
xorl %esi, %esi
callq 0x85478
movsd (%rax), %xmm0
movsd %xmm0, 0x18(%rsp)
movq %r15, %rdi
movl $0x1, %esi
callq 0x85478
movsd (%rax), %xmm0
movsd %xmm0, 0x20(%rsp)
movq %r15, %rdi
movl $0x2, %esi
callq 0x85478
movsd (%rax), %xmm2
movq 0x30(%rsp), %rax
movsd (%rax,%rbp), %xmm3
movsd 0x8(%rax,%rbp), %xmm4
movsd 0x10(%rax,%rbp), %xmm5
movq 0xb8(%rsp), %rdi
movsd 0x18(%rsp), %xmm0
movsd 0x20(%rsp), %xmm1
callq 0x5394a
movq 0x60(%rsp), %rax
movsd 0x18(%rax,%rbp), %xmm1
ucomisd %xmm0, %xmm1
movzbl %bl, %ebx
movl $0x1, %eax
cmoval %eax, %ebx
ja 0x7af16
incq %r12
movq 0x68(%rsp), %rax
subq 0x60(%rsp), %rax
shrq $0x5, %rax
cltq
addq $0x20, %rbp
cmpq %rax, %r12
jl 0x7ae6f
notb %bl
andb $0x1, %bl
movzbl %bl, %edx
movl $0x1, %r12d
movq 0x110(%rsp), %rbx
jmp 0x7af33
movl $0x1, %edx
movl 0x28(%rsp), %ecx
addl %edx, 0x50(%rsp)
xorb $0x1, %r14b
movzbl %r14b, %eax
addl %eax, 0x54(%rsp)
incl %ecx
cmpl $0x1f4, %ecx            # imm = 0x1F4
movq 0x108(%rsp), %r14
jne 0x7ab35
movl $0x8, %edx
movq 0x11c057(%rip), %rdi    # 0x196fc0
leaq 0xdbf10(%rip), %rsi     # 0x156e80
callq 0x44e0
movq 0x11c044(%rip), %rdi    # 0x196fc0
movl 0x54(%rsp), %esi
callq 0x4750
movq %rax, %rbp
movl $0x11, %edx
movq %rax, %rdi
leaq 0xdbef2(%rip), %rsi     # 0x156e89
callq 0x44e0
movq %rbp, %rdi
movl 0x50(%rsp), %esi
callq 0x4750
movl $0x1, %edx
movq %rax, %rdi
leaq 0xda577(%rip), %rsi     # 0x15552e
callq 0x44e0
xorps %xmm0, %xmm0
cvtsi2sdl 0x54(%rsp), %xmm0
movsd 0xdbba3(%rip), %xmm3    # 0x156b70
divsd %xmm3, %xmm0
movsd 0xd85b7(%rip), %xmm4    # 0x153590
mulsd %xmm4, %xmm0
movsd 0xd859b(%rip), %xmm2    # 0x153580
mulsd %xmm2, %xmm0
movq 0x30(%rsp), %rax
movsd 0x18(%rax,%rbx), %xmm1
mulsd %xmm1, %xmm1
mulsd %xmm0, %xmm1
movq 0xd0(%rsp), %rax
addsd (%rax), %xmm1
movsd %xmm1, (%rax)
xorps %xmm0, %xmm0
cvtsi2sdl 0x50(%rsp), %xmm0
divsd %xmm3, %xmm0
mulsd %xmm4, %xmm0
mulsd %xmm2, %xmm0
movq 0x30(%rsp), %rax
movsd 0x18(%rax,%rbx), %xmm1
mulsd %xmm1, %xmm1
mulsd %xmm0, %xmm1
movq 0xf0(%rsp), %rax
addsd (%rax), %xmm1
movsd %xmm1, (%rax)
incq %r13
movq 0x30(%rsp), %rax
movq 0x38(%rsp), %rcx
subq %rax, %rcx
shrq $0x5, %rcx
movslq %ecx, %rcx
cmpq %rcx, %r13
jl 0x7aaf0
movq 0x11bf55(%rip), %rbx    # 0x196fc0
leaq 0xdbdea(%rip), %rsi     # 0x156e5c
movl $0xc, %edx
movq %rbx, %rdi
callq 0x44e0
testq %r14, %r14
je 0x7b0a0
movq %r14, %rdi
callq 0x41e0
movq 0x11bf2d(%rip), %rdi    # 0x196fc0
movq %r14, %rsi
movq %rax, %rdx
callq 0x44e0
jmp 0x7b0b7
movq (%rbx), %rax
movq -0x18(%rax), %rax
leaq (%rbx,%rax), %rdi
movl 0x20(%rbx,%rax), %esi
orl $0x1, %esi
callq 0x4710
movq 0x11bf02(%rip), %rdi    # 0x196fc0
leaq 0xdbda4(%rip), %rsi     # 0x156e69
movl $0xc, %edx
callq 0x44e0
movl 0x1d0(%rsp), %esi
movq 0x11bee3(%rip), %rdi    # 0x196fc0
callq 0x4750
leaq 0xd43a5(%rip), %rsi     # 0x14f48e
movl $0x3, %edx
movq %rax, %rdi
callq 0x44e0
movq 0xd0(%rsp), %rax
movsd (%rax), %xmm0
movq 0x11beb7(%rip), %rdi    # 0x196fc0
callq 0x46b0
leaq 0xd4379(%rip), %rsi     # 0x14f48e
movl $0x3, %edx
movq %rax, %rdi
callq 0x44e0
movq 0x11be97(%rip), %rdi    # 0x196fc0
leaq 0xdbd46(%rip), %rsi     # 0x156e76
movl $0x9, %edx
callq 0x44e0
movq 0xf0(%rsp), %rax
movsd (%rax), %xmm0
movq 0x11be73(%rip), %rdi    # 0x196fc0
callq 0x46b0
leaq 0xd4335(%rip), %rsi     # 0x14f48e
movl $0x3, %edx
movq %rax, %rdi
callq 0x44e0
movq 0x11be53(%rip), %rdi    # 0x196fc0
leaq 0xda3ba(%rip), %rsi     # 0x15552e
movl $0x1, %edx
callq 0x44e0
movq 0xd0(%rsp), %rax
movsd (%rax), %xmm0
movsd %xmm0, 0x18(%rsp)
movq 0xa0(%rsp), %rdi
testq %rdi, %rdi
je 0x7b1ad
movq 0xb0(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movq 0x60(%rsp), %rdi
testq %rdi, %rdi
je 0x7b1c4
movq 0x70(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x7b1db
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movq 0xf0(%rsp), %rdi
testq %rdi, %rdi
je 0x7b1f8
movq 0x100(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movq 0xd0(%rsp), %rdi
testq %rdi, %rdi
je 0x7b215
movq 0xe0(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movsd 0x18(%rsp), %xmm0
addq $0x198, %rsp            # imm = 0x198
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xd4471(%rip), %rdi     # 0x14f6a5
movq 0x20(%rsp), %rsi
xorl %eax, %eax
callq 0x4630
movq %r14, %r13
jmp 0x7b252
movq %rbx, %r13
jmp 0x7b252
movq %rax, %r13
jmp 0x7b252
movq %rcx, %rdx
leaq 0xd444c(%rip), %rdi     # 0x14f6a5
movq %r13, %rsi
xorl %eax, %eax
callq 0x4630
jmp 0x7b283
jmp 0x7b283
jmp 0x7b283
jmp 0x7b283
jmp 0x7b283
jmp 0x7b283
jmp 0x7b283
jmp 0x7b283
jmp 0x7b283
jmp 0x7b283
jmp 0x7b283
jmp 0x7b283
jmp 0x7b283
jmp 0x7b283
jmp 0x7b283
jmp 0x7b283
movq %rax, %rbx
movq 0xa0(%rsp), %rdi
testq %rdi, %rdi
je 0x7b2a3
movq 0xb0(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movq 0x60(%rsp), %rdi
testq %rdi, %rdi
je 0x7b2ba
movq 0x70(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x7b2d1
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movq 0xf0(%rsp), %rdi
testq %rdi, %rdi
je 0x7b2ee
movq 0x100(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movq 0xd0(%rsp), %rdi
testq %rdi, %rdi
je 0x7b30b
movq 0xe0(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movq %rbx, %rdi
callq 0x4780
nop