private static ResultCounter VerifyFiles(List <string> fileNames)
        {
            Contract.Requires(cce.NonNullElements(fileNames));

            Program program = Utilities.IO.ParseBoogieProgram(fileNames, false);

            if (program == null)
            {
                return(ResultCounter.GetNewCounterWithInputError());
            }

            KernelAnalyser.PipelineOutcome oc = KernelAnalyser.ResolveAndTypecheck(program, fileNames[fileNames.Count - 1]);
            if (oc != KernelAnalyser.PipelineOutcome.ResolvedAndTypeChecked)
            {
                return(ResultCounter.GetNewCounterWithInputError());
            }

            KernelAnalyser.EliminateDeadVariables(program);
            KernelAnalyser.Inline(program);
            KernelAnalyser.CheckForQuantifiersAndSpecifyLogic(program);

            CommandLineOptions.Clo.PrintUnstructured = 2;

            if (CommandLineOptions.Clo.LoopUnrollCount != -1)
            {
                Debug.Assert(!CommandLineOptions.Clo.ContractInfer);
                program.UnrollLoops(CommandLineOptions.Clo.LoopUnrollCount, CommandLineOptions.Clo.SoundLoopUnrolling);
            }

            return(VerifyProgram(program));
        }
        private static ResultCounter VerifyProgram(Program program)
        {
            var counters = default(ResultCounter);

            ConditionGeneration vcgen = null;

            try
            {
                vcgen = new VCGen(program, CommandLineOptions.Clo.SimplifyLogFilePath, CommandLineOptions.Clo.SimplifyLogFileAppend, new List <Checker>());
            }
            catch (ProverException e)
            {
                Utilities.IO.ErrorWriteLine("Fatal Error: ProverException: {0}", e);
                return(ResultCounter.GetNewCounterWithInternalError());
            }

            // operate on a stable copy, in case it gets updated while we're running
            var decls = program.TopLevelDeclarations.ToArray();

            foreach (Declaration decl in decls)
            {
                Contract.Assert(decl != null);

                int prevAssertionCount = vcgen.CumulativeAssertionCount;

                Implementation impl = decl as Implementation;
                if (impl != null && CommandLineOptions.Clo.UserWantsToCheckRoutine(cce.NonNull(impl.Name)) && !impl.SkipVerification)
                {
                    List <Counterexample> errors;

                    DateTime start = default(DateTime);  // to please compiler's definite assignment rules
                    if (CommandLineOptions.Clo.Trace)
                    {
                        start = DateTime.UtcNow;
                        if (CommandLineOptions.Clo.Trace)
                        {
                            Console.WriteLine();
                            Console.WriteLine("Verifying {0} ...", impl.Name);
                        }
                    }

                    VCGen.Outcome outcome;
                    try
                    {
                        outcome = vcgen.VerifyImplementation(impl, out errors);
                    }
                    catch (VCGenException e)
                    {
                        Utilities.IO.ReportBplError(impl, string.Format("Error BP5010: {0}  Encountered in implementation {1}.", e.Message, impl.Name), true, true);
                        errors  = null;
                        outcome = VCGen.Outcome.Inconclusive;
                    }
                    catch (UnexpectedProverOutputException upo)
                    {
                        Utilities.IO.AdvisoryWriteLine("Advisory: {0} SKIPPED because of internal error: unexpected prover output: {1}", impl.Name, upo.Message);
                        errors  = null;
                        outcome = VCGen.Outcome.Inconclusive;
                    }

                    string   timeIndication = string.Empty;
                    DateTime end            = DateTime.UtcNow;
                    TimeSpan elapsed        = end - start;
                    if (CommandLineOptions.Clo.Trace)
                    {
                        int poCount = vcgen.CumulativeAssertionCount - prevAssertionCount;
                        timeIndication = string.Format(
                            "  [{0:F3} s, {1} proof {2}]  ",
                            elapsed.TotalSeconds,
                            poCount,
                            poCount == 1 ? "obligation" : "obligations");
                    }

                    KernelAnalyser.ProcessOutcome(program, impl.Name, outcome, errors, timeIndication, ref counters);

                    if (outcome == VCGen.Outcome.Errors || CommandLineOptions.Clo.Trace)
                    {
                        Console.Out.Flush();
                    }
                }
            }

            vcgen.Close();
            cce.NonNull(CommandLineOptions.Clo.TheProverFactory).Close();

            Utilities.IO.WriteTrailer(counters);
            return(counters);
        }