// File: 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
movq %rsp, %rbp
subq $0x740, %rsp            # imm = 0x740
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl $0x1, -0x1c(%rbp)
movl $0x0, -0x20(%rbp)
movl $0xffffffff, -0x24(%rbp) # imm = 0xFFFFFFFF
xorps %xmm0, %xmm0
movaps %xmm0, -0x40(%rbp)
movq $0x0, -0x30(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x658a0
movq -0x8(%rbp), %rdi
callq 0x10100
movq %rax, -0x568(%rbp)
leaq -0x59(%rbp), %rdi
movq %rdi, -0x560(%rbp)
callq 0x10960
movq -0x568(%rbp), %rsi
movq -0x560(%rbp), %rcx
leaq -0x58(%rbp), %rdi
leaq -0x24(%rbp), %rdx
callq 0x65a70
jmp 0xc5641
leaq -0x59(%rbp), %rdi
callq 0x13030
movl $0x0, -0x70(%rbp)
movl $0x0, -0x74(%rbp)
movl $0x0, -0x78(%rbp)
movl $0x0, -0x7c(%rbp)
movl -0x7c(%rbp), %eax
movq %rax, -0x570(%rbp)
movq -0x8(%rbp), %rdi
callq 0x10100
movq %rax, %rcx
movq -0x570(%rbp), %rax
cmpq %rcx, %rax
jae 0xc56f9
movq -0x8(%rbp), %rdi
movl -0x7c(%rbp), %eax
movl %eax, %esi
callq 0x10130
movq %rax, -0x578(%rbp)
jmp 0xc569f
movq -0x578(%rbp), %rax
movb 0x40(%rax), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x1, %eax
jne 0xc56e9
movl -0x74(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x74(%rbp)
jmp 0xc56e9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x59(%rbp), %rdi
callq 0x13030
jmp 0xc672b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0xc6722
jmp 0xc56eb
movl -0x7c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x7c(%rbp)
jmp 0xc5666
movq 0x1ad8c0(%rip), %rdi    # 0x272fc0
leaq 0x135b89(%rip), %rsi    # 0x1fb290
callq 0x5540
movq %rax, -0x580(%rbp)
jmp 0xc5715
movq -0x8(%rbp), %rdi
callq 0x10100
movq -0x580(%rbp), %rdi
movq %rax, %rsi
callq 0x5160
movq %rax, -0x588(%rbp)
jmp 0xc5736
movq -0x588(%rbp), %rdi
leaq 0x135b82(%rip), %rsi    # 0x1fb2c6
callq 0x5540
movq %rax, -0x590(%rbp)
jmp 0xc5752
movq -0x590(%rbp), %rdi
movl -0x74(%rbp), %esi
callq 0x58d0
movq %rax, -0x598(%rbp)
jmp 0xc576a
movq -0x598(%rbp), %rdi
leaq 0x135b59(%rip), %rsi    # 0x1fb2d1
callq 0x5540
movq %rax, -0x5a0(%rbp)
jmp 0xc5786
movq -0x5a0(%rbp), %rdi
movq 0x1ad804(%rip), %rsi    # 0x272f98
callq 0x55b0
jmp 0xc579b
jmp 0xc579d
movl -0x70(%rbp), %eax
movq %rax, -0x5a8(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x10090
movq %rax, %rcx
movq -0x5a8(%rbp), %rax
cmpq %rcx, %rax
je 0xc645d
movl -0x70(%rbp), %eax
movl %eax, %esi
leaq -0x58(%rbp), %rdi
callq 0x101d0
movq %rax, -0x5b0(%rbp)
jmp 0xc57da
movq -0x5b0(%rbp), %rax
cmpl $-0x1, (%rax)
je 0xc57f1
movl -0x70(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x70(%rbp)
jmp 0xc579d
movl $0x0, -0x80(%rbp)
xorps %xmm0, %xmm0
movaps %xmm0, -0xa0(%rbp)
movaps %xmm0, -0xb0(%rbp)
movl $0x0, -0x90(%rbp)
movl $0xffffffff, -0xb4(%rbp) # imm = 0xFFFFFFFF
leaq -0xc0(%rbp), %rdi
xorl %ecx, %ecx
movl %ecx, %esi
movl %ecx, %edx
callq 0x94010
jmp 0xc5831
leaq -0xf0(%rbp), %rdi
callq 0xcd1d0
leaq -0x108(%rbp), %rdi
callq 0xcd1f0
leaq -0x118(%rbp), %rdi
leaq -0x70(%rbp), %rsi
leaq -0xc0(%rbp), %rdx
callq 0xcd240
jmp 0xc5862
leaq -0x108(%rbp), %rdi
leaq -0x118(%rbp), %rsi
callq 0xcd210
jmp 0xc5877
leaq -0x128(%rbp), %rdi
leaq -0x70(%rbp), %rsi
leaq -0xc0(%rbp), %rdx
callq 0xcd240
jmp 0xc5890
leaq -0xf0(%rbp), %rdi
leaq -0x128(%rbp), %rsi
callq 0xcd270
movb %dl, -0x5b9(%rbp)
movq %rax, -0x5b8(%rbp)
jmp 0xc58b2
movb -0x5b9(%rbp), %al
movq -0x5b8(%rbp), %rcx
movq %rcx, -0x138(%rbp)
movb %al, -0x130(%rbp)
leaq -0x108(%rbp), %rdi
callq 0xcd2b0
cmpq $0x0, %rax
je 0xc5f42
leaq -0x108(%rbp), %rdi
callq 0xcd2d0
movups (%rax), %xmm0
movaps %xmm0, -0x150(%rbp)
movq -0x8(%rbp), %rdi
movslq -0x150(%rbp), %rsi
callq 0x10130
movq %rax, -0x5c8(%rbp)
jmp 0xc5911
movq -0x5c8(%rbp), %rsi
leaq -0x198(%rbp), %rdi
callq 0x64400
jmp 0xc5926
leaq -0x108(%rbp), %rdi
callq 0xcd310
leaq -0x198(%rbp), %rdi
addq $0x20, %rdi
callq 0x2a8e0
movq %rax, -0x1a0(%rbp)
leaq -0x198(%rbp), %rdi
addq $0x20, %rdi
callq 0x2a710
movq %rax, -0x1a8(%rbp)
leaq -0x1a0(%rbp), %rdi
leaq -0x1a8(%rbp), %rsi
callq 0x65370
testb $0x1, %al
jne 0xc597c
jmp 0xc5f31
leaq -0x1a0(%rbp), %rdi
movq %rdi, -0x5e8(%rbp)
callq 0x653b0
movq -0x5e8(%rbp), %rdi
movl 0x4(%rax), %eax
movl %eax, -0x1ac(%rbp)
leaq -0x14c(%rbp), %rax
movq %rax, -0x5e0(%rbp)
callq 0x653b0
movq -0x5e0(%rbp), %rdi
movq %rax, %rsi
addq $0x18, %rsi
callq 0x94150
movl %edx, -0x5d4(%rbp)
movq %rax, -0x5d0(%rbp)
jmp 0xc59d4
movl -0x5d4(%rbp), %eax
movq -0x5d0(%rbp), %rcx
movq %rcx, -0x1c8(%rbp)
movl %eax, -0x1c0(%rbp)
movl -0x1c0(%rbp), %eax
movl %eax, -0x1b0(%rbp)
movq -0x1c8(%rbp), %rax
movq %rax, -0x1b8(%rbp)
movslq -0x1ac(%rbp), %rsi
leaq -0x58(%rbp), %rdi
callq 0x101d0
movq %rax, -0x5f0(%rbp)
jmp 0xc5a21
movq -0x5f0(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x1cc(%rbp)
cmpl $-0x1, -0x1cc(%rbp)
jne 0xc5e7a
leaq -0xf0(%rbp), %rdi
leaq -0x1ac(%rbp), %rsi
callq 0xcd340
movq %rax, -0x5f8(%rbp)
jmp 0xc5a59
movq -0x5f8(%rbp), %rax
movq %rax, -0x1d8(%rbp)
leaq -0xf0(%rbp), %rdi
callq 0xcd3a0
movq %rax, -0x1e0(%rbp)
leaq -0x1d8(%rbp), %rdi
leaq -0x1e0(%rbp), %rsi
callq 0xcd370
testb $0x1, %al
jne 0xc5a96
jmp 0xc5dea
leaq -0x1d8(%rbp), %rdi
callq 0xcd3d0
movq %rax, %rdi
addq $0x4, %rdi
movl -0x1b0(%rbp), %eax
movl %eax, -0x1e8(%rbp)
movq -0x1b8(%rbp), %rax
movq %rax, -0x1f0(%rbp)
movl -0x1e8(%rbp), %eax
movl %eax, -0x1f8(%rbp)
movq -0x1f0(%rbp), %rax
movq %rax, -0x200(%rbp)
movq -0x200(%rbp), %rsi
movl -0x1f8(%rbp), %edx
callq 0x94040
movb %al, -0x5f9(%rbp)
jmp 0xc5af7
movb -0x5f9(%rbp), %al
testb $0x1, %al
jne 0xc5b03
jmp 0xc5b36
jmp 0xc5de5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0xc6440
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x198(%rbp), %rdi
callq 0x100e0
jmp 0xc6440
movl $0x1, -0xb4(%rbp)
leaq -0x1d8(%rbp), %rdi
callq 0xcd3d0
movq %rax, %rsi
addq $0x4, %rsi
leaq -0x1b8(%rbp), %rdi
callq 0x941b0
movl %edx, -0x60c(%rbp)
movq %rax, -0x608(%rbp)
jmp 0xc5b6e
movl -0x60c(%rbp), %eax
movq -0x608(%rbp), %rcx
movq %rcx, -0x220(%rbp)
movl %eax, -0x218(%rbp)
movq -0x220(%rbp), %rax
movq %rax, -0x20c(%rbp)
movl -0x218(%rbp), %eax
movl %eax, -0x204(%rbp)
cmpl $0x0, -0x80(%rbp)
jne 0xc5bda
movl -0x20c(%rbp), %eax
movl %eax, -0xb0(%rbp)
movl -0x208(%rbp), %eax
movl %eax, -0xa4(%rbp)
movl -0x204(%rbp), %eax
movl %eax, -0x98(%rbp)
movl -0x80(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x80(%rbp)
jmp 0xc5de3
cmpl $0x1, -0x80(%rbp)
jne 0xc5d53
cmpl $0x0, -0xb0(%rbp)
je 0xc5c1a
cvtsi2sdl -0x20c(%rbp), %xmm1
movsd 0x12c453(%rip), %xmm0   # 0x1f2050
mulsd %xmm1, %xmm0
cvtsi2sdl -0xb0(%rbp), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0x228(%rbp)
jmp 0xc5cbf
cmpl $0x0, -0xa4(%rbp)
je 0xc5c4d
cvtsi2sdl -0x208(%rbp), %xmm1
movsd 0x12c41d(%rip), %xmm0   # 0x1f2050
mulsd %xmm1, %xmm0
cvtsi2sdl -0xa4(%rbp), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0x228(%rbp)
jmp 0xc5cbd
cmpl $0x0, -0x98(%rbp)
je 0xc5c80
cvtsi2sdl -0x204(%rbp), %xmm1
movsd 0x12c3ea(%rip), %xmm0   # 0x1f2050
mulsd %xmm1, %xmm0
cvtsi2sdl -0x98(%rbp), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0x228(%rbp)
jmp 0xc5cbb
movq 0x1ad369(%rip), %rdi    # 0x272ff0
leaq 0x135663(%rip), %rsi    # 0x1fb2f1
callq 0x5540
movq %rax, -0x618(%rbp)
jmp 0xc5c9c
movq -0x618(%rbp), %rdi
leaq 0x13397b(%rip), %rsi    # 0x1f9625
callq 0x5540
jmp 0xc5cb1
movl $0x1, %edi
callq 0x67c0
jmp 0xc5cbd
jmp 0xc5cbf
cvtsi2sdl -0xb0(%rbp), %xmm0
mulsd -0x228(%rbp), %xmm0
cvtsi2sdl -0x20c(%rbp), %xmm1
ucomisd %xmm1, %xmm0
jne 0xc5d21
jp 0xc5d21
cvtsi2sdl -0xa4(%rbp), %xmm0
mulsd -0x228(%rbp), %xmm0
cvtsi2sdl -0x208(%rbp), %xmm1
ucomisd %xmm1, %xmm0
jne 0xc5d21
jp 0xc5d21
cvtsi2sdl -0x98(%rbp), %xmm0
mulsd -0x228(%rbp), %xmm0
cvtsi2sdl -0x204(%rbp), %xmm1
ucomisd %xmm1, %xmm0
jne 0xc5d21
jp 0xc5d21
jmp 0xc5d4e
movl -0x20c(%rbp), %eax
movl %eax, -0xac(%rbp)
movl -0x208(%rbp), %eax
movl %eax, -0xa0(%rbp)
movl -0x204(%rbp), %eax
movl %eax, -0x94(%rbp)
movl -0x80(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x80(%rbp)
jmp 0xc5de1
cmpl $0x2, -0x80(%rbp)
jne 0xc5ddf
movl -0x20c(%rbp), %eax
movl %eax, -0xa8(%rbp)
movl -0x208(%rbp), %eax
movl %eax, -0x9c(%rbp)
movl -0x204(%rbp), %eax
movl %eax, -0x90(%rbp)
leaq -0xb0(%rbp), %rdi
callq 0xe94b0
movl %eax, -0x61c(%rbp)
jmp 0xc5d95
movl -0x61c(%rbp), %eax
movl %eax, %ecx
negl %ecx
cmovnsl %ecx, %eax
cvtsi2sd %eax, %xmm1
movsd 0x130862(%rip), %xmm0   # 0x1f6610
ucomisd %xmm1, %xmm0
jbe 0xc5dd4
movl $0x0, -0x90(%rbp)
movl $0x0, -0x9c(%rbp)
movl $0x0, -0xa8(%rbp)
jmp 0xc5ddd
movl -0x80(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x80(%rbp)
jmp 0xc5ddf
jmp 0xc5de1
jmp 0xc5de3
jmp 0xc5de5
jmp 0xc5e75
leaq -0x238(%rbp), %rdi
leaq -0x1ac(%rbp), %rsi
leaq -0x1b8(%rbp), %rdx
callq 0xcd3f0
jmp 0xc5e06
leaq -0xf0(%rbp), %rdi
leaq -0x238(%rbp), %rsi
callq 0xcd270
movb %dl, -0x629(%rbp)
movq %rax, -0x628(%rbp)
jmp 0xc5e28
movb -0x629(%rbp), %al
movq -0x628(%rbp), %rcx
movq %rcx, -0x248(%rbp)
movb %al, -0x240(%rbp)
leaq -0x258(%rbp), %rdi
leaq -0x1ac(%rbp), %rsi
leaq -0x1b8(%rbp), %rdx
callq 0xcd3f0
jmp 0xc5e5e
leaq -0x108(%rbp), %rdi
leaq -0x258(%rbp), %rsi
callq 0xcd210
jmp 0xc5e73
jmp 0xc5e75
jmp 0xc5f17
movq 0x1ad16f(%rip), %rdi    # 0x272ff0
leaq 0x13549d(%rip), %rsi    # 0x1fb325
callq 0x5540
movq %rax, -0x638(%rbp)
jmp 0xc5e96
movq -0x638(%rbp), %rdi
leaq 0x133781(%rip), %rsi    # 0x1f9625
callq 0x5540
jmp 0xc5eab
movq 0x1ad13e(%rip), %rdi    # 0x272ff0
leaq 0x1354b3(%rip), %rsi    # 0x1fb36c
callq 0x5540
movq %rax, -0x640(%rbp)
jmp 0xc5ec7
movq -0x640(%rbp), %rdi
leaq 0x133750(%rip), %rsi    # 0x1f9625
callq 0x5540
jmp 0xc5edc
movq 0x1ad10d(%rip), %rdi    # 0x272ff0
leaq 0x12cd19(%rip), %rsi    # 0x1f2c03
callq 0x5540
movq %rax, -0x648(%rbp)
jmp 0xc5ef8
movq -0x648(%rbp), %rdi
leaq 0x13371f(%rip), %rsi    # 0x1f9625
callq 0x5540
jmp 0xc5f0d
movl $0x1, %edi
callq 0x67c0
leaq -0x1a0(%rbp), %rdi
xorl %esi, %esi
callq 0x654d0
movq %rax, -0x260(%rbp)
jmp 0xc5949
leaq -0x198(%rbp), %rdi
callq 0x100e0
jmp 0xc58cc
leaq -0x108(%rbp), %rdi
callq 0xcd2b0
cmpq $0x0, %rax
jne 0xc5f67
cmpl $-0x1, -0xb4(%rbp)
jne 0xc5f67
movl $0x0, -0xb4(%rbp)
leaq -0xf0(%rbp), %rdi
callq 0xcd420
movq %rax, -0x268(%rbp)
leaq -0x280(%rbp), %rdi
xorl %esi, %esi
movl $0x18, %edx
callq 0x52a0
leaq -0x280(%rbp), %rdi
callq 0xd0d0
leaq -0xf0(%rbp), %rdi
callq 0xcd3a0
movq %rax, -0x288(%rbp)
leaq -0x268(%rbp), %rdi
leaq -0x288(%rbp), %rsi
callq 0xcd370
testb $0x1, %al
jne 0xc5fc8
jmp 0xc6118
leaq -0x268(%rbp), %rdi
callq 0xcd3d0
movl (%rax), %eax
movl %eax, -0x28c(%rbp)
movslq -0x28c(%rbp), %rsi
leaq -0x58(%rbp), %rdi
callq 0x101d0
movq %rax, -0x650(%rbp)
jmp 0xc5ff5
movq -0x650(%rbp), %rax
cmpl $-0x1, (%rax)
je 0xc60b3
movq 0x1acfe4(%rip), %rdi    # 0x272ff0
leaq 0x13539b(%rip), %rsi    # 0x1fb3ae
callq 0x5540
movq %rax, -0x658(%rbp)
jmp 0xc6021
movq -0x658(%rbp), %rdi
leaq 0x1335f6(%rip), %rsi    # 0x1f9625
callq 0x5540
jmp 0xc6036
movq 0x1acfb3(%rip), %rdi    # 0x272ff0
leaq 0x135328(%rip), %rsi    # 0x1fb36c
callq 0x5540
movq %rax, -0x660(%rbp)
jmp 0xc6052
movq -0x660(%rbp), %rdi
leaq 0x1335c5(%rip), %rsi    # 0x1f9625
callq 0x5540
jmp 0xc6067
movq 0x1acf82(%rip), %rdi    # 0x272ff0
leaq 0x12cb8e(%rip), %rsi    # 0x1f2c03
callq 0x5540
movq %rax, -0x668(%rbp)
jmp 0xc6083
movq -0x668(%rbp), %rdi
leaq 0x133594(%rip), %rsi    # 0x1f9625
callq 0x5540
jmp 0xc6098
movl $0x1, %edi
callq 0x67c0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0xc6434
movl -0xb4(%rbp), %eax
movl %eax, -0x674(%rbp)
movslq -0x28c(%rbp), %rsi
leaq -0x58(%rbp), %rdi
callq 0x101d0
movq %rax, -0x670(%rbp)
jmp 0xc60d8
movq -0x670(%rbp), %rax
movl -0x674(%rbp), %ecx
movl %ecx, (%rax)
leaq -0x280(%rbp), %rdi
leaq -0x28c(%rbp), %rsi
callq 0xd1b0
jmp 0xc60fc
jmp 0xc60fe
leaq -0x268(%rbp), %rdi
xorl %esi, %esi
callq 0xcd450
movq %rax, -0x298(%rbp)
jmp 0xc5f99
movl -0x70(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x70(%rbp)
cmpl $0x1, -0xb4(%rbp)
jne 0xc61f3
movq -0x18(%rbp), %rax
movq %rax, -0x680(%rbp)
leaq -0x3e0(%rbp), %rdi
leaq -0x280(%rbp), %rsi
callq 0xeec0
jmp 0xc614e
movq -0x8(%rbp), %rdx
movl -0x80(%rbp), %ecx
leaq -0x3c8(%rbp), %rdi
leaq -0x3e0(%rbp), %rsi
leaq -0xb0(%rbp), %r8
callq 0xc4280
jmp 0xc6171
movq -0x680(%rbp), %rdi
leaq -0x3c8(%rbp), %rsi
callq 0xcd490
jmp 0xc6186
leaq -0x3c8(%rbp), %rdi
callq 0x14c10
leaq -0x3e0(%rbp), %rdi
callq 0xec80
leaq -0x280(%rbp), %rdi
callq 0x10090
movq %rax, %rcx
movslq -0x78(%rbp), %rax
addq %rcx, %rax
movl %eax, -0x78(%rbp)
jmp 0xc62f2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0xc61e2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x3c8(%rbp), %rdi
callq 0x14c10
leaq -0x3e0(%rbp), %rdi
callq 0xec80
jmp 0xc6434
movq -0x8(%rbp), %rax
movq %rax, -0x688(%rbp)
leaq -0x280(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0xed60
movq -0x688(%rbp), %rdi
movslq (%rax), %rsi
callq 0x2a4c0
movb 0x40(%rax), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x1, %eax
jne 0xc62f0
movq -0x18(%rbp), %rax
movq %rax, -0x690(%rbp)
leaq -0x528(%rbp), %rdi
leaq -0x280(%rbp), %rsi
callq 0xeec0
jmp 0xc624e
movq -0x8(%rbp), %rdx
movl -0x80(%rbp), %ecx
leaq -0x510(%rbp), %rdi
leaq -0x528(%rbp), %rsi
leaq -0xb0(%rbp), %r8
callq 0xc4280
jmp 0xc6271
movq -0x690(%rbp), %rdi
leaq -0x510(%rbp), %rsi
callq 0xcd490
jmp 0xc6286
leaq -0x510(%rbp), %rdi
callq 0x14c10
leaq -0x528(%rbp), %rdi
callq 0xec80
leaq -0x280(%rbp), %rdi
callq 0x10090
movq %rax, %rcx
movslq -0x78(%rbp), %rax
addq %rcx, %rax
movl %eax, -0x78(%rbp)
jmp 0xc62f0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0xc62df
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x510(%rbp), %rdi
callq 0x14c10
leaq -0x528(%rbp), %rdi
callq 0xec80
jmp 0xc6434
jmp 0xc62f2
movl $0x0, -0x530(%rbp)
movl -0x530(%rbp), %eax
movq %rax, -0x698(%rbp)
leaq -0x280(%rbp), %rdi
callq 0x10090
movq %rax, %rcx
movq -0x698(%rbp), %rax
cmpq %rcx, %rax
jae 0xc640b
cmpl $0x0, -0x530(%rbp)
jne 0xc636b
movq -0x8(%rbp), %rax
movq %rax, -0x6a0(%rbp)
leaq -0x280(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0xed60
movq -0x6a0(%rbp), %rdi
movslq (%rax), %rsi
callq 0x2a4c0
movb 0x40(%rax), %al
andb $0x1, %al
movb %al, -0x529(%rbp)
jmp 0xc63f5
movb -0x529(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x6a4(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x6b0(%rbp)
movl -0x530(%rbp), %eax
movl %eax, %esi
leaq -0x280(%rbp), %rdi
callq 0xed60
movq -0x6b0(%rbp), %rdi
movslq (%rax), %rsi
callq 0x2a4c0
movq %rax, %rcx
movl -0x6a4(%rbp), %eax
movb 0x40(%rcx), %cl
andb $0x1, %cl
movzbl %cl, %ecx
cmpl %ecx, %eax
je 0xc63f3
movq 0x1acbf9(%rip), %rdi    # 0x272fc0
leaq 0x13501c(%rip), %rsi    # 0x1fb3ea
callq 0x5540
movq %rax, -0x6b8(%rbp)
jmp 0xc63dc
movq -0x6b8(%rbp), %rdi
movq 0x1acbae(%rip), %rsi    # 0x272f98
callq 0x55b0
jmp 0xc63f1
jmp 0xc63f3
jmp 0xc63f5
jmp 0xc63f7
movl -0x530(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x530(%rbp)
jmp 0xc62fc
leaq -0x280(%rbp), %rdi
callq 0xec80
leaq -0x108(%rbp), %rdi
callq 0xcd4c0
leaq -0xf0(%rbp), %rdi
callq 0xcd520
jmp 0xc579d
leaq -0x280(%rbp), %rdi
callq 0xec80
leaq -0x108(%rbp), %rdi
callq 0xcd4c0
leaq -0xf0(%rbp), %rdi
callq 0xcd520
jmp 0xc6722
movq -0x10(%rbp), %rax
movq %rax, -0x6c0(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x10090
movq -0x6c0(%rbp), %rdi
movq %rax, %rsi
xorl %edx, %edx
callq 0xfea0
jmp 0xc6484
movl $0x0, -0x534(%rbp)
movl -0x534(%rbp), %eax
movq %rax, -0x6c8(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x10090
movq %rax, %rcx
movq -0x6c8(%rbp), %rax
cmpq %rcx, %rax
jae 0xc654f
movl -0x534(%rbp), %eax
movl %eax, %esi
leaq -0x58(%rbp), %rdi
callq 0x101d0
movq %rax, -0x6d0(%rbp)
jmp 0xc64d1
movq -0x6d0(%rbp), %rax
movl (%rax), %eax
subl $0x1, %eax
sete %al
movb %al, -0x6e1(%rbp)
movq -0x10(%rbp), %rdi
movl -0x534(%rbp), %eax
movl %eax, %esi
callq 0xfff0
movq %rdx, -0x6e0(%rbp)
movq %rax, -0x6d8(%rbp)
jmp 0xc6507
movb -0x6e1(%rbp), %al
movq -0x6e0(%rbp), %rcx
movq -0x6d8(%rbp), %rdx
movq %rdx, -0x548(%rbp)
movq %rcx, -0x540(%rbp)
movzbl %al, %esi
andl $0x1, %esi
leaq -0x548(%rbp), %rdi
callq 0x10040
movl -0x534(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x534(%rbp)
jmp 0xc648e
movl $0x0, -0x54c(%rbp)
movl $0x0, -0x550(%rbp)
movl $0x0, -0x554(%rbp)
movl -0x554(%rbp), %eax
movq %rax, -0x6f0(%rbp)
movq -0x18(%rbp), %rdi
callq 0x10230
movq %rax, %rcx
movq -0x6f0(%rbp), %rax
cmpq %rcx, %rax
jae 0xc65f2
movq -0x18(%rbp), %rdi
movl -0x554(%rbp), %eax
movl %eax, %esi
callq 0xcd540
movq %rax, -0x6f8(%rbp)
jmp 0xc65ac
movq -0x6f8(%rbp), %rax
cmpl $0x0, 0x108(%rax)
jle 0xc65cd
movl -0x54c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x54c(%rbp)
jmp 0xc65dc
movl -0x550(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x550(%rbp)
jmp 0xc65de
movl -0x554(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x554(%rbp)
jmp 0xc656d
movq 0x1ac9c7(%rip), %rdi    # 0x272fc0
leaq 0x134df7(%rip), %rsi    # 0x1fb3f7
callq 0x5540
movq %rax, -0x700(%rbp)
jmp 0xc660e
movq -0x700(%rbp), %rdi
movl -0x70(%rbp), %esi
callq 0x56f0
movq %rax, -0x708(%rbp)
jmp 0xc6626
movq -0x708(%rbp), %rdi
leaq 0x134dda(%rip), %rsi    # 0x1fb40e
callq 0x5540
jmp 0xc663b
movq 0x1ac97e(%rip), %rdi    # 0x272fc0
leaq 0x134dcd(%rip), %rsi    # 0x1fb416
callq 0x5540
movq %rax, -0x710(%rbp)
jmp 0xc6657
movq -0x710(%rbp), %rdi
movl -0x54c(%rbp), %esi
callq 0x58d0
movq %rax, -0x718(%rbp)
jmp 0xc6672
movq -0x718(%rbp), %rdi
leaq 0x134da3(%rip), %rsi    # 0x1fb423
callq 0x5540
movq %rax, -0x720(%rbp)
jmp 0xc668e
movq -0x720(%rbp), %rdi
movl -0x550(%rbp), %esi
callq 0x58d0
movq %rax, -0x728(%rbp)
jmp 0xc66a9
movq -0x728(%rbp), %rdi
leaq 0x134d7b(%rip), %rsi    # 0x1fb432
callq 0x5540
jmp 0xc66be
movl -0x78(%rbp), %esi
movq 0x1ac8f8(%rip), %rdi    # 0x272fc0
callq 0x58d0
movq %rax, -0x730(%rbp)
jmp 0xc66d6
movq -0x730(%rbp), %rdi
leaq 0x134d59(%rip), %rsi    # 0x1fb43d
callq 0x5540
movq %rax, -0x738(%rbp)
jmp 0xc66f2
movq -0x738(%rbp), %rdi
movq 0x1ac898(%rip), %rsi    # 0x272f98
callq 0x55b0
jmp 0xc6707
leaq -0x58(%rbp), %rdi
callq 0xec80
leaq -0x40(%rbp), %rdi
callq 0x14c80
addq $0x740, %rsp            # imm = 0x740
popq %rbp
retq
leaq -0x58(%rbp), %rdi
callq 0xec80
leaq -0x40(%rbp), %rdi
callq 0x14c80
movq -0x68(%rbp), %rdi
callq 0x58f0
nopl (%rax)