// File: /workspace/github_cpp_makefile_star2_O1/Luthaf[P]zeopp/networkanalysis.cc
// Function: identifyCages(ATOM_NETWORK*, VORONOI_NETWORK*, DIJKSTRA_NETWORK*, double, bool, std::basic_fstream<char, std::char_traits<char>>&, std::vector<CAGE, std::allocator<CAGE>>&)
void identifyCages(ATOM_NETWORK *atmnet, VORONOI_NETWORK *vornet, DIJKSTRA_NETWORK *dnet, double probeRadius, bool visualize, fstream &output, vector<CAGE> &cages) {
  vector<bool> nodeProcessed = vector<bool>(dnet->nodes.size(), false);
  vector<double> bestRadii   = vector<double>(dnet->nodes.size(), -1);
  unsigned int nodeIndex = 0;

  double maxRadius = 0.0;
  DELTA_POS filter(1,1,1);

  // Iterate over all nodes
  while(nodeIndex < nodeProcessed.size()){
   
    // Place starting node on stack with (0,0,0) displacement
    DELTA_POS displacement(0,0,0);
    map<int, pair<DELTA_POS, double> > visitedNodes;
    
    HEAP<pair<int, pair<DELTA_POS, double> > > heap (betterPath);
    heap.insert(pair<int, pair<DELTA_POS, double> > (nodeIndex, pair<DELTA_POS, double> (displacement, dnet->nodes[nodeIndex].max_radius)));
  
    while(heap.size() != 0){
      // Remove best remaining path
      pair<int, pair<DELTA_POS, double> > pathInfo = heap.pop();
      map<int, pair<DELTA_POS, double> >::iterator nodeInfo = visitedNodes.find(pathInfo.first);
      
      // Ending on a preprocessed node
      if(pathInfo.first == -1){
	bestRadii[nodeIndex] = pathInfo.second.second;
	break;
      }

      if(nodeInfo != visitedNodes.end()){
	if(nodeInfo->second.first.equals(pathInfo.second.first)){
	  // Circling back to previous node so terminate path
	  continue;
	}
	else {
	  // Found the optimal path through the start node
	  bestRadii[nodeIndex] = min(pathInfo.second.second, nodeInfo->second.second);
	  maxRadius = max(maxRadius, bestRadii[nodeIndex]);
	  break;
	}
      }
      else{
	visitedNodes.insert(pathInfo);
	DIJKSTRA_NODE currentNode = dnet->nodes[pathInfo.first];
	vector<CONN>::iterator connIter = currentNode.connections.begin();
	// Follow all edges leading to adjoining nodes
      
	while(connIter != currentNode.connections.end()){
	  int to = connIter->to;
	  if(nodeProcessed[to]){
	    // Know the best radii for this path because the next node has already been processed
	    // Change the path's node id to -1 to denote this
	    heap.insert(pair<int, pair<DELTA_POS, double> > (-1, pair<DELTA_POS, double> (DELTA_POS(0,0,0), min(connIter->max_radius, min(pathInfo.second.second, bestRadii[to])))));
	  }
	  else{
	    DELTA_POS newDisplacement = pathInfo.second.first + (connIter->deltaPos*filter);
	    heap.insert(pair<int, pair<DELTA_POS, double> > (to, pair<DELTA_POS, double> (newDisplacement, 
											  min(dnet->nodes[to].max_radius, min(pathInfo.second.second, connIter->max_radius)))));
	  }
	  connIter++;
	}
      }
    }
    nodeProcessed[nodeIndex] = true;
    nodeIndex++;
  }

  double CUTOFF_RATIO = 0.8; 

  // Identify nodes that satisfy cage criteria
  set<int> cageElements;
  for(unsigned int i = 0; i < vornet->nodes.size(); i++){
    double ratio = bestRadii[i]/(dnet->nodes[i].max_radius);
    if(ratio < CUTOFF_RATIO && bestRadii[i] > probeRadius) {
      cageElements.insert(i);
    }
  }
  
  // Calculate node overlaps
  vector< vector<double> > overlapFractions = calculateNodeOverlap(atmnet, vornet);

  // Cluster nodes in cages
  vector< set<int> > clusters = clusterElements(cageElements, overlapFractions, 0.1);


  //vector<CAGE> cages;
  for(unsigned int i = 0; i < clusters.size(); i++){
    cages.push_back(CAGE(clusters[i], atmnet, vornet));
  }

  if(visualize){
    output << "set num_cages " << clusters.size() << "\n";
    for(unsigned int i = 0; i < cages.size(); i++){
      cages[i].writeToVMD(i, output);
    }
  }
  else{
    vector<double> cageRadii;
    for(unsigned int i = 0; i < cages.size(); i++){
      cageRadii.push_back(cages[i].getRadius());
    }

     sort(cageRadii.begin(), cageRadii.end());
    
    vector<int> counts;
    vector<double> radii;
    double prevRad = -1, tolerance = 0.001;
    int numCageTypes = 0;
    for(unsigned int i = 0; i < cageRadii.size(); i++){
      if(abs(cageRadii[i] - prevRad) < tolerance)
	counts[numCageTypes - 1]++;
      else{
	counts.push_back(1); radii.push_back(cageRadii[i]);
	prevRad = cageRadii[i];	numCageTypes++;
      }
    }

    double totalCageAV = 0;
    output << "Note: Probe radius is subtracted from cage radius" << "\n";
    for(unsigned int i = 0; i < counts.size(); i++){
      output << counts[i] << " cage(s) of radius " << radii[i] - probeRadius << "\n";
      totalCageAV += calcSphereVolume(radii[i] - probeRadius)*counts[i];
    }
    output << "Total Cage AV: " << totalCageAV << " A^3" << "\n";
    double volumeFraction = totalCageAV/calcDeterminant(atmnet->ucVectors);
    double rho_crystal    = calcDensity(atmnet);
    double cageAVPerMass  = volumeFraction/rho_crystal;
    output << "Total Cage AV/Mass: " << cageAVPerMass << " cm^3/g" <<  "\n";
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x2c8, %rsp            # imm = 0x2C8
movq %r9, 0x70(%rsp)
movq %r8, %r12
movl %ecx, 0xe0(%rsp)
movsd %xmm0, 0xd8(%rsp)
movq %rdx, %r15
movq %rsi, 0xa0(%rsp)
movq %rdi, 0xd0(%rsp)
movq 0x8(%rdx), %rsi
subq (%rdx), %rsi
sarq $0x3, %rsi
movabsq $-0x71c71c71c71c71c7, %r14 # imm = 0x8E38E38E38E38E39
imulq %r14, %rsi
leaq 0x140(%rsp), %rbx
movb $0x0, (%rbx)
leaq 0xa8(%rsp), %rdi
leaq 0x108(%rsp), %rcx
movq %rbx, %rdx
callq 0x383b0
movq 0x8(%r15), %rsi
movq %r15, 0x20(%rsp)
subq (%r15), %rsi
sarq $0x3, %rsi
imulq %r14, %rsi
movabsq $-0x4010000000000000, %rax # imm = 0xBFF0000000000000
movq %rax, (%rbx)
leaq 0x1c8(%rsp), %rdi
leaq 0x140(%rsp), %rdx
leaq 0x108(%rsp), %rcx
callq 0x3871a
leaq 0x21c(%rsp), %rdi
movl $0x1, %esi
movl $0x1, %edx
movl $0x1, %ecx
callq 0x509d8
movq 0xb8(%rsp), %rax
movl 0xc0(%rsp), %ecx
subq 0xa8(%rsp), %rax
shlq $0x3, %rax
addq %rcx, %rax
movq %r12, 0x138(%rsp)
je 0x36e0b
movabsq $-0x8000000000000000, %r14 # imm = 0x8000000000000000
leaq 0x110(%rsp), %rbp
leaq 0x230(%rsp), %r13
leaq 0x88(%rsp), %rbx
movq $0x0, 0x28(%rsp)
movl $0x0, 0x78(%rsp)
leaq 0x30(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x509d8
movl $0x0, 0x110(%rsp)
xorl %eax, %eax
movq %rax, 0x118(%rsp)
movq %rbp, 0x120(%rsp)
movq %rbp, 0x128(%rsp)
movq %rax, 0x130(%rsp)
leaq 0xe8(%rsp), %r15
movq %r15, %rdi
leaq -0x1968(%rip), %rsi     # 0x35049
callq 0x3879c
movq 0x20(%rsp), %rax
movq (%rax), %rax
movq 0x28(%rsp), %rcx
leaq (%rcx,%rcx,8), %rcx
movl 0x38(%rsp), %edx
movl %edx, 0x148(%rsp)
movq 0x30(%rsp), %rdx
movq %rdx, 0x140(%rsp)
movsd 0x38(%rax,%rcx,8), %xmm0
movl 0x78(%rsp), %eax
movl %eax, 0x248(%rsp)
movq 0x140(%rsp), %rax
leaq 0x250(%rsp), %rcx
movq %rax, (%rcx)
movl 0x148(%rsp), %eax
movl %eax, 0x8(%rcx)
movl 0x14c(%rsp), %eax
movl %eax, 0xc(%rcx)
movsd %xmm0, 0x260(%rsp)
movupd 0x248(%rsp), %xmm0
movupd 0x258(%rsp), %xmm1
movupd %xmm1, 0x10(%rsp)
movupd %xmm0, (%rsp)
movq %r15, %rdi
callq 0x387de
movq 0xf0(%rsp), %rax
subq 0xe8(%rsp), %rax
movabsq $0x1fffffffe0, %rcx     # imm = 0x1FFFFFFFE0
testq %rcx, %rax
je 0x36d88
leaq 0x80(%rsp), %rdi
leaq 0xe8(%rsp), %rsi
callq 0x38914
movq 0x118(%rsp), %rcx
movq %rbp, %rax
testq %rcx, %rcx
je 0x36aae
movl 0x80(%rsp), %edx
movq %rbp, %rax
xorl %esi, %esi
cmpl %edx, 0x20(%rcx)
setl %sil
cmovgeq %rcx, %rax
movq 0x10(%rcx,%rsi,8), %rcx
testq %rcx, %rcx
jne 0x36a97
movq %rbp, %r15
cmpq %rbp, %rax
je 0x36ac7
movl 0x80(%rsp), %ecx
cmpl 0x20(%rax), %ecx
cmovlq %rbp, %rax
movq %rax, %r15
cmpl $-0x1, 0x80(%rsp)
je 0x36d54
leaq 0x110(%rsp), %rax
cmpq %rax, %r15
je 0x36b07
leaq 0x28(%r15), %rdi
movq 0x88(%rsp), %rsi
movl 0x90(%rsp), %edx
callq 0x509e2
testb %al, %al
jne 0x36d27
jmp 0x36d5f
leaq 0x108(%rsp), %rdi
leaq 0x80(%rsp), %rsi
callq 0x3b58c
movq %r14, %rbp
movq %r13, %r14
movq %rbx, %r13
movslq 0x80(%rsp), %rax
movq 0x20(%rsp), %rcx
movq (%rcx), %r15
leaq (%rax,%rax,8), %r12
leaq 0x20(%r15,%r12,8), %rsi
movupd -0x20(%rsi), %xmm0
movupd -0x10(%rsi), %xmm1
movapd %xmm0, 0x140(%rsp)
movapd %xmm1, 0x150(%rsp)
leaq 0x160(%rsp), %rbx
movq %rbx, %rdi
callq 0x38318
leaq (%r15,%r12,8), %rax
movb 0x40(%rax), %cl
movb %cl, 0x20(%rbx)
movq 0x38(%rax), %rax
movq %rax, 0x18(%rbx)
movq 0x160(%rsp), %r15
cmpq 0x168(%rsp), %r15
movq %r13, %rbx
movq %r14, %r13
movq %rbp, %r14
leaq 0xe8(%rsp), %rbp
je 0x36d02
addq $0x18, %r15
movslq -0x14(%r15), %r12
leaq 0x3f(%r12), %rax
testq %r12, %r12
cmovnsq %r12, %rax
sarq $0x6, %rax
shlq $0x3, %rax
addq 0xa8(%rsp), %rax
leaq 0x3f(%r14), %rcx
andq %r12, %rcx
xorl %edx, %edx
cmpq %r14, %rcx
setbe %dl
movq -0x8(%rax,%rdx,8), %rax
btq %r12, %rax
jae 0x36c5d
leaq 0x50(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x509d8
movq 0x1c8(%rsp), %rax
movsd (%rax,%r12,8), %xmm0
minsd 0x98(%rsp), %xmm0
movl 0x58(%rsp), %eax
minsd -0x8(%r15), %xmm0
movl %eax, 0x8(%r13)
movq 0x50(%rsp), %rax
movq %rax, (%r13)
movl $0xffffffff, 0x228(%rsp) # imm = 0xFFFFFFFF
movsd %xmm0, 0x240(%rsp)
movupd 0x228(%rsp), %xmm0
movupd 0x238(%rsp), %xmm1
movupd %xmm1, 0x10(%rsp)
movupd %xmm0, (%rsp)
movq %rbp, %rdi
callq 0x387de
jmp 0x36ce9
movq %r15, %rdi
leaq 0x21c(%rsp), %rsi
callq 0x50a14
movq %rax, 0x50(%rsp)
movl %edx, 0x58(%rsp)
movq %rbx, %rdi
leaq 0x50(%rsp), %rsi
callq 0x50a30
movq 0x20(%rsp), %rcx
movq (%rcx), %rcx
leaq (%r12,%r12,8), %rsi
movsd -0x8(%r15), %xmm0
minsd 0x98(%rsp), %xmm0
minsd 0x38(%rcx,%rsi,8), %xmm0
movl %r12d, 0x1e0(%rsp)
movq %rax, 0x1e8(%rsp)
movl %edx, 0x1f0(%rsp)
movsd %xmm0, 0x1f8(%rsp)
movupd 0x1e0(%rsp), %xmm0
movupd 0x1f0(%rsp), %xmm1
movupd %xmm1, 0x10(%rsp)
movupd %xmm0, (%rsp)
movq %rbp, %rdi
callq 0x387de
leaq 0x28(%r15), %rax
addq $0x10, %r15
cmpq 0x168(%rsp), %r15
movq %rax, %r15
jne 0x36ba7
movq 0x160(%rsp), %rdi
testq %rdi, %rdi
je 0x36d1f
movq 0x170(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movq 0x138(%rsp), %r12
movq 0xf0(%rsp), %rax
subq 0xe8(%rsp), %rax
movabsq $0x1fffffffe0, %rcx     # imm = 0x1FFFFFFFE0
testq %rcx, %rax
leaq 0x110(%rsp), %rbp
jne 0x36a68
jmp 0x36d88
movsd 0x98(%rsp), %xmm0
jmp 0x36d6e
movsd 0x38(%r15), %xmm0
minsd 0x98(%rsp), %xmm0
movq 0x1c8(%rsp), %rax
movq 0x28(%rsp), %rcx
movsd %xmm0, (%rax,%rcx,8)
leaq 0x110(%rsp), %rbp
movq 0xa8(%rsp), %rax
movq 0x28(%rsp), %rcx
movq %rcx, %rdx
movl $0x1, %esi
shlq %cl, %rsi
shrq $0x6, %rdx
orq %rsi, (%rax,%rdx,8)
movq 0xe8(%rsp), %rdi
testq %rdi, %rdi
je 0x36dc5
movq 0xf8(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movl 0x78(%rsp), %r15d
incl %r15d
leaq 0x108(%rsp), %rdi
callq 0x393e0
movl %r15d, 0x78(%rsp)
movl %r15d, %edx
movq 0xb8(%rsp), %rax
movl 0xc0(%rsp), %ecx
subq 0xa8(%rsp), %rax
leaq (%rcx,%rax,8), %rax
movq %rdx, 0x28(%rsp)
cmpq %rdx, %rax
ja 0x36962
leaq 0x110(%rsp), %rax
movl $0x0, (%rax)
xorl %r15d, %r15d
movq %r15, 0x8(%rax)
movq %rax, 0x10(%rax)
movq %rax, 0x18(%rax)
movq %r15, 0x20(%rax)
movq 0xa0(%rsp), %rcx
movq 0x50(%rcx), %rax
cmpq 0x48(%rcx), %rax
je 0x36eb6
leaq 0x108(%rsp), %rbx
leaq 0x140(%rsp), %r14
movq 0x1c8(%rsp), %rax
movsd (%rax,%r15,8), %xmm0
ucomisd 0xd8(%rsp), %xmm0
jbe 0x36e9a
movq 0x20(%rsp), %rax
movq (%rax), %rax
leaq (%r15,%r15,8), %rcx
divsd 0x38(%rax,%rcx,8), %xmm0
movsd 0x11c447(%rip), %xmm1   # 0x1532c8
ucomisd %xmm0, %xmm1
jbe 0x36e9a
movl %r15d, 0x140(%rsp)
movq %rbx, %rdi
movq %r14, %rsi
callq 0x3bc54
incl %r15d
movq 0xa0(%rsp), %rcx
movq 0x50(%rcx), %rax
subq 0x48(%rcx), %rax
sarq $0x6, %rax
cmpq %r15, %rax
ja 0x36e4e
leaq 0xe8(%rsp), %rdi
movq 0xd0(%rsp), %rsi
movq 0xa0(%rsp), %rdx
callq 0x35702
leaq 0x268(%rsp), %rdi
leaq 0x108(%rsp), %rsi
callq 0x11076
leaq 0x200(%rsp), %rdi
leaq 0xe8(%rsp), %rsi
callq 0xeec6
leaq 0x80(%rsp), %rdi
leaq 0x268(%rsp), %rsi
leaq 0x200(%rsp), %rdx
movsd 0x11814b(%rip), %xmm0   # 0x14f068
callq 0x35a08
leaq 0x200(%rsp), %rdi
callq 0xef60
leaq 0x268(%rsp), %rdi
callq 0xf168
movq 0x80(%rsp), %rax
movabsq $-0x5555555555555555, %r15 # imm = 0xAAAAAAAAAAAAAAAB
cmpq %rax, 0x88(%rsp)
je 0x37020
movl $0x1, %ebp
xorl %ecx, %ecx
leaq 0x298(%rsp), %rbx
leaq 0x140(%rsp), %r14
leaq (%rcx,%rcx,2), %rsi
shlq $0x4, %rsi
addq %rax, %rsi
movq %rbx, %rdi
callq 0x11076
movq %r14, %rdi
movq %rbx, %rsi
movq 0xd0(%rsp), %rdx
movq 0xa0(%rsp), %rcx
callq 0x36506
movq 0x70(%rsp), %rdi
movq %r14, %rsi
callq 0x3bcfe
movq 0x188(%rsp), %rdi
testq %rdi, %rdi
je 0x36fcb
movq 0x198(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movq 0x170(%rsp), %rdi
testq %rdi, %rdi
je 0x36fe8
movq 0x180(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movq %r14, %rdi
callq 0xf118
movq %rbx, %rdi
callq 0xf168
movl %ebp, %ecx
movq 0x80(%rsp), %rax
movq 0x88(%rsp), %rdx
subq %rax, %rdx
sarq $0x4, %rdx
imulq %r15, %rdx
incl %ebp
cmpq %rcx, %rdx
ja 0x36f73
cmpb $0x0, 0xe0(%rsp)
je 0x370c4
leaq 0x10(%r12), %rbx
leaq 0x11c41f(%rip), %rsi    # 0x153459
movl $0xe, %edx
movq %rbx, %rdi
callq 0x44e0
movq 0x88(%rsp), %rsi
subq 0x80(%rsp), %rsi
sarq $0x4, %rsi
imulq %r15, %rsi
movq %rbx, %rdi
callq 0x42b0
leaq 0x11e4c0(%rip), %rsi    # 0x15552e
movl $0x1, %edx
movq %rax, %rdi
callq 0x44e0
movq 0x70(%rsp), %rcx
movq (%rcx), %rax
cmpq %rax, 0x8(%rcx)
je 0x374e8
xorl %edi, %edi
xorl %ebx, %ebx
shlq $0x7, %rdi
addq %rax, %rdi
movl %ebx, %esi
movq %r12, %rdx
callq 0x366ac
incl %ebx
movq 0x70(%rsp), %rcx
movq (%rcx), %rax
movq 0x8(%rcx), %rcx
subq %rax, %rcx
sarq $0x7, %rcx
movq %rbx, %rdi
cmpq %rbx, %rcx
ja 0x37091
jmp 0x374e8
xorpd %xmm0, %xmm0
movapd %xmm0, 0x140(%rsp)
movq $0x0, 0x150(%rsp)
movq 0x70(%rsp), %rcx
movq (%rcx), %rax
cmpq %rax, 0x8(%rcx)
je 0x3715a
movl $0x1, %ebp
xorl %ecx, %ecx
leaq 0x140(%rsp), %rbx
leaq 0x30(%rsp), %r14
shlq $0x7, %rcx
movsd 0x78(%rax,%rcx), %xmm0
movsd %xmm0, 0x30(%rsp)
movq 0x148(%rsp), %rsi
cmpq 0x150(%rsp), %rsi
je 0x37133
movsd %xmm0, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x148(%rsp)
jmp 0x3713e
movq %rbx, %rdi
movq %r14, %rdx
callq 0x139c2
movl %ebp, %ecx
movq 0x70(%rsp), %rdx
movq (%rdx), %rax
movq 0x8(%rdx), %rdx
subq %rax, %rdx
sarq $0x7, %rdx
incl %ebp
cmpq %rcx, %rdx
ja 0x370ff
movq 0x140(%rsp), %rbx
movq 0x148(%rsp), %r14
cmpq %r14, %rbx
je 0x3719c
movq %r14, %rax
subq %rbx, %rax
sarq $0x3, %rax
bsrq %rax, %rdx
xorl $0x3f, %edx
addl %edx, %edx
xorq $0x7e, %rdx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x3c033
movq %rbx, %rdi
movq %r14, %rsi
callq 0x3c12c
xorpd %xmm0, %xmm0
movapd %xmm0, 0x30(%rsp)
xorl %r12d, %r12d
movq %r12, 0x40(%rsp)
movq %r12, 0x60(%rsp)
movapd %xmm0, 0x50(%rsp)
movq 0x140(%rsp), %rax
cmpq %rax, 0x148(%rsp)
je 0x372bf
movsd 0x11c0f9(%rip), %xmm0   # 0x1532d0
movl $0x1, %ebp
leaq 0x30(%rsp), %rbx
leaq 0xe4(%rsp), %r14
leaq 0x50(%rsp), %r15
xorl %r13d, %r13d
movsd (%rax,%r13,8), %xmm1
subsd %xmm0, %xmm1
andpd 0x117e8d(%rip), %xmm1   # 0x14f090
movsd 0x117e3d(%rip), %xmm2   # 0x14f048
ucomisd %xmm1, %xmm2
jbe 0x3721f
movq 0x30(%rsp), %rax
movslq %r12d, %rcx
incl -0x4(%rax,%rcx,4)
jmp 0x3729a
movl $0x1, 0xe4(%rsp)
movq 0x38(%rsp), %rsi
cmpq 0x40(%rsp), %rsi
je 0x37247
movl $0x1, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x38(%rsp)
jmp 0x37252
movq %rbx, %rdi
movq %r14, %rdx
callq 0x1422c
leaq (,%r13,8), %rdx
addq 0x140(%rsp), %rdx
movq 0x58(%rsp), %rsi
cmpq 0x60(%rsp), %rsi
je 0x37281
movsd (%rdx), %xmm0
movsd %xmm0, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x58(%rsp)
jmp 0x37289
movq %r15, %rdi
callq 0x148c4
movq 0x140(%rsp), %rax
movsd (%rax,%r13,8), %xmm0
incl %r12d
movl %ebp, %r13d
movq 0x140(%rsp), %rax
movq 0x148(%rsp), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
incl %ebp
cmpq %r13, %rcx
ja 0x371f1
movq 0x138(%rsp), %r13
addq $0x10, %r13
leaq 0x11c196(%rip), %rsi    # 0x153468
movl $0x31, %edx
movq %r13, %rdi
callq 0x44e0
leaq 0x11e248(%rip), %rsi    # 0x15552e
movl $0x1, %edx
movq %r13, %rdi
callq 0x44e0
movq 0x30(%rsp), %rax
cmpq %rax, 0x38(%rsp)
je 0x373c5
xorpd %xmm0, %xmm0
movsd %xmm0, 0x20(%rsp)
movl $0x1, %ebp
xorl %r12d, %r12d
leaq 0x11c17e(%rip), %rbx    # 0x15349a
leaq 0x11e20b(%rip), %r14    # 0x15552e
movl (%rax,%r12,4), %esi
movq %r13, %rdi
callq 0x4750
movq %rax, %r15
movl $0x13, %edx
movq %rax, %rdi
movq %rbx, %rsi
callq 0x44e0
movq 0x50(%rsp), %rax
movsd (%rax,%r12,8), %xmm0
subsd 0xd8(%rsp), %xmm0
movq %r15, %rdi
callq 0x46b0
movl $0x1, %edx
movq %rax, %rdi
movq %r14, %rsi
callq 0x44e0
movq 0x50(%rsp), %rax
movsd (%rax,%r12,8), %xmm0
subsd 0xd8(%rsp), %xmm0
callq 0x868e5
movq 0x30(%rsp), %rax
xorps %xmm1, %xmm1
cvtsi2sdl (%rax,%r12,4), %xmm1
movq 0x38(%rsp), %rcx
mulsd %xmm1, %xmm0
movsd 0x20(%rsp), %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, 0x20(%rsp)
movl %ebp, %r12d
subq %rax, %rcx
sarq $0x2, %rcx
incl %ebp
cmpq %r12, %rcx
ja 0x37323
jmp 0x373cf
xorpd %xmm0, %xmm0
movsd %xmm0, 0x20(%rsp)
leaq 0x11c0d8(%rip), %rsi    # 0x1534ae
movl $0xf, %edx
movq %r13, %rdi
callq 0x44e0
movq %r13, %rdi
movsd 0x20(%rsp), %xmm0
callq 0x46b0
movq %rax, %rbx
leaq 0x11c0c3(%rip), %rsi    # 0x1534be
movl $0x4, %edx
movq %rax, %rdi
callq 0x44e0
leaq 0x11e11f(%rip), %rsi    # 0x15552e
movl $0x1, %edx
movq %rbx, %rdi
callq 0x44e0
movq 0xd0(%rsp), %rbx
leaq 0x80(%rbx), %rdi
callq 0x84ffd
movsd %xmm0, 0x28(%rsp)
movq %rbx, %rdi
callq 0x3c9c8
movsd %xmm0, 0x78(%rsp)
leaq 0x11c078(%rip), %rsi    # 0x1534c3
movl $0x14, %edx
movq %r13, %rdi
callq 0x44e0
movsd 0x20(%rsp), %xmm0
divsd 0x28(%rsp), %xmm0
divsd 0x78(%rsp), %xmm0
movq %r13, %rdi
callq 0x46b0
movq %rax, %rbx
leaq 0x11c05c(%rip), %rsi    # 0x1534d8
movl $0x7, %edx
movq %rax, %rdi
callq 0x44e0
leaq 0x11e09e(%rip), %rsi    # 0x15552e
movl $0x1, %edx
movq %rbx, %rdi
callq 0x44e0
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0x374b4
movq 0x60(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x374cb
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movq 0x140(%rsp), %rdi
testq %rdi, %rdi
je 0x374e8
movq 0x150(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
leaq 0x80(%rsp), %rdi
callq 0xf4f6
leaq 0xe8(%rsp), %rdi
callq 0xef60
leaq 0x108(%rsp), %rdi
callq 0xf168
movq 0x1c8(%rsp), %rdi
testq %rdi, %rdi
je 0x3752c
movq 0x1d8(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movq 0xa8(%rsp), %rdi
testq %rdi, %rdi
je 0x37571
movq 0xc8(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
xorl %eax, %eax
movq %rax, 0xa8(%rsp)
movl %eax, 0xb0(%rsp)
movq %rax, 0xb8(%rsp)
movl %eax, 0xc0(%rsp)
movq %rax, 0xc8(%rsp)
addq $0x2c8, %rsp            # imm = 0x2C8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x3761b
jmp 0x3761b
jmp 0x375d4
movq %rax, %rbx
leaq 0x200(%rsp), %rdi
callq 0xef60
jmp 0x375a4
movq %rax, %rbx
leaq 0x268(%rsp), %rdi
callq 0xf168
jmp 0x37676
movq %rax, %rbx
jmp 0x37676
jmp 0x375db
jmp 0x375e3
movq %rax, %rbx
jmp 0x37704
jmp 0x375f0
jmp 0x3761b
jmp 0x3761b
jmp 0x3761b
jmp 0x3761b
movq %rax, %rbx
jmp 0x3764c
jmp 0x375f0
movq %rax, %rbx
jmp 0x37683
movq %rax, %rbx
jmp 0x376e7
jmp 0x37694
movq %rax, %rbx
jmp 0x37669
movq %rax, %rbx
leaq 0x140(%rsp), %rdi
callq 0x38abe
jmp 0x3760a
movq %rax, %rbx
leaq 0x298(%rsp), %rdi
callq 0xf168
jmp 0x37669
jmp 0x37694
movq %rax, %rbx
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0x37635
movq 0x60(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x3764c
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movq 0x140(%rsp), %rdi
testq %rdi, %rdi
je 0x37669
movq 0x150(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
leaq 0x80(%rsp), %rdi
callq 0xf4f6
leaq 0xe8(%rsp), %rdi
callq 0xef60
leaq 0x108(%rsp), %rdi
callq 0xf168
jmp 0x376e7
jmp 0x37694
movq %rax, %rbx
jmp 0x376bd
jmp 0x3769d
jmp 0x3769d
movq %rax, %rbx
movq 0x160(%rsp), %rdi
testq %rdi, %rdi
je 0x376bd
movq 0x170(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movq 0xe8(%rsp), %rdi
testq %rdi, %rdi
je 0x376da
movq 0xf8(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
leaq 0x108(%rsp), %rdi
callq 0x393e0
movq 0x1c8(%rsp), %rdi
testq %rdi, %rdi
je 0x37704
movq 0x1d8(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movq 0xa8(%rsp), %rdi
testq %rdi, %rdi
je 0x37749
movq 0xc8(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
xorl %eax, %eax
movq %rax, 0xa8(%rsp)
movl %eax, 0xb0(%rsp)
movq %rax, 0xb8(%rsp)
movl %eax, 0xc0(%rsp)
movq %rax, 0xc8(%rsp)
movq %rbx, %rdi
callq 0x4780