private static ISet <CFGEdge> IdentifyBackEdges(ControlFlowGraph cfg)
        {
            var back_edges = new HashSet <CFGEdge>();

            foreach (var node in cfg.Nodes)
            {
                foreach (var succ in node.Successors)
                {
                    if (node.Dominators.Contains(succ))
                    {
                        var edge = new CFGEdge(node, succ);
                        back_edges.Add(edge);
                    }
                }
            }

            return(back_edges);
        }
        private static CFGLoop IdentifyLoop(CFGEdge back_edge)
        {
            var loop  = new CFGLoop(back_edge.Target);
            var nodes = new Stack <CFGNode>();

            nodes.Push(back_edge.Source);

            do
            {
                var node     = nodes.Pop();
                var new_node = loop.Body.Add(node);

                if (new_node)
                {
                    foreach (var pred in node.Predecessors)
                    {
                        nodes.Push(pred);
                    }
                }
            }while (nodes.Count > 0);

            return(loop);
        }