// File: /workspace/github_cpp_makefile_star2_O1/Luthaf[P]zeopp/area_and_volume.cc
// Function: NEWcalcASA(MATERIAL*, double, int)
double NEWcalcASA(MATERIAL *Mat, double r_probe, int sampleDensity){
//numSamplesiATOM_NETWORK *hiaccatmnet, ATOM_NETWORK *orgatmnet, bool highAccuracy, double r_probe_chan, double r_probe, double rho_crystal, int numSamples, bool excludePockets, ostream &output, char *filename, bool visualize, bool VisITflag, bool LiverpoolFlag, bool ExtendedOutputFlag){


  // Inital checks
  if(!(Mat->accessAnalysis.alreadySegmentedFlag))
      {
      cerr << "Cannot run calcAV without prior accessibility analysis.\nExiting with return 0\n";
      return 0;
      }

  // Setting parameters
  Mat->ASAprobeRadius = r_probe;

  // Setting pointer to the original atom network (not one modified by -ha)
  ATOM_NETWORK *atmnet; // pointed to the analyzed (original atomsnet)
  atmnet = Mat->accessAnalysis.orgAtomNet;


  // commenting out removeOverlappedNodes() but not really sure it affects results. This function 
  // modifies the voronoi network so, if executed, may have effect on other functions, e.g. ones
  // triggered by -vol
  // accessAnalysis.removeOverlappedNodes();

  srand(randSeed);

  bool excludePockets = true; // this is default (in old version, without voro-stuff it was used)

  int numSamples; // number of samples per atom


  // inits of ASA data structures in MATERIALS class
  Mat->ASAaxsPoints.clear(); // List of accessible points to be visualized in ZeoVis/VISIT
  Mat->ASAaxsPointsChannelIDs.clear();  // corresponding channel IDs
  Mat->ASAinaxsPoints.clear(); // List of inaccessible points to be visualized in ZeoVis/VISIT
  Mat->ASAinaxsPointsPocketIDs.clear(); // corresponding pocket IDs
  Mat->ASAtotal = 0;
  Mat->ASAtotal_inaxs = 0;
  Mat->ASAnumSamples = 0;

  Mat->ASA_inChannel.clear(); Mat->ASA_inChannel.resize(Mat->accessAnalysis.n_channels,0);
  Mat->ASA_inPocket.clear(); Mat->ASA_inPocket.resize(Mat->accessAnalysis.n_pockets,0);

  //vectors that store SA contributions per atom (a pair of accessible and inaccessible)
  Mat->ASAhistogramSAperAtom.clear();


  // Sample around each of the network's atoms
  for(int i = 0; i < atmnet->numAtoms; i++){
    int count = 0;
    int count_inaxs = 0;
    // MC statistics can be collected w.r.t to identified channels and inaccessible pockets
    vector<int> count_inChannel(Mat->accessAnalysis.n_channels,0);
    vector<int> count_inPocket(Mat->accessAnalysis.n_pockets,0);

    // calculate number of samples per atom (from sample density)
    numSamples = (int)((4.0 * PI * pow((atmnet->atoms.at(i).radius + r_probe),2)) * sampleDensity);
    Mat->ASAnumSamples +=numSamples;

    for(int j = 0; j < numSamples; j++){
      bool overlaps = false;
      bool inside = false;

      // 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 *= (atmnet->atoms[i].radius + r_probe);
      ypoint *= (atmnet->atoms[i].radius + r_probe);
      zpoint *= (atmnet->atoms[i].radius + r_probe);

      // Convert (x,y,z) coordinates to ones relative to the unit cell vectors
      Point abc_coords = atmnet->xyz_to_abc(xpoint, ypoint, zpoint);

      // Transform coords relative to the atom center into ones relative to the unit cell vectors
      double newAPoint = abc_coords[0] + atmnet->atoms[i].a_coord;
      double newBPoint = abc_coords[1] + atmnet->atoms[i].b_coord;
      double newCPoint = abc_coords[2] + atmnet->atoms[i].c_coord;

      Point samplingPoint = atmnet->abc_to_xyz(newAPoint, newBPoint, newCPoint);


      // Calling accessibility object to determine accessibility of the point (this replaced a big chunk of code by Thomas)
      pair<bool,bool> answer = (Mat->accessAnalysis.isSPointInsideAtomAndNotAccessible(samplingPoint, i));
      inside = answer.first; overlaps = answer.second;
      if(Mat->accessAnalysis.needToResample() == true) j--; // the sampled point could not be analyzed in isSPointInsideAtomAndNotAccessible() function, resampling needed

      if(inside == false && excludePockets == false) overlaps = false; // if ignore inacceible pockets, treat the point as accessible (unless inside atom)


      // Store sampled points that did not overlap within atom for later visualization
      if(Mat->accessAnalysis.needToResample() == false && !inside) {
	Point abcCoords = Point(newAPoint, newBPoint, newCPoint);
//	Point coords = atmnet->abc_to_xyz(atmnet->shiftABCInUC(abcCoords)); // to be removed, new function stores fractional coordinates
        Point coords = atmnet->shiftABCInUC(abcCoords);
	if(overlaps)
          {
          count_inaxs++;
	  Mat->ASAinaxsPoints.push_back(coords);
          pair <int,int> CoP = Mat->accessAnalysis.lastChannelOrPocket();
          if(CoP.first!=-1)
            {
            cout << "Error: CoP.first!=-1 in pocket, consult source code provider\n";
            } else {
            count_inPocket[CoP.second]++;
            };
          Mat->ASAinaxsPointsPocketIDs.push_back(CoP.second);
          }
	else
          {
	  Mat->ASAaxsPoints.push_back(coords);
          count++;
          pair <int,int> CoP = Mat->accessAnalysis.lastChannelOrPocket();
          if(CoP.second!=-1)
            {
            cout << "Error: CoP.second!=-1 in channel, consult source code provider\n";
            } else {
            count_inChannel[CoP.first]++;
            };
          Mat->ASAaxsPointsChannelIDs.push_back(CoP.first);
          };
      }

//      if(accessAnalysis.needToResample() == false && !overlaps)
//        count++;
    }
   
    // SA per atom (in accessible space and in inaccessible pockets)
    double SAperAtom = (1.0*count)/numSamples * 4.0 * PI * pow((atmnet->atoms.at(i).radius + r_probe),2);
    double SAperAtom_inaxs = (1.0*count_inaxs)/numSamples * 4.0 * PI * pow((atmnet->atoms.at(i).radius + r_probe),2);

    //Increment total surface area by fraction of atom that is accessible
    Mat->ASAtotal += SAperAtom;
    //and inaccessible
    Mat->ASAtotal_inaxs += SAperAtom_inaxs;

    // SA per channel and pocket
    for(unsigned int m = 0; m < Mat->ASA_inChannel.size(); m++)
      {
      Mat->ASA_inChannel[m] += (1.0*count_inChannel[m])/numSamples * 4.0 * PI * pow((atmnet->atoms.at(i).radius + r_probe),2);
      };
    for(unsigned int m = 0; m < Mat->ASA_inPocket.size(); m++)
      {
      Mat->ASA_inPocket[m] += (1.0*count_inPocket[m])/numSamples * 4.0 * PI * pow((atmnet->atoms.at(i).radius + r_probe),2);
      };

    Mat->ASAhistogramSAperAtom.push_back(pair <double,double> (SAperAtom,SAperAtom_inaxs));

  } // ends the main ASA sampling loop (over atoms)

  // Write the necessary commands to the output stream
  // necessary to visualize the sampling

  /* Now moved to a different function */
  /*
  if(visualize){
    if(VisITflag == false)
      {
      reportPoints(output, axsPoints, inaxsPoints);
      }
    else{
      if(LiverpoolFlag == false)
        {
        //report points in std. VisIt format
        reportPointsVisIT(output, axsPoints, inaxsPoints);
        }
      else{
      //report points in Liverpool format
      vector<Point> LiverpoolAxsPoints = vector<Point> ();
      vector<Point> LiverpoolInaxsPoints = vector<Point> ();
      for(unsigned i = 0; i < axsPoints.size(); i++)
         {
         LiverpoolAxsPoints.push_back(atmnet->xyz_to_abc(axsPoints[i]));
         };
      for(unsigned j = 0; j < inaxsPoints.size(); j++)
         {
         LiverpoolInaxsPoints.push_back(atmnet->xyz_to_abc(inaxsPoints[j]));
         };
//      reportPointsVisIT(output, LiverpoolAxsPoints, LiverpoolInaxsPoints);
      reportPointsVisIT(output, LiverpoolAxsPoints, axsPointsChannelIDs, LiverpoolInaxsPoints, inaxsPointsPocketIDs);
      };
      };
    //reportResampledPoints(output, resampledInfo);
  }

  */ // ends writing vis files

  cout << "Total number of ASA MC samples = " << Mat->ASAnumSamples << "\n";
    
    // Warn user if points were resampled
  int resampleCount =  Mat->accessAnalysis.getResampleCount();
  if(resampleCount != 0){
    cerr << "\n" << "\n"
  	 << "Warning: Resampled " << resampleCount << " points out of " << Mat->ASAnumSamples
	 << "\n" << "\n"; 
  }
  return Mat->ASAtotal;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x138, %rsp            # imm = 0x138
cmpb $0x0, 0xb1d(%rdi)
je 0x4821c
movl %esi, %r15d
movq %rdi, %rbx
movsd %xmm0, 0x30(%rsp)
movsd %xmm0, 0xd40(%rdi)
movq 0x990(%rdi), %r14
movl $0x3b4ca6f5, %edi       # imm = 0x3B4CA6F5
callq 0x4410
movq 0xd60(%rbx), %rax
cmpq %rax, 0xd68(%rbx)
je 0x47851
movq %rax, 0xd68(%rbx)
movq 0xd78(%rbx), %rax
cmpq %rax, 0xd80(%rbx)
je 0x47868
movq %rax, 0xd80(%rbx)
movq 0xd90(%rbx), %rax
cmpq %rax, 0xd98(%rbx)
je 0x4787f
movq %rax, 0xd98(%rbx)
movq 0xda8(%rbx), %rax
cmpq %rax, 0xdb0(%rbx)
je 0x47896
movq %rax, 0xdb0(%rbx)
movl $0x0, 0xd48(%rbx)
leaq 0xdc0(%rbx), %rax
movq %rax, 0x70(%rsp)
xorpd %xmm0, %xmm0
movupd %xmm0, 0xd50(%rbx)
movq 0xdc0(%rbx), %rax
cmpq %rax, 0xdc8(%rbx)
je 0x478cf
movq %rax, 0xdc8(%rbx)
movslq 0xa68(%rbx), %rsi
leaq 0x90(%rsp), %rdx
movq $0x0, (%rdx)
movq 0x70(%rsp), %rdi
callq 0x49580
leaq 0xdd8(%rbx), %rax
movq %rax, 0x68(%rsp)
movq 0xdd8(%rbx), %rax
cmpq %rax, 0xde0(%rbx)
je 0x47912
movq %rax, 0xde0(%rbx)
movslq 0xa6c(%rbx), %rsi
leaq 0x90(%rsp), %rdx
movq $0x0, (%rdx)
movq 0x68(%rsp), %rdi
callq 0x49580
movq 0xdf0(%rbx), %rax
cmpq %rax, 0xdf8(%rbx)
je 0x47949
movq %rax, 0xdf8(%rbx)
cmpl $0x0, 0x110(%r14)
jle 0x4812e
leaq 0x990(%rbx), %rbp
leaq 0xd60(%rbx), %rax
movq %rax, 0x100(%rsp)
leaq 0xd78(%rbx), %rax
movq %rax, 0xf0(%rsp)
leaq 0xd90(%rbx), %rax
movq %rax, 0xf8(%rsp)
leaq 0xda8(%rbx), %rax
movq %rax, 0xe8(%rsp)
leaq 0xdf0(%rbx), %rax
movq %rax, 0xd8(%rsp)
xorps %xmm0, %xmm0
cvtsi2sd %r15d, %xmm0
movsd %xmm0, 0xe0(%rsp)
leaq 0xa8(%rsp), %rcx
xorl %r15d, %r15d
movq %rbx, 0x28(%rsp)
movslq 0xa68(%rbx), %rsi
xorl %eax, %eax
movl %eax, 0x78(%rsp)
leaq 0x90(%rsp), %rdi
leaq 0x78(%rsp), %rdx
movq %rbx, %r12
movq %rcx, %rbx
callq 0x38af6
movq %r12, %r13
movslq 0xa6c(%r12), %rsi
xorl %eax, %eax
movl %eax, 0xa8(%rsp)
leaq 0x78(%rsp), %rdi
movq %rbx, %rdx
leaq 0x108(%rsp), %rcx
callq 0x38af6
movq 0x2f0(%r14), %rax
movq 0x2f8(%r14), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
movabsq $-0x79435e50d79435e5, %r9 # imm = 0x86BCA1AF286BCA1B
imulq %r9, %rdx
cmpq %r15, %rdx
movsd 0x30(%rsp), %xmm4
jbe 0x48249
movq %r15, 0x18(%rsp)
imulq $0x98, %r15, %r15
movsd 0x30(%rax,%r15), %xmm0
addsd %xmm4, %xmm0
mulsd %xmm0, %xmm0
mulsd 0x10bb33(%rip), %xmm0   # 0x1535a0
mulsd 0xe0(%rsp), %xmm0
cvttsd2si %xmm0, %eax
addl %eax, 0xd48(%r13)
movl %eax, 0x54(%rsp)
testl %eax, %eax
jle 0x47e64
movl $0x0, 0x50(%rsp)
movl $0x0, 0x4c(%rsp)
xorl %ebx, %ebx
callq 0x4150
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
divsd 0x10baad(%rip), %xmm0   # 0x153560
addsd %xmm0, %xmm0
mulsd 0x10bac1(%rip), %xmm0   # 0x153580
movsd %xmm0, 0x40(%rsp)
callq 0x4150
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
divsd 0x10baaf(%rip), %xmm0   # 0x153588
addsd %xmm0, %xmm0
addsd 0x107573(%rip), %xmm0   # 0x14f058
movsd %xmm0, 0x58(%rsp)
callq 0x4400
movsd %xmm0, 0x60(%rsp)
callq 0x4100
movsd %xmm0, 0x38(%rsp)
movsd 0x40(%rsp), %xmm0
callq 0x4800
mulsd 0x38(%rsp), %xmm0
movsd %xmm0, 0x38(%rsp)
movsd 0x60(%rsp), %xmm0
callq 0x4100
movsd %xmm0, 0x60(%rsp)
movsd 0x40(%rsp), %xmm0
callq 0x4100
movsd 0x60(%rsp), %xmm1
mulsd %xmm0, %xmm1
movq 0x2f0(%r14), %rax
movsd 0x30(%rax,%r15), %xmm2
addsd 0x30(%rsp), %xmm2
movsd 0x38(%rsp), %xmm0
mulsd %xmm2, %xmm0
mulsd %xmm2, %xmm1
mulsd 0x58(%rsp), %xmm2
leaq 0xa8(%rsp), %r12
movq %r12, %rdi
movq %r14, %rsi
callq 0x531ea
movq %r12, %rdi
xorl %esi, %esi
callq 0x85478
movsd (%rax), %xmm0
movq 0x2f0(%r14), %rax
addsd 0x18(%rax,%r15), %xmm0
movsd %xmm0, 0x40(%rsp)
movq %r12, %rdi
movl $0x1, %esi
callq 0x85478
movsd (%rax), %xmm0
movq 0x2f0(%r14), %rax
addsd 0x20(%rax,%r15), %xmm0
movsd %xmm0, 0x58(%rsp)
movq %r12, %rdi
movl $0x2, %esi
callq 0x85478
movsd (%rax), %xmm2
movq 0x2f0(%r14), %rax
addsd 0x28(%rax,%r15), %xmm2
leaq 0x108(%rsp), %rdi
movq %r14, %rsi
movsd 0x40(%rsp), %xmm0
movsd 0x58(%rsp), %xmm1
movsd %xmm2, 0x38(%rsp)
callq 0x53092
movq 0x118(%rsp), %rax
movq %rax, 0x10(%rsp)
movupd 0x108(%rsp), %xmm0
movupd %xmm0, (%rsp)
movq %rbp, %rdi
movq 0x18(%rsp), %rsi
callq 0x97d5a
movl %eax, %r13d
movq %rbp, %rdi
callq 0x4935a
movl %eax, %r12d
movq %rbp, %rdi
callq 0x4935a
orb %r13b, %al
testb $0x1, %al
jne 0x47e2a
leaq 0x120(%rsp), %rdi
movsd 0x40(%rsp), %xmm0
movsd 0x58(%rsp), %xmm1
movsd 0x38(%rsp), %xmm2
callq 0x85436
movq 0x130(%rsp), %rax
movq %rax, 0x10(%rsp)
movupd 0x120(%rsp), %xmm0
movupd %xmm0, (%rsp)
leaq 0xc0(%rsp), %rdi
movq %r14, %rsi
callq 0x53d90
btl $0x8, %r13d
jb 0x47cd3
movq 0x28(%rsp), %rcx
movq 0xd68(%rcx), %rsi
cmpq 0xd70(%rcx), %rsi
je 0x47d0b
movq 0xd0(%rsp), %rax
movq %rax, 0x10(%rsi)
movupd 0xc0(%rsp), %xmm0
movupd %xmm0, (%rsi)
addq $0x18, 0xd68(%rcx)
jmp 0x47d20
movq 0x28(%rsp), %rcx
movq 0xd98(%rcx), %rsi
cmpq 0xda0(%rcx), %rsi
je 0x47d4e
movq 0xd0(%rsp), %rax
movq %rax, 0x10(%rsi)
movupd 0xc0(%rsp), %xmm0
movupd %xmm0, (%rsi)
addq $0x18, 0xd98(%rcx)
jmp 0x47d63
movq 0x100(%rsp), %rdi
leaq 0xc0(%rsp), %rdx
callq 0x3012c
movq %rbp, %rdi
callq 0x493cc
movq %rax, 0x20(%rsp)
cmpl $-0x1, 0x24(%rsp)
je 0x47d8f
movl $0x3f, %edx
movq 0x14f280(%rip), %rdi    # 0x196fc0
leaq 0x10b997(%rip), %rsi    # 0x1536de
callq 0x44e0
jmp 0x47d9f
movq 0xf8(%rsp), %rdi
leaq 0xc0(%rsp), %rdx
callq 0x3012c
movq %rbp, %rdi
callq 0x493cc
movq %rax, 0x20(%rsp)
cmpl $-0x1, %eax
je 0x47dc7
movl $0x3d, %edx
movq 0x14f23f(%rip), %rdi    # 0x196fc0
leaq 0x10b918(%rip), %rsi    # 0x1536a0
callq 0x44e0
jmp 0x47dd4
movslq 0x20(%rsp), %rax
movq 0x90(%rsp), %rcx
incl (%rcx,%rax,4)
movq 0x28(%rsp), %rcx
movq 0xd80(%rcx), %rsi
cmpq 0xd88(%rcx), %rsi
je 0x47dfc
movl 0x20(%rsp), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0xd80(%rcx)
jmp 0x47e0e
movslq 0x24(%rsp), %rax
movq 0x78(%rsp), %rcx
incl (%rcx,%rax,4)
movq 0x28(%rsp), %rcx
movq 0xdb0(%rcx), %rsi
cmpq 0xdb8(%rcx), %rsi
je 0x47e14
movl 0x24(%rsp), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0xdb0(%rcx)
jmp 0x47e26
movq 0xf0(%rsp), %rdi
leaq 0x20(%rsp), %rdx
callq 0xf7b4
incl 0x50(%rsp)
jmp 0x47e2a
movq 0xe8(%rsp), %rdi
leaq 0x24(%rsp), %rdx
callq 0xf7b4
incl 0x4c(%rsp)
movzbl %r12b, %eax
negl %eax
addl %eax, %ebx
incl %ebx
cmpl 0x54(%rsp), %ebx
jl 0x47a9f
xorps %xmm0, %xmm0
cvtsi2sdl 0x50(%rsp), %xmm0
cvtsi2sdl 0x4c(%rsp), %xmm3
movq 0x28(%rsp), %rbx
movsd 0x30(%rsp), %xmm4
movabsq $-0x79435e50d79435e5, %r9 # imm = 0x86BCA1AF286BCA1B
jmp 0x47e6f
movq %r13, %rbx
xorpd %xmm3, %xmm3
xorpd %xmm0, %xmm0
movq 0x2f0(%r14), %rax
movq 0x2f8(%r14), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
imulq %r9, %rdx
movq 0x18(%rsp), %rsi
cmpq %rsi, %rdx
jbe 0x4826d
xorps %xmm1, %xmm1
cvtsi2sdl 0x54(%rsp), %xmm1
divsd %xmm1, %xmm0
movsd 0x10b6e5(%rip), %xmm6   # 0x153590
mulsd %xmm6, %xmm0
movsd 0x10b6c9(%rip), %xmm5   # 0x153580
mulsd %xmm5, %xmm0
movq 0x2f0(%r14), %rcx
movq 0x2f8(%r14), %rdx
subq %rcx, %rdx
sarq $0x3, %rdx
imulq %r9, %rdx
cmpq %rsi, %rdx
jbe 0x4825a
movsd 0x30(%rax,%r15), %xmm2
addsd %xmm4, %xmm2
mulsd %xmm2, %xmm2
mulsd %xmm2, %xmm0
movq 0xdc8(%rbx), %rax
movq 0xdc0(%rbx), %rdx
divsd %xmm1, %xmm3
mulsd %xmm6, %xmm3
mulsd %xmm5, %xmm3
movsd 0x30(%rcx,%r15), %xmm2
addsd %xmm4, %xmm2
mulsd %xmm2, %xmm2
mulsd %xmm3, %xmm2
movsd 0xd50(%rbx), %xmm3
addsd %xmm0, %xmm3
movsd %xmm3, 0xd50(%rbx)
movsd 0xd58(%rbx), %xmm3
addsd %xmm2, %xmm3
movsd %xmm3, 0xd58(%rbx)
subq %rdx, %rax
je 0x47fdf
movq 0x2f0(%r14), %rsi
movq 0x2f8(%r14), %rdx
subq %rsi, %rdx
sarq $0x3, %rdx
imulq %r9, %rdx
cmpq 0x18(%rsp), %rdx
jbe 0x4828e
sarq $0x3, %rax
movq 0x90(%rsp), %rcx
leaq (%rsi,%r15), %rdx
addq $0x30, %rdx
movq 0x70(%rsp), %rsi
movq (%rsi), %rsi
xorl %edi, %edi
movsd 0x30(%rsp), %xmm5
movsd 0x10b5e2(%rip), %xmm6   # 0x153580
movsd 0x10b5ea(%rip), %xmm7   # 0x153590
xorps %xmm3, %xmm3
cvtsi2sdl (%rcx,%rdi,4), %xmm3
divsd %xmm1, %xmm3
mulsd %xmm7, %xmm3
mulsd %xmm6, %xmm3
movsd (%rdx), %xmm4
addsd %xmm5, %xmm4
mulsd %xmm4, %xmm4
mulsd %xmm3, %xmm4
addsd (%rsi,%rdi,8), %xmm4
movsd %xmm4, (%rsi,%rdi,8)
incq %rdi
movl %edi, %r8d
cmpq %r8, %rax
ja 0x47fa6
movq 0xde0(%rbx), %rax
movq 0xdd8(%rbx), %rcx
subq %rcx, %rax
je 0x48084
movq 0x2f0(%r14), %rsi
movq 0x2f8(%r14), %rdx
subq %rsi, %rdx
sarq $0x3, %rdx
imulq %r9, %rdx
cmpq 0x18(%rsp), %rdx
jbe 0x4827b
sarq $0x3, %rax
movq 0x78(%rsp), %rcx
leaq (%rsi,%r15), %rdx
addq $0x30, %rdx
movq 0x68(%rsp), %rsi
movq (%rsi), %rsi
xorl %edi, %edi
movsd 0x30(%rsp), %xmm5
movsd 0x10b53d(%rip), %xmm6   # 0x153580
movsd 0x10b545(%rip), %xmm7   # 0x153590
xorps %xmm3, %xmm3
cvtsi2sdl (%rcx,%rdi,4), %xmm3
divsd %xmm1, %xmm3
mulsd %xmm7, %xmm3
mulsd %xmm6, %xmm3
movsd (%rdx), %xmm4
addsd %xmm5, %xmm4
mulsd %xmm4, %xmm4
mulsd %xmm3, %xmm4
addsd (%rsi,%rdi,8), %xmm4
movsd %xmm4, (%rsi,%rdi,8)
incq %rdi
movl %edi, %r8d
cmpq %r8, %rax
ja 0x4804b
movsd %xmm0, 0xa8(%rsp)
movsd %xmm2, 0xb0(%rsp)
movq 0xdf8(%rbx), %rsi
cmpq 0xe00(%rbx), %rsi
je 0x480c2
movupd 0xa8(%rsp), %xmm0
movupd %xmm0, (%rsi)
addq $0x10, 0xdf8(%rbx)
movq 0x18(%rsp), %r15
jmp 0x480dc
movq 0xd8(%rsp), %rdi
leaq 0xa8(%rsp), %rdx
callq 0x49962
movq 0x18(%rsp), %r15
movq 0x78(%rsp), %rdi
testq %rdi, %rdi
je 0x480f6
movq 0x88(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movq 0x90(%rsp), %rdi
testq %rdi, %rdi
je 0x48113
movq 0xa0(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
incq %r15
movslq 0x110(%r14), %rax
cmpq %rax, %r15
leaq 0xa8(%rsp), %rcx
jl 0x479ca
leaq 0xd50(%rbx), %r12
movq 0x14ee84(%rip), %r14    # 0x196fc0
leaq 0x10be7e(%rip), %rsi    # 0x153fc1
movl $0x21, %edx
movq %r14, %rdi
callq 0x44e0
movl 0xd48(%rbx), %esi
movq %r14, %rdi
callq 0x4750
leaq 0x10d3c9(%rip), %rsi    # 0x15552e
movl $0x1, %edx
movq %rax, %rdi
callq 0x44e0
movl 0xb18(%rbx), %ebp
testl %ebp, %ebp
je 0x48214
movq 0x14ee69(%rip), %r15    # 0x196ff0
leaq 0x10d3a0(%rip), %r14    # 0x15552e
movl $0x1, %edx
movq %r15, %rdi
movq %r14, %rsi
callq 0x44e0
movl $0x1, %edx
movq %r15, %rdi
movq %r14, %rsi
callq 0x44e0
leaq 0x10b569(%rip), %rsi    # 0x15371e
movl $0x13, %edx
movq %r15, %rdi
callq 0x44e0
movq %r15, %rdi
movl %ebp, %esi
callq 0x4750
movq %rax, %r15
leaq 0x10b55c(%rip), %rsi    # 0x153732
movl $0xf, %edx
movq %rax, %rdi
callq 0x44e0
movl 0xd48(%rbx), %esi
movq %r15, %rdi
callq 0x4750
movq %rax, %rbx
movl $0x1, %edx
movq %rax, %rdi
movq %r14, %rsi
callq 0x44e0
movl $0x1, %edx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x44e0
movsd (%r12), %xmm0
jmp 0x48237
movq 0x14edcd(%rip), %rdi    # 0x196ff0
leaq 0x10b79e(%rip), %rsi    # 0x1539c8
movl $0x4e, %edx
callq 0x44e0
xorps %xmm0, %xmm0
addq $0x138, %rsp            # imm = 0x138
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x107455(%rip), %rdi    # 0x14f6a5
movq %r15, %rsi
xorl %eax, %eax
callq 0x4630
leaq 0x107444(%rip), %rdi    # 0x14f6a5
movq 0x18(%rsp), %rsi
xorl %eax, %eax
callq 0x4630
leaq 0x107431(%rip), %rdi    # 0x14f6a5
xorl %eax, %eax
callq 0x4630
leaq 0x107423(%rip), %rdi    # 0x14f6a5
movq 0x18(%rsp), %rsi
xorl %eax, %eax
callq 0x4630
leaq 0x107410(%rip), %rdi    # 0x14f6a5
movq 0x18(%rsp), %rsi
xorl %eax, %eax
callq 0x4630
jmp 0x482c4
jmp 0x482c4
jmp 0x482c4
jmp 0x482c4
jmp 0x482c4
movq %rax, %rbx
jmp 0x482e1
jmp 0x482c4
jmp 0x482c4
jmp 0x482c4
jmp 0x482c4
jmp 0x482c4
jmp 0x482c4
jmp 0x482c4
jmp 0x482c4
jmp 0x482c4
jmp 0x482c4
movq %rax, %rbx
movq 0x78(%rsp), %rdi
testq %rdi, %rdi
je 0x482e1
movq 0x88(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movq 0x90(%rsp), %rdi
testq %rdi, %rdi
je 0x482fe
movq 0xa0(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movq %rbx, %rdi
callq 0x4780