// File: /workspace/github_cpp_makefile_star2_O3/Luthaf[P]zeopp/psd.cc
// Function: NEWcalcPoreSizeDistr(MATERIAL*, std::ostream&)
void NEWcalcPoreSizeDistr(MATERIAL *Mat, ostream &output){

/* PSD debug section (old code that is not used */
  bool PSDDEBUG = false; // this flag enables execution of old parts of PSD output
                         // that can be used for debuging  

  string pointsFile, nodeAndRadiiFile;
  if(PSDDEBUG == true) { pointsFile = "DEBUG_PSDpointsfile"; nodeAndRadiiFile = "DEBUG_PSDnodeAndRadiiFile"; };
  ofstream outfile;
  if (!pointsFile.empty()) outfile.open(pointsFile.data());
  ofstream nodeAndRadii;
  if (!nodeAndRadiiFile.empty()) nodeAndRadii.open(nodeAndRadiiFile.data());

//The following data structures are used to PSDDEBUG

//List of sample points and radius of sphere that contains sample point for visualization in Visit
  vector <pair <Point, double> > axsPoint_and_radiiOfNodeSphere;
  vector <pair <Point, double> > axsPoint_and_radiiOfGhostSphere;
//List of node coordinates and radii for visualization
  vector <int> nodeIDs;
  vector <pair <Point, double> > coord_and_radiiOfNodeSphere;
  vector <pair <Point, double> > coord_and_radiiOfGhostSphere;
	vector <double> distanceBetweenNodeSpheres;
	vector <double> distanceBetweenGhostSpheres;

/* end PSD debug */


/* PSD codes assumes that AV run was executed and AV data structures in MATERIALS class are filled with data */

  int count = Mat->AVcount; // number of AV samples that turned accessible
  int incount = 0; // count number of points inside Voronoi nodes
  int outcount = 0; 

  cout << "PSD calculation for " << count << " points(" << Mat->AVaxsPoints.size() << ").\n"; 

  double pointParticleRadius; // used to be set to = Mat->AVprobeRadius; 

           // After vivid discussions with Rich, we concluded that the ghost particle radius
           // should be set to the smallest radius in the system
           // this gives the correct voronoi network, but the distance from the vericies of the ghost cell to the particle are not correct
           // representation of the pore diamter
  for(int i=0; i<Mat->accessAnalysis.analyzedAtomNet->atoms.size(); i++)
     {
     if(i == 0) pointParticleRadius = Mat->accessAnalysis.analyzedAtomNet->atoms.at(i).radius;
     else
     if(Mat->accessAnalysis.analyzedAtomNet->atoms.at(i).radius < pointParticleRadius) pointParticleRadius = Mat->accessAnalysis.analyzedAtomNet->atoms.at(i).radius;
     };
  cout << "Radius of ghost cell particle = " << pointParticleRadius << "\n";




//Below are functions that go beyond accessible volume calcluation. Each accessible point is analyzed to find the largest encapsulating sphere

//Determine whether sample point is inside/outside node sphere
  for (int a=0; a<Mat->AVaxsPoints.size(); a++){
    Point samplePt = Mat->accessAnalysis.analyzedAtomNet->abc_to_xyz(Mat->AVaxsPoints.at(a));
    Point maxNodeCoord = Point (0, 0, 0);
    double maxRadius = 0;
    for (int b=0; b<Mat->accessAnalysis.vornet.nodes.size(); b++)
      {
      bool access = Mat->accessAnalysis.accessInfo.at(b);
      if (access){
        Point nodePt = Point(Mat->accessAnalysis.vornet.nodes.at(b).x, Mat->accessAnalysis.vornet.nodes.at(b).y, Mat->accessAnalysis.vornet.nodes.at(b).z);
        double radius = Mat->accessAnalysis.vornet.nodes.at(b).rad_stat_sphere;
         //double radius = Mat->accessAnalysis.vornet.nodes.at(b).rad_stat_sphere + Mat->AVprobeRadius;
                        // commented out in non-inflated version
        double sampToNode = Mat->accessAnalysis.analyzedAtomNet->calcDistanceXYZ(samplePt[0], samplePt[1], samplePt[2], nodePt[0], nodePt[1], nodePt[2]);
        bool inSphere = (sampToNode <= radius); 
        //if point is inside more than one sphere, chooses largest sphere (i.e. largest radius)
        if (inSphere){
          maxRadius = max(radius, maxRadius);
          //If query zpsd, this stores the largest node sphere and its coordinate for visualization in Visit (only for PSD DEBUG)
          if (radius==maxRadius){
             maxNodeCoord = nodePt; 
             }
        } // ends if(inSphere)
      }
     }
    if (maxRadius==0) outcount++; 
    if (maxRadius!=0) incount++;



//Generate new "ghost" Voronoi cell

    // ghost cell particle radius (pointParticleRadius) is now set to the radius of the 
    // smallest atom (before the main PSD loop)

    voronoicell v(*(Mat->accessAnalysis.new_rad_con));
    Mat->accessAnalysis.new_rad_con->compute_ghost_cell(v, samplePt[0], samplePt[1], samplePt[2], pointParticleRadius);
    vector<double> vertexCoords;
    v.vertices(vertexCoords);

    vector <Point> pointVertexCoords;
    for (int a=0; a<vertexCoords.size(); a= a+3){
      Point vertexPoint = Point(vertexCoords.at(a), vertexCoords.at(a+1), vertexCoords.at(a+2));
      pointVertexCoords.push_back(vertexPoint);
    }

    double maxDistFromCtoV = 0;
    Point maxGhostCoord = Point (0, 0, 0);
//Calculate distance from center of cell to vertices
   for (int b=0; b<pointVertexCoords.size(); b++){
      Point vertexGlobalCoord = Point((samplePt[0]+pointVertexCoords.at(b)[0]), (samplePt[1]+pointVertexCoords.at(b)[1]), (samplePt[2]+pointVertexCoords.at(b)[2]));
      double calcDistFromCtoV = calcEuclideanDistance(pointVertexCoords.at(b)[0], pointVertexCoords.at(b)[1], pointVertexCoords.at(b)[2], 0.0, 0.0, 0.0) - pointParticleRadius;
      maxDistFromCtoV = max(maxDistFromCtoV, calcDistFromCtoV);
//If query zpsd, this stores the largest ghost sphere and its coordinate for visualization in Visit (only for PSDDEBUG)
      if (calcDistFromCtoV==maxDistFromCtoV){
         maxGhostCoord = vertexGlobalCoord;
         }
    }

//Compares node radius to biggest ghost radius and stores the larger of the two values accordingly
    double origNodeRadius = maxRadius;
    double ghostRadius = maxDistFromCtoV;  
    bool compareRadii = (origNodeRadius >= ghostRadius); 
    if (compareRadii) {
      Mat->AVaxsPointsPSD.push_back(2.0*origNodeRadius); 
      if (PSDDEBUG){
      axsPoint_and_radiiOfNodeSphere.push_back(pair<Point, double>(samplePt, origNodeRadius));
      checkDuplicates((Mat->accessAnalysis.analyzedAtomNet), &(Mat->accessAnalysis.vornet), nodeIDs, coord_and_radiiOfNodeSphere, maxNodeCoord, origNodeRadius);
      }
    }
    if (!compareRadii) {
      Mat->AVaxsPointsPSD.push_back(2.0*ghostRadius);
      if (PSDDEBUG){
        axsPoint_and_radiiOfGhostSphere.push_back(pair<Point, double>(samplePt, ghostRadius));
        coord_and_radiiOfGhostSphere.push_back(pair <Point, double> (maxGhostCoord, maxDistFromCtoV));
      }
    }
  }

  double volumeFraction = count*1.0/Mat->AVnumSamples;
  double nodeVolFraction = incount*1.0/Mat->AVnumSamples;
  double outFraction = outcount*1.0/Mat->AVnumSamples;


  Histogram(output, BINSTEP, MAXBINS, (Mat->AVaxsPointsPSD), count, nodeVolFraction, outFraction, Mat->AVnumSamples);

  printf("Pore size distribution calculated.\n\n");

  if (PSDDEBUG) {
    printFileCoords_Radii(outfile, axsPoint_and_radiiOfNodeSphere, axsPoint_and_radiiOfGhostSphere, distanceBetweenNodeSpheres, distanceBetweenGhostSpheres, false, -1, -1);
    printf("Points file generated.\n\n");
    printFileCoords_Radii(nodeAndRadii, coord_and_radiiOfNodeSphere, coord_and_radiiOfGhostSphere, distanceBetweenNodeSpheres, distanceBetweenGhostSpheres, false, -1, -1);
    printf("Radii file generated.\n");
    }


}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x658, %rsp            # imm = 0x658
movq %rsi, %r15
movq %rdi, %r14
leaq 0x108(%rsp), %rcx
movq %rcx, -0x10(%rcx)
xorl %eax, %eax
movq %rax, -0x8(%rcx)
movb %al, (%rcx)
leaq 0xe8(%rsp), %rcx
movq %rcx, -0x10(%rcx)
movq %rax, -0x8(%rcx)
movb %al, (%rcx)
leaq 0x458(%rsp), %r12
movq %r12, %rdi
callq 0x4720
cmpq $0x0, 0x100(%rsp)
je 0x8afcd
movq 0xf8(%rsp), %rsi
leaq 0x458(%rsp), %rdi
movl $0x10, %edx
callq 0x4070
leaq 0x258(%rsp), %rbp
movq %rbp, %rdi
callq 0x4720
cmpq $0x0, 0xe0(%rsp)
je 0x8b002
movq 0xd8(%rsp), %rsi
leaq 0x258(%rsp), %rdi
movl $0x10, %edx
callq 0x4070
movl 0xc7c(%r14), %eax
movl %eax, 0x60(%rsp)
movq 0x109fac(%rip), %rdi    # 0x194fc0
leaq 0xcaa95(%rip), %rsi     # 0x155ab0
movl $0x14, %edx
callq 0x44e0
movq 0x109f94(%rip), %rdi    # 0x194fc0
movl 0x60(%rsp), %esi
callq 0x4750
movq %rax, %rbx
leaq 0xcaa86(%rip), %rsi     # 0x155ac5
movl $0x8, %edx
movq %rax, %rdi
callq 0x44e0
movq 0xc98(%r14), %rsi
subq 0xc90(%r14), %rsi
sarq $0x3, %rsi
movabsq $-0x5555555555555555, %r13 # imm = 0xAAAAAAAAAAAAAAAB
imulq %r13, %rsi
movq %rbx, %rdi
callq 0x42b0
leaq 0xd28c6(%rip), %rsi     # 0x15d941
movl $0x3, %edx
movq %rax, %rdi
callq 0x44e0
movq 0x998(%r14), %rcx
movq 0x2f0(%rcx), %rax
movq 0x2f8(%rcx), %rdx
subq %rax, %rdx
je 0x8b0f7
sarq $0x3, %rdx
movabsq $-0x79435e50d79435e5, %rcx # imm = 0x86BCA1AF286BCA1B
imulq %rdx, %rcx
cmpq $0x1, %rcx
adcq $0x0, %rcx
addq $0x30, %rax
xorl %edx, %edx
movq %rax, %rsi
testq %rdx, %rdx
je 0x8b0dc
movsd (%rsi), %xmm0
movsd 0x50(%rsp), %xmm1
ucomisd %xmm0, %xmm1
ja 0x8b0e0
jmp 0x8b0e6
movsd (%rax), %xmm0
movsd %xmm0, 0x50(%rsp)
incq %rdx
addq $0x98, %rsi
cmpq %rdx, %rcx
jne 0x8b0c5
jmp 0x8b0f7
movq 0x109ec2(%rip), %rdi    # 0x194fc0
leaq 0xca9c9(%rip), %rsi     # 0x155ace
movl $0x20, %edx
callq 0x44e0
movq 0x109eaa(%rip), %rdi    # 0x194fc0
movsd 0x50(%rsp), %xmm0
callq 0x46b0
leaq 0xc84f6(%rip), %rsi     # 0x15361e
movl $0x1, %edx
movq %rax, %rdi
callq 0x44e0
movq 0xc90(%r14), %rax
cmpq %rax, 0xc98(%r14)
je 0x8b9fa
movq %r15, 0x118(%rsp)
leaq 0xa70(%r14), %rcx
movq %rcx, 0x128(%rsp)
leaq 0xd20(%r14), %rcx
movq %rcx, 0xd0(%rsp)
xorl %edx, %edx
leaq 0x240(%rsp), %rbp
xorl %r12d, %r12d
movl $0x0, 0x64(%rsp)
movq 0x998(%r14), %rsi
movq %rdx, 0x120(%rsp)
leaq (%rdx,%rdx,2), %rcx
movq 0x10(%rax,%rcx,8), %rdx
movq %rdx, 0x10(%rsp)
movupd (%rax,%rcx,8), %xmm0
movupd %xmm0, (%rsp)
movq %rbp, %rdi
callq 0x51d04
xorpd %xmm0, %xmm0
xorpd %xmm1, %xmm1
xorpd %xmm2, %xmm2
leaq 0x140(%rsp), %rdi
callq 0x83f68
movl %r12d, 0x94(%rsp)
movq 0x9f8(%r14), %rax
cmpq 0x9f0(%r14), %rax
je 0x8b3b1
xorpd %xmm0, %xmm0
movsd %xmm0, 0x58(%rsp)
xorl %r12d, %r12d
xorl %r15d, %r15d
movq 0x128(%rsp), %rdi
movq %r15, %rsi
callq 0xee36
testq %rdx, (%rax)
je 0x8b38d
movq 0x9f0(%r14), %rax
movq 0x9f8(%r14), %rdx
subq %rax, %rdx
sarq $0x6, %rdx
cmpq %r15, %rdx
jbe 0x8bb4c
movsd (%rax,%r12), %xmm0
movsd 0x8(%rax,%r12), %xmm1
movsd 0x10(%rax,%r12), %xmm2
leaq 0x158(%rsp), %rdi
callq 0x83f68
movq 0x9f0(%r14), %rax
movq 0x9f8(%r14), %rdx
subq %rax, %rdx
sarq $0x6, %rdx
cmpq %r15, %rdx
jbe 0x8bb3b
movsd 0x18(%rax,%r12), %xmm0
movsd %xmm0, 0x20(%rsp)
movq 0x998(%r14), %rbx
movq %rbp, %rdi
xorl %esi, %esi
callq 0x83f9a
movsd (%rax), %xmm0
movsd %xmm0, 0x28(%rsp)
movq %rbp, %rdi
movl $0x1, %esi
callq 0x83f9a
movsd (%rax), %xmm0
movsd %xmm0, 0x68(%rsp)
movq %rbp, %rdi
movl $0x2, %esi
callq 0x83f9a
movsd (%rax), %xmm0
movsd %xmm0, 0x88(%rsp)
leaq 0x158(%rsp), %rdi
xorl %esi, %esi
callq 0x83f9a
movsd (%rax), %xmm0
movsd %xmm0, 0x138(%rsp)
leaq 0x158(%rsp), %rdi
movl $0x1, %esi
callq 0x83f9a
movsd (%rax), %xmm0
movsd %xmm0, 0x130(%rsp)
leaq 0x158(%rsp), %rdi
movl $0x2, %esi
callq 0x83f9a
movsd (%rax), %xmm5
movq %rbx, %rdi
movsd 0x28(%rsp), %xmm0
movsd 0x68(%rsp), %xmm1
movsd 0x88(%rsp), %xmm2
movsd 0x138(%rsp), %xmm3
movsd 0x130(%rsp), %xmm4
callq 0x5364c
movsd 0x20(%rsp), %xmm1
ucomisd %xmm0, %xmm1
jb 0x8b38d
movsd 0x58(%rsp), %xmm0
maxsd %xmm1, %xmm0
movsd %xmm0, 0x58(%rsp)
ucomisd %xmm0, %xmm1
jne 0x8b38d
jp 0x8b38d
movq 0x168(%rsp), %rax
movq %rax, 0x150(%rsp)
movupd 0x158(%rsp), %xmm0
movapd %xmm0, 0x140(%rsp)
movq 0x9f8(%r14), %rax
subq 0x9f0(%r14), %rax
incq %r15
sarq $0x6, %rax
addq $0x40, %r12
cmpq %r15, %rax
ja 0x8b1f8
jmp 0x8b3bb
xorpd %xmm0, %xmm0
movsd %xmm0, 0x58(%rsp)
movq 0xad0(%r14), %rax
movsd 0x178(%rax), %xmm0
leaq 0x158(%rsp), %rdi
callq 0x1214ac
leaq 0x1098e2(%rip), %rax    # 0x194cc0
movq %rax, 0x158(%rsp)
movq 0xad0(%r14), %r15
movq %rbp, %rdi
xorl %esi, %esi
callq 0x83f9a
movl 0x94(%rsp), %r12d
movsd (%rax), %xmm0
movsd %xmm0, 0x20(%rsp)
movq %rbp, %rdi
movl $0x1, %esi
callq 0x83f9a
movsd (%rax), %xmm0
movsd %xmm0, 0x28(%rsp)
movq %rbp, %rdi
movl $0x2, %esi
callq 0x83f9a
movsd (%rax), %xmm0
movsd 0x20(%rsp), %xmm1
movsd %xmm1, 0x70(%rsp)
movsd 0x28(%rsp), %xmm1
movsd %xmm1, 0x30(%rsp)
movsd %xmm0, 0xb0(%rsp)
movq %r15, %rdi
leaq 0x98(%rsp), %rsi
leaq 0x70(%rsp), %rdx
leaq 0x30(%rsp), %rcx
leaq 0xb0(%rsp), %r8
callq 0x148c0a
movslq 0x98(%rsp), %rcx
movq 0x1a8(%r15), %rdx
movq 0x1b0(%r15), %rax
movq (%rdx,%rcx,8), %rdx
movslq (%rax,%rcx,4), %rsi
leal 0x1(%rsi), %edi
movl %edi, (%rax,%rcx,4)
shlq $0x5, %rsi
movsd 0x1d8(%r15), %xmm0
movsd %xmm0, 0x20(%rsp)
movsd 0x70(%rsp), %xmm0
movsd %xmm0, (%rdx,%rsi)
movsd 0x30(%rsp), %xmm0
movsd %xmm0, 0x8(%rdx,%rsi)
movsd 0xb0(%rsp), %xmm0
movsd %xmm0, 0x10(%rdx,%rsi)
movsd 0x50(%rsp), %xmm0
movsd %xmm0, 0x18(%rdx,%rsi)
ucomisd 0x1d8(%r15), %xmm0
jbe 0x8b4f7
movsd 0x50(%rsp), %xmm0
movsd %xmm0, 0x1d8(%r15)
movslq 0x98(%rsp), %r8
movl (%rax,%r8,4), %ecx
movl 0x128(%r15), %edi
movl 0x190(%r15), %esi
imull %edi, %esi
movl %r8d, %eax
cltd
idivl %esi
movl %eax, %esi
movl %edx, %eax
cltd
idivl %edi
movl %edx, %r9d
decl %ecx
leaq 0x1f8(%r15), %rdi
movl %esi, (%rsp)
leaq 0x158(%rsp), %rsi
movl %r8d, %edx
movl %r9d, %r8d
movl %eax, %r9d
callq 0x1418d0
movq 0x1b0(%r15), %rax
movslq 0x98(%rsp), %rcx
decl (%rax,%rcx,4)
movsd 0x20(%rsp), %xmm0
movsd %xmm0, 0x1d8(%r15)
xorpd %xmm0, %xmm0
movapd %xmm0, 0x70(%rsp)
movq $0x0, 0x80(%rsp)
leaq 0x158(%rsp), %rdi
leaq 0x70(%rsp), %rsi
callq 0x124df0
xorpd %xmm0, %xmm0
movapd %xmm0, 0x30(%rsp)
movq $0x0, 0x40(%rsp)
movq 0x70(%rsp), %rax
movq 0x78(%rsp), %rdx
subq %rax, %rdx
leaq 0x30(%rsp), %r15
je 0x8b659
sarq $0x3, %rdx
movl $0x1, %ebx
cmpq %rbx, %rdx
jbe 0x8bb2a
leaq 0x1(%rbx), %rsi
cmpq %rsi, %rdx
jbe 0x8bb2d
movsd -0x8(%rax,%rbx,8), %xmm0
movsd (%rax,%rbx,8), %xmm1
movsd 0x8(%rax,%rbx,8), %xmm2
leaq 0xb0(%rsp), %rdi
callq 0x83f68
movq 0x38(%rsp), %rsi
cmpq 0x40(%rsp), %rsi
je 0x8b624
movq 0xc0(%rsp), %rax
movq %rax, 0x10(%rsi)
movupd 0xb0(%rsp), %xmm0
movupd %xmm0, (%rsi)
addq $0x18, 0x38(%rsp)
jmp 0x8b634
movq %r15, %rdi
leaq 0xb0(%rsp), %rdx
callq 0x2fec4
movq 0x70(%rsp), %rax
movq 0x78(%rsp), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
leaq 0x3(%rbx), %rcx
addq $0x2, %rbx
cmpq %rbx, %rdx
movq %rcx, %rbx
ja 0x8b5c3
xorpd %xmm0, %xmm0
xorpd %xmm1, %xmm1
xorpd %xmm2, %xmm2
leaq 0xb0(%rsp), %rdi
callq 0x83f68
movq 0x38(%rsp), %rax
cmpq 0x30(%rsp), %rax
je 0x8b8ae
xorpd %xmm0, %xmm0
movsd %xmm0, 0x68(%rsp)
xorl %ebx, %ebx
xorl %r15d, %r15d
movq %rbp, %rdi
xorl %esi, %esi
callq 0x83f9a
movq 0x30(%rsp), %rdi
movq 0x38(%rsp), %rdx
subq %rdi, %rdx
sarq $0x3, %rdx
imulq %r13, %rdx
cmpq %r15, %rdx
jbe 0x8bb08
movsd (%rax), %xmm0
movsd %xmm0, 0x20(%rsp)
addq %rbx, %rdi
xorl %esi, %esi
callq 0x83f9a
movsd 0x20(%rsp), %xmm0
addsd (%rax), %xmm0
movsd %xmm0, 0x20(%rsp)
movq %rbp, %rdi
movl $0x1, %esi
callq 0x83f9a
movq 0x30(%rsp), %rdi
movq 0x38(%rsp), %rdx
subq %rdi, %rdx
sarq $0x3, %rdx
imulq %r13, %rdx
cmpq %r15, %rdx
jbe 0x8bb08
movsd (%rax), %xmm0
movsd %xmm0, 0x28(%rsp)
addq %rbx, %rdi
movl $0x1, %esi
callq 0x83f9a
movsd 0x28(%rsp), %xmm0
addsd (%rax), %xmm0
movsd %xmm0, 0x28(%rsp)
movq %rbp, %rdi
movl $0x2, %esi
callq 0x83f9a
movq 0x30(%rsp), %rdi
movq 0x38(%rsp), %rdx
subq %rdi, %rdx
sarq $0x3, %rdx
imulq %r13, %rdx
cmpq %r15, %rdx
jbe 0x8bb08
movsd (%rax), %xmm0
movsd %xmm0, 0x88(%rsp)
addq %rbx, %rdi
movl $0x2, %esi
callq 0x83f9a
movsd 0x28(%rsp), %xmm1
movsd 0x88(%rsp), %xmm2
addsd (%rax), %xmm2
leaq 0x98(%rsp), %rdi
movsd 0x20(%rsp), %xmm0
callq 0x83f68
movq 0x30(%rsp), %rdi
movq 0x38(%rsp), %rdx
subq %rdi, %rdx
sarq $0x3, %rdx
imulq %r13, %rdx
cmpq %r15, %rdx
jbe 0x8bb19
addq %rbx, %rdi
xorl %esi, %esi
callq 0x83f9a
movq 0x30(%rsp), %rdi
movq 0x38(%rsp), %rdx
subq %rdi, %rdx
sarq $0x3, %rdx
imulq %r13, %rdx
cmpq %r15, %rdx
jbe 0x8bb19
movsd (%rax), %xmm0
movsd %xmm0, 0x20(%rsp)
addq %rbx, %rdi
movl $0x1, %esi
callq 0x83f9a
movq 0x30(%rsp), %rdi
movq 0x38(%rsp), %rdx
subq %rdi, %rdx
sarq $0x3, %rdx
imulq %r13, %rdx
cmpq %r15, %rdx
jbe 0x8bb19
movsd (%rax), %xmm0
movsd %xmm0, 0x28(%rsp)
addq %rbx, %rdi
movl $0x2, %esi
callq 0x83f9a
movsd (%rax), %xmm2
xorps %xmm3, %xmm3
xorps %xmm4, %xmm4
xorps %xmm5, %xmm5
movsd 0x20(%rsp), %xmm0
movsd 0x28(%rsp), %xmm1
callq 0x84cbb
subsd 0x50(%rsp), %xmm0
movapd %xmm0, %xmm1
maxsd 0x68(%rsp), %xmm1
ucomisd %xmm1, %xmm0
jne 0x8b884
jp 0x8b884
movq 0xa8(%rsp), %rax
movq %rax, 0xc0(%rsp)
movupd 0x98(%rsp), %xmm0
movapd %xmm0, 0xb0(%rsp)
incq %r15
movq 0x38(%rsp), %rax
subq 0x30(%rsp), %rax
sarq $0x3, %rax
imulq %r13, %rax
addq $0x18, %rbx
movsd %xmm1, 0x68(%rsp)
cmpq %r15, %rax
ja 0x8b691
jmp 0x8b8b2
xorpd %xmm1, %xmm1
movsd 0x58(%rsp), %xmm0
ucomisd %xmm1, %xmm0
jae 0x8b8e1
addsd %xmm1, %xmm1
movsd %xmm1, 0x98(%rsp)
movq 0xd28(%r14), %rsi
cmpq 0xd30(%r14), %rsi
je 0x8b90f
movsd %xmm1, (%rsi)
jmp 0x8b902
addsd %xmm0, %xmm0
movsd %xmm0, 0x98(%rsp)
movq 0xd28(%r14), %rsi
cmpq 0xd30(%r14), %rsi
je 0x8b926
movsd %xmm0, (%rsi)
addq $0x8, %rsi
movq %rsi, 0xd28(%r14)
jmp 0x8b93b
movq 0xd0(%rsp), %rdi
leaq 0x98(%rsp), %rdx
callq 0x1391c
jmp 0x8b93b
movq 0xd0(%rsp), %rdi
leaq 0x98(%rsp), %rdx
callq 0x1391c
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x8b952
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movq 0x70(%rsp), %rdi
testq %rdi, %rdi
je 0x8b96c
movq 0x80(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movsd 0x58(%rsp), %xmm2
movapd %xmm2, %xmm0
xorpd %xmm1, %xmm1
cmpeqsd %xmm1, %xmm0
movq %xmm0, %rax
subl %eax, 0x64(%rsp)
cmpneqsd %xmm1, %xmm2
movq %xmm2, %rax
subl %eax, %r12d
leaq 0x158(%rsp), %rdi
callq 0x121724
movq 0x120(%rsp), %rdx
incq %rdx
movq 0xc90(%r14), %rax
movq 0xc98(%r14), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
imulq %r13, %rcx
cmpq %rdx, %rcx
ja 0x8b184
xorps %xmm1, %xmm1
cvtsi2sd %r12d, %xmm1
xorps %xmm2, %xmm2
cvtsi2sdl 0x64(%rsp), %xmm2
leaq 0x458(%rsp), %r12
movq 0x118(%rsp), %r15
leaq 0x258(%rsp), %rbp
jmp 0x8ba02
xorpd %xmm2, %xmm2
xorpd %xmm1, %xmm1
movl 0xc78(%r14), %r8d
xorps %xmm0, %xmm0
cvtsi2sd %r8d, %xmm0
divsd %xmm0, %xmm1
divsd %xmm0, %xmm2
addq $0xd20, %r14            # imm = 0xD20
movsd 0xc6860(%rip), %xmm0    # 0x152288
movq %r15, %rdi
movl $0x3e8, %esi            # imm = 0x3E8
movq %r14, %rdx
movl 0x60(%rsp), %ecx
callq 0x8a669
leaq 0xca24f(%rip), %rdi     # 0x155c92
callq 0x4660
movq 0x109551(%rip), %rax    # 0x194fa0
movq (%rax), %rbx
movq 0x18(%rax), %r14
leaq 0x260(%rsp), %rdi
movq %rbx, -0x8(%rdi)
movq -0x18(%rbx), %rax
movq %r14, 0x258(%rsp,%rax)
callq 0x4390
movl $0xf8, %r15d
addq %r15, %rbp
movq %rbp, %rdi
callq 0x41a0
leaq 0x460(%rsp), %rdi
movq %rbx, -0x8(%rdi)
movq -0x18(%rbx), %rax
movq %r14, 0x458(%rsp,%rax)
callq 0x4390
addq %r15, %r12
movq %r12, %rdi
callq 0x41a0
movq 0xd8(%rsp), %rdi
leaq 0xe8(%rsp), %rax
cmpq %rax, %rdi
je 0x8bad1
movq 0xe8(%rsp), %rsi
incq %rsi
callq 0x4470
movq 0xf8(%rsp), %rdi
leaq 0x108(%rsp), %rax
cmpq %rax, %rdi
je 0x8baf6
movq 0x108(%rsp), %rsi
incq %rsi
callq 0x4470
addq $0x658, %rsp            # imm = 0x658
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xc1be6(%rip), %rdi     # 0x14d6f5
movq %r15, %rsi
xorl %eax, %eax
callq 0x4630
leaq 0xc1bd5(%rip), %rdi     # 0x14d6f5
movq %r15, %rsi
xorl %eax, %eax
callq 0x4630
movq %rbx, %rsi
leaq 0xc1bc1(%rip), %rdi     # 0x14d6f5
xorl %eax, %eax
callq 0x4630
leaq 0xc1bb3(%rip), %rdi     # 0x14d6f5
movq %r15, %rsi
xorl %eax, %eax
callq 0x4630
leaq 0xc1ba2(%rip), %rdi     # 0x14d6f5
movq %r15, %rsi
xorl %eax, %eax
callq 0x4630
jmp 0x8bb9f
jmp 0x8bb63
jmp 0x8bb9f
movq %rax, %rbx
jmp 0x8bc1d
movq %rax, %rbx
jmp 0x8bc55
jmp 0x8bb9f
jmp 0x8bba4
jmp 0x8bba4
jmp 0x8bb9f
jmp 0x8bba4
movq %rax, %rbx
jmp 0x8bbbe
jmp 0x8bb9f
jmp 0x8bb9f
jmp 0x8bb9f
movq %rax, %rbx
jmp 0x8bbd8
jmp 0x8bb9f
jmp 0x8bb9f
jmp 0x8bb9f
jmp 0x8bb9f
jmp 0x8bba4
jmp 0x8bba4
jmp 0x8bba4
jmp 0x8bba4
jmp 0x8bba4
movq %rax, %rbx
jmp 0x8bbe5
movq %rax, %rbx
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x8bbbe
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movq 0x70(%rsp), %rdi
testq %rdi, %rdi
je 0x8bbd8
movq 0x80(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
leaq 0x158(%rsp), %rdi
callq 0x121724
movq 0x1093b4(%rip), %rax    # 0x194fa0
movq (%rax), %rcx
movq 0x18(%rax), %rax
leaq 0x260(%rsp), %rdi
movq %rcx, -0x8(%rdi)
movq -0x18(%rcx), %rcx
movq %rax, 0x258(%rsp,%rcx)
callq 0x4390
leaq 0x350(%rsp), %rdi
callq 0x41a0
movq 0x10937c(%rip), %rax    # 0x194fa0
movq (%rax), %rcx
movq 0x18(%rax), %rax
leaq 0x460(%rsp), %rdi
movq %rcx, -0x8(%rdi)
movq -0x18(%rcx), %rcx
movq %rax, 0x458(%rsp,%rcx)
callq 0x4390
leaq 0x550(%rsp), %rdi
callq 0x41a0
movq 0xd8(%rsp), %rdi
leaq 0xe8(%rsp), %rax
cmpq %rax, %rdi
je 0x8bc7a
movq 0xe8(%rsp), %rsi
incq %rsi
callq 0x4470
movq 0xf8(%rsp), %rdi
leaq 0x108(%rsp), %rax
cmpq %rax, %rdi
je 0x8bc9f
movq 0x108(%rsp), %rsi
incq %rsi
callq 0x4470
movq %rbx, %rdi
callq 0x4780