# Path: modules/run_ast/ast.py
# CPPPATH = 'utils/cpp.exe' if sys.platform == 'win32' else 'cpp'
# ABS_PATH = os.path.dirname(__file__)
# class IdentifyVarDecl(NodeVisitor):
# class RunAstDecl(object):
#     def __init__(self):
#     def getnumberofline(nodecoord):
#     def visit_Decl(self, node):
#     def __init__(self, _cfilepath):
#     def identify_decl(self):
# 
# Path: modules/invariant_tools/pips/translate_pips/translate_pips.py
# class PipsTranslateAnnot(object):
#     def __init__(self):
#     def instprecondinprog(self, _cprogrampath):
#     def hasprecondmorelines(_listcfile, _actualindex):
#     def translatepreconditionpips(self, _precondtext):
# 
# Path: modules/invariant_tools/pagai/translate_inv_pagai/translate_pagai.py
# class TranslatePagai(object):
#     def __init__(self):
#     def removenotprintable(self, __listprogram):
#     def identifyInv(self, __pathprogram):
#     def applyesbmcassume(self, __inv):
#     def writeInvPAGAI(self, __pathprogram, addassume):
# 
# Path: modules/invariant_tools/pagai/generate_inv_pagai/generate_inv_pagai.py
# class GeneratePagaiInv(object):
#     def __init__(self):
#     def generate_inv(self, __pathprogram):
# 
# Path: modules/bmc_check/esbmccheck.py
# class DepthEsbmcCheck(object):
#     def __init__(self):
#     def getlastlinenumfromce(_esbmccepath, _indexliststartsearch):
#     def translatecedata(self, _listlinesfromce):
#     def handletextfrom_ce(self, _stringtxtce, _enablescopecheck):
#     def getfunctnamebylinenum(self, _linenum):
#     def checkscopeextraassume(self, _linenumber):
#     def lastsearchbylinetoassume(_esbmccepath, _indexliststartsearch):
#     def getlastdatafromce(self, _esbmccepath):
#     def addassumeinprogram(self, _cprogrampath):
#     def savelist2file(_pathfile, _list2file):
#     def isdefiniedmemlimit(self):
#     def hasincorrectopesbmc(_esbmcoutput):
#     def hastimeoutfromesbmc(_esbmcoutput):
#     def hassuccessfulfromesbmc(_esbmcoutput):
#     def checkwithkparallel(self, _cprogrampath, _actual_ce, _listtmpfiles):
#     def cleantmpfiles(_listfiles2delete):
#     def kinductioncheck(self, _cprogrampath):
#     def getnumbeginfuncts(_cfilepath):
#     def configureUAPath(self):
#     def execUA(self, _cprogrampath, ua_ops):
#     def execBaseCase(self, _cprogrampath, actual_ce, lastResult):
#     def execForwardCondition(self, _cprogrampath, actual_ce, lastResult, listtmpfiles):
#     def execInductiveStep(self, _cprogrampath, actual_ce, lastResult, listtmpfiles, actual_detphver):
#     def check_witnessresult(self, _listresultwitness):
#     def check_witnessresultUA(self, _listresultwitness):
# 
# Path: modules/gnu_extension/hack_extensions.py
# def countwhiledelimiter(_list, _index):
# def make_pycparser_compatible(data):


import argparse
import shutil
import sys
import os
import commands
import re
import time
import random
import string
import platform
import time
from pipes import quote
from modules.run_ast import ast
from modules.invariant_tools.pips.translate_pips import translate_pips
from modules.invariant_tools.pagai.translate_inv_pagai import translate_pagai
from modules.invariant_tools.pagai.generate_inv_pagai import generate_inv_pagai
from modules.bmc_check import esbmccheck
from modules.gnu_extension import hack_extensions
                inputCFile = rundepthk.rununcrustify(inputCFile)

                # Apply hacking to handle with GNU extensions
                # HackGNUext: Generate a copy the analyzed program to a tmp file
                # now with the extension replaced from .i to .c
                inputCFile = rundepthk.applygnuhack(inputCFile)

            #if args.setOnlyCEUse or args.setInvariantTool == "all":
            rundepthk.use_counter_example = True


            if args.setOnlyCEUse and rundepthk.debug_op:
                print(">> Adopting only the ESBMC counterexample to generate assumes")

            if(args.setInvariantTool == "all"):
                print(">> Adopting PIPS, Pagai and CounterExample to generate assumes")

            codewithinv = ""
            __invgeneration = args.setInvariantTool
            pathcodeinvtranslated = ""
            ERROR_FLAG = False
            if (not args.setOnlyCEUse or args.setInvariantTool == "all") and  (not rundepthk.esbmc_is_termination and not rundepthk.esbmc_is_memory_safety):
                try:
                    # Choose invariant generation __invgeneration
                    # Applying steps of DepthK
                    runtranspagai = translate_pagai.TranslatePagai()
                    if __invgeneration == "pagai" or __invgeneration == "all":
                        # Generate invariants
                        if rundepthk.debug_op:
                            print(">> Running PAGAI to generate the invariants")

