// File: /workspace/github_cpp_makefile_star2_O3/Luthaf[P]zeopp/channel.cc
// Function: PORE::findChannelsAndPockets(DIJKSTRA_NETWORK*, std::vector<bool, std::allocator<bool>>*, std::vector<PORE, std::allocator<PORE>>*)
void PORE::findChannelsAndPockets(DIJKSTRA_NETWORK *dnet, vector<bool> *infoStorage,
                                  vector<PORE> *pores)
{
    //Define three access types
    const int ACCESSIBLE   =  1;
    const int INACCESSIBLE =  0;
    const int UNKNOWN      = -1;
    
    vector<DELTA_POS> directions = vector<DELTA_POS> ();
    
    // Initialize the status of each node as UNKNOWN
    vector<int> accessStatuses = vector<int> (dnet->nodes.size(), UNKNOWN);
    unsigned int nodeIndex = 0;
    
    // Get and Print basic info
    int noAccDijkNodes = 0; // number of active Dijkstra nodes (ones with radius > 0)
    int noAccDijkNodesAssigned = 0; // number of active Dijkstra nodes already assigned to pores.
    for(unsigned int i = 0; i < dnet->nodes.size(); i++)
    {
        if(dnet->nodes.at(i).active == true) noAccDijkNodes++;
        
        //debug line
        //cout << "id,active " << i << "   " << dnet->nodes.at(i).active << endl;
    };
    cout << "\nFinding channels and pockets in Dijkstra network of " << dnet->nodes.size() << " node(s). " << noAccDijkNodes << " are expected to compose pores." << endl;
    
    // Iterate over all nodes
    while(nodeIndex != accessStatuses.size()){
        //Skip node if access status already determined
        if(accessStatuses.at(nodeIndex) != UNKNOWN){
            nodeIndex++;
            continue;
        }
        
        // Start out with 0-dimensional pore w/o any basis vectors
        int dim = 0;
        int basis [3][3] = {{0,0,0},
			{0,0,0},
			{0,0,0}};
        
        // Place starting node on stack with (0,0,0) displacement
        int accessStatus = UNKNOWN;
        DELTA_POS displacement = DELTA_POS(0,0,0);
        map<int,DELTA_POS> visitedNodeDisplacement;
        vector<pair<int,DELTA_POS> > stack;
        stack.push_back(pair<int,DELTA_POS> (nodeIndex,displacement));
        visitedNodeDisplacement.insert(pair<int,DELTA_POS>(nodeIndex, displacement));
        
        while(stack.size() != 0){
            // Remove top-most node
            pair<int,DELTA_POS> nodeInfo = stack.back();
            DIJKSTRA_NODE currentNode = dnet->nodes.at(nodeInfo.first);
            stack.pop_back();
            
            // Follow all edges leading to adjoining nodes
            vector<CONN>::iterator connIter = currentNode.connections.begin();
            while(connIter != currentNode.connections.end()){
                int to = connIter->to;
                DELTA_POS newDisplacement = nodeInfo.second + connIter->deltaPos;
                int localAccessStatus = accessStatuses.at(to);
                
                if(localAccessStatus == UNKNOWN){
                    map<int,DELTA_POS>::iterator visitedNode = visitedNodeDisplacement.find(to);
                    if(visitedNode != visitedNodeDisplacement.end()){
                        if(visitedNode->second.equals(newDisplacement)){
                            // Circling back to previous node
                            // Do nothing
                        }
                        else{
                            // Nodes are ACCESSIBLE b/c same node visited in different unit cell
                            accessStatus = ACCESSIBLE;
                            DELTA_POS direction = newDisplacement - visitedNode->second;
                            
                            
                            /******* Start of Michael's code ******/
                            if(dim == 0){
                                basis[0][0] = direction.x;
                                basis[1][0] = direction.y;
                                basis[2][0] = direction.z;
                                dim++;
                            }
                            else if (dim == 1){
                                double v;
                                
                                if (basis[0][0] != 0) v = 1.0*direction.x/basis[0][0];
                                else if (basis[1][0] != 0) v = 1.0*direction.y/basis[1][0];
                                else if (basis[2][0] != 0) v = 1.0*direction.z/basis[2][0];
                                else {
                                    cerr << "Error: Pore basis vector is zero vector. Exiting..." << "\n";
                                    exit(1);
                                }
                                
                                if(!(basis[0][0]*v == direction.x && basis[1][0]*v == direction.y &&
                                     basis[2][0]*v == direction.z)){
                                    basis[0][1] = direction.x;
                                    basis[1][1] = direction.y;
                                    basis[2][1] = direction.z;
                                    dim++;
                                }
                            }
                            else if (dim == 2){
                                basis[0][2] = direction.x;
                                basis[1][2] = direction.y;
                                basis[2][2] = direction.z;
                                if(abs(calcDeterminant(basis)) < 1e-8){
                                    basis[0][2] = basis[1][2] = basis[2][2] = 0;
                                }
                                else
                                    dim++;
                            }
                            /****** End of Michael's code ******/
                        }
                    }
                    else{
                        // Node being visited for the first time
                        visitedNodeDisplacement.insert(pair<int,DELTA_POS>(to, newDisplacement));
                        stack.push_back(pair<int,DELTA_POS> (to, newDisplacement));
                    }
                }
                else{
                    // The status of a region should be determined
                    // with all of its neighbors. Otherwise, all possible nodes
                    // were not explored.
                    cerr << "Error: Illogical result  when attempting to identify channels/pockets." << "\n";
                    cerr << "Please contact the source code provider with your program input. " << "\n";
                    cerr << "Exiting ..." << "\n";
                    exit(1);
                }
                connIter++;
            }
        }
        
        // All connected nodes are inaccessible if their status is still UNKNOWN
        if((stack.size() == 0) && (accessStatus == UNKNOWN))
            accessStatus = INACCESSIBLE;
        
        // Record the access status for each node in the cycle and create
        // a list of the node ids for channel identification
        map<int,DELTA_POS>::iterator resultIter = visitedNodeDisplacement.begin();
        vector<int> listOfIDs = vector<int> ();
        while(resultIter != visitedNodeDisplacement.end()){
            
            int nodeID = resultIter->first;
            if(accessStatuses.at(nodeID) != UNKNOWN){
                // Each node should only have its accessibility determined once
                cerr << "Error: Accessibility of node was determined more than once." << "\n";
                cerr << "Please contact the source code provider with your program input. " << "\n";
                cerr << "Exiting ..." << "\n";
                exit(1);
            }
            else{
                // Store node's status
                accessStatuses.at(nodeID) = accessStatus;
                listOfIDs.push_back(nodeID);
            }
            resultIter++;
        }
        nodeIndex++;
        
        // Create CHANNEL from ACCESSIBLE nodes
        if(accessStatus == ACCESSIBLE){
            pores->push_back(PORE(listOfIDs, dnet, dim, basis));
            // store pore statistics (number of nodes included in pore)
            noAccDijkNodesAssigned += listOfIDs.size();
            //output << dim << " ";
        }else
        { // OTHERWISE create POCKET from INACCESSIBLE nodes (dim set to 0 indicates pocket)
            // additionally pockets have to be built from active nodes (this is to ensure their
            // size is larger than mix_radius)
            if(dnet->nodes[listOfIDs[0]].active == true)
            {
                pores->push_back(PORE(listOfIDs, dnet, dim, basis));
                // store pore statistics (number of nodes included in pore)
                noAccDijkNodesAssigned += listOfIDs.size();
            };
        };
        
        //more debug
        bool flg;
        for(unsigned int i=0;i<listOfIDs.size();i++)
        {
            if(i==0) flg = dnet->nodes[listOfIDs[0]].active;
            else
            {
                if(flg !=dnet->nodes[listOfIDs[i]].active) cout << "pocket error" << endl;
            };
        };
        //end of debug
    }
    // Store information in provided vector
    infoStorage -> resize(accessStatuses.size());
    for(unsigned int i = 0; i < accessStatuses.size(); i++){
        infoStorage -> at(i) = (accessStatuses.at(i) == ACCESSIBLE);
    }
    
    // Print summary
    int nchannel=0,npocket=0;
    for(unsigned int i = 0; i<pores->size(); i++)
    {
        if(pores->at(i).dimensionality>0) nchannel++; else npocket++;
    };
    cout << "Analyzed and assigned " << nodeIndex << " nodes.";
    cout << "\nIdentified " << nchannel << " channels and " << npocket << " pockets.\n";
    cout << noAccDijkNodesAssigned << " nodes assigned to pores. " << endl;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x288, %rsp            # imm = 0x288
movq %rdx, 0xb0(%rsp)
movq %rdi, %rbx
leaq 0x134(%rsp), %rdx
movl $0xffffffff, (%rdx)     # imm = 0xFFFFFFFF
movq 0x8(%rdi), %rax
subq (%rdi), %rax
movq %rsi, %r12
sarq $0x3, %rax
movabsq $-0x71c71c71c71c71c7, %r14 # imm = 0x8E38E38E38E38E39
imulq %r14, %rax
leaq 0x38(%rsp), %rdi
leaq 0x150(%rsp), %r13
movq %rax, %rsi
movq %r13, %rcx
callq 0x3864a
movq (%rbx), %rax
movq %rbx, 0x8(%rsp)
movq 0x8(%rbx), %rcx
subq %rax, %rcx
je 0x6ff18
sarq $0x3, %rcx
imulq %r14, %rcx
addq $0x40, %rax
xorl %ebx, %ebx
movl $0x1, %edx
movzbl (%rax), %esi
addl %esi, %ebx
movl %edx, %esi
addq $0x48, %rax
incl %edx
cmpq %rsi, %rcx
ja 0x6ff04
jmp 0x6ff1a
xorl %ebx, %ebx
movq 0x12509f(%rip), %rdi    # 0x194fc0
leaq 0xe4718(%rip), %rsi     # 0x154640
movl $0x35, %edx
callq 0x44e0
movq 0x8(%rsp), %rax
movq 0x8(%rax), %rsi
subq (%rax), %rsi
sarq $0x3, %rsi
imulq %r14, %rsi
movq 0x125073(%rip), %rdi    # 0x194fc0
callq 0x42b0
movq %rax, %r14
leaq 0xe471a(%rip), %rsi     # 0x154676
movl $0xa, %edx
movq %rax, %rdi
callq 0x44e0
movq %r14, %rdi
movl %ebx, %esi
callq 0x4750
movq %rax, %rbx
leaq 0xe4704(%rip), %rsi     # 0x154681
movl $0x1f, %edx
movq %rax, %rdi
callq 0x44e0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x4420
movsbl %al, %esi
movq %rbx, %rdi
callq 0x4040
movq %rax, %rdi
callq 0x42c0
movq 0x38(%rsp), %rax
movq 0x40(%rsp), %rcx
movq %rcx, %rsi
subq %rax, %rsi
sarq $0x2, %rsi
cmpq %rax, %rcx
je 0x7089f
leaq 0xec(%rsp), %rbx
leaq 0xa8(%r13), %rcx
movq %rcx, 0xc8(%rsp)
leaq 0xbc(%rsp), %rdi
movq %rsi, %rdx
xorl %r14d, %r14d
movq $0x0, 0x30(%rsp)
xorl %ebp, %ebp
cmpq %r14, %rdx
jbe 0x70b11
cmpl $-0x1, (%rax,%r14,4)
je 0x7001d
incl %ebp
movq %rbp, %r14
cmpq %rbp, %rdx
jne 0x6fffe
jmp 0x70897
xorpd %xmm0, %xmm0
movapd %xmm0, 0x80(%rsp)
movapd %xmm0, 0x70(%rsp)
movl $0x0, 0x90(%rsp)
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x506b0
movl $0x0, 0x100(%rsp)
xorl %ecx, %ecx
movq %rcx, 0x108(%rsp)
leaq 0x100(%rsp), %rax
movq %rax, 0x110(%rsp)
movq %rax, 0x118(%rsp)
movq %rcx, 0x120(%rsp)
movq %rcx, 0x60(%rsp)
xorpd %xmm0, %xmm0
movapd %xmm0, 0x50(%rsp)
movl %ebp, 0x150(%rsp)
movl 0xc4(%rsp), %eax
leaq 0x154(%rsp), %r13
movl %eax, 0x8(%r13)
movq 0xbc(%rsp), %rax
movq %rax, (%r13)
leaq 0x50(%rsp), %rdi
xorl %esi, %esi
leaq 0x150(%rsp), %r14
movq %r14, %rdx
callq 0x762fa
movl %ebp, 0x150(%rsp)
movl 0xc4(%rsp), %eax
movl %eax, 0x8(%r13)
movq 0xbc(%rsp), %rax
movq %rax, (%r13)
leaq 0xf8(%rsp), %rdi
movq %r14, %rsi
callq 0x7643a
movq %r12, 0x128(%rsp)
movq 0x58(%rsp), %rax
cmpq 0x50(%rsp), %rax
je 0x704e1
movl $0xffffffff, 0x4(%rsp)  # imm = 0xFFFFFFFF
xorl %r14d, %r14d
movupd -0x10(%rax), %xmm0
movapd %xmm0, 0x10(%rsp)
movslq 0x10(%rsp), %rsi
movq 0x8(%rsp), %rax
movq (%rax), %r15
movq 0x8(%rax), %rdx
subq %r15, %rdx
sarq $0x3, %rdx
movabsq $-0x71c71c71c71c71c7, %rax # imm = 0x8E38E38E38E38E39
imulq %rax, %rdx
cmpq %rsi, %rdx
jbe 0x70bc0
leaq (%rsi,%rsi,8), %r12
leaq (%r15,%r12,8), %rsi
addq $0x20, %rsi
movupd -0x20(%rsi), %xmm0
movupd -0x10(%rsi), %xmm1
movapd %xmm1, 0x160(%rsp)
movapd %xmm0, 0x150(%rsp)
leaq 0x170(%rsp), %rdi
callq 0x37e9e
leaq (%r15,%r12,8), %rax
movb 0x40(%rax), %cl
leaq 0x154(%rsp), %rdx
movb %cl, 0x3c(%rdx)
movq 0x38(%rax), %rax
addq $-0x10, 0x58(%rsp)
movq %rax, 0x34(%rdx)
movq 0x170(%rsp), %r12
cmpq 0x178(%rsp), %r12
je 0x7049d
movl 0x4(%r12), %r15d
leaq 0x18(%r12), %rsi
leaq 0x14(%rsp), %rdi
callq 0x50708
movslq %r15d, %rsi
movq %rax, 0xa0(%rsp)
movl %edx, 0xa8(%rsp)
movq 0x38(%rsp), %rdi
movq 0x40(%rsp), %rcx
subq %rdi, %rcx
sarq $0x2, %rcx
cmpq %rsi, %rcx
jbe 0x70a6b
cmpl $-0x1, (%rdi,%rsi,4)
jne 0x70a7c
movq 0x108(%rsp), %r8
testq %r8, %r8
je 0x7025f
leaq 0x100(%rsp), %r13
movq %r13, %rcx
movq %r8, %rsi
movl 0x20(%r8), %edi
xorl %r8d, %r8d
cmpl %r15d, %edi
setl %r8b
movq %rsi, %r13
cmovlq %rcx, %r13
movq 0x10(%rsi,%r8,8), %r8
testq %r8, %r8
jne 0x7021c
leaq 0x100(%rsp), %r8
cmpq %r8, %r13
je 0x7025f
cmpl %r15d, %edi
cmovlq %rcx, %rsi
cmpl 0x20(%rsi), %r15d
jge 0x702f3
movl %r15d, 0xe8(%rsp)
movl 0xa8(%rsp), %eax
movl %eax, 0x8(%rbx)
movq 0xa0(%rsp), %rax
movq %rax, (%rbx)
leaq 0xf8(%rsp), %rdi
leaq 0xe8(%rsp), %rsi
callq 0x7643a
movl %r15d, 0xe8(%rsp)
movl 0xa8(%rsp), %eax
movl %eax, 0x8(%rbx)
movq 0xa0(%rsp), %rax
movq %rax, (%rbx)
movq 0x58(%rsp), %rsi
cmpq 0x60(%rsp), %rsi
je 0x702d7
movupd 0xe8(%rsp), %xmm0
movupd %xmm0, (%rsi)
addq $0x10, 0x58(%rsp)
leaq 0xd0(%rsp), %r15
jmp 0x7030e
leaq 0x50(%rsp), %rdi
leaq 0xe8(%rsp), %rdx
callq 0x762fa
leaq 0xd0(%rsp), %r15
jmp 0x7030e
addq $0x24, %r13
movq %r13, %rdi
movq %rax, %rsi
callq 0x506ba
testb %al, %al
leaq 0xd0(%rsp), %r15
je 0x70325
addq $0x28, %r12
cmpq 0x178(%rsp), %r12
jne 0x701bd
jmp 0x70493
leaq 0xa0(%rsp), %rdi
movq %r13, %rsi
callq 0x50720
movl $0x1, 0x4(%rsp)
cmpl $0x2, %r14d
je 0x7037f
cmpl $0x1, %r14d
je 0x70371
testl %r14d, %r14d
jne 0x7030e
movl %eax, 0x70(%rsp)
shrq $0x20, %rax
movl %eax, 0x7c(%rsp)
movl %edx, 0x88(%rsp)
movl $0x1, 0x4(%rsp)
movl $0x1, %r14d
jmp 0x7030e
movl 0x70(%rsp), %ecx
testl %ecx, %ecx
je 0x703cc
movl %eax, %edi
movl %ecx, %esi
jmp 0x703ee
movl %eax, 0x78(%rsp)
shrq $0x20, %rax
movl %eax, 0x84(%rsp)
movl %edx, 0x90(%rsp)
leaq 0x70(%rsp), %rdi
callq 0x83b91
movl $0x3, %r14d
testl %eax, %eax
jne 0x7030e
xorl %eax, %eax
movl %eax, 0x90(%rsp)
movl %eax, 0x84(%rsp)
movl %eax, 0x78(%rsp)
movl $0x2, %r14d
jmp 0x7030e
movl 0x7c(%rsp), %esi
testl %esi, %esi
je 0x703dd
movq %rax, %rdi
shrq $0x20, %rdi
jmp 0x703ee
movl 0x88(%rsp), %esi
movl %edx, %edi
testl %esi, %esi
je 0x70bce
cvtsi2sd %edi, %xmm0
cvtsi2sd %esi, %xmm1
divsd %xmm1, %xmm0
xorps %xmm1, %xmm1
cvtsi2sd %ecx, %xmm1
mulsd %xmm0, %xmm1
cvtsi2sd %eax, %xmm2
ucomisd %xmm2, %xmm1
jne 0x70467
jp 0x70467
xorps %xmm1, %xmm1
cvtsi2sdl 0x7c(%rsp), %xmm1
mulsd %xmm0, %xmm1
movq %rax, %rcx
shrq $0x20, %rcx
xorps %xmm2, %xmm2
cvtsi2sd %ecx, %xmm2
ucomisd %xmm2, %xmm1
jne 0x7046e
jp 0x7046e
xorps %xmm1, %xmm1
cvtsi2sdl 0x88(%rsp), %xmm1
mulsd %xmm1, %xmm0
xorps %xmm1, %xmm1
cvtsi2sd %edx, %xmm1
movl $0x1, 0x4(%rsp)
ucomisd %xmm1, %xmm0
movl $0x1, %r14d
jne 0x7046e
jnp 0x7030e
jmp 0x7046e
movq %rax, %rcx
shrq $0x20, %rcx
movl %eax, 0x74(%rsp)
movl %ecx, 0x80(%rsp)
movl %edx, 0x8c(%rsp)
movl $0x2, %r14d
movl $0x1, 0x4(%rsp)
jmp 0x7030e
movq 0x170(%rsp), %r12
jmp 0x704a5
leaq 0xd0(%rsp), %r15
testq %r12, %r12
je 0x704bd
movq 0x180(%rsp), %rsi
subq %r12, %rsi
movq %r12, %rdi
callq 0x4470
movq 0x58(%rsp), %rax
cmpq 0x50(%rsp), %rax
jne 0x70118
movl 0x4(%rsp), %r13d
cmpl $-0x1, %r13d
movl $0x0, %eax
cmovel %eax, %r13d
jmp 0x704ef
xorl %r14d, %r14d
xorl %r13d, %r13d
leaq 0xd0(%rsp), %r15
movq 0x110(%rsp), %r12
xorpd %xmm0, %xmm0
movapd %xmm0, 0x10(%rsp)
movq $0x0, 0x20(%rsp)
leaq 0x100(%rsp), %rax
cmpq %rax, %r12
je 0x7058a
movslq 0x20(%r12), %rsi
movl %esi, 0x150(%rsp)
movq 0x38(%rsp), %rax
movq 0x40(%rsp), %rdx
subq %rax, %rdx
sarq $0x2, %rdx
cmpq %rsi, %rdx
jbe 0x70b22
cmpl $-0x1, (%rax,%rsi,4)
jne 0x70b30
movl %r13d, (%rax,%rsi,4)
movq 0x18(%rsp), %rsi
cmpq 0x20(%rsp), %rsi
je 0x7056b
movl 0x150(%rsp), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x18(%rsp)
jmp 0x7057d
leaq 0x10(%rsp), %rdi
leaq 0x150(%rsp), %rdx
callq 0xf864
movq %r12, %rdi
callq 0x42d0
movq %rax, %r12
jmp 0x7050a
cmpl $0x1, %r13d
movq 0x128(%rsp), %r12
jne 0x70665
movq %r15, %rdi
leaq 0x10(%rsp), %rsi
callq 0xe8f8
leaq 0x150(%rsp), %r13
movq %r13, %rdi
movq %r15, %rsi
movq 0x8(%rsp), %rdx
movl %r14d, %ecx
leaq 0x70(%rsp), %r8
callq 0x6ed98
movq 0xb0(%rsp), %rdi
movq %r13, %rsi
callq 0x76586
movq 0xc8(%rsp), %rdi
callq 0xf066
movq 0x1e0(%rsp), %rdi
testq %rdi, %rdi
je 0x70603
movq 0x1f0(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movq 0x1c8(%rsp), %rdi
testq %rdi, %rdi
je 0x70620
movq 0x1d8(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
leaq 0x1b0(%rsp), %rdi
callq 0xf10e
leaq 0x180(%rsp), %rdi
callq 0xf1b6
leaq 0x150(%rsp), %rdi
callq 0xf1b6
movq 0xd0(%rsp), %rdi
testq %rdi, %rdi
je 0x70754
movq 0xe0(%rsp), %rsi
jmp 0x7074c
movq 0x10(%rsp), %rdi
movslq (%rdi), %rax
movq 0x8(%rsp), %rcx
movq (%rcx), %rcx
leaq (%rax,%rax,8), %rax
cmpb $0x0, 0x40(%rcx,%rax,8)
je 0x70776
leaq 0x138(%rsp), %r15
movq %r15, %rdi
leaq 0x10(%rsp), %rsi
callq 0xe8f8
leaq 0x150(%rsp), %r13
movq %r13, %rdi
movq %r15, %rsi
movq 0x8(%rsp), %rdx
movl %r14d, %ecx
leaq 0x70(%rsp), %r8
callq 0x6ed98
movq 0xb0(%rsp), %rdi
movq %r13, %rsi
callq 0x76586
movq 0xc8(%rsp), %rdi
callq 0xf066
movq 0x1e0(%rsp), %rdi
testq %rdi, %rdi
je 0x706f3
movq 0x1f0(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movq 0x1c8(%rsp), %rdi
testq %rdi, %rdi
je 0x70710
movq 0x1d8(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
leaq 0x1b0(%rsp), %rdi
callq 0xf10e
leaq 0x180(%rsp), %rdi
callq 0xf1b6
leaq 0x150(%rsp), %rdi
callq 0xf1b6
movq 0x138(%rsp), %rdi
testq %rdi, %rdi
je 0x70754
movq 0x148(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %rax
movq %rax, %rcx
subq %rdi, %rcx
shrq $0x2, %rcx
movq 0x30(%rsp), %rdx
addl %ecx, %edx
movq %rdx, 0x30(%rsp)
jmp 0x7077b
movq 0x18(%rsp), %rax
cmpq %rdi, %rax
je 0x70835
movl $0x1, %r14d
xorl %ecx, %ecx
cmpl $0x1, %r14d
jne 0x707ab
movslq (%rdi), %rcx
movq 0x8(%rsp), %rdx
movq (%rdx), %rdx
leaq (%rcx,%rcx,8), %rcx
movb 0x40(%rdx,%rcx,8), %cl
movb %cl, 0x3(%rsp)
jmp 0x7081c
movb 0x3(%rsp), %dl
andb $0x1, %dl
movslq (%rdi,%rcx,4), %rcx
movq 0x8(%rsp), %rsi
movq (%rsi), %rsi
leaq (%rcx,%rcx,8), %rcx
cmpb 0x40(%rsi,%rcx,8), %dl
je 0x7081c
movl $0xc, %edx
movq 0x1247ec(%rip), %rdi    # 0x194fc0
leaq 0xe3fbf(%rip), %rsi     # 0x15479a
callq 0x44e0
movq 0x1247d9(%rip), %rcx    # 0x194fc0
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x4420
movsbl %al, %esi
movq 0x1247bb(%rip), %rdi    # 0x194fc0
callq 0x4040
movq %rax, %rdi
callq 0x42c0
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %rax
movl %r14d, %ecx
movq %rax, %rdx
subq %rdi, %rdx
sarq $0x2, %rdx
incl %r14d
cmpq %rcx, %rdx
ja 0x7078c
testq %rdi, %rdi
je 0x70847
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0x7085e
movq 0x60(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
incl %ebp
leaq 0xf8(%rsp), %rdi
callq 0x76206
movq 0x38(%rsp), %rax
movq 0x40(%rsp), %rdx
subq %rax, %rdx
sarq $0x2, %rdx
movl %ebp, %r14d
movq %r14, %rsi
cmpq %r14, %rdx
leaq 0xbc(%rsp), %rdi
jne 0x6fffe
jmp 0x708ab
movq %rdx, %r14
movq %rdx, %rsi
jmp 0x708ab
movq $0x0, 0x30(%rsp)
xorl %r14d, %r14d
movq %r12, %rdi
xorl %edx, %edx
callq 0xedc8
movq 0x38(%rsp), %rax
cmpq %rax, 0x40(%rsp)
je 0x70900
movl $0x1, %ebx
xorl %esi, %esi
movl (%rax,%rsi,4), %ebp
movq %r12, %rdi
callq 0xee36
cmpl $0x1, %ebp
jne 0x708dd
orq (%rax), %rdx
jmp 0x708e3
notq %rdx
andq (%rax), %rdx
movq %rdx, (%rax)
movl %ebx, %esi
movq 0x38(%rsp), %rax
movq 0x40(%rsp), %rcx
subq %rax, %rcx
sarq $0x2, %rcx
incl %ebx
cmpq %rsi, %rcx
ja 0x708c8
movq 0xb0(%rsp), %rcx
movq (%rcx), %rax
movq 0x8(%rcx), %rdx
subq %rax, %rdx
je 0x70959
sarq $0x4, %rdx
movabsq $-0x79435e50d79435e5, %rcx # imm = 0x86BCA1AF286BCA1B
imulq %rdx, %rcx
addq $0x108, %rax            # imm = 0x108
xorl %ebx, %ebx
movl $0x1, %edx
xorl %ebp, %ebp
xorl %esi, %esi
xorl %edi, %edi
cmpl $0x0, (%rax)
setle %sil
setg %dil
addl %edi, %ebp
addl %esi, %ebx
movl %edx, %esi
addq $0x130, %rax            # imm = 0x130
incl %edx
cmpq %rsi, %rcx
ja 0x70935
jmp 0x7095d
xorl %ebp, %ebp
xorl %ebx, %ebx
movq 0x12465c(%rip), %rdi    # 0x194fc0
leaq 0xe3e3c(%rip), %rsi     # 0x1547a7
movl $0x16, %edx
callq 0x44e0
movq 0x124644(%rip), %rdi    # 0x194fc0
movq %r14, %rsi
callq 0x42b0
leaq 0xe3e33(%rip), %rsi     # 0x1547be
movl $0x7, %edx
movq %rax, %rdi
callq 0x44e0
movq 0x124621(%rip), %rdi    # 0x194fc0
leaq 0xe3e20(%rip), %rsi     # 0x1547c6
movl $0xc, %edx
callq 0x44e0
movq 0x124609(%rip), %rdi    # 0x194fc0
movl %ebp, %esi
callq 0x4750
movq %rax, %r14
leaq 0xe3e0b(%rip), %rsi     # 0x1547d3
movl $0xe, %edx
movq %rax, %rdi
callq 0x44e0
movq %r14, %rdi
movl %ebx, %esi
callq 0x4750
leaq 0xe3dfc(%rip), %rsi     # 0x1547e2
movl $0xa, %edx
movq %rax, %rdi
callq 0x44e0
movq 0x1245c6(%rip), %rdi    # 0x194fc0
movq 0x30(%rsp), %rsi
callq 0x4750
movq %rax, %rbx
leaq 0xe3ddf(%rip), %rsi     # 0x1547ed
movl $0x1a, %edx
movq %rax, %rdi
callq 0x44e0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x4420
movsbl %al, %esi
movq %rbx, %rdi
callq 0x4040
movq %rax, %rdi
callq 0x42c0
movq 0x38(%rsp), %rdi
testq %rdi, %rdi
je 0x70a59
movq 0x48(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
addq $0x288, %rsp            # imm = 0x288
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xdcc83(%rip), %rdi     # 0x14d6f5
movq %rcx, %rdx
xorl %eax, %eax
callq 0x4630
movq 0x12456d(%rip), %rdi    # 0x194ff0
leaq 0xe3c4b(%rip), %rsi     # 0x1546d5
movl $0x46, %edx
callq 0x44e0
movq 0x124555(%rip), %rdi    # 0x194ff0
leaq 0xe2b7c(%rip), %rsi     # 0x15361e
movl $0x1, %edx
callq 0x44e0
movq 0x12453d(%rip), %rdi    # 0x194ff0
leaq 0xe3c62(%rip), %rsi     # 0x15471c
movl $0x41, %edx
callq 0x44e0
movq 0x124525(%rip), %rdi    # 0x194ff0
leaq 0xe2b4c(%rip), %rsi     # 0x15361e
movl $0x1, %edx
callq 0x44e0
movq 0x12450d(%rip), %rdi    # 0x194ff0
leaq 0xdd0c9(%rip), %rsi     # 0x14dbb3
movl $0xb, %edx
callq 0x44e0
movq 0x1244f5(%rip), %rdi    # 0x194ff0
leaq 0xe2b1c(%rip), %rsi     # 0x15361e
callq 0x4440
movl $0x1, %edi
callq 0x72bc
leaq 0xdcbdd(%rip), %rdi     # 0x14d6f5
movq %r14, %rsi
xorl %eax, %eax
callq 0x4630
leaq 0xdcbcc(%rip), %rdi     # 0x14d6f5
xorl %eax, %eax
callq 0x4630
movq 0x1244b9(%rip), %rdi    # 0x194ff0
leaq 0xe3c20(%rip), %rsi     # 0x15475e
movl $0x3b, %edx
callq 0x44e0
movq 0x1244a1(%rip), %rdi    # 0x194ff0
leaq 0xe2ac8(%rip), %rsi     # 0x15361e
movl $0x1, %edx
callq 0x44e0
movq 0x124489(%rip), %rdi    # 0x194ff0
leaq 0xe3bae(%rip), %rsi     # 0x15471c
movl $0x41, %edx
callq 0x44e0
movq 0x124471(%rip), %rdi    # 0x194ff0
leaq 0xe2a98(%rip), %rsi     # 0x15361e
movl $0x1, %edx
callq 0x44e0
movq 0x124459(%rip), %rdi    # 0x194ff0
leaq 0xdd015(%rip), %rsi     # 0x14dbb3
movl $0xb, %edx
callq 0x44e0
movq 0x124441(%rip), %rdi    # 0x194ff0
leaq 0xe2a68(%rip), %rsi     # 0x15361e
callq 0x4440
jmp 0x70b07
leaq 0xdcb2e(%rip), %rdi     # 0x14d6f5
xorl %eax, %eax
callq 0x4630
movq 0x12441b(%rip), %rdi    # 0x194ff0
leaq 0xe3ac5(%rip), %rsi     # 0x1546a1
movl $0x33, %edx
callq 0x44e0
movq 0x124403(%rip), %rdi    # 0x194ff0
leaq 0xe2a2a(%rip), %rsi     # 0x15361e
callq 0x4440
jmp 0x70b07
movq %rax, %rbx
jmp 0x70c15
jmp 0x70c79
movq %rax, %rbx
leaq 0x150(%rsp), %rdi
callq 0x7602c
movq 0x138(%rsp), %rdi
testq %rdi, %rdi
je 0x70c7c
movq 0x148(%rsp), %rsi
jmp 0x70c58
movq %rax, %rbx
leaq 0x150(%rsp), %rdi
callq 0x7602c
jmp 0x70c43
jmp 0x70c79
movq %rax, %rbx
movq 0xd0(%rsp), %rdi
testq %rdi, %rdi
je 0x70c7c
movq 0xe0(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
jmp 0x70c7c
jmp 0x70c8d
jmp 0x70c6e
jmp 0x70c6e
jmp 0x70c9c
jmp 0x70c79
jmp 0x70c6e
movq %rax, %rbx
jmp 0x70cbc
jmp 0x70c79
jmp 0x70c8d
jmp 0x70c8d
movq %rax, %rbx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x70cbc
movq 0x20(%rsp), %rsi
jmp 0x70cb4
movq %rax, %rbx
jmp 0x70ce0
jmp 0x70c9c
jmp 0x70c9c
jmp 0x70c9c
jmp 0x70c9c
jmp 0x70c9c
movq %rax, %rbx
movq 0x170(%rsp), %rdi
testq %rdi, %rdi
je 0x70cbc
movq 0x180(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0x70cd3
movq 0x60(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
leaq 0xf8(%rsp), %rdi
callq 0x76206
movq 0x38(%rsp), %rdi
testq %rdi, %rdi
je 0x70cf7
movq 0x48(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movq %rbx, %rdi
callq 0x4780
nop