// File: /workspace/github_cpp_makefile_star2_O2/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, 0x38(%rsp)
movq %rdx, %r12
movq %rsi, 0x58(%rsp)
leaq 0x100(%rsp), %rdi
xorpd %xmm0, %xmm0
xorpd %xmm1, %xmm1
xorpd %xmm2, %xmm2
callq 0x63c46
xorpd %xmm0, %xmm0
movapd %xmm0, 0xc0(%rsp)
andq $0x0, 0xd0(%rsp)
movapd %xmm0, 0xe0(%rsp)
andq $0x0, 0xf0(%rsp)
movl $0x3b4ca6f5, %edi       # imm = 0x3B4CA6F5
callq 0x4460
leaq 0x40(%rsp), %rax
andq $0x0, 0x10(%rax)
xorpd %xmm0, %xmm0
movapd %xmm0, (%rax)
andq $0x0, 0x90(%rsp)
leaq 0xa0(%rsp), %rax
andq $0x0, 0x10(%rax)
movapd %xmm0, 0x80(%rsp)
movapd %xmm0, (%rax)
xorl %r13d, %r13d
pushq $0x28
popq %r14
movl %ebx, 0x20(%rsp)
movq (%r12), %rcx
movq 0x8(%r12), %rsi
movq %rsi, %rax
subq %rcx, %rax
cqto
pushq $0x48
popq %rdi
idivq %rdi
cltq
cmpq %rax, %r13
jge 0x5ae4b
movq 0x38(%rsp), %rdi
movq %r13, %rsi
callq 0xac00
cmpl %ebx, (%rax)
jne 0x5ae43
movq %r12, %rdi
movq %r13, %rsi
callq 0xabe2
movsd 0x8(%rax), %xmm0
movsd %xmm0, 0x188(%rsp)
movq %r12, %rdi
movq %r13, %rsi
callq 0xabe2
movsd 0x10(%rax), %xmm0
movsd %xmm0, 0x190(%rsp)
movq %r12, %rdi
movq %r13, %rsi
callq 0xabe2
movsd 0x18(%rax), %xmm0
movsd %xmm0, 0x198(%rsp)
movq %r12, %rdi
movq %r13, %rsi
callq 0xabe2
movsd 0x38(%rax), %xmm0
mulsd 0xa641c(%rip), %xmm0    # 0x101140
movsd %xmm0, 0x1a0(%rsp)
leaq 0x40(%rsp), %rdi
leaq 0x188(%rsp), %rsi
callq 0x37192
xorl %ebp, %ebp
movq %r12, %rdi
movq %r13, %rsi
callq 0xabe2
movq 0x28(%rax), %rcx
subq 0x20(%rax), %rcx
movq %rcx, %rax
cqto
idivq %r14
cltq
cmpq %rax, %rbp
jge 0x5ae43
movq %r12, %rdi
movq %r13, %rsi
callq 0xabe2
addq $0x20, %rax
movq %rax, %rdi
movq %rbp, %rsi
callq 0x29efa
movslq 0x4(%rax), %rsi
movq 0x38(%rsp), %rdi
callq 0xac00
cmpl %ebx, (%rax)
je 0x5ae3b
xorl %r14d, %r14d
xorl %ebx, %ebx
movq 0xa0(%rsp), %rax
movq 0xa8(%rsp), %rcx
subq %rax, %rcx
shrq $0x2, %rcx
movslq %ecx, %rcx
cmpq %rcx, %rbx
jge 0x5adf6
movl (%rax,%rbx,4), %r15d
movq %r12, %rdi
movq %r13, %rsi
callq 0xabe2
addq $0x20, %rax
movq %rax, %rdi
movq %rbp, %rsi
callq 0x29efa
movslq 0x4(%rax), %rsi
movq 0x38(%rsp), %rdi
callq 0xac00
cmpl (%rax), %r15d
pushq $0x1
popq %rax
cmovel %eax, %r14d
incq %rbx
jmp 0x5ad9c
testl %r14d, %r14d
movl 0x20(%rsp), %ebx
pushq $0x28
popq %r14
jne 0x5ae3b
movq %r12, %rdi
movq %r13, %rsi
callq 0xabe2
addq $0x20, %rax
movq %rax, %rdi
movq %rbp, %rsi
callq 0x29efa
movslq 0x4(%rax), %rsi
movq 0x38(%rsp), %rdi
callq 0xac00
leaq 0xa0(%rsp), %rdi
movq %rax, %rsi
callq 0x9434
incq %rbp
jmp 0x5ad41
incq %r13
jmp 0x5ac8a
xorl %r14d, %r14d
leaq 0x60(%rsp), %rbx
leaq 0x150(%rsp), %r15
movq 0xa8(%rsp), %rax
subq 0xa0(%rsp), %rax
shrq $0x2, %rax
cltq
cmpq %rax, %r14
jge 0x5b0cf
xorl %r13d, %r13d
movq %r14, 0x78(%rsp)
movq %rsi, %rax
subq %rcx, %rax
cqto
pushq $0x48
popq %rdi
idivq %rdi
cltq
cmpq %rax, %r13
jge 0x5b0c7
movq 0x38(%rsp), %rdi
movq %r13, %rsi
callq 0xac00
movslq (%rax), %rax
cmpq %rax, %r14
jne 0x5b0b1
movq %r12, %rdi
movq %r13, %rsi
callq 0xabe2
movsd 0x8(%rax), %xmm0
movsd %xmm0, 0x168(%rsp)
movq %r12, %rdi
movq %r13, %rsi
callq 0xabe2
movsd 0x10(%rax), %xmm0
movsd %xmm0, 0x170(%rsp)
movq %r12, %rdi
movq %r13, %rsi
callq 0xabe2
movsd 0x18(%rax), %xmm0
movsd %xmm0, 0x178(%rsp)
movq %r12, %rdi
movq %r13, %rsi
callq 0xabe2
movsd 0x38(%rax), %xmm0
mulsd 0xa6229(%rip), %xmm0    # 0x101140
movsd %xmm0, 0x180(%rsp)
movq 0x40(%rsp), %rax
pushq $-0x1
popq %rbp
xorl %r14d, %r14d
movq 0x48(%rsp), %rcx
subq %rax, %rcx
shrq $0x5, %rcx
movslq %ecx, %rax
incq %rbp
cmpq %rax, %rbp
jge 0x5b09c
xorpd %xmm0, %xmm0
xorpd %xmm1, %xmm1
xorpd %xmm2, %xmm2
movq %rbx, %rdi
callq 0x63c46
movq %r12, %rdi
movq %r13, %rsi
callq 0xabe2
movsd 0x8(%rax), %xmm0
movsd %xmm0, 0x20(%rsp)
movq %rbx, %rdi
xorl %esi, %esi
callq 0x63c78
movsd 0x20(%rsp), %xmm0
movsd %xmm0, (%rax)
movq %r12, %rdi
movq %r13, %rsi
callq 0xabe2
movsd 0x10(%rax), %xmm0
movsd %xmm0, 0x20(%rsp)
movq %rbx, %rdi
pushq $0x1
popq %rsi
callq 0x63c78
movsd 0x20(%rsp), %xmm0
movsd %xmm0, (%rax)
movq %r12, %rdi
movq %r13, %rsi
callq 0xabe2
movsd 0x18(%rax), %xmm0
movsd %xmm0, 0x20(%rsp)
movq %rbx, %rdi
pushq $0x2
popq %rsi
callq 0x63c78
movsd 0x20(%rsp), %xmm0
movsd %xmm0, (%rax)
movq 0x40(%rsp), %rax
movsd (%rax,%r14), %xmm0
movsd 0x8(%rax,%r14), %xmm1
movsd 0x10(%rax,%r14), %xmm2
movq 0x70(%rsp), %rax
movq %rax, 0x10(%rsp)
movupd 0x60(%rsp), %xmm3
movupd %xmm3, (%rsp)
movq %r15, %rdi
movq 0x58(%rsp), %rsi
callq 0x3fa72
movq %r15, %rdi
xorl %esi, %esi
callq 0x63c78
movsd (%rax), %xmm0
movsd %xmm0, 0x20(%rsp)
movq %r15, %rdi
pushq $0x1
popq %rsi
callq 0x63c78
movsd (%rax), %xmm0
movsd %xmm0, 0x28(%rsp)
movq %r15, %rdi
pushq $0x2
popq %rsi
callq 0x63c78
movsd (%rax), %xmm2
movq 0x40(%rsp), %rax
movsd (%rax,%r14), %xmm3
movsd 0x8(%rax,%r14), %xmm4
movsd 0x10(%rax,%r14), %xmm5
movsd 0x20(%rsp), %xmm0
movsd 0x28(%rsp), %xmm1
callq 0x64934
movq 0x40(%rsp), %rax
movsd 0x18(%rax,%r14), %xmm1
addq $0x20, %r14
addsd 0x180(%rsp), %xmm1
ucomisd %xmm0, %xmm1
jbe 0x5af2b
jmp 0x5b0b1
leaq 0x80(%rsp), %rdi
leaq 0x168(%rsp), %rsi
callq 0x37192
incq %r13
movq (%r12), %rcx
movq 0x8(%r12), %rsi
movq 0x78(%rsp), %r14
jmp 0x5ae82
incq %r14
jmp 0x5ae5b
movq 0xf4eea(%rip), %rdi     # 0x14ffc0
leaq 0xa8dba(%rip), %rsi     # 0x103e97
callq 0x4480
movq 0x88(%rsp), %rsi
subq 0x80(%rsp), %rsi
sarq $0x5, %rsi
movq %rax, %rdi
callq 0x42e0
leaq 0xa8db0(%rip), %rsi     # 0x103eb5
movq %rax, %rdi
callq 0x4480
movq %rax, %rdi
movq 0x8(%r12), %rax
subq (%r12), %rax
cqto
pushq $0x48
popq %rcx
idivq %rcx
movq %rax, %rsi
callq 0x42e0
leaq 0xa8d93(%rip), %rsi     # 0x103ec3
movq %rax, %rdi
callq 0x4480
leaq 0xa743f(%rip), %rsi     # 0x10257e
movq %rax, %rdi
callq 0x4480
leaq 0x60(%rsp), %rdx
andq $0x0, (%rdx)
leaq 0xc0(%rsp), %rdi
pushq $0x1
popq %rsi
callq 0x3713c
leaq 0x60(%rsp), %rdx
andq $0x0, (%rdx)
leaq 0xe0(%rsp), %rdi
pushq $0x1
popq %rsi
callq 0x3713c
movq 0x40(%rsp), %rax
movq 0x48(%rsp), %rcx
movq %rcx, %rdx
subq %rax, %rdx
shrq $0x5, %rdx
movslq %edx, %rdx
xorl %esi, %esi
testq %rdx, %rdx
cmovleq %rsi, %rdx
shlq $0x5, %rdx
addq $0x20, %rdx
xorpd %xmm0, %xmm0
leaq 0x20(%rsi), %rdi
cmpq %rdi, %rdx
je 0x5b6bf
movsd 0x18(%rax,%rsi), %xmm1
ucomisd %xmm0, %xmm1
movq %rdi, %rsi
jbe 0x5b1a5
xorl %r15d, %r15d
leaq 0x100(%rsp), %r12
pushq $0x2
popq %r13
xorl %ebp, %ebp
subq %rax, %rcx
shrq $0x5, %rcx
movslq %ecx, %rcx
cmpq %rcx, %rbp
jge 0x5b6cb
movq %rbp, %rcx
shlq $0x5, %rcx
movq %rcx, 0x98(%rsp)
movsd 0x18(%rax,%rcx), %xmm0
movl $0x0, 0x34(%rsp)
ucomisd 0xa50d6(%rip), %xmm0    # 0x1002e0
movl $0x0, 0x30(%rsp)
jbe 0x5b5e0
movl $0x0, 0x34(%rsp)
movl $0x0, 0x30(%rsp)
xorl %eax, %eax
movq %rbp, 0x128(%rsp)
movl %eax, 0x38(%rsp)
cmpl $0x1f4, %eax            # imm = 0x1F4
je 0x5b5e0
callq 0x4170
cvtsi2sd %eax, %xmm0
divsd 0xa532e(%rip), %xmm0    # 0x100580
addsd %xmm0, %xmm0
mulsd 0xa5352(%rip), %xmm0    # 0x1005b0
movsd %xmm0, 0x20(%rsp)
callq 0x4170
cvtsi2sd %eax, %xmm0
divsd 0xa5343(%rip), %xmm0    # 0x1005b8
addsd %xmm0, %xmm0
addsd 0xa0dd7(%rip), %xmm0    # 0xfc058
movsd %xmm0, 0x130(%rsp)
callq 0x4450
movsd %xmm0, 0x28(%rsp)
callq 0x4110
movsd %xmm0, 0x78(%rsp)
movsd 0x20(%rsp), %xmm0
callq 0x47e0
movsd %xmm0, 0x148(%rsp)
movsd 0x28(%rsp), %xmm0
callq 0x4110
movsd %xmm0, 0x140(%rsp)
movsd 0x20(%rsp), %xmm0
callq 0x4110
movsd %xmm0, 0x138(%rsp)
movq 0x40(%rsp), %rax
movq 0x98(%rsp), %rbx
movsd (%rax,%rbx), %xmm0
movsd %xmm0, 0x28(%rsp)
movsd 0x18(%rax,%rbx), %xmm0
movsd %xmm0, 0x20(%rsp)
movq %r12, %rdi
xorl %esi, %esi
callq 0x63c78
movsd 0x78(%rsp), %xmm0
mulsd 0x148(%rsp), %xmm0
mulsd 0x20(%rsp), %xmm0
movsd 0x28(%rsp), %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, (%rax)
movq 0x40(%rsp), %rax
movsd 0x8(%rax,%rbx), %xmm0
movsd %xmm0, 0x28(%rsp)
movq %r12, %rdi
pushq $0x1
popq %rsi
callq 0x63c78
movsd 0x140(%rsp), %xmm0
mulsd 0x138(%rsp), %xmm0
mulsd 0x20(%rsp), %xmm0
addsd 0x28(%rsp), %xmm0
movsd %xmm0, (%rax)
movq 0x40(%rsp), %rax
movsd 0x10(%rax,%rbx), %xmm0
movsd %xmm0, 0x28(%rsp)
movq %r12, %rdi
movl %r13d, %esi
callq 0x63c78
movsd 0x130(%rsp), %xmm0
mulsd 0x20(%rsp), %xmm0
addsd 0x28(%rsp), %xmm0
movsd %xmm0, (%rax)
movq 0x110(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x100(%rsp), %xmm0
movups %xmm0, (%rsp)
leaq 0x60(%rsp), %rdi
movq 0x58(%rsp), %rbx
movq %rbx, %rsi
callq 0x3e4c8
movq 0x70(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x60(%rsp), %xmm0
movups %xmm0, (%rsp)
leaq 0x150(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x3f94a
movq 0x160(%rsp), %rax
movq %rax, 0x70(%rsp)
movups 0x150(%rsp), %xmm0
movaps %xmm0, 0x60(%rsp)
movq 0x70(%rsp), %rax
movq %rax, 0x10(%rsp)
movaps 0x60(%rsp), %xmm0
movups %xmm0, (%rsp)
movq %r14, %rdi
movq %rbx, %rsi
callq 0x3e536
movq 0x160(%rsp), %rax
movq %rax, 0x110(%rsp)
movupd 0x150(%rsp), %xmm0
movapd %xmm0, 0x100(%rsp)
movq 0x40(%rsp), %rax
xorl %r14d, %r14d
xorl %ebx, %ebx
movq 0x48(%rsp), %rcx
subq %rax, %rcx
shrq $0x5, %rcx
movslq %ecx, %rcx
cmpq %rcx, %rbx
jge 0x5b507
cmpq %r14, %r15
je 0x5b4fb
movq %r12, %rdi
xorl %esi, %esi
callq 0x63c78
movsd (%rax), %xmm0
movsd %xmm0, 0x20(%rsp)
movq %r12, %rdi
pushq $0x1
popq %rsi
callq 0x63c78
movsd (%rax), %xmm0
movsd %xmm0, 0x28(%rsp)
movq %r12, %rdi
movl %r13d, %esi
callq 0x63c78
movsd (%rax), %xmm2
movq 0x40(%rsp), %rax
movsd (%rax,%r14), %xmm3
movsd 0x8(%rax,%r14), %xmm4
movsd 0x10(%rax,%r14), %xmm5
movq 0x58(%rsp), %rdi
movsd 0x20(%rsp), %xmm0
movsd 0x28(%rsp), %xmm1
callq 0x3f636
movq 0x40(%rsp), %rax
movsd 0x18(%rax,%r14), %xmm1
addsd 0xa86e7(%rip), %xmm1    # 0x103bd8
ucomisd %xmm0, %xmm1
ja 0x5b5d5
incq %rbx
addq $0x20, %r14
jmp 0x5b455
setge %al
movzbl %al, %eax
addl %eax, 0x34(%rsp)
movq 0x80(%rsp), %rax
pushq $-0x1
popq %rbx
xorl %r14d, %r14d
movq 0x88(%rsp), %rcx
subq %rax, %rcx
shrq $0x5, %rcx
movslq %ecx, %rbp
incq %rbx
cmpq %rbp, %rbx
jge 0x5b5c1
movq %r12, %rdi
xorl %esi, %esi
callq 0x63c78
movsd (%rax), %xmm0
movsd %xmm0, 0x20(%rsp)
movq %r12, %rdi
pushq $0x1
popq %rsi
callq 0x63c78
movsd (%rax), %xmm0
movsd %xmm0, 0x28(%rsp)
movq %r12, %rdi
movl %r13d, %esi
callq 0x63c78
movsd (%rax), %xmm2
movq 0x40(%rsp), %rax
movsd (%rax,%r14), %xmm3
movsd 0x8(%rax,%r14), %xmm4
movsd 0x10(%rax,%r14), %xmm5
movq 0x58(%rsp), %rdi
movsd 0x20(%rsp), %xmm0
movsd 0x28(%rsp), %xmm1
callq 0x3f636
movq 0x80(%rsp), %rax
movsd 0x18(%rax,%r14), %xmm1
addq $0x20, %r14
ucomisd %xmm0, %xmm1
jbe 0x5b51f
xorl %eax, %eax
cmpq %rbp, %rbx
setge %al
addl %eax, 0x30(%rsp)
movq 0x128(%rsp), %rbp
movl 0x38(%rsp), %eax
incl %eax
jmp 0x5b232
movq 0xf49d9(%rip), %rdi     # 0x14ffc0
leaq 0xa8902(%rip), %rsi     # 0x103ef0
callq 0x4480
movq %rax, %rdi
movl 0x34(%rsp), %esi
callq 0x4760
movq %rax, %rdi
leaq 0xa88f0(%rip), %rsi     # 0x103ef9
callq 0x4480
movq %rax, %rdi
movl 0x30(%rsp), %esi
callq 0x4760
movq %rax, %rdi
leaq 0xa6f5a(%rip), %rsi     # 0x10257e
callq 0x4480
cvtsi2sdl 0x34(%rsp), %xmm0
movsd 0xa85a9(%rip), %xmm3    # 0x103be0
divsd %xmm3, %xmm0
movsd 0xa4f65(%rip), %xmm4    # 0x1005a8
mulsd %xmm4, %xmm0
movsd 0xa4f61(%rip), %xmm2    # 0x1005b0
mulsd %xmm2, %xmm0
movq 0x40(%rsp), %rax
movq 0x98(%rsp), %rdx
movsd 0x18(%rax,%rdx), %xmm1
mulsd %xmm1, %xmm1
mulsd %xmm0, %xmm1
movq 0xc0(%rsp), %rcx
addsd (%rcx), %xmm1
movsd %xmm1, (%rcx)
cvtsi2sdl 0x30(%rsp), %xmm0
divsd %xmm3, %xmm0
mulsd %xmm4, %xmm0
mulsd %xmm2, %xmm0
movsd 0x18(%rax,%rdx), %xmm1
mulsd %xmm1, %xmm1
mulsd %xmm0, %xmm1
movq 0xe0(%rsp), %rcx
addsd (%rcx), %xmm1
movsd %xmm1, (%rcx)
incq %rbp
movq 0x48(%rsp), %rcx
addq $0x20, %r15
jmp 0x5b1d2
movq 0xc0(%rsp), %rax
andq $0x0, (%rax)
movq 0xf48ee(%rip), %rdi     # 0x14ffc0
leaq 0xa87f3(%rip), %rsi     # 0x103ecc
callq 0x4480
movq %rax, %rdi
movq 0x120(%rsp), %rsi
callq 0x4480
leaq 0xa87e4(%rip), %rsi     # 0x103ed9
movq %rax, %rdi
callq 0x4480
movq %rax, %rdi
movl 0x1e0(%rsp), %esi
callq 0x4760
leaq 0xa0dbb(%rip), %rsi     # 0xfc4ce
movq %rax, %rdi
callq 0x4480
movq 0xc0(%rsp), %rax
movsd (%rax), %xmm0
movq 0xf4892(%rip), %rdi     # 0x14ffc0
callq 0x46c0
leaq 0xa0d94(%rip), %rsi     # 0xfc4ce
movq %rax, %rdi
callq 0x4480
movq 0xf4877(%rip), %rdi     # 0x14ffc0
leaq 0xa8796(%rip), %rsi     # 0x103ee6
callq 0x4480
movq 0xe0(%rsp), %rax
movsd (%rax), %xmm0
movq 0xf4858(%rip), %rdi     # 0x14ffc0
callq 0x46c0
leaq 0xa0d5a(%rip), %rsi     # 0xfc4ce
movq %rax, %rdi
callq 0x4480
movq 0xf483d(%rip), %rdi     # 0x14ffc0
leaq 0xa6df4(%rip), %rsi     # 0x10257e
callq 0x4480
leaq 0xc0(%rsp), %rbx
movq (%rbx), %rax
movsd (%rax), %xmm0
movsd %xmm0, 0x20(%rsp)
leaq 0xa0(%rsp), %rdi
callq 0xb290
leaq 0x80(%rsp), %rdi
callq 0x3796e
leaq 0x40(%rsp), %rdi
callq 0x3796e
leaq 0xe0(%rsp), %rdi
callq 0xb25c
movq %rbx, %rdi
callq 0xb25c
movsd 0x20(%rsp), %xmm0
addq $0x1a8, %rsp            # imm = 0x1A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x5b819
jmp 0x5b819
jmp 0x5b819
jmp 0x5b819
jmp 0x5b819
jmp 0x5b819
jmp 0x5b819
jmp 0x5b819
jmp 0x5b819
jmp 0x5b819
jmp 0x5b819
jmp 0x5b819
jmp 0x5b819
jmp 0x5b819
jmp 0x5b819
jmp 0x5b819
jmp 0x5b819
jmp 0x5b819
movq %rax, %rbx
leaq 0xa0(%rsp), %rdi
callq 0xb290
leaq 0x80(%rsp), %rdi
callq 0x3796e
leaq 0x40(%rsp), %rdi
callq 0x3796e
leaq 0xe0(%rsp), %rdi
callq 0xb25c
leaq 0xc0(%rsp), %rdi
callq 0xb25c
movq %rbx, %rdi
callq 0x4780