# Path: modules/run_ast/ast.py
# CPPPATH = 'utils/cpp.exe' if sys.platform == 'win32' else 'cpp'
# ABS_PATH = os.path.dirname(__file__)
# class IdentifyVarDecl(NodeVisitor):
# class RunAstDecl(object):
#     def __init__(self):
#     def getnumberofline(nodecoord):
#     def visit_Decl(self, node):
#     def __init__(self, _cfilepath):
#     def identify_decl(self):
# 
# Path: modules/invariant_tools/pips/translate_pips/translate_pips.py
# class PipsTranslateAnnot(object):
#     def __init__(self):
#     def instprecondinprog(self, _cprogrampath):
#     def hasprecondmorelines(_listcfile, _actualindex):
#     def translatepreconditionpips(self, _precondtext):
# 
# Path: modules/invariant_tools/pagai/translate_inv_pagai/translate_pagai.py
# class TranslatePagai(object):
#     def __init__(self):
#     def removenotprintable(self, __listprogram):
#     def identifyInv(self, __pathprogram):
#     def applyesbmcassume(self, __inv):
#     def writeInvPAGAI(self, __pathprogram, addassume):
# 
# Path: modules/invariant_tools/pagai/generate_inv_pagai/generate_inv_pagai.py
# class GeneratePagaiInv(object):
#     def __init__(self):
#     def generate_inv(self, __pathprogram):
# 
# Path: modules/bmc_check/esbmccheck.py
# class DepthEsbmcCheck(object):
#     def __init__(self):
#     def getlastlinenumfromce(_esbmccepath, _indexliststartsearch):
#     def translatecedata(self, _listlinesfromce):
#     def handletextfrom_ce(self, _stringtxtce, _enablescopecheck):
#     def getfunctnamebylinenum(self, _linenum):
#     def checkscopeextraassume(self, _linenumber):
#     def lastsearchbylinetoassume(_esbmccepath, _indexliststartsearch):
#     def getlastdatafromce(self, _esbmccepath):
#     def addassumeinprogram(self, _cprogrampath):
#     def savelist2file(_pathfile, _list2file):
#     def isdefiniedmemlimit(self):
#     def hasincorrectopesbmc(_esbmcoutput):
#     def hastimeoutfromesbmc(_esbmcoutput):
#     def hassuccessfulfromesbmc(_esbmcoutput):
#     def checkwithkparallel(self, _cprogrampath, _actual_ce, _listtmpfiles):
#     def cleantmpfiles(_listfiles2delete):
#     def kinductioncheck(self, _cprogrampath):
#     def getnumbeginfuncts(_cfilepath):
#     def configureUAPath(self):
#     def execUA(self, _cprogrampath, ua_ops):
#     def execBaseCase(self, _cprogrampath, actual_ce, lastResult):
#     def execForwardCondition(self, _cprogrampath, actual_ce, lastResult, listtmpfiles):
#     def execInductiveStep(self, _cprogrampath, actual_ce, lastResult, listtmpfiles, actual_detphver):
#     def check_witnessresult(self, _listresultwitness):
#     def check_witnessresultUA(self, _listresultwitness):
# 
# Path: modules/gnu_extension/hack_extensions.py
# def countwhiledelimiter(_list, _index):
# def make_pycparser_compatible(data):


# Path: depthk.py
import argparse
import shutil
import sys
import os
import commands
import re
import time
import random
import string
import platform
import time
from pipes import quote
from modules.run_ast import ast
from modules.invariant_tools.pips.translate_pips import translate_pips
from modules.invariant_tools.pagai.translate_inv_pagai import translate_pagai
from modules.invariant_tools.pagai.generate_inv_pagai import generate_inv_pagai
from modules.bmc_check import esbmccheck
from modules.gnu_extension import hack_extensions

                inputCFile = rundepthk.rununcrustify(inputCFile)

                # Apply hacking to handle with GNU extensions
                # HackGNUext: Generate a copy the analyzed program to a tmp file
                # now with the extension replaced from .i to .c
                inputCFile = rundepthk.applygnuhack(inputCFile)

            #if args.setOnlyCEUse or args.setInvariantTool == "all":
            rundepthk.use_counter_example = True


            if args.setOnlyCEUse and rundepthk.debug_op:
                print(">> Adopting only the ESBMC counterexample to generate assumes")

            if(args.setInvariantTool == "all"):
                print(">> Adopting PIPS, Pagai and CounterExample to generate assumes")

            codewithinv = ""
            __invgeneration = args.setInvariantTool
            pathcodeinvtranslated = ""
            ERROR_FLAG = False
            if (not args.setOnlyCEUse or args.setInvariantTool == "all") and  (not rundepthk.esbmc_is_termination and not rundepthk.esbmc_is_memory_safety):
                try:
                    # Choose invariant generation __invgeneration
                    # Applying steps of DepthK
                    runtranspagai = translate_pagai.TranslatePagai()
                    if __invgeneration == "pagai" or __invgeneration == "all":
                        # Generate invariants
                        if rundepthk.debug_op:
                            print(">> Running PAGAI to generate the invariants")

                        geninvpagai = generate_inv_pagai.GeneratePagaiInv()