// File: 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
movq %rsp, %rbp
subq $0xa70, %rsp            # imm = 0xA70
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movb $0x0, -0x11(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x5720
leaq -0x58(%rbp), %rdi
callq 0x5720
movb -0x11(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x1, %eax
jne 0xf52dd
leaq 0x107480(%rip), %rsi    # 0x1fc72d
leaq -0x38(%rbp), %rdi
callq 0x5710
jmp 0xf52b8
leaq 0x107482(%rip), %rsi    # 0x1fc741
leaq -0x58(%rbp), %rdi
callq 0x5710
jmp 0xf52ca
jmp 0xf52dd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0xf64e1
leaq -0x268(%rbp), %rdi
callq 0x5890
jmp 0xf52eb
leaq -0x38(%rbp), %rdi
callq 0x5850
testb $0x1, %al
jne 0xf532a
leaq -0x38(%rbp), %rdi
callq 0x52c0
movq %rax, %rsi
leaq -0x268(%rbp), %rdi
movl $0x10, %edx
callq 0x5080
jmp 0xf5317
jmp 0xf532a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0xf64d5
leaq -0x468(%rbp), %rdi
callq 0x5890
jmp 0xf5338
leaq -0x58(%rbp), %rdi
callq 0x5850
testb $0x1, %al
jne 0xf5377
leaq -0x58(%rbp), %rdi
callq 0x52c0
movq %rax, %rsi
leaq -0x468(%rbp), %rdi
movl $0x10, %edx
callq 0x5080
jmp 0xf5364
jmp 0xf5377
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0xf64c9
leaq -0x480(%rbp), %rdi
callq 0xf6db0
leaq -0x498(%rbp), %rdi
callq 0xf6db0
leaq -0x4b0(%rbp), %rdi
callq 0xd0d0
leaq -0x4c8(%rbp), %rdi
callq 0xf6db0
leaq -0x4e0(%rbp), %rdi
callq 0xf6db0
leaq -0x4f8(%rbp), %rdi
callq 0xf650
leaq -0x510(%rbp), %rdi
callq 0xf650
movq -0x8(%rbp), %rax
movl 0xc7c(%rax), %eax
movl %eax, -0x514(%rbp)
movl $0x0, -0x518(%rbp)
movl $0x0, -0x51c(%rbp)
movq 0x17dbca(%rip), %rdi    # 0x272fc0
leaq 0x10735e(%rip), %rsi    # 0x1fc75b
callq 0x5540
movq %rax, -0x808(%rbp)
jmp 0xf540b
movq -0x808(%rbp), %rdi
movl -0x514(%rbp), %esi
callq 0x58d0
movq %rax, -0x810(%rbp)
jmp 0xf5426
movq -0x810(%rbp), %rdi
leaq 0x10733c(%rip), %rsi    # 0x1fc770
callq 0x5540
movq %rax, -0x818(%rbp)
jmp 0xf5442
movq -0x8(%rbp), %rdi
addq $0xc90, %rdi            # imm = 0xC90
callq 0x17c60
movq -0x818(%rbp), %rdi
movq %rax, %rsi
callq 0x5160
movq %rax, -0x820(%rbp)
jmp 0xf546a
movq -0x820(%rbp), %rdi
leaq 0x1148d8(%rip), %rsi    # 0x209d50
callq 0x5540
jmp 0xf547f
movl $0x0, -0x52c(%rbp)
movslq -0x52c(%rbp), %rax
movq %rax, -0x828(%rbp)
movq -0x8(%rbp), %rax
movq 0x998(%rax), %rdi
addq $0x2f0, %rdi            # imm = 0x2F0
callq 0xf060
movq %rax, %rcx
movq -0x828(%rbp), %rax
cmpq %rcx, %rax
jae 0xf55af
cmpl $0x0, -0x52c(%rbp)
jne 0xf551b
movq -0x8(%rbp), %rax
movq 0x998(%rax), %rdi
addq $0x2f0, %rdi            # imm = 0x2F0
movslq -0x52c(%rbp), %rsi
callq 0xf090
movq %rax, -0x830(%rbp)
jmp 0xf54f1
movq -0x830(%rbp), %rax
movsd 0x30(%rax), %xmm0
movsd %xmm0, -0x528(%rbp)
jmp 0xf5599
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0xf6475
movq -0x8(%rbp), %rax
movq 0x998(%rax), %rdi
addq $0x2f0, %rdi            # imm = 0x2F0
movslq -0x52c(%rbp), %rsi
callq 0xf090
movq %rax, -0x838(%rbp)
jmp 0xf5542
movq -0x838(%rbp), %rax
movsd 0x30(%rax), %xmm1
movsd -0x528(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0xf5597
movq -0x8(%rbp), %rax
movq 0x998(%rax), %rdi
addq $0x2f0, %rdi            # imm = 0x2F0
movslq -0x52c(%rbp), %rsi
callq 0xf090
movq %rax, -0x840(%rbp)
jmp 0xf5583
movq -0x840(%rbp), %rax
movsd 0x30(%rax), %xmm0
movsd %xmm0, -0x528(%rbp)
jmp 0xf5599
jmp 0xf559b
movl -0x52c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x52c(%rbp)
jmp 0xf5489
movq 0x17da0a(%rip), %rdi    # 0x272fc0
leaq 0x1071bc(%rip), %rsi    # 0x1fc779
callq 0x5540
movq %rax, -0x848(%rbp)
jmp 0xf55cb
movq -0x848(%rbp), %rdi
movsd -0x528(%rbp), %xmm0
callq 0x5980
movq %rax, -0x850(%rbp)
jmp 0xf55e8
movq -0x850(%rbp), %rdi
leaq 0x10402f(%rip), %rsi    # 0x1f9625
callq 0x5540
jmp 0xf55fd
movl $0x0, -0x530(%rbp)
movslq -0x530(%rbp), %rax
movq %rax, -0x858(%rbp)
movq -0x8(%rbp), %rdi
addq $0xc90, %rdi            # imm = 0xC90
callq 0x17c60
movq %rax, %rcx
movq -0x858(%rbp), %rax
cmpq %rcx, %rax
jae 0xf629f
movq -0x8(%rbp), %rdi
movq 0x998(%rdi), %rax
movq %rax, -0x868(%rbp)
addq $0xc90, %rdi            # imm = 0xC90
movslq -0x530(%rbp), %rsi
callq 0x59c60
movq %rax, -0x860(%rbp)
jmp 0xf5666
movq -0x868(%rbp), %rsi
movq -0x860(%rbp), %rax
movq 0x10(%rax), %rcx
movq %rcx, -0x550(%rbp)
movups (%rax), %xmm0
movaps %xmm0, -0x560(%rbp)
movq -0x550(%rbp), %rcx
movq %rsp, %rax
movq %rcx, 0x10(%rax)
movaps -0x560(%rbp), %xmm0
movups %xmm0, (%rax)
leaq -0x548(%rbp), %rdi
callq 0x961d0
jmp 0xf56af
leaq -0x578(%rbp), %rdi
xorps %xmm2, %xmm2
movaps %xmm2, %xmm0
movaps %xmm2, %xmm1
callq 0xe9c70
jmp 0xf56c6
xorps %xmm0, %xmm0
movsd %xmm0, -0x580(%rbp)
movl $0x0, -0x584(%rbp)
movslq -0x584(%rbp), %rax
movq %rax, -0x870(%rbp)
movq -0x8(%rbp), %rdi
addq $0x990, %rdi            # imm = 0x990
addq $0x18, %rdi
addq $0x48, %rdi
callq 0xf270
movq %rax, %rcx
movq -0x870(%rbp), %rax
cmpq %rcx, %rax
jae 0xf5a6c
movq -0x8(%rbp), %rdi
addq $0xa70, %rdi            # imm = 0xA70
movslq -0x584(%rbp), %rsi
callq 0xfff0
movq %rdx, -0x880(%rbp)
movq %rax, -0x878(%rbp)
jmp 0xf573b
movq -0x880(%rbp), %rax
movq -0x878(%rbp), %rcx
movq %rcx, -0x598(%rbp)
movq %rax, -0x590(%rbp)
leaq -0x598(%rbp), %rdi
callq 0x101a0
andb $0x1, %al
movb %al, -0x585(%rbp)
testb $0x1, -0x585(%rbp)
je 0xf5a56
movq -0x8(%rbp), %rdi
addq $0x9f0, %rdi            # imm = 0x9F0
movslq -0x584(%rbp), %rsi
callq 0xf390
movq %rax, -0x888(%rbp)
jmp 0xf5798
movq -0x888(%rbp), %rax
movsd (%rax), %xmm0
movsd %xmm0, -0x898(%rbp)
movq -0x8(%rbp), %rdi
addq $0x9f0, %rdi            # imm = 0x9F0
movslq -0x584(%rbp), %rsi
callq 0xf390
movq %rax, -0x890(%rbp)
jmp 0xf57cb
movq -0x890(%rbp), %rax
movsd 0x8(%rax), %xmm0
movsd %xmm0, -0x8a8(%rbp)
movq -0x8(%rbp), %rdi
addq $0x9f0, %rdi            # imm = 0x9F0
movslq -0x584(%rbp), %rsi
callq 0xf390
movq %rax, -0x8a0(%rbp)
jmp 0xf57ff
movsd -0x8a8(%rbp), %xmm1
movsd -0x898(%rbp), %xmm0
movq -0x8a0(%rbp), %rax
movsd 0x10(%rax), %xmm2
leaq -0x5b0(%rbp), %rdi
callq 0xe9c70
jmp 0xf5829
movq -0x8(%rbp), %rdi
addq $0x9f0, %rdi            # imm = 0x9F0
movslq -0x584(%rbp), %rsi
callq 0xf390
movq %rax, -0x8b0(%rbp)
jmp 0xf5849
movq -0x8b0(%rbp), %rax
movsd 0x18(%rax), %xmm0
movsd %xmm0, -0x5b8(%rbp)
movq -0x8(%rbp), %rax
movq 0x998(%rax), %rax
movq %rax, -0x8c0(%rbp)
leaq -0x548(%rbp), %rdi
xorl %esi, %esi
callq 0xe9d70
movq %rax, -0x8b8(%rbp)
jmp 0xf5886
movq -0x8b8(%rbp), %rax
movsd (%rax), %xmm0
movsd %xmm0, -0x8d0(%rbp)
leaq -0x548(%rbp), %rdi
movl $0x1, %esi
callq 0xe9d70
movq %rax, -0x8c8(%rbp)
jmp 0xf58b3
movq -0x8c8(%rbp), %rax
movsd (%rax), %xmm0
movsd %xmm0, -0x8e0(%rbp)
leaq -0x548(%rbp), %rdi
movl $0x2, %esi
callq 0xe9d70
movq %rax, -0x8d8(%rbp)
jmp 0xf58e0
movq -0x8d8(%rbp), %rax
movsd (%rax), %xmm0
movsd %xmm0, -0x8f0(%rbp)
leaq -0x5b0(%rbp), %rdi
xorl %esi, %esi
callq 0xe9d70
movq %rax, -0x8e8(%rbp)
jmp 0xf590a
movq -0x8e8(%rbp), %rax
movsd (%rax), %xmm0
movsd %xmm0, -0x900(%rbp)
leaq -0x5b0(%rbp), %rdi
movl $0x1, %esi
callq 0xe9d70
movq %rax, -0x8f8(%rbp)
jmp 0xf5937
movq -0x8f8(%rbp), %rax
movsd (%rax), %xmm0
movsd %xmm0, -0x910(%rbp)
leaq -0x5b0(%rbp), %rdi
movl $0x2, %esi
callq 0xe9d70
movq %rax, -0x908(%rbp)
jmp 0xf5964
movsd -0x910(%rbp), %xmm4
movsd -0x900(%rbp), %xmm3
movsd -0x8f0(%rbp), %xmm2
movsd -0x8e0(%rbp), %xmm1
movsd -0x8d0(%rbp), %xmm0
movq -0x8c0(%rbp), %rdi
movq -0x908(%rbp), %rax
movsd (%rax), %xmm5
callq 0x97a10
movsd %xmm0, -0x918(%rbp)
jmp 0xf59ad
movsd -0x918(%rbp), %xmm0
movsd %xmm0, -0x5c0(%rbp)
movsd -0x5c0(%rbp), %xmm1
movsd -0x5b8(%rbp), %xmm0
ucomisd %xmm1, %xmm0
setae %al
andb $0x1, %al
movb %al, -0x5c1(%rbp)
testb $0x1, -0x5c1(%rbp)
je 0xf5a54
leaq -0x5b8(%rbp), %rdi
leaq -0x580(%rbp), %rsi
callq 0x64c70
movq %rax, -0x920(%rbp)
jmp 0xf5a01
movq -0x920(%rbp), %rax
movsd (%rax), %xmm0
movsd %xmm0, -0x580(%rbp)
movsd -0x5b8(%rbp), %xmm0
ucomisd -0x580(%rbp), %xmm0
jne 0xf5a52
jp 0xf5a52
movq -0x5b0(%rbp), %rax
movq %rax, -0x578(%rbp)
movq -0x5a8(%rbp), %rax
movq %rax, -0x570(%rbp)
movq -0x5a0(%rbp), %rax
movq %rax, -0x568(%rbp)
jmp 0xf5a54
jmp 0xf5a56
jmp 0xf5a58
movl -0x584(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x584(%rbp)
jmp 0xf56db
movsd -0x580(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0xf5a8e
jp 0xf5a8e
movl -0x51c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x51c(%rbp)
movsd -0x580(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0xf5aa3
jp 0xf5aa3
jmp 0xf5ab2
movl -0x518(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x518(%rbp)
movq -0x8(%rbp), %rax
movq 0xad0(%rax), %rsi
leaq -0x6b0(%rbp), %rdi
callq 0x15b70
jmp 0xf5acb
movq -0x8(%rbp), %rax
movq 0xad0(%rax), %rax
movq %rax, -0x930(%rbp)
leaq -0x548(%rbp), %rdi
xorl %esi, %esi
callq 0xe9d70
movq %rax, -0x928(%rbp)
jmp 0xf5af4
movq -0x928(%rbp), %rax
movsd (%rax), %xmm0
movsd %xmm0, -0x940(%rbp)
leaq -0x548(%rbp), %rdi
movl $0x1, %esi
callq 0xe9d70
movq %rax, -0x938(%rbp)
jmp 0xf5b21
movq -0x938(%rbp), %rax
movsd (%rax), %xmm0
movsd %xmm0, -0x950(%rbp)
leaq -0x548(%rbp), %rdi
movl $0x2, %esi
callq 0xe9d70
movq %rax, -0x948(%rbp)
jmp 0xf5b4e
movsd -0x950(%rbp), %xmm1
movsd -0x940(%rbp), %xmm0
movq -0x930(%rbp), %rdi
movq -0x948(%rbp), %rax
movsd (%rax), %xmm2
movsd -0x528(%rbp), %xmm3
leaq -0x6b0(%rbp), %rsi
callq 0xf6dd0
jmp 0xf5b86
leaq -0x6c8(%rbp), %rdi
movq %rdi, -0x958(%rbp)
callq 0xf650
movq -0x958(%rbp), %rsi
leaq -0x6b0(%rbp), %rdi
callq 0x1b0c40
jmp 0xf5bae
leaq -0x6e0(%rbp), %rdi
callq 0xed40
movl $0x0, -0x6e4(%rbp)
movslq -0x6e4(%rbp), %rax
movq %rax, -0x960(%rbp)
leaq -0x6c8(%rbp), %rdi
callq 0xf990
movq %rax, %rcx
movq -0x960(%rbp), %rax
cmpq %rcx, %rax
jae 0xf5d07
movslq -0x6e4(%rbp), %rsi
leaq -0x6c8(%rbp), %rdi
callq 0xfc80
movq %rax, -0x968(%rbp)
jmp 0xf5c0d
movq -0x968(%rbp), %rax
movsd (%rax), %xmm0
movsd %xmm0, -0x978(%rbp)
movl -0x6e4(%rbp), %eax
incl %eax
movslq %eax, %rsi
leaq -0x6c8(%rbp), %rdi
callq 0xfc80
movq %rax, -0x970(%rbp)
jmp 0xf5c40
movq -0x970(%rbp), %rax
movsd (%rax), %xmm0
movsd %xmm0, -0x988(%rbp)
movl -0x6e4(%rbp), %eax
addl $0x2, %eax
movslq %eax, %rsi
leaq -0x6c8(%rbp), %rdi
callq 0xfc80
movq %rax, -0x980(%rbp)
jmp 0xf5c74
movsd -0x988(%rbp), %xmm1
movsd -0x978(%rbp), %xmm0
movq -0x980(%rbp), %rax
movsd (%rax), %xmm2
leaq -0x700(%rbp), %rdi
callq 0xe9c70
jmp 0xf5c9d
leaq -0x6e0(%rbp), %rdi
leaq -0x700(%rbp), %rsi
callq 0x59bf0
jmp 0xf5cb2
jmp 0xf5cb4
movl -0x6e4(%rbp), %eax
addl $0x3, %eax
movl %eax, -0x6e4(%rbp)
jmp 0xf5bc4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0xf628e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0xf6282
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x6e0(%rbp), %rdi
callq 0xefe0
jmp 0xf6282
movq $0x0, -0x708(%rbp)
leaq -0x720(%rbp), %rdi
xorps %xmm2, %xmm2
movaps %xmm2, %xmm0
movaps %xmm2, %xmm1
callq 0xe9c70
jmp 0xf5d29
movl $0x0, -0x724(%rbp)
movslq -0x724(%rbp), %rax
movq %rax, -0x990(%rbp)
leaq -0x6e0(%rbp), %rdi
callq 0x17c60
movq %rax, %rcx
movq -0x990(%rbp), %rax
cmpq %rcx, %rax
jae 0xf608d
leaq -0x548(%rbp), %rdi
xorl %esi, %esi
callq 0xe9d70
movq %rax, -0x998(%rbp)
jmp 0xf5d77
movq -0x998(%rbp), %rax
movsd (%rax), %xmm0
movsd %xmm0, -0x9a8(%rbp)
movslq -0x724(%rbp), %rsi
leaq -0x6e0(%rbp), %rdi
callq 0x59c60
movq %rax, -0x9a0(%rbp)
jmp 0xf5da6
movq -0x9a0(%rbp), %rdi
xorl %esi, %esi
callq 0xe9d70
movq %rax, -0x9b0(%rbp)
jmp 0xf5dbd
movsd -0x9a8(%rbp), %xmm0
movq -0x9b0(%rbp), %rax
movsd (%rax), %xmm1
addsd %xmm1, %xmm0
movsd %xmm0, -0x9c0(%rbp)
leaq -0x548(%rbp), %rdi
movl $0x1, %esi
callq 0xe9d70
movq %rax, -0x9b8(%rbp)
jmp 0xf5df6
movq -0x9b8(%rbp), %rax
movsd (%rax), %xmm0
movsd %xmm0, -0x9d0(%rbp)
movslq -0x724(%rbp), %rsi
leaq -0x6e0(%rbp), %rdi
callq 0x59c60
movq %rax, -0x9c8(%rbp)
jmp 0xf5e25
movq -0x9c8(%rbp), %rdi
movl $0x1, %esi
callq 0xe9d70
movq %rax, -0x9d8(%rbp)
jmp 0xf5e3f
movsd -0x9d0(%rbp), %xmm0
movq -0x9d8(%rbp), %rax
movsd (%rax), %xmm1
addsd %xmm1, %xmm0
movsd %xmm0, -0x9e8(%rbp)
leaq -0x548(%rbp), %rdi
movl $0x2, %esi
callq 0xe9d70
movq %rax, -0x9e0(%rbp)
jmp 0xf5e78
movq -0x9e0(%rbp), %rax
movsd (%rax), %xmm0
movsd %xmm0, -0x9f8(%rbp)
movslq -0x724(%rbp), %rsi
leaq -0x6e0(%rbp), %rdi
callq 0x59c60
movq %rax, -0x9f0(%rbp)
jmp 0xf5ea7
movq -0x9f0(%rbp), %rdi
movl $0x2, %esi
callq 0xe9d70
movq %rax, -0xa00(%rbp)
jmp 0xf5ec1
movsd -0x9e8(%rbp), %xmm1
movsd -0x9c0(%rbp), %xmm0
movsd -0x9f8(%rbp), %xmm2
movq -0xa00(%rbp), %rax
movsd (%rax), %xmm3
addsd %xmm3, %xmm2
leaq -0x740(%rbp), %rdi
callq 0xe9c70
jmp 0xf5ef6
movslq -0x724(%rbp), %rsi
leaq -0x6e0(%rbp), %rdi
callq 0x59c60
movq %rax, -0xa08(%rbp)
jmp 0xf5f12
movq -0xa08(%rbp), %rdi
xorl %esi, %esi
callq 0xe9d70
movq %rax, -0xa10(%rbp)
jmp 0xf5f29
movq -0xa10(%rbp), %rax
movsd (%rax), %xmm0
movsd %xmm0, -0xa20(%rbp)
movslq -0x724(%rbp), %rsi
leaq -0x6e0(%rbp), %rdi
callq 0x59c60
movq %rax, -0xa18(%rbp)
jmp 0xf5f58
movq -0xa18(%rbp), %rdi
movl $0x1, %esi
callq 0xe9d70
movq %rax, -0xa28(%rbp)
jmp 0xf5f72
movq -0xa28(%rbp), %rax
movsd (%rax), %xmm0
movsd %xmm0, -0xa38(%rbp)
movslq -0x724(%rbp), %rsi
leaq -0x6e0(%rbp), %rdi
callq 0x59c60
movq %rax, -0xa30(%rbp)
jmp 0xf5fa1
movq -0xa30(%rbp), %rdi
movl $0x2, %esi
callq 0xe9d70
movq %rax, -0xa40(%rbp)
jmp 0xf5fbb
movsd -0xa38(%rbp), %xmm1
movsd -0xa20(%rbp), %xmm0
movq -0xa40(%rbp), %rax
movsd (%rax), %xmm2
xorps %xmm5, %xmm5
movaps %xmm5, %xmm3
movaps %xmm5, %xmm4
callq 0xebaf0
movsd %xmm0, -0xa48(%rbp)
jmp 0xf5fee
movsd -0xa48(%rbp), %xmm0
movsd -0x528(%rbp), %xmm1
subsd %xmm1, %xmm0
movsd %xmm0, -0x748(%rbp)
leaq -0x708(%rbp), %rdi
leaq -0x748(%rbp), %rsi
callq 0x64c70
movq %rax, -0xa50(%rbp)
jmp 0xf6026
movq -0xa50(%rbp), %rax
movsd (%rax), %xmm0
movsd %xmm0, -0x708(%rbp)
movsd -0x748(%rbp), %xmm0
ucomisd -0x708(%rbp), %xmm0
jne 0xf6077
jp 0xf6077
movq -0x740(%rbp), %rax
movq %rax, -0x720(%rbp)
movq -0x738(%rbp), %rax
movq %rax, -0x718(%rbp)
movq -0x730(%rbp), %rax
movq %rax, -0x710(%rbp)
jmp 0xf6079
movl -0x724(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x724(%rbp)
jmp 0xf5d33
movsd -0x580(%rbp), %xmm0
movsd %xmm0, -0x750(%rbp)
movsd -0x708(%rbp), %xmm0
movsd %xmm0, -0x758(%rbp)
movsd -0x750(%rbp), %xmm0
ucomisd -0x758(%rbp), %xmm0
setae %al
andb $0x1, %al
movb %al, -0x759(%rbp)
testb $0x1, -0x759(%rbp)
je 0xf61a4
movq -0x8(%rbp), %rdi
addq $0xd20, %rdi            # imm = 0xD20
movsd -0x750(%rbp), %xmm0
addsd %xmm0, %xmm0
movsd %xmm0, -0x768(%rbp)
leaq -0x768(%rbp), %rsi
callq 0xf6d0
jmp 0xf6102
testb $0x1, -0x11(%rbp)
je 0xf61a2
leaq -0x788(%rbp), %rdi
leaq -0x548(%rbp), %rsi
leaq -0x750(%rbp), %rdx
callq 0xf6f60
jmp 0xf6128
leaq -0x480(%rbp), %rdi
leaq -0x788(%rbp), %rsi
callq 0xf6f30
jmp 0xf613d
movq -0x8(%rbp), %rsi
movq 0x998(%rsi), %rdi
addq $0x9a8, %rsi            # imm = 0x9A8
movq -0x568(%rbp), %rax
movq %rax, -0x790(%rbp)
movups -0x578(%rbp), %xmm0
movaps %xmm0, -0x7a0(%rbp)
movsd -0x750(%rbp), %xmm0
movq -0x790(%rbp), %rcx
movq %rsp, %rax
movq %rcx, 0x10(%rax)
movaps -0x7a0(%rbp), %xmm1
movups %xmm1, (%rax)
leaq -0x4b0(%rbp), %rdx
leaq -0x4c8(%rbp), %rcx
callq 0xf4770
jmp 0xf61a0
jmp 0xf61a2
jmp 0xf61a4
testb $0x1, -0x759(%rbp)
jne 0xf624a
movq -0x8(%rbp), %rdi
addq $0xd20, %rdi            # imm = 0xD20
movsd -0x758(%rbp), %xmm0
addsd %xmm0, %xmm0
movsd %xmm0, -0x7a8(%rbp)
leaq -0x7a8(%rbp), %rsi
callq 0xf6d0
jmp 0xf61de
testb $0x1, -0x11(%rbp)
je 0xf6248
leaq -0x7c8(%rbp), %rdi
leaq -0x548(%rbp), %rsi
leaq -0x758(%rbp), %rdx
callq 0xf6f60
jmp 0xf6200
leaq -0x498(%rbp), %rdi
leaq -0x7c8(%rbp), %rsi
callq 0xf6f30
jmp 0xf6215
leaq -0x7e8(%rbp), %rdi
leaq -0x720(%rbp), %rsi
leaq -0x708(%rbp), %rdx
callq 0xf6f60
jmp 0xf6231
leaq -0x4e0(%rbp), %rdi
leaq -0x7e8(%rbp), %rsi
callq 0xf6f30
jmp 0xf6246
jmp 0xf6248
jmp 0xf624a
leaq -0x6e0(%rbp), %rdi
callq 0xefe0
leaq -0x6c8(%rbp), %rdi
callq 0xf9d0
leaq -0x6b0(%rbp), %rdi
callq 0x16350
movl -0x530(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x530(%rbp)
jmp 0xf5607
leaq -0x6c8(%rbp), %rdi
callq 0xf9d0
leaq -0x6b0(%rbp), %rdi
callq 0x16350
jmp 0xf6475
cvtsi2sdl -0x514(%rbp), %xmm0
movq -0x8(%rbp), %rax
cvtsi2sdl 0xc78(%rax), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0x7f0(%rbp)
cvtsi2sdl -0x518(%rbp), %xmm0
movq -0x8(%rbp), %rax
cvtsi2sdl 0xc78(%rax), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0x7f8(%rbp)
cvtsi2sdl -0x51c(%rbp), %xmm0
movq -0x8(%rbp), %rax
cvtsi2sdl 0xc78(%rax), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0x800(%rbp)
movq -0x10(%rbp), %rdi
movq -0x8(%rbp), %rax
movq %rax, %rdx
addq $0xd20, %rdx            # imm = 0xD20
movl -0x514(%rbp), %ecx
movsd -0x7f8(%rbp), %xmm1
movsd -0x800(%rbp), %xmm2
movl 0xc78(%rax), %r8d
movsd 0x101072(%rip), %xmm0   # 0x1f73a8
movl $0x3e8, %esi            # imm = 0x3E8
callq 0xf48c0
jmp 0xf6342
leaq 0x10638f(%rip), %rdi    # 0x1fc6d8
xorl %eax, %eax
callq 0x5070
jmp 0xf6352
testb $0x1, -0x11(%rbp)
je 0xf63ee
leaq -0x268(%rbp), %rdi
leaq -0x480(%rbp), %rsi
leaq -0x498(%rbp), %rdx
leaq -0x4f8(%rbp), %rcx
leaq -0x510(%rbp), %r8
xorl %r9d, %r9d
movsd 0xfc3ee(%rip), %xmm1    # 0x1f2778
movaps %xmm1, %xmm0
callq 0xf4dc0
jmp 0xf6394
leaq 0x106362(%rip), %rdi    # 0x1fc6fd
xorl %eax, %eax
callq 0x5070
jmp 0xf63a4
leaq -0x468(%rbp), %rdi
leaq -0x4c8(%rbp), %rsi
leaq -0x4e0(%rbp), %rdx
leaq -0x4f8(%rbp), %rcx
leaq -0x510(%rbp), %r8
xorl %r9d, %r9d
movsd 0xfc3a6(%rip), %xmm1    # 0x1f2778
movaps %xmm1, %xmm0
callq 0xf4dc0
jmp 0xf63dc
leaq 0x106333(%rip), %rdi    # 0x1fc716
xorl %eax, %eax
callq 0x5070
jmp 0xf63ec
jmp 0xf63ee
leaq -0x510(%rbp), %rdi
callq 0xf9d0
leaq -0x4f8(%rbp), %rdi
callq 0xf9d0
leaq -0x4e0(%rbp), %rdi
callq 0xf6fa0
leaq -0x4c8(%rbp), %rdi
callq 0xf6fa0
leaq -0x4b0(%rbp), %rdi
callq 0xec80
leaq -0x498(%rbp), %rdi
callq 0xf6fa0
leaq -0x480(%rbp), %rdi
callq 0xf6fa0
leaq -0x468(%rbp), %rdi
callq 0x5780
leaq -0x268(%rbp), %rdi
callq 0x5780
leaq -0x58(%rbp), %rdi
callq 0x5300
leaq -0x38(%rbp), %rdi
callq 0x5300
addq $0xa70, %rsp            # imm = 0xA70
popq %rbp
retq
leaq -0x510(%rbp), %rdi
callq 0xf9d0
leaq -0x4f8(%rbp), %rdi
callq 0xf9d0
leaq -0x4e0(%rbp), %rdi
callq 0xf6fa0
leaq -0x4c8(%rbp), %rdi
callq 0xf6fa0
leaq -0x4b0(%rbp), %rdi
callq 0xec80
leaq -0x498(%rbp), %rdi
callq 0xf6fa0
leaq -0x480(%rbp), %rdi
callq 0xf6fa0
leaq -0x468(%rbp), %rdi
callq 0x5780
leaq -0x268(%rbp), %rdi
callq 0x5780
leaq -0x58(%rbp), %rdi
callq 0x5300
leaq -0x38(%rbp), %rdi
callq 0x5300
movq -0x60(%rbp), %rdi
callq 0x58f0
nopl (%rax)