private void lastStep() {

        System.out.println("\n\nbefore: "+cfg);

        HashMap<Statement, List<Statement>> intersectLatestAndUsedOut = new HashMap<Statement, List<Statement>>();
        for(BaseBlock bb: cfg.getAllBaseBlocks()) {
            List<Statement> bbS = bb.getStatements();
            List<Statement> newListStatements = new LinkedList<Statement>();
            newListStatements.addAll(bbS);

            for (Statement s : bbS) {
                intersectLatestAndUsedOut.put(s, new LinkedList<Statement>());
                intersectLatestAndUsedOut.get(s).addAll(deleteTheSame(helpIntersect(latest.get(s), usedOut.get(s))));


                for (Statement n : intersectLatestAndUsedOut.get(s)) {
                    switch (n.baseOperation) {
                        case BINATY_OPERATION:
                            BinaryOperationStatement b = (BinaryOperationStatement) n;
                            Operand newOp = new TmpVariableOperand(b.lhv.type(), VarTable);//new TmpVariableOperand(VariableOperand, )
                            Statement newSt = new BinaryOperationStatement(b.leftOperand, b.rightOperand, newOp, b.operation);
                            System.out.println("new statement to insert: " + newSt);
                            newListStatements.add(newListStatements.indexOf(s), newSt);
                            newStatements.add(newSt);
                            //System.out.println("changed BB: "+ newListStatements);
                            whereToReplace.put(newSt, false);
                            break;
                        case UNARY_OPERATION:
                            UnaryOperationStatement u = (UnaryOperationStatement) n;
                            Operand newO = new TmpVariableOperand(u.lhv.type(), VarTable);//new TmpVariableOperand(VariableOperand, )
                            Statement newS = new UnaryOperationStatement((VariableOperand)newO, u.rhv, u.operation);
                            System.out.println("new statement to insert: " + newS);
                            newListStatements.add(newListStatements.indexOf(s), newS);
                            newStatements.add(newS);

                            whereToReplace.put(newS, false);
                            break;
                        default:
                            System.out.println("expression expected, but " + n + " found");
                    }
                }

                whereToReplace.put(s, false);
                if (usedOut.get(s) != null) {
                    boolean add = false;
                    for (Statement l : usedOut.get(s))
                        if (compareExpressions(s, l))
                            add = true;
                    if (add)
                        whereToReplace.put(s, true);
                }
                if (latest.get(s) == null) {
                    if (isExpression(s))
                        whereToReplace.put(s, true);
                } else {
                    boolean add = true;
                    for (Statement l : latest.get(s))
                        if (compareExpressions(s, l))
                            add = false;
                    if (add && isExpression(s))
                        whereToReplace.put(s, true);
                }


            }
            bb.statements.clear(); bb.statements.addAll(newListStatements);
            //System.out.println("changed BB: "+ bb);
        }


        for(BaseBlock bb: cfg.getAllBaseBlocks())
            for(Statement s: bb.getStatements()) {
                //System.out.println("insert before: " + s + "\t\t ex: " + intersectLatestAndUsedOut.get(s));
            }
        for(BaseBlock bb: cfg.getAllBaseBlocks())
            for(Statement s: bb.getStatements()) {
                //System.out.println("\t\t\t\t\t\t\treplace: " + s + "\t- "+whereToReplace.get(s));
            }



        HashMap<BaseBlock, List<Statement>> bbToStatements = new HashMap<BaseBlock, List<Statement>>();
        for(BaseBlock bb: cfg.getAllBaseBlocks()) {
            List<Statement> bbS = bb.getStatements();
            List<Statement> newListStatements = new LinkedList<Statement>();
            newListStatements.addAll(bbS);

            for (Statement s : bbS) {
                if (whereToReplace.get(s)) {
                    switch (s.baseOperation) {
                        case BINATY_OPERATION:
                            BinaryOperationStatement bin = (BinaryOperationStatement) s;
                            Statement as = new AssignmentStatement((VariableOperand) bin.lhv, findOperand(s));
                            newListStatements.add(newListStatements.indexOf(s), as);
                            newListStatements.remove(s);
                            break;
                        case UNARY_OPERATION:
                            UnaryOperationStatement u = (UnaryOperationStatement) s;
                            Statement ass = new AssignmentStatement((VariableOperand) u.lhv, findOperand(s));
                            newListStatements.add(newListStatements.indexOf(s), ass);
                            newListStatements.remove(s);
                            break;
                    }
                }
                bbToStatements.put(bb, newListStatements);
                //bb.statements.clear(); bb.statements.addAll(newListStatements);
            }
        }
        for(BaseBlock bb: bbToStatements.keySet()) {
            bb.getStatements().clear(); bb.getStatements().addAll(bbToStatements.get(bb));
            //System.out.println("after replace BB: "+ bb);
        }

        //for(BaseBlock b: cfg.getAllBaseBlocks())
            System.out.println("\n\nafter: "+cfg);
    }