// File: /workspace/github_cpp_makefile_star2_O1/Luthaf[P]zeopp/channel.cc
// Function: PORE::getRestrictingDiameters(int, std::vector<int, std::allocator<int>>, std::vector<std::vector<double, std::allocator<double>>, std::allocator<std::vector<double, std::allocator<double>>>>*, std::vector<std::vector<std::pair<int, int>, std::allocator<std::pair<int, int>>>, std::allocator<std::vector<std::pair<int, int>, std::allocator<std::pair<int, int>>>>>*, std::vector<double, std::allocator<double>>*, std::vector<int, std::allocator<int>>*, std::vector<double, std::allocator<double>>*, std::vector<int, std::allocator<int>>*)
void PORE::getRestrictingDiameters(int nSegments, vector<int> vorNetID, vector< vector<double> > *PLDtable, vector< vector< pair<int,int> > > *PLDEdgeTable, 
                                  vector<double> *segmentDi, vector<int> *segmentDiNodeID, vector <double> *segmentDiFinal, vector<int> *segmentDiFinalNodeID){
    //Define three access types
    const int ACCESSED   =  1;
    const int UNKNOWN      = -1;

    // flag that is used to terminate the search
    
    bool node2FoundFlag = false;

    // Make a local copy of nodes vector as it will be modified
    vector<DIJKSTRA_NODE> lnodes = nodes;
    
    // Initialize the unit cell position of each node
    vector<DELTA_POS> directions = vector<DELTA_POS> (lnodes.size(), DELTA_POS(0,0,0));
    
    // Initialize the status of each node as UNKNOWN
    vector<int> accessStatuses = vector<int> (lnodes.size(), UNKNOWN);
    unsigned int nodeIndex = 0;
    
    double di,df;

    if(nSegments < 1){
      cerr << "Number of semgents lower than 1. This function should not be called.\n" << "\n";
      abort();
      };

//debug
//for(unsigned int i=0; i<vorNetID.size();i++) cout << vorNetID[i] << "  ";


    // Need to translate IDs from the original Voronoi network to PORE ids 

    vector <int> PoreNodesSegmentIDs; // will store segment ID for each node in the current PORE

    PoreNodesSegmentIDs.resize(nodes.size(), -1);

    int nSegPresent = 0;
    for(unsigned int i=0; i<nodes.size(); i++)
       {
       int VnodeID = reverseIDMappings.find(i)->second;
       if(vorNetID[VnodeID] >= 0)
         {
         PoreNodesSegmentIDs[i] = vorNetID[VnodeID]; 
         nSegPresent++;
         };

       };

    cout << "Current PORE contains " << nSegPresent << " nodes in predefined segments. Proceeding with Restricting Diameter Calcs\n";

    // Start analysis by accepting all nodes already assigned to segments (segment seed nodes)
    // Store information about largest node pre-assigned to each segment

    for(unsigned int i=0; i<nodes.size(); i++)
       {
       if(PoreNodesSegmentIDs[i] > -1) 
          {
          accessStatuses[i] = ACCESSED;   
          directions[i] = DELTA_POS(0,0,0); // not sure about this line
          
          if(segmentDi->at(PoreNodesSegmentIDs[i]) < nodes.at(i).max_radius*2) 
             {
             segmentDi->at(PoreNodesSegmentIDs[i]) = nodes.at(i).max_radius*2;
             segmentDiNodeID->at(PoreNodesSegmentIDs[i]) = reverseIDMappings.find(i)->second;
             segmentDiFinal->at(PoreNodesSegmentIDs[i]) = segmentDi->at(PoreNodesSegmentIDs[i]);
             };
          };
       };


/* BUG BUG line (1ln) below, it probably clears segmentDiFinal too many times, moving to the above loop */
//    for(int i=0; i<nSegments; i++) segmentDiFinal->at(i) = segmentDi->at(i); // copying current segments into Final
    
/* old stuff to be removed
    // Start analysis for node of id = nodeid
    
    nodeIndex = node1; // node1 is w.r.t pore node index (use PORE reverseMapping to retrieve original node
    
    // accept the initial node
    di=lnodes.at(nodeIndex).max_radius;
    df=lnodes.at(nodeIndex).max_radius;
    
    accessStatuses[nodeIndex] = ACCESSED;
    
    directions[nodeIndex] = DELTA_POS(0,0,0);

 ends old stuff */
    
    compareConnections_ptr = &lnodes;
    HEAP< pair<int,int> > stack(compareConnections);
    
    // loop over all connections and add them to stack
    for(unsigned int n=0;  n<nodes.size(); n++)
      {
      if(accessStatuses[n] == ACCESSED)
        {
        for(unsigned int i=0; i<lnodes[n].connections.size(); i++)
          {
          if(lnodes[n].connections.at(i).max_radius > lnodes.at(lnodes[n].connections.at(i).to).max_radius)
              lnodes[n].connections.at(i).max_radius = lnodes.at(lnodes[n].connections.at(i).to).max_radius;
        
          stack.insert(pair<int,int>(n,i));
          };
        };
      };
    
    stack.reHeapify();

//
// Note: in the following blocks, we probably dont need directions[]
// to be cleaned in the future

    
    while(stack.size() != 0){
        //loop with Dijkstra-like propagation
        
        // select the path with largest opening
        pair<int,int> best = stack.pop();
        
        int best_node = lnodes[best.first].connections[best.second].to;
        
        if(accessStatuses[best_node]==UNKNOWN)
        {
            // if the node (best_node) is not assigned to segment, assign it to the current segment (determined by node best.first)
            // check new connections, add to heap or terminane
            
            accessStatuses[best_node] = ACCESSED; 
            directions[best_node] = directions[best.first];
            directions[best_node] = directions[best_node] + (lnodes[best.first].connections.at(best.second).deltaPos);
            PoreNodesSegmentIDs[best_node] = PoreNodesSegmentIDs[best.first];
           
            if(nodes.at(best_node).max_radius * 2 > segmentDiFinal->at(PoreNodesSegmentIDs[best.first])) 
               {   
               segmentDiFinal->at(PoreNodesSegmentIDs[best.first]) = nodes.at(best_node).max_radius * 2; 
               segmentDiFinalNodeID->at(PoreNodesSegmentIDs[best.first]) = reverseIDMappings.find(best_node)->second;
               };

            // going to add new connections to the heap
            for(unsigned int i=0; i<lnodes[best_node].connections.size(); i++)
            {
                if(lnodes[best_node].connections.at(i).max_radius > lnodes.at(lnodes[best_node].connections.at(i).to).max_radius)
                    lnodes[best_node].connections.at(i).max_radius = lnodes.at(lnodes[best_node].connections.at(i).to).max_radius;
                
                if(lnodes[best_node].connections[i].to!=best.first)
                    stack.insert(pair<int,int>(best_node,i));
            };	
//            stack.reHeapify(); 
//            I think reHeapify is not needed as heap.insert ensures proper sorting
        }
        
        else if(accessStatuses[best_node]==ACCESSED){
            //selected connection leads to a node that is already assigned to a segment

            // if it is of different segment, note the destricting diameter
            if(PoreNodesSegmentIDs[best_node] != PoreNodesSegmentIDs[best.first])
              {
              // record the largest resticting diameter between two segments of the same PORE
              double r = lnodes[best.first].connections.at(best.second).max_radius;

//begin debug
//cout << "PLD table size: " << PLDtable->size() << "   " << PLDtable->at(PoreNodesSegmentIDs[best_node]).size() << "\n";
//cout << "PoreNodesSegmentIDs[best_node]= " << PoreNodesSegmentIDs[best_node] << "   PoreNodesSegmentIDs[best.first]= " << PoreNodesSegmentIDs[best.first] << "\n"; 
//              if(PLDtable->size() > PoreNodesSegmentIDs[best_node] + 1 || PLDtable->at(PoreNodesSegmentIDs[best_node]).size() > PoreNodesSegmentIDs[best.first] + 1)
//    {cout << "alarm...\n";
//};
//end debug
              double stored_d = PLDtable->at(PoreNodesSegmentIDs[best_node]).at(PoreNodesSegmentIDs[best.first]);
              if(2*r> stored_d)
                {
                PLDtable->at(PoreNodesSegmentIDs[best_node]).at(PoreNodesSegmentIDs[best.first]) = 2*r;
                PLDtable->at(PoreNodesSegmentIDs[best.first]).at(PoreNodesSegmentIDs[best_node]) = 2*r;
                pair<int,int> p(reverseIDMappings.find(best_node)->second, reverseIDMappings.find(best.first)->second); 
                PLDEdgeTable->at(PoreNodesSegmentIDs[best_node]).at(PoreNodesSegmentIDs[best.first]) = p;
                PLDEdgeTable->at(PoreNodesSegmentIDs[best.first]).at(PoreNodesSegmentIDs[best_node]) = p;
                }else{
                //cerr << "Trying to store smaller diameter than already stored. This shouldnt happen. Check the code\n";
                };              
              } else
              {
              // both nodes are of the same segment, do nothing

              };
            
           /* old stuff, probably to be removed  
            if(!(directions[best_node]).equals(directions[best.first] + lnodes[best.first].connections.at(best.second).deltaPos))
            {
                // if nodes are in different unit cells (a loop is found); just update df and continue 
                if(df>nodes[best.first].connections.at(best.second).max_radius) df=nodes[best.first].connections.at(best.second).max_radius;
            };
           */
        }
        
        else{
            //
            // need this section ?
            //
        };
        
    };
   
   for(int i=0; i<nSegments; i++)
     {
     if(segmentDi->at(i)!=segmentDiFinal->at(i)) cerr << "Segment Di(" << segmentDi->at(i) << ") is different than Segment Di Final (" << segmentDiFinal->at(i) << ") for segment " << i << ".\n";
     };  

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb8, %rsp
movq %r9, 0x40(%rsp)
movq %r8, 0xa0(%rsp)
movq %rcx, 0xa8(%rsp)
movq %rdx, %rbp
movl %esi, %r12d
movl $0xffffffff, 0x4c(%rsp) # imm = 0xFFFFFFFF
movq %rdi, (%rsp)
leaq 0x60(%rdi), %rsi
leaq 0x28(%rsp), %r14
movq %r14, %rdi
callq 0x38ec6
movq (%r14), %rbx
movq 0x8(%r14), %r14
leaq 0x8(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x509d8
subq %rbx, %r14
sarq $0x3, %r14
movabsq $-0x71c71c71c71c71c7, %r15 # imm = 0x8E38E38E38E38E39
imulq %r15, %r14
leaq 0x88(%rsp), %rdi
leaq 0x8(%rsp), %rdx
leaq 0x70(%rsp), %rcx
movq %r14, %rsi
callq 0x76d3a
movq 0x30(%rsp), %rsi
subq 0x28(%rsp), %rsi
sarq $0x3, %rsi
imulq %r15, %rsi
leaq 0x70(%rsp), %rdi
leaq 0x4c(%rsp), %rdx
leaq 0x8(%rsp), %rcx
callq 0x38af6
testl %r12d, %r12d
jle 0x767a4
xorpd %xmm0, %xmm0
leaq 0x50(%rsp), %rdi
movapd %xmm0, (%rdi)
movq $0x0, 0x10(%rdi)
movq (%rsp), %rbx
movq 0x68(%rbx), %rsi
subq 0x60(%rbx), %rsi
sarq $0x3, %rsi
imulq %r15, %rsi
leaq 0x8(%rsp), %rdx
movl $0xffffffff, (%rdx)     # imm = 0xFFFFFFFF
callq 0x49326
movq 0x68(%rbx), %rax
movq 0x60(%rbx), %rcx
subq %rcx, %rax
je 0x75df7
sarq $0x3, %rax
imulq %r15, %rax
movq 0x40(%rbx), %rcx
leaq 0x38(%rbx), %rdx
movq (%rbp), %rsi
xorl %edi, %edi
movq 0x50(%rsp), %r8
xorl %ebp, %ebp
movq %rdx, %r9
testq %rcx, %rcx
je 0x75dc8
movq %rcx, %r10
movq %rdx, %r9
xorl %r11d, %r11d
cmpl %edi, 0x20(%r10)
setl %r11b
cmovgeq %r10, %r9
movq 0x10(%r10,%r11,8), %r10
testq %r10, %r10
jne 0x75daf
movq %rdx, %r10
cmpq %rdx, %r9
je 0x75ddb
cmpl 0x20(%r9), %edi
cmovlq %rdx, %r9
movq %r9, %r10
movslq 0x24(%r10), %r9
movl (%rsi,%r9,4), %r9d
testl %r9d, %r9d
js 0x75dee
movl %r9d, (%r8,%rdi,4)
incl %ebp
incl %edi
cmpq %rdi, %rax
ja 0x75da1
jmp 0x75df9
xorl %ebp, %ebp
movq 0x1211c0(%rip), %rdi    # 0x196fc0
leaq 0xe0c8e(%rip), %rsi     # 0x156a95
movl $0x16, %edx
callq 0x44e0
movq 0x1211a8(%rip), %rdi    # 0x196fc0
movl %ebp, %esi
callq 0x4750
leaq 0xe0c86(%rip), %rsi     # 0x156aac
movl $0x4a, %edx
movq %rax, %rdi
callq 0x44e0
movl %r12d, 0x48(%rsp)
movq (%rsp), %r12
movq 0x68(%r12), %rax
cmpq 0x60(%r12), %rax
je 0x75fba
movq 0xf0(%rsp), %rbx
leaq 0x38(%r12), %r13
xorl %r14d, %r14d
leaq 0x8(%rsp), %rbp
movq 0x50(%rsp), %rax
cmpl $0x0, (%rax,%r14,4)
js 0x75f9c
movq 0x70(%rsp), %rax
movl $0x1, (%rax,%r14,4)
movq %rbp, %rdi
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x509d8
movq 0x88(%rsp), %rax
leaq (%r14,%r14,2), %rcx
movl 0x10(%rsp), %edx
movl %edx, 0x8(%rax,%rcx,4)
movq 0x8(%rsp), %rdx
movq %rdx, (%rax,%rcx,4)
movq 0x50(%rsp), %rdi
movslq (%rdi,%r14,4), %rsi
movq 0x40(%rsp), %rax
movq (%rax), %rcx
movq 0x8(%rax), %rdx
subq %rcx, %rdx
sarq $0x3, %rdx
cmpq %rsi, %rdx
jbe 0x76711
movq 0x60(%r12), %rax
movq 0x68(%r12), %r8
subq %rax, %r8
sarq $0x3, %r8
imulq %r15, %r8
cmpq %r14, %r8
jbe 0x7670b
leaq (%r14,%r14,8), %r8
movsd 0x38(%rax,%r8,8), %xmm0
addsd %xmm0, %xmm0
ucomisd (%rcx,%rsi,8), %xmm0
jbe 0x75f9c
movsd %xmm0, (%rcx,%rsi,8)
movq 0x40(%r12), %r8
movq %r13, %rax
testq %r8, %r8
je 0x75f34
movq %r13, %rax
xorl %r9d, %r9d
cmpl %r14d, 0x20(%r8)
setl %r9b
cmovgeq %r8, %rax
movq 0x10(%r8,%r9,8), %r8
testq %r8, %r8
jne 0x75f1b
movq %r13, %r8
cmpq %r13, %rax
je 0x75f47
cmpl 0x20(%rax), %r14d
cmovlq %r13, %rax
movq %rax, %r8
movq (%rbx), %r9
movq 0x8(%rbx), %rax
subq %r9, %rax
sarq $0x2, %rax
cmpq %rsi, %rax
jbe 0x76744
movl 0x24(%r8), %eax
movl %eax, (%r9,%rsi,4)
movslq (%rdi,%r14,4), %rsi
cmpq %rsi, %rdx
jbe 0x76711
movq 0xf8(%rsp), %rdx
movq (%rdx), %rax
movq 0x8(%rdx), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
cmpq %rsi, %rdx
jbe 0x76711
movsd (%rcx,%rsi,8), %xmm0
movsd %xmm0, (%rax,%rsi,8)
movq 0x68(%r12), %rax
subq 0x60(%r12), %rax
incl %r14d
sarq $0x3, %rax
imulq %r15, %rax
cmpq %r14, %rax
ja 0x75e61
leaq 0x28(%rsp), %rax
movq %rax, 0x1217a2(%rip)    # 0x197768
leaq -0xbdb(%rip), %rsi      # 0x753f2
leaq 0x8(%rsp), %rdi
callq 0x76dc0
movq 0x68(%r12), %rax
movabsq $-0x3333333333333333, %r14 # imm = 0xCCCCCCCCCCCCCCCD
cmpq 0x60(%r12), %rax
je 0x760b9
xorl %ebx, %ebx
leaq 0x8(%rsp), %r13
movq 0x70(%rsp), %rax
cmpl $0x1, (%rax,%rbx,4)
jne 0x76098
movq 0x28(%rsp), %rcx
leaq (%rbx,%rbx,8), %rbp
movq 0x20(%rcx,%rbp,8), %rdi
cmpq %rdi, 0x28(%rcx,%rbp,8)
je 0x76098
movl $0x1, %r12d
xorl %esi, %esi
leaq (%rsi,%rsi,4), %r8
movslq 0x4(%rdi,%r8,8), %rax
movq 0x30(%rsp), %rdx
subq %rcx, %rdx
sarq $0x3, %rdx
imulq %r15, %rdx
cmpq %rax, %rdx
jbe 0x766d8
leaq (%rdi,%r8,8), %rdx
movsd 0x10(%rdx), %xmm1
leaq (%rax,%rax,8), %rax
movsd 0x38(%rcx,%rax,8), %xmm0
ucomisd %xmm0, %xmm1
jbe 0x76064
movsd %xmm0, 0x10(%rdx)
shlq $0x20, %rsi
orq %rbx, %rsi
movq %r13, %rdi
callq 0x76e02
movl %r12d, %esi
movq 0x28(%rsp), %rcx
movq 0x20(%rcx,%rbp,8), %rdi
movq 0x28(%rcx,%rbp,8), %rax
subq %rdi, %rax
sarq $0x3, %rax
imulq %r14, %rax
incl %r12d
cmpq %rsi, %rax
ja 0x76024
movq (%rsp), %r12
movq 0x68(%r12), %rax
subq 0x60(%r12), %rax
incl %ebx
sarq $0x3, %rax
imulq %r15, %rax
cmpq %rbx, %rax
ja 0x75ff8
movq 0x8(%rsp), %rdi
movq 0x10(%rsp), %rsi
movq 0x20(%rsp), %rax
leaq 0xb0(%rsp), %rdx
movq %rax, (%rdx)
callq 0x69775
movabsq $0x7fffffff8, %rcx      # imm = 0x7FFFFFFF8
movq 0x10(%rsp), %rax
subq 0x8(%rsp), %rax
testq %rcx, %rax
je 0x76525
leaq 0x38(%r12), %rbx
movq %rbx, 0x68(%rsp)
leaq 0x8(%rsp), %rdi
callq 0x76eae
movl %eax, %r13d
movslq %eax, %rbx
movq 0x28(%rsp), %r10
leaq (%rbx,%rbx,8), %rdx
sarq $0x20, %rax
movq 0x20(%r10,%rdx,8), %r9
leaq (%rax,%rax,4), %r8
movslq 0x4(%r9,%r8,8), %rbp
movq 0x70(%rsp), %rcx
movl (%rcx,%rbp,4), %esi
cmpl $0x1, %esi
je 0x76333
cmpl $-0x1, %esi
jne 0x76508
movl $0x1, (%rcx,%rbp,4)
movq 0x88(%rsp), %rcx
leaq (%rbx,%rbx,2), %rsi
leaq (,%rbp,2), %r12
addq %rbp, %r12
movl 0x8(%rcx,%rsi,4), %edi
movl %edi, 0x8(%rcx,%r12,4)
movq (%rcx,%rsi,4), %rsi
movq %rsi, (%rcx,%r12,4)
movq 0x28(%rsp), %rsi
movq 0x20(%rsi,%rdx,8), %rcx
movq 0x28(%rsi,%rdx,8), %rdx
subq %rcx, %rdx
sarq $0x3, %rdx
imulq %r14, %rdx
cmpq %rax, %rdx
jbe 0x7671f
leaq (,%r12,4), %rdi
addq 0x88(%rsp), %rdi
leaq (%rcx,%r8,8), %rsi
addq $0x18, %rsi
callq 0x50a30
movq 0x88(%rsp), %rcx
movq %rax, (%rcx,%r12,4)
movl %edx, 0x8(%rcx,%r12,4)
movq 0x50(%rsp), %rcx
movl (%rcx,%rbx,4), %eax
movl %eax, (%rcx,%rbp,4)
movq (%rsp), %rdi
movq 0x60(%rdi), %rax
movq 0x68(%rdi), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
imulq %r15, %rdx
cmpq %rbp, %rdx
jbe 0x76733
movslq (%rcx,%rbx,4), %rsi
movq 0xf8(%rsp), %rdx
movq (%rdx), %rcx
movq 0x8(%rdx), %rdx
subq %rcx, %rdx
sarq $0x3, %rdx
cmpq %rsi, %rdx
movq 0x68(%rsp), %r8
jbe 0x76730
leaq (,%rbp,8), %rbx
addq %rbp, %rbx
movsd 0x38(%rax,%rbx,8), %xmm0
addsd %xmm0, %xmm0
ucomisd (%rcx,%rsi,8), %xmm0
jbe 0x76294
movsd %xmm0, (%rcx,%rsi,8)
movq 0x40(%rdi), %rcx
movq %r8, %rax
testq %rcx, %rcx
je 0x7625d
movq %r8, %rax
xorl %edx, %edx
cmpl %ebp, 0x20(%rcx)
setl %dl
cmovgeq %rcx, %rax
movq 0x10(%rcx,%rdx,8), %rcx
testq %rcx, %rcx
jne 0x76247
movq %r8, %rcx
cmpq %r8, %rax
je 0x7626f
cmpl 0x20(%rax), %ebp
cmovlq %r8, %rax
movq %rax, %rcx
movq 0x100(%rsp), %rdx
movq (%rdx), %rax
movq 0x8(%rdx), %rdx
subq %rax, %rdx
sarq $0x2, %rdx
cmpq %rsi, %rdx
jbe 0x7676e
movl 0x24(%rcx), %ecx
movl %ecx, (%rax,%rsi,4)
movq 0x28(%rsp), %rcx
movq 0x20(%rcx,%rbx,8), %rdi
cmpq %rdi, 0x28(%rcx,%rbx,8)
je 0x76508
movl %ebp, %ebp
movl $0x1, %r12d
xorl %esi, %esi
leaq (%rsi,%rsi,4), %r8
movslq 0x4(%rdi,%r8,8), %rax
movq 0x30(%rsp), %rdx
subq %rcx, %rdx
sarq $0x3, %rdx
imulq %r15, %rdx
cmpq %rax, %rdx
jbe 0x766e9
leaq (%rdi,%r8,8), %rdx
movsd 0x10(%rdx), %xmm1
leaq (%rax,%rax,8), %rdi
movsd 0x38(%rcx,%rdi,8), %xmm0
ucomisd %xmm0, %xmm1
jbe 0x762f3
movsd %xmm0, 0x10(%rdx)
cmpl %r13d, %eax
je 0x76309
shlq $0x20, %rsi
orq %rbp, %rsi
leaq 0x8(%rsp), %rdi
callq 0x76e02
movl %r12d, %esi
movq 0x28(%rsp), %rcx
movq 0x20(%rcx,%rbx,8), %rdi
movq 0x28(%rcx,%rbx,8), %rax
subq %rdi, %rax
sarq $0x3, %rax
imulq %r14, %rax
incl %r12d
cmpq %rsi, %rax
ja 0x762b3
jmp 0x76508
movq 0x50(%rsp), %rdi
movslq (%rdi,%rbp,4), %rcx
movslq (%rdi,%rbx,4), %rsi
cmpl %esi, %ecx
je 0x76508
leaq (%r10,%rdx,8), %rdx
addq $0x20, %rdx
movq 0x8(%rdx), %rdx
subq %r9, %rdx
sarq $0x3, %rdx
imulq %r14, %rdx
cmpq %rax, %rdx
jbe 0x76755
movq 0xa8(%rsp), %rax
movq (%rax), %r10
movq 0x8(%rax), %rdx
subq %r10, %rdx
sarq $0x3, %rdx
movabsq $-0x5555555555555555, %rax # imm = 0xAAAAAAAAAAAAAAAB
imulq %rax, %rdx
cmpq %rcx, %rdx
jbe 0x7677f
leaq (%rcx,%rcx,2), %rax
movq (%r10,%rax,8), %r11
movq 0x8(%r10,%rax,8), %r12
subq %r11, %r12
sarq $0x3, %r12
cmpq %rsi, %r12
jbe 0x76766
leaq (%r9,%r8,8), %r8
movsd 0x10(%r8), %xmm0
addsd %xmm0, %xmm0
ucomisd (%r11,%rsi,8), %xmm0
jbe 0x76508
movsd %xmm0, (%r11,%rsi,8)
cmpq %rsi, %rdx
jbe 0x7677c
leaq (%rsi,%rsi,2), %rdx
movq (%r10,%rdx,8), %r8
movq 0x8(%r10,%rdx,8), %rdx
subq %r8, %rdx
sarq $0x3, %rdx
cmpq %rcx, %rdx
movq (%rsp), %r9
movq 0x68(%rsp), %r12
jbe 0x7677f
movsd %xmm0, (%r8,%rcx,8)
movq 0x40(%r9), %rdx
movq %r12, %r9
testq %rdx, %rdx
je 0x76432
movq %rdx, %r8
movq %r12, %r9
xorl %r10d, %r10d
cmpl %ebp, 0x20(%r8)
setl %r10b
cmovgeq %r8, %r9
movq 0x10(%r8,%r10,8), %r8
testq %r8, %r8
jne 0x76419
movq %r12, %r8
cmpq %r12, %r9
je 0x76445
cmpl 0x20(%r9), %ebp
cmovlq %r12, %r9
movq %r9, %r8
movq %r12, %r9
testq %rdx, %rdx
je 0x76469
movq %r12, %r9
xorl %r10d, %r10d
cmpl %r13d, 0x20(%rdx)
setl %r10b
cmovgeq %rdx, %r9
movq 0x10(%rdx,%r10,8), %rdx
testq %rdx, %rdx
jne 0x76450
movq %r12, %r11
cmpq %r12, %r9
je 0x7647c
cmpl %r13d, 0x20(%r9)
cmovgq %r12, %r9
movq %r9, %r11
movq 0xa0(%rsp), %rdx
movq (%rdx), %r9
movq 0x8(%rdx), %r10
subq %r9, %r10
sarq $0x3, %r10
movabsq $-0x5555555555555555, %rdx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rdx, %r10
cmpq %rcx, %r10
jbe 0x76790
movq (%r9,%rax,8), %r12
movq 0x8(%r9,%rax,8), %rdx
subq %r12, %rdx
sarq $0x3, %rdx
cmpq %rsi, %rdx
jbe 0x76796
movl 0x24(%r8), %eax
movl 0x24(%r11), %ecx
movl %eax, (%r12,%rsi,8)
movl %ecx, 0x4(%r12,%rsi,8)
movslq (%rdi,%rbx,4), %rsi
cmpq %rsi, %r10
jbe 0x76793
leaq (%rsi,%rsi,2), %rdx
movslq (%rdi,%rbp,4), %rsi
movq (%r9,%rdx,8), %rdi
movq 0x8(%r9,%rdx,8), %rdx
subq %rdi, %rdx
sarq $0x3, %rdx
cmpq %rsi, %rdx
jbe 0x76796
movl %eax, (%rdi,%rsi,8)
movl %ecx, 0x4(%rdi,%rsi,8)
movq 0x10(%rsp), %rax
subq 0x8(%rsp), %rax
movabsq $0x7fffffff8, %rcx      # imm = 0x7FFFFFFF8
testq %rcx, %rax
jne 0x760ff
movl 0x48(%rsp), %eax
cmpl $0x2, %eax
movl $0x1, %ebx
cmovgel %eax, %ebx
xorl %r14d, %r14d
movq 0x120ab2(%rip), %r15    # 0x196ff0
leaq 0xe05e5(%rip), %rbp     # 0x156b2a
leaq 0xe9579(%rip), %r12     # 0x15fac5
movq 0x40(%rsp), %rcx
movq (%rcx), %rax
movq 0x8(%rcx), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
cmpq %r14, %rdx
jbe 0x766fa
movq 0xf8(%rsp), %rdx
movq (%rdx), %rcx
movq 0x8(%rdx), %rdx
subq %rcx, %rdx
sarq $0x3, %rdx
cmpq %r14, %rdx
jbe 0x766fa
movsd (%rax,%r14,8), %xmm0
ucomisd (%rcx,%r14,8), %xmm0
jne 0x7659b
jnp 0x7664b
movl $0xb, %edx
movq %r15, %rdi
leaq 0xe054d(%rip), %rsi     # 0x156af7
callq 0x44e0
movq 0x40(%rsp), %rcx
movq (%rcx), %rax
movq 0x8(%rcx), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
cmpq %r14, %rdx
jbe 0x766fa
movsd (%rax,%r14,8), %xmm0
movq %r15, %rdi
callq 0x46b0
movq %rax, %r13
movl $0x26, %edx
movq %rax, %rdi
leaq 0xe0518(%rip), %rsi     # 0x156b03
callq 0x44e0
movq 0xf8(%rsp), %rcx
movq (%rcx), %rax
movq 0x8(%rcx), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
cmpq %r14, %rdx
jbe 0x766fa
movsd (%rax,%r14,8), %xmm0
movq %r13, %rdi
callq 0x46b0
movq %rax, %r13
movl $0xe, %edx
movq %rax, %rdi
movq %rbp, %rsi
callq 0x44e0
movq %r13, %rdi
movl %r14d, %esi
callq 0x4750
movl $0x2, %edx
movq %rax, %rdi
movq %r12, %rsi
callq 0x44e0
incq %r14
cmpq %r14, %rbx
jne 0x7654c
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x7666e
movq 0x18(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0x76685
movq 0x60(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movq 0x70(%rsp), %rdi
testq %rdi, %rdi
je 0x7669f
movq 0x80(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movq 0x88(%rsp), %rdi
testq %rdi, %rdi
je 0x766bc
movq 0x98(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
leaq 0x28(%rsp), %rdi
callq 0xf07c
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xd8fc6(%rip), %rdi     # 0x14f6a5
movq %rax, %rsi
xorl %eax, %eax
callq 0x4630
leaq 0xd8fb5(%rip), %rdi     # 0x14f6a5
movq %rax, %rsi
xorl %eax, %eax
callq 0x4630
leaq 0xd8fa4(%rip), %rdi     # 0x14f6a5
movq %r14, %rsi
xorl %eax, %eax
callq 0x4630
movq %r14, %rsi
movq %r8, %rdx
leaq 0xd8f8d(%rip), %rdi     # 0x14f6a5
xorl %eax, %eax
callq 0x4630
leaq 0xd8f7f(%rip), %rdi     # 0x14f6a5
movq %rax, %rsi
xorl %eax, %eax
callq 0x4630
movq %rsi, %rbp
leaq 0xd8f6b(%rip), %rdi     # 0x14f6a5
movq %rbp, %rsi
xorl %eax, %eax
callq 0x4630
leaq 0xd8f5a(%rip), %rdi     # 0x14f6a5
movq %rax, %rdx
xorl %eax, %eax
callq 0x4630
leaq 0xd8f49(%rip), %rdi     # 0x14f6a5
movq %rax, %rsi
xorl %eax, %eax
callq 0x4630
movq %rsi, %rcx
movq %r12, %rdx
jmp 0x7677f
leaq 0xd8f30(%rip), %rdi     # 0x14f6a5
xorl %eax, %eax
callq 0x4630
movq %rsi, %rcx
leaq 0xd8f1f(%rip), %rdi     # 0x14f6a5
movq %rcx, %rsi
xorl %eax, %eax
callq 0x4630
movq %rcx, %rsi
movq %r10, %rdx
leaq 0xd8f08(%rip), %rdi     # 0x14f6a5
xorl %eax, %eax
callq 0x4630
movq 0x120845(%rip), %rdi    # 0x196ff0
leaq 0xe029d(%rip), %rsi     # 0x156a4f
movl $0x45, %edx
callq 0x44e0
movq 0x12082d(%rip), %rdi    # 0x196ff0
leaq 0xded64(%rip), %rsi     # 0x15552e
callq 0x4440
callq 0x4260
movq %rax, %rbx
jmp 0x76842
jmp 0x76811
jmp 0x76802
movq %rax, %rbx
jmp 0x7685c
jmp 0x767e4
movq %rax, %rbx
jmp 0x76879
jmp 0x76802
jmp 0x76811
jmp 0x76811
jmp 0x76802
jmp 0x76811
jmp 0x76811
jmp 0x76811
jmp 0x76811
jmp 0x76802
jmp 0x76811
jmp 0x76811
movq %rax, %rbx
jmp 0x7682b
jmp 0x76811
jmp 0x76811
jmp 0x76811
jmp 0x76811
jmp 0x76811
movq %rax, %rbx
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x7682b
movq 0x18(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0x76842
movq 0x60(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movq 0x70(%rsp), %rdi
testq %rdi, %rdi
je 0x7685c
movq 0x80(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movq 0x88(%rsp), %rdi
testq %rdi, %rdi
je 0x76879
movq 0x98(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
leaq 0x28(%rsp), %rdi
callq 0xf07c
movq %rbx, %rdi
callq 0x4780
nop