private bool OpenBlock(BasicBlock block, OneExpression expression)
            {
                var stack = new Stack <(BasicBlock block, List <BasicBlock> way)>();

                foreach (var bblock in graph.GetParentsBasicBlocks(graph.VertexOf(block)))
                {
                    var way = new List <BasicBlock>()
                    {
                        bblock.block
                    };
                    stack.Push((bblock.block, way));
                }
                while (stack.Count != 0)
                {
                    var element = stack.Pop();
                    if (!IsContainedInListOfInstr(element.block.GetInstructions(), expression, element.block))
                    {
                        foreach (var parent in graph.GetParentsBasicBlocks(graph.VertexOf(element.block)))
                        {
                            if (parent.block == targetBlock)
                            {
                                return(false);
                            }
                            if (!element.way.Contains(parent.block))
                            {
                                stack.Push((parent.block, new List <BasicBlock>(element.way)
                                {
                                    parent.block
                                }));
                            }
                        }
                    }
                }
                return(true);
            }
 private bool InstructionContainsExpression(Instruction instruction, OneExpression expression)
 =>
 instruction.Operation == expression.Operation && (instruction.Operation == "MINUS" || instruction.Operation == "DIV") &&
 instruction.Argument1 == expression.Argument1 && instruction.Argument2 == expression.Argument2
 ||
 instruction.Operation == expression.Operation && (instruction.Operation != "MINUS" || instruction.Operation != "DIV") &&
 (instruction.Argument1 == expression.Argument1 && instruction.Argument2 == expression.Argument2 ||
  instruction.Argument1 == expression.Argument2 && instruction.Argument2 == expression.Argument1);
 private bool IsContainedInListOfInstr(IReadOnlyList <Instruction> instructions,
                                       OneExpression expression,
                                       BasicBlock block)
 {
     for (var i = instructions.Count - 1; i >= 0; i--)
     {
         if (InstructionContainsExpression(instructions[i], expression))
         {
             if (!listOfPointsInBlock.Select(element => element.block).Contains(block))
             {
                 listOfPointsInBlock.Add((block, i, instructions[i]));
 private static void GetU(ControlFlowGraph graph)
 {
     foreach (var block in graph.GetCurrentBasicBlocks())
     {
         foreach (var instruction in block.GetInstructions())
         {
             if (operationTypes.Contains(instruction.Operation))
             {
                 var newExpr = new OneExpression(instruction);
                 if (!UniversalSet.Contains(newExpr, new ExpressionEqualityComparer()))
                 {
                     UniversalSet.Add(newExpr);
                 }
             }
         }
     }
 }
 private void Get_e_gen(ControlFlowGraph graph)
 {
     foreach (var block in graph.GetCurrentBasicBlocks())
     {
         var s = new List <OneExpression>();
         foreach (var instruction in block.GetInstructions())
         {
             if (operationTypes.Contains(instruction.Operation))
             {
                 var newExpr = new OneExpression(instruction);
                 if (!s.Contains(newExpr))
                 {
                     s.Add(newExpr);
                 }
             }
         }
         e_gen.Add(block, s);
     }
 }
 private bool ContainsExpressionInInstructions(List <Instruction> instructions, OneExpression expression)
 {
     for (var i = 0; i < instructions.Count; i++)
     {
         if (InstructionContainsExpression(instructions[i], expression))
         {
             targetInstructionIndex = i;
             return(true);
         }
     }
     return(false);
 }